From 6489160ed30d7f5ca17e9675c2d667bc58820021 Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Mon, 27 Aug 2012 18:20:00 +0200 Subject: [PATCH] Added Transmission's comment field, which ends up in the error text message in the details screen for now. See issue 207. --- .../daemon/Transmission/TransmissionAdapter.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/src/org/transdroid/daemon/Transmission/TransmissionAdapter.java b/lib/src/org/transdroid/daemon/Transmission/TransmissionAdapter.java index 01e4a193..5c3bddeb 100644 --- a/lib/src/org/transdroid/daemon/Transmission/TransmissionAdapter.java +++ b/lib/src/org/transdroid/daemon/Transmission/TransmissionAdapter.java @@ -104,6 +104,7 @@ public class TransmissionAdapter implements IDaemonAdapter { private static final String RPC_DATEADDED = "addedDate"; private static final String RPC_DATEDONE = "doneDate"; private static final String RPC_AVAILABLE = "desiredAvailable"; + private static final String RPC_COMMENT = "comment"; private static final String RPC_FILE_NAME = "name"; private static final String RPC_FILE_LENGTH = "length"; @@ -142,7 +143,7 @@ public class TransmissionAdapter implements IDaemonAdapter { final String[] fieldsArray = new String[] { RPC_ID, RPC_NAME, RPC_ERROR, RPC_ERRORSTRING, RPC_STATUS, RPC_DOWNLOADDIR, RPC_RATEDOWNLOAD, RPC_RATEUPLOAD, RPC_PEERSGETTING, RPC_PEERSSENDING, RPC_PEERSCONNECTED, RPC_ETA, RPC_DOWNLOADSIZE1, RPC_DOWNLOADSIZE2, RPC_UPLOADEDEVER, - RPC_TOTALSIZE, RPC_DATEADDED, RPC_DATEDONE, RPC_AVAILABLE }; + RPC_TOTALSIZE, RPC_DATEADDED, RPC_DATEDONE, RPC_AVAILABLE, RPC_COMMENT }; for (String field : fieldsArray) { fields.put(field); } @@ -472,6 +473,9 @@ public class TransmissionAdapter implements IDaemonAdapter { // Error is a number, see https://trac.transmissionbt.com/browser/trunk/libtransmission/transmission.h#L1747 // We only consider it a real error if it is local (blocking), which is error code 3 boolean hasError = tor.getInt(RPC_ERROR) == 3; + String errorString = tor.getString(RPC_ERRORSTRING); + String commentString = tor.getString(RPC_COMMENT); + errorString = errorString.isEmpty()? commentString : errorString + "\n" + commentString; torrents.add(new Torrent( tor.getInt(RPC_ID), null, @@ -493,7 +497,7 @@ public class TransmissionAdapter implements IDaemonAdapter { (total == 0? 0: (have+(float)tor.getLong(RPC_AVAILABLE))/(float)total), null, // No label/category/group support in the RPC API for now new Date(tor.getLong(RPC_DATEADDED)), - tor.getString(RPC_ERRORSTRING) != null && tor.getString(RPC_ERRORSTRING).equals("")? null: tor.getString(RPC_ERRORSTRING))); + errorString)); } // Return the list