]> cgit.babelmonkeys.de Git - jubjub.git/blobdiff - src/core/JubChatClient.m
Adapt to use XMPPContactManager
[jubjub.git] / src / core / JubChatClient.m
index a31bdb598efcaee9b881955bd58cb3b5d6961a93..b4a1481fb4b76683e7aa039d106abadec4f83fb6 100644 (file)
@@ -3,6 +3,8 @@
 @implementation JubChatClient
 @synthesize connection;
 @synthesize roster;
+@synthesize contactManager;
+@synthesize presence;
 @synthesize ui;
 
 - initWithConfig: (JubConfig*)config
                roster = [[XMPPRoster alloc] initWithConnection: connection];
                [roster addDelegate: self];
 
+               contactManager = [[XMPPContactManager alloc]
+                                     initWithConnection: connection
+                                                 roster: roster];
+
                streamManagement = [[XMPPStreamManagement alloc]
                    initWithConnection: connection];
 
 - (void)dealloc
 {
        [roster release];
+       [contactManager release];
        [streamManagement release];
        [connection release];
+       [presence release];
 
        [super dealloc];
 }
 
-- (void)connection: (XMPPConnection*)conn_
+- (void)connection: (XMPPConnection*)connection_
      wasBoundToJID: (XMPPJID*)jid
 {
        of_log(@"Bound to JID: %@", [jid fullJID]);
        [roster requestRoster];
 }
 
+-   (void)connection: (XMPPConnection*)connection_
+  didReceivePresence: (XMPPPresence*)presence_
+{
+       if ([presence_.from isEqual: connection.JID]) {
+               [ui          client: self
+                 didChangePresence: presence_];
+               OF_SETTER(presence, presence_, YES, 0);
+       }
+}
+
 - (void)rosterWasReceived: (XMPPRoster*)roster
 {
-       [connection sendStanza: [XMPPPresence presence]];
+       XMPPPresence *pres = [XMPPPresence presence];
+       [pres setStatus: @"Hello from JubJub"];
+       [connection sendStanza: pres];
 }
 @end