From: Jordan Lee Date: Tue, 15 Feb 2011 15:18:51 +0000 (+0000) Subject: (trunk) make tr_torrentName() a public function. X-Git-Tag: 2.30b1~364 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=72f9ab91fa4320fa398cb86b5b15f4c53ad4fc44;p=transmission (trunk) make tr_torrentName() a public function. This has been a private function in libtransmission for awhile now but it makes more sense as a public function. --- diff --git a/gtk/details.c b/gtk/details.c index b0dd78710..c043bfc68 100644 --- a/gtk/details.c +++ b/gtk/details.c @@ -2024,7 +2024,7 @@ refreshTracker( struct DetailsImpl * di, tr_torrent ** torrents, int n ) for( i=0; i1 ? tr_torrentInfo( tor )->name : NULL; + const char * summary_name = n>1 ? tr_torrentName( tor ) : NULL; for( j=0; jname ); + char * title = g_strdup_printf( _( "%s - Edit Trackers" ), tr_torrentName( tor ) ); d = gtk_dialog_new_with_buttons( title, win, GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, @@ -2299,7 +2299,7 @@ on_tracker_list_add_button_clicked( GtkButton * button UNUSED, gpointer gdi ) GtkWidget * e; GtkWidget * t; GtkWidget * w; - char * title = g_strdup_printf( _( "%s - Add Tracker" ), tr_torrentInfo( tor )->name ); + char * title = g_strdup_printf( _( "%s - Add Tracker" ), tr_torrentName( tor ) ); w = gtk_dialog_new_with_buttons( title, GTK_WINDOW( di->dialog ), GTK_DIALOG_DESTROY_WITH_PARENT, diff --git a/gtk/file-list.c b/gtk/file-list.c index 2dbd6c997..048469844 100644 --- a/gtk/file-list.c +++ b/gtk/file-list.c @@ -539,7 +539,7 @@ gtr_file_list_set_torrent( GtkWidget * w, int torrentId ) /* build a GNode tree of the files */ root_data = g_new0( struct row_struct, 1 ); - root_data->name = g_strdup( inf->name ); + root_data->name = g_strdup( tr_torrentName( tor ) ); root_data->index = -1; root_data->length = 0; root = g_node_new( root_data ); diff --git a/gtk/notify.c b/gtk/notify.c index 2d046b008..1e6bb74e8 100644 --- a/gtk/notify.c +++ b/gtk/notify.c @@ -129,7 +129,7 @@ gtr_notify_send( TrTorrent *tor ) NotifyNotification * n; n = notify_notification_new( _( "Torrent Complete" ), - info->name, NULL + tr_torrentName( tr_torrent_handle( tor ) ), NULL /* the fourth argument was removed in libnotify 0.7.0 */ #if !defined(NOTIFY_VERSION_MINOR) || (NOTIFY_VERSION_MAJOR == 0 && NOTIFY_VERSION_MINOR < 7) , NULL diff --git a/gtk/relocate.c b/gtk/relocate.c index 9eeecd47e..fa1b98baf 100644 --- a/gtk/relocate.c +++ b/gtk/relocate.c @@ -61,7 +61,7 @@ startMovingNextTorrent( struct relocate_dialog_data * data ) data->torrent_ids = g_slist_delete_link( data->torrent_ids, data->torrent_ids ); - str = g_strdup_printf( _( "Moving \"%s\"" ), tr_torrentInfo(tor)->name ); + str = g_strdup_printf( _( "Moving \"%s\"" ), tr_torrentName( tor ) ); gtk_message_dialog_set_markup( GTK_MESSAGE_DIALOG( data->message_dialog ), str ); g_free( str ); } diff --git a/gtk/torrent-cell-renderer.c b/gtk/torrent-cell-renderer.c index e6556d952..395101fed 100644 --- a/gtk/torrent-cell-renderer.c +++ b/gtk/torrent-cell-renderer.c @@ -387,7 +387,7 @@ get_size_compact( TorrentCellRenderer * cell, const tr_stat * st = tr_torrentStatCached( (tr_torrent*)tor ); icon = get_icon( tor, COMPACT_ICON_SIZE, widget ); - name = tr_torrentInfo( tor )->name; + name = tr_torrentName( tor ); status = getShortStatusString( tor, st, p->upload_speed_KBps, p->download_speed_KBps ); gtr_cell_renderer_get_padding( GTK_CELL_RENDERER( cell ), &xpad, &ypad ); @@ -445,7 +445,7 @@ get_size_full( TorrentCellRenderer * cell, const tr_info * inf = tr_torrentInfo( tor ); icon = get_icon( tor, FULL_ICON_SIZE, widget ); - name = inf->name; + name = tr_torrentName( tor ); status = getStatusString( tor, st, p->upload_speed_KBps, p->download_speed_KBps ); progress = getProgressString( tor, inf, st ); gtr_cell_renderer_get_padding( GTK_CELL_RENDERER( cell ), &xpad, &ypad ); @@ -563,7 +563,7 @@ render_compact( TorrentCellRenderer * cell, const gboolean sensitive = active || st->error; icon = get_icon( tor, COMPACT_ICON_SIZE, widget ); - name = tr_torrentInfo( tor )->name; + name = tr_torrentName( tor ); status = getShortStatusString( tor, st, p->upload_speed_KBps, p->download_speed_KBps ); gtr_cell_renderer_get_padding( GTK_CELL_RENDERER( cell ), &xpad, &ypad ); get_text_color( widget, st, &text_color ); @@ -640,7 +640,7 @@ render_full( TorrentCellRenderer * cell, const gboolean sensitive = active || st->error; icon = get_icon( tor, FULL_ICON_SIZE, widget ); - name = inf->name; + name = tr_torrentName( tor ); status = getStatusString( tor, st, p->upload_speed_KBps, p->download_speed_KBps ); progress = getProgressString( tor, inf, st ); gtr_cell_renderer_get_padding( GTK_CELL_RENDERER( cell ), &xpad, &ypad ); diff --git a/gtk/tr-core.c b/gtk/tr-core.c index 5e63d0555..4e5015a2b 100644 --- a/gtk/tr-core.c +++ b/gtk/tr-core.c @@ -866,9 +866,11 @@ tr_core_close( TrCore * core ) } static char* -get_collated_name( const tr_info * inf ) +get_collated_name( const tr_torrent * tor ) { - char * down = g_utf8_strdown( inf->name ? inf->name : "", -1 ); + const char * name = tr_torrentName( tor ); + const tr_info * inf = tr_torrentInfo( tor ); + char * down = g_utf8_strdown( name ? name : "", -1 ); char * collated = g_strdup_printf( "%s\t%s", down, inf->hashString ); g_free( down ); return collated; @@ -877,16 +879,16 @@ get_collated_name( const tr_info * inf ) void tr_core_add_torrent( TrCore * self, TrTorrent * gtor, gboolean doNotify ) { - const tr_info * inf = tr_torrent_info( gtor ); const tr_stat * st = tr_torrent_stat( gtor ); tr_torrent * tor = tr_torrent_handle( gtor ); - char * collated = get_collated_name( inf ); + const char * name = tr_torrentName( tor ); + char * collated = get_collated_name( tor ); char * trackers = torrentTrackerString( tor ); GtkListStore * store = GTK_LIST_STORE( tr_core_raw_model( self ) ); GtkTreeIter unused; gtk_list_store_insert_with_values( store, &unused, 0, - MC_NAME, inf->name, + MC_NAME, name, MC_NAME_COLLATED, collated, MC_TORRENT, gtor, MC_TORRENT_RAW, tor, @@ -901,7 +903,7 @@ tr_core_add_torrent( TrCore * self, TrTorrent * gtor, gboolean doNotify ) -1 ); if( doNotify ) - gtr_notify_added( inf->name ); + gtr_notify_added( name ); /* cleanup */ g_object_unref( G_OBJECT( gtor ) ); @@ -1336,7 +1338,7 @@ update_foreach( GtkTreeModel * model, newRecheckProgress = st->recheckProgress; newActivePeerCount = st->peersSendingToUs + st->peersGettingFromUs + st->webseedsSendingToUs; newError = st->error; - newCollatedName = get_collated_name( tr_torrent_info( gtor ) ); + newCollatedName = get_collated_name( tor ); /* updating the model triggers off resort/refresh, so don't do it unless something's actually changed... */ diff --git a/gtk/tr-torrent.c b/gtk/tr-torrent.c index 849ae1fec..2458525a8 100644 --- a/gtk/tr-torrent.c +++ b/gtk/tr-torrent.c @@ -227,13 +227,12 @@ tr_torrent_open_folder( TrTorrent * gtor ) if( tor != NULL ) { - const tr_info * info = tr_torrent_info( gtor ); - const gboolean single = info->fileCount == 1; + const gboolean single = tr_torrent_info( gtor )->fileCount == 1; const char * currentDir = tr_torrentGetCurrentDir( tor ); if( single ) gtr_open_file( currentDir ); else { - char * path = g_build_filename( currentDir, info->name, NULL ); + char * path = g_build_filename( currentDir, tr_torrentName( tor ), NULL ); gtr_open_file( path ); g_free( path ); } diff --git a/libtransmission/rpcimpl.c b/libtransmission/rpcimpl.c index 420ca1768..f09ee4cd5 100644 --- a/libtransmission/rpcimpl.c +++ b/libtransmission/rpcimpl.c @@ -533,7 +533,7 @@ addField( const tr_torrent * tor, tr_benc * d, const char * key ) else if( tr_streq( key, keylen, "metadataPercentComplete" ) ) tr_bencDictAddReal( d, key, st->metadataPercentComplete ); else if( tr_streq( key, keylen, "name" ) ) - tr_bencDictAddStr( d, key, inf->name ); + tr_bencDictAddStr( d, key, tr_torrentName( tor ) ); else if( tr_streq( key, keylen, "percentDone" ) ) tr_bencDictAddReal( d, key, st->percentDone ); else if( tr_streq( key, keylen, "peer-limit" ) ) diff --git a/libtransmission/torrent.c b/libtransmission/torrent.c index b6032531d..522f664a7 100644 --- a/libtransmission/torrent.c +++ b/libtransmission/torrent.c @@ -68,6 +68,14 @@ **** ***/ +const char * +tr_torrentName( const tr_torrent * tor ) +{ + assert( tr_isTorrent( tor ) ); + + return tor->info.name; +} + int tr_torrentId( const tr_torrent * tor ) { diff --git a/libtransmission/torrent.h b/libtransmission/torrent.h index 9c8bcce53..923799625 100644 --- a/libtransmission/torrent.h +++ b/libtransmission/torrent.h @@ -372,14 +372,6 @@ void tr_torrentSetDirty( tr_torrent * tor ) tor->isDirty = TRUE; } -static inline -const char * tr_torrentName( const tr_torrent * tor ) -{ - assert( tr_isTorrent( tor ) ); - - return tor->info.name; -} - uint32_t tr_getBlockSize( uint32_t pieceSize ); /** diff --git a/libtransmission/transmission.h b/libtransmission/transmission.h index 2aa9b96d8..7ac2ca0f5 100644 --- a/libtransmission/transmission.h +++ b/libtransmission/transmission.h @@ -1088,6 +1088,10 @@ tr_torrent* tr_torrentFindFromHash( tr_session * session, const uint8_t * hash ) /** @brief Convenience function similar to tr_torrentFindFromHash() */ tr_torrent* tr_torrentFindFromMagnetLink( tr_session * session, const char * link ); +/** + * @return this torrent's name. + */ +const char* tr_torrentName( const tr_torrent * ); /** * @brief find the location of a torrent's file by looking with and without