#import "JubGtkUI.h"
@interface AppDelegate: OFObject
- <OFApplicationDelegate, XMPPConnectionDelegate>
+ <OFApplicationDelegate, XMPPConnectionDelegate, XMPPRosterDelegate>
{
XMPPConnection *connection;
XMPPRoster *roster;
@implementation AppDelegate
- (void)applicationDidFinishLaunching
{
- ui = [[JubGtkUI alloc] init];
+ id<XMPPRosterDelegate, XMPPConnectionDelegate> rosterDelegate;
connection = [[XMPPConnection alloc] init];
[connection addDelegate: self];
connection.username = @"alice";
connection.password = @"test";
- [connection connect];
- [connection handleConnection];
+ ui = [[JubGtkUI alloc] initWithConnection: connection];
+ rosterDelegate = [ui rosterDelegate];
+
+ [connection addDelegate: rosterDelegate];
roster = [[XMPPRoster alloc] initWithConnection: connection];
- [roster addDelegate: [ui rosterDelegate]];
+ [roster addDelegate: rosterDelegate];
+ [roster addDelegate: self];
+
+ [connection asyncConnectAndHandle];
[ui startUIThread];
}
[roster requestRoster];
}
+- (void)rosterWasReceived: (XMPPRoster*)roster
+{
+ [connection sendStanza: [XMPPPresence presence]];
+}
+
- (void)connection: (XMPPConnection*)conn
didReceiveElement: (OFXMLElement*)element
{