@@ -1,8 +1,8 @@ /* * Copyright (c) 2013, Florian Zeitz - * Copyright (c) 2013, 2016, Jonathan Schleifer + * Copyright (c) 2013, 2016, 2019, Jonathan Schleifer * * https://heap.zone/objxmpp/ * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -65,19 +65,19 @@ - (void)sendSubscribedToJID: (XMPPJID *)subscriber { XMPPPresence *presence = [XMPPPresence presenceWithType: @"subscribed"]; - [presence setTo: subscriber]; + presence.to = subscriber; [_connection sendStanza: presence]; } - (void)sendUnsubscribedToJID: (XMPPJID *)subscriber { XMPPPresence *presence = [XMPPPresence presenceWithType: @"unsubscribed"]; - [presence setTo: subscriber]; + presence.to = subscriber; [_connection sendStanza: presence]; } - (void)addDelegate: (id )delegate { @@ -101,15 +101,14 @@ [_contacts release]; _contacts = nil; _contacts = [[OFMutableDictionary alloc] init]; - rosterItems = [roster rosterItems]; + rosterItems = roster.rosterItems; for (OFString *bareJID in rosterItems) { XMPPContact *contact = [[[XMPPContact alloc] init] autorelease]; - [contact xmpp_setRosterItem: - [rosterItems objectForKey: bareJID]]; + contact.rosterItem = [rosterItems objectForKey: bareJID]; [_contacts setObject: contact forKey: bareJID]; [_delegates broadcastSelector: @selector(contactManager: didAddContact:) withObject: self @@ -119,15 +118,15 @@ - (void)roster: (XMPPRoster *)roster didReceiveRosterItem: (XMPPRosterItem *)rosterItem { XMPPContact *contact; - OFString *bareJID = [[rosterItem JID] bareJID]; + OFString *bareJID = rosterItem.JID.bareJID; contact = [_contacts objectForKey: bareJID]; - if ([[rosterItem subscription] isEqual: @"remove"]) { + if ([rosterItem.subscription isEqual: @"remove"]) { if (contact != nil) [_delegates broadcastSelector: @selector(contactManager: didRemoveContact:) withObject: self withObject: contact]; @@ -135,11 +134,11 @@ return; } if (contact == nil) { contact = [[[XMPPContact alloc] init] autorelease]; - [contact xmpp_setRosterItem: rosterItem]; + contact.rosterItem = rosterItem; [_contacts setObject: contact forKey: bareJID]; [_delegates broadcastSelector: @selector(contactManager: didAddContact:) withObject: self @@ -147,20 +146,20 @@ } else { [_delegates broadcastSelector: @selector(contact: willUpdateWithRosterItem:) withObject: contact withObject: rosterItem]; - [contact xmpp_setRosterItem: rosterItem]; + contact.rosterItem = rosterItem; } } - (void)connection: (XMPPConnection *)connection didReceivePresence: (XMPPPresence *)presence { XMPPContact *contact; - XMPPJID *JID = [presence from]; - OFString *type = [presence type]; + XMPPJID *JID = presence.from; + OFString *type = presence.type; /* Subscription request */ if ([type isEqual: @"subscribe"]) { of_log(@"ObjXMPP: received subscription request"); [_delegates broadcastSelector: @selector(contactManager: @@ -168,28 +167,28 @@ withObject: self withObject: presence]; return; } - contact = [_contacts objectForKey: [JID bareJID]]; + contact = [_contacts objectForKey: JID.bareJID]; if (contact == nil) return; /* Available presence */ if ([type isEqual: @"available"]) { [contact xmpp_setPresence: presence - resource: [JID resource]]; + resource: JID.resource]; [_delegates broadcastSelector: @selector(contact: didSendPresence:) withObject: contact withObject: presence]; return; } /* Unavailable presence */ if ([type isEqual: @"unavailable"]) { - [contact xmpp_removePresenceForResource: [JID resource]]; + [contact xmpp_removePresenceForResource: JID.resource]; [_delegates broadcastSelector: @selector(contact: didSendPresence:) withObject: contact withObject: presence]; return; @@ -197,18 +196,18 @@ } - (void)connection: (XMPPConnection *)connection didReceiveMessage: (XMPPMessage *)message { - XMPPJID *JID = [message from]; - XMPPContact *contact = [_contacts objectForKey: [JID bareJID]]; + XMPPJID *JID = message.from; + XMPPContact *contact = [_contacts objectForKey: JID.bareJID]; if (contact == nil) return; - [contact xmpp_setLockedOnJID: JID]; + contact.xmpp_lockedOnJID = JID; [_delegates broadcastSelector: @selector(contact:didSendMessage:) withObject: contact withObject: message]; } @end