diff --git a/cli/cli.c b/cli/cli.c index d125ea65f..835505be8 100644 --- a/cli/cli.c +++ b/cli/cli.c @@ -183,11 +183,11 @@ torrentCompletenessChanged( tr_torrent * torrent UNUSED, static int leftToScrape = 0; static void -scrapeDoneFunc( struct tr_handle * session UNUSED, - long response_code, - const void * response, - size_t response_byte_count, - void * host ) +scrapeDoneFunc( tr_session * session UNUSED, + long response_code, + const void * response, + size_t response_byte_count, + void * host ) { tr_benc top, *files; @@ -304,10 +304,10 @@ int main( int argc, char ** argv ) { - int error; - tr_handle * h; - tr_ctor * ctor; - tr_torrent * tor = NULL; + int error; + tr_session * h; + tr_ctor * ctor; + tr_torrent * tor = NULL; printf( "Transmission %s - http://www.transmissionbt.com/\n", LONG_VERSION_STRING ); diff --git a/daemon/daemon.c b/daemon/daemon.c index c0404b5d2..3428bb6aa 100644 --- a/daemon/daemon.c +++ b/daemon/daemon.c @@ -29,9 +29,9 @@ #define MY_NAME "transmission-daemon" -static int closing = FALSE; -static tr_handle * mySession; -static char * myConfigFilename = NULL; +static int closing = FALSE; +static tr_session * mySession = NULL; +static char * myConfigFilename = NULL; #define KEY_BLOCKLIST "blocklist-enabled" #define KEY_DOWNLOAD_DIR "download-dir" diff --git a/gtk/add-dialog.c b/gtk/add-dialog.c index 066b4550b..33375f8f0 100644 --- a/gtk/add-dialog.c +++ b/gtk/add-dialog.c @@ -168,7 +168,7 @@ sourceChanged( GtkFileChooserButton * b, int err = 0; int new_file = 0; tr_torrent * torrent; - tr_handle * handle = tr_core_handle( data->core ); + tr_session * session = tr_core_session( data->core ); if( filename && ( !data->filename || strcmp( filename, data->filename ) ) ) @@ -183,7 +183,7 @@ sourceChanged( GtkFileChooserButton * b, tr_ctorSetPaused( data->ctor, TR_FORCE, TRUE ); tr_ctorSetDeleteSource( data->ctor, FALSE ); - if( ( torrent = tr_torrentNew( handle, data->ctor, &err ) ) ) + if( ( torrent = tr_torrentNew( session, data->ctor, &err ) ) ) { removeOldTorrent( data ); data->gtor = tr_torrent_new_preexisting( torrent ); @@ -407,15 +407,16 @@ onAddDialogResponse( GtkDialog * dialog, if( response == GTK_RESPONSE_ACCEPT ) { - GtkWidget * w = gtk_file_chooser_get_extra_widget( - GTK_FILE_CHOOSER( dialog ) ); - const gboolean showOptions = gtk_toggle_button_get_active( - GTK_TOGGLE_BUTTON ( w ) ); + GtkFileChooser * chooser = GTK_FILE_CHOOSER( dialog ); + GtkWidget * w = gtk_file_chooser_get_extra_widget( chooser ); + GtkToggleButton * tb = GTK_TOGGLE_BUTTON( w ); + const gboolean showOptions = gtk_toggle_button_get_active( tb ); const pref_flag_t start = PREF_FLAG_DEFAULT; - const pref_flag_t prompt = - showOptions ? PREF_FLAG_TRUE : PREF_FLAG_FALSE; - GSList * l = gtk_file_chooser_get_filenames( - GTK_FILE_CHOOSER( dialog ) ); + const pref_flag_t prompt = showOptions + ? PREF_FLAG_TRUE + : PREF_FLAG_FALSE; + GSList * l = gtk_file_chooser_get_filenames( chooser ); + tr_core_add_list( core, l, start, prompt ); } diff --git a/gtk/blocklist.c b/gtk/blocklist.c index cf1055df6..9c55bd82c 100644 --- a/gtk/blocklist.c +++ b/gtk/blocklist.c @@ -139,7 +139,7 @@ blocklistThreadFunc( gpointer gcore ) if( ok ) { emitProgress( core, FALSE, _( "Parsing blocklist..." ) ); - rules = tr_blocklistSetContent( tr_core_handle( core ), filename2 ); + rules = tr_blocklistSetContent( tr_core_session( core ), filename2 ); } if( ok ) diff --git a/gtk/main.c b/gtk/main.c index f3514cab5..4dbed1b77 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -310,7 +310,7 @@ setupsighandlers( void ) } static tr_rpc_callback_status -onRPCChanged( tr_handle * handle UNUSED, +onRPCChanged( tr_session * session UNUSED, tr_rpc_callback_type type, struct tr_torrent * tor, void * gdata ) @@ -439,7 +439,7 @@ main( int argc, { GtkWindow * win; - tr_handle * h = tr_sessionInitFull( + tr_session * h = tr_sessionInitFull( configDir, "gtk", pref_string_get( PREF_KEY_DOWNLOAD_DIR ), @@ -501,7 +501,7 @@ main( int argc, static gboolean updateScheduledLimits( gpointer data ) { - tr_handle * tr = (tr_handle *) data; + tr_session * tr = data; static gboolean last_state = FALSE; gboolean in_sched_state = FALSE; @@ -641,9 +641,9 @@ appsetup( TrWindow * wind, updatemodel( cbdata ); /* start scheduled rate timer */ - updateScheduledLimits ( tr_core_handle( cbdata->core ) ); + updateScheduledLimits ( tr_core_session( cbdata->core ) ); g_timeout_add( 60 * 1000, updateScheduledLimits, - tr_core_handle( cbdata->core ) ); + tr_core_session( cbdata->core ) ); /* either show the window or iconify it */ if( !minimized ) @@ -1097,8 +1097,8 @@ prefschanged( TrCore * core UNUSED, const char * key, gpointer data ) { - struct cbdata * cbdata = data; - tr_handle * tr = tr_core_handle( cbdata->core ); + struct cbdata * cbdata = data; + tr_session * tr = tr_core_session( cbdata->core ); if( !strcmp( key, PREF_KEY_ENCRYPTION ) ) { @@ -1488,7 +1488,7 @@ doAction( const char * action_name, else if( !strcmp ( action_name, "new-torrent" ) ) { GtkWidget * w = make_meta_ui( GTK_WINDOW( data->wind ), - tr_core_handle( data->core ) ); + tr_core_session( data->core ) ); gtk_widget_show_all( w ); } else if( !strcmp( action_name, "remove-torrent" ) ) diff --git a/gtk/makemeta-ui.c b/gtk/makemeta-ui.c index e0d9d4254..ef67386a3 100644 --- a/gtk/makemeta-ui.c +++ b/gtk/makemeta-ui.c @@ -31,17 +31,17 @@ typedef struct { - GtkWidget * filename_entry; - GtkWidget * size_lb; - GtkWidget * pieces_lb; - GtkWidget * announce_list; - GtkWidget * comment_entry; - GtkWidget * progressbar; - GtkWidget * private_check; - GtkWidget * dialog; + GtkWidget * filename_entry; + GtkWidget * size_lb; + GtkWidget * pieces_lb; + GtkWidget * announce_list; + GtkWidget * comment_entry; + GtkWidget * progressbar; + GtkWidget * private_check; + GtkWidget * dialog; - tr_metainfo_builder * builder; - tr_handle * handle; + tr_metainfo_builder * builder; + tr_session * session; gboolean isBuilding; } @@ -303,7 +303,7 @@ onSourceActivated( GtkEditable * editable, if( ui->builder ) tr_metaInfoBuilderFree( ui->builder ); - ui->builder = tr_metaInfoBuilderCreate( ui->handle, filename ); + ui->builder = tr_metaInfoBuilderCreate( ui->session, filename ); refreshFromBuilder( ui ); } @@ -364,8 +364,8 @@ onChooseFileClicked( GtkButton * b, } GtkWidget* -make_meta_ui( GtkWindow * parent, - tr_handle * handle ) +make_meta_ui( GtkWindow * parent, + tr_session * session ) { int n; int row = 0; @@ -373,7 +373,7 @@ make_meta_ui( GtkWindow * parent, GtkBox * main_vbox; MakeMetaUI * ui = g_new0 ( MakeMetaUI, 1 ); - ui->handle = handle; + ui->session = session; d = gtk_dialog_new_with_buttons( _( "New Torrent" ), diff --git a/gtk/makemeta-ui.h b/gtk/makemeta-ui.h index e31d2a906..a47a290b4 100644 --- a/gtk/makemeta-ui.h +++ b/gtk/makemeta-ui.h @@ -16,7 +16,7 @@ #include #include -GtkWidget* make_meta_ui( GtkWindow * parent, - tr_handle * handle ); +GtkWidget* make_meta_ui( GtkWindow * parent, + tr_session * session ); #endif diff --git a/gtk/stats.c b/gtk/stats.c index abccc8064..b10a53516 100644 --- a/gtk/stats.c +++ b/gtk/stats.c @@ -61,8 +61,8 @@ updateStats( gpointer gdata ) struct stat_ui * ui = gdata; tr_session_stats one, all; - tr_sessionGetStats( tr_core_handle( ui->core ), &one ); - tr_sessionGetCumulativeStats( tr_core_handle( ui->core ), &all ); + tr_sessionGetStats( tr_core_session( ui->core ), &one ); + tr_sessionGetCumulativeStats( tr_core_session( ui->core ), &all ); setLabel( ui->one_up_lb, tr_strlsize( buf, one.uploadedBytes, sizeof( buf ) ) ); @@ -103,8 +103,7 @@ dialogResponse( GtkDialog * dialog, if( response == TR_RESPONSE_CLEAR ) { - tr_handle * handle = tr_core_handle( ui->core ); - tr_sessionClearStats( handle ); + tr_sessionClearStats( tr_core_session( ui->core ) ); updateStats( ui ); } diff --git a/gtk/tr-core.c b/gtk/tr-core.c index 7edb2f1f5..54990c97f 100644 --- a/gtk/tr-core.c +++ b/gtk/tr-core.c @@ -65,7 +65,7 @@ struct TrCorePrivate gboolean dbus_error; guint inhibit_cookie; GtkTreeModel * model; - tr_handle * handle; + tr_session * session; }; static void @@ -587,7 +587,7 @@ prefsChanged( TrCore * core, else if( !strcmp( key, PREF_KEY_MAX_PEERS_GLOBAL ) ) { const uint16_t val = pref_int_get( key ); - tr_sessionSetPeerLimit( tr_core_handle( core ), val ); + tr_sessionSetPeerLimit( tr_core_session( core ), val ); } else if( !strcmp( key, PREF_KEY_INHIBIT_HIBERNATION ) ) { @@ -674,11 +674,11 @@ tr_core_get_type( void ) **/ TrCore * -tr_core_new( tr_handle * h ) +tr_core_new( tr_session * session ) { TrCore * core = TR_CORE( g_object_new( TR_CORE_TYPE, NULL ) ); - core->priv->handle = h; + core->priv->session = session; /* init from prefs & listen to pref changes */ prefsChanged( core, PREF_KEY_SORT_MODE, NULL ); @@ -695,12 +695,12 @@ tr_core_new( tr_handle * h ) void tr_core_close( TrCore * core ) { - tr_handle * handle = tr_core_handle( core ); + tr_session * session = tr_core_session( core ); - if( handle ) + if( session ) { - core->priv->handle = NULL; - tr_sessionClose( handle ); + core->priv->session = NULL; + tr_sessionClose( session ); } } @@ -710,10 +710,10 @@ tr_core_model( TrCore * core ) return isDisposed( core ) ? NULL : core->priv->model; } -tr_handle * -tr_core_handle( TrCore * core ) +tr_session * +tr_core_session( TrCore * core ) { - return isDisposed( core ) ? NULL : core->priv->handle; + return isDisposed( core ) ? NULL : core->priv->session; } static gboolean @@ -745,7 +745,7 @@ tr_core_get_stats( const TrCore * core, if( !isDisposed( core ) ) { - tr_sessionGetSpeed( core->priv->handle, + tr_sessionGetSpeed( core->priv->session, &setme->clientDownloadSpeed, &setme->clientUploadSpeed ); @@ -815,14 +815,13 @@ tr_core_load( TrCore * self, tr_torrent ** torrents; tr_ctor * ctor; - ctor = tr_ctorNew( tr_core_handle( self ) ); + ctor = tr_ctorNew( tr_core_session( self ) ); if( forcePaused ) tr_ctorSetPaused( ctor, TR_FORCE, TRUE ); tr_ctorSetPeerLimit( ctor, TR_FALLBACK, pref_int_get( PREF_KEY_MAX_PEERS_PER_TORRENT ) ); - torrents = tr_sessionLoadTorrents ( tr_core_handle( - self ), ctor, &count ); + torrents = tr_sessionLoadTorrents ( tr_core_session( self ), ctor, &count ); for( i = 0; i < count; ++i ) tr_core_add_torrent( self, tr_torrent_new_preexisting( torrents[i] ) ); @@ -855,12 +854,12 @@ add_filename( TrCore * core, gboolean doStart, gboolean doPrompt ) { - tr_handle * handle = tr_core_handle( core ); + tr_session * session = tr_core_session( core ); - if( filename && handle ) + if( filename && session ) { int err; - tr_ctor * ctor = tr_ctorNew( handle ); + tr_ctor * ctor = tr_ctorNew( session ); tr_core_apply_defaults( ctor ); tr_ctorSetPaused( ctor, TR_FORCE, !doStart ); if( tr_ctorSetMetainfoFromFile( ctor, filename ) ) @@ -868,7 +867,7 @@ add_filename( TrCore * core, tr_core_errsig( core, TR_EINVALID, filename ); tr_ctorFree( ctor ); } - else if( ( err = tr_torrentParse( handle, ctor, NULL ) ) ) + else if( ( err = tr_torrentParse( session, ctor, NULL ) ) ) { /* don't complain about .torrent files in the watch directory that have already been added... that gets annoying, and we @@ -885,7 +884,7 @@ add_filename( TrCore * core, core )->promptsig, 0, ctor ); else { - tr_torrent * tor = tr_torrentNew( handle, ctor, &err ); + tr_torrent * tor = tr_torrentNew( session, ctor, &err ); if( err ) tr_core_errsig( core, err, filename ); else @@ -1193,7 +1192,7 @@ maybeInhibitHibernation( TrCore * core ) /* always allow hibernation when all the torrents are paused */ if( inhibit ) { gboolean active = FALSE; - tr_handle * session = tr_core_handle( core ); + tr_session * session = tr_core_session( core ); tr_torrent * tor = NULL; while(( tor = tr_torrentNext( session, tor ))) if(( active = ( tr_torrentGetActivity( tor ) != TR_STATUS_STOPPED ))) diff --git a/gtk/tr-core.h b/gtk/tr-core.h index 143751e03..32d223a4d 100644 --- a/gtk/tr-core.h +++ b/gtk/tr-core.h @@ -97,14 +97,14 @@ enum tr_core_err GType tr_core_get_type( void ); -TrCore * tr_core_new( tr_handle * ); +TrCore * tr_core_new( tr_session * ); void tr_core_close( TrCore* ); /* Return the model used without incrementing the reference count */ GtkTreeModel * tr_core_model( TrCore * self ); -tr_handle * tr_core_handle( TrCore * self ); +tr_session * tr_core_session( TrCore * self ); void tr_core_get_stats( const TrCore * core, struct core_stats * setme ); diff --git a/gtk/tr-prefs.c b/gtk/tr-prefs.c index 198299a74..528604feb 100644 --- a/gtk/tr-prefs.c +++ b/gtk/tr-prefs.c @@ -427,7 +427,7 @@ static void updateBlocklistText( GtkWidget * w, TrCore * core ) { - const int n = tr_blocklistGetRuleCount( tr_core_handle( core ) ); + const int n = tr_blocklistGetRuleCount( tr_core_session( core ) ); char buf[512]; g_snprintf( buf, sizeof( buf ), @@ -536,8 +536,8 @@ peerPage( GObject * core ) gtk_box_pack_start_defaults( GTK_BOX( h ), w ); b = gtr_button_new_from_stock( GTK_STOCK_REFRESH, _( "_Update" ) ); data->check = w; - g_object_set_data( G_OBJECT( b ), "handle", - tr_core_handle( TR_CORE( core ) ) ); + g_object_set_data( G_OBJECT( b ), "session", + tr_core_session( TR_CORE( core ) ) ); g_signal_connect( b, "clicked", G_CALLBACK( onUpdateBlocklistCB ), data ); gtk_box_pack_start( GTK_BOX( h ), b, FALSE, FALSE, 0 ); g_signal_connect( w, "toggled", G_CALLBACK( target_cb ), b ); @@ -1228,7 +1228,7 @@ struct test_port_data }; static void -testing_port_done( tr_handle * handle UNUSED, +testing_port_done( tr_session * session UNUSED, long response_code UNUSED, const void * response, size_t response_len, @@ -1257,15 +1257,15 @@ testing_port_begin( gpointer gdata ) GtkSpinButton * spin = g_object_get_data( G_OBJECT( data->label ), "tr-port-spin" ); - tr_handle * handle = g_object_get_data( G_OBJECT( + tr_session * session = g_object_get_data( G_OBJECT( data->label ), - "handle" ); + "session" ); const int port = gtk_spin_button_get_value_as_int( spin ); char url[256]; g_snprintf( url, sizeof( url ), "http://portcheck.transmissionbt.com/%d", port ); - tr_webRun( handle, url, NULL, testing_port_done, data ); + tr_webRun( session, url, NULL, testing_port_done, data ); } return FALSE; } @@ -1346,8 +1346,8 @@ networkPage( GObject * core ) hig_workarea_add_row( t, &row, _( "Listening _port:" ), h, w2 ); g_object_set_data( G_OBJECT( l ), "tr-port-spin", w2 ); - g_object_set_data( G_OBJECT( l ), "handle", - tr_core_handle( TR_CORE( core ) ) ); + g_object_set_data( G_OBJECT( l ), "session", + tr_core_session( TR_CORE( core ) ) ); data->id = g_signal_connect( TR_CORE( core ), "prefs-changed", G_CALLBACK( onCorePrefsChanged ), data ); diff --git a/gtk/tr-torrent.c b/gtk/tr-torrent.c index 6d4f6236e..e243e97fd 100644 --- a/gtk/tr-torrent.c +++ b/gtk/tr-torrent.c @@ -187,9 +187,9 @@ tr_torrent_new_preexisting( tr_torrent * tor ) } TrTorrent * -tr_torrent_new_ctor( tr_handle * handle, - tr_ctor * ctor, - char ** err ) +tr_torrent_new_ctor( tr_session * session, + tr_ctor * ctor, + char ** err ) { tr_torrent * tor; int errcode; @@ -202,11 +202,11 @@ tr_torrent_new_ctor( tr_handle * handle, * doesn't have any concept of the glib trash API */ tr_ctorGetDeleteSource( ctor, &doTrash ); tr_ctorSetDeleteSource( ctor, FALSE ); - tor = tr_torrentNew( handle, ctor, &errcode ); + tor = tr_torrentNew( session, ctor, &errcode ); if( tor && doTrash ) { - const char * config = tr_sessionGetConfigDir( handle ); + const char * config = tr_sessionGetConfigDir( session ); const char * source = tr_ctorGetSourceFile( ctor ); const int is_internal = source && ( strstr( source, config ) == source ); diff --git a/gtk/tr-torrent.h b/gtk/tr-torrent.h index f98d230de..39c618497 100644 --- a/gtk/tr-torrent.h +++ b/gtk/tr-torrent.h @@ -73,9 +73,9 @@ void tr_torrent_open_folder( TrTorrent * tor ); TrTorrent * tr_torrent_new_preexisting( tr_torrent * tor ); -TrTorrent * tr_torrent_new_ctor( tr_handle * handle, - tr_ctor * ctor, - char ** err ); +TrTorrent * tr_torrent_new_ctor( tr_session * session, + tr_ctor * ctor, + char ** err ); void tr_torrent_set_remove_flag( TrTorrent *, gboolean ); diff --git a/gtk/tr-window.c b/gtk/tr-window.c index 0d940336b..3608617fe 100644 --- a/gtk/tr-window.c +++ b/gtk/tr-window.c @@ -725,19 +725,19 @@ updateStats( PrivateData * p ) const char * pch; char up[32], down[32], ratio[32], buf[128]; struct tr_session_stats stats; - tr_handle * handle = tr_core_handle( p->core ); + tr_session * session = tr_core_session( p->core ); /* update the stats */ pch = pref_string_get( PREF_KEY_STATUSBAR_STATS ); if( !strcmp( pch, "session-ratio" ) ) { - tr_sessionGetStats( handle, &stats ); + tr_sessionGetStats( session, &stats ); tr_strlratio( ratio, stats.ratio, sizeof( ratio ) ); g_snprintf( buf, sizeof( buf ), _( "Ratio: %s" ), ratio ); } else if( !strcmp( pch, "session-transfer" ) ) { - tr_sessionGetStats( handle, &stats ); + tr_sessionGetStats( session, &stats ); tr_strlsize( up, stats.uploadedBytes, sizeof( up ) ); tr_strlsize( down, stats.downloadedBytes, sizeof( down ) ); /* Translators: do not translate the "size|" disambiguation prefix. @@ -748,7 +748,7 @@ updateStats( PrivateData * p ) } else if( !strcmp( pch, "total-transfer" ) ) { - tr_sessionGetCumulativeStats( handle, &stats ); + tr_sessionGetCumulativeStats( session, &stats ); tr_strlsize( up, stats.uploadedBytes, sizeof( up ) ); tr_strlsize( down, stats.downloadedBytes, sizeof( down ) ); /* Translators: do not translate the "size|" disambiguation prefix. @@ -759,7 +759,7 @@ updateStats( PrivateData * p ) } else /* default is total-ratio */ { - tr_sessionGetCumulativeStats( handle, &stats ); + tr_sessionGetCumulativeStats( session, &stats ); tr_strlratio( ratio, stats.ratio, sizeof( ratio ) ); g_snprintf( buf, sizeof( buf ), _( "Ratio: %s" ), ratio ); } @@ -771,9 +771,9 @@ updateSpeeds( PrivateData * p ) { char buf[128]; float u, d; - tr_handle * handle = tr_core_handle( p->core ); + tr_session * session = tr_core_session( p->core ); - tr_sessionGetSpeed( handle, &d, &u ); + tr_sessionGetSpeed( session, &d, &u ); tr_strlspeed( buf, d, sizeof( buf ) ); gtk_label_set_text( GTK_LABEL( p->dl_lb ), buf ); tr_strlspeed( buf, u, sizeof( buf ) ); @@ -785,7 +785,7 @@ tr_window_update( TrWindow * self ) { PrivateData * p = get_private_data( self ); - if( p && p->core && tr_core_handle( p->core ) ) + if( p && p->core && tr_core_session( p->core ) ) { updateSpeeds( p ); updateTorrentCount( p );