2 This library is free software; you can redistribute it and/or
3 modify it under the terms of the GNU Lesser General Public
4 License as published by the Free Software Foundation;
5 version 2.1 of the License.
7 This library is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 Lesser General Public License for more details.
12 You should have received a copy of the GNU Lesser General Public
13 License along with this library; if not, write to the Free Software
14 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 Copyright 2006 ComArch S.A.
27 #include <dbus/dbus-protocol.h>
29 #include <dbus-1.0/dbus/dbus-protocol.h>
32 #include <glib-2.0/glib.h>
34 /**\brief Callback function definition
36 *@param error - pointer to a GError structure. Currently not used
37 *@param words - GArray of osso_rpc_t structures containing sent data
38 *@param user_data - data passed by user while setting the callback
39 function with ::ws_dbus_set_cb
42 typedef void (* ws_dbus_cb) (GError *error, gpointer data, gpointer user_data);
44 /**\brief This structure contains data vital for DBUS communication.
46 * These are for example both the local and remote addresses of the applications
47 which are supposed to communicate. In this case they are the <I>GUI</I> and the
49 * The fields shouldn't be modified directly. It should be done by ws_dbus_config
56 WS_DBUS_TYPE_STRING = DBUS_TYPE_STRING,
57 WS_DBUS_TYPE_INT = DBUS_TYPE_INT32,
58 WS_DBUS_TYPE_UINT = DBUS_TYPE_UINT32,
59 WS_DBUS_TYPE_BOOLEAN = DBUS_TYPE_BOOLEAN,
60 WS_DBUS_TYPE_DOUBLE = DBUS_TYPE_DOUBLE,
61 WS_DBUS_TYPE_INVALID = DBUS_TYPE_INVALID,
62 WS_DBUS_TYPE_GARRAY = ((int) 'a'),
63 WS_DBUS_TYPE_SIGNAL = DBUS_TYPE_INT32
68 osso_context_t * context; ///<a pointer needed by osso_initiallize
70 gchar *service; ///<owner service path
71 gchar *object; ///<owner object path
72 gchar *iface; ///<owner interface path
74 gchar *remote_service; ///<remote service path
75 gchar *remote_object; ///<remote object path
76 gchar *remote_iface; ///<remote interface path
78 gchar *name; ///<Program name
79 gchar *version; ///<Program version
82 GArray *remote_method_data;
86 *\brief Informs whether the transmission succeeded or not
90 WS_DBUS_STATUS_OK = 0, ///<Transmission succeeded
91 WS_DBUS_STATUS_ERROR ///<Transmission error
94 /**\brief Specifies the possible kinds of event notifications that can be sent via DBus
98 WS_DBUS_INFO_TERMINATE = 1, ///<GUI signal - terminate the application
99 WS_DBUS_INFO_STOP_SEARCH, ///<GUI signal - stop the current search
100 WS_DBUS_INFO_SEARCH_FINISHED, ///<Manager signal - informs the GUI, that there will be no more results returned
101 WS_DBUS_INFO_CACHING, ///<Manager signal - informs the GUI, that caching has started
102 WS_DBUS_INFO_CACHING_FINISHED, ///<Manager signal - informs the GUI, that caching has finished
103 WS_DBUS_INFO_CONFIG_CHANGED, ///<GUI signal - informs the Manager about changes in the GConf configuration
104 WS_DBUS_ERROR_INVALID_FILE_FORMAT, ///<Parser error - dictionary file has invalid format
105 WS_DBUS_ERROR_FILE_NOT_FOUND, ///<Parser error - dictionary file not found
106 WS_DBUS_ERROR_NO_PERMISSION, ///<Parser error - no permission to read the dictionary file
107 WS_DBUS_ERROR_UNKNOWN, ///<Parser error - unknown error
108 WS_DBUS_ERROR_OUT_OF_MEMORY, ///<Either the UI or the manager is out of memory
109 WS_DBUS_ERROR_ENGINE_NOT_FOUND, ///<Manager error - dictionary engine module, couldn't be located
111 WS_DBUS_ERROR_DICTIONARY_NOT_LOAD, ///<Manager sigal - informs the GUI,that history record can not be found because dictionary is not activate
112 WS_DBUS_BOOKMARKS_ADDED_OK, ///<GUI signal - send if bookmark has been added succesfully
113 WS_DBUS_BOOKMARKS_REMOVED_OK, ///<GUI signal - send if bookmark has been removed succesfully
114 WS_DBUS_BOOKMARKS_ADDED_FAIL, ///<GUI signal - send if bookmark has not been added succesfully
115 WS_DBUS_BOOKMARKS_REMOVED_FAIL, ///<GUI signal - send if bookmark has not been removed succesfully
116 WS_DBUS_LOAD_BOOKMARK_FAILED, ///<GUI signal - blocks bookmarks
117 WS_DBUS_BOOKMARK_MODE_ON,
118 WS_DBUS_BOOKMARK_MODE_OFF,
119 WS_DBUS_EXTRACT_FILE,
120 WS_DBUS_EXTRACT_FILE_FINISHED,
121 WS_DBUS_WORDS_LIST_STARTED,
122 WS_DBUS_TRANSLATION_STARTED,
123 WS_DBUS_WORDS_LIST_FINISHED,
124 WS_DBUS_TRANSLATION_FINISHED,
125 WS_DBUS_WORDS_LIST_FULL,
126 WS_DBUS_WORDS_LIST_FILLED_NOT_FULL
132 *\brief This structure is used for specifying the field of WSDBusData structure one would like to modify.
134 *It is used in the ws_dbus_config function. Its main purpose is to clarify D-BUS
139 WS_DBUS_CONFIG_SERVICE = 1,
140 WS_DBUS_CONFIG_OBJECT,
141 WS_DBUS_CONFIG_IFACE,
142 WS_DBUS_CONFIG_REMOTE_SERVICE,
143 WS_DBUS_CONFIG_REMOTE_OBJECT,
144 WS_DBUS_CONFIG_REMOTE_IFACE
147 typedef struct _WSDBusData WSDBusData;
150 /**\brief First function to be called in every program using this wrapper library
152 *This function is used for allocating memory for the WSDBusData structure and
153 setting some basic parameters.
154 *@param name - name of the application
155 *@param version - app's version
156 *@return pointer to WSDBusData structure\n
159 WSDBusData * ws_dbus_create (gchar *name, gchar *version);
161 /**\brief This function is used for setting dbus service/client parameters.
163 *These include the addresses of both remote and local apps communicating
164 *@param ws_dbus_data - pointer to a structure uniquely identifying
165 the application for DBus. The possible values of
166 *this parameter are listed here: ::WSDBusConfig
167 *@param field - the name of the variable, this function is supposed to set.
168 *@param value - the value of the variable
169 *@return WS_STATUS_OK - on success \n
170 *WS_STATUS_ERROR - on error
173 WSDBusStatus ws_dbus_config (WSDBusData * ws_dbus_data,
178 *\brief Initialize D-BUS communication.
180 *It should be the called after <B>ws_dbus_create</B> and after setting all D-BUS
181 parameters with the <B>ws_dbus_config</B> function.
182 *The structure it returns is necessary to call out every function implemented in
183 this wrapper library.
184 *@param ws_dbus_data - it's a structure containing the unique paths to objects
185 and interfaces to be registered in the DBus session daemon
186 *@return WS_STATUS_OK - on success \n
187 *WS_STATUS_ERROR - on error
188 *\sa ::WSDBusConfig, ws_dbus_create, ws_dbus_config
190 WSDBusStatus ws_dbus_connect (WSDBusData * ws_dbus_data);
192 /**\brief Function deinitializing D-BUS wrapper library
194 *Before the program exits, all memory allocated by D-BUS should be freed.
195 @param ws_dbus_data - pointer to a structure uniquely identifying the
197 *@return WS_STATUS_OK - on success \n
198 *WS_STATUS_ERROR - on error
201 void ws_dbus_destroy (WSDBusData * ws_dbus_data);
203 /**\brief This function is used for setting a callback function for some predefined signals.
205 *Some of the signals should be used only by the <I>GUI</I>, others by the
208 *@param ws_dbus_data - pointer to a structure uniquely identifying the
209 application for D-BUS
210 *@param detailed_signal - string containing the signal name which will trigger
211 the function passed in
212 *the c_func parameter.
213 *@param c_func - is a pointer to the signal handling function.
214 *@param user_data - is the data passed directly to the signal handling function
216 *The predefined signal values for the GUI part are:
218 * - <I>"return_words"</I> - used for receiving a list of words found by
220 * - <I>"return_translations"</I> - used for receiving a list of
221 translations found by the <I>MANAGER</I>
222 * - <I>"signal"</I> - used for handling signals from the <I>MANAGER</I>.
223 In this case they are mainly error signals.
225 *The predefined signal values for the MANAGER part are:
227 * - <I>"find_word"</I> - used for receiving the word a user is looking for
228 * - <I>"find_translation"</I> - used for receiving the word a user needs
230 * - <I>"signal"</I> - used for handling signals from the <I>GUI</I>.
231 In this case they are termination and stop search signals.
233 *@return WS_STATUS_OK - on success \n
234 *WS_STATUS_ERROR - on error
235 *\sa ::WSDBusConfig \n
239 WSDBusStatus ws_dbus_set_cb (WSDBusData * ws_dbus_data,
240 gchar * detailed_signal,
244 WSDBusStatus ws_dbus_add_method (WSDBusData * ws_dbus_data, gchar *method, ...);
247 WSDBusStatus ws_dbus_call_method (WSDBusData * ws_dbus_data, gchar *method,
250 void ws_dbus_multipleargs_test (WSDBusData * ws_dbus_data, gchar *method, ...);
252 #define ws_dbus_notify(structure,arg) ws_dbus_call_method(structure,"signal",WS_DBUS_TYPE_SIGNAL,arg,WS_DBUS_TYPE_INVALID)
254 #define ws_dbus_client_find_word(structure,arg) ws_dbus_call_method(structure,"find_word",WS_DBUS_TYPE_STRING,arg,WS_DBUS_TYPE_INVALID)
256 #define ws_dbus_client_find_translation(structure,arg) ws_dbus_call_method(structure,"find_translation",WS_DBUS_TYPE_STRING,arg,WS_DBUS_TYPE_INVALID)
258 #define ws_dbus_client_add_bookmark(structure,arg1,arg2) ws_dbus_call_method(structure,"add_bookmark",WS_DBUS_TYPE_STRING,arg1,WS_DBUS_TYPE_STRING,arg2,WS_DBUS_TYPE_INVALID)
260 #define ws_dbus_client_remove_bookmark(structure,arg) ws_dbus_call_method(structure,"remove_bookmark",WS_DBUS_TYPE_STRING,arg,WS_DBUS_TYPE_INVALID)
262 #define ws_dbus_client_extract_dictionary(structure,arg) ws_dbus_call_method(structure,"extract_dictionary",WS_DBUS_TYPE_STRING,arg,WS_DBUS_TYPE_INVALID)
264 #define ws_dbus_server_return_extracted_dict(structure,arg) ws_dbus_call_method(structure,"return_extracted_dict",WS_DBUS_TYPE_STRING,arg,WS_DBUS_TYPE_INVALID)
266 #define ws_dbus_server_return_words(structure,arg) ws_dbus_call_method(structure,"return_words",WS_DBUS_TYPE_GARRAY,arg,WS_DBUS_TYPE_INVALID)
268 #define ws_dbus_server_return_translations(structure,arg) ws_dbus_call_method(structure,"return_translations",WS_DBUS_TYPE_STRING,arg,WS_DBUS_TYPE_INVALID)
270 #define ws_dbus_server_update_progressbar(structure,arg) ws_dbus_call_method(structure,"update_progressbar",WS_DBUS_TYPE_DOUBLE,arg,WS_DBUS_TYPE_INVALID)