1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-14 17:43:01 +01:00

Rename: groupchats -> conferences

This is in line with the toxcore API naming scheme and is in preparation
for the merge with the new groupchat implementation
This commit is contained in:
jfreegman 2020-11-08 10:08:24 -05:00
parent 811fbfbb1e
commit 4188b392cc
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63
28 changed files with 294 additions and 293 deletions

View File

@ -14,7 +14,7 @@ LDFLAGS ?=
LDFLAGS += ${USER_LDFLAGS} LDFLAGS += ${USER_LDFLAGS}
OBJ = autocomplete.o avatars.o bootstrap.o chat.o chat_commands.o configdir.o curl_util.o execute.o OBJ = autocomplete.o avatars.o bootstrap.o chat.o chat_commands.o configdir.o curl_util.o execute.o
OBJ += file_transfers.o friendlist.o global_commands.o group_commands.o groupchat.o help.o input.o OBJ += file_transfers.o friendlist.o global_commands.o conference_commands.o conference.o help.o input.o
OBJ += line_info.o log.o message_queue.o misc_tools.o name_lookup.o notify.o prompt.o qr_code.o settings.o OBJ += line_info.o log.o message_queue.o misc_tools.o name_lookup.o notify.o prompt.o qr_code.o settings.o
OBJ += term_mplex.o toxic.o toxic_strings.o windows.o OBJ += term_mplex.o toxic.o toxic_strings.o windows.o

View File

@ -75,7 +75,7 @@ static const char *chat_cmd_list[] = {
"/close", "/close",
"/connect", "/connect",
"/exit", "/exit",
"/group", "/conference",
"/help", "/help",
"/invite", "/invite",
"/join", "/join",
@ -714,28 +714,29 @@ static void chat_onFileRecv(ToxWindow *self, Tox *m, uint32_t friendnum, uint32_
} }
} }
static void chat_onGroupInvite(ToxWindow *self, Tox *m, int32_t friendnumber, uint8_t type, const char *group_pub_key, static void chat_onConferenceInvite(ToxWindow *self, Tox *m, int32_t friendnumber, uint8_t type,
uint16_t length) const char *conference_pub_key,
uint16_t length)
{ {
if (self->num != friendnumber) { if (self->num != friendnumber) {
return; return;
} }
if (Friends.list[friendnumber].group_invite.key != NULL) { if (Friends.list[friendnumber].conference_invite.key != NULL) {
free(Friends.list[friendnumber].group_invite.key); free(Friends.list[friendnumber].conference_invite.key);
} }
char *k = malloc(length); char *k = malloc(length);
if (k == NULL) { if (k == NULL) {
exit_toxic_err("Failed in chat_onGroupInvite", FATALERR_MEMORY); exit_toxic_err("Failed in chat_onConferenceInvite", FATALERR_MEMORY);
} }
memcpy(k, group_pub_key, length); memcpy(k, conference_pub_key, length);
Friends.list[friendnumber].group_invite.key = k; Friends.list[friendnumber].conference_invite.key = k;
Friends.list[friendnumber].group_invite.pending = true; Friends.list[friendnumber].conference_invite.pending = true;
Friends.list[friendnumber].group_invite.length = length; Friends.list[friendnumber].conference_invite.length = length;
Friends.list[friendnumber].group_invite.type = type; Friends.list[friendnumber].conference_invite.type = type;
sound_notify(self, generic_message, NT_WNDALERT_2 | user_settings->bell_on_invite, NULL); sound_notify(self, generic_message, NT_WNDALERT_2 | user_settings->bell_on_invite, NULL);
@ -743,12 +744,12 @@ static void chat_onGroupInvite(ToxWindow *self, Tox *m, int32_t friendnumber, ui
get_nick_truncate(m, name, friendnumber); get_nick_truncate(m, name, friendnumber);
if (self->active_box != -1) { if (self->active_box != -1) {
box_silent_notify2(self, NT_WNDALERT_2 | NT_NOFOCUS, self->active_box, "invites you to join group chat"); box_silent_notify2(self, NT_WNDALERT_2 | NT_NOFOCUS, self->active_box, "invites you to join conference");
} else { } else {
box_silent_notify(self, NT_WNDALERT_2 | NT_NOFOCUS, &self->active_box, name, "invites you to join group chat"); box_silent_notify(self, NT_WNDALERT_2 | NT_NOFOCUS, &self->active_box, name, "invites you to join conference");
} }
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "%s has invited you to a group chat.", name); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "%s has invited you to a conference.", name);
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Type \"/join\" to join the chat."); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Type \"/join\" to join the chat.");
} }
@ -1402,7 +1403,7 @@ ToxWindow *new_chat(Tox *m, uint32_t friendnum)
ret->onMessage = &chat_onMessage; ret->onMessage = &chat_onMessage;
ret->onConnectionChange = &chat_onConnectionChange; ret->onConnectionChange = &chat_onConnectionChange;
ret->onTypingChange = & chat_onTypingChange; ret->onTypingChange = & chat_onTypingChange;
ret->onGroupInvite = &chat_onGroupInvite; ret->onConferenceInvite = &chat_onConferenceInvite;
ret->onNickChange = &chat_onNickChange; ret->onNickChange = &chat_onNickChange;
ret->onStatusChange = &chat_onStatusChange; ret->onStatusChange = &chat_onStatusChange;
ret->onStatusMessageChange = &chat_onStatusMessageChange; ret->onStatusMessageChange = &chat_onStatusMessageChange;

View File

@ -29,7 +29,7 @@
#include "friendlist.h" #include "friendlist.h"
#include "execute.h" #include "execute.h"
#include "line_info.h" #include "line_info.h"
#include "groupchat.h" #include "conference.h"
#include "chat.h" #include "chat.h"
#include "file_transfers.h" #include "file_transfers.h"
@ -80,33 +80,33 @@ void cmd_cancelfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*ar
close_file_transfer(self, m, ft, TOX_FILE_CONTROL_CANCEL, msg, silent); close_file_transfer(self, m, ft, TOX_FILE_CONTROL_CANCEL, msg, silent);
} }
void cmd_groupinvite(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]) void cmd_conference_invite(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{ {
UNUSED_VAR(window); UNUSED_VAR(window);
if (argc < 1) { if (argc < 1) {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Group number required."); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Conference number required.");
return; return;
} }
long int groupnum = strtol(argv[1], NULL, 10); long int conferencenum = strtol(argv[1], NULL, 10);
if ((groupnum == 0 && strcmp(argv[1], "0")) || groupnum < 0 || groupnum == LONG_MAX) { if ((conferencenum == 0 && strcmp(argv[1], "0")) || conferencenum < 0 || conferencenum == LONG_MAX) {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Invalid group number."); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Invalid conference number.");
return; return;
} }
Tox_Err_Conference_Invite err; Tox_Err_Conference_Invite err;
if (!tox_conference_invite(m, self->num, groupnum, &err)) { if (!tox_conference_invite(m, self->num, conferencenum, &err)) {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to invite contact to group (error %d)", err); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to invite contact to conference (error %d)", err);
return; return;
} }
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Invited contact to Group %ld.", groupnum); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Invited contact to Conference %ld.", conferencenum);
} }
void cmd_join_group(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]) void cmd_conference_join(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{ {
UNUSED_VAR(window); UNUSED_VAR(window);
UNUSED_VAR(argc); UNUSED_VAR(argc);
@ -117,32 +117,32 @@ void cmd_join_group(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*ar
return; return;
} }
const char *groupkey = Friends.list[self->num].group_invite.key; const char *conferencekey = Friends.list[self->num].conference_invite.key;
uint16_t length = Friends.list[self->num].group_invite.length; uint16_t length = Friends.list[self->num].conference_invite.length;
uint8_t type = Friends.list[self->num].group_invite.type; uint8_t type = Friends.list[self->num].conference_invite.type;
if (!Friends.list[self->num].group_invite.pending) { if (!Friends.list[self->num].conference_invite.pending) {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "No pending group chat invite."); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "No pending conference invite.");
return; return;
} }
if (type != TOX_CONFERENCE_TYPE_TEXT) { if (type != TOX_CONFERENCE_TYPE_TEXT) {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Toxic does not support audio groups."); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Toxic does not support audio conferences.");
return; return;
} }
Tox_Err_Conference_Join err; Tox_Err_Conference_Join err;
uint32_t groupnum = tox_conference_join(m, self->num, (const uint8_t *) groupkey, length, &err); uint32_t conferencenum = tox_conference_join(m, self->num, (const uint8_t *) conferencekey, length, &err);
if (err != TOX_ERR_CONFERENCE_JOIN_OK) { if (err != TOX_ERR_CONFERENCE_JOIN_OK) {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Group chat instance failed to initialize (error %d)", err); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Conference instance failed to initialize (error %d)", err);
return; return;
} }
if (init_groupchat_win(m, groupnum, type, NULL, 0) == -1) { if (init_conference_win(m, conferencenum, 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, "Conference window failed to initialize.");
tox_conference_delete(m, groupnum, NULL); tox_conference_delete(m, conferencenum, NULL);
return; return;
} }

View File

@ -27,8 +27,8 @@
#include "toxic.h" #include "toxic.h"
void cmd_cancelfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_cancelfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
void cmd_groupinvite(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_conference_invite(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
void cmd_join_group(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_conference_join(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
void cmd_savefile(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_savefile(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
void cmd_sendfile(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_sendfile(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);

View File

@ -1,4 +1,4 @@
/* groupchat.c /* conference.c
* *
* *
* Copyright (C) 2014 Toxic All Rights Reserved. * Copyright (C) 2014 Toxic All Rights Reserved.
@ -50,7 +50,7 @@
#include "toxic.h" #include "toxic.h"
#include "execute.h" #include "execute.h"
#include "misc_tools.h" #include "misc_tools.h"
#include "groupchat.h" #include "conference.h"
#include "prompt.h" #include "prompt.h"
#include "toxic_strings.h" #include "toxic_strings.h"
#include "log.h" #include "log.h"
@ -64,14 +64,14 @@
extern char *DATA_FILE; extern char *DATA_FILE;
static GroupChat groupchats[MAX_GROUPCHAT_NUM]; static ConferenceChat conferences[MAX_CONFERENCE_NUM];
static int max_groupchat_index = 0; static int max_conference_index = 0;
extern struct user_settings *user_settings; extern struct user_settings *user_settings;
extern struct Winthread Winthread; extern struct Winthread Winthread;
/* Array of groupchat command names used for tab completion. */ /* Array of conference command names used for tab completion. */
static const char *group_cmd_list[] = { static const char *conference_cmd_list[] = {
"/accept", "/accept",
"/add", "/add",
"/avatar", "/avatar",
@ -80,7 +80,7 @@ static const char *group_cmd_list[] = {
"/connect", "/connect",
"/decline", "/decline",
"/exit", "/exit",
"/group", "/conference",
"/help", "/help",
"/log", "/log",
"/myid", "/myid",
@ -102,9 +102,9 @@ static const char *group_cmd_list[] = {
#endif /* PYTHON */ #endif /* PYTHON */
}; };
static ToxWindow *new_group_chat(uint32_t groupnum); static ToxWindow *new_conference_chat(uint32_t conferencenum);
static void kill_groupchat_window(ToxWindow *self) static void kill_conference_window(ToxWindow *self)
{ {
ChatContext *ctx = self->chatwin; ChatContext *ctx = self->chatwin;
@ -119,65 +119,65 @@ static void kill_groupchat_window(ToxWindow *self)
del_window(self); del_window(self);
} }
int init_groupchat_win(Tox *m, uint32_t groupnum, uint8_t type, const char *title, int init_conference_win(Tox *m, uint32_t conferencenum, uint8_t type, const char *title,
size_t title_length) size_t title_length)
{ {
if (groupnum > MAX_GROUPCHAT_NUM) { if (conferencenum > MAX_CONFERENCE_NUM) {
return -1; return -1;
} }
ToxWindow *self = new_group_chat(groupnum); ToxWindow *self = new_conference_chat(conferencenum);
for (int i = 0; i <= max_groupchat_index; ++i) { for (int i = 0; i <= max_conference_index; ++i) {
if (!groupchats[i].active) { if (!conferences[i].active) {
groupchats[i].chatwin = add_window(m, self); conferences[i].chatwin = add_window(m, self);
groupchats[i].active = true; conferences[i].active = true;
groupchats[i].num_peers = 0; conferences[i].num_peers = 0;
groupchats[i].type = type; conferences[i].type = type;
groupchats[i].start_time = get_unix_time(); conferences[i].start_time = get_unix_time();
set_active_window_index(groupchats[i].chatwin); set_active_window_index(conferences[i].chatwin);
set_window_title(self, title, title_length); set_window_title(self, title, title_length);
if (i == max_groupchat_index) { if (i == max_conference_index) {
++max_groupchat_index; ++max_conference_index;
} }
return 0; return 0;
} }
} }
kill_groupchat_window(self); kill_conference_window(self);
return -1; return -1;
} }
void free_groupchat(ToxWindow *self, uint32_t groupnum) void free_conference(ToxWindow *self, uint32_t conferencenum)
{ {
free_ptr_array((void **) groupchats[groupnum].name_list); free_ptr_array((void **) conferences[conferencenum].name_list);
free(groupchats[groupnum].peer_list); free(conferences[conferencenum].peer_list);
memset(&groupchats[groupnum], 0, sizeof(GroupChat)); memset(&conferences[conferencenum], 0, sizeof(ConferenceChat));
int i; int i;
for (i = max_groupchat_index; i > 0; --i) { for (i = max_conference_index; i > 0; --i) {
if (groupchats[i - 1].active) { if (conferences[i - 1].active) {
break; break;
} }
} }
max_groupchat_index = i; max_conference_index = i;
kill_groupchat_window(self); kill_conference_window(self);
} }
static void delete_groupchat(ToxWindow *self, Tox *m, uint32_t groupnum) static void delete_conference(ToxWindow *self, Tox *m, uint32_t conferencenum)
{ {
tox_conference_delete(m, groupnum, NULL); tox_conference_delete(m, conferencenum, NULL);
free_groupchat(self, groupnum); free_conference(self, conferencenum);
} }
/* destroys and re-creates groupchat window with or without the peerlist */ /* destroys and re-creates conference window with or without the peerlist */
void redraw_groupchat_win(ToxWindow *self) void redraw_conference_win(ToxWindow *self)
{ {
ChatContext *ctx = self->chatwin; ChatContext *ctx = self->chatwin;
@ -216,19 +216,19 @@ void redraw_groupchat_win(ToxWindow *self)
} }
static void groupchat_onGroupMessage(ToxWindow *self, Tox *m, uint32_t groupnum, uint32_t peernum, static void conference_onConferenceMessage(ToxWindow *self, Tox *m, uint32_t conferencenum, uint32_t peernum,
Tox_Message_Type type, const char *msg, size_t len) Tox_Message_Type type, const char *msg, size_t len)
{ {
UNUSED_VAR(len); UNUSED_VAR(len);
if (self->num != groupnum) { if (self->num != conferencenum) {
return; return;
} }
ChatContext *ctx = self->chatwin; ChatContext *ctx = self->chatwin;
char nick[TOX_MAX_NAME_LENGTH]; char nick[TOX_MAX_NAME_LENGTH];
get_group_nick_truncate(m, nick, peernum, groupnum); get_conference_nick_truncate(m, nick, peernum, conferencenum);
char selfnick[TOX_MAX_NAME_LENGTH]; char selfnick[TOX_MAX_NAME_LENGTH];
tox_self_get_name(m, (uint8_t *) selfnick); tox_self_get_name(m, (uint8_t *) selfnick);
@ -260,13 +260,13 @@ static void groupchat_onGroupMessage(ToxWindow *self, Tox *m, uint32_t groupnum,
write_to_log(msg, nick, ctx->log, false); write_to_log(msg, nick, ctx->log, false);
} }
static void groupchat_onGroupTitleChange(ToxWindow *self, Tox *m, uint32_t groupnum, uint32_t peernum, static void conference_onConferenceTitleChange(ToxWindow *self, Tox *m, uint32_t conferencenum, uint32_t peernum,
const char *title, const char *title,
size_t length) size_t length)
{ {
ChatContext *ctx = self->chatwin; ChatContext *ctx = self->chatwin;
if (self->num != groupnum) { if (self->num != conferencenum) {
return; return;
} }
@ -276,22 +276,22 @@ static void groupchat_onGroupTitleChange(ToxWindow *self, Tox *m, uint32_t group
get_time_str(timefrmt, sizeof(timefrmt)); get_time_str(timefrmt, sizeof(timefrmt));
/* don't announce title when we join the room */ /* don't announce title when we join the room */
if (!timed_out(groupchats[self->num].start_time, GROUP_EVENT_WAIT)) { if (!timed_out(conferences[self->num].start_time, CONFERENCE_EVENT_WAIT)) {
return; return;
} }
char nick[TOX_MAX_NAME_LENGTH]; char nick[TOX_MAX_NAME_LENGTH];
get_group_nick_truncate(m, nick, peernum, groupnum); get_conference_nick_truncate(m, nick, peernum, conferencenum);
line_info_add(self, timefrmt, nick, NULL, NAME_CHANGE, 0, 0, " set the group title to: %s", title); line_info_add(self, timefrmt, nick, NULL, NAME_CHANGE, 0, 0, " set the conference title to: %s", title);
char tmp_event[MAX_STR_SIZE]; char tmp_event[MAX_STR_SIZE];
snprintf(tmp_event, sizeof(tmp_event), "set title to %s", title); snprintf(tmp_event, sizeof(tmp_event), "set title to %s", title);
write_to_log(tmp_event, nick, ctx->log, true); write_to_log(tmp_event, nick, ctx->log, true);
} }
static void group_update_name_list(uint32_t groupnum) static void conference_update_name_list(uint32_t conferencenum)
{ {
GroupChat *chat = &groupchats[groupnum]; ConferenceChat *chat = &conferences[conferencenum];
if (!chat->active) { if (!chat->active) {
return; return;
@ -319,12 +319,12 @@ static void group_update_name_list(uint32_t groupnum)
qsort(chat->name_list, count, sizeof(char *), qsort_ptr_char_array_helper); qsort(chat->name_list, count, sizeof(char *), qsort_ptr_char_array_helper);
} }
/* Reallocates groupnum's peer list. Increase is true if the list needs to grow. /* Reallocates conferencenum's peer list. Increase is true if the list needs to grow.
* *
* Returns 0 on success. * Returns 0 on success.
* Returns -1 on failure. * Returns -1 on failure.
*/ */
static int realloc_peer_list(GroupChat *chat, uint32_t num_peers) static int realloc_peer_list(ConferenceChat *chat, uint32_t num_peers)
{ {
if (!chat) { if (!chat) {
return -1; return -1;
@ -336,7 +336,7 @@ static int realloc_peer_list(GroupChat *chat, uint32_t num_peers)
return 0; return 0;
} }
struct GroupPeer *tmp_list = realloc(chat->peer_list, num_peers * sizeof(struct GroupPeer)); struct ConferencePeer *tmp_list = realloc(chat->peer_list, num_peers * sizeof(struct ConferencePeer));
if (!tmp_list) { if (!tmp_list) {
return -1; return -1;
@ -347,9 +347,9 @@ static int realloc_peer_list(GroupChat *chat, uint32_t num_peers)
return 0; return 0;
} }
static void update_peer_list(Tox *m, uint32_t groupnum, uint32_t num_peers) static void update_peer_list(Tox *m, uint32_t conferencenum, uint32_t num_peers)
{ {
GroupChat *chat = &groupchats[groupnum]; ConferenceChat *chat = &conferences[conferencenum];
if (!chat->active) { if (!chat->active) {
return; return;
@ -358,16 +358,16 @@ static void update_peer_list(Tox *m, uint32_t groupnum, uint32_t num_peers)
realloc_peer_list(chat, num_peers); realloc_peer_list(chat, num_peers);
for (uint32_t i = 0; i < num_peers; ++i) { for (uint32_t i = 0; i < num_peers; ++i) {
GroupPeer *peer = &chat->peer_list[i]; ConferencePeer *peer = &chat->peer_list[i];
Tox_Err_Conference_Peer_Query err; Tox_Err_Conference_Peer_Query err;
size_t length = tox_conference_peer_get_name_size(m, groupnum, i, &err); size_t length = tox_conference_peer_get_name_size(m, conferencenum, i, &err);
if (err != TOX_ERR_CONFERENCE_PEER_QUERY_OK || length >= TOX_MAX_NAME_LENGTH) { if (err != TOX_ERR_CONFERENCE_PEER_QUERY_OK || length >= TOX_MAX_NAME_LENGTH) {
continue; continue;
} }
tox_conference_peer_get_name(m, groupnum, i, (uint8_t *) peer->name, &err); tox_conference_peer_get_name(m, conferencenum, i, (uint8_t *) peer->name, &err);
peer->name[length] = 0; peer->name[length] = 0;
if (err != TOX_ERR_CONFERENCE_PEER_QUERY_OK) { if (err != TOX_ERR_CONFERENCE_PEER_QUERY_OK) {
@ -379,20 +379,20 @@ static void update_peer_list(Tox *m, uint32_t groupnum, uint32_t num_peers)
peer->peernumber = i; peer->peernumber = i;
} }
group_update_name_list(groupnum); conference_update_name_list(conferencenum);
} }
static void groupchat_onGroupNameListChange(ToxWindow *self, Tox *m, uint32_t groupnum) static void conference_onConferenceNameListChange(ToxWindow *self, Tox *m, uint32_t conferencenum)
{ {
if (self->num != groupnum) { if (self->num != conferencenum) {
return; return;
} }
if (groupnum > max_groupchat_index) { if (conferencenum > max_conference_index) {
return; return;
} }
GroupChat *chat = &groupchats[groupnum]; ConferenceChat *chat = &conferences[conferencenum];
if (!chat->active) { if (!chat->active) {
return; return;
@ -406,42 +406,42 @@ static void groupchat_onGroupNameListChange(ToxWindow *self, Tox *m, uint32_t gr
Tox_Err_Conference_Peer_Query err; Tox_Err_Conference_Peer_Query err;
uint32_t num_peers = tox_conference_peer_count(m, groupnum, &err); uint32_t num_peers = tox_conference_peer_count(m, conferencenum, &err);
if (err != TOX_ERR_CONFERENCE_PEER_QUERY_OK) { if (err != TOX_ERR_CONFERENCE_PEER_QUERY_OK) {
fprintf(stderr, "groupchat_onGroupNameListChange() failed with error: %d\n", err); fprintf(stderr, "conference_onConferenceNameListChange() failed with error: %d\n", err);
return; return;
} }
chat->name_list = (char **) malloc_ptr_array(num_peers, TOX_MAX_NAME_LENGTH + 1); chat->name_list = (char **) malloc_ptr_array(num_peers, TOX_MAX_NAME_LENGTH + 1);
if (chat->name_list == NULL) { if (chat->name_list == NULL) {
fprintf(stderr, "groupchat_onGroupNameListChange(): Out of memory.\n"); fprintf(stderr, "conference_onConferenceNameListChange(): Out of memory.\n");
return; return;
} }
chat->num_peers = num_peers; chat->num_peers = num_peers;
chat->max_idx = num_peers; chat->max_idx = num_peers;
update_peer_list(m, groupnum, num_peers); update_peer_list(m, conferencenum, num_peers);
} }
static void groupchat_onGroupPeerNameChange(ToxWindow *self, Tox *m, uint32_t groupnum, uint32_t peernum, static void conference_onConferencePeerNameChange(ToxWindow *self, Tox *m, uint32_t conferencenum, uint32_t peernum,
const char *name, size_t length) const char *name, size_t length)
{ {
UNUSED_VAR(length); UNUSED_VAR(length);
if (self->num != groupnum) { if (self->num != conferencenum) {
return; return;
} }
GroupChat *chat = &groupchats[groupnum]; ConferenceChat *chat = &conferences[conferencenum];
if (!chat->active) { if (!chat->active) {
return; return;
} }
for (uint32_t i = 0; i < chat->max_idx; ++i) { for (uint32_t i = 0; i < chat->max_idx; ++i) {
GroupPeer *peer = &chat->peer_list[i]; ConferencePeer *peer = &chat->peer_list[i];
// Test against default tox name to prevent nick change spam on initial join (TODO: this is disgusting) // Test against default tox name to prevent nick change spam on initial join (TODO: this is disgusting)
if (peer->active && peer->peernumber == peernum && peer->name_length > 0) { if (peer->active && peer->peernumber == peernum && peer->name_length > 0) {
@ -459,10 +459,10 @@ static void groupchat_onGroupPeerNameChange(ToxWindow *self, Tox *m, uint32_t gr
} }
} }
groupchat_onGroupNameListChange(self, m, groupnum); conference_onConferenceNameListChange(self, m, conferencenum);
} }
static void send_group_action(ToxWindow *self, ChatContext *ctx, Tox *m, char *action) static void send_conference_action(ToxWindow *self, ChatContext *ctx, Tox *m, char *action)
{ {
if (action == NULL) { if (action == NULL) {
wprintw(ctx->history, "Invalid syntax.\n"); wprintw(ctx->history, "Invalid syntax.\n");
@ -479,7 +479,7 @@ static void send_group_action(ToxWindow *self, ChatContext *ctx, Tox *m, char *a
/* /*
* Return true if input is recognized by handler * Return true if input is recognized by handler
*/ */
static bool groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr) static bool conference_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
{ {
ChatContext *ctx = self->chatwin; ChatContext *ctx = self->chatwin;
@ -525,7 +525,7 @@ static bool groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
/* TODO: make this not suck */ /* TODO: make this not suck */
if (ctx->line[0] != L'/' || wcscmp(ctx->line, L"/me") == 0) { if (ctx->line[0] != L'/' || wcscmp(ctx->line, L"/me") == 0) {
diff = complete_line(self, (const char **) groupchats[self->num].name_list, groupchats[self->num].num_peers); diff = complete_line(self, (const char **) conferences[self->num].name_list, conferences[self->num].num_peers);
} else if (wcsncmp(ctx->line, L"/avatar ", wcslen(L"/avatar ")) == 0) { } else if (wcsncmp(ctx->line, L"/avatar ", wcslen(L"/avatar ")) == 0) {
diff = dir_match(self, m, ctx->line, L"/avatar"); diff = dir_match(self, m, ctx->line, L"/avatar");
} }
@ -537,7 +537,7 @@ static bool groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
#endif #endif
else { else {
diff = complete_line(self, group_cmd_list, sizeof(group_cmd_list) / sizeof(char *)); diff = complete_line(self, conference_cmd_list, sizeof(conference_cmd_list) / sizeof(char *));
} }
if (diff != -1) { if (diff != -1) {
@ -555,14 +555,14 @@ static bool groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
input_ret = true; input_ret = true;
const int L = y2 - CHATBOX_HEIGHT - SDBAR_OFST; const int L = y2 - CHATBOX_HEIGHT - SDBAR_OFST;
if (groupchats[self->num].side_pos < (int64_t) groupchats[self->num].num_peers - L) { if (conferences[self->num].side_pos < (int64_t) conferences[self->num].num_peers - L) {
++groupchats[self->num].side_pos; ++conferences[self->num].side_pos;
} }
} else if (key == T_KEY_C_UP) { } else if (key == T_KEY_C_UP) {
input_ret = true; input_ret = true;
if (groupchats[self->num].side_pos > 0) { if (conferences[self->num].side_pos > 0) {
--groupchats[self->num].side_pos; --conferences[self->num].side_pos;
} }
} else if (key == L'\r') { } else if (key == L'\r') {
input_ret = true; input_ret = true;
@ -581,12 +581,12 @@ static bool groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
if (line[0] == '/') { if (line[0] == '/') {
if (strcmp(line, "/close") == 0) { if (strcmp(line, "/close") == 0) {
delete_groupchat(self, m, self->num); delete_conference(self, m, self->num);
return true; return true;
} else if (strncmp(line, "/me ", strlen("/me ")) == 0) { } else if (strncmp(line, "/me ", strlen("/me ")) == 0) {
send_group_action(self, ctx, m, line + strlen("/me ")); send_conference_action(self, ctx, m, line + strlen("/me "));
} else { } else {
execute(ctx->history, self, m, line, GROUPCHAT_COMMAND_MODE); execute(ctx->history, self, m, line, CONFERENCE_COMMAND_MODE);
} }
} else { } else {
Tox_Err_Conference_Send_Message err; Tox_Err_Conference_Send_Message err;
@ -605,7 +605,7 @@ static bool groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
return input_ret; return input_ret;
} }
static void groupchat_onDraw(ToxWindow *self, Tox *m) static void conference_onDraw(ToxWindow *self, Tox *m)
{ {
UNUSED_VAR(m); UNUSED_VAR(m);
@ -638,7 +638,7 @@ static void groupchat_onDraw(ToxWindow *self, Tox *m)
mvwaddch(ctx->sidebar, y2 - CHATBOX_HEIGHT, 0, ACS_BTEE); mvwaddch(ctx->sidebar, y2 - CHATBOX_HEIGHT, 0, ACS_BTEE);
pthread_mutex_lock(&Winthread.lock); pthread_mutex_lock(&Winthread.lock);
uint32_t num_peers = groupchats[self->num].num_peers; uint32_t num_peers = conferences[self->num].num_peers;
pthread_mutex_unlock(&Winthread.lock); pthread_mutex_unlock(&Winthread.lock);
wmove(ctx->sidebar, 0, 1); wmove(ctx->sidebar, 0, 1);
@ -655,7 +655,7 @@ static void groupchat_onDraw(ToxWindow *self, Tox *m)
wmove(ctx->sidebar, i + 2, 1); wmove(ctx->sidebar, i + 2, 1);
pthread_mutex_lock(&Winthread.lock); pthread_mutex_lock(&Winthread.lock);
uint32_t peer = i + groupchats[self->num].side_pos; uint32_t peer = i + conferences[self->num].side_pos;
pthread_mutex_unlock(&Winthread.lock); pthread_mutex_unlock(&Winthread.lock);
/* truncate nick to fit in side panel without modifying list */ /* truncate nick to fit in side panel without modifying list */
@ -663,7 +663,7 @@ static void groupchat_onDraw(ToxWindow *self, Tox *m)
int maxlen = SIDEBAR_WIDTH - 2; int maxlen = SIDEBAR_WIDTH - 2;
pthread_mutex_lock(&Winthread.lock); pthread_mutex_lock(&Winthread.lock);
memcpy(tmpnck, groupchats[self->num].name_list[peer], maxlen); memcpy(tmpnck, conferences[self->num].name_list[peer], maxlen);
pthread_mutex_unlock(&Winthread.lock); pthread_mutex_unlock(&Winthread.lock);
tmpnck[maxlen] = '\0'; tmpnck[maxlen] = '\0';
@ -687,13 +687,13 @@ static void groupchat_onDraw(ToxWindow *self, Tox *m)
} }
} }
static void groupchat_onInit(ToxWindow *self, Tox *m) static void conference_onInit(ToxWindow *self, Tox *m)
{ {
int x2, y2; int x2, y2;
getmaxyx(self->window, y2, x2); getmaxyx(self->window, y2, x2);
if (x2 <= 0 || y2 <= 0) { if (x2 <= 0 || y2 <= 0) {
exit_toxic_err("failed in groupchat_onInit", FATALERR_CURSES); exit_toxic_err("failed in conference_onInit", FATALERR_CURSES);
} }
ChatContext *ctx = self->chatwin; ChatContext *ctx = self->chatwin;
@ -706,7 +706,7 @@ static void groupchat_onInit(ToxWindow *self, Tox *m)
ctx->log = calloc(1, sizeof(struct chatlog)); ctx->log = calloc(1, sizeof(struct chatlog));
if (ctx->log == NULL || ctx->hst == NULL) { if (ctx->log == NULL || ctx->hst == NULL) {
exit_toxic_err("failed in groupchat_onInit", FATALERR_MEMORY); exit_toxic_err("failed in conference_onInit", FATALERR_MEMORY);
} }
line_info_init(ctx->hst); line_info_init(ctx->hst);
@ -715,7 +715,7 @@ static void groupchat_onInit(ToxWindow *self, Tox *m)
char myid[TOX_ADDRESS_SIZE]; char myid[TOX_ADDRESS_SIZE];
tox_self_get_address(m, (uint8_t *) myid); tox_self_get_address(m, (uint8_t *) myid);
if (log_enable(self->name, myid, NULL, ctx->log, LOG_GROUP) == -1) { if (log_enable(self->name, myid, NULL, ctx->log, LOG_CONFERENCE) == -1) {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Warning: Log failed to initialize."); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Warning: Log failed to initialize.");
} }
} }
@ -726,37 +726,37 @@ static void groupchat_onInit(ToxWindow *self, Tox *m)
wmove(self->window, y2 - CURS_Y_OFFSET, 0); wmove(self->window, y2 - CURS_Y_OFFSET, 0);
} }
static ToxWindow *new_group_chat(uint32_t groupnum) static ToxWindow *new_conference_chat(uint32_t conferencenum)
{ {
ToxWindow *ret = calloc(1, sizeof(ToxWindow)); ToxWindow *ret = calloc(1, sizeof(ToxWindow));
if (ret == NULL) { if (ret == NULL) {
exit_toxic_err("failed in new_group_chat", FATALERR_MEMORY); exit_toxic_err("failed in new_conference_chat", FATALERR_MEMORY);
} }
ret->is_groupchat = true; ret->is_conference = true;
ret->onKey = &groupchat_onKey; ret->onKey = &conference_onKey;
ret->onDraw = &groupchat_onDraw; ret->onDraw = &conference_onDraw;
ret->onInit = &groupchat_onInit; ret->onInit = &conference_onInit;
ret->onGroupMessage = &groupchat_onGroupMessage; ret->onConferenceMessage = &conference_onConferenceMessage;
ret->onGroupNameListChange = &groupchat_onGroupNameListChange; ret->onConferenceNameListChange = &conference_onConferenceNameListChange;
ret->onGroupPeerNameChange = &groupchat_onGroupPeerNameChange; ret->onConferencePeerNameChange = &conference_onConferencePeerNameChange;
ret->onGroupTitleChange = &groupchat_onGroupTitleChange; ret->onConferenceTitleChange = &conference_onConferenceTitleChange;
snprintf(ret->name, sizeof(ret->name), "Group %u", groupnum); snprintf(ret->name, sizeof(ret->name), "Conference %u", conferencenum);
ChatContext *chatwin = calloc(1, sizeof(ChatContext)); ChatContext *chatwin = calloc(1, sizeof(ChatContext));
Help *help = calloc(1, sizeof(Help)); Help *help = calloc(1, sizeof(Help));
if (chatwin == NULL || help == NULL) { if (chatwin == NULL || help == NULL) {
exit_toxic_err("failed in new_group_chat", FATALERR_MEMORY); exit_toxic_err("failed in new_conference_chat", FATALERR_MEMORY);
} }
ret->chatwin = chatwin; ret->chatwin = chatwin;
ret->help = help; ret->help = help;
ret->num = groupnum; ret->num = conferencenum;
ret->show_peerlist = true; ret->show_peerlist = true;
ret->active_box = -1; ret->active_box = -1;

View File

@ -1,4 +1,4 @@
/* groupchat.h /* conference.h
* *
* *
* Copyright (C) 2014 Toxic All Rights Reserved. * Copyright (C) 2014 Toxic All Rights Reserved.
@ -20,23 +20,23 @@
* *
*/ */
#ifndef GROUPCHAT_H #ifndef CONFERENCE_H
#define GROUPCHAT_H #define CONFERENCE_H
#include "toxic.h" #include "toxic.h"
#include "windows.h" #include "windows.h"
#define SIDEBAR_WIDTH 16 #define SIDEBAR_WIDTH 16
#define SDBAR_OFST 2 /* Offset for the peer number box at the top of the statusbar */ #define SDBAR_OFST 2 /* Offset for the peer number box at the top of the statusbar */
#define MAX_GROUPCHAT_NUM MAX_WINDOWS_NUM - 2 #define MAX_CONFERENCE_NUM (MAX_WINDOWS_NUM - 2)
#define GROUP_EVENT_WAIT 3 #define CONFERENCE_EVENT_WAIT 3
typedef struct GroupPeer { typedef struct ConferencePeer {
bool active; bool active;
char name[TOX_MAX_NAME_LENGTH]; char name[TOX_MAX_NAME_LENGTH];
size_t name_length; size_t name_length;
uint32_t peernumber; uint32_t peernumber;
} GroupPeer; } ConferencePeer;
typedef struct { typedef struct {
int chatwin; int chatwin;
@ -45,20 +45,19 @@ typedef struct {
int side_pos; /* current position of the sidebar - used for scrolling up and down */ int side_pos; /* current position of the sidebar - used for scrolling up and down */
time_t start_time; time_t start_time;
GroupPeer *peer_list; ConferencePeer *peer_list;
uint32_t max_idx; uint32_t max_idx;
char **name_list; char **name_list;
uint32_t num_peers; uint32_t num_peers;
} ConferenceChat;
} GroupChat; /* Frees all Toxic associated data structures for a conference (does not call tox_conference_delete() ) */
void free_conference(ToxWindow *self, uint32_t conferencenum);
/* Frees all Toxic associated data structures for a groupchat (does not call tox_conference_delete() ) */ int init_conference_win(Tox *m, uint32_t conferencenum, uint8_t type, const char *title, size_t title_length);
void free_groupchat(ToxWindow *self, uint32_t groupnum);
int init_groupchat_win(Tox *m, uint32_t groupnum, uint8_t type, const char *title, size_t title_length); /* destroys and re-creates conference window with or without the peerlist */
void redraw_conference_win(ToxWindow *self);
/* destroys and re-creates groupchat window with or without the peerlist */ #endif /* CONFERENCE_H */
void redraw_groupchat_win(ToxWindow *self);
#endif /* GROUPCHAT_H */

View File

@ -1,4 +1,4 @@
/* group_commands.c /* conference_commands.c
* *
* *
* Copyright (C) 2014 Toxic All Rights Reserved. * Copyright (C) 2014 Toxic All Rights Reserved.
@ -28,7 +28,7 @@
#include "misc_tools.h" #include "misc_tools.h"
#include "log.h" #include "log.h"
void cmd_set_title(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]) void cmd_conference_set_title(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{ {
UNUSED_VAR(window); UNUSED_VAR(window);
@ -73,7 +73,7 @@ void cmd_set_title(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*arg
size_t sn_len = tox_self_get_name_size(m); size_t sn_len = tox_self_get_name_size(m);
selfnick[sn_len] = '\0'; selfnick[sn_len] = '\0';
line_info_add(self, timefrmt, selfnick, NULL, NAME_CHANGE, 0, 0, " set the group title to: %s", title); line_info_add(self, timefrmt, selfnick, NULL, NAME_CHANGE, 0, 0, " set the conference title to: %s", title);
char tmp_event[MAX_STR_SIZE + 20]; char tmp_event[MAX_STR_SIZE + 20];
snprintf(tmp_event, sizeof(tmp_event), "set title to %s", title); snprintf(tmp_event, sizeof(tmp_event), "set title to %s", title);

View File

@ -1,4 +1,4 @@
/* group_commands.h /* conference_commands.h
* *
* *
* Copyright (C) 2014 Toxic All Rights Reserved. * Copyright (C) 2014 Toxic All Rights Reserved.
@ -20,12 +20,12 @@
* *
*/ */
#ifndef GROUP_COMMANDS_H #ifndef CONFERENCE_COMMANDS_H
#define GROUP_COMMANDS_H #define CONFERENCE_COMMANDS_H
#include "windows.h" #include "windows.h"
#include "toxic.h" #include "toxic.h"
void cmd_set_title(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_conference_set_title(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
#endif /* GROUP_COMMANDS_H */ #endif /* CONFERENCE_COMMANDS_H */

View File

@ -29,7 +29,7 @@
#include "execute.h" #include "execute.h"
#include "chat_commands.h" #include "chat_commands.h"
#include "global_commands.h" #include "global_commands.h"
#include "group_commands.h" #include "conference_commands.h"
#include "line_info.h" #include "line_info.h"
#include "misc_tools.h" #include "misc_tools.h"
#include "notify.h" #include "notify.h"
@ -48,7 +48,7 @@ static struct cmd_func global_commands[] = {
{ "/connect", cmd_connect }, { "/connect", cmd_connect },
{ "/decline", cmd_decline }, { "/decline", cmd_decline },
{ "/exit", cmd_quit }, { "/exit", cmd_quit },
{ "/group", cmd_groupchat }, { "/conference", cmd_conference },
{ "/help", cmd_prompt_help }, { "/help", cmd_prompt_help },
{ "/log", cmd_log }, { "/log", cmd_log },
{ "/myid", cmd_myid }, { "/myid", cmd_myid },
@ -67,8 +67,8 @@ static struct cmd_func global_commands[] = {
{ "/sdev", cmd_change_device }, { "/sdev", cmd_change_device },
#endif /* AUDIO */ #endif /* AUDIO */
#ifdef VIDEO #ifdef VIDEO
{ "/lsvdev", cmd_list_video_devices }, { "/lsvdev", cmd_list_video_devices },
{ "/svdev", cmd_change_video_device }, { "/svdev", cmd_change_video_device },
#endif /* VIDEO */ #endif /* VIDEO */
#ifdef PYTHON #ifdef PYTHON
{ "/run", cmd_run }, { "/run", cmd_run },
@ -77,28 +77,28 @@ static struct cmd_func global_commands[] = {
}; };
static struct cmd_func chat_commands[] = { static struct cmd_func chat_commands[] = {
{ "/cancel", cmd_cancelfile }, { "/cancel", cmd_cancelfile },
{ "/invite", cmd_groupinvite }, { "/invite", cmd_conference_invite },
{ "/join", cmd_join_group }, { "/join", cmd_conference_join },
{ "/savefile", cmd_savefile }, { "/savefile", cmd_savefile },
{ "/sendfile", cmd_sendfile }, { "/sendfile", cmd_sendfile },
#ifdef AUDIO #ifdef AUDIO
{ "/call", cmd_call }, { "/call", cmd_call },
{ "/answer", cmd_answer }, { "/answer", cmd_answer },
{ "/reject", cmd_reject }, { "/reject", cmd_reject },
{ "/hangup", cmd_hangup }, { "/hangup", cmd_hangup },
{ "/mute", cmd_mute }, { "/mute", cmd_mute },
{ "/sense", cmd_sense }, { "/sense", cmd_sense },
{ "/bitrate", cmd_bitrate }, { "/bitrate", cmd_bitrate },
#endif /* AUDIO */ #endif /* AUDIO */
#ifdef VIDEO #ifdef VIDEO
{ "/video", cmd_video }, { "/video", cmd_video },
#endif /* VIDEO */ #endif /* VIDEO */
{ NULL, NULL }, { NULL, NULL },
}; };
static struct cmd_func group_commands[] = { static struct cmd_func conference_commands[] = {
{ "/title", cmd_set_title }, { "/title", cmd_conference_set_title },
#ifdef AUDIO #ifdef AUDIO
{ "/mute", cmd_mute }, { "/mute", cmd_mute },
@ -246,8 +246,8 @@ void execute(WINDOW *w, ToxWindow *self, Tox *m, const char *input, int mode)
break; break;
case GROUPCHAT_COMMAND_MODE: case CONFERENCE_COMMAND_MODE:
if (do_command(w, self, m, num_args, group_commands, args) == 0) { if (do_command(w, self, m, num_args, conference_commands, args) == 0) {
return; return;
} }

View File

@ -31,7 +31,7 @@
enum { enum {
GLOBAL_COMMAND_MODE, GLOBAL_COMMAND_MODE,
CHAT_COMMAND_MODE, CHAT_COMMAND_MODE,
GROUPCHAT_COMMAND_MODE, CONFERENCE_COMMAND_MODE,
}; };
void execute(WINDOW *w, ToxWindow *self, Tox *m, const char *input, int mode); void execute(WINDOW *w, ToxWindow *self, Tox *m, const char *input, int mode);

View File

@ -116,8 +116,8 @@ static void realloc_blocklist(int n)
void kill_friendlist(ToxWindow *self) void kill_friendlist(ToxWindow *self)
{ {
for (size_t i = 0; i < Friends.max_idx; ++i) { for (size_t i = 0; i < Friends.max_idx; ++i) {
if (Friends.list[i].active && Friends.list[i].group_invite.key != NULL) { if (Friends.list[i].active && Friends.list[i].conference_invite.key != NULL) {
free(Friends.list[i].group_invite.key); free(Friends.list[i].conference_invite.key);
} }
} }
@ -603,12 +603,13 @@ static void friendlist_onFileRecv(ToxWindow *self, Tox *m, uint32_t num, uint32_
sound_notify(prompt, notif_error, NT_WNDALERT_1, NULL); sound_notify(prompt, notif_error, NT_WNDALERT_1, NULL);
} }
static void friendlist_onGroupInvite(ToxWindow *self, Tox *m, int32_t num, uint8_t type, const char *group_pub_key, static void friendlist_onConferenceInvite(ToxWindow *self, Tox *m, int32_t num, uint8_t type,
uint16_t length) const char *conference_pub_key,
uint16_t length)
{ {
UNUSED_VAR(self); UNUSED_VAR(self);
UNUSED_VAR(type); UNUSED_VAR(type);
UNUSED_VAR(group_pub_key); UNUSED_VAR(conference_pub_key);
UNUSED_VAR(length); UNUSED_VAR(length);
if (num >= Friends.max_idx) { if (num >= Friends.max_idx) {
@ -628,7 +629,7 @@ static void friendlist_onGroupInvite(ToxWindow *self, Tox *m, int32_t num, uint8
get_nick_truncate(m, nick, num); get_nick_truncate(m, nick, num);
line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, RED, line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, RED,
"* Group chat invite from %s failed: too many windows are open.", nick); "* Conference chat invite from %s failed: too many windows are open.", nick);
sound_notify(prompt, notif_error, NT_WNDALERT_1, NULL); sound_notify(prompt, notif_error, NT_WNDALERT_1, NULL);
} }
@ -674,8 +675,8 @@ static void delete_friend(Tox *m, uint32_t f_num)
} }
} }
if (Friends.list[f_num].group_invite.key != NULL) { if (Friends.list[f_num].conference_invite.key != NULL) {
free(Friends.list[f_num].group_invite.key); free(Friends.list[f_num].conference_invite.key);
} }
memset(&Friends.list[f_num], 0, sizeof(ToxicFriend)); memset(&Friends.list[f_num], 0, sizeof(ToxicFriend));
@ -1333,7 +1334,7 @@ ToxWindow *new_friendlist(void)
ret->onStatusChange = &friendlist_onStatusChange; ret->onStatusChange = &friendlist_onStatusChange;
ret->onStatusMessageChange = &friendlist_onStatusMessageChange; ret->onStatusMessageChange = &friendlist_onStatusMessageChange;
ret->onFileRecv = &friendlist_onFileRecv; ret->onFileRecv = &friendlist_onFileRecv;
ret->onGroupInvite = &friendlist_onGroupInvite; ret->onConferenceInvite = &friendlist_onConferenceInvite;
#ifdef AUDIO #ifdef AUDIO
ret->onInvite = &friendlist_onAV; ret->onInvite = &friendlist_onAV;

View File

@ -35,7 +35,7 @@ struct LastOnline {
char hour_min_str[TIME_STR_SIZE]; /* holds 12/24-hour time string e.g. "10:43 PM" */ char hour_min_str[TIME_STR_SIZE]; /* holds 12/24-hour time string e.g. "10:43 PM" */
}; };
struct GroupChatInvite { struct ConferenceInvite {
char *key; char *key;
uint16_t length; uint16_t length;
uint8_t type; uint8_t type;
@ -57,7 +57,7 @@ typedef struct {
Tox_User_Status status; Tox_User_Status status;
struct LastOnline last_online; struct LastOnline last_online;
struct GroupChatInvite group_invite; struct ConferenceInvite conference_invite;
struct FileTransfer file_receiver[MAX_FILES]; struct FileTransfer file_receiver[MAX_FILES];
struct FileTransfer file_sender[MAX_FILES]; struct FileTransfer file_sender[MAX_FILES];

View File

@ -29,7 +29,7 @@
#include "friendlist.h" #include "friendlist.h"
#include "log.h" #include "log.h"
#include "line_info.h" #include "line_info.h"
#include "groupchat.h" #include "conference.h"
#include "prompt.h" #include "prompt.h"
#include "help.h" #include "help.h"
#include "term_mplex.h" #include "term_mplex.h"
@ -336,7 +336,7 @@ void cmd_decline(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)
--FrndRequests.num_requests; --FrndRequests.num_requests;
} }
void cmd_groupchat(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]) void cmd_conference(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{ {
UNUSED_VAR(window); UNUSED_VAR(window);
@ -346,7 +346,7 @@ void cmd_groupchat(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*arg
} }
if (argc < 1) { if (argc < 1) {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Please specify group type: text | audio"); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Please specify conference type: text | audio");
return; return;
} }
@ -357,31 +357,31 @@ void cmd_groupchat(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*arg
} else if (!strcasecmp(argv[1], "text")) { } else if (!strcasecmp(argv[1], "text")) {
type = TOX_CONFERENCE_TYPE_TEXT; type = TOX_CONFERENCE_TYPE_TEXT;
} else { } else {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Valid group types are: text | audio"); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Valid conference types are: text | audio");
return; return;
} }
if (type != TOX_CONFERENCE_TYPE_TEXT) { if (type != TOX_CONFERENCE_TYPE_TEXT) {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Toxic does not support audio groups."); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Toxic does not support audio conferences.");
return; return;
} }
Tox_Err_Conference_New err; Tox_Err_Conference_New err;
uint32_t groupnum = tox_conference_new(m, &err); uint32_t conferencenum = tox_conference_new(m, &err);
if (err != TOX_ERR_CONFERENCE_NEW_OK) { if (err != TOX_ERR_CONFERENCE_NEW_OK) {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Group chat instance failed to initialize (error %d)", err); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Conference instance failed to initialize (error %d)", err);
return; return;
} }
if (init_groupchat_win(m, groupnum, type, NULL, 0) == -1) { if (init_conference_win(m, conferencenum, 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, "Conference window failed to initialize.");
tox_conference_delete(m, groupnum, NULL); tox_conference_delete(m, conferencenum, NULL);
return; return;
} }
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Group chat [%d] created.", groupnum); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Conference [%d] created.", conferencenum);
} }
void cmd_log(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]) void cmd_log(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
@ -415,8 +415,8 @@ void cmd_log(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX
log_ret = log_enable(self->name, myid, Friends.list[self->num].pub_key, log, LOG_CHAT); log_ret = log_enable(self->name, myid, Friends.list[self->num].pub_key, log, LOG_CHAT);
} else if (self->is_prompt) { } else if (self->is_prompt) {
log_ret = log_enable(self->name, myid, NULL, log, LOG_PROMPT); log_ret = log_enable(self->name, myid, NULL, log, LOG_PROMPT);
} else if (self->is_groupchat) { } else if (self->is_conference) {
log_ret = log_enable(self->name, myid, NULL, log, LOG_GROUP); log_ret = log_enable(self->name, myid, NULL, log, LOG_CONFERENCE);
} }
msg = log_ret == 0 ? "Logging enabled." : "Warning: Log failed to initialize."; msg = log_ret == 0 ? "Logging enabled." : "Warning: Log failed to initialize.";

View File

@ -32,7 +32,7 @@ void cmd_avatar(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
void cmd_clear(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_clear(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
void cmd_connect(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_connect(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
void cmd_decline(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_decline(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
void cmd_groupchat(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_conference(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
void cmd_log(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_log(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
void cmd_myid(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]); void cmd_myid(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
#ifdef QRCODE #ifdef QRCODE

View File

@ -101,11 +101,11 @@ static void help_draw_menu(ToxWindow *self)
wattroff(win, A_BOLD | COLOR_PAIR(BLUE)); wattroff(win, A_BOLD | COLOR_PAIR(BLUE));
wprintw(win, "hat commands\n"); wprintw(win, "hat commands\n");
wprintw(win, " g"); wprintw(win, " c");
wattron(win, A_BOLD | COLOR_PAIR(BLUE)); wattron(win, A_BOLD | COLOR_PAIR(BLUE));
wprintw(win, "r"); wprintw(win, "o");
wattroff(win, A_BOLD | COLOR_PAIR(BLUE)); wattroff(win, A_BOLD | COLOR_PAIR(BLUE));
wprintw(win, "oup commands\n"); wprintw(win, "nference commands\n");
#ifdef PYTHON #ifdef PYTHON
wattron(win, A_BOLD | COLOR_PAIR(BLUE)); wattron(win, A_BOLD | COLOR_PAIR(BLUE));
@ -176,7 +176,7 @@ static void help_draw_global(ToxWindow *self)
wprintw(win, " /nick <nick> : Set your nickname\n"); wprintw(win, " /nick <nick> : Set your nickname\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, " /group <type> : Create a group chat where type: text | audio\n"); wprintw(win, " /conference <type> : Create a conference where type: text | audio\n");
wprintw(win, " /myid : Print your Tox ID\n"); wprintw(win, " /myid : Print your Tox ID\n");
#ifdef QRCODE #ifdef QRCODE
#ifdef QRPNG #ifdef QRPNG
@ -231,8 +231,8 @@ static void help_draw_chat(ToxWindow *self)
wprintw(win, "Chat Commands:\n"); wprintw(win, "Chat Commands:\n");
wattroff(win, A_BOLD | COLOR_PAIR(RED)); wattroff(win, A_BOLD | COLOR_PAIR(RED));
wprintw(win, " /invite <n> : Invite contact to a group chat\n"); wprintw(win, " /invite <n> : Invite contact to a conference \n");
wprintw(win, " /join : Join a pending group chat\n"); wprintw(win, " /join : Join a pending conference\n");
wprintw(win, " /sendfile <path> : Send a file\n"); wprintw(win, " /sendfile <path> : Send a file\n");
wprintw(win, " /savefile <id> : Receive a file\n"); wprintw(win, " /savefile <id> : Receive a file\n");
wprintw(win, " /cancel <type> <id> : Cancel file transfer where type: in|out\n"); wprintw(win, " /cancel <type> <id> : Cancel file transfer where type: in|out\n");
@ -279,8 +279,8 @@ static void help_draw_keys(ToxWindow *self)
wprintw(win, " Page Up and Page Down : Scroll window history one line\n"); wprintw(win, " Page Up and Page Down : Scroll window history one line\n");
wprintw(win, " Ctrl+F and Ctrl+V : Scroll window history half a page\n"); wprintw(win, " Ctrl+F and Ctrl+V : Scroll window history half a page\n");
wprintw(win, " Ctrl+H : Move to the bottom of window history\n"); wprintw(win, " Ctrl+H : Move to the bottom of window history\n");
wprintw(win, " Ctrl+up and Ctrl+down : Scroll peer list in groupchats\n"); wprintw(win, " Ctrl+up and Ctrl+down : Scroll peer list in conference\n");
wprintw(win, " Ctrl+B : Toggle the groupchat peerlist\n"); wprintw(win, " Ctrl+B : Toggle the conference peerlist\n");
wprintw(win, " Ctrl+J : Insert new line\n"); wprintw(win, " Ctrl+J : Insert new line\n");
wprintw(win, " Ctrl+T : Toggle paste mode\n\n"); wprintw(win, " Ctrl+T : Toggle paste mode\n\n");
wprintw(win, " (Note: Custom keybindings override these defaults.)\n\n"); wprintw(win, " (Note: Custom keybindings override these defaults.)\n\n");
@ -291,17 +291,17 @@ static void help_draw_keys(ToxWindow *self)
wnoutrefresh(win); wnoutrefresh(win);
} }
static void help_draw_group(ToxWindow *self) static void help_draw_conference(ToxWindow *self)
{ {
WINDOW *win = self->help->win; WINDOW *win = self->help->win;
wmove(win, 1, 1); wmove(win, 1, 1);
wattron(win, A_BOLD | COLOR_PAIR(RED)); wattron(win, A_BOLD | COLOR_PAIR(RED));
wprintw(win, "Group commands:\n"); wprintw(win, "Conference commands:\n");
wattroff(win, A_BOLD | COLOR_PAIR(RED)); wattroff(win, A_BOLD | COLOR_PAIR(RED));
wprintw(win, " /title <msg> : Set group title (show current title if no msg)\n\n"); wprintw(win, " /title <msg> : Set conference title (show current title if no msg)\n\n");
help_draw_bottom_menu(win); help_draw_bottom_menu(win);
@ -386,9 +386,9 @@ void help_onKey(ToxWindow *self, wint_t key)
self->help->type = HELP_GLOBAL; self->help->type = HELP_GLOBAL;
break; break;
case L'r': case L'o':
help_init_window(self, 6, 80); help_init_window(self, 6, 80);
self->help->type = HELP_GROUP; self->help->type = HELP_CONFERENCE;
break; break;
#ifdef PYTHON #ifdef PYTHON
@ -439,8 +439,8 @@ void help_onDraw(ToxWindow *self)
help_draw_contacts(self); help_draw_contacts(self);
break; break;
case HELP_GROUP: case HELP_CONFERENCE:
help_draw_group(self); help_draw_conference(self);
break; break;
#ifdef PYTHON #ifdef PYTHON

View File

@ -30,7 +30,7 @@ typedef enum {
HELP_MENU, HELP_MENU,
HELP_GLOBAL, HELP_GLOBAL,
HELP_CHAT, HELP_CHAT,
HELP_GROUP, HELP_CONFERENCE,
HELP_KEYS, HELP_KEYS,
HELP_CONTACTS, HELP_CONTACTS,
#ifdef PYTHON #ifdef PYTHON

View File

@ -32,7 +32,7 @@
#include "toxic_strings.h" #include "toxic_strings.h"
#include "line_info.h" #include "line_info.h"
#include "notify.h" #include "notify.h"
#include "groupchat.h" #include "conference.h"
#include "settings.h" #include "settings.h"
extern struct user_settings *user_settings; extern struct user_settings *user_settings;
@ -334,9 +334,9 @@ bool input_handle(ToxWindow *self, wint_t key, int x, int mx_x)
maybe convert entire function to if/else and make them all customizable keys? */ maybe convert entire function to if/else and make them all customizable keys? */
if (!match) { if (!match) {
if (key == user_settings->key_toggle_peerlist) { if (key == user_settings->key_toggle_peerlist) {
if (self->is_groupchat) { if (self->is_conference) {
self->show_peerlist ^= 1; self->show_peerlist ^= 1;
redraw_groupchat_win(self); redraw_conference_win(self);
} }
match = true; match = true;

View File

@ -28,7 +28,7 @@
#include "toxic.h" #include "toxic.h"
#include "windows.h" #include "windows.h"
#include "line_info.h" #include "line_info.h"
#include "groupchat.h" #include "conference.h"
#include "settings.h" #include "settings.h"
#include "notify.h" #include "notify.h"
#include "message_queue.h" #include "message_queue.h"
@ -277,7 +277,7 @@ static void line_info_check_queue(ToxWindow *self)
return; return;
} }
int offst = self->show_peerlist ? SIDEBAR_WIDTH : 0; /* offset width of groupchat sidebar */ int offst = self->show_peerlist ? SIDEBAR_WIDTH : 0; /* offset width of conference sidebar */
int lines = 1 + line->newlines + (line->len / (x2 - offst)); int lines = 1 + line->newlines + (line->len / (x2 - offst));
int max_y = y2 - CHATBOX_HEIGHT; int max_y = y2 - CHATBOX_HEIGHT;
@ -318,7 +318,7 @@ void line_info_print(ToxWindow *self)
return; return;
} }
if (self->is_groupchat) { if (self->is_conference) {
wmove(win, 0, 0); wmove(win, 0, 0);
} else { } else {
wmove(win, 2, 0); wmove(win, 2, 0);

View File

@ -35,10 +35,10 @@
extern struct user_settings *user_settings; extern struct user_settings *user_settings;
/* There are three types of logs: chat logs, groupchat logs, and prompt logs (see LOG_TYPE in log.h) /* There are three types of logs: chat logs, conference logs, and prompt logs (see LOG_TYPE in log.h)
A prompt log is in the format: LOGDIR/selfkey-home.log A prompt log is in the format: LOGDIR/selfkey-home.log
A chat log is in the format: LOGDIR/selfkey-friendname-otherkey.log A chat log is in the format: LOGDIR/selfkey-friendname-otherkey.log
A groupchat log is in the format: LOGDIR/selfkey-groupname-date[time].log A conference log is in the format: LOGDIR/selfkey-conferencename-date[time].log
Only the first (KEY_IDENT_DIGITS * 2) numbers of the key are used. Only the first (KEY_IDENT_DIGITS * 2) numbers of the key are used.
@ -75,7 +75,7 @@ static int get_log_path(char *dest, int destsize, char *name, const char *selfke
other_id[KEY_IDENT_DIGITS * 2] = '\0'; other_id[KEY_IDENT_DIGITS * 2] = '\0';
break; break;
case LOG_GROUP: case LOG_CONFERENCE:
strftime(other_id, sizeof(other_id), "%Y-%m-%d[%H:%M:%S]", get_time()); strftime(other_id, sizeof(other_id), "%Y-%m-%d[%H:%M:%S]", get_time());
path_len += strlen(other_id); path_len += strlen(other_id);
break; break;

View File

@ -31,7 +31,7 @@ struct chatlog {
}; };
typedef enum { typedef enum {
LOG_GROUP, LOG_CONFERENCE,
LOG_PROMPT, LOG_PROMPT,
LOG_CHAT, LOG_CHAT,
} LOG_TYPE; } LOG_TYPE;

View File

@ -406,16 +406,16 @@ on_error:
return len; return len;
} }
/* same as get_nick_truncate but for groupchats */ /* same as get_nick_truncate but for conferences */
int get_group_nick_truncate(Tox *m, char *buf, uint32_t peernum, uint32_t groupnum) int get_conference_nick_truncate(Tox *m, char *buf, uint32_t peernum, uint32_t conferencenum)
{ {
Tox_Err_Conference_Peer_Query err; Tox_Err_Conference_Peer_Query err;
size_t len = tox_conference_peer_get_name_size(m, groupnum, peernum, &err); size_t len = tox_conference_peer_get_name_size(m, conferencenum, peernum, &err);
if (err != TOX_ERR_CONFERENCE_PEER_QUERY_OK) { if (err != TOX_ERR_CONFERENCE_PEER_QUERY_OK) {
goto on_error; goto on_error;
} else { } else {
if (!tox_conference_peer_get_name(m, groupnum, peernum, (uint8_t *) buf, NULL)) { if (!tox_conference_peer_get_name(m, conferencenum, peernum, (uint8_t *) buf, NULL)) {
goto on_error; goto on_error;
} }
} }
@ -565,7 +565,7 @@ void set_window_title(ToxWindow *self, const char *title, int len)
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_conference) { /* keep conferencenumber in title */
snprintf(cpy, sizeof(cpy), "%u %s", self->num, title); snprintf(cpy, sizeof(cpy), "%u %s", self->num, title);
} else { } else {
snprintf(cpy, sizeof(cpy), "%s", title); snprintf(cpy, sizeof(cpy), "%s", title);

View File

@ -145,8 +145,8 @@ void str_to_lower(char *str);
Returns nick len on success, -1 on failure */ Returns nick len on success, -1 on failure */
size_t get_nick_truncate(Tox *m, char *buf, uint32_t friendnum); size_t get_nick_truncate(Tox *m, char *buf, uint32_t friendnum);
/* same as get_nick_truncate but for groupchats */ /* same as get_nick_truncate but for conferences */
int get_group_nick_truncate(Tox *m, char *buf, uint32_t peernum, uint32_t groupnum); int get_conference_nick_truncate(Tox *m, char *buf, uint32_t peernum, uint32_t conferencenum);
/* copies data to msg buffer. /* copies data to msg buffer.
returns length of msg, which will be no larger than size-1 */ returns length of msg, which will be no larger than size-1 */

View File

@ -59,7 +59,7 @@ static const char *glob_cmd_list[] = {
"/connect", "/connect",
"/decline", "/decline",
"/exit", "/exit",
"/group", "/conference",
"/help", "/help",
"/log", "/log",
"/myid", "/myid",

View File

@ -252,13 +252,13 @@ PyMODINIT_FUNC PyInit_toxic_api(void)
PyObject *m = PyModule_Create(&toxic_api_module); PyObject *m = PyModule_Create(&toxic_api_module);
PyObject *global_command_const = Py_BuildValue("i", GLOBAL_COMMAND_MODE); PyObject *global_command_const = Py_BuildValue("i", GLOBAL_COMMAND_MODE);
PyObject *chat_command_const = Py_BuildValue("i", CHAT_COMMAND_MODE); PyObject *chat_command_const = Py_BuildValue("i", CHAT_COMMAND_MODE);
PyObject *groupchat_command_const = Py_BuildValue("i", GROUPCHAT_COMMAND_MODE); PyObject *conference_command_const = Py_BuildValue("i", CONFERENCE_COMMAND_MODE);
PyObject_SetAttrString(m, "GLOBAL_COMMAND", global_command_const); PyObject_SetAttrString(m, "GLOBAL_COMMAND", global_command_const);
PyObject_SetAttrString(m, "CHAT_COMMAND", chat_command_const); PyObject_SetAttrString(m, "CHAT_COMMAND", chat_command_const);
PyObject_SetAttrString(m, "GROUPCHAT_COMMAND", groupchat_command_const); PyObject_SetAttrString(m, "CONFERENCE_COMMAND", conference_command_const);
Py_DECREF(global_command_const); Py_DECREF(global_command_const);
Py_DECREF(chat_command_const); Py_DECREF(chat_command_const);
Py_DECREF(groupchat_command_const); Py_DECREF(conference_command_const);
return m; return m;
} }

View File

@ -52,7 +52,7 @@
#include "friendlist.h" #include "friendlist.h"
#include "prompt.h" #include "prompt.h"
#include "misc_tools.h" #include "misc_tools.h"
#include "groupchat.h" #include "conference.h"
#include "file_transfers.h" #include "file_transfers.h"
#include "line_info.h" #include "line_info.h"
#include "settings.h" #include "settings.h"
@ -372,29 +372,29 @@ static void load_conferences(Tox *m)
tox_conference_get_chatlist(m, chatlist); tox_conference_get_chatlist(m, chatlist);
for (size_t i = 0; i < num_chats; ++i) { for (size_t i = 0; i < num_chats; ++i) {
uint32_t groupnum = chatlist[i]; uint32_t conferencenum = chatlist[i];
if (get_num_active_windows() >= MAX_WINDOWS_NUM) { if (get_num_active_windows() >= MAX_WINDOWS_NUM) {
tox_conference_delete(m, groupnum, NULL); tox_conference_delete(m, conferencenum, NULL);
continue; continue;
} }
Tox_Err_Conference_Get_Type err; Tox_Err_Conference_Get_Type err;
Tox_Conference_Type type = tox_conference_get_type(m, groupnum, &err); Tox_Conference_Type type = tox_conference_get_type(m, conferencenum, &err);
if (err != TOX_ERR_CONFERENCE_GET_TYPE_OK) { if (err != TOX_ERR_CONFERENCE_GET_TYPE_OK) {
tox_conference_delete(m, groupnum, NULL); tox_conference_delete(m, conferencenum, NULL);
continue; continue;
} }
Tox_Err_Conference_Title t_err; Tox_Err_Conference_Title t_err;
size_t length = tox_conference_get_title_size(m, groupnum, &t_err); size_t length = tox_conference_get_title_size(m, conferencenum, &t_err);
uint8_t title[MAX_STR_SIZE]; uint8_t title[MAX_STR_SIZE];
if (t_err != TOX_ERR_CONFERENCE_TITLE_OK || length >= sizeof(title)) { if (t_err != TOX_ERR_CONFERENCE_TITLE_OK || length >= sizeof(title)) {
length = 0; length = 0;
} else { } else {
tox_conference_get_title(m, groupnum, title, &t_err); tox_conference_get_title(m, conferencenum, title, &t_err);
if (t_err != TOX_ERR_CONFERENCE_TITLE_OK) { if (t_err != TOX_ERR_CONFERENCE_TITLE_OK) {
length = 0; length = 0;
@ -403,8 +403,8 @@ static void load_conferences(Tox *m)
title[length] = 0; title[length] = 0;
if (init_groupchat_win(m, groupnum, type, (const char *) title, length) == -1) { if (init_conference_win(m, conferencenum, type, (const char *) title, length) == -1) {
tox_conference_delete(m, groupnum, NULL); tox_conference_delete(m, conferencenum, NULL);
continue; continue;
} }
} }

View File

@ -115,14 +115,14 @@ void on_friend_name(Tox *m, uint32_t friendnumber, const uint8_t *string, size_t
void on_friend_status(Tox *m, uint32_t friendnumber, Tox_User_Status status, void *userdata); void on_friend_status(Tox *m, uint32_t friendnumber, Tox_User_Status status, void *userdata);
void on_friend_status_message(Tox *m, uint32_t friendnumber, const uint8_t *string, size_t length, void *userdata); void on_friend_status_message(Tox *m, uint32_t friendnumber, const uint8_t *string, size_t length, void *userdata);
void on_friend_added(Tox *m, uint32_t friendnumber, bool sort); void on_friend_added(Tox *m, uint32_t friendnumber, bool sort);
void on_conference_message(Tox *m, uint32_t groupnumber, uint32_t peernumber, Tox_Message_Type type, void on_conference_message(Tox *m, uint32_t conferencenumber, uint32_t peernumber, Tox_Message_Type type,
const uint8_t *message, size_t length, void *userdata); const uint8_t *message, size_t length, void *userdata);
void on_conference_invite(Tox *m, uint32_t friendnumber, Tox_Conference_Type type, const uint8_t *group_pub_key, void on_conference_invite(Tox *m, uint32_t friendnumber, Tox_Conference_Type type, const uint8_t *conference_pub_key,
size_t length, void *userdata); size_t length, void *userdata);
void on_conference_peer_list_changed(Tox *m, uint32_t groupnumber, void *userdata); void on_conference_peer_list_changed(Tox *m, uint32_t conferencenumber, void *userdata);
void on_conference_peer_name(Tox *m, uint32_t groupnumber, uint32_t peernumber, const uint8_t *name, void on_conference_peer_name(Tox *m, uint32_t conferencenumber, uint32_t peernumber, const uint8_t *name,
size_t length, void *userdata); size_t length, void *userdata);
void on_conference_title(Tox *m, uint32_t groupnumber, uint32_t peernumber, const uint8_t *title, size_t length, void on_conference_title(Tox *m, uint32_t conferencenumber, uint32_t peernumber, const uint8_t *title, size_t length,
void *userdata); void *userdata);
void on_file_chunk_request(Tox *m, uint32_t friendnumber, uint32_t filenumber, uint64_t position, size_t length, void on_file_chunk_request(Tox *m, uint32_t friendnumber, uint32_t filenumber, uint64_t position, size_t length,
void *userdata); void *userdata);

View File

@ -29,7 +29,7 @@
#include "prompt.h" #include "prompt.h"
#include "toxic.h" #include "toxic.h"
#include "windows.h" #include "windows.h"
#include "groupchat.h" #include "conference.h"
#include "chat.h" #include "chat.h"
#include "line_info.h" #include "line_info.h"
#include "misc_tools.h" #include "misc_tools.h"
@ -158,7 +158,7 @@ void on_friend_added(Tox *m, uint32_t friendnumber, bool sort)
store_data(m, DATA_FILE); store_data(m, DATA_FILE);
} }
void on_conference_message(Tox *m, uint32_t groupnumber, uint32_t peernumber, Tox_Message_Type type, void on_conference_message(Tox *m, uint32_t conferencenumber, uint32_t peernumber, Tox_Message_Type type,
const uint8_t *message, size_t length, void *userdata) const uint8_t *message, size_t length, void *userdata)
{ {
UNUSED_VAR(userdata); UNUSED_VAR(userdata);
@ -167,36 +167,36 @@ void on_conference_message(Tox *m, uint32_t groupnumber, uint32_t peernumber, To
length = copy_tox_str(msg, sizeof(msg), (const char *) message, length); length = copy_tox_str(msg, sizeof(msg), (const char *) message, length);
for (uint8_t i = 0; i < MAX_WINDOWS_NUM; ++i) { for (uint8_t i = 0; i < MAX_WINDOWS_NUM; ++i) {
if (windows[i] != NULL && windows[i]->onGroupMessage != NULL) { if (windows[i] != NULL && windows[i]->onConferenceMessage != NULL) {
windows[i]->onGroupMessage(windows[i], m, groupnumber, peernumber, type, msg, length); windows[i]->onConferenceMessage(windows[i], m, conferencenumber, peernumber, type, msg, length);
} }
} }
} }
void on_conference_invite(Tox *m, uint32_t friendnumber, Tox_Conference_Type type, const uint8_t *group_pub_key, void on_conference_invite(Tox *m, uint32_t friendnumber, Tox_Conference_Type type, const uint8_t *conference_pub_key,
size_t length, void *userdata) size_t length, void *userdata)
{ {
UNUSED_VAR(userdata); UNUSED_VAR(userdata);
for (uint8_t i = 0; i < MAX_WINDOWS_NUM; ++i) { for (uint8_t i = 0; i < MAX_WINDOWS_NUM; ++i) {
if (windows[i] != NULL && windows[i]->onGroupInvite != NULL) { if (windows[i] != NULL && windows[i]->onConferenceInvite != NULL) {
windows[i]->onGroupInvite(windows[i], m, friendnumber, type, (char *) group_pub_key, length); windows[i]->onConferenceInvite(windows[i], m, friendnumber, type, (char *) conference_pub_key, length);
} }
} }
} }
void on_conference_peer_list_changed(Tox *m, uint32_t groupnumber, void *userdata) void on_conference_peer_list_changed(Tox *m, uint32_t conferencenumber, void *userdata)
{ {
UNUSED_VAR(userdata); UNUSED_VAR(userdata);
for (uint8_t i = 0; i < MAX_WINDOWS_NUM; ++i) { for (uint8_t i = 0; i < MAX_WINDOWS_NUM; ++i) {
if (windows[i] != NULL && windows[i]->onGroupNameListChange != NULL) { if (windows[i] != NULL && windows[i]->onConferenceNameListChange != NULL) {
windows[i]->onGroupNameListChange(windows[i], m, groupnumber); windows[i]->onConferenceNameListChange(windows[i], m, conferencenumber);
} }
} }
} }
void on_conference_peer_name(Tox *m, uint32_t groupnumber, uint32_t peernumber, const uint8_t *name, void on_conference_peer_name(Tox *m, uint32_t conferencenumber, uint32_t peernumber, const uint8_t *name,
size_t length, void *userdata) size_t length, void *userdata)
{ {
UNUSED_VAR(userdata); UNUSED_VAR(userdata);
@ -206,13 +206,13 @@ void on_conference_peer_name(Tox *m, uint32_t groupnumber, uint32_t peernumber,
filter_str(nick, length); filter_str(nick, length);
for (uint8_t i = 0; i < MAX_WINDOWS_NUM; ++i) { for (uint8_t i = 0; i < MAX_WINDOWS_NUM; ++i) {
if (windows[i] != NULL && windows[i]->onGroupPeerNameChange != NULL) { if (windows[i] != NULL && windows[i]->onConferencePeerNameChange != NULL) {
windows[i]->onGroupPeerNameChange(windows[i], m, groupnumber, peernumber, nick, length); windows[i]->onConferencePeerNameChange(windows[i], m, conferencenumber, peernumber, nick, length);
} }
} }
} }
void on_conference_title(Tox *m, uint32_t groupnumber, uint32_t peernumber, const uint8_t *title, size_t length, void on_conference_title(Tox *m, uint32_t conferencenumber, uint32_t peernumber, const uint8_t *title, size_t length,
void *userdata) void *userdata)
{ {
UNUSED_VAR(userdata); UNUSED_VAR(userdata);
@ -221,8 +221,8 @@ void on_conference_title(Tox *m, uint32_t groupnumber, uint32_t peernumber, cons
length = copy_tox_str(data, sizeof(data), (const char *) title, length); length = copy_tox_str(data, sizeof(data), (const char *) title, length);
for (uint8_t i = 0; i < MAX_WINDOWS_NUM; ++i) { for (uint8_t i = 0; i < MAX_WINDOWS_NUM; ++i) {
if (windows[i] != NULL && windows[i]->onGroupTitleChange != NULL) { if (windows[i] != NULL && windows[i]->onConferenceTitleChange != NULL) {
windows[i]->onGroupTitleChange(windows[i], m, groupnumber, peernumber, data, length); windows[i]->onConferenceTitleChange(windows[i], m, conferencenumber, peernumber, data, length);
} }
} }
} }
@ -454,7 +454,7 @@ void on_window_resize(void)
wclear(w->help->win); wclear(w->help->win);
} }
if (w->is_groupchat) { if (w->is_conference) {
delwin(w->chatwin->sidebar); delwin(w->chatwin->sidebar);
w->chatwin->sidebar = NULL; w->chatwin->sidebar = NULL;
} else { } else {
@ -474,7 +474,7 @@ void on_window_resize(void)
} else { } else {
w->chatwin->history = subwin(w->window, y2 - CHATBOX_HEIGHT + 1, x2, 0, 0); w->chatwin->history = subwin(w->window, y2 - CHATBOX_HEIGHT + 1, x2, 0, 0);
if (!w->is_groupchat) { if (!w->is_conference) {
w->stb->topline = subwin(w->window, 2, x2, 0, 0); w->stb->topline = subwin(w->window, 2, x2, 0, 0);
} }
} }
@ -754,7 +754,7 @@ int get_num_active_windows(void)
return num_active_windows; return num_active_windows;
} }
/* destroys all chat and groupchat windows (should only be called on shutdown) */ /* destroys all chat and conference windows (should only be called on shutdown) */
void kill_all_windows(Tox *m) void kill_all_windows(Tox *m)
{ {
for (uint8_t i = 2; i < MAX_WINDOWS_NUM; ++i) { for (uint8_t i = 2; i < MAX_WINDOWS_NUM; ++i) {
@ -764,8 +764,8 @@ void kill_all_windows(Tox *m)
if (windows[i]->is_chat) { if (windows[i]->is_chat) {
kill_chat_window(windows[i], m); kill_chat_window(windows[i], m);
} else if (windows[i]->is_groupchat) { } else if (windows[i]->is_conference) {
free_groupchat(windows[i], windows[i]->num); free_conference(windows[i], windows[i]->num);
} }
} }

View File

@ -125,11 +125,11 @@ struct ToxWindow {
void(*onNickChange)(ToxWindow *, Tox *, uint32_t, const char *, size_t); void(*onNickChange)(ToxWindow *, Tox *, uint32_t, const char *, size_t);
void(*onStatusChange)(ToxWindow *, Tox *, uint32_t, Tox_User_Status); void(*onStatusChange)(ToxWindow *, Tox *, uint32_t, Tox_User_Status);
void(*onStatusMessageChange)(ToxWindow *, uint32_t, const char *, size_t); void(*onStatusMessageChange)(ToxWindow *, uint32_t, const char *, size_t);
void(*onGroupMessage)(ToxWindow *, Tox *, uint32_t, uint32_t, Tox_Message_Type, const char *, size_t); void(*onConferenceMessage)(ToxWindow *, Tox *, uint32_t, uint32_t, Tox_Message_Type, const char *, size_t);
void(*onGroupInvite)(ToxWindow *, Tox *, int32_t, uint8_t, const char *, uint16_t); void(*onConferenceInvite)(ToxWindow *, Tox *, int32_t, uint8_t, const char *, uint16_t);
void(*onGroupNameListChange)(ToxWindow *, Tox *, uint32_t); void(*onConferenceNameListChange)(ToxWindow *, Tox *, uint32_t);
void(*onGroupPeerNameChange)(ToxWindow *, Tox *, uint32_t, uint32_t, const char *, size_t); void(*onConferencePeerNameChange)(ToxWindow *, Tox *, uint32_t, uint32_t, const char *, size_t);
void(*onGroupTitleChange)(ToxWindow *, Tox *, uint32_t, uint32_t, const char *, size_t); void(*onConferenceTitleChange)(ToxWindow *, Tox *, uint32_t, uint32_t, const char *, size_t);
void(*onFileChunkRequest)(ToxWindow *, Tox *, uint32_t, uint32_t, uint64_t, size_t); void(*onFileChunkRequest)(ToxWindow *, Tox *, uint32_t, uint32_t, uint64_t, size_t);
void(*onFileRecvChunk)(ToxWindow *, Tox *, uint32_t, uint32_t, uint64_t, const char *, size_t); void(*onFileRecvChunk)(ToxWindow *, Tox *, uint32_t, uint32_t, uint64_t, const char *, size_t);
void(*onFileControl)(ToxWindow *, Tox *, uint32_t, uint32_t, Tox_File_Control); void(*onFileControl)(ToxWindow *, Tox *, uint32_t, uint32_t, Tox_File_Control);
@ -172,8 +172,8 @@ struct ToxWindow {
bool is_chat; bool is_chat;
bool is_prompt; bool is_prompt;
bool is_friendlist; bool is_friendlist;
bool is_groupchat; bool is_conference;
int show_peerlist; /* used to toggle groupchat peerlist */ int show_peerlist; /* used to toggle conference peerlist */
WINDOW_ALERTS alert; WINDOW_ALERTS alert;
@ -218,7 +218,7 @@ struct infobox {
#define MAX_LINE_HIST 128 #define MAX_LINE_HIST 128
/* chat and groupchat window/buffer holder */ /* chat and conference window/buffer holder */
struct ChatContext { struct ChatContext {
wchar_t line[MAX_STR_SIZE]; wchar_t line[MAX_STR_SIZE];
int pos; int pos;