|
Thanks -- Sarfraaz Ahmed <asarfraaz novell com> |
Index: camel/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
retrieving revision 1.2103
diff -u -r1.2103 ChangeLog
--- camel/ChangeLog 16 Apr 2004 18:34:55 -0000 1.2103
+++ camel/ChangeLog 19 Apr 2004 13:00:18 -0000
@@ -1,3 +1,8 @@
+2004-04-19 Sarfraaz Ahmed <asarfraaz novell com>
+
+ * camel-provider.h: Added flags for allowing camel providers to
+ display license file.
+
2004-04-16 Jeffrey Stedfast <fejj ximian com>
* camel-vee-store.c (change_folder): (flags & 0) will never be
Index: camel/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
retrieving revision 1.2103
diff -u -r1.2103 ChangeLog
--- camel/ChangeLog 16 Apr 2004 18:34:55 -0000 1.2103
+++ camel/ChangeLog 19 Apr 2004 13:01:01 -0000
@@ -1,3 +1,8 @@
+2004-04-19 Sarfraaz Ahmed <asarfraaz novell com>
+
+ * camel-provider.h: Added flags for allowing camel providers to
+ display license file.
+
2004-04-16 Jeffrey Stedfast <fejj ximian com>
* camel-vee-store.c (change_folder): (flags & 0) will never be
Index: mail/mail-account-gui.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-account-gui.c,v
retrieving revision 1.158
diff -u -r1.158 mail-account-gui.c
--- mail/mail-account-gui.c 8 Apr 2004 22:02:36 -0000 1.158
+++ mail/mail-account-gui.c 19 Apr 2004 13:02:02 -0000
@@ -27,6 +27,8 @@
#include <config.h>
#endif
+#include <glib.h>
+
#include <string.h>
#include <stdarg.h>
@@ -56,6 +58,9 @@
#define d(x)
+#define FILENAME EVOLUTION_GLADEDIR "/mail-license.glade"
+#define ROOTNODE "lic_dialog"
+
static void save_service (MailAccountGuiService *gsvc, GHashTable *extra_conf, EAccountService *service);
static void service_changed (GtkEntry *entry, gpointer user_data);
@@ -155,6 +160,109 @@
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);
+}
+
+#define BUFSIZE 1024
+
+static gboolean
+populate_text_entry (GtkTextView *view, const char *filename)
+{
+ FILE *fd;
+ char filebuf[BUFSIZE];
+ GtkTextIter iter;
+ GtkTextBuffer *buffer;
+ char fname[BUFSIZE];
+ int count;
+
+ g_sprintf (fname, "%s/../%s", EVOLUTION_GLADEDIR, filename);
+
+ fd = fopen (fname, "r");
+
+ if (!fd) {
+ /* FIXME: Should never come here */
+ return FALSE;
+ }
+
+ buffer = gtk_text_buffer_new (NULL);
+ gtk_text_buffer_get_start_iter (buffer, &iter);
+
+ while (!feof (fd)) {
+ count = fread (filebuf, 1, (BUFSIZE - 1), fd);
+ filebuf [count] = '\0';
+ gtk_text_buffer_insert (buffer, &iter, filebuf, -1);
+ }
+ gtk_text_view_set_buffer (GTK_TEXT_VIEW (view),
+ GTK_TEXT_BUFFER (buffer));
+ fclose (fd);
+ 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 (FILENAME, ROOTNODE, NULL);
+
+ top_widget = glade_xml_get_widget (xml, ROOTNODE);
+ 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 +324,34 @@
}
gboolean
+mail_account_gui_check_for_license (CamelProvider *prov)
+{
+ GConfClient *gconf;
+ gboolean accepted, status;
+
+ if (prov->flags & CAMEL_PROVIDER_CHECK_LICENSE) {
+ gconf = mail_config_get_gconf_client ();
+ accepted = gconf_client_get_bool (gconf, prov->gconf_license_bool_key, NULL);
+
+ if (accepted)
+ return TRUE;
+
+ /* Since the license is not yet accepted, pop-up a dialog
+ * to display the license agreement and check if the user
+ * accepts it
+ */
+
+ status = display_license (prov->license_file);
+ if (!status)
+ return FALSE;
+
+ status = gconf_client_set_bool (gconf, prov->gconf_license_bool_key, TRUE, NULL);
+
+ }
+ return TRUE;
+}
+
+gboolean
mail_account_gui_source_complete (MailAccountGui *gui, GtkWidget **incomplete)
{
return service_complete (&gui->source, gui->extra_config, incomplete);
@@ -492,6 +628,7 @@
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 +658,13 @@
else
gtk_label_set_text (gui->source.description, "");
+ printf("provider found \n");
+
+ 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 */
Index: camel/camel-provider.h
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-provider.h,v
retrieving revision 1.40
diff -u -r1.40 camel-provider.h
--- camel/camel-provider.h 19 Feb 2004 07:27:35 -0000 1.40
+++ camel/camel-provider.h 19 Apr 2004 13:02:24 -0000
@@ -59,6 +59,8 @@
* _IS_STORAGE mail is stored there. it will appear in the folder tree.
* _IS_EXTERNAL it appears in the folder tree but is not created by
* the mail component.
+ * _CHECK_LICENSE the provider configuration first needs the license to
+ * be accepted.
*/
#define CAMEL_PROVIDER_IS_REMOTE (1 << 0)
#define CAMEL_PROVIDER_IS_LOCAL (1 << 1)
@@ -66,6 +68,7 @@
#define CAMEL_PROVIDER_IS_SOURCE (1 << 3)
#define CAMEL_PROVIDER_IS_STORAGE (1 << 4)
#define CAMEL_PROVIDER_SUPPORTS_SSL (1 << 5)
+#define CAMEL_PROVIDER_CHECK_LICENSE (1 << 6)
/* Flags for url_flags. "ALLOW" means the config dialog will let
@@ -182,6 +185,17 @@
* evolution source tree).
*/
char *translation_domain;
+
+ /* This holds the gconf key string which needs to be checked/set
+ * for accepting the license
+ */
+ const char *gconf_license_bool_key;
+
+ /* This holds the license file name [ ascii text format ] containing
+ * the license agreement. This is read only when the CHECK_LICENSE
+ * flag is set
+ */
+ const char *license_file;
} CamelProvider;
typedef struct _CamelProviderModule CamelProviderModule;
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> <!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> <glade-interface> <widget class="GtkDialog" id="lic_dialog"> <property name="visible">True</property> <property name="title" translatable="yes">Exchange Connector License Agreement for Evolution</property> <property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="window_position">GTK_WIN_POS_NONE</property> <property name="modal">False</property> <property name="resizable">True</property> <property name="destroy_with_parent">False</property> <property name="has_separator">True</property> <child internal-child="vbox"> <widget class="GtkVBox" id="dialog_vbox"> <property name="visible">True</property> <property name="homogeneous">False</property> <property name="spacing">0</property> <child internal-child="action_area"> <widget class="GtkHButtonBox" id="dialog-action_area1"> <property name="visible">True</property> <property name="layout_style">GTK_BUTTONBOX_END</property> <child> <widget class="GtkButton" id="lic_no_button"> <property name="visible">True</property> <property name="can_default">True</property> <property name="can_focus">True</property> <property name="label" translatable="yes">NO</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="response_id">0</property> </widget> </child> <child> <widget class="GtkButton" id="lic_yes_button"> <property name="visible">True</property> <property name="can_default">True</property> <property name="can_focus">True</property> <property name="label" translatable="yes">YES</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="response_id">0</property> </widget> </child> </widget> <packing> <property name="padding">0</property> <property name="expand">False</property> <property name="fill">True</property> <property name="pack_type">GTK_PACK_END</property> </packing> </child> <child> <widget class="GtkVBox" id="vbox1"> <property name="visible">True</property> <property name="homogeneous">False</property> <property name="spacing">0</property> <child> <widget class="GtkLabel" id="lic_top_label"> <property name="visible">True</property> <property name="label" translatable="yes"> Please read carefully the license agreement for Evolution Exchange Connector displayed below and tick the check box for accepting it </property> <property name="use_underline">False</property> <property name="use_markup">False</property> <property name="justify">GTK_JUSTIFY_LEFT</property> <property name="wrap">False</property> <property name="selectable">False</property> <property name="xalign">0.5</property> <property name="yalign">0.5</property> <property name="xpad">0</property> <property name="ypad">0</property> </widget> <packing> <property name="padding">0</property> <property name="expand">False</property> <property name="fill">False</property> </packing> </child> <child> <widget class="GtkScrolledWindow" id="lic_scrolledwindow"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property> <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property> <property name="shadow_type">GTK_SHADOW_NONE</property> <property name="window_placement">GTK_CORNER_TOP_LEFT</property> <child> <widget class="GtkTextView" id="textview1"> <property name="width_request">500</property> <property name="height_request">400</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="editable">True</property> <property name="justification">GTK_JUSTIFY_LEFT</property> <property name="wrap_mode">GTK_WRAP_NONE</property> <property name="cursor_visible">True</property> <property name="pixels_above_lines">0</property> <property name="pixels_below_lines">0</property> <property name="pixels_inside_wrap">0</property> <property name="left_margin">0</property> <property name="right_margin">0</property> <property name="indent">0</property> <property name="text" translatable="yes"></property> </widget> </child> </widget> <packing> <property name="padding">0</property> <property name="expand">True</property> <property name="fill">True</property> </packing> </child> <child> <widget class="GtkCheckButton" id="lic_checkbutton"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="label" translatable="yes">Tick this to accept the license agreement</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="active">False</property> <property name="inconsistent">False</property> <property name="draw_indicator">True</property> </widget> <packing> <property name="padding">0</property> <property name="expand">False</property> <property name="fill">False</property> </packing> </child> </widget> <packing> <property name="padding">0</property> <property name="expand">True</property> <property name="fill">True</property> </packing> </child> </widget> </child> </widget> </glade-interface>