#include <config.h>
#include <string.h>
-#include <stdio.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <libempathy/empathy-tp-roomlist.h>
#include <libempathy/empathy-chatroom.h>
#include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-dispatcher.h>
+#include <libempathy/empathy-request-util.h>
#include <libempathy-gtk/empathy-account-chooser.h>
#include <libempathy-gtk/empathy-ui-utils.h>
static EmpathyNewChatroomDialog *dialog_p = NULL;
-/**
- * empathy_account_chooser_filter_supports_multichat:
- * @account: a #TpAccount
- * @user_data: user data or %NULL
- *
- * An #EmpathyAccountChooserFilterFunc that returns accounts that both
- * support multiuser text chat and are connected.
- *
- * Return value: TRUE if @account both supports muc and is connected
- */
-static gboolean
-empathy_account_chooser_filter_supports_multichat (TpAccount *account,
- gpointer user_data)
-{
- TpConnection *connection;
- EmpathyDispatcher *dispatcher;
- GList *classes;
-
- if (tp_account_get_connection_status (account, NULL) !=
- TP_CONNECTION_STATUS_CONNECTED)
- return FALSE;
-
- /* check if CM supports multiuser text chat */
- connection = tp_account_get_connection (account);
- if (connection == NULL)
- return FALSE;
-
- dispatcher = empathy_dispatcher_dup_singleton ();
-
- classes = empathy_dispatcher_find_requestable_channel_classes
- (dispatcher, connection, TP_IFACE_CHANNEL_TYPE_TEXT,
- TP_HANDLE_TYPE_ROOM, NULL);
-
- g_object_unref (dispatcher);
-
- if (classes == NULL)
- return FALSE;
-
- g_list_free (classes);
- return TRUE;
-}
void
empathy_new_chatroom_dialog_show (GtkWindow *parent)
/* Account chooser for custom */
dialog->account_chooser = empathy_account_chooser_new ();
empathy_account_chooser_set_filter (EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser),
- empathy_account_chooser_filter_supports_multichat,
+ empathy_account_chooser_filter_supports_chatrooms,
NULL);
gtk_table_attach_defaults (GTK_TABLE (dialog->table_info),
dialog->account_chooser,
static void
new_chatroom_dialog_update_widgets (EmpathyNewChatroomDialog *dialog)
{
- EmpathyAccountChooser *account_chooser;
const gchar *protocol;
- account_chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser);
-
if (dialog->account == NULL)
return;
gboolean listing = FALSE;
gboolean expanded = FALSE;
TpConnection *connection;
- EmpathyDispatcher *dispatcher;
- GList *classes = NULL;
+ TpCapabilities *caps;
if (dialog->room_list) {
g_object_unref (dialog->room_list);
dialog->status_changed_id = g_signal_connect (dialog->account,
"status-changed", G_CALLBACK (account_status_changed_cb), dialog);
- dispatcher = empathy_dispatcher_dup_singleton ();
+ /* empathy_account_chooser_filter_supports_chatrooms ensures that the
+ * account has a connection and CAPABILITIES has been prepared. */
+ g_assert (connection != NULL);
+ g_assert (tp_proxy_is_prepared (connection,
+ TP_CONNECTION_FEATURE_CAPABILITIES));
+ caps = tp_connection_get_capabilities (connection);
- if (connection != NULL) {
- classes = empathy_dispatcher_find_requestable_channel_classes (dispatcher,
- connection, TP_IFACE_CHANNEL_TYPE_ROOM_LIST,
- TP_HANDLE_TYPE_NONE, NULL);
- }
-
- if (classes != NULL) {
+ if (tp_capabilities_supports_room_list (caps, NULL)) {
/* Roomlist channels are supported */
dialog->room_list = empathy_tp_roomlist_new (dialog->account);
- g_list_free (classes);
}
else {
dialog->room_list = NULL;
}
- g_object_unref (dispatcher);
-
if (dialog->room_list) {
g_signal_connect (dialog->room_list, "destroy",
G_CALLBACK (new_chatroom_dialog_roomlist_destroy_cb),
EmpathyChatroom *chatroom,
EmpathyNewChatroomDialog *dialog)
{
- GtkTreeView *view;
- GtkTreeSelection *selection;
GtkListStore *store;
GtkTreeIter iter;
gchar *members;
gchar *tooltip;
const gchar *need_password;
const gchar *invite_only;
+ gchar *tmp;
DEBUG ("New chatroom listed: %s (%s)",
empathy_chatroom_get_name (chatroom),
empathy_chatroom_get_room (chatroom));
/* Add to model */
- view = GTK_TREE_VIEW (dialog->treeview);
- selection = gtk_tree_view_get_selection (view);
store = GTK_LIST_STORE (dialog->model);
members = g_strdup_printf ("%d", empathy_chatroom_get_members_count (chatroom));
+ tmp = g_strdup_printf ("<b>%s</b>", empathy_chatroom_get_name (chatroom));
/* Translators: Room/Join's roomlist tooltip. Parameters are a channel name,
yes/no, yes/no and a number. */
- tooltip = g_strdup_printf (_("<b>%s</b>\nInvite required: %s\nPassword required: %s\nMembers: %s"),
- empathy_chatroom_get_name (chatroom),
+ tooltip = g_strdup_printf (_("%s\nInvite required: %s\nPassword required: %s\nMembers: %s"),
+ tmp,
empathy_chatroom_get_invite_only (chatroom) ? _("Yes") : _("No"),
empathy_chatroom_get_need_password (chatroom) ? _("Yes") : _("No"),
members);
+ g_free (tmp);
invite_only = (empathy_chatroom_get_invite_only (chatroom) ?
GTK_STOCK_INDEX : NULL);
need_password = (empathy_chatroom_get_need_password (chatroom) ?
g_strstrip (room_name);
DEBUG ("Requesting channel for '%s'", room_name);
- empathy_dispatcher_join_muc (account, room_name,
- gtk_get_current_event_time ());
+
+ empathy_join_muc (account, room_name, empathy_get_current_action_time ());
g_free (room_name);
}