45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
|
if ([show isEqual: @"xa"])
return 4;
OF_ENSURE(0);
}
@implementation XMPPPresence
@dynamic type;
+ (instancetype)presence
{
return [[[self alloc] init] autorelease];
}
+ (instancetype)presenceWithID: (OFString*)ID
+ (instancetype)presenceWithID: (OFString *)ID
{
return [[[self alloc] initWithID: ID] autorelease];
}
+ (instancetype)presenceWithType: (OFString*)type
+ (instancetype)presenceWithType: (OFString *)type
{
return [[[self alloc] initWithType: type] autorelease];
}
+ (instancetype)presenceWithType: (OFString*)type
ID: (OFString*)ID
+ (instancetype)presenceWithType: (OFString *)type
ID: (OFString *)ID
{
return [[[self alloc] initWithType: type
ID: ID] autorelease];
}
- init
{
return [self initWithType: nil
ID: nil];
}
- initWithID: (OFString*)ID
- initWithID: (OFString *)ID
{
return [self initWithType: nil
ID: ID];
}
- initWithType: (OFString*)type
- initWithType: (OFString *)type
{
return [self initWithType: type
ID: nil];
}
- initWithType: (OFString*)type
ID: (OFString*)ID
- initWithType: (OFString *)type
ID: (OFString *)ID
{
return [super initWithName: @"presence"
type: type
ID: ID];
}
- initWithElement: (OFXMLElement*)element
- initWithElement: (OFXMLElement *)element
{
self = [super initWithElement: element];
@try {
OFXMLElement *subElement;
if ((subElement = [element elementForName: @"show"
|
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
-
+
-
-
+
+
-
+
-
+
-
-
-
-
-
-
+
-
-
-
-
-
-
+
-
+
-
-
-
-
-
-
+
|
[_status release];
[_show release];
[_priority release];
[super dealloc];
}
- (OFString*)type
- (void)setType: (OFString *)type
{
if (_type == nil)
return @"available";
if (type == nil)
type = @"available";
return [[_type copy] autorelease];
[super setType: type];
}
- (void)setShow: (OFString*)show
- (void)setShow: (OFString *)show
{
OFXMLElement *oldShow = [self elementForName: @"show"
namespace: XMPP_NS_CLIENT];
OFString *old;
if (oldShow != nil)
[self removeChild: oldShow];
if (show != nil)
[self addChild: [OFXMLElement elementWithName: @"show"
namespace: XMPP_NS_CLIENT
stringValue: show]];
old = _show;
_show = [show copy];
[old release];
}
- (OFString*)show
{
return [[_show copy] autorelease];
}
- (void)setStatus: (OFString*)status
- (void)setStatus: (OFString *)status
{
OFXMLElement *oldStatus = [self elementForName: @"status"
namespace: XMPP_NS_CLIENT];
OFString *old;
if (oldStatus != nil)
[self removeChild: oldStatus];
if (status != nil)
[self addChild: [OFXMLElement elementWithName: @"status"
namespace: XMPP_NS_CLIENT
stringValue: status]];
old = _status;
_status = [status copy];
[old release];
}
- (OFString*)status
{
return [[_status copy] autorelease];
}
- (void)setPriority: (OFNumber*)priority
- (void)setPriority: (OFNumber *)priority
{
intmax_t prio = [priority intMaxValue];
OFNumber *old;
if ((prio < -128) || (prio > 127))
@throw [OFInvalidArgumentException exception];
OFXMLElement *oldPriority = [self elementForName: @"priority"
namespace: XMPP_NS_CLIENT];
if (oldPriority != nil)
[self removeChild: oldPriority];
OFString* priority_s =
OFString *priority_s =
[OFString stringWithFormat: @"%" @PRId8, [priority int8Value]];
[self addChild: [OFXMLElement elementWithName: @"priority"
namespace: XMPP_NS_CLIENT
stringValue: priority_s]];
old = _priority;
_priority = [priority copy];
[old release];
}
- (OFNumber*)priority
{
return [[_priority copy] autorelease];
}
- (of_comparison_result_t)compare: (id <OFComparing>)object
{
XMPPPresence *otherPresence;
OFNumber *otherPriority;
OFString *otherShow;
of_comparison_result_t priorityOrder;
if (object == self)
return OF_ORDERED_SAME;
if (![object isKindOfClass: [XMPPPresence class]])
@throw [OFInvalidArgumentException exception];
otherPresence = (XMPPPresence*)object;
otherPresence = (XMPPPresence *)object;
otherPriority = [otherPresence priority];
if (otherPriority == nil)
otherPriority = [OFNumber numberWithInt8: 0];
if (_priority != nil)
priorityOrder = [_priority compare: otherPriority];
else
|