Skip to content

Commit

Permalink
Fixed an issue in which changed account settings did not take place i…
Browse files Browse the repository at this point in the history
…mmediately after enabling the account. AppController's preferenceControllerDidChangeAccountEnabled: creates new AKAccountController object and replaces the old one in accountControllers array.

The title of AKAccountController window sets in it's designated initializer.
  • Loading branch information
eofster committed Dec 25, 2008
1 parent 9a9ebea commit c8ad16c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
2 changes: 2 additions & 0 deletions AKAccountController.m
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ - (id)initWithTelephoneAccount:(AKTelephoneAccount *)anAccount

[account setDelegate:self];

[[self window] setTitle:[[self account] SIPAddress]];

return self;
}

Expand Down
23 changes: 17 additions & 6 deletions AppController.m
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ - (void)awakeFromNib
username:username];

[anAccountController setEnabled:[[accountDict objectForKey:AKAccountEnabled] boolValue]];
[[anAccountController window] setTitle:[[anAccountController account] SIPAddress]];

[[self accountControllers] addObject:anAccountController];

Expand Down Expand Up @@ -496,7 +495,6 @@ - (void)preferenceControllerDidAddAccount:(NSNotification *)notification

[[self accountControllers] addObject:theAccountController];

[[theAccountController window] setTitle:[[theAccountController account] SIPAddress]];
[[theAccountController window] orderFront:self];

// Register account.
Expand All @@ -518,22 +516,35 @@ - (void)preferenceControllerDidRemoveAccount:(NSNotification *)notification
- (void)preferenceControllerDidChangeAccountEnabled:(NSNotification *)notification
{
NSUInteger index = [[[notification userInfo] objectForKey:AKAccountIndex] integerValue];
AKAccountController *theAccountController = [[self accountControllers] objectAtIndex:index];

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSArray *savedAccounts = [defaults arrayForKey:AKAccounts];
NSDictionary *accountDict = [savedAccounts objectAtIndex:index];
[theAccountController setEnabled:[[accountDict objectForKey:AKAccountEnabled] boolValue]];

if ([theAccountController isEnabled]) {
BOOL isEnabled = [[accountDict objectForKey:AKAccountEnabled] boolValue];

AKAccountController *theAccountController;
if (isEnabled) {
theAccountController = [[[AKAccountController alloc] initWithFullName:[accountDict objectForKey:AKFullName]
SIPAddress:[accountDict objectForKey:AKSIPAddress]
registrar:[accountDict objectForKey:AKRegistrar]
realm:[accountDict objectForKey:AKRealm]
username:[accountDict objectForKey:AKUsername]]
autorelease];

[theAccountController setEnabled:isEnabled];

[[self accountControllers] replaceObjectAtIndex:index withObject:theAccountController];

[[theAccountController window] orderFront:nil];

// Register account (as a result, it will be added to Telephone).
[theAccountController setAccountRegistered:YES];

} else {
theAccountController = [[self accountControllers] objectAtIndex:index];
// Remove account from Telephone.
[[self telephone] removeAccount:[theAccountController account]];

[[theAccountController window] orderOut:nil];
}
}
Expand Down

0 comments on commit c8ad16c

Please sign in to comment.