-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathXMPPPresence.m
64 lines (52 loc) · 1.13 KB
/
XMPPPresence.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#import "XMPPPresence.h"
#import "NSXMLElementAdditions.h"
@implementation XMPPPresence
+ (XMPPPresence *)presenceFromElement:(NSXMLElement *)element
{
XMPPPresence *result = (XMPPPresence *)element;
result->isa = [XMPPPresence class];
return result;
}
- (id)initWithType:(NSString *)type to:(XMPPJID *)to
{
if(self = [super initWithName:@"presence"])
{
[self addAttributeWithName:@"type" stringValue:type];
[self addAttributeWithName:@"to" stringValue:[to description]];
}
return self;
}
- (NSString *)type
{
NSString *type = [[self attributeForName:@"type"] stringValue];
if(type)
return type;
else
return @"available";
}
- (NSString *)show
{
return [[self elementForName:@"show"] stringValue];
}
- (NSString *)status
{
return [[self elementForName:@"status"] stringValue];
}
- (int)priority
{
return [[[self elementForName:@"priority"] stringValue] intValue];
}
- (int)intShow
{
NSString *show = [self show];
if([show isEqualToString:@"dnd"])
return 0;
if([show isEqualToString:@"xa"])
return 1;
if([show isEqualToString:@"away"])
return 2;
if([show isEqualToString:@"chat"])
return 4;
return 3;
}
@end