]> granicus.if.org Git - transmission/commitdiff
(trunk) make tr_torrentName() a public function.
authorJordan Lee <jordan@transmissionbt.com>
Tue, 15 Feb 2011 15:18:51 +0000 (15:18 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Tue, 15 Feb 2011 15:18:51 +0000 (15:18 +0000)
This has been a private function in libtransmission for awhile now but it makes more sense as a public function.

gtk/details.c
gtk/file-list.c
gtk/notify.c
gtk/relocate.c
gtk/torrent-cell-renderer.c
gtk/tr-core.c
gtk/tr-torrent.c
libtransmission/rpcimpl.c
libtransmission/torrent.c
libtransmission/torrent.h
libtransmission/transmission.h

index b0dd7871048c1da589401de3c2b97d5b248cf741..c043bfc6847f1c998892ae00c60e7284b7cb8f8a 100644 (file)
@@ -2024,7 +2024,7 @@ refreshTracker( struct DetailsImpl * di, tr_torrent ** torrents, int n )
     for( i=0; i<n; ++i ) {
         int j;
         const tr_torrent * tor = torrents[i];
-        const char * summary_name = n>1 ? tr_torrentInfo( tor )->name : NULL;
+        const char * summary_name = n>1 ? tr_torrentName( tor ) : NULL;
         for( j=0; j<statCount[i]; ++j ) {
             const tr_tracker_stat * st = &stats[i][j];
             char * summary = buildTrackerSummary( summary_name, st, showScrape );
@@ -2189,7 +2189,7 @@ on_edit_trackers( GtkButton * button, gpointer data )
         GtkWindow * win = GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET( button ) ) );
         char * text = get_editable_tracker_list( tor );
         const int torrent_id = tr_torrentId( tor );
-        char * title = g_strdup_printf( _( "%s - Edit Trackers" ), tr_torrentInfo( tor )->name );
+        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,
index 2dbd6c99754b6c950f58d523247fee1a41922057..0484698444cbb7b484008da6aaaf9e6a5dc20183 100644 (file)
@@ -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 );
index 2d046b0085eb8a053779a4b0b4c9aa2b9703b8b8..1e6bb74e877a88e125dbe00a4132c0669d60b392 100644 (file)
@@ -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
index 9eeecd47e7bce2e8089142a6cdd143aca39be2fd..fa1b98baf75713de64bc1fab206b501d571e74f7 100644 (file)
@@ -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 );
 }
index e6556d9522288ebad0a5d809c1c7358abe04204f..395101fedb73ec080463ec5c614deeb125ee35c0 100644 (file)
@@ -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 );
index 5e63d055568fff88559d0f451970e6649a6b808e..4e5015a2b2eaa3ad814023abac235cc43c5ba4d9 100644 (file)
@@ -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... */
index 849ae1fec56811ee74e431a6c9d61928d58128a6..2458525a894671022aae7197456f95153fc4995f 100644 (file)
@@ -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 );
         }
index 420ca1768f2ebb300c1d1257bef97396b05f0051..f09ee4cd50e106dc64dfe98b14ae42f34e7b10cb 100644 (file)
@@ -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" ) )
index b6032531dc9c8dda333cc4909555bc928b61aba8..522f664a78624bac16f59871835ee7f694d2c783 100644 (file)
 ****
 ***/
 
+const char *
+tr_torrentName( const tr_torrent * tor )
+{
+    assert( tr_isTorrent( tor ) );
+
+    return tor->info.name;
+}
+
 int
 tr_torrentId( const tr_torrent * tor )
 {
index 9c8bcce5364fdc49daab249d234698885af40b9f..923799625c4b9f83f580ad93af9a845090e41c6a 100644 (file)
@@ -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 );
 
 /**
index 2aa9b96d866fc620e0de9d87c517b67d2fed344a..7ac2ca0f58092285d2fed1392995f983d6430d2c 100644 (file)
@@ -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