Example #1
0
gboolean
mu_util_play (const char *path, gboolean allow_local, gboolean allow_remote)
{
	gboolean rv;
	GError *err;
	const gchar *prog;
	char *cmdline;

	g_return_val_if_fail (path, FALSE);
	g_return_val_if_fail (mu_util_is_local_file (path) || allow_remote,
			      FALSE);
	g_return_val_if_fail (!mu_util_is_local_file (path) || allow_local,
			      FALSE);

	prog = g_getenv ("MU_PLAY_PROGRAM");
	if (!prog) {
#ifdef __APPLE__
		prog = "open";
#else
		prog = "xdg-open";
#endif /*!__APPLE__*/
	}

	cmdline = g_strconcat (prog, " ", path, NULL);
	err = NULL;
	rv = g_spawn_command_line_async (cmdline, &err);
	if (!rv) {
		g_warning ("failed to spawn %s: %s",
			   cmdline, err->message ? err->message : "error");
		g_error_free (err);
	}

	g_free (cmdline);
	return rv;
}
Example #2
0
gboolean
mu_util_play (const char *path, gboolean allow_local, gboolean allow_remote,
	      GError **err)
{
	gboolean rv;
	const gchar *argv[3];
	const char *prog;

	g_return_val_if_fail (path, FALSE);
	g_return_val_if_fail (mu_util_is_local_file (path) || allow_remote,
			      FALSE);
	g_return_val_if_fail (!mu_util_is_local_file (path) || allow_local,
			      FALSE);

	prog = g_getenv ("MU_PLAY_PROGRAM");
	if (!prog) {
#ifdef __APPLE__
		prog = "open";
#else
		prog = "xdg-open";
#endif /*!__APPLE__*/
	}

	if (!mu_util_program_in_path (prog)) {
		mu_util_g_set_error (err, MU_ERROR_FILE_CANNOT_EXECUTE,
				     "cannot find '%s' in path", prog);
		return FALSE;
	}

	argv[0] = prog;
	argv[1] = path;
	argv[2] = NULL;

	err = NULL;
	rv = g_spawn_async (NULL, (gchar**)&argv, NULL,
			    G_SPAWN_SEARCH_PATH, NULL, NULL, NULL,
			    err);
	return rv;
}
Example #3
0
File: mu-util.c Project: Dabg/mu
gboolean
mu_util_play (const char *path, gboolean allow_local, gboolean allow_remote,
	      GError **err)
{
	gboolean rv;
	const gchar *argv[3];
	const char *prog;

	g_return_val_if_fail (path, FALSE);
	g_return_val_if_fail (mu_util_is_local_file (path) || allow_remote,
			      FALSE);
	g_return_val_if_fail (!mu_util_is_local_file (path) || allow_local,
			      FALSE);

	prog = g_getenv ("MU_PLAY_PROGRAM");
	if (!prog) {
#ifdef __APPLE__
		prog = "open";
#else
		prog = "xdg-open";
#endif /*!__APPLE__*/
	}

	argv[0] = prog;
	argv[1] = path;
	argv[2] = NULL;

	err = NULL;
	rv = g_spawn_async (NULL,
			    (gchar**)&argv,
			    NULL,
			    G_SPAWN_SEARCH_PATH,
			    NULL, NULL, NULL,
			    err);
	return rv;
}
Example #4
0
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;
}