INCLUDE(FindPkgConfig)
pkg_check_modules(MENU_PKGS REQUIRED
ail
+ appsvc
aul
badge
bundle
heynoti
pkgmgr
pkgmgr-info
+ shortcut
sysman
syspopup-caller
utilX
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
ADD_EXECUTABLE(${PROJECT_NAME}
+ src/db.c
src/index.c
src/item.c
src/item_badge.c
src/pkgmgr.c
src/popup.c
src/util.c
+ src/all_apps/db.c
src/all_apps/layout.c
src/all_apps/list.c
+ src/all_apps/shortcut.c
)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -lm)
mouse_events: 1;
description {
state: "default" 0.0;
- rel1 { relative: 37/180 8/180; to, "bg"; }
- rel2 { relative: 143/180 114/180; to, "bg"; }
+ rel1 { relative: 36/180 7/180; to, "bg"; }
+ rel2 { relative: 144/180 115/180; to, "bg"; }
color: 0 0 0 0;
}
}
mouse_events: 1;
description {
state: "default" 0.0;
- rel1 { relative: 15/180 8/180; to, "bg"; }
+ rel1 { relative: 15/180 7/180; to, "bg"; }
rel2 { relative: 165/180 160/180; to, "bg"; }
color: 0 0 0 0;
visible: 1;
Section: utils
Priority: extra
Maintainer: Jin Yoon <jinny.yoon@samsung.com>
-Build-Depends: debhelper (>= 5), libelm-dev, libslp-utilx-dev, libslp-setting-dev, libefreet-dev, libslp-sysman-dev, libslp-pm-dev, dlog-dev, libecore-dev, libaul-1-dev, libpkgmgr-client-dev, syspopup-caller-dev, libheynoti-dev, libail-0-dev, librua-dev, libslp-shortcut-dev, menu-daemon, capi-appfw-application-dev, libbadge-dev, pkgmgr-info-dev, capi-system-info-dev
+Build-Depends: debhelper (>= 5), libelm-dev, libslp-utilx-dev, libslp-setting-dev, libefreet-dev, libslp-sysman-dev, libslp-pm-dev, dlog-dev, libecore-dev, libaul-1-dev, libpkgmgr-client-dev, syspopup-caller-dev, libheynoti-dev, libail-0-dev, librua-dev, libslp-shortcut-dev, menu-daemon, capi-appfw-application-dev, libbadge-dev, pkgmgr-info-dev, capi-system-info-dev, libshortcut-dev, libappsvc-dev
Homepage: N/A
Standards-Version: 0.1.0
Package: org.tizen.menu-screen
Section: utils
Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, libelm, libeina, libslp-utilx-0, libslp-setting-0, libefreet, libslp-sysman, libslp-pm-0, libdlog-0, libaul-1, libpkgmgr-client-0, syspopup-caller-0, libheynoti-0, libail-0, menu-daemon, capi-appfw-application, libbadge, pkgmgr-info, capi-system-info
+Depends: ${shlibs:Depends}, ${misc:Depends}, libelm, libeina, libslp-utilx-0, libslp-setting-0, libefreet, libslp-sysman, libslp-pm-0, libdlog-0, libaul-1, libpkgmgr-client-0, syspopup-caller-0, libheynoti-0, libail-0, menu-daemon, capi-appfw-application, libbadge, pkgmgr-info, capi-system-info, libshortcut-0, libappsvc-0
Description: inhouse menu-screen
Package: org.tizen.menu-screen-dbg
--- /dev/null
+ /*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+#ifndef __MENU_SCREEN_ALL_APPS_DB_H__
+#define __MENU_SCREEN_ALL_APPS_DB_H__
+
+#include "Elementary.h"
+#include "util.h"
+
+typedef struct _db_info {
+ long long rowid;
+ int type;
+
+ char *appid;
+ char *name;
+ char *content_info;
+ char *icon;
+} db_info;
+
+extern menu_screen_error_e all_apps_db_init(void);
+extern void all_apps_db_fini(void);
+
+extern Eina_List *all_apps_db_retrieve_all_info(void);
+extern void all_apps_db_unretrieve_info(db_info *info);
+extern void all_apps_db_unretrieve_all_info(Eina_List *list);
+
+extern long long all_apps_db_insert_shortcut(const char *appid, const char *name, int type, const char *content_info, const char *icon);
+extern menu_screen_error_e all_apps_db_delete_shortcut(long long rowid);
+
+#endif // __MENU_SCREEN_ALL_APPS_DB_H__
+// End of file
--- /dev/null
+ /*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+#ifndef _MENU_SCREEN_ALL_APPS_SHORTCUT_H_
+#define _MENU_SCREEN_ALL_APPS_SHORTCUT_H_
+
+#include <Elementary.h>
+#include <stdbool.h>
+
+extern Evas_Object *all_apps_shortcut_add(Evas_Object *scroller, long long rowid, const char *pkgname, const char *exec, const char *name, const char *icon, int type);
+extern void all_apps_shortcut_remove(Evas_Object *item);
+
+extern menu_screen_error_e all_apps_shortcut_add_all(Evas_Object *scroller);
+
+extern bool all_apps_shortcut_init(Evas_Object *all_apps);
+extern void all_apps_shortcut_fini(void);
+
+#endif // _MENU_SCREEN_ALL_APPS_SHORTCUT_H_
+
+// End of a file
--- /dev/null
+ /*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __MENU_SCREEN_DB_H__
+#define __MENU_SCREEN_DB_H__
+
+#include <stdbool.h>
+
+#include "util.h"
+
+typedef struct stmt stmt_h;
+
+extern stmt_h *db_prepare(const char *query);
+extern menu_screen_error_e db_bind_bool(stmt_h *handle, int idx, bool value);
+extern menu_screen_error_e db_bind_int(stmt_h *handle, int idx, int value);
+extern menu_screen_error_e db_bind_str(stmt_h *handle, int idx, const char *str);
+extern menu_screen_error_e db_next(stmt_h *handle);
+extern bool db_get_bool(stmt_h *handle, int index);
+extern int db_get_int(stmt_h *handle, int index);
+extern long long db_get_long_long(stmt_h *handle, int index);
+extern const char *db_get_str(stmt_h *handle, int index);
+extern menu_screen_error_e db_reset(stmt_h *handle);
+extern menu_screen_error_e db_finalize(stmt_h *handle);
+extern menu_screen_error_e db_exec(const char *query);
+extern long long db_last_insert_rowid(void);
+
+extern menu_screen_error_e db_open(const char *db_file);
+extern void db_close(void);
+
+extern menu_screen_error_e db_begin_transaction(void);
+extern menu_screen_error_e db_end_transaction(bool success);
+
+#endif // __MENU_SCREEN_DB_H__
+// End of file
extern char *item_get_desktop(Evas_Object *item);
extern void item_set_desktop(Evas_Object *item, char *name, int sync);
+extern int item_get_type(Evas_Object *item);
+extern void item_set_type(Evas_Object *edje, int type, int sync);
+
extern void item_enable_delete(Evas_Object *obj);
extern void item_disable_delete(Evas_Object *item);
extern unsigned int page_scroller_count_page(Evas_Object *scroller);
extern int page_scroller_get_page_no(Evas_Object* scroller, Evas_Object *page);
-extern menu_screen_error_e page_scroller_push_item(Evas_Object *scroller, app_info_t *ai);
+extern Evas_Object *page_scroller_push_item(Evas_Object *scroller, app_info_t *ai);
extern Evas_Object *page_scroller_find_item_by_package(Evas_Object *scroller, const char *package, int *page_no);
extern void page_scroller_trim_items(Evas_Object *scroller);
extern void page_scroller_bring_in(Evas_Object *scroller, int idx);
Source0: %{name}-%{version}.tar.gz
BuildRequires: pkgconfig(ail)
BuildRequires: pkgconfig(appcore-efl)
+BuildRequires: pkgconfig(appsvc)
BuildRequires: pkgconfig(aul)
BuildRequires: pkgconfig(badge)
BuildRequires: pkgconfig(bundle)
BuildRequires: pkgconfig(heynoti)
BuildRequires: pkgconfig(pkgmgr)
BuildRequires: pkgconfig(pkgmgr-info)
+BuildRequires: pkgconfig(shortcut)
BuildRequires: pkgconfig(sysman)
BuildRequires: pkgconfig(syspopup-caller)
BuildRequires: pkgconfig(utilX)
vconftool set -t int memory/menu-screen/is_menu_screen_done 0 -i -f
vconftool set -t string db/setting/menuscreen/package_name "org.tizen.menu-screen" -i -u 5000 -f
}
-
-
-
init_vconf
+if [ ! -d %{_datadir}/dbspace ]
+then
+ mkdir -p %{_datadir}/dbspace
+fi
+
+if [ ! -d %{_datadir}/shortcut ]
+then
+ mkdir -p %{_datadir}/shortcut
+else
+ rm -rf %{_datadir}/shortcut/*
+fi
+
+sqlite3 %{_datadir}/dbspace/.menu_screen.db 'PRAGMA journal_mode = PERSIST;
+ create table if not exists shortcut (
+ ROWID INTEGER PRIMARY KEY AUTOINCREMENT,
+ appid TEXT,
+ name TEXT,
+ type INTEGER,
+ content_info TEXT,
+ icon TEXT
+ );
+'
+
+chown -R 5000:5000 %{_datadir}
+chown root:5000 %{_datadir}/dbspace/.menu_screen.db
+chown root:5000 %{_datadir}/dbspace/.menu_screen.db-journal
+
+chmod 660 %{_datadir}/dbspace/.menu_screen.db
+chmod 660 %{_datadir}/dbspace/.menu_screen.db-journal
+
+if [ -f /usr/lib/rpm-plugins/msm.so ]
+then
+ chsmack -a 'org.tizen.menu-screen' %{_datadir}/dbspace/.menu_screen.db*
+fi
+
%files
%manifest %{name}.manifest
%defattr(-,root,root,-)
--- /dev/null
+ /*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+#include <sys/stat.h>
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "db.h"
+#include "util.h"
+#include "all_apps/db.h"
+
+#define QUERY_LEN 1024
+
+#define MENU_SCREEN_DB_FILE "/opt/usr/apps/com.samsung.menu-screen/data/dbspace/.menu_screen.db"
+#define SHORTCUT_TABLE "shortcut"
+#define QUERY_INSERT_SHORTCUT "INSERT INTO "SHORTCUT_TABLE" ("\
+ "appid,"\
+ "name,"\
+ "type,"\
+ "content_info,"\
+ "icon"\
+ ") VALUES ("\
+ "'%s', '%s', %d, '%s', '%s');"
+#define QUERY_DELETE_SHORTCUT "DELETE FROM "SHORTCUT_TABLE" WHERE ROWID=%lld"
+#define QUERY_GET_ALL "SELECT ROWID, appid, name, type, content_info, icon FROM "SHORTCUT_TABLE
+
+
+
+HAPI menu_screen_error_e all_apps_db_init(void)
+{
+ return db_open(MENU_SCREEN_DB_FILE);
+}
+
+
+
+HAPI void all_apps_db_fini(void)
+{
+ db_close();
+}
+
+
+
+HAPI Eina_List *all_apps_db_retrieve_all_info(void)
+{
+ stmt_h *st;
+ Eina_List *list = NULL;
+
+ retv_if(MENU_SCREEN_ERROR_OK != db_open(MENU_SCREEN_DB_FILE), NULL);
+
+ st = db_prepare(QUERY_GET_ALL);
+ retv_if(NULL == st, NULL);
+
+ menu_screen_error_e ret = MENU_SCREEN_ERROR_FAIL;
+ for (ret = db_next(st); MENU_SCREEN_ERROR_FAIL != ret && MENU_SCREEN_ERROR_NO_DATA != ret; ret = db_next(st)) {
+ db_info *info;
+ info = calloc(1, sizeof(db_info));
+ break_if(NULL == info);
+
+ info->rowid = db_get_long_long(st, 0); // 0 : ROWID
+
+ char *tmp = NULL;
+ tmp = (char *) db_get_str(st, 1); // 1 : appid
+ if (tmp && strlen(tmp)) {
+ info->appid = strdup(tmp);
+ goto_if(NULL == info->appid, APP_ERROR);
+ }
+
+ tmp = (char *) db_get_str(st, 2); // 2 : name
+ if (tmp && strlen(tmp)) {
+ info->name = strdup(tmp);
+ goto_if(NULL == info->name, APP_ERROR);
+ }
+
+ info->type = db_get_int(st, 3); // 3 : type
+
+ tmp = (char *) db_get_str(st, 4); // 4 : content_info
+ if (tmp && strlen(tmp)) {
+ info->content_info = strdup(tmp);
+ goto_if(NULL == info->content_info, APP_ERROR);
+ }
+
+ tmp = (char *) db_get_str(st, 5); // 5 : icon
+ if (tmp && strlen(tmp)) {
+ info->icon = strdup(tmp);
+ goto_if(NULL == info->icon, APP_ERROR);
+ }
+
+ list = eina_list_append(list, info);
+
+ continue;
+APP_ERROR:
+ if (info->appid) free(info->appid);
+ if (info->name) free(info->name);
+ if (info->content_info) free(info->content_info);
+ if (info->icon) free(info->icon);
+ if (info) free(info);
+ }
+
+ db_finalize(st);
+
+ return list;
+}
+
+
+
+HAPI void all_apps_db_unretrieve_info(db_info *info)
+{
+ ret_if(NULL == info);
+ if (info->appid) free(info->appid);
+ if (info->name) free(info->name);
+ if (info->content_info) free(info->content_info);
+ if (info->icon) free(info->icon);
+ if (info) free(info);
+}
+
+
+
+HAPI void all_apps_db_unretrieve_all_info(Eina_List *list)
+{
+ db_info *info = NULL;
+
+ EINA_LIST_FREE(list, info) {
+ if (NULL == info) break;
+ if (info->appid) free(info->appid);
+ if (info->name) free(info->name);
+ if (info->content_info) free(info->content_info);
+ if (info->icon) free(info->icon);
+ if (info) free(info);
+ }
+
+ eina_list_free(list);
+}
+
+
+
+HAPI long long all_apps_db_insert_shortcut(const char *appid, const char *name, int type, const char *content_info, const char *icon)
+{
+ char q[QUERY_LEN];
+
+ retv_if(MENU_SCREEN_ERROR_OK != db_open(MENU_SCREEN_DB_FILE), -1l);
+
+ snprintf(q, sizeof(q), QUERY_INSERT_SHORTCUT, appid, name, type, content_info, icon);
+ retv_if(db_exec(q) < 0, -1l);
+
+ long long id = -1l;
+ id = db_last_insert_rowid();
+
+ return id;
+}
+
+
+
+HAPI menu_screen_error_e all_apps_db_delete_shortcut(long long rowid)
+{
+ char q[QUERY_LEN];
+
+ retv_if(MENU_SCREEN_ERROR_OK != db_open(MENU_SCREEN_DB_FILE), MENU_SCREEN_ERROR_FAIL);
+
+ snprintf(q, sizeof(q), QUERY_DELETE_SHORTCUT, rowid);
+ retv_if(db_exec(q) < 0, MENU_SCREEN_ERROR_FAIL);
+
+ return MENU_SCREEN_ERROR_OK;
+}
+
+
+
+// END
#include "util.h"
#include "all_apps/layout.h"
#include "all_apps/list.h"
+#include "all_apps/shortcut.h"
#define ALL_APPS_EDJE_PORTRAIT EDJEDIR"/all_apps_portrait.edj"
#define ALL_APPS_GROUP "all_apps"
return MENU_SCREEN_ERROR_OK;
}
- retv_if(MENU_SCREEN_ERROR_FAIL == page_scroller_push_item(scroller, ai), MENU_SCREEN_ERROR_FAIL);
+ retv_if(NULL == page_scroller_push_item(scroller, ai), MENU_SCREEN_ERROR_FAIL);
return MENU_SCREEN_ERROR_OK;
page_scroller_bring_in(scroller, 0);
menu_screen_set_done(true);
- do {
- Evas_Object *button;
- button = _add_edit_button(all_apps, scroller);
- if (NULL == button) {
- _D("cannot make the edit button");
- }
- elm_object_part_content_set(all_apps, ALL_APPS_EDIT_BUTTON_PART, button);
- } while (0);
-
return ECORE_CALLBACK_CANCEL;
}
idle_timer = ecore_idler_add(_push_items_idler_cb, all_apps);
retv_if(NULL == idle_timer, MENU_SCREEN_ERROR_FAIL);
+ Evas_Object *scroller;
+ scroller = evas_object_data_get(all_apps, "scroller");
+ if (MENU_SCREEN_ERROR_OK != all_apps_shortcut_add_all(scroller))
+ _E("Cannot add shortcuts");
+
+ do {
+ Evas_Object *button;
+ button = _add_edit_button(all_apps, scroller);
+ if (NULL == button) {
+ _D("cannot make the edit button");
+ }
+ elm_object_part_content_set(all_apps, ALL_APPS_EDIT_BUTTON_PART, button);
+ } while (0);
+
return MENU_SCREEN_ERROR_OK;
}
elm_object_part_content_set(all_apps, "content", scroller);
evas_object_data_set(all_apps, "scroller", scroller);
-
+ if (!all_apps_shortcut_init(all_apps)) _E("Cannot initialize shortcut");
retv_if(MENU_SCREEN_ERROR_FAIL == _push_items(all_apps), NULL);
return all_apps;
ret_if(NULL == all_apps);
+ all_apps_shortcut_fini();
+
do {
Evas_Object *button;
if(all_apps) {
--- /dev/null
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+#include <shortcut.h>
+#include <stdbool.h>
+
+#include "item.h"
+#include "list.h"
+#include "page_scroller.h"
+#include "util.h"
+#include "all_apps/db.h"
+
+
+
+HAPI Evas_Object *all_apps_shortcut_add(
+ Evas_Object *scroller,
+ long long rowid,
+ const char *pkgname,
+ const char *exec,
+ const char *name,
+ const char *content_info,
+ const char *icon,
+ int type)
+{
+ _D("Shortcut : pkgname(%s) exec(%s) name(%s) icon(%s)", pkgname, exec, name, icon);
+
+ app_info_t ai = {0, };
+ ai.package = (char *) pkgname;
+ ai.exec = (char *) exec;
+ ai.name = (char *) name;
+ ai.icon = (char *) icon;
+ ai.nodisplay = 0;
+ ai.enabled = 1;
+ ai.x_slp_removable = 1;
+ ai.x_slp_taskmanage = 0;
+
+ if (ADD_TO_HOME_IS_LIVEBOX(type)) {
+ _D("This is a livebox");
+ return NULL;
+ }
+
+ Evas_Object *item = NULL;
+ retv_if(NULL == (item = page_scroller_push_item(scroller, &ai)), NULL);
+
+ long long *tmp;
+ tmp = calloc(1, sizeof(long long));
+ if (NULL == tmp) {
+ item_destroy(item);
+ return NULL;
+ }
+
+ if (LAUNCH_BY_PACKAGE == type) {
+ _D("This is a package");
+ evas_object_data_set(item, "shortcut_launch_package", (void *) true);
+ } else {
+ _D("This is a shortcut");
+ evas_object_data_set(item, "shortcut_launch_package", (void *) false);
+ }
+
+ *tmp = rowid;
+ evas_object_data_set(item, "is_shortcut", (void *) true);
+ evas_object_data_set(item, "rowid", tmp);
+ evas_object_data_set(item, "type", (void *) type);
+ evas_object_data_set(item, "content_info", content_info);
+
+ return item;
+}
+
+
+
+static Eina_Bool _push_items_idler_cb(void *data)
+{
+ Evas_Object *scroller = data;
+ Eina_List *list = evas_object_data_get(scroller, "list");
+ Eina_List *n;
+ Eina_List *t;
+ db_info *info = NULL;
+ EINA_LIST_FOREACH_SAFE(list, n, t, info) {
+ goto_if(NULL == info, ERROR);
+ Evas_Object *item = NULL;
+ item = all_apps_shortcut_add(
+ scroller,
+ info->rowid,
+ info->appid,
+ NULL,
+ info->name,
+ info->content_info,
+ info->icon,
+ info->type);
+
+ list = eina_list_remove(list, info);
+ evas_object_data_set(scroller, "list", list);
+
+ all_apps_db_unretrieve_info(info);
+ break_if(NULL == item);
+ }
+
+ return ECORE_CALLBACK_RENEW;
+ERROR:
+ list = evas_object_data_del(scroller, "list");
+ all_apps_db_unretrieve_all_info(list);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+
+HAPI menu_screen_error_e all_apps_shortcut_add_all(Evas_Object *scroller)
+{
+ Eina_List *list;
+
+ list = all_apps_db_retrieve_all_info();
+ if (NULL == list) {
+ _D("There is no shortcut");
+ return MENU_SCREEN_ERROR_OK;
+ }
+
+ evas_object_data_set(scroller, "list", list);
+
+ Ecore_Idler *idle_timer = NULL;
+ idle_timer = ecore_idler_add(_push_items_idler_cb, scroller);
+
+ return MENU_SCREEN_ERROR_OK;
+}
+
+
+
+HAPI void all_apps_shortcut_remove(Evas_Object *item)
+{
+ long long *tmp;
+ tmp = evas_object_data_del(item, "rowid");
+ if (tmp) {
+ all_apps_db_delete_shortcut(*tmp);
+ free(tmp);
+ }
+
+ Evas_Object *scroller;
+ scroller = evas_object_data_get(item, "scroller");
+
+ evas_object_data_del(item, "type");
+ evas_object_data_del(item, "content_info");
+ evas_object_data_del(item, "shortcut_launch_package");
+ evas_object_data_del(item, "is_shortcut");
+ item_destroy(item);
+
+ if (scroller) page_scroller_trim_items(scroller);
+}
+
+
+
+static int _shorcut_request_cb(
+ const char *pkgname,
+ const char *name,
+ int type,
+ const char *content_info,
+ const char *icon,
+ int pid,
+ double period,
+ void *data)
+{
+ Evas_Object *scroller = data;
+
+ retv_if(NULL == pkgname, -1);
+
+ _D("Package name: %s", pkgname);
+ _D("Name: %s", name);
+ _D("Type: %d", type);
+ _D("Content: %s", content_info);
+ _D("Icon: %s", icon);
+ _D("Requested from: %d", pid);
+ _D("period : %.2f", period);
+ _D("CBDATA: %p", data);
+
+ long long rowid = -1l;
+ rowid = all_apps_db_insert_shortcut(pkgname, name, type, content_info, icon);
+ retv_if(0l > rowid, -1);
+
+ Evas_Object *item = NULL;
+ item = all_apps_shortcut_add(scroller, rowid, pkgname, NULL, name, content_info, icon, type);
+ retv_if(NULL == item, -1);
+
+ return 0;
+}
+
+
+
+HAPI bool all_apps_shortcut_init(Evas_Object *all_apps)
+{
+ retv_if(NULL == all_apps, false);
+ retv_if(MENU_SCREEN_ERROR_OK != all_apps_db_init(), false);
+
+ Evas_Object *scroller;
+ scroller = evas_object_data_get(all_apps, "scroller");
+ retv_if(NULL == scroller, false);
+
+ int ret;
+ ret = shortcut_set_request_cb(_shorcut_request_cb, scroller);
+
+ return 0 == ret ? true : false;
+}
+
+
+
+HAPI void all_apps_shortcut_fini(void)
+{
+ all_apps_db_fini();
+}
+
+
+
+// End of file.
--- /dev/null
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+#include <db-util.h>
+#include <sqlite3.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "util.h"
+#include "db.h"
+
+
+
+#define retv_with_dbmsg_if(expr, val) do { \
+ if (expr) { \
+ _E("%s", sqlite3_errmsg(db_info.db)); \
+ return (val); \
+ } \
+} while (0)
+
+
+
+static struct {
+ sqlite3 *db;
+} db_info = {
+ .db = NULL,
+};
+
+struct stmt {
+ sqlite3_stmt *stmt;
+};
+
+
+
+HAPI menu_screen_error_e db_open(const char *db_file)
+{
+ int ret;
+
+ retv_if(NULL == db_file, MENU_SCREEN_ERROR_INVALID_PARAMETER);
+ if (db_info.db) {
+ return MENU_SCREEN_ERROR_OK;
+ }
+
+ ret = db_util_open(db_file, &db_info.db, DB_UTIL_REGISTER_HOOK_METHOD);
+ retv_with_dbmsg_if(ret != SQLITE_OK, MENU_SCREEN_ERROR_FAIL);
+
+ return MENU_SCREEN_ERROR_OK;
+}
+
+
+
+HAPI stmt_h *db_prepare(const char *query)
+{
+ int ret;
+ stmt_h *handle;
+
+ retv_if(NULL == query, NULL);
+
+ handle = calloc(1, sizeof(stmt_h));
+ retv_if(NULL == handle, NULL);
+
+ ret = sqlite3_prepare_v2(db_info.db, query, strlen(query), &(handle->stmt), NULL);
+ if (ret != SQLITE_OK) {
+ free(handle);
+ _E("%s", sqlite3_errmsg(db_info.db));
+ return NULL;
+ }
+
+ return handle;
+}
+
+
+
+HAPI menu_screen_error_e db_bind_bool(stmt_h *handle, int idx, bool value)
+{
+ int ret;
+
+ retv_if(NULL == handle, MENU_SCREEN_ERROR_FAIL);
+
+ ret = sqlite3_bind_int(handle->stmt, idx, (int) value);
+ retv_with_dbmsg_if(ret != SQLITE_OK, MENU_SCREEN_ERROR_FAIL);
+
+ return MENU_SCREEN_ERROR_OK;
+}
+
+
+
+HAPI menu_screen_error_e db_bind_int(stmt_h *handle, int idx, int value)
+{
+ int ret;
+
+ retv_if(NULL == handle, MENU_SCREEN_ERROR_FAIL);
+
+ ret = sqlite3_bind_int(handle->stmt, idx, value);
+ retv_with_dbmsg_if(ret != SQLITE_OK, MENU_SCREEN_ERROR_FAIL);
+
+ return MENU_SCREEN_ERROR_OK;
+}
+
+
+
+HAPI menu_screen_error_e db_bind_str(stmt_h *handle, int idx, const char *str)
+{
+ int ret;
+
+ retv_if(NULL == handle, MENU_SCREEN_ERROR_FAIL);
+
+ ret = sqlite3_bind_text(handle->stmt, idx, str, strlen(str), SQLITE_TRANSIENT);
+ retv_with_dbmsg_if(ret != SQLITE_OK, MENU_SCREEN_ERROR_FAIL);
+
+ return MENU_SCREEN_ERROR_OK;
+}
+
+
+
+HAPI menu_screen_error_e db_next(stmt_h *handle)
+{
+ int ret;
+
+ retv_if(NULL == handle, MENU_SCREEN_ERROR_FAIL);
+
+ ret = sqlite3_step(handle->stmt);
+ switch (ret) {
+ case SQLITE_ROW:
+ return MENU_SCREEN_ERROR_OK;
+ case SQLITE_DONE:
+ return MENU_SCREEN_ERROR_NO_DATA;
+ default:
+ retv_with_dbmsg_if(1, MENU_SCREEN_ERROR_FAIL);
+ }
+}
+
+
+
+HAPI bool db_get_bool(stmt_h *handle, int index)
+{
+ retv_if(NULL == handle, false);
+ return (bool) sqlite3_column_int(handle->stmt, index);
+}
+
+
+
+HAPI int db_get_int(stmt_h *handle, int index)
+{
+ retv_if(NULL == handle, 0);
+ return sqlite3_column_int(handle->stmt, index);
+}
+
+
+
+HAPI long long db_get_long_long(stmt_h *handle, int index)
+{
+ retv_if(NULL == handle, 0l);
+ return sqlite3_column_int64(handle->stmt, index);
+}
+
+
+HAPI const char *db_get_str(stmt_h *handle, int index)
+{
+ retv_if(NULL == handle, NULL);
+ return (const char *) sqlite3_column_text(handle->stmt, index);
+}
+
+
+
+HAPI menu_screen_error_e db_reset(stmt_h *handle)
+{
+ int ret;
+
+ retv_if(NULL == handle, MENU_SCREEN_ERROR_INVALID_PARAMETER);
+ retv_if(NULL == handle->stmt, MENU_SCREEN_ERROR_INVALID_PARAMETER);
+
+ ret = sqlite3_reset(handle->stmt);
+ retv_with_dbmsg_if(ret != SQLITE_OK, MENU_SCREEN_ERROR_FAIL);
+
+ sqlite3_clear_bindings(handle->stmt);
+
+ return MENU_SCREEN_ERROR_OK;
+}
+
+
+
+HAPI menu_screen_error_e db_finalize(stmt_h *handle)
+{
+ int ret;
+
+ retv_if(NULL == handle, MENU_SCREEN_ERROR_INVALID_PARAMETER);
+ retv_if(NULL == handle->stmt, MENU_SCREEN_ERROR_INVALID_PARAMETER);
+
+ ret = sqlite3_finalize(handle->stmt);
+ retv_with_dbmsg_if(ret != SQLITE_OK, MENU_SCREEN_ERROR_FAIL);
+ free(handle);
+
+ return MENU_SCREEN_ERROR_OK;
+}
+
+
+
+HAPI long long db_last_insert_rowid(void)
+{
+ retv_if(NULL == db_info.db, -1l);
+
+ long long rowid = sqlite3_last_insert_rowid(db_info.db);
+
+ return rowid;
+}
+
+
+
+HAPI menu_screen_error_e db_exec(const char *query)
+{
+ int ret;
+ char *errmsg;
+
+ retv_if(NULL == query, MENU_SCREEN_ERROR_INVALID_PARAMETER);
+ retv_if(NULL == db_info.db, MENU_SCREEN_ERROR_FAIL);
+
+ ret = sqlite3_exec(db_info.db, query, NULL, NULL, &errmsg);
+ if (ret != SQLITE_OK) {
+ _E("Cannot execute this query - %s. because %s",
+ query, errmsg? errmsg:"uncatched error");
+ sqlite3_free(errmsg);
+ return MENU_SCREEN_ERROR_FAIL;
+ }
+
+ return MENU_SCREEN_ERROR_OK;
+}
+
+
+
+HAPI void db_close(void)
+{
+ ret_if(!db_info.db);
+ sqlite3_close(db_info.db);
+ db_info.db = NULL;
+}
+
+
+
+HAPI menu_screen_error_e db_begin_transaction(void)
+{
+ int ret = -1;
+
+ ret = sqlite3_exec(db_info.db, "BEGIN IMMEDIATE TRANSACTION", NULL, NULL, NULL);
+
+ while (SQLITE_BUSY == ret) {
+ sleep(1);
+ ret = sqlite3_exec(db_info.db, "BEGIN IMMEDIATE TRANSACTION", NULL, NULL, NULL);
+ }
+
+ if (SQLITE_OK != ret) {
+ _E("sqlite3_exec() Failed(%d)", ret);
+ return MENU_SCREEN_ERROR_FAIL;
+ }
+
+ return MENU_SCREEN_ERROR_OK;
+}
+
+
+
+#define MENU_SCREEN_COMMIT_TRY_MAX 3
+HAPI menu_screen_error_e db_end_transaction(bool success)
+{
+ int ret = -1;
+ int i = 0;
+ char *errmsg = NULL;
+
+ if (success) {
+ ret = sqlite3_exec(db_info.db, "COMMIT TRANSACTION", NULL, NULL, &errmsg);
+ if (SQLITE_OK != ret) {
+ _E("sqlite3_exec(COMMIT) Failed(%d, %s)", ret, errmsg);
+ sqlite3_free(errmsg);
+
+ while (SQLITE_BUSY == ret && i < MENU_SCREEN_COMMIT_TRY_MAX) {
+ i++;
+ sleep(1);
+ ret = sqlite3_exec(db_info.db, "COMMIT TRANSACTION", NULL, NULL, NULL);
+ }
+
+ if (SQLITE_OK != ret) {
+ _E("sqlite3_exec() Failed(%d)", ret);
+ ret = sqlite3_exec(db_info.db, "ROLLBACK TRANSACTION", NULL, NULL, NULL);
+ if (SQLITE_OK != ret) {
+ _E("sqlite3_exec() Failed(%d)", ret);
+ }
+
+ return MENU_SCREEN_ERROR_FAIL;
+ }
+ }
+ } else {
+ sqlite3_exec(db_info.db, "ROLLBACK TRANSACTION", NULL, NULL, NULL);
+ }
+
+ return MENU_SCREEN_ERROR_OK;
+}
+
+
+
+// End of file.
#include <stdlib.h>
#include <Elementary.h>
-#include <aul.h>
#include <ail.h>
+#include <appsvc.h>
+#include <aul.h>
#include "menu_screen.h"
#include "item_badge.h"
#define STR_ATTRIBUTE_PKG_NAME "package"
#define STR_ATTRIBUTE_REMOVABLE "removable"
#define STR_ATTRIBUTE_DESKTOP "desktop"
+#define STR_ATTRIBUTE_TYPE "type"
#define STR_ATTRIBUTE_PAGE "pending,page"
#define STR_ICON_IMAGE_TYPE_OBJECT "object"
#define STR_ICON_IMAGE_TYPE_EDJE "edje"
+HAPI void item_set_type(Evas_Object *edje, int type, int sync)
+{
+ int tmp;
+ int changed;
+
+ tmp = (int) evas_object_data_get(edje, STR_ATTRIBUTE_TYPE);
+ changed = (tmp == type ? 0 : 1); // We have to do sync when an attribute is created
+
+ if (!changed) {
+ return ;
+ }
+
+ evas_object_data_set(edje, STR_ATTRIBUTE_TYPE, (void *) type);
+}
+
+
+
+HAPI inline int item_get_type(Evas_Object *edje)
+{
+ return (int) evas_object_data_get(edje, STR_ATTRIBUTE_TYPE);
+}
+
+
+
HAPI void item_set_package(Evas_Object *edje, char *package, int sync)
{
char *tmp;
static Eina_Bool _unblock_cb(void *data)
{
Evas_Object *layout;
- layout = evas_object_data_get(menu_screen_get_win(), "layout_current");
+ layout = evas_object_data_get(menu_screen_get_win(), "layout");
layout_disable_block(layout);
return EINA_FALSE;
}
+static void _run_cb(bundle *b, int request_code, appsvc_result_val result, void *data)
+{
+}
+
+
+
HAPI void item_launch(Evas_Object *obj)
{
char *package;
package = item_get_package(obj);
ret_if(NULL == package);
- layout = evas_object_data_get(menu_screen_get_win(), "layout_current");
+ layout = evas_object_data_get(menu_screen_get_win(), "layout");
layout_enable_block(layout);
- ret_aul = aul_open_app(package);
- if (ret_aul == AUL_R_EINVAL) {
- char* sinform;
- int len;
-
- // IDS_IDLE_POP_UNABLE_TO_LAUNCH_PS : "Unable to launch %s"
- len = strlen(D_("IDS_IDLE_POP_UNABLE_TO_LAUNCH_PS")) + strlen(name) + 1;
-
- sinform = calloc(len, sizeof(char));
- if (!sinform) {
- _E("cannot calloc for popup.");
- return;
+ bool is_shortcut = (bool) evas_object_data_get(obj, "is_shortcut");
+ bool shortcut_launch_package = (bool) evas_object_data_get(obj, "shortcut_launch_package");
+ if (is_shortcut && !shortcut_launch_package) {
+ bundle *b = NULL;
+ b = bundle_create();
+ ret_if(NULL == b);
+
+ appsvc_set_operation(b, APPSVC_OPERATION_VIEW);
+ appsvc_set_uri(b, evas_object_data_get(obj, "content_info"));
+
+ int ret = -1;
+ ret = appsvc_run_service(b, 0, _run_cb, NULL);
+ if (0 > ret) {
+ _E("cannot run service. ret [%d]", ret);
+ layout_disable_block(layout);
+ } else {
+ _D("Launch app's ret : [%d]", ret);
+ ecore_timer_add(LAYOUT_BLOCK_INTERVAL, _unblock_cb, NULL);
}
- snprintf(sinform, len, D_("IDS_IDLE_POP_UNABLE_TO_LAUNCH_PS"), name);
- popup_create(obj, sinform);
-
- free(sinform);
- layout_disable_block(layout);
+ bundle_free(b);
} else {
- _D("Launch app's ret : [%d]", ret_aul);
- _T(package);
- ecore_timer_add(LAYOUT_BLOCK_INTERVAL, _unblock_cb, NULL);
+ ret_aul = aul_open_app(package);
+ if (ret_aul == AUL_R_EINVAL) {
+ char* sinform;
+ int len;
+
+ // IDS_IDLE_POP_UNABLE_TO_LAUNCH_PS : "Unable to launch %s"
+ len = strlen(D_("IDS_IDLE_POP_UNABLE_TO_LAUNCH_PS")) + strlen(name) + 1;
+
+ sinform = calloc(len, sizeof(char));
+ if (!sinform) {
+ _E("cannot calloc for popup.");
+ return;
+ }
+
+ snprintf(sinform, len, D_("IDS_IDLE_POP_UNABLE_TO_LAUNCH_PS"), name);
+ popup_create(obj, sinform);
+
+ free(sinform);
+ layout_disable_block(layout);
+ } else {
+ _D("Launch app's ret : [%d]", ret_aul);
+ _T(package);
+ ecore_timer_add(LAYOUT_BLOCK_INTERVAL, _unblock_cb, NULL);
+ }
}
}
-HAPI menu_screen_error_e page_scroller_push_item(Evas_Object *scroller, app_info_t *ai)
+HAPI Evas_Object *page_scroller_push_item(Evas_Object *scroller, app_info_t *ai)
{
Evas_Object *page;
Evas_Object *item;
rotate = (int) evas_object_data_get(scroller, "rotate");
new_page = page_create(scroller, nr_of_pages, rotate);
- retv_if(NULL == new_page, MENU_SCREEN_ERROR_FAIL);
+ retv_if(NULL == new_page, NULL);
mapbuf_enable(new_page, 0);
}
item = item_create(scroller, ai);
- retv_if(NULL == item, MENU_SCREEN_ERROR_FAIL);
+ retv_if(NULL == item, NULL);
page = page_scroller_get_page_at(scroller, candidate_page);
if (!page) {
_D("Impossible, page is not found");
item_destroy(item);
- return MENU_SCREEN_ERROR_FAIL;
+ return NULL;
}
retv_if(MENU_SCREEN_ERROR_OK !=
_animated_pack_item(item, scroller, page, candidate_pos),
- MENU_SCREEN_ERROR_FAIL);
+ NULL);
- return MENU_SCREEN_ERROR_OK;
+ return item;
}
if (!item) {
item = page_scroller_find_item_by_package(scroller, ai.package, NULL);
if (!item) {
- int ret;
-
+ Evas_Object *item;
_D("package %s is installed directly", package);
- ret = page_scroller_push_item(scroller, &ai);
- if (ret == MENU_SCREEN_ERROR_OK) {
+ item = page_scroller_push_item(scroller, &ai);
+ if (item) {
break;
} else {
list_free_values(&ai);
item_destroy(item);
}
} else {
- int ret;
+ Evas_Object *item;
_D("Item is not found. Create a new one");
-
- ret = ((!ai.nodisplay && ai.enabled) ? page_scroller_push_item(scroller, &ai) : MENU_SCREEN_ERROR_OK);
- if (ret == MENU_SCREEN_ERROR_OK) {
+ item = ((!ai.nodisplay && ai.enabled) ? page_scroller_push_item(scroller, &ai) : NULL);
+ if (item) {
break;
} else {
list_free_values(&ai);
pi->item = page_scroller_find_item_by_package(scroller, package, &page_no);
if (!pi->item) {
- if (MENU_SCREEN_ERROR_FAIL == page_scroller_push_item(scroller, &pi->ai)) _E("Cannot push an item");
+ if (NULL == page_scroller_push_item(scroller, &pi->ai)) _E("Cannot push an item");
}
pi->item = page_scroller_find_item_by_package(scroller, package, &page_no);
pi->page = page_scroller_get_page_at(scroller, page_no);
pi->ai.nodisplay = false;
pi->ai.enabled = true;
- if (MENU_SCREEN_ERROR_FAIL == page_scroller_push_item(scroller, &pi->ai)) {
+ if (NULL == page_scroller_push_item(scroller, &pi->ai)) {
_E("Failed to create a new item, remove this package from the installing list");
list_free_values(&pi->ai);
install_list = eina_list_remove(install_list, pi);
#include "menu_screen.h"
#include "pkgmgr.h"
#include "util.h"
+#include "all_apps/shortcut.h"
#define BUFSZE 1024
evas_object_del(evas_object_data_del(popup, "button2"));
evas_object_del(popup);
- if (MENU_SCREEN_ERROR_OK != pkgmgr_uninstall(item)) {
- _E("Cannot communicate with the pkgmgr-server.");
+ bool is_shortcut = false;
+ is_shortcut = (bool) evas_object_data_get(item, "is_shortcut");
+
+ if (is_shortcut) {
+ all_apps_shortcut_remove(item);
+ } else {
+ if (MENU_SCREEN_ERROR_OK != pkgmgr_uninstall(item)) {
+ _E("Cannot communicate with the pkgmgr-server.");
+ }
}
}