コード例 #1
0
ファイル: mu-cmd-server.c プロジェクト: Popsch/mu
static MuError
open_part (MuMsg *msg, unsigned docid, unsigned index, GError **err)
{
	char *targetpath;
	gboolean rv;

	targetpath = mu_msg_part_get_cache_path (msg,MU_MSG_OPTION_NONE,
						 index, err);
	if (!targetpath)
		return print_and_clear_g_error (err);

	rv = mu_msg_part_save (msg, MU_MSG_OPTION_USE_EXISTING,
			       targetpath, index, err);
	if (!rv) {
		print_and_clear_g_error (err);
		goto leave;
	}

	rv = mu_util_play (targetpath, TRUE,/*allow local*/
			   FALSE/*allow remote*/, err);
	if (!rv)
		print_and_clear_g_error (err);
	else {
		gchar *path;
		path = mu_str_escape_c_literal (targetpath, FALSE);
		print_expr ("(:info open :message \"%s has been opened\")",
			    path);
		g_free (path);
	}
leave:
	g_free (targetpath);
	return MU_OK;
}
コード例 #2
0
ファイル: mu-cmd-extract.c プロジェクト: mylese/mu
static gboolean
save_part (MuMsg *msg, const char *targetdir, guint partidx, MuConfig *opts)
{
	GError *err;
	gchar *filepath;
	gboolean rv;
	MuMsgOptions msgopts;

	err = NULL;
	rv = FALSE;

	msgopts = mu_config_get_msg_options (opts);

	filepath = mu_msg_part_get_path (msg, msgopts, targetdir, partidx, &err);
	if (!filepath)
		goto exit;

	if (!mu_msg_part_save (msg, msgopts, filepath, partidx, &err))
		goto exit;

	if (opts->play)
		rv = mu_util_play (filepath, TRUE, FALSE, &err);
	else
		rv = TRUE;
exit:
	if (err) {
		g_warning ("error with MIME-part: %s", err->message);
		g_clear_error (&err);
	}

	g_free (filepath);
	return rv;
}
コード例 #3
0
ファイル: mu-cmd-extract.c プロジェクト: tavisrudd/mu
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;
}
コード例 #4
0
ファイル: mu-msg-body-view.c プロジェクト: antono/mu
static gboolean
on_navigation_policy_decision_requested (MuMsgBodyView *self, WebKitWebFrame *frame,
					 WebKitNetworkRequest *request,
					 WebKitWebNavigationAction *nav_action,
					 WebKitWebPolicyDecision *policy_decision,
					 gpointer data)
{
	const char* uri;
	WebKitWebNavigationReason reason;
	
	uri = webkit_network_request_get_uri (request);
	reason = webkit_web_navigation_action_get_reason (nav_action);
	
	/* if it wasn't a user click, don't the navigation */
	if (reason != WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) {
		webkit_web_policy_decision_ignore (policy_decision);
		return TRUE;
	}
	
	/* we handle links clicked ourselves, no need for navigation */
	webkit_web_policy_decision_ignore (policy_decision);
	
	/* if there are 'cmd:<action>" links in the body text of
	 * mu-internal messages (ie., notification from mu, not real
	 * e-mail messages), we emit the 'action requested'
	 * signal. this allows e.g triggering a database refresh from
	 * a <a href="cmd:refresh">Refresh</a> link
	 */
	if (g_ascii_strncasecmp (uri, "cmd:", 4) == 0)  {
		if (self->_priv->_view_mode == VIEW_MODE_NOTE) {
			g_signal_emit (G_OBJECT(self),
				       signals[ACTION_REQUESTED], 0,
				       uri + 4);
		}
		return TRUE;
	}
		
	/* don't try to play files on our local file system, this is not something
	 * external content should do.*/
	if (!mu_util_is_local_file(uri))
		mu_util_play (uri, FALSE, TRUE);
	
	return TRUE;
}
コード例 #5
0
ファイル: mu-cmd-extract.c プロジェクト: mylese/mu
static void
save_part_if (MuMsg *msg, MuMsgPart *part, SaveData *sd)
{
	gchar *filepath;
	gboolean rv;
	GError *err;
	MuMsgOptions msgopts;

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

	rv	 = FALSE;
	filepath = NULL;
	err      = NULL;

	msgopts = mu_config_get_msg_options (sd->opts);
	filepath = mu_msg_part_get_path (msg, msgopts,
					 sd->opts->targetdir,
					 part->index, &err);
	if (!filepath)
		goto exit;

	if (!mu_msg_part_save (msg, msgopts, filepath, part->index, &err))
		goto exit;

	if (sd->opts->play)
		rv = mu_util_play (filepath, TRUE, FALSE, &err);
	else
		rv = TRUE;

	++sd->saved_num;
exit:
	if (err)
		g_warning ("error saving MIME part: %s", err->message);

	g_free (filepath);
	g_clear_error (&err);

	sd->result = rv;

}
コード例 #6
0
ファイル: mu-cmd-extract.c プロジェクト: antono/mu
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);
}