From 81b4acbcdae282498216f49fb636a708459225b0 Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Thu, 4 Oct 2018 10:53:12 +0200 Subject: [PATCH 01/11] Pushed 2.5.11 release. --- latest-app.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/latest-app.html b/latest-app.html index 5e39b4c6..1e0815d5 100644 --- a/latest-app.html +++ b/latest-app.html @@ -1 +1 @@ -230|2.5.10 +231|2.5.11 From 3f3ca820e5bb16d2b80e915237d860e4604af1c5 Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Fri, 5 Oct 2018 20:55:53 +0200 Subject: [PATCH 02/11] Fix cleartext (non-ssl) http traffic on Android 9 though an explicit opt-in. --- app/src/main/AndroidManifest.xml | 3 ++- .../java/org/transdroid/daemon/Deluge/DelugeAdapter.java | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d55663f2..be680f59 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -49,7 +49,8 @@ android:icon="@drawable/ic_launcher" android:banner="@drawable/banner" android:label="@string/app_name" - android:theme="@style/Theme.AppCompat" > + android:theme="@style/Theme.AppCompat" + android:usesCleartextTraffic="true"> Date: Fri, 5 Oct 2018 21:49:20 +0200 Subject: [PATCH 03/11] Added real upload amount for qBittorrent (especially useful if files where available before starting the torrent). Fixes #259. --- .../daemon/Qbittorrent/QbittorrentAdapter.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java b/app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java index 82d53c9a..d61187e6 100644 --- a/app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java +++ b/app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java @@ -499,6 +499,7 @@ public class QbittorrentAdapter implements IDaemonAdapter { int seeders[]; double ratio; long size; + long uploaded; int dlspeed; int upspeed; Date addedOn = null; @@ -516,6 +517,11 @@ public class QbittorrentAdapter implements IDaemonAdapter { ratio = tor.getDouble("ratio"); dlspeed = tor.getInt("dlspeed"); upspeed = tor.getInt("upspeed"); + if (tor.has("uploaded")) { + uploaded = tor.getLong("uploaded"); + } else { + uploaded = (long) (size * ratio); + } final long addedOnTime = tor.optLong("added_on"); addedOn = (addedOnTime > 0) ? new Date(addedOnTime * 1000L) : null; final long completionOnTime = tor.optLong("completion_on"); @@ -529,6 +535,7 @@ public class QbittorrentAdapter implements IDaemonAdapter { seeders = parsePeers(tor.getString("num_seeds")); size = parseSize(tor.getString("size")); ratio = parseRatio(tor.getString("ratio")); + uploaded = (long) (size * ratio); dlspeed = parseSpeed(tor.getString("dlspeed")); upspeed = parseSpeed(tor.getString("upspeed")); } @@ -552,7 +559,7 @@ public class QbittorrentAdapter implements IDaemonAdapter { leechers[1], (int) eta, (long) (size * progress), - (long) (size * ratio), + uploaded, size, (float) progress, 0f, From 68e72d535abd9c0955336fc64d54d16ef36a590e Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Fri, 5 Oct 2018 22:00:04 +0200 Subject: [PATCH 04/11] Added real upload amount for qBittorrent (especially useful if files where available before starting the torrent). Fixes #259. Add support to set download location with qBittorrent. Fixes #399. --- .../java/org/transdroid/daemon/Daemon.java | 2 +- .../Qbittorrent/QbittorrentAdapter.java | 28 ++++++------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/org/transdroid/daemon/Daemon.java b/app/src/main/java/org/transdroid/daemon/Daemon.java index 8c98d2a0..0d1b655f 100644 --- a/app/src/main/java/org/transdroid/daemon/Daemon.java +++ b/app/src/main/java/org/transdroid/daemon/Daemon.java @@ -377,7 +377,7 @@ public enum Daemon { } public static boolean supportsSetDownloadLocation(Daemon type) { - return type == Transmission || type == Deluge || type == DelugeRpc || type == Dummy; + return type == Transmission || type == Deluge || type == DelugeRpc || type == qBittorrent || type == Dummy; } public static boolean supportsSetAlternativeMode(Daemon type) { diff --git a/app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java b/app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java index d61187e6..0982053d 100644 --- a/app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java +++ b/app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java @@ -45,25 +45,7 @@ import org.transdroid.daemon.Torrent; import org.transdroid.daemon.TorrentDetails; import org.transdroid.daemon.TorrentFile; import org.transdroid.daemon.TorrentStatus; -import org.transdroid.daemon.task.AddByFileTask; -import org.transdroid.daemon.task.AddByMagnetUrlTask; -import org.transdroid.daemon.task.AddByUrlTask; -import org.transdroid.daemon.task.DaemonTask; -import org.transdroid.daemon.task.DaemonTaskFailureResult; -import org.transdroid.daemon.task.DaemonTaskResult; -import org.transdroid.daemon.task.DaemonTaskSuccessResult; -import org.transdroid.daemon.task.GetFileListTask; -import org.transdroid.daemon.task.GetFileListTaskSuccessResult; -import org.transdroid.daemon.task.GetStatsTask; -import org.transdroid.daemon.task.GetStatsTaskSuccessResult; -import org.transdroid.daemon.task.GetTorrentDetailsTask; -import org.transdroid.daemon.task.GetTorrentDetailsTaskSuccessResult; -import org.transdroid.daemon.task.RemoveTask; -import org.transdroid.daemon.task.RetrieveTask; -import org.transdroid.daemon.task.RetrieveTaskSuccessResult; -import org.transdroid.daemon.task.SetFilePriorityTask; -import org.transdroid.daemon.task.SetLabelTask; -import org.transdroid.daemon.task.SetTransferRatesTask; +import org.transdroid.daemon.task.*; import org.transdroid.daemon.util.HttpHelper; import java.io.File; @@ -318,6 +300,14 @@ public class QbittorrentAdapter implements IDaemonAdapter { new BasicNameValuePair("category", labelTask.getNewLabel())); return new DaemonTaskSuccessResult(task); + case SetDownloadLocation: + + SetDownloadLocationTask setLocationTask = (SetDownloadLocationTask) task; + makeRequest(log, "/command/setLocation", + new BasicNameValuePair("hashes", task.getTargetTorrent().getUniqueID()), + new BasicNameValuePair("location", setLocationTask.getNewLocation())); + return new DaemonTaskSuccessResult(task); + case SetTransferRates: // Request to set the maximum transfer rates From 988c7868929d0f8f12d31fe955c5671e0a655014 Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Fri, 5 Oct 2018 22:06:46 +0200 Subject: [PATCH 05/11] Very light code cleanup. --- .../java/org/transdroid/daemon/Daemon.java | 34 +++++++++++-------- .../transdroid/daemon/DaemonException.java | 5 ++- .../org/transdroid/daemon/DaemonMethod.java | 2 +- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/org/transdroid/daemon/Daemon.java b/app/src/main/java/org/transdroid/daemon/Daemon.java index 0d1b655f..1024efe3 100644 --- a/app/src/main/java/org/transdroid/daemon/Daemon.java +++ b/app/src/main/java/org/transdroid/daemon/Daemon.java @@ -302,12 +302,14 @@ public enum Daemon { } public static boolean supportsAvailability(Daemon type) { - return type == uTorrent || type == BitTorrent || type == DLinkRouterBT || type == Transmission || type == Vuze || type == BuffaloNas || type == Dummy; + return type == uTorrent || type == BitTorrent || type == DLinkRouterBT || type == Transmission || type == Vuze || type == BuffaloNas + || type == Dummy; } public static boolean supportsFileListing(Daemon type) { - return type == Synology || type == Transmission || type == uTorrent || type == BitTorrent || type == KTorrent || type == Deluge || type == DelugeRpc - || type == rTorrent || type == Vuze || type == DLinkRouterBT || type == Bitflu || type == qBittorrent || type == BuffaloNas || type == BitComet || type == Aria2 || type == tTorrent || type == Dummy; + return type == Synology || type == Transmission || type == uTorrent || type == BitTorrent || type == KTorrent || type == Deluge + || type == DelugeRpc || type == rTorrent || type == Vuze || type == DLinkRouterBT || type == Bitflu || type == qBittorrent + || type == BuffaloNas || type == BitComet || type == Aria2 || type == tTorrent || type == Dummy; } public static boolean supportsFineDetails(Daemon type) { @@ -339,7 +341,8 @@ public enum Daemon { public static boolean supportsSetTransferRates(Daemon type) { return type == Deluge || type == DelugeRpc - || type == Transmission || type == uTorrent || type == BitTorrent || type == rTorrent || type == Vuze || type == BuffaloNas || type == BitComet || type == Aria2 || type == qBittorrent || type == Dummy; + || type == Transmission || type == uTorrent || type == BitTorrent || type == rTorrent || type == Vuze || type == BuffaloNas + || type == BitComet || type == Aria2 || type == qBittorrent || type == Dummy; } public static boolean supportsAddByFile(Daemon type) { @@ -349,26 +352,31 @@ public enum Daemon { public static boolean supportsAddByMagnetUrl(Daemon type) { return type == uTorrent || type == BitTorrent || type == Transmission || type == Synology || type == Deluge || type == DelugeRpc - || type == Bitflu || type == KTorrent || type == rTorrent || type == qBittorrent || type == BitComet || type == Aria2 || type == tTorrent || type == Dummy; + || type == Bitflu || type == KTorrent || type == rTorrent || type == qBittorrent || type == BitComet || type == Aria2 + || type == tTorrent || type == Dummy; } public static boolean supportsRemoveWithData(Daemon type) { return type == uTorrent || type == Vuze || type == Transmission || type == Deluge || type == DelugeRpc - || type == BitTorrent || type == Tfb4rt || type == DLinkRouterBT || type == Bitflu || type == qBittorrent || type == BuffaloNas || type == BitComet || type == rTorrent || type == Aria2 || type == tTorrent || type == Dummy; + || type == BitTorrent || type == Tfb4rt || type == DLinkRouterBT || type == Bitflu || type == qBittorrent || type == BuffaloNas + || type == BitComet || type == rTorrent || type == Aria2 || type == tTorrent || type == Dummy; } public static boolean supportsFilePrioritySetting(Daemon type) { - return type == BitTorrent || type == uTorrent || type == Transmission || type == KTorrent || type == rTorrent || type == Vuze || type == Deluge || type == DelugeRpc + return type == BitTorrent || type == uTorrent || type == Transmission || type == KTorrent || type == rTorrent || type == Vuze + || type == Deluge || type == DelugeRpc || type == qBittorrent || type == tTorrent || type == Dummy; } public static boolean supportsDateAdded(Daemon type) { - return type == Vuze || type == Transmission || type == rTorrent || type == Bitflu || type == BitComet || type == uTorrent || type == BitTorrent || type == Deluge || type == DelugeRpc + return type == Vuze || type == Transmission || type == rTorrent || type == Bitflu || type == BitComet || type == uTorrent + || type == BitTorrent || type == Deluge || type == DelugeRpc || type == qBittorrent || type == Dummy; } public static boolean supportsLabels(Daemon type) { - return type == uTorrent || type == BitTorrent || type == Deluge || type == DelugeRpc || type == BitComet || type == rTorrent || type == qBittorrent || type == Dummy; + return type == uTorrent || type == BitTorrent || type == Deluge || type == DelugeRpc || type == BitComet || type == rTorrent + || type == qBittorrent || type == Dummy; } public static boolean supportsSetLabel(Daemon type) { @@ -389,18 +397,16 @@ public enum Daemon { } public static boolean supportsForceRecheck(Daemon type) { - return type == uTorrent || type == BitTorrent || type == Deluge || type == DelugeRpc || type == rTorrent || type == Transmission || type == Dummy || type == qBittorrent; + return type == uTorrent || type == BitTorrent || type == Deluge || type == DelugeRpc || type == rTorrent || type == Transmission + || type == Dummy || type == qBittorrent; } public static boolean supportsExtraPassword(Daemon type) { return type == Deluge || type == Aria2; } - public static boolean supportsUsernameForHttp(Daemon type) { - return type == Deluge || type == Aria2; - } - public static boolean supportsRemoteRssManagement(Daemon type) { return type == uTorrent || type == DelugeRpc; } + } diff --git a/app/src/main/java/org/transdroid/daemon/DaemonException.java b/app/src/main/java/org/transdroid/daemon/DaemonException.java index f2d721c7..ca367540 100644 --- a/app/src/main/java/org/transdroid/daemon/DaemonException.java +++ b/app/src/main/java/org/transdroid/daemon/DaemonException.java @@ -18,6 +18,8 @@ package org.transdroid.daemon; +import android.support.annotation.NonNull; + /** * An exception thrown when an error occurs inside a server daemon adapter. * The error message is from a resource string ID, since this can be @@ -40,7 +42,7 @@ public class DaemonException extends Exception { ParsingFailed, AuthenticationFailure, NotConnected, - FileAccessError; + FileAccessError } public DaemonException(ExceptionType internalException, String message) { @@ -52,6 +54,7 @@ public class DaemonException extends Exception { return internalException; } + @NonNull @Override public String toString() { return internalException.toString() + " exception: " + getMessage(); diff --git a/app/src/main/java/org/transdroid/daemon/DaemonMethod.java b/app/src/main/java/org/transdroid/daemon/DaemonMethod.java index d459dcb1..f9ec9b7b 100644 --- a/app/src/main/java/org/transdroid/daemon/DaemonMethod.java +++ b/app/src/main/java/org/transdroid/daemon/DaemonMethod.java @@ -47,7 +47,7 @@ public enum DaemonMethod { ForceRecheck (22); private int code; - private static final Map lookup = new HashMap(); + private static final Map lookup = new HashMap<>(); static { for(DaemonMethod s : EnumSet.allOf(DaemonMethod.class)) From e0d0810be74f50dc00ca3156074f59a3121fcfd8 Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Fri, 5 Oct 2018 22:31:04 +0200 Subject: [PATCH 06/11] Show sizes in GB with 2 decimal places. Fixes #458. --- .../daemon/util/FileSizeConverter.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/transdroid/daemon/util/FileSizeConverter.java b/app/src/main/java/org/transdroid/daemon/util/FileSizeConverter.java index 13f18e38..6fad9fa5 100644 --- a/app/src/main/java/org/transdroid/daemon/util/FileSizeConverter.java +++ b/app/src/main/java/org/transdroid/daemon/util/FileSizeConverter.java @@ -17,6 +17,8 @@ */ package org.transdroid.daemon.util; +import java.util.Locale; + /** * Quick and dirty file size formatter. * @author erickok @@ -24,6 +26,7 @@ package org.transdroid.daemon.util; public class FileSizeConverter { private static final String DECIMAL_FORMATTER = "%.1f"; + private static final String DECIMAL_FORMATTER_GB = "%.2f"; /** * A quantity in which to express a file size. @@ -48,13 +51,13 @@ public class FileSizeConverter { out = String.valueOf(from); break; case KB: - out = String.format(DECIMAL_FORMATTER, ((double) from) / INC_SIZE); + out = String.format(Locale.getDefault(), DECIMAL_FORMATTER, ((double) from) / INC_SIZE); break; case MB: - out = String.format(DECIMAL_FORMATTER, ((double) from) / INC_SIZE / INC_SIZE); + out = String.format(Locale.getDefault(), DECIMAL_FORMATTER, ((double) from) / INC_SIZE / INC_SIZE); break; default: - out = String.format(DECIMAL_FORMATTER, ((double) from) / INC_SIZE / INC_SIZE / INC_SIZE); + out = String.format(Locale.getDefault(), DECIMAL_FORMATTER_GB, ((double) from) / INC_SIZE / INC_SIZE / INC_SIZE); break; } @@ -70,7 +73,6 @@ public class FileSizeConverter { return getSize(from, true); } - // Returns a file size in bytes in a nice readable formatted string /** * Returns a file size as nice readable string, e.g. 1234567890 (bytes) returns 1,15 or 1,15GB * @param from The file size in bytes @@ -81,13 +83,13 @@ public class FileSizeConverter { if (from < INC_SIZE) { return String.valueOf(from) + (withUnit ? SizeUnit.B.toString() : ""); } else if (from < (INC_SIZE * INC_SIZE)) { - return String.format(DECIMAL_FORMATTER, ((double) from) / INC_SIZE) + return String.format(Locale.getDefault(), DECIMAL_FORMATTER, ((double) from) / INC_SIZE) + (withUnit ? SizeUnit.KB.toString() : ""); } else if (from < (INC_SIZE * INC_SIZE * INC_SIZE)) { - return String.format(DECIMAL_FORMATTER, ((double) from) / INC_SIZE / INC_SIZE) + return String.format(Locale.getDefault(), DECIMAL_FORMATTER, ((double) from) / INC_SIZE / INC_SIZE) + (withUnit ? SizeUnit.MB.toString() : ""); } else { - return String.format(DECIMAL_FORMATTER, ((double) from) / INC_SIZE / INC_SIZE / INC_SIZE) + return String.format(Locale.getDefault(), DECIMAL_FORMATTER_GB, ((double) from) / INC_SIZE / INC_SIZE / INC_SIZE) + (withUnit ? SizeUnit.GB.toString() : ""); } } From c5fb7a9641640d1fcbb8541e207f695ad765921e Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Fri, 5 Oct 2018 22:59:34 +0200 Subject: [PATCH 07/11] Fix potential crash due to missing data in Deluge RPC adapter. Fixes #433. --- .../daemon/Deluge/DelugeRpcAdapter.java | 211 +++++------------- 1 file changed, 62 insertions(+), 149 deletions(-) diff --git a/app/src/main/java/org/transdroid/daemon/Deluge/DelugeRpcAdapter.java b/app/src/main/java/org/transdroid/daemon/Deluge/DelugeRpcAdapter.java index 3005ee3f..40386719 100644 --- a/app/src/main/java/org/transdroid/daemon/Deluge/DelugeRpcAdapter.java +++ b/app/src/main/java/org/transdroid/daemon/Deluge/DelugeRpcAdapter.java @@ -18,7 +18,6 @@ package org.transdroid.daemon.Deluge; import android.support.annotation.NonNull; - import org.base64.android.Base64; import org.transdroid.core.gui.log.Log; import org.transdroid.core.gui.remoterss.data.RemoteRssChannel; @@ -27,121 +26,22 @@ import org.transdroid.core.gui.remoterss.data.RemoteRssSupplier; import org.transdroid.core.rssparser.Channel; import org.transdroid.core.rssparser.Item; import org.transdroid.core.rssparser.RssParser; -import org.transdroid.daemon.Daemon; -import org.transdroid.daemon.DaemonException; +import org.transdroid.daemon.*; import org.transdroid.daemon.DaemonException.ExceptionType; -import org.transdroid.daemon.DaemonSettings; -import org.transdroid.daemon.IDaemonAdapter; -import org.transdroid.daemon.Label; -import org.transdroid.daemon.Priority; -import org.transdroid.daemon.Torrent; -import org.transdroid.daemon.TorrentDetails; -import org.transdroid.daemon.TorrentFile; -import org.transdroid.daemon.task.AddByFileTask; -import org.transdroid.daemon.task.AddByMagnetUrlTask; -import org.transdroid.daemon.task.AddByUrlTask; -import org.transdroid.daemon.task.DaemonTask; -import org.transdroid.daemon.task.DaemonTaskFailureResult; -import org.transdroid.daemon.task.DaemonTaskResult; -import org.transdroid.daemon.task.DaemonTaskSuccessResult; -import org.transdroid.daemon.task.ForceRecheckTask; -import org.transdroid.daemon.task.GetFileListTask; -import org.transdroid.daemon.task.GetFileListTaskSuccessResult; -import org.transdroid.daemon.task.GetTorrentDetailsTask; -import org.transdroid.daemon.task.GetTorrentDetailsTaskSuccessResult; -import org.transdroid.daemon.task.RemoveTask; -import org.transdroid.daemon.task.RetrieveTask; -import org.transdroid.daemon.task.RetrieveTaskSuccessResult; -import org.transdroid.daemon.task.SetDownloadLocationTask; -import org.transdroid.daemon.task.SetFilePriorityTask; -import org.transdroid.daemon.task.SetLabelTask; -import org.transdroid.daemon.task.SetTrackersTask; -import org.transdroid.daemon.task.SetTransferRatesTask; +import org.transdroid.daemon.task.*; import org.xml.sax.SAXException; -import java.io.BufferedInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; +import javax.xml.parsers.ParserConfigurationException; +import java.io.*; import java.net.URI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; -import java.util.Set; - -import javax.xml.parsers.ParserConfigurationException; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_DETAILS; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_DETAILS_FIELDS_ARRAY; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_DOWNLOADEDEVER; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_DOWNLOAD_LOCATION; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_ETA; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_FIELDS_ARRAY; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_FILEPRIORITIES; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_FILEPROGRESS; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_FILE_FIELDS_ARRAY; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_HASH; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_INDEX; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_KEY; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_LABEL; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_MAXDOWNLOAD; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_MAXUPLOAD; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_MESSAGE; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_ADD; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_ADD_FILE; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_ADD_MAGNET; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_FORCERECHECK; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_GET_LABELS; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_GET_METHOD_LIST; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_GET_RSS_CONFIG; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_GET_TORRENTS_STATUS; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_INFO; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_MOVESTORAGE; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_PAUSE; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_PAUSE_ALL; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_REMOVE; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_RESUME; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_RESUME_ALL; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_SETCONFIG; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_SETLABEL; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_SETTRACKERS; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_SET_TORRENT_OPTIONS; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_STATUS; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_MOVE_COMPLETED; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_MOVE_COMPLETED_PATH; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_NAME; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_NUMPEERS; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_NUMSEEDS; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_PARTDONE; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_PATH; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_RATEDOWNLOAD; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_RATEUPLOAD; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_RSSFEEDS; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_RSSFEED_KEY; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_SAVEPATH; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_SIZE; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_STATUS; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_SUBSCRIPTIONS; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_TIER; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_TIMEADDED; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_TOTALPEERS; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_TOTALSEEDS; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_TOTALSIZE; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_TRACKERS; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_TRACKER_STATUS; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_UPLOADEDEVER; -import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_URL; +import static org.transdroid.daemon.Deluge.DelugeCommon.*; /** * The daemon adapter from the Deluge torrent client using deluged API directly. + * * @author alon.albert */ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier { @@ -198,7 +98,7 @@ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier { return doForceRecheck(client, (ForceRecheckTask) task); default: return new DaemonTaskFailureResult(task, new DaemonException(ExceptionType.MethodUnsupported, task.getMethod() + " is not " + - "supported by " + getType())); + "supported by " + getType())); } } catch (DaemonException e) { return new DaemonTaskFailureResult(task, e); @@ -235,32 +135,39 @@ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier { final Map feedUrlMap = new HashMap<>(); final Map> feedItemMap = new HashMap<>(); - for (Map feed : rssFeeds.values()) { - final String feedUrl = (String) feed.get(RPC_URL); - final Object key = feed.get(RPC_KEY); - feedUrlMap.put(key, feedUrl); - final List items = getRssFeedItems(feedUrl, log); - feedItemMap.put(key, items); + if (rssFeeds != null) { + for (Map feed : rssFeeds.values()) { + final String feedUrl = (String) feed.get(RPC_URL); + final Object key = feed.get(RPC_KEY); + feedUrlMap.put(key, feedUrl); + final List items = getRssFeedItems(feedUrl, log); + feedItemMap.put(key, items); + } } //noinspection unchecked final Map> subscriptions = (Map>) rssConfig.get(RPC_SUBSCRIPTIONS); final ArrayList channels = new ArrayList<>(); - for (Map subscription : subscriptions.values()) { - final Integer key = Integer.valueOf(subscription.get(RPC_KEY).toString()); - final String name = (String) subscription.get(RPC_NAME); - final String label = (String) subscription.get(RPC_LABEL); - final String downloadLocation = (String) subscription.get(RPC_DOWNLOAD_LOCATION); - final String moveCompleted = (String) subscription.get(RPC_MOVE_COMPLETED); - final Object feedKey = subscription.get(RPC_RSSFEED_KEY); - final String feedUrl = feedUrlMap.get(feedKey); - - final List items = new ArrayList<>(); - for (Item item : feedItemMap.get(feedKey)) { - items.add(new DelugeRemoteRssItem(item.getTitle(), item.getLink(), name, item.getPubdate())); + if (subscriptions != null) { + for (Map subscription : subscriptions.values()) { + final Integer key = Integer.valueOf(subscription.get(RPC_KEY).toString()); + final String name = (String) subscription.get(RPC_NAME); + final String label = (String) subscription.get(RPC_LABEL); + final String downloadLocation = (String) subscription.get(RPC_DOWNLOAD_LOCATION); + final String moveCompleted = (String) subscription.get(RPC_MOVE_COMPLETED); + final Object feedKey = subscription.get(RPC_RSSFEED_KEY); + final String feedUrl = feedUrlMap.get(feedKey); + + final List items = new ArrayList<>(); + final List feedItems = feedItemMap.get(feedKey); + if (feedItems != null) { + for (Item item : feedItems) { + items.add(new DelugeRemoteRssItem(item.getTitle(), item.getLink(), name, item.getPubdate())); + } + } + + channels.add(new DelugeRemoteRssChannel(key, name, feedUrl, now, label, downloadLocation, moveCompleted, items)); } - - channels.add(new DelugeRemoteRssChannel(key, name, feedUrl, now, label, downloadLocation, moveCompleted, items)); } return channels; } finally { @@ -309,7 +216,7 @@ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier { // Get torrents //noinspection unchecked final Map> torrentsStatus = (Map>) client.sendRequest - (RPC_METHOD_GET_TORRENTS_STATUS, new HashMap<>(), RPC_FIELDS_ARRAY); + (RPC_METHOD_GET_TORRENTS_STATUS, new HashMap<>(), RPC_FIELDS_ARRAY); final List torrents = getTorrents(torrentsStatus.values()); // Check if Label plugin is enabled @@ -328,17 +235,19 @@ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier { private GetTorrentDetailsTaskSuccessResult doGetTorrentDetails(DelugeRpcClient client, GetTorrentDetailsTask task) throws DaemonException { //noinspection unchecked final Map response = (Map) client.sendRequest(RPC_METHOD_STATUS, task.getTargetTorrent().getUniqueID(), - RPC_DETAILS_FIELDS_ARRAY); + RPC_DETAILS_FIELDS_ARRAY); //noinspection unchecked final List> trackerResponses = (List>) response.get(RPC_TRACKERS); final List trackers = new ArrayList<>(); - for (Map trackerResponse : trackerResponses) { - trackers.add((String) trackerResponse.get(RPC_URL)); + if (trackerResponses != null) { + for (Map trackerResponse : trackerResponses) { + trackers.add((String) trackerResponse.get(RPC_URL)); + } } return new GetTorrentDetailsTaskSuccessResult(task, new TorrentDetails(trackers, Collections.singletonList((String) response.get - (RPC_TRACKER_STATUS)))); + (RPC_TRACKER_STATUS)))); } private GetFileListTaskSuccessResult doGetFileList(DelugeRpcClient client, GetFileListTask task) throws DaemonException { @@ -479,12 +388,12 @@ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier { } torrents.add(new Torrent(id++, (String) torrentMap.get(RPC_HASH), (String) torrentMap.get(RPC_NAME), DelugeCommon.convertDelugeState( - (String) torrentMap.get(RPC_STATUS)), torrentMap.get(RPC_SAVEPATH) + settings.getOS().getPathSeperator(), ((Number) torrentMap - .get(RPC_RATEDOWNLOAD)).intValue(), ((Number) torrentMap.get(RPC_RATEUPLOAD)).intValue(), ((Number) torrentMap.get - (RPC_NUMSEEDS)).intValue(), ((Number) torrentMap.get(RPC_TOTALSEEDS)).intValue(), ((Number) torrentMap.get(RPC_NUMPEERS)) - .intValue(), ((Number) torrentMap.get(RPC_TOTALPEERS)).intValue(), ((Number) torrentMap.get(RPC_ETA)).intValue(), ((Number) - torrentMap.get(RPC_DOWNLOADEDEVER)).longValue(), ((Number) torrentMap.get(RPC_UPLOADEDEVER)).longValue(), ((Number) torrentMap - .get(RPC_TOTALSIZE)).longValue(), ((Number) torrentMap.get(RPC_PARTDONE)).floatValue() / 100f, 0f, // Not available + (String) torrentMap.get(RPC_STATUS)), torrentMap.get(RPC_SAVEPATH) + settings.getOS().getPathSeperator(), ((Number) torrentMap + .get(RPC_RATEDOWNLOAD)).intValue(), ((Number) torrentMap.get(RPC_RATEUPLOAD)).intValue(), ((Number) torrentMap.get + (RPC_NUMSEEDS)).intValue(), ((Number) torrentMap.get(RPC_TOTALSEEDS)).intValue(), ((Number) torrentMap.get(RPC_NUMPEERS)) + .intValue(), ((Number) torrentMap.get(RPC_TOTALPEERS)).intValue(), ((Number) torrentMap.get(RPC_ETA)).intValue(), ((Number) + torrentMap.get(RPC_DOWNLOADEDEVER)).longValue(), ((Number) torrentMap.get(RPC_UPLOADEDEVER)).longValue(), ((Number) torrentMap + .get(RPC_TOTALSIZE)).longValue(), ((Number) torrentMap.get(RPC_PARTDONE)).floatValue() / 100f, 0f, // Not available (String) torrentMap.get(RPC_LABEL), timeAddedDate, null, // Not available error, getType())); } @@ -525,7 +434,7 @@ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier { final ArrayList files = new ArrayList<>(); //noinspection unchecked final Map response = (Map) client.sendRequest(RPC_METHOD_STATUS, torrent.getUniqueID(), - RPC_FILE_FIELDS_ARRAY); + RPC_FILE_FIELDS_ARRAY); //noinspection unchecked final List> fileMaps = (List>) response.get(RPC_DETAILS); @@ -534,15 +443,17 @@ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier { //noinspection unchecked final List progresses = (List) response.get(RPC_FILEPROGRESS); - for (int i = 0, n = fileMaps.size(); i < n; i++) { - final Map fileMap = fileMaps.get(i); - final int priority = priorities.get(i); - final float progress = progresses.get(i); + if (fileMaps != null) { + for (int i = 0, n = fileMaps.size(); i < n; i++) { + final Map fileMap = fileMaps.get(i); + final int priority = priorities.get(i); + final float progress = progresses.get(i); - final String path = (String) fileMap.get(RPC_PATH); - final long size = ((Number) fileMap.get(RPC_SIZE)).longValue(); - files.add(new TorrentFile(fileMap.get(RPC_INDEX).toString(), path, path, torrent.getLocationDir() + path, size, (long) (size * progress) - , convertDelugePriority(client, priority))); + final String path = (String) fileMap.get(RPC_PATH); + final long size = ((Number) fileMap.get(RPC_SIZE)).longValue(); + files.add(new TorrentFile(fileMap.get(RPC_INDEX).toString(), path, path, torrent.getLocationDir() + path, size, + (long) (size * progress), convertDelugePriority(client, priority))); + } } return files; } @@ -630,7 +541,7 @@ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier { */ private static class MutableInt { - int value = 1; + int value; MutableInt(int value) { this.value = value; @@ -643,5 +554,7 @@ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier { int get() { return value; } + } + } From 1ccb6def323f33cb0fe25b02851584e41637d3fc Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Fri, 5 Oct 2018 23:36:46 +0200 Subject: [PATCH 08/11] Releasing new version 2.5.12. --- app/build.gradle | 4 ++-- latest-app.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 796e06cb..f4fd18c5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { defaultConfig { minSdkVersion 15 targetSdkVersion 28 - versionCode 231 - versionName '2.5.11' + versionCode 232 + versionName '2.5.12' javaCompileOptions { annotationProcessorOptions { diff --git a/latest-app.html b/latest-app.html index 1e0815d5..9b7d5b3f 100644 --- a/latest-app.html +++ b/latest-app.html @@ -1 +1 @@ -231|2.5.11 +232|2.5.12 From 99874e38b767256f3931a5adeb1be27845868385 Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Mon, 8 Oct 2018 23:50:08 +0200 Subject: [PATCH 09/11] Updated reference to latest search module versions. --- latest-search.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/latest-search.html b/latest-search.html index 445388bf..ddd05535 100644 --- a/latest-search.html +++ b/latest-search.html @@ -1 +1 @@ -33|3.10 +34|3.11 From 3eb079a6c345acdfde2f41783f001328ede53264 Mon Sep 17 00:00:00 2001 From: Dan Pasanen Date: Mon, 22 Oct 2018 11:06:43 -0500 Subject: [PATCH 10/11] app: use relative path to manifest --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index f4fd18c5..18bc246b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -15,7 +15,7 @@ android { annotationProcessorOptions { arguments = [ "resourcePackageName": "org.transdroid", - "androidManifestFile": "/Users/erickok/Android/2312/transdroid/app/src/main/AndroidManifest.xml" + "androidManifestFile": "app/src/main/AndroidManifest.xml" ] } } From 7ed5562fb44cf5ad0140b0555c4e5ec23315f331 Mon Sep 17 00:00:00 2001 From: Dan Pasanen Date: Mon, 22 Oct 2018 11:24:38 -0500 Subject: [PATCH 11/11] app: read signing info from a keystore.properties file * This file is gitignore'd. An example is provided which must be copied and modified for a user to successfully build. --- .gitignore | 1 + app/build.gradle | 15 +++++++++++---- keystore.properties.example | 4 ++++ 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 keystore.properties.example diff --git a/.gitignore b/.gitignore index 462b229e..dd9d33af 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ build/ # local configuration file (sdk path, etc) +keystore.properties local.properties signing.gradle diff --git a/app/build.gradle b/app/build.gradle index 18bc246b..25330327 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -22,10 +22,17 @@ android { } signingConfigs { releaseConfig { - keyAlias 'transdroid' - keyPassword '' - storeFile file('../../erickok.keystore') - storePassword '' + def propsFile = rootProject.file('keystore.properties') + def configName = 'releaseConfig' + + if (propsFile.exists() && android.signingConfigs.hasProperty(configName)) { + def props = new Properties() + props.load(new FileInputStream(propsFile)) + keyAlias = props['keyAlias'] + storeFile = file(props['storeFile']) + keyPassword = props['keyPassword'] + storePassword = props['storePassword'] + } } } buildTypes { diff --git a/keystore.properties.example b/keystore.properties.example new file mode 100644 index 00000000..62ee6c80 --- /dev/null +++ b/keystore.properties.example @@ -0,0 +1,4 @@ +keyAlias=transdroid +keyPassword=123456 +storeFile=/home/user/transdroid.keystore +storePassword=123456