updates.
authorPekka Riikonen <priikone@silcnet.org>
Thu, 28 Jun 2001 19:22:24 +0000 (19:22 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Thu, 28 Jun 2001 19:22:24 +0000 (19:22 +0000)
19 files changed:
CHANGES
TODO
apps/irssi/src/silc/core/client_ops.c
apps/irssi/src/silc/core/client_ops.h
apps/irssi/src/silc/core/silc-channels.c
apps/silc/client_ops.c
apps/silc/client_ops.h
apps/silc/clientincludes.h [moved from includes/clientincludes.h with 100% similarity]
apps/silc/local_command.c
apps/silcd/serverincludes.h [moved from includes/serverincludes.h with 100% similarity]
lib/silcclient/client.c
lib/silcclient/client_channel.c
lib/silcclient/client_keyagr.c
lib/silcclient/client_prvmsg.c
lib/silcclient/command.c
lib/silcclient/command_reply.c
lib/silcclient/idlist.c
lib/silcclient/protocol.c
lib/silcclient/silcapi.h

diff --git a/CHANGES b/CHANGES
index fa9f19479881b5934a29cc5535c06075f70d9062..eda8d82ef0dfe7874a41f4b192ee794b521bcd50 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,22 @@
+Thu Jun 28 21:30:39 EEST 2001  Pekka Riikonen <priikone@silcnet.org>
+
+       * Changed the `say' client operation's interface to accept
+         new `type' argument to indicate the type of the message sent
+         by the library.  The application may filter the library's
+         messages according the type.  The affected file is the
+         lib/silcclient/silcapi.h.
+
+       * Added two new functions to lib/silcclient/silcapi.h:
+         silc_client_del_client and silc_client_del_client_by_id.
+         Affected file lib/silcclient/idlist.c.
+
+       * Moved the clientincludes.h from includes/ to silc/ and
+         serverincludes.h from includes/ to silcd/.
+
+       * The modes for the CMODE and CUMODE are now passed as
+         uint32 for application with COMMAND_REPLY.  The affected
+         file is lib/silcclient/command_reply.c.
+
 Wed Jun 27 22:24:47 EEST 2001  Pekka Riikonen <priikone@silcnet.org>
 
        * /WHOIS without arguments shows client's own information.
diff --git a/TODO b/TODO
index 1e67a4019de2df7f2b50fb4b28e030c957da8258..283d1db52dc99816901d8236f8a68eb2cfd7ec45 100644 (file)
--- a/TODO
+++ b/TODO
@@ -31,10 +31,11 @@ TODO/bugs In SILC Client Library
 ================================
 
  o Library should save the cumode and not start from 0 everytime then
-   CUMODE is issued.
-
- o Add some silc_client_del_client and other deletion funtions for
-   application to delete client entrys from the cache.
+   CUMODE is issued.  A mechanism of getting the channel entry for
+   CMODE and CUMODE by the command reply identifier must be added.
+   Otherwise saving the modes for the channels and channel user
+   entries are impossible since server does not send Channel ID as
+   command reply in these functions.
 
  o All protocol execution timeouts are hard coded. They should be 
    configurable and the Irssi SILC client should be able to set them
@@ -43,9 +44,6 @@ TODO/bugs In SILC Client Library
 
  o silc_client_close_connection leaks memory.  Read the XXX from code.
 
- o Some of the ops->say's should be removed and moved to the application
-   from the library.  Go through these.
-
  o The client library must manage somehow when receiving client that has
    same nickname, same server, same username but different Client ID than
    what we have in the cache.  It is now assumed that they are different
@@ -54,13 +52,6 @@ TODO/bugs In SILC Client Library
    interface separately or it could just remove the old client unless
    it is on some channels.
 
- o Add client library parameters or options that handle what kind of
-   messages the library should print out (using `say' client operation,
-   for example) and what is left for the application to print.  The
-   appliation could for example set that it handles all command printing
-   but all error printing should be handled by the library, etc...
-   This is not a showstopper.
-
 
 TODO/bugs In SILC Server
 ========================
@@ -189,6 +180,8 @@ TODO After 1.0
    to start writing one myself.  Anyhow, the OpenSSL X.509 lib should
    be checked.
 
+   Other package that should be checked is the NSS's X509 library.
+
  o SSH2 public keys support.  Maybe - not really needed but could be
    nice as SSH is widely used all over the place.  SILC Protocol 
    supports SSH2 public keys.
index 0b95e988bd309111cf570e1716e00fbc279113c9..12fe0f4eb13e2a37618ff300812a03c80c31bbef 100644 (file)
@@ -45,7 +45,7 @@ silc_verify_public_key_internal(SilcClient client, SilcClientConnection conn,
                                SilcVerifyPublicKey completion, void *context);
 
 void silc_say(SilcClient client, SilcClientConnection conn,
-                    char *msg, ...)
+             SilcClientMessageType type, char *msg, ...)
 {
   SILC_SERVER_REC *server;
   va_list va;
index c92ed024038a2173590d67d9a51827b709618dd0..620e72f89ddf5fb412c6b9a4436abc73a4f87726 100644 (file)
@@ -21,7 +21,8 @@
 #ifndef CLIENT_OPS_H
 #define CLIENT_OPS_H
 
-void silc_say(SilcClient client, SilcClientConnection conn, char *msg, ...);
+void silc_say(SilcClient client, SilcClientConnection conn, 
+             SilcClientMessageType type, char *msg, ...);
 void silc_say_error(char *msg, ...);
 void silc_channel_message(SilcClient client, SilcClientConnection conn,
                          SilcClientEntry sender, 
index ead74959c8bd6287016db399995632e6a4b73b04..c823e0a5e1699c87ca15ef31fbcaf3030a942152 100644 (file)
@@ -800,7 +800,8 @@ static void command_key(const char *data, SILC_SERVER_REC *server,
   g_free(tmp);
 
   if (argc < 4) {
-    silc_say(silc_client, conn, "Usage: /KEY msg|channel <nickname|channel> "
+    silc_say(silc_client, conn, SILC_CLIENT_MESSAGE_INFO,
+            "Usage: /KEY msg|channel <nickname|channel> "
             "set|unset|agreement|negotiate [<arguments>]");
     return;
   }
@@ -812,7 +813,8 @@ static void command_key(const char *data, SILC_SERVER_REC *server,
     type = 2;
 
   if (type == 0) {
-    silc_say(silc_client, conn, "Usage: /KEY msg|channel <nickname|channel> "
+    silc_say(silc_client, conn, SILC_CLIENT_MESSAGE_INFO,
+            "Usage: /KEY msg|channel <nickname|channel> "
             "set|unset|agreement|negotiate [<arguments>]");
     return;
   }
@@ -1018,7 +1020,7 @@ static void command_key(const char *data, SILC_SERVER_REC *server,
          else
            strcat(buf, "*generated*");
 
-         silc_say(silc_client, conn, "%s", buf);
+         silc_say(silc_client, conn, SILC_CLIENT_MESSAGE_INFO, "%s", buf);
        }
       } else {
        printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP,
@@ -1049,7 +1051,7 @@ static void command_key(const char *data, SILC_SERVER_REC *server,
          else
            strcat(buf, "*generated*");
 
-         silc_say(silc_client, conn, "%s", buf);
+         silc_say(silc_client, conn, SILC_CLIENT_MESSAGE_INFO, "%s", buf);
        }
       }
 
@@ -1089,7 +1091,7 @@ static void command_key(const char *data, SILC_SERVER_REC *server,
        
        strcat(buf, "<hidden>");
 
-       silc_say(silc_client, conn, "%s", buf);
+       silc_say(silc_client, conn, SILC_CLIENT_MESSAGE_INFO, "%s", buf);
       }
       
       silc_client_free_channel_private_keys(keys, keys_count);
@@ -1128,7 +1130,8 @@ static void command_key(const char *data, SILC_SERVER_REC *server,
   }
 
   if (command == 0) {
-    silc_say(silc_client, conn, "Usage: /KEY msg|channel <nickname|channel> "
+    silc_say(silc_client, conn, SILC_CLIENT_MESSAGE_INFO,
+            "Usage: /KEY msg|channel <nickname|channel> "
             "set|unset|agreement|negotiate [<arguments>]");
     goto out;
   }
index 47761266bedf11c78c0142df67e0746fca660953..c027c147df9a7449904f252cc68bb3e2313d1717 100644 (file)
@@ -177,12 +177,30 @@ silc_verify_public_key_internal(SilcClient client, SilcClientConnection conn,
   return FALSE;
 }
 
+void silc_say(SilcClient client, SilcClientConnection conn, 
+             char *msg, ...)
+{
+  va_list vp;
+  char message[2048];
+  SilcClientInternal app = (SilcClientInternal)client->application;
+
+  memset(message, 0, sizeof(message));
+  strncat(message, "\n***  ", 5);
+
+  va_start(vp, msg);
+  vsprintf(message + 5, msg, vp);
+  va_end(vp);
+  
+  /* Print the message */
+  silc_print_to_window(app->screen->output_win[0], message);
+}
+
 /* Prints a message with three star (*) sign before the actual message
    on the current output window. This is used to print command outputs
    and error messages. */
 
-void silc_say(SilcClient client, SilcClientConnection conn, 
-             char *msg, ...)
+void silc_op_say(SilcClient client, SilcClientConnection conn, 
+                SilcClientMessageType type, char *msg, ...)
 {
   va_list vp;
   char message[2048];
@@ -592,7 +610,7 @@ void silc_client_show_users(SilcClient client,
     k++;
   }
 
-  client->ops->say(client, conn, "Users on %s: %s", channel->channel_name, 
+  silc_say(client, conn, "Users on %s: %s", channel->channel_name, 
                   name_list);
   silc_free(name_list);
 }
@@ -638,10 +656,10 @@ void silc_command_reply(SilcClient client, SilcClientConnection conn,
          tmp = silc_argument_get_arg_type(silc_command_get_args(cmd_payload),
                                           3, NULL);
          if (tmp)
-           client->ops->say(client, conn, "%s: %s", tmp,
+           silc_say(client, conn, "%s: %s", tmp,
                             silc_client_command_status_message(status));
          else
-           client->ops->say(client, conn, "%s",
+           silc_say(client, conn, "%s",
                             silc_client_command_status_message(status));
          break;
        }
@@ -675,7 +693,7 @@ void silc_command_reply(SilcClient client, SilcClientConnection conn,
          strncat(buf, ")", 1);
        }
 
-       client->ops->say(client, conn, "%s", buf);
+       silc_say(client, conn, "%s", buf);
 
        if (channels) {
          SilcDList list = silc_channel_payload_parse_list(channels);
@@ -698,7 +716,7 @@ void silc_command_reply(SilcClient client, SilcClientConnection conn,
              silc_free(m);
            }
 
-           client->ops->say(client, conn, "%s", buf);
+           silc_say(client, conn, "%s", buf);
            silc_channel_payload_list_free(list);
          }
        }
@@ -706,18 +724,18 @@ void silc_command_reply(SilcClient client, SilcClientConnection conn,
        if (mode) {
          if ((mode & SILC_UMODE_SERVER_OPERATOR) ||
              (mode & SILC_UMODE_ROUTER_OPERATOR))
-           client->ops->say(client, conn, "%s is %s", nickname,
+           silc_say(client, conn, "%s is %s", nickname,
                             (mode & SILC_UMODE_SERVER_OPERATOR) ?
                             "Server Operator" :
                             (mode & SILC_UMODE_ROUTER_OPERATOR) ?
                             "SILC Operator" : "[Unknown mode]");
 
          if (mode & SILC_UMODE_GONE)
-           client->ops->say(client, conn, "%s is gone", nickname);
+           silc_say(client, conn, "%s is gone", nickname);
        }
 
        if (idle && nickname)
-         client->ops->say(client, conn, "%s has been idle %d %s",
+         silc_say(client, conn, "%s has been idle %d %s",
                           nickname,
                           idle > 60 ? (idle / 60) : idle,
                           idle > 60 ? "minutes" : "seconds");
@@ -735,10 +753,10 @@ void silc_command_reply(SilcClient client, SilcClientConnection conn,
          tmp = silc_argument_get_arg_type(silc_command_get_args(cmd_payload),
                                           3, NULL);
          if (tmp)
-           client->ops->say(client, conn, "%s: %s", tmp,
+           silc_say(client, conn, "%s: %s", tmp,
                             silc_client_command_status_message(status));
          else
-           client->ops->say(client, conn, "%s",
+           silc_say(client, conn, "%s",
                             silc_client_command_status_message(status));
          break;
        }
@@ -769,7 +787,7 @@ void silc_command_reply(SilcClient client, SilcClientConnection conn,
          strncat(buf, ")", 1);
        }
 
-       client->ops->say(client, conn, "%s", buf);
+       silc_say(client, conn, "%s", buf);
       }
       break;
 
@@ -817,7 +835,7 @@ void silc_command_reply(SilcClient client, SilcClientConnection conn,
        client_id_list = va_arg(vp, SilcBuffer);
 
        if (topic)
-         client->ops->say(client, conn, "Topic for %s: %s", 
+         silc_say(client, conn, "Topic for %s: %s", 
                           app->screen->bottom_line->channel, topic);
        
        app->screen->bottom_line->channel_mode = 
@@ -1308,7 +1326,7 @@ int silc_key_agreement(SilcClient client, SilcClientConnection conn,
 
 /* SILC client operations */
 SilcClientOperations ops = {
-  silc_say,
+  silc_op_say,
   silc_channel_message,
   silc_private_message,
   silc_notify,
index e803af4d720285389fbe854191224fcc0d892dd9..eb084caf185df502d4767c3a8f8cdf8669f0ea7e 100644 (file)
@@ -22,6 +22,8 @@
 #define CLIENT_OPS_H
 
 void silc_say(SilcClient client, SilcClientConnection conn, char *msg, ...);
+void silc_op_say(SilcClient client, SilcClientConnection conn, 
+                SilcClientMessageType type, char *msg, ...);
 void silc_channel_message(SilcClient client, SilcClientConnection conn,
                          SilcClientEntry sender, 
                          SilcChannelEntry channel, 
index 509b4fa2c52f89b35f26dab15d310aaa202cef3f..116f12fa679bad829ead432cc44864e468d5f4eb 100644 (file)
@@ -304,7 +304,7 @@ static void keyagr_completion(SilcClient client,
       /* 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);
     }
@@ -410,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;
@@ -433,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;
       }
     }
@@ -449,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. */
@@ -728,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;
@@ -776,7 +776,7 @@ SILC_CLIENT_LCMD_FUNC(notice)
 
   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;
index b79fc7891d5c29c95d9c0f3bfbcd1a285bfc659e..20c878707604a6a23192a2bc7b5e08eb62b48cb8 100644 (file)
@@ -279,7 +279,7 @@ int silc_client_connect_to_server(SilcClient client, int port,
 
   conn = silc_client_add_connection(client, host, port, context);
 
-  client->ops->say(client, conn, 
+  client->ops->say(client, conn, SILC_CLIENT_MESSAGE_AUDIT, 
                   "Connecting to port %d of server %s", port, host);
 
   /* Allocate internal context for connection process. This is
@@ -337,7 +337,7 @@ int silc_client_start_key_exchange(SilcClient client,
                      &protocol, (void *)proto_ctx,
                      silc_client_connect_to_server_second);
   if (!protocol) {
-    client->ops->say(client, conn, 
+    client->ops->say(client, conn, SILC_CLIENT_MESSAGE_ERROR,
                     "Error: Could not start authentication protocol");
     return FALSE;
   }
@@ -375,9 +375,10 @@ SILC_TASK_CALLBACK(silc_client_connect_to_server_start)
   if (opt != 0) {
     if (ctx->tries < 2) {
       /* Connection failed but lets try again */
-      client->ops->say(client, conn, "Could not connect to server %s: %s",
+      client->ops->say(client, conn, SILC_CLIENT_MESSAGE_ERROR,
+                      "Could not connect to server %s: %s",
                       ctx->host, strerror(opt));
-      client->ops->say(client, conn, 
+      client->ops->say(client, conn, SILC_CLIENT_MESSAGE_AUDIT, 
                       "Connecting to port %d of server %s resumed", 
                       ctx->port, ctx->host);
 
@@ -391,7 +392,8 @@ SILC_TASK_CALLBACK(silc_client_connect_to_server_start)
       ctx->tries++;
     } else {
       /* Connection failed and we won't try anymore */
-      client->ops->say(client, conn, "Could not connect to server %s: %s",
+      client->ops->say(client, conn, SILC_CLIENT_MESSAGE_ERROR,
+                      "Could not connect to server %s: %s",
                       ctx->host, strerror(opt));
       silc_schedule_unset_listen_fd(client->schedule, fd);
       silc_net_close_connection(fd);
@@ -1229,7 +1231,7 @@ void silc_client_disconnected_by_server(SilcClient client,
 
   msg = silc_calloc(message->len + 1, sizeof(char));
   memcpy(msg, message->data, message->len);
-  client->ops->say(client, sock->user_data, msg);
+  client->ops->say(client, sock->user_data, SILC_CLIENT_MESSAGE_AUDIT, msg);
   silc_free(msg);
 
   SILC_SET_DISCONNECTED(sock);
@@ -1247,7 +1249,7 @@ void silc_client_error_by_server(SilcClient client,
 
   msg = silc_calloc(message->len + 1, sizeof(char));
   memcpy(msg, message->data, message->len);
-  client->ops->say(client, sock->user_data, msg);
+  client->ops->say(client, sock->user_data, SILC_CLIENT_MESSAGE_AUDIT, msg);
   silc_free(msg);
 }
 
index 9a04d07e4a95784df223697f4739cb49d1cb4a75..2f6811927f07456c14d037580938b67a1c9be236 100644 (file)
@@ -310,7 +310,7 @@ void silc_client_save_channel_key(SilcClientConnection conn,
   memcpy(channel->key, key, tmp_len);
 
   if (!silc_cipher_alloc(cipher, &channel->channel_key)) {
-    conn->client->ops->say(conn->client, conn,
+    conn->client->ops->say(conn->client, conn, SILC_CLIENT_MESSAGE_AUDIT,
                     "Cannot talk to channel: unsupported cipher %s", cipher);
     goto out;
   }
index 6be73f8900ad1c4d14dbbfca47499126ee9d79ad..41c6edff3091daadfba0ceda553133799988e920 100644 (file)
@@ -152,7 +152,7 @@ SILC_TASK_CALLBACK(silc_client_process_key_agreement)
 
   sock = silc_net_accept_connection(ke->fd);
   if (sock < 0) {
-    client->ops->say(client, conn, 
+    client->ops->say(client, conn, SILC_CLIENT_MESSAGE_AUDIT,
                     "Could not accept key agreement connection: ", 
                     strerror(errno));
     ke->client_entry->ke = NULL;
@@ -180,7 +180,7 @@ SILC_TASK_CALLBACK(silc_client_process_key_agreement)
   /* Perform name and address lookups for the remote host. */
   silc_net_check_host_by_sock(sock, &newsocket->hostname, &newsocket->ip);
   if (!newsocket->hostname && !newsocket->ip) {
-    client->ops->say(client, conn, 
+    client->ops->say(client, conn, SILC_CLIENT_MESSAGE_AUDIT, 
                     "Could not resolve the remote IP or hostname");
     ke->client_entry->ke = NULL;
     ke->completion(ke->client, ke->conn, ke->client_entry, 
@@ -316,7 +316,7 @@ void silc_client_send_key_agreement(SilcClient client,
     ke->fd = silc_net_create_server(port, hostname);
 
     if (ke->fd < 0) {
-      client->ops->say(client, conn, 
+      client->ops->say(client, conn, SILC_CLIENT_MESSAGE_ERROR, 
                       "Cannot create listener on %s on port %d: %s", 
                       hostname, port, strerror(errno));
       completion(client, conn, client_entry, SILC_KEY_AGREEMENT_FAILURE,
@@ -428,9 +428,10 @@ SILC_TASK_CALLBACK(silc_client_perform_key_agreement_start)
   if (opt != 0) {
     if (ctx->tries < 2) {
       /* Connection failed but lets try again */
-      client->ops->say(client, conn, "Could not connect to client %s: %s",
+      client->ops->say(client, conn, SILC_CLIENT_MESSAGE_ERROR,
+                      "Could not connect to client %s: %s",
                       ctx->host, strerror(opt));
-      client->ops->say(client, conn, 
+      client->ops->say(client, conn, SILC_CLIENT_MESSAGE_AUDIT, 
                       "Connecting to port %d of client %s resumed", 
                       ctx->port, ctx->host);
 
@@ -444,7 +445,8 @@ SILC_TASK_CALLBACK(silc_client_perform_key_agreement_start)
       ctx->tries++;
     } else {
       /* Connection failed and we won't try anymore */
-      client->ops->say(client, conn, "Could not connect to client %s: %s",
+      client->ops->say(client, conn, SILC_CLIENT_MESSAGE_ERROR,
+                      "Could not connect to client %s: %s",
                       ctx->host, strerror(opt));
       silc_schedule_unset_listen_fd(client->schedule, fd);
       silc_net_close_connection(fd);
index 5b465df210a454534a44321317b590b5fa2ab31d..d0695efdf7d4d40af6caec0f16281a6c08be4035 100644 (file)
@@ -242,7 +242,7 @@ static void silc_client_private_message_key_cb(SilcClient client,
     goto out;
 
   /* Print some info for application */
-  client->ops->say(client, conn, 
+  client->ops->say(client, conn, SILC_CLIENT_MESSAGE_AUDIT, 
                   "Received private message key from %s%s%s %s%s%s", 
                   clients[0]->nickname,
                   clients[0]->server ? "@" : "",
index da2e7b7de8df58188d7d00531b9bb3a8917b5d1f..ce57cdbad035f368a011eddba5c41a787b1bee2c 100644 (file)
@@ -63,7 +63,7 @@ SilcClientCommand silc_command_list[] =
 };
 
 #define SILC_NOT_CONNECTED(x, c) \
-  x->ops->say((x), (c), \
+  x->ops->say((x), (c), SILC_CLIENT_MESSAGE_ERROR, \
           "You are not connected to a server, use /SERVER to connect");
 
 /* Command operation that is called at the end of all commands. 
@@ -289,7 +289,7 @@ SILC_CLIENT_CMD_FUNC(whowas)
   }
 
   if (cmd->argc < 2 || cmd->argc > 3) {
-    cmd->client->ops->say(cmd->client, conn, 
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
             "Usage: /WHOWAS <nickname>[@<server>] [<count>]");
     COMMAND_ERROR;
     goto out;
@@ -330,7 +330,7 @@ SILC_CLIENT_CMD_FUNC(identify)
   }
 
   if (cmd->argc < 2 || cmd->argc > 3) {
-    cmd->client->ops->say(cmd->client, conn,
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO,
             "Usage: /IDENTIFY <nickname>[@<server>] [<count>]");
     COMMAND_ERROR;
     goto out;
@@ -371,7 +371,7 @@ SILC_CLIENT_CMD_FUNC(nick)
   }
 
   if (cmd->argc < 2) {
-    cmd->client->ops->say(cmd->client, conn, "Usage: /NICK <nickname>");
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "Usage: /NICK <nickname>");
     COMMAND_ERROR;
     goto out;
   }
@@ -382,11 +382,11 @@ SILC_CLIENT_CMD_FUNC(nick)
   /* Show current nickname */
   if (cmd->argc < 2) {
     if (cmd->conn) {
-      cmd->client->ops->say(cmd->client, conn, 
+      cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
                            "Your nickname is %s on server %s", 
                            conn->nickname, conn->remote_host);
     } else {
-      cmd->client->ops->say(cmd->client, conn, 
+      cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
                            "Your nickname is %s", conn->nickname);
     }
 
@@ -485,7 +485,7 @@ SILC_CLIENT_CMD_FUNC(topic)
   }
 
   if (cmd->argc < 2 || cmd->argc > 3) {
-    cmd->client->ops->say(cmd->client, conn,
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO,
                          "Usage: /TOPIC <channel> [<topic>]");
     COMMAND_ERROR;
     goto out;
@@ -493,7 +493,7 @@ SILC_CLIENT_CMD_FUNC(topic)
 
   if (cmd->argv[1][0] == '*') {
     if (!conn->current_channel) {
-      cmd->client->ops->say(cmd->client, conn, "You are not on any channel");
+      cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "You are not on any channel");
       COMMAND_ERROR;
       goto out;
     }
@@ -503,14 +503,14 @@ SILC_CLIENT_CMD_FUNC(topic)
   }
 
   if (!conn->current_channel) {
-    cmd->client->ops->say(cmd->client, conn, "You are not on that channel");
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "You are not on that channel");
     COMMAND_ERROR;
     goto out;
   }
 
   /* Get the Channel ID of the channel */
   if (!silc_idcache_find_by_name_one(conn->channel_cache, name, &id_cache)) {
-    cmd->client->ops->say(cmd->client, conn, "You are not on that channel");
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "You are not on that channel");
     COMMAND_ERROR;
     goto out;
   }
@@ -563,7 +563,7 @@ SILC_CLIENT_CMD_FUNC(invite)
   }
 
   if (cmd->argc < 2) {
-    cmd->client->ops->say(cmd->client, conn,
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO,
                   "Usage: /INVITE <channel> [<nickname>[@server>]"
                   "[+|-[<nickname>[@<server>[!<username>[@hostname>]]]]]");
     COMMAND_ERROR;
@@ -572,7 +572,7 @@ SILC_CLIENT_CMD_FUNC(invite)
 
   if (cmd->argv[1][0] == '*') {
     if (!conn->current_channel) {
-      cmd->client->ops->say(cmd->client, conn, "You are not on any channel");
+      cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "You are not on any channel");
       COMMAND_ERROR;
       goto out;
     }
@@ -583,7 +583,7 @@ SILC_CLIENT_CMD_FUNC(invite)
 
     channel = silc_client_get_channel(cmd->client, conn, name);
     if (!channel) {
-      cmd->client->ops->say(cmd->client, conn, "You are on that channel");
+      cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "You are on that channel");
       COMMAND_ERROR;
       goto out;
     }
@@ -593,7 +593,7 @@ SILC_CLIENT_CMD_FUNC(invite)
   if (cmd->argc == 3) {
     if (cmd->argv[2][0] != '+' && cmd->argv[2][0] != '-') {
       if (!silc_parse_nickname(cmd->argv[2], &nickname, &server, &num)) {
-       cmd->client->ops->say(cmd->client, conn, "Bad nickname");
+       cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "Bad nickname");
        COMMAND_ERROR;
        goto out;
       }
@@ -744,7 +744,7 @@ SILC_CLIENT_CMD_FUNC(kill)
   }
 
   if (cmd->argc < 2) {
-    cmd->client->ops->say(cmd->client, conn, 
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
                          "Usage: /KILL <nickname> [<comment>]");
     COMMAND_ERROR;
     goto out;
@@ -752,7 +752,7 @@ SILC_CLIENT_CMD_FUNC(kill)
 
   /* Parse the typed nickname. */
   if (!silc_parse_nickname(cmd->argv[1], &nickname, &server, &num)) {
-    cmd->client->ops->say(cmd->client, conn, "Bad nickname");
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "Bad nickname");
     COMMAND_ERROR;
     goto out;
   }
@@ -856,7 +856,6 @@ SILC_CLIENT_CMD_FUNC(ping)
   SilcBuffer buffer;
   void *id;
   int i;
-  char *name = NULL;
 
   if (!cmd->conn) {
     SILC_NOT_CONNECTED(cmd->client, cmd->conn);
@@ -936,7 +935,7 @@ SILC_CLIENT_CMD_FUNC(join)
   if (silc_idcache_find_by_name_one(conn->channel_cache, cmd->argv[1],
                                    &id_cache)) {
 #if 0
-    cmd->client->ops->say(cmd->client, conn, 
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
                          "You are talking to channel %s", cmd->argv[1]);
     conn->current_channel = (SilcChannelEntry)id_cache->context;
     cmd->client->screen->bottom_line->channel = cmd->argv[1];
@@ -995,7 +994,7 @@ SILC_CLIENT_CMD_FUNC(motd)
   }
 
   if (cmd->argc < 1 || cmd->argc > 2) {
-    cmd->client->ops->say(cmd->client, conn,
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO,
                          "Usage: /MOTD [<server>]");
     COMMAND_ERROR;
     goto out;
@@ -1040,7 +1039,7 @@ SILC_CLIENT_CMD_FUNC(umode)
   }
 
   if (cmd->argc < 2) {
-    cmd->client->ops->say(cmd->client, conn, 
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
                  "Usage: /UMODE +|-<modes>");
     COMMAND_ERROR;
     goto out;
@@ -1135,7 +1134,7 @@ SILC_CLIENT_CMD_FUNC(cmode)
   }
 
   if (cmd->argc < 3) {
-    cmd->client->ops->say(cmd->client, conn, 
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
                  "Usage: /CMODE <channel> +|-<modes> [{ <arguments>}]");
     COMMAND_ERROR;
     goto out;
@@ -1143,7 +1142,7 @@ SILC_CLIENT_CMD_FUNC(cmode)
 
   if (cmd->argv[1][0] == '*') {
     if (!conn->current_channel) {
-      cmd->client->ops->say(cmd->client, conn, "You are not on any channel");
+      cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "You are not on any channel");
       COMMAND_ERROR;
       goto out;
     }
@@ -1154,7 +1153,7 @@ SILC_CLIENT_CMD_FUNC(cmode)
 
     channel = silc_client_get_channel(cmd->client, conn, name);
     if (!channel) {
-      cmd->client->ops->say(cmd->client, conn, "You are on that channel");
+      cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "You are on that channel");
       COMMAND_ERROR;
       goto out;
     }
@@ -1212,7 +1211,7 @@ SILC_CLIENT_CMD_FUNC(cmode)
        mode |= SILC_CHANNEL_MODE_ULIMIT;
        type = 3;
        if (cmd->argc < 4) {
-         cmd->client->ops->say(cmd->client, conn, 
+         cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
               "Usage: /CMODE <channel> +|-<modes> [{ <arguments>}]");
          COMMAND_ERROR;
          goto out;
@@ -1230,7 +1229,7 @@ SILC_CLIENT_CMD_FUNC(cmode)
        mode |= SILC_CHANNEL_MODE_PASSPHRASE;
        type = 4;
        if (cmd->argc < 4) {
-         cmd->client->ops->say(cmd->client, conn, 
+         cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
               "Usage: /CMODE <channel> +|-<modes> [{ <arguments>}]");
          COMMAND_ERROR;
          goto out;
@@ -1246,7 +1245,7 @@ SILC_CLIENT_CMD_FUNC(cmode)
        mode |= SILC_CHANNEL_MODE_CIPHER;
        type = 5;
        if (cmd->argc < 4) {
-         cmd->client->ops->say(cmd->client, conn, 
+         cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
               "Usage: /CMODE <channel> +|-<modes> [{ <arguments>}]");
          COMMAND_ERROR;
          goto out;
@@ -1262,7 +1261,7 @@ SILC_CLIENT_CMD_FUNC(cmode)
        mode |= SILC_CHANNEL_MODE_HMAC;
        type = 6;
        if (cmd->argc < 4) {
-         cmd->client->ops->say(cmd->client, conn, 
+         cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
               "Usage: /CMODE <channel> +|-<modes> [{ <arguments>}]");
          COMMAND_ERROR;
          goto out;
@@ -1279,7 +1278,7 @@ SILC_CLIENT_CMD_FUNC(cmode)
        type = 7;
 
        if (cmd->argc < 4) {
-         cmd->client->ops->say(cmd->client, conn, 
+         cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
               "Usage: /CMODE <channel> +|-<modes> [{ <arguments>}]");
          COMMAND_ERROR;
          goto out;
@@ -1364,7 +1363,7 @@ SILC_CLIENT_CMD_FUNC(cumode)
   }
 
   if (cmd->argc < 4) {
-    cmd->client->ops->say(cmd->client, conn, 
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
                  "Usage: /CUMODE <channel> +|-<modes> <nickname>[@<server>]");
     COMMAND_ERROR;
     goto out;
@@ -1372,7 +1371,7 @@ SILC_CLIENT_CMD_FUNC(cumode)
 
   if (cmd->argv[1][0] == '*') {
     if (!conn->current_channel) {
-      cmd->client->ops->say(cmd->client, conn, "You are not on any channel");
+      cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "You are not on any channel");
       COMMAND_ERROR;
       goto out;
     }
@@ -1383,7 +1382,7 @@ SILC_CLIENT_CMD_FUNC(cumode)
 
     channel = silc_client_get_channel(cmd->client, conn, name);
     if (!channel) {
-      cmd->client->ops->say(cmd->client, conn, "You are on that channel");
+      cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "You are on that channel");
       COMMAND_ERROR;
       goto out;
     }
@@ -1391,7 +1390,7 @@ SILC_CLIENT_CMD_FUNC(cumode)
 
   /* Parse the typed nickname. */
   if (!silc_parse_nickname(cmd->argv[3], &nickname, &server, &num)) {
-    cmd->client->ops->say(cmd->client, conn, "Bad nickname");
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "Bad nickname");
     COMMAND_ERROR;
     goto out;
   }
@@ -1416,9 +1415,10 @@ SILC_CLIENT_CMD_FUNC(cumode)
     return;
   }
   
+  /* Get the current mode */
   while ((chu = silc_list_get(channel->clients)) != SILC_LIST_END) {
     if (chu->client == client_entry) {
-      chu->mode = mode;
+      mode = chu->mode;
       break;
     }
   }
@@ -1527,7 +1527,7 @@ SILC_CLIENT_CMD_FUNC(kick)
   }
 
   if (cmd->argc < 3) {
-    cmd->client->ops->say(cmd->client, conn, 
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
                          "Usage: /KICK <channel> <nickname> [<comment>]");
     COMMAND_ERROR;
     goto out;
@@ -1535,7 +1535,7 @@ SILC_CLIENT_CMD_FUNC(kick)
 
   if (cmd->argv[1][0] == '*') {
     if (!conn->current_channel) {
-      cmd->client->ops->say(cmd->client, conn, "You are not on any channel");
+      cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "You are not on any channel");
       COMMAND_ERROR;
       goto out;
     }
@@ -1545,14 +1545,14 @@ SILC_CLIENT_CMD_FUNC(kick)
   }
 
   if (!conn->current_channel) {
-    cmd->client->ops->say(cmd->client, conn, "You are not on that channel");
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "You are not on that channel");
     COMMAND_ERROR;
     goto out;
   }
 
   /* Get the Channel ID of the channel */
   if (!silc_idcache_find_by_name_one(conn->channel_cache, name, &id_cache)) {
-    cmd->client->ops->say(cmd->client, conn, "You are not on that channel");
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "You are not on that channel");
     COMMAND_ERROR;
     goto out;
   }
@@ -1561,7 +1561,7 @@ SILC_CLIENT_CMD_FUNC(kick)
 
   /* Parse the typed nickname. */
   if (!silc_parse_nickname(cmd->argv[2], &nickname, &server, &num)) {
-    cmd->client->ops->say(cmd->client, conn, "Bad nickname");
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "Bad nickname");
     COMMAND_ERROR;
     goto out;
   }
@@ -1570,7 +1570,7 @@ SILC_CLIENT_CMD_FUNC(kick)
   target = silc_idlist_get_client(cmd->client, conn, nickname, 
                                  server, num, FALSE);
   if (!target) {
-    cmd->client->ops->say(cmd->client, conn, "No such client: %s",
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "No such client: %s",
                          cmd->argv[2]);
     COMMAND_ERROR;
     goto out;
@@ -1652,7 +1652,7 @@ SILC_CLIENT_CMD_FUNC(oper)
   }
 
   if (cmd->argc < 2) {
-    cmd->client->ops->say(cmd->client, conn, 
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
                          "Usage: /OPER <username> [<public key>]");
     COMMAND_ERROR;
     goto out;
@@ -1729,7 +1729,7 @@ SILC_CLIENT_CMD_FUNC(silcoper)
   }
 
   if (cmd->argc < 2) {
-    cmd->client->ops->say(cmd->client, conn, 
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
                          "Usage: /SILCOPER <username> [<public key>]");
     COMMAND_ERROR;
     goto out;
@@ -1777,7 +1777,7 @@ SILC_CLIENT_CMD_FUNC(connect)
   }
 
   if (cmd->argc < 2) {
-    cmd->client->ops->say(cmd->client, conn, 
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
                          "Usage: /CONNECT <server> [<port>]");
     COMMAND_ERROR;
     goto out;
@@ -1826,7 +1826,7 @@ SILC_CLIENT_CMD_FUNC(ban)
   }
 
   if (cmd->argc < 2) {
-    cmd->client->ops->say(cmd->client, conn, 
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
                   "Usage: /BAN <channel> "
                   "[+|-[<nickname>[@<server>[!<username>[@hostname>]]]]]");
     COMMAND_ERROR;
@@ -1835,7 +1835,7 @@ SILC_CLIENT_CMD_FUNC(ban)
 
   if (cmd->argv[1][0] == '*') {
     if (!conn->current_channel) {
-      cmd->client->ops->say(cmd->client, conn, "You are not on any channel");
+      cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "You are not on any channel");
       COMMAND_ERROR;
       goto out;
     }
@@ -1846,7 +1846,7 @@ SILC_CLIENT_CMD_FUNC(ban)
 
     channel = silc_client_get_channel(cmd->client, conn, name);
     if (!channel) {
-      cmd->client->ops->say(cmd->client, conn, "You are on that channel");
+      cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "You are on that channel");
       COMMAND_ERROR;
       goto out;
     }
@@ -1902,7 +1902,7 @@ SILC_CLIENT_CMD_FUNC(close)
   }
 
   if (cmd->argc < 2) {
-    cmd->client->ops->say(cmd->client, conn, 
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
                          "Usage: /CLOSE <server> [<port>]");
     COMMAND_ERROR;
     goto out;
@@ -1974,14 +1974,14 @@ SILC_CLIENT_CMD_FUNC(leave)
   }
 
   if (cmd->argc != 2) {
-    cmd->client->ops->say(cmd->client, conn, "Usage: /LEAVE <channel>");
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "Usage: /LEAVE <channel>");
     COMMAND_ERROR;
     goto out;
   }
 
   if (cmd->argv[1][0] == '*') {
     if (!conn->current_channel) {
-      cmd->client->ops->say(cmd->client, conn, "You are not on any channel");
+      cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "You are not on any channel");
       COMMAND_ERROR;
       goto out;
     }
@@ -1992,7 +1992,7 @@ SILC_CLIENT_CMD_FUNC(leave)
 
   /* Get the Channel ID of the channel */
   if (!silc_idcache_find_by_name_one(conn->channel_cache, name, &id_cache)) {
-    cmd->client->ops->say(cmd->client, conn, "You are not on that channel");
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "You are not on that channel");
     COMMAND_ERROR;
     goto out;
   }
@@ -2044,14 +2044,14 @@ SILC_CLIENT_CMD_FUNC(users)
   }
 
   if (cmd->argc != 2) {
-    cmd->client->ops->say(cmd->client, conn, "Usage: /USERS <channel>");
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "Usage: /USERS <channel>");
     COMMAND_ERROR;
     goto out;
   }
 
   if (cmd->argv[1][0] == '*') {
     if (!conn->current_channel) {
-      cmd->client->ops->say(cmd->client, conn, "You are not on any channel");
+      cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "You are not on any channel");
       COMMAND_ERROR;
       goto out;
     }
@@ -2061,7 +2061,7 @@ SILC_CLIENT_CMD_FUNC(users)
   }
 
   if (!conn->current_channel) {
-    cmd->client->ops->say(cmd->client, conn, "You are not on that channel");
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, "You are not on that channel");
     COMMAND_ERROR;
     goto out;
   }
@@ -2069,7 +2069,7 @@ SILC_CLIENT_CMD_FUNC(users)
   /* Get the Channel ID of the channel */
   if (!silc_idcache_find_by_name_one(conn->channel_cache, name, &id_cache)) {
     /* XXX should resolve the channel ID; LIST command */
-    cmd->client->ops->say(cmd->client, conn, 
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
                          "You are not on that channel", name);
     COMMAND_ERROR;
     goto out;
@@ -2126,14 +2126,14 @@ SILC_CLIENT_CMD_FUNC(getkey)
   }
 
   if (cmd->argc < 2) {
-    client->ops->say(client, conn, "Usage: /GETKEY <nickname>");
+    client->ops->say(client, conn, SILC_CLIENT_MESSAGE_INFO, "Usage: /GETKEY <nickname>");
     COMMAND_ERROR;
     goto out;
   }
 
   /* Parse the typed nickname. */
   if (!silc_parse_nickname(cmd->argv[1], &nickname, &server, &num)) {
-    client->ops->say(client, conn, "Bad nickname");
+    client->ops->say(client, conn, SILC_CLIENT_MESSAGE_INFO, "Bad nickname");
     COMMAND_ERROR;
     goto out;
   }
index 8f2dff66a498e4ef0e3cfb1b554f4d5cf1156c8d..1fa5d5a5af24d1322cea95ce77391d1434dda3cf 100644 (file)
@@ -564,7 +564,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(nick)
 
   SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL));
   if (status != SILC_STATUS_OK) {
-    cmd->client->ops->say(cmd->client, conn, "Cannot set nickname: %s", 
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
+                         "Cannot set nickname: %s", 
             silc_client_command_status_message(status));
     COMMAND_REPLY_ERROR;
     goto out;
@@ -572,7 +573,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(nick)
 
   argc = silc_argument_get_arg_num(cmd->args);
   if (argc < 2 || argc > 2) {
-    cmd->client->ops->say(cmd->client, conn, 
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
                          "Cannot set nickname: bad reply to command");
     COMMAND_REPLY_ERROR;
     goto out;
@@ -657,7 +658,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(topic)
 
   SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL));
   if (status != SILC_STATUS_OK) {
-    cmd->client->ops->say(cmd->client, conn,
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
             "%s", silc_client_command_status_message(status));
     COMMAND_REPLY_ERROR;
     SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_TOPIC);
@@ -722,7 +723,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(invite)
   tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
   SILC_GET16_MSB(status, tmp);
   if (status != SILC_STATUS_OK) {
-    cmd->client->ops->say(cmd->client, conn,
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
             "%s", silc_client_command_status_message(status));
     COMMAND_REPLY_ERROR;
     SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_INVITE);
@@ -775,7 +776,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(kill)
   tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
   SILC_GET16_MSB(status, tmp);
   if (status != SILC_STATUS_OK) {
-    cmd->client->ops->say(cmd->client, conn,
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
             "%s", silc_client_command_status_message(status));
     COMMAND_REPLY_ERROR;
     goto out;
@@ -806,7 +807,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(info)
   tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
   SILC_GET16_MSB(status, tmp);
   if (status != SILC_STATUS_OK) {
-    cmd->client->ops->say(cmd->client, conn,
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
             "%s", silc_client_command_status_message(status));
     COMMAND_REPLY_ERROR;
     SILC_CLIENT_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_INFO);
@@ -831,7 +832,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(info)
   if (!tmp)
     goto out;
 
-  client->ops->say(cmd->client, conn, "Info: %s", tmp);
+  client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
+                  "Info: %s", tmp);
 
   /* Notify application */
   COMMAND_REPLY((ARGS, NULL, (char *)tmp));
@@ -857,7 +859,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(ping)
 
   SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL));
   if (status != SILC_STATUS_OK) {
-    cmd->client->ops->say(cmd->client, conn,
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
             "%s", silc_client_command_status_message(status));
     COMMAND_REPLY_ERROR;
     goto out;
@@ -874,7 +876,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(ping)
   for (i = 0; i < conn->ping_count; i++) {
     if (SILC_ID_SERVER_COMPARE(conn->ping[i].dest_id, id)) {
       diff = curtime - conn->ping[i].start_time;
-      cmd->client->ops->say(cmd->client, conn, 
+      cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
                            "Ping reply from %s: %d second%s", 
                            conn->ping[i].dest_name, diff, 
                            diff == 1 ? "" : "s");
@@ -921,7 +923,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(join)
 
   SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL));
   if (status != SILC_STATUS_OK) {
-    cmd->client->ops->say(cmd->client, conn,
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
             "%s", silc_client_command_status_message(status));
     COMMAND_REPLY_ERROR;
     goto out;
@@ -929,7 +931,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(join)
 
   argc = silc_argument_get_arg_num(cmd->args);
   if (argc < 7 || argc > 14) {
-    cmd->client->ops->say(cmd->client, conn,
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
             "Cannot join channel: Bad reply packet");
     COMMAND_REPLY_ERROR;
     goto out;
@@ -938,7 +940,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(join)
   /* Get channel name */
   tmp = silc_argument_get_arg_type(cmd->args, 2, NULL);
   if (!tmp) {
-    cmd->client->ops->say(cmd->client, conn, 
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
                          "Cannot join channel: Bad reply packet");
     COMMAND_REPLY_ERROR;
     goto out;
@@ -948,7 +950,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(join)
   /* Get Channel ID */
   tmp = silc_argument_get_arg_type(cmd->args, 3, &len);
   if (!tmp) {
-    cmd->client->ops->say(cmd->client, conn, 
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
                          "Cannot join channel: Bad reply packet");
     COMMAND_REPLY_ERROR;
     silc_free(channel_name);
@@ -988,7 +990,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(join)
   hmac = silc_argument_get_arg_type(cmd->args, 11, NULL);
   if (hmac) {
     if (!silc_hmac_alloc(hmac, NULL, &channel->hmac)) {
-      cmd->client->ops->say(cmd->client, conn, 
+      cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, 
                            "Cannot join channel: Unsupported HMAC `%s'",
                            hmac);
       COMMAND_REPLY_ERROR;
@@ -1109,7 +1111,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(motd)
   tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
   SILC_GET16_MSB(status, tmp);
   if (status != SILC_STATUS_OK) {
-    cmd->client->ops->say(cmd->client, conn,
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
             "%s", silc_client_command_status_message(status));
     COMMAND_REPLY_ERROR;
     return;
@@ -1139,7 +1141,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(motd)
        if (i == 2)
          line[0] = ' ';
        
-       cmd->client->ops->say(cmd->client, conn, "%s", line);
+       cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO,
+                             "%s", line);
        
        if (!strlen(cp))
          break;
@@ -1172,7 +1175,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(umode)
   tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
   SILC_GET16_MSB(status, tmp);
   if (status != SILC_STATUS_OK) {
-    cmd->client->ops->say(cmd->client, conn,
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
             "%s", silc_client_command_status_message(status));
     COMMAND_REPLY_ERROR;
     goto out;
@@ -1206,10 +1209,11 @@ SILC_CLIENT_CMD_REPLY_FUNC(cmode)
   SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
   SilcCommandStatus status;
   unsigned char *tmp;
+  uint32 mode;
 
   SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL));
   if (status != SILC_STATUS_OK) {
-    cmd->client->ops->say(cmd->client, conn,
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
             "%s", silc_client_command_status_message(status));
     COMMAND_REPLY_ERROR;
     goto out;
@@ -1222,8 +1226,10 @@ SILC_CLIENT_CMD_REPLY_FUNC(cmode)
     goto out;
   }
 
+  SILC_GET32_MSB(mode, tmp);
+
   /* Notify application */
-  COMMAND_REPLY((ARGS, tmp));
+  COMMAND_REPLY((ARGS, mode));
 
   /* Execute any pending command callbacks */
   SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_CMODE);
@@ -1243,11 +1249,11 @@ SILC_CLIENT_CMD_REPLY_FUNC(cumode)
   SilcIDCacheEntry id_cache = NULL;
   SilcClientID *client_id;
   unsigned char *tmp, *id;
-  uint32 len;
+  uint32 len, mode;
   
   SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL));
   if (status != SILC_STATUS_OK) {
-    cmd->client->ops->say(cmd->client, conn,
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
             "%s", silc_client_command_status_message(status));
     COMMAND_REPLY_ERROR;
     goto out;
@@ -1281,8 +1287,10 @@ SILC_CLIENT_CMD_REPLY_FUNC(cumode)
     goto out;
   }
 
+  SILC_GET32_MSB(mode, tmp);
+
   /* Notify application */
-  COMMAND_REPLY((ARGS, tmp, (SilcClientEntry)id_cache->context));
+  COMMAND_REPLY((ARGS, mode, (SilcClientEntry)id_cache->context));
   silc_free(client_id);
   
   /* Execute any pending command callbacks */
@@ -1303,7 +1311,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(kick)
   tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
   SILC_GET16_MSB(status, tmp);
   if (status != SILC_STATUS_OK) {
-    cmd->client->ops->say(cmd->client, conn,
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
             "%s", silc_client_command_status_message(status));
     COMMAND_REPLY_ERROR;
     goto out;
@@ -1330,7 +1338,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(silcoper)
   tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
   SILC_GET16_MSB(status, tmp);
   if (status != SILC_STATUS_OK) {
-    cmd->client->ops->say(cmd->client, conn,
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
             "%s", silc_client_command_status_message(status));
     COMMAND_REPLY_ERROR;
     goto out;
@@ -1357,7 +1365,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(oper)
   tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
   SILC_GET16_MSB(status, tmp);
   if (status != SILC_STATUS_OK) {
-    cmd->client->ops->say(cmd->client, conn,
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
             "%s", silc_client_command_status_message(status));
     COMMAND_REPLY_ERROR;
     goto out;
@@ -1384,7 +1392,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(connect)
   tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
   SILC_GET16_MSB(status, tmp);
   if (status != SILC_STATUS_OK) {
-    cmd->client->ops->say(cmd->client, conn,
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
             "%s", silc_client_command_status_message(status));
     COMMAND_REPLY_ERROR;
     goto out;
@@ -1415,7 +1423,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(ban)
   tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
   SILC_GET16_MSB(status, tmp);
   if (status != SILC_STATUS_OK) {
-    cmd->client->ops->say(cmd->client, conn,
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
             "%s", silc_client_command_status_message(status));
     COMMAND_REPLY_ERROR;
     goto out;
@@ -1464,7 +1472,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(close)
   tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
   SILC_GET16_MSB(status, tmp);
   if (status != SILC_STATUS_OK) {
-    cmd->client->ops->say(cmd->client, conn,
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
             "%s", silc_client_command_status_message(status));
     COMMAND_REPLY_ERROR;
     goto out;
@@ -1491,7 +1499,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(shutdown)
   tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
   SILC_GET16_MSB(status, tmp);
   if (status != SILC_STATUS_OK) {
-    cmd->client->ops->say(cmd->client, conn,
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
             "%s", silc_client_command_status_message(status));
     COMMAND_REPLY_ERROR;
     goto out;
@@ -1520,7 +1528,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(leave)
   tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
   SILC_GET16_MSB(status, tmp);
   if (status != SILC_STATUS_OK) {
-    cmd->client->ops->say(cmd->client, conn,
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
             "%s", silc_client_command_status_message(status));
     COMMAND_REPLY_ERROR;
     goto out;
@@ -1562,7 +1570,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(users)
   tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
   SILC_GET16_MSB(status, tmp);
   if (status != SILC_STATUS_OK) {
-    cmd->client->ops->say(cmd->client, conn,
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
             "%s", silc_client_command_status_message(status));
     COMMAND_REPLY_ERROR;
     goto out;
@@ -1741,7 +1749,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(getkey)
   tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
   SILC_GET16_MSB(status, tmp);
   if (status != SILC_STATUS_OK) {
-    cmd->client->ops->say(cmd->client, conn,
+    cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
             "%s", silc_client_command_status_message(status));
     COMMAND_REPLY_ERROR;
     goto out;
index 671b7797eba515c18c2072c8be08cee3f4a3e9fb..ea45f108a4582cf3a9a0d394cb5eecb43c5bacce 100644 (file)
@@ -517,6 +517,25 @@ void silc_client_get_client_by_id_resolve(SilcClient client,
                              (void *)i);
 }
 
+/* Removes client from the cache by the client entry. */
+
+bool silc_client_del_client(SilcClient client, SilcClientConnection conn,
+                           SilcClientEntry client_entry)
+{
+  return silc_idcache_del_by_context(conn->client_cache, client_entry);
+}
+
+/* Removes client from the cache by the client ID. */
+
+bool silc_client_del_client_by_id(SilcClient client, 
+                                 SilcClientConnection conn,
+                                 SilcClientID *client_id)
+{
+  return silc_idcache_del_by_id_ext(conn->client_cache, (void *)client_id, 
+                                   NULL, NULL, 
+                                   silc_hash_client_id_compare, NULL);
+}
+
 /* Finds entry for channel by the channel name. Returns the entry or NULL
    if the entry was not found. It is found only if the client is joined
    to the channel. */
index ff9ba038c227f5a362e6cf9f83131ed2b33ea1c3..a47927edf1f82921b2ab6b73dd3e81ae691333d8 100644 (file)
@@ -213,7 +213,7 @@ SilcSKEStatus silc_ske_check_version(SilcSKE ske, unsigned char *version,
     status = SILC_SKE_STATUS_BAD_VERSION;
 
   if (status != SILC_SKE_STATUS_OK)
-    client->ops->say(client, conn, 
+    client->ops->say(client, conn, SILC_CLIENT_MESSAGE_AUDIT,
                     "We don't support server version `%s'", version);
 
   return status;
@@ -239,15 +239,15 @@ static void silc_client_protocol_ke_continue(SilcSKE ske,
 
   if (ske->status != SILC_SKE_STATUS_OK) {
     if (ske->status == SILC_SKE_STATUS_UNSUPPORTED_PUBLIC_KEY) {
-      client->ops->say(client, conn, 
+      client->ops->say(client, conn, SILC_CLIENT_MESSAGE_AUDIT, 
                       "Received unsupported server %s public key",
                       ctx->sock->hostname);
     } else if (ske->status == SILC_SKE_STATUS_PUBLIC_KEY_NOT_PROVIDED) {
-      client->ops->say(client, conn, 
+      client->ops->say(client, conn, SILC_CLIENT_MESSAGE_AUDIT,
                       "Remote host did not send its public key, even though "
                       "it must send it");
     } else {
-      client->ops->say(client, conn,
+      client->ops->say(client, conn, SILC_CLIENT_MESSAGE_ERROR,
                       "Error during key exchange protocol with server %s",
                       ctx->sock->hostname);
     }
@@ -455,11 +455,11 @@ SILC_TASK_CALLBACK(silc_client_protocol_key_exchange)
 
       if (status != SILC_SKE_STATUS_OK) {
         if (status == SILC_SKE_STATUS_UNSUPPORTED_PUBLIC_KEY) {
-          client->ops->say(client, conn, 
+          client->ops->say(client, conn, SILC_CLIENT_MESSAGE_AUDIT, 
                           "Received unsupported server %s public key",
                           ctx->sock->hostname);
         } else {
-          client->ops->say(client, conn,
+          client->ops->say(client, conn, SILC_CLIENT_MESSAGE_AUDIT,
                           "Error during key exchange protocol with server %s",
                           ctx->sock->hostname);
         }
@@ -675,7 +675,7 @@ SILC_TASK_CALLBACK(silc_client_protocol_connection_auth)
          break;
        }
 
-       client->ops->say(client, conn, 
+       client->ops->say(client, conn, SILC_CLIENT_MESSAGE_INFO,
                         "Password authentication required by server %s",
                         ctx->sock->hostname);
        client->ops->ask_passphrase(client, conn,
index 45506527d2eb43095eee4eb4cdace19246b7c9f6..9fa67c98ff2e242424ad23c37a1fa5ee8e001f5e 100644 (file)
@@ -166,6 +166,27 @@ typedef void (*SilcAskPassphrase)(unsigned char *passphrase,
  ***/
 typedef void (*SilcVerifyPublicKey)(bool success, void *context);
 
+/****d* silcclient/SilcClientAPI/SilcClientMessageType
+ *
+ * NAME
+ *
+ *    typedef enum { ... } SilcClientMessageType;
+ *
+ * DESCRIPTION
+ *
+ *    Different message types for `say' client operation.  The application
+ *    may filter the message sent by the library according this type.
+ *
+ * SOURCE
+ */
+typedef enum {
+  SILC_CLIENT_MESSAGE_INFO,           /* Informational */
+  SILC_CLIENT_MESSAGE_WARNING,        /* Warning */
+  SILC_CLIENT_MESSAGE_ERROR,          /* Error */
+  SILC_CLIENT_MESSAGE_AUDIT,          /* Auditable */
+} SilcClientMessageType;
+/***/
+
 /****s* silcclient/SilcClientAPI/SilcClientOperations
  *
  * NAME
@@ -183,8 +204,12 @@ typedef void (*SilcVerifyPublicKey)(bool success, void *context);
  */
 typedef struct {
   /* Message sent to the application by library. `conn' associates the
-     message to a specific connection.  `conn', however, may be NULL. */
-  void (*say)(SilcClient client, SilcClientConnection conn, char *msg, ...);
+     message to a specific connection.  `conn', however, may be NULL. 
+     The `type' indicates the type of the message sent by the library.
+     The applicationi can for example filter the message according the
+     type. */
+  void (*say)(SilcClient client, SilcClientConnection conn, 
+             SilcClientMessageType type, char *msg, ...);
 
   /* Message for a channel. The `sender' is the sender of the message 
      The `channel' is the channel. */
@@ -750,6 +775,40 @@ void silc_client_get_client_by_id_resolve(SilcClient client,
                                          SilcGetClientCallback completion,
                                          void *context);
 
+/****f* silcclient/SilcClientAPI/silc_client_del_client
+ *
+ * SYNOPSIS
+ *
+ *    bool silc_client_del_client(SilcClient client, SilcClientConnection conn,
+ *                                SilcClientEntry client_entry)
+ *
+ * DESCRIPTION
+ *
+ *    Removes client from local cache by the client entry indicated by
+ *    the `client_entry'.  Returns TRUE if the deletion were successful.
+ *
+ ***/
+bool silc_client_del_client(SilcClient client, SilcClientConnection conn,
+                           SilcClientEntry client_entry);
+
+/****f* silcclient/SilcClientAPI/silc_client_del_client_by_id
+ *
+ * SYNOPSIS
+ *
+ *    bool silc_client_del_client_by_id(SilcClient client, 
+ *                                      SilcClientConnection conn,
+ *                                      SilcClientID *client_id);
+ *
+ * DESCRIPTION
+ *
+ *    Removes client from local cache by the Client ID indicated by
+ *    the `Client ID'.  Returns TRUE if the deletion were successful.
+ *
+ ***/
+bool silc_client_del_client_by_id(SilcClient client, 
+                                 SilcClientConnection conn,
+                                 SilcClientID *client_id);
+
 /****f* silcclient/SilcClientAPI/silc_client_get_channel
  *
  * SYNOPSIS