00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00025 #include <ws_mng_bookmarks_utils.h>
00026
00033 void ws_mng_add_bookmark(GError *error, GArray* param, gpointer user_data)
00034 {
00035 g_debug("->%s", __FUNCTION__);
00036
00037 WSMngSearchData* data = (WSMngSearchData *) user_data;
00038 osso_rpc_t* osso_data = NULL;
00039 osso_rpc_t* osso_data_trans = NULL;
00040 gchar* word = NULL;
00041 gchar* translation = NULL;
00042
00043 if (data->bookmark != NULL)
00044 {
00045
00046 osso_data = &g_array_index (param, osso_rpc_t, 0);
00047 word = g_strdup(osso_data->value.s);
00048 osso_data_trans = &g_array_index (param, osso_rpc_t, 1);
00049 translation = g_strdup(osso_data_trans->value.s);
00050
00051
00052 gboolean is_added = dict_eng_add_word( data->bookmark,
00053 word,
00054 translation );
00055 if (is_added == TRUE)
00056 {
00057 ws_dbus_notify( data->dbus_data,
00058 WS_DBUS_BOOKMARKS_ADDED_OK );
00059 }
00060 else
00061 {
00062 ws_dbus_notify( data->dbus_data,
00063 WS_DBUS_BOOKMARKS_ADDED_FAIL );
00064 }
00065
00066 osso_rpc_free_val(osso_data);
00067 g_free(translation);
00068 g_free(word);
00069 }
00070 else
00071 {
00072 ws_dbus_notify( data->dbus_data,
00073 WS_DBUS_BOOKMARKS_ADDED_FAIL );
00074 g_debug("-> %s - there is no bookmark engine!\n", __FUNCTION__);
00075 }
00076
00077 g_debug("<-%s", __FUNCTION__);
00078 }
00079
00086 void ws_mng_remove_bookmark(GError *error, GArray* param, gpointer user_data)
00087 {
00088 g_debug("->%s", __FUNCTION__);
00089
00090 WSMngSearchData* data = (WSMngSearchData *) user_data;
00091 osso_rpc_t* osso_data = NULL;
00092 gchar* word = NULL;
00093
00094 if (data->bookmark != NULL)
00095 {
00096
00097 osso_data = &g_array_index(param, osso_rpc_t, 0);
00098 word = g_strdup(osso_data->value.s);
00099
00100 gboolean is_remove = dict_eng_remove_word( data->bookmark,
00101 word );
00102 if (TRUE == is_remove)
00103 {
00104 ws_dbus_notify( data->dbus_data,
00105 WS_DBUS_BOOKMARKS_REMOVED_OK );
00106 }
00107 else
00108 {
00109 ws_dbus_notify( data->dbus_data,
00110 WS_DBUS_BOOKMARKS_REMOVED_FAIL );
00111 }
00112
00113 osso_rpc_free_val(osso_data);
00114 }
00115 else
00116 {
00117 ws_dbus_notify( data->dbus_data,
00118 WS_DBUS_BOOKMARKS_ADDED_FAIL );
00119 g_debug("-> %s - there is no bookmark engine!\n", __FUNCTION__);
00120 }
00121
00122 g_debug("<-%s", __FUNCTION__);
00123 }
00124
00125
00130 void ws_mng_load_bookmark(WSMngSearchData* data)
00131 {
00132 g_debug("->%s", __FUNCTION__);
00133 guint i = 0;
00134 data->bookmark = NULL;
00135 gchar* current_directory = ws_mng_get_boomark_location();
00136
00137 if (NULL != current_directory)
00138 {
00139 for (i = 0; i < data->modules->len; ++i)
00140 {
00141
00142
00143 if (TRUE == dict_eng_module_check(
00144 g_array_index(data->modules, EngineModule, i),
00145 current_directory ))
00146 {
00147
00148 data->bookmark =
00149 dict_eng_module_create_ext(
00150 g_array_index(data->modules,
00151 EngineModule,
00152 i),
00153 current_directory,
00154 ENGINE_CREATE,
00155 ws_mng_progress_bar,
00156 data,
00157 0.02 );
00158
00159 dict_eng_set_callback( data->bookmark,
00160 ENGINE_WORD_LIST_SIGNAL,
00161 ws_mng_on_found_word,
00162 data );
00163 dict_eng_set_callback(data->bookmark,
00164 ENGINE_WORD_TRANSLATION_SIGNAL,
00165 ws_mng_on_found_translation,
00166 data);
00167
00168 break;
00169 }
00170 }
00171 g_free(current_directory);
00172 }
00173 g_debug("<-%s", __FUNCTION__);
00174 }
00175
00176