1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-15 03:13:03 +01:00

Add command to print your own group public key

This commit is contained in:
Jfreegman 2015-09-13 19:38:49 -04:00
parent b2c512687a
commit 97d5fb84fc
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63
6 changed files with 32 additions and 6 deletions

View File

@ -90,6 +90,7 @@ static struct cmd_func group_commands[] = {
{ "/ignore", cmd_ignore }, { "/ignore", cmd_ignore },
{ "/kick", cmd_kick }, { "/kick", cmd_kick },
{ "/mod", cmd_mod }, { "/mod", cmd_mod },
{ "/mykey", cmd_mykey },
{ "/passwd", cmd_set_passwd }, { "/passwd", cmd_set_passwd },
{ "/peerlimit", cmd_set_peerlimit }, { "/peerlimit", cmd_set_peerlimit },
{ "/privacy", cmd_set_privacy }, { "/privacy", cmd_set_privacy },

View File

@ -498,9 +498,9 @@ void cmd_myid(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
size_t i; size_t i;
for (i = 0; i < TOX_ADDRESS_SIZE; ++i) { for (i = 0; i < TOX_ADDRESS_SIZE; ++i) {
char xx[3]; char d[3];
snprintf(xx, sizeof(xx), "%02X", address[i] & 0xff); snprintf(d, sizeof(d), "%02X", address[i] & 0xff);
strcat(id, xx); strcat(id, d);
} }
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "%s", id); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "%s", id);

View File

@ -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]) void cmd_set_passwd(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{ {
const char *passwd = NULL; const char *passwd = NULL;

View File

@ -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_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_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_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_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_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]); void cmd_set_peerlimit(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);

View File

@ -70,9 +70,9 @@ extern struct user_settings *user_settings;
extern struct Winthread Winthread; extern struct Winthread Winthread;
#ifdef AUDIO #ifdef AUDIO
#define AC_NUM_GROUP_COMMANDS 38 #define AC_NUM_GROUP_COMMANDS 39
#else #else
#define AC_NUM_GROUP_COMMANDS 34 #define AC_NUM_GROUP_COMMANDS 35
#endif /* AUDIO */ #endif /* AUDIO */
/* groupchat command names used for tab completion. */ /* 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" }, { "/log" },
{ "/mod" }, { "/mod" },
{ "/myid" }, { "/myid" },
{ "/mykey" },
{ "/nick" }, { "/nick" },
{ "/note" }, { "/note" },
{ "/passwd" }, { "/passwd" },

View File

@ -244,6 +244,7 @@ static void help_draw_group(ToxWindow *self)
wattroff(win, A_BOLD | COLOR_PAIR(RED)); wattroff(win, A_BOLD | COLOR_PAIR(RED));
wprintw(win, " /chatid : Print the group chat id to share with others\n"); 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 <nick> : Ignore peer\n"); wprintw(win, " /ignore <nick> : Ignore peer\n");
wprintw(win, " /unignore <nick> : Unignore peer \n"); wprintw(win, " /unignore <nick> : Unignore peer \n");
wprintw(win, " /rejoin : Rejoin the group\n"); wprintw(win, " /rejoin : Rejoin the group\n");
@ -323,7 +324,7 @@ void help_onKey(ToxWindow *self, wint_t key)
break; break;
case 'r': case 'r':
help_init_window(self, 23, 80); help_init_window(self, 24, 80);
self->help->type = HELP_GROUP; self->help->type = HELP_GROUP;
break; break;