From af6a141a3e8147538523665c54ccb58389c032ae Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Thu, 15 Feb 2007 17:51:27 +0000 Subject: [PATCH] Fixed WATCH notify handling. --- CHANGES | 3 +++ TODO | 8 ++++++-- lib/doc/notifyargs.html | 4 +++- lib/silcclient/client_connect.c | 11 ++++++----- lib/silcclient/client_notify.c | 18 +++++------------- lib/silcclient/client_register.c | 24 +++++------------------- lib/silcclient/command.c | 32 ++++++++++++++++++++++++++++++++ lib/silcclient/command.h | 12 ++++++++++++ 8 files changed, 72 insertions(+), 40 deletions(-) diff --git a/CHANGES b/CHANGES index 6f446df9..94d2deed 100644 --- a/CHANGES +++ b/CHANGES @@ -5,6 +5,9 @@ Thu Feb 15 16:50:34 EET 2007 Pekka Riikonen 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 * Fixed packet wrapper stream API to support encoder/decoder diff --git a/TODO b/TODO index 8f748cfe..79e67d8f 100644 --- 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**** ======================== diff --git a/lib/doc/notifyargs.html b/lib/doc/notifyargs.html index 1751f47a..1844ceb8 100644 --- a/lib/doc/notifyargs.html +++ b/lib/doc/notifyargs.html @@ -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. SilcClientEntry watched_client, char *new_nickname, SilcUInt32 user_mode, SilcNotifyType notification, SilcPublicKey diff --git a/lib/silcclient/client_connect.c b/lib/silcclient/client_connect.c index bb3d74e8..f160fb02 100644 --- a/lib/silcclient/client_connect.c +++ b/lib/silcclient/client_connect.c @@ -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; diff --git a/lib/silcclient/client_notify.c b/lib/silcclient/client_notify.c index f9a8b131..be982311 100644 --- a/lib/silcclient/client_notify.c +++ b/lib/silcclient/client_notify.c @@ -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); } diff --git a/lib/silcclient/client_register.c b/lib/silcclient/client_register.c index 88726f5e..a2380c80 100644 --- a/lib/silcclient/client_register.c +++ b/lib/silcclient/client_register.c @@ -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)); diff --git a/lib/silcclient/command.c b/lib/silcclient/command.c index a5ba076e..080962a2 100644 --- a/lib/silcclient/command.c +++ b/lib/silcclient/command.c @@ -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-> diff --git a/lib/silcclient/command.h b/lib/silcclient/command.h index ef535b92..4937e746 100644 --- a/lib/silcclient/command.h +++ b/lib/silcclient/command.h @@ -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 */ -- 2.24.0