1 /************************************************************************************************
2 This file is part of WhiteStork.
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.
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.
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
18 Copyright 2006 ComArch S.A.
19 ************************************************************************************************/
29 #include <glib/gstdio.h>
30 #include "dictionary_engine.h"
33 struct _WSMngSearchData
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
45 typedef struct _WSMngSearchData WSMngSearchData;
47 * \brief Function is used to initialize D-BUS
49 *@param data structure stores variables which are need to comunicate by D-BUS.
51 void ws_mng_init_dbus (WSMngSearchData *data);
53 * \brief Function used to initialize user interface
55 * In this function new process is spawned and in this process user interfece is started.
57 void ws_mng_init_gui ();
60 * \brief Function used to initialize manager
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
65 void ws_mng_init (WSMngSearchData *data);
68 * \brief Function is used for set active configuration of dictionaries chosen by user.
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
73 void ws_mng_set_active_dict (WSMngSearchData *data);
77 * \brief Called when find word event occurs
79 * @param word word to search
80 * @param error error messages
81 * @param user_data user data passed to function
83 void ws_mng_on_search_word (GError *error, GArray *word, gpointer user_data);
86 * \brief Function used to run search for word engine in threads
88 * @param data required data for searach word
89 * @return gpointer return value
91 gpointer ws_mng_search_word (gpointer data);
94 * \brief Called when find translation event occurs
96 * @param word word to search
97 * @param error error messages
98 * @param user_data user data passed to function
100 void ws_mng_on_search_translation (GError *error, GArray *word, gpointer user_data);
103 * \brief Function used to run search for transaltion of word engine in threads
105 * @param data required data for search translation
106 * @return gpointer return value
108 gpointer ws_mng_search_translation (gpointer data);
111 * \brief Used to return results of found word from threads
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
118 void ws_mng_on_found_word (GArray* list, gchar* pattern, gpointer user_data, EngineStatus error);
121 * \brief Used to return results of transaltion from threads
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
129 void ws_mng_on_found_translation (gchar* translation, gchar* pattern, gpointer user_data, EngineStatus error);
132 * \brief Function used to close dictionaries and modules
134 * @param data structure holds pointers to data which need to be freed from memory
136 void ws_mng_close (WSMngSearchData *data);
139 * \brief Function used for handling signals sent by user interface
141 * @param error error messages
142 * @param signal type of signal
143 * @param user_data data passed to function
145 void ws_mng_signal_handling (GError *error, GArray *signal, gpointer user_data);