erscribble/test/ipc.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include <sys/stat.h>
00033 #include <unistd.h>
00034 #include <gtk/gtk.h>
00035
00036
00037 #include <liberipc/eripc.h>
00038 #include <liberipc/eripc_support.h>
00039
00040
00041 #include "config.h"
00042 #include "i18n.h"
00043 #include "ipc.h"
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 #define SCRIBBLETEST_MENU "scribbletest_menu"
00054
00055
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
00062 #define DBUS_SERVICE_SYSD "com.irexnet.sysd"
00063 #define DBUS_SERVICE_CTB "com.irexnet.ctb"
00064
00065
00066
00067
00068
00069
00070
00071
00072 static eripc_client_context_t *eripcClient = NULL;
00073
00074
00075
00076
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
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 }
00099 };
00100
00101
00102
00103
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
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
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
00169 main_quit();
00170 result = TRUE;
00171 }
00172
00173
00174 eripc_reply_bool(context, info->message_id, result);
00175 }
00176