Added more data fields to IdCard, new TrustAnchor class
authorAlberto Ruiz <aruiz@gnome.org>
Mon, 4 Jul 2011 16:43:57 +0000 (17:43 +0100)
committerAlberto Ruiz <aruiz@gnome.org>
Mon, 4 Jul 2011 16:44:11 +0000 (17:44 +0100)
Makefile.am
src/moonshot-id.vala
src/moonshot-webp-parser.vala

index 475b2b7..de028e5 100644 (file)
@@ -101,7 +101,7 @@ endif
 
 bin_PROGRAMS += src/moonshot-webp
 
-src_moonshot_webp_SOURCES = src/moonshot-webp-parser.vala
+src_moonshot_webp_SOURCES = src/moonshot-webp-parser.vala src/moonshot-id.vala
 src_moonshot_webp_LDADD = $(moonshot_LIBS)
 
 if IPC_DBUS
index 536a1a6..d82f1a6 100644 (file)
@@ -1,11 +1,25 @@
+public class TrustAnchor : Object
+{
+  public string ca_cert {get; set; default = null;}
+  public string subject {get; set; default = null;}
+  public string subject_alt  {get; set; default = null;}
+  public string server_cert  {get; set; default = null;}
+}
+
+public class IdCard : Object
+{
+  public string display_name { get; set; default = null; }
+  
+  public string username { get; set; default = null; }
+  public string password { get; set; default = null; }
 
-class IdCard : Object {
+  public string issuer { get; set; default = null; }
 
-    public Gdk.Pixbuf pixbuf {get; set; default = null; }
-    public string issuer { get; set; default = null; }
-    public string username { get; set; default = null; }
-    public string password { get; set; default = null; }
-    public string[] services { get; set; default = null; }
-    public string nai { get; set; default = null; }
+  public TrustAnchor trust_anchor  { get; set; default = new TrustAnchor (); }
+  
+  public Gdk.Pixbuf pixbuf { get; set; default = null; }    
+  public string[] services { get; set; default = null; }
 
+  //TODO: Set the getter and remove the setter/default
+  public string nai { get; set; default = null; }
 }
index 16ce39e..49dc5ac 100644 (file)
@@ -1,42 +1,57 @@
 namespace WebProvisioning
-{
-  class WebProvisionParser
+{ 
+  public IdCard card;
+
+  public void text_element_func (MarkupParseContext context,
+                                 string text,
+                                 size_t text_len) throws MarkupError
   {
-    public WebProvisionParser (string path)
+    unowned SList<string> stack = context.get_element_stack ();
+    
+    if (stack.nth_data(0) == "display-name")
     {
       
     }
-  }
-  
-  public void start_element_func (MarkupParseContext context,
-                                  string             element_name,
-                                  string[]           attribute_names,
-                                  string[]           attribute_values) throws MarkupError
-  {
-    debug ("Start: %s", element_name);
-  }
 
-  public void end_element_func (MarkupParseContext context,
-                                string             element_name) throws MarkupError
-  {
-    debug ("End: %s", element_name);
+    
   }
-  
-  public void text_element_func (MarkupParseContext context,
-                                 string text,
-                                 size_t text_len) throws MarkupError
+
+  class WebProvisionParser
   {
-    debug ("Text element: %s", text); 
-    foreach (string elm in context.get_element_stack ())
+    public WebProvisionParser (string path)
     {
-      stdout.printf("%s\n", elm);
+      string text = "";
+      var file = File.new_for_path (path);
+    
+      try
+      {
+        var dis = new DataInputStream (file.read ());
+        string line;
+        while ((line = dis.read_line (null)) != null)
+          text += line;
+      }
+      catch (Error e)
+      {
+        error ("Could not retreive file size");
+      }
+      
+      MarkupParser parser = {null, null, text_element_func, null, null};
+      
+      var ctx = new MarkupParseContext(parser, 0, null, null);
+      
+      try
+      {
+        ctx.parse (text, text.length);
+      }
+      catch (Error e)
+      {
+        error ("Could not parse %s, invalid content", path);
+      } 
     }
   }
-  
 
   public static int main (string[] args)
   {
-    string text = "";
     if (args.length < 2)
     {
       error ("Usage %s [-a] WEB_PROVISIONING_FILE", args[0]);
@@ -47,34 +62,8 @@ namespace WebProvisioning
       error ("%s does not exist", args[1]);
     }
     
-    var file = File.new_for_path (args[1]);
-    
-    try
-    {
-      var dis = new DataInputStream (file.read ());
-      string line;
-      while ((line = dis.read_line (null)) != null)
-        text += line;
-    }
-    catch (Error e)
-    {
-      error ("Could not retreive file size");
-    }
-    
-    MarkupParser parser = {start_element_func, end_element_func, text_element_func, null, null};
-    
-    var ctx = new MarkupParseContext(parser, 0, null, null);
-    
-    try
-    {
-      ctx.parse (text, text.length);
-    }
-    catch (Error e)
-    {
-      error ("Could not parse %s, invalid content", args[1]);
-    }
-    
-    
+    var webp = new WebProvisionParser (args[1]);
+
     return 0;
   }
 }