From e24b350723d74b2f5f86401f3ecd6b85017bf592 Mon Sep 17 00:00:00 2001 From: Emilio Pozuelo Monfort Date: Mon, 7 Mar 2011 17:55:48 +0000 Subject: Show an EULA when creating an Skype account The EULA is read from a file so it can be easily changed by distributors / OEMs. --- libempathy-gtk/empathy-account-widget.c | 53 +++++++++++++++++++++++++++++++++ libempathy-gtk/empathy-account-widget.h | 2 ++ src/empathy-accounts-dialog.c | 21 +++++++++++++ 3 files changed, 76 insertions(+) diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c index 3d3e3d0f8..d55951142 100644 --- a/libempathy-gtk/empathy-account-widget.c +++ b/libempathy-gtk/empathy-account-widget.c @@ -1407,6 +1407,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 3dfb40589..c5f94dd58 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -724,6 +724,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 @@ -742,6 +744,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); -- cgit v1.2.3