This has been a private function in libtransmission for awhile now but it makes more sense as a public function.
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 );
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,
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,
/* 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 );
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
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 );
}
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 );
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 );
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 );
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 );
}
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;
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,
-1 );
if( doNotify )
- gtr_notify_added( inf->name );
+ gtr_notify_added( name );
/* cleanup */
g_object_unref( G_OBJECT( gtor ) );
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... */
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 );
}
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" ) )
****
***/
+const char *
+tr_torrentName( const tr_torrent * tor )
+{
+ assert( tr_isTorrent( tor ) );
+
+ return tor->info.name;
+}
+
int
tr_torrentId( const 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 );
/**
/** @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