From 8c0bd86d5fdd6d87c3170e2a01423e7c7018a981 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 14 Nov 2008 03:56:01 +0000 Subject: Rearranged some of the addressbook code to try and eliminate some circular dependencies in our libraries. The circular dependency between the composer and the mail module is still causing me headaches. And it doesn't help that the addressbook and calendar also want to link to the composer. svn path=/branches/kill-bonobo/; revision=36782 --- composer/e-msg-composer.c | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'composer/e-msg-composer.c') diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 0efcbfcbe9..36b6479fbf 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -69,8 +69,8 @@ #include "e-util/e-util.h" #include #include "e-signature-combo-box.h" +#include "shell/e-shell.h" -#include #include #include #include @@ -94,7 +94,6 @@ #include "mail/mail-crypto.h" #include "mail/mail-mt.h" #include "mail/mail-ops.h" -#include "mail/mail-session.h" #include "mail/mail-tools.h" #include "e-msg-composer.h" @@ -875,7 +874,9 @@ build_message (EMsgComposer *composer, if (smime_sign) { CamelMimePart *npart = camel_mime_part_new (); + CamelSession *session; + session = e_msg_composer_get_session (composer); cipher = camel_smime_context_new (session); /* if we're also encrypting, envelope-sign rather than clear-sign */ @@ -899,10 +900,13 @@ build_message (EMsgComposer *composer, } if (smime_encrypt) { + CamelSession *session; + /* check to see if we should encrypt to self, NB removed after use */ if (account->smime_encrypt_to_self) g_ptr_array_add (recipients, g_strdup (account->smime_encrypt_key)); + session = e_msg_composer_get_session (composer); cipher = camel_smime_context_new (session); camel_smime_context_set_encrypt_key ((CamelSMIMEContext *)cipher, TRUE, account->smime_encrypt_key); @@ -2932,6 +2936,7 @@ create_composer (gint visible_mask) /** * e_msg_composer_new_with_type: + * @type: the type of composer to create * * Create a new message composer widget. The type can be * E_MSG_COMPOSER_MAIL, E_MSG_COMPOSER_POST or E_MSG_COMPOSER_MAIL_POST. @@ -2940,7 +2945,7 @@ create_composer (gint visible_mask) **/ EMsgComposer * -e_msg_composer_new_with_type (int type) +e_msg_composer_new_with_type (gint type) { EMsgComposer *composer; gint visible_mask; @@ -3749,6 +3754,32 @@ e_msg_composer_new_redirect (CamelMimeMessage *message, return composer; } +/** + * e_msg_composer_get_session: + * @composer: an #EMsgComposer + * + * Returns the mail module's global #CamelSession instance. Calling + * this function will load the mail module if it isn't already loaded. + * + * Returns: the mail module's #CamelSession + **/ +CamelSession * +e_msg_composer_get_session (EMsgComposer *composer) +{ + EShellModule *shell_module; + CamelSession *session; + EShell *shell; + + g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), NULL); + + shell = e_shell_get_default (); + shell_module = e_shell_get_module_by_name (shell, "mail"); + session = g_object_get_data (G_OBJECT (shell_module), "session"); + g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL); + + return session; +} + /** * e_msg_composer_send: * @composer: an #EMsgComposer -- cgit v1.2.3