--- /dev/null
+Sunghyuk Lee <sunghyuk.lee@samsung.com>
+Jin Yoon <jinny.yoon@samsung.com>
--- /dev/null
+# AIL build script
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(ail C)
+
+SET(LIBNAME "lib${PROJECT_NAME}")
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(BINDIR "${PREFIX}/bin")
+SET(LIBDIR "${PREFIX}/lib")
+SET(INCLUDEDIR "${PREFIX}/include")
+SET(VERSION_MAJOR 0)
+SET(VERSION "${VERSION_MAJOR}.1.0")
+
+# Add definitions
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-DPKGTYPE=\"${BUILD_PKGTYPE}\"")
+
+EXECUTE_PROCESS(COMMAND ../build_util/code_gen.sh)
+
+SET(SRCS
+ src/ail_db.c
+ src/ail_filter.c
+ src/ail_sql.c
+ src/ail_package.c
+ src/ail_desktop.c
+ src/ail_convert.c
+)
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+
+INCLUDE(FindPkgConfig)
+
+pkg_check_modules(LPKGS REQUIRED glib-2.0 sqlite3 dlog db-util xdgmime vconf)
+STRING(REPLACE ";" " " EXTRA_CFLAGS "${LPKGS_CFLAGS}")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+
+# Make libraries
+ADD_LIBRARY(${LIBNAME} SHARED ${SRCS})
+TARGET_LINK_LIBRARIES(${LIBNAME} ${LPKGS_LIBRARIES})
+SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
+SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES VERSION ${VERSION})
+SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
+
+# PC file
+CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc @ONLY)
+
+# Install
+INSTALL(TARGETS ${LIBNAME} DESTINATION lib)
+INSTALL(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION lib/pkgconfig)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/ail.h DESTINATION include)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/desktop.conf DESTINATION share/install-info)
+
+# AIL init database
+ADD_SUBDIRECTORY(initdb)
+
--- /dev/null
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+ Apache License\r
+ Version 2.0, January 2004\r
+ http://www.apache.org/licenses/\r
+\r
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+ 1. Definitions.\r
+\r
+ "License" shall mean the terms and conditions for use, reproduction,\r
+ and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+ "Licensor" shall mean the copyright owner or entity authorized by\r
+ the copyright owner that is granting the License.\r
+\r
+ "Legal Entity" shall mean the union of the acting entity and all\r
+ other entities that control, are controlled by, or are under common\r
+ control with that entity. For the purposes of this definition,\r
+ "control" means (i) the power, direct or indirect, to cause the\r
+ direction or management of such entity, whether by contract or\r
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+ outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+ "You" (or "Your") shall mean an individual or Legal Entity\r
+ exercising permissions granted by this License.\r
+\r
+ "Source" form shall mean the preferred form for making modifications,\r
+ including but not limited to software source code, documentation\r
+ source, and configuration files.\r
+\r
+ "Object" form shall mean any form resulting from mechanical\r
+ transformation or translation of a Source form, including but\r
+ not limited to compiled object code, generated documentation,\r
+ and conversions to other media types.\r
+\r
+ "Work" shall mean the work of authorship, whether in Source or\r
+ Object form, made available under the License, as indicated by a\r
+ copyright notice that is included in or attached to the work\r
+ (an example is provided in the Appendix below).\r
+\r
+ "Derivative Works" shall mean any work, whether in Source or Object\r
+ form, that is based on (or derived from) the Work and for which the\r
+ editorial revisions, annotations, elaborations, or other modifications\r
+ represent, as a whole, an original work of authorship. For the purposes\r
+ of this License, Derivative Works shall not include works that remain\r
+ separable from, or merely link (or bind by name) to the interfaces of,\r
+ the Work and Derivative Works thereof.\r
+\r
+ "Contribution" shall mean any work of authorship, including\r
+ the original version of the Work and any modifications or additions\r
+ to that Work or Derivative Works thereof, that is intentionally\r
+ submitted to Licensor for inclusion in the Work by the copyright owner\r
+ or by an individual or Legal Entity authorized to submit on behalf of\r
+ the copyright owner. For the purposes of this definition, "submitted"\r
+ means any form of electronic, verbal, or written communication sent\r
+ to the Licensor or its representatives, including but not limited to\r
+ communication on electronic mailing lists, source code control systems,\r
+ and issue tracking systems that are managed by, or on behalf of, the\r
+ Licensor for the purpose of discussing and improving the Work, but\r
+ excluding communication that is conspicuously marked or otherwise\r
+ designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+ "Contributor" shall mean Licensor and any individual or Legal Entity\r
+ on behalf of whom a Contribution has been received by Licensor and\r
+ subsequently incorporated within the Work.\r
+\r
+ 2. Grant of Copyright License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ copyright license to reproduce, prepare Derivative Works of,\r
+ publicly display, publicly perform, sublicense, and distribute the\r
+ Work and such Derivative Works in Source or Object form.\r
+\r
+ 3. Grant of Patent License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ (except as stated in this section) patent license to make, have made,\r
+ use, offer to sell, sell, import, and otherwise transfer the Work,\r
+ where such license applies only to those patent claims licensable\r
+ by such Contributor that are necessarily infringed by their\r
+ Contribution(s) alone or by combination of their Contribution(s)\r
+ with the Work to which such Contribution(s) was submitted. If You\r
+ institute patent litigation against any entity (including a\r
+ cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+ or a Contribution incorporated within the Work constitutes direct\r
+ or contributory patent infringement, then any patent licenses\r
+ granted to You under this License for that Work shall terminate\r
+ as of the date such litigation is filed.\r
+\r
+ 4. Redistribution. You may reproduce and distribute copies of the\r
+ Work or Derivative Works thereof in any medium, with or without\r
+ modifications, and in Source or Object form, provided that You\r
+ meet the following conditions:\r
+\r
+ (a) You must give any other recipients of the Work or\r
+ Derivative Works a copy of this License; and\r
+\r
+ (b) You must cause any modified files to carry prominent notices\r
+ stating that You changed the files; and\r
+\r
+ (c) You must retain, in the Source form of any Derivative Works\r
+ that You distribute, all copyright, patent, trademark, and\r
+ attribution notices from the Source form of the Work,\r
+ excluding those notices that do not pertain to any part of\r
+ the Derivative Works; and\r
+\r
+ (d) If the Work includes a "NOTICE" text file as part of its\r
+ distribution, then any Derivative Works that You distribute must\r
+ include a readable copy of the attribution notices contained\r
+ within such NOTICE file, excluding those notices that do not\r
+ pertain to any part of the Derivative Works, in at least one\r
+ of the following places: within a NOTICE text file distributed\r
+ as part of the Derivative Works; within the Source form or\r
+ documentation, if provided along with the Derivative Works; or,\r
+ within a display generated by the Derivative Works, if and\r
+ wherever such third-party notices normally appear. The contents\r
+ of the NOTICE file are for informational purposes only and\r
+ do not modify the License. You may add Your own attribution\r
+ notices within Derivative Works that You distribute, alongside\r
+ or as an addendum to the NOTICE text from the Work, provided\r
+ that such additional attribution notices cannot be construed\r
+ as modifying the License.\r
+\r
+ You may add Your own copyright statement to Your modifications and\r
+ may provide additional or different license terms and conditions\r
+ for use, reproduction, or distribution of Your modifications, or\r
+ for any such Derivative Works as a whole, provided Your use,\r
+ reproduction, and distribution of the Work otherwise complies with\r
+ the conditions stated in this License.\r
+\r
+ 5. Submission of Contributions. Unless You explicitly state otherwise,\r
+ any Contribution intentionally submitted for inclusion in the Work\r
+ by You to the Licensor shall be under the terms and conditions of\r
+ this License, without any additional terms or conditions.\r
+ Notwithstanding the above, nothing herein shall supersede or modify\r
+ the terms of any separate license agreement you may have executed\r
+ with Licensor regarding such Contributions.\r
+\r
+ 6. Trademarks. This License does not grant permission to use the trade\r
+ names, trademarks, service marks, or product names of the Licensor,\r
+ except as required for reasonable and customary use in describing the\r
+ origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+ 7. Disclaimer of Warranty. Unless required by applicable law or\r
+ agreed to in writing, Licensor provides the Work (and each\r
+ Contributor provides its Contributions) on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+ implied, including, without limitation, any warranties or conditions\r
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+ PARTICULAR PURPOSE. You are solely responsible for determining the\r
+ appropriateness of using or redistributing the Work and assume any\r
+ risks associated with Your exercise of permissions under this License.\r
+\r
+ 8. Limitation of Liability. In no event and under no legal theory,\r
+ whether in tort (including negligence), contract, or otherwise,\r
+ unless required by applicable law (such as deliberate and grossly\r
+ negligent acts) or agreed to in writing, shall any Contributor be\r
+ liable to You for damages, including any direct, indirect, special,\r
+ incidental, or consequential damages of any character arising as a\r
+ result of this License or out of the use or inability to use the\r
+ Work (including but not limited to damages for loss of goodwill,\r
+ work stoppage, computer failure or malfunction, or any and all\r
+ other commercial damages or losses), even if such Contributor\r
+ has been advised of the possibility of such damages.\r
+\r
+ 9. Accepting Warranty or Additional Liability. While redistributing\r
+ the Work or Derivative Works thereof, You may choose to offer,\r
+ and charge a fee for, acceptance of support, warranty, indemnity,\r
+ or other liability obligations and/or rights consistent with this\r
+ License. However, in accepting such obligations, You may act only\r
+ on Your own behalf and on Your sole responsibility, not on behalf\r
+ of any other Contributor, and only if You agree to indemnify,\r
+ defend, and hold each Contributor harmless for any liability\r
+ incurred by, or claims asserted against, such Contributor by reason\r
+ of your accepting any such warranty or additional liability.\r
+\r
+ END OF TERMS AND CONDITIONS\r
+\r
+ APPENDIX: How to apply the Apache License to your work.\r
+\r
+ To apply the Apache License to your work, attach the following\r
+ boilerplate notice, with the fields enclosed by brackets "[]"\r
+ replaced with your own identifying information. (Don't include\r
+ the brackets!) The text should be enclosed in the appropriate\r
+ comment syntax for the file format. We also recommend that a\r
+ file or class name and description of purpose be included on the\r
+ same "printed page" as the copyright notice for easier\r
+ identification within third-party archives.\r
+\r
+ Copyright [yyyy] [name of copyright owner]\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
--- /dev/null
+<manifest>
+ <define>
+ <domain name="ail"/>
+ <provide>
+ <label name="ail::db"/>
+ </provide>
+ </define>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
--- /dev/null
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: ail
+Description: Application Information Library
+Version: @VERSION@
+Requires: sqlite3 vconf dlog db-util
+Libs: -L@LIBDIR@ -lail
+Cflags: -I@INCLUDEDIR@
--- /dev/null
+ail-0 (0.2.41) unstable; urgency=low
+
+ * Git: slp/pkgs/a/ail
+ * Tag: ail-0_0.2.41
+
+ * [Modify] Fixed initdb checking
+
+ -- Sewook Park <sewook7.park@samsung.com> Wed, 13 Jun 2012 13:26:43 +0900
+
+ail-0 (0.2.40) unstable; urgency=low
+
+ * Git: slp/pkgs/a/ail
+ * Tag: ail-0_0.2.40
+
+ * [Modify] Applied installed-time field
+
+ -- Sewook Park <sewook7.park@samsung.com> Tue, 12 Jun 2012 10:28:21 +0900
+
+ail-0 (0.2.39) unstable; urgency=low
+
+ * Git: slp/pkgs/a/ail
+ * Tag: ail-0_0.2.39
+
+ * [Modify] Fixed bug
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Tue, 05 Jun 2012 17:07:40 +0900
+
+ail-0 (0.2.38) unstable; urgency=low
+
+ * Git: slp/pkgs/a/ail
+ * Tag: ail-0_0.2.38
+
+ * [Modify] Changed to use applicationID
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Tue, 05 Jun 2012 17:07:40 +0900
+
+ail-0 (0.2.37) unstable; urgency=low
+
+ * Git: slp/pkgs/a/ail
+ * Tag: ail-0_0.2.37
+
+ * [Modify] Added path for desktop file
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Tue, 05 Jun 2012 17:07:40 +0900
+
+ail-0 (0.2.36) unstable; urgency=low
+
+ * Git: slp/pkgs/a/ail
+ * Tag: ail-0_0.2.36
+
+ * [Modify] Changed API name
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Tue, 05 Jun 2012 17:07:40 +0900
+
+ail-0 (0.2.35) unstable; urgency=low
+
+ * Git: slp/pkgs/a/ail
+ * Tag: ail-0_0.2.35
+
+ * [Modify] add a path for desktop file
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Fri, 11 May 2012 17:14:40 +0900
+
+ail-0 (0.2.34) unstable; urgency=low
+
+ * Git: slp/pkgs/a/ail
+ * Tag: ail-0_0.2.34
+
+ * [Modify] add a path for desktop icons
+
+ -- Jinwoo Nam <jwoo.nam@samsung.com> Fri, 27 Apr 2012 14:33:31 +0900
+
+ail-0 (0.2.33) unstable; urgency=low
+
+ * Git: slp/pkgs/a/ail
+ * Tag: ail-0_0.2.33
+
+ * [Modify] Added Inactivated field
+
+ -- Sewook Park <sewook7.park@samsung.com> Fri, 06 Apr 2012 14:36:07 +0900
+
+ail-0 (0.2.32) unstable; urgency=low
+
+ * Git: slp/pkgs/a/ail
+ * Tag: ail-0_0.2.32
+
+ * [Modify] Fixed bug
+
+ -- Sewook Park <sewook7.park@samsung.com> Thu, 05 Apr 2012 23:06:49 +0900
+
+ail-0 (0.2.31) unstable; urgency=low
+
+ * Git: slp/pkgs/a/ail
+ * Tag: ail-0_0.2.31
+
+ * [Modify] Fixed AIL db permission, Cleaned up code
+
+ -- Sewook Park <sewook7.park@samsung.com> Mon, 02 Apr 2012 13:35:13 +0900
+
+ail-0 (0.2.30) unstable; urgency=low
+
+ * Git: slp/pkgs/a/ail
+ * Tag: ail-0_0.2.30
+
+ * [Modify] Fixed db open mode according to API
+
+ -- Sewook Park <sewook7.park@samsung.com> Thu, 29 Mar 2012 13:47:48 +0900
+
+ail-0 (0.2.29) unstable; urgency=low
+
+ * Git: slp/pkgs/a/ail
+ * Tag: ail-0_0.2.29
+
+ * [Modify] changed pkgtype according to build system
+
+ -- Sewook Park <sewook7.park@samsung.com> Wed, 28 Mar 2012 16:14:59 +0900
+
+ail-0 (0.2.28) unstable; urgency=low
+
+ * Git: slp/pkgs/a/ail
+ * Tag: ail-0_0.2.28
+
+ * [Modify] Fixed complie warnings
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Tue, 20 Mar 2012 13:37:41 +0900
+
+ail-0 (0.2.27) unstable; urgency=low
+
+ * Git: slp/pkgs/a/ail
+ * Tag: ail-0_0.2.27
+
+ * [Modify] Removed unused AIL field
+
+ -- Sewook Park <sewook7.park@samsung.com> Sat, 17 Mar 2012 21:20:35 +0900
+
+ail-0 (0.2.26) unstable; urgency=low
+
+ * Git: slp/pkgs/a/ail
+ * Tag: ail-0_0.2.26
+
+ * [Modify] Changed desktop field prefix
+
+ -- Sewook Park <sewook7.park@samsung.com> Thu, 15 Mar 2012 11:07:16 +0900
+
+ail-0 (0.2.25) unstable; urgency=low
+
+ * Git: slp/pkgs/a/ail
+ * Tag: ail-0_0.2.25
+
+ * [Modify] Fixed bug for X_SLP_TASKMANAGE_BOOL
+
+ -- Sewook Park <sewook7.park@samsung.com> Tue, 06 Mar 2012 10:11:40 +0900
+
+ail-0 (0.2.24) unstable; urgency=low
+
+ * Git: slp/pkgs/a/ail
+ * Tag: ail-0_0.2.24
+
+ * [Modify] Changed API parameter - from enum to string
+
+ -- Sewook Park <sewook7.park@samsung.com> Mon, 27 Feb 2012 10:16:04 +0900
+
+ail-0 (0.2.23) unstable; urgency=low
+
+ * Git: slp/pkgs/a/ail
+ * Tag: ail-0_0.2.23
+
+ * [Modify] Added package id field for widget
+
+ -- Sewook Park <sewook7.park@samsung.com> Mon, 30 Jan 2012 17:41:45 +0900
+
+ail-0 (0.2.22) unstable; urgency=low
+
+ * Git: slp/pkgs/a/ail
+ * Tag: ail-0_0.2.22
+
+ * [Modify] Added TC
+
+ -- Sewook Park <sewook7.park@samsung.com> Mon, 19 Dec 2011 19:06:02 +0900
+
+ail-0 (0.2.21) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.2.21
+
+ * [Modify] Added desktop.conf
+
+ -- Sewook Park <sewook7.park@samsung.com> Thu, 08 Dec 2011 14:53:02 +0900
+
+ail-0 (0.2.20) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.2.20
+
+ * [Modify] changed boilerplate
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Mon, 05 Dec 2011 16:29:21 +0900
+
+ail-0 (0.2.19) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.2.19
+
+ * [Modify] Fix code for CQ H0100135781
+
+ -- Sewook Park <sewook7.park@samsung.com> Thu, 01 Dec 2011 19:20:30 +0900
+
+ail-0 (0.2.18) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.2.18
+
+ * [Modify] Changed Boilerplate as per the guideline
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Mon, 07 Nov 2011 16:19:22 +0900
+
+ail-0 (0.2.17) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.2.17
+
+ * [Modify] Fix exec filter bug
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Fri, 04 Nov 2011 18:01:06 +0900
+
+ail-0 (0.2.16) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.2.16
+
+ * [Modify] Fix memory leak of prevent
+
+ -- Sewook Park <sewook7.park@samsung.com> Wed, 26 Oct 2011 19:50:44 +0900
+
+ail-0 (0.2.15) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.2.15
+
+ * [Modify] Fix Exec filter operation to like
+
+ -- Sewook Park <sewook7.park@samsung.com> Mon, 17 Oct 2011 16:42:54 +0900
+
+ail-0 (0.2.14) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.2.14
+
+ * [ADD] ail_db_close API
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Mon, 26 Sep 2011 19:22:41 +0900
+
+ail-0 (0.2.13) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.2.13
+
+ * [Remove] Remove old API
+
+ -- Sewook Park <sewook7.park@samsung.com> Mon, 26 Sep 2011 10:42:18 +0900
+
+ail-0 (0.2.12) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.2.12
+
+ * [Modify] Fix name filter bug
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Tue, 20 Sep 2011 16:11:34 +0900
+
+ail-0 (0.2.11) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.2.11
+
+ * [Modify] Change package uninstall default setting (X-SLP-Removable)
+ * [Modify] Fix ail filtering count bug
+
+ -- Sunghyuk Lee <sunghyuk.lee@samsung.com> Fri, 16 Sep 2011 12:21:01 +0900
+
+ail-0 (0.2.10) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.2.10
+
+ * [Modify] Support locale for filter
+ * [Remove] Remove buildutil
+
+ -- Sunghyuk Lee <sunghyuk.lee@samsung.com> Thu, 15 Sep 2011 14:18:55 +0900
+
+ail-0 (0.2.9) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.2.9
+
+ * [Add] Create localname table
+
+ -- Sunghyuk Lee <sunghyuk.lee@samsung.com> Mon, 05 Sep 2011 14:31:01 +0900
+
+ail-0 (0.2.8) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.2.8
+
+ * [Modify] Add ail_initdb error log to find opendir failure cause
+
+ -- Sunghyuk Lee <sunghyuk.lee@samsung.com> Thu, 25 Aug 2011 16:24:14 +0900
+
+ail-0 (0.2.7) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.2.7
+
+ * [Modify] get more detail error messages
+
+ -- Jin Yoon <jinny.yoon@samsung.com> Wed, 24 Aug 2011 09:32:08 +0900
+
+ail-0 (0.2.6) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.2.6
+
+ * [Modify] initdb uses fprintf instead of dlog because initdb is executed in the postinst
+
+ -- Jin Yoon <jinny.yoon@samsung.com> Tue, 23 Aug 2011 13:57:37 +0900
+
+ail-0 (0.2.5) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.2.5
+
+ * [Fix] Fix a wrong pointer when freeing handle
+
+ -- Sunghyuk Lee <sunghyuk.lee@samsung.com> Thu, 18 Aug 2011 14:41:01 +0900
+
+ail-0 (0.2.4) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.2.4
+
+ * [Fix] remove double free.
+
+ -- Jin Yoon <jinny.yoon@samsung.com> Thu, 18 Aug 2011 11:16:52 +0900
+
+ail-0 (0.2.3) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.2.3
+
+ * [Add] execute ail_initdb in the postinst.
+ * [Modify] db_finalize free a handle.
+
+ -- Jin Yoon <jinny.yoon@samsung.com> Wed, 17 Aug 2011 16:48:31 +0900
+
+ail-0 (0.2.1) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.2.1
+
+ * Add dependancies for dev package
+
+ -- Sunghyuk Lee <sunghyuk.lee@samsung.com> Mon, 08 Aug 2011 22:35:54 +0900
+
+ail-0 (0.2.0) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.2.0
+
+ * New AIL release
+ * Recacy APIs are deprecated
+
+ -- Sunghyuk Lee <sunghyuk.lee@samsung.com> Mon, 08 Aug 2011 21:11:18 +0900
+
+ail-0 (0.1.11) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.1.11
+
+ * Source code clean up
+
+ -- Jin Yoon <jinny.yoon@samsung.com> Sun, 17 Jul 2011 10:48:28 +0900
+
+ail-0 (0.1.10) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.1.10
+
+ * Update changelog
+
+ -- Sunghyuk Lee <sunghyuk.lee@samsung.com> Fri, 10 Jun 2011 19:11:15 +0900
+
+ail-0 (0.1.9) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.1.9
+
+ * SVACE Check
+
+ -- Jin Yoon <jinny.yoon@samsung.com> Wed, 08 Jun 2011 11:01:37 +0900
+
+ail-0 (0.1.8) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.1.8
+
+ * fix the LIMIT problem.
+
+ -- Jin Yoon <jinny.yoon@samsung.com> Sat, 21 May 2011 09:34:35 +0900
+
+ail-0 (0.1.7) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.1.7
+
+ * ail_package_get_icon returns the absolute path.
+ * Bug fix : ail_exec_exist, ail_set_rs_limit
+
+ -- Jin Yoon <jinny.yoon@samsung.com> Wed, 04 May 2011 14:50:50 +0900
+
+ail-0 (0.1.6) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.1.6
+
+ * Code Review
+
+ -- Jin Yoon <jinny.yoon@samsung.com> Mon, 25 Apr 2011 15:35:38 +0900
+
+ail-0 (0.1.5) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.1.5
+
+ -- Jin Yoon <jinny.yoon@samsung.com> Fri, 15 Apr 2011 22:10:44 +0900
+
+ail-0 (0.1.4) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.1.4
+
+ -- Jin Yoon <jinny.yoon@samsung.com> Thu, 14 Apr 2011 19:38:37 +0900
+
+ail-0 (0.1.3) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.1.3
+
+ -- Jin Yoon <jinny.yoon@samsung.com> Wed, 06 Apr 2011 16:27:13 +0900
+
+ail-0 (0.1.2) unstable; urgency=low
+
+ * Upload AIL after reviewing with gerrit
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail-0_0.1.2
+
+ -- Jin Yoon <jinny.yoon@samsung.com> Tue, 05 Apr 2011 18:30:32 +0900
+
+ail-0 (0.1.1) unstable; urgency=low
+
+ * Upload AIL Package to the Main Binary
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail_0.1.1
+
+ -- Jin Yoon <jinny.yoon@samsung.com> Mon, 04 Apr 2011 10:59:11 +0900
+
+ail (0.1.0) unstable; urgency=low
+
+ * Git: 165.213.180.234:/slp/pkgs/a/ail
+ * Tag: ail_0.1.0
+
+ * AIL(Application Information Library) added.
+
+ -- Jin Yoon <jinny.yoon@samsung.com> Wed, 15 Dec 2010 18:47:43 +0900
--- /dev/null
+Source: ail-0
+Section: devel
+Priority: extra
+Maintainer: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>, Jin Yoon <jinny.yoon@samsung.com>, Sunghyuk Lee <sunghyuk.lee@samsung.com>, Jinmin Chung <jinmin@samsung.com>
+Uploaders: Jin Yoon <jinny.yoon@samsung.com>
+Build-Depends: debhelper (>= 5), libvconf-dev, libsqlite3-dev, dlog-dev, libslp-db-util-dev, libglib2.0-dev, libxdgmime-dev
+Homepage: N/A
+Standards-Version: 0.1
+
+Package: libail-0
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Application Information Library
+
+Package: libail-0-dev
+Architecture: any
+Depends: libail-0 (= ${Source-Version}), libsqlite3-dev, dlog-dev, libslp-db-util-dev, libvconf-dev
+Description: Application Information Library
+
+Package: libail-0-dbg
+Section: debug
+Architecture: any
+Depends: libail-0 (= ${Source-Version})
+Description: Application Information Library
+
--- /dev/null
+CMakeLists.txt
--- /dev/null
+@PREFIX@/include/*.h
+@PREFIX@/lib/pkgconfig/*.pc
+@PREFIX@/lib/*.so
--- /dev/null
+@PREFIX@/lib/*.so.*
+@PREFIX@/bin/ail_initdb
+@PREFIX@/share/install-info/*
--- /dev/null
+#!/bin/sh
+CHDBGID="6010"
+
+init_appinfo_db()
+{
+ ail_initdb
+ if [ $? -ne 0 ]; then
+ echo "Failed to initialize app info db"
+ fi
+}
+
+update_DAC_for_db_file()
+{
+ if [ ! -f $@ ]; then
+ touch $@
+ fi
+
+ chown :$CHDBGID $@ 2>/dev/null
+ if [ $? -ne 0 ]; then
+ echo "Failed to change the owner of $@"
+ fi
+ chmod 664 $@ 2>/dev/null
+ if [ $? -ne 0 ]; then
+ echo "Failed to change the perms of $@"
+ fi
+}
+
+init_appinfo_db
+update_DAC_for_db_file /opt/dbspace/.app_info.db
+update_DAC_for_db_file /opt/dbspace/.app_info.db-journal
+
+# End of a file
--- /dev/null
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+CFLAGS += -Wall -g
+LDFLAGS ?=
+PREFIX ?= /usr
+DATADIR ?= /opt
+PKGTYPE ?= deb
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -O0
+else
+ CFLAGS += -O2
+endif
+
+ifneq (,$(findstring arm,$(DEB_HOST_ARCH)))
+ export ARCH = arm
+else
+ export ARCH = i686
+endif
+
+CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp
+
+LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed
+
+configure: configure-stamp
+configure-stamp:
+ dh_testdir
+ mkdir -p $(CMAKE_BUILD_DIR) && cd $(CMAKE_BUILD_DIR) && \
+ CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
+ cmake .. -DCMAKE_INSTALL_PREFIX="$(PREFIX)" -DBUILD_PKGTYPE="$(PKGTYPE)"
+
+ touch configure-stamp
+
+
+build: build-stamp
+
+build-stamp: configure-stamp
+ dh_testdir
+
+ # Add here commands to compile the package.
+ cd $(CMAKE_BUILD_DIR) && $(MAKE)
+
+ for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+ cat $$f > $${f%.in}; \
+ sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
+ sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
+ done
+
+ touch $@
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f *-stamp
+ rm -rf $(CMAKE_BUILD_DIR)
+
+ for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+ rm -f $${f%.in}; \
+ done
+
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ # Add here commands to install the package into debian/wavplayer.
+ cd $(CMAKE_BUILD_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installchangelogs
+ dh_installdocs
+ dh_installexamples
+ dh_install --list-missing --sourcedir=debian/tmp
+# dh_installmenu
+# dh_installdebconf
+# dh_installlogrotate
+# dh_installemacsen
+# dh_installpam
+# dh_installmime
+# dh_python
+# dh_installinit
+# dh_installcron
+# dh_installinfo
+ dh_installman
+ dh_link
+# dh_strip
+ dh_strip --dbg-package=libail-0-dbg
+ dh_compress
+ dh_fixperms
+# dh_perl
+ dh_makeshlibs
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
--- /dev/null
+/opt/share/applications
--- /dev/null
+/*
+ * ail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 SLP_PG_APPLICATION INFORMATION LIBRARY AIL
+ @{
+
+<h1 class="pg">Introduction</h1>
+
+<h2 class="pg">Purpose of this document</h2>
+ The purpose of this document is to describe how applications can use Application information library APIs to store/retrive the application's informations. This document gives programming guidelines to the application engineers.
+
+<h2 class="pg">Scope</h2>
+The scope of this document is limited to AIL API usage.
+
+
+<h1 class="pg">Architecture</h1>
+
+<h2 class="pg">Architecture overview</h2>
+Application information library manages the application information such as application name, type, icon path, exe path etc.
+
+@image html SLP_ail_logical_view.png
+
+<h2 class="pg">SLP Features</h2>
+- The Application information library provides installed applications informations.
+- The Application information library exposes the APIs to filter the applcation based on certain fields.
+- The Application information library uses DB to store the informations of the application.
+- The Application information library can process the desktop file to store/retrive the informations.
+
+
+<h1 class="pg">Application information library properties</h1>
+
+<h2 class="pg">AIL Functionality</h2>
+There are three types of API's provided by AIL
+- ail_appinfo_xxx
+ - Get the informations of the given package.
+- ail_filter_xxx
+ - Get the Application informations matched to filter condition.
+- ail_desktop_xxx
+ - add, update or remove package informations in DB.
+
+<h2 class="pg">Software Components</h2>
+- Query Requester
+ - It provides the interface to the DB. It is responsible for forming the query and excute the query in db.
+- Desktop file Reader/parser
+ - It can read the application's desktop file from the file system (/opt/share/application/).
+- Filter
+ - It can filter the query based on the given condition and it returns the filtered output to the application.
+- Get App info
+ - It can get the information of the application using appid.
+
+<h1 class="pg"> Software module Details </h2>
+
+<h2 class="pg"> Query Requester </h2>
+ - Query Requester module is provides the interface to sql DB in AIL.
+ - It is responsible for creating connection to the DB, form the sql query and execute the query in DB.
+ - It uses the libsql API to access the DB. (Eg) db_xx() API.
+
+@code
+
+@brief string type properties
+
+#define AIL_PROP_PACKAGE_STR "AIL_PROP_PACKAGE_STR"
+#define AIL_PROP_EXEC_STR "AIL_PROP_EXEC_STR"
+#define AIL_PROP_NAME_STR "AIL_PROP_NAME_STR"
+#define AIL_PROP_TYPE_STR "AIL_PROP_TYPE_STR"
+#define AIL_PROP_ICON_STR "AIL_PROP_ICON_STR"
+#define AIL_PROP_CATEGORIES_STR "AIL_PROP_CATEGORIES_STR"
+#define AIL_PROP_VERSION_STR "AIL_PROP_VERSION_STR"
+#define AIL_PROP_MIMETYPE_STR "AIL_PROP_MIMETYPE_STR"
+#define AIL_PROP_X_SLP_SERVICE_STR "AIL_PROP_X_SLP_SERVICE_STR"
+#define AIL_PROP_X_SLP_PACKAGETYPE_STR "AIL_PROP_X_SLP_PACKAGETYPE_STR"
+#define AIL_PROP_X_SLP_PACKAGECATEGORIES_STR "AIL_PROP_X_SLP_PACKAGECATEGORIES_STR"
+#define AIL_PROP_X_SLP_PACKAGEID_STR "AIL_PROP_X_SLP_PACKAGEID_STR"
+#define AIL_PROP_X_SLP_SVC_STR "AIL_PROP_X_SLP_SVC_STR"
+#define AIL_PROP_X_SLP_EXE_PATH "AIL_PROP_X_SLP_EXE_PATH"
+#define AIL_PROP_X_SLP_APPID_STR "AIL_PROP_X_SLP_APPID_STR"
+
+
+@brief integer type properties
+
+#define AIL_PROP_X_SLP_TEMP_INT "AIL_PROP_X_SLP_TEMP_INT"
+#define AIL_PROP_X_SLP_INSTALLEDTIME_INT "AIL_PROP_X_SLP_INSTALLEDTIME_INT"
+
+@brief boolean type properties
+
+#define AIL_PROP_NODISPLAY_BOOL "AIL_PROP_NODISPLAY_BOOL"
+#define AIL_PROP_X_SLP_TASKMANAGE_BOOL "AIL_PROP_X_SLP_TASKMANAGE_BOOL"
+#define AIL_PROP_X_SLP_MULTIPLE_BOOL "AIL_PROP_X_SLP_MULTIPLE_BOOL"
+#define AIL_PROP_X_SLP_REMOVABLE_BOOL "AIL_PROP_X_SLP_REMOVABLE_BOOL"
+#define AIL_PROP_X_SLP_INACTIVATED_BOOL "AIL_PROP_X_SLP_INACTIVATED_BOOL"
+
+
+@brief A handle for filters
+
+typedef struct ail_filter *ail_filter_h;
+
+@brief A handle for appinfos
+
+typedef struct ail_appinfo *ail_appinfo_h;
+
+@endcode
+
+
+<h2 class="pg">Desktop file Reader/parser</h2>
+ - This module provides set of APIs to add update delete application's desktop files contents in DB.
+ - It is responsible for validate the desktop file contents are in standard format.
+ - The major functionality of this module is add, update and delete desktop file contents in DB Eg.(ail_desktop_xxx())
+ <h3 class="pg"> Desktop file specification </h3>
+ - http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#introduction
+ - Desktop entry files should have the .desktop extension
+ - Entries in the file are {key,value} pairs in the format: Key=Value
+ - Standard Keys
+ - Type, Version, Name, NoDisplay, Icon, Hidden, Exec, Path, MimeType, Categories, URL, etc
+ - The Exec key must contain a command line. A command line consists of an executable program optionally followed by one or more arguments.
+ - The executable program can either be specified with its full path or with the name of the executable only.
+ - If no full path is provided the executable is looked up in the $PATH environment variable used by the desktop environment.
+ - The name or path of the executable program may not contain the equal sign ("="). Arguments are separated by a space.
+
+@image html SLP_AIL_desktop.png
+
+<h2 class="pg"> Adding desktop file to DB </h2>
+@image html SLP_AIL_add.png
+<h2 class="pg" > Sample code </h2>
+@code
+static ail_error_e _add_desktop(const char *package)
+{
+ ail_error_e ret;
+
+ if (!package) {
+ return AIL_ERROR_FAIL;
+ }
+
+ ret = ail_desktop_add(package);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ return AIL_ERROR_OK;
+}
+
+static ail_error_e _remove_desktop(const char *package)
+{
+ ail_error_e ret;
+
+ if (!package) {
+ return AIL_ERROR_FAIL;
+ }
+
+ ret = ail_desktop_remove(package);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ return AIL_ERROR_OK;
+}
+
+@endcode
+
+<h2 class="pg">Filter</h2>
+This module provides set of APIs to get the information from the DB based on the given matched condtion.
+It is reponsbile for giving the filtered output to the applications. Eg.(ail_filter_xxx()) These following are some of the filtering condition.
+ - Filter integer type only
+ - Filter string type only
+ - Filter bool type only
+
+<h3 class="pg" > Filter sample code </h3>
+@code
+ail_cb_ret_e appinfo_func(const ail_appinfo_h appinfo, void *user_data)
+{
+ int *i = (int *)user_data;
+ char *package;
+
+ ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
+ printf("i=%d %s\n", (*i)++, package);
+
+ if (*i > 30)
+ return AIL_CB_RET_CANCEL;
+
+ return AIL_CB_RET_CONTINUE;
+}
+
+int list_packages()
+{
+ ail_filter_h filter;
+ ail_error_e ret;
+ int i=0;
+
+ ret = ail_filter_new(&filter);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, true);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ ret = ail_filter_add_str(filter, AIL_PROP_TYPE_STR, "Application");
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ printf("List packages which are removable and 'Application' typed\n");
+ ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
+
+ ail_filter_destroy(filter);
+
+ return 0;
+}
+
+@endcode
+
+<h2 class="pg">Get Application info</h2>
+ - This module provides set of APIs to get informations of the installed packages.
+ - This module internally uses the query Requester module to get the information of the requested packages in DB. Eg.(ail_appinfo_xxx())
+@image html SLP_AIL_get.png
+
+@code
+static ail_error_e _get_name(const char *package)
+{
+ ail_appinfo_h handle;
+ ail_error_e ret;
+ char *str;
+
+ ret = ail_package_get_appinfo(package, &handle);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &str);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+ fprintf(stderr, "Package[%s], Property[%s] : %s\n", package, property, str);
+
+ ret = ail_package_destroy_appinfo(handle);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ return AIL_ERROR_OK;
+}
+
+@endcode
+
+
+ @}
+**/
--- /dev/null
+/*
+ * ail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 __AIL_H__
+#define __AIL_H__
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+
+/**
+ * @open
+ * @ingroup APPLICATION_FRAMEWORK
+ * @defgroup ail Application Information Library
+ */
+
+/**
+ * @file ail.h
+ * @brief Application Information Library header
+ * @author Sunghyuk Lee (sunghyuk.lee@samsung.com), Jin Yoon (jinny.yoon@samsung.com)
+ * @date 2011-07-30
+ * @version 0.1
+ */
+
+/**
+ * @addtogroup ail
+ * @{
+ */
+
+/**
+ * @brief string type properties
+ */
+#define AIL_PROP_PACKAGE_STR "AIL_PROP_PACKAGE_STR"
+#define AIL_PROP_EXEC_STR "AIL_PROP_EXEC_STR"
+#define AIL_PROP_NAME_STR "AIL_PROP_NAME_STR"
+#define AIL_PROP_TYPE_STR "AIL_PROP_TYPE_STR"
+#define AIL_PROP_ICON_STR "AIL_PROP_ICON_STR"
+#define AIL_PROP_CATEGORIES_STR "AIL_PROP_CATEGORIES_STR"
+#define AIL_PROP_VERSION_STR "AIL_PROP_VERSION_STR"
+#define AIL_PROP_MIMETYPE_STR "AIL_PROP_MIMETYPE_STR"
+#define AIL_PROP_X_SLP_SERVICE_STR "AIL_PROP_X_SLP_SERVICE_STR"
+#define AIL_PROP_X_SLP_PACKAGETYPE_STR "AIL_PROP_X_SLP_PACKAGETYPE_STR"
+#define AIL_PROP_X_SLP_PACKAGECATEGORIES_STR "AIL_PROP_X_SLP_PACKAGECATEGORIES_STR"
+#define AIL_PROP_X_SLP_PACKAGEID_STR "AIL_PROP_X_SLP_PACKAGEID_STR"
+#define AIL_PROP_X_SLP_SVC_STR "AIL_PROP_X_SLP_SVC_STR"
+#define AIL_PROP_X_SLP_EXE_PATH "AIL_PROP_X_SLP_EXE_PATH"
+#define AIL_PROP_X_SLP_APPID_STR "AIL_PROP_X_SLP_APPID_STR"
+#define AIL_PROP_X_SLP_PKGID_STR "AIL_PROP_X_SLP_PKGID_STR"
+#define AIL_PROP_X_SLP_DOMAIN_STR "AIL_PROP_X_SLP_DOMAIN_STR"
+
+
+/**
+ * @brief integer type properties
+ */
+#define AIL_PROP_X_SLP_TEMP_INT "AIL_PROP_X_SLP_TEMP_INT"
+#define AIL_PROP_X_SLP_INSTALLEDTIME_INT "AIL_PROP_X_SLP_INSTALLEDTIME_INT"
+
+/**
+ * @brief boolean type properties
+ */
+#define AIL_PROP_NODISPLAY_BOOL "AIL_PROP_NODISPLAY_BOOL"
+#define AIL_PROP_X_SLP_TASKMANAGE_BOOL "AIL_PROP_X_SLP_TASKMANAGE_BOOL"
+#define AIL_PROP_X_SLP_MULTIPLE_BOOL "AIL_PROP_X_SLP_MULTIPLE_BOOL"
+#define AIL_PROP_X_SLP_REMOVABLE_BOOL "AIL_PROP_X_SLP_REMOVABLE_BOOL"
+#define AIL_PROP_X_SLP_INACTIVATED_BOOL "AIL_PROP_X_SLP_INACTIVATED_BOOL"
+
+
+/**
+ * @brief A handle for filters
+ */
+typedef struct ail_filter *ail_filter_h;
+
+/**
+ * @brief A handle for appinfos
+ */
+typedef struct ail_appinfo *ail_appinfo_h;
+
+/**
+ * @brief return values
+ */
+typedef enum {
+ AIL_ERROR_OK = 0, /**< General success */
+ AIL_ERROR_FAIL = -1, /**< General error */
+ AIL_ERROR_DB_FAILED = -2, /**< Database error */
+ AIL_ERROR_OUT_OF_MEMORY = -3, /**< Out of memory */
+ AIL_ERROR_INVALID_PARAMETER = -4, /**< Invalid parameter */
+ AIL_ERROR_NO_DATA = -5, /**< Success, but no data */
+} ail_error_e;
+
+/**
+ * @fn ail_error_e ail_filter_new(ail_filter_h *filter)
+ *
+ * @brief Create a new filter handle which is used to filter records from Application Information Database. You can add filtering conditions to filter with ail_filter_add_xxx functions. All conditions are ANDed.
+ *
+ * @par Sync (or) Async : Synchronous API.
+ *
+ * @param[out] filter a pointer to a filter which is newly created
+ *
+ * @return 0 if success, negative value(<0) if fail\n
+ * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
+ * @retval AIL_ERROR_OUT_OF_MEMORY out of memory
+ *
+ * @pre None
+ * @post If the filter is no longer used, it should be freed with ail_filter_destroy()
+ *
+ * @see ail_filter_destroy()
+ *
+ * @par Prospective Clients:
+ * External Apps.
+ *
+ * @code
+int count_apps()
+{
+ ail_filter_h filter;
+ ail_error_e ret;
+ int n;
+
+ ret = ail_filter_new(&filter);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ ret = ail_filter_add_bool(filter, AIL_PROP_NODISPLAY_BOOL, false);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ ret = ail_filter_add_str(filter, AIL_PROP_MIMETYPE_STR, "audio/wav");
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ ret = ail_filter_count_appinfo(filter, &n);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+ ret = ail_filter_destroy(filter);
+
+ printf("N of apps not to be displayed and supporting 'audo/wav' mime type = %d\n", n);
+
+ return n;
+}
+ * @endcode
+ */
+ail_error_e ail_filter_new(ail_filter_h *filter);
+
+
+
+/**
+ * @fn ail_error_e ail_error_e ail_filter_add_int(ail_filter_h filter, const char *property, const int value)
+ *
+ * @brief Add integer condition to filter
+ *
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] filter a filter handle which can be create with ail_filter_new()
+ * @param[in] property a property type of integer
+ * @param[in] value the value to filter by
+ *
+ * @return 0 if success, negative value(<0) if fail\n
+ * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
+ * @retval AIL_ERROR_OUT_OF_MEMORY out of memory
+ *
+ * @pre The filter should be valid handle which was created by ail_filter_new()
+ *
+ * @see ail_filter_new()
+ *
+ * @par Prospective Clients:
+ * External Apps.
+ *
+ * @code
+int count_apps()
+{
+ ail_filter_h filter;
+ ail_error_e ret;
+ int n;
+
+ ret = ail_filter_new(&filter);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ ret = ail_filter_add_int(filter, AIL_PROP_X_SLP_BASELAYOUTWIDTH_INT, 480);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ ret = ail_filter_count_appinfo(filter, &n);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ printf("N of apps = %d\n", n);
+
+ return n;
+}
+ * @endcode
+ */
+ail_error_e ail_filter_add_int(ail_filter_h filter, const char *property, const int value);
+
+
+/**
+ * @fn ail_error_e ail_error_e ail_filter_add_bool(ail_filter_h filter, const char *property, const bool value)
+ *
+ * @brief Add boolean condition to filter by. The value can be true/false only
+ *
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] filter a filter handle which can be create with ail_filter_new()
+ * @param[in] property a property type of boolean
+ * @param[in] value the value to filter by
+ *
+ * @return 0 if success, negative value(<0) if fail\n
+ * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
+ * @retval AIL_ERROR_OUT_OF_MEMORY out of memory
+ *
+ * @pre The filter should be valid handle which was created by ail_filter_new()
+ *
+ * @see ail_filter_new()
+ *
+ * @par Prospective Clients:
+ * External Apps.
+ *
+ * @code
+int count_apps()
+{
+ ail_filter_h filter;
+ ail_error_e ret;
+ int n;
+
+ ret = ail_filter_new(&filter);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, true);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ ret = ail_filter_count_appinfo(filter, &n);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ fprintf(stderr, "N of apps = %d\n", n);
+
+ return n;
+}
+ * @endcode
+ */
+ail_error_e ail_filter_add_bool(ail_filter_h filter, const char *property, bool value);
+
+
+
+/**
+ * @fn ail_error_e ail_error_e ail_filter_add_str(ail_filter_h filter, const char *property, const char *value)
+ *
+ * @brief Add string condition to filter by. The string is case-sensitive.
+ *
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] filter a filter handle which can be create with ail_filter_new()
+ * @param[in] property a property type of string
+ * @param[in] value the value to filter by
+ *
+ * @return 0 if success, negative value(<0) if fail\n
+ * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
+ * @retval AIL_ERROR_OUT_OF_MEMORY out of memory
+ *
+ * @pre The filter should be valid handle which was created by ail_filter_new()
+ *
+ * @see ail_filter_new()
+ *
+ * @par Prospective Clients:
+ * External Apps.
+ *
+ * @code
+int count_apps()
+{
+ ail_filter_h filter;
+ ail_error_e ret;
+ int n;
+
+ ret = ail_filter_new(&filter);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ ret = ail_filter_add_str(filter, AIL_PROP_PACKAGE_STR, "com.samsung.memo");
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ ret = ail_filter_count_appinfo(filter, &n);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ fprintf(stderr, "N of apps = %d\n", n);
+
+ return n;
+}
+ * @endcode
+ */
+ail_error_e ail_filter_add_str(ail_filter_h filter, const char *property, const char *value);
+
+
+
+/**
+ * @fn ail_error_e ail_filter_destroy(ail_filter_h filter)
+ *
+ * @brief Destroy a filter which is not used any longer.
+ *
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] filter filter handle
+ *
+ * @return 0 if success, negative value(<0) if fail\n
+ * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
+ *
+ * @post If the filter is no longer used, it should be freed with ail_filter_destroy()
+ *
+ * @see ail_filter_new()
+ *
+ * @par Prospective Clients:
+ * External Apps.
+ *
+ * @code
+int count_apps()
+{
+ ail_filter_h filter;
+ ail_error_e ret;
+ int n;
+
+ ret = ail_filter_new(&filter);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, true);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ ret = ail_filter_count_appinfo(filter, &n);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ printf("N of removable apps = %d\n", n);
+
+ ret = ail_filter_add_str(filter, AIL_PROP_MIMETYPE_STR, "audio/wav");
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ ret = ail_filter_count_appinfo(filter, &n);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ printf("N of apps removable and supporting 'audo/wav' mime type = %d\n", n);
+
+ ret = ail_filter_destroy(filter);
+
+ return n;
+}
+ * @endcode
+ */
+ail_error_e ail_filter_destroy(ail_filter_h filter);
+
+
+
+/**
+ * @brief return value type of ail_list_appinfo_cb
+ */
+typedef enum {
+ AIL_CB_RET_CONTINUE = 1, /**< continue */
+ AIL_CB_RET_CANCEL = 0, /**< cancel */
+} ail_cb_ret_e;
+
+/**
+ * @fn ail_cb_ret_e (*ail_list_appinfo_cb) (const ail_appinfo_h appinfo_h, void *user_data)
+ *
+ * @breif Specifies the type of functions passed to ail_filter_list_appinfo_foreach().
+ *
+ * @param[in] appinfo_h the appinfo's handle
+ * @param[in] user_data user data passed to ail_filtet_list_appinfo_foreach()
+ *
+ * @return 0 if success, negative value(<0) if fail\n
+ * @retval AIL_CB_RET_CONTINUE return if you continue iteration
+ * @retval AIL_CB_RET_CANCEL return if you cancel iteration
+ *
+ * @see ail_filter_list_appinfo_foreach()
+ */
+typedef ail_cb_ret_e (*ail_list_appinfo_cb) (const ail_appinfo_h appinfo_h, void *user_data);
+
+/**
+ * @fn ail_error_e ail_error_e ail_filter_list_appinfo_foreach(ail_filter_h filter, ail_list_appinfo_cb func, void *user_data)
+ *
+ * @brief Calls the callback function for each app filtered by given filter. If the filter is not given (i.e filter handle is NULL), it is invoked for all apps.
+ *
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] filter a filter handle
+ * @param[in] func the function to call with each app's appinfo
+ * @param[in] user_data user_data to pass to the function
+ *
+ * @return 0 if success, negative value(<0) if fail\n
+ * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_DB_FAILED database error
+ * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
+ *
+ * @see ail_list_appinfo_cb
+ * @see ail_filter_add_bool()
+ * @see ail_filter_add_int()
+ * @see ail_filter_add_str()
+ *
+ * @par Prospective Clients:
+ * External Apps.
+ *
+ * @code
+
+ail_cb_ret_e appinfo_func(const ail_appinfo_h appinfo, void *user_data)
+{
+ int *i = (int *)user_data;
+ char *appid;
+
+ ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &appid);
+ printf("i=%d %s\n", (*i)++, appid);
+
+ if (*i > 30)
+ return AIL_CB_RET_CANCEL;
+
+ return AIL_CB_RET_CONTINUE;
+}
+
+int list_apps()
+{
+ ail_filter_h filter;
+ ail_error_e ret;
+ int i=0;
+
+ ret = ail_filter_new(&filter);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, true);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ ret = ail_filter_add_str(filter, AIL_PROP_TYPE_STR, "Application");
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ printf("List apps which are removable and 'Application' typed\n");
+ ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
+
+ ail_filter_destroy(filter);
+
+ return 0;
+}
+ * @endcode
+ */
+ail_error_e ail_filter_list_appinfo_foreach(ail_filter_h filter,
+ ail_list_appinfo_cb appinfo_func,
+ void *user_data);
+
+
+
+/**
+ * @fn ail_error_e ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *count)
+ *
+ * @brief Gets the number of app which is filtered by the given filter. If the filter is not given (i.e filter handle is NULL), all app are counted.
+ *
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] filter a filter handle
+ * @param[in] count the number of appinfo which is filtered
+ *
+ * @return 0 if success, negative value(<0) if fail\n
+ * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
+ * @retval AIL_ERROR_OUT_OF_MEMORY out of memory
+ *
+ * @pre None
+ * @post None
+ *
+ * @see ail_filter_new()
+ * @see ail_filter_add_bool()
+ * @see ail_filter_add_int()
+ * @see ail_filter_add_str()
+ *
+ * @par Prospective Clients:
+ * External Apps.
+ *
+ * @code
+int count_apps()
+{
+ ail_filter_h filter;
+ ail_error_e ret;
+ int n;
+
+ ret = ail_filter_new(&filter);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ ret = ail_filter_add_bool(filter, AIL_PROP_NODISPLAY_BOOL, true);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ ret = ail_filter_count_appinfo(filter, &n);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ printf("N of app not to be displayed = %d", n);
+
+ ret = ail_filter_count_appinfo(NULL, &n);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ printf("N of all app = %d\n", n);
+
+ return n;
+}
+ * @endcode
+ */
+ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *count);
+
+
+
+/**
+ * @fn ail_error_e ail_package_get_appinfo(const char *package, ail_appinfo_h *handle)
+ *
+ * @brief get an application information related to a package.
+ This API just retrieves all the information of the package from Application Information Database.
+ All data related to the package are loaded in the memory after calling this function.
+ If you want to read a value from the retrieving data, you have to use the functions of ail_appinfo_get_xxx.
+
+ * @par Sync (or) Async : Synchronous API.
+ *
+ * @param[in] package package name what you want to know about.
+ * @param[out] handle handle will be used with the functions of ail_appinfo_get_xxx. If no data, it will be NULL.
+ *
+ * @return 0 if success, negative value(<0) if fail\n
+ * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_FAIL internal error
+ * @retval AIL_ERROR_DB_FAILED database error
+ * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
+ * @retval AIL_ERROR_NO_DATA no data. cannot find the package.
+ *
+ * @pre declare a handle before calling this function. The handle is used as a second argument of this API.
+ * @post destroy the handle with the function of ail_package_destroy_appinfo after using it all.
+ *
+ * @see ail_package_destroy_appinfo(), ail_appinfo_get_bool(), ail_appinfo_get_int(), ail_appinfo_get_str()
+ *
+ * @par Prospective Clients:
+ * External Apps.
+ *
+ * @code
+static ail_error_e _get_name(const char *package)
+{
+ ail_appinfo_h handle;
+ ail_error_e ret;
+ char *str;
+
+ ret = ail_package_get_appinfo(package, &handle);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &str);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+ fprintf(stderr, "Package[%s], Property[%s] : %s\n", package, property, str);
+
+ ret = ail_package_destroy_appinfo(handle);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ return AIL_ERROR_OK;
+}
+ * @endcode
+ */
+ail_error_e ail_package_get_appinfo(const char *package, ail_appinfo_h *handle) __attribute__((deprecated));
+
+
+/**
+ * @fn ail_error_e ail_get_appinfo(const char *appid, ail_appinfo_h *handle)
+ *
+ * @brief get an application information related to a appid.
+ This API just retrieves all the information of the application from Application Information Database.
+ All data related to the appid are loaded in the memory after calling this function.
+ If you want to read a value from the retrieving data, you have to use the functions of ail_appinfo_get_xxx.
+
+ * @par Sync (or) Async : Synchronous API.
+ *
+ * @param[in] appid appid what you want to know about.
+ * @param[out] handle handle will be used with the functions of ail_appinfo_get_xxx. If no data, it will be NULL.
+ *
+ * @return 0 if success, negative value(<0) if fail\n
+ * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_FAIL internal error
+ * @retval AIL_ERROR_DB_FAILED database error
+ * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
+ * @retval AIL_ERROR_NO_DATA no data. cannot find the app.
+ *
+ * @pre declare a handle before calling this function. The handle is used as a second argument of this API.
+ * @post destroy the handle with the function of ail_get_appinfo after using it all.
+ *
+ * @see ail_get_appinfo(), ail_appinfo_get_bool(), ail_appinfo_get_int(), ail_appinfo_get_str()
+ *
+ * @par Prospective Clients:
+ * External Apps.
+ *
+ * @code
+static ail_error_e _get_name(const char *appid)
+{
+ ail_appinfo_h handle;
+ ail_error_e ret;
+ char *str;
+
+ ret = ail_get_appinfo(appid, &handle);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &str);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+ fprintf(stderr, "Package[%s], Property[%s] : %s\n", appid, property, str);
+
+ ret = ail_destroy_appinfo(handle);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ return AIL_ERROR_OK;
+}
+ * @endcode
+ */
+ail_error_e ail_get_appinfo(const char *appid, ail_appinfo_h *handle);
+
+
+/**
+ * @fn ail_error_e ail_appinfo_get_bool(const ail_appinfo_h handle, const char *property, bool *value)
+ *
+ * @brief get a boolean value related to the property.
+ Before using this API, the handle is defined by calling ail_get_appinfo.
+ This function needs a out-parameter for the value.
+ *
+ * @par Sync (or) Async : Synchronous API.
+ *
+ * @param[in] handle the handle is defined by calling ail_get_appinfo.
+ * @param[in] property a property type of boolean
+ * @param[out] value a out-parameter value that is mapped with the property.
+ *
+ * @return 0 if success, negative value(<0) if fail\n
+ * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_DB_FAILED database error
+ * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
+ *
+ * @pre define a handle using ail_get_appinfo. The handle is used as a first argument of this API.
+ * @post destroy the handle with the function of ail_destroy_appinfo after using it all.
+ *
+ * @see ail_get_appinfo(), ail_destroy_appinfo(), ail_appinfo_get_int(), ail_appinfo_get_str()
+ *
+ * @par Prospective Clients:
+ * External Apps.
+ *
+ * @code
+static ail_error_e _get_nodisplay(const char *appid)
+{
+ ail_appinfo_h handle;
+ ail_error_e ret;
+ bool value;
+
+ ret = ail_get_appinfo(appid, &handle);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ ret = ail_appinfo_get_bool(handle, AIL_PROP_NODISPLAY_BOOL, &value);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+ fprintf(stderr, "appid[%s] : %d\n", appid, value);
+
+ ret = ail_destroy_appinfo(handle);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ return AIL_ERROR_OK;
+}
+ * @endcode
+ */
+ail_error_e ail_appinfo_get_bool(const ail_appinfo_h handle, const char *property, bool *value);
+
+
+
+/**
+ * @fn ail_error_e ail_appinfo_get_int(const ail_appinfo_h handle, const char *property, int *value)
+ *
+ * @brief get a integer value related to the property.
+ Before using this API, the handle is defined by calling ail_get_appinfo.
+ This function needs a out-parameter for the value.
+ *
+ * @par Sync (or) Async : Synchronous API.
+ *
+ * @param[in] handle the handle is defined by calling ail_get_appinfo.
+ * @param[in] property a property type of integer.
+ * @param[out] value a out-parameter value that is mapped with the property.
+ *
+ * @return 0 if success, negative value(<0) if fail\n
+ * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_DB_FAILED database error
+ * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
+ *
+ * @pre define a handle using ail_get_appinfo. The handle is used as a first argument of this API.
+ * @post destroy the handle with the function of ail_destroy_appinfo after using it all.
+ *
+ * @see ail_get_appinfo(), ail_destroy_appinfo(), ail_appinfo_get_bool(), ail_appinfo_get_str()
+ *
+ * @par Prospective Clients:
+ * External Apps.
+ *
+ * @code
+static ail_error_e _get_x_slp_baselayoutwidth(const char *appid)
+{
+ ail_appinfo_h handle;
+ ail_error_e ret;
+ int value;
+
+ ret = ail_get_appinfo(appid, &handle);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ ret = ail_appinfo_get_int(handle, AIL_PROP_X_SLP_BASELAYOUTWIDTH_INT, &value);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+ fprintf(stderr, "Package[%s] : %d\n", appid, value);
+
+ ret = ail_destroy_appinfo(handle);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ return AIL_ERROR_OK;
+}
+ * @endcode
+ */
+ail_error_e ail_appinfo_get_int(const ail_appinfo_h handle, const char *property, int *value);
+
+
+
+/**
+ * @fn ail_error_e ail_appinfo_get_str(const ail_appinfo_h handle, const char *property, char **str)
+ *
+ * @brief get a string related to the property.
+ Before using this API, the handle is defined by calling ail_get_appinfo.
+ This function needs a out-parameter for the value.
+ *
+ * @par Sync (or) Async : Synchronous API.
+ *
+ * @param[in] handle the handle is defined by calling ail_get_appinfo.
+ * @param[in] property a property type of string.
+ * @param[out] str a out-parameter string that is mapped with the property. The icon property contains the absolute file path. If there is no data, the value of str is NULL.
+ *
+ * @return 0 if success, negative value(<0) if fail\n
+ * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_DB_FAILED database error
+ * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
+ *
+ * @pre define a handle using ail_get_appinfo. The handle is used as a first argument of this API.
+ * @post str doesn't need to be freed. It will be freed by calling ail_destroy_appinfo.
+ *
+ * @see ail_get_appinfo(), ail_destroy_appinfo(), ail_appinfo_get_bool(), ail_appinfo_get_int()
+ *
+ * @par Prospective Clients:
+ * External Apps.
+ *
+ * @code
+static ail_error_e _get_nodisplay(const char *appid)
+{
+ ail_appinfo_h handle;
+ ail_error_e ret;
+ char* value;
+
+ ret = ail_get_appinfo(appid, &handle);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &value);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+ fprintf(stderr, "Package[%s] : %d\n", appid, value);
+
+ ret = ail_destroy_appinfo(handle);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ return AIL_ERROR_OK;
+}
+ * @endcode
+ */
+ail_error_e ail_appinfo_get_str(const ail_appinfo_h handle, const char *property, char **str);
+
+
+
+/**
+ * @fn ail_error_e ail_package_destroy_appinfo(const ail_appinfo_h handle)
+ *
+ * @brief destroy a handle what you get with the function of ail_package_get_appinfo.
+ *
+ * @par Sync (or) Async : Synchronous API.
+ *
+ * @param[in] handle destroy all resources related to the handle.
+ *
+ * @return 0 if success, negative value(<0) if fail\n
+ * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_DB_FAILED database error
+ * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
+ *
+ * @pre need a handle that you don't need anymore.
+ * @post cannot use the handle after destroying.
+ *
+ * @see ail_package_get_appinfo(), ail_appinfo_get_bool(), ail_appinfo_get_int(), ail_appinfo_get_str()
+ *
+ * @par Prospective Clients:
+ * External Apps.
+ *
+ * @code
+static ail_error_e _get_name(const char *package)
+{
+ ail_appinfo_h handle;
+ ail_error_e ret;
+ char *str;
+
+ ret = ail_package_get_appinfo(package, &handle);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &str);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+ fprintf(stderr, "Package[%s], Property[%s] : %s\n", package, property, str);
+
+ ret = ail_package_destroy_appinfo(handle);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ return AIL_ERROR_OK;
+}
+ * @endcode
+ */
+ail_error_e ail_package_destroy_appinfo(const ail_appinfo_h handle) __attribute__((deprecated));
+
+
+/**
+ * @fn ail_error_e ail_destroy_appinfo(const ail_appinfo_h handle)
+ *
+ * @brief destroy a handle what you get with the function of ail_get_appinfo.
+ *
+ * @par Sync (or) Async : Synchronous API.
+ *
+ * @param[in] handle destroy all resources related to the handle.
+ *
+ * @return 0 if success, negative value(<0) if fail\n
+ * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_DB_FAILED database error
+ * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
+ *
+ * @pre need a handle that you don't need anymore.
+ * @post cannot use the handle after destroying.
+ *
+ * @see ail_get_appinfo(), ail_appinfo_get_bool(), ail_appinfo_get_int(), ail_appinfo_get_str()
+ *
+ * @par Prospective Clients:
+ * External Apps.
+ *
+ * @code
+static ail_error_e _get_name(const char *appid)
+{
+ ail_appinfo_h handle;
+ ail_error_e ret;
+ char *str;
+
+ ret = ail_get_appinfo(appid, &handle);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &str);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+ fprintf(stderr, "Package[%s], Property[%s] : %s\n", appid, property, str);
+
+ ret = ail_destroy_appinfo(handle);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ return AIL_ERROR_OK;
+}
+ * @endcode
+ */
+ail_error_e ail_destroy_appinfo(const ail_appinfo_h handle);
+
+
+/**
+ * @fn ail_error_e ail_desktop_add(const char *appid)
+ *
+ * @brief add a app information into Application Information Database.
+ A desktop file for this app has to be installed in the desktop directory before using this API.
+ If there is no database for Application Information Database, this API will create the DB.
+ If there is a DB, this function adds information for the app into the DB.
+ And a notification is published to the applications who want to know about changing DB.
+ *
+ * @par Sync (or) Async : Synchronous API.
+ *
+ * @param[in] appid
+ *
+ * @return 0 if success, negative value(<0) if fail\n
+ * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_FAIL internal error
+ * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
+ *
+ * @pre a desktop file for the app has to be installed in the desktop directory before using this API.
+ * @post app information is added into the Application Information Database.
+ *
+ * @see ail_desktop_update(), ail_desktop_remove()
+ *
+ * @par Prospective Clients:
+ * External Apps.
+ *
+ * @code
+static ail_error_e _add_desktop(const char *appid)
+{
+ ail_error_e ret;
+
+ if (!appid) {
+ return AIL_ERROR_FAIL;
+ }
+
+ ret = ail_desktop_add(appid);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ return AIL_ERROR_OK;
+}
+ * @endcode
+ */
+ail_error_e ail_desktop_add(const char *appid);
+
+
+
+/**
+ * @fn ail_error_e ail_desktop_update(const char *appid)
+ *
+ * @brief update a app information in the Application Information Database.
+ A desktop file for this app has to be installed in the desktop directory before using this API.
+ And a notification is published to the applications who want to know about changing DB.
+ *
+ * @par Sync (or) Async : Synchronous API.
+ *
+ * @param[in] appid
+ *
+ * @return 0 if success, negative value(<0) if fail\n
+ * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_FAIL internal error
+ * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
+ *
+ * @pre a desktop file for the app has to be installed in the desktop directory before using this API.
+ * @post update a app information in the Application Information Database.
+ *
+ * @see ail_desktop_add(), ail_desktop_remove()
+ *
+ * @par Prospective Clients:
+ * External Apps.
+ *
+ * @code
+static ail_error_e _update_desktop(const char *appid)
+{
+ ail_error_e ret;
+
+ if (!appid) {
+ return AIL_ERROR_FAIL;
+ }
+
+ ret = ail_desktop_update(appid);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ return AIL_ERROR_OK;
+}
+ * @endcode
+ */
+ail_error_e ail_desktop_update(const char *appid);
+
+
+
+/**
+ * @fn ail_error_e ail_desktop_remove(const char *appid)
+ *
+ * @brief remove a app information in the Application Information Database.
+ And a notification is published to the applications who want to know about changing DB.
+ *
+ * @par Sync (or) Async : Synchronous API.
+ *
+ * @param[in] appid
+ *
+ * @return 0 if success, negative value(<0) if fail\n
+ * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_FAIL internal error
+ * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
+ *
+ * @pre no pre-condition.
+ * @post app information is removed in the Application Information Database.
+ *
+ * @see ail_desktop_add(), ail_desktop_update()
+ *
+ * @par Prospective Clients:
+ * External Apps.
+ *
+ * @code
+static ail_error_e _remove_desktop(const char *appid)
+{
+ ail_error_e ret;
+
+ if (!appid) {
+ return AIL_ERROR_FAIL;
+ }
+
+ ret = ail_desktop_remove(appid);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ return AIL_ERROR_OK;
+}
+ * @endcode
+ */
+ail_error_e ail_desktop_remove(const char *appid);
+
+/** @} */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __AIL_H__ */
+// End of a file
--- /dev/null
+#AIL init DB build script
+
+SET(INITDB ail_initdb)
+SET(SRCS src/initdb.c)
+
+pkg_check_modules(INITDB_PKGS REQUIRED vconf dlog db-util sqlite3)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src)
+
+STRING(REPLACE ";" " " EXTRA_CFLAGS "${INITDB_PKGS_CFLAGS}")
+
+ADD_EXECUTABLE(${INITDB} ${SRCS})
+TARGET_LINK_LIBRARIES(${INITDB} ${LIBNAME} ${INITDB_PKGS_LIBRARIES})
+SET_TARGET_PROPERTIES(${INITDB} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+SET_TARGET_PROPERTIES(${INITDB} PROPERTIES SKIP_BUILD_RPATH true)
+
+INSTALL(TARGETS ${INITDB} DESTINATION ${BINDIR})
--- /dev/null
+/*
+ * ail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+#include "ail.h"
+#include "ail_private.h"
+
+#define OWNER_ROOT 0
+#define GROUP_MENU 6010
+#define BUFSZE 1024
+#define OPT_DESKTOP_DIRECTORY "/opt/share/applications"
+#define USR_DESKTOP_DIRECTORY "/usr/share/applications"
+#define APP_INFO_DB_FILE "/opt/dbspace/.app_info.db"
+
+#ifdef _E
+#undef _E
+#endif
+#define _E(fmt, arg...) fprintf(stderr, "[AIL_INITDB][E][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+
+#ifdef _D
+#undef _D
+#endif
+#define _D(fmt, arg...) fprintf(stderr, "[AIL_INITDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+
+static int initdb_count_app(void)
+{
+ ail_filter_h filter;
+ ail_error_e ret;
+ int total = 0;
+
+ ret = ail_filter_new(&filter);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
+
+ ret = ail_filter_add_bool(filter, AIL_PROP_NODISPLAY_BOOL, false);
+ if (ret != AIL_ERROR_OK) {
+ ail_filter_destroy(filter);
+ return -1;
+ }
+
+ ret = ail_filter_count_appinfo(filter, &total);
+ if (ret != AIL_ERROR_OK) {
+ ail_filter_destroy(filter);
+ return -1;
+ }
+
+ ail_filter_destroy(filter);
+
+ return total;
+}
+
+
+
+char* _desktop_to_package(const char* desktop)
+{
+ char *package, *tmp;
+
+ retv_if(!desktop, NULL);
+
+ package = strdup(desktop);
+ retv_if(!package, NULL);
+
+ tmp = strrchr(package, '.');
+ if(tmp == NULL) {
+ _E("(tmp == NULL) return\n");
+ free(package);
+ return NULL;
+ }
+
+ if (strcmp(tmp, ".desktop")) {
+ _E("%s is not a desktop file", desktop);
+ free(package);
+ return NULL;
+ }
+
+ *tmp = '\0';
+
+ return package;
+}
+
+
+
+int initdb_load_directory(const char *directory)
+{
+ DIR *dir;
+ struct dirent entry, *result;
+ int len, ret;
+ char buf[BUFSZE];
+
+ // desktop file
+ dir = opendir(directory);
+ if (!dir) {
+ if (strerror_r(errno, buf, sizeof(buf)) == 0)
+ _E("Failed to access the [%s] because %s\n", directory, buf);
+ return AIL_ERROR_FAIL;
+ }
+
+ len = strlen(directory) + 1;
+ _D("Loading desktop files from %s\n", directory);
+
+ for (ret = readdir_r(dir, &entry, &result);
+ ret == 0 && result != NULL;
+ ret = readdir_r(dir, &entry, &result)) {
+ char *package;
+
+ if (entry.d_name[0] == '.') continue;
+
+ package = _desktop_to_package(entry.d_name);
+ if (!package) {
+ _E("Failed to convert file to package[%s]\n", entry.d_name);
+ continue;
+ }
+
+ if (ail_desktop_add(package) != AIL_ERROR_OK) {
+ _E("Failed to add a package[%s]\n", package);
+ }
+
+ free(package);
+ }
+
+ closedir(dir);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+static int initdb_change_perm(const char *db_file)
+{
+ char buf[BUFSZE];
+ char journal_file[BUFSZE];
+ char *files[3];
+ int ret, i;
+
+ files[0] = (char *)db_file;
+ files[1] = journal_file;
+ files[2] = NULL;
+
+ retv_if(!db_file, AIL_ERROR_FAIL);
+
+ snprintf(journal_file, sizeof(journal_file), "%s%s", db_file, "-journal");
+
+ for (i = 0; files[i]; i++) {
+ ret = chown(files[i], OWNER_ROOT, GROUP_MENU);
+ if (ret == -1) {
+ strerror_r(errno, buf, sizeof(buf));
+ _E("FAIL : chown %s %d.%d, because %s", db_file, OWNER_ROOT, GROUP_MENU, buf);
+ return AIL_ERROR_FAIL;
+ }
+
+ ret = chmod(files[i], S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ if (ret == -1) {
+ strerror_r(errno, buf, sizeof(buf));
+ _E("FAIL : chmod %s 0664, because %s", db_file, buf);
+ return AIL_ERROR_FAIL;
+ }
+ }
+
+ return AIL_ERROR_OK;
+}
+
+
+static int __is_authorized()
+{
+ /* ail_init db should be called by as root privilege. */
+
+ uid_t uid = getuid();
+ if ((uid_t) 0 == uid)
+ return 1;
+ else
+ return 0;
+}
+
+
+int main(int argc, char *argv[])
+{
+ int ret;
+
+ if (!__is_authorized()) {
+ fprintf(stderr, "You are not an authorized user!\n");
+ _D("You are not an authorized user!\n");
+ return AIL_ERROR_FAIL;
+ }
+
+ ret = setenv("AIL_INITDB", "1", 1);
+ _D("AIL_INITDB : %d", ret);
+
+ ret = initdb_count_app();
+ if (ret > 0) {
+ _D("Some Apps in the App Info DB.");
+ return AIL_ERROR_OK;
+ }
+
+ ret = initdb_load_directory(OPT_DESKTOP_DIRECTORY);
+ if (ret == AIL_ERROR_FAIL) {
+ _E("cannot load opt desktop directory.");
+ return AIL_ERROR_FAIL;
+ }
+
+ ret = initdb_load_directory(USR_DESKTOP_DIRECTORY);
+ if (ret == AIL_ERROR_FAIL) {
+ _E("cannot load usr desktop directory.");
+ return AIL_ERROR_FAIL;
+ }
+
+ ret = initdb_change_perm(APP_INFO_DB_FILE);
+ if (ret == AIL_ERROR_FAIL) {
+ _E("cannot chown.");
+ return AIL_ERROR_FAIL;
+ }
+
+ return AIL_ERROR_OK;
+}
+
+
+
+// END
--- /dev/null
+#sbs-git:slp/pkgs/a/ail ail 0.2.22 29ac1f2c98453cad647cca6a92abc7da3dbb047b
+Name: ail
+Summary: Application Information Library
+Version: 0.2.55
+Release: 1
+Group: System/Libraries
+License: Apache License, Version 2.0
+Source0: %{name}-%{version}.tar.gz
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+BuildRequires: cmake
+BuildRequires: vconf-keys-devel
+BuildRequires: pkgconfig(sqlite3)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(db-util)
+BuildRequires: pkgconfig(xdgmime)
+
+
+%description
+Application Information Library
+
+%package devel
+Summary: Application Information Library Development files
+Group: Development/Libraries
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+Application Information Library (devel)
+
+%prep
+%setup -q
+
+%build
+CFLAGS+=" -fpic"
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DBUILD_PKGTYPE=rpm
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+%post
+
+CHDBGID="6010"
+
+update_DAC_for_db_file()
+{
+ if [ ! -f $@ ]; then
+ touch $@
+ fi
+
+ chown :$CHDBGID $@ 2>/dev/null
+ if [ $? -ne 0 ]; then
+ echo "Failed to change the owner of $@"
+ fi
+ chmod 664 $@ 2>/dev/null
+ if [ $? -ne 0 ]; then
+ echo "Failed to change the perms of $@"
+ fi
+}
+mkdir -p /opt/dbspace/
+ail_initdb
+update_DAC_for_db_file /opt/dbspace/.app_info.db
+update_DAC_for_db_file /opt/dbspace/.app_info.db-journal
+chsmack -a 'ail::db' /opt/dbspace/.app_info.db*
+
+%postun
+
+%files
+%manifest ail.manifest
+/usr/lib/libail.so.0
+/usr/lib/libail.so.0.1.0
+/usr/bin/ail_initdb
+/usr/share/install-info/*
+
+%files devel
+/usr/include/ail.h
+/usr/lib/libail.so
+/usr/lib/pkgconfig/ail.pc
--- /dev/null
+/*
+ * ail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <string.h>
+#include <stdio.h>
+#include "ail.h"
+#include "ail_private.h"
+#include "ail_convert.h"
+
+
+struct _ail_str_map_t {
+ ail_prop_str_e prop;
+ const char *property;
+};
+
+static struct _ail_str_map_t str_prop_map[] = {
+ {E_AIL_PROP_PACKAGE_STR, AIL_PROP_PACKAGE_STR},
+ {E_AIL_PROP_EXEC_STR, AIL_PROP_EXEC_STR},
+ {E_AIL_PROP_NAME_STR, AIL_PROP_NAME_STR},
+ {E_AIL_PROP_TYPE_STR, AIL_PROP_TYPE_STR},
+ {E_AIL_PROP_ICON_STR, AIL_PROP_ICON_STR},
+ {E_AIL_PROP_CATEGORIES_STR, AIL_PROP_CATEGORIES_STR},
+ {E_AIL_PROP_VERSION_STR, AIL_PROP_VERSION_STR},
+ {E_AIL_PROP_MIMETYPE_STR, AIL_PROP_MIMETYPE_STR},
+ {E_AIL_PROP_X_SLP_SERVICE_STR, AIL_PROP_X_SLP_SERVICE_STR},
+ {E_AIL_PROP_X_SLP_PACKAGETYPE_STR, AIL_PROP_X_SLP_PACKAGETYPE_STR},
+ {E_AIL_PROP_X_SLP_PACKAGECATEGORIES_STR, AIL_PROP_X_SLP_PACKAGECATEGORIES_STR},
+ {E_AIL_PROP_X_SLP_PACKAGEID_STR, AIL_PROP_X_SLP_PACKAGEID_STR},
+/* {E_AIL_PROP_X_SLP_URI_STR, AIL_PROP_X_SLP_URI_STR}, */
+ {E_AIL_PROP_X_SLP_SVC_STR, AIL_PROP_X_SLP_SVC_STR},
+ {E_AIL_PROP_X_SLP_EXE_PATH, AIL_PROP_X_SLP_EXE_PATH},
+ {E_AIL_PROP_X_SLP_APPID_STR, AIL_PROP_X_SLP_APPID_STR},
+ {E_AIL_PROP_X_SLP_PKGID_STR, AIL_PROP_X_SLP_PKGID_STR},
+ {E_AIL_PROP_X_SLP_DOMAIN_STR, AIL_PROP_X_SLP_DOMAIN_STR}
+};
+
+
+struct _ail_int_map_t {
+ ail_prop_int_e prop;
+ const char *property;
+};
+
+static struct _ail_int_map_t int_prop_map[] = {
+ {E_AIL_PROP_X_SLP_TEMP_INT, AIL_PROP_X_SLP_TEMP_INT},
+ {E_AIL_PROP_X_SLP_INSTALLEDTIME_INT, AIL_PROP_X_SLP_INSTALLEDTIME_INT}
+};
+
+
+struct _ail_bool_map_t {
+ ail_prop_bool_e prop;
+ const char *property;
+};
+
+static struct _ail_bool_map_t bool_prop_map[] = {
+ {E_AIL_PROP_NODISPLAY_BOOL, AIL_PROP_NODISPLAY_BOOL},
+ {E_AIL_PROP_X_SLP_TASKMANAGE_BOOL, AIL_PROP_X_SLP_TASKMANAGE_BOOL},
+ {E_AIL_PROP_X_SLP_MULTIPLE_BOOL, AIL_PROP_X_SLP_MULTIPLE_BOOL},
+ {E_AIL_PROP_X_SLP_REMOVABLE_BOOL, AIL_PROP_X_SLP_REMOVABLE_BOOL},
+/* {E_AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL, AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL}, */
+ {E_AIL_PROP_X_SLP_INACTIVATED_BOOL, AIL_PROP_X_SLP_INACTIVATED_BOOL}
+};
+
+
+inline ail_prop_str_e _ail_convert_to_prop_str(const char *property)
+{
+ int i = 0;
+ ail_prop_str_e prop = -1;
+
+ retv_if(!property, AIL_ERROR_INVALID_PARAMETER);
+
+ for (i=0 ; i<(E_AIL_PROP_STR_MAX - E_AIL_PROP_STR_MIN + 1) ; i++) {
+ if (strcmp(property, str_prop_map[i].property) == 0) {
+ prop = str_prop_map[i].prop;
+ break;
+ }
+ }
+
+ return prop;
+}
+
+inline ail_prop_int_e _ail_convert_to_prop_int(const char *property)
+{
+ int i = 0;
+ ail_prop_int_e prop = -1;
+
+ retv_if(!property, AIL_ERROR_INVALID_PARAMETER);
+
+ for (i=0 ; i<(E_AIL_PROP_INT_MAX - E_AIL_PROP_INT_MIN + 1) ; i++) {
+ if (strcmp(property, int_prop_map[i].property) == 0) {
+ prop = int_prop_map[i].prop;
+ break;
+ }
+ }
+
+ return prop;
+}
+
+inline ail_prop_bool_e _ail_convert_to_prop_bool(const char *property)
+{
+ int i = 0;
+ ail_prop_bool_e prop = -1;
+
+ retv_if(!property, AIL_ERROR_INVALID_PARAMETER);
+
+ for (i=0 ; i<(E_AIL_PROP_BOOL_MAX - E_AIL_PROP_BOOL_MIN + 1) ; i++) {
+ if (strcmp(property, bool_prop_map[i].property) == 0) {
+ prop = bool_prop_map[i].prop;
+ break;
+ }
+ }
+
+ return prop;
+}
+
--- /dev/null
+/*
+ * ail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 __AIL_CONVERT_H__
+#define __AIL_CONVERT_H__
+
+#include "ail_private.h"
+
+ail_prop_str_e _ail_convert_to_prop_str(const char *property);
+ail_prop_int_e _ail_convert_to_prop_int(const char *property);
+ail_prop_bool_e _ail_convert_to_prop_bool(const char *property);
+
+#endif /* __AIL_CONVERT_H__ */
--- /dev/null
+/*
+ * ail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <string.h>
+#include <db-util.h>
+#include <glib.h>
+#include "ail_private.h"
+#include "ail_db.h"
+
+#define retv_with_dbmsg_if(expr, val) do { \
+ if (expr) { \
+ _E("db_info.dbro: %s", sqlite3_errmsg(db_info.dbro)); \
+ _E("db_info.dbrw: %s", sqlite3_errmsg(db_info.dbrw)); \
+ return (val); \
+ } \
+} while (0)
+
+
+static __thread struct {
+ sqlite3 *dbro;
+ sqlite3 *dbrw;
+} db_info = {
+ .dbro = NULL,
+ .dbrw = NULL
+};
+
+ail_error_e db_open(db_open_mode mode)
+{
+ int ret;
+ int changed = 0;
+
+ if(mode & DB_OPEN_RO) {
+ if (!db_info.dbro) {
+ ret = db_util_open_with_options(APP_INFO_DB, &db_info.dbro, SQLITE_OPEN_READONLY, NULL);
+ _E("db_open_ro ret=%d", ret);
+ retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
+ }
+ }
+
+ if(mode & DB_OPEN_RW) {
+ if (!db_info.dbrw) {
+ ret = db_util_open(APP_INFO_DB, &db_info.dbrw, DB_UTIL_REGISTER_HOOK_METHOD);
+ _E("db_open_rw ret=%d", ret);
+ retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
+ }
+ }
+
+ return AIL_ERROR_OK;
+}
+
+
+
+ail_error_e db_prepare(const char *query, sqlite3_stmt **stmt)
+{
+ int ret;
+
+ retv_if(!query, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!stmt, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!db_info.dbro, AIL_ERROR_DB_FAILED);
+
+ ret = sqlite3_prepare_v2(db_info.dbro, query, strlen(query), stmt, NULL);
+ if (ret != SQLITE_OK) {
+ _E("%s\n", sqlite3_errmsg(db_info.dbro));
+ return AIL_ERROR_DB_FAILED;
+ } else
+ return AIL_ERROR_OK;
+}
+
+
+ail_error_e db_bind_bool(sqlite3_stmt *stmt, int idx, bool value)
+{
+ int ret;
+
+ retv_if(!stmt, AIL_ERROR_INVALID_PARAMETER);
+
+ ret = sqlite3_bind_int(stmt, idx, (int) value);
+ retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+ail_error_e db_bind_int(sqlite3_stmt *stmt, int idx, int value)
+{
+ int ret;
+
+ retv_if(!stmt, AIL_ERROR_INVALID_PARAMETER);
+
+ ret = sqlite3_bind_int(stmt, idx, value);
+ retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+ail_error_e db_step(sqlite3_stmt *stmt)
+{
+ int ret;
+
+ retv_if(!stmt, AIL_ERROR_INVALID_PARAMETER);
+
+ ret = sqlite3_step(stmt);
+ switch (ret) {
+ case SQLITE_DONE:
+ return AIL_ERROR_NO_DATA;
+ case SQLITE_ROW:
+ return AIL_ERROR_OK;
+ }
+
+ retv_with_dbmsg_if(1, AIL_ERROR_DB_FAILED);
+}
+
+
+
+ail_error_e db_column_bool(sqlite3_stmt *stmt, int index, bool *value)
+{
+ int out_val;
+
+ retv_if(!stmt, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+
+ out_val = sqlite3_column_int(stmt, index);
+ *value = (out_val == 1)? true:false;
+
+ return AIL_ERROR_OK;
+}
+
+
+
+ail_error_e db_column_int(sqlite3_stmt *stmt, int index, int *value)
+{
+ retv_if(!stmt, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+
+ *value = sqlite3_column_int(stmt, index);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+ail_error_e db_column_str(sqlite3_stmt *stmt, int index, char **str)
+{
+ retv_if(!stmt, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!str, AIL_ERROR_INVALID_PARAMETER);
+
+ *str = (char *)sqlite3_column_text(stmt, index);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+ail_error_e db_reset(sqlite3_stmt *stmt)
+{
+ int ret;
+
+ retv_if(!stmt, AIL_ERROR_INVALID_PARAMETER);
+
+ sqlite3_clear_bindings(stmt);
+
+ ret = sqlite3_reset(stmt);
+ retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+ail_error_e db_finalize(sqlite3_stmt *stmt)
+{
+ int ret;
+
+ retv_if(!stmt, AIL_ERROR_INVALID_PARAMETER);
+
+ ret = sqlite3_finalize(stmt);
+ retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+ail_error_e db_exec(const char *query)
+{
+ int ret;
+ char *errmsg;
+
+ retv_if(!query, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!db_info.dbrw, AIL_ERROR_DB_FAILED);
+
+ ret = sqlite3_exec(db_info.dbrw, query, NULL, NULL, &errmsg);
+ if (ret != SQLITE_OK) {
+ _E("Cannot execute this query - %s. because %s",
+ query, errmsg? errmsg:"uncatched error");
+ sqlite3_free(errmsg);
+ return AIL_ERROR_DB_FAILED;
+ }
+
+ return AIL_ERROR_OK;
+}
+
+
+
+ail_error_e db_close(void)
+{
+ int ret;
+
+ if(db_info.dbro) {
+ ret = sqlite3_close(db_info.dbro);
+ retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
+
+ db_info.dbro = NULL;
+ }
+ if(db_info.dbrw) {
+ ret = sqlite3_close(db_info.dbrw);
+ retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
+
+ db_info.dbrw = NULL;
+ }
+
+ return AIL_ERROR_OK;
+}
+
+EXPORT_API ail_error_e ail_db_close(void)
+{
+ return db_close();
+}
+
+int db_exec_sqlite_query(char *query, sqlite_query_callback callback, void *data)
+{
+ char *error_message = NULL;
+ if (SQLITE_OK !=
+ sqlite3_exec(db_info.dbro, query, callback, data, &error_message)) {
+ _E("Don't execute query = %s error message = %s\n", query,
+ error_message);
+ sqlite3_free(error_message);
+ return -1;
+ }
+ sqlite3_free(error_message);
+ return 0;
+}
+
+// End of file.
--- /dev/null
+/*
+ * ail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 __AIL_DB_H__
+#define __AIL_DB_H__
+
+#include <sqlite3.h>
+#include "ail.h"
+
+#define AIL_SQL_QUERY_MAX_LEN 2048
+
+typedef enum {
+ DB_OPEN_RO = 0x0001,
+ DB_OPEN_RW = 0x0002,
+} db_open_mode;
+typedef int (*sqlite_query_callback)(void *data, int ncols, char **coltxt, char **colname);
+
+ail_error_e db_open(db_open_mode mode);
+ail_error_e db_prepare(const char *query, sqlite3_stmt **stmt);
+
+ail_error_e db_bind_bool(sqlite3_stmt *stmt, int idx, bool value);
+ail_error_e db_bind_int(sqlite3_stmt *stmt, int idx, int value);
+
+ail_error_e db_step(sqlite3_stmt *stmt);
+
+ail_error_e db_column_bool(sqlite3_stmt *stmt, int index, bool *value);
+ail_error_e db_column_int(sqlite3_stmt *stmt, int index, int *value);
+ail_error_e db_column_str(sqlite3_stmt *stmt, int index, char **str);
+
+ail_error_e db_reset(sqlite3_stmt *stmt);
+ail_error_e db_finalize(sqlite3_stmt *stmt);
+
+
+ail_error_e db_exec(const char *query);
+ail_error_e db_close(void);
+int db_exec_sqlite_query(char *query, sqlite_query_callback callback, void *data);
+#endif
+// End of file
--- /dev/null
+/*
+ * ail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 _GNU_SOURCE
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <time.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <xdgmime.h>
+
+#include <vconf.h>
+#include <glib.h>
+
+#include "ail_private.h"
+#include "ail_db.h"
+#include "ail.h"
+
+#define OPT_DESKTOP_DIRECTORY "/opt/share/applications"
+#define USR_DESKTOP_DIRECTORY "/usr/share/applications"
+#define BUFSZE 4096
+
+#define whitespace(c) (((c) == ' ') || ((c) == '\t'))
+#define argsdelimiter " \t"
+
+typedef enum {
+ NOTI_ADD,
+ NOTI_UPDATE,
+ NOTI_REMOVE,
+ NOTI_MAX,
+} noti_type;
+
+struct entry_parser {
+ const char *field;
+ ail_error_e (*value_cb)(void *data, char *tag, char *value);
+};
+
+inline static char *_ltrim(char *str)
+{
+ if (!str) return NULL;
+
+ while (*str == ' ' || *str == '\t' || *str == '\n') str ++;
+
+ return str;
+}
+
+
+
+inline static int _rtrim(char *str)
+{
+ int len;
+
+ len = strlen(str);
+ while (--len >= 0 && (str[len] == ' ' || str[len] == '\n' || str[len] == '\t')) str[len] = '\0';
+
+ return len;
+}
+
+struct name_item {
+ char *locale;
+ char *name;
+};
+
+typedef struct {
+ const char* package;
+ char* exec;
+ char* name;
+ char* type;
+ char* icon;
+ char* categories;
+ char* version;
+ char* mimetype;
+ char* x_slp_service;
+ char* x_slp_packagetype;
+ char* x_slp_packagecategories;
+ char* x_slp_packageid;
+ char* x_slp_uri;
+ char* x_slp_svc;
+ char* x_slp_exe_path;
+ char* x_slp_appid;
+ char* x_slp_pkgid;
+ char* x_slp_domain;
+ int x_slp_baselayoutwidth;
+ int x_slp_installedtime;
+ int nodisplay;
+ int x_slp_taskmanage;
+ int x_slp_multiple;
+ int x_slp_removable;
+ int x_slp_ishorizontalscale;
+ int x_slp_inactivated;
+ char* desktop;
+ GSList* localname;
+} desktop_info_s;
+
+
+
+static ail_error_e _read_exec(void *data, char *tag, char *value)
+{
+ desktop_info_s *info = data;
+ char *token_exe_path;
+ char *save_ptr;
+ char *temp_exec;
+
+ retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+
+ SAFE_FREE_AND_STRDUP(value, info->exec);
+ retv_if(!info->exec, AIL_ERROR_OUT_OF_MEMORY);
+
+ temp_exec = strdup(value);
+ if(!temp_exec) {
+ free(info->exec);
+ return AIL_ERROR_OUT_OF_MEMORY;
+ }
+
+ token_exe_path = strtok_r(temp_exec, argsdelimiter, &save_ptr);
+
+ info->x_slp_exe_path = strdup(token_exe_path);
+ if(!info->x_slp_exe_path) {
+ free(info->exec);
+ info->exec = NULL;
+ free(temp_exec);
+ return AIL_ERROR_OUT_OF_MEMORY;
+ }
+
+ free(temp_exec);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+static ail_error_e _read_name(void *data, char *tag, char *value)
+{
+ desktop_info_s *info = data;
+
+ retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(0 == strlen(value), AIL_ERROR_FAIL);
+
+ if (tag && strlen(tag) > 0) {
+ struct name_item *item;
+ item = (struct name_item *)calloc(1, sizeof(struct name_item));
+ retv_if (NULL == item, AIL_ERROR_OUT_OF_MEMORY);
+
+ SAFE_FREE_AND_STRDUP(tag, item->locale);
+ if(NULL == item->locale) {
+ _E("(NULL == item->locale) return\n");
+ free(item);
+ return AIL_ERROR_OUT_OF_MEMORY;
+ }
+
+ SAFE_FREE_AND_STRDUP(value, item->name);
+ if(NULL == item->name) {
+ _E("(NULL == item->name) return\n");
+ free(item->locale);
+ free(item);
+ return AIL_ERROR_OUT_OF_MEMORY;
+ }
+
+ info->localname = g_slist_append(info->localname, item);
+
+ return AIL_ERROR_OK;
+ } else {
+ SAFE_FREE_AND_STRDUP(value, info->name);
+ retv_if (!info->name, AIL_ERROR_OUT_OF_MEMORY);
+
+ return AIL_ERROR_OK;
+ }
+}
+
+
+
+static ail_error_e _read_type(void *data, char *tag, char *value)
+{
+ desktop_info_s *info = data;
+
+ retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+
+ SAFE_FREE_AND_STRDUP(value, info->type);
+ retv_if (!info->type, AIL_ERROR_OUT_OF_MEMORY);
+
+ return AIL_ERROR_OK;
+}
+
+
+static char*
+_get_package_from_icon(char* icon)
+{
+ char* package;
+ char* extension;
+
+ retv_if(!icon, NULL);
+
+ package = strdup(icon);
+ retv_if(!package, NULL);
+ extension = rindex(package, '.');
+ if (extension) {
+ *extension = '\0';
+ } else {
+ _E("cannot extract from icon [%s] to package.", icon);
+ }
+
+ return package;
+}
+
+
+static char*
+_get_icon_with_path(char* icon)
+{
+ retv_if(!icon, NULL);
+
+ if (index(icon, '/') == NULL) {
+ char* package;
+ char* theme = NULL;
+ char* icon_with_path = NULL;
+ int len;
+
+ package = _get_package_from_icon(icon);
+ retv_if(!package, NULL);
+
+ theme = vconf_get_str("db/setting/theme");
+ if (!theme) {
+ theme = strdup("default");
+ if(!theme) {
+ free(package);
+ return NULL;
+ }
+ }
+
+ len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
+ icon_with_path = malloc(len);
+ if(icon_with_path == NULL) {
+ _E("(icon_with_path == NULL) return\n");
+ free(package);
+ free(theme);
+ return NULL;
+ }
+
+ memset(icon_with_path, 0, len);
+
+ sqlite3_snprintf( len, icon_with_path,"/opt/share/icons/%q/small/%q", theme, icon);
+ do {
+ if (access(icon_with_path, R_OK) == 0) break;
+ sqlite3_snprintf( len, icon_with_path,"/usr/share/icons/%q/small/%q", theme, icon);
+ if (access(icon_with_path, R_OK) == 0) break;
+ _D("cannot find icon %s", icon_with_path);
+ sqlite3_snprintf( len, icon_with_path, "/opt/share/icons/default/small/%q", icon);
+ if (access(icon_with_path, R_OK) == 0) break;
+ sqlite3_snprintf( len, icon_with_path, "/usr/share/icons/default/small/%q", icon);
+ if (access(icon_with_path, R_OK) == 0) break;
+
+ #if 1 /* this will be remove when finish the work for moving icon path */
+ _E("icon file must be moved to %s", icon_with_path);
+ sqlite3_snprintf( len, icon_with_path, "/opt/apps/%q/res/icons/%q/small/%q", package, theme, icon);
+ if (access(icon_with_path, R_OK) == 0) break;
+ sqlite3_snprintf( len, icon_with_path, "/usr/apps/%q/res/icons/%q/small/%q", package, theme, icon);
+ if (access(icon_with_path, R_OK) == 0) break;
+ _D("cannot find icon %s", icon_with_path);
+ sqlite3_snprintf( len, icon_with_path, "/opt/apps/%q/res/icons/default/small/%q", package, icon);
+ if (access(icon_with_path, R_OK) == 0) break;
+ sqlite3_snprintf( len, icon_with_path, "/usr/apps/%q/res/icons/default/small/%q", package, icon);
+ if (access(icon_with_path, R_OK) == 0) break;
+ #endif
+ } while (0);
+
+ free(theme);
+ free(package);
+
+ _D("Icon path : %s ---> %s", icon, icon_with_path);
+
+ return icon_with_path;
+ } else {
+ char* confirmed_icon = NULL;
+
+ confirmed_icon = strdup(icon);
+ retv_if(!confirmed_icon, NULL);
+ return confirmed_icon;
+ }
+}
+
+
+static ail_error_e _read_icon(void *data, char *tag, char *value)
+{
+ desktop_info_s *info = data;
+
+ retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+
+ info->icon = _get_icon_with_path(value);
+
+ retv_if (!info->icon, AIL_ERROR_OUT_OF_MEMORY);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+static ail_error_e _read_categories(void *data, char *tag, char *value)
+{
+ desktop_info_s *info = data;
+
+ retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+
+ SAFE_FREE_AND_STRDUP(value, info->categories);
+ retv_if (!info->categories, AIL_ERROR_OUT_OF_MEMORY);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+static ail_error_e _read_version(void *data, char *tag, char *value)
+{
+ desktop_info_s *info = data;
+
+ retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+
+ SAFE_FREE_AND_STRDUP(value, info->version);
+ retv_if (!info->version, AIL_ERROR_OUT_OF_MEMORY);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+static ail_error_e _read_mimetype(void *data, char *tag, char *value)
+{
+ desktop_info_s *info = data;
+ int size, total_len = 0;
+ char *mimes_origin, *mimes_changed, *token_unalias, *save_ptr;
+
+ retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!strlen(value), AIL_ERROR_FAIL);
+
+ mimes_origin = strdup(value);
+ retv_if(!mimes_origin, AIL_ERROR_OUT_OF_MEMORY);
+
+ size = getpagesize();
+ mimes_changed = calloc(1, size);
+ if(mimes_changed == NULL) {
+ _E("(mimes_changed == NULL) return\n");
+ free(mimes_origin);
+ return AIL_ERROR_OUT_OF_MEMORY;
+ }
+
+ token_unalias = strtok_r(mimes_origin, ";", &save_ptr);
+
+ while (token_unalias) {
+ int token_len;
+ const char *token_alias;
+
+ _rtrim(token_unalias);
+ token_unalias = _ltrim(token_unalias);
+
+ token_alias = xdg_mime_unalias_mime_type(token_unalias);
+ if (!token_alias) continue;
+
+ token_len = strlen(token_alias);
+ if (total_len + token_len + (1<<1) >= size) {
+ char *tmp;
+ size *= 2;
+ tmp = realloc(mimes_changed, size);
+ if(!tmp) {
+ free(mimes_changed);
+ return AIL_ERROR_OUT_OF_MEMORY;
+ }
+ mimes_changed = tmp;
+ }
+
+ strncat(mimes_changed, token_alias, size-1);
+ total_len += token_len;
+
+ token_unalias = strtok_r(NULL, ";", &save_ptr);
+ if (token_unalias) {
+ strncat(mimes_changed, ";", size-strlen(mimes_changed)-1);
+ }
+ }
+
+ SAFE_FREE(info->mimetype);
+ info->mimetype = mimes_changed;
+
+ return AIL_ERROR_OK;
+}
+
+
+
+static ail_error_e _read_nodisplay(void *data, char *tag, char *value)
+{
+ desktop_info_s* info = data;
+
+ retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+
+ info->nodisplay = !strcasecmp(value, "true");
+
+ return AIL_ERROR_OK;
+}
+
+
+
+static ail_error_e _read_x_slp_service(void *data, char *tag, char *value)
+{
+ desktop_info_s *info = data;
+
+ retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+
+ SAFE_FREE_AND_STRDUP(value, info->x_slp_service);
+ retv_if(!info->x_slp_service, AIL_ERROR_OUT_OF_MEMORY);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+static ail_error_e _read_x_slp_packagetype(void *data, char *tag, char *value)
+{
+ desktop_info_s *info = data;
+
+ retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+
+ SAFE_FREE_AND_STRDUP(value, info->x_slp_packagetype);
+ retv_if(!info->x_slp_packagetype, AIL_ERROR_OUT_OF_MEMORY);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+static ail_error_e _read_x_slp_packagecategories(void *data, char *tag, char *value)
+{
+ desktop_info_s *info = data;
+
+ retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+
+ SAFE_FREE_AND_STRDUP(value, info->x_slp_packagecategories);
+ retv_if(!info->x_slp_packagecategories, AIL_ERROR_OUT_OF_MEMORY);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+static ail_error_e _read_x_slp_packageid(void *data, char *tag, char *value)
+{
+ desktop_info_s *info = data;
+
+ retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+
+ SAFE_FREE_AND_STRDUP(value, info->x_slp_packageid);
+ retv_if(!info->x_slp_packageid, AIL_ERROR_OUT_OF_MEMORY);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+static ail_error_e _read_x_slp_uri(void *data, char *tag, char *value)
+{
+ desktop_info_s *info = data;
+
+ retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+
+ SAFE_FREE_AND_STRDUP(value, info->x_slp_uri);
+ retv_if(!info->x_slp_uri, AIL_ERROR_OUT_OF_MEMORY);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+static ail_error_e _read_x_slp_svc(void *data, char *tag, char *value)
+{
+ desktop_info_s *info = data;
+
+ retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+
+ SAFE_FREE_AND_STRDUP(value, info->x_slp_svc);
+ retv_if(!info->x_slp_svc, AIL_ERROR_OUT_OF_MEMORY);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+static ail_error_e _read_x_slp_taskmanage(void *data, char *tag, char *value)
+{
+ desktop_info_s *info = data;
+
+ retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+
+ info->x_slp_taskmanage = !strcasecmp(value, "true");
+
+ return AIL_ERROR_OK;
+}
+
+
+
+static ail_error_e _read_x_slp_multiple(void *data, char *tag, char *value)
+{
+ desktop_info_s *info = data;
+
+ retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+
+ info->x_slp_multiple = !strcasecmp(value, "true");
+
+ return AIL_ERROR_OK;
+}
+
+
+
+static ail_error_e _read_x_slp_removable(void *data, char *tag, char *value)
+{
+ desktop_info_s *info = data;
+
+ retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+
+ info->x_slp_removable = !strcasecmp(value, "true");
+
+ return AIL_ERROR_OK;
+}
+
+
+static ail_error_e _read_x_slp_appid(void *data, char *tag, char *value)
+{
+ desktop_info_s *info = data;
+
+ retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+
+ SAFE_FREE_AND_STRDUP(value, info->x_slp_appid);
+ retv_if(!info->x_slp_appid, AIL_ERROR_OUT_OF_MEMORY);
+
+ return AIL_ERROR_OK;
+}
+
+
+static ail_error_e _read_x_slp_pkgid(void *data, char *tag, char *value)
+{
+ desktop_info_s *info = data;
+
+ retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+
+ SAFE_FREE_AND_STRDUP(value, info->x_slp_pkgid);
+ retv_if(!info->x_slp_pkgid, AIL_ERROR_OUT_OF_MEMORY);
+
+ return AIL_ERROR_OK;
+}
+
+
+static ail_error_e _read_x_slp_domain(void *data, char *tag, char *value)
+{
+ desktop_info_s *info = data;
+
+ retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+
+ SAFE_FREE_AND_STRDUP(value, info->x_slp_domain);
+ retv_if(!info->x_slp_appid, AIL_ERROR_OUT_OF_MEMORY);
+
+ return AIL_ERROR_OK;
+}
+
+
+static struct entry_parser entry_parsers[] = {
+ {
+ .field = "exec",
+ .value_cb = _read_exec,
+ },
+ {
+ .field = "name",
+ .value_cb = _read_name,
+ },
+ {
+ .field = "type",
+ .value_cb = _read_type,
+ },
+ {
+ .field = "icon",
+ .value_cb = _read_icon,
+ },
+ {
+ .field = "categories",
+ .value_cb = _read_categories,
+ },
+ {
+ .field = "version",
+ .value_cb = _read_version,
+ },
+ {
+ .field = "mimetype",
+ .value_cb = _read_mimetype,
+ },
+ {
+ .field = "x-tizen-service",
+ .value_cb = _read_x_slp_service,
+ },
+ {
+ .field = "x-tizen-packagetype",
+ .value_cb = _read_x_slp_packagetype,
+ },
+ {
+ .field = "x-tizen-packagecategories",
+ .value_cb = _read_x_slp_packagecategories,
+ },
+ {
+ .field = "x-tizen-packageid",
+ .value_cb = _read_x_slp_packageid,
+ },
+ {
+ .field = "x-tizen-uri",
+ .value_cb = _read_x_slp_uri,
+ },
+ {
+ .field = "x-tizen-svc",
+ .value_cb = _read_x_slp_svc,
+ },
+ {
+ .field = "nodisplay",
+ .value_cb = _read_nodisplay,
+ },
+ {
+ .field = "x-tizen-taskmanage",
+ .value_cb = _read_x_slp_taskmanage,
+ },
+ {
+ .field = "x-tizen-multiple",
+ .value_cb = _read_x_slp_multiple,
+ },
+ {
+ .field = "x-tizen-removable",
+ .value_cb = _read_x_slp_removable,
+ },
+ {
+ .field = "x-tizen-appid",
+ .value_cb = _read_x_slp_appid,
+ },
+ {
+ .field = "x-tizen-pkgid",
+ .value_cb = _read_x_slp_pkgid,
+ },
+ {
+ .field = "x-tizen-domain",
+ .value_cb = _read_x_slp_domain,
+ },
+ {
+ .field = NULL,
+ .value_cb = NULL,
+ },
+};
+
+
+
+/* Utility functions */
+static int _count_all(void)
+{
+ ail_error_e ret;
+ int count;
+
+ ret = ail_filter_count_appinfo(NULL, &count);
+ if(ret != AIL_ERROR_OK) {
+ _E("cannot count appinfo");
+ count = -1;
+ }
+
+ retv_if(ret != AIL_ERROR_OK, -1);
+
+ return count;
+}
+
+
+
+char *_pkgname_to_desktop(const char *package)
+{
+ char *desktop;
+ int size;
+
+ retv_if(!package, NULL);
+
+ size = strlen(OPT_DESKTOP_DIRECTORY) + strlen(package) + 10;
+ desktop = malloc(size);
+ retv_if(!desktop, NULL);
+
+ snprintf(desktop, size, OPT_DESKTOP_DIRECTORY"/%s.desktop", package);
+
+ if (access(desktop, R_OK) == 0)
+ return desktop;
+
+ snprintf(desktop, size, USR_DESKTOP_DIRECTORY"/%s.desktop", package);
+
+ return desktop;
+}
+
+
+
+static inline int _strlen_desktop_info(desktop_info_s* info)
+{
+ int len = 0;
+
+ retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
+
+ if (info->package) len += strlen(info->package);
+ if (info->exec) len += strlen(info->exec);
+ if (info->name) len += strlen(info->name);
+ if (info->type) len += strlen(info->type);
+ if (info->icon) len += strlen(info->icon);
+ if (info->categories) len += strlen(info->categories);
+ if (info->version) len += strlen(info->version);
+ if (info->mimetype) len += strlen(info->mimetype);
+ if (info->x_slp_service) len += strlen(info->x_slp_service);
+ if (info->x_slp_packagetype) len += strlen(info->x_slp_packagetype);
+ if (info->x_slp_packagecategories) len += strlen(info->x_slp_packagecategories);
+ if (info->x_slp_packageid) len += strlen(info->x_slp_packageid);
+ if (info->x_slp_uri) len += strlen(info->x_slp_uri);
+ if (info->x_slp_svc) len += strlen(info->x_slp_svc);
+ if (info->x_slp_exe_path) len += strlen(info->x_slp_exe_path);
+ if (info->x_slp_appid) len += strlen(info->x_slp_appid);
+ if (info->desktop) len += strlen(info->desktop);
+
+ return len;
+}
+
+
+int __is_ail_initdb(void)
+{
+ if( getenv("AIL_INITDB") || getenv("INITDB") )
+ return 1;
+ else
+ return 0;
+}
+
+
+
+/* Manipulating desktop_info functions */
+static ail_error_e _init_desktop_info(desktop_info_s *info, const char *package)
+{
+ static int is_initdb = -1;
+
+ if(is_initdb == -1)
+ is_initdb = __is_ail_initdb();
+
+ retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!package, AIL_ERROR_INVALID_PARAMETER);
+
+ /* defaults */
+ info->package = package;
+
+ info->x_slp_taskmanage = 1;
+ info->x_slp_removable = 1;
+
+ if(is_initdb)
+ info->x_slp_installedtime = 0;
+ else
+ info->x_slp_installedtime = time(NULL);
+
+#ifdef PKGTYPE
+ info->x_slp_packagetype = strdup(PKGTYPE);
+#else
+ info->x_slp_packagetype = strdup("rpm");
+#endif
+ retv_if(!info->x_slp_packagetype, AIL_ERROR_OUT_OF_MEMORY);
+
+ info->x_slp_packageid = strdup(package);
+ retv_if(!info->x_slp_packageid, AIL_ERROR_OUT_OF_MEMORY);
+ info->x_slp_appid = strdup(package);
+ retv_if(!info->x_slp_appid, AIL_ERROR_OUT_OF_MEMORY);
+
+ info->desktop = _pkgname_to_desktop(package);
+ retv_if(!info->desktop, AIL_ERROR_FAIL);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+static ail_error_e _read_desktop_info(desktop_info_s* info)
+{
+ char *line = NULL;
+ FILE *fp;
+ size_t size = 0;
+ ssize_t read;
+
+ retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
+
+ fp = fopen(info->desktop, "r");
+ retv_if(!fp, AIL_ERROR_FAIL);
+
+ while ((read = getline(&line, &size, fp)) != -1) {
+ int len, idx;
+ char *tmp, *field, *field_name, *tag, *value;
+
+ tmp = _ltrim(line);
+ if(tmp == NULL) continue;
+ if (*tmp == '#') continue;
+ if (_rtrim(tmp) <= 0) continue;
+
+ len = strlen(line) + 1;
+ field = calloc(1, len);
+ field_name = calloc(1, len);
+ tag = calloc(1, len);
+ value = calloc(1, len);
+
+ if (!field || !field_name || !tag || !value) {
+ goto NEXT;
+ }
+
+ sscanf(tmp, "%[^=]=%[^\n]", field, value);
+ _rtrim(field);
+ tmp = _ltrim(value);
+
+ sscanf(field, "%[^[][%[^]]]", field_name, tag);
+
+ if (!field_name || !strlen(field_name)){
+ goto NEXT;
+ }
+
+ for (idx = 0; entry_parsers[idx].field; idx ++) {
+ if (!g_ascii_strcasecmp(entry_parsers[idx].field, field_name) && entry_parsers[idx].value_cb) {
+ if (entry_parsers[idx].value_cb(info, tag, tmp) != AIL_ERROR_OK) {
+ _E("field - [%s] is wrong.", field_name);
+ }
+ break;
+ }
+ }
+NEXT:
+ SAFE_FREE(field);
+ SAFE_FREE(field_name);
+ SAFE_FREE(tag);
+ SAFE_FREE(value);
+ }
+
+ _D("Read (%s).", info->package);
+ fclose(fp);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+static ail_error_e _modify_desktop_info_bool(desktop_info_s* info,
+ const char *property,
+ bool value)
+{
+ ail_prop_bool_e prop;
+ int val;
+
+ retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!property, AIL_ERROR_INVALID_PARAMETER);
+
+ prop = _ail_convert_to_prop_bool(property);
+
+ if (prop < E_AIL_PROP_BOOL_MIN || prop > E_AIL_PROP_BOOL_MAX)
+ return AIL_ERROR_INVALID_PARAMETER;
+
+ switch (prop) {
+ case E_AIL_PROP_X_SLP_INACTIVATED_BOOL:
+ info->x_slp_inactivated = (int)value;
+ break;
+ default:
+ return AIL_ERROR_FAIL;
+ }
+
+ return AIL_ERROR_OK;
+}
+
+
+
+static ail_error_e _create_table(void)
+{
+ int i;
+ ail_error_e ret;
+ const char *tbls[3] = {
+ "CREATE TABLE app_info "
+ "(package TEXT PRIMARY KEY, "
+ "exec TEXT DEFAULT 'No Exec', "
+ "name TEXT DEFAULT 'No Name', "
+ "type TEXT DEFAULT 'Application', "
+ "icon TEXT DEFAULT 'No Icon', "
+ "categories TEXT, "
+ "version TEXT, "
+ "mimetype TEXT, "
+ "x_slp_service TEXT, "
+ "x_slp_packagetype TEXT, "
+ "x_slp_packagecategories TEXT, "
+ "x_slp_packageid TEXT, "
+ "x_slp_uri TEXT, "
+ "x_slp_svc TEXT, "
+ "x_slp_exe_path TEXT, "
+ "x_slp_appid TEXT, "
+ "x_slp_pkgid TEXT, "
+ "x_slp_domain TEXT, "
+ "x_slp_baselayoutwidth INTEGER DEFAULT 0, "
+ "x_slp_installedtime INTEGER DEFAULT 0, "
+ "nodisplay INTEGER DEFAULT 0, "
+ "x_slp_taskmanage INTEGER DEFAULT 1, "
+ "x_slp_multiple INTEGER DEFAULT 0, "
+ "x_slp_removable INTEGER DEFAULT 1, "
+ "x_slp_ishorizontalscale INTEGER DEFAULT 0, "
+ "x_slp_inactivated INTEGER DEFAULT 0, "
+ "desktop TEXT UNIQUE NOT NULL);",
+ "CREATE TABLE localname (package TEXT NOT NULL, "
+ "locale TEXT NOT NULL, "
+ "name TEXT NOT NULL, PRIMARY KEY (package, locale));",
+ NULL
+ };
+
+ ret = db_open(DB_OPEN_RW);
+ retv_if(ret != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
+
+ for (i = 0; tbls[i] != NULL; i++) {
+ ret = db_exec(tbls[i]);
+ retv_if(ret != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
+ }
+
+ return AIL_ERROR_OK;
+}
+
+
+static inline void _insert_localname(gpointer data, gpointer user_data)
+{
+ char query[512];
+
+ struct name_item *item = (struct name_item *)data;
+ desktop_info_s *info = (desktop_info_s *)user_data;
+
+ snprintf(query, sizeof(query), "insert into localname (package, locale, name) "
+ "values ('%s', '%s', '%s');",
+ info->package, item->locale, item->name);
+ if (db_exec(query) < 0)
+ _E("Failed to insert local name of package[%s]",info->package);
+}
+
+static ail_error_e _insert_desktop_info(desktop_info_s *info)
+{
+ char *query;
+ int len;
+ ail_error_e ret;
+
+ len = _strlen_desktop_info(info) + (0x01 << 10);
+ query = calloc(1, len);
+ retv_if(!query, AIL_ERROR_OUT_OF_MEMORY);
+
+ sqlite3_snprintf(len, query, "insert into app_info ("
+ "package, "
+ "exec, name, "
+ "type, "
+ "icon, "
+ "categories, "
+ "version, "
+ "mimetype, "
+ "x_slp_service, "
+ "x_slp_packagetype, "
+ "x_slp_packagecategories, "
+ "x_slp_packageid, "
+ "x_slp_uri, "
+ "x_slp_svc, "
+ "x_slp_exe_path, "
+ "x_slp_appid, "
+ "x_slp_pkgid, "
+ "x_slp_domain, "
+ "x_slp_baselayoutwidth, "
+ "x_slp_installedtime, "
+ "nodisplay, "
+ "x_slp_taskmanage, "
+ "x_slp_multiple, "
+ "x_slp_removable, "
+ "x_slp_ishorizontalscale, "
+ "x_slp_inactivated, "
+ "desktop) "
+ "values "
+ "('%q', '%q', '%q', '%q', '%q', "
+ "'%q', '%q', '%q', '%q', '%q', "
+ "'%q', '%q', '%q', '%q', '%q', "
+ "'%q', '%q', '%q', "
+ "%d, %d, %d, %d, %d, %d, "
+ "%d, %d, "
+ "'%q');",
+ info->package,
+ info->exec,
+ info->name,
+ info->type,
+ info->icon,
+ info->categories,
+ info->version,
+ info->mimetype,
+ info->x_slp_service,
+ info->x_slp_packagetype,
+ info->x_slp_packagecategories,
+ info->x_slp_packageid,
+ info->x_slp_uri,
+ info->x_slp_svc,
+ info->x_slp_exe_path,
+ info->x_slp_appid,
+ info->x_slp_pkgid,
+ info->x_slp_domain,
+ info->x_slp_baselayoutwidth,
+ info->x_slp_installedtime,
+ info->nodisplay,
+ info->x_slp_taskmanage,
+ info->x_slp_multiple,
+ info->x_slp_removable,
+ info->x_slp_ishorizontalscale,
+ info->x_slp_inactivated,
+ info->desktop
+ );
+
+ ret = db_open(DB_OPEN_RW);
+ if(ret != AIL_ERROR_OK) {
+ _E("(tmp == NULL) return\n");
+ free(query);
+ return AIL_ERROR_DB_FAILED;
+ }
+
+ ret = db_exec(query);
+ retv_if(ret != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
+
+ if (info->localname)
+ g_slist_foreach(info->localname, _insert_localname, info);
+
+ _D("Add (%s).", info->package);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+static ail_error_e _update_desktop_info(desktop_info_s *info)
+{
+ char *query;
+ int len;
+
+ retv_if (NULL == info, AIL_ERROR_INVALID_PARAMETER);
+
+ if (db_open(DB_OPEN_RW) < 0) {
+ return AIL_ERROR_DB_FAILED;
+ }
+
+ len = _strlen_desktop_info(info) + (0x01 << 10);
+ query = calloc(1, len);
+ retv_if(!query, AIL_ERROR_OUT_OF_MEMORY);
+
+ sqlite3_snprintf ( len, query, "update app_info set "
+ "exec='%q', "
+ "name='%q', "
+ "type='%q', "
+ "icon='%q', "
+ "categories='%q', "
+ "version='%q', "
+ "mimetype='%q', "
+ "x_slp_service='%q', "
+ "x_slp_packagetype='%q', "
+ "x_slp_packagecategories='%q', "
+ "x_slp_packageid='%q', "
+ "x_slp_uri='%q', "
+ "x_slp_svc='%q', "
+ "x_slp_exe_path='%q', "
+ "x_slp_appid='%q', "
+ "x_slp_pkgid='%q', "
+ "x_slp_domain='%q', "
+ "x_slp_baselayoutwidth=%d, "
+ "x_slp_installedtime=%d, "
+ "nodisplay=%d, "
+ "x_slp_taskmanage=%d, "
+ "x_slp_multiple=%d, "
+ "x_slp_removable=%d, "
+ "x_slp_ishorizontalscale=%d, "
+ "x_slp_inactivated=%d, "
+ "desktop='%q'"
+ "where package='%q'",
+ info->exec,
+ info->name,
+ info->type,
+ info->icon,
+ info->categories,
+ info->version,
+ info->mimetype,
+ info->x_slp_service,
+ info->x_slp_packagetype,
+ info->x_slp_packagecategories,
+ info->x_slp_packageid,
+ info->x_slp_uri,
+ info->x_slp_svc,
+ info->x_slp_exe_path,
+ info->x_slp_appid,
+ info->x_slp_pkgid,
+ info->x_slp_domain,
+ info->x_slp_baselayoutwidth,
+ info->x_slp_installedtime,
+ info->nodisplay,
+ info->x_slp_taskmanage,
+ info->x_slp_multiple,
+ info->x_slp_removable,
+ info->x_slp_ishorizontalscale,
+ info->x_slp_inactivated,
+ info->desktop,
+ info->package);
+
+ if (db_exec(query) < 0) {
+ free (query);
+ return AIL_ERROR_DB_FAILED;
+ }
+
+ snprintf(query, len, "delete from localname where package = '%s'", info->package);
+
+ if (db_exec(query) < 0) {
+ free (query);
+ return AIL_ERROR_DB_FAILED;
+ }
+
+ if (info->localname)
+ g_slist_foreach(info->localname, _insert_localname, info);
+
+ _D("Update (%s).", info->package);
+
+ free(query);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+static ail_error_e _remove_package(const char* package)
+{
+ char *query;
+ int size;
+
+ retv_if(!package, AIL_ERROR_INVALID_PARAMETER);
+
+ if (db_open(DB_OPEN_RW) < 0) {
+ return AIL_ERROR_DB_FAILED;
+ }
+
+ size = strlen(package) + (0x01 << 10);
+ query = calloc(1, size);
+ retv_if(!query, AIL_ERROR_OUT_OF_MEMORY);
+
+ snprintf(query, size, "delete from app_info where package = '%s'", package);
+
+ if (db_exec(query) < 0) {
+ free(query);
+ return AIL_ERROR_DB_FAILED;
+ }
+
+ snprintf(query, size, "delete from localname where package = '%s'", package);
+ _D("query=%s",query);
+
+ if (db_exec(query) < 0) {
+ free(query);
+ return AIL_ERROR_DB_FAILED;
+ }
+
+ _D("Remove (%s).", package);
+ free(query);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+static ail_error_e _send_db_done_noti(noti_type type, const char *package)
+{
+ char *type_string, *noti_string;
+ int size;
+
+ retv_if(!package, AIL_ERROR_INVALID_PARAMETER);
+
+ switch (type) {
+ case NOTI_ADD:
+ type_string = "create";
+ break;
+ case NOTI_UPDATE:
+ type_string = "update";
+ break;
+ case NOTI_REMOVE:
+ type_string = "delete";
+ break;
+ default:
+ return AIL_ERROR_FAIL;
+ }
+
+ size = strlen(package) + 8;
+ noti_string = calloc(1, size);
+ retv_if(!noti_string, AIL_ERROR_OUT_OF_MEMORY);
+
+ snprintf(noti_string, size, "%s:%s", type_string, package);
+ vconf_set_str("memory/menuscreen/desktop", noti_string);
+ _D("Noti : %s", noti_string);
+
+ free(noti_string);
+
+ return AIL_ERROR_OK;
+}
+
+
+static void inline _name_item_free_func(gpointer data)
+{
+ struct name_item *item = (struct name_item *)data;
+ if (item){
+ SAFE_FREE(item->locale);
+ item->locale = NULL;
+ SAFE_FREE(item->name);
+ item->name = NULL;
+ }
+ SAFE_FREE(item);
+}
+
+static void _fini_desktop_info(desktop_info_s *info)
+{
+ SAFE_FREE(info->exec);
+ SAFE_FREE(info->name);
+ SAFE_FREE(info->type);
+ SAFE_FREE(info->icon);
+ SAFE_FREE(info->categories);
+ SAFE_FREE(info->version);
+ SAFE_FREE(info->mimetype);
+ SAFE_FREE(info->x_slp_service);
+ SAFE_FREE(info->x_slp_packagetype);
+ SAFE_FREE(info->x_slp_packagecategories);
+ SAFE_FREE(info->x_slp_packageid);
+ SAFE_FREE(info->x_slp_uri);
+ SAFE_FREE(info->x_slp_svc);
+ SAFE_FREE(info->x_slp_exe_path);
+ SAFE_FREE(info->x_slp_appid);
+ SAFE_FREE(info->desktop);
+ if (info->localname) {
+ g_slist_free_full(info->localname, _name_item_free_func);
+ info->localname = NULL;
+ }
+
+ return;
+}
+
+
+
+/* Public functions */
+EXPORT_API ail_error_e ail_desktop_add(const char *appid)
+{
+ desktop_info_s info = {0,};
+ ail_error_e ret;
+ int count;
+
+ retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
+
+ count = _count_all();
+ if (count <= 0) {
+ ret = _create_table();
+ if (ret != AIL_ERROR_OK) {
+ _D("Cannot create a table. Maybe there is already a table.");
+ }
+ }
+
+ ret = _init_desktop_info(&info, appid);
+ retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+
+ ret = _read_desktop_info(&info);
+ retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+
+ ret = _insert_desktop_info(&info);
+ retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+
+ ret = _send_db_done_noti(NOTI_ADD, appid);
+ retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+
+ _fini_desktop_info(&info);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+EXPORT_API ail_error_e ail_desktop_update(const char *appid)
+{
+ desktop_info_s info = {0,};
+ ail_error_e ret;
+
+ retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
+
+ ret = _init_desktop_info(&info, appid);
+ retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+
+ ret = _read_desktop_info(&info);
+ retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+
+ ret = _update_desktop_info(&info);
+ retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+
+ ret = _send_db_done_noti(NOTI_UPDATE, appid);
+ retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+
+ _fini_desktop_info(&info);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+EXPORT_API ail_error_e ail_desktop_remove(const char *appid)
+{
+ ail_error_e ret;
+
+ retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
+
+ ret = _remove_package(appid);
+ retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+
+ ret = _send_db_done_noti(NOTI_REMOVE, appid);
+ retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+
+ return AIL_ERROR_OK;
+}
+
+
+EXPORT_API ail_error_e ail_desktop_appinfo_modify_bool(const char *package,
+ const char *property,
+ bool value)
+{
+ desktop_info_s info = {0,};
+ ail_error_e ret;
+ ail_prop_bool_e prop;
+
+ retv_if(!package, AIL_ERROR_INVALID_PARAMETER);
+
+ retv_if(strcmp(property, AIL_PROP_X_SLP_INACTIVATED_BOOL),
+ AIL_ERROR_INVALID_PARAMETER);
+
+ ret = _init_desktop_info(&info, package);
+ retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+
+ ret = _modify_desktop_info_bool(&info, property, value);
+ retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+
+ ret = _update_desktop_info(&info);
+ retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+
+ ret = _send_db_done_noti(NOTI_UPDATE, package);
+ retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+
+ _fini_desktop_info(&info);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+
+// End of File
--- /dev/null
+/*
+ * ail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <glib.h>
+#include <string.h>
+#include <stdio.h>
+#include "ail.h"
+#include "ail_private.h"
+#include "ail_convert.h"
+#include "ail_sql.h"
+#include "ail_package.h"
+#include "ail_db.h"
+
+char *_get_where_clause(ail_filter_h filter);
+
+struct ail_filter {
+ GSList *list;
+};
+
+static inline void _add_cond_to_filter(ail_filter_h filter, struct element *cond)
+{
+ filter->list = g_slist_append(filter->list, cond);
+}
+
+EXPORT_API ail_error_e ail_filter_new(ail_filter_h *filter)
+{
+ struct ail_filter *f;
+
+ retv_if (NULL == filter, AIL_ERROR_INVALID_PARAMETER);
+
+ f = (struct ail_filter *)calloc(1, sizeof(struct ail_filter));
+ retv_if (NULL == f, AIL_ERROR_OUT_OF_MEMORY);
+
+ *filter = f;
+
+ return AIL_ERROR_OK;
+}
+
+static inline void _destroy_cond(gpointer data, gpointer user_data)
+{
+ if (!data)
+ return;
+
+ struct element *cond;
+ cond = (struct element *)data;
+
+ int t;
+ ELEMENT_TYPE(cond, t);
+ if (VAL_TYPE_STR == t) {
+ if(ELEMENT_STR(cond)->value)
+ free(ELEMENT_STR(cond)->value);
+ }
+ free(cond);
+ return;
+}
+
+
+EXPORT_API ail_error_e ail_filter_destroy(ail_filter_h filter)
+{
+ retv_if (NULL == filter, AIL_ERROR_INVALID_PARAMETER);
+
+ if (filter->list){
+ g_slist_foreach(filter->list, _destroy_cond, NULL);
+ g_slist_free(filter->list);
+ }
+
+ free(filter);
+
+ return AIL_ERROR_OK;
+}
+
+EXPORT_API ail_error_e ail_filter_add_bool(ail_filter_h filter, const char *property, bool value)
+{
+ struct element *c;
+ ail_prop_bool_e prop;
+
+ retv_if (NULL == filter, AIL_ERROR_INVALID_PARAMETER);
+ retv_if (NULL == property, AIL_ERROR_INVALID_PARAMETER);
+
+ prop = _ail_convert_to_prop_bool(property);
+
+ if (prop < E_AIL_PROP_BOOL_MIN || prop > E_AIL_PROP_BOOL_MAX)
+ return AIL_ERROR_INVALID_PARAMETER;
+
+ c = (struct element *)calloc(1, sizeof(struct element_bool));
+ retv_if (NULL == c, AIL_ERROR_OUT_OF_MEMORY);
+
+ ELEMENT_BOOL(c)->prop = (int)prop;
+ ELEMENT_BOOL(c)->value = value;
+
+ _add_cond_to_filter(filter, c);
+
+ return AIL_ERROR_OK;
+}
+
+EXPORT_API ail_error_e ail_filter_add_int(ail_filter_h filter, const char *property, int value)
+{
+ struct element *c;
+ ail_prop_int_e prop;
+
+ retv_if (NULL == filter, AIL_ERROR_INVALID_PARAMETER);
+ retv_if (NULL == property, AIL_ERROR_INVALID_PARAMETER);
+
+ prop = _ail_convert_to_prop_int(property);
+
+ if (prop < E_AIL_PROP_INT_MIN || prop > E_AIL_PROP_INT_MAX)
+ return AIL_ERROR_INVALID_PARAMETER;
+
+ c = (struct element *)calloc(1, sizeof(struct element_int));
+ retv_if (NULL == c, AIL_ERROR_OUT_OF_MEMORY);
+
+ ELEMENT_INT(c)->prop = (int)prop;
+ ELEMENT_INT(c)->value = value;
+
+ _add_cond_to_filter(filter, c);
+
+ return AIL_ERROR_OK;
+}
+
+EXPORT_API ail_error_e ail_filter_add_str(ail_filter_h filter, const char *property, const char *value)
+{
+ struct element *c; //condition
+ ail_prop_str_e prop;
+
+ retv_if (NULL == filter, AIL_ERROR_INVALID_PARAMETER);
+ retv_if (NULL == property, AIL_ERROR_INVALID_PARAMETER);
+
+ prop = _ail_convert_to_prop_str(property);
+
+ if (prop < E_AIL_PROP_STR_MIN || prop > E_AIL_PROP_STR_MAX)
+ return AIL_ERROR_INVALID_PARAMETER;
+
+ retv_if (NULL == value, AIL_ERROR_INVALID_PARAMETER);
+ retv_if (strlen(value) == 0, AIL_ERROR_INVALID_PARAMETER);
+
+ c = (struct element *)calloc(1, sizeof(struct element_str));
+
+ retv_if (NULL == c, AIL_ERROR_OUT_OF_MEMORY);
+
+ ELEMENT_STR(c)->prop = (int)prop;
+ ELEMENT_STR(c)->value = strdup(value);
+ if (!ELEMENT_STR(c)->value) {
+ free(c);
+ return AIL_ERROR_OUT_OF_MEMORY;
+ }
+
+ _add_cond_to_filter(filter, c);
+
+ return AIL_ERROR_OK;
+}
+
+static void _get_condition(gpointer data, char **condition)
+{
+ struct element *e = (struct element *)data;
+ const char *f;
+ char buf[AIL_SQL_QUERY_MAX_LEN];
+
+ f = sql_get_filter(e->prop);
+ int t;
+ ELEMENT_TYPE(e, t);
+
+ switch (t) {
+ case VAL_TYPE_BOOL:
+ snprintf(buf, sizeof(buf), f, ELEMENT_BOOL(e)->value);
+ break;
+ case VAL_TYPE_INT:
+ snprintf(buf, sizeof(buf), f, ELEMENT_INT(e)->value);
+ break;
+ case VAL_TYPE_STR:
+ if (E_AIL_PROP_NAME_STR == e->prop) {
+ snprintf(buf, sizeof(buf), f, ELEMENT_STR(e)->value, ELEMENT_STR(e)->value);
+ } else {
+ snprintf(buf, sizeof(buf), f, ELEMENT_STR(e)->value);
+ }
+ break;
+ default:
+ _E("Invalid property type");
+ *condition = NULL;
+ return;
+ }
+
+ *condition = strdup(buf);
+
+ return;
+}
+
+char *_get_where_clause(ail_filter_h filter)
+{
+ char *c;
+ char w[AIL_SQL_QUERY_MAX_LEN] = {0,};
+ c = NULL;
+
+ GSList *l;
+
+ snprintf(w, AIL_SQL_QUERY_MAX_LEN, " WHERE ");
+
+ for (l = filter->list; l; l = g_slist_next(l)) {
+ _get_condition(l->data, &c);
+ if (!c) return NULL;
+ if (*c == 0) {
+ free(c);
+ return NULL;
+ }
+
+ strncat(w, c, sizeof(w)-strlen(w)-1);
+ w[sizeof(w)-1] = '\0';
+ if(c) free(c);
+
+ if (g_slist_next(l)) {
+ strncat(w, " and ", sizeof(w)-strlen(w)-1);
+ w[sizeof(w)-1] = '\0';
+ }
+ }
+
+ _D("where = %s", w);
+
+ return strdup(w);
+}
+
+EXPORT_API ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *cnt)
+{
+ char q[AIL_SQL_QUERY_MAX_LEN];
+ char *w;
+ char *tmp_q;
+ char *l;
+ int r;
+ int n;
+ sqlite3_stmt *stmt;
+
+ retv_if(!cnt, AIL_ERROR_INVALID_PARAMETER);
+
+ if (db_open(DB_OPEN_RO) != AIL_ERROR_OK)
+ return AIL_ERROR_DB_FAILED;
+
+ snprintf(q, sizeof(q), "SELECT COUNT (*) FROM %s", SQL_TBL_APP_INFO_WITH_LOCALNAME);
+
+ tmp_q = strdup(q);
+ retv_if (NULL == tmp_q, AIL_ERROR_OUT_OF_MEMORY);
+ l = sql_get_locale();
+ if (NULL == l) {
+ _E("Failed to get locale string");
+ free(tmp_q);
+ return AIL_ERROR_FAIL;
+ }
+ snprintf(q, sizeof(q), tmp_q, l);
+ free(l);
+ free(tmp_q);
+
+ if (filter && filter->list) {
+ w = _get_where_clause(filter);
+ retv_if (NULL == w, AIL_ERROR_FAIL);
+ strncat(q, w, sizeof(q)-strlen(q)-1);
+ q[sizeof(q)-1] = '\0';
+ free(w);
+ }
+
+ _D("Query = %s",q);
+
+ if (db_prepare(q, &stmt) != AIL_ERROR_OK) {
+ return AIL_ERROR_DB_FAILED;
+ }
+
+ r = db_step(stmt);
+ if (r == AIL_ERROR_OK) {
+ db_column_int(stmt, 0, &n);
+ *cnt = n;
+ }
+
+ db_finalize(stmt);
+
+ return r;
+}
+
+
+
+EXPORT_API ail_error_e ail_filter_list_appinfo_foreach(ail_filter_h filter, ail_list_appinfo_cb cb, void *user_data)
+{
+ char q[AIL_SQL_QUERY_MAX_LEN];
+ char *tmp_q;
+ char *w;
+ char *l;
+ ail_cb_ret_e r;
+ sqlite3_stmt *stmt;
+ ail_appinfo_h ai;
+
+ retv_if (NULL == cb, AIL_ERROR_INVALID_PARAMETER);
+
+ if (db_open(DB_OPEN_RO) != AIL_ERROR_OK)
+ return AIL_ERROR_DB_FAILED;
+
+ snprintf(q, sizeof(q), "SELECT %s FROM %s", SQL_FLD_APP_INFO_WITH_LOCALNAME, SQL_TBL_APP_INFO_WITH_LOCALNAME);
+
+ tmp_q = strdup(q);
+ retv_if (NULL == tmp_q, AIL_ERROR_OUT_OF_MEMORY);
+ l = sql_get_locale();
+ if (NULL == l) {
+ _E("Failed to get locale string");
+ free(tmp_q);
+ return AIL_ERROR_FAIL;
+ }
+ snprintf(q, sizeof(q), tmp_q, l);
+ free(l);
+ free(tmp_q);
+
+ if (filter && filter->list) {
+ w = _get_where_clause(filter);
+ retv_if (NULL == w, AIL_ERROR_FAIL);
+ strncat(q, w, sizeof(q)-strlen(q)-1);
+ q[sizeof(q)-1] = '\0';
+ strncat(q, " order by app_info.package", sizeof(q)-strlen(q)-1);
+ q[sizeof(q)-1] = '\0';
+ free(w);
+ }
+ else
+ _D("No filter exists. All records are retreived");
+
+ _D("Query = %s",q);
+
+ if (db_prepare(q, &stmt) != AIL_ERROR_OK) {
+ return AIL_ERROR_DB_FAILED;
+ }
+
+ ai = appinfo_create();
+
+ appinfo_set_stmt(ai, stmt);
+ while (db_step(stmt) == AIL_ERROR_OK) {
+
+ r = cb(ai, user_data);
+ if (AIL_CB_RET_CANCEL == r)
+ break;
+ }
+ appinfo_destroy(ai);
+
+ db_finalize(stmt);
+
+ return AIL_ERROR_OK;
+}
+
--- /dev/null
+/*
+ * ail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <string.h>
+#include <stdlib.h>
+#include <db-util.h>
+#include <vconf.h>
+#include "ail.h"
+#include "ail_private.h"
+#include "ail_convert.h"
+#include "ail_db.h"
+#include "ail_sql.h"
+#include "ail_package.h"
+#include <assert.h>
+#include <unistd.h>
+
+#define LANGUAGE_LENGTH 2
+#define DEFAULT_LOCALE "No Locale"
+#define MAX_QUERY_LEN 4096
+
+struct ail_appinfo {
+ char **values;
+ sqlite3_stmt *stmt;
+};
+
+typedef struct _pkgmgr_locale_x {
+ char *locale;
+} pkgmgr_locale_x;
+
+
+/* get the first locale value*/
+static int __fallback_locale_cb(void *data, int ncols, char **coltxt, char **colname)
+{
+ pkgmgr_locale_x *info = (pkgmgr_locale_x *)data;
+
+ if (ncols >= 1)
+ info->locale = strdup(coltxt[0]);
+ else
+ info->locale = NULL;
+
+ return 0;
+}
+
+static int __check_validation_of_qurey_cb(void *data, int ncols, char **coltxt, char **colname)
+{
+ int *p = (int*)data;
+ *p = atoi(coltxt[0]);
+ return 0;
+}
+
+static int __check_app_locale_from_app_localized_info_by_exact(const char *appid, const char *locale)
+{
+ int result_query = -1;
+ char query[MAX_QUERY_LEN];
+
+ snprintf(query, MAX_QUERY_LEN, "select exists(select locale from localname where package='%s' and locale='%s')", appid, locale);
+ db_exec_sqlite_query(query, __check_validation_of_qurey_cb, (void *)&result_query);
+
+ return result_query;
+}
+
+static int __check_app_locale_from_app_localized_info_by_fallback(const char *appid, const char *locale)
+{
+ int result_query = -1;
+ char wildcard[2] = {'%','\0'};
+ char query[MAX_QUERY_LEN];
+ char lang[3] = {'\0'};
+ strncpy(lang, locale, LANGUAGE_LENGTH);
+
+ snprintf(query, MAX_QUERY_LEN, "select exists(select locale from localname where package='%s' and locale like '%s%s')", appid, lang, wildcard);
+ db_exec_sqlite_query(query, __check_validation_of_qurey_cb, (void *)&result_query);
+
+ return result_query;
+}
+
+static char* __get_app_locale_from_app_localized_info_by_fallback(const char *appid, const char *locale)
+{
+ char wildcard[2] = {'%','\0'};
+ char lang[3] = {'\0'};
+ char query[MAX_QUERY_LEN];
+ char *locale_new = NULL;
+ pkgmgr_locale_x *info = NULL;
+
+ info = (pkgmgr_locale_x *)malloc(sizeof(pkgmgr_locale_x));
+ if (info == NULL) {
+ _E("Out of Memory!!!\n");
+ return NULL;
+ }
+ memset(info, NULL, sizeof(*info));
+
+ strncpy(lang, locale, 2);
+ snprintf(query, MAX_QUERY_LEN, "select locale from localname where package='%s' and locale like '%s%s'", appid, lang, wildcard);
+ db_exec_sqlite_query(query, __fallback_locale_cb, (void *)info);
+ locale_new = info->locale;
+ free(info);
+
+ return locale_new;
+}
+
+static char* __convert_syslocale_to_manifest_locale(char *syslocale)
+{
+ char *locale = malloc(6);
+ if (!locale) {
+ _E("Malloc Failed\n");
+ return NULL;
+ }
+
+ sprintf(locale, "%c%c_%c%c", syslocale[0], syslocale[1], toupper(syslocale[3]), toupper(syslocale[4]));
+ return locale;
+}
+
+static char* __get_app_locale_by_fallback(const char *appid, const char *syslocale)
+{
+ assert(appid);
+ assert(syslocale);
+
+ char *locale = NULL;
+ char *locale_new = NULL;
+ int check_result = 0;
+
+ locale = __convert_syslocale_to_manifest_locale(syslocale);
+
+ /*check exact matching */
+ check_result = __check_app_locale_from_app_localized_info_by_exact(appid, locale);
+
+ /* Exact found */
+ if (check_result == 1) {
+ _D("%s find exact locale(%s)\n", appid, locale);
+ return locale;
+ }
+
+ /* fallback matching */
+ check_result = __check_app_locale_from_app_localized_info_by_fallback(appid, locale);
+ if(check_result == 1) {
+ locale_new = __get_app_locale_from_app_localized_info_by_fallback(appid, locale);
+ _D("%s found (%s) language-locale in DB by fallback!\n", appid, locale_new);
+ free(locale);
+ if (locale_new == NULL)
+ locale_new = strdup(DEFAULT_LOCALE);
+ return locale_new;
+ }
+
+ /* default locale */
+ free(locale);
+ _D("%s DEFAULT_LOCALE)\n", appid);
+ return strdup(DEFAULT_LOCALE);
+}
+
+void appinfo_set_stmt(ail_appinfo_h ai, sqlite3_stmt *stmt)
+{
+ ai->stmt = stmt;
+}
+
+ail_appinfo_h appinfo_create(void)
+{
+ ail_appinfo_h ai;
+ ai = calloc(1, sizeof(struct ail_appinfo));
+ retv_if (NULL == ai, NULL);
+ ai->stmt = NULL;
+
+ return ai;
+}
+
+void appinfo_destroy(ail_appinfo_h ai)
+{
+ if (ai)
+ free(ai);
+}
+
+
+
+static ail_error_e _retrieve_all_column(ail_appinfo_h ai)
+{
+ int i, j;
+ ail_error_e err;
+ char *col;
+
+ retv_if(!ai, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!ai->stmt, AIL_ERROR_INVALID_PARAMETER);
+
+ ai->values = calloc(NUM_OF_PROP, sizeof(char *));
+ retv_if(!ai->values, AIL_ERROR_OUT_OF_MEMORY);
+
+ for (i = 0; i < NUM_OF_PROP; i++) {
+ err = db_column_str(ai->stmt, i, &col);
+ if (AIL_ERROR_OK != err)
+ break;
+
+ if (!col) {
+ ai->values[i] = NULL;
+ } else {
+ ai->values[i] = strdup(col);
+ if (!ai->values[i]) {
+ err = AIL_ERROR_OUT_OF_MEMORY;
+ break;
+ }
+ }
+ }
+
+ if (err < 0) {
+ for (j = 0; j < i; ++j) {
+ if (ai->values[j])
+ free(ai->values[j]);
+ }
+ if (ai->values)
+ free(ai->values);
+ return err;
+ } else
+ return AIL_ERROR_OK;
+}
+
+
+EXPORT_API ail_error_e ail_package_destroy_appinfo(ail_appinfo_h ai)
+{
+ return ail_destroy_appinfo(ai);
+}
+
+EXPORT_API ail_error_e ail_destroy_appinfo(ail_appinfo_h ai)
+{
+ int i;
+
+ retv_if(!ai, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!ai->values, AIL_ERROR_INVALID_PARAMETER);
+
+ for (i = 0; i < NUM_OF_PROP; i++) {
+ if (ai->values[i]) {
+ free(ai->values[i]);
+ }
+ }
+
+ free(ai->values);
+ free(ai);
+
+ return AIL_ERROR_OK;
+}
+
+
+EXPORT_API ail_error_e ail_package_get_appinfo(const char *package, ail_appinfo_h *ai)
+{
+ return ail_get_appinfo(package, ai);
+}
+
+
+EXPORT_API ail_error_e ail_get_appinfo(const char *appid, ail_appinfo_h *ai)
+{
+ ail_error_e ret;
+ char query[AIL_SQL_QUERY_MAX_LEN];
+ sqlite3_stmt *stmt = NULL;
+ char w[AIL_SQL_QUERY_MAX_LEN];
+
+ retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!ai, AIL_ERROR_INVALID_PARAMETER);
+
+ *ai = appinfo_create();
+ retv_if(!*ai, AIL_ERROR_OUT_OF_MEMORY);
+
+ snprintf(w, sizeof(w), sql_get_filter(E_AIL_PROP_X_SLP_APPID_STR), appid);
+
+ snprintf(query, sizeof(query), "SELECT %s FROM %s WHERE %s",SQL_FLD_APP_INFO, SQL_TBL_APP_INFO, w);
+
+ do {
+ ret = db_open(DB_OPEN_RO);
+ if (ret < 0) break;
+
+ ret = db_prepare(query, &stmt);
+ if (ret < 0) break;
+
+ ret = db_step(stmt);
+ if (ret < 0) {
+ db_finalize(stmt);
+ break;
+ }
+
+ (*ai)->stmt = stmt;
+
+ ret = _retrieve_all_column(*ai);
+ if (ret < 0) {
+ db_finalize((*ai)->stmt);
+ break;
+ }
+
+ ret = db_finalize((*ai)->stmt);
+ if (ret < 0) break;
+ (*ai)->stmt = NULL;
+
+ return AIL_ERROR_OK;
+ } while(0);
+
+ appinfo_destroy(*ai);
+
+ return ret;
+}
+
+
+EXPORT_API ail_error_e ail_appinfo_get_bool(const ail_appinfo_h ai, const char *property, bool *value)
+{
+ ail_prop_bool_e prop;
+ int val;
+
+ retv_if(!ai, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!property, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+
+ prop = _ail_convert_to_prop_bool(property);
+
+ if (prop < E_AIL_PROP_BOOL_MIN || prop > E_AIL_PROP_BOOL_MAX)
+ return AIL_ERROR_INVALID_PARAMETER;
+
+ if (ai->stmt) {
+ int index;
+ index = sql_get_app_info_idx(prop);
+ if (db_column_bool(ai->stmt, index, value) < 0)
+ return AIL_ERROR_DB_FAILED;
+ } else {
+ val = atoi(ai->values[prop]);
+ *value = (val == 0? false : true);
+ }
+ return AIL_ERROR_OK;
+}
+
+
+
+EXPORT_API ail_error_e ail_appinfo_get_int(const ail_appinfo_h ai, const char *property, int *value)
+{
+ ail_prop_int_e prop;
+
+ retv_if(!ai, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!property, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+
+ prop = _ail_convert_to_prop_int(property);
+
+ if (prop < E_AIL_PROP_INT_MIN || prop > E_AIL_PROP_INT_MAX)
+ return AIL_ERROR_INVALID_PARAMETER;
+
+ if (ai->stmt) {
+ int index;
+ index = sql_get_app_info_idx(prop);
+ if (db_column_int(ai->stmt, index, value) < 0)
+ return AIL_ERROR_DB_FAILED;
+ } else
+ *value = atoi(ai->values[prop]);
+
+ return AIL_ERROR_OK;
+}
+
+#define QUERY_GET_LOCALNAME "select name from localname where package='%s' and locale='%s'"
+
+char *appinfo_get_localname(const char *package, char *locale)
+{
+ db_open(DB_OPEN_RO);
+ sqlite3_stmt *stmt;
+ char *str = NULL;
+ char *localname;
+ char query[512];
+
+ snprintf(query, sizeof(query), QUERY_GET_LOCALNAME, package, locale);
+
+ _D("Query = %s",query);
+ retv_if (db_prepare(query, &stmt) < 0, NULL);
+
+ do {
+ if (db_step(stmt) < 0)
+ break;
+ if (db_column_str(stmt, 0, &str) < 0)
+ break;
+ if (str)
+ localname = strdup(str);
+ else
+ localname = NULL;
+
+ db_finalize(stmt);
+
+ return localname;
+ } while(0);
+
+ db_finalize(stmt);
+ return NULL;
+}
+
+
+EXPORT_API ail_error_e ail_appinfo_get_str(const ail_appinfo_h ai, const char *property, char **str)
+{
+ int index;
+ char *value;
+ char *pkg;
+ char *pkg_type;
+ char *locale, *localname;
+ ail_prop_str_e prop;
+ char *locale_new;
+
+ retv_if(!ai, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!property, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!str, AIL_ERROR_INVALID_PARAMETER);
+
+ prop = _ail_convert_to_prop_str(property);
+
+ if (prop < E_AIL_PROP_STR_MIN || prop > E_AIL_PROP_STR_MAX)
+ return AIL_ERROR_INVALID_PARAMETER;
+
+ localname = NULL;
+
+ if (E_AIL_PROP_NAME_STR == prop) {
+ if (ai->stmt) {
+ if (db_column_str(ai->stmt, E_AIL_PROP_X_SLP_PACKAGETYPE_STR, &pkg_type) < 0)
+ return AIL_ERROR_DB_FAILED;
+ if(pkg_type && (strcasecmp(pkg_type, "tpk") ==0))
+ {
+ locale = sql_get_locale();
+ retv_if (NULL == locale, AIL_ERROR_FAIL);
+
+ if (db_column_str(ai->stmt, E_AIL_PROP_PACKAGE_STR, &pkg) < 0){
+ free(locale);
+ return AIL_ERROR_DB_FAILED;
+ }
+ if (pkg == NULL){
+ free(locale);
+ return AIL_ERROR_DB_FAILED;
+ }
+
+ locale_new = __get_app_locale_by_fallback(pkg, locale);
+ localname = (char *)appinfo_get_localname(pkg,locale_new);
+ free(locale);
+ free(locale_new);
+ } else {
+ if (db_column_str(ai->stmt, SQL_LOCALNAME_IDX, &localname) < 0)
+ return AIL_ERROR_DB_FAILED;
+ }
+ } else {
+ pkg_type = ai->values[E_AIL_PROP_X_SLP_PACKAGETYPE_STR];
+ pkg = ai->values[E_AIL_PROP_PACKAGE_STR];
+ retv_if (NULL == pkg, AIL_ERROR_FAIL);
+
+ locale = sql_get_locale();
+ retv_if (NULL == locale, AIL_ERROR_FAIL);
+
+ if(pkg_type && (strcasecmp(pkg_type, "tpk") ==0))
+ {
+ locale_new = __get_app_locale_by_fallback(pkg, locale);
+ localname = (char *)appinfo_get_localname(pkg,locale_new);
+ free(locale);
+ free(locale_new);
+ } else {
+ localname = (char *)appinfo_get_localname(pkg,locale);
+ free(locale);
+ }
+ }
+
+ if (localname) {
+ if (!ai->stmt) {
+ if (ai->values) {
+ if (ai->values[prop])
+ free(ai->values[prop]);
+ ai->values[prop] = localname;
+ }
+ }
+ *str = localname;
+ return AIL_ERROR_OK;
+ }
+ }
+
+ if (ai->stmt) {
+ index = sql_get_app_info_idx(prop);
+ if (db_column_str(ai->stmt, index, &value) < 0){
+ return AIL_ERROR_DB_FAILED;
+ }
+ *str = value;
+ } else
+ *str = ai->values[prop];
+
+ return AIL_ERROR_OK;
+}
+
+
+// End of file
--- /dev/null
+/*
+ * ail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 __AIL_PACKAGE_H__
+#define __AIL_PACKAGE_H__
+
+#include <sqlite3.h>
+#include "ail.h"
+
+ail_appinfo_h appinfo_create(void);
+void appinfo_destroy(ail_appinfo_h ai);
+void appinfo_set_stmt(ail_appinfo_h ai, sqlite3_stmt *stmt);
+
+#endif /* __AIL_PACKAGE_H__ */
--- /dev/null
+/*
+ * ail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 __AIL_PRIVATE_H__
+#define __AIL_PRIVATE_H__
+
+#include <stdbool.h>
+#include <sqlite3.h>
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#undef LOG_TAG
+#define LOG_TAG "AIL"
+
+#if 1
+#include <dlog.h>
+#define _E(fmt, arg...) LOGE("[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg)
+#define _D(fmt, arg...) LOGD("[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg)
+#else
+#include <stdio.h>
+#define _E(fmt, arg...) fprintf(stderr, "[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg)
+#define _D(fmt, arg...) fprintf(stderr, "[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg)
+#endif
+
+#define retv_if(expr, val) do { \
+ if(expr) { \
+ _E("(%s) -> %s() return\n", #expr, __FUNCTION__); \
+ return (val); \
+ } \
+} while (0)
+
+#define SAFE_FREE_AND_STRDUP(from, to) do { \
+ if (to) free(to); \
+ to = strdup(from); \
+} while (0)
+
+#define SAFE_FREE(ptr) do { \
+ if (ptr) free(ptr); \
+} while (0)
+
+struct element {
+ int prop;
+};
+
+struct element_int {
+ int prop;
+ int value;
+};
+
+struct element_bool {
+ int prop;
+ bool value;
+};
+
+struct element_str {
+ int prop;
+ char *value;
+};
+
+enum {
+ VAL_TYPE_BOOL,
+ VAL_TYPE_INT,
+ VAL_TYPE_STR,
+};
+
+#define ELEMENT_INT(e) ((struct element_int *)(e))
+#define ELEMENT_STR(e) ((struct element_str *)(e))
+#define ELEMENT_BOOL(e) ((struct element_bool *)(e))
+
+#define AIL_SQL_QUERY_MAX_LEN 2048
+#define APP_INFO_DB "/opt/dbspace/.app_info.db"
+
+#define ELEMENT_TYPE(e, t) do { \
+ if(e->prop >= E_AIL_PROP_STR_MIN && e->prop <= E_AIL_PROP_STR_MAX) t= (int)VAL_TYPE_STR; \
+ else if (e->prop >= E_AIL_PROP_INT_MIN && e->prop <= E_AIL_PROP_INT_MAX) t= (int)VAL_TYPE_INT; \
+ else if (e->prop >= E_AIL_PROP_BOOL_MIN && e->prop <= E_AIL_PROP_BOOL_MAX) t= (int)VAL_TYPE_BOOL; \
+ else t = -1; \
+} while(0)
+
+
+#define PROP_TYPE(p, t) do { \
+ if(p >= E_AIL_PROP_STR_MIN && p <= E_AIL_PROP_STR_MAX) t= (int)VAL_TYPE_STR; \
+ else if (p >= E_AIL_PROP_INT_MIN && p <= E_AIL_PROP_INT_MAX) t= (int)VAL_TYPE_INT; \
+ else if (p >= E_AIL_PROP_BOOL_MIN && p <= E_AIL_PROP_BOOL_MAX) t= (int)VAL_TYPE_BOOL; \
+ else t = NULL; \
+} while(0)
+
+
+/**
+ * @brief string type properties
+ */
+typedef enum {
+ E_AIL_PROP_STR_MIN = 0,
+ E_AIL_PROP_PACKAGE_STR = E_AIL_PROP_STR_MIN,
+ E_AIL_PROP_EXEC_STR,
+ E_AIL_PROP_NAME_STR,
+ E_AIL_PROP_TYPE_STR,
+ E_AIL_PROP_ICON_STR,
+ E_AIL_PROP_CATEGORIES_STR,
+ E_AIL_PROP_VERSION_STR,
+ E_AIL_PROP_MIMETYPE_STR,
+ E_AIL_PROP_X_SLP_SERVICE_STR,
+ E_AIL_PROP_X_SLP_PACKAGETYPE_STR,
+ E_AIL_PROP_X_SLP_PACKAGECATEGORIES_STR,
+ E_AIL_PROP_X_SLP_PACKAGEID_STR,
+ E_AIL_PROP_X_SLP_URI_STR,
+ E_AIL_PROP_X_SLP_SVC_STR,
+ E_AIL_PROP_X_SLP_EXE_PATH,
+ E_AIL_PROP_X_SLP_APPID_STR,
+ E_AIL_PROP_X_SLP_PKGID_STR,
+ E_AIL_PROP_X_SLP_DOMAIN_STR,
+ E_AIL_PROP_STR_MAX = E_AIL_PROP_X_SLP_DOMAIN_STR,
+} ail_prop_str_e;
+
+
+/**
+ * @brief integer type properties
+ */
+typedef enum {
+ E_AIL_PROP_INT_MIN = E_AIL_PROP_STR_MAX + 1,
+ E_AIL_PROP_X_SLP_TEMP_INT = E_AIL_PROP_INT_MIN,
+ E_AIL_PROP_X_SLP_INSTALLEDTIME_INT,
+ E_AIL_PROP_INT_MAX = E_AIL_PROP_X_SLP_INSTALLEDTIME_INT,
+} ail_prop_int_e;
+
+
+/**
+ * @brief boolean type properties
+ */
+typedef enum {
+ E_AIL_PROP_BOOL_MIN = E_AIL_PROP_INT_MAX + 1,
+ E_AIL_PROP_NODISPLAY_BOOL = E_AIL_PROP_BOOL_MIN,
+ E_AIL_PROP_X_SLP_TASKMANAGE_BOOL,
+ E_AIL_PROP_X_SLP_MULTIPLE_BOOL,
+ E_AIL_PROP_X_SLP_REMOVABLE_BOOL,
+ E_AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL,
+ E_AIL_PROP_X_SLP_INACTIVATED_BOOL,
+ E_AIL_PROP_BOOL_MAX = E_AIL_PROP_X_SLP_INACTIVATED_BOOL,
+} ail_prop_bool_e;
+
+#define NUM_OF_PROP E_AIL_PROP_BOOL_MAX + 1
+
+#endif
--- /dev/null
+/*
+ * ail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "ail.h"
+#include "ail_sql.h"
+#include "ail_db.h"
+#include "vconf.h"
+#include "ail_private.h"
+
+static const char *filter[] = {
+ "app_info.PACKAGE='%s'",
+ "app_info.EXEC='%s'",
+ "((localname.name is NULL and app_info.name like '%%%s%%') or (localname.name like '%%%s%%'))",
+ "app_info.TYPE like '%%%s%%'",
+ "app_info.ICON='%s'",
+ "app_info.CATEGORIES like '%%%s%%'",
+ "app_info.VERSION='%s'",
+ "app_info.MIMETYPE like '%%%s%%'",
+ "app_info.X_SLP_SERVICE like '%%%s%%'",
+ "app_info.X_SLP_PACKAGETYPE='%s'",
+ "app_info.X_SLP_PACKAGECATEGORIES like '%%%s%%'",
+ "app_info.X_SLP_PACKAGEID='%s'",
+ "app_info.X_SLP_URI='%s'",
+ "app_info.X_SLP_SVC like '%%%s%%'",
+ "app_info.X_SLP_EXE_PATH='%s'",
+ "app_info.X_SLP_APPID='%s'",
+ "app_info.X_SLP_PKGID='%s'",
+ "app_info.X_SLP_DOMAIN='%s'",
+ "app_info.X_SLP_BASELAYOUTWIDTH=%d",
+ "app_info.X_SLP_INSTALLEDTIME=%d",
+ "app_info.NODISPLAY=%d",
+ "app_info.X_SLP_TASKMANAGE=%d",
+ "app_info.X_SLP_MULTIPLE=%d",
+ "app_info.X_SLP_REMOVABLE=%d",
+ "app_info.X_SLP_ISHORIZONTALSCALE=%d",
+ "app_info.X_SLP_INACTIVATED=%d",
+ NULL,
+};
+
+
+inline const char *sql_get_filter(int prop)
+{
+ retv_if(prop < 0 || prop >= NUM_OF_PROP , NULL);
+ return filter[prop];
+}
+
+
+inline char *sql_get_locale(void)
+{
+ char *l;
+ char *r;
+ char buf[6];
+
+ retv_if ((l = vconf_get_str(VCONFKEY_LANGSET)) == NULL, NULL);
+ snprintf(buf, sizeof(buf), "%s", l);
+ free(l);
+
+ r = strdup(buf);
+
+ return r;
+}
+
+inline int sql_get_app_info_idx(int prop)
+{
+ return prop;
+}
+
+// End of file
--- /dev/null
+/*
+ * ail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 __AIL_SQL_H__
+#define __AIL_SQL_H__
+
+#include "ail.h"
+
+#define SQL_TBL_APP_INFO "app_info"
+#define SQL_TBL_APP_INFO_WITH_LOCALNAME "app_info LEFT OUTER JOIN localname " \
+ "ON app_info.package=localname.package " \
+ "and locale='%s'"
+
+#define SQL_FLD_APP_INFO "app_info.PACKAGE," \
+ "app_info.EXEC," \
+ "app_info.NAME," \
+ "app_info.TYPE," \
+ "app_info.ICON," \
+ "app_info.CATEGORIES," \
+ "app_info.VERSION," \
+ "app_info.MIMETYPE," \
+ "app_info.X_SLP_SERVICE," \
+ "app_info.X_SLP_PACKAGETYPE," \
+ "app_info.X_SLP_PACKAGECATEGORIES," \
+ "app_info.X_SLP_PACKAGEID," \
+ "app_info.X_SLP_URI," \
+ "app_info.X_SLP_SVC," \
+ "app_info.X_SLP_EXE_PATH," \
+ "app_info.X_SLP_APPID," \
+ "app_info.X_SLP_PKGID," \
+ "app_info.X_SLP_DOMAIN," \
+ "app_info.X_SLP_BASELAYOUTWIDTH," \
+ "app_info.X_SLP_INSTALLEDTIME," \
+ "app_info.NODISPLAY," \
+ "app_info.X_SLP_TASKMANAGE," \
+ "app_info.X_SLP_MULTIPLE," \
+ "app_info.X_SLP_REMOVABLE," \
+ "app_info.X_SLP_ISHORIZONTALSCALE," \
+ "app_info.X_SLP_INACTIVATED" \
+
+
+#define SQL_FLD_APP_INFO_WITH_LOCALNAME SQL_FLD_APP_INFO",""localname.name"
+#define SQL_LOCALNAME_IDX NUM_OF_PROP + 0
+
+const char *sql_get_filter(int prop);
+char *sql_get_locale();
+int sql_get_app_info_idx(int prop);
+
+#endif /* __AIL_SQL_H__ */