@ -70,71 +90,28 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -70,71 +90,28 @@ public class QbittorrentAdapter implements IDaemonAdapter {
// Format is something like 'qBittorrent v2.9.7 (Web UI)' or 'qBittorrent v3.0.0-alpha5 (Web UI)'
}catch(Exceptione2){
// Legacy mode; format is something like 'qBittorrent v2.9.7 (Web UI)' or 'qBittorrent v3.0.0-alpha5 (Web UI)'
Stringabout=makeRequest(log,"/about.html");
StringaboutStartText="qBittorrent v";
StringaboutEndText=" (Web UI)";
@ -144,13 +121,13 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -144,13 +121,13 @@ public class QbittorrentAdapter implements IDaemonAdapter {
// Unable to establish version number; assume an old version by setting it to version 1
version=10000;
apiVersion=10000;
}
}
@ -162,7 +139,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -162,7 +139,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
if(parts.length>0){
version=Integer.parseInt(parts[0])*100*100;
if(parts.length>1){
version+=Float.parseFloat(parts[1])*100;
version+=Integer.parseInt(parts[1])*100;
if(parts.length>2){
// For the last part only read until a non-numeric character is read
// For example version 3.0.0-alpha5 is read as version code 30000
@ -176,7 +153,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -176,7 +153,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
break;
}
}
version+=Float.parseFloat(numbers);
version+=Integer.parseInt(numbers);
}
}
}
@ -186,55 +163,60 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -186,55 +163,60 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -254,7 +236,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -254,7 +236,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -269,7 +251,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -269,7 +251,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -282,7 +264,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -282,7 +264,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
caseAddByFile:
// Upload a local .torrent file
if(version>=40200){
if(version>=40100){
path="/api/v2/torrents/add";
}else{
path="/command/upload";
@ -296,7 +278,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -296,7 +278,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
// Request to add a torrent by URL
Stringurl=((AddByUrlTask)task).getUrl();
if(version>=40200){
if(version>=40100){
path="/api/v2/torrents/add";
}else{
path="/command/upload";
@ -309,7 +291,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -309,7 +291,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
// Request to add a magnet link by URL
Stringmagnet=((AddByMagnetUrlTask)task).getUrl();
if(version>=40200){
if(version>=40100){
path="/api/v2/torrents/add";
}else{
path="/command/download";
@ -322,7 +304,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -322,7 +304,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -343,7 +325,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -343,7 +325,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -354,7 +336,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -354,7 +336,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -365,7 +347,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -365,7 +347,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -376,7 +358,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -376,7 +358,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -399,7 +381,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -399,7 +381,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
}
// We have to make a separate request per file, it seems
for(TorrentFilefile:setPrio.getForFiles()){
if(version>=40200){
if(version>=40100){
path="/api/v2/torrents/filePrio";
}else{
path="/command/setFilePrio";
@ -413,7 +395,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -413,7 +395,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
caseForceRecheck:
// Force recheck a torrent
if(version>=40200){
if(version>=40100){
path="/api/v2/torrents/recheck";
}else{
path="/command/recheck";
@ -424,7 +406,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -424,7 +406,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
caseToggleSequentialDownload:
// Toggle sequential download mode on a torrent
if(version>=40200){
if(version>=40100){
path="/api/v2/torrents/toggleSequentialDownload";
}else{
path="/command/toggleSequentialDownload";
@ -435,7 +417,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -435,7 +417,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
caseToggleFirstLastPieceDownload:
// Set policy for downloading first and last piece first on a torrent
if(version>=40200){
if(version>=40100){
path="/api/v2/torrents/toggleFirstLastPiecePrio";
}else{
path="/command/toggleFirstLastPiecePrio";
@ -446,7 +428,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -446,7 +428,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
caseSetLabel:
SetLabelTasklabelTask=(SetLabelTask)task;
if(version>=40200){
if(version>=40100){
path="/api/v2/torrents/setCategory";
}else{
path="/command/setCategory";
@ -459,7 +441,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -459,7 +441,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -478,7 +460,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -478,7 +460,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -493,7 +475,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -493,7 +475,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
caseGetStats:
// Refresh alternative download speeds setting
if(version>=40200){
if(version>=40100){
path="/api/v2/sync/maindata?rid=0";
}else{
path="/sync/maindata?rid=0";
@ -509,7 +491,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -509,7 +491,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
caseSetAlternativeMode:
// Flip alternative speed mode
if(version>=40200){
if(version>=40100){
path="/api/v2/transfer/toggleSpeedLimitsMode";
}else{
path="/command/toggleAlternativeSpeedLimits";
@ -567,12 +549,6 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -567,12 +549,6 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -604,8 +580,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -604,8 +580,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -614,14 +589,18 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -614,14 +589,18 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -667,7 +646,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -667,7 +646,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
Map<String,Label>labels=newHashMap<>();
for(inti=0;i<response.length();i++){
JSONObjecttor=response.getJSONObject(i);
if(apiVersion>=20000){
if(version>=40100){
Stringlabel=tor.optString("category");
if(label!=null&&label.length()>0){
finalLabellabelObject=labels.get(label);
@ -699,7 +678,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -699,7 +678,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -891,7 +870,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -891,7 +870,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {