-
Notifications
You must be signed in to change notification settings - Fork 2
/
JID.h
99 lines (96 loc) · 2.89 KB
/
JID.h
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
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
//
// JID.h
// Jabber
//
// Created by David Chisnall on Sun Apr 25 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef enum {invalidJID = 0, serverJID, serverResourceJID, userJID, resourceJID} JIDType;
/**
* The JID class represents a Jabber ID of the form user@server/resource. A JID
* may have all three components, a user and a server but no resource, a server
* and resource but no user, or just a server.
*
* Typically, two JIDs are referring to the same person (but not the same
* client) when they have the same user and server. For this reason, it is
* possible to compare two JIDs either with or without their associated
* resources. For example user@example.com/work and user@example.com/home would
* likely be two clients in use by the same user, and so chat messages from
* either should go into the same dialogue window.
*
* JID objects are immutable, and may be used as keys in collection objects such
* as dictionaries.
*/
@interface JID : NSObject {
JIDType type;
NSString * user;
NSString * server;
NSString * resource;
NSString * stringRepresentation;
NSString * stringRepresentationWithNoResource;
}
/**
* Creates a new JID from the given string.
*/
+ (id) jidWithString:(NSString*)aJid;
/**
* Initialises a new JID with a specified string
*/
- (id) initWithString:(NSString*)aJid;
/**
* Returns the amount of information provided by this JID.
*
* invalidJID - Not a valid Jabber ID.
*
* serverJID - A Jabber ID with only a server component.
*
* serverResourceJID - A JID of the form server/resource.
*
* userJID - A Jabber ID with a server and user, but no resource.
*
* resourceJID - A Jabber ID with all three components set.
*/
- (JIDType) type;
/**
* Compare two JIDs.
*/
- (NSComparisonResult) compare:(JID*)anAnotherJid;
/**
* Compare two JIDs excluding their resource component. Any combination of
* user@example.com/foo, user@example.com/bar and user@example.com will return
* NSOrderedSame when used as receiver and argument for this comparison.
*/
- (NSComparisonResult) compareWithNoResource:(JID*)anAnotherJid;
/**
* Test for JID equality. Returns YES if both JIDs have the same components and
* all components are the same.
*/
- (BOOL) isEqualToJID:(JID*)aJID;
/**
* Returns a new JID representing this JID with the resource stripped.
*/
- (JID*) rootJID;
/**
* A string representation of this JID. Should be renamed stringValue.
*/
- (NSString*) jidString;
/**
* A string value of the root JID. Semantically equivalent to calling
* [[aJid rootJID] jidString], but more efficient.
*/
- (NSString*) jidStringWithNoResource;
/**
* Returns the node; the component before the @, typically used to identify the
* user.
*/
- (NSString*) node;
/**
* Returns the server (domain) name for this JID.
*/
- (NSString*) domain;
/**
* Returns the resource for this JID.
*/
- (NSString*) resource;
@end