1
2
3
4
5
6
7
8
9
|
/*
* Copyright (c) 2010, 2011, 2012, 2013, 2016, 2017, 2018
* Jonathan Schleifer <js@heap.zone>
* Copyright (c) 2011, 2012, Florian Zeitz <florob@babelmonkeys.de>
*
* https://heap.zone/objxmpp/
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
|
|
|
1
2
3
4
5
6
7
8
9
|
/*
* Copyright (c) 2010, 2011, 2012, 2013, 2016, 2017, 2018, 2021
* Jonathan Schleifer <js@heap.zone>
* Copyright (c) 2011, 2012, Florian Zeitz <florob@babelmonkeys.de>
*
* https://heap.zone/objxmpp/
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
|
︙ | | | ︙ | |
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#import <ObjFW/ObjFW.h>
#import "XMPPCallback.h"
#import "XMPPStorage.h"
OF_ASSUME_NONNULL_BEGIN
#define XMPP_CONNECTION_BUFFER_LENGTH 512
@class XMPPConnection;
@class XMPPJID;
@class XMPPIQ;
@class XMPPMessage;
@class XMPPPresence;
@class XMPPAuthenticator;
|
|
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#import <ObjFW/ObjFW.h>
#import "XMPPCallback.h"
#import "XMPPStorage.h"
OF_ASSUME_NONNULL_BEGIN
#define XMPPConnectionBufferLength 512
@class XMPPConnection;
@class XMPPJID;
@class XMPPIQ;
@class XMPPMessage;
@class XMPPPresence;
@class XMPPAuthenticator;
|
︙ | | | ︙ | |
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
|
/*!
* @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
|
|
<
|
|
<
|
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/*!
* @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
|
︙ | | | ︙ | |
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
/*!
* @brief A class which abstracts a connection to an XMPP service.
*/
@interface XMPPConnection: OFObject
{
OFTCPSocket *_socket;
char _buffer[XMPP_CONNECTION_BUFFER_LENGTH];
OFXMLParser *_parser, *_oldParser;
OFXMLElementBuilder *_elementBuilder, *_oldElementBuilder;
OFString *_Nullable _username, *_Nullable _password, *_Nullable _server;
OFString *_Nullable _resource;
bool _usesAnonymousAuthentication;
OFString *_Nullable _privateKeyFile, *_Nullable _certificateFile;
const char *_Nullable _privateKeyPassphrase;
|
|
|
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
/*!
* @brief A class which abstracts a connection to an XMPP service.
*/
@interface XMPPConnection: OFObject
{
OFTCPSocket *_socket;
char _buffer[XMPPConnectionBufferLength];
OFXMLParser *_parser, *_oldParser;
OFXMLElementBuilder *_elementBuilder, *_oldElementBuilder;
OFString *_Nullable _username, *_Nullable _password, *_Nullable _server;
OFString *_Nullable _resource;
bool _usesAnonymousAuthentication;
OFString *_Nullable _privateKeyFile, *_Nullable _certificateFile;
const char *_Nullable _privateKeyPassphrase;
|
︙ | | | ︙ | |
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
|
*
* 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;
|
|
<
|
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
|
*
* 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;
|
︙ | | | ︙ | |
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
|
#ifdef OF_HAVE_BLOCKS
/*!
* @brief Sends an XMPPIQ, registering a callback block.
*
* @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
|
|
<
|
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
|
#ifdef OF_HAVE_BLOCKS
/*!
* @brief Sends an XMPPIQ, registering a callback block.
*
* @param IQ The IQ to send
* @param block The callback block
*/
- (void)sendIQ: (XMPPIQ *)IQ callbackBlock: (XMPPCallbackBlock)block;
#endif
/*!
* @brief Generates a new, unique stanza ID.
*
* @return A new, generated, unique stanza ID.
*/
- (OFString *)generateStanzaID;
@end
OF_ASSUME_NONNULL_END
|