summaryrefslogtreecommitdiff
path: root/src/se/leap/bitmaskclient/ProviderAPI.java
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2013-10-14 17:05:06 +0200
committerParménides GV <parmegv@sdf.org>2013-11-19 17:58:22 +0100
commita5d29e68e49576ebb71c3c887fba39a367730b58 (patch)
tree1dab2d163e0e0f77ef407dbcfe29661a8edce4ae /src/se/leap/bitmaskclient/ProviderAPI.java
parent61f48737a2a96304f7ab043e6a513204261bb860 (diff)
ProviderAPI broadcasts progress to CW.
Setting up a provider makes the progressbar move according to the number of files downloaded (1/3, 2/3, 3/3). Next step: recover from download errors individually. That means that if a download fails but the others went OK, the user will be prompted to retry that individual failing download.
Diffstat (limited to 'src/se/leap/bitmaskclient/ProviderAPI.java')
-rw-r--r--src/se/leap/bitmaskclient/ProviderAPI.java38
1 files changed, 9 insertions, 29 deletions
diff --git a/src/se/leap/bitmaskclient/ProviderAPI.java b/src/se/leap/bitmaskclient/ProviderAPI.java
index 60ed1e1f..27081df2 100644
--- a/src/se/leap/bitmaskclient/ProviderAPI.java
+++ b/src/se/leap/bitmaskclient/ProviderAPI.java
@@ -97,8 +97,8 @@ public class ProviderAPI extends IntentService {
SESSION_ID_COOKIE_KEY = "session_id_cookie_key",
SESSION_ID_KEY = "session_id",
ERRORS = "errors",
- UPDATE_ACTION = "update_action",
- UPDATE_DATA = "update data",
+ UPDATE_PROGRESSBAR = "update_action",
+ CURRENT_PROGRESS = "update data",
TAG = "provider_api_tag"
;
@@ -266,9 +266,9 @@ public class ProviderAPI extends IntentService {
*/
private void broadcast_progress(int progress) {
Intent intentUpdate = new Intent();
- intentUpdate.setAction(UPDATE_ACTION);
+ intentUpdate.setAction(UPDATE_PROGRESSBAR);
intentUpdate.addCategory(Intent.CATEGORY_DEFAULT);
- intentUpdate.putExtra(UPDATE_DATA, progress);
+ intentUpdate.putExtra(CURRENT_PROGRESS, progress);
sendBroadcast(intentUpdate);
}
@@ -421,38 +421,18 @@ public class ProviderAPI extends IntentService {
*/
private Bundle setUpProvider(Bundle task) {
Bundle result = new Bundle();
+ int progress = 0;
boolean danger_on = task.getBoolean(ProviderItem.DANGER_ON);
String provider_main_url = task.getString(Provider.MAIN_URL);
if(downloadCACert(provider_main_url, danger_on)) {
+ broadcast_progress(progress++);
result.putBoolean(RESULT_KEY, true);
- if(getAndSetProviderJson(provider_main_url))
+ if(getAndSetProviderJson(provider_main_url)) {
+ broadcast_progress(progress++);
if(getAndSetEipServiceJson())
- ;
- }
- /*
- try {
- String provider_dot_json_string = downloadWithCommercialCA(provider_json_url, danger_on);
- if(provider_dot_json_string.isEmpty()) {
- result.putBoolean(RESULT_KEY, false);
- } else {
- JSONObject provider_json = new JSONObject(provider_dot_json_string);
- if(provider_json.has(ERRORS)) {
- String reason_to_fail = provider_json.getString(ERRORS);
- result.putString(ERRORS, reason_to_fail);
- result.putBoolean(RESULT_KEY, false);
- } else {
- ConfigHelper.saveSharedPref(EIP.ALLOWED_ANON, provider_json.getJSONObject(Provider.SERVICE).getBoolean(EIP.ALLOWED_ANON));
-
- result.putString(Provider.NAME, added_provider.name());
- result.putBoolean(RESULT_KEY, true);
- result.putString(Provider.KEY, provider_json.toString());
- result.putBoolean(ProviderItem.DANGER_ON, danger_on);
+ broadcast_progress(progress++);
}
- } catch (JSONException e) {
- result.putBoolean(RESULT_KEY, false);
- result.putString(ERRORS, "Corrupt download");
}
- */
return result;
}