From dd751dd05c70719dc51f87eda1a9bb52ce7cd25b Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Fri, 29 Sep 2000 07:10:32 +0000 Subject: [PATCH] Added support for notify client operation. --- apps/silc/client_ops.c | 11 +++++++++++ lib/silcclient/README | 1 + lib/silcclient/client.c | 8 ++++++-- lib/silcclient/ops.h | 9 +++++++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/apps/silc/client_ops.c b/apps/silc/client_ops.c index 3a08a798..0dd9d1ef 100644 --- a/apps/silc/client_ops.c +++ b/apps/silc/client_ops.c @@ -64,6 +64,16 @@ void silc_private_message(SilcClient client, SilcClientConnection conn, silc_print(client, "*%s* %s", sender, msg); } + +/* Notify message to the client. The `type' is the notify type received + from server. The `msg' is a human readable message sent by the server. */ + +void silc_notify(SilcClient client, SilcClientConnection conn, + SilcNotifyType type, char *msg) +{ + silc_print(client, "*** %s", msg); +} + /* Command handler. This function is called always in the command function. If error occurs it will be called as well. `conn' is the associated client connection. `cmd_context' is the command context that was @@ -401,6 +411,7 @@ SilcClientOperations ops = { say: silc_say, channel_message: silc_channel_message, private_message: silc_private_message, + notify: silc_notify, command: silc_command, command_reply: silc_command_reply, connect: silc_connect, diff --git a/lib/silcclient/README b/lib/silcclient/README index 26eb3858..60af009c 100644 --- a/lib/silcclient/README +++ b/lib/silcclient/README @@ -46,6 +46,7 @@ SilcClientOperations ops = { say: silc_say, channel_message: silc_channel_message, private_message: silc_private_message, + notify: silc_notify, command: silc_command, command_reply: silc_command_reply, connect: silc_connect, diff --git a/lib/silcclient/client.c b/lib/silcclient/client.c index 66961bf8..f4a2b795 100644 --- a/lib/silcclient/client.c +++ b/lib/silcclient/client.c @@ -1246,10 +1246,14 @@ void silc_client_notify_by_server(SilcClient client, SilcBuffer message) { char *msg; + SilcNotifyType type; + + SILC_GET16_MSB(type, message->data); + silc_buffer_pull(message, 2); msg = silc_calloc(message->len + 1, sizeof(char)); memcpy(msg, message->data, message->len); - client->ops->say(client, sock->user_data, msg); + client->ops->notify(client, sock->user_data, type, msg); silc_free(msg); } @@ -1395,7 +1399,7 @@ void silc_client_channel_message(SilcClient client, id = silc_id_str2id(packet->dst_id, SILC_ID_CHANNEL); - /* Find the channel entry from channels on this window */ + /* Find the channel entry from channels on this connection */ if (!silc_idcache_find_by_id_one(conn->channel_cache, (void *)id, SILC_ID_CHANNEL, &id_cache)) goto out; diff --git a/lib/silcclient/ops.h b/lib/silcclient/ops.h index 49d3b8c4..69eb54e5 100644 --- a/lib/silcclient/ops.h +++ b/lib/silcclient/ops.h @@ -37,6 +37,8 @@ typedef struct { char *sender, char *channel_name, char *msg); void (*private_message)(SilcClient client, SilcClientConnection conn, char *sender, char *msg); + void (*notify)(SilcClient client, SilcClientConnection conn, + SilcNotifyType type, char *msg); void (*command)(SilcClient client, SilcClientConnection conn, SilcClientCommandContext cmd_context, int success, SilcCommand command); @@ -80,6 +82,13 @@ typedef struct { sender received in the packet. + void (*notify)(SilcClient client, SilcClientConnection conn, + SilcNotifyType type, char *msg); + + Notify message to the client. The `type' is the notify type received + from server. The `msg' is a human readable message sent by the server. + + void (*command)(SilcClient client, SilcClientConnection conn, SilcClientCommandContext cmd_context, int success, SilcCommand command); -- 2.43.0