------------------------------------------------------------ revno: 207 committer: Siegfried-Angel Gevatter Pujals <siegfr...@gevatter.com> branch nick: bluebird timestamp: Wed 2011-08-31 13:02:37 +0200 message: Start working on the blacklist extension. added: extensions/blacklist.vala src/ext-blacklist.vala@ modified: .bzrignore extensions/Makefile.am extensions/ds-registry.vala src/Makefile.am src/errors.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 '.bzrignore' --- .bzrignore 2011-08-06 15:50:22 +0000 +++ .bzrignore 2011-08-31 11:02:37 +0000 @@ -37,3 +37,11 @@ src/ontology.vala src/ontology-uris.vala extra/org.gnome.zeitgeist.service +extensions/.deps +extensions/.libs +extensions/*.c +extensions/*.stamp +extensions/*.la +extensions/*.lo +test/direct/marshalling +test/dbus/__pycache__ === modified file 'extensions/Makefile.am' --- extensions/Makefile.am 2011-08-25 20:55:03 +0000 +++ extensions/Makefile.am 2011-08-31 11:02:37 +0000 @@ -1,7 +1,7 @@ NULL = #extensionsdir = $(libdir)/zeitgeist/extensions -noinst_LTLIBRARIES = ds-registry.la +noinst_LTLIBRARIES = ds-registry.la blacklist.la AM_CPPFLAGS = \ $(BLUEBIRD_CFLAGS) \ @@ -26,3 +26,13 @@ ds_registry_la_LIBADD = \ $(BLUEBIRD_LIBS) \ $(NULL) + +blacklist_la_SOURCES = \ + blacklist.vala \ + $(NULL) + +blacklist_la_LDFLAGS = -module -avoid-version + +blacklist_la_LIBADD = \ + $(BLUEBIRD_LIBS) \ + $(NULL) === added file 'extensions/blacklist.vala' --- extensions/blacklist.vala 1970-01-01 00:00:00 +0000 +++ extensions/blacklist.vala 2011-08-31 11:02:37 +0000 @@ -0,0 +1,127 @@ +/* ds-registry.vala + * + * Copyright © 2011 Collabora Ltd. + * By Siegfried-Angel Gevatter Pujals <siegfr...@gevatter.com> + * Copyright © 2011 Michal Hruby <michal....@gmail.com> + * + * Based upon a Python implementation (2009-2011) by: + * Mikkel Kamstrup Erlandsen <mikkel.kamst...@gmail.com> + * Manish Sinha <manishsi...@ubuntu.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace Zeitgeist +{ + [DBus (name = "org.gnome.zeitgeist.Blacklist")] + interface RemoteBlacklist: Object + { + public abstract void add_template (string blacklist_id, + [DBus (signature = "(asaasay)")] Variant event_template) + throws Error; + [DBus (signature = "a{s(asaasay)}")] + public abstract Variant get_templates () throws Error; + public abstract void remove_template (string blacklist_id) + throws Error; + + public signal void template_added (string blacklist_id, + [DBus (signature = "s(asaasay)")] Variant event_template); + public signal void template_removed (string blacklist_id, + [DBus (signature = "s(asassay)")] Variant event_template); + } + + class Blacklist: Extension, RemoteBlacklist + { + private HashTable<string, Event> blacklist; + private uint registration_id; + + Blacklist () + { + Object (); + } + + construct + { + blacklist = new HashTable<string, Event> (str_hash, str_equal); + + // FIXME: load blacklist from file + + // This will be called after bus is acquired, so it shouldn't block + var connection = Bus.get_sync (BusType.SESSION, null); + registration_id = connection.register_object<RemoteBlacklist> ( + "/org/gnome/zeitgeist/blacklist", this); + } + + public override void unload () + { + var connection = Bus.get_sync (BusType.SESSION, null); + if (registration_id != 0) + { + connection.unregister_object (registration_id); + registration_id = 0; + } + + debug ("%s, this.ref_count = %u", Log.METHOD, this.ref_count); + } + + private void flush () + { + // FIXME: write to file. + } + + public GenericArray<Event?> 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) + { + Event template = new Event.from_variant (event_template); + blacklist.insert (blacklist_id, template); + flush (); + } + + public void remove_template (string blacklist_id) + { + Event template = blacklist.lookup (blacklist_id); + blacklist.remove (blacklist_id); + flush (); + } + + public Variant get_templates () + { + return null; //blacklist; + } + + } + + [ModuleInit] +#if BUILTIN_EXTENSIONS + Type blacklist_init (TypeModule module) + { +#else + Type extension_register (TypeModule module) + { +#endif + return typeof (Blacklist); + } +} + +// vim:expandtab:ts=4:sw=4 === modified file 'extensions/ds-registry.vala' --- extensions/ds-registry.vala 2011-08-31 09:44:40 +0000 +++ extensions/ds-registry.vala 2011-08-31 11:02:37 +0000 @@ -2,6 +2,10 @@ * * Copyright © 2011 Michal Hruby <michal....@gmail.com> * + * Based upon a Python implementation (2009-2010) by: + * Siegfried-Angel Gevatter Pujals <siegfr...@gevatter.com> + * Mikkel Kamstrup Erlandsen <mikkel.kamst...@gmail.com> + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 2.1 of the License, or @@ -32,7 +36,7 @@ bool enabled) throws Error; [DBus (signature = "(sssa(asaasay)bxb)")] public abstract Variant get_data_source_from_id (string id) throws Error; - + public signal void data_source_disconnected ( [DBus (signature = "(sssa(asaasay)bxb)")] Variant data_source); public signal void data_source_enabled (string unique_id, === modified file 'src/Makefile.am' --- src/Makefile.am 2011-08-25 21:43:52 +0000 +++ src/Makefile.am 2011-08-31 11:02:37 +0000 @@ -19,6 +19,7 @@ extensions_VALASOURCES = \ ext-data-source-registry.vala \ + ext-blacklist.vala \ $(NULL) bluebird_VALASOURCES = \ === modified file 'src/errors.vala' --- src/errors.vala 2011-08-31 09:31:29 +0000 +++ src/errors.vala 2011-08-31 11:02:37 +0000 @@ -3,12 +3,6 @@ * Copyright © 2011 Collabora Ltd. * By Siegfried-Angel Gevatter Pujals <siegfr...@gevatter.com> * - * Based upon a Python implementation (2009-2011) by: - * Markus Korn <thek...@gmx.net> - * Mikkel Kamstrup Erlandsen <mikkel.kamst...@gmail.com> - * Seif Lotfy <s...@lotfy.com> - * Siegfried-Angel Gevatter Pujals <siegfr...@gevatter.com> - * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 2.1 of the License, or === added symlink 'src/ext-blacklist.vala' === target is u'../extensions/blacklist.vala'
_______________________________________________ Mailing list: https://launchpad.net/~zeitgeist Post to : zeitgeist@lists.launchpad.net Unsubscribe : https://launchpad.net/~zeitgeist More help : https://help.launchpad.net/ListHelp