00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00026 #include <ws_mng_dictionary_utils.h>
00027
00033 void ws_mng_extract_dictionary( GError *error,
00034 GArray* param,
00035 gpointer user_data )
00036 {
00037 g_debug("->%s", __FUNCTION__);
00038 WSMngSearchData *data = (WSMngSearchData *) user_data;
00039 osso_rpc_t *osso_data;
00040
00041
00042 osso_data = &g_array_index (param, osso_rpc_t, 0);
00043 gchar* path = g_strdup(osso_data->value.s);
00044 gint result = -1;
00045
00046 gchar* dest = NULL;
00047 if (path != NULL)
00048 {
00049 gint count = 0;
00050 gchar** tmp = g_strsplit(path, "/", 0);
00051 while(tmp[count] != NULL)
00052 {
00053 ++count;
00054 }
00055 dest = g_strndup(path, g_strlen(path)- g_strlen(tmp[count -2]));
00056 g_strfreev(tmp);
00057 };
00058
00059 if (dest != NULL)
00060 {
00061 ws_dbus_notify(data->dbus_data, WS_DBUS_EXTRACT_FILE);
00062 result = decompress_file(path, &dest);
00063 ws_dbus_notify(data->dbus_data, WS_DBUS_EXTRACT_FILE_FINISHED);
00064 };
00065
00066 if (result == 0)
00067 {
00068 ws_dbus_server_return_extracted_dict(data->dbus_data, dest);
00069 }
00070 else
00071 {
00072 dest = "";
00073 ws_dbus_server_return_extracted_dict(data->dbus_data, dest);
00074 }
00075
00076 g_free(path);
00077 path = NULL;
00078 g_debug("<-%s", __FUNCTION__);
00079 }
00080
00081
00087 void ws_mng_load_dict(GArray* dict_directory, WSMngSearchData* data)
00088 {
00089 gint i = 0;
00090 gint j = 0;
00091 Engine* xdxf = NULL;
00092 g_debug("->%s", __FUNCTION__);
00093 EngineOptimizationFlag flag = ENGINE_NO;
00094 gchar* current_directory = NULL;
00095
00096 for (i =0; i<dict_directory->len; i++)
00097 {
00098 current_directory = strdup(g_array_index( dict_directory,
00099 gchar*,
00100 i ));
00101 flag = ENGINE_NO;
00102 for (j=0; j<data->modules->len; j++)
00103 {
00104 if (dict_eng_module_check( g_array_index( data->modules,
00105 EngineModule,
00106 j),
00107 current_directory ) == TRUE)
00108 {
00109
00110 if(ws_mng_if_optimized(current_directory))
00111 {
00112 flag = ENGINE_CREATE;
00113 }
00114
00115
00116 xdxf = dict_eng_module_create_ext(
00117 g_array_index( data->modules,
00118 EngineModule,
00119 j ),
00120 current_directory,
00121 flag,
00122 ws_mng_progress_bar,
00123 data,
00124 0.02 );
00125
00126
00127 dict_eng_set_callback( xdxf,
00128 ENGINE_WORD_LIST_SIGNAL,
00129 ws_mng_on_found_word,
00130 data );
00131
00132 dict_eng_set_callback( xdxf,
00133 ENGINE_WORD_TRANSLATION_SIGNAL,
00134 ws_mng_on_found_translation,
00135 data );
00136
00137
00138 g_array_append_val (data->dict, xdxf);
00139
00140 g_free(current_directory);
00141 current_directory = NULL;
00142 xdxf = NULL;
00143
00144
00145
00146 break;
00147 }
00148 }
00149 }
00150 g_debug("<-%s", __FUNCTION__);
00151 }
00152