From 6dd39519487b4796f1a5b3e4f5df54e34fe39bd9 Mon Sep 17 00:00:00 2001 From: Floens Date: Sun, 7 Jun 2015 14:42:17 +0200 Subject: [PATCH 1/3] Add "get_self" command This executes user_info with our_id --- interface.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/interface.c b/interface.c index 0df696a..8cf9d2d 100644 --- a/interface.c +++ b/interface.c @@ -856,6 +856,11 @@ void do_broadcast (struct command *command, int arg_num, struct arg args[], stru /* {{{ EDITING SELF PROFILE */ +void do_get_self(struct command *command, int arg_num, struct arg args[], struct in_ev *ev) { + if (ev) { ev->refcnt ++; } + tgl_do_get_user_info (TLS, TGL_MK_USER(TLS->our_id), 0, print_user_info_gw, ev); +} + void do_set_profile_photo (struct command *command, int arg_num, struct arg args[], struct in_ev *ev) { assert (arg_num == 1); if (ev) { ev->refcnt ++; } @@ -1344,6 +1349,7 @@ struct command commands[MAX_COMMANDS_SIZE] = { {"fwd", {ca_peer, ca_number, ca_period, ca_none}, do_fwd, "fwd +\tForwards message to peer. Forward to secret chats is forbidden", NULL}, {"fwd_media", {ca_peer, ca_number, ca_none}, do_fwd_media, "fwd_media \tForwards message media to peer. Forward to secret chats is forbidden. Result slightly differs from fwd", NULL}, {"get_message", {ca_number, ca_none}, do_get_message, "get_message \tGet message by id", NULL}, + {"get_self", {ca_none}, do_get_self, "get_self \tGet our user info", NULL}, {"help", {ca_none}, do_help, "help\tPrints this help", NULL}, {"history", {ca_peer, ca_number | ca_optional, ca_number | ca_optional, ca_none}, do_history, "history [limit] [offset]\tPrints messages with this peer (most recent message lower). Also marks messages as read", NULL}, {"import_card", {ca_string, ca_none}, do_import_card, "import_card \tGets user by card and prints it name. You can then send messages to him as usual", NULL}, From aee4b248a36947c5d4d83fe4c48fdd94e851efc0 Mon Sep 17 00:00:00 2001 From: Floens Date: Sun, 7 Jun 2015 23:06:46 +0200 Subject: [PATCH 2/3] Document get_self --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e2cd8aa..a51e762 100644 --- a/README.md +++ b/README.md @@ -188,6 +188,7 @@ If two or more peers have same name, number is appended to the name. (for * **stats** - just for debugging * **show_license** - prints contents of GPLv2 * **help** - prints this help +* **get_self** - get our user info #### Card * **export_card** - print your 'card' that anyone can later use to import your contact From de5d6de0c83e4b084657500a08b2c1f91e6691e0 Mon Sep 17 00:00:00 2001 From: Jesper Lyager Nielsen Date: Wed, 17 Jun 2015 11:04:57 +0200 Subject: [PATCH 3/3] Use sizeof() to get size of sun_path. - Size varies on platforms, OSX has 104, Linux has 108. --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 851799f..48f7631 100644 --- a/main.c +++ b/main.c @@ -939,7 +939,7 @@ int main (int argc, char **argv) { serv_addr.sun_family = AF_UNIX; - snprintf (serv_addr.sun_path, 108, "%s", unix_socket); + snprintf (serv_addr.sun_path, sizeof(serv_addr.sun_path), "%s", unix_socket); if (bind (usfd, (struct sockaddr *) &serv_addr, sizeof (serv_addr)) < 0) { perror ("bind");