ObjXMPP  Check-in [764c514b82]

Overview
Comment:Change documentation style to ObjFW's style
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 764c514b82a9a602511a39e468b00b0b24caad744bfc96df55d4f60f9009c4dc
User & Date: js on 2017-07-23 11:57:22
Other Links: manifest | tags
Context
2017-07-23
12:07
Make sure all properties are nonatomic check-in: 2469a8df49 user: js tags: trunk
11:57
Change documentation style to ObjFW's style check-in: 764c514b82 user: js tags: trunk
11:35
Stop using OFAutoreleasePool check-in: 7f939be668 user: js tags: trunk
Changes

Modified src/XMPPAuthenticator.h from [d85386eb0a] to [b6faf55748].

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
 * POSSIBILITY OF SUCH DAMAGE.
 */

#import <ObjFW/ObjFW.h>

OF_ASSUME_NONNULL_BEGIN

/**
 * \brief A base class for classes implementing authentication mechanisms
 */
@interface XMPPAuthenticator: OFObject
{
	OFString *_authzid, *_authcid, *_password;
}


/// \brief The authzid to get authorization for

@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *authzid;


/// \brief The authcid to authenticate with

@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *authcid;


/// \brief The password to authenticate with

@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *password;

/**
 * \brief Initializes an already allocated XMPPAuthenticator with an authcid
 *	  and password.
 *
 * \param authcid The authcid to authenticate with
 * \param password The password to authenticate with
 * \return A initialized XMPPAuthenticator
 */
- initWithAuthcid: (nullable OFString *)authcid
	 password: (nullable OFString *)password;

/**
 * \brief Initializes an already allocated XMPPSCRAMAuthenticator with an
 *	  authzid, authcid and password.
 *
 * \param authzid The authzid to get authorization for
 * \param authcid The authcid to authenticate with
 * \param password The password to authenticate with
 * \return A initialized XMPPAuthenticator
 */
- initWithAuthzid: (nullable OFString *)authzid
	  authcid: (nullable OFString *)authcid
	 password: (nullable OFString *)password OF_DESIGNATED_INITIALIZER;

/**
 * \brief Returns OFData containing the initial authentication message.
 *
 * \return An OFDataAray containing the initial authentication message
 */
- (nullable OFData *)initialMessage;

/**
 * \brief Continue authentication with the specified data.
 *
 * \param data The continuation data send by the server
 * \return The appropriate response if the data was a challenge, nil otherwise
 */
- (nullable OFData *)continueWithData: (OFData *)data;
@end

OF_ASSUME_NONNULL_END







|
|






>
|
>

>
>
|
>

>
>
|
>


|
|


|
|
|




|
|


|
|
|
|





|
|

|



|
|

|
|





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
 * POSSIBILITY OF SUCH DAMAGE.
 */

#import <ObjFW/ObjFW.h>

OF_ASSUME_NONNULL_BEGIN

/*!
 * @brief A base class for classes implementing authentication mechanisms
 */
@interface XMPPAuthenticator: OFObject
{
	OFString *_authzid, *_authcid, *_password;
}

/*!
 * The authzid to get authorization for.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *authzid;

/*!
 * The authcid to authenticate with.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *authcid;

/*!
 * The password to authenticate with.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *password;

/*!
 * @brief Initializes an already allocated XMPPAuthenticator with an authcid
 *	  and password.
 *
 * @param authcid The authcid to authenticate with
 * @param password The password to authenticate with
 * @return A initialized XMPPAuthenticator
 */
- initWithAuthcid: (nullable OFString *)authcid
	 password: (nullable OFString *)password;

/*!
 * @brief Initializes an already allocated XMPPSCRAMAuthenticator with an
 *	  authzid, authcid and password.
 *
 * @param authzid The authzid to get authorization for
 * @param authcid The authcid to authenticate with
 * @param password The password to authenticate with
 * @return A initialized XMPPAuthenticator
 */
- initWithAuthzid: (nullable OFString *)authzid
	  authcid: (nullable OFString *)authcid
	 password: (nullable OFString *)password OF_DESIGNATED_INITIALIZER;

/*!
 * @brief Returns OFData containing the initial authentication message.
 *
 * @return An OFDataAray containing the initial authentication message
 */
- (nullable OFData *)initialMessage;

/*!
 * @brief Continue authentication with the specified data.
 *
 * @param data The continuation data send by the server
 * @return The appropriate response if the data was a challenge, nil otherwise
 */
- (nullable OFData *)continueWithData: (OFData *)data;
@end

OF_ASSUME_NONNULL_END

Modified src/XMPPConnection.h from [423e3fef12] to [0b78eccdeb].

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
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
@class XMPPIQ;
@class XMPPMessage;
@class XMPPPresence;
@class XMPPAuthenticator;
@class SSLSocket;
@class XMPPMulticastDelegate;

/**
 * \brief A protocol that should be (partially) implemented by delegates of a
 *	  @ref XMPPConnection
 */
@protocol XMPPConnectionDelegate
@optional
/**
 * \brief This callback is called when the connection received an element.
 *
 * \param connection The connection that received the element
 * \param element The element that was received
 */
-  (void)connection: (XMPPConnection *)connection
  didReceiveElement: (OFXMLElement *)element;

/**
 * \brief This callback is called when the connection sent an element.
 *
 * \param connection The connection that sent the element
 * \param element The element that was sent
 */
- (void)connection: (XMPPConnection *)connection
    didSendElement: (OFXMLElement *)element;

/**
 * \brief This callback is called when the connection sucessfully authenticated.
 *
 * \param connection The connection that was authenticated
 */
- (void)connectionWasAuthenticated: (XMPPConnection *)connection;

/**
 * \brief This callback is called when the connection was bound to a JID.
 *
 * \param connection The connection that was bound to a JID
 * \param JID The JID the conecction was bound to
 */
- (void)connection: (XMPPConnection *)connection
     wasBoundToJID: (XMPPJID *)JID;

/**
 * \brief This callback is called when the connection received an IQ stanza.
 *
 * \param connection The connection that received the stanza
 * \param iq The IQ stanza that was received
 */
- (bool)connection: (XMPPConnection *)connection
      didReceiveIQ: (XMPPIQ *)iq;

/**
 * \brief This callback is called when the connection received a presence
 *	  stanza.
 *
 * \param connection The connection that received the stanza
 * \param presence The presence stanza that was received
 */
-   (void)connection: (XMPPConnection *)connection
  didReceivePresence: (XMPPPresence *)presence;

/**
 * \brief This callback is called when the connection received a message stanza.
 *
 * \param connection The connection that received the stanza
 * \param message The message stanza that was received
 */
-  (void)connection: (XMPPConnection *)connection
  didReceiveMessage: (XMPPMessage *)message;

/**
 * \brief This callback is called when the connection was closed.
 *
 * \param connection The connection that was closed
 */
- (void)connectionWasClosed: (XMPPConnection *)connection;

/*!
 * @brief This callback is called when the connection threw an exception.
 *
 * This is only called for connections on which
 * @ref XMPPConnection::handleConnection has been called.
 *
 * @param connection The connection which threw an exception
 * @param exception The exception the connection threw
 */
-  (void)connection: (XMPPConnection *)connection
  didThrowException: (OFException *)exception;

/**
 * \brief This callback is called when the connection is about to upgrade to
 *	  TLS.
 *
 * \param connection The connection that will upgraded to TLS
 */
- (void)connectionWillUpgradeToTLS: (XMPPConnection *)connection;

/**
 * \brief This callback is called when the connection was upgraded to use TLS.
 *
 * \param connection The connection that was upgraded to TLS
 */
- (void)connectionDidUpgradeToTLS: (XMPPConnection *)connection;
@end

/**
 * \brief A class which abstracts a connection to an XMPP service.
 */
@interface XMPPConnection: OFObject <OFXMLParserDelegate,
    OFXMLElementBuilderDelegate>
{
	id _socket;
	OFXMLParser *_parser, *_oldParser;
	OFXMLElementBuilder *_elementBuilder, *_oldElementBuilder;







|
|




|
|

|
|




|
|

|
|




|
|

|



|
|

|
|




|
|

|
|




|
|


|
|




|
|

|
|




|
|

|















|
|


|



|
|

|




|
|







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
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
@class XMPPIQ;
@class XMPPMessage;
@class XMPPPresence;
@class XMPPAuthenticator;
@class SSLSocket;
@class XMPPMulticastDelegate;

/*!
 * @brief A protocol that should be (partially) implemented by delegates of a
 *	  @ref XMPPConnection
 */
@protocol XMPPConnectionDelegate
@optional
/*!
 * @brief This callback is called when the connection received an element.
 *
 * @param connection The connection that received the element
 * @param element The element that was received
 */
-  (void)connection: (XMPPConnection *)connection
  didReceiveElement: (OFXMLElement *)element;

/*!
 * @brief This callback is called when the connection sent an element.
 *
 * @param connection The connection that sent the element
 * @param element The element that was sent
 */
- (void)connection: (XMPPConnection *)connection
    didSendElement: (OFXMLElement *)element;

/*!
 * @brief This callback is called when the connection sucessfully authenticated.
 *
 * @param connection The connection that was authenticated
 */
- (void)connectionWasAuthenticated: (XMPPConnection *)connection;

/*!
 * @brief This callback is called when the connection was bound to a JID.
 *
 * @param connection The connection that was bound to a JID
 * @param JID The JID the conecction was bound to
 */
- (void)connection: (XMPPConnection *)connection
     wasBoundToJID: (XMPPJID *)JID;

/*!
 * @brief This callback is called when the connection received an IQ stanza.
 *
 * @param connection The connection that received the stanza
 * @param iq The IQ stanza that was received
 */
- (bool)connection: (XMPPConnection *)connection
      didReceiveIQ: (XMPPIQ *)iq;

/*!
 * @brief This callback is called when the connection received a presence
 *	  stanza.
 *
 * @param connection The connection that received the stanza
 * @param presence The presence stanza that was received
 */
-   (void)connection: (XMPPConnection *)connection
  didReceivePresence: (XMPPPresence *)presence;

/*!
 * @brief This callback is called when the connection received a message stanza.
 *
 * @param connection The connection that received the stanza
 * @param message The message stanza that was received
 */
-  (void)connection: (XMPPConnection *)connection
  didReceiveMessage: (XMPPMessage *)message;

/*!
 * @brief This callback is called when the connection was closed.
 *
 * @param connection The connection that was closed
 */
- (void)connectionWasClosed: (XMPPConnection *)connection;

/*!
 * @brief This callback is called when the connection threw an exception.
 *
 * This is only called for connections on which
 * @ref XMPPConnection::handleConnection has been called.
 *
 * @param connection The connection which threw an exception
 * @param exception The exception the connection threw
 */
-  (void)connection: (XMPPConnection *)connection
  didThrowException: (OFException *)exception;

/*!
 * @brief This callback is called when the connection is about to upgrade to
 *	  TLS.
 *
 * @param connection The connection that will upgraded to TLS
 */
- (void)connectionWillUpgradeToTLS: (XMPPConnection *)connection;

/*!
 * @brief This callback is called when the connection was upgraded to use TLS.
 *
 * @param connection The connection that was upgraded to TLS
 */
- (void)connectionDidUpgradeToTLS: (XMPPConnection *)connection;
@end

/*!
 * @brief A class which abstracts a connection to an XMPP service.
 */
@interface XMPPConnection: OFObject <OFXMLParserDelegate,
    OFXMLElementBuilderDelegate>
{
	id _socket;
	OFXMLParser *_parser, *_oldParser;
	OFXMLElementBuilder *_elementBuilder, *_oldElementBuilder;
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
216
217
218
219
220
221
222
223
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
	bool _needsSession;
	bool _encryptionRequired, _encrypted;
	bool _supportsRosterVersioning;
	bool _supportsStreamManagement;
	unsigned int _lastID;
}


/// \brief The username to use for authentication

@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *username;


/// \brief The password to use for authentication

@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *password;

/**
 * \brief The server to use for the connection
 *
 * This is useful if the address of the server is different from the domain.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *server;


/// \brief The domain to connect to

@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *domain;


/// \brief The resource to request for the connection

@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *resource;


/// \brief The language to request for the connection

@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *language;


/// \brief A private key file to use for authentication

@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *privateKeyFile;


/// \brief A certificate file to use for authentication

@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *certificateFile;


/// \brief The JID the server assigned to the connection after binding

@property (readonly, nonatomic) XMPPJID *JID;


/// \brief The port to connect to

@property uint16_t port;


/// \brief An object for data storage, conforming to the XMPPStorage protocol

@property OF_NULLABLE_PROPERTY (assign) id <XMPPStorage> dataStorage;


/// \brief The socket used for the connection

@property (readonly, nonatomic) OFTCPSocket *socket;


/// \brief Whether encryption is required

@property bool encryptionRequired;


/// \brief Whether the connection is encrypted

@property (readonly) bool encrypted;


/// \brief Whether roster versioning is supported

@property (readonly) bool supportsRosterVersioning;


/// \brief Whether stream management is supported

@property (readonly) bool supportsStreamManagement;

/**
 * \brief Creates a new autoreleased XMPPConnection.
 *
 * \return A new autoreleased XMPPConnection
 */
+ (instancetype)connection;

/**
 * \brief Adds the specified delegate.
 *
 * \param delegate The delegate to add
 */
- (void)addDelegate: (id <XMPPConnectionDelegate>)delegate;

/**
 * \brief Removes the specified delegate.
 *
 * \param delegate The delegate to remove
 */
- (void)removeDelegate: (id <XMPPConnectionDelegate>)delegate;

/**
 * \brief Connects to the XMPP service.
 */
- (void)connect;

/**
 * \brief Closes the stream to the XMPP service
 */
- (void)close;

/**
 * \brief Checks the certificate presented by the server and sets the specified
 *	  pointer to the reason why the certificate is not valid
 *
 * \param reason A pointer to an OFString which is set to a reason in case the
 *		 certificate is not valid (otherwise, it does not touch it).
 *		 Passing NULL means the reason is not stored anywhere.
 * \return Whether the certificate is valid
 */
- (bool)checkCertificateAndGetReason:
    (OFString *__autoreleasing _Nonnull *_Nullable)reason;

/**
 * \brief Adds the connection to the run loop.
 */
- (void)handleConnection;

/**
 * \brief Asynchronously connects to the server and adds the connection to the
 *	  run loop.
 */
- (void)asyncConnectAndHandle;

/**
 * \brief Parses the specified buffer.
 *
 * This is useful for handling multiple connections at once.
 *
 * \param buffer The buffer to parse
 * \param length The length of the buffer. If length is 0, it is assumed that
 *		 the connection was closed.
 */
- (void)parseBuffer: (const void *)buffer
	     length: (size_t)length;

/**
 * \brief Sends an OFXMLElement, usually an XMPPStanza.
 *
 * \param element The element to send
 */
- (void)sendStanza: (OFXMLElement *)element;

/*!
 * @brief Sends an XMPPIQ, registering a callback method.
 *
 * @param IQ The IQ to send







>
|
>

>
>
|
>

>
|
|




>
>
|
>

>
>
|
>

>
>
|
>

>
>
|
>

>
>
|
>

>
>
|
>

>
>
|
>

>
>
|
>

>
>
|
>

>
>
|
>

>
>
|
>

>
>
|
>

>
>
|
>


|
|

|



|
|

|



|
|

|



|
|



|
|



|
|


|


|




|
|



|
|




|
|



|
|





|
|

|







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
216
217
218
219
220
221
222
223
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
	bool _needsSession;
	bool _encryptionRequired, _encrypted;
	bool _supportsRosterVersioning;
	bool _supportsStreamManagement;
	unsigned int _lastID;
}

/*!
 * The username to use for authentication.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *username;

/*!
 * The password to use for authentication.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *password;

/*!
 * The server to use for the connection.
 *
 * This is useful if the address of the server is different from the domain.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *server;

/*!
 * The domain to connect to.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *domain;

/*!
 * The resource to request for the connection.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *resource;

/*!
 * The language to request for the connection.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *language;

/*!
 * A private key file to use for authentication.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *privateKeyFile;

/*!
 * A certificate file to use for authentication.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *certificateFile;

/*!
 * The JID the server assigned to the connection after binding.
 */
@property (readonly, nonatomic) XMPPJID *JID;

/*!
 * The port to connect to.
 */
@property uint16_t port;

/*!
 * An object for data storage, conforming to the XMPPStorage protocol.
 */
@property OF_NULLABLE_PROPERTY (assign) id <XMPPStorage> dataStorage;

/*!
 * The socket used for the connection.
 */
@property (readonly, nonatomic) OFTCPSocket *socket;

/*!
 * Whether encryption is required.
 */
@property bool encryptionRequired;

/*!
 * Whether the connection is encrypted.
 */
@property (readonly) bool encrypted;

/*!
 * Whether roster versioning is supported.
 */
@property (readonly) bool supportsRosterVersioning;

/*!
 * Whether stream management is supported.
 */
@property (readonly) bool supportsStreamManagement;

/*!
 * Creates a new autoreleased XMPPConnection.
 *
 * @return A new autoreleased XMPPConnection
 */
+ (instancetype)connection;

/*!
 * @brief Adds the specified delegate.
 *
 * @param delegate The delegate to add
 */
- (void)addDelegate: (id <XMPPConnectionDelegate>)delegate;

/*!
 * @brief Removes the specified delegate.
 *
 * @param delegate The delegate to remove
 */
- (void)removeDelegate: (id <XMPPConnectionDelegate>)delegate;

/*!
 * @brief Connects to the XMPP service.
 */
- (void)connect;

/*!
 * @brief Closes the stream to the XMPP service
 */
- (void)close;

/*!
 * @brief Checks the certificate presented by the server and sets the specified
 *	  pointer to the reason why the certificate is not valid
 *
 * @param reason A pointer to an OFString which is set to a reason in case the
 *		 certificate is not valid (otherwise, it does not touch it).
 *		 Passing NULL means the reason is not stored anywhere.
 * @return Whether the certificate is valid
 */
- (bool)checkCertificateAndGetReason:
    (OFString *__autoreleasing _Nonnull *_Nullable)reason;

/*!
 * @brief Adds the connection to the run loop.
 */
- (void)handleConnection;

/*!
 * @brief Asynchronously connects to the server and adds the connection to the
 *	  run loop.
 */
- (void)asyncConnectAndHandle;

/*!
 * @brief Parses the specified buffer.
 *
 * This is useful for handling multiple connections at once.
 *
 * @param buffer The buffer to parse
 * @param length The length of the buffer. If length is 0, it is assumed that
 *		 the connection was closed.
 */
- (void)parseBuffer: (const void *)buffer
	     length: (size_t)length;

/*!
 * @brief Sends an OFXMLElement, usually an XMPPStanza.
 *
 * @param element The element to send
 */
- (void)sendStanza: (OFXMLElement *)element;

/*!
 * @brief Sends an XMPPIQ, registering a callback method.
 *
 * @param IQ The IQ to send
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
 * @param IQ The IQ to send
 * @param block The callback block
 */
-  (void)sendIQ: (XMPPIQ *)IQ
  callbackBlock: (xmpp_callback_block_t)block;
#endif

/**
 * \brief Generates a new, unique stanza ID.
 *
 * \return A new, generated, unique stanza ID.
 */
- (OFString *)generateStanzaID;
@end

OF_ASSUME_NONNULL_END







|
|

|





343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
 * @param IQ The IQ to send
 * @param block The callback block
 */
-  (void)sendIQ: (XMPPIQ *)IQ
  callbackBlock: (xmpp_callback_block_t)block;
#endif

/*!
 * @brief Generates a new, unique stanza ID.
 *
 * @return A new, generated, unique stanza ID.
 */
- (OFString *)generateStanzaID;
@end

OF_ASSUME_NONNULL_END

Modified src/XMPPContact.h from [3375b65268] to [d5fe6d2fd5].

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

@class XMPPConnection;
@class XMPPJID;
@class XMPPRosterItem;
@class XMPPMessage;
@class XMPPPresence;

/**
 * \brief A class describing a contact tracked by a XMPPContactManager
 */
@interface XMPPContact: OFObject
{
	XMPPRosterItem *_rosterItem;
	OFMutableDictionary *_presences;
	XMPPJID *_lockedOnJID;
}


/// \brief The XMPPRosterItem corresponding to this contact

@property (readonly, nonatomic) XMPPRosterItem *rosterItem;


/// \brief The XMPPPresences of this contact with the resources as keys

@property (readonly, nonatomic) OFDictionary *presences;

/**
 * \brief Sends a message to the contact honoring resource locking
 *
 * \param message The message to send
 * \param connection The connection to use for sending the message
 */
- (void)sendMessage: (XMPPMessage *)message
	 connection: (XMPPConnection *)connection;
@end

OF_ASSUME_NONNULL_END







|
|








>
|
>

>
>
|
>


|
|

|
|






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

@class XMPPConnection;
@class XMPPJID;
@class XMPPRosterItem;
@class XMPPMessage;
@class XMPPPresence;

/*!
 * @brief A class describing a contact tracked by a XMPPContactManager
 */
@interface XMPPContact: OFObject
{
	XMPPRosterItem *_rosterItem;
	OFMutableDictionary *_presences;
	XMPPJID *_lockedOnJID;
}

/*!
 * The XMPPRosterItem corresponding to this contact.
 */
@property (readonly, nonatomic) XMPPRosterItem *rosterItem;

/*!
 * The XMPPPresences of this contact with the resources as keys.
 */
@property (readonly, nonatomic) OFDictionary *presences;

/*!
 * @brief Sends a message to the contact honoring resource locking
 *
 * @param message The message to send
 * @param connection The connection to use for sending the message
 */
- (void)sendMessage: (XMPPMessage *)message
	 connection: (XMPPConnection *)connection;
@end

OF_ASSUME_NONNULL_END

Modified src/XMPPContactManager.h from [ffd20ba38a] to [7f67dd17c8].

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
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
OF_ASSUME_NONNULL_BEGIN

@class XMPPContact;
@class XMPPContactManager;
@class XMPPMulticastDelegate;
@class XMPPPresence;

/**
 * \brief A protocol that should be (partially) implemented by delegates
 *	  of a XMPPContactManager
 */
@protocol XMPPContactManagerDelegate <OFObject>
@optional
/**
 * \brief This callback is called whenever a new contact enters the users roster
 *
 * \param manager The contact manager that added the contact
 * \param contact The contact that was added
 */
- (void)contactManager: (XMPPContactManager *)manager
	 didAddContact: (XMPPContact *)contact;

/**
 * \brief This callback is called whenever a contact is no longer present in
 *	  the users roster
 *
 * \param manager The contact manager that removed the contact
 * \param contact The contact that was removed
 */
- (void)contactManager: (XMPPContactManager *)manager
      didRemoveContact: (XMPPContact *)contact;

/**
 * \brief This callback is called when a subscription request is received
 *
 * \param manager The contact manager that received the request
 * \param presence The type=subscribe presence
 */
-          (void)contactManager: (XMPPContactManager *)manager
  didReceiveSubscriptionRequest: (XMPPPresence *)presence;

/**
 * \brief This callback is called whenever a contact is about to change its
 *	  roster item
 *
 * \param contact The contact about to updated its roster item
 * \param rosterItem The roster item the contact is going to update with
 */
-	     (void)contact: (XMPPContact *)contact
  willUpdateWithRosterItem: (XMPPRosterItem *)rosterItem;

/**
 * \brief This callback is called whenever a contact send a presence stanza
 *
 * \param contact The contact that send the presence
 * \param presence The presence which was send by the contact
 */
-   (void)contact: (XMPPContact *)contact
  didSendPresence: (XMPPPresence *)presence;

/**
 * \brief This callback is called whenever a contact send a message stanza
 *
 * \param contact The contact that send the message
 * \param message The message which was send by the contact
 */
-  (void)contact: (XMPPContact *)contact
  didSendMessage: (XMPPMessage *)message;
@end

/**
 * \brief A class tracking a XMPPContact instance for each contact in the roster
 *
 * This class delegates to a XMPPConnection and a XMPPRoster, thereby tracking
 * each contacts presences and the current XMPPRosterItem.
 */
@interface XMPPContactManager: OFObject <XMPPConnectionDelegate,
    XMPPRosterDelegate>
{
	OFMutableDictionary *_contacts;
	XMPPConnection *_connection;
	XMPPRoster *_roster;
	XMPPMulticastDelegate *_delegates;
}


/// \brief The tracked contacts, with their bare JID as key

@property (readonly, nonatomic)
    OFDictionary OF_GENERIC(OFString *, XMPPContact *) *contacts;

/*!
 * @brief Initializes an already allocated XMPPContactManager.
 *
 * @param connection The connection to be used to track contacts
 * @param roster The roster used by the contact manager
 * @return An initialized XMPPContactManager
 */
- initWithConnection: (XMPPConnection *)connection
	      roster: (XMPPRoster *)roster OF_DESIGNATED_INITIALIZER;

- (void)sendSubscribedToJID: (XMPPJID *)subscriber;
- (void)sendUnsubscribedToJID: (XMPPJID *)subscriber;

/**
 * \brief Adds the specified delegate.
 *
 * \param delegate The delegate to add
 */
- (void)addDelegate: (id <XMPPContactManagerDelegate>)delegate;

/**
 * \brief Removes the specified delegate.
 *
 * \param delegate The delegate to remove
 */
- (void)removeDelegate: (id <XMPPContactManagerDelegate>)delegate;
@end

OF_ASSUME_NONNULL_END







|
|




|
|

|
|




|
|


|
|




|
|

|
|




|
|


|
|




|
|

|
|




|
|

|
|





|
|













>
|
>
















|
|

|



|
|

|





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
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
OF_ASSUME_NONNULL_BEGIN

@class XMPPContact;
@class XMPPContactManager;
@class XMPPMulticastDelegate;
@class XMPPPresence;

/*!
 * @brief A protocol that should be (partially) implemented by delegates
 *	  of a XMPPContactManager
 */
@protocol XMPPContactManagerDelegate <OFObject>
@optional
/*!
 * @brief This callback is called whenever a new contact enters the users roster
 *
 * @param manager The contact manager that added the contact
 * @param contact The contact that was added
 */
- (void)contactManager: (XMPPContactManager *)manager
	 didAddContact: (XMPPContact *)contact;

/*!
 * @brief This callback is called whenever a contact is no longer present in
 *	  the users roster
 *
 * @param manager The contact manager that removed the contact
 * @param contact The contact that was removed
 */
- (void)contactManager: (XMPPContactManager *)manager
      didRemoveContact: (XMPPContact *)contact;

/*!
 * @brief This callback is called when a subscription request is received
 *
 * @param manager The contact manager that received the request
 * @param presence The type=subscribe presence
 */
-          (void)contactManager: (XMPPContactManager *)manager
  didReceiveSubscriptionRequest: (XMPPPresence *)presence;

/*!
 * @brief This callback is called whenever a contact is about to change its
 *	  roster item
 *
 * @param contact The contact about to updated its roster item
 * @param rosterItem The roster item the contact is going to update with
 */
-	     (void)contact: (XMPPContact *)contact
  willUpdateWithRosterItem: (XMPPRosterItem *)rosterItem;

/*!
 * @brief This callback is called whenever a contact send a presence stanza
 *
 * @param contact The contact that send the presence
 * @param presence The presence which was send by the contact
 */
-   (void)contact: (XMPPContact *)contact
  didSendPresence: (XMPPPresence *)presence;

/*!
 * @brief This callback is called whenever a contact send a message stanza
 *
 * @param contact The contact that send the message
 * @param message The message which was send by the contact
 */
-  (void)contact: (XMPPContact *)contact
  didSendMessage: (XMPPMessage *)message;
@end

/*!
 * @brief A class tracking a XMPPContact instance for each contact in the roster
 *
 * This class delegates to a XMPPConnection and a XMPPRoster, thereby tracking
 * each contacts presences and the current XMPPRosterItem.
 */
@interface XMPPContactManager: OFObject <XMPPConnectionDelegate,
    XMPPRosterDelegate>
{
	OFMutableDictionary *_contacts;
	XMPPConnection *_connection;
	XMPPRoster *_roster;
	XMPPMulticastDelegate *_delegates;
}

/*!
 * The tracked contacts, with their bare JID as key.
 */
@property (readonly, nonatomic)
    OFDictionary OF_GENERIC(OFString *, XMPPContact *) *contacts;

/*!
 * @brief Initializes an already allocated XMPPContactManager.
 *
 * @param connection The connection to be used to track contacts
 * @param roster The roster used by the contact manager
 * @return An initialized XMPPContactManager
 */
- initWithConnection: (XMPPConnection *)connection
	      roster: (XMPPRoster *)roster OF_DESIGNATED_INITIALIZER;

- (void)sendSubscribedToJID: (XMPPJID *)subscriber;
- (void)sendUnsubscribedToJID: (XMPPJID *)subscriber;

/*!
 * @brief Adds the specified delegate.
 *
 * @param delegate The delegate to add
 */
- (void)addDelegate: (id <XMPPContactManagerDelegate>)delegate;

/*!
 * @brief Removes the specified delegate.
 *
 * @param delegate The delegate to remove
 */
- (void)removeDelegate: (id <XMPPContactManagerDelegate>)delegate;
@end

OF_ASSUME_NONNULL_END

Modified src/XMPPDiscoEntity.h from [1a213e145c] to [3c8c4b2136].

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
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
#import "XMPPConnection.h"
#import "XMPPDiscoNode.h"

OF_ASSUME_NONNULL_BEGIN

@class XMPPJID;

/**
 * \brief A class representing an entity responding to Service Discovery
 *	  queries
 */
@interface XMPPDiscoEntity: XMPPDiscoNode <XMPPConnectionDelegate>
{
	OFMutableDictionary *_discoNodes;
	XMPPConnection *_connection;
	OFString *_capsNode;
}

/**
 * \brief The XMPPDiscoNodes this entity provides Services Discovery
 *	  responses for
 *
 * This usually contains at least all immediate child nodes, but may contain
 * any number of nodes nested more deeply.
 */
@property (readonly) OFDictionary *discoNodes;

/**
 * The node advertised for the entity's capabilites.
 */
@property (readonly) OFString *capsNode;

+ (instancetype)discoNodeWithJID: (XMPPJID *)JID
			    node: (nullable OFString *)node OF_UNAVAILABLE;
+ (instancetype)discoNodeWithJID: (XMPPJID *)JID
			    node: (nullable OFString *)node
			    name: (nullable OFString *)name OF_UNAVAILABLE;

/**
 * \brief Creates a new autoreleased XMPPDiscoEntity with the specified
 *	  connection.
 *
 * \param connection The XMPPConnection to serve responses on.
 * \return A new autoreleased XMPPDiscoEntity
 */
+ (instancetype)discoEntityWithConnection: (XMPPConnection *)connection;

/**
 * \brief Creates a new autoreleased XMPPDiscoEntity with the specified
 *	  connection.
 *
 * \param connection The XMPPConnection to serve responses on.
 * \param capsNode The node advertised for the entity's capabilites
 * \return A new autoreleased XMPPDiscoEntity
 */
+ (instancetype)discoEntityWithConnection: (XMPPConnection *)connection
				 capsNode: (OFString *)capsNode;

- initWithJID: (XMPPJID *)JID
	 node: (nullable OFString *)node OF_UNAVAILABLE;
- initWithJID: (XMPPJID *)JID
	 node: (nullable OFString *)node
	 name: (nullable OFString *)name OF_UNAVAILABLE;

/**
 * \brief Initializes an already allocated XMPPDiscoEntity with the specified
 *	  connection.
 *
 * \param connection The XMPPConnection to serve responses on.
 *	  This must already be bound to a resource)
 * \return An initialized XMPPDiscoEntity
 */
- initWithConnection: (XMPPConnection *)connection;

/**
 * \brief Initializes an already allocated XMPPDiscoEntity with the specified
 *	  connection.
 *
 * \param connection The XMPPConnection to serve responses on.
 *	  This must already be bound to a resource)
 * \param capsNode The node advertised for the entity's capabilites
 * \return An initialized XMPPDiscoEntity
 */
- initWithConnection: (XMPPConnection *)connection
	    capsNode: (nullable OFString *)capsNode OF_DESIGNATED_INITIALIZER;

/**
 * \brief Adds a XMPPDiscoNode to provide responses for.
 *
 * \param node The XMPPDiscoNode to provide responses for
 */
- (void)addDiscoNode: (XMPPDiscoNode *)node;

/**
 * \brief Calculates the Entity Capabilities Hash of the entity
 *
 * \return A OFString containing the capabilities hash
 */
- (OFString *)capsHash;
@end

OF_ASSUME_NONNULL_END







|
|









|
|







|










|
|


|
|



|
|


|
|
|










|
|


|

|



|
|


|

|
|




|
|

|



|
|

|





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
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
#import "XMPPConnection.h"
#import "XMPPDiscoNode.h"

OF_ASSUME_NONNULL_BEGIN

@class XMPPJID;

/*!
 * @brief A class representing an entity responding to Service Discovery
 *	  queries
 */
@interface XMPPDiscoEntity: XMPPDiscoNode <XMPPConnectionDelegate>
{
	OFMutableDictionary *_discoNodes;
	XMPPConnection *_connection;
	OFString *_capsNode;
}

/*!
 * @brief The XMPPDiscoNodes this entity provides Services Discovery
 *	  responses for
 *
 * This usually contains at least all immediate child nodes, but may contain
 * any number of nodes nested more deeply.
 */
@property (readonly) OFDictionary *discoNodes;

/*!
 * The node advertised for the entity's capabilites.
 */
@property (readonly) OFString *capsNode;

+ (instancetype)discoNodeWithJID: (XMPPJID *)JID
			    node: (nullable OFString *)node OF_UNAVAILABLE;
+ (instancetype)discoNodeWithJID: (XMPPJID *)JID
			    node: (nullable OFString *)node
			    name: (nullable OFString *)name OF_UNAVAILABLE;

/*!
 * @brief Creates a new autoreleased XMPPDiscoEntity with the specified
 *	  connection.
 *
 * @param connection The XMPPConnection to serve responses on.
 * @return A new autoreleased XMPPDiscoEntity
 */
+ (instancetype)discoEntityWithConnection: (XMPPConnection *)connection;

/*!
 * @brief Creates a new autoreleased XMPPDiscoEntity with the specified
 *	  connection.
 *
 * @param connection The XMPPConnection to serve responses on.
 * @param capsNode The node advertised for the entity's capabilites
 * @return A new autoreleased XMPPDiscoEntity
 */
+ (instancetype)discoEntityWithConnection: (XMPPConnection *)connection
				 capsNode: (OFString *)capsNode;

- initWithJID: (XMPPJID *)JID
	 node: (nullable OFString *)node OF_UNAVAILABLE;
- initWithJID: (XMPPJID *)JID
	 node: (nullable OFString *)node
	 name: (nullable OFString *)name OF_UNAVAILABLE;

/*!
 * @brief Initializes an already allocated XMPPDiscoEntity with the specified
 *	  connection.
 *
 * @param connection The XMPPConnection to serve responses on.
 *	  This must already be bound to a resource)
 * @return An initialized XMPPDiscoEntity
 */
- initWithConnection: (XMPPConnection *)connection;

/*!
 * @brief Initializes an already allocated XMPPDiscoEntity with the specified
 *	  connection.
 *
 * @param connection The XMPPConnection to serve responses on.
 *	  This must already be bound to a resource)
 * @param capsNode The node advertised for the entity's capabilites
 * @return An initialized XMPPDiscoEntity
 */
- initWithConnection: (XMPPConnection *)connection
	    capsNode: (nullable OFString *)capsNode OF_DESIGNATED_INITIALIZER;

/*!
 * @brief Adds a XMPPDiscoNode to provide responses for.
 *
 * @param node The XMPPDiscoNode to provide responses for
 */
- (void)addDiscoNode: (XMPPDiscoNode *)node;

/*!
 * @brief Calculates the Entity Capabilities Hash of the entity
 *
 * @return A OFString containing the capabilities hash
 */
- (OFString *)capsHash;
@end

OF_ASSUME_NONNULL_END

Modified src/XMPPDiscoIdentity.h from [969a73bffe] to [810c5e6737].

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
 * POSSIBILITY OF SUCH DAMAGE.
 */

#import <ObjFW/ObjFW.h>

OF_ASSUME_NONNULL_BEGIN

/**
 * \brief A class describing a Service Discovery Identity
 */
@interface XMPPDiscoIdentity: OFObject <OFComparing>
{
	OFString *_category, *_name, *_type;
}


/// \brief The category of the identity

@property (readonly, nonatomic) OFString *category;


/// \brief The name of the identity, might be unset

@property (readonly, nonatomic) OFString *name;


/// \brief The type of the identity

@property (readonly, nonatomic) OFString *type;

/**
 * \brief Creates a new autoreleased XMPPDiscoIdentity with the specified
 *	  category, type and name.
 *
 * \param category The category of the identity
 * \param type The type of the identity
 * \param name The name of the identity
 * \return A new autoreleased XMPPDiscoIdentity
 */
+ (instancetype)identityWithCategory: (OFString *)category
				type: (OFString *)type
				name: (nullable OFString *)name;

/**
 * \brief Creates a new autoreleased XMPPDiscoIdentity with the specified
 *	  category and type.
 *
 * \param category The category of the identity
 * \param type The type of the identity
 * \return A new autoreleased XMPPDiscoIdentity
 */
+ (instancetype)identityWithCategory: (OFString *)category
				type: (OFString *)type;

- init OF_UNAVAILABLE;

/**
 * \brief Initializes an already allocated XMPPDiscoIdentity with the specified
 *	  category, type and name.
 *
 * \param category The category of the identity
 * \param type The type of the identity
 * \param name The name of the identity
 * \return An initialized XMPPDiscoIdentity
 */
- initWithCategory: (OFString *)category
	      type: (OFString *)type
	      name: (nullable OFString *)name OF_DESIGNATED_INITIALIZER;

/**
 * \brief Initializes an already allocated XMPPDiscoIdentity with the specified
 *	  category and type.
 *
 * \param category The category of the identity
 * \param type The type of the identity
 * \return An initialized XMPPDiscoIdentity
 */
- initWithCategory: (OFString *)category
	      type: (OFString *)type;
@end

OF_ASSUME_NONNULL_END







|
|






>
|
>

>
>
|
>

>
>
|
>


|
|


|
|
|
|





|
|


|
|
|






|
|


|
|
|
|





|
|


|
|
|






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
100
101
102
 * POSSIBILITY OF SUCH DAMAGE.
 */

#import <ObjFW/ObjFW.h>

OF_ASSUME_NONNULL_BEGIN

/*!
 * @brief A class describing a Service Discovery Identity
 */
@interface XMPPDiscoIdentity: OFObject <OFComparing>
{
	OFString *_category, *_name, *_type;
}

/*!
 * The category of the identity.
 */
@property (readonly, nonatomic) OFString *category;

/*!
 * The name of the identity, might be unset.
 */
@property (readonly, nonatomic) OFString *name;

/*!
 * The type of the identity.
 */
@property (readonly, nonatomic) OFString *type;

/*!
 * @brief Creates a new autoreleased XMPPDiscoIdentity with the specified
 *	  category, type and name.
 *
 * @param category The category of the identity
 * @param type The type of the identity
 * @param name The name of the identity
 * @return A new autoreleased XMPPDiscoIdentity
 */
+ (instancetype)identityWithCategory: (OFString *)category
				type: (OFString *)type
				name: (nullable OFString *)name;

/*!
 * @brief Creates a new autoreleased XMPPDiscoIdentity with the specified
 *	  category and type.
 *
 * @param category The category of the identity
 * @param type The type of the identity
 * @return A new autoreleased XMPPDiscoIdentity
 */
+ (instancetype)identityWithCategory: (OFString *)category
				type: (OFString *)type;

- init OF_UNAVAILABLE;

/*!
 * @brief Initializes an already allocated XMPPDiscoIdentity with the specified
 *	  category, type and name.
 *
 * @param category The category of the identity
 * @param type The type of the identity
 * @param name The name of the identity
 * @return An initialized XMPPDiscoIdentity
 */
- initWithCategory: (OFString *)category
	      type: (OFString *)type
	      name: (nullable OFString *)name OF_DESIGNATED_INITIALIZER;

/*!
 * @brief Initializes an already allocated XMPPDiscoIdentity with the specified
 *	  category and type.
 *
 * @param category The category of the identity
 * @param type The type of the identity
 * @return An initialized XMPPDiscoIdentity
 */
- initWithCategory: (OFString *)category
	      type: (OFString *)type;
@end

OF_ASSUME_NONNULL_END

Modified src/XMPPDiscoNode.h from [04990bb259] to [252498f722].

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
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
#import <ObjFW/ObjFW.h>

OF_ASSUME_NONNULL_BEGIN

@class XMPPDiscoIdentity;
@class XMPPJID;

/**
 * \brief A class describing a Service Discovery Node
 */
@interface XMPPDiscoNode: OFObject
{
	XMPPJID *_JID;
	OFString *_node;
	OFString *_name;
	OFSortedList *_identities;
	OFSortedList *_features;
	OFMutableDictionary *_childNodes;
}


/// \brief The JID this node lives on

@property (readonly, nonatomic) XMPPJID *JID;


/// \brief The node's opaque name of the node

@property (readonly, nonatomic) OFString *node;


/// \brief The node's human friendly name (may be unspecified)

@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *name;


/// \brief The node's list of identities

@property (readonly, nonatomic) OFSortedList *identities;


/// \brief The node's list of features

@property (readonly, nonatomic) OFSortedList *features;


/// \brief The node's children

@property (readonly, nonatomic) OFDictionary *childNodes;

/**
 * \brief Creates a new autoreleased XMPPDiscoNode with the specified
 *	  JID and node
 *
 * \param JID The JID this node lives on
 * \param node The node's opaque name
 * \return A new autoreleased XMPPDiscoNode
 */
+ (instancetype)discoNodeWithJID: (XMPPJID *)JID
			    node: (nullable OFString *)node;

/**
 * \brief Creates a new autoreleased XMPPDiscoNode with the specified
 *	  JID, node and name
 *
 * \param JID The JID this node lives on
 * \param node The node's opaque name
 * \param name The node's human friendly name
 * \return A new autoreleased XMPPDiscoNode
 */
+ (instancetype)discoNodeWithJID: (XMPPJID *)JID
			    node: (nullable OFString *)node
			    name: (nullable OFString *)name;

/**
 * \brief Initializes an already allocated XMPPDiscoNode with the specified
 *	  JID and node
 *
 * \param JID The JID this node lives on
 * \param node The node's opaque name
 * \return An initialized XMPPDiscoNode
 */
- initWithJID: (XMPPJID *)JID
	 node: (nullable OFString *)node;

/**
 * \brief Initializes an already allocated XMPPDiscoNode with the specified
 *	  JID, node and name
 *
 * \param JID The JID this node lives on
 * \param node The node's opaque name
 * \param name The node's human friendly name
 * \return An initialized XMPPDiscoNode
 */
- initWithJID: (XMPPJID *)JID
	 node: (nullable OFString *)node
	 name: (nullable OFString *)name OF_DESIGNATED_INITIALIZER;

 /**
  * \brief Adds an XMPPDiscoIdentity to the node
  *
  * \param identity The XMPPDiscoIdentity to add
  */
- (void)addIdentity: (XMPPDiscoIdentity *)identity;

 /**
  * \brief Adds a feature to the node
  *
  * \param feature The feature to add
  */
- (void)addFeature: (OFString *)feature;

 /**
  * \brief Adds a XMPPDiscoNode as child of the node
  *
  * \param node The XMPPDiscoNode to add as child
  */
- (void)addChildNode: (XMPPDiscoNode *)node;
@end

OF_ASSUME_NONNULL_END







|
|











>
|
>

>
>
|
>

>
>
|
>

>
>
|
>

>
>
|
>

>
>
|
>


|
|


|
|
|




|
|


|
|
|
|





|
|


|
|
|




|
|


|
|
|
|





|
|

|



|
|

|



|
|

|





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
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
#import <ObjFW/ObjFW.h>

OF_ASSUME_NONNULL_BEGIN

@class XMPPDiscoIdentity;
@class XMPPJID;

/*!
 * @brief A class describing a Service Discovery Node
 */
@interface XMPPDiscoNode: OFObject
{
	XMPPJID *_JID;
	OFString *_node;
	OFString *_name;
	OFSortedList *_identities;
	OFSortedList *_features;
	OFMutableDictionary *_childNodes;
}

/*!
 * @brief The JID this node lives on.
 */
@property (readonly, nonatomic) XMPPJID *JID;

/*!
 * @brief The node's opaque name of the node.
 */
@property (readonly, nonatomic) OFString *node;

/*!
 * @brief The node's human friendly name (may be unspecified).
 */
@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *name;

/*!
 * @brief The node's list of identities.
 */
@property (readonly, nonatomic) OFSortedList *identities;

/*!
 * @brief The node's list of features.
 */
@property (readonly, nonatomic) OFSortedList *features;

/*!
 * @brief The node's children.
 */
@property (readonly, nonatomic) OFDictionary *childNodes;

/*!
 * @brief Creates a new autoreleased XMPPDiscoNode with the specified
 *	  JID and node
 *
 * @param JID The JID this node lives on
 * @param node The node's opaque name
 * @return A new autoreleased XMPPDiscoNode
 */
+ (instancetype)discoNodeWithJID: (XMPPJID *)JID
			    node: (nullable OFString *)node;

/*!
 * @brief Creates a new autoreleased XMPPDiscoNode with the specified
 *	  JID, node and name
 *
 * @param JID The JID this node lives on
 * @param node The node's opaque name
 * @param name The node's human friendly name
 * @return A new autoreleased XMPPDiscoNode
 */
+ (instancetype)discoNodeWithJID: (XMPPJID *)JID
			    node: (nullable OFString *)node
			    name: (nullable OFString *)name;

/*!
 * @brief Initializes an already allocated XMPPDiscoNode with the specified
 *	  JID and node
 *
 * @param JID The JID this node lives on
 * @param node The node's opaque name
 * @return An initialized XMPPDiscoNode
 */
- initWithJID: (XMPPJID *)JID
	 node: (nullable OFString *)node;

/*!
 * @brief Initializes an already allocated XMPPDiscoNode with the specified
 *	  JID, node and name
 *
 * @param JID The JID this node lives on
 * @param node The node's opaque name
 * @param name The node's human friendly name
 * @return An initialized XMPPDiscoNode
 */
- initWithJID: (XMPPJID *)JID
	 node: (nullable OFString *)node
	 name: (nullable OFString *)name OF_DESIGNATED_INITIALIZER;

 /*!
  * @brief Adds an XMPPDiscoIdentity to the node
  *
  * @param identity The XMPPDiscoIdentity to add
  */
- (void)addIdentity: (XMPPDiscoIdentity *)identity;

 /*!
  * @brief Adds a feature to the node
  *
  * @param feature The feature to add
  */
- (void)addFeature: (OFString *)feature;

 /*!
  * @brief Adds a XMPPDiscoNode as child of the node
  *
  * @param node The XMPPDiscoNode to add as child
  */
- (void)addChildNode: (XMPPDiscoNode *)node;
@end

OF_ASSUME_NONNULL_END

Modified src/XMPPEXTERNALAuth.h from [0051e84d45] to [94169d2ce7].

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
 */

#import <ObjFW/ObjFW.h>
#import "XMPPAuthenticator.h"

OF_ASSUME_NONNULL_BEGIN

/**
 * \brief A class to authenticate using SASL EXTERNAL
 */
@interface XMPPEXTERNALAuth: XMPPAuthenticator
/**
 * \brief Creates a new autoreleased XMPPEXTERNALAuth.
 *
 * \return A new autoreleased XMPPEXTERNALAuth
 */
+ (instancetype)EXTERNALAuth;

/**
 * \brief Creates a new autoreleased XMPPEXTERNALAuth with an authzid.
 *
 * \param authzid The authzid to get authorization for
 * \return A new autoreleased XMPPEXTERNALAuth
 */
+ (instancetype)EXTERNALAuthWithAuthzid: (nullable OFString *)authzid;
@end

OF_ASSUME_NONNULL_END







|
|


|
|

|



|
|

|
|





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
 */

#import <ObjFW/ObjFW.h>
#import "XMPPAuthenticator.h"

OF_ASSUME_NONNULL_BEGIN

/*!
 * @brief A class to authenticate using SASL EXTERNAL
 */
@interface XMPPEXTERNALAuth: XMPPAuthenticator
/*!
 * @brief Creates a new autoreleased XMPPEXTERNALAuth.
 *
 * @return A new autoreleased XMPPEXTERNALAuth
 */
+ (instancetype)EXTERNALAuth;

/*!
 * @brief Creates a new autoreleased XMPPEXTERNALAuth with an authzid.
 *
 * @param authzid The authzid to get authorization for
 * @return A new autoreleased XMPPEXTERNALAuth
 */
+ (instancetype)EXTERNALAuthWithAuthzid: (nullable OFString *)authzid;
@end

OF_ASSUME_NONNULL_END

Modified src/XMPPExceptions.h from [679b6851a0] to [25d94540d0].

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
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
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
216
217
218
219
#import <ObjFW/ObjFW.h>

OF_ASSUME_NONNULL_BEGIN

@class XMPPConnection;
@class XMPPAuthenticator;

/**
 * \brief A base class for XMPP related exceptions
 */
@interface XMPPException: OFException
{
	XMPPConnection *_connection;
}


/// \brief The connection the exception relates to

@property OF_NULLABLE_PROPERTY (readonly, nonatomic) XMPPConnection *connection;

/**
 * \brief Creates a new XMPPException.
 *
 * \param connection The connection that received the data responsible
 *	  for this exception
 * \return A new XMPPException
 */
+ (instancetype)exceptionWithConnection: (nullable XMPPConnection *)connection;

- init OF_UNAVAILABLE;

/**
 * \brief Initializes an already allocated XMPPException.
 *
 * \param connection The connection that received the data responsible
 *	  for this exception
 * \return An initialized XMPPException
 */
- initWithConnection: (nullable XMPPConnection *)connection
    OF_DESIGNATED_INITIALIZER;
@end

/**
 * \brief An exception indicating a stream error was received
 */
@interface XMPPStreamErrorException: XMPPException
{
	OFString *_condition, *_reason;
}


/// \brief The defined error condition specified by the stream error

@property (readonly, nonatomic) OFString *condition;


/// \brief The descriptive free-form text specified by the stream error

@property (readonly, nonatomic) OFString *reason;

/**
 * \brief Creates a new XMPPStreamErrorException.
 *
 * \param connection The connection that received the stream error
 * \param condition The defined error condition specified by the stream error
 * \param reason The descriptive free-form text specified by the stream error
 * \return A new XMPPStreamErrorException
 */
+ (instancetype)exceptionWithConnection: (nullable XMPPConnection *)connection
			      condition: (OFString *)condition
				 reason: (OFString *)reason;

- initWithConnection: (nullable XMPPConnection *)connection OF_UNAVAILABLE;

/**
 * \brief Initializes an already allocated XMPPStreamErrorException.
 *
 * \param connection The connection that received the stream error
 * \param condition The defined error condition specified by the stream error
 * \param reason The descriptive free-form text specified by the stream error
 * \return An initialized XMPPStreamErrorException
 */
- initWithConnection: (nullable XMPPConnection *)connection
	   condition: (OFString *)condition
	      reason: (OFString *)reason OF_DESIGNATED_INITIALIZER;
@end

/**
 * \brief An exception indicating a stringprep profile
 *	  did not apply to a string
 */
@interface XMPPStringPrepFailedException: XMPPException
{
	OFString *_profile, *_string;
}


/// \brief The name of the stringprep profile that did not apply

@property (readonly, nonatomic) OFString *profile;


/// \brief The string that failed the stringprep profile

@property (readonly, nonatomic) OFString *string;

/**
 * \brief Creates a new XMPPStringPrepFailedException.
 *
 * \param connection The connection the string relates to
 * \param profile The name of the stringprep profile that did not apply
 * \param string The string that failed the stringprep profile
 * \return A new XMPPStringPrepFailedException
 */
+ (instancetype)exceptionWithConnection: (nullable XMPPConnection *)connection
				profile: (OFString *)profile
				 string: (OFString *)string;

- initWithConnection: (nullable XMPPConnection *)connection OF_UNAVAILABLE;

/**
 * \brief Initializes an already allocated XMPPStringPrepFailedException.
 *
 * \param connection The connection the string relates to
 * \param profile The name of the stringprep profile that did not apply
 * \param string The string that failed the stringprep profile
 * \return An initialized XMPPStringPrepFailedException
 */
- initWithConnection: (nullable XMPPConnection *)connection
	     profile: (OFString *)profile
	      string: (OFString *)string OF_DESIGNATED_INITIALIZER;
@end

/**
 * \brief An exception indicating IDNA translation of a string failed
 */
@interface XMPPIDNATranslationFailedException: XMPPException
{
	OFString *_operation, *_string;
}


/// \brief The IDNA translation operation which failed

@property (readonly, nonatomic) OFString *operation;


/// \brief The string that could not be translated

@property (readonly, nonatomic) OFString *string;

/**
 * \brief Creates a new XMPPIDNATranslationFailedException.
 *
 * \param connection The connection the string relates to
 * \param operation The name of the stringprep profile that did not apply
 * \param string The string that could not be translated
 * \return A new XMPPIDNATranslationFailedException
 */
+ (instancetype)exceptionWithConnection: (nullable XMPPConnection *)connection
			      operation: (OFString *)operation
				 string: (OFString *)string;

- initWithConnection: (nullable XMPPConnection *)connection OF_UNAVAILABLE;

/**
 * \brief Initializes an already allocated XMPPIDNATranslationFailedException.
 *
 * \param connection The connection the string relates to
 * \param operation The name of the stringprep profile that did not apply
 * \param string The string that could not be translated
 * \return An initialized XMPPIDNATranslationFailedException
 */
- initWithConnection: (nullable XMPPConnection *)connection
	   operation: (OFString *)operation
	      string: (OFString *)string;
@end

/**
 * \brief An exception indicating authentication failed
 */
@interface XMPPAuthFailedException: XMPPException
{
	OFString *_reason;
}


/// \brief The reason the authentication failed

@property (readonly, nonatomic) OFString *reason;

/**
 * \brief Creates a new XMPPAuthFailedException.
 *
 * \param connection The connection that could not be authenticated
 * \param reason The reason the authentication failed
 * \return A new XMPPAuthFailedException
 */
+ (instancetype)exceptionWithConnection: (nullable XMPPConnection *)connection
				 reason: (OFString *)reason;

- initWithConnection: (nullable XMPPConnection *)connection OF_UNAVAILABLE;

/**
 * \brief Initializes an already allocated XMPPAuthFailedException.
 *
 * \param connection The connection that could not be authenticated
 * \param reason The reason the authentication failed
 * \return An initialized XMPPAuthFailedException
 */
- initWithConnection: (nullable XMPPConnection *)connection
	      reason: (OFString *)reason OF_DESIGNATED_INITIALIZER;
@end

OF_ASSUME_NONNULL_END







|
|






>
|
>


|
|

|

|





|
|

|

|





|
|






>
|
>

>
>
|
>


|
|

|
|
|
|







|
|

|
|
|
|






|
|







>
|
>

>
>
|
>


|
|

|
|
|
|







|
|

|
|
|
|






|
|






>
|
>

>
>
|
>


|
|

|
|
|
|







|
|

|
|
|
|






|
|






>
|
>


|
|

|
|
|






|
|

|
|
|






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
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
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#import <ObjFW/ObjFW.h>

OF_ASSUME_NONNULL_BEGIN

@class XMPPConnection;
@class XMPPAuthenticator;

/*!
 * @brief A base class for XMPP related exceptions
 */
@interface XMPPException: OFException
{
	XMPPConnection *_connection;
}

/*!
 * The connection the exception relates to.
 */
@property OF_NULLABLE_PROPERTY (readonly, nonatomic) XMPPConnection *connection;

/*!
 * @brief Creates a new XMPPException.
 *
 * @param connection The connection that received the data responsible
 *	  for this exception
 * @return A new XMPPException
 */
+ (instancetype)exceptionWithConnection: (nullable XMPPConnection *)connection;

- init OF_UNAVAILABLE;

/*!
 * @brief Initializes an already allocated XMPPException.
 *
 * @param connection The connection that received the data responsible
 *	  for this exception
 * @return An initialized XMPPException
 */
- initWithConnection: (nullable XMPPConnection *)connection
    OF_DESIGNATED_INITIALIZER;
@end

/*!
 * @brief An exception indicating a stream error was received
 */
@interface XMPPStreamErrorException: XMPPException
{
	OFString *_condition, *_reason;
}

/*!
 * @brief The defined error condition specified by the stream error.
 */
@property (readonly, nonatomic) OFString *condition;

/*!
 * @brief The descriptive free-form text specified by the stream error.
 */
@property (readonly, nonatomic) OFString *reason;

/*!
 * @brief Creates a new XMPPStreamErrorException.
 *
 * @param connection The connection that received the stream error
 * @param condition The defined error condition specified by the stream error
 * @param reason The descriptive free-form text specified by the stream error
 * @return A new XMPPStreamErrorException
 */
+ (instancetype)exceptionWithConnection: (nullable XMPPConnection *)connection
			      condition: (OFString *)condition
				 reason: (OFString *)reason;

- initWithConnection: (nullable XMPPConnection *)connection OF_UNAVAILABLE;

/*!
 * @brief Initializes an already allocated XMPPStreamErrorException.
 *
 * @param connection The connection that received the stream error
 * @param condition The defined error condition specified by the stream error
 * @param reason The descriptive free-form text specified by the stream error
 * @return An initialized XMPPStreamErrorException
 */
- initWithConnection: (nullable XMPPConnection *)connection
	   condition: (OFString *)condition
	      reason: (OFString *)reason OF_DESIGNATED_INITIALIZER;
@end

/*!
 * @brief An exception indicating a stringprep profile
 *	  did not apply to a string
 */
@interface XMPPStringPrepFailedException: XMPPException
{
	OFString *_profile, *_string;
}

/*!
 * @brief The name of the stringprep profile that did not apply.
 */
@property (readonly, nonatomic) OFString *profile;

/*!
 * @brief The string that failed the stringprep profile.
 */
@property (readonly, nonatomic) OFString *string;

/*!
 * @brief Creates a new XMPPStringPrepFailedException.
 *
 * @param connection The connection the string relates to
 * @param profile The name of the stringprep profile that did not apply
 * @param string The string that failed the stringprep profile
 * @return A new XMPPStringPrepFailedException
 */
+ (instancetype)exceptionWithConnection: (nullable XMPPConnection *)connection
				profile: (OFString *)profile
				 string: (OFString *)string;

- initWithConnection: (nullable XMPPConnection *)connection OF_UNAVAILABLE;

/*!
 * @brief Initializes an already allocated XMPPStringPrepFailedException.
 *
 * @param connection The connection the string relates to
 * @param profile The name of the stringprep profile that did not apply
 * @param string The string that failed the stringprep profile
 * @return An initialized XMPPStringPrepFailedException
 */
- initWithConnection: (nullable XMPPConnection *)connection
	     profile: (OFString *)profile
	      string: (OFString *)string OF_DESIGNATED_INITIALIZER;
@end

/*!
 * @brief An exception indicating IDNA translation of a string failed
 */
@interface XMPPIDNATranslationFailedException: XMPPException
{
	OFString *_operation, *_string;
}

/*!
 * @brief The IDNA translation operation which failed.
 */
@property (readonly, nonatomic) OFString *operation;

/*!
 * @brief The string that could not be translated.
 */
@property (readonly, nonatomic) OFString *string;

/*!
 * @brief Creates a new XMPPIDNATranslationFailedException.
 *
 * @param connection The connection the string relates to
 * @param operation The name of the stringprep profile that did not apply
 * @param string The string that could not be translated
 * @return A new XMPPIDNATranslationFailedException
 */
+ (instancetype)exceptionWithConnection: (nullable XMPPConnection *)connection
			      operation: (OFString *)operation
				 string: (OFString *)string;

- initWithConnection: (nullable XMPPConnection *)connection OF_UNAVAILABLE;

/*!
 * @brief Initializes an already allocated XMPPIDNATranslationFailedException.
 *
 * @param connection The connection the string relates to
 * @param operation The name of the stringprep profile that did not apply
 * @param string The string that could not be translated
 * @return An initialized XMPPIDNATranslationFailedException
 */
- initWithConnection: (nullable XMPPConnection *)connection
	   operation: (OFString *)operation
	      string: (OFString *)string;
@end

/*!
 * @brief An exception indicating authentication failed
 */
@interface XMPPAuthFailedException: XMPPException
{
	OFString *_reason;
}

/*!
 * The reason the authentication failed.
 */
@property (readonly, nonatomic) OFString *reason;

/*!
 * @brief Creates a new XMPPAuthFailedException.
 *
 * @param connection The connection that could not be authenticated
 * @param reason The reason the authentication failed
 * @return A new XMPPAuthFailedException
 */
+ (instancetype)exceptionWithConnection: (nullable XMPPConnection *)connection
				 reason: (OFString *)reason;

- initWithConnection: (nullable XMPPConnection *)connection OF_UNAVAILABLE;

/*!
 * @brief Initializes an already allocated XMPPAuthFailedException.
 *
 * @param connection The connection that could not be authenticated
 * @param reason The reason the authentication failed
 * @return An initialized XMPPAuthFailedException
 */
- initWithConnection: (nullable XMPPConnection *)connection
	      reason: (OFString *)reason OF_DESIGNATED_INITIALIZER;
@end

OF_ASSUME_NONNULL_END

Modified src/XMPPIQ.h from [e565b6e506] to [6b12f9e135].

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
 * POSSIBILITY OF SUCH DAMAGE.
 */

#import "XMPPStanza.h"

OF_ASSUME_NONNULL_BEGIN

/**
 * \brief A class describing an IQ stanza.
 */
@interface XMPPIQ: XMPPStanza
/**
 * \brief Creates a new XMPPIQ with the specified type and ID.
 *
 * \param type The value for the stanza's type attribute
 * \param ID The value for the stanza's id attribute
 * \return A new autoreleased XMPPIQ
 */
+ (instancetype)IQWithType: (OFString *)type
			ID: (OFString *)ID;

/**
 * \brief Initializes an already allocated XMPPIQ with the specified type and
 *	  ID.
 *
 * \param type The value for the stanza's type attribute
 * \param ID The value for the stanza's id attribute
 * \return An initialized XMPPIQ
 */
- initWithType: (OFString *)type
	    ID: (OFString *)ID;

/**
 * \brief Generates a result IQ for the receiving object.
 *
 * \return A new autoreleased XMPPIQ
 */
- (XMPPIQ *)resultIQ;

/**
 * \brief Generates an error IQ for the receiving object.
 *
 * \param type An error type as defined by RFC 6120
 * \param condition An error condition as defined by RFC 6120
 * \param text A descriptive text
 * \return A new autoreleased XMPPIQ
 */
- (XMPPIQ *)errorIQWithType: (OFString *)type
		  condition: (OFString *)condition
		       text: (nullable OFString *)text;

/**
 * \brief Generates an error IQ for the receiving object.
 *
 * \param type An error type as defined by RFC 6120
 * \param condition A defined conditions from RFC 6120
 * \return A new autoreleased XMPPIQ
 */
- (XMPPIQ *)errorIQWithType: (OFString *)type
		  condition: (OFString *)condition;
@end

OF_ASSUME_NONNULL_END







|
|


|
|

|
|
|




|
|


|
|
|




|
|

|



|
|

|
|
|
|





|
|

|
|
|






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
 * POSSIBILITY OF SUCH DAMAGE.
 */

#import "XMPPStanza.h"

OF_ASSUME_NONNULL_BEGIN

/*!
 * @brief A class describing an IQ stanza.
 */
@interface XMPPIQ: XMPPStanza
/*!
 * @brief Creates a new XMPPIQ with the specified type and ID.
 *
 * @param type The value for the stanza's type attribute
 * @param ID The value for the stanza's id attribute
 * @return A new autoreleased XMPPIQ
 */
+ (instancetype)IQWithType: (OFString *)type
			ID: (OFString *)ID;

/*!
 * @brief Initializes an already allocated XMPPIQ with the specified type and
 *	  ID.
 *
 * @param type The value for the stanza's type attribute
 * @param ID The value for the stanza's id attribute
 * @return An initialized XMPPIQ
 */
- initWithType: (OFString *)type
	    ID: (OFString *)ID;

/*!
 * @brief Generates a result IQ for the receiving object.
 *
 * @return A new autoreleased XMPPIQ
 */
- (XMPPIQ *)resultIQ;

/*!
 * @brief Generates an error IQ for the receiving object.
 *
 * @param type An error type as defined by RFC 6120
 * @param condition An error condition as defined by RFC 6120
 * @param text A descriptive text
 * @return A new autoreleased XMPPIQ
 */
- (XMPPIQ *)errorIQWithType: (OFString *)type
		  condition: (OFString *)condition
		       text: (nullable OFString *)text;

/*!
 * @brief Generates an error IQ for the receiving object.
 *
 * @param type An error type as defined by RFC 6120
 * @param condition A defined conditions from RFC 6120
 * @return A new autoreleased XMPPIQ
 */
- (XMPPIQ *)errorIQWithType: (OFString *)type
		  condition: (OFString *)condition;
@end

OF_ASSUME_NONNULL_END

Modified src/XMPPJID.h from [bbf76b475f] to [0c0144bead].

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
 * POSSIBILITY OF SUCH DAMAGE.
 */

#import <ObjFW/ObjFW.h>

OF_ASSUME_NONNULL_BEGIN

/**
 * \brief A class for easy handling of JIDs.
 */
@interface XMPPJID: OFObject <OFCopying>
{
	OFString *_node, *_domain, *_resource;
}


/// \brief The JID's localpart

@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *node;


/// \brief The JID's domainpart

@property (nonatomic, copy) OFString *domain;


/// \brief The JID's resourcepart

@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *resource;

/**
 * \brief Creates a new autoreleased XMPPJID.
 *
 * \return A new autoreleased XMPPJID
 */
+ (instancetype)JID;

/**
 * \brief Creates a new autoreleased XMPPJID from a string.
 *
 * \param string The string to parse into a JID object
 * \return A new autoreleased XMPPJID
 */
+ (instancetype)JIDWithString: (OFString *)string;

/**
 * \brief Initializes an already allocated XMPPJID with a string.
 *
 * \param string The string to parse into a JID object
 * \return A initialized XMPPJID
 */
- initWithString: (OFString *)string;

/**
 * \brief Returns the bare JID.
 *
 * \return An OFString containing the bare JID
 */
- (OFString *)bareJID;

/**
 * \brief Returns the full JID.
 *
 * \return An OFString containing the full JID
 */
- (OFString *)fullJID;
@end

OF_ASSUME_NONNULL_END







|
|






>
|
>

>
>
|
>

>
>
|
>


|
|

|



|
|

|
|



|
|

|
|



|
|

|



|
|

|





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
 * POSSIBILITY OF SUCH DAMAGE.
 */

#import <ObjFW/ObjFW.h>

OF_ASSUME_NONNULL_BEGIN

/*!
 * @brief A class for easy handling of JIDs.
 */
@interface XMPPJID: OFObject <OFCopying>
{
	OFString *_node, *_domain, *_resource;
}

/*!
 * The JID's localpart.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *node;

/*!
 * The JID's domainpart.
 */
@property (nonatomic, copy) OFString *domain;

/*!
 * The JID's resourcepart.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *resource;

/*!
 * @brief Creates a new autoreleased XMPPJID.
 *
 * @return A new autoreleased XMPPJID
 */
+ (instancetype)JID;

/*!
 * @brief Creates a new autoreleased XMPPJID from a string.
 *
 * @param string The string to parse into a JID object
 * @return A new autoreleased XMPPJID
 */
+ (instancetype)JIDWithString: (OFString *)string;

/*!
 * @brief Initializes an already allocated XMPPJID with a string.
 *
 * @param string The string to parse into a JID object
 * @return A initialized XMPPJID
 */
- initWithString: (OFString *)string;

/*!
 * @brief Returns the bare JID.
 *
 * @return An OFString containing the bare JID
 */
- (OFString *)bareJID;

/*!
 * @brief Returns the full JID.
 *
 * @return An OFString containing the full JID
 */
- (OFString *)fullJID;
@end

OF_ASSUME_NONNULL_END

Modified src/XMPPMessage.h from [c499d3c2dc] to [c8a8b87bf3].

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
 * POSSIBILITY OF SUCH DAMAGE.
 */

#import "XMPPStanza.h"

OF_ASSUME_NONNULL_BEGIN

/**
 * \brief A class describing a message stanza.
 */
@interface XMPPMessage: XMPPStanza
/** The text content of the body of the message. */
@property (copy) OFString *body;

/**
 * \brief Creates a new autoreleased XMPPMessage.
 *
 * \return A new autoreleased XMPPMessage
 */
+ (instancetype)message;

/**
 * \brief Creates a new autoreleased XMPPMessage with the specified ID.
 *
 * \param ID The value for the stanza's id attribute
 * \return A new autoreleased XMPPMessage
 */
+ (instancetype)messageWithID: (nullable OFString *)ID;

/**
 * \brief Creates a new autoreleased XMPPMessage with the specified type.
 *
 * \param type The value for the stanza's type attribute
 * \return A new autoreleased XMPPMessage
 */
+ (instancetype)messageWithType: (nullable OFString *)type;

/**
 * \brief Creates a new autoreleased XMPPMessage with the specified type and ID.
 *
 * \param type The value for the stanza's type attribute
 * \param ID The value for the stanza's id attribute
 * \return A new autoreleased XMPPMessage
 */
+ (instancetype)messageWithType: (nullable OFString *)type
			     ID: (nullable OFString *)ID;

/**
 * \brief Initializes an already allocated XMPPMessage with the specified ID.
 *
 * \param ID The value for the stanza's id attribute
 * \return A initialized XMPPMessage
 */
- initWithID: (nullable OFString *)ID;

/**
 * \brief Initializes an already allocated XMPPMessage with the specified type.
 *
 * \param type The value for the stanza's type attribute
 * \return A initialized XMPPMessage
 */
- initWithType: (nullable OFString *)type;

/**
 * \brief Initializes an already allocated XMPPMessage with the specified type
 *	  and ID.
 *
 * \param type The value for the stanza's type attribute
 * \param ID The value for the stanza's id attribute
 * \return A initialized XMPPMessage
 */
- initWithType: (nullable OFString *)type
	    ID: (nullable OFString *)ID OF_DESIGNATED_INITIALIZER;
@end

OF_ASSUME_NONNULL_END







|
|


|


|
|

|



|
|

|
|



|
|

|
|



|
|

|
|
|




|
|

|
|



|
|

|
|



|
|


|
|
|






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
 * POSSIBILITY OF SUCH DAMAGE.
 */

#import "XMPPStanza.h"

OF_ASSUME_NONNULL_BEGIN

/*!
 * @brief A class describing a message stanza.
 */
@interface XMPPMessage: XMPPStanza
/*! The text content of the body of the message. */
@property (copy) OFString *body;

/*!
 * @brief Creates a new autoreleased XMPPMessage.
 *
 * @return A new autoreleased XMPPMessage
 */
+ (instancetype)message;

/*!
 * @brief Creates a new autoreleased XMPPMessage with the specified ID.
 *
 * @param ID The value for the stanza's id attribute
 * @return A new autoreleased XMPPMessage
 */
+ (instancetype)messageWithID: (nullable OFString *)ID;

/*!
 * @brief Creates a new autoreleased XMPPMessage with the specified type.
 *
 * @param type The value for the stanza's type attribute
 * @return A new autoreleased XMPPMessage
 */
+ (instancetype)messageWithType: (nullable OFString *)type;

/*!
 * @brief Creates a new autoreleased XMPPMessage with the specified type and ID.
 *
 * @param type The value for the stanza's type attribute
 * @param ID The value for the stanza's id attribute
 * @return A new autoreleased XMPPMessage
 */
+ (instancetype)messageWithType: (nullable OFString *)type
			     ID: (nullable OFString *)ID;

/*!
 * @brief Initializes an already allocated XMPPMessage with the specified ID.
 *
 * @param ID The value for the stanza's id attribute
 * @return A initialized XMPPMessage
 */
- initWithID: (nullable OFString *)ID;

/*!
 * @brief Initializes an already allocated XMPPMessage with the specified type.
 *
 * @param type The value for the stanza's type attribute
 * @return A initialized XMPPMessage
 */
- initWithType: (nullable OFString *)type;

/*!
 * @brief Initializes an already allocated XMPPMessage with the specified type
 *	  and ID.
 *
 * @param type The value for the stanza's type attribute
 * @param ID The value for the stanza's id attribute
 * @return A initialized XMPPMessage
 */
- initWithType: (nullable OFString *)type
	    ID: (nullable OFString *)ID OF_DESIGNATED_INITIALIZER;
@end

OF_ASSUME_NONNULL_END

Modified src/XMPPMulticastDelegate.h from [35f3f776c8] to [f5ae1a7771].

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

#import <ObjFW/OFObject.h>

OF_ASSUME_NONNULL_BEGIN

@class OFMutableData;

/**
 * \brief A class to provide multiple delegates in a single class
 */
@interface XMPPMulticastDelegate: OFObject
{
	OFMutableData *_delegates;
}

/**
 * \brief Adds a delegate which should receive the broadcasts.
 *
 * \param delegate The delegate to add
 */
- (void)addDelegate: (id)delegate;

/**
 * \brief Removes a delegate so it does not receive the broadcasts anymore.
 *
 * \param delegate The delegate to remove
 */
- (void)removeDelegate: (id)delegate;

/**
 * \brief Broadcasts a selector with an object to all registered delegates.
 *
 * \param selector The selector to broadcast
 * \param object The object to broadcast
 */
- (bool)broadcastSelector: (SEL)selector
	       withObject: (nullable id)object;

/**
 * \brief Broadcasts a selector with two objects to all registered delegates.
 *
 * \param selector The selector to broadcast
 * \param object1 The first object to broadcast
 * \param object2 The second object to broadcast
 */
- (bool)broadcastSelector: (SEL)selector
	       withObject: (nullable id)object1
	       withObject: (nullable id)object2;
@end

OF_ASSUME_NONNULL_END







|
|






|
|

|



|
|

|



|
|

|
|




|
|

|
|
|







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

#import <ObjFW/OFObject.h>

OF_ASSUME_NONNULL_BEGIN

@class OFMutableData;

/*!
 * @brief A class to provide multiple delegates in a single class
 */
@interface XMPPMulticastDelegate: OFObject
{
	OFMutableData *_delegates;
}

/*!
 * @brief Adds a delegate which should receive the broadcasts.
 *
 * @param delegate The delegate to add
 */
- (void)addDelegate: (id)delegate;

/*!
 * @brief Removes a delegate so it does not receive the broadcasts anymore.
 *
 * @param delegate The delegate to remove
 */
- (void)removeDelegate: (id)delegate;

/*!
 * @brief Broadcasts a selector with an object to all registered delegates.
 *
 * @param selector The selector to broadcast
 * @param object The object to broadcast
 */
- (bool)broadcastSelector: (SEL)selector
	       withObject: (nullable id)object;

/*!
 * @brief Broadcasts a selector with two objects to all registered delegates.
 *
 * @param selector The selector to broadcast
 * @param object1 The first object to broadcast
 * @param object2 The second object to broadcast
 */
- (bool)broadcastSelector: (SEL)selector
	       withObject: (nullable id)object1
	       withObject: (nullable id)object2;
@end

OF_ASSUME_NONNULL_END

Modified src/XMPPPLAINAuth.h from [3c1bd83caf] to [bbec616d93].

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
 */

#import <ObjFW/ObjFW.h>
#import "XMPPAuthenticator.h"

OF_ASSUME_NONNULL_BEGIN

/**
 * \brief A class to authenticate using SASL PLAIN
 */
@interface XMPPPLAINAuth: XMPPAuthenticator
/**
 * \brief Creates a new autoreleased XMPPPLAINAuth with an authcid and password.
 *
 * \param authcid The authcid to authenticate with
 * \param password The password to authenticate with
 * \return A new autoreleased XMPPPLAINAuth
 */
+ (instancetype)PLAINAuthWithAuthcid: (nullable OFString *)authcid
			    password: (nullable OFString *)password;

/**
 * \brief Creates a new autoreleased XMPPPLAINAuth with an authzid, authcid and
 *	  password.
 *
 * \param authzid The authzid to get authorization for
 * \param authcid The authcid to authenticate with
 * \param password The password to authenticate with
 * \return A new autoreleased XMPPPLAINAuth
 */
+ (instancetype)PLAINAuthWithAuthzid: (nullable OFString *)authzid
			     authcid: (nullable OFString *)authcid
			    password: (nullable OFString *)password;
@end

OF_ASSUME_NONNULL_END







|
|


|
|

|
|
|




|
|


|
|
|
|







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
 */

#import <ObjFW/ObjFW.h>
#import "XMPPAuthenticator.h"

OF_ASSUME_NONNULL_BEGIN

/*!
 * @brief A class to authenticate using SASL PLAIN
 */
@interface XMPPPLAINAuth: XMPPAuthenticator
/*!
 * @brief Creates a new autoreleased XMPPPLAINAuth with an authcid and password.
 *
 * @param authcid The authcid to authenticate with
 * @param password The password to authenticate with
 * @return A new autoreleased XMPPPLAINAuth
 */
+ (instancetype)PLAINAuthWithAuthcid: (nullable OFString *)authcid
			    password: (nullable OFString *)password;

/*!
 * @brief Creates a new autoreleased XMPPPLAINAuth with an authzid, authcid and
 *	  password.
 *
 * @param authzid The authzid to get authorization for
 * @param authcid The authcid to authenticate with
 * @param password The password to authenticate with
 * @return A new autoreleased XMPPPLAINAuth
 */
+ (instancetype)PLAINAuthWithAuthzid: (nullable OFString *)authzid
			     authcid: (nullable OFString *)authcid
			    password: (nullable OFString *)password;
@end

OF_ASSUME_NONNULL_END

Modified src/XMPPPresence.h from [0497c404f5] to [88a5ae6746].

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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
 * POSSIBILITY OF SUCH DAMAGE.
 */

#import "XMPPStanza.h"

OF_ASSUME_NONNULL_BEGIN

/**
 * \brief A class describing a presence stanza.
 */
@interface XMPPPresence: XMPPStanza <OFComparing>
{
	OFString *_status, *_show;
	OFNumber *_priority;
}

/**
 * The value of the stanza's type attribute.
 */
@property OF_NULL_RESETTABLE_PROPERTY (nonatomic, copy) OFString *type;

/**
 * The text content of the status element.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *status;

/**
 * The text content of the show element of the presence stanza.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *show;

/**
 * The numeric content of the priority element.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFNumber *priority;

/**
 * \brief Creates a new autoreleased XMPPPresence.
 *
 * \return A new autoreleased XMPPPresence
 */
+ (instancetype)presence;

/**
 * \brief Creates a new autoreleased XMPPPresence with the specified ID.
 *
 * \param ID The value for the stanza's id attribute
 * \return A new autoreleased XMPPPresence
 */
+ (instancetype)presenceWithID: (nullable OFString *)ID;

/**
 * \brief Creates a new autoreleased XMPPPresence with the specified type.
 *
 * \param type The value for the stanza's type attribute
 * \return A new autoreleased XMPPPresence
 */
+ (instancetype)presenceWithType: (nullable OFString *)type;

/**
 * \brief Creates a new autoreleased XMPPPresence with the specified type and
 *	  ID.
 *
 * \param type The value for the stanza's type attribute
 * \param ID The value for the stanza's id attribute
 * \return A new autoreleased XMPPPresence
 */
+ (instancetype)presenceWithType: (nullable OFString *)type
			      ID: (nullable OFString *)ID;

/**
 * \brief Initializes an already allocated XMPPPresence with the specified ID.
 *
 * \param ID The value for the stanza's id attribute
 * \return A initialized XMPPPresence
 */
- initWithID: (nullable OFString *)ID;

/**
 * \brief Initializes an already allocated XMPPPresence with the specified type.
 *
 * \param type The value for the stanza's type attribute
 * \return A initialized XMPPPresence
 */
- initWithType: (nullable OFString *)type;

/**
 * \brief Initializes an already allocated XMPPPresence with the specified type
 *	  and ID.
 *
 * \param type The value for the stanza's type attribute
 * \param ID The value for the stanza's id attribute
 * \return A initialized XMPPPresence
 */
- initWithType: (nullable OFString *)type
	    ID: (nullable OFString *)ID;
@end

OF_ASSUME_NONNULL_END







|
|







|




|




|




|




|
|

|



|
|

|
|



|
|

|
|



|
|


|
|
|




|
|

|
|



|
|

|
|



|
|


|
|
|






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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
 * POSSIBILITY OF SUCH DAMAGE.
 */

#import "XMPPStanza.h"

OF_ASSUME_NONNULL_BEGIN

/*!
 * @brief A class describing a presence stanza.
 */
@interface XMPPPresence: XMPPStanza <OFComparing>
{
	OFString *_status, *_show;
	OFNumber *_priority;
}

/*!
 * The value of the stanza's type attribute.
 */
@property OF_NULL_RESETTABLE_PROPERTY (nonatomic, copy) OFString *type;

/*!
 * The text content of the status element.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *status;

/*!
 * The text content of the show element of the presence stanza.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *show;

/*!
 * The numeric content of the priority element.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFNumber *priority;

/*!
 * @brief Creates a new autoreleased XMPPPresence.
 *
 * @return A new autoreleased XMPPPresence
 */
+ (instancetype)presence;

/*!
 * @brief Creates a new autoreleased XMPPPresence with the specified ID.
 *
 * @param ID The value for the stanza's id attribute
 * @return A new autoreleased XMPPPresence
 */
+ (instancetype)presenceWithID: (nullable OFString *)ID;

/*!
 * @brief Creates a new autoreleased XMPPPresence with the specified type.
 *
 * @param type The value for the stanza's type attribute
 * @return A new autoreleased XMPPPresence
 */
+ (instancetype)presenceWithType: (nullable OFString *)type;

/*!
 * @brief Creates a new autoreleased XMPPPresence with the specified type and
 *	  ID.
 *
 * @param type The value for the stanza's type attribute
 * @param ID The value for the stanza's id attribute
 * @return A new autoreleased XMPPPresence
 */
+ (instancetype)presenceWithType: (nullable OFString *)type
			      ID: (nullable OFString *)ID;

/*!
 * @brief Initializes an already allocated XMPPPresence with the specified ID.
 *
 * @param ID The value for the stanza's id attribute
 * @return A initialized XMPPPresence
 */
- initWithID: (nullable OFString *)ID;

/*!
 * @brief Initializes an already allocated XMPPPresence with the specified type.
 *
 * @param type The value for the stanza's type attribute
 * @return A initialized XMPPPresence
 */
- initWithType: (nullable OFString *)type;

/*!
 * @brief Initializes an already allocated XMPPPresence with the specified type
 *	  and ID.
 *
 * @param type The value for the stanza's type attribute
 * @param ID The value for the stanza's id attribute
 * @return A initialized XMPPPresence
 */
- initWithType: (nullable OFString *)type
	    ID: (nullable OFString *)ID;
@end

OF_ASSUME_NONNULL_END

Modified src/XMPPRoster.h from [7a62e71bc2] to [12b50e0f15].

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
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
OF_ASSUME_NONNULL_BEGIN

@class XMPPRosterItem;
@class XMPPIQ;
@class XMPPRoster;
@class XMPPMulticastDelegate;

/**
 * \brief A protocol that should be (partially) implemented by delegates
 *	  of a XMPPRoster
 */
@protocol XMPPRosterDelegate
@optional
/**
 * \brief This callback is called after the roster was received (as a result of
 *	  calling -requestRoster).
 *
 * \param roster The roster that was received
 */
- (void)rosterWasReceived: (XMPPRoster *)roster;

/**
 * \brief This callback is called whenever a roster push was received.
 *
 * \param roster The roster that was updated by the roster push
 * \param rosterItem The roster item received in the push
 */
-         (void)roster: (XMPPRoster *)roster
  didReceiveRosterItem: (XMPPRosterItem *)rosterItem;
@end

/**
 * \brief A class implementing roster related functionality.
 */
@interface XMPPRoster: OFObject <XMPPConnectionDelegate>
{
	XMPPConnection *_connection;
	OFMutableDictionary *_rosterItems;
	XMPPMulticastDelegate *_delegates;
	id <XMPPStorage> _dataStorage;
	bool _rosterRequested;
}

/**
 * \brief The connection to which the roster belongs
 */
@property (readonly, assign) XMPPConnection *connection;

/**
 * \brief An object for data storage, conforming to the XMPPStorage protocol.
 *
 * Inherited from the connection if not overridden.
 */
@property (nonatomic, assign) id <XMPPStorage> dataStorage;

/**
 * \brief The list of contacts as an OFDictionary with the bare JID as a string
 *	  as key.
 */
@property (readonly, nonatomic)
    OFDictionary OF_GENERIC(OFString *, XMPPRosterItem *) *rosterItems;

- init OF_UNAVAILABLE;

/**
 * \brief Initializes an already allocated XMPPRoster.
 *
 * \param connection The connection roster related stanzas are send and
 *		     received over
 * \return An initialized XMPPRoster
 */
- initWithConnection: (XMPPConnection *)connection OF_DESIGNATED_INITIALIZER;

/**
 * \brief Requests the roster from the server.
 */
- (void)requestRoster;

/**
 * \brief Adds a new contact to the roster.
 *
 * \param rosterItem The roster item to add to the roster
 */
- (void)addRosterItem: (XMPPRosterItem *)rosterItem;

/**
 * \brief Updates an already existing contact in the roster.
 *
 * \param rosterItem The roster item to update
 */
- (void)updateRosterItem: (XMPPRosterItem *)rosterItem;

/**
 * \brief Delete a contact from the roster.
 *
 * \param rosterItem The roster item to delete
 */
- (void)deleteRosterItem: (XMPPRosterItem *)rosterItem;

/**
 * \brief Adds the specified delegate.
 *
 * \param delegate The delegate to add
 */
- (void)addDelegate: (id <XMPPRosterDelegate>)delegate;

/**
 * \brief Removes the specified delegate.
 *
 * \param delegate The delegate to remove
 */
- (void)removeDelegate: (id <XMPPRosterDelegate>)delegate;
@end

OF_ASSUME_NONNULL_END







|
|




|
|


|



|
|

|
|





|
|










|
|



|
|





|
|







|
|

|

|



|
|



|
|

|



|
|

|



|
|

|



|
|

|



|
|

|





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
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
OF_ASSUME_NONNULL_BEGIN

@class XMPPRosterItem;
@class XMPPIQ;
@class XMPPRoster;
@class XMPPMulticastDelegate;

/*!
 * @brief A protocol that should be (partially) implemented by delegates
 *	  of a XMPPRoster
 */
@protocol XMPPRosterDelegate
@optional
/*!
 * @brief This callback is called after the roster was received (as a result of
 *	  calling -requestRoster).
 *
 * @param roster The roster that was received
 */
- (void)rosterWasReceived: (XMPPRoster *)roster;

/*!
 * @brief This callback is called whenever a roster push was received.
 *
 * @param roster The roster that was updated by the roster push
 * @param rosterItem The roster item received in the push
 */
-         (void)roster: (XMPPRoster *)roster
  didReceiveRosterItem: (XMPPRosterItem *)rosterItem;
@end

/*!
 * @brief A class implementing roster related functionality.
 */
@interface XMPPRoster: OFObject <XMPPConnectionDelegate>
{
	XMPPConnection *_connection;
	OFMutableDictionary *_rosterItems;
	XMPPMulticastDelegate *_delegates;
	id <XMPPStorage> _dataStorage;
	bool _rosterRequested;
}

/*!
 * @brief The connection to which the roster belongs
 */
@property (readonly, assign) XMPPConnection *connection;

/*!
 * @brief An object for data storage, conforming to the XMPPStorage protocol.
 *
 * Inherited from the connection if not overridden.
 */
@property (nonatomic, assign) id <XMPPStorage> dataStorage;

/*!
 * @brief The list of contacts as an OFDictionary with the bare JID as a string
 *	  as key.
 */
@property (readonly, nonatomic)
    OFDictionary OF_GENERIC(OFString *, XMPPRosterItem *) *rosterItems;

- init OF_UNAVAILABLE;

/*!
 * @brief Initializes an already allocated XMPPRoster.
 *
 * @param connection The connection roster related stanzas are send and
 *		     received over
 * @return An initialized XMPPRoster
 */
- initWithConnection: (XMPPConnection *)connection OF_DESIGNATED_INITIALIZER;

/*!
 * @brief Requests the roster from the server.
 */
- (void)requestRoster;

/*!
 * @brief Adds a new contact to the roster.
 *
 * @param rosterItem The roster item to add to the roster
 */
- (void)addRosterItem: (XMPPRosterItem *)rosterItem;

/*!
 * @brief Updates an already existing contact in the roster.
 *
 * @param rosterItem The roster item to update
 */
- (void)updateRosterItem: (XMPPRosterItem *)rosterItem;

/*!
 * @brief Delete a contact from the roster.
 *
 * @param rosterItem The roster item to delete
 */
- (void)deleteRosterItem: (XMPPRosterItem *)rosterItem;

/*!
 * @brief Adds the specified delegate.
 *
 * @param delegate The delegate to add
 */
- (void)addDelegate: (id <XMPPRosterDelegate>)delegate;

/*!
 * @brief Removes the specified delegate.
 *
 * @param delegate The delegate to remove
 */
- (void)removeDelegate: (id <XMPPRosterDelegate>)delegate;
@end

OF_ASSUME_NONNULL_END

Modified src/XMPPRosterItem.h from [b424f574a0] to [e89fc64008].

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

#import <ObjFW/ObjFW.h>

OF_ASSUME_NONNULL_BEGIN

@class XMPPJID;

/**
 * \brief A class for representing an item in the roster.
 */
@interface XMPPRosterItem: OFObject
{
	XMPPJID *_JID;
	OFString *_name;
	OFString *_subscription;
	OFArray *_groups;
}


/// \brief The JID of the roster item

@property (nonatomic, copy) XMPPJID *JID;


/// \brief The name of the roster item to show to the user

@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *name;


/// \brief The subscription for the roster item

@property (nonatomic, copy) OFString *subscription;


/// \brief An array of groups in which the roster item is

@property (nonatomic, copy) OFArray OF_GENERIC(OFString *) *groups;

/**
 * \brief Creates a new autoreleased roster item.
 *
 * \return A new autoreleased roster item.
 */
+ (instancetype)rosterItem;
@end

OF_ASSUME_NONNULL_END







|
|









>
|
>

>
>
|
>

>
>
|
>

>
>
|
>


|
|

|





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

#import <ObjFW/ObjFW.h>

OF_ASSUME_NONNULL_BEGIN

@class XMPPJID;

/*!
 * @brief A class for representing an item in the roster.
 */
@interface XMPPRosterItem: OFObject
{
	XMPPJID *_JID;
	OFString *_name;
	OFString *_subscription;
	OFArray *_groups;
}

/*!
 * The JID of the roster item.
 */
@property (nonatomic, copy) XMPPJID *JID;

/*!
 * The name of the roster item to show to the user.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *name;

/*!
 * The subscription for the roster item.
 */
@property (nonatomic, copy) OFString *subscription;

/*!
 * An array of groups in which the roster item is.
 */
@property (nonatomic, copy) OFArray OF_GENERIC(OFString *) *groups;

/*!
 * @brief Creates a new autoreleased roster item.
 *
 * @return A new autoreleased roster item.
 */
+ (instancetype)rosterItem;
@end

OF_ASSUME_NONNULL_END

Modified src/XMPPSCRAMAuth.h from [f16a3ea40b] to [4305196952].

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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122

#import <ObjFW/ObjFW.h>
#import "XMPPAuthenticator.h"
#import "XMPPConnection.h"

OF_ASSUME_NONNULL_BEGIN

/**
 * \brief A class to authenticate using SCRAM
 */
@interface XMPPSCRAMAuth: XMPPAuthenticator
{
	Class _hashType;
	OFString *_cNonce;
	OFString *_GS2Header;
	OFString *_clientFirstMessageBare;
	OFData *_serverSignature;
	XMPPConnection *_connection;
	bool _plusAvailable;
	bool _authenticated;
}

/**
 * \brief Creates a new autoreleased XMPPSCRAMAuth with an authcid and password.
 *
 * \param authcid The authcid to authenticate with
 * \param password The password to authenticate with
 * \param connection The connection over which authentication is done
 * \param hash The class to use for calulating hashes
 * \param plusAvailable Whether the PLUS variant was offered
 * \return A new autoreleased XMPPSCRAMAuth
 */
+ (instancetype)SCRAMAuthWithAuthcid: (nullable OFString *)authcid
			    password: (nullable OFString *)password
			  connection: (XMPPConnection *)connection
				hash: (Class)hash
		       plusAvailable: (bool)plusAvailable;

/**
 * \brief Creates a new autoreleased XMPPSCRAMAuth with an authzid, authcid and
 *	  password.
 *
 * \param authzid The authzid to get authorization for
 * \param authcid The authcid to authenticate with
 * \param password The password to authenticate with
 * \param connection The connection over which authentication is done
 * \param hash The class to use for calulating hashes
 * \param plusAvailable Whether the PLUS variant was offered
 * \return A new autoreleased XMPPSCRAMAuth
 */
+ (instancetype)SCRAMAuthWithAuthzid: (nullable OFString *)authzid
			     authcid: (nullable OFString *)authcid
			    password: (nullable OFString *)password
			  connection: (XMPPConnection *)connection
				hash: (Class)hash
		       plusAvailable: (bool)plusAvailable;

- initWithAuthcid: (nullable OFString *)authcid
	 password: (nullable OFString *)password OF_UNAVAILABLE;
- initWithAuthzid: (nullable OFString *)authzid
	  authcid: (nullable OFString *)authcid
	 password: (nullable OFString *)password OF_UNAVAILABLE;

/**
 * \brief Initializes an already allocated XMPPSCRAMAuth with an authcid and
 *	  password.
 *
 * \param authcid The authcid to authenticate with
 * \param password The password to authenticate with
 * \param connection The connection over which authentication is done
 * \param hash The class to use for calulating hashes
 * \param plusAvailable Whether the PLUS variant was offered
 * \return A initialized XMPPSCRAMAuth
 */
- initWithAuthcid: (nullable OFString *)authcid
	 password: (nullable OFString *)password
       connection: (XMPPConnection *)connection
	     hash: (Class)hash
    plusAvailable: (bool)plusAvailable;

/**
 * \brief Initializes an already allocated XMPPSCRAMAuth with a authzid,
 *	  authcid and password.
 *
 * \param authzid The authzid to get authorization for
 * \param authcid The authcid to authenticate with
 * \param password The password to authenticate with
 * \param connection The connection over which authentication is done
 * \param hash The class to use for calulating hashes
 * \param plusAvailable Whether the PLUS variant was offered
 * \return A initialized XMPPSCRAMAuth
 */
- initWithAuthzid: (nullable OFString *)authzid
	  authcid: (nullable OFString *)authcid
	 password: (nullable OFString *)password
       connection: (XMPPConnection *)connection
	     hash: (Class)hash
    plusAvailable: (bool)plusAvailable OF_DESIGNATED_INITIALIZER;
@end

OF_ASSUME_NONNULL_END







|
|













|
|

|
|
|
|
|
|







|
|


|
|
|
|
|
|
|














|
|


|
|
|
|
|
|







|
|


|
|
|
|
|
|
|










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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122

#import <ObjFW/ObjFW.h>
#import "XMPPAuthenticator.h"
#import "XMPPConnection.h"

OF_ASSUME_NONNULL_BEGIN

/*!
 * @brief A class to authenticate using SCRAM
 */
@interface XMPPSCRAMAuth: XMPPAuthenticator
{
	Class _hashType;
	OFString *_cNonce;
	OFString *_GS2Header;
	OFString *_clientFirstMessageBare;
	OFData *_serverSignature;
	XMPPConnection *_connection;
	bool _plusAvailable;
	bool _authenticated;
}

/*!
 * @brief Creates a new autoreleased XMPPSCRAMAuth with an authcid and password.
 *
 * @param authcid The authcid to authenticate with
 * @param password The password to authenticate with
 * @param connection The connection over which authentication is done
 * @param hash The class to use for calulating hashes
 * @param plusAvailable Whether the PLUS variant was offered
 * @return A new autoreleased XMPPSCRAMAuth
 */
+ (instancetype)SCRAMAuthWithAuthcid: (nullable OFString *)authcid
			    password: (nullable OFString *)password
			  connection: (XMPPConnection *)connection
				hash: (Class)hash
		       plusAvailable: (bool)plusAvailable;

/*!
 * @brief Creates a new autoreleased XMPPSCRAMAuth with an authzid, authcid and
 *	  password.
 *
 * @param authzid The authzid to get authorization for
 * @param authcid The authcid to authenticate with
 * @param password The password to authenticate with
 * @param connection The connection over which authentication is done
 * @param hash The class to use for calulating hashes
 * @param plusAvailable Whether the PLUS variant was offered
 * @return A new autoreleased XMPPSCRAMAuth
 */
+ (instancetype)SCRAMAuthWithAuthzid: (nullable OFString *)authzid
			     authcid: (nullable OFString *)authcid
			    password: (nullable OFString *)password
			  connection: (XMPPConnection *)connection
				hash: (Class)hash
		       plusAvailable: (bool)plusAvailable;

- initWithAuthcid: (nullable OFString *)authcid
	 password: (nullable OFString *)password OF_UNAVAILABLE;
- initWithAuthzid: (nullable OFString *)authzid
	  authcid: (nullable OFString *)authcid
	 password: (nullable OFString *)password OF_UNAVAILABLE;

/*!
 * @brief Initializes an already allocated XMPPSCRAMAuth with an authcid and
 *	  password.
 *
 * @param authcid The authcid to authenticate with
 * @param password The password to authenticate with
 * @param connection The connection over which authentication is done
 * @param hash The class to use for calulating hashes
 * @param plusAvailable Whether the PLUS variant was offered
 * @return A initialized XMPPSCRAMAuth
 */
- initWithAuthcid: (nullable OFString *)authcid
	 password: (nullable OFString *)password
       connection: (XMPPConnection *)connection
	     hash: (Class)hash
    plusAvailable: (bool)plusAvailable;

/*!
 * @brief Initializes an already allocated XMPPSCRAMAuth with a authzid,
 *	  authcid and password.
 *
 * @param authzid The authzid to get authorization for
 * @param authcid The authcid to authenticate with
 * @param password The password to authenticate with
 * @param connection The connection over which authentication is done
 * @param hash The class to use for calulating hashes
 * @param plusAvailable Whether the PLUS variant was offered
 * @return A initialized XMPPSCRAMAuth
 */
- initWithAuthzid: (nullable OFString *)authzid
	  authcid: (nullable OFString *)authcid
	 password: (nullable OFString *)password
       connection: (XMPPConnection *)connection
	     hash: (Class)hash
    plusAvailable: (bool)plusAvailable OF_DESIGNATED_INITIALIZER;
@end

OF_ASSUME_NONNULL_END

Modified src/XMPPStanza.h from [a0d35df9af] to [2122dfccd9].

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
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

#import <ObjFW/ObjFW.h>

OF_ASSUME_NONNULL_BEGIN

@class XMPPJID;

/**
 * \brief A class describing an XMPP Stanza.
 */
@interface XMPPStanza: OFXMLElement
{
	XMPPJID *_from, *_to;
	OFString *_type, *_ID, *_language;
}


/// \brief The value of the stanza's from attribute

@property OF_NULLABLE_PROPERTY (nonatomic, copy) XMPPJID *from;


/// \brief The value of the stanza's to attribute

@property OF_NULLABLE_PROPERTY (nonatomic, copy) XMPPJID *to;


/// \brief The value of the stanza's type attribute

@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *type;


/// \brief The value of the stanza's id attribute

@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *ID;


/// \brief The stanza's xml:lang

@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *language;

/**
 * \brief Creates a new autoreleased XMPPStanza with the specified name.
 *
 * \param name The stanza's name (one of iq, message or presence)
 * \return A new autoreleased XMPPStanza
 */
+ (instancetype)stanzaWithName: (OFString *)name;

/**
 * \brief Creates a new autoreleased XMPPStanza with the specified name and
 *	  type.
 *
 * \param name The stanza's name (one of iq, message or presence)
 * \param type The value for the stanza's type attribute
 * \return A new autoreleased XMPPStanza
 */
+ (instancetype)stanzaWithName: (OFString *)name
			  type: (nullable OFString *)type;

/**
 * \brief Creates a new autoreleased XMPPStanza with the specified name and ID.
 *
 * \param name The stanza's name (one of iq, message or presence)
 * \param ID The value for the stanza's id attribute
 * \return A new autoreleased XMPPStanza
 */
+ (instancetype)stanzaWithName: (OFString *)name
			    ID: (nullable OFString *)ID;

/**
 * \brief Creates a new autoreleased XMPPStanza with the specified name, type
 *	  and ID.
 *
 * \param name The stanza's name (one of iq, message or presence)
 * \param type The value for the stanza's type attribute
 * \param ID The value for the stanza's id attribute
 * \return A new autoreleased XMPPStanza
 */
+ (instancetype)stanzaWithName: (OFString *)name
			  type: (nullable OFString *)type
			    ID: (nullable OFString *)ID;

/**
 * \brief Creates a new autoreleased XMPPStanza from an OFXMLElement.
 *
 * \param element The element to base the XMPPStanza on
 * \return A new autoreleased XMPPStanza
 */
+ (instancetype)stanzaWithElement: (OFXMLElement *)element;

- initWithName: (OFString *)name
   stringValue: (nullable OFString *)stringValue OF_UNAVAILABLE;
- initWithName: (OFString *)name
     namespace: (nullable OFString *)namespace OF_UNAVAILABLE;
- initWithName: (OFString *)name
     namespace: (nullable OFString *)namespace
   stringValue: (nullable OFString *)stringValue OF_UNAVAILABLE;
- initWithXMLString: (OFString *)string OF_UNAVAILABLE;
- initWithFile: (OFString *)path OF_UNAVAILABLE;

/**
 * \brief Initializes an already allocated XMPPStanza with the specified name.
 *
 * \param name The stanza's name (one of iq, message or presence)
 * \return A initialized XMPPStanza
 */
- initWithName: (OFString *)name;

/**
 * \brief Initializes an already allocated XMPPStanza with the specified name
 *	  and type.
 *
 * \param name The stanza's name (one of iq, message or presence)
 * \param type The value for the stanza's type attribute
 * \return A initialized XMPPStanza
 */
- initWithName: (OFString *)name
	  type: (nullable OFString *)type;

/**
 * \brief Initializes an already allocated XMPPStanza with the specified name
 *	  and ID.
 *
 * \param name The stanza's name (one of iq, message or presence)
 * \param ID The value for the stanza's id attribute
 * \return A initialized XMPPStanza
 */
- initWithName: (OFString *)name
	    ID: (nullable OFString *)ID;

/**
 * \brief Initializes an already allocated XMPPStanza with the specified name,
 *	  type and ID.
 *
 * \param name The stanza's name (one of iq, message or presence)
 * \param type The value for the stanza's type attribute
 * \param ID The value for the stanza's id attribute
 * \return A initialized XMPPStanza
 */
- initWithName: (OFString *)name
	  type: (nullable OFString *)type
	    ID: (nullable OFString *)ID;

/**
 * \brief Initializes an already allocated XMPPStanza based on a OFXMLElement.
 *
 * \param element The element to base the XMPPStanza on
 * \return A initialized XMPPStanza
 */
- initWithElement: (OFXMLElement *)element;
@end

OF_ASSUME_NONNULL_END







|
|







>
|
>

>
>
|
>

>
>
|
>

>
>
|
>

>
>
|
>


|
|

|
|



|
|


|
|
|




|
|

|
|
|




|
|


|
|
|
|





|
|

|
|













|
|

|
|



|
|


|
|
|




|
|


|
|
|




|
|


|
|
|
|





|
|

|
|





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
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
168
169
170
171
172
173
174
175
176

#import <ObjFW/ObjFW.h>

OF_ASSUME_NONNULL_BEGIN

@class XMPPJID;

/*!
 * @brief A class describing an XMPP Stanza.
 */
@interface XMPPStanza: OFXMLElement
{
	XMPPJID *_from, *_to;
	OFString *_type, *_ID, *_language;
}

/*!
 * The value of the stanza's from attribute.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) XMPPJID *from;

/*!
 * The value of the stanza's to attribute.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) XMPPJID *to;

/*!
 * The value of the stanza's type attribute.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *type;

/*!
 * The value of the stanza's id attribute.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *ID;

/*!
 * The stanza's xml:lang.
 */
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *language;

/*!
 * @brief Creates a new autoreleased XMPPStanza with the specified name.
 *
 * @param name The stanza's name (one of iq, message or presence)
 * @return A new autoreleased XMPPStanza
 */
+ (instancetype)stanzaWithName: (OFString *)name;

/*!
 * @brief Creates a new autoreleased XMPPStanza with the specified name and
 *	  type.
 *
 * @param name The stanza's name (one of iq, message or presence)
 * @param type The value for the stanza's type attribute
 * @return A new autoreleased XMPPStanza
 */
+ (instancetype)stanzaWithName: (OFString *)name
			  type: (nullable OFString *)type;

/*!
 * @brief Creates a new autoreleased XMPPStanza with the specified name and ID.
 *
 * @param name The stanza's name (one of iq, message or presence)
 * @param ID The value for the stanza's id attribute
 * @return A new autoreleased XMPPStanza
 */
+ (instancetype)stanzaWithName: (OFString *)name
			    ID: (nullable OFString *)ID;

/*!
 * @brief Creates a new autoreleased XMPPStanza with the specified name, type
 *	  and ID.
 *
 * @param name The stanza's name (one of iq, message or presence)
 * @param type The value for the stanza's type attribute
 * @param ID The value for the stanza's id attribute
 * @return A new autoreleased XMPPStanza
 */
+ (instancetype)stanzaWithName: (OFString *)name
			  type: (nullable OFString *)type
			    ID: (nullable OFString *)ID;

/*!
 * @brief Creates a new autoreleased XMPPStanza from an OFXMLElement.
 *
 * @param element The element to base the XMPPStanza on
 * @return A new autoreleased XMPPStanza
 */
+ (instancetype)stanzaWithElement: (OFXMLElement *)element;

- initWithName: (OFString *)name
   stringValue: (nullable OFString *)stringValue OF_UNAVAILABLE;
- initWithName: (OFString *)name
     namespace: (nullable OFString *)namespace OF_UNAVAILABLE;
- initWithName: (OFString *)name
     namespace: (nullable OFString *)namespace
   stringValue: (nullable OFString *)stringValue OF_UNAVAILABLE;
- initWithXMLString: (OFString *)string OF_UNAVAILABLE;
- initWithFile: (OFString *)path OF_UNAVAILABLE;

/*!
 * @brief Initializes an already allocated XMPPStanza with the specified name.
 *
 * @param name The stanza's name (one of iq, message or presence)
 * @return A initialized XMPPStanza
 */
- initWithName: (OFString *)name;

/*!
 * @brief Initializes an already allocated XMPPStanza with the specified name
 *	  and type.
 *
 * @param name The stanza's name (one of iq, message or presence)
 * @param type The value for the stanza's type attribute
 * @return A initialized XMPPStanza
 */
- initWithName: (OFString *)name
	  type: (nullable OFString *)type;

/*!
 * @brief Initializes an already allocated XMPPStanza with the specified name
 *	  and ID.
 *
 * @param name The stanza's name (one of iq, message or presence)
 * @param ID The value for the stanza's id attribute
 * @return A initialized XMPPStanza
 */
- initWithName: (OFString *)name
	    ID: (nullable OFString *)ID;

/*!
 * @brief Initializes an already allocated XMPPStanza with the specified name,
 *	  type and ID.
 *
 * @param name The stanza's name (one of iq, message or presence)
 * @param type The value for the stanza's type attribute
 * @param ID The value for the stanza's id attribute
 * @return A initialized XMPPStanza
 */
- initWithName: (OFString *)name
	  type: (nullable OFString *)type
	    ID: (nullable OFString *)ID;

/*!
 * @brief Initializes an already allocated XMPPStanza based on a OFXMLElement.
 *
 * @param element The element to base the XMPPStanza on
 * @return A initialized XMPPStanza
 */
- initWithElement: (OFXMLElement *)element;
@end

OF_ASSUME_NONNULL_END