mirror of
https://github.com/irssi/irssi.git
synced 2025-01-03 14:56:47 -05:00
Track the account queries which are in progress
This commit is contained in:
parent
dc87199100
commit
04035ab7ca
@ -50,23 +50,6 @@ loop:
|
|||||||
#include <irssi/src/irc/core/irc-channels.h>
|
#include <irssi/src/irc/core/irc-channels.h>
|
||||||
#include <irssi/src/irc/core/servers-redirect.h>
|
#include <irssi/src/irc/core/servers-redirect.h>
|
||||||
|
|
||||||
enum {
|
|
||||||
CHANNEL_QUERY_MODE,
|
|
||||||
CHANNEL_QUERY_WHO,
|
|
||||||
CHANNEL_QUERY_BMODE,
|
|
||||||
|
|
||||||
CHANNEL_QUERIES
|
|
||||||
};
|
|
||||||
|
|
||||||
#define CHANNEL_IS_MODE_QUERY(a) ((a) != CHANNEL_QUERY_WHO)
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int current_query_type; /* query type that is currently being asked */
|
|
||||||
GSList *current_queries; /* All channels that are currently being queried */
|
|
||||||
|
|
||||||
GSList *queries[CHANNEL_QUERIES]; /* All queries that need to be asked from server */
|
|
||||||
} SERVER_QUERY_REC;
|
|
||||||
|
|
||||||
static void sig_connected(IRC_SERVER_REC *server)
|
static void sig_connected(IRC_SERVER_REC *server)
|
||||||
{
|
{
|
||||||
SERVER_QUERY_REC *rec;
|
SERVER_QUERY_REC *rec;
|
||||||
@ -76,6 +59,8 @@ static void sig_connected(IRC_SERVER_REC *server)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
rec = g_new0(SERVER_QUERY_REC, 1);
|
rec = g_new0(SERVER_QUERY_REC, 1);
|
||||||
|
rec->accountqueries = g_hash_table_new_full(
|
||||||
|
(GHashFunc) i_istr_hash, (GCompareFunc) i_istr_equal, (GDestroyNotify) g_free, NULL);
|
||||||
server->chanqueries = rec;
|
server->chanqueries = rec;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +76,8 @@ static void sig_disconnected(IRC_SERVER_REC *server)
|
|||||||
rec = server->chanqueries;
|
rec = server->chanqueries;
|
||||||
g_return_if_fail(rec != NULL);
|
g_return_if_fail(rec != NULL);
|
||||||
|
|
||||||
|
g_hash_table_foreach(rec->accountqueries, (GHFunc) g_free, NULL);
|
||||||
|
g_hash_table_destroy(rec->accountqueries);
|
||||||
for (n = 0; n < CHANNEL_QUERIES; n++)
|
for (n = 0; n < CHANNEL_QUERIES; n++)
|
||||||
g_slist_free(rec->queries[n]);
|
g_slist_free(rec->queries[n]);
|
||||||
g_slist_free(rec->current_queries);
|
g_slist_free(rec->current_queries);
|
||||||
@ -399,6 +386,12 @@ static void channel_got_query(IRC_CHANNEL_REC *chanrec, int query_type)
|
|||||||
query_check(chanrec->server);
|
query_check(chanrec->server);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void query_useraccount_error(IRC_SERVER_REC *server, const char *cmd, const char *arg)
|
||||||
|
{
|
||||||
|
/* query failed, ignore it but remove the marker */
|
||||||
|
g_hash_table_remove(server->chanqueries->accountqueries, arg);
|
||||||
|
}
|
||||||
|
|
||||||
static void sig_event_join(IRC_SERVER_REC *server, const char *data, const char *nick,
|
static void sig_event_join(IRC_SERVER_REC *server, const char *data, const char *nick,
|
||||||
const char *address)
|
const char *address)
|
||||||
{
|
{
|
||||||
@ -448,6 +441,10 @@ static void sig_event_join(IRC_SERVER_REC *server, const char *data, const char
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_hash_table_contains(server->chanqueries->accountqueries, nick)) {
|
||||||
|
/* query already sent */
|
||||||
|
return;
|
||||||
|
}
|
||||||
account = NULL;
|
account = NULL;
|
||||||
|
|
||||||
/* Check if user is already in some other channel, get the account from there */
|
/* Check if user is already in some other channel, get the account from there */
|
||||||
@ -470,11 +467,13 @@ static void sig_event_join(IRC_SERVER_REC *server, const char *data, const char
|
|||||||
if (g_hash_table_size(chanrec->nicks) < settings_get_int("channel_max_who_sync") &&
|
if (g_hash_table_size(chanrec->nicks) < settings_get_int("channel_max_who_sync") &&
|
||||||
server->isupport != NULL && g_hash_table_lookup(server->isupport, "whox") != NULL) {
|
server->isupport != NULL && g_hash_table_lookup(server->isupport, "whox") != NULL) {
|
||||||
char *cmd;
|
char *cmd;
|
||||||
server_redirect_event(server, "who user", 1, nick, -1, NULL, /* failure signal */
|
server_redirect_event(server, "who user", 1, nick, -1,
|
||||||
|
"chanquery useraccount abort", /* failure signal */
|
||||||
"event 354", "silent event whox useraccount", /* */
|
"event 354", "silent event whox useraccount", /* */
|
||||||
"", "event empty", /* */
|
"", "event empty", /* */
|
||||||
NULL);
|
NULL);
|
||||||
cmd = g_strdup_printf("WHO %s %%tna,745", nick);
|
cmd = g_strdup_printf("WHO %s %%tna,745", nick);
|
||||||
|
g_hash_table_add(server->chanqueries->accountqueries, g_strdup(nick));
|
||||||
irc_send_cmd(server, cmd);
|
irc_send_cmd(server, cmd);
|
||||||
g_free(cmd);
|
g_free(cmd);
|
||||||
}
|
}
|
||||||
@ -585,6 +584,7 @@ void channels_query_init(void)
|
|||||||
|
|
||||||
signal_add("chanquery ban end", (SIGNAL_FUNC) event_end_of_banlist);
|
signal_add("chanquery ban end", (SIGNAL_FUNC) event_end_of_banlist);
|
||||||
signal_add("chanquery abort", (SIGNAL_FUNC) query_current_error);
|
signal_add("chanquery abort", (SIGNAL_FUNC) query_current_error);
|
||||||
|
signal_add("chanquery useraccount abort", (SIGNAL_FUNC) query_useraccount_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
void channels_query_deinit(void)
|
void channels_query_deinit(void)
|
||||||
@ -601,4 +601,5 @@ void channels_query_deinit(void)
|
|||||||
|
|
||||||
signal_remove("chanquery ban end", (SIGNAL_FUNC) event_end_of_banlist);
|
signal_remove("chanquery ban end", (SIGNAL_FUNC) event_end_of_banlist);
|
||||||
signal_remove("chanquery abort", (SIGNAL_FUNC) query_current_error);
|
signal_remove("chanquery abort", (SIGNAL_FUNC) query_current_error);
|
||||||
|
signal_remove("chanquery useraccount abort", (SIGNAL_FUNC) query_useraccount_error);
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,16 @@
|
|||||||
#define IS_IRC_CHANNEL(channel) \
|
#define IS_IRC_CHANNEL(channel) \
|
||||||
(IRC_CHANNEL(channel) ? TRUE : FALSE)
|
(IRC_CHANNEL(channel) ? TRUE : FALSE)
|
||||||
|
|
||||||
|
enum {
|
||||||
|
CHANNEL_QUERY_MODE,
|
||||||
|
CHANNEL_QUERY_WHO,
|
||||||
|
CHANNEL_QUERY_BMODE,
|
||||||
|
|
||||||
|
CHANNEL_QUERIES
|
||||||
|
};
|
||||||
|
|
||||||
|
#define CHANNEL_IS_MODE_QUERY(a) ((a) != CHANNEL_QUERY_WHO)
|
||||||
|
|
||||||
#define STRUCT_SERVER_REC IRC_SERVER_REC
|
#define STRUCT_SERVER_REC IRC_SERVER_REC
|
||||||
struct _IRC_CHANNEL_REC {
|
struct _IRC_CHANNEL_REC {
|
||||||
#include <irssi/src/core/channel-rec.h>
|
#include <irssi/src/core/channel-rec.h>
|
||||||
@ -22,6 +32,14 @@ struct _IRC_CHANNEL_REC {
|
|||||||
int last_massjoins; /* Massjoins when last checked in timeout function */
|
int last_massjoins; /* Massjoins when last checked in timeout function */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct _SERVER_QUERY_REC {
|
||||||
|
int current_query_type; /* query type that is currently being asked */
|
||||||
|
GSList *current_queries; /* All channels that are currently being queried */
|
||||||
|
|
||||||
|
GSList *queries[CHANNEL_QUERIES]; /* All queries that need to be asked from server */
|
||||||
|
GHashTable *accountqueries; /* Per-nick account queries */
|
||||||
|
} SERVER_QUERY_REC;
|
||||||
|
|
||||||
void irc_channels_init(void);
|
void irc_channels_init(void);
|
||||||
void irc_channels_deinit(void);
|
void irc_channels_deinit(void);
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@ static void event_whox_743(SERVER_REC *server, const char *data)
|
|||||||
g_free(params);
|
g_free(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void event_whox_745(SERVER_REC *server, const char *data)
|
static void event_whox_745(IRC_SERVER_REC *server, const char *data)
|
||||||
{
|
{
|
||||||
char *params, *id, *nick, *account;
|
char *params, *id, *nick, *account;
|
||||||
GSList *nicks, *tmp;
|
GSList *nicks, *tmp;
|
||||||
@ -306,6 +306,7 @@ static void event_whox_745(SERVER_REC *server, const char *data)
|
|||||||
g_free(params);
|
g_free(params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
g_hash_table_remove(server->chanqueries->accountqueries, nick);
|
||||||
|
|
||||||
if (strcmp(account, "0") == 0) {
|
if (strcmp(account, "0") == 0) {
|
||||||
account = "*";
|
account = "*";
|
||||||
@ -503,6 +504,8 @@ static void event_nick(IRC_SERVER_REC *server, const char *data,
|
|||||||
server_change_nick(SERVER(server), nick);
|
server_change_nick(SERVER(server), nick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* invalidate any outstanding accountqueries for the old nick */
|
||||||
|
g_hash_table_remove(server->chanqueries->accountqueries, orignick);
|
||||||
nicklist_rename(SERVER(server), orignick, nick);
|
nicklist_rename(SERVER(server), orignick, nick);
|
||||||
g_free(params);
|
g_free(params);
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ struct _IRC_SERVER_REC {
|
|||||||
GSList *rejoin_channels; /* try to join to these channels after a while -
|
GSList *rejoin_channels; /* try to join to these channels after a while -
|
||||||
channels go here if they're "temporarily unavailable"
|
channels go here if they're "temporarily unavailable"
|
||||||
because of netsplits */
|
because of netsplits */
|
||||||
void *chanqueries;
|
struct _SERVER_QUERY_REC *chanqueries;
|
||||||
|
|
||||||
GHashTable *isupport;
|
GHashTable *isupport;
|
||||||
struct modes_type modes[256]; /* Stores the modes sent by a server in an isupport reply */
|
struct modes_type modes[256]; /* Stores the modes sent by a server in an isupport reply */
|
||||||
|
@ -222,6 +222,9 @@ static void event_quit(IRC_SERVER_REC *server, const char *data,
|
|||||||
nicklist_remove(CHANNEL(channel), nickrec);
|
nicklist_remove(CHANNEL(channel), nickrec);
|
||||||
}
|
}
|
||||||
g_slist_free(nicks);
|
g_slist_free(nicks);
|
||||||
|
|
||||||
|
/* invalidate any outstanding accountqueries for the nick */
|
||||||
|
g_hash_table_remove(server->chanqueries->accountqueries, nick);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void event_kick(IRC_SERVER_REC *server, const char *data)
|
static void event_kick(IRC_SERVER_REC *server, const char *data)
|
||||||
|
@ -442,7 +442,7 @@ static void redirect_abort(IRC_SERVER_REC *server, REDIRECT_REC *rec)
|
|||||||
g_free(str);
|
g_free(str);
|
||||||
|
|
||||||
if (rec->failure_signal != NULL)
|
if (rec->failure_signal != NULL)
|
||||||
signal_emit(rec->failure_signal, 1, server);
|
signal_emit(rec->failure_signal, 3, server, rec->cmd->name, rec->arg);
|
||||||
} else if (rec->last_signal != NULL) {
|
} else if (rec->last_signal != NULL) {
|
||||||
/* emit the last signal */
|
/* emit the last signal */
|
||||||
signal_emit(rec->last_signal, 1, server);
|
signal_emit(rec->last_signal, 1, server);
|
||||||
|
Loading…
Reference in New Issue
Block a user