summaryrefslogtreecommitdiff
path: root/src/se/leap/leapclient/EIP.java
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2013-07-20 00:39:10 +0200
committerParménides GV <parmegv@sdf.org>2013-07-20 00:39:10 +0200
commit3d652a20b5c28b0a424d516161034b23b2523d95 (patch)
tree0368ca6f91ebbd55f2aaaf56eee0d70beaccb861 /src/se/leap/leapclient/EIP.java
parentc7f73c9ef8f64351d4e462106a2ab5d216810684 (diff)
parentf0c42391501aa646c5d65df5e19dbbd36b19b970 (diff)
Merge branch 'feature/eip-control-ux' into develop
Diffstat (limited to 'src/se/leap/leapclient/EIP.java')
-rw-r--r--src/se/leap/leapclient/EIP.java21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/se/leap/leapclient/EIP.java b/src/se/leap/leapclient/EIP.java
index b86a2a4a..5057732e 100644
--- a/src/se/leap/leapclient/EIP.java
+++ b/src/se/leap/leapclient/EIP.java
@@ -54,6 +54,7 @@ public final class EIP extends IntentService {
// Used to store actions to "resume" onServiceConnection
private static String mPending = null;
+ private static int parsedEipSerial;
private static JSONObject eipDefinition = null;
private static OVPNGateway activeGateway = null;
@@ -70,6 +71,7 @@ public final class EIP extends IntentService {
try {
eipDefinition = ConfigHelper.getJsonFromSharedPref(ConfigHelper.EIP_SERVICE_KEY);
+ parsedEipSerial = ConfigHelper.getIntFromSharedPref(ConfigHelper.EIP_PARSED_SERIAL);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -224,7 +226,8 @@ public final class EIP extends IntentService {
// TODO Auto-generated catch block
e.printStackTrace();
}
- updateGateways();
+ if (eipDefinition.optInt("serial") > parsedEipSerial)
+ updateGateways();
}
/**
@@ -274,6 +277,8 @@ public final class EIP extends IntentService {
e.printStackTrace();
}
}
+
+ ConfigHelper.saveSharedPref(ConfigHelper.EIP_PARSED_SERIAL, eipDefinition.optInt(ConfigHelper.API_RETURN_SERIAL_KEY));
}
/**
@@ -287,6 +292,7 @@ public final class EIP extends IntentService {
private String TAG = "OVPNGateway";
+ private String mName;
private VpnProfile mVpnProfile;
private JSONObject mGateway;
private HashMap<String,Vector<Vector<String>>> options = new HashMap<String, Vector<Vector<String>>>();
@@ -299,17 +305,24 @@ public final class EIP extends IntentService {
* @param name The hostname of the gateway to inflate
*/
private OVPNGateway(String name){
+ mName = name;
+
+ this.loadVpnProfile();
+ }
+
+ private void loadVpnProfile() {
ProfileManager vpl = ProfileManager.getInstance(context);
try {
- if ( name == "first" ) {
- name = vpl.getProfiles().iterator().next().mName;
+ if ( mName == "first" ) {
+ mName = vpl.getProfiles().iterator().next().mName;
}
- mVpnProfile = vpl.getProfileByName(name);
+ mVpnProfile = vpl.getProfileByName(mName);
} catch (NoSuchElementException e) {
updateEIPService();
+ this.loadVpnProfile(); // FIXME catch infinite loops
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();