From 4aea6f5ede38f2d2d20a75895d9b598704fe14d0 Mon Sep 17 00:00:00 2001 From: Kibum Kim Date: Sat, 7 Jan 2012 00:42:21 +0900 Subject: Git init --- AUTHORS | 2 + CMakeLists.txt | 90 +++++++ LICENSE | 206 ++++++++++++++++ capi-social-call-log.pc.in | 15 ++ debian/README | 0 debian/capi-social-call-log-dev.install | 4 + debian/capi-social-call-log-dev.postinst | 1 + debian/capi-social-call-log.install | 1 + debian/capi-social-call-log.postinst | 1 + debian/changelog | 13 + debian/compat | 1 + debian/control | 22 ++ debian/rules | 65 +++++ include/calllog.h | 342 +++++++++++++++++++++++++++ include/calllog_private.h | 125 ++++++++++ include/calllog_types.h | 130 ++++++++++ packaging/capi-social-call-log.spec | 55 +++++ src/calllog.c | 394 +++++++++++++++++++++++++++++++ src/calllog_private.c | 105 ++++++++ 19 files changed, 1572 insertions(+) create mode 100755 AUTHORS create mode 100755 CMakeLists.txt create mode 100755 LICENSE create mode 100755 capi-social-call-log.pc.in create mode 100755 debian/README create mode 100755 debian/capi-social-call-log-dev.install create mode 100755 debian/capi-social-call-log-dev.postinst create mode 100755 debian/capi-social-call-log.install create mode 100755 debian/capi-social-call-log.postinst create mode 100644 debian/changelog create mode 100755 debian/compat create mode 100755 debian/control create mode 100755 debian/rules create mode 100755 include/calllog.h create mode 100755 include/calllog_private.h create mode 100755 include/calllog_types.h create mode 100755 packaging/capi-social-call-log.spec create mode 100755 src/calllog.c create mode 100755 src/calllog_private.c diff --git a/AUTHORS b/AUTHORS new file mode 100755 index 0000000..5ebcb3f --- /dev/null +++ b/AUTHORS @@ -0,0 +1,2 @@ +Jonghoon Lim +Jongchul Park \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100755 index 0000000..687a539 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,90 @@ + +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +SET(fw_name "capi-social-call-log") + +PROJECT(${fw_name}) + +SET(CMAKE_INSTALL_PREFIX /usr) +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) + +SET(INC_DIR include) +INCLUDE_DIRECTORIES(${INC_DIR}) + +SET(dependents "dlog contacts-service glib-2.0 capi-social-contacts") + +INCLUDE(FindPkgConfig) +pkg_check_modules(${fw_name} REQUIRED ${dependents}) +FOREACH(flag ${${fw_name}_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror") +SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") + +IF("${ARCH}" STREQUAL "arm") + ADD_DEFINITIONS("-DTARGET") +ENDIF("${ARCH}" STREQUAL "arm") + +ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") +ADD_DEFINITIONS("-DTIZEN_DEBUG") + +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib") + +aux_source_directory(src SOURCES) +ADD_LIBRARY(${fw_name} SHARED ${SOURCES}) + +TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS}) + +INSTALL(TARGETS ${fw_name} DESTINATION lib) +INSTALL( + DIRECTORY ${INC_DIR}/ DESTINATION include/social + FILES_MATCHING + PATTERN "*_private.h" EXCLUDE + PATTERN "${INC_DIR}/*.h" + ) + +SET(PC_NAME ${fw_name}) +SET(PC_REQUIRED ${dependents}) +SET(PC_LDFLAGS -l${fw_name}) +SET(PC_CFLAGS -I\${includedir}/social) + +CONFIGURE_FILE( + ${fw_name}.pc.in + ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc + @ONLY +) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION lib/pkgconfig) + +#ADD_SUBDIRECTORY(test) + +IF(UNIX) + +ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution) +ADD_CUSTOM_COMMAND( + DEPENDS clean + COMMENT "distribution clean" + COMMAND find + ARGS . + -not -name config.cmake -and \( + -name tester.c -or + -name Testing -or + -name CMakeFiles -or + -name cmake.depends -or + -name cmake.check_depends -or + -name CMakeCache.txt -or + -name cmake.check_cache -or + -name *.cmake -or + -name Makefile -or + -name core -or + -name core.* -or + -name gmon.out -or + -name install_manifest.txt -or + -name *.pc -or + -name *~ \) + | grep -v TC | xargs rm -rf + TARGET distclean + VERBATIM +) + +ENDIF(UNIX) + diff --git a/LICENSE b/LICENSE new file mode 100755 index 0000000..bbe9d02 --- /dev/null +++ b/LICENSE @@ -0,0 +1,206 @@ +Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + diff --git a/capi-social-call-log.pc.in b/capi-social-call-log.pc.in new file mode 100755 index 0000000..d48ca91 --- /dev/null +++ b/capi-social-call-log.pc.in @@ -0,0 +1,15 @@ + +# Package Information for pkg-config + +prefix=@PREFIX@ +exec_prefix=/usr +libdir=/usr/lib +includedir=/usr/include/social + +Name: @PC_NAME@ +Description: @PACKAGE_DESCRIPTION@ +Version: @VERSION@ +Requires: @PC_REQUIRED@ +Libs: -L${libdir} @PC_LDFLAGS@ +Cflags: -I${includedir} @PC_CFLAGS@ + diff --git a/debian/README b/debian/README new file mode 100755 index 0000000..e69de29 diff --git a/debian/capi-social-call-log-dev.install b/debian/capi-social-call-log-dev.install new file mode 100755 index 0000000..761a28b --- /dev/null +++ b/debian/capi-social-call-log-dev.install @@ -0,0 +1,4 @@ +/usr/include/* +/usr/include/*/* +/usr/lib/pkgconfig/*.pc + diff --git a/debian/capi-social-call-log-dev.postinst b/debian/capi-social-call-log-dev.postinst new file mode 100755 index 0000000..1a24852 --- /dev/null +++ b/debian/capi-social-call-log-dev.postinst @@ -0,0 +1 @@ +#!/bin/sh diff --git a/debian/capi-social-call-log.install b/debian/capi-social-call-log.install new file mode 100755 index 0000000..4a755a4 --- /dev/null +++ b/debian/capi-social-call-log.install @@ -0,0 +1 @@ +/usr/lib/lib*.so* diff --git a/debian/capi-social-call-log.postinst b/debian/capi-social-call-log.postinst new file mode 100755 index 0000000..1a24852 --- /dev/null +++ b/debian/capi-social-call-log.postinst @@ -0,0 +1 @@ +#!/bin/sh diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..6f24713 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,13 @@ +capi-social-call-log (0.1.1-22) unstable; urgency=low + + * version updated + * Git: api/call-log + * Tag: capi-social-call-log_0.1.1-22 + + -- Jonghoon Lim Thu, 15 Dec 2011 13:48:29 +0900 + +capi-social-call-log (0.0.1-1) unstable; urgency=low + + * Initial release. + + -- Jonghoon Lim Wed, 07 Dec 2011 12:50:23 +0900 diff --git a/debian/compat b/debian/compat new file mode 100755 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100755 index 0000000..23fa461 --- /dev/null +++ b/debian/control @@ -0,0 +1,22 @@ + +Source: capi-social-call-log +Section: libs +Priority: extra +Maintainer: Jongchul Park , Jonghoon Lim +Build-Depends: debhelper (>= 5), dlog-dev, libcontacts-service-dev, libglib2.0-dev, capi-social-contacts-dev, capi-base-common-dev + +Package: capi-social-call-log +Architecture: any +Depends: ${shilbs:Depends}, ${misc:Depends} +Description: Call log library in Tizen Native API + +Package: capi-social-call-log-dev +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, capi-social-call-log (= ${Source-Version}), dlog-dev, libcontacts-service-dev, libglib2.0-dev, capi-social-contacts-dev, capi-base-common-dev +Description: Call log library in Tizen Native API (DEV) + +Package: capi-social-call-log-dbg +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, capi-social-call-log (= ${Source-Version}) +Description: Call log library in Tizen Native API (DBG) + diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..3321e61 --- /dev/null +++ b/debian/rules @@ -0,0 +1,65 @@ +#!/usr/bin/make -f + +CFLAGS = -Wall -g + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif +CMAKE_ROOT_DIR ?= $(CURDIR) +CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp + +configure: configure-stamp +configure-stamp: + dh_testdir + mkdir -p $(CMAKE_BUILD_DIR) && cd $(CMAKE_BUILD_DIR) && cmake .. + touch configure-stamp + + +build: build-stamp +build-stamp: configure-stamp + dh_testdir + cd $(CMAKE_BUILD_DIR) && $(MAKE) + touch $@ + +clean: + cd $(CMAKE_ROOT_DIR) + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + rm -f + rm -rf $(CMAKE_BUILD_DIR) + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + cd $(CMAKE_BUILD_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install + +binary-indep: build install + +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples + dh_install --sourcedir=debian/tmp + dh_installman + dh_link + dh_strip --dbg-package=capi-social-call-log-dbg + dh_fixperms + 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/calllog.h b/include/calllog.h new file mode 100755 index 0000000..8f4d58c --- /dev/null +++ b/include/calllog.h @@ -0,0 +1,342 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef __TIZEN_CALLLOG_H__ +#define __TIZEN_CALLLOG_H__ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif +/** + * @addtogroup CAPI_SOCIAL_CALLLOG_MODULE + * @{ + */ + +/** + * @brief Opens a connection to call log service. + * + * @details Opening connection is necessary to access call log database. + * All operations like inserting, updating, and deleting call log require opened connection. + + * @remarks If the call log connection has been already established, this function will return #CALLLOG_ERROR_NONE. + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_DB_FAILED Failed to connect + * + * @see calllog_disconnect() + * + */ + +int calllog_connect(void); + +/** + * @brief Closes the connection to call log service. + * + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_DB_FAILED Database failed + * + * @see calllog_connect() + */ +int calllog_disconnect(void); + +/** + * @brief Creates a new call log handle. + * @remarks The call log handle must be released with calllog_destroy() by you. + * @remarks The created handle is not added to call log database until calllog_insert_to_db() is called. + * + * @param[out] log A new call log handle + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calllog_destroy() + * + */ +int calllog_create(calllog_h *log); + +/** + * @brief Destroys the call log handle. + * + * + * @param[in] log The call log handle + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calllog_create() + */ +int calllog_destroy(calllog_h log); + +/** + * @brief Inserts a new call log entry to the call log database. + * + * + * + * @param[in] log The call log handle + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALLLOG_ERROR_DB_FAILED Database failed + * + * @pre This function requires an open connection to call log service by calllog_connect(). + * + * @see calllog_connect() + * @see calllog_disconnect() + * @see calllog_delete_from_db() + * @see calllog_delete_all_from_db() + * + */ +int calllog_insert_to_db(calllog_h log); + +/** + * @brief Deletes the call log with given ID from the database. + * + * @param[in] calllog_db_id The database identifier of call log to delete + * + * @return 0 on success, otherwise a negative error value + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALLLOG_ERROR_DB_FAILED Database failed + * + * @pre This function requires an open connection to call log service by calllog_connect(). + * + * @see calllog_connect() + * @see calllog_disconnect() + * @see calllog_insert_to_db() + * @see calllog_delete_all_from_db() + */ +int calllog_delete_from_db(int calllog_db_id); + +/** + * @brief Deletes all the call log from the database. + * + * @return 0 on success, otherwise a negative error value + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALLLOG_ERROR_DB_FAILED Database failed + * + * @pre This function requires an open connection to call log service by calllog_connect(). + * + * @see calllog_connect() + * @see calllog_disconnect() + * @see calllog_insert_to_db() + * @see calllog_delete_from_db() + */ +int calllog_delete_all_from_db(void); + +/** + * @brief Updates the call log status of missed call from unchecked to checked. + * + * @param[in] calllog_db_id The database ID of call log to update \n + * The type of call log must be #CALLLOG_TYPE_VOICE_MISSED_UNCHECKED or #CALLLOG_TYPE_VIDEO_MISSED_UNCHECKED (If not, #CALLLOG_ERROR_INVALID_PARAMETER occurred) + * + * @return 0 on success, otherwise a negative error value + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Call log doesn't exist + * @retval #CALLLOG_ERROR_DB_FAILED Database failed + * + * @see calllog_query_calllog_by_number() + * @see calllog_set_type() + * @see calllog_get_type() + */ +int calllog_update_missed_unchecked_to_checked_to_db(int calllog_db_id); + +/** + * @brief Gets the time from the call log handle. + * + * + * @param[in] log The call log handle + * @param[out] log_time The log time in UNIX-time format + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calllog_set_time() + */ +int calllog_get_time(calllog_h log, time_t *log_time); + +/** + * @brief Sets a log time to the call log handle. + * + * + * @param[in] log The call log handle + * @param[in] log_time The log time in UNIX-time format + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calllog_get_time() + */ +int calllog_set_time(calllog_h log, time_t log_time); + +/** + * @brief Gets the log type from the call log handle. + * + * + * @param[in] log The call log handle + * @param[out] type The log type + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calllog_set_type() + */ +int calllog_get_type(calllog_h log, calllog_type_e *type); + +/** + * @brief Sets a log type to the call log handle. + * + * + * @param[in] log The call log handle + * @param[in] type The log type + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calllog_get_type() + */ +int calllog_set_type(calllog_h log, calllog_type_e type); + +/** + * @brief Gets the call duration from the call log handle. + * + * + * @param[in] log The call log handle + * @param[out] duration_sec The call duration (seconds) + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calllog_set_duration() + */ +int calllog_get_duration(calllog_h log, int *duration_sec); + +/** + * @brief Sets the call duration to the call log handle. + * + * @param[in] log The call log handle + * @param[in] duration_sec The call duration (seconds) + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calllog_get_duration() + */ +int calllog_set_duration(calllog_h log, int duration_sec); + +/** + * @brief Gets the phone number from the call log handle. + * + * @remarks @a number must be released with free() by you. + * + * @param[in] log The call log handle + * @param[out] number The phone number \n If the number does not exist, it is NULL + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calllog_set_number() + */ +int calllog_get_number(calllog_h log, char **number); + +/** + * @brief Sets the phone number to the call log handle. + * + * + * @param[in] log The call log handle + * @param[in] number The phone number + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calllog_get_number() + * + */ +int calllog_set_number(calllog_h log, const char *number); + +/** + * @brief Retrieves all call logs by invoking the given callback function iteratively. + * + * @param[in] callback The callback function + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALLLOG_ERROR_DB_FAILED Database failed + * + * @pre This function requires an open connection to call log service by calllog_connect(). + * + * @post This function invokes calllog_foreach_cb(). + * + * @see calllog_connect() + * @see calllog_foreach_cb() + * @see calllog_query_calllog_by_number() + */ +int calllog_foreach_calllog_from_db(calllog_foreach_cb callback, void *user_data); + +/** + * @brief Retrieves all call logs with the given number. + * + * @param[in] callback The callback function to invoke + * @param[in] number_to_find The number to filter + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALLLOG_ERROR_DB_FAILED Database failed + * + * @pre This function requires an open connection to call log service by calllog_connect(). + * + * @post This function invokes calllog_foreach_cb(). + * + * @see calllog_connect() + * @see calllog_foreach_cb() + * @see calllog_foreach_calllog_from_db() + */ +int calllog_query_calllog_by_number(calllog_foreach_cb callback, const char *number_to_find, void *user_data); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __CONTACTS_LOG_H__ */ + diff --git a/include/calllog_private.h b/include/calllog_private.h new file mode 100755 index 0000000..924cab8 --- /dev/null +++ b/include/calllog_private.h @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef __TIZEN_CALLLOG_PRIVATE_H__ +#define __TIZEN_CALLLOG_PRIVATE_H__ + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + * @internal + */ +typedef struct +{ + int v_type:16; + bool embedded; + bool deleted; + int id; + char *number; + int related_id; /* contact id */ + int log_time; + int calllog_type; + int extra_data1; /* duration, message_id */ + char *extra_data2; /*short message*/ +} _calllog_s;//CTS_PLOG_VAL_ + + +/** + * @internal + * @brief Retrieves the detailed information of each call log in the call log database. + * @details Retrieves just one call log for each phone number. + * If you want to get all the information for the number you can use calllog_query_calllog_by_number(). + * + * @param[in] callback The callback function + * @param[in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALLLOG_ERROR_DB_FAILED Database failed + * + * @pre This function requires an open connection to call log service by calllog_connect(). + * + * @post This function invokes calllog_foreach_cb(). + * + * @see calllog_connect() + * @see calllog_query_calllog_by_number() + */ +int _calllog_foreach_calllog_grouped_from_db(calllog_foreach_cb callback, void *user_data); + + +/** + * @internal + * @brief Gets the short message from the call log handle. + * + * @remarks @a shortmsg must be released with free() by you. + * + * @param[in] log The call log handle + * @param[out] shortmsg The short message to get + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALLLOG_ERROR_NO_DATA Data not found + * + * @see #calllog_h + * @see calllog_set_shortmsg() + */ +int _calllog_get_shortmsg(calllog_h log, char **shortmsg); + +/** + * @internal + * @brief Sets a short message to the call log handle. + * + * + * @param[in] log The call log handle + * @param[in] shortmsg The short message to set + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALLLOG_ERROR_NONE Successful + * @retval #CALLLOG_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calllog_h + * @see calllog_get_shortmsg() + */ +int _calllog_set_shortmsg(calllog_h log, const char *shortmsg); + + + + +#define _calllog_safe_free(_srcx_) { if(NULL != _srcx_) free(_srcx_); } +#define _calllog_safe_strdup(_srcx_) (NULL != _srcx_) ? strdup(_srcx_):NULL +#define _calllog_safe_str(_srcx_) (NULL != _srcx_) ? _srcx_:"" + +#define _calllog_free_strdup(_desty_, _srcx_) \ + { \ + if(_desty_) { free(_desty_); _desty_=NULL; }\ + if(_srcx_) _desty_ = strdup(_srcx_); \ + } + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CALLLOG_H__ */ + diff --git a/include/calllog_types.h b/include/calllog_types.h new file mode 100755 index 0000000..c919107 --- /dev/null +++ b/include/calllog_types.h @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef __TIZEN_CALLLOG_TYPE_H__ +#define __TIZEN_CALLLOG_TYPE_H__ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/** + * @addtogroup CAPI_SOCIAL_CALLLOG_MODULE + * @{ + */ + +/** + * @brief Enumerations for call log error. + */ +typedef enum +{ + CALLLOG_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + CALLLOG_ERROR_DB_FAILED = TIZEN_ERROR_SOCIAL_CLASS | 0x32, /**< Database operation failure */ + CALLLOG_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + CALLLOG_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + CALLLOG_ERROR_NO_DATA = TIZEN_ERROR_SOCIAL_CLASS | 0x33, /**< Requested data does not exist */ +} calllog_error_e; + +/** + * @brief Enumerations for call log types. + */ +typedef enum +{ + CALLLOG_TYPE_VOICE_ANSWERED = 1, /**< Incoming voice answered call log */ + CALLLOG_TYPE_VOICE_OUTGOING = 2, /**< Outgoing voice call log */ + CALLLOG_TYPE_VOICE_MISSED_UNCHECKED = 5, /**< Unchecked log of incoming missed voice call */ + CALLLOG_TYPE_VOICE_MISSED_CHECKED = 6, /**< Already checked log of incoming missed voice call */ + CALLLOG_TYPE_VOICE_REJECTED = 9, /**< Rejected voice call log */ + CALLLOG_TYPE_VOICE_BLOCKED = 11, /**< Blocked voice call log */ + + CALLLOG_TYPE_VIDEO_ANSWERED = 3, /**< Incoming video answered call log */ + CALLLOG_TYPE_VIDEO_OUTGOING = 4, /**< Outgoing video call log */ + CALLLOG_TYPE_VIDEO_MISSED_UNCHECKED = 7, /**< Unchecked log of incoming missed video call */ + CALLLOG_TYPE_VIDEO_MISSED_CHECKED = 8, /**< Already checked log of incoming missed video call */ + CALLLOG_TYPE_VIDEO_REJECTED = 10, /**< Rejected video call log */ + CALLLOG_TYPE_VIDEO_BLOCKED = 12, /**< Blocked video call log */ + + CALLLOG_TYPE_SMS_INCOMING = 103, /**< Incoming SMS log */ + CALLLOG_TYPE_SMS_OUTGOING = 104, /**< Outgoing SMS log */ + CALLLOG_TYPE_SMS_BLOCKED = 105, /**< Blocked SMS log */ + + CALLLOG_TYPE_MMS_INCOMING = 101, /**< Incoming MMS log */ + CALLLOG_TYPE_MMS_OUTGOING = 102, /**< Outgoing MMS log */ + CALLLOG_TYPE_MMS_BLOCKED = 106, /**< Blocked MMS log */ +} calllog_type_e; + +/** + * @brief The call log handle. + */ +typedef struct _calllog_s* calllog_h; + +/** + * @brief The structure of log entry in search results. + * + * @details This structure is passed to callback function in all log related + * iterations through list received from search functions. + * + * @see calllog_foreach_cb() + */ +typedef struct +{ + int calllog_db_id; /**< Call log entry id */ + calllog_type_e calllog_type; /**< Call log entry type */ + int contact_db_id; /**< Contact's id in database */ + char* first_name; /**< Contact's first name (also known as given name) */ + char* last_name; /**< Contact's last name (also known as family name) */ + char* display_name; /**< Display name (how contact's name should be presented) */ + char* contact_image_path; /**< Path to image with contact's picture */ + contact_number_type_e phone_number_type; /**< Phone number type (i.e.: work, cell) */ + char* phone_number; /**< Phone number */ + char* short_message; /**< Short message for this log */ + time_t timestamp; /**< Timestamp of this change */ + int duration_sec; /**< Duration (in seconds) for call logs */ +} calllog_query_detail_s; + +/** + * @brief The callback function to get call log details for each found call log. + * + * @param[in] query_log The log information + * @param[in] user_data The user data passed from the foreach function + * + * @return @c true to continue with the next iteration of the loop or @c false to break out of the loop. + * + * @pre Either calllog_foreach_calllog_from_db() or calllog_query_calllog_by_number() will invoke this callback. + * + * @see calllog_foreach_calllog_from_db() + * @see calllog_query_calllog_by_number() + */ +typedef bool (*calllog_foreach_cb)(calllog_query_detail_s *query_log, void *user_data); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __CALLLOG_H__ */ + diff --git a/packaging/capi-social-call-log.spec b/packaging/capi-social-call-log.spec new file mode 100755 index 0000000..1d8a9da --- /dev/null +++ b/packaging/capi-social-call-log.spec @@ -0,0 +1,55 @@ +Name: capi-social-call-log +Summary: Call log library in Tizen Native API +Version: 0.0.1 +Release: 1 +Group: TO_BE/FILLED_IN +License: TO BE FILLED IN +Source0: %{name}-%{version}.tar.gz +BuildRequires: cmake +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(contacts-service) +BuildRequires: pkgconfig(capi-social-contacts) +BuildRequires: pkgconfig(capi-base-common) +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig + +%description + + +%package devel +Summary: Call log library in Tizen Native API (Development) +Group: TO_BE/FILLED_IN +Requires: %{name} = %{version}-%{release} + +%description devel + + + +%prep +%setup -q + + +%build +cmake . -DCMAKE_INSTALL_PREFIX=/usr + + +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + + +%files +%{_libdir}/libcapi-social-call-log.so + +%files devel +%{_includedir}/social/*.h +%{_libdir}/pkgconfig/*.pc + + diff --git a/src/calllog.c b/src/calllog.c new file mode 100755 index 0000000..7ca5855 --- /dev/null +++ b/src/calllog.c @@ -0,0 +1,394 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include +#include +#include +#include +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "TIZEN_N_CALLLOG" +#define LOG_MODE (1) + +int calllog_connect(void) +{ + if(contacts_svc_connect() == CTS_SUCCESS) { + return CALLLOG_ERROR_NONE; + } + LOGE("[%s] CALLLOG_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALLLOG_ERROR_DB_FAILED); + return CALLLOG_ERROR_DB_FAILED; +} + +int calllog_disconnect(void) +{ + if(contacts_svc_disconnect() == CTS_SUCCESS) { + return CALLLOG_ERROR_NONE; + } + LOGE("[%s] CALLLOG_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALLLOG_ERROR_DB_FAILED); + return CALLLOG_ERROR_DB_FAILED; +} + +int calllog_create(calllog_h* log) +{ + if(log == NULL) { + LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER); + return CALLLOG_ERROR_INVALID_PARAMETER; + } + CTSvalue* value = contacts_svc_value_new(CTS_VALUE_PHONELOG); + if(value == NULL) { + LOGE("[%s] CALLLOG_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CALLLOG_ERROR_OUT_OF_MEMORY); + return CALLLOG_ERROR_OUT_OF_MEMORY; + } + *log = (calllog_h)value; + return CALLLOG_ERROR_NONE; +} + +int calllog_destroy(calllog_h log) +{ + if(log == NULL) { + LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER); + return CALLLOG_ERROR_INVALID_PARAMETER; + } + if(contacts_svc_value_free((CTSvalue*)log) == CTS_SUCCESS) { + return CALLLOG_ERROR_NONE; + } + LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER); + return CALLLOG_ERROR_INVALID_PARAMETER; +} + +int calllog_insert_to_db(calllog_h log) +{ + if(log == NULL) { + LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER); + return CALLLOG_ERROR_INVALID_PARAMETER; + } + if(contacts_svc_insert_phonelog((CTSvalue*)log) == CTS_SUCCESS) { + return CALLLOG_ERROR_NONE; + } + LOGE("[%s] CALLLOG_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALLLOG_ERROR_DB_FAILED); + return CALLLOG_ERROR_DB_FAILED; +} + +int calllog_delete_from_db(int calllog_db_id) +{ + if(calllog_db_id < 0) { + LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER); + return CALLLOG_ERROR_INVALID_PARAMETER; + } + if(contacts_svc_delete_phonelog(CTS_PLOG_DEL_BY_ID, calllog_db_id) == CTS_SUCCESS) { + return CALLLOG_ERROR_NONE; + } + LOGE("[%s] CALLLOG_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALLLOG_ERROR_DB_FAILED); + return CALLLOG_ERROR_DB_FAILED; +} + +int calllog_delete_all_from_db() +{ + CTSiter *iter = NULL; + if(CTS_SUCCESS != contacts_svc_get_list(CTS_LIST_ALL_PLOG, &iter)) { + LOGE("[%s] CALLLOG_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALLLOG_ERROR_DB_FAILED); + return CALLLOG_ERROR_DB_FAILED; + } + + // get count + int count = 0; + while(CTS_SUCCESS == contacts_svc_iter_next(iter)) { + CTSvalue* foreach_data = contacts_svc_iter_get_info(iter); + if(foreach_data == NULL) + break; + count++; + contacts_svc_value_free(foreach_data); + } + contacts_svc_iter_remove(iter); + + if(count == 0) { + return CALLLOG_ERROR_NONE; + } + + // create id list + iter = NULL; + if(CTS_SUCCESS != contacts_svc_get_list(CTS_LIST_ALL_PLOG, &iter)) { + LOGE("[%s] CALLLOG_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALLLOG_ERROR_DB_FAILED); + return CALLLOG_ERROR_DB_FAILED; + } + int *id_list = NULL; + int i = 0; + id_list = calloc(count, sizeof(int)); + if(id_list == NULL) { + LOGE("[%s] CALLLOG_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CALLLOG_ERROR_OUT_OF_MEMORY); + return CALLLOG_ERROR_OUT_OF_MEMORY; + } + while(CTS_SUCCESS == contacts_svc_iter_next(iter)) { + CTSvalue* foreach_data = contacts_svc_iter_get_info(iter); + if(foreach_data == NULL) + break; + id_list[i] = contacts_svc_value_get_int(foreach_data, CTS_LIST_PLOG_ID_INT); + contacts_svc_value_free(foreach_data); + i++; + } + contacts_svc_iter_remove(iter); + + // delete all call log + for(i=0; icalllog_type) < 0) { + contacts_svc_value_free(phonelog); + contacts_svc_disconnect(); + LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER); + return CALLLOG_ERROR_INVALID_PARAMETER; + } + + contacts_svc_value_free(phonelog); + contacts_svc_disconnect(); + return CALLLOG_ERROR_NONE; +} + +int calllog_get_time(calllog_h log, time_t* log_time) +{ + if(log == NULL || time == NULL) { + LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER); + return CALLLOG_ERROR_INVALID_PARAMETER; + } + CTSvalue * CTSlog = (CTSvalue *)log; + *log_time=(time_t)contacts_svc_value_get_int(CTSlog, CTS_PLOG_VAL_LOG_TIME_INT); + return CALLLOG_ERROR_NONE; +} + +int calllog_set_time(calllog_h log, time_t log_time) +{ + if(log == NULL) { + LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER); + return CALLLOG_ERROR_INVALID_PARAMETER; + } + CTSvalue * CTSlog = (CTSvalue *)log; + if(contacts_svc_value_set_int(CTSlog,CTS_PLOG_VAL_LOG_TIME_INT, (int)log_time) == CTS_SUCCESS) { + return CALLLOG_ERROR_NONE; + } + LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER); + return CALLLOG_ERROR_INVALID_PARAMETER; +} + + +int calllog_get_type(calllog_h log, calllog_type_e* type) +{ + if(log == NULL || type == NULL) { + LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER); + return CALLLOG_ERROR_INVALID_PARAMETER; + } + CTSvalue * CTSlog = (CTSvalue *)log; + * type=contacts_svc_value_get_int(CTSlog,CTS_PLOG_VAL_LOG_TYPE_INT); + return CALLLOG_ERROR_NONE; +} + +int calllog_set_type(calllog_h log, calllog_type_e type) +{ + if(log == NULL) { + LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER); + return CALLLOG_ERROR_INVALID_PARAMETER; + } + CTSvalue * CTSlog = (CTSvalue *)log; + + if(contacts_svc_value_set_int(CTSlog,CTS_PLOG_VAL_LOG_TYPE_INT,type) == CTS_SUCCESS) { + return CALLLOG_ERROR_NONE; + } + LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER); + return CALLLOG_ERROR_INVALID_PARAMETER; +} + + +int calllog_get_duration(calllog_h log, int* duration_sec) +{ + if(log == NULL || duration_sec == NULL) { + LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER); + return CALLLOG_ERROR_INVALID_PARAMETER; + } + CTSvalue * CTSlog = (CTSvalue *)log; + *duration_sec=contacts_svc_value_get_int(CTSlog,CTS_PLOG_VAL_DURATION_INT); + return CALLLOG_ERROR_NONE; +} + +int calllog_set_duration(calllog_h log, int duration_sec) +{ + if(log == NULL) { + LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER); + return CALLLOG_ERROR_INVALID_PARAMETER; + } + CTSvalue * CTSlog = (CTSvalue *)log; + if(contacts_svc_value_set_int(CTSlog,CTS_PLOG_VAL_DURATION_INT,duration_sec) == CTS_SUCCESS) { + return CALLLOG_ERROR_NONE; + } + LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER); + return CALLLOG_ERROR_INVALID_PARAMETER; +} + +int calllog_get_number(calllog_h log, char** number) +{ + if(log == NULL || number == NULL) { + LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER); + return CALLLOG_ERROR_INVALID_PARAMETER; + } + *number = NULL; + *number = _calllog_safe_strdup(((_calllog_s*)log)->number); + + return CALLLOG_ERROR_NONE; +} + +int calllog_set_number(calllog_h log, const char* number) +{ + if(log == NULL || number == NULL) { + LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER); + return CALLLOG_ERROR_INVALID_PARAMETER; + } + CTSvalue * CTSlog = (CTSvalue *)log; + + if(contacts_svc_value_set_str(CTSlog,CTS_PLOG_VAL_NUMBER_STR,number) == CTS_SUCCESS) { + return CALLLOG_ERROR_NONE; + } + LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER); + return CALLLOG_ERROR_INVALID_PARAMETER; +} + +int calllog_foreach_calllog_from_db(calllog_foreach_cb cb, void *user_data) +{ + if(cb == NULL) { + LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER); + return CALLLOG_ERROR_INVALID_PARAMETER; + } + CTSiter *iter = NULL; + int func_ret = 0; + if(CTS_SUCCESS != contacts_svc_get_list(CTS_LIST_ALL_PLOG, &iter)) { + LOGE("[%s] CALLLOG_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALLLOG_ERROR_DB_FAILED); + return CALLLOG_ERROR_DB_FAILED; + } + + while(CTS_SUCCESS == contacts_svc_iter_next(iter)) { + CTSvalue* foreach_data = contacts_svc_iter_get_info(iter); + if(foreach_data == NULL) + break; + + calllog_query_detail_s query_data; + query_data.calllog_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_PLOG_ID_INT); + query_data.calllog_type = contacts_svc_value_get_int(foreach_data, CTS_LIST_PLOG_LOG_TYPE_INT); + query_data.contact_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_PLOG_RELATED_ID_INT); + query_data.first_name = _calllog_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_PLOG_FIRST_NAME_STR)); + query_data.last_name = _calllog_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_PLOG_LAST_NAME_STR)); + query_data.display_name = _calllog_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_PLOG_DISPLAY_NAME_STR)); + query_data.contact_image_path = _calllog_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_PLOG_IMG_PATH_STR)); + query_data.phone_number_type = contacts_svc_value_get_int(foreach_data, CTS_LIST_PLOG_NUM_TYPE_INT); + query_data.phone_number = _calllog_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_PLOG_NUMBER_STR)); + query_data.short_message = _calllog_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_PLOG_SHORTMSG_STR)); + query_data.timestamp = (time_t)contacts_svc_value_get_int(foreach_data, CTS_LIST_PLOG_LOG_TIME_INT); + query_data.duration_sec = contacts_svc_value_get_int(foreach_data, CTS_LIST_PLOG_DURATION_INT); + + func_ret = cb(&query_data, user_data); + + contacts_svc_value_free(foreach_data); + + _calllog_safe_free(query_data.first_name); + _calllog_safe_free(query_data.last_name); + _calllog_safe_free(query_data.display_name); + _calllog_safe_free(query_data.contact_image_path); + _calllog_safe_free(query_data.phone_number); + _calllog_safe_free(query_data.short_message); + } + + contacts_svc_iter_remove(iter); + return CALLLOG_ERROR_NONE; +} + +int calllog_query_calllog_by_number(calllog_foreach_cb cb, const char* number_to_find, void* user_data) +{ + if(cb == NULL || number_to_find == NULL) { + LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER); + return CALLLOG_ERROR_INVALID_PARAMETER; + } + CTSiter *iter = NULL; + int func_ret = 0; + if(CTS_SUCCESS != contacts_svc_get_list_with_str(CTS_LIST_PLOGS_OF_NUMBER, number_to_find, &iter)) { + LOGE("[%s] CALLLOG_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALLLOG_ERROR_DB_FAILED); + return CALLLOG_ERROR_DB_FAILED; + } + + while(CTS_SUCCESS == contacts_svc_iter_next(iter)) { + CTSvalue* foreach_data = contacts_svc_iter_get_info(iter); + if(foreach_data == NULL) + break; + + calllog_query_detail_s query_data; + query_data.calllog_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_PLOG_ID_INT); + query_data.calllog_type = contacts_svc_value_get_int(foreach_data, CTS_LIST_PLOG_LOG_TYPE_INT); + query_data.contact_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_PLOG_RELATED_ID_INT); + query_data.first_name = _calllog_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_PLOG_FIRST_NAME_STR)); + query_data.last_name = _calllog_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_PLOG_LAST_NAME_STR)); + query_data.display_name = _calllog_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_PLOG_DISPLAY_NAME_STR)); + query_data.contact_image_path = _calllog_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_PLOG_IMG_PATH_STR)); + query_data.phone_number_type = contacts_svc_value_get_int(foreach_data, CTS_LIST_PLOG_NUM_TYPE_INT); + query_data.phone_number = _calllog_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_PLOG_NUMBER_STR)); + query_data.short_message = _calllog_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_PLOG_SHORTMSG_STR)); + query_data.timestamp = (time_t)contacts_svc_value_get_int(foreach_data, CTS_LIST_PLOG_LOG_TIME_INT); + query_data.duration_sec = contacts_svc_value_get_int(foreach_data, CTS_LIST_PLOG_DURATION_INT); + + func_ret = cb(&query_data, user_data); + + contacts_svc_value_free(foreach_data); + + _calllog_safe_free(query_data.first_name); + _calllog_safe_free(query_data.last_name); + _calllog_safe_free(query_data.display_name); + _calllog_safe_free(query_data.contact_image_path); + _calllog_safe_free(query_data.phone_number); + _calllog_safe_free(query_data.short_message); + } + + contacts_svc_iter_remove(iter); + return CALLLOG_ERROR_NONE; +} + + + diff --git a/src/calllog_private.c b/src/calllog_private.c new file mode 100755 index 0000000..3a0c096 --- /dev/null +++ b/src/calllog_private.c @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "TIZEN_N_CALLLOG" +#define LOG_MODE (1) + +int _calllog_foreach_calllog_grouped_from_db(calllog_foreach_cb cb, void* user_data) +{ + if(cb == NULL) { + LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER); + return CALLLOG_ERROR_INVALID_PARAMETER; + } + CTSiter *iter = NULL; + int func_ret = 0; + if(CTS_SUCCESS != contacts_svc_get_list(CTS_LIST_GROUPING_CALL_PLOG, &iter)) { + LOGE("[%s] CALLLOG_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALLLOG_ERROR_DB_FAILED); + return CALLLOG_ERROR_DB_FAILED; + } + + while(CTS_SUCCESS == contacts_svc_iter_next(iter)) { + CTSvalue* foreach_data = contacts_svc_iter_get_info(iter); + if(foreach_data == NULL) + break; + + calllog_query_detail_s query_data; + query_data.calllog_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_PLOG_ID_INT); + query_data.calllog_type = contacts_svc_value_get_int(foreach_data, CTS_LIST_PLOG_LOG_TYPE_INT); + query_data.contact_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_PLOG_RELATED_ID_INT); + query_data.first_name = _calllog_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_PLOG_FIRST_NAME_STR)); + query_data.last_name = _calllog_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_PLOG_LAST_NAME_STR)); + query_data.display_name = _calllog_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_PLOG_DISPLAY_NAME_STR)); + query_data.contact_image_path = _calllog_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_PLOG_IMG_PATH_STR)); + query_data.phone_number_type = contacts_svc_value_get_int(foreach_data, CTS_LIST_PLOG_NUM_TYPE_INT); + query_data.phone_number = _calllog_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_PLOG_NUMBER_STR)); + query_data.short_message = _calllog_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_PLOG_SHORTMSG_STR)); + query_data.timestamp = (time_t)contacts_svc_value_get_int(foreach_data, CTS_LIST_PLOG_LOG_TIME_INT); + query_data.duration_sec = contacts_svc_value_get_int(foreach_data, CTS_LIST_PLOG_DURATION_INT); + + func_ret = cb(&query_data, user_data); + + contacts_svc_value_free(foreach_data); + + _calllog_safe_free(query_data.first_name); + _calllog_safe_free(query_data.last_name); + _calllog_safe_free(query_data.display_name); + _calllog_safe_free(query_data.contact_image_path); + _calllog_safe_free(query_data.phone_number); + _calllog_safe_free(query_data.short_message); + } + + contacts_svc_iter_remove(iter); + return CALLLOG_ERROR_NONE; +} + +int _calllog_get_shortmsg(calllog_h log, char** shortmsg) +{ + if(log == NULL || shortmsg == NULL) { + LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER); + return CALLLOG_ERROR_INVALID_PARAMETER; + } + *shortmsg = _calllog_safe_strdup(((_calllog_s*)log)->extra_data2); + if(*shortmsg == NULL) { + LOGE("[%s] CALLLOG_ERROR_NO_DATA(0x%08x)", __FUNCTION__, CALLLOG_ERROR_NO_DATA); + return CALLLOG_ERROR_NO_DATA; + } + + return CALLLOG_ERROR_NONE; +} + +int _calllog_set_shortmsg(calllog_h log, const char* shortmsg) +{ + if(log == NULL || shortmsg == NULL) { + LOGE("[%s] CALLLOG_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALLLOG_ERROR_INVALID_PARAMETER); + return CALLLOG_ERROR_INVALID_PARAMETER; + } + CTSvalue * CTSlog = (CTSvalue *)log; + ((_calllog_s*)CTSlog)->extra_data2 = (char*)shortmsg; + return CALLLOG_ERROR_NONE; +} + -- cgit v1.2.3