Ejemplo n.º 1
0
static gboolean
handle_encrypted_part (MuMsg *msg, GMimeMultipartEncrypted *part,
		       MuMsgOptions opts, unsigned *index,
		       MuMsgPartForeachFunc func, gpointer user_data)
{
	GError *err;
	gboolean rv;
	GMimeObject *dec;
	MuMsgPartPasswordFunc pw_func;

	if (opts & MU_MSG_OPTION_CONSOLE_PASSWORD)
		pw_func = (MuMsgPartPasswordFunc)get_console_pw;
	else
		pw_func = NULL;


	err = NULL;
	dec = mu_msg_crypto_decrypt_part (part, opts, pw_func, NULL, &err);
	if (err) {
		g_warning ("error decrypting part: %s", err->message);
		g_clear_error (&err);
	}

	if (dec) {
		rv = handle_mime_object (msg, dec, (GMimeObject *) part,
		                         opts, index, TRUE, func, user_data);
		g_object_unref (dec);
	} else {
		/* On failure to decrypt, list the encrypted part as
		 * an attachment
		 */
		GMimeObject *encrypted;

		encrypted = g_mime_multipart_get_part (
			GMIME_MULTIPART (part), 1);

		g_return_val_if_fail (GMIME_IS_PART(encrypted), FALSE);

		rv = handle_mime_object (msg, encrypted, (GMimeObject *) part,
		                         opts, index, FALSE, func, user_data);
	}

	return rv;
}
Ejemplo n.º 2
0
static void
each_child (GMimeObject *parent, GMimeObject *part,
	    ForeachData *fdata)
{
	handle_mime_object (fdata->msg,
			    part,
			    parent,
			    fdata->opts,
			    fdata->index++,
			    fdata->func,
			    fdata->user_data);
}
Ejemplo n.º 3
0
static gboolean
handle_multipart (MuMsg *msg, GMimeMultipart *mpart, GMimeObject *parent,
                  MuMsgOptions opts, unsigned *index, gboolean decrypted,
		  MuMsgPartForeachFunc func, gpointer user_data)
{
	gboolean res;
	GMimeObject *part;
	guint i;

	res = TRUE;
	for (i = 0; i < mpart->children->len; i++) {
		part = (GMimeObject *) mpart->children->pdata[i];
		res &= handle_mime_object (msg, part, parent,
		                           opts, index, decrypted,
		                           func, user_data);
	}

	return res;
}
Ejemplo n.º 4
0
static char*
get_text_from_mime_msg (MuMsg *msg, GMimeMessage *mmsg, MuMsgOptions opts)
{
	GString *gstr;
	unsigned index;

	index = 1;
	gstr  = g_string_sized_new (4096);
	handle_mime_object (msg,
	                    mmsg->mime_part,
			    (GMimeObject *) mmsg,
			    opts,
			    &index,
	                    FALSE,
			    (MuMsgPartForeachFunc)accumulate_text,
			    &gstr);

	return g_string_free (gstr, FALSE);
}
Ejemplo n.º 5
0
gboolean
mu_msg_part_foreach (MuMsg *msg, MuMsgOptions opts,
		     MuMsgPartForeachFunc func, gpointer user_data)
{
	unsigned index;

	index = 1;
	g_return_val_if_fail (msg, FALSE);

	if (!mu_msg_load_msg_file (msg, NULL))
		return FALSE;

	return handle_mime_object (msg,
	                           msg->_file->_mime_msg->mime_part,
	                           (GMimeObject *) msg->_file->_mime_msg,
	                           opts,
	                           &index,
	                           FALSE,
	                           func,
	                           user_data);
}
Ejemplo n.º 6
0
/* call 'func' with information about this MIME-part */
static gboolean
handle_message_part (MuMsg *msg, GMimeMessagePart *mimemsgpart,
		     GMimeObject *parent, MuMsgOptions opts, unsigned *index,
		     gboolean decrypted,
		     MuMsgPartForeachFunc func, gpointer user_data)
{
	MuMsgPart msgpart;

	memset (&msgpart, 0, sizeof(MuMsgPart));

	msgpart.type        = "message";
	msgpart.subtype     = "rfc822";
	msgpart.index       = (*index)++;

	/* msgpart.size        = 0; /\* maybe calculate this? *\/ */

	msgpart.part_type  = MU_MSG_PART_TYPE_MESSAGE;
	msgpart.part_type |= get_disposition ((GMimeObject*)mimemsgpart);

	msgpart.data        = (gpointer)mimemsgpart;
	func (msg, &msgpart, user_data);

	if (opts & MU_MSG_OPTION_RECURSE_RFC822) {
		GMimeMessage *mmsg; /* may return NULL for some
				     * messages */
		mmsg = g_mime_message_part_get_message (mimemsgpart);
		if (mmsg)
			return handle_mime_object (msg,
			                           mmsg->mime_part,
			                           parent,
			                           opts,
			                           index,
			                           decrypted,
			                           func,
			                           user_data);
	}

	return TRUE;
}