*/
/**
+ * @brief Called to get the system popup information.
+ * @since_tizen 4.0
+ * @param[in] popup_name The name of the system popup
+ * @param[in] appid The application ID of the system popup
+ * @param[in] user_data The user data passed from the foreach function
+ * @return @c 0 to continue with the next iteration of the loop,
+ * otherwise a negative error value to break out of the loop
+ * @pre syspopup_foreach_info() will invoke this callback.
+ * @see syspopup_foreach_info()
+ */
+typedef int (*syspopup_info_cb)(const char *popup_name, const char *appid, void *user_data);
+
+/**
* @brief This API launch the system popup application with given popup name.
*
* This API launch the system popup application.
*/
int syspopup_destroy_all(void);
+/**
+ * @brief Retrieves the system popup information.
+ * @since_tizen 4.0
+ * @param[in] callback The iteration callback function
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ */
+int syspopup_foreach_info(syspopup_info_cb callback, void *user_data);
+
/** @} */
#ifdef __cplusplus
int _syspopup_info_add(syspopup_info_t *pinfo);
syspopup_info_t *_syspopup_info_get(const char *popup_name);
void _syspopup_info_free(syspopup_info_t *pinfo);
+int _syspopup_info_foreach(int (*callback)(syspopup_info_t *, void *),
+ void *user_data);
#endif
free(pinfo);
}
+
+int _syspopup_info_foreach(int (*callback)(syspopup_info_t *, void *),
+ void *user_data)
+{
+ const char query[] = "SELECT name, prio, focus, timeout, term_act, "
+ "endkey_act, pkgname FROM syspopup_info;";
+ sqlite3_stmt *stmt;
+ syspopup_info_t info;
+ int r;
+ int idx;
+
+ if (callback == NULL) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ if (__init() < 0)
+ return -1;
+
+ r = sqlite3_prepare_v2(db, query, sizeof(query), &stmt, NULL);
+ if (r != SQLITE_OK) {
+ _E("sqlite3_prepare_v2() is failed - %d(%s)",
+ r, sqlite3_errmsg(db));
+ __fini();
+ return -1;
+ }
+
+ while (sqlite3_step(stmt) == SQLITE_ROW) {
+ idx = 0;
+ info.name = (char *)sqlite3_column_text(stmt, idx++);
+ info.prio = sqlite3_column_int(stmt, idx++);
+ info.focus = sqlite3_column_int(stmt, idx++);
+ info.timeout = sqlite3_column_int(stmt, idx++);
+ info.term_act = sqlite3_column_int(stmt, idx++);
+ info.endkey_act = sqlite3_column_int(stmt, idx++);
+ info.pkgname = (char *)sqlite3_column_text(stmt, idx);
+
+ if (callback(&info, user_data) < 0)
+ break;
+ }
+ sqlite3_finalize(stmt);
+ __fini();
+
+ return 0;
+}
#include "syspopup_db.h"
#include "syspopup_api.h"
#include "simple_util.h"
+#include "syspopup_caller.h"
#define REGULAR_UID_MIN 5000
+struct cb_info {
+ syspopup_info_cb callback;
+ void *user_data;
+};
+
API int syspopup_launch_for_uid(char *popup_name, bundle *b, uid_t uid)
{
syspopup_info_t *info;
return ret;
}
+
+static int __foreach_cb(syspopup_info_t *sp_info, void *user_data)
+{
+ struct cb_info *info = (struct cb_info *)user_data;
+
+ if (!info)
+ return -1;
+
+ return info->callback(sp_info->name, sp_info->pkgname, info->user_data);
+}
+
+API int syspopup_foreach_info(syspopup_info_cb callback, void *user_data)
+{
+ struct cb_info info = {
+ .callback = callback,
+ .user_data = user_data
+ };
+
+ if (!callback) {
+ _E("Invalid parameter");
+ return -1;
+ }
+
+ return _syspopup_info_foreach(__foreach_cb, &info);
+}
#include <bundle_internal.h>
#include "syspopup_caller.h"
+static int __foreach_cb(const char *popup_name, const char *appid,
+ void *user_data)
+{
+ printf("system popup name [%s] appid [%s]\n", popup_name, appid);
+ return 0;
+}
+
static void usage(void)
{
- printf("[usage] sp_test launch/destroy popup_name..."
+ printf("[usage] sp_test launch/destroy/foreach popup_name..."
"(key1,val1,key2,val2,...)\n");
}
ret = syspopup_destroy_all();
if (ret < 0)
return -1;
+ } else if (strcmp(argv[1], "foreach") == 0) {
+ ret = syspopup_foreach_info(__foreach_cb, NULL);
+ if (ret < 0)
+ return -1;
} else {
usage();
}