aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2011-03-09 09:07:38 +0800
committerEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-04-08 18:41:27 +0800
commit14aba73c3467f44f3a4f9b786a82f160e08ffcc4 (patch)
tree233144dc987f1f2bd9dc1ecada87b9efecf0b4c8
parent5d5f9be3cf6033049908b13a4d10768672db94e4 (diff)
downloadgsoc2013-empathy-14aba73c3467f44f3a4f9b786a82f160e08ffcc4.tar
gsoc2013-empathy-14aba73c3467f44f3a4f9b786a82f160e08ffcc4.tar.gz
gsoc2013-empathy-14aba73c3467f44f3a4f9b786a82f160e08ffcc4.tar.bz2
gsoc2013-empathy-14aba73c3467f44f3a4f9b786a82f160e08ffcc4.tar.lz
gsoc2013-empathy-14aba73c3467f44f3a4f9b786a82f160e08ffcc4.tar.xz
gsoc2013-empathy-14aba73c3467f44f3a4f9b786a82f160e08ffcc4.tar.zst
gsoc2013-empathy-14aba73c3467f44f3a4f9b786a82f160e08ffcc4.zip
Move empathy-account-widget-skype into its own file
-rw-r--r--libempathy-gtk/Makefile.am2
-rw-r--r--libempathy-gtk/empathy-account-widget-private.h45
-rw-r--r--libempathy-gtk/empathy-account-widget-skype.c482
-rw-r--r--libempathy-gtk/empathy-account-widget-skype.h34
-rw-r--r--libempathy-gtk/empathy-account-widget.c488
5 files changed, 566 insertions, 485 deletions
diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am
index 38e990c8c..28bfbe07c 100644
--- a/libempathy-gtk/Makefile.am
+++ b/libempathy-gtk/Makefile.am
@@ -35,6 +35,7 @@ libempathy_gtk_handwritten_source = \
empathy-account-widget-irc.c \
empathy-account-widget-private.h \
empathy-account-widget-sip.c \
+ empathy-account-widget-skype.c \
empathy-account-widget.c \
empathy-avatar-chooser.c \
empathy-avatar-image.c \
@@ -97,6 +98,7 @@ libempathy_gtk_headers = \
empathy-account-chooser.h \
empathy-account-widget-irc.h \
empathy-account-widget-sip.h \
+ empathy-account-widget-skype.h \
empathy-account-widget.h \
empathy-avatar-chooser.h \
empathy-avatar-image.h \
diff --git a/libempathy-gtk/empathy-account-widget-private.h b/libempathy-gtk/empathy-account-widget-private.h
index d15aa550d..e0248ace9 100644
--- a/libempathy-gtk/empathy-account-widget-private.h
+++ b/libempathy-gtk/empathy-account-widget-private.h
@@ -26,6 +26,8 @@
#include <glib.h>
#include <gtk/gtk.h>
+#include "empathy-account-widget-irc.h"
+
G_BEGIN_DECLS
struct _EmpathyAccountWidgetUIDetails {
@@ -43,6 +45,49 @@ struct _EmpathyAccountWidgetUIDetails {
gpointer user_data);
};
+typedef struct {
+ EmpathyAccountSettings *settings;
+
+ GtkWidget *table_common_settings;
+ GtkWidget *apply_button;
+ GtkWidget *cancel_button;
+ GtkWidget *entry_password;
+ GtkWidget *spinbutton_port;
+ GtkWidget *enabled_checkbox;
+ GtkWidget *radiobutton_reuse;
+
+ gboolean simple;
+
+ gboolean contains_pending_changes;
+
+ /* An EmpathyAccountWidget can be used to either create an account or
+ * modify it. When we are creating an account, this member is set to TRUE */
+ gboolean creating_account;
+
+ /* whether there are any other real accounts. Necessary so we know whether
+ * it's safe to dismiss this widget in some cases (eg, whether the Cancel
+ * button should be sensitive) */
+ gboolean other_accounts_exist;
+
+ /* if TRUE, the GTK+ destroy signal has been fired and so the widgets
+ * embedded in this account widget can't be used any more
+ * workaround because some async callbacks can be called after the
+ * widget has been destroyed */
+ gboolean destroyed;
+
+ TpAccountManager *account_manager;
+
+ GtkWidget *param_account_widget;
+ GtkWidget *param_password_widget;
+
+ gboolean automatic_change;
+ GtkWidget *remember_password_widget;
+
+ /* Used only for IRC accounts */
+ EmpathyIrcNetworkChooser *irc_network_chooser;
+
+ gboolean dispose_run;
+} EmpathyAccountWidgetPriv;
void empathy_account_widget_handle_params (EmpathyAccountWidget *self,
const gchar *first_widget,
diff --git a/libempathy-gtk/empathy-account-widget-skype.c b/libempathy-gtk/empathy-account-widget-skype.c
new file mode 100644
index 000000000..9d0ae7ccb
--- /dev/null
+++ b/libempathy-gtk/empathy-account-widget-skype.c
@@ -0,0 +1,482 @@
+/*
+ * Copyright (C) 2011 Collabora Ltd.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * Authors: Danielle Madeley <danielle.madeley@collabora.co.uk>
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <glib/gi18n-lib.h>
+
+#include <extensions/extensions.h>
+
+#include <libempathy/empathy-utils.h>
+
+#include "empathy-account-widget-private.h"
+#include "empathy-ui-utils.h"
+
+#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
+#include <libempathy/empathy-debug.h>
+
+#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountWidget)
+
+enum {
+ PS_COL_ENUM_VALUE,
+ PS_COL_DISPLAY_NAME,
+ NUM_PS_COLS
+};
+
+static void
+account_widget_skype_combo_changed_cb (GtkComboBox *combo,
+ EmpathyAccountWidget *self)
+{
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+ const char *prop_name = g_object_get_data (G_OBJECT (combo), "dbus-property");
+ TpConnection *conn;
+ EmpPrivacySetting prop_value;
+ GtkTreeIter iter;
+ GValue value = { 0, };
+
+ gtk_combo_box_get_active_iter (combo, &iter);
+ gtk_tree_model_get (gtk_combo_box_get_model (combo), &iter,
+ PS_COL_ENUM_VALUE, &prop_value,
+ -1);
+
+ DEBUG ("Combo changed: %s", prop_name);
+
+ g_value_init (&value, G_TYPE_UINT);
+ g_value_set_uint (&value, prop_value);
+
+ conn = tp_account_get_connection (
+ empathy_account_settings_get_account (priv->settings));
+ tp_cli_dbus_properties_call_set (conn, -1,
+ EMP_IFACE_CONNECTION_INTERFACE_PRIVACY_SETTINGS,
+ prop_name, &value, NULL, NULL, NULL, NULL);
+
+ g_value_unset (&value);
+}
+
+static void
+account_widget_skype_toggle_changed_cb (GtkToggleButton *toggle,
+ EmpathyAccountWidget *self)
+{
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+ const char *prop_name = g_object_get_data (G_OBJECT (toggle),
+ "dbus-property");
+ TpConnection *conn;
+ GValue value = { 0, };
+
+ DEBUG ("Toggle changed: %s", prop_name);
+
+ g_value_init (&value, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&value, gtk_toggle_button_get_active (toggle));
+
+ conn = tp_account_get_connection (
+ empathy_account_settings_get_account (priv->settings));
+ tp_cli_dbus_properties_call_set (conn, -1,
+ EMP_IFACE_CONNECTION_INTERFACE_PRIVACY_SETTINGS,
+ prop_name, &value, NULL, NULL, NULL, NULL);
+
+ g_value_unset (&value);
+}
+
+static void
+account_widget_skype_set_value (EmpathyAccountWidget *self,
+ GtkWidget *widget,
+ GValue *value)
+{
+ g_return_if_fail (value != NULL);
+
+ if (GTK_IS_COMBO_BOX (widget))
+ {
+ GtkTreeModel *model =
+ gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
+ guint prop_value;
+ GtkTreeIter iter;
+ gboolean valid;
+
+ g_return_if_fail (G_VALUE_HOLDS_UINT (value));
+
+ prop_value = g_value_get_uint (value);
+
+ g_signal_handlers_block_by_func (widget,
+ account_widget_skype_combo_changed_cb, self);
+
+ for (valid = gtk_tree_model_get_iter_first (model, &iter);
+ valid;
+ valid = gtk_tree_model_iter_next (model, &iter))
+ {
+ guint v;
+
+ gtk_tree_model_get (model, &iter,
+ PS_COL_ENUM_VALUE, &v,
+ -1);
+
+ if (v == prop_value)
+ {
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (widget), &iter);
+ break;
+ }
+ }
+
+ g_signal_handlers_unblock_by_func (widget,
+ account_widget_skype_combo_changed_cb, self);
+ }
+ else if (GTK_IS_TOGGLE_BUTTON (widget))
+ {
+ g_return_if_fail (G_VALUE_HOLDS_BOOLEAN (value));
+
+ g_signal_handlers_block_by_func (widget,
+ account_widget_skype_toggle_changed_cb, self);
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget),
+ g_value_get_boolean (value));
+
+ g_signal_handlers_unblock_by_func (widget,
+ account_widget_skype_toggle_changed_cb, self);
+ }
+ else
+ {
+ g_assert_not_reached ();
+ }
+}
+
+static void
+account_widget_build_skype_get_privacy_settings_cb (TpProxy *cm,
+ GHashTable *props,
+ const GError *in_error,
+ gpointer user_data,
+ GObject *weak_obj)
+{
+ EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (weak_obj);
+ GtkBuilder *gui = user_data;
+ guint i;
+
+ static const char *widgets[] = {
+ "allow-text-chats-from",
+ "allow-skype-calls-from",
+ "allow-outside-calls-from",
+ "show-my-avatar-to",
+ "show-my-web-status"
+ };
+
+ if (in_error != NULL)
+ {
+ GtkWidget *table, *infobar, *label;
+
+ DEBUG ("Failed to get properties: %s", in_error->message);
+
+ table = GTK_WIDGET (gtk_builder_get_object (gui,
+ "privacy-settings-table"));
+ gtk_widget_set_sensitive (table, FALSE);
+
+ infobar = gtk_info_bar_new ();
+ gtk_box_pack_start (
+ GTK_BOX (gtk_builder_get_object (gui, "privacy-settings-vbox")),
+ infobar, FALSE, TRUE, 0);
+ gtk_info_bar_set_message_type (GTK_INFO_BAR (infobar), GTK_MESSAGE_ERROR);
+ label = gtk_label_new (_("Failed to retrieve privacy settings."));
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_container_add (GTK_CONTAINER (
+ gtk_info_bar_get_content_area (GTK_INFO_BAR (infobar))),
+ label);
+ gtk_widget_show (label);
+
+ return;
+ }
+
+ for (i = 0; i < G_N_ELEMENTS (widgets); i++)
+ {
+ GtkWidget *widget = GTK_WIDGET (gtk_builder_get_object (gui, widgets[i]));
+ const char *prop_name = g_object_get_data (G_OBJECT (widget),
+ "dbus-property");
+
+ DEBUG ("Widget '%s' (%s), prop = %s",
+ widgets[i], G_OBJECT_TYPE_NAME (widget), prop_name);
+
+ account_widget_skype_set_value (self, widget,
+ g_hash_table_lookup (props, prop_name));
+ }
+}
+
+static void
+account_widget_skype_properties_changed_cb (TpProxy *conn,
+ const char *interface,
+ GHashTable *props,
+ const char **invalidated,
+ gpointer user_data,
+ GObject *weak_obj)
+{
+ EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (weak_obj);
+ GtkWidget *table = user_data;
+ GHashTableIter iter;
+ const char *prop;
+ GValue *value;
+
+ g_hash_table_iter_init (&iter, props);
+ while (g_hash_table_iter_next (&iter, (gpointer) &prop, (gpointer) &value))
+ {
+ GList *children, *ptr;
+
+ DEBUG ("Property changed: %s", prop);
+
+ /* find this value in the widget tree */
+ children = gtk_container_get_children (GTK_CONTAINER (table));
+
+ for (ptr = children; ptr != NULL; ptr = ptr->next)
+ {
+ GtkWidget *widget = ptr->data;
+ const char *prop_name = g_object_get_data (G_OBJECT (widget),
+ "dbus-property");
+
+ if (!tp_strdiff (prop_name, prop))
+ {
+ DEBUG ("Got child %p (%s)", widget, G_OBJECT_TYPE_NAME (widget));
+
+ account_widget_skype_set_value (self, widget, value);
+ break;
+ }
+ }
+
+ g_list_free (children);
+ }
+}
+
+/**
+ * account_widget_build_skype_setup_combo:
+ * @gui:
+ * @widget:
+ * @first_option: a list of options from the enum, terminated by -1
+ */
+static void
+account_widget_build_skype_setup_combo (EmpathyAccountWidget *self,
+ GtkBuilder *gui,
+ const char *widget,
+ const char *prop_name,
+ int first_option,
+ ...)
+{
+ GtkWidget *combo;
+ GtkListStore *store;
+ va_list var_args;
+ int option;
+
+ static const char *options[NUM_EMP_PRIVACY_SETTINGS] = {
+ N_("Nobody"),
+ N_("Contacts"),
+ N_("Anyone"),
+ N_("Known Numbers")
+ };
+
+ combo = GTK_WIDGET (gtk_builder_get_object (gui, widget));
+
+ g_return_if_fail (combo != NULL);
+
+ store = gtk_list_store_new (NUM_PS_COLS,
+ G_TYPE_UINT, /* PS_COL_ENUM_VALUE */
+ G_TYPE_STRING /* PS_COL_DISPLAY_NAME */
+ );
+ gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (store));
+
+ va_start (var_args, first_option);
+
+ for (option = first_option; option != -1; option = va_arg (var_args, int))
+ {
+ gtk_list_store_insert_with_values (store, NULL, -1,
+ PS_COL_ENUM_VALUE, option,
+ PS_COL_DISPLAY_NAME, gettext(options[option]),
+ -1);
+ }
+
+ va_end (var_args);
+
+ g_object_set_data (G_OBJECT (combo), "dbus-property", (gpointer) prop_name);
+ g_signal_connect (combo, "changed",
+ G_CALLBACK (account_widget_skype_combo_changed_cb), self);
+}
+
+static void
+account_widget_skype_privacy_settings (GtkWidget *button,
+ EmpathyAccountWidget *self)
+{
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+ TpConnection *conn;
+ char *filename;
+ GtkBuilder *gui;
+ GtkWidget *dialog, *show_my_web_status, *table, *vbox;
+ GtkWidget *toplevel, *infobar, *label;
+
+ DEBUG ("Loading privacy settings");
+
+ filename = empathy_file_lookup ("empathy-account-widget-skype.ui",
+ "libempathy-gtk");
+ gui = empathy_builder_get_file (filename,
+ "privacy-settings-dialog", &dialog,
+ "privacy-settings-table", &table,
+ "privacy-settings-vbox", &vbox,
+ "show-my-web-status", &show_my_web_status,
+ NULL);
+
+ toplevel = gtk_widget_get_toplevel (self->ui_details->widget);
+ if (gtk_widget_is_toplevel (toplevel) && GTK_IS_WINDOW (toplevel))
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (toplevel));
+
+ /* make the settings insensitive when the account is disconnected */
+ tp_account_bind_connection_status_to_property (
+ empathy_account_settings_get_account (priv->settings),
+ table, "sensitive", FALSE);
+
+ /* set up an informative info bar */
+ infobar = gtk_info_bar_new ();
+ gtk_box_pack_start (GTK_BOX (vbox), infobar, FALSE, TRUE, 0);
+ gtk_info_bar_set_message_type (GTK_INFO_BAR (infobar), GTK_MESSAGE_INFO);
+ label = gtk_label_new (_("Privacy settings can only be changed while the "
+ "account is connected."));
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_container_add (
+ GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (infobar))),
+ label);
+ gtk_widget_show (label);
+ g_object_bind_property (table, "sensitive", infobar, "visible",
+ G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN);
+
+ account_widget_build_skype_setup_combo (self, gui,
+ "allow-text-chats-from", "AllowTextChannelsFrom",
+ EMP_PRIVACY_SETTING_ANYONE,
+ EMP_PRIVACY_SETTING_CONTACTS,
+ -1);
+ account_widget_build_skype_setup_combo (self, gui,
+ "allow-skype-calls-from", "AllowCallChannelsFrom",
+ EMP_PRIVACY_SETTING_ANYONE,
+ EMP_PRIVACY_SETTING_CONTACTS,
+ -1);
+ account_widget_build_skype_setup_combo (self, gui,
+ "allow-outside-calls-from", "AllowOutsideCallsFrom",
+ EMP_PRIVACY_SETTING_ANYONE,
+ EMP_PRIVACY_SETTING_KNOWN_NUMBERS,
+ EMP_PRIVACY_SETTING_CONTACTS,
+ -1);
+ account_widget_build_skype_setup_combo (self, gui,
+ "show-my-avatar-to", "ShowMyAvatarTo",
+ EMP_PRIVACY_SETTING_ANYONE,
+ EMP_PRIVACY_SETTING_CONTACTS,
+ -1);
+
+ g_object_set_data (G_OBJECT (show_my_web_status), "dbus-property",
+ "ShowMyWebStatus");
+ g_signal_connect (show_my_web_status, "toggled",
+ G_CALLBACK (account_widget_skype_toggle_changed_cb), self);
+
+ /* get the current parameter values from psyke */
+ conn = tp_account_get_connection (
+ empathy_account_settings_get_account (priv->settings));
+
+ tp_cli_dbus_properties_call_get_all (conn, -1,
+ EMP_IFACE_CONNECTION_INTERFACE_PRIVACY_SETTINGS,
+ account_widget_build_skype_get_privacy_settings_cb,
+ g_object_ref (gui), g_object_unref,
+ G_OBJECT (self));
+ tp_cli_dbus_properties_connect_to_properties_changed (conn,
+ account_widget_skype_properties_changed_cb,
+ table, NULL, G_OBJECT (self), NULL);
+
+ g_object_unref (gui);
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+}
+
+void
+empathy_account_widget_build_skype (EmpathyAccountWidget *self,
+ const char *filename)
+{
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+
+ if (priv->simple)
+ {
+ self->ui_details->gui = empathy_builder_get_file (filename,
+ "vbox_skype_simple", &self->ui_details->widget,
+ NULL);
+
+ empathy_account_widget_handle_params (self,
+ "entry_id_simple", "account",
+ "entry_password_simple", "password",
+ NULL);
+
+ self->ui_details->default_focus = g_strdup ("entry_id_simple");
+ }
+ else if (priv->creating_account)
+ {
+ /* if we don't have an account it means we're doing the initial setup */
+ self->ui_details->gui = empathy_builder_get_file (filename,
+ "table_common_skype_settings_setup", &priv->table_common_settings,
+ "vbox_skype_settings_setup", &self->ui_details->widget,
+ NULL);
+
+ empathy_account_widget_handle_params (self,
+ "entry_id_setup", "account",
+ "entry_password_setup", "password",
+ NULL);
+
+ self->ui_details->default_focus = g_strdup ("entry_id_setup");
+ }
+ else
+ {
+ TpAccount *account =
+ empathy_account_settings_get_account (priv->settings);
+ GtkWidget *edit_privacy_settings_button;
+ GtkWidget *plugged_into_skype_logo, *canonical_logo;
+ char *logo;
+
+ self->ui_details->gui = empathy_builder_get_file (filename,
+ "table_common_skype_settings", &priv->table_common_settings,
+ "vbox_skype_settings", &self->ui_details->widget,
+ "edit-privacy-settings-button", &edit_privacy_settings_button,
+ "plugged-into-skype-logo", &plugged_into_skype_logo,
+ "canonical-logo", &canonical_logo,
+ NULL);
+
+ empathy_builder_connect (self->ui_details->gui, self,
+ "edit-privacy-settings-button", "clicked",
+ account_widget_skype_privacy_settings,
+ NULL);
+
+ if (account != NULL)
+ tp_account_bind_connection_status_to_property (account,
+ edit_privacy_settings_button, "sensitive", FALSE);
+ else
+ gtk_widget_set_sensitive (edit_privacy_settings_button, FALSE);
+
+ logo = empathy_file_lookup ("plugged-into-skype.png", "data");
+ gtk_image_set_from_file (GTK_IMAGE (plugged_into_skype_logo), logo);
+ g_free (logo);
+
+ logo = empathy_file_lookup ("canonical-logo.png", "data");
+ gtk_image_set_from_file (GTK_IMAGE (canonical_logo), logo);
+ g_free (logo);
+
+ empathy_account_widget_handle_params (self,
+ "entry_id", "account",
+ "entry_password", "password",
+ NULL);
+
+ self->ui_details->default_focus = g_strdup ("entry_id");
+ }
+}
diff --git a/libempathy-gtk/empathy-account-widget-skype.h b/libempathy-gtk/empathy-account-widget-skype.h
new file mode 100644
index 000000000..46f70d04e
--- /dev/null
+++ b/libempathy-gtk/empathy-account-widget-skype.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2011 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Authors: Danielle Madeley <danielle.madeley@collabora.co.uk>
+ */
+
+#ifndef __EMPATHY_ACCOUNT_WIDGET_SKYPE_H__
+#define __EMPATHY_ACCOUNT_WIDGET_SKYPE_H__
+
+#include <gtk/gtk.h>
+#include <libempathy-gtk/empathy-account-widget.h>
+
+G_BEGIN_DECLS
+
+void empathy_account_widget_build_skype (EmpathyAccountWidget *self,
+ const char *filename);
+
+G_END_DECLS
+
+#endif /* __EMPATHY_ACCOUNT_WIDGET_SKYPE_H__ */
diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c
index 4495713a7..03fe0e29e 100644
--- a/libempathy-gtk/empathy-account-widget.c
+++ b/libempathy-gtk/empathy-account-widget.c
@@ -35,7 +35,6 @@
#include <mx-gtk/mx-gtk.h>
#endif /* HAVE_MEEGO */
-#include <extensions/extensions.h>
#include <libempathy/empathy-utils.h>
@@ -49,6 +48,7 @@
#include "empathy-account-widget-private.h"
#include "empathy-account-widget-sip.h"
#include "empathy-account-widget-irc.h"
+#include "empathy-account-widget-skype.h"
#include "empathy-ui-utils.h"
#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
@@ -56,51 +56,6 @@
G_DEFINE_TYPE (EmpathyAccountWidget, empathy_account_widget, G_TYPE_OBJECT)
-typedef struct {
- EmpathyAccountSettings *settings;
-
- GtkWidget *table_common_settings;
- GtkWidget *apply_button;
- GtkWidget *cancel_button;
- GtkWidget *entry_password;
- GtkWidget *spinbutton_port;
- GtkWidget *enabled_checkbox;
- GtkWidget *radiobutton_reuse;
-
- gboolean simple;
- gboolean enabled;
-
- gboolean contains_pending_changes;
-
- /* An EmpathyAccountWidget can be used to either create an account or
- * modify it. When we are creating an account, this member is set to TRUE */
- gboolean creating_account;
-
- /* whether there are any other real accounts. Necessary so we know whether
- * it's safe to dismiss this widget in some cases (eg, whether the Cancel
- * button should be sensitive) */
- gboolean other_accounts_exist;
-
- /* if TRUE, the GTK+ destroy signal has been fired and so the widgets
- * embedded in this account widget can't be used any more
- * workaround because some async callbacks can be called after the
- * widget has been destroyed */
- gboolean destroyed;
-
- TpAccountManager *account_manager;
-
- GtkWidget *param_account_widget;
- GtkWidget *param_password_widget;
-
- gboolean automatic_change;
- GtkWidget *remember_password_widget;
-
- /* Used only for IRC accounts */
- EmpathyIrcNetworkChooser *irc_network_chooser;
-
- gboolean dispose_run;
-} EmpathyAccountWidgetPriv;
-
enum {
PROP_PROTOCOL = 1,
PROP_SETTINGS,
@@ -1483,451 +1438,14 @@ account_widget_build_groupwise (EmpathyAccountWidget *self,
}
}
-enum {
- PS_COL_ENUM_VALUE,
- PS_COL_DISPLAY_NAME,
- NUM_PS_COLS
-};
-
-static void
-account_widget_skype_combo_changed_cb (GtkComboBox *combo,
- EmpathyAccountWidget *self)
-{
- EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
- const char *prop_name = g_object_get_data (G_OBJECT (combo), "dbus-property");
- TpConnection *conn;
- EmpPrivacySetting prop_value;
- GtkTreeIter iter;
- GValue value = { 0, };
-
- gtk_combo_box_get_active_iter (combo, &iter);
- gtk_tree_model_get (gtk_combo_box_get_model (combo), &iter,
- PS_COL_ENUM_VALUE, &prop_value,
- -1);
-
- DEBUG ("Combo changed: %s", prop_name);
-
- g_value_init (&value, G_TYPE_UINT);
- g_value_set_uint (&value, prop_value);
-
- conn = tp_account_get_connection (
- empathy_account_settings_get_account (priv->settings));
- tp_cli_dbus_properties_call_set (conn, -1,
- EMP_IFACE_CONNECTION_INTERFACE_PRIVACY_SETTINGS,
- prop_name, &value, NULL, NULL, NULL, NULL);
-
- g_value_unset (&value);
-}
-
-static void
-account_widget_skype_toggle_changed_cb (GtkToggleButton *toggle,
- EmpathyAccountWidget *self)
-{
- EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
- const char *prop_name = g_object_get_data (G_OBJECT (toggle),
- "dbus-property");
- TpConnection *conn;
- GValue value = { 0, };
-
- DEBUG ("Toggle changed: %s", prop_name);
-
- g_value_init (&value, G_TYPE_BOOLEAN);
- g_value_set_boolean (&value, gtk_toggle_button_get_active (toggle));
-
- conn = tp_account_get_connection (
- empathy_account_settings_get_account (priv->settings));
- tp_cli_dbus_properties_call_set (conn, -1,
- EMP_IFACE_CONNECTION_INTERFACE_PRIVACY_SETTINGS,
- prop_name, &value, NULL, NULL, NULL, NULL);
-
- g_value_unset (&value);
-}
-
-static void
-account_widget_skype_set_value (EmpathyAccountWidget *self,
- GtkWidget *widget,
- GValue *value)
-{
- g_return_if_fail (value != NULL);
-
- if (GTK_IS_COMBO_BOX (widget))
- {
- GtkTreeModel *model =
- gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
- guint prop_value;
- GtkTreeIter iter;
- gboolean valid;
-
- g_return_if_fail (G_VALUE_HOLDS_UINT (value));
-
- prop_value = g_value_get_uint (value);
-
- g_signal_handlers_block_by_func (widget,
- account_widget_skype_combo_changed_cb, self);
-
- for (valid = gtk_tree_model_get_iter_first (model, &iter);
- valid;
- valid = gtk_tree_model_iter_next (model, &iter))
- {
- guint v;
-
- gtk_tree_model_get (model, &iter,
- PS_COL_ENUM_VALUE, &v,
- -1);
-
- if (v == prop_value)
- {
- gtk_combo_box_set_active_iter (GTK_COMBO_BOX (widget), &iter);
- break;
- }
- }
-
- g_signal_handlers_unblock_by_func (widget,
- account_widget_skype_combo_changed_cb, self);
- }
- else if (GTK_IS_TOGGLE_BUTTON (widget))
- {
- g_return_if_fail (G_VALUE_HOLDS_BOOLEAN (value));
-
- g_signal_handlers_block_by_func (widget,
- account_widget_skype_toggle_changed_cb, self);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget),
- g_value_get_boolean (value));
-
- g_signal_handlers_unblock_by_func (widget,
- account_widget_skype_toggle_changed_cb, self);
- }
- else
- {
- g_assert_not_reached ();
- }
-}
-
-static void
-account_widget_build_skype_get_privacy_settings_cb (TpProxy *cm,
- GHashTable *props,
- const GError *in_error,
- gpointer user_data,
- GObject *weak_obj)
-{
- EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (weak_obj);
- GtkBuilder *gui = user_data;
- guint i;
-
- static const char *widgets[] = {
- "allow-text-chats-from",
- "allow-skype-calls-from",
- "allow-outside-calls-from",
- "show-my-avatar-to",
- "show-my-web-status"
- };
-
- if (in_error != NULL)
- {
- GtkWidget *table, *infobar, *label;
-
- DEBUG ("Failed to get properties: %s", in_error->message);
-
- table = GTK_WIDGET (gtk_builder_get_object (gui,
- "privacy-settings-table"));
- gtk_widget_set_sensitive (table, FALSE);
-
- infobar = gtk_info_bar_new ();
- gtk_box_pack_start (
- GTK_BOX (gtk_builder_get_object (gui, "privacy-settings-vbox")),
- infobar, FALSE, TRUE, 0);
- gtk_info_bar_set_message_type (GTK_INFO_BAR (infobar), GTK_MESSAGE_ERROR);
- label = gtk_label_new (_("Failed to retrieve privacy settings."));
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_container_add (GTK_CONTAINER (
- gtk_info_bar_get_content_area (GTK_INFO_BAR (infobar))),
- label);
- gtk_widget_show (label);
-
- return;
- }
-
- for (i = 0; i < G_N_ELEMENTS (widgets); i++)
- {
- GtkWidget *widget = GTK_WIDGET (gtk_builder_get_object (gui, widgets[i]));
- const char *prop_name = g_object_get_data (G_OBJECT (widget),
- "dbus-property");
-
- DEBUG ("Widget '%s' (%s), prop = %s",
- widgets[i], G_OBJECT_TYPE_NAME (widget), prop_name);
-
- account_widget_skype_set_value (self, widget,
- g_hash_table_lookup (props, prop_name));
- }
-}
-
-static void
-account_widget_skype_properties_changed_cb (TpProxy *conn,
- const char *interface,
- GHashTable *props,
- const char **invalidated,
- gpointer user_data,
- GObject *weak_obj)
-{
- EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (weak_obj);
- GtkWidget *table = user_data;
- GHashTableIter iter;
- const char *prop;
- GValue *value;
-
- g_hash_table_iter_init (&iter, props);
- while (g_hash_table_iter_next (&iter, (gpointer) &prop, (gpointer) &value))
- {
- GList *children, *ptr;
-
- DEBUG ("Property changed: %s", prop);
-
- /* find this value in the widget tree */
- children = gtk_container_get_children (GTK_CONTAINER (table));
-
- for (ptr = children; ptr != NULL; ptr = ptr->next)
- {
- GtkWidget *widget = ptr->data;
- const char *prop_name = g_object_get_data (G_OBJECT (widget),
- "dbus-property");
-
- if (!tp_strdiff (prop_name, prop))
- {
- DEBUG ("Got child %p (%s)", widget, G_OBJECT_TYPE_NAME (widget));
-
- account_widget_skype_set_value (self, widget, value);
- break;
- }
- }
-
- g_list_free (children);
- }
-}
-
-/**
- * account_widget_build_skype_setup_combo:
- * @gui:
- * @widget:
- * @first_option: a list of options from the enum, terminated by -1
- */
-static void
-account_widget_build_skype_setup_combo (EmpathyAccountWidget *self,
- GtkBuilder *gui,
- const char *widget,
- const char *prop_name,
- int first_option,
- ...)
-{
- GtkWidget *combo;
- GtkListStore *store;
- va_list var_args;
- int option;
-
- static const char *options[NUM_EMP_PRIVACY_SETTINGS] = {
- N_("Nobody"),
- N_("Contacts"),
- N_("Anyone"),
- N_("Known Numbers")
- };
-
- combo = GTK_WIDGET (gtk_builder_get_object (gui, widget));
-
- g_return_if_fail (combo != NULL);
-
- store = gtk_list_store_new (NUM_PS_COLS,
- G_TYPE_UINT, /* PS_COL_ENUM_VALUE */
- G_TYPE_STRING /* PS_COL_DISPLAY_NAME */
- );
- gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (store));
-
- va_start (var_args, first_option);
-
- for (option = first_option; option != -1; option = va_arg (var_args, int))
- {
- gtk_list_store_insert_with_values (store, NULL, -1,
- PS_COL_ENUM_VALUE, option,
- PS_COL_DISPLAY_NAME, gettext(options[option]),
- -1);
- }
-
- va_end (var_args);
-
- g_object_set_data (G_OBJECT (combo), "dbus-property", (gpointer) prop_name);
- g_signal_connect (combo, "changed",
- G_CALLBACK (account_widget_skype_combo_changed_cb), self);
-}
-
-static void
-account_widget_skype_privacy_settings (GtkWidget *button,
- EmpathyAccountWidget *self)
-{
- EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
- TpConnection *conn;
- char *filename;
- GtkBuilder *gui;
- GtkWidget *dialog, *show_my_web_status, *table, *vbox;
- GtkWidget *toplevel, *infobar, *label;
-
- DEBUG ("Loading privacy settings");
-
- filename = empathy_file_lookup ("empathy-account-widget-skype.ui",
- "libempathy-gtk");
- gui = empathy_builder_get_file (filename,
- "privacy-settings-dialog", &dialog,
- "privacy-settings-table", &table,
- "privacy-settings-vbox", &vbox,
- "show-my-web-status", &show_my_web_status,
- NULL);
-
- toplevel = gtk_widget_get_toplevel (self->ui_details->widget);
- if (gtk_widget_is_toplevel (toplevel) && GTK_IS_WINDOW (toplevel))
- gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (toplevel));
-
- /* make the settings insensitive when the account is disconnected */
- tp_account_bind_connection_status_to_property (
- empathy_account_settings_get_account (priv->settings),
- table, "sensitive", FALSE);
-
- /* set up an informative info bar */
- infobar = gtk_info_bar_new ();
- gtk_box_pack_start (GTK_BOX (vbox), infobar, FALSE, TRUE, 0);
- gtk_info_bar_set_message_type (GTK_INFO_BAR (infobar), GTK_MESSAGE_INFO);
- label = gtk_label_new (_("Privacy settings can only be changed while the "
- "account is connected."));
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_container_add (
- GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (infobar))),
- label);
- gtk_widget_show (label);
- g_object_bind_property (table, "sensitive", infobar, "visible",
- G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN);
-
- account_widget_build_skype_setup_combo (self, gui,
- "allow-text-chats-from", "AllowTextChannelsFrom",
- EMP_PRIVACY_SETTING_ANYONE,
- EMP_PRIVACY_SETTING_CONTACTS,
- -1);
- account_widget_build_skype_setup_combo (self, gui,
- "allow-skype-calls-from", "AllowCallChannelsFrom",
- EMP_PRIVACY_SETTING_ANYONE,
- EMP_PRIVACY_SETTING_CONTACTS,
- -1);
- account_widget_build_skype_setup_combo (self, gui,
- "allow-outside-calls-from", "AllowOutsideCallsFrom",
- EMP_PRIVACY_SETTING_ANYONE,
- EMP_PRIVACY_SETTING_KNOWN_NUMBERS,
- EMP_PRIVACY_SETTING_CONTACTS,
- -1);
- account_widget_build_skype_setup_combo (self, gui,
- "show-my-avatar-to", "ShowMyAvatarTo",
- EMP_PRIVACY_SETTING_ANYONE,
- EMP_PRIVACY_SETTING_CONTACTS,
- -1);
-
- g_object_set_data (G_OBJECT (show_my_web_status), "dbus-property",
- "ShowMyWebStatus");
- g_signal_connect (show_my_web_status, "toggled",
- G_CALLBACK (account_widget_skype_toggle_changed_cb), self);
-
- /* get the current parameter values from psyke */
- conn = tp_account_get_connection (
- empathy_account_settings_get_account (priv->settings));
-
- tp_cli_dbus_properties_call_get_all (conn, -1,
- EMP_IFACE_CONNECTION_INTERFACE_PRIVACY_SETTINGS,
- account_widget_build_skype_get_privacy_settings_cb,
- g_object_ref (gui), g_object_unref,
- G_OBJECT (self));
- tp_cli_dbus_properties_connect_to_properties_changed (conn,
- account_widget_skype_properties_changed_cb,
- table, NULL, G_OBJECT (self), NULL);
-
- g_object_unref (gui);
-
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-}
-
static void
account_widget_build_skype (EmpathyAccountWidget *self,
const char *filename)
{
- EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
-
- if (priv->simple)
- {
- self->ui_details->gui = empathy_builder_get_file (filename,
- "vbox_skype_simple", &self->ui_details->widget,
- NULL);
-
- empathy_account_widget_handle_params (self,
- "entry_id_simple", "account",
- "entry_password_simple", "password",
- NULL);
-
- self->ui_details->default_focus = g_strdup ("entry_id_simple");
- }
- else if (priv->creating_account)
- {
- /* if we don't have an account it means we're doing the initial setup */
- self->ui_details->gui = empathy_builder_get_file (filename,
- "table_common_skype_settings_setup", &priv->table_common_settings,
- "vbox_skype_settings_setup", &self->ui_details->widget,
- NULL);
-
- empathy_account_widget_handle_params (self,
- "entry_id_setup", "account",
- "entry_password_setup", "password",
- NULL);
-
- self->ui_details->default_focus = g_strdup ("entry_id_setup");
- }
- else
- {
- TpAccount *account =
- empathy_account_settings_get_account (priv->settings);
- GtkWidget *edit_privacy_settings_button;
- GtkWidget *plugged_into_skype_logo, *canonical_logo;
- char *logo;
-
- self->ui_details->gui = empathy_builder_get_file (filename,
- "table_common_skype_settings", &priv->table_common_settings,
- "vbox_skype_settings", &self->ui_details->widget,
- "edit-privacy-settings-button", &edit_privacy_settings_button,
- "plugged-into-skype-logo", &plugged_into_skype_logo,
- "canonical-logo", &canonical_logo,
- NULL);
-
- empathy_builder_connect (self->ui_details->gui, self,
- "edit-privacy-settings-button", "clicked",
- account_widget_skype_privacy_settings,
- NULL);
-
- if (account != NULL)
- tp_account_bind_connection_status_to_property (account,
- edit_privacy_settings_button, "sensitive", FALSE);
- else
- gtk_widget_set_sensitive (edit_privacy_settings_button, FALSE);
-
-
- logo = empathy_file_lookup ("plugged-into-skype.png", "data");
- gtk_image_set_from_file (GTK_IMAGE (plugged_into_skype_logo), logo);
- g_free (logo);
-
- logo = empathy_file_lookup ("canonical-logo.png", "data");
- gtk_image_set_from_file (GTK_IMAGE (canonical_logo), logo);
- g_free (logo);
-
- empathy_account_widget_handle_params (self,
- "entry_id", "account",
- "entry_password", "password",
- NULL);
-
- self->ui_details->default_focus = g_strdup ("entry_id");
- }
+ empathy_account_widget_build_skype (self, filename);
}
+
static void
account_widget_destroy_cb (GtkWidget *widget,
EmpathyAccountWidget *self)