mirror of
https://github.com/transmission/transmission
synced 2024-12-25 01:03:01 +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:
parent
7d65242e71
commit
cebcc3b6ef
3 changed files with 56 additions and 10 deletions
|
@ -614,10 +614,14 @@ torrentInitFromInfo( tr_torrent * tor )
|
|||
tor->completeness = tr_cpGetStatus( &tor->completion );
|
||||
}
|
||||
|
||||
static void tr_torrentFireMetadataCompleted( tr_torrent * tor );
|
||||
|
||||
void
|
||||
tr_torrentGotNewInfoDict( tr_torrent * tor )
|
||||
{
|
||||
torrentInitFromInfo( tor );
|
||||
|
||||
tr_torrentFireMetadataCompleted( tor );
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1617,6 +1621,12 @@ tr_torrentSetCompletenessCallback( tr_torrent * tor,
|
|||
tor->completeness_func_user_data = user_data;
|
||||
}
|
||||
|
||||
void
|
||||
tr_torrentClearCompletenessCallback( tr_torrent * torrent )
|
||||
{
|
||||
tr_torrentSetCompletenessCallback( torrent, NULL, NULL );
|
||||
}
|
||||
|
||||
void
|
||||
tr_torrentSetRatioLimitHitCallback( tr_torrent * tor,
|
||||
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;
|
||||
}
|
||||
|
||||
void
|
||||
tr_torrentClearCompletenessCallback( tr_torrent * torrent )
|
||||
{
|
||||
tr_torrentSetCompletenessCallback( torrent, NULL, NULL );
|
||||
}
|
||||
|
||||
void
|
||||
tr_torrentClearRatioLimitHitCallback( tr_torrent * torrent )
|
||||
{
|
||||
|
@ -1687,6 +1691,31 @@ tr_torrentRecheckCompleteness( tr_torrent * 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
|
||||
**/
|
||||
|
|
|
@ -219,11 +219,14 @@ struct tr_torrent
|
|||
time_t startDate;
|
||||
time_t anyDate;
|
||||
|
||||
tr_torrent_completeness_func * completeness_func;
|
||||
void * completeness_func_user_data;
|
||||
tr_torrent_metadata_func * metadata_func;
|
||||
void * metadata_func_user_data;
|
||||
|
||||
tr_torrent_ratio_limit_hit_func * ratio_limit_hit_func;
|
||||
void * ratio_limit_hit_func_user_data;
|
||||
tr_torrent_completeness_func * completeness_func;
|
||||
void * completeness_func_user_data;
|
||||
|
||||
tr_torrent_ratio_limit_hit_func * ratio_limit_hit_func;
|
||||
void * ratio_limit_hit_func_user_data;
|
||||
|
||||
tr_bool isRunning;
|
||||
tr_bool isDeleting;
|
||||
|
|
|
@ -1255,6 +1255,20 @@ void tr_torrentSetCompletenessCallback(
|
|||
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
|
||||
* has been hit. This will be called when the torrent's
|
||||
|
|
Loading…
Reference in a new issue