Menu option added to reload cached CA certificates
authorTobias Brunner <tobias@strongswan.org>
Tue, 7 Aug 2012 12:02:38 +0000 (14:02 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 13 Aug 2012 09:00:25 +0000 (11:00 +0200)
This might be required if the user installs a new CA certificate.

src/frontends/android/res/menu/main.xml [new file with mode: 0644]
src/frontends/android/res/values/strings.xml
src/frontends/android/src/org/strongswan/android/ui/MainActivity.java

diff --git a/src/frontends/android/res/menu/main.xml b/src/frontends/android/res/menu/main.xml
new file mode 100644 (file)
index 0000000..f5d1e31
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+    Copyright (C) 2012 Tobias Brunner
+    Hochschule fuer Technik Rapperswil
+
+    This program is free software; you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by the
+    Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+
+    This program is distributed in the hope that it will be useful, but
+    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+-->
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <item
+        android:id="@+id/menu_reload_certs"
+        android:title="@string/reload_trusted_certs"
+        android:showAsAction="withText" />
+
+</menu>
\ No newline at end of file
index 53a94bb..761b16a 100644 (file)
@@ -19,6 +19,7 @@
 
     <!-- Application -->
     <string name="app_name">strongSwan VPN Client</string>
+    <string name="reload_trusted_certs">Reload CA certificates</string>
 
     <!-- VPN profile list -->
     <string name="no_profiles">No VPN profiles.</string>
index 063d7a9..6a29889 100644 (file)
@@ -17,6 +17,7 @@
 
 package org.strongswan.android.ui;
 
+import org.strongswan.android.R;
 import org.strongswan.android.logic.TrustedCertificateManager;
 
 import android.app.ActionBar;
@@ -24,6 +25,9 @@ import android.app.Activity;
 import android.content.Intent;
 import android.net.VpnService;
 import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
 import android.view.Window;
 
 public class MainActivity extends Activity
@@ -57,7 +61,42 @@ public class MainActivity extends Activity
                }).start();
        }
 
-       private void startVpnService()
+       @Override
+       public boolean onCreateOptionsMenu(Menu menu)
+       {
+               MenuInflater inflater = getMenuInflater();
+               inflater.inflate(R.menu.main, menu);
+               return true;
+       }
+
+       @Override
+       public boolean onOptionsItemSelected(MenuItem item)
+       {
+               switch (item.getItemId())
+               {
+                       case R.id.menu_reload_certs:
+                               setProgressBarIndeterminateVisibility(true);
+                               new Thread(new Runnable() {
+                                       @Override
+                                       public void run()
+                                       {
+                                               TrustedCertificateManager.getInstance().reload();
+                                               runOnUiThread(new Runnable() {
+                                                       @Override
+                                                       public void run()
+                                                       {
+                                                               setProgressBarIndeterminateVisibility(false);
+                                                       }
+                                               });
+                                       }
+                               }).start();
+                               return true;
+                       default:
+                               return super.onOptionsItemSelected(item);
+               }
+       }
+
+       protected void prepareVpnService()
        {
                Intent intent = VpnService.prepare(this);
                if (intent != null)