mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-22 21:03:02 +01:00
Load conference titles on startup for saved conferences (#43)
This commit is contained in:
parent
12b9cd2386
commit
bb2257973e
@ -132,7 +132,7 @@ void cmd_join_group(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*ar
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (init_groupchat_win(prompt, m, groupnum, type) == -1) {
|
if (init_groupchat_win(prompt, m, groupnum, type, NULL, 0) == -1) {
|
||||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Group chat window failed to initialize.");
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Group chat window failed to initialize.");
|
||||||
tox_conference_delete(m, groupnum, NULL);
|
tox_conference_delete(m, groupnum, NULL);
|
||||||
return;
|
return;
|
||||||
|
@ -353,7 +353,7 @@ void cmd_groupchat(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*arg
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (init_groupchat_win(prompt, m, groupnum, type) == -1) {
|
if (init_groupchat_win(prompt, m, groupnum, type, NULL, 0) == -1) {
|
||||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Group chat window failed to initialize.");
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Group chat window failed to initialize.");
|
||||||
tox_conference_delete(m, groupnum, NULL);
|
tox_conference_delete(m, groupnum, NULL);
|
||||||
return;
|
return;
|
||||||
|
@ -36,7 +36,7 @@ void cmd_set_title(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*arg
|
|||||||
if (argc < 1) {
|
if (argc < 1) {
|
||||||
size_t tlen = tox_conference_get_title_size(m, self->num, &err);
|
size_t tlen = tox_conference_get_title_size(m, self->num, &err);
|
||||||
|
|
||||||
if (err != TOX_ERR_CONFERENCE_TITLE_OK) {
|
if (err != TOX_ERR_CONFERENCE_TITLE_OK || tlen >= sizeof(title)) {
|
||||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Title is not set");
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Title is not set");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ static void kill_groupchat_window(ToxWindow *self)
|
|||||||
del_window(self);
|
del_window(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
int init_groupchat_win(ToxWindow *prompt, Tox *m, uint32_t groupnum, uint8_t type)
|
int init_groupchat_win(ToxWindow *prompt, Tox *m, uint32_t groupnum, uint8_t type, const char *title, size_t title_length)
|
||||||
{
|
{
|
||||||
if (groupnum > MAX_GROUPCHAT_NUM) {
|
if (groupnum > MAX_GROUPCHAT_NUM) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -146,6 +146,7 @@ int init_groupchat_win(ToxWindow *prompt, Tox *m, uint32_t groupnum, uint8_t typ
|
|||||||
groupchats[i].start_time = get_unix_time();
|
groupchats[i].start_time = get_unix_time();
|
||||||
|
|
||||||
set_active_window_index(groupchats[i].chatwin);
|
set_active_window_index(groupchats[i].chatwin);
|
||||||
|
set_window_title(self, title, title_length);
|
||||||
|
|
||||||
if (i == max_groupchat_index) {
|
if (i == max_groupchat_index) {
|
||||||
++max_groupchat_index;
|
++max_groupchat_index;
|
||||||
|
@ -56,7 +56,7 @@ typedef struct {
|
|||||||
/* Frees all Toxic associated data structures for a groupchat (does not call tox_conference_delete() ) */
|
/* Frees all Toxic associated data structures for a groupchat (does not call tox_conference_delete() ) */
|
||||||
void free_groupchat(ToxWindow *self, Tox *m, uint32_t groupnum);
|
void free_groupchat(ToxWindow *self, Tox *m, uint32_t groupnum);
|
||||||
|
|
||||||
int init_groupchat_win(ToxWindow *prompt, Tox *m, uint32_t groupnum, uint8_t type);
|
int init_groupchat_win(ToxWindow *prompt, Tox *m, uint32_t groupnum, uint8_t type, const char *title, size_t title_length);
|
||||||
|
|
||||||
/* destroys and re-creates groupchat window with or without the peerlist */
|
/* destroys and re-creates groupchat window with or without the peerlist */
|
||||||
void redraw_groupchat_win(ToxWindow *self);
|
void redraw_groupchat_win(ToxWindow *self);
|
||||||
|
@ -539,6 +539,10 @@ int check_file_signature(const char *signature, size_t size, FILE *fp)
|
|||||||
/* sets window title in tab bar. */
|
/* sets window title in tab bar. */
|
||||||
void set_window_title(ToxWindow *self, const char *title, int len)
|
void set_window_title(ToxWindow *self, const char *title, int len)
|
||||||
{
|
{
|
||||||
|
if (len <= 0 || !title) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
char cpy[TOXIC_MAX_NAME_LENGTH + 1];
|
char cpy[TOXIC_MAX_NAME_LENGTH + 1];
|
||||||
|
|
||||||
if (self->is_groupchat) { /* keep groupnumber in title */
|
if (self->is_groupchat) { /* keep groupnumber in title */
|
||||||
|
18
src/toxic.c
18
src/toxic.c
@ -344,7 +344,23 @@ static void load_groups(ToxWindow *prompt, Tox *m)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (init_groupchat_win(prompt, m, groupnum, type) == -1) {
|
Tox_Err_Conference_Title t_err;
|
||||||
|
size_t length = tox_conference_get_title_size(m, groupnum, &t_err);
|
||||||
|
uint8_t title[MAX_STR_SIZE];
|
||||||
|
|
||||||
|
if (t_err != TOX_ERR_CONFERENCE_TITLE_OK || length >= sizeof(title)) {
|
||||||
|
length = 0;
|
||||||
|
} else {
|
||||||
|
tox_conference_get_title(m, groupnum, title, &t_err);
|
||||||
|
|
||||||
|
if (t_err != TOX_ERR_CONFERENCE_TITLE_OK) {
|
||||||
|
length = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
title[length] = 0;
|
||||||
|
|
||||||
|
if (init_groupchat_win(prompt, m, groupnum, type, (const char *) title, length) == -1) {
|
||||||
tox_conference_delete(m, groupnum, NULL);
|
tox_conference_delete(m, groupnum, NULL);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user