Integer type name change.
[silc.git] / apps / silc / local_command.c
index 2f18ae0344ff747b12bb170a2dcb5c03c7130f2b..76c5c5bf8824faf0d22ad2bb3254aeea1f647cc3 100644 (file)
@@ -90,7 +90,6 @@ SILC_CLIENT_LCMD_FUNC(version)
    private messages are not really commands, they are message packets,
    however, on user interface it is convenient to show them as commands
    as that is the common way of sending private messages (like in IRC). */
-/* XXX supports only one destination */
 
 SILC_CLIENT_LCMD_FUNC(msg)
 {
@@ -98,7 +97,7 @@ SILC_CLIENT_LCMD_FUNC(msg)
   SilcClientConnection conn = cmd->conn;
   SilcClient client = cmd->client;
   SilcClientEntry client_entry = NULL;
-  unsigned int num = 0;
+  SilcUInt32 num = 0;
   char *nickname = NULL, *server = NULL;
 
   if (!cmd->conn) {
@@ -218,6 +217,8 @@ SILC_CLIENT_LCMD_FUNC(away)
   SilcClientConnection conn = cmd->conn;
   SilcClient client = cmd->client;
   SilcClientInternal app = (SilcClientInternal)client->application;
+  unsigned char modebuf[4];
+  SilcBuffer idp, buffer;
 
   if (!cmd->conn) {
     silc_say(client, conn,
@@ -226,6 +227,8 @@ SILC_CLIENT_LCMD_FUNC(away)
   }
 
   if (cmd->argc == 1) {
+    conn->local_entry->mode &= ~SILC_UMODE_GONE;
+
     if (conn->away) {
       silc_free(conn->away->away);
       silc_free(conn->away);
@@ -236,7 +239,8 @@ SILC_CLIENT_LCMD_FUNC(away)
       silc_screen_print_bottom_line(app->screen, 0);
     }
   } else {
-
+    conn->local_entry->mode |= SILC_UMODE_GONE;
+  
     if (conn->away)
       silc_free(conn->away->away);
     else
@@ -249,6 +253,19 @@ SILC_CLIENT_LCMD_FUNC(away)
     silc_screen_print_bottom_line(app->screen, 0);
   }
 
+  /* Send the UMODE command to se myself as gone */
+  idp = silc_id_payload_encode(conn->local_id, SILC_ID_CLIENT);
+  SILC_PUT32_MSB(conn->local_entry->mode, modebuf);
+  buffer = silc_command_payload_encode_va(SILC_COMMAND_UMODE, 
+                                         ++conn->cmd_ident, 2, 
+                                         1, idp->data, idp->len, 
+                                         2, modebuf, sizeof(modebuf));
+  silc_client_packet_send(cmd->client, conn->sock, SILC_PACKET_COMMAND, 
+                         NULL, 0, NULL, NULL, buffer->data, 
+                         buffer->len, TRUE);
+  silc_buffer_free(buffer);
+  silc_buffer_free(idp);
+
  out:
   silc_client_command_free(cmd);
 }
@@ -284,17 +301,10 @@ static void keyagr_completion(SilcClient client,
             client_entry->nickname);;
 
     if (i->type == 1) {
-      if (!silc_client_ask_yes_no(client, 
-         "Would you like to use the key with private messages (y/n)? ")) {
-       silc_say(client, conn, "You can set the key material into use later by giving /KEY msg set command");
-       curr_key = key;
-       break;
-      }
-      
       /* Set the private key for this client */
       silc_client_del_private_message_key(client, conn, client_entry);
       silc_client_add_private_message_key_ske(client, conn, client_entry,
-                                             NULL, key);
+                                             NULL, key, FALSE);
       silc_say(client, conn, "The private messages with the %s are now protected with the private key", client_entry->nickname);
       silc_ske_free_key_material(key);
     }
@@ -339,7 +349,7 @@ SILC_CLIENT_LCMD_FUNC(key)
   SilcClient client = cmd->client;
   SilcClientEntry client_entry = NULL;
   SilcChannelEntry channel_entry = NULL;
-  unsigned int num = 0;
+  SilcUInt32 num = 0;
   char *nickname = NULL, *server = NULL;
   int command = 0, port = 0, type = 0;
   char *hostname = NULL;
@@ -400,7 +410,7 @@ SILC_CLIENT_LCMD_FUNC(key)
 
     if (cmd->argv[2][0] == '*') {
       if (!conn->current_channel) {
-       cmd->client->ops->say(cmd->client, conn, "You are not on any channel");
+       silc_say(cmd->client, conn, "You are not on any channel");
        goto out;
       }
       name = conn->current_channel->channel_name;
@@ -423,7 +433,7 @@ SILC_CLIENT_LCMD_FUNC(key)
       if (curr_key && type == 1 && client_entry) {
        silc_client_del_private_message_key(client, conn, client_entry);
        silc_client_add_private_message_key_ske(client, conn, client_entry,
-                                               NULL, curr_key);
+                                               NULL, curr_key, FALSE);
        goto out;
       }
     }
@@ -439,13 +449,13 @@ SILC_CLIENT_LCMD_FUNC(key)
                                              cmd->argv[5], cmd->argv[4],
                                              cmd->argv_lens[4],
                                              (cmd->argv[4][0] == '*' ?
-                                              TRUE : FALSE));
+                                              TRUE : FALSE), FALSE);
        else
          silc_client_add_private_message_key(client, conn, client_entry,
                                              NULL, cmd->argv[4],
                                              cmd->argv_lens[4],
                                              (cmd->argv[4][0] == '*' ?
-                                              TRUE : FALSE));
+                                              TRUE : FALSE), FALSE);
 
        /* Send the key to the remote client so that it starts using it
           too. */
@@ -488,7 +498,7 @@ SILC_CLIENT_LCMD_FUNC(key)
     } else if (type == 2) {
       /* Unset channel key(s) */
       SilcChannelPrivateKey *keys;
-      unsigned int keys_count;
+      SilcUInt32 keys_count;
       int number;
 
       if (cmd->argc == 4)
@@ -522,7 +532,7 @@ SILC_CLIENT_LCMD_FUNC(key)
 
     if (type == 1) {
       SilcPrivateMessageKeys keys;
-      unsigned int keys_count;
+      SilcUInt32 keys_count;
       int k, i, len;
       char buf[1024];
 
@@ -597,7 +607,7 @@ SILC_CLIENT_LCMD_FUNC(key)
       silc_client_free_private_message_keys(keys, keys_count);
     } else if (type == 2) {
       SilcChannelPrivateKey *keys;
-      unsigned int keys_count;
+      SilcUInt32 keys_count;
       int k, i, len;
       char buf[1024];
 
@@ -718,7 +728,7 @@ SILC_CLIENT_LCMD_FUNC(me)
 
   if (cmd->argv[1][0] == '*') {
     if (!conn->current_channel) {
-      cmd->client->ops->say(cmd->client, conn, "You are not on any channel");
+      silc_say(cmd->client, conn, "You are not on any channel");
       goto out;
     }
     name = conn->current_channel->channel_name;
@@ -760,13 +770,13 @@ SILC_CLIENT_LCMD_FUNC(notice)
   }
 
   if (cmd->argc < 3) {
-    silc_say(client, conn, "Usage: /ME <channel> <action message>");
+    silc_say(client, conn, "Usage: /NOTICE <channel> <message>");
     goto out;
   }
 
   if (cmd->argv[1][0] == '*') {
     if (!conn->current_channel) {
-      cmd->client->ops->say(cmd->client, conn, "You are not on any channel");
+      silc_say(cmd->client, conn, "You are not on any channel");
       goto out;
     }
     name = conn->current_channel->channel_name;