Changeset 10638


Ignore:
Timestamp:
May 8, 2010, 10:42:28 PM (11 years ago)
Author:
charles
Message:

(trunk) #1796 "run script after torrent completion" -- implemented for libT, RPC, and the GTK+ and Qt clients

Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure.ac

    r10607 r10638  
    109109AC_HEADER_TIME
    110110
    111 AC_CHECK_FUNCS([pread pwrite lrintf strlcpy daemon dirname basename strcasecmp localtime_r fallocate64 posix_fallocate memmem strtold syslog valloc getpagesize posix_memalign])
     111AC_CHECK_FUNCS([pread pwrite lrintf strlcpy daemon dirname basename strcasecmp localtime_r fallocate64 posix_fallocate memmem strtold syslog valloc getpagesize posix_memalign clearenv])
    112112AC_PROG_INSTALL
    113113AC_PROG_MAKE_SET
  • trunk/doc/rpc-spec.txt

    r10635 r10638  
    416416   "rpc-version"                 | number     the current RPC API version
    417417   "rpc-version-minimum"         | number     the minimum RPC API version supported
     418   "script-torrent-done-filename"| string     filename of the script to run
     419   "script-torrent-done-enabled" | boolean    whether or not to call the "done" script
    418420   "seedRatioLimit"              | double     the default seed ratio for torrents to use
    419421   "seedRatioLimited"            | boolean    true if seedRatioLimit is honored by default
  • trunk/gtk/main.c

    r10635 r10638  
    11451145
    11461146static void
    1147 prefschanged( TrCore * core UNUSED,
    1148               const char *  key,
    1149               gpointer      data )
    1150 {
    1151     struct cbdata  * cbdata = data;
    1152     tr_session     * tr     = tr_core_session( cbdata->core );
     1147prefschanged( TrCore * core UNUSED, const char * key, gpointer data )
     1148{
     1149    struct cbdata * cbdata = data;
     1150    tr_session * tr = tr_core_session( cbdata->core );
    11531151
    11541152    if( !strcmp( key, TR_PREFS_KEY_ENCRYPTION ) )
     
    13231321    {
    13241322        tr_sessionSetIncompleteDirEnabled( tr, pref_flag_get( key ) );
     1323    }
     1324    else if( !strcmp( key, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_ENABLED ) )
     1325    {
     1326        tr_sessionSetTorrentDoneScriptEnabled( tr, pref_flag_get( key ) );
     1327    }
     1328    else if( !strcmp( key, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_FILENAME ) )
     1329    {
     1330        tr_sessionSetTorrentDoneScript( tr, pref_string_get( key ) );
    13251331    }
    13261332    else if( !strcmp( key, TR_PREFS_KEY_START) )
  • trunk/gtk/tr-prefs.c

    r10635 r10638  
    224224
    225225static void
    226 chosen_cb( GtkFileChooser * w,
    227            gpointer         core )
     226chosen_cb( GtkFileChooser * w, gpointer core )
    228227{
    229228    const char * key = g_object_get_data( G_OBJECT( w ), PREF_KEY );
    230     char *       value = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( w ) );
    231 
     229    char * value = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( w ) );
    232230    tr_core_set_pref( TR_CORE( core ), key, value );
    233231    g_free( value );
     
    235233
    236234static GtkWidget*
    237 new_path_chooser_button( const char * key,
    238                          gpointer     core )
    239 {
    240     GtkWidget *  w = gtk_file_chooser_button_new(
    241         NULL,
    242         GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER );
     235new_path_chooser_button( const char * key, gpointer core )
     236{
     237    GtkWidget *  w = gtk_file_chooser_button_new( NULL, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER );
    243238    const char * path = pref_string_get( key );
    244 
    245     g_object_set_data_full( G_OBJECT( w ), PREF_KEY, g_strdup(
    246                                 key ), g_free );
     239    g_object_set_data_full( G_OBJECT( w ), PREF_KEY, g_strdup( key ), g_free );
    247240    g_signal_connect( w, "selection-changed", G_CALLBACK( chosen_cb ), core );
    248     gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER( w ), path );
     241    if( path != NULL )
     242        gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER( w ), path );
     243    return w;
     244}
     245
     246static GtkWidget*
     247new_file_chooser_button( const char * key, gpointer core )
     248{
     249    GtkWidget *  w = gtk_file_chooser_button_new( NULL, GTK_FILE_CHOOSER_ACTION_OPEN );
     250    const char * path = pref_string_get( key );
     251    g_object_set_data_full( G_OBJECT( w ), PREF_KEY, g_strdup( key ), g_free );
     252    if( path != NULL )
     253        gtk_file_chooser_set_filename( GTK_FILE_CHOOSER( w ), path );
     254    g_signal_connect( w, "selection-changed", G_CALLBACK( chosen_cb ), core );
    249255    return w;
    250256}
     
    302308    hig_workarea_add_wide_control( t, &row, w );
    303309
     310    w = new_path_chooser_button( TR_PREFS_KEY_DOWNLOAD_DIR, core );
     311    hig_workarea_add_row( t, &row, _( "Save to _Location:" ), w, NULL );
     312
    304313    s = _( "Keep _incomplete torrents in:" );
    305314    l = new_check_button( s, TR_PREFS_KEY_INCOMPLETE_DIR_ENABLED, core );
     
    309318    hig_workarea_add_row_w( t, &row, l, w, NULL );
    310319
    311     w = new_path_chooser_button( TR_PREFS_KEY_DOWNLOAD_DIR, core );
    312     hig_workarea_add_row( t, &row, _( "Save to _Location:" ), w, NULL );
     320    s = _( "Call scrip_t when torrent is completed:" );
     321    l = new_check_button( s, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_ENABLED, core );
     322    w = new_file_chooser_button( TR_PREFS_KEY_SCRIPT_TORRENT_DONE_FILENAME, core );
     323    gtk_widget_set_sensitive( GTK_WIDGET( w ), pref_flag_get( TR_PREFS_KEY_SCRIPT_TORRENT_DONE_ENABLED ) );
     324    g_signal_connect( l, "toggled", G_CALLBACK( target_cb ), w );
     325    hig_workarea_add_row_w( t, &row, l, w, NULL );
    313326
    314327    hig_workarea_add_section_divider( t, &row );
  • trunk/libtransmission/rpcimpl.c

    r10635 r10638  
    12311231    if( tr_bencDictFindBool( args_in, TR_PREFS_KEY_START, &boolVal ) )
    12321232        tr_sessionSetPaused( session, !boolVal );
     1233    if( tr_bencDictFindStr( args_in, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_FILENAME, &str ) )
     1234        tr_sessionSetTorrentDoneScript( session, str );
     1235    if( tr_bencDictFindBool( args_in, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_ENABLED, &boolVal ) )
     1236        tr_sessionSetTorrentDoneScriptEnabled( session, boolVal );
    12331237    if( tr_bencDictFindBool( args_in, TR_PREFS_KEY_TRASH_ORIGINAL, &boolVal ) )
    12341238        tr_sessionSetDeleteSource( session, boolVal );
     
    13441348    tr_bencDictAddInt ( d, TR_PREFS_KEY_DSPEED, tr_sessionGetSpeedLimit( s, TR_DOWN ) );
    13451349    tr_bencDictAddBool( d, TR_PREFS_KEY_DSPEED_ENABLED, tr_sessionIsSpeedLimited( s, TR_DOWN ) );
     1350    tr_bencDictAddStr ( d, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_FILENAME, tr_sessionGetTorrentDoneScript( s ) );
     1351    tr_bencDictAddBool( d, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_ENABLED, tr_sessionIsTorrentDoneScriptEnabled( s ) );
    13461352    tr_bencDictAddStr ( d, "version", LONG_VERSION_STRING );
    13471353    switch( tr_sessionGetEncryption( s ) ) {
  • trunk/libtransmission/session.c

    r10635 r10638  
    284284    tr_bencDictAddBool( d, TR_PREFS_KEY_RPC_WHITELIST_ENABLED,    TRUE );
    285285    tr_bencDictAddInt ( d, TR_PREFS_KEY_RPC_PORT,                 atoi( TR_DEFAULT_RPC_PORT_STR ) );
     286    tr_bencDictAddStr ( d, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_FILENAME, "" );
     287    tr_bencDictAddBool( d, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_ENABLED, FALSE );
    286288    tr_bencDictAddBool( d, TR_PREFS_KEY_ALT_SPEED_ENABLED,        FALSE );
    287289    tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_UP,             50 ); /* half the regular */
     
    349351    tr_bencDictAddStr ( d, TR_PREFS_KEY_RPC_WHITELIST,            tr_sessionGetRPCWhitelist( s ) );
    350352    tr_bencDictAddBool( d, TR_PREFS_KEY_RPC_WHITELIST_ENABLED,    tr_sessionGetRPCWhitelistEnabled( s ) );
     353    tr_bencDictAddBool( d, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_ENABLED, tr_sessionIsTorrentDoneScriptEnabled( s ) );
     354    tr_bencDictAddStr ( d, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_FILENAME, tr_sessionGetTorrentDoneScript( s ) );
    351355    tr_bencDictAddBool( d, TR_PREFS_KEY_ALT_SPEED_ENABLED,        tr_sessionUsesAltSpeed( s ) );
    352356    tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_UP,             tr_sessionGetAltSpeed( s, TR_UP ) );
     
    803807    turtleBootstrap( session, turtle );
    804808
     809    /**
     810    ***  Scripts
     811    **/
     812
     813    if( tr_bencDictFindBool( settings, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_ENABLED, &boolVal ) )
     814        tr_sessionSetTorrentDoneScriptEnabled( session, boolVal );
     815    if( tr_bencDictFindStr( settings, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_FILENAME, &str ) )
     816        tr_sessionSetTorrentDoneScript( session, str );
     817
    805818    data->done = TRUE;
    806819}
     
    16701683        tr_free( session->metainfoLookup );
    16711684    }
     1685    tr_free( session->torrentDoneScript );
    16721686    tr_free( session->buffer );
    16731687    tr_free( session->tag );
     
    24322446    }
    24332447}
     2448
     2449/****
     2450*****
     2451****/
     2452
     2453tr_bool
     2454tr_sessionIsTorrentDoneScriptEnabled( const tr_session * session )
     2455{
     2456    assert( tr_isSession( session ) );
     2457
     2458    return session->isTorrentDoneScriptEnabled;
     2459}
     2460
     2461void
     2462tr_sessionSetTorrentDoneScriptEnabled( tr_session * session, tr_bool isEnabled )
     2463{
     2464    assert( tr_isSession( session ) );
     2465    assert( tr_isBool( isEnabled ) );
     2466
     2467    session->isTorrentDoneScriptEnabled = isEnabled;
     2468}
     2469
     2470const char *
     2471tr_sessionGetTorrentDoneScript( const tr_session * session )
     2472{
     2473    assert( tr_isSession( session ) );
     2474
     2475    return session->torrentDoneScript;
     2476}
     2477
     2478void
     2479tr_sessionSetTorrentDoneScript( tr_session * session, const char * scriptFilename )
     2480{
     2481    assert( tr_isSession( session ) );
     2482
     2483    if( session->torrentDoneScript != scriptFilename )
     2484    {
     2485        tr_free( session->torrentDoneScript );
     2486        session->torrentDoneScript = tr_strdup( scriptFilename );
     2487    }
     2488}
  • trunk/libtransmission/session.h

    r10635 r10638  
    8989    tr_bool                      isProxyEnabled;
    9090    tr_bool                      isProxyAuthEnabled;
     91    tr_bool                      isTorrentDoneScriptEnabled;
    9192    tr_bool                      isClosed;
    9293    tr_bool                      useLazyBitfield;
     
    131132    tr_torrent *                 torrentList;
    132133
     134    char *                       torrentDoneScript;
     135
    133136    char *                       tag;
    134137    char *                       configDir;
  • trunk/libtransmission/torrent.c

    r10635 r10638  
    16901690}
    16911691
     1692
     1693static void
     1694torrentCallScript( tr_torrent * tor, const char * script )
     1695{
     1696    assert( tr_isTorrent( tor ) );
     1697
     1698    if( script && *script )
     1699    {
     1700        char buf[128];
     1701        const time_t now = tr_time( );
     1702
     1703#ifdef HAVE_CLEARENV
     1704        clearenv( );
     1705#endif
     1706
     1707        tr_snprintf( buf, sizeof( buf ), "%d", tr_torrentId( tor ) );
     1708        setenv( "TR_TORRENT_ID", buf, 1 );
     1709        setenv( "TR_TORRENT_NAME", tr_torrentName( tor ), 1 );
     1710        setenv( "TR_TORRENT_DIR", tor->currentDir, 1 );
     1711        setenv( "TR_TORRENT_HASH", tor->info.hashString, 1 );
     1712        ctime_r( &now, buf );
     1713        *strchr( buf,'\n' ) = '\0';
     1714        setenv( "TR_TIME_LOCALTIME", buf, 1 );
     1715        tr_torinf( tor, "Calling script \"%s\"", script );
     1716        system( script );
     1717    }
     1718}
     1719
    16921720void
    16931721tr_torrentRecheckCompleteness( tr_torrent * tor )
     
    17211749            if( tor->currentDir == tor->incompleteDir )
    17221750                tr_torrentSetLocation( tor, tor->downloadDir, TRUE, NULL, NULL );
     1751
     1752            if( tr_sessionIsTorrentDoneScriptEnabled( tor->session ) )
     1753                torrentCallScript( tor, tr_sessionGetTorrentDoneScript( tor->session ) );
    17231754        }
    17241755
  • trunk/libtransmission/transmission.h

    r10635 r10638  
    144144
    145145
    146 #define TR_DEFAULT_BIND_ADDRESS_IPV4       "0.0.0.0"
    147 #define TR_DEFAULT_BIND_ADDRESS_IPV6            "::"
    148 #define TR_DEFAULT_OPEN_FILE_LIMIT_STR          "32"
    149 #define TR_DEFAULT_RPC_WHITELIST         "127.0.0.1"
    150 #define TR_DEFAULT_RPC_PORT_STR               "9091"
    151 #define TR_DEFAULT_PEER_PORT_STR             "51413"
    152 #define TR_DEFAULT_PEER_SOCKET_TOS_STR           "0"
    153 #define TR_DEFAULT_PEER_LIMIT_GLOBAL_STR       "240"
    154 #define TR_DEFAULT_PEER_LIMIT_TORRENT_STR       "60"
    155 
    156 #define TR_PREFS_KEY_ALT_SPEED_ENABLED          "alt-speed-enabled"
    157 #define TR_PREFS_KEY_ALT_SPEED_UP               "alt-speed-up"
    158 #define TR_PREFS_KEY_ALT_SPEED_DOWN             "alt-speed-down"
    159 #define TR_PREFS_KEY_ALT_SPEED_TIME_BEGIN       "alt-speed-time-begin"
    160 #define TR_PREFS_KEY_ALT_SPEED_TIME_ENABLED     "alt-speed-time-enabled"
    161 #define TR_PREFS_KEY_ALT_SPEED_TIME_END         "alt-speed-time-end"
    162 #define TR_PREFS_KEY_ALT_SPEED_TIME_DAY         "alt-speed-time-day"
    163 #define TR_PREFS_KEY_BIND_ADDRESS_IPV4          "bind-address-ipv4"
    164 #define TR_PREFS_KEY_BIND_ADDRESS_IPV6          "bind-address-ipv6"
    165 #define TR_PREFS_KEY_BLOCKLIST_ENABLED          "blocklist-enabled"
    166 #define TR_PREFS_KEY_DHT_ENABLED                "dht-enabled"
    167 #define TR_PREFS_KEY_LPD_ENABLED                "lpd-enabled"
    168 #define TR_PREFS_KEY_DOWNLOAD_DIR               "download-dir"
    169 #define TR_PREFS_KEY_ENCRYPTION                 "encryption"
    170 #define TR_PREFS_KEY_INCOMPLETE_DIR             "incomplete-dir"
    171 #define TR_PREFS_KEY_INCOMPLETE_DIR_ENABLED     "incomplete-dir-enabled"
    172 #define TR_PREFS_KEY_LAZY_BITFIELD              "lazy-bitfield-enabled"
    173 #define TR_PREFS_KEY_MSGLEVEL                   "message-level"
    174 #define TR_PREFS_KEY_OPEN_FILE_LIMIT            "open-file-limit"
    175 #define TR_PREFS_KEY_PEER_LIMIT_GLOBAL          "peer-limit-global"
    176 #define TR_PREFS_KEY_PEER_LIMIT_TORRENT         "peer-limit-per-torrent"
    177 #define TR_PREFS_KEY_PEER_PORT                  "peer-port"
    178 #define TR_PREFS_KEY_PEER_PORT_RANDOM_ON_START  "peer-port-random-on-start"
    179 #define TR_PREFS_KEY_PEER_PORT_RANDOM_LOW       "peer-port-random-low"
    180 #define TR_PREFS_KEY_PEER_PORT_RANDOM_HIGH      "peer-port-random-high"
    181 #define TR_PREFS_KEY_PEER_SOCKET_TOS            "peer-socket-tos"
    182 #define TR_PREFS_KEY_PEER_CONGESTION_ALGORITHM  "peer-congestion-algorithm"
    183 #define TR_PREFS_KEY_PEX_ENABLED                "pex-enabled"
    184 #define TR_PREFS_KEY_PORT_FORWARDING            "port-forwarding-enabled"
    185 #define TR_PREFS_KEY_PROXY_AUTH_ENABLED         "proxy-auth-enabled"
    186 #define TR_PREFS_KEY_PREALLOCATION              "preallocation"
    187 #define TR_PREFS_KEY_PROXY_ENABLED              "proxy-enabled"
    188 #define TR_PREFS_KEY_PROXY_PASSWORD             "proxy-auth-password"
    189 #define TR_PREFS_KEY_PROXY_PORT                 "proxy-port"
    190 #define TR_PREFS_KEY_PROXY                      "proxy"
    191 #define TR_PREFS_KEY_PROXY_TYPE                 "proxy-type"
    192 #define TR_PREFS_KEY_PROXY_USERNAME             "proxy-auth-username"
    193 #define TR_PREFS_KEY_RATIO                      "ratio-limit"
    194 #define TR_PREFS_KEY_RATIO_ENABLED              "ratio-limit-enabled"
    195 #define TR_PREFS_KEY_RENAME_PARTIAL_FILES       "rename-partial-files"
    196 #define TR_PREFS_KEY_RPC_AUTH_REQUIRED          "rpc-authentication-required"
    197 #define TR_PREFS_KEY_RPC_BIND_ADDRESS           "rpc-bind-address"
    198 #define TR_PREFS_KEY_RPC_ENABLED                "rpc-enabled"
    199 #define TR_PREFS_KEY_RPC_PASSWORD               "rpc-password"
    200 #define TR_PREFS_KEY_RPC_PORT                   "rpc-port"
    201 #define TR_PREFS_KEY_RPC_USERNAME               "rpc-username"
    202 #define TR_PREFS_KEY_RPC_WHITELIST_ENABLED      "rpc-whitelist-enabled"
    203 #define TR_PREFS_KEY_RPC_WHITELIST              "rpc-whitelist"
    204 #define TR_PREFS_KEY_DSPEED                     "speed-limit-down"
    205 #define TR_PREFS_KEY_DSPEED_ENABLED             "speed-limit-down-enabled"
    206 #define TR_PREFS_KEY_USPEED_ENABLED             "speed-limit-up-enabled"
    207 #define TR_PREFS_KEY_USPEED                     "speed-limit-up"
    208 #define TR_PREFS_KEY_UMASK                      "umask"
    209 #define TR_PREFS_KEY_UPLOAD_SLOTS_PER_TORRENT   "upload-slots-per-torrent"
    210 #define TR_PREFS_KEY_START                      "start-added-torrents"
    211 #define TR_PREFS_KEY_TRASH_ORIGINAL             "trash-original-torrent-files"
     146#define TR_DEFAULT_BIND_ADDRESS_IPV4        "0.0.0.0"
     147#define TR_DEFAULT_BIND_ADDRESS_IPV6             "::"
     148#define TR_DEFAULT_OPEN_FILE_LIMIT_STR           "32"
     149#define TR_DEFAULT_RPC_WHITELIST          "127.0.0.1"
     150#define TR_DEFAULT_RPC_PORT_STR                "9091"
     151#define TR_DEFAULT_PEER_PORT_STR              "51413"
     152#define TR_DEFAULT_PEER_SOCKET_TOS_STR            "0"
     153#define TR_DEFAULT_PEER_LIMIT_GLOBAL_STR        "240"
     154#define TR_DEFAULT_PEER_LIMIT_TORRENT_STR        "60"
     155
     156#define TR_PREFS_KEY_ALT_SPEED_ENABLED             "alt-speed-enabled"
     157#define TR_PREFS_KEY_ALT_SPEED_UP                  "alt-speed-up"
     158#define TR_PREFS_KEY_ALT_SPEED_DOWN                "alt-speed-down"
     159#define TR_PREFS_KEY_ALT_SPEED_TIME_BEGIN          "alt-speed-time-begin"
     160#define TR_PREFS_KEY_ALT_SPEED_TIME_ENABLED        "alt-speed-time-enabled"
     161#define TR_PREFS_KEY_ALT_SPEED_TIME_END            "alt-speed-time-end"
     162#define TR_PREFS_KEY_ALT_SPEED_TIME_DAY            "alt-speed-time-day"
     163#define TR_PREFS_KEY_BIND_ADDRESS_IPV4             "bind-address-ipv4"
     164#define TR_PREFS_KEY_BIND_ADDRESS_IPV6             "bind-address-ipv6"
     165#define TR_PREFS_KEY_BLOCKLIST_ENABLED             "blocklist-enabled"
     166#define TR_PREFS_KEY_DHT_ENABLED                   "dht-enabled"
     167#define TR_PREFS_KEY_LPD_ENABLED                   "lpd-enabled"
     168#define TR_PREFS_KEY_DOWNLOAD_DIR                  "download-dir"
     169#define TR_PREFS_KEY_ENCRYPTION                    "encryption"
     170#define TR_PREFS_KEY_INCOMPLETE_DIR                "incomplete-dir"
     171#define TR_PREFS_KEY_INCOMPLETE_DIR_ENABLED        "incomplete-dir-enabled"
     172#define TR_PREFS_KEY_LAZY_BITFIELD                 "lazy-bitfield-enabled"
     173#define TR_PREFS_KEY_MSGLEVEL                      "message-level"
     174#define TR_PREFS_KEY_OPEN_FILE_LIMIT               "open-file-limit"
     175#define TR_PREFS_KEY_PEER_LIMIT_GLOBAL             "peer-limit-global"
     176#define TR_PREFS_KEY_PEER_LIMIT_TORRENT            "peer-limit-per-torrent"
     177#define TR_PREFS_KEY_PEER_PORT                     "peer-port"
     178#define TR_PREFS_KEY_PEER_PORT_RANDOM_ON_START     "peer-port-random-on-start"
     179#define TR_PREFS_KEY_PEER_PORT_RANDOM_LOW          "peer-port-random-low"
     180#define TR_PREFS_KEY_PEER_PORT_RANDOM_HIGH         "peer-port-random-high"
     181#define TR_PREFS_KEY_PEER_SOCKET_TOS               "peer-socket-tos"
     182#define TR_PREFS_KEY_PEER_CONGESTION_ALGORITHM     "peer-congestion-algorithm"
     183#define TR_PREFS_KEY_PEX_ENABLED                   "pex-enabled"
     184#define TR_PREFS_KEY_PORT_FORWARDING               "port-forwarding-enabled"
     185#define TR_PREFS_KEY_PROXY_AUTH_ENABLED            "proxy-auth-enabled"
     186#define TR_PREFS_KEY_PREALLOCATION                 "preallocation"
     187#define TR_PREFS_KEY_PROXY_ENABLED                 "proxy-enabled"
     188#define TR_PREFS_KEY_PROXY_PASSWORD                "proxy-auth-password"
     189#define TR_PREFS_KEY_PROXY_PORT                    "proxy-port"
     190#define TR_PREFS_KEY_PROXY                         "proxy"
     191#define TR_PREFS_KEY_PROXY_TYPE                    "proxy-type"
     192#define TR_PREFS_KEY_PROXY_USERNAME                "proxy-auth-username"
     193#define TR_PREFS_KEY_RATIO                         "ratio-limit"
     194#define TR_PREFS_KEY_RATIO_ENABLED                 "ratio-limit-enabled"
     195#define TR_PREFS_KEY_RENAME_PARTIAL_FILES          "rename-partial-files"
     196#define TR_PREFS_KEY_RPC_AUTH_REQUIRED             "rpc-authentication-required"
     197#define TR_PREFS_KEY_RPC_BIND_ADDRESS              "rpc-bind-address"
     198#define TR_PREFS_KEY_RPC_ENABLED                   "rpc-enabled"
     199#define TR_PREFS_KEY_RPC_PASSWORD                  "rpc-password"
     200#define TR_PREFS_KEY_RPC_PORT                      "rpc-port"
     201#define TR_PREFS_KEY_RPC_USERNAME                  "rpc-username"
     202#define TR_PREFS_KEY_RPC_WHITELIST_ENABLED         "rpc-whitelist-enabled"
     203#define TR_PREFS_KEY_SCRIPT_TORRENT_DONE_FILENAME  "script-torrent-done-filename"
     204#define TR_PREFS_KEY_SCRIPT_TORRENT_DONE_ENABLED   "script-torrent-done-enabled"
     205#define TR_PREFS_KEY_RPC_WHITELIST                 "rpc-whitelist"
     206#define TR_PREFS_KEY_DSPEED                        "speed-limit-down"
     207#define TR_PREFS_KEY_DSPEED_ENABLED                "speed-limit-down-enabled"
     208#define TR_PREFS_KEY_USPEED_ENABLED                "speed-limit-up-enabled"
     209#define TR_PREFS_KEY_USPEED                        "speed-limit-up"
     210#define TR_PREFS_KEY_UMASK                         "umask"
     211#define TR_PREFS_KEY_UPLOAD_SLOTS_PER_TORRENT      "upload-slots-per-torrent"
     212#define TR_PREFS_KEY_START                         "start-added-torrents"
     213#define TR_PREFS_KEY_TRASH_ORIGINAL                "trash-original-torrent-files"
    212214
    213215
     
    747749                                      tr_ctor     * ctor,
    748750                                      int         * setmeCount );
     751
     752/**
     753***
     754**/
     755
     756tr_bool tr_sessionIsTorrentDoneScriptEnabled( const tr_session * );
     757
     758void tr_sessionSetTorrentDoneScriptEnabled( tr_session *, tr_bool isEnabled );
     759
     760const char * tr_sessionGetTorrentDoneScript( const tr_session * );
     761
     762void tr_sessionSetTorrentDoneScript( tr_session *, const char * scriptFilename );
     763
    749764
    750765/** @} */
  • trunk/qt/prefs-dialog.cc

    r10635 r10638  
    491491
    492492void
     493PrefsDialog :: onScriptClicked( void )
     494{
     495    const QString title = tr( "Select \"Torrent Done\" Script" );
     496    const QString path = myPrefs.getString( Prefs::SCRIPT_TORRENT_DONE_FILENAME );
     497    QFileDialog * d = new QFileDialog( this, title, path );
     498    d->setFileMode( QFileDialog::ExistingFiles );
     499    connect( d, SIGNAL(filesSelected(const QStringList&)),
     500             this, SLOT(onScriptSelected(const QStringList&)) );
     501    d->show( );
     502}
     503
     504void
     505PrefsDialog :: onScriptSelected( const QStringList& list )
     506{
     507    if( list.size() == 1 )
     508        myPrefs.set( Prefs::Prefs::SCRIPT_TORRENT_DONE_FILENAME, list.first( ) );
     509}
     510
     511
     512void
    493513PrefsDialog :: onIncompleteClicked( void )
    494514{
     
    555575    const QIcon folderIcon = iconProvider.icon( QFileIconProvider::Folder );
    556576    const QPixmap folderPixmap = folderIcon.pixmap( iconSize );
     577    const QIcon fileIcon = iconProvider.icon( QFileIconProvider::File );
     578    const QPixmap filePixmap = fileIcon.pixmap( iconSize );
    557579
    558580    QWidget *l, *r;
     
    573595        hig->addWideControl( checkBoxNew( tr( "Append \".&part\" to incomplete files' names" ), Prefs::RENAME_PARTIAL_FILES ) );
    574596
    575         myIncompleteCheckbox = checkBoxNew( tr( "Keep &incomplete files in:" ), Prefs::INCOMPLETE_DIR_ENABLED );
     597        l = myIncompleteCheckbox = checkBoxNew( tr( "Keep &incomplete files in:" ), Prefs::INCOMPLETE_DIR_ENABLED );
    576598        b = myIncompleteButton = new QPushButton;
    577599        b->setIcon( folderPixmap );
     
    579601        connect( b, SIGNAL(clicked(bool)), this, SLOT(onIncompleteClicked(void)) );
    580602        hig->addRow( myIncompleteCheckbox, b );
     603        enableBuddyWhenChecked( qobject_cast<QCheckBox*>(l), b );
     604
     605        l = myTorrentDoneScriptCheckbox = checkBoxNew( tr( "Call scrip&t when torrent is completed" ), Prefs::SCRIPT_TORRENT_DONE_ENABLED );
     606        b = myTorrentDoneScriptFilename = new QPushButton;
     607        b->setIcon( filePixmap );
     608        b->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" );
     609        connect( b, SIGNAL(clicked(bool)), this, SLOT(onScriptClicked(void)) );
     610        hig->addRow( myTorrentDoneScriptCheckbox, b );
     611        enableBuddyWhenChecked( qobject_cast<QCheckBox*>(l), b );
    581612
    582613        b = myDestinationButton = new QPushButton;
  • trunk/qt/prefs-dialog.h

    r10516 r10638  
    5353        void onWatchClicked( );
    5454        void onWatchSelected( const QStringList& );
     55        void onScriptClicked( );
     56        void onScriptSelected( const QStringList& );
    5557        void onIncompleteClicked( );
    5658        void onIncompleteSelected( const QStringList& );
     
    9799        QPushButton * myPortButton;
    98100        QPushButton * myWatchButton;
     101        QPushButton * myTorrentDoneScriptFilename;
     102        QCheckBox * myTorrentDoneScriptCheckbox;
    99103        QCheckBox * myIncompleteCheckbox;
    100104        QPushButton * myIncompleteButton;
  • trunk/qt/prefs.cc

    r10635 r10638  
    8989    { PEER_PORT_RANDOM_LOW, TR_PREFS_KEY_PEER_PORT_RANDOM_LOW, QVariant::Int },
    9090    { PEER_PORT_RANDOM_HIGH, TR_PREFS_KEY_PEER_PORT_RANDOM_HIGH, QVariant::Int },
     91    { SCRIPT_TORRENT_DONE_ENABLED, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_ENABLED, QVariant::Bool },
     92    { SCRIPT_TORRENT_DONE_FILENAME, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_FILENAME, QVariant::String },
    9193    { SOCKET_TOS, TR_PREFS_KEY_PEER_SOCKET_TOS, QVariant::Int },
    9294    { START, TR_PREFS_KEY_START, QVariant::Bool },
  • trunk/qt/prefs.h

    r10635 r10638  
    9393            PEER_PORT_RANDOM_LOW,
    9494            PEER_PORT_RANDOM_HIGH,
     95            SCRIPT_TORRENT_DONE_ENABLED,
     96            SCRIPT_TORRENT_DONE_FILENAME,
    9597            SOCKET_TOS,
    9698            START,
  • trunk/qt/session.cc

    r10635 r10638  
    129129    if( myPrefs.isCore( key ) ) switch( key )
    130130    {
    131         case Prefs :: ALT_SPEED_LIMIT_UP:
    132131        case Prefs :: ALT_SPEED_LIMIT_DOWN:
    133132        case Prefs :: ALT_SPEED_LIMIT_ENABLED:
    134133        case Prefs :: ALT_SPEED_LIMIT_TIME_BEGIN:
     134        case Prefs :: ALT_SPEED_LIMIT_TIME_DAY:
     135        case Prefs :: ALT_SPEED_LIMIT_TIME_ENABLED:
    135136        case Prefs :: ALT_SPEED_LIMIT_TIME_END:
    136         case Prefs :: ALT_SPEED_LIMIT_TIME_ENABLED:
    137         case Prefs :: ALT_SPEED_LIMIT_TIME_DAY:
     137        case Prefs :: ALT_SPEED_LIMIT_UP:
     138        case Prefs :: BLOCKLIST_DATE:
    138139        case Prefs :: BLOCKLIST_ENABLED:
    139         case Prefs :: BLOCKLIST_DATE:
    140140        case Prefs :: DHT_ENABLED:
    141141        case Prefs :: DOWNLOAD_DIR:
     142        case Prefs :: DSPEED:
     143        case Prefs :: DSPEED_ENABLED:
    142144        case Prefs :: INCOMPLETE_DIR:
    143145        case Prefs :: INCOMPLETE_DIR_ENABLED:
     
    145147        case Prefs :: PEER_LIMIT_GLOBAL:
    146148        case Prefs :: PEER_LIMIT_TORRENT:
    147         case Prefs :: USPEED_ENABLED:
    148         case Prefs :: USPEED:
    149         case Prefs :: DSPEED_ENABLED:
    150         case Prefs :: DSPEED:
     149        case Prefs :: PEER_PORT:
     150        case Prefs :: PEER_PORT_RANDOM_ON_START:
     151        case Prefs :: PEX_ENABLED:
     152        case Prefs :: PORT_FORWARDING:
     153        case Prefs :: SCRIPT_TORRENT_DONE_ENABLED:
     154        case Prefs :: SCRIPT_TORRENT_DONE_FILENAME:
    151155        case Prefs :: START:
    152156        case Prefs :: TRASH_ORIGINAL:
    153         case Prefs :: PEX_ENABLED:
    154         case Prefs :: PORT_FORWARDING:
    155         case Prefs :: PEER_PORT:
    156         case Prefs :: PEER_PORT_RANDOM_ON_START:
     157        case Prefs :: USPEED:
     158        case Prefs :: USPEED_ENABLED:
    157159            sessionSet( myPrefs.keyStr(key), myPrefs.variant(key) );
    158160            break;
Note: See TracChangeset for help on using the changeset viewer.