Adjust to ObjFW changes

FossilOrigin-Name: 46f67c971bc57abd330349d54d237931079a832baaf20909e77039f6ce4b896d
This commit is contained in:
Jonathan Schleifer 2021-04-28 23:20:55 +00:00
parent c49e9a7375
commit 851e7fe676
10 changed files with 99 additions and 104 deletions

View file

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2010, 2011, 2012, 2013, 2015, 2016, 2017, 2018, 2019 * Copyright (c) 2010, 2011, 2012, 2013, 2015, 2016, 2017, 2018, 2019, 2021
* Jonathan Schleifer <js@heap.zone> * Jonathan Schleifer <js@nil.im>
* Copyright (c) 2011, 2012, Florian Zeitz <florob@babelmonkeys.de> * Copyright (c) 2011, 2012, Florian Zeitz <florob@babelmonkeys.de>
* *
* https://heap.zone/objxmpp/ * https://heap.zone/objxmpp/
@ -344,8 +344,8 @@
stringByPrependingString: @"_xmpp-client._tcp."]; stringByPrependingString: @"_xmpp-client._tcp."];
OFDNSQuery *query = [OFDNSQuery OFDNSQuery *query = [OFDNSQuery
queryWithDomainName: SRVDomain queryWithDomainName: SRVDomain
DNSClass: OF_DNS_CLASS_IN DNSClass: OFDNSClassIN
recordType: OF_DNS_RECORD_TYPE_SRV]; recordType: OFDNSRecordTypeSRV];
[[OFThread DNSResolver] asyncPerformQuery: query [[OFThread DNSResolver] asyncPerformQuery: query
delegate: self]; delegate: self];
} }
@ -753,7 +753,7 @@
withObject: self]; withObject: self];
newSock = [[SSLSocket alloc] initWithSocket: _socket]; newSock = [[SSLSocket alloc] initWithSocket: _socket];
newSock.certificateVerificationEnabled = false; newSock.verifiesCertificates = false;
#if 0 #if 0
/* FIXME: Not yet implemented by ObjOpenSSL */ /* FIXME: Not yet implemented by ObjOpenSSL */
[newSock setCertificateFile: _certificateFile]; [newSock setCertificateFile: _certificateFile];
@ -1084,7 +1084,7 @@
IQ: (XMPPIQ *)IQ IQ: (XMPPIQ *)IQ
{ {
if (![IQ.type isEqual: @"result"]) if (![IQ.type isEqual: @"result"])
OF_ENSURE(0); OFEnsure(0);
[_delegates broadcastSelector: @selector(connection:wasBoundToJID:) [_delegates broadcastSelector: @selector(connection:wasBoundToJID:)
withObject: self withObject: self

View file

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013, Florian Zeitz <florob@babelmonkeys.de> * Copyright (c) 2013, Florian Zeitz <florob@babelmonkeys.de>
* Copyright (c) 2013, 2016, 2019, Jonathan Schleifer <js@heap.zone> * Copyright (c) 2013, 2016, 2019, 2021, Jonathan Schleifer <js@nil.im>
* *
* https://heap.zone/objxmpp/ * https://heap.zone/objxmpp/
* *
@ -161,7 +161,6 @@
/* Subscription request */ /* Subscription request */
if ([type isEqual: @"subscribe"]) { if ([type isEqual: @"subscribe"]) {
of_log(@"ObjXMPP: received subscription request");
[_delegates broadcastSelector: @selector(contactManager: [_delegates broadcastSelector: @selector(contactManager:
didReceiveSubscriptionRequest:) didReceiveSubscriptionRequest:)
withObject: self withObject: self

View file

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013, Florian Zeitz <florob@babelmonkeys.de> * Copyright (c) 2013, Florian Zeitz <florob@babelmonkeys.de>
* Copyright (c) 2013, 2016, 2019, Jonathan Schleifer <js@heap.zone> * Copyright (c) 2013, 2016, 2019, 2021, Jonathan Schleifer <js@nil.im>
* *
* https://heap.zone/objxmpp/ * https://heap.zone/objxmpp/
* *
@ -114,8 +114,7 @@
- (OFString *)capsHash - (OFString *)capsHash
{ {
OFMutableString *caps = [OFMutableString string]; OFMutableString *caps = [OFMutableString string];
OFSHA1Hash *hash = [OFSHA1Hash OFSHA1Hash *hash = [OFSHA1Hash hashWithAllowsSwappableMemory: true];
cryptoHashWithAllowsSwappableMemory: true];
OFData *digest; OFData *digest;
for (XMPPDiscoIdentity *identity in _identities) for (XMPPDiscoIdentity *identity in _identities)

View file

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013, Florian Zeitz <florob@babelmonkeys.de> * Copyright (c) 2013, Florian Zeitz <florob@babelmonkeys.de>
* Copyright (c) 2013, 2016, 2019, Jonathan Schleifer <js@heap.zone> * Copyright (c) 2013, 2016, 2019, 2021, Jonathan Schleifer <js@nil.im>
* *
* https://heap.zone/objxmpp/ * https://heap.zone/objxmpp/
* *
@ -105,29 +105,28 @@
return false; return false;
} }
- (uint32_t)hash - (unsigned long)hash
{ {
uint32_t hash; unsigned long hash;
OF_HASH_INIT(hash); OFHashInit(&hash);
OF_HASH_ADD_HASH(hash, _category.hash); OFHashAddHash(&hash, _category.hash);
OF_HASH_ADD_HASH(hash, _type.hash); OFHashAddHash(&hash, _type.hash);
OF_HASH_ADD_HASH(hash, _name.hash); OFHashAddHash(&hash, _name.hash);
OF_HASH_FINALIZE(hash); OFHashFinalize(&hash);
return hash; return hash;
} }
- (of_comparison_result_t)compare: (id <OFComparing>)object - (OFComparisonResult)compare: (id <OFComparing>)object
{ {
XMPPDiscoIdentity *identity; XMPPDiscoIdentity *identity;
of_comparison_result_t categoryResult; OFComparisonResult categoryResult, typeResult;
of_comparison_result_t typeResult;
if (object == self) if (object == self)
return OF_ORDERED_SAME; return OFOrderedSame;
if (![(id)object isKindOfClass: [XMPPDiscoIdentity class]]) if (![(id)object isKindOfClass: [XMPPDiscoIdentity class]])
@throw [OFInvalidArgumentException exception]; @throw [OFInvalidArgumentException exception];
@ -135,11 +134,11 @@
identity = (XMPPDiscoIdentity *)object; identity = (XMPPDiscoIdentity *)object;
categoryResult = [_category compare: identity->_category]; categoryResult = [_category compare: identity->_category];
if (categoryResult != OF_ORDERED_SAME) if (categoryResult != OFOrderedSame)
return categoryResult; return categoryResult;
typeResult = [_type compare: identity->_type]; typeResult = [_type compare: identity->_type];
if (typeResult != OF_ORDERED_SAME) if (typeResult != OFOrderedSame)
return typeResult; return typeResult;
return [_name compare: identity->_name]; return [_name compare: identity->_name];

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, 2019, Jonathan Schleifer <js@webkeks.org> * Copyright (c) 2012, 2019, 2021, Jonathan Schleifer <js@nil.im>
* *
* https://heap.zone/objxmpp/ * https://heap.zone/objxmpp/
* *
@ -50,7 +50,7 @@
_file = [file copy]; _file = [file copy];
@try { @try {
_data = [[OFData dataWithContentsOfFile: file] _data = [[OFData dataWithContentsOfFile: file]
.messagePackValue copy]; .objectByParsingMessagePack copy];
} @catch (id e) { } @catch (id e) {
_data = [[OFMutableDictionary alloc] init]; _data = [[OFMutableDictionary alloc] init];
} }
@ -162,23 +162,23 @@
return boolean; return boolean;
} }
- (void)setIntegerValue: (intmax_t)integer - (void)setIntegerValue: (long long)integer
forPath: (OFString *)path forPath: (OFString *)path
{ {
void *pool = objc_autoreleasePoolPush(); void *pool = objc_autoreleasePoolPush();
[self xmpp_setObject: [OFNumber numberWithIntMax: integer] [self xmpp_setObject: [OFNumber numberWithLongLong: integer]
forPath: path]; forPath: path];
objc_autoreleasePoolPop(pool); objc_autoreleasePoolPop(pool);
} }
- (intmax_t)integerValueForPath: (OFString *)path - (long long)integerValueForPath: (OFString *)path
{ {
void *pool = objc_autoreleasePoolPush(); void *pool = objc_autoreleasePoolPush();
intmax_t integer; long long integer;
integer = [[self xmpp_objectForPath: path] intMaxValue]; integer = [[self xmpp_objectForPath: path] longLongValue];
objc_autoreleasePoolPop(pool); objc_autoreleasePoolPop(pool);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, 2012, 2013, 2019, Jonathan Schleifer <js@heap.zone> * Copyright (c) 2011, 2012, 2013, 2019, 2021, Jonathan Schleifer <js@nil.im>
* Copyright (c) 2011, 2012, 2013, Florian Zeitz <florob@babelmonkeys.de> * Copyright (c) 2011, 2012, 2013, Florian Zeitz <florob@babelmonkeys.de>
* *
* https://heap.zone/objxmpp/ * https://heap.zone/objxmpp/
@ -59,20 +59,20 @@
if (nodesep == SIZE_MAX) if (nodesep == SIZE_MAX)
self.node = nil; self.node = nil;
else else
self.node = self.node = [string substringWithRange:
[string substringWithRange: of_range(0, nodesep)]; OFRangeMake(0, nodesep)];
if (resourcesep == SIZE_MAX) { if (resourcesep == SIZE_MAX) {
self.resource = nil; self.resource = nil;
resourcesep = string.length; resourcesep = string.length;
} else { } else {
of_range_t range = of_range(resourcesep + 1, OFRange range = OFRangeMake(resourcesep + 1,
string.length - resourcesep - 1); string.length - resourcesep - 1);
self.resource = [string substringWithRange: range]; self.resource = [string substringWithRange: range];
} }
self.domain = [string substringWithRange: self.domain = [string substringWithRange:
of_range(nodesep + 1, resourcesep - nodesep - 1)]; OFRangeMake(nodesep + 1, resourcesep - nodesep - 1)];
} @catch (id e) { } @catch (id e) {
[self release]; [self release];
@throw e; @throw e;
@ -235,17 +235,17 @@
return false; return false;
} }
- (uint32_t)hash - (unsigned long)hash
{ {
uint32_t hash; unsigned long hash;
OF_HASH_INIT(hash); OFHashInit(&hash);
OF_HASH_ADD_HASH(hash, _node.hash); OFHashAddHash(&hash, _node.hash);
OF_HASH_ADD_HASH(hash, _domain.hash); OFHashAddHash(&hash, _domain.hash);
OF_HASH_ADD_HASH(hash, _resource.hash); OFHashAddHash(&hash, _resource.hash);
OF_HASH_FINALIZE(hash); OFHashFinalize(&hash);
return hash; return hash;
} }

View file

@ -1,5 +1,6 @@
/* /*
* Copyright (c) 2011, 2012, 2013, 2016, 2019, Jonathan Schleifer <js@heap.zone> * Copyright (c) 2011, 2012, 2013, 2016, 2019, 2021,
* Jonathan Schleifer <js@nil.im>
* Copyright (c) 2011, 2012, 2013, Florian Zeitz <florob@babelmonkeys.de> * Copyright (c) 2011, 2012, 2013, Florian Zeitz <florob@babelmonkeys.de>
* *
* https://heap.zone/objxmpp/ * https://heap.zone/objxmpp/
@ -43,7 +44,7 @@ showToInt(OFString *show)
if ([show isEqual: @"xa"]) if ([show isEqual: @"xa"])
return 4; return 4;
OF_ENSURE(0); OFEnsure(0);
} }
@implementation XMPPPresence @implementation XMPPPresence
@ -114,8 +115,8 @@ showToInt(OFString *show)
if ((subElement = [element elementForName: @"priority" if ((subElement = [element elementForName: @"priority"
namespace: XMPP_NS_CLIENT])) namespace: XMPP_NS_CLIENT]))
self.priority = [OFNumber self.priority = [OFNumber numberWithLongLong:
numberWithIntMax: subElement.decimalValue]; [subElement longLongValueWithBase: 10]];
} @catch (id e) { } @catch (id e) {
[self release]; [self release];
@throw e; @throw e;
@ -173,7 +174,7 @@ showToInt(OFString *show)
- (void)setPriority: (OFNumber *)priority - (void)setPriority: (OFNumber *)priority
{ {
intmax_t prio = priority.intMaxValue; long long prio = priority.longLongValue;
OFNumber *old; OFNumber *old;
if ((prio < -128) || (prio > 127)) if ((prio < -128) || (prio > 127))
@ -186,7 +187,7 @@ showToInt(OFString *show)
[self removeChild: oldPriority]; [self removeChild: oldPriority];
OFString *priority_s = OFString *priority_s =
[OFString stringWithFormat: @"%" @PRId8, priority.int8Value]; [OFString stringWithFormat: @"%hhd", priority.charValue];
[self addChild: [OFXMLElement elementWithName: @"priority" [self addChild: [OFXMLElement elementWithName: @"priority"
namespace: XMPP_NS_CLIENT namespace: XMPP_NS_CLIENT
stringValue: priority_s]]; stringValue: priority_s]];
@ -196,15 +197,15 @@ showToInt(OFString *show)
[old release]; [old release];
} }
- (of_comparison_result_t)compare: (id <OFComparing>)object - (OFComparisonResult)compare: (id <OFComparing>)object
{ {
XMPPPresence *otherPresence; XMPPPresence *otherPresence;
OFNumber *otherPriority; OFNumber *otherPriority;
OFString *otherShow; OFString *otherShow;
of_comparison_result_t priorityOrder; OFComparisonResult priorityOrder;
if (object == self) if (object == self)
return OF_ORDERED_SAME; return OFOrderedSame;
if (![(id)object isKindOfClass: [XMPPPresence class]]) if (![(id)object isKindOfClass: [XMPPPresence class]])
@throw [OFInvalidArgumentException exception]; @throw [OFInvalidArgumentException exception];
@ -212,24 +213,24 @@ showToInt(OFString *show)
otherPresence = (XMPPPresence *)object; otherPresence = (XMPPPresence *)object;
otherPriority = otherPresence.priority; otherPriority = otherPresence.priority;
if (otherPriority == nil) if (otherPriority == nil)
otherPriority = [OFNumber numberWithInt8: 0]; otherPriority = [OFNumber numberWithChar: 0];
if (_priority != nil) if (_priority != nil)
priorityOrder = [_priority compare: otherPriority]; priorityOrder = [_priority compare: otherPriority];
else else
priorityOrder = priorityOrder =
[[OFNumber numberWithInt8: 0] compare: otherPriority]; [[OFNumber numberWithChar: 0] compare: otherPriority];
if (priorityOrder != OF_ORDERED_SAME) if (priorityOrder != OFOrderedSame)
return priorityOrder; return priorityOrder;
otherShow = otherPresence.show; otherShow = otherPresence.show;
if ([_show isEqual: otherShow]) if ([_show isEqual: otherShow])
return OF_ORDERED_SAME; return OFOrderedSame;
if (showToInt(_show) < showToInt(otherShow)) if (showToInt(_show) < showToInt(otherShow))
return OF_ORDERED_ASCENDING; return OFOrderedAscending;
return OF_ORDERED_DESCENDING; return OFOrderedDescending;
} }
@end @end

View file

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2011, Florian Zeitz <florob@babelmonkeys.de> * Copyright (c) 2011, Florian Zeitz <florob@babelmonkeys.de>
* Copyright (c) 2011, 2019, Jonathan Schleifer <js@webkeks.org> * Copyright (c) 2011, 2019, 2021, Jonathan Schleifer <js@nil.im>
* *
* https://heap.zone/objxmpp/ * https://heap.zone/objxmpp/
* *
@ -226,8 +226,8 @@
{ {
size_t i; size_t i;
const uint8_t *clientKey, *serverKey, *clientSignature; const uint8_t *clientKey, *serverKey, *clientSignature;
intmax_t iterCount = 0; long long iterCount = 0;
id <OFCryptoHash> hash; id <OFCryptographicHash> hash;
OFMutableData *ret, *authMessage, *tmpArray; OFMutableData *ret, *authMessage, *tmpArray;
OFData *salt = nil, *saltedPassword; OFData *salt = nil, *saltedPassword;
OFString *tmpString, *sNonce = nil; OFString *tmpString, *sNonce = nil;
@ -248,7 +248,7 @@
for (OFString *component in for (OFString *component in
[challenge componentsSeparatedByString: @","]) { [challenge componentsSeparatedByString: @","]) {
OFString *entry = [component substringWithRange: OFString *entry = [component substringWithRange:
of_range(2, component.length - 2)]; OFRangeMake(2, component.length - 2)];
if ([component hasPrefix: @"r="]) { if ([component hasPrefix: @"r="]) {
if (![entry hasPrefix: _cNonce]) if (![entry hasPrefix: _cNonce])
@ -263,7 +263,7 @@
salt = [OFData dataWithBase64EncodedString: entry]; salt = [OFData dataWithBase64EncodedString: entry];
got |= GOT_SALT; got |= GOT_SALT;
} else if ([component hasPrefix: @"i="]) { } else if ([component hasPrefix: @"i="]) {
iterCount = entry.decimalValue; iterCount = [entry longLongValueWithBase: 10];
got |= GOT_ITERCOUNT; got |= GOT_ITERCOUNT;
} }
} }
@ -397,7 +397,7 @@
mess = [OFString stringWithUTF8String: data.items mess = [OFString stringWithUTF8String: data.items
length: data.count * data.itemSize]; length: data.count * data.itemSize];
value = [mess substringWithRange: of_range(2, mess.length - 2)]; value = [mess substringWithRange: OFRangeMake(2, mess.length - 2)];
if ([mess hasPrefix: @"v="]) { if ([mess hasPrefix: @"v="]) {
if (![value isEqual: _serverSignature.stringByBase64Encoding]) if (![value isEqual: _serverSignature.stringByBase64Encoding])
@ -430,7 +430,7 @@
} }
return [OFString stringWithCString: (char *)buf return [OFString stringWithCString: (char *)buf
encoding: OF_STRING_ENCODING_ASCII encoding: OFStringEncodingASCII
length: 64]; length: 64];
} }
@ -441,7 +441,7 @@
OFMutableData *k = [OFMutableData data]; OFMutableData *k = [OFMutableData data];
size_t i, kSize, blockSize = [_hashType blockSize]; size_t i, kSize, blockSize = [_hashType blockSize];
uint8_t *kI = NULL, *kO = NULL; uint8_t *kI = NULL, *kO = NULL;
id <OFCryptoHash> hashI, hashO; id <OFCryptographicHash> hashI, hashO;
if (key.itemSize * key.count > blockSize) { if (key.itemSize * key.count > blockSize) {
hashI = [[[_hashType alloc] init] autorelease]; hashI = [[[_hashType alloc] init] autorelease];
@ -454,8 +454,8 @@
count: key.itemSize * key.count]; count: key.itemSize * key.count];
@try { @try {
kI = [self allocMemoryWithSize: blockSize]; kI = OFAllocMemory(1, blockSize);
kO = [self allocMemoryWithSize: blockSize]; kO = OFAllocMemory(1, blockSize);
kSize = k.count; kSize = k.count;
memcpy(kI, k.items, kSize); memcpy(kI, k.items, kSize);
@ -468,19 +468,16 @@
} }
hashI = [[[_hashType alloc] init] autorelease]; hashI = [[[_hashType alloc] init] autorelease];
[hashI updateWithBuffer: kI [hashI updateWithBuffer: kI length: blockSize];
length: blockSize];
[hashI updateWithBuffer: data.items [hashI updateWithBuffer: data.items
length: data.itemSize * data.count]; length: data.itemSize * data.count];
hashO = [[[_hashType alloc] init] autorelease]; hashO = [[[_hashType alloc] init] autorelease];
[hashO updateWithBuffer: kO [hashO updateWithBuffer: kO length: blockSize];
length: blockSize]; [hashO updateWithBuffer: hashI.digest length: hashI.digestSize];
[hashO updateWithBuffer: hashI.digest
length: hashI.digestSize];
} @finally { } @finally {
[self freeMemory: kI]; OFFreeMemory(kI);
[self freeMemory: kO]; OFFreeMemory(kO);
} }
[hashO retain]; [hashO retain];
@ -502,7 +499,7 @@
OFMutableData *salty, *tmp; OFMutableData *salty, *tmp;
OFData *ret; OFData *ret;
result = [self allocMemoryWithSize: digestSize]; result = OFAllocMemory(1, digestSize);
@try { @try {
memset(result, 0, digestSize); memset(result, 0, digestSize);
@ -539,7 +536,7 @@
ret = [OFData dataWithItems: result ret = [OFData dataWithItems: result
count: digestSize]; count: digestSize];
} @finally { } @finally {
[self freeMemory: result]; OFFreeMemory(result);
} }
[ret retain]; [ret retain];

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Jonathan Schleifer <js@webkeks.org> * Copyright (c) 2012, 2021, Jonathan Schleifer <js@nil.im>
* *
* https://heap.zone/objxmpp/ * https://heap.zone/objxmpp/
* *
@ -36,9 +36,9 @@ OF_ASSUME_NONNULL_BEGIN
- (void)setBooleanValue: (bool)boolean - (void)setBooleanValue: (bool)boolean
forPath: (OFString *)path; forPath: (OFString *)path;
- (bool)booleanValueForPath: (OFString *)path; - (bool)booleanValueForPath: (OFString *)path;
- (void)setIntegerValue: (intmax_t)integer - (void)setIntegerValue: (long long)integer
forPath: (OFString *)path; forPath: (OFString *)path;
- (intmax_t)integerValueForPath: (OFString *)path; - (long long)integerValueForPath: (OFString *)path;
- (void)setArray: (nullable OFArray *)array - (void)setArray: (nullable OFArray *)array
forPath: (OFString *)path; forPath: (OFString *)path;
- (nullable OFArray *)arrayForPath: (OFString *)path; - (nullable OFArray *)arrayForPath: (OFString *)path;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2010, 2011, 2019, Jonathan Schleifer <js@webkeks.org> * Copyright (c) 2010, 2011, 2019, 2021, Jonathan Schleifer <js@nil.im>
* Copyright (c) 2011, 2012, Florian Zeitz <florob@babelmonkeys.de> * Copyright (c) 2011, 2012, Florian Zeitz <florob@babelmonkeys.de>
* *
* https://heap.zone/objxmpp/ * https://heap.zone/objxmpp/
@ -55,7 +55,7 @@ OF_APPLICATION_DELEGATE(AppDelegate)
XMPPPresence *pres = [XMPPPresence presence]; XMPPPresence *pres = [XMPPPresence presence];
pres.show = @"xa"; pres.show = @"xa";
pres.status = @"Bored"; pres.status = @"Bored";
pres.priority = [OFNumber numberWithInt8: 20]; pres.priority = [OFNumber numberWithChar: 20];
pres.to = [XMPPJID JIDWithString: @"alice@example.com"]; pres.to = [XMPPJID JIDWithString: @"alice@example.com"];
pres.from = [XMPPJID JIDWithString: @"bob@example.org"]; pres.from = [XMPPJID JIDWithString: @"bob@example.org"];
assert([pres.XMLString isEqual: @"<presence to='alice@example.com' " assert([pres.XMLString isEqual: @"<presence to='alice@example.com' "
@ -66,11 +66,11 @@ OF_APPLICATION_DELEGATE(AppDelegate)
XMPPPresence *pres2 = [XMPPPresence presence]; XMPPPresence *pres2 = [XMPPPresence presence];
pres2.show = @"away"; pres2.show = @"away";
pres2.status = @"Bored"; pres2.status = @"Bored";
pres2.priority = [OFNumber numberWithInt8: 23]; pres2.priority = [OFNumber numberWithChar: 23];
pres2.to = [XMPPJID JIDWithString: @"alice@example.com"]; pres2.to = [XMPPJID JIDWithString: @"alice@example.com"];
pres2.from = [XMPPJID JIDWithString: @"bob@example.org"]; pres2.from = [XMPPJID JIDWithString: @"bob@example.org"];
assert([pres compare: pres2] == OF_ORDERED_ASCENDING); assert([pres compare: pres2] == OFOrderedAscending);
XMPPMessage *msg = [XMPPMessage messageWithType: @"chat"]; XMPPMessage *msg = [XMPPMessage messageWithType: @"chat"];
msg.body = @"Hello everyone"; msg.body = @"Hello everyone";
@ -118,7 +118,7 @@ OF_APPLICATION_DELEGATE(AppDelegate)
[[XMPPStreamManagement alloc] initWithConnection: conn]; [[XMPPStreamManagement alloc] initWithConnection: conn];
if (arguments.count != 3) { if (arguments.count != 3) {
of_log(@"Invalid count of command line arguments!"); OFLog(@"Invalid count of command line arguments!");
[OFApplication terminateWithStatus: 1]; [OFApplication terminateWithStatus: 1];
} }
@ -133,25 +133,25 @@ OF_APPLICATION_DELEGATE(AppDelegate)
- (void)connection: (XMPPConnection *)conn - (void)connection: (XMPPConnection *)conn
didReceiveElement: (OFXMLElement *)element didReceiveElement: (OFXMLElement *)element
{ {
of_log(@"In: %@", element); OFLog(@"In: %@", element);
} }
- (void)connection: (XMPPConnection *)conn - (void)connection: (XMPPConnection *)conn
didSendElement: (OFXMLElement *)element didSendElement: (OFXMLElement *)element
{ {
of_log(@"Out: %@", element); OFLog(@"Out: %@", element);
} }
- (void)connectionWasAuthenticated: (XMPPConnection *)conn - (void)connectionWasAuthenticated: (XMPPConnection *)conn
{ {
of_log(@"Auth successful"); OFLog(@"Auth successful");
} }
- (void)connection: (XMPPConnection *)conn_ - (void)connection: (XMPPConnection *)conn_
wasBoundToJID: (XMPPJID *)JID wasBoundToJID: (XMPPJID *)JID
{ {
of_log(@"Bound to JID: %@", JID.fullJID); OFLog(@"Bound to JID: %@", JID.fullJID);
of_log(@"Supports SM: %@", OFLog(@"Supports SM: %@",
conn_.supportsStreamManagement ? @"true" : @"false"); conn_.supportsStreamManagement ? @"true" : @"false");
XMPPDiscoEntity *discoEntity = XMPPDiscoEntity *discoEntity =
@ -203,10 +203,10 @@ OF_APPLICATION_DELEGATE(AppDelegate)
{ {
XMPPPresence *pres; XMPPPresence *pres;
of_log(@"Got roster: %@", roster_.rosterItems); OFLog(@"Got roster: %@", roster_.rosterItems);
pres = [XMPPPresence presence]; pres = [XMPPPresence presence];
pres.priority = [OFNumber numberWithInt8: 10]; pres.priority = [OFNumber numberWithChar: 10];
pres.status = @"ObjXMPP test is working!"; pres.status = @"ObjXMPP test is working!";
[conn sendStanza: pres]; [conn sendStanza: pres];
@ -218,7 +218,7 @@ OF_APPLICATION_DELEGATE(AppDelegate)
namespace: @"urn:xmpp:ping"]]; namespace: @"urn:xmpp:ping"]];
[conn sendIQ: IQ [conn sendIQ: IQ
callbackBlock: ^ (XMPPConnection *c, XMPPIQ *resp) { callbackBlock: ^ (XMPPConnection *c, XMPPIQ *resp) {
of_log(@"Ping response: %@", resp); OFLog(@"Ping response: %@", resp);
}]; }];
#endif #endif
} }
@ -228,11 +228,11 @@ OF_APPLICATION_DELEGATE(AppDelegate)
OFString *reason; OFString *reason;
if (![conn_ checkCertificateAndGetReason: &reason]) { if (![conn_ checkCertificateAndGetReason: &reason]) {
[of_stdout writeString: @"Couldn't verify certificate: "]; [OFStdOut writeString: @"Couldn't verify certificate: "];
[of_stdout writeFormat: @"%@\n", reason]; [OFStdOut writeFormat: @"%@\n", reason];
[of_stdout writeString: @"Do you want to continue [y/N]? "]; [OFStdOut writeString: @"Do you want to continue [y/N]? "];
if (![[of_stdin readLine] hasPrefix: @"y"]) if (![[OFStdIn readLine] hasPrefix: @"y"])
[OFApplication terminateWithStatus: 1]; [OFApplication terminateWithStatus: 1];
} }
} }
@ -240,13 +240,13 @@ OF_APPLICATION_DELEGATE(AppDelegate)
- (void)roster: (XMPPRoster *)roster_ - (void)roster: (XMPPRoster *)roster_
didReceiveRosterItem: (XMPPRosterItem *)rosterItem didReceiveRosterItem: (XMPPRosterItem *)rosterItem
{ {
of_log(@"Got roster push: %@", rosterItem); OFLog(@"Got roster push: %@", rosterItem);
} }
- (bool)connection: (XMPPConnection *)conn - (bool)connection: (XMPPConnection *)conn
didReceiveIQ: (XMPPIQ *)iq didReceiveIQ: (XMPPIQ *)iq
{ {
of_log(@"IQ: %@", iq); OFLog(@"IQ: %@", iq);
return NO; return NO;
} }
@ -254,13 +254,13 @@ OF_APPLICATION_DELEGATE(AppDelegate)
- (void)connection: (XMPPConnection *)conn - (void)connection: (XMPPConnection *)conn
didReceiveMessage: (XMPPMessage *)msg didReceiveMessage: (XMPPMessage *)msg
{ {
of_log(@"Message: %@", msg); OFLog(@"Message: %@", msg);
} }
- (void)connection: (XMPPConnection *)conn - (void)connection: (XMPPConnection *)conn
didReceivePresence: (XMPPPresence *)pres didReceivePresence: (XMPPPresence *)pres
{ {
of_log(@"Presence: %@", pres); OFLog(@"Presence: %@", pres);
} }
- (void)connection: (XMPPConnection *)conn - (void)connection: (XMPPConnection *)conn
@ -272,6 +272,6 @@ OF_APPLICATION_DELEGATE(AppDelegate)
- (void)connectionWasClosed: (XMPPConnection *)conn - (void)connectionWasClosed: (XMPPConnection *)conn
error: (OFXMLElement *)error error: (OFXMLElement *)error
{ {
of_log(@"Connection was closed: %@", error); OFLog(@"Connection was closed: %@", error);
} }
@end @end