Exemple #1
0
static gboolean
save_part (MuMsg *msg, const char *targetdir, guint partidx, gboolean overwrite,
	   gboolean play)
{
	GError *err;
	gchar *filepath;

	filepath = mu_msg_part_filepath (msg, targetdir, partidx);
	if (!filepath) {
		g_warning ("failed to get filepath");
		return FALSE;
	}

	err = NULL;
	if (!mu_msg_part_save (msg, filepath, partidx, overwrite, FALSE, &err)) {
		if (err) {
			g_warning ("failed to save MIME-part: %s",
				   err->message);
			g_error_free (err);
		}
		g_free (filepath);
		return FALSE;
	}

	if (play)
		mu_util_play (filepath, TRUE, FALSE);

	g_free (filepath);
	return TRUE;
}
Exemple #2
0
static void
save_part_if (MuMsg *msg, MuMsgPart *part, SaveData *sd)
{
	gchar *filepath;
	gboolean rv;
	GError *err;

	if (ignore_part (msg, part, sd))
		return;

	rv	 = FALSE;
	filepath = NULL;

	err = NULL;
	filepath = mu_msg_part_filepath (msg, sd->targetdir, part->index, &err);
	if (!filepath) {
		g_warning ("failed to get file path: %s",
			   err&&err->message ? err->message : "error");
		g_clear_error (&err);
		goto leave;
	}

	if (!mu_msg_part_save (msg, filepath, part->index,
			       sd->overwrite, FALSE, &err)) {
		g_warning ("failed to save MIME-part: %s",
			   err&&err->message ? err->message : "error");
		g_clear_error (&err);
		goto leave;
	}

	if (sd->play && !mu_util_play (filepath, TRUE, FALSE))
		goto leave;

	rv = TRUE;
	++sd->saved_num;

leave:
	sd->result = rv;
	g_free (filepath);
}