ObjXMPP  Diff

Differences From Artifact [2470b625ea]:

To Artifact [cd7ef53266]:


44
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

@implementation XMPPPresence
+ presence
{
	return [[[self alloc] init] autorelease];
}

+ presenceWithID: (OFString*)ID_
{
	return [[[self alloc] initWithID: ID_] autorelease];
}

+ presenceWithType: (OFString*)type_
{
	return [[[self alloc] initWithType: type_] autorelease];
}

+ presenceWithType: (OFString*)type_
		ID: (OFString*)ID_
{
	return [[[self alloc] initWithType: type_
					ID: ID_] autorelease];
}

- init
{
	return [self initWithType: nil
			       ID: nil];
}

- initWithID: (OFString*)ID_
{
	return [self initWithType: nil
			       ID: ID_];
}

- initWithType: (OFString*)type_
{
	return [self initWithType: type_
			       ID: nil];
}

- initWithType: (OFString*)type_
	    ID: (OFString*)ID_
{
	return [super initWithName: @"presence"
			      type: type_
				ID: ID_];
}

- initWithElement: (OFXMLElement*)element
{
	self = [super initWithElement: element];

	@try {







|

|


|

|


|
|

|
|








|


|


|

|



|
|


|
|







44
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

@implementation XMPPPresence
+ presence
{
	return [[[self alloc] init] autorelease];
}

+ presenceWithID: (OFString*)ID
{
	return [[[self alloc] initWithID: ID] autorelease];
}

+ presenceWithType: (OFString*)type
{
	return [[[self alloc] initWithType: type] autorelease];
}

+ presenceWithType: (OFString*)type
		ID: (OFString*)ID
{
	return [[[self alloc] initWithType: type
					ID: ID] autorelease];
}

- init
{
	return [self initWithType: nil
			       ID: nil];
}

- initWithID: (OFString*)ID
{
	return [self initWithType: nil
			       ID: ID];
}

- initWithType: (OFString*)type
{
	return [self initWithType: type
			       ID: nil];
}

- initWithType: (OFString*)type
	    ID: (OFString*)ID
{
	return [super initWithName: @"presence"
			      type: type
				ID: ID];
}

- initWithElement: (OFXMLElement*)element
{
	self = [super initWithElement: element];

	@try {
118
119
120
121
122
123
124
125
126
127
128
129
130
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

	return self;
}


- (void)dealloc
{
	[status release];
	[show release];
	[priority release];

	[super dealloc];
}

- (OFString*)type
{
	if (type == nil)
		return @"available";

	return [[type copy] autorelease];
}

- (void)setShow: (OFString*)show_
{
	OFXMLElement *oldShow = [self elementForName: @"show"
					   namespace: XMPP_NS_CLIENT];

	if (oldShow != nil)
		[self removeChild: oldShow];

	if (show_ != nil)
		[self addChild: [OFXMLElement elementWithName: @"show"
						    namespace: XMPP_NS_CLIENT
						  stringValue: show_]];

	OF_SETTER(show, show_, YES, 1);
}

- (OFString*)show
{
	return [[show copy] autorelease];
}

- (void)setStatus: (OFString*)status_
{
	OFXMLElement *oldStatus = [self elementForName: @"status"
					     namespace: XMPP_NS_CLIENT];

	if (oldStatus != nil)
		[self removeChild: oldStatus];

	if (status_ != nil)
		[self addChild: [OFXMLElement elementWithName: @"status"
						    namespace: XMPP_NS_CLIENT
						  stringValue: status_]];

	OF_SETTER(status, status_, YES, 1);
}

- (OFString*)status
{
	return [[status copy] autorelease];
}

- (void)setPriority: (OFNumber*)priority_
{
	intmax_t prio = [priority_ intMaxValue];

	if ((prio < -128) || (prio > 127))
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	OFXMLElement *oldPriority = [self elementForName: @"priority"
					       namespace: XMPP_NS_CLIENT];

	if (oldPriority != nil)
		[self removeChild: oldPriority];

	OFString* priority_s =
	    [OFString stringWithFormat: @"%" @PRId8, [priority_ int8Value]];
	[self addChild: [OFXMLElement elementWithName: @"priority"
					    namespace: XMPP_NS_CLIENT
					  stringValue: priority_s]];

	OF_SETTER(priority, priority_, YES, 1);
}

- (OFString*)priority
{
	return [[priority copy] autorelease];
}

- (of_comparison_result_t)compare: (id <OFComparing>)object
{
	XMPPPresence *otherPresence;
	OFNumber *otherPriority;
	OFString *otherShow;







|
|
|






|


|


|







|


|

|




|


|







|


|

|




|


|

|













|




|


|

|







118
119
120
121
122
123
124
125
126
127
128
129
130
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

	return self;
}


- (void)dealloc
{
	[_status release];
	[_show release];
	[_priority release];

	[super dealloc];
}

- (OFString*)type
{
	if (_type == nil)
		return @"available";

	return [[_type copy] autorelease];
}

- (void)setShow: (OFString*)show
{
	OFXMLElement *oldShow = [self elementForName: @"show"
					   namespace: XMPP_NS_CLIENT];

	if (oldShow != nil)
		[self removeChild: oldShow];

	if (show != nil)
		[self addChild: [OFXMLElement elementWithName: @"show"
						    namespace: XMPP_NS_CLIENT
						  stringValue: show]];

	OF_SETTER(_show, show, YES, 1);
}

- (OFString*)show
{
	return [[_show copy] autorelease];
}

- (void)setStatus: (OFString*)status
{
	OFXMLElement *oldStatus = [self elementForName: @"status"
					     namespace: XMPP_NS_CLIENT];

	if (oldStatus != nil)
		[self removeChild: oldStatus];

	if (status != nil)
		[self addChild: [OFXMLElement elementWithName: @"status"
						    namespace: XMPP_NS_CLIENT
						  stringValue: status]];

	OF_SETTER(_status, status, YES, 1);
}

- (OFString*)status
{
	return [[_status copy] autorelease];
}

- (void)setPriority: (OFNumber*)priority
{
	intmax_t prio = [priority intMaxValue];

	if ((prio < -128) || (prio > 127))
		@throw [OFInvalidArgumentException
		    exceptionWithClass: [self class]
			      selector: _cmd];

	OFXMLElement *oldPriority = [self elementForName: @"priority"
					       namespace: XMPP_NS_CLIENT];

	if (oldPriority != nil)
		[self removeChild: oldPriority];

	OFString* priority_s =
	    [OFString stringWithFormat: @"%" @PRId8, [priority int8Value]];
	[self addChild: [OFXMLElement elementWithName: @"priority"
					    namespace: XMPP_NS_CLIENT
					  stringValue: priority_s]];

	OF_SETTER(_priority, priority, YES, 1);
}

- (OFNumber*)priority
{
	return [[_priority copy] autorelease];
}

- (of_comparison_result_t)compare: (id <OFComparing>)object
{
	XMPPPresence *otherPresence;
	OFNumber *otherPriority;
	OFString *otherShow;
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
			      selector: _cmd];

	otherPresence = (XMPPPresence*)object;
	otherPriority = [otherPresence priority];
	if (otherPriority == nil)
		otherPriority = [OFNumber numberWithInt8: 0];

	if (priority != nil)
		priorityOrder = [priority compare: otherPriority];
	else
		priorityOrder =
		    [[OFNumber numberWithInt8: 0] compare: otherPriority];

	if (priorityOrder != OF_ORDERED_SAME)
		return priorityOrder;

	otherShow = [otherPresence show];
	if ([show isEqual: otherShow])
		return OF_ORDERED_SAME;

	if (show_to_int(show) < show_to_int(otherShow))
		return OF_ORDERED_ASCENDING;

	return OF_ORDERED_DESCENDING;
}
@end







|
|








|


|





224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
			      selector: _cmd];

	otherPresence = (XMPPPresence*)object;
	otherPriority = [otherPresence priority];
	if (otherPriority == nil)
		otherPriority = [OFNumber numberWithInt8: 0];

	if (_priority != nil)
		priorityOrder = [_priority compare: otherPriority];
	else
		priorityOrder =
		    [[OFNumber numberWithInt8: 0] compare: otherPriority];

	if (priorityOrder != OF_ORDERED_SAME)
		return priorityOrder;

	otherShow = [otherPresence show];
	if ([_show isEqual: otherShow])
		return OF_ORDERED_SAME;

	if (show_to_int(_show) < show_to_int(otherShow))
		return OF_ORDERED_ASCENDING;

	return OF_ORDERED_DESCENDING;
}
@end