request for help
- From: christophe barbe <christophe barbe ml online fr>
- To: balsa mailing-list <balsa-list gnome org>
- Subject: request for help
- Date: Mon, 20 Aug 2001 21:07:58 +0200
I've attached to this mail a patch which is supposed to add an option in
the preferences dialogbox.
This option, ignore the badly choosen name (I'm going to find a better
one), ask for a program to set the X_Operating-System field in outgoing
mail and offer a preview.
This is something that is available with MUTT and I like that because it's
a way to advertise your favorite OS.
(personnaly I use echo -n "GNU/Debian SID on `uname -s -r`')
Everything is in place except adding the field in outgoing message but this
is easy.
My problem is that when I apply this patch I can no more open mailbox. I
imagine it's a problem with multi-thread and popen() but I can't figure out
why.
I'm not so experienced with gnome stuff too.
So if you can look at it I would be very pleased to learn.
Thank you,
Christophe
--
Christophe Barbé <christophe.barbe@online.fr>
GnuPG FingerPrint: E0F6 FADF 2A5C F072 6AF8 F67A 8F45 2F1E D72C B41E
diff -u -r balsa-before/src/balsa-app.c balsa-1.2.pre1/src/balsa-app.c
--- balsa-before/src/balsa-app.c Sun Aug 19 21:40:43 2001
+++ balsa-1.2.pre1/src/balsa-app.c Sun Aug 19 18:58:41 2001
@@ -277,6 +277,10 @@
/* arp */
balsa_app.quote_str = NULL;
+ /* X-Operating-System */
+ balsa_app.xsysop_cmd = g_strdup("uname -s -r");
+ balsa_app.xsysop_str = NULL;
+
/* quote regex */
balsa_app.quote_regex = g_strdup(DEFAULT_QUOTE_REGEX);
diff -u -r balsa-before/src/balsa-app.h balsa-1.2.pre1/src/balsa-app.h
--- balsa-before/src/balsa-app.h Sun Aug 19 21:40:43 2001
+++ balsa-1.2.pre1/src/balsa-app.h Sun Aug 19 18:57:58 2001
@@ -268,6 +268,10 @@
/* arp --- string to prefix "replied to" messages. */
gchar *quote_str;
+ /* X-Operating-System */
+ gchar *xsysop_cmd;
+ gchar *xsysop_str; /* this variable is runtime only (never saved) */
+
/* command line options */
gint check_mail_upon_startup;
gint remember_open_mboxes;
diff -u -r balsa-before/src/main.c balsa-1.2.pre1/src/main.c
--- balsa-before/src/main.c Sun Aug 19 21:40:03 2001
+++ balsa-1.2.pre1/src/main.c Sun Aug 19 19:13:11 2001
@@ -1,4 +1,5 @@
/* -*-mode:c; c-style:k&r; c-basic-offset:4; -*- */
+/* vim:set ts=4 sw=4 ai et */
/* Balsa E-Mail Client
* Copyright (C) 1997-2001 Stuart Parmenter and others,
* See the file AUTHORS for a list.
@@ -51,6 +52,7 @@
#include "mailbox-node.h"
#include "save-restore.h"
#include "sendmsg-window.h"
+#include "pref-manager.h"
#include "main.h"
#include "information.h"
#include "pop3.h"
@@ -305,7 +307,10 @@
/* checking for valid config files */
config_init();
- /* load mailboxes */
+ /* set X-Operating-System string */
+ update_xsysop_value();
+
+ /* load mailboxes */
mailboxes_init();
/* create all the pretty icons that balsa uses that
diff -u -r balsa-before/src/pref-manager.c balsa-1.2.pre1/src/pref-manager.c
--- balsa-before/src/pref-manager.c Sun Aug 19 21:40:43 2001
+++ balsa-1.2.pre1/src/pref-manager.c Sun Aug 19 19:12:46 2001
@@ -1,4 +1,5 @@
/* -*-mode:c; c-style:k&r; c-basic-offset:4; -*- */
+/* vim:set ts=4 sw=4 ai et */
/* Balsa E-Mail Client
* Copyright (C) 1997-2001 Stuart Parmenter and others,
* See the file AUTHORS for a list.
@@ -93,6 +94,12 @@
/* arp */
GtkWidget *quote_str;
+ /* Command used to get system information for X-Operating-System
+ * header field in outgoing mail */
+ GtkWidget *xsysop_cmd;
+ GtkWidget *xsysop_preview_update;
+ GtkWidget *xsysop_preview_text;
+
GtkWidget *message_font; /* font used to display messages */
GtkWidget *subject_font; /* font used to display messages */
GtkWidget *font_picker;
@@ -147,6 +154,7 @@
static void destroy_pref_window_cb(GtkWidget * pbox, gpointer data);
static void set_prefs(void);
static void apply_prefs(GnomePropertyBox * pbox, gint page_num);
+void update_xsysop_value(void);
void update_mail_servers(void);
static void update_address_books(void);
static void properties_modified_cb(GtkWidget * widget, GtkWidget * pbox);
@@ -158,6 +166,8 @@
static void address_book_add_cb(GtkWidget * widget, gpointer data);
static void address_book_delete_cb(GtkWidget * widget, gpointer data);
static void timer_modified_cb(GtkWidget * widget, GtkWidget * pbox);
+static void xsysop_modified_cb(GtkWidget * widget, GtkWidget * pbox);
+static void xsysop_preview_cb(GtkWidget * widget, GtkWidget * pbox);
static void mailbox_timer_modified_cb(GtkWidget * widget, GtkWidget * pbox);
static void wrap_modified_cb(GtkWidget * widget, GtkWidget * pbox);
static void pgdown_modified_cb(GtkWidget * widget, GtkWidget * pbox);
@@ -373,6 +383,14 @@
GTK_SIGNAL_FUNC(properties_modified_cb),
property_box);
+ /* X-Operating-System */
+ gtk_signal_connect(GTK_OBJECT(pui->xsysop_cmd), "changed",
+ GTK_SIGNAL_FUNC(xsysop_modified_cb),
+ property_box);
+ gtk_signal_connect(GTK_OBJECT(pui->xsysop_preview_update), "clicked",
+ GTK_SIGNAL_FUNC(xsysop_preview_cb),
+ property_box);
+
/* message font */
gtk_signal_connect(GTK_OBJECT(pui->message_font), "changed",
GTK_SIGNAL_FUNC(font_changed), property_box);
@@ -581,7 +599,13 @@
balsa_app.quote_str =
g_strdup(gtk_entry_get_text(GTK_ENTRY(pui->quote_str)));
- g_free(balsa_app.message_font);
+ /* X-Operating-System */
+ g_free(balsa_app.xsysop_cmd);
+ balsa_app.xsysop_cmd =
+ g_strdup(gtk_entry_get_text(GTK_ENTRY(pui->xsysop_cmd)));
+ update_xsysop_value();
+
+ g_free(balsa_app.message_font);
balsa_app.message_font =
g_strdup(gtk_entry_get_text(GTK_ENTRY(pui->message_font)));
g_free(balsa_app.subject_font);
@@ -802,6 +826,10 @@
gtk_entry_set_text(GTK_ENTRY(entry_widget), tmp);
g_free(tmp);
+ /* X-Operating-System */
+ gtk_entry_set_text(GTK_ENTRY(pui->xsysop_cmd), balsa_app.xsysop_cmd);
+ xsysop_preview_cb(NULL, NULL);
+
/* message font */
gtk_entry_set_text(GTK_ENTRY(pui->message_font),
balsa_app.message_font);
@@ -950,6 +978,51 @@
}
void
+update_xsysop_value(void)
+{
+ FILE *fp;
+ gchar *value, *cmdpath;
+
+ if (balsa_app.xsysop_cmd[0] == 0) return;
+
+ cmdpath=g_strdup(balsa_app.xsysop_cmd);
+
+ if ((fp = popen(cmdpath,"r")) == NULL) return;
+
+ libbalsa_readfile_nostat(fp, &value);
+ pclose(fp);
+ g_free(cmdpath);
+
+ if (balsa_app.xsysop_str!=NULL) g_free(balsa_app.xsysop_str);
+ balsa_app.xsysop_str=value;
+
+ fprintf(stderr, "--> %s\n", value);
+
+}
+
+static void
+xsysop_preview_cb(GtkWidget * widget, GtkWidget * pbox)
+{
+ FILE *fp;
+ gchar *preview, *cmdpath;
+
+ cmdpath =
+ g_strdup(gtk_entry_get_text(GTK_ENTRY(pui->xsysop_cmd)));
+
+ if (cmdpath[0] == 0) return;
+
+ if ((fp = popen(cmdpath,"r")) == NULL) return;
+
+ libbalsa_readfile_nostat(fp, &preview);
+ pclose(fp);
+
+ g_free(cmdpath);
+
+ gtk_label_set_text(GTK_LABEL (pui->xsysop_preview_text), preview);
+ /* disable preview button */
+}
+
+void
update_mail_servers(void)
{
GtkCList *clist;
@@ -1376,6 +1449,8 @@
GtkWidget *frame2;
GtkWidget *table;
GtkTable *table2;
+ GtkTable *table3;
+ GtkTable *table4;
GtkObject *spinbutton_adj;
GtkWidget *label;
GtkWidget *vbox1, *vbox2;
@@ -1417,7 +1492,7 @@
vbox2 = vbox_in_container(frame2);
- table2 = GTK_TABLE(gtk_table_new(3, 2, FALSE));
+ table2 = GTK_TABLE(gtk_table_new(3, 2, FALSE));
gtk_container_add(GTK_CONTAINER(vbox2), GTK_WIDGET(table2));
gtk_container_set_border_width(GTK_CONTAINER(table2), 2);
pui->quote_str = attach_entry(_("Reply prefix:"), 4, table2);
@@ -1427,6 +1502,31 @@
gtk_box_pack_start(GTK_BOX(vbox2), pui->always_queue_sent_mail,
FALSE, TRUE, 0);
+ table3 = GTK_TABLE(gtk_table_new(3, 2, FALSE));
+ gtk_container_add(GTK_CONTAINER(vbox2), GTK_WIDGET(table3));
+ gtk_container_set_border_width(GTK_CONTAINER(table3), 2);
+ pui->xsysop_cmd = attach_entry(_("System identification command :"),
+ 4, table3);
+
+ table4 = GTK_TABLE(gtk_table_new(3, 2, FALSE));
+ gtk_container_add(GTK_CONTAINER(vbox2), GTK_WIDGET(table4));
+ gtk_container_set_border_width(GTK_CONTAINER(table4), 2);
+
+
+ pui->xsysop_preview_update =
+ gtk_button_new_with_label(_("Preview:"));
+ gtk_table_attach(GTK_TABLE(table4), pui->xsysop_preview_update,
+ 0, 1, 0, 1,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+
+ pui->xsysop_preview_text =
+ gtk_label_new("");
+ gtk_table_attach(GTK_TABLE(table4), pui->xsysop_preview_text,
+ 1, 2, 0, 1,
+ (GtkAttachOptions) (0), (GtkAttachOptions) (0), 0, 0);
+
+
frame2 = gtk_frame_new(_("Encoding"));
gtk_box_pack_start(GTK_BOX(vbox1), frame2, FALSE, FALSE, 0);
gtk_container_set_border_width(GTK_CONTAINER(frame2), 5);
@@ -2149,6 +2249,14 @@
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pui->check_mail_auto));
gtk_widget_set_sensitive(GTK_WIDGET(pui->check_mail_minutes), newstate);
+ properties_modified_cb(widget, pbox);
+}
+
+void
+xsysop_modified_cb(GtkWidget * widget, GtkWidget * pbox)
+{
+ /* enable preview button */
+
properties_modified_cb(widget, pbox);
}
diff -u -r balsa-before/src/pref-manager.h balsa-1.2.pre1/src/pref-manager.h
--- balsa-before/src/pref-manager.h Sun Aug 19 21:40:03 2001
+++ balsa-1.2.pre1/src/pref-manager.h Sun Aug 19 17:27:32 2001
@@ -33,5 +33,8 @@
/* update the mail (POP3, IMAP) server clist */
void update_mail_servers(void);
+/* update system identification string */
+void update_xsysop_value(void);
+
#endif
/* __PREF_MANAGER_H__ */
diff -u -r balsa-before/src/save-restore.c balsa-1.2.pre1/src/save-restore.c
--- balsa-before/src/save-restore.c Sun Aug 19 21:40:43 2001
+++ balsa-1.2.pre1/src/save-restore.c Sun Aug 19 16:37:10 2001
@@ -655,6 +655,8 @@
balsa_app.wraplength = 40;
balsa_app.always_queue_sent_mail = d_get_gint("AlwaysQueueSentMail", 0);
+ g_free(balsa_app.xsysop_cmd);
+ balsa_app.xsysop_cmd = gnome_config_get_string("SystemIdentificationCmd");
gnome_config_pop_prefix();
@@ -880,6 +882,7 @@
gnome_config_set_int("WrapLength", balsa_app.wraplength);
gnome_config_set_int("AlwaysQueueSentMail", balsa_app.always_queue_sent_mail);
+ gnome_config_set_string("SystemIdentificationCmd", balsa_app.xsysop_cmd);
gnome_config_pop_prefix();
/* Compose window ... */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]