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) {
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;
/* 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);
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;
}
/* 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
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
* 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,