aboutsummaryrefslogtreecommitdiffstats
path: root/composer
diff options
context:
space:
mode:
authorRadek Doulik <rodo@ximian.com>2002-07-30 05:36:35 +0800
committerRadek Doulik <rodo@src.gnome.org>2002-07-30 05:36:35 +0800
commit6cc38b99d610689925d69eba4f4e2b4b940f1c91 (patch)
tree8d7b594892927c7ee644c8b88054b0075231f501 /composer
parent2cced15a67c22b7a253316130ddc80463c4f5151 (diff)
downloadgsoc2013-evolution-6cc38b99d610689925d69eba4f4e2b4b940f1c91.tar
gsoc2013-evolution-6cc38b99d610689925d69eba4f4e2b4b940f1c91.tar.gz
gsoc2013-evolution-6cc38b99d610689925d69eba4f4e2b4b940f1c91.tar.bz2
gsoc2013-evolution-6cc38b99d610689925d69eba4f4e2b4b940f1c91.tar.lz
gsoc2013-evolution-6cc38b99d610689925d69eba4f4e2b4b940f1c91.tar.xz
gsoc2013-evolution-6cc38b99d610689925d69eba4f4e2b4b940f1c91.tar.zst
gsoc2013-evolution-6cc38b99d610689925d69eba4f4e2b4b940f1c91.zip
new helper function (decode_signature_name): new helper function
2002-07-29 Radek Doulik <rodo@ximian.com> * e-msg-composer.c (encode_signature_name): new helper function (decode_signature_name): new helper function (get_signature_html): use encode_signature_name (set_signature_gui): use decode_signature_name svn path=/trunk/; revision=17636
Diffstat (limited to 'composer')
-rw-r--r--composer/ChangeLog7
-rw-r--r--composer/e-msg-composer.c109
2 files changed, 112 insertions, 4 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index dc3f9798f0..c9b084d7f3 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,3 +1,10 @@
+2002-07-29 Radek Doulik <rodo@ximian.com>
+
+ * e-msg-composer.c (encode_signature_name): new helper function
+ (decode_signature_name): new helper function
+ (get_signature_html): use encode_signature_name
+ (set_signature_gui): use decode_signature_name
+
2002-07-26 Radek Doulik <rodo@ximian.com>
* e-msg-composer.c (do_exit): don't assert on default, when ESC is
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index b9effd4899..76981765a8 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -897,6 +897,98 @@ prepare_engine (EMsgComposer *composer)
}
static gchar *
+encode_signature_name (const gchar *name)
+{
+ const gchar *s;
+ gchar *ename, *e;
+ gint len = 0;
+
+ s = name;
+ while (*s) {
+ len ++;
+ if (*s == '"' || *s == '.' || *s == '=')
+ len ++;
+ s ++;
+ }
+
+ ename = g_new (gchar, len + 1);
+
+ s = name;
+ e = ename;
+ while (*s) {
+ if (*s == '"') {
+ *e = '.';
+ e ++;
+ *e = '1';
+ e ++;
+ } else if (*s == '=') {
+ *e = '.';
+ e ++;
+ *e = '2';
+ e ++;
+ } else {
+ *e = *s;
+ e ++;
+ }
+ if (*s == '.') {
+ *e = '.';
+ e ++;
+ }
+ s ++;
+ }
+ *e = 0;
+
+ printf ("name: '%s'\nencoded name: '%s'\n", name, ename);
+
+ return ename;
+}
+
+static gchar *
+decode_signature_name (const gchar *name)
+{
+ const gchar *s;
+ gchar *dname, *d;
+ gint len = 0;
+
+ s = name;
+ while (*s) {
+ len ++;
+ if (*s == '.') {
+ s ++;
+ if (!*s || !(*s == '.' || *s == '1' || *s == '2'))
+ return NULL;
+ }
+ s ++;
+ }
+
+ dname = g_new (gchar, len + 1);
+
+ s = name;
+ d = dname;
+ while (*s) {
+ if (*s == '.') {
+ s ++;
+ if (!*s || !(*s == '.' || *s == '1' || *s == '2')) {
+ g_free (dname);
+ return NULL;
+ }
+ if (*s == '1')
+ *d = '"';
+ else if (*s == '2')
+ *d = '=';
+ else
+ *d = '.';
+ } else
+ *d = *s;
+ d ++;
+ s ++;
+ }
+ *d = 0;
+
+ return dname;
+}
+
+static gchar *
get_signature_html (EMsgComposer *composer)
{
gboolean format_html = FALSE;
@@ -945,6 +1037,11 @@ get_signature_html (EMsgComposer *composer)
/* printf ("text: %s\n", text); */
if (text) {
+ gchar *encoded_name = NULL;
+
+ if (composer->signature)
+ encoded_name = encode_signature_name (composer->signature->name);
+
/* The signature dash convention ("-- \n") is specified in the
* "Son of RFC 1036": http://www.chemie.fu-berlin.de/outerspace/netnews/son-of-1036.html,
* section 4.3.2.
@@ -955,12 +1052,13 @@ get_signature_html (EMsgComposer *composer)
"%s%s%s%s"
"</TD></TR></TABLE>",
composer->signature ? "name:" : "auto",
- composer->signature ? composer->signature->name : "",
+ composer->signature ? encoded_name : "",
format_html ? "" : "<PRE>\n",
format_html || (!strncmp ("-- \n", text, 4) || strstr(text, "\n-- \n")) ? "" : "-- \n",
text,
format_html ? "" : "</PRE>\n");
g_free (text);
+ g_free (encoded_name);
text = html;
}
@@ -3226,17 +3324,20 @@ set_signature_gui (EMsgComposer *composer)
if (ev._major == CORBA_NO_EXCEPTION && str) {
if (!strncmp (str, "name:", 5)) {
GList *list = NULL;
+ gchar *decoded_signature_name = decode_signature_name (str + 5);
list = mail_config_get_signature_list ();
- if (list)
+ if (list && decoded_signature_name)
for (; list; list = list->next) {
- if (!strcmp (str + 5, ((MailConfigSignature *) list->data)->name))
+ if (!strcmp (decoded_signature_name,
+ ((MailConfigSignature *) list->data)->name))
break;
}
- if (list)
+ if (list && decoded_signature_name)
composer->signature = (MailConfigSignature *) list->data;
else
composer->auto_signature = TRUE;
+ g_free (decoded_signature_name);
} else if (!strcmp (str, "auto")) {
composer->auto_signature = TRUE;
}