summaryrefslogtreecommitdiff
path: root/src/se/leap/leapclient/ConfigHelper.java
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2013-02-11 20:28:59 +0100
committerParménides GV <parmegv@sdf.org>2013-02-11 20:28:59 +0100
commit162afa5bfa6485f3aacb3f60e9c92fa0c3bfa7a7 (patch)
treec9fabab994e1e51e8ec90bc8b2c78cc55d219e3e /src/se/leap/leapclient/ConfigHelper.java
parent8db161017f55a710bd91aa14fe9c1b24d4efdeab (diff)
Gets provider.json from custom url (assuming the file is at the root of
the website, just as bitmask.net/provider.json), and writes it to a file in ~/leap_android. Next steps: parse that file and download eip-service and cert.
Diffstat (limited to 'src/se/leap/leapclient/ConfigHelper.java')
-rw-r--r--src/se/leap/leapclient/ConfigHelper.java32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/se/leap/leapclient/ConfigHelper.java b/src/se/leap/leapclient/ConfigHelper.java
index eded2504..c724a31c 100644
--- a/src/se/leap/leapclient/ConfigHelper.java
+++ b/src/se/leap/leapclient/ConfigHelper.java
@@ -1,18 +1,28 @@
package se.leap.leapclient;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
import org.json.JSONException;
import org.json.JSONObject;
import android.content.SharedPreferences;
+import android.os.Environment;
+import android.util.Log;
public class ConfigHelper {
final static String downloadJsonFilesBundleExtra = "downloadJSONFiles";
+ final static String downloadNewProviderDotJSON = "downloadNewProviderDotJSON";
final static String provider_key = "provider";
final static String cert_key = "cert";
final static String eip_service_key = "eip";
public static final String PREFERENCES_KEY = "LEAPPreferences";
+ public static final String user_directory = "leap_android";
+ public static String provider_key_url = "provider_main_url";
static void saveSharedPref(String shared_preferences_key, JSONObject content) {
@@ -27,9 +37,29 @@ public class ConfigHelper {
+ ConfigurationWizard.shared_preferences.getString(
shared_preferences_key, "Default"));
}
-
+
static void rescueJSONException(JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
+
+ static void saveFile(String filename, String content) {
+ File root = Environment.getExternalStorageDirectory();
+ File outDir = new File(root.getAbsolutePath() + File.separator + user_directory);
+ if (!outDir.isDirectory()) {
+ outDir.mkdir();
+ }
+ try {
+ if (!outDir.isDirectory()) {
+ throw new IOException(
+ "Unable to create directory " + user_directory + ". Maybe the SD card is mounted?");
+ }
+ File outputFile = new File(outDir, filename);
+ BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile));
+ writer.write(content);
+ writer.close();
+ } catch (IOException e) {
+ Log.w("leap_android", e.getMessage(), e);
+ }
+ }
}