diff options
Diffstat (limited to 'vdrmanager/de.bjusystems.vdrmanager/src')
14 files changed, 188 insertions, 81 deletions
diff --git a/vdrmanager/de.bjusystems.vdrmanager/src/main/java/de/bjusystems/vdrmanager/data/Preferences.java b/vdrmanager/de.bjusystems.vdrmanager/src/main/java/de/bjusystems/vdrmanager/data/Preferences.java index d4aaab9..6904402 100644 --- a/vdrmanager/de.bjusystems.vdrmanager/src/main/java/de/bjusystems/vdrmanager/data/Preferences.java +++ b/vdrmanager/de.bjusystems.vdrmanager/src/main/java/de/bjusystems/vdrmanager/data/Preferences.java @@ -10,7 +10,6 @@ import android.text.TextUtils; import de.bjusystems.vdrmanager.R; import de.bjusystems.vdrmanager.StringUtils; -import de.bjusystems.vdrmanager.app.VdrManagerApp; import de.bjusystems.vdrmanager.data.db.DBAccess; /** @@ -162,6 +161,10 @@ public class Preferences { return getCurrentVdr().getStreamingPassword(); } + public String getIp46Mode() { + return getCurrentVdr().getIp46Mode(); + } + /** * Properties singleton */ @@ -238,6 +241,15 @@ public class Preferences { * * @return port */ + public String getSvdrpHost() { + return getCurrentVdr().getSvdrpHost(); + } + + /** + * Gets the port + * + * @return port + */ public int getSvdrpPort() { return getCurrentVdr().getSvdrpPort(); } diff --git a/vdrmanager/de.bjusystems.vdrmanager/src/main/java/de/bjusystems/vdrmanager/data/Vdr.java b/vdrmanager/de.bjusystems.vdrmanager/src/main/java/de/bjusystems/vdrmanager/data/Vdr.java index b7960d3..ad53fd5 100644 --- a/vdrmanager/de.bjusystems.vdrmanager/src/main/java/de/bjusystems/vdrmanager/data/Vdr.java +++ b/vdrmanager/de.bjusystems.vdrmanager/src/main/java/de/bjusystems/vdrmanager/data/Vdr.java @@ -193,11 +193,17 @@ public class Vdr { @DatabaseField(columnName = "stz") private String serverTimeZone = "Europe/Berlin"; + @DatabaseField(columnName="svdrpHost") + private String svdrpHost = ""; + @DatabaseField(columnName="svdrpPort") private int svdrpPort = 6419; @DatabaseField(columnName="enableRemote") private boolean enableRemote = true; + + @DatabaseField(columnName="ip46Mode") + private String ip46Mode = "ip4"; public String getServerTimeZone() { return serverTimeZone; @@ -495,6 +501,14 @@ public class Vdr { this.timeout = timeout; } + public String getIp46Mode() { + return ip46Mode; + } + + public void setIp46Mode(final String ip46Mode) { + this.ip46Mode = ip46Mode; + } + private static <T> T get(Map<String, Object> map, String key) { return get(map, key, null); } @@ -563,6 +577,7 @@ public class Vdr { map.put("vdr_port", port); map.put("vdr_password", password); map.put("vdr_secure", secure); + map.put("vdr_ip46_mode", ip46Mode); map.put("limit_channels", filterChannels); map.put("last_channel", channelFilter); @@ -601,53 +616,13 @@ public class Vdr { map.put("key_smarttvweb_port", smarttvwebPort); map.put("key_smarttvweb_recstream_method", smarttvwebType); map.put("key_remote_enable", enableRemote); + map.put("key_svdrp_host", svdrpHost); map.put("key_svdrp_port", svdrpPort); return map; } public void set(Map<String, Object> map) { init(map); -/* - name = get(map, "vdr_name"); - host = get(map, "vdr_host"); - port = getInteger(map, "vdr_port"); - password = get(map, "vdr_password"); - secure = getBoolean(map, "vdr_secure"); - - filterChannels = getBoolean(map, "limit_channels"); - channelFilter = get(map, "last_channel"); - - wakeupEnabled = getBoolean(map, "key_wakeup_enabled"); - wakeupUrl = get(map, "key_wakeup_url"); - wakeupUser = get(map, "key_wakeup_user"); - wakeupPassword = get(map, "key_wakeup_password"); - wakeupMethod = get(map, "key_wakeup_method"); - wolCustomBroadcast = get(map, "key_wol_custom_broadcast"); - mac = get(map, "key_wakeup_wol_mac"); - - connectionTimeout = getInteger(map, "key_conntimeout_key"); - readTimeout = getInteger(map, "key_vdr_readtimeout"); - timeout = getInteger(map, "key_vdr_timeout"); - - timerPreMargin = getInteger(map, "timer_pre_start_buffer" - ); - timerPostMargin = getInteger(map, "timer_post_end_buffer"); - timerDefaultPriority = getInteger(map, "timer_default_priority"); - timerDefaultLifetime = getInteger(map, "timer_default_lifetime"); - - streamPort = getInteger(map, "streamingport"); - streamingPassword = get(map, "key_streaming_password"); - streamingUsername = get(map, "key_streaming_username"); - encoding = get(map, "key_vdr_encoding"); - streamFormat = get(map, "livetv_streamformat"); - remuxCommand = get(map, "remux_command"); - remuxParameter = get(map, "remux_parameter"); - enableRemux = getBoolean(map, "remux_enable"); - - enableRecStreaming = getBoolean(map, "key_rec_stream_enable"); - livePort = getInteger(map, "key_live_port"); - recStreamMethod = get(map, "key_recstream_method"); - */ } public void init(Map<String, Object> map) { @@ -656,6 +631,7 @@ public class Vdr { port = getInteger(map, "vdr_port", 6420); password = get(map, "vdr_password", ""); secure = getBoolean(map, "vdr_secure"); + ip46Mode = get(map, "vdr_ip46_mode"); filterChannels = getBoolean(map, "limit_channels", true); channelFilter = get(map, "last_channel", ""); @@ -694,6 +670,7 @@ public class Vdr { smarttvwebPort= getInteger(map, "key_smarttvweb_port", 8000); smarttvwebType= get(map, "key_smarttvweb_recstream_method", "progressive"); enableRemote = getBoolean(map, "key_remote_enable", true); + svdrpHost = get(map, "key_svdrp_host", ""); svdrpPort = getInteger(map, "key_svdrp_port", 6419); } @@ -713,6 +690,14 @@ public class Vdr { this.smarttvwebType = smarttvwebType; } + public String getSvdrpHost() { + return svdrpHost; + } + + public void setSvdrpHost(String svdrpHost) { + this.svdrpHost = svdrpHost; + } + public int getSvdrpPort() { return svdrpPort; } diff --git a/vdrmanager/de.bjusystems.vdrmanager/src/main/java/de/bjusystems/vdrmanager/data/db/DBAccess.java b/vdrmanager/de.bjusystems.vdrmanager/src/main/java/de/bjusystems/vdrmanager/data/db/DBAccess.java index f854204..a8305d9 100644 --- a/vdrmanager/de.bjusystems.vdrmanager/src/main/java/de/bjusystems/vdrmanager/data/db/DBAccess.java +++ b/vdrmanager/de.bjusystems.vdrmanager/src/main/java/de/bjusystems/vdrmanager/data/db/DBAccess.java @@ -32,7 +32,7 @@ public class DBAccess extends OrmLiteSqliteOpenHelper { // any time you make changes to your database objects, you may have to // increase the database version // Version 3 since 0.6 - private static final int DATABASE_VERSION = 5; + private static final int DATABASE_VERSION = 7; private RuntimeExceptionDao<Vdr, Integer> vdrDAO = null; @@ -126,6 +126,14 @@ public class DBAccess extends OrmLiteSqliteOpenHelper { } + if (oldVersion < 6) { + getVdrDAO().executeRaw("ALTER TABLE `vdr` ADD COLUMN svdrpHost varchar"); + } + + if (oldVersion < 7) { + getVdrDAO().executeRaw("ALTER TABLE `vdr` ADD COLUMN ip46Mode varchar"); + } + } catch (SQLException e) { Log.e(DBAccess.class.getName(), "Can't drop databases", e); throw new RuntimeException(e); diff --git a/vdrmanager/de.bjusystems.vdrmanager/src/main/java/de/bjusystems/vdrmanager/remote/RemoteActivity.java b/vdrmanager/de.bjusystems.vdrmanager/src/main/java/de/bjusystems/vdrmanager/remote/RemoteActivity.java index d935eda..7b73761 100644 --- a/vdrmanager/de.bjusystems.vdrmanager/src/main/java/de/bjusystems/vdrmanager/remote/RemoteActivity.java +++ b/vdrmanager/de.bjusystems.vdrmanager/src/main/java/de/bjusystems/vdrmanager/remote/RemoteActivity.java @@ -777,7 +777,11 @@ public class RemoteActivity extends Activity implements OnClickListener, View.On try { if (connection == null) { - connection = new Connection(Preferences.get().getHost(), Preferences.get().getSvdrpPort()); + String host = Preferences.get().getSvdrpHost(); + if (host == null || host.length() == 0) { + host = Preferences.get().getHost(); + } + connection = new Connection(host, Preferences.get().getSvdrpPort()); } send = connection.send(new HITK(hitk[0])); diff --git a/vdrmanager/de.bjusystems.vdrmanager/src/main/java/de/bjusystems/vdrmanager/utils/svdrp/SvdrpClient.java b/vdrmanager/de.bjusystems.vdrmanager/src/main/java/de/bjusystems/vdrmanager/utils/svdrp/SvdrpClient.java index 31fa0f4..f415d3a 100644 --- a/vdrmanager/de.bjusystems.vdrmanager/src/main/java/de/bjusystems/vdrmanager/utils/svdrp/SvdrpClient.java +++ b/vdrmanager/de.bjusystems.vdrmanager/src/main/java/de/bjusystems/vdrmanager/utils/svdrp/SvdrpClient.java @@ -1,13 +1,17 @@ package de.bjusystems.vdrmanager.utils.svdrp; +import android.util.Log; + import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.UnsupportedEncodingException; +import java.net.Inet4Address; +import java.net.Inet6Address; +import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Socket; -import java.net.SocketTimeoutException; import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -16,9 +20,6 @@ import java.util.TimerTask; import java.util.zip.GZIPInputStream; import java.util.zip.InflaterInputStream; -import android.content.Context; -import android.sax.StartElementListener; -import android.util.Log; import de.bjusystems.vdrmanager.app.C; import de.bjusystems.vdrmanager.data.Preferences; @@ -224,20 +225,69 @@ public abstract class SvdrpClient<Result> { // connect informListener(SvdrpEvent.CONNECTING); - if (prefs.isSecure()) { - socket = new MySSLSocketFactory(false, - certificateProblemListener).createSocket(); - } else { - socket = new Socket(); + InetAddress ip4address = null; + InetAddress ip6address = null; + + final InetAddress[] addresses = InetAddress.getAllByName(prefs.getHost()); + for (final InetAddress address : addresses) { + if (address instanceof Inet4Address) { + ip4address = address; + } else if (address instanceof Inet6Address) { + ip6address = address; + } } - socket.connect( - new InetSocketAddress(prefs.getHost(), prefs - .getPort()), - prefs.getConnectionTimeout() * 1000);// 8 secs for connect - if (abort) { - informListener(SvdrpEvent.ABORTED); + List<InetAddress> addressToTry = new ArrayList<>(); + + switch (prefs.getIp46Mode()) { + case "ip4": + addressToTry.add(ip4address); + break; + case "ip6": + addressToTry.add(ip6address); + break; + case "ip46": + addressToTry.add(ip4address); + addressToTry.add(ip6address); + break; + case "ip64": + addressToTry.add(ip6address); + addressToTry.add(ip4address); + break; } + + Exception exception = null; + for (final InetAddress inetAddress : addressToTry) { + if (inetAddress == null) { + continue; + } + if (abort) { + break; + } + + try { + initSocket(prefs); + socket.connect(new InetSocketAddress( + inetAddress, + prefs.getPort()), + prefs.getConnectionTimeout() * 1000); + break; + } catch (Exception e) { + socket.close(); + Log.w(TAG, "Couldn't connect to " + inetAddress.getHostAddress()); + exception = e; + } + } + + if (!socket.isConnected()) { + if (abort) { + informListener(SvdrpEvent.ABORTED); + } else { + informListener(SvdrpEvent.CONNECT_ERROR); + } + return false; + } + // socket.setSoTimeout(prefs.getReadTimeout() * 1000);// 15 sec for // each read @@ -261,14 +311,6 @@ public abstract class SvdrpClient<Result> { outputStream = socket.getOutputStream(); inputStream = socket.getInputStream(); - } catch (final SocketTimeoutException sote) { - Log.w(TAG, sote); - if (abort) { - informListener(SvdrpEvent.ABORTED); - } else { - informListener(SvdrpEvent.CONNECTION_TIMEOUT); - } - return false; } catch (final Exception e) { Log.w(TAG, e); @@ -293,6 +335,18 @@ public abstract class SvdrpClient<Result> { return true; } + private void initSocket(final Preferences prefs) throws Exception { + if (socket != null) { + socket.close(); + } + if (prefs.isSecure()) { + socket = new MySSLSocketFactory(false, + certificateProblemListener).createSocket(); + } else { + socket = new Socket(); + } + } + /** * Disconnect from SVDRP if connected * diff --git a/vdrmanager/de.bjusystems.vdrmanager/src/main/java/de/bjusystems/vdrmanager/utils/wakeup/AsyncWakeupTask.java b/vdrmanager/de.bjusystems.vdrmanager/src/main/java/de/bjusystems/vdrmanager/utils/wakeup/AsyncWakeupTask.java index 0b99b04..12a1f3e 100644 --- a/vdrmanager/de.bjusystems.vdrmanager/src/main/java/de/bjusystems/vdrmanager/utils/wakeup/AsyncWakeupTask.java +++ b/vdrmanager/de.bjusystems.vdrmanager/src/main/java/de/bjusystems/vdrmanager/utils/wakeup/AsyncWakeupTask.java @@ -6,8 +6,6 @@ import android.os.AsyncTask; import android.util.Log; import android.widget.Toast; -import java.io.IOException; - import de.bjusystems.vdrmanager.R; import de.bjusystems.vdrmanager.data.Preferences; import de.bjusystems.vdrmanager.utils.http.HttpHelper; diff --git a/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values-de/strings.xml b/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values-de/strings.xml index 3ba27fa..7a7d365 100644 --- a/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values-de/strings.xml +++ b/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values-de/strings.xml @@ -137,6 +137,8 @@ herrlado<herrlado@gmail.com></string> <string name="vdr_password_summary">Passwort für das VDR Plugin</string> <string name="vdr_ssl_title">Sichere Verbindung</string> <string name="vdr_ssl_summary">Verwende SSL für Verbindungen (aktuell nicht implementiert)</string> + <string name="vdr_ip46_mode_title">IPv4/6 Auswahl</string> + <string name="vdr_ip46_mode_summary">IPv4/6 Auswahl-Modus</string> <!-- channel filter preferences --> <string name="channel_filter_preferences">Kanaleinstellungen</string> <string name="channel_filter_filter_title">Begrenze Kanäle</string> @@ -493,8 +495,10 @@ Wie soll verfahren werden?</string> <string name="remote">Remote Control</string> <string name="remote_enable_summary">Shows the remote control view if enabled</string> <string name="remote_enable_title">Enable VDR remote control</string> + <string name="svdrp_host_title">SVDRP Hostname</string> + <string name="svdrp_host_summary">Standard ist der VDR Host</string> <string name="svdrp_port_title">SVDRP Port</string> - <string name="svdrp_port_summary">Default is 6419</string> + <string name="svdrp_port_summary">Standard ist 6419</string> <string name="label">Label</string> <string name="hitkcommand">HITK Command</string> <string name="menu_reset">Reset</string> diff --git a/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values-fr/strings.xml b/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values-fr/strings.xml index f7087cb..1816cef 100644 --- a/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values-fr/strings.xml +++ b/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values-fr/strings.xml @@ -493,7 +493,9 @@ Que voulez-vous faire?</string> <string name="remote">Télécommande</string> <string name="remote_enable_summary">Afficher la télécommande si activée</string> <string name="remote_enable_title">Activer la télécommande de VDR</string> - <string name="svdrp_port_title">Port DVDRP</string> + <string name="svdrp_host_title">Hôte SVDRP</string> + <string name="svdrp_host_summary">Hôte SVDRP</string> + <string name="svdrp_port_title">Port SVDRP</string> <string name="svdrp_port_summary">Par défaut le 6419</string> <string name="label">Label</string> <string name="hitkcommand">HITK Command</string> diff --git a/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values-it/strings.xml b/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values-it/strings.xml index 01575cb..b815bda 100644 --- a/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values-it/strings.xml +++ b/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values-it/strings.xml @@ -493,6 +493,8 @@ What do you want to do?</string> <string name="remote">Remote Control</string> <string name="remote_enable_summary">Shows the remote control view if enabled</string> <string name="remote_enable_title">Enable VDR remote control</string> + <string name="svdrp_host_title">SVDRP Nome sistema/IP</string> + <string name="svdrp_host_summary">Default is VDR host</string> <string name="svdrp_port_title">SVDRP Port</string> <string name="svdrp_port_summary">Default is 6419</string> <string name="label">Label</string> diff --git a/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values-pl/strings.xml b/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values-pl/strings.xml index a4338a4..e71e1a7 100644 --- a/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values-pl/strings.xml +++ b/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values-pl/strings.xml @@ -489,6 +489,8 @@ What do you want to do?</string> <string name="remote">Remote Control</string> <string name="remote_enable_summary">Shows the remote control view if enabled</string> <string name="remote_enable_title">Enable VDR remote control</string> + <string name="svdrp_host_title">Nazwa hosta SVDRP</string> + <string name="svdrp_host_summary">Default is VDR host</string> <string name="svdrp_port_title">SVDRP Port</string> <string name="svdrp_port_summary">Default is 6419</string> </resources> diff --git a/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values-uk/strings.xml b/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values-uk/strings.xml index 46dc34f..bf88f86 100644 --- a/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values-uk/strings.xml +++ b/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values-uk/strings.xml @@ -491,6 +491,8 @@ What do you want to do?</string> <string name="remote">Remote Control</string> <string name="remote_enable_summary">Shows the remote control view if enabled</string> <string name="remote_enable_title">Enable VDR remote control</string> + <string name="svdrp_host_title">SVDRP Host</string> + <string name="svdrp_host_summary">Default is vdr host</string> <string name="svdrp_port_title">SVDRP Port</string> <string name="svdrp_port_summary">Default is 6419</string> <string name="label">Label</string> diff --git a/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values/arrays.xml b/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values/arrays.xml index 94d1831..e43e39e 100644 --- a/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values/arrays.xml +++ b/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values/arrays.xml @@ -37,16 +37,23 @@ <item>vdr-smarttvweb</item> </string-array> - <string-array name="recent_channels_order_entry_values"> - <item>most</item> - <item>last</item> - </string-array> - <array name="recstream_smarttvweb_entry_values"> - <item>progressive</item> + <string-array name="recent_channels_order_entry_values"> + <item>most</item> + <item>last</item> + </string-array> + <array name="recstream_smarttvweb_entry_values"> + <item>progressive</item> <item>has</item> <item>hls</item> - </array> + </array> + + <string-array name="vdr_ip46_mode_values"> + <item>ip4</item> + <item>ip6</item> + <item>ip46</item> + <item>ip64</item> + </string-array> <string-array name="font"> <item> 500px </item> <item> address-book </item> @@ -836,4 +843,5 @@ <item> youtube-square </item> </string-array> + </resources> diff --git a/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values/strings.xml b/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values/strings.xml index 433f581..0ff0cd0 100644 --- a/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values/strings.xml +++ b/vdrmanager/de.bjusystems.vdrmanager/src/main/res/values/strings.xml @@ -148,6 +148,15 @@ <string name="vdr_password_summary">Password for the VDR plugin</string> <string name="vdr_ssl_title">Secure connect</string> <string name="vdr_ssl_summary">Use SSL for connections</string> + <string name="vdr_ip46_mode_title">IPv4/6 selection</string> + <string name="vdr_ip46_mode_summary">IPv4/6 selection mode</string> + + <string-array name="vdr_ip46_mode"> + <item>Use only IPv4</item> + <item>Use only IPv6</item> + <item>Prefer IPv4 over IPv6</item> + <item>Prefer IPv6 over IPv4</item> + </string-array> <!-- channel filter preferences --> <string name="channel_filter_preferences">Channel settings</string> @@ -547,6 +556,8 @@ <string name="remote_enable_title">Enable VDR remote control</string> <string name="svdrp_port_title">SVDRP Port</string> <string name="svdrp_port_summary">Default is 6419</string> + <string name="svdrp_host_title">SVDRP Host</string> + <string name="svdrp_host_summary">Default is vdr host</string> <string name="label">Label</string> <string name="hitkcommand">HITK Command</string> <string name="menu_reset">Reset</string> diff --git a/vdrmanager/de.bjusystems.vdrmanager/src/main/res/xml/vdr_prefs.xml b/vdrmanager/de.bjusystems.vdrmanager/src/main/res/xml/vdr_prefs.xml index 5c6e8b1..b221b3f 100644 --- a/vdrmanager/de.bjusystems.vdrmanager/src/main/res/xml/vdr_prefs.xml +++ b/vdrmanager/de.bjusystems.vdrmanager/src/main/res/xml/vdr_prefs.xml @@ -32,6 +32,15 @@ android:enabled="true" android:summary="@string/vdr_ssl_summary" android:title="@string/vdr_ssl_title" /> + + <ListPreference + android:entries="@array/vdr_ip46_mode" + android:entryValues="@array/vdr_ip46_mode_values" + android:defaultValue="ip4_only" + android:key="vdr_ip46_mode" + android:title="@string/vdr_ip46_mode_title" + android:summary="@string/vdr_ip46_mode_summary"/> + </PreferenceCategory> <PreferenceCategory android:key="filter_preferences" @@ -202,15 +211,21 @@ android:key="key_remote_enable" android:summary="@string/remote_enable_summary" android:title="@string/remote_enable_title" /> - - <EditTextPreference + + <EditTextPreference + android:inputType="text" + android:dependency="key_remote_enable" + android:key="key_svdrp_host" + android:summary="@string/svdrp_host_summary" + android:title="@string/svdrp_host_title"/> + <EditTextPreference android:inputType="number" android:key="key_svdrp_port" android:dependency="key_remote_enable" android:summary="@string/svdrp_port_summary" android:defaultValue="@integer/svdrp_default_port" android:title="@string/svdrp_port_title" /> - + </PreferenceCategory> <PreferenceScreen android:title="Advanced" > |