summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alan Fitton <ajf@eth0.org.uk>2011-11-17 13:21:27 +0000
committerGravatar Alan Fitton <ajf@eth0.org.uk>2011-11-17 13:21:27 +0000
commit57cb76cd8486a7cd4ca7de039dd874c6fe32ce94 (patch)
tree2f5955a8f200a9179a1ebe05be9a4150911b2ce7
parent5bb75c2cc4c5ad23eebef9832fb74a9eaf632b51 (diff)
allow remote session variables to be used in actions
-rw-r--r--src/main.c6
-rw-r--r--src/remote-exec.c10
-rw-r--r--src/remote-exec.h2
-rw-r--r--src/trg-destination-combo.c3
-rw-r--r--src/trg-main-window.c3
5 files changed, 14 insertions, 10 deletions
diff --git a/src/main.c b/src/main.c
index 647307e..bb21503 100644
--- a/src/main.c
+++ b/src/main.c
@@ -201,10 +201,10 @@ static int mailslot_send_message(HANDLE h, gchar **args) {
json_object_set_array_member(obj, "args", array);
g_strfreev(args);
+ } else {
+ json_object_set_boolean_member(obj, "present", TRUE);
}
- //json_object_set_boolean_member(obj, "present", TRUE);
-
json_node_take_object(node, obj);
generator = json_generator_new();
@@ -323,7 +323,7 @@ int main(int argc, char *argv[]) {
#ifdef HAVE_LIBUNIQUE
if (withUnique)
- app = unique_app_new_with_commands(TRG_LIBUNIQUE_DOMAIN, NULL,
+ app = unique_app_new_with_commands(TRG_LIBUNIQUE_DOMAIN, NULL,
"add", COMMAND_ADD, NULL);
if (withUnique && unique_app_is_running(app)) {
diff --git a/src/remote-exec.c b/src/remote-exec.c
index 0e3c4e9..30627b2 100644
--- a/src/remote-exec.c
+++ b/src/remote-exec.c
@@ -83,8 +83,10 @@ static gchar *dump_json_value(JsonNode * node) {
return g_string_free(buffer, FALSE);
}
-gchar *build_remote_exec_cmd(TrgPrefs *prefs, GtkTreeModel *model, GList *selection,
+gchar *build_remote_exec_cmd(TrgClient *tc, GtkTreeModel *model, GList *selection,
const gchar * input) {
+ TrgPrefs *prefs = trg_client_get_prefs(tc);
+ JsonObject *session = trg_client_get_session(tc);
JsonObject *profile = trg_prefs_get_connection(prefs);
gchar *work;
GRegex *regex, *replacerx;
@@ -110,10 +112,14 @@ gchar *build_remote_exec_cmd(TrgPrefs *prefs, GtkTreeModel *model, GList *select
replacerx = g_regex_new(wholeEscaped, 0, 0, NULL);
valuestr = NULL;
- if (json_object_has_member(profile, id)) {
+ if (profile && json_object_has_member(profile, id)) {
replacement = json_object_get_member(profile, id);
if (JSON_NODE_HOLDS_VALUE(replacement))
valuestr = dump_json_value(replacement);
+ } else if (session && json_object_has_member(session, id)) {
+ replacement = json_object_get_member(session, id);
+ if (JSON_NODE_HOLDS_VALUE(replacement))
+ valuestr = dump_json_value(replacement);
} else {
GString *gs = g_string_new ("");
GList *li;
diff --git a/src/remote-exec.h b/src/remote-exec.h
index 4fb67f4..4f8c52e 100644
--- a/src/remote-exec.h
+++ b/src/remote-exec.h
@@ -20,7 +20,7 @@
#ifndef REMOTE_EXEC_H_
#define REMOTE_EXEC_H_
-gchar *build_remote_exec_cmd(TrgPrefs *prefs, GtkTreeModel *model, GList *selection,
+gchar *build_remote_exec_cmd(TrgClient *tc, GtkTreeModel *model, GList *selection,
const gchar * input);
#endif /* REMOTE_EXEC_H_ */
diff --git a/src/trg-destination-combo.c b/src/trg-destination-combo.c
index 1689e52..e0207a6 100644
--- a/src/trg-destination-combo.c
+++ b/src/trg-destination-combo.c
@@ -184,7 +184,6 @@ static GObject *trg_destination_combo_constructor(GType type,
GtkTreePath *path;
GtkListStore *comboModel;
JsonArray *saved_destinations;
- JsonObject *t;
gchar *defaultDir;
comboModel = gtk_list_store_new(N_DEST_COLUMNS, G_TYPE_STRING,
@@ -233,7 +232,7 @@ static GObject *trg_destination_combo_constructor(GType type,
if (gtk_tree_model_get_iter(model, &iter, path)) {
gchar *dd;
- gtk_tree_model_get(model, &iter, TORRENT_COLUMN_JSON, &t,
+ gtk_tree_model_get(model, &iter,
TORRENT_COLUMN_DOWNLOADDIR, &dd, -1);
if (dd && g_strcmp0(dd, defaultDir))
diff --git a/src/trg-main-window.c b/src/trg-main-window.c
index 61e6aaf..2ec589f 100644
--- a/src/trg-main-window.c
+++ b/src/trg-main-window.c
@@ -1532,7 +1532,6 @@ static GtkWidget *limit_menu_new(TrgMainWindow * win, gchar * title,
static void exec_cmd_cb(GtkWidget *w, gpointer data) {
TrgMainWindowPrivate *priv = TRG_MAIN_WINDOW_GET_PRIVATE(data);
- TrgPrefs *prefs = trg_client_get_prefs(priv->client);
JsonObject *cmd_obj = (JsonObject*) g_object_get_data(G_OBJECT(w),
"cmd-object");
GtkTreeSelection *selection = gtk_tree_view_get_selection(
@@ -1543,7 +1542,7 @@ static void exec_cmd_cb(GtkWidget *w, gpointer data) {
gchar *cmd_line, **argv;
cmd_line = build_remote_exec_cmd(
- prefs,
+ priv->client,
model,
selectedRows,
json_object_get_string_member(cmd_obj,