silc_command_exec(server, "JOIN", channel);
g_free(channel);
}
+
g_strfreev(list);
}
static void sig_server_quit(SILC_SERVER_REC *server, const char *msg)
{
- if (IS_SILC_SERVER(server))
+ if (IS_SILC_SERVER(server) && server->conn && server->conn->sock)
silc_command_exec(server, "QUIT", msg);
}
(void)va_arg(va, char *);
channel = va_arg(va, SilcChannelEntry);
- mode = silc_client_chmode(modei, channel);
+ mode = silc_client_chmode(modei,
+ channel->channel_key->cipher->name,
+ channel->hmac->hmac->name);
chanrec = silc_channel_find_entry(server, channel);
if (chanrec != NULL) {
argv[1], argv_lens[1], TRUE);
printformat_module("fe-common/silc", server, chanrec->entry->channel_name,
- MSGLEVEL_ACTIONS, SILCTXT_CHANNEL_OWNACTION, argv[1]);
+ MSGLEVEL_ACTIONS, SILCTXT_CHANNEL_OWNACTION,
+ server->conn->local_entry->nickname, argv[1]);
+
+ for (i = 0; i < argc; i++)
+ silc_free(argv[i]);
+ silc_free(argv_lens);
+ silc_free(argv_types);
+}
+
+/* ACTION local command. Same as ME but takes the channel as mandatory
+ argument. */
+
+static void command_action(const char *data, SILC_SERVER_REC *server,
+ WI_ITEM_REC *item)
+{
+ SILC_CHANNEL_REC *chanrec;
+ char *tmpcmd = "ME", *tmp;
+ uint32 argc = 0;
+ unsigned char **argv;
+ uint32 *argv_lens, *argv_types;
+ int i;
+
+ if (!IS_SILC_SERVER(server) || !server->connected)
+ cmd_return_error(CMDERR_NOT_CONNECTED);
+
+ if (!IS_SILC_CHANNEL(item))
+ cmd_return_error(CMDERR_NOT_JOINED);
+
+ /* Now parse all arguments */
+ tmp = g_strconcat(tmpcmd, " ", data, NULL);
+ silc_parse_command_line(tmp, &argv, &argv_lens,
+ &argv_types, &argc, 3);
+ g_free(tmp);
+
+ if (argc < 3)
+ cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS);
+
+ chanrec = silc_channel_find(server, argv[1]);
+ if (chanrec == NULL)
+ cmd_return_error(CMDERR_CHAN_NOT_FOUND);
+
+ /* Send the action message */
+ silc_client_send_channel_message(silc_client, server->conn,
+ chanrec->entry, NULL,
+ SILC_MESSAGE_FLAG_ACTION,
+ argv[2], argv_lens[2], TRUE);
+
+ printformat_module("fe-common/silc", server, chanrec->entry->channel_name,
+ MSGLEVEL_ACTIONS, SILCTXT_CHANNEL_OWNACTION,
+ server->conn->local_entry->nickname, argv[2]);
for (i = 0; i < argc; i++)
silc_free(argv[i]);
argv[1], argv_lens[1], TRUE);
printformat_module("fe-common/silc", server, chanrec->entry->channel_name,
- MSGLEVEL_NOTICES, SILCTXT_CHANNEL_OWNNOTICE, argv[1]);
+ MSGLEVEL_NOTICES, SILCTXT_CHANNEL_OWNNOTICE,
+ server->conn->local_entry->nickname, argv[1]);
for (i = 0; i < argc; i++)
silc_free(argv[i]);
static void command_away(const char *data, SILC_SERVER_REC *server,
WI_ITEM_REC *item)
{
+ bool set;
+
if (!IS_SILC_SERVER(server) || !server->connected)
cmd_return_error(CMDERR_NOT_CONNECTED);
- /* XXX TODO */
+ if (*data == '\0') {
+ /* Remove any possible away message */
+ silc_client_set_away_message(silc_client, server->conn, NULL);
+ set = FALSE;
+
+ printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP,
+ SILCTXT_UNSET_AWAY);
+ } else {
+ /* Set the away message */
+ silc_client_set_away_message(silc_client, server->conn, (char *)data);
+ set = TRUE;
+
+ printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP,
+ SILCTXT_SET_AWAY, data);
+ }
+
+ signal_emit("away mode changed", 1, server);
+
+ silc_command_exec(server, "UMODE", set ? "+g" : "-g");
}
typedef struct {
SILC_SERVER_REC *server;
} *KeyInternal;
-static SilcSKEKeyMaterial *curr_key = NULL;
-
/* Key agreement callback that is called after the key agreement protocol
has been performed. This is called also if error occured during the
key agreement protocol. The `key' is the allocated key material and
{
KeyInternal i = (KeyInternal)context;
- curr_key = NULL;
-
switch(status) {
case SILC_KEY_AGREEMENT_OK:
printformat_module("fe-common/silc", i->server, NULL, MSGLEVEL_NOTICES,
} else {
/* Parse the typed nickname. */
if (!silc_parse_nickname(argv[2], &nickname, &serv, &num)) {
- silc_say(silc_client, conn, "Bad nickname");
+ printformat_module("fe-common/silc", server, NULL,
+ MSGLEVEL_CRAP, SILCTXT_BAD_NICK, argv[2]);
return;
}
if (!strcasecmp(argv[3], "set")) {
command = 1;
- if (argc == 4) {
- if (curr_key && type == 1 && client_entry) {
- silc_client_del_private_message_key(silc_client, conn, client_entry);
- silc_client_add_private_message_key_ske(silc_client, conn,
- client_entry, NULL, curr_key);
- goto out;
- }
- }
-
if (argc >= 5) {
if (type == 1 && client_entry) {
/* Set private message key */
command_bind("part", MODULE_NAME, (SIGNAL_FUNC) command_part);
command_bind("me", MODULE_NAME, (SIGNAL_FUNC) command_me);
+ command_bind("action", MODULE_NAME, (SIGNAL_FUNC) command_action);
command_bind("notice", MODULE_NAME, (SIGNAL_FUNC) command_notice);
command_bind("away", MODULE_NAME, (SIGNAL_FUNC) command_away);
command_bind("key", MODULE_NAME, (SIGNAL_FUNC) command_key);
command_unbind("part", (SIGNAL_FUNC) command_part);
command_unbind("me", (SIGNAL_FUNC) command_me);
+ command_unbind("action", (SIGNAL_FUNC) command_action);
command_unbind("notice", (SIGNAL_FUNC) command_notice);
command_unbind("away", (SIGNAL_FUNC) command_away);
command_unbind("key", (SIGNAL_FUNC) command_key);