Browse Source

Fixed support for Xirvik shared seedboxes (that require loading the RPC mount point from the server).

pull/148/merge
Eric Kok 11 years ago
parent
commit
6635c8ffc5
  1. 5
      core/res/values/changelog.xml
  2. 1
      core/res/values/strings.xml
  3. 4
      core/res/xml/pref_seedbox_xirvikshared.xml
  4. 6
      core/src/org/transdroid/core/seedbox/XirvikSharedSettings.java
  5. 78
      core/src/org/transdroid/core/seedbox/XirvikSharedSettingsActivity.java

5
core/res/values/changelog.xml

@ -18,6 +18,11 @@ @@ -18,6 +18,11 @@
<resources>
<string name="system_changelog">
Transdroid 2.1.2\n
- Fixed labeling from details screen\n
- Fixed qBittorrent support\n
- Fixed Xirvik shared seedbox support\n
\n
Transdroid 2.1.2\n
- Support for new Torrent Search\'s private sites\n
- Added optional auto refresh\n
- Allow larger .torrent file uploads with rTorrent\n

1
core/res/values/strings.xml

@ -328,6 +328,7 @@ @@ -328,6 +328,7 @@
<string name="pref_seedbox_xirvikhint">Like eplus001.xirvik.com</string>
<string name="pref_seedbox_xirvikhint2">Like semixl001a.xirvik.com</string>
<string name="pref_seedbox_xirvikhint3">Like desharedgbit001.xirvik.com</string>
<string name="pref_seedbox_xirviknofolder">Cannot retrieve the Xirvik SCGI folder setting; please try again later or correct your server address setting</string>
<string name="pref_seedbox_seedstuffhint">Like 001.seedstuff.ca</string>
<string-array name="pref_seedbox_xirvikclients" translatable="false">
<item>rTorrent</item>

4
core/res/xml/pref_seedbox_xirvikshared.xml

@ -35,5 +35,9 @@ @@ -35,5 +35,9 @@
android:key="seedbox_xirvikshared_pass"
android:title="@string/pref_pass"
android:inputType="textPassword" />
<EditTextPreference
android:key="seedbox_xirvikshared_rpc"
android:title="@string/pref_folder"
android:enabled="false" />
</PreferenceScreen>

6
core/src/org/transdroid/core/seedbox/XirvikSharedSettings.java

@ -44,6 +44,7 @@ public class XirvikSharedSettings extends SeedboxSettingsImpl implements Seedbox @@ -44,6 +44,7 @@ public class XirvikSharedSettings extends SeedboxSettingsImpl implements Seedbox
}
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);
return new ServerSetting(
orderOffset + order,
prefs.getString("seedbox_xirvikshared_name_" + order, null),
@ -56,7 +57,7 @@ public class XirvikSharedSettings extends SeedboxSettingsImpl implements Seedbox @@ -56,7 +57,7 @@ public class XirvikSharedSettings extends SeedboxSettingsImpl implements Seedbox
true,
true,
null,
"/RPC2",
rpc,
true,
user,
pass,
@ -85,7 +86,8 @@ public class XirvikSharedSettings extends SeedboxSettingsImpl implements Seedbox @@ -85,7 +86,8 @@ public class XirvikSharedSettings extends SeedboxSettingsImpl implements Seedbox
@Override
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_" }, order);
"seedbox_xirvikshared_server_", "seedbox_xirvikshared_user_", "seedbox_xirvikshared_pass_",
"seedbox_xirvikshared_rpc_" }, order);
}
}

78
core/src/org/transdroid/core/seedbox/XirvikSharedSettingsActivity.java

@ -16,22 +16,35 @@ @@ -16,22 +16,35 @@
*/
package org.transdroid.core.seedbox;
import java.io.InputStream;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.OptionsItem;
import org.androidannotations.annotations.OptionsMenu;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.transdroid.core.R;
import org.transdroid.core.gui.log.Log;
import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.core.gui.settings.KeyBoundPreferencesActivity;
import org.transdroid.core.gui.settings.*;
import org.transdroid.daemon.util.HttpHelper;
import android.annotation.TargetApi;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.PreferenceManager;
import de.keyboardsurfer.android.widget.crouton.Crouton;
/**
* Activity that allows for the configuration of a Xirvik shared seedbox. The key can be supplied to update an
* existing server setting instead of creating a new one.
* Activity that allows for the configuration of a Xirvik shared seedbox. The key can be supplied to update an existing
* server setting instead of creating a new one.
* @author Eric Kok
*/
@EActivity
@ -52,7 +65,68 @@ public class XirvikSharedSettingsActivity extends KeyBoundPreferencesActivity { @@ -52,7 +65,68 @@ public class XirvikSharedSettingsActivity extends KeyBoundPreferencesActivity {
initTextPreference("seedbox_xirvikshared_server");
initTextPreference("seedbox_xirvikshared_user");
initTextPreference("seedbox_xirvikshared_pass");
initTextPreference("seedbox_xirvikshared_rpc");
}
@Override
protected void onPreferencesChanged() {
new AsyncTask<Void, Void, String>() {
@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("<?xml")) {
folder = null;
}
stream.close();
return folder;
} catch (Exception e) {
Log.d(XirvikSharedSettingsActivity.this,
"Could not retrieve the Xirvik shared seedbox RPC mount point setting: " + e.toString());
return null;
}
}
@Override
protected void onPostExecute(String result) {
storeScgiMountFolder(result);
}
}.execute();
}
@SuppressWarnings("deprecation")
protected void storeScgiMountFolder(String result) {
Editor edit = PreferenceManager.getDefaultSharedPreferences(XirvikSharedSettingsActivity.this).edit();
EditTextPreference pref = (EditTextPreference) findPreference("seedbox_xirvikshared_rpc_" + key);
if (result == null) {
Crouton.showText(this, R.string.pref_seedbox_xirviknofolder, NavigationHelper.CROUTON_ERROR_STYLE);
edit.remove("seedbox_xirvikshared_rpc_" + key);
pref.setSummary("");
} else {
edit.putString("seedbox_xirvikshared_rpc_" + key, result);
pref.setSummary(result);
}
edit.commit();
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)

Loading…
Cancel
Save