Fixed WATCH notify handling.
authorPekka Riikonen <priikone@silcnet.org>
Thu, 15 Feb 2007 17:51:27 +0000 (17:51 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Thu, 15 Feb 2007 17:51:27 +0000 (17:51 +0000)
CHANGES
TODO
lib/doc/notifyargs.html
lib/silcclient/client_connect.c
lib/silcclient/client_notify.c
lib/silcclient/client_register.c
lib/silcclient/command.c
lib/silcclient/command.h

diff --git a/CHANGES b/CHANGES
index 6f446df9eee81b6ede5bbe4f28d454f2a007507f..94d2deed63d14134084d78816745bce7ee01d0c7 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,9 @@ Thu Feb 15 16:50:34 EET 2007  Pekka Riikonen <priikone@silcnet.org>
          can do partial reads to different buffers.  Affected file is
          lib/silccore/silcpacket.c.
 
+       * Fixed WATCH notify handling in client library.  Affected file
+         is lib/silcclient/client_notify.c.
+
 Wed Feb 14 17:05:38 EET 2007  Pekka Riikonen <priikone@silcnet.org>
 
        * Fixed packet wrapper stream API to support encoder/decoder
diff --git a/TODO b/TODO
index 8f748cfe679f53ee85094c899884ec6e279ad81d..79e67d8ff4717dd8185083fc9c2676150b444bc6 100644 (file)
--- a/TODO
+++ b/TODO
@@ -40,7 +40,7 @@ lib/silcclient, The Client Library    ***PARTLY DONE****
 
  o Remove protocol.[ch]. (***DONE)
 
- o File transfer rewrite. (***TESTING NEEDED)
+ o File transfer rewrite. (***DONE)
 
  o File transfer API documentation.
 
@@ -51,7 +51,7 @@ lib/silcclient, The Client Library    ***PARTLY DONE****
  o Starting key exchange directly, rewrite. (***DONE)
 
  o Channel messages, channel private keys, channel entires, channel
-   search, etc. rewrite.
+   search, etc. rewrite. (***TESTING NEEDED */
 
  o For many APIs leave the hash context allocations to the caller instead
    of using client->sha1hash and client->md5hash, or some kind of thread
@@ -75,6 +75,8 @@ lib/silcclient, The Client Library    ***PARTLY DONE****
 
  o UDP connections. (***TESTING NEEDED)
 
+ o Message ACKing.
+
  o in /cmode and /cumode with +r, maybe the public key and private key
    could be just some "string", which would then match to "string.pub" and
    "string.prv".
@@ -105,6 +107,8 @@ lib/silccore/silcpacket.[ch]        ****PARTLY DONE****
 
  o IV Included flag support, UDP transport support (***TESTING NEEDED)
 
+ o SILC_PACKET_FLAG_ACK support.
+
 
 lib/silccore/silcid.[ch]       ****DONE****
 ========================
index 1751f47ad261b7525fc9e31d10a440d6dc98711a..1844ceb8d5bd7b4e9f0dee53976477a4c56c9cca 100644 (file)
@@ -264,7 +264,9 @@ client just changed nickname the 'new_nickname' includes the new nickname.
 Otherwise this pointer is NULL.  The 'user_mode' is the client's mode in
 the SILC network.  The 'notification' contains the notify type that
 happened for the 'watched_client' (for example
-SILC_NOTIFY_TYPE_NICK_CHANGE if the client changed their nickname).
+SILC_NOTIFY_TYPE_NICK_CHANGE if the client changed their nickname).  If
+the `new_nickname' is NULL and `notification' is SILC_NOTIFY_TYPE_NONE the
+`watched_client' has just joined the network.
 </td>
 <td width="50%"><small>SilcClientEntry watched_client, char *new_nickname,
 SilcUInt32 user_mode, SilcNotifyType notification, SilcPublicKey
index bb3d74e84ad8a4e1a767bf93b6bd08d541f372c6..f160fb027b9048fba47bd10ff5d6095cacf1c9c2 100644 (file)
@@ -267,7 +267,7 @@ static void silc_client_rekey_completion(SilcSKE ske,
   silc_ske_free_rekey_material(conn->internal->rekey);
   conn->internal->rekey = rekey;
 
-  SILC_LOG_DEBUG(("Rekey completed"));
+  SILC_LOG_DEBUG(("Rekey completed conn %p", conn));
 
   /* Rekey done */
   silc_fsm_finish(fsm);
@@ -674,9 +674,10 @@ SILC_FSM_STATE(silc_client_st_connected)
   SILC_LOG_DEBUG(("Connection established"));
 
   /* Install rekey timer */
-  silc_schedule_task_add_timeout(conn->internal->schedule,
-                                silc_client_rekey_timer, conn,
-                                conn->internal->params.rekey_secs, 0);
+  if (conn->type != SILC_CONN_CLIENT)
+    silc_schedule_task_add_timeout(conn->internal->schedule,
+                                  silc_client_rekey_timer, conn,
+                                  conn->internal->params.rekey_secs, 0);
 
   /* If we connected to server, now register to network. */
   if (conn->type == SILC_CONN_SERVER &&
@@ -756,7 +757,7 @@ SILC_FSM_STATE(silc_client_st_rekey)
   SilcClientConnection conn = fsm_context;
   SilcClient client = conn->client;
 
-  SILC_LOG_DEBUG(("Rekey"));
+  SILC_LOG_DEBUG(("Rekey conn %p", conn));
 
   if (conn->internal->disconnected)
     return SILC_FSM_FINISH;
index f9a8b131769b90cdb86420283a5e95cd0ac31ef7..be982311a734406dc690bba0b1e302cfbe3fccf7 100644 (file)
@@ -1519,7 +1519,6 @@ SILC_FSM_STATE(silc_client_notify_watch)
   SilcArgumentPayload args = silc_notify_get_args(payload);
   SilcClientEntry client_entry = NULL;
   SilcNotifyType ntype = 0;
-  SilcBool del_client = FALSE;
   unsigned char *pk, *tmp;
   SilcUInt32 mode, pk_len, tmp_len;
   SilcPublicKey public_key = NULL;
@@ -1587,19 +1586,12 @@ SILC_FSM_STATE(silc_client_notify_watch)
 
   client_entry->mode = mode;
 
-  /* If nickname was changed, remove the client entry unless the
-     client is on some channel */
-  /* XXX, why do we need to remove the client entry?? */
-  if (tmp && ntype == SILC_NOTIFY_TYPE_NICK_CHANGE &&
-      !silc_hash_table_count(client_entry->channels))
-    del_client = TRUE;
-  else if (ntype == SILC_NOTIFY_TYPE_SIGNOFF ||
-          ntype == SILC_NOTIFY_TYPE_SERVER_SIGNOFF ||
-          ntype == SILC_NOTIFY_TYPE_KILLED)
-    del_client = TRUE;
-
-  if (del_client) {
+  /* Remove client that left the network. */
+  if (ntype == SILC_NOTIFY_TYPE_SIGNOFF ||
+      ntype == SILC_NOTIFY_TYPE_SERVER_SIGNOFF ||
+      ntype == SILC_NOTIFY_TYPE_KILLED) {
     silc_client_remove_from_channels(client, conn, client_entry);
+    client_entry->internal.valid = FALSE;
     silc_client_del_client(client, conn, client_entry);
   }
 
index 88726f5ea2f6961a4cb03ad63b065a2e089db9e4..a2380c80b5eee189fb7b59666d4804a2bdd92be0 100644 (file)
@@ -34,20 +34,6 @@ typedef struct {
 
 /************************ Static utility functions **************************/
 
-/* Command callback.  Nothing interesting to do here. */
-
-static SilcBool
-silc_client_register_command_called(SilcClient client,
-                                   SilcClientConnection conn,
-                                   SilcCommand command,
-                                   SilcStatus status,
-                                   SilcStatus error,
-                                   void *context,
-                                   va_list ap)
-{
-  return FALSE;
-}
-
 /* Continues resuming after resolving.  Continue after last reply. */
 
 static SilcBool
@@ -225,7 +211,7 @@ SILC_FSM_STATE(silc_client_st_register_complete)
   /* Issue IDENTIFY command for itself to get resolved hostname
      correctly from server. */
   silc_client_command_send(client, conn, SILC_COMMAND_IDENTIFY,
-                          silc_client_register_command_called, NULL,
+                          silc_client_command_called_dummy, NULL,
                           1, 5, silc_buffer_data(conn->internal->local_idp),
                           silc_buffer_len(conn->internal->local_idp));
 
@@ -239,7 +225,7 @@ SILC_FSM_STATE(silc_client_st_register_complete)
   /* Issue INFO command to fetch the real server name and server
      information and other stuff. */
   silc_client_command_send(client, conn, SILC_COMMAND_INFO,
-                          silc_client_register_command_called, NULL,
+                          silc_client_command_called_dummy, NULL,
                           1, 2, silc_buffer_data(conn->internal->remote_idp),
                           silc_buffer_len(conn->internal->remote_idp));
 
@@ -394,7 +380,7 @@ SILC_FSM_STATE(silc_client_st_resume_resolve_channels)
   /* Send UMODE command to get our own user mode in the network */
   SILC_LOG_DEBUG(("Resolving user mode"));
   silc_client_command_send(client, conn, SILC_COMMAND_UMODE,
-                          silc_client_register_command_called, NULL,
+                          silc_client_command_called_dummy, NULL,
                           1, 1, silc_buffer_data(conn->internal->local_idp),
                           silc_buffer_len(conn->internal->local_idp));
 
@@ -539,14 +525,14 @@ SILC_FSM_STATE(silc_client_st_resume_completed)
   /* Issue IDENTIFY command for itself to get resolved hostname
      correctly from server. */
   silc_client_command_send(client, conn, SILC_COMMAND_IDENTIFY,
-                          silc_client_register_command_called, NULL,
+                          silc_client_command_called_dummy, NULL,
                           1, 5, silc_buffer_data(conn->internal->local_idp),
                           silc_buffer_len(conn->internal->local_idp));
 
   /* Issue INFO command to fetch the real server name and server
      information and other stuff. */
   silc_client_command_send(client, conn, SILC_COMMAND_INFO,
-                          silc_client_register_command_called, NULL,
+                          silc_client_command_called_dummy, NULL,
                           1, 2, silc_buffer_data(conn->internal->remote_idp),
                           silc_buffer_len(conn->internal->remote_idp));
 
index a5ba076ec23cb79c7132c29ef04ed93576303cfa..080962a226b9ff62f9a155150ff1f3baca9af8d1 100644 (file)
@@ -123,6 +123,32 @@ static void silc_client_command_resolve_continue(SilcClient client,
   SILC_FSM_CALL_CONTINUE(&cmd->thread);
 }
 
+/* Dummy command callback.  Nothing interesting to do here.  Use this when
+   you just send command but don't care about reply. */
+
+SilcBool silc_client_command_called_dummy(SilcClient client,
+                                         SilcClientConnection conn,
+                                         SilcCommand command,
+                                         SilcStatus status,
+                                         SilcStatus error,
+                                         void *context,
+                                         va_list ap)
+{
+  return FALSE;
+}
+
+/* Dummy resolving callback.  Nothing interesting to do here.  Use this
+   when you just resolve entires but don't care about reply. */
+
+void silc_client_command_resolve_dummy(SilcClient client,
+                                      SilcClientConnection conn,
+                                      SilcStatus status,
+                                      SilcDList clients,
+                                      void *context)
+{
+  /* Nothing */
+}
+
 /* Register command to client */
 
 static SilcBool
@@ -2453,6 +2479,12 @@ SILC_FSM_STATE(silc_client_command_watch)
     silc_pkcs_public_key_free(pk);
   }
 
+  /* If watching by nickname, resolve all users with that nickname so that
+     we get their information immediately. */
+  if (type == 2)
+    silc_client_get_clients(conn->client, conn, cmd->argv[2], NULL,
+                           silc_client_command_resolve_dummy, NULL);
+
   /* Send the commmand */
   silc_client_command_send_va(conn, cmd, cmd->cmd, NULL, NULL, 2,
                              1, silc_buffer_datalen(conn->internal->
index ef535b9264cef2f80d5682dce66a8f89c01a6889..4937e746769f43eeb216ead932fddcd0f1d07abd 100644 (file)
@@ -59,5 +59,17 @@ SilcUInt16 silc_client_command_send_argv(SilcClient client,
                                         SilcUInt32 *argv_types);
 void silc_client_commands_register(SilcClient client);
 void silc_client_commands_unregister(SilcClient client);
+SilcBool silc_client_command_called_dummy(SilcClient client,
+                                         SilcClientConnection conn,
+                                         SilcCommand command,
+                                         SilcStatus status,
+                                         SilcStatus error,
+                                         void *context,
+                                         va_list ap);
+void silc_client_command_resolve_dummy(SilcClient client,
+                                      SilcClientConnection conn,
+                                      SilcStatus status,
+                                      SilcDList clients,
+                                      void *context);
 
 #endif /* COMMAND_H */