SilcClientConnection conn = cmd->conn;
SilcClientCommandReplyContext reply =
(SilcClientCommandReplyContext)context2;
- SilcCommandStatus status = silc_command_get_status(reply->payload);
+ SilcCommandStatus status;
+ silc_command_get_status(reply->payload, &status, NULL);
if (status == SILC_STATUS_OK) {
/* Set the nickname */
silc_idcache_del_by_context(conn->client_cache, conn->local_entry);
/* Close connection */
q->client->internal->ops->disconnect(q->client, q->conn);
- silc_client_close_connection(q->client, NULL, q->conn->sock->user_data);
+ silc_client_close_connection(q->client, q->conn->sock->user_data);
silc_free(q);
}
SilcClientCommandContext cmd = (SilcClientCommandContext)context;
SilcClientCommandReplyContext reply =
(SilcClientCommandReplyContext)context2;
- SilcCommandStatus status = silc_command_get_status(reply->payload);
+ SilcCommandStatus status;
+ silc_command_get_status(reply->payload, &status, NULL);
if (status == SILC_STATUS_OK) {
/* Remove with timeout */
silc_schedule_task_add(cmd->client->schedule, cmd->conn->sock->sock,
SilcClientConnection conn = cmd->conn;
SilcChannelEntry channel;
SilcBuffer buffer, idp, auth = NULL;
- char *name, *passphrase = NULL, *cipher = NULL, *hmac = NULL;
- int i;
+ char *name, *passphrase = NULL, *pu8, *cipher = NULL, *hmac = NULL;
+ int i, passphrase_len = 0;
if (!cmd->conn) {
SILC_NOT_CONNECTED(cmd->client, cmd->conn);
}
i++;
} else {
- passphrase = cmd->argv[i];
+ /* Passphrases must be UTF-8 encoded, so encode if it is not */
+ if (!silc_utf8_valid(cmd->argv[i], cmd->argv_lens[i])) {
+ passphrase_len = silc_utf8_encoded_len(cmd->argv[i],
+ cmd->argv_lens[i], 0);
+ pu8 = silc_calloc(passphrase_len, sizeof(*pu8));
+ passphrase_len = silc_utf8_encode(cmd->argv[i], cmd->argv_lens[i],
+ 0, pu8, passphrase_len);
+ passphrase = pu8;
+ } else {
+ passphrase = strdup(cmd->argv[i]);
+ passphrase_len = cmd->argv_lens[i];
+ }
}
}
silc_command_payload_encode_va(SILC_COMMAND_JOIN, 0, 6,
1, name, strlen(name),
2, idp->data, idp->len,
- 3, passphrase,
- passphrase ? strlen(passphrase) : 0,
+ 3, passphrase, passphrase_len,
4, cipher, cipher ? strlen(cipher) : 0,
5, hmac, hmac ? strlen(hmac) : 0,
6, auth ? auth->data : NULL,
silc_buffer_free(idp);
if (auth)
silc_buffer_free(auth);
+ silc_free(passphrase);
/* Notify application */
COMMAND;
else
mode &= ~SILC_UMODE_GONE;
break;
+ case 'i':
+ if (add)
+ mode |= SILC_UMODE_INDISPOSED;
+ else
+ mode &= ~SILC_UMODE_INDISPOSED;
+ break;
+ case 'b':
+ if (add)
+ mode |= SILC_UMODE_BUSY;
+ else
+ mode &= ~SILC_UMODE_BUSY;
+ break;
+ case 'p':
+ if (add)
+ mode |= SILC_UMODE_PAGE;
+ else
+ mode &= ~SILC_UMODE_PAGE;
+ break;
+ case 'h':
+ if (add)
+ mode |= SILC_UMODE_HYPER;
+ else
+ mode &= ~SILC_UMODE_HYPER;
+ break;
+ case 't':
+ if (add)
+ mode |= SILC_UMODE_ROBOT;
+ else
+ mode &= ~SILC_UMODE_ROBOT;
+ break;
default:
COMMAND_ERROR;
goto out;
}
static void silc_client_command_silcoper_send(unsigned char *data,
- SilcUInt32 data_len, void *context)
+ SilcUInt32 data_len,
+ void *context)
{
SilcClientCommandContext cmd = (SilcClientCommandContext)context;
SilcClientConnection conn = cmd->conn;
} else {
SilcClientCommandReplyContext reply =
(SilcClientCommandReplyContext)context2;
- SilcCommandStatus status = silc_command_get_status(reply->payload);
-
+ SilcCommandStatus error;
+
/* If nickname was not found, then resolve the server. */
- if (status == SILC_STATUS_ERR_NO_SUCH_NICK) {
+ silc_command_get_status(reply->payload, NULL, &error);
+ if (error == SILC_STATUS_ERR_NO_SUCH_NICK) {
/* This sends the IDENTIFY command to resolve the server. */
silc_client_command_register(client, SILC_COMMAND_IDENTIFY,
NULL, NULL,
/* If server was not found, then we've resolved both nickname and
server and did not find anybody. */
- if (status == SILC_STATUS_ERR_NO_SUCH_SERVER) {
+ if (error == SILC_STATUS_ERR_NO_SUCH_SERVER) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, "%s",
silc_client_command_status_message(SILC_STATUS_ERR_NO_SUCH_NICK));
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, "%s",
- silc_client_command_status_message(status));
+ silc_client_command_status_message(error));
COMMAND_ERROR;
goto out;
}