about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am36
-rw-r--r--configure.ac39
-rwxr-xr-xinstall-all.sh22
-rw-r--r--src/ui/notifier.c26
4 files changed, 91 insertions, 32 deletions
diff --git a/Makefile.am b/Makefile.am
index b5eea266..31280b0c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -25,11 +25,11 @@ core_sources = \
 	src/xmpp/capabilities.h src/xmpp/connection.h \
 	src/xmpp/roster.c src/xmpp/roster.h \
 	src/xmpp/bookmark.c src/xmpp/bookmark.h \
-    src/server_events.c src/server_events.h \
+	src/server_events.c src/server_events.h \
 	src/ui/ui.h src/ui/window.c src/ui/window.h src/ui/core.c \
 	src/ui/titlebar.c src/ui/statusbar.c src/ui/inputwin.c \
 	src/ui/console.c src/ui/notifier.c \
-    src/ui/windows.c src/ui/windows.h \
+	src/ui/windows.c src/ui/windows.h \
 	src/command/command.h src/command/command.c src/command/history.c \
 	src/command/commands.h src/command/commands.c \
 	src/command/history.h src/tools/parser.c \
@@ -62,18 +62,18 @@ test_sources = \
 	src/config/account.c src/config/account.h \
 	src/config/preferences.c src/config/preferences.h \
 	src/config/theme.c src/config/theme.h \
-    src/ui/windows.c src/ui/windows.h \
-    src/ui/window.c src/ui/window.h \
-    src/server_events.c src/server_events.h \
-    tests/xmpp/mock_xmpp.h tests/xmpp/mock_xmpp.c \
-    tests/otr/mock_otr.h tests/otr/mock_otr.c \
-    tests/ui/mock_ui.h tests/ui/mock_ui.c \
-    tests/config/mock_accounts.h tests/config/mock_accounts.c \
-    tests/helpers.c tests/helpers.h \
-    tests/log/mock_log.c \
-    tests/test_autocomplete.c \
-    tests/test_common.c \
-    tests/test_contact.c \
+	src/ui/windows.c src/ui/windows.h \
+	src/ui/window.c src/ui/window.h \
+	src/server_events.c src/server_events.h \
+	tests/xmpp/mock_xmpp.h tests/xmpp/mock_xmpp.c \
+	tests/otr/mock_otr.h tests/otr/mock_otr.c \
+	tests/ui/mock_ui.h tests/ui/mock_ui.c \
+	tests/config/mock_accounts.h tests/config/mock_accounts.c \
+	tests/helpers.c tests/helpers.h \
+	tests/log/mock_log.c \
+	tests/test_autocomplete.c \
+	tests/test_common.c \
+	tests/test_contact.c \
 	tests/test_cmd_connect.c \
 	tests/test_cmd_account.c \
 	tests/test_cmd_rooms.c \
@@ -89,18 +89,18 @@ test_sources = \
 	tests/test_preferences.c \
 	tests/test_server_events.c \
 	tests/test_muc.c \
-    tests/testsuite.c
+	tests/testsuite.c
 
 main_source = src/main.c
 
 git_sources = \
-    src/gitversion.c
+	src/gitversion.c
 
 otr3_sources = \
-    src/otr/otrlib.h src/otr/otrlibv3.c src/otr/otr.h src/otr/otr.c
+	src/otr/otrlib.h src/otr/otrlibv3.c src/otr/otr.h src/otr/otr.c
 
 otr4_sources = \
-    src/otr/otrlib.h src/otr/otrlibv4.c src/otr/otr.h src/otr/otr.c
+	src/otr/otrlib.h src/otr/otrlibv4.c src/otr/otr.h src/otr/otr.c
 
 if INCLUDE_GIT_VERSION
 with_git_sources = $(git_sources) $(core_sources)
diff --git a/configure.ac b/configure.ac
index efe4fcc3..fb6698ec 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,13 @@ AC_PROG_CC
 
 ### Get canonical host
 AC_CANONICAL_HOST
-AS_IF([test "x$host_os" = xcygwin],
+PLATFORM="unknown"
+AS_CASE([$host_os],
+    [darwin*], [PLATFORM="osx"],
+    [cygwin], [PLATFORM="cygwin"],
+    [PLATFORM="nix"])
+
+AS_IF([test "x$PLATFORM" = xcygwin],
     [AC_DEFINE([PLATFORM_CYGWIN], [1], [Cygwin])])
 
 ### Options
@@ -111,12 +117,28 @@ PKG_CHECK_MODULES([glib], [glib-2.0 >= 2.26], [],
     [AC_MSG_ERROR([glib 2.26 or higher is required for profanity])])
 PKG_CHECK_MODULES([curl], [libcurl], [],
     [AC_MSG_ERROR([libcurl is required for profanity])])
-AS_IF([test "x$enable_notifications" != xno],
-    [PKG_CHECK_MODULES([libnotify], [libnotify],
-        [AC_DEFINE([HAVE_LIBNOTIFY], [1], [libnotify module])],
-        [AS_IF([test "x$enable_notifications" = xyes],
-            [AC_MSG_ERROR([libnotify is required but does not exist])],
-            [AC_MSG_NOTICE([libnotify support will be disabled])])])])
+
+### Check for desktop notification support
+### Linux requires libnotify
+### Windows uses native OS calls
+### OSX requires terminal-notifier
+
+AS_IF([test "x$PLATFORM" = xosx],
+        [AS_IF([test "x$enable_notifications" != xno],
+            [NOTIFIER_PATH="no"
+            AC_PATH_PROG(NOTIFIER_PATH, terminal-notifier, no)
+            AS_IF([test "x$NOTIFIER_PATH" = xno],
+                [AS_IF([test "x$enable_notifications" = xyes],
+                    [AC_MSG_ERROR([terminal-notifier not found, required for desktop notifications.])],
+                    [AC_MSG_NOTICE([Desktop notifications not supported.])])],
+                [AC_DEFINE([HAVE_OSXNOTIFY], [1], [terminal notifier])])])],
+    [test "x$PLATFORM" = xnix],
+        [AS_IF([test "x$enable_notifications" != xno],
+            [PKG_CHECK_MODULES([libnotify], [libnotify],
+                [AC_DEFINE([HAVE_LIBNOTIFY], [1], [libnotify module])],
+                [AS_IF([test "x$enable_notifications" = xyes],
+                    [AC_MSG_ERROR([libnotify is required but does not exist])],
+                    [AC_MSG_NOTICE([libnotify support will be disabled])])])])])
 
 # TODO: rewrite this
 if test "x$with_xscreensaver" = xyes; then
@@ -163,7 +185,7 @@ elif test "x$enable_otr" = x; then
             ]])],
             [AM_CONDITIONAL([BUILD_OTR], [true]) AM_CONDITIONAL([BUILD_OTR4], [true]) AC_DEFINE([HAVE_LIBOTR], [1], [Have libotr])],
             [AM_CONDITIONAL([BUILD_OTR], [true]) AM_CONDITIONAL([BUILD_OTR3], [true]) AC_DEFINE([HAVE_LIBOTR], [1], [Have libotr])])],
-        [AC_MSG_NOTICE([libotr not found, otr entryption support not enabled])])
+        [AC_MSG_NOTICE([libotr not found, otr encryption support not enabled])])
 fi
 
 ### cmocka is required only for tests, profanity shouldn't be linked with it
@@ -193,6 +215,7 @@ AC_CONFIG_FILES([Makefile])
 AC_OUTPUT
 
 echo ""
+echo "PLATFORM       : $host_os"
 echo "PACKAGE_STATUS : $PACKAGE_STATUS"
 echo "AM_CFLAGS      : $AM_CFLAGS"
 echo "AM_CPPFLAGS    : $AM_CPPFLAGS"
diff --git a/install-all.sh b/install-all.sh
index 656d9d90..32f6a128 100755
--- a/install-all.sh
+++ b/install-all.sh
@@ -1,7 +1,19 @@
-#!/bin/sh
+#!/bin/bash
+
+set -o errtrace
 
 STATUS=development
 
+error_handler()
+{
+        ERR_CODE=$?
+        echo "Error $ERR_CODE with command '$BASH_COMMAND' on line ${BASH_LINENO[0]}. Exiting."
+        exit $ERR_CODE
+
+}
+
+trap error_handler ERR
+
 debian_prepare()
 {
     echo
@@ -23,7 +35,7 @@ fedora_prepare()
     echo
 
     ARCH=`arch`
-    
+
     sudo yum -y install gcc git autoconf automake openssl-devel.$ARCH expat-devel.$ARCH ncurses-devel.$ARCH  glib2-devel.$ARCH libnotify-devel.$ARCH libcurl-devel.$ARCH libXScrnSaver-devel.$ARCH libotr3-devel.$ARCH
 }
 
@@ -39,14 +51,12 @@ cygwin_prepare()
     mv apt-cyg /usr/local/bin/
 
     if [ -n "$CYG_MIRROR" ]; then
-        apt-cyg -m $CYG_MIRROR install git make gcc-core m4 automake autoconf pkg-config openssl-devel libexpat-devel zlib-devel libncursesw-devel libglib2.0-devel libcurl-devel libidn-devel libssh2-devel libkrb5-devel openldap-devel
+        apt-cyg -m $CYG_MIRROR install git make gcc-core m4 automake autoconf pkg-config openssl-devel libexpat-devel zlib-devel libncursesw-devel libglib2.0-devel libcurl-devel libidn-devel libssh2-devel libkrb5-devel openldap-devel libgcrypt-devel
     else
-        apt-cyg install git make gcc-core m4 automake autoconf pkg-config openssl-devel libexpat-devel zlib-devel libncursesw-devel libglib2.0-devel libcurl-devel libidn-devel libssh2-devel libkrb5-devel openldap-devel
+        apt-cyg install git make gcc-core m4 automake autoconf pkg-config openssl-devel libexpat-devel zlib-devel libncursesw-devel libglib2.0-devel libcurl-devel libidn-devel libssh2-devel libkrb5-devel openldap-devel libgcrypt-devel
 
     fi
 
-    ln -s /usr/bin/gcc-3.exe /usr/bin/gcc.exe
-
     export LIBRARY_PATH=/usr/local/lib/
 }
 
diff --git a/src/ui/notifier.c b/src/ui/notifier.c
index ebc61e0d..16fd814f 100644
--- a/src/ui/notifier.c
+++ b/src/ui/notifier.c
@@ -23,6 +23,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 
 #include <glib.h>
 #ifdef HAVE_LIBNOTIFY
@@ -205,6 +206,31 @@ _notify(const char * const message, int timeout,
 
     Shell_NotifyIcon(NIM_MODIFY, &nid);
 #endif
+#ifdef HAVE_OSXNOTIFY
+    GString *notify_command = g_string_new("terminal-notifier -title 'Profanity' -message '");
+    g_string_append(notify_command, message);
+    g_string_append(notify_command, "'");
+
+    char *term_name = getenv("TERM_PROGRAM");
+    char *app_id = NULL;
+    if (g_strcmp0(term_name, "Apple_Terminal") == 0) {
+        app_id = "com.apple.Terminal";
+    } else if (g_strcmp0(term_name, "iTerm.app") == 0) {
+        app_id = "com.googlecode.iterm2";
+    }
+
+    if (app_id != NULL) {
+        g_string_append(notify_command, " -sender ");
+        g_string_append(notify_command, app_id);
+    }
+
+    int res = system(notify_command->str);
+    if (res == -1) {
+        log_error("Could not send desktop notificaion.");
+    }
+
+    g_string_free(notify_command, TRUE);
+#endif
 }
 
 void