summaryrefslogtreecommitdiff
path: root/src/se/leap/bitmaskclient/ConfigurationWizard.java
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2013-09-06 12:54:24 +0200
committerParménides GV <parmegv@sdf.org>2013-11-19 17:43:20 +0100
commitc88555a1f3844fe4d5c69496e4a7f4aa966e4b3b (patch)
treeacea11db3dcd0d6f820cee1e1f71c5c5e684a592 /src/se/leap/bitmaskclient/ConfigurationWizard.java
parentecd01db4ca5c0000d671e888ebdf97c3fdbd51cc (diff)
Removing unnecessary fields from ProviderItem.
I'm targeting to refactor the whole ProviderItem class because I've not used the Provider class so far and I should not duplicate information from "Provider" into "ProviderItem".
Diffstat (limited to 'src/se/leap/bitmaskclient/ConfigurationWizard.java')
-rw-r--r--src/se/leap/bitmaskclient/ConfigurationWizard.java26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/se/leap/bitmaskclient/ConfigurationWizard.java b/src/se/leap/bitmaskclient/ConfigurationWizard.java
index 28a8a44a..389f7b49 100644
--- a/src/se/leap/bitmaskclient/ConfigurationWizard.java
+++ b/src/se/leap/bitmaskclient/ConfigurationWizard.java
@@ -174,13 +174,14 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
//Toast.makeText(this, getResources().getString(R.string.config_error_parsing), Toast.LENGTH_LONG);
setResult(RESULT_CANCELED, mConfigState);
}
- }
+ }
else if(resultCode == ProviderAPI.INCORRECTLY_UPDATED_PROVIDER_DOT_JSON) {
String reason_to_fail = resultData.getString(ProviderAPI.ERRORS);
showDownloadFailedDialog(getCurrentFocus(), reason_to_fail);
refreshProviderList(0);
mProgressBar.setVisibility(ProgressBar.GONE);
progressbar_description.setVisibility(TextView.GONE);
+ ConfigHelper.removeFromSharedPref(Provider.KEY);
setResult(RESULT_CANCELED, mConfigState);
}
else if(resultCode == ProviderAPI.CORRECTLY_DOWNLOADED_JSON_FILES) {
@@ -235,7 +236,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
int provider_index = getProviderIndex(id);
startProgressBar(provider_index);
mSelectedProvider = selected_provider;
- saveProviderJson(mSelectedProvider);
+ updateProviderDotJson(mSelectedProvider.name(), mSelectedProvider.providerJsonUrl(), mSelectedProvider.completelyTrusted());
}
@Override
@@ -262,7 +263,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
Iterator<ProviderItem> providers_iterator = ProviderListContent.ITEMS.iterator();
while(providers_iterator.hasNext()) {
ProviderItem provider = providers_iterator.next();
- if(provider.id.equalsIgnoreCase(id)) {
+ if(provider.name().equalsIgnoreCase(id)) {
return provider;
}
}
@@ -340,7 +341,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
return loaded_preseeded_providers;
}
- /**
+ /**
* Saves provider.json file associated with provider.
*
* If the provider is custom, the file has already been downloaded so we load it from memory.
@@ -350,18 +351,19 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
private void saveProviderJson(ProviderItem provider) {
JSONObject provider_json = new JSONObject();
try {
- if(!provider.custom) {
- updateProviderDotJson(provider.name, provider.provider_json_url, provider.danger_on);
+ if(!provider.custom()) {
+ updateProviderDotJson(mSelectedProvider.name(), provider.providerJsonUrl(), provider.completelyTrusted());
} else {
// FIXME!! We should we be updating our seeded providers list at ConfigurationWizard onStart() ?
// I think yes, but if so, where does this list live? leap.se, as it's the non-profit project for the software?
// If not, we should just be getting names/urls, and fetching the provider.json like in custom entries
- provider_json = provider.provider_json;
+ provider_json = ConfigHelper.getJsonFromSharedPref(Provider.KEY);
ConfigHelper.saveSharedPref(Provider.KEY, provider_json);
ConfigHelper.saveSharedPref(EIP.ALLOWED_ANON, provider_json.getJSONObject(Provider.SERVICE).getBoolean(EIP.ALLOWED_ANON));
- ConfigHelper.saveSharedPref(ProviderItem.DANGER_ON, provider.danger_on);
+ ConfigHelper.saveSharedPref(ProviderItem.DANGER_ON, provider.completelyTrusted());
mProgressBar.incrementProgressBy(1);
+
downloadJSONFiles(mSelectedProvider);
}
} catch (JSONException e) {
@@ -370,7 +372,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
}
}
- /**
+ /**
* Asks ProviderAPI to download provider site's certificate and eip-service.json
*
* URLs are fetched from the provider parameter
@@ -379,12 +381,12 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
private void downloadJSONFiles(ProviderItem provider) {
Intent provider_API_command = new Intent(this, ProviderAPI.class);
- Bundle parameters = new Bundle();
+ Bundle parameters = new Bundle();
- parameters.putString(Provider.KEY, provider.name);
+ parameters.putString(Provider.KEY, provider.name());
parameters.putString(Provider.CA_CERT, provider.cert_json_url);
parameters.putString(EIP.KEY, provider.eip_service_json_url);
- parameters.putBoolean(ProviderItem.DANGER_ON, provider.danger_on);
+ parameters.putBoolean(ProviderItem.DANGER_ON, provider.completelyTrusted());
provider_API_command.setAction(ProviderAPI.DOWNLOAD_JSON_FILES_BUNDLE_EXTRA);
provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters);