1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 17:47:37 +00:00

(trunk libT) #2096 "magnet links" -- add a callback for clients to know when a magnet torrent's metainfo is finished downloading.

This commit is contained in:
Charles Kerr 2009-11-26 17:58:44 +00:00
parent 7d65242e71
commit cebcc3b6ef
3 changed files with 56 additions and 10 deletions

View file

@ -614,10 +614,14 @@ torrentInitFromInfo( tr_torrent * tor )
tor->completeness = tr_cpGetStatus( &tor->completion ); tor->completeness = tr_cpGetStatus( &tor->completion );
} }
static void tr_torrentFireMetadataCompleted( tr_torrent * tor );
void void
tr_torrentGotNewInfoDict( tr_torrent * tor ) tr_torrentGotNewInfoDict( tr_torrent * tor )
{ {
torrentInitFromInfo( tor ); torrentInitFromInfo( tor );
tr_torrentFireMetadataCompleted( tor );
} }
static void static void
@ -1617,6 +1621,12 @@ tr_torrentSetCompletenessCallback( tr_torrent * tor,
tor->completeness_func_user_data = user_data; tor->completeness_func_user_data = user_data;
} }
void
tr_torrentClearCompletenessCallback( tr_torrent * torrent )
{
tr_torrentSetCompletenessCallback( torrent, NULL, NULL );
}
void void
tr_torrentSetRatioLimitHitCallback( tr_torrent * tor, tr_torrentSetRatioLimitHitCallback( tr_torrent * tor,
tr_torrent_ratio_limit_hit_func func, tr_torrent_ratio_limit_hit_func func,
@ -1628,12 +1638,6 @@ tr_torrentSetRatioLimitHitCallback( tr_torrent * tor,
tor->ratio_limit_hit_func_user_data = user_data; tor->ratio_limit_hit_func_user_data = user_data;
} }
void
tr_torrentClearCompletenessCallback( tr_torrent * torrent )
{
tr_torrentSetCompletenessCallback( torrent, NULL, NULL );
}
void void
tr_torrentClearRatioLimitHitCallback( tr_torrent * torrent ) tr_torrentClearRatioLimitHitCallback( tr_torrent * torrent )
{ {
@ -1687,6 +1691,31 @@ tr_torrentRecheckCompleteness( tr_torrent * tor )
tr_torrentUnlock( tor ); tr_torrentUnlock( tor );
} }
/***
****
***/
static void
tr_torrentFireMetadataCompleted( tr_torrent * tor )
{
assert( tr_isTorrent( tor ) );
if( tor->metadata_func )
tor->metadata_func( tor, tor->metadata_func_user_data );
}
void
tr_torrentSetMetadataCallback( tr_torrent * tor,
tr_torrent_metadata_func func,
void * user_data )
{
assert( tr_isTorrent( tor ) );
tor->metadata_func = func;
tor->metadata_func_user_data = user_data;
}
/** /**
*** File priorities *** File priorities
**/ **/

View file

@ -219,6 +219,9 @@ struct tr_torrent
time_t startDate; time_t startDate;
time_t anyDate; time_t anyDate;
tr_torrent_metadata_func * metadata_func;
void * metadata_func_user_data;
tr_torrent_completeness_func * completeness_func; tr_torrent_completeness_func * completeness_func;
void * completeness_func_user_data; void * completeness_func_user_data;

View file

@ -1255,6 +1255,20 @@ void tr_torrentSetCompletenessCallback(
void tr_torrentClearCompletenessCallback( tr_torrent * torrent ); void tr_torrentClearCompletenessCallback( tr_torrent * torrent );
typedef void ( tr_torrent_metadata_func )( tr_torrent * torrent,
void * user_data );
/**
* Register to be notified whenever a torrent changes from
* having incomplete metadata to having complete metadata.
* This happens when a magnet link finishes downloading
* metadata from its peers.
*/
void tr_torrentSetMetadataCallback (
tr_torrent * tor,
tr_torrent_metadata_func func,
void * user_data );
/** /**
* Register to be notified whenever a torrent's ratio limit * Register to be notified whenever a torrent's ratio limit
* has been hit. This will be called when the torrent's * has been hit. This will be called when the torrent's