*/
/* $Id$ */
-#include "clientlibincludes.h"
+#include "silcincludes.h"
+#include "silcclient.h"
#include "client_internal.h"
#define SILC_NOT_CONNECTED(x, c) \
encoded into correct form and in correct order. */
void silc_client_command_send(SilcClient client, SilcClientConnection conn,
- SilcCommand command, uint16 ident,
- uint32 argc, ...)
+ SilcCommand command, SilcUInt16 ident,
+ SilcUInt32 argc, ...)
{
SilcBuffer packet;
va_list ap;
void silc_client_command_pending(SilcClientConnection conn,
SilcCommand reply_cmd,
- uint16 ident,
+ SilcUInt16 ident,
SilcCommandCb callback,
void *context)
{
void silc_client_command_pending_del(SilcClientConnection conn,
SilcCommand reply_cmd,
- uint16 ident)
+ SilcUInt16 ident)
{
SilcClientCommandPending *r;
int silc_client_command_pending_check(SilcClientConnection conn,
SilcClientCommandReplyContext ctx,
SilcCommand command,
- uint16 ident)
+ SilcUInt16 ident)
{
SilcClientCommandPending *r;
SilcClientEntry client_entry = NULL;
SilcChannelEntry channel;
SilcBuffer buffer, clidp, chidp;
- uint32 type = 0;
+ SilcUInt32 type = 0;
char *nickname = NULL, *name;
char *invite = NULL;
{
SilcClientCommandContext cmd = (SilcClientCommandContext)context;
SilcClientConnection conn = cmd->conn;
- SilcIDCacheEntry id_cache = NULL;
+ SilcChannelEntry channel;
SilcBuffer buffer, idp, auth = NULL;
char *name, *passphrase = NULL, *cipher = NULL, *hmac = NULL;
int i;
}
/* See if we have joined to the requested channel already */
- if (silc_idcache_find_by_name_one(conn->channel_cache, cmd->argv[1],
- &id_cache)) {
- SilcChannelEntry channel = (SilcChannelEntry)id_cache->context;
- if (channel->on_channel)
- goto out;
- }
+ channel = silc_client_get_channel(cmd->client, conn, cmd->argv[1]);
+ if (channel && silc_client_on_channel(channel, conn->local_entry))
+ goto out;
idp = silc_id_payload_encode(conn->local_id, SILC_ID_CLIENT);
SilcClientConnection conn = cmd->conn;
SilcBuffer buffer, idp;
unsigned char *cp, modebuf[4];
- uint32 mode, add, len;
+ SilcUInt32 mode, add, len;
int i;
if (!cmd->conn) {
SilcChannelEntry channel;
SilcBuffer buffer, chidp, auth = NULL;
unsigned char *name, *cp, modebuf[4], tmp[4], *arg = NULL;
- uint32 mode, add, type, len, arg_len = 0;
+ SilcUInt32 mode, add, type, len, arg_len = 0;
int i;
if (!cmd->conn) {
SilcClientEntry client_entry;
SilcBuffer buffer, clidp, chidp, auth = NULL;
unsigned char *name, *cp, modebuf[4];
- uint32 mode = 0, add, len;
+ SilcUInt32 mode = 0, add, len;
char *nickname = NULL;
int i;
}
/* Get the current mode */
- silc_list_start(channel->clients);
- while ((chu = silc_list_get(channel->clients)) != SILC_LIST_END) {
- if (chu->client == client_entry) {
- mode = chu->mode;
- break;
- }
- }
+ chu = silc_client_on_channel(channel, client_entry);
+ if (chu)
+ mode = chu->mode;
/* Are we adding or removing mode */
if (cmd->argv[2][0] == '-')
}
static void silc_client_command_oper_send(unsigned char *data,
- uint32 data_len, void *context)
+ SilcUInt32 data_len, void *context)
{
SilcClientCommandContext cmd = (SilcClientCommandContext)context;
SilcClientConnection conn = cmd->conn;
}
static void silc_client_command_silcoper_send(unsigned char *data,
- uint32 data_len, void *context)
+ SilcUInt32 data_len, void *context)
{
SilcClientCommandContext cmd = (SilcClientCommandContext)context;
SilcClientConnection conn = cmd->conn;
SilcClientConnection conn = cmd->conn;
SilcBuffer buffer;
unsigned char port[4];
- uint32 tmp;
+ SilcUInt32 tmp;
if (!cmd->conn) {
SILC_NOT_CONNECTED(cmd->client, cmd->conn);
SilcClientConnection conn = cmd->conn;
SilcBuffer buffer;
unsigned char port[4];
- uint32 tmp;
+ SilcUInt32 tmp;
if (!cmd->conn) {
SILC_NOT_CONNECTED(cmd->client, cmd->conn);
{
SilcClientCommandContext cmd = (SilcClientCommandContext)context;
SilcClientConnection conn = cmd->conn;
- SilcIDCacheEntry id_cache = NULL;
SilcChannelEntry channel;
+ SilcChannelUser chu;
SilcBuffer buffer, idp;
char *name;
name = cmd->argv[1];
}
- /* Get the Channel ID of the channel */
- if (!silc_idcache_find_by_name_one(conn->channel_cache, name, &id_cache)) {
+ /* Get the channel entry */
+ channel = silc_client_get_channel(cmd->client, conn, name);
+ if (!channel) {
SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO,
"You are not on that channel");
COMMAND_ERROR;
goto out;
}
- channel = (SilcChannelEntry)id_cache->context;
- channel->on_channel = FALSE;
+ /* Remove us from channel */
+ chu = silc_client_on_channel(channel, conn->local_entry);
+ if (chu) {
+ silc_hash_table_del(chu->client->channels, chu->channel);
+ silc_hash_table_del(chu->channel->user_list, chu->client);
+ silc_free(chu);
+ }
/* Send LEAVE command to the server */
- idp = silc_id_payload_encode(id_cache->id, SILC_ID_CHANNEL);
+ idp = silc_id_payload_encode(channel->id, SILC_ID_CHANNEL);
buffer = silc_command_payload_encode_va(SILC_COMMAND_LEAVE, 0, 1,
1, idp->data, idp->len);
silc_client_packet_send(cmd->client, conn->sock, SILC_PACKET_COMMAND, NULL,
const char *name,
SilcCommandCb command_function,
SilcCommandCb command_reply_function,
- uint8 max_args,
- uint16 ident)
+ SilcUInt8 max_args,
+ SilcUInt16 ident)
{
SilcClientCommand cmd;
SilcCommand command,
SilcCommandCb command_function,
SilcCommandCb command_reply_function,
- uint16 ident)
+ SilcUInt16 ident)
{
SilcClientCommand cmd;
SILC_CLIENT_CMD(info, INFO, "INFO", 2);
SILC_CLIENT_CMD(connect, CONNECT, "CONNECT", 3);
SILC_CLIENT_CMD(ping, PING, "PING", 2);
- SILC_CLIENT_CMD(oper, OPER, "OPER", 2);
+ SILC_CLIENT_CMD(oper, OPER, "OPER", 3);
SILC_CLIENT_CMD(join, JOIN, "JOIN", 9);
SILC_CLIENT_CMD(motd, MOTD, "MOTD", 2);
SILC_CLIENT_CMD(umode, UMODE, "UMODE", 2);