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-12-10 18:08:21 +0100
commit576bb02d7a087a32863d310363968d304b3af52f (patch)
treecc7e326f83c19eaee33db984427f6978e59a468c /src/se/leap/bitmaskclient/ConfigurationWizard.java
parentb1dacaa6f0131193e04c10327a07f778a67b6d12 (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.java27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/se/leap/bitmaskclient/ConfigurationWizard.java b/src/se/leap/bitmaskclient/ConfigurationWizard.java
index 4a3bb12b..532debfd 100644
--- a/src/se/leap/bitmaskclient/ConfigurationWizard.java
+++ b/src/se/leap/bitmaskclient/ConfigurationWizard.java
@@ -175,13 +175,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) {
@@ -237,8 +238,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
@@ -265,7 +265,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;
}
}
@@ -343,7 +343,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.
@@ -353,18 +353,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) {
@@ -373,7 +374,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
@@ -382,12 +383,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);