Changeset 7370


Ignore:
Timestamp:
Dec 14, 2008, 12:31:33 AM (12 years ago)
Author:
livings124
Message:

#1559 Simplify tr_sessionInitFull - Mac client

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/transmission.h

    r7369 r7370  
    9292 * @addtogroup tr_session Session
    9393 *
    94  * A libtransmission session is created by calling either tr_sessionInit()
    95  * or tr_sessionInit().  libtransmission creates a thread for itself so that
    96  * it can operate independently of the caller's event loop.  The session will
    97  * continue until tr_sessionClose() is called.
     94 * A libtransmission session is created by calling tr_sessionInit().
     95 * libtransmission creates a thread for itself so that it can operate
     96 * independently of the caller's event loop.  The session will  continue
     97 * until tr_sessionClose() is called.
    9898 *
    9999 * @{
     
    237237 * @encode
    238238 *
    239  * @param tag "gtk", "mac", "daemon", etc... this is only for pre-1.30 resume files
     239 * @param tag "gtk", "macosx", "daemon", etc... this is only for pre-1.30 resume files
    240240 * @param configDir where Transmission will look for resume files, blocklists, etc.
    241241 * @param messageQueueingEnabled if false, messages will be dumped to stderr
  • trunk/macosx/Controller.m

    r7364 r7370  
    4949#import "ExpandedPathToIconTransformer.h"
    5050#import "SpeedLimitToTurtleIconTransformer.h"
     51#import "bencode.h"
    5152#import "utils.h"
    5253
     
    208209        fDefaults = [NSUserDefaults standardUserDefaults];
    209210       
    210         fLib = tr_sessionInitFull(NULL, /* use default config directory (Application Support) */
    211                                 "macosx",
    212 #warning update when changing in prefs
    213                                 [[[fDefaults stringForKey: @"DownloadFolder"] stringByExpandingTildeInPath] UTF8String],
    214                                 [fDefaults boolForKey: @"PEXGlobal"],
    215                                 [fDefaults boolForKey: @"NatTraversal"],
    216                                 [fDefaults boolForKey: @"RandomPort"] ? -1 : [fDefaults integerForKey: @"BindPort"],
    217                                 TR_DEFAULT_ENCRYPTION, /* reset in prefs */
    218                                 TR_DEFAULT_LAZY_BITFIELD_ENABLED,
    219                                 NO, /* reset in prefs */
    220                                 -1, /* reset in prefs */
    221                                 NO, /* reset in prefs */
    222                                 -1, /* reset in prefs */
    223                                 [fDefaults integerForKey: @"PeersTotal"],
    224                                 [fDefaults integerForKey: @"MessageLevel"],
    225                                 YES,
    226                                 [fDefaults boolForKey: @"Blocklist"],
    227                                 [fDefaults integerForKey: @"PeerSocketTOS"], /* hidden pref - default is TR_DEFAULT_PEER_SOCKET_TOS */
    228                                 [fDefaults boolForKey: @"RPC"],
    229                                 [fDefaults integerForKey: @"RPCPort"],
    230                                 [fDefaults boolForKey: @"RPCUseWhitelist"],
    231                                 NULL, /* reset in prefs */
    232                                 [fDefaults boolForKey: @"RPCAuthorize"],
    233                                 [[fDefaults stringForKey: @"RPCUsername"] UTF8String],
    234                                 "", /* reset in prefs - from Keychain */
    235                                 [fDefaults boolForKey: @"Proxy"],
    236                                 [[fDefaults stringForKey: @"ProxyAddress"] UTF8String],
    237                                 [fDefaults integerForKey: @"ProxyPort"],
    238                                 TR_DEFAULT_PROXY_TYPE, /* reset in prefs */
    239                                 [fDefaults boolForKey: @"ProxyAuthorize"],
    240                                 [[fDefaults stringForKey: @"ProxyUsername"] UTF8String],
    241                                 ""); /* reset in prefs - from Keychain */
     211        tr_benc settings;
     212        tr_bencInitDict(&settings, 21);
     213        tr_sessionGetDefaultSettings(&settings);
     214       
     215        tr_bencDictAddInt(&settings, TR_PREFS_KEY_BLOCKLIST_ENABLED, [fDefaults boolForKey: @"Blocklist"]);
     216       
     217        #warning update when changing in prefs
     218        tr_bencDictAddStr(&settings, TR_PREFS_KEY_DOWNLOAD_DIR, [[[fDefaults stringForKey: @"DownloadFolder"]
     219                                                                    stringByExpandingTildeInPath] UTF8String]);
     220       
     221        tr_bencDictAddInt(&settings, TR_PREFS_KEY_MSGLEVEL, [fDefaults boolForKey: @"MessageLevel"]);
     222        tr_bencDictAddInt(&settings, TR_PREFS_KEY_PEER_LIMIT_GLOBAL, [fDefaults integerForKey: @"PeersTotal"]);
     223        tr_bencDictAddInt(&settings, TR_PREFS_KEY_PEER_LIMIT_TORRENT, [fDefaults integerForKey: @"PeersTorrent"]);
     224       
     225        const BOOL randomPort = [fDefaults boolForKey: @"RandomPort"];
     226        tr_bencDictAddInt(&settings, TR_PREFS_KEY_PEER_PORT_RANDOM_ENABLED, randomPort);
     227        if (!randomPort)
     228            tr_bencDictAddInt(&settings, TR_PREFS_KEY_PEER_PORT, [fDefaults integerForKey: @"BindPort"]);
     229       
     230        //hidden pref
     231        if ([fDefaults objectForKey: @"PeerSocketTOS"])
     232            tr_bencDictAddInt(&settings, TR_PREFS_KEY_PEER_SOCKET_TOS, [fDefaults integerForKey: @"PeerSocketTOS"]);
     233       
     234        tr_bencDictAddInt(&settings, TR_PREFS_KEY_PEX_ENABLED, [fDefaults boolForKey: @"PEXGlobal"]);
     235        tr_bencDictAddInt(&settings, TR_PREFS_KEY_PORT_FORWARDING, [fDefaults boolForKey: @"NatTraversal"]);
     236        tr_bencDictAddInt(&settings, TR_PREFS_KEY_PROXY_AUTH_ENABLED, [fDefaults boolForKey: @"ProxyAuthorize"]);
     237        tr_bencDictAddInt(&settings, TR_PREFS_KEY_PROXY_ENABLED, [fDefaults boolForKey: @"Proxy"]);
     238        tr_bencDictAddInt(&settings, TR_PREFS_KEY_PROXY_PORT, [fDefaults integerForKey: @"ProxyPort"]);
     239        tr_bencDictAddStr(&settings, TR_PREFS_KEY_PROXY, [[fDefaults stringForKey: @"ProxyAddress"] UTF8String]);
     240        tr_bencDictAddStr(&settings, TR_PREFS_KEY_PROXY_USERNAME,  [[fDefaults stringForKey: @"ProxyUsername"] UTF8String]);
     241        tr_bencDictAddInt(&settings, TR_PREFS_KEY_RPC_AUTH_REQUIRED,  [fDefaults boolForKey: @"RPCAuthorize"]);
     242        tr_bencDictAddInt(&settings, TR_PREFS_KEY_RPC_ENABLED,  [fDefaults boolForKey: @"RPC"]);
     243        tr_bencDictAddInt(&settings, TR_PREFS_KEY_RPC_PORT,  [fDefaults integerForKey: @"RPCPort"]);
     244        tr_bencDictAddStr(&settings, TR_PREFS_KEY_RPC_USERNAME,  [[fDefaults stringForKey: @"RPCUsername"] UTF8String]);
     245        tr_bencDictAddInt(&settings, TR_PREFS_KEY_RPC_WHITELIST_ENABLED,  [fDefaults boolForKey: @"RPCUseWhitelist"]);
     246       
     247        fLib = tr_sessionInit("macosx", tr_getDefaultConfigDir("Transmission"), YES, &settings);
     248        tr_bencFree(&settings);
    242249       
    243250        [NSApp setDelegate: self];
  • trunk/macosx/Defaults.plist

    r7352 r7370  
    8787        <key>PEXGlobal</key>
    8888        <true/>
    89         <key>PeerSocketTOS</key>
    90         <integer>8</integer>
    9189        <key>PeersTorrent</key>
    9290        <integer>60</integer>
Note: See TracChangeset for help on using the changeset viewer.