ADD_DEFINITIONS("-DWAYLAND")
ENDIF(with_wayland)
-pkg_check_modules(libpkgs REQUIRED aul dlog bundle sqlite3 glib-2.0 dbus-glib-1 libtzplatform-config)
+pkg_check_modules(libpkgs REQUIRED aul dlog bundle sqlite3 glib-2.0 gio-2.0 libtzplatform-config)
FOREACH(flag ${libpkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
SET(CMAKE_SKIP_BUILD_RPATH true)
-# Get uname value to set 'TARGET' definition
+# Get uname value to set 'TARGET' definition
# TODO: Is this needed?
FIND_PROGRAM(UNAME NAMES uname)
EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
#define _E(fmt, arg...) LOGE(fmt,##arg)
#define _D(fmt, arg...) LOGD(fmt,##arg)
+#define _I(fmt, arg...) LOGI(fmt,##arg)
#define SYSPOPUP_DBUS_PATH "/syspopup/dbus_handler"
#define SYSPOPUP_DBUS_SIGNAL_INTERFACE "org.tizen.syspopup.signal"
/**
* @mainpage
- *
- * This is System Popup Library
+ *
+ * This is System Popup Library
* This library help to create system popup application & to launch/destroy system popup application
*
*/
/**
* @close
* @ingroup APPLICATION_FRAMEWORK
- * @defgroup syspopup System Popup Library
+ * @defgroup syspopup System Popup Library
* @{
*/
/**
- * @file syspopup.h
+ * @file syspopup.h
* @brief System Popup UI Library
*
* Patched by Knhoon Baik <knhoon.baik@samsung.com>
- * Patched by Noha Park <noha.park@samsung.com>
+ * Patched by Noha Park <noha.park@samsung.com>
*/
/**
* @defgroup syspopup_ui Helper Library to create system popup application
- * @ingroup syspopup
+ * @ingroup syspopup
* @brief Helper Library to create system popup application
*/
* @{
*/
-/**
- *@brief action handler supplied by user
+/**
+ * @brief action handler supplied by user
* def_term_fn is called when event to destroy all system popup occur
* def_timeout_fn is called when the system popup's timeout is expired
*/
/**
* @brief This API make elm system popup window
*
- * This API make elm system popup window.
+ * This API make elm system popup window.
* and then, make given elm system popup window as system popup type
* and set system popup properties based on system popup information DB.\n
* system popup properties to be set : timeout, default action type, ....
int syspopup_reset(bundle *b);
/**
- * @brief This API ask that the system popup is created and is running
+ * @brief This API ask that the system popup is created and is running
*
- * This API ask that the the system popup with popup name is created and is running after extracting popup name from given bundle.
+ * This API ask that the the system popup with popup name is created and is running after extracting popup name from given bundle.
*
* @param[in] b bundle received by app_reset handler (included system popup name)
- * @return true / false
+ * @return true / false
* @retval 1 app already has the system popup
* @retval 0 app has not the system popup
*/
/** @} */
#endif
-
#endif
/**
- * @file syspopup_caller.h
+ * @file syspopup_caller.h
* @brief Library to launch/destroy System Popup Application
*
* Patched by Knhoon Baik <knhoon.baik@samsung.com>
- * Patched by Noha Park <noha.park@samsung.com>
+ * Patched by Noha Park <noha.park@samsung.com>
*/
/**
* @defgroup syspopup_caller Helper Library to launch/destroy system popup application
- * @ingroup syspopup
+ * @ingroup syspopup
* @brief Helper Library to launch/destroy system popup application
*/
* And then, launch found application package
*
* @param[in] popup_name system popup application name to launch (not package name)
- * @param[in] b extra bundle(arguement) to toss the popup application
+ * @param[in] b extra bundle(arguement) to toss the popup application
* @return 0 if success, negative value(<0) if fail
* @retval 0 - success
* @retval -1 - generic error
* @retval 0 - success
* @retval -1 - generic error
*/
-int syspopup_destroy_all();
+int syspopup_destroy_all(void);
/** @} */
#endif
#endif
-
#include "syspopup_db.h"
#define SYSPOPUP_DEFAULT_TIMEOUT 20 /* sec */
-#define SYSPOPUP_TERM_NOTI_PATH "/usr/share/popup_noti_term"
struct _syspopup {
int id;
typedef struct _syspopup syspopup;
-syspopup *_syspopup_get_head();
+syspopup *_syspopup_get_head(void);
int _syspopup_add_new(syspopup *pinfo);
syspopup *_syspopup_find(const char *name);
syspopup *_syspopup_find_by_id(int id);
void _syspopup_info_free(syspopup_info_t *pinfo);
#endif
-
BuildRequires: pkgconfig(sqlite3)
BuildRequires: pkgconfig(bundle)
BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(dbus-glib-1)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(gio-2.0)
%if %{with x}
BuildRequires: pkgconfig(utilX)
BuildRequires: pkgconfig(x11)
%description
syspopup package for popup
-
%package devel
Summary: Syspopup development package
Group: System/Libraries
%description caller-devel
syspopup-caller development package for popup
-
%prep
%setup -q
sed -i %{SOURCE1001} -e "s|TZ_SYS_DB|%TZ_SYS_DB|g"
#include <glib.h>
#include <stdlib.h>
#include <string.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib-lowlevel.h>
#include <sys/types.h>
#include <grp.h>
+#include <gio/gio.h>
+#include <bundle_internal.h>
/* For multi-user support */
#include <tzplatform_config.h>
static syspopup *syspopup_head = NULL;
static int initialized = 0;
-static DBusConnection *bus;
-static int noti_fd = -1;
static int sp_id = 0;
-static void (*_term_handler) (void *data);
-static gboolean(*_timeout_handler) (void *data);
+static void (*_term_handler)(void *data);
+static gboolean (*_timeout_handler)(void *data);
-syspopup *_syspopup_get_head()
+syspopup *_syspopup_get_head(void)
{
return syspopup_head;
}
syspopup *_syspopup_find(const char *name)
{
syspopup *tmp;
+
tmp = syspopup_head;
while (tmp) {
if (tmp->name) {
if (strcmp(tmp->name, name) == 0)
return tmp;
}
+
tmp = tmp->next;
}
+
return NULL;
}
syspopup *_syspopup_find_by_id(int id)
{
syspopup *tmp;
+
tmp = syspopup_head;
while (tmp) {
if (tmp->id == id)
return tmp;
+
tmp = tmp->next;
}
+
return NULL;
}
{
if (sp->name != NULL)
free(sp->name);
+
if (sp->dupped_bundle != NULL)
bundle_free(sp->dupped_bundle);
+
free(sp);
}
__syspopup_free(target);
return;
}
+
tmp = tmp->next;
}
}
-
-static DBusHandlerResult
-__sys_popup_dbus_signal_filter(DBusConnection *conn, DBusMessage *message,
- void *user_data)
+static void __syspopup_dbus_signal_filter(GDBusConnection *conn,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
{
- const char *sender;
- const char *interface;
- int dead_pid;
-
- DBusError error;
- dbus_error_init(&error);
-
- interface = dbus_message_get_interface(message);
- if (interface == NULL) {
- _E("reject by security issue - no interface\n");
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- }
-
- if (dbus_message_is_signal(message, interface,
- SYSPOPUP_DBUS_SP_TERM_SIGNAL)) {
+ if (signal_name
+ && strcmp(signal_name, SYSPOPUP_DBUS_SP_TERM_SIGNAL) == 0) {
if (_term_handler)
_term_handler(NULL);
_D("term handler has been called");
}
-
- return DBUS_HANDLER_RESULT_HANDLED;
}
-
-
-int _syspopup_init(void (*term_handler) (void *),
- gboolean(*timeout_handler) (void *))
+int _syspopup_init(void (*term_handler)(void *),
+ gboolean (*timeout_handler)(void *))
{
- DBusError error;
- char rule[MAX_LOCAL_BUFSZ];
+ GDBusConnection *conn = NULL;
+ GError *err = NULL;
+ guint conn_subsc_id;
if (initialized)
return 0;
+#if !(GLIB_CHECK_VERSION(2, 36, 0))
+ g_type_init();
+#endif
+
_term_handler = term_handler;
_timeout_handler = timeout_handler;
- dbus_error_init(&error);
- bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
- if (!bus) {
- _E("Failed to connect to the D-BUS daemon: %s", error.message);
- dbus_error_free(&error);
- return -1;
- }
- dbus_connection_setup_with_g_main(bus, NULL);
-
- snprintf(rule, MAX_LOCAL_BUFSZ,
- "path='%s',type='signal',interface='%s'", SYSPOPUP_DBUS_PATH,
- SYSPOPUP_DBUS_SIGNAL_INTERFACE);
- /* listening to messages */
- dbus_bus_add_match(bus, rule, &error);
- if (dbus_error_is_set(&error)) {
- _E("Fail to rule set: %s", error.message);
- dbus_error_free(&error);
+ conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+ if (err) {
+ _E("gdbus connection error (%s)", err->message);
+ g_error_free(err);
return -1;
}
- if (dbus_connection_add_filter(bus,
- __sys_popup_dbus_signal_filter, NULL, NULL) == FALSE)
+ /* Add a fileter for signal */
+ conn_subsc_id = g_dbus_connection_signal_subscribe(conn,
+ NULL,
+ SYSPOPUP_DBUS_SIGNAL_INTERFACE,
+ NULL,
+ SYSPOPUP_DBUS_PATH,
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ __syspopup_dbus_signal_filter,
+ NULL,
+ NULL);
+ if (conn_subsc_id == 0) {
+ _E("Error in subscribing to the signal");
return -1;
+ }
_D("syspopup signal initialized");
-
initialized = 1;
+
return 0;
}
_E("no initialized");
return -1;
}
+
if (sp == NULL) {
_E("syspopup is NULL");
return -1;
}
+
if (info == NULL) {
_E("syspopup info is NULL");
return -1;
if (sp->timeout_id != 0)
g_source_remove(sp->timeout_id);
- if(info->timeout > 0) {
- sp->timeout_id = g_timeout_add_seconds(info->timeout, _timeout_handler,
- (void *)sp->id);
- _D("add timeout - timeout : id=%d,timeout=%d(sec)", sp->id,
- info->timeout);
+ if (info->timeout > 0) {
+ sp->timeout_id = g_timeout_add_seconds(info->timeout,
+ _timeout_handler, (void *)sp->id);
+ _D("add timeout - timeout : id=%d,timeout=%d(sec)",
+ sp->id, info->timeout);
}
return 0;
{
const char *name;
- if (getuid() != 0 && getuid() != tzplatform_getuid(TZ_USER_NAME)) {
- _E("syspopup permission error");
+ if (b == NULL) {
+ _E("bundle is NULL");
return NULL;
}
- if (b == NULL) {
- _E("bundle is NULL");
+ if (getuid() != 0 && getuid() != tzplatform_getuid(TZ_USER_NAME)) {
+ _E("syspopup permission error");
return NULL;
}
name = bundle_get_val(b, SYSPOPUP_NAME);
- if (name == NULL) {
+ if (name == NULL)
_E("this is no bundle for syspopup");
- }
+
return name;
}
int _syspopup_set_name_to_bundle(bundle *b, char *popup_name)
{
- if ((b == NULL) || (popup_name == NULL))
+ if (b == NULL || popup_name == NULL)
return -1;
+
bundle_add(b, SYSPOPUP_NAME, popup_name);
+
return 0;
}
-
#include "simple_util.h"
#define SYSPOPUP_DB_PATH tzplatform_mkpath(TZ_SYS_DB, ".syspopup.db")
-#define QUERY_MAXLEN 4096
+#define QUERY_MAXLEN 4096
-#define SP_INFO_TBL "syspopup_info"
-#define SP_INFO_TBL_F_NAME "name"
+#define SP_INFO_TBL "syspopup_info"
+#define SP_INFO_TBL_F_NAME "name"
static sqlite3 *db = NULL;
/**
- * exec
- * param[in] db handler
- * param[in] query query
- * return This method returns 0 (SUCCESS) or -1 (FAIL)
- */
-static int __exec(sqlite3 *db, char *query)
-{
- int rc = 0;
- char *errmsg = NULL;
-
- if (db == NULL) {
- _E("DB handler is null");
- return -1;
- }
- rc = sqlite3_exec(db, query, NULL, 0, &errmsg);
-
- if (rc != SQLITE_OK) {
- _D("Query: [%s]", query);
- _E("SQL error: %s\n", errmsg);
- sqlite3_free(errmsg);
- return (-1);
- }
-
- return 0;
-}
-
-/**
- * db initialize
- */
+ * * db initialize
+ * */
static int __init(void)
{
int rc;
}
rc = sqlite3_open(SYSPOPUP_DB_PATH, &db);
- if (rc) {
- _E("Can't open database: %s", sqlite3_errmsg(db));
- goto err;
- }
- /* Enable persist journal mode*/
- rc = sqlite3_exec(db, "PRAGMA journal_mode = PERSIST", NULL, NULL,
- NULL);
- if (SQLITE_OK != rc) {
- _D("Fail to change journal mode\n");
- goto err;
+ if (rc != SQLITE_OK) {
+ _E("Can't open database: %s / %d / %d", sqlite3_errmsg(db),
+ rc, sqlite3_extended_errcode(db));
+ return -1;
+ } else {
+ _D("db open sucess");
}
return 0;
-err:
- sqlite3_close(db);
- return -1;
}
static int __fini(void)
sqlite3_close(db);
db = NULL;
}
- return 0;
-}
-
-static int __delete_all(const char *tbl_name)
-{
- char *_sqlbuf;
- int rc;
- _sqlbuf = sqlite3_mprintf("DELETE FROM %s;", tbl_name);
- rc = __exec(db, _sqlbuf);
- sqlite3_free(_sqlbuf);
-
- return rc;
-}
-
-static int __delete_with_field(const char *tbl_name, const char *f_name,
- const char *val)
-{
- char *_sqlbuf;
- int rc;
-
- _sqlbuf = sqlite3_mprintf("DELETE FROM %s WHERE %s = '%s';",
- tbl_name, f_name, val);
- rc = __exec(db, _sqlbuf);
- sqlite3_free(_sqlbuf);
-
- return rc;
+ return 0;
}
-static int __count_with_field(const char *tbl_name, const char *f_name,
- const char *val)
+syspopup_info_t *_syspopup_info_get(const char *popup_name)
{
- char *_sqlbuf;
int rc;
- char **db_result = NULL;
- char *db_err = NULL;
- int nrows = 0;
- int ncols = 0;
- int cnt;
-
- _sqlbuf = sqlite3_mprintf("SELECT COUNT(*) FROM %s WHERE %s = '%s';",
- tbl_name, f_name, val);
-
- rc = sqlite3_get_table(db, _sqlbuf, &db_result, &nrows, &ncols,
- &db_err);
- if (rc == -1 || nrows == 0) {
- _E("get count = 0 or fail");
- sqlite3_free_table(db_result);
- sqlite3_free(_sqlbuf);
- return 0;
- } else {
- cnt = atoi(db_result[1]);
- sqlite3_free_table(db_result);
- sqlite3_free(_sqlbuf);
- }
-
- return cnt;
-}
-
-int _syspopup_info_add(syspopup_info_t *pinfo)
-{
- int rc = -1;
- int cnt = 0;
- char *_sqlbuf;
+ char sqlbuf[256] = {0,};
+ sqlite3_stmt *stmt = NULL;
+ syspopup_info_t *pinfo = NULL;
- if (pinfo->name == NULL) {
- _E("Name is null\n");
- return -1;
+ if (popup_name == NULL) {
+ _E("no popup name");
+ return NULL;
}
if (__init() < 0)
- return -1;
+ return NULL;
- cnt = __count_with_field(SP_INFO_TBL, SP_INFO_TBL_F_NAME, pinfo->name);
+ snprintf(sqlbuf, sizeof(sqlbuf),
+ "SELECT name,prio,focus,timeout,term_act,endkey_act,pkgname FROM %s WHERE %s = ?;",
+ SP_INFO_TBL, SP_INFO_TBL_F_NAME);
- if (cnt == 0) {
- _sqlbuf = sqlite3_mprintf("INSERT INTO %s "
- "(name,prio,focus,timeout,term_act,endkey_act,pkgname) values "
- "(\"%s\", %d, %d, %d, \"%s\");",
- SP_INFO_TBL,
- pinfo->name, pinfo->prio,
- pinfo->focus, pinfo->timeout,
- pinfo->term_act, pinfo->endkey_act,
- pinfo->pkgname);
- rc = __exec(db, _sqlbuf);
- sqlite3_free(_sqlbuf);
- } else {
- _E("already exist - %s", pinfo->name);
- rc = -1;
+ rc = sqlite3_prepare_v2(db, sqlbuf, -1, &stmt, NULL);
+ if (rc != SQLITE_OK) {
+ _E("popup info prepare error(%d)", rc);
+ goto out;
}
- if (rc < 0)
- _E("Fail to insert\n");
-
- __fini();
- return rc;
-}
-
-syspopup_info_t *_syspopup_info_get(const char *popup_name)
-{
- int rc = 0;
- char *_sqlbuf;
- sqlite3_stmt *stmt;
- syspopup_info_t *pinfo = NULL;
+ rc = sqlite3_bind_text(stmt, 1, popup_name, strlen(popup_name), SQLITE_STATIC);
+ if (rc != SQLITE_OK) {
+ _E("popup name bind error(%d)", rc);
+ goto out;
+ }
- if (popup_name == NULL) {
- _E("no popup name");
- return NULL;
+ rc = sqlite3_step(stmt);
+ if (rc != SQLITE_ROW) {
+ _E("error(%d) in prepare", rc);
+ goto out;
}
- if (__init() < 0)
- return NULL;
+ pinfo = (syspopup_info_t *)malloc(sizeof(syspopup_info_t));
+ if (pinfo == NULL) {
+ _E("malloc error");
+ goto out;
+ }
- _sqlbuf = sqlite3_mprintf("SELECT name,prio,focus,timeout,term_act,endkey_act,pkgname "
- "FROM %s WHERE %s='%s';",
- SP_INFO_TBL, SP_INFO_TBL_F_NAME, popup_name);
+ pinfo->name = strdup((char *)sqlite3_column_text(stmt, 0));
+ pinfo->prio = sqlite3_column_int(stmt, 1);
+ pinfo->focus = sqlite3_column_int(stmt, 2);
+ pinfo->timeout = sqlite3_column_int(stmt, 3);
+ pinfo->term_act = sqlite3_column_int(stmt, 4);
+ pinfo->endkey_act = sqlite3_column_int(stmt, 5);
- rc = sqlite3_prepare_v2(db, _sqlbuf, -1, &stmt, NULL);
- if (rc == SQLITE_OK) {
- rc = sqlite3_step(stmt);
- if (rc == SQLITE_ROW) {
- pinfo = (syspopup_info_t *) malloc(sizeof(syspopup_info_t));
- if (pinfo == NULL) {
- __fini();
- return NULL;
- }
- pinfo->name = strdup((char *) sqlite3_column_text(stmt, 0));
- pinfo->prio = sqlite3_column_int(stmt, 1);
- pinfo->focus = sqlite3_column_int(stmt, 2);
- pinfo->timeout = sqlite3_column_int(stmt, 3);
- pinfo->term_act = sqlite3_column_int(stmt, 4);
- pinfo->endkey_act = sqlite3_column_int(stmt, 5);
- if (sqlite3_column_text(stmt, 6) != NULL)
- pinfo->pkgname = strdup((char *) sqlite3_column_text(stmt, 6));
- else
- pinfo->pkgname = NULL;
- }
- sqlite3_finalize(stmt);
- }
+ if (sqlite3_column_text(stmt, 6) != NULL)
+ pinfo->pkgname = strdup((char *) sqlite3_column_text(stmt, 6));
+ else
+ pinfo->pkgname = NULL;
- sqlite3_free(_sqlbuf);
+out:
+ sqlite3_finalize(stmt);
__fini();
+
return pinfo;
}
{
if (pinfo->name)
free(pinfo->name);
+
if (pinfo->pkgname)
free(pinfo->pkgname);
+
free(pinfo);
}
-
# Set required packages
INCLUDE(FindPkgConfig)
-pkg_check_modules(spcpkgs REQUIRED dlog bundle sqlite3 glib-2.0 aul dbus-glib-1 libtzplatform-config)
+pkg_check_modules(spcpkgs REQUIRED dlog bundle sqlite3 glib-2.0 gio-2.0 aul libtzplatform-config)
FOREACH(flag ${spcpkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
#include <sys/stat.h>
#include <fcntl.h>
#include <glib.h>
-#include <dbus/dbus.h>
+#include <gio/gio.h>
#include <aul.h>
#include "syspopup_core.h"
}
ret = aul_launch_app(info->pkgname, b);
- if (ret < 0) {
- _E("aul launch error - %d", ret);
- }
+ if (ret < 0)
+ _E("aul launch error: %d", ret);
- if (is_bundle == 1) {
+ if (is_bundle == 1)
bundle_free(b);
- }
_syspopup_info_free(info);
return ret;
}
-API int syspopup_destroy_all()
+API int syspopup_destroy_all(void)
{
- DBusMessage *message;
- DBusError error;
- DBusConnection *bus = NULL;
-
- dbus_error_init(&error);
- bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
- if (bus == NULL) {
- _E("Failed to connect to the D-BUS daemon: %s", error.message);
- dbus_error_free(&error);
+ GDBusConnection *conn = NULL;
+ GError *err = NULL;
+ int ret = 0;
+
+#if !(GLIB_CHECK_VERSION(2, 36, 0))
+ g_type_init();
+#endif
+
+ conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+ if (err) {
+ _E("gdbus connection error: %s", err->message);
+ g_error_free(err);
return -1;
}
- message = dbus_message_new_signal(SYSPOPUP_DBUS_PATH,
- SYSPOPUP_DBUS_SIGNAL_INTERFACE,
- SYSPOPUP_DBUS_SP_TERM_SIGNAL);
-
- if (dbus_connection_send(bus, message, NULL) == FALSE) {
- _E("dbus send error");
- return -1;
+ if (g_dbus_connection_emit_signal(conn,
+ NULL,
+ SYSPOPUP_DBUS_PATH,
+ SYSPOPUP_DBUS_SIGNAL_INTERFACE,
+ SYSPOPUP_DBUS_SP_TERM_SIGNAL,
+ NULL,
+ &err) == FALSE) {
+ _E("emitting the signal error: %s", err->message);
+ ret = -1;
+ } else {
+ _D("send signal done");
}
- dbus_connection_flush(bus);
- dbus_message_unref(message);
+ if (err)
+ g_error_free(err);
+ if (conn)
+ g_object_unref(conn);
- dbus_connection_close(bus);
-
- _D("send signal done\n");
-
- return 0;
+ return ret;
}
-
# Set required packages
INCLUDE(FindPkgConfig)
-SET(APPSVC_SPPPGS_CHECK_MODULES "dlog bundle sqlite3 glib-2.0 evas elementary ecore ecore-input dbus-glib-1 libtzplatform-config")
+SET(APPSVC_SPPPGS_CHECK_MODULES "dlog bundle sqlite3 glib-2.0 gio-2.0 evas elementary ecore ecore-input libtzplatform-config")
IF (with_wayland)
pkg_check_modules(sppkgs REQUIRED ${APPSVC_SPPPGS_CHECK_MODULES})
INSTALL(TARGETS syspopup DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../include/syspopup.h DESTINATION include)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/syspopup.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-
#ifndef WAYLAND
#include <X11/Xatom.h>
#include <X11/Xutil.h>
+#include <Ecore_X.h>
#endif
#define WIN_PROP_NAME "SYSTEM_POPUP"
else {
if (num_ret < len)
len = num_ret;
+
for (i = 0; i < len; i++) {
val[i] = ((unsigned long *)prop_ret)[i];
}
+
num = len;
}
}
#endif
-/*
-static Window get_active_win(Display *dpy, Window win, Atom property)
-{
- Window active_win = None;
- Atom actual_type;
- int actual_format;
- unsigned long nitems, bytes_after;
- unsigned char *prop_return = NULL;
-
- if(Success == XGetWindowProperty(dpy, win, property, 0L, sizeof(Window),
- False, XA_WINDOW, &actual_type,
- &actual_format, &nitems, &bytes_after,
- &prop_return) && prop_return) {
- active_win = *(Window *)prop_return;
- XFree(prop_return);
- }
-
- return active_win;
-}
-*/
-
+#ifndef WAYLAND
static void __X_syspopup_term_handler(void *data)
{
-#ifndef WAYLAND
syspopup *tmp;
syspopup *next;
Display *d;
_D("enter syspopup term handler");
d = XOpenDisplay(NULL);
+
tmp = _syspopup_get_head();
while (tmp) {
-
_D("term action %d - %s", tmp->term_act, tmp->name);
next = tmp->next;
switch (tmp->term_act) {
case SYSPOPUP_TERM:
- win = (Window) tmp->internal_data;
+ win = (Window)tmp->internal_data;
if (tmp->def_term_fn != NULL)
tmp->def_term_fn(tmp->dupped_bundle,
tmp->user_data);
+
XKillClient(d, win);
- /*XDestroyWindow(d, win);*/
- /* TODO :modify for multi popup */
break;
case SYSPOPUP_HIDE:
- win = (Window) tmp->internal_data;
+ win = (Window)tmp->internal_data;
if (tmp->def_term_fn != NULL)
tmp->def_term_fn(tmp->dupped_bundle,
XUnmapWindow(d, win);
break;
default:
- _D("term action IGNORED - %s", tmp->name);
+ _D("term action IGNORED: %s", tmp->name);
}
+
tmp = next;
}
XCloseDisplay(d);
- /*TODO : if there is no popup window, kill client*/
-#endif
}
+#endif
+#ifndef WAYLAND
static gboolean __X_syspopup_timeout_handler(void *user_data)
{
-#ifndef WAYLAND
syspopup *sp = NULL;
Display *d;
int id;
_D("find timeout - %s", sp->name);
if (sp->def_timeout_fn != NULL)
sp->def_timeout_fn(sp->dupped_bundle, sp->user_data);
- win = (Window) sp->internal_data;
+
+ win = (Window)sp->internal_data;
XKillClient(d, win);
} else {
_E("no find timeout");
}
XCloseDisplay(d);
-#endif
return 0;
}
+#endif
#ifndef WAYLAND
static int __X_syspopup_change_xwin_type(Display *dpy, Window win)
XWMHints *hints;
hints = XAllocWMHints();
- if (!hints) return -1;
+ if (hints == NULL)
+ return -1;
hints->flags = InputHint | StateHint;
hints->input = 0;
int rotation = -1;
int ret;
- int angles[2];
-
Atom atom_active_win;
Atom atom_win_rotate_angle;
ret = __utilx_ss_get_window_property(dpy, root_win, atom_active_win,
XA_WINDOW,
(unsigned int *)&active_win, 1);
-
- /*printf("[SYSPOPUP] Active win : %x, Window %x\n", active_win, win);*/
-
- /*active_win = get_active_win(dpy, root_win, atom_active_win);*/
if (ret < 0)
return ret;
- atom_win_rotate_angle =
- XInternAtom(dpy, "_E_ILLUME_ROTATE_ROOT_ANGLE", False);
+ atom_win_rotate_angle = XInternAtom(dpy,
+ "_E_ILLUME_ROTATE_ROOT_ANGLE", False);
ret = __utilx_ss_get_window_property(dpy, root_win,
atom_win_rotate_angle, XA_CARDINAL,
(unsigned int *)&rotation, 1);
-
- /*printf("[SYSPOPUP] Rotation %d\n", rotation);*/
-
if (ret != -1)
return rotation;
_D("key press - %s", keyname);
- if ((strcmp(keyname, KEY_END) == 0) ||
- (strcmp(keyname, "Escape") == 0))
- {
+ if (strcmp(keyname, KEY_END) == 0) {
d = XOpenDisplay(NULL);
sp = _syspopup_find_by_id(id);
if (sp != NULL) {
- _D("find - %s / endkey_act - %d", sp->name, sp->endkey_act);
+ _D("find key down: %s", sp->name);
if (sp->endkey_act == SYSPOPUP_KEYEND_TERM) {
if (sp->def_term_fn != NULL)
sp->def_term_fn(sp->dupped_bundle,
sp->user_data);
+
win = (Window) sp->internal_data;
XKillClient(d, win);
-
} else if (sp->endkey_act == SYSPOPUP_KEYEND_HIDE) {
if (sp->def_term_fn != NULL)
sp->def_term_fn(sp->dupped_bundle,
sp->user_data);
+
win = (Window) sp->internal_data;
XUnmapWindow(d, win);
}
return 0;
}
#else
+#ifndef WAYLAND
static void __efl_rotation_set(Evas_Object* win, Ecore_X_Window xwin)
{
ecore_x_icccm_name_class_set(xwin, WIN_PROP_NAME, WIN_PROP_NAME);
}
}
#endif
+#endif
#ifndef WAYLAND
int X_make_syspopup(bundle *b, Display *dpy, Window xwin, void *win,
if (sp->dupped_bundle)
free(sp->dupped_bundle);
+
sp->dupped_bundle = bundle_dup(b);
- d = XOpenDisplay(NULL);
- win = (Window) sp->internal_data;
- utilx_set_system_notification_level(d, win, info->prio);
+ do {
+ d = XOpenDisplay(NULL);
+ if (d == NULL)
+ break;
- if (info->focus == 1) {
- __X_syspopup_disable_focus (d, win);
- }
+ win = (Window)sp->internal_data;
+ if (win == NULL)
+ break;
+
+ utilx_set_system_notification_level(d, win, info->prio);
+
+ if (info->focus == 1)
+ __X_syspopup_disable_focus (d, win);
#ifdef ROTATE_USING_X_CLIENT
- int (*rotate_func) (Display *, Window, syspopup *);
- rotate_func = sp->rotate_cb;
- rotate_func(d, win, sp);
+ int (*rotate_func) (Display *, Window, syspopup *);
+ rotate_func = sp->rotate_cb;
+ rotate_func(d, win, sp);
#else
- __efl_rotation_set((Evas_Object *)sp->win, (Ecore_X_Window)win);
+ __efl_rotation_set((Evas_Object *)sp->win, (Ecore_X_Window)win);
#endif
- XMapWindow(d, win);
- /*XMapRaised(d,win);*/
- XCloseDisplay(d);
+ XMapWindow(d, win);
+ XCloseDisplay(d);
+ } while (0);
_syspopup_info_free(info);
}
API int syspopup_has_popup(bundle *b)
{
const char *popup_name;
+
popup_name = _syspopup_get_name_from_bundle(b);
if (popup_name == NULL)
return 0;
if (_syspopup_find(popup_name) != NULL)
return 1;
- else
- return 0;
+
+ return 0;
}
API int syspopup_reset_timeout(bundle *b, unsigned int time)
_E("get syspopup info error");
return -1;
}
+
info->timeout = time;
ret = _syspopup_reset_timeout(sp, info);
_syspopup_info_free(info);
return ret;
}
-
#include <Ecore_X.h>
#endif
+#ifndef WAYLAND
static Eina_Bool __x_keypress_cb(void *data, int type, void *event)
{
int id = (int)data;
return ECORE_CALLBACK_RENEW;
}
+#endif
#ifdef ROTATE_USING_X_CLIENT
static Eina_Bool __x_rotate_cb(void *data, int type, void *event)
API int syspopup_reset(bundle *b)
{
+#ifndef WAYLAND
return X_syspopup_reset(b);
+#else
+ return 0;
+#endif
}
-