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
|
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
110
111
112
113
114
115
116
117
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
|
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
+
+
+
+
+
+
+
|
- initWithType: (OFString*)type_
ID: (OFString*)ID_
{
return [super initWithName: @"presence"
type: type_
ID: ID_];
}
- (void)dealloc
{
[status release];
[show release];
[priority release];
[super dealloc];
}
- (OFString*)type
{
if (type == nil)
return @"available";
return [[type copy] autorelease];
}
- (void)addShow: (OFString*)show
- (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]];
}
- (void)addStatus: (OFString*)status
[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]];
}
- (void)addPriority: (int8_t)priority
[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* prio = [OFString stringWithFormat: @"%" @PRId8, priority];
[OFString stringWithFormat: @"%" @PRId8, [priority_ int8Value]];
[self addChild: [OFXMLElement elementWithName: @"priority"
namespace: XMPP_NS_CLIENT
stringValue: prio]];
stringValue: priority_s]];
OF_SETTER(priority, priority_, YES, 1);
}
- (OFString*)priority
{
return [[priority copy] autorelease];
}
@end
|