[ISF_HAS_FEEDBACK=yes],
[ISF_HAS_FEEDBACK=no])
+# Check package manager
+PKG_CHECK_MODULES(PACKAGE_MANAGER, [capi-appfw-package-manager])
+
if test "$ISF_HAS_VCONF" = "yes"; then
AC_DEFINE(HAVE_VCONF,1,[Have VConf functions.])
fi
isf_panel_efl_SOURCES += minicontrol.cpp
endif
-isf_panel_efl_CXXFLAGS = @EFL_CFLAGS@ @ECOREX_CFLAGS@ @EFL_ASSIST_CFLAGS@ @VCONF_CFLAGS@ @X11_CFLAGS@ @PRIVILEGE_CONTROL_CFLAGS@ @DLOG_CFLAGS@ \
- @MINICONTROL_PROVIDER_CFLAGS@ @NOTIFICATION_CFLAGS@ @TTS_CFLAGS@ @EDBUS_CFLAGS@ @BLUETOOTH_CFLAGS@ @FEEDBACK_CFLAGS@
+isf_panel_efl_CXXFLAGS = @EFL_CFLAGS@ \
+ @EFL_ASSIST_CFLAGS@ \
+ @VCONF_CFLAGS@ \
+ @X11_CFLAGS@ \
+ @PRIVILEGE_CONTROL_CFLAGS@ \
+ @DLOG_CFLAGS@ \
+ @MINICONTROL_PROVIDER_CFLAGS@ \
+ @NOTIFICATION_CFLAGS@ \
+ @TTS_CFLAGS@ \
+ @EDBUS_CFLAGS@ \
+ @BLUETOOTH_CFLAGS@ \
+ @FEEDBACK_CFLAGS@ \
+ @UIGADGET_CFLAGS@ \
+ @PACKAGE_MANAGER_CFLAGS@
isf_panel_efl_LDFLAGS = @EFL_LIBS@ @LTLIBINTL@ -rpath $(libdir) \
@ECOREX_LIBS@ \
@TTS_LIBS@ \
@EDBUS_LIBS@ \
@BLUETOOTH_LIBS@ \
- @FEEDBACK_LIBS@
+ @UIGADGET_LIBS@ \
+ @PACKAGE_MANAGER_LIBS@
isf_panel_efl_LDADD = $(top_builddir)/ism/src/libscim@SCIM_EPOCH@.la
#if HAVE_BLUETOOTH
#include <bluetooth.h>
#endif
+#include <package_manager.h>
using namespace scim;
static Ecore_File_Monitor *_osp_keyboard_ise_em = NULL;
static OSPEmRepository _osp_bin_em;
static OSPEmRepository _osp_info_em;
+static package_manager_h pkgmgr = NULL;
static bool _launch_ise_on_request = false;
static bool _soft_keyboard_launched = false;
static Ecore_Event_Handler *_candidate_show_handler = NULL;
+static HelperInfo remove_helper_info;
+
enum {
EMOJI_IMAGE_WIDTH = 0,
EMOJI_IMAGE_HEIGHT,
return index;
}
+static bool
+app_info_cb (package_info_app_component_type_e comp_type, const char *app_id, void *user_data)
+{
+ HelperInfo *helper_info = (HelperInfo *)user_data;
+ if (!helper_info) return false;
+
+ /* FIXME : need to use generated UUID */
+ helper_info->uuid = String (app_id);
+
+ return true;
+}
+
+static bool get_helper_ise_info (const char *type, const char *package, HelperInfo *helper_info)
+{
+ package_info_h pkg_info;
+ char *pkg_label = NULL;
+ char *pkg_icon_path = NULL;
+ bool result = false;
+
+ if (!type)
+ return false;
+
+ if (strncmp (type, "wgt", 3) != 0)
+ return false;
+
+ package_manager_get_package_info (package, &pkg_info);
+ if (!pkg_info)
+ return false;
+
+ package_info_get_label (pkg_info, &pkg_label);
+ package_info_get_icon (pkg_info, &pkg_icon_path);
+
+ if (pkg_label && (strcasestr (pkg_label, "ime"))) {
+ package_info_foreach_app_from_package (pkg_info, PACKAGE_INFO_UIAPP, app_info_cb, helper_info);
+ helper_info->name = String (pkg_label);
+ helper_info->icon = String (pkg_icon_path);
+ helper_info->option = SCIM_HELPER_STAND_ALONE | SCIM_HELPER_NEED_SCREEN_INFO | SCIM_HELPER_NEED_SPOT_LOCATION_INFO | SCIM_HELPER_AUTO_RESTART;
+
+ if (pkg_label)
+ free (pkg_label);
+
+ if (pkg_icon_path)
+ free (pkg_icon_path);
+
+ result = true;
+ }
+
+ package_info_destroy (pkg_info);
+
+ return result;
+}
+
+static void _package_manager_event_cb (const char *type, const char *package, package_manager_event_type_e event_type, package_manager_event_state_e event_state, int progress, package_manager_error_e error, void *user_data)
+{
+ if (!package || !type) return;
+
+ if (event_type == PACKAGE_MANAGER_EVENT_TYPE_INSTALL ||
+ event_type == PACKAGE_MANAGER_EVENT_TYPE_UPDATE) {
+ HelperInfo helper_info;
+
+ if (event_state != PACKAGE_MANAGER_EVENT_STATE_COMPLETED)
+ return;
+
+ if (get_helper_ise_info (type, package, &helper_info)) {
+ /* update engine list */
+ if (isf_remove_helper_ise (helper_info.uuid.c_str (), _config))
+ LOGD ("remove helper info. uuid : %s\n", helper_info.uuid.c_str ());
+
+ if (isf_add_helper_ise (helper_info, String ("ise-web-helper-agent"))) {
+ LOGD ("add helper info. uuid : %s\n", helper_info.uuid.c_str ());
+ _panel_agent->update_ise_list (_uuids);
+ }
+ }
+ } else if (event_type == PACKAGE_MANAGER_EVENT_TYPE_UNINSTALL) {
+ switch (event_state) {
+ case PACKAGE_MANAGER_EVENT_STATE_STARTED:
+ /* get package information and check whether the type of package is Web IME */
+ /* In COMPLETED status, it is impossible to get the package information,
+ therefore it is necessary to get package information in the START status in advance */
+ if (get_helper_ise_info (type, package, &remove_helper_info)) {
+ LOGD ("'%s' package has been uninstalled", remove_helper_info.name.c_str ());
+ }
+ break;
+ case PACKAGE_MANAGER_EVENT_STATE_COMPLETED:
+ if (remove_helper_info.uuid.length () == 0)
+ return;
+
+ /* update engine list */
+ if (isf_remove_helper_ise (remove_helper_info.uuid.c_str (), _config)) {
+ LOGD ("Completed to remove IME uuid : %s\n", remove_helper_info.uuid.c_str ());
+
+ _panel_agent->update_ise_list (_uuids);
+
+ String uuid = scim_global_config_read (String (SCIM_GLOBAL_CONFIG_DEFAULT_ISE_UUID), _initial_ise_uuid);
+ if (uuid == remove_helper_info.uuid) {
+ /* switching to initial ISE */
+ if (_soft_keyboard_launched) {
+ _panel_agent->hide_helper (uuid);
+ _panel_agent->stop_helper (uuid);
+ _panel_agent->start_helper (_initial_ise_uuid);
+ }
+ }
+ }
+ remove_helper_info.uuid = String ("");
+ break;
+ case PACKAGE_MANAGER_EVENT_STATE_FAILED:
+ remove_helper_info.uuid = String ("");
+ break;
+ default:
+ break;
+ }
+ }
+}
+
/**
* @brief Get ISE module file path.
*
}
_osp_bin_em.clear ();
_osp_info_em.clear ();
+
+ if (pkgmgr) {
+ package_manager_destroy (pkgmgr);
+ pkgmgr = NULL;
+ }
}
/**
}
add_monitor_for_all_osp_modules ();
+
+ if (!pkgmgr) {
+ package_manager_create (&pkgmgr);
+ package_manager_set_event_cb (pkgmgr, _package_manager_event_cb, NULL);
+ }
}
/**
return dst_str;
}
+bool isf_add_helper_ise (HelperInfo helper_info, String module_name)
+{
+ String filename = String (USER_ENGINE_FILE_NAME);
+ FILE *engine_list_file = fopen (filename.c_str (), "a");
+ if (engine_list_file == NULL) {
+ LOGW ("Failed to open %s!!!\n", filename.c_str ());
+ return false;
+ }
+
+ _uuids.push_back (helper_info.uuid);
+ _names.push_back (helper_info.name);
+ _langs.push_back (isf_get_normalized_language ("en_US")); // FIXME
+ _module_names.push_back (module_name);
+ _icons.push_back (helper_info.icon);
+ _modes.push_back (TOOLBAR_HELPER_MODE);
+ _options.push_back (helper_info.option);
+
+ char mode[12];
+ char option[12];
+ snprintf (mode, sizeof (mode), "%d", (int)TOOLBAR_HELPER_MODE);
+ snprintf (option, sizeof (option), "%d", helper_info.option);
+
+ String line = isf_combine_ise_info_string (helper_info.name, helper_info.uuid, module_name, isf_get_normalized_language ("en_US"),
+ helper_info.icon, String (mode), String (option), String (""));
+ if (fputs (line.c_str (), engine_list_file) < 0) {
+ LOGW ("Failed to write (%s)!!!\n", line.c_str ());
+ }
+
+ if (fclose (engine_list_file) != 0)
+ LOGW ("Failed to fclose %s!!!\n", filename.c_str ());
+
+ return true;
+}
+
+bool isf_remove_helper_ise (const char *uuid, const ConfigPointer &config)
+{
+ String filename = String (USER_ENGINE_FILE_NAME);
+ if (isf_remove_ise_info_from_file_by_uuid (filename.c_str (), uuid)) {
+ isf_get_factory_list (ALL_ISE, config, _uuids, _names, _module_names, _langs, _icons, _modes, _options);
+
+ /* Update _groups */
+ _groups.clear ();
+ std::vector<String> ise_langs;
+ for (size_t i = 0; i < _uuids.size (); ++i) {
+ scim_split_string_list (ise_langs, _langs[i]);
+ for (size_t j = 0; j < ise_langs.size (); j++) {
+ if (std::find (_groups[ise_langs[j]].begin (), _groups[ise_langs[j]].end (), i) == _groups[ise_langs[j]].end ())
+ _groups[ise_langs[j]].push_back (i);
+ }
+ ise_langs.clear ();
+ }
+ return true;
+ } else {
+ LOGW ("Failed to remove uuid : %s from cache file : %s!!!", uuid, filename.c_str ());
+ return false;
+ }
+}
+
+
/*
vi:ts=4:nowrap:ai:expandtab
*/
bool isf_update_ise_list (LOAD_ISE_TYPE type, const ConfigPointer &config);
bool isf_update_ise_module (const String strModulePath, const ConfigPointer &config);
String isf_get_normalized_language (String src_str);
+bool isf_add_helper_ise (HelperInfo helper_info, String module_name);
+bool isf_remove_helper_ise (const char *uuid, const ConfigPointer &config);
#endif /* __ISF_PANEL_UTILITY_H */
}
}
+static void remove_ise_info_from_list_by_uuid (std::vector<ISEINFO> &info_list, const char *uuid)
+{
+ if (uuid == NULL)
+ return;
+
+ std::vector<ISEINFO>::iterator iter;
+ while (info_list.size () > 0) {
+ for (iter = info_list.begin (); iter != info_list.end (); iter++) {
+ if (iter->uuid == uuid)
+ break;
+ }
+
+ if (iter != info_list.end ())
+ info_list.erase (iter);
+ else
+ break;
+ }
+}
+
EAPI bool isf_add_keyboard_info_to_file (const char *filename, const char *module_name, const ConfigPointer &config)
{
std::vector<ISEINFO> info_list;
return false;
}
+EAPI bool isf_remove_ise_info_from_file_by_uuid (const char *filename, const char *uuid)
+{
+ std::vector<ISEINFO> info_list;
+ std::vector<ISEINFO>::iterator iter;
+
+ if (isf_read_ise_info_list (filename, info_list)) {
+
+ remove_ise_info_from_list_by_uuid (info_list, uuid);
+
+ return isf_write_ise_info_list (filename, info_list);
+ }
+ return false;
+}
+
EAPI void isf_update_ise_info_to_file (const char *filename, const ConfigPointer &config)
{
if (filename == NULL)
EAPI bool isf_add_keyboard_info_to_file (const char *filename, const char *module_name, const ConfigPointer &config);
EAPI bool isf_add_helper_info_to_file (const char *filename, const char *module_name);
EAPI bool isf_remove_ise_info_from_file (const char *filename, const char *module_name);
+EAPI bool isf_remove_ise_info_from_file_by_uuid (const char *filename, const char *uuid);
EAPI void isf_update_ise_info_to_file (const char *filename, const ConfigPointer &config);
#endif /* __ISF_QUERY_UTILITY_H */
BuildRequires: efl-assist-devel
BuildRequires: pkgconfig(ail)
BuildRequires: pkgconfig(libtzplatform-config)
+BuildRequires: capi-appfw-package-manager-devel
Requires(post): /sbin/ldconfig /usr/bin/vconftool
Requires(postun): /sbin/ldconfig