Plugins/Purple Service/ESPurpleQQAccountViewController.m
author Zachary West <zacw@adium.im>
Fri Oct 16 10:43:15 2009 -0400 (2009-10-16)
changeset 2613 3b847939c5de
parent 0 e22ad6bc8b46
permissions -rw-r--r--
Patch from Jortuny to allow specifying client version for QQ. Fixed a few things myself. Fixes #12748.
     1 //
     2 //  ESPurpleQQAccountViewController.m
     3 //  Adium
     4 //
     5 //  Created by Evan Schoenberg on 8/7/06.
     6 //
     7 
     8 #import "ESPurpleQQAccountViewController.h"
     9 #import "ESPurpleQQAccount.h"
    10 
    11 #import <AIUtilities/AIMenuAdditions.h>
    12 #import <AIUtilities/AIPopUpButtonAdditions.h>
    13 
    14 @interface ESPurpleQQAccountViewController()
    15 - (NSMenu *)clientVersionMenu;
    16 @end
    17 
    18 @implementation ESPurpleQQAccountViewController
    19 - (NSString *)nibName{
    20     return @"PurpleQQAccountView";
    21 }
    22 
    23 /*!
    24  * @brief Awake from nib
    25  */
    26 - (void)awakeFromNib
    27 {
    28 	[super awakeFromNib];
    29 	[popUp_clientVersion setMenu:[self clientVersionMenu]];
    30 }
    31 
    32 
    33 //Configure controls
    34 - (void)configureForAccount:(AIAccount *)inAccount
    35 {
    36     [super configureForAccount:inAccount];
    37 
    38 	[checkBox_useTCP setState:[[account preferenceForKey:KEY_QQ_USE_TCP 
    39 												   group:GROUP_ACCOUNT_STATUS] boolValue]];
    40 	[checkBox_useTCP setLocalizedString:AILocalizedString(@"Connect using TCP", nil)];
    41 
    42 	[label_connection setLocalizedString:AILocalizedString(@"Connection:", nil)];
    43 	
    44 	[label_clientVersion setLocalizedString:AILocalizedString(@"Client Version:", nil)];
    45 	
    46 	[popUp_clientVersion selectItemWithRepresentedObject:[inAccount preferenceForKey:KEY_QQ_CLIENT_VERSION
    47 																			   group:GROUP_ACCOUNT_STATUS]];
    48 }
    49 
    50 //Save controls
    51 - (void)saveConfiguration
    52 {
    53 	[account setPreference:[NSNumber numberWithBool:[checkBox_useTCP state]] 
    54 					forKey:KEY_QQ_USE_TCP group:GROUP_ACCOUNT_STATUS];
    55 	
    56 	[account setPreference:[[popUp_clientVersion selectedItem] representedObject]
    57 					forKey:KEY_QQ_CLIENT_VERSION
    58 					 group:GROUP_ACCOUNT_STATUS];
    59 
    60 	[super saveConfiguration];
    61 }
    62 
    63 - (NSMenu *)clientVersionMenu
    64 {
    65 	NSMenu			*clientVersionMenu = [[NSMenu allocWithZone:[NSMenu zone]] init];
    66 	NSDictionary	*clientVersionDict = [NSDictionary dictionaryWithObjectsAndKeys:
    67 										  @"2008", @"qq2008",
    68 										  @"2007", @"qq2007",
    69 										  @"2005", @"qq2005",
    70 										  nil];
    71 	
    72 	for (NSString *prefix in clientVersionDict.allKeys) {
    73 		[clientVersionMenu addItemWithTitle:[clientVersionDict objectForKey:prefix]
    74 									 target:nil
    75 									 action:nil
    76 							  keyEquivalent:@""
    77 						  representedObject:prefix];
    78 	}
    79 
    80 	return [clientVersionMenu autorelease];
    81 }
    82 
    83 @end