1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-16 04:03:02 +01:00

api update fixes

This commit is contained in:
Jfreegman 2013-09-17 20:54:25 -04:00
parent 4e5e3be95f
commit 49b78c9fd4
3 changed files with 12 additions and 11 deletions

View File

@ -71,7 +71,7 @@ static void close_groupchatwin(Tox *m, int groupnum)
group_chat_index = i; group_chat_index = i;
} }
static void groupchat_onGroupMessage(ToxWindow *self, Tox *m, int groupnum, uint8_t *msg, uint16_t len) static void groupchat_onGroupMessage(ToxWindow *self, Tox *m, int groupnum, int peernum, uint8_t *msg, uint16_t len)
{ {
if (self->num != groupnum) if (self->num != groupnum)
return; return;
@ -79,14 +79,15 @@ static void groupchat_onGroupMessage(ToxWindow *self, Tox *m, int groupnum, uint
ChatContext *ctx = (ChatContext *) self->chatwin; ChatContext *ctx = (ChatContext *) self->chatwin;
struct tm *timeinfo = get_time(); struct tm *timeinfo = get_time();
// uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'}; uint8_t nick[TOX_MAX_NAME_LENGTH] = {'\0'};
// tox_getname(m, num, nick); tox_group_peername(m, groupnum, peernum, nick);
nick[TOXIC_MAX_NAME_LENGTH] = '\0'; /* enforce client max name length */
wattron(ctx->history, COLOR_PAIR(CYAN)); wattron(ctx->history, COLOR_PAIR(CYAN));
wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec); wprintw(ctx->history, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
wattroff(ctx->history, COLOR_PAIR(CYAN)); wattroff(ctx->history, COLOR_PAIR(CYAN));
wattron(ctx->history, COLOR_PAIR(4)); wattron(ctx->history, COLOR_PAIR(4));
wprintw(ctx->history, "Toxicle: "); wprintw(ctx->history, "%s: ", nick);
wattroff(ctx->history, COLOR_PAIR(4)); wattroff(ctx->history, COLOR_PAIR(4));
wprintw(ctx->history, "%s\n", msg); wprintw(ctx->history, "%s\n", msg);

View File

@ -19,11 +19,11 @@
#define MAX_WINDOWS_NUM 32 #define MAX_WINDOWS_NUM 32
#define MAX_FRIENDS_NUM 100 #define MAX_FRIENDS_NUM 100
#define MAX_GROUPCHAT_NUM 30 #define MAX_GROUPCHAT_NUM MAX_WINDOWS_NUM - N_DEFAULT_WINS
#define MAX_STR_SIZE 256 #define MAX_STR_SIZE 256
#define KEY_SIZE_BYTES 32 #define KEY_SIZE_BYTES 32
#define TOXIC_MAX_NAME_LENGTH 30 /* Not to be confused with TOX_MAX_NAME_LENGTH */ #define TOXIC_MAX_NAME_LENGTH 30 /* Must be <= TOX_MAX_NAME_LENGTH */
#define N_DEFAULT_WINS 3 /* number of permanent default windows */ #define N_DEFAULT_WINS 2 /* number of permanent default windows */
#define UNKNOWN_NAME "Unknown" #define UNKNOWN_NAME "Unknown"
#define EXIT_SUCCESS 0 #define EXIT_SUCCESS 0
#define EXIT_FAILURE 1 #define EXIT_FAILURE 1
@ -52,7 +52,7 @@ struct ToxWindow_ {
void(*onStatusChange)(ToxWindow *, Tox *, int, TOX_USERSTATUS); void(*onStatusChange)(ToxWindow *, Tox *, int, TOX_USERSTATUS);
void(*onStatusMessageChange)(ToxWindow *, int, uint8_t *, uint16_t); void(*onStatusMessageChange)(ToxWindow *, int, uint8_t *, uint16_t);
void(*onAction)(ToxWindow *, Tox *, int, uint8_t *, uint16_t); void(*onAction)(ToxWindow *, Tox *, int, uint8_t *, uint16_t);
void(*onGroupMessage)(ToxWindow *, Tox *, int, uint8_t *, uint16_t); void(*onGroupMessage)(ToxWindow *, Tox *, int, int, uint8_t *, uint16_t);
void(*onGroupInvite)(ToxWindow *, Tox *, int, uint8_t *); void(*onGroupInvite)(ToxWindow *, Tox *, int, uint8_t *);
char name[TOX_MAX_NAME_LENGTH]; char name[TOX_MAX_NAME_LENGTH];
@ -97,7 +97,7 @@ void on_nickchange(Tox *m, int friendnumber, uint8_t *string, uint16_t length, v
void on_statuschange(Tox *m, int friendnumber, TOX_USERSTATUS status, void *userdata); void on_statuschange(Tox *m, int friendnumber, TOX_USERSTATUS status, void *userdata);
void on_statusmessagechange(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata); void on_statusmessagechange(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
void on_friendadded(Tox *m, int friendnumber); void on_friendadded(Tox *m, int friendnumber);
void on_groupmessage(Tox *m, int groupnumber, uint8_t *message, uint16_t length, void *userdata); void on_groupmessage(Tox *m, int groupnumber, int peernumber, uint8_t *message, uint16_t length, void *userdata);
void on_groupinvite(Tox *m, int friendnumber, uint8_t *group_pub_key, void *userdata); void on_groupinvite(Tox *m, int friendnumber, uint8_t *group_pub_key, void *userdata);
ToxWindow *init_windows(); ToxWindow *init_windows();
void draw_active_window(Tox *m); void draw_active_window(Tox *m);

View File

@ -125,13 +125,13 @@ void on_friendadded(Tox *m, int friendnumber)
wprintw(prompt->window, "\nCould not store Tox data\n"); wprintw(prompt->window, "\nCould not store Tox data\n");
} }
void on_groupmessage(Tox *m, int groupnumber, uint8_t *message, uint16_t length, void *userdata) void on_groupmessage(Tox *m, int groupnumber, int peernumber, uint8_t *message, uint16_t length, void *userdata)
{ {
int i; int i;
for (i = 0; i < MAX_WINDOWS_NUM; ++i) { for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
if (windows[i].onGroupMessage != NULL) if (windows[i].onGroupMessage != NULL)
windows[i].onGroupMessage(&windows[i], m, groupnumber, message, length); windows[i].onGroupMessage(&windows[i], m, groupnumber, peernumber, message, length);
} }
} }