1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-12-23 20:43:24 +01:00

Merge pull request #1 from Tox/master

Sync with main project
This commit is contained in:
Ansa89 2014-06-24 12:51:24 +02:00
commit c29d5d1ca2
22 changed files with 401 additions and 1297 deletions

13
.gitignore vendored
View File

@ -9,19 +9,10 @@
*.app *.app
*.swp *.swp
*.la *.la
m4/*
!m4/pkg.m4
configure
configure_aux
Makefile.in
aclocal.m4
config.h*
config.log
config.status
stamp-h1 stamp-h1
autom4te.cache
.deps .deps
.libs .libs
*.orig *.orig
build/toxic build/toxic
Makefile build/*.o
build/*.d

View File

@ -4,56 +4,45 @@ compiler:
- clang - clang
before_script: before_script:
#installing libsodium, needed for Core # Installing yasm (needed for compiling vpx) and openal
- git clone git://github.com/jedisct1/libsodium.git > /dev/null - sudo apt-get -yq install yasm libopenal-dev
# Installing libsodium, needed for toxcore
- git clone https://github.com/jedisct1/libsodium.git libsodium
- cd libsodium - cd libsodium
- git checkout tags/0.4.2 > /dev/null - git checkout tags/0.4.2 > /dev/null
- ./autogen.sh > /dev/null - ./autogen.sh > /dev/null
- ./configure > /dev/null - ./configure > /dev/null
- make check -j3 > /dev/null - make check -j2 || make check || exit 1 > /dev/null
- sudo make install > /dev/null - sudo make install > /dev/null
- cd .. - cd ..
#installing yasm, needed for compiling vpx # Installing libopus, needed for audio encoding/decoding
- sudo apt-get install yasm > /dev/null - wget http://downloads.xiph.org/releases/opus/opus-1.0.3.tar.gz
#installing libconfig, needed for DHT_bootstrap_daemon
- wget http://www.hyperrealm.com/libconfig/libconfig-1.4.9.tar.gz > /dev/null
- tar -xvzf libconfig-1.4.9.tar.gz > /dev/null
- cd libconfig-1.4.9
- ./configure > /dev/null
- make -j3 > /dev/null
- sudo make install > /dev/null
- cd ..
#installing libopus, needed for audio encoding/decoding
- wget http://downloads.xiph.org/releases/opus/opus-1.0.3.tar.gz > /dev/null
- tar xzf opus-1.0.3.tar.gz > /dev/null - tar xzf opus-1.0.3.tar.gz > /dev/null
- cd opus-1.0.3 - cd opus-1.0.3
- ./configure > /dev/null - ./configure > /dev/null
- make -j3 > /dev/null - make -j2 || make || exit 1 > /dev/null
- sudo make install > /dev/null - sudo make install > /dev/null
- cd .. - cd ..
#installing vpx # Installing vpx
- git clone http://git.chromium.org/webm/libvpx.git > /dev/null - git clone http://git.chromium.org/webm/libvpx.git libvpx
- cd libvpx - cd libvpx
- ./configure --enable-shared > /dev/null - ./configure --enable-shared > /dev/null
- make -j3 >/dev/null - make -j2 || make || exit 1 > /dev/null
- sudo make install > /dev/null - sudo make install > /dev/null
- cd .. - cd ..
#creating libraries links and updating cache # Creating libraries links and updating cache
- sudo ldconfig > /dev/null - sudo ldconfig > /dev/null
# creating librarys' links and updating cache # Installing toxcore
- sudo ldconfig - git clone https://github.com/irungentoo/toxcore.git toxcore
- git clone https://github.com/irungentoo/ProjectTox-Core.git toxcore
- cd toxcore - cd toxcore
- autoreconf -i - autoreconf -i
- ./configure --disable-tests --disable-ntox --disable-daemon --enable-av - ./configure --disable-tests --disable-ntox --disable-daemon --enable-av
- make -j2 - make -j2 || make || exit 1
- sudo make install - sudo make install
- cd .. - cd ..
- sudo apt-get install libopenal-dev -yq
script: script:
- autoreconf -i - cd build
- ./configure - make -j2 || make || exit 1
- make -j2
notifications: notifications:
email: false email: false

View File

@ -1,3 +0,0 @@
SUBDIRS = build misc
ACLOCAL_AMFLAGS = -I m4

View File

@ -1,25 +1,35 @@
# Toxic # Toxic
Toxic is an ncurses based instant messaging client for [Tox](https://tox.im) which formerly resided in the [Tox core repository](https://github.com/irungentoo/toxcore) and is now available as a standalone program. It looks like [this](http://i.imgur.com/hL7WhVl.png).
Toxic is an ncurses based instant messaging client for [Tox](http://tox.im) which formerly resided in the [Tox core repository](https://github.com/irungentoo/ProjectTox-Core) and is now available as a standalone program. It looks like [this](http://i.imgur.com/hL7WhVl.png).
## Installation ## Installation
* Generate the configure script by running the ```autoreconf -i``` command.
* Execute the configure script with ```./configure``` (you may need to pass it the location of your dependency libraries, i.e.): ### Base dependencies
```./configure --prefix=/where/to/install --with-libtoxcore-headers=/path/to/ProjectTox-Core/toxcore --with-libtoxcore-libs=/path/to/ProjectTox-Core/build/.libs --with-libsodium-headers=/path/to/libsodium/include/ --with-libsodium-libs=/path/to/sodiumtest/lib/ ``` * libtoxcore
* ncurses (for Debian based systems: libncurses5-dev libncursesw5-dev)
* Audio calling support requires openal installed ### Audio dependencies
* Compile with --disable-av to build without audio call support * libtoxav
* Compile and install the program with ```make && sudo make install``` * openal
#### Notes ### Compiling
If your default prefix is /usr/local and you get the error: "error while loading shared libraries: libtoxcore.so.0: cannot open shared object file: No such file or directory", then you can try running ```sudo ldconfig```. If that doesn't fix it, run: * `cd build/`
* `make`
* `sudo make install DESTDIR="/path/you/like"`
* You can add specific flags to makefile with `USER_CFLAGS=""` and/or `USER_LDFLAGS=""`
* You can pass your own flags to makefile with `CFLAGS=""` and/or `LDFLAGS=""` (this will supersede the defaults one)
* Audio calling support is automatically enabled if all dependencies are found
### Troubleshooting
If your default prefix is "/usr/local" and you get the error:
```
error while loading shared libraries: libtoxcore.so.0: cannot open shared object file: No such file or directory
```
you can try fix it running `sudo ldconfig`.
If that doesn't fix it, run:
``` ```
echo '/usr/local/lib/' | sudo tee -a /etc/ld.so.conf.d/locallib.conf echo '/usr/local/lib/' | sudo tee -a /etc/ld.so.conf.d/locallib.conf
sudo ldconfig sudo ldconfig
``` ```
If you dont already have them, you may need to install the ncurses libraries. For Debian based systems:
```
sudo apt-get install libncurses5-dev libncursesw5-dev
```
## Settings ## Settings
After running Toxic for the first time an empty file called toxic.conf should reside in your home configuration directory (~/.config/tox for Linux users). For an example on how to use this config file to save settings such as auto-logging and time format see: toxic/misc/toxic.conf After running Toxic for the first time an empty file called toxic.conf should reside in your home configuration directory ("~/.config/tox" for Linux users). For an example on how to use this config file to save settings such as auto-logging and time format see: [misc/toxic.conf](misc/toxic.conf).

100
build/Makefile Normal file
View File

@ -0,0 +1,100 @@
TOXIC_VERSION = 0.4.2
REV = $(shell git rev-list HEAD --count)
VERSION = $(TOXIC_VERSION)_r$(REV)
LIBS = libtoxcore ncurses
CFLAGS ?= $(USER_CFLAGS) -DTOXICVER="\"$(VERSION)\"" -std=gnu99 -pthread
LDFLAGS ?= $(USER_LDFLAGS)
SRC_DIR = ../src
DESTDIR ?= /usr/local
OBJ = chat.o chat_commands.o configdir.o dns.o execute.o
OBJ += file_senders.o friendlist.o global_commands.o groupchat.o line_info.o
OBJ += log.o misc_tools.o prompt.o settings.o toxic.o toxic_strings.o windows.o
# Variables for audio support
AUDIO_LIBS = libtoxav openal
AUDIO_CFLAGS = -D_SUPPORT_AUDIO
AUDIO_OBJ = device.o audio_call.o
# Check on wich system we are running
UNAME_S = $(shell uname -s)
ifeq ($(UNAME_S), Linux)
CFLAGS +=
LDFLAGS += -ldl -lresolv
endif
ifeq ($(UNAME_S), Darwin)
CFLAGS +=
LDFLAGS +=
endif
ifeq ($(UNAME_S), Solaris)
CFLAGS +=
LDFLAGS +=
endif
# Check on which platform we are running
UNAME_M = $(shell uname -m)
ifeq ($(UNAME_M), x86_64)
CFLAGS +=
LDFLAGS +=
endif
ifneq ($(filter %86, $(UNAME_M)),)
CFLAGS +=
LDFLAGS +=
endif
ifneq ($(filter arm%, $(UNAME_M)),)
CFLAGS +=
LDFLAGS +=
endif
# Check if we can build audio
CHECK_AUDIO_LIBS = $(shell pkg-config $(AUDIO_LIBS) || echo -n "error")
ifneq ($(CHECK_AUDIO_LIBS), error)
LIBS += $(AUDIO_LIBS)
CFLAGS += $(AUDIO_CFLAGS)
OBJ += $(AUDIO_OBJ)
else
ifneq ($(MAKECMDGOALS), clean)
MISSING_AUDIO_LIBS = $(shell for lib in $(AUDIO_LIBS) ; do if ! pkg-config $$lib ; then echo $$lib ; fi ; done)
$(warning WARNING -- Toxic will be compiled without audio support)
$(warning WARNING -- You need these libraries for audio support)
$(warning WARNING -- $(MISSING_AUDIO_LIBS))
endif
endif
# Check if we can build Toxic
CHECK_LIBS = $(shell pkg-config $(LIBS) || echo -n "error")
ifneq ($(CHECK_LIBS), error)
CFLAGS += $(shell pkg-config --cflags $(LIBS))
LDFLAGS += $(shell pkg-config --libs $(LIBS))
else
ifneq ($(MAKECMDGOALS), clean)
MISSING_LIBS = $(shell for lib in $(LIBS) ; do if ! pkg-config $$lib ; then echo $$lib ; fi ; done)
$(warning ERROR -- Cannot compile Toxic)
$(warning ERROR -- You need these libraries)
$(warning ERROR -- $(MISSING_LIBS))
$(error ERROR)
endif
endif
# Targets
all: toxic
toxic: $(OBJ)
$(CC) $(CFLAGS) -o toxic $(OBJ) $(LDFLAGS)
install: toxic
mkdir -pv $(DESTDIR)/bin
install -m 0755 toxic $(DESTDIR)/bin
%.o: $(SRC_DIR)/%.c
$(CC) $(CFLAGS) -o $*.o -c $(SRC_DIR)/$*.c
$(CC) -MM $(CFLAGS) $(SRC_DIR)/$*.c > $*.d
clean:
rm -rf *.d *.o toxic
-include $(OBJ:.o=.d)
.PHONY: clean all install

View File

@ -1,72 +0,0 @@
#Don't change this unless needed, else you'll break stuff
bin_PROGRAMS = toxic
toxic_SOURCES = $(top_srcdir)/src/toxic.c \
$(top_srcdir)/src/toxic.h \
$(top_srcdir)/src/chat.h \
$(top_srcdir)/src/chat.c \
$(top_srcdir)/src/configdir.h \
$(top_srcdir)/src/configdir.c \
$(top_srcdir)/src/prompt.h \
$(top_srcdir)/src/prompt.c \
$(top_srcdir)/src/friendlist.h \
$(top_srcdir)/src/friendlist.c \
$(top_srcdir)/src/windows.c \
$(top_srcdir)/src/windows.h \
$(top_srcdir)/src/groupchat.c \
$(top_srcdir)/src/groupchat.h \
$(top_srcdir)/src/global_commands.c \
$(top_srcdir)/src/global_commands.h \
$(top_srcdir)/src/chat_commands.c \
$(top_srcdir)/src/chat_commands.h \
$(top_srcdir)/src/execute.c \
$(top_srcdir)/src/execute.h \
$(top_srcdir)/src/misc_tools.c \
$(top_srcdir)/src/misc_tools.h \
$(top_srcdir)/src/toxic_strings.c \
$(top_srcdir)/src/toxic_strings.h \
$(top_srcdir)/src/log.c \
$(top_srcdir)/src/log.h \
$(top_srcdir)/src/file_senders.c \
$(top_srcdir)/src/file_senders.h \
$(top_srcdir)/src/line_info.c \
$(top_srcdir)/src/line_info.h \
$(top_srcdir)/src/settings.c \
$(top_srcdir)/src/settings.h \
$(top_srcdir)/src/dns.c \
$(top_srcdir)/src/dns.h
toxic_CFLAGS = -I$(top_srcdir) \
$(NCURSES_CFLAGS) \
$(LIBSODIUM_CFLAGS) \
$(LIBTOXCORE_CFLAGS) \
$(PTHREAD_CFLAGS)
toxic_CPPFLAGS = '-DTOXICVER="$(TOXIC_VERSION)"'
toxic_LDADD = $(LIBTOXCORE_LDFLAGS) \
$(LIBSODIUM_LDFLAGS) \
$(NCURSES_LIBS) \
$(LIBTOXCORE_LIBS) \
$(LIBSODIUM_LIBS) \
$(WINSOCK2_LIBS) \
$(PTHREAD_LIBS)
# For audio support
if BUILD_AV
toxic_SOURCES += $(top_srcdir)/src/audio_call.c \
$(top_srcdir)/src/audio_call.h \
$(top_srcdir)/src/device.c \
$(top_srcdir)/src/device.h
toxic_CFLAGS += $(LIBTOXAV_CFLAGS) \
$(OPENAL_CFLAGS) \
-Wimplicit-function-declaration
toxic_LDADD += $(LIBTOXAV_LIBS) \
$(OPENAL_LIBS)
endif

View File

@ -1,510 +0,0 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.65])
AC_INIT([toxic], [0.4.2], [https://tox.im/])
AC_CONFIG_AUX_DIR(configure_aux)
AC_CONFIG_SRCDIR([src/toxic.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([1.10 -Wall])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_CONFIG_MACRO_DIR([m4])
if test "x${prefix}" = "xNONE"; then
prefix="${ac_default_prefix}"
fi
DEPSEARCH=
LIBTOXCORE_SEARCH_HEADERS=
LIBTOXCORE_SEARCH_LIBS=
LIBSODIUM_SEARCH_HEADERS=
LIBSODIUM_SEARCH_LIBS=
LIBTOXCORE_FOUND="no"
NCURSES_FOUND="no"
NCURSES_WIDECHAR_SUPPORT="no"
AC_ARG_WITH(dependency-search,
AC_HELP_STRING([--with-dependency-search=DIR],
[search for dependencies in DIR, i.e. look for libraries in
DIR/lib and for headers in DIR/include]),
[
DEPSEARCH="$withval"
]
)
if test -n "$DEPSEARCH"; then
CFLAGS="$CFLAGS -I$DEPSEARCH/include"
CPPFLAGS="$CPPFLAGS -I$DEPSEARCH/include"
LDFLAGS="$LDFLAGS -L$DEPSEARCH/lib"
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$DEPSEARCH/lib/pkgconfig:/usr/local/lib/pkgconfig
else
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
fi
AC_ARG_WITH(libtoxcore-headers,
AC_HELP_STRING([--with-libtoxcore-headers=DIR],
[search for libtoxcore header files in DIR/tox]),
[
LIBTOXCORE_SEARCH_HEADERS="$withval"
AC_MSG_NOTICE([Will search for libtoxcore header files in $withval])
]
)
AC_ARG_WITH(libtoxcore-libs,
AC_HELP_STRING([--with-libtoxcore-libs=DIR],
[search for libtoxcore libraries in DIR]),
[
LIBTOXCORE_SEARCH_LIBS="$withval"
AC_MSG_NOTICE([Will search for libtoxcore libraries in $withval])
]
)
AC_ARG_WITH(libsodium-headers,
AC_HELP_STRING([--with-libsodium-headers=DIR],
[search for libsodium header files in DIR]),
[
LIBSODIUM_SEARCH_HEADERS="$withval"
AC_MSG_NOTICE([Will search for libsodium header files in $withval])
]
)
AC_ARG_WITH(libsodium-libs,
AC_HELP_STRING([--with-libsodium-libs=DIR],
[search for libsodium libraries in DIR]),
[
LIBSODIUM_SEARCH_LIBS="$withval"
AC_MSG_NOTICE([Will search for libsodium libraries in $withval])
]
)
WIN32=no
MACH=no
AC_CANONICAL_HOST
case $host_os in
*mingw*)
WIN32="yes"
;;
darwin*)
MACH=yes
;;
*freebsd*)
LDFLAGS="$LDFLAGS -L/usr/local/lib"
CFLAGS="$CFLAGS -I/usr/local/include"
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
;;
esac
# Checks for programs.
AC_PROG_CC
AM_PROG_CC_C_O
AC_CHECK_HEADERS(
[limits.h locale.h stdint.h stdlib.h string.h unistd.h wchar.h wctype.h],
[],
[ AC_MSG_ERROR([required header is missing on your system]) ])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_TYPE_SIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINT8_T
# Checks for library functions.
AC_FUNC_MALLOC
AC_CHECK_FUNCS(
[iswprint memmove memset mkdir setlocale strchr strdup],
[],
[ AC_MSG_ERROR([required library function is missing on your system])])
AX_PTHREAD( [], [ AC_MSG_ERROR([pthreads not found on your system]) ])
# pkg-config based tests
PKG_PROG_PKG_CONFIG
if test -n "$PKG_CONFIG"; then
if test "x$WIN32" != "xyes"; then
PKG_CHECK_MODULES([NCURSES], [ncursesw],
[
NCURSES_FOUND="yes"
NCURSES_WIDECHAR_SUPPORT="yes"
],
[
NCURSES_WIDECHAR_SUPPORT="no"
PKG_CHECK_MODULES([NCURSES], [ncurses],
[
NCURSES_FOUND="yes"
],
[
AC_MSG_WARN([$NCURSES_PKG_ERRORS])
])
])
fi
else
AC_MSG_WARN([pkg-config was not found on your sytem])
fi
if (test "x$NCURSES_FOUND" = "xno") && (test "x$WIN32" != "xyes"); then
AC_PATH_PROG([CURSES_CONFIG], [ncursesw5-config], [no])
if test "x$CURSES_CONFIG" != "xno"; then
AC_MSG_CHECKING(ncurses cflags)
NCURSES_CFLAGS=`${CURSES_CONFIG} --cflags`
AC_MSG_RESULT($NCURSES_CFLAGS)
AC_MSG_CHECKING(ncurses libraries)
NCURSES_LIBS=`${CURSES_CONFIG} --libs`
AC_MSG_RESULT($NCURSES_LIBS)
AC_SUBST(NCURSES_CFLAGS)
AC_SUBST(NCURSES_LIBS)
NCURSES_FOUND="yes"
NCURSES_WIDECHAR_SUPPORT="yes"
fi
fi
if (test "x$NCURSES_FOUND" = "xno") && (test "x$WIN32" != "xyes"); then
unset ac_cv_path_CURSES_CONFIG
AC_PATH_PROG([CURSES_CONFIG], [ncursesw5.4-config], [no])
if test "x$CURSES_CONFIG" != "xno"; then
AC_MSG_CHECKING(ncurses cflags)
NCURSES_CFLAGS=`${CURSES_CONFIG} --cflags`
AC_MSG_RESULT($NCURSES_CFLAGS)
AC_MSG_CHECKING(ncurses libraries)
NCURSES_LIBS=`${CURSES_CONFIG} --libs`
AC_MSG_RESULT($NCURSES_LIBS)
AC_SUBST(NCURSES_CFLAGS)
AC_SUBST(NCURSES_LIBS)
NCURSES_FOUND="yes"
NCURSES_WIDECHAR_SUPPORT="yes"
fi
fi
if (test "x$NCURSES_FOUND" = "xno") && (test "x$WIN32" != "xyes"); then
unset ac_cv_path_CURSES_CONFIG
AC_PATH_PROG([CURSES_CONFIG], [ncurses5-config], [no])
if test "x$CURSES_CONFIG" != "xno"; then
AC_MSG_CHECKING(ncurses cflags)
NCURSES_CFLAGS=`${CURSES_CONFIG} --cflags`
AC_MSG_RESULT($NCURSES_CFLAGS)
AC_MSG_CHECKING(ncurses libraries)
NCURSES_LIBS=`${CURSES_CONFIG} --libs`
AC_MSG_RESULT($NCURSES_LIBS)
AC_SUBST(NCURSES_CFLAGS)
AC_SUBST(NCURSES_LIBS)
NCURSES_FOUND="yes"
fi
fi
if (test "x$NCURSES_FOUND" = "xno") && (test "x$WIN32" != "xyes"); then
unset ac_cv_path_CURSES_CONFIG
AC_PATH_PROG([CURSES_CONFIG], [ncurses5.4-config], [no])
if test "x$CURSES_CONFIG" != "xno"; then
AC_MSG_CHECKING(ncurses cflags)
NCURSES_CFLAGS=`${CURSES_CONFIG} --cflags`
AC_MSG_RESULT($NCURSES_CFLAGS)
AC_MSG_CHECKING(ncurses libraries)
NCURSES_LIBS=`${CURSES_CONFIG} --libs`
AC_MSG_RESULT($NCURSES_LIBS)
AC_SUBST(NCURSES_CFLAGS)
AC_SUBST(NCURSES_LIBS)
NCURSES_FOUND="yes"
fi
fi
if test "x$NCURSES_FOUND" = "xno"; then
AC_CHECK_HEADER([curses.h],
[],
[
AC_MSG_ERROR([headers for the ncurses library were not found on your system])
]
)
if test "x$WIN32" = "xyes"; then
dnl Check if pdcurses provides wide char support
NCURSES_WIDECHAR_SUPPORT="no"
AC_CHECK_LIB([pdcurses], [clear],
[],
[
AC_MSG_ERROR([required library pdcurses was not found on your system])
]
)
AC_CHECK_LIB(ws2_32, main,
[
WINSOCK2_LIBS="-lws2_32"
AC_SUBST(WINSOCK2_LIBS)
],
[
AC_MSG_ERROR([required library winsock2 was not found on the system, please check your MinGW installation])
]
)
AC_DEFINE([_WIN32_WINNT], [0x501],
[enable getaddrinfo/freeaddrinfo on XP and higher])
else
AC_CHECK_LIB([ncursesw], [wget_wch],
[
NCURSES_WIDECHAR_SUPPORT="yes"
],
[
unset ac_cv_lib_ncursesw_wget_wch
AC_CHECK_LIB([ncursesw], [wget_wch],
[
NCURSES_WIDECHAR_SUPPORT="yes"
],
[
NCURSES_WIDECHAR_SUPPORT="no"
AC_CHECK_LIB([ncurses], [clear],
[],
[
unset ac_cv_lib_ncurses_clear
AC_CHECK_LIB([ncurses], [clear],
[],
[
AC_MSG_ERROR([required library ncurses was not found on your system])
],
[
-ltinfo
]
)
]
)
],
[
-ltinfo
]
)
]
)
fi
fi
if test -n "$PKG_CONFIG"; then
PKG_CHECK_MODULES(LIBTOXCORE, [libtoxcore],
[
LIBTOXCORE_FOUND="yes"
],
[
AC_MSG_WARN([required library libsodium was not found in requested location $LIBSODIUM_SEARCH_LIBS])
])
fi
if test "x$LIBTOXCORE_FOUND" = "xno"; then
LIBSODIUM_LIBS=
LIBSODIUM_LDFLAGS=
LDFLAGS_SAVE="$LDFLAGS"
if test -n "$LIBSODIUM_SEARCH_LIBS"; then
LDFLAGS="$LDFLAGS -L$LIBSODIUM_SEARCH_LIBS"
AC_CHECK_LIB(sodium, randombytes_random,
[
LIBSODIUM_LDFLAGS="-L$LIBSODIUM_SEARCH_LIBS"
LIBSODIUM_LIBS="-lsodium"
],
[
AC_MSG_ERROR([required library libsodium was not found in requested location $LIBSODIUM_SEARCH_LIBS])
]
)
else
AC_CHECK_LIB(sodium, randombytes_random,
[],
[
AC_MSG_ERROR([required library libsodium was not found on your system, please check http://download.libsodium.org/libsodium/releases/])
]
)
fi
LDFLAGS="$LDFLAGS_SAVE"
AC_SUBST(LIBSODIUM_LIBS)
AC_SUBST(LIBSODIUM_LDFLAGS)
LIBTOXCORE_CFLAGS=
CFLAGS_SAVE="$CFLAGS"
CPPFLAGS_SAVE="$CPPFLAGS"
if test -n "$LIBTOXCORE_SEARCH_HEADERS"; then
CFLAGS="$CFLAGS -I$LIBTOXCORE_SEARCH_HEADERS"
CPPFLAGS="$CPPFLAGS -I$LIBTOXCORE_SEARCH_HEADERS"
AC_CHECK_HEADER([tox/tox.h],
[
LIBTOXCORE_CFLAGS="-I$LIBTOXCORE_SEARCH_HEADERS"
],
[
AC_MSG_ERROR([headers for the toxcore library were not found on your system])
]
)
else
AC_CHECK_HEADER([tox/tox.h],
[],
[
AC_MSG_ERROR([headers for the toxcore library were not found on your system])
],
)
fi
CFLAGS="$CFLAGS_SAVE"
CPPFLAGS="$CPPFLAGS_SAVE"
AC_SUBST(LIBTOXCORE_CFLAGS)
LIBTOXCORE_LIBS=
LIBTOXCORE_LDFLAGS=
LDFLAGS_SAVE="$LDFLAGS"
if test -n "$LIBTOXCORE_SEARCH_LIBS"; then
LDFLAGS="$LDFLAGS $LIBSODIUM_LDFLAGS -L$LIBTOXCORE_SEARCH_LIBS"
AC_CHECK_LIB([toxcore], [tox_new],
[
LIBTOXCORE_LDFLAGS="-L$LIBTOXCORE_SEARCH_LIBS"
LIBTOXCORE_LIBS="-ltoxcore"
],
[
AC_MSG_ERROR([required library toxcore was not found on your system])
],
[
$WINSOCK2_LIBS
$LIBSODIUM_LIBS
]
)
else
LDFLAGS="$LDFLAGS $LIBSODIUM_LDFLAGS"
AC_CHECK_LIB([toxcore], [tox_new],
[],
[
AC_MSG_ERROR([required library toxcore was not found on your system])
],
[
$WINSOCK2_LIBS
$LIBSODIUM_LIBS
]
)
fi
LDFLAGS="$LDFLAGS_SAVE"
AC_SUBST(LIBTOXCORE_LIBS)
AC_SUBST(LIBTOXCORE_LDFLAGS)
fi
AC_CHECK_HEADER([resolv.h], [],
[
AC_MSG_ERROR([resolv.h header was not found on your system])
])
AC_CHECK_LIB(resolv, __res_init, [],
[
AC_MSG_ERROR([libresolv library was not found on your system])
])
####
#### A/V Stuff
AV_SEARCH_DIR=
BUILD_AV="yes"
AC_ARG_WITH(libtoxav-prefix,
AC_HELP_STRING([--with-libtoxav-prefix=DIR],
[search for libtoxav in DIR, i.e. look for libraries in
DIR/lib and for headers in DIR/include]),
[
AV_SEARCH_DIR="$withval"
]
)
if test -n "$AV_SEARCH_DIR"; then
CFLAGS="$CFLAGS -I$AV_SEARCH_DIR/include"
CPPFLAGS="$CPPFLAGS -I$AV_SEARCH_DIR/include"
LDFLAGS="$LDFLAGS -L$AV_SEARCH_DIR/lib"
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$AV_SEARCH_DIR/lib/pkgconfig
else
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig"
fi
# Check if specified enable
AC_ARG_ENABLE([av],
[AC_HELP_STRING([--disable-av], [build AV support libraries (default: auto)]) ],
[
if test "x$enableval" = "xno"; then
BUILD_AV="no"
elif test "x$enableval" = "xyes"; then
BUILD_AV="yes"
fi
]
)
# Check for A/V library
if test "x$BUILD_AV" = "xyes"; then
PKG_CHECK_MODULES([OPENAL], [openal],
[],
[
if test "x$MACH" = "xyes"; then
CFLAGS="$CFLAGS -framework OpenAL"
AC_CHECK_HEADER([OpenAL/al.h],
[
OPENAL_CFLAGS="-framework OpenAL"
OPENAL_LIBS="-framework OpenAL"
AC_SUBST(OPENAL_CFLAGS)
AC_SUBST(OPENAL_LIBS)
],
[
AC_MSG_NOTICE([No openal framework; disabling A/V support])
BUILD_AV="no"
]
)
CFLAGS="$CFLAGS_SAVE"
else
AC_MSG_NOTICE([No openal library; disabling A/V support])
BUILD_AV="no"
fi
])
fi
if test "x$BUILD_AV" = "xyes"; then
PKG_CHECK_MODULES([LIBTOXAV], [libtoxav],
[
AC_CHECK_HEADER([tox/toxav.h],
[
# Place define for audio support
AC_DEFINE([_SUPPORT_AUDIO], [], [Is audio supported])
AC_MSG_NOTICE([Building with audio support])
],
[
AC_MSG_NOTICE([No A/V headers; disabling A/V support])
BUILD_AV="no"
],)
],
[
AC_MSG_NOTICE([No A/V library; disabling A/V support])
BUILD_AV="no"
])
fi
AM_CONDITIONAL(BUILD_AV, test "x$BUILD_AV" = "xyes")
TOXIC_VERSION="$PACKAGE_VERSION"
AC_PATH_PROG([GIT], [git], [no])
if test "x$GIT" != "xno"; then
if test -d ${srcdir}/.git; then
TOXIC_VERSION="${TOXIC_VERSION}_r`${GIT} rev-list HEAD --count`"
fi
fi
AC_SUBST(TOXIC_VERSION)
eval PACKAGE_DATADIR="${datadir}/${PACKAGE}"
eval PACKAGE_DATADIR="${PACKAGE_DATADIR}"
AC_DEFINE_UNQUOTED(PACKAGE_DATADIR, "$PACKAGE_DATADIR", [toxic data directory])
if test "x$NCURSES_WIDECHAR_SUPPORT" = "xyes"; then
AC_DEFINE([HAVE_WIDECHAR], [1], [ncurses wide char support available])
AC_DEFINE([_XOPEN_SOURCE_EXTENDED], [1],
[enable X/Open Portability Guide functionality])
fi
AC_CONFIG_FILES([Makefile
misc/Makefile
build/Makefile])
AC_OUTPUT

View File

@ -1,317 +0,0 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_pthread.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
#
# DESCRIPTION
#
# This macro figures out how to build C programs using POSIX threads. It
# sets the PTHREAD_LIBS output variable to the threads library and linker
# flags, and the PTHREAD_CFLAGS output variable to any special C compiler
# flags that are needed. (The user can also force certain compiler
# flags/libs to be tested by setting these environment variables.)
#
# Also sets PTHREAD_CC to any special C compiler that is needed for
# multi-threaded programs (defaults to the value of CC otherwise). (This
# is necessary on AIX to use the special cc_r compiler alias.)
#
# NOTE: You are assumed to not only compile your program with these flags,
# but also link it with them as well. e.g. you should link with
# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
#
# If you are only building threads programs, you may wish to use these
# variables in your default LIBS, CFLAGS, and CC:
#
# LIBS="$PTHREAD_LIBS $LIBS"
# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# CC="$PTHREAD_CC"
#
# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
# has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name
# (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
#
# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
# PTHREAD_PRIO_INHERIT symbol is defined when compiling with
# PTHREAD_CFLAGS.
#
# ACTION-IF-FOUND is a list of shell commands to run if a threads library
# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
# is not found. If ACTION-IF-FOUND is not specified, the default action
# will define HAVE_PTHREAD.
#
# Please let the authors know if this macro fails on any platform, or if
# you have any other suggestions or comments. This macro was based on work
# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
# Alejandro Forero Cuervo to the autoconf macro repository. We are also
# grateful for the helpful feedback of numerous users.
#
# Updated for Autoconf 2.68 by Daniel Richard G.
#
# LICENSE
#
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
# Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 20
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
AC_DEFUN([AX_PTHREAD], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_LANG_PUSH([C])
ax_pthread_ok=no
# We used to check for pthread.h first, but this fails if pthread.h
# requires special compiler flags (e.g. on True64 or Sequent).
# It gets checked for in the link test anyway.
# First of all, check if the user has set any of the PTHREAD_LIBS,
# etcetera environment variables, and if threads linking works using
# them:
if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS"
AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
AC_TRY_LINK_FUNC(pthread_join, ax_pthread_ok=yes)
AC_MSG_RESULT($ax_pthread_ok)
if test x"$ax_pthread_ok" = xno; then
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
fi
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
fi
# We must check for the threads library under a number of different
# names; the ordering is very important because some systems
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
# libraries is broken (non-POSIX).
# Create a list of thread flags to try. Items starting with a "-" are
# C compiler flags, and other items are library names, except for "none"
# which indicates that we try without any flags at all, and "pthread-config"
# which is a program returning the flags for the Pth emulation library.
ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
# The ordering *is* (sometimes) important. Some notes on the
# individual items follow:
# pthreads: AIX (must check this before -lpthread)
# none: in case threads are in libc; should be tried before -Kthread and
# other compiler flags to prevent continual compiler warnings
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
# -pthreads: Solaris/gcc
# -mthreads: Mingw32/gcc, Lynx/gcc
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
# doesn't hurt to check since this sometimes defines pthreads too;
# also defines -D_REENTRANT)
# ... -mt is also the pthreads flag for HP/aCC
# pthread: Linux, etcetera
# --thread-safe: KAI C++
# pthread-config: use pthread-config program (for GNU Pth library)
case ${host_os} in
solaris*)
# On Solaris (at least, for some versions), libc contains stubbed
# (non-functional) versions of the pthreads routines, so link-based
# tests will erroneously succeed. (We need to link with -pthreads/-mt/
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
# a function called by this macro, so we could check for that, but
# who knows whether they'll stub that too in a future libc.) So,
# we'll just look for -pthreads and -lpthread first:
ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
;;
darwin*)
ax_pthread_flags="-pthread $ax_pthread_flags"
;;
esac
if test x"$ax_pthread_ok" = xno; then
for flag in $ax_pthread_flags; do
case $flag in
none)
AC_MSG_CHECKING([whether pthreads work without any flags])
;;
-*)
AC_MSG_CHECKING([whether pthreads work with $flag])
PTHREAD_CFLAGS="$flag"
;;
pthread-config)
AC_CHECK_PROG(ax_pthread_config, pthread-config, yes, no)
if test x"$ax_pthread_config" = xno; then continue; fi
PTHREAD_CFLAGS="`pthread-config --cflags`"
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
;;
*)
AC_MSG_CHECKING([for the pthreads library -l$flag])
PTHREAD_LIBS="-l$flag"
;;
esac
save_LIBS="$LIBS"
save_CFLAGS="$CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# Check for various functions. We must include pthread.h,
# since some functions may be macros. (On the Sequent, we
# need a special flag -Kthread to make this header compile.)
# We check for pthread_join because it is in -lpthread on IRIX
# while pthread_create is in libc. We check for pthread_attr_init
# due to DEC craziness with -lpthreads. We check for
# pthread_cleanup_push because it is one of the few pthread
# functions on Solaris that doesn't have a non-functional libc stub.
# We try pthread_create on general principles.
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
static void routine(void *a) { a = 0; }
static void *start_routine(void *a) { return a; }],
[pthread_t th; pthread_attr_t attr;
pthread_create(&th, 0, start_routine, 0);
pthread_join(th, 0);
pthread_attr_init(&attr);
pthread_cleanup_push(routine, 0);
pthread_cleanup_pop(0) /* ; */])],
[ax_pthread_ok=yes],
[])
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
AC_MSG_RESULT($ax_pthread_ok)
if test "x$ax_pthread_ok" = xyes; then
break;
fi
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
done
fi
# Various other checks:
if test "x$ax_pthread_ok" = xyes; then
save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS"
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
AC_MSG_CHECKING([for joinable pthread attribute])
attr_name=unknown
for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
[int attr = $attr; return attr /* ; */])],
[attr_name=$attr; break],
[])
done
AC_MSG_RESULT($attr_name)
if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
[Define to necessary symbol if this constant
uses a non-standard name on your system.])
fi
AC_MSG_CHECKING([if more special flags are required for pthreads])
flag=no
case ${host_os} in
aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";;
osf* | hpux*) flag="-D_REENTRANT";;
solaris*)
if test "$GCC" = "yes"; then
flag="-D_REENTRANT"
else
flag="-mt -D_REENTRANT"
fi
;;
esac
AC_MSG_RESULT(${flag})
if test "x$flag" != xno; then
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
fi
AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
ax_cv_PTHREAD_PRIO_INHERIT, [
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[#include <pthread.h>]], [[int i = PTHREAD_PRIO_INHERIT;]])],
[ax_cv_PTHREAD_PRIO_INHERIT=yes],
[ax_cv_PTHREAD_PRIO_INHERIT=no])
])
AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"],
AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], 1, [Have PTHREAD_PRIO_INHERIT.]))
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
# More AIX lossage: compile with *_r variant
if test "x$GCC" != xyes; then
case $host_os in
aix*)
AS_CASE(["x/$CC"],
[x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
[#handle absolute path differently from PATH based program lookup
AS_CASE(["x$CC"],
[x/*],
[AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
[AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
;;
esac
fi
fi
test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
AC_SUBST(PTHREAD_LIBS)
AC_SUBST(PTHREAD_CFLAGS)
AC_SUBST(PTHREAD_CC)
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test x"$ax_pthread_ok" = xyes; then
ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
:
else
ax_pthread_ok=no
$2
fi
AC_LANG_POP
])dnl AX_PTHREAD

199
m4/pkg.m4
View File

@ -1,199 +0,0 @@
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
# serial 1 (pkg-config-0.24)
#
# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# PKG_PROG_PKG_CONFIG([MIN-VERSION])
# ----------------------------------
AC_DEFUN([PKG_PROG_PKG_CONFIG],
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
fi
if test -n "$PKG_CONFIG"; then
_pkg_min_version=m4_default([$1], [0.9.0])
AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
PKG_CONFIG=""
fi
fi[]dnl
])# PKG_PROG_PKG_CONFIG
# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
#
# Check to see whether a particular set of modules exists. Similar
# to PKG_CHECK_MODULES(), but does not set variables or print errors.
#
# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
# only at the first occurence in configure.ac, so if the first place
# it's called might be skipped (such as if it is within an "if", you
# have to call PKG_CHECK_EXISTS manually
# --------------------------------------------------------------
AC_DEFUN([PKG_CHECK_EXISTS],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
if test -n "$PKG_CONFIG" && \
AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
m4_default([$2], [:])
m4_ifvaln([$3], [else
$3])dnl
fi])
# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
# ---------------------------------------------
m4_define([_PKG_CONFIG],
[if test -n "$$1"; then
pkg_cv_[]$1="$$1"
elif test -n "$PKG_CONFIG"; then
PKG_CHECK_EXISTS([$3],
[pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes ],
[pkg_failed=yes])
else
pkg_failed=untried
fi[]dnl
])# _PKG_CONFIG
# _PKG_SHORT_ERRORS_SUPPORTED
# -----------------------------
AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi[]dnl
])# _PKG_SHORT_ERRORS_SUPPORTED
# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
# [ACTION-IF-NOT-FOUND])
#
#
# Note that if there is a possibility the first call to
# PKG_CHECK_MODULES might not happen, you should be sure to include an
# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
#
#
# --------------------------------------------------------------
AC_DEFUN([PKG_CHECK_MODULES],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
pkg_failed=no
AC_MSG_CHECKING([for $1])
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
and $1[]_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.])
if test $pkg_failed = yes; then
AC_MSG_RESULT([no])
_PKG_SHORT_ERRORS_SUPPORTED
if test $_pkg_short_errors_supported = yes; then
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
else
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
m4_default([$4], [AC_MSG_ERROR(
[Package requirements ($2) were not met:
$$1_PKG_ERRORS
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
_PKG_TEXT])[]dnl
])
elif test $pkg_failed = untried; then
AC_MSG_RESULT([no])
m4_default([$4], [AC_MSG_FAILURE(
[The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.
_PKG_TEXT
To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
])
else
$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
AC_MSG_RESULT([yes])
$3
fi[]dnl
])# PKG_CHECK_MODULES
# PKG_INSTALLDIR(DIRECTORY)
# -------------------------
# Substitutes the variable pkgconfigdir as the location where a module
# should install pkg-config .pc files. By default the directory is
# $libdir/pkgconfig, but the default can be changed by passing
# DIRECTORY. The user can override through the --with-pkgconfigdir
# parameter.
AC_DEFUN([PKG_INSTALLDIR],
[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
m4_pushdef([pkg_description],
[pkg-config installation directory @<:@]pkg_default[@:>@])
AC_ARG_WITH([pkgconfigdir],
[AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
[with_pkgconfigdir=]pkg_default)
AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
m4_popdef([pkg_default])
m4_popdef([pkg_description])
]) dnl PKG_INSTALLDIR
# PKG_NOARCH_INSTALLDIR(DIRECTORY)
# -------------------------
# Substitutes the variable noarch_pkgconfigdir as the location where a
# module should install arch-independent pkg-config .pc files. By
# default the directory is $datadir/pkgconfig, but the default can be
# changed by passing DIRECTORY. The user can override through the
# --with-noarch-pkgconfigdir parameter.
AC_DEFUN([PKG_NOARCH_INSTALLDIR],
[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
m4_pushdef([pkg_description],
[pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
AC_ARG_WITH([noarch-pkgconfigdir],
[AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
[with_noarch_pkgconfigdir=]pkg_default)
AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
m4_popdef([pkg_default])
m4_popdef([pkg_description])
]) dnl PKG_NOARCH_INSTALLDIR

View File

@ -1 +0,0 @@
dist_pkgdata_DATA = DHTnodes

View File

@ -55,7 +55,7 @@
typedef struct _Call { typedef struct _Call {
pthread_t ttid; /* Transmission thread id */ pthread_t ttid; /* Transmission thread id */
_Bool ttas; /* Transmission thread active status (0 - stopped, 1- running) */ _Bool ttas, has_output; /* Transmission thread active status (0 - stopped, 1- running) */
int in_idx, out_idx; int in_idx, out_idx;
pthread_mutex_t mutex; pthread_mutex_t mutex;
} Call; } Call;
@ -98,7 +98,6 @@ void callback_call_ended ( int32_t call_index, void *arg );
void callback_requ_timeout ( int32_t call_index, void *arg ); void callback_requ_timeout ( int32_t call_index, void *arg );
void callback_peer_timeout ( int32_t call_index, void *arg ); void callback_peer_timeout ( int32_t call_index, void *arg );
static void print_err (ToxWindow *self, uint8_t *error_str) static void print_err (ToxWindow *self, uint8_t *error_str)
{ {
line_info_add(self, NULL, NULL, NULL, error_str, SYS_MSG, 0, 0); line_info_add(self, NULL, NULL, NULL, error_str, SYS_MSG, 0, 0);
@ -189,19 +188,23 @@ void *transmission(void *arg)
int32_t dec_frame_len; int32_t dec_frame_len;
int16_t PCM[frame_size]; int16_t PCM[frame_size];
this_call->has_output = 1;
if ( open_primary_device(input, &this_call->in_idx) != de_None )
if ( open_primary_device(input, &this_call->in_idx) != de_None ) goto cleanup; line_info_add(self, NULL, NULL, NULL, "Failed to open input device!", SYS_MSG, 0, 0);
if ( register_device_callback(call_index, this_call->in_idx, read_device_callback, &call_index, _True) != de_None) if ( register_device_callback(call_index, this_call->in_idx, read_device_callback, &call_index, _True) != de_None)
/* Set VAD as true for all; TODO: Make it more dynamic */ /* Set VAD as true for all; TODO: Make it more dynamic */
goto cleanup; line_info_add(self, NULL, NULL, NULL, "Failed to register input handler!", SYS_MSG, 0, 0);
if ( open_primary_device(output, &this_call->out_idx) != de_None ) goto cleanup;
if ( open_primary_device(output, &this_call->out_idx) != de_None ) {
line_info_add(self, NULL, NULL, NULL, "Failed to open output device!", SYS_MSG, 0, 0);
this_call->has_output = 0;
}
/* Start transmission */ /* Start transmission */
while (this_call->ttas) { while (this_call->ttas) {
lock; lock;
if ( this_call->has_output ) {
if (playback_device_ready(this_call->out_idx) == de_Busy) { if (playback_device_ready(this_call->out_idx) == de_Busy) {
unlock; unlock;
@ -218,6 +221,7 @@ void *transmission(void *arg)
/* >implying it'll ever get an error */ /* >implying it'll ever get an error */
} }
}
unlock; unlock;
usleep(1000); usleep(1000);
@ -304,10 +308,13 @@ void callback_recv_ending ( int32_t call_index, void* arg )
{ {
CB_BODY(call_index, arg, onEnding); CB_BODY(call_index, arg, onEnding);
stop_transmission(call_index); stop_transmission(call_index);
((ToxWindow*)arg)->call_idx = -1;
} }
void callback_recv_error ( int32_t call_index, void* arg ) void callback_recv_error ( int32_t call_index, void* arg )
{ {
CB_BODY(call_index, arg, onError); CB_BODY(call_index, arg, onError);
stop_transmission(call_index);
((ToxWindow*)arg)->call_idx = -1;
} }
void callback_call_started ( int32_t call_index, void* arg ) void callback_call_started ( int32_t call_index, void* arg )
{ {
@ -328,6 +335,7 @@ void callback_call_canceled ( int32_t call_index, void* arg )
/* In case call is active */ /* In case call is active */
stop_transmission(call_index); stop_transmission(call_index);
((ToxWindow*)arg)->call_idx = -1;
} }
void callback_call_rejected ( int32_t call_index, void* arg ) void callback_call_rejected ( int32_t call_index, void* arg )
{ {
@ -337,11 +345,13 @@ void callback_call_ended ( int32_t call_index, void* arg )
{ {
CB_BODY(call_index, arg, onEnd); CB_BODY(call_index, arg, onEnd);
stop_transmission(call_index); stop_transmission(call_index);
((ToxWindow*)arg)->call_idx = -1;
} }
void callback_requ_timeout ( int32_t call_index, void* arg ) void callback_requ_timeout ( int32_t call_index, void* arg )
{ {
CB_BODY(call_index, arg, onRequestTimeout); CB_BODY(call_index, arg, onRequestTimeout);
((ToxWindow*)arg)->call_idx = -1;
} }
void callback_peer_timeout ( int32_t call_index, void* arg ) void callback_peer_timeout ( int32_t call_index, void* arg )
{ {
@ -351,6 +361,7 @@ void callback_peer_timeout ( int32_t call_index, void* arg )
* actions that one can possibly take on timeout * actions that one can possibly take on timeout
*/ */
toxav_stop_call(ASettins.av, call_index); toxav_stop_call(ASettins.av, call_index);
((ToxWindow*)arg)->call_idx = -1;
} }
/* /*
* End of Callbacks * End of Callbacks
@ -375,6 +386,11 @@ void cmd_call(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
goto on_error; goto on_error;
} }
if (!self->stb->is_online) {
error_str = "Friend is offline.";
goto on_error;
}
ToxAvError error = toxav_call(ASettins.av, &self->call_idx, self->num, TypeAudio, 30); ToxAvError error = toxav_call(ASettins.av, &self->call_idx, self->num, TypeAudio, 30);
if ( error != ErrorNone ) { if ( error != ErrorNone ) {
@ -503,6 +519,7 @@ void cmd_cancel(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
if ( error != ErrorNone ) { if ( error != ErrorNone ) {
if ( error == ErrorNoCall ) error_str = "No call!"; if ( error == ErrorNoCall ) error_str = "No call!";
else if ( error == ErrorInvalidState ) error_str = "Cannot cancel in invalid state!";
else error_str = "Internal error!"; else error_str = "Internal error!";
goto on_error; goto on_error;
@ -644,7 +661,8 @@ void cmd_ccur_device(WINDOW * window, ToxWindow * self, Tox *m, int argc, char (
if (type == output) { if (type == output) {
pthread_mutex_lock(&this_call->mutex); pthread_mutex_lock(&this_call->mutex);
close_device(output, this_call->out_idx); close_device(output, this_call->out_idx);
open_device(output, selection, &this_call->out_idx); this_call->has_output = open_device(output, selection, &this_call->out_idx)
== de_None ? 1 : 0;
pthread_mutex_unlock(&this_call->mutex); pthread_mutex_unlock(&this_call->mutex);
} }
else { else {
@ -696,7 +714,13 @@ void cmd_mute(WINDOW * window, ToxWindow * self, Tox *m, int argc, char (*argv)[
Call* this_call = &ASettins.calls[self->call_idx]; Call* this_call = &ASettins.calls[self->call_idx];
pthread_mutex_lock(&this_call->mutex); pthread_mutex_lock(&this_call->mutex);
device_mute(type, type == input ? this_call->in_idx : this_call->out_idx); if (type == input) {
device_mute(type, this_call->in_idx);
self->chatwin->infobox.in_is_muted ^= 1;
} else {
device_mute(type, this_call->out_idx);
self->chatwin->infobox.out_is_muted ^= 1;
}
pthread_mutex_unlock(&this_call->mutex); pthread_mutex_unlock(&this_call->mutex);
} }
@ -727,7 +751,10 @@ void cmd_sense(WINDOW * window, ToxWindow * self, Tox *m, int argc, char (*argv)
} }
/* Call must be active */ /* Call must be active */
if ( self->call_idx > -1) device_set_VAD_treshold(ASettins.calls[self->call_idx].in_idx, value); if ( self->call_idx > -1) {
device_set_VAD_treshold(ASettins.calls[self->call_idx].in_idx, value);
self->chatwin->infobox.vad_lvl = value;
}
return; return;

View File

@ -27,6 +27,8 @@
#include "device.h" #include "device.h"
#define VAD_THRESHOLD_DEFAULT 40.0
typedef enum _AudioError { typedef enum _AudioError {
ae_None = 0, ae_None = 0,
ae_StartingCaptureDevice = 1 << 0, ae_StartingCaptureDevice = 1 << 0,
@ -34,7 +36,6 @@ typedef enum _AudioError {
ae_StartingCoreAudio = 1 << 2 ae_StartingCoreAudio = 1 << 2
} AudioError; } AudioError;
/* You will have to pass pointer to first member of 'windows' /* You will have to pass pointer to first member of 'windows'
* declared in windows.c otherwise undefined behaviour will * declared in windows.c otherwise undefined behaviour will
*/ */
@ -44,5 +45,4 @@ void terminate_audio();
int start_transmission(ToxWindow *self); int start_transmission(ToxWindow *self);
int stop_transmission(int call_index); int stop_transmission(int call_index);
#endif /* _audio_h */ #endif /* _audio_h */

View File

@ -53,6 +53,11 @@ extern ToxicFriend friends[MAX_FRIENDS_NUM];
extern struct _Winthread Winthread; extern struct _Winthread Winthread;
extern struct user_settings *user_settings; extern struct user_settings *user_settings;
#ifdef _SUPPORT_AUDIO
static void init_infobox(ToxWindow *self);
static void kill_infobox(ToxWindow *self);
#endif /* _SUPPORT_AUDIO */
#ifdef _SUPPORT_AUDIO #ifdef _SUPPORT_AUDIO
#define AC_NUM_CHAT_COMMANDS 26 #define AC_NUM_CHAT_COMMANDS 26
#else #else
@ -139,7 +144,7 @@ static void chat_onMessage(ToxWindow *self, Tox *m, int32_t num, uint8_t *msg, u
nick[n_len] = '\0'; nick[n_len] = '\0';
uint8_t timefrmt[TIME_STR_SIZE]; uint8_t timefrmt[TIME_STR_SIZE];
get_time_str(timefrmt); get_time_str(timefrmt, sizeof(timefrmt));
line_info_add(self, timefrmt, nick, NULL, msg, IN_MSG, 0, 0); line_info_add(self, timefrmt, nick, NULL, msg, IN_MSG, 0, 0);
@ -188,7 +193,7 @@ static void chat_onAction(ToxWindow *self, Tox *m, int32_t num, uint8_t *action,
nick[n_len] = '\0'; nick[n_len] = '\0';
uint8_t timefrmt[TIME_STR_SIZE]; uint8_t timefrmt[TIME_STR_SIZE];
get_time_str(timefrmt); get_time_str(timefrmt, sizeof(timefrmt));
line_info_add(self, timefrmt, nick, NULL, action, ACTION, 0, 0); line_info_add(self, timefrmt, nick, NULL, action, ACTION, 0, 0);
write_to_log(action, nick, ctx->log, true); write_to_log(action, nick, ctx->log, true);
@ -453,6 +458,8 @@ void chat_onStarting (ToxWindow *self, ToxAv *av, int call_index)
if ( self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0)) if ( self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
return; return;
init_infobox(self);
line_info_add(self, NULL, NULL, NULL, "Call started! Type: \"/hangup\" to end it.", SYS_MSG, 0, 0); line_info_add(self, NULL, NULL, NULL, "Call started! Type: \"/hangup\" to end it.", SYS_MSG, 0, 0);
} }
@ -461,6 +468,7 @@ void chat_onEnding (ToxWindow *self, ToxAv *av, int call_index)
if (self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0)) if (self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
return; return;
kill_infobox(self);
self->call_idx = -1; self->call_idx = -1;
line_info_add(self, NULL, NULL, NULL, "Call ended!", SYS_MSG, 0, 0); line_info_add(self, NULL, NULL, NULL, "Call ended!", SYS_MSG, 0, 0);
} }
@ -479,6 +487,8 @@ void chat_onStart (ToxWindow *self, ToxAv *av, int call_index)
if ( self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0)) if ( self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
return; return;
init_infobox(self);
line_info_add(self, NULL, NULL, NULL, "Call started! Type: \"/hangup\" to end it.", SYS_MSG, 0, 0); line_info_add(self, NULL, NULL, NULL, "Call started! Type: \"/hangup\" to end it.", SYS_MSG, 0, 0);
} }
@ -487,6 +497,7 @@ void chat_onCancel (ToxWindow *self, ToxAv *av, int call_index)
if ( self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0)) if ( self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
return; return;
kill_infobox(self);
self->call_idx = -1; self->call_idx = -1;
line_info_add(self, NULL, NULL, NULL, "Call canceled!", SYS_MSG, 0, 0); line_info_add(self, NULL, NULL, NULL, "Call canceled!", SYS_MSG, 0, 0);
} }
@ -505,6 +516,7 @@ void chat_onEnd (ToxWindow *self, ToxAv *av, int call_index)
if (self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0)) if (self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
return; return;
kill_infobox(self);
self->call_idx = -1; self->call_idx = -1;
line_info_add(self, NULL, NULL, NULL, "Call ended!", SYS_MSG, 0, 0); line_info_add(self, NULL, NULL, NULL, "Call ended!", SYS_MSG, 0, 0);
} }
@ -523,10 +535,96 @@ void chat_onPeerTimeout (ToxWindow *self, ToxAv *av, int call_index)
if (self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0)) if (self->call_idx != call_index || self->num != toxav_get_peer_id(av, call_index, 0))
return; return;
kill_infobox(self);
self->call_idx = -1; self->call_idx = -1;
line_info_add(self, NULL, NULL, NULL, "Peer disconnected; call ended!", SYS_MSG, 0, 0); line_info_add(self, NULL, NULL, NULL, "Peer disconnected; call ended!", SYS_MSG, 0, 0);
} }
#define INFOBOX_HEIGHT 7
#define INFOBOX_WIDTH 21
static void init_infobox(ToxWindow *self)
{
ChatContext *ctx = self->chatwin;
int x2, y2;
getmaxyx(self->window, y2, x2);
memset(&ctx->infobox, 0, sizeof(struct infobox));
ctx->infobox.win = newwin(INFOBOX_HEIGHT, INFOBOX_WIDTH + 1, 1, x2 - INFOBOX_WIDTH);
ctx->infobox.starttime = get_unix_time();
ctx->infobox.vad_lvl = VAD_THRESHOLD_DEFAULT;
ctx->infobox.active = true;
strcpy(ctx->infobox.timestr, "00");
}
static void kill_infobox(ToxWindow *self)
{
ChatContext *ctx = self->chatwin;
if (!ctx->infobox.win)
return;
delwin(ctx->infobox.win);
memset(&ctx->infobox, 0, sizeof(struct infobox));
}
/* update infobox info and draw in respective chat window */
static void draw_infobox(ToxWindow *self)
{
struct infobox *infobox = &self->chatwin->infobox;
if (infobox->win == NULL)
return;
int x2, y2;
getmaxyx(self->window, y2, x2);
if (x2 < INFOBOX_WIDTH || y2 < INFOBOX_HEIGHT)
return;
uint64_t curtime = get_unix_time();
/* update elapsed time string once per second */
if (curtime > infobox->lastupdate)
get_elapsed_time_str(infobox->timestr, sizeof(infobox->timestr), curtime - infobox->starttime);
infobox->lastupdate = curtime;
const char *in_is_muted = infobox->in_is_muted ? "yes" : "no";
const char *out_is_muted = infobox->out_is_muted ? "yes" : "no";
wmove(infobox->win, 1, 1);
wattron(infobox->win, COLOR_PAIR(RED) | A_BOLD);
wprintw(infobox->win, " Call Active\n");
wattroff(infobox->win, COLOR_PAIR(RED) | A_BOLD);
wattron(infobox->win, A_BOLD);
wprintw(infobox->win, " Duration: ");
wattroff(infobox->win, A_BOLD);
wprintw(infobox->win, "%s\n", infobox->timestr);
wattron(infobox->win, A_BOLD);
wprintw(infobox->win, " In muted: ");
wattroff(infobox->win, A_BOLD);
wprintw(infobox->win, "%s\n", in_is_muted);
wattron(infobox->win, A_BOLD);
wprintw(infobox->win, " Out muted: ");
wattroff(infobox->win, A_BOLD);
wprintw(infobox->win, "%s\n", out_is_muted);
wattron(infobox->win, A_BOLD);
wprintw(infobox->win, " VAD level: ");
wattroff(infobox->win, A_BOLD);
wprintw(infobox->win, "%.2f\n", infobox->vad_lvl);
wborder(infobox->win, ACS_VLINE, ' ', ACS_HLINE, ACS_HLINE, ACS_TTEE, ' ', ACS_LLCORNER, ' ');
wrefresh(infobox->win);
}
#endif /* _SUPPORT_AUDIO */ #endif /* _SUPPORT_AUDIO */
static void send_action(ToxWindow *self, ChatContext *ctx, Tox *m, uint8_t *action) static void send_action(ToxWindow *self, ChatContext *ctx, Tox *m, uint8_t *action)
@ -539,7 +637,7 @@ static void send_action(ToxWindow *self, ChatContext *ctx, Tox *m, uint8_t *acti
selfname[len] = '\0'; selfname[len] = '\0';
uint8_t timefrmt[TIME_STR_SIZE]; uint8_t timefrmt[TIME_STR_SIZE];
get_time_str(timefrmt); get_time_str(timefrmt, sizeof(timefrmt));
line_info_add(self, timefrmt, selfname, NULL, action, ACTION, 0, 0); line_info_add(self, timefrmt, selfname, NULL, action, ACTION, 0, 0);
@ -740,7 +838,7 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
selfname[len] = '\0'; selfname[len] = '\0';
uint8_t timefrmt[TIME_STR_SIZE]; uint8_t timefrmt[TIME_STR_SIZE];
get_time_str(timefrmt); get_time_str(timefrmt, sizeof(timefrmt));
line_info_add(self, timefrmt, selfname, NULL, line, OUT_MSG, 0, 0); line_info_add(self, timefrmt, selfname, NULL, line, OUT_MSG, 0, 0);
@ -874,6 +972,14 @@ static void chat_onDraw(ToxWindow *self, Tox *m)
wprintw(statusbar->topline, "}\n"); wprintw(statusbar->topline, "}\n");
mvwhline(ctx->linewin, 0, 0, ACS_HLINE, x2); mvwhline(ctx->linewin, 0, 0, ACS_HLINE, x2);
#ifdef _SUPPORT_AUDIO
wrefresh(self->window);
if (ctx->infobox.active)
draw_infobox(self);
#endif
} }
static void chat_onInit(ToxWindow *self, Tox *m) static void chat_onInit(ToxWindow *self, Tox *m)

View File

@ -192,7 +192,7 @@ DeviceError open_device(DeviceType type, int32_t selection, uint32_t* device_idx
if (type == input) { if (type == input) {
device->dhndl = alcCaptureOpenDevice(devices_names[type][selection], device->dhndl = alcCaptureOpenDevice(devices_names[type][selection],
av_DefaultSettings.audio_sample_rate, AL_FORMAT_MONO16, frame_size * 4); av_DefaultSettings.audio_sample_rate, AL_FORMAT_MONO16, frame_size * 4);
device->VAD_treshold = 40.0; device->VAD_treshold = VAD_THRESHOLD_DEFAULT;
} }
else { else {
device->dhndl = alcOpenDevice(devices_names[type][selection]); device->dhndl = alcOpenDevice(devices_names[type][selection]);

View File

@ -83,7 +83,7 @@ static struct _dns_thread {
static int dns_error(ToxWindow *self, uint8_t *errmsg) static int dns_error(ToxWindow *self, uint8_t *errmsg)
{ {
uint8_t msg[MAX_STR_SIZE]; uint8_t msg[MAX_STR_SIZE];
snprintf(msg, sizeof(msg), "DNS lookup failed: %s", errmsg); snprintf(msg, sizeof(msg), "User lookup failed: %s", errmsg);
pthread_mutex_lock(&dns_thread.lock); pthread_mutex_lock(&dns_thread.lock);
line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0); line_info_add(self, NULL, NULL, NULL, msg, SYS_MSG, 0, 0);
@ -116,13 +116,13 @@ static int parse_dns_response(ToxWindow *self, u_char *answer, int ans_len, uint
ans_pt += len; ans_pt += len;
if (ans_pt > ans_end - 4) if (ans_pt > ans_end - 4)
return dns_error(self, "Reply was too short."); return dns_error(self, "DNS reply was too short.");
int type; int type;
GETSHORT(type, ans_pt); GETSHORT(type, ans_pt);
if (type != T_TXT) if (type != T_TXT)
return dns_error(self, "Broken reply."); return dns_error(self, "Broken DNS reply.");
ans_pt += INT16SZ; /* class */ ans_pt += INT16SZ; /* class */
@ -139,7 +139,7 @@ static int parse_dns_response(ToxWindow *self, u_char *answer, int ans_len, uint
ans_pt += len; ans_pt += len;
if (ans_pt > ans_end - 10) if (ans_pt > ans_end - 10)
return dns_error(self, "Reply was too short."); return dns_error(self, "DNS reply was too short.");
GETSHORT(type, ans_pt); GETSHORT(type, ans_pt);
ans_pt += INT16SZ; ans_pt += INT16SZ;
@ -152,7 +152,7 @@ static int parse_dns_response(ToxWindow *self, u_char *answer, int ans_len, uint
} while (type == T_CNAME); } while (type == T_CNAME);
if (type != T_TXT) if (type != T_TXT)
return dns_error(self, "Not a TXT record."); return dns_error(self, "DNS response failed.");
uint32_t txt_len = *ans_pt; uint32_t txt_len = *ans_pt;
@ -234,7 +234,7 @@ void *dns3_lookup_thread(void *data)
int str_len = tox_generate_dns3_string(dns_obj, string, sizeof(string), &request_id, name, namelen); int str_len = tox_generate_dns3_string(dns_obj, string, sizeof(string), &request_id, name, namelen);
if (str_len == -1) { if (str_len == -1) {
dns_error(self, "Core failed to generate dns3 string."); dns_error(self, "Core failed to generate DNS3 string.");
kill_dns_thread(dns_obj); kill_dns_thread(dns_obj);
} }
@ -248,7 +248,7 @@ void *dns3_lookup_thread(void *data)
int ans_len = res_query(d_string, C_IN, T_TXT, answer, sizeof(answer)); int ans_len = res_query(d_string, C_IN, T_TXT, answer, sizeof(answer));
if (ans_len <= 0) { if (ans_len <= 0) {
dns_error(self, "Query failed."); dns_error(self, "DNS query failed.");
kill_dns_thread(dns_obj); kill_dns_thread(dns_obj);
} }
@ -263,14 +263,14 @@ void *dns3_lookup_thread(void *data)
/* extract the encrypted ID from TXT response */ /* extract the encrypted ID from TXT response */
if (strncmp(ans_id, TOX_DNS3_TXT_PREFIX, prfx_len) != 0) { if (strncmp(ans_id, TOX_DNS3_TXT_PREFIX, prfx_len) != 0) {
dns_error(self, "Bad dns3 TXT response."); dns_error(self, "Bad DNS3 TXT response.");
kill_dns_thread(dns_obj); kill_dns_thread(dns_obj);
} }
memcpy(encrypted_id, ans_id + prfx_len, ans_len - prfx_len); memcpy(encrypted_id, ans_id + prfx_len, ans_len - prfx_len);
if (tox_decrypt_dns3_TXT(dns_obj, t_data.id_bin, encrypted_id, strlen(encrypted_id), request_id) == -1) { if (tox_decrypt_dns3_TXT(dns_obj, t_data.id_bin, encrypted_id, strlen(encrypted_id), request_id) == -1) {
dns_error(self, "Core failed to decrypt response."); dns_error(self, "Core failed to decrypt DNS response.");
kill_dns_thread(dns_obj); kill_dns_thread(dns_obj);
} }

View File

@ -59,6 +59,7 @@ static int friendlist_index[MAX_FRIENDS_NUM] = {0};
static struct _pendingDel { static struct _pendingDel {
int num; int num;
bool active; bool active;
WINDOW *popup;
} pendingdelete; } pendingdelete;
#define S_WEIGHT 100 #define S_WEIGHT 100
@ -91,7 +92,7 @@ void sort_friendlist_index(void)
static void update_friend_last_online(int32_t num, uint64_t timestamp) static void update_friend_last_online(int32_t num, uint64_t timestamp)
{ {
friends[num].last_online.last_on = timestamp; friends[num].last_online.last_on = timestamp;
friends[num].last_online.tm = *localtime(&timestamp); friends[num].last_online.tm = *localtime((const time_t*)&timestamp);
/* if the format changes make sure TIME_STR_SIZE is the correct size */ /* if the format changes make sure TIME_STR_SIZE is the correct size */
const char *t = user_settings->time == TIME_12 ? "%I:%M %p" : "%H:%M"; const char *t = user_settings->time == TIME_12 ? "%I:%M %p" : "%H:%M";
@ -116,7 +117,7 @@ static void friendlist_onMessage(ToxWindow *self, Tox *m, int32_t num, uint8_t *
nick[n_len] = '\0'; nick[n_len] = '\0';
uint8_t timefrmt[TIME_STR_SIZE]; uint8_t timefrmt[TIME_STR_SIZE];
get_time_str(timefrmt); get_time_str(timefrmt, sizeof(timefrmt));
line_info_add(prompt, timefrmt, nick, NULL, str, IN_MSG, 0, 0); line_info_add(prompt, timefrmt, nick, NULL, str, IN_MSG, 0, 0);
@ -298,7 +299,7 @@ static void del_friend_activate(ToxWindow *self, Tox *m, int32_t f_num)
{ {
int x2, y2; int x2, y2;
getmaxyx(self->window, y2, x2); getmaxyx(self->window, y2, x2);
self->popup = newwin(3, 22 + TOXIC_MAX_NAME_LENGTH, 8, 8); pendingdelete.popup = newwin(3, 22 + TOXIC_MAX_NAME_LENGTH, 8, 8);
pendingdelete.active = true; pendingdelete.active = true;
pendingdelete.num = f_num; pendingdelete.num = f_num;
@ -310,30 +311,29 @@ static void del_friend_deactivate(ToxWindow *self, Tox *m, wint_t key)
if (key == 'y') if (key == 'y')
delete_friend(m, pendingdelete.num); delete_friend(m, pendingdelete.num);
delwin(pendingdelete.popup);
memset(&pendingdelete, 0, sizeof(pendingdelete)); memset(&pendingdelete, 0, sizeof(pendingdelete));
delwin(self->popup);
self->popup = NULL;
clear(); clear();
refresh(); refresh();
} }
static void draw_popup(ToxWindow *self, Tox *m) static void draw_popup(void)
{ {
if (self->popup == NULL) if (!pendingdelete.active)
return; return;
wattron(self->popup, A_BOLD); wattron(pendingdelete.popup, A_BOLD);
box(self->popup, ACS_VLINE, ACS_HLINE); box(pendingdelete.popup, ACS_VLINE, ACS_HLINE);
wattroff(self->popup, A_BOLD); wattroff(pendingdelete.popup, A_BOLD);
wmove(self->popup, 1, 1); wmove(pendingdelete.popup, 1, 1);
wprintw(self->popup, "Delete contact "); wprintw(pendingdelete.popup, "Delete contact ");
wattron(self->popup, A_BOLD); wattron(pendingdelete.popup, A_BOLD);
wprintw(self->popup, "%s", friends[pendingdelete.num].name); wprintw(pendingdelete.popup, "%s", friends[pendingdelete.num].name);
wattroff(self->popup, A_BOLD); wattroff(pendingdelete.popup, A_BOLD);
wprintw(self->popup, "? y/n"); wprintw(pendingdelete.popup, "? y/n");
wrefresh(self->popup); wrefresh(pendingdelete.popup);
} }
static void friendlist_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr) static void friendlist_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
@ -383,7 +383,7 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
getmaxyx(self->window, y2, x2); getmaxyx(self->window, y2, x2);
uint64_t cur_time = get_unix_time(); uint64_t cur_time = get_unix_time();
struct tm cur_loc_tm = *localtime(&cur_time); struct tm cur_loc_tm = *localtime((const time_t*)&cur_time);
bool fix_statuses = x2 != self->x; /* true if window x axis has changed */ bool fix_statuses = x2 != self->x; /* true if window x axis has changed */
@ -540,7 +540,7 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
self->x = x2; self->x = x2;
wrefresh(self->window); wrefresh(self->window);
draw_popup(self, m); draw_popup();
if (num_friends) { if (num_friends) {
wmove(self->window, y2 - 1, 1); wmove(self->window, y2 - 1, 1);

View File

@ -29,8 +29,6 @@
#include "windows.h" #include "windows.h"
#include "file_senders.h" #include "file_senders.h"
#define TIME_STR_SIZE 16
struct FileReceiver { struct FileReceiver {
uint8_t filenames[MAX_FILES][MAX_STR_SIZE]; uint8_t filenames[MAX_FILES][MAX_STR_SIZE];
FILE *files[MAX_FILES]; FILE *files[MAX_FILES];

View File

@ -200,7 +200,7 @@ static void groupchat_onGroupMessage(ToxWindow *self, Tox *m, int groupnum, int
alert_window(self, alert_type, beep); alert_window(self, alert_type, beep);
uint8_t timefrmt[TIME_STR_SIZE]; uint8_t timefrmt[TIME_STR_SIZE];
get_time_str(timefrmt); get_time_str(timefrmt, sizeof(timefrmt));
line_info_add(self, timefrmt, nick, NULL, msg, IN_MSG, 0, nick_clr); line_info_add(self, timefrmt, nick, NULL, msg, IN_MSG, 0, nick_clr);
write_to_log(msg, nick, ctx->log, false); write_to_log(msg, nick, ctx->log, false);
@ -240,7 +240,7 @@ static void groupchat_onGroupAction(ToxWindow *self, Tox *m, int groupnum, int p
nick[n_len] = '\0'; nick[n_len] = '\0';
uint8_t timefrmt[TIME_STR_SIZE]; uint8_t timefrmt[TIME_STR_SIZE];
get_time_str(timefrmt); get_time_str(timefrmt, sizeof(timefrmt));
line_info_add(self, timefrmt, nick, NULL, action, ACTION, 0, 0); line_info_add(self, timefrmt, nick, NULL, action, ACTION, 0, 0);
write_to_log(action, nick, ctx->log, true); write_to_log(action, nick, ctx->log, true);
@ -339,7 +339,7 @@ static void groupchat_onGroupNamelistChange(ToxWindow *self, Tox *m, int groupnu
uint8_t *event; uint8_t *event;
uint8_t timefrmt[TIME_STR_SIZE]; uint8_t timefrmt[TIME_STR_SIZE];
get_time_str(timefrmt); get_time_str(timefrmt, sizeof(timefrmt));
switch (change) { switch (change) {
case TOX_CHAT_CHANGE_PEER_ADD: case TOX_CHAT_CHANGE_PEER_ADD:

View File

@ -55,14 +55,33 @@ struct tm *get_time(void)
{ {
struct tm *timeinfo; struct tm *timeinfo;
uint64_t t = get_unix_time(); uint64_t t = get_unix_time();
timeinfo = localtime(&t); timeinfo = localtime((const time_t*)&t);
return timeinfo; return timeinfo;
} }
void get_time_str(uint8_t *buf) /*Puts the current time in buf in the format of [HH:mm:ss] */
void get_time_str(uint8_t *buf, int bufsize)
{ {
const char *t = user_settings->time == TIME_12 ? "[%-I:%M:%S] " : "[%H:%M:%S] "; const char *t = user_settings->time == TIME_12 ? "[%-I:%M:%S] " : "[%H:%M:%S] ";
strftime(buf, TIME_STR_SIZE, t, get_time()); strftime(buf, bufsize, t, get_time());
}
/* Converts seconds to string in format HH:mm:ss; truncates hours and minutes when necessary */
void get_elapsed_time_str(uint8_t *buf, int bufsize, uint64_t secs)
{
if (!secs)
return;
uint64_t seconds = secs % 60;
uint64_t minutes = (secs % 3600) / 60;
uint64_t hours = secs / 3600;
if (!minutes && !hours)
snprintf(buf, bufsize, "%.2ld", seconds);
else if (!hours)
snprintf(buf, bufsize, "%ld:%.2ld", minutes, seconds);
else
snprintf(buf, bufsize, "%ld:%.2ld:%.2ld", hours, minutes, seconds);
} }
char *hex_string_to_bin(const char *hex_string) char *hex_string_to_bin(const char *hex_string)
@ -70,11 +89,8 @@ char *hex_string_to_bin(const char *hex_string)
size_t len = strlen(hex_string); size_t len = strlen(hex_string);
char *val = malloc(len); char *val = malloc(len);
if (val == NULL) { if (val == NULL)
endwin(); exit_toxic_err("failed in hex_string_to_bin", FATALERR_MEMORY);
fprintf(stderr, "malloc() failed. Aborting...\n");
exit(EXIT_FAILURE);
}
size_t i; size_t i;
@ -90,7 +106,7 @@ int string_is_empty(char *string)
return string[0] == '\0'; return string[0] == '\0';
} }
/* convert a multibyte string to a wide character string (must provide buffer) */ /* convert a multibyte string to a wide character string and puts in buf. */
int mbs_to_wcs_buf(wchar_t *buf, const uint8_t *string, size_t n) int mbs_to_wcs_buf(wchar_t *buf, const uint8_t *string, size_t n)
{ {
size_t len = mbstowcs(NULL, string, 0) + 1; size_t len = mbstowcs(NULL, string, 0) + 1;
@ -104,8 +120,7 @@ int mbs_to_wcs_buf(wchar_t *buf, const uint8_t *string, size_t n)
return len; return len;
} }
/* converts wide character string into a multibyte string. /* converts wide character string into a multibyte string and puts in buf. */
Same thing as wcs_to_mbs() but caller must provide its own buffer */
int wcs_to_mbs_buf(uint8_t *buf, const wchar_t *string, size_t n) int wcs_to_mbs_buf(uint8_t *buf, const wchar_t *string, size_t n)
{ {
size_t len = wcstombs(NULL, string, 0) + 1; size_t len = wcstombs(NULL, string, 0) + 1;
@ -119,53 +134,6 @@ int wcs_to_mbs_buf(uint8_t *buf, const wchar_t *string, size_t n)
return len; return len;
} }
/* convert wide characters to multibyte string: string returned must be freed */
uint8_t *wcs_to_mbs(wchar_t *string)
{
uint8_t *ret = NULL;
size_t len = wcstombs(NULL, string, 0);
if (len != (size_t) - 1) {
ret = malloc(++len);
if (ret != NULL) {
if (wcstombs(ret, string, len) == (size_t) - 1)
return NULL;
}
} else {
ret = malloc(2);
if (ret != NULL) {
ret[0] = ' ';
ret[1] = '\0';
}
}
if (ret == NULL) {
endwin();
fprintf(stderr, "malloc() failed. Aborting...\n");
exit(EXIT_FAILURE);
}
return ret;
}
/* convert a wide char to multibyte string */
char *wc_to_char(wchar_t ch)
{
static char ret[MB_LEN_MAX + 1];
int len = wctomb(ret, ch);
if (len == -1) {
ret[0] = ' ';
ret[1] = '\0';
} else {
ret[len] = '\0';
}
return ret;
}
/* Returns 1 if connection has timed out, 0 otherwise */ /* Returns 1 if connection has timed out, 0 otherwise */
int timed_out(uint64_t timestamp, uint64_t curtime, uint64_t timeout) int timed_out(uint64_t timestamp, uint64_t curtime, uint64_t timeout)
{ {

View File

@ -39,8 +39,11 @@ char *hex_string_to_bin(const char *hex_string);
/* get the current unix time */ /* get the current unix time */
uint64_t get_unix_time(void); uint64_t get_unix_time(void);
/*Puts the current time in buf in the format of [Hour:Min:Sec] */ /*Puts the current time in buf in the format of [HH:mm:ss] */
void get_time_str(uint8_t *buf); void get_time_str(uint8_t *buf, int bufsize);
/* Converts seconds to string in format HH:mm:ss; truncates hours and minutes when necessary */
void get_elapsed_time_str(uint8_t *buf, int bufsize, uint64_t secs);
/* get the current local time */ /* get the current local time */
struct tm *get_time(void); struct tm *get_time(void);
@ -54,19 +57,12 @@ int string_is_empty(char *string);
/* convert a multibyte string to a wide character string (must provide buffer) */ /* convert a multibyte string to a wide character string (must provide buffer) */
int char_to_wcs_buf(wchar_t *buf, const uint8_t *string, size_t n); int char_to_wcs_buf(wchar_t *buf, const uint8_t *string, size_t n);
/* converts wide character string into a multibyte string. /* converts wide character string into a multibyte string and puts in buf. */
Same thing as wcs_to_mbs() but caller must provide its own buffer */
int wcs_to_mbs_buf(uint8_t *buf, const wchar_t *string, size_t n); int wcs_to_mbs_buf(uint8_t *buf, const wchar_t *string, size_t n);
/* convert a multibyte string to a wide character string (must provide buffer) */ /* convert a multibyte string to a wide character string and puts in buf) */
int mbs_to_wcs_buf(wchar_t *buf, const uint8_t *string, size_t n); int mbs_to_wcs_buf(wchar_t *buf, const uint8_t *string, size_t n);
/* convert wide characters to multibyte string: string returned must be free'd */
uint8_t *wcs_to_mbs(wchar_t *string);
/* convert a wide char to multibyte char */
char *wc_to_char(wchar_t ch);
/* Returns 1 if connection has timed out, 0 otherwise */ /* Returns 1 if connection has timed out, 0 otherwise */
int timed_out(uint64_t timestamp, uint64_t timeout, uint64_t curtime); int timed_out(uint64_t timestamp, uint64_t timeout, uint64_t curtime);

View File

@ -372,7 +372,7 @@ static void prompt_onConnectionChange(ToxWindow *self, Tox *m, int32_t friendnum
nick[n_len] = '\0'; nick[n_len] = '\0';
uint8_t timefrmt[TIME_STR_SIZE]; uint8_t timefrmt[TIME_STR_SIZE];
get_time_str(timefrmt); get_time_str(timefrmt, sizeof(timefrmt));
uint8_t *msg; uint8_t *msg;
if (status == 1) { if (status == 1) {
@ -393,7 +393,7 @@ static void prompt_onFriendRequest(ToxWindow *self, Tox *m, const uint8_t *key,
ChatContext *ctx = self->chatwin; ChatContext *ctx = self->chatwin;
uint8_t timefrmt[TIME_STR_SIZE]; uint8_t timefrmt[TIME_STR_SIZE];
get_time_str(timefrmt); get_time_str(timefrmt, sizeof(timefrmt));
uint8_t msg[MAX_STR_SIZE]; uint8_t msg[MAX_STR_SIZE];
snprintf(msg, sizeof(msg), "Friend request with the message '%s'", data); snprintf(msg, sizeof(msg), "Friend request with the message '%s'", data);

View File

@ -110,6 +110,7 @@ struct ToxWindow {
int call_idx; /* If in a call will have this index set, otherwise it's -1. int call_idx; /* If in a call will have this index set, otherwise it's -1.
* Don't modify outside av callbacks. */ * Don't modify outside av callbacks. */
int device_selection[2]; /* -1 if not set, if set uses these selections instead of primary device */ int device_selection[2]; /* -1 if not set, if set uses these selections instead of primary device */
#endif /* _SUPPORT_AUDIO */ #endif /* _SUPPORT_AUDIO */
char name[TOX_MAX_NAME_LENGTH]; char name[TOX_MAX_NAME_LENGTH];
@ -129,7 +130,6 @@ struct ToxWindow {
ChatContext *chatwin; ChatContext *chatwin;
StatusBar *stb; StatusBar *stb;
WINDOW *popup;
WINDOW *window; WINDOW *window;
}; };
@ -144,6 +144,23 @@ struct StatusBar {
bool is_online; bool is_online;
}; };
#ifdef _SUPPORT_AUDIO
/* holds display info for audio calls */
struct infobox {
float vad_lvl;
bool in_is_muted;
bool out_is_muted;
bool hide;
bool active;
uint64_t lastupdate;
uint64_t starttime;
char timestr[TIME_STR_SIZE];
WINDOW *win;
};
#endif
#define MAX_LINE_HIST 128 #define MAX_LINE_HIST 128
/* chat and groupchat window/buffer holder */ /* chat and groupchat window/buffer holder */
@ -160,6 +177,10 @@ struct ChatContext {
struct history *hst; struct history *hst;
struct chatlog *log; struct chatlog *log;
#ifdef _SUPPORT_AUDIO
struct infobox infobox;
#endif
uint8_t self_is_typing; uint8_t self_is_typing;
WINDOW *history; WINDOW *history;