| File: | Plugins/Send Message Contact Alert/ESSendMessageAlertDetailPane.m |
| Location: | line 195, column 11 |
| Description: | dead store |
| 1 | /* |
| 2 | * Adium is the legal property of its developers, whose names are listed in the copyright file included |
| 3 | * with this source distribution. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU |
| 6 | * General Public License as published by the Free Software Foundation; either version 2 of the License, |
| 7 | * or (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even |
| 10 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
| 11 | * Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License along with this program; if not, |
| 14 | * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 15 | */ |
| 16 | |
| 17 | #import <Adium/AIAccountControllerProtocol.h> |
| 18 | #import <Adium/AIContactControllerProtocol.h> |
| 19 | #import "ESSendMessageAlertDetailPane.h" |
| 20 | #import "ESSendMessageContactAlertPlugin.h" |
| 21 | #import <AIUtilities/AIAttributedStringAdditions.h> |
| 22 | #import <AIUtilities/AIPopUpButtonAdditions.h> |
| 23 | #import <Adium/AIAccount.h> |
| 24 | #import <Adium/AIContentMessage.h> |
| 25 | #import <Adium/AIListContact.h> |
| 26 | #import <Adium/AIMetaContact.h> |
| 27 | #import <Adium/AIUserIcons.h> |
| 28 | #import <Adium/AIAccountMenu.h> |
| 29 | #import <Adium/AIService.h> |
| 30 | |
| 31 | @interface ESSendMessageAlertDetailPane (PRIVATE) |
| 32 | - (void)setDestinationContact:(AIListContact *)inContact; |
| 33 | @end |
| 34 | |
| 35 | @implementation ESSendMessageAlertDetailPane |
| 36 | |
| 37 | //Pane Details |
| 38 | - (NSString *)label{ |
| 39 | return @""; |
| 40 | } |
| 41 | - (NSString *)nibName{ |
| 42 | return @"SendMessageContactAlert"; |
| 43 | } |
| 44 | |
| 45 | //Configure the detail view |
| 46 | - (void)viewDidLoad |
| 47 | { |
| 48 | toContact = nil0; |
| 49 | |
| 50 | [label_To setLocalizedString:AILocalizedString[ [ NSBundle bundleForClass : [ self class ] ] localizedStringForKey : ( @ "To:" ) value : @ "" table : ( 0 ) ](@"To:",nil)]; |
| 51 | [label_From setLocalizedString:AILocalizedString[ [ NSBundle bundleForClass : [ self class ] ] localizedStringForKey : ( @ "From:" ) value : @ "" table : ( 0 ) ](@"From:",nil)]; |
| 52 | [label_Message setLocalizedString:AILocalizedString[ [ NSBundle bundleForClass : [ self class ] ] localizedStringForKey : ( @ "Message:" ) value : @ "" table : ( 0 ) ](@"Message:",nil)]; |
| 53 | |
| 54 | [button_useAnotherAccount setLocalizedString:AILocalizedString[ [ NSBundle bundleForClass : [ self class ] ] localizedStringForKey : ( @ "Use another account if necessary" ) value : @ "" table : ( 0 ) ](@"Use another account if necessary",nil)]; |
| 55 | |
| 56 | accountMenu = [[AIAccountMenu accountMenuWithDelegate:self |
| 57 | submenuType:AIAccountNoSubmenu |
| 58 | showTitleVerbs:NO( BOOL ) 0] retain]; |
| 59 | //Update 'from' menu |
| 60 | [popUp_messageFrom setMenu:[accountMenu menu]]; |
| 61 | } |
| 62 | |
| 63 | // |
| 64 | - (void)viewWillClose |
| 65 | { |
| 66 | [toContact release]; toContact = nil0; |
| 67 | [accountMenu release]; accountMenu = nil0; |
| 68 | } |
| 69 | |
| 70 | //Configure for the action |
| 71 | - (void)configureForActionDetails:(NSDictionary *)inDetails listObject:(AIListObject *)inObject |
| 72 | { |
| 73 | AIAccount *sourceAccount; |
| 74 | NSAttributedString *messageText; |
| 75 | NSString *destUniqueID; |
| 76 | AIListObject *destObject = nil0; |
| 77 | |
| 78 | //Attempt to find a saved destination object; if none is found, use the one we were passed |
| 79 | destUniqueID = [inDetails objectForKey:KEY_MESSAGE_SEND_TO@ "Destination ID"]; |
| 80 | if (destUniqueID) destObject = [[adium contactController] existingListObjectWithUniqueID:destUniqueID]; |
| 81 | if (!destObject) destObject = inObject; |
| 82 | |
| 83 | //Configure the destination menu |
| 84 | [popUp_messageTo setMenu:[[adium contactController] menuOfAllContactsInContainingObject:nil0 withTarget:self]]; |
| 85 | |
| 86 | if (destObject && [destObject isKindOfClass:[AIListContact class]]) { |
| 87 | [self setDestinationContact:(AIListContact *)destObject]; |
| 88 | } else { |
| 89 | [self setDestinationContact:nil0]; |
| 90 | } |
| 91 | |
| 92 | //Configure the remaining controls |
| 93 | id accountID = [inDetails objectForKey:KEY_MESSAGE_SEND_FROM@ "Account ID"]; |
| 94 | if (![accountID isKindOfClass:[NSString class]]) { |
| 95 | //Old code stored this as an NSNumber; upgrade. |
| 96 | if ([accountID isKindOfClass:[NSNumber class]]) { |
| 97 | accountID = [NSString stringWithFormat:@"%i",[(NSNumber *)accountID intValue]]; |
| 98 | } else { |
| 99 | accountID = nil0; //Unrecognizable, ignore |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | if ((sourceAccount = [[adium accountController] accountWithInternalObjectID:(NSString *)accountID])) { |
| 104 | [popUp_messageFrom selectItemWithRepresentedObject:sourceAccount]; |
| 105 | } |
| 106 | |
| 107 | if ((messageText = [NSAttributedString stringWithData:[inDetails objectForKey:KEY_MESSAGE_SEND_MESSAGE@ "Message"]])) { |
| 108 | [[textView_message textStorage] setAttributedString:messageText]; |
| 109 | } else { |
| 110 | [textView_message setString:@""]; |
| 111 | } |
| 112 | |
| 113 | [button_useAnotherAccount setState:[[inDetails objectForKey:KEY_MESSAGE_OTHER_ACCOUNT@ "Allow Other"] boolValue]]; |
| 114 | } |
| 115 | |
| 116 | //Return our current configuration |
| 117 | - (NSDictionary *)actionDetails |
| 118 | { |
| 119 | NSDictionary *actionDetails; |
| 120 | |
| 121 | if (toContact && |
| 122 | [popUp_messageFrom numberOfItems] && [popUp_messageFrom selectedItem]) { |
| 123 | actionDetails = [NSDictionary dictionaryWithObjectsAndKeys: |
| 124 | [toContact internalObjectID], KEY_MESSAGE_SEND_TO@ "Destination ID", |
| 125 | [[[popUp_messageFrom selectedItem] representedObject] internalObjectID], KEY_MESSAGE_SEND_FROM@ "Account ID", |
| 126 | [NSNumber numberWithBool:[button_useAnotherAccount state]], KEY_MESSAGE_OTHER_ACCOUNT@ "Allow Other", |
| 127 | [[textView_message textStorage] dataRepresentation], KEY_MESSAGE_SEND_MESSAGE@ "Message", |
| 128 | nil0]; |
| 129 | } else { |
| 130 | actionDetails = nil0; |
| 131 | } |
| 132 | |
| 133 | return actionDetails; |
| 134 | } |
| 135 | |
| 136 | //Destination contact was selected from menu |
| 137 | - (void)selectContact:(id)sender |
| 138 | { |
| 139 | AIListObject *listObject; |
| 140 | |
| 141 | if ((listObject = [sender representedObject]) && |
| 142 | [listObject isKindOfClass:[AIListContact class]]) { |
| 143 | [self setDestinationContact:(AIListContact *)listObject]; |
| 144 | |
| 145 | [self detailsForHeaderChanged]; |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | //Set our destination contact |
| 150 | - (void)setDestinationContact:(AIListContact *)inContact |
| 151 | { |
| 152 | if (inContact != toContact) { |
| 153 | NSMenuItem *firstMenuItem; |
| 154 | AIAccount *preferredAccount; |
| 155 | |
| 156 | [toContact release]; toContact = [inContact retain]; |
| 157 | |
| 158 | //NSPopUpButton doesn't handle submenus well at all. We put a blank menu item at the top of our |
| 159 | //menu when we created it. We can now change its attributes to affect the way the unclicked button |
| 160 | //displays. |
| 161 | firstMenuItem = (NSMenuItem *)[[popUp_messageTo menu] itemAtIndex:0]; |
| 162 | [firstMenuItem setTitle:([toContact isKindOfClass:[AIMetaContact class]] ? |
| 163 | [toContact displayName] : |
| 164 | [toContact formattedUID])]; |
| 165 | [firstMenuItem setImage:[AIUserIcons menuUserIconForObject:toContact]]; |
| 166 | [popUp_messageTo selectItemAtIndex:0]; |
| 167 | |
| 168 | //Select preferred account |
| 169 | preferredAccount = [[adium accountController] preferredAccountForSendingContentType:CONTENT_MESSAGE_TYPE@ "Message" |
| 170 | toContact:toContact]; |
| 171 | if (preferredAccount) [popUp_messageFrom selectItemWithRepresentedObject:preferredAccount]; |
| 172 | |
| 173 | //Rebuild the account menu to be appropriate |
| 174 | [accountMenu rebuildMenu]; |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | - (void)accountMenu:(AIAccountMenu *)inAccountMenu didRebuildMenuItems:(NSArray *)menuItems |
| 179 | { |
| 180 | [popUp_messageFrom setMenu:[accountMenu menu]]; |
| 181 | |
| 182 | [popUp_messageFrom synchronizeTitleAndSelectedItem]; |
| 183 | } |
| 184 | |
| 185 | - (BOOL)accountMenu:(AIAccountMenu *)inAccountMenu shouldIncludeAccount:(AIAccount *)inAccount |
| 186 | { |
| 187 | BOOL shouldInclude = NO( BOOL ) 0; |
| 188 | NSString *accountServiceClass = [[inAccount service] serviceClass]; |
| 189 | |
| 190 | if ([toContact isKindOfClass:[AIMetaContact class]]) { |
| 191 | NSEnumerator *enumerator; |
| 192 | AIListContact *listContact; |
| 193 | |
| 194 | enumerator = [[(AIMetaContact *)toContact listContacts] objectEnumerator]; |
Although the value stored to 'listContact' is used in the enclosing expression, the value is never actually read from 'listContact' | |
| 195 | while ((listContact = [enumerator nextObject]) && !shouldInclude) { |
| 196 | shouldInclude = [accountServiceClass isEqualToString:[[toContact service] serviceClass]]; |
| 197 | } |
| 198 | |
| 199 | } else { |
| 200 | shouldInclude = [accountServiceClass isEqualToString:[[toContact service] serviceClass]]; |
| 201 | } |
| 202 | |
| 203 | return shouldInclude; |
| 204 | } |
| 205 | |
| 206 | @end |