From a381d7fdb71f88b99b35218c4066ff4e4a25c256 Mon Sep 17 00:00:00 2001 From: Sehong Na Date: Sat, 31 May 2014 12:48:35 +0900 Subject: [PATCH 1/1] Initialize Tizen 2.3 --- CMakeLists.txt | 54 +++ LICENSE | 206 +++++++++ NOTICE | 3 + debian/changelog | 894 ++++++++++++++++++++++++++++++++++++++ debian/compat | 1 + debian/control | 26 ++ debian/dirs | 2 + debian/docs | 1 + debian/libslp-memo-dev.install.in | 2 + debian/libslp-memo.install.in | 3 + debian/libslp-memo.postinst | 23 + debian/rules | 118 +++++ include/db-helper.h | 73 ++++ include/db-schema.h | 40 ++ include/db.h | 48 ++ include/memo-db.h | 650 +++++++++++++++++++++++++++ include/memo-log.h | 66 +++ libslp-memo.manifest | 12 + memo.pc.in | 13 + packaging/libslp-memo.spec | 72 +++ src/db-helper.c | 305 +++++++++++++ src/db.c | 627 ++++++++++++++++++++++++++ src/memo_dbif.c | 350 +++++++++++++++ 23 files changed, 3589 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 LICENSE create mode 100644 NOTICE create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/dirs create mode 100644 debian/docs create mode 100644 debian/libslp-memo-dev.install.in create mode 100644 debian/libslp-memo.install.in create mode 100644 debian/libslp-memo.postinst create mode 100755 debian/rules create mode 100644 include/db-helper.h create mode 100644 include/db-schema.h create mode 100644 include/db.h create mode 100644 include/memo-db.h create mode 100644 include/memo-log.h create mode 100755 libslp-memo.manifest create mode 100644 memo.pc.in create mode 100755 packaging/libslp-memo.spec create mode 100644 src/db-helper.c create mode 100644 src/db.c create mode 100644 src/memo_dbif.c diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..d7923d9 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,54 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(memo C) + +#IF($ENV{ARCH} MATCHES "arm") +# MESSAGE("Architecture: $ENV{ARCH}") +# SET(ENV{PKG_CONFIG_PATH} "/usr/x1/lib/pkgconfig:/opt/x1/lib/pkgconfig") +# SET(CMAKE_C_COMPILER "arm-linux-gcc") +# SET(CMAKE_CXX_COMPILER "arm-linux-g++") +# SET(CMAKE_SKIP_BUILD_RPATH TRUE) +# SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) +# SET(CMAKE_INSTALL_RPATH "/usr/x1/lib:/opt/x1/lib") +# SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +#ENDIF($ENV{ARCH} MATCHES "arm") + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(EXEC_PREFIX "\${prefix}") +SET(LIBDIR ${LIB_INSTALL_DIR}) +SET(INCLUDEDIR "\${prefix}/include") +SET(VERSION 0.1.0) + +SET(SRCS src/db.c + src/memo_dbif.c + src/db-helper.c) + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) + +INCLUDE(FindPkgConfig) +pkg_check_modules(pkgs REQUIRED db-util dlog vconf) + +FOREACH(flag ${pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag} -Wall") +ENDFOREACH(flag) + +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden") +#SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -finstrument-functions") + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") + +ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"") +ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"") +#ADD_DEFINITIONS("-DDEBUG") + +ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS}) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION}) + +CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/memo-db.h DESTINATION include) + +#ADD_SUBDIRECTORY(test) + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..249b868 --- /dev/null +++ b/LICENSE @@ -0,0 +1,206 @@ +Flora License + +Version 1.1, April, 2013 + +http://floralicense.org/license/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and +all other entities that control, are controlled by, or are +under common control with that entity. For the purposes of +this definition, "control" means (i) the power, direct or indirect, +to cause the direction or management of such entity, +whether by contract or otherwise, or (ii) ownership of fifty percent (50%) +or more of the outstanding shares, or (iii) beneficial ownership of +such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation source, +and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, +made available under the License, as indicated by a copyright notice +that is included in or attached to the work (an example is provided +in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, +that is based on (or derived from) the Work and for which the editorial +revisions, annotations, elaborations, or other modifications represent, +as a whole, an original work of authorship. For the purposes of this License, +Derivative Works shall not include works that remain separable from, +or merely link (or bind by name) to the interfaces of, the Work and +Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original +version of the Work and any modifications or additions to that Work or +Derivative Works thereof, that is intentionally submitted to Licensor +for inclusion in the Work by the copyright owner or by an individual or +Legal Entity authorized to submit on behalf of the copyright owner. +For the purposes of this definition, "submitted" means any form of +electronic, verbal, or written communication sent to the Licensor or +its representatives, including but not limited to communication on +electronic mailing lists, source code control systems, and issue +tracking systems that are managed by, or on behalf of, the Licensor +for the purpose of discussing and improving the Work, but excluding +communication that is conspicuously marked or otherwise designated +in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +"Tizen Certified Platform" shall mean a software platform that complies +with the standards set forth in the Tizen Compliance Specification +and passes the Tizen Compliance Tests as defined from time to time +by the Tizen Technical Steering Group and certified by the Tizen +Association or its designated agent. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work +solely as incorporated into a Tizen Certified Platform, where such +license applies only to those patent claims licensable by such +Contributor that are necessarily infringed by their Contribution(s) +alone or by combination of their Contribution(s) with the Work solely +as incorporated into a Tizen Certified Platform to which such +Contribution(s) was submitted. If You institute patent litigation +against any entity (including a cross-claim or counterclaim +in a lawsuit) alleging that the Work or a Contribution incorporated +within the Work constitutes direct or contributory patent infringement, +then any patent licenses granted to You under this License for that +Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof pursuant to the copyright license +above, in any medium, with or without modifications, and in Source or +Object form, provided that You meet the following conditions: + + 1. You must give any other recipients of the Work or Derivative Works + a copy of this License; and + 2. You must cause any modified files to carry prominent notices stating + that You changed the files; and + 3. You must retain, in the Source form of any Derivative Works that + You distribute, all copyright, patent, trademark, and attribution + notices from the Source form of the Work, excluding those notices + that do not pertain to any part of the Derivative Works; and + 4. If the Work includes a "NOTICE" text file as part of its distribution, + then any Derivative Works that You distribute must include a readable + copy of the attribution notices contained within such NOTICE file, + excluding those notices that do not pertain to any part of + the Derivative Works, in at least one of the following places: + within a NOTICE text file distributed as part of the Derivative Works; + within the Source form or documentation, if provided along with the + Derivative Works; or, within a display generated by the Derivative Works, + if and wherever such third-party notices normally appear. + The contents of the NOTICE file are for informational purposes only + and do not modify the License. You may add Your own attribution notices + within Derivative Works that You distribute, alongside or as an addendum + to the NOTICE text from the Work, provided that such additional attribution + notices cannot be construed as modifying the License. You may add Your own + copyright statement to Your modifications and may provide additional or + different license terms and conditions for use, reproduction, or + distribution of Your modifications, or for any such Derivative Works + as a whole, provided Your use, reproduction, and distribution of + the Work otherwise complies with the conditions stated in this License + and your own copyright statement or terms and conditions do not conflict + the conditions stated in the License including section 3. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Flora License to your work + +To apply the Flora License to your work, attach the following +boilerplate notice, with the fields enclosed by brackets "[]" +replaced with your own identifying information. (Don't include +the brackets!) The text should be enclosed in the appropriate +comment syntax for the file format. We also recommend that a +file or class name and description of purpose be included on the +same "printed page" as the copyright notice for easier +identification within third-party archives. + + Copyright 2013 Samsung Electronics Co., Ltd + + Licensed under the Flora License, Version 1.1 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://floralicense.org/license/ + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..6e010c0 --- /dev/null +++ b/NOTICE @@ -0,0 +1,3 @@ +Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. +Except as noted, this software is licensed under Flora License, Version 1.1. +Please, see the LICENSE.Flora file for Flora License, Version 1.1 terms and conditions. diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..78e9581 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,894 @@ +libslp-memo (0.1.4-20) unstable; urgency=low + + * [Request]Modify the vconf key name and move the define to vconf-internal-keys. + * Git : slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.4-20 + + -- Wei Hua Fri, 18 May 2012 10:59:00 +0800 + +libslp-memo (0.1.4-19) unstable; urgency=low + + * [Request]Replace heynoti with vconf due to the insecurity of heynoti. + * Git : slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.4-19 + + -- Canjiang Lu Sat, 14 Jan 2012 11:37:21 +0800 + +libslp-memo (0.1.4-18) unstable; urgency=low + + * upload + * Git : slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.4-18 + + -- Canjiang Lu Mon, 05 Dec 2011 11:38:13 +0800 + +libslp-memo (0.1.4-17) unstable; urgency=low + + * assume id of inserted record is max_rowid+1 is not legal, sqlite3_last_insert_rowid is safe + * Git : git@git_server:slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.4-17 + + -- Canjiang Lu Fri, 25 Nov 2011 14:22:33 +0800 + +libslp-memo (0.1.4-16) unstable; urgency=low + + * records synchronized from KIES may have no font info, add font_respect field to distinguish and install default font size/color to those records in that case + * Git : git@git_server:slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.4-16 + + -- Canjiang Lu Sat, 19 Nov 2011 10:32:50 +0800 + +libslp-memo (0.1.4-15) unstable; urgency=low + + * [fix bug]H0100135596, set default font size as 44 + * Git : git@git_server:slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.4-15 + + -- Canjiang Lu Sat, 22 Oct 2011 13:29:24 +0800 + +libslp-memo (0.1.4-14) unstable; urgency=low + + * copyright update + * Git : git@git_server:slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.4-14 + + -- Canjiang Lu Wed, 19 Oct 2011 14:37:11 +0800 + +libslp-memo (0.1.4-13) unstable; urgency=low + + * unused postinst script + * Git : git@git_server:slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.4-13 + + -- Canjiang Lu Tue, 20 Sep 2011 15:22:08 +0800 + +libslp-memo (0.1.4-12) unstable; urgency=low + + * package size optimize + * Git : git@git_server:slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.4-12 + + -- Canjiang Lu Tue, 20 Sep 2011 09:00:09 +0800 + +libslp-memo (0.1.4-11) unstable; urgency=low + + * it's illegal to retrieve deleted data + * Git : git@git_server:slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.4-11 + + -- Canjiang Lu Tue, 06 Sep 2011 10:47:08 +0800 + +libslp-memo (0.1.4-10) unstable; urgency=low + + * upload + * Git : git@git_server:slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.4-10 + + -- Canjiang Lu Fri, 19 Aug 2011 13:55:24 +0800 + +libslp-memo (0.1.4-9) unstable; urgency=low + + * replace strcat with strncat + * Git : git@git_server:slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.4-9 + + -- Canjiang Lu Tue, 16 Aug 2011 14:33:49 +0800 + +libslp-memo (0.1.4-8) unstable; urgency=low + + * fix prevent issues + * Git : git@git_server:slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.4-8 + + -- Canjiang Lu Tue, 16 Aug 2011 11:02:59 +0800 + +libslp-memo (0.1.4-7) unstable; urgency=low + + * fix prevent issue and set default sort type as descend + * Git : git@git_server:slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.4-7 + + -- Canjiang Lu Tue, 26 Jul 2011 14:01:52 +0800 + +libslp-memo (0.1.4-6) unstable; urgency=low + + * upload + * Git : git@git_server:slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.4-6 + + -- Canjiang Lu Thu, 21 Jul 2011 10:47:01 +0800 + +libslp-memo (0.1.4-5) unstable; urgency=low + + * upload + * Git : git@git_server:slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.4-5 + + -- Canjiang Lu Wed, 20 Jul 2011 10:03:35 +0800 + +libslp-memo (0.1.4-4) unstable; urgency=low + + * add all data iterator + * Git : git@git_server:slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.4-4 + + -- Canjiang Lu Fri, 15 Jul 2011 10:39:52 +0800 + +libslp-memo (0.1.4-3) unstable; urgency=low + + * upload + * Git : git@git_server:slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.4-3 + + -- Canjiang Lu Wed, 13 Jul 2011 08:58:50 +0800 + +libslp-memo (0.1.4-2) unstable; urgency=low + + * add search function + * Git : git@git_server:slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.4-2 + + -- Canjiang Lu Mon, 11 Jul 2011 15:55:47 +0800 + +libslp-memo (0.1.4-1) unstable; urgency=low + + * add API prototype for smart search + * Git : git@git_server:slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.4-1 + + -- Canjiang Lu Mon, 11 Jul 2011 14:04:03 +0800 + +libslp-memo (0.1.4-0) unstable; urgency=low + + * fix svace issues + * Git : git@git_server:slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.4-0 + + -- Canjiang Lu Tue, 28 Jun 2011 15:22:40 +0800 + +libslp-memo (0.1.3-99) unstable; urgency=low + + * insert comment when add new record + * Git : git@git_server:slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.3-99 + + -- Canjiang Lu Wed, 15 Jun 2011 14:52:11 +0800 + +libslp-memo (0.1.3-98) unstable; urgency=low + + * upload + * Git : git@git_server:slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.3-98 + + -- Canjiang Lu Thu, 19 May 2011 15:10:05 +0800 + +libslp-memo (0.1.3-97) unstable; urgency=low + + * upload + * Git : git@git_server:slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.3-97 + + -- Canjiang Lu Thu, 12 May 2011 08:35:33 +0800 + +libslp-memo (0.1.3-96) unstable; urgency=low + + * upload + * Git : git_server:slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.3-96 + + -- Canjiang Lu Wed, 20 Apr 2011 14:09:33 +0800 + +libslp-memo (0.1.3-95) unstable; urgency=low + + * single instance of db + * Git : git_server:slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.3-95 + + -- Canjiang Lu Tue, 19 Apr 2011 09:12:47 +0800 + +libslp-memo (0.1.3-94) unstable; urgency=low + + * upload + * Git : 165.213.180.234:slp/apps/l/libslp-memo + * Tag : libslp-memo_0.1.3-94 + + -- canjiang lu Tue, 12 Apr 2011 16:30:54 +0800 + +libslp-memo (0.1.3-93) unstable; urgency=low + + * upload + * Git: git@165.213.180.234:slp/apps/l/libslp-memo.git + * Tag: libslp-memo_0.1.3-93 + + -- Yang Qing Mon, 21 Mar 2011 11:14:42 +0800 + +libslp-memo (0.1.3-92) unstable; urgency=low + + * upload + * Git: git@165.213.180.234:slp/apps/l/libslp-memo.git + * Tag: libslp-memo_0.1.3-92 + + -- Yang Qing Tue, 01 Mar 2011 09:35:30 +0800 + +libslp-memo (0.1.3-91) unstable; urgency=low + + * Modify for prevent testing. + * Git: git@165.213.180.234:slp/apps/l/libslp-memo.git + * Tag: libslp-memo_0.1.3-91 + + -- Yang Qing Sat, 12 Feb 2011 09:07:21 +0800 + +libslp-memo (0.1.3-90) unstable; urgency=low + + * modify direcotries construct and files permission + * Git: git@165.213.180.234:slp/apps/l/libslp-memo.git + * Tag: libslp-memo_0.1.3-90 + + -- Yang Qing Wed, 09 Feb 2011 14:28:21 +0800 + +libslp-memo (0.1.3-89) unstable; urgency=low + + * fix a bug about quotes + * Git: git@165.213.180.234:slp/apps/l/libslp-memo.git + * Tag: libslp-memo_0.1.3-89 + + -- Yang Qing Sun, 06 Feb 2011 13:52:29 +0800 + +libslp-memo (0.1.3-88) unstable; urgency=low + + * upload + * Git: git@git_server:slp/apps/l/libslp-memo + * Tag: libslp-memo_0.1.3-88 + + -- Canjiang Lu Tue, 01 Feb 2011 15:22:22 +0800 + +libslp-memo (0.1.3-87) unstable; urgency=low + + * upload + * Git: git@git_server:slp/apps/l/libslp-memo + * Tag: libslp-memo_0.1.3-87 + + -- Canjiang Lu Thu, 27 Jan 2011 09:47:15 +0800 + +libslp-memo (0.1.3-86) unstable; urgency=low + + * upload + * Git: git@git_server:slp/apps/l/libslp-memo + * Tag: libslp-memo_0.1.3-86 + + -- Canjiang Lu Mon, 24 Jan 2011 10:32:18 +0800 + +libslp-memo (0.1.3-85) unstable; urgency=low + + * upload + * Git: git@git_server:slp/apps/l/libslp-memo + * Tag: libslp-memo_0.1.3-85 + + -- Canjiang Lu Sun, 23 Jan 2011 15:12:14 +0800 + +libslp-memo (0.1.3-84) unstable; urgency=low + + * upload + * Git: git@git_server:slp/apps/l/libslp-memo + * Tag: libslp-memo_0.1.3-84 + + -- Canjiang Lu Sat, 22 Jan 2011 17:12:38 +0800 + +libslp-memo (0.1.3-83) unstable; urgency=low + + * upload + * Git: git@git_server:slp/apps/l/libslp-memo + * Tag: libslp-memo_0.1.3-83 + + -- Canjiang Lu Thu, 20 Jan 2011 13:11:28 +0800 + +libslp-memo (0.1.3-82) unstable; urgency=low + + * upload + * Git: git@git_server:slp/apps/l/libslp-memo + * Tag: libslp-memo_0.1.3-82 + + -- Canjiang Lu Wed, 19 Jan 2011 14:55:44 +0800 + +libslp-memo (0.1.3-81) unstable; urgency=low + + * upload + * Git: git@git_server:slp/apps/l/libslp-memo + * Tag: libslp-memo_0.1.3-81 + + -- Canjiang Lu Wed, 19 Jan 2011 14:35:29 +0800 + +libslp-memo (0.1.3-80) unstable; urgency=low + + * save doodle_path in db + * Git: git@165.213.180.234:slp/apps/l/libslp-memo.git + * Tag: libslp-memo_0.1.3-80 + + -- Yang Qing Tue, 18 Jan 2011 09:53:50 +0800 + +libslp-memo (0.1.3-79) unstable; urgency=low + + * upload + * Git: git@git_server:slp/apps/l/libslp-memo + * Tag: libslp-memo_0.1.3-79 + + -- Canjiang Lu Mon, 17 Jan 2011 08:56:39 +0800 + +libslp-memo (0.1.3-78) unstable; urgency=low + + * upload + * Git: git@git_server:slp/apps/l/libslp-memo + * Tag: libslp-memo_0.1.3-78 + + -- Canjiang Lu Fri, 14 Jan 2011 13:47:24 +0800 + +libslp-memo (0.1.3-77) unstable; urgency=low + + * upload + * Git: git@git_server:slp/apps/l/libslp-memo + * Tag: libslp-memo_0.1.3-77 + + -- Canjiang Lu Thu, 13 Jan 2011 09:48:36 +0800 + +libslp-memo (0.1.3-76) unstable; urgency=low + + * upload + * Git: git@git_server:slp/apps/l/libslp-memo + * Tag: libslp-memo_0.1.3-76 + + -- Canjiang Lu Tue, 11 Jan 2011 14:39:49 +0800 + +libslp-memo (0.1.3-75) unstable; urgency=low + + * upload + * Git: git@git_server:slp/apps/l/libslp-memo + * Tag: libslp-memo_0.1.3-75 + + -- Canjiang Lu Mon, 10 Jan 2011 10:31:57 +0800 + +libslp-memo (0.1.3-74) unstable; urgency=low + + * upload + * Git: git@git_server:slp/apps/l/libslp-memo + * Tag: libslp-memo_0.1.3-74 + + -- Canjiang Lu Sat, 08 Jan 2011 14:11:50 +0800 + +libslp-memo (0.1.3-73) unstable; urgency=low + + * upload + * Git: git@git_server:slp/apps/l/libslp-memo + * Tag: libslp-memo_0.1.3-73 + + -- Canjiang Lu Sat, 08 Jan 2011 11:19:30 +0800 + +libslp-memo (0.1.3-72) unstable; urgency=low + + * upload + * Git: git@git_server:slp/apps/l/libslp-memo + * Tag: libslp-memo_0.1.3-72 + + -- Canjiang Lu Fri, 07 Jan 2011 16:38:35 +0800 + +libslp-memo (0.1.3-71) unstable; urgency=low + + * upload + * Git: 165.213.180.234:slp/apps/l/libslp-memo + * Tag: libslp-memo_0.1.3-71 + + -- Canjiang Lu Wed, 15 Dec 2010 09:07:18 +0800 + +libslp-memo (0.1.3-70) unstable; urgency=low + + * upload + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-70 + + -- Canjiang Lu Mon, 29 Nov 2010 13:58:58 +0800 + +libslp-memo (0.1.3-69) unstable; urgency=low + + * add as-needed to LDFLAG + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-69 + + -- Canjiang Lu Wed, 17 Nov 2010 14:44:32 +0800 + +libslp-memo (0.1.3-68) unstable; urgency=low + + * begin/end sync api policy updated + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-68 + + -- Canjiang Lu Mon, 15 Nov 2010 10:56:33 +0800 + +libslp-memo (0.1.3-67) unstable; urgency=low + + * add sync begin/end API + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-67 + + -- Canjiang Lu Thu, 11 Nov 2010 13:46:10 +0800 + +libslp-memo (0.1.3-66) unstable; urgency=low + + * enable debug package + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-66 + + -- Canjiang Lu Thu, 11 Nov 2010 09:03:20 +0800 + +libslp-memo (0.1.3-65) unstable; urgency=low + + * add api to force change callback; remove change callback in delete api + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-65 + + -- Canjiang Lu Mon, 08 Nov 2010 11:15:07 +0800 + +libslp-memo (0.1.3-64) unstable; urgency=low + + * enable callback function by heynoti_attach_handler + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-64 + + -- Canjiang Lu Tue, 02 Nov 2010 10:39:51 +0800 + +libslp-memo (0.1.3-63) unstable; urgency=low + + * add api description of memo_subscribe_change/memo_unsubscribe_change + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-63 + + -- Canjiang Lu Wed, 27 Oct 2010 13:28:06 +0800 + +libslp-memo (0.1.3-62) unstable; urgency=low + + * add subscribe/unsubscribe api for sync team + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-62 + + -- Canjiang Lu Mon, 25 Oct 2010 10:22:24 +0800 + +libslp-memo (0.1.3-61) unstable; urgency=low + + * do not generate api docs + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-61 + + -- Canjiang Lu Thu, 21 Oct 2010 14:16:26 +0800 + +libslp-memo (0.1.3-60) unstable; urgency=low + + * Lucene releated for smartsearch + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-60 + + -- Canjiang Lu Mon, 11 Oct 2010 15:27:09 +0800 + +libslp-memo (0.1.3-59) unstable; urgency=low + + * upload + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-59 + + -- Canjiang Lu Wed, 29 Sep 2010 11:10:57 +0800 + +libslp-memo (0.1.3-58) unstable; urgency=low + + * query modification after a specified time + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-58 + + -- Canjiang Lu Sun, 26 Sep 2010 10:44:11 +0800 + +libslp-memo (0.1.3-57) unstable; urgency=low + + * notify external module when memo db changed + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-57 + + -- Canjiang Lu Tue, 21 Sep 2010 08:47:56 +0800 + +libslp-memo (0.1.3-56) unstable; urgency=low + + * upload + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-56 + + -- Canjiang Lu Fri, 17 Sep 2010 08:08:20 +0800 + +libslp-memo (0.1.3-55) unstable; urgency=low + + * add api description in memo-db.h + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-55 + + -- Canjiang Lu Thu, 16 Sep 2010 14:57:16 +0800 + +libslp-memo (0.1.3-54) unstable; urgency=low + + * upload + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-54 + + -- Canjiang Lu Thu, 16 Sep 2010 08:40:50 +0800 + +libslp-memo (0.1.3-53) unstable; urgency=low + + * upload + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-53 + + -- X536 Gong Wed, 15 Sep 2010 17:01:08 +0800 + +libslp-memo (0.1.3-52) unstable; urgency=low + + * optimize memo-db.h + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-52 + + -- Canjiang Lu Wed, 15 Sep 2010 16:28:58 +0800 + +libslp-memo (0.1.3-51) unstable; urgency=low + + * extend record of memo + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-51 + + -- Canjiang Lu Wed, 15 Sep 2010 13:36:57 +0800 + +libslp-memo (0.1.3-50) unstable; urgency=low + + * upload + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-50 + + -- Canjiang Lu Tue, 14 Sep 2010 16:49:31 +0800 + +libslp-memo (0.1.3-49) unstable; urgency=low + + * upload + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-49 + + -- Canjiang Lu Mon, 13 Sep 2010 17:03:32 +0800 + +libslp-memo (0.1.3-48) unstable; urgency=low + + * upload + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-48 + + -- Canjiang Lu Sat, 11 Sep 2010 10:04:49 +0800 + +libslp-memo (0.1.3-47) unstable; urgency=low + + * remove sync db dependency + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-47 + + -- Canjiang Lu Thu, 02 Sep 2010 14:54:15 +0800 + +libslp-memo (0.1.3-46) unstable; urgency=low + + * remove doodle when delete data + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-46 + + -- Canjiang Lu Thu, 02 Sep 2010 11:07:24 +0800 + +libslp-memo (0.1.3-45) unstable; urgency=low + + * remove open source dependency + * Git: 165.213.180.234:/git/slp/apps/libslp-memo/ + * Tag: libslp-memo_0.1.3-45 + + -- Canjiang Lu Sat, 28 Aug 2010 11:36:01 +0800 + +libslp-memo (0.1.3-44) unstable; urgency=low + + * Fix bug of make dummy memo data + * Git: 165.213.180.234:/git/slp/apps/libslp-memo + * Tag: libslp-memo_0.1.3-44 + + -- Yang Qing Tue, 03 Aug 2010 13:02:34 +0800 + +libslp-memo (0.1.3-43) unstable; urgency=low + + * Fix build error + * Git: 165.213.180.234:/git/slp/apps/libslp-memo + * Tag: libslp-memo_0.1.3-43 + + -- Zhibin Zhou Sat, 31 Jul 2010 11:28:13 +0800 + +libslp-memo (0.1.3-42) unstable; urgency=low + + * Update DAC policy + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-memo-0 + * Tag: libslp-memo_0.1.3-42 + + -- Zhibin Zhou Sat, 24 Jul 2010 10:15:25 +0800 + +libslp-memo (0.1.3-41) unstable; urgency=low + + * re-upload + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-memo-0 + * Tag: libslp-memo_0.1.3-41 + + -- Newton Lee Thu, 15 Jul 2010 11:28:52 +0900 + +libslp-memo (0.1.3-40) unstable; urgency=low + + * repackage + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-memo-0 + * Tag: libslp-memo_0.1.3-40 + + -- Canjiang Lu Wed, 30 Jun 2010 05:33:28 +0800 + +libslp-memo (0.1.3-39) unstable; urgency=low + + * repackage for dlog update + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-memo-0 + * Tag: libslp-memo_0.1.3-39 + + -- Canjiang Lu Wed, 16 Jun 2010 04:21:49 +0800 + +libslp-memo (0.1.3-38) unstable; urgency=low + + * Add .memo.db-journal file + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-memo-0 + * Tag: libslp-memo_0.1.3-38 + + -- Zhou Zhibin Tue, 15 Jun 2010 11:40:15 +0800 + +libslp-memo (0.1.3-37) unstable; urgency=low + + * Change to new dlog API + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-memo-0 + * Tag: libslp-memo_0.1.3-37 + + -- Zhou Zhibin Mon, 14 Jun 2010 16:22:58 +0800 + +libslp-memo (0.1.3-36) unstable; urgency=low + + * Change to new dlog API + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-memo-0 + * Tag: libslp-memo_0.1.3-36 + + -- Zhou Zhibin Sat, 12 Jun 2010 16:27:47 +0800 + +libslp-memo (0.1.3-35) unstable; urgency=low + + * Add owner and permission control for .memo.db-journal + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-memo-0 + * Tag: libslp-memo_0.1.3-35 + + -- Zhou Zhibin Wed, 09 Jun 2010 09:17:28 +0800 + +libslp-memo (0.1.3-34) unstable; urgency=low + + * Update changlog + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-memo-0 + * Tag: libslp-memo_0.1.3-34 + + -- Zhou Zhibin Fri, 21 May 2010 09:41:33 +0800 + +libslp-memo (0.1.3-33) unstable; urgency=low + + * Remove DAC for .so + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-memo-0 + * Tag: libslp-memo_0.1.3-32 + + -- Zhou Zhibin Thu, 20 May 2010 14:11:54 +0800 + +libslp-memo (0.1.3-32) unstable; urgency=low + + * Update maintainer in control + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-memo-0 + * Tag: libslp-memo_0.1.3-32 + + -- Canjiang Lu Thu, 20 May 2010 11:06:42 +0800 + +libslp-memo (0.1.3-31) unstable; urgency=low + + * Apply security policy to direcotry /opt/dbspace + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-memo-0 + * Tag: libslp-memo_0.1.3-31 + + -- Canjiang Lu Mon, 17 May 2010 09:17:24 +0800 + +libslp-memo (0.1.3-30) unstable; urgency=low + + * Apply security policy + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-memo-0 + * Tag: libslp-memo_0.1.3-30 + + -- Canjiang Lu Wed, 12 May 2010 10:26:17 +0800 + +libslp-memo (0.1.3-29) unstable; urgency=low + + * Remove GetTimeZone function + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-memo-0 + * Tag: libslp-memo_0.1.3-29 + + -- Zhibin Zhou Mon, 19 Apr 2010 13:37:08 +0800 + +libslp-memo (0.1.3-28) unstable; urgency=low + + * Update version + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-memo-0 + * Tag: libslp-memo_0.1.3-28 + + -- Zhibin Zhou Fri, 16 Apr 2010 17:39:48 +0800 + +libslp-memo (0.1.3-21) unstable; urgency=low + + * Change file permission and owner for DAC + * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-memo-0 + * Tag: libslp-memo_0.1.3-21 + + -- Zhibin Zhou Fri, 16 Apr 2010 11:30:00 +0800 + +libslp-memo (0.1.3-20) unstable; urgency=low + + * Modify list order (Lastest memo will be listed on top) + * Add new API : memo_create_data_ex() + + -- Jae-Yong Lee Tue, 30 Mar 2010 17:43:03 +0900 + +libslp-memo (0.1.3-19) unstable; urgency=low + + * Upload tag: Toolchain Upgrade + + -- Jae-Yong Lee Thu, 25 Mar 2010 14:28:56 +0900 + +libslp-memo (0.1.3-18) unstable; urgency=low + + * Modify reference count for multiple db open/close + + -- Jae-Yong Lee Mon, 22 Mar 2010 17:20:21 +0900 + +libslp-memo (0.1.3-17) unstable; urgency=low + + * Modify error handling code (Requested by App-fwk) + + -- Jae-Yong Lee Tue, 16 Mar 2010 14:18:24 +0900 + +libslp-memo (0.1.3-16) unstable; urgency=low + + * Modify sync-db code (Requested by App-fwk) + * Add API for test data (Requested by test team) + + -- Jae-Yong Lee Thu, 11 Mar 2010 11:28:20 +0900 + +libslp-memo (0.1.3-15) unstable; urgency=low + + * fix include package + + -- Jae-Yong Lee Wed, 03 Mar 2010 13:56:27 +0900 + +libslp-memo (0.1.3-14) unstable; urgency=low + + * fix possible bug (DB finalization) + + -- Jae-Yong Lee Wed, 03 Mar 2010 11:33:04 +0900 + +libslp-memo (0.1.3-13) unstable; urgency=low + + * Apply Sync-db + * fix header overite problem + + -- Jae-Yong Lee Tue, 23 Feb 2010 19:01:36 +0900 + +libslp-memo (0.1.3-12) unstable; urgency=low + + * remove dependency for libslp-memo-include-dev + + -- Jae-Yong Lee Tue, 23 Feb 2010 16:26:09 +0900 + +libslp-memo (0.1.3-11) unstable; urgency=low + + * add header file package "libslp-memo-include-dev" for sync-db + + -- Jae-Yong Lee Tue, 23 Feb 2010 14:59:06 +0900 + +libslp-memo (0.1.3-10) unstable; urgency=low + + * fix duplicated db file + + -- Jae-Yong Lee Fri, 19 Feb 2010 20:32:53 +0900 + +libslp-memo (0.1.3-9) unstable; urgency=low + + * Apply db-util + + -- Jae-Yong Lee Fri, 19 Feb 2010 13:52:09 +0900 + +libslp-memo (0.1.3-8) unstable; urgency=low + + * Add APIs + - struct memo_data* memo_get_latest_data(void) + - int memo_get_count(int *count) + + -- Jae-Yong Lee Tue, 09 Feb 2010 09:16:20 +0900 + +libslp-memo (0.1.3-7) unstable; urgency=low + + * Remove prefix SLP + + -- Jae-Yong Lee Wed, 27 Jan 2010 13:58:32 +0900 + +libslp-memo (0.1.3-6) unstable; urgency=low + + * Add color column to db + + -- Jae-Yong Lee Wed, 13 Jan 2010 16:14:45 +0900 + +libslp-memo (0.1.3-4) unstable; urgency=low + + * Modified control maintainer + + -- Jaeyong Lee Tue, 12 Jan 2010 18:15:03 +0900 + +libslp-memo (0.1.3-3) unstable; urgency=low + + * Change prefix to SLP + + -- Byeongha Cho Fri, 20 Nov 2009 19:53:22 +0900 + +libslp-memo (0.1.3-2) unstable; urgency=low + + * Fill missing item in changelog + + -- Byeongha Cho Tue, 17 Nov 2009 16:40:54 +0900 + +libslp-memo (0.1.3-1) unstable; urgency=low + + * Update copyright + + -- Byeongha Cho Tue, 17 Nov 2009 15:46:54 +0900 + +libslp-memo (0.1.3) unstable; urgency=low + + * Change dependancy list + + -- Byeongha Cho Tue, 17 Nov 2009 15:44:54 +0900 + +libslp-memo (0.1.2) unstable; urgency=low + + * add pkgconfig file + + -- Byeongha Cho Fri, 13 Nov 2009 22:28:00 +0900 + +libslp-memo (0.1.1) unstable; urgency=low + + * Correcting dependancy error + + -- Byeongha Cho Fri, 13 Nov 2009 15:22:03 +0900 + +libslp-memo (0.1.0) unstable; urgency=low + + * Initial Release. + + -- Byeongha Cho Thu, 12 Nov 2009 14:18:02 +0900 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..2497a04 --- /dev/null +++ b/debian/control @@ -0,0 +1,26 @@ +Source: libslp-memo +Section: libs +Priority: extra +Maintainer: Zhou Zhibin , Lu Canjiang , Feng Li , Wei Hua +Build-Depends: debhelper (>= 5), libslp-db-util-dev, dlog-dev, libheynoti-dev, libvconf-dev +Standards-Version: 0.1.0 + +Package: libslp-memo-dev +Section: libs +Architecture: any +XB-Generate-Docs: no +XB-Public-Package: no +Depends: libslp-memo (= ${Source-Version}), dlog-dev +Description: library for memo(development package) + +Package: libslp-memo +Section: libs +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: library for memo + +Package: libslp-memo-dbg +Section: libs +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: library for memo diff --git a/debian/dirs b/debian/dirs new file mode 100644 index 0000000..ca882bb --- /dev/null +++ b/debian/dirs @@ -0,0 +1,2 @@ +usr/bin +usr/sbin diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..a0f0008 --- /dev/null +++ b/debian/docs @@ -0,0 +1 @@ +CMakeLists.txt diff --git a/debian/libslp-memo-dev.install.in b/debian/libslp-memo-dev.install.in new file mode 100644 index 0000000..f22d428 --- /dev/null +++ b/debian/libslp-memo-dev.install.in @@ -0,0 +1,2 @@ +@PREFIX@/lib/pkgconfig/* +@PREFIX@/include/*.h diff --git a/debian/libslp-memo.install.in b/debian/libslp-memo.install.in new file mode 100644 index 0000000..39ed062 --- /dev/null +++ b/debian/libslp-memo.install.in @@ -0,0 +1,3 @@ +@PREFIX@/lib/*.so* +/opt/data/ + diff --git a/debian/libslp-memo.postinst b/debian/libslp-memo.postinst new file mode 100644 index 0000000..0deccbb --- /dev/null +++ b/debian/libslp-memo.postinst @@ -0,0 +1,23 @@ +#!/bin/sh + +#add db +sqlite3 /opt/dbspace/.memo.db 'PRAGMA journal_mode = PERSIST; +CREATE TABLE if not exists memo ( id INTEGER PRIMARY KEY autoincrement, content TEXT, written_time TEXT, create_time INTEGER, modi_time INTEGER, delete_time INTEGER, doodle INTEGER, color INTEGER, comment TEXT, favorite INTEGER, font_respect INTEGER, font_size INTEGER, font_color INTEGER, doodle_path TEXT ); + ' + +if [ ${USER} = "root" ] +then + vconftool set -t int db/memo/data-change 0 -g 5000 +# Change file owner + chown :6009 /opt/dbspace/.memo.db + chown :6009 /opt/dbspace/.memo.db-journal + chown :6009 /opt/data/libslp-memo/.LIBSLP_MEMO_DB_CHANGED +else + vconftool set -t int db/memo/data-change 0 +fi +# Change file permissions + + chmod 660 /opt/dbspace/.memo.db + chmod 660 /opt/dbspace/.memo.db-journal + chmod 660 /opt/data/libslp-memo/.LIBSLP_MEMO_DB_CHANGED + diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..ab97137 --- /dev/null +++ b/debian/rules @@ -0,0 +1,118 @@ +#!/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 + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif + +LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed -Wl,--hash-style=both + +configure: configure-stamp +configure-stamp: + dh_testdir + # Add here commands to configure the package. + CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" cmake . -DCMAKE_INSTALL_PREFIX=$(PREFIX) + + touch configure-stamp + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + + # Add here commands to compile the package. + $(MAKE) + #docbook-to-man debian/wavplayer.sgml > wavplayer.1 + + 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 build-stamp configure-stamp + + # Add here commands to clean up after the build process. + -$(MAKE) clean + rm -rf CMakeCache.txt + rm -rf CMakeFiles + rm -rf cmake_install.cmake + rm -rf Makefile + rm -rf install_manifest.txt + rm -rf libmemo.so* + rm -rf memo.pc + + 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. + $(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 --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 --dbg-package=libslp-memo-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 diff --git a/include/db-helper.h b/include/db-helper.h new file mode 100644 index 0000000..210a5bb --- /dev/null +++ b/include/db-helper.h @@ -0,0 +1,73 @@ +/* +* +* Copyright 2012 Samsung Electronics Co., Ltd +* +* Licensed under the Flora License, Version 1.1 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://floralicense.org/license/ +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +#ifndef __MEMO_DB_HELPER_H__ +#define __MEMO_DB_HELPER_H__ + +#define MEMO_DB_MAX_CONTENT_LEN 1500 + +#define KEY_ID_NAME "id" + +enum key_public_t +{ + KEY_INPUT_END = -1, + + /* common */ + KEY_ITEM_MODE, /* 0-text, 1-doodle */ + KEY_FAVORITE, + KEY_COLOR, + + /* about text */ + KEY_CONTENT, + KEY_FONT_RESPECT, + KEY_FONT_SIZE, + KEY_FONT_COLOR, + + /* about doodle */ + KEY_COMMENT, + KEY_DOODLE_PATH, + + END_KEY_PUBLIC, +}; + +enum key_private_t +{ + KEY_CREATE_TIME = END_KEY_PUBLIC, + KEY_MODI_TIME, + KEY_DELETE_TIME, + KEY_WRITTEN_TIME, + + END_KEY_PRIVATE, + TOTAL_NUM_OF_KEYS = END_KEY_PRIVATE, +}; + +struct column_t +{ + char *name; + char *type; +}; + +char *db_content_truncate(char *content); + +char *db_make_insert_query(int key1, void *val1, ...); +char *db_make_update_query(int id, int key1, void *val1, ...); +char *db_make_delete_query(int id); +char *db_make_string_constant(const char *input); + +#endif /* __MEMO_DB_HELPER_H__ */ + diff --git a/include/db-schema.h b/include/db-schema.h new file mode 100644 index 0000000..bb09112 --- /dev/null +++ b/include/db-schema.h @@ -0,0 +1,40 @@ +/* +* +* Copyright 2012 Samsung Electronics Co., Ltd +* +* Licensed under the Flora License, Version 1.1 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://floralicense.org/license/ +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +#ifndef __MEMO_SCHEMA_H__ +#define __MEMO_SCHEMA_H__ + +#define CREATE_MEMO_TABLE " \ +create table if not exists memo ( \ +id INTEGER PRIMARY KEY autoincrement, \ +content TEXT, \ +written_time TEXT, \ +create_time INTEGER, \ +modi_time INTEGER, \ +delete_time INTEGER, \ +doodle INTEGER, \ +color INTEGER, \ +comment TEXT, \ +favorite INTEGER, \ +font_respect INTEGER, \ +font_size INTEGER, \ +font_color INTEGER, \ +doodle_path TEXT \ +)" + +#endif /* __MEMO_SCHEMA_H__ */ diff --git a/include/db.h b/include/db.h new file mode 100644 index 0000000..402af7a --- /dev/null +++ b/include/db.h @@ -0,0 +1,48 @@ +/* +* +* Copyright 2012 Samsung Electronics Co., Ltd +* +* Licensed under the Flora License, Version 1.1 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://floralicense.org/license/ +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +#ifndef __LIBSLP_MEMO_DB_H__ +#define __LIBSLP_MEMO_DB_H__ + +//#include // changed to db-util.h +#include "db-util.h" +#include "memo-db.h" + +sqlite3* db_init(char *); +void db_fini(sqlite3 *); + +int insert_data(sqlite3 *, struct memo_data *); +int remove_data(sqlite3 *, int id); +int update_data(sqlite3 *, struct memo_data *); + +int get_data(sqlite3 *, int , struct memo_data *); +struct memo_data_list* get_all_data_list(sqlite3 *); +struct memo_operation_list* get_operation_list(sqlite3 *db, time_t stamp); +int get_data_count(sqlite3 *db, int *count); + +int has_id(sqlite3 *, int id); +time_t get_modtime(sqlite3 *, int id); +int get_indexes(sqlite3 *db, int *aIndex, int len, MEMO_SORT_TYPE sort); +int search_data(sqlite3 *db, const char *search_str, int limit, int offset, MEMO_SORT_TYPE sort, + memo_data_iterate_cb_t cb, void *user_data); +int all_data(sqlite3 *db, memo_data_iterate_cb_t cb, void *user_data); + +#define DBHandle sqlite3 +//#define VCONFKEY_MEMO_DATA_CHANGE "db/memo/data-change" + +#endif /* __LIBSLP_MEMO_DB_H__ */ diff --git a/include/memo-db.h b/include/memo-db.h new file mode 100644 index 0000000..6ce7280 --- /dev/null +++ b/include/memo-db.h @@ -0,0 +1,650 @@ +/* +* +* Copyright 2012 Samsung Electronics Co., Ltd +* +* Licensed under the Flora License, Version 1.1 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://floralicense.org/license/ +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +/*! + * @defgroup app_lib Application library + * This is a framework for User interface + */ + +/*! + * @defgroup memo_db_group Memo DB Library + * @ingroup app_lib + * Functions to APIs to access memo DB. + */ + +/** + * @file memo-db.h + * @ingroup memo_db_group + * @brief This library provides APIs to access memo DB. + * @author Canjiang Lu + * @date 2010-09-15 + * @version 0.1.3-51 + */ + +#ifndef __MEMO_DB_H__ +#define __MEMO_DB_H__ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @def DATE_LEN + * Maxium length of date + */ +#define DATE_LEN 17 + +/** +* @struct memo_data +* @brief This structure defines memo information. +*/ +typedef struct memo_data { + unsigned int id; /**< index of memo record */ + char *content; /**< content */ + char written_time[DATE_LEN]; /**< wiritten time */ + time_t modi_time; /**< modify time stamp */ + int has_doodle; /**< has doodle image */ + unsigned int color; /**< background color */ + char *comment; + int favorite; + int font_respect; /**< distiguish records synchronized from KIES which has no font information */ + int font_size; + int font_color; + char *doodle_path; +} memo_data_t; + +/** + * @struct memo_data_list + * @brief List for memo data + */ +typedef struct memo_data_list { + struct memo_data md; /**< memo data */ + struct memo_data_list *prev; /**< Previous list */ + struct memo_data_list *next; /**< Next list */ +} memo_data_list_t; + +/** + * @brief Enum values for db operation + */ +enum { + MEMO_OPERATION_ADD, /**< operation add */ + MEMO_OPERATION_UPDATE, /**< operation update */ + MEMO_OPERATION_DELETE, /**< operation delete */ +}; + +typedef enum { + MEMO_SORT_INVALID = -1, + MEMO_SORT_CREATE_TIME, /* descend */ + MEMO_SORT_CREATE_TIME_ASC, + MEMO_SORT_TITLE, /* descend */ + MEMO_SORT_TITLE_ASC, + MEMO_SORT_TYPES, +}MEMO_SORT_TYPE; + +/** + * @struct memo_operation_list + * @brief List for memo data operation + */ +struct memo_operation_list { + int id; /**< index of memo record */ + int operation; /**< operation type */ + struct memo_operation_list *next; /**< Next list */ +}; + +/** + * This function init memo database, create db file to the @param dbfile if the dbfile is not null. + * If the file path is NULL, the db file will be created to the default path. + * + * @brief Initialize Memo-Database + * + * @param [in] dbfile the path of user defined db file. + * + * @return On success, 0 is returned. On error, -1 is returned + * + * @remarks The function must be called fristly before calling other functions of memo-db. + * + * @exception None + * + * @see memo_fini + * + * \par Sample code: + * \code + * ... + * memo_init(NULL); + * ... + * \endcode + */ +int memo_init(char *dbfile); + +/** + * This function fini memo database, it will close db and free db resource + * + * @brief Finialize Memo-Database + * + * @return None + * + * @remarks The function must be called finally when the application don't need db + * + * @exception None + * + * @see memo_init + * + * \par Sample code: + * \code + * ... + * memo_fini(); + * ... + * \endcode + */ +void memo_fini(void); + +/** + * This function create a pointer to struct memo_data. + * + * @brief Create memo data structure, Ref: memo_free_data() + * + * @return This function returns a pointer of memo_data on success or NULL on failure. + * + * @remarks None + * + * @exception None + * + * @see memo_free_data + * + * \par Sample code: + * \code + * ... + * memo_data *md = NULL; + * md = memo_create_data(); + * if (md == NULL) { + * return; + * } + * ... + * \endcode + */ +struct memo_data* memo_create_data(void); + +/** + * This function gets the data of the record assosiated with id. + * It will connect to db and search by id. + * + * + * @brief Get a record data by id + * + * @param [in] id the id of the memo record + * + * @return This function returns a pointer of memo_data on success or NULL on failure. + * + * @remarks The function must be called after memo_init(), and also given the correct id. + * + * @exception None + * + * @see + * + * \par Sample code: + * \code + * ... + * memo_data *md = NULL; + * md = memo_get_data(id); + * if (md == NULL) { + * return; + * } else { + * memo_free_data(md); + * } + * ... + * \endcode + */ +struct memo_data* memo_get_data(int id); + +/** + * This function free the data: struct memo_data. + * The function must be called after memo_create_data() + * + * @brief Free data struct + * + * @param [in] md a pointer to struct memo_data* + * + * @return None + * + * @remarks When application don't need the memo_data, must call the function to free the memory + * + * @exception None + * + * @see memo_create_data + * + * \par Sample code: + * \code + * ... + * memo_data *md = NULL; + * md = memo_get_data(id); + * if (md == NULL) { + * return; + * } else { + * memo_free_data(md); + * } + * ... + * \endcode + */ +void memo_free_data(struct memo_data *md); + +/** + * This function add the data: struct memo_data. + * This function is usually called together with memo_create_data(); + * + * @brief Insert a data to DB + * + * @param [in] md a pointer to struct memo_data* + * + * @return Return id (Success) or -1 (Failed) + * + * @remarks None + * + * @exception None + * + * @see memo_mod_data memo_del_data + * + * \par Sample code: + * \code + * ... + * memo_data *md = NULL; + * md = memo_create_data(); + * md->color = 1; + * ... + * if (memo_add_data(md) != -1) { + * return true; + * } else { + * return false; + * } + * ... + * \endcode + */ +int memo_add_data(struct memo_data *md); + +/** + * This function modify the data: struct memo_data. + * This function is usually called together with memo_get_data(); + * + * @brief Update a data to DB + * + * @param [in] md a pointer to struct memo_data* + * + * @return Return 0 (Success) or -1 (Failed) + * + * @remarks None + * + * @exception None + * + * @see memo_add_data memo_del_data + * + * \par Sample code: + * \code + * ... + * memo_data *md = NULL; + * md = memo_get_data(id); + * if (md == NULL) { + * return; + * } else { + * md->id = 2; + * memo_mod_data(md); + * memo_free_data(md); + * } + * ... + * \endcode + */ +int memo_mod_data(struct memo_data *md); + +/** + * This function delete the data assosiated with id. + * + * @brief Delete a data to DB + * + * @param [in] id the id of the memo record + * + * @return Return 0 (Success) or -1 (Failed) + * + * @remarks None + * + * @exception None + * + * @see memo_add_data memo_mod_data + * + * \par Sample code: + * \code + * ... + * if (memo_del_data(id) != -1) { + * return true; + * } else { + * return false; + * } + * ... + * \endcode + */ +int memo_del_data(int id); + +/** + * This function gets the data list of the memo assosiated. + * + * + * @brief Get all memo list + * + * @return This function returns a pointer of memo_data_list on success or NULL on failure. + * + * @remarks None + * + * @exception None + * + * @see memo_free_data_list + * + * \par Sample code: + * \code + * ... + * memo_data_list *l = NULL; + * l = memo_get_all_data_list(); + * while (l != NULL) { + * l = l->next; + * } + * memo_free_data_list(l); + * ... + * \endcode + */ +struct memo_data_list* memo_get_all_data_list(void); + +/** + * This function free the data list of struct memo_data_list + * This function must be called when data list get by memo_get_all_data_list is not being needed + * + * @brief Free data list + * + * @param [in] mdl pointer of memo_data_list + * + * @return None + * + * @remarks None + * + * @exception None + * + * @see memo_get_all_data_list + * + * \par Sample code: + * \code + * ... + * memo_data_list *l = NULL; + * l = memo_get_all_data_list(); + * while (l != NULL) { + * l = l->next; + * } + * memo_free_data_list(l); + * ... + * \endcode + */ +void memo_free_data_list(struct memo_data_list *mdl); + +/** + * This function gets the modify time of a record associated with id. + * + * + * @brief Get modify time stamp + * + * @param [in] id the id of the memo record + * + * @return This function returns the latest modify time of a record or -1 if failed. + * + * @remarks None + * + * @exception None + * + * @see memo_free_data_list + * + * \par Sample code: + * \code + * ... + * time_t *tm = -1; + * tm = memo_get_modified_time(id); + * if (tm == -1) { + * return; + * } else { + * ... + * } + * ... + * \endcode + */ +time_t memo_get_modified_time(int id); + +/** + * This function gets the records number in db. + * + * + * @brief Get number of records in db + * + * @param [out] count the count of the memo records + * + * @return Return 0 (Success) or -1 (Failed) + * + * @remarks None + * + * @exception None + * + * @see + * + * \par Sample code: + * \code + * ... + * int count = 0; + * if (memo_get_count(&count) == -1) { + * return; + * } else { + * ... + * } + * ... + * \endcode + */ +int memo_get_count(int *count); + +/** + * This function gets operation list of all updated record after specified time stamp. + * + * + * @brief Get operation list + * + * @param [in] stamp time stamp + * + * @return This function returns a pointer of memo_operation_list on success or NULL on failure. + * + * @remarks None + * + * @exception None + * + * @see memo_free_operation_list + * + * \par Sample code: + * \code + * ... + * memo_data *md = NULL; + * time_t tm = time((time_t *)0); + * memo_operation_list l = NULL; + * md = memo_create_data(); + * md->color = 1; + * ... + * if (memo_add_data(md) != -1) { + * l = memo_get_operation_list(tm); + * if (l != NULL) { + * memo_free_operation_list(); + * } + * } else { + * return false; + * } + * ... + * \endcode + */ +struct memo_operation_list* memo_get_operation_list(time_t stamp); + +/** + * This function free the data list of struct memo_operation_list + * This function must be called when data list get by memo_get_operation_list is not being needed + * + * @brief Free operation list + * + * @param [in] mol pointer of memo_operation_list + * + * @return None + * + * @remarks None + * + * @exception None + * + * @see memo_get_operation_list + * + * \par Sample code: + * \code + * ... + * memo_data *md = NULL; + * time_t tm = time((time_t *)0); + * memo_operation_list l = NULL; + * md = memo_create_data(); + * md->color = 1; + * ... + * if (memo_add_data(md) != -1) { + * l = memo_get_operation_list(tm); + * if (l != NULL) { + * memo_free_operation_list(); + * } + * } else { + * return false; + * } + * ... + * \endcode + */ +void memo_free_operation_list(struct memo_operation_list *mol); + +/** + * This function register callback funtion whenever memo record is update. + * + * + * @brief register callback + * + * @param [in] cb callback function + * + * @param [in] user_data The data to be passed to cb call. + * + * @return Return 0 (Success) or -1 (Failed) + * + * @remarks None + * + * @exception None + * + * @see memo_unsubscribe_change + * + * \par Sample code: + * \code + * ... + * \endcode + */ +int memo_subscribe_change(void (*cb)(void *), void *user_data); + +/** + * This function unregister callback funtion registered by memo_subscribe_change. + * + * + * @brief unregister callback + * + * @param [in] cb callback function to be unregistered. + * + * @return Return 0 (Success) or -1 (Failed) + * + * @remarks None + * + * @exception None + * + * @see memo_subscribe_change + * + * \par Sample code: + * \code + * ... + * \endcode + */ +int memo_unsubscribe_change(void (*cb)(void *)); + +/** + * This function is used to listen to the update of memo record. + * + * + * @brief accompanied with memo_end_trans, all update of memo record(update/add/delete) will trigger change callback + * registered by memo_subscribe_change + * + * @remarks None + * + * @exception None + * + * @see memo_end_trans + * + * \par Sample code: + * \code + * ... + * memo_begin_trans(); + * memo_add_data(md); // trigger callback + * memo_end_trans(); + * memo_add_data(md); // not trigger callback + * \endcode + */ +void memo_begin_trans(void); + +/** + * This function is used to end listen to the update of memo record and trigger callback. + * + * + * @brief + * + * @remarks None + * + * @exception None + * + * @see memo_begin_trans + * + * \par Sample code: + * \code + * ... + * memo_begin_trans(); + * memo_add_data(md); // trigger callback + * memo_end_trans(); + * memo_add_data(md); // not trigger callback + * \endcode + */ +void memo_end_trans(void); + +typedef void (*memo_data_iterate_cb_t) (memo_data_t *md, void *user_data); + +int memo_search_data(const char *search_str, int limit, int offset, MEMO_SORT_TYPE sort, + memo_data_iterate_cb_t cb, void *user_data); + +int memo_all_data(memo_data_iterate_cb_t cb, void *user_data); + +/* Ugh, the following APIs are under testing and provides no guarantee. + * If you want to use, please contact with canjiang.lu@samsung.com. + */ +int memo_get_indexes(int *aIndex, int len, MEMO_SORT_TYPE sort); + +#ifdef __cplusplus +} +#endif + +#endif /* __MEMO_DB_H__ */ + diff --git a/include/memo-log.h b/include/memo-log.h new file mode 100644 index 0000000..68aef19 --- /dev/null +++ b/include/memo-log.h @@ -0,0 +1,66 @@ +/* +* +* Copyright 2012 Samsung Electronics Co., Ltd +* +* Licensed under the Flora License, Version 1.1 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://floralicense.org/license/ +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +#ifndef __MEMO_LOG_H__ +#define __MEMO_LOG_H__ + +#include +#include + +#ifdef LOG_TAG + #undef LOG_TAG +#endif +#define LOG_TAG "libslp-memo" + +#define INFO(fmt, arg...) LOGI(fmt, ##arg) +#define ERR(fmt, arg...) LOGE(fmt, ##arg) +#define DBG(fmt, arg...) LOGD(fmt, ##arg) + +#define warn_if(expr, fmt, arg...) do { \ + if(expr) { \ + ERR("(%s) -> "fmt, #expr, ##arg); \ + } \ +} while (0) +#define ret_if(expr) do { \ + if(expr) { \ + ERR("(%s) -> %s() return", #expr, __FUNCTION__); \ + return; \ + } \ +} while (0) +#define retv_if(expr, val) do { \ + if(expr) { \ + ERR("(%s) -> %s() return", #expr, __FUNCTION__); \ + return (val); \ + } \ +} while (0) +#define retm_if(expr, fmt, arg...) do { \ + if(expr) { \ + ERR(fmt, ##arg); \ + ERR("(%s) -> %s() return", #expr, __FUNCTION__); \ + return; \ + } \ +} while (0) +#define retvm_if(expr, val, fmt, arg...) do { \ + if(expr) { \ + ERR(fmt, ##arg); \ + ERR("(%s) -> %s() return", #expr, __FUNCTION__); \ + return (val); \ + } \ +} while (0) + +#endif /* __MEMO_LOG_H__ */ diff --git a/libslp-memo.manifest b/libslp-memo.manifest new file mode 100755 index 0000000..87c14d0 --- /dev/null +++ b/libslp-memo.manifest @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/memo.pc.in b/memo.pc.in new file mode 100644 index 0000000..088afd7 --- /dev/null +++ b/memo.pc.in @@ -0,0 +1,13 @@ +# Package Information for pkg-config + +prefix=@PREFIX@ +exec_prefix=@EXEC_PREFIX@ +libdir=@LIBDIR@ +includedir=@INCLUDEDIR@ + +Name: libmemo +Description: Memo DB interface library +Version: @VERSION@ +Requires: +Libs: -L${libdir} -lmemo +Cflags: -I${includedir} diff --git a/packaging/libslp-memo.spec b/packaging/libslp-memo.spec new file mode 100755 index 0000000..843d21f --- /dev/null +++ b/packaging/libslp-memo.spec @@ -0,0 +1,72 @@ +Name: libslp-memo +Summary: Memo DB interface library +Version: 0.1.5 +Release: 1 +Group: TO_BE/FILLED_IN +License: Flora +Source0: libslp-memo-%{version}.tar.gz +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(heynoti) +BuildRequires: pkgconfig(db-util) +BuildRequires: pkgconfig(vconf) + +BuildRequires: cmake +Requires(post): /usr/bin/sqlite3 + +%description +library for memo(development package) + +%package devel +Summary: Development files for %{name} +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} + +%description devel +Development files for %{name} + +%prep +%setup -q + +%build +export LDFLAGS+=" -Wl,--rpath=%{_libdir} -Wl,--as-needed -Wl,--hash-style=both" +%cmake . + +make %{?jobs:-j%jobs} + +%install +mkdir -p %{buildroot}/usr/share/license +cp LICENSE %{buildroot}/usr/share/license/%{name} +%make_install + +%post +mkdir -p /opt/dbspace +sqlite3 /opt/dbspace/.memo.db 'PRAGMA journal_mode = PERSIST; +CREATE TABLE if not exists memo ( id INTEGER PRIMARY KEY autoincrement, content TEXT, written_time TEXT, create_time INTEGER, modi_time INTEGER, delete_time INTEGER, doodle INTEGER, color INTEGER, comment TEXT, favorite INTEGER,font_respect INTEGER, font_size INTEGER, font_color INTEGER, doodle_path TEXT ); + ' + +if [ -f /usr/lib/rpm-plugins/msm.so ] +then +chsmack -a 'memo::db' /opt/usr/dbspace/.memo.db* +fi + + + +# Change file owner +chown :5000 /opt/dbspace/.memo.db +chown :5000 /opt/dbspace/.memo.db-journal + +# Change file permissions +chmod 660 /opt/dbspace/.memo.db +chmod 660 /opt/dbspace/.memo.db-journal + +%files +%defattr(-,root,root,-) +%manifest libslp-memo.manifest +%{_libdir}/*.so.* +/usr/share/license/%{name} + +%files devel +%defattr(-,root,root,-) +%{_libdir}/*.so +%{_libdir}/pkgconfig/memo.pc +%{_includedir}/*.h diff --git a/src/db-helper.c b/src/db-helper.c new file mode 100644 index 0000000..ce2b70b --- /dev/null +++ b/src/db-helper.c @@ -0,0 +1,305 @@ +/* +* +* Copyright 2012 Samsung Electronics Co., Ltd +* +* Licensed under the Flora License, Version 1.1 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://floralicense.org/license/ +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +#include +#include +#include +#include +#include +#include +#include "db-helper.h" +#include "memo-db.h" + +#define SINGLE_QUOTO '\'' +#define sncat(to, size, from) \ + strncat(to, from, size-strlen(to)-1) + +struct key_value_t +{ + char *key; + char *value; +}; + +struct column_t columns[] = { + {"doodle", "%d"}, /* 0 - KEY_ITEM_MODE */ + {"favorite", "%d"}, /* 1 - KEY_FAVORITE */ + {"color", "%d"}, /* 2 - KEY_COLOR */ + {"content", "%s"}, /* 3 - KEY_CONTENT */ + {"font_respect", "%d"}, /* 4 - KEY_FONT_RESPECT */ + {"font_size", "%d"}, /* 5 - KEY_FONT_SIZE */ + {"font_color", "%d"}, /* 6 - KEY_FONT_COLOR */ + {"comment", "%s"}, /* 7 - KEY_COMMENT */ + {"doodle_path", "%s"}, /* 8 - KEY_DOODLE_PATH */ + {"create_time", "%d"}, /* 9 - KEY_CREATE_TIME */ + {"modi_time", "%d"}, /* 10 - KEY_MODI_TIME */ + {"delete_time", "%d"}, /* 11 - KEY_DELETE_TIME */ + {"written_time", "%s"}, /* 12 - KEY_WRITTEN_TIME */ +}; + +void string_append_printf(char *str, char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + char *buf = str + strlen(str); + vsprintf(buf, fmt, args); + va_end(args); +} + +/* + * @decription + * Limit the maximum content length. + * + * @param[in/out] content + * @return the original string pointer + */ +char *db_content_truncate(char *content) +{ + if (content == NULL) { return NULL; } + + if (strlen(content) > MEMO_DB_MAX_CONTENT_LEN) + { + content[MEMO_DB_MAX_CONTENT_LEN] = '\0'; + } + return content; +} + +char *db_parse_value(int key, void *val) +{ + char *type = columns[key].type; + + /* judge the val's type is string */ + bool is_string = (type[strlen(type) - 1] == 's' ? true : false); + + if (is_string) { + return db_make_string_constant((const char *)val); + } else { + int len = 32; + char *buf = (char *)malloc(sizeof(char) * len); + if (buf == NULL) { + return NULL; + } + snprintf(buf, len, type, val); + return buf; + } +} + +void db_key_value_array_append(struct key_value_t kv[], int total, int key1, void *val1) +{ + int i = total; + kv[i].key = columns[key1].name; + kv[i].value = db_parse_value(key1, val1); +} + +int db_parse_key_value(struct key_value_t kv[], int key1, void *val1, va_list args) +{ + int keyn = -1; + void *valn = NULL; + int count = 0; + + db_key_value_array_append(kv, count++, key1, val1); + + while(true) + { + keyn = va_arg(args, int); + valn = va_arg(args, void*); + + if(keyn == KEY_INPUT_END) { break; } + if(valn == NULL) { continue; } + + db_key_value_array_append(kv, count++, keyn, valn); + } + + return count; +} + + +char *db_make_insert_query(int key1, void *val1, ...) +{ + struct key_value_t kv[TOTAL_NUM_OF_KEYS]; + int count = 0; + int i = 0; + + va_list args; + va_start(args, val1); + count = db_parse_key_value(kv ,key1, val1, args); + va_end(args); + + db_key_value_array_append(kv, count++, KEY_CREATE_TIME, (void *)time(NULL)); + db_key_value_array_append(kv, count++, KEY_MODI_TIME, (void *)time(NULL)); + db_key_value_array_append(kv, count++, KEY_DELETE_TIME, (void *)-1); + + /* BEGIN Generate SQL Query */ + /* INSERT INTO memo (key1, key2, ...) VALUES (val1, val2, ...) */ + int len = 256; /* buffer length */ + for (i = 0; i < count; ++i) + { + len += strlen(kv[i].key); + len += strlen(kv[i].value); + } + + char *buf = (char *)malloc(len); + if (buf == NULL) { + for (i = 0; i < count; ++i) /* clean up */ + { + free(kv[i].value); + } + return NULL; + } + + strncpy(buf, "INSERT INTO memo (", len); + + for (i = 0; i < count; ++i) + { + sncat(buf, len, kv[i].key); + sncat(buf, len, i == count - 1 ? ") VALUES (" : ", "); + } + + for (i = 0; i < count; ++i) + { + sncat(buf, len, kv[i].value); + sncat(buf, len, i == count - 1 ? ")" : ", "); + } + /* END Generate SQL Query */ + + for (i = 0; i < count; ++i) /* clean up */ + { + free(kv[i].value); + } + + return buf; +} + +char *db_make_update_query(int id, int key1, void *val1, ...) +{ + struct key_value_t kv[TOTAL_NUM_OF_KEYS]; + int count = 0; + int i = 0; + + va_list args; + va_start(args, val1); + count = db_parse_key_value(kv ,key1, val1, args); + va_end(args); + + db_key_value_array_append(kv, count++, KEY_MODI_TIME, (void *)time(NULL)); + + /* BEGIN Generate SQL Query */ + /* UPDATE memo SET key1 = val1, key2 = val2, ... WHERE id = %d */ + int len = 256; /* buffer length */ + for (i = 0; i < count; ++i) + { + len += strlen(kv[i].key); + len += strlen(kv[i].value); + } + + char *buf = (char *)malloc(len); + if (buf == NULL) { + for (i = 0; i < count; ++i) /* clean up */ + { + free(kv[i].value); + } + return NULL; + } + + strncpy(buf, "UPDATE memo SET ", len); + + for (i = 0; i < count; ++i) + { + string_append_printf(buf, "%s = %s", kv[i].key, kv[i].value); + sncat(buf, len, i == count - 1 ? " " : ", "); + } + + string_append_printf(buf, "WHERE %s = %d", KEY_ID_NAME, id); + /* END Generate SQL Query */ + + for (i = 0; i < count; ++i) /* clean up */ + { + free(kv[i].value); + } + + return buf; +} + +char *db_make_delete_query(int id) +{ + return db_make_update_query(id, + KEY_DELETE_TIME, (void *)time(NULL), + KEY_INPUT_END); +} + +static int _string_constant_len(const char *input) +{ + if (input == NULL) { + return 0; + } + + int i = 0; + int len = strlen(input); + int size = len + 2; /* add enclosing quotes */ + + for (i=0; i +#include +#include +#include +#include + +#include "memo-log.h" +#include "memo-db.h" +#include "db-schema.h" +#include "db.h" +#include "db-helper.h" + +#define QUERY_MAXLEN 5120 +#define NFS_TEST + +#define TEXT(s, n) (char *)sqlite3_column_text(s, n) +#define INT(s, n) sqlite3_column_int(s, n) + +static char* _d(char *str) +{ + if(str == NULL /*|| strlen(str) == 0*/) return NULL; + return strdup(str); +} + +static int _exec(sqlite3 *db, char *query) +{ + int rc; + char *errmsg = NULL; + + retvm_if(db == NULL, -1, "DB handler is null"); + + rc = sqlite3_exec(db, query, NULL, 0, &errmsg); + if(rc != SQLITE_OK) { + DBG("Query: [%s]", query); + ERR("SQL error: %s\n", errmsg); + sqlite3_free(errmsg); + return -1; + } + return 0; +} + +static int _create_table(sqlite3 *db) +{ + int rc; + + rc = _exec(db, CREATE_MEMO_TABLE); + retv_if(rc == -1, -1); + + return 0; +} + +static inline void _make_qry_i_cd(char *query, int len, struct memo_data *cd) +{ + char * buf = db_make_insert_query( + KEY_ITEM_MODE, (void *)cd->has_doodle, + KEY_CONTENT, db_content_truncate(cd->content), + KEY_FONT_RESPECT, cd->font_respect, + KEY_FONT_SIZE, ((cd->font_respect ? cd->font_size : 44)), + KEY_FONT_COLOR, (cd->font_respect ? cd->font_color : 0xff000000), + KEY_COMMENT, cd->comment, + KEY_DOODLE_PATH, cd->doodle_path, + KEY_INPUT_END); + if (buf != NULL) { + snprintf(query, len, "%s", buf); + free(buf); + } +} + +int insert_data(sqlite3 *db, struct memo_data *cd) +{ + int rc = 0; + char *query = NULL; + int len = 512; + + retvm_if(db == NULL, -1, "DB handler is null"); + retvm_if(cd == NULL, -1, "Insert data is null"); + + if (cd->content != NULL) { + len += strlen(cd->content); + } + if (cd->comment != NULL) { + len += strlen(cd->comment); + } + query = (char *)malloc(len); + retv_if(query == NULL, -1); + _make_qry_i_cd(query, len, cd); + memo_begin_trans(); + rc = _exec(db, query); + memo_end_trans(); + free(query); + retv_if(rc == -1, rc); + cd->id = sqlite3_last_insert_rowid(db); + DBG("Memo id : %d", cd->id); + return cd->id; +} + +static inline void _make_qry_d_cd(char *query, int len, struct memo_data *cd) +{ + char *buf = db_make_delete_query(cd->id); + if (buf != NULL) { + snprintf(query, len, "%s", buf); + free(buf); + } +} + +int remove_data(sqlite3 *db, int cid) +{ + int rc; + char query[QUERY_MAXLEN]; + + retvm_if(db == NULL, -1, "DB handler is null"); + retvm_if(cid < 1, -1, "Invalid memo data ID"); + if (has_id(db, cid) != 1) { + return -1; + } + + struct memo_data memo; + memo.id = cid; + _make_qry_d_cd(query, sizeof(query), &memo); + memo_begin_trans(); + rc = _exec(db, query); + memo_end_trans(); + retv_if(rc == -1, rc); + return 0; +} + +static inline void _make_qry_u_cd(char *query, int len, struct memo_data *cd) +{ + char *buf = db_make_update_query(cd->id, + KEY_FAVORITE, (void *)cd->favorite, + KEY_CONTENT, db_content_truncate(cd->content), + KEY_FONT_RESPECT, cd->font_respect, + KEY_FONT_SIZE, ((cd->font_respect ? cd->font_size : 44)), + KEY_FONT_COLOR, (cd->font_respect ? cd->font_color : 0xff000000), + KEY_COMMENT, cd->comment, + KEY_DOODLE_PATH, cd->doodle_path, + KEY_INPUT_END); + if (buf != NULL) { + snprintf(query, len, "%s", buf); + free(buf); + } +} + +int update_data(sqlite3 *db, struct memo_data *cd) +{ + int rc; + char *query = NULL; + int len = 512; + + retvm_if(db == NULL, -1, "DB handler is null"); + retvm_if(cd == NULL, -1, "Update data is null"); + + if (cd->content != NULL) { + len += strlen(cd->content); + } + if (cd->comment != NULL) { + len += strlen(cd->comment); + } + query = (char *)malloc(len); + retv_if(query == NULL, -1); + _make_qry_u_cd(query, len, cd); + memo_begin_trans(); + rc = _exec(db, query); + memo_end_trans(); + free(query); + retv_if(rc == -1, rc); + return 0; +} + +static int _get_cd(sqlite3 *db, int cid, struct memo_data *cd) +{ + int rc; + char query[QUERY_MAXLEN]; + sqlite3_stmt *stmt; + int idx; + + snprintf(query, sizeof(query), "select content, modi_time, doodle, color, comment, favorite, font_respect, font_size, font_color, doodle_path " + "from memo where id = %d and delete_time = -1", + cid); + + rc = sqlite3_prepare(db, query, -1, &stmt, NULL); + if (SQLITE_OK != rc || NULL == stmt) { + ERR("SQL error\n"); + sqlite3_finalize(stmt); + return -1; + } + + rc = sqlite3_step(stmt); + if(rc == SQLITE_ROW) { + idx = 0; + cd->content = _d(TEXT(stmt, idx++)); + //strncpy(cd->written_time, _s(TEXT(stmt, idx++)), DATE_LEN); + cd->modi_time = INT(stmt, idx++); + cd->has_doodle = INT(stmt, idx++); + cd->color = INT(stmt, idx++); + cd->comment = _d(TEXT(stmt, idx++)); + cd->favorite = INT(stmt, idx++); + cd->font_respect = INT(stmt, idx++); + cd->font_size = INT(stmt, idx++); + cd->font_color = INT(stmt, idx++); + cd->doodle_path = _d(TEXT(stmt, idx++)); + } else { + retvm_if(1, -1, "Contact data %d does not exist", cid); + } + rc = sqlite3_finalize(stmt); + + return 0; +} + +int get_data(sqlite3 *db, int cid, struct memo_data *cd) +{ + int rc; + + retvm_if(db == NULL, -1, "DB handler is null"); + retvm_if(cd == NULL, -1, "Output struct is null"); + retvm_if(cid < 1, -1, "Invalid memo ID"); + + rc = _get_cd(db, cid, cd); + retv_if(rc == -1, rc); + + cd->id = cid; + return 0; +} + +static struct memo_data_list* _get_data_list(sqlite3 *db, const char* query) +{ + int rc; + sqlite3_stmt *stmt; + struct memo_data_list *cd = NULL; + struct memo_data_list *t; + int idx; + + retvm_if(db == NULL, cd, "DB handler is null"); + + rc = sqlite3_prepare(db, query, -1, &stmt, NULL); + if (SQLITE_OK != rc || NULL == stmt) { + ERR("SQL error\n"); + sqlite3_finalize(stmt); + return NULL; + } + + rc = sqlite3_step(stmt); + while(rc == SQLITE_ROW) { + idx=0; + t = (struct memo_data_list *)calloc(1, sizeof(struct memo_data_list)); + if (t == NULL) { + continue; + } + t->md.id = INT(stmt, idx++); + t->md.content = _d(TEXT(stmt, idx++)); + //strncpy(t->md.written_time, _s(TEXT(stmt, idx++)), DATE_LEN); + t->md.modi_time = INT(stmt, idx++); + t->md.has_doodle = INT(stmt, idx++); + t->md.color = INT(stmt, idx++); // jwh : color added + t->md.comment = _d(TEXT(stmt, idx++)); + t->md.favorite = INT(stmt, idx++); + t->md.font_respect = INT(stmt, idx++); + t->md.font_size = INT(stmt, idx++); + t->md.font_color = INT(stmt, idx++); + t->md.doodle_path = _d(TEXT(stmt, idx++)); + + t->next = NULL; + t->prev = NULL; + if (cd != NULL) { + t->next = cd; + cd->prev = t; + } + cd = t; + rc = sqlite3_step(stmt); + } + rc = sqlite3_finalize(stmt); + + return cd; +} + +struct memo_data_list* get_all_data_list(sqlite3 *db) +{ + char query[QUERY_MAXLEN]; + retvm_if(db == NULL, NULL, "db handler is null"); + + snprintf(query, sizeof(query), "select " + "id, content, modi_time, doodle, color, comment, favorite, font_respect, font_size, font_color, doodle_path " + "from memo where delete_time = -1 order by create_time asc"); + + return _get_data_list(db, query); +} + +struct memo_operation_list* get_operation_list(sqlite3 *db, time_t stamp) +{ + char query[QUERY_MAXLEN]; + int rc; + sqlite3_stmt *stmt; + time_t create_tm, del_tm; + struct memo_operation_list *t = NULL; + struct memo_operation_list *cd = NULL; + int idx; + + retvm_if(db == NULL, NULL, "db handler is null"); + snprintf(query, sizeof(query), "select " + "id, create_time, modi_time, delete_time " + "from memo where modi_time > %ld", stamp); + rc = sqlite3_prepare(db, query, -1, &stmt, NULL); + if (SQLITE_OK != rc || NULL == stmt) { + ERR("SQL error\n"); + sqlite3_finalize(stmt); + return NULL; + } + + rc = sqlite3_step(stmt); + while(rc == SQLITE_ROW) { + idx=0; + t = (struct memo_operation_list *)malloc(sizeof(struct memo_operation_list)); + if (t == NULL) { + continue; + } + t->id = INT(stmt, idx++); + create_tm = INT(stmt, idx++); + INT(stmt, idx++); + del_tm = INT(stmt, idx++); + if (del_tm != -1) { + t->operation = MEMO_OPERATION_DELETE; + } else if (stamp < create_tm) { + t->operation = MEMO_OPERATION_ADD; + } else { + t->operation = MEMO_OPERATION_UPDATE; + } + t->next = cd; + cd = t; + rc = sqlite3_step(stmt); + } + rc = sqlite3_finalize(stmt); + + return cd; +} + +int has_id(sqlite3 *db, int cid) +{ + int rc; + int ret = 0; + char query[QUERY_MAXLEN]; + sqlite3_stmt *stmt; + + retvm_if(db == NULL, ret, "DB handler is null"); + retvm_if(cid < 1, ret, "Invalid memo data ID"); + + snprintf(query, sizeof(query), "select id from memo where id = %d", cid); + + rc = sqlite3_prepare(db, query, -1, &stmt, NULL); + if (SQLITE_OK != rc || NULL == stmt) { + ERR("SQL error\n"); + sqlite3_finalize(stmt); + return -1; + } + + rc = sqlite3_step(stmt); + if(rc == SQLITE_ROW) { + ret = 1; // exist + } + rc = sqlite3_finalize(stmt); + + return ret; +} + +time_t get_modtime(sqlite3 *db, int cid) +{ + int rc; + time_t ret = -1; + char query[QUERY_MAXLEN]; + sqlite3_stmt *stmt; + + retvm_if(db == NULL, ret, "DB handler is null"); + retvm_if(cid < 1, ret, "Invalid memo data ID"); + + snprintf(query, sizeof(query), "select modi_time from memo where id = %d", cid); + + rc = sqlite3_prepare(db, query, -1, &stmt, NULL); + if (SQLITE_OK != rc || NULL == stmt) { + ERR("SQL error\n"); + sqlite3_finalize(stmt); + return -1; + } + + rc = sqlite3_step(stmt); + if(rc == SQLITE_ROW) { + ret = INT(stmt, 0); + } + rc = sqlite3_finalize(stmt); + + return ret; +} + +sqlite3* db_init(char *root) +{ + int rc; + sqlite3 *db = NULL; + + //rc = sqlite3_open(root, &db); // changed to db_util_open + rc = db_util_open(root, &db, DB_UTIL_REGISTER_HOOK_METHOD); + //rc = db_util_open(root, &db, 0); + if(rc) { + ERR("Can't open database: %s", sqlite3_errmsg(db)); + //sqlite3_close(db);// changed to db_util_close + db_util_close(db); + return NULL; + } + + rc = _create_table(db); + if(rc) { + ERR("Can't create tables: %s", sqlite3_errmsg(db)); + //sqlite3_close(db);// changed to db_util_close + db_util_close(db); + return NULL; + } + + return db; +} + +void db_fini(sqlite3 *db) +{ + if(db) { + //sqlite3_close(db); // changed to db_util_close + db_util_close(db); + } +} + +/* +* @fn int get_latest_data(sqlite3 *db, struct memo_data *cd) +* @brif Get latest memo data from db +* +* Request by Widget Memo application. +* Added by jy.Lee (jaeyong911.lee@samsung.com) +*/ +int get_data_count(sqlite3 *db, int *count) +{ + int rc; + char query[QUERY_MAXLEN]; + sqlite3_stmt *stmt; + int idx; + int ret = 0; + + snprintf(query, sizeof(query), "select count(id) from memo where delete_time = -1"); + + rc = sqlite3_prepare(db, query, -1, &stmt, NULL); + if (SQLITE_OK != rc || NULL == stmt) { + ERR("SQL error\n"); + sqlite3_finalize(stmt); + return -1; + } + + rc = sqlite3_step(stmt); + if(rc == SQLITE_ROW) { + idx = 0; + *count = INT(stmt, idx++); + } else { + ret = -1; //retvm_if(1, -1, "data does not exist"); + } + rc = sqlite3_finalize(stmt); + + return ret; +} + +/** + * @brief Get indexes from database, if aIndex is NULL this function returns the number of records in database. + * + * @param [in] db handle of sqlite3 database + * + * @param [out] aIndex buffer to store retrieved indexes + * + * @param [in] len length of aIndex, the maximum number of indexes to be retrieved + * + * @param [in] sort sort type of result, currently not used(create_time descend defaultly) + * + * @return number of retrieved indexes or number of records + * + * @remarks If the number of indexes storded in database is larger than len, + the trailing indexes will be omitted. + * + */ +int get_indexes(sqlite3 *db, int *aIndex, int len, MEMO_SORT_TYPE sort) +{ + int rc = 0; + sqlite3_stmt *stmt = NULL; + char query[128] = {0}; + int i = 0; + const char *str_sort = "order by create_time desc"; + + retvm_if(db == NULL, 0, "db handler is null"); + retvm_if(len < 0, 0, "index buffer length invalid"); + + if (aIndex == NULL) { /* return number of records */ + get_data_count(db, &i); + return i; + } + + /* ugh, get sort type dynamically */ + snprintf(query, sizeof(query), "select id from memo where delete_time = -1 %s limit %d", str_sort, len); + rc = sqlite3_prepare(db, query, -1, &stmt, NULL); + if ((rc == SQLITE_OK) && (stmt != NULL)) { + rc = sqlite3_step(stmt); + while((rc==SQLITE_ROW)) { /* loop times depends on limit keyword, aIndex will not overflow */ + aIndex[i++] = INT(stmt, 0); + rc = sqlite3_step(stmt); + } + } + rc = sqlite3_finalize(stmt); + return i; +} + + +static const char *_get_sort_exp(MEMO_SORT_TYPE sort) +{ + const char *exp = "create_time DESC"; /* default sort type */ + switch (sort) { + case MEMO_SORT_CREATE_TIME: + exp = "create_time DESC"; + break; + case MEMO_SORT_CREATE_TIME_ASC: + exp = "create_time ASC"; + break; + case MEMO_SORT_TITLE: + exp = "CASE WHEN comment IS NOT NULL THEN comment ELSE content END DESC"; + break; + case MEMO_SORT_TITLE_ASC: + exp = "CASE WHEN comment IS NOT NULL THEN comment ELSE content END ASC"; + break; + default: + break; + } + return exp; +} + +int search_data(sqlite3 *db, const char *search_str, int limit, int offset, MEMO_SORT_TYPE sort, + memo_data_iterate_cb_t cb, void *user_data) +{ + retvm_if(db == NULL, -1, "db handler is NULL"); + retvm_if(search_str == NULL, -1, "search string is NULL"); + + int rc = 0; + sqlite3_stmt *stmt = NULL; + char query[QUERY_MAXLEN] = {0}; + int idx = 0; + memo_data_t *md = (memo_data_t *)calloc(1, sizeof(memo_data_t)); + retvm_if(md == NULL, -1, "calloc failed"); + + snprintf(query, sizeof(query), + "SELECT id, content, modi_time, doodle, comment, font_respect, font_size, font_color " + "FROM memo WHERE delete_time = -1 AND " + "CASE WHEN comment IS NOT NULL THEN comment like '%%%s%%' " + "ELSE content LIKE '%%%s%%' END " + "ORDER BY %s LIMIT %d OFFSET %d", + search_str, search_str, _get_sort_exp(sort), limit, offset); + LOGD("[query] : %s\n", query); + rc = sqlite3_prepare(db, query, -1, &stmt, NULL); + if ((rc == SQLITE_OK) && (stmt != NULL)) { + rc = sqlite3_step(stmt); + while((rc==SQLITE_ROW)) { + idx=0; + md->id = INT(stmt, idx++); + md->content = TEXT(stmt, idx++); + md->modi_time = INT(stmt, idx++); + md->has_doodle = INT(stmt, idx++); + md->comment = TEXT(stmt, idx++); + md->font_respect = INT(stmt, idx++); + md->font_size = INT(stmt, idx++); + md->font_color = INT(stmt, idx++); + cb(md, user_data); /* callback */ + rc = sqlite3_step(stmt); + } + } + rc = sqlite3_finalize(stmt); + free(md); + return 0; +} + +int all_data(sqlite3 *db, memo_data_iterate_cb_t cb, void *user_data) +{ + retvm_if(db == NULL, -1, "db handler is NULL"); + retvm_if(cb == NULL, -1, "iterator callback is NULL"); + + int rc = 0; + sqlite3_stmt *stmt = NULL; + int idx = 0; + memo_data_t *md = (memo_data_t *)calloc(1, sizeof(memo_data_t)); + retvm_if(md == NULL, -1, "calloc failed"); + + rc = sqlite3_prepare(db, + "SELECT id, content, modi_time, doodle, comment, font_respect, font_size, font_color " + "FROM memo where delete_time = -1 order by create_time desc", + -1, &stmt, NULL); + if ((rc == SQLITE_OK) && (stmt != NULL)) { + rc = sqlite3_step(stmt); + while((rc==SQLITE_ROW)) { + idx=0; + md->id = INT(stmt, idx++); + md->content = TEXT(stmt, idx++); + md->modi_time = INT(stmt, idx++); + md->has_doodle = INT(stmt, idx++); + md->comment = TEXT(stmt, idx++); + md->font_respect = INT(stmt, idx++); + md->font_size = INT(stmt, idx++); + md->font_color = INT(stmt, idx++); + cb(md, user_data); /* callback */ + rc = sqlite3_step(stmt); + } + } + rc = sqlite3_finalize(stmt); + free(md); + return 0; +} + diff --git a/src/memo_dbif.c b/src/memo_dbif.c new file mode 100644 index 0000000..db3429b --- /dev/null +++ b/src/memo_dbif.c @@ -0,0 +1,350 @@ +/* +* +* Copyright 2012 Samsung Electronics Co., Ltd +* +* Licensed under the Flora License, Version 1.1 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://floralicense.org/license/ +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ +#include +#include +#include +#include +#include +#include +#include + +#include "memo-log.h" +#include "memo-db.h" +#include "db.h" + +#ifndef MEMOAPI +#define MEMOAPI __attribute__ ((visibility("default"))) +#endif + +#define DB_PREFIX_PATH "/opt/dbspace" +#define DBNAME ".memo.db" + +static void (*g_data_monitor) (void *) = NULL; +static int trans_count = 0; +static DBHandle *db; +static int ref_count = 0; + +/****************************** +* External API +*******************************/ +/** + * @fn int memo_init(char *dbfile) + * @brief initialize memo db library + * @param[in] dbfile db file path + * @return Return 0 (Success) or -1 (Failed) + */ +MEMOAPI int memo_init(char *dbfile) +{ + char *name = NULL; + char defname[PATH_MAX]; + + if(db) { + ref_count++; + return 0; + } + + if(dbfile) + name = dbfile; + + if(name == NULL) { + snprintf(defname, sizeof(defname), "%s/%s", + DB_PREFIX_PATH, DBNAME); + name = defname; + } + + DBG("DB name : %s", name); + db = db_init(name); + retv_if(db == NULL, -1); + ref_count++; + return 0; +} + +/** + * @fn void memo_fini(void) + * @brief terminate memo db library + * @return None + */ +MEMOAPI void memo_fini(void) +{ + ref_count--; + if (ref_count == 0) { + db_fini(db); + db = NULL; + } +} + +/** + * @fn struct memo_data* memo_create_data() + * @brief create memo data struct + * @return The pointer of created memo data + */ +MEMOAPI struct memo_data* memo_create_data() +{ + return (struct memo_data *)calloc(1, sizeof(struct memo_data)); +} + +/** + * @fn struct memo_data* memo_get_data(int id) + * @brief Get memo data with specific id + * @param[in] id db id + * @return The pointer of memo data struct + */ +MEMOAPI struct memo_data* memo_get_data(int id) +{ + int rc; + struct memo_data *md; + + retvm_if(db == NULL, NULL, "DB Handle is null, need memo_init"); + retvm_if(id < 1, NULL, "Invalid memo data id : %d", id); + + md = memo_create_data(); + retv_if(md == NULL, md); + + rc = get_data(db, id, md); + if(rc) { + memo_free_data(md); + return NULL; + } + + return md; +} + +/** + * @fn void memo_free_data(struct memo_data *md) + * @brief deallocate memo data + * @param[in] md memo data + * @return None + */ +MEMOAPI void memo_free_data(struct memo_data *md) +{ + ret_if(md == NULL); + + if(md->content) + free(md->content); + + if(md->comment) + free(md->comment); + + if(md->doodle_path) + free(md->doodle_path); + + free(md); +} + +/** + * @fn int memo_add_data(struct memo_data *md) + * @brief insert memo data + * @param[in] md memo data struct + * @return Return id (Success) or -1 (Failed) + */ +MEMOAPI int memo_add_data(struct memo_data *md) +{ + retvm_if(db == NULL, -1, "DB Handle is null, need memo_init"); + return insert_data(db, md); +} + +/** + * @fn int memo_mod_data(struct memo_data *md) + * @brief Update data in DB + * @param[in] md The pointer of memo data + * @return Return 0 (Success) or -1 (Failed) + */ +MEMOAPI int memo_mod_data(struct memo_data *md) +{ + retvm_if(db == NULL, -1, "DB Handle is null, need memo_init"); + retvm_if(md == NULL, -1, "Update data is null"); + retvm_if(md->id < 1, -1, "Invalid memo data ID"); + return update_data(db, md); +} + +/** + * @fn int memo_del_data(int id) + * @brief remove data of specific id from DB + * @param[in] id db id + * @return Return 0 (Success) or -1 (Failed) + */ +MEMOAPI int memo_del_data(int id) +{ + char buf[128] = {0}; + retvm_if(db == NULL, -1, "DB Handle is null, need memo_init"); + retvm_if(id < 1, -1, "Invalid memo data ID"); + memo_data_t *md = memo_get_data(id); + /* delete doodle */ + if(md->has_doodle == 1) { + snprintf(buf, 128, "/opt/usr/apps/org.tizen.memo/data/doodle/%d.png", id); + if(remove(buf) != 0) { + ERR("Remove file error\n"); + memo_free_data(md); + return -1; + } + } + memo_free_data(md); + return remove_data(db, id); +} + +/** + * @fn struct memo_data_list* memo_get_all_data_list() + * @brief Get the all data list + * @return the header of struct memo_data_list linked list + */ +MEMOAPI struct memo_data_list* memo_get_all_data_list(void) +{ + struct memo_data_list *mdl; + + retvm_if(db == NULL, NULL, "DB Handle is null, need memo_init"); + + mdl = get_all_data_list(db); + return mdl; +} + +/** + * @fn void memo_free_data_list(struct memo_data_list *mdl) + * @brief deallocate memo data list + * @param[in] mdl the pointer of memo_data_list struct + * @return None + */ +MEMOAPI void memo_free_data_list(struct memo_data_list *mdl) +{ + struct memo_data_list *t, *d; + + t = mdl; + while(t) { + d = t; + t = t->next; + if(d->md.content) free(d->md.content); + free(d); + } +} + +/** + * @fn time_t memo_get_modified_time(int id) + * @brief Get modified time + * @param[in] id db id + * @return modified time + */ +MEMOAPI time_t memo_get_modified_time(int id) +{ + retvm_if(db == NULL, -1, "DB Handle is null, need memo_init"); + + return get_modtime(db, id); +} + +/** + * @fn int memo_get_count(int *count) + * @brief Get number of memo + * @return 0 on success + or -1 on fail + * + * Requested by widget memo + * Added by jy.Lee (jaeyong911.lee@samsung.com) + */ +MEMOAPI int memo_get_count(int *count) +{ + int rc; + retvm_if(db == NULL, -1, "DB Handle is null, need memo_init"); + retvm_if(count == NULL, -1, "count pointer is null"); + + rc = get_data_count(db, count); + if(rc) { + return -1; + } + + return 0; +} + +MEMOAPI struct memo_operation_list* memo_get_operation_list(time_t stamp) +{ + struct memo_operation_list *mol; + + retvm_if(db == NULL, NULL, "DB Handle is null, need memo_init"); + + mol = get_operation_list(db, stamp); + return mol; +} + +MEMOAPI void memo_free_operation_list(struct memo_operation_list *mol) +{ + struct memo_operation_list *t, *d; + + t = mol; + while(t) { + d = t; + t = t->next; + free(d); + } +} + +static void _on_data_change(keynode_t *node, void *user_data) +{ + if (g_data_monitor != NULL) { + g_data_monitor(user_data); + } +} + +MEMOAPI int memo_subscribe_change(void (*cb)(void *), void *user_data) +{ + g_data_monitor = cb; + vconf_notify_key_changed(VCONFKEY_MEMO_DATA_CHANGE, _on_data_change, user_data); + return 0; +} + +MEMOAPI int memo_unsubscribe_change(void (*cb)(void *)) +{ + vconf_ignore_key_changed(VCONFKEY_MEMO_DATA_CHANGE, _on_data_change); + g_data_monitor = NULL; + return 0; +} + +MEMOAPI void memo_begin_trans(void) +{ + trans_count++; +} + +MEMOAPI void memo_end_trans(void) +{ + int value = 0; + trans_count--; + if (trans_count == 0) { + if(vconf_get_int(VCONFKEY_MEMO_DATA_CHANGE, &value)) { + LOGD("vconf_get_int FAIL\n"); + } else { + if (value == 0) { + vconf_set_int(VCONFKEY_MEMO_DATA_CHANGE, 1); + } else { + vconf_set_int(VCONFKEY_MEMO_DATA_CHANGE, 0); + } + } + } +} + +MEMOAPI int memo_get_indexes(int *aIndex, int len, MEMO_SORT_TYPE sort) +{ + return get_indexes(db, aIndex, len, sort); +} + +MEMOAPI int memo_search_data(const char *search_str, int limit, int offset, MEMO_SORT_TYPE sort, + memo_data_iterate_cb_t cb, void *user_data) +{ + return search_data(db, search_str, limit, offset, sort, cb, user_data); +} + +MEMOAPI int memo_all_data(memo_data_iterate_cb_t cb, void *user_data) +{ + return all_data(db, cb, user_data); +} + -- 2.7.4