#include "fe-common/silc/module-formats.h"
#include "core.h"
+#include "blob.h"
static void
silc_verify_public_key_internal(SilcClient client, SilcClientConnection conn,
strcat(buf, " [blocks private messages]");
if (mode & SILC_UMODE_DETACHED)
strcat(buf, " [detached]");
+ if (mode & SILC_UMODE_REJECT_WATCHING)
+ strcat(buf, " [rejects watching]");
+ if (mode & SILC_UMODE_BLOCK_INVITE)
+ strcat(buf, " [blocks invites]");
}
void silc_say(SilcClient client, SilcClientConnection conn,
va_end(va);
}
+void silc_emit_mime_sig(SILC_SERVER_REC *server, SILC_CHANNEL_REC *channel,
+ const char *data, SilcUInt32 data_len,
+ const char *encoding, const char *type,
+ const char *nick)
+{
+ BLOB_REC blob;
+
+ blob_fill(&blob);
+ blob.octets = data_len;
+ blob.data = (char *)data;
+
+ signal_emit("mime", 6, server, channel, &blob, encoding, type, nick);
+}
+
/* Message for a channel. The `sender' is the nickname of the sender
received in the packet. The `channel_name' is the name of the channel. */
if (flags & SILC_MESSAGE_FLAG_DATA) {
/* MIME object received, try to display it as well as we can */
- char type[128];
+ char type[128], enc[128];
unsigned char *data;
+ SilcUInt32 data_len;
memset(type, 0, sizeof(type));
+ memset(enc, 0, sizeof(enc));
if (!silc_mime_parse(message, message_len, NULL, 0, type, sizeof(type) - 1,
- NULL, 0, &data, NULL))
+ enc, sizeof(enc) - 1, &data, &data_len))
return;
/* Then figure out what we can display */
/* It is something textual, display it */
message = (const unsigned char *)data;
} else {
+ silc_emit_mime_sig(server, chanrec, data, data_len,
+ enc, type, nick->nick);
message = NULL;
}
}
printformat_module("fe-common/silc", server, channel->channel_name,
MSGLEVEL_NOTICES, SILCTXT_CHANNEL_NOTICE,
nick == NULL ? "[<unknown>]" : nick->nick, message);
- else
+ else {
+ if (flags & SILC_MESSAGE_FLAG_UTF8 && !silc_term_utf8()) {
+ char tmp[256], *cp, *dm = NULL;
+
+ memset(tmp, 0, sizeof(tmp));
+ cp = tmp;
+ if (message_len > sizeof(tmp) - 1) {
+ dm = silc_calloc(message_len + 1, sizeof(*dm));
+ cp = dm;
+ }
+
+ silc_utf8_decode(message, message_len, SILC_STRING_LANGUAGE,
+ cp, message_len);
+ signal_emit("message public", 6, server, cp,
+ nick == NULL ? "[<unknown>]" : nick->nick,
+ nick == NULL ? "" : nick->host == NULL ? "" : nick->host,
+ chanrec->name, nick);
+ silc_free(dm);
+ return;
+ }
+
signal_emit("message public", 6, server, message,
nick == NULL ? "[<unknown>]" : nick->nick,
nick == NULL ? "" : nick->host == NULL ? "" : nick->host,
chanrec->name, nick);
+ }
}
/* Private message to the client. The `sender' is the nickname of the
if (flags & SILC_MESSAGE_FLAG_DATA) {
/* MIME object received, try to display it as well as we can */
- char type[128];
+ char type[128], enc[128];
unsigned char *data;
+ SilcUInt32 data_len;
memset(type, 0, sizeof(type));
+ memset(enc, 0, sizeof(enc));
if (!silc_mime_parse(message, message_len, NULL, 0, type, sizeof(type) - 1,
- NULL, 0, &data, NULL))
+ enc, sizeof(enc) - 1, &data, &data_len))
return;
/* Then figure out what we can display */
/* It is something textual, display it */
message = (const unsigned char *)data;
} else {
+ silc_emit_mime_sig(server, NULL, data, data_len,
+ enc, type, sender->nickname);
message = NULL;
}
}
if (!message)
return;
+ if (flags & SILC_MESSAGE_FLAG_UTF8 && !silc_term_utf8()) {
+ char tmp[256], *cp, *dm = NULL;
+
+ memset(tmp, 0, sizeof(tmp));
+ cp = tmp;
+ if (message_len > sizeof(tmp) - 1) {
+ dm = silc_calloc(message_len + 1, sizeof(*dm));
+ cp = dm;
+ }
+
+ silc_utf8_decode(message, message_len, SILC_STRING_LANGUAGE,
+ cp, message_len);
+ signal_emit("message private", 4, server, cp,
+ sender->nickname ? sender->nickname : "[<unknown>]",
+ sender->username ? userhost : NULL);
+ silc_free(dm);
+ return;
+ }
+
signal_emit("message private", 4, server, message,
sender->nickname ? sender->nickname : "[<unknown>]",
sender->username ? userhost : NULL);
SILCTXT_CHANNEL_FOUNDER,
channel->channel_name, client_entry2->nickname);
+ if (mode & SILC_CHANNEL_UMODE_QUIET && conn->local_entry == client_entry2)
+ printformat_module("fe-common/silc",
+ server, channel->channel_name, MSGLEVEL_CRAP,
+ SILCTXT_CHANNEL_QUIETED, channel->channel_name);
+
silc_free(tmp);
break;
{
SILC_SERVER_REC *server = conn->context;
- if (!server) {
+ if (!server || server->disconnected) {
silc_client_close_connection(client, conn);
return;
}
/* Called to indicate that connection was disconnected to the server. */
-void silc_disconnect(SilcClient client, SilcClientConnection conn)
+void silc_disconnect(SilcClient client, SilcClientConnection conn,
+ SilcStatus status, const char *message)
{
SILC_SERVER_REC *server = conn->context;
silc_change_nick(server, silc_client->username);
}
+ if (message)
+ silc_say(client, conn, SILC_CLIENT_MESSAGE_AUDIT,
+ "Server closed connection: %s (%d) %s",
+ silc_get_status_message(status), status,
+ message ? message : "");
+
server->conn->context = NULL;
server->conn = NULL;
server->connection_lost = TRUE;
SILC_LOG_DEBUG(("Start"));
- if (!success)
+ if (!success) {
+ silc_say_error("%s", silc_get_status_message(status));
return;
+ }
- switch(command) {
+ switch (command) {
case SILC_COMMAND_INVITE:
printformat_module("fe-common/silc", server, NULL,
MSGLEVEL_CRAP, SILCTXT_CHANNEL_INVITING,
void ask_passphrase_completion(const char *passphrase, void *context)
{
AskPassphrase p = (AskPassphrase)context;
+ if (passphrase && passphrase[0] == '\0')
+ passphrase = NULL;
p->completion((unsigned char *)passphrase,
passphrase ? strlen(passphrase) : 0, p->context);
silc_free(p);