remove unused flags
This commit is contained in:
parent
efe4847204
commit
e698756c98
|
@ -210,7 +210,7 @@ int main( int argc, char ** argv )
|
|||
{
|
||||
printf( "creator: %s\n", info->creator );
|
||||
}
|
||||
if( TR_FLAG_PRIVATE & info->flags )
|
||||
if( info->isPrivate )
|
||||
{
|
||||
printf( "private flag set\n" );
|
||||
}
|
||||
|
|
|
@ -499,18 +499,15 @@ opentor( const char * path, const char * hash, uint8_t * data, size_t size,
|
|||
|
||||
if( NULL != path )
|
||||
{
|
||||
tor->tor = tr_torrentInit( gl_handle, path, dir,
|
||||
TR_FLAG_SAVE | TR_FLAG_PAUSED, &errcode );
|
||||
tor->tor = tr_torrentInit( gl_handle, path, dir, 1, &errcode );
|
||||
}
|
||||
else if( NULL != hash )
|
||||
{
|
||||
tor->tor = tr_torrentInitSaved( gl_handle, hash, dir, TR_FLAG_PAUSED,
|
||||
&errcode );
|
||||
tor->tor = tr_torrentInitSaved( gl_handle, hash, dir, 1, &errcode );
|
||||
}
|
||||
else
|
||||
{
|
||||
tor->tor = tr_torrentInitData( gl_handle, data, size, dir,
|
||||
TR_FLAG_SAVE | TR_FLAG_PAUSED, &errcode );
|
||||
tor->tor = tr_torrentInitData( gl_handle, data, size, dir, 1, &errcode );
|
||||
}
|
||||
|
||||
if( NULL == tor->tor )
|
||||
|
@ -567,7 +564,7 @@ opentor( const char * path, const char * hash, uint8_t * data, size_t size,
|
|||
inf = tr_torrentInfo( tor->tor );
|
||||
memcpy( tor->hash, inf->hash, sizeof tor->hash );
|
||||
|
||||
if( TR_FLAG_PRIVATE & inf->flags )
|
||||
if( inf->isPrivate )
|
||||
{
|
||||
tor->pexset = 1;
|
||||
tor->pex = 0;
|
||||
|
@ -834,7 +831,7 @@ savestate( void )
|
|||
tr_bencInit( tor, TYPE_DICT );
|
||||
inf = tr_torrentInfo( ii->tor );
|
||||
st = tr_torrentStat( ii->tor );
|
||||
pexset = ( ii->pexset && !( TR_FLAG_PRIVATE & inf->flags ) );
|
||||
pexset = ( ii->pexset && !inf->isPrivate );
|
||||
if( tr_bencDictReserve( tor, ( pexset ? 4 : 3 ) ) )
|
||||
{
|
||||
goto nomem;
|
||||
|
|
|
@ -715,7 +715,7 @@ static GtkWidget* info_page_new (tr_torrent * tor)
|
|||
hig_workarea_add_row (t, &row, name, l, NULL);
|
||||
|
||||
g_snprintf (name, sizeof(name), namefmt, _("Secure"));
|
||||
pch = (info->flags & TR_FLAG_PRIVATE)
|
||||
pch = (info->isPrivate )
|
||||
? _("Private Torrent, PEX disabled")
|
||||
: _("Public Torrent");
|
||||
l = gtk_label_new (pch);
|
||||
|
|
|
@ -345,10 +345,9 @@ tr_core_quiescent( TrCore * self )
|
|||
}
|
||||
|
||||
int
|
||||
tr_core_load( TrCore * self, gboolean forcepaused )
|
||||
tr_core_load( TrCore * self, gboolean paused )
|
||||
{
|
||||
int i;
|
||||
int flags;
|
||||
int count = 0;
|
||||
tr_torrent ** torrents;
|
||||
char * path;
|
||||
|
@ -357,11 +356,7 @@ tr_core_load( TrCore * self, gboolean forcepaused )
|
|||
|
||||
path = getdownloaddir( );
|
||||
|
||||
flags = 0;
|
||||
if( forcepaused )
|
||||
flags |= TR_FLAG_PAUSED;
|
||||
|
||||
torrents = tr_loadTorrents ( self->handle, NULL, flags, &count );
|
||||
torrents = tr_loadTorrents ( self->handle, NULL, paused, &count );
|
||||
for( i=0; i<count; ++i )
|
||||
tr_core_insert( self, tr_torrent_new_preexisting( torrents[i] ) );
|
||||
tr_free( torrents );
|
||||
|
|
|
@ -195,7 +195,7 @@ tr_torrent_new( tr_handle * back, const char *torrent, const char *dir,
|
|||
{
|
||||
TrTorrent *ret;
|
||||
tr_torrent *handle;
|
||||
int errcode, flags;
|
||||
int errcode;
|
||||
|
||||
g_assert(NULL != dir);
|
||||
|
||||
|
@ -203,11 +203,7 @@ tr_torrent_new( tr_handle * back, const char *torrent, const char *dir,
|
|||
|
||||
errcode = -1;
|
||||
|
||||
flags = ( TR_TOR_COPY == act || TR_TOR_MOVE == act ? TR_FLAG_SAVE : 0 );
|
||||
if( paused )
|
||||
flags |= TR_FLAG_PAUSED;
|
||||
|
||||
handle = tr_torrentInit( back, torrent, dir, flags, &errcode );
|
||||
handle = tr_torrentInit( back, torrent, dir, paused, &errcode );
|
||||
|
||||
if(NULL == handle) {
|
||||
switch(errcode) {
|
||||
|
@ -238,18 +234,13 @@ tr_torrent_new_with_data( tr_handle * back, uint8_t * data, size_t size,
|
|||
{
|
||||
tr_torrent * handle;
|
||||
int errcode;
|
||||
int flags;
|
||||
|
||||
g_assert( NULL != dir );
|
||||
|
||||
*err = NULL;
|
||||
|
||||
flags = TR_FLAG_SAVE;
|
||||
if( paused )
|
||||
flags |= TR_FLAG_PAUSED;
|
||||
|
||||
errcode = -1;
|
||||
handle = tr_torrentInitData( back, data, size, dir, flags, &errcode );
|
||||
handle = tr_torrentInitData( back, data, size, dir, paused, &errcode );
|
||||
|
||||
if( NULL == handle )
|
||||
{
|
||||
|
|
|
@ -313,7 +313,7 @@ tr_fastResumeSave( const tr_torrent * tor )
|
|||
total = tor->corruptCur + tor->corruptPrev;
|
||||
fastResumeWriteData( FR_ID_CORRUPT, &total, 8, 1, file );
|
||||
|
||||
if( !( TR_FLAG_PRIVATE & tor->info.flags ) )
|
||||
if( !tor->info.isPrivate )
|
||||
{
|
||||
tr_pex * pex;
|
||||
const int count = tr_peerMgrGetPeers( tor->handle->peerMgr,
|
||||
|
@ -713,7 +713,7 @@ fastResumeLoadImpl ( tr_torrent * tor,
|
|||
break;
|
||||
|
||||
case FR_ID_PEERS_OLD:
|
||||
if( !( TR_FLAG_PRIVATE & tor->info.flags ) )
|
||||
if( !tor->info.isPrivate )
|
||||
{
|
||||
uint8_t * buf = malloc( len );
|
||||
if( 1 != fread( buf, len, 1, file ) )
|
||||
|
@ -734,7 +734,7 @@ fastResumeLoadImpl ( tr_torrent * tor,
|
|||
}
|
||||
|
||||
case FR_ID_PEERS:
|
||||
if( !( TR_FLAG_PRIVATE & tor->info.flags ) )
|
||||
if( !tor->info.isPrivate )
|
||||
{
|
||||
const int count = len / sizeof(tr_pex);
|
||||
tr_pex * pex = tr_new0( tr_pex, count );
|
||||
|
|
|
@ -186,7 +186,6 @@ static struct inf gl_inf[] =
|
|||
{ "name", IPC_INF_NAME, RB_ENTRY_INITIALIZER() },
|
||||
{ "path", IPC_INF_PATH, RB_ENTRY_INITIALIZER() },
|
||||
{ "private", IPC_INF_PRIVATE, RB_ENTRY_INITIALIZER() },
|
||||
{ "saved", IPC_INF_SAVED, RB_ENTRY_INITIALIZER() },
|
||||
{ "size", IPC_INF_SIZE, RB_ENTRY_INITIALIZER() },
|
||||
{ "trackers", IPC_INF_TRACKERS, RB_ENTRY_INITIALIZER() },
|
||||
};
|
||||
|
@ -681,12 +680,7 @@ ipc_addinfo( benc_val_t * list, int tor, const tr_info * inf, int types )
|
|||
tr_bencInitStr( item, inf->torrent, -1, 1 );
|
||||
break;
|
||||
case IPC_INF_PRIVATE:
|
||||
tr_bencInitInt( item,
|
||||
( TR_FLAG_PRIVATE & inf->flags ? 1 : 0 ) );
|
||||
break;
|
||||
case IPC_INF_SAVED:
|
||||
tr_bencInitInt( item,
|
||||
( TR_FLAG_SAVE & inf->flags ? 1 : 0 ) );
|
||||
tr_bencInitInt( item, inf->isPrivate ? 1 : 0 );
|
||||
break;
|
||||
case IPC_INF_SIZE:
|
||||
tr_bencInitInt( item, inf->totalSize );
|
||||
|
|
|
@ -88,7 +88,6 @@ enum ipc_msg
|
|||
#define IPC_INF_NAME ( 1 << 6 )
|
||||
#define IPC_INF_PATH ( 1 << 7 )
|
||||
#define IPC_INF_PRIVATE ( 1 << 8 )
|
||||
#define IPC_INF_SAVED ( 1 << 9 )
|
||||
#define IPC_INF_SIZE ( 1 << 10 )
|
||||
#define IPC_INF_TRACKERS ( 1 << 11 )
|
||||
#define IPC_INF__MAX ( 1 << 12 )
|
||||
|
|
|
@ -227,7 +227,7 @@ realparse( tr_info * inf, const uint8_t * buf, size_t size )
|
|||
if( ( NULL != val && ( TYPE_INT != val->type || 0 != val->val.i ) ) ||
|
||||
( NULL != val2 && ( TYPE_INT != val2->type || 0 != val2->val.i ) ) )
|
||||
{
|
||||
inf->flags |= TR_FLAG_PRIVATE;
|
||||
inf->isPrivate = 1;
|
||||
}
|
||||
|
||||
/* Piece length */
|
||||
|
@ -664,7 +664,7 @@ parseFiles( tr_info * inf, benc_val_t * name,
|
|||
if( files && TYPE_LIST == files->type )
|
||||
{
|
||||
/* Multi-file mode */
|
||||
inf->multifile = 1;
|
||||
inf->isMultifile = 1;
|
||||
inf->fileCount = files->val.l.count;
|
||||
inf->files = calloc( inf->fileCount, sizeof( inf->files[0] ) );
|
||||
|
||||
|
@ -698,7 +698,7 @@ parseFiles( tr_info * inf, benc_val_t * name,
|
|||
else if( NULL != length && TYPE_INT == length->type )
|
||||
{
|
||||
/* Single-file mode */
|
||||
inf->multifile = 0;
|
||||
inf->isMultifile = 0;
|
||||
inf->fileCount = 1;
|
||||
inf->files = calloc( 1, sizeof( inf->files[0] ) );
|
||||
|
||||
|
|
|
@ -257,16 +257,14 @@ static void
|
|||
torrentRealInit( tr_handle * h,
|
||||
tr_torrent * tor,
|
||||
const char * destination,
|
||||
int flags )
|
||||
int isPaused )
|
||||
{
|
||||
int doStart;
|
||||
uint64_t loaded;
|
||||
uint64_t t;
|
||||
tr_bitfield * uncheckedPieces;
|
||||
tr_info * info = &tor->info;
|
||||
|
||||
tor->info.flags |= flags;
|
||||
|
||||
|
||||
tr_globalLock( h );
|
||||
|
||||
tor->destination = tr_strdup( destination );
|
||||
|
@ -347,7 +345,7 @@ torrentRealInit( tr_handle * h,
|
|||
/* the `paused' flag has highest precedence...
|
||||
after that, the fastresume setting is used...
|
||||
if that's not found, default to RUNNING */
|
||||
if( flags & TR_FLAG_PAUSED )
|
||||
if( isPaused )
|
||||
doStart = 0;
|
||||
else if( loaded & TR_FR_RUN )
|
||||
doStart = tor->isRunning;
|
||||
|
@ -455,7 +453,7 @@ tr_torrent *
|
|||
tr_torrentInit( tr_handle * h,
|
||||
const char * path,
|
||||
const char * destination,
|
||||
int flags,
|
||||
int isPaused,
|
||||
int * error )
|
||||
{
|
||||
int val;
|
||||
|
@ -470,8 +468,8 @@ tr_torrentInit( tr_handle * h,
|
|||
else if(!(( tor = tr_new0( tr_torrent, 1 ))))
|
||||
*error = TR_EOTHER;
|
||||
else {
|
||||
tr_metainfoParseFile( &tor->info, h->tag, path, TR_FLAG_SAVE & flags );
|
||||
torrentRealInit( h, tor, destination, flags );
|
||||
tr_metainfoParseFile( &tor->info, h->tag, path, TRUE );
|
||||
torrentRealInit( h, tor, destination, isPaused );
|
||||
}
|
||||
|
||||
return tor;
|
||||
|
@ -506,7 +504,7 @@ tr_torrent *
|
|||
tr_torrentInitSaved( tr_handle * h,
|
||||
const char * hashStr,
|
||||
const char * destination,
|
||||
int flags,
|
||||
int isPaused,
|
||||
int * error )
|
||||
{
|
||||
int val;
|
||||
|
@ -522,7 +520,7 @@ tr_torrentInitSaved( tr_handle * h,
|
|||
*error = TR_EOTHER;
|
||||
else {
|
||||
tr_metainfoParseHash( &tor->info, h->tag, hashStr );
|
||||
torrentRealInit( h, tor, destination, (TR_FLAG_SAVE|flags) );
|
||||
torrentRealInit( h, tor, destination, isPaused );
|
||||
}
|
||||
|
||||
return tor;
|
||||
|
@ -559,7 +557,7 @@ tr_torrentInitData( tr_handle * h,
|
|||
const uint8_t * data,
|
||||
size_t size,
|
||||
const char * destination,
|
||||
int flags,
|
||||
int isPaused,
|
||||
int * error )
|
||||
{
|
||||
int val;
|
||||
|
@ -574,8 +572,8 @@ tr_torrentInitData( tr_handle * h,
|
|||
else if(!(( tor = tr_new0( tr_torrent, 1 ))))
|
||||
*error = TR_EOTHER;
|
||||
else {
|
||||
tr_metainfoParseData( &tor->info, h->tag, data, size, TR_FLAG_SAVE & flags );
|
||||
torrentRealInit( h, tor, destination, flags );
|
||||
tr_metainfoParseData( &tor->info, h->tag, data, size, TRUE );
|
||||
torrentRealInit( h, tor, destination, isPaused );
|
||||
}
|
||||
|
||||
return tor;
|
||||
|
@ -647,13 +645,7 @@ tr_torrentChangeMyPort( tr_torrent * tor )
|
|||
int
|
||||
tr_torrentIsPexEnabled( const tr_torrent * tor )
|
||||
{
|
||||
if( tor->info.flags & TR_FLAG_PRIVATE )
|
||||
return FALSE;
|
||||
|
||||
if( tor->pexDisabled )
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return !tor->info.isPrivate && !tor->pexDisabled;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -663,7 +655,7 @@ tr_torrentDisablePex( tr_torrent * tor, int disable )
|
|||
assert( disable==0 || disable==1 );
|
||||
|
||||
/* pex is ALWAYS disabled for private torrents */
|
||||
if( tor->info.flags & TR_FLAG_PRIVATE )
|
||||
if( tor->info.isPrivate )
|
||||
disable = TRUE;
|
||||
|
||||
tor->pexDisabled = disable;
|
||||
|
|
|
@ -329,7 +329,7 @@ tr_close( tr_handle * h )
|
|||
tr_torrent **
|
||||
tr_loadTorrents ( tr_handle * h,
|
||||
const char * destination,
|
||||
int flags,
|
||||
int isPaused,
|
||||
int * setmeCount )
|
||||
{
|
||||
int i, n = 0;
|
||||
|
@ -351,7 +351,7 @@ tr_loadTorrents ( tr_handle * h,
|
|||
tr_torrent * tor;
|
||||
char path[MAX_PATH_LENGTH];
|
||||
tr_buildPath( path, sizeof(path), torrentDir, d->d_name, NULL );
|
||||
tor = tr_torrentInit( h, path, destination, flags, NULL );
|
||||
tor = tr_torrentInit( h, path, destination, isPaused, NULL );
|
||||
if( tor != NULL ) {
|
||||
tr_list_append( &list, tor );
|
||||
n++;
|
||||
|
|
|
@ -315,7 +315,7 @@ void tr_close( tr_handle * );
|
|||
*/
|
||||
tr_torrent ** tr_loadTorrents ( tr_handle * h,
|
||||
const char * destination,
|
||||
int flags,
|
||||
int isPaused,
|
||||
int * setmeCount );
|
||||
|
||||
|
||||
|
@ -333,10 +333,10 @@ tr_torrent ** tr_loadTorrents ( tr_handle * h,
|
|||
#define TR_EUNSUPPORTED 2
|
||||
#define TR_EDUPLICATE 3
|
||||
#define TR_EOTHER 666
|
||||
tr_torrent * tr_torrentInit( tr_handle * handle,
|
||||
tr_torrent * tr_torrentInit( tr_handle * handle,
|
||||
const char * metainfo_filename,
|
||||
const char * destination,
|
||||
int flags,
|
||||
int isPaused,
|
||||
int * setme_error );
|
||||
|
||||
typedef struct tr_info tr_info;
|
||||
|
@ -381,7 +381,8 @@ tr_torrentParseHash( const tr_handle * h,
|
|||
tr_torrent * tr_torrentInitData( tr_handle *,
|
||||
const uint8_t * data, size_t size,
|
||||
const char * destination,
|
||||
int flags, int * error );
|
||||
int isPaused,
|
||||
int * error );
|
||||
|
||||
/***********************************************************************
|
||||
* tr_torrentInitSaved
|
||||
|
@ -393,7 +394,8 @@ tr_torrent * tr_torrentInitData( tr_handle *,
|
|||
tr_torrent * tr_torrentInitSaved( tr_handle *,
|
||||
const char * hashStr,
|
||||
const char * destination,
|
||||
int flags, int * error );
|
||||
int isPaused,
|
||||
int * error );
|
||||
|
||||
/***********************************************************************
|
||||
* tr_torrentDisablePex
|
||||
|
@ -574,10 +576,8 @@ struct tr_info
|
|||
char name[MAX_PATH_LENGTH];
|
||||
|
||||
/* Flags */
|
||||
#define TR_FLAG_SAVE 0x01 /* save a copy of the torrent file */
|
||||
#define TR_FLAG_PRIVATE 0x02 /* do not share information for this torrent */
|
||||
#define TR_FLAG_PAUSED 0x04 /* don't start the torrent when adding it */
|
||||
int flags;
|
||||
unsigned int isPrivate : 1;
|
||||
unsigned int isMultifile : 1;
|
||||
|
||||
/* Tracker info */
|
||||
struct
|
||||
|
@ -600,7 +600,6 @@ struct tr_info
|
|||
tr_piece * pieces;
|
||||
|
||||
/* Files info */
|
||||
int multifile;
|
||||
int fileCount;
|
||||
tr_file * files;
|
||||
};
|
||||
|
|
|
@ -371,7 +371,7 @@ void MyFrame :: OnOpen( wxCommandEvent& WXUNUSED(event) )
|
|||
tr_torrent * tor = tr_torrentInit( handle,
|
||||
filename.c_str(),
|
||||
mySavePath.c_str(),
|
||||
TR_FLAG_SAVE, NULL );
|
||||
false, NULL );
|
||||
if( tor )
|
||||
myTorrents.push_back( tor );
|
||||
}
|
||||
|
@ -673,11 +673,8 @@ MyFrame :: MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size
|
|||
*** Load the torrents
|
||||
**/
|
||||
|
||||
int flags = 0;
|
||||
if( paused )
|
||||
flags |= TR_FLAG_PAUSED;
|
||||
int count = 0;
|
||||
tr_torrent ** torrents = tr_loadTorrents ( handle, mySavePath.c_str(), flags, &count );
|
||||
tr_torrent ** torrents = tr_loadTorrents ( handle, mySavePath.c_str(), paused, &count );
|
||||
myTorrents.insert( myTorrents.end(), torrents, torrents+count );
|
||||
tr_free( torrents );
|
||||
|
||||
|
|
Loading…
Reference in New Issue