From ef1e76bf0c81a599d6b27b7a7bff7dd635b85fa2 Mon Sep 17 00:00:00 2001 From: V V Date: Fri, 2 Oct 2015 18:23:04 +0300 Subject: [PATCH] added create_channel --- interface.c | 25 ++++++++++++++++++++----- tgl | 2 +- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/interface.c b/interface.c index 92ca09b..2c3ef4f 100644 --- a/interface.c +++ b/interface.c @@ -1272,6 +1272,18 @@ void do_channel_set_about (struct command *command, int arg_num, struct arg args if (ev) { ev->refcnt ++; } tgl_do_channel_set_about (TLS, args[0].peer_id, ARG2STR (1), print_success_gw, ev); } + +void do_create_channel (struct command *command, int arg_num, struct arg args[], struct in_ev *ev) { + assert (arg_num >= 2 && arg_num <= 1000); + static tgl_peer_id_t ids[1000]; + int i; + for (i = 0; i < arg_num - 2; i++) { + ids[i] = args[i + 2].peer_id; + } + + if (ev) { ev->refcnt ++; } + tgl_do_create_channel (TLS, arg_num - 2, ids, ARG2STR (0), ARG2STR (1), 1, print_success_gw, ev); +} /* }}} */ /* {{{ WORKING WITH DIALOG LIST */ @@ -1531,6 +1543,7 @@ struct command commands[MAX_COMMANDS_SIZE] = { {"clear", {ca_none}, do_clear, "clear\tClears all data and exits. For debug.", NULL}, {"contact_list", {ca_none}, do_contact_list, "contact_list\tPrints contact list", NULL}, {"contact_search", {ca_string, ca_none}, do_resolve_username, "contact_search username\tSearches user by username", NULL}, + {"create_channel", {ca_string, ca_string, ca_user | ca_optional, ca_period, ca_none}, do_create_channel, "create_channel +\tCreates channel with users", NULL}, {"create_group_chat", {ca_string, ca_user, ca_period, ca_none}, do_create_group_chat, "create_group_chat +\tCreates group chat with users", NULL}, {"create_secret_chat", {ca_user, ca_none}, do_create_secret_chat, "create_secret_chat \tStarts creation of secret chat", NULL}, {"del_contact", {ca_user, ca_none}, do_del_contact, "del_contact \tDeletes contact from contact list", NULL}, @@ -3258,6 +3271,8 @@ void interpreter_ex (char *line, void *ex) { int period = 0; if (*flags == ca_period) { flags --; + } + if (*flags != ca_none && *(flags + 1) == ca_period) { period = 1; } enum command_argument op = (*flags) & 255; @@ -3390,17 +3405,17 @@ void interpreter_ex (char *line, void *ex) { assert (0); } - if (opt && !ok) { - line_ptr = save; - flags ++; - continue; - } if (period && !ok) { line_ptr = save; flags += 2; args_num --; continue; } + if (opt && !ok) { + line_ptr = save; + flags ++; + continue; + } if (!ok) { fail_interface (TLS, ex, ENOSYS, "can not parse arg #%d", args_num); break; diff --git a/tgl b/tgl index 4d5071b..352c42a 160000 --- a/tgl +++ b/tgl @@ -1 +1 @@ -Subproject commit 4d5071bc0da868130620c1dc420c3d358524732a +Subproject commit 352c42add860b0f65ee3944a1584c8208ea07df4