mackx avatar mackx committed 4e99df0

Show rxvt in the TaskBar

Comments (0)

Files changed (8)

+syntax: glob
+
+*.a
+*.la
+*.lai
+*.o
+*.lo
+Makefile
+rxvtlib.h
+config.h
+config.log
+config.status
+libtool
+src/rxvt
+rclock/rclock
+rclock/rclock.1
+autoconf/Make.common
+
 # DESTDIR = /usr/local/X11/$(VERNAME)
 
 # Installation target directories & other installation stuff
-prefix = /usr/local
+prefix = /media/mmcblk0p1/Programs/_rxvt
 exec_prefix = ${prefix}
 bindir = ${exec_prefix}/bin
 libdir = ${exec_prefix}/lib
 manext = 1
 
 # Tools & program stuff
-CC = gcc
-CPP = gcc -E
+CC = arm-poky-linux-gnueabi-gcc
+CPP = arm-poky-linux-gnueabi-gcc -E
 MV = /bin/mv
 RM = /bin/rm
 RMF = /bin/rm -f
 CP = /bin/cp
 LN = /bin/ln
-SED = /usr/bin/sed
-AWK = awk
+SED = /bin/sed
+AWK = mawk
 ECHO = /bin/echo
 CMP = /usr/bin/cmp
 TBL = /usr/bin/tbl
 DLIB = 
 
 # X Include directory
-XINC =  -I/usr/X11R6/include 
+XINC =  
 
 # extra libraries needed by X on some systems, X library location
-XLIB = -L/usr/X11R6/lib -Wl,-rpath -Wl,/usr/X11R6/lib  -lX11 
+XLIB =   -lX11 
 
 LIBTOOL = $(SHELL) $(top_builddir)/libtool
 COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(DEBUG) $(DINCLUDE) $(XINC) -I$(basedir) -I$(srcdir) -I.
 #-------------------------------------------------------------------------
 
 all allbin alldoc tags:
-	@if test xnetbsdelf1.6Q = xcygwin; then (cd W11; ${MAKE} $@ || exit 1); fi
+	@if test xlinux-gnueabi = xcygwin; then (cd W11; ${MAKE} $@ || exit 1); fi
 	@for I in ${subdirs}; do (cd $$I; ${MAKE} $@ || exit 1); done
 
 realclean: clean
 clean:
 	$(RMF) *~ config.cache
 	$(RMF) -r autom4te.cache
-	@if test xnetbsdelf1.6Q = xcygwin; then (cd W11; ${MAKE} $@ || exit 1); fi
+	@if test xlinux-gnueabi = xcygwin; then (cd W11; ${MAKE} $@ || exit 1); fi
 	@for I in ${subdirs}; do (cd $$I; ${MAKE} $@ || exit 1); done
 
 #
 	$(MKDIR) $(DESTDIR)$(mandir)
 
 install: installdirs
-	@if test xnetbsdelf1.6Q = xcygwin; then (cd W11; ${MAKE} $@ || exit 1); fi
+	@if test xlinux-gnueabi = xcygwin; then (cd W11; ${MAKE} $@ || exit 1); fi
 	@for I in $(subdirs); do (cd $$I; $(MAKE) DESTDIR=$(DESTDIR) $@ || exit 1); done
 
 Makefiles:
+Use ./configure.sh to configure for the DR
+
+Use to build: 
+make install DESTDIR=~/Development/Bitbucket/
+To strip the image:
+arm-poky-linux-gnueabi-strip ~/Development/Bitbucket/media/mmcblk0p1/Programs/_rxvt/bin/rxvt
+
+
+Replace ~/Development/Bitbucket with a directory of your choice. The
+files that are required for the DR will be copied in this diretory.
+
+./configure --host=arm-poky-linux-gnueabi --prefix=/media/mmcblk0p1/Programs/_rxvt
 
 COMPILE += `pkg-config --cflags liberkeyb-client`
 LINK += -lerkeyb-client
+COMPILE += `pkg-config --cflags liberipc`
+LINK += -leripc
+
 # for developers: the following debug options may be used
 #	-DDEBUG_CMD -DDEBUG_MAIN -DDEBUG_MENU -DDEBUG_MENUARROWS
 #	-DDEBUG_MENUBAR_STACKING -DDEBUG_MENU_LAYOUT -DDEBUG_RESOURCES
 	scrollbar-rxvt.c scrollbar-next.c scrollbar-xterm.c strings.c \
 	xdefaults.c xpm.c
 
-SRCS =  rxvt.c $(LIBSRCS)
+SRCS =  rxvt.c dr-ipc.c $(LIBSRCS)
 
 HDRS =	command.h defaultfont.h feature.h grkelot.h init.h logging.h \
 	menubar.h netdisp.h protos.h rxvt.h rxvtgrx.h version.h
 
 EXTRAHDRS = rxvtlib.h
 
-OBJS =	@OBJLIST@ rxvt.o
+OBJS =	@OBJLIST@ rxvt.o dr-ipc.o
 LIBOBJS = @LIBOBJLIST@
 LIBVERSION = @LIBVERSION@
 INSTALL_LIBRXVT = @INSTALL_LIBRXVT@
 	scrollbar-rxvt.intpro scrollbar-next.intpro scrollbar-xterm.intpro \
 	strings.intpro xdefaults.intpro xpm.intpro
 
-DEPS =  rxvt.h rxvtlib.h ${basedir}/config.h feature.h .protos
+DEPS =  rxvt.h rxvtlib.h dr-ipc.h ${basedir}/config.h feature.h .protos
 
 #
 # Distribution variables
 #-------------------------------------------------------------------------
 all: allbin
 
-rxvt: version.h rxvt.o librxvt.la
-	$(LIBTOOL) --mode=link $(LINK) rxvt.o librxvt.la $(LIBS) $(XLIB) $(DLIB) -o $@
+rxvt: version.h rxvt.o dr-ipc.o librxvt.la
+	$(LIBTOOL) --mode=link $(LINK) rxvt.o dr-ipc.o librxvt.la $(LIBS) $(XLIB) $(DLIB) -o $@
 
 .protos: $(EXTPROS)
 	@$(RMF) .protos
 strings.o:          strings.c   $(DEPS) strings.intpro
 xdefaults.o:        xdefaults.c $(DEPS) xdefaults.intpro	  version.h
 xpm.o:              xpm.c       $(DEPS) xpm.intpro
+dr-ipc.o:           dr-ipc.c    $(DEPS)
 
 command.lo:         command.c   $(DEPS) command.intpro	command.h version.h
 defaultfont.lo:     defaultfont.c $(DEPS) defaultfont.intpro defaultfont.h
 strings.lo:         strings.c   $(DEPS) strings.intpro
 xdefaults.lo:       xdefaults.c $(DEPS) xdefaults.intpro	  version.h
 xpm.lo:             xpm.c       $(DEPS) xpm.intpro
+dr-ipc.lo:          dr-ipc.c    $(DEPS)
+/*
+ * File Name: ipc.c
+ */
+
+/*
+ * This file is part of hello-world.
+ *
+ * hello-world 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.
+ *
+ * hello-world 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/>.
+ */
+
+/**
+ * Copyright (C) 2009 iRex Technologies B.V.
+ * All rights reserved.
+ */
+
+//----------------------------------------------------------------------------
+// Include Files
+//----------------------------------------------------------------------------
+
+// system include files, between < >
+#include <stdio.h>
+#include <stdlib.h>
+#include <gdk/gdkx.h>
+#include <gtk/gtk.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+// ereader include files, between < >
+#include <liberipc/eripc.h>
+#include <liberipc/eripc_support.h>
+
+// local include files, between " "
+#include "dr-ipc.h"
+//#include "dr-menu.h"
+
+
+//----------------------------------------------------------------------------
+// Type Declarations
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
+// Constants
+//----------------------------------------------------------------------------
+
+// IPC application
+// TODO: set DBUS_APPL_NAME to your application name, use lower-case and digits only
+//       or set to PACKAGENAME when this is lower-case and digits only
+#define DBUS_APPL_NAME                   "rxvt"            // lower-case and digits only
+#define DBUS_SERVICE                     "com.irexnet." DBUS_APPL_NAME
+#define DBUS_PATH                        "/com/irexnet/" DBUS_APPL_NAME
+#define DBUS_INTERFACE                   "com.irexnet." DBUS_APPL_NAME
+
+// IPC system control
+#define DBUS_SERVICE_SYSTEM_CONTROL     "com.irexnet.sysd"
+
+// IPC popup menu
+#define DBUS_SERVICE_POPUP_MENU         "com.irexnet.popupmenu"
+
+
+//----------------------------------------------------------------------------
+// Static Variables
+//----------------------------------------------------------------------------
+
+static eripc_client_context_t *eripcClient = NULL;
+
+#define LOGPRINTF printf
+#define WARNPRINTF printf
+#define ERRORPRINTF printf
+
+
+//============================================================================
+// Local Function Definitions
+//============================================================================
+
+static void on_menu_item         ( eripc_context_t          *context,
+                                   const eripc_event_info_t *info,
+                                   void                     *user_data );
+
+static void on_mounted           ( eripc_context_t          *context,
+                                   const eripc_event_info_t *info,
+                                   void                     *user_data );
+
+static void on_file_open         ( eripc_context_t          *context,
+                                   const eripc_event_info_t *info,
+                                   void                     *user_data );
+
+static void on_file_close        ( eripc_context_t          *context,
+                                   const eripc_event_info_t *info,
+                                   void                     *user_data );
+
+static void on_window_activated  ( eripc_context_t          *context,
+                                   const eripc_event_info_t *info,
+                                   void                     *user_data );
+
+static void on_window_deactivated( eripc_context_t          *context,
+                                   const eripc_event_info_t *info,
+                                   void                     *user_data );
+
+static void on_prepare_unmount   ( eripc_context_t          *context,
+                                   const eripc_event_info_t *info,
+                                   void                     *user_data );
+
+static void on_unmounted         ( eripc_context_t          *context,
+                                   const eripc_event_info_t *info,
+                                   void                     *user_data );
+
+static void on_prepare_standby   ( eripc_context_t          *context,
+                                   const eripc_event_info_t *info,
+                                   void                     *user_data );
+
+static void on_changed_locale    ( eripc_context_t          *context,
+                                   const eripc_event_info_t *info,
+                                   void                     *user_data );
+
+static void on_changed_orientation(eripc_context_t          *context,
+                                   const eripc_event_info_t *info,
+                                   void                     *user_data );
+
+static void on_page_change               (eripc_context_t *context,
+                                          const eripc_event_info_t *info,
+                                          void *user_data);
+
+static void on_sys_changed_pageturn_inverted (eripc_context_t *context,
+                                          const eripc_event_info_t *info,
+                                          void *user_data);
+
+
+// Exported DBUS API list
+static eripc_callback_function_t service_functions[] = {
+    // message handlers (method calls to this service)
+    { on_menu_item,           "menuItemActivated",      NULL                       , 0 },
+    { on_mounted,             "sysVolumeMounted",       NULL                       , 0 },
+    { on_file_open,           "openFile",               NULL                       , 0 },
+    { on_file_close,          "closeFile",              NULL                       , 0 },
+    { on_window_activated,    "activatedWindow",        NULL                       , 0 },
+    { on_window_deactivated,  "deactivatedWindow",      NULL                       , 0 },
+    // signal handlers (broadcasted from given service)
+    { on_mounted,             "sysVolumeMounted",       DBUS_SERVICE_SYSTEM_CONTROL, 0 },
+    { on_prepare_unmount,     "sysPrepareUnmount",      DBUS_SERVICE_SYSTEM_CONTROL, 0 },
+    { on_unmounted,           "sysVolumeUnmounted",     DBUS_SERVICE_SYSTEM_CONTROL, 0 },
+    { on_prepare_standby,     "sysPrepareStandby",      DBUS_SERVICE_SYSTEM_CONTROL, 0 },
+    { on_changed_locale,      "sysChangedLocale",       DBUS_SERVICE_SYSTEM_CONTROL, 0 },
+    { on_changed_orientation, "sysChangedOrientation",  DBUS_SERVICE_SYSTEM_CONTROL, 0 },
+    { on_page_change,         "pageChange",             NULL                       , 0 },
+    { on_sys_changed_pageturn_inverted, "sysChangedPageturnInverted", DBUS_SERVICE_SYSTEM_CONTROL , 0},
+    { NULL, NULL, NULL, 0 }
+};
+
+
+//============================================================================
+// Functions Implementation
+//============================================================================
+
+
+//----------------------------------------------------------------------------
+// Generic
+//----------------------------------------------------------------------------
+
+// initialise
+void ipc_set_services (void)
+{
+    eripcClient = eripc_client_context_new(
+                    DBUS_APPL_NAME,
+                    "1.0",
+                    DBUS_SERVICE,
+                    DBUS_PATH,
+                    DBUS_INTERFACE,
+                    service_functions);
+}
+
+
+// un-initialise
+void ipc_unset_services (void)
+{
+    eripc_client_context_free(eripcClient, service_functions);
+}
+
+
+//----------------------------------------------------------------------------
+// System control
+//----------------------------------------------------------------------------
+
+// report "application started"
+/* void ipc_sys_startup_complete ( void ) */
+void ipc_sys_startup_complete ( int xid )
+{
+    //const int xid = GDK_WINDOW_XID(GTK_WIDGET(data)->window);
+    eripc_sysd_startup_complete( eripcClient, getpid(), FALSE, xid );
+}
+
+
+// start task (application)
+gint ipc_sys_start_task ( const gchar  *cmd_line,
+                          const gchar  *work_dir,
+                          const gchar  *label,
+                          const gchar  *thumbnail_path,
+                          gchar        **err_message )
+{
+    // LOGPRINTF("entry: cmd_line [%s] work_dir [%s] label [%s] thumbnail_path [%s]",
+    //                    cmd_line,     work_dir,     label,     thumbnail_path       );
+    g_assert( cmd_line && *cmd_line );
+    return eripc_sysd_start_task( eripcClient,
+                                  cmd_line,
+                                  work_dir,
+                                  label,
+                                  thumbnail_path,
+                                  err_message);
+}
+
+
+// stop task (application)
+gboolean ipc_sys_stop_task ( const gchar  *cmd_line )
+{
+    // LOGPRINTF("entry: cmd_line [%s]", cmd_line );
+    g_assert( cmd_line && *cmd_line );
+    return eripc_sysd_stop_task( eripcClient, cmd_line );
+}
+
+
+// set busy indication
+gboolean ipc_sys_busy( gboolean look_busy )
+{
+    if (look_busy)
+        return eripc_sysd_set_busy(eripcClient, "delaydialog", NULL);
+    else
+        return eripc_sysd_reset_busy(eripcClient);
+}
+
+// indicate busy with background tasks (to prevent suspend mode from kicking-in)
+gboolean ipc_sys_bg_busy ( gboolean on )
+{
+    //LOGPRINTF("entry [%d]", on);
+    if (on)
+        return eripc_sysd_set_bg_busy(eripcClient);
+    else
+        return eripc_sysd_reset_bg_busy(eripcClient);
+}
+
+
+//----------------------------------------------------------------------------
+// Popup menu
+//----------------------------------------------------------------------------
+
+// add a menu set
+gboolean ipc_menu_add_menu( const char *name,
+                            const char *group1,
+                            const char *group2,
+                            const char *group3 )
+{
+    return eripc_menu_add_menu(eripcClient, name, group1, group2, group3, "");
+}
+
+
+// add a menu group
+gboolean ipc_menu_add_group( const char *name,
+                             const char *parent,
+                             const char *image )
+{
+    return eripc_menu_add_group(eripcClient, name, parent, image);
+}
+
+
+// add a menu item
+gboolean ipc_menu_add_item( const char *name,
+                            const char *parent,
+                            const char *image  )
+{
+    return eripc_menu_add_item(eripcClient, name, parent, image);
+}
+
+
+// set text for a menu set
+gboolean ipc_menu_set_menu_label ( const char *name,
+                                   const char *label )
+{
+    return eripc_menu_set_menu_label(eripcClient, name, label);
+}
+
+
+// set text for a menu group
+gboolean ipc_menu_set_group_label ( const char *name,
+                                    const char *label )
+{
+    return eripc_menu_set_group_label(eripcClient, name, label);
+}
+
+
+// set text for an menu item
+gboolean ipc_menu_set_item_label ( const char *name,
+                                   const char *parent,
+                                   const char *label )
+{
+    return eripc_menu_set_item_label(eripcClient, name, parent, label);
+}
+
+
+// show the given menu set
+gboolean ipc_menu_show_menu( const char *name )
+{
+    return eripc_menu_show_menu(eripcClient, name);
+}
+
+
+// remove the given menu set
+gboolean ipc_remove_menu( const char *name )
+{
+    return eripc_menu_remove_menu(eripcClient, name);
+}
+
+
+// set the state of a menu group
+gboolean ipc_menu_set_group_state( const char *name,
+                                   const char *state )
+{
+    return eripc_menu_set_group_state(eripcClient, name, state);
+}
+
+
+// set the state of a menu item
+gboolean ipc_menu_set_item_state( const char *name,
+                                  const char *parent,
+                                  const char *state  )
+{
+    return eripc_menu_set_item_state(eripcClient, name, parent, state);
+}
+
+
+//============================================================================
+// Local Function Implementation
+//============================================================================
+
+//----------------------------------------------------------------------------
+// Signal/message handlers
+//----------------------------------------------------------------------------
+
+/* @brief Called when a menu items is activated in Popup menu
+ *
+ * Application (callee) should handle the item depending on the current state.
+ */
+static void on_menu_item ( eripc_context_t          *context,
+                           const eripc_event_info_t *info,
+                           void                     *user_data )
+{
+    // LOGPRINTF("entry");
+    const eripc_arg_t *arg_array = info->args;
+
+    if ((arg_array[0].type == ERIPC_TYPE_STRING) &&
+        (arg_array[1].type == ERIPC_TYPE_STRING) &&
+        (arg_array[2].type == ERIPC_TYPE_STRING) &&
+        (arg_array[3].type == ERIPC_TYPE_STRING))
+    {
+        const char        *item      = arg_array[0].value.s;
+        const char        *group     = arg_array[1].value.s;
+        const char        *menu      = arg_array[2].value.s;
+        const char        *state     = arg_array[3].value.s;
+
+        if (item && group && menu && state)
+        {
+            //menu_on_item_activated( item, group, menu, state );
+        }
+    }
+}
+
+
+/* @brief Called after a window was activated (set to the foreground)
+ *
+ * Application (callee) should set its context for the given window and set the
+ * Popupmenu menu context.
+ */
+static void on_window_activated( eripc_context_t          *context,
+                                 const eripc_event_info_t *info,
+                                 void                     *user_data )
+{
+    // LOGPRINTF("entry");
+    gchar             *msg        = NULL;
+    gboolean          result      = FALSE;
+    const eripc_arg_t *arg_array  = info->args;
+
+    printf("on_window_activated\n");
+    if (arg_array[0].type == ERIPC_TYPE_INT)
+    {
+        // TODO: Replace implementation
+
+        gint window = arg_array[0].value.i;
+
+        //menu_show();
+
+        result = TRUE;
+    }
+
+    // return result to caller
+    eripc_reply_bool(context, info->message_id, result);
+}
+
+
+/* @brief Called after a window was deactivated (set to the background)
+ *
+ * Application (callee) may adapt its context and free resources.
+ */
+static void on_window_deactivated( eripc_context_t          *context,
+                                   const eripc_event_info_t *info,
+                                   void                     *user_data )
+{
+    // LOGPRINTF("entry");
+    gchar             *msg        = NULL;
+    gboolean          result      = FALSE;
+    const eripc_arg_t *arg_array  = info->args;
+
+	printf("on_window_deactivated\n");
+    if (arg_array[0].type == ERIPC_TYPE_INT)
+    {
+        // TODO: Replace implementation
+
+        gint window = arg_array[0].value.i;
+
+        result = TRUE;
+    }
+
+    // return result to caller
+    eripc_reply_bool(context, info->message_id, result);
+
+    // and close application
+    // ISR: no!, we don't want to quit the app when setting to the background
+    /* main_quit(); */
+}
+
+
+/* @brief Called when a file, document or url is to be opened by the application
+ *
+ * Application (callee) should create and realise, or reuse an existing window
+ * for the given file and return the X window id in the method reply. The X window
+ * can be obtained using GDK_WINDOW_XID(widget->window). When the file is already
+ * opened by the callee, it may just return its X window id. This call implies that
+ * the window is activated (set to the foreground) so callee should also set its
+ * context for the given window and set the Popupmenu menu context.
+ * System Daemon adds a task to Task Manager of Popupmenu, or replaces the task
+ * when an existing window is returned.
+ */
+static void on_file_open ( eripc_context_t          *context,
+                           const eripc_event_info_t *info,
+                           void                     *user_data )
+{
+    // LOGPRINTF("entry");
+    gchar             *msg        = NULL;
+    gchar             *error_msg  = NULL;
+    gint              my_xid      = -1;
+
+    const eripc_arg_t *arg_array  = info->args;
+
+    if (arg_array[0].type == ERIPC_TYPE_STRING)
+    {
+        const char *file = arg_array[0].value.s;
+        if (file)
+        {
+            // TODO: Replace implementation
+
+            /* gboolean success = TRUE; */
+
+            /* if (success) */
+            /* { */
+            /*     my_xid = GDK_WINDOW_XID(g_main_window->window); */
+            /*     menu_show(); */
+            /* } */
+            /* else */
+            /* { */
+            /*     error_msg = g_strdup_printf(_("Error opening '%s'"), file); */
+            /* } */
+        }
+    }
+
+    // return result to caller
+    eripc_reply_varargs(context, info->message_id,
+                        ERIPC_TYPE_INT, my_xid,
+                        ERIPC_TYPE_STRING, error_msg,
+                        ERIPC_TYPE_INVALID);
+    g_free(error_msg);
+}
+
+
+/* @brief Called when a file, document or url is to be closed by the application
+ *
+ * Application (callee) should close the file and may destroy its window and free
+ * other resources. System Daemon removes the task from the Task Manager of Popupmenu.
+ */
+static void on_file_close ( eripc_context_t          *context,
+                            const eripc_event_info_t *info,
+                            void                     *user_data )
+{
+    // LOGPRINTF("entry");
+    gchar             *msg        = NULL;
+    gboolean          result      = FALSE;
+    const eripc_arg_t *arg_array  = info->args;
+
+    if (arg_array[0].type == ERIPC_TYPE_STRING)
+    {
+        const char *file = arg_array[0].value.s;
+        if (file)
+        {
+            // TODO: Replace implementation
+
+            result = TRUE;
+        }
+    }
+
+    // return result to caller
+    eripc_reply_bool(context, info->message_id, result);
+}
+
+
+/* @brief Called just after a volume is mounted
+ *
+ * Application may use this to add/open the new volume.
+ */
+static void on_mounted ( eripc_context_t          *context,
+                         const eripc_event_info_t *info,
+                         void                     *user_data )
+{
+    // LOGPRINTF("entry");
+    gchar             *msg        = NULL;
+    const eripc_arg_t *arg_array  = info->args;
+
+    if (arg_array[0].type == ERIPC_TYPE_STRING)
+    {
+        const char *mountpoint = arg_array[0].value.s;
+        if (mountpoint)
+        {
+            // TODO: Replace implementation
+        }
+    }
+}
+
+
+/* @brief Called just before unmounting the volume
+ *
+ * Application must close all its open files on the given volume. Failing to
+ * this signal may result in unsaved data or currupt files.
+ */
+static void on_prepare_unmount ( eripc_context_t          *context,
+                                 const eripc_event_info_t *info,
+                                 void                     *user_data )
+{
+    // LOGPRINTF("entry");
+    gchar             *msg        = NULL;
+    const eripc_arg_t *arg_array  = info->args;
+
+    if (arg_array[0].type == ERIPC_TYPE_STRING)
+    {
+        const char *mountpoint = arg_array[0].value.s;
+        if (mountpoint)
+        {
+            // TODO: Replace implementation
+        }
+    }
+}
+
+
+/* @brief Called just after unmounting the volume
+ *
+ * Typically an application should have responded to a prior sysPrepareUnmount
+ * signal, but when a device with volumes was removed unexpectedly it may need
+ * to act on this signal.
+ */
+static void on_unmounted ( eripc_context_t          *context,
+                           const eripc_event_info_t *info,
+                           void                     *user_data )
+{
+    // LOGPRINTF("entry");
+    gchar             *msg        = NULL;
+    const eripc_arg_t *arg_array  = info->args;
+
+    if (arg_array[0].type == ERIPC_TYPE_STRING)
+    {
+        const char  *mountpoint = arg_array[0].value.s;
+        if (mountpoint)
+        {
+            // TODO: Replace implementation
+        }
+    }
+}
+
+
+/* @brief Called just before the system enters standby mode
+ *
+ * Application must commit changes (flush) of all its open files. Failing to
+ * handle this signal may result in unsaved data or currupt files.
+ */
+static void on_prepare_standby ( eripc_context_t          *context,
+                                 const eripc_event_info_t *info,
+                                 void                     *user_data )
+{
+    // LOGPRINTF("entry");
+
+    // TODO: Add implementation here
+}
+
+
+/* @brief Called when the system's locale has changed
+ *
+ * Application should load language dependent screen texts and probably set new
+ * labels for its menu items; to activate a new locale application should call:
+ *             g_setenv("LANG", new_locale, TRUE);
+ *             setlocale(LC_ALL, "");
+ */
+static void on_changed_locale ( eripc_context_t          *context,
+                                const eripc_event_info_t *info,
+                                void                     *user_data )
+{
+    // LOGPRINTF("entry");
+    const eripc_arg_t *arg_array = info->args;
+
+    if (arg_array[0].type == ERIPC_TYPE_STRING)
+    {
+        const char *locale = arg_array[0].value.s;
+        if (locale)
+        {
+            const char *old_locale = g_getenv("LANG");
+            if (!old_locale || (strcmp(old_locale, locale) != 0))
+            {
+                /* main_set_locale(locale); */
+            }
+        }
+    }
+}
+
+
+/* @brief Called when the display's orientation has changed
+ *
+ * Application may need to adapt its screen size, coordinates and/or origin.
+ * Possible values: "portrait", "landscape_clockwise", "landscape_anticlockwise"
+ */
+static void on_changed_orientation ( eripc_context_t          *context,
+                                     const eripc_event_info_t *info,
+                                     void                     *user_data )
+{
+    // LOGPRINTF("entry");
+    gchar             *msg        = NULL;
+    const eripc_arg_t *arg_array = info->args;
+
+    if (arg_array[0].type == ERIPC_TYPE_STRING)
+    {
+        const char *orientation = arg_array[0].value.s;
+        if (orientation)
+        {
+            // TODO: Replace implementation
+        }
+    }
+}
+
+//---------------------
+// new ipc callbacks
+//---------------------
+
+
+static void on_sys_changed_pageturn_inverted(  eripc_context_t *context,
+                                            const eripc_event_info_t *info,
+                                            void *user_data)
+{
+    // LOGPRINTF("entry");
+    gchar             *msg        = NULL;
+    const eripc_arg_t *arg_array = info->args;
+
+    if (arg_array[0].type == ERIPC_TYPE_BOOL)
+    {
+        gboolean is_inverted = arg_array[0].value.b;
+
+        // TODO: Replace implementation
+    }
+
+}
+
+
+static void on_page_change( eripc_context_t *context,
+                            const eripc_event_info_t *info,
+                            void *user_data)
+{
+    // LOGPRINTF("entry");
+    gchar             *msg        = NULL;
+    const eripc_arg_t *arg_array = info->args;
+
+    g_return_if_fail(arg_array[0].type == ERIPC_TYPE_STRING);
+
+    const gchar* direction = arg_array[0].value.s;
+
+    if (direction)
+    {
+        // TODO: Replace implementation
+    }
+}
+
+
+
+//--------------------------------------------------
+// Queries over ipc
+//-------------------------------------------------
+
+// the following functions queries sysd about the
+// custom setting of the flipbar.
+
+// Function: ipc_sys_is_pageturn_inverted()
+//
+// Return value: False -> pageturning is not inverted i.e. left to right gives next page
+//               True  -> pageturning is     inverted i.e. left to right gives previous page
+// Intended use: during application initialisation and only useful in portrait reading mode
+
+gboolean ipc_sys_is_pageturn_inverted()
+{
+    gboolean result = FALSE;
+
+    eripc_error_t retval;
+    eripc_event_info_t* info = NULL;
+
+    // LOGPRINTF("entry");
+
+    retval = eripc_send_varargs_and_wait(eripcClient->context,
+            &info,
+            ERIPC_BUS_SESSION,
+            DBUS_SERVICE_SYSTEM_CONTROL,
+            "sysGetPageturnInverted",
+            ERIPC_TYPE_INVALID);
+
+    if (retval != ERIPC_ERROR_SUCCESS)
+    {
+        ERRORPRINTF("Error launching eripc handler");
+    }
+    else if (info == NULL || info->args == NULL)
+    {
+        ERRORPRINTF("sysd returns OK but no reply structure");
+    }
+    else
+    {
+        const eripc_arg_t *arg_array = info->args;
+
+        if (arg_array[0].type == ERIPC_TYPE_BOOL)
+        {
+            result = (gboolean) arg_array[0].value.b;
+        }
+        else
+        {
+            result = FALSE ;
+        }
+    }
+
+    eripc_event_info_free(eripcClient->context, info);
+    return result;
+}
+
+
+
+// Function: ipc_sys_is_in_portrait_mode()
+//
+// Return value: False -> the device is in landscape mode i.e. flipbar up should be interpreted as previous page.
+//               True  ->  the device is in portrait mode i.e. flipbar interpretation should depend on sys_is_pageturn_inverted result.
+// Intended use: during application initialisation
+
+gboolean ipc_sys_is_in_portrait_mode(void)
+{
+
+    gboolean result = TRUE;
+
+    eripc_error_t retval;
+    eripc_event_info_t* info = NULL;
+
+    LOGPRINTF("entry");
+
+    retval = eripc_send_varargs_and_wait(eripcClient->context,
+            &info,
+            ERIPC_BUS_SESSION,
+            DBUS_SERVICE_SYSTEM_CONTROL,
+            "sysGetOrientation",
+            ERIPC_TYPE_INVALID);
+
+    if (retval != ERIPC_ERROR_SUCCESS)
+    {
+        ERRORPRINTF("Error launching eripc handler");
+    }
+    else if (info == NULL || info->args == NULL)
+    {
+        ERRORPRINTF("sysd returns OK but no reply structure");
+    }
+    else
+    {
+        const eripc_arg_t *arg_array = info->args;
+
+        if (arg_array[0].type == ERIPC_TYPE_STRING)
+        {
+            if ( strcmp("portrait", arg_array[0].value.s) == 0 )
+            {
+                result = TRUE;
+            }
+            else
+            {
+                result = FALSE;
+            }
+        }
+        else
+        {
+            result = FALSE ;
+        }
+    }
+    eripc_event_info_free(eripcClient->context, info);
+    return result;
+}
+#ifndef __IPC_H__
+#define __IPC_H__
+
+/**
+ * File Name  : ipc.h
+ *
+ * Description: The dbus-based eripc functions
+ */
+
+/*
+ * This file is part of hello-world.
+ *
+ * hello-world 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.
+ *
+ * hello-world 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/>.
+ */
+
+/**
+ * Copyright (C) 2009 iRex Technologies B.V.
+ * All rights reserved.
+ */
+
+
+//----------------------------------------------------------------------------
+// Include Files
+//----------------------------------------------------------------------------
+
+#include <liberipc/eripc.h>
+
+G_BEGIN_DECLS
+
+
+//----------------------------------------------------------------------------
+// Definitions
+//----------------------------------------------------------------------------
+
+
+//----------------------------------------------------------------------------
+// Forward Declarations
+//----------------------------------------------------------------------------
+
+
+//----------------------------------------------------------------------------
+// Type Declarations
+//----------------------------------------------------------------------------
+
+
+//----------------------------------------------------------------------------
+// Global Constants
+//----------------------------------------------------------------------------
+
+
+//============================================================================
+// Public Functions
+//============================================================================
+
+/**---------------------------------------------------------------------------
+ *
+ * Name :  ipc_set_services
+ *
+ * @brief  Setup IPC connection and register API functions
+ *
+ * @param  --
+ *
+ * @return --
+ *
+ *--------------------------------------------------------------------------*/
+void ipc_set_services ( void );
+
+
+/**---------------------------------------------------------------------------
+ *
+ * Name :  ipc_unset_services
+ *
+ * @brief  Unregister API functions
+ *
+ * @param  --
+ *
+ * @return --
+ *
+ *--------------------------------------------------------------------------*/
+void ipc_unset_services ( void );
+
+
+/**---------------------------------------------------------------------------
+ *
+ * Name :  ipc_sys_startup_complete
+ *
+ * @brief  Report "application started" to sysd
+ *
+ * @param  --
+ *
+ * @return --
+ *
+ *--------------------------------------------------------------------------*/
+void ipc_sys_startup_complete ( int xid );
+
+
+/**---------------------------------------------------------------------------
+ *
+ * Name :  ipc_sys_start_task
+ *
+ * @brief  Send message startTask to system control,
+ *         usually to open a document in the relevant viewer application
+ *
+ * @param  [in]  cmd_line - command-line to launch the task (executable + options)
+ * @param  [in]  work_dir - working directory in which to start this task
+ * @param  [in]  label - text to show in popup menu
+ * @param  [in]  thumbnail_path - the file containing the thumbnail to show in popup menu
+ * @param  [out] err_message - error message text from application
+ *
+ * @return error code (0 for success, >0 for failure)
+ *
+ *--------------------------------------------------------------------------*/
+gint ipc_sys_start_task ( const gchar  *cmd_line,
+                          const gchar  *work_dir,
+                          const gchar  *label,
+                          const gchar  *thumbnail_path,
+                          gchar        **err_message );
+
+
+/**---------------------------------------------------------------------------
+ *
+ * Name :  ipc_sys_stop_task
+ *
+ * @brief  Send message stopTask to system control,
+ *         usually to close a documen that has previously been open using ipc_sys_start_task()
+ *
+ * @param  [in] cmd_line - command-line passed to ipc_sys_start_task() when launching the task
+ *
+ * @return TRUE on success, FALSE otherwise
+ *
+ *--------------------------------------------------------------------------*/
+gboolean ipc_sys_stop_task ( const gchar  *cmd_line );
+
+
+/**---------------------------------------------------------------------------
+ *
+ * Name :  ipc_menu_add_menu
+ *
+ * @brief  Send message addMenu to popup menu
+ *
+ * @param  [in] name - name (mnemonic) of the menu
+ * @param  [in] group1 .. group3 - name (mnemonic) of the menu groups
+ *
+ * @return TRUE on success, FALSE otherwise
+ *
+ *--------------------------------------------------------------------------*/
+gboolean ipc_menu_add_menu ( const char *name,
+                             const char *group1,
+                             const char *group2,
+                             const char *group3 );
+
+
+/**---------------------------------------------------------------------------
+ *
+ * Name :  ipc_menu_add_group
+ *
+ * @brief  Send message addGroup to popup menu
+ *
+ * @param  [in] name - name (mnemonic) of menu group
+ * @param  [in] parent - name (mnemonic) of the group this group belongs to,
+ *                       or NULL when this group is at the highest level
+ * @param  [in] image - icon bitmap file
+ *
+ * @return TRUE on success, FALSE otherwise
+ *
+ *--------------------------------------------------------------------------*/
+gboolean ipc_menu_add_group ( const char *name,
+                              const char *parent,
+                              const char *image  );
+
+
+/**---------------------------------------------------------------------------
+ *
+ * Name :  ipc_menu_add_item
+ *
+ * @brief  Send message addGroup to popup menu
+ *
+ * @param  [in] name - name (mnemonic) of menu item
+ * @param  [in] parent - name (mnemomic) of the menu group this item belongs to
+ * @param  [in] image - icon bitmap file
+ *
+ * @return TRUE on success, FALSE otherwise
+ *
+ *--------------------------------------------------------------------------*/
+gboolean ipc_menu_add_item ( const char *name,
+                             const char *parent,
+                             const char *image  );
+
+
+/**---------------------------------------------------------------------------
+ *
+ * Name :  ipc_menu_set_menu_label
+ *
+ * @brief  Send message setMenuLabel to popup menu
+ *
+ * @param  [in] name - name (mnemonic) of the menu
+ * @param  [in] label - on-screen text at the top of the menu
+ *
+ * @return TRUE on success, FALSE otherwise
+ *
+ *--------------------------------------------------------------------------*/
+gboolean ipc_menu_set_menu_label ( const char *name,
+                                   const char *label );
+
+
+/**---------------------------------------------------------------------------
+ *
+ * Name :  ipc_menu_set_group_label
+ *
+ * @brief  Send message setGroupLabel to popup menu
+ *
+ * @param  [in] name - name (mnemonic) of menu group
+ * @param  [in] label - on-screen text at the top of the menu group
+ *
+ * @return TRUE on success, FALSE otherwise
+ *
+ *--------------------------------------------------------------------------*/
+gboolean ipc_menu_set_group_label ( const char *name,
+                                    const char *label );
+
+
+/**---------------------------------------------------------------------------
+ *
+ * Name :  ipc_menu_set_item_label
+ *
+ * @brief  Send message setItemLabel to popup menu
+ *
+ * @param  [in] name - name (mnemonic) of menu item
+ * @param  [in] parent - name (mnemomic) of the menu group this item belongs to
+ * @param  [in] label - on-screen text below icon
+ *
+ * @return TRUE on success, FALSE otherwise
+ *
+ *--------------------------------------------------------------------------*/
+gboolean ipc_menu_set_item_label ( const char *name,
+                                   const char *parent,
+                                   const char *label );
+
+
+/**---------------------------------------------------------------------------
+ *
+ * Name :  ipc_menu_show_menu
+ *
+ * @brief  Send message showMenu to popup menu
+ *
+ * @param  [in] name - name (mnemonic) of menu to be displayed
+ *
+ * @return TRUE on success, FALSE otherwise
+ *
+ *--------------------------------------------------------------------------*/
+gboolean ipc_menu_show_menu ( const char *name );
+
+
+/**---------------------------------------------------------------------------
+ *
+ * Name :  ipc_remove_menu
+ *
+ * @brief  Remove menu from popup menu.
+ *
+ * @param  [in] name - name (mnemonic) of menu to be removed
+ *
+ * @return --
+ *
+ *--------------------------------------------------------------------------*/
+gboolean ipc_remove_menu( const char *name );
+
+
+/**---------------------------------------------------------------------------
+ *
+ * Name :  ipc_menu_set_group_state
+ *
+ * @brief  Send message setItemState to popup menu
+ *
+ * @param  [in] name - name (mnemonic) of menu group to be set
+ * @param  [in] state - new state ("normal", "disabled")
+ *
+ * @return TRUE on success, FALSE otherwise
+ *
+ *--------------------------------------------------------------------------*/
+gboolean ipc_menu_set_group_state ( const char *name,
+                                    const char *state );
+
+
+/**---------------------------------------------------------------------------
+ *
+ * Name :  ipc_menu_set_item_state
+ *
+ * @brief  Send message setItemState to popup menu
+ *
+ * @param  [in] name - name (mnemonic) of menu item to be set
+ * @param  [in] parent - name (mnemomic) of the menu group this item belongs to
+ * @param  [in] state - new state ("normal", "selected", "disabled")
+ *
+ * @return TRUE on success, FALSE otherwise
+ *
+ *--------------------------------------------------------------------------*/
+gboolean ipc_menu_set_item_state ( const char *name,
+                                   const char *parent,
+                                   const char *state  );
+
+
+/**---------------------------------------------------------------------------
+ *
+ * Name :  ipc_sys_busy
+ *
+ * @brief  Send message sysSetBusy to system daemon
+ *
+ * @param  [in] look_busy - TRUE to show, FALSE to remove the busy indication
+ *
+ * @return TRUE on success, FALSE otherwise
+ *
+ *--------------------------------------------------------------------------*/
+gboolean ipc_sys_busy( gboolean look_busy );
+
+
+/**---------------------------------------------------------------------------
+ *
+ * Name : ipc_sys_is_pageturn_inverted
+ *
+ * @brief  Query sysd if pageturning is inverted
+ *
+ * @return TRUE if inverted, FALSE otherwise
+ *
+ *--------------------------------------------------------------------------*/
+gboolean ipc_sys_is_pageturn_inverted();
+
+
+/**---------------------------------------------------------------------------
+ *
+ * Name :  ipc_sys_is_in_portrait_mode
+ *
+ * @brief  Query sysd if device in portrait mode
+ *
+ * @return TRUE if in portrait mode, FALSE otherwise (landscape)
+ *
+ *--------------------------------------------------------------------------*/
+gboolean ipc_sys_is_in_portrait_mode();
+
+
+G_END_DECLS
+
+#endif /* __IPC_H__ */
 
 #include <stdio.h>
 #include "liberkeyb/erkeyb-client.h"
+#include "dr-ipc.h"
+
+void my_local_exit_function(void)
+{
+	// We are exiting, so all io is closed, need to re-open IO to hide keyboard
+    erkeyb_client_init();
+	erkeyb_client_hide();
+	erkeyb_client_term();
+}
+
 /*----------------------------------------------------------------------*/
 /* main() */
 /* INTPROTO */
 {
     rxvt_t         *rxvt_vars;
 
+	// show the keyboard during start-up
     erkeyb_client_init();
     erkeyb_client_show();
-    atexit(erkeyb_client_term);
-    atexit(erkeyb_client_hide);
-	
+	// install callback to remove the keboard
+	atexit(my_local_exit_function);
+
     if ((rxvt_vars = rxvt_init(argc, argv)) == NULL)
 	return EXIT_FAILURE;
+	// make sure that rxvt is shown in a tab
+	ipc_set_services();
+	ipc_sys_startup_complete(rxvt_vars->TermWin.parent[0]);
+
     rxvt_main_loop(rxvt_vars);	/* main processing loop */
+	
     return EXIT_SUCCESS;
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.