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.
David@0
     1
//
David@0
     2
//  ESPurpleQQAccount.m
David@0
     3
//  Adium
David@0
     4
//
David@0
     5
//  Created by Evan Schoenberg on 8/7/06.
David@0
     6
//
David@0
     7
David@0
     8
#import "ESPurpleQQAccount.h"
David@0
     9
David@0
    10
David@0
    11
@implementation ESPurpleQQAccount
David@0
    12
David@0
    13
- (const char*)protocolPlugin
David@0
    14
{
David@0
    15
    return "prpl-qq";
David@0
    16
}
David@0
    17
David@0
    18
- (void)configurePurpleAccount
David@0
    19
{
David@0
    20
	[super configurePurpleAccount];
David@0
    21
	
David@0
    22
	purple_account_set_bool(account, "use_tcp", [[self preferenceForKey:KEY_QQ_USE_TCP group:GROUP_ACCOUNT_STATUS] boolValue]);
zacw@2613
    23
	purple_account_set_string(account, "client_version", [[self preferenceForKey:KEY_QQ_CLIENT_VERSION group:GROUP_ACCOUNT_STATUS] UTF8String]);
David@0
    24
}
David@0
    25
David@0
    26
/*!
David@0
    27
 * @brief The server name to be passed to libpurple
David@427
    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
David@0
    29
 * for host reachability checking purpoes.
David@0
    30
 */
David@0
    31
- (NSString *)hostForPurple
David@0
    32
{
David@0
    33
	NSString *specifiedHost = [self preferenceForKey:KEY_CONNECT_HOST group:GROUP_ACCOUNT_STATUS];
David@0
    34
	return (specifiedHost ? specifiedHost : nil);			
David@0
    35
}
David@0
    36
David@0
    37
- (NSString *)host
David@0
    38
{
David@0
    39
/* This is not technically right, since the qq plugin randomly chooses one of many different servers at connect time.
David@0
    40
 * "sz.tencent.com" or "sz#.tencent.com" for UDP
David@0
    41
 * "tcpconn.tencent.com" or "tcpconn#.tencent.com" where (# <= 6) for TCP.
David@0
    42
 * Specifying the host is important for network reachability checking, though, and generally all hosts should be up if one is reachable.
David@0
    43
 */
David@0
    44
	NSString *host = [self hostForPurple];
David@0
    45
	if (!host)
David@0
    46
		host = ([[self preferenceForKey:KEY_QQ_USE_TCP group:GROUP_ACCOUNT_STATUS] boolValue] ? @"tcpconn.tencent.com" : @"sz.tencent.com");
David@0
    47
	
David@0
    48
	return host;
David@0
    49
}
David@0
    50
David@0
    51
#pragma mark Account Action Menu Items
David@0
    52
- (NSString *)titleForAccountActionMenuLabel:(const char *)label
David@0
    53
{
David@0
    54
	if (label && (strcmp(label, _("Modify my information")) == 0)) {
David@0
    55
		return AILocalizedString(@"Modify My Information", "Menu title for configuring the public information for a QQ account");
David@0
    56
	}
David@0
    57
	
David@0
    58
	return [super titleForAccountActionMenuLabel:label];
David@0
    59
}
David@0
    60
David@0
    61
@end