From c01aa98a1d43ae0d6b56f0d13a8782dbb6a3e35e Mon Sep 17 00:00:00 2001 From: parmegv Date: Tue, 12 Feb 2013 19:33:19 +0100 Subject: New custom provider dialog effectively adds the new provider to the ProviderListFragment, and then the user can choose it. --- src/se/leap/leapclient/ProviderListContent.java | 27 ++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'src/se/leap/leapclient/ProviderListContent.java') diff --git a/src/se/leap/leapclient/ProviderListContent.java b/src/se/leap/leapclient/ProviderListContent.java index bf8bfa87..5fe206eb 100644 --- a/src/se/leap/leapclient/ProviderListContent.java +++ b/src/se/leap/leapclient/ProviderListContent.java @@ -1,5 +1,6 @@ package se.leap.leapclient; +import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; @@ -35,7 +36,8 @@ public class ProviderListContent { /** * A dummy item representing a piece of content. */ - public static class ProviderItem { + public static class ProviderItem { + public boolean custom = false; public String id; public String name; public String provider_json_url; @@ -43,7 +45,6 @@ public class ProviderListContent { public String eip_service_json_url; public String cert_json_url; - public ProviderItem(String id, String name, String provider_json_url, String eip_service_json_url, String cert_json_url) { this.id = id; this.name = name; @@ -52,7 +53,7 @@ public class ProviderListContent { this.cert_json_url = cert_json_url; } - public ProviderItem(String name, InputStream urls_file_input_stream) { + public ProviderItem(String name, InputStream urls_file_input_stream, boolean custom) { try { byte[] urls_file_bytes = new byte[urls_file_input_stream.available()]; @@ -74,6 +75,26 @@ public class ProviderListContent { } } + public ProviderItem(String name, FileInputStream provider_json, boolean custom) { + + try { + byte[] urls_file_bytes = new byte[provider_json.available()]; + provider_json.read(urls_file_bytes); + String urls_file_content = new String(urls_file_bytes); + JSONObject file_contents = new JSONObject(urls_file_content); + id = name; + this.name = name; + eip_service_json_url = (String) file_contents.get("api_uri") + ConfigHelper.eip_service_api_path; + cert_json_url = (String) file_contents.get("ca_cert_uri"); + } catch (JSONException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + @Override public String toString() { return name; -- cgit v1.2.3