diff options
author | Sung-jae Park <nicesj.park@samsung.com> | 2015-05-11 21:08:06 +0900 |
---|---|---|
committer | Sung-jae Park <nicesj.park@samsung.com> | 2015-05-11 21:08:06 +0900 |
commit | 7ad2f3d8c2880cd888ee3e05c6a950f442e9dd65 (patch) | |
tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 | |
parent | b674a425512a5ba5a4c9692d06316a687757a396 (diff) | |
download | shortcut-7ad2f3d8c2880cd888ee3e05c6a950f442e9dd65.tar.gz shortcut-7ad2f3d8c2880cd888ee3e05c6a950f442e9dd65.tar.bz2 shortcut-7ad2f3d8c2880cd888ee3e05c6a950f442e9dd65.zip |
Clean up old codes
Tizen 2.3/2.4 codes are replaced with old 3.0
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rw-r--r-- | lib/CMakeLists.txt | 55 | ||||
-rw-r--r-- | lib/LICENSE | 204 | ||||
-rw-r--r-- | lib/include/dlist.h | 43 | ||||
-rw-r--r-- | lib/include/shortcut.h | 557 | ||||
-rw-r--r-- | lib/include/shortcut_PG.h | 226 | ||||
-rw-r--r-- | lib/include/shortcut_internal.h | 229 | ||||
-rw-r--r-- | lib/include/shortcut_manager.h | 177 | ||||
-rw-r--r-- | lib/shortcut.pc.in | 11 | ||||
-rw-r--r-- | lib/src/dlist.c | 189 | ||||
-rw-r--r-- | lib/src/icon.c | 817 | ||||
-rw-r--r-- | lib/src/main.c | 1062 | ||||
-rw-r--r-- | packaging/libshortcut.changes | 3 | ||||
-rw-r--r-- | packaging/libshortcut.manifest | 8 | ||||
-rw-r--r-- | packaging/libshortcut.spec | 85 | ||||
-rw-r--r-- | pkgmgr_shortcut/CMakeLists.txt | 32 | ||||
-rw-r--r-- | pkgmgr_shortcut/include/dlist.h | 44 | ||||
-rw-r--r-- | pkgmgr_shortcut/src/dlist.c | 189 | ||||
-rw-r--r-- | pkgmgr_shortcut/src/service_register.c | 1270 | ||||
-rw-r--r-- | sample.xml | 62 | ||||
-rw-r--r-- | test/Makefile | 4 | ||||
-rw-r--r-- | test/application.c | 62 | ||||
-rw-r--r-- | test/homescreen.c | 40 | ||||
-rw-r--r-- | test/icon.c | 96 | ||||
-rw-r--r-- | test/shortcut.c | 41 | ||||
-rwxr-xr-x | test_db_builder.sh | 81 |
26 files changed, 0 insertions, 5593 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index ea60a32..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) - -set(CMAKE_SKIP_BUILD_RPATH true) - -ADD_SUBDIRECTORY("pkgmgr_shortcut") -ADD_SUBDIRECTORY("lib") diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt deleted file mode 100644 index 206ae46..0000000 --- a/lib/CMakeLists.txt +++ /dev/null @@ -1,55 +0,0 @@ -PROJECT(shortcut C) - -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/include) - -SET(PREFIX ${CMAKE_INSTALL_PREFIX}) -SET(EXEC_PREFIX "\${prefix}") -SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}") -SET(VERSION_MAJOR 0) -SET(VERSION "${VERSION_MAJOR}.0.1") - -INCLUDE(FindPkgConfig) -pkg_check_modules(svc_pkgs REQUIRED - dlog - sqlite3 - libxml-2.0 - glib-2.0 - db-util - com-core - vconf - libtzplatform-config - capi-base-common - aul -) - -FOREACH(flag ${svc_pkgs_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -g -Wall -Werror") -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") - -ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"") -ADD_DEFINITIONS("-DLOG_TAG=\"SHORTCUT\"") -ADD_DEFINITIONS("-D_USE_ECORE_TIME_GET") - -ADD_LIBRARY(${PROJECT_NAME} SHARED - src/main.c - src/icon.c - src/dlist.c -) - -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${svc_pkgs_LDFLAGS}) - -CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) -SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_NAME}.pc") - -INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR}) -INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/include/shortcut.h DESTINATION include/${PROJECT_NAME}) -INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/include/shortcut_PG.h DESTINATION include/${PROJECT_NAME}) -INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/include/shortcut_manager.h DESTINATION include/${PROJECT_NAME}) -INSTALL(FILES ${CMAKE_BINARY_DIR}/lib/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) -INSTALL(FILES ${CMAKE_SOURCE_DIR}/lib/LICENSE DESTINATION /usr/share/license RENAME "lib${PROJECT_NAME}") - -SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR}) -SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION}) diff --git a/lib/LICENSE b/lib/LICENSE deleted file mode 100644 index 3b739e3..0000000 --- a/lib/LICENSE +++ /dev/null @@ -1,204 +0,0 @@ -Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
-
- 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.
-
diff --git a/lib/include/dlist.h b/lib/include/dlist.h deleted file mode 100644 index cd1a421..0000000 --- a/lib/include/dlist.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.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. - */ - -#define dlist_remove_data(list, data) do { \ - struct dlist *l; \ - l = dlist_find_data(list, data); \ - list = dlist_remove(list, l); \ -} while (0) - -#define dlist_foreach(list, l, data) \ - for ((l) = (list); (l) && ((data) = dlist_data(l)); (l) = dlist_next(l)) - -#define dlist_foreach_safe(list, l, n, data) \ - for ((l) = (list), (n) = dlist_next(l); \ - (l) && ((data) = dlist_data(l)); \ - (l) = (n), (n) = dlist_next(l)) - -struct dlist; - -extern struct dlist *dlist_append(struct dlist *list, void *data); -extern struct dlist *dlist_prepend(struct dlist *list, void *data); -extern struct dlist *dlist_remove(struct dlist *list, struct dlist *l); -extern struct dlist *dlist_find_data(struct dlist *list, void *data); -extern void *dlist_data(struct dlist *l); -extern struct dlist *dlist_next(struct dlist *l); -extern struct dlist *dlist_prev(struct dlist *l); -extern int dlist_count(struct dlist *l); -extern struct dlist *dlist_nth(struct dlist *l, int nth); - -/* End of a file */ diff --git a/lib/include/shortcut.h b/lib/include/shortcut.h deleted file mode 100644 index 6df2b47..0000000 --- a/lib/include/shortcut.h +++ /dev/null @@ -1,557 +0,0 @@ -/* - * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. - * - * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 - * - * 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 __SHORTCUT_H__ -#define __SHORTCUT_H__ - -#include <tizen.h> -#include <shortcut_manager.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file shortcut.h - * @brief This file declares the API of the libshortcut library. - */ - -/** - * @addtogroup SHORTCUT_MODULE - * @{ - */ - -/** - * @internal - * @brief Called to the add_to_home request. - * @details The homescreen should define a callback as this type and implement the service code - * for adding a new application shortcut. - * @since_tizen 2.3 - * @param[in] appid The shortcut that is added for this package - * @param[in] name The name of the created shortcut icon - * @param[in] type One of the three defined types - * @param[in] content_info The specific information for creating a new shortcut - * @param[in] icon The absolute path of an icon file for this shortcut - * @param[in] pid The process ID of who request add_to_home - * @param[in] allow_duplicate @c 1 if the shortcut can be duplicated, - * otherwise a shourtcut should exist only once - * @param[in] data The callback data - * @return The result of handling a shortcut creation request\n - * This returns @c 0 if the add_to_home request is handled successfully, - * otherwise it returns a proper errno. - * @see shortcut_set_request_cb() - */ -typedef int (*request_cb_t)(const char *appid, const char *name, int type, const char *content_info, const char *icon, int pid, double period, int allow_duplicate, void *data); - -/** - * @brief Called to receive the result of add_to_home_shortcut(). - * @since_tizen 2.3 - * @param[in] ret The result value, it could be @c 0 if it succeeds to add a shortcut, - * otherwise it returns an errno - * @param[in] pid The process ID of who handle this add_to_home request - * @param[in] data The callback data - * @return int @c 0 if there is no error, - otherwise errno - * @see add_to_home_shortcut() - */ -typedef int (*result_internal_cb_t)(int ret, int pid, void *data); - -/** - * @brief Enumeration for shortcut types. - * @details Basically, three types of shortcuts are defined. - * Every homescreen developer should support these types of shortcuts. - * Or return a proper errno to figure out why the application failed to add a shortcut. - * #LAUNCH_BY_PACKAGE is used for adding a package itself as a shortcut. - * #LAUNCH_BY_URI is used for adding a shortcut for "uri" data. - * @since_tizen 2.3 - */ -enum shortcut_internal_type { - /**< Deprecated type */ - SHORTCUT_PACKAGE = 0x00000000, /**< Launch the package using the given package name */ - SHORTCUT_DATA = 0x00000001, /**< Launch the related package with the given data(content_info) */ - SHORTCUT_FILE = 0x00000002, /**< Launch the related package with the given filename(content_info) */ - - LAUNCH_BY_PACKAGE = 0x00000000, - - SHORTCUT_REMOVE = 0x40000000, /**< Remove a shortcut */ - LIVEBOX_REMOVE = 0x80000000, /**< Remove a livebox */ - - LIVEBOX_TYPE_DEFAULT = 0x10000000, /**< Type mask for the default livebox */ - LIVEBOX_TYPE_EASY_DEFAULT = 0x30000000, /**< Type mask for the easy mode livebox */ - LIVEBOX_TYPE_1x1 = 0x10010000, /**< 1x1 */ - LIVEBOX_TYPE_2x1 = 0x10020000, /**< 2x1 */ - LIVEBOX_TYPE_2x2 = 0x10040000, /**< 2x2 */ - LIVEBOX_TYPE_4x1 = 0x10080000, /**< 4x1 */ - LIVEBOX_TYPE_4x2 = 0x10100000, /**< 4x2 */ - LIVEBOX_TYPE_4x3 = 0x10200000, /**< 4x3 */ - LIVEBOX_TYPE_4x4 = 0x10400000, /**< 4x4 */ - LIVEBOX_TYPE_4x5 = 0x11000000, /**< 4x5 */ - LIVEBOX_TYPE_4x6 = 0x12000000, /**< 4x6 */ - LIVEBOX_TYPE_EASY_1x1 = 0x30010000, /**< Easy mode 1x1 */ - LIVEBOX_TYPE_EASY_3x1 = 0x30020000, /**< Easy mode 3x2 */ - LIVEBOX_TYPE_EASY_3x3 = 0x30040000, /**< Easy mode 3x3 */ - LIVEBOX_TYPE_UNKNOWN = 0x1FFF0000, /**< Error */ -}; - -/** - * @brief Enumeration for values of shortcut response types. - * @since_tizen 2.3 - */ -enum shortcut_internal_error_e { - SHORTCUT_ERROR = 0x80000000, /**< MSB(1). Check this using the #SHORTCUT_STATUS_IS_ERROR macro */ - - SHORTCUT_STATUS_CARED = 0x08000000, /**< Shortcut status is already cared. Check this using the #SHORTCUT_STATUS_IS_CARED macro */ - - SHORTCUT_ERROR_BUSY = TIZEN_ERROR_RESOURCE_BUSY, /**< Receiver is busy, try again later */ - SHORTCUT_ERROR_UNSUPPORTED = SHORTCUT_ERROR | 0x0400 /**< Shortcut is not supported */ -}; - -/** - * @brief Definition for a macro to check type. - * @since_tizen 2.3 - * @param[in] type The type of box - * @return bool - * @retval true(1) If it is a livebox - * @retval false(0) If it is not a livebox - * @see shortcut_type - */ -#define ADD_TO_HOME_IS_LIVEBOX(type) (!!((type) & 0x10000000)) - -/** - * @brief Definition for a macro to check the request status. - * @since_tizen 2.3 - * @param[in] type The status - * @return bool - * @retval true(1) Error - * @retval false(0) Not an error - * @see shortcut_error_e - */ -#define SHORTCUT_STATUS_IS_ERROR(type) (!!((type) & SHORTCUT_ERROR)) - -/** - * @brief Definition for a macro to check the request status. - * @since_tizen 2.3 - * @param[in] type The status - * @return bool - * @retval true(1) Shortcut request is already handled by the requestee (homescreen, viewer, ...) - * @retval false(0) Request result should be cared by the requestor - * @see shortcut_error_e - */ -#define SHORTCUT_STATUS_IS_CARED(type) (!!((type) & SHORTCUT_STATUS_CARED)) - -/** - * @brief Definition for filtering the pure error code from the given status. - * @since_tizen 2.3 - * @param[in] status The status - * @return The status code (error) - * @see shortcut_error_e - */ -#define SHORTCUT_ERROR_CODE(status) ((status) & ~SHORTCUT_STATUS_CARED) - -/** - * - * @internal - * - * @brief Supports the shortcut creating request. - * - * @details - * Sync (or) Async: - * This is an asynchronous API. - * - * Important Notes: \n - * Should be used from the homescreen.\n - * Should check the return value of this function. - * - * Prospective Clients: - * Homescreen. - * - * @since_tizen 2.3 - * - * @privlevel public - * @privilege %http://tizen.org/privilege/shortcut - * - * @param[in] request_cb The callback function pointer that is invoked when add_to_home is requested - * @param[in] data The callback data to deliver to the callback function - * - * @return The return type (int) - * @retval 0 Callback function is successfully registered - * @retval <0 Failed to register the callback function for the request - * - * @pre You have to prepare a callback function. - * - * @post If a request is sent from the application, the registered callback will be invoked. - * - * @see request_cb_t - * @par Example - * @code - * #include <shortcut.h> - * - * static int request_cb(const char *appid, const char *name, int type, const char *content_info, const char *icon, int pid, void *data) - * { - * printf("Package name: %s\n", appid); - * printf("Name: %s\n", name); - * printf("Type: %d\n", type); - * printf("Content: %s\n", content_info); - * printf("Icon: %s\n", icon); - * printf("Requested from: %d\n", pid); - * printf("CBDATA: %p\n", data); - * return 0; // returns success. - * } - * - * static int app_create(void *data) - * { - * shortcut_set_request_cb(request_cb, NULL); - * return 0; - * } - * - * int main(int argc, char *argv[]) - * { - * appcore.... - * } - * - * @endcode - */ -extern int shortcut_set_request_cb(request_cb_t request_cb, void *data); - -/** - * - * @brief Supports the add_to_home feature, should invoke this. - * - * @details - * Sync (or) Async: - * This is an asynchronous API. - * - * Important Notes:\n - * Application must check the return value of this function.\n - * Application must check the return status from the callback function.\n - * Application should set the callback function to get the result of this request. - * - * Prospective Clients: - * Inhouse Apps. - * - * @since_tizen 2.3 - * - * @privlevel public - * @privilege %http://tizen.org/privilege/shortcut - * - * @remarks If a homescreen does not support this feature, you will get a proper error code. - * @param[in] appid The package name of the owner of this shortcut - * @param[in] name The name of the created shortcut icon - * @param[in] type The type of shortcuts (livebox or shortcut, and its size if it is for the livebox) - * @param[in] content_info The specific information for delivering to the viewer for creating a shortcut - * @param[in] icon The absolute path of an icon file - * @param[in] allow_duplicate @c 1 if it accepts the duplicated shortcut, - * otherwise @c 0 - * @param[in] result_cb The address of the callback function that is called when the result comes back from the viewer - * @param[in] data The callback data that is used in the callback function - * - * @return The return type (int) - * @retval 0 Succeeded to send the request - * @retval #SHORTCUT_ERROR_FAULT Unrecoverable error - * @retval #SHORTCUT_ERROR_INVALID_PARAMETER Shortcut request is not valid, invalid parameter or invalid argument value - * @retval #SHORTCUT_ERROR_COMM Connection is not estabilished. or there is a problem in the communication - * @retval #SHORTCUT_ERROR_OUT_OF_MEMORY Memory is not enough to handle a new request - * @retval #SHORTCUT_ERROR_IO_ERROR Unable to access the file or DB. Check your resource files - * @retval #SHORTCUT_ERROR_PERMISSION_DENIED Has no permission to add a shortcut - * @retval #SHORTCUT_ERROR_NOT_SUPPORTED Shortcut is not supported - * - * @pre You have to prepare the callback function. - * - * @post You have to check the return status from the callback function which is passed by the argument. - * - * @see result_internal_cb_t - * - * @par Example - * @code - * - * #include <stdio.h> - * #include <shortcut.h> - * - * static int result_cb(int ret, int pid, void *data) - * { - * if (ret < 0) - * printf("Failed to add a shortcut: %s\n", perror(ret)); - * - * printf("Processed by the %d\n", pid); - * return 0; - * } - * - * static int app_create(void *data) - * { - * add_to_home_shortcut("org.tizen.gallery", "With friends", - * LAUNCH_BY_URI, "gallery:0000-0000", - * "/opt/media/Pictures/Friends.jpg", 0, result_cb, NULL); - * return 0; - * } - * - * int main(int argc, char *argv[]) - * { - * appcore.... - * } - * - * @endcode - */ -extern int add_to_home_shortcut(const char *appid, const char *name, int type, const char *content_info, const char *icon, int allow_duplicate, result_internal_cb_t result_cb, void *data); - -/** - * - * @internal - * - * @brief Gets the installed shortcut view list. - * - * @details - * Sync (or) Async: - * This is a synchronous API. - * - * Important Notes:\n - * Application must check the return value of this function.\n - * Application must check the return status from the callback function.\n - * Application should set the callback function to get the result of this request. - * - * Prospective Clients: - * Inhouse Apps. - * - * @since_tizen 2.3 - * - * @privlevel public - * @privilege %http://tizen.org/privilege/shortcut - * - * @remarks If a homescreen does not support this feature, you will get a proper error code. - * @param[in] appid The package name - * @param[in] cb The callback function to get the shortcut item information - * @param[in] data The callback data that is used in the callback function - * - * @return The return type (int) - * @retval @c N Number of items (call count of the callback function) - * @retval #SHORTCUT_ERROR_FAULT Unrecoverable error - * @retval #SHORTCUT_ERROR_IO_ERROR Unable to access the file or DB. Check your resource files - * - * @pre You have to prepare the callback function. - * - * @post You have to check the return status from the callback function which is passed by the argument. - * - * @see result_internal_cb_t - */ -extern int shortcut_get_list(const char *appid, int (*cb)(const char *appid, const char *icon, const char *name, const char *extra_key, const char *extra_data, void *data), void *data); - -/** - * - * - * @brief Supports the add_to_home feature, should invoke this. - * - * @details - * Sync (or) Async: - * This is an asynchronous API. - * - * Important Notes:\n - * Application must check the return value of this function.\n - * Application must check the return status from the callback function.\n - * Application should set the callback function to get the result of this request. - * - * Prospective Clients: - * Inhouse Apps. - * - * @since_tizen 2.3 - * - * @privlevel public - * @privilege %http://tizen.org/privilege/shortcut - * - * @remarks If a homescreen does not support this feature, you will get a proper error code. - * @param[in] appid The package name of the owner of this shortcut - * @param[in] name The name of the created shortcut icon - * @param[in] type The type of shortcuts (livebox or shortcut, and its size if it is for the livebox) - * @param[in] content_info The specific information for delivering to the viewer for creating a shortcut - * @param[in] icon The absolute path of an icon file - * @param[in] period The update period - * @param[in] allow_duplicate @c 1 if it accepts the duplicated shortcut, - * otherwise @c 0 - * @param[in] result_cb The address of the callback function that is called when the result comes back from the viewer - * @param[in] data The callback data that is used in the callback function - * - * @return The return type (int) - * @retval 0 Succeeded to send the request - * @retval #SHORTCUT_ERROR_FAULT Unrecoverable error - * @retval #SHORTCUT_ERROR_INVALID_PARAMETER Shortcut request is not valid, invalid parameter or invalid argument value - * @retval #SHORTCUT_ERROR_COMM Connection is not established or there is a problem in the communication - * @retval #SHORTCUT_ERROR_OUT_OF_MEMORY Memory is not enough to handle a new request - * @retval #SHORTCUT_ERROR_IO_ERROR Unable to access the file or DB Check your resource files - * @retval #SHORTCUT_ERROR_PERMISSION_DENIED Has no permission to add a shortcut - * @retval #SHORTCUT_ERROR_NOT_SUPPORTED Shortcut is not supported - * - * @pre You have to prepare the callback function. - * - * @post You have to check the return status from the callback function which is passed by the argument. - * - * @see result_internal_cb_t - * - * @par Example - * @code - * - * #include <stdio.h> - * #include <shortcut.h> - * - * static int result_cb(int ret, int pid, void *data) - * { - * if (ret < 0) - * printf("Failed to add a shortcut: %s\n", perror(ret)); - * - * printf("Processed by the %d\n", pid); - * return 0; - * } - * - * static int app_create(void *data) - * { - * add_to_home_livebox("org.tizen.gallery.livebox", "With friends", - * LAUNCH_BY_URI, "gallery:0000-0000", - * "/opt/media/Pictures/Friends.jpg", -1.0f, 0, result_cb, NULL); - * return 0; - * } - * - * int main(int argc, char *argv[]) - * { - * appcore.... - * } - * - * @endcode - */ -extern int add_to_home_livebox(const char *appid, const char *name, int type, const char *content, const char *icon, double period, int allow_duplicate, result_internal_cb_t result_cb, void *data); - -struct shortcut_icon; - -/** - * @brief Called when send a request to create a icon snapshot image. - * @details This callback will be called with its result. - * @param[in] handle Handle of requestor - * @param[in] ret status of request - * @param[in] data Callback data - * @return int result state of callback call - * @retval 0 If it is successfully completed - * @see shortcut_icon_request_send() - */ -typedef int (*icon_request_cb_t)(struct shortcut_icon *handle, int ret, void *data); - -#define DEFAULT_ICON_PART "icon" -#define DEFAULT_NAME_PART "name" -#define SHORTCUT_ICON_TYPE_IMAGE "image" -#define SHORTCUT_ICON_TYPE_TEXT "text" -#define SHORTCUT_ICON_TYPE_SCRIPT "script" - -/** - * @brief Initializes the icon creation service. - * @param[in] init_cb Initialized result will be delievered via this callback - * @param[in] data Callback data - * @return int value - * @retval #SHORTCUT_ERROR_INVALID_PARAMETER Already initialized - * @retval #SHORTCUT_ERROR_NONE Successfully initialized - * @see shortcut_icon_service_fini() - */ -extern int shortcut_icon_service_init(int (*init_cb)(int status, void *data), void *data); - -/** - * @brief Finalizes the icon creation service. - * @return int value - * @retval #SHORTCUT_ERROR_NONE Successfully initialized - * @retval #SHORTCUT_ERROR_INVALID_PARAMETER icon service is not initialized - * @see shortcut_icon_service_init() - */ -extern int shortcut_icon_service_fini(void); - -/** - * @brief Creates a request object to create a new icon image. - * @return struct shortcut_icon * value - * @retval @c NULL If it fails to create a new handle - * @retval pointer Handle address - * @see shortcut_icon_request_destroy() - */ -extern struct shortcut_icon *shortcut_icon_request_create(void); - -/** - * @brief Sets information for creating icon image. - * @param[in] handle Request handle - * @param[in] id Target ID to be affected by this data - * @param[in] type SHORTCUT_ICON_TYPE_IMAGE, SHORTCUT_ICON_TYPE_TEXT, SHORTCUT_ICON_TYPE_SCRIPT can be used - * @param[in] part Target part to be affect by this data - * @param[in] data type == IMAGE ? Image file path : type == TEXT ? text string : type == SCRIPT ? script file path : N/A - * @param[in] option Image load option or group name of script file to be loaded - * @param[in] subid ID for script. this ID will be used as "id" - * @return int value - * @retval index Index of data set - * @retval #SHORTCUT_ERROR_INVALID_PARAMETER Invalid handle - * @retval #SHORTCUT_ERROR_OUT_OF_MEMORY Out of memory - * @see shortcut_icon_request_create() - */ -extern int shortcut_icon_request_set_info(struct shortcut_icon *handle, const char *id, const char *type, const char *part, const char *data, const char *option, const char *subid); - -/** - * @brief Sends requests to create an icon image. - * @param[in] handle Icon request handle - * @param[in] size_type Size type to be created - * @param[in] layout Layout filename (edje filename) - * @param[in] group Group name - * @param[in] outfile Output image filename - * @param[in] result_cb Result callback - * @param[in] data Callback data - * @return int value - * @retval #SHORTCUT_ERROR_INVALID_PARAMETER Invalid parameters - * @retval #SHORTCUT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #SHORTCUT_ERROR_FAULT Failed to send a request - * @retval #SHORTCUT_ERROR_NONE Successfully sent - * @see shortcut_icon_service_fini() - */ -extern int shortcut_icon_request_send(struct shortcut_icon *handle, int size_type, const char *layout, const char *group, const char *outfile, icon_request_cb_t result_cb, void *data); - -/** - * @brief Destroys handle of creating shortcut icon request. - * @param[in] handle Shortcut request handle - * @return int value - * @retval #SHORTCUT_ERROR_INVALID_PARAMETER Invalid handle - * @retval #SHORTCUT_ERROR_NONE Successfully destroyed - * @see shortcut_icon_service_fini() - */ -extern int shortcut_icon_request_destroy(struct shortcut_icon *handle); - - -/** - * @brief Sets private data to the handle to carry it with a handle. - * @param[in] handle Handle to be used for carrying a data - * @param[in] data Private data - * @return int value - * @retval #SHORTCUT_ERROR_INVALID_PARAMETER Invalid handle - * @retval #SHORTCUT_ERROR_NONE Successfully done - * @see shortcut_icon_service_fini() - */ -extern int shortcut_icon_request_set_data(struct shortcut_icon *handle, void *data); - -/** - * @brief Gets the private data from handle. - * @param[in] handle - * @return int value - * @retval @c NULL If there is no data - * @retval pointer data pointer - * @see shortcut_icon_request_set_data() - */ -extern void *shortcut_icon_request_data(struct shortcut_icon *handle); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/include/shortcut_PG.h b/lib/include/shortcut_PG.h deleted file mode 100644 index 75c4f26..0000000 --- a/lib/include/shortcut_PG.h +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. - * - * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 - * - * 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. - * -*/ - -/** - * @ingroup SLP_PG - * @defgroup SHORTCUT_PG Add to home (shortcut) - * @{ -<H1>1. Shortcut</H1> -Tizen is supporting the "add shortcut or add to home" for various applications. -Developers may use the shortcut library (libshortcut) to implement features sending (applications) and receiving (possibly home screen) shortcuts. -If home screen implements the shortcut service using the library, the applications are good to go for adding their shortcuts to the home screen(, and vice versa.) - -<H1>2. How to add a new shortcut to the home screen</H1> -<H2>2.1 Add to home (From the app to home)</H2> - -The followings are two separate APIs to support "add to home" feature. - -\code -typedef int (*result_cb_t)(int ret, int pid, void *data) - -extern int add_to_home_shortcut(const char *pkgname, const char *name, int type, const char *content_info, const char *icon, result_cb_t result_cb, void *data) - -extern int add_to_home_livebox(const char *pkgname, const char *name, int type, const char *content, const char *icon, double period, result_cb_t result_cb, void *data) -\endcode - -Currently, our home screen can contain two different types of contents (that are pure shortcuts and liveboxes). - -To add a pure shortcut i.e., simply for launching an app, developers can use "add_to_home_shortcut" API to deliver their shortcuts to a home screen. - -If your application supports our livebox service and implments livebox type shortcut, then you can use "add_to_home_livebox" API to have a home screen add the livebox on its screen. - -<TABLE> -<TR><TH>Parameters</TH><TH>Comment</TH></TR> -<TR><TD>pkgname</TD><TD>Package name</TD></TR> -<TR><TD>name</TD><TD>Application name wich will be displayed on the screen</TD></TR> -<TR><TD>type</TD><TD>Basically it describes launching options whether to use a package name or URI. LAUNCH_BY_PACKAGE or LAUNCH_BY_URI</TD></TR> -<TR><TD>content</TD><TD> -Application data used for creating a pure shortcut or creating a livebox - - Shortcut - -1. if the type is Launch by package: None - -2. if the type is Launch by URI: put the URI in the content - - Livebox: any data necessary to create a livebox. Basically, it will passed to the livebox plug-in's create function. -</TD></TR> -<TR><TD>icon</TD><TD>Absolute path to the icon file, If you set this "NULL", the home screen will use the deafult icon file (but it is depends on the homescreen implementations)</TD></TR> -<TR><TD>period</TD><TD><Only for livebox> Update period. The period must be greater than 0.0f</TD></TR> -<TR><TD>result_cb</TD><TD>Result callback. The callback will be called after a shortcut or livebox has been added. Don't forget to check the return value.</TD></TR> -<TR><TD>data</TD><TD>Callback data</TD></TR> -</TABLE> - -<H3>2.1.1 Supported types</H3> -\snippet lib/include/shortcut.h Enumeration values for type of shortcuts - -<H2>2.2 Add shortcut (Home screen retrieves shortcuts from app)</H2> -"Add shortcut " service enables home screen to retrieve all shortcuts that applications promised to support and request an app to send their shortcuts to home directly, as opposed to "add to home". - -It is initiated by home screen as opposed to "add to home" which is initiated by an application."Add shortcut " service enables home screen to retrieve all shortcuts that applications promised to support and request an app to send their shortcuts to home directly, as opposed to "add to home". - -It is initiated by home screen as opposed to "add to home" which is initiated by an application. - -<H3>2.2.1 Build the shortcut list DB</H3> -\image html BuildShortcutList.png - -To recognize how many and what kinds of shortcuts have been registerred, each application who wants to support "add shortcut" service needs to install the XML file that defines "shortcut" information. -The following table describes the format and information necessary to define the shortcuts application can support. -Then, the information will be shown and used in home screen when a user selects "add shortcut" service. - -<TABLE> -<TH><TD>Syntax of the shortcut manifest file</TD></TH> -<TR><TD> -\code -<manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.APP_PKGNAME"> -... - <shortcut-list> - <shortcut appid="org.tizen.myapp" extra_key="key_string" extra_data="data_string_for_key"> - <icon>/opt/share/icons/default/small/org.tizen.myapp-shortcut.png</icon> - <label>Default name</label> - <label xml:lang="en-us">Name en</label> - <label xml:lang="nl-nl">Name nl</label> - <label xml:lang="de-de">Name de</label> - <label xml:lang="zh-hk">Name hk</label> - <label xml:lang="zh-cn">Name cn</label> - <label xml:lang="ru-ru">Name ru</label> - <label xml:lang="zh-tw">Name tw</label> - <label xml:lang="ja-jp">Name jp</label> - <label xml:lang="es-es">Name es</label> - <label xml:lang="el-gr">Name gr</label> - <label xml:lang="it-it">Name it</label> - <label xml:lang="tr-tr">Name tr</label> - <label xml:lang="pt-pt">Name pt</label> - <label xml:lang="fr-fr">Name fr</label> - <label xml:lang="ko-kr">Name kr</label> - </shortcut> - <shortcut appid="org.tizen.myapp" extra_key="key_string" extra_data="data_string_for_key"> - <label>Default name</label> - </shortcut> - ... - <shortcut appid="org.tizen.myapp" extra_key="key_string" extra_data="data_string_for_key"> - <label>Default name</label> - <icon>/opt/share/icons/default/small/org.tizen.myapp2.png</icon> - </shortcut> - </shortcut-list> -... -</manifest> -\endcode -</TD></TR> -</TABLE> - -Install this XML file to /opt/share/packages/YOUR_PKGNAME.xml (Note: After manifest has been applied to the binary, simply copy the content to your manifest file.) -Shortcut listing application will list up these items on its screen and each item will be displayed using the string in label field. -When selected, it will launch the selected app using app service with "appid" and a bundle holding data in the pair of extra_key and extra-data fields. -Obviously, icon will be used to display visual information for given shortcut type.(that said the icon could be other than the application's default icon) - -<H3>2.2.2 Jump to the APP</H3> -\image html JumpToApp.png - -Shortcut listing application will launch your application using app-svc with package name and param attributes. -It will use the pkgname and param attrbute to launch your application. -Shortcut list view will launch your "[App] Shortcut list" using followed code. - -<TABLE> -<TH><TD>Launch your app from shortcut list viewer</TD></TH> -<TR><TD> -\code -service_h service; -service_create(&service); -service_set_package(service, APPID); /* <shortcut appid="APPID" ...> */ -service_add_extra_data(service, EXTRA_KEY, EXTRA_DATA); /* <shortcut extra_key="EXTRA_KEY" extra_data="EXTRA_DATA" ...> */ -ret = service_send_launch_request(service, NULL, NULL); -if (ret ...) { } -service_destroy(service); -\endcode -</TD></TR> -</TABLE> -When your app is launched, the app should send a selected item as a shortcut or livebox to the home screen using "add_to_home" series functions mentioned above. - -<H3>2.2.3 What each app has to do</H3> -You can implement your shortcut list view using App or UG. - -Who is going to handle the shortcut - -<UL> -<LI>Handled by App - <LI>App should prepare a shortcut-add view as guided</LI> -</LI> -<LI>Handeld by UG - <LI>UG should be launched as an app and provide the shortcut-add view</LI> -</LI> -</UL> - -In your shortcut list view, you just call the "add_to_home_shortcut" or "add_to_home_livebox" which are described in the section 2.1 - -<H4>2.2.3.1 Handled by App</H4> -\image html ShortcutApp.png -When your application is launched by the shortcut list application (displayed on the left most of above figure). -Your application should go back to the normal view when you receive the PAUSE event. -If you didn't change the view of your application, the user will see this shortcut list view again even if the user -launches your application from the app-tray(or homescreen). -So you have to change the view from the shortcut list to the normal(or previous) view when you get the PAUSE event. - -<H4>2.2.3.2 Handled by UG</H4> -\image html ShortcutUG.png -In this case, the Shortcut List application will launch your UG as a process. -When you receive PAUSE event, or need to change to other view (not in the same UG), you should destroy current UG. -If you didn't destroy it, it will be reside on the process list. and it will not be destroyed automatically. - -Currently, UG container process only supporting the multiple instance for a process. -So if the user tries to add a new shortcut again from the shortcut list application, your UG will be launched again if you didn't -terminate previous UG process (when you got PAUSE event). - -<H1>3. What the home screen should do</H1> -\code -typedef int (*request_cb_t)(const char *pkgname, const char *name, int type, const char *content_info, const char *icon, int pid, double period, void *data) -extern int shortcut_set_request_cb(request_cb_t request_cb, void *data) -\endcode - -<TABLE> -<TR><TH>Parameter</TH><TH>Comment</TH></TR> -<TR><TD>pkgname</TD><TD>Package name to be added</TD></TR> -<TR><TD>name</TD><TD>Application name to be displayed on the screen</TD></TR> -<TR><TD>type</TD><TD>LAUNCH_BY_PACKAGE or LAUNCH_BY_URI</TD></TR> -<TR><TD>content_info</TD><TD>Used for the livebox, or homescreen by itself if it required.</TD></TR> -<TR><TD>icon</TD><TD>Absolute path of the icon file. (If it is not exists, the homescreen can use the deafult icon file)</TD></TR> -<TR><TD>pid</TD><TD>Reuquestor's Process ID</TD></TR> -<TR><TD>period</TD><TD>Update period only for the livebox</TD></TR> -<TR><TD>data</TD><TD>Callback data</TD></TR> -</TABLE> - -<H1>4. To list up shortcuts registred in the device</H1> -<TABLE> -<TR><TH>shortcut-list viewer will launch your app by this way</TH></TR> -<TR><TD> -\code -int shortcut_get_list(const char *pkgname, int (*cb)(const char *pkgname, const char *icon, const char *name, const char *extra_key, const char *extra_data, void *data), void *data) -\endcode -</TD></TR> -</TABLE> - -If you specified the "pkgname", this API will only gathering the given Package's shortcut list. -If you set is to NULL, this API will gathering all shortcuts. -Every shortcut item will be passed via "cb" callback function. so it will be invoked N times if the number of registered shortcut item is N. -pkgname and name and param is described in the XML file of each application package. -It will returns the number of shortcut items, or return <0 as an error value. - --EIO : failed to access shortcut list DB -> 0 : Number of shortcut items (count of callback function calling) - * - * @} -*/ diff --git a/lib/include/shortcut_internal.h b/lib/include/shortcut_internal.h deleted file mode 100644 index 51c2162..0000000 --- a/lib/include/shortcut_internal.h +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. - * - * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 - * - * 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. - * -*/ - -#if !defined(SECURE_LOGD) -#define SECURE_LOGD LOGD -#endif - -#if !defined(SECURE_LOGE) -#define SECURE_LOGE LOGE -#endif - -#if !defined(SECURE_LOGW) -#define SECURE_LOGW LOGW -#endif - -#if !defined(FLOG) -#define DbgPrint(format, arg...) SECURE_LOGD(format, ##arg) -#define ErrPrint(format, arg...) SECURE_LOGE(format, ##arg) -#else -extern FILE *__file_log_fp; -#define DbgPrint(format, arg...) do { fprintf(__file_log_fp, "[LOG] [[32m%s/%s[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0) - -#define ErrPrint(format, arg...) do { fprintf(__file_log_fp, "[ERR] [[32m%s/%s[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0) -#endif - -#if !defined(EAPI) -#define EAPI __attribute__((visibility("default"))) -#endif - -#if !defined(VCONFKEY_MASTER_STARTED) -#define VCONFKEY_MASTER_STARTED "memory/data-provider-master/started" -#endif - -#define DEFAULT_ICON_LAYOUT "" -#define DEFAULT_ICON_GROUP "" - -/** - * @brief Definition for a macro to check the request type. - * @since_tizen 2.3 - * @param[in] type Request type - * @return bool - * @retval true(1) Shortcut remove request - * @retval false(0) Not a remove request - * @see shortcut_type - */ -#define ADD_TO_HOME_IS_REMOVE_SHORTCUT(type) (!!((type) & SHORTCUT_REMOVE)) - -/** - * @brief Definition for a macro to check the request type. - * @since_tizen 2.3 - * @param[in] type Request type - * @return bool - * @retval true(1) Dynamicbox remove request - * @retval false(0) Not a remove request - * @see shortcut_type - */ -#define ADD_TO_HOME_IS_REMOVE_LIVEBOX(type) (!!((type) & LIVEBOX_REMOVE)) - -/** - * @brief Called to receive the result of add_to_home_shortcut(). - * @since_tizen 2.3 - * @param[in] ret The result value, it could be @c 0 if it succeeds to add a shortcut, - * otherwise it returns an errno - * @param[in] pid The process ID of who handle this add_to_home request - * @param[in] data The callback data - * @return int @c 0 if there is no error, - otherwise errno - * @see add_to_home_shortcut() - */ -typedef int (*result_internal_cb_t)(int ret, int pid, void *data); - -/** - * - * - * @brief The application, which supporting the add_to_home feature, should invoke this. - * - * @details - * Sync (or) Async: - * This is an asynchronous API. - * - * Important Notes:\n - * Application must check the return value of this function.\n - * Application must check the return status from the callback function\n - * Application should set the callback function to get the result of this request. - * - * Prospective Clients: - * Inhouse Apps. - * - * @since_tizen 2.3 - * - * @remarks - If a homescreen does not support this feature, you will get proper error code. - * @param[in] appid Package name of owner of this shortcut. - * @param[in] name Name for created shortcut icon. - * @param[in] content_info Specific information for delivering to the viewer for creating a shortcut. - * @param[in] result_cb Address of callback function which will be called when the result comes back from the viewer. - * @param[in] data Callback data which will be used in callback function - * - * @return Return Type (int) - * \retval 0 Succeed to send the request - * \retval #SHORTCUT_ERROR_FAULT Unrecoverable error - * \retval #SHORTCUT_ERROR_INVALID_PARAMETER Shortcut request is not valid, invalid parameter or invalid argument value - * \retval #SHORTCUT_ERROR_COMM Connection is not estabilished. or there is a problem of communication - * \retval #SHORTCUT_ERROR_OUT_OF_MEMORY Memory is not enough to handle new request - * \retval #SHORTCUT_ERROR_IO_ERROR Unable to access file or DB. Check your resource files - * \retval #SHORTCUT_ERROR_PERMISSION_DENIED Has no permission to add a shortcut - * - * @pre You have to prepare the callback function - * - * @post You have to check the return status from callback function which is passed by argument. - * - * @see result_internal_cb_t - * - * @par Example - * @code - * - * #include <stdio.h> - * #include <shortcut.h> - * - * static int result_cb(int ret, int pid, void *data) - * { - * if (ret < 0) - * printf("Failed to add a shortcut: %s\n", perror(ret)); - * - * printf("Processed by the %d\n", pid); - * return 0; - * } - * - * static int app_create(void *data) - * { - * add_to_home_remove_shortcut("org.tizen.gallery.livebox", "With friends", - * "gallery:0000-0000", - * result_cb, NULL); - * return 0; - * } - * - * int main(int argc, char *argv[]) - * { - * appcore.... - * } - * - * @endcode - */ -extern int add_to_home_remove_shortcut(const char *appid, const char *name, const char *content_info, result_internal_cb_t result_cb, void *data); - -/** - * - * - * @brief The application, which supporting the add_to_home feature, should invoke this. - * - * @details - * Sync (or) Async: - * This is an asynchronous API. - * - * Important Notes:\n - * Application must check the return value of this function.\n - * Application must check the return status from the callback function\n - * Application should set the callback function to get the result of this request. - * - * Prospective Clients: - * Inhouse Apps. - * - * @since_tizen 2.3 - * - * @remarks - If a homescreen does not support this feature, you will get proper error code. - * @param[in] appid Package name of owner of this shortcut. - * @param[in] name Name for created shortcut icon. - * @param[in] result_cb Address of callback function which will be called when the result comes back from the viewer. - * @param[in] data Callback data which will be used in callback function - * - * @return Return Type (int) - * \retval 0 Succeed to send the request - * \retval #SHORTCUT_ERROR_FAULT Unrecoverable error - * \retval #SHORTCUT_ERROR_INVALID_PARAMETER Shortcut request is not valid, invalid parameter or invalid argument value - * \retval #SHORTCUT_ERROR_COMM Connection is not estabilished. or there is a problem of communication - * \retval #SHORTCUT_ERROR_OUT_OF_MEMORY Memory is not enough to handle new request - * \retval #SHORTCUT_ERROR_IO_ERROR Unable to access file or DB. Check your resource files - * \retval #SHORTCUT_ERROR_PERMISSION_DENIED Has no permission to add a shortcut - * - * @pre You have to prepare the callback function - * - * @post You have to check the return status from callback function which is passed by argument. - * - * @see result_internal_cb_t - * - * @par Example - * @code - * - * #include <stdio.h> - * #include <shortcut.h> - * - * static int result_cb(int ret, int pid, void *data) - * { - * if (ret < 0) - * printf("Failed to add a shortcut: %s\n", perror(ret)); - * - * printf("Processed by the %d\n", pid); - * return 0; - * } - * - * static int app_create(void *data) - * { - * add_to_home_remove_livebox("org.tizen.gallery.livebox", "With friends", result_cb, NULL); - * return 0; - * } - * - * int main(int argc, char *argv[]) - * { - * appcore.... - * } - * - * @endcode - */ -extern int add_to_home_remove_livebox(const char *appid, const char *name, result_internal_cb_t result_cb, void *data); - -/* End of a file */ diff --git a/lib/include/shortcut_manager.h b/lib/include/shortcut_manager.h deleted file mode 100644 index 5cbab0b..0000000 --- a/lib/include/shortcut_manager.h +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. - * - * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 - * - * 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 __SHORTCUT_MANAGER_H__ -#define __SHORTCUT_MANAGER_H__ - -#include <tizen.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file shortcut_manager.h - * @brief This file declares the API of the libshortcut library. - */ - -/** - * @addtogroup SHORTCUT_MODULE - * @{ - */ - -/** - * @brief Called to receive the result of shortcut_add_to_home(). - * @since_tizen 2.3 - * @param[in] ret The result value, it could be @c 0 if it succeeds to add a shortcut, - * otherwise it returns an errno - * @param[in] data The callback data - * @return int @c 0 if there is no error, - otherwise errno - * @see shortcut_add_to_home() - */ -typedef int (*result_cb_t)(int ret, void *data); - -/** - * @brief Enumeration for shortcut types. - * @details Basically, two types of shortcuts are defined. - * Every homescreen developer should support these types of shortcuts. - * Or return a proper errno to figure out why the application failed to add a shortcut. - * #LAUNCH_BY_APP is used for adding a package itself as a shortcut. - * #LAUNCH_BY_URI is used for adding a shortcut for "uri" data. - * @since_tizen 2.3 - */ -typedef enum _shortcut_type { - /**< Use these */ - LAUNCH_BY_APP = 0x00000000, /**< Launch the application itself */ - LAUNCH_BY_URI = 0x00000001, /**< Launch the application with the given data(URI) */ -} shortcut_type; - -/** - * @brief Enumeration for values of shortcut response types. - * @since_tizen 2.3 - */ -enum shortcut_error_e { - SHORTCUT_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successfully handled */ - SHORTCUT_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Shortcut request is not valid, invalid parameter or invalid argument value */ - SHORTCUT_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Memory is not enough to handle a new request */ - SHORTCUT_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< Unable to access the file or DB. Check your resource files */ - SHORTCUT_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Has no permission to add a shortcut */ - SHORTCUT_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported shortcut */ - SHORTCUT_ERROR_RESOURCE_BUSY = TIZEN_ERROR_RESOURCE_BUSY, /**< Receiver is busy, try again later */ - SHORTCUT_ERROR_NO_SPACE = TIZEN_ERROR_SHORTCUT | 0x0001, /**< There is no space to add a new shortcut */ - SHORTCUT_ERROR_EXIST = TIZEN_ERROR_SHORTCUT | 0x0002, /**< Shortcut is already added */ - SHORTCUT_ERROR_FAULT = TIZEN_ERROR_SHORTCUT | 0x0004, /**< Failed to add a shortcut. Unrecoverable error */ - SHORTCUT_ERROR_COMM = TIZEN_ERROR_SHORTCUT | 0x0040 /**< Connection is not established. or there is a problem in the communication */ -}; - -/** - * - * @brief Supports the add_to_home feature, should invoke this. - * - * @details - * Sync (or) Async: - * This is an asynchronous API. - * - * @since_tizen 2.3 - * - * @privlevel public - * @privilege %http://tizen.org/privilege/shortcut - * - * @remarks Application must check the return value of this function.\n - * Application must check the return status from the callback function.\n - * Application should set the callback function to get the result of this request. - * @remarks If a homescreen does not support this feature, you will get a proper error code. - * - * @param[in] name The name of the created shortcut icon - * @param[in] type The type of shortcuts - * @param[in] uri The specific information for delivering to the viewer for creating a shortcut - * @param[in] icon The absolute path of an icon file - * @param[in] allow_duplicate @c 1 if it accepts the duplicated shortcut, - * otherwise @c 0 - * @param[in] result_cb The address of the callback function that is called when the result comes back from the viewer - * @param[in] data The callback data that is used in the callback function - * - * @return @c 0 on success, otherwise a negative error value - * @retval #SHORTCUT_ERROR_NONE Successful - * @retval #SHORTCUT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #SHORTCUT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #SHORTCUT_ERROR_IO_ERROR I/O error - * @retval #SHORTCUT_ERROR_PERMISSION_DENIED Permission denied - * @retval #SHORTCUT_ERROR_NOT_SUPPORTED Not supported - * @retval #SHORTCUT_ERROR_RESOURCE_BUSY Device or resource busy - * @retval #SHORTCUT_ERROR_NO_SPACE No space - * @retval #SHORTCUT_ERROR_EXIST Already exist - * @retval #SHORTCUT_ERROR_FAULT Unrecoverable error - * @retval #SHORTCUT_ERROR_COMM Connection failed - * - * @pre You have to prepare the callback function. - * - * @post You have to check the return status from the callback function which is passed by the argument. - * - * @see result_cb_t - * - * @par Example - * @code - * - * #include <stdio.h> - * #include <shortcut_manager.h> - * - * static int result_cb(int ret, int pid, void *data) - * { - * if (ret < 0) - * printf("Failed to add a shortcut: %s\n", perror(ret)); - * - * printf("Processed by the %d\n", pid); - * return 0; - * } - * - * static int app_create(void *data) - * { - * char* data_path = app_get_data_path(); - * int path_len = strlen(data_path)+10; - * char * path = malloc(path_len); - * memset(path, 0, path_len); - * strncat(path, data_path, path_len); - * strncat(path, "Friend.jpg", path_len); - * - * shortcut_add_to_home("With friends", - * LAUNCH_BY_URI, "gallery:0000-0000", - * path, 0, result_cb, NULL); - * free(path); - * - * return 0; - * } - * - * int main(int argc, char *argv[]) - * { - * appcore.... - * } - * - * @endcode - */ -extern int shortcut_add_to_home(const char *name, shortcut_type type, const char *uri, const char *icon, int allow_duplicate, result_cb_t result_cb, void *data); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/shortcut.pc.in b/lib/shortcut.pc.in deleted file mode 100644 index 060e119..0000000 --- a/lib/shortcut.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@PREFIX@ -exec_prefix=@EXEC_PREFIX@ -libdir=@LIBDIR@ -includedir=@INCLUDEDIR@ - -Name: shortcut -Description: shortcut server platform library -Version: @VERSION@ -Requires: capi-base-common -Libs: -L${libdir} -lshortcut -Cflags: -I${includedir} diff --git a/lib/src/dlist.c b/lib/src/dlist.c deleted file mode 100644 index 3ae571b..0000000 --- a/lib/src/dlist.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright 2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.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 <stdio.h> -#include <stdlib.h> -#include <assert.h> - -#include "dlist.h" - -/*! - * \brief - * This dlist is called Modified Doubly Linked List. - * - * Noramlly, The dobule linked list contains address of previous and next element. - * This dlist also contains them, but the tail element only contains prev address. - * - * The head element's prev pointer indicates the last element. - * But the last element's next pointer indicates NIL. - * - * So we can find the last element while crawling this DList - * But we have to remember the address of the head element. - */ - -struct dlist { - struct dlist *next; - struct dlist *prev; - void *data; -}; - -struct dlist *dlist_append(struct dlist *list, void *data) -{ - struct dlist *item; - - item = malloc(sizeof(*item)); - if (!item) { - return NULL; - } - - item->next = NULL; - item->data = data; - - if (!list) { - item->prev = item; - - list = item; - } else { - item->prev = list->prev; - item->prev->next = item; - list->prev = item; - } - - assert(!list->prev->next && "item NEXT"); - - return list; -} - -struct dlist *dlist_prepend(struct dlist *list, void *data) -{ - struct dlist *item; - - item = malloc(sizeof(*item)); - if (!item) { - return NULL; - } - - item->data = data; - - if (!list) { - item->prev = item; - item->next = NULL; - } else { - if (list->prev->next) { - list->prev->next = item; - } - - item->prev = list->prev; - item->next = list; - - list->prev = item; - - } - - return item; -} - -struct dlist *dlist_remove(struct dlist *list, struct dlist *l) -{ - if (!list || !l) { - return NULL; - } - - if (l == list) { - list = l->next; - } else { - l->prev->next = l->next; - } - - if (l->next) { - l->next->prev = l->prev; - } - /*! - * \note - * If the removed entry 'l' has no next element, it is the last element. - * In this case, check the existence of the list first, - * and if the list is not empty, update the 'prev' of the list (which is a head element of the list) - * - * If we didn't care about this, the head element(list) can indicates the invalid element. - */ - else if (list) { - list->prev = l->prev; - } - - free(l); - return list; -} - -struct dlist *dlist_find_data(struct dlist *list, void *data) -{ - struct dlist *l; - void *_data; - - dlist_foreach(list, l, _data) { - if (data == _data) { - return l; - } - } - - return NULL; -} - -void *dlist_data(struct dlist *l) -{ - return l ? l->data : NULL; -} - -struct dlist *dlist_next(struct dlist *l) -{ - return l ? l->next : NULL; -} - -struct dlist *dlist_prev(struct dlist *l) -{ - return l ? l->prev : NULL; -} - -int dlist_count(struct dlist *l) -{ - register int i; - struct dlist *n; - void *data; - - i = 0; - dlist_foreach(l, n, data) { - i++; - } - - return i; -} - -struct dlist *dlist_nth(struct dlist *l, int nth) -{ - register int i; - struct dlist *n; - - i = 0; - for (n = l; n; n = n->next) { - if (i == nth) { - return n; - } - i++; - } - - return NULL; -} - -/* End of a file */ diff --git a/lib/src/icon.c b/lib/src/icon.c deleted file mode 100644 index 4e0619b..0000000 --- a/lib/src/icon.c +++ /dev/null @@ -1,817 +0,0 @@ -/* - * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. - * - * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 - * - * 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 <stdio.h> -#include <stdlib.h> -#include <errno.h> -#include <unistd.h> -#include <fcntl.h> -#include <string.h> -#include <sys/socket.h> -#include <sys/ioctl.h> -#include <libgen.h> -#include <sys/time.h> -#include <time.h> - -#include <dlog.h> -#include <glib.h> -#include <db-util.h> -#include <vconf.h> -#include <vconf-keys.h> - -#include <packet.h> -#include <com-core.h> -#include <com-core_packet.h> - -#include "shortcut_internal.h" -#include "shortcut.h" -#include "dlist.h" - - - -#define CREATED 0x00BEEF00 -#define DESTROYED 0x00DEAD00 - -static struct info { - int fd; - int (*init_cb)(int status, void *data); - void *cbdata; - int initialized; - - const char *utility_socket; - - struct dlist *pending_list; -#if defined(_USE_ECORE_TIME_GET) - clockid_t type; -#endif -} s_info = { - .fd = -1, - .init_cb = NULL, - .cbdata = NULL, - .initialized = 0, - - .utility_socket = "/tmp/.utility.service", - .pending_list = NULL, -#if defined(_USE_ECORE_TIME_GET) - .type = CLOCK_MONOTONIC, -#endif -}; - - - -struct request_item { - struct shortcut_icon *handle; - icon_request_cb_t result_cb; - void *data; -}; - - - -struct pending_item { - struct request_item *item; - struct packet *packet; -}; - - - -struct block { - unsigned int idx; - - char *type; - char *part; - char *data; - char *option; - char *id; - char *target_id; -}; - - - -struct shortcut_icon { - unsigned int state; - struct shortcut_desc *desc; - int refcnt; - void *data; -}; - - - -struct shortcut_desc { - int for_pd; - - unsigned int last_idx; - - struct dlist *block_list; -}; - - - -static inline void delete_block(struct block *block) -{ - DbgPrint("Release block: %p\n", block); - free(block->type); - free(block->part); - free(block->data); - free(block->option); - free(block->id); - free(block->target_id); - free(block); -} - - - -static inline int shortcut_icon_desc_close(struct shortcut_desc *handle) -{ - struct dlist *l; - struct dlist *n; - struct block *block; - - dlist_foreach_safe(handle->block_list, l, n, block) { - handle->block_list = dlist_remove(handle->block_list, l); - delete_block(block); - } - - free(handle); - return 0; -} - - - -static inline struct shortcut_icon *shortcut_icon_request_unref(struct shortcut_icon *handle) -{ - handle->refcnt--; - DbgPrint("Handle: refcnt[%d]\n", handle->refcnt); - - if (handle->refcnt == 0) { - handle->state = DESTROYED; - shortcut_icon_desc_close(handle->desc); - free(handle); - handle = NULL; - } - - return handle; -} - - - -static inline struct shortcut_icon *shortcut_icon_request_ref(struct shortcut_icon *handle) -{ - handle->refcnt++; - DbgPrint("Handle: refcnt[%d]\n", handle->refcnt); - return handle; -} - - - -static int disconnected_cb(int handle, void *data) -{ - if (s_info.fd != handle) { - return 0; - } - - ErrPrint("Disconnected\n"); - s_info.fd = -1; - s_info.init_cb = NULL; - s_info.cbdata = NULL; - s_info.initialized = 0; - return 0; -} - - - -static inline struct shortcut_desc *shortcut_icon_desc_open(void) -{ - struct shortcut_desc *handle; - - handle = calloc(1, sizeof(*handle)); - if (!handle) { - ErrPrint("Error: %s\n", strerror(errno)); - return NULL; - } - - return handle; -} - - - -static inline int shortcut_icon_desc_save(struct shortcut_desc *handle, const char *filename) -{ - struct dlist *l; - struct dlist *n; - struct block *block; - FILE *fp; - - if (!handle) { - return SHORTCUT_ERROR_INVALID_PARAMETER; - } - - fp = fopen(filename, "w+t"); - if (!fp) { - ErrPrint("Error: %s\n", strerror(errno)); - return SHORTCUT_ERROR_IO_ERROR; - } - - DbgPrint("Close and flush\n"); - dlist_foreach_safe(handle->block_list, l, n, block) { - DbgPrint("{\n"); - fprintf(fp, "{\n"); - if (block->type) { - fprintf(fp, "type=%s\n", block->type); - DbgPrint("type=%s\n", block->type); - } - - if (block->part) { - fprintf(fp, "part=%s\n", block->part); - DbgPrint("part=%s\n", block->part); - } - - if (block->data) { - fprintf(fp, "data=%s\n", block->data); - DbgPrint("data=%s\n", block->data); - } - - if (block->option) { - fprintf(fp, "option=%s\n", block->option); - DbgPrint("option=%s\n", block->option); - } - - if (block->id) { - fprintf(fp, "id=%s\n", block->id); - DbgPrint("id=%s\n", block->id); - } - - if (block->target_id) { - fprintf(fp, "target=%s\n", block->target_id); - DbgPrint("target=%s\n", block->target_id); - } - - fprintf(fp, "}\n"); - DbgPrint("}\n"); - } - - if (fclose(fp) != 0) { - ErrPrint("fclose: %s\n", strerror(errno)); - } - return SHORTCUT_ERROR_NONE; -} - - - -static inline struct block *find_block(struct shortcut_desc *handle, const char *id, const char *part) -{ - struct block *block; - struct dlist *l; - - dlist_foreach(handle->block_list, l, block) { - if (!strcmp(block->part, part) && (!id || !strcmp(block->id, id))) { - return block; - } - } - - return NULL; -} - - - -static inline int update_block(struct block *block, const char *data, const char *option) -{ - char *_data = NULL; - char *_option = NULL; - - if (data) { - _data = strdup(data); - if (!_data) { - ErrPrint("Heap: %s\n", strerror(errno)); - return SHORTCUT_ERROR_OUT_OF_MEMORY; - } - } - - if (option) { - _option = strdup(option); - if (!_option) { - ErrPrint("Heap: %s\n", strerror(errno)); - free(_data); - return SHORTCUT_ERROR_OUT_OF_MEMORY; - } - } - - free(block->data); - free(block->option); - - block->data = _data; - block->option = _option; - return 0; -} - - - -/*! - * \return idx - */ - - - -static inline int shortcut_icon_desc_add_block(struct shortcut_desc *handle, const char *id, const char *type, const char *part, const char *data, const char *option, const char *target_id) -{ - struct block *block; - - if (!handle || !type) { - return SHORTCUT_ERROR_INVALID_PARAMETER; - } - - if (!part) { - part = ""; - } - - if (!data) { - data = ""; - } - - if (target_id) { - if (strcmp(type, SHORTCUT_ICON_TYPE_SCRIPT)) { - ErrPrint("target id only can be used for script type\n"); - return SHORTCUT_ERROR_INVALID_PARAMETER; - } - } - - block = find_block(handle, id, part); - if (!block) { - block = calloc(1, sizeof(*block)); - if (!block) { - ErrPrint("Heap: %s\n", strerror(errno)); - return SHORTCUT_ERROR_OUT_OF_MEMORY; - } - - block->type = strdup(type); - if (!block->type) { - ErrPrint("Heap: %s\n", strerror(errno)); - free(block); - return SHORTCUT_ERROR_OUT_OF_MEMORY; - } - - block->part = strdup(part); - if (!block->part) { - ErrPrint("Heap: %s\n", strerror(errno)); - free(block->type); - free(block); - return SHORTCUT_ERROR_OUT_OF_MEMORY; - } - - block->data = strdup(data); - if (!block->data) { - ErrPrint("Heap: %s\n", strerror(errno)); - free(block->type); - free(block->part); - free(block); - return SHORTCUT_ERROR_OUT_OF_MEMORY; - } - - if (option) { - block->option = strdup(option); - if (!block->option) { - ErrPrint("Heap: %s\n", strerror(errno)); - free(block->data); - free(block->type); - free(block->part); - free(block); - return SHORTCUT_ERROR_OUT_OF_MEMORY; - } - } - - if (id) { - block->id = strdup(id); - if (!block->id) { - ErrPrint("Heap: %s\n", strerror(errno)); - free(block->option); - free(block->data); - free(block->type); - free(block->part); - free(block); - return SHORTCUT_ERROR_OUT_OF_MEMORY; - } - } - - if (target_id) { - block->target_id = strdup(target_id); - if (!block->target_id) { - ErrPrint("Heap: %s\n", strerror(errno)); - free(block->id); - free(block->option); - free(block->data); - free(block->type); - free(block->part); - free(block); - return SHORTCUT_ERROR_OUT_OF_MEMORY; - } - } - - block->idx = handle->last_idx++; - handle->block_list = dlist_append(handle->block_list, block); - } else { - if (strcmp(block->type, type)) { - ErrPrint("type is not valid (%s, %s)\n", block->type, type); - return SHORTCUT_ERROR_INVALID_PARAMETER; - } - - if ((block->target_id && !target_id) || (!block->target_id && target_id)) { - ErrPrint("type is not valid (%s, %s)\n", block->type, type); - return SHORTCUT_ERROR_INVALID_PARAMETER; - } - - if (block->target_id && target_id && strcmp(block->target_id, target_id)) { - ErrPrint("type is not valid (%s, %s)\n", block->type, type); - return SHORTCUT_ERROR_INVALID_PARAMETER; - } - - update_block(block, data, option); - } - - return block->idx; -} - - - -static int icon_request_cb(pid_t pid, int handle, const struct packet *packet, void *data) -{ - struct request_item *item = data; - int ret; - - if (!packet) { - ret = -EFAULT; - DbgPrint("Disconnected?\n"); - } else { - if (packet_get(packet, "i", &ret) != 1) { - DbgPrint("Invalid packet\n"); - ret = -EINVAL; - } - } - - if (item->result_cb) { - item->result_cb(item->handle, ret, item->data); - } - - (void)shortcut_icon_request_unref(item->handle); - free(item); - return 0; -} - - - -static inline int make_connection(void) -{ - int ret; - static struct method service_table[] = { - { - .cmd = NULL, - .handler = NULL, - }, - }; - - s_info.fd = com_core_packet_client_init(s_info.utility_socket, 0, service_table); - if (s_info.fd < 0) { - ret = SHORTCUT_ERROR_COMM; - - if (s_info.init_cb) { - s_info.init_cb(ret, s_info.cbdata); - } - } else { - struct dlist *l; - struct dlist *n; - struct pending_item *pend; - - if (s_info.init_cb) { - s_info.init_cb(SHORTCUT_ERROR_NONE, s_info.cbdata); - } - - dlist_foreach_safe(s_info.pending_list, l, n, pend) { - s_info.pending_list = dlist_remove(s_info.pending_list, l); - - ret = com_core_packet_async_send(s_info.fd, pend->packet, 0.0f, icon_request_cb, pend->item); - packet_destroy(pend->packet); - if (ret < 0) { - ErrPrint("ret: %d\n", ret); - if (pend->item->result_cb) { - pend->item->result_cb(pend->item->handle, ret, pend->item->data); - } - free(pend->item); - } - - free(pend); - } - - ret = SHORTCUT_ERROR_NONE; - } - - return ret; -} - - - -static void master_started_cb(keynode_t *node, void *user_data) -{ - int state = 0; - - if (vconf_get_bool(VCONFKEY_MASTER_STARTED, &state) < 0) { - ErrPrint("Unable to get \"%s\"\n", VCONFKEY_MASTER_STARTED); - } - - if (state == 1 && (make_connection() == SHORTCUT_ERROR_NONE)) { - int ret; - ret = vconf_ignore_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb); - DbgPrint("Ignore VCONF [%d]\n", ret); - } -} - - - -EAPI int shortcut_icon_service_init(int (*init_cb)(int status, void *data), void *data) -{ - int ret; - - if (s_info.fd >= 0) { - return SHORTCUT_ERROR_INVALID_PARAMETER; - } - - if (s_info.initialized) { - s_info.initialized = 1; - com_core_add_event_callback(CONNECTOR_DISCONNECTED, disconnected_cb, NULL); - } - - s_info.init_cb = init_cb; - s_info.cbdata = data; - - ret = vconf_notify_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb, NULL); - if (ret < 0) { - ErrPrint("Failed to add vconf for service state [%d]\n", ret); - } else { - DbgPrint("vconf is registered\n"); - } - - master_started_cb(NULL, NULL); - return SHORTCUT_ERROR_NONE; -} - - - -EAPI int shortcut_icon_service_fini(void) -{ - struct dlist *l; - struct dlist *n; - struct pending_item *pend; - - if (s_info.initialized) { - com_core_del_event_callback(CONNECTOR_DISCONNECTED, disconnected_cb, NULL); - s_info.initialized = 0; - } - - if (s_info.fd < 0) { - return SHORTCUT_ERROR_INVALID_PARAMETER; - } - - com_core_packet_client_fini(s_info.fd); - s_info.init_cb = NULL; - s_info.cbdata = NULL; - s_info.fd = -1; - - dlist_foreach_safe(s_info.pending_list, l, n, pend) { - s_info.pending_list = dlist_remove(s_info.pending_list, l); - packet_unref(pend->packet); - if (pend->item->result_cb) { - pend->item->result_cb(pend->item->handle, SHORTCUT_ERROR_COMM, pend->item->data); - } - free(pend->item); - free(pend); - } - return SHORTCUT_ERROR_NONE; -} - - - -EAPI struct shortcut_icon *shortcut_icon_request_create(void) -{ - struct shortcut_icon *handle; - - handle = malloc(sizeof(*handle)); - if (!handle) { - ErrPrint("Heap: %s\n", strerror(errno)); - return NULL; - } - - handle->desc = shortcut_icon_desc_open(); - if (!handle->desc) { - ErrPrint("Uanble to open desc\n"); - free(handle); - return NULL; - } - - handle->state = CREATED; - handle->refcnt = 1; - return handle; -} - - -EAPI int shortcut_icon_request_set_data(struct shortcut_icon *handle, void *data) -{ - if (!handle || handle->state != CREATED) { - ErrPrint("Handle is not valid\n"); - return SHORTCUT_ERROR_INVALID_PARAMETER; - } - - handle->data = data; - return SHORTCUT_ERROR_NONE; -} - - - -EAPI void *shortcut_icon_request_data(struct shortcut_icon *handle) -{ - if (!handle || handle->state != CREATED) { - ErrPrint("Handle is not valid\n"); - return NULL; - } - - return handle->data; -} - - - -EAPI int shortcut_icon_request_set_info(struct shortcut_icon *handle, const char *id, const char *type, const char *part, const char *data, const char *option, const char *subid) -{ - if (!handle || handle->state != CREATED) { - ErrPrint("Handle is not valid\n"); - return SHORTCUT_ERROR_INVALID_PARAMETER; - } - - return shortcut_icon_desc_add_block(handle->desc, id, type, part, data, option, subid); -} - - - -EAPI int shortcut_icon_request_destroy(struct shortcut_icon *handle) -{ - if (!handle || handle->state != CREATED) { - ErrPrint("Handle is not valid\n"); - return SHORTCUT_ERROR_INVALID_PARAMETER; - } - - (void)shortcut_icon_request_unref(handle); - return SHORTCUT_ERROR_NONE; -} - - - -EAPI int shortcut_icon_request_send(struct shortcut_icon *handle, int size_type, const char *layout, const char *group, const char *outfile, icon_request_cb_t result_cb, void *data) -{ - int ret; - struct packet *packet; - struct request_item *item; - char *filename; - int len; - - if (!handle || handle->state != CREATED) { - ErrPrint("Handle is not valid\n"); - return SHORTCUT_ERROR_INVALID_PARAMETER; - } - - if (!layout) { - layout = DEFAULT_ICON_LAYOUT; - } - - if (!group) { - group = DEFAULT_ICON_GROUP; - } - - len = strlen(outfile) + strlen(".desc") + 1 + 30; /* 30 == strlen(tv.tv_sec) + strlen(tv.tv_usec) + 10 (reserved) */ - filename = malloc(len); - if (!filename) { - ErrPrint("Heap: %s\n", strerror(errno)); - return SHORTCUT_ERROR_OUT_OF_MEMORY; - } - -#if defined(_USE_ECORE_TIME_GET) - struct timespec ts; - double tv; - do { - if (clock_gettime(s_info.type, &ts) == 0) { - tv = ts.tv_sec + ts.tv_nsec / 1000000000.0f; - break; - } - - ErrPrint("%d: %s\n", s_info.type, strerror(errno)); - if (s_info.type == CLOCK_MONOTONIC) { - s_info.type = CLOCK_REALTIME; - } else if (s_info.type == CLOCK_REALTIME) { - struct timeval _tv; - if (gettimeofday(&_tv, NULL) < 0) { - ErrPrint("gettimeofday: %s\n", strerror(errno)); - _tv.tv_sec = rand(); - _tv.tv_usec = rand(); - } - - tv = (double)_tv.tv_sec + (double)_tv.tv_usec / 1000000.0f; - break; - } - } while (1); - ret = snprintf(filename, len, "%s.%lf.desc", outfile, tv); -#else - struct timeval tv; - if (gettimeofday(&tv, NULL) != 0) { - ErrPrint("gettimeofday: %s\n", strerror(errno)); - tv.tv_sec = rand(); - tv.tv_usec = rand(); - } - - ret = snprintf(filename, len, "%s.%lu.%lu.desc", outfile, tv.tv_sec, tv.tv_usec); -#endif - if (ret < 0) { - ErrPrint("snprintf: %s\n", strerror(errno)); - goto out; - } - - ret = shortcut_icon_desc_save(handle->desc, filename); - if (ret < 0) { - goto out; - } - - item = malloc(sizeof(*item)); - if (!item) { - ErrPrint("Heap: %s\n", strerror(errno)); - if (unlink(filename) < 0) { - ErrPrint("Unlink: %s\n", strerror(errno)); - } - ret = SHORTCUT_ERROR_OUT_OF_MEMORY; - goto out; - } - - item->result_cb = result_cb; - item->data = data; - item->handle = shortcut_icon_request_ref(handle); - - packet = packet_create("icon_create", "sssis", layout, group, filename, size_type, outfile); - if (!packet) { - ErrPrint("Failed to create a packet\n"); - if (unlink(filename) < 0) { - ErrPrint("Unlink: %s\n", strerror(errno)); - } - free(item); - (void)shortcut_icon_request_unref(handle); - ret = SHORTCUT_ERROR_FAULT; - goto out; - } - - if (s_info.fd >= 0 && !s_info.pending_list) { - ret = com_core_packet_async_send(s_info.fd, packet, 0.0f, icon_request_cb, item); - packet_destroy(packet); - if (ret < 0) { - ErrPrint("ret: %d\n", ret); - if (unlink(filename) < 0) { - ErrPrint("Unlink: %s\n", strerror(errno)); - } - free(item); - (void)shortcut_icon_request_unref(handle); - } - DbgPrint("Request is sent\n"); - } else { - struct pending_item *pend; - - pend = malloc(sizeof(*pend)); - if (!pend) { - ErrPrint("Heap: %s\n", strerror(errno)); - packet_destroy(packet); - free(item); - if (unlink(filename) < 0) { - ErrPrint("Unlink: %s\n", strerror(errno)); - } - (void)shortcut_icon_request_unref(handle); - ret = SHORTCUT_ERROR_OUT_OF_MEMORY; - goto out; - } - - pend->packet = packet; - pend->item = item; - - s_info.pending_list = dlist_append(s_info.pending_list, pend); - DbgPrint("Request is pended\n"); - - ret = SHORTCUT_ERROR_NONE; - } - -out: - free(filename); - return ret; -} - -/* End of a file */ diff --git a/lib/src/main.c b/lib/src/main.c deleted file mode 100644 index 62376c8..0000000 --- a/lib/src/main.c +++ /dev/null @@ -1,1062 +0,0 @@ -/* - * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. - * - * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 - * - * 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 <stdlib.h> -#include <errno.h> -#include <unistd.h> -#include <fcntl.h> -#include <string.h> -#include <sys/socket.h> -#include <sys/ioctl.h> -#include <libgen.h> - -#include <aul.h> -#include <dlog.h> -#include <glib.h> -#include <db-util.h> -#include <vconf.h> -#include <vconf-keys.h> - -#include <packet.h> -#include <com-core.h> -#include <com-core_packet.h> - -/* For multi-user support */ -#include <tzplatform_config.h> - -#include "shortcut.h" -#include "shortcut_internal.h" -#include "shortcut_manager.h" - -#define SHORTCUT_PKGNAME_LEN 512 - -int errno; - -static struct info { - const char *dbfile; - sqlite3 *handle; - int server_fd; - int client_fd; - const char *socket_file; - struct { - int (*request_cb)(const char *appid, const char *name, int type, const char *content, const char *icon, pid_t pid, double period, int allow_duplicate, void *data); - void *data; - } server_cb; - int initialized; - int db_opened; - guint timer_id; -} s_info = { - .server_fd = -1, - .client_fd = -1, - .socket_file = "/tmp/.shortcut.service", - .dbfile = "", - .handle = NULL, - .initialized = 0, - .db_opened = 0, - .timer_id = 0, -}; - - -static inline int make_connection(void); - - -static struct packet *remove_shortcut_handler(pid_t pid, int handle, const struct packet *packet) -{ - const char *appid; - const char *name; - const char *content_info; - int ret; - int sender_pid; - - if (!packet) { - ErrPrint("Packet is NIL, maybe disconnected?\n"); - return NULL; - } - - if (packet_get(packet, "isss", &sender_pid, &appid, &name, &content_info) != 4) { - ErrPrint("Invalid apcket\n"); - return NULL; - } - - DbgPrint("appid[%s], name[%s], content_info[%s]\n", appid, name, content_info); - - if (s_info.server_cb.request_cb) { - ret = s_info.server_cb.request_cb(appid, name, SHORTCUT_REMOVE, content_info, NULL, sender_pid, -1.0f, 0, s_info.server_cb.data); - } else { - ret = SHORTCUT_ERROR_UNSUPPORTED; - } - - return packet_create_reply(packet, "i", ret); -} - - - -static struct packet *remove_livebox_handler(pid_t pid, int handle, const struct packet *packet) -{ - const char *appid; - const char *name; - int ret; - int sender_pid; - - if (!packet) { - ErrPrint("PAcket is NIL, maybe disconnected?\n"); - return NULL; - } - - if (packet_get(packet, "iss", &sender_pid, &appid, &name) != 3) { - ErrPrint("Invalid packet\n"); - return NULL; - } - - DbgPrint("appid[%s], name[%s]\n", appid, name); - - if (s_info.server_cb.request_cb) { - ret = s_info.server_cb.request_cb(appid, name, LIVEBOX_REMOVE, NULL, NULL, sender_pid, -1.0f, 0, s_info.server_cb.data); - } else { - ret = SHORTCUT_ERROR_UNSUPPORTED; - } - - return packet_create_reply(packet, "i", ret); -} - - - -static struct packet *add_shortcut_handler(pid_t pid, int handle, const struct packet *packet) -{ - const char *appid; - const char *name; - int type; - const char *content; - const char *icon; - int allow_duplicate; - int ret; - int sender_pid; - - if (!packet) { - return NULL; - } - - if (packet_get(packet, "ississi", &sender_pid, &appid, &name, &type, &content, &icon, &allow_duplicate) != 7) { - ErrPrint("Invalid packet\n"); - return NULL; - } - - DbgPrint("appid[%s], name[%s], type[0x%x], content[%s], icon[%s] allow_duplicate[%d]\n", appid, name, type, content, icon, allow_duplicate); - - if (s_info.server_cb.request_cb) { - ret = s_info.server_cb.request_cb(appid, name, type, content, icon, sender_pid, -1.0f, allow_duplicate, s_info.server_cb.data); - } else { - ret = SHORTCUT_ERROR_UNSUPPORTED; - } - - return packet_create_reply(packet, "i", ret); -} - - - -static struct packet *add_livebox_handler(pid_t pid, int handle, const struct packet *packet) -{ - const char *appid; - const char *name; - int type; - const char *content; - const char *icon; - double period; - int allow_duplicate; - int ret; - int sender_pid; - - if (!packet) { - return NULL; - } - - if (packet_get(packet, "ississdi", &sender_pid, &appid, &name, &type, &content, &icon, &period, &allow_duplicate) != 8) { - ErrPrint("Invalid packet\n"); - return NULL; - } - - DbgPrint("appid[%s], name[%s], type[0x%x], content[%s], icon[%s], period[%lf], allow_duplicate[%d]\n", appid, name, type, content, icon, period, allow_duplicate); - - if (s_info.server_cb.request_cb) { - ret = s_info.server_cb.request_cb(appid, name, type, content, icon, sender_pid, period, allow_duplicate, s_info.server_cb.data); - } else { - ret = 0; - } - - return packet_create_reply(packet, "i", ret); -} - - - -static void master_started_cb(keynode_t *node, void *user_data) -{ - int state = 0; - - if (vconf_get_bool(VCONFKEY_MASTER_STARTED, &state) < 0) { - ErrPrint("Unable to get \"%s\"\n", VCONFKEY_MASTER_STARTED); - } - - if (state == 1 && make_connection() == SHORTCUT_ERROR_NONE) { - int ret; - ret = vconf_ignore_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb); - DbgPrint("Ignore VCONF [%d]\n", ret); - } -} - - - -int shortcut_is_master_ready(void) -{ - int ret = -1, is_master_started = 0; - - ret = vconf_get_bool(VCONFKEY_MASTER_STARTED, &is_master_started); - if (ret == 0 && is_master_started == 1) { - ErrPrint("the master has been started"); - } else { - is_master_started = 0; - ErrPrint("the master has been stopped"); - } - - return is_master_started; -} - - - -static gboolean timeout_cb(void *data) -{ - int ret; - - ret = vconf_notify_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb, NULL); - if (ret < 0) { - ErrPrint("Failed to add vconf for service state [%d]\n", ret); - } else { - DbgPrint("vconf is registered\n"); - } - - master_started_cb(NULL, NULL); - - s_info.timer_id = 0; - return FALSE; -} - - - -static int disconnected_cb(int handle, void *data) -{ - if (s_info.client_fd == handle) { - s_info.client_fd = SHORTCUT_ERROR_INVALID_PARAMETER; - return 0; - } - - if (s_info.server_fd == handle) { - if (!s_info.timer_id) { - s_info.server_fd = SHORTCUT_ERROR_INVALID_PARAMETER; - s_info.timer_id = g_timeout_add(1000, timeout_cb, NULL); - if (!s_info.timer_id) { - ErrPrint("Unable to add timer\n"); - } - } - return 0; - } - - return 0; -} - - - -static inline int make_connection(void) -{ - int ret; - struct packet *packet; - static struct method service_table[] = { - { - .cmd = "add_shortcut", - .handler = add_shortcut_handler, - }, - { - .cmd = "add_livebox", - .handler = add_livebox_handler, - }, - { - .cmd = "rm_shortcut", - .handler = remove_shortcut_handler, - }, - { - .cmd = "rm_livebox", - .handler = remove_livebox_handler, - }, - { - .cmd = NULL, - .handler = NULL, - }, - }; - - if (s_info.initialized == 0) { - s_info.initialized = 1; - com_core_add_event_callback(CONNECTOR_DISCONNECTED, disconnected_cb, NULL); - } - - s_info.server_fd = com_core_packet_client_init(s_info.socket_file, 0, service_table); - if (s_info.server_fd < 0) { - ErrPrint("Failed to make a connection to the master\n"); - return SHORTCUT_ERROR_COMM; - } - - packet = packet_create_noack("service_register", ""); - if (!packet) { - ErrPrint("Failed to build a packet\n"); - return SHORTCUT_ERROR_FAULT; - } - - ret = com_core_packet_send_only(s_info.server_fd, packet); - DbgPrint("Service register sent: %d\n", ret); - packet_destroy(packet); - if (ret != 0) { - com_core_packet_client_fini(s_info.server_fd); - s_info.server_fd = -1; - ret = SHORTCUT_ERROR_COMM; - } else { - ret = SHORTCUT_ERROR_NONE; - } - - DbgPrint("Server FD: %d\n", s_info.server_fd); - return ret; -} - - - -static char *_shortcut_get_pkgname_by_pid(void) -{ - char pkgname[SHORTCUT_PKGNAME_LEN + 1] = { 0, }; - int pid = 0, ret = 0; - int fd; - char *dup_pkgname; - - pid = getpid(); - - ret = aul_app_get_pkgname_bypid(pid, pkgname, sizeof(pkgname)); - if (ret != 0) { - char buf[SHORTCUT_PKGNAME_LEN + 1] = { 0, }; - - snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid); - - fd = open(buf, O_RDONLY); - if (fd < 0) { - return NULL; - } - - ret = read(fd, pkgname, sizeof(pkgname) - 1); - close(fd); - - if (ret <= 0) { - return NULL; - } - - pkgname[ret] = '\0'; - /*! - * \NOTE - * "ret" is not able to be larger than "sizeof(pkgname) - 1", - * if the system is not going wrong. - */ - } else { - if (strlen(pkgname) <= 0) { - return NULL; - } - } - - dup_pkgname = strdup(pkgname); - if (!dup_pkgname) - ErrPrint("Heap: %s\n", strerror(errno)); - - return dup_pkgname; -} - - - -EAPI int shortcut_set_request_cb(request_cb_t request_cb, void *data) -{ - if (request_cb == NULL) { - return SHORTCUT_ERROR_INVALID_PARAMETER; - } - - s_info.server_cb.request_cb = request_cb; - s_info.server_cb.data = data; - - if (s_info.server_fd < 0) { - int ret; - - ret = vconf_notify_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb, NULL); - if (ret < 0) { - ErrPrint("Failed to add vconf for service state [%d]\n", ret); - return SHORTCUT_ERROR_COMM; - } else { - DbgPrint("vconf is registered\n"); - } - - master_started_cb(NULL, NULL); - } - - return SHORTCUT_ERROR_NONE; -} - - - -struct result_cb_item { - result_internal_cb_t result_internal_cb; - result_cb_t result_cb; - void *data; -}; - - - -static int shortcut_send_cb(pid_t pid, int handle, const struct packet *packet, void *data) -{ - struct result_cb_item *item = data; - int ret; - - if (!packet) { - ErrPrint("Packet is not valid\n"); - ret = SHORTCUT_ERROR_FAULT; - } else if (packet_get(packet, "i", &ret) != 1) { - ErrPrint("Packet is not valid\n"); - ret = SHORTCUT_ERROR_INVALID_PARAMETER; - } - - if (item->result_internal_cb) { - ret = item->result_internal_cb(ret, pid, item->data); - } else if (item->result_cb) { - ret = item->result_cb(ret, item->data); - } else { - ret = SHORTCUT_ERROR_NONE; - } - free(item); - return ret; -} - - - -EAPI int add_to_home_remove_shortcut(const char *appid, const char *name, const char *content_info, result_internal_cb_t result_cb, void *data) -{ - struct packet *packet; - struct result_cb_item *item; - int ret; - - if (!appid || !name) { - ErrPrint("Invalid argument\n"); - return SHORTCUT_ERROR_INVALID_PARAMETER; - } - - if (!s_info.initialized) { - s_info.initialized = 1; - com_core_add_event_callback(CONNECTOR_DISCONNECTED, disconnected_cb, NULL); - } - - if (s_info.client_fd < 0) { - static struct method service_table[] = { - { - .cmd = NULL, - .handler = NULL, - }, - }; - - s_info.client_fd = com_core_packet_client_init(s_info.socket_file, 0, service_table); - if (s_info.client_fd < 0) { - ErrPrint("Failed to make connection\n"); - return SHORTCUT_ERROR_COMM; - } - } - - item = malloc(sizeof(*item)); - if (!item) { - ErrPrint("Heap: %s\n", strerror(errno)); - return SHORTCUT_ERROR_OUT_OF_MEMORY; - } - - item->result_internal_cb = result_cb; - item->result_cb = NULL; - item->data = data; - - packet = packet_create("rm_shortcut", "isss", getpid(), appid, name, content_info); - if (!packet) { - ErrPrint("Failed to build a packet\n"); - free(item); - return SHORTCUT_ERROR_FAULT; - } - - ret = com_core_packet_async_send(s_info.client_fd, packet, 0.0f, shortcut_send_cb, item); - if (ret < 0) { - packet_destroy(packet); - free(item); - com_core_packet_client_fini(s_info.client_fd); - s_info.client_fd = SHORTCUT_ERROR_INVALID_PARAMETER; - return SHORTCUT_ERROR_COMM; - } - - return SHORTCUT_ERROR_NONE; -} - - - -EAPI int add_to_home_remove_livebox(const char *appid, const char *name, result_internal_cb_t result_cb, void *data) -{ - struct packet *packet; - struct result_cb_item *item; - int ret; - - if (!appid || !name) { - ErrPrint("Invalid argument\n"); - return SHORTCUT_ERROR_INVALID_PARAMETER; - } - - if (!s_info.initialized) { - s_info.initialized = 1; - com_core_add_event_callback(CONNECTOR_DISCONNECTED, disconnected_cb, NULL); - } - - if (s_info.client_fd < 0) { - static struct method service_table[] = { - { - .cmd = NULL, - .handler = NULL, - }, - }; - - - s_info.client_fd = com_core_packet_client_init(s_info.socket_file, 0, service_table); - if (s_info.client_fd < 0) { - ErrPrint("Failed to make connection\n"); - return SHORTCUT_ERROR_COMM; - } - } - - item = malloc(sizeof(*item)); - if (!item) { - ErrPrint("Heap: %s\n", strerror(errno)); - return SHORTCUT_ERROR_OUT_OF_MEMORY; - } - - item->result_internal_cb = result_cb; - item->result_cb = NULL; - item->data = data; - - packet = packet_create("rm_livebox", "iss", getpid(), appid, name); - if (!packet) { - ErrPrint("Failed to build a packet\n"); - free(item); - return SHORTCUT_ERROR_FAULT; - } - - ret = com_core_packet_async_send(s_info.client_fd, packet, 0.0f, shortcut_send_cb, item); - if (ret < 0) { - packet_destroy(packet); - free(item); - com_core_packet_client_fini(s_info.client_fd); - s_info.client_fd = SHORTCUT_ERROR_INVALID_PARAMETER; - return SHORTCUT_ERROR_COMM; - } - - return SHORTCUT_ERROR_NONE; -} - - - -EAPI int add_to_home_shortcut(const char *appid, const char *name, int type, const char *content, const char *icon, int allow_duplicate, result_internal_cb_t result_cb, void *data) -{ - struct packet *packet; - struct result_cb_item *item; - int ret; - - if (ADD_TO_HOME_IS_LIVEBOX(type)) { - ErrPrint("Invalid type used for adding a shortcut\n"); - return SHORTCUT_ERROR_INVALID_PARAMETER; - } - - if (!s_info.initialized) { - s_info.initialized = 1; - com_core_add_event_callback(CONNECTOR_DISCONNECTED, disconnected_cb, NULL); - } - - if (s_info.client_fd < 0) { - static struct method service_table[] = { - { - .cmd = NULL, - .handler = NULL, - }, - }; - - s_info.client_fd = com_core_packet_client_init(s_info.socket_file, 0, service_table); - if (s_info.client_fd < 0) { - ErrPrint("Failed to make connection\n"); - return SHORTCUT_ERROR_COMM; - } - } - - item = malloc(sizeof(*item)); - if (!item) { - ErrPrint("Heap: %s\n", strerror(errno)); - return SHORTCUT_ERROR_OUT_OF_MEMORY; - } - - item->result_internal_cb = result_cb; - item->result_cb = NULL; - item->data = data; - - if (!appid) { - appid = ""; - } - - if (!name) { - name = ""; - } - - if (!content) { - content = ""; - } - - if (!icon) { - icon = ""; - } - - packet = packet_create("add_shortcut", "ississi", getpid(), appid, name, type, content, icon, allow_duplicate); - if (!packet) { - ErrPrint("Failed to build a packet\n"); - free(item); - return SHORTCUT_ERROR_FAULT; - } - - ret = com_core_packet_async_send(s_info.client_fd, packet, 0.0f, shortcut_send_cb, item); - if (ret < 0) { - packet_destroy(packet); - free(item); - com_core_packet_client_fini(s_info.client_fd); - s_info.client_fd = SHORTCUT_ERROR_INVALID_PARAMETER; - return SHORTCUT_ERROR_COMM; - } - - return SHORTCUT_ERROR_NONE; -} - -EAPI int shortcut_add_to_home(const char *name, shortcut_type type, const char *uri, const char *icon, int allow_duplicate, result_cb_t result_cb, void *data) -{ - struct packet *packet; - struct result_cb_item *item; - char *appid = NULL; - int ret; - - if (ADD_TO_HOME_IS_LIVEBOX(type)) { - ErrPrint("Invalid type used for adding a shortcut\n"); - return SHORTCUT_ERROR_INVALID_PARAMETER; - } - - appid = _shortcut_get_pkgname_by_pid(); - - if (!s_info.initialized) { - s_info.initialized = 1; - com_core_add_event_callback(CONNECTOR_DISCONNECTED, disconnected_cb, NULL); - } - - if (s_info.client_fd < 0) { - static struct method service_table[] = { - { - .cmd = NULL, - .handler = NULL, - }, - }; - - s_info.client_fd = com_core_packet_client_init(s_info.socket_file, 0, service_table); - if (s_info.client_fd < 0) { - if (appid) { - free(appid); - } - if (shortcut_is_master_ready() == 1) { - return SHORTCUT_ERROR_PERMISSION_DENIED; - } - else { - return SHORTCUT_ERROR_COMM; - } - } - } - - item = malloc(sizeof(*item)); - if (!item) { - if (appid) { - free(appid); - } - ErrPrint("Heap: %s\n", strerror(errno)); - return SHORTCUT_ERROR_OUT_OF_MEMORY; - } - - item->result_cb = result_cb; - item->result_internal_cb = NULL; - item->data = data; - - if (!name) { - name = ""; - } - - if (!uri) { - uri = ""; - } - - if (!icon) { - icon = ""; - } - - packet = packet_create("add_shortcut", "ississi", getpid(), appid, name, type, uri, icon, allow_duplicate); - if (!packet) { - ErrPrint("Failed to build a packet\n"); - if (appid) { - free(appid); - } - if (item) { - free(item); - } - return SHORTCUT_ERROR_FAULT; - } - - if (appid) { - free(appid); - } - - ret = com_core_packet_async_send(s_info.client_fd, packet, 0.0f, shortcut_send_cb, item); - packet_destroy(packet); - if (ret < 0) { - if (item) { - free(item); - } - com_core_packet_client_fini(s_info.client_fd); - s_info.client_fd = SHORTCUT_ERROR_INVALID_PARAMETER; - return SHORTCUT_ERROR_COMM; - } - - return SHORTCUT_ERROR_NONE; -} - - -EAPI int add_to_home_livebox(const char *appid, const char *name, int type, const char *content, const char *icon, double period, int allow_duplicate, result_internal_cb_t result_cb, void *data) -{ - struct packet *packet; - struct result_cb_item *item; - int ret; - - if (!ADD_TO_HOME_IS_LIVEBOX(type)) { - ErrPrint("Invalid type is used for adding a livebox\n"); - return SHORTCUT_ERROR_INVALID_PARAMETER; - } - - if (!s_info.initialized) { - s_info.initialized = 1; - com_core_add_event_callback(CONNECTOR_DISCONNECTED, disconnected_cb, NULL); - } - - if (s_info.client_fd < 0) { - static struct method service_table[] = { - { - .cmd = NULL, - .handler = NULL, - }, - }; - - s_info.client_fd = com_core_packet_client_init(s_info.socket_file, 0, service_table); - if (s_info.client_fd < 0) { - return SHORTCUT_ERROR_COMM; - } - } - - item = malloc(sizeof(*item)); - if (!item) { - ErrPrint("Heap: %s\n", strerror(errno)); - return SHORTCUT_ERROR_OUT_OF_MEMORY; - } - - item->result_internal_cb = result_cb; - item->result_cb = NULL; - item->data = data; - - packet = packet_create("add_livebox", "ississdi", getpid(), appid, name, type, content, icon, period, allow_duplicate); - if (!packet) { - ErrPrint("Failed to build a packet\n"); - free(item); - return SHORTCUT_ERROR_FAULT; - } - - ret = com_core_packet_async_send(s_info.client_fd, packet, 0.0f, shortcut_send_cb, item); - if (ret < 0) { - packet_destroy(packet); - free(item); - com_core_packet_client_fini(s_info.client_fd); - s_info.client_fd = SHORTCUT_ERROR_INVALID_PARAMETER; - return SHORTCUT_ERROR_COMM; - } - - return SHORTCUT_ERROR_NONE; -} - - -static inline int open_db(void) -{ - int ret; - - s_info.dbfile = tzplatform_mkpath(TZ_SYS_DB, ".shortcut_service.db"); - ret = db_util_open(s_info.dbfile, &s_info.handle, DB_UTIL_REGISTER_HOOK_METHOD); - if (ret != SQLITE_OK) { - DbgPrint("Failed to open a %s\n", s_info.dbfile); - return SHORTCUT_ERROR_IO_ERROR; - } - - return SHORTCUT_ERROR_NONE; -} - - - -/*! - * \note this function will returns allocated(heap) string - */ -static inline int get_i18n_name(const char *lang, int id, char **name, char **icon) -{ - sqlite3_stmt *stmt; - static const char *query = "SELECT name, icon FROM shortcut_name WHERE id = ? AND lang = ? COLLATE NOCASE"; - const unsigned char *_name; - const unsigned char *_icon; - int ret = 0; - int status; - - status = sqlite3_prepare_v2(s_info.handle, query, -1, &stmt, NULL); - if (status != SQLITE_OK) { - ErrPrint("Failed to prepare stmt: %s\n", sqlite3_errmsg(s_info.handle)); - return -EFAULT; - } - - status = sqlite3_bind_int(stmt, 1, id); - if (status != SQLITE_OK) { - ErrPrint("Failed to bind id: %s\n", sqlite3_errmsg(s_info.handle)); - ret = -EFAULT; - goto out; - } - - status = sqlite3_bind_text(stmt, 2, lang, -1, SQLITE_TRANSIENT); - if (status != SQLITE_OK) { - ErrPrint("Failed to bind lang: %s\n", sqlite3_errmsg(s_info.handle)); - ret = -EFAULT; - goto out; - } - - DbgPrint("id: %d, lang: %s\n", id, lang); - if (SQLITE_ROW != sqlite3_step(stmt)) { - ErrPrint("Failed to do step: %s\n", sqlite3_errmsg(s_info.handle)); - ret = -ENOENT; - goto out; - } - - _name = sqlite3_column_text(stmt, 0); - if (name) { - if (_name && strlen((const char *)_name)) { - *name = strdup((const char *)_name); - if (!*name) { - ErrPrint("strdup: %s\n", strerror(errno)); - ret = -ENOMEM; - goto out; - } - } else { - *name = NULL; - } - } - - _icon = sqlite3_column_text(stmt, 1); - if (icon) { - if (_icon && strlen((const char *)_icon)) { - *icon = strdup((const char *)_icon); - if (!*icon) { - ErrPrint("strdup: %s\n", strerror(errno)); - ret = -ENOMEM; - if (name && *name) { - free(*name); - } - goto out; - } - } else { - *icon = NULL; - } - } - -out: - sqlite3_reset(stmt); - sqlite3_clear_bindings(stmt); - sqlite3_finalize(stmt); - return ret; -} - - - -static inline char *cur_locale(void) -{ - char *language; - language = vconf_get_str(VCONFKEY_LANGSET); - if (language) { - char *ptr; - - ptr = language; - while (*ptr) { - if (*ptr == '.') { - *ptr = '\0'; - break; - } - - if (*ptr == '_') { - *ptr = '-'; - } - - ptr++; - } - } else { - language = strdup("en-us"); - if (!language) { - ErrPrint("Heap: %s\n", strerror(errno)); - } - } - - return language; -} - - - -/*! - * \note READ ONLY DB - */ -EAPI int shortcut_get_list(const char *appid, int (*cb)(const char *appid, const char *icon, const char *name, const char *extra_key, const char *extra_data, void *data), void *data) -{ - sqlite3_stmt *stmt; - const char *query; - const unsigned char *name; - char *i18n_name = NULL; - char *i18n_icon = NULL; - const unsigned char *extra_data; - const unsigned char *extra_key; - const unsigned char *icon; - int id; - int ret; - int cnt; - char *language; - - if (cb == NULL) { - return SHORTCUT_ERROR_INVALID_PARAMETER; - } - - if (!s_info.db_opened) { - s_info.db_opened = (open_db() == 0); - } - - if (!s_info.db_opened) { - ErrPrint("Failed to open a DB\n"); - return SHORTCUT_ERROR_IO_ERROR; - } - - language = cur_locale(); - if (!language) { - ErrPrint("Locale is not valid\n"); - return SHORTCUT_ERROR_FAULT; - } - - if (appid) { - query = "SELECT id, appid, name, extra_key, extra_data, icon FROM shortcut_service WHERE appid = ?"; - ret = sqlite3_prepare_v2(s_info.handle, query, -1, &stmt, NULL); - if (ret != SQLITE_OK) { - ErrPrint("prepare: %s\n", sqlite3_errmsg(s_info.handle)); - free(language); - return SHORTCUT_ERROR_IO_ERROR; - } - - ret = sqlite3_bind_text(stmt, 1, appid, -1, SQLITE_TRANSIENT); - if (ret != SQLITE_OK) { - ErrPrint("bind text: %s\n", sqlite3_errmsg(s_info.handle)); - sqlite3_finalize(stmt); - free(language); - return SHORTCUT_ERROR_IO_ERROR; - } - } else { - query = "SELECT id, appid, name, extra_key, extra_data, icon FROM shortcut_service"; - ret = sqlite3_prepare_v2(s_info.handle, query, -1, &stmt, NULL); - if (ret != SQLITE_OK) { - ErrPrint("prepare: %s\n", sqlite3_errmsg(s_info.handle)); - free(language); - return SHORTCUT_ERROR_IO_ERROR; - } - } - - cnt = 0; - while (SQLITE_ROW == sqlite3_step(stmt)) { - id = sqlite3_column_int(stmt, 0); - - appid = (const char *)sqlite3_column_text(stmt, 1); - if (!appid) { - LOGE("Failed to get package name\n"); - continue; - } - - name = sqlite3_column_text(stmt, 2); - if (!name) { - LOGE("Failed to get name\n"); - continue; - } - - extra_key = sqlite3_column_text(stmt, 3); - if (!extra_key) { - LOGE("Failed to get service\n"); - continue; - } - - extra_data = sqlite3_column_text(stmt, 4); - if (!extra_data) { - LOGE("Failed to get service\n"); - continue; - } - - icon = sqlite3_column_text(stmt, 5); - if (!icon) { - LOGE("Failed to get icon\n"); - continue; - } - - /*! - * \todo - * Implement the "GET LOCALE" code - */ - if (get_i18n_name(language, id, &i18n_name, &i18n_icon) < 0) { - /* Okay, we can't manage this. just use the fallback string */ - } - - cnt++; - if (cb(appid, (i18n_icon != NULL ? i18n_icon : (char *)icon), (i18n_name != NULL ? i18n_name : (char *)name), (char *)extra_key, (char *)extra_data, data) < 0) { - free(i18n_name); - break; - } - - free(i18n_name); - i18n_name = NULL; - - free(i18n_icon); - i18n_icon = NULL; - } - - sqlite3_reset(stmt); - sqlite3_clear_bindings(stmt); - sqlite3_finalize(stmt); - free(language); - return cnt; -} - -/* End of a file */ diff --git a/packaging/libshortcut.changes b/packaging/libshortcut.changes deleted file mode 100644 index 835d142..0000000 --- a/packaging/libshortcut.changes +++ /dev/null @@ -1,3 +0,0 @@ -* Wed Jun 05 2013 Xavier Roche <xavrock.os@gmail.com> accepted/tizen/20130520.100932@8fcc60e -- Replace manifest with default floor - diff --git a/packaging/libshortcut.manifest b/packaging/libshortcut.manifest deleted file mode 100644 index 41365c3..0000000 --- a/packaging/libshortcut.manifest +++ /dev/null @@ -1,8 +0,0 @@ -<manifest> - <request> - <domain name="_"/> - </request> - <assign> - <filesystem path="TZ_SYS_DB/.shortcut_service.db*" label="User" /> - </assign> -</manifest> diff --git a/packaging/libshortcut.spec b/packaging/libshortcut.spec deleted file mode 100644 index 8f26aac..0000000 --- a/packaging/libshortcut.spec +++ /dev/null @@ -1,85 +0,0 @@ -Name: libshortcut -Summary: Shortcut add feature supporting library -Version: 0.6.11 -Release: 0 -Group: Graphics & UI Framework/Libraries -License: Apache-2.0 -Source0: %{name}-%{version}.tar.gz -Source1001: %{name}.manifest - -Requires(post): /sbin/ldconfig -Requires(postun): /sbin/ldconfig -Requires: tizen-platform-config-tools - -BuildRequires: cmake, gettext-tools, coreutils -BuildRequires: pkgconfig(glib-2.0) -BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(db-util) -BuildRequires: pkgconfig(sqlite3) -BuildRequires: pkgconfig(com-core) -BuildRequires: pkgconfig(libxml-2.0) -BuildRequires: pkgconfig(vconf) -BuildRequires: pkgconfig(libtzplatform-config) -BuildRequires: pkgconfig(capi-base-common) -BuildRequires: pkgconfig(aul) - -%description -[Shortcut] AddToHome feature supporting library for menu/home screen developers. - -%package devel -Summary: AddToHome feature supporting library development files -Group: Development/Libraries -Requires: %{name} = %{version}-%{release} - -%description devel -[Shortcut] AddToHome feature supporting library for menu/home screen developers -(dev). - -%prep -%setup -q -sed -i %{SOURCE1001} -e "s|TZ_SYS_DB|%TZ_SYS_DB|g" -cp %{SOURCE1001} . - -%build -%if 0%{?sec_build_binary_debug_enable} -export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE" -export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE" -export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE" -%endif -%if 0%{?tizen_build_binary_release_type_eng} -export CFLAGS="${CFLAGS} -DTIZEN_ENGINEER_MODE" -export CXXFLAGS="${CXXFLAGS} -DTIZEN_ENGINEER_MODE" -export FFLAGS="${FFLAGS} -DTIZEN_ENGINEER_MODE" -%endif -%cmake . -make %{?jobs:-j%jobs} - -%install -rm -rf %{buildroot} -%make_install -mkdir -p %{buildroot}%{TZ_SYS_DB} -touch %{buildroot}%{TZ_SYS_DB}/.shortcut_service.db -touch %{buildroot}%{TZ_SYS_DB}/.shortcut_service.db-journal - -%post -n libshortcut -p /sbin/ldconfig - -%postun -n libshortcut -p /sbin/ldconfig - -%files -n libshortcut -%manifest %{name}.manifest -%defattr(-,root,root,-) -%{_libdir}/*.so* -%{_prefix}/etc/package-manager/parserlib/* -%{_datarootdir}/license/* -%attr(640,root,%{TZ_SYS_USER_GROUP}) %{TZ_SYS_DB}/.shortcut_service.db -%attr(640,root,%{TZ_SYS_USER_GROUP}) %{TZ_SYS_DB}/.shortcut_service.db-journal - -%files devel -%manifest %{name}.manifest -%defattr(-,root,root,-) -%{_includedir}/shortcut/shortcut_PG.h -%{_includedir}/shortcut/shortcut.h -%{_includedir}/shortcut/shortcut_manager.h -%{_libdir}/pkgconfig/shortcut.pc - -# End of a file diff --git a/pkgmgr_shortcut/CMakeLists.txt b/pkgmgr_shortcut/CMakeLists.txt deleted file mode 100644 index 30b81ac..0000000 --- a/pkgmgr_shortcut/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -PROJECT(shortcut-list C) - -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/pkgmgr_shortcut/include) - -INCLUDE(FindPkgConfig) -pkg_check_modules(bin_pkgs REQUIRED - dlog - sqlite3 - libxml-2.0 - db-util - libtzplatform-config -) - -FOREACH(flag ${bin_pkgs_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Wall -Werror") - -ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"") -ADD_DEFINITIONS("-DLOG_TAG=\"PKGMGR_SHORTCUT\"") - -ADD_LIBRARY(${PROJECT_NAME} SHARED - src/service_register.c - src/dlist.c -) - -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${bin_pkgs_LDFLAGS}) - -INSTALL(TARGETS ${PROJECT_NAME} DESTINATION "etc/package-manager/parserlib") - -# End of a file diff --git a/pkgmgr_shortcut/include/dlist.h b/pkgmgr_shortcut/include/dlist.h deleted file mode 100644 index 04283eb..0000000 --- a/pkgmgr_shortcut/include/dlist.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. - * - * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 - * - * 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. - * -*/ - -#define dlist_remove_data(list, data) do { \ - struct dlist *l; \ - l = dlist_find_data(list, data); \ - list = dlist_remove(list, l); \ -} while (0) - -#define dlist_foreach(list, l, data) \ - for ((l) = (list); (l) && ((data) = dlist_data(l)); (l) = dlist_next(l)) - -#define dlist_foreach_safe(list, l, n, data) \ - for ((l) = (list), (n) = dlist_next(l); \ - (l) && ((data) = dlist_data(l)); \ - (l) = (n), (n) = dlist_next(l)) - -struct dlist; - -extern struct dlist *dlist_append(struct dlist *list, void *data); -extern struct dlist *dlist_prepend(struct dlist *list, void *data); -extern struct dlist *dlist_remove(struct dlist *list, struct dlist *l); -extern struct dlist *dlist_find_data(struct dlist *list, void *data); -extern void *dlist_data(struct dlist *l); -extern struct dlist *dlist_next(struct dlist *l); -extern struct dlist *dlist_prev(struct dlist *l); -extern int dlist_count(struct dlist *l); -extern struct dlist *dlist_nth(struct dlist *l, int nth); - -/* End of a file */ diff --git a/pkgmgr_shortcut/src/dlist.c b/pkgmgr_shortcut/src/dlist.c deleted file mode 100644 index 1764dfd..0000000 --- a/pkgmgr_shortcut/src/dlist.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. - * - * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 - * - * 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 <stdio.h> -#include <stdlib.h> -#include <assert.h> - -#include "dlist.h" - -/*! - * \brief - * This dlist is called Modified Doubly Linked List. - * - * Noramlly, The dobule linked list contains address of previous and next element. - * This dlist also contains them, but the tail element only contains prev address. - * - * The head element's prev pointer indicates the last element. - * But the last element's next pointer indicates NIL. - * - * So we can find the last element while crawling this DList - * But we have to remember the address of the head element. - */ - -struct dlist { - struct dlist *next; - struct dlist *prev; - void *data; -}; - -struct dlist *dlist_append(struct dlist *list, void *data) -{ - struct dlist *item; - - item = malloc(sizeof(*item)); - if (!item) { - return NULL; - } - - item->next = NULL; - item->data = data; - - if (!list) { - item->prev = item; - - list = item; - } else { - item->prev = list->prev; - item->prev->next = item; - list->prev = item; - } - - assert(!list->prev->next && "item NEXT"); - - return list; -} - -struct dlist *dlist_prepend(struct dlist *list, void *data) -{ - struct dlist *item; - - item = malloc(sizeof(*item)); - if (!item) { - return NULL; - } - - item->data = data; - - if (!list) { - item->prev = item; - item->next = NULL; - } else { - if (list->prev->next) { - list->prev->next = item; - } - - item->prev = list->prev; - item->next = list; - - list->prev = item; - - } - - return item; -} - -struct dlist *dlist_remove(struct dlist *list, struct dlist *l) -{ - if (!list || !l) - return NULL; - - if (l == list) { - list = l->next; - } else { - l->prev->next = l->next; - } - - if (l->next) { - l->next->prev = l->prev; - } - /*! - * \note - * If the removed entry 'l' has no next element, it is the last element. - * In this case, check the existence of the list first, - * and if the list is not empty, update the 'prev' of the list (which is a head element of the list) - * - * If we didn't care about this, the head element(list) can indicates the invalid element. - */ - else if (list) { - list->prev = l->prev; - } - - free(l); - return list; -} - -struct dlist *dlist_find_data(struct dlist *list, void *data) -{ - struct dlist *l; - void *_data; - - dlist_foreach(list, l, _data) { - if (data == _data) { - return l; - } - } - - return NULL; -} - -void *dlist_data(struct dlist *l) -{ - return l ? l->data : NULL; -} - -struct dlist *dlist_next(struct dlist *l) -{ - return l ? l->next : NULL; -} - -struct dlist *dlist_prev(struct dlist *l) -{ - return l ? l->prev : NULL; -} - -int dlist_count(struct dlist *l) -{ - register int i; - struct dlist *n; - void *data; - - i = 0; - dlist_foreach(l, n, data) { - i++; - } - - return i; -} - -struct dlist *dlist_nth(struct dlist *l, int nth) -{ - register int i; - struct dlist *n; - - i = 0; - for (n = l; n; n = n->next) { - if (i == nth) { - return n; - } - i++; - } - - return NULL; -} - -/* End of a file */ diff --git a/pkgmgr_shortcut/src/service_register.c b/pkgmgr_shortcut/src/service_register.c deleted file mode 100644 index 2e03c2c..0000000 --- a/pkgmgr_shortcut/src/service_register.c +++ /dev/null @@ -1,1270 +0,0 @@ -/* - * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. - * - * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 - * - * 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 <stdio.h> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#include <libgen.h> -#include <string.h> - -#include <sqlite3.h> -#include <db-util.h> -#include <libxml/parser.h> -#include <libxml/tree.h> -#include <dlog.h> - -/* For multi-user support */ -#include <tzplatform_config.h> - -#include "dlist.h" - -#if !defined(SECURE_LOGD) -#define SECURE_LOGD LOGD -#endif - -#if !defined(SECURE_LOGE) -#define SECURE_LOGE LOGE -#endif - -#if !defined(SECURE_LOGW) -#define SECURE_LOGW LOGW -#endif - -#if !defined(FLOG) -#define DbgPrint(format, arg...) SECURE_LOGD("[[32m%s/%s[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg) -#define ErrPrint(format, arg...) SECURE_LOGE("[[32m%s/%s[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg) -#endif -/* End of a file */ - -/*! - * DB Table schema - * - * +----+-------+-------+------+---------+-----------+------------+ - * | id | pkgid | appid | Icon | Name | extra_key | extra_data | - * +----+-------+-------+------+---------+-----------+------------+ - * | id | - | - | - | - | - | - | - * +----+-------+-------+------+---------+-----------+------------+ - * - * +----+-------+------+------+------+ - * | fk | pkgid | lang | name | icon | - * +----+-------+------+------+------+ - * | id | - | - | | - | - * +----+-------+------+------+------+ - */ - -#if !defined(LIBXML_TREE_ENABLED) - #error "LIBXML is not supporting the tree" -#endif - -int errno; - -struct i18n_name { - xmlChar *icon; - xmlChar *name; - xmlChar *lang; -}; - -static struct { - const char *dbfile; - sqlite3 *handle; -} s_info = { - .dbfile = "", - .handle = NULL, -}; - -static inline int begin_transaction(void) -{ - sqlite3_stmt *stmt; - int ret; - - ret = sqlite3_prepare_v2(s_info.handle, "BEGIN TRANSACTION", -1, &stmt, NULL); - if (ret != SQLITE_OK) { - DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle)); - return EXIT_FAILURE; - } - - if (sqlite3_step(stmt) != SQLITE_DONE) { - DbgPrint("Failed to do update (%s)\n", - sqlite3_errmsg(s_info.handle)); - sqlite3_finalize(stmt); - return EXIT_FAILURE; - } - - sqlite3_finalize(stmt); - return EXIT_SUCCESS; -} - -static inline int rollback_transaction(void) -{ - int ret; - sqlite3_stmt *stmt; - - ret = sqlite3_prepare_v2(s_info.handle, "ROLLBACK TRANSACTION", -1, &stmt, NULL); - if (ret != SQLITE_OK) { - DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle)); - return EXIT_FAILURE; - } - - if (sqlite3_step(stmt) != SQLITE_DONE) { - DbgPrint("Failed to do update (%s)\n", - sqlite3_errmsg(s_info.handle)); - sqlite3_finalize(stmt); - return EXIT_FAILURE; - } - - sqlite3_finalize(stmt); - return EXIT_SUCCESS; -} - -static inline int commit_transaction(void) -{ - sqlite3_stmt *stmt; - int ret; - - ret = sqlite3_prepare_v2(s_info.handle, "COMMIT TRANSACTION", -1, &stmt, NULL); - if (ret != SQLITE_OK) { - DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle)); - return EXIT_FAILURE; - } - - if (sqlite3_step(stmt) != SQLITE_DONE) { - DbgPrint("Failed to do update (%s)\n", - sqlite3_errmsg(s_info.handle)); - sqlite3_finalize(stmt); - return EXIT_FAILURE; - } - - sqlite3_finalize(stmt); - return EXIT_SUCCESS; -} - -static void db_create_version(void) -{ - static const char *ddl = "CREATE TABLE version (version INTEGER)"; - char *err; - - if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) { - ErrPrint("Failed to execute the DDL (%s)\n", err); - return; - } - - if (sqlite3_changes(s_info.handle) == 0) { - ErrPrint("No changes to DB\n"); - } -} - -static int set_version(int version) -{ - static const char *dml = "INSERT INTO version (version) VALUES (?)"; - sqlite3_stmt *stmt; - int ret; - - ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL); - if (ret != SQLITE_OK) { - ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle)); - return -EIO; - } - - if (sqlite3_bind_int(stmt, 1, version) != SQLITE_OK) { - ErrPrint("Failed to bind a id(%s)\n", sqlite3_errmsg(s_info.handle)); - ret = -EIO; - goto out; - } - - ret = sqlite3_step(stmt); - if (ret != SQLITE_DONE) { - ErrPrint("Failed to execute the DML for version: %d\n", ret); - ret = -EIO; - } else { - ret = 0; - } - -out: - sqlite3_reset(stmt); - sqlite3_clear_bindings(stmt); - sqlite3_finalize(stmt); - return ret; -} - -static int update_version(int version) -{ - static const char *dml = "UPDATE version SET version = ?"; - sqlite3_stmt *stmt; - int ret; - - ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL); - if (ret != SQLITE_OK) { - ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle)); - return -EIO; - } - - if (sqlite3_bind_int(stmt, 1, version) != SQLITE_OK) { - ErrPrint("Failed to bind a version: %s\n", sqlite3_errmsg(s_info.handle)); - ret = -EIO; - goto out; - } - - ret = sqlite3_step(stmt); - if (ret != SQLITE_DONE) { - ErrPrint("Failed to execute DML: %d\n", ret); - ret = -EIO; - } else { - ret = 0; - } - -out: - sqlite3_reset(stmt); - sqlite3_clear_bindings(stmt); - sqlite3_finalize(stmt); - return ret; -} - -static int get_version(void) -{ - static const char *dml = "SELECT version FROM version"; - sqlite3_stmt *stmt; - int ret; - - ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL); - if (ret != SQLITE_OK) { - return -ENOSYS; - } - - if (sqlite3_step(stmt) != SQLITE_ROW) { - ret = -ENOENT; - } else { - ret = sqlite3_column_int(stmt, 0); - } - - sqlite3_reset(stmt); - sqlite3_clear_bindings(stmt); - sqlite3_finalize(stmt); - return ret; -} - -static void db_create_table(void) -{ - char *err; - static const char *ddl = - "CREATE TABLE shortcut_service (" - "id INTEGER PRIMARY KEY AUTOINCREMENT, " - "pkgid TEXT, " - "appid TEXT, " - "icon TEXT, " - "name TEXT, " - "extra_key TEXT, " - "extra_data TEXT)"; - - if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) { - ErrPrint("Failed to execute the DDL (%s)\n", err); - return; - } - - if (sqlite3_changes(s_info.handle) == 0) { - ErrPrint("No changes to DB\n"); - } - - ddl = "CREATE TABLE shortcut_name (id INTEGER, pkgid TEXT, lang TEXT, name TEXT, icon TEXT)"; - if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) { - ErrPrint("Failed to execute the DDL (%s)\n", err); - return; - } - - if (sqlite3_changes(s_info.handle) == 0) { - ErrPrint("No changes to DB\n"); - } - - db_create_version(); -} - -static void alter_shortcut_icon(void) -{ - char *err; - static const char *ddl = "ALTER TABLE shortcut_name ADD icon TEXT"; - - if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) { - ErrPrint("Failed to execute the DDL (%s)\n", err); - return; - } - - if (sqlite3_changes(s_info.handle) == 0) { - ErrPrint("No changes to DB\n"); - } -} - -static void alter_shortcut_name(void) -{ - char *err; - static const char *ddl = "ALTER TABLE shortcut_name ADD pkgid TEXT"; - - if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) { - ErrPrint("Failed to execute the DDL (%s)\n", err); - return; - } - - if (sqlite3_changes(s_info.handle) == 0) { - ErrPrint("No changes to DB\n"); - } -} - -static void alter_shortcut_service(void) -{ - char *err; - static const char *ddl = "ALTER TABLE shortcut_service ADD pkgid TEXT"; - - if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) { - ErrPrint("Failed to execute the DDL (%s)\n", err); - return; - } - - if (sqlite3_changes(s_info.handle) == 0) { - ErrPrint("No changes to DB\n"); - } -} - -static int db_remove_by_pkgid(const char *pkgid) -{ - static const char *dml = "DELETE FROM shortcut_service WHERE pkgid = ?"; - sqlite3_stmt *stmt; - int ret; - - if (!pkgid) { - ErrPrint("Invalid argument\n"); - return -EINVAL; - } - - ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL); - if (ret != SQLITE_OK) { - ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle)); - return -EIO; - } - - ret = -EIO; - if (sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT) != SQLITE_OK) { - ErrPrint("Failed to bind a pkgid(%s)\n", sqlite3_errmsg(s_info.handle)); - goto out; - } - - ret = 0; - if (sqlite3_step(stmt) != SQLITE_DONE) { - ret = -EIO; - ErrPrint("Failed to execute the DML for %s\n", pkgid); - } else { - if (sqlite3_changes(s_info.handle) == 0) { - DbgPrint("No changed\n"); - } - } - -out: - sqlite3_reset(stmt); - sqlite3_clear_bindings(stmt); - sqlite3_finalize(stmt); - return ret; -} - -static void do_upgrade_db_schema(void) -{ - int version; - - version = get_version(); - - switch (version) { - case -ENOSYS: - db_create_version(); - /* Need to create version table */ - case -ENOENT: - if (set_version(1) < 0) { - ErrPrint("Failed to set version\n"); - } - /* Need to set version */ - alter_shortcut_name(); - alter_shortcut_service(); - case 1: - alter_shortcut_icon(); - if (update_version(2) < 0) { - ErrPrint("Failed to update version\n"); - } - case 2: - break; - default: - /* Need to update version */ - DbgPrint("Old version: %d\n", version); - if (update_version(2) < 0) { - ErrPrint("Failed to update version\n"); - } - - alter_shortcut_name(); - alter_shortcut_service(); - /* 2 */ - alter_shortcut_icon(); - break; - } -} - -static int db_remove_record(const char *pkgid, const char *appid, const char *key, const char *data) -{ - static const char *dml = "DELETE FROM shortcut_service WHERE appid = ? AND extra_key = ? AND extra_data = ? AND pkgid = ?"; - sqlite3_stmt *stmt; - int ret; - - if (!appid || !key || !data) { - ErrPrint("Invalid argument\n"); - return -EINVAL; - } - - ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL); - if (ret != SQLITE_OK) { - ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle)); - return -EIO; - } - - ret = -EIO; - if (sqlite3_bind_text(stmt, 1, appid, -1, SQLITE_TRANSIENT) != SQLITE_OK) { - ErrPrint("Failed to bind a appid(%s)\n", sqlite3_errmsg(s_info.handle)); - goto out; - } - - if (sqlite3_bind_text(stmt, 2, key, -1, SQLITE_TRANSIENT) != SQLITE_OK) { - ErrPrint("Failed to bind a key(%s)\n", sqlite3_errmsg(s_info.handle)); - goto out; - } - - if (sqlite3_bind_text(stmt, 3, data, -1, SQLITE_TRANSIENT) != SQLITE_OK) { - ErrPrint("Failed to bind a data(%s)\n", sqlite3_errmsg(s_info.handle)); - goto out; - } - - if (sqlite3_bind_text(stmt, 4, pkgid, -1, SQLITE_TRANSIENT) != SQLITE_OK) { - ErrPrint("Failed to bind a pkgid(%s)\n", sqlite3_errmsg(s_info.handle)); - goto out; - } - - ret = 0; - if (sqlite3_step(stmt) != SQLITE_DONE) { - ret = -EIO; - ErrPrint("Failed to execute the DML for %s - %s(%s)\n", appid, key, data); - } - - if (sqlite3_changes(s_info.handle) == 0) { - DbgPrint("No changes\n"); - } - -out: - sqlite3_reset(stmt); - sqlite3_clear_bindings(stmt); - sqlite3_finalize(stmt); - return ret; -} - -static int db_remove_name_by_pkgid(const char *pkgid) -{ - static const char *dml = "DELETE FROM shortcut_name WHERE pkgid = ?"; - sqlite3_stmt *stmt; - int ret; - - if (!pkgid) { - ErrPrint("Invalid id\n"); - return -EINVAL; - } - - ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL); - if (ret != SQLITE_OK) { - ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle)); - return -EIO; - } - - if (sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT) != SQLITE_OK) { - ErrPrint("Failed to bind pkgid(%s)\n", pkgid); - return -EIO; - } - - ret = 0; - if (sqlite3_step(stmt) != SQLITE_DONE) { - ret = -EIO; - ErrPrint("Failed to execute the DML for %s\n", pkgid); - goto out; - } - - if (sqlite3_changes(s_info.handle) == 0) { - DbgPrint("No chnages\n"); - } - -out: - sqlite3_reset(stmt); - sqlite3_clear_bindings(stmt); - sqlite3_finalize(stmt); - return ret; -} - -static int db_remove_name(int id) -{ - static const char *dml = "DELETE FROM shortcut_name WHERE id = ?"; - sqlite3_stmt *stmt; - int ret; - - if (id < 0) { - ErrPrint("Inavlid id\n"); - return -EINVAL; - } - - ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL); - if (ret != SQLITE_OK) { - ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle)); - return -EIO; - } - - if (sqlite3_bind_int(stmt, 1, id) != SQLITE_OK) { - ErrPrint("Failed to bind id(%d)\n", id); - ret = -EIO; - goto out; - } - - ret = 0; - if (sqlite3_step(stmt) != SQLITE_DONE) { - ret = -EIO; - ErrPrint("Failed to execute the DML for %d\n", id); - goto out; - } - - if (sqlite3_changes(s_info.handle) == 0) { - DbgPrint("No changes\n"); - } - -out: - sqlite3_reset(stmt); - sqlite3_clear_bindings(stmt); - sqlite3_finalize(stmt); - return ret; -} - -static int db_insert_record(const char *pkgid, const char *appid, const char *icon, const char *name, const char *key, const char *data) -{ - static const char *dml = "INSERT INTO shortcut_service (pkgid, appid, icon, name, extra_key, extra_data) VALUES (?, ?, ?, ?, ?, ?)"; - sqlite3_stmt *stmt; - int ret; - - if (!pkgid) { - ErrPrint("Failed to get pkgid\n"); - return -EINVAL; - } - - if (!appid) { - ErrPrint("Failed to get appid\n"); - return -EINVAL; - } - - if (!name) { - ErrPrint("Failed to get name\n"); - return -EINVAL; - } - - if (!key) { - ErrPrint("Failed to get key\n"); - return -EINVAL; - } - - if (!data) { - ErrPrint("Faield to get key\n"); - return -EINVAL; - } - - icon = icon ? icon : ""; - - ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL); - if (ret != SQLITE_OK) { - ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle)); - return -EIO; - } - - ret = -EIO; - if (sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT) != SQLITE_OK) { - ErrPrint("Failed to bind a pkgid(%s)\n", sqlite3_errmsg(s_info.handle)); - goto out; - } - - if (sqlite3_bind_text(stmt, 2, appid, -1, SQLITE_TRANSIENT) != SQLITE_OK) { - ErrPrint("Failed to bind a appid(%s)\n", sqlite3_errmsg(s_info.handle)); - goto out; - } - - if (sqlite3_bind_text(stmt, 3, icon, -1, SQLITE_TRANSIENT) != SQLITE_OK) { - ErrPrint("Failed to bind a icon(%s)\n", sqlite3_errmsg(s_info.handle)); - goto out; - } - - if (sqlite3_bind_text(stmt, 4, name, -1, SQLITE_TRANSIENT) != SQLITE_OK) { - ErrPrint("Failed to bind a name(%s)\n", sqlite3_errmsg(s_info.handle)); - goto out; - } - - if (sqlite3_bind_text(stmt, 5, key, -1, SQLITE_TRANSIENT) != SQLITE_OK) { - ErrPrint("Failed to bind a service(%s)\n", sqlite3_errmsg(s_info.handle)); - goto out; - } - - if (sqlite3_bind_text(stmt, 6, data, -1, SQLITE_TRANSIENT) != SQLITE_OK) { - ErrPrint("Failed to bind a service(%s)\n", sqlite3_errmsg(s_info.handle)); - goto out; - } - - ret = 0; - if (sqlite3_step(stmt) != SQLITE_DONE) { - ErrPrint("Failed to execute the DML for %s - %s\n", appid, name); - ret = -EIO; - } - -out: - sqlite3_reset(stmt); - sqlite3_clear_bindings(stmt); - sqlite3_finalize(stmt); - return ret; -} - -static int db_insert_name(int id, const char *pkgid, const char *lang, const char *name, const char *icon) -{ - static const char *dml = "INSERT INTO shortcut_name (id, pkgid, lang, name, icon) VALUES (?, ?, ?, ?, ?)"; - sqlite3_stmt *stmt; - int ret; - - if (id < 0 || !lang) { - ErrPrint("Invalid parameters\n"); - return -EINVAL; - } - - if (!name) { - name = ""; - } - - if (!icon) { - icon = ""; - } - - ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL); - if (ret != SQLITE_OK) { - ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle)); - return -EIO; - } - - if (sqlite3_bind_int(stmt, 1, id) != SQLITE_OK) { - ErrPrint("Failed to bind a id(%s)\n", sqlite3_errmsg(s_info.handle)); - ret = -EIO; - goto out; - } - - if (sqlite3_bind_text(stmt, 2, pkgid, -1, SQLITE_TRANSIENT) != SQLITE_OK) { - ErrPrint("Failed to bind a pkgid(%s)\n", sqlite3_errmsg(s_info.handle)); - ret = -EIO; - goto out; - } - - if (sqlite3_bind_text(stmt, 3, lang, -1, SQLITE_TRANSIENT) != SQLITE_OK) { - ErrPrint("Failed to bind a id(%s)\n", sqlite3_errmsg(s_info.handle)); - ret = -EIO; - goto out; - } - - if (sqlite3_bind_text(stmt, 4, name, -1, SQLITE_TRANSIENT) != SQLITE_OK) { - ErrPrint("Failed to bind a id(%s)\n", sqlite3_errmsg(s_info.handle)); - ret = -EIO; - goto out; - } - - if (sqlite3_bind_text(stmt, 5, icon, -1, SQLITE_TRANSIENT) != SQLITE_OK) { - ErrPrint("Failed to bind a id(%s)\n", sqlite3_errmsg(s_info.handle)); - ret = -EIO; - goto out; - } - - ret = 0; - if (sqlite3_step(stmt) != SQLITE_DONE) { - ErrPrint("Failed to execute the DML for %d %s %s\n", id, lang, name); - ret = -EIO; - } - -out: - sqlite3_reset(stmt); - sqlite3_clear_bindings(stmt); - sqlite3_finalize(stmt); - return ret; -} - -static int db_get_id(const char *pkgid, const char *appid, const char *key, const char *data) -{ - static const char *dml = "SELECT id FROM shortcut_service WHERE pkgid = ? AND appid = ? AND extra_key = ? AND extra_data = ?"; - sqlite3_stmt *stmt; - int ret; - - if (!appid || !key || !data) { - ErrPrint("Invalid argument\n"); - return -EINVAL; - } - - ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL); - if (ret != SQLITE_OK) { - ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle)); - return -EIO; - } - - ret = -EIO; - if (sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT) != SQLITE_OK) { - ErrPrint("Failed to bind a pkgid(%s) - %s\n", pkgid, sqlite3_errmsg(s_info.handle)); - goto out; - } - - if (sqlite3_bind_text(stmt, 2, appid, -1, SQLITE_TRANSIENT) != SQLITE_OK) { - ErrPrint("Failed to bind a appid(%s) - %s\n", appid, sqlite3_errmsg(s_info.handle)); - goto out; - } - - if (sqlite3_bind_text(stmt, 3, key, -1, SQLITE_TRANSIENT) != SQLITE_OK) { - ErrPrint("Failed to bind a key(%s) - %s\n", key, sqlite3_errmsg(s_info.handle)); - goto out; - } - - if (sqlite3_bind_text(stmt, 4, data, -1, SQLITE_TRANSIENT) != SQLITE_OK) { - ErrPrint("Failed to bind a data(%s) - %s\n", data, sqlite3_errmsg(s_info.handle)); - goto out; - } - - if (sqlite3_step(stmt) != SQLITE_ROW) { - ErrPrint("Failed to execute the DML for %s - %s, %s\n", appid, key, data); - ret = -EIO; - goto out; - } - - ret = sqlite3_column_int(stmt, 0); - -out: - sqlite3_reset(stmt); - sqlite3_clear_bindings(stmt); - sqlite3_finalize(stmt); - return ret; -} - -static int db_init(void) -{ - int ret; - struct stat stat; - - s_info.dbfile = tzplatform_mkpath(TZ_SYS_DB, ".shortcut_service.db"); - ret = db_util_open(s_info.dbfile, &s_info.handle, DB_UTIL_REGISTER_HOOK_METHOD); - if (ret != SQLITE_OK) { - ErrPrint("Failed to open a DB\n"); - return -EIO; - } - - if (lstat(s_info.dbfile, &stat) < 0) { - ErrPrint("%s\n", strerror(errno)); - db_util_close(s_info.handle); - s_info.handle = NULL; - return -EIO; - } - - if (!S_ISREG(stat.st_mode)) { - ErrPrint("Invalid file\n"); - db_util_close(s_info.handle); - s_info.handle = NULL; - return -EINVAL; - } - - if (!stat.st_size) { - db_create_table(); - } - - return 0; -} - -static int db_fini(void) -{ - if (!s_info.handle) { - return 0; - } - - db_util_close(s_info.handle); - s_info.handle = NULL; - - return 0; -} - -static int do_uninstall(const char *appid) -{ - int ret; - - ret = db_remove_by_pkgid(appid); - if (ret < 0) { - ErrPrint("Failed to remove a record: %s\n", appid); - return ret; - } - - ret = db_remove_name_by_pkgid(appid); - if (ret < 0) { - ErrPrint("Failed to remove name records: %s\n", appid); - return ret; - } - - return 0; -} - -static inline struct i18n_name *find_i18n_name(struct dlist *i18n_list, xmlChar *lang) -{ - struct dlist *l; - struct i18n_name *i18n; - - dlist_foreach(i18n_list, l, i18n) { - if (!xmlStrcasecmp(i18n->lang, lang)) { - return i18n; - } - } - - return NULL; -} - -static inline struct i18n_name *create_i18n_name(xmlChar *lang, xmlChar *name, xmlChar *icon) -{ - struct i18n_name *i18n; - - i18n = malloc(sizeof(*i18n)); - if (!i18n) { - ErrPrint("Heap: %s\n", strerror(errno)); - return NULL; - } - - i18n->lang = lang; - i18n->name = name; - i18n->icon = icon; - - return i18n; -} - -static inline void destroy_i18n_name(struct i18n_name *i18n) -{ - xmlFree(i18n->lang); - xmlFree(i18n->name); - xmlFree(i18n->icon); - free(i18n); -} - -static int do_install(xmlDocPtr docPtr, const char *appid) -{ - xmlNodePtr node = NULL; - xmlNodePtr child = NULL; - xmlChar *key; - xmlChar *data; - xmlChar *name; - xmlChar *icon; - xmlChar *lang; - xmlChar *shortcut_appid; - xmlNodePtr root; - struct i18n_name *i18n; - struct dlist *i18n_list = NULL; - struct dlist *l; - struct dlist *n; - int id; - - root = xmlDocGetRootElement(docPtr); - if (!root) { - ErrPrint("Invalid node ptr\n"); - return -EINVAL; - } - - for (root = root->children; root; root = root->next) { - if (!xmlStrcasecmp(root->name, (const xmlChar *)"shortcut-list")) { - break; - } - } - - if (!root) { - ErrPrint("Root has no children\n"); - return -EINVAL; - } - - DbgPrint("AppID: %s\n", appid); - - root = root->children; /* Jump to children node */ - for (node = root; node; node = node->next) { - if (node->type == XML_ELEMENT_NODE) { - DbgPrint("Element %s\n", node->name); - } - - if (xmlStrcasecmp(node->name, (const xmlChar *)"shortcut")) { - continue; - } - - if (!xmlHasProp(node, (xmlChar *)"extra_key") || !xmlHasProp(node, (xmlChar *)"extra_data")) { - DbgPrint("Invalid element %s\n", node->name); - continue; - } - - key = xmlGetProp(node, (xmlChar *)"extra_key"); - data = xmlGetProp(node, (xmlChar *)"extra_data"); - shortcut_appid = xmlGetProp(node, (xmlChar *)"appid"); - - icon = NULL; - name = NULL; - for (child = node->children; child; child = child->next) { - if (!xmlStrcasecmp(child->name, (const xmlChar *)"icon")) { - lang = xmlNodeGetLang(child); - if (!lang) { - if (icon) { - DbgPrint("Default icon is duplicated\n"); - } else { - icon = xmlNodeGetContent(child); - DbgPrint("Default icon is %s\n", icon); - } - - continue; - } - - i18n = find_i18n_name(i18n_list, lang); - if (i18n) { - xmlFree(lang); - - if (i18n->icon) { - DbgPrint("%s is duplicated\n", i18n->icon); - continue; - } - - i18n->icon = xmlNodeGetContent(child); - } else { - i18n = create_i18n_name(lang, NULL, xmlNodeGetContent(child)); - if (!i18n) { - ErrPrint("Failed to create a new i18n_name\n"); - continue; - } - i18n_list = dlist_append(i18n_list, i18n); - } - - continue; - } - - if (!xmlStrcasecmp(child->name, (const xmlChar *)"label")) { - lang = xmlNodeGetLang(child); - if (!lang) { - if (name) { - DbgPrint("Default name is duplicated\n"); - } else { - name = xmlNodeGetContent(child); - DbgPrint("Default name is %s\n", name); - } - - continue; - } - - i18n = find_i18n_name(i18n_list, lang); - if (i18n) { - xmlFree(lang); - - if (i18n->name) { - DbgPrint("%s is duplicated\n", i18n->name); - continue; - } - - i18n->name = xmlNodeGetContent(child); - } else { - i18n = create_i18n_name(lang, xmlNodeGetContent(child), NULL); - if (!i18n) { - ErrPrint("Failed to create a new i18n_name\n"); - continue; - } - i18n_list = dlist_append(i18n_list, i18n); - } - - continue; - } - } - - DbgPrint("appid: %s\n", appid); - DbgPrint("shortcut appid: %s\n", shortcut_appid); - DbgPrint("key: %s\n", key); - DbgPrint("data: %s\n", data); - DbgPrint("icon: %s\n", icon); - DbgPrint("Default name: %s\n", name); - - if (!shortcut_appid) { - shortcut_appid = xmlStrdup((xmlChar *)appid); - DbgPrint("Use the default appid\n"); - } - - begin_transaction(); - if (db_insert_record(appid, (char *)shortcut_appid, (char *)icon, (char *)name, (char *)key, (char *)data) < 0) { - ErrPrint("Failed to insert a new record\n"); - rollback_transaction(); - - dlist_foreach_safe(i18n_list, l, n, i18n) { - i18n_list = dlist_remove(i18n_list, l); - destroy_i18n_name(i18n); - } - } else { - id = db_get_id((char *)appid, (char *)shortcut_appid, (char *)key, (char *)data); - if (id < 0) { - ErrPrint("Failed to insert a new record\n"); - rollback_transaction(); - - dlist_foreach_safe(i18n_list, l, n, i18n) { - i18n_list = dlist_remove(i18n_list, l); - destroy_i18n_name(i18n); - } - } else { - dlist_foreach_safe(i18n_list, l, n, i18n) { - i18n_list = dlist_remove(i18n_list, l); - if (db_insert_name(id, appid, (char *)i18n->lang, (char *)i18n->name, (char *)i18n->icon) < 0) { - ErrPrint("Failed to add i18n name: %s(%s)\n", i18n->name, i18n->lang); - } - destroy_i18n_name(i18n); - } - commit_transaction(); - } - } - - xmlFree(key); - xmlFree(data); - xmlFree(icon); - xmlFree(name); - xmlFree(shortcut_appid); - } - - return 0; -} - -int PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL(const char *appid) -{ - if (!s_info.handle) { - if (db_init() < 0) { - return -EIO; - } - } - - do_upgrade_db_schema(); - return 0; -} - -int PKGMGR_PARSER_PLUGIN_POST_UNINSTALL(const char *appid) -{ - int ret; - - begin_transaction(); - ret = do_uninstall(appid); - if (ret < 0) { - rollback_transaction(); - return ret; - } - commit_transaction(); - - db_fini(); - return 0; -} - -int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr docPtr, const char *_appid) -{ - xmlNodePtr node = NULL; - xmlChar *key; - xmlChar *data; - xmlChar *appid; - xmlNodePtr root; - int id; - - if (!docPtr) { - DbgPrint("Package manager doesn't support the docPtr (%s)\n", _appid); - return 0; - } - - root = xmlDocGetRootElement(docPtr); - if (!root) { - ErrPrint("Invalid node ptr\n"); - return -EINVAL; - } - - for (root = root->children; root; root = root->next) { - if (!xmlStrcasecmp(root->name, (const xmlChar *)"shortcut-list")) { - break; - } - } - - if (!root) { - ErrPrint("Root has no shortcut-list\n"); - return -EINVAL; - } - - DbgPrint("AppID: %s\n", _appid); - root = root->children; - for (node = root; node; node = node->next) { - if (node->type == XML_ELEMENT_NODE) { - DbgPrint("Element %s\n", node->name); - } - - if (xmlStrcasecmp(node->name, (const xmlChar *)"shortcut")) { - continue; - } - - if (!xmlHasProp(node, (xmlChar *)"extra_data") - || !xmlHasProp(node, (xmlChar *)"extra_key") - || !xmlHasProp(node, (xmlChar *)"appid")) - { - DbgPrint("Invalid element %s\n", node->name); - continue; - } - - appid = xmlGetProp(node, (xmlChar *)"appid"); - key = xmlGetProp(node, (xmlChar *)"extra_key"); - data = xmlGetProp(node, (xmlChar *)"extra_data"); - - DbgPrint("appid: %s\n", appid); - DbgPrint("key: %s\n", key); - DbgPrint("data: %s\n", data); - - id = db_get_id("", (char *)appid, (char *)key, (char *)data); - if (id < 0) { - ErrPrint("No records found\n"); - xmlFree(appid); - xmlFree(key); - xmlFree(data); - continue; - } - - begin_transaction(); - if (db_remove_record("", (char *)appid, (char *)key, (char *)data) < 0) { - ErrPrint("Failed to remove a record\n"); - rollback_transaction(); - xmlFree(appid); - xmlFree(key); - xmlFree(data); - continue; - } - - if (db_remove_name(id) < 0) { - ErrPrint("Failed to remove name records\n"); - rollback_transaction(); - xmlFree(appid); - xmlFree(key); - xmlFree(data); - continue; - } - commit_transaction(); - - xmlFree(appid); - xmlFree(key); - xmlFree(data); - - /*! - * \note - * if (node->children) - * DbgPrint("Skip this node's children\n"); - */ - } - - return 0; -} - -int PKGMGR_PARSER_PLUGIN_PRE_INSTALL(const char *appid) -{ - int ret; - - if (!s_info.handle) { - if (db_init() < 0) { - return -EIO; - } - } - - do_upgrade_db_schema(); - - begin_transaction(); - ret = do_uninstall(appid); - if (ret < 0) { - ErrPrint("Failed to remove record: %s\n", appid); - /* Keep going */ - } - commit_transaction(); - return 0; -} - -int PKGMGR_PARSER_PLUGIN_POST_INSTALL(const char *appid) -{ - db_fini(); - return 0; -} - -int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr docPtr, const char *appid) -{ - return do_install(docPtr, appid); -} - -int PKGMGR_PARSER_PLUGIN_PRE_UPGRADE(const char *appid) -{ - int ret; - - if (!s_info.handle) { - if (db_init() < 0) { - return -EIO; - } - } - - do_upgrade_db_schema(); - - begin_transaction(); - ret = do_uninstall(appid); - if (ret < 0) { - ErrPrint("Failed to remove a record: %s\n", appid); - /* Keep going */ - } - commit_transaction(); - return 0; -} - -int PKGMGR_PARSER_PLUGIN_POST_UPGRADE(const char *appid) -{ - db_fini(); - return 0; -} - -int PKGMGR_PARSER_PLUGIN_UPGRADE(xmlDocPtr docPtr, const char *appid) -{ - /* So... ugly */ - return do_install(docPtr, appid); -} - -/* -int main(int argc, char *argv[]) -{ - xmlDoc *doc; - xmlNode *root; - - if (argc != 2) { - ErrPRint("Invalid argument: %s XML_FILENAME\n", argv[0]); - return -EINVAL; - } - - doc = xmlReadFile(argv[1], NULL, 0); - if (!doc) { - ErrPrint("Failed to parse %s\n", argv[1]); - return -EIO; - } - - root = xmlDocGetRootElement(doc); - - db_init(); - install_shortcut("", root); - db_fini(); - - xmlFreeDoc(doc); - xmlCleanupParser(); - return 0; -} -*/ - -/* End of a file */ diff --git a/sample.xml b/sample.xml deleted file mode 100644 index 0e471a0..0000000 --- a/sample.xml +++ /dev/null @@ -1,62 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.myapp" version="0.3.5" install-location="auto"> -<shortcut-list test="a"> - <shortcut appid="org.tizen.myapp" extra_key="key" extra_data="SERVICE INFORMATION 1"> - <icon>/opt/usr/apps/org.tizen.myapp/res/icon/myapp_shortcut01.png</icon> - <label>Default Name</label> - <label xml:lang="en-us">Name en</label> - <label xml:lang="nl-nl">Name nl</label> - <label xml:lang="de-de">Name de</label> - <label xml:lang="zh-hk">Name hk</label> - <label xml:lang="zh-cn">Name cn</label> - <label xml:lang="ru-ru">Name ru</label> - <label xml:lang="zh-tw">Name tw</label> - <label xml:lang="ja-jp">Name jp</label> - <label xml:lang="es-es">Name es</label> - <label xml:lang="el-gr">Name gr</label> - <label xml:lang="it-it">Name it</label> - <label xml:lang="tr-tr">Name tr</label> - <label xml:lang="pt-pt">Name pt</label> - <label xml:lang="fr-fr">Name fr</label> - <label xml:lang="kor-kr">Name kr</label> - </shortcut> - <shortcut appid="org.tizen.myapp-gadget" extra_key="key" extra_data="SERVICE INFORMATION 2"> - <icon>/opt/usr/apps/org.tizen.myapp/res/icon/gadget_shortcut01.png</icon> - <label>Default Name 02</label> - <label xml:lang="en-us">Name en</label> - <label xml:lang="nl-nl">Name nl</label> - <label xml:lang="de-de">Name de</label> - <label xml:lang="zh-hk">Name hk</label> - <label xml:lang="zh-cn">Name cn</label> - <label xml:lang="ru-ru">Name ru</label> - <label xml:lang="zh-tw">Name tw</label> - <label xml:lang="ja-jp">Name jp</label> - <label xml:lang="es-es">Name es</label> - <label xml:lang="el-gr">Name gr</label> - <label xml:lang="it-it">Name it</label> - <label xml:lang="tr-tr">Name tr</label> - <label xml:lang="pt-pt">Name pt</label> - <label xml:lang="fr-fr">Name fr</label> - <label xml:lang="kor-kr">Name kr</label> - </shortcut> - <shortcut appid="org.tizen.myapp" extra_key="key" extra_data="SERVICE INFORMATION 3"> - <icon>/opt/usr/apps/org.tizen.myapp/res/icon/mayapp_shortcut02.png</icon> - <label>Default Name 03</label> - <label xml:lang="en-us">Name en</label> - <label xml:lang="nl-nl">Name nl</label> - <label xml:lang="de-de">Name de</label> - <label xml:lang="zh-hk">Name hk</label> - <label xml:lang="zh-cn">Name cn</label> - <label xml:lang="ru-ru">Name ru</label> - <label xml:lang="zh-tw">Name tw</label> - <label xml:lang="ja-jp">Name jp</label> - <label xml:lang="es-es">Name es</label> - <label xml:lang="el-gr">Name gr</label> - <label xml:lang="it-it">Name it</label> - <label xml:lang="tr-tr">Name tr</label> - <label xml:lang="pt-pt">Name pt</label> - <label xml:lang="fr-fr">Name fr</label> - <label xml:lang="kor-kr">Name kr</label> - </shortcut> -</shortcut-list> -</manifest> diff --git a/test/Makefile b/test/Makefile deleted file mode 100644 index abe5c1b..0000000 --- a/test/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -all: - @gcc homescreen.c -Wall -o homescreen `pkg-config ecore elementary shortcut --cflags --libs` - @gcc application.c -Wall -o application `pkg-config ecore elementary shortcut --cflags --libs` - @gcc shortcut.c -Wall -o shortcut `pkg-config ecore elementary shortcut --cflags --libs` diff --git a/test/application.c b/test/application.c deleted file mode 100644 index 886cff3..0000000 --- a/test/application.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. - * - * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 - * - * 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 <Elementary.h> -#include <shortcut.h> - -/* For multi-user support */ -#include <tzplatform_config.h> - -#define FILE_PNG tzplatform_mkpath(TZ_SYS_SHARE, "image/what.png") - -static int result_cb(int ret, int pid, void *data) -{ - printf("Client: Return %d (%d)\n", ret, pid); - //elm_exit(); - return 0; -} - -static Eina_Bool shortcut_add_cb(void *data) -{ - int ret; - - ret = add_to_home_shortcut("pkgname", "MyName", 0, "/usr/bin/true", FILE_PNG, result_cb, NULL); - printf("Client: shortcut_add_to_home returns: %d\n", ret); - - ret = add_to_home_livebox("pkgname", "MyName", 0, "/usr/bin/true", FILE_PNG, 1.0f, result_cb, NULL); - printf("Client: shortcut_add_to_home_with_period returns: %d\n", ret); - - return ECORE_CALLBACK_RENEW; -} - -int elm_main(int argc, char *argv[]) -{ - Ecore_Timer *timer; - - timer = ecore_timer_add(3.0f, shortcut_add_cb, NULL); - if (!timer) { - printf("Failed to add a timer\n"); - } - - elm_run(); - elm_shutdown(); - - return 0; -} - -ELM_MAIN() -/* End of a file */ diff --git a/test/homescreen.c b/test/homescreen.c deleted file mode 100644 index 0b6c5f7..0000000 --- a/test/homescreen.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. - * - * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 - * - * 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 <Elementary.h> -#include <shortcut.h> - -int shortcut_request_cb(const char *pkgname, const char *name, int type, const char *exec, const char *icon, int pid, double period, void *data) -{ - printf("SERVER: name: %s, type: %d, exec: %s, icon: %s, pid: %d, data: %p, period: %lf\n", - name, type, exec, icon, pid, data, period); - return 0; -} - -int elm_main(int argc, char *argv[]) -{ - shortcut_set_request_cb(shortcut_request_cb, NULL); - - elm_run(); - elm_shutdown(); - - return 0; -} - -ELM_MAIN() -/* End of a file */ - diff --git a/test/icon.c b/test/icon.c deleted file mode 100644 index 71547c5..0000000 --- a/test/icon.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. - * - * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 - * - * 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 <Elementary.h> -#include <shortcut.h> - -/* For multi-user support */ -#include <tzplatform_config.h> - -#define USR_SHARE tzplatform_getenv(TZ_USER_SHARE) - -static int result_cb(struct shortcut_icon *handle, int ret, void *data) -{ - printf("Client: Return %d (%p)\n", ret, handle); - return 0; -} - -static Eina_Bool test_main(void *data) -{ - struct shortcut_icon *handle; - static int idx = 0; - int ret; - char filename[256]; - int type; - - idx++; - - handle = shortcut_icon_request_create(); - if (!handle) { - printf("Failed to create a request\n"); - return ECORE_CALLBACK_RENEW; - } - - printf("Test: %d\n", idx); - ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_IMAGE, DEFAULT_ICON_PART, "/usr/share/icons/default/small/org.tizen.music-player.png", NULL, NULL); - printf("NAME set_info: %d\n", ret); - - snprintf(filename, sizeof(filename), "App Name %d", idx); - ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_TEXT, DEFAULT_NAME_PART, filename, NULL, NULL); - printf("TEXT set_info: %d\n", ret); - - snprintf(filename, sizeof(filename), "%s/live_magazine/always/out%d.png", USR_SHARE, idx); - - switch (idx % 7) { - case 0: type = LIVEBOX_TYPE_1x1; break; - case 1: type = LIVEBOX_TYPE_2x1; break; - case 2: type = LIVEBOX_TYPE_2x2; break; - case 3: type = LIVEBOX_TYPE_4x1; break; - case 4: type = LIVEBOX_TYPE_4x2; break; - case 5: type = LIVEBOX_TYPE_4x3; break; - case 6: type = LIVEBOX_TYPE_4x4; break; - default: type = LIVEBOX_TYPE_1x1; break; - } - - ret = shortcut_icon_request_send(handle, type, NULL, NULL, filename, result_cb, NULL); - printf("request: %d\n", ret); - - ret = shortcut_icon_request_destroy(handle); - printf("destroy: %d\n", ret); - return ECORE_CALLBACK_RENEW; -} - -static int initialized_cb(int status, void *data) -{ - printf("Hello initializer\n"); - return 0; -} - -int elm_main(int argc, char *argv[]) -{ - shortcut_icon_service_init(NULL, NULL); - - ecore_timer_add(5.0f, test_main, NULL); - - elm_run(); - shortcut_icon_service_fini(); - elm_shutdown(); - return 0; -} - -ELM_MAIN() -/* End of a file */ diff --git a/test/shortcut.c b/test/shortcut.c deleted file mode 100644 index eb8b5d6..0000000 --- a/test/shortcut.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. - * - * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 - * - * 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 <Elementary.h> -#include <shortcut.h> - -static int shortcut_list_cb(const char *appid, const char *icon, const char *name, const char *extra_key, const char *extra_data, void *data) -{ - printf("appid[%s] icon[%s], name[%s] extra_key[%s], extra_ata[%s]\n", appid, icon, name, extra_key, extra_data); - return 0; -} - -int elm_main(int argc, char *argv[]) -{ - int ret; - ret = shortcut_get_list(NULL, shortcut_list_cb, NULL); - if (ret < 0) - printf("Error: %d\n", ret); - - elm_run(); - elm_shutdown(); - - return 0; -} - -ELM_MAIN() -/* End of a file */ diff --git a/test_db_builder.sh b/test_db_builder.sh deleted file mode 100755 index 6e20008..0000000 --- a/test_db_builder.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/sh -#/* -# * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. -# * -# * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 -# * -# * 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. -# * -#*/ - -eval $(tzplatform-get TZ_SYS_DB) -DBFILE=$TZ_SYS_DB"/.shortcut_service.db" - -APPID=( -"org.tizen.facebook" -"org.tizen.facebook" -"org.tizen.facebook" -"org.tizen.facebook" -"org.tizen.facebook" -) - -ICON=( -"" -"" -"" -"" -"" -) - -NAME=( -"Friend's wall" -"Groups" -"Update status" -"Like by me" -"My wall" -) - -KEY=( -"livebox_shortcut_type" -"livebox_shortcut_type" -"livebox_shortcut_type" -"livebox_shortcut_type" -"livebox_shortcut_type" -) - -VALUE=( -"shortcut_friends" -"shortcut_groups" -"shortcut_post" -"shortcut_like" -"shortcut_me" -) - -CNT=0 -ERR=0 -MAX=5 - -sqlite3 $DBFILE "CREATE TABLE shortcut_service (id INTEGER PRIMARY KEY AUTOINCREMENT, appid TEXT, icon TEXT, name TEXT, extra_key TEXT, extra_data TEXT)" -sqlite3 $DBFILE "CREATE TABLE shortcut_name (id INTEGER, lang TEXT, name TEXT)" -while [ $CNT -lt $MAX ] -do - echo "Insert a new record ('${APPID[$CNT]}', '${ICON[$CNT]}', '${NAME[$CNT]}', \"${KEY[$CNT]}\", \"${VALUE[$CNT]}\")" - sqlite3 $DBFILE "INSERT INTO shortcut_service (appid, icon, name, extra_key, extra_data) VALUES ('${APPID[$CNT]}', '${ICON[$CNT]}', \"${NAME[$CNT]}\", \"${KEY[$CNT]}\", \"${VALUE[$CNT]}\")" 2>/dev/null - if [ $? -ne 0 ]; then - let ERR=$ERR+1 - fi - ID=`sqlite3 $DBFILE "SELECT id FROM shortcut_service WHERE appid = \"${APPID[$CNT]}\" AND extra_key = \"${KEY[$CNT]}\" AND extra_data = \"${VALUE[$CNT]}\""` - echo "Insert a name: \"${NAME[$CNT]}\"" - sqlite3 $DBFILE "INSERT INTO shortcut_name (id, lang, name) VALUES ('$ID', 'en-us', \"${NAME[CNT]}\")" - let CNT=$CNT+1 -done - -echo "Error/Total: $ERR/$CNT" |