Commit Graph

36 Commits

Author SHA1 Message Date
Charles Kerr f59118d1fe
feat: add torrent-get 'primary-mime-type' to RPC. (#1464)
* feat: add torrent-get 'primary-mime-type' to RPC.

This is a cheap way for RPC clients to know what type of content is in a
torrent. This info can be used to display the torrent, e.g. by using an
icon that corresponds to the mime type.

* use size_t for content byte count

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* explicit boolean expressions

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* use uint64_t for content byte counts

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* avoid unnecessary logic branches

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* explicit cast

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>

* refactor: add an autogenerated mime-type.h header

* chore: maybe fix the win32 FTBFS

* chore: add mime-types.[ch] to xcode

* Squashed commit of the following:

commit 4c7153fa48
Author: Mike Gelfand <mikedld@users.noreply.github.com>
Date:   Tue Oct 13 03:15:19 2020 +0300

    Remove autotools-based build system (#1465)

    * Support .git files (e.g. for worktrees, submodules)
    * Fix symlinks in source tarball, switch to TXZ, adjust non-release name
    * Remove autotools stuff

Co-authored-by: Mike Gelfand <mikedld@users.noreply.github.com>
2020-10-13 10:33:56 -05:00
Charles Kerr 92fc42ceb5
Scrape www subdomain for favicon (#1451)
* fix: scrape other subdomains for favicon
2020-09-17 00:38:13 -05:00
Charles Kerr 90ce7efc09
fixup: qt client nicer torrent add handling (#1427)
* refactor: omit unnecessary #include

* refactor: make the onDuplicatesTimer slot private.

* feat: show dupe torrents in dialog's detailText

* fix: a stupid bug that I introduced.
2020-09-07 10:20:48 -05:00
Charles Kerr fdaad67def fixup! refactor: make variant_headers reusable to qt app. (#1369) 2020-09-07 00:33:46 -05:00
Charles Kerr 6b89ee7903 fixup! refactor: make variant_headers reusable to qt app. (#1369) 2020-09-06 22:12:55 -05:00
Charles Kerr cf9b81eb7d
feat: nicer add-torrent workflow in the qt client. (#1410)
* If you accidentally try to add a lot of duplicates -- for example, by
  starting up with a lot of duplicate torrents in the watchdir -- then
  coalesce all of them into a single error dialog instead of spamming
  the desktop with a different dialog for every duplicate.

* Make the duplicate torrent dialog's error message slightly terser to
  make it accommodate a long list of torrents: omit the ".torrent" file
  suffixes and show an abbreviated form of the existing torrent's hash.

* Support searching by torrent hash in the filterbar's text entry.
  This is useful when copy/pasting the hash from the duplicate torrent
  error dialog and is also consistent with the GTK client behavior.

* Copy the GTK client's behavior of appending ".added" to the end of
  .torrent files after they've been added to the session.
2020-08-26 20:42:41 -05:00
Charles Kerr 68920f5fa6
refactor: remove exit-time destructors from transmission-qt (#1395)
* refactor: remove exit-time destructors from transmission-qt
2020-08-15 10:42:51 -05:00
Charles Kerr 677dc73eac
refactor: use GTest for running tests (#1383)
* refactor: use google-test on libtransmission tests
2020-08-11 13:11:55 -05:00
Charles Kerr 8f12792186
fix: ensure details dialog is updated on selection (#1376)
* fix: ensure details dialog is updated on selection
2020-07-29 11:56:23 -05:00
Charles Kerr 0b042d85dd
fix: type deduction error introduced in 00be8d0 (#1372)
Explicitly delete the implied function to ensure we don't get bitten by
this again in the future.

Mark the string_views constexpr where possible so that we can avoid some
strlen() calls at runtime.
2020-07-27 18:34:40 -05:00
Charles Kerr 00be8d00d7
refactor: make variant_headers reusable to qt app. (#1369)
* refactor: make variant_headers reusable to qt app.

Torrent.cc's `change()` template methods are generically useful to deal
with tr_variant wrangling, but previously were only used in Torrent.cc.
This PR moves them into a new API `VariantHelpers.h` for use by Prefs,
Session, TorrentModel, etc.
2020-07-26 23:30:58 -05:00
Charles Kerr 51573a3c1e
chore: clang-tidy cleanups (#1287)
* chore: fix syntax error in clang-tidy config file
2020-06-05 14:02:11 -05:00
Charles Kerr 1f28470cf4
chore: prefer QStringLiteral (#1284)
Further reading:
* https://forum.qt.io/topic/78540/qstringliteral-vs-qlatin1string/2
* https://woboq.com/blog/qstringliteral.html
* https://www.qt.io/blog/2014/06/13/qt-weekly-13-qstringliteral

tl;dr: QLatin1Literal uses less memory than QStringLiteral; however,
since most Qt APIs require a QString argument, there's extra runtime
cost of converting QLatin1Strings to QStrings. QStringLiteral uses a
little more memory but constructs its QStrings at compile time.

ok, the `prefer-qstringliteral` branch is getting out of control: the
secondary goal of fixing a .clang-tidy issue is causing more diffs
than the primary goal. So, I'm breaking it into two separate PRs.
2020-05-29 12:40:07 -05:00
Charles Kerr 070a7f2ffc
refactor: use snake_case field naming in qt client (#1262)
* refactor: use snake_case field naming in qt client

* fix: some missed symbols

* chore: make uncrustify happy

* fixup! refactor: use snake_case field naming in qt client
2020-05-27 16:53:12 -05:00
Charles Kerr d43aeb6a5c
chore: add clang-tidy checks to Qt client (#1236)
* chore: add clang-tidy integration for Qt client
2020-05-19 20:32:51 -05:00
Charles Kerr 6aa559f12f
refactor: remove QVariants from torrent (#1234)
* chore: remove qvariants from torrent class

* chore: remove unused Q_DECLARE macro calls

* refactor: remove unused includes from Torrent.h

* chore: make clang-tidy and linter happy

* refactor: rename 'setValue()' to 'change()'

* refactor: make tr_variant function paramters const

* chore: remove devel scaffolding

* refactor: rename peer_limit_ to peerLimit_

* refactor: do not use bitwise logic on booleans
2020-05-19 18:42:17 -05:00
Charles Kerr c62cb35fd4
qt client speedups
* faster updating of trackers combobox.
* generate trackerDisplayNames just once per torrent
* refactor: cache torrent delegate's warning emblem
* refactor: change mainwin refresh debounce to 200ms
* refactor: do not store trackers, hosts in QVariant
* refactor: don't use `virtual` when it's not needed
* refactor: faster counting torrents-matching-filter
* refactor: faster tracker handling in filterbar
* refactor: improve json parser's prealloc heuristic
* refactor: make Torrent::hasError() faster
* refactor: remove redundant speed stats collection
* refactor: remove unnecessary tor->isQueued() calls
* refactor: use unordered containers where possible
* scale favicons only once, when adding to the cache
2019-11-11 19:37:05 -06:00
Charles Kerr 96f76999aa
feat: add "table" format in torrent-get RPC (#1049)
* feat: add optional "format" arg to torrent-get RPC

If the "format" request was "objects" (default), "torrents" will be an
array of objects, each of which contains the key/value pairs matching
the request's "fields" arg. This is unchanged from previous versions.

If the format was "table", then "torrents" will be an array of arrays.
The first row holds the keys and each remaining row holds a torrent's
values for those keys. This format is more efficient in terms of JSON
generation and JSON parsing.
2019-11-09 17:02:23 -06:00
Charles Kerr d857a5821a
refractor: simplify torrent model signal emissions (#1044)
refractor: simplify torrent model signal emissions

The Torrent->Application signal connections make up for about 5% of the
app's memory use. Move this to the TorrentModel so that there are only a
handful of signal connections.

Moving signals to TorrentModel means batch change signals can be emitted
instead of per-change-per-torrent emissions and can be handled that way.
2019-11-09 08:44:40 -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
Mike Gelfand 82df3a87f4 Update to Uncrustify 0.68.1
Tweak a few rules in the process. Now all code in cli, daemon, gtk,
libtransmission, qt, and utils is properly formatted with no manual
intervention.
2019-02-15 09:21:48 +03:00
Mike Gelfand 375f2642c8 Revert dd538539aa, fix RPC queue processing
Queue callback for items returning no new future was never called leaving
queue alive and leading to memory leak in Qt client.
2017-07-15 08:46:31 +03:00
Mike Gelfand 6b0229a546 Fix some issues reported by Coverity 2017-05-16 21:37:00 +03:00
Mike Gelfand dd538539aa Fix torrent file trashing upon addition (Qt client) 2017-05-02 21:35:56 +03:00
Mike Gelfand a762c770f2 Make conditional expressions explicitly boolean 2017-04-30 19:26:01 +03:00
Mike Gelfand 6da99c05e2 Use nullptr consistencty instead of 0 and NULL (Qt client) 2017-04-30 19:26:01 +03:00
Mike Gelfand dadffa2c0f Align type qualifiers to the right (code style)
This way all the qualifiers (`const`, `volatile`, `mutable`) are grouped
together, e.g. `T const* const x` vs. `const T* const x`. Also helps reading
types right-to-left, e.g. "constant pointer to constant T" vs. "constant
pointer to T which is constant".
2017-04-20 19:53:20 +03:00
Mike Gelfand d7930984ef Adjust uncrustify config, reformat all but Mac client
There're places where manual intervention is still required as uncrustify
is not ideal (unfortunately), but at least one may rely on it to do the
right thing most of the time (e.g. when sending in a patch).

The style itself is quite different from what we had before but making it
uniform across all the codebase is the key. I also hope that it'll make the
code more readable (YMMV) and less sensitive to further changes.
2017-04-20 10:01:22 +03:00
Mike Gelfand 4b4797a220 Revert debugging code... 2016-10-03 21:54:21 +03:00
Mike Gelfand 981ef30ab4 Use session ID (if available) to check if session is local or not (Qt client) 2016-10-03 21:26:28 +03:00
Mike Gelfand 2248d3670f Get rid of $Id$ SVN keywords in source files 2016-09-02 23:10:15 +03:00
Mike Gelfand 2b917de65b Refactor RPC requests code for proper queueing (patch by intelfx @ GH-10)
This refactoring is driven by the need to be able to do true queued RPC calls
(where each successive call uses the result of the previous).

Currently, such queueing of requests is done by assigning them special "magic"
tag numbers, which are then intercepted in one big switch() statement and acted
upon. This (aside from making code greatly unclear) effectively makes each such
queue a singleton, because state passing is restricted to global variables.

We refactor RpcClient to assign an unique tag to each remote call, and then
abstract all the call<->response matching with Qt's future/promise mechanism.

Finally, we introduce a "RPC request queue" class (RpcQueue) which is built on
top of QFutureWatcher and C++11's <functional> library. This class maintains
a queue of functions, where each function receives an RPC response, does
necessary processing, performs another call and finally returns its future.
2016-04-19 20:41:59 +00:00
Mike Gelfand c955c04d8f Explicitly compare result of str(n)cmp/memcmp to signify that it's not boolean 2016-03-13 22:11:01 +00:00
Mike Gelfand f89fab72f9 Remove unused session tag 2015-10-18 18:39:14 +00:00
Mike Gelfand 5120fc0f2c Unify/prettify Qt client headers style 2015-06-12 22:12:12 +00:00
Mike Gelfand 07912d230b Use PascalCase for Qt client filenames
Split FileTree.{h,cc} and FilterBar.{h,cc} files so that each class
is in its own file.

This breaks translations (some classes got renamed => context changed),
to be fixed by next commit (along with Tx sync).
2015-06-10 21:27:11 +00:00
Renamed from qt/session.cc (Browse further)