Browse Source

Merge branch 'pathfix' of https://github.com/invisiblek/transdroid into invisiblek-pathfix

pull/471/head
Eric Kok 6 years ago
parent
commit
2f8ce10739
  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. 211
      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 @@ @@ -3,6 +3,7 @@
build/
# local configuration file (sdk path, etc)
keystore.properties
local.properties
signing.gradle

19
app/build.gradle

@ -8,8 +8,8 @@ android { @@ -8,8 +8,8 @@ android {
defaultConfig {
minSdkVersion 15
targetSdkVersion 28
versionCode 231
versionName '2.5.11'
versionCode 232
versionName '2.5.12'
javaCompileOptions {
annotationProcessorOptions {
@ -22,10 +22,17 @@ android { @@ -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 {

3
app/src/main/AndroidManifest.xml

@ -50,7 +50,8 @@ @@ -50,7 +50,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">
<uses-library
android:name="org.apache.http.legacy"

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

@ -302,12 +302,14 @@ public enum Daemon { @@ -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 { @@ -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 { @@ -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) {
@ -377,7 +385,7 @@ public enum Daemon { @@ -377,7 +385,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) {
@ -389,18 +397,16 @@ public enum Daemon { @@ -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;
}
}

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

@ -18,6 +18,8 @@ @@ -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 { @@ -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 { @@ -52,6 +54,7 @@ public class DaemonException extends Exception {
return internalException;
}
@NonNull
@Override
public String toString() {
return internalException.toString() + " exception: " + getMessage();

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

@ -47,7 +47,7 @@ public enum DaemonMethod { @@ -47,7 +47,7 @@ public enum DaemonMethod {
ForceRecheck (22);
private int code;
private static final Map<Integer,DaemonMethod> lookup = new HashMap<Integer,DaemonMethod>();
private static final Map<Integer,DaemonMethod> lookup = new HashMap<>();
static {
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; @@ -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_METHOD;
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_AUTH_LOGIN;
import static org.transdroid.daemon.Deluge.DelugeCommon.RPC_METHOD_FORCERECHECK;
@ -145,7 +144,7 @@ public class DelugeAdapter implements IDaemonAdapter { @@ -145,7 +144,7 @@ public class DelugeAdapter implements IDaemonAdapter {
private static final String PATH_TO_UPLOAD = "/upload";
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 DefaultHttpClient httpclient;
@ -156,7 +155,7 @@ public class DelugeAdapter implements IDaemonAdapter { @@ -156,7 +155,7 @@ public class DelugeAdapter implements IDaemonAdapter {
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;

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

@ -18,7 +18,6 @@ @@ -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; @@ -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 { @@ -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 { @@ -235,32 +135,39 @@ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier {
final Map<Object, String> feedUrlMap = new HashMap<>();
final Map<Object, List<Item>> feedItemMap = new HashMap<>();
for (Map<String, Object> feed : rssFeeds.values()) {
final String feedUrl = (String) feed.get(RPC_URL);
final Object key = feed.get(RPC_KEY);
feedUrlMap.put(key, feedUrl);
final List<Item> items = getRssFeedItems(feedUrl, log);
feedItemMap.put(key, items);
if (rssFeeds != null) {
for (Map<String, Object> feed : rssFeeds.values()) {
final String feedUrl = (String) feed.get(RPC_URL);
final Object key = feed.get(RPC_KEY);
feedUrlMap.put(key, feedUrl);
final List<Item> items = getRssFeedItems(feedUrl, log);
feedItemMap.put(key, items);
}
}
//noinspection unchecked
final Map<String, Map<String, Object>> subscriptions = (Map<String, Map<String, Object>>) rssConfig.get(RPC_SUBSCRIPTIONS);
final ArrayList<RemoteRssChannel> channels = new ArrayList<>();
for (Map<String, Object> 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<RemoteRssItem> 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<String, Object> 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<RemoteRssItem> items = new ArrayList<>();
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()));
}
}
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 { @@ -309,7 +216,7 @@ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier {
// Get torrents
//noinspection unchecked
final Map<String, Map<String, Object>> torrentsStatus = (Map<String, Map<String, Object>>) client.sendRequest
(RPC_METHOD_GET_TORRENTS_STATUS, new HashMap<>(), RPC_FIELDS_ARRAY);
(RPC_METHOD_GET_TORRENTS_STATUS, new HashMap<>(), RPC_FIELDS_ARRAY);
final List<Torrent> torrents = getTorrents(torrentsStatus.values());
// Check if Label plugin is enabled
@ -328,17 +235,19 @@ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier { @@ -328,17 +235,19 @@ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier {
private GetTorrentDetailsTaskSuccessResult doGetTorrentDetails(DelugeRpcClient client, GetTorrentDetailsTask task) throws DaemonException {
//noinspection unchecked
final Map<String, Object> response = (Map<String, Object>) client.sendRequest(RPC_METHOD_STATUS, task.getTargetTorrent().getUniqueID(),
RPC_DETAILS_FIELDS_ARRAY);
RPC_DETAILS_FIELDS_ARRAY);
//noinspection unchecked
final List<Map<String, Object>> trackerResponses = (List<Map<String, Object>>) response.get(RPC_TRACKERS);
final List<String> trackers = new ArrayList<>();
for (Map<String, Object> trackerResponse : trackerResponses) {
trackers.add((String) trackerResponse.get(RPC_URL));
if (trackerResponses != null) {
for (Map<String, Object> 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 { @@ -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 { @@ -525,7 +434,7 @@ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier {
final ArrayList<TorrentFile> files = new ArrayList<>();
//noinspection unchecked
final Map<String, Object> response = (Map<String, Object>) client.sendRequest(RPC_METHOD_STATUS, torrent.getUniqueID(),
RPC_FILE_FIELDS_ARRAY);
RPC_FILE_FIELDS_ARRAY);
//noinspection unchecked
final List<Map<String, Object>> fileMaps = (List<Map<String, Object>>) response.get(RPC_DETAILS);
@ -534,15 +443,17 @@ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier { @@ -534,15 +443,17 @@ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier {
//noinspection unchecked
final List<Float> progresses = (List<Float>) response.get(RPC_FILEPROGRESS);
for (int i = 0, n = fileMaps.size(); i < n; i++) {
final Map<String, Object> 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<String, Object> 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 { @@ -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 { @@ -643,5 +554,7 @@ public class DelugeRpcAdapter implements IDaemonAdapter, RemoteRssSupplier {
int get() {
return value;
}
}
}

37
app/src/main/java/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java

@ -45,25 +45,7 @@ import org.transdroid.daemon.Torrent; @@ -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 { @@ -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
@ -499,6 +489,7 @@ public class QbittorrentAdapter implements IDaemonAdapter { @@ -499,6 +489,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
int seeders[];
double ratio;
long size;
long uploaded;
int dlspeed;
int upspeed;
Date addedOn = null;
@ -516,6 +507,11 @@ public class QbittorrentAdapter implements IDaemonAdapter { @@ -516,6 +507,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 +525,7 @@ public class QbittorrentAdapter implements IDaemonAdapter { @@ -529,6 +525,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 +549,7 @@ public class QbittorrentAdapter implements IDaemonAdapter { @@ -552,7 +549,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
leechers[1],
(int) eta,
(long) (size * progress),
(long) (size * ratio),
uploaded,
size,
(float) progress,
0f,

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

@ -17,6 +17,8 @@ @@ -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; @@ -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 { @@ -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 { @@ -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 { @@ -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() : "");
}
}

4
keystore.properties.example

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

2
latest-app.html

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

2
latest-search.html

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

Loading…
Cancel
Save