diff options
author | Nicolas Dufresne <nicolas.dufresne@collabora.com> | 2012-03-28 15:16:15 -0400 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.com> | 2012-03-28 15:16:15 -0400 |
commit | d834c43aff5c92a9b61723c8812c0cd536542513 (patch) | |
tree | 39c221d6e45e13e38160aef4ea27091692fd0846 | |
parent | fcf24e9575f05d7cdb08a1073d58f36d120ccd79 (diff) | |
download | telepathy-logger-d834c43aff5c92a9b61723c8812c0cd536542513.tar.gz |
Port TplCallChannel to Call1 API
This include a API break in the unstable Call code. Code using the
unstable call log feature will need porting.
-rw-r--r-- | configure.ac | 13 | ||||
-rw-r--r-- | data/Logger.Call.client.in | 4 | ||||
-rw-r--r-- | data/Makefile.am | 2 | ||||
-rw-r--r-- | src/telepathy-logger.c | 8 | ||||
-rw-r--r-- | telepathy-logger/Makefile.am | 27 | ||||
-rw-r--r-- | telepathy-logger/call-channel-internal.h | 4 | ||||
-rw-r--r-- | telepathy-logger/call-channel.c | 412 | ||||
-rw-r--r-- | telepathy-logger/call-event-internal.h | 4 | ||||
-rw-r--r-- | telepathy-logger/call-event.c | 29 | ||||
-rw-r--r-- | telepathy-logger/call-event.h | 9 | ||||
-rw-r--r-- | telepathy-logger/log-store-xml.c | 9 | ||||
-rw-r--r-- | telepathy-logger/observer.c | 6 | ||||
-rw-r--r-- | telepathy-logger/streamed-media-channel.c | 33 | ||||
-rw-r--r-- | telepathy-logger/telepathy-logger.h | 1 | ||||
-rw-r--r-- | tests/dbus/test-tpl-log-store-xml.c | 10 |
15 files changed, 150 insertions, 421 deletions
diff --git a/configure.ac b/configure.ac index 6290051..0600566 100644 --- a/configure.ac +++ b/configure.ac @@ -185,18 +185,6 @@ if test x$enable_debug = xyes; then fi AM_CONDITIONAL([ENABLE_DEBUG], [test "x$enable_debug" = xyes]) -#------------------------------------------------------------ -# Enable Call logging -#------------------------------------------------------------ -AC_ARG_ENABLE(call, - AS_HELP_STRING([--enable-call],[compile with experimental Call logging support]), - enable_call=$enableval, enable_call=no ) - -if test x$enable_call = xyes; then - AC_DEFINE(ENABLE_CALL, [], [Enable Call logging]) -fi -AM_CONDITIONAL([ENABLE_CALL], [test "x$enable_call" = xyes]) - # ----------------------------------------------------------- # Coding style checks # ----------------------------------------------------------- @@ -239,6 +227,5 @@ Configure summary: Bugreporting URL............: ${PACKAGE_BUGREPORT} Public extensions library...: ${enable_public_extensions} Introspection support.......: ${found_introspection} - Call support................: ${enable_call} " diff --git a/data/Logger.Call.client.in b/data/Logger.Call.client.in index 8722162..1dce357 100644 --- a/data/Logger.Call.client.in +++ b/data/Logger.Call.client.in @@ -3,10 +3,10 @@ org.freedesktop.Telepathy.Channel.ChannelType s=org.freedesktop.Telepathy.Channe org.freedesktop.Telepathy.Channel.TargetHandleType u=1 [org.freedesktop.Telepathy.Client.Observer.ObserverChannelFilter 3] -org.freedesktop.Telepathy.Channel.ChannelType s=org.freedesktop.Telepathy.Channel.Type.Call.DRAFT +org.freedesktop.Telepathy.Channel.ChannelType s=org.freedesktop.Telepathy.Channel.Type.Call1 org.freedesktop.Telepathy.Channel.TargetHandleType u=1 [org.freedesktop.Telepathy.Client.Observer.ObserverChannelFilter 4] -org.freedesktop.Telepathy.Channel.ChannelType s=org.freedesktop.Telepathy.Channel.Type.Call.DRAFT +org.freedesktop.Telepathy.Channel.ChannelType s=org.freedesktop.Telepathy.Channel.Type.Call1 org.freedesktop.Telepathy.Channel.TargetHandleType u=2 diff --git a/data/Makefile.am b/data/Makefile.am index 7759e18..1e2d780 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -37,8 +37,6 @@ CLEANFILES = \ Logger.client: $(clientfile_parts) @cp $(top_srcdir)/data/Logger.Observer.client.in $(clientfile_DATA) @cat $(top_srcdir)/data/Logger.Text.client.in >> $(clientfile_DATA) -if ENABLE_CALL @cat $(top_srcdir)/data/Logger.Call.client.in >> $(clientfile_DATA) -endif $(AM_V_GEN)cat $(top_srcdir)/data/Logger.Recover.client.in >> $(clientfile_DATA) diff --git a/src/telepathy-logger.c b/src/telepathy-logger.c index 25df9fe..1b39952 100644 --- a/src/telepathy-logger.c +++ b/src/telepathy-logger.c @@ -28,11 +28,8 @@ #include <telepathy-logger/text-channel-internal.h> #include <telepathy-logger/observer-internal.h> #include <telepathy-logger/dbus-service-internal.h> - -#ifdef ENABLE_CALL #include <telepathy-logger/call-channel-internal.h> #include <telepathy-logger/streamed-media-channel-internal.h> -#endif /* ENABLE_CALL */ #define DEBUG_FLAG TPL_DEBUG_MAIN #include <telepathy-logger/debug-internal.h> @@ -165,16 +162,13 @@ main (int argc, (TplChannelConstructor) _tpl_text_channel_new); DEBUG ("- TplTextChannel registered."); -#ifdef ENABLE_CALL _tpl_channel_factory_add ("org.freedesktop.Telepathy.Channel.Type.StreamedMedia", (TplChannelConstructor) _tpl_streamed_media_channel_new); DEBUG ("- TplStreamedMediaChannel registered."); - _tpl_channel_factory_add ("org.freedesktop.Telepathy.Channel.Type.Call.DRAFT", + _tpl_channel_factory_add ("org.freedesktop.Telepathy.Channel.Type.Call1", (TplChannelConstructor) _tpl_call_channel_new); DEBUG ("- TplCallChannel registered."); -#endif /* ENABLE_CALL */ - observer = _tpl_observer_dup (&error); diff --git a/telepathy-logger/Makefile.am b/telepathy-logger/Makefile.am index 977ee40..4809af4 100644 --- a/telepathy-logger/Makefile.am +++ b/telepathy-logger/Makefile.am @@ -27,26 +27,6 @@ EXTRA_DIST = \ tpl-marshal.list \ $(NULL) -if ENABLE_CALL - -call_headers = call-event.h -call_sources = \ - call-channel.c \ - call-channel-internal.h \ - streamed-media-channel.c \ - streamed-media-channel-internal.h - -else # ENABLE_CALL - -EXTRA_DIST += \ - call-event.h \ - call-channel.c \ - call-channel-internal.h \ - streamed-media-channel.c \ - streamed-media-channel-internal.h - -endif # ENABLE_CALL - LIBTPLdir = $(includedir)/telepathy-logger-0.2/telepathy-logger LIBTPL_HEADERS = \ entity.h \ @@ -54,7 +34,7 @@ LIBTPL_HEADERS = \ log-manager.h \ telepathy-logger.h \ text-event.h \ - $(call_headers) \ + call-event.h \ $(NULL) %-marshal.c: %-marshal.list Makefile.am @@ -107,7 +87,10 @@ libtelepathy_logger_la_SOURCES = \ text-event-internal.h \ util-internal.h \ util.c \ - $(call_sources) \ + call-channel.c \ + call-channel-internal.h \ + streamed-media-channel.c \ + streamed-media-channel-internal.h \ $(NULL) nodist_libtelepathy_logger_la_SOURCES = \ diff --git a/telepathy-logger/call-channel-internal.h b/telepathy-logger/call-channel-internal.h index 1de19e9..a03bfa1 100644 --- a/telepathy-logger/call-channel-internal.h +++ b/telepathy-logger/call-channel-internal.h @@ -47,7 +47,7 @@ typedef enum typedef struct _TplCallChannelPriv TplCallChannelPriv; typedef struct { - TpChannel parent; + TpCallChannel parent; /* private */ TplCallChannelPriv *priv; @@ -55,7 +55,7 @@ typedef struct typedef struct { - TpChannelClass parent_class; + TpCallChannelClass parent_class; } TplCallChannelClass; GType _tpl_call_channel_get_type (void); diff --git a/telepathy-logger/call-channel.c b/telepathy-logger/call-channel.c index 5b0fa12..4aa95fd 100644 --- a/telepathy-logger/call-channel.c +++ b/telepathy-logger/call-channel.c @@ -39,18 +39,6 @@ #define DEBUG_FLAG TPL_DEBUG_CHANNEL #include "debug-internal.h" -#define TPL_IFACE_CHANNEL_TYPE_CALL \ - "org.freedesktop.Telepathy.Channel.Type.Call.DRAFT" -#define TPL_IFACE_QUARK_CHANNEL_TYPE_CALL tpl_get_channel_type_call_interface () - -typedef enum -{ - PENDING_INITIATOR_STATE = 1, - PENDING_RECEIVER_STATE, - ACCEPTED_STATE, - ENDED_STATE, -} CallState; - struct _TplCallChannelPriv { TpAccount *account; @@ -61,35 +49,17 @@ struct _TplCallChannelPriv GTimer *timer; gboolean timer_started; TplEntity *end_actor; - TplCallEndReason end_reason; + TpCallStateChangeReason end_reason; gchar *detailed_end_reason; }; -static TpContactFeature features[3] = { - TP_CONTACT_FEATURE_ALIAS, - TP_CONTACT_FEATURE_PRESENCE, - TP_CONTACT_FEATURE_AVATAR_TOKEN -}; - static void tpl_call_channel_iface_init (TplChannelInterface *iface); G_DEFINE_TYPE_WITH_CODE (TplCallChannel, _tpl_call_channel, - TP_TYPE_CHANNEL, + TP_TYPE_CALL_CHANNEL, G_IMPLEMENT_INTERFACE (TPL_TYPE_CHANNEL, tpl_call_channel_iface_init)) -static GQuark -tpl_get_channel_type_call_interface (void) -{ - static GQuark interface = 0; - - if (G_UNLIKELY (interface == 0)) - interface = g_quark_from_static_string (TPL_IFACE_CHANNEL_TYPE_CALL); - - return interface; -} - - static void proxy_prepared_cb (GObject *source, GAsyncResult *result, @@ -137,50 +107,46 @@ pendingproc_prepare_tp_channel (TplActionChain *ctx, static void -get_remote_contacts_cb (TpConnection *connection, - guint n_contacts, - TpContact *const *contacts, - guint n_failed, - const TpHandle *failed, - const GError *error, - gpointer user_data, - GObject *weak_object) +pendingproc_get_contacts (TplActionChain *ctx, + gpointer user_data) { - TpChannel *chan = TP_CHANNEL (weak_object); - TplCallChannelPriv *priv = TPL_CALL_CHANNEL (weak_object)->priv; - TplActionChain *ctx = user_data; - guint i; - - if (error != NULL) - { - DEBUG ("Failed to get remote contacts: %s", error->message); + TplCallChannel *self = _tpl_action_chain_get_object (ctx); + TplCallChannelPriv *priv = self->priv; + TpChannel *chan = TP_CHANNEL (self); + TpConnection *con = tp_channel_borrow_connection (chan); + GHashTable *members; + GHashTableIter iter; + TpHandle handle; + TpHandleType handle_type; + gboolean is_room; + TpContact *contact; + TplEntity *entity; - if (ctx != NULL) - _tpl_action_chain_terminate (ctx, error); - return; - } + /* Get and store entities */ + members = tp_call_channel_get_members (TP_CALL_CHANNEL (self)); - for (i = 0; i < n_contacts; i++) + g_hash_table_iter_init (&iter, members); + while (g_hash_table_iter_next (&iter, (gpointer *) &contact, NULL)) { - TpContact *contact = contacts[i]; - TpHandle handle = tp_contact_get_handle (contact); - + handle = tp_contact_get_handle (contact); g_hash_table_insert (priv->entities, GUINT_TO_POINTER (handle), tpl_entity_new_from_tp_contact (contact, TPL_ENTITY_CONTACT)); } - if (ctx != NULL) - { - TplEntity *target; - TpHandle target_handle; - - target_handle = tp_channel_get_handle (chan, NULL); + /* Identify target */ + handle = tp_channel_get_handle (chan, &handle_type); + is_room = (handle_type == TP_HANDLE_TYPE_ROOM); - target = g_hash_table_lookup (priv->entities, - GUINT_TO_POINTER (target_handle)); + if (is_room) + { + priv->receiver = + tpl_entity_new_from_room_id (tp_channel_get_identifier (chan)); + } + else + { + entity = g_hash_table_lookup (priv->entities, GUINT_TO_POINTER (handle)); - /* Should not happen, but as we never know ... */ - if (target == NULL) + if (entity == NULL) { GError *new_error = NULL; new_error = g_error_new (TPL_CALL_CHANNEL_ERROR, @@ -192,204 +158,58 @@ get_remote_contacts_cb (TpConnection *connection, } if (tp_channel_get_requested (chan)) - priv->receiver = g_object_ref (target); + priv->receiver = g_object_ref (entity); else - priv->sender = g_object_ref (target); - - _tpl_action_chain_continue (ctx); - } -} - - -static void -get_call_members_cb (TpProxy *proxy, - const GValue *value, - const GError *error, - gpointer user_data, - GObject *weak_object) -{ - TplCallChannel *self = TPL_CALL_CHANNEL (weak_object); - TplActionChain *ctx = user_data; - GHashTable *members; - GArray *arr; - GList *it; - TpHandle target; - TpHandleType target_type; - - members = g_value_get_boxed (value); - arr = g_array_new (FALSE, FALSE, sizeof (TpHandle)); - - for (it = g_hash_table_get_keys (members); it != NULL; it = g_list_next (it)) - { - TpHandle remote = GPOINTER_TO_INT (it->data); - g_array_append_val (arr, remote); - } - - /* Get the contact of the TargetHandle */ - target = tp_channel_get_handle (TP_CHANNEL (self), &target_type); - - if (target_type == TP_HANDLE_TYPE_ROOM) - self->priv->receiver = tpl_entity_new_from_room_id ( - tp_channel_get_identifier (TP_CHANNEL (self))); - else if (!g_hash_table_lookup_extended (members, - GINT_TO_POINTER (target), NULL, NULL)) - g_array_append_val (arr, target); - - if (arr->len > 0) - { - TpConnection *tp_conn = tp_channel_borrow_connection (TP_CHANNEL (self)); - - tp_connection_get_contacts_by_handle (tp_conn, - arr->len, (TpHandle *) arr->data, - G_N_ELEMENTS (features), features, get_remote_contacts_cb, ctx, NULL, - G_OBJECT (self)); - - g_array_unref (arr); - } - else - { - g_array_unref (arr); - _tpl_action_chain_continue (ctx); - } -} - - -static void -pendingproc_get_remote_contacts (TplActionChain *ctx, - gpointer user_data) -{ - TplCallChannel *self = _tpl_action_chain_get_object (ctx); - - tp_cli_dbus_properties_call_get (TP_PROXY (self), -1, - TPL_IFACE_CHANNEL_TYPE_CALL, "CallMembers", - get_call_members_cb, ctx, NULL, - G_OBJECT (self)); -} - - -static void -get_self_contact_cb (TpConnection *connection, - guint n_contacts, - TpContact *const *contacts, - guint n_failed, - const TpHandle *failed, - const GError *error, - gpointer user_data, - GObject *weak_object) -{ - TplActionChain *ctx = user_data; - TplCallChannel *tpl_call = _tpl_action_chain_get_object (ctx); - TplChannel *tpl_chan = TPL_CHANNEL (tpl_call); - TpChannel *tp_chan = TP_CHANNEL (tpl_chan); - TplEntity *self; - gboolean is_room = FALSE; - - g_return_if_fail (TPL_IS_CALL_CHANNEL (tpl_call)); - - if (n_failed > 0) - { - TpConnection *tp_conn = tp_channel_borrow_connection (tp_chan); - const gchar *conn_path; - GError *new_error = NULL; - - conn_path = tp_proxy_get_object_path (TP_PROXY (tp_conn)); - - new_error = g_error_new (error->domain, error->code, - "Error resolving self handle for connection %s: %s)", - conn_path, error->message); - - _tpl_action_chain_terminate (ctx, new_error); - g_error_free (new_error); - return; + priv->sender = g_object_ref (entity); } - self = tpl_entity_new_from_tp_contact (contacts[0], TPL_ENTITY_SELF); + /* Get and store self entity */ + contact = tp_channel_group_get_self_contact (chan); + if (contact == NULL) + contact = tp_connection_get_self_contact (con); - if (tpl_call->priv->receiver != NULL) - is_room = (tpl_entity_get_entity_type (tpl_call->priv->receiver) - == TPL_ENTITY_ROOM); + handle = tp_contact_get_handle (contact); + entity = tpl_entity_new_from_tp_contact (contact, TPL_ENTITY_SELF); + g_hash_table_insert (priv->entities, GUINT_TO_POINTER (handle), entity); - if (tp_channel_get_requested (tp_chan) || is_room) - tpl_call->priv->sender = self; + if (tp_channel_get_requested (chan) || is_room) + priv->sender = g_object_ref (entity); else - tpl_call->priv->receiver = self; + priv->receiver = g_object_ref (entity); _tpl_action_chain_continue (ctx); } static void -pendingproc_get_local_contact (TplActionChain *ctx, - gpointer user_data) -{ - TplCallChannel *tpl_media = _tpl_action_chain_get_object (ctx); - TpChannel *chan = TP_CHANNEL (tpl_media); - TpConnection *tp_conn = tp_channel_borrow_connection (chan); - TpHandle my_handle; - - my_handle = tp_channel_group_get_self_handle (chan); - if (my_handle == 0) - my_handle = tp_connection_get_self_handle (tp_conn); - - tp_connection_get_contacts_by_handle (tp_conn, 1, &my_handle, - G_N_ELEMENTS (features), features, get_self_contact_cb, ctx, NULL, - G_OBJECT (tpl_media)); -} - -static TplCallEndReason -tp_to_tpl_end_reason (guint reason) -{ - switch (reason) - { - case 1: - return TPL_CALL_END_REASON_USER_REQUESTED; - case 3: - return TPL_CALL_END_REASON_NO_ANSWER; - case 0: - default: - return TPL_CALL_END_REASON_UNKNOWN; - } -} - - -static void -call_state_changed_cb (DBusGProxy *proxy, - CallState state, - guint flags, - GValueArray *reason, +call_state_changed_cb (TpCallChannel *call, + TpCallState state, + TpCallFlags flags, + TpCallStateReason *reason, GHashTable *details, gpointer user_data) { - static const gchar *reasons[] = { - "Unknown", - "User Requested", - "No Answer" - }; TplCallChannel *self = TPL_CALL_CHANNEL (user_data); TplCallChannelPriv *priv = self->priv; switch (state) { - case ACCEPTED_STATE: + case TP_CALL_STATE_ACCEPTED: { - DEBUG ("Moving to ACCEPTED_STATE, start_time=%li", - time (NULL)); - g_timer_start (priv->timer); - priv->timer_started = TRUE; + if (!priv->timer_started) + { + DEBUG ("Moving to ACCEPTED_STATE, start_time=%li", + time (NULL)); + g_timer_start (priv->timer); + priv->timer_started = TRUE; + } } break; - case ENDED_STATE: + case TP_CALL_STATE_ENDED: { - TpHandle actor = g_value_get_uint ( - g_value_array_get_nth (reason, 0)); - TplCallEndReason end_reason = tp_to_tpl_end_reason ( - g_value_get_uint (g_value_array_get_nth (reason, 1))); - gchar *detailed_reason = g_value_dup_string ( - g_value_array_get_nth (reason, 2)); - priv->end_actor = g_hash_table_lookup (priv->entities, - GUINT_TO_POINTER (actor)); + GUINT_TO_POINTER (reason->actor)); if (priv->end_actor == NULL) priv->end_actor = tpl_entity_new ("unknown", TPL_ENTITY_UNKNOWN, @@ -397,19 +217,19 @@ call_state_changed_cb (DBusGProxy *proxy, else g_object_ref (priv->end_actor); - priv->end_reason = end_reason; + priv->end_reason = reason->reason; - if (detailed_reason == NULL) + if (reason->dbus_reason == NULL) priv->detailed_end_reason = g_strdup (""); else - priv->detailed_end_reason = detailed_reason; + priv->detailed_end_reason = g_strdup (reason->dbus_reason); g_timer_stop (priv->timer); DEBUG ( "Moving to ENDED_STATE, duration=%" G_GINT64_FORMAT " reason=%s details=%s", (gint64) (priv->timer_started ? g_timer_elapsed (priv->timer, NULL) : -1), - reasons[priv->end_reason], + _tpl_call_event_end_reason_to_str(priv->end_reason), priv->detailed_end_reason); } break; @@ -422,57 +242,31 @@ call_state_changed_cb (DBusGProxy *proxy, static void -call_members_changed_cb (DBusGProxy *proxy, - GHashTable *flags_changed, +call_members_changed_cb (TpCallChannel *call, + GHashTable *updates, GArray *removed, + TpCallStateReason reason, gpointer user_data) { - TplCallChannel *self = user_data; - TpChannel *chan = TP_CHANNEL (self); + TplCallChannel *self = TPL_CALL_CHANNEL (call); + TplCallChannelPriv *priv = self->priv; GHashTableIter iter; - gpointer key; - GArray *added; - - added = g_array_new (FALSE, FALSE, sizeof (TpHandle)); - - g_hash_table_iter_init (&iter, flags_changed); - while (g_hash_table_iter_next (&iter, &key, NULL)) - { - TpHandle handle = GPOINTER_TO_INT (key); - g_array_append_val (added, handle); - } + TpContact *contact; - if (added->len > 0) + g_hash_table_iter_init (&iter, updates); + while (g_hash_table_iter_next (&iter, (gpointer *) &contact, NULL)) { - tp_connection_get_contacts_by_handle (tp_channel_borrow_connection (chan), - added->len, (TpHandle *) added->data, - G_N_ELEMENTS (features), features, get_remote_contacts_cb, NULL, NULL, - G_OBJECT (self)); - } - - g_array_unref (added); -} - - -static void -chan_members_changed_cb (TpChannel *chan, - gchar *message, - GArray *added, - GArray *removed, - GArray *local_pending, - GArray *remote_pending, - TpHandle actor, - guint reason, - gpointer user_data) -{ - TplCallChannel *self = user_data; + TpHandle handle = tp_contact_get_handle (contact); + TplEntity *entity = g_hash_table_lookup (priv->entities, + GUINT_TO_POINTER (handle)); - if (added->len > 0) - { - tp_connection_get_contacts_by_handle (tp_channel_borrow_connection (chan), - added->len, (TpHandle *) added->data, - G_N_ELEMENTS (features), features, get_remote_contacts_cb, NULL, NULL, - G_OBJECT (self)); + if (!entity) + { + entity = tpl_entity_new_from_tp_contact (contact, + TPL_ENTITY_CONTACT); + g_hash_table_insert (priv->entities, GUINT_TO_POINTER (handle), + entity); + } } } @@ -548,47 +342,12 @@ pendingproc_connect_signals (TplActionChain *ctx, gpointer user_data) { TplCallChannel *self = _tpl_action_chain_get_object (ctx); - DBusGProxy *proxy; - GError *error = NULL; - - proxy = tp_proxy_borrow_interface_by_id (TP_PROXY (self), - TPL_IFACE_QUARK_CHANNEL_TYPE_CALL, &error); - - if (proxy == NULL) - { - _tpl_action_chain_terminate (ctx, error); - g_error_free (error); - return; - } - - dbus_g_proxy_add_signal (proxy, - "CallStateChanged", - G_TYPE_UINT, - G_TYPE_UINT, - dbus_g_type_get_struct ("GValueArray", - G_TYPE_UINT, - G_TYPE_UINT, - G_TYPE_STRING, - G_TYPE_INVALID), - dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), - G_TYPE_INVALID); - - dbus_g_proxy_add_signal (proxy, - "CallMembersChanged", - dbus_g_type_get_map ("GHashTable", G_TYPE_UINT, G_TYPE_UINT), - DBUS_TYPE_G_UINT_ARRAY, - G_TYPE_INVALID); - - dbus_g_proxy_connect_signal (proxy, - "CallStateChanged", - G_CALLBACK (call_state_changed_cb), self, NULL); - dbus_g_proxy_connect_signal (proxy, - "CallMembersChanged", - G_CALLBACK (call_members_changed_cb), self, NULL); + tp_g_signal_connect_object (self, "state-changed", + G_CALLBACK (call_state_changed_cb), self, 0); - tp_g_signal_connect_object (TP_CHANNEL (self), "group-members-changed", - G_CALLBACK (chan_members_changed_cb), self, 0); + tp_g_signal_connect_object (self, "members-changed", + G_CALLBACK (call_members_changed_cb), self, 0); tp_g_signal_connect_object (TP_CHANNEL (self), "invalidated", G_CALLBACK (channel_invalidated_cb), self, 0); @@ -608,8 +367,7 @@ tpl_call_channel_prepare_async (TplChannel *chan, _tpl_action_chain_append (actions, pendingproc_connect_signals, NULL); _tpl_action_chain_append (actions, pendingproc_prepare_tp_connection, NULL); _tpl_action_chain_append (actions, pendingproc_prepare_tp_channel, NULL); - _tpl_action_chain_append (actions, pendingproc_get_remote_contacts, NULL); - _tpl_action_chain_append (actions, pendingproc_get_local_contact, NULL); + _tpl_action_chain_append (actions, pendingproc_get_contacts, NULL); _tpl_action_chain_continue (actions); } diff --git a/telepathy-logger/call-event-internal.h b/telepathy-logger/call-event-internal.h index f5f37a3..11cf810 100644 --- a/telepathy-logger/call-event-internal.h +++ b/telepathy-logger/call-event-internal.h @@ -39,8 +39,8 @@ struct _TplCallEventClass TplEventClass parent_class; }; -const gchar * _tpl_call_event_end_reason_to_str (TplCallEndReason reason); -TplCallEndReason _tpl_call_event_str_to_end_reason (const gchar *str); +const gchar * _tpl_call_event_end_reason_to_str (TpCallStateChangeReason reason); +TpCallStateChangeReason _tpl_call_event_str_to_end_reason (const gchar *str); G_END_DECLS diff --git a/telepathy-logger/call-event.c b/telepathy-logger/call-event.c index 612d61d..eeca764 100644 --- a/telepathy-logger/call-event.c +++ b/telepathy-logger/call-event.c @@ -53,7 +53,7 @@ struct _TplCallEventPriv { GTimeSpan duration; TplEntity *end_actor; - TplCallEndReason end_reason; + TpCallStateChangeReason end_reason; gchar *detailed_end_reason; }; @@ -67,8 +67,19 @@ enum static const gchar* end_reasons[] = { "unknown", + "progress-made", "user-requested", - "no-answer" + "forwared", + "rejected", + "no-answer", + "invalid-contact", + "permission-denied", + "busy", + "internal-error", + "service-error", + "network-error", + "media-error", + "connectivity-error" }; @@ -167,7 +178,7 @@ static void tpl_call_event_class_init (TplCallEventClass *klass) param_spec = g_param_spec_int ("end-reason", "End Reason", "Reason for wich this call was ended", - 0, G_MAXINT, TPL_CALL_END_REASON_UNKNOWN, + 0, G_MAXINT, TP_CALL_STATE_CHANGE_REASON_UNKNOWN, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); g_object_class_install_property (object_class, PROP_END_REASON, param_spec); @@ -225,13 +236,13 @@ tpl_call_event_get_end_actor (TplCallEvent *self) * tpl_call_event_get_end_reason: * @self: a #TplCallEvent * - * Returns: the same #TplCallEndReason as #TplCallEvent:end-actor property + * Returns: the same #TpCallStateChangeReason as #TplCallEvent:end-reason property */ -TplCallEndReason +TpCallStateChangeReason tpl_call_event_get_end_reason (TplCallEvent *self) { g_return_val_if_fail (TPL_IS_CALL_EVENT (self), - TPL_CALL_END_REASON_UNKNOWN); + TP_CALL_STATE_CHANGE_REASON_UNKNOWN); return self->priv->end_reason; } @@ -254,14 +265,14 @@ tpl_call_event_get_detailed_end_reason (TplCallEvent *self) const gchar * -_tpl_call_event_end_reason_to_str (TplCallEndReason reason) +_tpl_call_event_end_reason_to_str (TpCallStateChangeReason reason) { g_return_val_if_fail (reason < G_N_ELEMENTS (end_reasons), end_reasons[0]); return end_reasons[reason]; } -TplCallEndReason +TpCallStateChangeReason _tpl_call_event_str_to_end_reason (const gchar *str) { guint i; @@ -269,5 +280,5 @@ _tpl_call_event_str_to_end_reason (const gchar *str) if (g_strcmp0 (str, end_reasons[i]) == 0) return i; - return TPL_CALL_END_REASON_UNKNOWN; + return TP_CALL_STATE_CHANGE_REASON_UNKNOWN; } diff --git a/telepathy-logger/call-event.h b/telepathy-logger/call-event.h index 507b77d..85dd890 100644 --- a/telepathy-logger/call-event.h +++ b/telepathy-logger/call-event.h @@ -37,18 +37,11 @@ typedef struct _TplCallEvent TplCallEvent; typedef struct _TplCallEventClass TplCallEventClass; typedef struct _TplCallEventPriv TplCallEventPriv; -typedef enum -{ - TPL_CALL_END_REASON_UNKNOWN = 0, - TPL_CALL_END_REASON_USER_REQUESTED, - TPL_CALL_END_REASON_NO_ANSWER, -} TplCallEndReason; - GType tpl_call_event_get_type (void); GTimeSpan tpl_call_event_get_duration (TplCallEvent *self); TplEntity * tpl_call_event_get_end_actor (TplCallEvent *self); -TplCallEndReason tpl_call_event_get_end_reason (TplCallEvent *self); +TpCallStateChangeReason tpl_call_event_get_end_reason (TplCallEvent *self); const gchar * tpl_call_event_get_detailed_end_reason (TplCallEvent *self); diff --git a/telepathy-logger/log-store-xml.c b/telepathy-logger/log-store-xml.c index ce348b7..907191f 100644 --- a/telepathy-logger/log-store-xml.c +++ b/telepathy-logger/log-store-xml.c @@ -73,12 +73,7 @@ #define LOG_FOOTER \ "</log>\n" -#ifdef ENABLE_CALL #define ALL_SUPPORTED_TYPES (TPL_EVENT_MASK_TEXT | TPL_EVENT_MASK_CALL) -#else -#define ALL_SUPPORTED_TYPES TPL_EVENT_MASK_TEXT -#endif /* ENABLE_CALL */ - #define CONTAINS_ALL_SUPPORTED_TYPES(type_mask) \ (((type_mask) & ALL_SUPPORTED_TYPES) == ALL_SUPPORTED_TYPES) @@ -638,7 +633,7 @@ add_call_event (TplLogStoreXml *self, gchar *actor_avatar = NULL; gchar *actor_id = NULL; gchar *log_str = NULL; - TplCallEndReason reason; + TpCallStateChangeReason reason; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); g_return_val_if_fail (TPL_IS_LOG_STORE_XML (self), FALSE); @@ -1221,7 +1216,7 @@ parse_call_node (TplLogStoreXml *self, gchar *duration_str; gint64 duration = -1; gchar *reason_str; - TplCallEndReason reason = TPL_CALL_END_REASON_UNKNOWN; + TpCallStateChangeReason reason = TP_CALL_STATE_CHANGE_REASON_UNKNOWN; gchar *detailed_reason; time_str = (gchar *) xmlGetProp (node, (const xmlChar *) "time"); diff --git a/telepathy-logger/observer.c b/telepathy-logger/observer.c index 96e44a2..0be6f65 100644 --- a/telepathy-logger/observer.c +++ b/telepathy-logger/observer.c @@ -355,7 +355,6 @@ _tpl_observer_init (TplObserver *self) TP_HANDLE_TYPE_ROOM, NULL)); -#ifdef ENABLE_CALL /* Observe contact stream media channels */ tp_base_client_take_observer_filter (TP_BASE_CLIENT (self), tp_asv_new ( @@ -369,7 +368,7 @@ _tpl_observer_init (TplObserver *self) tp_base_client_take_observer_filter (TP_BASE_CLIENT (self), tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, - "org.freedesktop.Telepathy.Channel.Type.Call.DRAFT", + "org.freedesktop.Telepathy.Channel.Type.Call1", TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, NULL)); @@ -378,11 +377,10 @@ _tpl_observer_init (TplObserver *self) tp_base_client_take_observer_filter (TP_BASE_CLIENT (self), tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, - "org.freedesktop.Telepathy.Channel.Type.Call.DRAFT", + "org.freedesktop.Telepathy.Channel.Type.Call1", TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_ROOM, NULL)); -#endif /* ENABLE_CALL */ tp_base_client_set_observer_recover (TP_BASE_CLIENT (self), TRUE); } diff --git a/telepathy-logger/streamed-media-channel.c b/telepathy-logger/streamed-media-channel.c index 32ba65e..5f03bcf 100644 --- a/telepathy-logger/streamed-media-channel.c +++ b/telepathy-logger/streamed-media-channel.c @@ -57,7 +57,7 @@ struct _TplStreamedMediaChannelPriv gboolean timer_started; CallState state; TplEntity *end_actor; - TplCallEndReason end_reason; + TpCallStateChangeReason end_reason; const gchar *detailed_end_reason; }; @@ -327,40 +327,49 @@ on_group_members_changed_cb (TpChannel *chan, break; case TP_CHANNEL_GROUP_CHANGE_REASON_OFFLINE: + priv->end_reason = TP_CALL_STATE_CHANGE_REASON_NO_ANSWER; priv->detailed_end_reason = TP_ERROR_STR_OFFLINE; break; case TP_CHANNEL_GROUP_CHANGE_REASON_KICKED: + priv->end_reason = TP_CALL_STATE_CHANGE_REASON_USER_REQUESTED; priv->detailed_end_reason = TP_ERROR_STR_CHANNEL_KICKED; break; case TP_CHANNEL_GROUP_CHANGE_REASON_BUSY: + priv->end_reason = TP_CALL_STATE_CHANGE_REASON_BUSY; priv->detailed_end_reason = TP_ERROR_STR_BUSY; break; case TP_CHANNEL_GROUP_CHANGE_REASON_BANNED: + priv->end_reason = TP_CALL_STATE_CHANGE_REASON_USER_REQUESTED; priv->detailed_end_reason = TP_ERROR_STR_CHANNEL_BANNED; break; case TP_CHANNEL_GROUP_CHANGE_REASON_ERROR: + priv->end_reason = TP_CALL_STATE_CHANGE_REASON_NETWORK_ERROR; priv->detailed_end_reason = TP_ERROR_STR_NETWORK_ERROR; break; case TP_CHANNEL_GROUP_CHANGE_REASON_INVALID_CONTACT: + priv->end_reason = TP_CALL_STATE_CHANGE_REASON_INVALID_CONTACT; priv->detailed_end_reason = TP_ERROR_STR_DOES_NOT_EXIST; break; case TP_CHANNEL_GROUP_CHANGE_REASON_NO_ANSWER: + priv->end_reason = TP_CALL_STATE_CHANGE_REASON_NO_ANSWER; priv->detailed_end_reason = TP_ERROR_STR_NO_ANSWER; break; case TP_CHANNEL_GROUP_CHANGE_REASON_PERMISSION_DENIED: + priv->end_reason = TP_CALL_STATE_CHANGE_REASON_PERMISSION_DENIED; priv->detailed_end_reason = TP_ERROR_STR_PERMISSION_DENIED; break; default: g_warning ("Invalid change reason for StreamMedia call ending: %i", reason); + priv->end_reason = TP_CALL_STATE_CHANGE_REASON_UNKNOWN; priv->detailed_end_reason = TP_ERROR_STR_INVALID_ARGUMENT; break; } @@ -372,21 +381,25 @@ on_group_members_changed_cb (TpChannel *chan, * receiver terminates that call before accepting it, and no other * reason was provided. Also, even if the call was not answered, the * spec enforces that the end_reason must be user_requested */ - if (reason == TP_CHANNEL_GROUP_CHANGE_REASON_NONE - && actor == receiver) + if (reason == TP_CHANNEL_GROUP_CHANGE_REASON_NONE) { - priv->end_reason = TPL_CALL_END_REASON_USER_REQUESTED; - priv->detailed_end_reason = TP_ERROR_STR_REJECTED; + if (actor == receiver) + { + priv->end_reason = TP_CALL_STATE_CHANGE_REASON_REJECTED; + priv->detailed_end_reason = TP_ERROR_STR_REJECTED; + } + else + { + priv->end_reason = TP_CALL_STATE_CHANGE_REASON_NO_ANSWER; + } } - else - priv->end_reason = TPL_CALL_END_REASON_NO_ANSWER; break; case ACCEPTED_STATE: - priv->end_reason = TPL_CALL_END_REASON_USER_REQUESTED; - if (reason == TP_CHANNEL_GROUP_CHANGE_REASON_NONE) { + priv->end_reason = TP_CALL_STATE_CHANGE_REASON_USER_REQUESTED; + /* If the SelfHandle is removed from a group for this reason and the * actor is not the SelfHandle, the equivalent D-Bus error is * org.freedesktop.Telepathy.Error.Terminated. If the SelfHandle is @@ -402,7 +415,7 @@ on_group_members_changed_cb (TpChannel *chan, default: /* somethings wrong */ - priv->end_reason = TPL_CALL_END_REASON_UNKNOWN; + priv->end_reason = TP_CALL_STATE_CHANGE_REASON_UNKNOWN; break; } diff --git a/telepathy-logger/telepathy-logger.h b/telepathy-logger/telepathy-logger.h index 0ad4a41..7cedaa6 100644 --- a/telepathy-logger/telepathy-logger.h +++ b/telepathy-logger/telepathy-logger.h @@ -23,6 +23,7 @@ #include <telepathy-logger/entity.h> #include <telepathy-logger/text-event.h> +#include <telepathy-logger/call-event.h> #include <telepathy-logger/event.h> #include <telepathy-logger/log-manager.h> diff --git a/tests/dbus/test-tpl-log-store-xml.c b/tests/dbus/test-tpl-log-store-xml.c index 97843bd..f35b4a7 100644 --- a/tests/dbus/test-tpl-log-store-xml.c +++ b/tests/dbus/test-tpl-log-store-xml.c @@ -755,7 +755,7 @@ test_add_call_event (XmlTestCaseFixture *fixture, /* TplCallEvent */ "duration", (gint64) 1234, "end-actor", me, - "end-reason", TPL_CALL_END_REASON_USER_REQUESTED, + "end-reason", TP_CALL_STATE_CHANGE_REASON_USER_REQUESTED, "detailed-end-reason", TP_ERROR_STR_CANCELLED, NULL); @@ -784,7 +784,7 @@ test_add_call_event (XmlTestCaseFixture *fixture, /* TplCallEvent */ "duration", (gint64) 2345, "end-actor", contact, - "end-reason", TPL_CALL_END_REASON_USER_REQUESTED, + "end-reason", TP_CALL_STATE_CHANGE_REASON_USER_REQUESTED, "detailed-end-reason", TP_ERROR_STR_TERMINATED, NULL); @@ -813,7 +813,7 @@ test_add_call_event (XmlTestCaseFixture *fixture, /* TplCallEvent */ "duration", (gint64) 3456, "end-actor", room, - "end-reason", TPL_CALL_END_REASON_USER_REQUESTED, + "end-reason", TP_CALL_STATE_CHANGE_REASON_USER_REQUESTED, "detailed-end-reason", TP_ERROR_STR_CHANNEL_KICKED, NULL); @@ -842,7 +842,7 @@ test_add_call_event (XmlTestCaseFixture *fixture, /* TplCallEvent */ "duration", (gint64) -1, "end-actor", room, - "end-reason", TPL_CALL_END_REASON_NO_ANSWER, + "end-reason", TP_CALL_STATE_CHANGE_REASON_NO_ANSWER, "detailed-end-reason", "", NULL); @@ -906,10 +906,8 @@ test_exists (XmlTestCaseFixture *fixture, g_assert (_tpl_log_store_exists (fixture->store, account2, user3, TPL_EVENT_MASK_ANY)); -#ifdef ENABLE_CALL g_assert (!_tpl_log_store_exists (fixture->store, account2, user3, TPL_EVENT_MASK_TEXT)); g_assert (_tpl_log_store_exists (fixture->store, account2, user3, TPL_EVENT_MASK_CALL)); -#endif g_object_unref (account1); g_object_unref (account2); |