← Back to team overview

zeitgeist team mailing list archive

[Branch ~zeitgeist/zeitgeist/bluebird] Rev 227: Revert some of the signature check asserts, they are supposed to be

 

------------------------------------------------------------
revno: 227
committer: Siegfried-Angel Gevatter Pujals <siegfried@xxxxxxxxxxxx>
branch nick: bluebird
timestamp: Mon 2011-09-05 13:49:45 +0200
message:
  Revert some of the signature check asserts, they are supposed to be
  checked by D-Bus itself and so shouldn't be a problem.
modified:
  extensions/blacklist.vala
  extensions/ds-registry.vala
  src/datamodel.vala


--
lp:~zeitgeist/zeitgeist/bluebird
https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird

Your team Zeitgeist Framework Team is subscribed to branch lp:~zeitgeist/zeitgeist/bluebird.
To unsubscribe from this branch go to https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird/+edit-subscription
=== modified file 'extensions/blacklist.vala'
--- extensions/blacklist.vala	2011-09-05 10:27:02 +0000
+++ extensions/blacklist.vala	2011-09-05 11:49:45 +0000
@@ -95,33 +95,63 @@
             // FIXME: write to file.
         }
 
-        public GenericArray<Event?> pre_insert_events (
-            GenericArray<Event?> events, BusName sender)
+        public override void pre_insert_events (GenericArray<Event?> events,
+            BusName? sender)
         {
             // FIXME: do template matching...
             // for event in events:
             //     for tmpl in blacklist:
             //         if event.matches_template(tmpl): event = null
-            return events;
         }
 
         public void add_template (string blacklist_id, Variant event_template)
+            throws EngineError
         {
             Event template = new Event.from_variant (event_template);
             blacklist.insert (blacklist_id, template);
+            debug ("Added blacklist template: %s", blacklist_id);
+            // FIXME: signals...
             flush ();
         }
 
         public void remove_template (string blacklist_id)
         {
             Event template = blacklist.lookup (blacklist_id);
-            blacklist.remove (blacklist_id);
+            if (blacklist.remove (blacklist_id))
+                debug ("Removed blacklist template: %s", blacklist_id);
+            else
+                debug ("Blacklist template \"%s\" not found.", blacklist_id);
+            // FIXME: signals...
             flush ();
         }
 
+        private Variant blacklist_template_to_variant (string blacklist_id,
+            Event event_template)
+        {
+            var vb = new VariantBuilder (new VariantType ("s(asaasay)"));
+            vb.add ("s", blacklist_id);
+            vb.add_value (event_template.to_variant ());
+            return vb.end ();
+        }
+
         public Variant get_templates ()
         {
-            return null; //blacklist;
+            var vb = new VariantBuilder (new VariantType ("a{s(asaasay)}"));
+            {
+                var iter = HashTableIter<string, Event> (blacklist);
+                string blacklist_id;
+                Event event_template;
+                vb.open (new VariantType ("{s(asaasay)}"));
+                while (iter.next (out blacklist_id, out event_template))
+                {
+                    vb.open (new VariantType ("s(asaasay)"));
+                    vb.add_value (blacklist_template_to_variant (
+                        blacklist_id, event_template));
+                    vb.close ();
+                }
+                vb.close ();
+            }
+            return vb.end ();
         }
 
     }

=== modified file 'extensions/ds-registry.vala'
--- extensions/ds-registry.vala	2011-09-05 11:16:46 +0000
+++ extensions/ds-registry.vala	2011-09-05 11:49:45 +0000
@@ -68,7 +68,7 @@
                 event_templates: templates);
         }
 
-        public DataSource.from_variant (Variant variant)
+        public DataSource.from_variant (Variant variant) throws EngineError
         {
             // we expect (sssa(asaasay)bxb)
             warn_if_fail (variant.get_type_string () == "(sssa(asaasay)bxb)"
@@ -202,6 +202,7 @@
 
         public bool register_data_source (string unique_id, string name,
             string description, Variant event_templates, BusName? sender)
+            throws EngineError
         {
             debug ("%s: %s, %s, %s", Log.METHOD, unique_id, name, description);
 

=== modified file 'src/datamodel.vala'
--- src/datamodel.vala	2011-09-05 11:16:04 +0000
+++ src/datamodel.vala	2011-09-05 11:49:45 +0000
@@ -74,10 +74,8 @@
         }
 
         public TimeRange.from_variant (Variant variant)
-            throws EngineError
         {
-            assert_sig (variant.get_type_string () == "(xx)",
-                "expected (xx)");
+            assert (variant.get_type_string () == "(xx)");
 
             int64 start_msec = 0;
             int64 end_msec = 0;
@@ -290,8 +288,7 @@
         }
 
         public Event.from_variant (Variant event_variant) throws EngineError {
-            assert_sig (event_variant.get_type_string () == "(asaasay)",
-                "expected (asaasay)");
+            assert (event_variant.get_type_string () == "(asaasay)");
 
             VariantIter iter = event_variant.iterator();
 
@@ -478,12 +475,10 @@
     {
 
         public static GenericArray<Event> from_variant (Variant vevents)
-            throws EngineError
         {
             GenericArray<Event> events = new GenericArray<Event> ();
 
-            assert_sig (vevents.get_type_string () == "a(asaasay)",
-                "expected a(asaasay)");
+            assert (vevents.get_type_string () == "a(asaasay)");
 
             foreach (Variant event in vevents)
             {