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
|
#define XMPP_NS_SASL @"urn:ietf:params:xml:ns:xmpp-sasl"
#define XMPP_NS_STARTTLS @"urn:ietf:params:xml:ns:xmpp-tls"
#define XMPP_NS_STANZAS @"urn:ietf:params:xml:ns:xmpp-stanzas"
#define XMPP_NS_SESSION @"urn:ietf:params:xml:ns:xmpp-session"
#define XMPP_NS_STREAM @"http://etherx.jabber.org/streams"
@protocol XMPPConnectionDelegate
@optional
- (void)connectionWasAuthenticated: (XMPPConnection*)conn;
- (void)connection: (XMPPConnection*)conn
wasBoundToJID: (XMPPJID*)jid;
- (void)connectionDidReceiveRoster: (XMPPConnection*)conn;
- (BOOL)connection: (XMPPConnection*)conn
didReceiveIQ: (XMPPIQ*)iq;
- (void)connection: (XMPPConnection*)conn
didReceivePresence: (XMPPPresence*)pres;
- (void)connection: (XMPPConnection*)conn
didReceiveMessage: (XMPPMessage*)msg;
- (void)connectionWasClosed: (XMPPConnection*)conn;
@end
/**
* \brief A class which abstracts a connection to an XMPP service.
*/
@interface XMPPConnection: OFObject <OFXMLParserDelegate,
OFXMLElementBuilderDelegate>
{
OFTCPSocket *sock;
OFXMLParser *parser;
OFXMLElementBuilder *elementBuilder;
OFString *username, *password, *server, *resource;
XMPPJID *JID;
uint16_t port;
id <XMPPConnectionDelegate, OFObject> delegate;
XMPPAuthenticator *authModule;
BOOL needsSession;
unsigned int lastID;
OFString *bindID, *sessionID, *rosterID;
XMPPRoster *roster;
}
@property (copy) OFString *username, *password, *server, *resource;
@property (copy, readonly) XMPPJID *JID;
@property (assign) uint16_t port;
@property (retain) id <XMPPConnectionDelegate> delegate;
@property (readonly, retain) XMPPRoster *roster;
/**
* Connects to the XMPP service.
*/
- (void)connect;
/**
|
>
>
>
>
>
|
>
|
>
>
>
|
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
|
#define XMPP_NS_SASL @"urn:ietf:params:xml:ns:xmpp-sasl"
#define XMPP_NS_STARTTLS @"urn:ietf:params:xml:ns:xmpp-tls"
#define XMPP_NS_STANZAS @"urn:ietf:params:xml:ns:xmpp-stanzas"
#define XMPP_NS_SESSION @"urn:ietf:params:xml:ns:xmpp-session"
#define XMPP_NS_STREAM @"http://etherx.jabber.org/streams"
@protocol XMPPConnectionDelegate
#ifndef XMPP_CONNECTION_M
<OFObject>
#endif
#ifdef OF_HAVE_OPTIONAL_PROTOCOLS
@optional
#endif
- (void)connectionWasAuthenticated: (XMPPConnection*)conn;
- (void)connection: (XMPPConnection*)conn
wasBoundToJID: (XMPPJID*)jid;
- (void)connectionDidReceiveRoster: (XMPPConnection*)conn;
- (BOOL)connection: (XMPPConnection*)conn
didReceiveIQ: (XMPPIQ*)iq;
- (void)connection: (XMPPConnection*)conn
didReceivePresence: (XMPPPresence*)pres;
- (void)connection: (XMPPConnection*)conn
didReceiveMessage: (XMPPMessage*)msg;
- (void)connectionWasClosed: (XMPPConnection*)conn;
@end
/**
* \brief A class which abstracts a connection to an XMPP service.
*/
@interface XMPPConnection: OFObject
#ifdef OF_HAVE_OPTONAL_PROTOCOLS
<OFXMLParserDelegate, OFXMLElementBuilderDelegate>
#endif
{
OFTCPSocket *sock;
OFXMLParser *parser;
OFXMLElementBuilder *elementBuilder;
OFString *username, *password, *server, *resource;
XMPPJID *JID;
uint16_t port;
id <XMPPConnectionDelegate, OFObject> delegate;
XMPPAuthenticator *authModule;
BOOL needsSession;
unsigned int lastID;
OFString *bindID, *sessionID, *rosterID;
XMPPRoster *roster;
}
#ifdef OF_HAVE_PROPERTIES
@property (copy) OFString *username, *password, *server, *resource;
@property (copy, readonly) XMPPJID *JID;
@property (assign) uint16_t port;
@property (retain) id <XMPPConnectionDelegate> delegate;
@property (readonly, retain) XMPPRoster *roster;
#endif
/**
* Connects to the XMPP service.
*/
- (void)connect;
/**
|
105
106
107
108
109
110
111
112
|
*/
- (OFString*)generateStanzaID;
/**
* Requests the roster.
*/
- (void)requestRoster;
@end
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
|
*/
- (OFString*)generateStanzaID;
/**
* Requests the roster.
*/
- (void)requestRoster;
- (void)setUsername: (OFString*)username;
- (OFString*)username;
- (void)setPassword: (OFString*)password;
- (OFString*)password;
- (void)setServer: (OFString*)server;
- (OFString*)server;
- (void)setResource: (OFString*)resource;
- (OFString*)resource;
- (XMPPJID*)JID;
- (void)setPort: (uint16_t)port;
- (uint16_t)port;
- (void)setDelegate: (id <XMPPConnectionDelegate>)delegate;
- (id <XMPPConnectionDelegate>)delegate;
- (XMPPRoster*)roster;
- (void)XMPP_startStream;
- (void)XMPP_handleStanza: (OFXMLElement*)elem;
- (void)XMPP_sendAuth: (OFString*)name;
- (void)XMPP_handleIQ: (XMPPIQ*)iq;
- (void)XMPP_handleMessage: (XMPPMessage*)msg;
- (void)XMPP_handlePresence: (XMPPPresence*)pres;
- (void)XMPP_handleFeatures: (OFXMLElement*)elem;
- (void)XMPP_sendResourceBind;
- (void)XMPP_handleResourceBind: (XMPPIQ*)iq;
- (void)XMPP_sendSession;
- (void)XMPP_handleSession: (XMPPIQ*)iq;
- (void)XMPP_handleRoster: (XMPPIQ*)iq;
@end
@interface OFObject (XMPPConnectionDelegate) <XMPPConnectionDelegate>
@end
|