summaryrefslogtreecommitdiff
path: root/src/de/blinkt/openvpn/DisconnectVPN.java
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2013-10-13 18:20:23 +0200
committerArne Schwabe <arne@rfc2549.org>2013-10-13 18:20:23 +0200
commit313775ae54d11aae34d5b7137c70d284afd59acd (patch)
tree863d33d80d66503c7cdba826e7feb9fa6516b0a2 /src/de/blinkt/openvpn/DisconnectVPN.java
parent1295b8f844f914feeeef245229ca166b93ca37cd (diff)
Make disconnect option work again, add compat Logwindow class
Diffstat (limited to 'src/de/blinkt/openvpn/DisconnectVPN.java')
-rw-r--r--src/de/blinkt/openvpn/DisconnectVPN.java80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/de/blinkt/openvpn/DisconnectVPN.java b/src/de/blinkt/openvpn/DisconnectVPN.java
new file mode 100644
index 00000000..0f9e83aa
--- /dev/null
+++ b/src/de/blinkt/openvpn/DisconnectVPN.java
@@ -0,0 +1,80 @@
+package de.blinkt.openvpn;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.*;
+import android.os.IBinder;
+import de.blinkt.openvpn.core.OpenVpnService;
+import de.blinkt.openvpn.core.ProfileManager;
+
+/**
+ * Created by arne on 13.10.13.
+ */
+public class DisconnectVPN extends Activity implements DialogInterface.OnClickListener{
+ protected OpenVpnService mService;
+
+ private ServiceConnection mConnection = new ServiceConnection() {
+
+
+ @Override
+ public void onServiceConnected(ComponentName className,
+ IBinder service) {
+ // We've bound to LocalService, cast the IBinder and get LocalService instance
+ OpenVpnService.LocalBinder binder = (OpenVpnService.LocalBinder) service;
+ mService = binder.getService();
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName arg0) {
+ mService =null;
+ }
+
+ };
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ Intent intent = new Intent(this, OpenVpnService.class);
+ intent.setAction(OpenVpnService.START_SERVICE);
+ bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
+ showDisconnectDialog();
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ unbindService(mConnection);
+ }
+
+ // if (getIntent() !=null && OpenVpnService.DISCONNECT_VPN.equals(getIntent().getAction()))
+
+ // setIntent(null);
+
+ /*
+ @Override
+ protected void onNewIntent(Intent intent) {
+ super.onNewIntent(intent);
+ setIntent(intent);
+ }
+ */
+
+ private void showDisconnectDialog() {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle(R.string.title_cancel);
+ builder.setMessage(R.string.cancel_connection_query);
+ builder.setNegativeButton(android.R.string.no, this);
+ builder.setPositiveButton(android.R.string.yes,this);
+
+ builder.show();
+ }
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if (which == DialogInterface.BUTTON_POSITIVE) {
+ ProfileManager.setConntectedVpnProfileDisconnected(this);
+ if (mService != null && mService.getManagement() != null)
+ mService.getManagement().stopVPN();
+ }
+ finish();
+ }
+}