Fix oops.
adium-1.5.10.4
tip
2017-04-25, Robert Vehse
* Adium is the legal property of its developers, whose names are listed in the copyright file included * with this source distribution. * This program is free software; you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * Public License for more details. * You should have received a copy of the GNU General Public License along with this program; if not, * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #import "AIAdvancedInspectorPane.h" #import "AINewGroupWindowController.h" #import <AIUtilities/AIParagraphStyleAdditions.h> #import <Adium/AIListObject.h> #import <Adium/AIListContact.h> #import <Adium/AIAccountControllerProtocol.h> #import <AIUtilities/AIArrayAdditions.h> #import <Adium/AIAccount.h> #import <Adium/AIService.h> #import <Adium/AIListGroup.h> #import <Adium/AIListBookmark.h> #import <Adium/AILocalizationTextField.h> #import <Adium/AIMetaContact.h> #import <Adium/AIContactControllerProtocol.h> #import <Adium/AIContentControllerProtocol.h> #import <AIUtilities/AIMenuAdditions.h> #import <AIUtilities/AIPopUpButtonAdditions.h> #import <AIUtilities/AIStringFormatter.h> #import <AIUtilities/AIStringAdditions.h> #import <Adium/AIAccountMenu.h> #import <Adium/AIContactMenu.h> #define ADVANCED_NIB_NAME (@"AIAdvancedInspectorPane") @interface AIAdvancedInspectorPane() - (void)configureControlDimming; - (void)addNewGroup:(id)sender; - (void)newGroupControllerDidEnd:(NSNotification *)notification; @implementation AIAdvancedInspectorPane [NSBundle loadNibNamed:[self nibName] owner:self]; [popUp_encryption setMenu:[adium.contentController encryptionMenuNotifyingTarget:self withDefault:YES]]; [[popUp_encryption menu] setAutoenablesItems:NO]; //Observe contact list changes [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadPopup) //Observe account changes [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadPopup) accountMenu = [[AIAccountMenu accountMenuWithDelegate:self submenuType:AIAccountNoSubmenu showTitleVerbs:NO] retain]; [accountMenu release]; accountMenu = nil; [contactMenu release]; contactMenu = nil; [displayedObject release]; displayedObject = nil; [inspectorContentView release]; inspectorContentView = nil; [[NSNotificationCenter defaultCenter] removeObserver:self]; return ADVANCED_NIB_NAME; -(NSView *)inspectorContentView return inspectorContentView; - (void)configureControlDimming [button_addOrRemoveGroup setEnabled:[tableView_groups numberOfSelectedRows] forSegment:1]; -(void)updateForListObject:(AIListObject *)inObject if (displayedObject != inObject) { [displayedObject release]; displayedObject = ([inObject isKindOfClass:[AIListContact class]] ? [(AIListContact *)inObject parentContact] : [displayedObject retain]; //Rebuild the account and contacts lists if(![inObject isKindOfClass:[AIListContact class]]) { [popUp_encryption selectItemWithTag:EncryptedChat_Default]; [popUp_encryption selectItemWithTag:((AIListContact *)inObject).encryptedChatPreferences]; [checkBox_alwaysShow setEnabled:![inObject isKindOfClass:[AIListGroup class]]]; [checkBox_alwaysShow setState:inObject.alwaysVisible]; [checkBox_autoJoin setEnabled:[inObject isKindOfClass:[AIListBookmark class]]]; [checkBox_autoJoin setState:[[inObject preferenceForKey:KEY_AUTO_JOIN group:GROUP_LIST_BOOKMARK] boolValue]]; [popUp_accounts setEnabled:![inObject isKindOfClass:[AIListGroup class]]]; [popUp_contact setEnabled:![inObject isKindOfClass:[AIListGroup class]]]; [button_addOrRemoveGroup setEnabled:![inObject isKindOfClass:[AIListGroup class]] forSegment:0]; #pragma mark Preference callbacks - (IBAction)selectedEncryptionPreference:(id)sender [displayedObject setPreference:[NSNumber numberWithInteger:[sender tag]] forKey:KEY_ENCRYPTED_CHAT_PREFERENCE - (IBAction)setVisible:(id)sender [displayedObject setAlwaysVisible:[checkBox_alwaysShow state]]; - (IBAction)setAutoJoin:(id)sender [displayedObject setPreference:[NSNumber numberWithBool:[sender state]] group:GROUP_LIST_BOOKMARK]; [accountMenu rebuildMenu]; NSMenu *groupMenu = [adium.contactController groupMenuWithTarget:self]; [groupMenu addItem:[NSMenuItem separatorItem]]; [groupMenu addItemWithTitle:[AILocalizedString(@"New Group", nil) stringByAppendingEllipsis] action:@selector(addNewGroup:) [button_addOrRemoveGroup setMenu:groupMenu]; [button_addOrRemoveGroup setMenuIndicatorShown:YES forSegment:0]; [self configureControlDimming]; - (void)accountMenu:(AIAccountMenu *)inAccountMenu didSelectAccount:(AIAccount *)inAccount currentSelectedAccount = inAccount; // Instantiate here so we don't end up creating a massive menu for all contacts. contactMenu = [[AIContactMenu contactMenuWithDelegate:self forContactsInObject:displayedObject] retain]; [contactMenu setContainingObject:displayedObject]; - (BOOL)accountMenu:(AIAccountMenu *)inAccountMenu shouldIncludeAccount:(AIAccount *)inAccount if ([displayedObject isKindOfClass:[AIMetaContact class]]) { NSArray *services = [((AIMetaContact *)displayedObject).uniqueContainedObjects valueForKeyPath:@"service.serviceClass"]; return [services containsObject:inAccount.service.serviceClass]; } else if ([displayedObject isKindOfClass:[AIListContact class]]) { return [displayedObject.service.serviceClass isEqualToString:inAccount.service.serviceClass]; - (void)accountMenu:(AIAccountMenu *)inAccountMenu didRebuildMenuItems:(NSArray *)menuItems [popUp_accounts setMenu:[inAccountMenu menu]]; [self accountMenu:inAccountMenu didSelectAccount:([popUp_accounts numberOfItems] ? [[popUp_accounts selectedItem] representedObject] : - (void)contactMenuDidRebuild:(AIContactMenu *)inContactMenu [popUp_contact setMenu:inContactMenu.menu]; [self contactMenu:inContactMenu didSelectContact:([popUp_contact numberOfItems] ? [[popUp_contact selectedItem] representedObject] : - (void)contactMenu:(AIContactMenu *)inContactMenu didSelectContact:(AIListContact *)inContact // Avoid triggering a full reload when this ends up creating a new contact. currentSelectedContact = [adium.contactController contactWithService:inContact.service account:currentSelectedAccount [tableView_groups reloadData]; - (BOOL)contactMenu:(AIContactMenu *)inContactMenu shouldIncludeContact:(AIListContact *)inContact AIAccount *selectedAccount = currentSelectedAccount; // Include this contact if it's the same as the selected account. return [selectedAccount.service.serviceClass isEqualToString:inContact.service.serviceClass]; - (NSControlSize)controlSizeForAccountMenu:(AIAccountMenu *)inAccountMenu return NSSmallControlSize; #pragma mark Group control - (void)addNewGroup:(id)sender AINewGroupWindowController *newGroupController = [[AINewGroupWindowController alloc] init]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(newGroupControllerDidEnd:) name:@"NewGroupWindowControllerDidEnd" object:newGroupController.window]; [newGroupController showOnWindow:inspectorContentView.window]; for (AIListGroup *group in [currentSelectedContact.remoteGroups.allObjects objectsAtIndexes:tableView_groups.selectedRowIndexes]) { [currentSelectedContact removeFromGroup:group]; [tableView_groups deselectAll:nil]; [tableView_groups reloadData]; - (void)newGroupControllerDidEnd:(NSNotification *)notification NSParameterAssert([notification.object isKindOfClass:[NSWindow class]]); NSParameterAssert([((NSWindow *)notification.object).windowController isKindOfClass:[AINewGroupWindowController class]]); AINewGroupWindowController *windowController = ((NSWindow *)notification.object).windowController; if (windowController.group) { [currentSelectedAccount addContact:currentSelectedContact toGroup:windowController.group]; [tableView_groups deselectAll:nil]; [tableView_groups reloadData]; [[NSNotificationCenter defaultCenter] removeObserver:self name:@"NewGroupWindowControllerDidEnd" object:notification.object]; - (void)selectGroup:(id)sender AIListGroup *group = [sender representedObject]; [currentSelectedAccount addContact:currentSelectedContact toGroup:group]; [tableView_groups deselectAll:nil]; [tableView_groups reloadData]; - (void)addOrRemoveGroup:(id)sender NSInteger selectedSegment = [sender selectedSegment]; switch (selectedSegment) { [sender showMenuForSegment:selectedSegment]; #pragma mark Accounts Table View Data Sources * @brief Number of table view rows - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView return currentSelectedContact.remoteGroups.count; * @brief Table view set object value - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row NSString *identifier = [tableColumn identifier]; if ([identifier isEqualToString:@"group"]) { NSArray *contactGroups = currentSelectedContact.remoteGroups.allObjects; return ((AIListGroup *)[contactGroups objectAtIndex:row]).displayName; - (void)tableViewSelectionDidChange:(NSNotification *)notification [self configureControlDimming]; - (void)tableViewDeleteSelectedRows:(NSTableView *)tableView