Skip to content
Browse files

Account management table should reflect up to date connection status

  • Loading branch information...
1 parent f2bc5b9 commit 8709a14afaa149f45fea13b4920208a382c3b072 @benlangfeld committed Nov 5, 2010
Showing with 18 additions and 4 deletions.
  1. +5 −0 Controllers/ManageAccountsController.j
  2. +13 −4 Models/Account.j
View
5 Controllers/ManageAccountsController.j
@@ -66,6 +66,11 @@ var SharedController = nil;
selector:@selector(accountsWereUpdated:)
name:AccountWasDeletedNotification
object:nil];
+ [[CPNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(accountsWereUpdated:)
+ name:AccountConnectionStatusDidChangeNotification
+ object:nil];
}
return self;
}
View
17 Models/Account.j
@@ -29,10 +29,11 @@ ConnectionStatusConnected = @"Connected";
ConnectionStatusConnecting = @"Connecting";
ConnectionStatusDisconnected = @"Disconnected";
-AccountWasCreatedNotification = @"AccountWasCreatedNotification";
-AccountWasAddedNotification = @"AccountWasAddedNotification";
-AccountWasEditedNotification = @"AccountWasEditedNotification";
-AccountWasDeletedNotification = @"AccountWasDeletedNotification";
+AccountWasCreatedNotification = @"AccountWasCreatedNotification";
+AccountWasAddedNotification = @"AccountWasAddedNotification";
+AccountWasEditedNotification = @"AccountWasEditedNotification";
+AccountWasDeletedNotification = @"AccountWasDeletedNotification";
+AccountConnectionStatusDidChangeNotification = @"AccountConnectionStatusDidChangeNotification";
@implementation Account : TNStropheConnection
{
@@ -69,16 +70,19 @@ AccountWasDeletedNotification = @"AccountWasDeletedNotification";
- (BOOL)onStropheConnecting:(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
@@ -89,29 +93,34 @@ AccountWasDeletedNotification = @"AccountWasDeletedNotification";
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

0 comments on commit 8709a14

Please sign in to comment.
Something went wrong with that request. Please try again.