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