1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <meta http-equiv="Content-type" content="text/html; charset=iso-8859-2">
5 <title>WhiteStork Multilingual Dictionary</title>
6 <link rel="Stylesheet" type="text/css" href="./css/style.css">
10 <tr><td colspan="2"><center><img src="./images/label2.png"></center></td></tr>
12 <td id="left_border"> </td>
18 <tr><th>Menu</th></tr>
21 <a href="index.html">About</a><br>
22 <a href="licence.html">Licence</a><br>
23 <a href="howto.html">How to...</a><br>
24 <a href="devhowto.html">For developers</a><br>
25 <a href="faq.html">FAQ</a><br>
26 <a href="http://mdictionary.garage.maemo.org/userguide/" target="blank">User Guide</a><br>
27 <a href="screen.html">Screenshots</a><br>
28 <a href="download.html">Download</a><br>
29 <a href="contact.html">Contact us</a><br>
32 <tr><th class="footer"> </th></tr>
39 <tr><th> </th></tr>
43 <div class="faq_title">Developer's HOWTO: making Your own GUI for mDictionary</div>
44 <p><b>mDictionary</b> is intended to be as modifiable as possible. So apart from developing Your own dictionary engines, You can also create alternative user interface, should You find ours inattractive. For the intrepid ones, I have described how to do that. In this howto, I am going to explain how to communicate GUI with the engines's manager</p>
46 <p>The only header file You need to include in Your GUI is <func>ws_dbus.h</func>. It contains all the functions necessary to communicate with the engines manager. The header file is available from our svn repository at <a href="https://garage.maemo.org">https://garage.maemo.org</a>.</p>
47 <p>Firstly, You initialize our dbus wrapper library with <func>ws_dbus_create</func> function. You have to specify the name and the version of Your app and store the function's return value as it is necessary for further dbus wrapper communication.</p>
49 <div class="code">dbus_data = ws_dbus_create ("WhiteStorkGui", "v1.0");</div>
51 Then You configure the remote and local addresses, by using <func>ws_dbus_config</func>. The settings should be the same as in the example, below:
53 <div class="code">ws_dbus_config (dbus_data,
54 WS_DBUS_CONFIG_SERVICE,
55 "org.maemo.WhiteStorkGui");
56 ws_dbus_config (dbus_data,
57 WS_DBUS_CONFIG_OBJECT,
58 "/org/maemo/WhiteStorkGui");
59 ws_dbus_config (dbus_data,
61 "org.maemo.WhiteStorkGui");
62 ws_dbus_config (dbus_data,
63 WS_DBUS_CONFIG_REMOTE_SERVICE,
64 "org.maemo.WhiteStorkManager");
65 ws_dbus_config (dbus_data,
66 WS_DBUS_CONFIG_REMOTE_OBJECT,
67 "/org/maemo/WhiteStorkManager");
68 ws_dbus_config (dbus_data,
69 WS_DBUS_CONFIG_REMOTE_IFACE,
70 "org.maemo.WhiteStorkManager");
73 Now You have to call the <func>ws_dbus_connect</func> function. It's an opaque function, which allows local methods to be run remotely.
75 <div class="code">ws_dbus_connect (dbus_data);</div>
77 The only thing that's left now is specifying callback functions (with <func>ws_dbus_set_cb</func>), which are to be called
78 whenever the manager calls a remote method.
80 <div class="code">ws_dbus_set_cb (dbus_data,
82 ws_gui_dbus_return_words,
86 <p>Callbacks definition:</p>
88 <div class="code">void ws_gui_dbus_return_words (GError *error, GArray *words, gpointer user_data);</div>
90 <div class="faq_question">
91 Accessing received data inside a callback handling function:
94 In this case, words is a <func>GArray</func> of <func>osso_rpc_t</func> values. To access the contents of an osso_rpc_t variable, You first have to check its type by accessing the type field. The value field is an union of primitives. Depending on the type, You should read the value by accessing a proper field. Here is an example:
96 <div class="code">int i;
98 for (i = 0; i < words->len; ++i)
101 data = g_array_index (words, osso_rpc_t, 0);
102 if (data.type == DBUS_TYPE_STRING)
105 char *tmp_word = g_strdup(data.value.s);
110 <div class="faq_question">
112 Calling remote methods on manager:
115 <div class="code">ws_dbus_client_find_word (ws_gui_app->dbus_data, word);</div>
117 All functions containing the word client in their name, should be called from the GUI application.
119 Please refer to dbus wrapper API documentation for further info. It can be generated by issuing <func>make docs</func>
120 command in dbus wrapper source directory.
124 <tr><th class="footer"> </th></tr>
128 <tr><td colspan="2" id="footer_border"> </td></tr>
129 <tr><td colspan="2" id="footer">© 2006 <a href="#top">WhiteStork Multilingual Dictionary</a></td></tr>
132 <td id="right_border"> </td>