aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorSarfraaz Ahmed <asarfraaz@novell.com>2004-04-23 12:15:22 +0800
committerAhmed Sarfraaz <sarfraaz@src.gnome.org>2004-04-23 12:15:22 +0800
commitbfc9c251ae17ffdac7bbcc2112066617f6982150 (patch)
treef8df9024ed4adb59e37f191d607e302d4c2a48cb /mail
parentbfc49c80227b6d165d726019711af83fe3338068 (diff)
downloadgsoc2013-evolution-bfc9c251ae17ffdac7bbcc2112066617f6982150.tar.gz
gsoc2013-evolution-bfc9c251ae17ffdac7bbcc2112066617f6982150.tar.zst
gsoc2013-evolution-bfc9c251ae17ffdac7bbcc2112066617f6982150.zip
Added a check for HAS_LICENSE flag.
2004-04-23 Sarfraaz Ahmed <asarfraaz@novell.com> * mail-account-gui.c (mail_account_gui_source_complete): Added a check for HAS_LICENSE flag. (mail_account_gui_check_for_license)(display_license) (populate_text_entry)(check_button_state)(set_license_accepted) (set_license_rejected): Implemented svn path=/trunk/; revision=25591
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog8
-rw-r--r--mail/mail-account-gui.c152
2 files changed, 159 insertions, 1 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index f850374bd8..0cc9d67efb 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,11 @@
+2004-04-23 Sarfraaz Ahmed <asarfraaz@novell.com>
+
+ * mail-account-gui.c (mail_account_gui_source_complete): Added a
+ check for HAS_LICENSE flag.
+ (mail_account_gui_check_for_license)(display_license)
+ (populate_text_entry)(check_button_state)(set_license_accepted)
+ (set_license_rejected): Implemented
+
2004-04-22 Not Zed <NotZed@Ximian.com>
* em-migrate.c (em_migrate_imap_cmeta_1_4): do the imap cmeta
diff --git a/mail/mail-account-gui.c b/mail/mail-account-gui.c
index 3814f9bf97..ed91f4ae29 100644
--- a/mail/mail-account-gui.c
+++ b/mail/mail-account-gui.c
@@ -27,6 +27,8 @@
#include <config.h>
#endif
+#include <glib.h>
+
#include <string.h>
#include <stdarg.h>
@@ -155,6 +157,116 @@ auto_detected_foreach (gpointer key, gpointer value, gpointer user_data)
g_free (value);
}
+static void
+set_license_rejected (GtkWidget *widget, gpointer data)
+{
+ gtk_dialog_response (GTK_DIALOG (data), GTK_RESPONSE_DELETE_EVENT);
+ return;
+}
+
+static void
+set_license_accepted (GtkWidget *widget, gpointer data)
+{
+ gtk_dialog_response (GTK_DIALOG (data), GTK_RESPONSE_ACCEPT);
+ return;
+
+}
+
+static void
+check_button_state (GtkToggleButton *button, gpointer data)
+{
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button)))
+ gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE);
+ else
+ gtk_widget_set_sensitive (GTK_WIDGET (data), FALSE);
+}
+
+
+static gboolean
+populate_text_entry (GtkTextView *view, const char *filename)
+{
+ FILE *fd;
+ char *filebuf;
+ GtkTextIter iter;
+ GtkTextBuffer *buffer;
+ int count;
+
+ g_return_val_if_fail (filename != NULL , FALSE);
+
+ fd = fopen (filename, "r");
+
+ if (!fd) {
+ /* FIXME: Should never come here */
+ return FALSE;
+ }
+
+ filebuf = g_malloc (1024);
+
+ buffer = gtk_text_buffer_new (NULL);
+ gtk_text_buffer_get_start_iter (buffer, &iter);
+
+ while (!feof (fd) && !ferror (fd)) {
+ count = fread (filebuf, 1, sizeof (filebuf), fd);
+ gtk_text_buffer_insert (buffer, &iter, filebuf, count);
+ }
+ gtk_text_view_set_buffer (GTK_TEXT_VIEW (view),
+ GTK_TEXT_BUFFER (buffer));
+ fclose (fd);
+ g_free (filebuf);
+ return TRUE;
+}
+
+static gboolean
+display_license(const char *filename)
+{
+ GladeXML *xml;
+ GtkWidget *top_widget;
+ GtkTextView *text_entry;
+ GtkButton *button_yes, *button_no;
+ GtkCheckButton *check_button;
+ GtkResponseType response;
+ gboolean status;
+
+ xml = glade_xml_new (EVOLUTION_GLADEDIR "/mail-license.glade",
+ "lic_dialog", NULL);
+
+ top_widget = glade_xml_get_widget (xml, "lic_dialog");
+ text_entry = GTK_TEXT_VIEW (glade_xml_get_widget (xml, "textview1"));
+ status = populate_text_entry (GTK_TEXT_VIEW (text_entry), filename);
+ if (!status)
+ goto failed;
+
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (text_entry), FALSE);
+
+ button_yes = GTK_BUTTON (glade_xml_get_widget (xml, "lic_yes_button"));
+ gtk_widget_set_sensitive (GTK_WIDGET (button_yes), FALSE);
+
+ button_no = GTK_BUTTON (glade_xml_get_widget (xml, "lic_no_button"));
+
+ check_button = GTK_CHECK_BUTTON (glade_xml_get_widget (xml,
+ "lic_checkbutton"));
+
+ g_signal_connect (check_button, "toggled",
+ G_CALLBACK (check_button_state), button_yes);
+ g_signal_connect (button_yes, "clicked",
+ G_CALLBACK (set_license_accepted),
+ GTK_WIDGET (top_widget));
+ g_signal_connect (button_no, "clicked",
+ G_CALLBACK (set_license_rejected),
+ GTK_WIDGET (top_widget));
+
+ response = gtk_dialog_run (GTK_DIALOG (top_widget));
+ if (response == GTK_RESPONSE_ACCEPT) {
+ gtk_widget_destroy (top_widget);
+ g_object_unref (xml);
+ return TRUE;
+ }
+failed:
+ gtk_widget_destroy (top_widget);
+ g_object_unref (xml);
+ return FALSE;
+}
+
static gboolean
service_complete (MailAccountGuiService *service, GHashTable *extra_config, GtkWidget **incomplete)
{
@@ -216,6 +328,40 @@ service_complete (MailAccountGuiService *service, GHashTable *extra_config, GtkW
}
gboolean
+mail_account_gui_check_for_license (CamelProvider *prov)
+{
+ GConfClient *gconf;
+ gboolean accepted, status;
+ char *gconf_license_key;
+
+ if (prov->flags & CAMEL_PROVIDER_HAS_LICENSE) {
+ gconf = mail_config_get_gconf_client ();
+ gconf_license_key = g_strdup_printf (
+ "/apps/evolution/mail/licenses/%s_accepted",
+ prov->license);
+
+ accepted = gconf_client_get_bool (gconf, gconf_license_key,
+ NULL);
+ if (!accepted) {
+ /* Since the license is not yet accepted, pop-up a
+ * dialog to display the license agreement and check
+ * if the user accepts it
+ */
+
+ if (display_license (prov->license_file)) {
+ status = gconf_client_set_bool (gconf,
+ gconf_license_key, TRUE, NULL);
+ } else {
+ g_free (gconf_license_key);
+ return FALSE;
+ }
+ }
+ g_free (gconf_license_key);
+ }
+ return TRUE;
+}
+
+gboolean
mail_account_gui_source_complete (MailAccountGui *gui, GtkWidget **incomplete)
{
return service_complete (&gui->source, gui->extra_config, incomplete);
@@ -492,6 +638,7 @@ source_type_changed (GtkWidget *widget, gpointer user_data)
GtkWidget *file_entry, *label, *frame, *dwidget = NULL;
CamelProvider *provider;
gboolean writeable;
+ gboolean license_accepted = TRUE;
provider = g_object_get_data ((GObject *) widget, "provider");
@@ -521,8 +668,11 @@ source_type_changed (GtkWidget *widget, gpointer user_data)
else
gtk_label_set_text (gui->source.description, "");
+ if (gui->source.provider)
+ license_accepted = mail_account_gui_check_for_license (gui->source.provider);
+
frame = glade_xml_get_widget (gui->xml, "source_frame");
- if (provider) {
+ if (provider && license_accepted) {
gtk_widget_show (frame);
/* hostname */