mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-25 23:53:02 +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:
parent
811fbfbb1e
commit
4188b392cc
2
Makefile
2
Makefile
@ -14,7 +14,7 @@ LDFLAGS ?=
|
||||
LDFLAGS += ${USER_LDFLAGS}
|
||||
|
||||
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 += term_mplex.o toxic.o toxic_strings.o windows.o
|
||||
|
||||
|
31
src/chat.c
31
src/chat.c
@ -75,7 +75,7 @@ static const char *chat_cmd_list[] = {
|
||||
"/close",
|
||||
"/connect",
|
||||
"/exit",
|
||||
"/group",
|
||||
"/conference",
|
||||
"/help",
|
||||
"/invite",
|
||||
"/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,
|
||||
uint16_t length)
|
||||
static void chat_onConferenceInvite(ToxWindow *self, Tox *m, int32_t friendnumber, uint8_t type,
|
||||
const char *conference_pub_key,
|
||||
uint16_t length)
|
||||
{
|
||||
if (self->num != friendnumber) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Friends.list[friendnumber].group_invite.key != NULL) {
|
||||
free(Friends.list[friendnumber].group_invite.key);
|
||||
if (Friends.list[friendnumber].conference_invite.key != NULL) {
|
||||
free(Friends.list[friendnumber].conference_invite.key);
|
||||
}
|
||||
|
||||
char *k = malloc(length);
|
||||
|
||||
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);
|
||||
Friends.list[friendnumber].group_invite.key = k;
|
||||
Friends.list[friendnumber].group_invite.pending = true;
|
||||
Friends.list[friendnumber].group_invite.length = length;
|
||||
Friends.list[friendnumber].group_invite.type = type;
|
||||
memcpy(k, conference_pub_key, length);
|
||||
Friends.list[friendnumber].conference_invite.key = k;
|
||||
Friends.list[friendnumber].conference_invite.pending = true;
|
||||
Friends.list[friendnumber].conference_invite.length = length;
|
||||
Friends.list[friendnumber].conference_invite.type = type;
|
||||
|
||||
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);
|
||||
|
||||
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 {
|
||||
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.");
|
||||
}
|
||||
|
||||
@ -1402,7 +1403,7 @@ ToxWindow *new_chat(Tox *m, uint32_t friendnum)
|
||||
ret->onMessage = &chat_onMessage;
|
||||
ret->onConnectionChange = &chat_onConnectionChange;
|
||||
ret->onTypingChange = & chat_onTypingChange;
|
||||
ret->onGroupInvite = &chat_onGroupInvite;
|
||||
ret->onConferenceInvite = &chat_onConferenceInvite;
|
||||
ret->onNickChange = &chat_onNickChange;
|
||||
ret->onStatusChange = &chat_onStatusChange;
|
||||
ret->onStatusMessageChange = &chat_onStatusMessageChange;
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "friendlist.h"
|
||||
#include "execute.h"
|
||||
#include "line_info.h"
|
||||
#include "groupchat.h"
|
||||
#include "conference.h"
|
||||
#include "chat.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);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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) {
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Invalid group number.");
|
||||
if ((conferencenum == 0 && strcmp(argv[1], "0")) || conferencenum < 0 || conferencenum == LONG_MAX) {
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Invalid conference number.");
|
||||
return;
|
||||
}
|
||||
|
||||
Tox_Err_Conference_Invite err;
|
||||
|
||||
if (!tox_conference_invite(m, self->num, groupnum, &err)) {
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to invite contact to group (error %d)", 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 conference (error %d)", err);
|
||||
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(argc);
|
||||
@ -117,32 +117,32 @@ void cmd_join_group(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*ar
|
||||
return;
|
||||
}
|
||||
|
||||
const char *groupkey = Friends.list[self->num].group_invite.key;
|
||||
uint16_t length = Friends.list[self->num].group_invite.length;
|
||||
uint8_t type = Friends.list[self->num].group_invite.type;
|
||||
const char *conferencekey = Friends.list[self->num].conference_invite.key;
|
||||
uint16_t length = Friends.list[self->num].conference_invite.length;
|
||||
uint8_t type = Friends.list[self->num].conference_invite.type;
|
||||
|
||||
if (!Friends.list[self->num].group_invite.pending) {
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "No pending group chat invite.");
|
||||
if (!Friends.list[self->num].conference_invite.pending) {
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "No pending conference invite.");
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
|
||||
if (init_groupchat_win(m, groupnum, type, NULL, 0) == -1) {
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Group chat window failed to initialize.");
|
||||
tox_conference_delete(m, groupnum, NULL);
|
||||
if (init_conference_win(m, conferencenum, type, NULL, 0) == -1) {
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Conference window failed to initialize.");
|
||||
tox_conference_delete(m, conferencenum, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -27,8 +27,8 @@
|
||||
#include "toxic.h"
|
||||
|
||||
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_join_group(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_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_sendfile(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* groupchat.c
|
||||
/* conference.c
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2014 Toxic All Rights Reserved.
|
||||
@ -50,7 +50,7 @@
|
||||
#include "toxic.h"
|
||||
#include "execute.h"
|
||||
#include "misc_tools.h"
|
||||
#include "groupchat.h"
|
||||
#include "conference.h"
|
||||
#include "prompt.h"
|
||||
#include "toxic_strings.h"
|
||||
#include "log.h"
|
||||
@ -64,14 +64,14 @@
|
||||
|
||||
extern char *DATA_FILE;
|
||||
|
||||
static GroupChat groupchats[MAX_GROUPCHAT_NUM];
|
||||
static int max_groupchat_index = 0;
|
||||
static ConferenceChat conferences[MAX_CONFERENCE_NUM];
|
||||
static int max_conference_index = 0;
|
||||
|
||||
extern struct user_settings *user_settings;
|
||||
extern struct Winthread Winthread;
|
||||
|
||||
/* Array of groupchat command names used for tab completion. */
|
||||
static const char *group_cmd_list[] = {
|
||||
/* Array of conference command names used for tab completion. */
|
||||
static const char *conference_cmd_list[] = {
|
||||
"/accept",
|
||||
"/add",
|
||||
"/avatar",
|
||||
@ -80,7 +80,7 @@ static const char *group_cmd_list[] = {
|
||||
"/connect",
|
||||
"/decline",
|
||||
"/exit",
|
||||
"/group",
|
||||
"/conference",
|
||||
"/help",
|
||||
"/log",
|
||||
"/myid",
|
||||
@ -102,9 +102,9 @@ static const char *group_cmd_list[] = {
|
||||
#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;
|
||||
|
||||
@ -119,65 +119,65 @@ static void kill_groupchat_window(ToxWindow *self)
|
||||
del_window(self);
|
||||
}
|
||||
|
||||
int init_groupchat_win(Tox *m, uint32_t groupnum, uint8_t type, const char *title,
|
||||
size_t title_length)
|
||||
int init_conference_win(Tox *m, uint32_t conferencenum, uint8_t type, const char *title,
|
||||
size_t title_length)
|
||||
{
|
||||
if (groupnum > MAX_GROUPCHAT_NUM) {
|
||||
if (conferencenum > MAX_CONFERENCE_NUM) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ToxWindow *self = new_group_chat(groupnum);
|
||||
ToxWindow *self = new_conference_chat(conferencenum);
|
||||
|
||||
for (int i = 0; i <= max_groupchat_index; ++i) {
|
||||
if (!groupchats[i].active) {
|
||||
groupchats[i].chatwin = add_window(m, self);
|
||||
groupchats[i].active = true;
|
||||
groupchats[i].num_peers = 0;
|
||||
groupchats[i].type = type;
|
||||
groupchats[i].start_time = get_unix_time();
|
||||
for (int i = 0; i <= max_conference_index; ++i) {
|
||||
if (!conferences[i].active) {
|
||||
conferences[i].chatwin = add_window(m, self);
|
||||
conferences[i].active = true;
|
||||
conferences[i].num_peers = 0;
|
||||
conferences[i].type = type;
|
||||
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);
|
||||
|
||||
if (i == max_groupchat_index) {
|
||||
++max_groupchat_index;
|
||||
if (i == max_conference_index) {
|
||||
++max_conference_index;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
kill_groupchat_window(self);
|
||||
kill_conference_window(self);
|
||||
|
||||
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(groupchats[groupnum].peer_list);
|
||||
memset(&groupchats[groupnum], 0, sizeof(GroupChat));
|
||||
free_ptr_array((void **) conferences[conferencenum].name_list);
|
||||
free(conferences[conferencenum].peer_list);
|
||||
memset(&conferences[conferencenum], 0, sizeof(ConferenceChat));
|
||||
|
||||
int i;
|
||||
|
||||
for (i = max_groupchat_index; i > 0; --i) {
|
||||
if (groupchats[i - 1].active) {
|
||||
for (i = max_conference_index; i > 0; --i) {
|
||||
if (conferences[i - 1].active) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
max_groupchat_index = i;
|
||||
kill_groupchat_window(self);
|
||||
max_conference_index = i;
|
||||
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);
|
||||
free_groupchat(self, groupnum);
|
||||
tox_conference_delete(m, conferencenum, NULL);
|
||||
free_conference(self, conferencenum);
|
||||
}
|
||||
|
||||
/* destroys and re-creates groupchat window with or without the peerlist */
|
||||
void redraw_groupchat_win(ToxWindow *self)
|
||||
/* destroys and re-creates conference window with or without the peerlist */
|
||||
void redraw_conference_win(ToxWindow *self)
|
||||
{
|
||||
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,
|
||||
Tox_Message_Type type, const char *msg, size_t len)
|
||||
static void conference_onConferenceMessage(ToxWindow *self, Tox *m, uint32_t conferencenum, uint32_t peernum,
|
||||
Tox_Message_Type type, const char *msg, size_t len)
|
||||
{
|
||||
UNUSED_VAR(len);
|
||||
|
||||
if (self->num != groupnum) {
|
||||
if (self->num != conferencenum) {
|
||||
return;
|
||||
}
|
||||
|
||||
ChatContext *ctx = self->chatwin;
|
||||
|
||||
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];
|
||||
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);
|
||||
}
|
||||
|
||||
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,
|
||||
size_t length)
|
||||
{
|
||||
ChatContext *ctx = self->chatwin;
|
||||
|
||||
if (self->num != groupnum) {
|
||||
if (self->num != conferencenum) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -276,22 +276,22 @@ static void groupchat_onGroupTitleChange(ToxWindow *self, Tox *m, uint32_t group
|
||||
get_time_str(timefrmt, sizeof(timefrmt));
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
char nick[TOX_MAX_NAME_LENGTH];
|
||||
get_group_nick_truncate(m, nick, peernum, groupnum);
|
||||
line_info_add(self, timefrmt, nick, NULL, NAME_CHANGE, 0, 0, " set the group title to: %s", title);
|
||||
get_conference_nick_truncate(m, nick, peernum, conferencenum);
|
||||
line_info_add(self, timefrmt, nick, NULL, NAME_CHANGE, 0, 0, " set the conference title to: %s", title);
|
||||
|
||||
char tmp_event[MAX_STR_SIZE];
|
||||
snprintf(tmp_event, sizeof(tmp_event), "set title to %s", title);
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
|
||||
/* 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 -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) {
|
||||
return -1;
|
||||
@ -336,7 +336,7 @@ static int realloc_peer_list(GroupChat *chat, uint32_t num_peers)
|
||||
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) {
|
||||
return -1;
|
||||
@ -347,9 +347,9 @@ static int realloc_peer_list(GroupChat *chat, uint32_t num_peers)
|
||||
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) {
|
||||
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);
|
||||
|
||||
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;
|
||||
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) {
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (groupnum > max_groupchat_index) {
|
||||
if (conferencenum > max_conference_index) {
|
||||
return;
|
||||
}
|
||||
|
||||
GroupChat *chat = &groupchats[groupnum];
|
||||
ConferenceChat *chat = &conferences[conferencenum];
|
||||
|
||||
if (!chat->active) {
|
||||
return;
|
||||
@ -406,42 +406,42 @@ static void groupchat_onGroupNameListChange(ToxWindow *self, Tox *m, uint32_t gr
|
||||
|
||||
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) {
|
||||
fprintf(stderr, "groupchat_onGroupNameListChange() failed with error: %d\n", err);
|
||||
fprintf(stderr, "conference_onConferenceNameListChange() failed with error: %d\n", err);
|
||||
return;
|
||||
}
|
||||
|
||||
chat->name_list = (char **) malloc_ptr_array(num_peers, TOX_MAX_NAME_LENGTH + 1);
|
||||
|
||||
if (chat->name_list == NULL) {
|
||||
fprintf(stderr, "groupchat_onGroupNameListChange(): Out of memory.\n");
|
||||
fprintf(stderr, "conference_onConferenceNameListChange(): Out of memory.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
chat->num_peers = 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)
|
||||
{
|
||||
UNUSED_VAR(length);
|
||||
|
||||
if (self->num != groupnum) {
|
||||
if (self->num != conferencenum) {
|
||||
return;
|
||||
}
|
||||
|
||||
GroupChat *chat = &groupchats[groupnum];
|
||||
ConferenceChat *chat = &conferences[conferencenum];
|
||||
|
||||
if (!chat->active) {
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
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) {
|
||||
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
|
||||
*/
|
||||
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;
|
||||
|
||||
@ -525,7 +525,7 @@ static bool groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
|
||||
|
||||
/* TODO: make this not suck */
|
||||
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) {
|
||||
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
|
||||
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) {
|
||||
@ -555,14 +555,14 @@ static bool groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
|
||||
input_ret = true;
|
||||
const int L = y2 - CHATBOX_HEIGHT - SDBAR_OFST;
|
||||
|
||||
if (groupchats[self->num].side_pos < (int64_t) groupchats[self->num].num_peers - L) {
|
||||
++groupchats[self->num].side_pos;
|
||||
if (conferences[self->num].side_pos < (int64_t) conferences[self->num].num_peers - L) {
|
||||
++conferences[self->num].side_pos;
|
||||
}
|
||||
} else if (key == T_KEY_C_UP) {
|
||||
input_ret = true;
|
||||
|
||||
if (groupchats[self->num].side_pos > 0) {
|
||||
--groupchats[self->num].side_pos;
|
||||
if (conferences[self->num].side_pos > 0) {
|
||||
--conferences[self->num].side_pos;
|
||||
}
|
||||
} else if (key == L'\r') {
|
||||
input_ret = true;
|
||||
@ -581,12 +581,12 @@ static bool groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
|
||||
|
||||
if (line[0] == '/') {
|
||||
if (strcmp(line, "/close") == 0) {
|
||||
delete_groupchat(self, m, self->num);
|
||||
delete_conference(self, m, self->num);
|
||||
return true;
|
||||
} 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 {
|
||||
execute(ctx->history, self, m, line, GROUPCHAT_COMMAND_MODE);
|
||||
execute(ctx->history, self, m, line, CONFERENCE_COMMAND_MODE);
|
||||
}
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
static void groupchat_onDraw(ToxWindow *self, Tox *m)
|
||||
static void conference_onDraw(ToxWindow *self, Tox *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);
|
||||
|
||||
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);
|
||||
|
||||
wmove(ctx->sidebar, 0, 1);
|
||||
@ -655,7 +655,7 @@ static void groupchat_onDraw(ToxWindow *self, Tox *m)
|
||||
wmove(ctx->sidebar, i + 2, 1);
|
||||
|
||||
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);
|
||||
|
||||
/* 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;
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
getmaxyx(self->window, y2, x2);
|
||||
|
||||
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;
|
||||
@ -706,7 +706,7 @@ static void groupchat_onInit(ToxWindow *self, Tox *m)
|
||||
ctx->log = calloc(1, sizeof(struct chatlog));
|
||||
|
||||
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);
|
||||
@ -715,7 +715,7 @@ static void groupchat_onInit(ToxWindow *self, Tox *m)
|
||||
char myid[TOX_ADDRESS_SIZE];
|
||||
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.");
|
||||
}
|
||||
}
|
||||
@ -726,37 +726,37 @@ static void groupchat_onInit(ToxWindow *self, Tox *m)
|
||||
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));
|
||||
|
||||
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->onDraw = &groupchat_onDraw;
|
||||
ret->onInit = &groupchat_onInit;
|
||||
ret->onGroupMessage = &groupchat_onGroupMessage;
|
||||
ret->onGroupNameListChange = &groupchat_onGroupNameListChange;
|
||||
ret->onGroupPeerNameChange = &groupchat_onGroupPeerNameChange;
|
||||
ret->onGroupTitleChange = &groupchat_onGroupTitleChange;
|
||||
ret->onKey = &conference_onKey;
|
||||
ret->onDraw = &conference_onDraw;
|
||||
ret->onInit = &conference_onInit;
|
||||
ret->onConferenceMessage = &conference_onConferenceMessage;
|
||||
ret->onConferenceNameListChange = &conference_onConferenceNameListChange;
|
||||
ret->onConferencePeerNameChange = &conference_onConferencePeerNameChange;
|
||||
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));
|
||||
Help *help = calloc(1, sizeof(Help));
|
||||
|
||||
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->help = help;
|
||||
|
||||
ret->num = groupnum;
|
||||
ret->num = conferencenum;
|
||||
ret->show_peerlist = true;
|
||||
ret->active_box = -1;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* groupchat.h
|
||||
/* conference.h
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2014 Toxic All Rights Reserved.
|
||||
@ -20,23 +20,23 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GROUPCHAT_H
|
||||
#define GROUPCHAT_H
|
||||
#ifndef CONFERENCE_H
|
||||
#define CONFERENCE_H
|
||||
|
||||
#include "toxic.h"
|
||||
#include "windows.h"
|
||||
|
||||
#define SIDEBAR_WIDTH 16
|
||||
#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 GROUP_EVENT_WAIT 3
|
||||
#define MAX_CONFERENCE_NUM (MAX_WINDOWS_NUM - 2)
|
||||
#define CONFERENCE_EVENT_WAIT 3
|
||||
|
||||
typedef struct GroupPeer {
|
||||
typedef struct ConferencePeer {
|
||||
bool active;
|
||||
char name[TOX_MAX_NAME_LENGTH];
|
||||
size_t name_length;
|
||||
uint32_t peernumber;
|
||||
} GroupPeer;
|
||||
} ConferencePeer;
|
||||
|
||||
typedef struct {
|
||||
int chatwin;
|
||||
@ -45,20 +45,19 @@ typedef struct {
|
||||
int side_pos; /* current position of the sidebar - used for scrolling up and down */
|
||||
time_t start_time;
|
||||
|
||||
GroupPeer *peer_list;
|
||||
ConferencePeer *peer_list;
|
||||
uint32_t max_idx;
|
||||
|
||||
char **name_list;
|
||||
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() ) */
|
||||
void free_groupchat(ToxWindow *self, uint32_t groupnum);
|
||||
int init_conference_win(Tox *m, uint32_t conferencenum, uint8_t type, const char *title, size_t title_length);
|
||||
|
||||
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 */
|
||||
void redraw_groupchat_win(ToxWindow *self);
|
||||
|
||||
#endif /* GROUPCHAT_H */
|
||||
#endif /* CONFERENCE_H */
|
@ -1,4 +1,4 @@
|
||||
/* group_commands.c
|
||||
/* conference_commands.c
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2014 Toxic All Rights Reserved.
|
||||
@ -28,7 +28,7 @@
|
||||
#include "misc_tools.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);
|
||||
|
||||
@ -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);
|
||||
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];
|
||||
snprintf(tmp_event, sizeof(tmp_event), "set title to %s", title);
|
@ -1,4 +1,4 @@
|
||||
/* group_commands.h
|
||||
/* conference_commands.h
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2014 Toxic All Rights Reserved.
|
||||
@ -20,12 +20,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GROUP_COMMANDS_H
|
||||
#define GROUP_COMMANDS_H
|
||||
#ifndef CONFERENCE_COMMANDS_H
|
||||
#define CONFERENCE_COMMANDS_H
|
||||
|
||||
#include "windows.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 */
|
@ -29,7 +29,7 @@
|
||||
#include "execute.h"
|
||||
#include "chat_commands.h"
|
||||
#include "global_commands.h"
|
||||
#include "group_commands.h"
|
||||
#include "conference_commands.h"
|
||||
#include "line_info.h"
|
||||
#include "misc_tools.h"
|
||||
#include "notify.h"
|
||||
@ -48,7 +48,7 @@ static struct cmd_func global_commands[] = {
|
||||
{ "/connect", cmd_connect },
|
||||
{ "/decline", cmd_decline },
|
||||
{ "/exit", cmd_quit },
|
||||
{ "/group", cmd_groupchat },
|
||||
{ "/conference", cmd_conference },
|
||||
{ "/help", cmd_prompt_help },
|
||||
{ "/log", cmd_log },
|
||||
{ "/myid", cmd_myid },
|
||||
@ -67,8 +67,8 @@ static struct cmd_func global_commands[] = {
|
||||
{ "/sdev", cmd_change_device },
|
||||
#endif /* AUDIO */
|
||||
#ifdef VIDEO
|
||||
{ "/lsvdev", cmd_list_video_devices },
|
||||
{ "/svdev", cmd_change_video_device },
|
||||
{ "/lsvdev", cmd_list_video_devices },
|
||||
{ "/svdev", cmd_change_video_device },
|
||||
#endif /* VIDEO */
|
||||
#ifdef PYTHON
|
||||
{ "/run", cmd_run },
|
||||
@ -77,28 +77,28 @@ static struct cmd_func global_commands[] = {
|
||||
};
|
||||
|
||||
static struct cmd_func chat_commands[] = {
|
||||
{ "/cancel", cmd_cancelfile },
|
||||
{ "/invite", cmd_groupinvite },
|
||||
{ "/join", cmd_join_group },
|
||||
{ "/savefile", cmd_savefile },
|
||||
{ "/sendfile", cmd_sendfile },
|
||||
{ "/cancel", cmd_cancelfile },
|
||||
{ "/invite", cmd_conference_invite },
|
||||
{ "/join", cmd_conference_join },
|
||||
{ "/savefile", cmd_savefile },
|
||||
{ "/sendfile", cmd_sendfile },
|
||||
#ifdef AUDIO
|
||||
{ "/call", cmd_call },
|
||||
{ "/answer", cmd_answer },
|
||||
{ "/reject", cmd_reject },
|
||||
{ "/hangup", cmd_hangup },
|
||||
{ "/mute", cmd_mute },
|
||||
{ "/sense", cmd_sense },
|
||||
{ "/bitrate", cmd_bitrate },
|
||||
{ "/call", cmd_call },
|
||||
{ "/answer", cmd_answer },
|
||||
{ "/reject", cmd_reject },
|
||||
{ "/hangup", cmd_hangup },
|
||||
{ "/mute", cmd_mute },
|
||||
{ "/sense", cmd_sense },
|
||||
{ "/bitrate", cmd_bitrate },
|
||||
#endif /* AUDIO */
|
||||
#ifdef VIDEO
|
||||
{ "/video", cmd_video },
|
||||
{ "/video", cmd_video },
|
||||
#endif /* VIDEO */
|
||||
{ NULL, NULL },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
static struct cmd_func group_commands[] = {
|
||||
{ "/title", cmd_set_title },
|
||||
static struct cmd_func conference_commands[] = {
|
||||
{ "/title", cmd_conference_set_title },
|
||||
|
||||
#ifdef AUDIO
|
||||
{ "/mute", cmd_mute },
|
||||
@ -246,8 +246,8 @@ void execute(WINDOW *w, ToxWindow *self, Tox *m, const char *input, int mode)
|
||||
|
||||
break;
|
||||
|
||||
case GROUPCHAT_COMMAND_MODE:
|
||||
if (do_command(w, self, m, num_args, group_commands, args) == 0) {
|
||||
case CONFERENCE_COMMAND_MODE:
|
||||
if (do_command(w, self, m, num_args, conference_commands, args) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
enum {
|
||||
GLOBAL_COMMAND_MODE,
|
||||
CHAT_COMMAND_MODE,
|
||||
GROUPCHAT_COMMAND_MODE,
|
||||
CONFERENCE_COMMAND_MODE,
|
||||
};
|
||||
|
||||
void execute(WINDOW *w, ToxWindow *self, Tox *m, const char *input, int mode);
|
||||
|
@ -116,8 +116,8 @@ static void realloc_blocklist(int n)
|
||||
void kill_friendlist(ToxWindow *self)
|
||||
{
|
||||
for (size_t i = 0; i < Friends.max_idx; ++i) {
|
||||
if (Friends.list[i].active && Friends.list[i].group_invite.key != NULL) {
|
||||
free(Friends.list[i].group_invite.key);
|
||||
if (Friends.list[i].active && Friends.list[i].conference_invite.key != NULL) {
|
||||
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);
|
||||
}
|
||||
|
||||
static void friendlist_onGroupInvite(ToxWindow *self, Tox *m, int32_t num, uint8_t type, const char *group_pub_key,
|
||||
uint16_t length)
|
||||
static void friendlist_onConferenceInvite(ToxWindow *self, Tox *m, int32_t num, uint8_t type,
|
||||
const char *conference_pub_key,
|
||||
uint16_t length)
|
||||
{
|
||||
UNUSED_VAR(self);
|
||||
UNUSED_VAR(type);
|
||||
UNUSED_VAR(group_pub_key);
|
||||
UNUSED_VAR(conference_pub_key);
|
||||
UNUSED_VAR(length);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
@ -674,8 +675,8 @@ static void delete_friend(Tox *m, uint32_t f_num)
|
||||
}
|
||||
}
|
||||
|
||||
if (Friends.list[f_num].group_invite.key != NULL) {
|
||||
free(Friends.list[f_num].group_invite.key);
|
||||
if (Friends.list[f_num].conference_invite.key != NULL) {
|
||||
free(Friends.list[f_num].conference_invite.key);
|
||||
}
|
||||
|
||||
memset(&Friends.list[f_num], 0, sizeof(ToxicFriend));
|
||||
@ -1333,7 +1334,7 @@ ToxWindow *new_friendlist(void)
|
||||
ret->onStatusChange = &friendlist_onStatusChange;
|
||||
ret->onStatusMessageChange = &friendlist_onStatusMessageChange;
|
||||
ret->onFileRecv = &friendlist_onFileRecv;
|
||||
ret->onGroupInvite = &friendlist_onGroupInvite;
|
||||
ret->onConferenceInvite = &friendlist_onConferenceInvite;
|
||||
|
||||
#ifdef AUDIO
|
||||
ret->onInvite = &friendlist_onAV;
|
||||
|
@ -35,7 +35,7 @@ struct LastOnline {
|
||||
char hour_min_str[TIME_STR_SIZE]; /* holds 12/24-hour time string e.g. "10:43 PM" */
|
||||
};
|
||||
|
||||
struct GroupChatInvite {
|
||||
struct ConferenceInvite {
|
||||
char *key;
|
||||
uint16_t length;
|
||||
uint8_t type;
|
||||
@ -57,7 +57,7 @@ typedef struct {
|
||||
Tox_User_Status status;
|
||||
|
||||
struct LastOnline last_online;
|
||||
struct GroupChatInvite group_invite;
|
||||
struct ConferenceInvite conference_invite;
|
||||
|
||||
struct FileTransfer file_receiver[MAX_FILES];
|
||||
struct FileTransfer file_sender[MAX_FILES];
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "friendlist.h"
|
||||
#include "log.h"
|
||||
#include "line_info.h"
|
||||
#include "groupchat.h"
|
||||
#include "conference.h"
|
||||
#include "prompt.h"
|
||||
#include "help.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;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@ -346,7 +346,7 @@ void cmd_groupchat(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*arg
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -357,31 +357,31 @@ void cmd_groupchat(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*arg
|
||||
} else if (!strcasecmp(argv[1], "text")) {
|
||||
type = TOX_CONFERENCE_TYPE_TEXT;
|
||||
} 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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
|
||||
if (init_groupchat_win(m, groupnum, type, NULL, 0) == -1) {
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Group chat window failed to initialize.");
|
||||
tox_conference_delete(m, groupnum, NULL);
|
||||
if (init_conference_win(m, conferencenum, type, NULL, 0) == -1) {
|
||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Conference window failed to initialize.");
|
||||
tox_conference_delete(m, conferencenum, NULL);
|
||||
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])
|
||||
@ -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);
|
||||
} else if (self->is_prompt) {
|
||||
log_ret = log_enable(self->name, myid, NULL, log, LOG_PROMPT);
|
||||
} else if (self->is_groupchat) {
|
||||
log_ret = log_enable(self->name, myid, NULL, log, LOG_GROUP);
|
||||
} else if (self->is_conference) {
|
||||
log_ret = log_enable(self->name, myid, NULL, log, LOG_CONFERENCE);
|
||||
}
|
||||
|
||||
msg = log_ret == 0 ? "Logging enabled." : "Warning: Log failed to initialize.";
|
||||
|
@ -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_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_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_myid(WINDOW *, ToxWindow *, Tox *, int argc, char (*argv)[MAX_STR_SIZE]);
|
||||
#ifdef QRCODE
|
||||
|
30
src/help.c
30
src/help.c
@ -101,11 +101,11 @@ static void help_draw_menu(ToxWindow *self)
|
||||
wattroff(win, A_BOLD | COLOR_PAIR(BLUE));
|
||||
wprintw(win, "hat commands\n");
|
||||
|
||||
wprintw(win, " g");
|
||||
wprintw(win, " c");
|
||||
wattron(win, A_BOLD | COLOR_PAIR(BLUE));
|
||||
wprintw(win, "r");
|
||||
wprintw(win, "o");
|
||||
wattroff(win, A_BOLD | COLOR_PAIR(BLUE));
|
||||
wprintw(win, "oup commands\n");
|
||||
wprintw(win, "nference commands\n");
|
||||
|
||||
#ifdef PYTHON
|
||||
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, " /nospam <value> : Change part of your Tox ID to stop spam\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");
|
||||
#ifdef QRCODE
|
||||
#ifdef QRPNG
|
||||
@ -231,8 +231,8 @@ static void help_draw_chat(ToxWindow *self)
|
||||
wprintw(win, "Chat Commands:\n");
|
||||
wattroff(win, A_BOLD | COLOR_PAIR(RED));
|
||||
|
||||
wprintw(win, " /invite <n> : Invite contact to a group chat\n");
|
||||
wprintw(win, " /join : Join a pending group chat\n");
|
||||
wprintw(win, " /invite <n> : Invite contact to a conference \n");
|
||||
wprintw(win, " /join : Join a pending conference\n");
|
||||
wprintw(win, " /sendfile <path> : Send a file\n");
|
||||
wprintw(win, " /savefile <id> : Receive a file\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, " 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+up and Ctrl+down : Scroll peer list in groupchats\n");
|
||||
wprintw(win, " Ctrl+B : Toggle the groupchat peerlist\n");
|
||||
wprintw(win, " Ctrl+up and Ctrl+down : Scroll peer list in conference\n");
|
||||
wprintw(win, " Ctrl+B : Toggle the conference peerlist\n");
|
||||
wprintw(win, " Ctrl+J : Insert new line\n");
|
||||
wprintw(win, " Ctrl+T : Toggle paste mode\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);
|
||||
}
|
||||
|
||||
static void help_draw_group(ToxWindow *self)
|
||||
static void help_draw_conference(ToxWindow *self)
|
||||
{
|
||||
WINDOW *win = self->help->win;
|
||||
|
||||
wmove(win, 1, 1);
|
||||
|
||||
wattron(win, A_BOLD | COLOR_PAIR(RED));
|
||||
wprintw(win, "Group commands:\n");
|
||||
wprintw(win, "Conference commands:\n");
|
||||
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);
|
||||
|
||||
@ -386,9 +386,9 @@ void help_onKey(ToxWindow *self, wint_t key)
|
||||
self->help->type = HELP_GLOBAL;
|
||||
break;
|
||||
|
||||
case L'r':
|
||||
case L'o':
|
||||
help_init_window(self, 6, 80);
|
||||
self->help->type = HELP_GROUP;
|
||||
self->help->type = HELP_CONFERENCE;
|
||||
break;
|
||||
|
||||
#ifdef PYTHON
|
||||
@ -439,8 +439,8 @@ void help_onDraw(ToxWindow *self)
|
||||
help_draw_contacts(self);
|
||||
break;
|
||||
|
||||
case HELP_GROUP:
|
||||
help_draw_group(self);
|
||||
case HELP_CONFERENCE:
|
||||
help_draw_conference(self);
|
||||
break;
|
||||
|
||||
#ifdef PYTHON
|
||||
|
@ -30,7 +30,7 @@ typedef enum {
|
||||
HELP_MENU,
|
||||
HELP_GLOBAL,
|
||||
HELP_CHAT,
|
||||
HELP_GROUP,
|
||||
HELP_CONFERENCE,
|
||||
HELP_KEYS,
|
||||
HELP_CONTACTS,
|
||||
#ifdef PYTHON
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "toxic_strings.h"
|
||||
#include "line_info.h"
|
||||
#include "notify.h"
|
||||
#include "groupchat.h"
|
||||
#include "conference.h"
|
||||
#include "settings.h"
|
||||
|
||||
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? */
|
||||
if (!match) {
|
||||
if (key == user_settings->key_toggle_peerlist) {
|
||||
if (self->is_groupchat) {
|
||||
if (self->is_conference) {
|
||||
self->show_peerlist ^= 1;
|
||||
redraw_groupchat_win(self);
|
||||
redraw_conference_win(self);
|
||||
}
|
||||
|
||||
match = true;
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "toxic.h"
|
||||
#include "windows.h"
|
||||
#include "line_info.h"
|
||||
#include "groupchat.h"
|
||||
#include "conference.h"
|
||||
#include "settings.h"
|
||||
#include "notify.h"
|
||||
#include "message_queue.h"
|
||||
@ -277,7 +277,7 @@ static void line_info_check_queue(ToxWindow *self)
|
||||
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 max_y = y2 - CHATBOX_HEIGHT;
|
||||
|
||||
@ -318,7 +318,7 @@ void line_info_print(ToxWindow *self)
|
||||
return;
|
||||
}
|
||||
|
||||
if (self->is_groupchat) {
|
||||
if (self->is_conference) {
|
||||
wmove(win, 0, 0);
|
||||
} else {
|
||||
wmove(win, 2, 0);
|
||||
|
@ -35,10 +35,10 @@
|
||||
|
||||
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 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.
|
||||
|
||||
@ -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';
|
||||
break;
|
||||
|
||||
case LOG_GROUP:
|
||||
case LOG_CONFERENCE:
|
||||
strftime(other_id, sizeof(other_id), "%Y-%m-%d[%H:%M:%S]", get_time());
|
||||
path_len += strlen(other_id);
|
||||
break;
|
||||
|
@ -31,7 +31,7 @@ struct chatlog {
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
LOG_GROUP,
|
||||
LOG_CONFERENCE,
|
||||
LOG_PROMPT,
|
||||
LOG_CHAT,
|
||||
} LOG_TYPE;
|
||||
|
@ -406,16 +406,16 @@ on_error:
|
||||
return len;
|
||||
}
|
||||
|
||||
/* same as get_nick_truncate but for groupchats */
|
||||
int get_group_nick_truncate(Tox *m, char *buf, uint32_t peernum, uint32_t groupnum)
|
||||
/* same as get_nick_truncate but for conferences */
|
||||
int get_conference_nick_truncate(Tox *m, char *buf, uint32_t peernum, uint32_t conferencenum)
|
||||
{
|
||||
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) {
|
||||
goto on_error;
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
@ -565,7 +565,7 @@ void set_window_title(ToxWindow *self, const char *title, int len)
|
||||
|
||||
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);
|
||||
} else {
|
||||
snprintf(cpy, sizeof(cpy), "%s", title);
|
||||
|
@ -145,8 +145,8 @@ void str_to_lower(char *str);
|
||||
Returns nick len on success, -1 on failure */
|
||||
size_t get_nick_truncate(Tox *m, char *buf, uint32_t friendnum);
|
||||
|
||||
/* same as get_nick_truncate but for groupchats */
|
||||
int get_group_nick_truncate(Tox *m, char *buf, uint32_t peernum, uint32_t groupnum);
|
||||
/* same as get_nick_truncate but for conferences */
|
||||
int get_conference_nick_truncate(Tox *m, char *buf, uint32_t peernum, uint32_t conferencenum);
|
||||
|
||||
/* copies data to msg buffer.
|
||||
returns length of msg, which will be no larger than size-1 */
|
||||
|
@ -59,7 +59,7 @@ static const char *glob_cmd_list[] = {
|
||||
"/connect",
|
||||
"/decline",
|
||||
"/exit",
|
||||
"/group",
|
||||
"/conference",
|
||||
"/help",
|
||||
"/log",
|
||||
"/myid",
|
||||
|
@ -252,13 +252,13 @@ PyMODINIT_FUNC PyInit_toxic_api(void)
|
||||
PyObject *m = PyModule_Create(&toxic_api_module);
|
||||
PyObject *global_command_const = Py_BuildValue("i", GLOBAL_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, "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(chat_command_const);
|
||||
Py_DECREF(groupchat_command_const);
|
||||
Py_DECREF(conference_command_const);
|
||||
return m;
|
||||
}
|
||||
|
||||
|
18
src/toxic.c
18
src/toxic.c
@ -52,7 +52,7 @@
|
||||
#include "friendlist.h"
|
||||
#include "prompt.h"
|
||||
#include "misc_tools.h"
|
||||
#include "groupchat.h"
|
||||
#include "conference.h"
|
||||
#include "file_transfers.h"
|
||||
#include "line_info.h"
|
||||
#include "settings.h"
|
||||
@ -372,29 +372,29 @@ static void load_conferences(Tox *m)
|
||||
tox_conference_get_chatlist(m, chatlist);
|
||||
|
||||
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) {
|
||||
tox_conference_delete(m, groupnum, NULL);
|
||||
tox_conference_delete(m, conferencenum, NULL);
|
||||
continue;
|
||||
}
|
||||
|
||||
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) {
|
||||
tox_conference_delete(m, groupnum, NULL);
|
||||
tox_conference_delete(m, conferencenum, NULL);
|
||||
continue;
|
||||
}
|
||||
|
||||
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];
|
||||
|
||||
if (t_err != TOX_ERR_CONFERENCE_TITLE_OK || length >= sizeof(title)) {
|
||||
length = 0;
|
||||
} 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) {
|
||||
length = 0;
|
||||
@ -403,8 +403,8 @@ static void load_conferences(Tox *m)
|
||||
|
||||
title[length] = 0;
|
||||
|
||||
if (init_groupchat_win(m, groupnum, type, (const char *) title, length) == -1) {
|
||||
tox_conference_delete(m, groupnum, NULL);
|
||||
if (init_conference_win(m, conferencenum, type, (const char *) title, length) == -1) {
|
||||
tox_conference_delete(m, conferencenum, NULL);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
10
src/toxic.h
10
src/toxic.h
@ -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_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_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);
|
||||
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);
|
||||
void on_conference_peer_list_changed(Tox *m, uint32_t groupnumber, void *userdata);
|
||||
void on_conference_peer_name(Tox *m, uint32_t groupnumber, uint32_t peernumber, const uint8_t *name,
|
||||
void on_conference_peer_list_changed(Tox *m, uint32_t conferencenumber, void *userdata);
|
||||
void on_conference_peer_name(Tox *m, uint32_t conferencenumber, uint32_t peernumber, const uint8_t *name,
|
||||
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 on_file_chunk_request(Tox *m, uint32_t friendnumber, uint32_t filenumber, uint64_t position, size_t length,
|
||||
void *userdata);
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "prompt.h"
|
||||
#include "toxic.h"
|
||||
#include "windows.h"
|
||||
#include "groupchat.h"
|
||||
#include "conference.h"
|
||||
#include "chat.h"
|
||||
#include "line_info.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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
|
||||
for (uint8_t i = 0; i < MAX_WINDOWS_NUM; ++i) {
|
||||
if (windows[i] != NULL && windows[i]->onGroupMessage != NULL) {
|
||||
windows[i]->onGroupMessage(windows[i], m, groupnumber, peernumber, type, msg, length);
|
||||
if (windows[i] != NULL && windows[i]->onConferenceMessage != NULL) {
|
||||
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)
|
||||
{
|
||||
UNUSED_VAR(userdata);
|
||||
|
||||
for (uint8_t i = 0; i < MAX_WINDOWS_NUM; ++i) {
|
||||
if (windows[i] != NULL && windows[i]->onGroupInvite != NULL) {
|
||||
windows[i]->onGroupInvite(windows[i], m, friendnumber, type, (char *) group_pub_key, length);
|
||||
if (windows[i] != NULL && windows[i]->onConferenceInvite != NULL) {
|
||||
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);
|
||||
|
||||
for (uint8_t i = 0; i < MAX_WINDOWS_NUM; ++i) {
|
||||
if (windows[i] != NULL && windows[i]->onGroupNameListChange != NULL) {
|
||||
windows[i]->onGroupNameListChange(windows[i], m, groupnumber);
|
||||
if (windows[i] != NULL && windows[i]->onConferenceNameListChange != NULL) {
|
||||
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)
|
||||
{
|
||||
UNUSED_VAR(userdata);
|
||||
@ -206,13 +206,13 @@ void on_conference_peer_name(Tox *m, uint32_t groupnumber, uint32_t peernumber,
|
||||
filter_str(nick, length);
|
||||
|
||||
for (uint8_t i = 0; i < MAX_WINDOWS_NUM; ++i) {
|
||||
if (windows[i] != NULL && windows[i]->onGroupPeerNameChange != NULL) {
|
||||
windows[i]->onGroupPeerNameChange(windows[i], m, groupnumber, peernumber, nick, length);
|
||||
if (windows[i] != NULL && windows[i]->onConferencePeerNameChange != NULL) {
|
||||
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)
|
||||
{
|
||||
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);
|
||||
|
||||
for (uint8_t i = 0; i < MAX_WINDOWS_NUM; ++i) {
|
||||
if (windows[i] != NULL && windows[i]->onGroupTitleChange != NULL) {
|
||||
windows[i]->onGroupTitleChange(windows[i], m, groupnumber, peernumber, data, length);
|
||||
if (windows[i] != NULL && windows[i]->onConferenceTitleChange != NULL) {
|
||||
windows[i]->onConferenceTitleChange(windows[i], m, conferencenumber, peernumber, data, length);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -454,7 +454,7 @@ void on_window_resize(void)
|
||||
wclear(w->help->win);
|
||||
}
|
||||
|
||||
if (w->is_groupchat) {
|
||||
if (w->is_conference) {
|
||||
delwin(w->chatwin->sidebar);
|
||||
w->chatwin->sidebar = NULL;
|
||||
} else {
|
||||
@ -474,7 +474,7 @@ void on_window_resize(void)
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -754,7 +754,7 @@ int get_num_active_windows(void)
|
||||
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)
|
||||
{
|
||||
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) {
|
||||
kill_chat_window(windows[i], m);
|
||||
} else if (windows[i]->is_groupchat) {
|
||||
free_groupchat(windows[i], windows[i]->num);
|
||||
} else if (windows[i]->is_conference) {
|
||||
free_conference(windows[i], windows[i]->num);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,11 +125,11 @@ struct ToxWindow {
|
||||
void(*onNickChange)(ToxWindow *, Tox *, uint32_t, const char *, size_t);
|
||||
void(*onStatusChange)(ToxWindow *, Tox *, uint32_t, Tox_User_Status);
|
||||
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(*onGroupInvite)(ToxWindow *, Tox *, int32_t, uint8_t, const char *, uint16_t);
|
||||
void(*onGroupNameListChange)(ToxWindow *, Tox *, uint32_t);
|
||||
void(*onGroupPeerNameChange)(ToxWindow *, Tox *, uint32_t, uint32_t, const char *, size_t);
|
||||
void(*onGroupTitleChange)(ToxWindow *, Tox *, uint32_t, uint32_t, const char *, size_t);
|
||||
void(*onConferenceMessage)(ToxWindow *, Tox *, uint32_t, uint32_t, Tox_Message_Type, const char *, size_t);
|
||||
void(*onConferenceInvite)(ToxWindow *, Tox *, int32_t, uint8_t, const char *, uint16_t);
|
||||
void(*onConferenceNameListChange)(ToxWindow *, Tox *, uint32_t);
|
||||
void(*onConferencePeerNameChange)(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(*onFileRecvChunk)(ToxWindow *, Tox *, uint32_t, uint32_t, uint64_t, const char *, size_t);
|
||||
void(*onFileControl)(ToxWindow *, Tox *, uint32_t, uint32_t, Tox_File_Control);
|
||||
@ -172,8 +172,8 @@ struct ToxWindow {
|
||||
bool is_chat;
|
||||
bool is_prompt;
|
||||
bool is_friendlist;
|
||||
bool is_groupchat;
|
||||
int show_peerlist; /* used to toggle groupchat peerlist */
|
||||
bool is_conference;
|
||||
int show_peerlist; /* used to toggle conference peerlist */
|
||||
|
||||
WINDOW_ALERTS alert;
|
||||
|
||||
@ -218,7 +218,7 @@ struct infobox {
|
||||
|
||||
#define MAX_LINE_HIST 128
|
||||
|
||||
/* chat and groupchat window/buffer holder */
|
||||
/* chat and conference window/buffer holder */
|
||||
struct ChatContext {
|
||||
wchar_t line[MAX_STR_SIZE];
|
||||
int pos;
|
||||
|
Loading…
Reference in New Issue
Block a user