mirror of
https://github.com/transmission/transmission
synced 2025-03-16 08:49:47 +00:00
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
56 changed files with 302 additions and 536 deletions
18
cli/cli.c
18
cli/cli.c
|
@ -262,18 +262,16 @@ int tr_main(int argc, char* argv[])
|
|||
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;
|
||||
|
||||
if (!tr_sys_dir_create(str, TR_SYS_DIR_CREATE_PARENTS, 0700, &error))
|
||||
{
|
||||
fprintf(stderr, "Unable to create download directory \"%s\": %s\n", str, error->message);
|
||||
tr_error_free(error);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (!tr_sys_dir_create(str, TR_SYS_DIR_CREATE_PARENTS, 0700, &error))
|
||||
{
|
||||
fprintf(stderr, "Unable to create download directory \"%s\": %s\n", str, error->message);
|
||||
tr_error_free(error);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1430,6 +1430,8 @@ static void refreshPeerRow(GtkListStore* store, GtkTreeIter* iter, tr_peer_stat
|
|||
char cancelled_by_peer[64] = { '\0' };
|
||||
char cancelled_by_client[64] = { '\0' };
|
||||
|
||||
g_return_if_fail(peer != NULL);
|
||||
|
||||
if (peer->rateToPeer_KBps > 0.01)
|
||||
{
|
||||
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(gdata);
|
||||
|
||||
int w, h;
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
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_height, h);
|
||||
|
|
|
@ -129,15 +129,14 @@ static gboolean refreshFilesForeach(GtkTreeModel* model, GtkTreePath* path, GtkT
|
|||
* which breaks this foreach () call. (See #3529)
|
||||
* As a workaround: if that's about to happen, temporarily disable
|
||||
* 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)) ||
|
||||
((refresh_data->sort_column_id == FC_ENABLED) && (enabled != old_enabled))))
|
||||
{
|
||||
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->resort_needed = TRUE;
|
||||
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(data->model),
|
||||
GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, GTK_SORT_ASCENDING);
|
||||
}
|
||||
refresh_data->resort_needed = TRUE;
|
||||
|
||||
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(data->model),
|
||||
GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, GTK_SORT_ASCENDING);
|
||||
}
|
||||
|
||||
gtk_tree_store_set(data->store, iter,
|
||||
|
|
18
gtk/main.c
18
gtk/main.c
|
@ -547,18 +547,16 @@ static void on_startup(GApplication* application, gpointer user_data)
|
|||
tr_sessionSetRPCCallback(session, on_rpc_changed, cbdata);
|
||||
|
||||
/* 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);
|
||||
int const SECONDS_IN_A_WEEK = 7 * 24 * 60 * 60;
|
||||
time_t const now = time(NULL);
|
||||
int64_t const last_time = gtr_pref_int_get(TR_KEY_blocklist_date);
|
||||
int const SECONDS_IN_A_WEEK = 7 * 24 * 60 * 60;
|
||||
time_t const now = time(NULL);
|
||||
|
||||
if (last_time + SECONDS_IN_A_WEEK < now)
|
||||
{
|
||||
gtr_core_blocklist_update(cbdata->core);
|
||||
}
|
||||
if (last_time + SECONDS_IN_A_WEEK < now)
|
||||
{
|
||||
gtr_core_blocklist_update(cbdata->core);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,6 @@ static void setLabelFromRatio(GtkLabel* l, double d)
|
|||
static gboolean updateStats(gpointer gdata)
|
||||
{
|
||||
char buf[128];
|
||||
char const* fmt;
|
||||
tr_session_stats one;
|
||||
tr_session_stats all;
|
||||
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));
|
||||
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);
|
||||
setLabel(ui->all_sessions_lb, buf);
|
||||
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;
|
||||
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;
|
||||
GtkMessageDialog* d = GTK_MESSAGE_DIALOG(data->updateBlocklistDialog);
|
||||
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_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);
|
||||
}
|
||||
|
||||
|
|
|
@ -255,19 +255,18 @@ static void status_menu_toggled_cb(GtkCheckMenuItem* menu_item, gpointer vprivat
|
|||
|
||||
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);
|
||||
char const* stock = b ? "alt-speed-on" : "alt-speed-off";
|
||||
GtkWidget* w = p->alt_speed_button;
|
||||
char const* const stock = b ? "alt-speed-on" : "alt-speed-off";
|
||||
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));
|
||||
char d[32];
|
||||
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)");
|
||||
str = g_strdup_printf(fmt, d, u);
|
||||
|
||||
char* const str = b ?
|
||||
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_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)
|
||||
{
|
||||
if (req->partial_seed)
|
||||
{
|
||||
if (req->event != TR_ANNOUNCE_EVENT_STOPPED)
|
||||
{
|
||||
return "paused";
|
||||
}
|
||||
}
|
||||
|
||||
return tr_announce_event_get_string(req->event);
|
||||
return req->partial_seed && (req->event != TR_ANNOUNCE_EVENT_STOPPED) ?
|
||||
"paused" :
|
||||
tr_announce_event_get_string(req->event);
|
||||
}
|
||||
|
||||
static char* announce_url_new(tr_session const* session, tr_announce_request const* req)
|
||||
|
@ -429,12 +423,10 @@ static void on_scrape_done(tr_session* session, bool did_connect, bool did_timeo
|
|||
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))
|
||||
|
|
|
@ -522,13 +522,12 @@ tr_socket_t tr_fdSocketCreate(tr_session* session, int domain, int type)
|
|||
|
||||
if (gFd->peerCount < session->peerLimit)
|
||||
{
|
||||
if ((s = socket(domain, type, 0)) == TR_BAD_SOCKET)
|
||||
s = socket(domain, type, 0);
|
||||
|
||||
if ((s == TR_BAD_SOCKET) && (sockerrno != EAFNOSUPPORT))
|
||||
{
|
||||
if (sockerrno != EAFNOSUPPORT)
|
||||
{
|
||||
char err_buf[512];
|
||||
tr_logAddError(_("Couldn't create socket: %s"), tr_net_strerror(err_buf, sizeof(err_buf), sockerrno));
|
||||
}
|
||||
char err_buf[512];
|
||||
tr_logAddError(_("Couldn't create socket: %s"), tr_net_strerror(err_buf, sizeof(err_buf), sockerrno));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -172,24 +172,12 @@ static void setReadState(tr_handshake* handshake, handshake_state_t state)
|
|||
|
||||
static bool buildHandshakeMessage(tr_handshake* handshake, uint8_t* buf)
|
||||
{
|
||||
unsigned char const* peer_id = NULL;
|
||||
uint8_t const* torrentHash;
|
||||
tr_torrent* tor;
|
||||
bool success;
|
||||
uint8_t const* const torrent_hash = tr_cryptoGetTorrentHash(handshake->crypto);
|
||||
tr_torrent* const tor = torrent_hash == NULL ? NULL : tr_torrentFindFromHash(handshake->session, torrent_hash);
|
||||
unsigned char const* const peer_id = tor == NULL ? NULL : tr_torrentGetPeerId(tor);
|
||||
bool const success = peer_id != NULL;
|
||||
|
||||
if ((torrentHash = tr_cryptoGetTorrentHash(handshake->crypto)) != NULL)
|
||||
{
|
||||
if ((tor = tr_torrentFindFromHash(handshake->session, torrentHash)) != NULL)
|
||||
{
|
||||
peer_id = tr_torrentGetPeerId(tor);
|
||||
}
|
||||
}
|
||||
|
||||
if (peer_id == NULL)
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
else
|
||||
if (success)
|
||||
{
|
||||
uint8_t* walk = buf;
|
||||
|
||||
|
@ -208,13 +196,12 @@ static bool buildHandshakeMessage(tr_handshake* handshake, uint8_t* buf)
|
|||
}
|
||||
|
||||
walk += HANDSHAKE_FLAGS_LEN;
|
||||
memcpy(walk, torrentHash, SHA_DIGEST_LENGTH);
|
||||
memcpy(walk, torrent_hash, SHA_DIGEST_LENGTH);
|
||||
walk += SHA_DIGEST_LENGTH;
|
||||
memcpy(walk, peer_id, PEER_ID_LEN);
|
||||
walk += PEER_ID_LEN;
|
||||
|
||||
TR_ASSERT(walk - buf == HANDSHAKE_SIZE);
|
||||
success = true;
|
||||
}
|
||||
|
||||
return success;
|
||||
|
|
|
@ -490,14 +490,13 @@ static void tr_realMakeMetaInfo(tr_metainfo_builder* builder)
|
|||
}
|
||||
|
||||
/* save the file */
|
||||
if (builder->result == TR_MAKEMETA_OK && !builder->abortFlag)
|
||||
if ((builder->result == TR_MAKEMETA_OK) &&
|
||||
(!builder->abortFlag) &&
|
||||
(tr_variantToFile(&top, TR_VARIANT_FMT_BENC, builder->outputFile) != 0))
|
||||
{
|
||||
if (tr_variantToFile(&top, TR_VARIANT_FMT_BENC, builder->outputFile) != 0)
|
||||
{
|
||||
builder->my_errno = errno;
|
||||
tr_strlcpy(builder->errfile, builder->outputFile, sizeof(builder->errfile));
|
||||
builder->result = TR_MAKEMETA_IO_WRITE;
|
||||
}
|
||||
builder->my_errno = errno;
|
||||
tr_strlcpy(builder->errfile, builder->outputFile, sizeof(builder->errfile));
|
||||
builder->result = TR_MAKEMETA_IO_WRITE;
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
|
|
|
@ -265,13 +265,11 @@ static char const* parseFiles(tr_info* inf, tr_variant* files, tr_variant const*
|
|||
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";
|
||||
break;
|
||||
}
|
||||
result = "path";
|
||||
break;
|
||||
}
|
||||
|
||||
bool is_file_adjusted;
|
||||
|
@ -613,12 +611,10 @@ static char const* tr_metainfoParseImpl(tr_session const* session, tr_info* inf,
|
|||
{
|
||||
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))
|
||||
|
@ -635,12 +631,10 @@ static char const* tr_metainfoParseImpl(tr_session const* session, tr_info* inf,
|
|||
/* comment */
|
||||
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);
|
||||
|
@ -649,12 +643,10 @@ static char const* tr_metainfoParseImpl(tr_session const* session, tr_info* inf,
|
|||
/* created by */
|
||||
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);
|
||||
|
@ -669,12 +661,10 @@ static char const* tr_metainfoParseImpl(tr_session const* session, tr_info* inf,
|
|||
inf->dateCreated = i;
|
||||
|
||||
/* 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;
|
||||
|
|
|
@ -144,12 +144,11 @@ 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) &&
|
||||
(!is_enabled || nat->private_port != private_port))
|
||||
{
|
||||
if (nat->is_mapped && (!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))
|
||||
|
|
|
@ -418,17 +418,13 @@ static tr_socket_t tr_netBindTCPImpl(tr_address const* addr, tr_port port, bool
|
|||
|
||||
#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) &&
|
||||
(sockerrno != ENOPROTOOPT)) // if the kernel doesn't support it, ignore it
|
||||
{
|
||||
if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (void const*)&optval, sizeof(optval)) == -1)
|
||||
{
|
||||
if (sockerrno != ENOPROTOOPT) /* if the kernel doesn't support it, ignore it */
|
||||
{
|
||||
*errOut = sockerrno;
|
||||
tr_netCloseSocket(fd);
|
||||
return TR_BAD_SOCKET;
|
||||
}
|
||||
}
|
||||
*errOut = sockerrno;
|
||||
tr_netCloseSocket(fd);
|
||||
return TR_BAD_SOCKET;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -790,12 +790,10 @@ static void getBlockRequestPeers(tr_swarm* s, tr_block_index_t block, tr_ptrArra
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1100,12 +1098,9 @@ static void pieceListRebuild(tr_swarm* s)
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2207,12 +2202,10 @@ void tr_peerMgrAddPex(tr_torrent* tor, uint8_t from, tr_pex const* pex, int8_t s
|
|||
tr_swarm* s = tor->swarm;
|
||||
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);
|
||||
|
|
|
@ -865,7 +865,6 @@ static void sendLtepHandshake(tr_peerMsgs* msgs)
|
|||
{
|
||||
tr_variant val;
|
||||
bool allow_pex;
|
||||
bool allow_metadata_xfer;
|
||||
struct evbuffer* payload;
|
||||
struct evbuffer* out = msgs->outMessages;
|
||||
unsigned char const* ipv6 = tr_globalIPv6();
|
||||
|
@ -885,14 +884,7 @@ static void sendLtepHandshake(tr_peerMsgs* msgs)
|
|||
msgs->clientSentLtepHandshake = true;
|
||||
|
||||
/* decide if we want to advertise metadata xfer support (BEP 9) */
|
||||
if (tr_torrentIsPrivate(msgs->torrent))
|
||||
{
|
||||
allow_metadata_xfer = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
allow_metadata_xfer = true;
|
||||
}
|
||||
bool const allow_metadata_xfer = !tr_torrentIsPrivate(msgs->torrent);
|
||||
|
||||
/* decide if we want to advertise pex support */
|
||||
if (!tr_torrentAllowsPex(msgs->torrent))
|
||||
|
@ -1028,12 +1020,10 @@ static void parseLtepHandshake(tr_peerMsgs* msgs, uint32_t len, struct evbuffer*
|
|||
}
|
||||
|
||||
/* 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) */
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
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;
|
||||
memcpy(&pex.addr.addr.addr4, addr, 4);
|
||||
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;
|
||||
memcpy(&pex.addr.addr.addr6, addr, 16);
|
||||
|
@ -1933,12 +1927,9 @@ static void updateDesiredRequestCount(tr_peerMsgs* msgs)
|
|||
msgs->desiredRequestCount = MAX(floor, estimatedBlocksInPeriod);
|
||||
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1012,12 +1012,9 @@ 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)
|
||||
|
|
|
@ -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_isPriority(tmp))
|
||||
tr_priority_t const priority = (tr_priority_t)tmp;
|
||||
|
||||
if (tr_isPriority(priority))
|
||||
{
|
||||
tr_torrentSetPriority(tor, tmp);
|
||||
tr_torrentSetPriority(tor, priority);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1712,14 +1714,12 @@ static void gotNewBlocklist(tr_session* session, bool did_connect, bool did_time
|
|||
stream.avail_out = buflen;
|
||||
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_error_clear(&error);
|
||||
break;
|
||||
}
|
||||
tr_snprintf(result, sizeof(result), _("Couldn't save file \"%1$s\": %2$s"), filename, error->message);
|
||||
tr_error_clear(&error);
|
||||
break;
|
||||
}
|
||||
|
||||
if (err != Z_OK)
|
||||
|
@ -1735,13 +1735,11 @@ static void gotNewBlocklist(tr_session* session, bool did_connect, bool did_time
|
|||
|
||||
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_error_clear(&error);
|
||||
}
|
||||
tr_snprintf(result, sizeof(result), _("Couldn't save file \"%1$s\": %2$s"), filename, error->message);
|
||||
tr_error_clear(&error);
|
||||
}
|
||||
|
||||
tr_sys_file_close(fd, NULL);
|
||||
|
@ -1916,12 +1914,10 @@ static char const* torrentAdd(tr_session* session, tr_variant* args_in, tr_varia
|
|||
|
||||
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;
|
||||
|
@ -2046,20 +2042,16 @@ static char const* sessionSet(tr_session* session, tr_variant* args_in, tr_varia
|
|||
char const* download_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;
|
||||
|
|
|
@ -184,17 +184,15 @@ bool tr_session_id_is_local(char const* session_id)
|
|||
}
|
||||
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
|
||||
if (error->code == EWOULDBLOCK)
|
||||
(error->code == EWOULDBLOCK))
|
||||
#else
|
||||
if (error->code == ERROR_LOCK_VIOLATION)
|
||||
(error->code == ERROR_LOCK_VIOLATION))
|
||||
#endif
|
||||
{
|
||||
ret = true;
|
||||
tr_error_clear(&error);
|
||||
}
|
||||
{
|
||||
ret = true;
|
||||
tr_error_clear(&error);
|
||||
}
|
||||
|
||||
tr_sys_file_close(lock_file, NULL);
|
||||
|
|
|
@ -3042,12 +3042,9 @@ int tr_sessionCountQueueFreeSlots(tr_session* session, tr_direction dir)
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -151,12 +151,10 @@ int tr_ctorSetMetainfoFromFile(tr_ctor* ctor, char const* filename)
|
|||
{
|
||||
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))
|
||||
|
|
|
@ -109,12 +109,9 @@ tr_torrent* tr_torrentFindFromHash(tr_session* session, uint8_t const* torrentHa
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,24 +154,18 @@ bool tr_torrentIsPieceTransferAllowed(tr_torrent const* tor, tr_direction direct
|
|||
|
||||
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))
|
||||
{
|
||||
unsigned int limit;
|
||||
|
||||
if (tr_sessionGetActiveSpeedLimit_Bps(tor->session, direction, &limit))
|
||||
unsigned int limit = 0;
|
||||
if (tr_sessionGetActiveSpeedLimit_Bps(tor->session, direction, &limit) && (limit <= 0))
|
||||
{
|
||||
if (limit <= 0)
|
||||
{
|
||||
allowed = false;
|
||||
}
|
||||
allowed = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,23 +200,9 @@ static int peerIdTTL(tr_torrent const* tor)
|
|||
|
||||
unsigned char const* tr_torrentGetPeerId(tr_torrent* tor)
|
||||
{
|
||||
bool needs_new_peer_id = false;
|
||||
|
||||
if (*tor->peer_id == '\0')
|
||||
{
|
||||
needs_new_peer_id = true;
|
||||
}
|
||||
|
||||
if (!needs_new_peer_id)
|
||||
{
|
||||
if (!tr_torrentIsPrivate(tor))
|
||||
{
|
||||
if (peerIdTTL(tor) <= 0)
|
||||
{
|
||||
needs_new_peer_id = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool const needs_new_peer_id =
|
||||
(*tor->peer_id == '\0') || // doesn't have one
|
||||
(!tr_torrentIsPrivate(tor) && (peerIdTTL(tor) <= 0)); // has one but it's expired
|
||||
|
||||
if (needs_new_peer_id)
|
||||
{
|
||||
|
@ -722,12 +699,9 @@ static tr_priority_t calculatePiecePriority(tr_torrent const* tor, tr_piece_inde
|
|||
/* when dealing with multimedia files, getting the first and
|
||||
last pieces can sometimes allow you to preview it a bit
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2774,12 +2748,10 @@ 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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3485,12 +3457,11 @@ static void tr_torrentPieceCompleted(tr_torrent* tor, tr_piece_index_t pieceInde
|
|||
{
|
||||
tr_file const* file = &tor->info.files[i];
|
||||
|
||||
if (file->firstPiece <= pieceIndex && pieceIndex <= file->lastPiece)
|
||||
if ((file->firstPiece <= pieceIndex) &&
|
||||
(pieceIndex <= file->lastPiece) &&
|
||||
tr_cpFileIsComplete(&tor->completion, i))
|
||||
{
|
||||
if (tr_cpFileIsComplete(&tor->completion, i))
|
||||
{
|
||||
tr_torrentFileCompleted(tor, i);
|
||||
}
|
||||
tr_torrentFileCompleted(tor, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3736,22 +3707,20 @@ void tr_torrentSetQueuePosition(tr_torrent* tor, int pos)
|
|||
|
||||
while ((walk = tr_torrentNext(tor->session, walk)) != NULL)
|
||||
{
|
||||
if (old_pos < pos)
|
||||
if ((old_pos < pos) &&
|
||||
(old_pos <= walk->queuePosition) &&
|
||||
(walk->queuePosition <= pos))
|
||||
{
|
||||
if (old_pos <= walk->queuePosition && walk->queuePosition <= pos)
|
||||
{
|
||||
walk->queuePosition--;
|
||||
walk->anyDate = now;
|
||||
}
|
||||
walk->queuePosition--;
|
||||
walk->anyDate = now;
|
||||
}
|
||||
|
||||
if (old_pos > pos)
|
||||
if ((old_pos > pos) &&
|
||||
(pos <= walk->queuePosition) &&
|
||||
(walk->queuePosition < old_pos))
|
||||
{
|
||||
if (pos <= walk->queuePosition && walk->queuePosition < old_pos)
|
||||
{
|
||||
walk->queuePosition++;
|
||||
walk->anyDate = now;
|
||||
}
|
||||
walk->queuePosition++;
|
||||
walk->anyDate = now;
|
||||
}
|
||||
|
||||
if (back < walk->queuePosition)
|
||||
|
|
|
@ -583,12 +583,9 @@ bool tr_dhtAddNode(tr_session* ss, tr_address const* address, tr_port port, bool
|
|||
/* Since we don't want to abuse our bootstrap nodes,
|
||||
* 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)
|
||||
|
|
|
@ -182,7 +182,7 @@ enum
|
|||
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;
|
||||
|
||||
|
@ -212,22 +212,21 @@ int tr_upnpPulse(tr_upnp* handle, int port, bool isEnabled, bool doPortCheck)
|
|||
freeUPNPDevlist(devlist);
|
||||
}
|
||||
|
||||
if (handle->state == TR_UPNP_IDLE)
|
||||
if ((handle->state == TR_UPNP_IDLE) &&
|
||||
(handle->isMapped) &&
|
||||
(!isEnabled || handle->port != port))
|
||||
{
|
||||
if (handle->isMapped && (!isEnabled || handle->port != port))
|
||||
{
|
||||
handle->state = TR_UPNP_UNMAP;
|
||||
}
|
||||
handle->state = TR_UPNP_UNMAP;
|
||||
}
|
||||
|
||||
if (isEnabled && handle->isMapped && doPortCheck)
|
||||
if (isEnabled &&
|
||||
handle->isMapped &&
|
||||
doPortCheck &&
|
||||
((tr_upnpGetSpecificPortMappingEntry(handle, "TCP") != UPNPCOMMAND_SUCCESS) ||
|
||||
(tr_upnpGetSpecificPortMappingEntry(handle, "UDP") != UPNPCOMMAND_SUCCESS)))
|
||||
{
|
||||
if (tr_upnpGetSpecificPortMappingEntry(handle, "TCP") != UPNPCOMMAND_SUCCESS ||
|
||||
tr_upnpGetSpecificPortMappingEntry(handle, "UDP") != UPNPCOMMAND_SUCCESS)
|
||||
{
|
||||
tr_logAddNamedInfo(getKey(), _("Port %d isn't forwarded"), handle->port);
|
||||
handle->isMapped = false;
|
||||
}
|
||||
tr_logAddNamedInfo(getKey(), _("Port %d isn't forwarded"), handle->port);
|
||||
handle->isMapped = false;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
int err_tcp = -1;
|
||||
int err_udp = -1;
|
||||
errno = 0;
|
||||
|
||||
if (handle->urls.controlURL == NULL)
|
||||
|
@ -266,8 +260,8 @@ int tr_upnpPulse(tr_upnp* handle, int port, bool isEnabled, bool doPortCheck)
|
|||
char desc[64];
|
||||
tr_snprintf(desc, sizeof(desc), "%s at %d", TR_NAME, port);
|
||||
|
||||
err_tcp = tr_upnpAddPortMapping(handle, "TCP", port, desc);
|
||||
err_udp = tr_upnpAddPortMapping(handle, "UDP", port, desc);
|
||||
int const err_tcp = tr_upnpAddPortMapping(handle, "TCP", port, desc);
|
||||
int const err_udp = tr_upnpAddPortMapping(handle, "UDP", port, desc);
|
||||
|
||||
handle->isMapped = err_tcp == 0 || err_udp == 0;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,6 @@ tr_upnp* tr_upnpInit(void);
|
|||
|
||||
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,12 +1877,9 @@ void* tr_valloc(size_t bufLen)
|
|||
|
||||
#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
|
||||
|
|
|
@ -357,22 +357,20 @@ bool tr_variantGetBool(tr_variant const* v, bool* setme)
|
|||
success = true;
|
||||
}
|
||||
|
||||
if (!success && tr_variantIsInt(v))
|
||||
if ((!success) &&
|
||||
tr_variantIsInt(v) &&
|
||||
(v->val.i == 0 || v->val.i == 1))
|
||||
{
|
||||
if (v->val.i == 0 || v->val.i == 1)
|
||||
{
|
||||
*setme = v->val.i != 0;
|
||||
success = true;
|
||||
}
|
||||
*setme = v->val.i != 0;
|
||||
success = true;
|
||||
}
|
||||
|
||||
if (!success && tr_variantGetStr(v, &str, NULL))
|
||||
if ((!success) &&
|
||||
tr_variantGetStr(v, &str, NULL) &&
|
||||
(strcmp(str, "true") == 0 || strcmp(str, "false") == 0))
|
||||
{
|
||||
if (strcmp(str, "true") == 0 || strcmp(str, "false") == 0)
|
||||
{
|
||||
*setme = strcmp(str, "true") == 0;
|
||||
success = true;
|
||||
}
|
||||
*setme = strcmp(str, "true") == 0;
|
||||
success = true;
|
||||
}
|
||||
|
||||
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;
|
||||
tr_watchdir_retries_init(&handle->active_retries);
|
||||
|
||||
if (!force_generic)
|
||||
if (!force_generic && (handle->backend == NULL))
|
||||
{
|
||||
#ifdef WITH_INOTIFY
|
||||
|
||||
if (handle->backend == NULL)
|
||||
{
|
||||
handle->backend = tr_watchdir_inotify_new(handle);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef WITH_KQUEUE
|
||||
|
||||
if (handle->backend == NULL)
|
||||
{
|
||||
handle->backend = tr_watchdir_kqueue_new(handle);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
if (handle->backend == NULL)
|
||||
{
|
||||
handle->backend = tr_watchdir_win32_new(handle);
|
||||
}
|
||||
|
||||
#if defined(WITH_INOTIFY)
|
||||
handle->backend = tr_watchdir_inotify_new(handle);
|
||||
#elif defined(WITH_KQUEUE)
|
||||
handle->backend = tr_watchdir_kqueue_new(handle);
|
||||
#elif defined(_WIN32)
|
||||
handle->backend = tr_watchdir_win32_new(handle);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
<body>
|
||||
<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="machelp">
|
||||
<a class="bread" href="../index.html">Transmission Help</a>
|
||||
|
@ -22,179 +20,92 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="letters">
|
||||
<span style="font: Lucida grande, arial, sans-serif"><strong>Index</strong></span>
|
||||
</div>
|
||||
|
||||
<div id="terms">
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
|
||||
|
||||
<table style="width: 100%; border-width: 0; padding: 0">
|
||||
<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>
|
||||
</td>
|
||||
|
||||
<td class="blue" valign="top" width="18"></td>
|
||||
|
||||
<td class="blue" valign="top" width="250">
|
||||
<p class="seealso"> </p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="blue" valign="top">
|
||||
<td class="blue">
|
||||
<p><a href="FAQ.html">Frequently Asked Questions</a></p>
|
||||
</td>
|
||||
|
||||
<td class="blue" valign="top" width="18"></td>
|
||||
|
||||
<td class="blue" valign="top" width="250">
|
||||
<p class="seealso"> </p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="blue" valign="top" width="135">
|
||||
<td class="blue">
|
||||
<p><a href="gettingstarted.html">Getting Started</a></p>
|
||||
</td>
|
||||
|
||||
<td class="blue" valign="top" width="18"></td>
|
||||
|
||||
<td class="blue" valign="top" width="250">
|
||||
<p class="seealso"> </p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="blue" valign="top">
|
||||
<td class="blue">
|
||||
<p><a href="usingt.html">Managing your transfers</a></p>
|
||||
</td>
|
||||
|
||||
<td class="blue" valign="top" width="18"></td>
|
||||
|
||||
<td class="blue" valign="top" width="250">
|
||||
<p class="seealso"> </p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="blue" valign="top" width=150">
|
||||
<td class="blue">
|
||||
<p><a href="check.html">Manual torrent verification</a></p>
|
||||
</td>
|
||||
|
||||
<td class="blue" valign="top" width="18"></td>
|
||||
|
||||
<td class="blue" valign="top" width="250">
|
||||
<p class="seealso"> </p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="blue" valign="top" width="135">
|
||||
<td class="blue">
|
||||
<p><a href="Speed.html">Maximizing download speed</a></p>
|
||||
</td>
|
||||
|
||||
<td class="blue" valign="top" width="18"></td>
|
||||
|
||||
<td class="blue" valign="top" width="250">
|
||||
<p class="seealso"> </p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="blue" valign="top" width="135">
|
||||
<td class="blue">
|
||||
<p><a href="network.html">Network preferences</a></p>
|
||||
</td>
|
||||
|
||||
<td class="blue" valign="top" width="18"></td>
|
||||
|
||||
<td class="blue" valign="top" width="250">
|
||||
<p class="seealso"> </p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="blue" valign="top" width="135">
|
||||
<td class="blue">
|
||||
<p><a href="peers.html">Peer preferences</a></p>
|
||||
</td>
|
||||
|
||||
<td class="blue" valign="top" width="18"></td>
|
||||
|
||||
<td class="blue" valign="top" width="250">
|
||||
<p class="seealso"> </p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="blue" valign="top" width="135">
|
||||
<td class="blue">
|
||||
<p><a href="portforward.html">Port Forwarding FAQ</a></p>
|
||||
</td>
|
||||
|
||||
<td class="blue" valign="top" width="18"></td>
|
||||
|
||||
<td class="blue" valign="top" width="250">
|
||||
<p class="seealso"> </p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="blue" valign="top" width="135">
|
||||
<td class="blue">
|
||||
<p><a href="remote.html">Remote</a></p>
|
||||
</td>
|
||||
|
||||
<td class="blue" valign="top" width="18"></td>
|
||||
|
||||
<td class="blue" valign="top" width="250">
|
||||
<p class="seealso"> </p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="blue" valign="top" width="135">
|
||||
<td class="blue">
|
||||
<p><a href="scripts.html">Running Scripts</a></p>
|
||||
</td>
|
||||
|
||||
<td class="blue" valign="top" width="18"></td>
|
||||
|
||||
<td class="blue" valign="top" width="250">
|
||||
<p class="seealso"> </p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="blue" valign="top" width="135">
|
||||
<td class="blue">
|
||||
<p><a href="pfrouter.html">Router</a></p>
|
||||
</td>
|
||||
|
||||
<td class="blue" valign="top" width="18"></td>
|
||||
|
||||
<td class="blue" valign="top" width="250">
|
||||
<p class="seealso"> </p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="blue" valign="top" width="135">
|
||||
<td class="blue">
|
||||
<p><a href="tracker.html">Tracker information</a></p>
|
||||
</td>
|
||||
|
||||
<td class="blue" valign="top" width="18"></td>
|
||||
|
||||
<td class="blue" valign="top" width="250">
|
||||
<p class="seealso"> </p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="blue" valign="top" width="135">
|
||||
<td class="blue">
|
||||
<p><a href="troubleshoot.html">Troubleshooting port issues</a></p>
|
||||
</td>
|
||||
|
||||
<td class="blue" valign="top" width="18"></td>
|
||||
|
||||
<td class="blue" valign="top" width="250">
|
||||
<p class="seealso"> </p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
<div id="mainbox">
|
||||
<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 class="pagetitle">
|
||||
|
@ -37,7 +37,7 @@
|
|||
</td>
|
||||
</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">
|
||||
<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.
|
||||
|
@ -58,7 +58,7 @@
|
|||
</td>
|
||||
</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">
|
||||
<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.
|
||||
|
@ -75,7 +75,7 @@
|
|||
</td>
|
||||
</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">
|
||||
<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>
|
||||
|
@ -90,7 +90,7 @@
|
|||
</td>
|
||||
</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">
|
||||
<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..."
|
||||
|
@ -107,7 +107,7 @@
|
|||
</td>
|
||||
</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">
|
||||
<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.
|
||||
|
@ -125,7 +125,7 @@
|
|||
</td>
|
||||
</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">
|
||||
<p>Click the Inspector icon, or simply double-click any transfer in the main window.
|
||||
<p>The inspector gives you:
|
||||
|
@ -147,7 +147,7 @@
|
|||
</td>
|
||||
</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">
|
||||
<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).
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||
|
@ -11,12 +12,12 @@
|
|||
<body bgcolor="white" marginheight="0" marginwidth="0" topmargin="0">
|
||||
<div id="frame">
|
||||
<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">
|
||||
<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>
|
||||
</center>
|
||||
</div>
|
||||
</div>
|
||||
<div id="contentcenter"></div>
|
||||
<div id="contentright">
|
||||
|
@ -40,4 +41,4 @@
|
|||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -22,7 +22,7 @@ class AboutDialog : public BaseDialog
|
|||
TR_DISABLE_COPY_MOVE(AboutDialog)
|
||||
|
||||
public:
|
||||
AboutDialog(QWidget* parent = nullptr);
|
||||
explicit AboutDialog(QWidget* parent = nullptr);
|
||||
|
||||
private slots:
|
||||
void showCredits();
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
public:
|
||||
AddData() = default;
|
||||
|
||||
AddData(QString const& str)
|
||||
explicit AddData(QString const& str)
|
||||
{
|
||||
set(str);
|
||||
}
|
||||
|
|
|
@ -185,10 +185,9 @@ Application::Application(int& argc, char** argv) :
|
|||
|
||||
for (QString const& filename : filenames)
|
||||
{
|
||||
auto const a = AddData(filename);
|
||||
QString metainfo;
|
||||
|
||||
AddData a(filename);
|
||||
|
||||
switch (a.type)
|
||||
{
|
||||
case AddData::URL:
|
||||
|
@ -290,7 +289,7 @@ Application::Application(int& argc, char** argv) :
|
|||
connect(session_, &Session::sourceChanged, this, &Application::onSessionSourceChanged);
|
||||
connect(session_, &Session::torrentsRemoved, model_, &TorrentModel::removeTorrents);
|
||||
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
|
||||
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)
|
||||
{
|
||||
if (addme.type == addme.NONE)
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
|
||||
public slots:
|
||||
void addTorrent(AddData const&);
|
||||
void addTorrent(QString const&);
|
||||
|
||||
private slots:
|
||||
void consentGiven(int result);
|
||||
|
|
|
@ -22,7 +22,7 @@ class ColumnResizer : public QObject
|
|||
TR_DISABLE_COPY_MOVE(ColumnResizer)
|
||||
|
||||
public:
|
||||
ColumnResizer(QObject* parent = nullptr);
|
||||
explicit ColumnResizer(QObject* parent = nullptr);
|
||||
|
||||
void addLayout(QGridLayout* layout);
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ class FileTreeDelegate : public QItemDelegate
|
|||
TR_DISABLE_COPY_MOVE(FileTreeDelegate)
|
||||
|
||||
public:
|
||||
FileTreeDelegate(QObject* parent = nullptr) :
|
||||
explicit FileTreeDelegate(QObject* parent = nullptr) :
|
||||
QItemDelegate(parent)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -129,26 +129,23 @@ void FileTreeView::resizeEvent(QResizeEvent* 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
|
||||
// wanted/unwanted state or the file priority
|
||||
|
||||
Qt::KeyboardModifiers const modifiers = event->modifiers();
|
||||
|
||||
if (modifiers == Qt::NoModifier)
|
||||
{
|
||||
// handle using the keyboard to toggle the
|
||||
// wanted/unwanted state or the file priority
|
||||
model_->twiddleWanted(selectedSourceRows());
|
||||
return;
|
||||
}
|
||||
|
||||
Qt::KeyboardModifiers const modifiers = event->modifiers();
|
||||
|
||||
if (modifiers == Qt::NoModifier)
|
||||
{
|
||||
model_->twiddleWanted(selectedSourceRows());
|
||||
return;
|
||||
}
|
||||
|
||||
if (modifiers == Qt::ShiftModifier)
|
||||
{
|
||||
model_->twiddlePriority(selectedSourceRows());
|
||||
return;
|
||||
}
|
||||
if (modifiers == Qt::ShiftModifier)
|
||||
{
|
||||
model_->twiddlePriority(selectedSourceRows());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -343,7 +343,7 @@ void FilterBar::onActivityIndexChanged(int i)
|
|||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
};
|
||||
|
||||
public:
|
||||
FilterBarComboBox(QWidget* parent = nullptr);
|
||||
explicit FilterBarComboBox(QWidget* parent = nullptr);
|
||||
|
||||
// QWidget
|
||||
QSize minimumSizeHint() const override;
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
};
|
||||
|
||||
public:
|
||||
FilterMode(int mode = SHOW_ALL) :
|
||||
explicit FilterMode(int mode = SHOW_ALL) :
|
||||
mode_(mode)
|
||||
{
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public:
|
|||
};
|
||||
|
||||
public:
|
||||
SortMode(int mode = SORT_BY_ID) :
|
||||
explicit SortMode(int mode = SORT_BY_ID) :
|
||||
mode_(mode)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class IconToolButton : public QToolButton
|
|||
TR_DISABLE_COPY_MOVE(IconToolButton)
|
||||
|
||||
public:
|
||||
IconToolButton(QWidget* parent = nullptr);
|
||||
explicit IconToolButton(QWidget* parent = nullptr);
|
||||
|
||||
// QWidget
|
||||
QSize sizeHint() const override;
|
||||
|
|
|
@ -30,7 +30,7 @@ class InteropObject : public QObject
|
|||
#endif
|
||||
|
||||
public:
|
||||
InteropObject(QObject* parent = nullptr);
|
||||
explicit InteropObject(QObject* parent = nullptr);
|
||||
|
||||
public slots:
|
||||
bool PresentWindow();
|
||||
|
|
|
@ -18,7 +18,7 @@ class LicenseDialog : public BaseDialog
|
|||
TR_DISABLE_COPY_MOVE(LicenseDialog)
|
||||
|
||||
public:
|
||||
LicenseDialog(QWidget* parent = nullptr);
|
||||
explicit LicenseDialog(QWidget* parent = nullptr);
|
||||
|
||||
private:
|
||||
Ui::LicenseDialog ui_ = {};
|
||||
|
|
|
@ -1295,7 +1295,7 @@ void MainWindow::openURL()
|
|||
str.clear();
|
||||
}
|
||||
|
||||
addTorrent(str, true);
|
||||
addTorrent(AddData(str), true);
|
||||
}
|
||||
|
||||
void MainWindow::addTorrents(QStringList const& filenames)
|
||||
|
@ -1316,7 +1316,7 @@ void MainWindow::addTorrents(QStringList const& 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();
|
||||
}
|
||||
|
||||
qApp->addTorrent(key);
|
||||
qApp->addTorrent(AddData(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
};
|
||||
|
||||
public:
|
||||
PathButton(QWidget* parent = nullptr);
|
||||
explicit PathButton(QWidget* parent = nullptr);
|
||||
|
||||
void setMode(Mode mode);
|
||||
void setTitle(QString const& title);
|
||||
|
|
|
@ -133,7 +133,7 @@ public:
|
|||
};
|
||||
|
||||
public:
|
||||
Prefs(QString config_dir);
|
||||
explicit Prefs(QString config_dir);
|
||||
~Prefs() override;
|
||||
|
||||
bool isCore(int key) const
|
||||
|
|
|
@ -209,35 +209,35 @@ void PrefsDialog::linkWidgetToPref(QWidget* widget, int pref_key)
|
|||
updateWidgetValue(widget, pref_key);
|
||||
widgets_.insert(pref_key, widget);
|
||||
|
||||
auto* check_box = qobject_cast<QCheckBox*>(widget);
|
||||
auto const* check_box = qobject_cast<QCheckBox*>(widget);
|
||||
if (check_box != nullptr)
|
||||
{
|
||||
connect(check_box, &QAbstractButton::toggled, this, &PrefsDialog::checkBoxToggled);
|
||||
return;
|
||||
}
|
||||
|
||||
auto* time_edit = qobject_cast<QTimeEdit*>(widget);
|
||||
auto const* time_edit = qobject_cast<QTimeEdit*>(widget);
|
||||
if (time_edit != nullptr)
|
||||
{
|
||||
connect(time_edit, &QAbstractSpinBox::editingFinished, this, &PrefsDialog::timeEditingFinished);
|
||||
return;
|
||||
}
|
||||
|
||||
auto* line_edit = qobject_cast<QLineEdit*>(widget);
|
||||
auto const* line_edit = qobject_cast<QLineEdit*>(widget);
|
||||
if (line_edit != nullptr)
|
||||
{
|
||||
connect(line_edit, &QLineEdit::editingFinished, this, &PrefsDialog::lineEditingFinished);
|
||||
return;
|
||||
}
|
||||
|
||||
auto* path_button = qobject_cast<PathButton*>(widget);
|
||||
auto const* path_button = qobject_cast<PathButton*>(widget);
|
||||
if (path_button != nullptr)
|
||||
{
|
||||
connect(path_button, &PathButton::pathChanged, this, &PrefsDialog::pathChanged);
|
||||
return;
|
||||
}
|
||||
|
||||
auto* spin_box = qobject_cast<QAbstractSpinBox*>(widget);
|
||||
auto const* spin_box = qobject_cast<QAbstractSpinBox*>(widget);
|
||||
if (spin_box != nullptr)
|
||||
{
|
||||
connect(spin_box, &QAbstractSpinBox::editingFinished, this, &PrefsDialog::spinBoxEditingFinished);
|
||||
|
@ -762,14 +762,11 @@ void PrefsDialog::refreshPref(int key)
|
|||
{
|
||||
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);
|
||||
int const index = combo_box->findData(prefs_.getInt(key));
|
||||
combo_box->setCurrentIndex(index);
|
||||
}
|
||||
auto* combo_box = qobject_cast<QComboBox*>(w);
|
||||
int const index = combo_box->findData(prefs_.getInt(key));
|
||||
combo_box->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ class RpcClient : public QObject
|
|||
TR_DISABLE_COPY_MOVE(RpcClient)
|
||||
|
||||
public:
|
||||
RpcClient(QObject* parent = nullptr);
|
||||
explicit RpcClient(QObject* parent = nullptr);
|
||||
|
||||
void stop();
|
||||
void start(tr_session* session);
|
||||
|
|
|
@ -51,8 +51,8 @@ class SqueezeLabel : public QLabel
|
|||
TR_DISABLE_COPY_MOVE(SqueezeLabel)
|
||||
|
||||
public:
|
||||
SqueezeLabel(QWidget* parent = nullptr);
|
||||
SqueezeLabel(QString const& text, QWidget* parent = nullptr);
|
||||
explicit SqueezeLabel(QWidget* parent = nullptr);
|
||||
explicit SqueezeLabel(QString const& text, QWidget* parent = nullptr);
|
||||
|
||||
protected:
|
||||
// QWidget
|
||||
|
|
|
@ -112,12 +112,12 @@ private:
|
|||
public:
|
||||
TorrentHash() {}
|
||||
|
||||
TorrentHash(char const* str)
|
||||
explicit TorrentHash(char const* 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());
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class TorrentView : public QListView
|
|||
TR_DISABLE_COPY_MOVE(TorrentView)
|
||||
|
||||
public:
|
||||
TorrentView(QWidget* parent = nullptr);
|
||||
explicit TorrentView(QWidget* parent = nullptr);
|
||||
|
||||
public slots:
|
||||
void setHeaderText(QString const& text);
|
||||
|
|
|
@ -23,7 +23,7 @@ class TrackerDelegate : public QItemDelegate
|
|||
TR_DISABLE_COPY_MOVE(TrackerDelegate)
|
||||
|
||||
public:
|
||||
TrackerDelegate(QObject* parent = nullptr) :
|
||||
explicit TrackerDelegate(QObject* parent = nullptr) :
|
||||
QItemDelegate(parent)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class WatchDir : public QObject
|
|||
TR_DISABLE_COPY_MOVE(WatchDir)
|
||||
|
||||
public:
|
||||
WatchDir(TorrentModel const&);
|
||||
explicit WatchDir(TorrentModel const&);
|
||||
|
||||
void setPath(QString const& path, bool is_enabled);
|
||||
|
||||
|
|
16
utils/edit.c
16
utils/edit.c
|
@ -146,18 +146,14 @@ static bool removeURL(tr_variant* metainfo, char const* url)
|
|||
* use it as the "announce" field */
|
||||
if (changed && !tr_variantDictFindStr(metainfo, TR_KEY_announce, &str, NULL))
|
||||
{
|
||||
tr_variant* tier;
|
||||
tr_variant* node;
|
||||
|
||||
if ((tier = tr_variantListChild(announce_list, 0)) != NULL)
|
||||
tr_variant* const tier = tr_variantListChild(announce_list, 0);
|
||||
if (tier != 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);
|
||||
printf("\tAdded \"%s\" to announce\n", str);
|
||||
}
|
||||
tr_variantDictAddStr(metainfo, TR_KEY_announce, str);
|
||||
printf("\tAdded \"%s\" to announce\n", str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2339,7 +2339,6 @@ static int processArgs(char const* rpcurl, int argc, char const* const* argv)
|
|||
case 'V': /* show version number */
|
||||
fprintf(stderr, "%s %s\n", MY_NAME, LONG_VERSION_STRING);
|
||||
exit(0);
|
||||
break;
|
||||
|
||||
case TR_OPT_ERR:
|
||||
fprintf(stderr, "invalid option\n");
|
||||
|
|
Loading…
Add table
Reference in a new issue