mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-26 14:03:27 +01:00
add ability for founder to set group privacy state
This commit is contained in:
parent
0481f43746
commit
29d0384a90
@ -88,6 +88,7 @@ static struct cmd_func group_commands[] = {
|
||||
{ "/chatid", cmd_chatid },
|
||||
{ "/ignore", cmd_ignore },
|
||||
{ "/passwd", cmd_set_passwd },
|
||||
{ "/privacy", cmd_set_privacy },
|
||||
{ "/rejoin", cmd_rejoin },
|
||||
{ "/topic", cmd_set_topic },
|
||||
{ "/unignore", cmd_unignore },
|
||||
|
@ -112,6 +112,51 @@ void cmd_set_passwd(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*ar
|
||||
}
|
||||
}
|
||||
|
||||
void cmd_set_privacy(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||
{
|
||||
const char *pstate_str = NULL;
|
||||
TOX_GROUP_PRIVACY_STATE privacy_state;
|
||||
|
||||
if (argc < 1) {
|
||||
privacy_state = tox_group_get_privacy_state(m, self->num);
|
||||
|
||||
if (privacy_state == TOX_GP_INVALID) {
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to retrieve privacy state");
|
||||
return;
|
||||
}
|
||||
|
||||
pstate_str = privacy_state == TOX_GP_PRIVATE ? "private" : "public";
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Privacy state is set to %s.", pstate_str);
|
||||
return;
|
||||
}
|
||||
|
||||
pstate_str = argv[1];
|
||||
|
||||
if (strcasecmp(pstate_str, "private") != 0 && strcasecmp(pstate_str, "public") != 0) {
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Privacy state must be \"private\" or \"public\".");
|
||||
return;
|
||||
}
|
||||
|
||||
privacy_state = strcasecmp(pstate_str, "private") == 0 ? TOX_GP_PRIVATE : TOX_GP_PUBLIC;
|
||||
|
||||
int ret = tox_group_set_privacy_state(m, self->num, privacy_state);
|
||||
|
||||
switch (ret) {
|
||||
case 0: {
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Privacy state has been set to %s.", pstate_str);
|
||||
return;
|
||||
}
|
||||
case -2: {
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "You do not have permission to set the privacy state.");
|
||||
return;
|
||||
}
|
||||
default: {
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Error setting privacy state.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cmd_rejoin(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||
{
|
||||
if (tox_group_reconnect(m, self->num) == -1)
|
||||
|
@ -29,6 +29,7 @@
|
||||
void cmd_chatid(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_set_passwd(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||
void cmd_set_privacy(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||
void cmd_rejoin(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||
void cmd_set_topic(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||
void cmd_unignore(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||
|
@ -70,9 +70,9 @@ extern struct user_settings *user_settings;
|
||||
extern struct Winthread Winthread;
|
||||
|
||||
#ifdef AUDIO
|
||||
#define AC_NUM_GROUP_COMMANDS 29
|
||||
#define AC_NUM_GROUP_COMMANDS 30
|
||||
#else
|
||||
#define AC_NUM_GROUP_COMMANDS 25
|
||||
#define AC_NUM_GROUP_COMMANDS 26
|
||||
#endif /* AUDIO */
|
||||
|
||||
/* groupchat command names used for tab completion. */
|
||||
@ -94,10 +94,11 @@ static const char group_cmd_list[AC_NUM_GROUP_COMMANDS][MAX_CMDNAME_SIZE] = {
|
||||
{ "/myid" },
|
||||
{ "/nick" },
|
||||
{ "/note" },
|
||||
{ "/passwd" },
|
||||
{ "/privacy" },
|
||||
{ "/quit" },
|
||||
{ "/rejoin" },
|
||||
{ "/requests" },
|
||||
{ "/passwd" },
|
||||
{ "/status" },
|
||||
{ "/topic" },
|
||||
{ "/unignore" },
|
||||
|
@ -246,6 +246,7 @@ static void help_draw_group(ToxWindow *self)
|
||||
wprintw(win, " /chatid : Print the group chat id to share with others.\n");
|
||||
wprintw(win, " /ignore <nick> : Ignore peer\n");
|
||||
wprintw(win, " /passwd <password> : Set group password (leave blank to unset)\n");
|
||||
wprintw(win, " /privacy <state> : Set group privacy state: private|public\n");
|
||||
wprintw(win, " /rejoin : Rejoin the group\n");
|
||||
wprintw(win, " /topic <msg> : Set group topic (show current topic if no msg)\n");
|
||||
wprintw(win, " /unignore <nick> : Unignore peer \n");
|
||||
@ -308,7 +309,7 @@ void help_onKey(ToxWindow *self, wint_t key)
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
help_init_window(self, 12, 80);
|
||||
help_init_window(self, 13, 80);
|
||||
self->help->type = HELP_GROUP;
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user