]> git.0d.be Git - empathy.git/commitdiff
Skip accounts which don't support rooms in "Manage Favorites" dialog
authorChandni Verma <chandniverma2112@gmail.com>
Mon, 3 Jan 2011 15:55:43 +0000 (21:25 +0530)
committerChandni Verma <chandniverma2112@gmail.com>
Mon, 3 Jan 2011 15:55:43 +0000 (21:25 +0530)
Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=603027
libempathy-gtk/empathy-account-chooser.c
libempathy-gtk/empathy-account-chooser.h
src/empathy-chatrooms-window.c
src/empathy-new-chatroom-dialog.c

index f1c0ec6b4e87ace664373999628b4f975d95e1ef..809c2933a6aa178044922507ceed13d2fd1b8661 100644 (file)
@@ -957,6 +957,77 @@ empathy_account_chooser_filter_is_connected (
        callback (is_connected, callback_data);
 }
 
+typedef struct {
+       EmpathyAccountChooserFilterResultCallback callback;
+       gpointer                                  user_data;
+} FilterCallbackData;
+
+static void
+conn_prepared_cb (GObject *conn,
+               GAsyncResult *result,
+               gpointer user_data)
+{
+       FilterCallbackData *data = user_data;
+       GError             *myerr = NULL;
+       TpCapabilities     *caps;
+
+       if (!tp_proxy_prepare_finish (conn, result, &myerr)) {
+               data->callback (FALSE, data->user_data);
+               g_slice_free (FilterCallbackData, data);
+               return;
+       }
+
+       caps = tp_connection_get_capabilities (TP_CONNECTION (conn));
+       data->callback (tp_capabilities_supports_text_chatrooms (caps),
+                       data->user_data);
+
+       g_slice_free (FilterCallbackData, data);
+}
+
+/**
+ * empathy_account_chooser_filter_supports_multichat:
+ * @account: a #TpAccount
+ * @callback: an #EmpathyAccountChooserFilterResultCallback accepting the result
+ * @callback_data: data passed to the @callback
+ * @user_data: user data or %NULL
+ *
+ * An #EmpathyAccountChooserFilterFunc that returns accounts that both
+ * support multiuser text chat and are connected.
+ *
+ * Returns (via the callback) TRUE if @account both supports muc and is connected
+ */
+void
+empathy_account_chooser_filter_supports_chatrooms (
+       TpAccount                                 *account,
+       EmpathyAccountChooserFilterResultCallback  callback,
+       gpointer                                   callback_data,
+       gpointer                                   user_data)
+{
+       TpConnection       *connection;
+       FilterCallbackData *cb_data;
+       GQuark              features[] = { TP_CONNECTION_FEATURE_CAPABILITIES, 0 };
+
+       if (tp_account_get_connection_status (account, NULL) !=
+               TP_CONNECTION_STATUS_CONNECTED) {
+               callback (FALSE, callback_data);
+               return;
+       }
+
+       /* check if CM supports multiuser text chat */
+       connection = tp_account_get_connection (account);
+       if (connection == NULL) {
+               callback (FALSE, callback_data);
+               return;
+       }
+
+       cb_data = g_slice_new0 (FilterCallbackData);
+       cb_data->callback = callback;
+       cb_data->user_data = callback_data;
+
+       tp_proxy_prepare_async (connection, features, conn_prepared_cb,
+               cb_data);
+}
+
 gboolean
 empathy_account_chooser_is_ready (EmpathyAccountChooser *self)
 {
index dfd372c3e9a1bab0448d5062d90c3cff9f1effbe..04e6230bd476662871f683fc3fa777ca0b14a38c 100644 (file)
@@ -91,6 +91,10 @@ void           empathy_account_chooser_filter_is_connected (TpAccount
                                                           EmpathyAccountChooserFilterResultCallback callback,
                                                           gpointer               callback_data,
                                                           gpointer               user_data);
+void           empathy_account_chooser_filter_supports_chatrooms (TpAccount       *account,
+                                                          EmpathyAccountChooserFilterResultCallback callback,
+                                                          gpointer               callback_data,
+                                                          gpointer               user_data);
 gboolean       empathy_account_chooser_is_ready (EmpathyAccountChooser *chooser);
 
 G_END_DECLS
index 35e3e8b9d78b171c35f98b8d96d544a8aba110be..1b00548f52e2a2e6c5ab9c4d824743041ea4a22a 100644 (file)
@@ -139,7 +139,7 @@ empathy_chatrooms_window_show (GtkWindow *parent)
        /* Account chooser for chat rooms */
        window->account_chooser = empathy_account_chooser_new ();
        empathy_account_chooser_set_filter (EMPATHY_ACCOUNT_CHOOSER (window->account_chooser),
-                                           empathy_account_chooser_filter_is_connected,
+                                           empathy_account_chooser_filter_supports_chatrooms,
                                            NULL);
        g_object_set (window->account_chooser,
                      "has-all-option", TRUE,
index 58690d139e750f5585478f983ae2a7c17d6283ec..f0e58c749731b3d8e23d592f6b117a382f977521 100644 (file)
@@ -73,11 +73,6 @@ typedef struct {
        GtkWidget         *viewport_error;
 } EmpathyNewChatroomDialog;
 
-typedef struct {
-  EmpathyAccountChooserFilterResultCallback callback;
-  gpointer                                  user_data;
-} FilterCallbackData;
-
 enum {
        COL_NEED_PASSWORD,
        COL_INVITE_ONLY,
@@ -138,70 +133,6 @@ static void        new_chatroom_dialog_button_close_error_clicked_cb   (GtkButton
 static EmpathyNewChatroomDialog *dialog_p = NULL;
 
 
-static void
-conn_prepared_cb (GObject *conn,
-                 GAsyncResult *result,
-                 gpointer user_data)
-{
-       FilterCallbackData *data = user_data;
-       GError             *myerr = NULL;
-       TpCapabilities     *caps;
-
-       if (!tp_proxy_prepare_finish (conn, result, &myerr)) {
-               data->callback (FALSE, data->user_data);
-               g_slice_free (FilterCallbackData, data);
-       }
-
-       caps = tp_connection_get_capabilities (TP_CONNECTION (conn));
-       data->callback (tp_capabilities_supports_text_chatrooms (caps),
-                       data->user_data);
-
-       g_slice_free (FilterCallbackData, data);
-}
-
-/**
- * empathy_account_chooser_filter_supports_multichat:
- * @account: a #TpAccount
- * @callback: an #EmpathyAccountChooserFilterResultCallback accepting the result
- * @callback_data: data passed to the @callback
- * @user_data: user data or %NULL
- *
- * An #EmpathyAccountChooserFilterFunc that returns accounts that both
- * support multiuser text chat and are connected.
- *
- * Returns (via the callback) TRUE if @account both supports muc and is connected
- */
-static void
-empathy_account_chooser_filter_supports_multichat (
-       TpAccount                                 *account,
-       EmpathyAccountChooserFilterResultCallback  callback,
-       gpointer                                   callback_data,
-       gpointer                                   user_data)
-{
-       TpConnection       *connection;
-       FilterCallbackData *cb_data;
-       GQuark              features[] = { TP_CONNECTION_FEATURE_CAPABILITIES, 0 };
-
-       if (tp_account_get_connection_status (account, NULL) !=
-           TP_CONNECTION_STATUS_CONNECTED) {
-               callback (FALSE, callback_data);
-               return;
-       }
-
-       /* check if CM supports multiuser text chat */
-       connection = tp_account_get_connection (account);
-       if (connection == NULL) {
-               callback (FALSE, callback_data);
-               return;
-       }
-
-       cb_data = g_slice_new0 (FilterCallbackData);
-       cb_data->callback = callback;
-       cb_data->user_data = callback_data;
-        tp_proxy_prepare_async (connection, features, conn_prepared_cb,
-               cb_data);
-}
-
 void
 empathy_new_chatroom_dialog_show (GtkWindow *parent)
 {
@@ -270,7 +201,7 @@ 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,