From nobody@FreeBSD.org  Thu Dec  5 21:14:48 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTPS id 5CD7E3D2
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  5 Dec 2013 21:14:48 +0000 (UTC)
Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 3D6851CF9
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  5 Dec 2013 21:14:48 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id rB5LEmVb065917
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 5 Dec 2013 21:14:48 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id rB5LElAJ065800;
	Thu, 5 Dec 2013 21:14:47 GMT
	(envelope-from nobody)
Message-Id: <201312052114.rB5LElAJ065800@oldred.freebsd.org>
Date: Thu, 5 Dec 2013 21:14:47 GMT
From: Arseny Nasokin <eirnym@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [PATCH] RPC sugar for transmission-cli and daemon
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         184524
>Category:       ports
>Synopsis:       [PATCH] net-p2p/transmission: RPC sugar for transmission-cli and daemon
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    crees
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Dec 05 21:20:00 UTC 2013
>Closed-Date:    Sat Dec 21 16:54:26 UTC 2013
>Last-Modified:  Sat Dec 21 16:54:26 UTC 2013
>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:
Responsible-Changed-From-To: freebsd-ports-bugs->crees 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Fri Dec 6 07:06:17 UTC 2013 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=184524 
State-Changed-From-To: open->closed 
State-Changed-By: crees 
State-Changed-When: Sat Dec 21 16:54:25 UTC 2013 
State-Changed-Why:  
I'm sorry that I missed the email about this.  This is fantastic work, 
although it does not belong in the ports tree.  Please pass it upstream, 
and it will be in the next released version if you get it in on time! 
If you need help with that, please ask me. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=184524 
>Unformatted:
