Adjust to ObjFW changes

This commit is contained in:
Jonathan Schleifer 2017-05-13 16:49:49 +02:00
parent 73d3bca240
commit 5fa8b0b9b3
No known key found for this signature in database
GPG key ID: 28D65178B37F33E3
51 changed files with 935 additions and 859 deletions

View file

@ -23,6 +23,8 @@
#import <ObjFW/ObjFW.h> #import <ObjFW/ObjFW.h>
OF_ASSUME_NONNULL_BEGIN
/** /**
* \brief A base class for classes implementing authentication mechanisms * \brief A base class for classes implementing authentication mechanisms
*/ */
@ -32,11 +34,11 @@
} }
/// \brief The authzid to get authorization for /// \brief The authzid to get authorization for
@property (copy) OFString *authzid; @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *authzid;
/// \brief The authcid to authenticate with /// \brief The authcid to authenticate with
@property (copy) OFString *authcid; @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *authcid;
/// \brief The password to authenticate with /// \brief The password to authenticate with
@property (copy) OFString *password; @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *password;
/** /**
* \brief Initializes an already allocated XMPPAuthenticator with an authcid * \brief Initializes an already allocated XMPPAuthenticator with an authcid
@ -46,8 +48,8 @@
* \param password The password to authenticate with * \param password The password to authenticate with
* \return A initialized XMPPAuthenticator * \return A initialized XMPPAuthenticator
*/ */
- initWithAuthcid: (OFString*)authcid - initWithAuthcid: (nullable OFString *)authcid
password: (OFString*)password; password: (nullable OFString *)password;
/** /**
* \brief Initializes an already allocated XMPPSCRAMAuthenticator with an * \brief Initializes an already allocated XMPPSCRAMAuthenticator with an
@ -58,16 +60,16 @@
* \param password The password to authenticate with * \param password The password to authenticate with
* \return A initialized XMPPAuthenticator * \return A initialized XMPPAuthenticator
*/ */
- initWithAuthzid: (OFString*)authzid - initWithAuthzid: (nullable OFString *)authzid
authcid: (OFString*)authcid authcid: (nullable OFString *)authcid
password: (OFString*)password; password: (nullable OFString *)password OF_DESIGNATED_INITIALIZER;
/** /**
* \brief Returns an OFDataArray containing the initial authentication message. * \brief Returns an OFDataArray containing the initial authentication message.
* *
* \return An OFDataAray containing the initial authentication message * \return An OFDataAray containing the initial authentication message
*/ */
- (OFDataArray*)initialMessage; - (OFDataArray *)initialMessage;
/** /**
* \brief Continue authentication with the specified data. * \brief Continue authentication with the specified data.
@ -75,5 +77,7 @@
* \param data The continuation data send by the server * \param data The continuation data send by the server
* \return The appropriate response if the data was a challenge, nil otherwise * \return The appropriate response if the data was a challenge, nil otherwise
*/ */
- (OFDataArray*)continueWithData: (OFDataArray*)data; - (nullable OFDataArray *)continueWithData: (OFDataArray *)data;
@end @end
OF_ASSUME_NONNULL_END

View file

@ -30,17 +30,17 @@
@implementation XMPPAuthenticator @implementation XMPPAuthenticator
@synthesize authzid = _authzid, authcid = _authcid, password = _password; @synthesize authzid = _authzid, authcid = _authcid, password = _password;
- initWithAuthcid: (OFString*)authcid - initWithAuthcid: (OFString *)authcid
password: (OFString*)password password: (OFString *)password
{ {
return [self initWithAuthzid: nil return [self initWithAuthzid: nil
authcid: authcid authcid: authcid
password: password]; password: password];
} }
- initWithAuthzid: (OFString*)authzid - initWithAuthzid: (OFString *)authzid
authcid: (OFString*)authcid authcid: (OFString *)authcid
password: (OFString*)password password: (OFString *)password
{ {
self = [super init]; self = [super init];
@ -65,12 +65,12 @@
[super dealloc]; [super dealloc];
} }
- (OFDataArray*)initialMessage - (OFDataArray *)initialMessage
{ {
return nil; return nil;
} }
- (OFDataArray*)continueWithData: (OFDataArray*)challenge - (OFDataArray *)continueWithData: (OFDataArray *)challenge
{ {
return nil; return nil;
} }

View file

@ -22,11 +22,14 @@
#import <ObjFW/ObjFW.h> #import <ObjFW/ObjFW.h>
OF_ASSUME_NONNULL_BEGIN
@class XMPPConnection; @class XMPPConnection;
@class XMPPIQ; @class XMPPIQ;
#ifdef OF_HAVE_BLOCKS #ifdef OF_HAVE_BLOCKS
typedef void (^xmpp_callback_block_t)(XMPPConnection*, XMPPIQ*); typedef void (^xmpp_callback_block_t)(XMPPConnection *_Nonnull,
XMPPIQ *_Nonnull);
#endif #endif
@interface XMPPCallback: OFObject @interface XMPPCallback: OFObject
@ -48,6 +51,8 @@ typedef void (^xmpp_callback_block_t)(XMPPConnection*, XMPPIQ*);
- initWithTarget: (id)target - initWithTarget: (id)target
selector: (SEL)selector; selector: (SEL)selector;
- (void)runWithIQ: (XMPPIQ*)iq - (void)runWithIQ: (XMPPIQ *)iq
connection: (XMPPConnection*)connection; connection: (XMPPConnection *)connection;
@end @end
OF_ASSUME_NONNULL_END

View file

@ -30,7 +30,8 @@
#ifdef OF_HAVE_BLOCKS #ifdef OF_HAVE_BLOCKS
+ (instancetype)callbackWithBlock: (xmpp_callback_block_t)block + (instancetype)callbackWithBlock: (xmpp_callback_block_t)block
{ {
return [[(XMPPCallback*)[self alloc] initWithBlock: block] autorelease]; return [[(XMPPCallback *)[self alloc]
initWithBlock: block] autorelease];
} }
- initWithBlock: (xmpp_callback_block_t)block - initWithBlock: (xmpp_callback_block_t)block
@ -76,16 +77,16 @@
[super dealloc]; [super dealloc];
} }
- (void)runWithIQ: (XMPPIQ*)iq - (void)runWithIQ: (XMPPIQ *)IQ
connection: (XMPPConnection*)connection connection: (XMPPConnection *)connection
{ {
#ifdef OF_HAVE_BLOCKS #ifdef OF_HAVE_BLOCKS
if (_block != NULL) if (_block != NULL)
_block(connection, iq); _block(connection, IQ);
else else
#endif #endif
[_target performSelector: _selector [_target performSelector: _selector
withObject: connection withObject: connection
withObject: iq]; withObject: IQ];
} }
@end @end

View file

@ -27,6 +27,8 @@
#import "XMPPCallback.h" #import "XMPPCallback.h"
#import "XMPPStorage.h" #import "XMPPStorage.h"
OF_ASSUME_NONNULL_BEGIN
@class XMPPConnection; @class XMPPConnection;
@class XMPPJID; @class XMPPJID;
@class XMPPIQ; @class XMPPIQ;
@ -37,13 +39,10 @@
@class XMPPMulticastDelegate; @class XMPPMulticastDelegate;
/** /**
* \brief A protocol that should be (partially) implemented * \brief A protocol that should be (partially) implemented by delegates of a
* by delegates of a XMPPConnection * @ref XMPPConnection
*/ */
@protocol XMPPConnectionDelegate @protocol XMPPConnectionDelegate
#ifndef XMPP_CONNECTION_M
<OFObject>
#endif
@optional @optional
/** /**
* \brief This callback is called when the connection received an element. * \brief This callback is called when the connection received an element.
@ -51,8 +50,8 @@
* \param connection The connection that received the element * \param connection The connection that received the element
* \param element The element that was received * \param element The element that was received
*/ */
- (void)connection: (XMPPConnection*)connection - (void)connection: (XMPPConnection *)connection
didReceiveElement: (OFXMLElement*)element; didReceiveElement: (OFXMLElement *)element;
/** /**
* \brief This callback is called when the connection sent an element. * \brief This callback is called when the connection sent an element.
@ -60,15 +59,15 @@
* \param connection The connection that sent the element * \param connection The connection that sent the element
* \param element The element that was sent * \param element The element that was sent
*/ */
- (void)connection: (XMPPConnection*)connection - (void)connection: (XMPPConnection *)connection
didSendElement: (OFXMLElement*)element; didSendElement: (OFXMLElement *)element;
/** /**
* \brief This callback is called when the connection sucessfully authenticated. * \brief This callback is called when the connection sucessfully authenticated.
* *
* \param connection The connection that was authenticated * \param connection The connection that was authenticated
*/ */
- (void)connectionWasAuthenticated: (XMPPConnection*)connection; - (void)connectionWasAuthenticated: (XMPPConnection *)connection;
/** /**
* \brief This callback is called when the connection was bound to a JID. * \brief This callback is called when the connection was bound to a JID.
@ -76,8 +75,8 @@
* \param connection The connection that was bound to a JID * \param connection The connection that was bound to a JID
* \param JID The JID the conecction was bound to * \param JID The JID the conecction was bound to
*/ */
- (void)connection: (XMPPConnection*)connection - (void)connection: (XMPPConnection *)connection
wasBoundToJID: (XMPPJID*)JID; wasBoundToJID: (XMPPJID *)JID;
/** /**
* \brief This callback is called when the connection received an IQ stanza. * \brief This callback is called when the connection received an IQ stanza.
@ -85,8 +84,8 @@
* \param connection The connection that received the stanza * \param connection The connection that received the stanza
* \param iq The IQ stanza that was received * \param iq The IQ stanza that was received
*/ */
- (bool)connection: (XMPPConnection*)connection - (bool)connection: (XMPPConnection *)connection
didReceiveIQ: (XMPPIQ*)iq; didReceiveIQ: (XMPPIQ *)iq;
/** /**
* \brief This callback is called when the connection received a presence * \brief This callback is called when the connection received a presence
@ -95,8 +94,8 @@
* \param connection The connection that received the stanza * \param connection The connection that received the stanza
* \param presence The presence stanza that was received * \param presence The presence stanza that was received
*/ */
- (void)connection: (XMPPConnection*)connection - (void)connection: (XMPPConnection *)connection
didReceivePresence: (XMPPPresence*)presence; didReceivePresence: (XMPPPresence *)presence;
/** /**
* \brief This callback is called when the connection received a message stanza. * \brief This callback is called when the connection received a message stanza.
@ -104,15 +103,15 @@
* \param connection The connection that received the stanza * \param connection The connection that received the stanza
* \param message The message stanza that was received * \param message The message stanza that was received
*/ */
- (void)connection: (XMPPConnection*)connection - (void)connection: (XMPPConnection *)connection
didReceiveMessage: (XMPPMessage*)message; didReceiveMessage: (XMPPMessage *)message;
/** /**
* \brief This callback is called when the connection was closed. * \brief This callback is called when the connection was closed.
* *
* \param connection The connection that was closed * \param connection The connection that was closed
*/ */
- (void)connectionWasClosed: (XMPPConnection*)connection; - (void)connectionWasClosed: (XMPPConnection *)connection;
/*! /*!
* @brief This callback is called when the connection threw an exception. * @brief This callback is called when the connection threw an exception.
@ -123,8 +122,8 @@
* @param connection The connection which threw an exception * @param connection The connection which threw an exception
* @param exception The exception the connection threw * @param exception The exception the connection threw
*/ */
- (void)connection: (XMPPConnection*)connection - (void)connection: (XMPPConnection *)connection
didThrowException: (OFException*)exception; didThrowException: (OFException *)exception;
/** /**
* \brief This callback is called when the connection is about to upgrade to * \brief This callback is called when the connection is about to upgrade to
@ -132,14 +131,14 @@
* *
* \param connection The connection that will upgraded to TLS * \param connection The connection that will upgraded to TLS
*/ */
- (void)connectionWillUpgradeToTLS: (XMPPConnection*)connection; - (void)connectionWillUpgradeToTLS: (XMPPConnection *)connection;
/** /**
* \brief This callback is called when the connection was upgraded to use TLS. * \brief This callback is called when the connection was upgraded to use TLS.
* *
* \param connection The connection that was upgraded to TLS * \param connection The connection that was upgraded to TLS
*/ */
- (void)connectionDidUpgradeToTLS: (XMPPConnection*)connection; - (void)connectionDidUpgradeToTLS: (XMPPConnection *)connection;
@end @end
/** /**
@ -160,7 +159,7 @@
id <XMPPStorage> _dataStorage; id <XMPPStorage> _dataStorage;
OFString *_language; OFString *_language;
XMPPMulticastDelegate *_delegates; XMPPMulticastDelegate *_delegates;
OFMutableDictionary *_callbacks; OFMutableDictionary OF_GENERIC(OFString *, XMPPCallback *) *_callbacks;
XMPPAuthenticator *_authModule; XMPPAuthenticator *_authModule;
bool _streamOpen; bool _streamOpen;
bool _needsSession; bool _needsSession;
@ -171,33 +170,33 @@
} }
/// \brief The username to use for authentication /// \brief The username to use for authentication
@property (copy) OFString *username; @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *username;
/// \brief The password to use for authentication /// \brief The password to use for authentication
@property (copy) OFString *password; @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *password;
/** /**
* \brief The server to use for the connection * \brief The server to use for the connection
* *
* This is useful if the address of the server is different from the domain. * This is useful if the address of the server is different from the domain.
*/ */
@property (copy) OFString *server; @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *server;
/// \brief The domain to connect to /// \brief The domain to connect to
@property (copy) OFString *domain; @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *domain;
/// \brief The resource to request for the connection /// \brief The resource to request for the connection
@property (copy) OFString *resource; @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *resource;
/// \brief The language to request for the connection /// \brief The language to request for the connection
@property (copy) OFString *language; @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *language;
/// \brief A private key file to use for authentication /// \brief A private key file to use for authentication
@property (copy) OFString *privateKeyFile; @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *privateKeyFile;
/// \brief A certificate file to use for authentication /// \brief A certificate file to use for authentication
@property (copy) OFString *certificateFile; @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *certificateFile;
/// \brief The JID the server assigned to the connection after binding /// \brief The JID the server assigned to the connection after binding
@property (copy, readonly) XMPPJID *JID; @property (readonly, nonatomic) XMPPJID *JID;
/// \brief The port to connect to /// \brief The port to connect to
@property uint16_t port; @property uint16_t port;
/// \brief An object for data storage, conforming to the XMPPStorage protocol /// \brief An object for data storage, conforming to the XMPPStorage protocol
@property (assign) id <XMPPStorage> dataStorage; @property OF_NULLABLE_PROPERTY (assign) id <XMPPStorage> dataStorage;
/// \brief The socket used for the connection /// \brief The socket used for the connection
@property (readonly, retain) OFTCPSocket *socket; @property (readonly, nonatomic) OFTCPSocket *socket;
/// \brief Whether encryption is required /// \brief Whether encryption is required
@property bool encryptionRequired; @property bool encryptionRequired;
/// \brief Whether the connection is encrypted /// \brief Whether the connection is encrypted
@ -247,7 +246,8 @@
* Passing NULL means the reason is not stored anywhere. * Passing NULL means the reason is not stored anywhere.
* \return Whether the certificate is valid * \return Whether the certificate is valid
*/ */
- (bool)checkCertificateAndGetReason: (OFString**)reason; - (bool)checkCertificateAndGetReason:
(OFString *__autoreleasing _Nonnull *_Nullable)reason;
/** /**
* \brief Adds the connection to the run loop. * \brief Adds the connection to the run loop.
@ -269,43 +269,15 @@
* \param length The length of the buffer. If length is 0, it is assumed that * \param length The length of the buffer. If length is 0, it is assumed that
* the connection was closed. * the connection was closed.
*/ */
- (void)parseBuffer: (const void*)buffer - (void)parseBuffer: (const void *)buffer
length: (size_t)length; length: (size_t)length;
/**
* \brief Returns the socket used by the XMPPConnection.
*
* \return The socket used by the XMPPConnection
*/
- (OFTCPSocket*)socket;
/**
* \brief Returns whether encryption is encrypted.
*
* \return Whether encryption is encrypted
*/
- (bool)encryptionRequired;
/**
* \brief Sets whether encryption is required.
*
* \param required Whether encryption is required
*/
- (void)setEncryptionRequired: (bool)required;
/**
* \brief Returns whether the connection is encrypted.
*
* \return Whether the connection is encrypted
*/
- (bool)encrypted;
/** /**
* \brief Sends an OFXMLElement, usually an XMPPStanza. * \brief Sends an OFXMLElement, usually an XMPPStanza.
* *
* \param element The element to send * \param element The element to send
*/ */
- (void)sendStanza: (OFXMLElement*)element; - (void)sendStanza: (OFXMLElement *)element;
/*! /*!
* @brief Sends an XMPPIQ, registering a callback method. * @brief Sends an XMPPIQ, registering a callback method.
@ -313,9 +285,9 @@
* @param IQ The IQ to send * @param IQ The IQ to send
* @param target The object that contains the callback method * @param target The object that contains the callback method
* @param selector The selector of the callback method, * @param selector The selector of the callback method,
* must take exactly one parameter of type XMPPIQ* * must take exactly one parameter of type `XMPPIQ *`
*/ */
- (void)sendIQ: (XMPPIQ*)IQ - (void)sendIQ: (XMPPIQ *)IQ
callbackTarget: (id)target callbackTarget: (id)target
selector: (SEL)selector; selector: (SEL)selector;
@ -326,7 +298,7 @@
* @param IQ The IQ to send * @param IQ The IQ to send
* @param block The callback block * @param block The callback block
*/ */
- (void)sendIQ: (XMPPIQ*)IQ - (void)sendIQ: (XMPPIQ *)IQ
callbackBlock: (xmpp_callback_block_t)block; callbackBlock: (xmpp_callback_block_t)block;
#endif #endif
@ -335,49 +307,7 @@
* *
* \return A new, generated, unique stanza ID. * \return A new, generated, unique stanza ID.
*/ */
- (OFString*)generateStanzaID; - (OFString *)generateStanzaID;
- (void)setUsername: (OFString*)username;
- (OFString*)username;
- (void)setPassword: (OFString*)password;
- (OFString*)password;
- (void)setServer: (OFString*)server;
- (OFString*)server;
- (void)setDomain: (OFString*)domain;
- (OFString*)domain;
- (void)setResource: (OFString*)resource;
- (OFString*)resource;
- (XMPPJID*)JID;
- (void)setPort: (uint16_t)port;
- (uint16_t)port;
- (void)setDataStorage: (id <XMPPStorage>)dataStorage;
- (id <XMPPStorage>)dataStorage;
- (void)setLanguage: (OFString*)language;
- (OFString*)language;
- (bool)supportsRosterVersioning;
- (bool)supportsStreamManagement;
- (void)XMPP_startStream;
- (void)XMPP_handleStream: (OFXMLElement*)element;
- (void)XMPP_handleTLS: (OFXMLElement*)element;
- (void)XMPP_handleSASL: (OFXMLElement*)element;
- (void)XMPP_handleStanza: (OFXMLElement*)element;
- (void)XMPP_sendAuth: (OFString*)authName;
- (void)XMPP_sendResourceBind;
- (void)XMPP_sendStreamError: (OFString*)condition
text: (OFString*)text;
- (void)XMPP_handleIQ: (XMPPIQ*)iq;
- (void)XMPP_handleMessage: (XMPPMessage*)message;
- (void)XMPP_handlePresence: (XMPPPresence*)presence;
- (void)XMPP_handleFeatures: (OFXMLElement*)element;
- (void)XMPP_handleResourceBindForConnection: (XMPPConnection*)connection
IQ: (XMPPIQ*)iq;
- (void)XMPP_sendSession;
- (void)XMPP_handleSessionForConnection: (XMPPConnection*)connection
IQ: (XMPPIQ*)iq;
- (OFString*)XMPP_IDNAToASCII: (OFString*)domain;
- (XMPPMulticastDelegate*)XMPP_delegates;
@end @end
@interface OFObject (XMPPConnectionDelegate) <XMPPConnectionDelegate> OF_ASSUME_NONNULL_END
@end

View file

@ -59,19 +59,46 @@
#define BUFFER_LENGTH 512 #define BUFFER_LENGTH 512
OF_ASSUME_NONNULL_BEGIN
@interface XMPPConnection ()
- (void)XMPP_startStream;
- (void)XMPP_handleStream: (OFXMLElement *)element;
- (void)XMPP_handleTLS: (OFXMLElement *)element;
- (void)XMPP_handleSASL: (OFXMLElement *)element;
- (void)XMPP_handleStanza: (OFXMLElement *)element;
- (void)XMPP_sendAuth: (OFString *)authName;
- (void)XMPP_sendResourceBind;
- (void)XMPP_sendStreamError: (OFString *)condition
text: (nullable OFString *)text;
- (void)XMPP_handleIQ: (XMPPIQ *)IQ;
- (void)XMPP_handleMessage: (XMPPMessage *)message;
- (void)XMPP_handlePresence: (XMPPPresence *)presence;
- (void)XMPP_handleFeatures: (OFXMLElement *)element;
- (void)XMPP_handleResourceBindForConnection: (XMPPConnection *)connection
IQ: (XMPPIQ *)IQ;
- (void)XMPP_sendSession;
- (void)XMPP_handleSessionForConnection: (XMPPConnection *)connection
IQ: (XMPPIQ *)IQ;
- (OFString *)XMPP_IDNAToASCII: (OFString *)domain;
- (XMPPMulticastDelegate *)XMPP_delegates;
@end
@interface XMPPConnection_ConnectThread: OFThread @interface XMPPConnection_ConnectThread: OFThread
{ {
OFThread *_sourceThread; OFThread *_sourceThread;
XMPPConnection *_connection; XMPPConnection *_connection;
} }
- initWithSourceThread: (OFThread*)sourceThread - initWithSourceThread: (OFThread *)sourceThread
connection: (XMPPConnection*)connection; connection: (XMPPConnection *)connection;
@end @end
OF_ASSUME_NONNULL_END
@implementation XMPPConnection_ConnectThread @implementation XMPPConnection_ConnectThread
- initWithSourceThread: (OFThread*)sourceThread - initWithSourceThread: (OFThread *)sourceThread
connection: (XMPPConnection*)connection connection: (XMPPConnection *)connection
{ {
self = [super init]; self = [super init];
@ -118,7 +145,9 @@
@end @end
@implementation XMPPConnection @implementation XMPPConnection
@synthesize language = _language, privateKeyFile = _privateKeyFile; @synthesize username = _username, resource = _resource, server = _server;
@synthesize domain = _domain, password = _password, language = _language;
@synthesize privateKeyFile = _privateKeyFile;
@synthesize certificateFile = _certificateFile, socket = _socket; @synthesize certificateFile = _certificateFile, socket = _socket;
@synthesize encryptionRequired = _encryptionRequired, encrypted = _encrypted; @synthesize encryptionRequired = _encryptionRequired, encrypted = _encrypted;
@synthesize supportsRosterVersioning = _supportsRosterVersioning; @synthesize supportsRosterVersioning = _supportsRosterVersioning;
@ -165,7 +194,7 @@
[super dealloc]; [super dealloc];
} }
- (void)setUsername: (OFString*)username - (void)setUsername: (OFString *)username
{ {
OFString *old = _username; OFString *old = _username;
@ -191,12 +220,7 @@
[old release]; [old release];
} }
- (OFString*)username - (void)setResource: (OFString *)resource
{
return [[_username copy] autorelease];
}
- (void)setResource: (OFString*)resource
{ {
OFString *old = _resource; OFString *old = _resource;
@ -222,12 +246,7 @@
[old release]; [old release];
} }
- (OFString*)resource - (void)setServer: (OFString *)server
{
return [[_resource copy] autorelease];
}
- (void)setServer: (OFString*)server
{ {
OFString *old = _server; OFString *old = _server;
@ -239,12 +258,7 @@
[old release]; [old release];
} }
- (OFString*)server - (void)setDomain: (OFString *)domain
{
return [[_server copy] autorelease];
}
- (void)setDomain: (OFString*)domain
{ {
OFString *oldDomain = _domain; OFString *oldDomain = _domain;
OFString *oldDomainToASCII = _domainToASCII; OFString *oldDomainToASCII = _domainToASCII;
@ -276,12 +290,7 @@
[oldDomainToASCII release]; [oldDomainToASCII release];
} }
- (OFString*)domain - (void)setPassword: (OFString *)password
{
return [[_domain copy] autorelease];
}
- (void)setPassword: (OFString*)password
{ {
OFString *old = _password; OFString *old = _password;
@ -307,11 +316,6 @@
[old release]; [old release];
} }
- (OFString*)password
{
return [[_password copy] autorelease];
}
- (void)connect - (void)connect
{ {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
@ -382,7 +386,7 @@
[pool release]; [pool release];
} }
- (bool)XMPP_parseBuffer: (const void*)buffer - (bool)XMPP_parseBuffer: (const void *)buffer
length: (size_t)length length: (size_t)length
{ {
if ([_socket isAtEndOfStream]) { if ([_socket isAtEndOfStream]) {
@ -404,7 +408,7 @@
return true; return true;
} }
- (void)parseBuffer: (const void*)buffer - (void)parseBuffer: (const void *)buffer
length: (size_t)length length: (size_t)length
{ {
[self XMPP_parseBuffer: buffer [self XMPP_parseBuffer: buffer
@ -417,10 +421,10 @@
_oldElementBuilder = nil; _oldElementBuilder = nil;
} }
- (bool)stream: (OFStream*)stream - (bool)stream: (OFStream *)stream
didReadIntoBuffer: (char*)buffer didReadIntoBuffer: (char *)buffer
length: (size_t)length length: (size_t)length
exception: (OFException*)exception exception: (OFException *)exception
{ {
if (exception != nil) { if (exception != nil) {
[_delegates broadcastSelector: @selector(connection: [_delegates broadcastSelector: @selector(connection:
@ -469,7 +473,7 @@
return _streamOpen; return _streamOpen;
} }
- (bool)checkCertificateAndGetReason: (OFString**)reason - (bool)checkCertificateAndGetReason: (OFString **)reason
{ {
X509Certificate *cert; X509Certificate *cert;
OFDictionary *SANs; OFDictionary *SANs;
@ -505,7 +509,7 @@
return false; return false;
} }
- (void)sendStanza: (OFXMLElement*)element - (void)sendStanza: (OFXMLElement *)element
{ {
[_delegates broadcastSelector: @selector(connection:didSendElement:) [_delegates broadcastSelector: @selector(connection:didSendElement:)
withObject: self withObject: self
@ -514,7 +518,7 @@
[_socket writeString: [element XMLString]]; [_socket writeString: [element XMLString]];
} }
- (void)sendIQ: (XMPPIQ*)IQ - (void)sendIQ: (XMPPIQ *)IQ
callbackTarget: (id)target callbackTarget: (id)target
selector: (SEL)selector selector: (SEL)selector
{ {
@ -545,7 +549,7 @@
} }
#ifdef OF_HAVE_BLOCKS #ifdef OF_HAVE_BLOCKS
- (void)sendIQ: (XMPPIQ*)IQ - (void)sendIQ: (XMPPIQ *)IQ
callbackBlock: (xmpp_callback_block_t)block callbackBlock: (xmpp_callback_block_t)block
{ {
OFAutoreleasePool *pool; OFAutoreleasePool *pool;
@ -574,20 +578,17 @@
} }
#endif #endif
- (OFString*)generateStanzaID - (OFString *)generateStanzaID
{ {
return [OFString stringWithFormat: @"objxmpp_%u", _lastID++]; return [OFString stringWithFormat: @"objxmpp_%u", _lastID++];
} }
- (void)parser: (OFXMLParser*)p - (void)parser: (OFXMLParser *)parser
didStartElement: (OFString*)name didStartElement: (OFString *)name
prefix: (OFString*)prefix prefix: (OFString *)prefix
namespace: (OFString*)ns namespace: (OFString *)NS
attributes: (OFArray*)attributes attributes: (OFArray *)attributes
{ {
OFEnumerator *enumerator;
OFXMLAttribute *attribute;
if (![name isEqual: @"stream"]) { if (![name isEqual: @"stream"]) {
// No dedicated stream error for this, may not even be XMPP // No dedicated stream error for this, may not even be XMPP
[self close]; [self close];
@ -601,14 +602,13 @@
return; return;
} }
if (![ns isEqual: XMPP_NS_STREAM]) { if (![NS isEqual: XMPP_NS_STREAM]) {
[self XMPP_sendStreamError: @"invalid-namespace" [self XMPP_sendStreamError: @"invalid-namespace"
text: nil]; text: nil];
return; return;
} }
enumerator = [attributes objectEnumerator]; for (OFXMLAttribute *attribute in attributes) {
while ((attribute = [enumerator nextObject]) != nil) {
if ([[attribute name] isEqual: @"from"] && if ([[attribute name] isEqual: @"from"] &&
![[attribute stringValue] isEqual: _domain]) { ![[attribute stringValue] isEqual: _domain]) {
[self XMPP_sendStreamError: @"invalid-from" [self XMPP_sendStreamError: @"invalid-from"
@ -623,11 +623,11 @@
} }
} }
[_parser setDelegate: _elementBuilder]; [parser setDelegate: _elementBuilder];
} }
- (void)elementBuilder: (OFXMLElementBuilder*)builder - (void)elementBuilder: (OFXMLElementBuilder *)builder
didBuildElement: (OFXMLElement*)element didBuildElement: (OFXMLElement *)element
{ {
/* Ignore whitespace elements */ /* Ignore whitespace elements */
if ([element name] == nil) if ([element name] == nil)
@ -654,10 +654,10 @@
[self XMPP_handleSASL: element]; [self XMPP_handleSASL: element];
} }
- (void)elementBuilder: (OFXMLElementBuilder*)builder - (void)elementBuilder: (OFXMLElementBuilder *)builder
didNotExpectCloseTag: (OFString*)name didNotExpectCloseTag: (OFString *)name
prefix: (OFString*)prefix prefix: (OFString *)prefix
namespace: (OFString*)ns namespace: (OFString *)ns
{ {
if (![name isEqual: @"stream"] || ![prefix isEqual: @"stream"] || if (![name isEqual: @"stream"] || ![prefix isEqual: @"stream"] ||
![ns isEqual: XMPP_NS_STREAM]) ![ns isEqual: XMPP_NS_STREAM])
@ -722,7 +722,7 @@
_lastID = 0; _lastID = 0;
} }
- (void)XMPP_handleStanza: (OFXMLElement*)element - (void)XMPP_handleStanza: (OFXMLElement *)element
{ {
if ([[element name] isEqual: @"iq"]) { if ([[element name] isEqual: @"iq"]) {
[self XMPP_handleIQ: [XMPPIQ stanzaWithElement: element]]; [self XMPP_handleIQ: [XMPPIQ stanzaWithElement: element]];
@ -746,7 +746,7 @@
} }
- (void)XMPP_handleStream: (OFXMLElement*)element - (void)XMPP_handleStream: (OFXMLElement *)element
{ {
if ([[element name] isEqual: @"features"]) { if ([[element name] isEqual: @"features"]) {
[self XMPP_handleFeatures: element]; [self XMPP_handleFeatures: element];
@ -850,7 +850,7 @@
assert(0); assert(0);
} }
- (void)XMPP_handleTLS: (OFXMLElement*)element - (void)XMPP_handleTLS: (OFXMLElement *)element
{ {
if ([[element name] isEqual: @"proceed"]) { if ([[element name] isEqual: @"proceed"]) {
/* FIXME: Catch errors here */ /* FIXME: Catch errors here */
@ -891,7 +891,7 @@
assert(0); assert(0);
} }
- (void)XMPP_handleSASL: (OFXMLElement*)element - (void)XMPP_handleSASL: (OFXMLElement *)element
{ {
if ([[element name] isEqual: @"challenge"]) { if ([[element name] isEqual: @"challenge"]) {
OFXMLElement *responseTag; OFXMLElement *responseTag;
@ -939,7 +939,7 @@
assert(0); assert(0);
} }
- (void)XMPP_handleIQ: (XMPPIQ*)IQ - (void)XMPP_handleIQ: (XMPPIQ *)IQ
{ {
bool handled = false; bool handled = false;
XMPPCallback *callback; XMPPCallback *callback;
@ -970,21 +970,21 @@
} }
} }
- (void)XMPP_handleMessage: (XMPPMessage*)message - (void)XMPP_handleMessage: (XMPPMessage *)message
{ {
[_delegates broadcastSelector: @selector(connection:didReceiveMessage:) [_delegates broadcastSelector: @selector(connection:didReceiveMessage:)
withObject: self withObject: self
withObject: message]; withObject: message];
} }
- (void)XMPP_handlePresence: (XMPPPresence*)presence - (void)XMPP_handlePresence: (XMPPPresence *)presence
{ {
[_delegates broadcastSelector: @selector(connection:didReceivePresence:) [_delegates broadcastSelector: @selector(connection:didReceivePresence:)
withObject: self withObject: self
withObject: presence]; withObject: presence];
} }
- (void)XMPP_handleFeatures: (OFXMLElement*)element - (void)XMPP_handleFeatures: (OFXMLElement *)element
{ {
OFXMLElement *startTLS = [element elementForName: @"starttls" OFXMLElement *startTLS = [element elementForName: @"starttls"
namespace: XMPP_NS_STARTTLS]; namespace: XMPP_NS_STARTTLS];
@ -1023,7 +1023,7 @@
while ((mech = [enumerator nextObject]) != nil) while ((mech = [enumerator nextObject]) != nil)
[mechanisms addObject: [mech stringValue]]; [mechanisms addObject: [mech stringValue]];
if (_privateKeyFile && _certificateFile && if (_privateKeyFile != nil && _certificateFile != nil &&
[mechanisms containsObject: @"EXTERNAL"]) { [mechanisms containsObject: @"EXTERNAL"]) {
_authModule = [[XMPPEXTERNALAuth alloc] init]; _authModule = [[XMPPEXTERNALAuth alloc] init];
[self XMPP_sendAuth: @"EXTERNAL"]; [self XMPP_sendAuth: @"EXTERNAL"];
@ -1063,8 +1063,8 @@
assert(0); assert(0);
} }
if (session != nil && ![session elementForName: @"optional" if (session != nil && [session elementForName: @"optional"
namespace: XMPP_NS_SESSION]) namespace: XMPP_NS_SESSION] == nil)
_needsSession = true; _needsSession = true;
if (bind != nil) { if (bind != nil) {
@ -1075,7 +1075,7 @@
assert(0); assert(0);
} }
- (void)XMPP_sendAuth: (OFString*)authName - (void)XMPP_sendAuth: (OFString *)authName
{ {
OFXMLElement *authTag; OFXMLElement *authTag;
OFDataArray *initialMessage = [_authModule initialMessage]; OFDataArray *initialMessage = [_authModule initialMessage];
@ -1119,8 +1119,8 @@
IQ:)]; IQ:)];
} }
- (void)XMPP_sendStreamError: (OFString*)condition - (void)XMPP_sendStreamError: (OFString *)condition
text: (OFString*)text text: (OFString *)text
{ {
OFXMLElement *error = [OFXMLElement OFXMLElement *error = [OFXMLElement
elementWithName: @"error" elementWithName: @"error"
@ -1139,22 +1139,21 @@
[self close]; [self close];
} }
- (void)XMPP_handleResourceBindForConnection: (XMPPConnection*)connection - (void)XMPP_handleResourceBindForConnection: (XMPPConnection *)connection
IQ: (XMPPIQ*)iq IQ: (XMPPIQ *)IQ
{ {
OFXMLElement *bindElement; OFXMLElement *bindElement, *JIDElement;
OFXMLElement *jidElement;
assert([[iq type] isEqual: @"result"]); assert([[IQ type] isEqual: @"result"]);
bindElement = [iq elementForName: @"bind" bindElement = [IQ elementForName: @"bind"
namespace: XMPP_NS_BIND]; namespace: XMPP_NS_BIND];
assert(bindElement != nil); assert(bindElement != nil);
jidElement = [bindElement elementForName: @"jid" JIDElement = [bindElement elementForName: @"jid"
namespace: XMPP_NS_BIND]; namespace: XMPP_NS_BIND];
_JID = [[XMPPJID alloc] initWithString: [jidElement stringValue]]; _JID = [[XMPPJID alloc] initWithString: [JIDElement stringValue]];
if (_needsSession) { if (_needsSession) {
[self XMPP_sendSession]; [self XMPP_sendSession];
@ -1168,29 +1167,29 @@
- (void)XMPP_sendSession - (void)XMPP_sendSession
{ {
XMPPIQ *iq; XMPPIQ *IQ = [XMPPIQ IQWithType: @"set"
iq = [XMPPIQ IQWithType: @"set"
ID: [self generateStanzaID]]; ID: [self generateStanzaID]];
[iq addChild: [OFXMLElement elementWithName: @"session"
[IQ addChild: [OFXMLElement elementWithName: @"session"
namespace: XMPP_NS_SESSION]]; namespace: XMPP_NS_SESSION]];
[self sendIQ: iq
[self sendIQ: IQ
callbackTarget: self callbackTarget: self
selector: @selector(XMPP_handleSessionForConnection:IQ:)]; selector: @selector(XMPP_handleSessionForConnection:IQ:)];
} }
- (void)XMPP_handleSessionForConnection: (XMPPConnection*)connection - (void)XMPP_handleSessionForConnection: (XMPPConnection *)connection
IQ: (XMPPIQ*)iq IQ: (XMPPIQ *)IQ
{ {
if (![[iq type] isEqual: @"result"]) if (![[IQ type] isEqual: @"result"])
assert(0); OF_ENSURE(0);
[_delegates broadcastSelector: @selector(connection:wasBoundToJID:) [_delegates broadcastSelector: @selector(connection:wasBoundToJID:)
withObject: self withObject: self
withObject: _JID]; withObject: _JID];
} }
- (OFString*)XMPP_IDNAToASCII: (OFString*)domain - (OFString *)XMPP_IDNAToASCII: (OFString *)domain
{ {
OFString *ret; OFString *ret;
char *cDomain; char *cDomain;
@ -1236,7 +1235,7 @@
[_delegates removeDelegate: delegate]; [_delegates removeDelegate: delegate];
} }
- (XMPPMulticastDelegate*)XMPP_delegates - (XMPPMulticastDelegate *)XMPP_delegates
{ {
return _delegates; return _delegates;
} }

13
src/XMPPContact+Private.h Normal file
View file

@ -0,0 +1,13 @@
#import "XMPPContact.h"
OF_ASSUME_NONNULL_BEGIN
@interface XMPPContact ()
- (void)XMPP_setRosterItem: (XMPPRosterItem *)rosterItem;
- (void)XMPP_setPresence: (XMPPPresence *)presence
resource: (OFString *)resource;
- (void)XMPP_removePresenceForResource: (OFString *)resource;
- (void)XMPP_setLockedOnJID: (nullable XMPPJID *)JID;
@end
OF_ASSUME_NONNULL_END

View file

@ -23,6 +23,8 @@
#import <ObjFW/ObjFW.h> #import <ObjFW/ObjFW.h>
OF_ASSUME_NONNULL_BEGIN
@class XMPPConnection; @class XMPPConnection;
@class XMPPJID; @class XMPPJID;
@class XMPPRosterItem; @class XMPPRosterItem;
@ -40,9 +42,9 @@
} }
/// \brief The XMPPRosterItem corresponding to this contact /// \brief The XMPPRosterItem corresponding to this contact
@property (readonly) XMPPRosterItem *rosterItem; @property (readonly, nonatomic) XMPPRosterItem *rosterItem;
/// \brief The XMPPPresences of this contact with the resources as keys /// \brief The XMPPPresences of this contact with the resources as keys
@property (readonly) OFDictionary *presences; @property (readonly, nonatomic) OFDictionary *presences;
/** /**
* \brief Sends a message to the contact honoring resource locking * \brief Sends a message to the contact honoring resource locking
@ -50,12 +52,8 @@
* \param message The message to send * \param message The message to send
* \param connection The connection to use for sending the message * \param connection The connection to use for sending the message
*/ */
- (void)sendMessage: (XMPPMessage*)message - (void)sendMessage: (XMPPMessage *)message
connection: (XMPPConnection*)connection; connection: (XMPPConnection *)connection;
- (void)XMPP_setRosterItem: (XMPPRosterItem*)rosterItem;
- (void)XMPP_setPresence: (XMPPPresence*)presence
resource: (OFString*)resource;
- (void)XMPP_removePresenceForResource: (OFString*)resource;
- (void)XMPP_setLockedOnJID: (XMPPJID*)JID;
@end @end
OF_ASSUME_NONNULL_END

View file

@ -22,6 +22,7 @@
*/ */
#import "XMPPContact.h" #import "XMPPContact.h"
#import "XMPPContact+Private.h"
#import "XMPPMessage.h" #import "XMPPMessage.h"
#import "XMPPConnection.h" #import "XMPPConnection.h"
@ -50,8 +51,8 @@
[super dealloc]; [super dealloc];
} }
- (void)sendMessage: (XMPPMessage*)message - (void)sendMessage: (XMPPMessage *)message
connection: (XMPPConnection*)connection connection: (XMPPConnection *)connection
{ {
if (_lockedOnJID == nil) if (_lockedOnJID == nil)
[message setTo: [_rosterItem JID]]; [message setTo: [_rosterItem JID]];
@ -61,15 +62,15 @@
[connection sendStanza: message]; [connection sendStanza: message];
} }
- (void)XMPP_setRosterItem: (XMPPRosterItem*)rosterItem - (void)XMPP_setRosterItem: (XMPPRosterItem *)rosterItem
{ {
XMPPRosterItem *old = _rosterItem; XMPPRosterItem *old = _rosterItem;
_rosterItem = [rosterItem retain]; _rosterItem = [rosterItem retain];
[old release]; [old release];
} }
- (void)XMPP_setPresence: (XMPPPresence*)presence - (void)XMPP_setPresence: (XMPPPresence *)presence
resource: (OFString*)resource resource: (OFString *)resource
{ {
if (resource != nil) if (resource != nil)
[_presences setObject: presence [_presences setObject: presence
@ -81,7 +82,7 @@
[self XMPP_setLockedOnJID: nil]; [self XMPP_setLockedOnJID: nil];
} }
- (void)XMPP_removePresenceForResource: (OFString*)resource - (void)XMPP_removePresenceForResource: (OFString *)resource
{ {
if (resource != nil) { if (resource != nil) {
[_presences removeObjectForKey: resource]; [_presences removeObjectForKey: resource];
@ -93,7 +94,7 @@
[self XMPP_setLockedOnJID: nil]; [self XMPP_setLockedOnJID: nil];
} }
- (void)XMPP_setLockedOnJID: (XMPPJID*)JID; - (void)XMPP_setLockedOnJID: (XMPPJID *)JID;
{ {
XMPPJID *old = _lockedOnJID; XMPPJID *old = _lockedOnJID;
_lockedOnJID = [JID retain]; _lockedOnJID = [JID retain];

View file

@ -26,6 +26,8 @@
#import "XMPPConnection.h" #import "XMPPConnection.h"
#import "XMPPRoster.h" #import "XMPPRoster.h"
OF_ASSUME_NONNULL_BEGIN
@class XMPPContact; @class XMPPContact;
@class XMPPContactManager; @class XMPPContactManager;
@class XMPPMulticastDelegate; @class XMPPMulticastDelegate;
@ -43,8 +45,8 @@
* \param manager The contact manager that added the contact * \param manager The contact manager that added the contact
* \param contact The contact that was added * \param contact The contact that was added
*/ */
- (void)contactManager: (XMPPContactManager*)manager - (void)contactManager: (XMPPContactManager *)manager
didAddContact: (XMPPContact*)contact; didAddContact: (XMPPContact *)contact;
/** /**
* \brief This callback is called whenever a contact is no longer present in * \brief This callback is called whenever a contact is no longer present in
@ -53,8 +55,8 @@
* \param manager The contact manager that removed the contact * \param manager The contact manager that removed the contact
* \param contact The contact that was removed * \param contact The contact that was removed
*/ */
- (void)contactManager: (XMPPContactManager*)manager - (void)contactManager: (XMPPContactManager *)manager
didRemoveContact: (XMPPContact*)contact; didRemoveContact: (XMPPContact *)contact;
/** /**
* \brief This callback is called when a subscription request is received * \brief This callback is called when a subscription request is received
@ -62,8 +64,8 @@
* \param manager The contact manager that received the request * \param manager The contact manager that received the request
* \param presence The type=subscribe presence * \param presence The type=subscribe presence
*/ */
- (void)contactManager: (XMPPContactManager*)manager - (void)contactManager: (XMPPContactManager *)manager
didReceiveSubscriptionRequest: (XMPPPresence*)presence; didReceiveSubscriptionRequest: (XMPPPresence *)presence;
/** /**
* \brief This callback is called whenever a contact is about to change its * \brief This callback is called whenever a contact is about to change its
@ -72,8 +74,8 @@
* \param contact The contact about to updated 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 * \param rosterItem The roster item the contact is going to update with
*/ */
- (void)contact: (XMPPContact*)contact - (void)contact: (XMPPContact *)contact
willUpdateWithRosterItem: (XMPPRosterItem*)rosterItem; willUpdateWithRosterItem: (XMPPRosterItem *)rosterItem;
/** /**
* \brief This callback is called whenever a contact send a presence stanza * \brief This callback is called whenever a contact send a presence stanza
@ -81,8 +83,8 @@
* \param contact The contact that send the presence * \param contact The contact that send the presence
* \param presence The presence which was send by the contact * \param presence The presence which was send by the contact
*/ */
- (void)contact: (XMPPContact*)contact - (void)contact: (XMPPContact *)contact
didSendPresence: (XMPPPresence*)presence; didSendPresence: (XMPPPresence *)presence;
/** /**
* \brief This callback is called whenever a contact send a message stanza * \brief This callback is called whenever a contact send a message stanza
@ -90,8 +92,8 @@
* \param contact The contact that send the message * \param contact The contact that send the message
* \param message The message which was send by the contact * \param message The message which was send by the contact
*/ */
- (void)contact: (XMPPContact*)contact - (void)contact: (XMPPContact *)contact
didSendMessage: (XMPPMessage*)message; didSendMessage: (XMPPMessage *)message;
@end @end
/** /**
@ -110,7 +112,8 @@
} }
/// \brief The tracked contacts, with their bare JID as key /// \brief The tracked contacts, with their bare JID as key
@property (readonly) OFDictionary *contacts; @property (readonly, nonatomic)
OFDictionary OF_GENERIC(OFString *, XMPPContact *) *contacts;
/*! /*!
* @brief Initializes an already allocated XMPPContactManager. * @brief Initializes an already allocated XMPPContactManager.
@ -119,11 +122,11 @@
* @param roster The roster used by the contact manager * @param roster The roster used by the contact manager
* @return An initialized XMPPContactManager * @return An initialized XMPPContactManager
*/ */
- initWithConnection: (XMPPConnection*)connection - initWithConnection: (XMPPConnection *)connection
roster: (XMPPRoster*)roster; roster: (XMPPRoster *)roster OF_DESIGNATED_INITIALIZER;
- (void)sendSubscribedToJID: (XMPPJID*)subscriber; - (void)sendSubscribedToJID: (XMPPJID *)subscriber;
- (void)sendUnsubscribedToJID: (XMPPJID*)subscriber; - (void)sendUnsubscribedToJID: (XMPPJID *)subscriber;
/** /**
* \brief Adds the specified delegate. * \brief Adds the specified delegate.
@ -139,3 +142,5 @@
*/ */
- (void)removeDelegate: (id <XMPPContactManagerDelegate>)delegate; - (void)removeDelegate: (id <XMPPContactManagerDelegate>)delegate;
@end @end
OF_ASSUME_NONNULL_END

View file

@ -21,8 +21,9 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#import "XMPPContact.h"
#import "XMPPContactManager.h" #import "XMPPContactManager.h"
#import "XMPPContact.h"
#import "XMPPContact+Private.h"
#import "XMPPJID.h" #import "XMPPJID.h"
#import "XMPPMulticastDelegate.h" #import "XMPPMulticastDelegate.h"
#import "XMPPPresence.h" #import "XMPPPresence.h"
@ -31,8 +32,8 @@
@implementation XMPPContactManager @implementation XMPPContactManager
@synthesize contacts = _contacts; @synthesize contacts = _contacts;
- initWithConnection: (XMPPConnection*)connection - initWithConnection: (XMPPConnection *)connection
roster: (XMPPRoster*)roster roster: (XMPPRoster *)roster
{ {
self = [super init]; self = [super init];
@ -62,14 +63,14 @@
} }
- (void)sendSubscribedToJID: (XMPPJID*)subscriber - (void)sendSubscribedToJID: (XMPPJID *)subscriber
{ {
XMPPPresence *presence = [XMPPPresence presenceWithType: @"subscribed"]; XMPPPresence *presence = [XMPPPresence presenceWithType: @"subscribed"];
[presence setTo: subscriber]; [presence setTo: subscriber];
[_connection sendStanza: presence]; [_connection sendStanza: presence];
} }
- (void)sendUnsubscribedToJID: (XMPPJID*)subscriber - (void)sendUnsubscribedToJID: (XMPPJID *)subscriber
{ {
XMPPPresence *presence = XMPPPresence *presence =
[XMPPPresence presenceWithType: @"unsubscribed"]; [XMPPPresence presenceWithType: @"unsubscribed"];
@ -87,7 +88,7 @@
[_delegates removeDelegate: delegate]; [_delegates removeDelegate: delegate];
} }
- (void)rosterWasReceived: (XMPPRoster*)roster - (void)rosterWasReceived: (XMPPRoster *)roster
{ {
OFEnumerator *contactEnumerator; OFEnumerator *contactEnumerator;
XMPPContact *contact; XMPPContact *contact;
@ -120,8 +121,8 @@
} }
} }
- (void)roster: (XMPPRoster*)roster - (void)roster: (XMPPRoster *)roster
didReceiveRosterItem: (XMPPRosterItem*)rosterItem didReceiveRosterItem: (XMPPRosterItem *)rosterItem
{ {
XMPPContact *contact; XMPPContact *contact;
OFString *bareJID = [[rosterItem JID] bareJID]; OFString *bareJID = [[rosterItem JID] bareJID];
@ -156,8 +157,8 @@
} }
} }
- (void)connection: (XMPPConnection*)connection - (void)connection: (XMPPConnection *)connection
didReceivePresence: (XMPPPresence*)presence didReceivePresence: (XMPPPresence *)presence
{ {
XMPPContact *contact; XMPPContact *contact;
XMPPJID *JID = [presence from]; XMPPJID *JID = [presence from];
@ -199,8 +200,8 @@
} }
} }
- (void)connection: (XMPPConnection*)connection - (void)connection: (XMPPConnection *)connection
didReceiveMessage: (XMPPMessage*)message didReceiveMessage: (XMPPMessage *)message
{ {
XMPPJID *JID = [message from]; XMPPJID *JID = [message from];
XMPPContact *contact = [_contacts objectForKey: [JID bareJID]]; XMPPContact *contact = [_contacts objectForKey: [JID bareJID]];

View file

@ -26,6 +26,8 @@
#import "XMPPConnection.h" #import "XMPPConnection.h"
#import "XMPPDiscoNode.h" #import "XMPPDiscoNode.h"
OF_ASSUME_NONNULL_BEGIN
@class XMPPJID; @class XMPPJID;
/** /**
@ -53,6 +55,12 @@
*/ */
@property (readonly) OFString *capsNode; @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 * \brief Creates a new autoreleased XMPPDiscoEntity with the specified
* connection. * connection.
@ -60,7 +68,7 @@
* \param connection The XMPPConnection to serve responses on. * \param connection The XMPPConnection to serve responses on.
* \return A new autoreleased XMPPDiscoEntity * \return A new autoreleased XMPPDiscoEntity
*/ */
+ (instancetype)discoEntityWithConnection: (XMPPConnection*)connection; + (instancetype)discoEntityWithConnection: (XMPPConnection *)connection;
/** /**
* \brief Creates a new autoreleased XMPPDiscoEntity with the specified * \brief Creates a new autoreleased XMPPDiscoEntity with the specified
@ -70,8 +78,14 @@
* \param capsNode The node advertised for the entity's capabilites * \param capsNode The node advertised for the entity's capabilites
* \return A new autoreleased XMPPDiscoEntity * \return A new autoreleased XMPPDiscoEntity
*/ */
+ (instancetype)discoEntityWithConnection: (XMPPConnection*)connection + (instancetype)discoEntityWithConnection: (XMPPConnection *)connection
capsNode: (OFString*)capsNode; 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 * \brief Initializes an already allocated XMPPDiscoEntity with the specified
@ -81,7 +95,7 @@
* This must already be bound to a resource) * This must already be bound to a resource)
* \return An initialized XMPPDiscoEntity * \return An initialized XMPPDiscoEntity
*/ */
- initWithConnection: (XMPPConnection*)connection; - initWithConnection: (XMPPConnection *)connection;
/** /**
* \brief Initializes an already allocated XMPPDiscoEntity with the specified * \brief Initializes an already allocated XMPPDiscoEntity with the specified
@ -92,20 +106,22 @@
* \param capsNode The node advertised for the entity's capabilites * \param capsNode The node advertised for the entity's capabilites
* \return An initialized XMPPDiscoEntity * \return An initialized XMPPDiscoEntity
*/ */
- initWithConnection: (XMPPConnection*)connection - initWithConnection: (XMPPConnection *)connection
capsNode: (OFString*)capsNode; capsNode: (nullable OFString *)capsNode OF_DESIGNATED_INITIALIZER;
/** /**
* \brief Adds a XMPPDiscoNode to provide responses for. * \brief Adds a XMPPDiscoNode to provide responses for.
* *
* \param node The XMPPDiscoNode to provide responses for * \param node The XMPPDiscoNode to provide responses for
*/ */
- (void)addDiscoNode: (XMPPDiscoNode*)node; - (void)addDiscoNode: (XMPPDiscoNode *)node;
/** /**
* \brief Calculates the Entity Capabilities Hash of the entity * \brief Calculates the Entity Capabilities Hash of the entity
* *
* \return A OFString containing the capabilities hash * \return A OFString containing the capabilities hash
*/ */
- (OFString*)capsHash; - (OFString *)capsHash;
@end @end
OF_ASSUME_NONNULL_END

View file

@ -22,6 +22,8 @@
*/ */
#import "XMPPDiscoEntity.h" #import "XMPPDiscoEntity.h"
#import "XMPPDiscoNode.h"
#import "XMPPDiscoNode+Private.h"
#import "XMPPDiscoIdentity.h" #import "XMPPDiscoIdentity.h"
#import "XMPPIQ.h" #import "XMPPIQ.h"
#import "namespaces.h" #import "namespaces.h"
@ -29,29 +31,37 @@
@implementation XMPPDiscoEntity @implementation XMPPDiscoEntity
@synthesize discoNodes = _discoNodes, capsNode = _capsNode; @synthesize discoNodes = _discoNodes, capsNode = _capsNode;
+ (instancetype)discoEntityWithConnection: (XMPPConnection*)connection + (instancetype)discoEntityWithConnection: (XMPPConnection *)connection
{ {
return [[[self alloc] initWithConnection: connection] autorelease]; return [[[self alloc] initWithConnection: connection] autorelease];
} }
+ (instancetype)discoEntityWithConnection: (XMPPConnection*)connection + (instancetype)discoEntityWithConnection: (XMPPConnection *)connection
capsNode: (OFString*)capsNode capsNode: (OFString *)capsNode
{ {
return [[[self alloc] initWithConnection: connection return [[[self alloc] initWithConnection: connection
capsNode: capsNode] autorelease]; capsNode: capsNode] autorelease];
} }
- initWithConnection: (XMPPConnection*)connection - initWithConnection: (XMPPConnection *)connection
{ {
return [self initWithConnection: connection return [self initWithConnection: connection
capsNode: nil]; capsNode: nil];
} }
- initWithConnection: (XMPPConnection*)connection - initWithJID: (XMPPJID *)JID
capsNode: (OFString*)capsNode node: (nullable OFString *)node
name: (nullable OFString *)name
{
OF_INVALID_INIT_METHOD
}
- initWithConnection: (XMPPConnection *)connection
capsNode: (OFString *)capsNode
{ {
self = [super initWithJID: [connection JID] self = [super initWithJID: [connection JID]
node: nil]; node: nil
name: nil];
@try { @try {
_discoNodes = [[OFMutableDictionary alloc] init]; _discoNodes = [[OFMutableDictionary alloc] init];
@ -75,13 +85,13 @@
[super dealloc]; [super dealloc];
} }
- (void)addDiscoNode: (XMPPDiscoNode*)node - (void)addDiscoNode: (XMPPDiscoNode *)node
{ {
[_discoNodes setObject: node [_discoNodes setObject: node
forKey: [node node]]; forKey: [node node]];
} }
- (OFString*)capsHash - (OFString *)capsHash
{ {
OFEnumerator *enumerator; OFEnumerator *enumerator;
XMPPDiscoIdentity *identity; XMPPDiscoIdentity *identity;
@ -108,14 +118,14 @@
return [digest stringByBase64Encoding]; return [digest stringByBase64Encoding];
} }
- (void)connection: (XMPPConnection*)connection - (void)connection: (XMPPConnection *)connection
wasBoundToJID: (XMPPJID*)JID wasBoundToJID: (XMPPJID *)JID
{ {
_JID = [JID copy]; _JID = [JID copy];
} }
- (bool)connection: (XMPPConnection*)connection - (bool)connection: (XMPPConnection *)connection
didReceiveIQ: (XMPPIQ*)IQ didReceiveIQ: (XMPPIQ *)IQ
{ {
if (![[IQ to] isEqual: _JID]) if (![[IQ to] isEqual: _JID])
return false; return false;

View file

@ -23,6 +23,8 @@
#import <ObjFW/ObjFW.h> #import <ObjFW/ObjFW.h>
OF_ASSUME_NONNULL_BEGIN
/** /**
* \brief A class describing a Service Discovery Identity * \brief A class describing a Service Discovery Identity
*/ */
@ -32,11 +34,11 @@
} }
/// \brief The category of the identity /// \brief The category of the identity
@property (readonly) OFString *category; @property (readonly, nonatomic) OFString *category;
/// \brief The name of the identity, might be unset /// \brief The name of the identity, might be unset
@property (readonly) OFString *name; @property (readonly, nonatomic) OFString *name;
/// \brief The type of the identity /// \brief The type of the identity
@property (readonly) OFString *type; @property (readonly, nonatomic) OFString *type;
/** /**
* \brief Creates a new autoreleased XMPPDiscoIdentity with the specified * \brief Creates a new autoreleased XMPPDiscoIdentity with the specified
@ -47,9 +49,9 @@
* \param name The name of the identity * \param name The name of the identity
* \return A new autoreleased XMPPDiscoIdentity * \return A new autoreleased XMPPDiscoIdentity
*/ */
+ (instancetype)identityWithCategory: (OFString*)category + (instancetype)identityWithCategory: (OFString *)category
type: (OFString*)type type: (OFString *)type
name: (OFString*)name; name: (nullable OFString *)name;
/** /**
* \brief Creates a new autoreleased XMPPDiscoIdentity with the specified * \brief Creates a new autoreleased XMPPDiscoIdentity with the specified
@ -59,8 +61,10 @@
* \param type The type of the identity * \param type The type of the identity
* \return A new autoreleased XMPPDiscoIdentity * \return A new autoreleased XMPPDiscoIdentity
*/ */
+ (instancetype)identityWithCategory: (OFString*)category + (instancetype)identityWithCategory: (OFString *)category
type: (OFString*)type; type: (OFString *)type;
- init OF_UNAVAILABLE;
/** /**
* \brief Initializes an already allocated XMPPDiscoIdentity with the specified * \brief Initializes an already allocated XMPPDiscoIdentity with the specified
@ -71,9 +75,9 @@
* \param name The name of the identity * \param name The name of the identity
* \return An initialized XMPPDiscoIdentity * \return An initialized XMPPDiscoIdentity
*/ */
- initWithCategory: (OFString*)category - initWithCategory: (OFString *)category
type: (OFString*)type type: (OFString *)type
name: (OFString*)name; name: (nullable OFString *)name OF_DESIGNATED_INITIALIZER;
/** /**
* \brief Initializes an already allocated XMPPDiscoIdentity with the specified * \brief Initializes an already allocated XMPPDiscoIdentity with the specified
@ -83,6 +87,8 @@
* \param type The type of the identity * \param type The type of the identity
* \return An initialized XMPPDiscoIdentity * \return An initialized XMPPDiscoIdentity
*/ */
- initWithCategory: (OFString*)category - initWithCategory: (OFString *)category
type: (OFString*)type; type: (OFString *)type;
@end @end
OF_ASSUME_NONNULL_END

View file

@ -26,25 +26,25 @@
@implementation XMPPDiscoIdentity @implementation XMPPDiscoIdentity
@synthesize category = _category, name = _name, type = _type; @synthesize category = _category, name = _name, type = _type;
+ (instancetype)identityWithCategory: (OFString*)category + (instancetype)identityWithCategory: (OFString *)category
type: (OFString*)type type: (OFString *)type
name: (OFString*)name name: (OFString *)name
{ {
return [[[self alloc] initWithCategory: category return [[[self alloc] initWithCategory: category
type: type type: type
name: name] autorelease]; name: name] autorelease];
} }
+ (instancetype)identityWithCategory: (OFString*)category + (instancetype)identityWithCategory: (OFString *)category
type: (OFString*)type type: (OFString *)type
{ {
return [[[self alloc] initWithCategory: category return [[[self alloc] initWithCategory: category
type: type] autorelease]; type: type] autorelease];
} }
- initWithCategory: (OFString*)category - initWithCategory: (OFString *)category
type: (OFString*)type type: (OFString *)type
name: (OFString*)name name: (OFString *)name
{ {
self = [super init]; self = [super init];
@ -63,8 +63,8 @@
return self; return self;
} }
- initWithCategory: (OFString*)category - initWithCategory: (OFString *)category
type: (OFString*)type type: (OFString *)type
{ {
return [self initWithCategory: category return [self initWithCategory: category
type: type type: type
@ -73,14 +73,7 @@
- init - init
{ {
@try { OF_INVALID_INIT_METHOD
[self doesNotRecognizeSelector: _cmd];
} @catch (id e) {
[self release];
@throw e;
}
abort();
} }
- (void)dealloc - (void)dealloc
@ -139,7 +132,7 @@
if (![object isKindOfClass: [XMPPDiscoIdentity class]]) if (![object isKindOfClass: [XMPPDiscoIdentity class]])
@throw [OFInvalidArgumentException exception]; @throw [OFInvalidArgumentException exception];
identity = (XMPPDiscoIdentity*)object; identity = (XMPPDiscoIdentity *)object;
categoryResult = [_category compare: identity->_category]; categoryResult = [_category compare: identity->_category];
if (categoryResult != OF_ORDERED_SAME) if (categoryResult != OF_ORDERED_SAME)

View file

@ -0,0 +1,15 @@
#import "XMPPDiscoNode.h"
OF_ASSUME_NONNULL_BEGIN
@class XMPPConnection;
@class XMPPIQ;
@interface XMPPDiscoNode ()
- (bool)XMPP_handleItemsIQ: (XMPPIQ *)IQ
connection: (XMPPConnection *)connection;
- (bool)XMPP_handleInfoIQ: (XMPPIQ *)IQ
connection: (XMPPConnection *)connection;
@end
OF_ASSUME_NONNULL_END

View file

@ -23,6 +23,8 @@
#import <ObjFW/ObjFW.h> #import <ObjFW/ObjFW.h>
OF_ASSUME_NONNULL_BEGIN
@class XMPPDiscoIdentity; @class XMPPDiscoIdentity;
@class XMPPJID; @class XMPPJID;
@ -40,17 +42,17 @@
} }
/// \brief The JID this node lives on /// \brief The JID this node lives on
@property (readonly) XMPPJID *JID; @property (readonly, nonatomic) XMPPJID *JID;
/// \brief The node's opaque name of the node /// \brief The node's opaque name of the node
@property (readonly) OFString *node; @property (readonly, nonatomic) OFString *node;
/// \brief The node's human friendly name (may be unspecified) /// \brief The node's human friendly name (may be unspecified)
@property (readonly) OFString *name; @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *name;
/// \brief The node's list of identities /// \brief The node's list of identities
@property (readonly) OFSortedList *identities; @property (readonly, nonatomic) OFSortedList *identities;
/// \brief The node's list of features /// \brief The node's list of features
@property (readonly) OFSortedList *features; @property (readonly, nonatomic) OFSortedList *features;
/// \brief The node's children /// \brief The node's children
@property (readonly) OFDictionary *childNodes; @property (readonly, nonatomic) OFDictionary *childNodes;
/** /**
* \brief Creates a new autoreleased XMPPDiscoNode with the specified * \brief Creates a new autoreleased XMPPDiscoNode with the specified
@ -60,8 +62,8 @@
* \param node The node's opaque name * \param node The node's opaque name
* \return A new autoreleased XMPPDiscoNode * \return A new autoreleased XMPPDiscoNode
*/ */
+ (instancetype)discoNodeWithJID: (XMPPJID*)JID + (instancetype)discoNodeWithJID: (XMPPJID *)JID
node: (OFString*)node; node: (nullable OFString *)node;
/** /**
* \brief Creates a new autoreleased XMPPDiscoNode with the specified * \brief Creates a new autoreleased XMPPDiscoNode with the specified
@ -72,9 +74,9 @@
* \param name The node's human friendly name * \param name The node's human friendly name
* \return A new autoreleased XMPPDiscoNode * \return A new autoreleased XMPPDiscoNode
*/ */
+ (instancetype)discoNodeWithJID: (XMPPJID*)JID + (instancetype)discoNodeWithJID: (XMPPJID *)JID
node: (OFString*)node node: (nullable OFString *)node
name: (OFString*)name; name: (nullable OFString *)name;
/** /**
* \brief Initializes an already allocated XMPPDiscoNode with the specified * \brief Initializes an already allocated XMPPDiscoNode with the specified
@ -84,8 +86,8 @@
* \param node The node's opaque name * \param node The node's opaque name
* \return An initialized XMPPDiscoNode * \return An initialized XMPPDiscoNode
*/ */
- initWithJID: (XMPPJID*)JID - initWithJID: (XMPPJID *)JID
node: (OFString*)node; node: (nullable OFString *)node;
/** /**
* \brief Initializes an already allocated XMPPDiscoNode with the specified * \brief Initializes an already allocated XMPPDiscoNode with the specified
@ -96,33 +98,30 @@
* \param name The node's human friendly name * \param name The node's human friendly name
* \return An initialized XMPPDiscoNode * \return An initialized XMPPDiscoNode
*/ */
- initWithJID: (XMPPJID*)JID - initWithJID: (XMPPJID *)JID
node: (OFString*)node node: (nullable OFString *)node
name: (OFString*)name; name: (nullable OFString *)name OF_DESIGNATED_INITIALIZER;
/** /**
* \brief Adds an XMPPDiscoIdentity to the node * \brief Adds an XMPPDiscoIdentity to the node
* *
* \param identity The XMPPDiscoIdentity to add * \param identity The XMPPDiscoIdentity to add
*/ */
- (void)addIdentity: (XMPPDiscoIdentity*)identity; - (void)addIdentity: (XMPPDiscoIdentity *)identity;
/** /**
* \brief Adds a feature to the node * \brief Adds a feature to the node
* *
* \param feature The feature to add * \param feature The feature to add
*/ */
- (void)addFeature: (OFString*)feature; - (void)addFeature: (OFString *)feature;
/** /**
* \brief Adds a XMPPDiscoNode as child of the node * \brief Adds a XMPPDiscoNode as child of the node
* *
* \param node The XMPPDiscoNode to add as child * \param node The XMPPDiscoNode to add as child
*/ */
- (void)addChildNode: (XMPPDiscoNode*)node; - (void)addChildNode: (XMPPDiscoNode *)node;
- (bool)XMPP_handleItemsIQ: (XMPPIQ*)IQ
connection: (XMPPConnection*)connection;
- (bool)XMPP_handleInfoIQ: (XMPPIQ*)IQ
connection: (XMPPConnection*)connection;
@end @end
OF_ASSUME_NONNULL_END

View file

@ -21,11 +21,12 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#import "XMPPDiscoNode.h"
#import "XMPPDiscoNode+Private.h"
#import "XMPPConnection.h" #import "XMPPConnection.h"
#import "XMPPIQ.h" #import "XMPPIQ.h"
#import "XMPPJID.h" #import "XMPPJID.h"
#import "XMPPDiscoEntity.h" #import "XMPPDiscoEntity.h"
#import "XMPPDiscoNode.h"
#import "XMPPDiscoIdentity.h" #import "XMPPDiscoIdentity.h"
#import "namespaces.h" #import "namespaces.h"
@ -34,33 +35,33 @@
@synthesize JID = _JID, node = _node, name = _name, identities = _identities; @synthesize JID = _JID, node = _node, name = _name, identities = _identities;
@synthesize features = _features, childNodes = _childNodes; @synthesize features = _features, childNodes = _childNodes;
+ (instancetype)discoNodeWithJID: (XMPPJID*)JID + (instancetype)discoNodeWithJID: (XMPPJID *)JID
node: (OFString*)node; node: (OFString *)node;
{ {
return [[[self alloc] initWithJID: JID return [[[self alloc] initWithJID: JID
node: node] autorelease]; node: node] autorelease];
} }
+ (instancetype)discoNodeWithJID: (XMPPJID*)JID + (instancetype)discoNodeWithJID: (XMPPJID *)JID
node: (OFString*)node node: (OFString *)node
name: (OFString*)name name: (OFString *)name
{ {
return [[[self alloc] initWithJID: JID return [[[self alloc] initWithJID: JID
node: node node: node
name: name] autorelease]; name: name] autorelease];
} }
- initWithJID: (XMPPJID*)JID - initWithJID: (XMPPJID *)JID
node: (OFString*)node node: (OFString *)node
{ {
return [self initWithJID: JID return [self initWithJID: JID
node: node node: node
name: nil]; name: nil];
} }
- initWithJID: (XMPPJID*)JID - initWithJID: (XMPPJID *)JID
node: (OFString*)node node: (OFString *)node
name: (OFString*)name name: (OFString *)name
{ {
self = [super init]; self = [super init];
@ -98,24 +99,29 @@
[super dealloc]; [super dealloc];
} }
- (void)addIdentity: (XMPPDiscoIdentity*)identity - (OFDictionary *)childNodes
{
return [[_childNodes copy] autorelease];
}
- (void)addIdentity: (XMPPDiscoIdentity *)identity
{ {
[_identities insertObject: identity]; [_identities insertObject: identity];
} }
- (void)addFeature: (OFString*)feature - (void)addFeature: (OFString *)feature
{ {
[_features insertObject: feature]; [_features insertObject: feature];
} }
- (void)addChildNode: (XMPPDiscoNode*)node - (void)addChildNode: (XMPPDiscoNode *)node
{ {
[_childNodes setObject: node [_childNodes setObject: node
forKey: [node node]]; forKey: [node node]];
} }
- (bool)XMPP_handleItemsIQ: (XMPPIQ*)IQ - (bool)XMPP_handleItemsIQ: (XMPPIQ *)IQ
connection: (XMPPConnection*)connection connection: (XMPPConnection *)connection
{ {
XMPPIQ *resultIQ; XMPPIQ *resultIQ;
OFXMLElement *response; OFXMLElement *response;
@ -156,8 +162,8 @@
return true; return true;
} }
- (bool)XMPP_handleInfoIQ: (XMPPIQ*)IQ - (bool)XMPP_handleInfoIQ: (XMPPIQ *)IQ
connection: (XMPPConnection*)connection connection: (XMPPConnection *)connection
{ {
XMPPIQ *resultIQ; XMPPIQ *resultIQ;
OFXMLElement *response; OFXMLElement *response;

View file

@ -23,6 +23,8 @@
#import <ObjFW/ObjFW.h> #import <ObjFW/ObjFW.h>
#import "XMPPAuthenticator.h" #import "XMPPAuthenticator.h"
OF_ASSUME_NONNULL_BEGIN
/** /**
* \brief A class to authenticate using SASL EXTERNAL * \brief A class to authenticate using SASL EXTERNAL
*/ */
@ -40,5 +42,7 @@
* \param authzid The authzid to get authorization for * \param authzid The authzid to get authorization for
* \return A new autoreleased XMPPEXTERNALAuth * \return A new autoreleased XMPPEXTERNALAuth
*/ */
+ (instancetype)EXTERNALAuthWithAuthzid: (OFString*)authzid; + (instancetype)EXTERNALAuthWithAuthzid: (nullable OFString *)authzid;
@end @end
OF_ASSUME_NONNULL_END

View file

@ -33,14 +33,14 @@
password: nil] autorelease]; password: nil] autorelease];
} }
+ (instancetype)EXTERNALAuthWithAuthzid: (OFString*)authzid + (instancetype)EXTERNALAuthWithAuthzid: (OFString *)authzid
{ {
return [[[self alloc] initWithAuthzid: authzid return [[[self alloc] initWithAuthzid: authzid
authcid: nil authcid: nil
password: nil] autorelease]; password: nil] autorelease];
} }
- (OFDataArray*)initialMessage - (OFDataArray *)initialMessage
{ {
OFDataArray *message = [OFDataArray dataArray]; OFDataArray *message = [OFDataArray dataArray];

View file

@ -23,6 +23,8 @@
#import <ObjFW/ObjFW.h> #import <ObjFW/ObjFW.h>
OF_ASSUME_NONNULL_BEGIN
@class XMPPConnection; @class XMPPConnection;
@class XMPPAuthenticator; @class XMPPAuthenticator;
@ -35,7 +37,7 @@
} }
/// \brief The connection the exception relates to /// \brief The connection the exception relates to
@property (readonly, retain) XMPPConnection *connection; @property OF_NULLABLE_PROPERTY (readonly, nonatomic) XMPPConnection *connection;
/** /**
* \brief Creates a new XMPPException. * \brief Creates a new XMPPException.
@ -44,7 +46,9 @@
* for this exception * for this exception
* \return A new XMPPException * \return A new XMPPException
*/ */
+ (instancetype)exceptionWithConnection: (XMPPConnection*)connection; + (instancetype)exceptionWithConnection: (nullable XMPPConnection *)connection;
- init OF_UNAVAILABLE;
/** /**
* \brief Initializes an already allocated XMPPException. * \brief Initializes an already allocated XMPPException.
@ -53,7 +57,8 @@
* for this exception * for this exception
* \return An initialized XMPPException * \return An initialized XMPPException
*/ */
- initWithConnection: (XMPPConnection*)connection; - initWithConnection: (nullable XMPPConnection *)connection
OF_DESIGNATED_INITIALIZER;
@end @end
/** /**
@ -65,9 +70,9 @@
} }
/// \brief The defined error condition specified by the stream error /// \brief The defined error condition specified by the stream error
@property (readonly, copy) OFString *condition; @property (readonly, nonatomic) OFString *condition;
/// \brief The descriptive free-form text specified by the stream error /// \brief The descriptive free-form text specified by the stream error
@property (readonly, copy) OFString *reason; @property (readonly, nonatomic) OFString *reason;
/** /**
* \brief Creates a new XMPPStreamErrorException. * \brief Creates a new XMPPStreamErrorException.
@ -77,9 +82,11 @@
* \param reason The descriptive free-form text specified by the stream error * \param reason The descriptive free-form text specified by the stream error
* \return A new XMPPStreamErrorException * \return A new XMPPStreamErrorException
*/ */
+ (instancetype)exceptionWithConnection: (XMPPConnection*)connection + (instancetype)exceptionWithConnection: (nullable XMPPConnection *)connection
condition: (OFString*)condition condition: (OFString *)condition
reason: (OFString*)reason; reason: (OFString *)reason;
- initWithConnection: (nullable XMPPConnection *)connection OF_UNAVAILABLE;
/** /**
* \brief Initializes an already allocated XMPPStreamErrorException. * \brief Initializes an already allocated XMPPStreamErrorException.
@ -89,9 +96,9 @@
* \param reason The descriptive free-form text specified by the stream error * \param reason The descriptive free-form text specified by the stream error
* \return An initialized XMPPStreamErrorException * \return An initialized XMPPStreamErrorException
*/ */
- initWithConnection: (XMPPConnection*)connection - initWithConnection: (nullable XMPPConnection *)connection
condition: (OFString*)condition condition: (OFString *)condition
reason: (OFString*)reason; reason: (OFString *)reason OF_DESIGNATED_INITIALIZER;
@end @end
/** /**
@ -104,9 +111,9 @@
} }
/// \brief The name of the stringprep profile that did not apply /// \brief The name of the stringprep profile that did not apply
@property (readonly, copy) OFString *profile; @property (readonly, nonatomic) OFString *profile;
/// \brief The string that failed the stringprep profile /// \brief The string that failed the stringprep profile
@property (readonly, copy) OFString *string; @property (readonly, nonatomic) OFString *string;
/** /**
* \brief Creates a new XMPPStringPrepFailedException. * \brief Creates a new XMPPStringPrepFailedException.
@ -116,9 +123,11 @@
* \param string The string that failed the stringprep profile * \param string The string that failed the stringprep profile
* \return A new XMPPStringPrepFailedException * \return A new XMPPStringPrepFailedException
*/ */
+ (instancetype)exceptionWithConnection: (XMPPConnection*)connection + (instancetype)exceptionWithConnection: (nullable XMPPConnection *)connection
profile: (OFString*)profile profile: (OFString *)profile
string: (OFString*)string; string: (OFString *)string;
- initWithConnection: (nullable XMPPConnection *)connection OF_UNAVAILABLE;
/** /**
* \brief Initializes an already allocated XMPPStringPrepFailedException. * \brief Initializes an already allocated XMPPStringPrepFailedException.
@ -128,9 +137,9 @@
* \param string The string that failed the stringprep profile * \param string The string that failed the stringprep profile
* \return An initialized XMPPStringPrepFailedException * \return An initialized XMPPStringPrepFailedException
*/ */
- initWithConnection: (XMPPConnection*)connection - initWithConnection: (nullable XMPPConnection *)connection
profile: (OFString*)profile profile: (OFString *)profile
string: (OFString*)string; string: (OFString *)string OF_DESIGNATED_INITIALIZER;
@end @end
/** /**
@ -142,9 +151,9 @@
} }
/// \brief The IDNA translation operation which failed /// \brief The IDNA translation operation which failed
@property (readonly, copy) OFString *operation; @property (readonly, nonatomic) OFString *operation;
/// \brief The string that could not be translated /// \brief The string that could not be translated
@property (readonly, copy) OFString *string; @property (readonly, nonatomic) OFString *string;
/** /**
* \brief Creates a new XMPPIDNATranslationFailedException. * \brief Creates a new XMPPIDNATranslationFailedException.
@ -154,9 +163,11 @@
* \param string The string that could not be translated * \param string The string that could not be translated
* \return A new XMPPIDNATranslationFailedException * \return A new XMPPIDNATranslationFailedException
*/ */
+ (instancetype)exceptionWithConnection: (XMPPConnection*)connection + (instancetype)exceptionWithConnection: (nullable XMPPConnection *)connection
operation: (OFString*)operation operation: (OFString *)operation
string: (OFString*)string; string: (OFString *)string;
- initWithConnection: (nullable XMPPConnection *)connection OF_UNAVAILABLE;
/** /**
* \brief Initializes an already allocated XMPPIDNATranslationFailedException. * \brief Initializes an already allocated XMPPIDNATranslationFailedException.
@ -166,9 +177,9 @@
* \param string The string that could not be translated * \param string The string that could not be translated
* \return An initialized XMPPIDNATranslationFailedException * \return An initialized XMPPIDNATranslationFailedException
*/ */
- initWithConnection: (XMPPConnection*)connection - initWithConnection: (nullable XMPPConnection *)connection
operation: (OFString*)operation operation: (OFString *)operation
string: (OFString*)string; string: (OFString *)string;
@end @end
/** /**
@ -180,7 +191,7 @@
} }
/// \brief The reason the authentication failed /// \brief The reason the authentication failed
@property (readonly, copy) OFString *reason; @property (readonly, nonatomic) OFString *reason;
/** /**
* \brief Creates a new XMPPAuthFailedException. * \brief Creates a new XMPPAuthFailedException.
@ -189,8 +200,10 @@
* \param reason The reason the authentication failed * \param reason The reason the authentication failed
* \return A new XMPPAuthFailedException * \return A new XMPPAuthFailedException
*/ */
+ (instancetype)exceptionWithConnection: (XMPPConnection*)connection + (instancetype)exceptionWithConnection: (nullable XMPPConnection *)connection
reason: (OFString*)reason; reason: (OFString *)reason;
- initWithConnection: (nullable XMPPConnection *)connection OF_UNAVAILABLE;
/** /**
* \brief Initializes an already allocated XMPPAuthFailedException. * \brief Initializes an already allocated XMPPAuthFailedException.
@ -199,6 +212,8 @@
* \param reason The reason the authentication failed * \param reason The reason the authentication failed
* \return An initialized XMPPAuthFailedException * \return An initialized XMPPAuthFailedException
*/ */
- initWithConnection: (XMPPConnection*)connection - initWithConnection: (nullable XMPPConnection *)connection
reason: (OFString*)reason; reason: (OFString *)reason OF_DESIGNATED_INITIALIZER;
@end @end
OF_ASSUME_NONNULL_END

View file

@ -33,7 +33,7 @@
@implementation XMPPException @implementation XMPPException
@synthesize connection = _connection; @synthesize connection = _connection;
+ (instancetype)exceptionWithConnection: (XMPPConnection*)connection + (instancetype)exceptionWithConnection: (XMPPConnection *)connection
{ {
return [[[self alloc] initWithConnection: connection] autorelease]; return [[[self alloc] initWithConnection: connection] autorelease];
} }
@ -43,7 +43,7 @@
OF_INVALID_INIT_METHOD OF_INVALID_INIT_METHOD
} }
- initWithConnection: (XMPPConnection*)connection - initWithConnection: (XMPPConnection *)connection
{ {
self = [super init]; self = [super init];
@ -68,23 +68,23 @@
@implementation XMPPStreamErrorException @implementation XMPPStreamErrorException
@synthesize condition = _condition, reason = _reason; @synthesize condition = _condition, reason = _reason;
+ (instancetype)exceptionWithConnection: (XMPPConnection*)connection + (instancetype)exceptionWithConnection: (XMPPConnection *)connection
condition: (OFString*)condition condition: (OFString *)condition
reason: (OFString*)reason; reason: (OFString *)reason;
{ {
return [[[self alloc] initWithConnection: connection return [[[self alloc] initWithConnection: connection
condition: condition condition: condition
reason: reason] autorelease]; reason: reason] autorelease];
} }
- initWithConnection: (XMPPConnection*)connection - initWithConnection: (XMPPConnection *)connection
{ {
OF_INVALID_INIT_METHOD OF_INVALID_INIT_METHOD
} }
- initWithConnection: (XMPPConnection*)connection - initWithConnection: (XMPPConnection *)connection
condition: (OFString*)condition condition: (OFString *)condition
reason: (OFString*)reason reason: (OFString *)reason
{ {
self = [super initWithConnection: connection]; self = [super initWithConnection: connection];
@ -107,7 +107,7 @@
[super dealloc]; [super dealloc];
} }
- (OFString*)description - (OFString *)description
{ {
return [OFString stringWithFormat: return [OFString stringWithFormat:
@"Got stream error: %@. Reason: %@!", _condition, _reason]; @"Got stream error: %@. Reason: %@!", _condition, _reason];
@ -117,23 +117,23 @@
@implementation XMPPStringPrepFailedException @implementation XMPPStringPrepFailedException
@synthesize profile = _profile, string = _string; @synthesize profile = _profile, string = _string;
+ (instancetype)exceptionWithConnection: (XMPPConnection*)connection + (instancetype)exceptionWithConnection: (XMPPConnection *)connection
profile: (OFString*)profile profile: (OFString *)profile
string: (OFString*)string string: (OFString *)string
{ {
return [[[self alloc] initWithConnection: connection return [[[self alloc] initWithConnection: connection
profile: profile profile: profile
string: string] autorelease]; string: string] autorelease];
} }
- initWithConnection: (XMPPConnection*)connection - initWithConnection: (XMPPConnection *)connection
{ {
OF_INVALID_INIT_METHOD OF_INVALID_INIT_METHOD
} }
- initWithConnection: (XMPPConnection*)connection - initWithConnection: (XMPPConnection *)connection
profile: (OFString*)profile profile: (OFString *)profile
string: (OFString*)string string: (OFString *)string
{ {
self = [super initWithConnection: connection]; self = [super initWithConnection: connection];
@ -156,7 +156,7 @@
[super dealloc]; [super dealloc];
} }
- (OFString*)description - (OFString *)description
{ {
return [OFString stringWithFormat: return [OFString stringWithFormat:
@"Stringprep with profile %@ failed on string '%@'!", @"Stringprep with profile %@ failed on string '%@'!",
@ -167,23 +167,23 @@
@implementation XMPPIDNATranslationFailedException @implementation XMPPIDNATranslationFailedException
@synthesize operation = _operation, string = _string; @synthesize operation = _operation, string = _string;
+ (instancetype)exceptionWithConnection: (XMPPConnection*)connection + (instancetype)exceptionWithConnection: (XMPPConnection *)connection
operation: (OFString*)operation operation: (OFString *)operation
string: (OFString*)string string: (OFString *)string
{ {
return [[[self alloc] initWithConnection: connection return [[[self alloc] initWithConnection: connection
operation: operation operation: operation
string: string] autorelease]; string: string] autorelease];
} }
- initWithConnection: (XMPPConnection*)connection - initWithConnection: (XMPPConnection *)connection
{ {
OF_INVALID_INIT_METHOD OF_INVALID_INIT_METHOD
} }
- initWithConnection: (XMPPConnection*)connection - initWithConnection: (XMPPConnection *)connection
operation: (OFString*)operation operation: (OFString *)operation
string: (OFString*)string string: (OFString *)string
{ {
self = [super initWithConnection: connection]; self = [super initWithConnection: connection];
@ -206,7 +206,7 @@
[super dealloc]; [super dealloc];
} }
- (OFString*)description - (OFString *)description
{ {
return [OFString stringWithFormat: return [OFString stringWithFormat:
@"IDNA operation %@ failed on string '%@'!", _operation, _string]; @"IDNA operation %@ failed on string '%@'!", _operation, _string];
@ -216,20 +216,20 @@
@implementation XMPPAuthFailedException @implementation XMPPAuthFailedException
@synthesize reason = _reason; @synthesize reason = _reason;
+ (instancetype)exceptionWithConnection: (XMPPConnection*)connection + (instancetype)exceptionWithConnection: (XMPPConnection *)connection
reason: (OFString*)reason; reason: (OFString *)reason;
{ {
return [[[self alloc] initWithConnection: connection return [[[self alloc] initWithConnection: connection
reason: reason] autorelease]; reason: reason] autorelease];
} }
- initWithConnection: (XMPPConnection*)connection - initWithConnection: (XMPPConnection *)connection
{ {
OF_INVALID_INIT_METHOD OF_INVALID_INIT_METHOD
} }
- initWithConnection: (XMPPConnection*)connection - initWithConnection: (XMPPConnection *)connection
reason: (OFString*)reason reason: (OFString *)reason
{ {
self = [super initWithConnection: connection]; self = [super initWithConnection: connection];
@ -250,7 +250,7 @@
[super dealloc]; [super dealloc];
} }
- (OFString*)description - (OFString *)description
{ {
return [OFString stringWithFormat: return [OFString stringWithFormat:
@"Authentication failed. Reason: %@!", _reason]; @"Authentication failed. Reason: %@!", _reason];

View file

@ -24,6 +24,8 @@
#import "XMPPStorage.h" #import "XMPPStorage.h"
OF_ASSUME_NONNULL_BEGIN
@class OFMutableDictionary; @class OFMutableDictionary;
@interface XMPPFileStorage: OFObject <XMPPStorage> @interface XMPPFileStorage: OFObject <XMPPStorage>
@ -32,5 +34,8 @@
OFMutableDictionary *_data; OFMutableDictionary *_data;
} }
- initWithFile: (OFString*)file; - init OF_UNAVAILABLE;
- initWithFile: (OFString *)file;
@end @end
OF_ASSUME_NONNULL_END

View file

@ -40,17 +40,10 @@
@implementation XMPPFileStorage @implementation XMPPFileStorage
- init - init
{ {
@try { OF_INVALID_INIT_METHOD
[self doesNotRecognizeSelector: _cmd];
} @catch (id e) {
[self release];
@throw e;
}
abort();
} }
- initWithFile: (OFString*)file - initWithFile: (OFString *)file
{ {
self = [super init]; self = [super init];
@ -88,7 +81,7 @@
} }
- (void)XMPP_setObject: (id)object - (void)XMPP_setObject: (id)object
forPath: (OFString*)path forPath: (OFString *)path
{ {
OFArray *pathComponents = [path componentsSeparatedByString: @"."]; OFArray *pathComponents = [path componentsSeparatedByString: @"."];
OFMutableDictionary *iter = _data; OFMutableDictionary *iter = _data;
@ -118,21 +111,18 @@
[iter removeObjectForKey: [pathComponents lastObject]]; [iter removeObjectForKey: [pathComponents lastObject]];
} }
- (id)XMPP_objectForPath: (OFString*)path - (id)XMPP_objectForPath: (OFString *)path
{ {
OFArray *pathComponents = [path componentsSeparatedByString: @"."];
OFEnumerator *enumerator = [pathComponents objectEnumerator];
OFString *component;
id object = _data; id object = _data;
while ((component = [enumerator nextObject]) != nil) for (OFString *component in [path componentsSeparatedByString: @"."])
object = [object objectForKey: component]; object = [object objectForKey: component];
return object; return object;
} }
- (void)setStringValue: (OFString*)string - (void)setStringValue: (OFString *)string
forPath: (OFString*)path forPath: (OFString *)path
{ {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
@ -142,7 +132,7 @@
[pool release]; [pool release];
} }
- (OFString*)stringValueForPath: (OFString*)path - (OFString *)stringValueForPath: (OFString *)path
{ {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFString *string; OFString *string;
@ -155,7 +145,7 @@
} }
- (void)setBooleanValue: (bool)boolean - (void)setBooleanValue: (bool)boolean
forPath: (OFString*)path forPath: (OFString *)path
{ {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
@ -165,7 +155,7 @@
[pool release]; [pool release];
} }
- (bool)booleanValueForPath: (OFString*)path - (bool)booleanValueForPath: (OFString *)path
{ {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
bool boolean; bool boolean;
@ -178,7 +168,7 @@
} }
- (void)setIntegerValue: (intmax_t)integer - (void)setIntegerValue: (intmax_t)integer
forPath: (OFString*)path forPath: (OFString *)path
{ {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
@ -188,7 +178,7 @@
[pool release]; [pool release];
} }
- (intmax_t)integerValueForPath: (OFString*)path - (intmax_t)integerValueForPath: (OFString *)path
{ {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
intmax_t integer; intmax_t integer;
@ -200,8 +190,8 @@
return integer; return integer;
} }
- (void)setArray: (OFArray*)array - (void)setArray: (OFArray *)array
forPath: (OFString*)path forPath: (OFString *)path
{ {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
@ -211,7 +201,7 @@
[pool release]; [pool release];
} }
- (OFArray*)arrayForPath: (OFString*)path - (OFArray *)arrayForPath: (OFString *)path
{ {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFArray *array; OFArray *array;
@ -223,8 +213,8 @@
return array; return array;
} }
- (void)setDictionary: (OFDictionary*)dictionary - (void)setDictionary: (OFDictionary *)dictionary
forPath: (OFString*)path forPath: (OFString *)path
{ {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
@ -234,7 +224,7 @@
[pool release]; [pool release];
} }
- (OFDictionary*)dictionaryForPath: (OFString*)path - (OFDictionary *)dictionaryForPath: (OFString *)path
{ {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFDictionary *dictionary; OFDictionary *dictionary;

View file

@ -23,6 +23,8 @@
#import "XMPPStanza.h" #import "XMPPStanza.h"
OF_ASSUME_NONNULL_BEGIN
/** /**
* \brief A class describing an IQ stanza. * \brief A class describing an IQ stanza.
*/ */
@ -34,8 +36,8 @@
* \param ID The value for the stanza's id attribute * \param ID The value for the stanza's id attribute
* \return A new autoreleased XMPPIQ * \return A new autoreleased XMPPIQ
*/ */
+ (instancetype)IQWithType: (OFString*)type + (instancetype)IQWithType: (OFString *)type
ID: (OFString*)ID; ID: (OFString *)ID;
/** /**
* \brief Initializes an already allocated XMPPIQ with the specified type and * \brief Initializes an already allocated XMPPIQ with the specified type and
@ -45,15 +47,15 @@
* \param ID The value for the stanza's id attribute * \param ID The value for the stanza's id attribute
* \return An initialized XMPPIQ * \return An initialized XMPPIQ
*/ */
- initWithType: (OFString*)type - initWithType: (OFString *)type
ID: (OFString*)ID; ID: (OFString *)ID;
/** /**
* \brief Generates a result IQ for the receiving object. * \brief Generates a result IQ for the receiving object.
* *
* \return A new autoreleased XMPPIQ * \return A new autoreleased XMPPIQ
*/ */
- (XMPPIQ*)resultIQ; - (XMPPIQ *)resultIQ;
/** /**
* \brief Generates an error IQ for the receiving object. * \brief Generates an error IQ for the receiving object.
@ -63,9 +65,9 @@
* \param text A descriptive text * \param text A descriptive text
* \return A new autoreleased XMPPIQ * \return A new autoreleased XMPPIQ
*/ */
- (XMPPIQ*)errorIQWithType: (OFString*)type - (XMPPIQ *)errorIQWithType: (OFString *)type
condition: (OFString*)condition condition: (OFString *)condition
text: (OFString*)text; text: (nullable OFString *)text;
/** /**
* \brief Generates an error IQ for the receiving object. * \brief Generates an error IQ for the receiving object.
@ -74,6 +76,8 @@
* \param condition A defined conditions from RFC 6120 * \param condition A defined conditions from RFC 6120
* \return A new autoreleased XMPPIQ * \return A new autoreleased XMPPIQ
*/ */
- (XMPPIQ*)errorIQWithType: (OFString*)type - (XMPPIQ *)errorIQWithType: (OFString *)type
condition: (OFString*)condition; condition: (OFString *)condition;
@end @end
OF_ASSUME_NONNULL_END

View file

@ -29,15 +29,15 @@
#import "XMPPIQ.h" #import "XMPPIQ.h"
@implementation XMPPIQ @implementation XMPPIQ
+ (instancetype)IQWithType: (OFString*)type + (instancetype)IQWithType: (OFString *)type
ID: (OFString*)ID ID: (OFString *)ID
{ {
return [[[self alloc] initWithType: type return [[[self alloc] initWithType: type
ID: ID] autorelease]; ID: ID] autorelease];
} }
- initWithType: (OFString*)type - initWithType: (OFString *)type
ID: (OFString*)ID ID: (OFString *)ID
{ {
self = [super initWithName: @"iq" self = [super initWithName: @"iq"
type: type type: type
@ -55,7 +55,7 @@
return self; return self;
} }
- (XMPPIQ*)resultIQ - (XMPPIQ *)resultIQ
{ {
XMPPIQ *ret = [XMPPIQ IQWithType: @"result" XMPPIQ *ret = [XMPPIQ IQWithType: @"result"
ID: [self ID]]; ID: [self ID]];
@ -64,9 +64,9 @@
return ret; return ret;
} }
- (XMPPIQ*)errorIQWithType: (OFString*)type - (XMPPIQ *)errorIQWithType: (OFString *)type
condition: (OFString*)condition condition: (OFString *)condition
text: (OFString*)text text: (OFString *)text
{ {
XMPPIQ *ret = [XMPPIQ IQWithType: @"error" XMPPIQ *ret = [XMPPIQ IQWithType: @"error"
ID: [self ID]]; ID: [self ID]];
@ -91,8 +91,8 @@
return ret; return ret;
} }
- (XMPPIQ*)errorIQWithType: (OFString*)type - (XMPPIQ *)errorIQWithType: (OFString *)type
condition: (OFString*)condition condition: (OFString *)condition
{ {
return [self errorIQWithType: type return [self errorIQWithType: type
condition: condition condition: condition

View file

@ -23,6 +23,8 @@
#import <ObjFW/ObjFW.h> #import <ObjFW/ObjFW.h>
OF_ASSUME_NONNULL_BEGIN
/** /**
* \brief A class for easy handling of JIDs. * \brief A class for easy handling of JIDs.
*/ */
@ -32,11 +34,11 @@
} }
/// \brief The JID's localpart /// \brief The JID's localpart
@property (copy) OFString *node; @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *node;
/// \brief The JID's domainpart /// \brief The JID's domainpart
@property (copy) OFString *domain; @property (nonatomic, copy) OFString *domain;
/// \brief The JID's resourcepart /// \brief The JID's resourcepart
@property (copy) OFString *resource; @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *resource;
/** /**
* \brief Creates a new autoreleased XMPPJID. * \brief Creates a new autoreleased XMPPJID.
@ -51,7 +53,7 @@
* \param string The string to parse into a JID object * \param string The string to parse into a JID object
* \return A new autoreleased XMPPJID * \return A new autoreleased XMPPJID
*/ */
+ (instancetype)JIDWithString: (OFString*)string; + (instancetype)JIDWithString: (OFString *)string;
/** /**
* \brief Initializes an already allocated XMPPJID with a string. * \brief Initializes an already allocated XMPPJID with a string.
@ -59,19 +61,21 @@
* \param string The string to parse into a JID object * \param string The string to parse into a JID object
* \return A initialized XMPPJID * \return A initialized XMPPJID
*/ */
- initWithString: (OFString*)string; - initWithString: (OFString *)string;
/** /**
* \brief Returns the bare JID. * \brief Returns the bare JID.
* *
* \return An OFString containing the bare JID * \return An OFString containing the bare JID
*/ */
- (OFString*)bareJID; - (OFString *)bareJID;
/** /**
* \brief Returns the full JID. * \brief Returns the full JID.
* *
* \return An OFString containing the full JID * \return An OFString containing the full JID
*/ */
- (OFString*)fullJID; - (OFString *)fullJID;
@end @end
OF_ASSUME_NONNULL_END

View file

@ -33,17 +33,19 @@
#import "XMPPExceptions.h" #import "XMPPExceptions.h"
@implementation XMPPJID @implementation XMPPJID
@synthesize node = _node, domain = _domain, resource = _resource;
+ (instancetype)JID + (instancetype)JID
{ {
return [[[self alloc] init] autorelease]; return [[[self alloc] init] autorelease];
} }
+ (instancetype)JIDWithString: (OFString*)string + (instancetype)JIDWithString: (OFString *)string
{ {
return [[[self alloc] initWithString: string] autorelease]; return [[[self alloc] initWithString: string] autorelease];
} }
- initWithString: (OFString*)string - initWithString: (OFString *)string
{ {
size_t nodesep, resourcesep; size_t nodesep, resourcesep;
@ -103,7 +105,7 @@
return new; return new;
} }
- (void)setNode: (OFString*)node - (void)setNode: (OFString *)node
{ {
OFString *old = _node; OFString *old = _node;
char *nodepart; char *nodepart;
@ -132,12 +134,7 @@
[old release]; [old release];
} }
- (OFString*)node - (void)setDomain: (OFString *)domain
{
return [[_node copy] autorelease];
}
- (void)setDomain: (OFString*)domain
{ {
OFString *old = _domain; OFString *old = _domain;
char *srv; char *srv;
@ -160,12 +157,7 @@
[old release]; [old release];
} }
- (OFString*)domain - (void)setResource: (OFString *)resource
{
return [[_domain copy] autorelease];
}
- (void)setResource: (OFString*)resource
{ {
OFString *old = _resource; OFString *old = _resource;
char *res; char *res;
@ -194,12 +186,7 @@
[old release]; [old release];
} }
- (OFString*)resource - (OFString *)bareJID
{
return [[_resource copy] autorelease];
}
- (OFString*)bareJID
{ {
if (_node != nil) if (_node != nil)
return [OFString stringWithFormat: @"%@@%@", _node, _domain]; return [OFString stringWithFormat: @"%@@%@", _node, _domain];
@ -207,7 +194,7 @@
return [OFString stringWithFormat: @"%@", _domain]; return [OFString stringWithFormat: @"%@", _domain];
} }
- (OFString*)fullJID - (OFString *)fullJID
{ {
/* If we don't have a resource, the full JID is equal to the bare JID */ /* If we don't have a resource, the full JID is equal to the bare JID */
if (_resource == nil) if (_resource == nil)
@ -221,7 +208,7 @@
_domain, _resource]; _domain, _resource];
} }
- (OFString*)description - (OFString *)description
{ {
return [self fullJID]; return [self fullJID];
} }

View file

@ -23,6 +23,8 @@
#import "XMPPStanza.h" #import "XMPPStanza.h"
OF_ASSUME_NONNULL_BEGIN
/** /**
* \brief A class describing a message stanza. * \brief A class describing a message stanza.
*/ */
@ -43,7 +45,7 @@
* \param ID The value for the stanza's id attribute * \param ID The value for the stanza's id attribute
* \return A new autoreleased XMPPMessage * \return A new autoreleased XMPPMessage
*/ */
+ (instancetype)messageWithID: (OFString*)ID; + (instancetype)messageWithID: (nullable OFString *)ID;
/** /**
* \brief Creates a new autoreleased XMPPMessage with the specified type. * \brief Creates a new autoreleased XMPPMessage with the specified type.
@ -51,7 +53,7 @@
* \param type The value for the stanza's type attribute * \param type The value for the stanza's type attribute
* \return A new autoreleased XMPPMessage * \return A new autoreleased XMPPMessage
*/ */
+ (instancetype)messageWithType: (OFString*)type; + (instancetype)messageWithType: (nullable OFString *)type;
/** /**
* \brief Creates a new autoreleased XMPPMessage with the specified type and ID. * \brief Creates a new autoreleased XMPPMessage with the specified type and ID.
@ -60,8 +62,8 @@
* \param ID The value for the stanza's id attribute * \param ID The value for the stanza's id attribute
* \return A new autoreleased XMPPMessage * \return A new autoreleased XMPPMessage
*/ */
+ (instancetype)messageWithType: (OFString*)type + (instancetype)messageWithType: (nullable OFString *)type
ID: (OFString*)ID; ID: (nullable OFString *)ID;
/** /**
* \brief Initializes an already allocated XMPPMessage with the specified ID. * \brief Initializes an already allocated XMPPMessage with the specified ID.
@ -69,7 +71,7 @@
* \param ID The value for the stanza's id attribute * \param ID The value for the stanza's id attribute
* \return A initialized XMPPMessage * \return A initialized XMPPMessage
*/ */
- initWithID: (OFString*)ID; - initWithID: (nullable OFString *)ID;
/** /**
* \brief Initializes an already allocated XMPPMessage with the specified type. * \brief Initializes an already allocated XMPPMessage with the specified type.
@ -77,7 +79,7 @@
* \param type The value for the stanza's type attribute * \param type The value for the stanza's type attribute
* \return A initialized XMPPMessage * \return A initialized XMPPMessage
*/ */
- initWithType: (OFString*)type; - initWithType: (nullable OFString *)type;
/** /**
* \brief Initializes an already allocated XMPPMessage with the specified type * \brief Initializes an already allocated XMPPMessage with the specified type
@ -87,6 +89,8 @@
* \param ID The value for the stanza's id attribute * \param ID The value for the stanza's id attribute
* \return A initialized XMPPMessage * \return A initialized XMPPMessage
*/ */
- initWithType: (OFString*)type - initWithType: (nullable OFString *)type
ID: (OFString*)ID; ID: (nullable OFString *)ID OF_DESIGNATED_INITIALIZER;
@end @end
OF_ASSUME_NONNULL_END

View file

@ -34,18 +34,18 @@
return [[[self alloc] init] autorelease]; return [[[self alloc] init] autorelease];
} }
+ (instancetype)messageWithID: (OFString*)ID + (instancetype)messageWithID: (OFString *)ID
{ {
return [[[self alloc] initWithID: ID] autorelease]; return [[[self alloc] initWithID: ID] autorelease];
} }
+ (instancetype)messageWithType: (OFString*)type + (instancetype)messageWithType: (OFString *)type
{ {
return [[[self alloc] initWithType: type] autorelease]; return [[[self alloc] initWithType: type] autorelease];
} }
+ (instancetype)messageWithType: (OFString*)type + (instancetype)messageWithType: (OFString *)type
ID: (OFString*)ID ID: (OFString *)ID
{ {
return [[[self alloc] initWithType: type return [[[self alloc] initWithType: type
ID: ID] autorelease]; ID: ID] autorelease];
@ -57,27 +57,27 @@
ID: nil]; ID: nil];
} }
- initWithID: (OFString*)ID - initWithID: (OFString *)ID
{ {
return [self initWithType: nil return [self initWithType: nil
ID: ID]; ID: ID];
} }
- initWithType: (OFString*)type - initWithType: (OFString *)type
{ {
return [self initWithType: type return [self initWithType: type
ID: nil]; ID: nil];
} }
- initWithType: (OFString*)type - initWithType: (OFString *)type
ID: (OFString*)ID ID: (OFString *)ID
{ {
return [super initWithName: @"message" return [super initWithName: @"message"
type: type type: type
ID: ID]; ID: ID];
} }
- (void)setBody: (OFString*)body - (void)setBody: (OFString *)body
{ {
OFXMLElement *oldBody = [self elementForName: @"body" OFXMLElement *oldBody = [self elementForName: @"body"
namespace: XMPP_NS_CLIENT]; namespace: XMPP_NS_CLIENT];
@ -91,7 +91,7 @@
stringValue: body]]; stringValue: body]];
} }
- (OFString*)body - (OFString *)body
{ {
return [[self elementForName: @"body" return [[self elementForName: @"body"
namespace: XMPP_NS_CLIENT] stringValue]; namespace: XMPP_NS_CLIENT] stringValue];

View file

@ -22,6 +22,8 @@
#import <ObjFW/OFObject.h> #import <ObjFW/OFObject.h>
OF_ASSUME_NONNULL_BEGIN
@class OFDataArray; @class OFDataArray;
/** /**
@ -53,7 +55,7 @@
* \param object The object to broadcast * \param object The object to broadcast
*/ */
- (bool)broadcastSelector: (SEL)selector - (bool)broadcastSelector: (SEL)selector
withObject: (id)object; withObject: (nullable id)object;
/** /**
* \brief Broadcasts a selector with two objects to all registered delegates. * \brief Broadcasts a selector with two objects to all registered delegates.
@ -63,6 +65,8 @@
* \param object2 The second object to broadcast * \param object2 The second object to broadcast
*/ */
- (bool)broadcastSelector: (SEL)selector - (bool)broadcastSelector: (SEL)selector
withObject: (id)object1 withObject: (nullable id)object1
withObject: (id)object2; withObject: (nullable id)object2;
@end @end
OF_ASSUME_NONNULL_END

View file

@ -23,6 +23,8 @@
#import <ObjFW/ObjFW.h> #import <ObjFW/ObjFW.h>
#import "XMPPAuthenticator.h" #import "XMPPAuthenticator.h"
OF_ASSUME_NONNULL_BEGIN
/** /**
* \brief A class to authenticate using SASL PLAIN * \brief A class to authenticate using SASL PLAIN
*/ */
@ -34,8 +36,8 @@
* \param password The password to authenticate with * \param password The password to authenticate with
* \return A new autoreleased XMPPPLAINAuth * \return A new autoreleased XMPPPLAINAuth
*/ */
+ (instancetype)PLAINAuthWithAuthcid: (OFString*)authcid + (instancetype)PLAINAuthWithAuthcid: (nullable OFString *)authcid
password: (OFString*)password; password: (nullable OFString *)password;
/** /**
* \brief Creates a new autoreleased XMPPPLAINAuth with an authzid, authcid and * \brief Creates a new autoreleased XMPPPLAINAuth with an authzid, authcid and
@ -46,7 +48,9 @@
* \param password The password to authenticate with * \param password The password to authenticate with
* \return A new autoreleased XMPPPLAINAuth * \return A new autoreleased XMPPPLAINAuth
*/ */
+ (instancetype)PLAINAuthWithAuthzid: (OFString*)authzid + (instancetype)PLAINAuthWithAuthzid: (nullable OFString *)authzid
authcid: (OFString*)authcid authcid: (nullable OFString *)authcid
password: (OFString*)password; password: (nullable OFString *)password;
@end @end
OF_ASSUME_NONNULL_END

View file

@ -28,23 +28,23 @@
#import "XMPPExceptions.h" #import "XMPPExceptions.h"
@implementation XMPPPLAINAuth @implementation XMPPPLAINAuth
+ (instancetype)PLAINAuthWithAuthcid: (OFString*)authcid + (instancetype)PLAINAuthWithAuthcid: (OFString *)authcid
password: (OFString*)password password: (OFString *)password
{ {
return [[[self alloc] initWithAuthcid: authcid return [[[self alloc] initWithAuthcid: authcid
password: password] autorelease]; password: password] autorelease];
} }
+ (instancetype)PLAINAuthWithAuthzid: (OFString*)authzid + (instancetype)PLAINAuthWithAuthzid: (OFString *)authzid
authcid: (OFString*)authcid authcid: (OFString *)authcid
password: (OFString*)password password: (OFString *)password
{ {
return [[[self alloc] initWithAuthzid: authzid return [[[self alloc] initWithAuthzid: authzid
authcid: authcid authcid: authcid
password: password] autorelease]; password: password] autorelease];
} }
- (OFDataArray*)initialMessage - (OFDataArray *)initialMessage
{ {
OFDataArray *message = [OFDataArray dataArray]; OFDataArray *message = [OFDataArray dataArray];

View file

@ -23,6 +23,8 @@
#import "XMPPStanza.h" #import "XMPPStanza.h"
OF_ASSUME_NONNULL_BEGIN
/** /**
* \brief A class describing a presence stanza. * \brief A class describing a presence stanza.
*/ */
@ -32,20 +34,25 @@
OFNumber *_priority; 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. * The text content of the status element.
*/ */
@property (copy) OFString *status; @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *status;
/** /**
* The text content of the show element of the presence stanza. * The text content of the show element of the presence stanza.
*/ */
@property (copy) OFString *show; @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *show;
/** /**
* The numeric content of the priority element. * The numeric content of the priority element.
*/ */
@property (copy) OFNumber *priority; @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFNumber *priority;
/** /**
* \brief Creates a new autoreleased XMPPPresence. * \brief Creates a new autoreleased XMPPPresence.
@ -60,7 +67,7 @@
* \param ID The value for the stanza's id attribute * \param ID The value for the stanza's id attribute
* \return A new autoreleased XMPPPresence * \return A new autoreleased XMPPPresence
*/ */
+ (instancetype)presenceWithID: (OFString*)ID; + (instancetype)presenceWithID: (nullable OFString *)ID;
/** /**
* \brief Creates a new autoreleased XMPPPresence with the specified type. * \brief Creates a new autoreleased XMPPPresence with the specified type.
@ -68,7 +75,7 @@
* \param type The value for the stanza's type attribute * \param type The value for the stanza's type attribute
* \return A new autoreleased XMPPPresence * \return A new autoreleased XMPPPresence
*/ */
+ (instancetype)presenceWithType: (OFString*)type; + (instancetype)presenceWithType: (nullable OFString *)type;
/** /**
* \brief Creates a new autoreleased XMPPPresence with the specified type and * \brief Creates a new autoreleased XMPPPresence with the specified type and
@ -78,8 +85,8 @@
* \param ID The value for the stanza's id attribute * \param ID The value for the stanza's id attribute
* \return A new autoreleased XMPPPresence * \return A new autoreleased XMPPPresence
*/ */
+ (instancetype)presenceWithType: (OFString*)type + (instancetype)presenceWithType: (nullable OFString *)type
ID: (OFString*)ID; ID: (nullable OFString *)ID;
/** /**
* \brief Initializes an already allocated XMPPPresence with the specified ID. * \brief Initializes an already allocated XMPPPresence with the specified ID.
@ -87,7 +94,7 @@
* \param ID The value for the stanza's id attribute * \param ID The value for the stanza's id attribute
* \return A initialized XMPPPresence * \return A initialized XMPPPresence
*/ */
- initWithID: (OFString*)ID; - initWithID: (nullable OFString *)ID;
/** /**
* \brief Initializes an already allocated XMPPPresence with the specified type. * \brief Initializes an already allocated XMPPPresence with the specified type.
@ -95,7 +102,7 @@
* \param type The value for the stanza's type attribute * \param type The value for the stanza's type attribute
* \return A initialized XMPPPresence * \return A initialized XMPPPresence
*/ */
- initWithType: (OFString*)type; - initWithType: (nullable OFString *)type;
/** /**
* \brief Initializes an already allocated XMPPPresence with the specified type * \brief Initializes an already allocated XMPPPresence with the specified type
@ -105,6 +112,8 @@
* \param ID The value for the stanza's id attribute * \param ID The value for the stanza's id attribute
* \return A initialized XMPPPresence * \return A initialized XMPPPresence
*/ */
- initWithType: (OFString*)type - initWithType: (nullable OFString *)type
ID: (OFString*)ID; ID: (nullable OFString *)ID;
@end @end
OF_ASSUME_NONNULL_END

View file

@ -49,23 +49,25 @@ show_to_int(OFString *show)
} }
@implementation XMPPPresence @implementation XMPPPresence
@dynamic type;
+ (instancetype)presence + (instancetype)presence
{ {
return [[[self alloc] init] autorelease]; return [[[self alloc] init] autorelease];
} }
+ (instancetype)presenceWithID: (OFString*)ID + (instancetype)presenceWithID: (OFString *)ID
{ {
return [[[self alloc] initWithID: ID] autorelease]; return [[[self alloc] initWithID: ID] autorelease];
} }
+ (instancetype)presenceWithType: (OFString*)type + (instancetype)presenceWithType: (OFString *)type
{ {
return [[[self alloc] initWithType: type] autorelease]; return [[[self alloc] initWithType: type] autorelease];
} }
+ (instancetype)presenceWithType: (OFString*)type + (instancetype)presenceWithType: (OFString *)type
ID: (OFString*)ID ID: (OFString *)ID
{ {
return [[[self alloc] initWithType: type return [[[self alloc] initWithType: type
ID: ID] autorelease]; ID: ID] autorelease];
@ -77,27 +79,27 @@ show_to_int(OFString *show)
ID: nil]; ID: nil];
} }
- initWithID: (OFString*)ID - initWithID: (OFString *)ID
{ {
return [self initWithType: nil return [self initWithType: nil
ID: ID]; ID: ID];
} }
- initWithType: (OFString*)type - initWithType: (OFString *)type
{ {
return [self initWithType: type return [self initWithType: type
ID: nil]; ID: nil];
} }
- initWithType: (OFString*)type - initWithType: (OFString *)type
ID: (OFString*)ID ID: (OFString *)ID
{ {
return [super initWithName: @"presence" return [super initWithName: @"presence"
type: type type: type
ID: ID]; ID: ID];
} }
- initWithElement: (OFXMLElement*)element - initWithElement: (OFXMLElement *)element
{ {
self = [super initWithElement: element]; self = [super initWithElement: element];
@ -135,15 +137,15 @@ show_to_int(OFString *show)
[super dealloc]; [super dealloc];
} }
- (OFString*)type - (void)setType: (OFString *)type
{ {
if (_type == nil) if (type == nil)
return @"available"; type = @"available";
return [[_type copy] autorelease]; [super setType: type];
} }
- (void)setShow: (OFString*)show - (void)setShow: (OFString *)show
{ {
OFXMLElement *oldShow = [self elementForName: @"show" OFXMLElement *oldShow = [self elementForName: @"show"
namespace: XMPP_NS_CLIENT]; namespace: XMPP_NS_CLIENT];
@ -162,12 +164,7 @@ show_to_int(OFString *show)
[old release]; [old release];
} }
- (OFString*)show - (void)setStatus: (OFString *)status
{
return [[_show copy] autorelease];
}
- (void)setStatus: (OFString*)status
{ {
OFXMLElement *oldStatus = [self elementForName: @"status" OFXMLElement *oldStatus = [self elementForName: @"status"
namespace: XMPP_NS_CLIENT]; namespace: XMPP_NS_CLIENT];
@ -186,12 +183,7 @@ show_to_int(OFString *show)
[old release]; [old release];
} }
- (OFString*)status - (void)setPriority: (OFNumber *)priority
{
return [[_status copy] autorelease];
}
- (void)setPriority: (OFNumber*)priority
{ {
intmax_t prio = [priority intMaxValue]; intmax_t prio = [priority intMaxValue];
OFNumber *old; OFNumber *old;
@ -205,7 +197,7 @@ show_to_int(OFString *show)
if (oldPriority != nil) if (oldPriority != nil)
[self removeChild: oldPriority]; [self removeChild: oldPriority];
OFString* priority_s = OFString *priority_s =
[OFString stringWithFormat: @"%" @PRId8, [priority int8Value]]; [OFString stringWithFormat: @"%" @PRId8, [priority int8Value]];
[self addChild: [OFXMLElement elementWithName: @"priority" [self addChild: [OFXMLElement elementWithName: @"priority"
namespace: XMPP_NS_CLIENT namespace: XMPP_NS_CLIENT
@ -216,11 +208,6 @@ show_to_int(OFString *show)
[old release]; [old release];
} }
- (OFNumber*)priority
{
return [[_priority copy] autorelease];
}
- (of_comparison_result_t)compare: (id <OFComparing>)object - (of_comparison_result_t)compare: (id <OFComparing>)object
{ {
XMPPPresence *otherPresence; XMPPPresence *otherPresence;
@ -234,7 +221,7 @@ show_to_int(OFString *show)
if (![object isKindOfClass: [XMPPPresence class]]) if (![object isKindOfClass: [XMPPPresence class]])
@throw [OFInvalidArgumentException exception]; @throw [OFInvalidArgumentException exception];
otherPresence = (XMPPPresence*)object; otherPresence = (XMPPPresence *)object;
otherPriority = [otherPresence priority]; otherPriority = [otherPresence priority];
if (otherPriority == nil) if (otherPriority == nil)
otherPriority = [OFNumber numberWithInt8: 0]; otherPriority = [OFNumber numberWithInt8: 0];

View file

@ -26,6 +26,8 @@
#import "XMPPConnection.h" #import "XMPPConnection.h"
#import "XMPPStorage.h" #import "XMPPStorage.h"
OF_ASSUME_NONNULL_BEGIN
@class XMPPRosterItem; @class XMPPRosterItem;
@class XMPPIQ; @class XMPPIQ;
@class XMPPRoster; @class XMPPRoster;
@ -36,9 +38,6 @@
* of a XMPPRoster * of a XMPPRoster
*/ */
@protocol XMPPRosterDelegate @protocol XMPPRosterDelegate
#ifndef XMPP_ROSTER_M
<OFObject>
#endif
@optional @optional
/** /**
* \brief This callback is called after the roster was received (as a result of * \brief This callback is called after the roster was received (as a result of
@ -46,7 +45,7 @@
* *
* \param roster The roster that was received * \param roster The roster that was received
*/ */
- (void)rosterWasReceived: (XMPPRoster*)roster; - (void)rosterWasReceived: (XMPPRoster *)roster;
/** /**
* \brief This callback is called whenever a roster push was received. * \brief This callback is called whenever a roster push was received.
@ -54,8 +53,8 @@
* \param roster The roster that was updated by the roster push * \param roster The roster that was updated by the roster push
* \param rosterItem The roster item received in the push * \param rosterItem The roster item received in the push
*/ */
- (void)roster: (XMPPRoster*)roster - (void)roster: (XMPPRoster *)roster
didReceiveRosterItem: (XMPPRosterItem*)rosterItem; didReceiveRosterItem: (XMPPRosterItem *)rosterItem;
@end @end
/** /**
@ -80,22 +79,25 @@
* *
* Inherited from the connection if not overridden. * Inherited from the connection if not overridden.
*/ */
@property (assign) id <XMPPStorage> dataStorage; @property (nonatomic, assign) id <XMPPStorage> dataStorage;
/** /**
* \brief The list of contacts as an OFDictionary with the bare JID as a string * \brief The list of contacts as an OFDictionary with the bare JID as a string
* as key. * as key.
*/ */
@property (readonly, copy) OFDictionary *rosterItems; @property (readonly, nonatomic)
OFDictionary OF_GENERIC(OFString *, XMPPRosterItem *) *rosterItems;
- init OF_UNAVAILABLE;
/** /**
* \brief Initializes an already allocated XMPPRoster. * \brief Initializes an already allocated XMPPRoster.
* *
* \param connection The connection roster related stanzas * \param connection The connection roster related stanzas are send and
* are send and received over * received over
* \return An initialized XMPPRoster * \return An initialized XMPPRoster
*/ */
- initWithConnection: (XMPPConnection*)connection; - initWithConnection: (XMPPConnection *)connection OF_DESIGNATED_INITIALIZER;
/** /**
* \brief Requests the roster from the server. * \brief Requests the roster from the server.
@ -107,21 +109,21 @@
* *
* \param rosterItem The roster item to add to the roster * \param rosterItem The roster item to add to the roster
*/ */
- (void)addRosterItem: (XMPPRosterItem*)rosterItem; - (void)addRosterItem: (XMPPRosterItem *)rosterItem;
/** /**
* \brief Updates an already existing contact in the roster. * \brief Updates an already existing contact in the roster.
* *
* \param rosterItem The roster item to update * \param rosterItem The roster item to update
*/ */
- (void)updateRosterItem: (XMPPRosterItem*)rosterItem; - (void)updateRosterItem: (XMPPRosterItem *)rosterItem;
/** /**
* \brief Delete a contact from the roster. * \brief Delete a contact from the roster.
* *
* \param rosterItem The roster item to delete * \param rosterItem The roster item to delete
*/ */
- (void)deleteRosterItem: (XMPPRosterItem*)rosterItem; - (void)deleteRosterItem: (XMPPRosterItem *)rosterItem;
/** /**
* \brief Adds the specified delegate. * \brief Adds the specified delegate.
@ -136,12 +138,6 @@
* \param delegate The delegate to remove * \param delegate The delegate to remove
*/ */
- (void)removeDelegate: (id <XMPPRosterDelegate>)delegate; - (void)removeDelegate: (id <XMPPRosterDelegate>)delegate;
- (void)XMPP_updateRosterItem: (XMPPRosterItem*)rosterItem;
- (void)XMPP_handleInitialRosterForConnection: (XMPPConnection*)connection
IQ: (XMPPIQ*)iq;
- (XMPPRosterItem*)XMPP_rosterItemWithXMLElement: (OFXMLElement*)element;
@end @end
@interface OFObject (XMPPRosterDelegate) <XMPPRosterDelegate> OF_ASSUME_NONNULL_END
@end

View file

@ -39,11 +39,27 @@
#import "XMPPMulticastDelegate.h" #import "XMPPMulticastDelegate.h"
#import "namespaces.h" #import "namespaces.h"
OF_ASSUME_NONNULL_BEGIN
@interface XMPPRoster ()
- (void)XMPP_updateRosterItem: (XMPPRosterItem *)rosterItem;
- (void)XMPP_handleInitialRosterForConnection: (XMPPConnection *)connection
IQ: (XMPPIQ *)IQ;
- (XMPPRosterItem *)XMPP_rosterItemWithXMLElement: (OFXMLElement *)element;
@end
OF_ASSUME_NONNULL_END
@implementation XMPPRoster @implementation XMPPRoster
@synthesize connection = _connection, dataStorage = _dataStorage; @synthesize connection = _connection, dataStorage = _dataStorage;
@synthesize rosterItems = _rosterItems; @synthesize rosterItems = _rosterItems;
- initWithConnection: (XMPPConnection*)connection - init
{
OF_INVALID_INIT_METHOD
}
- initWithConnection: (XMPPConnection *)connection
{ {
self = [super init]; self = [super init];
@ -102,25 +118,25 @@
IQ:)]; IQ:)];
} }
- (bool)connection: (XMPPConnection*)connection - (bool)connection: (XMPPConnection *)connection
didReceiveIQ: (XMPPIQ*)iq didReceiveIQ: (XMPPIQ *)IQ
{ {
OFXMLElement *rosterElement; OFXMLElement *rosterElement;
OFXMLElement *element; OFXMLElement *element;
XMPPRosterItem *rosterItem; XMPPRosterItem *rosterItem;
OFString *origin; OFString *origin;
rosterElement = [iq elementForName: @"query" rosterElement = [IQ elementForName: @"query"
namespace: XMPP_NS_ROSTER]; namespace: XMPP_NS_ROSTER];
if (rosterElement == nil) if (rosterElement == nil)
return false; return false;
if (![[iq type] isEqual: @"set"]) if (![[IQ type] isEqual: @"set"])
return false; return false;
// Ensure the roster push has been sent by the server // Ensure the roster push has been sent by the server
origin = [[iq from] fullJID]; origin = [[IQ from] fullJID];
if (origin != nil && ![origin isEqual: [[connection JID] bareJID]]) if (origin != nil && ![origin isEqual: [[connection JID] bareJID]])
return false; return false;
@ -146,17 +162,17 @@
[_dataStorage save]; [_dataStorage save];
} }
[connection sendStanza: [iq resultIQ]]; [connection sendStanza: [IQ resultIQ]];
return true; return true;
} }
- (void)addRosterItem: (XMPPRosterItem*)rosterItem - (void)addRosterItem: (XMPPRosterItem *)rosterItem
{ {
[self updateRosterItem: rosterItem]; [self updateRosterItem: rosterItem];
} }
- (void)updateRosterItem: (XMPPRosterItem*)rosterItem - (void)updateRosterItem: (XMPPRosterItem *)rosterItem
{ {
XMPPIQ *IQ = [XMPPIQ IQWithType: @"set" XMPPIQ *IQ = [XMPPIQ IQWithType: @"set"
ID: [_connection generateStanzaID]]; ID: [_connection generateStanzaID]];
@ -185,7 +201,7 @@
[_connection sendStanza: IQ]; [_connection sendStanza: IQ];
} }
- (void)deleteRosterItem: (XMPPRosterItem*)rosterItem - (void)deleteRosterItem: (XMPPRosterItem *)rosterItem
{ {
XMPPIQ *IQ = [XMPPIQ IQWithType: @"set" XMPPIQ *IQ = [XMPPIQ IQWithType: @"set"
ID: [_connection generateStanzaID]]; ID: [_connection generateStanzaID]];
@ -224,17 +240,7 @@
_dataStorage = dataStorage; _dataStorage = dataStorage;
} }
- (XMPPConnection*)connection - (void)XMPP_updateRosterItem: (XMPPRosterItem *)rosterItem
{
return _connection;
}
- (id <XMPPStorage>)dataStorage
{
return _dataStorage;
}
- (void)XMPP_updateRosterItem: (XMPPRosterItem*)rosterItem
{ {
if ([_connection supportsRosterVersioning]) { if ([_connection supportsRosterVersioning]) {
OFMutableDictionary *items = [[[_dataStorage dictionaryForPath: OFMutableDictionary *items = [[[_dataStorage dictionaryForPath:
@ -274,7 +280,7 @@
[_rosterItems removeObjectForKey: [[rosterItem JID] bareJID]]; [_rosterItems removeObjectForKey: [[rosterItem JID] bareJID]];
} }
- (XMPPRosterItem*)XMPP_rosterItemWithXMLElement: (OFXMLElement*)element - (XMPPRosterItem *)XMPP_rosterItemWithXMLElement: (OFXMLElement *)element
{ {
OFString *subscription; OFString *subscription;
OFEnumerator *groupEnumerator; OFEnumerator *groupEnumerator;
@ -310,14 +316,10 @@
return rosterItem; return rosterItem;
} }
- (void)XMPP_handleInitialRosterForConnection: (XMPPConnection*)connection - (void)XMPP_handleInitialRosterForConnection: (XMPPConnection *)connection
IQ: (XMPPIQ*)IQ IQ: (XMPPIQ *)IQ
{ {
OFXMLElement *rosterElement; OFXMLElement *rosterElement = [IQ elementForName: @"query"
OFEnumerator *enumerator;
OFXMLElement *element;
rosterElement = [IQ elementForName: @"query"
namespace: XMPP_NS_ROSTER]; namespace: XMPP_NS_ROSTER];
if ([connection supportsRosterVersioning]) { if ([connection supportsRosterVersioning]) {
@ -350,8 +352,7 @@
forPath: @"roster.items"]; forPath: @"roster.items"];
} }
enumerator = [[rosterElement children] objectEnumerator]; for (OFXMLElement *element in [rosterElement children]) {
while ((element = [enumerator nextObject]) != nil) {
OFAutoreleasePool *pool; OFAutoreleasePool *pool;
XMPPRosterItem *rosterItem; XMPPRosterItem *rosterItem;

View file

@ -23,6 +23,8 @@
#import <ObjFW/ObjFW.h> #import <ObjFW/ObjFW.h>
OF_ASSUME_NONNULL_BEGIN
@class XMPPJID; @class XMPPJID;
/** /**
@ -37,13 +39,13 @@
} }
/// \brief The JID of the roster item /// \brief The JID of the roster item
@property (copy) XMPPJID *JID; @property (nonatomic, copy) XMPPJID *JID;
/// \brief The name of the roster item to show to the user /// \brief The name of the roster item to show to the user
@property (copy) OFString *name; @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *name;
/// \brief The subscription for the roster item /// \brief The subscription for the roster item
@property (copy) OFString *subscription; @property (nonatomic, copy) OFString *subscription;
/// \brief An array of groups in which the roster item is /// \brief An array of groups in which the roster item is
@property (copy) OFArray *groups; @property (nonatomic, copy) OFArray OF_GENERIC(OFString *) *groups;
/** /**
* \brief Creates a new autoreleased roster item. * \brief Creates a new autoreleased roster item.
@ -52,3 +54,5 @@
*/ */
+ (instancetype)rosterItem; + (instancetype)rosterItem;
@end @end
OF_ASSUME_NONNULL_END

View file

@ -66,7 +66,7 @@
return new; return new;
} }
- (OFString*)description - (OFString *)description
{ {
return [OFString stringWithFormat: @"<XMPPRosterItem, JID=%@, name=%@, " return [OFString stringWithFormat: @"<XMPPRosterItem, JID=%@, name=%@, "
@"subscription=%@, groups=%@>", @"subscription=%@, groups=%@>",

View file

@ -24,6 +24,8 @@
#import "XMPPAuthenticator.h" #import "XMPPAuthenticator.h"
#import "XMPPConnection.h" #import "XMPPConnection.h"
OF_ASSUME_NONNULL_BEGIN
/** /**
* \brief A class to authenticate using SCRAM * \brief A class to authenticate using SCRAM
*/ */
@ -49,9 +51,9 @@
* \param plusAvailable Whether the PLUS variant was offered * \param plusAvailable Whether the PLUS variant was offered
* \return A new autoreleased XMPPSCRAMAuth * \return A new autoreleased XMPPSCRAMAuth
*/ */
+ (instancetype)SCRAMAuthWithAuthcid: (OFString*)authcid + (instancetype)SCRAMAuthWithAuthcid: (nullable OFString *)authcid
password: (OFString*)password password: (nullable OFString *)password
connection: (XMPPConnection*)connection connection: (XMPPConnection *)connection
hash: (Class)hash hash: (Class)hash
plusAvailable: (bool)plusAvailable; plusAvailable: (bool)plusAvailable;
@ -67,13 +69,19 @@
* \param plusAvailable Whether the PLUS variant was offered * \param plusAvailable Whether the PLUS variant was offered
* \return A new autoreleased XMPPSCRAMAuth * \return A new autoreleased XMPPSCRAMAuth
*/ */
+ (instancetype)SCRAMAuthWithAuthzid: (OFString*)authzid + (instancetype)SCRAMAuthWithAuthzid: (nullable OFString *)authzid
authcid: (OFString*)authcid authcid: (nullable OFString *)authcid
password: (OFString*)password password: (nullable OFString *)password
connection: (XMPPConnection*)connection connection: (XMPPConnection *)connection
hash: (Class)hash hash: (Class)hash
plusAvailable: (bool)plusAvailable; 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 * \brief Initializes an already allocated XMPPSCRAMAuth with an authcid and
* password. * password.
@ -85,9 +93,9 @@
* \param plusAvailable Whether the PLUS variant was offered * \param plusAvailable Whether the PLUS variant was offered
* \return A initialized XMPPSCRAMAuth * \return A initialized XMPPSCRAMAuth
*/ */
- initWithAuthcid: (OFString*)authcid - initWithAuthcid: (nullable OFString *)authcid
password: (OFString*)password password: (nullable OFString *)password
connection: (XMPPConnection*)connection connection: (XMPPConnection *)connection
hash: (Class)hash hash: (Class)hash
plusAvailable: (bool)plusAvailable; plusAvailable: (bool)plusAvailable;
@ -103,21 +111,12 @@
* \param plusAvailable Whether the PLUS variant was offered * \param plusAvailable Whether the PLUS variant was offered
* \return A initialized XMPPSCRAMAuth * \return A initialized XMPPSCRAMAuth
*/ */
- initWithAuthzid: (OFString*)authzid - initWithAuthzid: (nullable OFString *)authzid
authcid: (OFString*)authcid authcid: (nullable OFString *)authcid
password: (OFString*)password password: (nullable OFString *)password
connection: (XMPPConnection*)connection connection: (XMPPConnection *)connection
hash: (Class)hash hash: (Class)hash
plusAvailable: (bool)plusAvailable; plusAvailable: (bool)plusAvailable OF_DESIGNATED_INITIALIZER;
/// \cond internal
- (OFString*)XMPP_genNonce;
- (const uint8_t*)XMPP_HMACWithKey: (OFDataArray*)key
data: (OFDataArray*)data;
- (OFDataArray*)XMPP_hiWithData: (OFDataArray*)str
salt: (OFDataArray*)salt
iterationCount: (intmax_t)i;
- (OFDataArray*)XMPP_parseServerFirstMessage: (OFDataArray*)data;
- (OFDataArray*)XMPP_parseServerFinalMessage: (OFDataArray*)data;
/// \endcond
@end @end
OF_ASSUME_NONNULL_END

View file

@ -37,10 +37,25 @@
#define HMAC_IPAD 0x36 #define HMAC_IPAD 0x36
#define HMAC_OPAD 0x5c #define HMAC_OPAD 0x5c
OF_ASSUME_NONNULL_BEGIN
@interface XMPPSCRAMAuth ()
- (OFString *)XMPP_genNonce;
- (const uint8_t *)XMPP_HMACWithKey: (OFDataArray *)key
data: (OFDataArray *)data;
- (OFDataArray *)XMPP_hiWithData: (OFDataArray *)str
salt: (OFDataArray *)salt
iterationCount: (intmax_t)i;
- (OFDataArray *)XMPP_parseServerFirstMessage: (OFDataArray *)data;
- (OFDataArray *)XMPP_parseServerFinalMessage: (OFDataArray *)data;
@end
OF_ASSUME_NONNULL_END
@implementation XMPPSCRAMAuth @implementation XMPPSCRAMAuth
+ (instancetype)SCRAMAuthWithAuthcid: (OFString*)authcid + (instancetype)SCRAMAuthWithAuthcid: (OFString *)authcid
password: (OFString*)password password: (OFString *)password
connection: (XMPPConnection*)connection connection: (XMPPConnection *)connection
hash: (Class)hash hash: (Class)hash
plusAvailable: (bool)plusAvailable plusAvailable: (bool)plusAvailable
{ {
@ -51,10 +66,10 @@
plusAvailable: plusAvailable] autorelease]; plusAvailable: plusAvailable] autorelease];
} }
+ (instancetype)SCRAMAuthWithAuthzid: (OFString*)authzid + (instancetype)SCRAMAuthWithAuthzid: (OFString *)authzid
authcid: (OFString*)authcid authcid: (OFString *)authcid
password: (OFString*)password password: (OFString *)password
connection: (XMPPConnection*)connection connection: (XMPPConnection *)connection
hash: (Class)hash hash: (Class)hash
plusAvailable: (bool)plusAvailable plusAvailable: (bool)plusAvailable
{ {
@ -66,9 +81,9 @@
plusAvailable: plusAvailable] autorelease]; plusAvailable: plusAvailable] autorelease];
} }
- initWithAuthcid: (OFString*)authcid - initWithAuthcid: (OFString *)authcid
password: (OFString*)password password: (OFString *)password
connection: (XMPPConnection*)connection connection: (XMPPConnection *)connection
hash: (Class)hash hash: (Class)hash
plusAvailable: (bool)plusAvailable plusAvailable: (bool)plusAvailable
{ {
@ -80,10 +95,10 @@
plusAvailable: plusAvailable]; plusAvailable: plusAvailable];
} }
- initWithAuthzid: (OFString*)authzid - initWithAuthzid: (OFString *)authzid
authcid: (OFString*)authcid authcid: (OFString *)authcid
password: (OFString*)password password: (OFString *)password
connection: (XMPPConnection*)connection connection: (XMPPConnection *)connection
hash: (Class)hash hash: (Class)hash
plusAvailable: (bool)plusAvailable plusAvailable: (bool)plusAvailable
{ {
@ -109,7 +124,7 @@
[super dealloc]; [super dealloc];
} }
- (void)setAuthzid: (OFString*)authzid - (void)setAuthzid: (OFString *)authzid
{ {
OFString *old = _authzid; OFString *old = _authzid;
@ -126,7 +141,7 @@
[old release]; [old release];
} }
- (void)setAuthcid: (OFString*)authcid - (void)setAuthcid: (OFString *)authcid
{ {
OFString *old = _authcid; OFString *old = _authcid;
@ -143,7 +158,7 @@
[old release]; [old release];
} }
- (OFDataArray*)initialMessage - (OFDataArray *)initialMessage
{ {
OFDataArray *ret = [OFDataArray dataArray]; OFDataArray *ret = [OFDataArray dataArray];
@ -180,7 +195,7 @@
return ret; return ret;
} }
- (OFDataArray*)continueWithData: (OFDataArray*)data - (OFDataArray *)continueWithData: (OFDataArray *)data
{ {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFDataArray *ret; OFDataArray *ret;
@ -196,7 +211,7 @@
return [ret autorelease]; return [ret autorelease];
} }
- (OFDataArray*)XMPP_parseServerFirstMessage: (OFDataArray*)data - (OFDataArray *)XMPP_parseServerFirstMessage: (OFDataArray *)data
{ {
size_t i; size_t i;
const uint8_t *clientKey, *serverKey, *clientSignature; const uint8_t *clientKey, *serverKey, *clientSignature;
@ -253,7 +268,8 @@
[tmpArray addItems: [_GS2Header UTF8String] [tmpArray addItems: [_GS2Header UTF8String]
count: [_GS2Header UTF8StringLength]]; count: [_GS2Header UTF8StringLength]];
if (_plusAvailable && [_connection encrypted]) { if (_plusAvailable && [_connection encrypted]) {
OFDataArray *channelBinding = [((SSLSocket*)[_connection socket]) OFDataArray *channelBinding =
[((SSLSocket *)[_connection socket])
channelBindingDataWithType: @"tls-unique"]; channelBindingDataWithType: @"tls-unique"];
[tmpArray addItems: [channelBinding items] [tmpArray addItems: [channelBinding items]
count: [channelBinding count]]; count: [channelBinding count]];
@ -312,7 +328,7 @@
* IETF RFC 5802: * IETF RFC 5802:
* StoredKey := H(ClientKey) * StoredKey := H(ClientKey)
*/ */
[hash updateWithBuffer: (void*) clientKey [hash updateWithBuffer: (void *)clientKey
length: [_hashType digestSize]]; length: [_hashType digestSize]];
tmpArray = [OFDataArray dataArray]; tmpArray = [OFDataArray dataArray];
[tmpArray addItems: [hash digest] [tmpArray addItems: [hash digest]
@ -368,7 +384,7 @@
return ret; return ret;
} }
- (OFDataArray*)XMPP_parseServerFinalMessage: (OFDataArray*)data - (OFDataArray *)XMPP_parseServerFinalMessage: (OFDataArray *)data
{ {
OFString *mess, *value; OFString *mess, *value;
@ -398,7 +414,7 @@
return nil; return nil;
} }
- (OFString*)XMPP_genNonce - (OFString *)XMPP_genNonce
{ {
uint8_t buf[64]; uint8_t buf[64];
size_t i; size_t i;
@ -414,13 +430,13 @@
buf[i] = '~'; buf[i] = '~';
} }
return [OFString stringWithCString: (char*)buf return [OFString stringWithCString: (char *)buf
encoding: OF_STRING_ENCODING_ASCII encoding: OF_STRING_ENCODING_ASCII
length: 64]; length: 64];
} }
- (const uint8_t*)XMPP_HMACWithKey: (OFDataArray*)key - (const uint8_t *)XMPP_HMACWithKey: (OFDataArray *)key
data: (OFDataArray*)data data: (OFDataArray *)data
{ {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFDataArray *k = [OFDataArray dataArray]; OFDataArray *k = [OFDataArray dataArray];
@ -453,15 +469,15 @@
} }
hashI = [[[_hashType alloc] init] autorelease]; hashI = [[[_hashType alloc] init] autorelease];
[hashI updateWithBuffer: (char*)kI [hashI updateWithBuffer: (char *)kI
length: blockSize]; length: blockSize];
[hashI updateWithBuffer: [data items] [hashI updateWithBuffer: [data items]
length: [data itemSize] * [data count]]; length: [data itemSize] * [data count]];
hashO = [[[_hashType alloc] init] autorelease]; hashO = [[[_hashType alloc] init] autorelease];
[hashO updateWithBuffer: (char*)kO [hashO updateWithBuffer: (char *)kO
length: blockSize]; length: blockSize];
[hashO updateWithBuffer: (char*)[hashI digest] [hashO updateWithBuffer: (char *)[hashI digest]
length: [_hashType digestSize]]; length: [_hashType digestSize]];
} @finally { } @finally {
[self freeMemory: kI]; [self freeMemory: kI];
@ -474,8 +490,8 @@
return [[hashO autorelease] digest]; return [[hashO autorelease] digest];
} }
- (OFDataArray*)XMPP_hiWithData: (OFDataArray*)str - (OFDataArray *)XMPP_hiWithData: (OFDataArray *)str
salt: (OFDataArray*)salt salt: (OFDataArray *)salt
iterationCount: (intmax_t)i iterationCount: (intmax_t)i
{ {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];

View file

@ -27,6 +27,8 @@
#import <ObjFW/ObjFW.h> #import <ObjFW/ObjFW.h>
OF_ASSUME_NONNULL_BEGIN
@interface XMPPSRVEntry: OFObject @interface XMPPSRVEntry: OFObject
{ {
uint16_t _priority; uint16_t _priority;
@ -40,18 +42,19 @@
@property (readonly) uint16_t weight; @property (readonly) uint16_t weight;
@property uint32_t accumulatedWeight; @property uint32_t accumulatedWeight;
@property (readonly) uint16_t port; @property (readonly) uint16_t port;
@property (readonly, copy) OFString *target; @property (readonly, nonatomic) OFString *target;
+ (instancetype)entryWithPriority: (uint16_t)priority + (instancetype)entryWithPriority: (uint16_t)priority
weight: (uint16_t)weight weight: (uint16_t)weight
port: (uint16_t)port port: (uint16_t)port
target: (OFString*)target; target: (OFString *)target;
+ (instancetype)entryWithResourceRecord: (ns_rr)resourceRecord + (instancetype)entryWithResourceRecord: (ns_rr)resourceRecord
handle: (ns_msg)handle; handle: (ns_msg)handle;
- init OF_UNAVAILABLE;
- initWithPriority: (uint16_t)priority - initWithPriority: (uint16_t)priority
weight: (uint16_t)weight weight: (uint16_t)weight
port: (uint16_t)port port: (uint16_t)port
target: (OFString*)target; target: (OFString *)target;
- initWithResourceRecord: (ns_rr)resourceRecord - initWithResourceRecord: (ns_rr)resourceRecord
handle: (ns_msg)handle; handle: (ns_msg)handle;
@end @end
@ -63,13 +66,11 @@
OFList *_list; OFList *_list;
} }
@property (readonly, copy) OFString *domain; @property (readonly, nonatomic) OFString *domain;
+ (instancetype)lookupWithDomain: (OFString*)domain; + (instancetype)lookupWithDomain: (OFString *)domain;
- initWithDomain: (OFString*)domain; - init OF_UNAVAILABLE;
- initWithDomain: (OFString *)domain;
- (void)XMPP_lookup;
- (void)XMPP_addEntry: (XMPPSRVEntry*)item;
@end @end
@interface XMPPSRVEnumerator: OFEnumerator @interface XMPPSRVEnumerator: OFEnumerator
@ -80,5 +81,8 @@
bool _done; bool _done;
} }
- initWithList: (OFList*)list; - init OF_UNAVAILABLE;
- initWithList: (OFList *)list;
@end @end
OF_ASSUME_NONNULL_END

View file

@ -40,6 +40,15 @@
#import <ObjFW/OFLocalization.h> #import <ObjFW/OFLocalization.h>
OF_ASSUME_NONNULL_BEGIN
@interface XMPPSRVLookup ()
- (void)XMPP_lookup;
- (void)XMPP_addEntry: (XMPPSRVEntry *)item;
@end
OF_ASSUME_NONNULL_END
@implementation XMPPSRVEntry @implementation XMPPSRVEntry
@synthesize priority = _priority, weight = _weight; @synthesize priority = _priority, weight = _weight;
@synthesize accumulatedWeight = _accumulatedWeight, port = _port; @synthesize accumulatedWeight = _accumulatedWeight, port = _port;
@ -48,7 +57,7 @@
+ (instancetype)entryWithPriority: (uint16_t)priority + (instancetype)entryWithPriority: (uint16_t)priority
weight: (uint16_t)weight weight: (uint16_t)weight
port: (uint16_t)port port: (uint16_t)port
target: (OFString*)target target: (OFString *)target
{ {
return [[[self alloc] initWithPriority: priority return [[[self alloc] initWithPriority: priority
weight: weight weight: weight
@ -65,20 +74,13 @@
- init - init
{ {
@try { OF_INVALID_INIT_METHOD
[self doesNotRecognizeSelector: _cmd];
} @catch (id e) {
[self release];
@throw e;
}
abort();
} }
- initWithPriority: (uint16_t)priority - initWithPriority: (uint16_t)priority
weight: (uint16_t)weight weight: (uint16_t)weight
port: (uint16_t)port port: (uint16_t)port
target: (OFString*)target target: (OFString *)target
{ {
self = [super init]; self = [super init];
@ -104,13 +106,13 @@
const uint16_t *rdata; const uint16_t *rdata;
char buffer[NS_MAXDNAME]; char buffer[NS_MAXDNAME];
rdata = (const uint16_t*)(void*)ns_rr_rdata(resourceRecord); rdata = (const uint16_t *)(void *)ns_rr_rdata(resourceRecord);
_priority = ntohs(rdata[0]); _priority = ntohs(rdata[0]);
_weight = ntohs(rdata[1]); _weight = ntohs(rdata[1]);
_port = ntohs(rdata[2]); _port = ntohs(rdata[2]);
if (dn_expand(ns_msg_base(handle), ns_msg_end(handle), if (dn_expand(ns_msg_base(handle), ns_msg_end(handle),
(uint8_t*)&rdata[3], buffer, NS_MAXDNAME) < 1) (uint8_t *)&rdata[3], buffer, NS_MAXDNAME) < 1)
@throw [OFInitializationFailedException @throw [OFInitializationFailedException
exceptionWithClass: [self class]]; exceptionWithClass: [self class]];
@ -132,7 +134,7 @@
[super dealloc]; [super dealloc];
} }
- (OFString*)description - (OFString *)description
{ {
return [OFString stringWithFormat: return [OFString stringWithFormat:
@"<%@ priority: %" PRIu16 @", weight: %" PRIu16 @", target: %@:%" @"<%@ priority: %" PRIu16 @", weight: %" PRIu16 @", target: %@:%"
@ -143,12 +145,17 @@
@implementation XMPPSRVLookup @implementation XMPPSRVLookup
@synthesize domain = _domain; @synthesize domain = _domain;
+ (instancetype)lookupWithDomain: (OFString*)domain + (instancetype)lookupWithDomain: (OFString *)domain
{ {
return [[[self alloc] initWithDomain: domain] autorelease]; return [[[self alloc] initWithDomain: domain] autorelease];
} }
- initWithDomain: (OFString*)domain - init
{
OF_INVALID_INIT_METHOD
}
- initWithDomain: (OFString *)domain
{ {
self = [super init]; self = [super init];
@ -231,7 +238,7 @@
[pool release]; [pool release];
} }
- (void)XMPP_addEntry: (XMPPSRVEntry*)entry - (void)XMPP_addEntry: (XMPPSRVEntry *)entry
{ {
OFAutoreleasePool *pool; OFAutoreleasePool *pool;
OFList *subList; OFList *subList;
@ -273,14 +280,19 @@
[pool release]; [pool release];
} }
- (OFEnumerator*)objectEnumerator - (OFEnumerator *)objectEnumerator
{ {
return [[[XMPPSRVEnumerator alloc] initWithList: _list] autorelease]; return [[[XMPPSRVEnumerator alloc] initWithList: _list] autorelease];
} }
@end @end
@implementation XMPPSRVEnumerator @implementation XMPPSRVEnumerator
- initWithList: (OFList*)list - init
{
OF_INVALID_INIT_METHOD
}
- initWithList: (OFList *)list
{ {
self = [super init]; self = [super init];
@ -321,7 +333,7 @@
if ([_subListCopy count] > 0) { if ([_subListCopy count] > 0) {
uint32_t randomWeight; uint32_t randomWeight;
RAND_pseudo_bytes((uint8_t*)&randomWeight, sizeof(uint32_t)); RAND_pseudo_bytes((uint8_t *)&randomWeight, sizeof(uint32_t));
randomWeight %= (totalWeight + 1); randomWeight %= (totalWeight + 1);
for (iter = [_subListCopy firstListObject]; iter != NULL; for (iter = [_subListCopy firstListObject]; iter != NULL;

View file

@ -23,6 +23,8 @@
#import <ObjFW/ObjFW.h> #import <ObjFW/ObjFW.h>
OF_ASSUME_NONNULL_BEGIN
@class XMPPJID; @class XMPPJID;
/** /**
@ -35,15 +37,15 @@
} }
/// \brief The value of the stanza's from attribute /// \brief The value of the stanza's from attribute
@property (copy) XMPPJID *from; @property OF_NULLABLE_PROPERTY (nonatomic, copy) XMPPJID *from;
/// \brief The value of the stanza's to attribute /// \brief The value of the stanza's to attribute
@property (copy) XMPPJID *to; @property OF_NULLABLE_PROPERTY (nonatomic, copy) XMPPJID *to;
/// \brief The value of the stanza's type attribute /// \brief The value of the stanza's type attribute
@property (copy) OFString *type; @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *type;
/// \brief The value of the stanza's id attribute /// \brief The value of the stanza's id attribute
@property (copy) OFString *ID; @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *ID;
/// \brief The stanza's xml:lang /// \brief The stanza's xml:lang
@property (copy) OFString *language; @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *language;
/** /**
* \brief Creates a new autoreleased XMPPStanza with the specified name. * \brief Creates a new autoreleased XMPPStanza with the specified name.
@ -51,7 +53,7 @@
* \param name The stanza's name (one of iq, message or presence) * \param name The stanza's name (one of iq, message or presence)
* \return A new autoreleased XMPPStanza * \return A new autoreleased XMPPStanza
*/ */
+ (instancetype)stanzaWithName: (OFString*)name; + (instancetype)stanzaWithName: (OFString *)name;
/** /**
* \brief Creates a new autoreleased XMPPStanza with the specified name and * \brief Creates a new autoreleased XMPPStanza with the specified name and
@ -61,8 +63,8 @@
* \param type The value for the stanza's type attribute * \param type The value for the stanza's type attribute
* \return A new autoreleased XMPPStanza * \return A new autoreleased XMPPStanza
*/ */
+ (instancetype)stanzaWithName: (OFString*)name + (instancetype)stanzaWithName: (OFString *)name
type: (OFString*)type; type: (nullable OFString *)type;
/** /**
* \brief Creates a new autoreleased XMPPStanza with the specified name and ID. * \brief Creates a new autoreleased XMPPStanza with the specified name and ID.
@ -71,8 +73,8 @@
* \param ID The value for the stanza's id attribute * \param ID The value for the stanza's id attribute
* \return A new autoreleased XMPPStanza * \return A new autoreleased XMPPStanza
*/ */
+ (instancetype)stanzaWithName: (OFString*)name + (instancetype)stanzaWithName: (OFString *)name
ID: (OFString*)ID; ID: (nullable OFString *)ID;
/** /**
* \brief Creates a new autoreleased XMPPStanza with the specified name, type * \brief Creates a new autoreleased XMPPStanza with the specified name, type
@ -83,9 +85,9 @@
* \param ID The value for the stanza's id attribute * \param ID The value for the stanza's id attribute
* \return A new autoreleased XMPPStanza * \return A new autoreleased XMPPStanza
*/ */
+ (instancetype)stanzaWithName: (OFString*)name + (instancetype)stanzaWithName: (OFString *)name
type: (OFString*)type type: (nullable OFString *)type
ID: (OFString*)ID; ID: (nullable OFString *)ID;
/** /**
* \brief Creates a new autoreleased XMPPStanza from an OFXMLElement. * \brief Creates a new autoreleased XMPPStanza from an OFXMLElement.
@ -93,7 +95,17 @@
* \param element The element to base the XMPPStanza on * \param element The element to base the XMPPStanza on
* \return A new autoreleased XMPPStanza * \return A new autoreleased XMPPStanza
*/ */
+ (instancetype)stanzaWithElement: (OFXMLElement*)element; + (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. * \brief Initializes an already allocated XMPPStanza with the specified name.
@ -101,7 +113,7 @@
* \param name The stanza's name (one of iq, message or presence) * \param name The stanza's name (one of iq, message or presence)
* \return A initialized XMPPStanza * \return A initialized XMPPStanza
*/ */
- initWithName: (OFString*)name; - initWithName: (OFString *)name;
/** /**
* \brief Initializes an already allocated XMPPStanza with the specified name * \brief Initializes an already allocated XMPPStanza with the specified name
@ -111,8 +123,8 @@
* \param type The value for the stanza's type attribute * \param type The value for the stanza's type attribute
* \return A initialized XMPPStanza * \return A initialized XMPPStanza
*/ */
- initWithName: (OFString*)name - initWithName: (OFString *)name
type: (OFString*)type; type: (nullable OFString *)type;
/** /**
* \brief Initializes an already allocated XMPPStanza with the specified name * \brief Initializes an already allocated XMPPStanza with the specified name
@ -122,8 +134,8 @@
* \param ID The value for the stanza's id attribute * \param ID The value for the stanza's id attribute
* \return A initialized XMPPStanza * \return A initialized XMPPStanza
*/ */
- initWithName: (OFString*)name - initWithName: (OFString *)name
ID: (OFString*)ID; ID: (nullable OFString *)ID;
/** /**
* \brief Initializes an already allocated XMPPStanza with the specified name, * \brief Initializes an already allocated XMPPStanza with the specified name,
@ -134,9 +146,9 @@
* \param ID The value for the stanza's id attribute * \param ID The value for the stanza's id attribute
* \return A initialized XMPPStanza * \return A initialized XMPPStanza
*/ */
- initWithName: (OFString*)name - initWithName: (OFString *)name
type: (OFString*)type type: (nullable OFString *)type
ID: (OFString*)ID; ID: (nullable OFString *)ID;
/** /**
* \brief Initializes an already allocated XMPPStanza based on a OFXMLElement. * \brief Initializes an already allocated XMPPStanza based on a OFXMLElement.
@ -144,5 +156,7 @@
* \param element The element to base the XMPPStanza on * \param element The element to base the XMPPStanza on
* \return A initialized XMPPStanza * \return A initialized XMPPStanza
*/ */
- initWithElement: (OFXMLElement*)element; - initWithElement: (OFXMLElement *)element;
@end @end
OF_ASSUME_NONNULL_END

View file

@ -30,65 +30,85 @@
#import "namespaces.h" #import "namespaces.h"
@implementation XMPPStanza @implementation XMPPStanza
+ (instancetype)stanzaWithName: (OFString*)name @synthesize from = _from, to = _to, type = _type, ID = _ID;
@synthesize language = _language;
+ (instancetype)stanzaWithName: (OFString *)name
{ {
return [[[self alloc] initWithName: name] autorelease]; return [[[self alloc] initWithName: name] autorelease];
} }
+ (instancetype)stanzaWithName: (OFString*)name + (instancetype)stanzaWithName: (OFString *)name
type: (OFString*)type type: (OFString *)type
{ {
return [[[self alloc] initWithName: name return [[[self alloc] initWithName: name
type: type] autorelease]; type: type] autorelease];
} }
+ (instancetype)stanzaWithName: (OFString*)name + (instancetype)stanzaWithName: (OFString *)name
ID: (OFString*)ID ID: (OFString *)ID
{ {
return [[[self alloc] initWithName: name return [[[self alloc] initWithName: name
ID: ID] autorelease]; ID: ID] autorelease];
} }
+ (instancetype)stanzaWithName: (OFString*)name + (instancetype)stanzaWithName: (OFString *)name
type: (OFString*)type type: (OFString *)type
ID: (OFString*)ID ID: (OFString *)ID
{ {
return [[[self alloc] initWithName: name return [[[self alloc] initWithName: name
type: type type: type
ID: ID] autorelease]; ID: ID] autorelease];
} }
+ (instancetype)stanzaWithElement: (OFXMLElement*)element + (instancetype)stanzaWithElement: (OFXMLElement *)element
{ {
return [[[self alloc] initWithElement: element] autorelease]; return [[[self alloc] initWithElement: element] autorelease];
} }
- initWithName: (OFString*)name - initWithName: (OFString *)name
namespace: (nullable OFString *)namespace
stringValue: (nullable OFString *)stringValue
{
OF_INVALID_INIT_METHOD
}
- initWithXMLString: (OFString *)string
{
OF_INVALID_INIT_METHOD
}
- initWithFile: (OFString *)path
{
OF_INVALID_INIT_METHOD
}
- initWithName: (OFString *)name
{ {
return [self initWithName: name return [self initWithName: name
type: nil type: nil
ID: nil]; ID: nil];
} }
- initWithName: (OFString*)name - initWithName: (OFString *)name
type: (OFString*)type type: (OFString *)type
{ {
return [self initWithName: name return [self initWithName: name
type: type type: type
ID: nil]; ID: nil];
} }
- initWithName: (OFString*)name - initWithName: (OFString *)name
ID: (OFString*)ID ID: (OFString *)ID
{ {
return [self initWithName: name return [self initWithName: name
type: nil type: nil
ID: ID]; ID: ID];
} }
- initWithName: (OFString*)name - initWithName: (OFString *)name
type: (OFString*)type type: (OFString *)type
ID: (OFString*)ID ID: (OFString *)ID
{ {
self = [super initWithName: name self = [super initWithName: name
namespace: XMPP_NS_CLIENT]; namespace: XMPP_NS_CLIENT];
@ -115,7 +135,7 @@
return self; return self;
} }
- initWithElement: (OFXMLElement*)element - initWithElement: (OFXMLElement *)element
{ {
self = [super initWithElement: element]; self = [super initWithElement: element];
@ -153,7 +173,7 @@
[super dealloc]; [super dealloc];
} }
- (void)setFrom: (XMPPJID*)from - (void)setFrom: (XMPPJID *)from
{ {
XMPPJID *old = _from; XMPPJID *old = _from;
_from = [from copy]; _from = [from copy];
@ -166,12 +186,7 @@
stringValue: [from fullJID]]; stringValue: [from fullJID]];
} }
- (XMPPJID*)from - (void)setTo: (XMPPJID *)to
{
return [[_from copy] autorelease];
}
- (void)setTo: (XMPPJID*)to
{ {
XMPPJID *old = _to; XMPPJID *old = _to;
_to = [to copy]; _to = [to copy];
@ -184,12 +199,7 @@
stringValue: [to fullJID]]; stringValue: [to fullJID]];
} }
- (XMPPJID*)to - (void)setType: (OFString *)type
{
return [[_to copy] autorelease];
}
- (void)setType: (OFString*)type
{ {
OFString *old = _type; OFString *old = _type;
_type = [type copy]; _type = [type copy];
@ -202,12 +212,7 @@
stringValue: type]; stringValue: type];
} }
- (OFString*)type - (void)setID: (OFString *)ID
{
return [[_type copy] autorelease];
}
- (void)setID: (OFString*)ID
{ {
OFString *old = _ID; OFString *old = _ID;
_ID = [ID copy]; _ID = [ID copy];
@ -220,12 +225,7 @@
stringValue: ID]; stringValue: ID];
} }
- (OFString*)ID - (void)setLanguage: (OFString *)language
{
return [[_ID copy] autorelease];
}
- (void)setLanguage: (OFString*)language
{ {
OFString *old = _language; OFString *old = _language;
_language = [language copy]; _language = [language copy];
@ -240,9 +240,4 @@
@"namespace" @"namespace"
stringValue: language]; stringValue: language];
} }
- (OFString*)language
{
return [[_language copy] autorelease];
}
@end @end

View file

@ -22,25 +22,29 @@
#import <ObjFW/OFObject.h> #import <ObjFW/OFObject.h>
OF_ASSUME_NONNULL_BEGIN
@class OFString; @class OFString;
@class OFArray; @class OFArray;
@class OFDictionary; @class OFDictionary;
@protocol XMPPStorage <OFObject> @protocol XMPPStorage <OFObject>
- (void)save; - (void)save;
- (void)setStringValue: (OFString*)string - (void)setStringValue: (nullable OFString *)string
forPath: (OFString*)path; forPath: (OFString *)path;
- (OFString*)stringValueForPath: (OFString*)path; - (nullable OFString *)stringValueForPath: (OFString *)path;
- (void)setBooleanValue: (bool)boolean - (void)setBooleanValue: (bool)boolean
forPath: (OFString*)path; forPath: (OFString *)path;
- (bool)booleanValueForPath: (OFString*)path; - (bool)booleanValueForPath: (OFString *)path;
- (void)setIntegerValue: (intmax_t)integer - (void)setIntegerValue: (intmax_t)integer
forPath: (OFString*)path; forPath: (OFString *)path;
- (intmax_t)integerValueForPath: (OFString*)path; - (intmax_t)integerValueForPath: (OFString *)path;
- (void)setArray: (OFArray*)array - (void)setArray: (nullable OFArray *)array
forPath: (OFString*)path; forPath: (OFString *)path;
- (OFArray*)arrayForPath: (OFString*)path; - (nullable OFArray *)arrayForPath: (OFString *)path;
- (void)setDictionary: (OFDictionary*)dictionary - (void)setDictionary: (nullable OFDictionary *)dictionary
forPath: (OFString*)path; forPath: (OFString *)path;
- (OFDictionary*)dictionaryForPath: (OFString*)path; - (nullable OFDictionary *)dictionaryForPath: (OFString *)path;
@end @end
OF_ASSUME_NONNULL_END

View file

@ -23,11 +23,16 @@
#import "XMPPConnection.h" #import "XMPPConnection.h"
OF_ASSUME_NONNULL_BEGIN
@interface XMPPStreamManagement: OFObject <XMPPConnectionDelegate> @interface XMPPStreamManagement: OFObject <XMPPConnectionDelegate>
{ {
XMPPConnection *_connection; XMPPConnection *_connection;
uint32_t _receivedCount; uint32_t _receivedCount;
} }
- initWithConnection: (XMPPConnection*)connection; - init OF_UNAVAILABLE;
- initWithConnection: (XMPPConnection *)connection;
@end @end
OF_ASSUME_NONNULL_END

View file

@ -26,7 +26,12 @@
#import "namespaces.h" #import "namespaces.h"
@implementation XMPPStreamManagement @implementation XMPPStreamManagement
- initWithConnection: (XMPPConnection*)connection - init
{
OF_INVALID_INIT_METHOD
}
- initWithConnection: (XMPPConnection *)connection
{ {
self = [super init]; self = [super init];
@ -48,8 +53,8 @@
[super dealloc]; [super dealloc];
} }
- (void)connection: (XMPPConnection*)connection - (void)connection: (XMPPConnection *)connection
didReceiveElement: (OFXMLElement*)element didReceiveElement: (OFXMLElement *)element
{ {
OFString *elementName = [element name]; OFString *elementName = [element name];
OFString *elementNS = [element namespace]; OFString *elementNS = [element namespace];
@ -85,14 +90,14 @@
} }
/* TODO: Count outgoing stanzas here and cache them, send own ACK requests /* TODO: Count outgoing stanzas here and cache them, send own ACK requests
- (void)connection: (XMPPConnection*)connection - (void)connection: (XMPPConnection *)connection
didSendElement: (OFXMLElement*)element didSendElement: (OFXMLElement *)element
{ {
} }
*/ */
- (void)connection: (XMPPConnection*)connection - (void)connection: (XMPPConnection *)connection
wasBoundToJID: (XMPPJID*)JID wasBoundToJID: (XMPPJID *)JID
{ {
if ([connection supportsStreamManagement]) if ([connection supportsStreamManagement])
[connection sendStanza: [connection sendStanza:

View file

@ -22,5 +22,9 @@
#import <ObjFW/OFXMLElementBuilder.h> #import <ObjFW/OFXMLElementBuilder.h>
OF_ASSUME_NONNULL_BEGIN
@interface XMPPXMLElementBuilder: OFXMLElementBuilder @interface XMPPXMLElementBuilder: OFXMLElementBuilder
@end @end
OF_ASSUME_NONNULL_END

View file

@ -29,14 +29,14 @@
#import <ObjFW/OFMalformedXMLException.h> #import <ObjFW/OFMalformedXMLException.h>
@implementation XMPPXMLElementBuilder @implementation XMPPXMLElementBuilder
- (void)parser: (OFXMLParser*)parser - (void)parser: (OFXMLParser *)parser
foundProcessingInstructions: (OFString*)pi foundProcessingInstructions: (OFString *)pi
{ {
@throw [OFMalformedXMLException exception]; @throw [OFMalformedXMLException exception];
} }
- (void)parser: (OFXMLParser*)parser - (void)parser: (OFXMLParser *)parser
foundComment: (OFString*)comment foundComment: (OFString *)comment
{ {
@throw [OFMalformedXMLException exception]; @throw [OFMalformedXMLException exception];
} }

View file

@ -38,9 +38,7 @@
#import "XMPPFileStorage.h" #import "XMPPFileStorage.h"
@interface AppDelegate: OFObject @interface AppDelegate: OFObject
#ifdef OF_HAVE_OPTIONAL_PROTOCOLS
<OFApplicationDelegate, XMPPConnectionDelegate, XMPPRosterDelegate> <OFApplicationDelegate, XMPPConnectionDelegate, XMPPRosterDelegate>
#endif
{ {
XMPPConnection *conn; XMPPConnection *conn;
XMPPRoster *roster; XMPPRoster *roster;
@ -131,25 +129,25 @@ OF_APPLICATION_DELEGATE(AppDelegate)
[conn asyncConnectAndHandle]; [conn asyncConnectAndHandle];
} }
- (void)connection: (XMPPConnection*)conn - (void)connection: (XMPPConnection *)conn
didReceiveElement: (OFXMLElement*)element didReceiveElement: (OFXMLElement *)element
{ {
of_log(@"In: %@", element); of_log(@"In: %@", element);
} }
- (void)connection: (XMPPConnection*)conn - (void)connection: (XMPPConnection *)conn
didSendElement: (OFXMLElement*)element didSendElement: (OFXMLElement *)element
{ {
of_log(@"Out: %@", element); of_log(@"Out: %@", element);
} }
- (void)connectionWasAuthenticated: (XMPPConnection*)conn - (void)connectionWasAuthenticated: (XMPPConnection *)conn
{ {
of_log(@"Auth successful"); of_log(@"Auth successful");
} }
- (void)connection: (XMPPConnection*)conn_ - (void)connection: (XMPPConnection *)conn_
wasBoundToJID: (XMPPJID*)jid wasBoundToJID: (XMPPJID *)jid
{ {
of_log(@"Bound to JID: %@", [jid fullJID]); of_log(@"Bound to JID: %@", [jid fullJID]);
of_log(@"Supports SM: %@", of_log(@"Supports SM: %@",
@ -200,7 +198,7 @@ OF_APPLICATION_DELEGATE(AppDelegate)
[roster requestRoster]; [roster requestRoster];
} }
- (void)rosterWasReceived: (XMPPRoster*)roster_ - (void)rosterWasReceived: (XMPPRoster *)roster_
{ {
XMPPPresence *pres; XMPPPresence *pres;
@ -224,7 +222,7 @@ OF_APPLICATION_DELEGATE(AppDelegate)
#endif #endif
} }
- (void)connectionDidUpgradeToTLS: (XMPPConnection*)conn_ - (void)connectionDidUpgradeToTLS: (XMPPConnection *)conn_
{ {
OFString *reason; OFString *reason;
@ -238,39 +236,39 @@ OF_APPLICATION_DELEGATE(AppDelegate)
} }
} }
- (void)roster: (XMPPRoster*)roster_ - (void)roster: (XMPPRoster *)roster_
didReceiveRosterItem: (XMPPRosterItem*)rosterItem didReceiveRosterItem: (XMPPRosterItem *)rosterItem
{ {
of_log(@"Got roster push: %@", rosterItem); of_log(@"Got roster push: %@", rosterItem);
} }
- (bool)connection: (XMPPConnection*)conn - (bool)connection: (XMPPConnection *)conn
didReceiveIQ: (XMPPIQ*)iq didReceiveIQ: (XMPPIQ *)iq
{ {
of_log(@"IQ: %@", iq); of_log(@"IQ: %@", iq);
return NO; return NO;
} }
- (void)connection: (XMPPConnection*)conn - (void)connection: (XMPPConnection *)conn
didReceiveMessage: (XMPPMessage*)msg didReceiveMessage: (XMPPMessage *)msg
{ {
of_log(@"Message: %@", msg); of_log(@"Message: %@", msg);
} }
- (void)connection: (XMPPConnection*)conn - (void)connection: (XMPPConnection *)conn
didReceivePresence: (XMPPPresence*)pres didReceivePresence: (XMPPPresence *)pres
{ {
of_log(@"Presence: %@", pres); of_log(@"Presence: %@", pres);
} }
- (void)connection: (XMPPConnection*)conn - (void)connection: (XMPPConnection *)conn
didThrowException: (id)e didThrowException: (id)e
{ {
@throw e; @throw e;
} }
- (void)connectionWasClosed: (XMPPConnection*)conn - (void)connectionWasClosed: (XMPPConnection *)conn
{ {
of_log(@"Connection was closed!"); of_log(@"Connection was closed!");
} }