示例#1
0
文件: mu-msg.c 项目: akonring/mu
/* for some data, we need to read the message file from disk */
gboolean
mu_msg_load_msg_file (MuMsg *self, GError **err)
{
	const char *path;

	g_return_val_if_fail (self, FALSE);

	if (self->_file)
		return TRUE; /* nothing to do */

	if (!(path = get_path (self))) {
		mu_util_g_set_error (err, MU_ERROR_INTERNAL,
				     "cannot get path for message");
		return FALSE;
	}

	self->_file = mu_msg_file_new (path, NULL, err);

	return  (self->_file != NULL);
}
示例#2
0
文件: mu-msg.c 项目: bonega/mu
/* for some data, we need to read the message file from disk */
static MuMsgFile*
get_msg_file (MuMsg *self)
{
	MuMsgFile *mfile;
	const char *path;
	GError *err;

	if (!(path = get_path (self)))
		return NULL;

	err = NULL;
	mfile = mu_msg_file_new (path, NULL, &err);
	if (!mfile) {
		g_warning ("%s: failed to create MuMsgFile: %s",
			   __FUNCTION__, err->message ? err->message : "?");
		g_error_free (err);
		return NULL;
	}

	return mfile;
}
示例#3
0
文件: mu-msg.c 项目: bonega/mu
MuMsg*
mu_msg_new_from_file (const char *path, const char *mdir, GError **err)
{
	MuMsg *self;
	MuMsgFile *msgfile;

	g_return_val_if_fail (path, NULL);

	if (G_UNLIKELY(!_gmime_initialized)) {
		gmime_init ();
		atexit (gmime_uninit);
	}

	msgfile = mu_msg_file_new (path, mdir, err);
	if (!msgfile)
		return NULL;

	self = msg_new ();
	self->_file = msgfile;

	return self;
}
示例#4
0
文件: mu-msg.c 项目: tuxella/mu
/*
 * move a msg to another maildir, trying to maintain 'integrity',
 * ie. msg in 'new/' will go to new/, one in cur/ goes to cur/. be
 * super-paranoid here...
 */
gboolean
mu_msg_move_to_maildir (MuMsg *self, const char *maildir,
			MuFlags flags, gboolean ignore_dups, gboolean new_name,
			GError **err)
{
	char *newfullpath;
	char *targetmdir;

	g_return_val_if_fail (self, FALSE);
	g_return_val_if_fail (maildir, FALSE);     /* i.e. "/inbox" */

	/* targetmdir is the full path to maildir, i.e.,
	 * /home/foo/Maildir/inbox */
	targetmdir = get_target_mdir (self, maildir, err);
	if (!targetmdir)
		return FALSE;

	newfullpath = mu_maildir_move_message (mu_msg_get_path (self),
					       targetmdir, flags,
					       ignore_dups, new_name, err);
	/* update the message path and the flags; they may have
	 * changed */
	if (!newfullpath) {
		g_free (targetmdir);
		return FALSE;
	}

	/* clear the old backends */
	mu_msg_doc_destroy  (self->_doc);
	self->_doc = NULL;

	mu_msg_file_destroy (self->_file);

	/* and create a new one */
	self->_file = mu_msg_file_new (newfullpath, maildir, err);
	g_free (targetmdir);

	return self->_file ? TRUE : FALSE;
}