summaryrefslogtreecommitdiff
path: root/src/se/leap/bitmaskclient/EIP.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/se/leap/bitmaskclient/EIP.java')
-rw-r--r--src/se/leap/bitmaskclient/EIP.java35
1 files changed, 31 insertions, 4 deletions
diff --git a/src/se/leap/bitmaskclient/EIP.java b/src/se/leap/bitmaskclient/EIP.java
index f9384ff6..edd73e83 100644
--- a/src/se/leap/bitmaskclient/EIP.java
+++ b/src/se/leap/bitmaskclient/EIP.java
@@ -214,8 +214,7 @@ public final class EIP extends IntentService {
* Intent to {@link se.leap.openvpn.LaunchVPN}
*/
private void startEIP() {
- if (activeGateway==null)
- activeGateway = selectGateway();
+ activeGateway = selectGateway();
Intent intent = new Intent(this,LaunchVPN.class);
intent.setAction(Intent.ACTION_MAIN);
@@ -252,10 +251,19 @@ public final class EIP extends IntentService {
private void updateEIPService() {
try {
eipDefinition = ConfigHelper.getJsonFromSharedPref(EIP.KEY);
+ parsedEipSerial = ConfigHelper.getIntFromSharedPref(PARSED_SERIAL);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
+ if(parsedEipSerial == 0) {
+ // Delete all vpn profiles
+ ProfileManager vpl = ProfileManager.getInstance(context);
+ Collection<VpnProfile> profiles = vpl.getProfiles();
+ for (VpnProfile profile : profiles){
+ vpl.removeProfile(context, profile);
+ }
+ }
if (eipDefinition.optInt("serial") > parsedEipSerial)
updateGateways();
}
@@ -431,6 +439,8 @@ public final class EIP extends IntentService {
String ports = "ports";
String protos = "protocols";
String capabilities = "capabilities";
+ String location_key = "location";
+ String locations = "locations";
Vector<String> arg = new Vector<String>();
Vector<Vector<String>> args = new Vector<Vector<String>>();
@@ -447,7 +457,6 @@ public final class EIP extends IntentService {
arg.add(word);
value.add( (Vector<String>) arg.clone() );
options.put(key, (Vector<Vector<String>>) value.clone());
-
value.clear();
arg.clear();
}
@@ -457,7 +466,7 @@ public final class EIP extends IntentService {
}
try {
- arg.add("remote");
+ arg.add(remote);
arg.add(mGateway.getString(remote));
} catch (JSONException e) {
// TODO Auto-generated catch block
@@ -467,7 +476,25 @@ public final class EIP extends IntentService {
options.put("remote", (Vector<Vector<String>>) args.clone() );
arg.clear();
args.clear();
+
+
+ try {
+
+ arg.add(location_key);
+ String locationText = "";
+ locationText = eipDefinition.getJSONObject(locations).getJSONObject(mGateway.getString(location_key)).getString("name");
+ arg.add(locationText);
+
+ } catch (JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ args.add((Vector<String>) arg.clone());
+ options.put("location", (Vector<Vector<String>>) args.clone() );
+
+ arg.clear();
+ args.clear();
JSONArray protocolsJSON = null;
arg.add("proto");
try {