summaryrefslogtreecommitdiff
path: root/src/fe-common
diff options
context:
space:
mode:
Diffstat (limited to 'src/fe-common')
-rw-r--r--src/fe-common/irc/dcc/fe-dcc.c471
-rw-r--r--src/fe-common/irc/dcc/module-formats.c14
-rw-r--r--src/fe-common/irc/dcc/module-formats.h8
-rw-r--r--src/fe-common/irc/fe-irc-commands.c60
4 files changed, 277 insertions, 276 deletions
diff --git a/src/fe-common/irc/dcc/fe-dcc.c b/src/fe-common/irc/dcc/fe-dcc.c
index 1ca4b167..0bc08fb9 100644
--- a/src/fe-common/irc/dcc/fe-dcc.c
+++ b/src/fe-common/irc/dcc/fe-dcc.c
@@ -27,6 +27,7 @@
#include "levels.h"
#include "irc.h"
#include "channels.h"
+#include "query.h"
#include "irc/dcc/dcc.h"
@@ -35,279 +36,294 @@
static void dcc_connected(DCC_REC *dcc)
{
- gchar *str;
-
- g_return_if_fail(dcc != NULL);
-
- switch (dcc->dcc_type)
- {
- case DCC_TYPE_CHAT:
- printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_CHAT_CONNECTED,
- dcc->nick, dcc->addrstr, dcc->port);
-
- str = g_strconcat("=", dcc->nick, NULL);
- /*FIXME: dcc_chat_create(dcc->server, str, FALSE);*/
- g_free(str);
- break;
- case DCC_TYPE_SEND:
- printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_SEND_CONNECTED,
- dcc->arg, dcc->nick, dcc->addrstr, dcc->port);
- break;
- case DCC_TYPE_GET:
- printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_GET_CONNECTED,
- dcc->arg, dcc->nick, dcc->addrstr, dcc->port);
- break;
- }
+ char *sender;
+
+ g_return_if_fail(dcc != NULL);
+
+ switch (dcc->type) {
+ case DCC_TYPE_CHAT:
+ sender = g_strconcat("=", dcc->nick, NULL);
+ printformat(dcc->server, sender, MSGLEVEL_DCC, IRCTXT_DCC_CHAT_CONNECTED,
+ dcc->nick, dcc->addrstr, dcc->port);
+ if (query_find(NULL, sender) == NULL)
+ query_create(dcc->server, sender, TRUE);
+ g_free(sender);
+ break;
+ case DCC_TYPE_SEND:
+ printformat(dcc->server, dcc->nick, MSGLEVEL_DCC, IRCTXT_DCC_SEND_CONNECTED,
+ dcc->arg, dcc->nick, dcc->addrstr, dcc->port);
+ break;
+ case DCC_TYPE_GET:
+ printformat(dcc->server, dcc->nick, MSGLEVEL_DCC, IRCTXT_DCC_GET_CONNECTED,
+ dcc->arg, dcc->nick, dcc->addrstr, dcc->port);
+ break;
+ }
}
static void dcc_rejected(DCC_REC *dcc)
{
- g_return_if_fail(dcc != NULL);
+ g_return_if_fail(dcc != NULL);
- printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_CLOSE,
- dcc_type2str(dcc->dcc_type), dcc->nick, dcc->arg);
+ printformat(dcc->server, dcc->nick, MSGLEVEL_DCC, IRCTXT_DCC_CLOSE,
+ dcc_type2str(dcc->type), dcc->nick, dcc->arg);
}
static void dcc_closed(DCC_REC *dcc)
{
- time_t secs;
- gdouble kbs;
-
- g_return_if_fail(dcc != NULL);
-
- secs = dcc->starttime == 0 ? -1 : time(NULL)-dcc->starttime;
- kbs = (gdouble) (dcc->transfd-dcc->skipped) / (secs == 0 ? 1 : secs) / 1024.0;
-
- switch (dcc->dcc_type)
- {
- case DCC_TYPE_CHAT:
- {
- /* nice kludge :) if connection was lost, close the channel.
- after closed channel (can be done with /unquery too)
- prints the disconnected-text.. */
- CHANNEL_REC *channel;
- gchar *str;
-
- str = g_strdup_printf("=%s", dcc->nick);
- printformat(dcc->server, str, MSGLEVEL_DCC,
- IRCTXT_DCC_CHAT_DISCONNECTED, dcc->nick);
-
- channel = channel_find(dcc->server, str);
- if (channel != NULL)
- channel_destroy(channel);
- g_free(str);
- }
- break;
- case DCC_TYPE_SEND:
- if (secs == -1)
- {
- /* aborted */
- printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_SEND_ABORTED,
- dcc->arg, dcc->nick);
- }
- else
- {
- printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_SEND_COMPLETE,
- dcc->arg, dcc->transfd/1024, dcc->nick, (glong) secs, kbs);
- }
- break;
- case DCC_TYPE_GET:
- if (secs == -1)
- {
- /* aborted */
- printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_GET_ABORTED,
- dcc->arg, dcc->nick);
- }
- else
- {
- printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_GET_COMPLETE,
- dcc->arg, dcc->transfd/1024, dcc->nick, (glong) secs, kbs);
- }
- break;
- }
+ char *sender;
+ double kbs;
+ time_t secs;
+
+ g_return_if_fail(dcc != NULL);
+
+ secs = dcc->starttime == 0 ? -1 : time(NULL)-dcc->starttime;
+ kbs = (double) (dcc->transfd-dcc->skipped) / (secs == 0 ? 1 : secs) / 1024.0;
+
+ switch (dcc->type) {
+ case DCC_TYPE_CHAT:
+ sender = g_strconcat("=", dcc->nick, NULL);
+ printformat(dcc->server, sender, MSGLEVEL_DCC,
+ IRCTXT_DCC_CHAT_DISCONNECTED, dcc->nick);
+ g_free(sender);
+ break;
+ case DCC_TYPE_SEND:
+ if (secs == -1) {
+ /* aborted */
+ printformat(dcc->server, dcc->nick, MSGLEVEL_DCC, IRCTXT_DCC_SEND_ABORTED,
+ dcc->arg, dcc->nick);
+ } else {
+ printformat(dcc->server, dcc->nick, MSGLEVEL_DCC, IRCTXT_DCC_SEND_COMPLETE,
+ dcc->arg, dcc->transfd/1024, dcc->nick, (long) secs, kbs);
+ }
+ break;
+ case DCC_TYPE_GET:
+ if (secs == -1) {
+ /* aborted */
+ printformat(dcc->server, dcc->nick, MSGLEVEL_DCC, IRCTXT_DCC_GET_ABORTED,
+ dcc->arg, dcc->nick);
+ } else {
+ printformat(dcc->server, dcc->nick, MSGLEVEL_DCC, IRCTXT_DCC_GET_COMPLETE,
+ dcc->arg, dcc->transfd/1024, dcc->nick, (long) secs, kbs);
+ }
+ break;
+ }
}
-static void dcc_chat_in_action(gchar *msg, DCC_REC *dcc)
+static void dcc_chat_action(const char *msg, DCC_REC *dcc)
{
- gchar *sender;
+ char *sender;
- g_return_if_fail(dcc != NULL);
- g_return_if_fail(msg != NULL);
+ g_return_if_fail(dcc != NULL);
+ g_return_if_fail(msg != NULL);
- sender = g_strconcat("=", dcc->nick, NULL);
- printformat(NULL, sender, MSGLEVEL_DCC,
- IRCTXT_ACTION_DCC, dcc->nick, msg);
- g_free(sender);
+ sender = g_strconcat("=", dcc->nick, NULL);
+ printformat(NULL, sender, MSGLEVEL_DCC,
+ IRCTXT_ACTION_DCC, dcc->nick, msg);
+ g_free(sender);
}
-static void dcc_chat_ctcp(gchar *msg, DCC_REC *dcc)
+static void dcc_chat_ctcp(const char *msg, DCC_REC *dcc)
{
- gchar *sender;
+ char *sender;
- g_return_if_fail(dcc != NULL);
- g_return_if_fail(msg != NULL);
+ g_return_if_fail(dcc != NULL);
+ g_return_if_fail(msg != NULL);
- sender = g_strconcat("=", dcc->nick, NULL);
- printformat(NULL, sender, MSGLEVEL_DCC, IRCTXT_DCC_CTCP, dcc->nick, msg);
- g_free(sender);
+ sender = g_strconcat("=", dcc->nick, NULL);
+ printformat(NULL, sender, MSGLEVEL_DCC, IRCTXT_DCC_CTCP, dcc->nick, msg);
+ g_free(sender);
}
-static void dcc_chat_msg(DCC_REC *dcc, gchar *msg)
+static void dcc_chat_msg(DCC_REC *dcc, const char *msg)
{
- gchar *nick;
+ char *sender;
- g_return_if_fail(dcc != NULL);
- g_return_if_fail(msg != NULL);
+ g_return_if_fail(dcc != NULL);
+ g_return_if_fail(msg != NULL);
- nick = g_strconcat("=", dcc->nick, NULL);
- printformat(NULL, nick, MSGLEVEL_DCC, IRCTXT_DCC_MSG, dcc->nick, msg);
- g_free(nick);
+ sender = g_strconcat("=", dcc->nick, NULL);
+ printformat(NULL, sender, MSGLEVEL_DCC,
+ query_find(NULL, sender) ? IRCTXT_DCC_MSG_QUERY :
+ IRCTXT_DCC_MSG, dcc->nick, msg);
+ g_free(sender);
}
static void dcc_request(DCC_REC *dcc)
{
- g_return_if_fail(dcc != NULL);
-
- switch (dcc->dcc_type)
- {
- case DCC_TYPE_CHAT:
- printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_CHAT,
- dcc->nick, dcc->addrstr, dcc->port);
- break;
- case DCC_TYPE_GET:
- printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_SEND,
- dcc->nick, dcc->addrstr, dcc->port, dcc->arg, dcc->size);
- break;
- }
+ g_return_if_fail(dcc != NULL);
+
+ switch (dcc->type) {
+ case DCC_TYPE_CHAT:
+ printformat(dcc->server, dcc->nick, MSGLEVEL_DCC, IRCTXT_DCC_CHAT,
+ dcc->nick, dcc->addrstr, dcc->port);
+ break;
+ case DCC_TYPE_GET:
+ printformat(dcc->server, dcc->nick, MSGLEVEL_DCC, IRCTXT_DCC_SEND,
+ dcc->nick, dcc->addrstr, dcc->port, dcc->arg, dcc->size);
+ break;
+ }
}
static void dcc_error_connect(DCC_REC *dcc)
{
- g_return_if_fail(dcc != NULL);
+ g_return_if_fail(dcc != NULL);
- printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_CONNECT_ERROR, dcc->addrstr, dcc->port);
+ printformat(dcc->server, dcc->nick, MSGLEVEL_DCC, IRCTXT_DCC_CONNECT_ERROR, dcc->addrstr, dcc->port);
}
-static void dcc_error_file_create(DCC_REC *dcc, gchar *fname)
+static void dcc_error_file_create(DCC_REC *dcc, const char *fname)
{
- g_return_if_fail(dcc != NULL);
+ g_return_if_fail(dcc != NULL);
- printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_CANT_CREATE, fname);
+ printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_CANT_CREATE, fname);
}
-static void dcc_error_file_not_found(gchar *nick, gchar *fname)
+static void dcc_error_file_not_found(const char *nick, const char *fname)
{
- g_return_if_fail(nick != NULL);
- g_return_if_fail(fname != NULL);
+ g_return_if_fail(nick != NULL);
+ g_return_if_fail(fname != NULL);
- printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_SEND_FILE_NOT_FOUND, fname);
+ printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_SEND_FILE_NOT_FOUND, fname);
}
-static void dcc_error_get_not_found(gchar *nick)
+static void dcc_error_get_not_found(const char *nick)
{
- g_return_if_fail(nick != NULL);
+ g_return_if_fail(nick != NULL);
- printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_GET_NOT_FOUND, nick);
+ printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_GET_NOT_FOUND, nick);
}
-static void dcc_error_send_exists(gchar *nick, gchar *fname)
+static void dcc_error_send_exists(const char *nick, const char *fname)
{
- g_return_if_fail(nick != NULL);
- g_return_if_fail(fname != NULL);
+ g_return_if_fail(nick != NULL);
+ g_return_if_fail(fname != NULL);
- printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_SEND_EXISTS, fname, nick);
+ printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_SEND_EXISTS, fname, nick);
}
-static void dcc_error_unknown_type(gchar *type)
+static void dcc_error_unknown_type(const char *type)
{
- g_return_if_fail(type != NULL);
+ g_return_if_fail(type != NULL);
- printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_UNKNOWN_TYPE, type);
+ printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_UNKNOWN_TYPE, type);
}
-static void dcc_error_close_not_found(gchar *type, gchar *nick, gchar *fname)
+static void dcc_error_close_not_found(const char *type, const char *nick, const char *fname)
{
- g_return_if_fail(type != NULL);
- g_return_if_fail(nick != NULL);
- g_return_if_fail(fname != NULL);
-
- if (fname == '\0') fname = "(ANY)";
- switch (dcc_str2type(type))
- {
- case DCC_TYPE_CHAT:
- printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_CHAT_NOT_FOUND, nick);
- break;
- case DCC_TYPE_SEND:
- printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_SEND_NOT_FOUND, nick, fname);
- break;
- case DCC_TYPE_GET:
- printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_GET_NOT_FOUND, nick, fname);
- break;
- }
+ g_return_if_fail(type != NULL);
+ g_return_if_fail(nick != NULL);
+ g_return_if_fail(fname != NULL);
+
+ if (fname == '\0') fname = "(ANY)";
+ switch (dcc_str2type(type)) {
+ case DCC_TYPE_CHAT:
+ printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_CHAT_NOT_FOUND, nick);
+ break;
+ case DCC_TYPE_SEND:
+ printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_SEND_NOT_FOUND, nick, fname);
+ break;
+ case DCC_TYPE_GET:
+ printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_GET_NOT_FOUND, nick, fname);
+ break;
+ }
}
-static void dcc_unknown_ctcp(gchar *data, gchar *sender)
+static void dcc_unknown_ctcp(const char *data, const char *sender)
{
- gchar *params, *type, *args;
+ char *params, *type, *args;
- g_return_if_fail(data != NULL);
+ g_return_if_fail(data != NULL);
- params = cmd_get_params(data, 2 | PARAM_FLAG_GETREST, &type, &args);
- printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_UNKNOWN_CTCP, type, sender, args);
- g_free(params);
+ params = cmd_get_params(data, 2 | PARAM_FLAG_GETREST, &type, &args);
+ printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_UNKNOWN_CTCP, type, sender, args);
+ g_free(params);
}
-static void dcc_unknown_reply(gchar *data, gchar *sender)
+static void dcc_unknown_reply(const char *data, const char *sender)
{
- gchar *params, *type, *args;
+ char *params, *type, *args;
- g_return_if_fail(data != NULL);
+ g_return_if_fail(data != NULL);
- params = cmd_get_params(data, 2 | PARAM_FLAG_GETREST, &type, &args);
- printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_UNKNOWN_REPLY, type, sender, args);
- g_free(params);
+ params = cmd_get_params(data, 2 | PARAM_FLAG_GETREST, &type, &args);
+ printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_UNKNOWN_REPLY, type, sender, args);
+ g_free(params);
}
-static void dcc_chat_write(gchar *data)
+static void sig_dcc_destroyed(DCC_REC *dcc)
{
- DCC_REC *dcc;
- gchar *params, *text, *target;
+ QUERY_REC *query;
+ char *nick;
+
+ if (dcc->type != DCC_TYPE_CHAT)
+ return;
- g_return_if_fail(data != NULL);
+ nick = g_strconcat("=", dcc->nick, NULL);
+ query = query_find(NULL, nick);
+ g_free(nick);
- params = cmd_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &text);
+ if (query != NULL) {
+ /* DCC chat closed, close the query with it. */
+ query_destroy(query);
+ }
+}
- if (*target == '=')
- {
- /* dcc msg */
- dcc = dcc_find_item(DCC_TYPE_CHAT, target+1, NULL);
- if (dcc == NULL)
- {
- printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
- IRCTXT_DCC_CHAT_NOT_FOUND, target+1);
- return;
- }
+static void sig_query_destroyed(QUERY_REC *query)
+{
+ DCC_REC *dcc;
- printformat(NULL, target, MSGLEVEL_DCC, IRCTXT_OWN_DCC, target+1, text);
- }
+ if (*query->nick != '=')
+ return;
- g_free(params);
+ dcc = dcc_find_item(DCC_TYPE_CHAT, query->nick+1, NULL);
+ if (dcc != NULL && !dcc->destroyed) {
+ /* DCC query window closed, close the dcc chat too. */
+ signal_emit("dcc closed", 1, dcc);
+ dcc_destroy(dcc);
+ }
}
-static void dcc_chat_out_me(gchar *data, SERVER_REC *server, WI_IRC_REC *item)
+static void cmd_msg(const char *data)
{
DCC_REC *dcc;
+ char *params, *text, *target;
g_return_if_fail(data != NULL);
- dcc = irc_item_dcc_chat(item);
+ if (*data != '=') {
+ /* handle only DCC messages */
+ return;
+ }
+
+ params = cmd_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &text);
+
+ dcc = dcc_find_item(DCC_TYPE_CHAT, target+1, NULL);
+ if (dcc == NULL) {
+ printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
+ IRCTXT_DCC_CHAT_NOT_FOUND, target+1);
+ } else {
+ printformat(NULL, target, MSGLEVEL_DCC,
+ query_find(NULL, target) ? IRCTXT_OWN_DCC_QUERY :
+ IRCTXT_OWN_DCC, dcc->mynick, text);
+ }
+
+ g_free(params);
+}
+
+static void cmd_me(const char *data, SERVER_REC *server, WI_IRC_REC *item)
+{
+ DCC_REC *dcc;
+
+ g_return_if_fail(data != NULL);
+
+ dcc = item_get_dcc(item);
if (dcc == NULL) return;
printformat(NULL, item->name, MSGLEVEL_DCC,
IRCTXT_OWN_DCC_ME, dcc->mynick, data);
}
-static void dcc_chat_out_action(const char *data, SERVER_REC *server, WI_IRC_REC *item)
+static void cmd_action(const char *data, SERVER_REC *server, WI_IRC_REC *item)
{
char *params, *target, *text;
DCC_REC *dcc;
@@ -323,17 +339,17 @@ static void dcc_chat_out_action(const char *data, SERVER_REC *server, WI_IRC_REC
if (*target == '\0' || *text == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
dcc = dcc_find_item(DCC_TYPE_CHAT, target+1, NULL);
- if (dcc == NULL){
+ if (dcc == NULL) {
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
IRCTXT_DCC_CHAT_NOT_FOUND, target+1);
} else {
- printformat(NULL, item->name, MSGLEVEL_DCC,
+ printformat(NULL, target, MSGLEVEL_DCC,
IRCTXT_OWN_DCC_ME, dcc->mynick, text);
}
g_free(params);
}
-static void dcc_chat_out_ctcp(gchar *data, SERVER_REC *server)
+static void cmd_ctcp(const char *data, SERVER_REC *server)
{
char *params, *target, *ctcpcmd, *ctcpdata;
DCC_REC *dcc;
@@ -363,44 +379,29 @@ static void dcc_chat_out_ctcp(gchar *data, SERVER_REC *server)
g_free(params);
}
-static void cmd_dcc_list(gchar *data)
+static void cmd_dcc_list(const char *data)
{
- GSList *tmp;
- time_t going;
-
- g_return_if_fail(data != NULL);
-
- printtext(NULL, NULL, MSGLEVEL_DCC, "%gDCC connections");
- for (tmp = dcc_conns; tmp != NULL; tmp = tmp->next)
- {
- DCC_REC *dcc = tmp->data;
-
- going = time(NULL) - dcc->starttime;
- if (going == 0) going = 1; /* no division by zeros :) */
-
- if (dcc->dcc_type == DCC_TYPE_CHAT)
- printtext(NULL, NULL, MSGLEVEL_DCC, "%g %s %s", dcc->nick, dcc_type2str(dcc->dcc_type));
- else
- printtext(NULL, NULL, MSGLEVEL_DCC, "%g %s %s: %luk of %luk (%d%%) - %fkB/s - %s",
- dcc->nick, dcc_type2str(dcc->dcc_type), dcc->transfd/1024, dcc->size/1024,
- dcc->size == 0 ? 0 : (100*dcc->transfd/dcc->size),
- (gdouble) (dcc->transfd-dcc->skipped)/going/1024, dcc->arg);
- }
-}
+ GSList *tmp;
+ time_t going;
-static void dcc_chat_closed(WINDOW_REC *window, WI_IRC_REC *item)
-{
- DCC_REC *dcc;
+ g_return_if_fail(data != NULL);
- dcc = irc_item_dcc_chat(item);
- if (dcc == NULL) return;
+ printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_LIST_HEADER);
+ for (tmp = dcc_conns; tmp != NULL; tmp = tmp->next) {
+ DCC_REC *dcc = tmp->data;
- /* check that we haven't got here from dcc_destroy() so we won't try to
- close the dcc again.. */
- if (!dcc->destroyed) {
- /* DCC query window closed, close the dcc chat too. */
- dcc_destroy(dcc);
+ going = time(NULL) - dcc->starttime;
+ if (going == 0) going = 1; /* no division by zeros :) */
+
+ if (dcc->type == DCC_TYPE_CHAT)
+ printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_LIST_LINE_CHAT, dcc->nick, dcc_type2str(dcc->type));
+ else
+ printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_LIST_LINE_FILE,
+ dcc->nick, dcc_type2str(dcc->type), dcc->transfd/1024, dcc->size/1024,
+ dcc->size == 0 ? 0 : (100*dcc->transfd/dcc->size),
+ (double) (dcc->transfd-dcc->skipped)/going/1024, dcc->arg);
}
+ printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_LIST_FOOTER);
}
void fe_irc_dcc_init(void)
@@ -409,7 +410,7 @@ void fe_irc_dcc_init(void)
signal_add("dcc rejected", (SIGNAL_FUNC) dcc_rejected);
signal_add("dcc closed", (SIGNAL_FUNC) dcc_closed);
signal_add("dcc chat message", (SIGNAL_FUNC) dcc_chat_msg);
- signal_add("dcc ctcp action", (SIGNAL_FUNC) dcc_chat_in_action);
+ signal_add("dcc ctcp action", (SIGNAL_FUNC) dcc_chat_action);
signal_add("default dcc ctcp", (SIGNAL_FUNC) dcc_chat_ctcp);
signal_add("dcc request", (SIGNAL_FUNC) dcc_request);
signal_add("dcc error connect", (SIGNAL_FUNC) dcc_error_connect);
@@ -421,13 +422,14 @@ void fe_irc_dcc_init(void)
signal_add("dcc error close not found", (SIGNAL_FUNC) dcc_error_close_not_found);
signal_add("dcc unknown ctcp", (SIGNAL_FUNC) dcc_unknown_ctcp);
signal_add("dcc unknown reply", (SIGNAL_FUNC) dcc_unknown_reply);
- command_bind("msg", NULL, (SIGNAL_FUNC) dcc_chat_write);
- command_bind("me", NULL, (SIGNAL_FUNC) dcc_chat_out_me);
- command_bind("action", NULL, (SIGNAL_FUNC) dcc_chat_out_action);
- command_bind("ctcp", NULL, (SIGNAL_FUNC) dcc_chat_out_ctcp);
+ signal_add("dcc destroyed", (SIGNAL_FUNC) sig_dcc_destroyed);
+ signal_add("query destroyed", (SIGNAL_FUNC) sig_query_destroyed);
+ command_bind("msg", NULL, (SIGNAL_FUNC) cmd_msg);
+ command_bind("me", NULL, (SIGNAL_FUNC) cmd_me);
+ command_bind("action", NULL, (SIGNAL_FUNC) cmd_action);
+ command_bind("ctcp", NULL, (SIGNAL_FUNC) cmd_ctcp);
command_bind("dcc ", NULL, (SIGNAL_FUNC) cmd_dcc_list);
command_bind("dcc list", NULL, (SIGNAL_FUNC) cmd_dcc_list);
- signal_add("window item remove", (SIGNAL_FUNC) dcc_chat_closed);
theme_register(fecommon_irc_dcc_formats);
}
@@ -440,7 +442,7 @@ void fe_irc_dcc_deinit(void)
signal_remove("dcc rejected", (SIGNAL_FUNC) dcc_rejected);
signal_remove("dcc closed", (SIGNAL_FUNC) dcc_closed);
signal_remove("dcc chat message", (SIGNAL_FUNC) dcc_chat_msg);
- signal_remove("dcc ctcp action", (SIGNAL_FUNC) dcc_chat_in_action);
+ signal_remove("dcc ctcp action", (SIGNAL_FUNC) dcc_chat_action);
signal_remove("default dcc ctcp", (SIGNAL_FUNC) dcc_chat_ctcp);
signal_remove("dcc request", (SIGNAL_FUNC) dcc_request);
signal_remove("dcc error connect", (SIGNAL_FUNC) dcc_error_connect);
@@ -452,11 +454,12 @@ void fe_irc_dcc_deinit(void)
signal_remove("dcc error close not found", (SIGNAL_FUNC) dcc_error_close_not_found);
signal_remove("dcc unknown ctcp", (SIGNAL_FUNC) dcc_unknown_ctcp);
signal_remove("dcc unknown reply", (SIGNAL_FUNC) dcc_unknown_reply);
- command_unbind("msg", (SIGNAL_FUNC) dcc_chat_write);
- command_unbind("me", (SIGNAL_FUNC) dcc_chat_out_me);
- command_unbind("action", (SIGNAL_FUNC) dcc_chat_out_action);
- command_unbind("ctcp", (SIGNAL_FUNC) dcc_chat_out_ctcp);
+ signal_remove("dcc destroyed", (SIGNAL_FUNC) sig_dcc_destroyed);
+ signal_remove("query destroyed", (SIGNAL_FUNC) sig_query_destroyed);
+ command_unbind("msg", (SIGNAL_FUNC) cmd_msg);
+ command_unbind("me", (SIGNAL_FUNC) cmd_me);
+ command_unbind("action", (SIGNAL_FUNC) cmd_action);
+ command_unbind("ctcp", (SIGNAL_FUNC) cmd_ctcp);
command_unbind("dcc ", (SIGNAL_FUNC) cmd_dcc_list);
command_unbind("dcc list", (SIGNAL_FUNC) cmd_dcc_list);
- signal_remove("window item remove", (SIGNAL_FUNC) dcc_chat_closed);
}
diff --git a/src/fe-common/irc/dcc/module-formats.c b/src/fe-common/irc/dcc/module-formats.c
index 4dee15f7..da2cdc68 100644
--- a/src/fe-common/irc/dcc/module-formats.c
+++ b/src/fe-common/irc/dcc/module-formats.c
@@ -27,11 +27,13 @@ FORMAT_REC fecommon_irc_dcc_formats[] = {
/* ---- */
{ NULL, "DCC", 0 },
- { "own_dcc", "%K[%rdcc%K(%R$0%K)]%n $1", 2, { 0, 0 } },
- { "own_dcc_me", "%W * $0%n $1", 2, { 0, 0 } },
+ { "own_dcc", "%K[%rdcc%K(%R$0%K)]%n %|$1", 2, { 0, 0 } },
+ { "own_dcc_me", "%W * $0%n %|$1", 2, { 0, 0 } },
{ "own_dcc_ctcp", "%K[%rctcp%K(%R$0%K)]%n $1 $2", 3, { 0, 0, 0 } },
- { "dcc_msg", "%K[%G$0%K(%gdcc%K)]%n $1", 2, { 0, 0 } },
- { "action_dcc", "%W (*dcc*) $0%n $1", 2, { 0, 0 } },
+ { "dcc_msg", "%K[%G$0%K(%gdcc%K)]%n %|$1", 2, { 0, 0 } },
+ { "action_dcc", "%W (*dcc*) $0%n %|$1", 2, { 0, 0 } },
+ { "own_dcc_query", "%K<%W$0%K>%n %|$1", 2, { 0, 0 } },
+ { "dcc_msg_query", "%K<%G$0%K>%n %|$1", 2, { 0, 0 } },
{ "dcc_ctcp", "%g>>> DCC CTCP received from %_$0%_%K: %g$1", 2, { 0, 0 } },
{ "dcc_chat", "%gDCC CHAT from %_$0%_ %K[%g$1 port $2%K]", 3, { 0, 0, 1 } },
{ "dcc_chat_not_found", "%gNo DCC CHAT connection open to %_$0", 1, { 0 } },
@@ -55,6 +57,10 @@ FORMAT_REC fecommon_irc_dcc_formats[] = {
{ "dcc_cant_create", "%gDCC can't create file %G$0%g", 1, { 0 } },
{ "dcc_rejected", "%gDCC %G$0%g was rejected by %_$1%_ %K[%G$2%K]", 3, { 0, 0, 0 } },
{ "dcc_close", "%gDCC %G$0%g close for %_$1%_ %K[%G$2%K]", 3, { 0, 0, 0 } },
+ { "dcc_list_header", "%gDCC connections", 0 },
+ { "dcc_list_line_chat", "%g $0 $1", 2, { 0, 0 } },
+ { "dcc_list_line_file", "%g $0 $1: $2k of $3k ($4%%) - $5kB/s - $6", 7, { 0, 0, 2, 2, 1, 3, 0 } },
+ { "dcc_list_footer", "", 0 },
{ NULL, NULL, 0 }
};
diff --git a/src/fe-common/irc/dcc/module-formats.h b/src/fe-common/irc/dcc/module-formats.h
index d7fe8eff..b61faad5 100644
--- a/src/fe-common/irc/dcc/module-formats.h
+++ b/src/fe-common/irc/dcc/module-formats.h
@@ -10,6 +10,8 @@ enum {
IRCTXT_OWN_DCC_CTCP,
IRCTXT_DCC_MSG,
IRCTXT_ACTION_DCC,
+ IRCTXT_OWN_DCC_QUERY,
+ IRCTXT_DCC_MSG_QUERY,
IRCTXT_DCC_CTCP,
IRCTXT_DCC_CHAT,
IRCTXT_DCC_CHAT_NOT_FOUND,
@@ -32,7 +34,11 @@ enum {
IRCTXT_DCC_CONNECT_ERROR,
IRCTXT_DCC_CANT_CREATE,
IRCTXT_DCC_REJECTED,
- IRCTXT_DCC_CLOSE
+ IRCTXT_DCC_CLOSE,
+ IRCTXT_DCC_LIST_HEADER,
+ IRCTXT_DCC_LIST_LINE_CHAT,
+ IRCTXT_DCC_LIST_LINE_FILE,
+ IRCTXT_DCC_LIST_FOOTER
};
extern FORMAT_REC fecommon_irc_dcc_formats[];
diff --git a/src/fe-common/irc/fe-irc-commands.c b/src/fe-common/irc/fe-irc-commands.c
index dc844346..fa8d9a2f 100644
--- a/src/fe-common/irc/fe-irc-commands.c
+++ b/src/fe-common/irc/fe-irc-commands.c
@@ -161,25 +161,6 @@ static void cmd_msg(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
g_free(params);
}
-static void cmd_notice(gchar *data, IRC_SERVER_REC *server)
-{
- char *params, *target, *msg;
-
- g_return_if_fail(data != NULL);
- if (server == NULL || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED);
-
- params = cmd_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
- if (*target == '\0' || *msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
-
- if (*target == '@' && ischannel(target[1]))
- target++; /* Hybrid 6 feature, send notice to all ops in channel */
-
- printformat(server, target, MSGLEVEL_NOTICES | MSGLEVEL_NOHILIGHT,
- IRCTXT_OWN_NOTICE, target, msg);
-
- g_free(params);
-}
-
static void cmd_me(gchar *data, IRC_SERVER_REC *server, WI_IRC_REC *item)
{
g_return_if_fail(data != NULL);
@@ -187,11 +168,6 @@ static void cmd_me(gchar *data, IRC_SERVER_REC *server, WI_IRC_REC *item)
if (!irc_item_check(item))
return;
- if (irc_item_dcc_chat(item)) {
- /* DCC action - handled by fe-dcc.c */
- return;
- }
-
if (server == NULL || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED);
printformat(server, item->name, MSGLEVEL_ACTIONS,
@@ -206,10 +182,6 @@ static void cmd_action(const char *data, IRC_SERVER_REC *server)
g_return_if_fail(data != NULL);
if (server == NULL || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED);
- if (*data == '=') {
- /* DCC action - handled by fe-dcc.c */
- return;
- }
params = cmd_get_params(data, 3 | PARAM_FLAG_GETREST, &target, &text);
if (*target == '\0' || *text == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
@@ -219,6 +191,25 @@ static void cmd_action(const char *data, IRC_SERVER_REC *server)
g_free(params);
}
+static void cmd_notice(gchar *data, IRC_SERVER_REC *server)
+{
+ char *params, *target, *msg;
+
+ g_return_if_fail(data != NULL);
+ if (server == NULL || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED);
+
+ params = cmd_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
+ if (*target == '\0' || *msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
+
+ if (*target == '@' && ischannel(target[1]))
+ target++; /* Hybrid 6 feature, send notice to all ops in channel */
+
+ printformat(server, target, MSGLEVEL_NOTICES | MSGLEVEL_NOHILIGHT,
+ IRCTXT_OWN_NOTICE, target, msg);
+
+ g_free(params);
+}
+
static void cmd_ctcp(const char *data, IRC_SERVER_REC *server)
{
char *params, *target, *ctcpcmd, *ctcpdata;
@@ -229,11 +220,6 @@ static void cmd_ctcp(const char *data, IRC_SERVER_REC *server)
params = cmd_get_params(data, 3 | PARAM_FLAG_GETREST, &target, &ctcpcmd, &ctcpdata);
if (*target == '\0' || *ctcpcmd == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
- if (*target == '=') {
- /* send CTCP via DCC CHAT */
- g_free(params);
- return;
- }
if (*target == '@' && ischannel(target[1]))
target++; /* Hybrid 6 feature, send ctcp to all ops in channel */
@@ -401,10 +387,10 @@ void fe_irc_commands_init(void)
{
command_bind("query", NULL, (SIGNAL_FUNC) cmd_query);
command_bind("unquery", NULL, (SIGNAL_FUNC) cmd_unquery);
- command_bind("msg", NULL, (SIGNAL_FUNC) cmd_msg);
+ command_bind_last("msg", NULL, (SIGNAL_FUNC) cmd_msg);
+ command_bind_last("me", NULL, (SIGNAL_FUNC) cmd_me);
+ command_bind_last("action", NULL, (SIGNAL_FUNC) cmd_action);
command_bind("notice", NULL, (SIGNAL_FUNC) cmd_notice);
- command_bind("me", NULL, (SIGNAL_FUNC) cmd_me);
- command_bind("action", NULL, (SIGNAL_FUNC) cmd_action);
command_bind("ctcp", NULL, (SIGNAL_FUNC) cmd_ctcp);
command_bind("nctcp", NULL, (SIGNAL_FUNC) cmd_nctcp);
command_bind("ban", NULL, (SIGNAL_FUNC) cmd_ban);
@@ -420,9 +406,9 @@ void fe_irc_commands_deinit(void)
command_unbind("query", (SIGNAL_FUNC) cmd_query);
command_unbind("unquery", (SIGNAL_FUNC) cmd_unquery);
command_unbind("msg", (SIGNAL_FUNC) cmd_msg);
- command_unbind("notice", (SIGNAL_FUNC) cmd_notice);
command_unbind("me", (SIGNAL_FUNC) cmd_me);
command_unbind("action", (SIGNAL_FUNC) cmd_action);
+ command_unbind("notice", (SIGNAL_FUNC) cmd_notice);
command_unbind("ctcp", (SIGNAL_FUNC) cmd_ctcp);
command_unbind("nctcp", (SIGNAL_FUNC) cmd_nctcp);
command_unbind("ban", (SIGNAL_FUNC) cmd_ban);