Initial import
[mdictionary] / include / ws_manager.h
1 /************************************************************************************************
2 This file is part of WhiteStork.
3
4 WhiteStork is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 WhiteStork is distributed in the hope that it will be useful, 
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License 
15 along with WhiteStork; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
18 Copyright 2006 ComArch S.A.
19 ************************************************************************************************/
20 #ifndef _WS_MANAGER
21 #define _WS_MANAGER
22
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <unistd.h>
26 #include <pthread.h>
27 #include <gmodule.h>
28 #include <glib.h>
29 #include <glib/gstdio.h>
30 #include "dictionary_engine.h"
31 #include "ws_dbus.h"
32
33 struct _WSMngSearchData
34 {
35         GArray *dict; ///< pointer to GArray structure which stores pointers to fuction used to service dictionaries 
36         GArray *modules; ///< pointer to GArray structure which stores pointers to fuction used to service modules loading
37         gchar *word; ///< word which will be used to search a dictionaries
38         //pthread_mutex_t a_mutex ///< mutex used to  synchronize threads
39         pthread_t p_thread; ///< a thread in which we serching 
40         WSDBusData *dbus_data; ///< a DBUS data
41         GMainLoop *loop; ///pointer to main loop
42         GModule *library; ///library used to load modules
43 };
44
45 typedef struct _WSMngSearchData WSMngSearchData;
46 /** 
47 * \brief Function is used to initialize D-BUS
48 *
49 *@param data structure stores variables which are need to comunicate by D-BUS.
50 */
51 void ws_mng_init_dbus (WSMngSearchData *data);
52 /**
53 * \brief Function used to initialize user interface
54 *
55 * In this function new process is spawned and in this process user interfece is started.
56 */
57 void ws_mng_init_gui ();
58
59 /**
60 * \brief Function used to initialize manager
61 *
62 * Fuction loads from modules pointers to functions used to service searching in dictionaries and stores them in WSMngSearchData structure
63 *@param data pointer to structure WSMngSearchData which stores variables needed to service manager
64 */
65 void ws_mng_init (WSMngSearchData *data);
66
67 /**
68 * \brief Function is used for set active configuration of dictionaries chosen by user.
69 *
70 * When changes in GConf configuration occurs function clean structure which store pointers to functions used to service searching in dictionaries and fills it again. The dictionaries are omitted when it they are not selected by user.
71 *@param data pointer to a structure holding pointers to functions used to service searching in dictionaries
72 */
73 void ws_mng_set_active_dict (WSMngSearchData *data);
74
75
76 /**
77 * \brief Called when find word event occurs 
78 *
79 * @param word word to search
80 * @param error error messages
81 * @param user_data user data passed to function
82 */
83 void ws_mng_on_search_word (GError *error, GArray *word, gpointer user_data);
84
85 /**
86 * \brief Function used to run search for word engine in threads
87
88 * @param data required data for searach word
89 * @return gpointer return value 
90 */
91 gpointer ws_mng_search_word (gpointer data);
92
93 /**
94 * \brief Called when find translation event occurs
95 *
96 * @param word word to search
97 * @param error error messages
98 * @param user_data user data passed to function
99 */
100 void ws_mng_on_search_translation (GError *error, GArray *word, gpointer user_data);
101
102 /**
103 * \brief Function used to run search for transaltion of word engine in threads
104
105 * @param data required data for search translation
106 * @return gpointer return value 
107 */
108 gpointer ws_mng_search_translation (gpointer data);
109
110 /**
111 * \brief Used to return results of found word from threads 
112 *
113 * @param list word list found in dictionaries
114 * @param pattern a word which is being search for in dictionaries
115 * @param user_data data passed to function
116 * @param error engine status information
117 */
118 void ws_mng_on_found_word (GArray* list, gchar* pattern, gpointer user_data, EngineStatus error);
119
120 /**
121 * \brief Used to return results of transaltion from threads
122 *
123 * @param translation translation of word found in dictionaries
124 * @param pattern a word which is being serch for in dictionaries
125 * @param user_data data passed to function
126 * @param error engine status information
127 */
128
129 void ws_mng_on_found_translation (gchar* translation, gchar* pattern, gpointer user_data, EngineStatus error);
130
131 /**
132 * \brief Function used to close dictionaries and modules
133 *
134 * @param data structure holds pointers to data which need to be freed from memory
135 */
136 void ws_mng_close (WSMngSearchData *data);
137
138 /**
139 * \brief Function used for handling signals sent by user interface
140 *
141 * @param error error messages
142 * @param signal type of signal
143 * @param user_data data passed to function 
144 */
145 void ws_mng_signal_handling (GError *error, GArray *signal, gpointer user_data);
146
147 #endif
148