diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2014-02-21 12:11:43 +0100 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2014-02-27 15:37:58 +0100 |
commit | 19e99ccc8bbf4b1d99849f2f8e8fcb517743050b (patch) | |
tree | 0a623adee98222df6fd90109fedc84fe1c71dd2e | |
parent | 996076ea780a05b996e37e46408e3f6f71e0d996 (diff) |
use vardict API to interact and request channels
-rw-r--r-- | libempathy-gtk/empathy-call-utils.c | 32 | ||||
-rw-r--r-- | libempathy-gtk/empathy-call-utils.h | 2 | ||||
-rw-r--r-- | libempathy-gtk/empathy-chat.c | 18 | ||||
-rw-r--r-- | libempathy-gtk/empathy-log-window.c | 16 | ||||
-rw-r--r-- | libempathy-gtk/empathy-share-my-desktop.c | 23 | ||||
-rw-r--r-- | libempathy/empathy-auth-factory.c | 34 | ||||
-rw-r--r-- | libempathy/empathy-chatroom-manager.c | 10 | ||||
-rw-r--r-- | libempathy/empathy-ft-factory.c | 11 | ||||
-rw-r--r-- | libempathy/empathy-ft-handler.c | 59 | ||||
-rw-r--r-- | libempathy/empathy-request-util.c | 22 | ||||
-rw-r--r-- | libempathy/empathy-tp-chat.c | 30 | ||||
-rw-r--r-- | src/empathy-call-factory.c | 50 | ||||
-rw-r--r-- | src/empathy-call-handler.c | 3 | ||||
-rw-r--r-- | src/empathy-call-observer.c | 11 | ||||
-rw-r--r-- | src/empathy-chat-manager.c | 28 | ||||
-rw-r--r-- | src/empathy-event-manager.c | 48 |
16 files changed, 182 insertions, 215 deletions
diff --git a/libempathy-gtk/empathy-call-utils.c b/libempathy-gtk/empathy-call-utils.c index 47dec88d..2e6e5bc9 100644 --- a/libempathy-gtk/empathy-call-utils.c +++ b/libempathy-gtk/empathy-call-utils.c @@ -71,30 +71,30 @@ show_call_error (GError *error) gtk_widget_show (dialog); } -GHashTable * +GVariant * empathy_call_create_call_request (const gchar *contact, gboolean initial_audio, gboolean initial_video) { - GHashTable *asv = tp_asv_new ( - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, - TP_IFACE_CHANNEL_TYPE_CALL1, - TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT, - TP_ENTITY_TYPE_CONTACT, - TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING, - contact, - NULL); + GVariantDict dict; + + g_variant_dict_init (&dict, NULL); + g_variant_dict_insert (&dict, TP_PROP_CHANNEL_CHANNEL_TYPE, "s", + TP_IFACE_CHANNEL_TYPE_CALL1); + g_variant_dict_insert (&dict, TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, "u", + TP_ENTITY_TYPE_CONTACT); + g_variant_dict_insert (&dict, TP_PROP_CHANNEL_TARGET_ID, "s", contact); /* Only add InitialAudio or InitialVideo if they are true: it should work * with genuinely voice-only CMs. */ if (initial_audio) - tp_asv_set_boolean (asv, TP_PROP_CHANNEL_TYPE_CALL1_INITIAL_AUDIO, - initial_audio); + g_variant_dict_insert (&dict, TP_PROP_CHANNEL_TYPE_CALL1_INITIAL_AUDIO, "b", + initial_audio); if (initial_video) - tp_asv_set_boolean (asv, TP_PROP_CHANNEL_TYPE_CALL1_INITIAL_VIDEO, - initial_video); + g_variant_dict_insert (&dict, TP_PROP_CHANNEL_TYPE_CALL1_INITIAL_VIDEO, "b", + initial_video); - return asv; + return g_variant_dict_end (&dict); } static void @@ -121,7 +121,7 @@ call_new_with_streams (const gchar *contact, gboolean initial_video, gint64 timestamp) { - GHashTable *call_request; + GVariant *call_request; TpAccountChannelRequest *call_req; /* Call */ @@ -131,8 +131,6 @@ call_new_with_streams (const gchar *contact, call_req = tp_account_channel_request_new (account, call_request, timestamp); - g_hash_table_unref (call_request); - tp_account_channel_request_create_channel_async (call_req, EMPATHY_CALL_TP_BUS_NAME, NULL, create_call_channel_cb, NULL); diff --git a/libempathy-gtk/empathy-call-utils.h b/libempathy-gtk/empathy-call-utils.h index 788d828f..2e099f16 100644 --- a/libempathy-gtk/empathy-call-utils.h +++ b/libempathy-gtk/empathy-call-utils.h @@ -32,7 +32,7 @@ void empathy_call_new_with_streams (const gchar *contact, gboolean initial_video, gint64 timestamp); -GHashTable * empathy_call_create_call_request (const gchar *contact, +GVariant * empathy_call_create_call_request (const gchar *contact, gboolean initial_audio, gboolean initial_video); diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index 19e1dbc3..6cf9b1e2 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -844,16 +844,17 @@ chat_command_msg_internal (EmpathyChat *chat, EmpathyChatPriv *priv = GET_PRIV (chat); ChatCommandMsgData *data; TpAccountChannelRequest *req; - GHashTable *request; + GVariantDict dict; - request = tp_asv_new ( - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_TEXT, - TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT, TP_ENTITY_TYPE_CONTACT, - TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING, contact_id, - NULL); + g_variant_dict_init (&dict, NULL); + g_variant_dict_insert (&dict, TP_PROP_CHANNEL_CHANNEL_TYPE, "s", + TP_IFACE_CHANNEL_TYPE_TEXT); + g_variant_dict_insert (&dict, TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, "u", + TP_ENTITY_TYPE_CONTACT); + g_variant_dict_insert (&dict, TP_PROP_CHANNEL_TARGET_ID, "s", contact_id); - req = tp_account_channel_request_new (priv->account, request, - empathy_get_current_action_time ()); + req = tp_account_channel_request_new (priv->account, + g_variant_dict_end (&dict), empathy_get_current_action_time ()); /* FIXME: We should probably search in members alias. But this * is enough for IRC */ @@ -865,7 +866,6 @@ chat_command_msg_internal (EmpathyChat *chat, EMPATHY_CHAT_TP_BUS_NAME, NULL, chat_command_msg_cb, data); g_object_unref (req); - g_hash_table_unref (request); } static void diff --git a/libempathy-gtk/empathy-log-window.c b/libempathy-gtk/empathy-log-window.c index 17e3731c..60e89036 100644 --- a/libempathy-gtk/empathy-log-window.c +++ b/libempathy-gtk/empathy-log-window.c @@ -1046,16 +1046,12 @@ log_window_create_observer (EmpathyLogWindow *self) self->priv->channels = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, g_object_unref); - tp_base_client_take_observer_filter (self->priv->observer, - tp_asv_new ( - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, - TP_IFACE_CHANNEL_TYPE_TEXT, - NULL)); - tp_base_client_take_observer_filter (self->priv->observer, - tp_asv_new ( - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, - TP_IFACE_CHANNEL_TYPE_CALL1, - NULL)); + tp_base_client_add_observer_filter (self->priv->observer, + g_variant_new_parsed ("{ %s: <%s> }", + TP_PROP_CHANNEL_CHANNEL_TYPE, TP_IFACE_CHANNEL_TYPE_TEXT)); + tp_base_client_add_observer_filter (self->priv->observer, + g_variant_new_parsed ("{ %s: <%s> }", + TP_PROP_CHANNEL_CHANNEL_TYPE, TP_IFACE_CHANNEL_TYPE_CALL1)); tp_base_client_register (self->priv->observer, NULL); diff --git a/libempathy-gtk/empathy-share-my-desktop.c b/libempathy-gtk/empathy-share-my-desktop.c index 3be92a9c..a185d87d 100644 --- a/libempathy-gtk/empathy-share-my-desktop.c +++ b/libempathy-gtk/empathy-share-my-desktop.c @@ -45,7 +45,7 @@ void empathy_share_my_desktop_share_with_contact (EmpathyContact *contact) { TpAccountChannelRequest *req; - GHashTable *request; + GVariantDict request; TpContact *tp_contact; tp_contact = empathy_contact_get_tp_contact (contact); @@ -58,22 +58,21 @@ empathy_share_my_desktop_share_with_contact (EmpathyContact *contact) return; } - request = tp_asv_new ( - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, - TP_IFACE_CHANNEL_TYPE_STREAM_TUBE1, - TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT, - TP_ENTITY_TYPE_CONTACT, - TP_PROP_CHANNEL_TARGET_HANDLE, G_TYPE_UINT, - tp_contact_get_handle (tp_contact), - TP_PROP_CHANNEL_TYPE_STREAM_TUBE1_SERVICE, G_TYPE_STRING, "rfb", - NULL); + g_variant_dict_init (&request, NULL); + g_variant_dict_insert (&request, TP_PROP_CHANNEL_CHANNEL_TYPE, "s", + TP_IFACE_CHANNEL_TYPE_STREAM_TUBE1); + g_variant_dict_insert (&request, TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, "u", + TP_ENTITY_TYPE_CONTACT); + g_variant_dict_insert (&request, TP_PROP_CHANNEL_TARGET_HANDLE, "u", + tp_contact_get_handle (tp_contact)); + g_variant_dict_insert (&request, TP_PROP_CHANNEL_TYPE_STREAM_TUBE1_SERVICE, + "s", "rfb"); req = tp_account_channel_request_new (empathy_contact_get_account (contact), - request, TP_USER_ACTION_TIME_CURRENT_TIME); + g_variant_dict_end (&request), TP_USER_ACTION_TIME_CURRENT_TIME); tp_account_channel_request_create_channel_async (req, NULL, NULL, create_tube_channel_cb, NULL); g_object_unref (req); - g_hash_table_unref (request); } diff --git a/libempathy/empathy-auth-factory.c b/libempathy/empathy-auth-factory.c index ecaff1fb..16711cd6 100644 --- a/libempathy/empathy-auth-factory.c +++ b/libempathy/empathy-auth-factory.c @@ -632,22 +632,18 @@ empathy_auth_factory_constructed (GObject *obj) tp_base_client_set_handler_bypass_approval (client, FALSE); /* Handle ServerTLSConnection and ServerAuthentication channels */ - tp_base_client_take_handler_filter (client, tp_asv_new ( - /* ChannelType */ - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, + tp_base_client_add_handler_filter (client, g_variant_new_parsed ( + "{ %s: <%s>, %s: <%u> }", + TP_PROP_CHANNEL_CHANNEL_TYPE, TP_IFACE_CHANNEL_TYPE_SERVER_TLS_CONNECTION1, - /* AuthenticationMethod */ - TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT, - TP_ENTITY_TYPE_NONE, NULL)); + TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, (guint32) TP_ENTITY_TYPE_NONE)); - tp_base_client_take_handler_filter (client, tp_asv_new ( - /* ChannelType */ - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, + tp_base_client_add_handler_filter (client, g_variant_new_parsed ( + "{ %s: <%s>, %s: <%s> }", + TP_PROP_CHANNEL_CHANNEL_TYPE, TP_IFACE_CHANNEL_TYPE_SERVER_AUTHENTICATION1, - /* AuthenticationMethod */ - TP_PROP_CHANNEL_TYPE_SERVER_AUTHENTICATION1_AUTHENTICATION_METHOD, - G_TYPE_STRING, TP_IFACE_CHANNEL_INTERFACE_SASL_AUTHENTICATION1, - NULL)); + TP_PROP_CHANNEL_TYPE_SERVER_AUTHENTICATION1_AUTHENTICATION_METHOD, + TP_IFACE_CHANNEL_INTERFACE_SASL_AUTHENTICATION1)); /* We are also an observer so that we can see new auth channels * popping up and if we have the password already saved to one @@ -656,14 +652,12 @@ empathy_auth_factory_constructed (GObject *obj) * sense. */ /* Observe ServerAuthentication channels */ - tp_base_client_take_observer_filter (client, tp_asv_new ( - /* ChannelType */ - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, + tp_base_client_add_observer_filter (client, g_variant_new_parsed ( + "{ %s: <%s>, %s: <%s> }", + TP_PROP_CHANNEL_CHANNEL_TYPE, TP_IFACE_CHANNEL_TYPE_SERVER_AUTHENTICATION1, - /* AuthenticationMethod */ - TP_PROP_CHANNEL_TYPE_SERVER_AUTHENTICATION1_AUTHENTICATION_METHOD, - G_TYPE_STRING, TP_IFACE_CHANNEL_INTERFACE_SASL_AUTHENTICATION1, - NULL)); + TP_PROP_CHANNEL_TYPE_SERVER_AUTHENTICATION1_AUTHENTICATION_METHOD, + TP_IFACE_CHANNEL_INTERFACE_SASL_AUTHENTICATION1)); tp_base_client_set_observer_delay_approvers (client, TRUE); } diff --git a/libempathy/empathy-chatroom-manager.c b/libempathy/empathy-chatroom-manager.c index adcaacad..41a8da54 100644 --- a/libempathy/empathy-chatroom-manager.c +++ b/libempathy/empathy-chatroom-manager.c @@ -588,12 +588,10 @@ empathy_chatroom_manager_constructor (GType type, priv->observer = tp_simple_observer_new_with_am (priv->account_manager, TRUE, "Empathy.ChatroomManager", TRUE, observe_channel_cb, self, NULL); - tp_base_client_take_observer_filter (priv->observer, tp_asv_new ( - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, - TP_IFACE_CHANNEL_TYPE_TEXT, - TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT, - TP_ENTITY_TYPE_ROOM, - NULL)); + tp_base_client_add_observer_filter (priv->observer, g_variant_new_parsed ( + "{ %s: <%s>, %s: <%u> }", + TP_PROP_CHANNEL_CHANNEL_TYPE, TP_IFACE_CHANNEL_TYPE_TEXT, + TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, (guint32) TP_ENTITY_TYPE_ROOM)); if (!tp_base_client_register (priv->observer, &error)) { diff --git a/libempathy/empathy-ft-factory.c b/libempathy/empathy-ft-factory.c index 003a50c2..ed5bfd5f 100644 --- a/libempathy/empathy-ft-factory.c +++ b/libempathy/empathy-ft-factory.c @@ -194,14 +194,13 @@ empathy_ft_factory_init (EmpathyFTFactory *self) priv->handler = tp_simple_handler_new_with_am (am, FALSE, FALSE, EMPATHY_FT_TP_BUS_NAME_SUFFIX, FALSE, handle_channel_cb, self, NULL); - tp_base_client_take_handler_filter (priv->handler, tp_asv_new ( - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, - TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER1, - TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT, TP_ENTITY_TYPE_CONTACT, + tp_base_client_add_handler_filter (priv->handler, g_variant_new_parsed ( + "{ %s: <%s>, %s: <%u>, %s: <%b> }", + TP_PROP_CHANNEL_CHANNEL_TYPE, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER1, + TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, (guint32) TP_ENTITY_TYPE_CONTACT, /* Only handle *incoming* channels as outgoing FT channels has to be * handled by the requester. */ - TP_PROP_CHANNEL_REQUESTED, G_TYPE_BOOLEAN, FALSE, - NULL)); + TP_PROP_CHANNEL_REQUESTED, FALSE)); g_object_unref (am); } diff --git a/libempathy/empathy-ft-handler.c b/libempathy/empathy-ft-handler.c index a64f557c..c24dcb7f 100644 --- a/libempathy/empathy-ft-handler.c +++ b/libempathy/empathy-ft-handler.c @@ -123,7 +123,7 @@ typedef struct { gboolean use_hash; /* request for the new transfer */ - GHashTable *request; + GVariantDict *request; /* transfer properties */ EmpathyContact *contact; @@ -273,11 +273,7 @@ do_dispose (GObject *object) priv->cancellable = NULL; } - if (priv->request != NULL) - { - g_hash_table_unref (priv->request); - priv->request = NULL; - } + g_clear_pointer (&priv->request, g_variant_dict_unref); G_OBJECT_CLASS (empathy_ft_handler_parent_class)->dispose (object); } @@ -836,12 +832,16 @@ ft_handler_push_to_dispatcher (EmpathyFTHandler *handler) EmpathyFTHandlerPriv *priv = GET_PRIV (handler); TpAccountChannelRequest *req; + g_return_if_fail (priv->request != NULL); + DEBUG ("Pushing request to the dispatcher"); account = empathy_contact_get_account (priv->contact); - req = tp_account_channel_request_new (account, priv->request, - priv->user_action_time); + req = tp_account_channel_request_new (account, + g_variant_dict_end (priv->request), priv->user_action_time); + + g_clear_pointer (&priv->request, g_variant_dict_unref); tp_account_channel_request_create_and_handle_channel_async (req, NULL, ft_handler_create_channel_cb, handler); @@ -859,23 +859,24 @@ ft_handler_populate_outgoing_request (EmpathyFTHandler *handler) contact_handle = empathy_contact_get_handle (priv->contact); uri = g_file_get_uri (priv->gfile); - priv->request = tp_asv_new ( - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, - TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER1, - TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT, - TP_ENTITY_TYPE_CONTACT, - TP_PROP_CHANNEL_TARGET_HANDLE, G_TYPE_UINT, - contact_handle, - TP_PROP_CHANNEL_TYPE_FILE_TRANSFER1_CONTENT_TYPE, G_TYPE_STRING, - priv->content_type, - TP_PROP_CHANNEL_TYPE_FILE_TRANSFER1_FILENAME, G_TYPE_STRING, - priv->filename, - TP_PROP_CHANNEL_TYPE_FILE_TRANSFER1_SIZE, G_TYPE_UINT64, - priv->total_bytes, - TP_PROP_CHANNEL_TYPE_FILE_TRANSFER1_DATE, G_TYPE_UINT64, - priv->mtime, - TP_PROP_CHANNEL_TYPE_FILE_TRANSFER1_URI, G_TYPE_STRING, uri, - NULL); + priv->request = g_variant_dict_new (NULL); + g_variant_dict_insert (priv->request, TP_PROP_CHANNEL_CHANNEL_TYPE, + "s", TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER1); + g_variant_dict_insert (priv->request, TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, + "u", TP_ENTITY_TYPE_CONTACT); + g_variant_dict_insert (priv->request, TP_PROP_CHANNEL_TARGET_HANDLE, + "u", contact_handle); + g_variant_dict_insert (priv->request, + TP_PROP_CHANNEL_TYPE_FILE_TRANSFER1_CONTENT_TYPE, + "s", priv->content_type); + g_variant_dict_insert (priv->request, + TP_PROP_CHANNEL_TYPE_FILE_TRANSFER1_FILENAME, "s", priv->filename); + g_variant_dict_insert (priv->request, + TP_PROP_CHANNEL_TYPE_FILE_TRANSFER1_SIZE, "t", priv->total_bytes); + g_variant_dict_insert (priv->request, + TP_PROP_CHANNEL_TYPE_FILE_TRANSFER1_DATE, "t", priv->mtime); + g_variant_dict_insert (priv->request, TP_PROP_CHANNEL_TYPE_FILE_TRANSFER1_URI, + "s", uri); g_free (uri); } @@ -927,8 +928,8 @@ hash_job_done (gpointer user_data) /* set the checksum in the request... * im.telepathy.v1.Channel.Type.FileTransfer.ContentHash */ - tp_asv_set_string (priv->request, - TP_PROP_CHANNEL_TYPE_FILE_TRANSFER1_CONTENT_HASH, + g_variant_dict_insert (priv->request, + TP_PROP_CHANNEL_TYPE_FILE_TRANSFER1_CONTENT_HASH, "s", g_checksum_get_string (hash_data->checksum)); } @@ -1067,8 +1068,8 @@ ft_handler_read_async_cb (GObject *source, /* FIXME: MD5 is the only ContentHashType supported right now */ hash_data->checksum = g_checksum_new (G_CHECKSUM_MD5); - tp_asv_set_uint32 (priv->request, - TP_PROP_CHANNEL_TYPE_FILE_TRANSFER1_CONTENT_HASH_TYPE, + g_variant_dict_insert (priv->request, + TP_PROP_CHANNEL_TYPE_FILE_TRANSFER1_CONTENT_HASH_TYPE, "s", TP_FILE_HASH_TYPE_MD5); g_signal_emit (handler, signals[HASHING_STARTED], 0); diff --git a/libempathy/empathy-request-util.c b/libempathy/empathy-request-util.c index da770106..17cc037c 100644 --- a/libempathy/empathy-request-util.c +++ b/libempathy/empathy-request-util.c @@ -60,28 +60,28 @@ create_text_channel (TpAccount *account, GAsyncReadyCallback callback, gpointer user_data) { - GHashTable *request; + GVariantDict dict; TpAccountChannelRequest *req; - request = tp_asv_new ( - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, - TP_IFACE_CHANNEL_TYPE_TEXT, - TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT, target_entity_type, - TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING, target_id, - NULL); + g_variant_dict_init (&dict, NULL); + g_variant_dict_insert (&dict, TP_PROP_CHANNEL_CHANNEL_TYPE, "s", + TP_IFACE_CHANNEL_TYPE_TEXT); + g_variant_dict_insert (&dict, TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, "u", + target_entity_type); + g_variant_dict_insert (&dict, TP_PROP_CHANNEL_TARGET_ID, "s", target_id); if (sms_channel) - tp_asv_set_boolean (request, - TP_PROP_CHANNEL_INTERFACE_SMS1_SMS_CHANNEL, TRUE); + g_variant_dict_insert (&dict, + TP_PROP_CHANNEL_INTERFACE_SMS1_SMS_CHANNEL, "b", TRUE); - req = tp_account_channel_request_new (account, request, timestamp); + req = tp_account_channel_request_new (account, g_variant_dict_end (&dict), + timestamp); tp_account_channel_request_set_delegate_to_preferred_handler (req, TRUE); tp_account_channel_request_ensure_channel_async (req, EMPATHY_CHAT_TP_BUS_NAME, NULL, callback ? callback : ensure_text_channel_cb, user_data); - g_hash_table_unref (request); g_object_unref (req); } diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index 70f0925b..b18551cd 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -196,31 +196,34 @@ empathy_tp_chat_add (EmpathyTpChat *self, else if (self->priv->can_upgrade_to_muc) { TpAccountChannelRequest *req; - GHashTable *props; + GVariantDict props; const char *object_path; - GPtrArray channels = { (gpointer *) &object_path, 1 }; + GVariantBuilder channels; const char *invitees[2] = { NULL, }; TpAccount *account; invitees[0] = empathy_contact_get_id (contact); object_path = tp_proxy_get_object_path (self); - props = tp_asv_new ( - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, - TP_IFACE_CHANNEL_TYPE_TEXT, - TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT, - TP_ENTITY_TYPE_NONE, + g_variant_builder_init (&channels, G_VARIANT_TYPE ("ao")); + g_variant_builder_add (&channels, "o", object_path); + + g_variant_dict_init (&props, NULL); + g_variant_dict_insert (&props, TP_PROP_CHANNEL_CHANNEL_TYPE, "s", + TP_IFACE_CHANNEL_TYPE_TEXT); + g_variant_dict_insert (&props, TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, "u", + TP_ENTITY_TYPE_NONE); + g_variant_dict_insert_value (&props, TP_PROP_CHANNEL_INTERFACE_CONFERENCE1_INITIAL_CHANNELS, - TP_ARRAY_TYPE_OBJECT_PATH_LIST, &channels, + g_variant_builder_end (&channels)); + g_variant_dict_insert_value (&props, TP_PROP_CHANNEL_INTERFACE_CONFERENCE1_INITIAL_INVITEE_IDS, - G_TYPE_STRV, invitees, - /* FIXME: InvitationMessage ? */ - NULL); + g_variant_new_strv (invitees, -1)); account = empathy_tp_chat_get_account (self); - req = tp_account_channel_request_new (account, props, - TP_USER_ACTION_TIME_NOT_USER_ACTION); + req = tp_account_channel_request_new (account, + g_variant_dict_end (&props), TP_USER_ACTION_TIME_NOT_USER_ACTION); /* Although this is a MUC, it's anonymous, so CreateChannel is * valid. */ @@ -228,7 +231,6 @@ empathy_tp_chat_add (EmpathyTpChat *self, EMPATHY_CHAT_TP_BUS_NAME, NULL, create_conference_cb, NULL); g_object_unref (req); - g_hash_table_unref (props); } else { diff --git a/src/empathy-call-factory.c b/src/empathy-call-factory.c index 36432d2b..fa5c1fc4 100644 --- a/src/empathy-call-factory.c +++ b/src/empathy-call-factory.c @@ -64,35 +64,27 @@ empathy_call_factory_init (EmpathyCallFactory *obj) { TpBaseClient *client = (TpBaseClient *) obj; - tp_base_client_take_approver_filter (client, tp_asv_new ( - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, - TP_IFACE_CHANNEL_TYPE_CALL1, - TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, - G_TYPE_UINT, TP_ENTITY_TYPE_CONTACT, - NULL)); - - tp_base_client_take_handler_filter (client, tp_asv_new ( - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, - TP_IFACE_CHANNEL_TYPE_CALL1, - TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, - G_TYPE_UINT, TP_ENTITY_TYPE_CONTACT, - NULL)); - - tp_base_client_take_handler_filter (client, tp_asv_new ( - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, - TP_IFACE_CHANNEL_TYPE_CALL1, - TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, - G_TYPE_UINT, TP_ENTITY_TYPE_CONTACT, - TP_PROP_CHANNEL_TYPE_CALL1_INITIAL_AUDIO, G_TYPE_BOOLEAN, TRUE, - NULL)); - - tp_base_client_take_handler_filter (client, tp_asv_new ( - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, - TP_IFACE_CHANNEL_TYPE_CALL1, - TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, - G_TYPE_UINT, TP_ENTITY_TYPE_CONTACT, - TP_PROP_CHANNEL_TYPE_CALL1_INITIAL_VIDEO, G_TYPE_BOOLEAN, TRUE, - NULL)); + tp_base_client_add_approver_filter (client, + g_variant_new_parsed ("{ %s: <%s>, %s: <%u> }", + TP_PROP_CHANNEL_CHANNEL_TYPE, TP_IFACE_CHANNEL_TYPE_CALL1, + TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, TP_ENTITY_TYPE_CONTACT)); + + tp_base_client_add_handler_filter (client, + g_variant_new_parsed ("{ %s: <%s>, %s: <%u> }", + TP_PROP_CHANNEL_CHANNEL_TYPE, TP_IFACE_CHANNEL_TYPE_CALL1, + TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, TP_ENTITY_TYPE_CONTACT)); + + tp_base_client_add_handler_filter (client, + g_variant_new_parsed ("{ %s: <%s>, %s: <%u>, %s: <%b> }", + TP_PROP_CHANNEL_CHANNEL_TYPE, TP_IFACE_CHANNEL_TYPE_CALL1, + TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, TP_ENTITY_TYPE_CONTACT, + TP_PROP_CHANNEL_TYPE_CALL1_INITIAL_AUDIO, TRUE)); + + tp_base_client_add_handler_filter (client, + g_variant_new_parsed ("{ %s: <%s>, %s: <%u>, %s: <%b> }", + TP_PROP_CHANNEL_CHANNEL_TYPE, TP_IFACE_CHANNEL_TYPE_CALL1, + TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, TP_ENTITY_TYPE_CONTACT, + TP_PROP_CHANNEL_TYPE_CALL1_INITIAL_VIDEO, TRUE)); tp_base_client_add_handler_capabilities_varargs (client, TP_TOKEN_CHANNEL_TYPE_CALL1_AUDIO, diff --git a/src/empathy-call-handler.c b/src/empathy-call-handler.c index 1c4939af..46f62c2f 100644 --- a/src/empathy-call-handler.c +++ b/src/empathy-call-handler.c @@ -902,7 +902,7 @@ empathy_call_handler_start_call (EmpathyCallHandler *handler, EmpathyCallHandlerPriv *priv = GET_PRIV (handler); TpAccountChannelRequest *req; TpAccount *account; - GHashTable *request; + GVariant *request; if (priv->call != NULL) { @@ -942,7 +942,6 @@ empathy_call_handler_start_call (EmpathyCallHandler *handler, empathy_call_handler_request_cb, handler); g_object_unref (req); - g_hash_table_unref (request); } /** diff --git a/src/empathy-call-observer.c b/src/empathy-call-observer.c index ef9d163a..ffaa6138 100644 --- a/src/empathy-call-observer.c +++ b/src/empathy-call-observer.c @@ -288,13 +288,10 @@ empathy_call_observer_init (EmpathyCallObserver *self) "Empathy.CallObserver", FALSE, observe_channel, self, NULL); /* Observe Call channels */ - tp_base_client_take_observer_filter (self->priv->observer, - tp_asv_new ( - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, - TP_IFACE_CHANNEL_TYPE_CALL1, - TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT, - TP_ENTITY_TYPE_CONTACT, - NULL)); + tp_base_client_add_observer_filter (self->priv->observer, + g_variant_new_parsed ("{ %s: <%s>, %s: <%u> }", + TP_PROP_CHANNEL_CHANNEL_TYPE, TP_IFACE_CHANNEL_TYPE_CALL1, + TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, (guint32) TP_ENTITY_TYPE_CONTACT)); tp_base_client_set_observer_delay_approvers (self->priv->observer, TRUE); diff --git a/src/empathy-chat-manager.c b/src/empathy-chat-manager.c index 250cd1f2..278af3b3 100644 --- a/src/empathy-chat-manager.c +++ b/src/empathy-chat-manager.c @@ -279,20 +279,20 @@ empathy_chat_manager_init (EmpathyChatManager *self) g_object_unref (am); - tp_base_client_take_handler_filter (priv->handler, tp_asv_new ( - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_TEXT, - TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT, TP_ENTITY_TYPE_CONTACT, - NULL)); - - tp_base_client_take_handler_filter (priv->handler, tp_asv_new ( - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_TEXT, - TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT, TP_ENTITY_TYPE_ROOM, - NULL)); - - tp_base_client_take_handler_filter (priv->handler, tp_asv_new ( - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_TEXT, - TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT, TP_ENTITY_TYPE_NONE, - NULL)); + tp_base_client_add_handler_filter (priv->handler, + g_variant_new_parsed ("{ %s: <%s>, %s: <%u> }", + TP_PROP_CHANNEL_CHANNEL_TYPE, TP_IFACE_CHANNEL_TYPE_TEXT, + TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, TP_ENTITY_TYPE_CONTACT)); + + tp_base_client_add_handler_filter (priv->handler, + g_variant_new_parsed ("{ %s: <%s>, %s: <%u> }", + TP_PROP_CHANNEL_CHANNEL_TYPE, TP_IFACE_CHANNEL_TYPE_TEXT, + TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, TP_ENTITY_TYPE_ROOM)); + + tp_base_client_add_handler_filter (priv->handler, + g_variant_new_parsed ("{ %s: <%s>, %s: <%u> }", + TP_PROP_CHANNEL_CHANNEL_TYPE, TP_IFACE_CHANNEL_TYPE_TEXT, + TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, TP_ENTITY_TYPE_NONE)); if (!tp_base_client_register (priv->handler, &error)) { diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c index 68fed6bb..37cf451f 100644 --- a/src/empathy-event-manager.c +++ b/src/empathy-event-manager.c @@ -1309,34 +1309,28 @@ empathy_event_manager_init (EmpathyEventManager *manager) FALSE, approve_channel, manager, NULL); /* Private text channels */ - tp_base_client_take_approver_filter (priv->approver, - tp_asv_new ( - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_TEXT, - TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT, TP_ENTITY_TYPE_CONTACT, - NULL)); + tp_base_client_add_approver_filter (priv->approver, + g_variant_new_parsed ("{ %s: <%s>, %s: <%u> }", + TP_PROP_CHANNEL_CHANNEL_TYPE, TP_IFACE_CHANNEL_TYPE_TEXT, + TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, (guint32) TP_ENTITY_TYPE_CONTACT)); /* Muc text channels */ - tp_base_client_take_approver_filter (priv->approver, - tp_asv_new ( - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_TEXT, - TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT, TP_ENTITY_TYPE_ROOM, - NULL)); + tp_base_client_add_approver_filter (priv->approver, + g_variant_new_parsed ("{ %s: <%s>, %s: <%u> }", + TP_PROP_CHANNEL_CHANNEL_TYPE, TP_IFACE_CHANNEL_TYPE_TEXT, + TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, (guint32) TP_ENTITY_TYPE_ROOM)); /* File transfer */ - tp_base_client_take_approver_filter (priv->approver, - tp_asv_new ( - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, - TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER1, - TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT, TP_ENTITY_TYPE_CONTACT, - NULL)); + tp_base_client_add_approver_filter (priv->approver, + g_variant_new_parsed ("{ %s: <%s>, %s: <%u> }", + TP_PROP_CHANNEL_CHANNEL_TYPE, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER1, + TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, (guint32) TP_ENTITY_TYPE_CONTACT)); /* Calls */ - tp_base_client_take_approver_filter (priv->approver, - tp_asv_new ( - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, - TP_IFACE_CHANNEL_TYPE_CALL1, - TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, G_TYPE_UINT, TP_ENTITY_TYPE_CONTACT, - NULL)); + tp_base_client_add_approver_filter (priv->approver, + g_variant_new_parsed ("{ %s: <%s>, %s: <%u> }", + TP_PROP_CHANNEL_CHANNEL_TYPE, TP_IFACE_CHANNEL_TYPE_CALL1, + TP_PROP_CHANNEL_TARGET_ENTITY_TYPE, (guint32) TP_ENTITY_TYPE_CONTACT)); /* I don't feel good about doing this, and I'm sorry, but the * capabilities connection feature is added earlier because it's @@ -1352,14 +1346,12 @@ empathy_event_manager_init (EmpathyEventManager *manager) NULL); /* SASL auth channels */ - tp_base_client_take_approver_filter (priv->auth_approver, - tp_asv_new ( - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, + tp_base_client_add_approver_filter (priv->auth_approver, + g_variant_new_parsed ("{ %s: <%s>, %s: <%s> }", + TP_PROP_CHANNEL_CHANNEL_TYPE, TP_IFACE_CHANNEL_TYPE_SERVER_AUTHENTICATION1, TP_PROP_CHANNEL_TYPE_SERVER_AUTHENTICATION1_AUTHENTICATION_METHOD, - G_TYPE_STRING, - TP_IFACE_CHANNEL_INTERFACE_SASL_AUTHENTICATION1, - NULL)); + TP_IFACE_CHANNEL_INTERFACE_SASL_AUTHENTICATION1)); if (!tp_base_client_register (priv->approver, &error)) { |