@@ -1,7 +1,7 @@ /* - * Copyright (c) 2010, 2011, 2019, Jonathan Schleifer + * Copyright (c) 2010, 2011, 2019, 2021, Jonathan Schleifer * Copyright (c) 2011, 2012, Florian Zeitz * * https://heap.zone/objxmpp/ * * Permission to use, copy, modify, and/or distribute this software for any @@ -53,11 +53,11 @@ OFArray *arguments = [OFApplication arguments]; 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: @"xa" @"Bored20" @@ -64,15 +64,15 @@ @""]); 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"; msg.to = [XMPPJID JIDWithString: @"jdev@conference.jabber.org"]; msg.from = [XMPPJID JIDWithString: @"alice@example.com"]; @@ -116,11 +116,11 @@ [roster addDelegate: self]; [[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]; } conn.domain = [arguments objectAtIndex: 0]; conn.username = [arguments objectAtIndex: 1]; @@ -131,29 +131,29 @@ } - (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 = [[XMPPDiscoEntity alloc] initWithConnection: conn]; @@ -201,14 +201,14 @@ - (void)rosterWasReceived: (XMPPRoster *)roster_ { 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]; #ifdef OF_HAVE_BLOCKS @@ -216,53 +216,53 @@ ID: [conn generateStanzaID]]; [IQ addChild: [OFXMLElement elementWithName: @"ping" namespace: @"urn:xmpp:ping"]]; [conn sendIQ: IQ callbackBlock: ^ (XMPPConnection *c, XMPPIQ *resp) { - of_log(@"Ping response: %@", resp); + OFLog(@"Ping response: %@", resp); }]; #endif } - (void)connectionDidUpgradeToTLS: (XMPPConnection *)conn_ { 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]; } } - (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; } - (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 didThrowException: (id)e { @@ -270,8 +270,8 @@ } - (void)connectionWasClosed: (XMPPConnection *)conn error: (OFXMLElement *)error { - of_log(@"Connection was closed: %@", error); + OFLog(@"Connection was closed: %@", error); } @end