From d593e26023996fec1f27b7dfd6073c5787cf90b2 Mon Sep 17 00:00:00 2001 From: lado Date: Mon, 7 Nov 2011 23:10:02 +0100 Subject: connection timeout svdrp event --- vdrmanager/res/values-de/progress.xml | 3 ++- vdrmanager/res/values/progress.xml | 3 ++- .../src/de/bjusystems/vdrmanager/gui/BaseActivity.java | 5 +++++ .../de/bjusystems/vdrmanager/gui/SvdrpProgressDialog.java | 1 + .../de/bjusystems/vdrmanager/tasks/AsyncProgressTask.java | 1 + .../de/bjusystems/vdrmanager/utils/svdrp/SvdrpClient.java | 14 ++++++++++++-- .../de/bjusystems/vdrmanager/utils/svdrp/SvdrpEvent.java | 4 ++++ 7 files changed, 27 insertions(+), 4 deletions(-) diff --git a/vdrmanager/res/values-de/progress.xml b/vdrmanager/res/values-de/progress.xml index 89bdb39..0aa7dc4 100644 --- a/vdrmanager/res/values-de/progress.xml +++ b/vdrmanager/res/values-de/progress.xml @@ -3,7 +3,8 @@ Verbinde… - Verbindung fehlgeschlagen + Verbindung fehlgeschlagen! + Zeitüberschreitung beim Verbindungsaufbau! Anmelden. Anmelden fehlgeschlagen. Lade EPG… diff --git a/vdrmanager/res/values/progress.xml b/vdrmanager/res/values/progress.xml index 9074a7a..a6d4634 100644 --- a/vdrmanager/res/values/progress.xml +++ b/vdrmanager/res/values/progress.xml @@ -3,7 +3,8 @@ Connecting… - Connection failed + Connection failed! + Connection timeout! Login. Login failed. Loading EPG… diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java index 412b4de..c6fccc6 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java @@ -50,6 +50,7 @@ public abstract class BaseActivity extends Activity protected void switchNoConnection() { if (flipper == null) { + say(R.string.no_connection); return; } @@ -152,6 +153,9 @@ public abstract class BaseActivity extends Activity protected boolean noConnection(SvdrpEvent event) { switch (event) { + case CONNECTION_TIMEOUT: + say(R.string.progress_connect_timeout); + switchNoConnection(); case CONNECT_ERROR: say(R.string.progress_connect_error); switchNoConnection(); @@ -220,6 +224,7 @@ public abstract class BaseActivity extends Activity case CONNECTED: connected(); break; + case CONNECTION_TIMEOUT: case CONNECT_ERROR: case FINISHED_ABNORMALY: case LOGIN_ERROR: diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/SvdrpProgressDialog.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/SvdrpProgressDialog.java index 304e922..1b3b1a9 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/SvdrpProgressDialog.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/SvdrpProgressDialog.java @@ -31,6 +31,7 @@ public class SvdrpProgressDialog extends ProgressDialog implements public void svdrpEvent(final SvdrpEvent sevent, T e) { switch (sevent) { case ABORTED: + case CONNECTION_TIMEOUT: case CONNECT_ERROR: case ERROR: case LOGIN_ERROR: diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/tasks/AsyncProgressTask.java b/vdrmanager/src/de/bjusystems/vdrmanager/tasks/AsyncProgressTask.java index 09c796f..26bc510 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/tasks/AsyncProgressTask.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/tasks/AsyncProgressTask.java @@ -20,6 +20,7 @@ public abstract class AsyncProgressTask { switch (event) { case ABORTED: case CONNECT_ERROR: + case CONNECTION_TIMEOUT: case ERROR: case LOGIN_ERROR: case FINISHED_ABNORMALY: diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpClient.java b/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpClient.java index 58b64f2..f8ff229 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpClient.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpClient.java @@ -6,6 +6,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.InetSocketAddress; import java.net.Socket; +import java.net.SocketTimeoutException; import java.util.ArrayList; import java.util.List; import java.util.Timer; @@ -154,7 +155,7 @@ public abstract class SvdrpClient { new InetSocketAddress(prefs.getSvdrpHost(), prefs .getSvdrpPort()), prefs.getConnectionTimeout() * 1000);// 8 secs for connect - if(abort){ + if (abort) { informListener(SvdrpEvent.ABORTED, null); } // @@ -175,9 +176,18 @@ public abstract class SvdrpClient { } }, delay); informListener(SvdrpEvent.CONNECTED, null); + } catch (final SocketTimeoutException sote) { + Log.w(TAG, sote); + if (abort) { + informListener(SvdrpEvent.ABORTED, null); + } else { + informListener(SvdrpEvent.CONNECTION_TIMEOUT, null); + } + return false; } catch (final Exception e) { + Log.w(TAG, e); - if(abort){ + if (abort) { informListener(SvdrpEvent.ABORTED, null); } else { informListener(SvdrpEvent.CONNECT_ERROR, null); diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpEvent.java b/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpEvent.java index 4384136..7eb6fac 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpEvent.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SvdrpEvent.java @@ -17,4 +17,8 @@ public enum SvdrpEvent { ABORTED, ERROR, CACHE_HIT, + CONNECTION_TIMEOUT + // + ; + } -- cgit v1.2.3