chore: sonarcloud warnings 2 (#1496)
* fix "merge nested if" sonarcloud warnings * fix explicit constructor warnings in qt client
This commit is contained in:
parent
e59fe7daaf
commit
19e52d8b9a
|
@ -262,9 +262,8 @@ int tr_main(int argc, char* argv[])
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tr_variantDictFindStr(&settings, TR_KEY_download_dir, &str, NULL))
|
if (tr_variantDictFindStr(&settings, TR_KEY_download_dir, &str, NULL) &&
|
||||||
{
|
!tr_sys_path_exists(str, NULL))
|
||||||
if (!tr_sys_path_exists(str, NULL))
|
|
||||||
{
|
{
|
||||||
tr_error* error = NULL;
|
tr_error* error = NULL;
|
||||||
|
|
||||||
|
@ -275,7 +274,6 @@ int tr_main(int argc, char* argv[])
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
h = tr_sessionInit(configDir, false, &settings);
|
h = tr_sessionInit(configDir, false, &settings);
|
||||||
|
|
||||||
|
|
|
@ -1430,6 +1430,8 @@ static void refreshPeerRow(GtkListStore* store, GtkTreeIter* iter, tr_peer_stat
|
||||||
char cancelled_by_peer[64] = { '\0' };
|
char cancelled_by_peer[64] = { '\0' };
|
||||||
char cancelled_by_client[64] = { '\0' };
|
char cancelled_by_client[64] = { '\0' };
|
||||||
|
|
||||||
|
g_return_if_fail(peer != NULL);
|
||||||
|
|
||||||
if (peer->rateToPeer_KBps > 0.01)
|
if (peer->rateToPeer_KBps > 0.01)
|
||||||
{
|
{
|
||||||
tr_formatter_speed_KBps(up_speed, peer->rateToPeer_KBps, sizeof(up_speed));
|
tr_formatter_speed_KBps(up_speed, peer->rateToPeer_KBps, sizeof(up_speed));
|
||||||
|
@ -2906,7 +2908,8 @@ static void on_details_window_size_allocated(GtkWidget* gtk_window, GtkAllocatio
|
||||||
TR_UNUSED(alloc);
|
TR_UNUSED(alloc);
|
||||||
TR_UNUSED(gdata);
|
TR_UNUSED(gdata);
|
||||||
|
|
||||||
int w, h;
|
int w = 0;
|
||||||
|
int h = 0;
|
||||||
gtk_window_get_size(GTK_WINDOW(gtk_window), &w, &h);
|
gtk_window_get_size(GTK_WINDOW(gtk_window), &w, &h);
|
||||||
gtr_pref_int_set(TR_KEY_details_window_width, w);
|
gtr_pref_int_set(TR_KEY_details_window_width, w);
|
||||||
gtr_pref_int_set(TR_KEY_details_window_height, h);
|
gtr_pref_int_set(TR_KEY_details_window_height, h);
|
||||||
|
|
|
@ -129,16 +129,15 @@ static gboolean refreshFilesForeach(GtkTreeModel* model, GtkTreePath* path, GtkT
|
||||||
* which breaks this foreach () call. (See #3529)
|
* which breaks this foreach () call. (See #3529)
|
||||||
* As a workaround: if that's about to happen, temporarily disable
|
* As a workaround: if that's about to happen, temporarily disable
|
||||||
* sorting until we finish walking the tree. */
|
* sorting until we finish walking the tree. */
|
||||||
if (!refresh_data->resort_needed)
|
if (!refresh_data->resort_needed &&
|
||||||
{
|
(((refresh_data->sort_column_id == FC_PRIORITY) && (priority != old_priority)) ||
|
||||||
if ((refresh_data->resort_needed = (refresh_data->sort_column_id == FC_PRIORITY && priority != old_priority) ||
|
((refresh_data->sort_column_id == FC_ENABLED) && (enabled != old_enabled))))
|
||||||
(refresh_data->sort_column_id == FC_ENABLED && enabled != old_enabled)))
|
|
||||||
{
|
{
|
||||||
refresh_data->resort_needed = TRUE;
|
refresh_data->resort_needed = TRUE;
|
||||||
|
|
||||||
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(data->model),
|
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(data->model),
|
||||||
GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, GTK_SORT_ASCENDING);
|
GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, GTK_SORT_ASCENDING);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
gtk_tree_store_set(data->store, iter,
|
gtk_tree_store_set(data->store, iter,
|
||||||
FC_PRIORITY, priority,
|
FC_PRIORITY, priority,
|
||||||
|
|
|
@ -547,9 +547,8 @@ static void on_startup(GApplication* application, gpointer user_data)
|
||||||
tr_sessionSetRPCCallback(session, on_rpc_changed, cbdata);
|
tr_sessionSetRPCCallback(session, on_rpc_changed, cbdata);
|
||||||
|
|
||||||
/* check & see if it's time to update the blocklist */
|
/* check & see if it's time to update the blocklist */
|
||||||
if (gtr_pref_flag_get(TR_KEY_blocklist_enabled))
|
if (gtr_pref_flag_get(TR_KEY_blocklist_enabled) &&
|
||||||
{
|
gtr_pref_flag_get(TR_KEY_blocklist_updates_enabled))
|
||||||
if (gtr_pref_flag_get(TR_KEY_blocklist_updates_enabled))
|
|
||||||
{
|
{
|
||||||
int64_t const last_time = gtr_pref_int_get(TR_KEY_blocklist_date);
|
int64_t const last_time = gtr_pref_int_get(TR_KEY_blocklist_date);
|
||||||
int const SECONDS_IN_A_WEEK = 7 * 24 * 60 * 60;
|
int const SECONDS_IN_A_WEEK = 7 * 24 * 60 * 60;
|
||||||
|
@ -560,7 +559,6 @@ static void on_startup(GApplication* application, gpointer user_data)
|
||||||
gtr_core_blocklist_update(cbdata->core);
|
gtr_core_blocklist_update(cbdata->core);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* if there's no magnet link handler registered, register us */
|
/* if there's no magnet link handler registered, register us */
|
||||||
ensure_magnet_handler_exists();
|
ensure_magnet_handler_exists();
|
||||||
|
|
|
@ -52,7 +52,6 @@ static void setLabelFromRatio(GtkLabel* l, double d)
|
||||||
static gboolean updateStats(gpointer gdata)
|
static gboolean updateStats(gpointer gdata)
|
||||||
{
|
{
|
||||||
char buf[128];
|
char buf[128];
|
||||||
char const* fmt;
|
|
||||||
tr_session_stats one;
|
tr_session_stats one;
|
||||||
tr_session_stats all;
|
tr_session_stats all;
|
||||||
size_t const buflen = sizeof(buf);
|
size_t const buflen = sizeof(buf);
|
||||||
|
@ -66,7 +65,7 @@ static gboolean updateStats(gpointer gdata)
|
||||||
setLabel(ui->one_time_lb, tr_strltime(buf, one.secondsActive, buflen));
|
setLabel(ui->one_time_lb, tr_strltime(buf, one.secondsActive, buflen));
|
||||||
setLabelFromRatio(ui->one_ratio_lb, one.ratio);
|
setLabelFromRatio(ui->one_ratio_lb, one.ratio);
|
||||||
|
|
||||||
fmt = ngettext("Started %'d time", "Started %'d times", (int)all.sessionCount);
|
char const* const fmt = ngettext("Started %'d time", "Started %'d times", (int)all.sessionCount);
|
||||||
g_snprintf(buf, buflen, fmt, (int)all.sessionCount);
|
g_snprintf(buf, buflen, fmt, (int)all.sessionCount);
|
||||||
setLabel(ui->all_sessions_lb, buf);
|
setLabel(ui->all_sessions_lb, buf);
|
||||||
setLabel(ui->all_up_lb, tr_strlsize(buf, all.uploadedBytes, buflen));
|
setLabel(ui->all_up_lb, tr_strlsize(buf, all.uploadedBytes, buflen));
|
||||||
|
|
|
@ -449,12 +449,12 @@ static void onBlocklistUpdated(TrCore* core, int n, gpointer gdata)
|
||||||
{
|
{
|
||||||
bool const success = n >= 0;
|
bool const success = n >= 0;
|
||||||
int const count = n >= 0 ? n : tr_blocklistGetRuleCount(gtr_core_session(core));
|
int const count = n >= 0 ? n : tr_blocklistGetRuleCount(gtr_core_session(core));
|
||||||
char const* s = ngettext("Blocklist has %'d rule.", "Blocklist has %'d rules.", count);
|
|
||||||
struct blocklist_data* data = gdata;
|
struct blocklist_data* data = gdata;
|
||||||
GtkMessageDialog* d = GTK_MESSAGE_DIALOG(data->updateBlocklistDialog);
|
GtkMessageDialog* d = GTK_MESSAGE_DIALOG(data->updateBlocklistDialog);
|
||||||
gtk_widget_set_sensitive(data->updateBlocklistButton, TRUE);
|
gtk_widget_set_sensitive(data->updateBlocklistButton, TRUE);
|
||||||
gtk_message_dialog_set_markup(d, success ? _("<b>Update succeeded!</b>") : _("<b>Unable to update.</b>"));
|
gtk_message_dialog_set_markup(d, success ? _("<b>Update succeeded!</b>") : _("<b>Unable to update.</b>"));
|
||||||
gtk_message_dialog_format_secondary_text(d, s, count);
|
char const* const fmt = ngettext("Blocklist has %'d rule.", "Blocklist has %'d rules.", count);
|
||||||
|
gtk_message_dialog_format_secondary_text(d, fmt, count);
|
||||||
updateBlocklistText(data->label, core);
|
updateBlocklistText(data->label, core);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -255,19 +255,18 @@ static void status_menu_toggled_cb(GtkCheckMenuItem* menu_item, gpointer vprivat
|
||||||
|
|
||||||
static void syncAltSpeedButton(PrivateData* p)
|
static void syncAltSpeedButton(PrivateData* p)
|
||||||
{
|
{
|
||||||
char u[32];
|
|
||||||
char d[32];
|
|
||||||
char* str;
|
|
||||||
char const* fmt;
|
|
||||||
gboolean const b = gtr_pref_flag_get(TR_KEY_alt_speed_enabled);
|
gboolean const b = gtr_pref_flag_get(TR_KEY_alt_speed_enabled);
|
||||||
char const* stock = b ? "alt-speed-on" : "alt-speed-off";
|
char const* const stock = b ? "alt-speed-on" : "alt-speed-off";
|
||||||
GtkWidget* w = p->alt_speed_button;
|
GtkWidget* const w = p->alt_speed_button;
|
||||||
|
|
||||||
|
char u[32];
|
||||||
tr_formatter_speed_KBps(u, gtr_pref_int_get(TR_KEY_alt_speed_up), sizeof(u));
|
tr_formatter_speed_KBps(u, gtr_pref_int_get(TR_KEY_alt_speed_up), sizeof(u));
|
||||||
|
char d[32];
|
||||||
tr_formatter_speed_KBps(d, gtr_pref_int_get(TR_KEY_alt_speed_down), sizeof(d));
|
tr_formatter_speed_KBps(d, gtr_pref_int_get(TR_KEY_alt_speed_down), sizeof(d));
|
||||||
fmt = b ? _("Click to disable Alternative Speed Limits\n (%1$s down, %2$s up)") :
|
|
||||||
_("Click to enable Alternative Speed Limits\n (%1$s down, %2$s up)");
|
char* const str = b ?
|
||||||
str = g_strdup_printf(fmt, d, u);
|
g_strdup_printf(_("Click to disable Alternative Speed Limits\n (%1$s down, %2$s up)"), d, u) :
|
||||||
|
g_strdup_printf(_("Click to enable Alternative Speed Limits\n (%1$s down, %2$s up)"), d, u);
|
||||||
|
|
||||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), b);
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), b);
|
||||||
gtk_image_set_from_stock(GTK_IMAGE(p->alt_speed_image), stock, -1);
|
gtk_image_set_from_stock(GTK_IMAGE(p->alt_speed_image), stock, -1);
|
||||||
|
|
|
@ -36,15 +36,9 @@
|
||||||
|
|
||||||
static char const* get_event_string(tr_announce_request const* req)
|
static char const* get_event_string(tr_announce_request const* req)
|
||||||
{
|
{
|
||||||
if (req->partial_seed)
|
return req->partial_seed && (req->event != TR_ANNOUNCE_EVENT_STOPPED) ?
|
||||||
{
|
"paused" :
|
||||||
if (req->event != TR_ANNOUNCE_EVENT_STOPPED)
|
tr_announce_event_get_string(req->event);
|
||||||
{
|
|
||||||
return "paused";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return tr_announce_event_get_string(req->event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char* announce_url_new(tr_session const* session, tr_announce_request const* req)
|
static char* announce_url_new(tr_session const* session, tr_announce_request const* req)
|
||||||
|
@ -429,13 +423,11 @@ static void on_scrape_done(tr_session* session, bool did_connect, bool did_timeo
|
||||||
response->errmsg = tr_strndup(str, len);
|
response->errmsg = tr_strndup(str, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tr_variantDictFindDict(&top, TR_KEY_flags, &flags))
|
if (tr_variantDictFindDict(&top, TR_KEY_flags,
|
||||||
{
|
&flags) && tr_variantDictFindInt(flags, TR_KEY_min_request_interval, &intVal))
|
||||||
if (tr_variantDictFindInt(flags, TR_KEY_min_request_interval, &intVal))
|
|
||||||
{
|
{
|
||||||
response->min_request_interval = intVal;
|
response->min_request_interval = intVal;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (tr_variantDictFindDict(&top, TR_KEY_files, &files))
|
if (tr_variantDictFindDict(&top, TR_KEY_files, &files))
|
||||||
{
|
{
|
||||||
|
|
|
@ -522,15 +522,14 @@ tr_socket_t tr_fdSocketCreate(tr_session* session, int domain, int type)
|
||||||
|
|
||||||
if (gFd->peerCount < session->peerLimit)
|
if (gFd->peerCount < session->peerLimit)
|
||||||
{
|
{
|
||||||
if ((s = socket(domain, type, 0)) == TR_BAD_SOCKET)
|
s = socket(domain, type, 0);
|
||||||
{
|
|
||||||
if (sockerrno != EAFNOSUPPORT)
|
if ((s == TR_BAD_SOCKET) && (sockerrno != EAFNOSUPPORT))
|
||||||
{
|
{
|
||||||
char err_buf[512];
|
char err_buf[512];
|
||||||
tr_logAddError(_("Couldn't create socket: %s"), tr_net_strerror(err_buf, sizeof(err_buf), sockerrno));
|
tr_logAddError(_("Couldn't create socket: %s"), tr_net_strerror(err_buf, sizeof(err_buf), sockerrno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (s != TR_BAD_SOCKET)
|
if (s != TR_BAD_SOCKET)
|
||||||
{
|
{
|
||||||
|
|
|
@ -172,24 +172,12 @@ static void setReadState(tr_handshake* handshake, handshake_state_t state)
|
||||||
|
|
||||||
static bool buildHandshakeMessage(tr_handshake* handshake, uint8_t* buf)
|
static bool buildHandshakeMessage(tr_handshake* handshake, uint8_t* buf)
|
||||||
{
|
{
|
||||||
unsigned char const* peer_id = NULL;
|
uint8_t const* const torrent_hash = tr_cryptoGetTorrentHash(handshake->crypto);
|
||||||
uint8_t const* torrentHash;
|
tr_torrent* const tor = torrent_hash == NULL ? NULL : tr_torrentFindFromHash(handshake->session, torrent_hash);
|
||||||
tr_torrent* tor;
|
unsigned char const* const peer_id = tor == NULL ? NULL : tr_torrentGetPeerId(tor);
|
||||||
bool success;
|
bool const success = peer_id != NULL;
|
||||||
|
|
||||||
if ((torrentHash = tr_cryptoGetTorrentHash(handshake->crypto)) != NULL)
|
if (success)
|
||||||
{
|
|
||||||
if ((tor = tr_torrentFindFromHash(handshake->session, torrentHash)) != NULL)
|
|
||||||
{
|
|
||||||
peer_id = tr_torrentGetPeerId(tor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (peer_id == NULL)
|
|
||||||
{
|
|
||||||
success = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
uint8_t* walk = buf;
|
uint8_t* walk = buf;
|
||||||
|
|
||||||
|
@ -208,13 +196,12 @@ static bool buildHandshakeMessage(tr_handshake* handshake, uint8_t* buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
walk += HANDSHAKE_FLAGS_LEN;
|
walk += HANDSHAKE_FLAGS_LEN;
|
||||||
memcpy(walk, torrentHash, SHA_DIGEST_LENGTH);
|
memcpy(walk, torrent_hash, SHA_DIGEST_LENGTH);
|
||||||
walk += SHA_DIGEST_LENGTH;
|
walk += SHA_DIGEST_LENGTH;
|
||||||
memcpy(walk, peer_id, PEER_ID_LEN);
|
memcpy(walk, peer_id, PEER_ID_LEN);
|
||||||
walk += PEER_ID_LEN;
|
walk += PEER_ID_LEN;
|
||||||
|
|
||||||
TR_ASSERT(walk - buf == HANDSHAKE_SIZE);
|
TR_ASSERT(walk - buf == HANDSHAKE_SIZE);
|
||||||
success = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
|
|
|
@ -490,15 +490,14 @@ static void tr_realMakeMetaInfo(tr_metainfo_builder* builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* save the file */
|
/* save the file */
|
||||||
if (builder->result == TR_MAKEMETA_OK && !builder->abortFlag)
|
if ((builder->result == TR_MAKEMETA_OK) &&
|
||||||
{
|
(!builder->abortFlag) &&
|
||||||
if (tr_variantToFile(&top, TR_VARIANT_FMT_BENC, builder->outputFile) != 0)
|
(tr_variantToFile(&top, TR_VARIANT_FMT_BENC, builder->outputFile) != 0))
|
||||||
{
|
{
|
||||||
builder->my_errno = errno;
|
builder->my_errno = errno;
|
||||||
tr_strlcpy(builder->errfile, builder->outputFile, sizeof(builder->errfile));
|
tr_strlcpy(builder->errfile, builder->outputFile, sizeof(builder->errfile));
|
||||||
builder->result = TR_MAKEMETA_IO_WRITE;
|
builder->result = TR_MAKEMETA_IO_WRITE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
tr_variantFree(&top);
|
tr_variantFree(&top);
|
||||||
|
|
|
@ -265,14 +265,12 @@ static char const* parseFiles(tr_info* inf, tr_variant* files, tr_variant const*
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tr_variantDictFindList(file, TR_KEY_path_utf_8, &path))
|
if (!tr_variantDictFindList(file, TR_KEY_path_utf_8, &path) &&
|
||||||
{
|
!tr_variantDictFindList(file, TR_KEY_path, &path))
|
||||||
if (!tr_variantDictFindList(file, TR_KEY_path, &path))
|
|
||||||
{
|
{
|
||||||
result = "path";
|
result = "path";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool is_file_adjusted;
|
bool is_file_adjusted;
|
||||||
if (!getfile(&inf->files[i].name, &is_file_adjusted, root_name, path, buf))
|
if (!getfile(&inf->files[i].name, &is_file_adjusted, root_name, path, buf))
|
||||||
|
@ -613,13 +611,11 @@ static char const* tr_metainfoParseImpl(tr_session const* session, tr_info* inf,
|
||||||
{
|
{
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
||||||
if (!tr_variantDictFindStr(infoDict, TR_KEY_name_utf_8, &str, &len))
|
if (!tr_variantDictFindStr(infoDict, TR_KEY_name_utf_8, &str, &len) &&
|
||||||
{
|
!tr_variantDictFindStr(infoDict, TR_KEY_name, &str, &len))
|
||||||
if (!tr_variantDictFindStr(infoDict, TR_KEY_name, &str, &len))
|
|
||||||
{
|
{
|
||||||
str = "";
|
str = "";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (tr_str_is_empty(str))
|
if (tr_str_is_empty(str))
|
||||||
{
|
{
|
||||||
|
@ -635,13 +631,11 @@ static char const* tr_metainfoParseImpl(tr_session const* session, tr_info* inf,
|
||||||
/* comment */
|
/* comment */
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
||||||
if (!tr_variantDictFindStr(meta, TR_KEY_comment_utf_8, &str, &len))
|
if (!tr_variantDictFindStr(meta, TR_KEY_comment_utf_8, &str, &len) &&
|
||||||
{
|
!tr_variantDictFindStr(meta, TR_KEY_comment, &str, &len))
|
||||||
if (!tr_variantDictFindStr(meta, TR_KEY_comment, &str, &len))
|
|
||||||
{
|
{
|
||||||
str = "";
|
str = "";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
tr_free(inf->comment);
|
tr_free(inf->comment);
|
||||||
inf->comment = tr_utf8clean(str, len);
|
inf->comment = tr_utf8clean(str, len);
|
||||||
|
@ -649,13 +643,11 @@ static char const* tr_metainfoParseImpl(tr_session const* session, tr_info* inf,
|
||||||
/* created by */
|
/* created by */
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
||||||
if (!tr_variantDictFindStr(meta, TR_KEY_created_by_utf_8, &str, &len))
|
if (!tr_variantDictFindStr(meta, TR_KEY_created_by_utf_8, &str, &len) &&
|
||||||
{
|
!tr_variantDictFindStr(meta, TR_KEY_created_by, &str, &len))
|
||||||
if (!tr_variantDictFindStr(meta, TR_KEY_created_by, &str, &len))
|
|
||||||
{
|
{
|
||||||
str = "";
|
str = "";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
tr_free(inf->creator);
|
tr_free(inf->creator);
|
||||||
inf->creator = tr_utf8clean(str, len);
|
inf->creator = tr_utf8clean(str, len);
|
||||||
|
@ -669,13 +661,11 @@ static char const* tr_metainfoParseImpl(tr_session const* session, tr_info* inf,
|
||||||
inf->dateCreated = i;
|
inf->dateCreated = i;
|
||||||
|
|
||||||
/* private */
|
/* private */
|
||||||
if (!tr_variantDictFindInt(infoDict, TR_KEY_private, &i))
|
if (!tr_variantDictFindInt(infoDict, TR_KEY_private, &i) &&
|
||||||
{
|
!tr_variantDictFindInt(meta, TR_KEY_private, &i))
|
||||||
if (!tr_variantDictFindInt(meta, TR_KEY_private, &i))
|
|
||||||
{
|
{
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
inf->isPrivate = i != 0;
|
inf->isPrivate = i != 0;
|
||||||
|
|
||||||
|
|
|
@ -144,13 +144,12 @@ int tr_natpmpPulse(struct tr_natpmp* nat, tr_port private_port, bool is_enabled,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nat->state == TR_NATPMP_IDLE || nat->state == TR_NATPMP_ERR)
|
if ((nat->state == TR_NATPMP_IDLE || nat->state == TR_NATPMP_ERR) &&
|
||||||
{
|
(nat->is_mapped) &&
|
||||||
if (nat->is_mapped && (!is_enabled || nat->private_port != private_port))
|
(!is_enabled || nat->private_port != private_port))
|
||||||
{
|
{
|
||||||
nat->state = TR_NATPMP_SEND_UNMAP;
|
nat->state = TR_NATPMP_SEND_UNMAP;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (nat->state == TR_NATPMP_SEND_UNMAP && canSendCommand(nat))
|
if (nat->state == TR_NATPMP_SEND_UNMAP && canSendCommand(nat))
|
||||||
{
|
{
|
||||||
|
|
|
@ -418,18 +418,14 @@ static tr_socket_t tr_netBindTCPImpl(tr_address const* addr, tr_port port, bool
|
||||||
|
|
||||||
#ifdef IPV6_V6ONLY
|
#ifdef IPV6_V6ONLY
|
||||||
|
|
||||||
if (addr->type == TR_AF_INET6)
|
if ((addr->type == TR_AF_INET6) &&
|
||||||
{
|
(setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (void const*)&optval, sizeof(optval)) == -1) &&
|
||||||
if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (void const*)&optval, sizeof(optval)) == -1)
|
(sockerrno != ENOPROTOOPT)) // if the kernel doesn't support it, ignore it
|
||||||
{
|
|
||||||
if (sockerrno != ENOPROTOOPT) /* if the kernel doesn't support it, ignore it */
|
|
||||||
{
|
{
|
||||||
*errOut = sockerrno;
|
*errOut = sockerrno;
|
||||||
tr_netCloseSocket(fd);
|
tr_netCloseSocket(fd);
|
||||||
return TR_BAD_SOCKET;
|
return TR_BAD_SOCKET;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -790,13 +790,11 @@ static void getBlockRequestPeers(tr_swarm* s, tr_block_index_t block, tr_ptrArra
|
||||||
|
|
||||||
static void decrementPendingReqCount(struct block_request const* b)
|
static void decrementPendingReqCount(struct block_request const* b)
|
||||||
{
|
{
|
||||||
if (b->peer != NULL)
|
if ((b->peer != NULL) &&
|
||||||
{
|
(b->peer->pendingReqsToPeer > 0))
|
||||||
if (b->peer->pendingReqsToPeer > 0)
|
|
||||||
{
|
{
|
||||||
--b->peer->pendingReqsToPeer;
|
--b->peer->pendingReqsToPeer;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void requestListRemove(tr_swarm* s, tr_block_index_t block, tr_peer const* peer)
|
static void requestListRemove(tr_swarm* s, tr_block_index_t block, tr_peer const* peer)
|
||||||
|
@ -1100,14 +1098,11 @@ static void pieceListRebuild(tr_swarm* s)
|
||||||
|
|
||||||
for (tr_piece_index_t i = 0; i < inf->pieceCount; ++i)
|
for (tr_piece_index_t i = 0; i < inf->pieceCount; ++i)
|
||||||
{
|
{
|
||||||
if (!inf->pieces[i].dnd)
|
if (!inf->pieces[i].dnd && !tr_torrentPieceIsComplete(tor, i))
|
||||||
{
|
|
||||||
if (!tr_torrentPieceIsComplete(tor, i))
|
|
||||||
{
|
{
|
||||||
pool[poolCount++] = i;
|
pool[poolCount++] = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pieceCount = poolCount;
|
pieceCount = poolCount;
|
||||||
pieces = tr_new0(struct weighted_piece, pieceCount);
|
pieces = tr_new0(struct weighted_piece, pieceCount);
|
||||||
|
@ -2207,13 +2202,11 @@ void tr_peerMgrAddPex(tr_torrent* tor, uint8_t from, tr_pex const* pex, int8_t s
|
||||||
tr_swarm* s = tor->swarm;
|
tr_swarm* s = tor->swarm;
|
||||||
managerLock(s->manager);
|
managerLock(s->manager);
|
||||||
|
|
||||||
if (!tr_sessionIsAddressBlocked(s->manager->session, &pex->addr))
|
if (!tr_sessionIsAddressBlocked(s->manager->session, &pex->addr) &&
|
||||||
{
|
tr_address_is_valid_for_peers(&pex->addr, pex->port))
|
||||||
if (tr_address_is_valid_for_peers(&pex->addr, pex->port))
|
|
||||||
{
|
{
|
||||||
ensureAtomExists(s, &pex->addr, pex->port, pex->flags, seedProbability, from);
|
ensureAtomExists(s, &pex->addr, pex->port, pex->flags, seedProbability, from);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
managerUnlock(s->manager);
|
managerUnlock(s->manager);
|
||||||
}
|
}
|
||||||
|
|
|
@ -865,7 +865,6 @@ static void sendLtepHandshake(tr_peerMsgs* msgs)
|
||||||
{
|
{
|
||||||
tr_variant val;
|
tr_variant val;
|
||||||
bool allow_pex;
|
bool allow_pex;
|
||||||
bool allow_metadata_xfer;
|
|
||||||
struct evbuffer* payload;
|
struct evbuffer* payload;
|
||||||
struct evbuffer* out = msgs->outMessages;
|
struct evbuffer* out = msgs->outMessages;
|
||||||
unsigned char const* ipv6 = tr_globalIPv6();
|
unsigned char const* ipv6 = tr_globalIPv6();
|
||||||
|
@ -885,14 +884,7 @@ static void sendLtepHandshake(tr_peerMsgs* msgs)
|
||||||
msgs->clientSentLtepHandshake = true;
|
msgs->clientSentLtepHandshake = true;
|
||||||
|
|
||||||
/* decide if we want to advertise metadata xfer support (BEP 9) */
|
/* decide if we want to advertise metadata xfer support (BEP 9) */
|
||||||
if (tr_torrentIsPrivate(msgs->torrent))
|
bool const allow_metadata_xfer = !tr_torrentIsPrivate(msgs->torrent);
|
||||||
{
|
|
||||||
allow_metadata_xfer = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
allow_metadata_xfer = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* decide if we want to advertise pex support */
|
/* decide if we want to advertise pex support */
|
||||||
if (!tr_torrentAllowsPex(msgs->torrent))
|
if (!tr_torrentAllowsPex(msgs->torrent))
|
||||||
|
@ -1028,13 +1020,11 @@ static void parseLtepHandshake(tr_peerMsgs* msgs, uint32_t len, struct evbuffer*
|
||||||
}
|
}
|
||||||
|
|
||||||
/* look for metainfo size (BEP 9) */
|
/* look for metainfo size (BEP 9) */
|
||||||
if (tr_variantDictFindInt(&val, TR_KEY_metadata_size, &i))
|
if (tr_variantDictFindInt(&val, TR_KEY_metadata_size, &i) &&
|
||||||
{
|
tr_torrentSetMetadataSizeHint(msgs->torrent, i))
|
||||||
if (tr_torrentSetMetadataSizeHint(msgs->torrent, i))
|
|
||||||
{
|
{
|
||||||
msgs->metadata_size_hint = (size_t)i;
|
msgs->metadata_size_hint = (size_t)i;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* look for upload_only (BEP 21) */
|
/* look for upload_only (BEP 21) */
|
||||||
if (tr_variantDictFindInt(&val, TR_KEY_upload_only, &i))
|
if (tr_variantDictFindInt(&val, TR_KEY_upload_only, &i))
|
||||||
|
@ -1050,14 +1040,18 @@ static void parseLtepHandshake(tr_peerMsgs* msgs, uint32_t len, struct evbuffer*
|
||||||
dbgmsg(msgs, "peer's port is now %d", (int)i);
|
dbgmsg(msgs, "peer's port is now %d", (int)i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tr_peerIoIsIncoming(msgs->io) && tr_variantDictFindRaw(&val, TR_KEY_ipv4, &addr, &addr_len) && addr_len == 4)
|
if (tr_peerIoIsIncoming(msgs->io) &&
|
||||||
|
tr_variantDictFindRaw(&val, TR_KEY_ipv4, &addr, &addr_len) &&
|
||||||
|
addr_len == 4)
|
||||||
{
|
{
|
||||||
pex.addr.type = TR_AF_INET;
|
pex.addr.type = TR_AF_INET;
|
||||||
memcpy(&pex.addr.addr.addr4, addr, 4);
|
memcpy(&pex.addr.addr.addr4, addr, 4);
|
||||||
tr_peerMgrAddPex(msgs->torrent, TR_PEER_FROM_LTEP, &pex, seedProbability);
|
tr_peerMgrAddPex(msgs->torrent, TR_PEER_FROM_LTEP, &pex, seedProbability);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tr_peerIoIsIncoming(msgs->io) && tr_variantDictFindRaw(&val, TR_KEY_ipv6, &addr, &addr_len) && addr_len == 16)
|
if (tr_peerIoIsIncoming(msgs->io) &&
|
||||||
|
tr_variantDictFindRaw(&val, TR_KEY_ipv6, &addr, &addr_len) &&
|
||||||
|
addr_len == 16)
|
||||||
{
|
{
|
||||||
pex.addr.type = TR_AF_INET6;
|
pex.addr.type = TR_AF_INET6;
|
||||||
memcpy(&pex.addr.addr.addr6, addr, 16);
|
memcpy(&pex.addr.addr.addr6, addr, 16);
|
||||||
|
@ -1933,14 +1927,11 @@ static void updateDesiredRequestCount(tr_peerMsgs* msgs)
|
||||||
msgs->desiredRequestCount = MAX(floor, estimatedBlocksInPeriod);
|
msgs->desiredRequestCount = MAX(floor, estimatedBlocksInPeriod);
|
||||||
|
|
||||||
/* honor the peer's maximum request count, if specified */
|
/* honor the peer's maximum request count, if specified */
|
||||||
if (msgs->reqq > 0)
|
if ((msgs->reqq > 0) && (msgs->desiredRequestCount > msgs->reqq))
|
||||||
{
|
|
||||||
if (msgs->desiredRequestCount > msgs->reqq)
|
|
||||||
{
|
{
|
||||||
msgs->desiredRequestCount = msgs->reqq;
|
msgs->desiredRequestCount = msgs->reqq;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void updateMetadataRequests(tr_peerMsgs* msgs, time_t now)
|
static void updateMetadataRequests(tr_peerMsgs* msgs, time_t now)
|
||||||
|
|
|
@ -1012,13 +1012,10 @@ static uint64_t setFromCtor(tr_torrent* tor, uint64_t fields, tr_ctor const* cto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((fields & TR_FR_MAX_PEERS) != 0)
|
if (((fields & TR_FR_MAX_PEERS) != 0) && tr_ctorGetPeerLimit(ctor, mode, &tor->maxConnectedPeers))
|
||||||
{
|
|
||||||
if (tr_ctorGetPeerLimit(ctor, mode, &tor->maxConnectedPeers))
|
|
||||||
{
|
{
|
||||||
ret |= TR_FR_MAX_PEERS;
|
ret |= TR_FR_MAX_PEERS;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ((fields & TR_FR_DOWNLOAD_DIR) != 0)
|
if ((fields & TR_FR_DOWNLOAD_DIR) != 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1407,9 +1407,11 @@ static char const* torrentSet(tr_session* session, tr_variant* args_in, tr_varia
|
||||||
|
|
||||||
if (tr_variantDictFindInt(args_in, TR_KEY_bandwidthPriority, &tmp))
|
if (tr_variantDictFindInt(args_in, TR_KEY_bandwidthPriority, &tmp))
|
||||||
{
|
{
|
||||||
if (tr_isPriority(tmp))
|
tr_priority_t const priority = (tr_priority_t)tmp;
|
||||||
|
|
||||||
|
if (tr_isPriority(priority))
|
||||||
{
|
{
|
||||||
tr_torrentSetPriority(tor, tmp);
|
tr_torrentSetPriority(tor, priority);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1712,15 +1714,13 @@ static void gotNewBlocklist(tr_session* session, bool did_connect, bool did_time
|
||||||
stream.avail_out = buflen;
|
stream.avail_out = buflen;
|
||||||
err = inflate(&stream, Z_NO_FLUSH);
|
err = inflate(&stream, Z_NO_FLUSH);
|
||||||
|
|
||||||
if (stream.avail_out < buflen)
|
if ((stream.avail_out < buflen) &&
|
||||||
{
|
(!tr_sys_file_write(fd, buf, buflen - stream.avail_out, NULL, &error)))
|
||||||
if (!tr_sys_file_write(fd, buf, buflen - stream.avail_out, NULL, &error))
|
|
||||||
{
|
{
|
||||||
tr_snprintf(result, sizeof(result), _("Couldn't save file \"%1$s\": %2$s"), filename, error->message);
|
tr_snprintf(result, sizeof(result), _("Couldn't save file \"%1$s\": %2$s"), filename, error->message);
|
||||||
tr_error_clear(&error);
|
tr_error_clear(&error);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (err != Z_OK)
|
if (err != Z_OK)
|
||||||
{
|
{
|
||||||
|
@ -1735,14 +1735,12 @@ static void gotNewBlocklist(tr_session* session, bool did_connect, bool did_time
|
||||||
|
|
||||||
inflateEnd(&stream);
|
inflateEnd(&stream);
|
||||||
|
|
||||||
if (err == Z_DATA_ERROR) /* couldn't inflate it... it's probably already uncompressed */
|
if ((err == Z_DATA_ERROR) && // couldn't inflate it... it's probably already uncompressed
|
||||||
{
|
!tr_sys_file_write(fd, response, response_byte_count, NULL, &error))
|
||||||
if (!tr_sys_file_write(fd, response, response_byte_count, NULL, &error))
|
|
||||||
{
|
{
|
||||||
tr_snprintf(result, sizeof(result), _("Couldn't save file \"%1$s\": %2$s"), filename, error->message);
|
tr_snprintf(result, sizeof(result), _("Couldn't save file \"%1$s\": %2$s"), filename, error->message);
|
||||||
tr_error_clear(&error);
|
tr_error_clear(&error);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
tr_sys_file_close(fd, NULL);
|
tr_sys_file_close(fd, NULL);
|
||||||
|
|
||||||
|
@ -1916,13 +1914,11 @@ static char const* torrentAdd(tr_session* session, tr_variant* args_in, tr_varia
|
||||||
|
|
||||||
char const* download_dir = NULL;
|
char const* download_dir = NULL;
|
||||||
|
|
||||||
if (tr_variantDictFindStr(args_in, TR_KEY_download_dir, &download_dir, NULL))
|
if (tr_variantDictFindStr(args_in, TR_KEY_download_dir, &download_dir, NULL) &&
|
||||||
{
|
tr_sys_path_is_relative(download_dir))
|
||||||
if (tr_sys_path_is_relative(download_dir))
|
|
||||||
{
|
{
|
||||||
return "download directory path is not absolute";
|
return "download directory path is not absolute";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int64_t i;
|
int64_t i;
|
||||||
bool boolVal;
|
bool boolVal;
|
||||||
|
@ -2046,21 +2042,17 @@ static char const* sessionSet(tr_session* session, tr_variant* args_in, tr_varia
|
||||||
char const* download_dir = NULL;
|
char const* download_dir = NULL;
|
||||||
char const* incomplete_dir = NULL;
|
char const* incomplete_dir = NULL;
|
||||||
|
|
||||||
if (tr_variantDictFindStr(args_in, TR_KEY_download_dir, &download_dir, NULL))
|
if (tr_variantDictFindStr(args_in, TR_KEY_download_dir, &download_dir, NULL) &&
|
||||||
{
|
tr_sys_path_is_relative(download_dir))
|
||||||
if (tr_sys_path_is_relative(download_dir))
|
|
||||||
{
|
{
|
||||||
return "download directory path is not absolute";
|
return "download directory path is not absolute";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (tr_variantDictFindStr(args_in, TR_KEY_incomplete_dir, &incomplete_dir, NULL))
|
if (tr_variantDictFindStr(args_in, TR_KEY_incomplete_dir, &incomplete_dir, NULL) &&
|
||||||
{
|
tr_sys_path_is_relative(incomplete_dir))
|
||||||
if (tr_sys_path_is_relative(incomplete_dir))
|
|
||||||
{
|
{
|
||||||
return "incomplete torrents directory path is not absolute";
|
return "incomplete torrents directory path is not absolute";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int64_t i;
|
int64_t i;
|
||||||
double d;
|
double d;
|
||||||
|
|
|
@ -184,18 +184,16 @@ bool tr_session_id_is_local(char const* session_id)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!tr_sys_file_lock(lock_file, TR_SYS_FILE_LOCK_SH | TR_SYS_FILE_LOCK_NB, &error))
|
if (!tr_sys_file_lock(lock_file, TR_SYS_FILE_LOCK_SH | TR_SYS_FILE_LOCK_NB, &error) &&
|
||||||
{
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
if (error->code == EWOULDBLOCK)
|
(error->code == EWOULDBLOCK))
|
||||||
#else
|
#else
|
||||||
if (error->code == ERROR_LOCK_VIOLATION)
|
(error->code == ERROR_LOCK_VIOLATION))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
ret = true;
|
ret = true;
|
||||||
tr_error_clear(&error);
|
tr_error_clear(&error);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
tr_sys_file_close(lock_file, NULL);
|
tr_sys_file_close(lock_file, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3042,14 +3042,11 @@ int tr_sessionCountQueueFreeSlots(tr_session* session, tr_direction dir)
|
||||||
|
|
||||||
while ((tor = tr_torrentNext(session, tor)) != NULL)
|
while ((tor = tr_torrentNext(session, tor)) != NULL)
|
||||||
{
|
{
|
||||||
if (!tr_torrentIsStalled(tor))
|
if (!tr_torrentIsStalled(tor) && (tr_torrentGetActivity(tor) == activity))
|
||||||
{
|
|
||||||
if (tr_torrentGetActivity(tor) == activity)
|
|
||||||
{
|
{
|
||||||
++active_count;
|
++active_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (active_count >= max)
|
if (active_count >= max)
|
||||||
{
|
{
|
||||||
|
|
|
@ -151,13 +151,11 @@ int tr_ctorSetMetainfoFromFile(tr_ctor* ctor, char const* filename)
|
||||||
{
|
{
|
||||||
char const* name;
|
char const* name;
|
||||||
|
|
||||||
if (!tr_variantDictFindStr(info, TR_KEY_name_utf_8, &name, NULL))
|
if (!tr_variantDictFindStr(info, TR_KEY_name_utf_8, &name, NULL) &&
|
||||||
{
|
!tr_variantDictFindStr(info, TR_KEY_name, &name, NULL))
|
||||||
if (!tr_variantDictFindStr(info, TR_KEY_name, &name, NULL))
|
|
||||||
{
|
{
|
||||||
name = NULL;
|
name = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (tr_str_is_empty(name))
|
if (tr_str_is_empty(name))
|
||||||
{
|
{
|
||||||
|
|
|
@ -109,14 +109,11 @@ tr_torrent* tr_torrentFindFromHash(tr_session* session, uint8_t const* torrentHa
|
||||||
|
|
||||||
while ((tor = tr_torrentNext(session, tor)) != NULL)
|
while ((tor = tr_torrentNext(session, tor)) != NULL)
|
||||||
{
|
{
|
||||||
if (*tor->info.hash == *torrentHash)
|
if ((*tor->info.hash == *torrentHash) && (memcmp(tor->info.hash, torrentHash, SHA_DIGEST_LENGTH) == 0))
|
||||||
{
|
|
||||||
if (memcmp(tor->info.hash, torrentHash, SHA_DIGEST_LENGTH) == 0)
|
|
||||||
{
|
{
|
||||||
return tor;
|
return tor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -157,26 +154,20 @@ bool tr_torrentIsPieceTransferAllowed(tr_torrent const* tor, tr_direction direct
|
||||||
|
|
||||||
bool allowed = true;
|
bool allowed = true;
|
||||||
|
|
||||||
if (tr_torrentUsesSpeedLimit(tor, direction))
|
if (tr_torrentUsesSpeedLimit(tor, direction) &&
|
||||||
{
|
tr_torrentGetSpeedLimit_Bps(tor, direction) <= 0)
|
||||||
if (tr_torrentGetSpeedLimit_Bps(tor, direction) <= 0)
|
|
||||||
{
|
{
|
||||||
allowed = false;
|
allowed = false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (tr_torrentUsesSessionLimits(tor))
|
if (tr_torrentUsesSessionLimits(tor))
|
||||||
{
|
{
|
||||||
unsigned int limit;
|
unsigned int limit = 0;
|
||||||
|
if (tr_sessionGetActiveSpeedLimit_Bps(tor->session, direction, &limit) && (limit <= 0))
|
||||||
if (tr_sessionGetActiveSpeedLimit_Bps(tor->session, direction, &limit))
|
|
||||||
{
|
|
||||||
if (limit <= 0)
|
|
||||||
{
|
{
|
||||||
allowed = false;
|
allowed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return allowed;
|
return allowed;
|
||||||
}
|
}
|
||||||
|
@ -209,23 +200,9 @@ static int peerIdTTL(tr_torrent const* tor)
|
||||||
|
|
||||||
unsigned char const* tr_torrentGetPeerId(tr_torrent* tor)
|
unsigned char const* tr_torrentGetPeerId(tr_torrent* tor)
|
||||||
{
|
{
|
||||||
bool needs_new_peer_id = false;
|
bool const needs_new_peer_id =
|
||||||
|
(*tor->peer_id == '\0') || // doesn't have one
|
||||||
if (*tor->peer_id == '\0')
|
(!tr_torrentIsPrivate(tor) && (peerIdTTL(tor) <= 0)); // has one but it's expired
|
||||||
{
|
|
||||||
needs_new_peer_id = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!needs_new_peer_id)
|
|
||||||
{
|
|
||||||
if (!tr_torrentIsPrivate(tor))
|
|
||||||
{
|
|
||||||
if (peerIdTTL(tor) <= 0)
|
|
||||||
{
|
|
||||||
needs_new_peer_id = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (needs_new_peer_id)
|
if (needs_new_peer_id)
|
||||||
{
|
{
|
||||||
|
@ -722,14 +699,11 @@ static tr_priority_t calculatePiecePriority(tr_torrent const* tor, tr_piece_inde
|
||||||
/* when dealing with multimedia files, getting the first and
|
/* when dealing with multimedia files, getting the first and
|
||||||
last pieces can sometimes allow you to preview it a bit
|
last pieces can sometimes allow you to preview it a bit
|
||||||
before it's fully downloaded... */
|
before it's fully downloaded... */
|
||||||
if (file->priority >= TR_PRI_NORMAL)
|
if ((file->priority >= TR_PRI_NORMAL) && (file->firstPiece == piece || file->lastPiece == piece))
|
||||||
{
|
|
||||||
if (file->firstPiece == piece || file->lastPiece == piece)
|
|
||||||
{
|
{
|
||||||
priority = TR_PRI_HIGH;
|
priority = TR_PRI_HIGH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return priority;
|
return priority;
|
||||||
}
|
}
|
||||||
|
@ -2774,14 +2748,12 @@ bool tr_torrentPieceNeedsCheck(tr_torrent const* tor, tr_piece_index_t p)
|
||||||
|
|
||||||
for (tr_file_index_t i = f; i < inf->fileCount && pieceHasFile(p, &inf->files[i]); ++i)
|
for (tr_file_index_t i = f; i < inf->fileCount && pieceHasFile(p, &inf->files[i]); ++i)
|
||||||
{
|
{
|
||||||
if (tr_cpFileIsComplete(&tor->completion, i))
|
if (tr_cpFileIsComplete(&tor->completion, i) &&
|
||||||
{
|
(tr_torrentGetFileMTime(tor, i) > inf->pieces[p].timeChecked))
|
||||||
if (tr_torrentGetFileMTime(tor, i) > inf->pieces[p].timeChecked)
|
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -3485,14 +3457,13 @@ static void tr_torrentPieceCompleted(tr_torrent* tor, tr_piece_index_t pieceInde
|
||||||
{
|
{
|
||||||
tr_file const* file = &tor->info.files[i];
|
tr_file const* file = &tor->info.files[i];
|
||||||
|
|
||||||
if (file->firstPiece <= pieceIndex && pieceIndex <= file->lastPiece)
|
if ((file->firstPiece <= pieceIndex) &&
|
||||||
{
|
(pieceIndex <= file->lastPiece) &&
|
||||||
if (tr_cpFileIsComplete(&tor->completion, i))
|
tr_cpFileIsComplete(&tor->completion, i))
|
||||||
{
|
{
|
||||||
tr_torrentFileCompleted(tor, i);
|
tr_torrentFileCompleted(tor, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tr_torrentGotBlock(tr_torrent* tor, tr_block_index_t block)
|
void tr_torrentGotBlock(tr_torrent* tor, tr_block_index_t block)
|
||||||
|
@ -3736,23 +3707,21 @@ void tr_torrentSetQueuePosition(tr_torrent* tor, int pos)
|
||||||
|
|
||||||
while ((walk = tr_torrentNext(tor->session, walk)) != NULL)
|
while ((walk = tr_torrentNext(tor->session, walk)) != NULL)
|
||||||
{
|
{
|
||||||
if (old_pos < pos)
|
if ((old_pos < pos) &&
|
||||||
{
|
(old_pos <= walk->queuePosition) &&
|
||||||
if (old_pos <= walk->queuePosition && walk->queuePosition <= pos)
|
(walk->queuePosition <= pos))
|
||||||
{
|
{
|
||||||
walk->queuePosition--;
|
walk->queuePosition--;
|
||||||
walk->anyDate = now;
|
walk->anyDate = now;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (old_pos > pos)
|
if ((old_pos > pos) &&
|
||||||
{
|
(pos <= walk->queuePosition) &&
|
||||||
if (pos <= walk->queuePosition && walk->queuePosition < old_pos)
|
(walk->queuePosition < old_pos))
|
||||||
{
|
{
|
||||||
walk->queuePosition++;
|
walk->queuePosition++;
|
||||||
walk->anyDate = now;
|
walk->anyDate = now;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (back < walk->queuePosition)
|
if (back < walk->queuePosition)
|
||||||
{
|
{
|
||||||
|
|
|
@ -583,13 +583,10 @@ bool tr_dhtAddNode(tr_session* ss, tr_address const* address, tr_port port, bool
|
||||||
/* Since we don't want to abuse our bootstrap nodes,
|
/* Since we don't want to abuse our bootstrap nodes,
|
||||||
* we don't ping them if the DHT is in a good state. */
|
* we don't ping them if the DHT is in a good state. */
|
||||||
|
|
||||||
if (bootstrap)
|
if (bootstrap && (tr_dhtStatus(ss, af, NULL) >= TR_DHT_FIREWALLED))
|
||||||
{
|
|
||||||
if (tr_dhtStatus(ss, af, NULL) >= TR_DHT_FIREWALLED)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (address->type == TR_AF_INET)
|
if (address->type == TR_AF_INET)
|
||||||
{
|
{
|
||||||
|
|
|
@ -182,7 +182,7 @@ enum
|
||||||
UPNP_IGD_INVALID = 3
|
UPNP_IGD_INVALID = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
int tr_upnpPulse(tr_upnp* handle, int port, bool isEnabled, bool doPortCheck)
|
int tr_upnpPulse(tr_upnp* handle, tr_port port, bool isEnabled, bool doPortCheck)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -212,23 +212,22 @@ int tr_upnpPulse(tr_upnp* handle, int port, bool isEnabled, bool doPortCheck)
|
||||||
freeUPNPDevlist(devlist);
|
freeUPNPDevlist(devlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handle->state == TR_UPNP_IDLE)
|
if ((handle->state == TR_UPNP_IDLE) &&
|
||||||
{
|
(handle->isMapped) &&
|
||||||
if (handle->isMapped && (!isEnabled || handle->port != port))
|
(!isEnabled || handle->port != port))
|
||||||
{
|
{
|
||||||
handle->state = TR_UPNP_UNMAP;
|
handle->state = TR_UPNP_UNMAP;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (isEnabled && handle->isMapped && doPortCheck)
|
if (isEnabled &&
|
||||||
{
|
handle->isMapped &&
|
||||||
if (tr_upnpGetSpecificPortMappingEntry(handle, "TCP") != UPNPCOMMAND_SUCCESS ||
|
doPortCheck &&
|
||||||
tr_upnpGetSpecificPortMappingEntry(handle, "UDP") != UPNPCOMMAND_SUCCESS)
|
((tr_upnpGetSpecificPortMappingEntry(handle, "TCP") != UPNPCOMMAND_SUCCESS) ||
|
||||||
|
(tr_upnpGetSpecificPortMappingEntry(handle, "UDP") != UPNPCOMMAND_SUCCESS)))
|
||||||
{
|
{
|
||||||
tr_logAddNamedInfo(getKey(), _("Port %d isn't forwarded"), handle->port);
|
tr_logAddNamedInfo(getKey(), _("Port %d isn't forwarded"), handle->port);
|
||||||
handle->isMapped = false;
|
handle->isMapped = false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (handle->state == TR_UPNP_UNMAP)
|
if (handle->state == TR_UPNP_UNMAP)
|
||||||
{
|
{
|
||||||
|
@ -243,18 +242,13 @@ int tr_upnpPulse(tr_upnp* handle, int port, bool isEnabled, bool doPortCheck)
|
||||||
handle->port = -1;
|
handle->port = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handle->state == TR_UPNP_IDLE)
|
if ((handle->state == TR_UPNP_IDLE) && isEnabled && !handle->isMapped)
|
||||||
{
|
|
||||||
if (isEnabled && !handle->isMapped)
|
|
||||||
{
|
{
|
||||||
handle->state = TR_UPNP_MAP;
|
handle->state = TR_UPNP_MAP;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (handle->state == TR_UPNP_MAP)
|
if (handle->state == TR_UPNP_MAP)
|
||||||
{
|
{
|
||||||
int err_tcp = -1;
|
|
||||||
int err_udp = -1;
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
if (handle->urls.controlURL == NULL)
|
if (handle->urls.controlURL == NULL)
|
||||||
|
@ -266,8 +260,8 @@ int tr_upnpPulse(tr_upnp* handle, int port, bool isEnabled, bool doPortCheck)
|
||||||
char desc[64];
|
char desc[64];
|
||||||
tr_snprintf(desc, sizeof(desc), "%s at %d", TR_NAME, port);
|
tr_snprintf(desc, sizeof(desc), "%s at %d", TR_NAME, port);
|
||||||
|
|
||||||
err_tcp = tr_upnpAddPortMapping(handle, "TCP", port, desc);
|
int const err_tcp = tr_upnpAddPortMapping(handle, "TCP", port, desc);
|
||||||
err_udp = tr_upnpAddPortMapping(handle, "UDP", port, desc);
|
int const err_udp = tr_upnpAddPortMapping(handle, "UDP", port, desc);
|
||||||
|
|
||||||
handle->isMapped = err_tcp == 0 || err_udp == 0;
|
handle->isMapped = err_tcp == 0 || err_udp == 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,6 @@ tr_upnp* tr_upnpInit(void);
|
||||||
|
|
||||||
void tr_upnpClose(tr_upnp*);
|
void tr_upnpClose(tr_upnp*);
|
||||||
|
|
||||||
int tr_upnpPulse(tr_upnp*, int port, bool isEnabled, bool doPortCheck);
|
int tr_upnpPulse(tr_upnp*, tr_port port, bool isEnabled, bool doPortCheck);
|
||||||
|
|
||||||
/* @} */
|
/* @} */
|
||||||
|
|
|
@ -1877,13 +1877,10 @@ void* tr_valloc(size_t bufLen)
|
||||||
|
|
||||||
#ifdef HAVE_POSIX_MEMALIGN
|
#ifdef HAVE_POSIX_MEMALIGN
|
||||||
|
|
||||||
if (buf == NULL)
|
if ((buf == NULL) && (posix_memalign(&buf, pageSize, allocLen) != 0))
|
||||||
{
|
|
||||||
if (posix_memalign(&buf, pageSize, allocLen) != 0)
|
|
||||||
{
|
{
|
||||||
buf = NULL; /* just retry with valloc/malloc */
|
buf = NULL; /* just retry with valloc/malloc */
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -357,23 +357,21 @@ bool tr_variantGetBool(tr_variant const* v, bool* setme)
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success && tr_variantIsInt(v))
|
if ((!success) &&
|
||||||
{
|
tr_variantIsInt(v) &&
|
||||||
if (v->val.i == 0 || v->val.i == 1)
|
(v->val.i == 0 || v->val.i == 1))
|
||||||
{
|
{
|
||||||
*setme = v->val.i != 0;
|
*setme = v->val.i != 0;
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!success && tr_variantGetStr(v, &str, NULL))
|
if ((!success) &&
|
||||||
{
|
tr_variantGetStr(v, &str, NULL) &&
|
||||||
if (strcmp(str, "true") == 0 || strcmp(str, "false") == 0)
|
(strcmp(str, "true") == 0 || strcmp(str, "false") == 0))
|
||||||
{
|
{
|
||||||
*setme = strcmp(str, "true") == 0;
|
*setme = strcmp(str, "true") == 0;
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,33 +234,14 @@ tr_watchdir_t tr_watchdir_new(char const* path, tr_watchdir_cb callback, void* c
|
||||||
handle->event_base = event_base;
|
handle->event_base = event_base;
|
||||||
tr_watchdir_retries_init(&handle->active_retries);
|
tr_watchdir_retries_init(&handle->active_retries);
|
||||||
|
|
||||||
if (!force_generic)
|
if (!force_generic && (handle->backend == NULL))
|
||||||
{
|
|
||||||
#ifdef WITH_INOTIFY
|
|
||||||
|
|
||||||
if (handle->backend == NULL)
|
|
||||||
{
|
{
|
||||||
|
#if defined(WITH_INOTIFY)
|
||||||
handle->backend = tr_watchdir_inotify_new(handle);
|
handle->backend = tr_watchdir_inotify_new(handle);
|
||||||
}
|
#elif defined(WITH_KQUEUE)
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WITH_KQUEUE
|
|
||||||
|
|
||||||
if (handle->backend == NULL)
|
|
||||||
{
|
|
||||||
handle->backend = tr_watchdir_kqueue_new(handle);
|
handle->backend = tr_watchdir_kqueue_new(handle);
|
||||||
}
|
#elif defined(_WIN32)
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
|
|
||||||
if (handle->backend == NULL)
|
|
||||||
{
|
|
||||||
handle->backend = tr_watchdir_win32_new(handle);
|
handle->backend = tr_watchdir_win32_new(handle);
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
<body>
|
<body>
|
||||||
<p><a name="ax-index" id="ax-index"></a><a name="ax-index-link" id="ax-index-link"></a></p>
|
<p><a name="ax-index" id="ax-index"></a><a name="ax-index-link" id="ax-index-link"></a></p>
|
||||||
|
|
||||||
<a name="menus"></a>
|
|
||||||
|
|
||||||
<div id="banner">
|
<div id="banner">
|
||||||
<div id="machelp">
|
<div id="machelp">
|
||||||
<a class="bread" href="../index.html">Transmission Help</a>
|
<a class="bread" href="../index.html">Transmission Help</a>
|
||||||
|
@ -22,179 +20,92 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="letters">
|
|
||||||
<span style="font: Lucida grande, arial, sans-serif"><strong>Index</strong></span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="terms">
|
<div id="terms">
|
||||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
<table style="width: 100%; border-width: 0; padding: 0">
|
||||||
|
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="blue" valign="top" width="175">
|
<th style="font: Lucida grande, arial, sans-serif"><strong>Index</strong></th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="blue">
|
||||||
<p><a href="pffirewall.html">Firewall</a></p>
|
<p><a href="pffirewall.html">Firewall</a></p>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="blue" valign="top" width="18"></td>
|
|
||||||
|
|
||||||
<td class="blue" valign="top" width="250">
|
|
||||||
<p class="seealso"> </p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="blue" valign="top">
|
<td class="blue">
|
||||||
<p><a href="FAQ.html">Frequently Asked Questions</a></p>
|
<p><a href="FAQ.html">Frequently Asked Questions</a></p>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="blue" valign="top" width="18"></td>
|
|
||||||
|
|
||||||
<td class="blue" valign="top" width="250">
|
|
||||||
<p class="seealso"> </p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="blue" valign="top" width="135">
|
<td class="blue">
|
||||||
<p><a href="gettingstarted.html">Getting Started</a></p>
|
<p><a href="gettingstarted.html">Getting Started</a></p>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="blue" valign="top" width="18"></td>
|
|
||||||
|
|
||||||
<td class="blue" valign="top" width="250">
|
|
||||||
<p class="seealso"> </p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="blue" valign="top">
|
<td class="blue">
|
||||||
<p><a href="usingt.html">Managing your transfers</a></p>
|
<p><a href="usingt.html">Managing your transfers</a></p>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="blue" valign="top" width="18"></td>
|
|
||||||
|
|
||||||
<td class="blue" valign="top" width="250">
|
|
||||||
<p class="seealso"> </p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="blue" valign="top" width=150">
|
<td class="blue">
|
||||||
<p><a href="check.html">Manual torrent verification</a></p>
|
<p><a href="check.html">Manual torrent verification</a></p>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="blue" valign="top" width="18"></td>
|
|
||||||
|
|
||||||
<td class="blue" valign="top" width="250">
|
|
||||||
<p class="seealso"> </p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="blue" valign="top" width="135">
|
<td class="blue">
|
||||||
<p><a href="Speed.html">Maximizing download speed</a></p>
|
<p><a href="Speed.html">Maximizing download speed</a></p>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="blue" valign="top" width="18"></td>
|
|
||||||
|
|
||||||
<td class="blue" valign="top" width="250">
|
|
||||||
<p class="seealso"> </p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="blue" valign="top" width="135">
|
<td class="blue">
|
||||||
<p><a href="network.html">Network preferences</a></p>
|
<p><a href="network.html">Network preferences</a></p>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="blue" valign="top" width="18"></td>
|
|
||||||
|
|
||||||
<td class="blue" valign="top" width="250">
|
|
||||||
<p class="seealso"> </p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="blue" valign="top" width="135">
|
<td class="blue">
|
||||||
<p><a href="peers.html">Peer preferences</a></p>
|
<p><a href="peers.html">Peer preferences</a></p>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="blue" valign="top" width="18"></td>
|
|
||||||
|
|
||||||
<td class="blue" valign="top" width="250">
|
|
||||||
<p class="seealso"> </p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="blue" valign="top" width="135">
|
<td class="blue">
|
||||||
<p><a href="portforward.html">Port Forwarding FAQ</a></p>
|
<p><a href="portforward.html">Port Forwarding FAQ</a></p>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="blue" valign="top" width="18"></td>
|
|
||||||
|
|
||||||
<td class="blue" valign="top" width="250">
|
|
||||||
<p class="seealso"> </p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="blue" valign="top" width="135">
|
<td class="blue">
|
||||||
<p><a href="remote.html">Remote</a></p>
|
<p><a href="remote.html">Remote</a></p>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="blue" valign="top" width="18"></td>
|
|
||||||
|
|
||||||
<td class="blue" valign="top" width="250">
|
|
||||||
<p class="seealso"> </p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="blue" valign="top" width="135">
|
<td class="blue">
|
||||||
<p><a href="scripts.html">Running Scripts</a></p>
|
<p><a href="scripts.html">Running Scripts</a></p>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="blue" valign="top" width="18"></td>
|
|
||||||
|
|
||||||
<td class="blue" valign="top" width="250">
|
|
||||||
<p class="seealso"> </p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="blue" valign="top" width="135">
|
<td class="blue">
|
||||||
<p><a href="pfrouter.html">Router</a></p>
|
<p><a href="pfrouter.html">Router</a></p>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="blue" valign="top" width="18"></td>
|
|
||||||
|
|
||||||
<td class="blue" valign="top" width="250">
|
|
||||||
<p class="seealso"> </p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="blue" valign="top" width="135">
|
<td class="blue">
|
||||||
<p><a href="tracker.html">Tracker information</a></p>
|
<p><a href="tracker.html">Tracker information</a></p>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="blue" valign="top" width="18"></td>
|
|
||||||
|
|
||||||
<td class="blue" valign="top" width="250">
|
|
||||||
<p class="seealso"> </p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="blue" valign="top" width="135">
|
<td class="blue">
|
||||||
<p><a href="troubleshoot.html">Troubleshooting port issues</a></p>
|
<p><a href="troubleshoot.html">Troubleshooting port issues</a></p>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="blue" valign="top" width="18"></td>
|
|
||||||
|
|
||||||
<td class="blue" valign="top" width="250">
|
|
||||||
<p class="seealso"> </p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
<div id="mainbox">
|
<div id="mainbox">
|
||||||
<div id="caticon">
|
<div id="caticon">
|
||||||
<img src="../gfx/TransmissionIcon.png" alt="Transmission Icon" height="32" width="32" border="0">
|
<img src="../gfx/TransmissionIcon.png" alt="Transmission Logo" height="32" width="32" border="0">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="pagetitle">
|
<div class="pagetitle">
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="150"><img src="../gfx/open.png" height="auto" width="150" border="0"></td>
|
<td valign="top" width="150"><img alt="adding a torrent" src="../gfx/open.png" height="auto" width="150" border="0"></td>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<p>Download your file's associated 'torrent file' (extension .torrent). These are commonly found at <a href="http://en.wikipedia.org/wiki/BitTorrent_tracker">'tracker' websites</a>.
|
<p>Download your file's associated 'torrent file' (extension .torrent). These are commonly found at <a href="http://en.wikipedia.org/wiki/BitTorrent_tracker">'tracker' websites</a>.
|
||||||
<p>Once you have the torrent file, drag it into Transmission - downloading should start immediately.
|
<p>Once you have the torrent file, drag it into Transmission - downloading should start immediately.
|
||||||
|
@ -58,7 +58,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="150"><img src="../gfx/creation.png" height="auto" width="150" border="0"></td>
|
<td valign="top" width="150"><img alt="creating a torrent" src="../gfx/creation.png" height="auto" width="150" border="0"></td>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<p>Yes, you can share a file or folder by dragging it into Transmission. Alternatively, click 'Create' in the toolbar, and choose your file.
|
<p>Yes, you can share a file or folder by dragging it into Transmission. Alternatively, click 'Create' in the toolbar, and choose your file.
|
||||||
<p>When the dialog box appears, enter your tracker address (or addresses), comments, and private status.
|
<p>When the dialog box appears, enter your tracker address (or addresses), comments, and private status.
|
||||||
|
@ -75,7 +75,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="150"><img src="../gfx/scheduler.png" height="auto" width="150" border="0"></td>
|
<td valign="top" width="150"><img alt="scheduler" src="../gfx/scheduler.png" height="auto" width="150" border="0"></td>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<p>Yes, by using 'Speed Limit Mode'. Simply go to Preferences -> Bandwidth, and then set both the speed you would like Transmission to be limited to, as well as the period of time you would like the limits applied.
|
<p>Yes, by using 'Speed Limit Mode'. Simply go to Preferences -> Bandwidth, and then set both the speed you would like Transmission to be limited to, as well as the period of time you would like the limits applied.
|
||||||
<p>When Speed Limit Mode is enabled, the turtle will be illuminated in blue.</p>
|
<p>When Speed Limit Mode is enabled, the turtle will be illuminated in blue.</p>
|
||||||
|
@ -90,7 +90,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="150"><img src="../gfx/queue.png" height="auto" width="150" border="0"></td>
|
<td valign="top" width="150"><img alt="queue" src="../gfx/queue.png" height="auto" width="150" border="0"></td>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<p>Yes, you can queue seeding and/or downloading transfers via Preferences -> Transfers -> Management.
|
<p>Yes, you can queue seeding and/or downloading transfers via Preferences -> Transfers -> Management.
|
||||||
<p>The queue system is very simple: You start and pause transfers as usual, but if you're over the queue limit starting a transfer will instead make it "Waiting to download..."
|
<p>The queue system is very simple: You start and pause transfers as usual, but if you're over the queue limit starting a transfer will instead make it "Waiting to download..."
|
||||||
|
@ -107,7 +107,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="150"><img src="../gfx/group.png" height="auto" width="150" border="0"></td>
|
<td valign="top" width="150"><img alt="groups" src="../gfx/group.png" height="auto" width="150" border="0"></td>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<p>Transmission allows you to sort your torrents by various criteria. Choose "Sort Transfers By" in the View menu, as well as the Action menu.
|
<p>Transmission allows you to sort your torrents by various criteria. Choose "Sort Transfers By" in the View menu, as well as the Action menu.
|
||||||
<p>You can also filter your torrents by their activity state. Simply enable the Filter bar in the View menu.
|
<p>You can also filter your torrents by their activity state. Simply enable the Filter bar in the View menu.
|
||||||
|
@ -125,7 +125,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="150"><img src="../gfx/inspector.png" height="auto" width="150" border="0"></td>
|
<td valign="top" width="150"><img alt="inspector" src="../gfx/inspector.png" height="auto" width="150" border="0"></td>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<p>Click the Inspector icon, or simply double-click any transfer in the main window.
|
<p>Click the Inspector icon, or simply double-click any transfer in the main window.
|
||||||
<p>The inspector gives you:
|
<p>The inspector gives you:
|
||||||
|
@ -147,7 +147,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="150"><img src="../gfx/fileselection.png" height="auto" width="150" border="0"></td>
|
<td valign="top" width="150"><img alt="file selection" src="../gfx/fileselection.png" height="auto" width="150" border="0"></td>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<p>Yes, either upon opening a torrent, or once it has started. When you open a multi-file torrent, a detailed Open window will appear, allowing you to select specific files.
|
<p>Yes, either upon opening a torrent, or once it has started. When you open a multi-file torrent, a detailed Open window will appear, allowing you to select specific files.
|
||||||
<p>For transfers which are already running, double click them to open the Inspector, and then click the 'Files' tab. Simply check the boxes next to the files you want to download (the default is all of them).
|
<p>For transfers which are already running, double click them to open the Inspector, and then click the 'Files' tab. Simply check the boxes next to the files you want to download (the default is all of them).
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<html>
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||||
|
@ -11,12 +12,12 @@
|
||||||
<body bgcolor="white" marginheight="0" marginwidth="0" topmargin="0">
|
<body bgcolor="white" marginheight="0" marginwidth="0" topmargin="0">
|
||||||
<div id="frame">
|
<div id="frame">
|
||||||
<div id="contentleft">
|
<div id="contentleft">
|
||||||
<center>
|
<div style="text-align: center;">
|
||||||
<IMG SRC="gfx/TransWindow.png" height="auto" width="225" ALT="Image of Transmission window" BORDER="0">
|
<IMG SRC="gfx/TransWindow.png" height="auto" width="225" ALT="Image of Transmission window" BORDER="0">
|
||||||
<h1><img class="icon" src="gfx/TransmissionIcon.png" alt="Transmission icon" height="32" width="32" border="0"> Transmission Help</h1>
|
<h1><img class="icon" src="gfx/TransmissionIcon.png" alt="Transmission icon" height="32" width="32" border="0"> Transmission Help</h1>
|
||||||
|
|
||||||
<h4><a href="https://transmissionbt.com/">transmissionbt.com</a></h4>
|
<h4><a href="https://transmissionbt.com/">transmissionbt.com</a></h4>
|
||||||
</center>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="contentcenter"></div>
|
<div id="contentcenter"></div>
|
||||||
<div id="contentright">
|
<div id="contentright">
|
||||||
|
|
|
@ -22,7 +22,7 @@ class AboutDialog : public BaseDialog
|
||||||
TR_DISABLE_COPY_MOVE(AboutDialog)
|
TR_DISABLE_COPY_MOVE(AboutDialog)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AboutDialog(QWidget* parent = nullptr);
|
explicit AboutDialog(QWidget* parent = nullptr);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void showCredits();
|
void showCredits();
|
||||||
|
|
|
@ -27,7 +27,7 @@ public:
|
||||||
public:
|
public:
|
||||||
AddData() = default;
|
AddData() = default;
|
||||||
|
|
||||||
AddData(QString const& str)
|
explicit AddData(QString const& str)
|
||||||
{
|
{
|
||||||
set(str);
|
set(str);
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,10 +185,9 @@ Application::Application(int& argc, char** argv) :
|
||||||
|
|
||||||
for (QString const& filename : filenames)
|
for (QString const& filename : filenames)
|
||||||
{
|
{
|
||||||
|
auto const a = AddData(filename);
|
||||||
QString metainfo;
|
QString metainfo;
|
||||||
|
|
||||||
AddData a(filename);
|
|
||||||
|
|
||||||
switch (a.type)
|
switch (a.type)
|
||||||
{
|
{
|
||||||
case AddData::URL:
|
case AddData::URL:
|
||||||
|
@ -290,7 +289,7 @@ Application::Application(int& argc, char** argv) :
|
||||||
connect(session_, &Session::sourceChanged, this, &Application::onSessionSourceChanged);
|
connect(session_, &Session::sourceChanged, this, &Application::onSessionSourceChanged);
|
||||||
connect(session_, &Session::torrentsRemoved, model_, &TorrentModel::removeTorrents);
|
connect(session_, &Session::torrentsRemoved, model_, &TorrentModel::removeTorrents);
|
||||||
connect(session_, &Session::torrentsUpdated, model_, &TorrentModel::updateTorrents);
|
connect(session_, &Session::torrentsUpdated, model_, &TorrentModel::updateTorrents);
|
||||||
connect(watch_dir_, &WatchDir::torrentFileAdded, this, &Application::addTorrent);
|
connect(watch_dir_, &WatchDir::torrentFileAdded, this, qOverload<QString const&>(&Application::addTorrent));
|
||||||
|
|
||||||
// init from preferences
|
// init from preferences
|
||||||
for (auto const key : { Prefs::DIR_WATCH })
|
for (auto const key : { Prefs::DIR_WATCH })
|
||||||
|
@ -550,6 +549,11 @@ void Application::refreshTorrents()
|
||||||
****
|
****
|
||||||
***/
|
***/
|
||||||
|
|
||||||
|
void Application::addTorrent(QString const& addme)
|
||||||
|
{
|
||||||
|
addTorrent(AddData(addme));
|
||||||
|
}
|
||||||
|
|
||||||
void Application::addTorrent(AddData const& addme)
|
void Application::addTorrent(AddData const& addme)
|
||||||
{
|
{
|
||||||
if (addme.type == addme.NONE)
|
if (addme.type == addme.NONE)
|
||||||
|
|
|
@ -44,6 +44,7 @@ public:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void addTorrent(AddData const&);
|
void addTorrent(AddData const&);
|
||||||
|
void addTorrent(QString const&);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void consentGiven(int result);
|
void consentGiven(int result);
|
||||||
|
|
|
@ -22,7 +22,7 @@ class ColumnResizer : public QObject
|
||||||
TR_DISABLE_COPY_MOVE(ColumnResizer)
|
TR_DISABLE_COPY_MOVE(ColumnResizer)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ColumnResizer(QObject* parent = nullptr);
|
explicit ColumnResizer(QObject* parent = nullptr);
|
||||||
|
|
||||||
void addLayout(QGridLayout* layout);
|
void addLayout(QGridLayout* layout);
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ class FileTreeDelegate : public QItemDelegate
|
||||||
TR_DISABLE_COPY_MOVE(FileTreeDelegate)
|
TR_DISABLE_COPY_MOVE(FileTreeDelegate)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FileTreeDelegate(QObject* parent = nullptr) :
|
explicit FileTreeDelegate(QObject* parent = nullptr) :
|
||||||
QItemDelegate(parent)
|
QItemDelegate(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,9 +129,7 @@ void FileTreeView::resizeEvent(QResizeEvent* event)
|
||||||
|
|
||||||
void FileTreeView::keyPressEvent(QKeyEvent* event)
|
void FileTreeView::keyPressEvent(QKeyEvent* event)
|
||||||
{
|
{
|
||||||
if (state() != EditingState)
|
if ((state() != EditingState) && (event->key() == Qt::Key_Space))
|
||||||
{
|
|
||||||
if (event->key() == Qt::Key_Space)
|
|
||||||
{
|
{
|
||||||
// handle using the keyboard to toggle the
|
// handle using the keyboard to toggle the
|
||||||
// wanted/unwanted state or the file priority
|
// wanted/unwanted state or the file priority
|
||||||
|
@ -150,7 +148,6 @@ void FileTreeView::keyPressEvent(QKeyEvent* event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
QTreeView::keyPressEvent(event);
|
QTreeView::keyPressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -343,7 +343,7 @@ void FilterBar::onActivityIndexChanged(int i)
|
||||||
{
|
{
|
||||||
if (!is_bootstrapping_)
|
if (!is_bootstrapping_)
|
||||||
{
|
{
|
||||||
FilterMode const mode = activity_combo_->itemData(i, ACTIVITY_ROLE).toInt();
|
auto const mode = FilterMode(activity_combo_->itemData(i, ACTIVITY_ROLE).toInt());
|
||||||
prefs_.set(Prefs::FILTER_MODE, mode);
|
prefs_.set(Prefs::FILTER_MODE, mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FilterBarComboBox(QWidget* parent = nullptr);
|
explicit FilterBarComboBox(QWidget* parent = nullptr);
|
||||||
|
|
||||||
// QWidget
|
// QWidget
|
||||||
QSize minimumSizeHint() const override;
|
QSize minimumSizeHint() const override;
|
||||||
|
|
|
@ -29,7 +29,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FilterMode(int mode = SHOW_ALL) :
|
explicit FilterMode(int mode = SHOW_ALL) :
|
||||||
mode_(mode)
|
mode_(mode)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SortMode(int mode = SORT_BY_ID) :
|
explicit SortMode(int mode = SORT_BY_ID) :
|
||||||
mode_(mode)
|
mode_(mode)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ class IconToolButton : public QToolButton
|
||||||
TR_DISABLE_COPY_MOVE(IconToolButton)
|
TR_DISABLE_COPY_MOVE(IconToolButton)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IconToolButton(QWidget* parent = nullptr);
|
explicit IconToolButton(QWidget* parent = nullptr);
|
||||||
|
|
||||||
// QWidget
|
// QWidget
|
||||||
QSize sizeHint() const override;
|
QSize sizeHint() const override;
|
||||||
|
|
|
@ -30,7 +30,7 @@ class InteropObject : public QObject
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InteropObject(QObject* parent = nullptr);
|
explicit InteropObject(QObject* parent = nullptr);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool PresentWindow();
|
bool PresentWindow();
|
||||||
|
|
|
@ -18,7 +18,7 @@ class LicenseDialog : public BaseDialog
|
||||||
TR_DISABLE_COPY_MOVE(LicenseDialog)
|
TR_DISABLE_COPY_MOVE(LicenseDialog)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LicenseDialog(QWidget* parent = nullptr);
|
explicit LicenseDialog(QWidget* parent = nullptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::LicenseDialog ui_ = {};
|
Ui::LicenseDialog ui_ = {};
|
||||||
|
|
|
@ -1295,7 +1295,7 @@ void MainWindow::openURL()
|
||||||
str.clear();
|
str.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
addTorrent(str, true);
|
addTorrent(AddData(str), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::addTorrents(QStringList const& filenames)
|
void MainWindow::addTorrents(QStringList const& filenames)
|
||||||
|
@ -1316,7 +1316,7 @@ void MainWindow::addTorrents(QStringList const& filenames)
|
||||||
|
|
||||||
for (QString const& filename : filenames)
|
for (QString const& filename : filenames)
|
||||||
{
|
{
|
||||||
addTorrent(filename, show_options);
|
addTorrent(AddData(filename), show_options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1589,7 +1589,7 @@ void MainWindow::dropEvent(QDropEvent* event)
|
||||||
key = url.toLocalFile();
|
key = url.toLocalFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
qApp->addTorrent(key);
|
qApp->addTorrent(AddData(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PathButton(QWidget* parent = nullptr);
|
explicit PathButton(QWidget* parent = nullptr);
|
||||||
|
|
||||||
void setMode(Mode mode);
|
void setMode(Mode mode);
|
||||||
void setTitle(QString const& title);
|
void setTitle(QString const& title);
|
||||||
|
|
|
@ -133,7 +133,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Prefs(QString config_dir);
|
explicit Prefs(QString config_dir);
|
||||||
~Prefs() override;
|
~Prefs() override;
|
||||||
|
|
||||||
bool isCore(int key) const
|
bool isCore(int key) const
|
||||||
|
|
|
@ -209,35 +209,35 @@ void PrefsDialog::linkWidgetToPref(QWidget* widget, int pref_key)
|
||||||
updateWidgetValue(widget, pref_key);
|
updateWidgetValue(widget, pref_key);
|
||||||
widgets_.insert(pref_key, widget);
|
widgets_.insert(pref_key, widget);
|
||||||
|
|
||||||
auto* check_box = qobject_cast<QCheckBox*>(widget);
|
auto const* check_box = qobject_cast<QCheckBox*>(widget);
|
||||||
if (check_box != nullptr)
|
if (check_box != nullptr)
|
||||||
{
|
{
|
||||||
connect(check_box, &QAbstractButton::toggled, this, &PrefsDialog::checkBoxToggled);
|
connect(check_box, &QAbstractButton::toggled, this, &PrefsDialog::checkBoxToggled);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* time_edit = qobject_cast<QTimeEdit*>(widget);
|
auto const* time_edit = qobject_cast<QTimeEdit*>(widget);
|
||||||
if (time_edit != nullptr)
|
if (time_edit != nullptr)
|
||||||
{
|
{
|
||||||
connect(time_edit, &QAbstractSpinBox::editingFinished, this, &PrefsDialog::timeEditingFinished);
|
connect(time_edit, &QAbstractSpinBox::editingFinished, this, &PrefsDialog::timeEditingFinished);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* line_edit = qobject_cast<QLineEdit*>(widget);
|
auto const* line_edit = qobject_cast<QLineEdit*>(widget);
|
||||||
if (line_edit != nullptr)
|
if (line_edit != nullptr)
|
||||||
{
|
{
|
||||||
connect(line_edit, &QLineEdit::editingFinished, this, &PrefsDialog::lineEditingFinished);
|
connect(line_edit, &QLineEdit::editingFinished, this, &PrefsDialog::lineEditingFinished);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* path_button = qobject_cast<PathButton*>(widget);
|
auto const* path_button = qobject_cast<PathButton*>(widget);
|
||||||
if (path_button != nullptr)
|
if (path_button != nullptr)
|
||||||
{
|
{
|
||||||
connect(path_button, &PathButton::pathChanged, this, &PrefsDialog::pathChanged);
|
connect(path_button, &PathButton::pathChanged, this, &PrefsDialog::pathChanged);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* spin_box = qobject_cast<QAbstractSpinBox*>(widget);
|
auto const* spin_box = qobject_cast<QAbstractSpinBox*>(widget);
|
||||||
if (spin_box != nullptr)
|
if (spin_box != nullptr)
|
||||||
{
|
{
|
||||||
connect(spin_box, &QAbstractSpinBox::editingFinished, this, &PrefsDialog::spinBoxEditingFinished);
|
connect(spin_box, &QAbstractSpinBox::editingFinished, this, &PrefsDialog::spinBoxEditingFinished);
|
||||||
|
@ -762,14 +762,11 @@ void PrefsDialog::refreshPref(int key)
|
||||||
{
|
{
|
||||||
QWidget* w(it.value());
|
QWidget* w(it.value());
|
||||||
|
|
||||||
if (!updateWidgetValue(w, key))
|
if (!updateWidgetValue(w, key) && (key == Prefs::ENCRYPTION))
|
||||||
{
|
|
||||||
if (key == Prefs::ENCRYPTION)
|
|
||||||
{
|
{
|
||||||
auto* combo_box = qobject_cast<QComboBox*>(w);
|
auto* combo_box = qobject_cast<QComboBox*>(w);
|
||||||
int const index = combo_box->findData(prefs_.getInt(key));
|
int const index = combo_box->findData(prefs_.getInt(key));
|
||||||
combo_box->setCurrentIndex(index);
|
combo_box->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ class RpcClient : public QObject
|
||||||
TR_DISABLE_COPY_MOVE(RpcClient)
|
TR_DISABLE_COPY_MOVE(RpcClient)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RpcClient(QObject* parent = nullptr);
|
explicit RpcClient(QObject* parent = nullptr);
|
||||||
|
|
||||||
void stop();
|
void stop();
|
||||||
void start(tr_session* session);
|
void start(tr_session* session);
|
||||||
|
|
|
@ -51,8 +51,8 @@ class SqueezeLabel : public QLabel
|
||||||
TR_DISABLE_COPY_MOVE(SqueezeLabel)
|
TR_DISABLE_COPY_MOVE(SqueezeLabel)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SqueezeLabel(QWidget* parent = nullptr);
|
explicit SqueezeLabel(QWidget* parent = nullptr);
|
||||||
SqueezeLabel(QString const& text, QWidget* parent = nullptr);
|
explicit SqueezeLabel(QString const& text, QWidget* parent = nullptr);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// QWidget
|
// QWidget
|
||||||
|
|
|
@ -112,12 +112,12 @@ private:
|
||||||
public:
|
public:
|
||||||
TorrentHash() {}
|
TorrentHash() {}
|
||||||
|
|
||||||
TorrentHash(char const* str)
|
explicit TorrentHash(char const* str)
|
||||||
{
|
{
|
||||||
tr_hex_to_sha1(data_.data(), str);
|
tr_hex_to_sha1(data_.data(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
TorrentHash(QString const& str)
|
explicit TorrentHash(QString const& str)
|
||||||
{
|
{
|
||||||
tr_hex_to_sha1(data_.data(), str.toUtf8().constData());
|
tr_hex_to_sha1(data_.data(), str.toUtf8().constData());
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ class TorrentView : public QListView
|
||||||
TR_DISABLE_COPY_MOVE(TorrentView)
|
TR_DISABLE_COPY_MOVE(TorrentView)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TorrentView(QWidget* parent = nullptr);
|
explicit TorrentView(QWidget* parent = nullptr);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setHeaderText(QString const& text);
|
void setHeaderText(QString const& text);
|
||||||
|
|
|
@ -23,7 +23,7 @@ class TrackerDelegate : public QItemDelegate
|
||||||
TR_DISABLE_COPY_MOVE(TrackerDelegate)
|
TR_DISABLE_COPY_MOVE(TrackerDelegate)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TrackerDelegate(QObject* parent = nullptr) :
|
explicit TrackerDelegate(QObject* parent = nullptr) :
|
||||||
QItemDelegate(parent)
|
QItemDelegate(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ class WatchDir : public QObject
|
||||||
TR_DISABLE_COPY_MOVE(WatchDir)
|
TR_DISABLE_COPY_MOVE(WatchDir)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WatchDir(TorrentModel const&);
|
explicit WatchDir(TorrentModel const&);
|
||||||
|
|
||||||
void setPath(QString const& path, bool is_enabled);
|
void setPath(QString const& path, bool is_enabled);
|
||||||
|
|
||||||
|
|
12
utils/edit.c
12
utils/edit.c
|
@ -146,21 +146,17 @@ static bool removeURL(tr_variant* metainfo, char const* url)
|
||||||
* use it as the "announce" field */
|
* use it as the "announce" field */
|
||||||
if (changed && !tr_variantDictFindStr(metainfo, TR_KEY_announce, &str, NULL))
|
if (changed && !tr_variantDictFindStr(metainfo, TR_KEY_announce, &str, NULL))
|
||||||
{
|
{
|
||||||
tr_variant* tier;
|
tr_variant* const tier = tr_variantListChild(announce_list, 0);
|
||||||
tr_variant* node;
|
if (tier != NULL)
|
||||||
|
|
||||||
if ((tier = tr_variantListChild(announce_list, 0)) != NULL)
|
|
||||||
{
|
{
|
||||||
if ((node = tr_variantListChild(tier, 0)) != NULL)
|
tr_variant const* const node = tr_variantListChild(tier, 0);
|
||||||
{
|
if ((node != NULL) && tr_variantGetStr(node, &str, NULL))
|
||||||
if (tr_variantGetStr(node, &str, NULL))
|
|
||||||
{
|
{
|
||||||
tr_variantDictAddStr(metainfo, TR_KEY_announce, str);
|
tr_variantDictAddStr(metainfo, TR_KEY_announce, str);
|
||||||
printf("\tAdded \"%s\" to announce\n", str);
|
printf("\tAdded \"%s\" to announce\n", str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2339,7 +2339,6 @@ static int processArgs(char const* rpcurl, int argc, char const* const* argv)
|
||||||
case 'V': /* show version number */
|
case 'V': /* show version number */
|
||||||
fprintf(stderr, "%s %s\n", MY_NAME, LONG_VERSION_STRING);
|
fprintf(stderr, "%s %s\n", MY_NAME, LONG_VERSION_STRING);
|
||||||
exit(0);
|
exit(0);
|
||||||
break;
|
|
||||||
|
|
||||||
case TR_OPT_ERR:
|
case TR_OPT_ERR:
|
||||||
fprintf(stderr, "invalid option\n");
|
fprintf(stderr, "invalid option\n");
|
||||||
|
|
Loading…
Reference in New Issue