Changeset 2463


Ignore:
Timestamp:
Jul 23, 2007, 3:03:45 AM (15 years ago)
Author:
charles
Message:

use tr_loadTorrents() during startup.

Location:
trunk/gtk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/main.c

    r2444 r2463  
    413413
    414414    /* add torrents from command-line and saved state */
    415     if( NULL != state )
    416     {
    417         tr_core_load( cbdata->core, state, paused );
    418     }
     415    tr_core_load( cbdata->core, paused );
     416
    419417    if( NULL != args )
    420418    {
     
    736734    {
    737735        PREF_ID_PORT,
     736        PREF_ID_DOWNLIMIT,
    738737        PREF_ID_USEDOWNLIMIT,
     738        PREF_ID_UPLIMIT,
    739739        PREF_ID_USEUPLIMIT,
    740740        PREF_ID_NAT,
     
    753753prefschanged( TrCore * core SHUTUP, int id, gpointer data )
    754754{
    755     struct cbdata * cbdata;
    756     tr_handle_t   * tr;
     755    struct cbdata * cbdata = data;
     756    tr_handle_t   * tr     = tr_core_handle( cbdata->core );
    757757    gboolean        boolval;
    758 
    759     cbdata = data;
    760     tr     = tr_core_handle( cbdata->core );
    761758
    762759    switch( id )
  • trunk/gtk/tr_core.c

    r2425 r2463  
    3232#include <libtransmission/bencode.h>
    3333#include <libtransmission/transmission.h>
     34#include <libtransmission/utils.h>
    3435
    3536#include "conf.h"
     
    402403
    403404int
    404 tr_core_load( TrCore * self, const benc_val_t * state, gboolean forcepaused )
    405 {
     405tr_core_load( TrCore * self, gboolean forcepaused )
     406{
     407    int i;
     408    int flags;
    406409    int count = 0;
    407 
    408     TR_IS_CORE( self );
    409 
    410     if( TYPE_LIST == state->type )
    411     {
    412         int ii;
    413         for( ii = 0; ii < state->val.l.count; ii++ )
    414         {
    415             char * errstr = NULL;
    416             TrTorrent * tor = tr_torrent_new_with_state( self->handle,
    417                                                      state->val.l.vals + ii,
    418                                                      forcepaused, &errstr );
    419             if( NULL == tor )
    420             {
    421                 tr_core_errsig( self, TR_CORE_ERR_ADD_TORRENT, errstr );
    422                 g_free( errstr );
    423             }
    424             else
    425             {
    426                 g_assert( NULL == errstr );
    427                 tr_core_insert( self, tor );
    428                 count++;
    429             }
    430         }
    431     }
     410    tr_torrent_t ** torrents;
     411    const char * destination;
     412
     413    TR_IS_CORE( self );
     414
     415    destination = getdownloaddir( );
     416
     417    flags = 0;
     418    if( forcepaused )
     419         flags |= TR_FLAG_PAUSED;
     420
     421    torrents = tr_loadTorrents ( self->handle, destination, flags, &count );
     422    for( i=0; i<count; ++i )
     423        tr_core_insert( self, tr_torrent_new_preexisting( torrents[i] ) );
     424    tr_free( torrents );
    432425
    433426    return count;
     
    560553    gtk_tree_model_get( self->model, iter, MC_TORRENT, &tor, -1 );
    561554    gtk_list_store_remove( GTK_LIST_STORE( self->model ), iter );
    562 
    563     if( TR_FLAG_SAVE & tr_torrent_info( tor )->flags )
    564         tr_torrentRemoveSaved( tr_torrent_handle( tor ) );
     555    tr_torrentRemoveSaved( tr_torrent_handle( tor ) );
    565556
    566557    tr_torrent_sever( tor );
  • trunk/gtk/tr_core.h

    r2400 r2463  
    125125   or more "error" signals with TR_CORE_ERR_ADD_TORRENT */
    126126int
    127 tr_core_load( TrCore * self, const benc_val_t * state, gboolean forcepaused );
     127tr_core_load( TrCore * self, gboolean forcepaused );
    128128
    129129/* Any the tr_core_add functions below may trigger an "error" signal
  • trunk/gtk/tr_torrent.c

    r2441 r2463  
    292292}
    293293
     294TrTorrent*
     295tr_torrent_new_preexisting( tr_torrent_t * tor )
     296{
     297    return maketorrent( tor );
     298}
     299
     300
    294301TrTorrent *
    295302tr_torrent_new( tr_handle_t * back, const char *torrent, const char *dir,
  • trunk/gtk/tr_torrent.h

    r2441 r2463  
    100100
    101101TrTorrent *
     102tr_torrent_new_preexisting( tr_torrent_t * tor );
     103
     104TrTorrent *
    102105tr_torrent_new( tr_handle_t * handle, const char * path, const char * dir,
    103106                enum tr_torrent_action act, gboolean paused, char ** err);
Note: See TracChangeset for help on using the changeset viewer.