static uint64_t setFromCtor( tr_torrent * tor, uint64_t fields, const tr_ctor * ctor, int mode ) { uint64_t ret = 0; if( fields & TR_FR_RUN ) { uint8_t isPaused; if( !tr_ctorGetPaused( ctor, mode, &isPaused ) ) { tor->isRunning = !isPaused; ret |= TR_FR_RUN; } } if( fields & TR_FR_MAX_PEERS ) if( !tr_ctorGetPeerLimit( ctor, mode, &tor->maxConnectedPeers ) ) ret |= TR_FR_MAX_PEERS; if( fields & TR_FR_DOWNLOAD_DIR ) { const char * path; if( !tr_ctorGetDownloadDir( ctor, mode, &path ) && path && *path ) { ret |= TR_FR_DOWNLOAD_DIR; tr_free( tor->downloadDir ); tor->downloadDir = tr_strdup( path ); } } return ret; }
static void tr_core_apply_defaults( tr_ctor * ctor ) { if( tr_ctorGetPaused( ctor, TR_FORCE, NULL ) ) tr_ctorSetPaused( ctor, TR_FORCE, !gtr_pref_flag_get( TR_PREFS_KEY_START ) ); if( tr_ctorGetDeleteSource( ctor, NULL ) ) tr_ctorSetDeleteSource( ctor, gtr_pref_flag_get( TR_PREFS_KEY_TRASH_ORIGINAL ) ); if( tr_ctorGetPeerLimit( ctor, TR_FORCE, NULL ) ) tr_ctorSetPeerLimit( ctor, TR_FORCE, gtr_pref_int_get( TR_PREFS_KEY_PEER_LIMIT_TORRENT ) ); if( tr_ctorGetDownloadDir( ctor, TR_FORCE, NULL ) ) { const char * path = gtr_pref_string_get( TR_PREFS_KEY_DOWNLOAD_DIR ); tr_ctorSetDownloadDir( ctor, TR_FORCE, path ); } }
static uint64_t setFromCtor(tr_torrent* tor, uint64_t fields, tr_ctor const* ctor, int mode) { uint64_t ret = 0; if ((fields & TR_FR_RUN) != 0) { bool isPaused; if (tr_ctorGetPaused(ctor, mode, &isPaused)) { tor->isRunning = !isPaused; ret |= TR_FR_RUN; } } if ((fields & TR_FR_MAX_PEERS) != 0) { if (tr_ctorGetPeerLimit(ctor, mode, &tor->maxConnectedPeers)) { ret |= TR_FR_MAX_PEERS; } } if ((fields & TR_FR_DOWNLOAD_DIR) != 0) { char const* path; if (tr_ctorGetDownloadDir(ctor, mode, &path) && path != NULL && *path != '\0') { ret |= TR_FR_DOWNLOAD_DIR; tr_free(tor->downloadDir); tor->downloadDir = tr_strdup(path); } } return ret; }