mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Remember server for /EXEC targets.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3267 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
5133583132
commit
f2e5137c21
@ -28,6 +28,7 @@
|
|||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "levels.h"
|
#include "levels.h"
|
||||||
|
|
||||||
|
#include "servers.h"
|
||||||
#include "channels.h"
|
#include "channels.h"
|
||||||
#include "queries.h"
|
#include "queries.h"
|
||||||
|
|
||||||
@ -187,6 +188,7 @@ static void process_destroy(PROCESS_REC *rec, int status)
|
|||||||
|
|
||||||
g_free_not_null(rec->name);
|
g_free_not_null(rec->name);
|
||||||
g_free_not_null(rec->target);
|
g_free_not_null(rec->target);
|
||||||
|
g_free_not_null(rec->target_server);
|
||||||
g_free(rec->args);
|
g_free(rec->args);
|
||||||
g_free(rec);
|
g_free(rec);
|
||||||
}
|
}
|
||||||
@ -375,9 +377,10 @@ static void sig_exec_input_reader(PROCESS_REC *rec)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void handle_exec(const char *args, GHashTable *optlist,
|
static void handle_exec(const char *args, GHashTable *optlist,
|
||||||
WI_ITEM_REC *item)
|
SERVER_REC *server, WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
PROCESS_REC *rec;
|
PROCESS_REC *rec;
|
||||||
|
SERVER_REC *target_server;
|
||||||
char *target, *level;
|
char *target, *level;
|
||||||
int notice, signum, interactive, target_nick, target_channel;
|
int notice, signum, interactive, target_nick, target_channel;
|
||||||
|
|
||||||
@ -394,6 +397,7 @@ static void handle_exec(const char *args, GHashTable *optlist,
|
|||||||
}
|
}
|
||||||
|
|
||||||
target = NULL;
|
target = NULL;
|
||||||
|
target_server = NULL;
|
||||||
notice = FALSE;
|
notice = FALSE;
|
||||||
|
|
||||||
if (g_hash_table_lookup(optlist, "in") != NULL) {
|
if (g_hash_table_lookup(optlist, "in") != NULL) {
|
||||||
@ -418,13 +422,16 @@ static void handle_exec(const char *args, GHashTable *optlist,
|
|||||||
if (item == NULL)
|
if (item == NULL)
|
||||||
cmd_return_error(CMDERR_NOT_JOINED);
|
cmd_return_error(CMDERR_NOT_JOINED);
|
||||||
target = (char *) window_item_get_target(item);
|
target = (char *) window_item_get_target(item);
|
||||||
|
target_server = item->server;
|
||||||
target_channel = IS_CHANNEL(item);
|
target_channel = IS_CHANNEL(item);
|
||||||
target_nick = IS_QUERY(item);
|
target_nick = IS_QUERY(item);
|
||||||
} else if (g_hash_table_lookup(optlist, "msg") != NULL) {
|
} else if (g_hash_table_lookup(optlist, "msg") != NULL) {
|
||||||
/* redirect output to /msg <nick> */
|
/* redirect output to /msg <nick> */
|
||||||
target = g_hash_table_lookup(optlist, "msg");
|
target = g_hash_table_lookup(optlist, "msg");
|
||||||
|
target_server = server;
|
||||||
} else if (g_hash_table_lookup(optlist, "notice") != NULL) {
|
} else if (g_hash_table_lookup(optlist, "notice") != NULL) {
|
||||||
target = g_hash_table_lookup(optlist, "notice");
|
target = g_hash_table_lookup(optlist, "notice");
|
||||||
|
target_server = server;
|
||||||
notice = TRUE;
|
notice = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -456,6 +463,8 @@ static void handle_exec(const char *args, GHashTable *optlist,
|
|||||||
/* redirect output to target */
|
/* redirect output to target */
|
||||||
g_free_and_null(rec->target);
|
g_free_and_null(rec->target);
|
||||||
rec->target = g_strdup(target);
|
rec->target = g_strdup(target);
|
||||||
|
rec->target_server = target_server == NULL ? NULL :
|
||||||
|
g_strdup(target_server->tag);
|
||||||
rec->notice = notice;
|
rec->notice = notice;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,6 +505,8 @@ static void handle_exec(const char *args, GHashTable *optlist,
|
|||||||
|
|
||||||
rec->id = process_get_new_id();
|
rec->id = process_get_new_id();
|
||||||
rec->target = g_strdup(target);
|
rec->target = g_strdup(target);
|
||||||
|
rec->target_server = target_server == NULL ? NULL :
|
||||||
|
g_strdup(target_server->tag);
|
||||||
rec->target_win = active_win;
|
rec->target_win = active_win;
|
||||||
rec->target_channel = target_channel;
|
rec->target_channel = target_channel;
|
||||||
rec->target_nick = target_nick;
|
rec->target_nick = target_nick;
|
||||||
@ -535,7 +546,7 @@ static void cmd_exec(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
|
|||||||
if (cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
|
if (cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
|
||||||
PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST,
|
PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST,
|
||||||
"exec", &optlist, &args)) {
|
"exec", &optlist, &args)) {
|
||||||
handle_exec(args, optlist, item);
|
handle_exec(args, optlist, server, item);
|
||||||
cmd_params_free(free_arg);
|
cmd_params_free(free_arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -584,9 +595,18 @@ static void sig_exec_input(PROCESS_REC *rec, const char *text)
|
|||||||
server = NULL;
|
server = NULL;
|
||||||
|
|
||||||
if (rec->target != NULL) {
|
if (rec->target != NULL) {
|
||||||
|
if (rec->target_server != NULL) {
|
||||||
|
server = server_find_tag(rec->target_server);
|
||||||
|
if (server == NULL) {
|
||||||
|
/* disconnected - target is lost */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
item = NULL;
|
||||||
|
} else {
|
||||||
item = window_item_find(NULL, rec->target);
|
item = window_item_find(NULL, rec->target);
|
||||||
server = item != NULL ? item->server :
|
server = item != NULL ? item->server :
|
||||||
active_win->active_server;
|
active_win->active_server;
|
||||||
|
}
|
||||||
|
|
||||||
str = g_strconcat(rec->target_nick ? "-nick " :
|
str = g_strconcat(rec->target_nick ? "-nick " :
|
||||||
rec->target_channel ? "-channel " : "",
|
rec->target_channel ? "-channel " : "",
|
||||||
|
@ -32,6 +32,7 @@ struct PROCESS_REC {
|
|||||||
|
|
||||||
int level; /* what level to use when printing the text */
|
int level; /* what level to use when printing the text */
|
||||||
char *target; /* send text with /msg <target> ... */
|
char *target; /* send text with /msg <target> ... */
|
||||||
|
char *target_server;
|
||||||
WINDOW_REC *target_win; /* print text to this window */
|
WINDOW_REC *target_win; /* print text to this window */
|
||||||
EXEC_WI_REC *target_item; /* print text to this exec window item */
|
EXEC_WI_REC *target_item; /* print text to this exec window item */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user