Plugins/Purple Service/ESPurpleYahooAccountViewController.m
branchadium-1.5.11
changeset 6014 fcb71cb71a3d
parent 5941 307f53385811
parent 6013 f8d0dc659e3f
child 6016 325e2ab3406f
equal deleted inserted replaced
5941:307f53385811 6014:fcb71cb71a3d
     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 "ESPurpleYahooAccountViewController.h"
       
    18 #import "ESPurpleYahooAccount.h"
       
    19 #import <Adium/AIAccount.h>
       
    20 #import <AIUtilities/AIPopUpButtonAdditions.h>
       
    21 #import <AIUtilities/AIMenuAdditions.h>
       
    22 
       
    23 @interface ESPurpleYahooAccountViewController ()
       
    24 - (NSMenu *)chatServerMenu;
       
    25 @end
       
    26 
       
    27 @implementation ESPurpleYahooAccountViewController
       
    28 
       
    29 /*!
       
    30  * @brief Nib name
       
    31  */
       
    32 - (NSString *)nibName{
       
    33     return @"ESPurpleYahooAccountView";
       
    34 }
       
    35 
       
    36 /*!
       
    37  * @brief Awake from nib
       
    38  */
       
    39 - (void)awakeFromNib
       
    40 {
       
    41 	[super awakeFromNib];
       
    42 	[popUp_chatServer setMenu:[self chatServerMenu]];
       
    43 }
       
    44 
       
    45 /*!
       
    46  * @brief Configure controls
       
    47  */
       
    48 - (void)configureForAccount:(AIAccount *)inAccount
       
    49 {
       
    50 	[super configureForAccount:inAccount];
       
    51 
       
    52 	[popUp_chatServer selectItemWithRepresentedObject:[inAccount preferenceForKey:KEY_YAHOO_ROOM_LIST_LOCALE
       
    53 																			group:GROUP_ACCOUNT_STATUS]];
       
    54 }
       
    55 
       
    56 /*!
       
    57  * @brief Save controls
       
    58  */
       
    59 - (void)saveConfiguration
       
    60 {
       
    61     [super saveConfiguration];
       
    62 	
       
    63 	[account setPreference:[[popUp_chatServer selectedItem] representedObject]
       
    64 					forKey:KEY_YAHOO_ROOM_LIST_LOCALE
       
    65 					 group:GROUP_ACCOUNT_STATUS];
       
    66 }
       
    67 
       
    68 - (NSMenu *)chatServerMenu
       
    69 {
       
    70 	NSMenu			*chatServerMenu = [[NSMenu allocWithZone:[NSMenu zone]] init];
       
    71 	NSMutableArray	*menuItems = [NSMutableArray array];
       
    72 	NSMenuItem		*menuItem;
       
    73 	NSEnumerator	*enumerator;
       
    74 	NSString		*prefix;
       
    75 	NSDictionary	*roomListServersDict;
       
    76 
       
    77 	roomListServersDict = [NSDictionary dictionaryWithObjectsAndKeys:
       
    78 		@"Asia", @"aa",
       
    79 		@"Argentina", @"ar",
       
    80 		@"Australia", @"au",
       
    81 		@"Brazil", @"br",
       
    82 		@"Canada", @"ca",
       
    83 		@"Central African Republic", @"cf",
       
    84 		@"China", @"cn",
       
    85 /*		@"Germany", @"de",*/
       
    86 		@"Denmark", @"dk",
       
    87 		@"Spain", @"es",
       
    88 		@"France", @"fr",
       
    89 		@"Hong Kong", @"hk",
       
    90 		@"India", @"in",
       
    91 		@"Italy", @"it",
       
    92 		@"Korea, Republic of", @"kr",
       
    93 		@"Mexico", @"mx",
       
    94 		@"Norway", @"no",
       
    95 		@"Sweden", @"se",
       
    96 		@"Singapore", @"sg",
       
    97 		@"Taiwan", @"tw",
       
    98 		@"United Kingdom", @"uk",
       
    99 		nil];
       
   100 
       
   101 	menuItem = [[[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:AILocalizedString(@"United States",nil)
       
   102 																	 target:nil
       
   103 																	 action:nil
       
   104 															  keyEquivalent:@""] autorelease];
       
   105 	[menuItem setRepresentedObject:@"us"];
       
   106 	[menuItems addObject:menuItem];
       
   107 
       
   108 	enumerator = [roomListServersDict keyEnumerator];
       
   109 	while ((prefix = [enumerator nextObject])) {
       
   110 		menuItem = [[[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:[roomListServersDict objectForKey:prefix]
       
   111 																		 target:nil
       
   112 																		 action:nil
       
   113 																  keyEquivalent:@""] autorelease];
       
   114 		[menuItem setRepresentedObject:prefix];
       
   115 		[menuItems addObject:menuItem];		
       
   116 	}
       
   117 
       
   118 	[menuItems sortUsingSelector:@selector(titleCompare:)];
       
   119 
       
   120 	for (menuItem in menuItems) {
       
   121 		[chatServerMenu addItem:menuItem];
       
   122 	}
       
   123 
       
   124 	return [chatServerMenu autorelease];
       
   125 }
       
   126 
       
   127 @end