mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-22 10:23:02 +01:00
detach group names from global name
Group names are now set on a per-group basis and are not affected by the global /nick command.
This commit is contained in:
parent
5d757e1230
commit
ff669be8d1
@ -130,6 +130,7 @@ static struct cmd_func groupchat_commands[] = {
|
|||||||
{ "/list", cmd_list },
|
{ "/list", cmd_list },
|
||||||
{ "/locktopic", cmd_set_topic_lock },
|
{ "/locktopic", cmd_set_topic_lock },
|
||||||
{ "/mod", cmd_mod },
|
{ "/mod", cmd_mod },
|
||||||
|
{ "/nick", cmd_group_nick },
|
||||||
{ "/passwd", cmd_set_passwd },
|
{ "/passwd", cmd_set_passwd },
|
||||||
{ "/peerlimit", cmd_set_peerlimit },
|
{ "/peerlimit", cmd_set_peerlimit },
|
||||||
{ "/privacy", cmd_set_privacy },
|
{ "/privacy", cmd_set_privacy },
|
||||||
|
@ -777,7 +777,6 @@ void cmd_nick(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
|
|||||||
|
|
||||||
tox_self_set_name(m, (uint8_t *) nick, len, NULL);
|
tox_self_set_name(m, (uint8_t *) nick, len, NULL);
|
||||||
prompt_update_nick(prompt, nick);
|
prompt_update_nick(prompt, nick);
|
||||||
set_nick_all_groups(m, nick, len);
|
|
||||||
|
|
||||||
store_data(m, DATA_FILE);
|
store_data(m, DATA_FILE);
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,32 @@ void cmd_disconnect(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*ar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmd_group_nick(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
|
{
|
||||||
|
UNUSED_VAR(window);
|
||||||
|
|
||||||
|
if (argc < 1) {
|
||||||
|
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "Input required.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
char nick[MAX_STR_SIZE];
|
||||||
|
snprintf(nick, sizeof(nick), "%s", argv[1]);
|
||||||
|
size_t len = strlen(nick);
|
||||||
|
|
||||||
|
if (!valid_nick(nick)) {
|
||||||
|
line_info_add(self, false, NULL, NULL, SYS_MSG, 0, 0, "Invalid name.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = MIN(len, TOXIC_MAX_NAME_LENGTH - 1);
|
||||||
|
nick[len] = '\0';
|
||||||
|
|
||||||
|
set_nick_this_group(self, m, nick, len);
|
||||||
|
|
||||||
|
store_data(m, DATA_FILE);
|
||||||
|
}
|
||||||
|
|
||||||
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])
|
||||||
{
|
{
|
||||||
if (argc < 1) {
|
if (argc < 1) {
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
void cmd_chatid(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
|
void cmd_chatid(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||||
void cmd_disconnect(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
|
void cmd_disconnect(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||||
|
void cmd_group_nick(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_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_list(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]);
|
||||||
|
@ -363,40 +363,75 @@ int init_groupchat_win(Tox *m, uint32_t groupnumber, const char *groupname, size
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_nick_all_groups(Tox *m, const char *new_nick, size_t length)
|
void set_nick_this_group(ToxWindow *self, Tox *m, const char *new_nick, size_t length)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < max_groupchat_index; ++i) {
|
if (self == NULL) {
|
||||||
if (groupchats[i].active) {
|
return;
|
||||||
ToxWindow *self = get_window_ptr(groupchats[i].chatwin);
|
}
|
||||||
|
|
||||||
if (!self) {
|
char old_nick[TOX_MAX_NAME_LENGTH + 1];
|
||||||
continue;
|
size_t old_length = get_group_self_nick_truncate(m, old_nick, self->num);
|
||||||
|
|
||||||
|
Tox_Err_Group_Self_Name_Set err;
|
||||||
|
tox_group_self_set_name(m, self->num, (uint8_t *) new_nick, length, &err);
|
||||||
|
|
||||||
|
GroupChat *chat = get_groupchat(self->num);
|
||||||
|
|
||||||
|
if (chat == NULL) {
|
||||||
|
line_info_add(self, false, NULL, 0, SYS_MSG, 0, RED, "-!- Failed to set nick: invalid groupnumber");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (err) {
|
||||||
|
case TOX_ERR_GROUP_SELF_NAME_SET_OK: {
|
||||||
|
groupchat_onGroupSelfNickChange(self, m, self->num, old_nick, old_length, new_nick, length);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
if (chat->time_connected > 0) {
|
||||||
|
line_info_add(self, false, NULL, 0, SYS_MSG, 0, RED, "-!- Failed to set nick (error %d).", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
char old_nick[TOX_MAX_NAME_LENGTH + 1];
|
break;
|
||||||
size_t old_length = get_group_self_nick_truncate(m, old_nick, self->num);
|
|
||||||
|
|
||||||
Tox_Err_Group_Self_Name_Set err;
|
|
||||||
tox_group_self_set_name(m, groupchats[i].groupnumber, (uint8_t *) new_nick, length, &err);
|
|
||||||
|
|
||||||
switch (err) {
|
|
||||||
case TOX_ERR_GROUP_SELF_NAME_SET_OK: {
|
|
||||||
groupchat_onGroupSelfNickChange(self, m, self->num, old_nick, old_length, new_nick, length);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
if (groupchats[i].time_connected > 0) {
|
|
||||||
line_info_add(self, false, NULL, 0, SYS_MSG, 0, RED, "-!- Failed to set nick (error %d).", err);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* void set_nick_all_groups(Tox *m, const char *new_nick, size_t length) */
|
||||||
|
/* { */
|
||||||
|
/* for (int i = 0; i < max_groupchat_index; ++i) { */
|
||||||
|
/* if (groupchats[i].active) { */
|
||||||
|
/* ToxWindow *self = get_window_ptr(groupchats[i].chatwin); */
|
||||||
|
|
||||||
|
/* if (!self) { */
|
||||||
|
/* continue; */
|
||||||
|
/* } */
|
||||||
|
|
||||||
|
/* char old_nick[TOX_MAX_NAME_LENGTH + 1]; */
|
||||||
|
/* size_t old_length = get_group_self_nick_truncate(m, old_nick, self->num); */
|
||||||
|
|
||||||
|
/* Tox_Err_Group_Self_Name_Set err; */
|
||||||
|
/* tox_group_self_set_name(m, groupchats[i].groupnumber, (uint8_t *) new_nick, length, &err); */
|
||||||
|
|
||||||
|
/* switch (err) { */
|
||||||
|
/* case TOX_ERR_GROUP_SELF_NAME_SET_OK: { */
|
||||||
|
/* groupchat_onGroupSelfNickChange(self, m, self->num, old_nick, old_length, new_nick, length); */
|
||||||
|
/* break; */
|
||||||
|
/* } */
|
||||||
|
|
||||||
|
/* default: { */
|
||||||
|
/* if (groupchats[i].time_connected > 0) { */
|
||||||
|
/* line_info_add(self, false, NULL, 0, SYS_MSG, 0, RED, "-!- Failed to set nick (error %d).", err); */
|
||||||
|
/* } */
|
||||||
|
|
||||||
|
/* break; */
|
||||||
|
/* } */
|
||||||
|
/* } */
|
||||||
|
/* } */
|
||||||
|
/* } */
|
||||||
|
/* } */
|
||||||
|
|
||||||
void set_status_all_groups(Tox *m, uint8_t status)
|
void set_status_all_groups(Tox *m, uint8_t status)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < max_groupchat_index; ++i) {
|
for (int i = 0; i < max_groupchat_index; ++i) {
|
||||||
|
@ -68,7 +68,7 @@ typedef struct {
|
|||||||
|
|
||||||
void exit_groupchat(ToxWindow *self, Tox *m, uint32_t groupnumber, const char *partmessage, size_t length);
|
void exit_groupchat(ToxWindow *self, Tox *m, uint32_t groupnumber, const char *partmessage, size_t length);
|
||||||
int init_groupchat_win(Tox *m, uint32_t groupnumber, const char *groupname, size_t length, Group_Join_Type join_type);
|
int init_groupchat_win(Tox *m, uint32_t groupnumber, const char *groupname, size_t length, Group_Join_Type join_type);
|
||||||
void set_nick_all_groups(Tox *m, const char *new_nick, size_t length);
|
void set_nick_this_group(ToxWindow *self, Tox *m, const char *new_nick, size_t length);
|
||||||
void set_status_all_groups(Tox *m, uint8_t status);
|
void set_status_all_groups(Tox *m, uint8_t status);
|
||||||
int get_peer_index(uint32_t groupnumber, uint32_t peer_id);
|
int get_peer_index(uint32_t groupnumber, uint32_t peer_id);
|
||||||
void groupchat_onGroupPeerExit(ToxWindow *self, Tox *m, uint32_t groupnumber, uint32_t peer_id,
|
void groupchat_onGroupPeerExit(ToxWindow *self, Tox *m, uint32_t groupnumber, uint32_t peer_id,
|
||||||
|
@ -183,7 +183,7 @@ static void help_draw_global(ToxWindow *self)
|
|||||||
wprintw(win, " /requests : List pending friend requests\n");
|
wprintw(win, " /requests : List pending friend requests\n");
|
||||||
wprintw(win, " /status <type> : Set status (Online, Busy, Away)\n");
|
wprintw(win, " /status <type> : Set status (Online, Busy, Away)\n");
|
||||||
wprintw(win, " /note <msg> : Set a personal note\n");
|
wprintw(win, " /note <msg> : Set a personal note\n");
|
||||||
wprintw(win, " /nick <nick> : Set your nickname\n");
|
wprintw(win, " /nick <name> : Set your global name (doesn't affect groups)\n");
|
||||||
wprintw(win, " /nospam <value> : Change part of your Tox ID to stop spam\n");
|
wprintw(win, " /nospam <value> : Change part of your Tox ID to stop spam\n");
|
||||||
wprintw(win, " /log <on> or <off> : Enable/disable logging\n");
|
wprintw(win, " /log <on> or <off> : Enable/disable logging\n");
|
||||||
wprintw(win, " /myid : Print your Tox ID\n");
|
wprintw(win, " /myid : Print your Tox ID\n");
|
||||||
@ -307,6 +307,7 @@ static void help_draw_groupchats(ToxWindow *self)
|
|||||||
wprintw(win, " /list : Print a list of peers currently in the group\n");
|
wprintw(win, " /list : Print a list of peers currently in the group\n");
|
||||||
wprintw(win, " /locktopic : Set the topic lock: on | off\n");
|
wprintw(win, " /locktopic : Set the topic lock: on | off\n");
|
||||||
wprintw(win, " /mod <name> : Promote a peer to moderator\n");
|
wprintw(win, " /mod <name> : Promote a peer to moderator\n");
|
||||||
|
wprintw(win, " /nick <name> : Set your name for this group only\n");
|
||||||
wprintw(win, " /passwd <s> : Set a password needed to join the group\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");
|
wprintw(win, " /peerlimit <n> : Set the maximum number of peers that can join\n");
|
||||||
wprintw(win, " /privacy <state> : Set the privacy state: private | public\n");
|
wprintw(win, " /privacy <state> : Set the privacy state: private | public\n");
|
||||||
@ -496,7 +497,7 @@ void help_onKey(ToxWindow *self, wint_t key)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case L'r':
|
case L'r':
|
||||||
help_init_window(self, 26, 80);
|
help_init_window(self, 27, 80);
|
||||||
self->help->type = HELP_GROUP;
|
self->help->type = HELP_GROUP;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user