Browse Source

Merge branch 'invisiblek-pathfix' into dev

pull/471/head
Eric Kok 6 years ago
parent
commit
96bf3f3dc0
  1. 1
      .gitignore
  2. 19
      app/build.gradle
  3. 3
      app/src/main/AndroidManifest.xml
  4. 36
      app/src/main/java/org/transdroid/daemon/Daemon.java
  5. 5
      app/src/main/java/org/transdroid/daemon/DaemonException.java
  6. 2
      app/src/main/java/org/transdroid/daemon/DaemonMethod.java
  7. 5
      app/src/main/java/org/transdroid/daemon/Deluge/DelugeAdapter.java
  8. 135
      app/src/main/java/org/transdroid/daemon/Deluge/DelugeRpcAdapter.java
  9. 37
      app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java
  10. 16
      app/src/main/java/org/transdroid/daemon/util/FileSizeConverter.java
  11. 4
      keystore.properties.example
  12. 2
      latest-app.html
  13. 2
      latest-search.html

1
.gitignore vendored

@ -3,6 +3,7 @@
build/ build/
# local configuration file (sdk path, etc) # local configuration file (sdk path, etc)
keystore.properties
local.properties local.properties
signing.gradle signing.gradle

19
app/build.gradle

@ -8,8 +8,8 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 15 minSdkVersion 15
targetSdkVersion 28 targetSdkVersion 28
versionCode 231 versionCode 232
versionName '2.5.11' versionName '2.5.12'
javaCompileOptions { javaCompileOptions {
annotationProcessorOptions { annotationProcessorOptions {
@ -22,10 +22,17 @@ android {
} }
signingConfigs { signingConfigs {
releaseConfig { releaseConfig {
keyAlias 'transdroid' def propsFile = rootProject.file('keystore.properties')
keyPassword '' def configName = 'releaseConfig'
storeFile file('../../erickok.keystore')
storePassword '' 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 { buildTypes {

3
app/src/main/AndroidManifest.xml

@ -50,7 +50,8 @@
android:icon="@drawable/ic_launcher" android:icon="@drawable/ic_launcher"
android:banner="@drawable/banner" android:banner="@drawable/banner"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/Theme.AppCompat" > android:theme="@style/Theme.AppCompat"
android:usesCleartextTraffic="true">
<uses-library <uses-library
android:name="org.apache.http.legacy" android:name="org.apache.http.legacy"

36
app/src/main/java/org/transdroid/daemon/Daemon.java

@ -302,12 +302,14 @@ public enum Daemon {
} }
public static boolean supportsAvailability(Daemon type) { 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) { public static boolean supportsFileListing(Daemon type) {
return type == Synology || type == Transmission || type == uTorrent || type == BitTorrent || type == KTorrent || type == Deluge || type == DelugeRpc return type == Synology || type == Transmission || type == uTorrent || type == BitTorrent || type == KTorrent || type == Deluge
|| type == rTorrent || type == Vuze || type == DLinkRouterBT || type == Bitflu || type == qBittorrent || type == BuffaloNas || type == BitComet || type == Aria2 || type == tTorrent || type == Dummy; || 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) { public static boolean supportsFineDetails(Daemon type) {
@ -339,7 +341,8 @@ public enum Daemon {
public static boolean supportsSetTransferRates(Daemon type) { public static boolean supportsSetTransferRates(Daemon type) {
return type == Deluge || type == DelugeRpc 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) { public static boolean supportsAddByFile(Daemon type) {
@ -349,26 +352,31 @@ public enum Daemon {
public static boolean supportsAddByMagnetUrl(Daemon type) { public static boolean supportsAddByMagnetUrl(Daemon type) {
return type == uTorrent || type == BitTorrent || type == Transmission || type == Synology || type == Deluge || type == DelugeRpc 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) { public static boolean supportsRemoveWithData(Daemon type) {
return type == uTorrent || type == Vuze || type == Transmission || type == Deluge || type == DelugeRpc 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) { 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; || type == qBittorrent || type == tTorrent || type == Dummy;
} }
public static boolean supportsDateAdded(Daemon type) { 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; || type == qBittorrent || type == Dummy;
} }
public static boolean supportsLabels(Daemon type) { 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) { public static boolean supportsSetLabel(Daemon type) {
@ -377,7 +385,7 @@ public enum Daemon {
} }
public static boolean supportsSetDownloadLocation(Daemon type) { 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) { public static boolean supportsSetAlternativeMode(Daemon type) {
@ -389,18 +397,16 @@ public enum Daemon {
} }
public static boolean supportsForceRecheck(Daemon type) { 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) { public static boolean supportsExtraPassword(Daemon type) {
return type == Deluge || type == Aria2; return type == Deluge || type == Aria2;
} }
public static boolean supportsUsernameForHttp(Daemon type) {
return type == Deluge || type == Aria2;
}
public static boolean supportsRemoteRssManagement(Daemon type) { public static boolean supportsRemoteRssManagement(Daemon type) {
return type == uTorrent || type == DelugeRpc; return type == uTorrent || type == DelugeRpc;
} }
} }

5
app/src/main/java/org/transdroid/daemon/DaemonException.java

@ -18,6 +18,8 @@
package org.transdroid.daemon; package org.transdroid.daemon;
import android.support.annotation.NonNull;
/** /**
* An exception thrown when an error occurs inside a server daemon adapter. * 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 * The error message is from a resource string ID, since this can be
@ -40,7 +42,7 @@ public class DaemonException extends Exception {
ParsingFailed, ParsingFailed,
AuthenticationFailure, AuthenticationFailure,
NotConnected, NotConnected,
FileAccessError; FileAccessError
} }
public DaemonException(ExceptionType internalException, String message) { public DaemonException(ExceptionType internalException, String message) {
@ -52,6 +54,7 @@ public class DaemonException extends Exception {
return internalException; return internalException;
} }
@NonNull
@Override @Override
public String toString() { public String toString() {
return internalException.toString() + " exception: " + getMessage(); return internalException.toString() + " exception: " + getMessage();

2
app/src/main/java/org/transdroid/daemon/DaemonMethod.java

@ -47,7 +47,7 @@ public enum DaemonMethod {
ForceRecheck (22); ForceRecheck (22);
private int code; private int code;
private static final Map<Integer,DaemonMethod> lookup = new HashMap<Integer,DaemonMethod>(); private static final Map<Integer,DaemonMethod> lookup = new HashMap<>();
static { static {
for(DaemonMethod s : EnumSet.allOf(DaemonMethod.class)) for(DaemonMethod s : EnumSet.allOf(DaemonMethod.class))

5
app/src/main/java/org/transdroid/daemon/Deluge/DelugeAdapter.java

@ -92,7 +92,6 @@ 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_MESSAGE;
import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD; import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD;
import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_ADD; 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_ADD_MAGNET;
import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_AUTH_LOGIN; import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_AUTH_LOGIN;
import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_FORCERECHECK; import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_FORCERECHECK;
@ -145,7 +144,7 @@ public class DelugeAdapter implements IDaemonAdapter {
private static final String PATH_TO_UPLOAD = "/upload"; private static final String PATH_TO_UPLOAD = "/upload";
private static final String RPC_ID = "id"; private static final String RPC_ID = "id";
private final String RPC_METHOD_ADD_FILE = "web.add_torrents"; private static final String RPC_METHOD_ADD_FILE = "web.add_torrents";
private DaemonSettings settings; private DaemonSettings settings;
private DefaultHttpClient httpclient; private DefaultHttpClient httpclient;
@ -156,7 +155,7 @@ public class DelugeAdapter implements IDaemonAdapter {
this.settings = settings; this.settings = settings;
} }
public JSONArray addTorrentByFile(String file, Log log) throws JSONException, IOException, DaemonException { private JSONArray addTorrentByFile(String file, Log log) throws JSONException, IOException, DaemonException {
String url = buildWebUIUrl() + PATH_TO_UPLOAD; String url = buildWebUIUrl() + PATH_TO_UPLOAD;

135
app/src/main/java/org/transdroid/daemon/Deluge/DelugeRpcAdapter.java

@ -18,7 +18,6 @@
package org.transdroid.daemon.Deluge; package org.transdroid.daemon.Deluge;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import org.base64.android.Base64; import org.base64.android.Base64;
import org.transdroid.core.gui.log.Log; import org.transdroid.core.gui.log.Log;
import org.transdroid.core.gui.remoterss.data.RemoteRssChannel; 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.Channel;
import org.transdroid.core.rssparser.Item; import org.transdroid.core.rssparser.Item;
import org.transdroid.core.rssparser.RssParser; import org.transdroid.core.rssparser.RssParser;
import org.transdroid.daemon.Daemon; import org.transdroid.daemon.*;
import org.transdroid.daemon.DaemonException;
import org.transdroid.daemon.DaemonException.ExceptionType; import org.transdroid.daemon.DaemonException.ExceptionType;
import org.transdroid.daemon.DaemonSettings; import org.transdroid.daemon.task.*;
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.xml.sax.SAXException; import org.xml.sax.SAXException;
import java.io.BufferedInputStream; import javax.xml.parsers.ParserConfigurationException;
import java.io.ByteArrayOutputStream; import java.io.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.util.ArrayList; import java.util.*;
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.Map.Entry; 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.*;
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;
/** /**
* The daemon adapter from the Deluge torrent client using deluged API directly. * The daemon adapter from the Deluge torrent client using deluged API directly.
*
* @author alon.albert * @author alon.albert
*/ */
public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier { public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier {
@ -235,6 +135,7 @@ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier {
final Map<Object, String> feedUrlMap = new HashMap<>(); final Map<Object, String> feedUrlMap = new HashMap<>();
final Map<Object, List<Item>> feedItemMap = new HashMap<>(); final Map<Object, List<Item>> feedItemMap = new HashMap<>();
if (rssFeeds != null) {
for (Map<String, Object> feed : rssFeeds.values()) { for (Map<String, Object> feed : rssFeeds.values()) {
final String feedUrl = (String) feed.get(RPC_URL); final String feedUrl = (String) feed.get(RPC_URL);
final Object key = feed.get(RPC_KEY); final Object key = feed.get(RPC_KEY);
@ -242,10 +143,12 @@ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier {
final List<Item> items = getRssFeedItems(feedUrl, log); final List<Item> items = getRssFeedItems(feedUrl, log);
feedItemMap.put(key, items); feedItemMap.put(key, items);
} }
}
//noinspection unchecked //noinspection unchecked
final Map<String, Map<String, Object>> subscriptions = (Map<String, Map<String, Object>>) rssConfig.get(RPC_SUBSCRIPTIONS); final Map<String, Map<String, Object>> subscriptions = (Map<String, Map<String, Object>>) rssConfig.get(RPC_SUBSCRIPTIONS);
final ArrayList<RemoteRssChannel> channels = new ArrayList<>(); final ArrayList<RemoteRssChannel> channels = new ArrayList<>();
if (subscriptions != null) {
for (Map<String, Object> subscription : subscriptions.values()) { for (Map<String, Object> subscription : subscriptions.values()) {
final Integer key = Integer.valueOf(subscription.get(RPC_KEY).toString()); final Integer key = Integer.valueOf(subscription.get(RPC_KEY).toString());
final String name = (String) subscription.get(RPC_NAME); final String name = (String) subscription.get(RPC_NAME);
@ -256,12 +159,16 @@ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier {
final String feedUrl = feedUrlMap.get(feedKey); final String feedUrl = feedUrlMap.get(feedKey);
final List<RemoteRssItem> items = new ArrayList<>(); final List<RemoteRssItem> items = new ArrayList<>();
for (Item item : feedItemMap.get(feedKey)) { final List<Item> feedItems = feedItemMap.get(feedKey);
if (feedItems != null) {
for (Item item : feedItems) {
items.add(new DelugeRemoteRssItem(item.getTitle(), item.getLink(), name, item.getPubdate())); 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; return channels;
} finally { } finally {
client.close(); client.close();
@ -333,9 +240,11 @@ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier {
//noinspection unchecked //noinspection unchecked
final List<Map<String, Object>> trackerResponses = (List<Map<String, Object>>) response.get(RPC_TRACKERS); final List<Map<String, Object>> trackerResponses = (List<Map<String, Object>>) response.get(RPC_TRACKERS);
final List<String> trackers = new ArrayList<>(); final List<String> trackers = new ArrayList<>();
if (trackerResponses != null) {
for (Map<String, Object> trackerResponse : trackerResponses) { for (Map<String, Object> trackerResponse : trackerResponses) {
trackers.add((String) trackerResponse.get(RPC_URL)); trackers.add((String) trackerResponse.get(RPC_URL));
} }
}
return new GetTorrentDetailsTaskSuccessResult(task, new TorrentDetails(trackers, Collections.singletonList((String) response.get return new GetTorrentDetailsTaskSuccessResult(task, new TorrentDetails(trackers, Collections.singletonList((String) response.get
(RPC_TRACKER_STATUS)))); (RPC_TRACKER_STATUS))));
@ -534,6 +443,7 @@ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier {
//noinspection unchecked //noinspection unchecked
final List<Float> progresses = (List<Float>) response.get(RPC_FILEPROGRESS); final List<Float> progresses = (List<Float>) response.get(RPC_FILEPROGRESS);
if (fileMaps != null) {
for (int i = 0, n = fileMaps.size(); i < n; i++) { for (int i = 0, n = fileMaps.size(); i < n; i++) {
final Map<String, Object> fileMap = fileMaps.get(i); final Map<String, Object> fileMap = fileMaps.get(i);
final int priority = priorities.get(i); final int priority = priorities.get(i);
@ -541,8 +451,9 @@ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier {
final String path = (String) fileMap.get(RPC_PATH); final String path = (String) fileMap.get(RPC_PATH);
final long size = ((Number) fileMap.get(RPC_SIZE)).longValue(); 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) files.add(new TorrentFile(fileMap.get(RPC_INDEX).toString(), path, path, torrent.getLocationDir() + path, size,
, convertDelugePriority(client, priority))); (long) (size * progress), convertDelugePriority(client, priority)));
}
} }
return files; return files;
} }
@ -630,7 +541,7 @@ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier {
*/ */
private static class MutableInt { private static class MutableInt {
int value = 1; int value;
MutableInt(int value) { MutableInt(int value) {
this.value = value; this.value = value;
@ -643,5 +554,7 @@ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier {
int get() { int get() {
return value; return value;
} }
} }
} }

37
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.TorrentDetails;
import org.transdroid.daemon.TorrentFile; import org.transdroid.daemon.TorrentFile;
import org.transdroid.daemon.TorrentStatus; import org.transdroid.daemon.TorrentStatus;
import org.transdroid.daemon.task.AddByFileTask; import org.transdroid.daemon.task.*;
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.util.HttpHelper; import org.transdroid.daemon.util.HttpHelper;
import java.io.File; import java.io.File;
@ -318,6 +300,14 @@ public class QbittorrentAdapter implements IDaemonAdapter {
new BasicNameValuePair("category", labelTask.getNewLabel())); new BasicNameValuePair("category", labelTask.getNewLabel()));
return new DaemonTaskSuccessResult(task); 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: case SetTransferRates:
// Request to set the maximum transfer rates // Request to set the maximum transfer rates
@ -499,6 +489,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
int seeders[]; int seeders[];
double ratio; double ratio;
long size; long size;
long uploaded;
int dlspeed; int dlspeed;
int upspeed; int upspeed;
Date addedOn = null; Date addedOn = null;
@ -516,6 +507,11 @@ public class QbittorrentAdapter implements IDaemonAdapter {
ratio = tor.getDouble("ratio"); ratio = tor.getDouble("ratio");
dlspeed = tor.getInt("dlspeed"); dlspeed = tor.getInt("dlspeed");
upspeed = tor.getInt("upspeed"); upspeed = tor.getInt("upspeed");
if (tor.has("uploaded")) {
uploaded = tor.getLong("uploaded");
} else {
uploaded = (long) (size * ratio);
}
final long addedOnTime = tor.optLong("added_on"); final long addedOnTime = tor.optLong("added_on");
addedOn = (addedOnTime > 0) ? new Date(addedOnTime * 1000L) : null; addedOn = (addedOnTime > 0) ? new Date(addedOnTime * 1000L) : null;
final long completionOnTime = tor.optLong("completion_on"); final long completionOnTime = tor.optLong("completion_on");
@ -529,6 +525,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
seeders = parsePeers(tor.getString("num_seeds")); seeders = parsePeers(tor.getString("num_seeds"));
size = parseSize(tor.getString("size")); size = parseSize(tor.getString("size"));
ratio = parseRatio(tor.getString("ratio")); ratio = parseRatio(tor.getString("ratio"));
uploaded = (long) (size * ratio);
dlspeed = parseSpeed(tor.getString("dlspeed")); dlspeed = parseSpeed(tor.getString("dlspeed"));
upspeed = parseSpeed(tor.getString("upspeed")); upspeed = parseSpeed(tor.getString("upspeed"));
} }
@ -552,7 +549,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
leechers[1], leechers[1],
(int) eta, (int) eta,
(long) (size * progress), (long) (size * progress),
(long) (size * ratio), uploaded,
size, size,
(float) progress, (float) progress,
0f, 0f,

16
app/src/main/java/org/transdroid/daemon/util/FileSizeConverter.java

@ -17,6 +17,8 @@
*/ */
package org.transdroid.daemon.util; package org.transdroid.daemon.util;
import java.util.Locale;
/** /**
* Quick and dirty file size formatter. * Quick and dirty file size formatter.
* @author erickok * @author erickok
@ -24,6 +26,7 @@ package org.transdroid.daemon.util;
public class FileSizeConverter { public class FileSizeConverter {
private static final String DECIMAL_FORMATTER = "%.1f"; private static final String DECIMAL_FORMATTER = "%.1f";
private static final String DECIMAL_FORMATTER_GB = "%.2f";
/** /**
* A quantity in which to express a file size. * A quantity in which to express a file size.
@ -48,13 +51,13 @@ public class FileSizeConverter {
out = String.valueOf(from); out = String.valueOf(from);
break; break;
case KB: case KB:
out = String.format(DECIMAL_FORMATTER, ((double) from) / INC_SIZE); out = String.format(Locale.getDefault(), DECIMAL_FORMATTER, ((double) from) / INC_SIZE);
break; break;
case MB: 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; break;
default: 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; break;
} }
@ -70,7 +73,6 @@ public class FileSizeConverter {
return getSize(from, true); 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 * 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 * @param from The file size in bytes
@ -81,13 +83,13 @@ public class FileSizeConverter {
if (from < INC_SIZE) { if (from < INC_SIZE) {
return String.valueOf(from) + (withUnit ? SizeUnit.B.toString() : ""); return String.valueOf(from) + (withUnit ? SizeUnit.B.toString() : "");
} else if (from < (INC_SIZE * INC_SIZE)) { } 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() : ""); + (withUnit ? SizeUnit.KB.toString() : "");
} else if (from < (INC_SIZE * INC_SIZE * INC_SIZE)) { } 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() : ""); + (withUnit ? SizeUnit.MB.toString() : "");
} else { } 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() : ""); + (withUnit ? SizeUnit.GB.toString() : "");
} }
} }

4
keystore.properties.example

@ -0,0 +1,4 @@
keyAlias=transdroid
keyPassword=123456
storeFile=/home/user/transdroid.keystore
storePassword=123456

2
latest-app.html

@ -1 +1 @@
230|2.5.10 232|2.5.12

2
latest-search.html

@ -1 +1 @@
33|3.10 34|3.11

Loading…
Cancel
Save