From 5dcbaaf03567a2aede850bf17e4d595126ea98b4 Mon Sep 17 00:00:00 2001 From: Danielle Madeley Date: Fri, 11 Dec 2009 16:59:56 +1100 Subject: Add an Invite Participants menu item and make it request the Conf channel --- src/empathy-chat-window.c | 76 ++++++++++++++++++++++++++++++++++++++++++++-- src/empathy-chat-window.ui | 7 +++++ 2 files changed, 81 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index 658e59426..0ed5011df 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -35,8 +35,7 @@ #include #include -#include -#include +#include #include #include @@ -54,6 +53,8 @@ #include #include +#include + #include "empathy-chat-window.h" #include "empathy-about-dialog.h" @@ -818,6 +819,76 @@ chat_window_contacts_toggled_cb (GtkToggleAction *toggle_action, empathy_chat_set_show_contacts (priv->current_chat, active); } +static void +upgrade_to_muc_cb (TpConnection *connection, + gboolean yours, + const char *object_path, + GHashTable *properties, + const GError *error, + gpointer user_data, + GObject *window) +{ + if (error) + { + g_critical ("%s", error->message); + return; + } + + g_print ("GOT CHANNEL! %s\n", object_path); +} + +static void +chat_window_invite_participant_activate_cb (GtkAction *action, + EmpathyChatWindow *window) +{ + EmpathyChatWindowPriv *priv; + EmpathyTpChat *tp_chat; + TpConnection *connection; + TpChannel *channel; + GHashTable *props; + GPtrArray *channels; + char *invitees[3] = { NULL, }; + + g_print ("INVITE PARTICIPANT\n"); + + priv = GET_PRIV (window); + + g_return_if_fail (priv->current_chat != NULL); + + /* FIXME: this is for upgrading a 1-to-1 channel to a MUC, inviting + * a user to a MUC is much easier, and needs to be written */ + + tp_chat = empathy_chat_get_tp_chat (priv->current_chat); + connection = empathy_tp_chat_get_connection (tp_chat); + channel = empathy_tp_chat_get_channel (tp_chat); + + /* Ensure a MUC channel */ + channels = g_ptr_array_sized_new (1); + g_ptr_array_add (channels, (char *) tp_proxy_get_object_path (channel)); + + invitees[0] = (char *) tp_channel_get_identifier (channel); + // invitees[1] = /* FIXME: ask for this */ + + props = tp_asv_new ( + TP_IFACE_CHANNEL ".ChannelType", G_TYPE_STRING, + TP_IFACE_CHANNEL_TYPE_TEXT, + TP_IFACE_CHANNEL ".TargetHandleType", G_TYPE_UINT, + TP_HANDLE_TYPE_NONE, + EMP_IFACE_CHANNEL_INTERFACE_CONFERENCE ".InitialChannels", + TP_ARRAY_TYPE_OBJECT_PATH_LIST, channels, + EMP_IFACE_CHANNEL_INTERFACE_CONFERENCE ".InitialInviteeIDs", + G_TYPE_STRV, invitees, + /* FIXME: InvitationMessage ? */ + NULL); + + /* FIXME: this probably needs to go through EmpathyDispatcher */ + tp_cli_connection_interface_requests_call_ensure_channel ( + connection, -1, props, upgrade_to_muc_cb, NULL, NULL, + G_OBJECT (window)); + + g_hash_table_destroy (props); +} + static void chat_window_close_activate_cb (GtkAction *action, EmpathyChatWindow *window) @@ -1725,6 +1796,7 @@ empathy_chat_window_init (EmpathyChatWindow *window) "menu_conv_clear", "activate", chat_window_clear_activate_cb, "menu_conv_favorite", "toggled", chat_window_favorite_toggled_cb, "menu_conv_toggle_contacts", "toggled", chat_window_contacts_toggled_cb, + "menu_conv_invite_participant", "activate", chat_window_invite_participant_activate_cb, "menu_conv_close", "activate", chat_window_close_activate_cb, "menu_edit", "activate", chat_window_edit_activate_cb, "menu_edit_cut", "activate", chat_window_cut_activate_cb, diff --git a/src/empathy-chat-window.ui b/src/empathy-chat-window.ui index 57326a3e3..88d099c16 100644 --- a/src/empathy-chat-window.ui +++ b/src/empathy-chat-window.ui @@ -38,6 +38,12 @@ _Show Contact List + + + menu_conv_invite_participant + Invite _Participant... + + gtk-close @@ -145,6 +151,7 @@ + -- cgit v1.2.3