From 2a06c1ba56520a8c5e0f99edff21e0a9b1fa90bc Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Tue, 30 Jun 2015 12:58:50 +0200 Subject: [PATCH] Added native support for Dediseebox seedboxes. --- app/src/main/AndroidManifest.xml | 1 + .../core/seedbox/DediseedboxSettings.java | 91 +++++++++++++++++++ .../seedbox/DediseedboxSettingsActivity.java | 72 +++++++++++++++ .../core/seedbox/SeedboxProvider.java | 6 ++ app/src/main/res/values/strings.xml | 1 + .../main/res/xml/pref_seedbox_dediseedbox.xml | 39 ++++++++ 6 files changed, 210 insertions(+) create mode 100644 app/src/main/java/org/transdroid/core/seedbox/DediseedboxSettings.java create mode 100644 app/src/main/java/org/transdroid/core/seedbox/DediseedboxSettingsActivity.java create mode 100644 app/src/main/res/xml/pref_seedbox_dediseedbox.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 88ed9c9e..7b88f377 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -190,6 +190,7 @@ + diff --git a/app/src/main/java/org/transdroid/core/seedbox/DediseedboxSettings.java b/app/src/main/java/org/transdroid/core/seedbox/DediseedboxSettings.java new file mode 100644 index 00000000..70e849f6 --- /dev/null +++ b/app/src/main/java/org/transdroid/core/seedbox/DediseedboxSettings.java @@ -0,0 +1,91 @@ +/* + * Copyright 2010-2013 Eric Kok et al. + * + * Transdroid is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Transdroid is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Transdroid. If not, see . + */ +package org.transdroid.core.seedbox; + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; + +import org.transdroid.core.app.settings.ServerSetting; +import org.transdroid.daemon.Daemon; +import org.transdroid.daemon.OS; + +/** + * Implementation of {@link SeedboxSettings} for Dediseedbox seedboxes. + * @author Eric Kok + */ +public class DediseedboxSettings extends SeedboxSettingsImpl implements SeedboxSettings { + + @Override + public String getName() { + return "Dediseedbox"; + } + + @Override + public ServerSetting getServerSetting(SharedPreferences prefs, int orderOffset, int order) { + // @formatter:off + String server = prefs.getString("seedbox_dediseedbox_server_" + order, null); + if (server == null) { + return null; + } + String user = prefs.getString("seedbox_dediseedbox_user_" + order, null); + String pass = prefs.getString("seedbox_dediseedbox_pass_" + order, null); + return new ServerSetting( + orderOffset + order, + prefs.getString("seedbox_dediseedbox_name_" + order, null), + Daemon.rTorrent, + server, + null, + 443, + null, + 443, + true, + false, + null, + "/rutorrent/plugins/httprpc/action.php", + true, + user, + pass, + null, + OS.Linux, + "/", + "ftp://" + user + "@" + server + "/", + pass, + 6, + true, + true, + true); + // @formatter:on + } + + @Override + public Intent getSettingsActivityIntent(Context context) { + return DediseedboxSettingsActivity_.intent(context).get(); + } + + @Override + public int getMaxSeedboxOrder(SharedPreferences prefs) { + return getMaxSeedboxOrder(prefs, "seedbox_dediseedbox_server_"); + } + + @Override + public void removeServerSetting(SharedPreferences prefs, int order) { + removeServerSetting(prefs, "seedbox_dediseedbox_server_", new String[] { "seedbox_dediseedbox_name_", + "seedbox_dediseedbox_server_", "seedbox_dediseedbox_user_", "seedbox_dediseedbox_pass_" }, order); + } + +} diff --git a/app/src/main/java/org/transdroid/core/seedbox/DediseedboxSettingsActivity.java b/app/src/main/java/org/transdroid/core/seedbox/DediseedboxSettingsActivity.java new file mode 100644 index 00000000..79b856ce --- /dev/null +++ b/app/src/main/java/org/transdroid/core/seedbox/DediseedboxSettingsActivity.java @@ -0,0 +1,72 @@ +/* + * Copyright 2010-2013 Eric Kok et al. + * + * Transdroid is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Transdroid is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Transdroid. If not, see . + */ +package org.transdroid.core.seedbox; + +import android.annotation.TargetApi; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Build; +import android.os.Bundle; +import android.preference.PreferenceManager; + +import org.androidannotations.annotations.EActivity; +import org.androidannotations.annotations.OptionsItem; +import org.androidannotations.annotations.OptionsMenu; +import org.transdroid.R; +import org.transdroid.core.gui.settings.KeyBoundPreferencesActivity; +import org.transdroid.core.gui.settings.MainSettingsActivity_; + +/** + * Activity that allows for the configuration of a Dediseedbox seedbox. The key can be supplied to update an + * existing server setting instead of creating a new one. + * @author Eric Kok + */ +@EActivity +@OptionsMenu(resName = "activity_deleteableprefs") +public class DediseedboxSettingsActivity extends KeyBoundPreferencesActivity { + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + // Load the raw preferences to show in this screen + init(R.xml.pref_seedbox_dediseedbox, + SeedboxProvider.Dediseedbox.getSettings().getMaxSeedboxOrder( + PreferenceManager.getDefaultSharedPreferences(this))); + initTextPreference("seedbox_dediseedbox_name"); + initTextPreference("seedbox_dediseedbox_server"); + initTextPreference("seedbox_dediseedbox_user"); + initTextPreference("seedbox_dediseedbox_pass"); + + } + + @TargetApi(Build.VERSION_CODES.HONEYCOMB) + @OptionsItem(android.R.id.home) + protected void navigateUp() { + MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start(); + } + + @OptionsItem(resName = "action_removesettings") + protected void removeSettings() { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); + SeedboxProvider.Dediseedbox.getSettings().removeServerSetting(prefs, key); + finish(); + } + +} diff --git a/app/src/main/java/org/transdroid/core/seedbox/SeedboxProvider.java b/app/src/main/java/org/transdroid/core/seedbox/SeedboxProvider.java index cd3fb83e..83974cc8 100644 --- a/app/src/main/java/org/transdroid/core/seedbox/SeedboxProvider.java +++ b/app/src/main/java/org/transdroid/core/seedbox/SeedboxProvider.java @@ -25,6 +25,12 @@ import org.transdroid.core.gui.settings.KeyBoundPreferencesActivity; */ public enum SeedboxProvider { + Dediseedbox { + @Override + public SeedboxSettings getSettings() { + return new DediseedboxSettings(); + } + }, Seedstuff { @Override public SeedboxSettings getSettings() { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f417a3d3..db3889f0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -351,6 +351,7 @@ Like desharedgbit001.xirvik.com Cannot retrieve the Xirvik SCGI folder setting; please try again later or correct your server address setting Like 001.seedstuff.ca + Like abcd123.dediseedbox.com rTorrent uTorrent diff --git a/app/src/main/res/xml/pref_seedbox_dediseedbox.xml b/app/src/main/res/xml/pref_seedbox_dediseedbox.xml new file mode 100644 index 00000000..81933679 --- /dev/null +++ b/app/src/main/res/xml/pref_seedbox_dediseedbox.xml @@ -0,0 +1,39 @@ + + + + + + + + + +