aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2009-12-21 09:51:02 +0800
committerDanielle Madeley <danielle.madeley@collabora.co.uk>2009-12-21 17:55:03 +0800
commiteb36cae56aec0cd245d693ebf2bcb4ce20fb458b (patch)
tree7a873c4c5b9f6f9221c5809a05f80decbb1b247d /src
parent901c4d9b608d764a894c4a4a9df803c3e06a6ab3 (diff)
downloadgsoc2013-empathy-eb36cae56aec0cd245d693ebf2bcb4ce20fb458b.tar
gsoc2013-empathy-eb36cae56aec0cd245d693ebf2bcb4ce20fb458b.tar.gz
gsoc2013-empathy-eb36cae56aec0cd245d693ebf2bcb4ce20fb458b.tar.bz2
gsoc2013-empathy-eb36cae56aec0cd245d693ebf2bcb4ce20fb458b.tar.lz
gsoc2013-empathy-eb36cae56aec0cd245d693ebf2bcb4ce20fb458b.tar.xz
gsoc2013-empathy-eb36cae56aec0cd245d693ebf2bcb4ce20fb458b.tar.zst
gsoc2013-empathy-eb36cae56aec0cd245d693ebf2bcb4ce20fb458b.zip
Refactor MUC upgrading to be a feature of TpChat->add()
Add a method to be able to tell whether a given TpChat supports you calling add() on it.
Diffstat (limited to 'src')
-rw-r--r--src/empathy-chat-window.c84
1 files changed, 10 insertions, 74 deletions
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index 5e0ad049c..67bf7d9e7 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -39,7 +39,6 @@
#include <libempathy/empathy-contact.h>
#include <libempathy/empathy-message.h>
-#include <libempathy/empathy-dispatcher.h>
#include <libempathy/empathy-chatroom-manager.h>
#include <libempathy/empathy-utils.h>
#include <libempathy/empathy-tp-contact-factory.h>
@@ -55,8 +54,6 @@
#include <libempathy-gtk/empathy-ui-utils.h>
#include <libempathy-gtk/empathy-notify-manager.h>
-#include <extensions/extensions.h>
-
#include "empathy-chat-window.h"
#include "empathy-about-dialog.h"
#include "empathy-invite-participant-dialog.h"
@@ -823,51 +820,6 @@ chat_window_contacts_toggled_cb (GtkToggleAction *toggle_action,
}
static void
-chat_window_upgrade_to_muc (EmpathyChat *chat,
- const char *id)
-{
- EmpathyDispatcher *dispatcher = empathy_dispatcher_dup_singleton ();
- EmpathyTpChat *tp_chat;
- TpConnection *connection;
- TpChannel *channel;
- GHashTable *props;
- GPtrArray *channels;
- char *invitees[3] = { NULL, };
-
- tp_chat = empathy_chat_get_tp_chat (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] = (char *) id;
-
- 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);
-
- /* Although this is a MUC, it's anonymous, so CreateChannel is valid */
- /* props now belongs to EmpathyDispatcher, don't free it */
- empathy_dispatcher_create_channel (dispatcher, connection,
- props, NULL, NULL);
-
- g_ptr_array_free (channels, TRUE);
-
- g_object_unref (dispatcher);
-}
-
-static void
got_contact_cb (EmpathyTpContactFactory *factory,
EmpathyContact *contact,
const GError *error,
@@ -876,13 +828,10 @@ got_contact_cb (EmpathyTpContactFactory *factory,
{
EmpathyTpChat *tp_chat = EMPATHY_TP_CHAT (user_data);
- if (error != NULL)
- {
+ if (error != NULL) {
DEBUG ("Failed: %s", error->message);
return;
- }
- else
- {
+ } else {
empathy_contact_list_add (EMPATHY_CONTACT_LIST (tp_chat),
contact, _("Inviting you to this room"));
}
@@ -913,35 +862,22 @@ chat_window_invite_participant_activate_cb (GtkAction *action,
response = gtk_dialog_run (GTK_DIALOG (dialog));
- if (response == GTK_RESPONSE_ACCEPT)
- {
+ if (response == GTK_RESPONSE_ACCEPT) {
+ TpConnection *connection;
+ EmpathyTpContactFactory *factory;
const char *id;
- TpHandleType handle_type;
id = empathy_contact_selector_dialog_get_selected (
EMPATHY_CONTACT_SELECTOR_DIALOG (dialog), NULL);
if (EMP_STR_EMPTY (id)) goto out;
- tp_channel_get_handle (channel, &handle_type);
-
- if (handle_type == TP_HANDLE_TYPE_CONTACT)
- {
- chat_window_upgrade_to_muc (priv->current_chat, id);
- }
- else
- {
- TpConnection *connection;
- EmpathyTpContactFactory *factory;
+ connection = tp_channel_borrow_connection (channel);
+ factory = empathy_tp_contact_factory_dup_singleton (connection);
- connection = tp_channel_borrow_connection (channel);
- factory = empathy_tp_contact_factory_dup_singleton (connection);
+ empathy_tp_contact_factory_get_from_id (factory, id,
+ got_contact_cb, tp_chat, NULL, NULL);
- empathy_tp_contact_factory_get_from_id (factory, id,
- got_contact_cb, tp_chat, NULL, NULL);
-
-
- g_object_unref (factory);
- }
+ g_object_unref (factory);
}
out: