Skip to content

Commit

Permalink
Update StropheCappuccino and use new TNStropheClient
Browse files Browse the repository at this point in the history
* Also fix a couple'a minor bugs
  • Loading branch information
benlangfeld committed Jan 16, 2011
1 parent d9dc3b6 commit aef488f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 63 deletions.
5 changes: 5 additions & 0 deletions Controllers/AccountsController.j
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ RosterViewDragType = @"RosterViewDragType";
selector:@selector(reload)
name:TNStropheRosterRemovedGroupNotification
object:nil];
[[CPNotificationCenter defaultCenter]
addObserver:self
selector:@selector(reload)
name:TNStropheRosterPushNotification
object:nil];
}

- (void)setupStoredAccounts
Expand Down
2 changes: 1 addition & 1 deletion Controllers/ManageAccountsController.j
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var SharedController = nil;
[[CPNotificationCenter defaultCenter]
addObserver:self
selector:@selector(accountsWereUpdated:)
name:AccountConnectionStatusDidChangeNotification
name:TNStropheConnectionStatusDidChangeNotification
object:nil];
}
return self;
Expand Down
2 changes: 1 addition & 1 deletion Libraries/StropheCappuccino
Submodule StropheCappuccino updated from d57b54 to 2980ca
72 changes: 12 additions & 60 deletions Models/Account.j
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@ ConnectionStatusConnected = @"Connected";
ConnectionStatusConnecting = @"Connecting";
ConnectionStatusDisconnected = @"Disconnected";

AccountWasCreatedNotification = @"AccountWasCreatedNotification";
AccountWasAddedNotification = @"AccountWasAddedNotification";
AccountWasEditedNotification = @"AccountWasEditedNotification";
AccountWasDeletedNotification = @"AccountWasDeletedNotification";
AccountConnectionStatusDidChangeNotification = @"AccountConnectionStatusDidChangeNotification";
AccountWasCreatedNotification = @"AccountWasCreatedNotification";
AccountWasAddedNotification = @"AccountWasAddedNotification";
AccountWasEditedNotification = @"AccountWasEditedNotification";
AccountWasDeletedNotification = @"AccountWasDeletedNotification";

@implementation Account : TNStropheConnection
@implementation Account : TNStropheClient
{
TNStropheRoster roster @accessors;
BOOL enabled @accessors(property=isEnabled);

CPWindowController setStatusController;
Expand All @@ -55,10 +53,12 @@ AccountConnectionStatusDidChangeNotification = @"AccountConnectionStatusDidCh
if (self = [super initWithService:BOSHService JID:aJID password:aPassword])
{
enabled = isEnabled;
roster = [TNStropheRoster rosterWithConnection:self];
[self setDelegate:self];
[roster setDelegate:self];
[[CPNotificationCenter defaultCenter] postNotificationName:AccountWasCreatedNotification object:self];
[[CPNotificationCenter defaultCenter]
addObserver:self
selector:@selector(whenStropheConnected:)
name:TNStropheConnectionStatusConnected
object:[self connection]];
}
return self;
}
Expand All @@ -68,65 +68,17 @@ AccountConnectionStatusDidChangeNotification = @"AccountConnectionStatusDidCh
return [[self JID] full];
}

- (BOOL)onStropheConnecting:(id)aConnection
- (void)whenStropheConnected:(id)aConnection
{
CPLog.debug("XMPP: Connecting");
[[CPNotificationCenter defaultCenter] postNotificationName:AccountConnectionStatusDidChangeNotification object:self];
}

- (BOOL)onStropheAuthenticating:(id)aConnection
{
CPLog.debug("XMPP: Authenticating");
[[CPNotificationCenter defaultCenter] postNotificationName:AccountConnectionStatusDidChangeNotification object:self];
}

- (BOOL)onStropheAuthFail:(id)aConnection
{
CPLog.warn("XMPP: Authentication Failed");
[[CPNotificationCenter defaultCenter] postNotificationName:AccountConnectionStatusDidChangeNotification object:self];
}

- (BOOL)onStropheConnected:(id)aConnection
{
CPLog.info("XMPP: Connected");
[[CPNotificationCenter defaultCenter]
removeObserver:self
name:TNStropheConnectionStatusDisconnected
object:nil];
[roster getRoster];
[[CPNotificationCenter defaultCenter] postNotificationName:AccountConnectionStatusDidChangeNotification object:self];
}

- (BOOL)onStropheConnectFail:(id)aConnection
{
CPLog.warn("XMPP: Connection Failed");
[roster clear];
[[CPNotificationCenter defaultCenter] postNotificationName:AccountConnectionStatusDidChangeNotification object:self];
}

- (BOOL)onStropheDisconnecting:(id)aConnection
{
CPLog.debug("XMPP: Disconnecting");
[[CPNotificationCenter defaultCenter] postNotificationName:AccountConnectionStatusDidChangeNotification object:self];
}

- (BOOL)onStropheDisconnected:(id)aConnection
{
CPLog.debug("XMPP: Disconnected");
[roster clear];
[[CPNotificationCenter defaultCenter] postNotificationName:AccountConnectionStatusDidChangeNotification object:self];
}

- (BOOL)onStropheError:(id)aConnection
{
CPLog.error("XMPP: Error");
[roster clear];
[[CPNotificationCenter defaultCenter] postNotificationName:AccountConnectionStatusDidChangeNotification object:self];
}

- (CPString)connectionStatus
{
if ([self isConnected])
if ([[self connection] isConnected])
return ConnectionStatusConnected;

return ConnectionStatusDisconnected;
Expand Down
Loading

0 comments on commit aef488f

Please sign in to comment.