diff --git a/src/execute.c b/src/execute.c index 9ba68c7..e36f682 100644 --- a/src/execute.c +++ b/src/execute.c @@ -90,6 +90,7 @@ static struct cmd_func group_commands[] = { { "/ignore", cmd_ignore }, { "/kick", cmd_kick }, { "/mod", cmd_mod }, + { "/mykey", cmd_mykey }, { "/passwd", cmd_set_passwd }, { "/peerlimit", cmd_set_peerlimit }, { "/privacy", cmd_set_privacy }, diff --git a/src/global_commands.c b/src/global_commands.c index b9af59c..7f33f98 100644 --- a/src/global_commands.c +++ b/src/global_commands.c @@ -498,9 +498,9 @@ void cmd_myid(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA size_t i; for (i = 0; i < TOX_ADDRESS_SIZE; ++i) { - char xx[3]; - snprintf(xx, sizeof(xx), "%02X", address[i] & 0xff); - strcat(id, xx); + char d[3]; + snprintf(d, sizeof(d), "%02X", address[i] & 0xff); + strcat(id, d); } line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "%s", id); diff --git a/src/group_commands.c b/src/group_commands.c index fe96eea..6d0f612 100644 --- a/src/group_commands.c +++ b/src/group_commands.c @@ -294,6 +294,28 @@ void cmd_unmod(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[M } } +void cmd_mykey(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]) +{ + char pk_string[TOX_GROUP_PEER_PUBLIC_KEY_SIZE * 2 + 1] = {0}; + char pk[TOX_GROUP_PEER_PUBLIC_KEY_SIZE]; + + TOX_ERR_GROUP_SELF_QUERY err; + if (!tox_group_self_get_public_key(m, self->num, (uint8_t *) pk, &err)) { + line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to fetch your public key (error %d)", err); + return; + } + + size_t i; + + for (i = 0; i < TOX_GROUP_PEER_PUBLIC_KEY_SIZE; ++i) { + char d[3]; + snprintf(d, sizeof(d), "%02X", pk[i] & 0xff); + strcat(pk_string, d); + } + + line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "%s", pk_string); +} + void cmd_set_passwd(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]) { const char *passwd = NULL; diff --git a/src/group_commands.h b/src/group_commands.h index b80a4d9..9058e1b 100644 --- a/src/group_commands.h +++ b/src/group_commands.h @@ -31,6 +31,7 @@ void cmd_chatid(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[ void cmd_ignore(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_kick(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_mod(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]); +void cmd_mykey(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_prune(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_set_passwd(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_set_peerlimit(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]); diff --git a/src/groupchat.c b/src/groupchat.c index 13b0639..4df297a 100644 --- a/src/groupchat.c +++ b/src/groupchat.c @@ -70,9 +70,9 @@ extern struct user_settings *user_settings; extern struct Winthread Winthread; #ifdef AUDIO -#define AC_NUM_GROUP_COMMANDS 38 +#define AC_NUM_GROUP_COMMANDS 39 #else -#define AC_NUM_GROUP_COMMANDS 34 +#define AC_NUM_GROUP_COMMANDS 35 #endif /* AUDIO */ /* groupchat command names used for tab completion. */ @@ -95,6 +95,7 @@ static const char group_cmd_list[AC_NUM_GROUP_COMMANDS][MAX_CMDNAME_SIZE] = { { "/log" }, { "/mod" }, { "/myid" }, + { "/mykey" }, { "/nick" }, { "/note" }, { "/passwd" }, diff --git a/src/help.c b/src/help.c index c073276..afb4ff5 100644 --- a/src/help.c +++ b/src/help.c @@ -244,6 +244,7 @@ static void help_draw_group(ToxWindow *self) wattroff(win, A_BOLD | COLOR_PAIR(RED)); wprintw(win, " /chatid : Print the group chat id to share with others\n"); + wprintw(win, " /mykey : Print your group public key\n"); wprintw(win, " /ignore : Ignore peer\n"); wprintw(win, " /unignore : Unignore peer \n"); wprintw(win, " /rejoin : Rejoin the group\n"); @@ -323,7 +324,7 @@ void help_onKey(ToxWindow *self, wint_t key) break; case 'r': - help_init_window(self, 23, 80); + help_init_window(self, 24, 80); self->help->type = HELP_GROUP; break;