diff options
author | Tom Smeding <tom.smeding@gmail.com> | 2020-07-30 20:45:54 +0200 |
---|---|---|
committer | Tom Smeding <tom.smeding@gmail.com> | 2020-07-30 20:45:54 +0200 |
commit | 6244f4a65aa391cae85bfc6930589ba7feaa536e (patch) | |
tree | d73c2a136bcfd124e8051eb09268af8fedfdbd3b /ssh/client.c | |
parent | dd40033d6d6358da8d065db04b3bfbcd834202ff (diff) | |
parent | 79c8ffd915115728070339f30d57a3a3e31bd322 (diff) |
Merge branch 'version2'
Diffstat (limited to 'ssh/client.c')
-rw-r--r-- | ssh/client.c | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/ssh/client.c b/ssh/client.c index 52f26c6..a262d6f 100644 --- a/ssh/client.c +++ b/ssh/client.c @@ -199,7 +199,7 @@ static bool handle_line( if (state->focus_room != NULL) { char *message = NULL; sv_copy(line, &message); - enum tomsg_retval ret = tomsg_send(client, state->focus_room, message, NULL); + enum tomsg_retval ret = tomsg_send(client, state->focus_room, message, -1, NULL); free(message); if (ret != TOMSG_OK) return true; return false; @@ -253,7 +253,15 @@ static bool handle_line( } else if (sv_equals(command, "s") || sv_equals(command, "send")) { if (parse_args(line, args, num_args = 2, true)) { autocomplete_roomname(state, &args[0]); - ret = tomsg_send(client, args[0], args[1], NULL); + ret = tomsg_send(client, args[0], args[1], -1, NULL); + } + + } else if (sv_equals(command, "r") || sv_equals(command, "reply")) { + int64_t replyid; + if (parse_args(line, args, num_args = 3, true) && + parse_i64(args[1], &replyid)) { + autocomplete_roomname(state, &args[0]); + ret = tomsg_send(client, args[0], args[2], replyid, NULL); } } else if (sv_equals(command, "ping")) { @@ -277,6 +285,14 @@ static bool handle_line( ret = tomsg_history(client, args[0], count, msgid); } + } else if (sv_equals(command, "get") || + sv_equals(command, "get_message")) { + int64_t msgid; + if (parse_args(line, args, num_args = 1, false) && + parse_i64(args[0], &msgid)) { + ret = tomsg_get_message(client, msgid); + } + } else if (sv_equals(command, "on") || sv_equals(command, "is_online")) { if (parse_args(line, args, num_args = 1, false)) { @@ -314,9 +330,11 @@ static bool handle_line( " create_room\n" " invite <room> <user>\n" " s/send <room> <message...>\n" + " r/reply <room> <msgid> <message...>\n" " ping\n" " hist/history <room> <count>\n" " histb/history_before <room> <count> <before_msgid>\n" + " get/get_message <msgid>\n" " on/is_online <user>\n" " act/user_active <y/n>\n" " help\n" @@ -352,6 +370,7 @@ static const char* event_type_descr(enum tomsg_event_type type) { case TOMSG_EV_INVITE: return "invite"; case TOMSG_EV_SEND: return "send"; case TOMSG_EV_HISTORY: return "history"; + case TOMSG_EV_GET_MESSAGE: return "get_message"; case TOMSG_EV_PING: return "ping"; case TOMSG_EV_IS_ONLINE: return "is_online"; case TOMSG_EV_USER_ACTIVE: return "user_active"; @@ -365,8 +384,12 @@ static const char* event_type_descr(enum tomsg_event_type type) { } static void print_history_message(const struct history_message msg) { - printf("%" PRIi64 " \x1B[90m%" PRIi64 "\x1B[0m <%s> %s\n", - msg.msgid, msg.timestamp, msg.username, msg.message); + printf("%" PRIi64 " \x1B[90m%" PRIi64 "\x1B[0m <%s> ", + msg.msgid, msg.timestamp, msg.username); + if (msg.replyid != -1) { + printf("\x1B[32m[%" PRIi64 "<-]\x1B[0m ", msg.replyid); + } + printf("%s\n", msg.message); } static void handle_event(struct state *state, const struct tomsg_event event) { @@ -438,6 +461,12 @@ static void handle_event(struct state *state, const struct tomsg_event event) { } break; + case TOMSG_EV_GET_MESSAGE: + printf(" %" PRIi64 " is in room %s:\n ", + event.get_message.message.msgid, event.get_message.room_name); + print_history_message(event.get_message.message); + break; + case TOMSG_EV_PING: printf(" Pong\n"); break; |