From d378e3b493737c5283b29e8c49d8c2b289c891fa Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Mon, 31 Dec 2012 20:41:28 +0100 Subject: Cleanups --- src/de/blinkt/openvpn/OpenVPN.java | 6 +++--- src/de/blinkt/openvpn/OpenVpnManagementThread.java | 12 +++++++++++- src/de/blinkt/openvpn/OpenVpnService.java | 17 +++++++++-------- 3 files changed, 23 insertions(+), 12 deletions(-) (limited to 'src/de/blinkt') diff --git a/src/de/blinkt/openvpn/OpenVPN.java b/src/de/blinkt/openvpn/OpenVPN.java index 2d7b7db6..e11d254f 100644 --- a/src/de/blinkt/openvpn/OpenVPN.java +++ b/src/de/blinkt/openvpn/OpenVPN.java @@ -26,7 +26,7 @@ public class OpenVPN { logInformation(); } - static class LogItem { + public static class LogItem { public static final int ERROR = 1; public static final int INFO = 2; public static final int VERBOSE = 3; @@ -116,11 +116,11 @@ public class OpenVPN { logInfo(R.string.mobile_info,Build.MODEL, Build.BOARD,Build.BRAND,Build.VERSION.SDK_INT); } - synchronized static void addLogListener(LogListener ll){ + public synchronized static void addLogListener(LogListener ll){ logListener.add(ll); } - synchronized static void removeLogListener(LogListener ll) { + public synchronized static void removeLogListener(LogListener ll) { logListener.remove(ll); } diff --git a/src/de/blinkt/openvpn/OpenVpnManagementThread.java b/src/de/blinkt/openvpn/OpenVpnManagementThread.java index ee458200..e2a183b9 100644 --- a/src/de/blinkt/openvpn/OpenVpnManagementThread.java +++ b/src/de/blinkt/openvpn/OpenVpnManagementThread.java @@ -411,13 +411,20 @@ public class OpenVpnManagementThread implements Runnable { private void processPWCommand(String argument) { //argument has the form Need 'Private Key' password - + // or ">PASSWORD:Verification Failed: '%s' ['%s']" String needed; + + + try{ int p1 = argument.indexOf('\''); int p2 = argument.indexOf('\'',p1+1); needed = argument.substring(p1+1, p2); + if (argument.startsWith("Verification Failed")) { + proccessPWFailed(needed, argument.substring(p2+1)); + return; + } } catch (StringIndexOutOfBoundsException sioob) { OpenVPN.logMessage(0, "", "Could not parse management Password command: " + argument); return; @@ -445,6 +452,9 @@ public class OpenVpnManagementThread implements Runnable { + private void proccessPWFailed(String needed, String args) { + OpenVPN.updateStateString("AUTH_FAILED", needed + args); + } 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 f4550c13..dff50e54 100644 --- a/src/de/blinkt/openvpn/OpenVpnService.java +++ b/src/de/blinkt/openvpn/OpenVpnService.java @@ -94,7 +94,7 @@ public class OpenVpnService extends VpnService implements StateListener { int icon = R.drawable.ic_stat_vpn; android.app.Notification.Builder nbuilder = new Notification.Builder(this); - nbuilder.setContentTitle("OpenVPN - " + mProfile.mName); + nbuilder.setContentTitle(getString(R.string.notifcation_title,mProfile.mName)); nbuilder.setContentText(msg); nbuilder.setOnlyAlertOnce(true); nbuilder.setOngoing(true); @@ -124,9 +124,9 @@ public class OpenVpnService extends VpnService implements StateListener { Method setpriority = nbuilder.getClass().getMethod("setPriority", int.class); // PRIORITY_MIN == -2 setpriority.invoke(nbuilder, -2 ); - -/* PendingIntent cancelconnet=null; - + + /* PendingIntent cancelconnet=null; + nbuilder.addAction(android.R.drawable.ic_menu_close_clear_cancel, getString(R.string.cancel_connection),cancelconnet); */ } @@ -325,10 +325,11 @@ public class OpenVpnService extends VpnService implements StateListener { bconfig[5] = getString(R.string.routes_info6, joinString(mRoutesv6)); String session = mProfile.mName; - if(mLocalIP!=null) - session+= " - " + mLocalIP; - if(mLocalIPv6!=null) - session+= " - " + mLocalIPv6; + if(mLocalIP!=null && mLocalIPv6!=null) + session = getString(R.string.session_ipv6string,session, mLocalIP, mLocalIPv6); + else if (mLocalIP !=null) + session= getString(R.string.session_ipv4string, session, mLocalIP); + builder.setSession(session); -- cgit v1.2.3