summaryrefslogtreecommitdiff
path: root/src/se
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2013-10-22 17:43:28 +0200
committerParménides GV <parmegv@sdf.org>2013-12-10 18:14:18 +0100
commite89dc12bb93da0a638d9a199af4d91a54aa3556e (patch)
tree4601b386e9045260e67c8d2b82d7e264bae79d76 /src/se
parent4460a3cb0dfe10a32ce6697047c7331536233d91 (diff)
Save my work until now
Diffstat (limited to 'src/se')
-rw-r--r--src/se/leap/bitmaskclient/ConfigurationWizard.java12
-rw-r--r--src/se/leap/bitmaskclient/Dashboard.java3
-rw-r--r--src/se/leap/bitmaskclient/ProviderAPI.java70
-rw-r--r--src/se/leap/bitmaskclient/ProviderListFragment.java1
4 files changed, 50 insertions, 36 deletions
diff --git a/src/se/leap/bitmaskclient/ConfigurationWizard.java b/src/se/leap/bitmaskclient/ConfigurationWizard.java
index a4d8599f..0cdd4561 100644
--- a/src/se/leap/bitmaskclient/ConfigurationWizard.java
+++ b/src/se/leap/bitmaskclient/ConfigurationWizard.java
@@ -189,7 +189,8 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
// resetOldConnection();
ProviderItem selected_provider = getProvider(id);
int provider_index = getProviderIndex(id);
- startProgressBar(provider_index);
+
+ startProgressBar(provider_index+1);
provider_list_fragment.hideAllBut(provider_index);
setUpProvider(selected_provider.providerMainUrl(), true);
}
@@ -236,6 +237,12 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
return "";
}
+ private void startProgressBar() {
+ mProgressBar.setVisibility(ProgressBar.VISIBLE);
+ mProgressBar.setProgress(0);
+ mProgressBar.setMax(3);
+ }
+
private void startProgressBar(int list_item_index) {
mProgressBar.setVisibility(ProgressBar.VISIBLE);
progressbar_description.setVisibility(TextView.VISIBLE);
@@ -253,8 +260,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
ProviderItem provider = providers_iterator.next();
if(provider.name().equalsIgnoreCase(id)) {
break;
- }
- index++;
+ } else index++;
}
return index;
}
diff --git a/src/se/leap/bitmaskclient/Dashboard.java b/src/se/leap/bitmaskclient/Dashboard.java
index 8c7c495d..ecac500e 100644
--- a/src/se/leap/bitmaskclient/Dashboard.java
+++ b/src/se/leap/bitmaskclient/Dashboard.java
@@ -166,6 +166,8 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
providerNameTV = (TextView) findViewById(R.id.providerName);
providerNameTV.setText(provider.getDomain());
providerNameTV.setTextSize(28);
+
+ mProgressBar = (ProgressBar) findViewById(R.id.eipProgress);
FragmentManager fragMan = getFragmentManager();
if ( provider.hasEIP()){
@@ -224,6 +226,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
}
eipStop();
}
+ //unregisterReceiver(providerAPI_broadcast_receiver_update);
ConfigHelper.removeFromSharedPref(Provider.KEY);
startActivityForResult(new Intent(this,ConfigurationWizard.class), SWITCH_PROVIDER);
return true;
diff --git a/src/se/leap/bitmaskclient/ProviderAPI.java b/src/se/leap/bitmaskclient/ProviderAPI.java
index bf3cf662..0070b307 100644
--- a/src/se/leap/bitmaskclient/ProviderAPI.java
+++ b/src/se/leap/bitmaskclient/ProviderAPI.java
@@ -58,7 +58,6 @@ import org.apache.http.client.ClientProtocolException;
import org.jboss.security.srp.SRPParameters;
import org.json.JSONException;
import org.json.JSONObject;
-import org.json.JSONStringer;
import se.leap.bitmaskclient.R;
import se.leap.bitmaskclient.ProviderListContent.ProviderItem;
@@ -69,7 +68,6 @@ import android.os.Handler;
import android.os.ResultReceiver;
import android.util.Base64;
import android.util.Log;
-import android.widget.Toast;
/**
* Implements HTTP api methods used to manage communications with the provider server.
@@ -97,8 +95,8 @@ public class ProviderAPI extends IntentService {
SESSION_ID_COOKIE_KEY = "session_id_cookie_key",
SESSION_ID_KEY = "session_id",
ERRORS = "errors",
- UPDATE_PROGRESSBAR = "update_action",
- CURRENT_PROGRESS = "update data",
+ UPDATE_PROGRESSBAR = "update_progressbar",
+ CURRENT_PROGRESS = "current_progress",
TAG = "provider_api_tag"
;
@@ -123,6 +121,7 @@ public class ProviderAPI extends IntentService {
PROVIDER_JSON_DOWNLOADED = false,
EIP_SERVICE_JSON_DOWNLOADED = false
;
+
public ProviderAPI() {
super("ProviderAPI");
Log.v("ClassName", "Provider API");
@@ -150,7 +149,7 @@ public class ProviderAPI extends IntentService {
if(result.getBoolean(RESULT_KEY)) {
receiver.send(PROVIDER_OK, Bundle.EMPTY);
} else {
- receiver.send(PROVIDER_NOK, Bundle.EMPTY);
+ receiver.send(PROVIDER_NOK, result);
}
} else if (action.equalsIgnoreCase(SRP_AUTH)) {
Bundle session_id_bundle = authenticateBySRP(parameters);
@@ -425,39 +424,43 @@ public class ProviderAPI extends IntentService {
* @return a bundle with a boolean value mapped to a key named RESULT_KEY, and which is true if the update was successful.
*/
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);
- result.putBoolean(RESULT_KEY, false);
- if(downloadCACert(provider_main_url, danger_on)) {
+ Bundle current_download = downloadCACert(provider_main_url, danger_on);
+ if(current_download.containsKey(RESULT_KEY) && current_download.getBoolean(RESULT_KEY)) {
broadcast_progress(progress++);
- CA_CERT_DOWNLOADED = true;
- if(getAndSetProviderJson(provider_main_url)) {
+ //CA_CERT_DOWNLOADED = true;
+ current_download = getAndSetProviderJson(provider_main_url);
+ if(current_download.containsKey(RESULT_KEY) && current_download.getBoolean(RESULT_KEY)) {
broadcast_progress(progress++);
- PROVIDER_JSON_DOWNLOADED = true;
- if(getAndSetEipServiceJson()) {
+ //PROVIDER_JSON_DOWNLOADED = true;
+ current_download = getAndSetEipServiceJson();
+ if(current_download.containsKey(RESULT_KEY) && current_download.getBoolean(RESULT_KEY)) {
broadcast_progress(progress++);
- EIP_SERVICE_JSON_DOWNLOADED = true;
+ //EIP_SERVICE_JSON_DOWNLOADED = true;
}
}
}
- if(CA_CERT_DOWNLOADED && PROVIDER_JSON_DOWNLOADED && EIP_SERVICE_JSON_DOWNLOADED)
- result.putBoolean(RESULT_KEY, true);
-
- return result;
+ return current_download;
}
- private boolean downloadCACert(String provider_main_url, boolean danger_on) {
+ private Bundle downloadCACert(String provider_main_url, boolean danger_on) {
+ Bundle result = new Bundle();
String cert_string = downloadWithCommercialCA(provider_main_url + "/ca.crt", danger_on);
- if(validCertificate(cert_string))
+ if(validCertificate(cert_string)) {
ConfigHelper.saveSharedPref(Provider.CA_CERT, cert_string);
- else
- return false;
+ result.putBoolean(RESULT_KEY, true);
+ } else {
+ String reason_to_fail = cert_string;
+ result.putString(ERRORS, reason_to_fail);
+ result.putBoolean(RESULT_KEY, false);
+
+ }
- return true;
+ return result;
}
private boolean validCertificate(String cert_string) {
@@ -475,8 +478,8 @@ public class ProviderAPI extends IntentService {
return result;
}
- private boolean getAndSetProviderJson(String provider_main_url) {
- boolean result = false;
+ private Bundle getAndSetProviderJson(String provider_main_url) {
+ Bundle result = new Bundle();
String provider_dot_json_string = downloadWithProviderCA(provider_main_url + "/provider.json", true);
@@ -487,28 +490,31 @@ public class ProviderAPI extends IntentService {
ConfigHelper.saveSharedPref(Provider.KEY, provider_json);
ConfigHelper.saveSharedPref(EIP.ALLOWED_ANON, provider_json.getJSONObject(Provider.SERVICE).getBoolean(EIP.ALLOWED_ANON));
- ProviderItem added_provider = new ProviderItem(name, provider_main_url);
-
- result = true;
+
+ result.putBoolean(RESULT_KEY, true);
} catch (JSONException e) {
}
return result;
}
- private boolean getAndSetEipServiceJson() {
- boolean result = false;
-
+ private Bundle getAndSetEipServiceJson() {
+ Bundle result = new Bundle();
+ String eip_service_json_string = "";
try {
JSONObject provider_json = ConfigHelper.getJsonFromSharedPref(Provider.KEY);
String eip_service_url = provider_json.getString(Provider.API_URL) + "/" + provider_json.getString(Provider.API_VERSION) + "/" + EIP.SERVICE_API_PATH;
- String eip_service_json_string = downloadWithProviderCA(eip_service_url, true);
+ eip_service_json_string = downloadWithProviderCA(eip_service_url, true);
JSONObject eip_service_json = new JSONObject(eip_service_json_string);
eip_service_json.getInt(Provider.API_RETURN_SERIAL);
ConfigHelper.saveSharedPref(EIP.KEY, eip_service_json);
- result = true;
+
+ result.putBoolean(RESULT_KEY, true);
} catch (JSONException e) {
+ String reason_to_fail = eip_service_json_string;
+ result.putString(ERRORS, reason_to_fail);
+ result.putBoolean(RESULT_KEY, false);
}
return result;
}
diff --git a/src/se/leap/bitmaskclient/ProviderListFragment.java b/src/se/leap/bitmaskclient/ProviderListFragment.java
index 862177a2..76628f8c 100644
--- a/src/se/leap/bitmaskclient/ProviderListFragment.java
+++ b/src/se/leap/bitmaskclient/ProviderListFragment.java
@@ -19,7 +19,6 @@
import se.leap.bitmaskclient.R;
import se.leap.bitmaskclient.ProviderListContent.ProviderItem;
import android.app.Activity;
-import android.app.DialogFragment;
import android.app.ListFragment;
import android.os.Bundle;
import android.view.LayoutInflater;