diff options
Diffstat (limited to 'src/de/blinkt')
-rw-r--r-- | src/de/blinkt/openvpn/ConfigParser.java | 2 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/LaunchVPN.java | 4 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/LogWindow.java | 4 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/MainActivity.java | 3 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/OpenVPN.java | 49 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/OpenVPNThread.java | 2 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/OpenVpnManagementThread.java | 4 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/OpenVpnService.java | 7 |
8 files changed, 50 insertions, 25 deletions
diff --git a/src/de/blinkt/openvpn/ConfigParser.java b/src/de/blinkt/openvpn/ConfigParser.java index faf0dbd9..37741937 100644 --- a/src/de/blinkt/openvpn/ConfigParser.java +++ b/src/de/blinkt/openvpn/ConfigParser.java @@ -2,8 +2,6 @@ package de.blinkt.openvpn; import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; import java.io.Reader; import java.util.HashMap; import java.util.Locale; diff --git a/src/de/blinkt/openvpn/LaunchVPN.java b/src/de/blinkt/openvpn/LaunchVPN.java index e45bee3b..32ebe33d 100644 --- a/src/de/blinkt/openvpn/LaunchVPN.java +++ b/src/de/blinkt/openvpn/LaunchVPN.java @@ -16,10 +16,7 @@ package de.blinkt.openvpn; -import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; -import java.io.InputStream; import java.util.Collection; import java.util.Vector; @@ -32,7 +29,6 @@ import android.content.DialogInterface.OnClickListener; import android.content.Intent; import android.content.SharedPreferences; import android.net.VpnService; -import android.os.Build; import android.os.Bundle; import android.os.Parcelable; import android.preference.PreferenceManager; diff --git a/src/de/blinkt/openvpn/LogWindow.java b/src/de/blinkt/openvpn/LogWindow.java index ad3af278..88615e12 100644 --- a/src/de/blinkt/openvpn/LogWindow.java +++ b/src/de/blinkt/openvpn/LogWindow.java @@ -327,12 +327,12 @@ public class LogWindow extends ListActivity implements StateListener { } @Override - public void updateState(final String status,final String logmessage) { + public void updateState(final String status,final String logmessage, final int resid) { runOnUiThread(new Runnable() { @Override public void run() { - String prefix=status+ ":"; + String prefix=getString(resid) + ":"; if (status.equals("BYTECOUNT") || status.equals("NOPROCESS") ) prefix=""; mSpeedView.setText(prefix + logmessage); diff --git a/src/de/blinkt/openvpn/MainActivity.java b/src/de/blinkt/openvpn/MainActivity.java index 32cf575b..57506c4f 100644 --- a/src/de/blinkt/openvpn/MainActivity.java +++ b/src/de/blinkt/openvpn/MainActivity.java @@ -1,11 +1,8 @@ package de.blinkt.openvpn; -import java.io.File; -import java.util.ArrayList; import java.util.List; import android.content.Intent; -import android.net.Uri; import android.preference.PreferenceActivity; public class MainActivity extends PreferenceActivity { diff --git a/src/de/blinkt/openvpn/OpenVPN.java b/src/de/blinkt/openvpn/OpenVPN.java index e11d254f..342f02c0 100644 --- a/src/de/blinkt/openvpn/OpenVPN.java +++ b/src/de/blinkt/openvpn/OpenVPN.java @@ -19,6 +19,8 @@ public class OpenVPN { private static String mLaststate; + private static int mLastStateresid=R.string.state_noprocess; + static { logbuffer = new LinkedList<LogItem>(); logListener = new Vector<OpenVPN.LogListener>(); @@ -66,7 +68,7 @@ public class OpenVPN { } - String getString(Context c) { + public String getString(Context c) { if(mMessage !=null) { return mMessage; } else { @@ -97,7 +99,7 @@ public class OpenVPN { } public interface StateListener { - void updateState(String state, String logmessage); + void updateState(String state, String logmessage, int localizedResId); } synchronized static void logMessage(int level,String prefix, String message) @@ -128,7 +130,35 @@ public class OpenVPN { public synchronized static void addStateListener(StateListener sl){ stateListener.add(sl); if(mLaststate!=null) - sl.updateState(mLaststate, mLaststatemsg); + sl.updateState(mLaststate, mLaststatemsg, mLastStateresid); + } + + private static int getLocalizedState(String state){ + if (state.equals("CONNECTING")) + return R.string.state_connecting; + else if (state.equals("WAIT")) + return R.string.state_wait; + else if (state.equals("AUTH")) + return R.string.state_auth; + else if (state.equals("GET_CONFIG")) + return R.string.state_get_config; + else if (state.equals("ASSIGN_IP")) + return R.string.state_assign_ip; + else if (state.equals("ADD_ROUTES")) + return R.string.state_add_routes; + else if (state.equals("CONNECTED")) + return R.string.state_connected; + else if (state.equals("RECONNECTING")) + return R.string.state_reconnecting; + else if (state.equals("EXITING")) + return R.string.state_exiting; + else if (state.equals("RESOLVE")) + return R.string.state_resolve; + else if (state.equals("TCP_CONNECT")) + return R.string.state_tcp_connect; + else + return R.string.unknown_state; + } public synchronized static void removeStateListener(StateListener sl) { @@ -157,12 +187,18 @@ public class OpenVPN { } - public synchronized static void updateStateString(String state, String msg) { + public static void updateStateString (String state, String msg) { + int rid = getLocalizedState(state); + updateStateString(state, msg,rid); + } + + public synchronized static void updateStateString(String state, String msg, int resid) { mLaststate= state; mLaststatemsg = msg; - + mLastStateresid = resid; + for (StateListener sl : stateListener) { - sl.updateState(state,msg); + sl.updateState(state,msg,resid); } } @@ -196,5 +232,4 @@ public class OpenVPN { newlogItem(new LogItem(LogItem.ERROR, ressourceId,args)); } - } diff --git a/src/de/blinkt/openvpn/OpenVPNThread.java b/src/de/blinkt/openvpn/OpenVPNThread.java index 3922e679..1ef04f70 100644 --- a/src/de/blinkt/openvpn/OpenVPNThread.java +++ b/src/de/blinkt/openvpn/OpenVPNThread.java @@ -54,7 +54,7 @@ public class OpenVPNThread implements Runnable { if( exitvalue != 0)
OpenVPN.logError("Process exited with exit value " + exitvalue);
- OpenVPN.updateStateString("NOPROCESS","No process running.");
+ OpenVPN.updateStateString("NOPROCESS","No process running.", R.string.state_noprocess);
if(mDumpPath!=null) {
try {
BufferedWriter logout = new BufferedWriter(new FileWriter(mDumpPath + ".log"));
diff --git a/src/de/blinkt/openvpn/OpenVpnManagementThread.java b/src/de/blinkt/openvpn/OpenVpnManagementThread.java index e2a183b9..c6a4c73e 100644 --- a/src/de/blinkt/openvpn/OpenVpnManagementThread.java +++ b/src/de/blinkt/openvpn/OpenVpnManagementThread.java @@ -220,7 +220,7 @@ public class OpenVpnManagementThread implements Runnable { releaseHoldCmd();
} else {
mWaitingForRelease=true;
- OpenVPN.updateStateString("NONETWORK", "Waiting for usable network");
+ OpenVPN.updateStateString("NONETWORK", "",R.string.state_nonetwork);
}
}
private void releaseHoldCmd() {
@@ -453,7 +453,7 @@ public class OpenVpnManagementThread implements Runnable { private void proccessPWFailed(String needed, String args) {
- OpenVPN.updateStateString("AUTH_FAILED", needed + args);
+ OpenVPN.updateStateString("AUTH_FAILED", needed + args,R.string.state_auth_failed);
}
private void logStatusMessage(String command) {
OpenVPN.logMessage(0,"MGMT:", command);
diff --git a/src/de/blinkt/openvpn/OpenVpnService.java b/src/de/blinkt/openvpn/OpenVpnService.java index dff50e54..908224e5 100644 --- a/src/de/blinkt/openvpn/OpenVpnService.java +++ b/src/de/blinkt/openvpn/OpenVpnService.java @@ -19,7 +19,6 @@ package de.blinkt.openvpn; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.Locale; import java.util.Vector; import android.app.Notification; @@ -431,7 +430,7 @@ public class OpenVpnService extends VpnService implements StateListener { } @Override - public void updateState(String state,String logmessage) { + public void updateState(String state,String logmessage, int resid) { // If the process is not running, ignore any state, // Notification should be invisible in this state if(mProcessThread==null) @@ -454,8 +453,8 @@ public class OpenVpnService extends VpnService implements StateListener { // Other notifications are shown, // This also mean we are no longer connected, ignore bytecount messages until next // CONNECTED - String ticker = state.toLowerCase(Locale.getDefault()); - showNotification(state +" " + logmessage,ticker,false,0); + String ticker = getString(resid); + showNotification(getString(resid) +" " + logmessage,ticker,false,0); } } |