@ -70,7 +70,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -70,7 +70,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
privateDaemonSettingssettings;
privateDefaultHttpClienthttpclient;
privateintversion=-1;
privatefloatapiVersion=-1;// starting from 2.3 old API is dropped so we are going to use float
privateintapiVersion=-1;
publicQbittorrentAdapter(DaemonSettingssettings){
this.settings=settings;
@ -87,53 +87,53 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -87,53 +87,53 @@ public class QbittorrentAdapter implements IDaemonAdapter {
// The API version is only supported since qBittorrent 3.2, so otherwise we assume version 1
@ -149,7 +149,19 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -149,7 +149,19 @@ public class QbittorrentAdapter implements IDaemonAdapter {
}
log.d(LOG_NAME,"qBittorrent client version is "+versionText);
version=parseVersionNumber(versionText);
}catch(Exceptione){
// Unable to establish version number; assume an old version by setting it to version 1
version=10000;
apiVersion=10000;
}
}
privateintparseVersionNumber(StringversionText){
// String found: now parse a version like 2.9.7 as a number like 20907 (allowing 10 places for each .)
intversion=-1;
String[]parts=versionText.split("\\.");
if(parts.length>0){
version=Integer.parseInt(parts[0])*100*100;
@ -172,20 +184,14 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -172,20 +184,14 @@ public class QbittorrentAdapter implements IDaemonAdapter {
}
}
}
}catch(Exceptione){
// Unable to establish version number; assume an old version by setting it to version 1
// API changed in 3.2.0, login is now handled by its own request, which provides you a cookie.
// If we don't have that cookie, let's try and get it.
if(apiVersion<(float)2){
if(apiVersion<20000){
return;
}
@ -198,7 +204,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -198,7 +204,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -666,7 +672,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -666,7 +672,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
Map<String,Label>labels=newHashMap<>();
for(inti=0;i<response.length();i++){
JSONObjecttor=response.getJSONObject(i);
if(apiVersion>=2){
if(apiVersion>=20000){
Stringlabel=tor.optString("category");
if(label!=null&&label.length()>0){
finalLabellabelObject=labels.get(label);
@ -698,7 +704,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -698,7 +704,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -890,7 +896,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -890,7 +896,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {