summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/Provider.java
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2014-12-04 00:46:25 +0100
committerParménides GV <parmegv@sdf.org>2014-12-04 00:46:25 +0100
commit6c79290b1783a303fad5ea8be3c3583cc79dad84 (patch)
tree7976e93ed94efe96ef86dcc1a128c660fb927af5 /app/src/main/java/se/leap/bitmaskclient/Provider.java
parentd67d127aa9691fbad10f93294c6b0b7e45406ed8 (diff)
Learning to use Butterknife, refactoring small things.
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/Provider.java')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/Provider.java66
1 files changed, 16 insertions, 50 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/Provider.java b/app/src/main/java/se/leap/bitmaskclient/Provider.java
index fa1a4fb5..bb30905c 100644
--- a/app/src/main/java/se/leap/bitmaskclient/Provider.java
+++ b/app/src/main/java/se/leap/bitmaskclient/Provider.java
@@ -110,11 +110,10 @@ public final class Provider implements Serializable {
}
protected String getDomain(){
- String domain = "Null";
+ String domain = "";
try {
domain = definition.getString(API_TERM_DOMAIN);
} catch (JSONException e) {
- domain = "Null";
e.printStackTrace();
}
return domain;
@@ -157,58 +156,25 @@ public final class Provider implements Serializable {
}
protected boolean hasEIP() {
- JSONArray services = null;
try {
- services = definition.getJSONArray(API_TERM_SERVICES); // returns ["openvpn"]
+ JSONArray services = definition.getJSONArray(API_TERM_SERVICES); // returns ["openvpn"]
+ for (int i=0;i<API_EIP_TYPES.length+1;i++){
+ try {
+ // Walk the EIP types array looking for matches in provider's service definitions
+ if ( Arrays.asList(API_EIP_TYPES).contains( services.getString(i) ) )
+ return true;
+ } catch (NullPointerException e){
+ e.printStackTrace();
+ return false;
+ } catch (JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return false;
+ }
+ }
} catch (Exception e) {
// TODO: handle exception
}
- for (int i=0;i<API_EIP_TYPES.length+1;i++){
- try {
- // Walk the EIP types array looking for matches in provider's service definitions
- if ( Arrays.asList(API_EIP_TYPES).contains( services.getString(i) ) )
- return true;
- } catch (NullPointerException e){
- e.printStackTrace();
- return false;
- } catch (JSONException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- return false;
- }
- }
return false;
}
-
- protected String getEIPType() {
- // FIXME!!!!! We won't always be providing /only/ OpenVPN, will we?
- // This will have to hook into some saved choice of EIP transport
- if ( instance.hasEIP() )
- return "OpenVPN";
- else
- return null;
- }
-
- protected JSONObject getEIP() {
- // FIXME!!!!! We won't always be providing /only/ OpenVPN, will we?
- // This will have to hook into some saved choice of EIP transport, cluster, gateway
- // with possible "choose at random" preference
- if ( instance.hasEIP() ){
- // TODO Might need an EIP class, but we've only got OpenVPN type right now,
- // and only one gateway for our only provider...
- // TODO We'll try to load from preferences, have to call ProviderAPI if we've got nothin...
- JSONObject eipObject = null;
- try {
- eipObject = new JSONObject( preferences.getString(PREFS_EIP_NAME, "") );
- } catch (JSONException e) {
- // TODO ConfigHelper.rescueJSON()
- // Still nothing?
- // TODO ProviderAPI.getEIP()
- e.printStackTrace();
- }
-
- return eipObject;
- } else
- return null;
- }
}