From dc5a8d44e5f9dacba2bd79dc563e13804b75b358 Mon Sep 17 00:00:00 2001 From: "Henrique N. Lengler" Date: Sun, 15 Mar 2015 16:27:00 -0300 Subject: [PATCH 1/8] Add OpenBSD option to Makefile --- build/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/Makefile b/build/Makefile index 2ebc5db..6f4ec4c 100644 --- a/build/Makefile +++ b/build/Makefile @@ -24,6 +24,9 @@ endif ifeq ($(UNAME_S), FreeBSD) -include $(CFG_DIR)/systems/FreeBSD.mk endif +ifeq ($(UNAME_S), OpenBSD) + -include $(CFG_DIR)/systems/FreeBSD.mk +endif ifeq ($(UNAME_S), Darwin) -include $(CFG_DIR)/systems/Darwin.mk endif From 2b2e74654950639e5650e73b7a8dc851a1fc9ab1 Mon Sep 17 00:00:00 2001 From: "Henrique N. Lengler" Date: Sun, 15 Mar 2015 16:34:56 -0300 Subject: [PATCH 2/8] added gnumake as dep., because you can't compile with *BSDmake --- INSTALL.md | 1 + 1 file changed, 1 insertion(+) diff --git a/INSTALL.md b/INSTALL.md index 6dc0bba..8633b93 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -14,6 +14,7 @@ | [Tox Core](https://github.com/irungentoo/toxcore) | BASE | *None* | | [NCurses](https://www.gnu.org/software/ncurses) | BASE | libncursesw5-dev | | [LibConfig](http://www.hyperrealm.com/libconfig) | BASE | libconfig-dev | +| [GNUmake](http://www.gnu.org/software/make/) | BASE | make | | [Tox Core AV](https://github.com/irungentoo/toxcore) | AUDIO | *None* | | [OpenAL](http://openal.org) | AUDIO, SOUND NOTIFICATIONS | libopenal-dev | | [OpenALUT](http://openal.org) | SOUND NOTIFICATIONS | libalut-dev | From 59e11149977adebdf361c663367e8d97c23e8598 Mon Sep 17 00:00:00 2001 From: Ansa89 Date: Mon, 16 Mar 2015 13:16:03 +0100 Subject: [PATCH 3/8] Some cosmetics changes --- INSTALL.md | 2 +- build/Makefile | 14 +++++++------- cfg/checks/av.mk | 22 ++++++++++------------ cfg/checks/check_features.mk | 26 ++++++++++++-------------- cfg/checks/desktop_notifications.mk | 16 +++++++--------- cfg/checks/sound_notifications.mk | 22 ++++++++++------------ cfg/checks/x11.mk | 18 ++++++++---------- cfg/global_vars.mk | 4 ++-- cfg/targets/install.mk | 6 +++--- 9 files changed, 60 insertions(+), 70 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 8633b93..88b87a9 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -14,7 +14,7 @@ | [Tox Core](https://github.com/irungentoo/toxcore) | BASE | *None* | | [NCurses](https://www.gnu.org/software/ncurses) | BASE | libncursesw5-dev | | [LibConfig](http://www.hyperrealm.com/libconfig) | BASE | libconfig-dev | -| [GNUmake](http://www.gnu.org/software/make/) | BASE | make | +| [GNUmake](https://www.gnu.org/software/make) | BASE | make | | [Tox Core AV](https://github.com/irungentoo/toxcore) | AUDIO | *None* | | [OpenAL](http://openal.org) | AUDIO, SOUND NOTIFICATIONS | libopenal-dev | | [OpenALUT](http://openal.org) | SOUND NOTIFICATIONS | libalut-dev | diff --git a/build/Makefile b/build/Makefile index 6f4ec4c..9d4b45d 100644 --- a/build/Makefile +++ b/build/Makefile @@ -19,31 +19,31 @@ OBJ += group_commands.o term_mplex.o # Check on wich system we are running UNAME_S = $(shell uname -s) ifeq ($(UNAME_S), Linux) - -include $(CFG_DIR)/systems/Linux.mk + -include $(CFG_DIR)/systems/Linux.mk endif ifeq ($(UNAME_S), FreeBSD) - -include $(CFG_DIR)/systems/FreeBSD.mk + -include $(CFG_DIR)/systems/FreeBSD.mk endif ifeq ($(UNAME_S), OpenBSD) -include $(CFG_DIR)/systems/FreeBSD.mk endif ifeq ($(UNAME_S), Darwin) - -include $(CFG_DIR)/systems/Darwin.mk + -include $(CFG_DIR)/systems/Darwin.mk endif ifeq ($(UNAME_S), Solaris) - -include $(CFG_DIR)/systems/Solaris.mk + -include $(CFG_DIR)/systems/Solaris.mk endif # Check on which platform we are running UNAME_M = $(shell uname -m) ifeq ($(UNAME_M), x86_64) - -include $(CFG_DIR)/platforms/x86_64.mk + -include $(CFG_DIR)/platforms/x86_64.mk endif ifneq ($(filter %86, $(UNAME_M)),) - -include $(CFG_DIR)/platforms/x86.mk + -include $(CFG_DIR)/platforms/x86.mk endif ifneq ($(filter arm%, $(UNAME_M)),) - -include $(CFG_DIR)/platforms/arm.mk + -include $(CFG_DIR)/platforms/arm.mk endif # Include all needed checks diff --git a/cfg/checks/av.mk b/cfg/checks/av.mk index 54d93ed..4d3837e 100644 --- a/cfg/checks/av.mk +++ b/cfg/checks/av.mk @@ -2,22 +2,20 @@ AUDIO_LIBS = libtoxav openal AUDIO_CFLAGS = -DAUDIO ifneq (, $(findstring device.o, $(OBJ))) - AUDIO_OBJ = audio_call.o + AUDIO_OBJ = audio_call.o else - AUDIO_OBJ = audio_call.o device.o + AUDIO_OBJ = audio_call.o device.o endif # Check if we can build audio support CHECK_AUDIO_LIBS = $(shell pkg-config --exists $(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 --exists $$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 + 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 --exists $$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 diff --git a/cfg/checks/check_features.mk b/cfg/checks/check_features.mk index 33c937b..430d1af 100644 --- a/cfg/checks/check_features.mk +++ b/cfg/checks/check_features.mk @@ -3,38 +3,36 @@ CHECKS_DIR = $(CFG_DIR)/checks # Check if we want build X11 support X11 = $(shell if [ -z "$(DISABLE_X11)" ] || [ "$(DISABLE_X11)" = "0" ] ; then echo enabled ; else echo disabled ; fi) ifneq ($(X11), disabled) - -include $(CHECKS_DIR)/x11.mk + -include $(CHECKS_DIR)/x11.mk endif # Check if we want build audio support AUDIO = $(shell if [ -z "$(DISABLE_AV)" ] || [ "$(DISABLE_AV)" = "0" ] ; then echo enabled ; else echo disabled ; fi) ifneq ($(AUDIO), disabled) - -include $(CHECKS_DIR)/av.mk + -include $(CHECKS_DIR)/av.mk endif # Check if we want build sound notifications support SND_NOTIFY = $(shell if [ -z "$(DISABLE_SOUND_NOTIFY)" ] || [ "$(DISABLE_SOUND_NOTIFY)" = "0" ] ; then echo enabled ; else echo disabled ; fi) ifneq ($(SND_NOTIFY), disabled) - -include $(CHECKS_DIR)/sound_notifications.mk + -include $(CHECKS_DIR)/sound_notifications.mk endif # Check if we want build desktop notifications support DESK_NOTIFY = $(shell if [ -z "$(DISABLE_DESKTOP_NOTIFY)" ] || [ "$(DISABLE_DESKTOP_NOTIFY)" = "0" ] ; then echo enabled ; else echo disabled ; fi) ifneq ($(DESK_NOTIFY), disabled) - -include $(CHECKS_DIR)/desktop_notifications.mk + -include $(CHECKS_DIR)/desktop_notifications.mk endif # Check if we can build Toxic CHECK_LIBS = $(shell pkg-config --exists $(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 --exists $$lib ; then echo $$lib ; fi ; done) -$(warning ERROR -- Cannot compile Toxic) -$(warning ERROR -- You need these libraries) -$(warning ERROR -- $(MISSING_LIBS)) -$(error ERROR) -endif + 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 --exists $$lib ; then echo $$lib ; fi ; done) + $(warning ERROR -- Cannot compile Toxic) + $(warning ERROR -- You need these libraries) + $(warning ERROR -- $(MISSING_LIBS)) + $(error ERROR) endif diff --git a/cfg/checks/desktop_notifications.mk b/cfg/checks/desktop_notifications.mk index 7901207..97d2531 100644 --- a/cfg/checks/desktop_notifications.mk +++ b/cfg/checks/desktop_notifications.mk @@ -5,13 +5,11 @@ DESK_NOTIFY_CFLAGS = -DBOX_NOTIFY # Check if we can build desktop notifications support CHECK_DESK_NOTIFY_LIBS = $(shell pkg-config --exists $(DESK_NOTIFY_LIBS) || echo -n "error") ifneq ($(CHECK_DESK_NOTIFY_LIBS), error) - LIBS += $(DESK_NOTIFY_LIBS) - CFLAGS += $(DESK_NOTIFY_CFLAGS) -else -ifneq ($(MAKECMDGOALS), clean) -MISSING_DESK_NOTIFY_LIBS = $(shell for lib in $(DESK_NOTIFY_LIBS) ; do if ! pkg-config --exists $$lib ; then echo $$lib ; fi ; done) -$(warning WARNING -- Toxic will be compiled without desktop notifications support) -$(warning WARNING -- You need these libraries for desktop notifications support) -$(warning WARNING -- $(MISSING_DESK_NOTIFY_LIBS)) -endif + LIBS += $(DESK_NOTIFY_LIBS) + CFLAGS += $(DESK_NOTIFY_CFLAGS) +else ifneq ($(MAKECMDGOALS), clean) + MISSING_DESK_NOTIFY_LIBS = $(shell for lib in $(DESK_NOTIFY_LIBS) ; do if ! pkg-config --exists $$lib ; then echo $$lib ; fi ; done) + $(warning WARNING -- Toxic will be compiled without desktop notifications support) + $(warning WARNING -- You need these libraries for desktop notifications support) + $(warning WARNING -- $(MISSING_DESK_NOTIFY_LIBS)) endif diff --git a/cfg/checks/sound_notifications.mk b/cfg/checks/sound_notifications.mk index 1413651..e8dc699 100644 --- a/cfg/checks/sound_notifications.mk +++ b/cfg/checks/sound_notifications.mk @@ -2,22 +2,20 @@ SND_NOTIFY_LIBS = openal freealut SND_NOTIFY_CFLAGS = -DSOUND_NOTIFY ifneq (, $(findstring device.o, $(OBJ))) - SND_NOTIFY_OBJ = + SND_NOTIFY_OBJ = else - SND_NOTIFY_OBJ = device.o + SND_NOTIFY_OBJ = device.o endif # Check if we can build sound notifications support CHECK_SND_NOTIFY_LIBS = $(shell pkg-config --exists $(SND_NOTIFY_LIBS) || echo -n "error") ifneq ($(CHECK_SND_NOTIFY_LIBS), error) - LIBS += $(SND_NOTIFY_LIBS) - CFLAGS += $(SND_NOTIFY_CFLAGS) - OBJ += $(SND_NOTIFY_OBJ) -else -ifneq ($(MAKECMDGOALS), clean) -MISSING_SND_NOTIFY_LIBS = $(shell for lib in $(SND_NOTIFY_LIBS) ; do if ! pkg-config --exists $$lib ; then echo $$lib ; fi ; done) -$(warning WARNING -- Toxic will be compiled without sound notifications support) -$(warning WARNING -- You need these libraries for sound notifications support) -$(warning WARNING -- $(MISSING_SND_NOTIFY_LIBS)) -endif + LIBS += $(SND_NOTIFY_LIBS) + CFLAGS += $(SND_NOTIFY_CFLAGS) + OBJ += $(SND_NOTIFY_OBJ) +else ifneq ($(MAKECMDGOALS), clean) + MISSING_SND_NOTIFY_LIBS = $(shell for lib in $(SND_NOTIFY_LIBS) ; do if ! pkg-config --exists $$lib ; then echo $$lib ; fi ; done) + $(warning WARNING -- Toxic will be compiled without sound notifications support) + $(warning WARNING -- You need these libraries for sound notifications support) + $(warning WARNING -- $(MISSING_SND_NOTIFY_LIBS)) endif diff --git a/cfg/checks/x11.mk b/cfg/checks/x11.mk index f7c5c07..94c2f97 100644 --- a/cfg/checks/x11.mk +++ b/cfg/checks/x11.mk @@ -6,14 +6,12 @@ X11_OBJ = xtra.o # Check if we can build X11 support CHECK_X11_LIBS = $(shell pkg-config --exists $(X11_LIBS) || echo -n "error") ifneq ($(CHECK_X11_LIBS), error) - LIBS += $(X11_LIBS) - CFLAGS += $(X11_CFLAGS) - OBJ += $(X11_OBJ) -else -ifneq ($(MAKECMDGOALS), clean) -MISSING_X11_LIBS = $(shell for lib in $(X11_LIBS) ; do if ! pkg-config --exists $$lib ; then echo $$lib ; fi ; done) -$(warning WARNING -- Toxic will be compiled without x11 support (needed for focus tracking and drag&drop support)) -$(warning WARNING -- You need these libraries for x11 support) -$(warning WARNING -- $(MISSING_X11_LIBS)) -endif + LIBS += $(X11_LIBS) + CFLAGS += $(X11_CFLAGS) + OBJ += $(X11_OBJ) +else ifneq ($(MAKECMDGOALS), clean) + MISSING_X11_LIBS = $(shell for lib in $(X11_LIBS) ; do if ! pkg-config --exists $$lib ; then echo $$lib ; fi ; done) + $(warning WARNING -- Toxic will be compiled without x11 support (needed for focus tracking and drag&drop support)) + $(warning WARNING -- You need these libraries for x11 support) + $(warning WARNING -- $(MISSING_X11_LIBS)) endif diff --git a/cfg/global_vars.mk b/cfg/global_vars.mk index 9c70dfe..832ad49 100644 --- a/cfg/global_vars.mk +++ b/cfg/global_vars.mk @@ -2,9 +2,9 @@ TOXIC_VERSION = 0.5.2 REV = $(shell git rev-list HEAD --count 2>/dev/null || echo -n "error") ifneq (, $(findstring error, $(REV))) - VERSION = $(TOXIC_VERSION) + VERSION = $(TOXIC_VERSION) else - VERSION = $(TOXIC_VERSION)_r$(REV) + VERSION = $(TOXIC_VERSION)_r$(REV) endif # Project directories diff --git a/cfg/targets/install.mk b/cfg/targets/install.mk index ff992df..49155b2 100644 --- a/cfg/targets/install.mk +++ b/cfg/targets/install.mk @@ -3,11 +3,11 @@ install: toxic @echo "Installing toxic executable" @mkdir -p $(abspath $(DESTDIR)/$(BINDIR)) @install -m 0755 toxic $(abspath $(DESTDIR)/$(BINDIR)/toxic) - + @echo "Installing desktop file" @mkdir -p $(abspath $(DESTDIR)/$(APPDIR)) @install -m 0644 $(MISC_DIR)/$(DESKFILE) $(abspath $(DESTDIR)/$(APPDIR)/$(DESKFILE)) - + @echo "Installing data files" @mkdir -p $(abspath $(DESTDIR)/$(DATADIR)) @for f in $(DATAFILES) ; do \ @@ -19,7 +19,7 @@ install: toxic @for f in $(SNDFILES) ; do \ install -m 0644 $(SND_DIR)/$$f $(abspath $(DESTDIR)/$(DATADIR)/sounds/$$f) ;\ done - + @echo "Installing man pages" @mkdir -p $(abspath $(DESTDIR)/$(MANDIR)) @for f in $(MANFILES) ; do \ From ce1ae1d7dc16ba63cedb2ab8ce6d36dd544fa23c Mon Sep 17 00:00:00 2001 From: jlo Date: Tue, 17 Mar 2015 14:25:15 -0500 Subject: [PATCH 4/8] added tab autocomplete for "/status o" => "/status online" --- src/autocomplete.c | 8 +++--- src/chat.c | 64 ++++++++++++++++++++++++++-------------------- src/prompt.c | 19 +++++++++----- src/toxic.c | 1 + 4 files changed, 54 insertions(+), 38 deletions(-) diff --git a/src/autocomplete.c b/src/autocomplete.c index 5b6af44..11f7965 100644 --- a/src/autocomplete.c +++ b/src/autocomplete.c @@ -245,7 +245,7 @@ int dir_match(ToxWindow *self, Tox *m, const wchar_t *line, const wchar_t *cmd) const wchar_t *tmpline = &line[wcslen(cmd) + 2]; /* start after "/command \"" */ if (wcs_to_mbs_buf(b_path, tmpline, sizeof(b_path)) == -1) - return -1; + return -1; if (wcs_to_mbs_buf(b_cmd, cmd, sizeof(b_cmd)) == -1) return -1; @@ -257,11 +257,11 @@ int dir_match(ToxWindow *self, Tox *m, const wchar_t *line, const wchar_t *cmd) if (!b_path[0]) { /* list everything in pwd */ b_path[0] = '.'; - b_path[1] = '\0'; + b_path[1] = '\0'; } else if (!si && b_path[0] != '/') { /* look for matches in pwd */ char tmp[MAX_STR_SIZE]; snprintf(tmp, sizeof(tmp), ".%s", b_path); - strcpy(b_path, tmp); + strcpy(b_path, tmp); } strcpy(b_name, &b_path[si + 1]); @@ -277,7 +277,7 @@ int dir_match(ToxWindow *self, Tox *m, const wchar_t *line, const wchar_t *cmd) int dircount = 0; while ((entry = readdir(dp)) && dircount < MAX_DIRS) { - if (strncmp(entry->d_name, b_name, b_name_len) == 0 + if (strncmp(entry->d_name, b_name, b_name_len) == 0 && strcmp(".", entry->d_name) && strcmp("..", entry->d_name)) { snprintf(dirnames[dircount], sizeof(dirnames[dircount]), "%s", entry->d_name); ++dircount; diff --git a/src/chat.c b/src/chat.c index e44546d..b221905 100644 --- a/src/chat.c +++ b/src/chat.c @@ -160,12 +160,12 @@ static void chat_onMessage(ToxWindow *self, Tox *m, int32_t num, const char *msg line_info_add(self, timefrmt, nick, NULL, IN_MSG, 0, 0, "%s", msg); write_to_log(msg, nick, ctx->log, false); - - if (self->active_box != -1) - box_notify2(self, generic_message, NT_WNDALERT_1 | NT_NOFOCUS, self->active_box, "%s", msg); - else + + if (self->active_box != -1) + box_notify2(self, generic_message, NT_WNDALERT_1 | NT_NOFOCUS, self->active_box, "%s", msg); + else box_notify(self, generic_message, NT_WNDALERT_1 | NT_NOFOCUS, &self->active_box, nick, "%s", msg); - + } static void chat_resume_file_transfers(Tox *m, int fnum); @@ -188,7 +188,7 @@ static void chat_onConnectionChange(ToxWindow *self, Tox *m, int32_t num, uint8_ if (status == 1) { /* Friend goes online */ statusbar->is_online = true; - Friends.list[num].is_typing = user_settings->show_typing_other == SHOW_TYPING_ON + Friends.list[num].is_typing = user_settings->show_typing_other == SHOW_TYPING_ON ? tox_get_is_typing(m, num) : 0; chat_resume_file_transfers(m, num); @@ -233,7 +233,7 @@ static void chat_onAction(ToxWindow *self, Tox *m, int32_t num, const char *acti line_info_add(self, timefrmt, nick, NULL, IN_ACTION, 0, 0, "%s", action); write_to_log(action, nick, ctx->log, true); - + if (self->active_box != -1) box_notify2(self, generic_message, NT_WNDALERT_1 | NT_NOFOCUS, self->active_box, "* %s %s", nick, action ); else @@ -352,10 +352,10 @@ static void chat_onFileSendRequest(ToxWindow *self, Tox *m, int32_t num, uint8_t strcpy(Friends.list[num].file_receiver[filenum].filename, filename); if (self->active_box != -1) - box_notify2(self, transfer_pending, NT_WNDALERT_0 | NT_NOFOCUS, self->active_box, + box_notify2(self, transfer_pending, NT_WNDALERT_0 | NT_NOFOCUS, self->active_box, "Incoming file: %s", filename ); else - box_notify(self, transfer_pending, NT_WNDALERT_0 | NT_NOFOCUS, &self->active_box, self->name, + box_notify(self, transfer_pending, NT_WNDALERT_0 | NT_NOFOCUS, &self->active_box, self->name, "Incoming file: %s", filename ); } @@ -478,7 +478,7 @@ static void chat_onFileControl(ToxWindow *self, Tox *m, int32_t num, uint8_t rec snprintf(msg, sizeof(msg), "File transfer for '%s' failed.", filename); if (self->active_box != -1) - box_notify2(self, error, NT_NOFOCUS | NT_WNDALERT_2, + box_notify2(self, error, NT_NOFOCUS | NT_WNDALERT_2, self->active_box, "File transfer for '%s' failed!", filename ); else box_notify(self, error, NT_NOFOCUS | NT_WNDALERT_2, &self->active_box, @@ -507,7 +507,7 @@ static void chat_onFileControl(ToxWindow *self, Tox *m, int32_t num, uint8_t rec if (self->active_box != -1) box_notify2(self, transfer_completed, NT_NOFOCUS | NT_WNDALERT_2, self->active_box, "%s", msg); else - box_notify(self, transfer_completed, NT_NOFOCUS | NT_WNDALERT_2, &self->active_box, + box_notify(self, transfer_completed, NT_NOFOCUS | NT_WNDALERT_2, &self->active_box, self->name, "%s", msg); break; @@ -604,14 +604,14 @@ void chat_onInvite (ToxWindow *self, ToxAv *av, int call_index) return; /* call_index is set here and reset on call end */ - + self->call_idx = call_index; line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Incoming audio call! Type: \"/answer\" or \"/reject\""); - + if (self->ringing_sound == -1) sound_notify(self, call_incoming, NT_LOOP, &self->ringing_sound); - - + + if (self->active_box != -1) box_silent_notify2(self, NT_NOFOCUS | NT_WNDALERT_0, self->active_box, "Incoming audio call!"); else @@ -624,7 +624,7 @@ void chat_onRinging (ToxWindow *self, ToxAv *av, int call_index) return; line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Ringing...type \"/hangup\" to cancel it."); - + #ifdef SOUND_NOTIFY if (self->ringing_sound == -1) sound_notify(self, call_outgoing, NT_LOOP, &self->ringing_sound); @@ -639,7 +639,7 @@ void chat_onStarting (ToxWindow *self, ToxAv *av, int call_index) init_infobox(self); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call started! Type: \"/hangup\" to end it."); - + #ifdef SOUND_NOTIFY stop_sound(self->ringing_sound); #endif /* SOUND_NOTIFY */ @@ -653,7 +653,7 @@ void chat_onEnding (ToxWindow *self, ToxAv *av, int call_index) kill_infobox(self); self->call_idx = -1; line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call ended!"); - + #ifdef SOUND_NOTIFY stop_sound(self->ringing_sound); #endif /* SOUND_NOTIFY */ @@ -666,7 +666,7 @@ void chat_onError (ToxWindow *self, ToxAv *av, int call_index) self->call_idx = -1; line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Error!"); - + #ifdef SOUND_NOTIFY stop_sound(self->ringing_sound); #endif /* SOUND_NOTIFY */ @@ -680,7 +680,7 @@ void chat_onStart (ToxWindow *self, ToxAv *av, int call_index) init_infobox(self); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call started! Type: \"/hangup\" to end it."); - + #ifdef SOUND_NOTIFY stop_sound(self->ringing_sound); #endif /* SOUND_NOTIFY */ @@ -694,7 +694,7 @@ void chat_onCancel (ToxWindow *self, ToxAv *av, int call_index) kill_infobox(self); self->call_idx = -1; line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call canceled!"); - + #ifdef SOUND_NOTIFY stop_sound(self->ringing_sound); #endif /* SOUND_NOTIFY */ @@ -707,7 +707,7 @@ void chat_onReject (ToxWindow *self, ToxAv *av, int call_index) self->call_idx = -1; line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Rejected!"); - + #ifdef SOUND_NOTIFY stop_sound(self->ringing_sound); #endif /* SOUND_NOTIFY */ @@ -721,7 +721,7 @@ void chat_onEnd (ToxWindow *self, ToxAv *av, int call_index) kill_infobox(self); self->call_idx = -1; line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call ended!"); - + #ifdef SOUND_NOTIFY stop_sound(self->ringing_sound); #endif /* SOUND_NOTIFY */ @@ -734,7 +734,7 @@ void chat_onRequestTimeout (ToxWindow *self, ToxAv *av, int call_index) self->call_idx = -1; line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "No answer!"); - + #ifdef SOUND_NOTIFY stop_sound(self->ringing_sound); #endif /* SOUND_NOTIFY */ @@ -748,7 +748,7 @@ void chat_onPeerTimeout (ToxWindow *self, ToxAv *av, int call_index) kill_infobox(self); self->call_idx = -1; line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Peer disconnected; call ended!"); - + #ifdef SOUND_NOTIFY stop_sound(self->ringing_sound); #endif /* SOUND_NOTIFY */ @@ -856,6 +856,7 @@ static void send_action(ToxWindow *self, ChatContext *ctx, Tox *m, char *action) static void chat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr) { + ChatContext *ctx = self->chatwin; StatusBar *statusbar = self->stb; @@ -893,6 +894,13 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr) diff = dir_match(self, m, ctx->line, L"/sendfile"); } else if (wcsncmp(ctx->line, L"/avatar \"", wcslen(L"/avatar \"")) == 0) { diff = dir_match(self, m, ctx->line, L"/avatar"); + } else if (wcsncmp(ctx->line, L"/status ", wcslen(L"/status ")) == 0){ + const char status_cmd_list[3][8] = { + {"online"}, + {"away"}, + {"busy"}, + }; + diff = complete_line(self, status_cmd_list, 3, 8); } else { diff = complete_line(self, chat_cmd_list, AC_NUM_CHAT_COMMANDS, MAX_CMDNAME_SIZE); } @@ -1162,14 +1170,14 @@ ToxWindow new_chat(Tox *m, int32_t friendnum) ret.onEnd = &chat_onEnd; ret.onRequestTimeout = &chat_onRequestTimeout; ret.onPeerTimeout = &chat_onPeerTimeout; - + ret.call_idx = -1; ret.device_selection[0] = ret.device_selection[1] = -1; ret.ringing_sound = -1; #endif /* AUDIO */ - + ret.active_box = -1; - + char nick[TOX_MAX_NAME_LENGTH]; int n_len = get_nick_truncate(m, nick, friendnum); set_window_title(&ret, nick, n_len); diff --git a/src/prompt.c b/src/prompt.c index 10af01e..a2b881d 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -81,7 +81,7 @@ static const char glob_cmd_list[AC_NUM_GLOB_COMMANDS][MAX_CMDNAME_SIZE] = { #endif /* AUDIO */ }; -void kill_prompt_window(ToxWindow *self) +void kill_prompt_window(ToxWindow *self) { ChatContext *ctx = self->chatwin; StatusBar *statusbar = self->stb; @@ -116,7 +116,7 @@ void prompt_update_statusmessage(ToxWindow *prompt, Tox *m, const char *statusms snprintf(statusbar->statusmsg, sizeof(statusbar->statusmsg), "%s", statusmsg); int len = strlen(statusbar->statusmsg); statusbar->statusmsg_len = len; - tox_set_status_message(m, (uint8_t *) statusmsg, (uint64_t) len); + tox_set_status_message(m, (uint8_t *) statusmsg, (uint64_t) len); } /* Updates own status in prompt statusbar */ @@ -193,7 +193,14 @@ static void prompt_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr) if (wcsncmp(ctx->line, L"/avatar \"", wcslen(L"/avatar \"")) == 0) diff = dir_match(self, m, ctx->line, L"/avatar"); - else + else if (wcsncmp(ctx->line, L"/status ", wcslen(L"/status ")) == 0){ + const char status_cmd_list[3][8] = { + {"online"}, + {"away"}, + {"busy"}, + }; + diff = complete_line(self, status_cmd_list, 3, 8); + } else diff = complete_line(self, glob_cmd_list, AC_NUM_GLOB_COMMANDS, MAX_CMDNAME_SIZE); if (diff != -1) { @@ -350,7 +357,7 @@ static void prompt_onConnectionChange(ToxWindow *self, Tox *m, int32_t friendnum write_to_log(msg, nick, ctx->log, true); if (self->active_box != -1) - box_notify2(self, user_log_in, NT_WNDALERT_2 | NT_NOTIFWND | NT_RESTOL, self->active_box, + box_notify2(self, user_log_in, NT_WNDALERT_2 | NT_NOTIFWND | NT_RESTOL, self->active_box, "%s has come online", nick ); else box_notify(self, user_log_in, NT_WNDALERT_2 | NT_NOTIFWND | NT_RESTOL, &self->active_box, @@ -361,7 +368,7 @@ static void prompt_onConnectionChange(ToxWindow *self, Tox *m, int32_t friendnum write_to_log(msg, nick, ctx->log, true); if (self->active_box != -1) - box_notify2(self, user_log_out, NT_WNDALERT_2 | NT_NOTIFWND | NT_RESTOL, self->active_box, + box_notify2(self, user_log_out, NT_WNDALERT_2 | NT_NOTIFWND | NT_RESTOL, self->active_box, "%s has gone offline", nick ); else box_notify(self, user_log_out, NT_WNDALERT_2 | NT_NOTIFWND | NT_RESTOL, &self->active_box, @@ -501,6 +508,6 @@ ToxWindow new_prompt(void) ret.help = help; ret.active_box = -1; - + return ret; } diff --git a/src/toxic.c b/src/toxic.c index eec9cc6..16534ba 100644 --- a/src/toxic.c +++ b/src/toxic.c @@ -1006,6 +1006,7 @@ void DnD_callback(const char* asdv, DropType dt) int main(int argc, char *argv[]) { + parse_args(argc, argv); if (arg_opts.encrypt_data && arg_opts.unencrypt_data) { From ec23cedc3ae59179ffc4be9cc3325f070cd40b51 Mon Sep 17 00:00:00 2001 From: Andrey Alekseenko Date: Wed, 18 Mar 2015 19:28:04 +0300 Subject: [PATCH 5/8] Fixing couple leaking file descriptors --- src/autocomplete.c | 2 ++ src/chat.c | 1 + 2 files changed, 3 insertions(+) diff --git a/src/autocomplete.c b/src/autocomplete.c index 5b6af44..109d925 100644 --- a/src/autocomplete.c +++ b/src/autocomplete.c @@ -284,6 +284,8 @@ int dir_match(ToxWindow *self, Tox *m, const wchar_t *line, const wchar_t *cmd) } } + closedir(dp); + if (dircount == 0) return -1; diff --git a/src/chat.c b/src/chat.c index e44546d..ea2a8da 100644 --- a/src/chat.c +++ b/src/chat.c @@ -325,6 +325,7 @@ static void chat_onFileSendRequest(ToxWindow *self, Tox *m, int32_t num, uint8_t int count = 1; while ((filecheck = fopen(filename, "r"))) { + fclose(filecheck); filename[len] = '\0'; char d[9]; sprintf(d, "(%d)", count++); From a11289de795de5c4bc119bfd648c8bd96e2acaa6 Mon Sep 17 00:00:00 2001 From: Ansa89 Date: Sat, 21 Mar 2015 18:33:51 +0100 Subject: [PATCH 6/8] Move makefile into root directory Requested by @mannol. --- INSTALL.md | 1 - build/Makefile => Makefile | 28 +++++++++++++++++----------- cfg/global_vars.mk | 1 + cfg/targets/install.mk | 4 ++-- 4 files changed, 20 insertions(+), 14 deletions(-) rename build/Makefile => Makefile (73%) diff --git a/INSTALL.md b/INSTALL.md index 88b87a9..4e96a30 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -36,7 +36,6 @@ You can omit `libnotify` if you intend to build without desktop notifications en ## Compiling ``` -cd build/ make PREFIX="/where/to/install" sudo make install PREFIX="/where/to/install" ``` diff --git a/build/Makefile b/Makefile similarity index 73% rename from build/Makefile rename to Makefile index 9d4b45d..3038ada 100644 --- a/build/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -BASE_DIR = $(shell cd .. && pwd -P) +BASE_DIR = $(shell pwd -P) CFG_DIR = $(BASE_DIR)/cfg -include $(CFG_DIR)/global_vars.mk @@ -49,22 +49,28 @@ endif # Include all needed checks -include $(CFG_DIR)/checks/check_features.mk +# Fix path for object files +OBJ := $(addprefix $(BUILD_DIR)/, $(OBJ)) + # Targets -all: toxic +all: $(BUILD_DIR)/toxic -toxic: $(OBJ) - @echo " LD $@" - @$(CC) $(CFLAGS) -o toxic $(OBJ) $(LDFLAGS) +$(BUILD_DIR)/toxic: $(OBJ) + @echo " LD $(@:$(BUILD_DIR)/%=%)" + @$(CC) $(CFLAGS) -o $(BUILD_DIR)/toxic $(OBJ) $(LDFLAGS) -%.o: $(SRC_DIR)/%.c - @echo " CC $@" - @$(CC) $(CFLAGS) -o $*.o -c $(SRC_DIR)/$*.c - @$(CC) -MM $(CFLAGS) $(SRC_DIR)/$*.c > $*.d +$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c + @if [ ! -e $(BUILD_DIR) ]; then \ + mkdir -p $(BUILD_DIR) ;\ + fi + @echo " CC $(@:$(BUILD_DIR)/%=%)" + @$(CC) $(CFLAGS) -o $(BUILD_DIR)/$*.o -c $(SRC_DIR)/$*.c + @$(CC) -MM $(CFLAGS) $(SRC_DIR)/$*.c > $(BUILD_DIR)/$*.d clean: - rm -f *.d *.o toxic + rm -rf $(BUILD_DIR) --include $(OBJ:.o=.d) +-include $(BUILD_DIR)/$(OBJ:.o=.d) -include $(CFG_DIR)/targets/*.mk diff --git a/cfg/global_vars.mk b/cfg/global_vars.mk index 832ad49..52942fa 100644 --- a/cfg/global_vars.mk +++ b/cfg/global_vars.mk @@ -8,6 +8,7 @@ else endif # Project directories +BUILD_DIR = $(BASE_DIR)/build DOC_DIR = $(BASE_DIR)/doc SRC_DIR = $(BASE_DIR)/src SND_DIR = $(BASE_DIR)/sounds diff --git a/cfg/targets/install.mk b/cfg/targets/install.mk index 49155b2..cdc0067 100644 --- a/cfg/targets/install.mk +++ b/cfg/targets/install.mk @@ -1,8 +1,8 @@ # Install target -install: toxic +install: $(BUILD_DIR)/toxic @echo "Installing toxic executable" @mkdir -p $(abspath $(DESTDIR)/$(BINDIR)) - @install -m 0755 toxic $(abspath $(DESTDIR)/$(BINDIR)/toxic) + @install -m 0755 $(BUILD_DIR)/toxic $(abspath $(DESTDIR)/$(BINDIR)/toxic) @echo "Installing desktop file" @mkdir -p $(abspath $(DESTDIR)/$(APPDIR)) From 59b16f77603855f6e0fddde7b2e25ceba6a18f68 Mon Sep 17 00:00:00 2001 From: Ansa89 Date: Sat, 21 Mar 2015 18:38:28 +0100 Subject: [PATCH 7/8] Fix travis build --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8b48566..07ec154 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,7 +41,6 @@ before_script: - sudo make install - cd .. script: - - cd build - make -j2 || make || exit 1 notifications: email: false From dfbb1338a50aba1cf38e18174dead3838b753a69 Mon Sep 17 00:00:00 2001 From: Ansa89 Date: Sat, 21 Mar 2015 19:31:00 +0100 Subject: [PATCH 8/8] Makefile: be less aggressive when cleaning --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3038ada..07fa384 100644 --- a/Makefile +++ b/Makefile @@ -68,7 +68,7 @@ $(BUILD_DIR)/%.o: $(SRC_DIR)/%.c @$(CC) -MM $(CFLAGS) $(SRC_DIR)/$*.c > $(BUILD_DIR)/$*.d clean: - rm -rf $(BUILD_DIR) + rm -f $(BUILD_DIR)/*.d $(BUILD_DIR)/*.o $(BUILD_DIR)/toxic -include $(BUILD_DIR)/$(OBJ:.o=.d)