Watcher list support added.
[silc.git] / lib / silcclient / command_reply.h
index 63a09e0c0f47e6e40c329444b47dc8081ab99be4..9811e1c9ae5679be8739c2f50cee7b9dc559ec8f 100644 (file)
@@ -26,42 +26,62 @@ typedef struct {
   SilcCommand cmd;
 } SilcClientCommandReply;
 
+/* Context holding pending command callbacks. */
+typedef struct {
+  SilcCommandCb callback;
+  void *context;
+} *SilcClientCommandPendingCallbacks;
+
 /* Context sent as argument to all command reply functions */
 struct SilcClientCommandReplyContextStruct {
   SilcClient client;
   SilcSocketConnection sock;
   SilcCommandPayload payload;
+  SilcStatus status;
+  SilcStatus error;
   SilcArgumentPayload args;
   SilcPacketContext *packet;
 
   /* If defined this executes the pending command. */
-  SilcCommandCb callback;
-  void *context;
-  uint16 ident;
+  SilcClientCommandPendingCallbacks callbacks;
+  SilcUInt32 callbacks_count;
+  SilcUInt16 ident;
 };
 
 /* Macros */
 
+/* Command reply operation that is called at the end of all command replys. 
+   Usage: COMMAND_REPLY((ARGS, argument1, argument2, etc...)), */
+#define COMMAND_REPLY(args) cmd->client->internal->ops->command_reply args
+#define ARGS cmd->client, cmd->sock->user_data,                                \
+             cmd->payload, TRUE, silc_command_get(cmd->payload), cmd->status
+
+/* Error reply to application. Usage: COMMAND_REPLY_ERROR; */
+#define COMMAND_REPLY_ERROR cmd->client->internal->ops->               \
+  command_reply(cmd->client, cmd->sock->user_data, cmd->payload,       \
+  FALSE, silc_command_get(cmd->payload), cmd->status)
+
 /* Macro used to declare command reply functions */
 #define SILC_CLIENT_CMD_REPLY_FUNC(func)                               \
 void silc_client_command_reply_##func(void *context, void *context2)
 
 /* Status message structure. Messages are defined below. */
 typedef struct {
-  SilcCommandStatus status;
+  SilcStatus status;
   char *message;
-} SilcCommandStatusMessage;
+} SilcStatusMessage;
 
 /* Status messages returned by the server */
 #define STAT(x) SILC_STATUS_ERR_##x
-DLLAPI extern const SilcCommandStatusMessage silc_command_status_messages[];
+DLLAPI extern const SilcStatusMessage silc_command_status_messages[];
 
 /* Prototypes */
 
+char *silc_client_status_message(SilcStatus status);
 void silc_client_command_reply_process(SilcClient client,
                                       SilcSocketConnection sock,
                                       SilcPacketContext *packet);
-char *silc_client_command_status_message(SilcCommandStatus status);
+void silc_client_command_reply_free(SilcClientCommandReplyContext cmd);
 SILC_CLIENT_CMD_REPLY_FUNC(whois);
 SILC_CLIENT_CMD_REPLY_FUNC(whowas);
 SILC_CLIENT_CMD_REPLY_FUNC(identify);
@@ -71,12 +91,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(topic);
 SILC_CLIENT_CMD_REPLY_FUNC(invite);
 SILC_CLIENT_CMD_REPLY_FUNC(kill);
 SILC_CLIENT_CMD_REPLY_FUNC(info);
-SILC_CLIENT_CMD_REPLY_FUNC(links);
 SILC_CLIENT_CMD_REPLY_FUNC(stats);
-SILC_CLIENT_CMD_REPLY_FUNC(users);
-SILC_CLIENT_CMD_REPLY_FUNC(connect);
 SILC_CLIENT_CMD_REPLY_FUNC(ping);
-SILC_CLIENT_CMD_REPLY_FUNC(pong);
 SILC_CLIENT_CMD_REPLY_FUNC(oper);
 SILC_CLIENT_CMD_REPLY_FUNC(join);
 SILC_CLIENT_CMD_REPLY_FUNC(motd);
@@ -85,8 +101,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(cmode);
 SILC_CLIENT_CMD_REPLY_FUNC(cumode);
 SILC_CLIENT_CMD_REPLY_FUNC(kick);
 SILC_CLIENT_CMD_REPLY_FUNC(ban);
-SILC_CLIENT_CMD_REPLY_FUNC(close);
-SILC_CLIENT_CMD_REPLY_FUNC(shutdown);
+SILC_CLIENT_CMD_REPLY_FUNC(detach);
+SILC_CLIENT_CMD_REPLY_FUNC(watch);
 SILC_CLIENT_CMD_REPLY_FUNC(silcoper);
 SILC_CLIENT_CMD_REPLY_FUNC(leave);
 SILC_CLIENT_CMD_REPLY_FUNC(users);
@@ -97,5 +113,10 @@ SILC_CLIENT_CMD_REPLY_FUNC(quit);
 SILC_CLIENT_CMD_REPLY_FUNC(whois_i);
 SILC_CLIENT_CMD_REPLY_FUNC(identify_i);
 SILC_CLIENT_CMD_REPLY_FUNC(info_i);
+SILC_CLIENT_CMD_REPLY_FUNC(users_i);
+
+SILC_CLIENT_CMD_REPLY_FUNC(connect);
+SILC_CLIENT_CMD_REPLY_FUNC(close);
+SILC_CLIENT_CMD_REPLY_FUNC(shutdown);
 
 #endif