diff options
author | Seif Lotfy <seif@lotfy.com> | 2012-08-05 13:12:55 +0200 |
---|---|---|
committer | Seif Lotfy <seif@lotfy.com> | 2012-08-05 13:12:55 +0200 |
commit | fa5cea7e2317ae206ba2bb4eef3e77525bcfb3c2 (patch) | |
tree | d7214aed507057c916d7e613949825b26fc07c55 | |
parent | 9678c79e3839005d48dd7091e47b921d53e17a10 (diff) |
Port to libzeitgeist2
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/desktop-launch-listener.vala | 16 | ||||
-rw-r--r-- | src/downloads-directory-provider.vala | 26 | ||||
-rw-r--r-- | src/kde-recent-document-provider.vala | 63 | ||||
-rw-r--r-- | src/recent-manager-provider.vala | 27 | ||||
-rw-r--r-- | src/telepathy-observer.vala | 118 | ||||
-rw-r--r-- | src/utils.vala | 13 | ||||
-rw-r--r-- | src/zeitgeist-datahub.vala | 32 |
9 files changed, 177 insertions, 123 deletions
diff --git a/configure.ac b/configure.ac index d3b6a7a..e2ddd35 100644 --- a/configure.ac +++ b/configure.ac @@ -69,7 +69,7 @@ MIN_JSON_GLIB_VERSION=0.14.0 MIN_GTK_VERSION=2.16.0 MIN_TP_GLIB_VERSION=0.18.0 -LIBRARY_MODULES="glib-2.0 >= $MIN_GLIB_VERSION gobject-2.0 gio-2.0 gio-unix-2.0 zeitgeist-1.0 >= $MIN_ZEITGEIST_VERSION json-glib-1.0 >= $MIN_JSON_GLIB_VERSION" +LIBRARY_MODULES="glib-2.0 >= $MIN_GLIB_VERSION gobject-2.0 gio-2.0 gio-unix-2.0 zeitgeist-2.0 >= $MIN_ZEITGEIST_VERSION json-glib-1.0 >= $MIN_JSON_GLIB_VERSION" PKG_CHECK_MODULES(DATAHUB_MODULES, [$LIBRARY_MODULES]) PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= $MIN_GTK_VERSION]) @@ -132,5 +132,6 @@ ${PACKAGE}-${VERSION} Optional Providers Downloads Directory Monitor: ${with_downloads_monitor} + Telepathy Logger : ${have_telepathy} EOF diff --git a/src/Makefile.am b/src/Makefile.am index db09959..076fc1c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,7 +8,7 @@ VALAFLAGS = \ --pkg gio-unix-2.0 \ --pkg gtk+-2.0 \ --pkg json-glib-1.0 \ - --pkg zeitgeist-1.0 \ + --pkg zeitgeist-2.0 \ glib-extra.vapi \ $(top_srcdir)/config.vapi \ $(NULL) diff --git a/src/desktop-launch-listener.vala b/src/desktop-launch-listener.vala index 25af42e..ddcc613 100644 --- a/src/desktop-launch-listener.vala +++ b/src/desktop-launch-listener.vala @@ -142,16 +142,16 @@ public class DesktopLaunchListener : DataProvider var event = new Zeitgeist.Event (); var subject = new Zeitgeist.Subject (); - event.set_actor (launcher_uri); - event.set_interpretation (Zeitgeist.ZG_ACCESS_EVENT); - event.set_manifestation (Zeitgeist.ZG_USER_ACTIVITY); + event.actor = launcher_uri; + event.interpretation = ZG.ACCESS_EVENT; + event.manifestation = ZG.USER_ACTIVITY; event.add_subject (subject); - subject.set_uri (launched_uri); - subject.set_interpretation (Zeitgeist.NFO_SOFTWARE); - subject.set_manifestation (Zeitgeist.NFO_SOFTWARE_ITEM); - subject.set_mimetype ("application/x-desktop"); - subject.set_text (dai.get_display_name ()); + subject.uri = launched_uri; + subject.interpretation = NFO.SOFTWARE; + subject.manifestation = NFO.SOFTWARE_ITEM; + subject.mimetype = "application/x-desktop"; + subject.text = dai.get_display_name (); var arr = new GenericArray<Event> (); arr.add (event); diff --git a/src/downloads-directory-provider.vala b/src/downloads-directory-provider.vala index a472feb..6b77217 100644 --- a/src/downloads-directory-provider.vala +++ b/src/downloads-directory-provider.vala @@ -56,8 +56,15 @@ public class DownloadsDirectoryMonitor : DataProvider if (downloads_path != null) { downloads_directory = File.new_for_path (downloads_path); - monitor = downloads_directory.monitor_directory ( - GLib.FileMonitorFlags.NONE/*SEND_MOVED*/); + try + { + monitor = downloads_directory.monitor_directory ( + GLib.FileMonitorFlags.NONE/*SEND_MOVED*/); + } + catch (GLib.Error err) + { + warning ("Couldn't set up monitor on Downloads directory: %s", err.message); + } } } @@ -79,9 +86,9 @@ public class DownloadsDirectoryMonitor : DataProvider } private const string ATTRIBUTES = - FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE + "," + - FILE_ATTRIBUTE_STANDARD_IS_HIDDEN + "," + - FILE_ATTRIBUTE_STANDARD_IS_BACKUP + ","; + FileAttribute.STANDARD_FAST_CONTENT_TYPE + "," + + FileAttribute.STANDARD_IS_HIDDEN + "," + + FileAttribute.STANDARD_IS_BACKUP + ","; private async void process_event (GLib.File file, GLib.File? other_file, GLib.FileMonitorEvent event_type) @@ -115,7 +122,7 @@ public class DownloadsDirectoryMonitor : DataProvider } string mimetype = subject_info.get_attribute_string ( - FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE); + FileAttribute.STANDARD_FAST_CONTENT_TYPE); string origin = Path.get_dirname (uri); string basename = Path.get_basename (file.get_path ()); @@ -125,11 +132,12 @@ public class DownloadsDirectoryMonitor : DataProvider mimetype, origin, basename, - ""); // storage will be figured out by Zeitgeist + "", uri); // storage will be figured out by Zeitgeist string actor = ""; // unknown - Event event = new Event.full (ZG_CREATE_EVENT, ZG_WORLD_ACTIVITY, - actor, subject, null); + Event event = new Event.full (ZG.CREATE_EVENT, ZG.WORLD_ACTIVITY, + actor, null, null); + event.add_subject (subject); if (event != null) { diff --git a/src/kde-recent-document-provider.vala b/src/kde-recent-document-provider.vala index 65e7531..736f77b 100644 --- a/src/kde-recent-document-provider.vala +++ b/src/kde-recent-document-provider.vala @@ -40,15 +40,15 @@ public class RecentDocumentsKDE : DataProvider private const string ATTRIBUTE_SEPARATOR = ","; private const string FILE_ATTRIBUTE_QUERY_RECENT = - GLib.FILE_ATTRIBUTE_STANDARD_TYPE + ATTRIBUTE_SEPARATOR + - GLib.FILE_ATTRIBUTE_TIME_MODIFIED + ATTRIBUTE_SEPARATOR + - GLib.FILE_ATTRIBUTE_TIME_MODIFIED_USEC; + GLib.FileAttribute.STANDARD_TYPE + ATTRIBUTE_SEPARATOR + + GLib.FileAttribute.TIME_MODIFIED + ATTRIBUTE_SEPARATOR + + GLib.FileAttribute.TIME_MODIFIED_USEC; private const string FILE_ATTRIBUTE_QUERY_SUBJECT = - GLib.FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE + ATTRIBUTE_SEPARATOR + - GLib.FILE_ATTRIBUTE_TIME_MODIFIED + ATTRIBUTE_SEPARATOR + - GLib.FILE_ATTRIBUTE_TIME_MODIFIED_USEC + ATTRIBUTE_SEPARATOR + - GLib.FILE_ATTRIBUTE_TIME_CHANGED + ATTRIBUTE_SEPARATOR + - GLib.FILE_ATTRIBUTE_TIME_CHANGED_USEC; + GLib.FileAttribute.STANDARD_CONTENT_TYPE + ATTRIBUTE_SEPARATOR + + GLib.FileAttribute.TIME_MODIFIED + ATTRIBUTE_SEPARATOR + + GLib.FileAttribute.TIME_MODIFIED_USEC + ATTRIBUTE_SEPARATOR + + GLib.FileAttribute.TIME_CHANGED + ATTRIBUTE_SEPARATOR + + GLib.FileAttribute.TIME_CHANGED_USEC; private const int TIME_EPSILON = 100; // msec @@ -73,13 +73,27 @@ public class RecentDocumentsKDE : DataProvider construct { - recent_regex = new Regex ("URL\\[[^]]+\\]="); - url_regex = new Regex ("\\$HOME"); - + //FIXME: is done properly ? + try + { + recent_regex = new Regex ("URL\\[[^]]+\\]="); + url_regex = new Regex ("\\$HOME"); + } + catch (RegexError err) + { + warning ("Couldn't process regex: %s", err.message); + } recent_document_path = Environment.get_home_dir () + RECENT_DOCUMENTS_PATH; recent_documents_directory = File.new_for_path (recent_document_path); - monitor = recent_documents_directory.monitor_directory ( - GLib.FileMonitorFlags.NONE); + try + { + monitor = recent_documents_directory.monitor_directory ( + GLib.FileMonitorFlags.NONE); + } + catch (GLib.IOError err) + { + warning ("Couldn't set up monitor: %s", err.message); + } } public override void start () @@ -130,7 +144,7 @@ public class RecentDocumentsKDE : DataProvider FILE_ATTRIBUTE_QUERY_RECENT, GLib.FileQueryInfoFlags.NONE); GLib.FileType file_type = (GLib.FileType) recent_info.get_attribute_uint32 ( - GLib.FILE_ATTRIBUTE_STANDARD_TYPE); + GLib.FileAttribute.STANDARD_TYPE); if (file_type != GLib.FileType.REGULAR) return null; @@ -171,23 +185,23 @@ public class RecentDocumentsKDE : DataProvider int64 modification_time = Timestamp.from_timeval (timeval); timeval.tv_sec = (long) subject_info.get_attribute_uint64 ( - GLib.FILE_ATTRIBUTE_TIME_CHANGED); + GLib.FileAttribute.TIME_CHANGED); timeval.tv_usec = subject_info.get_attribute_uint32 ( - GLib.FILE_ATTRIBUTE_TIME_CHANGED_USEC); + GLib.FileAttribute.TIME_CHANGED_USEC); int64 creation_time = Timestamp.from_timeval (timeval); string mimetype = subject_info.get_attribute_string ( - FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE); + FileAttribute.STANDARD_CONTENT_TYPE); string event_interpretation; int64 creation_diff = event_time - creation_time; int64 modification_diff = event_time - modification_time; if (creation_diff.abs () < TIME_EPSILON) - event_interpretation = ZG_CREATE_EVENT; + event_interpretation = ZG.CREATE_EVENT; else if (modification_diff.abs () < TIME_EPSILON) - event_interpretation = ZG_MODIFY_EVENT; + event_interpretation = ZG.MODIFY_EVENT; else - event_interpretation = ZG_ACCESS_EVENT; + event_interpretation = ZG.ACCESS_EVENT; string origin = Path.get_dirname (uri); var subject = @@ -199,9 +213,10 @@ public class RecentDocumentsKDE : DataProvider basename, ""); // storage will be figured out by Zeitgeist - Event event = new Event.full (event_interpretation, ZG_USER_ACTIVITY, - actor, subject, null); - event.set_timestamp (event_time); + Event event = new Event.full (event_interpretation, ZG.USER_ACTIVITY, + actor, null, null); + event.add_subject (subject); + event.timestamp = event_time; return event; } @@ -234,7 +249,7 @@ public class RecentDocumentsKDE : DataProvider GLib.File directory = GLib.File.new_for_path (recent_document_path); GLib.FileEnumerator enumerator = directory.enumerate_children ( - FILE_ATTRIBUTE_STANDARD_NAME, GLib.FileQueryInfoFlags.NONE); + FileAttribute.STANDARD_NAME, GLib.FileQueryInfoFlags.NONE); GLib.FileInfo fi; while ((fi = enumerator.next_file ()) != null) { diff --git a/src/recent-manager-provider.vala b/src/recent-manager-provider.vala index 466a71c..df16811 100644 --- a/src/recent-manager-provider.vala +++ b/src/recent-manager-provider.vala @@ -179,13 +179,14 @@ public class RecentManagerGtk : DataProvider if (log_create) { - event = new Event.full (ZG_CREATE_EVENT, - ZG_USER_ACTIVITY, + event = new Event.full (ZG.ACCESS_EVENT, + ZG.USER_ACTIVITY, actor, - subject, null); + null, null); + event.add_subject (subject); timestamp = ri.get_added (); timestamp *= 1000; - event.set_timestamp (timestamp); + event.timestamp = timestamp; if (timestamp > last_timestamp && timestamp >= 0) { events.add ((owned) event); @@ -194,13 +195,14 @@ public class RecentManagerGtk : DataProvider if (log_modify) { - event = new Event.full (ZG_MODIFY_EVENT, - ZG_USER_ACTIVITY, + event = new Event.full (ZG.MODIFY_EVENT, + ZG.USER_ACTIVITY, actor, - subject, null); + null , null); + event.add_subject (subject); timestamp = ri.get_modified (); timestamp *= 1000; - event.set_timestamp (timestamp); + event.timestamp = timestamp; if (timestamp > last_timestamp && timestamp >= 0) { events.add ((owned) event); @@ -209,13 +211,14 @@ public class RecentManagerGtk : DataProvider if (log_access) { - event = new Event.full (ZG_ACCESS_EVENT, - ZG_USER_ACTIVITY, + event = new Event.full (ZG.ACCESS_EVENT, + ZG.USER_ACTIVITY, actor, - subject, null); + null, null); + event.add_subject (subject); timestamp = ri.get_visited (); timestamp *= 1000; - event.set_timestamp (timestamp); + event.timestamp = timestamp; if (timestamp > last_timestamp && timestamp >= 0) { events.add ((owned) event); diff --git a/src/telepathy-observer.vala b/src/telepathy-observer.vala index a605138..657f812 100644 --- a/src/telepathy-observer.vala +++ b/src/telepathy-observer.vala @@ -49,7 +49,14 @@ public class TelepathyObserver : DataProvider construct { call_timers = new HashTable<string, Timer> (str_hash, str_equal); - dbus = TelepathyGLib.DBusDaemon.dup (); + try { + dbus = TelepathyGLib.DBusDaemon.dup (); + } + catch (GLib.Error err) + { + warning ("Couldn't dup DBusDaemon: %s", err.message); + return; + } factory = new TelepathyGLib.AutomaticClientFactory (dbus); Quark[] channel_quark = {TelepathyGLib.Channel.get_feature_quark_contacts ()}; @@ -86,7 +93,7 @@ public class TelepathyObserver : DataProvider obj_path = this.tp_account_path.printf(obj_path[ TelepathyGLib.ACCOUNT_OBJECT_PATH_BASE.length : obj_path.length]); Event event_template = new Event.full ( - ZG_ACCESS_EVENT, + ZG.ACCESS_EVENT, "", this.actor, null, @@ -96,9 +103,9 @@ public class TelepathyObserver : DataProvider * Whether user initiated the chat or not */ if (!channel.requested) - event_template.set_manifestation (ZG_WORLD_ACTIVITY); + event_template.manifestation = ZG.WORLD_ACTIVITY; else - event_template.set_manifestation (ZG_USER_ACTIVITY); + event_template.manifestation = ZG.USER_ACTIVITY; /* * Create IM subject for the event @@ -106,8 +113,8 @@ public class TelepathyObserver : DataProvider event_template.add_subject ( new Subject.full ( "", - NMO_IMMESSAGE, - NFO_SOFTWARE_SERVICE, + NMO.IMMESSAGE, + NFO.SOFTWARE_SERVICE, "plain/text", this.tp_identifier.printf (target.get_identifier ()), "", @@ -120,8 +127,8 @@ public class TelepathyObserver : DataProvider event_template.add_subject ( new Subject.full ( this.tp_identifier.printf (target.get_identifier ()), - NCO_CONTACT, - NCO_CONTACT_LIST_DATA_OBJECT, + NCO.CONTACT, + NCO.CONTACT_LIST_DATA_OBJECT, "", obj_path, target.get_alias (), @@ -156,8 +163,8 @@ public class TelepathyObserver : DataProvider if (!message.is_delivery_report ()) { event_template = this.create_text_event (account, channel); - event_template.set_interpretation (ZG_RECEIVE_EVENT); - event_template.set_manifestation (ZG_WORLD_ACTIVITY); + event_template.interpretation = ZG.RECEIVE_EVENT; + event_template.manifestation = ZG.WORLD_ACTIVITY; this.push_event (event_template); } // FIXME: what about sent messages? what happens with them? @@ -169,7 +176,7 @@ public class TelepathyObserver : DataProvider event_template = this.create_text_event (account, channel); // manifestation depends on the chat creator, unless we can // get a better value. - event_template.set_interpretation (ZG_LEAVE_EVENT); + event_template.interpretation = ZG.LEAVE_EVENT; this.push_event (event_template); }); /* @@ -177,8 +184,8 @@ public class TelepathyObserver : DataProvider */ channel.message_received.connect (() => { event_template = this.create_text_event (account, channel); - event_template.set_interpretation (ZG_RECEIVE_EVENT); - event_template.set_manifestation (ZG_WORLD_ACTIVITY); + event_template.interpretation = ZG.RECEIVE_EVENT; + event_template.manifestation = ZG.WORLD_ACTIVITY; this.push_event (event_template); }); /* @@ -186,8 +193,8 @@ public class TelepathyObserver : DataProvider */ channel.message_sent.connect (() => { event_template = this.create_text_event (account, channel); - event_template.set_interpretation (ZG_SEND_EVENT); - event_template.set_manifestation (ZG_USER_ACTIVITY); + event_template.interpretation = ZG.SEND_EVENT; + event_template.manifestation = ZG.USER_ACTIVITY; this.push_event (event_template); }); } @@ -207,21 +214,21 @@ public class TelepathyObserver : DataProvider obj_path = this.tp_account_path.printf(obj_path[ TelepathyGLib.ACCOUNT_OBJECT_PATH_BASE.length : obj_path.length]); Event event_template = new Event.full ( - ZG_ACCESS_EVENT, - ZG_USER_ACTIVITY, + ZG.ACCESS_EVENT, + ZG.USER_ACTIVITY, this.actor, null, obj_path); if (!channel.requested) - event_template.set_manifestation (ZG_WORLD_ACTIVITY); + event_template.manifestation = ZG.WORLD_ACTIVITY; /* * Create Call subject for the event */ event_template.add_subject ( new Subject.full ( "", - NFO_AUDIO, - NFO_MEDIA_STREAM, + NFO.AUDIO, + NFO.MEDIA_STREAM, "x-telepathy/call", this.tp_identifier.printf (target.get_identifier ()), target.get_alias (), @@ -233,8 +240,8 @@ public class TelepathyObserver : DataProvider event_template.add_subject ( new Subject.full ( this.tp_identifier.printf(target.get_identifier ()), - NCO_CONTACT, - NCO_CONTACT_LIST_DATA_OBJECT, + NCO.CONTACT, + NCO.CONTACT_LIST_DATA_OBJECT, "", obj_path, target.get_alias (), @@ -267,7 +274,7 @@ public class TelepathyObserver : DataProvider */ if (state == TelepathyGLib.CallState.INITIALISED) { - event_template.set_interpretation (ZG_CREATE_EVENT); + event_template.interpretation = ZG.CREATE_EVENT; Timer t = new Timer (); t.stop (); call_timers.insert (channel.get_object_path (), (owned) t); @@ -281,27 +288,27 @@ public class TelepathyObserver : DataProvider { if (state == TelepathyGLib.CallState.ACTIVE) { - event_template.set_interpretation (ZG_ACCESS_EVENT); + event_template.interpretation = ZG.ACCESS_EVENT; call_timers.lookup (channel.get_object_path ()).start(); this.push_event (event_template); } else if (state == TelepathyGLib.CallState.ENDED) { - event_template.set_interpretation (ZG_LEAVE_EVENT); + event_template.interpretation = ZG.LEAVE_EVENT; /* Call was created by user but was rejected or not answered */ if (reason.reason == TelepathyGLib.CallStateChangeReason.REJECTED || reason.reason == TelepathyGLib.CallStateChangeReason.NO_ANSWER) { if (channel.requested) - event_template.set_manifestation (ZG_WORLD_ACTIVITY); + event_template.manifestation = ZG.WORLD_ACTIVITY; else - event_template.set_interpretation (ZG_USER_ACTIVITY); + event_template.interpretation = ZG.USER_ACTIVITY; if (reason.reason == TelepathyGLib.CallStateChangeReason.NO_ANSWER) - event_template.set_interpretation (ZG_EXPIRE_EVENT); + event_template.interpretation = ZG.EXPIRE_EVENT; else - event_template.set_interpretation (ZG_DENY_EVENT); + event_template.interpretation = ZG.DENY_EVENT; } var duration = call_timers.lookup (channel.get_object_path ()).elapsed (); @@ -326,7 +333,7 @@ public class TelepathyObserver : DataProvider size_t length; object.set_object_member (call_json_domain, details_obj); string payload_string = gen.to_data(out length); - event_template.set_payload (new GLib.ByteArray.take (payload_string.data)); + event_template.payload = new GLib.ByteArray.take (payload_string.data); this.push_event (event_template); } } @@ -347,7 +354,16 @@ public class TelepathyObserver : DataProvider var target = channel.get_target_contact (); var attr = "%s, %s, %s".printf (FileAttribute.STANDARD_DISPLAY_NAME, FileAttribute.STANDARD_CONTENT_TYPE, FileAttribute.STANDARD_SIZE); - var info = yield channel.file.query_info_async (attr, 0); + FileInfo info = null; + try + { + info = yield channel.file.query_info_async (attr, 0); + } + catch (GLib.Error err) + { + warning ("Couldn't process %s: %s", channel.file.get_path (), err.message); + return; + } var obj_path = account.get_object_path (); obj_path = this.tp_account_path.printf("%s", obj_path [TelepathyGLib.ACCOUNT_OBJECT_PATH_BASE.length: @@ -356,32 +372,32 @@ public class TelepathyObserver : DataProvider var event_template = new Event (); if (channel.requested) { - event_template.set_interpretation (ZG_SEND_EVENT); - event_template.set_manifestation (ZG_USER_ACTIVITY); + event_template.interpretation = ZG.SEND_EVENT; + event_template.manifestation = ZG.USER_ACTIVITY; } else { - event_template.set_interpretation (ZG_RECEIVE_EVENT); - event_template.set_manifestation (ZG_WORLD_ACTIVITY); + event_template.interpretation = ZG.RECEIVE_EVENT; + event_template.manifestation = ZG.WORLD_ACTIVITY; } - event_template.set_actor (this.actor); + event_template.actor = this.actor; /* * Create Subject representing the sent/received file */ var subj = new Subject (); - subj.set_uri (channel.file.get_uri ()); - subj.set_interpretation (interpretation_for_mimetype (info.get_content_type ())); - subj.set_manifestation (NFO_FILE_DATA_OBJECT); - subj.set_text (info.get_display_name ()); - subj.set_mimetype (info.get_content_type ()); + subj.uri = channel.file.get_uri (); + subj.interpretation = interpretation_for_mimetype (info.get_content_type ()); + subj.manifestation = NFO.FILE_DATA_OBJECT; + subj.text = info.get_display_name (); + subj.mimetype = info.get_content_type (); if (channel.requested == true) { var split_uri = channel.file.get_uri ().split ("/"); var uri = "%s/".printf(string.join ("/", split_uri[0:split_uri.length-1])); - subj.set_origin (uri); + subj.origin = uri; } else - subj.set_origin (this.tp_identifier.printf (target.get_identifier ())); + subj.origin = this.tp_identifier.printf (target.get_identifier ()); event_template.add_subject (subj); /* @@ -389,8 +405,8 @@ public class TelepathyObserver : DataProvider */ event_template.add_subject ( new Subject.full (this.tp_identifier.printf(target.get_identifier ()), - NCO_CONTACT, - NCO_CONTACT_LIST_DATA_OBJECT, + NCO.CONTACT, + NCO.CONTACT_LIST_DATA_OBJECT, "", obj_path, target.get_alias (), @@ -416,7 +432,7 @@ public class TelepathyObserver : DataProvider size_t length; object.set_object_member (ft_json_domain, details_obj); string payload_string = gen.to_data (out length); - event_template.set_payload (new GLib.ByteArray.take (payload_string.data)); + event_template.payload = new GLib.ByteArray.take (payload_string.data); this.push_event (event_template); } } @@ -492,8 +508,14 @@ public class TelepathyObserver : DataProvider TelepathyGLib.IFACE_CHANNEL_TYPE_FILE_TRANSFER); ft_filter.insert (TelepathyGLib.PROP_CHANNEL_TARGET_HANDLE_TYPE, 1); // 1 => TP_HANDLE_TYPE_CONTACT, somehow vala fails to compile when using the constant observer.add_observer_filter (ft_filter); - - observer.register (); + try + { + observer.register (); + } + catch (GLib.Error err) + { + warning ("Couldn't register observer: %s", err.message); + } } public override void stop () diff --git a/src/utils.vala b/src/utils.vala index d78414d..998eb2b 100644 --- a/src/utils.vala +++ b/src/utils.vala @@ -37,8 +37,15 @@ public class Utils : Object string contents; #if VALA_0_14 uint8[] contents_array; - if (!file.load_contents (null, out contents_array, null)) - return null; + try + { + if (!file.load_contents (null, out contents_array, null)) + return null; + } + catch (Error err) + { + warning ("Couldn't get file contents %s: %s", file.get_path (), err.message); + } contents = (string) contents_array; #else if (!file.load_contents (null, out contents, null, null)) @@ -221,7 +228,7 @@ public class Utils : Object try { var enumerator = - app_dir.enumerate_children (FILE_ATTRIBUTE_STANDARD_NAME, 0, null); + app_dir.enumerate_children (FileAttribute.STANDARD_NAME, 0, null); FileInfo fi = enumerator.next_file (null); while (fi != null) { diff --git a/src/zeitgeist-datahub.vala b/src/zeitgeist-datahub.vala index ab63a10..30152da 100644 --- a/src/zeitgeist-datahub.vala +++ b/src/zeitgeist-datahub.vala @@ -55,7 +55,7 @@ public class DataHub : Object, DataHubService zg_log = new Zeitgeist.Log (); zg_log.notify["connected"].connect (() => { - if (!zg_log.is_connected ()) + if (!zg_log.is_connected) { debug ("Zeitgeist-daemon disappeared from the bus, exitting..."); quit (); @@ -70,7 +70,7 @@ public class DataHub : Object, DataHubService unowned List<DataSource> iter = sources_info; while (iter != null) { - if (iter.data.get_unique_id () == ds.get_unique_id ()) + if (iter.data.unique_id == ds.unique_id) { break; } @@ -93,9 +93,9 @@ public class DataHub : Object, DataHubService { registry.source_registered.connect (data_source_registered); var sources = yield registry.get_data_sources (null); - for (uint i=0; i<sources.len; i++) + for (uint i=0; i<sources.length; i++) { - sources_info.prepend (sources.index (i) as DataSource); + sources_info.prepend (sources.get (i) as DataSource); } } catch (GLib.Error err) @@ -131,9 +131,9 @@ public class DataHub : Object, DataHubService int64 timestamp = 0; foreach (var src in sources_info) { - if (src.get_unique_id () == prov.unique_id) + if (src.unique_id == prov.unique_id) { - timestamp = src.get_timestamp (); + timestamp = src.timestamp; break; } } @@ -143,7 +143,7 @@ public class DataHub : Object, DataHubService var ds = new DataSource.full (prov.unique_id, prov.name, prov.description, - new PtrArray ()); // FIXME: templates! + new GenericArray<Event> ()); // FIXME: templates! try { enabled = yield registry.register_data_source (ds, null); @@ -197,14 +197,12 @@ public class DataHub : Object, DataHubService while (all_events.length > 0) { uint elements_pushed = uint.min ((uint) all_events.length, 100); - PtrArray ptr_arr = new PtrArray.with_free_func (Object.unref); - // careful here, the ptr array does ref_sink on the events - // inside Log.insert_events + GenericArray<Event> ptr_arr = new GenericArray<Event> (); for (uint i=0; i<elements_pushed; i++) ptr_arr.add (all_events[i]); try { - yield zg_log.insert_events_from_ptrarray ((owned) ptr_arr, null); + yield zg_log.insert_events_from_ptrarray (ptr_arr, null); } catch (GLib.Error err) { @@ -247,15 +245,15 @@ public class DataHub : Object, DataHubService string[] actors = {}; foreach (unowned DataSource src in sources_info) { - if (only_enabled && !src.is_enabled ()) continue; - unowned PtrArray template_arr = src.get_event_templates (); + if (only_enabled && !src.enabled) continue; + var template_arr = src.event_templates; if (template_arr != null) { - for (uint i=0; i<template_arr.len; i++) + for (uint i=0; i<template_arr.length; i++) { - unowned Zeitgeist.Event event_template = - template_arr.index (i) as Zeitgeist.Event; - unowned string? actor = event_template.get_actor (); + Zeitgeist.Event event_template = + template_arr.get (i) as Zeitgeist.Event; + string? actor = event_template.actor; if (actor != null && actor != "") { |