Author: ek.kato
Date: Tue Mar 17 04:26:43 2009
New Revision: 5896

Added:
   trunk/notify/uim-growl.m
Modified:
   trunk/configure.ac
   trunk/notify/Makefile.am

Log:
* configure.ac : Growl support for Mac OS X.
* notify/Makefile.am : Ditto.
* notify/uim-growl.m : Ditto. New file.


Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac  (original)
+++ trunk/configure.ac  Tue Mar 17 04:26:43 2009
@@ -13,6 +13,7 @@
 AC_PROG_CXX
 AC_PROG_CC
 AC_PROG_CPP
+AC_PROG_OBJC
 AC_PROG_LN_S
 AC_PROG_INSTALL
 AC_PROG_MAKE_SET
@@ -1364,13 +1365,13 @@
 # ****************************
 # *** Tests for uim-notify ***
 # ****************************
-notify_targets='stderr libnotify knotify3'
+notify_targets='stderr libnotify knotify3 growl'

 AC_ARG_ENABLE(notify,
AS_HELP_STRING([--enable-notify@<:@=agent-list@:>@ (HIGHLY EXPERIMENTAL)],
                  [enable system message notification for users
                  (specify comma separated notification agent list
-                 from stderr, libnotify and knotify3)]),
+                 from stderr, libnotify, knotify3 and growl)]),
   [ enable_notify=$enableval
     have_notify_opt=yes ],
   [ enable_notify=yes
@@ -1438,6 +1439,15 @@
   use_notify="${use_notify}knotify3 "
 fi

+AC_MSG_CHECKING([whether growl is requested])
+if test "x$au_enable_growl" = xyes; then
+  AC_MSG_RESULT([yes])
+  use_growl="yes"
+  use_notify="${use_notify}growl "
+else
+  AC_MSG_RESULT(no)
+fi
+
 if test "x$use_notify" = "x"; then
   use_notify=none
 fi
@@ -1445,6 +1455,7 @@
 AM_CONDITIONAL(NOTIFY, test "x$enable_notify" != xno)
 AM_CONDITIONAL(LIBNOTIFY, test x$use_libnotify = xyes)
 AM_CONDITIONAL(KNOTIFY3, test x$use_knotify3 = xyes)
+AM_CONDITIONAL(GROWL, test x$use_growl = xyes)


AC_DEFINE(UIM_USE_ERROR_GUARD, 1, [Define to 1 if you want to use longjmp-based error handlings])

Modified: trunk/notify/Makefile.am
==============================================================================
--- trunk/notify/Makefile.am    (original)
+++ trunk/notify/Makefile.am    Tue Mar 17 04:26:43 2009
@@ -20,3 +20,12 @@
libuimnotify_knotify3_la_LDFLAGS = -avoid-version -module -...@knotify3_lib_dir@ $(QT_LDFLAGS) libuimnotify_knotify3_la_LIBADD = -lkdeui -lkdecore $(top_builddir)/replace/libreplace.la
 endif
+
+if GROWL
+uimnotify_plugin_LTLIBRARIES += libuimnotify-growl.la
+libuimnotify_growl_la_SOURCES = uim-growl.m
+# FIXME: configuration for Growl framework path
+libuimnotify_growl_la_OBJCFLAGS = -x objective-c -F../../../Sources/Growl
+libuimnotify_growl_la_LDFLAGS = -avoid-version -module -framework Cocoa -F../../../Sources/Growl -framework Growl
+libuimnotify_growl_la_LIBADD = $(top_builddir)/replace/libreplace.la
+endif

Added: trunk/notify/uim-growl.m
==============================================================================
--- (empty file)
+++ trunk/notify/uim-growl.m    Tue Mar 17 04:26:43 2009
@@ -0,0 +1,112 @@
+/*
+  Copyright (c) 2009 uim Project http://code.google.com/p/uim/
+
+  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+
+  1. Redistributions of source code must retain the above copyright
+     notice, this list of conditions and the following disclaimer.
+  2. Redistributions in binary form must reproduce the above copyright
+     notice, this list of conditions and the following disclaimer in the
+     documentation and/or other materials provided with the distribution.
+  3. Neither the name of authors nor the names of its contributors
+     may be used to endorse or promote products derived from this software
+     without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
+  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+  SUCH DAMAGE.
+
+*/
+
+#include <config.h>
+
+#import <Cocoa/Cocoa.h>
+#import <Growl/GrowlApplicationBridge.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+
+#include "uim.h"  /* for uim_bool */
+#include "uim-notify.h"
+
+
+static uim_bool
+uim_growl_notify(int prio, BOOL is_sticky, const char *body)
+{
+  char body_short[256];
+
+  BOOL ret;
+  char *msg;
+  NSString *string;
+  const char *str[3] = {"uim notify info", "dummy", "uim notify fatal"};
+
+  if (prio > 2 || prio < 0)
+    return UIM_FALSE;
+
+  strlcpy(body_short, body, sizeof(body_short));
+
+  fprintf(stderr, "libuim: %s\n", body);
+
+  [GrowlApplicationBridge
+         notifyWithTitle:@"uim Notification"
+             description:[NSString stringWithUTF8String:body_short]
+        notificationName:[NSString stringWithCString:str[prio]]
+                iconData:nil
+                priority:prio
+                isSticky:is_sticky
+            clickContext:nil];
+
+  return UIM_TRUE;
+}
+
+/*
+  interface
+ */
+static uim_notify_desc uim_notify_growl_desc = {
+  "growl",
+  "Output via growl",
+};
+
+const uim_notify_desc *
+uim_notify_plugin_get_desc(void)
+{
+  return &uim_notify_growl_desc;
+}
+
+uim_bool
+uim_notify_plugin_init(void)
+{
+  return UIM_TRUE;
+}
+
+void
+uim_notify_plugin_quit(void)
+{
+  return;
+}
+
+uim_bool
+uim_notify_plugin_info(const char *msg)
+{
+  return uim_growl_notify(0, NO, msg);
+}
+
+uim_bool
+uim_notify_plugin_fatal(const char *msg)
+{
+  return uim_growl_notify(2, YES, msg);
+}

Reply via email to