diff options
author | Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk> | 2011-03-08 01:55:48 +0800 |
---|---|---|
committer | Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk> | 2011-04-08 18:41:28 +0800 |
commit | 35d8977bb40bde9ba18a552fe9f7da11640b173a (patch) | |
tree | 766a3da5c137400fe3eea55266350e68b354e9ec | |
parent | 79daab89f4689f9a589e605bec6cbd549a8a55e3 (diff) | |
download | gsoc2013-empathy-35d8977bb40bde9ba18a552fe9f7da11640b173a.tar gsoc2013-empathy-35d8977bb40bde9ba18a552fe9f7da11640b173a.tar.gz gsoc2013-empathy-35d8977bb40bde9ba18a552fe9f7da11640b173a.tar.bz2 gsoc2013-empathy-35d8977bb40bde9ba18a552fe9f7da11640b173a.tar.lz gsoc2013-empathy-35d8977bb40bde9ba18a552fe9f7da11640b173a.tar.xz gsoc2013-empathy-35d8977bb40bde9ba18a552fe9f7da11640b173a.tar.zst gsoc2013-empathy-35d8977bb40bde9ba18a552fe9f7da11640b173a.zip |
Show an EULA when creating an Skype account
The EULA is read from a file so it can be easily changed by
distributors / OEMs.
-rw-r--r-- | libempathy-gtk/empathy-account-widget.c | 53 | ||||
-rw-r--r-- | libempathy-gtk/empathy-account-widget.h | 2 | ||||
-rw-r--r-- | src/empathy-accounts-dialog.c | 21 |
3 files changed, 76 insertions, 0 deletions
diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c index 03fe0e29e..38353ef4d 100644 --- a/libempathy-gtk/empathy-account-widget.c +++ b/libempathy-gtk/empathy-account-widget.c @@ -1438,6 +1438,59 @@ account_widget_build_groupwise (EmpathyAccountWidget *self, } } +gboolean +account_widget_skype_show_eula (GtkWindow *parent) +{ + GtkWidget *dialog, *textview, *vbox, *scrolledwindow; + GtkTextBuffer *buffer; + gchar *filename = empathy_file_lookup ("skype-eula.txt", "data"); + gchar *eula; + gint result; + gsize len; + GError *error = NULL; + + g_file_get_contents (filename, &eula, &len, &error); + g_free (filename); + + if (error != NULL) + { + g_warning ("Could not open Skype EULA: %s", error->message); + g_error_free (error); + return FALSE; + } + + dialog = gtk_dialog_new_with_buttons (_("End User License Agreement"), + parent, GTK_DIALOG_MODAL, + _("Decline"), GTK_RESPONSE_CANCEL, + _("Accept"), GTK_RESPONSE_ACCEPT, + NULL); + + buffer = gtk_text_buffer_new (NULL); + gtk_text_buffer_set_text (buffer, eula, len); + g_free (eula); + textview = gtk_text_view_new_with_buffer (buffer); + gtk_text_view_set_editable (GTK_TEXT_VIEW (textview), FALSE); + gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (textview), GTK_WRAP_WORD_CHAR); + + vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); + + scrolledwindow = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_add_with_viewport ( + GTK_SCROLLED_WINDOW (scrolledwindow), textview); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow), + GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + + gtk_box_pack_start (GTK_BOX (vbox), scrolledwindow, TRUE, TRUE, 0); + gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 250); + gtk_widget_show_all (dialog); + + result = gtk_dialog_run (GTK_DIALOG (dialog)); + + gtk_widget_destroy (dialog); + + return (result == GTK_RESPONSE_ACCEPT); +} + static void account_widget_build_skype (EmpathyAccountWidget *self, const char *filename) diff --git a/libempathy-gtk/empathy-account-widget.h b/libempathy-gtk/empathy-account-widget.h index ecc52e6c6..149334b03 100644 --- a/libempathy-gtk/empathy-account-widget.h +++ b/libempathy-gtk/empathy-account-widget.h @@ -82,6 +82,8 @@ void empathy_account_widget_set_password_param (EmpathyAccountWidget *self, void empathy_account_widget_set_other_accounts_exist ( EmpathyAccountWidget *self, gboolean others_exist); +gboolean account_widget_skype_show_eula (GtkWindow *parent); + /* protected methods */ void empathy_account_widget_changed (EmpathyAccountWidget *widget); diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 3c690c071..3d9ebb48b 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -740,6 +740,8 @@ accounts_dialog_protocol_changed_cb (GtkWidget *widget, GtkTreeIter iter; gboolean creating; EmpathyAccountSettings *settings; + TpConnectionManager *cm; + TpConnectionManagerProtocol *proto; gchar *account = NULL, *password = NULL; /* The "changed" signal is fired during the initiation of the @@ -758,6 +760,25 @@ accounts_dialog_protocol_changed_cb (GtkWidget *widget, if (!gtk_tree_selection_get_selected (selection, &model, &iter)) return; + cm = empathy_protocol_chooser_dup_selected ( + EMPATHY_PROTOCOL_CHOOSER (priv->combobox_protocol), &proto, NULL, NULL); + + if (cm == NULL) + return; + + g_object_unref (cm); + + if (!tp_strdiff (proto->name, "skype")) + { + if (!account_widget_skype_show_eula (GTK_WINDOW (dialog))) + { + gtk_combo_box_set_active ( + GTK_COMBO_BOX (priv->combobox_protocol), 0); + empathy_account_dialog_cancel (dialog); + return; + } + } + /* Save "account" and "password" parameters */ g_object_get (priv->setting_widget_object, "settings", &settings, NULL); |