diff --git a/src/telepathy-observer.vala b/src/telepathy-observer.vala index b80da5d..204fcc3 100644 --- a/src/telepathy-observer.vala +++ b/src/telepathy-observer.vala @@ -71,28 +71,6 @@ public class TelepathyObserver : DataProvider private void push_event (Event event) { - /*stdout.printf("Event:\n"); - stdout.printf(" - timestamp:%s\n", (string)event.get_timestamp ()); - stdout.printf(" - actor:%s\n", event.get_actor ()); - stdout.printf(" - interpretation:%s\n", event.get_interpretation ()); - stdout.printf(" - manifestation:%s\n", event.get_manifestation ()); - stdout.printf(" - origin:%s\n", event.get_origin ()); - stdout.printf(" - subjects:%i\n", event.num_subjects ()); - for (var i=0; i events = new GenericArray (); events.add (event); items_available (events); @@ -105,15 +83,14 @@ public class TelepathyObserver : DataProvider { var target = channel.get_target_contact (); var obj_path = account.get_object_path (); - obj_path = this.tp_account_path.printf(obj_path[TelepathyGLib.ACCOUNT_OBJECT_PATH_BASE.length: - obj_path.length]); + 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, "", this.actor, null, null); - event_template.set_origin (obj_path); /* * Whether user initiated the chat or not @@ -132,20 +109,21 @@ public class TelepathyObserver : DataProvider NMO_IMMESSAGE, NFO_SOFTWARE_SERVICE, "plain/text", - this.tp_identifier.printf(target.get_identifier ()), - "Chat with %s".printf (target.get_alias ()), + this.tp_identifier.printf (target.get_identifier ()), + "", "net") ); + /* * Create Contact subject for the event */ event_template.add_subject ( new Subject.full ( - this.tp_identifier.printf(target.get_identifier ()), + this.tp_identifier.printf (target.get_identifier ()), NCO_CONTACT, NCO_CONTACT_LIST_DATA_OBJECT, "", - this.tp_identifier.printf(target.get_identifier ()), + obj_path, target.get_alias (), "net") ); @@ -159,17 +137,20 @@ public class TelepathyObserver : DataProvider ObserveChannelsContext context) { /* - *Channel has been created + * Channel has been created */ TextChannel channel = (TextChannel) b_channel; var target = channel.get_target_contact (); if (target != null) { /* - * Create an event representing a conversation start + * Create an event representing conversation start */ var event_template = this.create_text_event (account, channel); this.push_event (event_template); + /* + * Process pending messages + */ foreach (var message in channel.get_pending_messages ()) { if (!message.is_delivery_report ()) @@ -179,12 +160,15 @@ public class TelepathyObserver : DataProvider event_template.set_manifestation (ZG_WORLD_ACTIVITY); this.push_event (event_template); } + // FIXME: what about sent messages? what happens with them? } /* - * Connect to an signals representing a conversation end + * Connect to the signal representing conversation end */ channel.invalidated.connect (() => { 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); this.push_event (event_template); }); @@ -216,54 +200,46 @@ public class TelepathyObserver : DataProvider { var targets = channel.get_members (); if (targets == null) - { return null; - } + weak TelepathyGLib.Contact? target = targets.get_keys ().data; + var obj_path = account.get_object_path (); - obj_path = this.tp_account_path.printf(obj_path [TelepathyGLib.ACCOUNT_OBJECT_PATH_BASE.length: - obj_path.length]); + 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, this.actor, null, - obj_path); + null); if (!channel.requested) event_template.set_manifestation (ZG_WORLD_ACTIVITY); - var i = 0; - foreach (var target in targets.get_keys()) - { - if (i == 0) - { - /* - * Create Call subject for the event - */ - event_template.add_subject ( - new Subject.full ( - "", - NFO_AUDIO, - NFO_MEDIA_STREAM, - "x-telepathy/call", - this.tp_identifier.printf (target.get_identifier ()), - target.get_alias (), - "net") - ); - } - /* - * Create Contact subject for the event - */ - event_template.add_subject ( - new Subject.full ( - this.tp_identifier.printf(target.get_identifier ()), - NCO_CONTACT, - NCO_CONTACT_LIST_DATA_OBJECT, - "", - this.tp_identifier.printf(target.get_identifier ()), - target.get_alias (), - "net") - ); - i++; - } + /* + * Create Call subject for the event + */ + event_template.add_subject ( + new Subject.full ( + "", + NFO_AUDIO, + NFO_MEDIA_STREAM, + "x-telepathy/call", + this.tp_identifier.printf (target.get_identifier ()), + target.get_alias (), + "net") + ); + /* + * Create Contact subject for the event + */ + event_template.add_subject ( + new Subject.full ( + this.tp_identifier.printf(target.get_identifier ()), + NCO_CONTACT, + NCO_CONTACT_LIST_DATA_OBJECT, + "", + obj_path, + target.get_alias (), + "net") + ); return event_template; } @@ -278,9 +254,8 @@ public class TelepathyObserver : DataProvider channel.state_changed.connect (() => { CallFlags flags; - HashTable details; TelepathyGLib.CallStateReason reason; - CallState state = channel.get_state (out flags, out details, out reason); + CallState state = channel.get_state (out flags, null, out reason); /* * Create an Event template for call events @@ -333,7 +308,7 @@ public class TelepathyObserver : DataProvider call_timers.lookup (channel.get_object_path ()).stop; call_timers.remove (channel.get_object_path ()); /* - * Create JSoN payload representing the call metadata including + * Create JSON payload representing the call metadata including * duration and termination reasons of the call. */ var gen = new Generator(); @@ -390,7 +365,6 @@ public class TelepathyObserver : DataProvider event_template.set_manifestation (ZG_WORLD_ACTIVITY); } event_template.set_actor (this.actor); - event_template.set_origin (obj_path); /* * Create Subject representing the sent/received file */ @@ -402,7 +376,7 @@ public class TelepathyObserver : DataProvider subj.set_mimetype (info.get_content_type ()); if (channel.requested == true) { - var split_uri = channel.file.get_uri ().split ("/"); + 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); } @@ -418,7 +392,7 @@ public class TelepathyObserver : DataProvider NCO_CONTACT, NCO_CONTACT_LIST_DATA_OBJECT, "", - this.tp_identifier.printf(target.get_identifier ()), + obj_path, target.get_alias (), "net")); /* @@ -499,7 +473,7 @@ public class TelepathyObserver : DataProvider */ HashTable call_filter = new HashTable (str_hash, str_equal); call_filter.insert (TelepathyGLib.PROP_CHANNEL_CHANNEL_TYPE, - TelepathyGLib.IFACE_CHANNEL_TYPE_CALL); + TelepathyGLib.IFACE_CHANNEL_TYPE_CALL); call_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 (call_filter); /* @@ -507,7 +481,7 @@ public class TelepathyObserver : DataProvider */ HashTable text_filter = new HashTable (str_hash, str_equal); text_filter.insert (TelepathyGLib.PROP_CHANNEL_CHANNEL_TYPE, - TelepathyGLib.IFACE_CHANNEL_TYPE_TEXT); + TelepathyGLib.IFACE_CHANNEL_TYPE_TEXT); text_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 (text_filter); /* @@ -515,7 +489,7 @@ public class TelepathyObserver : DataProvider */ HashTable ft_filter = new HashTable (str_hash, str_equal); ft_filter.insert (TelepathyGLib.PROP_CHANNEL_CHANNEL_TYPE, - TelepathyGLib.IFACE_CHANNEL_TYPE_FILE_TRANSFER); + 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);