summaryrefslogtreecommitdiff
path: root/src/de/blinkt/openvpn/ProfileManager.java
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2012-05-04 00:28:52 +0200
committerArne Schwabe <arne@rfc2549.org>2012-05-04 00:28:52 +0200
commit7bfd830078268c010fdc65ccb2ef4980bf6c8e4d (patch)
tree119750363771382ea684ed0f8cff6ac7c767ca1b /src/de/blinkt/openvpn/ProfileManager.java
parent2b3ea917b0a830e3ff4817c7240e0f1808ae58bc (diff)
Get vpn list working again, not yet perfect but at least delete works
http://code.google.com/p/android/issues/detail?id=3414 is hunting me :(
Diffstat (limited to 'src/de/blinkt/openvpn/ProfileManager.java')
-rw-r--r--src/de/blinkt/openvpn/ProfileManager.java31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/de/blinkt/openvpn/ProfileManager.java b/src/de/blinkt/openvpn/ProfileManager.java
index 9e5b1602..f8193003 100644
--- a/src/de/blinkt/openvpn/ProfileManager.java
+++ b/src/de/blinkt/openvpn/ProfileManager.java
@@ -24,20 +24,25 @@ public class ProfileManager {
private HashMap<String,VpnProfile> profiles=new HashMap<String, VpnProfile>();
public static VpnProfile get(String key) {
- checkInstance();
+ if(instance==null)
+ return null;
return instance.profiles.get(key);
}
+
+
private ProfileManager() { }
- private static void checkInstance() {
- if(instance == null)
+ private static void checkInstance(Context context) {
+ if(instance == null) {
instance = new ProfileManager();
+ instance.loadVPNList(context);
+ }
}
- public static ProfileManager getInstance() {
- checkInstance();
+ public static ProfileManager getInstance(Context context) {
+ checkInstance(context);
return instance;
}
@@ -56,8 +61,8 @@ public class ProfileManager {
return null;
}
- public void saveProfileList(Activity activity) {
- SharedPreferences sharedprefs = activity.getSharedPreferences(PREFS_NAME,Activity.MODE_PRIVATE);
+ public void saveProfileList(Context context) {
+ SharedPreferences sharedprefs = context.getSharedPreferences(PREFS_NAME,Activity.MODE_PRIVATE);
Editor editor = sharedprefs.edit();
editor.putStringSet("vpnlist", profiles.keySet());
editor.commit();
@@ -89,7 +94,7 @@ public class ProfileManager {
}
- void loadVPNList(Context context) {
+ private void loadVPNList(Context context) {
profiles = new HashMap<String, VpnProfile>();
SharedPreferences settings =context.getSharedPreferences(PREFS_NAME,Activity.MODE_PRIVATE);
Set<String> vlist = settings.getStringSet("vpnlist", null);
@@ -120,4 +125,14 @@ public class ProfileManager {
return profiles.size();
}
+
+
+ public void removeProfile(Context context,VpnProfile profile) {
+ String vpnentry = profile.getUUID().toString();
+ profiles.remove(vpnentry);
+ saveProfileList(context);
+ context.deleteFile(vpnentry + ".vp");
+
+ }
+
}