1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-07-01 17:57:45 +02:00

group title fixes and api update

This commit is contained in:
Jfreegman 2014-11-15 15:55:45 -05:00
parent 1bd880708b
commit 4e177d60b0
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63
7 changed files with 24 additions and 8 deletions

View File

@ -79,7 +79,7 @@ static const char chat_cmd_list[AC_NUM_CHAT_COMMANDS][MAX_CMDNAME_SIZE] = {
{ "/close" }, { "/close" },
{ "/connect" }, { "/connect" },
{ "/exit" }, { "/exit" },
{ "/groupchat" }, { "/group" },
{ "/help" }, { "/help" },
{ "/invite" }, { "/invite" },
{ "/join" }, { "/join" },

View File

@ -330,7 +330,16 @@ void cmd_groupchat(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*arg
return; return;
} }
uint8_t type = TOX_GROUPCHAT_TYPE_AV ? !strcasecmp(argv[1], "audio") : TOX_GROUPCHAT_TYPE_TEXT; uint8_t type;
if (!strcasecmp(argv[1], "audio"))
type = TOX_GROUPCHAT_TYPE_AV;
else if (!strcasecmp(argv[1], "text"))
type = TOX_GROUPCHAT_TYPE_TEXT;
else {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Valid group types are: text | audio");
return;
}
int groupnum = -1; int groupnum = -1;

View File

@ -33,8 +33,15 @@ void cmd_set_title(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*arg
char title[MAX_STR_SIZE]; char title[MAX_STR_SIZE];
if (argc < 1) { if (argc < 1) {
snprintf(title, sizeof(title), "Title is set to: %s", self->name); int tlen = tox_group_get_title(m, self->num, (uint8_t *) title);
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, MAGENTA, title);
if (tlen != -1) {
title[tlen] = '\0';
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Title is set to: %s", title);
} else {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Title is not set");
}
return; return;
} }

View File

@ -290,7 +290,7 @@ static void groupchat_onGroupTitleChange(ToxWindow *self, Tox *m, int groupnum,
/* announce title when we join the room */ /* announce title when we join the room */
if (!timed_out(groupchats[self->num].start_time, get_unix_time(), GROUP_EVENT_WAIT)) { if (!timed_out(groupchats[self->num].start_time, get_unix_time(), GROUP_EVENT_WAIT)) {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, MAGENTA, "Title is set to: %s", title); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Title is set to: %s", title);
return; return;
} }

View File

@ -384,7 +384,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_groupchat) /* keep groupnumber in title */
snprintf(cpy, sizeof(cpy), "%d-%s", self->num, title); snprintf(cpy, sizeof(cpy), "%d %s", self->num, title);
else else
snprintf(cpy, sizeof(cpy), "%s", title); snprintf(cpy, sizeof(cpy), "%s", title);

View File

@ -309,11 +309,11 @@ static Tox *init_tox(void)
tox_callback_group_message(m, on_groupmessage, NULL); tox_callback_group_message(m, on_groupmessage, NULL);
tox_callback_group_action(m, on_groupaction, NULL); tox_callback_group_action(m, on_groupaction, NULL);
tox_callback_group_namelist_change(m, on_group_namelistchange, NULL); tox_callback_group_namelist_change(m, on_group_namelistchange, NULL);
tox_callback_group_title(m, on_group_titlechange, NULL);
tox_callback_file_send_request(m, on_file_sendrequest, NULL); tox_callback_file_send_request(m, on_file_sendrequest, NULL);
tox_callback_file_control(m, on_file_control, NULL); tox_callback_file_control(m, on_file_control, NULL);
tox_callback_file_data(m, on_file_data, NULL); tox_callback_file_data(m, on_file_data, NULL);
tox_callback_read_receipt(m, on_read_receipt, NULL); tox_callback_read_receipt(m, on_read_receipt, NULL);
tox_callback_group_title(m, on_group_titlechange, NULL);
tox_set_name(m, (uint8_t *) "Toxic User", strlen("Toxic User")); tox_set_name(m, (uint8_t *) "Toxic User", strlen("Toxic User"));

View File

@ -37,7 +37,7 @@
#include "toxic.h" #include "toxic.h"
#define MAX_WINDOWS_NUM 32 #define MAX_WINDOWS_NUM 32
#define MAX_WINDOW_NAME_LENGTH 20 #define MAX_WINDOW_NAME_LENGTH 22
#define CURS_Y_OFFSET 1 /* y-axis cursor offset for chat contexts */ #define CURS_Y_OFFSET 1 /* y-axis cursor offset for chat contexts */
#define CHATBOX_HEIGHT 2 #define CHATBOX_HEIGHT 2