00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00034 #ifndef _WS_DBUS
00035 #define _WS_DBUS
00036
00037 #ifdef __cplusplus
00038 extern "C" {
00039 #endif
00040
00041 #include <libosso.h>
00042 #include <dbus/dbus-protocol.h>
00043 #include <string.h>
00044 #include <dbus-1.0/dbus/dbus-protocol.h>
00045 #include <stdio.h>
00046 #include <stdlib.h>
00047 #include <glib-2.0/glib.h>
00048
00057 typedef void (* ws_dbus_cb) (GError *error, gpointer data, gpointer user_data);
00058
00060 typedef enum
00061 {
00062 WS_DBUS_TYPE_STRING = DBUS_TYPE_STRING,
00063 WS_DBUS_TYPE_INT = DBUS_TYPE_INT32,
00064 WS_DBUS_TYPE_UINT = DBUS_TYPE_UINT32,
00065 WS_DBUS_TYPE_BOOLEAN = DBUS_TYPE_BOOLEAN,
00066 WS_DBUS_TYPE_DOUBLE = DBUS_TYPE_DOUBLE,
00067 WS_DBUS_TYPE_INVALID = DBUS_TYPE_INVALID,
00068 WS_DBUS_TYPE_GARRAY = ((int) 'a'),
00069 WS_DBUS_TYPE_SIGNAL = DBUS_TYPE_INT32
00070 } WSDBusDataType;
00071
00078 struct _WSDBusData
00079 {
00080 osso_context_t * context;
00082 gchar *service;
00084 gchar *object;
00086 gchar *iface;
00089 gchar *remote_service;
00091 gchar *remote_object;
00093 gchar *remote_iface;
00096 gchar *name;
00098 gchar *version;
00101 GArray *method_data;
00103 GArray *remote_method_data;
00108 };
00109
00112 typedef enum
00113 {
00114 WS_DBUS_STATUS_OK = 0,
00116 WS_DBUS_STATUS_ERROR
00118 } WSDBusStatus;
00119
00123 typedef enum
00124 {
00125 WS_DBUS_INFO_TERMINATE = 1,
00127 WS_DBUS_INFO_STOP_SEARCH,
00129 WS_DBUS_INFO_SEARCH_FINISHED,
00133 WS_DBUS_INFO_CACHING,
00135 WS_DBUS_INFO_CACHING_FINISHED,
00137 WS_DBUS_INFO_CONFIG_CHANGED,
00141 WS_DBUS_ERROR_INVALID_FILE_FORMAT,
00143 WS_DBUS_ERROR_FILE_NOT_FOUND,
00145 WS_DBUS_ERROR_NO_PERMISSION,
00147 WS_DBUS_ERROR_UNKNOWN,
00149 WS_DBUS_ERROR_OUT_OF_MEMORY,
00151 WS_DBUS_ERROR_ENGINE_NOT_FOUND,
00154 WS_DBUS_ERROR_DICTIONARY_NOT_LOAD,
00158 WS_DBUS_BOOKMARKS_ADDED_OK,
00160 WS_DBUS_BOOKMARKS_REMOVED_OK,
00162 WS_DBUS_BOOKMARKS_ADDED_FAIL,
00164 WS_DBUS_BOOKMARKS_REMOVED_FAIL,
00166 WS_DBUS_LOAD_BOOKMARK_FAILED,
00168 WS_DBUS_BOOKMARK_MODE_ON,
00170 WS_DBUS_BOOKMARK_MODE_OFF,
00172 WS_DBUS_EXTRACT_FILE,
00174 WS_DBUS_EXTRACT_FILE_FINISHED,
00176 WS_DBUS_WORDS_LIST_STARTED,
00178 WS_DBUS_TRANSLATION_STARTED,
00180 WS_DBUS_WORDS_LIST_FINISHED,
00182 WS_DBUS_TRANSLATION_FINISHED,
00184 WS_DBUS_WORDS_LIST_FULL,
00186 WS_DBUS_WORDS_LIST_FILLED_NOT_FULL
00188 } WSDBusNotify;
00189
00190
00197 typedef enum
00198 {
00199 WS_DBUS_CONFIG_SERVICE = 1,
00200 WS_DBUS_CONFIG_OBJECT,
00201 WS_DBUS_CONFIG_IFACE,
00202 WS_DBUS_CONFIG_REMOTE_SERVICE,
00203 WS_DBUS_CONFIG_REMOTE_OBJECT,
00204 WS_DBUS_CONFIG_REMOTE_IFACE
00205 } WSDBusConfig;
00206
00207 typedef struct _WSDBusData WSDBusData;
00208
00209
00219 WSDBusData * ws_dbus_create (gchar *name, gchar *version);
00220
00233 WSDBusStatus ws_dbus_config (WSDBusData * ws_dbus_data,
00234 WSDBusConfig field,
00235 gchar *value);
00236
00250 WSDBusStatus ws_dbus_connect (WSDBusData * ws_dbus_data);
00251
00259 void ws_dbus_destroy (WSDBusData * ws_dbus_data);
00260
00274 WSDBusStatus ws_dbus_set_cb (WSDBusData * ws_dbus_data,
00275 gchar * detailed_signal,
00276 gpointer c_func,
00277 gpointer user_data);
00278
00289 WSDBusStatus ws_dbus_add_method (WSDBusData * ws_dbus_data, gchar *method, ...);
00290
00303 WSDBusStatus ws_dbus_call_method (WSDBusData * ws_dbus_data, gchar *method,...);
00304
00310 #define ws_dbus_client_find_word(structure,arg)\
00311 ws_dbus_call_method(structure,\
00312 "find_word",\
00313 WS_DBUS_TYPE_STRING,\
00314 arg,\
00315 WS_DBUS_TYPE_INVALID)
00316
00320 #define ws_dbus_client_find_translation(structure,arg)\
00321 ws_dbus_call_method(structure,\
00322 "find_translation",\
00323 WS_DBUS_TYPE_STRING,\
00324 arg,\
00325 WS_DBUS_TYPE_INVALID)
00326
00329 #define ws_dbus_client_add_bookmark(structure,arg1,arg2)\
00330 ws_dbus_call_method(structure,\
00331 "add_bookmark",\
00332 WS_DBUS_TYPE_STRING,\
00333 arg1,\
00334 WS_DBUS_TYPE_STRING,\
00335 arg2,\
00336 WS_DBUS_TYPE_INVALID)
00337
00340 #define ws_dbus_client_remove_bookmark(structure,arg)\
00341 ws_dbus_call_method(structure,\
00342 "remove_bookmark",\
00343 WS_DBUS_TYPE_STRING,\
00344 arg,\
00345 WS_DBUS_TYPE_INVALID)
00346
00349 #define ws_dbus_client_extract_dictionary(structure,arg)\
00350 ws_dbus_call_method(structure,\
00351 "extract_dictionary",\
00352 WS_DBUS_TYPE_STRING,\
00353 arg,\
00354 WS_DBUS_TYPE_INVALID)
00355
00359
00362 #define ws_dbus_server_return_extracted_dict(structure,arg)\
00363 ws_dbus_call_method(structure,\
00364 "return_extracted_dict",\
00365 WS_DBUS_TYPE_STRING,\
00366 arg,\
00367 WS_DBUS_TYPE_INVALID)
00368
00371 #define ws_dbus_server_return_words(structure,arg)\
00372 ws_dbus_call_method(structure,\
00373 "return_words",\
00374 WS_DBUS_TYPE_GARRAY,\
00375 arg,\
00376 WS_DBUS_TYPE_INVALID)
00377
00380 #define ws_dbus_server_return_translations(structure,arg)\
00381 ws_dbus_call_method(structure,\
00382 "return_translations",\
00383 WS_DBUS_TYPE_STRING,\
00384 arg,\
00385 WS_DBUS_TYPE_INVALID)
00386
00389 #define ws_dbus_server_update_progressbar(structure,arg)\
00390 ws_dbus_call_method(structure,\
00391 "update_progressbar",\
00392 WS_DBUS_TYPE_DOUBLE,\
00393 arg,\
00394 WS_DBUS_TYPE_INVALID)
00395
00399
00402 #define ws_dbus_notify(structure,arg)\
00403 ws_dbus_call_method(structure,\
00404 "signal",\
00405 WS_DBUS_TYPE_SIGNAL,\
00406 arg,\
00407 WS_DBUS_TYPE_INVALID)
00408
00411 #ifdef __cplusplus
00412 }
00413 #endif
00414
00415 #endif
00416