mirror of
https://github.com/transmission/transmission
synced 2024-12-25 01:03:01 +00:00
(trunk libT) #2929 "persistent tracker error messages in main window" -- experimental fix
This commit is contained in:
parent
8a83a4bf79
commit
5ca8d41816
4 changed files with 36 additions and 8 deletions
|
@ -581,7 +581,7 @@ getTier( tr_announcer * announcer, int torrentId, int tierId )
|
|||
**** PUBLISH
|
||||
***/
|
||||
|
||||
static const tr_tracker_event emptyEvent = { 0, NULL, NULL, 0, 0 };
|
||||
static const tr_tracker_event emptyEvent = { 0, NULL, NULL, NULL, 0, 0 };
|
||||
|
||||
static void
|
||||
publishMessage( tr_tier * tier, const char * msg, int type )
|
||||
|
@ -592,6 +592,7 @@ publishMessage( tr_tier * tier, const char * msg, int type )
|
|||
tr_tracker_event event = emptyEvent;
|
||||
event.messageType = type;
|
||||
event.text = msg;
|
||||
event.tracker = tier->currentTracker ? tier->currentTracker->announce : NULL;
|
||||
tr_publisherPublish( &tiers->publisher, tier, &event );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ typedef struct
|
|||
|
||||
/* for TR_TRACKER_WARNING and TR_TRACKER_ERROR */
|
||||
const char * text;
|
||||
const char * tracker;
|
||||
|
||||
/* for TR_TRACKER_PEERS */
|
||||
const uint8_t * compact;
|
||||
|
|
|
@ -347,10 +347,21 @@ tr_torrentSetLocalError( tr_torrent * tor, const char * fmt, ... )
|
|||
|
||||
va_start( ap, fmt );
|
||||
tor->error = TR_STAT_LOCAL_ERROR;
|
||||
tor->errorTracker[0] = '\0';
|
||||
evutil_vsnprintf( tor->errorString, sizeof( tor->errorString ), fmt, ap );
|
||||
va_end( ap );
|
||||
}
|
||||
|
||||
static void
|
||||
tr_torrentClearError( tr_torrent * tor )
|
||||
{
|
||||
assert( tr_isTorrent( tor ) );
|
||||
|
||||
tor->error = TR_STAT_OK;
|
||||
tor->errorString[0] = '\0';
|
||||
tor->errorTracker[0] = '\0';
|
||||
}
|
||||
|
||||
static void
|
||||
onTrackerResponse( void * tracker UNUSED,
|
||||
void * vevent,
|
||||
|
@ -386,21 +397,20 @@ onTrackerResponse( void * tracker UNUSED,
|
|||
case TR_TRACKER_WARNING:
|
||||
tr_torerr( tor, _( "Tracker warning: \"%s\"" ), event->text );
|
||||
tor->error = TR_STAT_TRACKER_WARNING;
|
||||
tr_strlcpy( tor->errorTracker, event->tracker, sizeof( tor->errorTracker ) );
|
||||
tr_strlcpy( tor->errorString, event->text, sizeof( tor->errorString ) );
|
||||
break;
|
||||
|
||||
case TR_TRACKER_ERROR:
|
||||
tr_torerr( tor, _( "Tracker error: \"%s\"" ), event->text );
|
||||
tor->error = TR_STAT_TRACKER_ERROR;
|
||||
tr_strlcpy( tor->errorTracker, event->tracker, sizeof( tor->errorTracker ) );
|
||||
tr_strlcpy( tor->errorString, event->text, sizeof( tor->errorString ) );
|
||||
break;
|
||||
|
||||
case TR_TRACKER_ERROR_CLEAR:
|
||||
if( tor->error != TR_STAT_LOCAL_ERROR )
|
||||
{
|
||||
tor->error = TR_STAT_OK;
|
||||
tor->errorString[0] = '\0';
|
||||
}
|
||||
tr_torrentClearError( tor );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1363,10 +1373,9 @@ checkAndStartImpl( void * vtor )
|
|||
{
|
||||
const time_t now = tr_time( );
|
||||
tor->isRunning = TRUE;
|
||||
tor->error = TR_STAT_OK;
|
||||
tor->errorString[0] = '\0';
|
||||
tor->completeness = tr_cpGetStatus( &tor->completion );
|
||||
tor->startDate = tor->anyDate = now;
|
||||
tr_torrentClearError( tor );
|
||||
|
||||
tr_torrentResetTransferStats( tor );
|
||||
tr_announcerTorrentStarted( tor );
|
||||
|
@ -2210,6 +2219,22 @@ tr_torrentSetAnnounceList( tr_torrent * tor,
|
|||
/* cleanup */
|
||||
tr_bencFree( &metainfo );
|
||||
|
||||
/* if we had a tracker-related error on this torrent,
|
||||
* and that tracker's been removed,
|
||||
* then clear the error */
|
||||
if( ( tor->error == TR_STAT_TRACKER_WARNING )
|
||||
|| ( tor->error == TR_STAT_TRACKER_ERROR ) )
|
||||
{
|
||||
tr_bool clear = TRUE;
|
||||
|
||||
for( i=0; clear && i<trackerCount; ++i )
|
||||
if( !strcmp( trackers[i].announce, tor->errorTracker ) )
|
||||
clear = FALSE;
|
||||
|
||||
if( clear )
|
||||
tr_torrentClearError( tor );
|
||||
}
|
||||
|
||||
/* tell the announcer to reload this torrent's tracker list */
|
||||
tr_announcerResetTorrent( tor->session->announcer, tor );
|
||||
}
|
||||
|
|
|
@ -141,6 +141,7 @@ struct tr_torrent
|
|||
|
||||
tr_stat_errtype error;
|
||||
char errorString[128];
|
||||
char errorTracker[128];
|
||||
|
||||
uint8_t obfuscatedHash[SHA_DIGEST_LENGTH];
|
||||
|
||||
|
|
Loading…
Reference in a new issue