mirror of
https://github.com/Tha14/toxic.git
synced 2024-12-23 19:53:25 +01:00
add ability for founder to set group peer limit
This commit is contained in:
parent
29d0384a90
commit
a6d7e9b839
@ -85,18 +85,19 @@ static struct cmd_func chat_commands[] = {
|
||||
};
|
||||
|
||||
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 },
|
||||
{ "/chatid", cmd_chatid },
|
||||
{ "/ignore", cmd_ignore },
|
||||
{ "/passwd", cmd_set_passwd },
|
||||
{ "/peerlimit", cmd_set_peerlimit },
|
||||
{ "/privacy", cmd_set_privacy },
|
||||
{ "/rejoin", cmd_rejoin },
|
||||
{ "/topic", cmd_set_topic },
|
||||
{ "/unignore", cmd_unignore },
|
||||
#ifdef AUDIO
|
||||
{ "/mute", cmd_mute },
|
||||
{ "/sense", cmd_sense },
|
||||
{ "/mute", cmd_mute },
|
||||
{ "/sense", cmd_sense },
|
||||
#endif /* AUDIO */
|
||||
{ NULL, NULL },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
#define NUM_SPECIAL_COMMANDS 8
|
||||
|
@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "toxic.h"
|
||||
#include "windows.h"
|
||||
@ -112,6 +113,47 @@ void cmd_set_passwd(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*ar
|
||||
}
|
||||
}
|
||||
|
||||
void cmd_set_peerlimit(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||
{
|
||||
int maxpeers = 0;
|
||||
|
||||
if (argc < 1) {
|
||||
maxpeers = tox_group_get_peer_limit(m, self->num);
|
||||
|
||||
if (maxpeers == -1) {
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to retrieve peer limit");
|
||||
return;
|
||||
}
|
||||
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Peer limit is set to %d", maxpeers);
|
||||
return;
|
||||
}
|
||||
|
||||
maxpeers = atoi(argv[1]);
|
||||
|
||||
if (maxpeers <= 0) {
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Peer limit must be a value greater than 0");
|
||||
return;
|
||||
}
|
||||
|
||||
int ret = tox_group_set_peer_limit(m, self->num, (uint32_t) maxpeers);
|
||||
|
||||
switch (ret) {
|
||||
case 0: {
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Peer limit has been set to %d", maxpeers);
|
||||
return;
|
||||
}
|
||||
case -2: {
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "You do not have permission to set the peer limit.");
|
||||
return;
|
||||
}
|
||||
default: {
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to set the peer limit");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cmd_set_privacy(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||
{
|
||||
const char *pstate_str = NULL;
|
||||
|
@ -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_peerlimit(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]);
|
||||
|
@ -70,9 +70,9 @@ extern struct user_settings *user_settings;
|
||||
extern struct Winthread Winthread;
|
||||
|
||||
#ifdef AUDIO
|
||||
#define AC_NUM_GROUP_COMMANDS 30
|
||||
#define AC_NUM_GROUP_COMMANDS 31
|
||||
#else
|
||||
#define AC_NUM_GROUP_COMMANDS 26
|
||||
#define AC_NUM_GROUP_COMMANDS 27
|
||||
#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] = {
|
||||
{ "/nick" },
|
||||
{ "/note" },
|
||||
{ "/passwd" },
|
||||
{ "/peerlimit" },
|
||||
{ "/privacy" },
|
||||
{ "/quit" },
|
||||
{ "/rejoin" },
|
||||
|
@ -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, " /peerlimit <num> : Set group peer limit\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");
|
||||
@ -309,7 +310,7 @@ void help_onKey(ToxWindow *self, wint_t key)
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
help_init_window(self, 13, 80);
|
||||
help_init_window(self, 14, 80);
|
||||
self->help->type = HELP_GROUP;
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user