X-Git-Url: http://cgit.babelmonkeys.de/?p=jubjub.git;a=blobdiff_plain;f=src%2Fcore%2FJubChatClient.m;h=1d7874ad563d26c044f5b9d100651c0505deb94f;hp=eea1b8a98fd0af6df0e898a3e951c850cd102d8a;hb=1a38d433f22f577feb4007160d7a591b00518c9f;hpb=8ec9e490edfa8566751bb07e33ae259a69b031d8 diff --git a/src/core/JubChatClient.m b/src/core/JubChatClient.m index eea1b8a..1d7874a 100644 --- a/src/core/JubChatClient.m +++ b/src/core/JubChatClient.m @@ -1,9 +1,13 @@ #import "JubChatClient.h" +#import "ObjXMPP/namespaces.h" + +#define JUB_CLIENT_URI @"http://babelmonkeys.de/jubjub" @implementation JubChatClient @synthesize connection = _connection; @synthesize roster = _roster; @synthesize contactManager = _contactManager; +@synthesize discoEntity = _discoEntity; @synthesize presence = _presence; @synthesize ui = _ui; @@ -47,6 +51,7 @@ [_roster release]; [_contactManager release]; + [_discoEntity release]; [_streamManagement release]; [_connection release]; [_presence release]; @@ -111,6 +116,17 @@ if (text != nil) presence.status = text; + OFXMLElement *caps = [OFXMLElement elementWithName: @"c" + namespace: XMPP_NS_CAPS]; + [caps addAttributeWithName: @"hash" + stringValue: @"sha-1"]; + [caps addAttributeWithName: @"ver" + stringValue: [_discoEntity capsHash]]; + [caps addAttributeWithName: @"node" + stringValue: JUB_CLIENT_URI]; + + [presence addChild: caps]; + [_connection sendStanza: presence]; } @@ -119,6 +135,17 @@ { of_log(@"Bound to JID: %@", [jid fullJID]); + _discoEntity = + [[XMPPDiscoEntity alloc] initWithConnection: connection + capsNode: JUB_CLIENT_URI]; + + XMPPDiscoIdentity *identity = + [XMPPDiscoIdentity identityWithCategory: @"client" + type: @"pc" + name: @"JubJub"]; + [_discoEntity addIdentity: identity]; + [_discoEntity addFeature: XMPP_NS_CAPS]; + [_roster requestRoster]; } @@ -145,8 +172,7 @@ - (void)rosterWasReceived: (XMPPRoster*)roster { - XMPPPresence *pres = [XMPPPresence presence]; - [pres setStatus: @"Hello from JubJub"]; - [_connection sendStanza: pres]; + [self sendPresenceWithStatus: @"available" + text: @"Hello from JubJub"]; } @end