aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-05-17 05:52:49 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-05-17 05:52:49 +0800
commit1849ce6cd24bf6d57dca4e34207e231fd03d8c02 (patch)
treebb7bb9ddf55a73c71efca0fb5bba8f961709bc2c
parent7031a911d71eb1f527f8ff9336f050679a7b74f9 (diff)
downloadgsoc2013-evolution-1849ce6cd24bf6d57dca4e34207e231fd03d8c02.tar
gsoc2013-evolution-1849ce6cd24bf6d57dca4e34207e231fd03d8c02.tar.gz
gsoc2013-evolution-1849ce6cd24bf6d57dca4e34207e231fd03d8c02.tar.bz2
gsoc2013-evolution-1849ce6cd24bf6d57dca4e34207e231fd03d8c02.tar.lz
gsoc2013-evolution-1849ce6cd24bf6d57dca4e34207e231fd03d8c02.tar.xz
gsoc2013-evolution-1849ce6cd24bf6d57dca4e34207e231fd03d8c02.tar.zst
gsoc2013-evolution-1849ce6cd24bf6d57dca4e34207e231fd03d8c02.zip
Added S/MIME sign/encrypt code. (init): Initalize smime_sign/encrypt.
2001-05-16 Jeffrey Stedfast <fejj@ximian.com> * e-msg-composer.c (build_message): Added S/MIME sign/encrypt code. (init): Initalize smime_sign/encrypt. (e_msg_composer_get_smime_encrypt): new (e_msg_composer_set_smime_encrypt): new (e_msg_composer_get_smime_sign): new (e_msg_composer_set_smime_sign): new (menu_security_smime_sign_cb): new (menu_security_smime_encrypt_cb): new (setup_ui): Setup the UI for S/MIME stuff. svn path=/trunk/; revision=9858
-rw-r--r--composer/ChangeLog12
-rw-r--r--composer/e-msg-composer.c222
-rw-r--r--composer/e-msg-composer.h39
3 files changed, 254 insertions, 19 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index 07a3ad90ec..d4ed6e3018 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,3 +1,15 @@
+2001-05-16 Jeffrey Stedfast <fejj@ximian.com>
+
+ * e-msg-composer.c (build_message): Added S/MIME sign/encrypt code.
+ (init): Initalize smime_sign/encrypt.
+ (e_msg_composer_get_smime_encrypt): new
+ (e_msg_composer_set_smime_encrypt): new
+ (e_msg_composer_get_smime_sign): new
+ (e_msg_composer_set_smime_sign): new
+ (menu_security_smime_sign_cb): new
+ (menu_security_smime_encrypt_cb): new
+ (setup_ui): Setup the UI for S/MIME stuff.
+
2001-05-10 Jeffrey Stedfast <fejj@ximian.com>
* e-msg-composer.c (build_message): If we are creating a message
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index bfa11d0507..d78c509f44 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -413,7 +413,8 @@ build_message (EMsgComposer *composer)
break;
case MSG_FORMAT_PLAIN:
/* FIXME: this is just evil... */
- if (!(composer->pgp_sign || composer->pgp_encrypt))
+ if (!(composer->pgp_sign || composer->pgp_encrypt ||
+ composer->smime_sign || composer->smime_encrypt))
part = CAMEL_MIME_PART (new);
else
part = camel_mime_part_new ();
@@ -486,6 +487,70 @@ build_message (EMsgComposer *composer)
goto exception;
}
+#ifdef HAVE_NSS
+ if (composer->smime_sign) {
+ /* FIXME: should use the S/MIME signature certificate email address */
+ const char *address;
+
+ camel_exception_init (&ex);
+ from = e_msg_composer_hdrs_get_from (E_MSG_COMPOSER_HDRS (composer->hdrs));
+ camel_internet_address_get (from, 0, NULL, &address);
+ mail_crypto_smime_part_sign (&part, address, CAMEL_CIPHER_HASH_SHA1,
+ &ex);
+ camel_object_unref (CAMEL_OBJECT (from));
+ if (camel_exception_is_set (&ex))
+ goto exception;
+ }
+
+ if (composer->smime_encrypt) {
+ /* FIXME: recipients should be an array of certificates rather than email addresses */
+ const CamelInternetAddress *addr;
+ const char *address;
+ GPtrArray *recipients;
+ int i, len;
+
+ camel_exception_init (&ex);
+ recipients = g_ptr_array_new ();
+
+ addr = camel_mime_message_get_recipients (new, CAMEL_RECIPIENT_TYPE_TO);
+ len = camel_address_length (CAMEL_ADDRESS (addr));
+ for (i = 0; i < len; i++) {
+ camel_internet_address_get (addr, i, NULL, &address);
+ g_ptr_array_add (recipients, g_strdup (address));
+ }
+
+ addr = camel_mime_message_get_recipients (new, CAMEL_RECIPIENT_TYPE_CC);
+ len = camel_address_length (CAMEL_ADDRESS (addr));
+ for (i = 0; i < len; i++) {
+ camel_internet_address_get (addr, i, NULL, &address);
+ g_ptr_array_add (recipients, g_strdup (address));
+ }
+
+ addr = camel_mime_message_get_recipients (new, CAMEL_RECIPIENT_TYPE_BCC);
+ len = camel_address_length (CAMEL_ADDRESS (addr));
+ for (i = 0; i < len; i++) {
+ camel_internet_address_get (addr, i, NULL, &address);
+ g_ptr_array_add (recipients, g_strdup (address));
+ }
+
+ mail_crypto_smime_part_encrypt (&part, recipients, &ex);
+ for (i = 0; i < recipients->len; i++)
+ g_free (recipients->pdata[i]);
+ g_ptr_array_free (recipients, TRUE);
+ if (camel_exception_is_set (&ex))
+ goto exception;
+ }
+#else
+ if (composer->smime_sign || composer->smime_encrypt) {
+ camel_exception_setv (&ex, CAMEL_EXCEPTION_SYSTEM,
+ _("This version of Evolution was not built with support for S/MIME.\n"
+ "You may wish to instead use PGP to %s your document."),
+ composer->smime_sign && composer->smime_encrypt ? _("sign and encrypt") :
+ (composer->smime_sign ? _("sign") : _("encrypt")));
+ goto exception;
+ }
+#endif /* HAVE_NSS */
+
/* set the toplevel mime part of the message */
if (part != CAMEL_MIME_PART (new)) {
camel_medium_set_content_object (CAMEL_MEDIUM (new),
@@ -1193,7 +1258,7 @@ menu_security_pgp_sign_cb (BonoboUIComponent *component,
{
if (type != Bonobo_UIComponent_STATE_CHANGED)
return;
-
+
e_msg_composer_set_pgp_sign (E_MSG_COMPOSER (composer), atoi (state));
}
@@ -1212,6 +1277,35 @@ menu_security_pgp_encrypt_cb (BonoboUIComponent *component,
}
static void
+menu_security_smime_sign_cb (BonoboUIComponent *component,
+ const char *path,
+ Bonobo_UIComponent_EventType type,
+ const char *state,
+ gpointer composer)
+
+{
+ if (type != Bonobo_UIComponent_STATE_CHANGED)
+ return;
+
+ e_msg_composer_set_smime_sign (E_MSG_COMPOSER (composer), atoi (state));
+}
+
+static void
+menu_security_smime_encrypt_cb (BonoboUIComponent *component,
+ const char *path,
+ Bonobo_UIComponent_EventType type,
+ const char *state,
+ gpointer composer)
+
+{
+ if (type != Bonobo_UIComponent_STATE_CHANGED)
+ return;
+
+ e_msg_composer_set_smime_encrypt (E_MSG_COMPOSER (composer), atoi (state));
+}
+
+
+static void
menu_view_from_cb (BonoboUIComponent *component,
const char *path,
Bonobo_UIComponent_EventType type,
@@ -1285,6 +1379,7 @@ static void
setup_ui (EMsgComposer *composer)
{
BonoboUIContainer *container;
+ gboolean hide_smime;
container = bonobo_ui_container_new ();
bonobo_ui_container_set_win (container, BONOBO_WINDOW (composer));
@@ -1359,6 +1454,36 @@ setup_ui (EMsgComposer *composer)
composer->uic, "SecurityPGPEncrypt",
menu_security_pgp_encrypt_cb, composer);
+#ifdef HAVE_NSS
+ hide_smime = FALSE;
+#else
+ hide_smime = TRUE;
+#endif
+
+ /* Security -> S/MIME Sign */
+ bonobo_ui_component_set_prop (
+ composer->uic, "/commands/SecuritySMimeSign",
+ "state", composer->smime_sign ? "1" : "0", NULL);
+ bonobo_ui_component_set_prop (
+ composer->uic, "/commands/SecuritySMimeSign",
+ "hidden", hide_smime ? "1" : "0", NULL);
+
+ bonobo_ui_component_add_listener (
+ composer->uic, "SecuritySMimeSign",
+ menu_security_smime_sign_cb, composer);
+
+ /* Security -> S/MIME Encrypt */
+ bonobo_ui_component_set_prop (
+ composer->uic, "/commands/SecuritySMimeEncrypt",
+ "state", composer->smime_encrypt ? "1" : "0", NULL);
+ bonobo_ui_component_set_prop (
+ composer->uic, "/commands/SecuritySMimeEncrypt",
+ "hidden", hide_smime ? "1" : "0", NULL);
+
+ bonobo_ui_component_add_listener (
+ composer->uic, "SecuritySMimeEncrypt",
+ menu_security_smime_encrypt_cb, composer);
+
/* View -> Attachments */
bonobo_ui_component_add_listener (
composer->uic, "ViewAttach",
@@ -1596,7 +1721,9 @@ init (EMsgComposer *composer)
composer->send_html = FALSE;
composer->pgp_sign = FALSE;
composer->pgp_encrypt = FALSE;
-
+ composer->smime_sign = FALSE;
+ composer->smime_encrypt = FALSE;
+
composer->has_changed = FALSE;
}
@@ -2583,7 +2710,7 @@ e_msg_composer_get_pgp_sign (EMsgComposer *composer)
{
g_return_val_if_fail (composer != NULL, FALSE);
g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), FALSE);
-
+
return composer->pgp_sign;
}
@@ -2626,12 +2753,97 @@ e_msg_composer_get_pgp_encrypt (EMsgComposer *composer)
{
g_return_val_if_fail (composer != NULL, FALSE);
g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), FALSE);
-
+
return composer->pgp_encrypt;
}
/**
+ * e_msg_composer_set_smime_sign:
+ * @composer: A message composer widget
+ * @send_html: Whether the composer should have the "S/MIME Sign" flag set
+ *
+ * Set the status of the "S/MIME Sign" toggle item. The user can override it.
+ **/
+void
+e_msg_composer_set_smime_sign (EMsgComposer *composer, gboolean smime_sign)
+{
+ g_return_if_fail (composer != NULL);
+ g_return_if_fail (E_IS_MSG_COMPOSER (composer));
+
+ if (composer->smime_sign && smime_sign)
+ return;
+ if (!composer->smime_sign && !smime_sign)
+ return;
+
+ composer->smime_sign = smime_sign;
+
+ bonobo_ui_component_set_prop (composer->uic, "/commands/SecuritySMimeSign",
+ "state", composer->smime_sign ? "1" : "0", NULL);
+}
+
+/**
+ * e_msg_composer_get_smime_sign:
+ * @composer: A message composer widget
+ *
+ * Get the status of the "S/MIME Sign" flag.
+ *
+ * Return value: The status of the "S/MIME Sign" flag.
+ **/
+gboolean
+e_msg_composer_get_smime_sign (EMsgComposer *composer)
+{
+ g_return_val_if_fail (composer != NULL, FALSE);
+ g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), FALSE);
+
+ return composer->smime_sign;
+}
+
+
+/**
+ * e_msg_composer_set_smime_encrypt:
+ * @composer: A message composer widget
+ * @send_html: Whether the composer should have the "S/MIME Encrypt" flag set
+ *
+ * Set the status of the "S/MIME Encrypt" toggle item. The user can override it.
+ **/
+void
+e_msg_composer_set_smime_encrypt (EMsgComposer *composer, gboolean smime_encrypt)
+{
+ g_return_if_fail (composer != NULL);
+ g_return_if_fail (E_IS_MSG_COMPOSER (composer));
+
+ if (composer->smime_encrypt && smime_encrypt)
+ return;
+ if (!composer->smime_encrypt && !smime_encrypt)
+ return;
+
+ composer->smime_encrypt = smime_encrypt;
+
+ bonobo_ui_component_set_prop (composer->uic, "/commands/SecuritySMimeEncrypt",
+ "state", composer->smime_encrypt ? "1" : "0", NULL);
+}
+
+
+/**
+ * e_msg_composer_get_smime_encrypt:
+ * @composer: A message composer widget
+ *
+ * Get the status of the "S/MIME Encrypt" flag.
+ *
+ * Return value: The status of the "S/MIME Encrypt" flag.
+ **/
+gboolean
+e_msg_composer_get_smime_encrypt (EMsgComposer *composer)
+{
+ g_return_val_if_fail (composer != NULL, FALSE);
+ g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), FALSE);
+
+ return composer->smime_encrypt;
+}
+
+
+/**
* e_msg_composer_set_view_bcc:
* @composer: A message composer widget
* @state: whether to show or hide the bcc view
diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h
index 68aae2cc73..7f0db7e16b 100644
--- a/composer/e-msg-composer.h
+++ b/composer/e-msg-composer.h
@@ -76,15 +76,17 @@ struct _EMsgComposer {
char *sig_file;
gboolean attachment_bar_visible : 1;
- gboolean send_html : 1;
- gboolean pgp_sign : 1;
- gboolean pgp_encrypt : 1;
- gboolean view_from : 1;
- gboolean view_replyto : 1;
- gboolean view_bcc : 1;
- gboolean view_cc : 1;
- gboolean view_subject : 1;
- gboolean has_changed : 1;
+ gboolean send_html : 1;
+ gboolean pgp_sign : 1;
+ gboolean pgp_encrypt : 1;
+ gboolean smime_sign : 1;
+ gboolean smime_encrypt : 1;
+ gboolean view_from : 1;
+ gboolean view_replyto : 1;
+ gboolean view_bcc : 1;
+ gboolean view_cc : 1;
+ gboolean view_subject : 1;
+ gboolean has_changed : 1;
gboolean in_signature_insert : 1;
};
@@ -143,6 +145,13 @@ void e_msg_composer_set_view_cc (EMsgComposer *compose
const MailConfigAccount *e_msg_composer_get_preferred_account (EMsgComposer *composer);
+void e_msg_composer_clear_inlined_table (EMsgComposer *composer);
+gchar * e_msg_composer_guess_mime_type (const gchar *file_name);
+
+void e_msg_composer_set_changed (EMsgComposer *composer);
+void e_msg_composer_unset_changed (EMsgComposer *composer);
+
+/* PGP */
void e_msg_composer_set_pgp_sign (EMsgComposer *composer,
gboolean pgp_sign);
gboolean e_msg_composer_get_pgp_sign (EMsgComposer *composer);
@@ -150,11 +159,13 @@ void e_msg_composer_set_pgp_encrypt (EMsgComposer *compose
gboolean pgp_encrypt);
gboolean e_msg_composer_get_pgp_encrypt (EMsgComposer *composer);
-void e_msg_composer_clear_inlined_table (EMsgComposer *composer);
-gchar * e_msg_composer_guess_mime_type (const gchar *file_name);
-
-void e_msg_composer_set_changed (EMsgComposer *composer);
-void e_msg_composer_unset_changed (EMsgComposer *composer);
+/* S/MIME */
+void e_msg_composer_set_smime_sign (EMsgComposer *composer,
+ gboolean smime_sign);
+gboolean e_msg_composer_get_smime_sign (EMsgComposer *composer);
+void e_msg_composer_set_smime_encrypt (EMsgComposer *composer,
+ gboolean smime_encrypt);
+gboolean e_msg_composer_get_smime_encrypt (EMsgComposer *composer);
#ifdef __cplusplus
}