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
|
#include <stringprep.h>
#import "XMPPJID.h"
#import "XMPPExceptions.h"
@implementation XMPPJID
+ (instancetype)JID
{
return [[[self alloc] init] autorelease];
}
+ (instancetype)JIDWithString: (OFString*)string
{
return [[[self alloc] initWithString: string] autorelease];
}
- initWithString: (OFString*)string
{
size_t nodesep, resourcesep;
self = [super init];
if (string == nil) {
[self release];
|
>
>
|
|
|
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
|
#include <stringprep.h>
#import "XMPPJID.h"
#import "XMPPExceptions.h"
@implementation XMPPJID
@synthesize node = _node, domain = _domain, resource = _resource;
+ (instancetype)JID
{
return [[[self alloc] init] autorelease];
}
+ (instancetype)JIDWithString: (OFString *)string
{
return [[[self alloc] initWithString: string] autorelease];
}
- initWithString: (OFString *)string
{
size_t nodesep, resourcesep;
self = [super init];
if (string == nil) {
[self release];
|
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
[new release];
@throw e;
}
return new;
}
- (void)setNode: (OFString*)node
{
OFString *old = _node;
char *nodepart;
Stringprep_rc rc;
if (node == nil) {
[old release];
|
|
|
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
[new release];
@throw e;
}
return new;
}
- (void)setNode: (OFString *)node
{
OFString *old = _node;
char *nodepart;
Stringprep_rc rc;
if (node == nil) {
[old release];
|
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
} @finally {
free(nodepart);
}
[old release];
}
- (OFString*)node
{
return [[_node copy] autorelease];
}
- (void)setDomain: (OFString*)domain
{
OFString *old = _domain;
char *srv;
Stringprep_rc rc;
if (((rc = stringprep_profile([domain UTF8String], &srv,
"Nameprep", 0)) != STRINGPREP_OK) || (srv[0] == '\0') ||
|
<
<
<
<
<
|
|
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
} @finally {
free(nodepart);
}
[old release];
}
- (void)setDomain: (OFString *)domain
{
OFString *old = _domain;
char *srv;
Stringprep_rc rc;
if (((rc = stringprep_profile([domain UTF8String], &srv,
"Nameprep", 0)) != STRINGPREP_OK) || (srv[0] == '\0') ||
|
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
} @finally {
free(srv);
}
[old release];
}
- (OFString*)domain
{
return [[_domain copy] autorelease];
}
- (void)setResource: (OFString*)resource
{
OFString *old = _resource;
char *res;
Stringprep_rc rc;
if (resource == nil) {
[old release];
|
<
<
<
<
<
|
|
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
} @finally {
free(srv);
}
[old release];
}
- (void)setResource: (OFString *)resource
{
OFString *old = _resource;
char *res;
Stringprep_rc rc;
if (resource == nil) {
[old release];
|
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
|
} @finally {
free(res);
}
[old release];
}
- (OFString*)resource
{
return [[_resource copy] autorelease];
}
- (OFString*)bareJID
{
if (_node != nil)
return [OFString stringWithFormat: @"%@@%@", _node, _domain];
else
return [OFString stringWithFormat: @"%@", _domain];
}
- (OFString*)fullJID
{
/* If we don't have a resource, the full JID is equal to the bare JID */
if (_resource == nil)
return [self bareJID];
if (_node != nil)
return [OFString stringWithFormat: @"%@@%@/%@",
_node, _domain, _resource];
else
return [OFString stringWithFormat: @"%@/%@",
_domain, _resource];
}
- (OFString*)description
{
return [self fullJID];
}
- (bool)isEqual: (id)object
{
XMPPJID *JID;
|
<
<
<
<
<
|
|
|
|
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
|
} @finally {
free(res);
}
[old release];
}
- (OFString *)bareJID
{
if (_node != nil)
return [OFString stringWithFormat: @"%@@%@", _node, _domain];
else
return [OFString stringWithFormat: @"%@", _domain];
}
- (OFString *)fullJID
{
/* If we don't have a resource, the full JID is equal to the bare JID */
if (_resource == nil)
return [self bareJID];
if (_node != nil)
return [OFString stringWithFormat: @"%@@%@/%@",
_node, _domain, _resource];
else
return [OFString stringWithFormat: @"%@/%@",
_domain, _resource];
}
- (OFString *)description
{
return [self fullJID];
}
- (bool)isEqual: (id)object
{
XMPPJID *JID;
|