Adjust to ObjFW changes
This commit is contained in:
parent
73d3bca240
commit
5fa8b0b9b3
51 changed files with 935 additions and 859 deletions
|
@ -23,6 +23,8 @@
|
|||
|
||||
#import <ObjFW/ObjFW.h>
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* \brief A base class for classes implementing authentication mechanisms
|
||||
*/
|
||||
|
@ -32,11 +34,11 @@
|
|||
}
|
||||
|
||||
/// \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
|
||||
@property (copy) OFString *authcid;
|
||||
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *authcid;
|
||||
/// \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
|
||||
|
@ -46,8 +48,8 @@
|
|||
* \param password The password to authenticate with
|
||||
* \return A initialized XMPPAuthenticator
|
||||
*/
|
||||
- initWithAuthcid: (OFString*)authcid
|
||||
password: (OFString*)password;
|
||||
- initWithAuthcid: (nullable OFString *)authcid
|
||||
password: (nullable OFString *)password;
|
||||
|
||||
/**
|
||||
* \brief Initializes an already allocated XMPPSCRAMAuthenticator with an
|
||||
|
@ -58,9 +60,9 @@
|
|||
* \param password The password to authenticate with
|
||||
* \return A initialized XMPPAuthenticator
|
||||
*/
|
||||
- initWithAuthzid: (OFString*)authzid
|
||||
authcid: (OFString*)authcid
|
||||
password: (OFString*)password;
|
||||
- initWithAuthzid: (nullable OFString *)authzid
|
||||
authcid: (nullable OFString *)authcid
|
||||
password: (nullable OFString *)password OF_DESIGNATED_INITIALIZER;
|
||||
|
||||
/**
|
||||
* \brief Returns an OFDataArray containing the initial authentication message.
|
||||
|
@ -75,5 +77,7 @@
|
|||
* \param data The continuation data send by the server
|
||||
* \return The appropriate response if the data was a challenge, nil otherwise
|
||||
*/
|
||||
- (OFDataArray*)continueWithData: (OFDataArray*)data;
|
||||
- (nullable OFDataArray *)continueWithData: (OFDataArray *)data;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -22,11 +22,14 @@
|
|||
|
||||
#import <ObjFW/ObjFW.h>
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class XMPPConnection;
|
||||
@class XMPPIQ;
|
||||
|
||||
#ifdef OF_HAVE_BLOCKS
|
||||
typedef void (^xmpp_callback_block_t)(XMPPConnection*, XMPPIQ*);
|
||||
typedef void (^xmpp_callback_block_t)(XMPPConnection *_Nonnull,
|
||||
XMPPIQ *_Nonnull);
|
||||
#endif
|
||||
|
||||
@interface XMPPCallback: OFObject
|
||||
|
@ -51,3 +54,5 @@ typedef void (^xmpp_callback_block_t)(XMPPConnection*, XMPPIQ*);
|
|||
- (void)runWithIQ: (XMPPIQ *)iq
|
||||
connection: (XMPPConnection *)connection;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -30,7 +30,8 @@
|
|||
#ifdef OF_HAVE_BLOCKS
|
||||
+ (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
|
||||
|
@ -76,16 +77,16 @@
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)runWithIQ: (XMPPIQ*)iq
|
||||
- (void)runWithIQ: (XMPPIQ *)IQ
|
||||
connection: (XMPPConnection *)connection
|
||||
{
|
||||
#ifdef OF_HAVE_BLOCKS
|
||||
if (_block != NULL)
|
||||
_block(connection, iq);
|
||||
_block(connection, IQ);
|
||||
else
|
||||
#endif
|
||||
[_target performSelector: _selector
|
||||
withObject: connection
|
||||
withObject: iq];
|
||||
withObject: IQ];
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#import "XMPPCallback.h"
|
||||
#import "XMPPStorage.h"
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class XMPPConnection;
|
||||
@class XMPPJID;
|
||||
@class XMPPIQ;
|
||||
|
@ -37,13 +39,10 @@
|
|||
@class XMPPMulticastDelegate;
|
||||
|
||||
/**
|
||||
* \brief A protocol that should be (partially) implemented
|
||||
* by delegates of a XMPPConnection
|
||||
* \brief A protocol that should be (partially) implemented by delegates of a
|
||||
* @ref XMPPConnection
|
||||
*/
|
||||
@protocol XMPPConnectionDelegate
|
||||
#ifndef XMPP_CONNECTION_M
|
||||
<OFObject>
|
||||
#endif
|
||||
@optional
|
||||
/**
|
||||
* \brief This callback is called when the connection received an element.
|
||||
|
@ -160,7 +159,7 @@
|
|||
id <XMPPStorage> _dataStorage;
|
||||
OFString *_language;
|
||||
XMPPMulticastDelegate *_delegates;
|
||||
OFMutableDictionary *_callbacks;
|
||||
OFMutableDictionary OF_GENERIC(OFString *, XMPPCallback *) *_callbacks;
|
||||
XMPPAuthenticator *_authModule;
|
||||
bool _streamOpen;
|
||||
bool _needsSession;
|
||||
|
@ -171,33 +170,33 @@
|
|||
}
|
||||
|
||||
/// \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
|
||||
@property (copy) OFString *password;
|
||||
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *password;
|
||||
/**
|
||||
* \brief The server to use for the connection
|
||||
*
|
||||
* This is useful if the address of the server is different from the domain.
|
||||
*/
|
||||
@property (copy) OFString *server;
|
||||
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *server;
|
||||
/// \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
|
||||
@property (copy) OFString *resource;
|
||||
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *resource;
|
||||
/// \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
|
||||
@property (copy) OFString *privateKeyFile;
|
||||
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *privateKeyFile;
|
||||
/// \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
|
||||
@property (copy, readonly) XMPPJID *JID;
|
||||
@property (readonly, nonatomic) XMPPJID *JID;
|
||||
/// \brief The port to connect to
|
||||
@property uint16_t port;
|
||||
/// \brief An object for data storage, conforming to the XMPPStorage protocol
|
||||
@property (assign) id <XMPPStorage> dataStorage;
|
||||
@property OF_NULLABLE_PROPERTY (assign) id <XMPPStorage> dataStorage;
|
||||
/// \brief The socket used for the connection
|
||||
@property (readonly, retain) OFTCPSocket *socket;
|
||||
@property (readonly, nonatomic) OFTCPSocket *socket;
|
||||
/// \brief Whether encryption is required
|
||||
@property bool encryptionRequired;
|
||||
/// \brief Whether the connection is encrypted
|
||||
|
@ -247,7 +246,8 @@
|
|||
* Passing NULL means the reason is not stored anywhere.
|
||||
* \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.
|
||||
|
@ -272,34 +272,6 @@
|
|||
- (void)parseBuffer: (const void *)buffer
|
||||
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.
|
||||
*
|
||||
|
@ -313,7 +285,7 @@
|
|||
* @param IQ The IQ to send
|
||||
* @param target The object that contains 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
|
||||
callbackTarget: (id)target
|
||||
|
@ -336,48 +308,6 @@
|
|||
* \return A new, generated, unique stanza ID.
|
||||
*/
|
||||
- (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
|
||||
|
||||
@interface OFObject (XMPPConnectionDelegate) <XMPPConnectionDelegate>
|
||||
@end
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -59,6 +59,31 @@
|
|||
|
||||
#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
|
||||
{
|
||||
OFThread *_sourceThread;
|
||||
|
@ -69,6 +94,8 @@
|
|||
connection: (XMPPConnection *)connection;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
||||
@implementation XMPPConnection_ConnectThread
|
||||
- initWithSourceThread: (OFThread *)sourceThread
|
||||
connection: (XMPPConnection *)connection
|
||||
|
@ -118,7 +145,9 @@
|
|||
@end
|
||||
|
||||
@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 encryptionRequired = _encryptionRequired, encrypted = _encrypted;
|
||||
@synthesize supportsRosterVersioning = _supportsRosterVersioning;
|
||||
|
@ -191,11 +220,6 @@
|
|||
[old release];
|
||||
}
|
||||
|
||||
- (OFString*)username
|
||||
{
|
||||
return [[_username copy] autorelease];
|
||||
}
|
||||
|
||||
- (void)setResource: (OFString *)resource
|
||||
{
|
||||
OFString *old = _resource;
|
||||
|
@ -222,11 +246,6 @@
|
|||
[old release];
|
||||
}
|
||||
|
||||
- (OFString*)resource
|
||||
{
|
||||
return [[_resource copy] autorelease];
|
||||
}
|
||||
|
||||
- (void)setServer: (OFString *)server
|
||||
{
|
||||
OFString *old = _server;
|
||||
|
@ -239,11 +258,6 @@
|
|||
[old release];
|
||||
}
|
||||
|
||||
- (OFString*)server
|
||||
{
|
||||
return [[_server copy] autorelease];
|
||||
}
|
||||
|
||||
- (void)setDomain: (OFString *)domain
|
||||
{
|
||||
OFString *oldDomain = _domain;
|
||||
|
@ -276,11 +290,6 @@
|
|||
[oldDomainToASCII release];
|
||||
}
|
||||
|
||||
- (OFString*)domain
|
||||
{
|
||||
return [[_domain copy] autorelease];
|
||||
}
|
||||
|
||||
- (void)setPassword: (OFString *)password
|
||||
{
|
||||
OFString *old = _password;
|
||||
|
@ -307,11 +316,6 @@
|
|||
[old release];
|
||||
}
|
||||
|
||||
- (OFString*)password
|
||||
{
|
||||
return [[_password copy] autorelease];
|
||||
}
|
||||
|
||||
- (void)connect
|
||||
{
|
||||
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
||||
|
@ -579,15 +583,12 @@
|
|||
return [OFString stringWithFormat: @"objxmpp_%u", _lastID++];
|
||||
}
|
||||
|
||||
- (void)parser: (OFXMLParser*)p
|
||||
- (void)parser: (OFXMLParser *)parser
|
||||
didStartElement: (OFString *)name
|
||||
prefix: (OFString *)prefix
|
||||
namespace: (OFString*)ns
|
||||
namespace: (OFString *)NS
|
||||
attributes: (OFArray *)attributes
|
||||
{
|
||||
OFEnumerator *enumerator;
|
||||
OFXMLAttribute *attribute;
|
||||
|
||||
if (![name isEqual: @"stream"]) {
|
||||
// No dedicated stream error for this, may not even be XMPP
|
||||
[self close];
|
||||
|
@ -601,14 +602,13 @@
|
|||
return;
|
||||
}
|
||||
|
||||
if (![ns isEqual: XMPP_NS_STREAM]) {
|
||||
if (![NS isEqual: XMPP_NS_STREAM]) {
|
||||
[self XMPP_sendStreamError: @"invalid-namespace"
|
||||
text: nil];
|
||||
return;
|
||||
}
|
||||
|
||||
enumerator = [attributes objectEnumerator];
|
||||
while ((attribute = [enumerator nextObject]) != nil) {
|
||||
for (OFXMLAttribute *attribute in attributes) {
|
||||
if ([[attribute name] isEqual: @"from"] &&
|
||||
![[attribute stringValue] isEqual: _domain]) {
|
||||
[self XMPP_sendStreamError: @"invalid-from"
|
||||
|
@ -623,7 +623,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
[_parser setDelegate: _elementBuilder];
|
||||
[parser setDelegate: _elementBuilder];
|
||||
}
|
||||
|
||||
- (void)elementBuilder: (OFXMLElementBuilder *)builder
|
||||
|
@ -1023,7 +1023,7 @@
|
|||
while ((mech = [enumerator nextObject]) != nil)
|
||||
[mechanisms addObject: [mech stringValue]];
|
||||
|
||||
if (_privateKeyFile && _certificateFile &&
|
||||
if (_privateKeyFile != nil && _certificateFile != nil &&
|
||||
[mechanisms containsObject: @"EXTERNAL"]) {
|
||||
_authModule = [[XMPPEXTERNALAuth alloc] init];
|
||||
[self XMPP_sendAuth: @"EXTERNAL"];
|
||||
|
@ -1063,8 +1063,8 @@
|
|||
assert(0);
|
||||
}
|
||||
|
||||
if (session != nil && ![session elementForName: @"optional"
|
||||
namespace: XMPP_NS_SESSION])
|
||||
if (session != nil && [session elementForName: @"optional"
|
||||
namespace: XMPP_NS_SESSION] == nil)
|
||||
_needsSession = true;
|
||||
|
||||
if (bind != nil) {
|
||||
|
@ -1140,21 +1140,20 @@
|
|||
}
|
||||
|
||||
- (void)XMPP_handleResourceBindForConnection: (XMPPConnection *)connection
|
||||
IQ: (XMPPIQ*)iq
|
||||
IQ: (XMPPIQ *)IQ
|
||||
{
|
||||
OFXMLElement *bindElement;
|
||||
OFXMLElement *jidElement;
|
||||
OFXMLElement *bindElement, *JIDElement;
|
||||
|
||||
assert([[iq type] isEqual: @"result"]);
|
||||
assert([[IQ type] isEqual: @"result"]);
|
||||
|
||||
bindElement = [iq elementForName: @"bind"
|
||||
bindElement = [IQ elementForName: @"bind"
|
||||
namespace: XMPP_NS_BIND];
|
||||
|
||||
assert(bindElement != nil);
|
||||
|
||||
jidElement = [bindElement elementForName: @"jid"
|
||||
JIDElement = [bindElement elementForName: @"jid"
|
||||
namespace: XMPP_NS_BIND];
|
||||
_JID = [[XMPPJID alloc] initWithString: [jidElement stringValue]];
|
||||
_JID = [[XMPPJID alloc] initWithString: [JIDElement stringValue]];
|
||||
|
||||
if (_needsSession) {
|
||||
[self XMPP_sendSession];
|
||||
|
@ -1168,22 +1167,22 @@
|
|||
|
||||
- (void)XMPP_sendSession
|
||||
{
|
||||
XMPPIQ *iq;
|
||||
|
||||
iq = [XMPPIQ IQWithType: @"set"
|
||||
XMPPIQ *IQ = [XMPPIQ IQWithType: @"set"
|
||||
ID: [self generateStanzaID]];
|
||||
[iq addChild: [OFXMLElement elementWithName: @"session"
|
||||
|
||||
[IQ addChild: [OFXMLElement elementWithName: @"session"
|
||||
namespace: XMPP_NS_SESSION]];
|
||||
[self sendIQ: iq
|
||||
|
||||
[self sendIQ: IQ
|
||||
callbackTarget: self
|
||||
selector: @selector(XMPP_handleSessionForConnection:IQ:)];
|
||||
}
|
||||
|
||||
- (void)XMPP_handleSessionForConnection: (XMPPConnection *)connection
|
||||
IQ: (XMPPIQ*)iq
|
||||
IQ: (XMPPIQ *)IQ
|
||||
{
|
||||
if (![[iq type] isEqual: @"result"])
|
||||
assert(0);
|
||||
if (![[IQ type] isEqual: @"result"])
|
||||
OF_ENSURE(0);
|
||||
|
||||
[_delegates broadcastSelector: @selector(connection:wasBoundToJID:)
|
||||
withObject: self
|
||||
|
|
13
src/XMPPContact+Private.h
Normal file
13
src/XMPPContact+Private.h
Normal 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
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#import <ObjFW/ObjFW.h>
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class XMPPConnection;
|
||||
@class XMPPJID;
|
||||
@class XMPPRosterItem;
|
||||
|
@ -40,9 +42,9 @@
|
|||
}
|
||||
|
||||
/// \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
|
||||
@property (readonly) OFDictionary *presences;
|
||||
@property (readonly, nonatomic) OFDictionary *presences;
|
||||
|
||||
/**
|
||||
* \brief Sends a message to the contact honoring resource locking
|
||||
|
@ -52,10 +54,6 @@
|
|||
*/
|
||||
- (void)sendMessage: (XMPPMessage *)message
|
||||
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
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
*/
|
||||
|
||||
#import "XMPPContact.h"
|
||||
#import "XMPPContact+Private.h"
|
||||
#import "XMPPMessage.h"
|
||||
#import "XMPPConnection.h"
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#import "XMPPConnection.h"
|
||||
#import "XMPPRoster.h"
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class XMPPContact;
|
||||
@class XMPPContactManager;
|
||||
@class XMPPMulticastDelegate;
|
||||
|
@ -110,7 +112,8 @@
|
|||
}
|
||||
|
||||
/// \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.
|
||||
|
@ -120,7 +123,7 @@
|
|||
* @return An initialized XMPPContactManager
|
||||
*/
|
||||
- initWithConnection: (XMPPConnection *)connection
|
||||
roster: (XMPPRoster*)roster;
|
||||
roster: (XMPPRoster *)roster OF_DESIGNATED_INITIALIZER;
|
||||
|
||||
- (void)sendSubscribedToJID: (XMPPJID *)subscriber;
|
||||
- (void)sendUnsubscribedToJID: (XMPPJID *)subscriber;
|
||||
|
@ -139,3 +142,5 @@
|
|||
*/
|
||||
- (void)removeDelegate: (id <XMPPContactManagerDelegate>)delegate;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -21,8 +21,9 @@
|
|||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#import "XMPPContact.h"
|
||||
#import "XMPPContactManager.h"
|
||||
#import "XMPPContact.h"
|
||||
#import "XMPPContact+Private.h"
|
||||
#import "XMPPJID.h"
|
||||
#import "XMPPMulticastDelegate.h"
|
||||
#import "XMPPPresence.h"
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#import "XMPPConnection.h"
|
||||
#import "XMPPDiscoNode.h"
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class XMPPJID;
|
||||
|
||||
/**
|
||||
|
@ -53,6 +55,12 @@
|
|||
*/
|
||||
@property (readonly) OFString *capsNode;
|
||||
|
||||
+ (instancetype)discoNodeWithJID: (XMPPJID *)JID
|
||||
node: (nullable OFString *)node OF_UNAVAILABLE;
|
||||
+ (instancetype)discoNodeWithJID: (XMPPJID *)JID
|
||||
node: (nullable OFString *)node
|
||||
name: (nullable OFString *)name OF_UNAVAILABLE;
|
||||
|
||||
/**
|
||||
* \brief Creates a new autoreleased XMPPDiscoEntity with the specified
|
||||
* connection.
|
||||
|
@ -73,6 +81,12 @@
|
|||
+ (instancetype)discoEntityWithConnection: (XMPPConnection *)connection
|
||||
capsNode: (OFString *)capsNode;
|
||||
|
||||
- initWithJID: (XMPPJID *)JID
|
||||
node: (nullable OFString *)node OF_UNAVAILABLE;
|
||||
- initWithJID: (XMPPJID *)JID
|
||||
node: (nullable OFString *)node
|
||||
name: (nullable OFString *)name OF_UNAVAILABLE;
|
||||
|
||||
/**
|
||||
* \brief Initializes an already allocated XMPPDiscoEntity with the specified
|
||||
* connection.
|
||||
|
@ -93,7 +107,7 @@
|
|||
* \return An initialized XMPPDiscoEntity
|
||||
*/
|
||||
- initWithConnection: (XMPPConnection *)connection
|
||||
capsNode: (OFString*)capsNode;
|
||||
capsNode: (nullable OFString *)capsNode OF_DESIGNATED_INITIALIZER;
|
||||
|
||||
/**
|
||||
* \brief Adds a XMPPDiscoNode to provide responses for.
|
||||
|
@ -109,3 +123,5 @@
|
|||
*/
|
||||
- (OFString *)capsHash;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
*/
|
||||
|
||||
#import "XMPPDiscoEntity.h"
|
||||
#import "XMPPDiscoNode.h"
|
||||
#import "XMPPDiscoNode+Private.h"
|
||||
#import "XMPPDiscoIdentity.h"
|
||||
#import "XMPPIQ.h"
|
||||
#import "namespaces.h"
|
||||
|
@ -47,11 +49,19 @@
|
|||
capsNode: nil];
|
||||
}
|
||||
|
||||
- initWithJID: (XMPPJID *)JID
|
||||
node: (nullable OFString *)node
|
||||
name: (nullable OFString *)name
|
||||
{
|
||||
OF_INVALID_INIT_METHOD
|
||||
}
|
||||
|
||||
- initWithConnection: (XMPPConnection *)connection
|
||||
capsNode: (OFString *)capsNode
|
||||
{
|
||||
self = [super initWithJID: [connection JID]
|
||||
node: nil];
|
||||
node: nil
|
||||
name: nil];
|
||||
|
||||
@try {
|
||||
_discoNodes = [[OFMutableDictionary alloc] init];
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#import <ObjFW/ObjFW.h>
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* \brief A class describing a Service Discovery Identity
|
||||
*/
|
||||
|
@ -32,11 +34,11 @@
|
|||
}
|
||||
|
||||
/// \brief The category of the identity
|
||||
@property (readonly) OFString *category;
|
||||
@property (readonly, nonatomic) OFString *category;
|
||||
/// \brief The name of the identity, might be unset
|
||||
@property (readonly) OFString *name;
|
||||
@property (readonly, nonatomic) OFString *name;
|
||||
/// \brief The type of the identity
|
||||
@property (readonly) OFString *type;
|
||||
@property (readonly, nonatomic) OFString *type;
|
||||
|
||||
/**
|
||||
* \brief Creates a new autoreleased XMPPDiscoIdentity with the specified
|
||||
|
@ -49,7 +51,7 @@
|
|||
*/
|
||||
+ (instancetype)identityWithCategory: (OFString *)category
|
||||
type: (OFString *)type
|
||||
name: (OFString*)name;
|
||||
name: (nullable OFString *)name;
|
||||
|
||||
/**
|
||||
* \brief Creates a new autoreleased XMPPDiscoIdentity with the specified
|
||||
|
@ -62,6 +64,8 @@
|
|||
+ (instancetype)identityWithCategory: (OFString *)category
|
||||
type: (OFString *)type;
|
||||
|
||||
- init OF_UNAVAILABLE;
|
||||
|
||||
/**
|
||||
* \brief Initializes an already allocated XMPPDiscoIdentity with the specified
|
||||
* category, type and name.
|
||||
|
@ -73,7 +77,7 @@
|
|||
*/
|
||||
- initWithCategory: (OFString *)category
|
||||
type: (OFString *)type
|
||||
name: (OFString*)name;
|
||||
name: (nullable OFString *)name OF_DESIGNATED_INITIALIZER;
|
||||
|
||||
/**
|
||||
* \brief Initializes an already allocated XMPPDiscoIdentity with the specified
|
||||
|
@ -86,3 +90,5 @@
|
|||
- initWithCategory: (OFString *)category
|
||||
type: (OFString *)type;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -73,14 +73,7 @@
|
|||
|
||||
- init
|
||||
{
|
||||
@try {
|
||||
[self doesNotRecognizeSelector: _cmd];
|
||||
} @catch (id e) {
|
||||
[self release];
|
||||
@throw e;
|
||||
}
|
||||
|
||||
abort();
|
||||
OF_INVALID_INIT_METHOD
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
|
|
15
src/XMPPDiscoNode+Private.h
Normal file
15
src/XMPPDiscoNode+Private.h
Normal 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
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#import <ObjFW/ObjFW.h>
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class XMPPDiscoIdentity;
|
||||
@class XMPPJID;
|
||||
|
||||
|
@ -40,17 +42,17 @@
|
|||
}
|
||||
|
||||
/// \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
|
||||
@property (readonly) OFString *node;
|
||||
@property (readonly, nonatomic) OFString *node;
|
||||
/// \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
|
||||
@property (readonly) OFSortedList *identities;
|
||||
@property (readonly, nonatomic) OFSortedList *identities;
|
||||
/// \brief The node's list of features
|
||||
@property (readonly) OFSortedList *features;
|
||||
@property (readonly, nonatomic) OFSortedList *features;
|
||||
/// \brief The node's children
|
||||
@property (readonly) OFDictionary *childNodes;
|
||||
@property (readonly, nonatomic) OFDictionary *childNodes;
|
||||
|
||||
/**
|
||||
* \brief Creates a new autoreleased XMPPDiscoNode with the specified
|
||||
|
@ -61,7 +63,7 @@
|
|||
* \return A new autoreleased XMPPDiscoNode
|
||||
*/
|
||||
+ (instancetype)discoNodeWithJID: (XMPPJID *)JID
|
||||
node: (OFString*)node;
|
||||
node: (nullable OFString *)node;
|
||||
|
||||
/**
|
||||
* \brief Creates a new autoreleased XMPPDiscoNode with the specified
|
||||
|
@ -73,8 +75,8 @@
|
|||
* \return A new autoreleased XMPPDiscoNode
|
||||
*/
|
||||
+ (instancetype)discoNodeWithJID: (XMPPJID *)JID
|
||||
node: (OFString*)node
|
||||
name: (OFString*)name;
|
||||
node: (nullable OFString *)node
|
||||
name: (nullable OFString *)name;
|
||||
|
||||
/**
|
||||
* \brief Initializes an already allocated XMPPDiscoNode with the specified
|
||||
|
@ -85,7 +87,7 @@
|
|||
* \return An initialized XMPPDiscoNode
|
||||
*/
|
||||
- initWithJID: (XMPPJID *)JID
|
||||
node: (OFString*)node;
|
||||
node: (nullable OFString *)node;
|
||||
|
||||
/**
|
||||
* \brief Initializes an already allocated XMPPDiscoNode with the specified
|
||||
|
@ -97,8 +99,8 @@
|
|||
* \return An initialized XMPPDiscoNode
|
||||
*/
|
||||
- initWithJID: (XMPPJID *)JID
|
||||
node: (OFString*)node
|
||||
name: (OFString*)name;
|
||||
node: (nullable OFString *)node
|
||||
name: (nullable OFString *)name OF_DESIGNATED_INITIALIZER;
|
||||
|
||||
/**
|
||||
* \brief Adds an XMPPDiscoIdentity to the node
|
||||
|
@ -120,9 +122,6 @@
|
|||
* \param node The XMPPDiscoNode to add as child
|
||||
*/
|
||||
- (void)addChildNode: (XMPPDiscoNode *)node;
|
||||
|
||||
- (bool)XMPP_handleItemsIQ: (XMPPIQ*)IQ
|
||||
connection: (XMPPConnection*)connection;
|
||||
- (bool)XMPP_handleInfoIQ: (XMPPIQ*)IQ
|
||||
connection: (XMPPConnection*)connection;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -21,11 +21,12 @@
|
|||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#import "XMPPDiscoNode.h"
|
||||
#import "XMPPDiscoNode+Private.h"
|
||||
#import "XMPPConnection.h"
|
||||
#import "XMPPIQ.h"
|
||||
#import "XMPPJID.h"
|
||||
#import "XMPPDiscoEntity.h"
|
||||
#import "XMPPDiscoNode.h"
|
||||
#import "XMPPDiscoIdentity.h"
|
||||
#import "namespaces.h"
|
||||
|
||||
|
@ -98,6 +99,11 @@
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (OFDictionary *)childNodes
|
||||
{
|
||||
return [[_childNodes copy] autorelease];
|
||||
}
|
||||
|
||||
- (void)addIdentity: (XMPPDiscoIdentity *)identity
|
||||
{
|
||||
[_identities insertObject: identity];
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#import <ObjFW/ObjFW.h>
|
||||
#import "XMPPAuthenticator.h"
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* \brief A class to authenticate using SASL EXTERNAL
|
||||
*/
|
||||
|
@ -40,5 +42,7 @@
|
|||
* \param authzid The authzid to get authorization for
|
||||
* \return A new autoreleased XMPPEXTERNALAuth
|
||||
*/
|
||||
+ (instancetype)EXTERNALAuthWithAuthzid: (OFString*)authzid;
|
||||
+ (instancetype)EXTERNALAuthWithAuthzid: (nullable OFString *)authzid;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#import <ObjFW/ObjFW.h>
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class XMPPConnection;
|
||||
@class XMPPAuthenticator;
|
||||
|
||||
|
@ -35,7 +37,7 @@
|
|||
}
|
||||
|
||||
/// \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.
|
||||
|
@ -44,7 +46,9 @@
|
|||
* for this exception
|
||||
* \return A new XMPPException
|
||||
*/
|
||||
+ (instancetype)exceptionWithConnection: (XMPPConnection*)connection;
|
||||
+ (instancetype)exceptionWithConnection: (nullable XMPPConnection *)connection;
|
||||
|
||||
- init OF_UNAVAILABLE;
|
||||
|
||||
/**
|
||||
* \brief Initializes an already allocated XMPPException.
|
||||
|
@ -53,7 +57,8 @@
|
|||
* for this exception
|
||||
* \return An initialized XMPPException
|
||||
*/
|
||||
- initWithConnection: (XMPPConnection*)connection;
|
||||
- initWithConnection: (nullable XMPPConnection *)connection
|
||||
OF_DESIGNATED_INITIALIZER;
|
||||
@end
|
||||
|
||||
/**
|
||||
|
@ -65,9 +70,9 @@
|
|||
}
|
||||
|
||||
/// \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
|
||||
@property (readonly, copy) OFString *reason;
|
||||
@property (readonly, nonatomic) OFString *reason;
|
||||
|
||||
/**
|
||||
* \brief Creates a new XMPPStreamErrorException.
|
||||
|
@ -77,10 +82,12 @@
|
|||
* \param reason The descriptive free-form text specified by the stream error
|
||||
* \return A new XMPPStreamErrorException
|
||||
*/
|
||||
+ (instancetype)exceptionWithConnection: (XMPPConnection*)connection
|
||||
+ (instancetype)exceptionWithConnection: (nullable XMPPConnection *)connection
|
||||
condition: (OFString *)condition
|
||||
reason: (OFString *)reason;
|
||||
|
||||
- initWithConnection: (nullable XMPPConnection *)connection OF_UNAVAILABLE;
|
||||
|
||||
/**
|
||||
* \brief Initializes an already allocated XMPPStreamErrorException.
|
||||
*
|
||||
|
@ -89,9 +96,9 @@
|
|||
* \param reason The descriptive free-form text specified by the stream error
|
||||
* \return An initialized XMPPStreamErrorException
|
||||
*/
|
||||
- initWithConnection: (XMPPConnection*)connection
|
||||
- initWithConnection: (nullable XMPPConnection *)connection
|
||||
condition: (OFString *)condition
|
||||
reason: (OFString*)reason;
|
||||
reason: (OFString *)reason OF_DESIGNATED_INITIALIZER;
|
||||
@end
|
||||
|
||||
/**
|
||||
|
@ -104,9 +111,9 @@
|
|||
}
|
||||
|
||||
/// \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
|
||||
@property (readonly, copy) OFString *string;
|
||||
@property (readonly, nonatomic) OFString *string;
|
||||
|
||||
/**
|
||||
* \brief Creates a new XMPPStringPrepFailedException.
|
||||
|
@ -116,10 +123,12 @@
|
|||
* \param string The string that failed the stringprep profile
|
||||
* \return A new XMPPStringPrepFailedException
|
||||
*/
|
||||
+ (instancetype)exceptionWithConnection: (XMPPConnection*)connection
|
||||
+ (instancetype)exceptionWithConnection: (nullable XMPPConnection *)connection
|
||||
profile: (OFString *)profile
|
||||
string: (OFString *)string;
|
||||
|
||||
- initWithConnection: (nullable XMPPConnection *)connection OF_UNAVAILABLE;
|
||||
|
||||
/**
|
||||
* \brief Initializes an already allocated XMPPStringPrepFailedException.
|
||||
*
|
||||
|
@ -128,9 +137,9 @@
|
|||
* \param string The string that failed the stringprep profile
|
||||
* \return An initialized XMPPStringPrepFailedException
|
||||
*/
|
||||
- initWithConnection: (XMPPConnection*)connection
|
||||
- initWithConnection: (nullable XMPPConnection *)connection
|
||||
profile: (OFString *)profile
|
||||
string: (OFString*)string;
|
||||
string: (OFString *)string OF_DESIGNATED_INITIALIZER;
|
||||
@end
|
||||
|
||||
/**
|
||||
|
@ -142,9 +151,9 @@
|
|||
}
|
||||
|
||||
/// \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
|
||||
@property (readonly, copy) OFString *string;
|
||||
@property (readonly, nonatomic) OFString *string;
|
||||
|
||||
/**
|
||||
* \brief Creates a new XMPPIDNATranslationFailedException.
|
||||
|
@ -154,10 +163,12 @@
|
|||
* \param string The string that could not be translated
|
||||
* \return A new XMPPIDNATranslationFailedException
|
||||
*/
|
||||
+ (instancetype)exceptionWithConnection: (XMPPConnection*)connection
|
||||
+ (instancetype)exceptionWithConnection: (nullable XMPPConnection *)connection
|
||||
operation: (OFString *)operation
|
||||
string: (OFString *)string;
|
||||
|
||||
- initWithConnection: (nullable XMPPConnection *)connection OF_UNAVAILABLE;
|
||||
|
||||
/**
|
||||
* \brief Initializes an already allocated XMPPIDNATranslationFailedException.
|
||||
*
|
||||
|
@ -166,7 +177,7 @@
|
|||
* \param string The string that could not be translated
|
||||
* \return An initialized XMPPIDNATranslationFailedException
|
||||
*/
|
||||
- initWithConnection: (XMPPConnection*)connection
|
||||
- initWithConnection: (nullable XMPPConnection *)connection
|
||||
operation: (OFString *)operation
|
||||
string: (OFString *)string;
|
||||
@end
|
||||
|
@ -180,7 +191,7 @@
|
|||
}
|
||||
|
||||
/// \brief The reason the authentication failed
|
||||
@property (readonly, copy) OFString *reason;
|
||||
@property (readonly, nonatomic) OFString *reason;
|
||||
|
||||
/**
|
||||
* \brief Creates a new XMPPAuthFailedException.
|
||||
|
@ -189,9 +200,11 @@
|
|||
* \param reason The reason the authentication failed
|
||||
* \return A new XMPPAuthFailedException
|
||||
*/
|
||||
+ (instancetype)exceptionWithConnection: (XMPPConnection*)connection
|
||||
+ (instancetype)exceptionWithConnection: (nullable XMPPConnection *)connection
|
||||
reason: (OFString *)reason;
|
||||
|
||||
- initWithConnection: (nullable XMPPConnection *)connection OF_UNAVAILABLE;
|
||||
|
||||
/**
|
||||
* \brief Initializes an already allocated XMPPAuthFailedException.
|
||||
*
|
||||
|
@ -199,6 +212,8 @@
|
|||
* \param reason The reason the authentication failed
|
||||
* \return An initialized XMPPAuthFailedException
|
||||
*/
|
||||
- initWithConnection: (XMPPConnection*)connection
|
||||
reason: (OFString*)reason;
|
||||
- initWithConnection: (nullable XMPPConnection *)connection
|
||||
reason: (OFString *)reason OF_DESIGNATED_INITIALIZER;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#import "XMPPStorage.h"
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class OFMutableDictionary;
|
||||
|
||||
@interface XMPPFileStorage: OFObject <XMPPStorage>
|
||||
|
@ -32,5 +34,8 @@
|
|||
OFMutableDictionary *_data;
|
||||
}
|
||||
|
||||
- init OF_UNAVAILABLE;
|
||||
- initWithFile: (OFString *)file;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -40,14 +40,7 @@
|
|||
@implementation XMPPFileStorage
|
||||
- init
|
||||
{
|
||||
@try {
|
||||
[self doesNotRecognizeSelector: _cmd];
|
||||
} @catch (id e) {
|
||||
[self release];
|
||||
@throw e;
|
||||
}
|
||||
|
||||
abort();
|
||||
OF_INVALID_INIT_METHOD
|
||||
}
|
||||
|
||||
- initWithFile: (OFString *)file
|
||||
|
@ -120,12 +113,9 @@
|
|||
|
||||
- (id)XMPP_objectForPath: (OFString *)path
|
||||
{
|
||||
OFArray *pathComponents = [path componentsSeparatedByString: @"."];
|
||||
OFEnumerator *enumerator = [pathComponents objectEnumerator];
|
||||
OFString *component;
|
||||
id object = _data;
|
||||
|
||||
while ((component = [enumerator nextObject]) != nil)
|
||||
for (OFString *component in [path componentsSeparatedByString: @"."])
|
||||
object = [object objectForKey: component];
|
||||
|
||||
return object;
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#import "XMPPStanza.h"
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* \brief A class describing an IQ stanza.
|
||||
*/
|
||||
|
@ -65,7 +67,7 @@
|
|||
*/
|
||||
- (XMPPIQ *)errorIQWithType: (OFString *)type
|
||||
condition: (OFString *)condition
|
||||
text: (OFString*)text;
|
||||
text: (nullable OFString *)text;
|
||||
|
||||
/**
|
||||
* \brief Generates an error IQ for the receiving object.
|
||||
|
@ -77,3 +79,5 @@
|
|||
- (XMPPIQ *)errorIQWithType: (OFString *)type
|
||||
condition: (OFString *)condition;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#import <ObjFW/ObjFW.h>
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* \brief A class for easy handling of JIDs.
|
||||
*/
|
||||
|
@ -32,11 +34,11 @@
|
|||
}
|
||||
|
||||
/// \brief The JID's localpart
|
||||
@property (copy) OFString *node;
|
||||
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *node;
|
||||
/// \brief The JID's domainpart
|
||||
@property (copy) OFString *domain;
|
||||
@property (nonatomic, copy) OFString *domain;
|
||||
/// \brief The JID's resourcepart
|
||||
@property (copy) OFString *resource;
|
||||
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *resource;
|
||||
|
||||
/**
|
||||
* \brief Creates a new autoreleased XMPPJID.
|
||||
|
@ -75,3 +77,5 @@
|
|||
*/
|
||||
- (OFString *)fullJID;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#import "XMPPExceptions.h"
|
||||
|
||||
@implementation XMPPJID
|
||||
@synthesize node = _node, domain = _domain, resource = _resource;
|
||||
|
||||
+ (instancetype)JID
|
||||
{
|
||||
return [[[self alloc] init] autorelease];
|
||||
|
@ -132,11 +134,6 @@
|
|||
[old release];
|
||||
}
|
||||
|
||||
- (OFString*)node
|
||||
{
|
||||
return [[_node copy] autorelease];
|
||||
}
|
||||
|
||||
- (void)setDomain: (OFString *)domain
|
||||
{
|
||||
OFString *old = _domain;
|
||||
|
@ -160,11 +157,6 @@
|
|||
[old release];
|
||||
}
|
||||
|
||||
- (OFString*)domain
|
||||
{
|
||||
return [[_domain copy] autorelease];
|
||||
}
|
||||
|
||||
- (void)setResource: (OFString *)resource
|
||||
{
|
||||
OFString *old = _resource;
|
||||
|
@ -194,11 +186,6 @@
|
|||
[old release];
|
||||
}
|
||||
|
||||
- (OFString*)resource
|
||||
{
|
||||
return [[_resource copy] autorelease];
|
||||
}
|
||||
|
||||
- (OFString *)bareJID
|
||||
{
|
||||
if (_node != nil)
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#import "XMPPStanza.h"
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* \brief A class describing a message stanza.
|
||||
*/
|
||||
|
@ -43,7 +45,7 @@
|
|||
* \param ID The value for the stanza's id attribute
|
||||
* \return A new autoreleased XMPPMessage
|
||||
*/
|
||||
+ (instancetype)messageWithID: (OFString*)ID;
|
||||
+ (instancetype)messageWithID: (nullable OFString *)ID;
|
||||
|
||||
/**
|
||||
* \brief Creates a new autoreleased XMPPMessage with the specified type.
|
||||
|
@ -51,7 +53,7 @@
|
|||
* \param type The value for the stanza's type attribute
|
||||
* \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.
|
||||
|
@ -60,8 +62,8 @@
|
|||
* \param ID The value for the stanza's id attribute
|
||||
* \return A new autoreleased XMPPMessage
|
||||
*/
|
||||
+ (instancetype)messageWithType: (OFString*)type
|
||||
ID: (OFString*)ID;
|
||||
+ (instancetype)messageWithType: (nullable OFString *)type
|
||||
ID: (nullable OFString *)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
|
||||
* \return A initialized XMPPMessage
|
||||
*/
|
||||
- initWithID: (OFString*)ID;
|
||||
- initWithID: (nullable OFString *)ID;
|
||||
|
||||
/**
|
||||
* \brief Initializes an already allocated XMPPMessage with the specified type.
|
||||
|
@ -77,7 +79,7 @@
|
|||
* \param type The value for the stanza's type attribute
|
||||
* \return A initialized XMPPMessage
|
||||
*/
|
||||
- initWithType: (OFString*)type;
|
||||
- initWithType: (nullable OFString *)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
|
||||
* \return A initialized XMPPMessage
|
||||
*/
|
||||
- initWithType: (OFString*)type
|
||||
ID: (OFString*)ID;
|
||||
- initWithType: (nullable OFString *)type
|
||||
ID: (nullable OFString *)ID OF_DESIGNATED_INITIALIZER;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
#import <ObjFW/OFObject.h>
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class OFDataArray;
|
||||
|
||||
/**
|
||||
|
@ -53,7 +55,7 @@
|
|||
* \param object The object to broadcast
|
||||
*/
|
||||
- (bool)broadcastSelector: (SEL)selector
|
||||
withObject: (id)object;
|
||||
withObject: (nullable id)object;
|
||||
|
||||
/**
|
||||
* \brief Broadcasts a selector with two objects to all registered delegates.
|
||||
|
@ -63,6 +65,8 @@
|
|||
* \param object2 The second object to broadcast
|
||||
*/
|
||||
- (bool)broadcastSelector: (SEL)selector
|
||||
withObject: (id)object1
|
||||
withObject: (id)object2;
|
||||
withObject: (nullable id)object1
|
||||
withObject: (nullable id)object2;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#import <ObjFW/ObjFW.h>
|
||||
#import "XMPPAuthenticator.h"
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* \brief A class to authenticate using SASL PLAIN
|
||||
*/
|
||||
|
@ -34,8 +36,8 @@
|
|||
* \param password The password to authenticate with
|
||||
* \return A new autoreleased XMPPPLAINAuth
|
||||
*/
|
||||
+ (instancetype)PLAINAuthWithAuthcid: (OFString*)authcid
|
||||
password: (OFString*)password;
|
||||
+ (instancetype)PLAINAuthWithAuthcid: (nullable OFString *)authcid
|
||||
password: (nullable OFString *)password;
|
||||
|
||||
/**
|
||||
* \brief Creates a new autoreleased XMPPPLAINAuth with an authzid, authcid and
|
||||
|
@ -46,7 +48,9 @@
|
|||
* \param password The password to authenticate with
|
||||
* \return A new autoreleased XMPPPLAINAuth
|
||||
*/
|
||||
+ (instancetype)PLAINAuthWithAuthzid: (OFString*)authzid
|
||||
authcid: (OFString*)authcid
|
||||
password: (OFString*)password;
|
||||
+ (instancetype)PLAINAuthWithAuthzid: (nullable OFString *)authzid
|
||||
authcid: (nullable OFString *)authcid
|
||||
password: (nullable OFString *)password;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#import "XMPPStanza.h"
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* \brief A class describing a presence stanza.
|
||||
*/
|
||||
|
@ -32,20 +34,25 @@
|
|||
OFNumber *_priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* The value of the stanza's type attribute.
|
||||
*/
|
||||
@property OF_NULL_RESETTABLE_PROPERTY (nonatomic, copy) OFString *type;
|
||||
|
||||
/**
|
||||
* The text content of the status element.
|
||||
*/
|
||||
@property (copy) OFString *status;
|
||||
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *status;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@property (copy) OFNumber *priority;
|
||||
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFNumber *priority;
|
||||
|
||||
/**
|
||||
* \brief Creates a new autoreleased XMPPPresence.
|
||||
|
@ -60,7 +67,7 @@
|
|||
* \param ID The value for the stanza's id attribute
|
||||
* \return A new autoreleased XMPPPresence
|
||||
*/
|
||||
+ (instancetype)presenceWithID: (OFString*)ID;
|
||||
+ (instancetype)presenceWithID: (nullable OFString *)ID;
|
||||
|
||||
/**
|
||||
* \brief Creates a new autoreleased XMPPPresence with the specified type.
|
||||
|
@ -68,7 +75,7 @@
|
|||
* \param type The value for the stanza's type attribute
|
||||
* \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
|
||||
|
@ -78,8 +85,8 @@
|
|||
* \param ID The value for the stanza's id attribute
|
||||
* \return A new autoreleased XMPPPresence
|
||||
*/
|
||||
+ (instancetype)presenceWithType: (OFString*)type
|
||||
ID: (OFString*)ID;
|
||||
+ (instancetype)presenceWithType: (nullable OFString *)type
|
||||
ID: (nullable OFString *)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
|
||||
* \return A initialized XMPPPresence
|
||||
*/
|
||||
- initWithID: (OFString*)ID;
|
||||
- initWithID: (nullable OFString *)ID;
|
||||
|
||||
/**
|
||||
* \brief Initializes an already allocated XMPPPresence with the specified type.
|
||||
|
@ -95,7 +102,7 @@
|
|||
* \param type The value for the stanza's type attribute
|
||||
* \return A initialized XMPPPresence
|
||||
*/
|
||||
- initWithType: (OFString*)type;
|
||||
- initWithType: (nullable OFString *)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
|
||||
* \return A initialized XMPPPresence
|
||||
*/
|
||||
- initWithType: (OFString*)type
|
||||
ID: (OFString*)ID;
|
||||
- initWithType: (nullable OFString *)type
|
||||
ID: (nullable OFString *)ID;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -49,6 +49,8 @@ show_to_int(OFString *show)
|
|||
}
|
||||
|
||||
@implementation XMPPPresence
|
||||
@dynamic type;
|
||||
|
||||
+ (instancetype)presence
|
||||
{
|
||||
return [[[self alloc] init] autorelease];
|
||||
|
@ -135,12 +137,12 @@ show_to_int(OFString *show)
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (OFString*)type
|
||||
- (void)setType: (OFString *)type
|
||||
{
|
||||
if (_type == nil)
|
||||
return @"available";
|
||||
if (type == nil)
|
||||
type = @"available";
|
||||
|
||||
return [[_type copy] autorelease];
|
||||
[super setType: type];
|
||||
}
|
||||
|
||||
- (void)setShow: (OFString *)show
|
||||
|
@ -162,11 +164,6 @@ show_to_int(OFString *show)
|
|||
[old release];
|
||||
}
|
||||
|
||||
- (OFString*)show
|
||||
{
|
||||
return [[_show copy] autorelease];
|
||||
}
|
||||
|
||||
- (void)setStatus: (OFString *)status
|
||||
{
|
||||
OFXMLElement *oldStatus = [self elementForName: @"status"
|
||||
|
@ -186,11 +183,6 @@ show_to_int(OFString *show)
|
|||
[old release];
|
||||
}
|
||||
|
||||
- (OFString*)status
|
||||
{
|
||||
return [[_status copy] autorelease];
|
||||
}
|
||||
|
||||
- (void)setPriority: (OFNumber *)priority
|
||||
{
|
||||
intmax_t prio = [priority intMaxValue];
|
||||
|
@ -216,11 +208,6 @@ show_to_int(OFString *show)
|
|||
[old release];
|
||||
}
|
||||
|
||||
- (OFNumber*)priority
|
||||
{
|
||||
return [[_priority copy] autorelease];
|
||||
}
|
||||
|
||||
- (of_comparison_result_t)compare: (id <OFComparing>)object
|
||||
{
|
||||
XMPPPresence *otherPresence;
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#import "XMPPConnection.h"
|
||||
#import "XMPPStorage.h"
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class XMPPRosterItem;
|
||||
@class XMPPIQ;
|
||||
@class XMPPRoster;
|
||||
|
@ -36,9 +38,6 @@
|
|||
* of a XMPPRoster
|
||||
*/
|
||||
@protocol XMPPRosterDelegate
|
||||
#ifndef XMPP_ROSTER_M
|
||||
<OFObject>
|
||||
#endif
|
||||
@optional
|
||||
/**
|
||||
* \brief This callback is called after the roster was received (as a result of
|
||||
|
@ -80,22 +79,25 @@
|
|||
*
|
||||
* 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
|
||||
* 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.
|
||||
*
|
||||
* \param connection The connection roster related stanzas
|
||||
* are send and received over
|
||||
* \param connection The connection roster related stanzas are send and
|
||||
* received over
|
||||
* \return An initialized XMPPRoster
|
||||
*/
|
||||
- initWithConnection: (XMPPConnection*)connection;
|
||||
- initWithConnection: (XMPPConnection *)connection OF_DESIGNATED_INITIALIZER;
|
||||
|
||||
/**
|
||||
* \brief Requests the roster from the server.
|
||||
|
@ -136,12 +138,6 @@
|
|||
* \param delegate The delegate to remove
|
||||
*/
|
||||
- (void)removeDelegate: (id <XMPPRosterDelegate>)delegate;
|
||||
|
||||
- (void)XMPP_updateRosterItem: (XMPPRosterItem*)rosterItem;
|
||||
- (void)XMPP_handleInitialRosterForConnection: (XMPPConnection*)connection
|
||||
IQ: (XMPPIQ*)iq;
|
||||
- (XMPPRosterItem*)XMPP_rosterItemWithXMLElement: (OFXMLElement*)element;
|
||||
@end
|
||||
|
||||
@interface OFObject (XMPPRosterDelegate) <XMPPRosterDelegate>
|
||||
@end
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -39,10 +39,26 @@
|
|||
#import "XMPPMulticastDelegate.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
|
||||
@synthesize connection = _connection, dataStorage = _dataStorage;
|
||||
@synthesize rosterItems = _rosterItems;
|
||||
|
||||
- init
|
||||
{
|
||||
OF_INVALID_INIT_METHOD
|
||||
}
|
||||
|
||||
- initWithConnection: (XMPPConnection *)connection
|
||||
{
|
||||
self = [super init];
|
||||
|
@ -103,24 +119,24 @@
|
|||
}
|
||||
|
||||
- (bool)connection: (XMPPConnection *)connection
|
||||
didReceiveIQ: (XMPPIQ*)iq
|
||||
didReceiveIQ: (XMPPIQ *)IQ
|
||||
{
|
||||
OFXMLElement *rosterElement;
|
||||
OFXMLElement *element;
|
||||
XMPPRosterItem *rosterItem;
|
||||
OFString *origin;
|
||||
|
||||
rosterElement = [iq elementForName: @"query"
|
||||
rosterElement = [IQ elementForName: @"query"
|
||||
namespace: XMPP_NS_ROSTER];
|
||||
|
||||
if (rosterElement == nil)
|
||||
return false;
|
||||
|
||||
if (![[iq type] isEqual: @"set"])
|
||||
if (![[IQ type] isEqual: @"set"])
|
||||
return false;
|
||||
|
||||
// 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]])
|
||||
return false;
|
||||
|
||||
|
@ -146,7 +162,7 @@
|
|||
[_dataStorage save];
|
||||
}
|
||||
|
||||
[connection sendStanza: [iq resultIQ]];
|
||||
[connection sendStanza: [IQ resultIQ]];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -224,16 +240,6 @@
|
|||
_dataStorage = dataStorage;
|
||||
}
|
||||
|
||||
- (XMPPConnection*)connection
|
||||
{
|
||||
return _connection;
|
||||
}
|
||||
|
||||
- (id <XMPPStorage>)dataStorage
|
||||
{
|
||||
return _dataStorage;
|
||||
}
|
||||
|
||||
- (void)XMPP_updateRosterItem: (XMPPRosterItem *)rosterItem
|
||||
{
|
||||
if ([_connection supportsRosterVersioning]) {
|
||||
|
@ -313,11 +319,7 @@
|
|||
- (void)XMPP_handleInitialRosterForConnection: (XMPPConnection *)connection
|
||||
IQ: (XMPPIQ *)IQ
|
||||
{
|
||||
OFXMLElement *rosterElement;
|
||||
OFEnumerator *enumerator;
|
||||
OFXMLElement *element;
|
||||
|
||||
rosterElement = [IQ elementForName: @"query"
|
||||
OFXMLElement *rosterElement = [IQ elementForName: @"query"
|
||||
namespace: XMPP_NS_ROSTER];
|
||||
|
||||
if ([connection supportsRosterVersioning]) {
|
||||
|
@ -350,8 +352,7 @@
|
|||
forPath: @"roster.items"];
|
||||
}
|
||||
|
||||
enumerator = [[rosterElement children] objectEnumerator];
|
||||
while ((element = [enumerator nextObject]) != nil) {
|
||||
for (OFXMLElement *element in [rosterElement children]) {
|
||||
OFAutoreleasePool *pool;
|
||||
XMPPRosterItem *rosterItem;
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#import <ObjFW/ObjFW.h>
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class XMPPJID;
|
||||
|
||||
/**
|
||||
|
@ -37,13 +39,13 @@
|
|||
}
|
||||
|
||||
/// \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
|
||||
@property (copy) OFString *name;
|
||||
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *name;
|
||||
/// \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
|
||||
@property (copy) OFArray *groups;
|
||||
@property (nonatomic, copy) OFArray OF_GENERIC(OFString *) *groups;
|
||||
|
||||
/**
|
||||
* \brief Creates a new autoreleased roster item.
|
||||
|
@ -52,3 +54,5 @@
|
|||
*/
|
||||
+ (instancetype)rosterItem;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#import "XMPPAuthenticator.h"
|
||||
#import "XMPPConnection.h"
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* \brief A class to authenticate using SCRAM
|
||||
*/
|
||||
|
@ -49,8 +51,8 @@
|
|||
* \param plusAvailable Whether the PLUS variant was offered
|
||||
* \return A new autoreleased XMPPSCRAMAuth
|
||||
*/
|
||||
+ (instancetype)SCRAMAuthWithAuthcid: (OFString*)authcid
|
||||
password: (OFString*)password
|
||||
+ (instancetype)SCRAMAuthWithAuthcid: (nullable OFString *)authcid
|
||||
password: (nullable OFString *)password
|
||||
connection: (XMPPConnection *)connection
|
||||
hash: (Class)hash
|
||||
plusAvailable: (bool)plusAvailable;
|
||||
|
@ -67,13 +69,19 @@
|
|||
* \param plusAvailable Whether the PLUS variant was offered
|
||||
* \return A new autoreleased XMPPSCRAMAuth
|
||||
*/
|
||||
+ (instancetype)SCRAMAuthWithAuthzid: (OFString*)authzid
|
||||
authcid: (OFString*)authcid
|
||||
password: (OFString*)password
|
||||
+ (instancetype)SCRAMAuthWithAuthzid: (nullable OFString *)authzid
|
||||
authcid: (nullable OFString *)authcid
|
||||
password: (nullable OFString *)password
|
||||
connection: (XMPPConnection *)connection
|
||||
hash: (Class)hash
|
||||
plusAvailable: (bool)plusAvailable;
|
||||
|
||||
- initWithAuthcid: (nullable OFString *)authcid
|
||||
password: (nullable OFString *)password OF_UNAVAILABLE;
|
||||
- initWithAuthzid: (nullable OFString *)authzid
|
||||
authcid: (nullable OFString *)authcid
|
||||
password: (nullable OFString *)password OF_UNAVAILABLE;
|
||||
|
||||
/**
|
||||
* \brief Initializes an already allocated XMPPSCRAMAuth with an authcid and
|
||||
* password.
|
||||
|
@ -85,8 +93,8 @@
|
|||
* \param plusAvailable Whether the PLUS variant was offered
|
||||
* \return A initialized XMPPSCRAMAuth
|
||||
*/
|
||||
- initWithAuthcid: (OFString*)authcid
|
||||
password: (OFString*)password
|
||||
- initWithAuthcid: (nullable OFString *)authcid
|
||||
password: (nullable OFString *)password
|
||||
connection: (XMPPConnection *)connection
|
||||
hash: (Class)hash
|
||||
plusAvailable: (bool)plusAvailable;
|
||||
|
@ -103,21 +111,12 @@
|
|||
* \param plusAvailable Whether the PLUS variant was offered
|
||||
* \return A initialized XMPPSCRAMAuth
|
||||
*/
|
||||
- initWithAuthzid: (OFString*)authzid
|
||||
authcid: (OFString*)authcid
|
||||
password: (OFString*)password
|
||||
- initWithAuthzid: (nullable OFString *)authzid
|
||||
authcid: (nullable OFString *)authcid
|
||||
password: (nullable OFString *)password
|
||||
connection: (XMPPConnection *)connection
|
||||
hash: (Class)hash
|
||||
plusAvailable: (bool)plusAvailable;
|
||||
|
||||
/// \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
|
||||
plusAvailable: (bool)plusAvailable OF_DESIGNATED_INITIALIZER;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -37,6 +37,21 @@
|
|||
#define HMAC_IPAD 0x36
|
||||
#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
|
||||
+ (instancetype)SCRAMAuthWithAuthcid: (OFString *)authcid
|
||||
password: (OFString *)password
|
||||
|
@ -253,7 +268,8 @@
|
|||
[tmpArray addItems: [_GS2Header UTF8String]
|
||||
count: [_GS2Header UTF8StringLength]];
|
||||
if (_plusAvailable && [_connection encrypted]) {
|
||||
OFDataArray *channelBinding = [((SSLSocket*)[_connection socket])
|
||||
OFDataArray *channelBinding =
|
||||
[((SSLSocket *)[_connection socket])
|
||||
channelBindingDataWithType: @"tls-unique"];
|
||||
[tmpArray addItems: [channelBinding items]
|
||||
count: [channelBinding count]];
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
|
||||
#import <ObjFW/ObjFW.h>
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XMPPSRVEntry: OFObject
|
||||
{
|
||||
uint16_t _priority;
|
||||
|
@ -40,7 +42,7 @@
|
|||
@property (readonly) uint16_t weight;
|
||||
@property uint32_t accumulatedWeight;
|
||||
@property (readonly) uint16_t port;
|
||||
@property (readonly, copy) OFString *target;
|
||||
@property (readonly, nonatomic) OFString *target;
|
||||
|
||||
+ (instancetype)entryWithPriority: (uint16_t)priority
|
||||
weight: (uint16_t)weight
|
||||
|
@ -48,6 +50,7 @@
|
|||
target: (OFString *)target;
|
||||
+ (instancetype)entryWithResourceRecord: (ns_rr)resourceRecord
|
||||
handle: (ns_msg)handle;
|
||||
- init OF_UNAVAILABLE;
|
||||
- initWithPriority: (uint16_t)priority
|
||||
weight: (uint16_t)weight
|
||||
port: (uint16_t)port
|
||||
|
@ -63,13 +66,11 @@
|
|||
OFList *_list;
|
||||
}
|
||||
|
||||
@property (readonly, copy) OFString *domain;
|
||||
@property (readonly, nonatomic) OFString *domain;
|
||||
|
||||
+ (instancetype)lookupWithDomain: (OFString *)domain;
|
||||
- init OF_UNAVAILABLE;
|
||||
- initWithDomain: (OFString *)domain;
|
||||
|
||||
- (void)XMPP_lookup;
|
||||
- (void)XMPP_addEntry: (XMPPSRVEntry*)item;
|
||||
@end
|
||||
|
||||
@interface XMPPSRVEnumerator: OFEnumerator
|
||||
|
@ -80,5 +81,8 @@
|
|||
bool _done;
|
||||
}
|
||||
|
||||
- init OF_UNAVAILABLE;
|
||||
- initWithList: (OFList *)list;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -40,6 +40,15 @@
|
|||
|
||||
#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
|
||||
@synthesize priority = _priority, weight = _weight;
|
||||
@synthesize accumulatedWeight = _accumulatedWeight, port = _port;
|
||||
|
@ -65,14 +74,7 @@
|
|||
|
||||
- init
|
||||
{
|
||||
@try {
|
||||
[self doesNotRecognizeSelector: _cmd];
|
||||
} @catch (id e) {
|
||||
[self release];
|
||||
@throw e;
|
||||
}
|
||||
|
||||
abort();
|
||||
OF_INVALID_INIT_METHOD
|
||||
}
|
||||
|
||||
- initWithPriority: (uint16_t)priority
|
||||
|
@ -148,6 +150,11 @@
|
|||
return [[[self alloc] initWithDomain: domain] autorelease];
|
||||
}
|
||||
|
||||
- init
|
||||
{
|
||||
OF_INVALID_INIT_METHOD
|
||||
}
|
||||
|
||||
- initWithDomain: (OFString *)domain
|
||||
{
|
||||
self = [super init];
|
||||
|
@ -280,6 +287,11 @@
|
|||
@end
|
||||
|
||||
@implementation XMPPSRVEnumerator
|
||||
- init
|
||||
{
|
||||
OF_INVALID_INIT_METHOD
|
||||
}
|
||||
|
||||
- initWithList: (OFList *)list
|
||||
{
|
||||
self = [super init];
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#import <ObjFW/ObjFW.h>
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class XMPPJID;
|
||||
|
||||
/**
|
||||
|
@ -35,15 +37,15 @@
|
|||
}
|
||||
|
||||
/// \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
|
||||
@property (copy) XMPPJID *to;
|
||||
@property OF_NULLABLE_PROPERTY (nonatomic, copy) XMPPJID *to;
|
||||
/// \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
|
||||
@property (copy) OFString *ID;
|
||||
@property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *ID;
|
||||
/// \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.
|
||||
|
@ -62,7 +64,7 @@
|
|||
* \return A new autoreleased XMPPStanza
|
||||
*/
|
||||
+ (instancetype)stanzaWithName: (OFString *)name
|
||||
type: (OFString*)type;
|
||||
type: (nullable OFString *)type;
|
||||
|
||||
/**
|
||||
* \brief Creates a new autoreleased XMPPStanza with the specified name and ID.
|
||||
|
@ -72,7 +74,7 @@
|
|||
* \return A new autoreleased XMPPStanza
|
||||
*/
|
||||
+ (instancetype)stanzaWithName: (OFString *)name
|
||||
ID: (OFString*)ID;
|
||||
ID: (nullable OFString *)ID;
|
||||
|
||||
/**
|
||||
* \brief Creates a new autoreleased XMPPStanza with the specified name, type
|
||||
|
@ -84,8 +86,8 @@
|
|||
* \return A new autoreleased XMPPStanza
|
||||
*/
|
||||
+ (instancetype)stanzaWithName: (OFString *)name
|
||||
type: (OFString*)type
|
||||
ID: (OFString*)ID;
|
||||
type: (nullable OFString *)type
|
||||
ID: (nullable OFString *)ID;
|
||||
|
||||
/**
|
||||
* \brief Creates a new autoreleased XMPPStanza from an OFXMLElement.
|
||||
|
@ -95,6 +97,16 @@
|
|||
*/
|
||||
+ (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.
|
||||
*
|
||||
|
@ -112,7 +124,7 @@
|
|||
* \return A initialized XMPPStanza
|
||||
*/
|
||||
- initWithName: (OFString *)name
|
||||
type: (OFString*)type;
|
||||
type: (nullable OFString *)type;
|
||||
|
||||
/**
|
||||
* \brief Initializes an already allocated XMPPStanza with the specified name
|
||||
|
@ -123,7 +135,7 @@
|
|||
* \return A initialized XMPPStanza
|
||||
*/
|
||||
- initWithName: (OFString *)name
|
||||
ID: (OFString*)ID;
|
||||
ID: (nullable OFString *)ID;
|
||||
|
||||
/**
|
||||
* \brief Initializes an already allocated XMPPStanza with the specified name,
|
||||
|
@ -135,8 +147,8 @@
|
|||
* \return A initialized XMPPStanza
|
||||
*/
|
||||
- initWithName: (OFString *)name
|
||||
type: (OFString*)type
|
||||
ID: (OFString*)ID;
|
||||
type: (nullable OFString *)type
|
||||
ID: (nullable OFString *)ID;
|
||||
|
||||
/**
|
||||
* \brief Initializes an already allocated XMPPStanza based on a OFXMLElement.
|
||||
|
@ -146,3 +158,5 @@
|
|||
*/
|
||||
- initWithElement: (OFXMLElement *)element;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
#import "namespaces.h"
|
||||
|
||||
@implementation XMPPStanza
|
||||
@synthesize from = _from, to = _to, type = _type, ID = _ID;
|
||||
@synthesize language = _language;
|
||||
|
||||
+ (instancetype)stanzaWithName: (OFString *)name
|
||||
{
|
||||
return [[[self alloc] initWithName: name] autorelease];
|
||||
|
@ -63,6 +66,23 @@
|
|||
return [[[self alloc] initWithElement: element] autorelease];
|
||||
}
|
||||
|
||||
- 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
|
||||
|
@ -166,11 +186,6 @@
|
|||
stringValue: [from fullJID]];
|
||||
}
|
||||
|
||||
- (XMPPJID*)from
|
||||
{
|
||||
return [[_from copy] autorelease];
|
||||
}
|
||||
|
||||
- (void)setTo: (XMPPJID *)to
|
||||
{
|
||||
XMPPJID *old = _to;
|
||||
|
@ -184,11 +199,6 @@
|
|||
stringValue: [to fullJID]];
|
||||
}
|
||||
|
||||
- (XMPPJID*)to
|
||||
{
|
||||
return [[_to copy] autorelease];
|
||||
}
|
||||
|
||||
- (void)setType: (OFString *)type
|
||||
{
|
||||
OFString *old = _type;
|
||||
|
@ -202,11 +212,6 @@
|
|||
stringValue: type];
|
||||
}
|
||||
|
||||
- (OFString*)type
|
||||
{
|
||||
return [[_type copy] autorelease];
|
||||
}
|
||||
|
||||
- (void)setID: (OFString *)ID
|
||||
{
|
||||
OFString *old = _ID;
|
||||
|
@ -220,11 +225,6 @@
|
|||
stringValue: ID];
|
||||
}
|
||||
|
||||
- (OFString*)ID
|
||||
{
|
||||
return [[_ID copy] autorelease];
|
||||
}
|
||||
|
||||
- (void)setLanguage: (OFString *)language
|
||||
{
|
||||
OFString *old = _language;
|
||||
|
@ -240,9 +240,4 @@
|
|||
@"namespace"
|
||||
stringValue: language];
|
||||
}
|
||||
|
||||
- (OFString*)language
|
||||
{
|
||||
return [[_language copy] autorelease];
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -22,25 +22,29 @@
|
|||
|
||||
#import <ObjFW/OFObject.h>
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class OFString;
|
||||
@class OFArray;
|
||||
@class OFDictionary;
|
||||
|
||||
@protocol XMPPStorage <OFObject>
|
||||
- (void)save;
|
||||
- (void)setStringValue: (OFString*)string
|
||||
- (void)setStringValue: (nullable OFString *)string
|
||||
forPath: (OFString *)path;
|
||||
- (OFString*)stringValueForPath: (OFString*)path;
|
||||
- (nullable OFString *)stringValueForPath: (OFString *)path;
|
||||
- (void)setBooleanValue: (bool)boolean
|
||||
forPath: (OFString *)path;
|
||||
- (bool)booleanValueForPath: (OFString *)path;
|
||||
- (void)setIntegerValue: (intmax_t)integer
|
||||
forPath: (OFString *)path;
|
||||
- (intmax_t)integerValueForPath: (OFString *)path;
|
||||
- (void)setArray: (OFArray*)array
|
||||
- (void)setArray: (nullable OFArray *)array
|
||||
forPath: (OFString *)path;
|
||||
- (OFArray*)arrayForPath: (OFString*)path;
|
||||
- (void)setDictionary: (OFDictionary*)dictionary
|
||||
- (nullable OFArray *)arrayForPath: (OFString *)path;
|
||||
- (void)setDictionary: (nullable OFDictionary *)dictionary
|
||||
forPath: (OFString *)path;
|
||||
- (OFDictionary*)dictionaryForPath: (OFString*)path;
|
||||
- (nullable OFDictionary *)dictionaryForPath: (OFString *)path;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -23,11 +23,16 @@
|
|||
|
||||
#import "XMPPConnection.h"
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XMPPStreamManagement: OFObject <XMPPConnectionDelegate>
|
||||
{
|
||||
XMPPConnection *_connection;
|
||||
uint32_t _receivedCount;
|
||||
}
|
||||
|
||||
- init OF_UNAVAILABLE;
|
||||
- initWithConnection: (XMPPConnection *)connection;
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -26,6 +26,11 @@
|
|||
#import "namespaces.h"
|
||||
|
||||
@implementation XMPPStreamManagement
|
||||
- init
|
||||
{
|
||||
OF_INVALID_INIT_METHOD
|
||||
}
|
||||
|
||||
- initWithConnection: (XMPPConnection *)connection
|
||||
{
|
||||
self = [super init];
|
||||
|
|
|
@ -22,5 +22,9 @@
|
|||
|
||||
#import <ObjFW/OFXMLElementBuilder.h>
|
||||
|
||||
OF_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XMPPXMLElementBuilder: OFXMLElementBuilder
|
||||
@end
|
||||
|
||||
OF_ASSUME_NONNULL_END
|
||||
|
|
|
@ -38,9 +38,7 @@
|
|||
#import "XMPPFileStorage.h"
|
||||
|
||||
@interface AppDelegate: OFObject
|
||||
#ifdef OF_HAVE_OPTIONAL_PROTOCOLS
|
||||
<OFApplicationDelegate, XMPPConnectionDelegate, XMPPRosterDelegate>
|
||||
#endif
|
||||
{
|
||||
XMPPConnection *conn;
|
||||
XMPPRoster *roster;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue