Modernize coding style
This commit is contained in:
parent
d6f82eb3d5
commit
3438e3569b
37 changed files with 407 additions and 422 deletions
|
@ -56,8 +56,8 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @param password The password to authenticate with
|
* @param password The password to authenticate with
|
||||||
* @return A initialized XMPPAuthenticator
|
* @return A initialized XMPPAuthenticator
|
||||||
*/
|
*/
|
||||||
- initWithAuthcid: (nullable OFString *)authcid
|
- (instancetype)initWithAuthcid: (nullable OFString *)authcid
|
||||||
password: (nullable OFString *)password;
|
password: (nullable OFString *)password;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Initializes an already allocated XMPPSCRAMAuthenticator with an
|
* @brief Initializes an already allocated XMPPSCRAMAuthenticator with an
|
||||||
|
@ -68,9 +68,10 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @param password The password to authenticate with
|
* @param password The password to authenticate with
|
||||||
* @return A initialized XMPPAuthenticator
|
* @return A initialized XMPPAuthenticator
|
||||||
*/
|
*/
|
||||||
- initWithAuthzid: (nullable OFString *)authzid
|
- (instancetype)initWithAuthzid: (nullable OFString *)authzid
|
||||||
authcid: (nullable OFString *)authcid
|
authcid: (nullable OFString *)authcid
|
||||||
password: (nullable OFString *)password OF_DESIGNATED_INITIALIZER;
|
password: (nullable OFString *)password
|
||||||
|
OF_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Returns OFData containing the initial authentication message.
|
* @brief Returns OFData containing the initial authentication message.
|
||||||
|
|
|
@ -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
|
- (instancetype)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
|
- (instancetype)initWithAuthzid: (OFString *)authzid
|
||||||
authcid: (OFString *)authcid
|
authcid: (OFString *)authcid
|
||||||
password: (OFString *)password
|
password: (OFString *)password
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
|
|
|
@ -43,13 +43,13 @@ typedef void (^xmpp_callback_block_t)(XMPPConnection *_Nonnull,
|
||||||
|
|
||||||
#ifdef OF_HAVE_BLOCKS
|
#ifdef OF_HAVE_BLOCKS
|
||||||
+ (instancetype)callbackWithBlock: (xmpp_callback_block_t)callback;
|
+ (instancetype)callbackWithBlock: (xmpp_callback_block_t)callback;
|
||||||
- initWithBlock: (xmpp_callback_block_t)callback;
|
- (instancetype)initWithBlock: (xmpp_callback_block_t)callback;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
+ (instancetype)callbackWithTarget: (id)target
|
+ (instancetype)callbackWithTarget: (id)target
|
||||||
selector: (SEL)selector;
|
selector: (SEL)selector;
|
||||||
- initWithTarget: (id)target
|
- (instancetype)initWithTarget: (id)target
|
||||||
selector: (SEL)selector;
|
selector: (SEL)selector;
|
||||||
|
|
||||||
- (void)runWithIQ: (XMPPIQ *)iq
|
- (void)runWithIQ: (XMPPIQ *)iq
|
||||||
connection: (XMPPConnection *)connection;
|
connection: (XMPPConnection *)connection;
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
initWithBlock: block] autorelease];
|
initWithBlock: block] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithBlock: (xmpp_callback_block_t)block
|
- (instancetype)initWithBlock: (xmpp_callback_block_t)block
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
|
@ -56,8 +56,8 @@
|
||||||
selector: selector] autorelease];
|
selector: selector] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithTarget: (id)target
|
- (instancetype)initWithTarget: (id)target
|
||||||
selector: (SEL)selector
|
selector: (SEL)selector
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
|
|
|
@ -58,33 +58,46 @@
|
||||||
|
|
||||||
#define BUFFER_LENGTH 512
|
#define BUFFER_LENGTH 512
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_BEGIN
|
|
||||||
|
|
||||||
@interface XMPPConnection ()
|
@interface XMPPConnection ()
|
||||||
- (void)XMPP_startStream;
|
- (void)xmpp_socketDidConnect: (OFTCPSocket *)socket
|
||||||
- (void)XMPP_handleStream: (OFXMLElement *)element;
|
context: (OFArray *)nextSRVRecords
|
||||||
- (void)XMPP_handleTLS: (OFXMLElement *)element;
|
exception: (id)exception;
|
||||||
- (void)XMPP_handleSASL: (OFXMLElement *)element;
|
- (void)xmpp_tryNextSRVRecord: (OFArray *)SRVRecords;
|
||||||
- (void)XMPP_handleStanza: (OFXMLElement *)element;
|
- (void)xmpp_resolver: (OFDNSResolver *)resolver
|
||||||
- (void)XMPP_sendAuth: (OFString *)authName;
|
didResolveDomainName: (OFString *)domainName
|
||||||
- (void)XMPP_sendResourceBind;
|
answerRecords: (OFDictionary *)answerRecords
|
||||||
- (void)XMPP_sendStreamError: (OFString *)condition
|
authorityRecords: (OFDictionary *)authorityRecords
|
||||||
text: (nullable OFString *)text;
|
additionalRecords: (OFDictionary *)additionalRecords
|
||||||
- (void)XMPP_handleIQ: (XMPPIQ *)IQ;
|
context: (OFString *)domainToASCII
|
||||||
- (void)XMPP_handleMessage: (XMPPMessage *)message;
|
exception: (id)exception;
|
||||||
- (void)XMPP_handlePresence: (XMPPPresence *)presence;
|
- (bool)xmpp_parseBuffer: (const void *)buffer
|
||||||
- (void)XMPP_handleFeatures: (OFXMLElement *)element;
|
length: (size_t)length;
|
||||||
- (void)XMPP_handleResourceBindForConnection: (XMPPConnection *)connection
|
- (bool)xmpp_stream: (OFStream *)stream
|
||||||
|
didReadIntoBuffer: (char *)buffer
|
||||||
|
length: (size_t)length
|
||||||
|
exception: (OFException *)exception;
|
||||||
|
- (void)xmpp_startStream;
|
||||||
|
- (void)xmpp_handleStanza: (OFXMLElement *)element;
|
||||||
|
- (void)xmpp_handleStream: (OFXMLElement *)element;
|
||||||
|
- (void)xmpp_handleTLS: (OFXMLElement *)element;
|
||||||
|
- (void)xmpp_handleSASL: (OFXMLElement *)element;
|
||||||
|
- (void)xmpp_handleIQ: (XMPPIQ *)IQ;
|
||||||
|
- (void)xmpp_handleMessage: (XMPPMessage *)message;
|
||||||
|
- (void)xmpp_handlePresence: (XMPPPresence *)presence;
|
||||||
|
- (void)xmpp_handleFeatures: (OFXMLElement *)element;
|
||||||
|
- (void)xmpp_sendAuth: (OFString *)authName;
|
||||||
|
- (void)xmpp_sendResourceBind;
|
||||||
|
- (void)xmpp_sendStreamError: (OFString *)condition
|
||||||
|
text: (OFString *)text;
|
||||||
|
- (void)xmpp_handleResourceBindForConnection: (XMPPConnection *)connection
|
||||||
IQ: (XMPPIQ *)IQ;
|
IQ: (XMPPIQ *)IQ;
|
||||||
- (void)XMPP_sendSession;
|
- (void)xmpp_sendSession;
|
||||||
- (void)XMPP_handleSessionForConnection: (XMPPConnection *)connection
|
- (void)xmpp_handleSessionForConnection: (XMPPConnection *)connection
|
||||||
IQ: (XMPPIQ *)IQ;
|
IQ: (XMPPIQ *)IQ;
|
||||||
- (OFString *)XMPP_IDNAToASCII: (OFString *)domain;
|
- (OFString *)xmpp_IDNAToASCII: (OFString *)domain;
|
||||||
- (XMPPMulticastDelegate *)XMPP_delegates;
|
- (XMPPMulticastDelegate *)xmpp_delegates;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_END
|
|
||||||
|
|
||||||
@implementation XMPPConnection
|
@implementation XMPPConnection
|
||||||
@synthesize username = _username, resource = _resource, server = _server;
|
@synthesize username = _username, resource = _resource, server = _server;
|
||||||
@synthesize domain = _domain, password = _password, language = _language;
|
@synthesize domain = _domain, password = _password, language = _language;
|
||||||
|
@ -99,7 +112,7 @@ OF_ASSUME_NONNULL_END
|
||||||
return [[[self alloc] init] autorelease];
|
return [[[self alloc] init] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- init
|
- (instancetype)init
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
|
@ -192,7 +205,7 @@ OF_ASSUME_NONNULL_END
|
||||||
OFString *old = _server;
|
OFString *old = _server;
|
||||||
|
|
||||||
if (server != nil)
|
if (server != nil)
|
||||||
_server = [self XMPP_IDNAToASCII: server];
|
_server = [self xmpp_IDNAToASCII: server];
|
||||||
else
|
else
|
||||||
_server = nil;
|
_server = nil;
|
||||||
|
|
||||||
|
@ -221,7 +234,7 @@ OF_ASSUME_NONNULL_END
|
||||||
free(srv);
|
free(srv);
|
||||||
}
|
}
|
||||||
|
|
||||||
_domainToASCII = [self XMPP_IDNAToASCII: _domain];
|
_domainToASCII = [self xmpp_IDNAToASCII: _domain];
|
||||||
} else {
|
} else {
|
||||||
_domain = nil;
|
_domain = nil;
|
||||||
_domainToASCII = nil;
|
_domainToASCII = nil;
|
||||||
|
@ -257,7 +270,7 @@ OF_ASSUME_NONNULL_END
|
||||||
[old release];
|
[old release];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)XMPP_socketDidConnect: (OFTCPSocket *)socket
|
- (void)xmpp_socketDidConnect: (OFTCPSocket *)socket
|
||||||
context: (OFArray *)nextSRVRecords
|
context: (OFArray *)nextSRVRecords
|
||||||
exception: (id)exception
|
exception: (id)exception
|
||||||
{
|
{
|
||||||
|
@ -265,7 +278,7 @@ OF_ASSUME_NONNULL_END
|
||||||
|
|
||||||
if (exception != nil) {
|
if (exception != nil) {
|
||||||
if (nextSRVRecords != nil) {
|
if (nextSRVRecords != nil) {
|
||||||
[self XMPP_tryNextSRVRecord: nextSRVRecords];
|
[self xmpp_tryNextSRVRecord: nextSRVRecords];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,18 +289,18 @@ OF_ASSUME_NONNULL_END
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
[self XMPP_startStream];
|
[self xmpp_startStream];
|
||||||
|
|
||||||
buffer = [self allocMemoryWithSize: BUFFER_LENGTH];
|
buffer = [self allocMemoryWithSize: BUFFER_LENGTH];
|
||||||
[_socket asyncReadIntoBuffer: buffer
|
[_socket asyncReadIntoBuffer: buffer
|
||||||
length: BUFFER_LENGTH
|
length: BUFFER_LENGTH
|
||||||
target: self
|
target: self
|
||||||
selector: @selector(XMPP_stream:didReadIntoBuffer:
|
selector: @selector(xmpp_stream:didReadIntoBuffer:
|
||||||
length:exception:)
|
length:exception:)
|
||||||
context: nil];
|
context: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)XMPP_tryNextSRVRecord: (OFArray *)SRVRecords
|
- (void)xmpp_tryNextSRVRecord: (OFArray *)SRVRecords
|
||||||
{
|
{
|
||||||
OFSRVDNSResourceRecord *record = [SRVRecords objectAtIndex: 0];
|
OFSRVDNSResourceRecord *record = [SRVRecords objectAtIndex: 0];
|
||||||
|
|
||||||
|
@ -299,12 +312,12 @@ OF_ASSUME_NONNULL_END
|
||||||
[_socket asyncConnectToHost: [record target]
|
[_socket asyncConnectToHost: [record target]
|
||||||
port: [record port]
|
port: [record port]
|
||||||
target: self
|
target: self
|
||||||
selector: @selector(XMPP_socketDidConnect:
|
selector: @selector(xmpp_socketDidConnect:
|
||||||
context:exception:)
|
context:exception:)
|
||||||
context: SRVRecords];
|
context: SRVRecords];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)XMPP_resolver: (OFDNSResolver *)resolver
|
- (void)xmpp_resolver: (OFDNSResolver *)resolver
|
||||||
didResolveDomainName: (OFString *)domainName
|
didResolveDomainName: (OFString *)domainName
|
||||||
answerRecords: (OFDictionary *)answerRecords
|
answerRecords: (OFDictionary *)answerRecords
|
||||||
authorityRecords: (OFDictionary *)authorityRecords
|
authorityRecords: (OFDictionary *)authorityRecords
|
||||||
|
@ -335,13 +348,13 @@ OF_ASSUME_NONNULL_END
|
||||||
[_socket asyncConnectToHost: domainToASCII
|
[_socket asyncConnectToHost: domainToASCII
|
||||||
port: _port
|
port: _port
|
||||||
target: self
|
target: self
|
||||||
selector: @selector(XMPP_socketDidConnect:
|
selector: @selector(xmpp_socketDidConnect:
|
||||||
context:exception:)
|
context:exception:)
|
||||||
context: nil];
|
context: nil];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
[self XMPP_tryNextSRVRecord: records];
|
[self xmpp_tryNextSRVRecord: records];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)asyncConnect
|
- (void)asyncConnect
|
||||||
|
@ -357,14 +370,14 @@ OF_ASSUME_NONNULL_END
|
||||||
[_socket asyncConnectToHost: _server
|
[_socket asyncConnectToHost: _server
|
||||||
port: _port
|
port: _port
|
||||||
target: self
|
target: self
|
||||||
selector: @selector(XMPP_socketDidConnect:
|
selector: @selector(xmpp_socketDidConnect:
|
||||||
context:exception:)
|
context:exception:)
|
||||||
context: nil];
|
context: nil];
|
||||||
else
|
else
|
||||||
[[OFThread DNSResolver]
|
[[OFThread DNSResolver]
|
||||||
asyncResolveHost: _domainToASCII
|
asyncResolveHost: _domainToASCII
|
||||||
target: self
|
target: self
|
||||||
selector: @selector(XMPP_resolver:
|
selector: @selector(xmpp_resolver:
|
||||||
didResolveDomainName:answerRecords:
|
didResolveDomainName:answerRecords:
|
||||||
authorityRecords:additionalRecords:
|
authorityRecords:additionalRecords:
|
||||||
context:exception:)
|
context:exception:)
|
||||||
|
@ -373,7 +386,7 @@ OF_ASSUME_NONNULL_END
|
||||||
objc_autoreleasePoolPop(pool);
|
objc_autoreleasePoolPop(pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (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]) {
|
||||||
|
@ -386,7 +399,7 @@ OF_ASSUME_NONNULL_END
|
||||||
[_parser parseBuffer: buffer
|
[_parser parseBuffer: buffer
|
||||||
length: length];
|
length: length];
|
||||||
} @catch (OFMalformedXMLException *e) {
|
} @catch (OFMalformedXMLException *e) {
|
||||||
[self XMPP_sendStreamError: @"bad-format"
|
[self xmpp_sendStreamError: @"bad-format"
|
||||||
text: nil];
|
text: nil];
|
||||||
[self close];
|
[self close];
|
||||||
return false;
|
return false;
|
||||||
|
@ -398,7 +411,7 @@ OF_ASSUME_NONNULL_END
|
||||||
- (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
|
||||||
length: length];
|
length: length];
|
||||||
|
|
||||||
[_oldParser release];
|
[_oldParser release];
|
||||||
|
@ -408,7 +421,7 @@ OF_ASSUME_NONNULL_END
|
||||||
_oldElementBuilder = nil;
|
_oldElementBuilder = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (bool)XMPP_stream: (OFStream *)stream
|
- (bool)xmpp_stream: (OFStream *)stream
|
||||||
didReadIntoBuffer: (char *)buffer
|
didReadIntoBuffer: (char *)buffer
|
||||||
length: (size_t)length
|
length: (size_t)length
|
||||||
exception: (OFException *)exception
|
exception: (OFException *)exception
|
||||||
|
@ -423,7 +436,7 @@ OF_ASSUME_NONNULL_END
|
||||||
}
|
}
|
||||||
|
|
||||||
@try {
|
@try {
|
||||||
if (![self XMPP_parseBuffer: buffer
|
if (![self xmpp_parseBuffer: buffer
|
||||||
length: length])
|
length: length])
|
||||||
return false;
|
return false;
|
||||||
} @catch (id e) {
|
} @catch (id e) {
|
||||||
|
@ -445,7 +458,7 @@ OF_ASSUME_NONNULL_END
|
||||||
[_socket asyncReadIntoBuffer: buffer
|
[_socket asyncReadIntoBuffer: buffer
|
||||||
length: BUFFER_LENGTH
|
length: BUFFER_LENGTH
|
||||||
target: self
|
target: self
|
||||||
selector: @selector(XMPP_stream:
|
selector: @selector(xmpp_stream:
|
||||||
didReadIntoBuffer:length:
|
didReadIntoBuffer:length:
|
||||||
exception:)
|
exception:)
|
||||||
context: nil];
|
context: nil];
|
||||||
|
@ -583,13 +596,13 @@ OF_ASSUME_NONNULL_END
|
||||||
}
|
}
|
||||||
|
|
||||||
if (![prefix isEqual: @"stream"]) {
|
if (![prefix isEqual: @"stream"]) {
|
||||||
[self XMPP_sendStreamError: @"bad-namespace-prefix"
|
[self xmpp_sendStreamError: @"bad-namespace-prefix"
|
||||||
text: nil];
|
text: nil];
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -597,13 +610,13 @@ OF_ASSUME_NONNULL_END
|
||||||
for (OFXMLAttribute *attribute in attributes) {
|
for (OFXMLAttribute *attribute in attributes) {
|
||||||
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"
|
||||||
text: nil];
|
text: nil];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ([[attribute name] isEqual: @"version"] &&
|
if ([[attribute name] isEqual: @"version"] &&
|
||||||
![[attribute stringValue] isEqual: @"1.0"]) {
|
![[attribute stringValue] isEqual: @"1.0"]) {
|
||||||
[self XMPP_sendStreamError: @"unsupported-version"
|
[self xmpp_sendStreamError: @"unsupported-version"
|
||||||
text: nil];
|
text: nil];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -628,16 +641,16 @@ OF_ASSUME_NONNULL_END
|
||||||
withObject: element];
|
withObject: element];
|
||||||
|
|
||||||
if ([[element namespace] isEqual: XMPP_NS_CLIENT])
|
if ([[element namespace] isEqual: XMPP_NS_CLIENT])
|
||||||
[self XMPP_handleStanza: element];
|
[self xmpp_handleStanza: element];
|
||||||
|
|
||||||
if ([[element namespace] isEqual: XMPP_NS_STREAM])
|
if ([[element namespace] isEqual: XMPP_NS_STREAM])
|
||||||
[self XMPP_handleStream: element];
|
[self xmpp_handleStream: element];
|
||||||
|
|
||||||
if ([[element namespace] isEqual: XMPP_NS_STARTTLS])
|
if ([[element namespace] isEqual: XMPP_NS_STARTTLS])
|
||||||
[self XMPP_handleTLS: element];
|
[self xmpp_handleTLS: element];
|
||||||
|
|
||||||
if ([[element namespace] isEqual: XMPP_NS_SASL])
|
if ([[element namespace] isEqual: XMPP_NS_SASL])
|
||||||
[self XMPP_handleSASL: element];
|
[self xmpp_handleSASL: element];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)elementBuilder: (OFXMLElementBuilder *)builder
|
- (void)elementBuilder: (OFXMLElementBuilder *)builder
|
||||||
|
@ -653,7 +666,7 @@ OF_ASSUME_NONNULL_END
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)XMPP_startStream
|
- (void)xmpp_startStream
|
||||||
{
|
{
|
||||||
OFString *langString = @"";
|
OFString *langString = @"";
|
||||||
|
|
||||||
|
@ -708,34 +721,34 @@ OF_ASSUME_NONNULL_END
|
||||||
_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]];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([[element name] isEqual: @"message"]) {
|
if ([[element name] isEqual: @"message"]) {
|
||||||
[self XMPP_handleMessage:
|
[self xmpp_handleMessage:
|
||||||
[XMPPMessage stanzaWithElement: element]];
|
[XMPPMessage stanzaWithElement: element]];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([[element name] isEqual: @"presence"]) {
|
if ([[element name] isEqual: @"presence"]) {
|
||||||
[self XMPP_handlePresence:
|
[self xmpp_handlePresence:
|
||||||
[XMPPPresence stanzaWithElement: element]];
|
[XMPPPresence stanzaWithElement: element]];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
[self XMPP_sendStreamError: @"unsupported-stanza-type"
|
[self xmpp_sendStreamError: @"unsupported-stanza-type"
|
||||||
text: nil];
|
text: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (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];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -836,7 +849,7 @@ OF_ASSUME_NONNULL_END
|
||||||
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 */
|
||||||
|
@ -865,7 +878,7 @@ OF_ASSUME_NONNULL_END
|
||||||
withObject: self];
|
withObject: self];
|
||||||
|
|
||||||
/* Stream restart */
|
/* Stream restart */
|
||||||
[self XMPP_startStream];
|
[self xmpp_startStream];
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -877,7 +890,7 @@ OF_ASSUME_NONNULL_END
|
||||||
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;
|
||||||
|
@ -908,7 +921,7 @@ OF_ASSUME_NONNULL_END
|
||||||
withObject: self];
|
withObject: self];
|
||||||
|
|
||||||
/* Stream restart */
|
/* Stream restart */
|
||||||
[self XMPP_startStream];
|
[self xmpp_startStream];
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -923,7 +936,7 @@ OF_ASSUME_NONNULL_END
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)XMPP_handleIQ: (XMPPIQ *)IQ
|
- (void)xmpp_handleIQ: (XMPPIQ *)IQ
|
||||||
{
|
{
|
||||||
bool handled = false;
|
bool handled = false;
|
||||||
XMPPCallback *callback;
|
XMPPCallback *callback;
|
||||||
|
@ -954,21 +967,21 @@ OF_ASSUME_NONNULL_END
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (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];
|
||||||
|
@ -1000,17 +1013,13 @@ OF_ASSUME_NONNULL_END
|
||||||
_supportsStreamManagement = true;
|
_supportsStreamManagement = true;
|
||||||
|
|
||||||
if (mechs != nil) {
|
if (mechs != nil) {
|
||||||
OFEnumerator *enumerator;
|
for (OFXMLElement *mech in [mechs children])
|
||||||
OFXMLElement *mech;
|
|
||||||
|
|
||||||
enumerator = [[mechs children] objectEnumerator];
|
|
||||||
while ((mech = [enumerator nextObject]) != nil)
|
|
||||||
[mechanisms addObject: [mech stringValue]];
|
[mechanisms addObject: [mech stringValue]];
|
||||||
|
|
||||||
if (_privateKeyFile != nil && _certificateFile != nil &&
|
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"];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1021,7 +1030,7 @@ OF_ASSUME_NONNULL_END
|
||||||
connection: self
|
connection: self
|
||||||
hash: [OFSHA1Hash class]
|
hash: [OFSHA1Hash class]
|
||||||
plusAvailable: true];
|
plusAvailable: true];
|
||||||
[self XMPP_sendAuth: @"SCRAM-SHA-1-PLUS"];
|
[self xmpp_sendAuth: @"SCRAM-SHA-1-PLUS"];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1032,7 +1041,7 @@ OF_ASSUME_NONNULL_END
|
||||||
connection: self
|
connection: self
|
||||||
hash: [OFSHA1Hash class]
|
hash: [OFSHA1Hash class]
|
||||||
plusAvailable: false];
|
plusAvailable: false];
|
||||||
[self XMPP_sendAuth: @"SCRAM-SHA-1"];
|
[self xmpp_sendAuth: @"SCRAM-SHA-1"];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1040,7 +1049,7 @@ OF_ASSUME_NONNULL_END
|
||||||
_authModule = [[XMPPPLAINAuth alloc]
|
_authModule = [[XMPPPLAINAuth alloc]
|
||||||
initWithAuthcid: _username
|
initWithAuthcid: _username
|
||||||
password: _password];
|
password: _password];
|
||||||
[self XMPP_sendAuth: @"PLAIN"];
|
[self xmpp_sendAuth: @"PLAIN"];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1052,14 +1061,14 @@ OF_ASSUME_NONNULL_END
|
||||||
_needsSession = true;
|
_needsSession = true;
|
||||||
|
|
||||||
if (bind != nil) {
|
if (bind != nil) {
|
||||||
[self XMPP_sendResourceBind];
|
[self xmpp_sendResourceBind];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)XMPP_sendAuth: (OFString *)authName
|
- (void)xmpp_sendAuth: (OFString *)authName
|
||||||
{
|
{
|
||||||
OFXMLElement *authTag;
|
OFXMLElement *authTag;
|
||||||
OFData *initialMessage = [_authModule initialMessage];
|
OFData *initialMessage = [_authModule initialMessage];
|
||||||
|
@ -1079,7 +1088,7 @@ OF_ASSUME_NONNULL_END
|
||||||
[self sendStanza: authTag];
|
[self sendStanza: authTag];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)XMPP_sendResourceBind
|
- (void)xmpp_sendResourceBind
|
||||||
{
|
{
|
||||||
XMPPIQ *IQ;
|
XMPPIQ *IQ;
|
||||||
OFXMLElement *bind;
|
OFXMLElement *bind;
|
||||||
|
@ -1099,11 +1108,11 @@ OF_ASSUME_NONNULL_END
|
||||||
|
|
||||||
[self sendIQ: IQ
|
[self sendIQ: IQ
|
||||||
callbackTarget: self
|
callbackTarget: self
|
||||||
selector: @selector(XMPP_handleResourceBindForConnection:
|
selector: @selector(xmpp_handleResourceBindForConnection:
|
||||||
IQ:)];
|
IQ:)];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)XMPP_sendStreamError: (OFString *)condition
|
- (void)xmpp_sendStreamError: (OFString *)condition
|
||||||
text: (OFString *)text
|
text: (OFString *)text
|
||||||
{
|
{
|
||||||
OFXMLElement *error = [OFXMLElement
|
OFXMLElement *error = [OFXMLElement
|
||||||
|
@ -1123,7 +1132,7 @@ OF_ASSUME_NONNULL_END
|
||||||
[self close];
|
[self close];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)XMPP_handleResourceBindForConnection: (XMPPConnection *)connection
|
- (void)xmpp_handleResourceBindForConnection: (XMPPConnection *)connection
|
||||||
IQ: (XMPPIQ *)IQ
|
IQ: (XMPPIQ *)IQ
|
||||||
{
|
{
|
||||||
OFXMLElement *bindElement, *JIDElement;
|
OFXMLElement *bindElement, *JIDElement;
|
||||||
|
@ -1140,7 +1149,7 @@ OF_ASSUME_NONNULL_END
|
||||||
_JID = [[XMPPJID alloc] initWithString: [JIDElement stringValue]];
|
_JID = [[XMPPJID alloc] initWithString: [JIDElement stringValue]];
|
||||||
|
|
||||||
if (_needsSession) {
|
if (_needsSession) {
|
||||||
[self XMPP_sendSession];
|
[self xmpp_sendSession];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1149,7 +1158,7 @@ OF_ASSUME_NONNULL_END
|
||||||
withObject: _JID];
|
withObject: _JID];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)XMPP_sendSession
|
- (void)xmpp_sendSession
|
||||||
{
|
{
|
||||||
XMPPIQ *IQ = [XMPPIQ IQWithType: @"set"
|
XMPPIQ *IQ = [XMPPIQ IQWithType: @"set"
|
||||||
ID: [self generateStanzaID]];
|
ID: [self generateStanzaID]];
|
||||||
|
@ -1159,10 +1168,10 @@ OF_ASSUME_NONNULL_END
|
||||||
|
|
||||||
[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"])
|
||||||
|
@ -1173,7 +1182,7 @@ OF_ASSUME_NONNULL_END
|
||||||
withObject: _JID];
|
withObject: _JID];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (OFString *)XMPP_IDNAToASCII: (OFString *)domain
|
- (OFString *)xmpp_IDNAToASCII: (OFString *)domain
|
||||||
{
|
{
|
||||||
OFString *ret;
|
OFString *ret;
|
||||||
char *cDomain;
|
char *cDomain;
|
||||||
|
@ -1219,7 +1228,7 @@ OF_ASSUME_NONNULL_END
|
||||||
[_delegates removeDelegate: delegate];
|
[_delegates removeDelegate: delegate];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (XMPPMulticastDelegate *)XMPP_delegates
|
- (XMPPMulticastDelegate *)xmpp_delegates
|
||||||
{
|
{
|
||||||
return _delegates;
|
return _delegates;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
OF_ASSUME_NONNULL_BEGIN
|
OF_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface XMPPContact ()
|
@interface XMPPContact ()
|
||||||
- (void)XMPP_setRosterItem: (XMPPRosterItem *)rosterItem;
|
- (void)xmpp_setRosterItem: (XMPPRosterItem *)rosterItem;
|
||||||
- (void)XMPP_setPresence: (XMPPPresence *)presence
|
- (void)xmpp_setPresence: (XMPPPresence *)presence
|
||||||
resource: (OFString *)resource;
|
resource: (OFString *)resource;
|
||||||
- (void)XMPP_removePresenceForResource: (OFString *)resource;
|
- (void)xmpp_removePresenceForResource: (OFString *)resource;
|
||||||
- (void)XMPP_setLockedOnJID: (nullable XMPPJID *)JID;
|
- (void)xmpp_setLockedOnJID: (nullable XMPPJID *)JID;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_END
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
@synthesize rosterItem = _rosterItem;
|
@synthesize rosterItem = _rosterItem;
|
||||||
@synthesize presences = _presences;
|
@synthesize presences = _presences;
|
||||||
|
|
||||||
- init
|
- (instancetype)init
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
|
@ -62,14 +62,14 @@
|
||||||
[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)
|
||||||
|
@ -79,10 +79,10 @@
|
||||||
[_presences setObject: presence
|
[_presences setObject: presence
|
||||||
forKey: @""];
|
forKey: @""];
|
||||||
|
|
||||||
[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];
|
||||||
|
@ -91,10 +91,10 @@
|
||||||
_presences = [[OFMutableDictionary alloc] init];
|
_presences = [[OFMutableDictionary alloc] init];
|
||||||
}
|
}
|
||||||
|
|
||||||
[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];
|
||||||
|
|
|
@ -124,8 +124,9 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @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
|
- (instancetype)initWithConnection: (XMPPConnection *)connection
|
||||||
roster: (XMPPRoster *)roster OF_DESIGNATED_INITIALIZER;
|
roster: (XMPPRoster *)roster
|
||||||
|
OF_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
- (void)sendSubscribedToJID: (XMPPJID *)subscriber;
|
- (void)sendSubscribedToJID: (XMPPJID *)subscriber;
|
||||||
- (void)sendUnsubscribedToJID: (XMPPJID *)subscriber;
|
- (void)sendUnsubscribedToJID: (XMPPJID *)subscriber;
|
||||||
|
|
|
@ -32,8 +32,8 @@
|
||||||
@implementation XMPPContactManager
|
@implementation XMPPContactManager
|
||||||
@synthesize contacts = _contacts;
|
@synthesize contacts = _contacts;
|
||||||
|
|
||||||
- initWithConnection: (XMPPConnection *)connection
|
- (instancetype)initWithConnection: (XMPPConnection *)connection
|
||||||
roster: (XMPPRoster *)roster
|
roster: (XMPPRoster *)roster
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
|
@ -90,27 +90,22 @@
|
||||||
|
|
||||||
- (void)rosterWasReceived: (XMPPRoster *)roster
|
- (void)rosterWasReceived: (XMPPRoster *)roster
|
||||||
{
|
{
|
||||||
OFEnumerator *contactEnumerator;
|
|
||||||
XMPPContact *contact;
|
|
||||||
OFDictionary *rosterItems;
|
OFDictionary *rosterItems;
|
||||||
OFEnumerator *rosterItemEnumerator;
|
|
||||||
OFString *bareJID;
|
|
||||||
|
|
||||||
contactEnumerator = [_contacts objectEnumerator];
|
for (XMPPContact *contact in _contacts)
|
||||||
while ((contact = [contactEnumerator nextObject]) != nil) {
|
|
||||||
[_delegates broadcastSelector: @selector(contactManager:
|
[_delegates broadcastSelector: @selector(contactManager:
|
||||||
didRemoveContact:)
|
didRemoveContact:)
|
||||||
withObject: self
|
withObject: self
|
||||||
withObject: contact];
|
withObject: contact];
|
||||||
}
|
|
||||||
[_contacts release];
|
[_contacts release];
|
||||||
|
_contacts = nil;
|
||||||
|
|
||||||
_contacts = [[OFMutableDictionary alloc] init];
|
_contacts = [[OFMutableDictionary alloc] init];
|
||||||
|
|
||||||
rosterItems = [roster rosterItems];
|
rosterItems = [roster rosterItems];
|
||||||
rosterItemEnumerator = [rosterItems keyEnumerator];
|
for (OFString *bareJID in rosterItems) {
|
||||||
while ((bareJID = [rosterItemEnumerator nextObject]) != nil) {
|
XMPPContact *contact = [[[XMPPContact alloc] init] autorelease];
|
||||||
contact = [[[XMPPContact alloc] init] autorelease];
|
[contact xmpp_setRosterItem:
|
||||||
[contact XMPP_setRosterItem:
|
|
||||||
[rosterItems objectForKey: bareJID]];
|
[rosterItems objectForKey: bareJID]];
|
||||||
[_contacts setObject: contact
|
[_contacts setObject: contact
|
||||||
forKey: bareJID];
|
forKey: bareJID];
|
||||||
|
@ -141,7 +136,7 @@
|
||||||
|
|
||||||
if (contact == nil) {
|
if (contact == nil) {
|
||||||
contact = [[[XMPPContact alloc] init] autorelease];
|
contact = [[[XMPPContact alloc] init] autorelease];
|
||||||
[contact XMPP_setRosterItem: rosterItem];
|
[contact xmpp_setRosterItem: rosterItem];
|
||||||
[_contacts setObject: contact
|
[_contacts setObject: contact
|
||||||
forKey: bareJID];
|
forKey: bareJID];
|
||||||
[_delegates broadcastSelector: @selector(contactManager:
|
[_delegates broadcastSelector: @selector(contactManager:
|
||||||
|
@ -153,7 +148,7 @@
|
||||||
willUpdateWithRosterItem:)
|
willUpdateWithRosterItem:)
|
||||||
withObject: contact
|
withObject: contact
|
||||||
withObject: rosterItem];
|
withObject: rosterItem];
|
||||||
[contact XMPP_setRosterItem: rosterItem];
|
[contact xmpp_setRosterItem: rosterItem];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +175,7 @@
|
||||||
|
|
||||||
/* Available presence */
|
/* Available presence */
|
||||||
if ([type isEqual: @"available"]) {
|
if ([type isEqual: @"available"]) {
|
||||||
[contact XMPP_setPresence: presence
|
[contact xmpp_setPresence: presence
|
||||||
resource: [JID resource]];
|
resource: [JID resource]];
|
||||||
[_delegates broadcastSelector: @selector(contact:
|
[_delegates broadcastSelector: @selector(contact:
|
||||||
didSendPresence:)
|
didSendPresence:)
|
||||||
|
@ -191,7 +186,7 @@
|
||||||
|
|
||||||
/* Unavailable presence */
|
/* Unavailable presence */
|
||||||
if ([type isEqual: @"unavailable"]) {
|
if ([type isEqual: @"unavailable"]) {
|
||||||
[contact XMPP_removePresenceForResource: [JID resource]];
|
[contact xmpp_removePresenceForResource: [JID resource]];
|
||||||
[_delegates broadcastSelector: @selector(contact:
|
[_delegates broadcastSelector: @selector(contact:
|
||||||
didSendPresence:)
|
didSendPresence:)
|
||||||
withObject: contact
|
withObject: contact
|
||||||
|
@ -209,7 +204,7 @@
|
||||||
if (contact == nil)
|
if (contact == nil)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[contact XMPP_setLockedOnJID: JID];
|
[contact xmpp_setLockedOnJID: JID];
|
||||||
|
|
||||||
[_delegates broadcastSelector: @selector(contact:didSendMessage:)
|
[_delegates broadcastSelector: @selector(contact:didSendMessage:)
|
||||||
withObject: contact
|
withObject: contact
|
||||||
|
|
|
@ -81,11 +81,11 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
+ (instancetype)discoEntityWithConnection: (XMPPConnection *)connection
|
+ (instancetype)discoEntityWithConnection: (XMPPConnection *)connection
|
||||||
capsNode: (OFString *)capsNode;
|
capsNode: (OFString *)capsNode;
|
||||||
|
|
||||||
- initWithJID: (XMPPJID *)JID
|
- (instancetype)initWithJID: (XMPPJID *)JID
|
||||||
node: (nullable OFString *)node OF_UNAVAILABLE;
|
node: (nullable OFString *)node OF_UNAVAILABLE;
|
||||||
- initWithJID: (XMPPJID *)JID
|
- (instancetype)initWithJID: (XMPPJID *)JID
|
||||||
node: (nullable OFString *)node
|
node: (nullable OFString *)node
|
||||||
name: (nullable OFString *)name OF_UNAVAILABLE;
|
name: (nullable OFString *)name OF_UNAVAILABLE;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Initializes an already allocated XMPPDiscoEntity with the specified
|
* @brief Initializes an already allocated XMPPDiscoEntity with the specified
|
||||||
|
@ -95,7 +95,7 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* 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;
|
- (instancetype)initWithConnection: (XMPPConnection *)connection;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Initializes an already allocated XMPPDiscoEntity with the specified
|
* @brief Initializes an already allocated XMPPDiscoEntity with the specified
|
||||||
|
@ -106,8 +106,9 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @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
|
- (instancetype)initWithConnection: (XMPPConnection *)connection
|
||||||
capsNode: (nullable OFString *)capsNode OF_DESIGNATED_INITIALIZER;
|
capsNode: (nullable OFString *)capsNode
|
||||||
|
OF_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Adds a XMPPDiscoNode to provide responses for.
|
* @brief Adds a XMPPDiscoNode to provide responses for.
|
||||||
|
|
|
@ -43,21 +43,21 @@
|
||||||
capsNode: capsNode] autorelease];
|
capsNode: capsNode] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithConnection: (XMPPConnection *)connection
|
- (instancetype)initWithConnection: (XMPPConnection *)connection
|
||||||
{
|
{
|
||||||
return [self initWithConnection: connection
|
return [self initWithConnection: connection
|
||||||
capsNode: nil];
|
capsNode: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithJID: (XMPPJID *)JID
|
- (instancetype)initWithJID: (XMPPJID *)JID
|
||||||
node: (nullable OFString *)node
|
node: (nullable OFString *)node
|
||||||
name: (nullable OFString *)name
|
name: (nullable OFString *)name
|
||||||
{
|
{
|
||||||
OF_INVALID_INIT_METHOD
|
OF_INVALID_INIT_METHOD
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithConnection: (XMPPConnection *)connection
|
- (instancetype)initWithConnection: (XMPPConnection *)connection
|
||||||
capsNode: (OFString *)capsNode
|
capsNode: (OFString *)capsNode
|
||||||
{
|
{
|
||||||
self = [super initWithJID: [connection JID]
|
self = [super initWithJID: [connection JID]
|
||||||
node: nil
|
node: nil
|
||||||
|
@ -93,20 +93,15 @@
|
||||||
|
|
||||||
- (OFString *)capsHash
|
- (OFString *)capsHash
|
||||||
{
|
{
|
||||||
OFEnumerator *enumerator;
|
|
||||||
XMPPDiscoIdentity *identity;
|
|
||||||
OFString *feature;
|
|
||||||
OFMutableString *caps = [OFMutableString string];
|
OFMutableString *caps = [OFMutableString string];
|
||||||
OFSHA1Hash *hash = [OFSHA1Hash cryptoHash];
|
OFSHA1Hash *hash = [OFSHA1Hash cryptoHash];
|
||||||
OFData *digest;
|
OFData *digest;
|
||||||
|
|
||||||
enumerator = [_identities objectEnumerator];
|
for (XMPPDiscoIdentity *identity in _identities)
|
||||||
while ((identity = [enumerator nextObject]) != nil)
|
|
||||||
[caps appendFormat: @"%@/%@//%@<", [identity category],
|
[caps appendFormat: @"%@/%@//%@<", [identity category],
|
||||||
[identity type], [identity name]];
|
[identity type], [identity name]];
|
||||||
|
|
||||||
enumerator = [_features objectEnumerator];
|
for (OFString *feature in _features)
|
||||||
while ((feature = [enumerator nextObject]) != nil)
|
|
||||||
[caps appendFormat: @"%@<", feature];
|
[caps appendFormat: @"%@<", feature];
|
||||||
|
|
||||||
[hash updateWithBuffer: [caps UTF8String]
|
[hash updateWithBuffer: [caps UTF8String]
|
||||||
|
@ -137,12 +132,12 @@
|
||||||
OFString *node =
|
OFString *node =
|
||||||
[[query attributeForName: @"node"] stringValue];
|
[[query attributeForName: @"node"] stringValue];
|
||||||
if (node == nil)
|
if (node == nil)
|
||||||
return [self XMPP_handleItemsIQ: IQ
|
return [self xmpp_handleItemsIQ: IQ
|
||||||
connection: connection];
|
connection: connection];
|
||||||
|
|
||||||
XMPPDiscoNode *responder = [_discoNodes objectForKey: node];
|
XMPPDiscoNode *responder = [_discoNodes objectForKey: node];
|
||||||
if (responder != nil)
|
if (responder != nil)
|
||||||
return [responder XMPP_handleItemsIQ: IQ
|
return [responder xmpp_handleItemsIQ: IQ
|
||||||
connection: connection];
|
connection: connection];
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -156,18 +151,18 @@
|
||||||
[[query attributeForName: @"node"] stringValue];
|
[[query attributeForName: @"node"] stringValue];
|
||||||
|
|
||||||
if (node == nil)
|
if (node == nil)
|
||||||
return [self XMPP_handleInfoIQ: IQ
|
return [self xmpp_handleInfoIQ: IQ
|
||||||
connection: connection];
|
connection: connection];
|
||||||
|
|
||||||
OFString *capsNode = [_capsNode stringByAppendingFormat: @"#%@",
|
OFString *capsNode = [_capsNode stringByAppendingFormat: @"#%@",
|
||||||
[self capsHash]];
|
[self capsHash]];
|
||||||
if ([capsNode isEqual: node])
|
if ([capsNode isEqual: node])
|
||||||
return [self XMPP_handleInfoIQ: IQ
|
return [self xmpp_handleInfoIQ: IQ
|
||||||
connection: connection];
|
connection: connection];
|
||||||
|
|
||||||
XMPPDiscoNode *responder = [_discoNodes objectForKey: node];
|
XMPPDiscoNode *responder = [_discoNodes objectForKey: node];
|
||||||
if (responder != nil)
|
if (responder != nil)
|
||||||
return [responder XMPP_handleInfoIQ: IQ
|
return [responder xmpp_handleInfoIQ: IQ
|
||||||
connection: connection];
|
connection: connection];
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -72,7 +72,7 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
+ (instancetype)identityWithCategory: (OFString *)category
|
+ (instancetype)identityWithCategory: (OFString *)category
|
||||||
type: (OFString *)type;
|
type: (OFString *)type;
|
||||||
|
|
||||||
- init OF_UNAVAILABLE;
|
- (instancetype)init OF_UNAVAILABLE;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Initializes an already allocated XMPPDiscoIdentity with the specified
|
* @brief Initializes an already allocated XMPPDiscoIdentity with the specified
|
||||||
|
@ -83,9 +83,10 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @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
|
- (instancetype)initWithCategory: (OFString *)category
|
||||||
type: (OFString *)type
|
type: (OFString *)type
|
||||||
name: (nullable OFString *)name OF_DESIGNATED_INITIALIZER;
|
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
|
||||||
|
@ -95,8 +96,8 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @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
|
- (instancetype)initWithCategory: (OFString *)category
|
||||||
type: (OFString *)type;
|
type: (OFString *)type;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_END
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -42,9 +42,9 @@
|
||||||
type: type] autorelease];
|
type: type] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithCategory: (OFString *)category
|
- (instancetype)initWithCategory: (OFString *)category
|
||||||
type: (OFString *)type
|
type: (OFString *)type
|
||||||
name: (OFString *)name
|
name: (OFString *)name
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
|
@ -63,15 +63,15 @@
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithCategory: (OFString *)category
|
- (instancetype)initWithCategory: (OFString *)category
|
||||||
type: (OFString *)type
|
type: (OFString *)type
|
||||||
{
|
{
|
||||||
return [self initWithCategory: category
|
return [self initWithCategory: category
|
||||||
type: type
|
type: type
|
||||||
name: nil];
|
name: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- init
|
- (instancetype)init
|
||||||
{
|
{
|
||||||
OF_INVALID_INIT_METHOD
|
OF_INVALID_INIT_METHOD
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
@class XMPPIQ;
|
@class XMPPIQ;
|
||||||
|
|
||||||
@interface XMPPDiscoNode ()
|
@interface XMPPDiscoNode ()
|
||||||
- (bool)XMPP_handleItemsIQ: (XMPPIQ *)IQ
|
- (bool)xmpp_handleItemsIQ: (XMPPIQ *)IQ
|
||||||
connection: (XMPPConnection *)connection;
|
connection: (XMPPConnection *)connection;
|
||||||
- (bool)XMPP_handleInfoIQ: (XMPPIQ *)IQ
|
- (bool)xmpp_handleInfoIQ: (XMPPIQ *)IQ
|
||||||
connection: (XMPPConnection *)connection;
|
connection: (XMPPConnection *)connection;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -103,8 +103,8 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @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
|
- (instancetype)initWithJID: (XMPPJID *)JID
|
||||||
node: (nullable OFString *)node;
|
node: (nullable OFString *)node;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Initializes an already allocated XMPPDiscoNode with the specified
|
* @brief Initializes an already allocated XMPPDiscoNode with the specified
|
||||||
|
@ -115,29 +115,30 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @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
|
- (instancetype)initWithJID: (XMPPJID *)JID
|
||||||
node: (nullable OFString *)node
|
node: (nullable OFString *)node
|
||||||
name: (nullable OFString *)name OF_DESIGNATED_INITIALIZER;
|
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;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -51,17 +51,17 @@
|
||||||
name: name] autorelease];
|
name: name] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithJID: (XMPPJID *)JID
|
- (instancetype)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
|
- (instancetype)initWithJID: (XMPPJID *)JID
|
||||||
node: (OFString *)node
|
node: (OFString *)node
|
||||||
name: (OFString *)name
|
name: (OFString *)name
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
|
@ -120,13 +120,11 @@
|
||||||
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;
|
||||||
XMPPDiscoNode *child;
|
|
||||||
OFEnumerator *enumerator;
|
|
||||||
OFXMLElement *query = [IQ elementForName: @"query"
|
OFXMLElement *query = [IQ elementForName: @"query"
|
||||||
namespace: XMPP_NS_DISCO_ITEMS];
|
namespace: XMPP_NS_DISCO_ITEMS];
|
||||||
OFString *node = [[query attributeForName: @"node"] stringValue];
|
OFString *node = [[query attributeForName: @"node"] stringValue];
|
||||||
|
@ -139,8 +137,7 @@
|
||||||
namespace: XMPP_NS_DISCO_ITEMS];
|
namespace: XMPP_NS_DISCO_ITEMS];
|
||||||
[resultIQ addChild: response];
|
[resultIQ addChild: response];
|
||||||
|
|
||||||
enumerator = [_childNodes objectEnumerator];
|
for (XMPPDiscoNode *child in _childNodes) {
|
||||||
while ((child = [enumerator nextObject])) {
|
|
||||||
OFXMLElement *item =
|
OFXMLElement *item =
|
||||||
[OFXMLElement elementWithName: @"item"
|
[OFXMLElement elementWithName: @"item"
|
||||||
namespace: XMPP_NS_DISCO_ITEMS];
|
namespace: XMPP_NS_DISCO_ITEMS];
|
||||||
|
@ -162,22 +159,18 @@
|
||||||
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;
|
||||||
OFEnumerator *enumerator;
|
|
||||||
OFString *feature;
|
|
||||||
XMPPDiscoIdentity *identity;
|
|
||||||
|
|
||||||
resultIQ = [IQ resultIQ];
|
resultIQ = [IQ resultIQ];
|
||||||
response = [OFXMLElement elementWithName: @"query"
|
response = [OFXMLElement elementWithName: @"query"
|
||||||
namespace: XMPP_NS_DISCO_INFO];
|
namespace: XMPP_NS_DISCO_INFO];
|
||||||
[resultIQ addChild: response];
|
[resultIQ addChild: response];
|
||||||
|
|
||||||
enumerator = [_identities objectEnumerator];
|
for (XMPPDiscoIdentity *identity in _identities) {
|
||||||
while ((identity = [enumerator nextObject])) {
|
|
||||||
OFXMLElement *identityElement =
|
OFXMLElement *identityElement =
|
||||||
[OFXMLElement elementWithName: @"identity"
|
[OFXMLElement elementWithName: @"identity"
|
||||||
namespace: XMPP_NS_DISCO_INFO];
|
namespace: XMPP_NS_DISCO_INFO];
|
||||||
|
@ -193,8 +186,7 @@
|
||||||
[response addChild: identityElement];
|
[response addChild: identityElement];
|
||||||
}
|
}
|
||||||
|
|
||||||
enumerator = [_features objectEnumerator];
|
for (OFString *feature in _features) {
|
||||||
while ((feature = [enumerator nextObject])) {
|
|
||||||
OFXMLElement *featureElement =
|
OFXMLElement *featureElement =
|
||||||
[OFXMLElement elementWithName: @"feature"
|
[OFXMLElement elementWithName: @"feature"
|
||||||
namespace: XMPP_NS_DISCO_INFO];
|
namespace: XMPP_NS_DISCO_INFO];
|
||||||
|
|
|
@ -50,7 +50,7 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
*/
|
*/
|
||||||
+ (instancetype)exceptionWithConnection: (nullable XMPPConnection *)connection;
|
+ (instancetype)exceptionWithConnection: (nullable XMPPConnection *)connection;
|
||||||
|
|
||||||
- init OF_UNAVAILABLE;
|
- (instancetype)init OF_UNAVAILABLE;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Initializes an already allocated XMPPException.
|
* @brief Initializes an already allocated XMPPException.
|
||||||
|
@ -59,7 +59,7 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* for this exception
|
* for this exception
|
||||||
* @return An initialized XMPPException
|
* @return An initialized XMPPException
|
||||||
*/
|
*/
|
||||||
- initWithConnection: (nullable XMPPConnection *)connection
|
- (instancetype)initWithConnection: (nullable XMPPConnection *)connection
|
||||||
OF_DESIGNATED_INITIALIZER;
|
OF_DESIGNATED_INITIALIZER;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -93,7 +93,8 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
condition: (OFString *)condition
|
condition: (OFString *)condition
|
||||||
reason: (OFString *)reason;
|
reason: (OFString *)reason;
|
||||||
|
|
||||||
- initWithConnection: (nullable XMPPConnection *)connection OF_UNAVAILABLE;
|
- (instancetype)initWithConnection: (nullable XMPPConnection *)connection
|
||||||
|
OF_UNAVAILABLE;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Initializes an already allocated XMPPStreamErrorException.
|
* @brief Initializes an already allocated XMPPStreamErrorException.
|
||||||
|
@ -103,9 +104,10 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @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: (nullable XMPPConnection *)connection
|
- (instancetype)initWithConnection: (nullable XMPPConnection *)connection
|
||||||
condition: (OFString *)condition
|
condition: (OFString *)condition
|
||||||
reason: (OFString *)reason OF_DESIGNATED_INITIALIZER;
|
reason: (OFString *)reason
|
||||||
|
OF_DESIGNATED_INITIALIZER;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -139,7 +141,8 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
profile: (OFString *)profile
|
profile: (OFString *)profile
|
||||||
string: (OFString *)string;
|
string: (OFString *)string;
|
||||||
|
|
||||||
- initWithConnection: (nullable XMPPConnection *)connection OF_UNAVAILABLE;
|
- (instancetype)initWithConnection: (nullable XMPPConnection *)connection
|
||||||
|
OF_UNAVAILABLE;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Initializes an already allocated XMPPStringPrepFailedException.
|
* @brief Initializes an already allocated XMPPStringPrepFailedException.
|
||||||
|
@ -149,9 +152,10 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @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: (nullable XMPPConnection *)connection
|
- (instancetype)initWithConnection: (nullable XMPPConnection *)connection
|
||||||
profile: (OFString *)profile
|
profile: (OFString *)profile
|
||||||
string: (OFString *)string OF_DESIGNATED_INITIALIZER;
|
string: (OFString *)string
|
||||||
|
OF_DESIGNATED_INITIALIZER;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -184,7 +188,8 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
operation: (OFString *)operation
|
operation: (OFString *)operation
|
||||||
string: (OFString *)string;
|
string: (OFString *)string;
|
||||||
|
|
||||||
- initWithConnection: (nullable XMPPConnection *)connection OF_UNAVAILABLE;
|
- (instancetype)initWithConnection: (nullable XMPPConnection *)connection
|
||||||
|
OF_UNAVAILABLE;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Initializes an already allocated XMPPIDNATranslationFailedException.
|
* @brief Initializes an already allocated XMPPIDNATranslationFailedException.
|
||||||
|
@ -194,9 +199,9 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @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: (nullable XMPPConnection *)connection
|
- (instancetype)initWithConnection: (nullable XMPPConnection *)connection
|
||||||
operation: (OFString *)operation
|
operation: (OFString *)operation
|
||||||
string: (OFString *)string;
|
string: (OFString *)string;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -222,7 +227,8 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
+ (instancetype)exceptionWithConnection: (nullable XMPPConnection *)connection
|
+ (instancetype)exceptionWithConnection: (nullable XMPPConnection *)connection
|
||||||
reason: (OFString *)reason;
|
reason: (OFString *)reason;
|
||||||
|
|
||||||
- initWithConnection: (nullable XMPPConnection *)connection OF_UNAVAILABLE;
|
- (instancetype)initWithConnection: (nullable XMPPConnection *)connection
|
||||||
|
OF_UNAVAILABLE;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Initializes an already allocated XMPPAuthFailedException.
|
* @brief Initializes an already allocated XMPPAuthFailedException.
|
||||||
|
@ -231,8 +237,9 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @param reason The reason the authentication failed
|
* @param reason The reason the authentication failed
|
||||||
* @return An initialized XMPPAuthFailedException
|
* @return An initialized XMPPAuthFailedException
|
||||||
*/
|
*/
|
||||||
- initWithConnection: (nullable XMPPConnection *)connection
|
- (instancetype)initWithConnection: (nullable XMPPConnection *)connection
|
||||||
reason: (OFString *)reason OF_DESIGNATED_INITIALIZER;
|
reason: (OFString *)reason
|
||||||
|
OF_DESIGNATED_INITIALIZER;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_END
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -38,12 +38,12 @@
|
||||||
return [[[self alloc] initWithConnection: connection] autorelease];
|
return [[[self alloc] initWithConnection: connection] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- init
|
- (instancetype)init
|
||||||
{
|
{
|
||||||
OF_INVALID_INIT_METHOD
|
OF_INVALID_INIT_METHOD
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithConnection: (XMPPConnection *)connection
|
- (instancetype)initWithConnection: (XMPPConnection *)connection
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
|
@ -77,14 +77,14 @@
|
||||||
reason: reason] autorelease];
|
reason: reason] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithConnection: (XMPPConnection *)connection
|
- (instancetype)initWithConnection: (XMPPConnection *)connection
|
||||||
{
|
{
|
||||||
OF_INVALID_INIT_METHOD
|
OF_INVALID_INIT_METHOD
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithConnection: (XMPPConnection *)connection
|
- (instancetype)initWithConnection: (XMPPConnection *)connection
|
||||||
condition: (OFString *)condition
|
condition: (OFString *)condition
|
||||||
reason: (OFString *)reason
|
reason: (OFString *)reason
|
||||||
{
|
{
|
||||||
self = [super initWithConnection: connection];
|
self = [super initWithConnection: connection];
|
||||||
|
|
||||||
|
@ -126,14 +126,14 @@
|
||||||
string: string] autorelease];
|
string: string] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithConnection: (XMPPConnection *)connection
|
- (instancetype)initWithConnection: (XMPPConnection *)connection
|
||||||
{
|
{
|
||||||
OF_INVALID_INIT_METHOD
|
OF_INVALID_INIT_METHOD
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithConnection: (XMPPConnection *)connection
|
- (instancetype)initWithConnection: (XMPPConnection *)connection
|
||||||
profile: (OFString *)profile
|
profile: (OFString *)profile
|
||||||
string: (OFString *)string
|
string: (OFString *)string
|
||||||
{
|
{
|
||||||
self = [super initWithConnection: connection];
|
self = [super initWithConnection: connection];
|
||||||
|
|
||||||
|
@ -176,14 +176,14 @@
|
||||||
string: string] autorelease];
|
string: string] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithConnection: (XMPPConnection *)connection
|
- (instancetype)initWithConnection: (XMPPConnection *)connection
|
||||||
{
|
{
|
||||||
OF_INVALID_INIT_METHOD
|
OF_INVALID_INIT_METHOD
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithConnection: (XMPPConnection *)connection
|
- (instancetype)initWithConnection: (XMPPConnection *)connection
|
||||||
operation: (OFString *)operation
|
operation: (OFString *)operation
|
||||||
string: (OFString *)string
|
string: (OFString *)string
|
||||||
{
|
{
|
||||||
self = [super initWithConnection: connection];
|
self = [super initWithConnection: connection];
|
||||||
|
|
||||||
|
@ -223,13 +223,13 @@
|
||||||
reason: reason] autorelease];
|
reason: reason] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithConnection: (XMPPConnection *)connection
|
- (instancetype)initWithConnection: (XMPPConnection *)connection
|
||||||
{
|
{
|
||||||
OF_INVALID_INIT_METHOD
|
OF_INVALID_INIT_METHOD
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithConnection: (XMPPConnection *)connection
|
- (instancetype)initWithConnection: (XMPPConnection *)connection
|
||||||
reason: (OFString *)reason
|
reason: (OFString *)reason
|
||||||
{
|
{
|
||||||
self = [super initWithConnection: connection];
|
self = [super initWithConnection: connection];
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,8 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
OFMutableDictionary *_data;
|
OFMutableDictionary *_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
- init OF_UNAVAILABLE;
|
- (instancetype)init OF_UNAVAILABLE;
|
||||||
- initWithFile: (OFString *)file;
|
- (instancetype)initWithFile: (OFString *)file;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_END
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -38,12 +38,12 @@
|
||||||
#import "XMPPFileStorage.h"
|
#import "XMPPFileStorage.h"
|
||||||
|
|
||||||
@implementation XMPPFileStorage
|
@implementation XMPPFileStorage
|
||||||
- init
|
- (instancetype)init
|
||||||
{
|
{
|
||||||
OF_INVALID_INIT_METHOD
|
OF_INVALID_INIT_METHOD
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithFile: (OFString *)file
|
- (instancetype)initWithFile: (OFString *)file
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
|
@ -80,16 +80,14 @@
|
||||||
[[_data messagePackRepresentation] writeToFile: _file];
|
[[_data messagePackRepresentation] writeToFile: _file];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (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;
|
||||||
OFEnumerator *enumerator = [pathComponents objectEnumerator];
|
|
||||||
OFString *component;
|
|
||||||
size_t i = 0, components = [pathComponents count];
|
size_t i = 0, components = [pathComponents count];
|
||||||
|
|
||||||
while ((component = [enumerator nextObject]) != nil) {
|
for (OFString *component in pathComponents) {
|
||||||
if (i++ == components - 1)
|
if (i++ == components - 1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -111,7 +109,7 @@
|
||||||
[iter removeObjectForKey: [pathComponents lastObject]];
|
[iter removeObjectForKey: [pathComponents lastObject]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)XMPP_objectForPath: (OFString *)path
|
- (id)xmpp_objectForPath: (OFString *)path
|
||||||
{
|
{
|
||||||
id object = _data;
|
id object = _data;
|
||||||
|
|
||||||
|
@ -126,7 +124,7 @@
|
||||||
{
|
{
|
||||||
void *pool = objc_autoreleasePoolPush();
|
void *pool = objc_autoreleasePoolPush();
|
||||||
|
|
||||||
[self XMPP_setObject: string
|
[self xmpp_setObject: string
|
||||||
forPath: path];
|
forPath: path];
|
||||||
|
|
||||||
objc_autoreleasePoolPop(pool);
|
objc_autoreleasePoolPop(pool);
|
||||||
|
@ -137,7 +135,7 @@
|
||||||
void *pool = objc_autoreleasePoolPush();
|
void *pool = objc_autoreleasePoolPush();
|
||||||
OFString *string;
|
OFString *string;
|
||||||
|
|
||||||
string = [self XMPP_objectForPath: path];
|
string = [self xmpp_objectForPath: path];
|
||||||
|
|
||||||
objc_autoreleasePoolPop(pool);
|
objc_autoreleasePoolPop(pool);
|
||||||
|
|
||||||
|
@ -149,7 +147,7 @@
|
||||||
{
|
{
|
||||||
void *pool = objc_autoreleasePoolPush();
|
void *pool = objc_autoreleasePoolPush();
|
||||||
|
|
||||||
[self XMPP_setObject: [OFNumber numberWithBool: boolean]
|
[self xmpp_setObject: [OFNumber numberWithBool: boolean]
|
||||||
forPath: path];
|
forPath: path];
|
||||||
|
|
||||||
objc_autoreleasePoolPop(pool);
|
objc_autoreleasePoolPop(pool);
|
||||||
|
@ -160,7 +158,7 @@
|
||||||
void *pool = objc_autoreleasePoolPush();
|
void *pool = objc_autoreleasePoolPush();
|
||||||
bool boolean;
|
bool boolean;
|
||||||
|
|
||||||
boolean = [[self XMPP_objectForPath: path] boolValue];
|
boolean = [[self xmpp_objectForPath: path] boolValue];
|
||||||
|
|
||||||
objc_autoreleasePoolPop(pool);
|
objc_autoreleasePoolPop(pool);
|
||||||
|
|
||||||
|
@ -172,7 +170,7 @@
|
||||||
{
|
{
|
||||||
void *pool = objc_autoreleasePoolPush();
|
void *pool = objc_autoreleasePoolPush();
|
||||||
|
|
||||||
[self XMPP_setObject: [OFNumber numberWithIntMax: integer]
|
[self xmpp_setObject: [OFNumber numberWithIntMax: integer]
|
||||||
forPath: path];
|
forPath: path];
|
||||||
|
|
||||||
objc_autoreleasePoolPop(pool);
|
objc_autoreleasePoolPop(pool);
|
||||||
|
@ -183,7 +181,7 @@
|
||||||
void *pool = objc_autoreleasePoolPush();
|
void *pool = objc_autoreleasePoolPush();
|
||||||
intmax_t integer;
|
intmax_t integer;
|
||||||
|
|
||||||
integer = [[self XMPP_objectForPath: path] intMaxValue];
|
integer = [[self xmpp_objectForPath: path] intMaxValue];
|
||||||
|
|
||||||
objc_autoreleasePoolPop(pool);
|
objc_autoreleasePoolPop(pool);
|
||||||
|
|
||||||
|
@ -195,7 +193,7 @@
|
||||||
{
|
{
|
||||||
void *pool = objc_autoreleasePoolPush();
|
void *pool = objc_autoreleasePoolPush();
|
||||||
|
|
||||||
[self XMPP_setObject: array
|
[self xmpp_setObject: array
|
||||||
forPath: path];
|
forPath: path];
|
||||||
|
|
||||||
objc_autoreleasePoolPop(pool);
|
objc_autoreleasePoolPop(pool);
|
||||||
|
@ -206,7 +204,7 @@
|
||||||
void *pool = objc_autoreleasePoolPush();
|
void *pool = objc_autoreleasePoolPush();
|
||||||
OFArray *array;
|
OFArray *array;
|
||||||
|
|
||||||
array = [self XMPP_objectForPath: path];
|
array = [self xmpp_objectForPath: path];
|
||||||
|
|
||||||
objc_autoreleasePoolPop(pool);
|
objc_autoreleasePoolPop(pool);
|
||||||
|
|
||||||
|
@ -218,7 +216,7 @@
|
||||||
{
|
{
|
||||||
void *pool = objc_autoreleasePoolPush();
|
void *pool = objc_autoreleasePoolPush();
|
||||||
|
|
||||||
[self XMPP_setObject: dictionary
|
[self xmpp_setObject: dictionary
|
||||||
forPath: path];
|
forPath: path];
|
||||||
|
|
||||||
objc_autoreleasePoolPop(pool);
|
objc_autoreleasePoolPop(pool);
|
||||||
|
@ -229,7 +227,7 @@
|
||||||
void *pool = objc_autoreleasePoolPush();
|
void *pool = objc_autoreleasePoolPush();
|
||||||
OFDictionary *dictionary;
|
OFDictionary *dictionary;
|
||||||
|
|
||||||
dictionary = [self XMPP_objectForPath: path];
|
dictionary = [self xmpp_objectForPath: path];
|
||||||
|
|
||||||
objc_autoreleasePoolPop(pool);
|
objc_autoreleasePoolPop(pool);
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,8 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @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
|
- (instancetype)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.
|
||||||
|
|
|
@ -36,8 +36,8 @@
|
||||||
ID: ID] autorelease];
|
ID: ID] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithType: (OFString *)type
|
- (instancetype)initWithType: (OFString *)type
|
||||||
ID: (OFString *)ID
|
ID: (OFString *)ID
|
||||||
{
|
{
|
||||||
self = [super initWithName: @"iq"
|
self = [super initWithName: @"iq"
|
||||||
type: type
|
type: type
|
||||||
|
|
|
@ -69,7 +69,7 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @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;
|
- (instancetype)initWithString: (OFString *)string;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Returns the bare JID.
|
* @brief Returns the bare JID.
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
return [[[self alloc] initWithString: string] autorelease];
|
return [[[self alloc] initWithString: string] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithString: (OFString *)string
|
- (instancetype)initWithString: (OFString *)string
|
||||||
{
|
{
|
||||||
size_t nodesep, resourcesep;
|
size_t nodesep, resourcesep;
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @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: (nullable OFString *)ID;
|
- (instancetype)initWithID: (nullable OFString *)ID;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Initializes an already allocated XMPPMessage with the specified type.
|
* @brief Initializes an already allocated XMPPMessage with the specified type.
|
||||||
|
@ -81,7 +81,7 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @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: (nullable OFString *)type;
|
- (instancetype)initWithType: (nullable OFString *)type;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Initializes an already allocated XMPPMessage with the specified type
|
* @brief Initializes an already allocated XMPPMessage with the specified type
|
||||||
|
@ -91,8 +91,8 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @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: (nullable OFString *)type
|
- (instancetype)initWithType: (nullable OFString *)type
|
||||||
ID: (nullable OFString *)ID OF_DESIGNATED_INITIALIZER;
|
ID: (nullable OFString *)ID OF_DESIGNATED_INITIALIZER;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_END
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -51,26 +51,26 @@
|
||||||
ID: ID] autorelease];
|
ID: ID] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- init
|
- (instancetype)init
|
||||||
{
|
{
|
||||||
return [self initWithType: nil
|
return [self initWithType: nil
|
||||||
ID: nil];
|
ID: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithID: (OFString *)ID
|
- (instancetype)initWithID: (OFString *)ID
|
||||||
{
|
{
|
||||||
return [self initWithType: nil
|
return [self initWithType: nil
|
||||||
ID: ID];
|
ID: ID];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithType: (OFString *)type
|
- (instancetype)initWithType: (OFString *)type
|
||||||
{
|
{
|
||||||
return [self initWithType: type
|
return [self initWithType: type
|
||||||
ID: nil];
|
ID: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithType: (OFString *)type
|
- (instancetype)initWithType: (OFString *)type
|
||||||
ID: (OFString *)ID
|
ID: (OFString *)ID
|
||||||
{
|
{
|
||||||
return [super initWithName: @"message"
|
return [super initWithName: @"message"
|
||||||
type: type
|
type: type
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#import "XMPPMulticastDelegate.h"
|
#import "XMPPMulticastDelegate.h"
|
||||||
|
|
||||||
@implementation XMPPMulticastDelegate
|
@implementation XMPPMulticastDelegate
|
||||||
- init
|
- (instancetype)init
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @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: (nullable OFString *)ID;
|
- (instancetype)initWithID: (nullable OFString *)ID;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Initializes an already allocated XMPPPresence with the specified type.
|
* @brief Initializes an already allocated XMPPPresence with the specified type.
|
||||||
|
@ -102,7 +102,7 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @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: (nullable OFString *)type;
|
- (instancetype)initWithType: (nullable OFString *)type;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Initializes an already allocated XMPPPresence with the specified type
|
* @brief Initializes an already allocated XMPPPresence with the specified type
|
||||||
|
@ -112,8 +112,8 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @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: (nullable OFString *)type
|
- (instancetype)initWithType: (nullable OFString *)type
|
||||||
ID: (nullable OFString *)ID;
|
ID: (nullable OFString *)ID;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_END
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -73,33 +73,33 @@ show_to_int(OFString *show)
|
||||||
ID: ID] autorelease];
|
ID: ID] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- init
|
- (instancetype)init
|
||||||
{
|
{
|
||||||
return [self initWithType: nil
|
return [self initWithType: nil
|
||||||
ID: nil];
|
ID: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithID: (OFString *)ID
|
- (instancetype)initWithID: (OFString *)ID
|
||||||
{
|
{
|
||||||
return [self initWithType: nil
|
return [self initWithType: nil
|
||||||
ID: ID];
|
ID: ID];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithType: (OFString *)type
|
- (instancetype)initWithType: (OFString *)type
|
||||||
{
|
{
|
||||||
return [self initWithType: type
|
return [self initWithType: type
|
||||||
ID: nil];
|
ID: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithType: (OFString *)type
|
- (instancetype)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
|
- (instancetype)initWithElement: (OFXMLElement *)element
|
||||||
{
|
{
|
||||||
self = [super initWithElement: element];
|
self = [super initWithElement: element];
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
@property (readonly, nonatomic)
|
@property (readonly, nonatomic)
|
||||||
OFDictionary OF_GENERIC(OFString *, XMPPRosterItem *) *rosterItems;
|
OFDictionary OF_GENERIC(OFString *, XMPPRosterItem *) *rosterItems;
|
||||||
|
|
||||||
- init OF_UNAVAILABLE;
|
- (instancetype)init OF_UNAVAILABLE;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Initializes an already allocated XMPPRoster.
|
* @brief Initializes an already allocated XMPPRoster.
|
||||||
|
@ -97,7 +97,8 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* received over
|
* received over
|
||||||
* @return An initialized XMPPRoster
|
* @return An initialized XMPPRoster
|
||||||
*/
|
*/
|
||||||
- initWithConnection: (XMPPConnection *)connection OF_DESIGNATED_INITIALIZER;
|
- (instancetype)initWithConnection: (XMPPConnection *)connection
|
||||||
|
OF_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Requests the roster from the server.
|
* @brief Requests the roster from the server.
|
||||||
|
|
|
@ -42,10 +42,10 @@
|
||||||
OF_ASSUME_NONNULL_BEGIN
|
OF_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface XMPPRoster ()
|
@interface XMPPRoster ()
|
||||||
- (void)XMPP_updateRosterItem: (XMPPRosterItem *)rosterItem;
|
- (void)xmpp_updateRosterItem: (XMPPRosterItem *)rosterItem;
|
||||||
- (void)XMPP_handleInitialRosterForConnection: (XMPPConnection *)connection
|
- (void)xmpp_handleInitialRosterForConnection: (XMPPConnection *)connection
|
||||||
IQ: (XMPPIQ *)IQ;
|
IQ: (XMPPIQ *)IQ;
|
||||||
- (XMPPRosterItem *)XMPP_rosterItemWithXMLElement: (OFXMLElement *)element;
|
- (XMPPRosterItem *)xmpp_rosterItemWithXMLElement: (OFXMLElement *)element;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_END
|
OF_ASSUME_NONNULL_END
|
||||||
|
@ -54,12 +54,12 @@ OF_ASSUME_NONNULL_END
|
||||||
@synthesize connection = _connection, dataStorage = _dataStorage;
|
@synthesize connection = _connection, dataStorage = _dataStorage;
|
||||||
@synthesize rosterItems = _rosterItems;
|
@synthesize rosterItems = _rosterItems;
|
||||||
|
|
||||||
- init
|
- (instancetype)init
|
||||||
{
|
{
|
||||||
OF_INVALID_INIT_METHOD
|
OF_INVALID_INIT_METHOD
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithConnection: (XMPPConnection *)connection
|
- (instancetype)initWithConnection: (XMPPConnection *)connection
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ OF_ASSUME_NONNULL_END
|
||||||
|
|
||||||
[_connection sendIQ: iq
|
[_connection sendIQ: iq
|
||||||
callbackTarget: self
|
callbackTarget: self
|
||||||
selector: @selector(XMPP_handleInitialRosterForConnection:
|
selector: @selector(xmpp_handleInitialRosterForConnection:
|
||||||
IQ:)];
|
IQ:)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,14 +144,14 @@ OF_ASSUME_NONNULL_END
|
||||||
namespace: XMPP_NS_ROSTER];
|
namespace: XMPP_NS_ROSTER];
|
||||||
|
|
||||||
if (element != nil) {
|
if (element != nil) {
|
||||||
rosterItem = [self XMPP_rosterItemWithXMLElement: element];
|
rosterItem = [self xmpp_rosterItemWithXMLElement: element];
|
||||||
|
|
||||||
[_delegates broadcastSelector: @selector(
|
[_delegates broadcastSelector: @selector(
|
||||||
roster:didReceiveRosterItem:)
|
roster:didReceiveRosterItem:)
|
||||||
withObject: self
|
withObject: self
|
||||||
withObject: rosterItem];
|
withObject: rosterItem];
|
||||||
|
|
||||||
[self XMPP_updateRosterItem: rosterItem];
|
[self xmpp_updateRosterItem: rosterItem];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([_connection supportsRosterVersioning]) {
|
if ([_connection supportsRosterVersioning]) {
|
||||||
|
@ -180,8 +180,6 @@ OF_ASSUME_NONNULL_END
|
||||||
namespace: XMPP_NS_ROSTER];
|
namespace: XMPP_NS_ROSTER];
|
||||||
OFXMLElement *item = [OFXMLElement elementWithName: @"item"
|
OFXMLElement *item = [OFXMLElement elementWithName: @"item"
|
||||||
namespace: XMPP_NS_ROSTER];
|
namespace: XMPP_NS_ROSTER];
|
||||||
OFEnumerator *enumerator;
|
|
||||||
OFString *group;
|
|
||||||
|
|
||||||
[item addAttributeWithName: @"jid"
|
[item addAttributeWithName: @"jid"
|
||||||
stringValue: [[rosterItem JID] bareJID]];
|
stringValue: [[rosterItem JID] bareJID]];
|
||||||
|
@ -189,8 +187,7 @@ OF_ASSUME_NONNULL_END
|
||||||
[item addAttributeWithName: @"name"
|
[item addAttributeWithName: @"name"
|
||||||
stringValue: [rosterItem name]];
|
stringValue: [rosterItem name]];
|
||||||
|
|
||||||
enumerator = [[rosterItem groups] objectEnumerator];
|
for (OFString *group in [rosterItem groups])
|
||||||
while ((group = [enumerator nextObject]) != nil)
|
|
||||||
[item addChild: [OFXMLElement elementWithName: @"group"
|
[item addChild: [OFXMLElement elementWithName: @"group"
|
||||||
namespace: XMPP_NS_ROSTER
|
namespace: XMPP_NS_ROSTER
|
||||||
stringValue: group]];
|
stringValue: group]];
|
||||||
|
@ -240,7 +237,7 @@ OF_ASSUME_NONNULL_END
|
||||||
_dataStorage = dataStorage;
|
_dataStorage = dataStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)XMPP_updateRosterItem: (XMPPRosterItem *)rosterItem
|
- (void)xmpp_updateRosterItem: (XMPPRosterItem *)rosterItem
|
||||||
{
|
{
|
||||||
if ([_connection supportsRosterVersioning]) {
|
if ([_connection supportsRosterVersioning]) {
|
||||||
OFMutableDictionary *items = [[[_dataStorage dictionaryForPath:
|
OFMutableDictionary *items = [[[_dataStorage dictionaryForPath:
|
||||||
|
@ -280,11 +277,9 @@ OF_ASSUME_NONNULL_END
|
||||||
[_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;
|
|
||||||
OFXMLElement *groupElement;
|
|
||||||
OFMutableArray *groups = [OFMutableArray array];
|
OFMutableArray *groups = [OFMutableArray array];
|
||||||
XMPPRosterItem *rosterItem = [XMPPRosterItem rosterItem];
|
XMPPRosterItem *rosterItem = [XMPPRosterItem rosterItem];
|
||||||
[rosterItem setJID: [XMPPJID JIDWithString:
|
[rosterItem setJID: [XMPPJID JIDWithString:
|
||||||
|
@ -304,10 +299,9 @@ OF_ASSUME_NONNULL_END
|
||||||
|
|
||||||
[rosterItem setSubscription: subscription];
|
[rosterItem setSubscription: subscription];
|
||||||
|
|
||||||
groupEnumerator = [[element
|
for (OFXMLElement *groupElement in
|
||||||
elementsForName: @"group"
|
[element elementsForName: @"group"
|
||||||
namespace: XMPP_NS_ROSTER] objectEnumerator];
|
namespace: XMPP_NS_ROSTER])
|
||||||
while ((groupElement = [groupEnumerator nextObject]) != nil)
|
|
||||||
[groups addObject: [groupElement stringValue]];
|
[groups addObject: [groupElement stringValue]];
|
||||||
|
|
||||||
if ([groups count] > 0)
|
if ([groups count] > 0)
|
||||||
|
@ -316,7 +310,7 @@ OF_ASSUME_NONNULL_END
|
||||||
return rosterItem;
|
return rosterItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)XMPP_handleInitialRosterForConnection: (XMPPConnection *)connection
|
- (void)xmpp_handleInitialRosterForConnection: (XMPPConnection *)connection
|
||||||
IQ: (XMPPIQ *)IQ
|
IQ: (XMPPIQ *)IQ
|
||||||
{
|
{
|
||||||
OFXMLElement *rosterElement = [IQ elementForName: @"query"
|
OFXMLElement *rosterElement = [IQ elementForName: @"query"
|
||||||
|
@ -324,12 +318,8 @@ OF_ASSUME_NONNULL_END
|
||||||
|
|
||||||
if ([connection supportsRosterVersioning]) {
|
if ([connection supportsRosterVersioning]) {
|
||||||
if (rosterElement == nil) {
|
if (rosterElement == nil) {
|
||||||
OFDictionary *items = [_dataStorage
|
for (OFDictionary *item in
|
||||||
dictionaryForPath: @"roster.items"];
|
[_dataStorage dictionaryForPath: @"roster.items"]) {
|
||||||
OFEnumerator *enumerator = [items objectEnumerator];
|
|
||||||
OFDictionary *item;
|
|
||||||
|
|
||||||
while ((item = [enumerator nextObject]) != nil) {
|
|
||||||
XMPPRosterItem *rosterItem;
|
XMPPRosterItem *rosterItem;
|
||||||
XMPPJID *JID;
|
XMPPJID *JID;
|
||||||
|
|
||||||
|
@ -360,9 +350,9 @@ OF_ASSUME_NONNULL_END
|
||||||
![[element namespace] isEqual: XMPP_NS_ROSTER])
|
![[element namespace] isEqual: XMPP_NS_ROSTER])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
rosterItem = [self XMPP_rosterItemWithXMLElement: element];
|
rosterItem = [self xmpp_rosterItemWithXMLElement: element];
|
||||||
|
|
||||||
[self XMPP_updateRosterItem: rosterItem];
|
[self xmpp_updateRosterItem: rosterItem];
|
||||||
|
|
||||||
objc_autoreleasePoolPop(pool);
|
objc_autoreleasePoolPop(pool);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,11 +76,11 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
hash: (Class)hash
|
hash: (Class)hash
|
||||||
plusAvailable: (bool)plusAvailable;
|
plusAvailable: (bool)plusAvailable;
|
||||||
|
|
||||||
- initWithAuthcid: (nullable OFString *)authcid
|
- (instancetype)initWithAuthcid: (nullable OFString *)authcid
|
||||||
password: (nullable OFString *)password OF_UNAVAILABLE;
|
password: (nullable OFString *)password OF_UNAVAILABLE;
|
||||||
- initWithAuthzid: (nullable OFString *)authzid
|
- (instancetype)initWithAuthzid: (nullable OFString *)authzid
|
||||||
authcid: (nullable OFString *)authcid
|
authcid: (nullable OFString *)authcid
|
||||||
password: (nullable OFString *)password OF_UNAVAILABLE;
|
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
|
||||||
|
@ -93,11 +93,11 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @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: (nullable OFString *)authcid
|
- (instancetype)initWithAuthcid: (nullable OFString *)authcid
|
||||||
password: (nullable OFString *)password
|
password: (nullable OFString *)password
|
||||||
connection: (XMPPConnection *)connection
|
connection: (XMPPConnection *)connection
|
||||||
hash: (Class)hash
|
hash: (Class)hash
|
||||||
plusAvailable: (bool)plusAvailable;
|
plusAvailable: (bool)plusAvailable;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Initializes an already allocated XMPPSCRAMAuth with a authzid,
|
* @brief Initializes an already allocated XMPPSCRAMAuth with a authzid,
|
||||||
|
@ -111,12 +111,12 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @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: (nullable OFString *)authzid
|
- (instancetype)initWithAuthzid: (nullable OFString *)authzid
|
||||||
authcid: (nullable OFString *)authcid
|
authcid: (nullable OFString *)authcid
|
||||||
password: (nullable OFString *)password
|
password: (nullable OFString *)password
|
||||||
connection: (XMPPConnection *)connection
|
connection: (XMPPConnection *)connection
|
||||||
hash: (Class)hash
|
hash: (Class)hash
|
||||||
plusAvailable: (bool)plusAvailable OF_DESIGNATED_INITIALIZER;
|
plusAvailable: (bool)plusAvailable OF_DESIGNATED_INITIALIZER;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_END
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -37,21 +37,17 @@
|
||||||
#define HMAC_IPAD 0x36
|
#define HMAC_IPAD 0x36
|
||||||
#define HMAC_OPAD 0x5c
|
#define HMAC_OPAD 0x5c
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_BEGIN
|
|
||||||
|
|
||||||
@interface XMPPSCRAMAuth ()
|
@interface XMPPSCRAMAuth ()
|
||||||
- (OFString *)XMPP_genNonce;
|
- (OFString *)xmpp_genNonce;
|
||||||
- (const uint8_t *)XMPP_HMACWithKey: (OFData *)key
|
- (const uint8_t *)xmpp_HMACWithKey: (OFData *)key
|
||||||
data: (OFData *)data;
|
data: (OFData *)data;
|
||||||
- (OFData *)XMPP_hiWithData: (OFData *)str
|
- (OFData *)xmpp_hiWithData: (OFData *)str
|
||||||
salt: (OFData *)salt
|
salt: (OFData *)salt
|
||||||
iterationCount: (intmax_t)i;
|
iterationCount: (intmax_t)i;
|
||||||
- (OFData *)XMPP_parseServerFirstMessage: (OFData *)data;
|
- (OFData *)xmpp_parseServerFirstMessage: (OFData *)data;
|
||||||
- (OFData *)XMPP_parseServerFinalMessage: (OFData *)data;
|
- (OFData *)xmpp_parseServerFinalMessage: (OFData *)data;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_END
|
|
||||||
|
|
||||||
@implementation XMPPSCRAMAuth
|
@implementation XMPPSCRAMAuth
|
||||||
+ (instancetype)SCRAMAuthWithAuthcid: (OFString *)authcid
|
+ (instancetype)SCRAMAuthWithAuthcid: (OFString *)authcid
|
||||||
password: (OFString *)password
|
password: (OFString *)password
|
||||||
|
@ -81,11 +77,11 @@ OF_ASSUME_NONNULL_END
|
||||||
plusAvailable: plusAvailable] autorelease];
|
plusAvailable: plusAvailable] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithAuthcid: (OFString *)authcid
|
- (instancetype)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
|
||||||
{
|
{
|
||||||
return [self initWithAuthzid: nil
|
return [self initWithAuthzid: nil
|
||||||
authcid: authcid
|
authcid: authcid
|
||||||
|
@ -95,12 +91,12 @@ OF_ASSUME_NONNULL_END
|
||||||
plusAvailable: plusAvailable];
|
plusAvailable: plusAvailable];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithAuthzid: (OFString *)authzid
|
- (instancetype)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
|
||||||
{
|
{
|
||||||
self = [super initWithAuthzid: authzid
|
self = [super initWithAuthzid: authzid
|
||||||
authcid: authcid
|
authcid: authcid
|
||||||
|
@ -179,7 +175,7 @@ OF_ASSUME_NONNULL_END
|
||||||
else
|
else
|
||||||
_GS2Header = (_plusAvailable ? @"p=tls-unique,," : @"y,,");
|
_GS2Header = (_plusAvailable ? @"p=tls-unique,," : @"y,,");
|
||||||
|
|
||||||
_cNonce = [[self XMPP_genNonce] retain];
|
_cNonce = [[self xmpp_genNonce] retain];
|
||||||
|
|
||||||
[_clientFirstMessageBare release];
|
[_clientFirstMessageBare release];
|
||||||
_clientFirstMessageBare = nil;
|
_clientFirstMessageBare = nil;
|
||||||
|
@ -203,9 +199,9 @@ OF_ASSUME_NONNULL_END
|
||||||
OFData *ret;
|
OFData *ret;
|
||||||
|
|
||||||
if (!_serverSignature)
|
if (!_serverSignature)
|
||||||
ret = [self XMPP_parseServerFirstMessage: data];
|
ret = [self xmpp_parseServerFirstMessage: data];
|
||||||
else
|
else
|
||||||
ret = [self XMPP_parseServerFinalMessage: data];
|
ret = [self xmpp_parseServerFinalMessage: data];
|
||||||
|
|
||||||
[ret retain];
|
[ret retain];
|
||||||
[pool release];
|
[pool release];
|
||||||
|
@ -213,7 +209,7 @@ OF_ASSUME_NONNULL_END
|
||||||
return [ret autorelease];
|
return [ret autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (OFData *)XMPP_parseServerFirstMessage: (OFData *)data
|
- (OFData *)xmpp_parseServerFirstMessage: (OFData *)data
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
const uint8_t *clientKey, *serverKey, *clientSignature;
|
const uint8_t *clientKey, *serverKey, *clientSignature;
|
||||||
|
@ -222,8 +218,6 @@ OF_ASSUME_NONNULL_END
|
||||||
OFMutableData *ret, *authMessage, *tmpArray;
|
OFMutableData *ret, *authMessage, *tmpArray;
|
||||||
OFData *salt = nil, *saltedPassword;
|
OFData *salt = nil, *saltedPassword;
|
||||||
OFString *tmpString, *sNonce = nil;
|
OFString *tmpString, *sNonce = nil;
|
||||||
OFEnumerator *enumerator;
|
|
||||||
OFString *comp;
|
|
||||||
enum {
|
enum {
|
||||||
GOT_SNONCE = 0x01,
|
GOT_SNONCE = 0x01,
|
||||||
GOT_SALT = 0x02,
|
GOT_SALT = 0x02,
|
||||||
|
@ -234,17 +228,16 @@ OF_ASSUME_NONNULL_END
|
||||||
ret = [OFMutableData data];
|
ret = [OFMutableData data];
|
||||||
authMessage = [OFMutableData data];
|
authMessage = [OFMutableData data];
|
||||||
|
|
||||||
OFString *chal = [OFString stringWithUTF8String: [data items]
|
OFString *challenge = [OFString stringWithUTF8String: [data items]
|
||||||
length: [data count] *
|
length: [data count] *
|
||||||
[data itemSize]];
|
[data itemSize]];
|
||||||
|
|
||||||
enumerator =
|
for (OFString *component in
|
||||||
[[chal componentsSeparatedByString: @","] objectEnumerator];
|
[challenge componentsSeparatedByString: @","]) {
|
||||||
while ((comp = [enumerator nextObject]) != nil) {
|
OFString *entry = [component substringWithRange:
|
||||||
OFString *entry = [comp substringWithRange:
|
of_range(2, [component length] - 2)];
|
||||||
of_range(2, [comp length] - 2)];
|
|
||||||
|
|
||||||
if ([comp hasPrefix: @"r="]) {
|
if ([component hasPrefix: @"r="]) {
|
||||||
if (![entry hasPrefix: _cNonce])
|
if (![entry hasPrefix: _cNonce])
|
||||||
@throw [XMPPAuthFailedException
|
@throw [XMPPAuthFailedException
|
||||||
exceptionWithConnection: nil
|
exceptionWithConnection: nil
|
||||||
|
@ -253,10 +246,10 @@ OF_ASSUME_NONNULL_END
|
||||||
|
|
||||||
sNonce = entry;
|
sNonce = entry;
|
||||||
got |= GOT_SNONCE;
|
got |= GOT_SNONCE;
|
||||||
} else if ([comp hasPrefix: @"s="]) {
|
} else if ([component hasPrefix: @"s="]) {
|
||||||
salt = [OFData dataWithBase64EncodedString: entry];
|
salt = [OFData dataWithBase64EncodedString: entry];
|
||||||
got |= GOT_SALT;
|
got |= GOT_SALT;
|
||||||
} else if ([comp hasPrefix: @"i="]) {
|
} else if ([component hasPrefix: @"i="]) {
|
||||||
iterCount = [entry decimalValue];
|
iterCount = [entry decimalValue];
|
||||||
got |= GOT_ITERCOUNT;
|
got |= GOT_ITERCOUNT;
|
||||||
}
|
}
|
||||||
|
@ -293,7 +286,7 @@ OF_ASSUME_NONNULL_END
|
||||||
*/
|
*/
|
||||||
tmpArray = [OFMutableData dataWithItems: [_password UTF8String]
|
tmpArray = [OFMutableData dataWithItems: [_password UTF8String]
|
||||||
count: [_password UTF8StringLength]];
|
count: [_password UTF8StringLength]];
|
||||||
saltedPassword = [self XMPP_hiWithData: tmpArray
|
saltedPassword = [self xmpp_hiWithData: tmpArray
|
||||||
salt: salt
|
salt: salt
|
||||||
iterationCount: iterCount];
|
iterationCount: iterCount];
|
||||||
|
|
||||||
|
@ -316,7 +309,7 @@ OF_ASSUME_NONNULL_END
|
||||||
* IETF RFC 5802:
|
* IETF RFC 5802:
|
||||||
* ClientKey := HMAC(SaltedPassword, "Client Key")
|
* ClientKey := HMAC(SaltedPassword, "Client Key")
|
||||||
*/
|
*/
|
||||||
clientKey = [self XMPP_HMACWithKey: saltedPassword
|
clientKey = [self xmpp_HMACWithKey: saltedPassword
|
||||||
data: [OFData dataWithItems: "Client Key"
|
data: [OFData dataWithItems: "Client Key"
|
||||||
count: 10]];
|
count: 10]];
|
||||||
|
|
||||||
|
@ -332,7 +325,7 @@ OF_ASSUME_NONNULL_END
|
||||||
* ClientSignature := HMAC(StoredKey, AuthMessage)
|
* ClientSignature := HMAC(StoredKey, AuthMessage)
|
||||||
*/
|
*/
|
||||||
clientSignature = [self
|
clientSignature = [self
|
||||||
XMPP_HMACWithKey: [OFData dataWithItems: [hash digest]
|
xmpp_HMACWithKey: [OFData dataWithItems: [hash digest]
|
||||||
count: [_hashType digestSize]]
|
count: [_hashType digestSize]]
|
||||||
data: authMessage];
|
data: authMessage];
|
||||||
|
|
||||||
|
@ -340,7 +333,7 @@ OF_ASSUME_NONNULL_END
|
||||||
* IETF RFC 5802:
|
* IETF RFC 5802:
|
||||||
* ServerKey := HMAC(SaltedPassword, "Server Key")
|
* ServerKey := HMAC(SaltedPassword, "Server Key")
|
||||||
*/
|
*/
|
||||||
serverKey = [self XMPP_HMACWithKey: saltedPassword
|
serverKey = [self xmpp_HMACWithKey: saltedPassword
|
||||||
data: [OFData dataWithItems: "Server Key"
|
data: [OFData dataWithItems: "Server Key"
|
||||||
count: 10]];
|
count: 10]];
|
||||||
|
|
||||||
|
@ -353,7 +346,7 @@ OF_ASSUME_NONNULL_END
|
||||||
|
|
||||||
[_serverSignature release];
|
[_serverSignature release];
|
||||||
_serverSignature = [[OFData alloc]
|
_serverSignature = [[OFData alloc]
|
||||||
initWithItems: [self XMPP_HMACWithKey: tmpArray
|
initWithItems: [self xmpp_HMACWithKey: tmpArray
|
||||||
data: authMessage]
|
data: authMessage]
|
||||||
count: [_hashType digestSize]];
|
count: [_hashType digestSize]];
|
||||||
|
|
||||||
|
@ -378,7 +371,7 @@ OF_ASSUME_NONNULL_END
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (OFData *)XMPP_parseServerFinalMessage: (OFData *)data
|
- (OFData *)xmpp_parseServerFinalMessage: (OFData *)data
|
||||||
{
|
{
|
||||||
OFString *mess, *value;
|
OFString *mess, *value;
|
||||||
|
|
||||||
|
@ -407,7 +400,7 @@ OF_ASSUME_NONNULL_END
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (OFString *)XMPP_genNonce
|
- (OFString *)xmpp_genNonce
|
||||||
{
|
{
|
||||||
uint8_t buf[64];
|
uint8_t buf[64];
|
||||||
size_t i;
|
size_t i;
|
||||||
|
@ -428,7 +421,7 @@ OF_ASSUME_NONNULL_END
|
||||||
length: 64];
|
length: 64];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (const uint8_t *)XMPP_HMACWithKey: (OFData *)key
|
- (const uint8_t *)xmpp_HMACWithKey: (OFData *)key
|
||||||
data: (OFData *)data
|
data: (OFData *)data
|
||||||
{
|
{
|
||||||
void *pool = objc_autoreleasePoolPush();
|
void *pool = objc_autoreleasePoolPush();
|
||||||
|
@ -484,7 +477,7 @@ OF_ASSUME_NONNULL_END
|
||||||
return [[hashO autorelease] digest];
|
return [[hashO autorelease] digest];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (OFData *)XMPP_hiWithData: (OFData *)str
|
- (OFData *)xmpp_hiWithData: (OFData *)str
|
||||||
salt: (OFData *)salt
|
salt: (OFData *)salt
|
||||||
iterationCount: (intmax_t)i
|
iterationCount: (intmax_t)i
|
||||||
{
|
{
|
||||||
|
@ -505,7 +498,7 @@ OF_ASSUME_NONNULL_END
|
||||||
[salty addItems: "\0\0\0\1"
|
[salty addItems: "\0\0\0\1"
|
||||||
count: 4];
|
count: 4];
|
||||||
|
|
||||||
uOld = [self XMPP_HMACWithKey: str
|
uOld = [self xmpp_HMACWithKey: str
|
||||||
data: salty];
|
data: salty];
|
||||||
|
|
||||||
for (j = 0; j < digestSize; j++)
|
for (j = 0; j < digestSize; j++)
|
||||||
|
@ -521,7 +514,7 @@ OF_ASSUME_NONNULL_END
|
||||||
pool = objc_autoreleasePoolPush();
|
pool = objc_autoreleasePoolPush();
|
||||||
[tmp autorelease];
|
[tmp autorelease];
|
||||||
|
|
||||||
u = [self XMPP_HMACWithKey: str
|
u = [self xmpp_HMACWithKey: str
|
||||||
data: tmp];
|
data: tmp];
|
||||||
|
|
||||||
for (k = 0; k < digestSize; k++)
|
for (k = 0; k < digestSize; k++)
|
||||||
|
|
|
@ -111,15 +111,15 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
*/
|
*/
|
||||||
+ (instancetype)stanzaWithElement: (OFXMLElement *)element;
|
+ (instancetype)stanzaWithElement: (OFXMLElement *)element;
|
||||||
|
|
||||||
- initWithName: (OFString *)name
|
- (instancetype)initWithName: (OFString *)name
|
||||||
stringValue: (nullable OFString *)stringValue OF_UNAVAILABLE;
|
stringValue: (nullable OFString *)stringValue OF_UNAVAILABLE;
|
||||||
- initWithName: (OFString *)name
|
- (instancetype)initWithName: (OFString *)name
|
||||||
namespace: (nullable OFString *)namespace OF_UNAVAILABLE;
|
namespace: (nullable OFString *)namespace OF_UNAVAILABLE;
|
||||||
- initWithName: (OFString *)name
|
- (instancetype)initWithName: (OFString *)name
|
||||||
namespace: (nullable OFString *)namespace
|
namespace: (nullable OFString *)namespace
|
||||||
stringValue: (nullable OFString *)stringValue OF_UNAVAILABLE;
|
stringValue: (nullable OFString *)stringValue OF_UNAVAILABLE;
|
||||||
- initWithXMLString: (OFString *)string OF_UNAVAILABLE;
|
- (instancetype)initWithXMLString: (OFString *)string OF_UNAVAILABLE;
|
||||||
- initWithFile: (OFString *)path OF_UNAVAILABLE;
|
- (instancetype)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.
|
||||||
|
@ -127,7 +127,7 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @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;
|
- (instancetype)initWithName: (OFString *)name;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Initializes an already allocated XMPPStanza with the specified name
|
* @brief Initializes an already allocated XMPPStanza with the specified name
|
||||||
|
@ -137,8 +137,8 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @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
|
- (instancetype)initWithName: (OFString *)name
|
||||||
type: (nullable 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
|
||||||
|
@ -148,8 +148,8 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @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
|
- (instancetype)initWithName: (OFString *)name
|
||||||
ID: (nullable 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,
|
||||||
|
@ -160,9 +160,9 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @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
|
- (instancetype)initWithName: (OFString *)name
|
||||||
type: (nullable OFString *)type
|
type: (nullable OFString *)type
|
||||||
ID: (nullable 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.
|
||||||
|
@ -170,7 +170,7 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
* @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;
|
- (instancetype)initWithElement: (OFXMLElement *)element;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_END
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -66,49 +66,49 @@
|
||||||
return [[[self alloc] initWithElement: element] autorelease];
|
return [[[self alloc] initWithElement: element] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithName: (OFString *)name
|
- (instancetype)initWithName: (OFString *)name
|
||||||
namespace: (nullable OFString *)namespace
|
namespace: (nullable OFString *)namespace
|
||||||
stringValue: (nullable OFString *)stringValue
|
stringValue: (nullable OFString *)stringValue
|
||||||
{
|
{
|
||||||
OF_INVALID_INIT_METHOD
|
OF_INVALID_INIT_METHOD
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithXMLString: (OFString *)string
|
- (instancetype)initWithXMLString: (OFString *)string
|
||||||
{
|
{
|
||||||
OF_INVALID_INIT_METHOD
|
OF_INVALID_INIT_METHOD
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithFile: (OFString *)path
|
- (instancetype)initWithFile: (OFString *)path
|
||||||
{
|
{
|
||||||
OF_INVALID_INIT_METHOD
|
OF_INVALID_INIT_METHOD
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithName: (OFString *)name
|
- (instancetype)initWithName: (OFString *)name
|
||||||
{
|
{
|
||||||
return [self initWithName: name
|
return [self initWithName: name
|
||||||
type: nil
|
type: nil
|
||||||
ID: nil];
|
ID: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithName: (OFString *)name
|
- (instancetype)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
|
- (instancetype)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
|
- (instancetype)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
|
||||||
|
@ -136,7 +136,7 @@
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithElement: (OFXMLElement *)element
|
- (instancetype)initWithElement: (OFXMLElement *)element
|
||||||
{
|
{
|
||||||
self = [super initWithElement: element];
|
self = [super initWithElement: element];
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,8 @@ OF_ASSUME_NONNULL_BEGIN
|
||||||
uint32_t _receivedCount;
|
uint32_t _receivedCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
- init OF_UNAVAILABLE;
|
- (instancetype)init OF_UNAVAILABLE;
|
||||||
- initWithConnection: (XMPPConnection *)connection;
|
- (instancetype)initWithConnection: (XMPPConnection *)connection;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
OF_ASSUME_NONNULL_END
|
OF_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -26,12 +26,12 @@
|
||||||
#import "namespaces.h"
|
#import "namespaces.h"
|
||||||
|
|
||||||
@implementation XMPPStreamManagement
|
@implementation XMPPStreamManagement
|
||||||
- init
|
- (instancetype)init
|
||||||
{
|
{
|
||||||
OF_INVALID_INIT_METHOD
|
OF_INVALID_INIT_METHOD
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithConnection: (XMPPConnection *)connection
|
- (instancetype)initWithConnection: (XMPPConnection *)connection
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue