[PATCH] email capplet capabilities extended




hi, 

i looked a little at the email-capplet and added some additional user
inputs. i think that all the settings that the conduit knows about can
be set now, specifically:

* you can specify the 'From' email address for mail coming from the
pilot

* the MH directory that should be scanned for messages to be uploaded 
to your pilot

* location and flags of the mailer (ie sendmail)

* what to do with the mails being synced: save/delete a copy of the 
outbound mail on the pilot and same on the host computer with mails 
going to the pilot. 

vadim, i changed the logic in the ok/try/cancel thing, could you
please double check that this is the intended behavior? thanks.

since i am also new to this project, here is the diff against last
nights CVS changes. 

cheers,
patrick.



Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-pilot/conduits/email/ChangeLog,v
retrieving revision 1.3
diff -u -r1.3 ChangeLog
--- ChangeLog	1999/10/25 03:50:42	1.3
+++ ChangeLog	1999/10/26 01:16:06
@@ -1,3 +1,20 @@
+
+1999-10-26 Patrick Decowski <decowski@mit.edu>
+	
+	* email-conduit-control-applet.c: the user can now edit the 'From'
+	address that sendmail will slap on the emails coming from the
+	pilot. the MH Directory can be edited, this is the dir from
+	which the mail is uploaded to the pilot. also the sendmail
+	location and the action to undertake with the mails being synced
+	to the pilot and from the pilot (file or delete) can be changed in
+	this capplet.
+
+	while doing this i changed the try/ok etc logic to what the backup
+	conduit is doing.
+
+	* email_conduit.h: the conduit now saves the data that was edited
+	in the capplet to '/gnome-pilot.d/email-conduit/' 
+	
 1999-10-23 Vadim Strizhvesky <vadim@optonline.net>
 
 	* email-conduit-control-applet.c: fixed some messages to pertain to 
Index: email-conduit-control-applet.c
===================================================================
RCS file: /cvs/gnome/gnome-pilot/conduits/email/email-conduit-control-applet.c,v
retrieving revision 1.9
diff -u -r1.9 email-conduit-control-applet.c
--- email-conduit-control-applet.c	1999/10/25 03:50:42	1.9
+++ email-conduit-control-applet.c	1999/10/26 01:16:06
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
 /* Control applet ("capplet") for the gnome-pilot email conduit,           */
 /* based on                                                                 */
 /* gpilotd control applet ('capplet') for use with the GNOME control center */
@@ -36,16 +37,23 @@
 static void doRevertSettings(GtkWidget *widget, ConduitCfg *conduitCfg);
 static void doSaveSettings(GtkWidget *widget, ConduitCfg *conduitCfg);
 
-static void readStateCfg(GtkWidget *,ConduitCfg*);
-static void setStateCfg(GtkWidget *,ConduitCfg*);
+static void readOptionsCfg(GtkWidget *w, ConduitCfg **state);
+static void setOptionsCfg(GtkWidget *w, ConduitCfg *state);
+static void readStateCfg(GtkWidget *w,ConduitCfg **state);
+static void setStateCfg(GtkWidget *w,ConduitCfg *state);
 
 gint pilotId;
 CORBA_Environment ev;
 
+#define ACTION_OPTIONS_COUNT 2
+static gchar* action_options[] = { N_("file"), 
+                                   N_("delete") };
+
 static void
 doTrySettings(GtkWidget *widget, ConduitCfg *conduitCfg)
 {
-    readStateCfg(cfgStateWindow,curState);
+    readStateCfg(cfgStateWindow, &conduitCfg);
+    readOptionsCfg(cfgOptionsWindow, &conduitCfg);
     if(activated)
       gpilotd_conduit_mgmt_enable(conduit,pilotId,GnomePilotConduitSyncTypeCustom);
     else
@@ -55,8 +63,8 @@
 static void
 doSaveSettings(GtkWidget *widget, ConduitCfg *conduitCfg)
 {
-    doTrySettings(widget, curState);
-    save_configuration(curState);
+    doTrySettings(widget, conduitCfg);
+    save_configuration(conduitCfg);
 }
 
 
@@ -66,12 +74,14 @@
     activated = org_activation_state;
     destroy_configuration(&curState);
     curState = dupe_configuration(origState);
-    setStateCfg(cfgStateWindow,curState);
+    setOptionsCfg(cfgOptionsWindow, curState);
+    setStateCfg(cfgStateWindow, curState);
 }
 
+/* Don't allow any spaces */
 static void
-insert_dir_callback (GtkEditable    *editable, const gchar    *text,
-		     gint len, gint *position, void *data)
+insert_callback (GtkEditable    *editable, const gchar    *text,
+                 gint len, gint *position, void *data)
 {
     gint i;
     gchar *curname;
@@ -92,10 +102,11 @@
 	}
     }
 }
+
 static void
-insert_dir_callback2(GtkEditable    *editable, const gchar    *text,
-		      gint            length, gint           *position,
-		      void *data)
+insert_callback2(GtkEditable    *editable, const gchar    *text,
+                 gint            length, gint           *position,
+                 void *data)
 {
     if (!ignore_changes)
         capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
@@ -126,7 +137,7 @@
 
 static void toggled_cb(GtkWidget *widget, gpointer data) {
   if(!ignore_changes) {
-    /* gtk_widget_set_sensitive(cfgOptionsWindow,GTK_TOGGLE_BUTTON(widget)->active); */
+          gtk_widget_set_sensitive(cfgOptionsWindow,GTK_TOGGLE_BUTTON(widget)->active);
     capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
   }
 }
@@ -170,24 +181,167 @@
 
     ignore_changes = TRUE;
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),activated);
-    /*    gtk_widget_set_sensitive(cfgOptionsWindow,GTK_TOGGLE_BUTTON(button)->active); */
+    gtk_widget_set_sensitive(cfgOptionsWindow,GTK_TOGGLE_BUTTON(button)->active);
     ignore_changes = FALSE;
 }
 
 
 static void
-readStateCfg(GtkWidget *widget,ConduitCfg *cfg)
+readStateCfg(GtkWidget *widget,ConduitCfg **cfg)
 {
-  GtkWidget *button;
+        GtkWidget *button;
 
-  button  = gtk_object_get_data(GTK_OBJECT(widget), "conduit_on_off");
-  
-  g_assert(button!=NULL);
+        button  = gtk_object_get_data(GTK_OBJECT(widget), "conduit_on_off");
+        
+        g_assert(button!=NULL);
+
+        activated = GTK_TOGGLE_BUTTON(button)->active;
+}
+
+static GtkWidget
+*createCfgWindow(void)
+{
+	GtkWidget *vbox, *table;
+	GtkWidget *entry, *label;
+	GtkWidget *button;
+	GtkWidget *combo;
+        GList    *options=NULL;
+        int i;
+
+	vbox = gtk_vbox_new(FALSE, GNOME_PAD);
+
+	table = gtk_table_new(2, 4, FALSE);
+	gtk_table_set_row_spacings(GTK_TABLE(table), 4);
+	gtk_table_set_col_spacings(GTK_TABLE(table), 10);
+	gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, GNOME_PAD);
+
+        /* Get the From Address */
+	label = gtk_label_new(_("From E-mail Address"));
+	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);
+    
+	entry = gtk_entry_new_with_max_length(128);
+	gtk_object_set_data(GTK_OBJECT(vbox), "FromAddress", entry);
+	gtk_table_attach_defaults(GTK_TABLE(table), entry, 1, 2, 0, 1);
+        /* no spaces in the fields */
+  	gtk_signal_connect(GTK_OBJECT(entry), "insert_text",
+  			   GTK_SIGNAL_FUNC(insert_callback),
+  			   NULL);
+
+	gtk_signal_connect_after(GTK_OBJECT(entry), "insert_text",
+                                 GTK_SIGNAL_FUNC(insert_callback2),
+                                 NULL);
+
+        /* Get the MH Directory */
+	label = gtk_label_new(_("MH Mail directory"));
+	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);
+
+	entry = gtk_entry_new_with_max_length(256);
+	gtk_object_set_data(GTK_OBJECT(vbox), "MailDir", entry);
+	gtk_table_attach_defaults(GTK_TABLE(table), entry, 1, 2, 1, 2);
+        /* no spaces in the fields */
+  	gtk_signal_connect(GTK_OBJECT(entry), "insert_text",
+  			   GTK_SIGNAL_FUNC(insert_callback),
+  			   NULL);
+
+        gtk_signal_connect_after(GTK_OBJECT(entry), "insert_text",
+                                 GTK_SIGNAL_FUNC(insert_callback2),
+                                 NULL);
+
+        /* Get sendmail location */
+	label = gtk_label_new(_("Mailer location"));
+	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3);
+
+	entry = gtk_entry_new_with_max_length(256);
+	gtk_object_set_data(GTK_OBJECT(vbox), "SendmailLoc", entry);
+	gtk_table_attach_defaults(GTK_TABLE(table), entry, 1, 2, 2, 3);
+
+        gtk_signal_connect_after(GTK_OBJECT(entry), "insert_text",
+                                 GTK_SIGNAL_FUNC(insert_callback2),
+                                 NULL);
+
+        for (i = 0; i < ACTION_OPTIONS_COUNT; i++) {
+                action_options[i] = _(action_options[i]);
+                options = g_list_append(options, action_options[i]);
+        }
+        
+        /* is the mail on the host computer archived? */
+        label = gtk_label_new(_("Mail on Host"));
+        gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4);
+
+        combo = gtk_combo_new();
+        gtk_combo_set_popdown_strings( GTK_COMBO(combo), options) ;
+        gtk_signal_connect(GTK_OBJECT(GTK_COMBO(combo)->entry), "changed",
+                           GTK_SIGNAL_FUNC(insert_callback2),
+                           NULL);
+        gtk_object_set_data(GTK_OBJECT(vbox), "SendAction", combo);
+ 
+        gtk_table_attach_defaults(GTK_TABLE(table), combo, 1, 2, 4, 5);
+
+
+        /* what to do with mail sent from the pilot */
+        label = gtk_label_new(_("Mail sent from pilot"));
+        gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 4, 5);
+
+        combo = gtk_combo_new();
+        gtk_combo_set_popdown_strings( GTK_COMBO(combo), options) ;
+        gtk_signal_connect(GTK_OBJECT(GTK_COMBO(combo)->entry), "changed",
+                           GTK_SIGNAL_FUNC(insert_callback2),
+                           NULL);
+        gtk_object_set_data(GTK_OBJECT(vbox), "RecvAction", combo);
+ 
+        gtk_table_attach_defaults(GTK_TABLE(table), combo, 1, 2, 3, 4);
+
+
+	return vbox;
+}
 
-  activated = GTK_TOGGLE_BUTTON(button)->active;
+static void
+setOptionsCfg(GtkWidget *pilotcfg, ConduitCfg *state)
+{
+	GtkWidget *fromAddress, *mailDir, *sendmailLoc, *sendAct, *recvAct;
+
+	fromAddress = gtk_object_get_data(GTK_OBJECT(pilotcfg), "FromAddress");
+	mailDir = gtk_object_get_data(GTK_OBJECT(pilotcfg), "MailDir");
+        sendmailLoc = gtk_object_get_data(GTK_OBJECT(pilotcfg), "SendmailLoc");
+        sendAct = gtk_object_get_data(GTK_OBJECT(pilotcfg), "SendAction");
+        recvAct = gtk_object_get_data(GTK_OBJECT(pilotcfg), "RecvAction");
+
+	g_assert(fromAddress != NULL);
+	g_assert(mailDir != NULL);
+	g_assert(sendmailLoc != NULL);
+	g_assert(sendAct != NULL);
+	g_assert(recvAct != NULL);
+
+	ignore_changes = TRUE;
+
+	gtk_entry_set_text(GTK_ENTRY(fromAddress), state->fromAddr);
+	gtk_entry_set_text(GTK_ENTRY(mailDir), state->mhDirectory);
+	gtk_entry_set_text(GTK_ENTRY(sendmailLoc), state->sendmail);
+        gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(sendAct)->entry), state->sendAction);
+        gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(recvAct)->entry), state->receiveAction);
+
+	ignore_changes = FALSE;
 }
 
 static void
+readOptionsCfg(GtkWidget *pilotcfg, ConduitCfg **state)
+{
+	GtkWidget *fromAddress, *mailDir, *sendmailLoc, *sendAct, *recvAct;
+
+	fromAddress = gtk_object_get_data(GTK_OBJECT(pilotcfg), "FromAddress");
+	mailDir = gtk_object_get_data(GTK_OBJECT(pilotcfg), "MailDir");
+	sendmailLoc = gtk_object_get_data(GTK_OBJECT(pilotcfg), "SendmailLoc");
+	sendAct = gtk_object_get_data(GTK_OBJECT(pilotcfg), "SendAction");
+	recvAct = gtk_object_get_data(GTK_OBJECT(pilotcfg), "RecvAction");
+
+	(*state)->fromAddr = gtk_entry_get_text(GTK_ENTRY(fromAddress));
+	(*state)->mhDirectory = gtk_entry_get_text(GTK_ENTRY(mailDir));
+	(*state)->sendmail = gtk_entry_get_text(GTK_ENTRY(sendmailLoc));
+	(*state)->sendAction = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(sendAct)->entry));
+	(*state)->receiveAction = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(recvAct)->entry));
+}
+
+static void
 pilot_capplet_setup(void)
 {
     GtkWidget *frame, *table;
@@ -204,17 +358,24 @@
     cfgStateWindow = createStateCfgWindow();
     gtk_container_add(GTK_CONTAINER(frame), cfgStateWindow);
 
+    frame = gtk_frame_new(_("SendMail options"));
+    gtk_container_border_width(GTK_CONTAINER(frame), GNOME_PAD_SMALL);
+    gtk_table_attach_defaults(GTK_TABLE(table), frame, 0, 1, 1, 2);
+    cfgOptionsWindow = createCfgWindow();
+    gtk_container_add(GTK_CONTAINER(frame), cfgOptionsWindow);
+
     gtk_signal_connect(GTK_OBJECT(capplet), "try",
-			GTK_SIGNAL_FUNC(doTrySettings), NULL);
+			GTK_SIGNAL_FUNC(doTrySettings), curState);
     gtk_signal_connect(GTK_OBJECT(capplet), "revert",
-			GTK_SIGNAL_FUNC(doRevertSettings), NULL);
+			GTK_SIGNAL_FUNC(doRevertSettings), curState);
     gtk_signal_connect(GTK_OBJECT(capplet), "ok",
-			GTK_SIGNAL_FUNC(doSaveSettings), NULL);
+			GTK_SIGNAL_FUNC(doSaveSettings), curState);
     gtk_signal_connect(GTK_OBJECT(capplet), "help",
 			GTK_SIGNAL_FUNC(about_cb), NULL);
 
 
-    setStateCfg(cfgStateWindow,curState);
+    setStateCfg(cfgStateWindow, curState);
+    setOptionsCfg(cfgOptionsWindow, curState);
 
     gtk_widget_show_all(capplet);
 }
Index: email_conduit.h
===================================================================
RCS file: /cvs/gnome/gnome-pilot/conduits/email/email_conduit.h,v
retrieving revision 1.7
diff -u -r1.7 email_conduit.h
--- email_conduit.h	1999/10/17 18:56:38	1.7
+++ email_conduit.h	1999/10/26 01:16:06
@@ -51,14 +51,18 @@
 	gchar *prefix;
 
 	g_assert(c!=NULL);
-	prefix = g_strdup_printf("/gnome-pilot.d/memo-conduit/Pilot_%u/",c->pilotId);
+	prefix = g_strdup_printf("/gnome-pilot.d/email-conduit/Pilot_%u/",c->pilotId);
 
 #ifdef EC_DEBUG
-	fprintf(stderr,"memo_conduit: savecfg: prefix = %s\n",prefix);
+	fprintf(stderr,"email_conduit: savecfg: prefix = %s\n",prefix);
 #endif
 
 	gnome_config_push_prefix(prefix);
-	/* config goes here */
+	gnome_config_set_string("sendmail", c->sendmail);
+	gnome_config_set_string("from_address", c->fromAddr);
+	gnome_config_set_string("send_action", c->sendAction);
+	gnome_config_set_string("mh_directory", c->mhDirectory);
+	gnome_config_set_string("receive_action", c->receiveAction);
 	gnome_config_pop_prefix();
 
 	gnome_config_sync();



-------------------------------------------o-------------------------------
Patrick Decowski                           |
24-504                                     |    Home:      (617)625-9352
Massachusetts Institute of Technology      |    Office:    (617)253-9735
77 Massachusetts Ave                       |    Fax:       (617)253-1755
Cambridge, MA 02139-4307                   |
-------------------------------------------o-------------------------------
http://web.mit.edu/decowski/www/home.html  |    e-mail: decowski@mit.edu
-------------------------------------------o-------------------------------



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]