updates.
[silc.git] / lib / silcclient / command.c
index d74faf3db569c5784a5abf4d37fb41849b4b25ac..5379000a24473ba256a5e1d37f0f2fb0953fcb66 100644 (file)
@@ -320,8 +320,6 @@ SILC_CLIENT_CMD_FUNC(identify)
   }
 
   if (cmd->argc < 2 || cmd->argc > 3) {
-    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO,
-            "Usage: /IDENTIFY <nickname>[@<server>] [<count>]");
     COMMAND_ERROR;
     goto out;
   }
@@ -1607,11 +1605,15 @@ static void silc_client_command_oper_send(unsigned char *data,
   SilcClientConnection conn = cmd->conn;
   SilcBuffer buffer, auth;
 
-  if (cmd->argc == 3) {
-    /* Pulic key auth XXX TODO */
-    auth = NULL;
+  if (cmd->argc >= 3) {
+    /* Encode the public key authentication payload */
+    auth = silc_auth_public_key_auth_generate(cmd->client->public_key,
+                                             cmd->client->private_key,
+                                             conn->hash,
+                                             conn->local_id,
+                                             SILC_ID_CLIENT);
   } else {
-    /* Encode the authentication payload */
+    /* Encode the password authentication payload */
     auth = silc_auth_payload_encode(SILC_AUTH_PASSWORD, NULL, 0,
                                    data, data_len);
   }
@@ -1636,8 +1638,6 @@ SILC_CLIENT_CMD_FUNC(oper)
 {
   SilcClientCommandContext cmd = (SilcClientCommandContext)context;
   SilcClientConnection conn = cmd->conn;
-  unsigned char *auth_data;
-  uint32 auth_data_len = 0;
 
   if (!cmd->conn) {
     SILC_NOT_CONNECTED(cmd->client, cmd->conn);
@@ -1647,17 +1647,12 @@ SILC_CLIENT_CMD_FUNC(oper)
 
   if (cmd->argc < 2) {
     cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
-                         "Usage: /OPER <username> [<public key>]");
+                         "Usage: /OPER <username> [-pubkey]");
     COMMAND_ERROR;
     goto out;
   }
 
-  if (cmd->argc == 3) {
-    /* XXX Get public key */
-    auth_data = NULL;
-    COMMAND_ERROR;
-    goto out;
-  } else {
+  if (cmd->argc < 3) {
     /* Get passphrase */
     cmd->client->ops->ask_passphrase(cmd->client, conn,
                                     silc_client_command_oper_send,
@@ -1665,13 +1660,7 @@ SILC_CLIENT_CMD_FUNC(oper)
     return;
   }
 
-  silc_client_command_oper_send(auth_data, auth_data_len, context);
-
-  memset(auth_data, 0, auth_data_len);
-  silc_free(auth_data);
-
-  /* Notify application */
-  COMMAND;
+  silc_client_command_oper_send(NULL, 0, context);
 
  out:
   silc_client_command_free(cmd);
@@ -1684,11 +1673,15 @@ static void silc_client_command_silcoper_send(unsigned char *data,
   SilcClientConnection conn = cmd->conn;
   SilcBuffer buffer, auth;
 
-  if (cmd->argc == 3) {
-    /* Pulic key auth XXX TODO */
-    auth = NULL;
+  if (cmd->argc >= 3) {
+    /* Encode the public key authentication payload */
+    auth = silc_auth_public_key_auth_generate(cmd->client->public_key,
+                                             cmd->client->private_key,
+                                             conn->hash,
+                                             conn->local_id,
+                                             SILC_ID_CLIENT);
   } else {
-    /* Encode the authentication payload */
+    /* Encode the password authentication payload */
     auth = silc_auth_payload_encode(SILC_AUTH_PASSWORD, NULL, 0,
                                    data, data_len);
   }
@@ -1713,8 +1706,6 @@ SILC_CLIENT_CMD_FUNC(silcoper)
 {
   SilcClientCommandContext cmd = (SilcClientCommandContext)context;
   SilcClientConnection conn = cmd->conn;
-  unsigned char *auth_data;
-  uint32 auth_data_len = 0;
 
   if (!cmd->conn) {
     SILC_NOT_CONNECTED(cmd->client, cmd->conn);
@@ -1724,17 +1715,12 @@ SILC_CLIENT_CMD_FUNC(silcoper)
 
   if (cmd->argc < 2) {
     cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
-                         "Usage: /SILCOPER <username> [<public key>]");
+                         "Usage: /SILCOPER <username> [-pubkey]");
     COMMAND_ERROR;
     goto out;
   }
 
-  if (cmd->argc == 3) {
-    /* XXX Get public key */
-    auth_data = NULL;
-    COMMAND_ERROR;
-    goto out;
-  } else {
+  if (cmd->argc < 3) {
     /* Get passphrase */
     cmd->client->ops->ask_passphrase(cmd->client, conn,
                                     silc_client_command_silcoper_send,
@@ -1742,13 +1728,7 @@ SILC_CLIENT_CMD_FUNC(silcoper)
     return;
   }
 
-  silc_client_command_silcoper_send(auth_data, auth_data_len, context);
-
-  memset(auth_data, 0, auth_data_len);
-  silc_free(auth_data);
-
-  /* Notify application */
-  COMMAND;
+  silc_client_command_silcoper_send(NULL, 0, context);
 
  out:
   silc_client_command_free(cmd);
@@ -2013,12 +1993,7 @@ SILC_CLIENT_CMD_FUNC(leave)
   if (conn->current_channel == channel)
     conn->current_channel = NULL;
 
-  silc_idcache_del_by_id(conn->channel_cache, channel->id);
-  silc_free(channel->channel_name);
-  silc_free(channel->id);
-  silc_free(channel->key);
-  silc_cipher_free(channel->channel_key);
-  silc_free(channel);
+  silc_client_del_channel(cmd->client, cmd->conn, channel);
 
  out:
   silc_client_command_free(cmd);