Plugins/Purple Service/ESPurpleQQAccount.m
author Zachary West <zacw@adium.im>
Fri Oct 16 10:43:15 2009 -0400 (2009-10-16)
changeset 2613 3b847939c5de
parent 427 1f3c6cb9b8d7
permissions -rw-r--r--
Patch from Jortuny to allow specifying client version for QQ. Fixed a few things myself. Fixes #12748.
     1 //
     2 //  ESPurpleQQAccount.m
     3 //  Adium
     4 //
     5 //  Created by Evan Schoenberg on 8/7/06.
     6 //
     7 
     8 #import "ESPurpleQQAccount.h"
     9 
    10 
    11 @implementation ESPurpleQQAccount
    12 
    13 - (const char*)protocolPlugin
    14 {
    15     return "prpl-qq";
    16 }
    17 
    18 - (void)configurePurpleAccount
    19 {
    20 	[super configurePurpleAccount];
    21 	
    22 	purple_account_set_bool(account, "use_tcp", [[self preferenceForKey:KEY_QQ_USE_TCP group:GROUP_ACCOUNT_STATUS] boolValue]);
    23 	purple_account_set_string(account, "client_version", [[self preferenceForKey:KEY_QQ_CLIENT_VERSION group:GROUP_ACCOUNT_STATUS] UTF8String]);
    24 }
    25 
    26 /*!
    27  * @brief The server name to be passed to libpurple
    28  * QQ prpl will choose a server randomly for load balancing if we don't pass one, so do that.  -self.host returns the first server
    29  * for host reachability checking purpoes.
    30  */
    31 - (NSString *)hostForPurple
    32 {
    33 	NSString *specifiedHost = [self preferenceForKey:KEY_CONNECT_HOST group:GROUP_ACCOUNT_STATUS];
    34 	return (specifiedHost ? specifiedHost : nil);			
    35 }
    36 
    37 - (NSString *)host
    38 {
    39 /* This is not technically right, since the qq plugin randomly chooses one of many different servers at connect time.
    40  * "sz.tencent.com" or "sz#.tencent.com" for UDP
    41  * "tcpconn.tencent.com" or "tcpconn#.tencent.com" where (# <= 6) for TCP.
    42  * Specifying the host is important for network reachability checking, though, and generally all hosts should be up if one is reachable.
    43  */
    44 	NSString *host = [self hostForPurple];
    45 	if (!host)
    46 		host = ([[self preferenceForKey:KEY_QQ_USE_TCP group:GROUP_ACCOUNT_STATUS] boolValue] ? @"tcpconn.tencent.com" : @"sz.tencent.com");
    47 	
    48 	return host;
    49 }
    50 
    51 #pragma mark Account Action Menu Items
    52 - (NSString *)titleForAccountActionMenuLabel:(const char *)label
    53 {
    54 	if (label && (strcmp(label, _("Modify my information")) == 0)) {
    55 		return AILocalizedString(@"Modify My Information", "Menu title for configuring the public information for a QQ account");
    56 	}
    57 	
    58 	return [super titleForAccountActionMenuLabel:label];
    59 }
    60 
    61 @end