Don't authenticate if we don't have to. Fetch API version information and adjust our behaviour accordingly. Still some crash bugs to sort out in API ver 2.
@ -82,6 +82,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -82,6 +82,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
privateDaemonSettingssettings;
privateDefaultHttpClienthttpclient;
privateintversion=-1;
privateintapiVersion=-1;
publicQbittorrentAdapter(DaemonSettingssettings){
this.settings=settings;
@ -93,6 +94,24 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -93,6 +94,24 @@ public class QbittorrentAdapter implements IDaemonAdapter {
// We still need to retrieve the version number from the server
// Do this by getting the web interface about page and trying to parse the version number
// Format is something like 'qBittorrent v2.9.7 (Web UI)'
try{
StringapiVerText=makeRequest(log,"/version/api");
apiVersion=Integer.parseInt(apiVerText.trim());
}
catch(DaemonExceptione){
apiVersion=1;
log.d(LOG_NAME,e.toString());
}
catch(NumberFormatExceptione){
apiVersion=1;
log.d(LOG_NAME,e.toString());
}
log.d(LOG_NAME,"qBittorrent API version is "+apiVersion);
// TODO: In API ver 2, query this information from /version/qbittorrent instead.
// For now at least this works fine, though
Stringabout=makeRequest(log,"/about.html");
StringaboutStartText="qBittorrent v";
StringaboutEndText=" (Web UI)";
@ -129,47 +148,72 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -129,47 +148,72 @@ public class QbittorrentAdapter implements IDaemonAdapter {
}
// Unable to establish version number; assume an old version by setting it to version 1
@ -177,7 +221,8 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -177,7 +221,8 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -398,10 +443,22 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -398,10 +443,22 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -415,7 +472,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -415,7 +472,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@ -550,7 +607,12 @@ public class QbittorrentAdapter implements IDaemonAdapter {
@@ -550,7 +607,12 @@ public class QbittorrentAdapter implements IDaemonAdapter {