#include "rawlog.h"
#include "misc.h"
#include "settings.h"
+#include "blob.h"
#include "channels-setup.h"
#include "silc-commands.h"
+void sig_mime(SILC_SERVER_REC *server, SILC_CHANNEL_REC *channel,
+ BLOB_REC *blob, const char *enc, const char *type,
+ const char *nick)
+{
+ if (!(IS_SILC_SERVER(server)))
+ return;
+
+ printformat_module("fe-common/silc", server,
+ channel == NULL ? NULL : channel->name,
+ MSGLEVEL_CRAP, SILCTXT_MESSAGE_DATA,
+ nick == NULL ? "[<unknown>]" : nick, type);
+}
+
SILC_CHANNEL_REC *silc_channel_create(SILC_SERVER_REC *server,
const char *name, int automatic)
{
SILC_CHANNEL_REC *chanrec;
char *tmpcmd = "ME", *tmp;
SilcUInt32 argc = 0;
+ unsigned char *message = NULL;
unsigned char **argv;
SilcUInt32 *argv_lens, *argv_types;
int i;
if (chanrec == NULL)
cmd_return_error(CMDERR_CHAN_NOT_FOUND);
+ if (!silc_term_utf8()) {
+ int len = silc_utf8_encoded_len(argv[1], argv_lens[1],
+ SILC_STRING_LANGUAGE);
+ message = silc_calloc(len + 1, sizeof(*message));
+ g_return_if_fail(message != NULL);
+ silc_utf8_encode(argv[1], argv_lens[1], SILC_STRING_LANGUAGE,
+ message, len);
+ }
+
/* Send the action message */
silc_client_send_channel_message(silc_client, server->conn,
chanrec->entry, NULL,
- SILC_MESSAGE_FLAG_ACTION,
- argv[1], argv_lens[1], TRUE);
+ SILC_MESSAGE_FLAG_ACTION |
+ SILC_MESSAGE_FLAG_UTF8,
+ message ? message : argv[1],
+ message ? strlen(message) : argv_lens[1],
+ TRUE);
printformat_module("fe-common/silc", server, chanrec->entry->channel_name,
MSGLEVEL_ACTIONS, SILCTXT_CHANNEL_OWNACTION,
silc_free(argv[i]);
silc_free(argv_lens);
silc_free(argv_types);
+ silc_free(message);
}
/* ACTION local command. Same as ME but takes the channel as mandatory
SILC_CHANNEL_REC *chanrec;
char *tmpcmd = "ME", *tmp;
SilcUInt32 argc = 0;
+ unsigned char *message = NULL;
unsigned char **argv;
SilcUInt32 *argv_lens, *argv_types;
int i;
if (chanrec == NULL)
cmd_return_error(CMDERR_CHAN_NOT_FOUND);
+ if (!silc_term_utf8()) {
+ int len = silc_utf8_encoded_len(argv[2], argv_lens[2],
+ SILC_STRING_LANGUAGE);
+ message = silc_calloc(len + 1, sizeof(*message));
+ g_return_if_fail(message != NULL);
+ silc_utf8_encode(argv[2], argv_lens[2], SILC_STRING_LANGUAGE,
+ message, len);
+ }
+
/* 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);
+ SILC_MESSAGE_FLAG_ACTION |
+ SILC_MESSAGE_FLAG_UTF8,
+ message ? message : argv[2],
+ message ? strlen(message) : argv_lens[2],
+ TRUE);
printformat_module("fe-common/silc", server, chanrec->entry->channel_name,
MSGLEVEL_ACTIONS, SILCTXT_CHANNEL_OWNACTION,
silc_free(argv[i]);
silc_free(argv_lens);
silc_free(argv_types);
+ silc_free(message);
}
/* NOTICE local command. */
SILC_CHANNEL_REC *chanrec;
char *tmpcmd = "ME", *tmp;
SilcUInt32 argc = 0;
+ unsigned char *message = NULL;
unsigned char **argv;
SilcUInt32 *argv_lens, *argv_types;
int i;
if (chanrec == NULL)
cmd_return_error(CMDERR_CHAN_NOT_FOUND);
+ if (!silc_term_utf8()) {
+ int len = silc_utf8_encoded_len(argv[1], argv_lens[1],
+ SILC_STRING_LANGUAGE);
+ message = silc_calloc(len + 1, sizeof(*message));
+ g_return_if_fail(message != NULL);
+ silc_utf8_encode(argv[1], argv_lens[1], SILC_STRING_LANGUAGE,
+ message, len);
+ }
+
/* Send the action message */
silc_client_send_channel_message(silc_client, server->conn,
chanrec->entry, NULL,
- SILC_MESSAGE_FLAG_NOTICE,
- argv[1], argv_lens[1], TRUE);
+ SILC_MESSAGE_FLAG_NOTICE |
+ SILC_MESSAGE_FLAG_UTF8,
+ message ? message : argv[1],
+ message ? strlen(message) : argv_lens[1],
+ TRUE);
printformat_module("fe-common/silc", server, chanrec->entry->channel_name,
MSGLEVEL_NOTICES, SILCTXT_CHANNEL_OWNNOTICE,
silc_free(argv[i]);
silc_free(argv_lens);
silc_free(argv_types);
+ silc_free(message);
}
/* AWAY local command. Sends UMODE command that sets the SILC_UMODE_GONE
printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP,
SILCTXT_UNSET_AWAY);
- server->usermode_away = FALSE;
} else {
/* Set the away message */
silc_client_set_away_message(silc_client, server->conn, (char *)data);
printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP,
SILCTXT_SET_AWAY, data);
- server->usermode_away = TRUE;
}
+ server->usermode_away = set;
+ g_free_and_null(server->away_reason);
+ if (set)
+ server->away_reason = g_strdup((char *)data);
+
signal_emit("away mode changed", 1, server);
silc_command_exec(server, "UMODE", set ? "+g" : "-g");
signal_add("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
signal_add("server connected", (SIGNAL_FUNC) sig_connected);
signal_add("server quit", (SIGNAL_FUNC) sig_server_quit);
+ signal_add("mime", (SIGNAL_FUNC) sig_mime);
command_bind_silc("part", MODULE_NAME, (SIGNAL_FUNC) command_part);
command_bind_silc("me", MODULE_NAME, (SIGNAL_FUNC) command_me);
signal_remove("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);
signal_remove("server connected", (SIGNAL_FUNC) sig_connected);
signal_remove("server quit", (SIGNAL_FUNC) sig_server_quit);
+ signal_remove("mime", (SIGNAL_FUNC) sig_mime);
command_unbind("part", (SIGNAL_FUNC) command_part);
command_unbind("me", (SIGNAL_FUNC) command_me);