(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.
This commit is contained in:
Jordan Lee 2011-02-15 15:18:51 +00:00
parent f8f61d89d5
commit 72f9ab91fa
11 changed files with 34 additions and 29 deletions

View 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,

View 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 );

View 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

View 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 );
}

View 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 );

View 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... */

View 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 );
}

View 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" ) )

View File

@ -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 )
{

View 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 );
/**

View 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