mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-26 22:43:26 +01:00
Merge branch 'master' of github.com:/Tox/toxic
This commit is contained in:
commit
8b6d50cd68
47
.travis.yml
Normal file
47
.travis.yml
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
language: c
|
||||||
|
compiler:
|
||||||
|
- gcc
|
||||||
|
- clang
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
# installing libsodium, needed for Core
|
||||||
|
- git clone git://github.com/jedisct1/libsodium.git
|
||||||
|
- cd libsodium
|
||||||
|
- git checkout tags/0.4.2
|
||||||
|
- ./autogen.sh
|
||||||
|
- ./configure && make check -j3
|
||||||
|
- sudo make install
|
||||||
|
- cd ..
|
||||||
|
# installing libconfig, needed for DHT_bootstrap_daemon
|
||||||
|
- wget http://www.hyperrealm.com/libconfig/libconfig-1.4.9.tar.gz
|
||||||
|
- tar -xvzf libconfig-1.4.9.tar.gz
|
||||||
|
- cd libconfig-1.4.9
|
||||||
|
- ./configure && make -j3
|
||||||
|
- sudo make install
|
||||||
|
- cd ..
|
||||||
|
# creating librarys' links and updating cache
|
||||||
|
- sudo ldconfig
|
||||||
|
# installing sphinx, needed for documentation
|
||||||
|
- sudo apt-get install python-sphinx
|
||||||
|
# installing check, needed for unit tests
|
||||||
|
- sudo apt-get install check
|
||||||
|
|
||||||
|
- git clone https://github.com/irungentoo/ProjectTox-Core.git toxcore
|
||||||
|
- cd toxcore
|
||||||
|
- mkdir build
|
||||||
|
- cd build
|
||||||
|
- cmake ..
|
||||||
|
- make toxcore -j2
|
||||||
|
- cd ../..
|
||||||
|
script:
|
||||||
|
- autoreconf -i
|
||||||
|
- ./configure --with-libtoxcore-headers=$TRAVIS_BUILD_DIR/toxcore/core --with-libtoxcore-libs=$TRAVIS_BUILD_DIR/toxcore/build/core
|
||||||
|
- make -j2
|
||||||
|
notifications:
|
||||||
|
email: false
|
||||||
|
|
||||||
|
irc:
|
||||||
|
channels:
|
||||||
|
- "chat.freenode.net#tox-dev"
|
||||||
|
on_success: always
|
||||||
|
on_failure: always
|
@ -252,7 +252,7 @@ CPPFLAGS_SAVE="$CPPFLAGS"
|
|||||||
if test -n "$LIBTOXCORE_SEARCH_HEADERS"; then
|
if test -n "$LIBTOXCORE_SEARCH_HEADERS"; then
|
||||||
CFLAGS="$CFLAGS -I$LIBTOXCORE_SEARCH_HEADERS $LIBSODIUM_CFLAGS"
|
CFLAGS="$CFLAGS -I$LIBTOXCORE_SEARCH_HEADERS $LIBSODIUM_CFLAGS"
|
||||||
CPPFLAGS="$CPPFLAGS -I$LIBTOXCORE_SEARCH_HEADERS $LIBSODIUM_CFLAGS"
|
CPPFLAGS="$CPPFLAGS -I$LIBTOXCORE_SEARCH_HEADERS $LIBSODIUM_CFLAGS"
|
||||||
AC_CHECK_HEADER([Messenger.h],
|
AC_CHECK_HEADER([tox.h],
|
||||||
[
|
[
|
||||||
LIBTOXCORE_CFLAGS="-I$LIBTOXCORE_SEARCH_HEADERS"
|
LIBTOXCORE_CFLAGS="-I$LIBTOXCORE_SEARCH_HEADERS"
|
||||||
],
|
],
|
||||||
@ -263,7 +263,7 @@ if test -n "$LIBTOXCORE_SEARCH_HEADERS"; then
|
|||||||
else
|
else
|
||||||
CFLAGS="$CFLAGS $LIBSODIUM_CFLAGS"
|
CFLAGS="$CFLAGS $LIBSODIUM_CFLAGS"
|
||||||
CPPFLAGS="$CPPFLAGS $LIBSODIUM_CFLAGS"
|
CPPFLAGS="$CPPFLAGS $LIBSODIUM_CFLAGS"
|
||||||
AC_CHECK_HEADER([Messenger.h],
|
AC_CHECK_HEADER([tox.h],
|
||||||
[],
|
[],
|
||||||
[
|
[
|
||||||
AC_MSG_ERROR([headers for the toxcore library were not found on your system])
|
AC_MSG_ERROR([headers for the toxcore library were not found on your system])
|
||||||
@ -279,7 +279,7 @@ LIBTOXCORE_LDFLAGS=
|
|||||||
LDFLAGS_SAVE="$LDFLAGS"
|
LDFLAGS_SAVE="$LDFLAGS"
|
||||||
if test -n "$LIBTOXCORE_SEARCH_LIBS"; then
|
if test -n "$LIBTOXCORE_SEARCH_LIBS"; then
|
||||||
LDFLAGS="$LDFLAGS $LIBSODIUM_LDFLAGS -L$LIBTOXCORE_SEARCH_LIBS $LIBSODIUM_LIBS"
|
LDFLAGS="$LDFLAGS $LIBSODIUM_LDFLAGS -L$LIBTOXCORE_SEARCH_LIBS $LIBSODIUM_LIBS"
|
||||||
AC_CHECK_LIB([toxcore], [initMessenger],
|
AC_CHECK_LIB([toxcore], [tox_new],
|
||||||
[
|
[
|
||||||
LIBTOXCORE_LDFLAGS="-L$LIBTOXCORE_SEARCH_LIBS"
|
LIBTOXCORE_LDFLAGS="-L$LIBTOXCORE_SEARCH_LIBS"
|
||||||
LIBTOXCORE_LIBS="-ltoxcore"
|
LIBTOXCORE_LIBS="-ltoxcore"
|
||||||
@ -290,7 +290,7 @@ if test -n "$LIBTOXCORE_SEARCH_LIBS"; then
|
|||||||
)
|
)
|
||||||
else
|
else
|
||||||
LDFLAGS="$LDFLAGS $LIBSODIUM_LDFLAGS $LIBSODIUM_LIBS"
|
LDFLAGS="$LDFLAGS $LIBSODIUM_LDFLAGS $LIBSODIUM_LIBS"
|
||||||
AC_CHECK_LIB([toxcore], [initMessenger],
|
AC_CHECK_LIB([toxcore], [tox_new],
|
||||||
[],
|
[],
|
||||||
[
|
[
|
||||||
AC_MSG_ERROR([required library toxcore was not found on your system])
|
AC_MSG_ERROR([required library toxcore was not found on your system])
|
||||||
|
59
src/chat.c
59
src/chat.c
@ -13,9 +13,6 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#include "Messenger.h"
|
|
||||||
#include "network.h"
|
|
||||||
|
|
||||||
#include "toxic_windows.h"
|
#include "toxic_windows.h"
|
||||||
#include "friendlist.h"
|
#include "friendlist.h"
|
||||||
#include "chat.h"
|
#include "chat.h"
|
||||||
@ -31,7 +28,7 @@ typedef struct {
|
|||||||
} ChatContext;
|
} ChatContext;
|
||||||
|
|
||||||
void print_help(ChatContext *self);
|
void print_help(ChatContext *self);
|
||||||
void execute(ToxWindow *self, ChatContext *ctx, Messenger *m, char *cmd);
|
void execute(ToxWindow *self, ChatContext *ctx, Tox *m, char *cmd);
|
||||||
|
|
||||||
struct tm *get_time(void)
|
struct tm *get_time(void)
|
||||||
{
|
{
|
||||||
@ -42,18 +39,18 @@ struct tm *get_time(void)
|
|||||||
return timeinfo;
|
return timeinfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void chat_onMessage(ToxWindow *self, Messenger *m, int num, uint8_t *msg, uint16_t len)
|
static void chat_onMessage(ToxWindow *self, Tox *m, int num, uint8_t *msg, uint16_t len)
|
||||||
{
|
{
|
||||||
ChatContext *ctx = (ChatContext *) self->x;
|
ChatContext *ctx = (ChatContext *) self->x;
|
||||||
uint8_t nick[MAX_NAME_LENGTH] = {0};
|
uint8_t nick[TOX_MAX_NAME_LENGTH] = {0};
|
||||||
struct tm *timeinfo = get_time();
|
struct tm *timeinfo = get_time();
|
||||||
|
|
||||||
if (ctx->friendnum != num)
|
if (ctx->friendnum != num)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
getname(m, num, (uint8_t *) &nick);
|
tox_getname(m, num, (uint8_t *) &nick);
|
||||||
msg[len - 1] = '\0';
|
msg[len - 1] = '\0';
|
||||||
nick[MAX_NAME_LENGTH - 1] = '\0';
|
nick[TOX_MAX_NAME_LENGTH - 1] = '\0';
|
||||||
|
|
||||||
wattron(ctx->history, COLOR_PAIR(2));
|
wattron(ctx->history, COLOR_PAIR(2));
|
||||||
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);
|
||||||
@ -67,7 +64,7 @@ static void chat_onMessage(ToxWindow *self, Messenger *m, int num, uint8_t *msg,
|
|||||||
beep();
|
beep();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void chat_onAction(ToxWindow *self, Messenger *m, int num, uint8_t *action, uint16_t len)
|
static void chat_onAction(ToxWindow *self, Tox *m, int num, uint8_t *action, uint16_t len)
|
||||||
{
|
{
|
||||||
ChatContext *ctx = (ChatContext *) self->x;
|
ChatContext *ctx = (ChatContext *) self->x;
|
||||||
struct tm *timeinfo = get_time();
|
struct tm *timeinfo = get_time();
|
||||||
@ -176,7 +173,7 @@ static char *wc_to_char(wchar_t ch)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void chat_onKey(ToxWindow *self, Messenger *m, wint_t key)
|
static void chat_onKey(ToxWindow *self, Tox *m, wint_t key)
|
||||||
{
|
{
|
||||||
ChatContext *ctx = (ChatContext *) self->x;
|
ChatContext *ctx = (ChatContext *) self->x;
|
||||||
struct tm *timeinfo = get_time();
|
struct tm *timeinfo = get_time();
|
||||||
@ -222,7 +219,7 @@ static void chat_onKey(ToxWindow *self, Messenger *m, wint_t key)
|
|||||||
else {
|
else {
|
||||||
/* make sure the string has at least non-space character */
|
/* make sure the string has at least non-space character */
|
||||||
if (!string_is_empty(line)) {
|
if (!string_is_empty(line)) {
|
||||||
uint8_t selfname[MAX_NAME_LENGTH];
|
uint8_t selfname[TOX_MAX_NAME_LENGTH];
|
||||||
getself_name(m, selfname, sizeof(selfname));
|
getself_name(m, selfname, sizeof(selfname));
|
||||||
|
|
||||||
wattron(ctx->history, COLOR_PAIR(2));
|
wattron(ctx->history, COLOR_PAIR(2));
|
||||||
@ -233,7 +230,7 @@ static void chat_onKey(ToxWindow *self, Messenger *m, wint_t key)
|
|||||||
wattroff(ctx->history, COLOR_PAIR(1));
|
wattroff(ctx->history, COLOR_PAIR(1));
|
||||||
wprintw(ctx->history, "%s\n", line);
|
wprintw(ctx->history, "%s\n", line);
|
||||||
|
|
||||||
if (m_sendmessage(m, ctx->friendnum, (uint8_t *) line, strlen(line) + 1) == 0) {
|
if (tox_sendmessage(m, ctx->friendnum, (uint8_t *) line, strlen(line) + 1) == 0) {
|
||||||
wattron(ctx->history, COLOR_PAIR(3));
|
wattron(ctx->history, COLOR_PAIR(3));
|
||||||
wprintw(ctx->history, " * Failed to send message.\n");
|
wprintw(ctx->history, " * Failed to send message.\n");
|
||||||
wattroff(ctx->history, COLOR_PAIR(3));
|
wattroff(ctx->history, COLOR_PAIR(3));
|
||||||
@ -247,7 +244,7 @@ static void chat_onKey(ToxWindow *self, Messenger *m, wint_t key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void execute(ToxWindow *self, ChatContext *ctx, Messenger *m, char *cmd)
|
void execute(ToxWindow *self, ChatContext *ctx, Tox *m, char *cmd)
|
||||||
{
|
{
|
||||||
if (!strcmp(cmd, "/clear") || !strcmp(cmd, "/c")) {
|
if (!strcmp(cmd, "/clear") || !strcmp(cmd, "/c")) {
|
||||||
wclear(self->window);
|
wclear(self->window);
|
||||||
@ -281,7 +278,7 @@ void execute(ToxWindow *self, ChatContext *ctx, Messenger *m, char *cmd)
|
|||||||
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(2));
|
wattroff(ctx->history, COLOR_PAIR(2));
|
||||||
|
|
||||||
uint8_t selfname[MAX_NAME_LENGTH];
|
uint8_t selfname[TOX_MAX_NAME_LENGTH];
|
||||||
int len = getself_name(m, selfname, sizeof(selfname));
|
int len = getself_name(m, selfname, sizeof(selfname));
|
||||||
char msg[MAX_STR_SIZE - len - 4];
|
char msg[MAX_STR_SIZE - len - 4];
|
||||||
snprintf(msg, sizeof(msg), "* %s %s\n", (uint8_t *) selfname, action);
|
snprintf(msg, sizeof(msg), "* %s %s\n", (uint8_t *) selfname, action);
|
||||||
@ -290,7 +287,7 @@ void execute(ToxWindow *self, ChatContext *ctx, Messenger *m, char *cmd)
|
|||||||
wprintw(ctx->history, msg);
|
wprintw(ctx->history, msg);
|
||||||
wattroff(ctx->history, COLOR_PAIR(5));
|
wattroff(ctx->history, COLOR_PAIR(5));
|
||||||
|
|
||||||
if (m_sendaction(m, ctx->friendnum, (uint8_t *) msg, strlen(msg) + 1) < 0) {
|
if (tox_sendaction(m, ctx->friendnum, (uint8_t *) msg, strlen(msg) + 1) < 0) {
|
||||||
wattron(ctx->history, COLOR_PAIR(3));
|
wattron(ctx->history, COLOR_PAIR(3));
|
||||||
wprintw(ctx->history, " * Failed to send action\n");
|
wprintw(ctx->history, " * Failed to send action\n");
|
||||||
wattroff(ctx->history, COLOR_PAIR(3));
|
wattroff(ctx->history, COLOR_PAIR(3));
|
||||||
@ -308,20 +305,20 @@ void execute(ToxWindow *self, ChatContext *ctx, Messenger *m, char *cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
status++;
|
status++;
|
||||||
USERSTATUS status_kind;
|
TOX_USERSTATUS status_kind;
|
||||||
|
|
||||||
if (!strncmp(status, "online", strlen("online"))) {
|
if (!strncmp(status, "online", strlen("online"))) {
|
||||||
status_kind = USERSTATUS_NONE;
|
status_kind = TOX_USERSTATUS_NONE;
|
||||||
status_text = "ONLINE";
|
status_text = "ONLINE";
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (!strncmp(status, "away", strlen("away"))) {
|
else if (!strncmp(status, "away", strlen("away"))) {
|
||||||
status_kind = USERSTATUS_AWAY;
|
status_kind = TOX_USERSTATUS_AWAY;
|
||||||
status_text = "AWAY";
|
status_text = "AWAY";
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (!strncmp(status, "busy", strlen("busy"))) {
|
else if (!strncmp(status, "busy", strlen("busy"))) {
|
||||||
status_kind = USERSTATUS_BUSY;
|
status_kind = TOX_USERSTATUS_BUSY;
|
||||||
status_text = "BUSY";
|
status_text = "BUSY";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,12 +330,12 @@ void execute(ToxWindow *self, ChatContext *ctx, Messenger *m, char *cmd)
|
|||||||
msg = strchr(status, ' ');
|
msg = strchr(status, ' ');
|
||||||
|
|
||||||
if (msg == NULL) {
|
if (msg == NULL) {
|
||||||
m_set_userstatus(m, status_kind);
|
tox_set_userstatus(m, status_kind);
|
||||||
wprintw(ctx->history, "Status set to: %s\n", status_text);
|
wprintw(ctx->history, "Status set to: %s\n", status_text);
|
||||||
} else {
|
} else {
|
||||||
msg++;
|
msg++;
|
||||||
m_set_userstatus(m, status_kind);
|
tox_set_userstatus(m, status_kind);
|
||||||
m_set_statusmessage(m, ( uint8_t *) msg, strlen(msg) + 1);
|
tox_set_statusmessage(m, ( uint8_t *) msg, strlen(msg) + 1);
|
||||||
wprintw(ctx->history, "Status set to: %s, %s\n", status_text, msg);
|
wprintw(ctx->history, "Status set to: %s, %s\n", status_text, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -353,17 +350,17 @@ void execute(ToxWindow *self, ChatContext *ctx, Messenger *m, char *cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nick++;
|
nick++;
|
||||||
setname(m, (uint8_t *) nick, strlen(nick) + 1);
|
tox_setname(m, (uint8_t *) nick, strlen(nick) + 1);
|
||||||
wprintw(ctx->history, "Nickname set to: %s\n", nick);
|
wprintw(ctx->history, "Nickname set to: %s\n", nick);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (!strcmp(cmd, "/myid")) {
|
else if (!strcmp(cmd, "/myid")) {
|
||||||
char id[FRIEND_ADDRESS_SIZE * 2 + 1] = {0};
|
char id[TOX_FRIEND_ADDRESS_SIZE * 2 + 1] = {0};
|
||||||
int i;
|
int i;
|
||||||
uint8_t address[FRIEND_ADDRESS_SIZE];
|
uint8_t address[TOX_FRIEND_ADDRESS_SIZE];
|
||||||
getaddress(m, address);
|
getaddress(m, address);
|
||||||
|
|
||||||
for (i = 0; i < FRIEND_ADDRESS_SIZE; i++) {
|
for (i = 0; i < TOX_FRIEND_ADDRESS_SIZE; i++) {
|
||||||
char xx[3];
|
char xx[3];
|
||||||
snprintf(xx, sizeof(xx), "%02X", address[i] & 0xff);
|
snprintf(xx, sizeof(xx), "%02X", address[i] & 0xff);
|
||||||
strcat(id, xx);
|
strcat(id, xx);
|
||||||
@ -383,7 +380,7 @@ void execute(ToxWindow *self, ChatContext *ctx, Messenger *m, char *cmd)
|
|||||||
wprintw(ctx->history, "Invalid command.\n");
|
wprintw(ctx->history, "Invalid command.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void chat_onDraw(ToxWindow *self, Messenger *m)
|
static void chat_onDraw(ToxWindow *self, Tox *m)
|
||||||
{
|
{
|
||||||
curs_set(1);
|
curs_set(1);
|
||||||
int x, y;
|
int x, y;
|
||||||
@ -394,7 +391,7 @@ static void chat_onDraw(ToxWindow *self, Messenger *m)
|
|||||||
wrefresh(self->window);
|
wrefresh(self->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void chat_onInit(ToxWindow *self, Messenger *m)
|
static void chat_onInit(ToxWindow *self, Tox *m)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
ChatContext *ctx = (ChatContext *) self->x;
|
ChatContext *ctx = (ChatContext *) self->x;
|
||||||
@ -424,7 +421,7 @@ void print_help(ChatContext *self)
|
|||||||
wattroff(self->history, COLOR_PAIR(2));
|
wattroff(self->history, COLOR_PAIR(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
ToxWindow new_chat(Messenger *m, int friendnum)
|
ToxWindow new_chat(Tox *m, int friendnum)
|
||||||
{
|
{
|
||||||
ToxWindow ret;
|
ToxWindow ret;
|
||||||
memset(&ret, 0, sizeof(ret));
|
memset(&ret, 0, sizeof(ret));
|
||||||
@ -437,8 +434,8 @@ ToxWindow new_chat(Messenger *m, int friendnum)
|
|||||||
ret.onStatusChange = &chat_onStatusChange;
|
ret.onStatusChange = &chat_onStatusChange;
|
||||||
ret.onAction = &chat_onAction;
|
ret.onAction = &chat_onAction;
|
||||||
|
|
||||||
uint8_t nick[MAX_NAME_LENGTH] = {0};
|
uint8_t nick[TOX_MAX_NAME_LENGTH] = {0};
|
||||||
getname(m, friendnum, (uint8_t *) &nick);
|
tox_getname(m, friendnum, (uint8_t *) &nick);
|
||||||
|
|
||||||
snprintf(ret.title, sizeof(ret.title), "[%s (%d)]", nick, friendnum);
|
snprintf(ret.title, sizeof(ret.title), "[%s (%d)]", nick, friendnum);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#ifndef CHAT_H_6489PZ13
|
#ifndef CHAT_H_6489PZ13
|
||||||
#define CHAT_H_6489PZ13
|
#define CHAT_H_6489PZ13
|
||||||
|
|
||||||
ToxWindow new_chat(Messenger *m, int friendnum);
|
ToxWindow new_chat(Tox *m, int friendnum);
|
||||||
|
|
||||||
#endif /* end of include guard: CHAT_H_6489PZ13 */
|
#endif /* end of include guard: CHAT_H_6489PZ13 */
|
||||||
|
@ -4,30 +4,28 @@
|
|||||||
|
|
||||||
#include "dhtstatus.h"
|
#include "dhtstatus.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "network.h"
|
|
||||||
#include "DHT.h"
|
|
||||||
|
|
||||||
typedef uint8_t ipbuf[3 * 4 + 3 + 1];
|
typedef uint8_t ipbuf[3 * 4 + 3 + 1];
|
||||||
static int num_selected = 0;
|
static int num_selected = 0;
|
||||||
|
|
||||||
static void printip(ipbuf buf, IP ip)
|
static void printip(ipbuf buf, tox_IP ip)
|
||||||
{
|
{
|
||||||
sprintf((char *)buf, "%u.%u.%u.%u", ip.c[0], ip.c[1], ip.c[2], ip.c[3]);
|
sprintf((char *)buf, "%u.%u.%u.%u", ip.c[0], ip.c[1], ip.c[2], ip.c[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dhtstatus_onKey(ToxWindow *self, Messenger *m, wint_t key)
|
static void dhtstatus_onKey(ToxWindow *self, Tox *m, wint_t key)
|
||||||
{
|
{
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case KEY_UP:
|
case KEY_UP:
|
||||||
case 'k':
|
case 'k':
|
||||||
if (--num_selected < 0)
|
if (--num_selected < 0)
|
||||||
num_selected = CLIENT_ID_SIZE - 1;
|
num_selected = TOX_CLIENT_ID_SIZE - 1;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_DOWN:
|
case KEY_DOWN:
|
||||||
case 'j':
|
case 'j':
|
||||||
num_selected = (num_selected + 1) % CLIENT_ID_SIZE;
|
num_selected = (num_selected + 1) % TOX_CLIENT_ID_SIZE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\n':
|
case '\n':
|
||||||
@ -38,8 +36,9 @@ static void dhtstatus_onKey(ToxWindow *self, Messenger *m, wint_t key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dhtstatus_onDraw(ToxWindow *self, Messenger *m)
|
static void dhtstatus_onDraw(ToxWindow *self, Tox *m)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
Client_data *close_clientlist = DHT_get_close_list(m->dht);
|
Client_data *close_clientlist = DHT_get_close_list(m->dht);
|
||||||
curs_set(0);
|
curs_set(0);
|
||||||
werase(self->window);
|
werase(self->window);
|
||||||
@ -52,6 +51,7 @@ static void dhtstatus_onDraw(ToxWindow *self, Messenger *m)
|
|||||||
now);
|
now);
|
||||||
|
|
||||||
for (i = 0; i < 32; i++) { /*Number of nodes in closelist*/
|
for (i = 0; i < 32; i++) { /*Number of nodes in closelist*/
|
||||||
|
/*
|
||||||
Client_data *client = close_clientlist + i;
|
Client_data *client = close_clientlist + i;
|
||||||
|
|
||||||
if (i == num_selected) wattron(self->window, COLOR_PAIR(3));
|
if (i == num_selected) wattron(self->window, COLOR_PAIR(3));
|
||||||
@ -82,9 +82,10 @@ static void dhtstatus_onDraw(ToxWindow *self, Messenger *m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
wrefresh(self->window);
|
wrefresh(self->window);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dhtstatus_onInit(ToxWindow *self, Messenger *m)
|
static void dhtstatus_onInit(ToxWindow *self, Tox *m)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,15 +10,14 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "Messenger.h"
|
#include "tox.h"
|
||||||
#include "network.h"
|
|
||||||
|
|
||||||
#include "friendlist.h"
|
#include "friendlist.h"
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t name[MAX_NAME_LENGTH];
|
uint8_t name[TOX_MAX_NAME_LENGTH];
|
||||||
uint8_t status[MAX_STATUSMESSAGE_LENGTH];
|
uint8_t status[TOX_MAX_STATUSMESSAGE_LENGTH];
|
||||||
int num;
|
int num;
|
||||||
int chatwin;
|
int chatwin;
|
||||||
} friend_t;
|
} friend_t;
|
||||||
@ -28,7 +27,7 @@ static int num_friends = 0;
|
|||||||
static int num_selected = 0;
|
static int num_selected = 0;
|
||||||
|
|
||||||
|
|
||||||
void friendlist_onMessage(ToxWindow *self, Messenger *m, int num, uint8_t *str, uint16_t len)
|
void friendlist_onMessage(ToxWindow *self, Tox *m, int num, uint8_t *str, uint16_t len)
|
||||||
{
|
{
|
||||||
if (num >= num_friends)
|
if (num >= num_friends)
|
||||||
return;
|
return;
|
||||||
@ -40,7 +39,7 @@ void friendlist_onMessage(ToxWindow *self, Messenger *m, int num, uint8_t *str,
|
|||||||
|
|
||||||
void friendlist_onNickChange(ToxWindow *self, int num, uint8_t *str, uint16_t len)
|
void friendlist_onNickChange(ToxWindow *self, int num, uint8_t *str, uint16_t len)
|
||||||
{
|
{
|
||||||
if (len >= MAX_NAME_LENGTH || num >= num_friends)
|
if (len >= TOX_MAX_NAME_LENGTH || num >= num_friends)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
memcpy((char *) &friends[num].name, (char *) str, len);
|
memcpy((char *) &friends[num].name, (char *) str, len);
|
||||||
@ -49,27 +48,27 @@ void friendlist_onNickChange(ToxWindow *self, int num, uint8_t *str, uint16_t le
|
|||||||
|
|
||||||
void friendlist_onStatusChange(ToxWindow *self, int num, uint8_t *str, uint16_t len)
|
void friendlist_onStatusChange(ToxWindow *self, int num, uint8_t *str, uint16_t len)
|
||||||
{
|
{
|
||||||
if (len >= MAX_STATUSMESSAGE_LENGTH || num >= num_friends)
|
if (len >= TOX_MAX_STATUSMESSAGE_LENGTH || num >= num_friends)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
memcpy((char *) &friends[num].status, (char *) str, len);
|
memcpy((char *) &friends[num].status, (char *) str, len);
|
||||||
friends[num].status[len] = 0;
|
friends[num].status[len] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int friendlist_onFriendAdded(Messenger *m, int num)
|
int friendlist_onFriendAdded(Tox *m, int num)
|
||||||
{
|
{
|
||||||
if (num_friends == MAX_FRIENDS_NUM)
|
if (num_friends == MAX_FRIENDS_NUM)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
friends[num_friends].num = num;
|
friends[num_friends].num = num;
|
||||||
getname(m, num, friends[num_friends].name);
|
tox_getname(m, num, friends[num_friends].name);
|
||||||
strcpy((char *) friends[num_friends].name, "unknown");
|
strcpy((char *) friends[num_friends].name, "unknown");
|
||||||
strcpy((char *) friends[num_friends].status, "unknown");
|
strcpy((char *) friends[num_friends].status, "unknown");
|
||||||
friends[num_friends++].chatwin = -1;
|
friends[num_friends++].chatwin = -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void friendlist_onKey(ToxWindow *self, Messenger *m, wint_t key)
|
static void friendlist_onKey(ToxWindow *self, Tox *m, wint_t key)
|
||||||
{
|
{
|
||||||
if (key == KEY_UP) {
|
if (key == KEY_UP) {
|
||||||
if (--num_selected < 0)
|
if (--num_selected < 0)
|
||||||
@ -87,7 +86,7 @@ static void friendlist_onKey(ToxWindow *self, Messenger *m, wint_t key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void friendlist_onDraw(ToxWindow *self, Messenger *m)
|
static void friendlist_onDraw(ToxWindow *self, Tox *m)
|
||||||
{
|
{
|
||||||
curs_set(0);
|
curs_set(0);
|
||||||
werase(self->window);
|
werase(self->window);
|
||||||
@ -125,7 +124,7 @@ void disable_chatwin(int f_num)
|
|||||||
friends[f_num].chatwin = -1;
|
friends[f_num].chatwin = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void friendlist_onInit(ToxWindow *self, Messenger *m)
|
static void friendlist_onInit(ToxWindow *self, Tox *m)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "chat.h"
|
#include "chat.h"
|
||||||
|
|
||||||
ToxWindow new_friendlist();
|
ToxWindow new_friendlist();
|
||||||
int friendlist_onFriendAdded(Messenger *m, int num);
|
int friendlist_onFriendAdded(Tox *m, int num);
|
||||||
void disable_chatwin(int f_num);
|
void disable_chatwin(int f_num);
|
||||||
|
|
||||||
#endif /* end of include guard: FRIENDLIST_H_53I41IM */
|
#endif /* end of include guard: FRIENDLIST_H_53I41IM */
|
||||||
|
106
src/main.c
106
src/main.c
@ -14,16 +14,18 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
|
||||||
#ifdef _win32
|
#ifdef _win32
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#else
|
#else
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Messenger.h"
|
#include "tox.h"
|
||||||
#include "network.h"
|
|
||||||
|
|
||||||
#include "configdir.h"
|
#include "configdir.h"
|
||||||
#include "toxic_windows.h"
|
#include "toxic_windows.h"
|
||||||
@ -68,39 +70,79 @@ static void init_term()
|
|||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Messenger *init_tox()
|
static Tox *init_tox()
|
||||||
{
|
{
|
||||||
/* Init core */
|
/* Init core */
|
||||||
Messenger *m = initMessenger();
|
Tox *m = tox_new();
|
||||||
|
|
||||||
/* Callbacks */
|
/* Callbacks */
|
||||||
m_callback_friendrequest(m, on_request, NULL);
|
tox_callback_friendrequest(m, on_request, NULL);
|
||||||
m_callback_friendmessage(m, on_message, NULL);
|
tox_callback_friendmessage(m, on_message, NULL);
|
||||||
m_callback_namechange(m, on_nickchange, NULL);
|
tox_callback_namechange(m, on_nickchange, NULL);
|
||||||
m_callback_statusmessage(m, on_statuschange, NULL);
|
tox_callback_statusmessage(m, on_statuschange, NULL);
|
||||||
m_callback_action(m, on_action, NULL);
|
tox_callback_action(m, on_action, NULL);
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
setname(m, (uint8_t *) "Cool guy", sizeof("Cool guy"));
|
tox_setname(m, (uint8_t *) "Cool guy", sizeof("Cool guy"));
|
||||||
#elif defined(WIN32)
|
#elif defined(WIN32)
|
||||||
setname(m, (uint8_t *) "I should install GNU/Linux", sizeof("I should install GNU/Linux"));
|
tox_setname(m, (uint8_t *) "I should install GNU/Linux", sizeof("I should install GNU/Linux"));
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
setname(m, (uint8_t *) "Hipster", sizeof("Hipster")); //This used to users of other Unixes are hipsters
|
tox_setname(m, (uint8_t *) "Hipster", sizeof("Hipster")); //This used to users of other Unixes are hipsters
|
||||||
#else
|
#else
|
||||||
setname(m, (uint8_t *) "Registered Minix user #4", sizeof("Registered Minix user #4"));
|
tox_setname(m, (uint8_t *) "Registered Minix user #4", sizeof("Registered Minix user #4"));
|
||||||
#endif
|
#endif
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
resolve_addr():
|
||||||
|
address should represent IPv4 or a hostname with A record
|
||||||
|
|
||||||
|
returns a data in network byte order that can be used to set IP.i or IP_Port.ip.i
|
||||||
|
returns 0 on failure
|
||||||
|
|
||||||
|
TODO: Fix ipv6 support
|
||||||
|
*/
|
||||||
|
uint32_t resolve_addr(const char *address)
|
||||||
|
{
|
||||||
|
struct addrinfo *server = NULL;
|
||||||
|
struct addrinfo hints;
|
||||||
|
int rc;
|
||||||
|
uint32_t addr;
|
||||||
|
|
||||||
|
memset(&hints, 0, sizeof(hints));
|
||||||
|
hints.ai_family = AF_INET; // IPv4 only right now.
|
||||||
|
hints.ai_socktype = SOCK_DGRAM; // type of socket Tox uses.
|
||||||
|
|
||||||
|
rc = getaddrinfo(address, "echo", &hints, &server);
|
||||||
|
|
||||||
|
// Lookup failed.
|
||||||
|
if (rc != 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPv4 records only..
|
||||||
|
if (server->ai_family != AF_INET) {
|
||||||
|
freeaddrinfo(server);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
addr = ((struct sockaddr_in *)server->ai_addr)->sin_addr.s_addr;
|
||||||
|
|
||||||
|
freeaddrinfo(server);
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
|
|
||||||
#define MAXLINE 90 /* Approx max number of chars in a sever line (IP + port + key) */
|
#define MAXLINE 90 /* Approx max number of chars in a sever line (IP + port + key) */
|
||||||
#define MINLINE 70
|
#define MINLINE 70
|
||||||
#define MAXSERVERS 50
|
#define MAXSERVERS 50
|
||||||
|
|
||||||
/* Connects to a random DHT server listed in the DHTservers file */
|
/* Connects to a random DHT server listed in the DHTservers file */
|
||||||
int init_connection(Messenger *m)
|
int init_connection(Tox *m)
|
||||||
{
|
{
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
|
|
||||||
if (DHT_isconnected(m->dht))
|
if (tox_isconnected(m))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fp = fopen(SRVLIST_FILE, "r");
|
fp = fopen(SRVLIST_FILE, "r");
|
||||||
@ -132,7 +174,7 @@ int init_connection(Messenger *m)
|
|||||||
if (!ip || !port || !key)
|
if (!ip || !port || !key)
|
||||||
return 3;
|
return 3;
|
||||||
|
|
||||||
IP_Port dht;
|
tox_IP_Port dht;
|
||||||
dht.port = htons(atoi(port));
|
dht.port = htons(atoi(port));
|
||||||
uint32_t resolved_address = resolve_addr(ip);
|
uint32_t resolved_address = resolve_addr(ip);
|
||||||
|
|
||||||
@ -140,19 +182,19 @@ int init_connection(Messenger *m)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
dht.ip.i = resolved_address;
|
dht.ip.i = resolved_address;
|
||||||
unsigned char *binary_string = hex_string_to_bin(key);
|
uint8_t *binary_string = hex_string_to_bin(key);
|
||||||
DHT_bootstrap(m->dht, dht, binary_string);
|
tox_bootstrap(m, dht, binary_string);
|
||||||
free(binary_string);
|
free(binary_string);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_tox(Messenger *m, ToxWindow *prompt)
|
static void do_tox(Tox *m, ToxWindow *prompt)
|
||||||
{
|
{
|
||||||
static int conn_try = 0;
|
static int conn_try = 0;
|
||||||
static int conn_err = 0;
|
static int conn_err = 0;
|
||||||
static bool dht_on = false;
|
static bool dht_on = false;
|
||||||
|
|
||||||
if (!dht_on && !DHT_isconnected(m->dht) && !(conn_try++ % 100)) {
|
if (!dht_on && !tox_isconnected(m) && !(conn_try++ % 100)) {
|
||||||
if (!conn_err) {
|
if (!conn_err) {
|
||||||
conn_err = init_connection(m);
|
conn_err = init_connection(m);
|
||||||
wprintw(prompt->window, "\nEstablishing connection...\n");
|
wprintw(prompt->window, "\nEstablishing connection...\n");
|
||||||
@ -160,15 +202,15 @@ static void do_tox(Messenger *m, ToxWindow *prompt)
|
|||||||
if (conn_err)
|
if (conn_err)
|
||||||
wprintw(prompt->window, "\nAuto-connect failed with error code %d\n", conn_err);
|
wprintw(prompt->window, "\nAuto-connect failed with error code %d\n", conn_err);
|
||||||
}
|
}
|
||||||
} else if (!dht_on && DHT_isconnected(m->dht)) {
|
} else if (!dht_on && tox_isconnected(m)) {
|
||||||
dht_on = true;
|
dht_on = true;
|
||||||
wprintw(prompt->window, "\nDHT connected.\n");
|
wprintw(prompt->window, "\nDHT connected.\n");
|
||||||
} else if (dht_on && !DHT_isconnected(m->dht)) {
|
} else if (dht_on && !tox_isconnected(m)) {
|
||||||
dht_on = false;
|
dht_on = false;
|
||||||
wprintw(prompt->window, "\nDHT disconnected. Attempting to reconnect.\n");
|
wprintw(prompt->window, "\nDHT disconnected. Attempting to reconnect.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
doMessenger(m);
|
tox_do(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
int f_loadfromfile;
|
int f_loadfromfile;
|
||||||
@ -180,7 +222,7 @@ int f_loadfromfile;
|
|||||||
* Return 2 opening path failed
|
* Return 2 opening path failed
|
||||||
* Return 3 fwrite failed
|
* Return 3 fwrite failed
|
||||||
*/
|
*/
|
||||||
int store_data(Messenger *m, char *path)
|
int store_data(Tox *m, char *path)
|
||||||
{
|
{
|
||||||
if (f_loadfromfile == 0) /*If file loading/saving is disabled*/
|
if (f_loadfromfile == 0) /*If file loading/saving is disabled*/
|
||||||
return 0;
|
return 0;
|
||||||
@ -189,14 +231,14 @@ int store_data(Messenger *m, char *path)
|
|||||||
size_t len;
|
size_t len;
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
|
|
||||||
len = Messenger_size(m);
|
len = tox_size(m);
|
||||||
buf = malloc(len);
|
buf = malloc(len);
|
||||||
|
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Messenger_save(m, buf);
|
tox_save(m, buf);
|
||||||
|
|
||||||
fd = fopen(path, "w");
|
fd = fopen(path, "w");
|
||||||
|
|
||||||
@ -216,7 +258,7 @@ int store_data(Messenger *m, char *path)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void load_data(Messenger *m, char *path)
|
static void load_data(Tox *m, char *path)
|
||||||
{
|
{
|
||||||
if (f_loadfromfile == 0) /*If file loading/saving is disabled*/
|
if (f_loadfromfile == 0) /*If file loading/saving is disabled*/
|
||||||
return;
|
return;
|
||||||
@ -247,12 +289,14 @@ static void load_data(Messenger *m, char *path)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Messenger_load(m, buf, len);
|
tox_load(m, buf, len);
|
||||||
|
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
for (i = 0; i < m->numfriends; i++) {
|
char name[TOX_MAX_NAME_LENGTH];
|
||||||
|
while (tox_getname(m, i, (uint8_t *)name) != -1) {
|
||||||
on_friendadded(m, i);
|
on_friendadded(m, i);
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(buf);
|
free(buf);
|
||||||
@ -314,7 +358,7 @@ int main(int argc, char *argv[])
|
|||||||
free(user_config_dir);
|
free(user_config_dir);
|
||||||
|
|
||||||
init_term();
|
init_term();
|
||||||
Messenger *m = init_tox();
|
Tox *m = init_tox();
|
||||||
ToxWindow *prompt = init_windows(m);
|
ToxWindow *prompt = init_windows(m);
|
||||||
|
|
||||||
if (f_loadfromfile)
|
if (f_loadfromfile)
|
||||||
@ -342,7 +386,7 @@ int main(int argc, char *argv[])
|
|||||||
draw_active_window(m);
|
draw_active_window(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanupMessenger(m);
|
tox_kill(m);
|
||||||
free(DATA_FILE);
|
free(DATA_FILE);
|
||||||
free(SRVLIST_FILE);
|
free(SRVLIST_FILE);
|
||||||
return 0;
|
return 0;
|
||||||
|
125
src/prompt.c
125
src/prompt.c
@ -10,40 +10,37 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "Messenger.h"
|
|
||||||
#include "network.h"
|
|
||||||
|
|
||||||
#include "prompt.h"
|
#include "prompt.h"
|
||||||
|
|
||||||
extern char *DATA_FILE;
|
extern char *DATA_FILE;
|
||||||
extern int store_data(Messenger *m, char *path);
|
extern int store_data(Tox *m, char *path);
|
||||||
|
|
||||||
uint8_t pending_requests[MAX_STR_SIZE][CLIENT_ID_SIZE]; // XXX
|
uint8_t pending_requests[MAX_STR_SIZE][TOX_CLIENT_ID_SIZE]; // XXX
|
||||||
uint8_t num_requests = 0; // XXX
|
uint8_t num_requests = 0; // XXX
|
||||||
|
|
||||||
static char prompt_buf[MAX_STR_SIZE] = {0};
|
static char prompt_buf[MAX_STR_SIZE] = {0};
|
||||||
static int prompt_buf_pos = 0;
|
static int prompt_buf_pos = 0;
|
||||||
|
|
||||||
/* commands */
|
/* commands */
|
||||||
void cmd_accept(ToxWindow *, Messenger *m, char **);
|
void cmd_accept(ToxWindow *, Tox *m, char **);
|
||||||
void cmd_add(ToxWindow *, Messenger *m, char **);
|
void cmd_add(ToxWindow *, Tox *m, char **);
|
||||||
void cmd_clear(ToxWindow *, Messenger *m, char **);
|
void cmd_clear(ToxWindow *, Tox *m, char **);
|
||||||
void cmd_connect(ToxWindow *, Messenger *m, char **);
|
void cmd_connect(ToxWindow *, Tox *m, char **);
|
||||||
void cmd_help(ToxWindow *, Messenger *m, char **);
|
void cmd_help(ToxWindow *, Tox *m, char **);
|
||||||
void cmd_msg(ToxWindow *, Messenger *m, char **);
|
void cmd_msg(ToxWindow *, Tox *m, char **);
|
||||||
void cmd_myid(ToxWindow *, Messenger *m, char **);
|
void cmd_myid(ToxWindow *, Tox *m, char **);
|
||||||
void cmd_nick(ToxWindow *, Messenger *m, char **);
|
void cmd_nick(ToxWindow *, Tox *m, char **);
|
||||||
void cmd_mynick(ToxWindow *, Messenger *m, char **);
|
void cmd_mynick(ToxWindow *, Tox *m, char **);
|
||||||
void cmd_quit(ToxWindow *, Messenger *m, char **);
|
void cmd_quit(ToxWindow *, Tox *m, char **);
|
||||||
void cmd_status(ToxWindow *, Messenger *m, char **);
|
void cmd_status(ToxWindow *, Tox *m, char **);
|
||||||
void cmd_statusmsg(ToxWindow *, Messenger *m, char **);
|
void cmd_statusmsg(ToxWindow *, Tox *m, char **);
|
||||||
|
|
||||||
#define NUM_COMMANDS 14
|
#define NUM_COMMANDS 14
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
char *name;
|
char *name;
|
||||||
int numargs;
|
int numargs;
|
||||||
void (*func)(ToxWindow *, Messenger *m, char **);
|
void (*func)(ToxWindow *, Tox *m, char **);
|
||||||
} commands[] = {
|
} commands[] = {
|
||||||
{ "accept", 1, cmd_accept },
|
{ "accept", 1, cmd_accept },
|
||||||
{ "add", 1, cmd_add },
|
{ "add", 1, cmd_add },
|
||||||
@ -64,7 +61,7 @@ static struct {
|
|||||||
// XXX:
|
// XXX:
|
||||||
int add_req(uint8_t *public_key)
|
int add_req(uint8_t *public_key)
|
||||||
{
|
{
|
||||||
memcpy(pending_requests[num_requests], public_key, CLIENT_ID_SIZE);
|
memcpy(pending_requests[num_requests], public_key, TOX_CLIENT_ID_SIZE);
|
||||||
++num_requests;
|
++num_requests;
|
||||||
return num_requests - 1;
|
return num_requests - 1;
|
||||||
}
|
}
|
||||||
@ -83,7 +80,7 @@ unsigned char *hex_string_to_bin(char hex_string[])
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_accept(ToxWindow *self, Messenger *m, char **args)
|
void cmd_accept(ToxWindow *self, Tox *m, char **args)
|
||||||
{
|
{
|
||||||
int num = atoi(args[1]);
|
int num = atoi(args[1]);
|
||||||
|
|
||||||
@ -102,9 +99,9 @@ void cmd_accept(ToxWindow *self, Messenger *m, char **args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_add(ToxWindow *self, Messenger *m, char **args)
|
void cmd_add(ToxWindow *self, Tox *m, char **args)
|
||||||
{
|
{
|
||||||
uint8_t id_bin[FRIEND_ADDRESS_SIZE];
|
uint8_t id_bin[TOX_FRIEND_ADDRESS_SIZE];
|
||||||
char xx[3];
|
char xx[3];
|
||||||
uint32_t x;
|
uint32_t x;
|
||||||
char *id = args[1];
|
char *id = args[1];
|
||||||
@ -118,14 +115,14 @@ void cmd_add(ToxWindow *self, Messenger *m, char **args)
|
|||||||
if (!msg)
|
if (!msg)
|
||||||
msg = "";
|
msg = "";
|
||||||
|
|
||||||
if (strlen(id) != 2 * FRIEND_ADDRESS_SIZE) {
|
if (strlen(id) != 2 * TOX_FRIEND_ADDRESS_SIZE) {
|
||||||
wprintw(self->window, "Invalid ID length.\n");
|
wprintw(self->window, "Invalid ID length.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < FRIEND_ADDRESS_SIZE; ++i) {
|
for (i = 0; i < TOX_FRIEND_ADDRESS_SIZE; ++i) {
|
||||||
xx[0] = id[2 * i];
|
xx[0] = id[2 * i];
|
||||||
xx[1] = id[2 * i + 1];
|
xx[1] = id[2 * i + 1];
|
||||||
xx[2] = '\0';
|
xx[2] = '\0';
|
||||||
@ -138,38 +135,38 @@ void cmd_add(ToxWindow *self, Messenger *m, char **args)
|
|||||||
id_bin[i] = x;
|
id_bin[i] = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < FRIEND_ADDRESS_SIZE; i++) {
|
for (i = 0; i < TOX_FRIEND_ADDRESS_SIZE; i++) {
|
||||||
id[i] = toupper(id[i]);
|
id[i] = toupper(id[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int num = m_addfriend(m, id_bin, (uint8_t *) msg, strlen(msg) + 1);
|
int num = m_addfriend(m, id_bin, (uint8_t *) msg, strlen(msg) + 1);
|
||||||
|
|
||||||
switch (num) {
|
switch (num) {
|
||||||
case FAERR_TOOLONG:
|
case TOX_FAERR_TOOLONG:
|
||||||
wprintw(self->window, "Message is too long.\n");
|
wprintw(self->window, "Message is too long.\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FAERR_NOMESSAGE:
|
case TOX_FAERR_NOMESSAGE:
|
||||||
wprintw(self->window, "Please add a message to your request.\n");
|
wprintw(self->window, "Please add a message to your request.\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FAERR_OWNKEY:
|
case TOX_FAERR_OWNKEY:
|
||||||
wprintw(self->window, "That appears to be your own ID.\n");
|
wprintw(self->window, "That appears to be your own ID.\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FAERR_ALREADYSENT:
|
case TOX_FAERR_ALREADYSENT:
|
||||||
wprintw(self->window, "Friend request already sent.\n");
|
wprintw(self->window, "Friend request already sent.\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FAERR_UNKNOWN:
|
case TOX_FAERR_UNKNOWN:
|
||||||
wprintw(self->window, "Undefined error when adding friend.\n");
|
wprintw(self->window, "Undefined error when adding friend.\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FAERR_BADCHECKSUM:
|
case TOX_FAERR_BADCHECKSUM:
|
||||||
wprintw(self->window, "Bad checksum in address.\n");
|
wprintw(self->window, "Bad checksum in address.\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FAERR_SETNEWNOSPAM:
|
case TOX_FAERR_SETNEWNOSPAM:
|
||||||
wprintw(self->window, "Nospam was different.\n");
|
wprintw(self->window, "Nospam was different.\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -180,14 +177,14 @@ void cmd_add(ToxWindow *self, Messenger *m, char **args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_clear(ToxWindow *self, Messenger *m, char **args)
|
void cmd_clear(ToxWindow *self, Tox *m, char **args)
|
||||||
{
|
{
|
||||||
wclear(self->window);
|
wclear(self->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_connect(ToxWindow *self, Messenger *m, char **args)
|
void cmd_connect(ToxWindow *self, Tox *m, char **args)
|
||||||
{
|
{
|
||||||
IP_Port dht;
|
tox_IP_Port dht;
|
||||||
char *ip = args[1];
|
char *ip = args[1];
|
||||||
char *port = args[2];
|
char *port = args[2];
|
||||||
char *key = args[3];
|
char *key = args[3];
|
||||||
@ -205,18 +202,18 @@ void cmd_connect(ToxWindow *self, Messenger *m, char **args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
dht.ip.i = resolved_address;
|
dht.ip.i = resolved_address;
|
||||||
unsigned char *binary_string = hex_string_to_bin(key);
|
uint8_t *binary_string = hex_string_to_bin(key);
|
||||||
DHT_bootstrap(m->dht, dht, binary_string);
|
tox_bootstrap(m, dht, binary_string);
|
||||||
free(binary_string);
|
free(binary_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_quit(ToxWindow *self, Messenger *m, char **args)
|
void cmd_quit(ToxWindow *self, Tox *m, char **args)
|
||||||
{
|
{
|
||||||
endwin();
|
endwin();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_help(ToxWindow *self, Messenger *m, char **args)
|
void cmd_help(ToxWindow *self, Tox *m, char **args)
|
||||||
{
|
{
|
||||||
wclear(self->window);
|
wclear(self->window);
|
||||||
wattron(self->window, COLOR_PAIR(2) | A_BOLD);
|
wattron(self->window, COLOR_PAIR(2) | A_BOLD);
|
||||||
@ -242,25 +239,25 @@ void cmd_help(ToxWindow *self, Messenger *m, char **args)
|
|||||||
wattroff(self->window, COLOR_PAIR(2));
|
wattroff(self->window, COLOR_PAIR(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_msg(ToxWindow *self, Messenger *m, char **args)
|
void cmd_msg(ToxWindow *self, Tox *m, char **args)
|
||||||
{
|
{
|
||||||
char *id = args[1];
|
char *id = args[1];
|
||||||
char *msg = args[2];
|
char *msg = args[2];
|
||||||
|
|
||||||
if (m_sendmessage(m, atoi(id), (uint8_t *) msg, strlen(msg) + 1) == 0)
|
if (tox_sendmessage(m, atoi(id), (uint8_t *) msg, strlen(msg) + 1) == 0)
|
||||||
wprintw(self->window, "Error occurred while sending message.\n");
|
wprintw(self->window, "Error occurred while sending message.\n");
|
||||||
else
|
else
|
||||||
wprintw(self->window, "Message successfully sent.\n");
|
wprintw(self->window, "Message successfully sent.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_myid(ToxWindow *self, Messenger *m, char **args)
|
void cmd_myid(ToxWindow *self, Tox *m, char **args)
|
||||||
{
|
{
|
||||||
char id[FRIEND_ADDRESS_SIZE * 2 + 1] = {0};
|
char id[TOX_FRIEND_ADDRESS_SIZE * 2 + 1] = {0};
|
||||||
size_t i;
|
size_t i;
|
||||||
uint8_t address[FRIEND_ADDRESS_SIZE];
|
uint8_t address[TOX_FRIEND_ADDRESS_SIZE];
|
||||||
getaddress(m, address);
|
getaddress(m, address);
|
||||||
|
|
||||||
for (i = 0; i < FRIEND_ADDRESS_SIZE; ++i) {
|
for (i = 0; i < TOX_FRIEND_ADDRESS_SIZE; ++i) {
|
||||||
char xx[3];
|
char xx[3];
|
||||||
snprintf(xx, sizeof(xx), "%02X", address[i] & 0xff);
|
snprintf(xx, sizeof(xx), "%02X", address[i] & 0xff);
|
||||||
strcat(id, xx);
|
strcat(id, xx);
|
||||||
@ -269,10 +266,10 @@ void cmd_myid(ToxWindow *self, Messenger *m, char **args)
|
|||||||
wprintw(self->window, "%s\n", id);
|
wprintw(self->window, "%s\n", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_nick(ToxWindow *self, Messenger *m, char **args)
|
void cmd_nick(ToxWindow *self, Tox *m, char **args)
|
||||||
{
|
{
|
||||||
char *nick = args[1];
|
char *nick = args[1];
|
||||||
setname(m, (uint8_t *) nick, strlen(nick) + 1);
|
tox_setname(m, (uint8_t *) nick, strlen(nick) + 1);
|
||||||
wprintw(self->window, "Nickname set to: %s\n", nick);
|
wprintw(self->window, "Nickname set to: %s\n", nick);
|
||||||
|
|
||||||
if (store_data(m, DATA_FILE)) {
|
if (store_data(m, DATA_FILE)) {
|
||||||
@ -280,29 +277,29 @@ void cmd_nick(ToxWindow *self, Messenger *m, char **args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_mynick(ToxWindow *self, Messenger *m, char **args)
|
void cmd_mynick(ToxWindow *self, Tox *m, char **args)
|
||||||
{
|
{
|
||||||
uint8_t *nick = malloc(m->name_length);
|
uint8_t *nick = malloc(TOX_MAX_NAME_LENGTH);
|
||||||
getself_name(m, nick, m->name_length);
|
tox_getselfname(m, nick, TOX_MAX_NAME_LENGTH);
|
||||||
wprintw(self->window, "Current nickname: %s\n", nick);
|
wprintw(self->window, "Current nickname: %s\n", nick);
|
||||||
free(nick);
|
free(nick);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_status(ToxWindow *self, Messenger *m, char **args)
|
void cmd_status(ToxWindow *self, Tox *m, char **args)
|
||||||
{
|
{
|
||||||
char *status = args[1];
|
char *status = args[1];
|
||||||
char *status_text;
|
char *status_text;
|
||||||
|
|
||||||
USERSTATUS status_kind;
|
TOX_USERSTATUS status_kind;
|
||||||
|
|
||||||
if (!strncmp(status, "online", strlen("online"))) {
|
if (!strncmp(status, "online", strlen("online"))) {
|
||||||
status_kind = USERSTATUS_NONE;
|
status_kind = TOX_USERSTATUS_NONE;
|
||||||
status_text = "ONLINE";
|
status_text = "ONLINE";
|
||||||
} else if (!strncmp(status, "away", strlen("away"))) {
|
} else if (!strncmp(status, "away", strlen("away"))) {
|
||||||
status_kind = USERSTATUS_AWAY;
|
status_kind = TOX_USERSTATUS_AWAY;
|
||||||
status_text = "AWAY";
|
status_text = "AWAY";
|
||||||
} else if (!strncmp(status, "busy", strlen("busy"))) {
|
} else if (!strncmp(status, "busy", strlen("busy"))) {
|
||||||
status_kind = USERSTATUS_BUSY;
|
status_kind = TOX_USERSTATUS_BUSY;
|
||||||
status_text = "BUSY";
|
status_text = "BUSY";
|
||||||
} else {
|
} else {
|
||||||
wprintw(self->window, "Invalid status.\n");
|
wprintw(self->window, "Invalid status.\n");
|
||||||
@ -312,23 +309,23 @@ void cmd_status(ToxWindow *self, Messenger *m, char **args)
|
|||||||
char *msg = args[2];
|
char *msg = args[2];
|
||||||
|
|
||||||
if (msg == NULL) {
|
if (msg == NULL) {
|
||||||
m_set_userstatus(m, status_kind);
|
tox_set_userstatus(m, status_kind);
|
||||||
wprintw(self->window, "Status set to: %s\n", status_text);
|
wprintw(self->window, "Status set to: %s\n", status_text);
|
||||||
} else {
|
} else {
|
||||||
m_set_userstatus(m, status_kind);
|
tox_set_userstatus(m, status_kind);
|
||||||
m_set_statusmessage(m, (uint8_t *) msg, strlen(msg) + 1);
|
tox_set_statusmessage(m, (uint8_t *) msg, strlen(msg) + 1);
|
||||||
wprintw(self->window, "Status set to: %s, %s\n", status_text, msg);
|
wprintw(self->window, "Status set to: %s, %s\n", status_text, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_statusmsg(ToxWindow *self, Messenger *m, char **args)
|
void cmd_statusmsg(ToxWindow *self, Tox *m, char **args)
|
||||||
{
|
{
|
||||||
char *msg = args[1];
|
char *msg = args[1];
|
||||||
m_set_statusmessage(m, (uint8_t *) msg, strlen(msg) + 1);
|
tox_set_statusmessage(m, (uint8_t *) msg, strlen(msg) + 1);
|
||||||
wprintw(self->window, "Status set to: %s\n", msg);
|
wprintw(self->window, "Status set to: %s\n", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void execute(ToxWindow *self, Messenger *m, char *u_cmd)
|
static void execute(ToxWindow *self, Tox *m, char *u_cmd)
|
||||||
{
|
{
|
||||||
int newlines = 0;
|
int newlines = 0;
|
||||||
char cmd[MAX_STR_SIZE] = {0};
|
char cmd[MAX_STR_SIZE] = {0};
|
||||||
@ -436,7 +433,7 @@ static void execute(ToxWindow *self, Messenger *m, char *u_cmd)
|
|||||||
wprintw(self->window, "Invalid command.\n");
|
wprintw(self->window, "Invalid command.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prompt_onKey(ToxWindow *self, Messenger *m, wint_t key)
|
static void prompt_onKey(ToxWindow *self, Tox *m, wint_t key)
|
||||||
{
|
{
|
||||||
/* Add printable characters to line */
|
/* Add printable characters to line */
|
||||||
if (isprint(key)) {
|
if (isprint(key)) {
|
||||||
@ -472,7 +469,7 @@ static void prompt_onKey(ToxWindow *self, Messenger *m, wint_t key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prompt_onDraw(ToxWindow *self, Messenger *m)
|
static void prompt_onDraw(ToxWindow *self, Tox *m)
|
||||||
{
|
{
|
||||||
curs_set(1);
|
curs_set(1);
|
||||||
int x, y;
|
int x, y;
|
||||||
@ -493,7 +490,7 @@ static void prompt_onDraw(ToxWindow *self, Messenger *m)
|
|||||||
wrefresh(self->window);
|
wrefresh(self->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prompt_onInit(ToxWindow *self, Messenger *m)
|
static void prompt_onInit(ToxWindow *self, Tox *m)
|
||||||
{
|
{
|
||||||
scrollok(self->window, 1);
|
scrollok(self->window, 1);
|
||||||
cmd_help(self, m, NULL);
|
cmd_help(self, m, NULL);
|
||||||
|
@ -9,7 +9,9 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <wctype.h>
|
#include <wctype.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#include "Messenger.h"
|
|
||||||
|
#include "tox.h"
|
||||||
|
|
||||||
#define MAX_WINDOWS_NUM 32
|
#define MAX_WINDOWS_NUM 32
|
||||||
#define MAX_FRIENDS_NUM 100
|
#define MAX_FRIENDS_NUM 100
|
||||||
#define MAX_STR_SIZE 256
|
#define MAX_STR_SIZE 256
|
||||||
@ -25,14 +27,14 @@
|
|||||||
typedef struct ToxWindow_ ToxWindow;
|
typedef struct ToxWindow_ ToxWindow;
|
||||||
|
|
||||||
struct ToxWindow_ {
|
struct ToxWindow_ {
|
||||||
void(*onKey)(ToxWindow *, Messenger *, wint_t);
|
void(*onKey)(ToxWindow *, Tox *, wint_t);
|
||||||
void(*onDraw)(ToxWindow *, Messenger *);
|
void(*onDraw)(ToxWindow *, Tox *);
|
||||||
void(*onInit)(ToxWindow *, Messenger *);
|
void(*onInit)(ToxWindow *, Tox *);
|
||||||
void(*onFriendRequest)(ToxWindow *, uint8_t *, uint8_t *, uint16_t);
|
void(*onFriendRequest)(ToxWindow *, uint8_t *, uint8_t *, uint16_t);
|
||||||
void(*onMessage)(ToxWindow *, Messenger *, int, uint8_t *, uint16_t);
|
void(*onMessage)(ToxWindow *, Tox *, int, uint8_t *, uint16_t);
|
||||||
void(*onNickChange)(ToxWindow *, int, uint8_t *, uint16_t);
|
void(*onNickChange)(ToxWindow *, int, uint8_t *, uint16_t);
|
||||||
void(*onStatusChange)(ToxWindow *, int, uint8_t *, uint16_t);
|
void(*onStatusChange)(ToxWindow *, int, uint8_t *, uint16_t);
|
||||||
void(*onAction)(ToxWindow *, Messenger *, int, uint8_t *, uint16_t);
|
void(*onAction)(ToxWindow *, Tox *, int, uint8_t *, uint16_t);
|
||||||
char title[256];
|
char title[256];
|
||||||
|
|
||||||
void *x;
|
void *x;
|
||||||
@ -42,14 +44,14 @@ struct ToxWindow_ {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void on_request(uint8_t *public_key, uint8_t *data, uint16_t length, void *userdata);
|
void on_request(uint8_t *public_key, uint8_t *data, uint16_t length, void *userdata);
|
||||||
void on_message(Messenger *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
|
void on_message(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
|
||||||
void on_action(Messenger *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
|
void on_action(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
|
||||||
void on_nickchange(Messenger *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
|
void on_nickchange(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
|
||||||
void on_statuschange(Messenger *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
|
void on_statuschange(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
|
||||||
void on_friendadded(Messenger *m, int friendnumber);
|
void on_friendadded(Tox *m, int friendnumber);
|
||||||
ToxWindow *init_windows();
|
ToxWindow *init_windows();
|
||||||
void draw_active_window(Messenger *m);
|
void draw_active_window(Tox *m);
|
||||||
int add_window(Messenger *m, ToxWindow w);
|
int add_window(Tox *m, ToxWindow w);
|
||||||
void del_window(ToxWindow *w);
|
void del_window(ToxWindow *w);
|
||||||
void set_active_window(int ch);
|
void set_active_window(int ch);
|
||||||
#endif
|
#endif
|
||||||
|
@ -2,18 +2,21 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "friendlist.h"
|
#include "friendlist.h"
|
||||||
#include "prompt.h"
|
#include "prompt.h"
|
||||||
#include "dhtstatus.h"
|
#include "dhtstatus.h"
|
||||||
#include "toxic_windows.h"
|
#include "toxic_windows.h"
|
||||||
|
|
||||||
extern char *DATA_FILE;
|
extern char *DATA_FILE;
|
||||||
extern int store_data(Messenger *m, char *path);
|
extern int store_data(Tox *m, char *path);
|
||||||
|
|
||||||
static ToxWindow windows[MAX_WINDOWS_NUM];
|
static ToxWindow windows[MAX_WINDOWS_NUM];
|
||||||
static ToxWindow *active_window;
|
static ToxWindow *active_window;
|
||||||
static ToxWindow *prompt;
|
static ToxWindow *prompt;
|
||||||
static Messenger *m;
|
static Tox *m;
|
||||||
|
|
||||||
/* CALLBACKS START */
|
/* CALLBACKS START */
|
||||||
void on_request(uint8_t *public_key, uint8_t *data, uint16_t length, void *userdata)
|
void on_request(uint8_t *public_key, uint8_t *data, uint16_t length, void *userdata)
|
||||||
@ -36,7 +39,7 @@ void on_request(uint8_t *public_key, uint8_t *data, uint16_t length, void *userd
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_message(Messenger *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata)
|
void on_message(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -46,7 +49,7 @@ void on_message(Messenger *m, int friendnumber, uint8_t *string, uint16_t length
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_action(Messenger *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata)
|
void on_action(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -56,7 +59,7 @@ void on_action(Messenger *m, int friendnumber, uint8_t *string, uint16_t length,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_nickchange(Messenger *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata)
|
void on_nickchange(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata)
|
||||||
{
|
{
|
||||||
wprintw(prompt->window, "\n(nickchange) %d: %s\n", friendnumber, string);
|
wprintw(prompt->window, "\n(nickchange) %d: %s\n", friendnumber, string);
|
||||||
int i;
|
int i;
|
||||||
@ -67,7 +70,7 @@ void on_nickchange(Messenger *m, int friendnumber, uint8_t *string, uint16_t len
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_statuschange(Messenger *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata)
|
void on_statuschange(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata)
|
||||||
{
|
{
|
||||||
wprintw(prompt->window, "\n(statuschange) %d: %s\n", friendnumber, string);
|
wprintw(prompt->window, "\n(statuschange) %d: %s\n", friendnumber, string);
|
||||||
int i;
|
int i;
|
||||||
@ -78,17 +81,17 @@ void on_statuschange(Messenger *m, int friendnumber, uint8_t *string, uint16_t l
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_friendadded(Messenger *m, int friendnumber)
|
void on_friendadded(Tox *m, int friendnumber)
|
||||||
{
|
{
|
||||||
friendlist_onFriendAdded(m, friendnumber);
|
friendlist_onFriendAdded(m, friendnumber);
|
||||||
|
|
||||||
if (store_data(m, DATA_FILE)) {
|
if (store_data(m, DATA_FILE)) {
|
||||||
wprintw(prompt->window, "\nCould not store Messenger data\n");
|
wprintw(prompt->window, "\nCould not store Tox data\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* CALLBACKS END */
|
/* CALLBACKS END */
|
||||||
|
|
||||||
int add_window(Messenger *m, ToxWindow w)
|
int add_window(Tox *m, ToxWindow w)
|
||||||
{
|
{
|
||||||
if (LINES < 2)
|
if (LINES < 2)
|
||||||
return -1;
|
return -1;
|
||||||
@ -226,7 +229,7 @@ void prepare_window(WINDOW *w)
|
|||||||
wresize(w, LINES - 2, COLS);
|
wresize(w, LINES - 2, COLS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_active_window(Messenger *m)
|
void draw_active_window(Tox *m)
|
||||||
{
|
{
|
||||||
|
|
||||||
ToxWindow *a = active_window;
|
ToxWindow *a = active_window;
|
||||||
|
Loading…
Reference in New Issue
Block a user