aboutsummaryrefslogtreecommitdiffstats
path: root/composer
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-05-26 23:40:50 +0800
committerDan Winship <danw@src.gnome.org>2000-05-26 23:40:50 +0800
commitc6af86a140a9e54abdb19e4ccc127f061df65450 (patch)
tree1b9d1ad17b8e30b5d8443f6dded7f249ee29d3ef /composer
parent47ab2202ba161234ec2790290152f64be0163dd7 (diff)
downloadgsoc2013-evolution-c6af86a140a9e54abdb19e4ccc127f061df65450.tar
gsoc2013-evolution-c6af86a140a9e54abdb19e4ccc127f061df65450.tar.gz
gsoc2013-evolution-c6af86a140a9e54abdb19e4ccc127f061df65450.tar.bz2
gsoc2013-evolution-c6af86a140a9e54abdb19e4ccc127f061df65450.tar.lz
gsoc2013-evolution-c6af86a140a9e54abdb19e4ccc127f061df65450.tar.xz
gsoc2013-evolution-c6af86a140a9e54abdb19e4ccc127f061df65450.tar.zst
gsoc2013-evolution-c6af86a140a9e54abdb19e4ccc127f061df65450.zip
routine to read the user's signature file. (set_editor_text): If the user
* e-msg-composer.c (get_signature): routine to read the user's signature file. (set_editor_text): If the user has configured a signature, append it to the set text. (e_msg_composer_new): Call set_editor_text with "" to load the signature (if any). svn path=/trunk/; revision=3220
Diffstat (limited to 'composer')
-rw-r--r--composer/ChangeLog7
-rw-r--r--composer/e-msg-composer.c69
2 files changed, 75 insertions, 1 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index 3c5045d2a4..ffae8ed918 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -4,6 +4,13 @@
PersistStream changes
(build_message): Update for CamelMultipart changes.
+ * e-msg-composer.c (get_signature): routine to read the user's
+ signature file.
+ (set_editor_text): If the user has configured a signature, append
+ it to the set text.
+ (e_msg_composer_new): Call set_editor_text with "" to load the
+ signature (if any).
+
2000-05-25 Not Zed <NotZed@HelixCode.com>
* e-msg-composer.c (build_message): Use camel_data_wrapper_new
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 1f12d8ece5..ac6663decd 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -39,6 +39,7 @@
#include <bonobo.h>
#include <bonobo/bonobo-stream-memory.h>
#include "e-util/e-html-utils.h"
+#include "e-util/e-setup.h"
#include <glade/glade.h>
@@ -202,12 +203,73 @@ build_message (EMsgComposer *composer)
return new;
}
+static char *
+get_signature ()
+{
+ char *path, *sigfile, *rawsig;
+ static char *htmlsig = NULL;
+ static time_t sigmodtime = -1;
+ struct stat st;
+ int fd;
+
+ path = g_strdup_printf ("=%s/config=/mail/id_sig", evolution_dir);
+ sigfile = gnome_config_get_string (path);
+ g_free (path);
+ if (!sigfile || !*sigfile) {
+ return NULL;
+ }
+
+ if (stat (sigfile, &st) == -1) {
+ char *msg;
+
+ msg = g_strdup_printf ("Could not open signature file %s:\n%s",
+ sigfile, g_strerror (errno));
+ gnome_error_dialog (msg);
+ g_free (msg);
+
+ return NULL;
+ }
+
+ if (st.st_mtime == sigmodtime)
+ return htmlsig;
+
+ rawsig = g_malloc (st.st_size + 1);
+ fd = open (sigfile, O_RDONLY);
+ if (fd == -1) {
+ char *msg;
+
+ msg = g_strdup_printf ("Could not open signature file %s:\n%s",
+ sigfile, g_strerror (errno));
+ gnome_error_dialog (msg);
+ g_free (msg);
+
+ return NULL;
+ }
+
+ read (fd, rawsig, st.st_size);
+ rawsig[st.st_size] = '\0';
+ close (fd);
+
+ htmlsig = e_text_to_html (rawsig, 0);
+ sigmodtime = st.st_mtime;
+
+ return htmlsig;
+}
+
static void
set_editor_text (BonoboWidget *editor, const char *text)
{
Bonobo_PersistStream persist;
BonoboStream *stream;
CORBA_Environment ev;
+ char *sig, *fulltext;
+
+ sig = get_signature ();
+ if (sig) {
+ fulltext = g_strdup_printf ("%s<BR>\n<PRE>\n--\n%s<PRE>",
+ text, sig);
+ } else
+ fulltext = (char*)text;
CORBA_exception_init (&ev);
persist = (Bonobo_PersistStream)
@@ -217,8 +279,10 @@ set_editor_text (BonoboWidget *editor, const char *text)
&ev);
g_assert (persist != CORBA_OBJECT_NIL);
- stream = bonobo_stream_mem_create ((char *)text, strlen (text),
+ stream = bonobo_stream_mem_create (fulltext, strlen (fulltext),
TRUE, FALSE);
+ if (sig)
+ g_free (fulltext);
Bonobo_PersistStream_load (persist, (Bonobo_Stream)bonobo_object_corba_objref (BONOBO_OBJECT (stream)), "text/html", &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
/* FIXME. Some error message. */
@@ -678,6 +742,9 @@ e_msg_composer_new (void)
new = gtk_type_new (e_msg_composer_get_type ());
e_msg_composer_construct (E_MSG_COMPOSER (new));
+ /* Load the signature, if any. */
+ set_editor_text (BONOBO_WIDGET (E_MSG_COMPOSER (new)->editor), "");
+
return new;
}