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

View file

@ -1,6 +1,6 @@
/*
* 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/
*
@ -161,7 +161,6 @@
/* Subscription request */
if ([type isEqual: @"subscribe"]) {
of_log(@"ObjXMPP: received subscription request");
[_delegates broadcastSelector: @selector(contactManager:
didReceiveSubscriptionRequest:)
withObject: self

View file

@ -1,6 +1,6 @@
/*
* 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/
*
@ -114,8 +114,7 @@
- (OFString *)capsHash
{
OFMutableString *caps = [OFMutableString string];
OFSHA1Hash *hash = [OFSHA1Hash
cryptoHashWithAllowsSwappableMemory: true];
OFSHA1Hash *hash = [OFSHA1Hash hashWithAllowsSwappableMemory: true];
OFData *digest;
for (XMPPDiscoIdentity *identity in _identities)

View file

@ -1,6 +1,6 @@
/*
* 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/
*
@ -105,29 +105,28 @@
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);
OF_HASH_ADD_HASH(hash, _type.hash);
OF_HASH_ADD_HASH(hash, _name.hash);
OFHashAddHash(&hash, _category.hash);
OFHashAddHash(&hash, _type.hash);
OFHashAddHash(&hash, _name.hash);
OF_HASH_FINALIZE(hash);
OFHashFinalize(&hash);
return hash;
}
- (of_comparison_result_t)compare: (id <OFComparing>)object
- (OFComparisonResult)compare: (id <OFComparing>)object
{
XMPPDiscoIdentity *identity;
of_comparison_result_t categoryResult;
of_comparison_result_t typeResult;
OFComparisonResult categoryResult, typeResult;
if (object == self)
return OF_ORDERED_SAME;
return OFOrderedSame;
if (![(id)object isKindOfClass: [XMPPDiscoIdentity class]])
@throw [OFInvalidArgumentException exception];
@ -135,11 +134,11 @@
identity = (XMPPDiscoIdentity *)object;
categoryResult = [_category compare: identity->_category];
if (categoryResult != OF_ORDERED_SAME)
if (categoryResult != OFOrderedSame)
return categoryResult;
typeResult = [_type compare: identity->_type];
if (typeResult != OF_ORDERED_SAME)
if (typeResult != OFOrderedSame)
return typeResult;
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/
*
@ -50,7 +50,7 @@
_file = [file copy];
@try {
_data = [[OFData dataWithContentsOfFile: file]
.messagePackValue copy];
.objectByParsingMessagePack copy];
} @catch (id e) {
_data = [[OFMutableDictionary alloc] init];
}
@ -162,23 +162,23 @@
return boolean;
}
- (void)setIntegerValue: (intmax_t)integer
- (void)setIntegerValue: (long long)integer
forPath: (OFString *)path
{
void *pool = objc_autoreleasePoolPush();
[self xmpp_setObject: [OFNumber numberWithIntMax: integer]
[self xmpp_setObject: [OFNumber numberWithLongLong: integer]
forPath: path];
objc_autoreleasePoolPop(pool);
}
- (intmax_t)integerValueForPath: (OFString *)path
- (long long)integerValueForPath: (OFString *)path
{
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);

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>
*
* https://heap.zone/objxmpp/
@ -59,20 +59,20 @@
if (nodesep == SIZE_MAX)
self.node = nil;
else
self.node =
[string substringWithRange: of_range(0, nodesep)];
self.node = [string substringWithRange:
OFRangeMake(0, nodesep)];
if (resourcesep == SIZE_MAX) {
self.resource = nil;
resourcesep = string.length;
} else {
of_range_t range = of_range(resourcesep + 1,
OFRange range = OFRangeMake(resourcesep + 1,
string.length - resourcesep - 1);
self.resource = [string substringWithRange: range];
}
self.domain = [string substringWithRange:
of_range(nodesep + 1, resourcesep - nodesep - 1)];
OFRangeMake(nodesep + 1, resourcesep - nodesep - 1)];
} @catch (id e) {
[self release];
@throw e;
@ -235,17 +235,17 @@
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);
OF_HASH_ADD_HASH(hash, _domain.hash);
OF_HASH_ADD_HASH(hash, _resource.hash);
OFHashAddHash(&hash, _node.hash);
OFHashAddHash(&hash, _domain.hash);
OFHashAddHash(&hash, _resource.hash);
OF_HASH_FINALIZE(hash);
OFHashFinalize(&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>
*
* https://heap.zone/objxmpp/
@ -43,7 +44,7 @@ showToInt(OFString *show)
if ([show isEqual: @"xa"])
return 4;
OF_ENSURE(0);
OFEnsure(0);
}
@implementation XMPPPresence
@ -114,8 +115,8 @@ showToInt(OFString *show)
if ((subElement = [element elementForName: @"priority"
namespace: XMPP_NS_CLIENT]))
self.priority = [OFNumber
numberWithIntMax: subElement.decimalValue];
self.priority = [OFNumber numberWithLongLong:
[subElement longLongValueWithBase: 10]];
} @catch (id e) {
[self release];
@throw e;
@ -173,7 +174,7 @@ showToInt(OFString *show)
- (void)setPriority: (OFNumber *)priority
{
intmax_t prio = priority.intMaxValue;
long long prio = priority.longLongValue;
OFNumber *old;
if ((prio < -128) || (prio > 127))
@ -186,7 +187,7 @@ showToInt(OFString *show)
[self removeChild: oldPriority];
OFString *priority_s =
[OFString stringWithFormat: @"%" @PRId8, priority.int8Value];
[OFString stringWithFormat: @"%hhd", priority.charValue];
[self addChild: [OFXMLElement elementWithName: @"priority"
namespace: XMPP_NS_CLIENT
stringValue: priority_s]];
@ -196,15 +197,15 @@ showToInt(OFString *show)
[old release];
}
- (of_comparison_result_t)compare: (id <OFComparing>)object
- (OFComparisonResult)compare: (id <OFComparing>)object
{
XMPPPresence *otherPresence;
OFNumber *otherPriority;
OFString *otherShow;
of_comparison_result_t priorityOrder;
OFComparisonResult priorityOrder;
if (object == self)
return OF_ORDERED_SAME;
return OFOrderedSame;
if (![(id)object isKindOfClass: [XMPPPresence class]])
@throw [OFInvalidArgumentException exception];
@ -212,24 +213,24 @@ showToInt(OFString *show)
otherPresence = (XMPPPresence *)object;
otherPriority = otherPresence.priority;
if (otherPriority == nil)
otherPriority = [OFNumber numberWithInt8: 0];
otherPriority = [OFNumber numberWithChar: 0];
if (_priority != nil)
priorityOrder = [_priority compare: otherPriority];
else
priorityOrder =
[[OFNumber numberWithInt8: 0] compare: otherPriority];
[[OFNumber numberWithChar: 0] compare: otherPriority];
if (priorityOrder != OF_ORDERED_SAME)
if (priorityOrder != OFOrderedSame)
return priorityOrder;
otherShow = otherPresence.show;
if ([_show isEqual: otherShow])
return OF_ORDERED_SAME;
return OFOrderedSame;
if (showToInt(_show) < showToInt(otherShow))
return OF_ORDERED_ASCENDING;
return OFOrderedAscending;
return OF_ORDERED_DESCENDING;
return OFOrderedDescending;
}
@end

View file

@ -1,6 +1,6 @@
/*
* 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/
*
@ -226,8 +226,8 @@
{
size_t i;
const uint8_t *clientKey, *serverKey, *clientSignature;
intmax_t iterCount = 0;
id <OFCryptoHash> hash;
long long iterCount = 0;
id <OFCryptographicHash> hash;
OFMutableData *ret, *authMessage, *tmpArray;
OFData *salt = nil, *saltedPassword;
OFString *tmpString, *sNonce = nil;
@ -248,7 +248,7 @@
for (OFString *component in
[challenge componentsSeparatedByString: @","]) {
OFString *entry = [component substringWithRange:
of_range(2, component.length - 2)];
OFRangeMake(2, component.length - 2)];
if ([component hasPrefix: @"r="]) {
if (![entry hasPrefix: _cNonce])
@ -263,7 +263,7 @@
salt = [OFData dataWithBase64EncodedString: entry];
got |= GOT_SALT;
} else if ([component hasPrefix: @"i="]) {
iterCount = entry.decimalValue;
iterCount = [entry longLongValueWithBase: 10];
got |= GOT_ITERCOUNT;
}
}
@ -397,7 +397,7 @@
mess = [OFString stringWithUTF8String: data.items
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 (![value isEqual: _serverSignature.stringByBase64Encoding])
@ -430,7 +430,7 @@
}
return [OFString stringWithCString: (char *)buf
encoding: OF_STRING_ENCODING_ASCII
encoding: OFStringEncodingASCII
length: 64];
}
@ -441,7 +441,7 @@
OFMutableData *k = [OFMutableData data];
size_t i, kSize, blockSize = [_hashType blockSize];
uint8_t *kI = NULL, *kO = NULL;
id <OFCryptoHash> hashI, hashO;
id <OFCryptographicHash> hashI, hashO;
if (key.itemSize * key.count > blockSize) {
hashI = [[[_hashType alloc] init] autorelease];
@ -454,8 +454,8 @@
count: key.itemSize * key.count];
@try {
kI = [self allocMemoryWithSize: blockSize];
kO = [self allocMemoryWithSize: blockSize];
kI = OFAllocMemory(1, blockSize);
kO = OFAllocMemory(1, blockSize);
kSize = k.count;
memcpy(kI, k.items, kSize);
@ -468,19 +468,16 @@
}
hashI = [[[_hashType alloc] init] autorelease];
[hashI updateWithBuffer: kI
length: blockSize];
[hashI updateWithBuffer: kI length: blockSize];
[hashI updateWithBuffer: data.items
length: data.itemSize * data.count];
hashO = [[[_hashType alloc] init] autorelease];
[hashO updateWithBuffer: kO
length: blockSize];
[hashO updateWithBuffer: hashI.digest
length: hashI.digestSize];
[hashO updateWithBuffer: kO length: blockSize];
[hashO updateWithBuffer: hashI.digest length: hashI.digestSize];
} @finally {
[self freeMemory: kI];
[self freeMemory: kO];
OFFreeMemory(kI);
OFFreeMemory(kO);
}
[hashO retain];
@ -502,7 +499,7 @@
OFMutableData *salty, *tmp;
OFData *ret;
result = [self allocMemoryWithSize: digestSize];
result = OFAllocMemory(1, digestSize);
@try {
memset(result, 0, digestSize);
@ -539,7 +536,7 @@
ret = [OFData dataWithItems: result
count: digestSize];
} @finally {
[self freeMemory: result];
OFFreeMemory(result);
}
[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/
*
@ -36,9 +36,9 @@ OF_ASSUME_NONNULL_BEGIN
- (void)setBooleanValue: (bool)boolean
forPath: (OFString *)path;
- (bool)booleanValueForPath: (OFString *)path;
- (void)setIntegerValue: (intmax_t)integer
- (void)setIntegerValue: (long long)integer
forPath: (OFString *)path;
- (intmax_t)integerValueForPath: (OFString *)path;
- (long long)integerValueForPath: (OFString *)path;
- (void)setArray: (nullable OFArray *)array
forPath: (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>
*
* https://heap.zone/objxmpp/
@ -55,7 +55,7 @@ OF_APPLICATION_DELEGATE(AppDelegate)
XMPPPresence *pres = [XMPPPresence presence];
pres.show = @"xa";
pres.status = @"Bored";
pres.priority = [OFNumber numberWithInt8: 20];
pres.priority = [OFNumber numberWithChar: 20];
pres.to = [XMPPJID JIDWithString: @"alice@example.com"];
pres.from = [XMPPJID JIDWithString: @"bob@example.org"];
assert([pres.XMLString isEqual: @"<presence to='alice@example.com' "
@ -66,11 +66,11 @@ OF_APPLICATION_DELEGATE(AppDelegate)
XMPPPresence *pres2 = [XMPPPresence presence];
pres2.show = @"away";
pres2.status = @"Bored";
pres2.priority = [OFNumber numberWithInt8: 23];
pres2.priority = [OFNumber numberWithChar: 23];
pres2.to = [XMPPJID JIDWithString: @"alice@example.com"];
pres2.from = [XMPPJID JIDWithString: @"bob@example.org"];
assert([pres compare: pres2] == OF_ORDERED_ASCENDING);
assert([pres compare: pres2] == OFOrderedAscending);
XMPPMessage *msg = [XMPPMessage messageWithType: @"chat"];
msg.body = @"Hello everyone";
@ -118,7 +118,7 @@ OF_APPLICATION_DELEGATE(AppDelegate)
[[XMPPStreamManagement alloc] initWithConnection: conn];
if (arguments.count != 3) {
of_log(@"Invalid count of command line arguments!");
OFLog(@"Invalid count of command line arguments!");
[OFApplication terminateWithStatus: 1];
}
@ -133,25 +133,25 @@ OF_APPLICATION_DELEGATE(AppDelegate)
- (void)connection: (XMPPConnection *)conn
didReceiveElement: (OFXMLElement *)element
{
of_log(@"In: %@", element);
OFLog(@"In: %@", element);
}
- (void)connection: (XMPPConnection *)conn
didSendElement: (OFXMLElement *)element
{
of_log(@"Out: %@", element);
OFLog(@"Out: %@", element);
}
- (void)connectionWasAuthenticated: (XMPPConnection *)conn
{
of_log(@"Auth successful");
OFLog(@"Auth successful");
}
- (void)connection: (XMPPConnection *)conn_
wasBoundToJID: (XMPPJID *)JID
{
of_log(@"Bound to JID: %@", JID.fullJID);
of_log(@"Supports SM: %@",
OFLog(@"Bound to JID: %@", JID.fullJID);
OFLog(@"Supports SM: %@",
conn_.supportsStreamManagement ? @"true" : @"false");
XMPPDiscoEntity *discoEntity =
@ -203,10 +203,10 @@ OF_APPLICATION_DELEGATE(AppDelegate)
{
XMPPPresence *pres;
of_log(@"Got roster: %@", roster_.rosterItems);
OFLog(@"Got roster: %@", roster_.rosterItems);
pres = [XMPPPresence presence];
pres.priority = [OFNumber numberWithInt8: 10];
pres.priority = [OFNumber numberWithChar: 10];
pres.status = @"ObjXMPP test is working!";
[conn sendStanza: pres];
@ -218,7 +218,7 @@ OF_APPLICATION_DELEGATE(AppDelegate)
namespace: @"urn:xmpp:ping"]];
[conn sendIQ: IQ
callbackBlock: ^ (XMPPConnection *c, XMPPIQ *resp) {
of_log(@"Ping response: %@", resp);
OFLog(@"Ping response: %@", resp);
}];
#endif
}
@ -228,11 +228,11 @@ OF_APPLICATION_DELEGATE(AppDelegate)
OFString *reason;
if (![conn_ checkCertificateAndGetReason: &reason]) {
[of_stdout writeString: @"Couldn't verify certificate: "];
[of_stdout writeFormat: @"%@\n", reason];
[of_stdout writeString: @"Do you want to continue [y/N]? "];
[OFStdOut writeString: @"Couldn't verify certificate: "];
[OFStdOut writeFormat: @"%@\n", reason];
[OFStdOut writeString: @"Do you want to continue [y/N]? "];
if (![[of_stdin readLine] hasPrefix: @"y"])
if (![[OFStdIn readLine] hasPrefix: @"y"])
[OFApplication terminateWithStatus: 1];
}
}
@ -240,13 +240,13 @@ OF_APPLICATION_DELEGATE(AppDelegate)
- (void)roster: (XMPPRoster *)roster_
didReceiveRosterItem: (XMPPRosterItem *)rosterItem
{
of_log(@"Got roster push: %@", rosterItem);
OFLog(@"Got roster push: %@", rosterItem);
}
- (bool)connection: (XMPPConnection *)conn
didReceiveIQ: (XMPPIQ *)iq
{
of_log(@"IQ: %@", iq);
OFLog(@"IQ: %@", iq);
return NO;
}
@ -254,13 +254,13 @@ OF_APPLICATION_DELEGATE(AppDelegate)
- (void)connection: (XMPPConnection *)conn
didReceiveMessage: (XMPPMessage *)msg
{
of_log(@"Message: %@", msg);
OFLog(@"Message: %@", msg);
}
- (void)connection: (XMPPConnection *)conn
didReceivePresence: (XMPPPresence *)pres
{
of_log(@"Presence: %@", pres);
OFLog(@"Presence: %@", pres);
}
- (void)connection: (XMPPConnection *)conn
@ -272,6 +272,6 @@ OF_APPLICATION_DELEGATE(AppDelegate)
- (void)connectionWasClosed: (XMPPConnection *)conn
error: (OFXMLElement *)error
{
of_log(@"Connection was closed: %@", error);
OFLog(@"Connection was closed: %@", error);
}
@end