first (buggy) version of keyboard usage in qml list
[mdictionary] / www / 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         <!--    <div class="installs">
35                         INSTALL:
36                         <a href="files/mdictionary.install"
37                            class="install" style="margin-top:4px;"
38                            title="Click to install mDictionary on OS2006"><span>OS2006</span>
39                         </a>
40                         <a href="files/mdictionary.install"
41                            class="install" style="clear:both; margin-top:4px;"
42                            title="Click to install mDictionary on OS2007"><span style="letter-spacing:0px;">OS2007</span>
43                         </a>
44                         <a href="files/mdictionary2008.install"
45                            class="install" style="clear:both; margin-top:4px;"
46                            title="Click to install mDictionary on OS2008"><span style="letter-spacing:0px;">OS2008</span>
47                         </a>
48                         <span style="clear:both;text-align:center;display:block;font-size:9px;"><a href="howto.html" style="font-size:9px;text-decoration:none;">(read How To... first)</a></span>
49                 </div>
50 -->             
51                 <div style="display:block;height:100px;">
52                         <p class="title">
53                                 mDictionary
54                         </p>
55                         <p class="description">
56                                 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)
57                         </p>
58                         <p class="description">
59                                 &nbsp; and <a href="http://www.meego.com" target="_blank"><img align="top" border="0" src="images/Meego.png" width="80" height="20" ></a> (N900 & netbook )
60                         </p>
61                 </div>
62                 <div id="topBarLinks">
63                         <a href="index.html" >Home</a>
64                         <a href="download.html">Download</a>
65                         <a href="qmlelements.html">QML Elements</a>
66                         <a href="howto.html">How to..</a>
67                         <a href="screen800.html">Screenshots</a>
68                         <a href="userguide.html">User Guide</a>
69                         <a href="faq.html">FAQ</a>
70                         <a href="devhowto.html" class="current" >Development</a>
71                         <a href="contact.html">Contact</a>
72                 </div>
73         </div>
74         <div id="contentContainer">
75
76
77                 <h1>Developer's HOWTO:<br />making Your own plugin</h1>
78                         The manual is available <a href="files/doc-plugin.1.0.4.odt">here</a>
79
80                 <h1>Developer's HOWTO:<br />making Your own GUI (new version of mDictionary)</h1>
81                         The manual isn't available yet 
82                 
83                 <h1>Developer's HOWTO:<br />making Your own GUI for mDictionary (old versien of mDictionary)</h1>
84
85 <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>
86
87 <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>
88 <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>
89         
90 <div class="code">dbus_data = ws_dbus_create ("mDictionaryGui", "v1.0");</div>
91 <p>
92 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:
93
94 </p>
95 <div class="code">ws_dbus_config( dbus_data,
96                 WS_DBUS_CONFIG_SERVICE,
97                 "org.maemo.mDictionaryGui" );
98 ws_dbus_config( dbus_data,
99                 WS_DBUS_CONFIG_OBJECT,
100                 "/org/maemo/mDictionaryGui" );
101 ws_dbus_config( dbus_data,
102                 WS_DBUS_CONFIG_IFACE,
103                 "org.maemo.mDictionaryGui" );
104 ws_dbus_config( dbus_data,
105                 WS_DBUS_CONFIG_REMOTE_SERVICE,
106                 "org.maemo.mDictionaryManager" );
107 ws_dbus_config( dbus_data,
108                 WS_DBUS_CONFIG_REMOTE_OBJECT,
109                 "/org/maemo/mDictionaryManager" );
110 ws_dbus_config( dbus_data,
111                 WS_DBUS_CONFIG_REMOTE_IFACE,
112                 "org.maemo.mDictionaryManager" );</div>
113 <p>
114 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. 
115 </p>
116 <div class="code">ws_dbus_connect( dbus_data );</div>
117 <p>
118 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
119 whenever the manager calls a remote method.
120 </p>
121 <div class="code">ws_dbus_set_cb( dbus_data,
122                 "return_words",
123                 ws_gui_dbus_return_words,
124                 ws_gui_app );</div>
125
126 <p>Callbacks definition:</p>
127
128 <div class="code">void ws_gui_dbus_return_words( GError *error,
129                                GArray *words,
130                                gpointer user_data );</div>
131
132 <p class="faq_question">
133 Accessing received data inside a callback handling function:
134 </p>
135
136 <p>
137 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:
138 </p>
139
140 <div class="code">int i;
141 osso_rpc_t data;
142 for (i = 0; i < words->len; ++i)
143 {
144         data = g_array_index (words, osso_rpc_t, 0);
145         if (DBUS_TYPE_STRING == data.type)
146         {
147                 char *tmp_word = g_strdup(data.value.s);
148                 do_sth_with_word(tmp_word);
149         };
150 };
151 </div>
152 <p class="faq_question">
153         Calling remote methods on manager:
154 </p>
155 <div class="code">ws_dbus_client_find_word (ws_gui_app->dbus_data, word);</div>
156 <p>
157 All functions containing the word client in their name, should be called from the GUI application.
158
159 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.
160 </p>
161
162 </div>
163         <div id="footer">
164                         <p>Copyright &copy; 2006 - 2008 ComArch S.A.</p>
165                         <br>
166                         <a href="http://www.comarch.com"><img src="images/comarch.png"
167                              alt="ComArch Information Technology"
168                              width="150px"
169                              height="36px"
170                                  border="0"
171                                  >
172                         </a>
173                 </div>
174         </div>
175 </div>
176 <br>
177 </body>
178 </html>