XMPPRoster *_roster;
XMPPStreamManagement *_streamManagement;
XMPPContactManager *_contactManager;
+ XMPPDiscoEntity *_discoEntity;
XMPPPresence *_presence;
id<JubUI> _ui;
}
@property (readonly) XMPPConnection *connection;
@property (readonly) XMPPRoster *roster;
@property (readonly) XMPPContactManager *contactManager;
+@property (readonly) XMPPDiscoEntity *discoEntity;
@property (readonly) XMPPPresence *presence;
@property (assign) id<JubUI> ui;
#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;
[_roster release];
[_contactManager release];
+ [_discoEntity release];
[_streamManagement release];
[_connection release];
[_presence release];
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];
}
{
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];
}
- (void)rosterWasReceived: (XMPPRoster*)roster
{
- XMPPPresence *pres = [XMPPPresence presence];
- [pres setStatus: @"Hello from JubJub"];
- [_connection sendStanza: pres];
+ [self sendPresenceWithStatus: @"available"
+ text: @"Hello from JubJub"];
}
@end