summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/values/untranslatable.xml14
-rw-r--r--src/de/blinkt/openvpn/LaunchVPN.java24
-rw-r--r--src/de/blinkt/openvpn/core/OpenVPN.java3
-rw-r--r--src/de/blinkt/openvpn/core/OpenVpnService.java6
4 files changed, 34 insertions, 13 deletions
diff --git a/res/values/untranslatable.xml b/res/values/untranslatable.xml
index 70ca6b7f..1b4fdd9b 100644
--- a/res/values/untranslatable.xml
+++ b/res/values/untranslatable.xml
@@ -19,9 +19,9 @@
<string name="openssl" translatable="false">OpenSSL</string>
<string name="unknown_state" translatable="false">Unknown state</string>
<string name="permission_description">Allows another app to control OpenVPN</string>
- <string name="bouncy_castle" translatable="false">Bouncy Castle Crypto APIs</string>
- <string name="copyright_bouncycastle" translatable="false">Copyright © 2000–2012 The Legion Of The Bouncy Castle (http://www.bouncycastle.org)</string>
-
+ <string name="bouncy_castle" translatable="false">Bouncy Castle Crypto APIs</string>
+ <string name="copyright_bouncycastle" translatable="false">Copyright © 2000–2012 The Legion Of The Bouncy Castle (http://www.bouncycastle.org)</string>
+
<string-array name="tls_directions_values" translatable="false">
<item>0</item>
<item>1</item>
@@ -43,4 +43,10 @@
<item>-1</item>
</string-array>
-</resources>
+ <!-- These strings should not be visible to the user -->
+ <string name="state_user_vpn_permission" translatable="false">Waiting for user permission to use VPN API</string>
+ <string name="state_user_vpn_password" translatable="false">Waiting for user VPN password</string>
+ <string name="state_user_vpn_password_cancelled" translatable="false">VPN password input dialog cancelled</string>
+ <string name="state_user_vpn_permission_cancelled" translatable="false">VPN API permission dialog cancelled</string>
+
+</resources> \ No newline at end of file
diff --git a/src/de/blinkt/openvpn/LaunchVPN.java b/src/de/blinkt/openvpn/LaunchVPN.java
index f07a77b9..80075086 100644
--- a/src/de/blinkt/openvpn/LaunchVPN.java
+++ b/src/de/blinkt/openvpn/LaunchVPN.java
@@ -26,6 +26,7 @@ import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import de.blinkt.openvpn.core.OpenVPN;
+import de.blinkt.openvpn.core.OpenVPN.ConnectionStatus;
import de.blinkt.openvpn.core.ProfileManager;
import de.blinkt.openvpn.core.VPNLaunchHelper;
@@ -61,7 +62,7 @@ public class LaunchVPN extends ListActivity implements OnItemClickListener {
public static final String EXTRA_HIDELOG = "de.blinkt.openvpn.showNoLogWindow";;
private static final int START_VPN_PROFILE= 70;
-
+
private ProfileManager mPM;
private VpnProfile mSelectedProfile;
@@ -74,7 +75,7 @@ public class LaunchVPN extends ListActivity implements OnItemClickListener {
super.onCreate(icicle);
mPM =ProfileManager.getInstance(this);
-
+
}
@Override
@@ -84,10 +85,10 @@ public class LaunchVPN extends ListActivity implements OnItemClickListener {
final Intent intent = getIntent();
final String action = intent.getAction();
-
+
// If the intent is a request to create a shortcut, we'll do that and exit
-
+
if(Intent.ACTION_MAIN.equals(action)) {
// we got called to be the starting point, most likely a shortcut
String shortcutUUID = intent.getStringExtra( EXTRA_KEY);
@@ -201,7 +202,7 @@ public class LaunchVPN extends ListActivity implements OnItemClickListener {
}
-
+
private void askForPW(final int type) {
@@ -234,6 +235,8 @@ public class LaunchVPN extends ListActivity implements OnItemClickListener {
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
+ OpenVPN.updateStateString("USER_VPN_PASSWORD_CANCELLED", "", R.string.state_user_vpn_password_cancelled,
+ ConnectionStatus.LEVEL_NOTCONNECTED);
finish();
}
});
@@ -242,24 +245,29 @@ public class LaunchVPN extends ListActivity implements OnItemClickListener {
}
@Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ protected void onActivityResult (int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==START_VPN_PROFILE) {
if(resultCode == Activity.RESULT_OK) {
int needpw = mSelectedProfile.needUserPWInput();
if(needpw !=0) {
+ OpenVPN.updateStateString("USER_VPN_PASSWORD", "", R.string.state_user_vpn_password,
+ ConnectionStatus.LEVEL_WAITING_FOR_USER_INPUT);
askForPW(needpw);
} else {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean showlogwindow = prefs.getBoolean("showlogwindow", true);
-
+
if(!mhideLog && showlogwindow)
showLogWindow();
new startOpenVpnThread().start();
}
} else if (resultCode == Activity.RESULT_CANCELED) {
// User does not want us to start, so we just vanish
+ OpenVPN.updateStateString("USER_VPN_PERMISSION_CANCELLED", "", R.string.state_user_vpn_permission_cancelled,
+ ConnectionStatus.LEVEL_NOTCONNECTED);
+
finish();
}
}
@@ -309,6 +317,8 @@ public class LaunchVPN extends ListActivity implements OnItemClickListener {
if (intent != null) {
+ OpenVPN.updateStateString("USER_VPN_PERMISSION", "", R.string.state_user_vpn_password,
+ ConnectionStatus.LEVEL_WAITING_FOR_USER_INPUT);
// Start the query
try {
startActivityForResult(intent, START_VPN_PROFILE);
diff --git a/src/de/blinkt/openvpn/core/OpenVPN.java b/src/de/blinkt/openvpn/core/OpenVPN.java
index 2bc4cf6b..982a1e62 100644
--- a/src/de/blinkt/openvpn/core/OpenVPN.java
+++ b/src/de/blinkt/openvpn/core/OpenVPN.java
@@ -44,7 +44,8 @@ public class OpenVPN {
public enum ConnectionStatus {
LEVEL_NONETWORK (3),
LEVEL_NOTCONNECTED (4),
- LEVEL_AUTH_FAILED ( 5),
+ LEVEL_AUTH_FAILED (5),
+ LEVEL_WAITING_FOR_USER_INPUT (6),
LEVEL_CONNECTING_SERVER_REPLIED ( 1),
LEVEL_CONNECTING_NO_SERVER_REPLY_YET (2),
LEVEL_CONNECTED (0), UNKNOWN_LEVEL(-1);
diff --git a/src/de/blinkt/openvpn/core/OpenVpnService.java b/src/de/blinkt/openvpn/core/OpenVpnService.java
index 4dba80f1..d86ae92b 100644
--- a/src/de/blinkt/openvpn/core/OpenVpnService.java
+++ b/src/de/blinkt/openvpn/core/OpenVpnService.java
@@ -541,7 +541,11 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
// Display byte count only after being connected
{
- if(level == ConnectionStatus.LEVEL_CONNECTED) {
+ if (level == ConnectionStatus.LEVEL_WAITING_FOR_USER_INPUT) {
+ // The user is presented a dialog of some kind, no need to inform the user
+ // with a notifcation
+ return;
+ } else if(level == ConnectionStatus.LEVEL_CONNECTED) {
mDisplayBytecount = true;
mConnecttime = System.currentTimeMillis();
} else {