Commit Graph

13387 Commits

Author SHA1 Message Date
Charles Kerr 2cc5cfe3e3
feat: smart caching of TorrentDelegate::sizeHint() (#1026)
* feat: smart caching of TorrentDelegate::sizeHint()

* chore: bump c++ requirement to c++17 / c++1z
2019-11-06 18:17:48 -06:00
Charles Kerr 973afda057
refactor: keep torrent's time properties as time_t (#1042)
* refactor: keep torrent's time properties as time_t

Comparing QDateTimes is expensive. Keep the torrents' time properties in
the time_t form that we got them from RPG in; difftime() is cheaper.
2019-11-06 17:31:41 -06:00
Charles Kerr aa9b752cd9
refactor: don't load the same stock more than once (#1041)
* refactor: don't load the same stock more than once

Some actions share an icon -- for example, "start all", "start now", and
"start" each use "media-playback-start". When this happens, get the icon
once and cache it to avoid hitting the disk more often than necessary.

In addition, the statusbar's network transfer icon was being reloaded in
a periodic upkeep timer, reloading with QIcon::fromTheme each time. Only
give icons are needed, so load them once and cache them.

* refactor: better lookup of torrent mime-type icons

filename-to-mime-type and mime-type-to-icon lookups are both expensive,
so do a better job of detecting top-level folders and caching the icons
based on file suffixes.

This also lets find a good mime icon even if the torrent doesn't have
its 'files' property populated yet from RPC.
2019-11-06 15:09:04 -06:00
Charles Kerr edbdeae623
fix: use bash, not sh, for code_style.sh script (#1022)
The script uses "set -o", which doesn't exist in vanilla sh, causing
failure on systems that bind sh to dash rather than bash. This PR makes
the bash requirement explicit.
2019-11-06 13:47:54 -06:00
Charles Kerr b0e33117c5
Fix some gtk warnings (#1038)
* fix gtk deprecation warning: gtk_misc_set_alignment

* fix gtk deprecation warning: gtk_alignment_new

* fix gtk deprecation warning: gtk_tree_view_set_rules_hint

* fix gtk deprecation warning: gtk_image_new_from_stock

* fixup! fix gtk deprecation warning: gtk_alignment_new

* fix gtk deprecation warning: gtk_dialog_set_alternative_button_order

* fix gtk deprecation warning: gtk_show_uri

* fix gtk deprecation warning: gtk_widget_set_margin_left

* fix gtk deprecation warning: gtk_button_set_alignment

* fix gtk deprecation warning: g_type_class_add_private

* fix gtk deprecation warning: gtk_menu_popup

* fix gtk deprecation warning: gtk_misc_set_padding

* chore: uncrustify

* fix: silence G_TYPE_INSTANCE_GET_PRIVATE warning

Deprecaed starting in glib 2.58

* chore: uncrustify
2019-11-06 13:09:27 -06:00
Charles Kerr abac811dd2
fix: gcc warnings in libtransmission/ and utils/ (#843)
* fix: __attribute__(__printf__) warnings

* fix: implicit fallthrough warning

* fixup! fix: implicit fallthrough warning

* fix: disable warnings for 3rd party code

Since we want to leave upstream code as-is

* fixup! fix: disable warnings for 3rd party code

* fixup! fix: disable warnings for 3rd party code

* silence spurious alignment warning

Xrefs
Discussion: https://stackoverflow.com/a/35554349
Macro inspiration: 90ac46f710/f/src/util/util_safealign.h (_35)

* fixup! fix: disable warnings for 3rd party code

* fixup! fix: implicit fallthrough warning

* make uncrustify happy

* remove uncrustify-test.sh

that's probably off-topic for this PR

* fixup! fix: __attribute__(__printf__) warnings

* Update libtransmission/CMakeLists.txt

Co-Authored-By: ckerr <ckerr@github.com>

* fixup! silence spurious alignment warning

* use -w for DISABLE_WARNINGS in Clang

* refactor: fix libtransmission deprecation warnings

* fix: pthread_create's start_routine's return value

This was defined as `void` on non-Windows but should have been `void*`

* chore: uncrustify

* fix: add DISABLE_WARNINGS option for SunPro Studio

* fix "unused in lambda capture" warnings by clang++

* fix 'increases required alignment' warning

Caused from storing int16_t's in a char array.

* fix net.c 'increases required alignment' warning

The code passes in a `struct sockaddr_storage*` which is a padded struct
large enough for the necessary alignment. Unfortunately it was recast as
a `struct sockaddr*` which has less padding and a smaller alignment. The
warning occrred because of these differing alignments.

* make building quieter so warnings are more visible

* fixup! fix 'increases required alignment' warning

* Fix -Wcast-function-type warnings in GTK+ app code

https://gitlab.gnome.org/GNOME/gnome-terminal/issues/96 talks about both
the issue and its solution.

GCC 8's -Wcast-function-type, enabled by -Wextra, is problematic in glib
applications because it's idiomatic there to recast function signatures,
e.g. `g_slist_free(list, (GFunc)g_free, NULL);`.

Disabling the warning with pragmas causes "unrecognized pragma" warnings
on clang and older versions of gcc, and disabling the warning could miss
actual bugs. GCC defines `void (*)(void)` as a special case that matches
anything so we can silence warnings by double-casting through GCallback.

In the previous example, the warning is silenced by changing the code to
read `g_slist_free(list, (GFunc)(GCallback)g_free, NULL);`).

* fixup! fix "unused in lambda capture" warnings by clang++

* fixup! fix "unused in lambda capture" warnings by clang++

* fix two more libtransmission compiler warnings

* fix: in watchdir, use TR_ENABLE_ASSERTS not NDEBUG
2019-11-06 11:27:03 -06:00
Tom Forbes 8d7fbb5d45 Increase the buffer size used in tr_moveFile (#933)
In some filesystems, including ones mounted on a network drive, using a small buffer size 
significantly hurts copy performance. Upping the buffer to 1024kb to increase copy performance.
2019-11-06 09:46:13 -06:00
Pavel Shlyak 2ef07517b6 Cleanup duplicates in clients.c (#991) 2019-10-21 08:20:40 -05:00
C.W. Betts 33b792531d Use -[[NSFileManager defaultManager] stringWithFileSystemRepresentation:length:] in one other place. 2019-07-28 16:13:57 -06:00
C.W. Betts 751200f59a Update PrefsController:
Use [[NSFileManager defaultManager] stringWithFileSystemRepresentation:length:] instead of using NSString's creation.
2019-07-21 15:04:09 -06:00
Mike Gelfand 5a5fe7d7fe Bump version to 3.00 (nightly) 2019-07-21 15:11:49 +03:00
Mingye Wang bcf8128400 Unify/Modernize TOS to DSCP standards (#737)
* Unify/Modernize TOS to DSCP standards

The set of pre-named TOS values are now renamed to the latest DSCP
standards, with traffic classes and everything exciting. To keep
everything in the same place, a segment has been added to net.h to keep
the currently named values.

A result of these changes is that "lowcost" is probably no longer
harmless, as it now encourages the router to preferentially drop the
packages when bandwidth requires so. "lowdelay" is assigned to a pretty
high AF class for SIP and stuff. I am not sure at all about the
"throughput" assignment. I mean, the whole point of DSCP-fication is
translating from the old ToS bits to a more precedence-based notation,
and precedence is supposed to lie beside the old 4 ToS bits...

A funny interaction between the AFxy and the old ToS fields lies in
the old "reliability" (0x08) field. All odd numbers of y (1, 3 : low,
high) switches it on. If you spend 5 more minutes on it you can probably
come up with "pun" values that hold similar meanings in DSCP and
Prec/ToS.

By removing the IPv6 override, I should have kind of satisfied the #692
request.

Fixes: #692
2019-07-21 14:09:04 +03:00
C.W. Betts cabffe76eb Replace -[[NSURL path] fileSystemRepresentation] with just -[NSURL fileSystemRepresentation].
We're targeting a late-enough version of OS X that has that API.
2019-07-20 14:00:19 -06:00
C.W. Betts f1616c5065 Replace some instances of -UTF8String with -fileSystemRepresentation. 2019-07-20 13:40:33 -06:00
C.W. Betts 0a67db48bc Merge branch 'master' into patch-1 2019-07-15 12:24:32 -06:00
Mike Gelfand eef4799388 Update Uncrustify config to 0.69 2019-07-15 02:30:41 +03:00
Mike Gelfand 35ed02a1fd Use explicit boolean conversions (follow-up) 2019-07-14 22:57:40 +03:00
Mike Gelfand 10cdd7f790 Use explicit boolean conversions 2019-07-14 16:25:07 +03:00
Mike Gelfand 16d385e4c7 Fixup code style 2019-07-13 23:02:27 +03:00
Mike Gelfand ec79767e5f Support OFD locks and missing flock 2019-07-13 22:53:04 +03:00
Mike Gelfand a3e4919385 Introduce `tr_str_is_empty` to relay intent better 2019-07-13 12:00:06 +03:00
Mike Gelfand bff188c2cf Fully cover `tr_metainfo_sanitize_path_component` 2019-06-24 06:32:38 +03:00
Mike Gelfand 99033b067d Sanitize suspicious path components instead of rejecting them
Apply the same rules on all the supported platforms to avoid issues
with network shares and alien file systems.

For future compatibility, explicitly mark adjusted paths as renamed.

Fixes: #294
2019-06-23 18:08:31 +03:00
Mike Gelfand 139f3a3f4b Add missing declaration for `tr_strcasestr` 2019-06-23 12:07:33 +03:00
Mike Gelfand f3968b7708 Load CA certs from system store on Windows / OpenSSL
Fixes: #446
2019-06-23 11:59:53 +03:00
Mike Gelfand 3538eb93c3 Update curl and openssl to those in 10.10 SDK (macOS) 2019-06-22 16:43:59 +03:00
Mike Gelfand c369f36867 Only add revision to filename for nightly builds (MSI package) 2019-06-20 04:55:30 +03:00
Mike Gelfand fc5857f0d8 Include Windows Vista Qt style, remove dbus revision suffix and expat (MSI package) 2019-06-20 04:55:30 +03:00
Mike Gelfand 1f756114a5 Support OpenSSL 1.1 x64 file names (MSI package) 2019-06-18 22:50:03 +03:00
Mike Gelfand af3d4639e2 Support OpenSSL 1.1 file names (MSI package) 2019-06-18 08:21:01 +03:00
Mike Gelfand a82c26642c Support MSVS 2017 VC CRT MSM file locations (MSI package) 2019-06-18 08:10:30 +03:00
C.W. Betts 77016edadd Xcode: Update/fix framework references. 2019-06-15 12:19:34 -06:00
C.W. Betts 2d4a53f2df Xcode: Fix development region. 2019-06-15 12:12:55 -06:00
C.W. Betts 3b1780982a Xcode: Add encoding info to strings files. 2019-06-15 09:37:14 -06:00
C.W. Betts 04c6885232 Xcode: Fix localization paths. 2019-06-15 09:23:17 -06:00
C.W. Betts 8911c9a839 Fix Xcode groups:
Make them actually point to the folders.
2019-06-15 09:15:10 -06:00
Mitch Livingston cff5a68814
Merge branch 'master' into dock_string_crash_fix 2019-04-27 21:43:10 -04:00
Mike Gelfand 3d9fd25269 Fixup invalid daemon foreground mode check (2cc996cb77) 2019-04-22 07:20:46 +03:00
Dmitry Serov 4d071deead Log attempts to open non-URL strings 2019-04-19 15:41:02 +07:00
Dmitry Serov 4331d9f0c7 Ignore non-URL strings when opening URLs 2019-04-19 02:28:45 +07:00
LaserEyess 750589101a Parse session-id header case-insensitively (#765)
RFC 2616 defines headers as case-insensitive, so if rpc is behind a
reverse proxy that lowers the case of headers, transmission will not
parse them correctly.

A new wrapper function, `tr_strcasestr` is added to
libtransmission/utils.c to allow for comparisons of headers case
insensitively, and checks in cmake and autogen are included.
2019-03-17 17:37:52 +03:00
Mike Gelfand e736604fc3 Mark a couple of MSI properties as secure
They are being discarded by server side with "ignoring disallowed
property" messages otherwise which leads to failed checks using those
properties.

Fixes: #451
2019-03-17 17:33:58 +03:00
Mike Gelfand c567588587 Remove useless parentheses 2019-03-17 09:18:27 +03:00
Mike Gelfand 5693e59256 Define each identifier in a dedicated statement
* MISRA C++:2008, 8-0-1 - An init-declarator-list or a member-declarator-list
  shall consist of a single init-declarator or member-declarator respectively
* CERT, DCL52-J. - Do not declare more than one variable per declaration
* CERT, DCL04-C. - Do not declare more than one variable per declaration
2019-03-17 09:15:35 +03:00
Mike Gelfand 97a0fed734 Remove side effects from right hand operands of && or ||
* MISRA C:2004, 12.4 - The right-hand operand of a logical && or || operator
  shall not contain side effects.
* MISRA C++:2008, 5-14-1 - The right hand operand of a logical && or ||
  operator shall not contain side effects.
* MISRA C:2012, 13.5 - The right hand operand of a logical && or || operator
  shall not contain persistent side effects
* CERT, EXP02-C. - Be aware of the short-circuit behavior of the logical AND
  and OR operators
2019-03-17 09:09:08 +03:00
Mike Gelfand 17307e7484 Extract assignments from expression
Assignments explicitly enclosed in parentheses are ignored.

* MISRA C:2004, 13.1 - Assignment operators shall not be used in expressions
  that yield a Boolean value
* MISRA C++:2008, 6-2-1 - Assignment operators shall not be used in
  sub-expressions
* MISRA C:2012, 13.4 - The result of an assignment operator should not be used
* MITRE, CWE-481 - Assigning instead of Comparing
* CERT, EXP45-C. - Do not perform assignments in selection statements
* CERT, EXP51-J. - Do not perform assignments in conditional expressions
2019-03-17 08:00:15 +03:00
Mike Gelfand d3b8982195 Uppercase the literal suffixes
* MISRA C++:2008, 2-13-4 - Literal suffixes shall be upper case
* MISRA C:2012, 7.3 - The lowercase character "l" shall not be used in a
  literal suffix
* CERT DCL16-C. - Use "L," not "l," to indicate a long value
* CERT, DCL50-J. - Use visually distinct identifiers
2019-03-17 07:07:48 +03:00
Mitch Livingston a2c42268dc
Merge pull request #859 from fishead/fix-typo
fix typo
2019-03-16 12:51:32 -04:00
Chuan Zhang 84f3ba606a
typo 2019-03-16 22:36:18 +08:00
Mike Gelfand 2cc996cb77 Refactor daemon startup a bit
Fix exit code to be zero when dumping settings along the way.

Closes: #487
2019-03-15 21:55:45 +03:00