From cf8736e23bb0581a5deacdcdb0572b7d79d10860 Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Mon, 26 Apr 2021 15:45:09 +0200 Subject: [PATCH] Support for adding Xirvik servers by QR code --- .../app/settings/ApplicationSettings.java | 1 + .../core/app/settings/ServerSetting.java | 7 +- .../transdroid/core/gui/TorrentsActivity.java | 2 +- .../core/gui/search/BarcodeHelper.java | 1 + .../gui/settings/MainSettingsActivity.java | 68 ++++++++++++++++- .../core/seedbox/DediseedboxSettings.java | 1 + .../core/seedbox/XirvikDediSettings.java | 32 +++++++- .../core/seedbox/XirvikSemiSettings.java | 32 +++++++- .../core/seedbox/XirvikSharedSettings.java | 35 ++++++++- .../seedbox/XirvikSharedSettingsActivity.java | 73 +++++++++++-------- .../org/transdroid/daemon/DaemonSettings.java | 10 ++- .../transdroid/daemon/util/HttpHelper.java | 17 ++++- app/src/main/res/values/changelog.xml | 3 + app/src/main/res/values/strings.xml | 2 + 14 files changed, 240 insertions(+), 44 deletions(-) diff --git a/app/src/main/java/org/transdroid/core/app/settings/ApplicationSettings.java b/app/src/main/java/org/transdroid/core/app/settings/ApplicationSettings.java index d4d9ffe4..583a521a 100644 --- a/app/src/main/java/org/transdroid/core/app/settings/ApplicationSettings.java +++ b/app/src/main/java/org/transdroid/core/app/settings/ApplicationSettings.java @@ -188,6 +188,7 @@ public class ApplicationSettings { prefs.getString("server_user_" + order, null), prefs.getString("server_pass_" + order, null), prefs.getString("server_extrapass_" + order, null), + null, OS.fromCode(prefs.getString("server_os_" + order, "type_linux")), prefs.getString("server_downloaddir_" + order, null), prefs.getString("server_ftpurl_" + order, null), diff --git a/app/src/main/java/org/transdroid/core/app/settings/ServerSetting.java b/app/src/main/java/org/transdroid/core/app/settings/ServerSetting.java index c3e061af..21bc77da 100644 --- a/app/src/main/java/org/transdroid/core/app/settings/ServerSetting.java +++ b/app/src/main/java/org/transdroid/core/app/settings/ServerSetting.java @@ -49,6 +49,7 @@ public class ServerSetting implements SimpleListItem { private final String username; private final String password; private final String extraPass; + private final String authToken; private final OS os; private final String downloadDir; private final String ftpUrl; @@ -80,6 +81,7 @@ public class ServerSetting implements SimpleListItem { * @param username The user name to provide during authentication * @param password The password to provide during authentication * @param extraPass The Deluge web interface password + * @param authToken Alternative authentication method via auth token added as custom network header * @param downloadDir The default download directory (which may also be used as base directory for file paths) * @param ftpUrl The partial URL to connect to when requesting FTP-style transfers * @param timeout The number of seconds to wait before timing out a connection attempt @@ -87,7 +89,7 @@ public class ServerSetting implements SimpleListItem { */ public ServerSetting(int key, String name, Daemon type, String address, String localAddress, int localPort, String localNetwork, int port, boolean ssl, boolean localSsl, boolean sslTrustAll, String sslTrustKey, String folder, boolean useAuthentication, String username, - String password, String extraPass, OS os, String downloadDir, String ftpUrl, String ftpPassword, int timeout, + String password, String extraPass, String authToken, OS os, String downloadDir, String ftpUrl, String ftpPassword, int timeout, boolean alarmOnFinishedDownload, boolean alarmOnNewTorrent, String excludeFilter, String includeFilter, boolean isAutoGenerated) { this.key = key; @@ -107,6 +109,7 @@ public class ServerSetting implements SimpleListItem { this.username = username; this.password = password; this.extraPass = extraPass; + this.authToken = authToken; this.os = os; this.downloadDir = downloadDir; this.ftpUrl = ftpUrl; @@ -331,7 +334,7 @@ public class ServerSetting implements SimpleListItem { } } return new DaemonSettings(name, type, addressToUse, portToUse, sslEnable, sslTrustAll, sslTrustKey, folder, - useAuthentication, username, password, extraPass, os, downloadDir, ftpUrl, ftpPassword, timeout, + useAuthentication, username, password, extraPass, authToken, os, downloadDir, ftpUrl, ftpPassword, timeout, alarmOnFinishedDownload, alarmOnNewTorrent, Integer.toString(key), isAutoGenerated); } } diff --git a/app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java b/app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java index 791eba05..ec40eeb5 100644 --- a/app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java +++ b/app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java @@ -1077,7 +1077,7 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE try { // Cookies are taken from the websearchSetting that we already matched against this target URL - DefaultHttpClient httpclient = HttpHelper.createStandardHttpClient(false, null, null, true, null, 10000, null, -1); + DefaultHttpClient httpclient = HttpHelper.createStandardHttpClient(false, null, null, null, true, null, 10000, null, -1); Map cookies = HttpHelper.parseCookiePairs(websearchSetting.getCookies()); String domain = Uri.parse(url).getHost(); for (Entry pair : cookies.entrySet()) { diff --git a/app/src/main/java/org/transdroid/core/gui/search/BarcodeHelper.java b/app/src/main/java/org/transdroid/core/gui/search/BarcodeHelper.java index 6ff8406d..6232ec0b 100644 --- a/app/src/main/java/org/transdroid/core/gui/search/BarcodeHelper.java +++ b/app/src/main/java/org/transdroid/core/gui/search/BarcodeHelper.java @@ -31,6 +31,7 @@ public class BarcodeHelper { // A 'random' ID to identify QR-encoded settings scan intents public static final int ACTIVITY_BARCODE_QRSETTINGS = 0x0000c0df; + public static final int ACTIVITY_BARCODE_ADDSERVER = 0x0000c0e0; private static final Uri SCANNER_MARKET_URI = Uri.parse("market://search?q=pname:com.google.zxing.client.android"); /** diff --git a/app/src/main/java/org/transdroid/core/gui/settings/MainSettingsActivity.java b/app/src/main/java/org/transdroid/core/gui/settings/MainSettingsActivity.java index c5f589f5..33e9a55e 100644 --- a/app/src/main/java/org/transdroid/core/gui/settings/MainSettingsActivity.java +++ b/app/src/main/java/org/transdroid/core/gui/settings/MainSettingsActivity.java @@ -30,8 +30,13 @@ import androidx.preference.ListPreference; import androidx.preference.Preference; import androidx.preference.Preference.OnPreferenceClickListener; +import com.nispok.snackbar.Snackbar; +import com.nispok.snackbar.SnackbarManager; +import com.nispok.snackbar.enums.SnackbarType; + import org.androidannotations.annotations.Bean; import org.androidannotations.annotations.EActivity; +import org.androidannotations.annotations.OnActivityResult; import org.androidannotations.annotations.OptionsItem; import org.transdroid.R; import org.transdroid.core.app.search.SearchHelper; @@ -41,13 +46,19 @@ import org.transdroid.core.app.settings.RssfeedSetting; import org.transdroid.core.app.settings.ServerSetting; import org.transdroid.core.app.settings.WebsearchSetting; import org.transdroid.core.gui.TorrentsActivity_; +import org.transdroid.core.gui.log.Log; import org.transdroid.core.gui.navigation.NavigationHelper; +import org.transdroid.core.gui.search.BarcodeHelper; import org.transdroid.core.gui.settings.RssfeedPreference.OnRssfeedClickedListener; import org.transdroid.core.gui.settings.ServerPreference.OnServerClickedListener; import org.transdroid.core.gui.settings.WebsearchPreference.OnWebsearchClickedListener; import org.transdroid.core.seedbox.SeedboxPreference; import org.transdroid.core.seedbox.SeedboxPreference.OnSeedboxClickedListener; import org.transdroid.core.seedbox.SeedboxProvider; +import org.transdroid.core.seedbox.XirvikDediSettings; +import org.transdroid.core.seedbox.XirvikSemiSettings; +import org.transdroid.core.seedbox.XirvikSharedSettings; +import org.transdroid.core.seedbox.XirvikSharedSettingsActivity; import java.util.ArrayList; import java.util.List; @@ -68,6 +79,8 @@ public class MainSettingsActivity extends PreferenceCompatActivity { protected ApplicationSettings applicationSettings; @Bean protected SearchHelper searchHelper; + @Bean + protected Log log; protected SharedPreferences prefs; private OnPreferenceClickListener onAddServer = new OnPreferenceClickListener() { @Override @@ -115,6 +128,8 @@ public class MainSettingsActivity extends PreferenceCompatActivity { // Start the configuration activity for this specific chosen seedbox if (which == 0) ServerSettingsActivity_.intent(MainSettingsActivity.this).start(); + else if (which == SeedboxProvider.values().length + 1) + BarcodeHelper.startBarcodeScanner(this, BarcodeHelper.ACTIVITY_BARCODE_ADDSERVER); else startActivity(SeedboxProvider.values()[which - 1].getSettings().getSettingsActivityIntent(MainSettingsActivity.this)); }; @@ -251,14 +266,63 @@ public class MainSettingsActivity extends PreferenceCompatActivity { protected Dialog onCreateDialog(int id) { if (id == DIALOG_ADDSEEDBOX) { // Open dialog to pick one of the supported seedbox providers (or a normal server) - String[] seedboxes = new String[SeedboxProvider.values().length + 1]; + String[] seedboxes = new String[SeedboxProvider.values().length + 2]; seedboxes[0] = getString(R.string.pref_addserver_normal); - for (int i = 0; i < seedboxes.length - 1; i++) { + for (int i = 0; i < seedboxes.length - 2; i++) { seedboxes[i + 1] = getString(R.string.pref_seedbox_addseedbox, SeedboxProvider.values()[i].getSettings().getName()); } + seedboxes[seedboxes.length - 1] = getString(R.string.pref_seedbox_xirvikviaqr); return new AlertDialog.Builder(this).setItems(seedboxes, onAddSeedbox).create(); } return null; } + @OnActivityResult(BarcodeHelper.ACTIVITY_BARCODE_ADDSERVER) + public void onServerBarcodeScanned(int resultCode, Intent data) { + if (resultCode == RESULT_OK && data != null) { + final String result = data.getStringExtra("SCAN_RESULT"); + final String format = data.getStringExtra("SCAN_RESULT_FORMAT"); + if (format == null || !format.equals("QR_CODE") || result == null || result.split("\n").length < 3) { + SnackbarManager.show(Snackbar.with(this).text(R.string.pref_seedbox_xirvikscanerror).colorResource(R.color.red) + .type(SnackbarType.MULTI_LINE)); + return; + } + onServerBarcodeScanHandled(result.split("\n")); + } + } + + protected void onServerBarcodeScanHandled(String[] qrResult) { + final String server = qrResult[0]; + final String token = qrResult[2]; + switch (qrResult[1]) { + case "P": + XirvikDediSettings xirvikDediSettings = new XirvikDediSettings(); + xirvikDediSettings.saveServerSetting(this, server, token); + onResume(); + break; + case "N": + XirvikSemiSettings xirvikSemiSettings = new XirvikSemiSettings(); + xirvikSemiSettings.saveServerSetting(this, server, token); + onResume(); + break; + case "RG": + new XirvikSharedSettingsActivity.RetrieveXirvikAutoConfTask(server, "", "", token) { + @Override + protected void onPostExecute(String result) { + if (result == null) { + log.d(MainSettingsActivity.this, "Could not retrieve the Xirvik shared seedbox RPC mount point setting"); + } + XirvikSharedSettings xirvikSharedSettings = new XirvikSharedSettings(); + xirvikSharedSettings.saveServerSetting(getApplicationContext(), server, token, result); + onResume(); + } + }.execute(); + break; + default: + SnackbarManager.show(Snackbar.with(this).text(R.string.pref_seedbox_xirvikscanerror).colorResource(R.color.red).type(SnackbarType.MULTI_LINE)); + break; + } + } + + } diff --git a/app/src/main/java/org/transdroid/core/seedbox/DediseedboxSettings.java b/app/src/main/java/org/transdroid/core/seedbox/DediseedboxSettings.java index 0b5593a5..46ab5870 100644 --- a/app/src/main/java/org/transdroid/core/seedbox/DediseedboxSettings.java +++ b/app/src/main/java/org/transdroid/core/seedbox/DediseedboxSettings.java @@ -63,6 +63,7 @@ public class DediseedboxSettings extends SeedboxSettingsImpl implements SeedboxS user, pass, null, + null, OS.Linux, "/", "ftp://" + user + "@" + server + "/", diff --git a/app/src/main/java/org/transdroid/core/seedbox/XirvikDediSettings.java b/app/src/main/java/org/transdroid/core/seedbox/XirvikDediSettings.java index 8d8467d5..3c82fd46 100644 --- a/app/src/main/java/org/transdroid/core/seedbox/XirvikDediSettings.java +++ b/app/src/main/java/org/transdroid/core/seedbox/XirvikDediSettings.java @@ -20,6 +20,8 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import androidx.preference.PreferenceManager; + import org.transdroid.core.app.settings.ServerSetting; import org.transdroid.daemon.Daemon; import org.transdroid.daemon.OS; @@ -46,6 +48,7 @@ public class XirvikDediSettings extends SeedboxSettingsImpl implements SeedboxSe Daemon type = Daemon.fromCode(prefs.getString("seedbox_xirvikdedi_client_" + order, null)); String user = prefs.getString("seedbox_xirvikdedi_user_" + order, null); String pass = prefs.getString("seedbox_xirvikdedi_pass_" + order, null); + String authToken = prefs.getString("seedbox_xirvikdedi_token_" + order, null); return new ServerSetting( orderOffset + order, prefs.getString("seedbox_xirvikdedi_name_" + order, null), @@ -64,6 +67,7 @@ public class XirvikDediSettings extends SeedboxSettingsImpl implements SeedboxSe user, pass, type == Daemon.Deluge ? "deluge" : null, + authToken, OS.Linux, type == Daemon.uTorrent ? "/downloads" : null, "ftp://" + user + "@" + server + "/", @@ -91,7 +95,33 @@ public class XirvikDediSettings extends SeedboxSettingsImpl implements SeedboxSe public void removeServerSetting(SharedPreferences prefs, int order) { removeServerSetting(prefs, "seedbox_xirvikdedi_server_", new String[]{"seedbox_xirvikdedi_name_", "seedbox_xirvikdedi_server_", "seedbox_xirvikdedi_client_", "seedbox_xirvikdedi_user_", - "seedbox_xirvikdedi_pass_"}, order); + "seedbox_xirvikdedi_pass_", "seedbox_xirvikdedi_token_"}, order); + } + + public void saveServerSetting(Context context, String server, String token) { + // Get server order + int key = SeedboxProvider.XirvikDedi.getSettings().getMaxSeedboxOrder(PreferenceManager.getDefaultSharedPreferences(context)) + 1; + + // Shared preferences + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + + // Check server already exists to replace token + for(int i = 0 ; i <= SeedboxProvider.XirvikDedi.getSettings().getMaxSeedboxOrder(PreferenceManager.getDefaultSharedPreferences(context)) ; i++) { + if(prefs.getString("seedbox_xirvikdedi_server_" + i, "").equals(server)) { + key = i; + } + } + + // Store new seedbox pref + prefs.edit() + .putString("seedbox_xirvikdedi_client_" + key, Daemon.toCode(Daemon.rTorrent)) + .putString("seedbox_xirvikdedi_name" + key, "QR Server " + key) + .putString("seedbox_xirvikdedi_server_" + key, server) + .putString("seedbox_xirvikdedi_user_" + key, "") + .putString("seedbox_xirvikdedi_pass_" + key, "") + .putString("seedbox_xirvikdedi_token_" + key, token) + .apply(); + } } diff --git a/app/src/main/java/org/transdroid/core/seedbox/XirvikSemiSettings.java b/app/src/main/java/org/transdroid/core/seedbox/XirvikSemiSettings.java index 02e58fad..e030d053 100644 --- a/app/src/main/java/org/transdroid/core/seedbox/XirvikSemiSettings.java +++ b/app/src/main/java/org/transdroid/core/seedbox/XirvikSemiSettings.java @@ -20,6 +20,8 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import androidx.preference.PreferenceManager; + import org.transdroid.core.app.settings.ServerSetting; import org.transdroid.daemon.Daemon; import org.transdroid.daemon.OS; @@ -45,6 +47,7 @@ public class XirvikSemiSettings extends SeedboxSettingsImpl implements SeedboxSe } String user = prefs.getString("seedbox_xirviksemi_user_" + order, null); String pass = prefs.getString("seedbox_xirviksemi_pass_" + order, null); + String authToken = prefs.getString("seedbox_xirviksemi_token_" + order, null); return new ServerSetting( orderOffset + order, prefs.getString("seedbox_xirviksemi_name_" + order, null), @@ -63,6 +66,7 @@ public class XirvikSemiSettings extends SeedboxSettingsImpl implements SeedboxSe user, pass, null, + authToken, OS.Linux, null, "ftp://" + user + "@" + server + "/downloads", @@ -89,7 +93,33 @@ public class XirvikSemiSettings extends SeedboxSettingsImpl implements SeedboxSe @Override public void removeServerSetting(SharedPreferences prefs, int order) { removeServerSetting(prefs, "seedbox_xirviksemi_server_", new String[]{"seedbox_xirviksemi_name_", - "seedbox_xirviksemi_server_", "seedbox_xirviksemi_user_", "seedbox_xirviksemi_pass_"}, order); + "seedbox_xirviksemi_server_", "seedbox_xirviksemi_user_", "seedbox_xirviksemi_pass_", "seedbox_xirviksemi_token_"}, order); + } + + public void saveServerSetting(Context context, String server, String token) { + // Get server order + int key = SeedboxProvider.XirvikSemi.getSettings().getMaxSeedboxOrder(PreferenceManager.getDefaultSharedPreferences(context)) + 1; + + // Shared preferences + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + + // Check server already exists to replace token + for (int i = 0; i <= SeedboxProvider.XirvikSemi.getSettings().getMaxSeedboxOrder(PreferenceManager.getDefaultSharedPreferences(context)); i++) { + if (prefs.getString("seedbox_xirviksemi_server_" + i, "").equals(server)) { + key = i; + } + } + + // Store new seedbox pref + prefs.edit() + .putString("seedbox_xirviksemi_client_" + key, Daemon.toCode(Daemon.rTorrent)) + .putString("seedbox_xirviksemi_name" + key, "QR Server " + key) + .putString("seedbox_xirviksemi_server_" + key, server) + .putString("seedbox_xirviksemi_user_" + key, "") + .putString("seedbox_xirviksemi_pass_" + key, "") + .putString("seedbox_xirviksemi_token_" + key, token) + .apply(); + } } diff --git a/app/src/main/java/org/transdroid/core/seedbox/XirvikSharedSettings.java b/app/src/main/java/org/transdroid/core/seedbox/XirvikSharedSettings.java index 6f671098..f3e4afb9 100644 --- a/app/src/main/java/org/transdroid/core/seedbox/XirvikSharedSettings.java +++ b/app/src/main/java/org/transdroid/core/seedbox/XirvikSharedSettings.java @@ -20,6 +20,8 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import androidx.preference.PreferenceManager; + import org.transdroid.core.app.settings.ServerSetting; import org.transdroid.daemon.Daemon; import org.transdroid.daemon.OS; @@ -43,13 +45,15 @@ public class XirvikSharedSettings extends SeedboxSettingsImpl implements Seedbox if (server == null) { return null; } + Daemon type = Daemon.fromCode(prefs.getString("seedbox_xirvikshared_client_" + order, null)); String user = prefs.getString("seedbox_xirvikshared_user_" + order, null); String pass = prefs.getString("seedbox_xirvikshared_pass_" + order, null); String rpc = prefs.getString("seedbox_xirvikshared_rpc_" + order, null); + String authToken = prefs.getString("seedbox_xirvikshared_token_" + order, null); return new ServerSetting( orderOffset + order, prefs.getString("seedbox_xirvikshared_name_" + order, null), - Daemon.rTorrent, + type, server, null, 0, @@ -64,6 +68,7 @@ public class XirvikSharedSettings extends SeedboxSettingsImpl implements Seedbox user, pass, null, + authToken, OS.Linux, null, "ftp://" + user + "@" + server + "/downloads", @@ -91,7 +96,33 @@ public class XirvikSharedSettings extends SeedboxSettingsImpl implements Seedbox public void removeServerSetting(SharedPreferences prefs, int order) { removeServerSetting(prefs, "seedbox_xirvikshared_server_", new String[]{"seedbox_xirvikshared_name_", "seedbox_xirvikshared_server_", "seedbox_xirvikshared_user_", "seedbox_xirvikshared_pass_", - "seedbox_xirvikshared_rpc_"}, order); + "seedbox_xirvikshared_rpc_", "seedbox_xirvikshared_token_"}, order); + } + + public void saveServerSetting(final Context context, String server, String token, String rcp) { + // Get server order + int key = SeedboxProvider.XirvikShared.getSettings().getMaxSeedboxOrder(PreferenceManager.getDefaultSharedPreferences(context)) + 1; + + // Shared preferences + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + + // Check server already exists to replace token + for (int i = 0; i <= SeedboxProvider.XirvikShared.getSettings().getMaxSeedboxOrder(PreferenceManager.getDefaultSharedPreferences(context)); i++) { + if (prefs.getString("seedbox_xirvikshared_server_" + i, "").equals(server)) { + key = i; + } + } + + // Store new seedbox pref + prefs.edit() + .putString("seedbox_xirvikshared_client_" + key, Daemon.toCode(Daemon.rTorrent)) + .putString("seedbox_xirvikshared_name" + key, "QR Server " + key) + .putString("seedbox_xirvikshared_server_" + key, server) + .putString("seedbox_xirvikshared_user_" + key, "") + .putString("seedbox_xirvikshared_pass_" + key, "") + .putString("seedbox_xirvikshared_token_" + key, token) + .putString("seedbox_xirvikshared_rpc_" + key, rcp) + .apply(); } } diff --git a/app/src/main/java/org/transdroid/core/seedbox/XirvikSharedSettingsActivity.java b/app/src/main/java/org/transdroid/core/seedbox/XirvikSharedSettingsActivity.java index b7efbc46..ea0c3cbc 100644 --- a/app/src/main/java/org/transdroid/core/seedbox/XirvikSharedSettingsActivity.java +++ b/app/src/main/java/org/transdroid/core/seedbox/XirvikSharedSettingsActivity.java @@ -90,38 +90,13 @@ public class XirvikSharedSettingsActivity extends KeyBoundPreferencesActivity { excludeFilter.setEnabled(alarmNew || alarmFinished); includeFilter.setEnabled(alarmNew || alarmFinished); - new AsyncTask() { - @Override - protected String doInBackground(Void... params) { - try { - - // When the shared server settings change, we also have to update the RPC mount point to use - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(XirvikSharedSettingsActivity.this); - String server = prefs.getString("seedbox_xirvikshared_server_" + key, null); - String user = prefs.getString("seedbox_xirvikshared_user_" + key, null); - String pass = prefs.getString("seedbox_xirvikshared_pass_" + key, null); - - // Retrieve the RPC mount point setting from the server itself - DefaultHttpClient httpclient = - HttpHelper.createStandardHttpClient(true, user, pass, true, null, HttpHelper.DEFAULT_CONNECTION_TIMEOUT, server, 443); - String url = "https://" + server + ":443/browsers_addons/transdroid_autoconf.txt"; - HttpResponse request = httpclient.execute(new HttpGet(url)); - InputStream stream = request.getEntity().getContent(); - String folder = HttpHelper.convertStreamToString(stream).trim(); - if (folder.startsWith(" { + final String server; + final String user; + final String pass; + final String token; + + public RetrieveXirvikAutoConfTask(String server, String user, String pass, String token) { + this.server = server; + this.user = user; + this.pass = pass; + this.token = token; + } + + @Override + protected String doInBackground(Void... params) { + try { + // Retrieve the RPC mount point setting from the server itself + DefaultHttpClient httpclient = + HttpHelper.createStandardHttpClient(true, user, pass, token, true, null, HttpHelper.DEFAULT_CONNECTION_TIMEOUT, server, 443); + String url = "https://" + server + ":443/browsers_addons/transdroid_autoconf.txt"; + HttpResponse request = httpclient.execute(new HttpGet(url)); + InputStream stream = request.getEntity().getContent(); + String folder = HttpHelper.convertStreamToString(stream).trim(); + if (folder.startsWith(" +Transdroid 2.5.20\n +- Add Xirvik servers via QR code\n +\n Transdroid 2.5.19\n - Dark theme to use black background\n - Reinstated black widget\n diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e43f4875..d2ffffe4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -379,6 +379,8 @@ Torrent client Client to connect to Server address + Add Xirvik server via QR + Not a valid Xirvik server QR code Like eplus001.xirvik.com Like semixl001a.xirvik.com Like desharedgbit001.xirvik.com