mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-14 05:43:02 +01:00
Add /list command that lists all group peers w/ public keys
This commit is contained in:
parent
5dabaac804
commit
1211899a40
@ -127,6 +127,7 @@ static struct cmd_func groupchat_commands[] = {
|
||||
{ "/disconnect",cmd_disconnect },
|
||||
{ "/ignore", cmd_ignore },
|
||||
{ "/kick", cmd_kick },
|
||||
{ "/list", cmd_list },
|
||||
{ "/mod", cmd_mod },
|
||||
{ "/passwd", cmd_set_passwd },
|
||||
{ "/peerlimit", cmd_set_peerlimit },
|
||||
|
@ -162,6 +162,34 @@ void cmd_kick(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
|
||||
}
|
||||
}
|
||||
|
||||
void cmd_list(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||
{
|
||||
GroupChat *chat = get_groupchat(self->num);
|
||||
|
||||
if (!chat) {
|
||||
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "Failed to fetch GroupChat object.");
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < chat->max_idx; ++i) {
|
||||
GroupPeer *peer = &chat->peer_list[i];
|
||||
|
||||
if (!peer->active) {
|
||||
continue;
|
||||
}
|
||||
|
||||
char pk_string[TOX_GROUP_PEER_PUBLIC_KEY_SIZE * 2 + 1] = {0};
|
||||
|
||||
for (size_t j = 0; j < TOX_GROUP_PEER_PUBLIC_KEY_SIZE; ++j) {
|
||||
char d[3];
|
||||
snprintf(d, sizeof(d), "%02X", peer->public_key[j] & 0xff);
|
||||
strcat(pk_string, d);
|
||||
}
|
||||
|
||||
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "%s : %s", pk_string, peer->name);
|
||||
}
|
||||
}
|
||||
|
||||
void cmd_mod(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||
{
|
||||
if (argc < 1) {
|
||||
@ -689,15 +717,13 @@ void cmd_whois(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[M
|
||||
get_unix_time() - chat->peer_list[peer_index].last_active);
|
||||
|
||||
char pk_string[TOX_GROUP_PEER_PUBLIC_KEY_SIZE * 2 + 1] = {0};
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < TOX_GROUP_PEER_PUBLIC_KEY_SIZE; ++i) {
|
||||
for (size_t i = 0; i < TOX_GROUP_PEER_PUBLIC_KEY_SIZE; ++i) {
|
||||
char d[3];
|
||||
snprintf(d, sizeof(d), "%02X", chat->peer_list[peer_index].public_key[i] & 0xff);
|
||||
strcat(pk_string, d);
|
||||
}
|
||||
|
||||
|
||||
TOX_ERR_GROUP_PEER_QUERY conn_err;
|
||||
Tox_Connection connection_type = tox_group_peer_get_connection_status(m, self->num, peer_id, &conn_err);
|
||||
|
||||
|
@ -30,6 +30,7 @@ void cmd_chatid(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
|
||||
void cmd_disconnect(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_list(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_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]);
|
||||
|
@ -88,6 +88,7 @@ static const char *group_cmd_list[] = {
|
||||
"/ignore",
|
||||
"/join",
|
||||
"/kick",
|
||||
"/list",
|
||||
"/log",
|
||||
"/mod",
|
||||
"/myid",
|
||||
|
@ -302,6 +302,7 @@ static void help_draw_groupchats(ToxWindow *self)
|
||||
wprintw(win, " /ignore <name> : Ignore a peer\n");
|
||||
wprintw(win, " /unignore <name> : Unignore an ignored peer\n");
|
||||
wprintw(win, " /kick <name> : Remove a peer from the group\n");
|
||||
wprintw(win, " /list : Print a list of peers currently in the group\n");
|
||||
wprintw(win, " /mod <name> : Promote a peer to moderator\n");
|
||||
wprintw(win, " /passwd <s> : Set a password needed to join the group\n");
|
||||
wprintw(win, " /peerlimit <n> : Set the maximum number of peers that can join\n");
|
||||
@ -488,7 +489,7 @@ void help_onKey(ToxWindow *self, wint_t key)
|
||||
break;
|
||||
|
||||
case L'r':
|
||||
help_init_window(self, 23, 80);
|
||||
help_init_window(self, 24, 80);
|
||||
self->help->type = HELP_GROUP;
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user