aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-contact-dialogs.c
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2007-10-21 06:07:28 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2007-10-21 06:07:28 +0800
commit004e78f70d1088c94bdd00e66c96260abe03cae9 (patch)
treecffed793486c9322d189fce6c7691186e10c30f2 /libempathy-gtk/empathy-contact-dialogs.c
parentcdd6455b8cacfbc06363e0f3e9737f7cc6e4b640 (diff)
downloadgsoc2013-empathy-004e78f70d1088c94bdd00e66c96260abe03cae9.tar
gsoc2013-empathy-004e78f70d1088c94bdd00e66c96260abe03cae9.tar.gz
gsoc2013-empathy-004e78f70d1088c94bdd00e66c96260abe03cae9.tar.bz2
gsoc2013-empathy-004e78f70d1088c94bdd00e66c96260abe03cae9.tar.lz
gsoc2013-empathy-004e78f70d1088c94bdd00e66c96260abe03cae9.tar.xz
gsoc2013-empathy-004e78f70d1088c94bdd00e66c96260abe03cae9.tar.zst
gsoc2013-empathy-004e78f70d1088c94bdd00e66c96260abe03cae9.zip
To know if an account is connected, use
2007-10-21 Xavier Claessens <xclaesse@gmail.com> * libempathy-gtk/empathy-account-chooser.c: * libempathy-gtk/empathy-contact-dialogs.c: * libempathy-gtk/empathy-contact-widget.c: * libempathy-gtk/empathy-contact-widget.h: * libempathy-gtk/empathy-accounts-dialog.c: To know if an account is connected, use mission_control_get_connection_status() instead of mission_control_get_connection(). Update account chooser if an account's status changes or if it get removed. Move account chooser filter func for add-contact's window from EmpathyContactWidget to EmpathyContactDialogs. svn path=/trunk/; revision=384
Diffstat (limited to 'libempathy-gtk/empathy-contact-dialogs.c')
-rw-r--r--libempathy-gtk/empathy-contact-dialogs.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/libempathy-gtk/empathy-contact-dialogs.c b/libempathy-gtk/empathy-contact-dialogs.c
index d032eab5a..96895cc2f 100644
--- a/libempathy-gtk/empathy-contact-dialogs.c
+++ b/libempathy-gtk/empathy-contact-dialogs.c
@@ -29,8 +29,11 @@
#include <glade/glade.h>
#include <glib/gi18n.h>
+#include <libmissioncontrol/mission-control.h>
+
#include <libempathy/empathy-contact-manager.h>
#include <libempathy/empathy-contact-list.h>
+#include <libempathy/empathy-utils.h>
#include "empathy-contact-dialogs.h"
#include "empathy-contact-widget.h"
@@ -195,6 +198,11 @@ empathy_contact_information_dialog_show (EmpathyContact *contact,
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
contact_widget,
TRUE, TRUE, 0);
+ if (flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT) {
+ empathy_contact_widget_set_account_filter (contact_widget,
+ empathy_account_chooser_filter_is_connected,
+ NULL);
+ }
g_object_set_data (G_OBJECT (dialog), "contact_widget", contact_widget);
information_dialogs = g_list_prepend (information_dialogs, dialog);
@@ -214,6 +222,37 @@ empathy_contact_information_dialog_show (EmpathyContact *contact,
* New contact dialog
*/
+static gboolean
+can_add_contact_to_account (McAccount *account,
+ gpointer user_data)
+{
+ MissionControl *mc;
+ TelepathyConnectionStatus status;
+ McProfile *profile;
+ const gchar *protocol_name;
+
+ mc = empathy_mission_control_new ();
+ status = mission_control_get_connection_status (mc, account, NULL);
+ g_object_unref (mc);
+ if (status != TP_CONN_STATUS_CONNECTED) {
+ /* Account is disconnected */
+ return FALSE;
+ }
+
+ profile = mc_account_get_profile (account);
+ protocol_name = mc_profile_get_protocol_name (profile);
+ if (strcmp (protocol_name, "local-xmpp") == 0) {
+ /* We can't add accounts to a XMPP LL connection
+ * FIXME: We should inspect the flags of the contact list group interface
+ */
+ g_object_unref (profile);
+ return FALSE;
+ }
+
+ g_object_unref (profile);
+ return TRUE;
+}
+
static void
new_contact_response_cb (GtkDialog *dialog,
gint response,
@@ -279,6 +318,9 @@ empathy_new_contact_dialog_show (GtkWindow *parent)
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
contact_widget,
TRUE, TRUE, 0);
+ empathy_contact_widget_set_account_filter (contact_widget,
+ can_add_contact_to_account,
+ NULL);
new_contact_dialog = dialog;