* mu-msg / mu-msg-file: move gmime init to mu_msg

we need gmime even for the MuMsgDoc backend, as there we are using gmime for
  parsing address lists. using the function without 'init' caused crashes...
This commit is contained in:
Dirk-Jan C. Binnema
2011-08-20 11:55:27 +03:00
parent 9b0a9320f5
commit 56c6863c09
3 changed files with 44 additions and 37 deletions

View File

@ -49,46 +49,12 @@ static gboolean init_file_metadata (MuMsgFile *self, const char* path,
static gboolean init_mime_msg (MuMsgFile *msg, const char *path, GError **err);
/* note, we do the gmime initialization here rather than in
* mu-runtime, because this way we don't need mu-runtime for simple
* cases -- such as our unit tests */
static gboolean _gmime_initialized = FALSE;
static void
gmime_init (void)
{
g_return_if_fail (!_gmime_initialized);
#ifdef GMIME_ENABLE_RFC2047_WORKAROUNDS
g_mime_init(GMIME_ENABLE_RFC2047_WORKAROUNDS);
#else
g_mime_init(0);
#endif /* GMIME_ENABLE_RFC2047_WORKAROUNDS */
_gmime_initialized = TRUE;
}
static void
gmime_uninit (void)
{
g_return_if_fail (_gmime_initialized);
g_mime_shutdown();
_gmime_initialized = FALSE;
}
MuMsgFile*
mu_msg_file_new (const char* filepath, const char *mdir, GError **err)
{
MuMsgFile *self;
g_return_val_if_fail (filepath, NULL);
if (G_UNLIKELY(!_gmime_initialized)) {
gmime_init ();
g_atexit (gmime_uninit);
}
self = g_slice_new0 (MuMsgFile);