From bb987226c843375a93043bbd5f78a94e0edea29d Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Fri, 18 May 2012 19:12:38 +0200 Subject: Version 0.5.5 - Add state to speed display --- res/values/strings.xml | 3 ++- res/xml/main_headers.xml | 9 ++++----- src/de/blinkt/openvpn/LogWindow.java | 6 +++--- src/de/blinkt/openvpn/OpenVPN.java | 20 ++++++++++---------- src/de/blinkt/openvpn/OpenVPNThread.java | 2 +- src/de/blinkt/openvpn/OpenVpnManagementThread.java | 11 ++++++++++- src/de/blinkt/openvpn/Settings_Authentication.java | 1 - src/de/blinkt/openvpn/Settings_IP.java | 1 - src/de/blinkt/openvpn/Settings_Routing.java | 1 - todo.txt | 1 - 10 files changed, 30 insertions(+), 25 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index c74362e7..0f1004a7 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -219,5 +219,6 @@ Got an excption trying to show the Android 4.0+ certificate selction dialog. This should never happens as this a standard feature of Android 4.0+. Maybe your Android ROM support for certificate storage is broken IPv4 IPv6 - Waiting for byte count messageā€¦ + Waiting for state messageā€¦ + General Settings diff --git a/res/xml/main_headers.xml b/res/xml/main_headers.xml index 71913f49..95bc6fe3 100644 --- a/res/xml/main_headers.xml +++ b/res/xml/main_headers.xml @@ -11,11 +11,10 @@ android:summary="@string/faq_summary" android:title="@string/faq" /> -
- + + \ No newline at end of file diff --git a/src/de/blinkt/openvpn/LogWindow.java b/src/de/blinkt/openvpn/LogWindow.java index 2e2612d3..b38951df 100644 --- a/src/de/blinkt/openvpn/LogWindow.java +++ b/src/de/blinkt/openvpn/LogWindow.java @@ -28,9 +28,9 @@ import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; import de.blinkt.openvpn.OpenVPN.LogListener; -import de.blinkt.openvpn.OpenVPN.SpeedListener; +import de.blinkt.openvpn.OpenVPN.StateListener; -public class LogWindow extends ListActivity implements SpeedListener { +public class LogWindow extends ListActivity implements StateListener { private String[] mBconfig=null; @@ -270,7 +270,7 @@ public class LogWindow extends ListActivity implements SpeedListener { } @Override - public void updateSpeed(final String logmessage) { + public void updateState(final String logmessage) { runOnUiThread(new Runnable() { @Override diff --git a/src/de/blinkt/openvpn/OpenVPN.java b/src/de/blinkt/openvpn/OpenVPN.java index 1d9eb6e0..40fe3afd 100644 --- a/src/de/blinkt/openvpn/OpenVPN.java +++ b/src/de/blinkt/openvpn/OpenVPN.java @@ -10,15 +10,15 @@ public class OpenVPN { public static LinkedList logbuffer = new LinkedList(); private static Vector logListener=new Vector(); - private static Vector speedListener=new Vector(); + private static Vector stateListener=new Vector(); private static String[] mBconfig; public interface LogListener { void newLog(String logmessage); } - public interface SpeedListener { - void updateSpeed(String logmessage); + public interface StateListener { + void updateState(String logmessage); } synchronized static void logMessage(int level,String prefix, String message) @@ -46,12 +46,12 @@ public class OpenVPN { } - synchronized static void addSpeedListener(SpeedListener sl){ - speedListener.add(sl); + synchronized static void addSpeedListener(StateListener sl){ + stateListener.add(sl); } - synchronized static void removeSpeedListener(SpeedListener sl) { - speedListener.remove(sl); + synchronized static void removeSpeedListener(StateListener sl) { + stateListener.remove(sl); } @@ -77,9 +77,9 @@ public class OpenVPN { } - public static void updateSpeedString(String msg) { - for (SpeedListener sl : speedListener) { - sl.updateSpeed(msg); + public static void updateStateString(String msg) { + for (StateListener sl : stateListener) { + sl.updateState(msg); } } } diff --git a/src/de/blinkt/openvpn/OpenVPNThread.java b/src/de/blinkt/openvpn/OpenVPNThread.java index 89cd0a59..dcd5f4ec 100644 --- a/src/de/blinkt/openvpn/OpenVPNThread.java +++ b/src/de/blinkt/openvpn/OpenVPNThread.java @@ -58,7 +58,7 @@ public class OpenVPNThread implements Runnable { //mInterface = null; - mService.getHandler().sendEmptyMessage(R.string.disconnected); + OpenVPN.updateStateString("No process running"); // Not a good place to do it, but will do OpenVPN.logBuilderConfig(null); Log.i(TAG, "Exiting"); diff --git a/src/de/blinkt/openvpn/OpenVpnManagementThread.java b/src/de/blinkt/openvpn/OpenVpnManagementThread.java index 82d6f00d..c10cdb1e 100644 --- a/src/de/blinkt/openvpn/OpenVpnManagementThread.java +++ b/src/de/blinkt/openvpn/OpenVpnManagementThread.java @@ -161,10 +161,13 @@ public class OpenVpnManagementThread implements Runnable { } else if (cmd.equals("HOLD")) { managmentCommand("hold release\n"); managmentCommand("bytecount " + mBytecountinterval + "\n"); + managmentCommand("state on\n"); } else if (cmd.equals("NEED-OK")) { processNeedCommand(argument); } else if (cmd.equals("BYTECOUNT")){ processByteCount(argument); + } else if (cmd.equals("STATE")){ + processState(argument); } else if (cmd.equals("LOG")) { String[] args = argument.split(",",3); // 0 unix time stamp @@ -183,6 +186,12 @@ public class OpenVpnManagementThread implements Runnable { } } + private void processState(String argument) { + String[] args = argument.split(",",2); + OpenVPN.updateStateString(args[1]); + } + + private void processByteCount(String argument) { // >BYTECOUNT:{BYTES_IN},{BYTES_OUT} int comma = argument.indexOf(','); @@ -200,7 +209,7 @@ public class OpenVpnManagementThread implements Runnable { humanReadableByteCount(diffin, false), humanReadableByteCount(out, false), humanReadableByteCount(diffout, false)); - OpenVPN.updateSpeedString(netstat); + OpenVPN.updateStateString(netstat); } diff --git a/src/de/blinkt/openvpn/Settings_Authentication.java b/src/de/blinkt/openvpn/Settings_Authentication.java index 6d6960e9..b2e84087 100644 --- a/src/de/blinkt/openvpn/Settings_Authentication.java +++ b/src/de/blinkt/openvpn/Settings_Authentication.java @@ -9,7 +9,6 @@ import android.preference.ListPreference; import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; import android.preference.Preference.OnPreferenceClickListener; -import android.preference.PreferenceFragment; import android.preference.SwitchPreference; diff --git a/src/de/blinkt/openvpn/Settings_IP.java b/src/de/blinkt/openvpn/Settings_IP.java index f1e495c8..d6fd19d4 100644 --- a/src/de/blinkt/openvpn/Settings_IP.java +++ b/src/de/blinkt/openvpn/Settings_IP.java @@ -4,7 +4,6 @@ import android.preference.CheckBoxPreference; import android.preference.EditTextPreference; import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; -import android.preference.PreferenceFragment; import android.preference.PreferenceManager; import android.preference.SwitchPreference; diff --git a/src/de/blinkt/openvpn/Settings_Routing.java b/src/de/blinkt/openvpn/Settings_Routing.java index 8305f4db..202c45c1 100644 --- a/src/de/blinkt/openvpn/Settings_Routing.java +++ b/src/de/blinkt/openvpn/Settings_Routing.java @@ -4,7 +4,6 @@ import android.preference.CheckBoxPreference; import android.preference.EditTextPreference; import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; -import android.preference.PreferenceManager; public class Settings_Routing extends OpenVpnPreferencesFragment implements OnPreferenceChangeListener { diff --git a/todo.txt b/todo.txt index 77736361..62e6d279 100644 --- a/todo.txt +++ b/todo.txt @@ -17,7 +17,6 @@ Ideas: Missing configuration options: IPv6 support: -- Make GUI IPv6 fit - fix bogus tun-ipv6 warning Tap support: -- cgit v1.2.3