Date: Thu, 5 Dec 2013 21:14:47 GMT From: Arseny Nasokin <eirnym@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: ports/184524: [PATCH] RPC sugar for transmission-cli and daemon Message-ID: <201312052114.rB5LElAJ065800@oldred.freebsd.org> Resent-Message-ID: <201312052120.rB5LK0TG033525@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 184524 >Category: ports >Synopsis: [PATCH] RPC sugar for transmission-cli and daemon >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Dec 05 21:20:00 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Arseny Nasokin >Release: FreeBSD 11-CURRENT >Organization: private person >Environment: >Description: I want to share my RPC sugar patch I use for years. It adds several categories for torrent files filtered inside libtransmission, because client (e.g. transmission-remote in my case) don't have enough information. >How-To-Repeat: >Fix: Patch attached with submission follows: # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # rpc-sugar # Makefile.patch # echo x - rpc-sugar sed 's/^X//' >rpc-sugar << 'END-of-rpc-sugar' XIndex: libtransmission/rpcimpl.c X=================================================================== X--- libtransmission/rpcimpl.c (revision 14215) X+++ libtransmission/rpcimpl.c (working copy) X@@ -160,7 +160,7 @@ X } X else if (tr_variantDictFindStr (args, TR_KEY_ids, &str, NULL)) X { X- if (!strcmp (str, "recently-active")) X+ if (!strcmp (str, "recently-active")) /* Torrents with last activity in RECENTLY_ACTIVE_SECONDS */ X { X tr_torrent * tor = NULL; X const time_t now = tr_time (); X@@ -171,6 +171,147 @@ X if (tor->anyDate >= now - window) X torrents[torrentCount++] = tor; X } X+ else if (!strcmp (str, "running")) /* Currently active torrents. */ X+ { X+ tr_torrent * tor = NULL; X+ const int n = tr_sessionCountTorrents (session); X+ torrents = tr_new0 (tr_torrent *, n); X+ while ((tor = tr_torrentNext (session, tor))) X+ { X+ const tr_torrent_activity activity = tr_torrentGetActivity (tor); X+ if (activity != TR_STATUS_STOPPED && activity != TR_STATUS_CHECK && \ X+ activity != TR_STATUS_CHECK_WAIT) X+ torrents[torrentCount++] = tor; X+ } X+ } X+ else if (!strcmp (str, "paused")) /* Not finished and stopped torrents */ X+ { X+ tr_torrent * tor = NULL; X+ const int n = tr_sessionCountTorrents (session); X+ torrents = tr_new0 (tr_torrent *, n); X+ while ((tor = tr_torrentNext (session, tor))) X+ if (tr_torrentGetActivity (tor) == TR_STATUS_STOPPED && \ X+ tr_torrentGetCompleteness(tor) != TR_SEED) X+ torrents[torrentCount++] = tor; X+ } X+ else if (!strcmp (str, "stopped")) /* Finished and stopped torrents */ X+ { X+ tr_torrent * tor = NULL; X+ const int n = tr_sessionCountTorrents (session); X+ torrents = tr_new0 (tr_torrent *, n); X+ while ((tor = tr_torrentNext (session, tor))) X+ if (tr_torrentGetActivity (tor) == TR_STATUS_STOPPED && \ X+ tr_torrentGetCompleteness(tor) == TR_SEED) X+ torrents[torrentCount++] = tor; X+ } X+ else if (!strcmp (str, "idle")) /* Torrents has been queued to seed or download */ X+ { X+ tr_torrent * tor = NULL; X+ const int n = tr_sessionCountTorrents (session); X+ torrents = tr_new0 (tr_torrent *, n); X+ while ((tor = tr_torrentNext (session, tor))) X+ { X+ const tr_torrent_activity activity = tr_torrentGetActivity (tor); X+ if (activity == TR_STATUS_SEED_WAIT || activity == TR_STATUS_DOWNLOAD_WAIT) X+ torrents[torrentCount++] = tor; X+ } X+ } X+ else if (!strcmp (str, "downloading")) /* Download in progress */ X+ { X+ tr_torrent * tor = NULL; X+ const int n = tr_sessionCountTorrents (session); X+ torrents = tr_new0 (tr_torrent *, n); X+ while ((tor = tr_torrentNext (session, tor))) X+ if (tr_torrentGetActivity (tor) == TR_STATUS_DOWNLOAD) X+ torrents[torrentCount++] = tor; X+ } X+ else if (!strcmp (str, "seeding")) /* Now seeding */ X+ { X+ tr_torrent * tor = NULL; X+ const int n = tr_sessionCountTorrents (session); X+ torrents = tr_new0 (tr_torrent *, n); X+ while ((tor = tr_torrentNext (session, tor))) X+ if (tr_torrentGetActivity (tor) == TR_STATUS_SEED) X+ torrents[torrentCount++] = tor; X+ } X+ else if (!strcmp (str, "verify")) /* Torrents in verify state */ X+ { X+ tr_torrent * tor = NULL; X+ const int n = tr_sessionCountTorrents (session); X+ torrents = tr_new0 (tr_torrent *, n); X+ while ((tor = tr_torrentNext (session, tor))) X+ { X+ const tr_torrent_activity activity = tr_torrentGetActivity (tor); X+ if (activity == TR_STATUS_CHECK || activity == TR_STATUS_CHECK_WAIT) X+ torrents[torrentCount++] = tor; X+ } X+ } X+ else if (!strcmp (str, "error")) /* Torrents with local errors */ X+ { X+ tr_torrent * tor = NULL; X+ const int n = tr_sessionCountTorrents (session); X+ torrents = tr_new0 (tr_torrent *, n); X+ while ((tor = tr_torrentNext (session, tor))) X+ { X+ const tr_torrent_activity activity = tr_torrentGetActivity (tor); X+ if (tor->error == TR_STAT_LOCAL_ERROR && activity != TR_STATUS_CHECK && \ X+ activity != TR_STATUS_CHECK_WAIT) X+ torrents[torrentCount++] = tor; X+ } X+ } X+ else if (!strcmp (str, "gone")) /* Torrents with permanent tracker errors */ X+ { X+ tr_torrent * tor = NULL; X+ const int n = tr_sessionCountTorrents (session); X+ torrents = tr_new0 (tr_torrent *, n); X+ while ((tor = tr_torrentNext (session, tor))) X+ { X+ const tr_torrent_activity activity = tr_torrentGetActivity (tor); X+ if (tor->error == TR_STAT_TRACKER_ERROR && activity != TR_STATUS_CHECK && \ X+ activity != TR_STATUS_CHECK_WAIT) X+ torrents[torrentCount++] = tor; X+ } X+ } X+ else if (!strcmp (str, "warn")) /* Torrents which has tracker warnings */ X+ { X+ tr_torrent * tor = NULL; X+ const int n = tr_sessionCountTorrents (session); X+ torrents = tr_new0 (tr_torrent *, n); X+ while ((tor = tr_torrentNext (session, tor))) X+ { X+ const tr_torrent_activity activity = tr_torrentGetActivity (tor); X+ if (tor->error == TR_STAT_TRACKER_WARNING && activity != TR_STATUS_CHECK && \ X+ activity != TR_STATUS_CHECK_WAIT) X+ torrents[torrentCount++] = tor; X+ } X+ } X+ else if (!strcmp (str, "healthy")) /* Fine torrents */ X+ { X+ tr_torrent * tor = NULL; X+ const int n = tr_sessionCountTorrents (session); X+ torrents = tr_new0 (tr_torrent *, n); X+ while ((tor = tr_torrentNext (session, tor))) X+ if (tor->error == TR_STAT_OK) X+ torrents[torrentCount++] = tor; X+ } X+ else if (!strcmp (str, "done")) /* Finished torrents */ X+ { X+ tr_torrent * tor = NULL; X+ const int n = tr_sessionCountTorrents (session); X+ torrents = tr_new0 (tr_torrent *, n); X+ while ((tor = tr_torrentNext (session, tor))) X+ if (tr_torrentGetCompleteness(tor) == TR_SEED) X+ torrents[torrentCount++] = tor; X+ } X+ else if (!strcmp (str, "leech")) /* Not finished torrents */ X+ { X+ tr_torrent * tor = NULL; X+ const int n = tr_sessionCountTorrents (session); X+ torrents = tr_new0 (tr_torrent *, n); X+ while ((tor = tr_torrentNext (session! tor))) X+ if (tr_torrentGetCompleteness(tor) != TR_SEED) X+ torrents[torrentCount++] = tor; X+ } X else X { X tr_torrent * tor; END-of-rpc-sugar echo x - Makefile.patch sed 's/^X//' >Makefile.patch << 'END-of-Makefile.patch' X27a28,32 X> .if ${SLAVEPORT} == cli || ${SLAVEPORT} == daemon X> OPTIONS_DEFINE+= RPC_SUGAR X> RPC_SUGAR_DESC?= some RPC sugar for CLI and daemon X> .endif X> X56a62,65 X> .if ${PORT_OPTIONS:MRPC_SUGAR} X> CONFIGURE_ARGS+=--enable-lightweight X> .endif X> END-of-Makefile.patch exit >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201312052114.rB5LElAJ065800>