From: Pekka Riikonen Date: Sat, 21 Feb 2004 08:05:05 +0000 (+0000) Subject: The _CLOSED flag is called when calling silc_client_file_close. X-Git-Tag: silc.server.0.9.17~12 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=da637bc72fa4b710a89b8a9c158e9f6df0d6ae98 The _CLOSED flag is called when calling silc_client_file_close. Added silc_client_get_clients_whois using WHOIS command and supporting requested attributes. --- diff --git a/CHANGES b/CHANGES index fa7f18d3..e48d7389 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,13 @@ +Fri Feb 20 20:37:38 EET 2004 Pekka Riikonen + + * Call the monitor callback with _CLOSED status from the + silc_client_file_close. Affected files are + lib/silcclient/client_fpt.c, silcclient.h + + * Added silc_client_get_clients_whois which resolves using + WHOIS, and supports requested attributes as well. + Affected files are lib/silcclient/silcclient.h, idlist.c. + Fri Feb 19 21:09:22 EET 2004 Pekka Riikonen * Added support for asking the destination filename where diff --git a/apps/irssi/src/silc/core/silc-servers.c b/apps/irssi/src/silc/core/silc-servers.c index 37a0b9eb..9d5d661b 100644 --- a/apps/irssi/src/silc/core/silc-servers.c +++ b/apps/irssi/src/silc/core/silc-servers.c @@ -597,6 +597,9 @@ static void silc_client_file_monitor(SilcClient client, FtpSession ftp; char fsize[32]; + if (status == SILC_CLIENT_FILE_MONITOR_CLOSED) + return; + snprintf(fsize, sizeof(fsize) - 1, "%llu", ((filesize + 1023) / 1024)); silc_dlist_start(server->ftp_sessions); diff --git a/lib/silcclient/client_ftp.c b/lib/silcclient/client_ftp.c index 4806cf62..42b987ca 100644 --- a/lib/silcclient/client_ftp.c +++ b/lib/silcclient/client_ftp.c @@ -1060,9 +1060,8 @@ SilcClientFileError silc_client_file_close(SilcClient client, silc_dlist_start(conn->internal->ftp_sessions); while ((session = silc_dlist_get(conn->internal->ftp_sessions)) != SILC_LIST_END) { - if (session->session_id == session_id) { + if (session->session_id == session_id) break; - } } if (session == SILC_LIST_END) { @@ -1070,6 +1069,13 @@ SilcClientFileError silc_client_file_close(SilcClient client, return SILC_CLIENT_FILE_UNKNOWN_SESSION; } + if (session->monitor) + (*session->monitor)(session->client, session->conn, + SILC_CLIENT_FILE_MONITOR_CLOSED, + SILC_CLIENT_FILE_OK, 0, 0, + session->client_entry, session->session_id, + session->filepath, session->monitor_context); + silc_client_ftp_session_free(session); return SILC_CLIENT_FILE_OK; diff --git a/lib/silcclient/idlist.c b/lib/silcclient/idlist.c index 00a24a2e..38864297 100644 --- a/lib/silcclient/idlist.c +++ b/lib/silcclient/idlist.c @@ -132,7 +132,7 @@ SILC_CLIENT_CMD_FUNC(get_client_callback) /* Get the clients */ clients = silc_client_get_clients_local(i->client, i->conn, - i->nickname, i->server, + i->nickname, NULL, &clients_count); if (clients) { i->completion(i->client, i->conn, clients, clients_count, i->context); @@ -155,12 +155,14 @@ SILC_CLIENT_CMD_FUNC(get_client_callback) get the client entry since this function may be very slow and should be used only to initially get the client entries. */ -void silc_client_get_clients(SilcClient client, - SilcClientConnection conn, - const char *nickname, - const char *server, - SilcGetClientCallback completion, - void *context) +void silc_client_get_clients_i(SilcClient client, + SilcClientConnection conn, + SilcCommand command, + const char *nickname, + const char *server, + SilcBuffer attributes, + SilcGetClientCallback completion, + void *context) { GetClientInternal i; int len; @@ -190,23 +192,57 @@ void silc_client_get_clients(SilcClient client, } /* Register our own command reply for this command */ - silc_client_command_register(client, SILC_COMMAND_IDENTIFY, NULL, NULL, - silc_client_command_reply_identify_i, 0, - ++conn->cmd_ident); - - /* Send the command */ - silc_client_command_send(client, conn, SILC_COMMAND_IDENTIFY, - conn->cmd_ident, 1, 1, userhost, - strlen(userhost)); + if (command == SILC_COMMAND_IDENTIFY) { + silc_client_command_register(client, command, NULL, NULL, + silc_client_command_reply_identify_i, 0, + ++conn->cmd_ident); + /* Send the command */ + silc_client_command_send(client, conn, SILC_COMMAND_IDENTIFY, + conn->cmd_ident, 1, 1, userhost, + strlen(userhost)); + } else { + silc_client_command_register(client, command, NULL, NULL, + silc_client_command_reply_whois_i, 0, + ++conn->cmd_ident); + /* Send the command */ + silc_client_command_send(client, conn, command, conn->cmd_ident, 2, + 1, userhost, strlen(userhost), + 3, attributes ? attributes->data : NULL, + attributes ? attributes->len : 0); + } /* Add pending callback */ - silc_client_command_pending(conn, SILC_COMMAND_IDENTIFY, conn->cmd_ident, + silc_client_command_pending(conn, command, conn->cmd_ident, silc_client_command_get_client_callback, (void *)i); - silc_free(userhost); } +void silc_client_get_clients(SilcClient client, + SilcClientConnection conn, + const char *nickname, + const char *server, + SilcGetClientCallback completion, + void *context) +{ + silc_client_get_clients_i(client, conn, SILC_COMMAND_IDENTIFY, + nickname, server, NULL, + completion, context); +} + +void silc_client_get_clients_whois(SilcClient client, + SilcClientConnection conn, + const char *nickname, + const char *server, + SilcBuffer attributes, + SilcGetClientCallback completion, + void *context) +{ + silc_client_get_clients_i(client, conn, SILC_COMMAND_WHOIS, + nickname, server, attributes, + completion, context); +} + /* The old style function to find client entry. This is used by the library internally. If `query' is TRUE then the client information is requested by the server. The pending command callback must be set diff --git a/lib/silcclient/silcclient.h b/lib/silcclient/silcclient.h index b02b60f9..3f337ec9 100644 --- a/lib/silcclient/silcclient.h +++ b/lib/silcclient/silcclient.h @@ -1300,6 +1300,48 @@ void silc_client_get_clients(SilcClient client, SilcGetClientCallback completion, void *context); +/****f* silcclient/SilcClientAPI/silc_client_get_clients + * + * SYNOPSIS + * + * void silc_client_get_clients_whois(SilcClient client, + * SilcClientConnection conn, + * const char *nickname, + * const char *server, + * SilcBuffer attributes, + * SilcGetClientCallback completion, + * void *context); + * + * DESCRIPTION + * + * Finds client entry or entries by the `nickname' and `server'. The + * completion callback will be called when the client entries has been + * found. After the server returns the client information it is cached + * and can be accesses locally at a later time. The resolving is done + * with WHOIS command. The `server' may be NULL. + * + * If the `attributes' is non-NULL then the buffer includes Requested + * Attributes which can be used to fetch very detailed information + * about the user. If it is NULL then only normal WHOIS query is + * made (for more information about attributes see SilcAttribute). + * Caller may create the `attributes' with silc_client_attributes_request + * function. + * + * NOTES + * + * The resolving is done with WHOIS command. For this reason this + * command may take a long time because it resolves detailed user + * information. + * + ***/ +void silc_client_get_clients_whois(SilcClient client, + SilcClientConnection conn, + const char *nickname, + const char *server, + SilcBuffer attributes, + SilcGetClientCallback completion, + void *context); + /****f* silcclient/SilcClientAPI/silc_client_get_clients_local * * SYNOPSIS @@ -2618,7 +2660,10 @@ silc_client_file_receive(SilcClient client, * If file transmission is being conducted it will be aborted * automatically. This function is also used to close the session * after successful file transmission. This function can be used - * also to reject incoming file transmission request. + * also to reject incoming file transmission request. If the + * session was already started and the monitor callback was set + * the monitor callback will be called with the monitor status + * SILC_CLIENT_FILE_MONITOR_CLOSED. * ***/ SilcClientFileError silc_client_file_close(SilcClient client,