erscribble/test/ipc.c

Go to the documentation of this file.
00001 /*
00002  * File Name: ipc.c
00003  */
00004 
00005 /*
00006  * This file is part of ...
00007  *
00008  * settings is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation, either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * settings is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00020  */
00021 
00022 /**
00023  * Copyright (C) 2008 iRex Technologies B.V.
00024  * All rights reserved.
00025  */
00026 
00027 //----------------------------------------------------------------------------
00028 // Include Files
00029 //----------------------------------------------------------------------------
00030 
00031 // system include files, between < >
00032 #include <sys/stat.h>
00033 #include <unistd.h>
00034 #include <gtk/gtk.h>
00035 
00036 // ereader include files, between < >
00037 #include <liberipc/eripc.h>
00038 #include <liberipc/eripc_support.h>
00039 
00040 // local include files, between " "
00041 #include "config.h"
00042 #include "i18n.h"
00043 #include "ipc.h"
00044 
00045 //----------------------------------------------------------------------------
00046 // Type Declarations
00047 //----------------------------------------------------------------------------
00048 
00049 //----------------------------------------------------------------------------
00050 // Global Constants
00051 //----------------------------------------------------------------------------
00052 
00053 #define SCRIBBLETEST_MENU               "scribbletest_menu"
00054 
00055 // IPC settings
00056 #define DBUS_APPL_NAME           PACKAGE_NAME
00057 #define DBUS_SERVICE             "com.irexnet."DBUS_APPL_NAME
00058 #define DBUS_PATH                "/com/irexnet/"DBUS_APPL_NAME
00059 #define DBUS_INTERFACE           "com.irexnet."DBUS_APPL_NAME
00060 
00061 // IPC popup menu
00062 #define DBUS_SERVICE_SYSD        "com.irexnet.sysd"
00063 #define DBUS_SERVICE_CTB         "com.irexnet.ctb"
00064 
00065 // Popup menu strings
00066 
00067 
00068 //----------------------------------------------------------------------------
00069 // Static Variables
00070 //----------------------------------------------------------------------------
00071 
00072 static eripc_client_context_t *eripcClient = NULL;
00073 
00074 
00075 //============================================================================
00076 // Local Function Definitions
00077 //============================================================================
00078 
00079 void main_quit()
00080 {
00081     ipc_unset_services();
00082     gtk_main_quit();
00083 }
00084 
00085 static void on_window_activated  ( eripc_context_t          *context,
00086                                    const eripc_event_info_t *info,
00087                                    void                     *user_data );
00088 
00089 static void on_window_deactivated ( eripc_context_t          *context,
00090                                    const eripc_event_info_t *info,
00091                                    void                     *user_data );
00092 
00093 // Exported DBUS API list
00094 static eripc_callback_function_t
00095 service_functions[] = {
00096     { on_window_activated,  "activatedWindow",     NULL,              0 },
00097     { on_window_deactivated,"deactivatedWindow",   NULL,              0 },
00098     { NULL }  // end of list
00099 };
00100 
00101 
00102 //============================================================================
00103 // Functions Implementation
00104 //============================================================================
00105 
00106 gboolean ipc_set_services()
00107 {
00108     eripcClient = eripc_client_context_new(
00109                     DBUS_APPL_NAME,
00110                     "1.0",
00111                     DBUS_SERVICE,
00112                     DBUS_PATH,
00113                     DBUS_INTERFACE,
00114                     service_functions);
00115 
00116     return TRUE;
00117 }
00118 
00119 
00120 void ipc_unset_services()
00121 {
00122     eripc_client_context_free(eripcClient, service_functions);
00123 }
00124 
00125 
00126 void ipc_sys_startup_complete ( void )
00127 {
00128     eripc_sysd_startup_complete( eripcClient, getpid(), FALSE, 0 );
00129 }
00130 
00131 
00132 gboolean ipc_set_stylus(const char* state)
00133 {
00134     g_return_val_if_fail( (state != NULL), FALSE);
00135     return eripc_menu_set_statusitem_state(eripcClient, "statusbar_stylus", state);
00136 }
00137 
00138 
00139 //============================================================================
00140 // Local Functions Implementation
00141 //============================================================================
00142 
00143 static void on_window_activated(eripc_context_t          *context,
00144                                 const eripc_event_info_t *info,
00145                                 void                     *user_data)
00146 {
00147     gboolean          result      = FALSE; 
00148     const eripc_arg_t *arg_array  = info->args;
00149 
00150     if (arg_array[0].type == ERIPC_TYPE_INT)
00151     {
00152         result = TRUE;
00153     }
00154 
00155     // return result to caller
00156     eripc_reply_bool(context, info->message_id, result);
00157 }
00158 
00159 static void on_window_deactivated(eripc_context_t          *context,
00160                                 const eripc_event_info_t *info,
00161                                 void                     *user_data)
00162 {
00163     gboolean          result      = FALSE; 
00164     const eripc_arg_t *arg_array  = info->args;
00165 
00166     if (arg_array[0].type == ERIPC_TYPE_INT)
00167     {
00168         // gtk_main_quit();
00169         main_quit();
00170         result = TRUE;
00171     }
00172 
00173     // return result to caller
00174     eripc_reply_bool(context, info->message_id, result);
00175 }
00176 
Generated by  doxygen 1.6.2-20100208