* bugfix for pngfix issues on IE browser (background scale etc.)
[mdictionary] / devhowto.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3 <head>
4         <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
5         <meta http-equiv="content-language" content="EN" />
6         <meta name="description" content="Home page for mDictionary project - 
7                     mobile multilingual dictionary for maemo.org platform 
8                     (previously known as a 'WhiteStork')" />
9         <meta name="keywords" content="mdictionary whitestork maemo n770
10                     n800 n810 dictionary xdxf stardict mobile linux comarch" />
11         <meta name="language" content="English" />
12         <meta name="owner" content="ComArch S.A." />
13         <meta name="copyright" content="ComArch, 2006-2007. All rights Reserved."/>
14
15         <link rel="shortcut icon" href="images/favicon.png" type="image/x-icon"></link>
16         <link rel="stylesheet" href="styles/main.css" type="text/css"></link>
17         <!--[if IE 6]>
18                 <link rel="stylesheet"
19                       type="text/css"
20                       href="styles/main_ie.css" />
21
22                 <script src="scripts/pngfix.js" type="text/javascript"></script>
23         <![endif]-->
24         <script language="JavaScript" src="scripts/javascripts.js" ></script>
25
26         <title>
27                 mDictionary - multilingual dictionary for Maemo
28         </title>
29 </head>
30 <body>
31 <div id="webContainer">
32         <div id="topBar">
33                 <img src="images/mLogo_ie24.png" style="float:left;"></img>
34                 <a href="files/mdictionary.install"
35                    class="install">
36                         install
37                 </a>
38                 <div style="display:block;height:100px;">
39                         <p class="title">
40                                 mDictionary
41                         </p>
42                         <p class="description">
43                                 multilingual dictionary for <a href="http://www.maemo.org" target="_blank"><img align="top" border="0" src="images/maemo_logo.png" ></a>(N770, N800 &amp; N810)
44                         </p>
45                 </div>
46                 <div id="topBarLinks">
47                         <a href="index.html">Home</a>
48                         <a href="download.html">Download</a>
49                         <a href="howto.html">How to..</a>
50                         <a href="screen800.html">Screenshots</a>
51                         <a href="userguide.html">User Guide</a>
52                         <a href="faq.html">FAQ</a>
53                         <a href="devhowto.html" class="current">Development</a>
54                         <a href="contact.html">Contact</a>
55                 </div>
56
57         </div>
58         <div id="contentContainer">
59                 <h1>Developer's HOWTO:<br />making Your own GUI for mDictionary</h1>
60
61 <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>
62
63 <p>The only header file You need to include in Your GUI is <span class="code">ws_dbus.h</span>. 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>
64 <p>Firstly, You initialize our dbus wrapper library with <span class="code">ws_dbus_create</span> 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>
65         
66 <div class="code">dbus_data = ws_dbus_create ("mDictionaryGui", "v1.0");</div>
67 <p>
68 Then You configure the remote and local addresses, by using <span class="code">ws_dbus_config</span>. The settings should be the same as in the example, below:
69
70 </p>
71 <div class="code">ws_dbus_config( dbus_data,
72                 WS_DBUS_CONFIG_SERVICE,
73                 "org.maemo.mDictionaryGui" );
74 ws_dbus_config( dbus_data,
75                 WS_DBUS_CONFIG_OBJECT,
76                 "/org/maemo/mDictionaryGui" );
77 ws_dbus_config( dbus_data,
78                 WS_DBUS_CONFIG_IFACE,
79                 "org.maemo.mDictionaryGui" );
80 ws_dbus_config( dbus_data,
81                 WS_DBUS_CONFIG_REMOTE_SERVICE,
82                 "org.maemo.mDictionaryManager" );
83 ws_dbus_config( dbus_data,
84                 WS_DBUS_CONFIG_REMOTE_OBJECT,
85                 "/org/maemo/mDictionaryManager" );
86 ws_dbus_config( dbus_data,
87                 WS_DBUS_CONFIG_REMOTE_IFACE,
88                 "org.maemo.mDictionaryManager" );</div>
89 <p>
90 Now You have to call the <span class="code">ws_dbus_connect</span> function. It's an opaque function, which allows local methods to be run remotely. 
91 </p>
92 <div class="code">ws_dbus_connect( dbus_data );</div>
93 <p>
94 The only thing that's left now is specifying callback functions (with <span class="code">ws_dbus_set_cb</span>), which are to be called
95 whenever the manager calls a remote method.
96 </p>
97 <div class="code">ws_dbus_set_cb( dbus_data,
98                 "return_words",
99                 ws_gui_dbus_return_words,
100                 ws_gui_app );</div>
101
102 <p>Callbacks definition:</p>
103
104 <div class="code">void ws_gui_dbus_return_words( GError *error,
105                                GArray *words,
106                                gpointer user_data );</div>
107
108 <p class="faq_question">
109 Accessing received data inside a callback handling function:
110 </p>
111
112 <p>
113 In this case, words is a <span class="code">GArray</span> of <span class="code">osso_rpc_t</span> values. To access the contents of an <span class="code">osso_rpc_t</span> 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:
114 </p>
115
116 <div class="code">int i;
117 osso_rpc_t data;
118 for (i = 0; i < words->len; ++i)
119 {
120         data = g_array_index (words, osso_rpc_t, 0);
121         if (DBUS_TYPE_STRING == data.type)
122         {
123                 char *tmp_word = g_strdup(data.value.s);
124                 do_sth_with_word(tmp_word);
125         };
126 };
127 </div>
128 <p class="faq_question">
129         Calling remote methods on manager:
130 </p>
131 <div class="code">ws_dbus_client_find_word (ws_gui_app->dbus_data, word);</div>
132 <p>
133 All functions containing the word client in their name, should be called from the GUI application.
134
135 Please refer to dbus wrapper API documentation for further info. It can be generated by issuing <span class="code">make docs</span> command in dbus wrapper source directory.
136 </p>
137
138 </div>
139         <div id="footer">
140                         <p>Copyright &copy; 2006 - 2007 ComArch S.A.</p>
141                         <br>
142                         <a href="http://www.comarch.com"><img src="images/comarch.png"
143                              alt="ComArch Information Technology"
144                              width="150px"
145                              height="36px"
146                                  border="0"
147                                  >
148                         </a>
149                 </div>
150         </div>
151 </div>
152 <br>
153 </body>
154 </html>