Compare commits

..

No commits in common. 'aadddd0d3ac926bb376e956e2d2451f7d91ff638' and '98906e8e2467ed5e065f2a7c22610ae2b1fa9caf' have entirely different histories.

  1. 16
      app/src/main/java/org/transdroid/daemon/adapters/bitComet/BitCometAdapter.java
  2. 24
      app/src/main/java/org/transdroid/daemon/adapters/qBittorrent/QBittorrentAdapter.java

16
app/src/main/java/org/transdroid/daemon/adapters/bitComet/BitCometAdapter.java

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
/*
/*
* This file is part of Transdroid <http://www.transdroid.org>
*
* Transdroid is free software: you can redistribute it and/or modify
@ -592,12 +592,6 @@ public class BitCometAdapter implements IDaemonAdapter { @@ -592,12 +592,6 @@ public class BitCometAdapter implements IDaemonAdapter {
// End of a 'transfer' item, add gathered torrent data
sizeDone = (long) (totalSize * progress);
// Fix seeding status for completed torrents
if (status == TorrentStatus.Downloading && progress >= 1) {
status = TorrentStatus.Seeding;
}
// @formatter:off
torrents.add(new Torrent(
id,
@ -662,10 +656,10 @@ public class BitCometAdapter implements IDaemonAdapter { @@ -662,10 +656,10 @@ public class BitCometAdapter implements IDaemonAdapter {
status = convertStatus(xpp.getText());
break;
case "bytes_downloaded":
sizeDone = Long.parseLong(xpp.getText());
sizeDone = Integer.parseInt(xpp.getText());
break;
case "bytes_uploaded":
sizeUp = Long.parseLong(xpp.getText());
sizeUp = Integer.parseInt(xpp.getText());
break;
case "size":
totalSize = Long.parseLong(xpp.getText());
@ -784,10 +778,6 @@ public class BitCometAdapter implements IDaemonAdapter { @@ -784,10 +778,6 @@ public class BitCometAdapter implements IDaemonAdapter {
return TorrentStatus.Paused;
} else if (state.equals("running")) {
return TorrentStatus.Downloading;
} else if (state.equals("hashing")) {
return TorrentStatus.Checking;
} else if (state.equals("queued")) {
return TorrentStatus.Queued;
}
return TorrentStatus.Unknown;
}

24
app/src/main/java/org/transdroid/daemon/adapters/qBittorrent/QBittorrentAdapter.java

@ -90,10 +90,6 @@ public class QBittorrentAdapter implements IDaemonAdapter { @@ -90,10 +90,6 @@ public class QBittorrentAdapter implements IDaemonAdapter {
private DefaultHttpClient httpclient;
private int version = -1;
private long lastAuthTime = -1;
private int qbNoPriority = 0;
private int qbLowPriority = 1;
private int qbNormalPriority = 2;
private int qbHighPriority = 7;
public QBittorrentAdapter(DaemonSettings settings) {
this.settings = settings;
@ -128,14 +124,10 @@ public class QBittorrentAdapter implements IDaemonAdapter { @@ -128,14 +124,10 @@ public class QBittorrentAdapter implements IDaemonAdapter {
}
version = parseVersionNumber(versionText);
if (version >= 30200) {
qbNormalPriority = 6;
}
} catch (Exception e) {
// Unable to establish version number; assume an old version by setting it to version 1
version = 10000;
qbNormalPriority = 2;
}
}
@ -379,13 +371,13 @@ public class QBittorrentAdapter implements IDaemonAdapter { @@ -379,13 +371,13 @@ public class QBittorrentAdapter implements IDaemonAdapter {
// Update the priorities to a set of files
SetFilePriorityTask setPrio = (SetFilePriorityTask) task;
int newPrio = qbNoPriority;
String newPrio = "0";
if (setPrio.getNewPriority() == Priority.Low) {
newPrio = qbLowPriority;
newPrio = "1";
} else if (setPrio.getNewPriority() == Priority.Normal) {
newPrio = qbNormalPriority;
newPrio = "2";
} else if (setPrio.getNewPriority() == Priority.High) {
newPrio = qbHighPriority;
newPrio = "7";
}
// We have to make a separate request per file, it seems
for (TorrentFile file : setPrio.getForFiles()) {
@ -395,7 +387,7 @@ public class QBittorrentAdapter implements IDaemonAdapter { @@ -395,7 +387,7 @@ public class QBittorrentAdapter implements IDaemonAdapter {
path = "/command/setFilePrio";
}
makeRequest(log, path, new BasicNameValuePair("hash", task.getTargetTorrent().getUniqueID()),
new BasicNameValuePair("id", file.getKey()), new BasicNameValuePair("priority", Integer.toString(newPrio)));
new BasicNameValuePair("id", file.getKey()), new BasicNameValuePair("priority", newPrio));
}
return new DaemonTaskSuccessResult(task);
@ -899,11 +891,11 @@ public class QBittorrentAdapter implements IDaemonAdapter { @@ -899,11 +891,11 @@ public class QBittorrentAdapter implements IDaemonAdapter {
private Priority parsePriority(int priority) {
// Priority is an integer
// Actually 1 = Normal, 2 = High, 7 = Maximum, but adjust this to Transdroid values
if (priority == qbNoPriority) {
if (priority == 0) {
return Priority.Off;
} else if (priority == qbLowPriority) {
} else if (priority == 1) {
return Priority.Low;
} else if (priority == qbNormalPriority) {
} else if (priority == 2) {
return Priority.Normal;
}
return Priority.High;

Loading…
Cancel
Save