diff options
author | Yeongil Jang <yg0577.jang@samsung.com> | 2012-09-21 00:19:43 +0900 |
---|---|---|
committer | Yeongil Jang <yg0577.jang@samsung.com> | 2012-09-21 00:19:43 +0900 |
commit | 6d5a5230487644957ac52c689af2395c3267338a (patch) | |
tree | 2b233f37b8629da2893cf09ce5dd0262e337c1e9 | |
parent | a51a532adbad8e61d9917d43a98a73a5dea67a83 (diff) | |
download | calendar-2.0alpha.tar.gz calendar-2.0alpha.tar.bz2 calendar-2.0alpha.zip |
2.0_alpha release commitHEADsubmit/master/20120920.1528342.0_alphamaster2.0alpha
33 files changed, 10448 insertions, 2113 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a852fc9..3d4b065 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ 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 "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") IF("${ARCH}" STREQUAL "arm") @@ -67,10 +67,10 @@ IF(UNIX) ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution) ADD_CUSTOM_COMMAND( - DEPENDS clean + DEPENDS clean COMMENT "distribution clean" COMMAND find - ARGS . + ARGS ${CMAKE_CURRENT_SOURCE_DIR} -not -name config.cmake -and \( -name tester.c -or -name Testing -or diff --git a/TC/_export_env.sh b/TC/_export_env.sh new file mode 100755 index 0000000..72a11ec --- /dev/null +++ b/TC/_export_env.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +. ./config +export TET_INSTALL_PATH=$TET_INSTALL_HOST_PATH # tetware root path +export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target # tetware target path +export PATH=$TET_TARGET_PATH/bin:$PATH +export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH +export TET_ROOT=$TET_TARGET_PATH diff --git a/TC/_export_target_env.sh b/TC/_export_target_env.sh new file mode 100755 index 0000000..5ddaa53 --- /dev/null +++ b/TC/_export_target_env.sh @@ -0,0 +1,7 @@ +#!/bin/sh +. ./config +export TET_INSTALL_PATH=$TET_INSTALL_TARGET_PATH # path to path +export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target +export PATH=$TET_TARGET_PATH/bin:$PATH +export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH +export TET_ROOT=$TET_TARGET_PATH diff --git a/TC/build.sh b/TC/build.sh new file mode 100755 index 0000000..6be8d56 --- /dev/null +++ b/TC/build.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +. ./_export_env.sh # setting environment variables + +export TET_SUITE_ROOT=`pwd` +FILE_NAME_EXTENSION=`date +%s` + +RESULT_DIR=results +HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html +JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal + +mkdir -p $RESULT_DIR + +tcc -c -p ./ +tcc -b -j $JOURNAL_RESULT -p ./ +grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
\ No newline at end of file diff --git a/TC/clean.sh b/TC/clean.sh new file mode 100755 index 0000000..29743e0 --- /dev/null +++ b/TC/clean.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +. ./_export_env.sh # setting environment variables + +export TET_SUITE_ROOT=`pwd` +RESULT_DIR=results + +tcc -c -p ./ # executing tcc, with clean option (-c) +rm -r $RESULT_DIR +rm -r tet_tmp_dir +rm testcase/tet_captured diff --git a/TC/config.default b/TC/config.default new file mode 100755 index 0000000..04684f0 --- /dev/null +++ b/TC/config.default @@ -0,0 +1,2 @@ +TET_INSTALL_HOST_PATH=/home/rookiejava/dts_tool/TETware +TET_INSTALL_TARGET_PATH=/mnt/nfs/dts_tool/TETware diff --git a/TC/execute.sh b/TC/execute.sh new file mode 100755 index 0000000..215ad6c --- /dev/null +++ b/TC/execute.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +. ./_export_target_env.sh # setting environment variables + +export TET_SUITE_ROOT=`pwd` +FILE_NAME_EXTENSION=`date +%s` + +RESULT_DIR=results +HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html +JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal + +mkdir -p $RESULT_DIR + +tcc -e -j $JOURNAL_RESULT -p ./ +#grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT +grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT + diff --git a/TC/testcase/Makefile b/TC/testcase/Makefile new file mode 100755 index 0000000..f5aa3fb --- /dev/null +++ b/TC/testcase/Makefile @@ -0,0 +1,25 @@ +CC ?= gcc + +C_FILES = $(shell ls *.c) + +PKGS = capi-social-calendar dlog glib-2.0 capi-social-contacts + +LDFLAGS = `pkg-config --libs $(PKGS)` +LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o +LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s +LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s + +CFLAGS = -I. `pkg-config --cflags $(PKGS)` +CFLAGS += -I$(TET_ROOT)/inc/tet3 +CFLAGS += -Wall + +#TARGETS = $(C_FILES:%.c=tc-%) +TCS := $(shell ls -1 *.c | cut -d. -f1) + +all: $(TCS) + +%: %.c + $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) + +clean: + rm -f $(TCS) diff --git a/TC/testcase/tslist b/TC/testcase/tslist new file mode 100755 index 0000000..1c3dbde --- /dev/null +++ b/TC/testcase/tslist @@ -0,0 +1,5 @@ +/testcase/utc_social_calendar +/testcase/utc_social_calendar_attendee +/testcase/utc_social_calendar_event +/testcase/utc_social_calendar_todo + diff --git a/TC/testcase/utc_social_calendar.c b/TC/testcase/utc_social_calendar.c new file mode 100755 index 0000000..1adb42e --- /dev/null +++ b/TC/testcase/utc_social_calendar.c @@ -0,0 +1,839 @@ +/* + * 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 <tet_api.h> +#include <social/calendar.h> + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +#define API_NAME_CALENDAR_CONNECT "calendar_connect" +#define API_NAME_CALENDAR_DISCONNECT "calendar_disconnect" +#define API_NAME_CALENDAR_ADD_DB_CHANGED_CB "calendar_add_db_changed_cb" +#define API_NAME_CALENDAR_FOREACH_TIMEZONE "calendar_foreach_timezone" +#define API_NAME_CALENDAR_FOREACH_CALENDAR_FROM_DB "calendar_foreach_calendar_book_from_db" +#define API_NAME_CALENDAR_BOOK_CREATE "calendar_book_create" +#define API_NAME_CALENDAR_BOOK_DESTROY "calendar_book_destroy" +#define API_NAME_CALENDAR_BOOK_INSERT_TO_DB "calendar_book_insert_to_db" +#define API_NAME_CALENDAR_BOOK_UPDATE_TO_DB "calendar_book_update_to_db" +#define API_NAME_CALENDAR_BOOK_DELETE_FROM_DB "calendar_book_delete_from_db" +#define API_NAME_CALENDAR_BOOK_GET_FROM_DB "calendar_book_get_from_db" +#define API_NAME_CALENDAR_BOOK_DELETE_ALL_BY_ACCOUNT "calendar_book_delete_all_by_account" +#define API_NAME_CALENDAR_BOOK_GET_DB_ID "calendar_book_get_db_id" +#define API_NAME_CALENDAR_BOOK_GET_IS_DEFAULT "calendar_book_get_is_default" +#define API_NAME_CALENDAR_BOOK_SET_NAME "calendar_book_set_name" +#define API_NAME_CALENDAR_BOOK_GET_NAME "calendar_book_get_name" +#define API_NAME_CALENDAR_BOOK_SET_IS_VISIBLE "calendar_book_set_is_visibile" +#define API_NAME_CALENDAR_BOOK_GET_IS_VISIBLE "calendar_book_get_is_visibile" +#define API_NAME_CALENDAR_BOOK_SET_COLOR "calendar_book_set_color" +#define API_NAME_CALENDAR_BOOK_GET_COLOR "calendar_book_get_color" +#define API_NAME_CALENDAR_BOOK_SET_ACCOUNT_DB_ID "calendar_book_set_account_db_id" +#define API_NAME_CALENDAR_BOOK_GET_ACCOUNT_DB_ID "calendar_book_get_account_db_id" +#define API_NAME_CALENDAR_BOOK_FREE_CALENDAR_BOOK_ARRAY "calendar_book_free_calendar_book_array" +#define API_NAME_CALENDAR_BOOK_GET_ALL_CALENDAR_BOOK "calendar_book_get_all_calendar_book" +#define API_NAME_CALENDAR_BOOK_SEARCH_CALENDAR_BOOK_BY_ACCOUNT "calendar_book_search_calendar_book_by_account" + +#define API_NAME_CALENDAR_ADD_DB_CHANGED_CB "calendar_add_db_changed_cb" +#define API_NAME_CALENDAR_REMOVE_DB_CHANGED_CB "calendar_remove_db_changed_cb" +#define API_NAME_CALENDAR_GET_DB_VERSION "calendar_get_db_version" + +#define API_NAME_CALENDAR_BOOK_UNSET_COLOR "calendar_book_unset_color" + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_social_calendar_calendar_connect_disconnect_p(void); +static void utc_social_calendar_calendar_set_unset_db_changed_cb_p(void); +static void utc_social_calendar_calendar_set_unset_db_changed_cb_n(void); +//static void utc_social_calendar_foreach_timezone_p(void); +//static void utc_social_calendar_foreach_timezone_n(void); +//static void utc_social_calendar_foreach_calendar_book_from_db_p(void); +//static void utc_social_calendar_foreach_calendar_book_from_db_n(void); +static void utc_social_calendar_book_create_p(void); +static void utc_social_calendar_book_create_n(void); +static void utc_social_calendar_book_destroy_p(void); +static void utc_social_calendar_book_destroy_n(void); +static void utc_social_calendar_book_insert_to_db_p(void); +static void utc_social_calendar_book_get_is_default_n(void); +static void utc_social_calendar_book_get_name_n(void); +static void utc_social_calendar_book_get_is_visible_n(void); +static void utc_social_calendar_book_get_color_n(void); +static void utc_social_calendar_book_get_account_db_id_n(void); +static void utc_social_calendar_book_get_all_calendar_book_n(void); +static void utc_social_calendar_book_search_calendar_book_by_account_n(void); +static void utc_social_calendar_book_free_calendar_book_array_n(void); + +static void utc_social_calendar_add_db_changed_cb_p(void); +static void utc_social_calendar_add_db_changed_cb_n(void); +static void utc_social_calendar_remove_db_changed_cb_p(void); +static void utc_social_calendar_remove_db_changed_cb_n(void); +static void utc_social_calendar_get_db_version_p(void); +static void utc_social_calendar_get_db_version_n(void); + +static void utc_social_calendar_book_unset_color_p(void); +static void utc_social_calendar_book_unset_color_n(void); + +struct tet_testlist tet_testlist[] = { + { utc_social_calendar_calendar_connect_disconnect_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_set_unset_db_changed_cb_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_set_unset_db_changed_cb_n, NEGATIVE_TC_IDX }, +// { utc_social_calendar_foreach_timezone_p, POSITIVE_TC_IDX }, // TOREM +// { utc_social_calendar_foreach_timezone_n, NEGATIVE_TC_IDX }, // TOREM +// { utc_social_calendar_foreach_calendar_book_from_db_p, POSITIVE_TC_IDX }, +// { utc_social_calendar_foreach_calendar_book_from_db_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_book_create_p, POSITIVE_TC_IDX }, + { utc_social_calendar_book_create_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_book_destroy_p, POSITIVE_TC_IDX }, + { utc_social_calendar_book_destroy_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_book_insert_to_db_p, POSITIVE_TC_IDX }, + { utc_social_calendar_book_get_is_default_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_book_get_name_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_book_get_is_visible_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_book_get_color_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_book_get_account_db_id_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_book_get_all_calendar_book_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_book_search_calendar_book_by_account_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_book_free_calendar_book_array_n, NEGATIVE_TC_IDX }, + + { utc_social_calendar_add_db_changed_cb_p, POSITIVE_TC_IDX }, + { utc_social_calendar_add_db_changed_cb_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_remove_db_changed_cb_p, POSITIVE_TC_IDX }, + { utc_social_calendar_remove_db_changed_cb_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_get_db_version_p, POSITIVE_TC_IDX }, + { utc_social_calendar_get_db_version_n, NEGATIVE_TC_IDX }, + + { utc_social_calendar_book_unset_color_p, POSITIVE_TC_IDX }, + { utc_social_calendar_book_unset_color_n, NEGATIVE_TC_IDX }, + + { NULL, 0 }, +}; + +static void startup(void) +{ + int ret; + ret = calendar_connect(); + if (ret < 0) + dts_message(__func__, "calendar_connect failed(%d)", ret); +} + +static void cleanup(void) +{ + int ret; + ret = calendar_disconnect(); + if (ret < 0) + dts_message(__func__, "calendar_disconnect failed(%d)", ret); +} + +void _calendar_db_changed_cb(void* user_date) +{ + +} + +static void utc_social_calendar_calendar_connect_disconnect_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + if((ret = calendar_connect()) == CALENDAR_ERROR_NONE) { + if((ret = calendar_disconnect()) == CALENDAR_ERROR_NONE) { + dts_pass(API_NAME_CALENDAR_CONNECT); + } + else { + dts_message(API_NAME_CALENDAR_DISCONNECT, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_DISCONNECT); + } + } + else { + dts_message(API_NAME_CALENDAR_CONNECT, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_CONNECT); + } +} + +void changed_db_cb(void *user_data) +{ +} + +static void utc_social_calendar_calendar_set_unset_db_changed_cb_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_ADD_DB_CHANGED_CB; + calendar_connect(); + if((ret = calendar_add_db_changed_cb(changed_db_cb, CALENDAR_DB_CHANGED_CB_TYPE_CALENDAR_BOOK, NULL)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_remove_db_changed_cb(changed_db_cb, CALENDAR_DB_CHANGED_CB_TYPE_CALENDAR_BOOK)) == CALENDAR_ERROR_NONE) { + calendar_disconnect(); + dts_pass(api_name); + } + } + else { + calendar_disconnect(); + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_set_unset_db_changed_cb_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_ADD_DB_CHANGED_CB; + + if((ret = calendar_add_db_changed_cb(NULL, CALENDAR_DB_CHANGED_CB_TYPE_CALENDAR_BOOK, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + if((ret = calendar_remove_db_changed_cb(NULL, CALENDAR_DB_CHANGED_CB_TYPE_CALENDAR_BOOK)) == CALENDAR_ERROR_INVALID_PARAMETER) { + dts_pass(api_name); + } + } + else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +//bool dts_calendar_foreach_timezone_cb(calendar_foreach_timezone_s *timezone, void *user_data) +//{ +// return false; +//} +// +//static void utc_social_calendar_foreach_timezone_p(void) +//{ +// int ret = CALENDAR_ERROR_NONE; +// char* api_name = API_NAME_CALENDAR_FOREACH_TIMEZONE; +// if((ret = calendar_foreach_timezone(dts_calendar_foreach_timezone_cb, NULL)) == CALENDAR_ERROR_NONE) { +// dts_pass(api_name); +// } +// else { +// dts_message(api_name, "Calendar : %d", ret); +// dts_fail(api_name); +// } +//} +// +//static void utc_social_calendar_foreach_timezone_n(void) +//{ +// int ret = CALENDAR_ERROR_NONE; +// char* api_name = API_NAME_CALENDAR_FOREACH_TIMEZONE; +// if((ret = calendar_foreach_timezone(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { +// dts_pass(api_name); +// } +// else { +// dts_message(api_name, "Calendar : %d", ret); +// dts_fail(api_name); +// } +//} + +bool dts_calendar_foreach_calendar_cb(calendar_query_calendar_book_s *calendar, void *user_data) +{ + return false; +} + +//static void utc_social_calendar_foreach_calendar_book_from_db_p(void) +//{ +// int ret = CALENDAR_ERROR_NONE; +// char* api_name = API_NAME_CALENDAR_FOREACH_CALENDAR_FROM_DB; +// +// bool success = false; +// +// calendar_connect(); +// if((ret = calendar_foreach_calendar_book_from_db(dts_calendar_foreach_calendar_cb, NULL)) == CALENDAR_ERROR_NONE) { +// success = true; +// } +// calendar_disconnect(); +// +// if(success == true) { +// dts_pass(api_name); +// } else { +// dts_message(api_name, "Calendar : %d", ret); +// dts_fail(api_name); +// } +//} +// +//static void utc_social_calendar_foreach_calendar_book_from_db_n(void) +//{ +// int ret = CALENDAR_ERROR_NONE; +// char* api_name = API_NAME_CALENDAR_FOREACH_CALENDAR_FROM_DB; +// +// bool success = false; +// +// if((ret = calendar_foreach_calendar_book_from_db(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { +// +// success = true; +// } +// +// if(success == true) { +// dts_pass(api_name); +// } else { +// dts_message(api_name, "Calendar : %d", ret); +// dts_fail(api_name); +// } +//} + +static void utc_social_calendar_book_create_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_BOOK_CREATE; + + bool success = false; + + calendar_book_h calendar_book_h = NULL; + + if ((ret = calendar_book_create(&calendar_book_h)) == CALENDAR_ERROR_NONE) { + success = true; + } + + calendar_book_destroy(calendar_book_h); + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_book_create_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_BOOK_CREATE; + + bool success = false; + + if((ret = calendar_event_create(NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_book_destroy_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_BOOK_DESTROY; + + bool success = false; + + calendar_book_h calendar_book_h = NULL; + + calendar_book_create(&calendar_book_h); + + if((ret = calendar_book_destroy(calendar_book_h)) == CALENDAR_ERROR_NONE) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_book_destroy_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_BOOK_DESTROY; + + bool success = false; + + if((ret = calendar_book_destroy(NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_book_insert_to_db_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char *api = API_NAME_CALENDAR_BOOK_INSERT_TO_DB; + calendar_book_h calbook; + + int calbook_id; + int acc_id = 3; + unsigned char red = 5; + unsigned char green = 5; + unsigned char blue = 5; + bool is_default; + bool is_visible = true; + char *name = "Test Name"; + + ret = calendar_book_create(&calbook); + if (ret < 0) { + dts_message(api, "calendar_book_create failed(%d)", ret); + dts_fail(api); + return; + } + + ret = calendar_book_set_name(calbook, name); + if (ret < 0) { + dts_message(api, "calendar_book_set_name failed(%d)", ret); + calendar_book_destroy(calbook); + dts_fail(api); + return; + } + + ret = calendar_book_set_is_visible(calbook, is_visible); + if (ret < 0) { + dts_message(api, "calendar_book_set_is_visible failed(%d)", ret); + calendar_book_destroy(calbook); + dts_fail(api); + return; + } + + ret = calendar_book_set_color(calbook, red, blue, green); + if (ret < 0) { + dts_message(api, "calendar_book_set_color failed(%d)", ret); + calendar_book_destroy(calbook); + dts_fail(api); + return; + } + + ret = calendar_book_set_account_db_id(calbook, acc_id); + if (ret < 0) { + dts_message(api, "calendar_book_set_account_db_id failed(%d)", ret); + calendar_book_destroy(calbook); + dts_fail(api); + return; + } + + ret = calendar_book_insert_to_db(calbook, &calbook_id); + if (ret < 0) { + dts_message(api, "calendar_book_set_account_db_id failed(%d)", ret); + calendar_book_destroy(calbook); + dts_fail(api); + return; + } + + ret = calendar_book_destroy(calbook); + if (ret < 0) { + dts_message(api, "calendar_book_set_account_db_id failed(%d)", ret); + dts_fail(api); + return; + } + + ret = calendar_book_create(&calbook); + if (ret < 0) { + dts_message(api, "calendar_book_create failed(%d)", ret); + dts_fail(api); + return; + } + + ret = calendar_book_get_from_db(calbook_id, &calbook); + if (ret < 0) { + dts_message(api, "calendar_book_get_from_db failed(%d)", ret); + calendar_book_destroy(calbook); + dts_fail(api); + return; + } + + ret = calendar_book_get_db_id(calbook, &calbook_id); + if (ret < 0) { + dts_message(api, "calendar_book_get_db_id failed(%d)", ret); + calendar_book_destroy(calbook); + dts_fail(api); + return; + } + + ret = calendar_book_get_is_default(calbook, &is_default); + if (ret < 0) { + dts_message(api, "calendar_book_get_is_default failed(%d)", ret); + calendar_book_destroy(calbook); + dts_fail(api); + return; + } + + ret = calendar_book_get_color(calbook, &red, &green, &blue); + if (ret < 0) { + dts_message(api, "calendar_book_get_is_color failed(%d)", ret); + calendar_book_destroy(calbook); + dts_fail(api); + return; + } + + ret = calendar_book_get_is_visible(calbook, &is_visible); + if (ret < 0) { + dts_message(api, "calendar_book_get_is_visible failed(%d)", ret); + calendar_book_destroy(calbook); + dts_fail(api); + return; + } + + ret = calendar_book_get_account_db_id(calbook, &acc_id); + if (ret < 0) { + dts_message(api, "calendar_book_get_account_db_id failed(%d)", ret); + calendar_book_destroy(calbook); + dts_fail(api); + return; + } + + ret = calendar_book_get_is_default(calbook, &is_default); + if (ret < 0) { + dts_message(api, "calendar_book_get_is_default failed(%d)", ret); + calendar_book_destroy(calbook); + dts_fail(api); + return; + } + + ret = calendar_book_get_name(calbook, &name); + if (ret < 0) { + dts_message(api, "calendar_book_get_name failed(%d)", ret); + calendar_book_destroy(calbook); + dts_fail(api); + return; + } + + ret = calendar_book_destroy(calbook); + if (ret < 0) { + dts_message(api, "calendar_book_destroy failed(%d)", ret); + free(name); + dts_fail(api); + return; + } + + int len; + calendar_book_h *calbook_array; + + ret = calendar_book_get_all_calendar_book(&calbook_array, &len); + if (ret < 0) { + dts_message(api, "calendar_book_get_all_calendar_book failed(%d)", ret); + dts_fail(api); + } + + ret = calendar_book_free_calendar_book_array(calbook_array); + if (ret < 0) { + dts_message(api, "calendar_book_free_calendar_book_array failed(%d)", ret); + dts_fail(api); + } + + ret = calendar_book_delete_from_db(calbook_id); + if (ret < 0) { + dts_message(api, "calendar_book_delete_from_db failed(%d)", ret); + dts_fail(api); + } + + dts_pass(api); +} + +static void utc_social_calendar_book_get_is_default_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_BOOK_GET_IS_DEFAULT; + + bool success = false; + + if((ret = calendar_book_get_is_default(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_book_get_name_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_BOOK_GET_NAME; + + bool success = false; + + if((ret = calendar_book_get_name(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_book_get_is_visible_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_BOOK_GET_IS_VISIBLE; + + bool success = false; + + if((ret = calendar_book_get_is_visible(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_book_get_color_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_BOOK_GET_COLOR; + + bool success = false; + + if((ret = calendar_book_get_color(NULL, NULL, NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_book_get_account_db_id_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_BOOK_GET_ACCOUNT_DB_ID; + + bool success = false; + + if((ret = calendar_book_get_account_db_id(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_book_free_calendar_book_array_n(void) +{ + char* api_name = API_NAME_CALENDAR_BOOK_FREE_CALENDAR_BOOK_ARRAY; + int error; + + if ((error = calendar_book_free_calendar_book_array(NULL)) + != CALENDAR_ERROR_INVALID_PARAMETER) { + dts_message(api_name, "Error: %d", error); + dts_fail(api_name); + return; + } + + dts_pass(api_name); +} + +static void utc_social_calendar_book_get_all_calendar_book_n(void) +{ + char* api_name = API_NAME_CALENDAR_BOOK_GET_ALL_CALENDAR_BOOK; + + int error; + calendar_book_h *calendar_book_array = NULL; + int length; + if ((error = calendar_book_get_all_calendar_book(NULL, &length)) + != CALENDAR_ERROR_INVALID_PARAMETER) { + dts_message(api_name, "Error : %d", error); + dts_fail(api_name); + return; + } + + if ((error = calendar_book_get_all_calendar_book(&calendar_book_array, NULL)) + != CALENDAR_ERROR_INVALID_PARAMETER) { + dts_message(api_name, "Error : %d", error); + dts_fail(api_name); + return; + } + + dts_pass(api_name); +} + +static void utc_social_calendar_book_search_calendar_book_by_account_n(void) +{ + char* api_name = API_NAME_CALENDAR_BOOK_SEARCH_CALENDAR_BOOK_BY_ACCOUNT; + + int error; + calendar_book_h *calendar_book_array = NULL; + int length; + if ((error = calendar_book_get_all_calendar_book(NULL, &length)) + != CALENDAR_ERROR_INVALID_PARAMETER) { + dts_message(api_name, "Error : %d", error); + dts_fail(api_name); + return; + } + + if ((error = calendar_book_search_calendar_book_by_account(-1, &calendar_book_array, NULL)) + != CALENDAR_ERROR_INVALID_PARAMETER) { + dts_message(api_name, "Error : %d", error); + dts_fail(api_name); + return; + } + + dts_pass(api_name); +} + +static void utc_social_calendar_add_db_changed_cb_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + if ((ret = calendar_add_db_changed_cb(_calendar_db_changed_cb, + CALENDAR_DB_CHANGED_CB_TYPE_CALENDAR_BOOK, (void*)123)) + == CALENDAR_ERROR_NONE) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_ADD_DB_CHANGED_CB); + } else { + dts_message(API_NAME_CALENDAR_ADD_DB_CHANGED_CB, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_ADD_DB_CHANGED_CB); + } +} + +static void utc_social_calendar_add_db_changed_cb_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + if ((ret = calendar_add_db_changed_cb(NULL, + CALENDAR_DB_CHANGED_CB_TYPE_CALENDAR_BOOK, (void*)123)) + == CALENDAR_ERROR_INVALID_PARAMETER) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_ADD_DB_CHANGED_CB); + } else { + dts_message(API_NAME_CALENDAR_ADD_DB_CHANGED_CB, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_ADD_DB_CHANGED_CB); + } +} + +static void utc_social_calendar_remove_db_changed_cb_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + if ((ret = calendar_remove_db_changed_cb(_calendar_db_changed_cb, CALENDAR_DB_CHANGED_CB_TYPE_CALENDAR_BOOK)) == CALENDAR_ERROR_NONE) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_REMOVE_DB_CHANGED_CB); + } else { + dts_message(API_NAME_CALENDAR_REMOVE_DB_CHANGED_CB, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_REMOVE_DB_CHANGED_CB); + } +} + +static void utc_social_calendar_remove_db_changed_cb_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + if ((ret = calendar_remove_db_changed_cb(NULL, CALENDAR_DB_CHANGED_CB_TYPE_CALENDAR_BOOK)) == CALENDAR_ERROR_INVALID_PARAMETER) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_REMOVE_DB_CHANGED_CB); + } else { + dts_message(API_NAME_CALENDAR_REMOVE_DB_CHANGED_CB, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_REMOVE_DB_CHANGED_CB); + } +} + +static void utc_social_calendar_get_db_version_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + int db_version; + + if ((ret = calendar_get_db_version(&db_version)) == CALENDAR_ERROR_NONE) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_GET_DB_VERSION); + } else { + dts_message(API_NAME_CALENDAR_GET_DB_VERSION, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_GET_DB_VERSION); + } +} + +static void utc_social_calendar_get_db_version_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + if ((ret = calendar_get_db_version(NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_GET_DB_VERSION); + } else { + dts_message(API_NAME_CALENDAR_GET_DB_VERSION, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_GET_DB_VERSION); + } +} + +static void utc_social_calendar_book_unset_color_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + calendar_book_h calendar_book = NULL; + calendar_book_create(&calendar_book); + + if ((ret = calendar_book_unset_color(calendar_book)) == CALENDAR_ERROR_NONE) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_BOOK_UNSET_COLOR); + } else { + dts_message(API_NAME_CALENDAR_BOOK_UNSET_COLOR, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_BOOK_UNSET_COLOR); + } +} + +static void utc_social_calendar_book_unset_color_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + if ((ret = calendar_book_unset_color(NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_BOOK_UNSET_COLOR); + } else { + dts_message(API_NAME_CALENDAR_BOOK_UNSET_COLOR, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_BOOK_UNSET_COLOR); + } +} diff --git a/TC/testcase/utc_social_calendar_attendee.c b/TC/testcase/utc_social_calendar_attendee.c new file mode 100755 index 0000000..b57d490 --- /dev/null +++ b/TC/testcase/utc_social_calendar_attendee.c @@ -0,0 +1,292 @@ +/* + * 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 <tet_api.h> +#include <social/calendar.h> + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +#define API_NAME_CALENDAR_ATTENDEE_GET_NAME "calendar_attendee_get_name" +#define API_NAME_CALENDAR_ATTENDEE_SET_NAME "calendar_attendee_set_name" +#define API_NAME_CALENDAR_ATTENDEE_GET_EMAIL "calendar_attendee_get_email" +#define API_NAME_CALENDAR_ATTENDEE_SET_EMAIL "calendar_attendee_set_email" +#define API_NAME_CALENDAR_ATTENDEE_ITERATOR_NEXT "calendar_attendee_iterator_next" +#define API_NAME_CALENDAR_ATTENDEE_GET_CONTACT_DB_ID "calendar_attendee_get_contact_db_id" +#define API_NAME_CALENDAR_ATTENDEE_GET_PHONE_NUMBER "calendar_attendee_get_phone_number" + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_social_calendar_calendar_attendee_get_set_name_p(void); +static void utc_social_calendar_calendar_attendee_get_set_name_n(void); +static void utc_social_calendar_calendar_attendee_get_set_email_p(void); +static void utc_social_calendar_calendar_attendee_get_set_email_n(void); +static void utc_social_calendar_calendar_attendee_iterator_next_has_next_p(void); +static void utc_social_calendar_calendar_attendee_iterator_next_has_next_n(void); +static void utc_social_calendar_calendar_attendee_get_contact_db_id_p(void); +static void utc_social_calendar_calendar_attendee_get_contact_db_id_n(void); +static void utc_social_calendar_calendar_attendee_get_phone_number_p(void); +static void utc_social_calendar_calendar_attendee_get_phone_number_n(void); + +struct tet_testlist tet_testlist[] = { + { utc_social_calendar_calendar_attendee_get_set_name_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_attendee_get_set_name_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_attendee_get_set_email_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_attendee_get_set_email_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_attendee_iterator_next_has_next_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_attendee_iterator_next_has_next_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_attendee_get_contact_db_id_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_attendee_get_contact_db_id_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_attendee_get_phone_number_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_attendee_get_phone_number_n, NEGATIVE_TC_IDX }, + + { NULL, 0 }, +}; + +static void startup(void) +{ + /* start of TC */ +} + +static void cleanup(void) +{ + /* end of TC */ +} + +static void utc_social_calendar_calendar_attendee_get_set_name_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_ATTENDEE_GET_NAME; + bool success = false; + char* name = NULL; + + calendar_attendee_h attendee = NULL; + calendar_event_h event = NULL; + if(calendar_event_create(&event) == CALENDAR_ERROR_NONE) { + if(calendar_event_add_attendee(event, &attendee) == CALENDAR_ERROR_NONE){ + if((ret = calendar_attendee_set_name(attendee, "name")) == CALENDAR_ERROR_NONE) { + if((ret = calendar_attendee_get_name(attendee, &name)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + } + } + + if(name != NULL) { + free(name); + } + calendar_event_destroy(event); + if(success == true) { + dts_pass(api_name); + } + else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_attendee_get_set_name_n(void) +{ + if(calendar_attendee_set_name(NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER + && calendar_attendee_get_name(NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER) { + dts_pass(API_NAME_CALENDAR_ATTENDEE_GET_NAME); + } + dts_fail(API_NAME_CALENDAR_ATTENDEE_GET_NAME); +} + +static void utc_social_calendar_calendar_attendee_get_set_email_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_ATTENDEE_GET_EMAIL; + bool success = false; + char* email = NULL; + + calendar_attendee_h attendee = NULL; + calendar_event_h event = NULL; + if(calendar_event_create(&event) == CALENDAR_ERROR_NONE) { + if(calendar_event_add_attendee(event, &attendee) == CALENDAR_ERROR_NONE){ + if((ret = calendar_attendee_set_email(attendee, "test@test.com")) == CALENDAR_ERROR_NONE) { + if((ret = calendar_attendee_get_email(attendee, &email)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + } + } + + if(email != NULL) { + free(email); + } + calendar_event_destroy(event); + if(success == true) { + dts_pass(api_name); + } + else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_attendee_get_set_email_n(void) +{ + if(calendar_attendee_set_email(NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER + && calendar_attendee_get_email(NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER) { + dts_pass(API_NAME_CALENDAR_ATTENDEE_GET_EMAIL); + } + dts_fail(API_NAME_CALENDAR_ATTENDEE_GET_EMAIL); +} + +static void utc_social_calendar_calendar_attendee_iterator_next_has_next_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_ATTENDEE_ITERATOR_NEXT; + bool success = false; + + calendar_attendee_h attendee = NULL; + calendar_attendee_h attendee_r = NULL; + calendar_attendee_iterator_h iterator = NULL; + calendar_event_h event = NULL; + + if(calendar_event_create(&event) == CALENDAR_ERROR_NONE) { + if(calendar_event_add_attendee(event, &attendee) == CALENDAR_ERROR_NONE){ + calendar_event_set_subject(event, "subject"); + calendar_attendee_set_name(attendee, "name"); + if((ret = calendar_event_get_attendee_iterator(event, &iterator)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_attendee_iterator_has_next(iterator)) == true) { + if((ret = calendar_attendee_iterator_next(&iterator, &attendee_r)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + } + } + } + + calendar_event_destroy(event); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_attendee_iterator_next_has_next_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_ATTENDEE_ITERATOR_NEXT; + bool success = false; + if((ret = calendar_attendee_iterator_has_next(NULL)) == false) { + if((ret = calendar_attendee_iterator_next(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_attendee_get_contact_db_id_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_ATTENDEE_GET_CONTACT_DB_ID; + bool success = false; + + int id = 0; + calendar_attendee_h attendee = NULL; + calendar_event_h event = NULL; + if(calendar_event_create(&event) == CALENDAR_ERROR_NONE) { + if(calendar_event_add_attendee(event, &attendee) == CALENDAR_ERROR_NONE){ + if((ret = calendar_attendee_set_contact_db_id(attendee, 1)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_attendee_get_contact_db_id(attendee, &id)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + } + } + + calendar_event_destroy(event); + if(success == true) { + dts_pass(api_name); + } + else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_attendee_get_contact_db_id_n(void) +{ + char* api_name = API_NAME_CALENDAR_ATTENDEE_GET_CONTACT_DB_ID; + if(calendar_attendee_get_contact_db_id(NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER + && calendar_attendee_set_contact_db_id(NULL, -1) == CALENDAR_ERROR_INVALID_PARAMETER) { + dts_pass(api_name); + } + dts_fail(api_name); +} + +static void utc_social_calendar_calendar_attendee_get_phone_number_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_ATTENDEE_GET_PHONE_NUMBER; + bool success = false; + + char* phone_number = NULL; + calendar_attendee_h attendee = NULL; + calendar_event_h event = NULL; + if(calendar_event_create(&event) == CALENDAR_ERROR_NONE) { + if(calendar_event_add_attendee(event, &attendee) == CALENDAR_ERROR_NONE){ + if((ret = calendar_attendee_set_phone_number(attendee, "01088889999")) == CALENDAR_ERROR_NONE) { + if((ret = calendar_attendee_get_phone_number(attendee, &phone_number)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + } + } + + if(phone_number != NULL) { + free(phone_number); + } + calendar_event_destroy(event); + if(success == true) { + dts_pass(api_name); + } + else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_attendee_get_phone_number_n(void) +{ + char* api_name = API_NAME_CALENDAR_ATTENDEE_GET_PHONE_NUMBER; + if(calendar_attendee_get_phone_number(NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER + && calendar_attendee_set_phone_number(NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER) { + dts_pass(api_name); + } + dts_fail(api_name); +} + + + diff --git a/TC/testcase/utc_social_calendar_event.c b/TC/testcase/utc_social_calendar_event.c new file mode 100755 index 0000000..f718c66 --- /dev/null +++ b/TC/testcase/utc_social_calendar_event.c @@ -0,0 +1,2459 @@ +/* + * 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 <tet_api.h> +#include <social/calendar.h> +#include <social/contacts.h> + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +#define API_NAME_CALENDAR_EVENT_CREATE "CALENDAR_EVENT_CREATE" +#define API_NAME_CALENDAR_EVENT_DESTROY "CALENDAR_EVENT_DESTROY" +#define API_NAME_CALENDAR_EVENT_GET_DB_ID "CALENDAR_EVENT_GET_DB_ID" +#define API_NAME_CALENDAR_EVENT_GET_ORIGINAL_EVENT_DB_ID "CALENDAR_EVENT_GET_ORIGINAL_EVENT_DB_ID" +#define API_NAME_CALENDAR_EVENT_GET_CALENDAR_DB_ID "CALENDAR_EVENT_GET_CALENDAR_BOOK_DB_ID" +#define API_NAME_CALENDAR_EVENT_GET_SUBJECT "CALENDAR_EVENT_GET_SUBJECT" +#define API_NAME_CALENDAR_EVENT_SET_SUBJECT "CALENDAR_EVENT_SET_SUBJECT" +#define API_NAME_CALENDAR_EVENT_GET_DESCRIPTION "CALENDAR_EVENT_GET_DESCRIPTION" +#define API_NAME_CALENDAR_EVENT_SET_DESCRIPTION "CALENDAR_EVENT_SET_DESCRIPTION" +#define API_NAME_CALENDAR_EVENT_GET_TIMEZONE "CALENDAR_EVENT_GET_TIMEZONE" +#define API_NAME_CALENDAR_EVENT_GET_VISIBILITY "CALENDAR_EVENT_GET_VISIBILITY" +#define API_NAME_CALENDAR_EVENT_GET_LAST_MODIFIED_TIME "CALENDAR_EVENT_GET_LAST_MODIFIED_TIME" +#define API_NAME_CALENDAR_EVENT_GET_IS_ALL_DAY_EVENT "CALENDAR_EVENT_GET_IS_ALL_DAY_EVENT" +#define API_NAME_CALENDAR_EVENT_SET_IS_ALL_DAY_EVENT "CALENDAR_EVENT_SET_IS_ALL_DAY_EVENT" +#define API_NAME_CALENDAR_EVENT_GET_LOCATION "CALENDAR_EVENT_GET_LOCATION" +#define API_NAME_CALENDAR_EVENT_SET_LOCATION "CALENDAR_EVENT_SET_LOCATION" +#define API_NAME_CALENDAR_EVENT_INSERT_TO_DB "CALENDAR_EVENT_INSERT_TO_DB" +#define API_NAME_CALENDAR_EVENT_DELETE_FROM_DB "CALENDAR_EVENT_DELETE_FROM_DB" +#define API_NAME_CALENDAR_EVENT_UPDATE_TO_DB "CALENDAR_EVENT_UPDATE_TO_DB" +#define API_NAME_CALENDAR_EVENT_GET_FROM_DB "CALENDAR_EVENT_GET_FROM_DB" +#define API_NAME_CALENDAR_EVENT_GET_START_TIME "CALENDAR_EVENT_GET_START_TIME" +#define API_NAME_CALENDAR_EVENT_SET_START_TIME "CALENDAR_EVENT_SET_START_TIME" +#define API_NAME_CALENDAR_EVENT_GET_END_TIME "CALENDAR_EVENT_GET_END_TIME" +#define API_NAME_CALENDAR_EVENT_SET_END_TIME "CALENDAR_EVENT_SET_END_TIME" +#define API_NAME_CALENDAR_EVENT_GET_RECURRENCE_UNTIL_TIME "CALENDAR_EVENT_GET_RECURRENCE_UNTIL_DATE" +#define API_NAME_CALENDAR_EVENT_SET_RECURRENCE_UNTIL_TIME "CALENDAR_EVENT_SET_RECURRENCE_UNTIL_DATE" +#define API_NAME_CALENDAR_EVENT_GET_RECURRENCE_FREQUENCY "CALENDAR_EVENT_GET_RECURRENCE_FREQUENCY" +#define API_NAME_CALENDAR_EVENT_SET_RECURRENCE_FREQUENCY "CALENDAR_EVENT_SET_RECURRENCE_FREQUENCY" +#define API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_INTERVAL "CALENDAR_EVENT_GET_SET_RECURRENCE_INTERVAL" +#define API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_COUNT "CALENDAR_EVENT_GET_SET_RECURRENCE_COUNT" +#define API_NAME_CALENDAR_EVENT_GET_REMINDER "CALENDAR_EVENT_GET_REMINDER" +#define API_NAME_CALENDAR_EVENT_SET_REMINDER "CALENDAR_EVENT_SET_REMINDER" +#define API_NAME_CALENDAR_FOREACH_EVENT_FROM_DB "CALENDAR_FOREACH_EVENT_FROM_DB" +#define API_NAME_CALENDAR_EVENT_ADD_ATTENDEE "CALENDAR_FOREACH_EVENT_ADD_ATTENDEE" +#define API_NAME_CALENDAR_EVENT_ADD_ATTENDEE_WITH_CONTACT "CALENDAR_FOREACH_EVENT_ADD_ATTENDEE_WITH_CONTACT" +#define API_NAME_CALENDAR_EVENT_REMOVE_ATTENDEE "CALENDAR_FOREACH_EVENT_REMOVE_ATTENDEE" +#define API_NAME_CALENDAR_EVENT_GET_TOTAL_COUNT_FROM_DB "CALENDAR_EVENT_GET_TOTAL_COUNT_FROM_DB" +#define API_NAME_CALENDAR_EVENT_GET_ATTENDEE_ITERATOR "CALENDAR_EVENT_GET_ATTENDEE_ITERATOR" +#define API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_BYDAY "CALENDAR_EVENT_GET_SET_RECURRENCE_BYDAY" +#define API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_BYSETPOS "CALENDAR_EVENT_GET_SET_RECURRENCE_BYSETPOS" +#define API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_BYMONTHDAY "CALENDAR_EVENT_GET_SET_RECURRENCE_BYSETPOS" +#define API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_BYMONTH "CALENDAR_EVENT_GET_SET_RECURRENCE_BYSETPOS" +#define API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_BYWEEKSTART "CALENDAR_EVENT_GET_SET_RECURRENCE_BYSETPOS" + +#define API_NAME_CALENDAR_FOREACH_QUERY_BY_SUBJECT "CALENDAR_EVENT_FOREACH_QUERY_BY_SUBJECT" +#define API_NAME_CALENDAR_FOREACH_QUERY_BY_DESCRIPTION "CALENDAR_EVENT_FOREACH_QUERY_BY_DESCRIPTION" +#define API_NAME_CALENDAR_FOREACH_QUERY_BY_LOCATION "CALENDAR_EVENT_FOREACH_QUERY_BY_LOCATION" +#define API_NAME_CALENDAR_FOREACH_QUERY_BY_PERIOD "CALENDAR_EVENT_FOREACH_QUERY_BY_PERIOD" +#define API_NAME_CALENDAR_QUERY_EVENT_BY_TIME_LAST_MODIFIED "CALENDAR_QUERY_EVENT_BY_TIME_LAST_MODIFIED" +#define API_NAME_CALENDAR_QUERY_EVENT_BY_CALENDAR "CALENDAR_QUERY_EVENT_BY_CALENDAR" +#define API_NAME_CALENDAR_EVENT_GET_FROM_VCALENDAR "CALENDAR_EVENT_GET_FROM_VCALENDAR" +#define API_NAME_CALENDAR_EVENT_GET_VCALENDAR_FROM_EVENT "CALENDAR_EVENT_GET_VCALENDAR_FROM_EVENT" + +#define API_NAME_CALENDAR_EVENT_GET_SET_CATEGORIES "CALENDAR_EVENT_GET_SET_CATEGORIES" +#define API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_WEEK_START "CALENDAR_EVENT_GET_SET_RECURRENCE_WEEK_START" +#define API_NAME_CALENDAR_EVENT_GET_SET_BUSY_STATUS "CALENDAR_EVENT_GET_SET_BUSY_STATUS" +#define API_NAME_CALENDAR_EVENT_SEARCH_EVENT_BY_VERSION "CALENDAR_EVENT_SEARCH_EVENT_BY_VERSION" +#define API_NAME_CALENDAR_EVENT_FREE_EVENT_ARRAY "CALENDAR_EVENT_FREE_EVENT_ARRAY" +#define API_NAME_CALENDAR_EVENT_FREE_MODIFIED_EVENT_ARRAY "CALENDAR_EVENT_FREE_MODIFIED_EVENT_ARRAY" +#define API_NAME_CALENDAR_EVENT_SEARCH_EVENT_BY_CALENDAR_BOOK "CALENDAR_EVENT_SEARCH_EVENT_BY_CALENDAR_BOOK" +#define API_NAME_CALENDAR_EVENT_SEARCH_EXTEND_EVENT_INSTANCE_BY_PERIOD "CALENDAR_EVENT_SEARCH_EXTEND_EVENT_INSTANCE_BY_PERIOD" +#define API_NAME_CALENDAR_EVENT_SEARCH_ALL_DAY_EXTEND_EVENT_INSTANCE_BY_PERIOD "CALENDAR_EVENT_SEARCH_ALL_DAY_EXTEND_EVENT_INSTANCE_BY_PERIOD" +#define API_NAME_CALENDAR_EVENT_DELETE_RECURRENCE_EVENT_INSTANCE_FROM_DB "CALENDAR_EVENT_DELETE_RECURRENCE_EVENT_INSTANCE_FROM_DB" +#define API_NAME_CALENDAR_EVENT_DELETE_ALL_DAY_RECURRENCE_EVENT_INSTANCE_FROM_DB "CALENDAR_EVENT_DELETE_ALL_DAY_RECURRENCE_EVENT_INSTANCE_FROM_DB" +#define API_NAME_CALENDAR_EVENT_GET_SET_EXDATE "CALENDAR_EVENT_GET_SET_EXDATE" +#define API_NAME_CALENDAR_EVENT_GET_EVENT_ARRAY_FROM_VCALENDAR "CALENDAR_EVENT_GET_EVENT_ARRAY_FROM_VCALENDAR" +#define API_NAME_CALENDAR_EVENT_GET_VCALENDAR_FROM_DB "CALENDAR_EVENT_GET_VCALENDAR_FROM_DB" + +#define SAMPLE_VCAL \ + "BEGIN:VCALENDAR\r\n" \ + "METHOD:REQUEST\r\n" \ + "PRODID:Microsoft CDO for Microsoft Exchange\r\n" \ + "VERSION:2.0\r\n" \ + "BEGIN:VTIMEZONE\r\n" \ + " TZID:tz\r\n" \ + " X-MICROSOFT-CDO-TZID:10\r\n" \ + " LAST-MODIFIED:20111229T172655Z\r\n" \ + " BEGIN:STANDARD\r\n" \ + " DTSTART:20111106T020000\r\n" \ + " TZOFFSETTO:+0000\r\n" \ + " TZOFFSETFROM:+0000\r\n" \ + " END:STANDARD\r\n" \ + " BEGIN:DAYLIGHT\r\n" \ + " DTSTART:20120313T020000\r\n" \ + " TZOFFSETTO:+0100\r\n" \ + " TZOFFSETFROM:+0000\r\n" \ + " END:DAYLIGHT\r\n" \ + "END:VTIMEZONE\r\n" \ + "BEGIN:VEVENT\r\n" \ + " SUMMARY:Simple Event\, Attendees:Tin Tin \r\n" \ + " ORGANIZER:MAILTO:tin.tin@acme.com\r\n" \ + " ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=;X-NUM-GUESTS=0:mailto:tin.tin@acme.com\r\n" \ + " ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=;X-NUM-GUESTS=0:mailto:tin.tin@acme.com\r\n" \ + " LOCATION:Conference Room\r\n" \ + " DTSTAMP:20111229T172652Z\r\n" \ + " UID:D26B0632-8496-4E76-977F-E7A04AF4CF4D\r\n" \ + " SEQUENCE:1\r\n" \ + " URL;VALUE=URI:http://acme/Lists/Conf/DispForm.aspx?ID=1178\r\n" \ + " DTSTART;TZID=tz:20111229T140000\r\n" \ + " DTEND;TZID=tz:20111229T150000\r\n" \ + " RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TH;WKST=SU\r\n" \ + "END:VEVENT\r\n" \ + "END:VCALENDAR" + +#define SAMPLE_VCAL2 \ + "BEGIN:VCALENDAR\r\n" \ + "VERSION:1.0\r\n" \ + "BEGIN:VEVENT\r\n" \ + "SUMMARY:Sample vCalendar event\r\n" \ + "DTSTART:20031228T080000\r\n" \ + "DTEND:20031228T083000\r\n" \ + "END:VEVENT\r\n" \ + "END:VCALENDAR\r\n" + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_social_calendar_calendar_event_create_p(void); +static void utc_social_calendar_calendar_event_create_n(void); +static void utc_social_calendar_calendar_event_destroy_p(void); +static void utc_social_calendar_calendar_event_destroy_n(void); +static void utc_social_calendar_calendar_event_get_db_id_p(void); +static void utc_social_calendar_calendar_event_get_db_id_n(void); +static void utc_social_calendar_calendar_event_get_calendar_book_db_id_p(void); +static void utc_social_calendar_calendar_event_get_calendar_book_db_id_n(void); +static void utc_social_calendar_calendar_event_get_set_subject_p(void); +static void utc_social_calendar_calendar_event_get_set_subject_n(void); +static void utc_social_calendar_calendar_event_get_set_description_p(void); +static void utc_social_calendar_calendar_event_get_set_description_n(void); +static void utc_social_calendar_calendar_event_get_set_timezone_p(void); +static void utc_social_calendar_calendar_event_get_set_timezone_n(void); +static void utc_social_calendar_calendar_event_get_set_visibility_p(void); +static void utc_social_calendar_calendar_event_get_set_visibility_n(void); +static void utc_social_calendar_calendar_event_get_last_modified_time_p(void); +static void utc_social_calendar_calendar_event_get_last_modified_time_n(void); +static void utc_social_calendar_calendar_event_get_set_all_day_event_p(void); +static void utc_social_calendar_calendar_event_get_set_all_day_event_n(void); +static void utc_social_calendar_calendar_event_get_set_location_p(void); +static void utc_social_calendar_calendar_event_get_set_location_n(void); +static void utc_social_calendar_calendar_event_get_set_reminder_p(void); +static void utc_social_calendar_calendar_event_get_set_reminder_n(void); +static void utc_social_calendar_calendar_event_get_set_recurrence_frequency_p(void); +static void utc_social_calendar_calendar_event_get_set_recurrence_frequency_n(void); +static void utc_social_calendar_calendar_event_get_set_recurrence_interval_p(void); +static void utc_social_calendar_calendar_event_get_set_recurrence_interval_n(void); +static void utc_social_calendar_calendar_event_get_set_recurrence_count_p(void); +static void utc_social_calendar_calendar_event_get_set_recurrence_count_n(void); +static void utc_social_calendar_calendar_event_get_set_recurrence_until_date_p(void); +static void utc_social_calendar_calendar_event_get_set_recurrence_until_date_n(void); + +static void utc_social_calendar_calendar_event_get_set_start_time_p(void); +static void utc_social_calendar_calendar_event_get_set_start_time_n(void); +static void utc_social_calendar_calendar_event_get_set_end_time_p(void); +static void utc_social_calendar_calendar_event_get_set_end_time_n(void); +static void utc_social_calendar_calendar_event_insert_to_db_p(void); +static void utc_social_calendar_calendar_event_insert_to_db_n(void); +static void utc_social_calendar_calendar_event_delete_from_db_p(void); +static void utc_social_calendar_calendar_event_delete_from_db_n(void); +static void utc_social_calendar_calendar_event_update_to_db_p(void); +static void utc_social_calendar_calendar_event_update_to_db_n(void); +static void utc_social_calendar_calendar_event_get_from_db_p(void); +static void utc_social_calendar_calendar_event_get_from_db_n(void); +static void utc_social_calendar_calendar_event_add_attendee_p(void); +static void utc_social_calendar_calendar_event_add_attendee_n(void); +static void utc_social_calendar_calendar_event_add_attendee_with_contact_p(void); +static void utc_social_calendar_calendar_event_add_attendee_with_contact_n(void); +static void utc_social_calendar_calendar_event_remove_attendee_p(void); +static void utc_social_calendar_calendar_event_remove_attendee_n(void); +static void utc_social_calendar_calendar_event_get_attendee_iterator_p(void); +static void utc_social_calendar_calendar_event_get_attendee_iterator_n(void); + +static void utc_social_calendar_calendar_event_get_set_recurrence_byday_p(void); +static void utc_social_calendar_calendar_event_get_set_recurrence_byday_n(void); +static void utc_social_calendar_calendar_event_get_set_recurrence_bysetpos_p(void); +static void utc_social_calendar_calendar_event_get_set_recurrence_bysetpos_n(void); +static void utc_social_calendar_calendar_event_get_set_recurrence_bymonthday_p(void); +static void utc_social_calendar_calendar_event_get_set_recurrence_bymonthday_n(void); +static void utc_social_calendar_calendar_event_get_set_recurrence_bymonth_p(void); +static void utc_social_calendar_calendar_event_get_set_recurrence_bymonth_n(void); +static void utc_social_calendar_calendar_event_get_set_recurrence_week_start_p(void); +static void utc_social_calendar_calendar_event_get_set_recurrence_week_start_n(void); + +static void utc_social_calendar_event_get_set_categories_p(void); +static void utc_social_calendar_event_get_set_categories_n(void); +static void utc_social_calendar_event_get_set_recurrence_week_start_p(void); +static void utc_social_calendar_event_get_set_recurrence_week_start_n(void); +static void utc_social_calendar_event_get_set_busy_status_p(void); +static void utc_social_calendar_event_get_set_busy_status_n(void); +static void utc_social_calendar_event_search_event_by_version_p(void); +static void utc_social_calendar_event_search_event_by_version_n(void); +static void utc_social_calendar_event_free_event_array_p(void); +static void utc_social_calendar_event_free_event_array_n(void); +static void utc_social_calendar_event_free_modified_event_array_p(void); +static void utc_social_calendar_event_free_modified_event_array_n(void); +static void utc_social_calendar_event_search_event_by_calendar_book_p(void); +static void utc_social_calendar_event_search_event_by_calendar_book_n(void); + +static void utc_social_calendar_event_search_extend_instance_by_period_p(void); +static void utc_social_calendar_event_search_extend_instance_by_period_n(void); +static void utc_social_calendar_event_search_all_day_extend_instance_by_period_p(void); +static void utc_social_calendar_event_search_all_day_extend_instance_by_period_n(void); + +static void utc_social_calendar_event_delete_recurrence_instance_from_db_p(void); +static void utc_social_calendar_event_delete_recurrence_instance_from_db_n(void); +static void utc_social_calendar_event_delete_recurrence_all_day_instance_from_db_p(void); +static void utc_social_calendar_event_delete_recurrence_all_day_instance_from_db_n(void); +static void utc_social_calendar_event_get_set_exdate_p(void); +static void utc_social_calendar_event_get_set_exdate_n(void); + +static void utc_social_calendar_event_get_event_array_from_vcalendar_p(void); +static void utc_social_calendar_event_get_event_array_from_vcalendar_n(void); +static void utc_social_calendar_event_get_vcalendar_from_db_p(void); +static void utc_social_calendar_event_get_vcalendar_from_db_n(void); + +struct tet_testlist tet_testlist[] = { + { utc_social_calendar_calendar_event_create_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_create_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_destroy_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_destroy_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_subject_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_subject_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_description_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_description_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_timezone_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_timezone_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_visibility_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_visibility_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_last_modified_time_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_last_modified_time_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_all_day_event_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_all_day_event_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_location_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_location_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_reminder_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_reminder_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_recurrence_frequency_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_recurrence_frequency_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_recurrence_interval_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_recurrence_interval_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_recurrence_count_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_recurrence_count_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_recurrence_until_date_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_recurrence_until_date_n, NEGATIVE_TC_IDX }, + + { utc_social_calendar_calendar_event_get_set_recurrence_byday_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_recurrence_byday_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_recurrence_bysetpos_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_recurrence_bysetpos_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_recurrence_bymonthday_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_recurrence_bymonthday_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_recurrence_bymonth_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_recurrence_bymonth_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_recurrence_week_start_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_recurrence_week_start_n, NEGATIVE_TC_IDX }, + + { utc_social_calendar_calendar_event_get_set_start_time_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_start_time_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_end_time_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_set_end_time_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_insert_to_db_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_insert_to_db_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_from_db_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_from_db_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_db_id_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_db_id_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_calendar_book_db_id_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_calendar_book_db_id_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_update_to_db_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_update_to_db_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_delete_from_db_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_delete_from_db_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_add_attendee_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_add_attendee_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_add_attendee_with_contact_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_add_attendee_with_contact_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_remove_attendee_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_remove_attendee_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_attendee_iterator_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_event_get_attendee_iterator_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_event_get_set_categories_p, POSITIVE_TC_IDX }, + { utc_social_calendar_event_get_set_categories_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_event_get_set_recurrence_week_start_p, POSITIVE_TC_IDX }, + { utc_social_calendar_event_get_set_recurrence_week_start_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_event_get_set_busy_status_p, POSITIVE_TC_IDX }, + { utc_social_calendar_event_get_set_busy_status_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_event_search_event_by_version_p, POSITIVE_TC_IDX }, + { utc_social_calendar_event_search_event_by_version_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_event_free_event_array_p, POSITIVE_TC_IDX }, + { utc_social_calendar_event_free_event_array_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_event_free_modified_event_array_p, POSITIVE_TC_IDX }, + { utc_social_calendar_event_free_modified_event_array_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_event_search_event_by_calendar_book_p, POSITIVE_TC_IDX }, + { utc_social_calendar_event_search_event_by_calendar_book_n, NEGATIVE_TC_IDX }, + + { utc_social_calendar_event_search_extend_instance_by_period_p, POSITIVE_TC_IDX }, + { utc_social_calendar_event_search_extend_instance_by_period_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_event_search_all_day_extend_instance_by_period_p, POSITIVE_TC_IDX }, + { utc_social_calendar_event_search_all_day_extend_instance_by_period_n, NEGATIVE_TC_IDX }, + + { utc_social_calendar_event_delete_recurrence_instance_from_db_p, POSITIVE_TC_IDX }, + { utc_social_calendar_event_delete_recurrence_instance_from_db_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_event_delete_recurrence_all_day_instance_from_db_p, POSITIVE_TC_IDX}, + { utc_social_calendar_event_delete_recurrence_all_day_instance_from_db_n, NEGATIVE_TC_IDX}, + { utc_social_calendar_event_get_set_exdate_p, POSITIVE_TC_IDX }, + { utc_social_calendar_event_get_set_exdate_n, NEGATIVE_TC_IDX }, + + { utc_social_calendar_event_get_event_array_from_vcalendar_p, POSITIVE_TC_IDX }, + { utc_social_calendar_event_get_event_array_from_vcalendar_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_event_get_vcalendar_from_db_p, POSITIVE_TC_IDX }, + { utc_social_calendar_event_get_vcalendar_from_db_n, NEGATIVE_TC_IDX }, + + { NULL, 0 }, +}; + +calendar_event_h _dts_event = NULL; + +static void startup(void) +{ + /* start of TC */ + calendar_event_create(&_dts_event); + calendar_event_set_subject(_dts_event, "Event test subject"); + calendar_event_set_description(_dts_event, "Event test description"); +} + +static void cleanup(void) +{ + /* end of TC */ + calendar_event_destroy(_dts_event); +} + +bool dts_calendar_event_cb(calendar_event_h event, void *user_data) +{ + char *subject = NULL; + calendar_event_get_subject(event, &subject); + printf("# subject : %s\n", subject); + return true; +} + +bool dts_calendar_query_event_cb(calendar_event_h event, void *user_data) +{ + return false; +} + +static void utc_social_calendar_calendar_event_create_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_CREATE; + + calendar_event_h event = NULL; + if((ret = calendar_event_create(&event)) == CALENDAR_ERROR_NONE) { + calendar_event_destroy(event); + dts_pass(api_name); + } + else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_create_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_CREATE; + + if((ret = calendar_event_create(NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + dts_pass(api_name); + } + else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_destroy_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_DESTROY; + bool success = false; + + calendar_event_h event = NULL; + if((ret = calendar_event_create(&event)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_destroy(event)) == CALENDAR_ERROR_NONE){ + success = true; + } + } + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_destroy_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_DESTROY; + + if((ret = calendar_event_destroy(NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + dts_pass(api_name); + } + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); +} + +int dts_event_db_id_inserted = -1; +static void utc_social_calendar_calendar_event_get_db_id_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_DB_ID; + bool success = false; + int db_id = -1; + + calendar_event_h event = NULL; + calendar_connect(); + if((ret = calendar_event_get_from_db(dts_event_db_id_inserted, &event)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_get_db_id(event, &db_id)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + calendar_event_destroy(event); + calendar_disconnect(); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_db_id_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_DB_ID; + + if((ret = calendar_event_get_db_id(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_calendar_book_db_id_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_CALENDAR_DB_ID; + bool success = false; + int db_id = -1; + + if((ret = calendar_event_get_calendar_book_db_id(_dts_event, &db_id)) == CALENDAR_ERROR_NONE) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_calendar_book_db_id_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_CALENDAR_DB_ID; + bool success = false; + + if((ret = calendar_event_get_calendar_book_db_id(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } + +} + +static void utc_social_calendar_calendar_event_get_set_subject_n(void) +{ + if(calendar_event_set_subject(NULL, "subject") == CALENDAR_ERROR_INVALID_PARAMETER + && calendar_event_get_subject(NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER) { + dts_pass(API_NAME_CALENDAR_EVENT_GET_SUBJECT); + } + dts_fail(API_NAME_CALENDAR_EVENT_GET_SUBJECT); +} + +static void utc_social_calendar_calendar_event_get_set_subject_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_SUBJECT; + bool success = false; + char* subject = NULL; + + calendar_event_h event = NULL; + if((ret = calendar_event_create(&event)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_set_subject(event, "subject")) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_get_subject(event, &subject)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + } + if(subject != NULL) { + free(subject); + } + calendar_event_destroy(event); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_set_description_n(void) +{ + if(calendar_event_set_description(NULL, "description") == CALENDAR_ERROR_INVALID_PARAMETER + && calendar_event_get_description(NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER) { + dts_pass(API_NAME_CALENDAR_EVENT_GET_DESCRIPTION); + } + dts_fail(API_NAME_CALENDAR_EVENT_GET_DESCRIPTION); +} + +static void utc_social_calendar_calendar_event_get_set_description_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_DESCRIPTION; + bool success = false; + calendar_event_h event = NULL; + char* description = NULL; + + if(calendar_event_create(&event) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_set_description(event, "description")) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_get_description(event, &description)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + } + if(description != NULL) { + free(description); + } + calendar_event_destroy(event); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_set_all_day_event_n(void) +{ + if(calendar_event_set_all_day_event(NULL, 2012, 1, 1, 2013, 12 ,31) == CALENDAR_ERROR_INVALID_PARAMETER + && calendar_event_get_all_day_event(NULL, NULL, NULL, NULL, NULL, NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER) { + dts_pass(API_NAME_CALENDAR_EVENT_GET_IS_ALL_DAY_EVENT); + } + dts_fail(API_NAME_CALENDAR_EVENT_GET_IS_ALL_DAY_EVENT); +} + +static void utc_social_calendar_calendar_event_get_set_timezone_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_TIMEZONE; + bool success = false; + + calendar_event_h event = NULL; + char* timezone = NULL; + + calendar_event_create(&event); + if((ret = calendar_event_set_timezone(event, "Seoul")) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_get_timezone(event, &timezone)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + + if(timezone != NULL) { + free(timezone); + } + calendar_event_destroy(event); + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_set_timezone_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_TIMEZONE; + bool success = false; + + if((ret = calendar_event_set_timezone(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + if((ret = calendar_event_get_timezone(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_set_visibility_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_TIMEZONE; + bool success = false; + + calendar_event_h event = NULL; + calendar_visibility_e visibility = 0; + + calendar_event_create(&event); + if((ret = calendar_event_set_visibility(event, CALENDAR_VISIBILITY_PRIVATE)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_get_visibility(event, &visibility)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + calendar_event_destroy(event); + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_set_visibility_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_VISIBILITY; + bool success = false; + + if((ret = calendar_event_set_visibility(NULL, 0)) == CALENDAR_ERROR_INVALID_PARAMETER) { + if((ret = calendar_event_get_visibility(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_last_modified_time_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_LAST_MODIFIED_TIME; + bool success = false; + + calendar_event_h event = NULL; + long long int lastmodifiedtime = 0; + + calendar_event_create(&event); + if((ret = calendar_event_get_last_modified_time(event, &lastmodifiedtime)) == CALENDAR_ERROR_NONE) { + success = true; + } + calendar_event_destroy(event); + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_last_modified_time_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_LAST_MODIFIED_TIME; + bool success = false; + + if((ret = calendar_event_get_last_modified_time(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_set_all_day_event_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_IS_ALL_DAY_EVENT; + int start_year, start_month, start_day; + int end_year, end_month, end_day; + bool success = false; + + calendar_event_h event = NULL; + if(calendar_event_create(&event) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_set_all_day_event(event, 2012, 1, 1, 2013, 12 ,31)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_get_all_day_event(event, + &start_year, &start_month, &start_day, + &end_year, &end_month, &end_day)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + } + calendar_event_destroy(event); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_set_location_n(void) +{ + if(calendar_event_set_location(NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER + && calendar_event_get_location(NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER) { + dts_pass(API_NAME_CALENDAR_EVENT_GET_LOCATION); + } + dts_fail(API_NAME_CALENDAR_EVENT_GET_LOCATION); +} + +static void utc_social_calendar_calendar_event_get_set_location_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_LOCATION; + bool success = false; + char* location = NULL; + + calendar_event_h event = NULL; + if((ret = calendar_event_create(&event)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_set_location(event, "location")) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_get_location(event, &location)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + } + if(location != NULL) { + free(location); + } + calendar_event_destroy(event); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_insert_to_db_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_INSERT_TO_DB; + bool success = false; + + calendar_event_h event = NULL; + calendar_connect(); + if((ret = calendar_event_create(&event)) == CALENDAR_ERROR_NONE) { + calendar_event_set_subject(event, "Event test subject"); + calendar_event_set_description(event, "Event test description"); + if((ret = calendar_event_insert_to_db(event, 1, &dts_event_db_id_inserted)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + calendar_event_destroy(event); + calendar_disconnect(); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_insert_to_db_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_INSERT_TO_DB; + + if((ret = calendar_event_insert_to_db(NULL, 1, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + dts_pass(api_name); + } + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); +} + +static void utc_social_calendar_calendar_event_delete_from_db_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_DELETE_FROM_DB; + bool success = false; + + calendar_connect(); + if((ret = calendar_event_delete_from_db(dts_event_db_id_inserted)) == CALENDAR_ERROR_NONE) { + success = true; + } + calendar_disconnect(); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_delete_from_db_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_DELETE_FROM_DB; + + if((ret = calendar_event_delete_from_db(-1)) == CALENDAR_ERROR_INVALID_PARAMETER) { // ?? + dts_pass(api_name); + } + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); +} + +static void utc_social_calendar_calendar_event_update_to_db_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_UPDATE_TO_DB; + bool success = false; + + calendar_event_h event = NULL; + calendar_connect(); + if((ret = calendar_event_get_from_db(dts_event_db_id_inserted, &event)) == CALENDAR_ERROR_NONE) { + calendar_event_set_subject(event, "DTS subject updated"); + calendar_event_set_description(event, "DTS description updated"); + if((ret = calendar_event_update_to_db(event)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + calendar_event_destroy(event); + calendar_disconnect(); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_update_to_db_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_UPDATE_TO_DB; + + if((ret = calendar_event_update_to_db(NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + dts_pass(api_name); + } + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); +} + +static void utc_social_calendar_calendar_event_get_from_db_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_FROM_DB; + bool success = false; + + calendar_event_h event = NULL; + calendar_connect(); + if((ret = calendar_event_get_from_db(dts_event_db_id_inserted, &event)) == CALENDAR_ERROR_NONE) { + success = true; + } + calendar_event_destroy(event); + calendar_disconnect(); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_from_db_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_FROM_DB; + + if((ret = calendar_event_get_from_db(0, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + dts_pass(api_name); + } + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); +} + +static void utc_social_calendar_calendar_event_get_set_start_time_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_START_TIME; + bool success = false; + long long int start_time = 0; + + calendar_event_h event = NULL; + if((ret = calendar_event_create(&event)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_set_start_time(event, start_time)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_get_start_time(event, &start_time)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + } + calendar_event_destroy(event); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_set_start_time_n(void) +{ + long long int start_time = 0; + if(calendar_event_set_start_time(NULL, start_time) == CALENDAR_ERROR_INVALID_PARAMETER + && calendar_event_get_start_time(NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER){ + dts_pass(API_NAME_CALENDAR_EVENT_GET_START_TIME); + } + dts_fail(API_NAME_CALENDAR_EVENT_GET_START_TIME); +} + +static void utc_social_calendar_calendar_event_get_set_end_time_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_END_TIME; + bool success = false; + long long int end_time = 0; + + calendar_event_h event = NULL; + if((ret = calendar_event_create(&event)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_set_end_time(event, end_time)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_get_end_time(event, &end_time)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + } + calendar_event_destroy(event); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_set_end_time_n(void) +{ + long long int end_time = 0; + if(calendar_event_set_end_time(NULL, end_time) == CALENDAR_ERROR_INVALID_PARAMETER + && calendar_event_get_end_time(NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER){ + dts_pass(API_NAME_CALENDAR_EVENT_GET_END_TIME); + } + dts_fail(API_NAME_CALENDAR_EVENT_GET_END_TIME); +} + +static void utc_social_calendar_calendar_event_get_set_recurrence_frequency_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_RECURRENCE_FREQUENCY; + bool success = false; + calendar_recurrence_frequency_e frequency = CALENDAR_RECURRENCE_NONE; + + calendar_event_h event = NULL; + if((ret = calendar_event_create(&event)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_set_recurrence_frequency(event, frequency)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_get_recurrence_frequency(event, &frequency)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + } + calendar_event_destroy(event); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_set_recurrence_frequency_n(void) +{ + calendar_recurrence_frequency_e frequency = CALENDAR_RECURRENCE_NONE; + if(calendar_event_set_recurrence_frequency(NULL, frequency) == CALENDAR_ERROR_INVALID_PARAMETER + && calendar_event_get_recurrence_frequency(NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER){ + dts_pass(API_NAME_CALENDAR_EVENT_GET_RECURRENCE_FREQUENCY); + } + dts_fail(API_NAME_CALENDAR_EVENT_GET_RECURRENCE_FREQUENCY); +} + +static void utc_social_calendar_calendar_event_get_set_recurrence_interval_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_INTERVAL; + bool success = false; + int interval = 100; + + calendar_event_h event = NULL; + if((ret = calendar_event_create(&event)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_set_recurrence_interval(event, interval)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_get_recurrence_interval(event, &interval)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + } + calendar_event_destroy(event); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_set_recurrence_interval_n(void) +{ + int interval = 100; + if(calendar_event_set_recurrence_interval(NULL, interval) == CALENDAR_ERROR_INVALID_PARAMETER + && calendar_event_get_recurrence_interval(NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER){ + dts_pass(API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_INTERVAL); + } + dts_fail(API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_INTERVAL); +} + +static void utc_social_calendar_calendar_event_get_set_recurrence_count_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_COUNT; + bool success = false; + int recurrence_count = 1000; + + calendar_event_h event = NULL; + if((ret = calendar_event_create(&event)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_set_recurrence_count(event, recurrence_count)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_get_recurrence_count(event, &recurrence_count)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + } + calendar_event_destroy(event); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_set_recurrence_count_n(void) +{ + int recurrence_count = 1000; + if(calendar_event_set_recurrence_count(NULL, recurrence_count) == CALENDAR_ERROR_INVALID_PARAMETER + && calendar_event_get_recurrence_count(NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER){ + dts_pass(API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_COUNT); + } + dts_fail(API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_COUNT); +} + +/* +static void utc_social_calendar_calendar_event_get_set_recurrence_week_flag_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_RECURRENCE_WEEK_FLAG; + bool success = false; + int week_flag = CALENDAR_WEEK_FLAG_SUN | CALENDAR_WEEK_FLAG_MON; + + calendar_event_h event = NULL; + if((ret = calendar_event_create(&event)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_set_recurrence_week_flag(event, week_flag)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_get_recurrence_week_flag(event, &week_flag)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + } + calendar_event_destroy(event); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_set_recurrence_week_flag_n(void) +{ + calendar_week_flag_e week_flag = CALENDAR_WEEK_FLAG_SUN | CALENDAR_WEEK_FLAG_MON; + if(calendar_event_set_recurrence_week_flag(NULL, week_flag) == CALENDAR_ERROR_INVALID_PARAMETER + && calendar_event_get_recurrence_week_flag(NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER){ + dts_pass(API_NAME_CALENDAR_EVENT_GET_RECURRENCE_WEEK_FLAG); + } + dts_fail(API_NAME_CALENDAR_EVENT_GET_RECURRENCE_WEEK_FLAG); +} +*/ +static void utc_social_calendar_calendar_event_get_set_reminder_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_REMINDER; + int reminder_interval = 5; + calendar_reminder_interval_type_e reminder_interval_type = CALENDAR_REMINDER_TIME_UNIT_HOUR; + bool success = false; + + calendar_event_h event = NULL; + if((ret = calendar_event_create(&event)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_set_reminder(event, reminder_interval_type, reminder_interval)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_get_reminder(event, &reminder_interval,&reminder_interval)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + } + calendar_event_destroy(event); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_set_reminder_n(void) +{ + calendar_reminder_interval_type_e reminder_interval_type = CALENDAR_REMINDER_TIME_UNIT_HOUR; + int reminder_interval = 5; + + if(calendar_event_set_reminder(NULL, reminder_interval_type,reminder_interval) == CALENDAR_ERROR_INVALID_PARAMETER + && calendar_event_get_reminder(NULL, NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER){ + dts_pass(API_NAME_CALENDAR_EVENT_GET_REMINDER); + } + dts_fail(API_NAME_CALENDAR_EVENT_GET_REMINDER); +} + +static void utc_social_calendar_calendar_event_get_set_recurrence_until_date_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_RECURRENCE_UNTIL_TIME; + bool success = false; + + long long int recurrence_until_date = 0; + + calendar_event_h event = NULL; + if((ret = calendar_event_create(&event)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_set_recurrence_until_date(event, recurrence_until_date)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_get_recurrence_until_date(event, &recurrence_until_date)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + } + calendar_event_destroy(event); + + success = true; + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_set_recurrence_until_date_n(void) +{ + long long int recurrence_until_date = 0; + + if(calendar_event_set_recurrence_until_date(NULL, recurrence_until_date) == CALENDAR_ERROR_INVALID_PARAMETER + && calendar_event_get_recurrence_until_date(NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER){ + dts_pass(API_NAME_CALENDAR_EVENT_GET_RECURRENCE_UNTIL_TIME); + } + dts_fail(API_NAME_CALENDAR_EVENT_GET_RECURRENCE_UNTIL_TIME); +} + +static void utc_social_calendar_calendar_event_add_attendee_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_ADD_ATTENDEE; + + bool success = false; + + calendar_event_h event = NULL; + calendar_attendee_h attendee = NULL; + + if(calendar_event_create(&event) == CALENDAR_ERROR_NONE) { + if(calendar_event_add_attendee(event, &attendee) == CALENDAR_ERROR_NONE){ + success = true; + } + } + calendar_event_destroy(event); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_add_attendee_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_ADD_ATTENDEE; + + if((ret = calendar_event_add_attendee(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER){ + dts_pass(api_name); + } + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); +} + +static void utc_social_calendar_calendar_event_add_attendee_with_contact_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_ADD_ATTENDEE_WITH_CONTACT; + + bool success = false; + + // insert contact--------------------------- + contact_h contact = NULL; + contact_email_h email = NULL; + contact_number_h number = NULL; + int contact_db_id = 0; + contact_create(&contact); + contact_email_create(&email); + contact_email_set_type(email, CONTACT_EMAIL_TYPE_HOME); + contact_email_set_address(email, "dts@dts.com"); + contact_number_create(&number); + contact_number_set_type(number, CONTACT_NUMBER_TYPE_HOME); + contact_number_set_number(number, "01100009999"); + + contact_create(&contact); + contact_add_email(contact, email); + contact_add_number(contact, number); + contacts_connect(); + contact_insert_to_db(contact, 0, &contact_db_id); + + contact_email_destroy(email); + contact_number_destroy(number); + contact_destroy(contact); + //---------------------------------------- + + calendar_event_h event = NULL; + calendar_attendee_h attendee = NULL; + + if(calendar_event_create(&event) == CALENDAR_ERROR_NONE) { + if(calendar_event_add_attendee_with_contact(event, contact_db_id, &attendee) == CALENDAR_ERROR_NONE){ + success = true; + } + } + + contacts_disconnect(); + calendar_event_destroy(event); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_add_attendee_with_contact_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_ADD_ATTENDEE_WITH_CONTACT; + + if((ret = calendar_event_add_attendee_with_contact(NULL, 0, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER){ + dts_pass(api_name); + } + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); +} + +static void utc_social_calendar_calendar_event_remove_attendee_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_REMOVE_ATTENDEE; + bool success = false; + calendar_event_h event = NULL; + calendar_attendee_h attendee = NULL; + + if(calendar_event_create(&event) == CALENDAR_ERROR_NONE) { + if(calendar_event_add_attendee(event, &attendee) == CALENDAR_ERROR_NONE){ + calendar_attendee_set_name(attendee, "name"); + if((ret = calendar_event_remove_attendee(event, attendee)) == CALENDAR_ERROR_NONE){ + success = true; + } + } + } + calendar_event_destroy(event); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_remove_attendee_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_REMOVE_ATTENDEE; + + if((ret = calendar_event_remove_attendee(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER){ + dts_pass(api_name); + } + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); +} + +static void utc_social_calendar_calendar_event_get_attendee_iterator_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_ATTENDEE_ITERATOR; + bool success = false; + calendar_event_h event = NULL; + calendar_attendee_h attendee = NULL; + calendar_attendee_iterator_h iterator = NULL; + + if(calendar_event_create(&event) == CALENDAR_ERROR_NONE && calendar_event_add_attendee(event, &attendee) == CALENDAR_ERROR_NONE){ + calendar_attendee_set_name(attendee, "name"); + if((ret = calendar_event_get_attendee_iterator(event, &iterator)) == CALENDAR_ERROR_NONE){ + success = true; + } + } + calendar_event_destroy(event); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_attendee_iterator_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_ATTENDEE_ITERATOR; + + if((ret = calendar_event_get_attendee_iterator(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER){ + dts_pass(api_name); + } + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); +} + +static void utc_social_calendar_calendar_event_get_set_recurrence_byday_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_BYDAY; + bool success = false; + char* byday = "xxxxxxxxxxxxxxxxx"; + + calendar_event_h event = NULL; + if((ret = calendar_event_create(&event)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_set_recurrence_byday(event, byday)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_get_recurrence_byday(event, &byday)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + } + calendar_event_destroy(event); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_set_recurrence_byday_n(void) +{ + char* byday = "xxxxxxxxxxxxxxxxx"; + if(calendar_event_set_recurrence_byday(NULL, byday) == CALENDAR_ERROR_INVALID_PARAMETER + && calendar_event_get_recurrence_byday(NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER){ + dts_pass(API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_BYDAY); + } + dts_fail(API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_BYDAY); +} + +static void utc_social_calendar_calendar_event_get_set_recurrence_bysetpos_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_BYSETPOS; + bool success = false; + char* bysetpos = "xxxxxxxxxxxxxxxxx"; + + calendar_event_h event = NULL; + if((ret = calendar_event_create(&event)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_set_recurrence_bysetpos(event, bysetpos)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_get_recurrence_bysetpos(event, &bysetpos)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + } + calendar_event_destroy(event); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_set_recurrence_bysetpos_n(void) +{ + char* bysetpos = "xxxxxxxxxxxxxxxxx"; + if(calendar_event_set_recurrence_bysetpos(NULL, bysetpos) == CALENDAR_ERROR_INVALID_PARAMETER + && calendar_event_get_recurrence_bysetpos(NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER){ + dts_pass(API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_BYSETPOS); + } + dts_fail(API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_BYSETPOS); +} + +static void utc_social_calendar_calendar_event_get_set_recurrence_bymonthday_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_BYMONTHDAY; + bool success = false; + char* bymonthday = "xxxxxxxxxxxxxxxxx"; + + calendar_event_h event = NULL; + if((ret = calendar_event_create(&event)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_set_recurrence_bymonthday(event, bymonthday)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_get_recurrence_bymonthday(event, &bymonthday)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + } + calendar_event_destroy(event); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_set_recurrence_bymonthday_n(void) +{ + char* bymonthday = "xxxxxxxxxxxxxxxxx"; + if(calendar_event_set_recurrence_bymonthday(NULL, bymonthday) == CALENDAR_ERROR_INVALID_PARAMETER + && calendar_event_get_recurrence_bymonthday(NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER){ + dts_pass(API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_BYMONTHDAY); + } + dts_fail(API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_BYMONTHDAY); +} + +static void utc_social_calendar_calendar_event_get_set_recurrence_bymonth_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_BYMONTH; + bool success = false; + char* bymonth = "xxxxxxxxxxxxxxxxx"; + + calendar_event_h event = NULL; + if((ret = calendar_event_create(&event)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_set_recurrence_bymonth(event, bymonth)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_get_recurrence_bymonth(event, &bymonth)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + } + calendar_event_destroy(event); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_set_recurrence_bymonth_n(void) +{ + char* bymonth = "xxxxxxxxxxxxxxxxx"; + if(calendar_event_set_recurrence_bymonth(NULL, bymonth) == CALENDAR_ERROR_INVALID_PARAMETER + && calendar_event_get_recurrence_bymonth(NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER){ + dts_pass(API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_BYMONTH); + } + dts_fail(API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_BYMONTH); +} + +static void utc_social_calendar_calendar_event_get_set_recurrence_week_start_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_BYWEEKSTART; + bool success = false; + calendar_week_flag_e week_start = CALENDAR_WEEK_FLAG_SUN; + + calendar_event_h event = NULL; + if((ret = calendar_event_create(&event)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_set_recurrence_week_start(event, week_start)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_event_get_recurrence_week_start(event, &week_start)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + } + calendar_event_destroy(event); + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_set_recurrence_week_start_n(void) +{ + calendar_week_flag_e week_start = CALENDAR_WEEK_FLAG_SUN; + if(calendar_event_set_recurrence_week_start(NULL, week_start) == CALENDAR_ERROR_INVALID_PARAMETER + && calendar_event_get_recurrence_week_start(NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER){ + dts_pass(API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_BYWEEKSTART); + } + dts_fail(API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_BYWEEKSTART); +} +/* +static void utc_social_calendar_calendar_event_get_from_vcalendar_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_FROM_VCALENDAR; + + bool success = false; + + calendar_event_h event = NULL; + char* vcalendar_stream = NULL; + + calendar_event_get_vcalendar_from_event(_dts_event, &vcalendar_stream); + if(calendar_event_get_from_vcalendar(vcalendar_stream, &event) == CALENDAR_ERROR_NONE){ + success = true; + } + + calendar_event_destroy(event); + if(vcalendar_stream != NULL) + free(vcalendar_stream); + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_from_vcalendar_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_FROM_VCALENDAR; + + bool success = false; + + if(calendar_event_get_from_vcalendar(NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER){ + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_vcalendar_from_event_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_VCALENDAR_FROM_EVENT; + + bool success = false; + + char* vcalendar_stream = NULL; + + if(calendar_event_get_vcalendar_from_event(_dts_event, &vcalendar_stream) == CALENDAR_ERROR_NONE){ + success = true; + } + + if(vcalendar_stream != NULL) + free(vcalendar_stream); + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_event_get_vcalendar_from_event_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_EVENT_GET_VCALENDAR_FROM_EVENT; + + bool success = false; + + if(calendar_event_get_vcalendar_from_event(NULL, NULL) == CALENDAR_ERROR_INVALID_PARAMETER){ + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar : %d", ret); + dts_fail(api_name); + } +} +*/ + +static void utc_social_calendar_event_get_set_categories_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + char* categories = NULL; + + calendar_event_h event = NULL; + if ((ret = calendar_event_create(&event)) == CALENDAR_ERROR_NONE) { + if ((ret = calendar_event_set_categories(event, "category1,category2,category3")) == CALENDAR_ERROR_NONE) { + if ((ret = calendar_event_get_categories(event, &categories)) == CALENDAR_ERROR_NONE) { + pass = true; + if (categories != NULL) { + free(categories); + } + } + } + calendar_event_destroy(event); + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_EVENT_GET_SET_CATEGORIES); + } else { + dts_message(API_NAME_CALENDAR_EVENT_GET_SET_CATEGORIES, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_EVENT_GET_SET_CATEGORIES); + } +} + +static void utc_social_calendar_event_get_set_categories_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + if ((ret = calendar_event_set_categories(NULL, "category1,category2,category3")) == CALENDAR_ERROR_INVALID_PARAMETER + && (ret = calendar_event_get_categories(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + dts_pass(API_NAME_CALENDAR_EVENT_GET_SET_CATEGORIES); + } + dts_fail(API_NAME_CALENDAR_EVENT_GET_SET_CATEGORIES); +} + +static void utc_social_calendar_event_get_set_recurrence_week_start_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + calendar_week_flag_e recurrence_week = CALENDAR_WEEK_FLAG_NONE; + + calendar_event_h event = NULL; + if ((ret = calendar_event_create(&event)) == CALENDAR_ERROR_NONE) { + if ((ret = calendar_event_set_recurrence_week_start(event, CALENDAR_WEEK_FLAG_SUN)) == CALENDAR_ERROR_NONE) { + if ((ret = calendar_event_get_recurrence_week_start(event, &recurrence_week)) == CALENDAR_ERROR_NONE) { + pass = true; + } + } + calendar_event_destroy(event); + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_WEEK_START); + } else { + dts_message(API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_WEEK_START, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_WEEK_START); + } +} + +static void utc_social_calendar_event_get_set_recurrence_week_start_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + if ((ret = calendar_event_set_recurrence_week_start(NULL, CALENDAR_WEEK_FLAG_SUN)) == CALENDAR_ERROR_INVALID_PARAMETER + && (ret = calendar_event_get_recurrence_week_start(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + dts_pass(API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_WEEK_START); + } + dts_fail(API_NAME_CALENDAR_EVENT_GET_SET_RECURRENCE_WEEK_START); +} + +static void utc_social_calendar_event_get_set_busy_status_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + calendar_event_busy_status_e busy_status; + + calendar_event_h event = NULL; + if ((ret = calendar_event_create(&event)) == CALENDAR_ERROR_NONE) { + if ((ret = calendar_event_set_busy_status(event, CALENDAR_EVENT_BUSY_STATUS_BUSY)) == CALENDAR_ERROR_NONE) { + if ((ret = calendar_event_get_busy_status(event, &busy_status)) == CALENDAR_ERROR_NONE) { + pass = true; + } + } + calendar_event_destroy(event); + } + if (pass) { + dts_pass(API_NAME_CALENDAR_EVENT_GET_SET_BUSY_STATUS); + } else { + dts_message(API_NAME_CALENDAR_EVENT_GET_SET_BUSY_STATUS, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_EVENT_GET_SET_BUSY_STATUS); + } +} + +static void utc_social_calendar_event_get_set_busy_status_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + if ((ret = calendar_event_set_busy_status(NULL, CALENDAR_EVENT_BUSY_STATUS_BUSY)) == CALENDAR_ERROR_INVALID_PARAMETER + && (ret = calendar_event_get_busy_status(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + dts_pass(API_NAME_CALENDAR_EVENT_GET_SET_BUSY_STATUS); + } + dts_fail(API_NAME_CALENDAR_EVENT_GET_SET_BUSY_STATUS); +} + +static void utc_social_calendar_event_search_event_by_version_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + pcalendar_modified_event_s* modified_event_array = NULL; + int length = 0; + + calendar_connect(); + int calendar_db_version = 0; + + if ((ret = calendar_event_search_event_by_version(DEFAULT_CALENDAR_BOOK_DB_ID, calendar_db_version, &modified_event_array, &length)) == CALENDAR_ERROR_NONE) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_EVENT_SEARCH_EVENT_BY_VERSION); + } else { + dts_message(API_NAME_CALENDAR_EVENT_SEARCH_EVENT_BY_VERSION, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_EVENT_SEARCH_EVENT_BY_VERSION); + } +} + +static void utc_social_calendar_event_search_event_by_version_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + int length = 0; + + calendar_connect(); + + if ((ret = calendar_event_search_event_by_version(DEFAULT_CALENDAR_BOOK_DB_ID, 0, NULL, &length)) == CALENDAR_ERROR_INVALID_PARAMETER) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_EVENT_SEARCH_EVENT_BY_VERSION); + } else { + dts_message(API_NAME_CALENDAR_EVENT_SEARCH_EVENT_BY_VERSION, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_EVENT_SEARCH_EVENT_BY_VERSION); + } +} + +static void utc_social_calendar_event_free_event_array_p(void) +{ + bool pass = false; + int ret = CALENDAR_ERROR_NONE; + calendar_event_h* event_array = NULL; + int length; + + char *vcal; + vcal = strdup(SAMPLE_VCAL2); + + if (!vcal) { + dts_message(API_NAME_CALENDAR_EVENT_FREE_EVENT_ARRAY, "strdup failed"); + dts_fail(API_NAME_CALENDAR_EVENT_FREE_EVENT_ARRAY); + return; + } + + if ((ret = calendar_event_get_event_array_from_vcalendar(vcal, &event_array, &length)) == CALENDAR_ERROR_NONE) { + if ((ret = calendar_event_free_event_array(event_array)) == CALENDAR_ERROR_NONE) { + pass = true; + } + } else { + dts_message(API_NAME_CALENDAR_EVENT_FREE_EVENT_ARRAY, "Error while setting up test"); + } + free(vcal); + + if (pass) { + dts_pass(API_NAME_CALENDAR_EVENT_FREE_EVENT_ARRAY); + } else { + dts_message(API_NAME_CALENDAR_EVENT_FREE_EVENT_ARRAY, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_EVENT_FREE_EVENT_ARRAY); + } +} + +static void utc_social_calendar_event_free_event_array_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + if ((ret = calendar_event_free_event_array(NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_EVENT_FREE_EVENT_ARRAY); + } else { + dts_message(API_NAME_CALENDAR_EVENT_FREE_EVENT_ARRAY, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_EVENT_FREE_EVENT_ARRAY); + } +} + +static void utc_social_calendar_event_free_modified_event_array_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + pcalendar_modified_event_s *modified_event_array = NULL; + + if ((ret = calendar_event_free_modified_event_array(modified_event_array)) == CALENDAR_ERROR_NONE) { + pass = true; + } + + // TODO: more elaborate test-case needed! + pass = true; + + if (pass) { + dts_pass(API_NAME_CALENDAR_EVENT_FREE_MODIFIED_EVENT_ARRAY); + } else { + dts_message(API_NAME_CALENDAR_EVENT_FREE_MODIFIED_EVENT_ARRAY, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_EVENT_FREE_MODIFIED_EVENT_ARRAY); + } +} + +static void utc_social_calendar_event_free_modified_event_array_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + if ((ret = calendar_event_free_modified_event_array(NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_EVENT_FREE_MODIFIED_EVENT_ARRAY); + } else { + dts_message(API_NAME_CALENDAR_EVENT_FREE_MODIFIED_EVENT_ARRAY, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_EVENT_FREE_MODIFIED_EVENT_ARRAY); + } +} + +static void utc_social_calendar_event_search_event_by_calendar_book_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + calendar_event_h* event_array = NULL; + int length = 0; + + if ((ret = calendar_event_search_event_by_calendar_book(DEFAULT_CALENDAR_BOOK_DB_ID, &event_array, &length)) == CALENDAR_ERROR_NONE) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_EVENT_SEARCH_EVENT_BY_CALENDAR_BOOK); + } else { + dts_message(API_NAME_CALENDAR_EVENT_SEARCH_EVENT_BY_CALENDAR_BOOK, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_EVENT_SEARCH_EVENT_BY_CALENDAR_BOOK); + } +} + +static void utc_social_calendar_event_search_event_by_calendar_book_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + calendar_event_h* event_array = NULL; + int length = 0; + + if ((ret = calendar_event_search_event_by_calendar_book(DEFAULT_CALENDAR_BOOK_DB_ID, NULL, &length)) == CALENDAR_ERROR_INVALID_PARAMETER && + (ret = calendar_event_search_event_by_calendar_book(DEFAULT_CALENDAR_BOOK_DB_ID, &event_array, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_EVENT_SEARCH_EVENT_BY_CALENDAR_BOOK); + } else { + dts_message(API_NAME_CALENDAR_EVENT_SEARCH_EVENT_BY_CALENDAR_BOOK, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_EVENT_SEARCH_EVENT_BY_CALENDAR_BOOK); + } +} + +static int _create_sample_event(const char subject[], long long int start, long long int end) +{ + calendar_event_h event = NULL; + int event_id; + + if (calendar_event_create(&event) != CALENDAR_ERROR_NONE) return 1; + if (calendar_event_set_subject(event, subject) != CALENDAR_ERROR_NONE) return 2; + if (calendar_event_set_start_time(event, start) != CALENDAR_ERROR_NONE) return 3; + if (calendar_event_set_end_time(event, end) != CALENDAR_ERROR_NONE) return 4; + if (calendar_event_insert_to_db(event, DEFAULT_CALENDAR_BOOK_DB_ID, &event_id) != CALENDAR_ERROR_NONE) + return 5; + if(calendar_event_destroy(event) != CALENDAR_ERROR_NONE) return 6; + return 0; +} + +static void utc_social_calendar_event_search_extend_instance_by_period_p(void) +{ + calendar_connect(); + int ret; + if ((ret = _create_sample_event("A", 0, 200))) + dts_message(API_NAME_CALENDAR_EVENT_SEARCH_ALL_DAY_EXTEND_EVENT_INSTANCE_BY_PERIOD, + "Error creating precondition(%d)", ret); + if ((_create_sample_event("B", 100, 300))) + dts_message(API_NAME_CALENDAR_EVENT_SEARCH_ALL_DAY_EXTEND_EVENT_INSTANCE_BY_PERIOD, + "Error creating precondition(%d)", ret); + if ((_create_sample_event("C", 200, 400))) + dts_message(API_NAME_CALENDAR_EVENT_SEARCH_ALL_DAY_EXTEND_EVENT_INSTANCE_BY_PERIOD, + "Error creating precondition(%d)", ret); + if ((_create_sample_event("D", 300, 500))) + dts_message(API_NAME_CALENDAR_EVENT_SEARCH_ALL_DAY_EXTEND_EVENT_INSTANCE_BY_PERIOD, + "Error creating precondition(%d)", ret); + if ((_create_sample_event("E", 400, 600))) + dts_message(API_NAME_CALENDAR_EVENT_SEARCH_ALL_DAY_EXTEND_EVENT_INSTANCE_BY_PERIOD, + "Error creating precondition(%d)", ret); + if ((_create_sample_event("F", 500, 700))) + dts_message(API_NAME_CALENDAR_EVENT_SEARCH_ALL_DAY_EXTEND_EVENT_INSTANCE_BY_PERIOD, + "Error creating precondition(%d)", ret); + if ((_create_sample_event("G", 600, 800))) + dts_message(API_NAME_CALENDAR_EVENT_SEARCH_ALL_DAY_EXTEND_EVENT_INSTANCE_BY_PERIOD, + "Error creating precondition(%d)", ret); + + calendar_event_h *event_array = NULL; + int length; + + bool pass = true; + ret = calendar_event_search_extend_instance_by_period(DEFAULT_CALENDAR_BOOK_DB_ID, + 300, 500, &event_array, &length); // B?, C, D, E, F? + if (ret != CALENDAR_ERROR_NONE) + pass = false; + + calendar_disconnect(); + + int i; + for (i = 0; i < length; i++) { + char* subject = NULL; + calendar_event_get_subject(event_array[i], &subject); + dts_message(API_NAME_CALENDAR_EVENT_SEARCH_EXTEND_EVENT_INSTANCE_BY_PERIOD, + "Event : %s", subject); + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_EVENT_SEARCH_EXTEND_EVENT_INSTANCE_BY_PERIOD); + } else { + dts_message(API_NAME_CALENDAR_EVENT_SEARCH_EXTEND_EVENT_INSTANCE_BY_PERIOD, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_EVENT_SEARCH_EXTEND_EVENT_INSTANCE_BY_PERIOD); + } +} + +static void utc_social_calendar_event_search_extend_instance_by_period_n(void) +{ + calendar_event_h *event_array = NULL; + int length; + + bool pass = false; + + calendar_connect(); + if ((calendar_event_search_extend_instance_by_period(DEFAULT_CALENDAR_BOOK_DB_ID, + 300, 500, &event_array, NULL) == CALENDAR_ERROR_INVALID_PARAMETER) && + (calendar_event_search_extend_instance_by_period(DEFAULT_CALENDAR_BOOK_DB_ID, + 300, 500, NULL, &length) == CALENDAR_ERROR_INVALID_PARAMETER)) + pass = true; + calendar_disconnect(); + + if (pass) { + dts_pass(API_NAME_CALENDAR_EVENT_SEARCH_EXTEND_EVENT_INSTANCE_BY_PERIOD); + } else { + dts_fail(API_NAME_CALENDAR_EVENT_SEARCH_EXTEND_EVENT_INSTANCE_BY_PERIOD); + } +} + +static int _create_sample_all_day_event(const char subject[], + int period_start_year, int period_start_month, int period_start_day, + int period_end_year, int period_end_month, int period_end_day) +{ + calendar_event_h event = NULL; + int event_id; + + if (calendar_event_create(&event) != CALENDAR_ERROR_NONE) return 1; + if (calendar_event_set_subject(event, subject) != CALENDAR_ERROR_NONE) return 2; + if (calendar_event_set_all_day_event(event, + period_start_year, period_start_month, period_start_day, + period_end_year, period_end_month, period_end_day) != CALENDAR_ERROR_NONE) return 3; + if (calendar_event_insert_to_db(event, + DEFAULT_CALENDAR_BOOK_DB_ID, &event_id) != CALENDAR_ERROR_NONE) return 4; + if (calendar_event_destroy(event) != CALENDAR_ERROR_NONE) return 5; + return 0; +} + +static void utc_social_calendar_event_search_all_day_extend_instance_by_period_p(void) +{ + calendar_connect(); + int ret; + if ((ret = _create_sample_all_day_event("A", 2000, 1, 1, 2002, 12, 31))) + dts_message(API_NAME_CALENDAR_EVENT_SEARCH_ALL_DAY_EXTEND_EVENT_INSTANCE_BY_PERIOD, + "Error creating precondition(%d)", ret); + if ((ret = _create_sample_all_day_event("B", 2001, 1, 1, 2003, 12, 31))) + dts_message(API_NAME_CALENDAR_EVENT_SEARCH_ALL_DAY_EXTEND_EVENT_INSTANCE_BY_PERIOD, + "Error creating precondition(%d)", ret); + if ((ret = _create_sample_all_day_event("C", 2002, 1, 1, 2004, 12, 31))) + dts_message(API_NAME_CALENDAR_EVENT_SEARCH_ALL_DAY_EXTEND_EVENT_INSTANCE_BY_PERIOD, + "Error creating precondition(%d)", ret); + if ((ret = _create_sample_all_day_event("D", 2003, 1, 1, 2005, 12, 31))) + dts_message(API_NAME_CALENDAR_EVENT_SEARCH_ALL_DAY_EXTEND_EVENT_INSTANCE_BY_PERIOD, + "Error creating precondition(%d)", ret); + if ((ret = _create_sample_all_day_event("E", 2004, 1, 1, 2006, 12, 31))) + dts_message(API_NAME_CALENDAR_EVENT_SEARCH_ALL_DAY_EXTEND_EVENT_INSTANCE_BY_PERIOD, + "Error creating precondition(%d)", ret); + if ((ret = _create_sample_all_day_event("F", 2005, 1, 1, 2007, 12, 31))) + dts_message(API_NAME_CALENDAR_EVENT_SEARCH_ALL_DAY_EXTEND_EVENT_INSTANCE_BY_PERIOD, + "Error creating precondition(%d)", ret); + + calendar_event_h *event_array = NULL; + int length; + + bool pass = false; + if ((ret = calendar_event_search_all_day_extend_instance_by_period(DEFAULT_CALENDAR_BOOK_DB_ID, + 2003, 2, 1, 2004, 12, 30, &event_array, &length)) == CALENDAR_ERROR_NONE) { // B, C, D, E, F + pass = true; + } + + calendar_disconnect(); + + int i; + for (i = 0; i < length; i++) { + char* subject = NULL; + calendar_event_get_subject(event_array[i], &subject); + dts_message(API_NAME_CALENDAR_EVENT_SEARCH_ALL_DAY_EXTEND_EVENT_INSTANCE_BY_PERIOD, + "Event : %s", subject); + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_EVENT_SEARCH_ALL_DAY_EXTEND_EVENT_INSTANCE_BY_PERIOD); + } else { + dts_fail(API_NAME_CALENDAR_EVENT_SEARCH_ALL_DAY_EXTEND_EVENT_INSTANCE_BY_PERIOD); + } +} + +static void utc_social_calendar_event_search_all_day_extend_instance_by_period_n(void) +{ + calendar_event_h *event_array = NULL; + int length; + + bool pass = false; + + calendar_connect(); + if ((calendar_event_search_all_day_extend_instance_by_period(DEFAULT_CALENDAR_BOOK_DB_ID, + 2003, 2, 1, 2004, 12, 30, &event_array, NULL) == CALENDAR_ERROR_INVALID_PARAMETER) && + (calendar_event_search_all_day_extend_instance_by_period(DEFAULT_CALENDAR_BOOK_DB_ID, + 2003, 2, 1, 2004, 12, 30, NULL, &length) == CALENDAR_ERROR_INVALID_PARAMETER)) + pass = true; + calendar_disconnect(); + + if (pass) { + dts_pass(API_NAME_CALENDAR_EVENT_SEARCH_ALL_DAY_EXTEND_EVENT_INSTANCE_BY_PERIOD); + } else { + dts_fail(API_NAME_CALENDAR_EVENT_SEARCH_ALL_DAY_EXTEND_EVENT_INSTANCE_BY_PERIOD); + } +} + +static int _create_sample_recurrence_event(calendar_event_h *event, const char subject[], + long long int start, long long int end, long long int until, int *event_id) +{ + calendar_event_h event_h = NULL; + int id; + + if (calendar_event_create(&event_h) != CALENDAR_ERROR_NONE) return 1; + if (calendar_event_set_subject(event_h, subject) != CALENDAR_ERROR_NONE) return 2; + if (calendar_event_set_start_time(event_h, start) != CALENDAR_ERROR_NONE) return 3; + if (calendar_event_set_end_time(event_h, end) != CALENDAR_ERROR_NONE) return 4; + if (calendar_event_set_recurrence_frequency(event_h, CALENDAR_RECURRENCE_DAILY) + != CALENDAR_ERROR_NONE) return 5; + if (calendar_event_set_recurrence_interval(event_h, 1) != CALENDAR_ERROR_NONE) return 7; + if (calendar_event_set_recurrence_count(event_h, 10) != CALENDAR_ERROR_NONE) return 8; + if (calendar_event_insert_to_db(event_h, DEFAULT_CALENDAR_BOOK_DB_ID, &id) + != CALENDAR_ERROR_NONE) return 9; + if (event) *event = event_h; + if (event_id) *event_id = id; + return 0; +} + +static int _create_sample_all_day_recurrence_event(const char subject[], + int sy, int sm, int sd, int ey, int em, int ed, int *event_id) +{ + calendar_event_h event = NULL; + int id; + + if (calendar_event_create(&event) != CALENDAR_ERROR_NONE) return 1; + if (calendar_event_set_subject(event, subject) != CALENDAR_ERROR_NONE) return 2; + if (calendar_event_set_all_day_event(event, sy, sm, sd, ey, em, ed) != CALENDAR_ERROR_NONE) return 3; + if (calendar_event_set_recurrence_frequency(event, CALENDAR_RECURRENCE_DAILY) + != CALENDAR_ERROR_NONE) return 4; + if (calendar_event_set_recurrence_interval(event, 1) != CALENDAR_ERROR_NONE) return 5; + if (calendar_event_set_recurrence_count(event, 10) != CALENDAR_ERROR_NONE) return 6; + if (calendar_event_insert_to_db(event, DEFAULT_CALENDAR_BOOK_DB_ID, &id) + != CALENDAR_ERROR_NONE) return 7; + *event_id = id; + return 0; +} + +static void utc_social_calendar_event_delete_recurrence_instance_from_db_p(void) +{ + int ret, event_id; + + calendar_connect(); + + /*>>>>> pre-condition:make normal instance */ + ret = _create_sample_recurrence_event(NULL, "A", 5000000, 5030000, 8000000, &event_id); + if (ret) { + dts_message(API_NAME_CALENDAR_EVENT_DELETE_RECURRENCE_EVENT_INSTANCE_FROM_DB, + "Error creating precondition(%d)", ret); + } + /* end pre-condition <<<<<*/ + + ret = calendar_event_delete_recurrence_instance_from_db(event_id, 5000000); + + /*>>>>> post-condition:delete pre-condition */ + ret = calendar_event_delete_from_db(event_id); + if (ret != CALENDAR_ERROR_NONE) { + dts_message(API_NAME_CALENDAR_EVENT_DELETE_RECURRENCE_EVENT_INSTANCE_FROM_DB, + "Error deleting postcondition(%d)", ret); + } + /* end post-condition <<<<<*/ + calendar_disconnect(); + + if (ret == CALENDAR_ERROR_NONE) { + dts_pass(API_NAME_CALENDAR_EVENT_DELETE_RECURRENCE_EVENT_INSTANCE_FROM_DB); + } else { + dts_fail(API_NAME_CALENDAR_EVENT_DELETE_RECURRENCE_EVENT_INSTANCE_FROM_DB); + } +} + +static void utc_social_calendar_event_delete_recurrence_instance_from_db_n(void) +{ + int ret, event_id; + bool pass = false; + + calendar_connect(); + + /*>>>>> pre-condition:make normal instance */ + ret = _create_sample_recurrence_event(NULL, "A", 5000000, 5030000, 8000000, &event_id); + if (ret) { + dts_message(API_NAME_CALENDAR_EVENT_DELETE_RECURRENCE_EVENT_INSTANCE_FROM_DB, + "Error creating precondition(%d)", ret); + } + /* end pre-condition <<<<<*/ + + ret = calendar_event_delete_recurrence_instance_from_db(-1, 5000000); + if (ret == CALENDAR_ERROR_INVALID_PARAMETER) { + pass = true; + } + + /*>>>>> post-condition:delete pre-condition */ + ret = calendar_event_delete_from_db(dts_event_db_id_inserted); + if (ret != CALENDAR_ERROR_NONE) { + dts_message(API_NAME_CALENDAR_EVENT_DELETE_RECURRENCE_EVENT_INSTANCE_FROM_DB, + "Error deleting postcondition(%d)", ret); + } + /* end post-condition <<<<<*/ + calendar_disconnect(); + + if (pass) { + dts_pass(API_NAME_CALENDAR_EVENT_DELETE_RECURRENCE_EVENT_INSTANCE_FROM_DB); + } else { + dts_fail(API_NAME_CALENDAR_EVENT_DELETE_RECURRENCE_EVENT_INSTANCE_FROM_DB); + } +} + +static void utc_social_calendar_event_delete_recurrence_all_day_instance_from_db_p(void) +{ + int ret, event_id; + bool pass = false; + + calendar_connect(); + + /*>>>>> pre-condition:make normal instance */ + ret = _create_sample_all_day_recurrence_event("B", 2012, 1, 1, 2012, 1, 1, &event_id); + if (ret) { + dts_message(API_NAME_CALENDAR_EVENT_DELETE_ALL_DAY_RECURRENCE_EVENT_INSTANCE_FROM_DB, + "Error creating precondition(%d)", ret); + } + /* end pre-condition <<<<<*/ + + ret = calendar_event_delete_recurrence_all_day_instance_from_db(event_id, 2012, 1, 1); + + /*>>>>> post-condition:delete pre-condition */ + ret = calendar_event_delete_from_db(event_id); + if (ret != CALENDAR_ERROR_NONE) { + dts_message(API_NAME_CALENDAR_EVENT_DELETE_ALL_DAY_RECURRENCE_EVENT_INSTANCE_FROM_DB, + "Error deleting postcondition(%d)", ret); + } + /* end post-condition <<<<<*/ + calendar_disconnect(); + + if (ret == CALENDAR_ERROR_NONE) { + dts_pass(API_NAME_CALENDAR_EVENT_DELETE_ALL_DAY_RECURRENCE_EVENT_INSTANCE_FROM_DB); + } else { + dts_fail(API_NAME_CALENDAR_EVENT_DELETE_ALL_DAY_RECURRENCE_EVENT_INSTANCE_FROM_DB); + } +} + +static void utc_social_calendar_event_delete_recurrence_all_day_instance_from_db_n(void) +{ + int ret, event_id; + bool pass = false; + + calendar_connect(); + + /*>>>>> pre-condition:make normal instance */ + ret = _create_sample_all_day_recurrence_event("B", 2012, 1, 1, 2012, 1, 1, &event_id); + if (ret) { + dts_message(API_NAME_CALENDAR_EVENT_DELETE_ALL_DAY_RECURRENCE_EVENT_INSTANCE_FROM_DB, + "Error creating precondition(%d)", ret); + } + /* end pre-condition <<<<<*/ + + ret = calendar_event_delete_recurrence_all_day_instance_from_db(-1, 2012, 1, 1); + if (ret == CALENDAR_ERROR_INVALID_PARAMETER) { + pass = true; + } + + /*>>>>> post-condition:delete pre-condition */ + ret = calendar_event_delete_from_db(event_id); + if (ret != CALENDAR_ERROR_NONE) { + dts_message(API_NAME_CALENDAR_EVENT_DELETE_ALL_DAY_RECURRENCE_EVENT_INSTANCE_FROM_DB, + "Error deleting postcondition(%d)", ret); + } + /* end post-condition <<<<<*/ + calendar_disconnect(); + + if (pass) { + dts_pass(API_NAME_CALENDAR_EVENT_DELETE_ALL_DAY_RECURRENCE_EVENT_INSTANCE_FROM_DB,); + } else { + dts_fail(API_NAME_CALENDAR_EVENT_DELETE_ALL_DAY_RECURRENCE_EVENT_INSTANCE_FROM_DB,); + } +} + +static void utc_social_calendar_event_get_set_exdate_p(void) +{ + int ret, event_id; + bool pass = false; + calendar_event_h event = NULL; + char *exdate = NULL; + + calendar_connect(); + + /*>>>>> pre-condition:make normal instance */ + ret = _create_sample_recurrence_event(&event, "A", 5000000, 5030000, 8000000, &event_id); + ret |= calendar_event_delete_recurrence_instance_from_db(event_id, 5000000); + if (ret) { + dts_message(API_NAME_CALENDAR_EVENT_GET_SET_EXDATE, + "Error creating precondition(%d)", ret); + } + /* end pre-condition <<<<<*/ + + ret = calendar_event_get_recurrence_exdate(event, &exdate); + if (exdate) free(exdate); + + /*>>>>> post-condition:delete pre-condition */ + ret = calendar_event_delete_from_db(event_id); + if (ret != CALENDAR_ERROR_NONE) { + dts_message(API_NAME_CALENDAR_EVENT_DELETE_ALL_DAY_RECURRENCE_EVENT_INSTANCE_FROM_DB, + "Error deleting postcondition(%d)", ret); + } + /* end post-condition <<<<<*/ + calendar_disconnect(); + + if (ret == CALENDAR_ERROR_NONE) { + dts_pass(API_NAME_CALENDAR_EVENT_GET_SET_EXDATE); + } else { + dts_fail(API_NAME_CALENDAR_EVENT_GET_SET_EXDATE); + } +} + +static void utc_social_calendar_event_get_set_exdate_n(void) +{ + int ret, event_id; + bool pass = false; + calendar_event_h event = NULL; + char *exdate = NULL; + + calendar_connect(); + + /*>>>>> pre-condition:make normal instance */ + ret = _create_sample_recurrence_event(&event, "A", 5000000, 5030000, 8000000, &event_id); + ret |= calendar_event_delete_recurrence_instance_from_db(event_id, 5000000); + if (ret) { + dts_message(API_NAME_CALENDAR_EVENT_GET_SET_EXDATE, + "Error creating precondition(%d)", ret); + } + /* end pre-condition <<<<<*/ + + if ((calendar_event_get_recurrence_exdate(NULL, &exdate) == CALENDAR_ERROR_INVALID_PARAMETER) && + (calendar_event_get_recurrence_exdate(event, NULL) == CALENDAR_ERROR_INVALID_PARAMETER)) { + pass = true; + } + if (exdate) free(exdate); + + /*>>>>> post-condition:delete pre-condition */ + ret = calendar_event_delete_from_db(event_id); + if (ret != CALENDAR_ERROR_NONE) { + dts_message(API_NAME_CALENDAR_EVENT_DELETE_ALL_DAY_RECURRENCE_EVENT_INSTANCE_FROM_DB, + "Error deleting postcondition(%d)", ret); + } + /* end post-condition <<<<<*/ + calendar_disconnect(); + + if (pass) { + dts_pass(API_NAME_CALENDAR_EVENT_GET_SET_EXDATE); + } else { + dts_fail(API_NAME_CALENDAR_EVENT_GET_SET_EXDATE); + } +} + +static void utc_social_calendar_event_get_event_array_from_vcalendar_p(void) // fail (UNRESOLVED) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + calendar_connect(); + + calendar_event_h* event_array = NULL; + int length; + + char *vcal; + vcal = strdup(SAMPLE_VCAL2); + + if (!vcal) { + dts_message(API_NAME_CALENDAR_EVENT_GET_EVENT_ARRAY_FROM_VCALENDAR, "strdup failed"); + dts_fail(API_NAME_CALENDAR_EVENT_GET_EVENT_ARRAY_FROM_VCALENDAR); + return; + } + + if ((ret = calendar_event_get_event_array_from_vcalendar(vcal, &event_array, &length)) == CALENDAR_ERROR_NONE) { + dts_message(API_NAME_CALENDAR_EVENT_GET_EVENT_ARRAY_FROM_VCALENDAR, "length : %d", length); + if (length == 1) + pass = true; + } + free(vcal); + + if (pass) { + dts_pass(API_NAME_CALENDAR_EVENT_GET_EVENT_ARRAY_FROM_VCALENDAR); + } else { + dts_message(API_NAME_CALENDAR_EVENT_GET_EVENT_ARRAY_FROM_VCALENDAR, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_EVENT_GET_EVENT_ARRAY_FROM_VCALENDAR); + } +} + +static void utc_social_calendar_event_get_event_array_from_vcalendar_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + calendar_connect(); + + calendar_event_h* event_array = NULL; + int length = 0; + + char *vcal; + vcal = strdup(SAMPLE_VCAL2); + + if (!vcal) { + dts_message(API_NAME_CALENDAR_EVENT_GET_EVENT_ARRAY_FROM_VCALENDAR, "strdup failed"); + dts_fail(API_NAME_CALENDAR_EVENT_GET_EVENT_ARRAY_FROM_VCALENDAR); + return; + } + + if ((ret = calendar_event_get_event_array_from_vcalendar(NULL, &event_array, &length)) == CALENDAR_ERROR_INVALID_PARAMETER && + (ret = calendar_event_get_event_array_from_vcalendar(vcal, NULL, &length)) == CALENDAR_ERROR_INVALID_PARAMETER) { + pass = true; + } + + free(vcal); + + if (pass) { + dts_pass(API_NAME_CALENDAR_EVENT_GET_EVENT_ARRAY_FROM_VCALENDAR); + } else { + dts_message(API_NAME_CALENDAR_EVENT_GET_EVENT_ARRAY_FROM_VCALENDAR, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_EVENT_GET_EVENT_ARRAY_FROM_VCALENDAR); + } +} + +static void utc_social_calendar_event_get_vcalendar_from_db_p(void) // fail +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + calendar_connect(); + + int event_db_id_array[1]; +// event_db_id_array[0] = DEFAULT_CALENDAR_BOOK_DB_ID; + event_db_id_array[0] = 2; // DEFAULT_CALENDAR_BOOK_DB_ID is deleted before, so set 2 + char *vcalendar_stream = NULL; + + if (calendar_event_get_vcalendar_from_db(event_db_id_array, 1, &vcalendar_stream) == CALENDAR_ERROR_NONE) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_EVENT_GET_VCALENDAR_FROM_DB); + } else { + dts_message(API_NAME_CALENDAR_EVENT_GET_VCALENDAR_FROM_DB, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_EVENT_GET_VCALENDAR_FROM_DB); + } +} + +static void utc_social_calendar_event_get_vcalendar_from_db_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + calendar_connect(); + + int event_db_id_array[1]; + event_db_id_array[0] = DEFAULT_CALENDAR_BOOK_DB_ID; + char *vcalendar_stream = NULL; + + if (calendar_event_get_vcalendar_from_db(NULL, 1, &vcalendar_stream) == CALENDAR_ERROR_INVALID_PARAMETER) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_EVENT_GET_VCALENDAR_FROM_DB); + } else { + dts_message(API_NAME_CALENDAR_EVENT_GET_VCALENDAR_FROM_DB, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_EVENT_GET_VCALENDAR_FROM_DB); + } +} + diff --git a/TC/testcase/utc_social_calendar_todo.c b/TC/testcase/utc_social_calendar_todo.c new file mode 100755 index 0000000..f77eb10 --- /dev/null +++ b/TC/testcase/utc_social_calendar_todo.c @@ -0,0 +1,1385 @@ +/* + * 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 <tet_api.h> +#include <social/calendar.h> + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +#define API_NAME_CALENDAR_TODO_CREATE "calendar_todo_create" +#define API_NAME_CALENDAR_TODO_GET_DB_ID "calendar_todo_get_db_id" +#define API_NAME_CALENDAR_TODO_GET_CALENDAR_BOOK_DB_ID "calendar_todo_get_calendar_book_db_id" +#define API_NAME_CALENDAR_TODO_GET_SUBJECT "calendar_todo_get_subject" +#define API_NAME_CALENDAR_TODO_GET_DESCRIPTION "calendar_todo_get_description" +#define API_NAME_CALENDAR_TODO_GET_LOCATION "calendar_todo_get_location" +#define API_NAME_CALENDAR_TODO_GET_TIMEZONE "calendar_todo_get_timezone" +#define API_NAME_CALENDAR_TODO_GET_PRIORITY "calendar_todo_get_priority" +#define API_NAME_CALENDAR_TODO_GET_STATUS "calendar_todo_get_status" +#define API_NAME_CALENDAR_TODO_GET_VISIBILITY "calendar_todo_get_visibility" +#define API_NAME_CALENDAR_TODO_GET_START_TIME "calendar_todo_get_start_time" +#define API_NAME_CALENDAR_TODO_GET_DUE_TIME "calendar_todo_get_due_time" +#define API_NAME_CALENDAR_FOREACH_TODO_FROM_DB "calendar_foreach_todo_from_db" +#define API_NAME_CALENDAR_QUERY_TODO_BY_CALENDAR "calendar_query_todo_by_calendar" +#define API_NAME_CALENDAR_TODO_INSERT_TO_DB "calendar_todo_insert_to_db" +#define API_NAME_CALENDAR_TODO_GET_FROM_DB "calendar_todo_get_from_db" +#define API_NAME_CALENDAR_TODO_GET_LAST_MODIFIED_TIME "calendar_todo_get_last_modified_time" +#define API_NAME_CALENDAR_TODO_UPDATE_TO_DB "calendar_todo_update_to_db" +#define API_NAME_CALENDAR_TODO_DELETE_FROM_DB "calendar_todo_delete_from_db" + +#define API_NAME_CALENDAR_TODO_GET_SET_CATEGORIES "calendar_todo_get_set_categories" +#define API_NAME_CALENDAR_TODO_GET_TOTAL_COUNT_FROM_DB "calendar_todo_get_total_count_from_db" +#define API_NAME_CALENDAR_TODO_GET_TOTAL_COUNT_BY_DUEDATE_RANGE "CALENDAR_TODO_GET_TOTAL_COUNT_BY_DUEDATE_RANGE" +#define API_NAME_CALENDAR_TODO_FREE_ARRAY "calendar_todo_free_array" +#define API_NAME_CALENDAR_TODO_FREE_MODIFIED_TODO_ARRAY_FREE "calendar_todo_free_modified_todo_array_free" +#define API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_CALENDAR_BOOK "calendar_todo_search_todo_by_calendar_book" +#define API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_DUEDATE_RANGE "CALENDAR_TODO_SEARCH_TODO_BY_DUEDATE_RANGE" +#define API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_VERSION "calendar_todo_search_todo_by_version" + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_social_calendar_calendar_todo_create_destroy_p(void); +static void utc_social_calendar_calendar_todo_create_destroy_n(void); +static void utc_social_calendar_calendar_todo_get_db_id_p(void); +static void utc_social_calendar_calendar_todo_get_db_id_n(void); +static void utc_social_calendar_calendar_todo_get_calendar_book_db_id_p(void); +static void utc_social_calendar_calendar_todo_get_calendar_book_db_id_n(void); +static void utc_social_calendar_calendar_todo_get_set_subject_p(void); +static void utc_social_calendar_calendar_todo_get_set_subject_n(void); +static void utc_social_calendar_calendar_todo_get_set_description_p(void); +static void utc_social_calendar_calendar_todo_get_set_description_n(void); +static void utc_social_calendar_calendar_todo_get_set_location_p(void); +static void utc_social_calendar_calendar_todo_get_set_location_n(void); +static void utc_social_calendar_calendar_todo_get_set_timezone_p(void); +static void utc_social_calendar_calendar_todo_get_set_timezone_n(void); +static void utc_social_calendar_calendar_todo_get_set_priority_p(void); +static void utc_social_calendar_calendar_todo_get_set_priority_n(void); +static void utc_social_calendar_calendar_todo_get_set_status_p(void); +static void utc_social_calendar_calendar_todo_get_set_status_n(void); +static void utc_social_calendar_calendar_todo_get_set_visibility_p(void); +static void utc_social_calendar_calendar_todo_get_set_visibility_n(void); +static void utc_social_calendar_calendar_todo_get_set_start_time_p(void); +static void utc_social_calendar_calendar_todo_get_set_start_time_n(void); +static void utc_social_calendar_calendar_todo_get_set_due_time_p(void); +static void utc_social_calendar_calendar_todo_get_set_due_time_n(void); +//static void utc_social_calendar_calendar_foreach_todo_from_db_p(void); +//static void utc_social_calendar_calendar_foreach_todo_from_db_n(void); +//static void utc_social_calendar_calendar_query_todo_by_calendar_p(void); +//static void utc_social_calendar_calendar_query_todo_by_calendar_n(void); +static void utc_social_calendar_calendar_todo_insert_to_db_p(void); +static void utc_social_calendar_calendar_todo_insert_to_db_n(void); +static void utc_social_calendar_calendar_todo_get_from_db_p(void); +static void utc_social_calendar_calendar_todo_get_from_db_n(void); +static void utc_social_calendar_calendar_todo_get_last_modified_time_p(void); +static void utc_social_calendar_calendar_todo_get_last_modified_time_n(void); +static void utc_social_calendar_calendar_todo_update_to_db_p(void); +static void utc_social_calendar_calendar_todo_update_to_db_n(void); +static void utc_social_calendar_calendar_todo_delete_from_db_p(void); +static void utc_social_calendar_calendar_todo_delete_from_db_n(void); + +static void utc_social_calendar_todo_get_set_categories_p(void); +static void utc_social_calendar_todo_get_set_categories_n(void); +static void utc_social_calendar_todo_get_total_count_from_db_p(void); +static void utc_social_calendar_todo_get_total_count_from_db_n(void); +static void utc_social_calendar_todo_get_total_count_by_duedate_range_p(void); +static void utc_social_calendar_todo_get_total_count_by_duedate_range_n(void); +static void utc_social_calendar_todo_free_array_p(void); +static void utc_social_calendar_todo_free_array_n(void); +static void utc_social_calendar_todo_free_modified_todo_array_free_p(void); +static void utc_social_calendar_todo_free_modified_todo_array_free_n(void); +static void utc_social_calendar_todo_search_todo_by_calendar_book_p(void); +static void utc_social_calendar_todo_search_todo_by_calendar_book_n(void); +static void utc_social_calendar_todo_search_todo_by_duedate_range_p(void); +static void utc_social_calendar_todo_search_todo_by_duedate_range_n(void); +static void utc_social_calendar_todo_search_todo_by_version_p(void); +static void utc_social_calendar_todo_search_todo_by_version_n(void); + +struct tet_testlist tet_testlist[] = { + { utc_social_calendar_calendar_todo_create_destroy_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_create_destroy_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_db_id_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_db_id_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_calendar_book_db_id_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_calendar_book_db_id_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_subject_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_subject_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_description_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_description_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_location_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_location_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_timezone_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_timezone_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_priority_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_priority_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_status_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_status_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_visibility_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_visibility_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_start_time_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_start_time_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_due_time_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_set_due_time_n, NEGATIVE_TC_IDX }, +// { utc_social_calendar_calendar_foreach_todo_from_db_p, POSITIVE_TC_IDX }, // TOREM +// { utc_social_calendar_calendar_foreach_todo_from_db_n, NEGATIVE_TC_IDX }, // TOREM +// { utc_social_calendar_calendar_query_todo_by_calendar_p, POSITIVE_TC_IDX }, // TOREM +// { utc_social_calendar_calendar_query_todo_by_calendar_n, NEGATIVE_TC_IDX }, // TOREM + { utc_social_calendar_calendar_todo_insert_to_db_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_insert_to_db_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_from_db_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_from_db_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_last_modified_time_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_get_last_modified_time_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_update_to_db_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_update_to_db_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_delete_from_db_p, POSITIVE_TC_IDX }, + { utc_social_calendar_calendar_todo_delete_from_db_n, NEGATIVE_TC_IDX }, + + { utc_social_calendar_todo_get_set_categories_p, POSITIVE_TC_IDX }, + { utc_social_calendar_todo_get_set_categories_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_todo_get_total_count_from_db_p, POSITIVE_TC_IDX }, + { utc_social_calendar_todo_get_total_count_from_db_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_todo_get_total_count_by_duedate_range_p, POSITIVE_TC_IDX }, + { utc_social_calendar_todo_get_total_count_by_duedate_range_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_todo_free_array_p, POSITIVE_TC_IDX }, + { utc_social_calendar_todo_free_array_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_todo_free_modified_todo_array_free_p, POSITIVE_TC_IDX }, + { utc_social_calendar_todo_free_modified_todo_array_free_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_todo_search_todo_by_calendar_book_p, POSITIVE_TC_IDX }, + { utc_social_calendar_todo_search_todo_by_calendar_book_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_todo_search_todo_by_duedate_range_p, POSITIVE_TC_IDX }, + { utc_social_calendar_todo_search_todo_by_duedate_range_n, NEGATIVE_TC_IDX }, + { utc_social_calendar_todo_search_todo_by_version_p, POSITIVE_TC_IDX }, + { utc_social_calendar_todo_search_todo_by_version_n, NEGATIVE_TC_IDX }, + + { NULL, 0 }, +}; + +calendar_todo_h _dts_todo = NULL; +int _dts_todo_db_id = -1; + +static void startup(void) +{ + /* start of TC */ + calendar_connect(); + calendar_todo_create(&_dts_todo); +} + +static void cleanup(void) +{ + /* end of TC */ + calendar_disconnect(); + calendar_todo_destroy(_dts_todo); +} + +static void utc_social_calendar_calendar_todo_create_destroy_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_CREATE; + + bool success = false; + + calendar_todo_h todo = NULL; + + if((ret = calendar_todo_create(&todo)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_todo_destroy(todo)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_create_destroy_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_CREATE; + + bool success = false; + + if((ret = calendar_todo_create(NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + if((ret = calendar_todo_destroy(NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_db_id_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_DB_ID; + + bool success = false; + + int todo_db_id = 0; + + if((ret = calendar_todo_get_db_id(_dts_todo, &todo_db_id)) == CALENDAR_ERROR_NONE) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_db_id_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_DB_ID; + + bool success = false; + + if((ret = calendar_todo_get_db_id(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_calendar_book_db_id_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_CALENDAR_BOOK_DB_ID; + + bool success = false; + + int calendar_db_id = 0; + + if((ret = calendar_todo_get_calendar_book_db_id(&_dts_todo, &calendar_db_id)) == CALENDAR_ERROR_NONE) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_calendar_book_db_id_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_CALENDAR_BOOK_DB_ID; + + bool success = false; + + if((ret = calendar_todo_get_calendar_book_db_id(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_subject_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_SUBJECT; + + bool success = false; + + char* subject = NULL; + + if((ret = calendar_todo_set_subject(_dts_todo, "todo subject")) == CALENDAR_ERROR_NONE) { + if((ret = calendar_todo_get_subject(_dts_todo, &subject)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + + if(subject != NULL) { + free(subject); + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_subject_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_CREATE; + + bool success = false; + + if((ret = calendar_todo_set_subject(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + if((ret = calendar_todo_get_subject(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_description_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_DESCRIPTION; + + bool success = false; + + char* description = NULL; + + if((ret = calendar_todo_set_description(_dts_todo, "todo description")) == CALENDAR_ERROR_NONE) { + if((ret = calendar_todo_get_description(_dts_todo, &description)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + + if(description != NULL) { + free(description); + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_description_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_DESCRIPTION; + + bool success = false; + + if((ret = calendar_todo_set_description(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + if((ret = calendar_todo_get_description(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_location_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_LOCATION; + + bool success = false; + + char* location = NULL; + + if((ret = calendar_todo_set_location(_dts_todo, "todo location")) == CALENDAR_ERROR_NONE) { + if((ret = calendar_todo_get_location(_dts_todo, &location)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + + if(location != NULL) { + free(location); + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_location_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_LOCATION; + + bool success = false; + + if((ret = calendar_todo_set_location(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + if((ret = calendar_todo_get_location(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_timezone_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_TIMEZONE; + + bool success = false; + + char* timezone = NULL; + + if((ret = calendar_todo_set_timezone(_dts_todo, "Seoul")) == CALENDAR_ERROR_NONE) { + if((ret = calendar_todo_get_timezone(_dts_todo, &timezone)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + + if(timezone != NULL) { + free(timezone); + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_timezone_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_TIMEZONE; + + bool success = false; + + if((ret = calendar_todo_set_timezone(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + if((ret = calendar_todo_get_timezone(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_priority_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_PRIORITY; + + bool success = false; + + calendar_todo_priority_e value = 0; + + if((ret = calendar_todo_set_priority(_dts_todo, 0)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_todo_get_priority(_dts_todo, &value)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_priority_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_PRIORITY; + + bool success = false; + + if((ret = calendar_todo_set_priority(NULL, 0)) == CALENDAR_ERROR_INVALID_PARAMETER) { + if((ret = calendar_todo_get_priority(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_status_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_STATUS; + + bool success = false; + + calendar_todo_status_e value = 0; + + if((ret = calendar_todo_set_status(_dts_todo, 0)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_todo_get_status(_dts_todo, &value)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_status_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_STATUS; + + bool success = false; + + if((ret = calendar_todo_set_status(NULL, 0)) == CALENDAR_ERROR_INVALID_PARAMETER) { + if((ret = calendar_todo_get_status(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_visibility_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_VISIBILITY; + + bool success = false; + + calendar_visibility_e value = 0; + + if((ret = calendar_todo_set_visibility(_dts_todo, 0)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_todo_get_visibility(_dts_todo, &value)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_visibility_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_VISIBILITY; + + bool success = false; + + if((ret = calendar_todo_set_visibility(NULL, 0)) == CALENDAR_ERROR_INVALID_PARAMETER) { + if((ret = calendar_todo_get_visibility(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_start_time_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_START_TIME; + + bool success = false; + + long long int value = {0}; + + if((ret = calendar_todo_set_start_time(_dts_todo, value)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_todo_get_start_time(_dts_todo, &value)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_start_time_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_START_TIME; + + bool success = false; + + long long int value = 0; + + if((ret = calendar_todo_set_start_time(NULL, value)) == CALENDAR_ERROR_INVALID_PARAMETER) { + if((ret = calendar_todo_get_start_time(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_due_time_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_DUE_TIME; + + bool success = false; + + long long int value = 0; + + if((ret = calendar_todo_set_due_time(_dts_todo, value)) == CALENDAR_ERROR_NONE) { + if((ret = calendar_todo_get_due_time(_dts_todo, &value)) == CALENDAR_ERROR_NONE) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_set_due_time_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_DUE_TIME; + + bool success = false; + + long long int value = 0; + + if((ret = calendar_todo_set_due_time(NULL, value)) == CALENDAR_ERROR_INVALID_PARAMETER) { + if((ret = calendar_todo_get_due_time(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +bool dts_calendar_foreach_query_todo_cb(calendar_todo_h todo, void *user_data) +{ + return false; +} + +//static void utc_social_calendar_calendar_foreach_todo_from_db_p(void) +//{ +// int ret = CALENDAR_ERROR_NONE; +// char* api_name = API_NAME_CALENDAR_FOREACH_TODO_FROM_DB; +// bool success = false; +// +// if((ret = calendar_foreach_todo_from_db(dts_calendar_foreach_query_todo_cb, NULL)) == CALENDAR_ERROR_NONE) { +// success = true; +// } +// +// if(success == true) { +// dts_pass(api_name); +// } else { +// dts_message(api_name, "Calendar : %d", ret); +// dts_fail(api_name); +// } +//} +// +//static void utc_social_calendar_calendar_foreach_todo_from_db_n(void) +//{ +// int ret = CALENDAR_ERROR_NONE; +// char* api_name = API_NAME_CALENDAR_FOREACH_TODO_FROM_DB; +// bool success = false; +// +// if((ret = calendar_foreach_todo_from_db(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { +// success = true; +// } +// +// if(success == true) { +// dts_pass(api_name); +// } else { +// dts_message(api_name, "Calendar : %d", ret); +// dts_fail(api_name); +// } +//} +// +//static void utc_social_calendar_calendar_query_todo_by_calendar_p(void) +//{ +// int ret = CALENDAR_ERROR_NONE; +// char* api_name = API_NAME_CALENDAR_QUERY_TODO_BY_CALENDAR; +// bool success = false; +// +// if((ret = calendar_query_todo_by_calendar(dts_calendar_foreach_query_todo_cb, 1, NULL)) == CALENDAR_ERROR_NONE) { +// success = true; +// } +// +// if(success == true) { +// dts_pass(api_name); +// } else { +// dts_message(api_name, "Calendar : %d", ret); +// dts_fail(api_name); +// } +//} +// +//static void utc_social_calendar_calendar_query_todo_by_calendar_n(void) +//{ +// int ret = CALENDAR_ERROR_NONE; +// char* api_name = API_NAME_CALENDAR_QUERY_TODO_BY_CALENDAR; +// bool success = false; +// +// if((ret = calendar_query_todo_by_calendar(NULL, 1, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { +// success = true; +// } +// +// if(success == true) { +// dts_pass(api_name); +// } else { +// dts_message(api_name, "Calendar : %d", ret); +// dts_fail(api_name); +// } +//} + +static void utc_social_calendar_calendar_todo_insert_to_db_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_INSERT_TO_DB; + + bool success = false; + + if((ret = calendar_todo_insert_to_db(_dts_todo, 1, &_dts_todo_db_id)) == CALENDAR_ERROR_NONE) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_insert_to_db_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_INSERT_TO_DB; + + bool success = false; + + if((ret = calendar_todo_insert_to_db(NULL, 1, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_from_db_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_FROM_DB; + + bool success = false; + calendar_todo_h todo = NULL; + + if((ret = calendar_todo_get_from_db(_dts_todo_db_id, &todo)) == CALENDAR_ERROR_NONE) { + success = true; + } + calendar_todo_destroy(todo); + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_from_db_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_FROM_DB; + + bool success = false; + + if((ret = calendar_todo_get_from_db(0, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_last_modified_time_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_LAST_MODIFIED_TIME; + + bool success = false; + long long int value = 0; + + if((ret = calendar_todo_get_last_modified_time(_dts_todo, &value)) == CALENDAR_ERROR_NONE) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_get_last_modified_time_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_GET_LAST_MODIFIED_TIME; + + bool success = false; + + if((ret = calendar_todo_get_last_modified_time(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_update_to_db_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_UPDATE_TO_DB; + + bool success = false; + + if((ret = calendar_todo_update_to_db(_dts_todo)) == CALENDAR_ERROR_NONE) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_update_to_db_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_UPDATE_TO_DB; + + bool success = false; + + if((ret = calendar_todo_update_to_db(NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_delete_from_db_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_DELETE_FROM_DB; + + bool success = false; + + if((ret = calendar_todo_delete_from_db(_dts_todo_db_id)) == CALENDAR_ERROR_NONE) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_calendar_todo_delete_from_db_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + char* api_name = API_NAME_CALENDAR_TODO_DELETE_FROM_DB; + + bool success = false; + + if((ret = calendar_todo_delete_from_db(-1)) == CALENDAR_ERROR_INVALID_PARAMETER) { + success = true; + } + + if(success == true) { + dts_pass(api_name); + } else { + dts_message(api_name, "Calendar to-do : %d", ret); + dts_fail(api_name); + } +} + +static void utc_social_calendar_todo_get_set_categories_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + char* categories = NULL; + + calendar_event_h event = NULL; + if ((ret = calendar_todo_create(&event)) == CALENDAR_ERROR_NONE) { + if ((ret = calendar_todo_set_categories(event, "category1,category2,category3")) == CALENDAR_ERROR_NONE) { + if ((ret = calendar_todo_get_categories(event, &categories)) == CALENDAR_ERROR_NONE) { + pass = true; + if (categories != NULL) { + free(categories); + } + } + } + calendar_todo_destroy(event); + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_TODO_GET_SET_CATEGORIES); + } else { + dts_message(API_NAME_CALENDAR_TODO_GET_SET_CATEGORIES, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_TODO_GET_SET_CATEGORIES); + } +} + +static void utc_social_calendar_todo_get_set_categories_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + if ((ret = calendar_todo_set_categories(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER && + (ret = calendar_todo_get_categories(NULL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + dts_pass(API_NAME_CALENDAR_TODO_GET_SET_CATEGORIES); + } + dts_fail(API_NAME_CALENDAR_TODO_GET_SET_CATEGORIES); +} + +static void utc_social_calendar_todo_get_total_count_from_db_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + int count; + + if ((ret = calendar_todo_get_total_count_from_db(DEFAULT_CALENDAR_BOOK_DB_ID, CALENDAR_TODO_FILTER_PRIORITY_ALL, CALENDAR_TODO_FILTER_STATUS_ALL, &count)) == CALENDAR_ERROR_NONE) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_TODO_GET_TOTAL_COUNT_FROM_DB); + } else { + dts_message(API_NAME_CALENDAR_TODO_GET_TOTAL_COUNT_FROM_DB, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_TODO_GET_TOTAL_COUNT_FROM_DB); + } +} + +static void utc_social_calendar_todo_get_total_count_from_db_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + if ((ret = calendar_todo_get_total_count_from_db(DEFAULT_CALENDAR_BOOK_DB_ID, CALENDAR_TODO_FILTER_PRIORITY_ALL, CALENDAR_TODO_FILTER_STATUS_ALL, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER ) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_TODO_GET_TOTAL_COUNT_FROM_DB); + } else { + dts_message(API_NAME_CALENDAR_TODO_GET_TOTAL_COUNT_FROM_DB, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_TODO_GET_TOTAL_COUNT_FROM_DB); + } +} + +static int _create_sample_todo(const char subject[], long long int due) +{ + calendar_todo_h todo; + if (calendar_todo_create(&todo) != CALENDAR_ERROR_NONE) return 1; + if (calendar_todo_set_subject(todo, subject) != CALENDAR_ERROR_NONE) return 2; + if (calendar_todo_set_due_time(todo, due) != CALENDAR_ERROR_NONE) return 3; + if (calendar_todo_set_priority(todo, CALENDAR_TODO_PRIORITY_NORMAL) != CALENDAR_ERROR_NONE) return 4; + if (calendar_todo_set_status(todo, CALENDAR_TODO_STATUS_IN_PROCESS) != CALENDAR_ERROR_NONE) return 5; + int todo_id; + if (calendar_todo_insert_to_db(todo, DEFAULT_CALENDAR_BOOK_DB_ID, &todo_id) != CALENDAR_ERROR_NONE) + return 6; + if (calendar_todo_destroy(todo) != CALENDAR_ERROR_NONE) return 7; + return 0; +} + +static void utc_social_calendar_todo_get_total_count_by_duedate_range_p(void) +{ + const char* api_name = API_NAME_CALENDAR_TODO_GET_TOTAL_COUNT_BY_DUEDATE_RANGE; + + calendar_connect(); + + int error; + if ((error = _create_sample_todo("", 100))) + dts_message(api_name, "Error while building precondition(%d)", error); + if ((error = _create_sample_todo("", 200))) + dts_message(api_name, "Error while building precondition(%d)", error); + if ((error = _create_sample_todo("", 300))) + dts_message(api_name, "Error while building precondition(%d)", error); + if ((error = _create_sample_todo("", 400))) + dts_message(api_name, "Error while building precondition(%d)", error); + if ((error = _create_sample_todo("", 500))) + dts_message(api_name, "Error while building precondition(%d)", error); + + int count; + if ((error = calendar_todo_get_total_count_by_duedate_range(DEFAULT_CALENDAR_BOOK_DB_ID, 200, 400, + CALENDAR_TODO_PRIORITY_NORMAL, + CALENDAR_TODO_STATUS_IN_PROCESS, + &count)) + != CALENDAR_ERROR_NONE) { + dts_message(api_name, "Error : %d", error); + dts_fail(api_name); + return; + } + + calendar_disconnect(); + + if (count != 3) { + dts_message(api_name, "Count(%d)", count); + dts_fail(api_name); + return; + } + + dts_pass(api_name); +} + +static void utc_social_calendar_todo_get_total_count_by_duedate_range_n(void) +{ + const char* api_name = API_NAME_CALENDAR_TODO_GET_TOTAL_COUNT_BY_DUEDATE_RANGE; + int error; + if ((error = calendar_todo_get_total_count_by_duedate_range(DEFAULT_CALENDAR_BOOK_DB_ID, 200, 400, + CALENDAR_TODO_FILTER_PRIORITY_ALL, CALENDAR_TODO_FILTER_STATUS_ALL, NULL)) + != CALENDAR_ERROR_INVALID_PARAMETER) { + dts_message(api_name, "Error : %d", error); + dts_fail(api_name); + return; + } + dts_pass(api_name); +} + +static void utc_social_calendar_todo_free_array_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + calendar_todo_h* todo_array = NULL; + int length; + + calendar_connect(); + + ret = calendar_todo_search_todo_by_calendar_book(DEFAULT_CALENDAR_BOOK_DB_ID, + CALENDAR_TODO_FILTER_PRIORITY_ALL, + CALENDAR_TODO_FILTER_STATUS_ALL, + &todo_array, &length); + + if (ret != CALENDAR_ERROR_NONE) { + dts_message(API_NAME_CALENDAR_TODO_FREE_ARRAY, "Error while test set-up!"); + dts_fail(API_NAME_CALENDAR_TODO_FREE_ARRAY); + return; + } + + if (todo_array[0] == NULL) { + dts_message(API_NAME_CALENDAR_TODO_FREE_ARRAY, "array is NULL"); + } + dts_message(API_NAME_CALENDAR_TODO_FREE_ARRAY, "lendth:%d", length); + + if ((ret = calendar_todo_free_todo_array(todo_array)) == CALENDAR_ERROR_NONE) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_TODO_FREE_ARRAY); + } else { + dts_message(API_NAME_CALENDAR_TODO_FREE_ARRAY, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_TODO_FREE_ARRAY); + } +} + +static void utc_social_calendar_todo_free_array_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + if ((ret = calendar_todo_free_todo_array(NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_TODO_FREE_ARRAY); + } else { + dts_message(API_NAME_CALENDAR_TODO_FREE_ARRAY, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_TODO_FREE_ARRAY); + } +} + +static void utc_social_calendar_todo_free_modified_todo_array_free_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + pcalendar_modified_todo_s* modified_todo_array = NULL; + + if ((ret = calendar_todo_free_modified_todo_array(modified_todo_array)) == CALENDAR_ERROR_NONE) { + pass = true; + } + + // TODO: more elaborate test-case needed! + pass = true; + + if (pass) { + dts_pass(API_NAME_CALENDAR_TODO_FREE_MODIFIED_TODO_ARRAY_FREE); + } else { + dts_message(API_NAME_CALENDAR_TODO_FREE_MODIFIED_TODO_ARRAY_FREE, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_TODO_FREE_MODIFIED_TODO_ARRAY_FREE); + } +} + +static void utc_social_calendar_todo_free_modified_todo_array_free_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + if ((ret = calendar_todo_free_modified_todo_array(NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_TODO_FREE_MODIFIED_TODO_ARRAY_FREE); + } else { + dts_message(API_NAME_CALENDAR_TODO_FREE_MODIFIED_TODO_ARRAY_FREE, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_TODO_FREE_MODIFIED_TODO_ARRAY_FREE); + } +} + +static void utc_social_calendar_todo_search_todo_by_calendar_book_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + calendar_todo_h* todo_array = NULL; + int length; + + calendar_connect(); + + if ((ret = calendar_todo_search_todo_by_calendar_book(DEFAULT_CALENDAR_BOOK_DB_ID, CALENDAR_TODO_FILTER_PRIORITY_ALL, CALENDAR_TODO_FILTER_STATUS_ALL, + &todo_array, &length)) == CALENDAR_ERROR_NONE) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_CALENDAR_BOOK); + } else { + dts_message(API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_CALENDAR_BOOK, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_CALENDAR_BOOK); + } +} + +static void utc_social_calendar_todo_search_todo_by_calendar_book_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + calendar_connect(); + + calendar_todo_h* todo_array; + int length; + + if ((ret = calendar_todo_search_todo_by_calendar_book(DEFAULT_CALENDAR_BOOK_DB_ID, CALENDAR_TODO_FILTER_PRIORITY_ALL, CALENDAR_TODO_FILTER_STATUS_ALL, + NULL, &length)) == CALENDAR_ERROR_INVALID_PARAMETER && + (ret = calendar_todo_search_todo_by_calendar_book(DEFAULT_CALENDAR_BOOK_DB_ID, CALENDAR_TODO_FILTER_PRIORITY_ALL, CALENDAR_TODO_FILTER_STATUS_ALL, + &todo_array, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_CALENDAR_BOOK); + } else { + dts_message(API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_CALENDAR_BOOK, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_CALENDAR_BOOK); + } +} + +static void utc_social_calendar_todo_search_todo_by_duedate_range_p(void) +{ + const char* api_name = API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_DUEDATE_RANGE; + + calendar_connect(); + + int error; + if ((error = _create_sample_todo("", 100))) + dts_message(api_name, "Error while building precondition(%d)", error); + if ((error = _create_sample_todo("", 200))) + dts_message(api_name, "Error while building precondition(%d)", error); + if ((error = _create_sample_todo("", 300))) + dts_message(api_name, "Error while building precondition(%d)", error); + if ((error = _create_sample_todo("", 400))) + dts_message(api_name, "Error while building precondition(%d)", error); + if ((error = _create_sample_todo("", 500))) + dts_message(api_name, "Error while building precondition(%d)", error); + + calendar_todo_h *todo_array = NULL; + int length; + if ((error = calendar_todo_search_todo_by_duedate_range(DEFAULT_CALENDAR_BOOK_DB_ID, 200, 400, + CALENDAR_TODO_FILTER_PRIORITY_ALL, CALENDAR_TODO_FILTER_STATUS_ALL, &todo_array, &length)) + != CALENDAR_ERROR_NONE) { + dts_message(api_name, "Error : %d", error); + dts_fail(api_name); + return; + } + + calendar_disconnect(); + + dts_pass(api_name); +} + +static void utc_social_calendar_todo_search_todo_by_duedate_range_n(void) +{ + const char* api_name = API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_DUEDATE_RANGE; + int error; + calendar_todo_h *todo_array = NULL; + int length; + + if ((error = calendar_todo_search_todo_by_duedate_range(DEFAULT_CALENDAR_BOOK_DB_ID, 200, 400, + CALENDAR_TODO_FILTER_PRIORITY_ALL, CALENDAR_TODO_FILTER_STATUS_ALL, NULL, &length)) + != CALENDAR_ERROR_INVALID_PARAMETER) { + dts_message(api_name, "Error : %d", error); + dts_fail(api_name); + return; + } + + if ((error = calendar_todo_search_todo_by_duedate_range(DEFAULT_CALENDAR_BOOK_DB_ID, 200, 400, + CALENDAR_TODO_FILTER_PRIORITY_ALL, CALENDAR_TODO_FILTER_STATUS_ALL, &todo_array, NULL)) + != CALENDAR_ERROR_INVALID_PARAMETER) { + dts_message(api_name, "Error : %d", error); + dts_fail(api_name); + return; + } + + dts_pass(api_name); +} + +static void utc_social_calendar_todo_search_todo_by_version_p(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + int length; + + calendar_connect(); + pcalendar_modified_todo_s* modified_todo_array = NULL; + + if ((ret = calendar_todo_search_todo_by_version(DEFAULT_CALENDAR_BOOK_DB_ID, 0, &modified_todo_array, &length)) == CALENDAR_ERROR_NONE) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_VERSION); + } else { + dts_message(API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_VERSION, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_VERSION); + } +} + +static void utc_social_calendar_todo_search_todo_by_version_n(void) +{ + int ret = CALENDAR_ERROR_NONE; + bool pass = false; + + calendar_modified_todo_s* modified_todo_array = NULL; + int length; + + if ((ret = calendar_todo_search_todo_by_version(DEFAULT_CALENDAR_BOOK_DB_ID, 0, NULL, &length)) == CALENDAR_ERROR_INVALID_PARAMETER && + (ret = calendar_todo_search_todo_by_version(DEFAULT_CALENDAR_BOOK_DB_ID, 0, &modified_todo_array, NULL)) == CALENDAR_ERROR_INVALID_PARAMETER) { + pass = true; + } + + if (pass) { + dts_pass(API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_VERSION); + } else { + dts_message(API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_VERSION, "Calendar : %d", ret); + dts_fail(API_NAME_CALENDAR_TODO_SEARCH_TODO_BY_VERSION); + } +} diff --git a/TC/tet_scen b/TC/tet_scen new file mode 100755 index 0000000..03f029a --- /dev/null +++ b/TC/tet_scen @@ -0,0 +1,7 @@ +all + ^TEST +##### Scenarios for TEST ##### + +# Test scenario +TEST + :include:/testcase/tslist diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg new file mode 100755 index 0000000..f7eda55 --- /dev/null +++ b/TC/tetbuild.cfg @@ -0,0 +1,5 @@ +TET_OUTPUT_CAPTURE=True # capture option for build operation checking +TET_BUILD_TOOL=make # build with using make command +TET_BUILD_FILE=-f Makefile # execution file (Makefile) for build +TET_API_COMPLIANT=True # use TET API in Test Case ? +TET_PASS_TC_NAME=True # report passed TC name in Journal file? diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg new file mode 100755 index 0000000..02d7030 --- /dev/null +++ b/TC/tetclean.cfg @@ -0,0 +1,5 @@ +TET_OUTPUT_CAPTURE=True # capture option +TET_CLEAN_TOOL= make clean # clean tool +TET_CLEAN_FILE= Makefile # file for clean +TET_API_COMPLIANT=True # TET API useage +TET_PASS_TC_NAME=True # showing name , passed TC diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg new file mode 100755 index 0000000..ef3e452 --- /dev/null +++ b/TC/tetexec.cfg @@ -0,0 +1,5 @@ +TET_OUTPUT_CAPTURE=True # capturing execution or not +TET_EXEC_TOOL= # ex) exec : execution tool set up/ Optional +TET_EXEC_FILE= # ex) exectool : execution file/ Optional +TET_API_COMPLIANT=True # Test case or Tool usesTET API? +TET_PASS_TC_NAME=True # showing Passed TC name ? diff --git a/debian/capi-social-calendar-dev.install b/debian/capi-social-calendar-dev.install index 761a28b..761a28b 100755..100644 --- a/debian/capi-social-calendar-dev.install +++ b/debian/capi-social-calendar-dev.install diff --git a/debian/capi-social-calendar-dev.postinst b/debian/capi-social-calendar-dev.postinst index 1a24852..1a24852 100755..100644 --- a/debian/capi-social-calendar-dev.postinst +++ b/debian/capi-social-calendar-dev.postinst diff --git a/debian/capi-social-calendar.install b/debian/capi-social-calendar.install index 4a755a4..4a755a4 100755..100644 --- a/debian/capi-social-calendar.install +++ b/debian/capi-social-calendar.install diff --git a/debian/capi-social-calendar.postinst b/debian/capi-social-calendar.postinst index 1a24852..1a24852 100755..100644 --- a/debian/capi-social-calendar.postinst +++ b/debian/capi-social-calendar.postinst diff --git a/debian/changelog b/debian/changelog index 6f1192c..2d85b19 100755 --- a/debian/changelog +++ b/debian/changelog @@ -1,37 +1,359 @@ +capi-social-calendar (0.1.1-53) unstable; urgency=low + + * fixed: sound path was not updated because of struct api instead of value api. + * Git: framework/api/calendar + * Tag: capi-social-calendar_0.1.1-53 + + -- Jeesun Kim <iamjs.kim@samsung.com> Tue, 28 Aug 2012 09:51:36 +0900 + +capi-social-calendar (0.1.1-52) unstable; urgency=low + + * fixed: set strdup when returning byday value. + * Git: framework/api/calendar + * Tag: capi-social-calendar_0.1.1-52 + + -- Jeesun Kim <iamjs.kim@samsung.com> Tue, 28 Aug 2012 09:51:36 +0900 + +capi-social-calendar (0.1.1-51) unstable; urgency=low + + * added calendar id when updated list is returned. + * Git: framework/api/calendar + * Tag: capi-social-calendar_0.1.1-51 + + -- Jeesun Kim <iamjs.kim@samsung.com> Mon, 20 Aug 2012 20:10:19 +0900 + +capi-social-calendar (0.1.1-50) unstable; urgency=low + + * set return 0 when count is 0. + * Git: framework/api/calendar + * Tag: capi-social-calendar_0.1.1-50 + + -- Jeesun Kim <iamjs.kim@samsung.com> Thu, 16 Aug 2012 09:59:28 +0900 + +capi-social-calendar (0.1.1-49) unstable; urgency=low + + * added reminder type enum mapping api. + * Git: framework/api/calendar + * Tag: capi-social-calendar_0.1.1-49 + + -- Jeesun Kim <iamjs.kim@samsung.com> Wed, 08 Aug 2012 10:18:43 +0900 + +capi-social-calendar (0.1.1-48) unstable; urgency=low + + * added recurrence until for allday. + * Git: slp/api/calendar + * Tag: capi-social-calendar_0.1.1-48 + + -- Jeesun Kim <iamjs.kim@samsung.com> Thu, 02 Aug 2012 22:21:15 +0900 + +capi-social-calendar (0.1.1-47) unstable; urgency=low + + * added define for unsetting due time. + * Git: slp/api/calendar + * Tag: capi-social-calendar_0.1.1-47 + + -- Jeesun Kim <iamjs.kim@samsung.com> Mon, 30 Jul 2012 17:44:55 +0900 + +capi-social-calendar (0.1.1-46) unstable; urgency=low + + * fixed jira 6214. + * Git: slp/api/calendar + * Tag: capi-social-calendar_0.1.1-46 + + -- Jeesun Kim <iamjs.kim@samsung.com> Wed, 25 Jul 2012 13:10:40 +0900 + +capi-social-calendar (0.1.1-45) unstable; urgency=low + + * modified jira issue. s1-6213. + * Git: slp/api/calendar + * Tag: capi-social-calendar_0.1.1-45 + + -- Jeesun Kim <iamjs.kim@samsung.com> Mon, 23 Jul 2012 17:57:21 +0900 + +capi-social-calendar (0.1.1-44) unstable; urgency=low + + * fixed jira 6119. + * Git: slp/api/calendar + * Tag: capi-social-calendar_0.1.1-44 + + -- Jeesun Kim <iamjs.kim@samsung.com> Fri, 20 Jul 2012 15:38:23 +0900 + +capi-social-calendar (0.1.1-43) unstable; urgency=low + + * updated changelog for obs. + * Git: slp/api/calendar + * Tag: capi-social-calendar_0.1.1-43 + + -- Jeesun Kim <iamjs.kim@samsung.com> Tue, 17 Jul 2012 18:28:00 +0900 + +capi-social-calendar (0.1.1-42) unstable; urgency=low + + * New API : int calendar_begin_transaction(void); int calendar_rollback_transaction(void); int calendar_commit_transaction(void); + * Git: slp/api/calendar + * Tag: capi-social-calendar_0.1.1-42 + + -- Jeesun Kim <iamjs.kim@samsung.com> Mon, 16 Jul 2012 18:56:06 +0900 + +capi-social-calendar (0.1.1-41) unstable; urgency=low + + * modified free array API + * Git: slp/api/calendar + * Tag: capi-social-calendar_0.1.1-41 + + -- tw123.Kim <tw123.kim@samsung.com> THU, 13 Jul 2012 13:40:00 +0900 + +capi-social-calendar (0.1.1-40) unstable; urgency=low + + * modified reminder API and todo API + * Git: slp/api/calendar + * Tag: capi-social-calendar_0.1.1-40 + + -- tw123.Kim <tw123.kim@samsung.com> THU, 12 Jul 2012 18:40:00 +0900 + +capi-social-calendar (0.1.1-39) unstable; urgency=low + + * Recurrence API changed Time interface format changed from "struct tm" to "long long int" + * Git: slp/api/calendar + * Tag: capi-social-calendar_0.1.1-39 + + -- Jeesun Kim <iamjs.kim@samsung.com> Sun, 01 Jul 2012 16:29:35 +0900 + +capi-social-calendar (0.1.1-38) unstable; urgency=low + + * modified deprecated APIs. + * Git: slp/api/calendar + * Tag: capi-social-calendar_0.1.1-38 + + -- Jeesun Kim <iamjs.kim@samsung.com> Mon, 21 May 2012 20:37:50 +0900 + +capi-social-calendar (0.1.1-37) unstable; urgency=low + + * APIs for Calendar added and changed + * Git: slp/api/calendar + * Tag: capi-social-calendar_0.1.1-37 + + -- Jonghoon Lim <j.h.lim@samsung.com> Tue, 08 May 2012 10:56:20 +0900 + +capi-social-calendar (0.1.1-36) unstable; urgency=low + + * added new APIs. + * Git: slp/api/calendar + * Tag: capi-social-calendar_0.1.1-36 + + -- Jeesun Kim <iamjs.kim@samsung.com> Fri, 30 Mar 2012 21:59:53 +0900 + +capi-social-calendar (0.1.1-35) unstable; urgency=low + + * added capi-social-contacts in makelists. + * Git: slp/api/calendar + * Tag: capi-social-calendar_0.1.1-35 + + -- Jeesun Kim <iamjs.kim@samsung.com> Thu, 22 Mar 2012 11:25:12 +0900 + +capi-social-calendar (0.1.1-34) unstable; urgency=low + + * modified cmakelists -werror for making deprecated api as warning. + * Git: slp/api/calendar + * Tag: capi-social-calendar_0.1.1-34 + + -- Jeesun Kim <iamjs.kim@samsung.com> Wed, 21 Mar 2012 16:00:00 +0900 + capi-social-calendar (0.1.1-33) unstable; urgency=low * package build dependency updated - * Git: api/calendar - * Tag: capi-social-calendar_0.1.1-33 + * Git: slp/api/calendar + * Tag: capi-social-calendar_0.1.1-33 -- Jonghoon Lim <j.h.lim@samsung.com> Fri, 16 Mar 2012 12:01:32 +0900 capi-social-calendar (0.1.1-32) unstable; urgency=low - * Multiple calendar feature added - * Git: api/calendar + * so versioning fixed + * Git: slp/api/calendar * Tag: capi-social-calendar_0.1.1-32 - -- Jonghoon Lim <j.h.lim@samsung.com> Fri, 10 Feb 2012 15:31:07 +0900 + -- Jonghoon Lim <j.h.lim@samsung.com> Thu, 16 Feb 2012 17:03:16 +0900 + +capi-social-calendar (0.1.1-31) unstable; urgency=low + + * so versioning fixed + * Git: slp/api/calendar + * Tag: capi-social-calendar_0.1.1-31 + + -- Jonghoon Lim <j.h.lim@samsung.com> Tue, 14 Feb 2012 16:33:42 +0900 + +capi-social-calendar (0.1.1-30) unstable; urgency=low + + * calendar_event_get_calendar_db_id, calendar_todo_get_calendar_db_id + * Git: slp/api/calendar + * Tag: capi-social-calendar_0.1.1-30 + + -- Jonghoon Lim <j.h.lim@samsung.com> Thu, 02 Feb 2012 10:40:10 +0900 + +capi-social-calendar (0.1.1-29) unstable; urgency=low + + * DEFAULT_CALENDAR_DB_ID newly defined + * Git: slp/api/calendar + * Tag: capi-social-calendar_0.1.1-29 + + -- Jonghoon Lim <j.h.lim@samsung.com> Thu, 26 Jan 2012 11:03:46 +0900 + +capi-social-calendar (0.1.1-28) unstable; urgency=low + + * multi calendar feature added + * Git: slp/api/calendar + * Tag: capi-social-calendar_0.1.1-28 + + -- Jonghoon Lim <j.h.lim@samsung.com> Mon, 16 Jan 2012 17:28:33 +0900 capi-social-calendar (0.1.1-27) unstable; urgency=low - * version updated - * Git: api/calendar - * Tag: capi-social-calendar_0.1.1-27 + * Typo error fixed + * Git: slp/api/calendar + * Tag: capi-social-calendar_0.1.1-27 - -- Jonghoon Lim <j.h.lim@samsung.com> Mon, 19 Dec 2011 14:52:01 +0900 + -- Jonghoon Lim <j.h.lim@samsung.com> Mon, 19 Dec 2011 14:31:53 +0900 capi-social-calendar (0.1.1-26) unstable; urgency=low - * version updated - * Git: api/calendar + * Removed using hidden Legacy API + * Git: slp/api/calendar * Tag: capi-social-calendar_0.1.1-26 - -- Jonghoon Lim <j.h.lim@samsung.com> Thu, 15 Dec 2011 13:43:07 +0900 + -- Jonghoon Lim <j.h.lim@samsung.com> Fri, 09 Dec 2011 09:26:07 +0900 + +capi-social-calendar (0.1.1-25) unstable; urgency=low + + * spec file updated + * Git: slp-source.sec.samsung.net:slp/api/calendar + * Tag: capi-social-calendar_0.1.1-25 + + -- Jonghoon Lim <j.h.lim@samsung.com> Wed, 07 Dec 2011 12:59:01 +0900 + +capi-social-calendar (0.1.1-24) unstable; urgency=low + + * To follow up, calendar-service To-do status symbol changing 2 + * Git: slp-source.sec.samsung.net:slp/api/calendar + * Tag: capi-social-calendar_0.1.1-24 + + -- Jonghoon Lim <j.h.lim@samsung.com> Wed, 07 Dec 2011 10:55:04 +0900 + +capi-social-calendar (0.1.1-23) unstable; urgency=low + + * To follow up, calendar-service To-do status symbol changing + * Git: slp-source.sec.samsung.net:slp/api/calendar + * Tag: capi-social-calendar_0.1.1-23 + + -- Jonghoon Lim <j.h.lim@samsung.com> Tue, 06 Dec 2011 19:22:52 +0900 + +capi-social-calendar (0.1.1-22) unstable; urgency=low + + * To follow up, calendar service multi alarm + * Git: slp-source.sec.samsung.net:slp/api/calendar + * Tag: capi-social-calendar_0.1.1-22 + + -- Jonghoon Lim <j.h.lim@samsung.com> Mon, 05 Dec 2011 18:35:38 +0900 + +capi-social-calendar (0.1.1-21) unstable; urgency=low + + * TIZEN_ERROR_OK --> TIZEN_ERROR_NONE + * Git: slp-source.sec.samsung.net:slp/api/calendar + * Tag: capi-social-calendar_0.1.1-21 + + -- Jonghoon Lim <j.h.lim@samsung.com> Mon, 05 Dec 2011 13:03:18 +0900 + +capi-social-calendar (0.1.1-2) unstable; urgency=low + + * dlog details added + * Git: slp-source.sec.samsung.net:slp/api/calendar + * Tag: capi-social-calendar_0.1.1-2 + + -- Jonghoon Lim <j.h.lim@samsung.com> Wed, 30 Nov 2011 20:36:17 +0900 + +capi-social-calendar (0.1.1-1) unstable; urgency=low + + * tizen namespace applied + * Git: slp-source.sec.samsung.net:slp/api/calendar + * Tag: capi-social-calendar_0.1.1-1 + + -- Jonghoon Lim <j.h.lim@samsung.com> Wed, 23 Nov 2011 14:20:28 +0900 + +capi-social-calendar (0.1.0-22) unstable; urgency=low + + * Follow up calendar-service changes + * Git: slp-source.sec.samsung.net:slp/api/calendar + * Tag: capi-social-calendar_0.1.0-22 + + -- Jonghoon Lim <j.h.lim@samsung.com> Mon, 21 Nov 2011 15:59:42 +0900 + +capi-social-calendar (0.1.0-21) unstable; urgency=low + + * Build break fix + * Git: slp-source.sec.samsung.net:slp/api/calendar + * Tag: capi-social-calendar_0.1.0-21 + + -- Jonghoon Lim <j.h.lim@samsung.com> Mon, 21 Nov 2011 06:26:49 +0900 + +capi-social-calendar (0.1.0-2-dts40) unstable; urgency=low + + * DTS updated + * Git: slp-source.sec.samsung.net:slp/api/calendar + * Tag: capi-social-calendar_0.1.0-2_dts40 + + -- Jonghoon Lim <j.h.lim@samsung.com> Mon, 10 Oct 2011 11:20:33 +0900 + +capi-social-calendar (0.1.0-2-dts) unstable; urgency=low + + * DTS updated + * Git: slp-source.sec.samsung.net:slp/api/calendar + * Tag: capi-social-calendar_0.1.0-2_dts + + -- Jonghoon Lim <j.h.lim@samsung.com> Wed, 05 Oct 2011 17:24:50 +0900 + +capi-social-calendar (0.1.0-1) unstable; urgency=low + + * alpha release + * Git: slp-source.sec.samsung.net:slp/api/calendar + * Tag: capi-social-calendar_0.1.0-1 + + -- Jonghoon Lim <j.h.lim@samsung.com> Tue, 27 Sep 2011 21:43:15 +0900 + +capi-social-calendar (0.0.1-14) unstable; urgency=low + + * alpha + * Git: slp-source.sec.samsung.net:slp/api/calendar + * Tag: capi-social-calendar_0.0.1-14 + + -- Jonghoon Lim <j.h.lim@samsung.com> Mon, 26 Sep 2011 22:21:40 +0900 + +capi-social-calendar (0.0.1-13) unstable; urgency=low + + * alpha + * Git: slp-source.sec.samsung.net:slp/api/calendar + * Tag: capi-social-calendar_0.0.1-13 + + -- Jonghoon Lim <j.h.lim@samsung.com> Fri, 23 Sep 2011 20:12:32 +0900 + +capi-social-calendar (0.0.1-12) unstable; urgency=low + + * "alpha" release : applied Vincent's and Juwon's review + * Git: slp-source.sec.samsung.net:slp/api/calendar + * Tag: capi-social-calendar_0.0.1-12 + + -- Jonghoon Lim <j.h.lim@samsung.com> Fri, 23 Sep 2011 20:06:59 +0900 + +capi-social-calendar (0.0.1-11) unstable; urgency=low + + * "To do" object added, timezone function added + * Git: slp-source.sec.samsung.net:slp/api/calendar + * Tag: capi-social-calendar_0.0.1-11 + + -- Jonghoon Lim <j.h.lim@samsung.com> Mon, 05 Sep 2011 11:04:51 +0900 capi-social-calendar (0.0.1-1) unstable; urgency=low + * Initial upload + * Git: slp-source.sec.samsung.net:slp/api/calendar + * Tag: capi-social-calendar_0.0.1-1 - * Initial release. + -- Jonghoon Lim <j.h.lim@samsung.com> Mon, 08 Aug 2011 09:49:19 +0900 - -- Jonghoon Lim <j.h.lim@samsung.com> Wed, 07 Dec 2011 12:48:12 +0900 diff --git a/debian/rules b/debian/rules index fb887f6..5ba9d0b 100755 --- a/debian/rules +++ b/debian/rules @@ -26,11 +26,10 @@ build-stamp: configure-stamp touch $@ clean: - cd $(CMAKE_ROOT_DIR) dh_testdir dh_testroot rm -f build-stamp configure-stamp - rm -f + -cd $(CMAKE_BUILD_DIR) && $(MAKE) distclean rm -rf $(CMAKE_BUILD_DIR) dh_clean diff --git a/include/calendar.h b/include/calendar.h index cb12a45..74020d0 100755 --- a/include/calendar.h +++ b/include/calendar.h @@ -11,17 +11,17 @@ * 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. + * limitations under the License. */ - + #ifndef __TIZEN_SOCIAL_CALENDAR_CALENDAR_H__ #define __TIZEN_SOCIAL_CALENDAR_CALENDAR_H__ #include <tizen.h> #include <time.h> -#include <calendar_attendee.h> -#include <calendar_types.h> +#include "calendar_attendee.h" +#include "calendar_types.h" #ifdef __cplusplus @@ -36,9 +36,9 @@ extern "C" { /** * @brief Connects to the calendar service. * - * @details Opening connection is necessary to access the calendar database. + * @details Opening connection is necessary to access the calendar database. * All operations like inserting, updating, or deleting calendar require opened connection to work properly. - + * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_DB_FAILED No access to database @@ -61,27 +61,56 @@ int calendar_connect(void); int calendar_disconnect(void); /** - * @brief Retrieves all timezone information supported on a device. + * @brief Begins transaction to calendar database * - * @param[in] callback The callback function to invoke - * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_DB_FAILED No access to database * - * @return 0 on success, otherwise a negative error value. - * @retval #CALENDAR_ERROR_NONE Successful - * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * @pre This function requires an open connection to the calendar service by calendar_connect(). * - * @post This function invokes calendar_foreach_timezone_cb(). + * @see calendar_connect() + * @see calendar_rollback_transaction() + * @see calendar_commit_transaction() + */ +int calendar_begin_transaction(void); + +/** + * @brief Rollbacks transaction to calendar database * - * @see calendar_foreach_timezone_cb() - * @see calendar_event_set_timezone() - * @see calendar_todo_set_timezone() + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_DB_FAILED No access to database + * + * @pre This function requires an open connection to the calendar service by calendar_connect(). + * + * @see calendar_connect() + * @see calendar_begin_transaction() + * @see calendar_commit_transaction() */ -int calendar_foreach_timezone(calendar_foreach_timezone_cb callback, void *user_data); +int calendar_rollback_transaction(void); /** - * @brief Registers a callback function to be invoked when any database change occur. + * @brief Commits transaction to calendar database + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_DB_FAILED No access to database * - * @param[in] callback The callback function to invoke + * @pre This function requires an open connection to the calendar service by calendar_connect(). + * + * @see calendar_connect() + * @see calendar_begin_transaction() + * @see calendar_rollback_transaction() + */ +int calendar_commit_transaction(void); + + +/** + * @brief Registers a callback function to be invoked when any database change occurs. + * + * @param[in] callback The callback function to invoke + * @param[in] type The notification type to subscribe * @param[in] user_data The user data to be passed to the callback function * * @return 0 on success, otherwise a negative error value. @@ -90,19 +119,26 @@ int calendar_foreach_timezone(calendar_foreach_timezone_cb callback, void *user_ * * @pre This function requires an open connection to the calendar service by calendar_connect(). * @post calendar_db_changed_cb() will be invoked. - * + * * @see calendar_db_changed_cb() - * @see calendar_unset_db_changed_cb() + * @see calendar_remove_db_changed_cb() + * @see calendar_book_insert_to_db() + * @see calendar_book_update_to_db() + * @see calendar_book_delete_from_db() * @see calendar_event_insert_to_db() * @see calendar_event_update_to_db() * @see calendar_event_delete_from_db() + * @see calendar_todo_insert_to_db() + * @see calendar_todo_update_to_db() + * @see calendar_todo_delete_from_db() */ -int calendar_set_db_changed_cb(calendar_db_changed_cb callback, void *user_data); +int calendar_add_db_changed_cb(calendar_db_changed_cb callback, calendar_db_changed_cb_type_e type, void *user_data); /** * @brief Unregisters the callback function. * * @param[in] callback The callback function to unregister + * @param[in] type The notification type to unregister callback * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful @@ -110,9 +146,23 @@ int calendar_set_db_changed_cb(calendar_db_changed_cb callback, void *user_data) * * @pre This function requires an open connection to the calendar service by calendar_connect(). * @see calendar_db_changed_cb() - * @see calendar_set_db_changed_cb() + * @see calendar_add_db_changed_cb() + */ +int calendar_remove_db_changed_cb(calendar_db_changed_cb callback, calendar_db_changed_cb_type_e type); + +/** + * @brief Gets the calendar database version. + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALENDAR_ERROR_DB_FAILED Database operation failure + * + * @see calendar_connect() + * @see calendar_query_event_by_version() + * @see calendar_query_todo_by_version() */ -int calendar_unset_db_changed_cb(calendar_db_changed_cb callback); +int calendar_get_db_version(int* calendar_db_version); /** * @} @@ -144,7 +194,7 @@ int calendar_event_create(calendar_event_h *event); /** * @brief Destroys the calendar event handle and releases all its resources. * - * @param[out] event The calendar event handle + * @param[out] event The calendar event handle * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful @@ -158,10 +208,10 @@ int calendar_event_destroy(calendar_event_h event); /** * @brief Adds a calendar event to the calendar database. * - * @param[in] event The calendar event handle - * @param[in] calendar_db_id The calendar database ID to which the event insert. \n - * 1 means the default calendar on the device - * @param[out] event_db_id The event db ID associated with the calendar event \n + * @param[in] event The calendar event handle + * @param[in] calendar_book_db_id The calendar book database ID to which the event insert. \n + * #DEFAULT_EVENT_CALENDAR_BOOK_DB_ID means the default event calendar book on the device + * @param[out] event_db_id The event database ID associated with the calendar event \n * If the function fails, it is -1. * * @return 0 on success, otherwise a negative error value. @@ -174,12 +224,12 @@ int calendar_event_destroy(calendar_event_h event); * @see calendar_event_update_to_db() * @see calendar_event_delete_from_db() */ -int calendar_event_insert_to_db(calendar_event_h event, int calendar_db_id, int *event_db_id); +int calendar_event_insert_to_db(calendar_event_h event, int calendar_book_db_id, int *event_db_id); /** * @brief Removes the calendar event from the calendar database. * - * @param[in] event_id The event ID to delete + * @param[in] event_db_id The database event ID to delete * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful @@ -191,13 +241,13 @@ int calendar_event_insert_to_db(calendar_event_h event, int calendar_db_id, int * @see calendar_event_insert_to_db() * @see calendar_event_update_to_db() */ -int calendar_event_delete_from_db(int event_id); +int calendar_event_delete_from_db(int event_db_id); /** * @brief Updates the calendar event in the calendar database. * @details calendar_event_get_db_id() is called internally to update in the calendar database to get the event ID in the calendar database. * - * @param[in] event The calendar event handle + * @param[in] event The calendar event handle * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful @@ -218,9 +268,9 @@ int calendar_event_update_to_db(calendar_event_h event); /** * @brief Gets the calendar event from the calendar database. * @details This function gets the new calendar event handle with the given event database ID from the calendar database. \n - * The new calendar event handle will be created. + * The new calendar event handle will be created. * - * @remarks The created calendar event handle must be released with calendar_event_destroy() by you. + * @remarks The created calendar event handle must be released with calendar_event_destroy() by you. * * * @param[in] event_id The event ID @@ -235,14 +285,14 @@ int calendar_event_update_to_db(calendar_event_h event); * * @see calendar_event_destroy() */ -int calendar_event_get_from_db(int event_id, calendar_event_h *event); +int calendar_event_get_from_db(int event_db_id, calendar_event_h *event); /** - * @brief Gets the database ID associated with the given calendar event handle. + * @brief Gets the database ID associated with the given calendar event handle. * * @param[in] event The calendar event handle * @param[out] event_db_id The event database ID fetched from the calendar event handle (default : 0) \n - * 0 means the event is not in calendar database. + * 0 means the event is not in calendar database. * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful @@ -254,11 +304,11 @@ int calendar_event_get_from_db(int event_id, calendar_event_h *event); int calendar_event_get_db_id(calendar_event_h event, int *event_db_id); /** - * @brief Gets the calendar database ID associated with the given calendar event handle. + * @brief Gets The calendar book database ID associated with the given calendar event handle. * * @param[in] event The calendar event handle - * @param[out] calendar_db_id The calendar database ID fetched from the calendar event handle (default : 0) \n - * 0 means the event is not in calendar database. + * @param[out] calendar_book_db_id The calendar book database ID fetched from the calendar event handle (default : 0) \n + * 0 means the event is not in calendar database. * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful @@ -266,14 +316,14 @@ int calendar_event_get_db_id(calendar_event_h event, int *event_db_id); * * @see calendar_event_insert_to_db() */ -int calendar_event_get_calendar_db_id(calendar_event_h event, int *calendar_db_id); +int calendar_event_get_calendar_book_db_id(calendar_event_h event, int *calendar_book_db_id); /** * @brief Gets the subject of the event from the calendar event handle . * * @remarks @a subject must be released with free() by you. * - * @param [in] event The calendar event handle + * @param [in] event The calendar event handle * @param [out] subject The subject of the event \n If the subject does not exist, it is NULL * * @return 0 on success, otherwise a negative error value. @@ -285,11 +335,10 @@ int calendar_event_get_calendar_db_id(calendar_event_h event, int *calendar_db_i */ int calendar_event_get_subject(calendar_event_h event, char **subject); - /** * @brief Sets the subject of the event in the calendar event handle. * - * @param [in] event The calendar event handle + * @param [in] event The calendar event handle * @param [in] subject The subject of the event * * @return 0 on success, otherwise a negative error value. @@ -300,13 +349,12 @@ int calendar_event_get_subject(calendar_event_h event, char **subject); */ int calendar_event_set_subject(calendar_event_h event, const char *subject); - /** * @brief Gets the description of the event from the calendar event handle. * - * @remarks @a description must be released with free() by you. + * @remarks @a description must be released with free() by you. * - * @param [in] event The calendar event handle + * @param [in] event The calendar event handle * @param [out] description The description of the event \n If the description does not exist, it is NULL * * @return 0 on success, otherwise a negative error value. @@ -317,11 +365,10 @@ int calendar_event_set_subject(calendar_event_h event, const char *subject); */ int calendar_event_get_description(calendar_event_h event, char **description); - /** * @brief Sets a description of the event in the calendar event handle. * - * @param [in] event The calendar event handle + * @param [in] event The calendar event handle * @param [in] description The description of the event * * @return 0 on success, otherwise a negative error value. @@ -332,11 +379,72 @@ int calendar_event_get_description(calendar_event_h event, char **description); */ int calendar_event_set_description(calendar_event_h event, const char *description); +/** + * @brief Gets the start time of the event from the calendar event handle. + * + * @param [in] event The calendar event handle + * @param [out] start_time The start date of the event \n + * The @a start_time is a unix timestamp since 00:00, Jan 1 1970 UTC. + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALENDAR_ERROR_NO_DATA Data not found + * + * @see calendar_event_set_start_time() + */ +int calendar_event_get_start_time(calendar_event_h event, long long int *start_time); + +/** + * @brief Sets a start time of the event in the calendar event handle. + * + * @param [in] event The calendar event handle + * @param [in] start_time The start date of the event \n + * The @a start_time is a unix timestamp since 00:00, Jan 1 1970 UTC. + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_event_get_start_time() + */ +int calendar_event_set_start_time(calendar_event_h event, long long int start_time); + +/** + * @brief Gets the end time of the event from the calendar event handle. + * + * @param [in] event The calendar event handle + * @param [out] end_time The end date of the event\n + * The @a end_time is a unix timestamp since 00:00, Jan 1 1970 UTC. + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALENDAR_ERROR_NO_DATA Data not found + * + * @see calendar_event_set_end_time() + */ +int calendar_event_get_end_time(calendar_event_h event, long long int *end_time); + +/** + * @brief Sets the end time of the event in the calendar event handle. + * + * @param[in] event The calendar event handle + * @param[in] end_time The end date of the event\n + * The @a end_time is a unix timestamp since 00:00, Jan 1 1970 UTC. + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_event_get_end_time() + */ +int calendar_event_set_end_time(calendar_event_h event, long long int end_time); /** * @brief Gets an all-day event property of the calendar event handle. * - * @param [in] event The calendar event handle + * @param [in] event The calendar event handle * @param [out] is_all_day_event @c true if the event lasts for an entire day, otherwise @c false \n * (default : @c false) * @@ -348,30 +456,54 @@ int calendar_event_set_description(calendar_event_h event, const char *descripti */ int calendar_event_get_is_all_day_event(calendar_event_h event, bool *is_all_day_event); - /** - * @brief Sets an all-day event property of the calendar event handle. + * @brief Sets an all-day event with date range * - * @param [in] event The calendar event handle - * @param [in] is_all_day_event The all-day event type \n - * @c true if the event will last for an entire day, otherwise @c false \n - * (default : @c false) + * @param [in] event The calendar event handle + * @param [in] start_year Year of start date + * @param [in] start_month Month of start date + * @param [in] start_day Day of start date + * @param [in] end_year Year of end date + * @param [in] end_month Month of end date + * @param [in] end_day Day of end date * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * * @see calendar_event_get_is_all_day_event() + * @see calendar_event_get_all_day_event() */ -int calendar_event_set_is_all_day_event(calendar_event_h event, bool is_all_day_event); +int calendar_event_set_all_day_event(calendar_event_h event, int start_year, int start_month, int start_day, + int end_year, int end_month, int end_day); +/** + * @brief Gets an all-day event date range + * + * @param [in] event The calendar event handle + * @param [out] start_year Year of start date + * @param [out] start_month Month of start date + * @param [out] start_day Day of start date + * @param [out] end_year Year of end date + * @param [out] end_month Month of end date + * @param [out] end_day Day of end date + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_event_get_is_all_day_event() + * @see calendar_event_set_all_day_event() + */ +int calendar_event_get_all_day_event(calendar_event_h event, int *start_year, int *start_month, int *start_day, + int *end_year, int *end_month, int *end_day); /** * @brief Gets the location of the event from the calendar event handle. * - * @remarks @a location must be released with free() by you. + * @remarks @a location must be released with free() by you. * - * @param [in] event The calendar event handle + * @param [in] event The calendar event handle * @param [out] location The location of the event \n If the location does not exist, it is NULL * * @return 0 on success, otherwise a negative error value. @@ -382,11 +514,10 @@ int calendar_event_set_is_all_day_event(calendar_event_h event, bool is_all_day_ */ int calendar_event_get_location(calendar_event_h event, char **location); - /** * @brief Sets a location of the event in the calendar event handle. * - * @param [in] event The calendar event handle + * @param [in] event The calendar event handle * @param [in] location The location of the event * * @return 0 on success, otherwise a negative error value. @@ -397,15 +528,14 @@ int calendar_event_get_location(calendar_event_h event, char **location); */ int calendar_event_set_location(calendar_event_h event, const char *location); - /** * @brief Gets the reminder of the event from the calendar event handle. * @details The function returns reminder type and interval of the event. - * * - * @param [in] event The calendar event handle - * @param [out] reminder_interval_type The reminder type - * @param [out] reminder_interval The interval + * + * @param [in] event The calendar event handle + * @param [out] reminder_interval_type The reminder type + * @param [out] reminder_interval The interval * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful @@ -415,13 +545,12 @@ int calendar_event_set_location(calendar_event_h event, const char *location); */ int calendar_event_get_reminder(calendar_event_h event, calendar_reminder_interval_type_e *reminder_interval_type, int *reminder_interval); - /** * @brief Sets a reminder of the event in the calendar event handle. * * @remarks If reminder is set, the alarm will remind the event with in-house calendar application. * - * @param [in] event The calendar event handle + * @param [in] event The calendar event handle * @param [in] reminder_interval_type The reminder interval type * @param [in] reminder_interval The reminder interval * @@ -434,556 +563,825 @@ int calendar_event_get_reminder(calendar_event_h event, calendar_reminder_interv int calendar_event_set_reminder(calendar_event_h event, calendar_reminder_interval_type_e reminder_interval_type, int reminder_interval); /** - * @brief Gets the recurrence frequency of the event from the calendar event handle. + * @brief Gets the sound file path from the event handle. + * + * @remarks @a sound_file_path must be released with free() by you. + * + * @param[in] event The calendar event handle + * @param[out] sound_file_path The sound file path \n + * If @a sound_file_path does not exist, it is NULL + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_event_set_reminder_sound_file_path() + */ +int calendar_event_get_reminder_sound_file_path(calendar_event_h event, char **sound_file_path); + +/** + * @brief Sets the sound file path to the event handle. * - * @param[in] event The calendar event handle - * @param[out] recurrence_frequency The recurrence type of the event + * @param[in] event The calendar event handle + * @param[in] sound_file_path The sound file path to set * * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_event_get_reminder_sound_file_path() + */ +int calendar_event_set_reminder_sound_file_path(calendar_event_h event, const char *sound_file_path); + +/** + * @brief Creates a attendee handle and make adds it to the calendar event. + * + * @remarks The created handle is not added to calendar database until calendar_event_insert_to_db() is called + * + * @param[in] event The calendar event handle + * @param[out] attendee A new attendee handle + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_event_remove_attendee() + * @see calendar_attendee_set_name() + * @see calendar_attendee_set_email() + * @see calendar_attendee_set_phone_number() + * @see calendar_event_get_attendee_iterator() + */ +int calendar_event_add_attendee(calendar_event_h event, calendar_attendee_h* attendee); + +/** + * @brief Creates a attendee handle with contact ID and adds it to the calendar event. + * + * @details Adds an existing contact as an attendee to an event. A new attendee record is created, and the name, email address and phone number are populated from the values in the contact record. + * @remarks The created handle is not added to calendar database until calendar_event_insert_to_db() is called + * + * + * @param[in] event The calendar event handle + * @param[in] contact_db_id The contact DB ID which is related to attendee + * @param[out] attendee A new attendee handle from contact ID in the contacts database + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre This function requires an open connection to Contacts Service by contacts_connect(). + * + * @see calendar_event_remove_attendee() + * @see calendar_attendee_set_name() + * @see calendar_attendee_set_email() + * @see calendar_attendee_set_phone_number() + * @see calendar_event_get_attendee_iterator() + * @see contact_get_db_id() + * @see contact_get_from_db() + * @see calendar_attendee_get_phone_number() + */ +int calendar_event_add_attendee_with_contact(calendar_event_h event, int contact_db_id, calendar_attendee_h* attendee); + +/** + * @brief Removes the attendee from the calendar event handle. + * + * + * @param[in] event The calendar event handle + * @param[in] attendee The attendee handle + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_event_add_attendee() + * @see calendar_event_get_attendee_iterator() + */ +int calendar_event_remove_attendee(calendar_event_h event, calendar_attendee_h attendee); + +/** + * @brief Gets the attendee iterator handle from the event handle. + * + * @param[in] event The calendar event handle + * @param[out] iterator The attendee iterator handle + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_attendee_iterator_has_next() + * @see calendar_attendee_iterator_next() + * + */ +int calendar_event_get_attendee_iterator(calendar_event_h event, calendar_attendee_iterator_h *iterator); + +/** + * @brief Gets the last modified time of the event handle. + * + * @param[in] event The calendar event handle + * @param[out] modified_time The last modified time of event \n + * The @a modified_time is a unix timestamp since 00:00, Jan 1 1970 UTC. + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALENDAR_ERROR_NO_DATA Data not found + * + * @see calendar_event_insert_to_db() + * @see calendar_event_update_to_db() + */ +int calendar_event_get_last_modified_time(calendar_event_h event, long long int *modified_time); + +/** + * @brief Gets the visibility for the given calendar event handle. + * + * @param[in] event The calendar event handle + * @param[out] visibility The visibility of the event \n (default : #CALENDAR_VISIBILITY_PUBLIC) + * + * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * - * @see calendar_event_set_recurrence_frequency() - * @see calendar_event_set_recurrence_week_flag() - * @see calendar_event_get_recurrence_week_flag() - * @see calendar_event_add_recurrence_exception_date() + * @see calendar_event_set_visibility() */ -int calendar_event_get_recurrence_frequency(calendar_event_h event, calendar_recurrence_frequency_e *recurrence_frequency); +int calendar_event_get_visibility(calendar_event_h event, calendar_visibility_e *visibility); +/** + * @brief Sets the visibility for the given calendar event handle. + * + * @param[in] event The calendar event handle + * @param[in] visibility The visibility of the event + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_event_get_visibility() + */ +int calendar_event_set_visibility(calendar_event_h event, calendar_visibility_e visibility); /** - * @brief Sets a recurrence frequency of the event in the calendar event handle. + * @brief Gets the category for the given calendar event handle. + * @remarks @a categories must be released with free() by you. * - * @param [in] event The calendar event handle - * @param [in] recurrence_frequency The recurrence frequency of the event \n - * If you set it to #CALENDAR_RECURRENCE_WEEKLY, you have to set calendar_event_set_recurrence_week_flag(). + * @param[in] event The calendar event handle + * @param[out] categories The category of the event \n Multiple categories are seperated by "," * - * @return 0 on success, otherwise a negative error value. - * @retval #CALENDAR_ERROR_NONE Successful - * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * - * @see calendar_event_get_recurrence_frequency() - * @see calendar_event_set_recurrence_week_flag() - * @see calendar_event_get_recurrence_week_flag() - * @see calendar_event_add_recurrence_exception_date() + * @see calendar_event_set_categories() */ -int calendar_event_set_recurrence_frequency(calendar_event_h event, calendar_recurrence_frequency_e recurrence_frequency); +int calendar_event_get_categories(calendar_event_h event, char **categories); /** - * @brief Gets the recurrence frequency of the event in the calendar event handle. + * @brief Sets the category for the given calendar event handle. * - * @remarks This function is valid only if recurrence frequency of the event is #CALENDAR_RECURRENCE_WEEKLY. + * @param[in] event The calendar event handle + * @param[in] categories The category of the event \n Multiple categories are seperated by "," * - * @param[in] event The calendar event handle - * @param[out] week_flag The days of week flag of the event \n It supports "OR"ing combination of #calendar_week_flag_e. \n eg) #CALENDAR_WEEK_FLAG_TUE | #CALENDAR_WEEK_FLAG_FRI + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * - * @return 0 on success, otherwise a negative error value. + * @see calendar_event_get_categories() + */ +int calendar_event_set_categories(calendar_event_h event, const char *categories); + +/** + * @brief Gets the status for the given calendar event handle. + * + * @param[in] event The calendar event handle + * @param[out] status The status of the event \n (default : #CALENDAR_EVENT_STATUS_NONE) + * + * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * - * @see calendar_event_set_recurrence_week_flag() - * @see calendar_event_set_recurrence_frequency() - * @see calendar_event_get_recurrence_frequency() + * @see calendar_event_set_status() */ -int calendar_event_get_recurrence_week_flag(calendar_event_h event, int *week_flag); +int calendar_event_get_status(calendar_event_h event, calendar_event_status_e *status); /** - * @brief Sets the days of week flag to the calendar event handle. + * @brief Sets a status for the given calendar event handle. + * + * @param[in] event The calendar event handle + * @param[in] status The status of the event + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * - * @remarks This function is valid only if recurrence frequency of the event is #CALENDAR_RECURRENCE_WEEKLY. + * @see calendar_event_get_status() + */ +int calendar_event_set_status(calendar_event_h event, calendar_event_status_e status); + +/** + * @brief Gets the busy status for the given calendar event handle. * - * @param[in] event The calendar event handle - * @param[in] week_flag The days of week flag of the event \n It supports "OR"ing combination of #calendar_week_flag_e. \n eg) #CALENDAR_WEEK_FLAG_TUE | #CALENDAR_WEEK_FLAG_FRI + * @param[in] event The calendar event handle + * @param[out] busy_status The busy status of the event \n (default : #CALENDAR_EVENT_BUSY_STATUS_FREE) * - * @return 0 on success, otherwise a negative error value. + * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * - * @see calendar_event_get_recurrence_week_flag() - * @see calendar_event_set_recurrence_frequency() - * @see calendar_event_get_recurrence_frequency() + * @see calendar_event_set_busy_status() + */ +int calendar_event_get_busy_status(calendar_event_h event, calendar_event_busy_status_e *busy_status); + +/** + * @brief Sets a busy status for the given calendar event handle. * + * @param[in] event The calendar event handle + * @param[in] busy_status The busy status of the event + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_event_get_busy_status() */ -int calendar_event_set_recurrence_week_flag(calendar_event_h event, int week_flag); +int calendar_event_set_busy_status(calendar_event_h event, calendar_event_busy_status_e busy_status); /** - * @brief Gets the recurrence ending time of the event from the calendar event handle. - * @details If recurrence frequency of the event is activated, then @a recurrence_until_date indicates recurrence ending time. + * @brief Gets the priority for the given calendar event handle. + * + * @param[in] event The calendar event handle + * @param[out] priority The priority of the event \n (default : #CALENDAR_EVENT_PRIORITY_LOW) + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_event_set_priority() + */ +int calendar_event_get_priority(calendar_event_h event, calendar_event_priority_e *priority); + +/** + * @brief Sets a priority for the given calendar event handle. + * + * @param[in] todo The calendar event handle + * @param[in] priority The priority of the event + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_event_get_priority() + */ +int calendar_event_set_priority(calendar_event_h event, calendar_event_priority_e priority); + +/** + * @brief Gets the UID of the event from the calendar event handle. + * + * @remarks @a uid must be released with free() by you. * - * @param [in] event The calendar event handle - * @param [out] recurrence_until_date The ending time of the recurrence event + * @param [in] event The calendar event handle + * @param [out] uid The UID of the event \n If the uid does not exist, it is NULL * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CALENDAR_ERROR_NO_DATA Data not found * - * @see calendar_event_set_recurrence_until_date() + * @see calendar_event_set_uid() */ -int calendar_event_get_recurrence_until_date(calendar_event_h event, struct tm *recurrence_until_date); - +int calendar_event_get_uid(calendar_event_h event, char **uid); /** - * @brief Sets a recurrence end time of the event in the calendar event handle. + * @brief Sets a UID of the event in the calendar event handle. * - * @param [in] event The calendar event handle - * @param [in] recurrence_until_date The end time of the recurrence event + * @param [in] event The calendar event handle + * @param [in] uid The UID of the event * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * - * @pre @a event has a recurrence frequency property using calendar_event_set_recurrence_frequency(). - * - * @see calendar_event_get_recurrence_until_date() + * @see calendar_event_get_uid() */ -int calendar_event_set_recurrence_until_date(calendar_event_h event, struct tm recurrence_until_date); +int calendar_event_set_uid(calendar_event_h event, const char *uid); /** - * @brief Adds a recurrence exception date to the calendar event handle. + * @brief Gets the timezone details for the given calendar event handle. * - * @param[in] event The calendar event handle - * @param[in] year The year of date \n It has to be more than 1900 - * @param[in] month The month of date [1-12] - * @param[in] day The day of date [1-31] + * @remark @a timezone_name must be released with free() by you. + * + * @param[in] event The calendar event handle + * @param[out] timezone_name The time zone name * * @return 0 on success, otherwise a negative error value. - * @retval #CALENDAR_ERROR_NONE Successful - * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory - * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * - * @see calendar_event_set_recurrence_frequency() - * @see calendar_event_get_recurrence_exception_iterator() + * @see calendar_foreach_timezone() + * @see calendar_event_set_timezone() */ -int calendar_event_add_recurrence_exception_date(calendar_event_h event, int year, int month, int day); - +int calendar_event_get_timezone(calendar_event_h event, char** timezone_name); /** - * @brief Gets the recurrence exception iterator handle from the event handle. + * @brief Sets a timezone for the given calendar event handle. * - * @param[in] event The calendar event handle - * @param[out] iterator The recurrence exception iterator handle \n If the iterator does not exist, it is NULL + * @param[in] event The calendar event handle + * @param[in] timezone_name The time zone name * * @return 0 on success, otherwise a negative error value. - * @retval #CALENDAR_ERROR_NONE Successful - * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * - * @see calendar_recurrence_exception_has_next() - * @see calendar_recurrence_exception_next() + * @see calendar_foreach_timezone() + * @see calendar_event_get_timezone() */ -int calendar_event_get_recurrence_exception_iterator(calendar_event_h event, calendar_recurrence_exception_iterator_h *iterator); +int calendar_event_set_timezone(calendar_event_h event, const char* timezone_name); /** - * @brief Checks whether there is a next recurrence exception handle on the list. + * @brief Gets events as array from vCalendar * - * @param [in] iterator The recurrence exception iterator handle + * @remarks @a event_array must be released with calendar_event_free_event_array() by you. * - * @return @c true If the next element exists or @c false If the next element doesn't exist + * @param[in] vcalendar_stream The vCalendar stream to convert + * @param[out] event_array The event array + * @param[out] length The length of the event array * - * @see calendar_event_get_recurrence_exception_iterator() - * @see calendar_recurrence_exception_next() + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory + * + * @see calendar_event_free_event_array() + * @see calendar_event_get_vcalendar_from_db() */ -bool calendar_recurrence_exception_has_next(calendar_recurrence_exception_iterator_h iterator); +int calendar_event_get_event_array_from_vcalendar(const char *vcalendar_stream, calendar_event_h **event_array, int *length); /** - * @brief Moves recurrence exception list iterator to the next position and gets recurrence exception date. - * @details If the next element for the current recurrence exception list exists, then the iterator is moved to - * the next position on the list and the recurrence exception handle for this position is returned. - * When the iterator reaches the last element of the list, all further calls will return - * #CALENDAR_ERROR_ITERATOR_END and @a recurrence exception will remain unchanged. + * @brief Gets vCalendar with event database ID from the calendar database * - * @param [in] iterator The recurrent exception iterator handle - * @param [out] year The year of date \n It is supposed to be more than 1900 - * @param [out] month The month of date [1-12] - * @param [out] day The day of date [1-31] + * @remarks @a vcalendar_stream must be released with free() by you. * - * @return 0 on success, otherwise a negative error value. - * @retval #CALENDAR_ERROR_NONE Successful - * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CALENDAR_ERROR_ITERATOR_END Iterator is on the last position + * @param[in] event_db_id_array The event database ID array + * @param[in] length Length of event database ID array + * @param[out] vcalendar_stream The vCalendar stream to convert + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * - * @see calendar_event_get_recurrence_exception_iterator() - * @see calendar_recurrence_exception_has_next() + * @see calendar_connect() + * @see calendar_event_get_event_array_from_vcalendar() */ -int calendar_recurrence_exception_next(calendar_recurrence_exception_iterator_h *iterator, int* year, int* month, int* day); +int calendar_event_get_vcalendar_from_db(int *event_db_id_array, int length, char **vcalendar_stream); /** - * @brief Gets the start time of the event from the calendar event handle. + * @brief Gets information whether an event is recurrence or not. * - * @param [in] event The calendar event handle - * @param [out] start_time The start date of the event + * @param [in] event The calendar event handle + * @param [out] is_recurrence @c true if the event is recurrence event, otherwise @c false \n + * (default : @c false) * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CALENDAR_ERROR_NO_DATA Data not found * - * @see calendar_event_set_start_time() + * @see calendar_event_set_recurrence_frequency() */ -int calendar_event_get_start_time(calendar_event_h event, struct tm *start_time); +int calendar_event_get_is_recurrence(calendar_event_h event, bool *is_recurrence); +/** + * @brief Gets the recurrence frequency of the event from the calendar event handle. + * + * @param[in] event The calendar event handle + * @param[out] recurrence_frequency The recurrence frequency of the event + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_event_set_recurrence_frequency() + * @see calendar_event_set_recurrence_byday() + * @see calendar_event_get_recurrence_byday() + */ +int calendar_event_get_recurrence_frequency(calendar_event_h event, calendar_recurrence_frequency_e *recurrence_frequency); /** - * @brief Sets a start time of the event in the calendar event handle. + * @brief Sets a recurrence frequency of the event to the calendar event handle. * - * @param [in] event The calendar event handle - * @param [in] start_time The start date of the event + * @param [in] event The calendar event handle + * @param [in] recurrence_frequency The recurrence frequency of the event \n + * If you set it to #CALENDAR_RECURRENCE_WEEKLY, you have to set calendar_event_set_recurrence_byday(). * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * - * @see calendar_event_get_start_time() + * @see calendar_event_get_recurrence_frequency() + * @see calendar_event_set_recurrence_byday() + * @see calendar_event_get_recurrence_byday() */ -int calendar_event_set_start_time(calendar_event_h event, struct tm start_time); +int calendar_event_set_recurrence_frequency(calendar_event_h event, calendar_recurrence_frequency_e recurrence_frequency); +/** + * @brief Gets the recurrence interval of the event from the calendar event handle. + * + * @param[in] event The calendar event handle + * @param[out] recurrence_interval The recurrence interval of the event + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_event_set_recurrence_interval() + * @see calendar_event_get_recurrence_frequency() + */ +int calendar_event_get_recurrence_interval(calendar_event_h event, int *recurrence_interval); /** - * @brief Gets the end time of the event from the calendar event handle. + * @brief Sets a recurrence interval of the event in the calendar event handle. * - * @param [in] event The calendar event handle - * @param [out] end_time The end date of the event + * @param [in] event The calendar event handle + * @param [in] recurrence_interval The recurrence interval of the event * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CALENDAR_ERROR_NO_DATA Data not found * - * @see calendar_event_set_end_time() + * @see calendar_event_get_recurrence_interval() + * @see calendar_event_set_recurrence_frequency() */ -int calendar_event_get_end_time(calendar_event_h event, struct tm *end_time); - +int calendar_event_set_recurrence_interval(calendar_event_h event, int recurrence_interval); /** - * @brief Sets the end time of the event in the calendar event handle. + * @brief Gets the recurrence count of the event from the calendar event handle. * - * @param[in] event The calendar event handle - * @param[in] end_time The end date of the event + * @param[in] event The calendar event handle + * @param[out] recurrence_count The recurrence type of the event * - * @return 0 on success, otherwise a negative error value. + * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * - * @see calendar_event_get_end_time() + * @see calendar_event_set_recurrence_count() + * @see calendar_event_get_recurrence_frequency() */ -int calendar_event_set_end_time(calendar_event_h event, struct tm end_time); +int calendar_event_get_recurrence_count(calendar_event_h event, int *recurrence_count); /** - * @brief Gets the total number of events from the calendar database. - * @pre This function requires an open connection to the calendar service by calendar_connect(). + * @brief Sets a recurrence count of the event to the calendar event handle. * - * @param[out] count The total number of events + * @param [in] event The calendar event handle + * @param [in] recurrence_count The recurrence count of the event * - * @return 0 on success, otherwise a negative error value. - * @retval #CALENDAR_ERROR_NONE Successful - * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CALENDAR_ERROR_DB_FAILED No access to database + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * - * @see calendar_connect() + * @see calendar_event_get_recurrence_count() + * @see calendar_event_set_recurrence_frequency() */ -int calendar_event_get_total_count_from_db(int *count); +int calendar_event_set_recurrence_count(calendar_event_h event, int recurrence_count); /** - * @brief Creates a attendee handle and make adds it to the calendar event. + * @brief Gets the recurrence ending time of the event from the calendar event handle. + * @details If recurrence frequency of the event is activated, then @a recurrence_until_date indicates recurrence ending time. * - * @remarks The created handle is not added to calendar database until calendar_event_insert_to_db() is called + * @param [in] event The calendar event handle + * @param [out] recurrence_until_date The ending time of the recurrence event \n + * The @a recurrence_until_date is a unix timestamp since 00:00, Jan 1 1970 UTC. * - * @param[in] event The calendar event handle - * @param[out] attendee A new attendee handle - * - * @return 0 on success, otherwise a negative error value. - * @retval #CALENDAR_ERROR_NONE Successful - * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory - * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALENDAR_ERROR_NO_DATA Data not found * - * @see calendar_event_remove_attendee() - * @see calendar_attendee_set_name() - * @see calendar_attendee_set_email() - * @see calendar_attendee_set_phone_number() - * @see calendar_event_get_attendee_iterator() + * @see calendar_event_set_recurrence_until_date() */ -int calendar_event_add_attendee(calendar_event_h event, calendar_attendee_h* attendee); +int calendar_event_get_recurrence_until_date(calendar_event_h event, long long int *recurrence_until_date); /** - * @brief Creates a attendee handle with contact ID and adds it to the calendar event. - * - * @details Adds an existing contact as an attendee to an event. A new attendee record is created, and the name, email address and phone number are populated from the values in the contact record. - * @remarks The created handle is not added to calendar database until calendar_event_insert_to_db() is called + * @brief Sets a recurrence end time of the event in the calendar event handle. * + * @param [in] event The calendar event handle + * @param [in] recurrence_until_date The end time of the recurrence event \n + * The @a recurrence_until_date is a unix timestamp since 00:00, Jan 1 1970 UTC. * - * @param[in] event The calendar event handle - * @param[in] contact_db_id The contact DB ID which is related to attendee - * @param[out] attendee A new attendee handle from contact ID in the contacts database * - * @return 0 on success, otherwise a negative error value. - * @retval #CALENDAR_ERROR_NONE Successful - * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory - * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * - * @pre This function requires an open connection to Contacts Service by contacts_connect(). + * @pre @a event has a recurrence frequency property using calendar_event_set_recurrence_frequency(). * - * @see calendar_event_remove_attendee() - * @see calendar_attendee_set_name() - * @see calendar_attendee_set_email() - * @see calendar_attendee_set_phone_number() - * @see calendar_event_get_attendee_iterator() - * @see contact_get_db_id() - * @see contact_get_from_db() - * @see calendar_attendee_get_phone_number() + * @see calendar_event_get_recurrence_until_date() */ -int calendar_event_add_attendee_with_contact(calendar_event_h event, int contact_db_id, calendar_attendee_h* attendee); +int calendar_event_set_recurrence_until_date(calendar_event_h event, long long int recurrence_until_date); /** - * @brief Removes the attendee from the calendar event handle. - * + * @brief Gets the recurrence ending date for all day event + * @details If recurrence frequency of the event is activated, then @a recurrence_until_date indicates recurrence ending time. * - * @param[in] event The calendar event handle - * @param[in] attendee The attendee handle + * @param [in] event The calendar event handle + * @param [out] until_year Year of until date + * @param [out] until_month Month of until date + * @param [out] until_day Day of until date * - * @return 0 on success, otherwise a negative error value. - * @retval #CALENDAR_ERROR_NONE Successful - * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALENDAR_ERROR_NO_DATA Data not found * - * @see calendar_event_add_attendee() - * @see calendar_event_get_attendee_iterator() + * @see calendar_event_set_all_day_recurrence_until_date() */ -int calendar_event_remove_attendee(calendar_event_h event, calendar_attendee_h attendee); +int calendar_event_get_all_day_recurrence_until_date(calendar_event_h event, int *until_year, int *until_month, int *until_day); /** - * @brief Gets the attendee iterator handle from the event handle. + * @brief Sets a recurrence end date for all day event * - * @param[in] event The calendar event handle - * @param[out] iterator The attendee iterator handle + * @param [in] event The calendar event handle + * @param [in] until_year Year of until date + * @param [in] until_month Month of until date + * @param [in] until_day Day of until date * - * @return 0 on success, otherwise a negative error value. - * @retval #CALENDAR_ERROR_NONE Successful - * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * - * @see calendar_attendee_iterator_has_next() - * @see calendar_attendee_iterator_next() + * @pre @a event has a recurrence frequency property using calendar_event_set_recurrence_frequency(). * + * @see calendar_event_get_all_day_recurrence_until_date() */ -int calendar_event_get_attendee_iterator(calendar_event_h event, calendar_attendee_iterator_h *iterator); +int calendar_event_set_all_day_recurrence_until_date(calendar_event_h event, int until_year, int until_month, int until_day); /** - * @brief Gets the last modified time of the event handle. + * @brief Gets the recurrence frequency of the event from the calendar event handle. + * @details This rule is "BYDAY" rule in RFC 5545 iCalendar http://http://www.ietf.org/rfc/rfc2445.txt * - * @param[in] event The calendar event handle - * @param[out] modified_time The last modified time of event + * @remarks @a byday must be released with free() by you. * - * @return 0 on success, otherwise a negative error value. - * @retval #CALENDAR_ERROR_NONE Successful - * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CALENDAR_ERROR_NO_DATA Data not found + * @param[in] event The calendar event handle + * @param[out] byday The "BYDAY" of the reccurrence event \n combination of [[-]1~5]MO, TU, WE, TH, FR, SA, SU with "," * - * @see calendar_event_insert_to_db() - * @see calendar_event_update_to_db() + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_event_set_recurrence_byday() + * @see calendar_event_set_recurrence_frequency() + * @see calendar_event_get_recurrence_frequency() */ -int calendar_event_get_last_modified_time(calendar_event_h event, struct tm *modified_time); +int calendar_event_get_recurrence_byday(calendar_event_h event, char **byday); /** - * @brief Gets the visibility for the given calendar event handle. + * @brief Sets the days of week flag to the calendar event handle. + * @details This rule is "BYDAY" rule in RFC 5545 iCalendar http://http://www.ietf.org/rfc/rfc2445.txt * - * @param[in] event The calendar event handle - * @param[out] visibility The visibility of the event \n (default : #CALENDAR_VISIBILITY_PUBLIC) + * @param[in] event The calendar event handle + * @param[in] byday The "BYDAY" of the reccurrence event \n combination of [[-]1~5]MO, TU, WE, TH, FR, SA, SU with "," * - * @return 0 on success, otherwise a negative error value. + * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * - * @see calendar_event_set_visibility() + * @see calendar_event_get_recurrence_byday() + * @see calendar_event_set_recurrence_frequency() + * @see calendar_event_get_recurrence_frequency() */ -int calendar_event_get_visibility(calendar_event_h event, calendar_visibility_e *visibility); +int calendar_event_set_recurrence_byday(calendar_event_h event, const char* byday); /** - * @brief Sets a visibility for the given calendar event handle. + * @brief Gets the recurrence position flag of the event from the calendar event handle. + * @details This rule is "BYSETPOS" rule in RFC 5545 iCalendar http://http://www.ietf.org/rfc/rfc2445.txt * - * @param[in] event The calendar event handle - * @param[in] visibility The visibility of the event + * @remarks @a bysetpos must be released with free() by you. * - * @return 0 on success, otherwise a negative error value. + * @param[in] event The calendar event handle + * @param[out] bysetpos The "BYSETPOS" of the reccurrence event \n combination of 1 to 366 or -366 to -1 with "," + * + * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * - * @see calendar_event_get_visibility() + * @see calendar_event_set_recurrence_bysetpos() */ -int calendar_event_set_visibility(calendar_event_h event, calendar_visibility_e visibility); +int calendar_event_get_recurrence_bysetpos(calendar_event_h event, char **bysetpos); /** - * @brief Gets the timezone details for the given calendar event handle. + * @brief Sets a recurrence position flag of the event to the calendar event handle. + * @details This rule is "BYSETPOS" rule in RFC 5545 iCalendar http://http://www.ietf.org/rfc/rfc2445.txt * - * @remark @a timezone_name must be released with free() by you. + * @param[in] event The calendar event handle + * @param[in] bysetpos The "BYSETPOS" of the reccurrence event \n combination of 1 to 366 or -366 to -1 with "," * - * @param[in] event The calendar event handle - * @param[out] timezone_name The time zone name + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * - * @return 0 on success, otherwise a negative error value. - * @retval #CALENDAR_ERROR_NONE Successful - * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * @see calendar_event_get_recurrence_bysetpos() + */ +int calendar_event_set_recurrence_bysetpos(calendar_event_h event, const char* bysetpos); + +/** + * @brief Gets a recurrence BYMONTHDAY of the event to the calendar event handle. + * @details This rule is "BYMONTHDAY" rule in RFC 5545 iCalendar http://http://www.ietf.org/rfc/rfc2445.txt * - * @see calendar_foreach_timezone() - * @see calendar_event_set_timezone() + * @remarks @a bymonthday must be released with free() by you. + * + * @param[in] event The calendar event handle + * @param[out] bymonthday The BYMONTHDAY of the reccurrence event \n combination of 1 to 31 or -31 to -1 with "," + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter */ -int calendar_event_get_timezone(calendar_event_h event, char** timezone_name); +int calendar_event_get_recurrence_bymonthday(calendar_event_h event, char **bymonthday); /** - * @brief Sets a timezone for the given calendar event handle. + * @brief Sets a recurrence BYMONTHDAY of the event to the calendar event handle. + * @details This rule is "BYMONTHDAY" rule in RFC 5545 iCalendar http://http://www.ietf.org/rfc/rfc2445.txt * - * @param[in] event The calendar event handle - * @param[in] timezone_name The time zone name + * @param[in] event The calendar event handle + * @param[in] bymonthday The BYMONTHDAY of the reccurrence event \n combination of 1 to 31 or -31 to -1 with "," * - * @return 0 on success, otherwise a negative error value. - * @retval #CALENDAR_ERROR_NONE Successful - * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + */ +int calendar_event_set_recurrence_bymonthday(calendar_event_h event, const char* bymonthday); + +/** + * @brief Gets a recurrence BYMONTH of the event to the calendar event handle. + * @details This rule is "BYMONTH" rule in RFC 5545 iCalendar http://http://www.ietf.org/rfc/rfc2445.txt * - * @see calendar_foreach_timezone() - * @see calendar_event_get_timezone() + * @remarks @a bymonth must be released with free() by you. + * + * @param[in] event The calendar event handle + * @param[out] bymonth The BYMONTH of the reccurrence event \n combination of 1 to 12 with "," + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter */ -int calendar_event_set_timezone(calendar_event_h event, const char* timezone_name); +int calendar_event_get_recurrence_bymonth(calendar_event_h event, char** bymonth); /** - * @brief Gets an event from vCalendar and returns a new event handle. + * @brief Sets a recurrence BYMONTH of the event to the calendar event handle. + * @details This rule is "BYMONTH" rule in RFC 5545 iCalendar http://http://www.ietf.org/rfc/rfc2445.txt * - * @remarks The new event handle must be released with calendar_event_destroy() by you. + * @param[in] event The calendar event handle + * @param[in] bymonth The BYMONTH of the reccurrence event \n combination of 1 to 12 with "," * - * @param[in] vcalendar_stream The vCalendar stream to convert - * @param[out] event The event handle + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + */ +int calendar_event_set_recurrence_bymonth(calendar_event_h event, const char* bymonth); + +/** + * @brief Gets the first day of the week. * - * @return 0 on success, otherwise a negative error value. + * @param[in] event The calendar event handle + * @param[out] week_start The first day of the week for the recurrence + * + * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory * - * @see calendar_event_destroy() - * @see calendar_event_get_vcalendar_from_event() + * @see calendar_event_set_recurrence_week_start() */ -int calendar_event_get_from_vcalendar(const char *vcalendar_stream, calendar_event_h *event); +int calendar_event_get_recurrence_week_start(calendar_event_h event, calendar_week_flag_e *week_start); /** - * @brief Gets vCalendar from the event handle. - * - * @remarks @a vcalendar_stream must be released with free() by you. + * @brief Sets the first day of the week * - * @param[in] event The event handle - * @param[out] vcalendar_stream The vCalendar stream to convert + * @param[in] event The calendar event handle + * @param[in] week_start The first day of the week for the recurrence * - * @return 0 on success, otherwise a negative error value. + * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * - * @see calendar_event_get_from_vcalendar() + * @see calendar_event_get_recurrence_week_start() */ -int calendar_event_get_vcalendar_from_event(calendar_event_h event, char **vcalendar_stream); +int calendar_event_set_recurrence_week_start(calendar_event_h event, calendar_week_flag_e week_start); /** - * @brief Retrieves all calendar events from all of calendars by invoking the given callback function iteratively. + * @brief Removes the recurrence event instance from the calendar database. * - * @param[in] callback The callback function to invoke - * @param[in] user_data The user data to be passed to the callback function + * @param[in] event_db_id The event database ID to delete + * @param[in] start_time The recurrence instance start time to delete * - * @return 0 on success, otherwise a negative error value. - * @retval #CALENDAR_ERROR_NONE Successful - * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_DB_FAILED No access to database * - * @pre This function requires an open connection to the calendar service by calendar_connect(). - * - * @post This function invokes calendar_foreach_query_event_cb(). + * @pre This function requires an open connection to the calendar service by calendar_connect(). * - * @see calendar_foreach_query_event_cb() + * @see calendar_connect() + * @see calendar_event_get_recurrence_exdate() */ -int calendar_foreach_event_from_db(calendar_foreach_query_event_cb callback, void *user_data); +int calendar_event_delete_recurrence_instance_from_db(int event_db_id, long long int start_time); /** - * @brief Retrieves all calendar events with the given calendar database ID. + * @brief Removes the recurrence all day event instance from the calendar database. * - * @param[in] callback The callback function to invoke - * @param[in] calendar_db_id The calendar database ID to filter \n - * 1 means the default calendar on the device - * @param[in] user_data The user data to be passed to the callback function + * @param[in] event_db_id The event database ID to delete + * @param[in] year The year of recurrence all instance + * @param[in] month The month of recurrence all instance + * @param[in] day The day of recurrence all instance * - * @return 0 on success, otherwise a negative error value. - * @retval #CALENDAR_ERROR_NONE Successful - * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CALENDAR_ERROR_DB_FAILED No access to database + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_DB_FAILED No access to database * - * @pre This function requires an open connection to the calendar service by calendar_connect(). + * @pre This function requires an open connection to the calendar service by calendar_connect(). + * + * @see calendar_connect() + * @see calendar_event_get_recurrence_exdate() + */ +int calendar_event_delete_recurrence_all_day_instance_from_db(int event_db_id, int year, int month, int day); + +/** + * @brief Gets a recurrence EXDATE of the event to the calendar event handle. + * @details This rule is "EXDATE" rule in RFC 5545 iCalendar http://http://www.ietf.org/rfc/rfc2445.txt * - * @post This function invokes calendar_foreach_query_event_cb(). + * @remarks @a exdate must be released with free() by you. * - * @see calendar_foreach_query_event_cb() - * @see calendar_foreach_event_from_db() - * @see calendar_query_event_by_description() - * @see calendar_query_event_by_location() - * @see calendar_query_event_by_period() + * @param[in] event The calendar event handle + * @param[out] exdate The EXDATE of the reccurrence event + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_event_delete_recurrence_instance_from_db() + * @see calendar_event_delete_recurrence_all_day_instance_from_db() */ -int calendar_query_event_by_calendar(calendar_foreach_query_event_cb callback, int calendar_db_id, void *user_data); +int calendar_event_get_recurrence_exdate(calendar_event_h event, char** exdate); /** - * @brief Retrieves all calendar events with the given subject. + * @brief Frees event array * - * @param[in] callback The callback function to invoke - * @param[in] calendar_db_id The calendar database ID to filter \n - * 1 means the default calendar on the device - * @param[in] subject_to_find The description to filter - * @param[in] user_data The user data to be passed to the callback function + * @param[out] event_array The event array * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CALENDAR_ERROR_DB_FAILED No access to database * - * @pre This function requires an open connection to the calendar service by calendar_connect(). + * @see calendar_event_search_event_by_calendar_book() + */ +int calendar_event_free_event_array(calendar_event_h *event_array); + +/** + * @brief Frees modified event array * - * @post This function invokes calendar_foreach_query_event_cb(). + * @param[out] modified_event_array The modified event array * - * @see calendar_event_get_subject() - * @see calendar_event_set_subject() - * @see calendar_foreach_query_event_cb() - * @see calendar_query_event_by_calendar() - * @see calendar_query_event_by_description() - * @see calendar_query_event_by_location() - * @see calendar_query_event_by_period() + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_event_search_event_by_version() */ -int calendar_query_event_by_subject(calendar_foreach_query_event_cb callback, int calendar_db_id, const char *subject_to_find, void *user_data); +int calendar_event_free_modified_event_array(pcalendar_modified_event_s *modified_event_array); /** - * @brief Retrieves all calendar events with the given description. + * @brief Retrieves all events as array from calendar book * - * @param[in] callback The callback function to invoke - * @param[in] calendar_db_id The calendar database ID to filter \n - * 1 means the default calendar on the device - * @param[in] description_to_find The description to filter - * @param[in] user_data The user data to be passed to the callback function + * @remarks @a event_array must be released with calendar_event_free_event_array() by you. + * + * @param[in] calendar_book_db_id The calendar book database ID to filter \n + * #DEFAULT_EVENT_CALENDAR_BOOK_DB_ID means the default event calendar book on the device \n + * #CALENDAR_BOOK_FILTER_ALL means all calendar books on the device + * @param[out] event_array The event array + * @param[out] length The length of the event array * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CALENDAR_ERROR_DB_FAILED No access to database + * @retval #CALENDAR_ERROR_DB_FAILED Database operation failure * * @pre This function requires an open connection to the calendar service by calendar_connect(). * - * @post This function invokes calendar_foreach_query_event_cb(). - * - * @see calendar_event_get_description() - * @see calendar_event_set_description() - * @see calendar_foreach_query_event_cb() - * @see calendar_query_event_by_calendar() - * @see calendar_query_event_by_subject() - * @see calendar_query_event_by_location() - * @see calendar_query_event_by_period() - * @see calendar_foreach_query_event_cb() + * @see calendar_connect() + * @see calendar_event_free_event_array() */ -int calendar_query_event_by_description(calendar_foreach_query_event_cb callback, int calendar_db_id, const char *description_to_find, void *user_data); +int calendar_event_search_event_by_calendar_book(int calendar_book_db_id, calendar_event_h **event_array, int *length); /** - * @brief Retrieves all calendar events with the given location. + * @brief Retrieves extend event instances within specified time range. + * + * @remarks @a event_array must be released with calendar_event_free_event_array() by you. * - * @param[in] callback The callback function to invoke - * @param[in] calendar_db_id The calendar database ID to filter \n - * 1 means the default calendar on the device - * @param[in] location_to_find The location to filter - * @param[in] user_data The user data to be passed to the callback function + * @param[in] calendar_book_db_id The calendar book database ID to filter \n + * #DEFAULT_EVENT_CALENDAR_BOOK_DB_ID means the default event calendar book on the device \n + * #CALENDAR_BOOK_FILTER_ALL means all calendar books on the device + * @param[in] period_start_time The start of the time range\n + * The @a start_time is a unix timestamp since 00:00, Jan 1 1970 UTC. + * @param[in] period_end_time The end of the time range\n + * The @a end_time is a unix timestamp since 00:00, Jan 1 1970 UTC. + * @param[out] event_array The event array + * @param[out] length The length of the event array * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful @@ -992,27 +1390,29 @@ int calendar_query_event_by_description(calendar_foreach_query_event_cb callback * * @pre This function requires an open connection to the calendar service by calendar_connect(). * - * @post This function invokes calendar_foreach_query_event_cb(). - * - * @see calendar_event_get_location() - * @see calendar_event_set_location() - * @see calendar_foreach_query_event_cb() - * @see calendar_query_event_by_calendar() - * @see calendar_query_event_by_subject() - * @see calendar_query_event_by_description() - * @see calendar_query_event_by_period() + * @see calendar_connect() + * @see calendar_event_free_event_array() */ -int calendar_query_event_by_location(calendar_foreach_query_event_cb callback, int calendar_db_id, const char *location_to_find, void *user_data); +int calendar_event_search_extend_instance_by_period(int calendar_book_db_id, + long long int period_start_time, long long int period_end_time, + calendar_event_h **event_array, int *length); /** - * @brief Retrieves all calendar events between the given start_time and end_time. + * @brief Retrieves all day extend event instances within specified time range. * - * @param[in] callback The callback function to invoke - * @param[in] calendar_db_id The calendar database ID to filter \n - * 1 means the default calendar on the device - * @param[in] start_time The start date - * @param[in] end_time The end date - * @param[in] user_data The user data to be passed to the callback function + * @remarks @a event_array must be released with calendar_event_free_event_array() by you. + * + * @param[in] calendar_book_db_id The calendar book database ID to filter \n + * #DEFAULT_EVENT_CALENDAR_BOOK_DB_ID means the default event calendar book on the device \n + * #CALENDAR_BOOK_FILTER_ALL means all calendar books on the device + * @param[in] period_start_year The start year of the time range + * @param[in] period_start_month The start month of the time range + * @param[in] period_start_day The start day of the time range + * @param[in] period_end_year The end year of the time range + * @param[in] period_end_month The end month of the time range + * @param[in] period_end_day The end day of the time range + * @param[out] event_array The event array + * @param[out] length The length of the event array * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful @@ -1021,45 +1421,38 @@ int calendar_query_event_by_location(calendar_foreach_query_event_cb callback, i * * @pre This function requires an open connection to the calendar service by calendar_connect(). * - * @post This function invokes calendar_foreach_query_event_cb(). - * - * @see calendar_event_get_start_time() - * @see calendar_event_set_start_time() - * @see calendar_event_get_end_time() - * @see calendar_event_set_end_time() - * @see calendar_foreach_query_event_cb() - * @see calendar_query_event_by_calendar() - * @see calendar_query_event_by_subject() - * @see calendar_query_event_by_description() - * @see calendar_query_event_by_location() - * @see calendar_foreach_query_event_cb() - * + * @see calendar_connect() + * @see calendar_event_free_event_array() */ -int calendar_query_event_by_period(calendar_foreach_query_event_cb callback, int calendar_db_id, struct tm start_time, struct tm end_time, void *user_data); +int calendar_event_search_all_day_extend_instance_by_period(int calendar_book_db_id, + int period_start_year, int period_start_month, int period_start_day, + int period_end_year, int period_end_month, int period_end_day, + calendar_event_h **event_array, int *length); /** - * @brief Retrieves all calendar events that have been modified since the given time. - * @details This function will find all changed event since the given time + * @brief Retrieves all modified events information as array that have been modified since the given version. + * + * @remarks @a modified_event_array must be released with calendar_event_free_modified_event_array() by you. * - * @param[in] callback The callback function to invoke - * @param[in] calendar_db_id The calendar database ID to filter \n - * 1 means the default calendar on the device - * @param[in] time The time to find events which are changed since when - * @param[in] user_data The user data to be passed to the callback function + * @param[in] calendar_book_db_id The calendar book database ID to filter \n + * #DEFAULT_EVENT_CALENDAR_BOOK_DB_ID means the default event calendar book on the device \n + * #CALENDAR_BOOK_FILTER_ALL means all calendar books on the device + * @param[in] calendar_db_version The calendar database version + * @param[out] modified_event_array The modified event information array + * @param[out] length The length of the event array * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CALENDAR_ERROR_DB_FAILED No access to database + * @retval #CALENDAR_ERROR_DB_FAILED Database operation failure * * @pre This function requires an open connection to the calendar service by calendar_connect(). * - * @post This function invokes calendar_foreach_query_event_cb(). - * - * @see calendar_event_get_last_modified_time() - * @see calendar_foreach_query_event_cb() + * @see calendar_connect() + * @see calendar_event_free_modified_event_array() */ -int calendar_query_event_by_time_last_modified(calendar_foreach_query_event_cb callback, int calendar_db_id, struct tm time, void *user_data); +int calendar_event_search_event_by_version(int calendar_book_db_id, int calendar_db_version, pcalendar_modified_event_s **modified_event_array, int *length); /** * @} @@ -1090,9 +1483,9 @@ int calendar_query_event_by_time_last_modified(calendar_foreach_query_event_cb c int calendar_todo_create(calendar_todo_h *todo); /** - * @brief Destroys the calendar to-do handle + * @brief Destroys the calendar to-do handle * - * @param[in] todo The calendar to-do handle + * @param[in] todo The calendar to-do handle * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful @@ -1106,9 +1499,9 @@ int calendar_todo_destroy(calendar_todo_h todo); /** * @brief Adds the given to-do item to the calendar database. * - * @param[in] todo The calendar to-do handle - * @param[in] calendar_db_id The calendar database ID to which the event insert. \n - * 1 means the default calendar on the device + * @param[in] todo The calendar to-do handle + * @param[in] calendar_book_db_id The calendar book database ID to which the to-do insert. \n + * #DEFAULT_TODO_CALENDAR_BOOK_DB_ID means the default to-do calendar book on the device * @param[out] todo_db_id The to-do ID to be assigned to the to-do item * * @return 0 on success, otherwise a negative error value. @@ -1120,7 +1513,7 @@ int calendar_todo_destroy(calendar_todo_h todo); * @see calendar_todo_update_to_db() * */ -int calendar_todo_insert_to_db(calendar_todo_h todo, int calendar_db_id, int *todo_db_id); +int calendar_todo_insert_to_db(calendar_todo_h todo, int calendar_book_db_id, int *todo_db_id); /** * @brief Removes the to-do item from the calendar database. @@ -1142,7 +1535,7 @@ int calendar_todo_delete_from_db(int todo_id); * @brief Updates the to-do item on the calendar database. * @details calendar_todo_get_db_id() is called internally to update the to-do item in the calendar database. * - * @param[in] todo The calendar to-do handle + * @param[in] todo The calendar to-do handle * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful @@ -1160,13 +1553,13 @@ int calendar_todo_update_to_db(calendar_todo_h todo); /** * @brief Gets the to-do item handle associated with the given to-do DB ID. - * @details This function gets the new to-do handle with the given to-do database ID from the calendar database. - * A new calendar to-do handle will be created. + * @details This function gets the new to-do handle with the given to-do database ID from the calendar database. + * A new calendar to-do handle will be created. * - * @remarks The new to-do handle must be released with calendar_todo_destroy() by you. + * @remarks The new to-do handle must be released with calendar_todo_destroy() by you. * * @param[in] todo_id The to-do Database ID - * @param[out] todo The calendar to-do handle + * @param[out] todo The calendar to-do handle * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful @@ -1181,7 +1574,7 @@ int calendar_todo_update_to_db(calendar_todo_h todo); int calendar_todo_get_from_db(int todo_id, calendar_todo_h *todo); /** - * @brief Gets the database ID for the given calendar to-do handle. + * @brief Gets the database ID for the given calendar to-do handle. * * @param[in] todo The calendar to-do handle * @param[out] todo_db_id The database ID of the to-do item (default : 0) \n @@ -1197,11 +1590,11 @@ int calendar_todo_get_from_db(int todo_id, calendar_todo_h *todo); int calendar_todo_get_db_id(calendar_todo_h todo, int *todo_db_id); /** - * @brief Gets the calendar database ID associated with the given calendar to-do handle. + * @brief Gets The calendar book database ID associated with the given calendar to-do handle. * * @param[in] todo The calendar to-do handle - * @param[out] calendar_db_id The calendar database ID fetched from the calendar to-do handle (default : 0) \n - * 0 means the to-do is not in calendar database. + * @param[out] calendar_book_db_id The calendar book database ID fetched from the calendar to-do handle (default : 0) \n + * 0 means the to-do is not in calendar database. * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful @@ -1209,14 +1602,14 @@ int calendar_todo_get_db_id(calendar_todo_h todo, int *todo_db_id); * * @see calendar_todo_insert_to_db() */ -int calendar_todo_get_calendar_db_id(calendar_todo_h todo, int *calendar_db_id); +int calendar_todo_get_calendar_book_db_id(calendar_todo_h todo, int *calendar_book_db_id); /** * @brief Gets the subject of the to-do from the calendar to-do handle. * - * @remarks @a subject must be released with free() by you. + * @remarks @a subject must be released with free() by you. * - * @param [in] todo The calendar to-do handle + * @param [in] todo The calendar to-do handle * @param [out] subject The subject of the to-do \n If the subject does not exist, it is NULL * * @return 0 on success, otherwise a negative error value. @@ -1230,7 +1623,7 @@ int calendar_todo_get_subject(calendar_todo_h todo, char **subject); /** * @brief Sets a subject of the to-do handle. * - * @param [in] todo The calendar to-do handle + * @param [in] todo The calendar to-do handle * @param [in] subject The subject of the to-do * * @return 0 on success, otherwise a negative error value. @@ -1244,9 +1637,9 @@ int calendar_todo_set_subject(calendar_todo_h todo, const char *subject); /** * @brief Gets description of the to-do from the calendar to-do handle. * - * @remarks @a description must be released with free() by you. + * @remarks @a description must be released with free() by you. * - * @param [in] todo The calendar to-do handle + * @param [in] todo The calendar to-do handle * @param [out] description The description of the to-do \n If the description does not exist, it is NULL * * @return 0 on success, otherwise a negative error value. @@ -1260,7 +1653,7 @@ int calendar_todo_get_description(calendar_todo_h todo, char **description); /** * @brief Sets a description of the to-do in the calendar to-do handle. * - * @param [in] todo The calendar to-do handle + * @param [in] todo The calendar to-do handle * @param [in] description The description of the to-do * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful @@ -1272,7 +1665,7 @@ int calendar_todo_get_description(calendar_todo_h todo, char **description); int calendar_todo_set_description(calendar_todo_h todo, const char *description); /** - * @brief Gets the priority for the given calendar to-do handle. + * @brief Gets the priority for the given calendar to-do handle. * * @param[in] todo The calendar to-do handle * @param[out] priority The priority of the to-do @@ -1286,7 +1679,7 @@ int calendar_todo_set_description(calendar_todo_h todo, const char *description) int calendar_todo_get_priority(calendar_todo_h todo, calendar_todo_priority_e *priority); /** - * @brief Sets a priority for the given calendar to-do handle. + * @brief Sets a priority for the given calendar to-do handle. * * @param[in] todo The calendar to-do handle * @param[in] priority The priority of the to-do @@ -1300,7 +1693,7 @@ int calendar_todo_get_priority(calendar_todo_h todo, calendar_todo_priority_e *p int calendar_todo_set_priority(calendar_todo_h todo, calendar_todo_priority_e priority); /** - * @brief Gets the status for the given calendar to-do handle. + * @brief Gets the status for the given calendar to-do handle. * * @param[in] todo The calendar to-do handle * @param[out] status The status of the to-do @@ -1309,12 +1702,12 @@ int calendar_todo_set_priority(calendar_todo_h todo, calendar_todo_priority_e pr * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * - * @see calendar_todo_set_status() + * @see calendar_todo_set_status() */ int calendar_todo_get_status(calendar_todo_h todo, calendar_todo_status_e *status); /** - * @brief Sets a status for the given calendar to-do handle. + * @brief Sets a status for the given calendar to-do handle. * * @param[in] todo The calendar to-do handle * @param[in] status The status of the to-do @@ -1328,7 +1721,7 @@ int calendar_todo_get_status(calendar_todo_h todo, calendar_todo_status_e *statu int calendar_todo_set_status(calendar_todo_h todo, calendar_todo_status_e status); /** - * @brief Gets the visibility for the given calendar to-do handle. + * @brief Gets the visibility for the given calendar to-do handle. * * @param[in] todo The calendar to-do handle * @param[out] visibility The visibility of the to-do \n (default : #CALENDAR_VISIBILITY_PUBLIC) @@ -1342,7 +1735,7 @@ int calendar_todo_set_status(calendar_todo_h todo, calendar_todo_status_e status int calendar_todo_get_visibility(calendar_todo_h todo, calendar_visibility_e *visibility); /** - * @brief Sets a visibility for the given calendar to-do handle. + * @brief Sets a visibility for the given calendar to-do handle. * * @param[in] todo The calendar to-do handle * @param[in] visibility The visibility of the to-do @@ -1358,9 +1751,9 @@ int calendar_todo_set_visibility(calendar_todo_h todo, calendar_visibility_e vis /** * @brief Gets the location of the to-do from the calendar to-do handle. * - * @remarks @a location must be released with free() by you. + * @remarks @a location must be released with free() by you. * - * @param [in] todo The calendar to-do handle + * @param [in] todo The calendar to-do handle * @param [out] location The location of the to-do \n If the location does not exist, it is NULL * * @return 0 on success, otherwise a negative error value. @@ -1375,7 +1768,7 @@ int calendar_todo_get_location(calendar_todo_h todo, char **location); /** * @brief Sets a location of the to-do in the calendar to-do handle. * - * @param [in] todo The calendar to-do handle + * @param [in] todo The calendar to-do handle * @param [in] location The location of the to-do * * @return 0 on success, otherwise a negative error value. @@ -1389,8 +1782,9 @@ int calendar_todo_set_location(calendar_todo_h todo, const char *location); /** * @brief Gets the last modified time of the to-do item. * - * @param[in] todo The calendar to-do handle - * @param[out] modified_time The last modified time + * @param[in] todo The calendar to-do handle + * @param[out] modified_time The last modified time\n + * The @a modified_time is a unix timestamp since 00:00, Jan 1 1970 UTC. * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful @@ -1401,9 +1795,9 @@ int calendar_todo_set_location(calendar_todo_h todo, const char *location); * @see calendar_todo_update_to_db() * */ -int calendar_todo_get_last_modified_time(calendar_todo_h todo, struct tm *modified_time); +int calendar_todo_get_last_modified_time(calendar_todo_h todo, long long int *modified_time); /** - * @brief Gets the timezone details for the given calendar to-do handle. + * @brief Gets the timezone details for the given calendar to-do handle. * @remarks @a timezone_name must be released with free() by you. * * @param[in] todo The calendar to-do handle @@ -1416,10 +1810,10 @@ int calendar_todo_get_last_modified_time(calendar_todo_h todo, struct tm *modifi * @see calendar_todo_set_timezone() * @see calendar_foreach_timezone() */ -int calendar_todo_get_timezone(calendar_todo_h todo, char** timezone_name); +int calendar_todo_get_timezone(calendar_todo_h todo, char** timezone_name); /** - * @brief Sets the timezone for the given calendar to-do handle. + * @brief Sets the timezone for the given calendar to-do handle. * * @param[in] todo The calendar to-do handle * @param[in] timezone_name The timezone name eg. Europe/Paris @@ -1431,13 +1825,14 @@ int calendar_todo_get_timezone(calendar_todo_h todo, char** timezone_name); * @see calendar_todo_get_timezone() * @see calendar_foreach_timezone() */ -int calendar_todo_set_timezone(calendar_todo_h todo, const char* timezone_name); +int calendar_todo_set_timezone(calendar_todo_h todo, const char* timezone_name); /** * @brief Gets the start time of the to-do from the calendar to-do handle. * - * @param [in] todo The calendar to-do handle - * @param [out] start_time The start date of the to-do + * @param [in] todo The calendar to-do handle + * @param [out] start_time The start date of the to-do\n + * The @a start_time is a unix timestamp since 00:00, Jan 1 1970 UTC. * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful @@ -1446,29 +1841,42 @@ int calendar_todo_set_timezone(calendar_todo_h todo, const char* timezone_name); * * @see calendar_todo_set_start_time() */ -int calendar_todo_get_start_time(calendar_todo_h todo, struct tm *start_time); +int calendar_todo_get_start_time(calendar_todo_h todo, long long int *start_time); /** - * @brief Sets a start time of the to-do in the calendar to-do handle. + * @brief Sets a start time of the to-do in the calendar to-do handle. * - * @param [in] todo The calendar todo handle - * @param [in] start_time The start date of the todo + * @param [in] todo The calendar todo handle + * @param [in] start_time The start date of the todo\n + * The @a start_time is a unix timestamp since 00:00, Jan 1 1970 UTC. * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * * @see calendar_todo_get_start_time() - * */ -int calendar_todo_set_start_time(calendar_todo_h todo, struct tm start_time); +int calendar_todo_set_start_time(calendar_todo_h todo, long long int start_time); +/** + * @brief Unsets a start time of the to-do in the calendar to-do handle. + * + * @param [in] todo The calendar todo handle + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_todo_set_start_time() + */ +int calendar_todo_unset_start_time(calendar_todo_h todo); /** * @brief Gets the due time of the to-do from the calendar to-do handle. * - * @param [in] todo The calendar to-do handle - * @param [out] due_time The due date of the to-do + * @param [in] todo The calendar to-do handle + * @param [out] due_time The due date of the to-do\n + * The @a due_time is a unix timestamp since 00:00, Jan 1 1970 UTC. * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful @@ -1476,15 +1884,15 @@ int calendar_todo_set_start_time(calendar_todo_h todo, struct tm start_time); * @retval #CALENDAR_ERROR_NO_DATA Data not found * * @see calendar_todo_set_due_time() - * */ -int calendar_todo_get_due_time(calendar_todo_h todo, struct tm *due_time); +int calendar_todo_get_due_time(calendar_todo_h todo, long long int *due_time); /** * @brief Sets a due time of the to-do in the calendar to-do handle. * - * @param[in] todo The calendar to-do handle - * @param[in] due_time The due date of the to-do + * @param[in] todo The calendar to-do handle + * @param[in] due_time The due date of the to-do\n + * The @a due_time is a unix timestamp since 00:00, Jan 1 1970 UTC. * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful @@ -1492,47 +1900,182 @@ int calendar_todo_get_due_time(calendar_todo_h todo, struct tm *due_time); * * @see calendar_todo_get_due_time() */ -int calendar_todo_set_due_time(calendar_todo_h todo, struct tm due_time); +int calendar_todo_set_due_time(calendar_todo_h todo, long long int due_time); /** - * @brief Retrieves all to-do items by invoking the given callback function iteratively. + * @brief Unsets a due time of the to-do in the calendar to-do handle. * - * @param[in] callback The callback function to invoke - * @param[in] user_data The user data to be passed to the callback function + * @param[in] todo The calendar to-do handle * - * @return 0 on success, otherwise a negative error value. + * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_todo_set_due_time() + */ +int calendar_todo_unset_due_time(calendar_todo_h todo); + +/** + * @brief Gets the total number of to-dos from the calendar book. + * + * @param[in] calendar_book_db_id The calendar book database ID to filter \n + * #DEFAULT_TODO_CALENDAR_BOOK_DB_ID means the default to-do calendar book on the device \n + * #CALENDAR_BOOK_FILTER_ALL means all calendar books on the device + * @param[in] todo_priority The to-do priority(#calendar_todo_priority_e) to filter \n + * Supports "OR"ing of #calendar_todo_priority_e + * @param[in] todo_status The to-do status(#calendar_todo_status_e) to filter \n + * Supports "OR"ing of #calendar_todo_status_e + * @param[out] count The total number of to-dos + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALENDAR_ERROR_DB_FAILED No access to database + * + * @pre This function requires an open connection to the calendar service by calendar_connect(). + * + * @see calendar_connect() + */ +int calendar_todo_get_total_count_from_db(int calendar_book_db_id, int todo_priority, int todo_status, int *count); + +/** + * @brief Gets the total number of to-dos within specified time range from the calendar book. + * + * @param[in] calendar_book_db_id The calendar book database ID to filter \n + * #DEFAULT_TODO_CALENDAR_BOOK_DB_ID means the default to-do calendar book on the device \n + * #CALENDAR_BOOK_FILTER_ALL means all calendar books on the device + * @param[in] start_duedate_range The start of the time range\n + * The @a start_duedate_range is a unix timestamp since 00:00, Jan 1 1970 UTC. + * @param[in] end_duedate_range The end of the time range\n + * The @a end_duedate_range is a unix timestamp since 00:00, Jan 1 1970 UTC. + * @param[in] todo_priority The to-do priority(#calendar_todo_priority_e) to filter \n + * Supports "OR"ing of #calendar_todo_priority_e + * @param[in] todo_status The to-do status(#calendar_todo_status_e) to filter \n + * Supports "OR"ing of #calendar_todo_status_e + * @param[out] count The total number of to-dos + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CALENDAR_ERROR_DB_FAILED No access to database * * @pre This function requires an open connection to the calendar service by calendar_connect(). * - * @post This function invokes calendar_foreach_query_todo_cb(). + * @see calendar_connect() + */ +int calendar_todo_get_total_count_by_duedate_range(int calendar_book_db_id, long long int start_duedate_range, long long int end_duedate_range, int todo_priority, int todo_status, int *count); + +/** + * @brief Frees to-do array + * + * @param[out] todo_array The to-do array * - * @see calendar_foreach_query_todo_cb() + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_todo_search_todo_by_calendar_book() */ -int calendar_foreach_todo_from_db(calendar_foreach_query_todo_cb callback, void *user_data); +int calendar_todo_free_todo_array(calendar_todo_h *todo_array); /** - * @brief Retrieves all to-do items with the given calendar database ID by invoking the given callback function iteratively. + * @brief Frees modified to-do array * - * @param[in] callback The callback function to invoke - * @param[in] calendar_db_id The calendar database ID to filter \n - * 1 means the default calendar on the device - * @param[in] user_data The user data to be passed to the callback function + * @param[out] modified_todo_array The modified to-do array + * @param[out] length The length of the array * - * @return 0 on success, otherwise a negative error value. + * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CALENDAR_ERROR_DB_FAILED No access to database + * + * @see calendar_todo_search_todo_by_version() + */ +int calendar_todo_free_modified_todo_array(pcalendar_modified_todo_s *modified_todo_array); + +/** + * @brief Retrieves all to-dos as array from calendar book + * + * @remarks @a todo_array must be released with calendar_todo_free_todo_array() by you. + * + * @param[in] calendar_book_db_id The calendar book database ID to filter \n + * #DEFAULT_TODO_CALENDAR_BOOK_DB_ID means the default to-do calendar book on the device \n + * #CALENDAR_BOOK_FILTER_ALL means all calendar books on the device + * @param[in] todo_priority The to-do priority(#calendar_todo_priority_e) to filter \n + * Supports "OR"ing of #calendar_todo_priority_e + * @param[in] todo_status The to-do status(#calendar_todo_status_e) to filter \n + * Supports "OR"ing of #calendar_todo_status_e + * @param[out] todo_array The to-do array + * @param[out] length The length of the to-do array + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALENDAR_ERROR_DB_FAILED Database operation failure * * @pre This function requires an open connection to the calendar service by calendar_connect(). * - * @post This function invokes calendar_foreach_query_todo_cb(). + * @see calendar_connect() + * @see calendar_todo_free_todo_array() + */ +int calendar_todo_search_todo_by_calendar_book(int calendar_book_db_id, int todo_priority, int todo_status, calendar_todo_h **todo_array, int *length); + +/** + * @brief Retrieves all calendar to-dos as array within specified time range. + * + * @remarks @a todo_array must be released with calendar_todo_free_todo_array() by you. + * + * @param[in] calendar_book_db_id The calendar book database ID to filter \n + * #DEFAULT_TODO_CALENDAR_BOOK_DB_ID means the default to-do calendar book on the device \n + * #CALENDAR_BOOK_FILTER_ALL means all calendar books on the device + * @param[in] start_duedate_range The start of the time range\n + * The @a start_duedate_range is a unix timestamp since 00:00, Jan 1 1970 UTC. + * @param[in] end_duedate_range The end of the time range\n + * The @a end_duedate_range is a unix timestamp since 00:00, Jan 1 1970 UTC. + * @param[in] todo_priority The to-do priority(#calendar_todo_priority_e) to filter \n + * Supports "OR"ing of #calendar_todo_priority_e + * @param[in] todo_status The to-do status(#calendar_todo_status_e) to filter \n + * Supports "OR"ing of #calendar_todo_status_e + * @param[out] todo_array The to-do array + * @param[out] length The length of the todo array + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALENDAR_ERROR_DB_FAILED Database operation failure + * + * @pre This function requires an open connection to the calendar service by calendar_connect(). * - * @see calendar_foreach_query_todo_cb() + * @see calendar_connect() + * @see calendar_todo_free_todo_array() */ -int calendar_query_todo_by_calendar(calendar_foreach_query_todo_cb callback, int calendar_db_id, void *user_data); +int calendar_todo_search_todo_by_duedate_range(int calendar_book_db_id, long long int start_duedate_range, long long int end_duedate_range, int todo_priority, int todo_status, calendar_todo_h **todo_array, int *length); + +/** + * @brief Retrieves all modified to-dos information as array that have been modified since the given version. + * + * @remarks @a modified_todo_array must be released with calendar_todo_free_modified_todo_array() by you. + * + * @param[in] calendar_book_db_id The calendar book database ID to filter \n + * #DEFAULT_TODO_CALENDAR_BOOK_DB_ID means the default to-do calendar book on the device \n + * #CALENDAR_BOOK_FILTER_ALL means all calendar books on the device + * @param[in] calendar_db_version The calendar database version + * @param[out] modified_todo_array The modified to-do information array + * @param[out] length The length of the to-do array + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALENDAR_ERROR_DB_FAILED Database operation failure + * + * @pre This function requires an open connection to the calendar service by calendar_connect(). + * + * @see calendar_connect() + * @see calendar_todo_free_modified_todo_array() + */ +int calendar_todo_search_todo_by_version(int calendar_book_db_id, int calendar_db_version, pcalendar_modified_todo_s **modified_todo_array, int *length); /** * @} @@ -1544,14 +2087,44 @@ int calendar_query_todo_by_calendar(calendar_foreach_query_todo_cb callback, int */ /** - * @brief Gets the calendar from the calendar database. - * @details This function gets the new calendar handle with the given calendar database ID from the calendar database. \n - * The new calendar handle will be created. + * @brief Creates a handle to the calendar book. + * @remarks The calendar book handle must be released with calendar_book_destroy() by you. + * @remarks The created handle is not added to calendar database until calendar_insert_to_db() is called + * + * @param[out] calendar_book A new handle to calendar book + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory + * + * @see calendar_book_destroy() + * + */ +int calendar_book_create(calendar_book_h *calendar_book); + +/** + * @brief Destroys the calendar book handle and releases all its resources. * - * @remarks The created calendar handle must be released with calendar_destroy() by you. + * @param[out] calendar_book The calendar book handle * - * @param[in] calendar_db_id The calendar database ID - * @param[out] calendar The calendar handle associated with the calendar database ID + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_book_get_from_db() + */ +int calendar_book_destroy(calendar_book_h calendar_book); + +/** + * @brief Gets the calendar book from the calendar database. + * @details This function gets the new calendar book handle with the given calendar book database ID from the calendar database. \n + * The new calendar book handle will be created. + * + * @remarks The created calendar book handle must be released with calendar_book_destroy() by you. + * + * @param[in] calendar_book_db_id The calendar book database ID + * @param[out] calendar_book The calendar book handle associated with The calendar book database ID * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful @@ -1560,110 +2133,289 @@ int calendar_query_todo_by_calendar(calendar_foreach_query_todo_cb callback, int * * @pre This function requires an open connection to the calendar service by calendar_connect(). * - * @see calendar_destroy() + * @see calendar_book_destroy() + */ +int calendar_book_get_from_db(int calendar_book_db_id, calendar_book_h *calendar_book); + +/** + * @brief Adds a calendar book to the calendar database. + * + * @param[in] calendar_book The calendar book handle + * @param[out] calendar_book_db_id The calendar book database ID associated with the calendar book \n + * If the function fails, it is -1. + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_DB_FAILED No access to database + * + * @pre This function requires an open connection to the calendar service by calendar_connect(). + * + * @see calendar_connect() + * @see calendar_book_delete_from_db() + */ +int calendar_book_insert_to_db(calendar_book_h calendar_book, int *calendar_book_db_id); + +/** + * @brief Updates a calendar book to the calendar database. + * + * @param[in] calendar_book The calendar book handle + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_DB_FAILED No access to database + * + * @pre This function requires an open connection to the calendar service by calendar_connect(). + * + * @see calendar_book_connect() */ -int calendar_get_from_db(int calendar_db_id, calendar_h *calendar); +int calendar_book_update_to_db(calendar_book_h calendar_book); /** - * @brief Destroys the calendar handle and releases all its resources. + * @brief Removes the calendar book from the calendar database. * - * @param[out] calendar The calendar handle + * @param[in] calendar_book_db_id The calendar book database ID to delete + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_DB_FAILED No access to database + * + * @pre This function requires an open connection to the calendar service by calendar_connect(). + * + * @see calendar_connect() + */ +int calendar_book_delete_from_db(int calendar_book_db_id); + +/** + * @brief Removes the calendar books, events and to-dos from the calendar database. + * + * @param[in] account_db_id The account database ID to filter + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_DB_FAILED No access to database + * + * @pre This function requires an open connection to the calendar service by calendar_connect(). + * + * @see calendar_connect() + */ +int calendar_book_delete_all_by_account(int account_db_id); + +/** + * @brief Gets the calendar book database ID associated with the given calendar book handle. + * + * @param[in] calendar_book The calendar book handle + * @param[out] calendar_book_db_id The calendar book database ID fetched from the calendar book handle * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * - * @see calendar_get_from_db() + * @see calendar_book_get_from_db() + */ +int calendar_book_get_db_id(calendar_book_h calendar_book, int *calendar_book_db_id); + +/** + * @brief Sets the calendar book type associated with the given calendar book handle. + * + * @param[in] calendar_book The calendar book handle + * @param[in] calendar_book_type The calendar book type. \n Supports "OR"ing of #calendar_book_type_e + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * + * @see calendar_book_get_type() */ -int calendar_destroy(calendar_h calendar); +int calendar_book_set_type(calendar_book_h calendar_book, int calendar_book_type); /** - * @brief Gets the database ID associated with the given calendar handle. + * @brief Gets the calendar book type associated with the given calendar book handle. * - * @param[in] calendar The calendar handle - * @param[out] calendar_db_id The calendar database ID fetched from the calendar handle + * @param[in] calendar_book The calendar book handle + * @param[out] calendar_book_type The calendar book type. \n Supports "OR"ing of #calendar_book_type_e * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter * - * @see calendar_get_from_db() + * @see calendar_book_set_type() */ -int calendar_get_db_id(calendar_h calendar, int *calendar_db_id); +int calendar_book_get_type(calendar_book_h calendar_book, int *calendar_book_type); /** - * @brief Gets the status whether the calendar is default calendar is or not in the device. + * @brief Gets the status whether the calendar book is default calendar book is or not in the device. * - * @param [in] calendar The calendar handle - * @param [out] is_default @c true if the calendar is the default calendar in the device @c false \n + * @param [in] calendar_book The calendar book handle + * @param [out] is_default @c true if the calendar is the default calendar book in the device @c false \n * (default : @c false) * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter */ -int calendar_get_is_default(calendar_h calendar, bool *is_default); +int calendar_book_get_is_default(calendar_book_h calendar_book, bool *is_default); /** - * @brief Gets the name of the calendar from the calendar handle. + * @brief Sets the name of the calendar from the calendar book handle. * - * @remarks @a calendar_name must be released with free() by you. + * @remarks @a calendar_name must be released with free() by you. * - * @param [in] calendar The calendar handle - * @param [out] calendar_name The name of the calendar \n If the name does not exist, it is NULL + * @param [in] calendar_book The calendar book handle + * @param [in] calendar_book_name The name of the calendar book * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_book_get_name() + */ +int calendar_book_set_name(calendar_book_h calendar_book, const char *calendar_book_name); + +/** + * @brief Gets the name of the calendar book from the calendar book handle. + * + * @remarks @a calendar_book_name must be released with free() by you. + * + * @param [in] calendar_book The calendar book handle + * @param [out] calendar_book_name The name of the calendar book \n If the name does not exist, it is NULL + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_book_set_name() + */ +int calendar_book_get_name(calendar_book_h calendar_book, char **calendar_book_name); + +/** + * @brief Sets the visible status of the calendar book handle. + * + * @param [in] calendar_book The calendar book handle + * @param [in] is_visible @c true if the calendar book is visible in the device, otherwise @c false \n + * (default : @c false) + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_book_get_is_visibile() */ -int calendar_get_name(calendar_h calendar, char **calendar_name); +int calendar_book_set_is_visible(calendar_book_h calendar_book, bool is_visible); /** - * @brief Gets the visible status of the calendar handle. + * @brief Gets the visible status of the calendar book handle. * - * @param [in] calendar The calendar handle - * @param [out] is_visible @c true if the calendar is visible in the device, otherwise @c false \n + * @param [in] calendar_book The calendar book handle + * @param [out] is_visible @c true if the calendar book is visible in the device, otherwise @c false \n * (default : @c false) * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_book_set_is_visibile() + */ +int calendar_book_get_is_visible(calendar_book_h calendar_book, bool *is_visible); + +/** + * @brief Sets the color of the calendar book from the calendar book handle. + * + * @param [in] calendar_book The calendar book handle + * @param [in] red The calendar book color which represents red among RGB + * @param [in] green The calendar book color which represents green among RGB + * @param [in] blue The calendar book color which represents blue among RGB + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_book_get_color() + * @see calendar_book_unset_color() + */ +int calendar_book_set_color(calendar_book_h calendar_book, unsigned char red, unsigned char green, unsigned char blue); + +/** + * @brief Unsets the color of the calendar book from the calendar book handle. + * + * @param [in] calendar_book The calendar book handle + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_book_set_color() */ -int calendar_get_is_visibile(calendar_h calendar, bool *is_visible); +int calendar_book_unset_color(calendar_book_h calendar_book); /** - * @brief Gets the color of the calendar from the calendar handle. + * @brief Gets the color of the calendar book from the calendar book handle. + * + * @remarks returns @a CALENDAR_ERROR_NO_DATA means calendar book color is not valid * - * @param [in] calendar The calendar handle - * @param [out] red The calendar color which represents red among RGB - * @param [out] green The calendar color which represents green among RGB - * @param [out] blue The calendar color which represents blue among RGB + * @param [in] calendar_book The calendar book handle + * @param [out] red The calendar book color which represents red among RGB + * @param [out] green The calendar book color which represents green among RGB + * @param [out] blue The calendar book color which represents blue among RGB * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALENDAR_ERROR_NO_DATA Data not found + * + * @see calendar_book_set_color() + */ +int calendar_book_get_color(calendar_book_h calendar_book, unsigned char *red, unsigned char *green, unsigned char *blue); + +/** + * @brief Sets the account database ID associated with the given calendar book handle. + * + * @param[in] calendar_book The calendar book handle + * @param[in] account_db_id The account database ID(default : 0) \n + * 0 means the calendar book is not related to any accounts. + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_book_get_account_db_id() */ -int calendar_get_color(calendar_h calendar, unsigned char *red, unsigned char *green, unsigned char *blue); +int calendar_book_set_account_db_id(calendar_book_h calendar_book, int account_db_id); /** - * @brief Gets the account database ID associated with the given calendar handle. + * @brief Gets the account database ID associated with the given calendar book handle. * - * @param[in] calendar The calendar handle + * @param[in] calendar_book The calendar book handle * @param[out] account_db_id The account database ID(default : 0) \n - * 0 means the calendar is not related to any accounts. + * 0 means the calendar book is not related to any accounts. * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_book_set_account_db_id() */ -int calendar_get_account_db_id(calendar_h calendar, int *account_db_id); +int calendar_book_get_account_db_id(calendar_book_h calendar_book, int *account_db_id); /** - * @brief Retrieves all calendars by invoking the given callback function iteratively. + * @brief Frees calendar book array * - * @param[in] callback The callback function to invoke - * @param[in] user_data The user data to be passed to the callback function + * @param[out] calendar_book_array The calendar book array + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_book_get_all_calendar_book() + */ +int calendar_book_free_calendar_book_array(calendar_book_h *calendar_book_array); + +/** + * @brief Retrieves all calendar books as array from database. + * + * @remarks @a calendar_book_array must be released with calendar_book_free_calendar_book_array() by you. + * + * @param[out] calendar_book_array The calendar book array + * @param[out] length The length of the calendar book array * * @return 0 on success, otherwise a negative error value. * @retval #CALENDAR_ERROR_NONE Successful @@ -1672,11 +2424,31 @@ int calendar_get_account_db_id(calendar_h calendar, int *account_db_id); * * @pre This function requires an open connection to the calendar service by calendar_connect(). * - * @post This function invokes calendar_foreach_query_event_cb(). + * @see calendar_connect() + * @see calendar_book_free_calendar_book_array() + */ +int calendar_book_get_all_calendar_book(calendar_book_h **calendar_book_array, int *length); + +/** + * @brief Retrieves calendar books as array with account database ID from database. + * + * @remarks @a calendar_book_array must be released with calendar_book_free_calendar_book_array() by you. * - * @see calendar_foreach_query_calendar_cb() + * @param[in] account_db_id The account database ID to filter + * @param[out] calendar_book_array The calendar book array + * @param[out] length The length of the calendar book array + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CALENDAR_ERROR_DB_FAILED No access to database + * + * @pre This function requires an open connection to the calendar service by calendar_connect(). + * + * @see calendar_connect() + * @see calendar_book_free_calendar_book_array() */ -int calendar_foreach_calendar_from_db(calendar_foreach_query_calendar_cb callback, void *user_data); +int calendar_book_search_calendar_book_by_account(int account_db_id, calendar_book_h **calendar_book_array, int *length); /** * @} diff --git a/include/calendar_attendee.h b/include/calendar_attendee.h index 8e4cf90..49821f4 100755 --- a/include/calendar_attendee.h +++ b/include/calendar_attendee.h @@ -14,13 +14,14 @@ * limitations under the License. */ - + #ifndef __TIZEN_SOCIAL_CALENDAR_CALENDAR_ATTENDEE_H__ #define __TIZEN_SOCIAL_CALENDAR_CALENDAR_ATTENDEE_H__ #include <tizen.h> #include <time.h> -#include <calendar_types.h> + +#include "calendar_types.h" @@ -161,6 +162,62 @@ int calendar_attendee_get_contact_db_id(calendar_attendee_h attendee, int *conta int calendar_attendee_set_contact_db_id(calendar_attendee_h attendee, int contact_db_id); /** + * @brief Gets the status for the given calendar attendee handle. + * + * @param[in] attendee The calendar attendee handle + * @param[out] status The status of the attendee \n (default : #CALENDAR_ATTENDEE_STATUS_PENDING) + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_attendee_set_status() + */ +int calendar_attendee_get_status(calendar_attendee_h attendee, calendar_attendee_status_e *status); + +/** + * @brief Sets a status for the given calendar attendee handle. + * + * @param[in] attendee The calendar attendee handle + * @param[in] status The status of the attendee + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_attendee_get_status() + */ +int calendar_attendee_set_status(calendar_attendee_h attendee, calendar_attendee_status_e status); + +/** + * @brief Gets the role for the given calendar attendee handle. + * + * @param[in] attendee The calendar attendee handle + * @param[out] role The role of the attendee \n (default : #CALENDAR_ATTENDEE_ROLE_REQ_PARTICIPANT) + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_attendee_set_role() + */ +int calendar_attendee_get_role(calendar_attendee_h attendee, calendar_attendee_role_e *role); + +/** + * @brief Sets a role for the given calendar attendee handle. + * + * @param[in] attendee The calendar attendee handle + * @param[in] role The role of the attendee + * + * @return 0 on success, otherwise a negative error value. + * @retval #CALENDAR_ERROR_NONE Successful + * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see calendar_attendee_get_role() + */ +int calendar_attendee_set_role(calendar_attendee_h attendee, calendar_attendee_role_e role); + +/** * @brief Checks whether there is a next attendee handle on the list. * * @param [in] iterator The attendee iterator handle diff --git a/include/calendar_private.h b/include/calendar_private.h index 18d1bcc..2796572 100755..100644 --- a/include/calendar_private.h +++ b/include/calendar_private.h @@ -11,15 +11,18 @@ * 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. + * limitations under the License. */ - + #ifndef __TIZEN_SOCIAL_CALENDAR_PRIVATE_H__ #define __TIZEN_SOCIAL_CALENDAR_PRIVATE_H__ #include <glib.h> -#include <calendar_types.h> + +#include "calendar_types.h" +#include "calendar_private.h" +#include "calendar.h" #ifdef __cplusplus extern "C" { @@ -28,11 +31,11 @@ extern "C" { /** * @internal */ -typedef struct GList calendar_list_s; +typedef struct GList calendar_list_s; typedef struct { - int event_type; - void* user_data; + int event_type; + void* user_data; } calendar_event_legacy_s; typedef struct { @@ -42,7 +45,7 @@ typedef struct { typedef struct { int index; /**< Record index */ - int account_id; /**< Account_id */ + int account_id; /**< Account_id */ int cal_type; /**< Calendar event type */ int sch_category; /**< Category of schedule */ @@ -72,7 +75,7 @@ typedef struct int task_status; /**< current task status */ int priority; /**< Priority */ int timezone; /**< timezone of task */ - int file_id; /**< file id for attach or alarm tone*/ + int file_id; /**< file id for attach or alarm tone*/ int contact_id; /**< contact id for birthday in contact list */ GList* attendee_list; /**< collection of attendee */ int busy_status; /**< ACS, G : Flag of busy or not */ @@ -93,7 +96,6 @@ typedef struct char* edit_uri; /**< G : EditUri for google calendar */ char* gevent_id; /**< G : Server id of an event */ int dst; /**< dst of event */ - GList* exception_date_list; /**< exception dates */ int original_event_id; /**< original event id for recurrency exception */ double latitude; double longitude; @@ -120,11 +122,8 @@ typedef struct GList* _calendar_glist_next_until_not_deleted(GList* list); -int _calendar_event_foreach(calendar_foreach_query_event_cb callback, int account_db_id, int calendar_db_id, void* user_data); -int _calendar_todo_foreach(calendar_foreach_query_todo_cb callback, int account_db_id, int calendar_db_id, void* user_data); -int _calendar_event_query(calendar_foreach_query_event_cb callback, int calendar_db_id, char* option, const char* string_to_find, void* user_data); -int _calendar_get_account_db_id(int calendar_db_id); -void _calendar_parse_color(char* color_string, unsigned char* red, unsigned char* green, unsigned char* blue); +int _calendar_get_account_db_id(int calendar_db_id); +void _calendar_parse_color(char* color_string, unsigned char* red, unsigned char* green, unsigned char* blue); /** * Internal Macros @@ -140,14 +139,13 @@ void _calendar_parse_color(char* color_string, unsigned char* red, unsigned char } \ }while(0) -#define CONTACTS_INVALID_ARG_CHECK(_condition_) do { \ +#define CALENDAR_INVALID_ARG_CHECK(_condition_) do { \ if(_condition_) { \ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); \ return CALENDAR_ERROR_INVALID_PARAMETER; \ } \ }while(0) - #ifdef __cplusplus } #endif diff --git a/include/calendar_types.h b/include/calendar_types.h index 890a711..058d395 100755 --- a/include/calendar_types.h +++ b/include/calendar_types.h @@ -11,7 +11,7 @@ * 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. + * limitations under the License. */ @@ -46,6 +46,16 @@ typedef enum } calendar_error_e; /** + * @brief Enumerations for calendar book type. "OR"ing supported. + */ +typedef enum +{ + CALENDAR_BOOK_TYPE_NONE = 0, /**< Calendar book type default */ + CALENDAR_BOOK_TYPE_EVENT = 1<<0, /**< Event calendar book type */ + CALENDAR_BOOK_TYPE_TODO = 1<<1 /**< To-do Calendar book type */ +} calendar_book_type_e; + +/** * @brief Enumerations for calendar visibility type. */ typedef enum @@ -56,31 +66,6 @@ typedef enum } calendar_visibility_e; /** - * @brief Enumerations for calendar timezone details. - */ -typedef struct -{ - char* timezone_name; /**< Timezone name eg. Europe/Paris */ - char* city_name; /**< City name eg. Paris */ - char* country_name; /**< Country name eg. France */ - char* time_offset; /**< Time offset eg. GMT+1 */ - char* timezone_detail_filepath; /**< Timezone detail file path eg. /.../Europe/Paris */ -}calendar_foreach_timezone_s ; - -/** - * @brief Called once for each timezone supported on a device. - * - * @param[out] timezone The timezone 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 return @c false to break out of the loop. - * - * @pre calendar_foreach_timezone() will invoke this callback. - * - * @see calendar_foreach_timezone() - */ -typedef bool (*calendar_foreach_timezone_cb)(calendar_foreach_timezone_s *timezone, void *user_data); -/** * @} */ @@ -89,18 +74,45 @@ typedef bool (*calendar_foreach_timezone_cb)(calendar_foreach_timezone_s *timezo * @{ */ - /** +/** + * @brief Enumerations of attendee status. + */ +typedef enum +{ + CALENDAR_ATTENDEE_STATUS_PENDING = 0, /**< Pending status */ + CALENDAR_ATTENDEE_STATUS_ACCEPTED, /**< Accepted status */ + CALENDAR_ATTENDEE_STATUS_DECLINED, /**< Decliend status */ + CALENDAR_ATTENDEE_STATUS_TENTATIVE, /**< Tentative status */ + CALENDAR_ATTENDEE_STATUS_DELEGATED, /**< Delegated status */ + CALENDAR_ATTENDEE_STATUS_COMPLETED, /**< Completed status */ + CALENDAR_ATTENDEE_STATUS_IN_PROCESS, /**< In process status */ + CALENDAR_ATTENDEE_STATUS_MAX, +}calendar_attendee_status_e; + +/** + * @brief Enumerations of attendee role. + */ +typedef enum +{ + CALENDAR_ATTENDEE_ROLE_REQ_PARTICIPANT = 0, /**< Participation is required */ + CALENDAR_ATTENDEE_ROLE_OPT_PARTICIPANT, /**< Accepted status */ + CALENDAR_ATTENDEE_ROLE_NON_PARTICIPANT, /**< Non-Participant */ + CALENDAR_ATTENDEE_ROLE_CHAIR, /**< Chairperson */ + CALENDAR_ATTENDEE_ROLE_MAX, +}calendar_attendee_role_e; + +/** * @brief The calendar attendee handle. * @see calendar_event_add_attendee() * @see calendar_event_remove_attendee() */ -typedef struct calendar_attendee_s *calendar_attendee_h; /* cal_value */ +typedef struct calendar_attendee_s* calendar_attendee_h; /** * @brief The event attendee iterator. * @see calendar_event_get_attendee_iterator() */ -typedef struct calendar_list_s *calendar_attendee_iterator_h; +typedef struct calendar_list_s* calendar_attendee_iterator_h; /** * @} @@ -115,16 +127,10 @@ typedef struct calendar_list_s *calendar_attendee_iterator_h; /** * @brief The calendar event handle. */ -typedef struct calendar_event_s *calendar_event_h; +typedef struct calendar_event_s* calendar_event_h; /** - * @brief The calendar recurrence exception iterator handle. - * @see calendar_event_get_recurrence_exception_iterator() - */ -typedef struct calendar_list_s *calendar_recurrence_exception_iterator_h; - -/** - * @brief Reminder interval type of event such as minutes, hours, days, or etc. + * @brief Reminder interval type of event such as minutes, hours, days, or etc. */ typedef enum { @@ -136,7 +142,6 @@ typedef enum CALENDAR_REMINDER_TIME_UNIT_MONTH, /**< Reminder interval in months */ } calendar_reminder_interval_type_e; - /** * @brief Enumerations of the frequency of event recurrence. */ @@ -146,11 +151,11 @@ typedef enum CALENDAR_RECURRENCE_DAILY, /**< A Event occurs every day */ CALENDAR_RECURRENCE_WEEKLY, /**< A Event occurs on the same day of every week \n According to week flag, the event will recurrence every days of week */ CALENDAR_RECURRENCE_MONTHLY, /**< A Event occurs on the same day of every month */ - CALENDAR_RECURRENCE_YEARLY, /**< A Event occurs on the same day of every year */ + CALENDAR_RECURRENCE_YEARLY /**< A Event occurs on the same day of every year */ } calendar_recurrence_frequency_e; /** - * @brief Enumerations of weekly recurrence event which days of week will be repeated. + * @brief Enumerations of weekly recurrence event which days of week will be repeated. "OR"ing supported. */ typedef enum { @@ -166,27 +171,79 @@ typedef enum } calendar_week_flag_e; /** - * @brief Called once for each event returned from the query. - * - * @param[in] event The calendar event handle - * @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 return @c false to break out of the loop. - * - * @pre calendar_foreach_event_from_db() will invoke this callback. - * @pre calendar_query_event_by_subject() will invoke this callback. - * @pre calendar_query_event_by_description() will invoke this callback. - * @pre calendar_query_event_by_location() will invoke this callback. - * @pre calendar_query_event_by_period() will invoke this callback. - * @pre calendar_query_event_by_time_last_modified() will invoke this callback. + * @brief Enumerations of category for event. + */ +typedef enum +{ + CALENDAR_EVENT_CATEGORY_NONE=0, /**< No category */ + CALENDAR_EVENT_CATEGORY_APPOINTMENT, /**< Appointment category */ + CALENDAR_EVENT_CATEGORY_IMPORTANT, /**< Important category */ + CALENDAR_EVENT_CATEGORY_ANNIVERSARY, /**< Anniversary category */ + CALENDAR_EVENT_CATEGORY_BIRTHDAY, /**< Birthday category */ + CALENDAR_EVENT_CATEGORY_HOLIDAY, /**< Holiday category */ + CALENDAR_EVENT_CATEGORY_PRIVATE, /**< Private category */ + CALENDAR_EVENT_CATEGORY_BUSSINESS /**< Bussiness category */ +}calendar_event_category_e; + +/** + * @brief Enumerations of status for event. + */ +typedef enum +{ + CALENDAR_EVENT_STATUS_NONE = 0x01, /**< None */ + CALENDAR_EVENT_STATUS_TENTATIVE = 0x02, /**< The event is tentative */ + CALENDAR_EVENT_STATUS_CONFIRMED = 0x04, /**< The event is confirmed */ + CALENDAR_EVENT_STATUS_CANCELLED = 0x08 /**< The event is cancelled */ +}calendar_event_status_e; + +/** + * @brief Enumerations of busy status for event. + */ +typedef enum +{ + CALENDAR_EVENT_BUSY_STATUS_FREE = 0, /**< The free status */ + CALENDAR_EVENT_BUSY_STATUS_BUSY, /**< The busy status */ + CALENDAR_EVENT_BUSY_STATUS_UNAVAILABLE, /**< The unavailable status */ + CALENDAR_EVENT_BUSY_STATUS_TENTATIVE /**< The tentative status */ +}calendar_event_busy_status_e; + +/** + * @brief Calendar event item priority + */ +typedef enum +{ + CALENDAR_EVENT_PRIORITY_LOW = 0, /**< Low priority */ + CALENDAR_EVENT_PRIORITY_NORMAL, /**< Normal priority */ + CALENDAR_EVENT_PRIORITY_HIGH /**< High priority */ +} calendar_event_priority_e; + +/** + * @brief Enumerations of modified status for event. + */ +typedef enum +{ + CALENDAR_EVENT_MODIFIED_STATUS_INSERTED = 0, /**< The event is inserted */ + CALENDAR_EVENT_MODIFIED_STATUS_UPDATED, /**< The event is updated */ + CALENDAR_EVENT_MODIFIED_STATUS_DELETED /**< The event is deleted */ +}calendar_event_modified_status_e; + +/** + * @brief The structure of modified event * - * @see calendar_query_event_by_subject() - * @see calendar_query_event_by_description() - * @see calendar_query_event_by_location() - * @see calendar_query_event_by_period() - * @see calendar_foreach_event_from_db() + * @see calendar_event_search_event_by_version() + */ +typedef struct +{ + calendar_event_modified_status_e modified_status; /**< modified status */ + int event_db_id; /**< event database ID */ + int calendar_book_db_id; /**< calendar book database ID */ + int calendar_db_version; /**< calendar database version */ +}calendar_modified_event_s; + +/** + * @brief The pointer type of calendar_modified_event_s */ -typedef bool (*calendar_foreach_query_event_cb)(calendar_event_h event, void *user_data); +typedef calendar_modified_event_s* pcalendar_modified_event_s; /** * @} @@ -198,18 +255,25 @@ typedef bool (*calendar_foreach_query_event_cb)(calendar_event_h event, void *us */ /** - * @brief Called when any database changes has occurred. + * @brief Enumerations of calendar database changed type. + */ +typedef enum +{ + CALENDAR_DB_CHANGED_CB_TYPE_CALENDAR_BOOK = 1, /**< Subscribes a calendar book related notifications */ + CALENDAR_DB_CHANGED_CB_TYPE_EVENT, /**< Subscribes a event related notifications */ + CALENDAR_DB_CHANGED_CB_TYPE_TODO /**< Subscribes a to-do related notifications */ +}calendar_db_changed_cb_type_e; + +/** + * @brief Called when any database changes has occurred. * * @param[in] user_data The user data passed from the callback registration function * - * @pre calendar_set_db_changed_cb() will invoke this callback. + * @pre calendar_add_db_changed_cb() will invoke this callback. * @pre calendar_event_insert_to_db(), calendar_event_delete_from_db() or calendar_event_update_to_db() will invoke this callback. * - * @see calendar_set_db_changed_cb() - * @see calendar_unset_db_changed_cb() - * @see calendar_event_insert_to_db() - * @see calendar_event_delete_from_db() - * @see calendar_event_update_to_db() + * @see calendar_add_db_changed_cb() + * @see calendar_remove_db_changed_cb() */ typedef void (*calendar_db_changed_cb)(void *user_data); @@ -225,56 +289,67 @@ typedef void (*calendar_db_changed_cb)(void *user_data); /** * @brief The calendar to-do handle. */ -typedef struct calendar_event_s *calendar_todo_h; +typedef struct calendar_event_s* calendar_todo_h; /** * @brief Calendar to-do item priority */ typedef enum { - CALENDAR_TODO_PRIORITY_LOW = 0, /**< Low priority */ - CALENDAR_TODO_PRIORITY_NORMAL, /**< Normal priority */ - CALENDAR_TODO_PRIORITY_HIGH /**< High priority */ + CALENDAR_TODO_PRIORITY_NONE = 0x01, /**< Priority none */ + CALENDAR_TODO_PRIORITY_LOW = 0x08, /**< Low priority */ + CALENDAR_TODO_PRIORITY_NORMAL = 0x04, /**< Normal priority */ + CALENDAR_TODO_PRIORITY_HIGH = 0x02, /**< High priority */ } calendar_todo_priority_e; +/** + * @brief Enumerations of status for to-do. + */ typedef enum { - CALENDAR_TODO_STATUS_NONE = 0, /**< None */ - CALENDAR_TODO_STATUS_NEEDS_ACTION, /**< Needs action status */ - CALENDAR_TODO_STATUS_COMPLETED, /**< Completed status */ - CALENDAR_TODO_STATUS_IN_PROCESS, /**< Work in process status */ - CALENDAR_TODO_STATUS_CANCELED /**< Canceled status */ + CALENDAR_TODO_STATUS_NONE = 0x0100, /**< None */ + CALENDAR_TODO_STATUS_NEEDS_ACTION = 0x0200, /**< Needs action status */ + CALENDAR_TODO_STATUS_COMPLETED = 0x0400, /**< Completed status */ + CALENDAR_TODO_STATUS_IN_PROCESS = 0x0800, /**< Work in process status */ + CALENDAR_TODO_STATUS_CANCELED = 0x1000 /**< Canceled status */ } calendar_todo_status_e; +// deprecated +#define CALENDAR_TODO_FILTER_PRIORITY_ALL -1 + +// deprecated +#define CALENDAR_TODO_FILTER_STATUS_ALL -1 + /** - * @brief Called once for each calendar to-do item. - * - * @param[in] todo The calendar to-do handle - * @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 return @c false to break out of the loop. + * @brief Enumerations of modified status for to-do. + */ +typedef enum +{ + CALENDAR_TODO_MODIFIED_STATUS_INSERTED = 0, /**< The to-do is inserted */ + CALENDAR_TODO_MODIFIED_STATUS_UPDATED, /**< The to-do is updated */ + CALENDAR_TODO_MODIFIED_STATUS_DELETED /**< The to-do is deleted */ +}calendar_todo_modified_status_e; + +/** + * @brief The structure of modified to-do * - * @pre calendar_foreach_todo_from_db() will invoke this callback. - * @see calendar_foreach_todo_from_db() + * @see calendar_todo_search_todo_by_version() */ -typedef bool (*calendar_foreach_query_todo_cb)(calendar_todo_h todo, void *user_data); +typedef struct +{ + calendar_todo_modified_status_e modified_status; /**< modified status */ + int todo_db_id; /**< to-do database ID */ + int calendar_book_db_id; /**< calendar book database ID */ + int calendar_db_version; /**< calendar database version */ +}calendar_modified_todo_s; + /** - * @} + * @brief The pointer type of calendar_modified_todo_s */ +typedef calendar_modified_todo_s* pcalendar_modified_todo_s; /** - * @ingroup CAPI_SOCIAL_CALENDAR_MODULE - * @defgroup CAPI_SOCIAL_CALENDAR_MULTIPLECALENDAR_MODULE Multiple Calendar - * - * @brief Calendar definition and Calendar related operations. - * - * @section CAPI_SOCIAL_CALENDAR_MULTIPLECALENDAR_MODULE_HEADER Required Header - * \#include <calendar.h> - * - * @section CAPI_SOCIAL_CALENDAR_MULTIPLECALENDAR_MODULE_OVERVIEW Overview - * Calendar - * - * <BR> + * @} */ /** @@ -285,42 +360,42 @@ typedef bool (*calendar_foreach_query_todo_cb)(calendar_todo_h todo, void *user_ /** * @brief The calendar handle. */ -typedef struct calendar_event_s *calendar_h; +typedef struct calendar_event_s* calendar_book_h; + +// deprecated +#define DEFAULT_CALENDAR_BOOK_DB_ID 1 + +/** + * @brief Definition for default event calendar book database ID + */ +#define DEFAULT_EVENT_CALENDAR_BOOK_DB_ID 1 + +/** + * @brief Definition for default to-do calendar book database ID + */ +#define DEFAULT_TODO_CALENDAR_BOOK_DB_ID 2 /** - * @brief Definition for default calendar database ID + * @brief Definition for all calendar book */ -#define DEFAULT_CALENDAR_DB_ID 1 +#define CALENDAR_BOOK_FILTER_ALL -1 /** * @brief The structure of calendar in search results. * - * @see calendar_foreach_query_calendar_cb() + * @see calendar_foreach_query_calendar_book_cb() */ typedef struct { - int calendar_db_id; /**< calendar database ID */ - char* calendar_name; /**< calendar name */ - bool calendar_is_default; /**< default calendar status */ - bool calendar_is_visible; /**< calendar visible status */ - unsigned char calendar_color_red; /**< calendar color red among RGB */ - unsigned char calendar_color_green; /**< calendar color green among RGB */ - unsigned char calendar_color_blue; /**< calendar color blue among RGB */ - int account_db_id; /**< account database ID */ -}calendar_query_calendar_s; - -/** - * @brief The callback function to get the calendar - * - * @param[in] calendar The calendar - * @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 calendar_foreach_calendar_from_db() will invoke this callback. - * - * @see calendar_foreach_calendar_from_db() - */ -typedef bool (*calendar_foreach_query_calendar_cb)(calendar_query_calendar_s *calendar, void *user_data); + int calendar_db_id; /**< Calendar database ID */ + int calendar_type; /**< Calendar type. It supports "OR"ing of #calendar_book_type_e*/ + char* calendar_name; /**< Calendar name */ + bool calendar_is_default; /**< Default calendar status */ + bool calendar_is_visible; /**< Calendar visible status */ + unsigned char calendar_color_red; /**< Calendar color red among RGB */ + unsigned char calendar_color_green; /**< Calendar color green among RGB */ + unsigned char calendar_color_blue; /**< Calendar color blue among RGB */ + int account_db_id; /**< Account database ID */ +}calendar_query_calendar_book_s; /** * @} diff --git a/packaging/capi-social-calendar.manifest b/packaging/capi-social-calendar.manifest deleted file mode 100644 index 017d22d..0000000 --- a/packaging/capi-social-calendar.manifest +++ /dev/null @@ -1,5 +0,0 @@ -<manifest> - <request> - <domain name="_"/> - </request> -</manifest> diff --git a/packaging/capi-social-calendar.spec b/packaging/capi-social-calendar.spec index 05126be..e38aab8 100644..100755 --- a/packaging/capi-social-calendar.spec +++ b/packaging/capi-social-calendar.spec @@ -1,11 +1,10 @@ Name: capi-social-calendar -Summary: Calendar library in Tizen Native API -Version: 0.1.1 -Release: 35 +Summary: Calendar library in Tizen C API +Version: 0.1.1 +Release: 53 Group: TO_BE/FILLED_IN -License: Apache-2.0 +License: TO BE FILLED IN Source0: %{name}-%{version}.tar.gz -Source1001: packaging/capi-social-calendar.manifest BuildRequires: cmake BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(calendar) @@ -22,7 +21,7 @@ Requires(postun): /sbin/ldconfig %package devel -Summary: Calendar library in Tizen Native API (Development) +Summary: Calendar library in SLP C API (Development) Group: TO_BE/FILLED_IN Requires: %{name} = %{version}-%{release} @@ -35,7 +34,6 @@ Requires: %{name} = %{version}-%{release} %build -cp %{SOURCE1001} . MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} @@ -52,11 +50,9 @@ rm -rf %{buildroot} %files -%manifest capi-social-calendar.manifest %{_libdir}/libcapi-social-calendar.so.* %files devel -%manifest capi-social-calendar.manifest %{_includedir}/social/*.h %{_libdir}/pkgconfig/*.pc %{_libdir}/libcapi-social-calendar.so diff --git a/src/calendar.c b/src/calendar.c index c91ec63..d27d007 100755 --- a/src/calendar.c +++ b/src/calendar.c @@ -11,20 +11,22 @@ * 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. + * limitations under the License. */ - + #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <stdint.h> #include <time.h> -#include <calendar.h> -#include <calendar_private.h> - -#include <calendar-svc-provider.h> #include <dlog.h> #include <contacts.h> +#include <calendar-svc-provider.h> + +#include "calendar_private.h" +#include "calendar_types.h" +#include "calendar.h" #ifdef LOG_TAG #undef LOG_TAG @@ -33,142 +35,189 @@ #define LOG_TAG "TIZEN_N_CALENDAR" #define LOG_MODE (1) +#ifndef CALS_TODO_NO_DUE_DATE +#define CALS_TODO_NO_DUE_DATE INT64_MAX +#endif + + /* * Public Implementation */ int calendar_connect(void) { - int ret_val = calendar_svc_connect(); - - if (ret_val == CAL_SUCCESS) { - return CALENDAR_ERROR_NONE; - } else { - LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); + if (calendar_svc_connect() != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_DB_FAILED); return CALENDAR_ERROR_DB_FAILED; } + return CALENDAR_ERROR_NONE; } int calendar_disconnect(void) { - int ret_val = calendar_svc_close(); + if (calendar_svc_close() != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_DB_FAILED); + return CALENDAR_ERROR_DB_FAILED; + } + return CALENDAR_ERROR_NONE; +} - if (ret_val == CAL_SUCCESS) { - return CALENDAR_ERROR_NONE; - } else { - LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); +int calendar_begin_transaction(void) +{ + if (calendar_svc_begin_trans()!= CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_DB_FAILED); return CALENDAR_ERROR_DB_FAILED; } + return CALENDAR_ERROR_NONE; +} + +int calendar_rollback_transaction(void) +{ + if (calendar_svc_end_trans(false)!= CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_DB_FAILED); + return CALENDAR_ERROR_DB_FAILED; + } + return CALENDAR_ERROR_NONE; +} + +int calendar_commit_transaction(void) +{ + if (calendar_svc_end_trans(true)!= CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_DB_FAILED); + return CALENDAR_ERROR_DB_FAILED; + } + return CALENDAR_ERROR_NONE; +} + +int calendar_book_delete_from_db(int calendar_db_id) +{ + int ret; + + ret = calendar_svc_delete(CAL_STRUCT_CALENDAR, calendar_db_id); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_DB_FAILED); + return CALENDAR_ERROR_DB_FAILED; + } + return CALENDAR_ERROR_NONE; +} + +int calendar_delete_all_by_account(int account_db_id) +{ + int ret; + + ret = calendar_svc_delete(CAL_STRUCT_SCHEDULE, account_db_id); + + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_DB_FAILED); + return CALENDAR_ERROR_DB_FAILED; + } + return CALENDAR_ERROR_NONE; } int calendar_event_insert_to_db(calendar_event_h event, int calendar_db_id, int *event_id) -{ +{ CALENDAR_NULL_ARG_CHECK(event); CALENDAR_NULL_ARG_CHECK(event_id); - - int ret_val = CALENDAR_ERROR_NONE; - int account_db_id = _calendar_get_account_db_id(calendar_db_id); - CONTACTS_INVALID_ARG_CHECK(account_db_id == -2); + int ret; + int account_db_id; + cal_struct *cs; - calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_INT_CALENDAR_ID, calendar_db_id); - calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_INT_ACCOUNT_ID, account_db_id); + account_db_id = _calendar_get_account_db_id(calendar_db_id); + CALENDAR_INVALID_ARG_CHECK(account_db_id == -2); - ret_val = -1; - ret_val = calendar_svc_insert((cal_struct*)((calendar_event_s*)event)->event_legacy); - if (ret_val < 0) { - LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if (cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + calendar_svc_struct_set_int(cs, CAL_VALUE_INT_CALENDAR_ID, calendar_db_id); + calendar_svc_struct_set_int(cs, CAL_VALUE_INT_ACCOUNT_ID, account_db_id); + + ret = calendar_svc_insert(cs); + if (ret < 0) { + LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_DB_FAILED); return CALENDAR_ERROR_DB_FAILED; } - *event_id = ret_val; - return CALENDAR_ERROR_NONE; + *event_id = ret; + return CALENDAR_ERROR_NONE; } int calendar_event_delete_from_db(int event_id) -{ - CONTACTS_INVALID_ARG_CHECK(event_id <= 0); - - int ret_val = CALENDAR_ERROR_NONE; - - ret_val = calendar_svc_delete(CAL_STRUCT_SCHEDULE, event_id); - - if (ret_val == CAL_SUCCESS) { - ret_val = CALENDAR_ERROR_NONE; - } - else { - LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); - ret_val = CALENDAR_ERROR_DB_FAILED; - } +{ + CALENDAR_INVALID_ARG_CHECK(event_id <= 0); + + int ret; - return ret_val; + ret = calendar_svc_delete(CAL_STRUCT_SCHEDULE, event_id); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_DB_FAILED); + return CALENDAR_ERROR_DB_FAILED; + } + return CALENDAR_ERROR_NONE; } int calendar_event_update_to_db(calendar_event_h event) -{ +{ CALENDAR_NULL_ARG_CHECK(event); - int ret_val = CALENDAR_ERROR_NONE; + int ret; + cal_struct *cs; - if((cal_struct*)((calendar_event_s*)event)->event_legacy == NULL) { - LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); - return CALENDAR_ERROR_INVALID_PARAMETER; - } - - int event_id = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_TABLE_INT_INDEX); - if(event_id <= 0) { - LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); - return CALENDAR_ERROR_INVALID_PARAMETER; - } - - cal_struct* cal = NULL; - if(calendar_svc_get(CAL_STRUCT_SCHEDULE, event_id, NULL, &cal) == CAL_SUCCESS) { // referenced (SVACE) - if( ((calendar_schedule_s*)((calendar_event_legacy_s*)cal)->user_data)->is_deleted == true ) { // referenced (SVACE) - if(cal != NULL) { // referenced (SVACE) - calendar_svc_struct_free(&cal); - } - LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); - return CALENDAR_ERROR_INVALID_PARAMETER; - } else { - if(cal != NULL) { // referenced (SVACE) - calendar_svc_struct_free(&cal); - } - } - } else { - if(cal != NULL) { // referenced (SVACE) - calendar_svc_struct_free(&cal); - } - LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } - - ret_val = calendar_svc_update((cal_struct*)((calendar_event_s*)event)->event_legacy); - if (ret_val != CAL_SUCCESS) { - LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); + ret = calendar_svc_update(cs); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_DB_FAILED); return CALENDAR_ERROR_DB_FAILED; } - - return CALENDAR_ERROR_NONE; + return CALENDAR_ERROR_NONE; } int calendar_event_get_from_db(int event_id, calendar_event_h *event) { CALENDAR_NULL_ARG_CHECK(event); - *event = malloc(sizeof(calendar_event_s)); - if (*event == NULL) { - LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY); + + int ret; + calendar_event_s *ce; + + ce = calloc(1, sizeof(calendar_event_s)); + if (ce == NULL) { + LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY); return CALENDAR_ERROR_OUT_OF_MEMORY; } - memset(*event, 0, sizeof(calendar_event_s)); - if(calendar_svc_get(CAL_STRUCT_SCHEDULE, event_id, NULL, (cal_struct**)&(*(calendar_event_s**)event)->event_legacy) != CAL_SUCCESS) { + LOGD("event_id = %d", event_id); + + ret = calendar_svc_get(CAL_STRUCT_SCHEDULE, event_id, NULL, + (cal_struct **)&(ce->event_legacy)); + if(ret != CAL_SUCCESS) { free(*event); *event = NULL; - - LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); + LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_DB_FAILED); return CALENDAR_ERROR_DB_FAILED; } + *event = (calendar_event_h)ce; return CALENDAR_ERROR_NONE; } @@ -177,129 +226,988 @@ int calendar_event_get_db_id(calendar_event_h event, int *db_id) CALENDAR_NULL_ARG_CHECK(event); CALENDAR_NULL_ARG_CHECK(db_id); - *db_id = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)event)->event_legacy, (char*)CAL_VALUE_INT_INDEX); + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + *db_id = calendar_svc_struct_get_int(cs, CAL_VALUE_INT_INDEX); if(*db_id < 0) *db_id = 0; return CALENDAR_ERROR_NONE; } -int calendar_event_get_calendar_db_id(calendar_event_h event, int *calendar_db_id) +int calendar_event_get_calendar_book_db_id(calendar_event_h event, int *calendar_book_db_id) { CALENDAR_NULL_ARG_CHECK(event); - CALENDAR_NULL_ARG_CHECK(calendar_db_id); + CALENDAR_NULL_ARG_CHECK(calendar_book_db_id); - *calendar_db_id = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)event)->event_legacy, - (char*)CAL_VALUE_INT_CALENDAR_ID); - if(*calendar_db_id < 0) - *calendar_db_id = 0; + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + *calendar_book_db_id = calendar_svc_struct_get_int(cs, CAL_VALUE_INT_CALENDAR_ID); + if(*calendar_book_db_id < 0) + *calendar_book_db_id = 0; + return CALENDAR_ERROR_NONE; +} + +int calendar_event_get_status(calendar_event_h event, calendar_event_status_e *status) +{ + CALENDAR_NULL_ARG_CHECK(event); + CALENDAR_NULL_ARG_CHECK(status); + + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + *status = calendar_svc_struct_get_int(cs, CAL_VALUE_INT_MEETING_STATUS); + if (*status < 0) { + *status = 0; + } + return CALENDAR_ERROR_NONE; +} + +int calendar_event_set_status(calendar_event_h event, calendar_event_status_e status) +{ + CALENDAR_NULL_ARG_CHECK(event); + + int ret; + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + ret = calendar_svc_struct_set_int(cs, CAL_VALUE_INT_MEETING_STATUS, status); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + return CALENDAR_ERROR_NONE; +} + +int calendar_event_get_priority(calendar_event_h event, calendar_event_priority_e *priority) +{ + CALENDAR_NULL_ARG_CHECK(event); + CALENDAR_NULL_ARG_CHECK(priority); + + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + *priority = calendar_svc_struct_get_int(cs, CAL_VALUE_INT_PRIORITY); + + return CALENDAR_ERROR_NONE; +} + +int calendar_event_set_priority(calendar_event_h event, calendar_event_priority_e priority) +{ + CALENDAR_NULL_ARG_CHECK(event); + + int ret; + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + ret = calendar_svc_struct_set_int(cs, CAL_VALUE_INT_PRIORITY, priority); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + return CALENDAR_ERROR_NONE; +} + +int calendar_event_get_busy_status(calendar_event_h event, calendar_event_busy_status_e *busy_status) +{ + CALENDAR_NULL_ARG_CHECK(event); + CALENDAR_NULL_ARG_CHECK(busy_status); + + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + *busy_status = calendar_svc_struct_get_int(cs, CAL_VALUE_INT_BUSY_STATUS); + + return CALENDAR_ERROR_NONE; +} + +int calendar_event_set_busy_status(calendar_event_h event, calendar_event_busy_status_e busy_status) +{ + CALENDAR_NULL_ARG_CHECK(event); + + int ret; + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + ret = calendar_svc_struct_set_int(cs, CAL_VALUE_INT_BUSY_STATUS, busy_status); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } return CALENDAR_ERROR_NONE; } -int calendar_event_get_total_count_from_db(int *count) -{ +// TOREM +int calendar_event_get_total_count_from_db(int calendar_book_db_id, int *count) +{ CALENDAR_NULL_ARG_CHECK(count); - - *count = calendar_svc_get_count(0, 0, (char*)CAL_STRUCT_SCHEDULE); - if(*count == CAL_ERR_FAIL) - { + + int cnt; + int account_db_id; + + account_db_id = _calendar_get_account_db_id(calendar_book_db_id); + CALENDAR_INVALID_ARG_CHECK(account_db_id == -2); + cnt = calendar_svc_get_count(account_db_id, calendar_book_db_id, CAL_STRUCT_SCHEDULE); + if(cnt == CAL_ERR_FAIL) { *count = 0; - LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); + LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_DB_FAILED); + return CALENDAR_ERROR_DB_FAILED; + } + + *count = cnt; + return CALENDAR_ERROR_NONE; +} + +int calendar_event_get_reminder_sound_file_path(calendar_event_h event, char **sound_file_path) +{ + CALENDAR_NULL_ARG_CHECK(event); + CALENDAR_NULL_ARG_CHECK(sound_file_path); + + cal_struct *cs; + GList *alarm_list; + int ret; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + ret = calendar_svc_struct_get_list(cs, CAL_VALUE_LST_ALARM, &alarm_list); + if (ret < CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + if (!alarm_list || !alarm_list->data) { + *sound_file_path = NULL; + return CALENDAR_ERROR_NONE; + } + + *sound_file_path = _calendar_safe_strdup( + calendar_svc_value_get_str(alarm_list->data, CAL_VALUE_TXT_ALARMS_TONE)); + + return CALENDAR_ERROR_NONE; +} + +int calendar_event_set_reminder_sound_file_path(calendar_event_h event, const char *sound_file_path) +{ + CALENDAR_NULL_ARG_CHECK(event); + + int ret; + cal_struct *cs; + GList *alarm_list = NULL; + cal_value *value; + GList* list = NULL; + int svc_reminder_interval_type; + int reminder_interval; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + ret = calendar_svc_struct_get_list(cs, CAL_VALUE_LST_ALARM, &alarm_list); + if (ret < CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + if (alarm_list) { + if (!alarm_list->data) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + value = (cal_value *)alarm_list->data; + svc_reminder_interval_type = calendar_svc_value_get_int(value, + CAL_VALUE_INT_ALARMS_TICK_UNIT); + reminder_interval = calendar_svc_value_get_int(value, + CAL_VALUE_INT_ALARMS_TICK); + calendar_svc_struct_free(&value); + alarm_list = NULL; + } + + value = calendar_svc_value_new(CAL_VALUE_LST_ALARM); + if (value == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + ret = calendar_svc_value_set_int(value, + CAL_VALUE_INT_ALARMS_TICK_UNIT, svc_reminder_interval_type); + if (ret != CAL_SUCCESS) { + calendar_svc_value_free(&value); + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + ret = calendar_svc_value_set_int(value, CAL_VALUE_INT_ALARMS_TICK, reminder_interval); + if (ret != CAL_SUCCESS) { + calendar_svc_value_free(&value); + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + ret = calendar_svc_value_set_str(value, CAL_VALUE_TXT_ALARMS_TONE, sound_file_path); + if (ret != CAL_SUCCESS) { + calendar_svc_value_free(&value); + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + calendar_svc_struct_store_list(cs, CAL_VALUE_LST_ALARM, NULL); + list = g_list_append(list, value); + ret = calendar_svc_struct_store_list(cs, CAL_VALUE_LST_ALARM, list); + if (ret != CAL_SUCCESS) { + calendar_svc_value_free(&value); + g_list_free(list); + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + return CALENDAR_ERROR_NONE; +} + +int calendar_event_get_recurrence_byday(calendar_event_h event, char **byday) +{ + CALENDAR_NULL_ARG_CHECK(event); + CALENDAR_NULL_ARG_CHECK(byday); + + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + *byday = _calendar_safe_strdup( + calendar_svc_struct_get_str(cs, CALS_VALUE_TXT_RRULE_BYDAY)); + return CALENDAR_ERROR_NONE; +} + +int calendar_event_set_recurrence_byday(calendar_event_h event, const char* byday) +{ + CALENDAR_NULL_ARG_CHECK(event); + + int ret; + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + ret = calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYDAY, byday); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + return CALENDAR_ERROR_NONE; +} + +int calendar_event_get_recurrence_bysetpos(calendar_event_h event, char **bysetpos) +{ + CALENDAR_NULL_ARG_CHECK(event); + CALENDAR_NULL_ARG_CHECK(bysetpos); + + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + *bysetpos = _calendar_safe_strdup( + calendar_svc_struct_get_str(cs, CALS_VALUE_TXT_RRULE_BYSETPOS)); + return CALENDAR_ERROR_NONE; +} + +int calendar_event_set_recurrence_bysetpos(calendar_event_h event, const char* bysetpos) +{ + CALENDAR_NULL_ARG_CHECK(event); + + int ret; + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + ret = calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYSETPOS, bysetpos); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + return CALENDAR_ERROR_NONE; +} + +int calendar_event_get_recurrence_bymonthday(calendar_event_h event, char **bymonthday) +{ + CALENDAR_NULL_ARG_CHECK(event); + CALENDAR_NULL_ARG_CHECK(bymonthday); + + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + *bymonthday = _calendar_safe_strdup( + calendar_svc_struct_get_str(cs, CALS_VALUE_TXT_RRULE_BYMONTHDAY)); + return CALENDAR_ERROR_NONE; +} + +int calendar_event_set_recurrence_bymonthday(calendar_event_h event, const char* bymonthday) +{ + CALENDAR_NULL_ARG_CHECK(event); + + int ret; + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + ret = calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYMONTHDAY, bymonthday); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + return CALENDAR_ERROR_NONE; +} + +int calendar_event_get_recurrence_bymonth(calendar_event_h event, char **bymonth) +{ + CALENDAR_NULL_ARG_CHECK(event); + CALENDAR_NULL_ARG_CHECK(bymonth); + + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + *bymonth = _calendar_safe_strdup( + calendar_svc_struct_get_str(cs, CALS_VALUE_TXT_RRULE_BYMONTH)); + return CALENDAR_ERROR_NONE; +} + +int calendar_event_set_recurrence_bymonth(calendar_event_h event, const char* bymonth) +{ + CALENDAR_NULL_ARG_CHECK(event); + + int ret; + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + ret = calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYMONTH, bymonth); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + return CALENDAR_ERROR_NONE; +} + +int calendar_event_get_recurrence_week_start(calendar_event_h event, calendar_week_flag_e *week_start) +{ + CALENDAR_NULL_ARG_CHECK(event); + CALENDAR_NULL_ARG_CHECK(week_start); + + int wkst; + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + wkst = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_RRULE_WKST); + switch (wkst) { + case CALS_SUNDAY: + *week_start = CALENDAR_WEEK_FLAG_SUN; + break; + case CALS_MONDAY: + *week_start = CALENDAR_WEEK_FLAG_MON; + break; + case CALS_TUESDAY: + *week_start = CALENDAR_WEEK_FLAG_TUE; + break; + case CALS_WEDNESDAY: + *week_start = CALENDAR_WEEK_FLAG_WED; + break; + case CALS_THURSDAY: + *week_start = CALENDAR_WEEK_FLAG_THU; + break; + case CALS_FRIDAY: + *week_start = CALENDAR_WEEK_FLAG_FRI; + break; + case CALS_SATURDAY: + *week_start = CALENDAR_WEEK_FLAG_SAT; + break; + default: + *week_start = CALENDAR_WEEK_FLAG_SUN; + break; + } + return CALENDAR_ERROR_NONE; +} + +int calendar_event_set_recurrence_week_start(calendar_event_h event, calendar_week_flag_e week_start) +{ + CALENDAR_NULL_ARG_CHECK(event); + + int ret = CALENDAR_ERROR_NONE; + int wkst; + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + switch (week_start) { + case CALENDAR_WEEK_FLAG_SUN: + wkst = CALS_SUNDAY; + break; + case CALENDAR_WEEK_FLAG_MON: + wkst = CALS_MONDAY; + break; + case CALENDAR_WEEK_FLAG_TUE: + wkst = CALS_TUESDAY; + break; + case CALENDAR_WEEK_FLAG_WED: + wkst = CALS_WEDNESDAY; + break; + case CALENDAR_WEEK_FLAG_THU: + wkst = CALS_THURSDAY; + break; + case CALENDAR_WEEK_FLAG_FRI: + wkst = CALS_FRIDAY; + break; + case CALENDAR_WEEK_FLAG_SAT: + wkst = CALS_SATURDAY; + break; + default: + wkst = CALS_SUNDAY; + break; + } + ret = calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_WKST, wkst); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + return CALENDAR_ERROR_NONE; +} + +int calendar_event_delete_recurrence_instance_from_db(int event_db_id, long long int start_time) +{ + int ret; + + if (event_db_id < 0) { + LOGE("Invalid argument: event_db_id is NULL"); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + ret = calendar_svc_event_delete_normal_instance(event_db_id, start_time); + if (ret != CAL_SUCCESS) { + LOGE("Failed to delete normal instance"); + return CALENDAR_ERROR_DB_FAILED; + } + return CALENDAR_ERROR_NONE; +} + +int calendar_event_delete_recurrence_all_day_instance_from_db(int event_db_id, int year, int month, int day) +{ + int ret; + + if (event_db_id < 0) { + LOGE("Invalid argument: event_db_id is NULL"); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + ret = calendar_svc_event_delete_allday_instance(event_db_id, year, month, day); + if (ret != CAL_SUCCESS) { + LOGE("Failed to delete normal instance"); return CALENDAR_ERROR_DB_FAILED; } + return CALENDAR_ERROR_NONE; +} + +int calendar_event_get_recurrence_exdate(calendar_event_h event, char** exdate) +{ + CALENDAR_NULL_ARG_CHECK(event); + CALENDAR_NULL_ARG_CHECK(exdate); + + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if (cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + *exdate = _calendar_safe_strdup( + calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_EXDATE)); + return CALENDAR_ERROR_NONE; +} + +int calendar_event_get_uid(calendar_event_h event, char **uid) +{ + CALENDAR_NULL_ARG_CHECK(event); + CALENDAR_NULL_ARG_CHECK(uid); + + char *_uid; + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + _uid = _calendar_safe_strdup( + calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_UID)); + if (_uid == NULL || strlen(_uid) < 1) { + *uid = NULL; + + } else { + *uid = _uid; + + } + + return CALENDAR_ERROR_NONE; +} + +int calendar_event_set_uid(calendar_event_h event, const char *uid) +{ + CALENDAR_NULL_ARG_CHECK(event); + + int ret; + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + ret = calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_UID, uid); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + return CALENDAR_ERROR_NONE; +} + +int calendar_event_get_recurrence_interval(calendar_event_h event, int *recurrence_interval) +{ + CALENDAR_NULL_ARG_CHECK(event); + CALENDAR_NULL_ARG_CHECK(recurrence_interval); + + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + *recurrence_interval = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_RRULE_INTERVAL); + + return CALENDAR_ERROR_NONE; +} + +int calendar_event_set_recurrence_interval(calendar_event_h event, int recurrence_interval) +{ + CALENDAR_NULL_ARG_CHECK(event); + + int ret; + cal_struct *cs; - return CALENDAR_ERROR_NONE; + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + ret = calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_INTERVAL, recurrence_interval); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + return CALENDAR_ERROR_NONE; +} + +int calendar_event_get_recurrence_count(calendar_event_h event, int *recurrence_count) +{ + CALENDAR_NULL_ARG_CHECK(event); + CALENDAR_NULL_ARG_CHECK(recurrence_count); + + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + *recurrence_count = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_RRULE_COUNT); + + return CALENDAR_ERROR_NONE; +} + +int calendar_event_set_recurrence_count(calendar_event_h event, int recurrence_count) +{ + CALENDAR_NULL_ARG_CHECK(event); + + int ret; + int type; + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + type = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_DTSTART_TYPE); + calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_UNTIL_TYPE, type); + + calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_RANGE_TYPE, CALS_RANGE_COUNT); + ret = calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_COUNT, recurrence_count); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + return CALENDAR_ERROR_NONE; +} + +int calendar_attendee_get_status(calendar_attendee_h attendee, calendar_attendee_status_e *status) +{ + CALENDAR_NULL_ARG_CHECK(attendee); + CALENDAR_NULL_ARG_CHECK(status); + + *status = calendar_svc_value_get_int( + (cal_value*)attendee, + CAL_VALUE_INT_ATTENDEE_DETAIL_STATUS); + if(*status < 0 || *status > CALENDAR_ATTENDEE_STATUS_MAX) { + *status = -1; + return CALENDAR_ERROR_NO_DATA; + } + return CALENDAR_ERROR_NONE; +} + +int calendar_attendee_set_status(calendar_attendee_h attendee, calendar_attendee_status_e status) +{ + CALENDAR_NULL_ARG_CHECK(attendee); + + int ret; + + ret = calendar_svc_value_set_int( + (cal_value*)attendee, + CAL_VALUE_INT_ATTENDEE_DETAIL_STATUS, status); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + return CALENDAR_ERROR_NONE; +} + +int calendar_attendee_get_role(calendar_attendee_h attendee, calendar_attendee_role_e *role) +{ + CALENDAR_NULL_ARG_CHECK(attendee); + CALENDAR_NULL_ARG_CHECK(role); + + *role = calendar_svc_value_get_int( + (cal_value*)attendee, + CAL_VALUE_INT_ATTENDEE_ROLE); + if(*role < 0 || *role > CALENDAR_ATTENDEE_ROLE_MAX) { + *role = -1; + return CALENDAR_ERROR_NO_DATA; + } + return CALENDAR_ERROR_NONE; +} + +int calendar_attendee_set_role(calendar_attendee_h attendee, calendar_attendee_role_e role) +{ + CALENDAR_NULL_ARG_CHECK(attendee); + + int ret; + + ret = calendar_svc_value_set_int( + (cal_value*)attendee, + CAL_VALUE_INT_ATTENDEE_ROLE, role); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + return CALENDAR_ERROR_NONE; } int calendar_event_create (calendar_event_h *event) -{ +{ CALENDAR_NULL_ARG_CHECK(event); - *event = malloc(sizeof(calendar_event_s)); + *event = calloc(1, sizeof(calendar_event_s)); if (*event == NULL) { - LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY); + LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY); return CALENDAR_ERROR_OUT_OF_MEMORY; } - (*(calendar_event_s**)event)->event_legacy = (calendar_event_legacy_s*)calendar_svc_struct_new(CAL_STRUCT_SCHEDULE); + (*(calendar_event_s**)event)->event_legacy = (calendar_event_legacy_s*)calendar_svc_struct_new(CAL_STRUCT_SCHEDULE); if ((*(calendar_event_s**)event)->event_legacy == NULL) { free(*event); *event = NULL; - LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY); + LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY); return CALENDAR_ERROR_OUT_OF_MEMORY; } - calendar_svc_struct_set_int((cal_struct*)(*(calendar_event_s**)event)->event_legacy, CAL_VALUE_INT_TIMEZONE, 100); // set default timezone - + return CALENDAR_ERROR_NONE; } - + int calendar_event_destroy(calendar_event_h event) -{ - int ret_val = CALENDAR_ERROR_NONE; +{ CALENDAR_NULL_ARG_CHECK(event); - ret_val = calendar_svc_struct_free((cal_struct **)&((calendar_event_s*)event)->event_legacy); - - if (ret_val != CAL_SUCCESS) { - LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); - ret_val = CALENDAR_ERROR_INVALID_PARAMETER; - } else { - free(event); - ret_val = CALENDAR_ERROR_NONE; + int ret; + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; } - return ret_val; + ret = calendar_svc_struct_free(&cs); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY); + return CALENDAR_ERROR_OUT_OF_MEMORY; + } + + free(event); + return CALENDAR_ERROR_NONE; } int calendar_event_get_subject(calendar_event_h event, char **subject) -{ +{ CALENDAR_NULL_ARG_CHECK(event); CALENDAR_NULL_ARG_CHECK(subject); - *subject = NULL; - *subject = _calendar_safe_strdup(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_TXT_SUMMARY)); + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } - return CALENDAR_ERROR_NONE; + *subject = _calendar_safe_strdup( + calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_SUMMARY)); + + return CALENDAR_ERROR_NONE; } int calendar_event_set_subject(calendar_event_h event,const char *subject) -{ - int ret_val = CALENDAR_ERROR_NONE; +{ CALENDAR_NULL_ARG_CHECK(event); - ret_val = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_TXT_SUMMARY, subject); + int ret; + cal_struct *cs; - if (ret_val != CAL_SUCCESS) { - LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } + ret = calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_SUMMARY, subject); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + return CALENDAR_ERROR_NONE; +} + +int calendar_event_get_categories(calendar_event_h event, char **categories) +{ + CALENDAR_NULL_ARG_CHECK(event); + CALENDAR_NULL_ARG_CHECK(categories); + + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + *categories = _calendar_safe_strdup( + calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_CATEGORIES)); + + return CALENDAR_ERROR_NONE; +} + +int calendar_event_set_categories(calendar_event_h event,const char *categories) +{ + CALENDAR_NULL_ARG_CHECK(event); + + int ret; + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + ret = calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_CATEGORIES, categories); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } return CALENDAR_ERROR_NONE; } int calendar_event_get_description(calendar_event_h event,char **description) -{ +{ CALENDAR_NULL_ARG_CHECK(event); CALENDAR_NULL_ARG_CHECK(description); - *description = NULL; - *description = _calendar_safe_strdup(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_TXT_DESCRIPTION)); + cal_struct *cs; - return CALENDAR_ERROR_NONE; + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + *description = _calendar_safe_strdup( + calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_DESCRIPTION)); + + return CALENDAR_ERROR_NONE; } int calendar_event_set_description(calendar_event_h event, const char *description) -{ - int ret_val = CALENDAR_ERROR_NONE; - +{ CALENDAR_NULL_ARG_CHECK(event); - ret_val = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_TXT_DESCRIPTION, description); + int ret; + cal_struct *cs; - if (ret_val != CAL_SUCCESS) { - LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } + ret = calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_DESCRIPTION, description); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } return CALENDAR_ERROR_NONE; } @@ -308,56 +1216,174 @@ int calendar_event_get_is_all_day_event(calendar_event_h event, bool *is_all_day CALENDAR_NULL_ARG_CHECK(event); CALENDAR_NULL_ARG_CHECK(is_all_day_event); - *is_all_day_event = (bool)calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)event)->event_legacy, - CAL_VALUE_INT_ALL_DAY_EVENT); + cal_struct *cs; + bool all_day; + int type; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + type = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_DTSTART_TYPE); + + if (type == CALS_TIME_LOCALTIME) + all_day = true; + else + all_day = false; + + *is_all_day_event = all_day; return CALENDAR_ERROR_NONE; } -int calendar_event_set_is_all_day_event(calendar_event_h event, bool is_all_day_event) -{ - int ret_val = CALENDAR_ERROR_NONE; - +int calendar_event_set_all_day_event(calendar_event_h event, + int start_year, int start_month, int start_day, + int end_year, int end_month, int end_day) +{ CALENDAR_NULL_ARG_CHECK(event); - ret_val = calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)event)->event_legacy, - CAL_VALUE_INT_ALL_DAY_EVENT, is_all_day_event); - if (ret_val != CAL_SUCCESS) { - LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + int ret; + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + ret = calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTSTART_TYPE, CALS_TIME_LOCALTIME); + ret |= calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTSTART_YEAR, start_year); + ret |= calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTSTART_MONTH, start_month); + ret |= calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTSTART_MDAY, start_day); + ret |= calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTEND_TYPE, CALS_TIME_LOCALTIME); + ret |= calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTEND_YEAR, end_year); + ret |= calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTEND_MONTH, end_month); + ret |= calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTEND_MDAY, end_day); + + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + return CALENDAR_ERROR_NONE; +} + +int calendar_event_get_all_day_event(calendar_event_h event, + int *start_year, int *start_month, int *start_day, + int *end_year, int *end_month, int *end_day) +{ + CALENDAR_NULL_ARG_CHECK(event); + CALENDAR_NULL_ARG_CHECK(start_year); + CALENDAR_NULL_ARG_CHECK(start_month); + CALENDAR_NULL_ARG_CHECK(start_day); + CALENDAR_NULL_ARG_CHECK(end_year); + CALENDAR_NULL_ARG_CHECK(end_month); + CALENDAR_NULL_ARG_CHECK(end_day); + + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } + *start_year = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_DTSTART_YEAR); + *start_month = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_DTSTART_MONTH); + *start_day = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_DTSTART_MDAY); + *end_year = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_DTEND_YEAR); + *end_month = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_DTEND_MONTH); + *end_day = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_DTEND_MDAY); + return CALENDAR_ERROR_NONE; - } +} int calendar_event_get_location(calendar_event_h event, char **location) -{ +{ CALENDAR_NULL_ARG_CHECK(event); CALENDAR_NULL_ARG_CHECK(location); - *location = NULL; - *location = _calendar_safe_strdup(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)event)->event_legacy, - CAL_VALUE_TXT_LOCATION)); - - return CALENDAR_ERROR_NONE; + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + *location = _calendar_safe_strdup( + calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_LOCATION) ); + + return CALENDAR_ERROR_NONE; } int calendar_event_set_location(calendar_event_h event, const char *location) -{ - int ret_val = CALENDAR_ERROR_NONE; - +{ CALENDAR_NULL_ARG_CHECK(event); + CALENDAR_NULL_ARG_CHECK(location); - ret_val = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)event)->event_legacy, - CAL_VALUE_TXT_LOCATION, location); - - if (ret_val != CAL_SUCCESS) - { - LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + int ret; + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } - return CALENDAR_ERROR_NONE; + ret = calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_LOCATION, location); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + return CALENDAR_ERROR_NONE; +} + + +int _get_svc_reminder_interval_type(calendar_reminder_interval_type_e reminder_interval_type) +{ + switch (reminder_interval_type) { + case CALENDAR_REMINDER_NONE: + return CAL_SCH_TIME_UNIT_OFF; + case CALENDAR_REMINDER_TIME_UNIT_MINUTE: + return CAL_SCH_TIME_UNIT_MIN; + case CALENDAR_REMINDER_TIME_UNIT_HOUR: + return CAL_SCH_TIME_UNIT_HOUR; + case CALENDAR_REMINDER_TIME_UNIT_DAY: + return CAL_SCH_TIME_UNIT_DAY; + case CALENDAR_REMINDER_TIME_UNIT_WEEK: + return CAL_SCH_TIME_UNIT_WEEK; + case CALENDAR_REMINDER_TIME_UNIT_MONTH: + return CAL_SCH_TIME_UNIT_MONTH; + } + return CAL_SCH_TIME_UNIT_OFF; +} + +calendar_reminder_interval_type_e _set_svc_reminder_interval_type(int svc_reminder_interval_type) +{ + switch (svc_reminder_interval_type) { + case CAL_SCH_TIME_UNIT_OFF: + return CALENDAR_REMINDER_NONE; + case CAL_SCH_TIME_UNIT_MIN: + return CALENDAR_REMINDER_TIME_UNIT_MINUTE; + case CAL_SCH_TIME_UNIT_HOUR: + return CALENDAR_REMINDER_TIME_UNIT_HOUR; + case CAL_SCH_TIME_UNIT_DAY: + return CALENDAR_REMINDER_TIME_UNIT_DAY; + case CAL_SCH_TIME_UNIT_WEEK: + return CALENDAR_REMINDER_TIME_UNIT_WEEK; + case CAL_SCH_TIME_UNIT_MONTH: + return CALENDAR_REMINDER_TIME_UNIT_MONTH; + } + return CALENDAR_REMINDER_NONE; } int calendar_event_get_reminder(calendar_event_h event,calendar_reminder_interval_type_e *reminder_interval_type, int *reminder_interval) @@ -366,21 +1392,29 @@ int calendar_event_get_reminder(calendar_event_h event,calendar_reminder_interva CALENDAR_NULL_ARG_CHECK(reminder_interval_type); CALENDAR_NULL_ARG_CHECK(reminder_interval); - GList* list = NULL; - if(calendar_svc_struct_get_list((cal_struct*)((calendar_event_s*)event)->event_legacy, - CAL_VALUE_LST_ALARM, &list) != CAL_SUCCESS) { - LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + GList *alarm_list; + int r; + int svc_reminder_interval_type; + + r = calendar_svc_struct_get_list((cal_struct*)((calendar_event_s*)event)->event_legacy, + CAL_VALUE_LST_ALARM, &alarm_list); + if (r < CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } - if (g_list_length(list) == 0) { - LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); - return CALENDAR_ERROR_INVALID_PARAMETER; + if (!alarm_list || !alarm_list->data) { + *reminder_interval_type = CALENDAR_REMINDER_NONE; + *reminder_interval = 0; + return CALENDAR_ERROR_NONE; } - cal_value *value = (cal_value *)list->data; - *reminder_interval_type = calendar_svc_value_get_int(value, CAL_VALUE_INT_ALARMS_TICK_UNIT); - *reminder_interval = calendar_svc_value_get_int(value, CAL_VALUE_INT_ALARMS_TICK); + svc_reminder_interval_type = calendar_svc_value_get_int(alarm_list->data, + CAL_VALUE_INT_ALARMS_TICK_UNIT); + *reminder_interval_type = _set_svc_reminder_interval_type(svc_reminder_interval_type); + *reminder_interval = calendar_svc_value_get_int(alarm_list->data, + CAL_VALUE_INT_ALARMS_TICK); return CALENDAR_ERROR_NONE; } @@ -389,31 +1423,56 @@ int calendar_event_set_reminder(calendar_event_h event,calendar_reminder_interva { CALENDAR_NULL_ARG_CHECK(event); - cal_value *value = calendar_svc_value_new(CAL_VALUE_LST_ALARM); - if(calendar_svc_value_set_int(value, CAL_VALUE_INT_ALARMS_TICK_UNIT, reminder_interval_type) != CAL_SUCCESS) { + int ret; + int svc_reminder_interval_type; + cal_struct *cs; + cal_value *value; + GList* list = NULL; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + value = calendar_svc_value_new(CAL_VALUE_LST_ALARM); + if (value == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + svc_reminder_interval_type = _get_svc_reminder_interval_type(reminder_interval_type); + + ret = calendar_svc_value_set_int(value, + CAL_VALUE_INT_ALARMS_TICK_UNIT, svc_reminder_interval_type); + if (ret != CAL_SUCCESS) { calendar_svc_value_free(&value); - LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } - if(calendar_svc_value_set_int(value, CAL_VALUE_INT_ALARMS_TICK, reminder_interval) != CAL_SUCCESS) { + ret = calendar_svc_value_set_int(value, CAL_VALUE_INT_ALARMS_TICK, reminder_interval); + if (ret != CAL_SUCCESS) { calendar_svc_value_free(&value); - LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } - GList* list = NULL; - calendar_svc_struct_store_list((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_LST_ALARM, NULL); + calendar_svc_struct_store_list(cs, CAL_VALUE_LST_ALARM, NULL); list = g_list_append(list, value); - if(calendar_svc_struct_store_list((cal_struct*)((calendar_event_s*)event)->event_legacy, - CAL_VALUE_LST_ALARM, list) != CAL_SUCCESS) { + ret = calendar_svc_struct_store_list(cs, CAL_VALUE_LST_ALARM, list); + if (ret != CAL_SUCCESS) { calendar_svc_value_free(&value); g_list_free(list); - LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } - return CALENDAR_ERROR_NONE; } @@ -422,382 +1481,268 @@ int calendar_event_get_recurrence_frequency(calendar_event_h event,calendar_recu CALENDAR_NULL_ARG_CHECK(event); CALENDAR_NULL_ARG_CHECK(recurrence_frequency); - *recurrence_frequency = (calendar_recurrence_frequency_e)calendar_svc_struct_get_int( - (cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_INT_REPEAT_TERM); + int freq; + cal_struct *cs; + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + freq = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_RRULE_FREQ); + switch (freq) { + case CALS_FREQ_ONCE: + *recurrence_frequency = CALENDAR_RECURRENCE_NONE; + break; + case CALS_FREQ_YEARLY: + *recurrence_frequency = CALENDAR_RECURRENCE_YEARLY; + break; + case CALS_FREQ_MONTHLY: + *recurrence_frequency = CALENDAR_RECURRENCE_MONTHLY; + break; + case CALS_FREQ_WEEKLY: + *recurrence_frequency = CALENDAR_RECURRENCE_WEEKLY; + break; + case CALS_FREQ_DAILY: + *recurrence_frequency = CALENDAR_RECURRENCE_DAILY; + break; + } return CALENDAR_ERROR_NONE; } int calendar_event_set_recurrence_frequency(calendar_event_h event,calendar_recurrence_frequency_e recurrence_frequency) { - int ret_val = CALENDAR_ERROR_NONE; - CALENDAR_NULL_ARG_CHECK(event); - calendar_event_legacy_s* event_legacy = ((calendar_event_s*)event)->event_legacy; - ret_val = calendar_svc_struct_set_int((cal_struct*)event_legacy, CAL_VALUE_INT_REPEAT_TERM, recurrence_frequency); - switch(recurrence_frequency) - { + int ret; + int freq = CALS_FREQ_ONCE; + cal_struct *cs; + + switch (recurrence_frequency) { + case CALENDAR_RECURRENCE_NONE: + freq = CALS_FREQ_ONCE; + break; case CALENDAR_RECURRENCE_DAILY: - ret_val = calendar_svc_struct_set_int((cal_struct*)event_legacy, CAL_VALUE_INT_REPEAT_INTERVAL, 1); + freq = CALS_FREQ_DAILY; break; case CALENDAR_RECURRENCE_WEEKLY: - ret_val = calendar_svc_struct_set_int((cal_struct*)event_legacy, CAL_VALUE_INT_REPEAT_INTERVAL, 1); - break; -// case CALENDAR_RECURRENCE_WEEKDAY: -// ret_val = calendar_svc_struct_set_int((cal_struct*)event_legacy, CAL_VALUE_INT_REPEAT_INTERVAL, 1); -// break; - case CALENDAR_RECURRENCE_NONE: - ret_val = calendar_svc_struct_set_int((cal_struct*)event_legacy, CAL_VALUE_INT_REPEAT_INTERVAL, 1); + freq = CALS_FREQ_WEEKLY; break; case CALENDAR_RECURRENCE_MONTHLY: + freq = CALS_FREQ_MONTHLY; + break; case CALENDAR_RECURRENCE_YEARLY: -// case CALENDAR_RECURRENCE_MONTHLY_ON_DAY: - ret_val = calendar_svc_struct_set_int((cal_struct*)event_legacy, CAL_VALUE_INT_REPEAT_INTERVAL, 1); + freq = CALS_FREQ_YEARLY; + break; + default: + freq = CALS_FREQ_ONCE; break; } - if (ret_val != CAL_SUCCESS) - { - LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + ret = calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_FREQ, freq); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } return CALENDAR_ERROR_NONE; } -int calendar_event_get_recurrence_week_flag(calendar_event_h event, int *week_flag) +int calendar_event_get_recurrence_until_date(calendar_event_h event, long long int *recurrence_until_date) { CALENDAR_NULL_ARG_CHECK(event); - CALENDAR_NULL_ARG_CHECK(week_flag); - - char* week_flag_string = calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_TXT_WEEK_FLAG); - - if(week_flag_string == NULL) { - *week_flag = 0; - return CALENDAR_ERROR_NONE; - } - - *week_flag = CALENDAR_WEEK_FLAG_NONE; - if(week_flag_string[0] == '1') - *week_flag = *week_flag | CALENDAR_WEEK_FLAG_SUN; - if(week_flag_string[1] == '1') - *week_flag = *week_flag | CALENDAR_WEEK_FLAG_MON; - if(week_flag_string[2] == '1') - *week_flag = *week_flag | CALENDAR_WEEK_FLAG_TUE; - if(week_flag_string[3] == '1') - *week_flag = *week_flag | CALENDAR_WEEK_FLAG_WED; - if(week_flag_string[4] == '1') - *week_flag = *week_flag | CALENDAR_WEEK_FLAG_THU; - if(week_flag_string[5] == '1') - *week_flag = *week_flag | CALENDAR_WEEK_FLAG_FRI; - if(week_flag_string[6] == '1') - *week_flag = *week_flag | CALENDAR_WEEK_FLAG_SAT; - - return CALENDAR_ERROR_NONE; -} - -int calendar_event_set_recurrence_week_flag(calendar_event_h event, int week_flag) -{ - CALENDAR_NULL_ARG_CHECK(event); - - char week_flag_string[8]; // never overflows - if(week_flag & CALENDAR_WEEK_FLAG_SUN) week_flag_string[0] = '1'; - else week_flag_string[0] = '0'; - if(week_flag & CALENDAR_WEEK_FLAG_MON) week_flag_string[1] = '1'; - else week_flag_string[1] = '0'; - if(week_flag & CALENDAR_WEEK_FLAG_TUE) week_flag_string[2] = '1'; - else week_flag_string[2] = '0'; - if(week_flag & CALENDAR_WEEK_FLAG_WED) week_flag_string[3] = '1'; - else week_flag_string[3] = '0'; - if(week_flag & CALENDAR_WEEK_FLAG_THU) week_flag_string[4] = '1'; - else week_flag_string[4] = '0'; - if(week_flag & CALENDAR_WEEK_FLAG_FRI) week_flag_string[5] = '1'; - else week_flag_string[5] = '0'; - if(week_flag & CALENDAR_WEEK_FLAG_SAT) week_flag_string[6] = '1'; - else week_flag_string[6] = '0'; - week_flag_string[7] = 0x00; - - calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_TXT_WEEK_FLAG, week_flag_string); //days in which recurrence should be activated - - return CALENDAR_ERROR_NONE; -} - - -int calendar_event_get_recurrence_until_date(calendar_event_h event, struct tm *recurrence_until_date) -{ - time_t time; - struct tm *tmp_date = NULL; - - CALENDAR_NULL_ARG_CHECK(event); CALENDAR_NULL_ARG_CHECK(recurrence_until_date); - time = calendar_svc_struct_get_time((cal_struct*)((calendar_event_s*)event)->event_legacy, - CAL_VALUE_GMT_REPEAT_END_DATE, CAL_TZ_FLAG_LOCAL); - - if(time == 0) { - LOGE("[%s] CALENDAR_ERROR_NO_DATA(0x%08x)", __FUNCTION__, CALENDAR_ERROR_NO_DATA); - return CALENDAR_ERROR_NO_DATA; - } - - tmp_date = localtime(&time); - - if (tmp_date == NULL) { - return CALENDAR_ERROR_NO_DATA; - } - - *recurrence_until_date = *tmp_date; - - return CALENDAR_ERROR_NONE; -} - -int calendar_event_set_recurrence_until_date(calendar_event_h event, struct tm recurrence_until_date) -{ - int ret_val = CALENDAR_ERROR_NONE; + long long int lli; + cal_struct *cs; - CALENDAR_NULL_ARG_CHECK(event); - - ret_val = calendar_svc_struct_set_time((cal_struct*)((calendar_event_s*)event)->event_legacy, - CAL_VALUE_GMT_REPEAT_END_DATE, CAL_TZ_FLAG_LOCAL, mktime(&recurrence_until_date)); - - if (ret_val != CAL_SUCCESS) { - LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); - return CALENDAR_ERROR_INVALID_PARAMETER; + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; } - return CALENDAR_ERROR_NONE; -} - -int calendar_event_add_recurrence_exception_date(calendar_event_h event, int year, int month, int day) -{ - CALENDAR_NULL_ARG_CHECK(event); - - int ret_val = CALENDAR_ERROR_NONE; - GList* exception_list = NULL; - struct tm date = {0}; - date.tm_year = year - 1900; - date.tm_mon = month - 1; - date.tm_mday = day; - - cal_value *value = calendar_svc_value_new(CAL_VALUE_LST_EXCEPTION_DATE); - if(value == NULL) { - LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY); - return CALENDAR_ERROR_OUT_OF_MEMORY; + lli = calendar_svc_struct_get_lli(cs, CALS_VALUE_LLI_RRULE_UNTIL_UTIME); + if (lli == CALS_TODO_NO_DUE_DATE) { + return CALENDAR_ERROR_NO_DATA; } - calendar_svc_value_set_tm(value, CAL_VALUE_GMT_EXCEPTION_DATE_TIME, CAL_TZ_FLAG_LOCAL, &date); - - //get attendee list firstly - calendar_svc_struct_get_list((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_LST_EXCEPTION_DATE, &exception_list); - exception_list = g_list_append(exception_list, value); - ret_val = calendar_svc_struct_store_list((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_LST_EXCEPTION_DATE, exception_list); - - return CALENDAR_ERROR_NONE; + + *recurrence_until_date = lli; + return CALENDAR_ERROR_NONE; } -int calendar_event_get_recurrence_exception_iterator(calendar_event_h event, calendar_recurrence_exception_iterator_h *iterator) +int calendar_event_set_recurrence_until_date(calendar_event_h event, long long int recurrence_until_date) { - CALENDAR_NULL_ARG_CHECK(event); - CALENDAR_NULL_ARG_CHECK(iterator); - - GList* exception_list = NULL; - //get attendee list first - calendar_svc_struct_get_list((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_LST_EXCEPTION_DATE, &exception_list); - *iterator = (calendar_recurrence_exception_iterator_h)exception_list; + CALENDAR_NULL_ARG_CHECK(event); - return CALENDAR_ERROR_NONE; -} + int ret = CALENDAR_ERROR_NONE; + cal_struct *cs; -bool calendar_recurrence_exception_has_next(calendar_recurrence_exception_iterator_h iterator) -{ - CALENDAR_NULL_ARG_CHECK(iterator); - if(iterator == NULL) { - return false; + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; } - GList* glist = (GList*)iterator; - cal_value* value = (cal_value*)glist->data; - if(value == NULL) { - return false; - } - glist = _calendar_glist_next_until_not_deleted(glist); - if(glist == NULL) { - return false; + calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_RANGE_TYPE, CALS_RANGE_UNTIL); + calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_UNTIL_TYPE, CALS_TIME_UTIME); + ret = calendar_svc_struct_set_lli(cs, + CALS_VALUE_LLI_RRULE_UNTIL_UTIME, recurrence_until_date); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; } - - return true; + return CALENDAR_ERROR_NONE; } -int calendar_recurrence_exception_next(calendar_recurrence_exception_iterator_h *iterator, int* year, int* month, int* day) +int calendar_event_get_start_time(calendar_event_h event, long long int *start_time) { - CALENDAR_NULL_ARG_CHECK(iterator); - CALENDAR_NULL_ARG_CHECK(year); - CALENDAR_NULL_ARG_CHECK(month); - CALENDAR_NULL_ARG_CHECK(day); - - cal_value *value = NULL; - *year = 0; - *month = 0; - *day = 0; - GList* glist = (GList*)*iterator; - glist = _calendar_glist_next_until_not_deleted(glist); - if(glist != NULL) - { - value = glist->data; - struct tm *date = calendar_svc_value_get_tm(value, CAL_VALUE_GMT_EXCEPTION_DATE_TIME, CAL_TZ_FLAG_LOCAL); - *year = date->tm_year + 1900; - *month = date->tm_mon + 1; - *day = date->tm_mday; - glist = g_list_next(glist); - *iterator = (calendar_recurrence_exception_iterator_h)glist; - return CALENDAR_ERROR_NONE; - } - *iterator = NULL; - return CALENDAR_ERROR_ITERATOR_END; -} - -int calendar_event_get_start_time(calendar_event_h event, struct tm *start_time) -{ - time_t time; - struct tm *tmp_date = NULL; CALENDAR_NULL_ARG_CHECK(event); CALENDAR_NULL_ARG_CHECK(start_time); - time = calendar_svc_struct_get_time((cal_struct*)((calendar_event_s*)event)->event_legacy, - CAL_VALUE_GMT_START_DATE_TIME, CAL_TZ_FLAG_LOCAL); - - if(time == 0) { - LOGE("[%s] CALENDAR_ERROR_NO_DATA(0x%08x)", __FUNCTION__, CALENDAR_ERROR_NO_DATA); - return CALENDAR_ERROR_NO_DATA; - } - - tmp_date = localtime(&time); - - if (tmp_date == NULL) { - LOGE("[%s] CALENDAR_ERROR_NO_DATA(0x%08x)", __FUNCTION__, CALENDAR_ERROR_NO_DATA); - return CALENDAR_ERROR_NO_DATA; - } + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } - *start_time = *tmp_date; + *start_time = calendar_svc_struct_get_lli(cs, CALS_VALUE_LLI_DTSTART_UTIME); - return CALENDAR_ERROR_NONE; + return CALENDAR_ERROR_NONE; } -int calendar_event_set_start_time(calendar_event_h event, struct tm start_time) -{ - int ret_val = CALENDAR_ERROR_NONE; - +int calendar_event_set_start_time(calendar_event_h event, long long int start_time) +{ CALENDAR_NULL_ARG_CHECK(event); - ret_val = calendar_svc_struct_set_time((cal_struct*)((calendar_event_s*)event)->event_legacy, - CAL_VALUE_GMT_START_DATE_TIME, CAL_TZ_FLAG_LOCAL, mktime(&start_time)); + int ret; + cal_struct *cs; - if (ret_val != CAL_SUCCESS) - { - LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); - return CALENDAR_ERROR_INVALID_PARAMETER; + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; } - return CALENDAR_ERROR_NONE; -} + ret = calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTSTART_TYPE, CALS_TIME_UTIME); + ret = calendar_svc_struct_set_lli(cs, + CALS_VALUE_LLI_DTSTART_UTIME, start_time); -int calendar_event_get_end_time(calendar_event_h event, struct tm *end_time) -{ - time_t time; - struct tm *tmp_date = NULL; + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + return CALENDAR_ERROR_NONE; +} +int calendar_event_get_end_time(calendar_event_h event, long long int *end_time) +{ CALENDAR_NULL_ARG_CHECK(event); CALENDAR_NULL_ARG_CHECK(end_time); - time = calendar_svc_struct_get_time((cal_struct*)((calendar_event_s*)event)->event_legacy, - CAL_VALUE_GMT_END_DATE_TIME, CAL_TZ_FLAG_LOCAL); + cal_struct *cs; - if(time == 0) { - LOGE("[%s] CALENDAR_ERROR_NO_DATA(0x%08x)", __FUNCTION__, CALENDAR_ERROR_NO_DATA); - return CALENDAR_ERROR_NO_DATA; - } - - tmp_date = localtime(&time); - - if (tmp_date == NULL) { - LOGE("[%s] CALENDAR_ERROR_NO_DATA(0x%08x)", __FUNCTION__, CALENDAR_ERROR_NO_DATA); - return CALENDAR_ERROR_NO_DATA; - } + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } - *end_time = *tmp_date; + *end_time = calendar_svc_struct_get_lli(cs, CALS_VALUE_LLI_DTEND_UTIME); - return CALENDAR_ERROR_NONE; + return CALENDAR_ERROR_NONE; } -int calendar_event_set_end_time(calendar_event_h event, struct tm end_time) -{ - int ret_val = CALENDAR_ERROR_NONE; +int calendar_event_set_end_time(calendar_event_h event, long long int end_time) +{ CALENDAR_NULL_ARG_CHECK(event); - ret_val = calendar_svc_struct_set_time((cal_struct*)((calendar_event_s*)event)->event_legacy, - CAL_VALUE_GMT_END_DATE_TIME, CAL_TZ_FLAG_LOCAL, mktime(&end_time)); - - if (ret_val != CAL_SUCCESS) - { - LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + int ret; + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } - return CALENDAR_ERROR_NONE; + ret = calendar_svc_struct_set_lli(cs, CALS_VALUE_LLI_DTEND_UTIME, end_time); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + return CALENDAR_ERROR_NONE; } int calendar_attendee_get_name(calendar_attendee_h attendee, char **name) -{ +{ CALENDAR_NULL_ARG_CHECK(attendee); CALENDAR_NULL_ARG_CHECK(name); - *name = NULL; *name = _calendar_safe_strdup(calendar_svc_value_get_str((cal_value*)attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME)); - return CALENDAR_ERROR_NONE; + return CALENDAR_ERROR_NONE; } int calendar_attendee_set_name(calendar_attendee_h attendee, const char *name) -{ - int ret_val = CALENDAR_ERROR_NONE; +{ + int ret = CALENDAR_ERROR_NONE; CALENDAR_NULL_ARG_CHECK(attendee); - ret_val = calendar_svc_value_set_str((cal_value*)attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME, name); - - if (ret_val != CAL_SUCCESS) - { - LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + ret = calendar_svc_value_set_str((cal_value*)attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME, name); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } - - return CALENDAR_ERROR_NONE; + return CALENDAR_ERROR_NONE; } int calendar_attendee_get_email(calendar_attendee_h attendee, char **email) -{ +{ CALENDAR_NULL_ARG_CHECK(attendee); CALENDAR_NULL_ARG_CHECK(email); - *email = NULL; - *email = _calendar_safe_strdup(calendar_svc_value_get_str((cal_value*)attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_EMAIL)); - - return CALENDAR_ERROR_NONE; + *email = _calendar_safe_strdup( + calendar_svc_value_get_str((cal_value*)attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_EMAIL)); + + return CALENDAR_ERROR_NONE; } int calendar_attendee_set_email(calendar_attendee_h attendee, const char *email) -{ - int ret_val = CALENDAR_ERROR_NONE; +{ + int ret = CALENDAR_ERROR_NONE; CALENDAR_NULL_ARG_CHECK(attendee); CALENDAR_NULL_ARG_CHECK(email); - ret_val = calendar_svc_value_set_str((cal_value*)attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_EMAIL, email); - - if (ret_val != CAL_SUCCESS) - { - LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + ret = calendar_svc_value_set_str((cal_value*)attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_EMAIL, email); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } - - return CALENDAR_ERROR_NONE; + return CALENDAR_ERROR_NONE; } int calendar_attendee_get_phone_number(calendar_attendee_h attendee, char **phone_number) @@ -805,27 +1750,26 @@ int calendar_attendee_get_phone_number(calendar_attendee_h attendee, char **phon CALENDAR_NULL_ARG_CHECK(attendee); CALENDAR_NULL_ARG_CHECK(phone_number); - *phone_number = NULL; *phone_number = _calendar_safe_strdup(calendar_svc_value_get_str((cal_value*)attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_NUMBER)); - return CALENDAR_ERROR_NONE; + return CALENDAR_ERROR_NONE; } int calendar_attendee_set_phone_number(calendar_attendee_h attendee, const char *phone_number) { - int ret_val = CALENDAR_ERROR_NONE; + int ret = CALENDAR_ERROR_NONE; CALENDAR_NULL_ARG_CHECK(attendee); CALENDAR_NULL_ARG_CHECK(phone_number); - ret_val = calendar_svc_value_set_str((cal_value*)attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_NUMBER, phone_number); - - if (ret_val != CAL_SUCCESS) + ret = calendar_svc_value_set_str((cal_value*)attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_NUMBER, phone_number); + + if (ret != CAL_SUCCESS) { LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } - return CALENDAR_ERROR_NONE; + return CALENDAR_ERROR_NONE; } int calendar_attendee_get_contact_db_id(calendar_attendee_h attendee, int *contact_db_id) @@ -837,64 +1781,73 @@ int calendar_attendee_get_contact_db_id(calendar_attendee_h attendee, int *conta *contact_db_id = calendar_svc_value_get_int((cal_value*)attendee, CAL_VALUE_INT_ATTENDEE_DETAIL_CT_INDEX); if(*contact_db_id <= 0) *contact_db_id = -1; - return CALENDAR_ERROR_NONE; + return CALENDAR_ERROR_NONE; } int calendar_attendee_set_contact_db_id(calendar_attendee_h attendee, int contact_db_id) { - int ret_val = CALENDAR_ERROR_NONE; CALENDAR_NULL_ARG_CHECK(attendee); - - ret_val = calendar_svc_value_set_int((cal_value*)attendee, CAL_VALUE_INT_ATTENDEE_DETAIL_CT_INDEX, contact_db_id); - if (ret_val != CAL_SUCCESS) + + int ret; + + ret = calendar_svc_value_set_int((cal_value*)attendee, CAL_VALUE_INT_ATTENDEE_DETAIL_CT_INDEX, contact_db_id); + if (ret != CAL_SUCCESS) { - LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } - return CALENDAR_ERROR_NONE; + return CALENDAR_ERROR_NONE; } - + int calendar_event_add_attendee(calendar_event_h event, calendar_attendee_h* attendee) { - int ret_val = CALENDAR_ERROR_NONE; - GList* attendee_list = NULL; - CALENDAR_NULL_ARG_CHECK(event); CALENDAR_NULL_ARG_CHECK(attendee); - *attendee = (calendar_attendee_h)calendar_svc_value_new(CAL_VALUE_LST_ATTENDEE_LIST); + int ret = CALENDAR_ERROR_NONE; + GList* attendee_list = NULL; + cal_struct *cs; - if (*attendee == NULL) - { - LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY); + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + *attendee = (calendar_attendee_h)calendar_svc_value_new(CAL_VALUE_LST_ATTENDEE_LIST); + if (*attendee == NULL) { + LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY); return CALENDAR_ERROR_OUT_OF_MEMORY; } //get attendee list first - calendar_svc_struct_get_list((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_LST_ATTENDEE_LIST, &attendee_list); + calendar_svc_struct_get_list(cs, CAL_VALUE_LST_ATTENDEE_LIST, &attendee_list); attendee_list = g_list_append(attendee_list, *attendee); - ret_val = calendar_svc_struct_store_list((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_LST_ATTENDEE_LIST, attendee_list); - - return CALENDAR_ERROR_NONE; + ret = calendar_svc_struct_store_list(cs, CAL_VALUE_LST_ATTENDEE_LIST, attendee_list); + + return CALENDAR_ERROR_NONE; } int calendar_event_add_attendee_with_contact(calendar_event_h event, int contact_db_id, calendar_attendee_h* attendee) { - int ret_val = CALENDAR_ERROR_NONE; + int ret = CALENDAR_ERROR_NONE; contact_h contact = NULL; if(contact_get_from_db(contact_db_id, &contact) != CONTACTS_ERROR_NONE) { LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } - if((ret_val = calendar_event_add_attendee(event, attendee)) != CALENDAR_ERROR_NONE) + if((ret = calendar_event_add_attendee(event, attendee)) != CALENDAR_ERROR_NONE) { LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY); return CALENDAR_ERROR_OUT_OF_MEMORY; } calendar_attendee_set_contact_db_id(*attendee, contact_db_id); - + contact_name_h name = NULL; if(contact_get_name(contact, &name) == CONTACTS_ERROR_NONE) { char *first_name = NULL; @@ -927,20 +1880,20 @@ int calendar_event_add_attendee_with_contact(calendar_event_h event, int contact _calendar_safe_free(number_string); } } - + contact_destroy(contact); - - return CALENDAR_ERROR_NONE; + + return CALENDAR_ERROR_NONE; } int calendar_event_remove_attendee(calendar_event_h event, calendar_attendee_h attendee) -{ +{ CALENDAR_NULL_ARG_CHECK(event); CALENDAR_NULL_ARG_CHECK(attendee); - calendar_svc_value_set_int((cal_value*)attendee, CAL_VALUE_INT_DETAIL_DELETE, 1); - - return CALENDAR_ERROR_NONE; + calendar_svc_value_set_int((cal_value*)attendee, CAL_VALUE_INT_DETAIL_DELETE, 1); + + return CALENDAR_ERROR_NONE; } int calendar_event_get_attendee_iterator(calendar_event_h event, calendar_attendee_iterator_h *iterator) @@ -953,11 +1906,11 @@ int calendar_event_get_attendee_iterator(calendar_event_h event, calendar_attend //get attendee list first calendar_svc_struct_get_list((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_LST_ATTENDEE_LIST, &attendee_list); *iterator = (calendar_attendee_iterator_h)attendee_list; - return CALENDAR_ERROR_NONE; + return CALENDAR_ERROR_NONE; } bool calendar_attendee_iterator_has_next(calendar_attendee_iterator_h iterator) -{ +{ if(iterator == NULL) { return false; } @@ -976,7 +1929,7 @@ bool calendar_attendee_iterator_has_next(calendar_attendee_iterator_h iterator) } int calendar_attendee_iterator_next(calendar_attendee_iterator_h *iterator, calendar_attendee_h *attendee) -{ +{ CALENDAR_NULL_ARG_CHECK(iterator); CALENDAR_NULL_ARG_CHECK(attendee); @@ -988,137 +1941,324 @@ int calendar_attendee_iterator_next(calendar_attendee_iterator_h *iterator, cale *attendee = (calendar_attendee_h)(glist)->data; glist = g_list_next(glist); *iterator = (calendar_attendee_iterator_h)glist; - return CALENDAR_ERROR_NONE; + return CALENDAR_ERROR_NONE; } *iterator = NULL; return CALENDAR_ERROR_ITERATOR_END; } -//Provide iterator instead of event -int calendar_foreach_event_from_db(calendar_foreach_query_event_cb callback, void *user_data) -{ - CALENDAR_NULL_ARG_CHECK(callback); - return _calendar_event_foreach(callback, ALL_ACCOUNT_ID, ALL_CALENDAR_ID, user_data); +int calendar_event_free_event_array(calendar_event_h *event_array) +{ + int i; + CALENDAR_NULL_ARG_CHECK(event_array); + + for (i = 0; event_array[i]; i++) { + calendar_event_destroy(event_array[i]); + } + free(event_array); + return CALENDAR_ERROR_NONE; } -int calendar_query_event_by_calendar(calendar_foreach_query_event_cb callback, int calendar_db_id, void *user_data) +int calendar_event_free_modified_event_array(pcalendar_modified_event_s *modified_event_array) { - CALENDAR_NULL_ARG_CHECK(callback); - CONTACTS_INVALID_ARG_CHECK(calendar_db_id < 1); - int account_db_id = _calendar_get_account_db_id(calendar_db_id); - CONTACTS_INVALID_ARG_CHECK(account_db_id == -2); - - return _calendar_event_foreach(callback, account_db_id, calendar_db_id, user_data); + CALENDAR_NULL_ARG_CHECK(modified_event_array); + + int i = 0; + pcalendar_modified_event_s *p; + + p = modified_event_array; + + if (p) { + while (p[i]) { + free(p[i]); + i++; + } + free(p); + } + + return CALENDAR_ERROR_NONE; } -int calendar_query_event_by_subject(calendar_foreach_query_event_cb callback, int calendar_db_id, const char *subject_to_find, void* user_data) +void __free_event_data(gpointer data, gpointer user_data) { - CALENDAR_NULL_ARG_CHECK(callback); - CALENDAR_NULL_ARG_CHECK(subject_to_find); - return _calendar_event_query(callback, calendar_db_id, CAL_VALUE_TXT_SUMMARY, subject_to_find, user_data); + if (data) { + calendar_event_h *event = (calendar_event_h *)data; + if (event) free(event); + } } -int calendar_query_event_by_description(calendar_foreach_query_event_cb callback, int calendar_db_id, const char *description_to_find, void* user_data) +static calendar_error_e _get_h_array_from_legacy_iter(const char fn[], + cal_iter* iter, calendar_event_h **event_h_array, int *length) { - CALENDAR_NULL_ARG_CHECK(callback); - CALENDAR_NULL_ARG_CHECK(description_to_find); - return _calendar_event_query(callback, calendar_db_id, CAL_VALUE_TXT_DESCRIPTION, description_to_find, user_data); + int i; + int is_error = 0; + cal_struct *cs = NULL; + calendar_event_s *ce; + GList *cursor; + GList *l = NULL; + + if (iter == NULL) { + LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", + fn, CALENDAR_ERROR_DB_FAILED); + return CALENDAR_ERROR_DB_FAILED; + } + + while (calendar_svc_iter_next(iter) == CAL_SUCCESS) + { + if(calendar_svc_iter_get_info(iter, &cs) != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", + fn, CALENDAR_ERROR_OUT_OF_MEMORY); + is_error = 1; + break; + } + + ce = calloc(1, sizeof(calendar_event_s)); + if (ce == NULL) { + LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", + fn, CALENDAR_ERROR_OUT_OF_MEMORY); + is_error = 1; + } + + ce->event_legacy = (calendar_event_legacy_s *)cs; + l = g_list_append(l, ce); + cs = NULL; + } + calendar_svc_iter_remove(&iter); + + if (is_error) { + g_list_foreach(l, __free_event_data, NULL); + g_list_free(l); + return CALENDAR_ERROR_OUT_OF_MEMORY; + } + + /* malloc array and fill data */ + *length = g_list_length(l); + + /* plus 1 to fill null pointer*/ + calendar_event_h *p = calloc(*length + 1, sizeof(calendar_event_h)); + if (p == NULL) { + LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", + fn,CALENDAR_ERROR_OUT_OF_MEMORY); + g_list_foreach(l, __free_event_data, NULL); + g_list_free(l); + return CALENDAR_ERROR_OUT_OF_MEMORY; + } + + cursor = l; + for (i = 0; cursor; i++) { + p[i] = (calendar_event_h)cursor->data; + cursor = g_list_next(cursor); + } + g_list_free(l); + + /* fill NULL pointer to indicate end of array */ + p[i] = NULL; + *event_h_array = p; + + return CALENDAR_ERROR_NONE; } -int calendar_query_event_by_location(calendar_foreach_query_event_cb callback, int calendar_db_id, const char *location_to_find, void* user_data) +static calendar_error_e _get_count_from_legacy_iter(const char fn[], + cal_iter* iter, int *count) { - CALENDAR_NULL_ARG_CHECK(callback); - CALENDAR_NULL_ARG_CHECK(location_to_find); - return _calendar_event_query(callback, calendar_db_id, CAL_VALUE_TXT_LOCATION, location_to_find, user_data); + int is_error = 0; + cal_struct *cs = NULL; + calendar_event_s *ce; + GList *l = NULL; + + if (iter == NULL) { + LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", + fn, CALENDAR_ERROR_DB_FAILED); + return CALENDAR_ERROR_DB_FAILED; + } + + while (calendar_svc_iter_next(iter) == CAL_SUCCESS) + { + if(calendar_svc_iter_get_info(iter, &cs) != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", + fn, CALENDAR_ERROR_OUT_OF_MEMORY); + is_error = 1; + break; + } + + ce = calloc(1, sizeof(calendar_event_s)); + if (ce == NULL) { + LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", + fn, CALENDAR_ERROR_OUT_OF_MEMORY); + is_error = 1; + } + + ce->event_legacy = (calendar_event_legacy_s *)cs; + l = g_list_append(l, ce); + cs = NULL; + } + calendar_svc_iter_remove(&iter); + + if (is_error) { + g_list_foreach(l, __free_event_data, NULL); + g_list_free(l); + return CALENDAR_ERROR_OUT_OF_MEMORY; + } + + *count = g_list_length(l); + + g_list_free(l); + + return CALENDAR_ERROR_NONE; } -int calendar_query_event_by_period(calendar_foreach_query_event_cb callback, int calendar_db_id, struct tm start_time, struct tm end_time, void* user_data) +int calendar_event_search_event_by_calendar_book(int calendar_book_db_id, calendar_event_h **event_array, int *length) { - CALENDAR_NULL_ARG_CHECK(callback); - int ret_val = 0; - cal_iter* iter = NULL; - bool callback_return = true; - - int account_id = _calendar_get_account_db_id(calendar_db_id); - CONTACTS_INVALID_ARG_CHECK(account_id == -2); - - //fetch from DB - ret_val = calendar_svc_get_event_list_by_tm_period (account_id, calendar_db_id, &start_time, &end_time, &iter); + CALENDAR_NULL_ARG_CHECK(event_array); + CALENDAR_NULL_ARG_CHECK(length); - if (ret_val != CAL_SUCCESS) { - LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); - return CALENDAR_ERROR_DB_FAILED; + int ret; + cal_iter *iter = NULL; + + ret = calendar_svc_get_all(0, calendar_book_db_id, CAL_STRUCT_SCHEDULE, &iter); + if (CAL_SUCCESS != ret) { + LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_DB_FAILED); + return CALENDAR_ERROR_DB_FAILED; } - - if (iter == NULL) { - LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); - return CALENDAR_ERROR_DB_FAILED; - } else { - while (calendar_svc_iter_next(iter) == CAL_SUCCESS) - { - calendar_event_s cal_event_from_db = {0,}; - if(calendar_svc_iter_get_info(iter, (cal_struct**)&cal_event_from_db.event_legacy) != CAL_SUCCESS) { - calendar_svc_iter_remove(&iter); - return CALENDAR_ERROR_NONE; // consider this as no data - } - - if(cal_event_from_db.event_legacy == NULL) { - calendar_svc_iter_remove(&iter); - break; - } - - //execute callback - callback_return = callback((calendar_event_h)&cal_event_from_db, user_data); - calendar_svc_struct_free((cal_struct**)&cal_event_from_db.event_legacy); - if(callback_return == false) { - break; - } - } - calendar_svc_iter_remove(&iter); + if ((ret = _get_h_array_from_legacy_iter(__FUNCTION__, iter, event_array, length)) + != CALENDAR_ERROR_NONE) + return ret; - return CALENDAR_ERROR_NONE; - } + return CALENDAR_ERROR_NONE; +} + +int calendar_event_search_extend_instance_by_period(int calendar_book_db_id, + long long int period_start_time, long long int period_end_time, + calendar_event_h **event_array, int *length) +{ + CALENDAR_NULL_ARG_CHECK(event_array); + CALENDAR_NULL_ARG_CHECK(length); + + cal_iter *iter = NULL; + int ret = calendar_svc_event_get_normal_list_by_period(calendar_book_db_id, + CALS_LIST_PERIOD_NORMAL_OSP, + period_start_time, period_end_time, &iter); + if (CAL_SUCCESS != ret) { + LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_DB_FAILED); + return CALENDAR_ERROR_DB_FAILED; + } + + if ((ret = _get_h_array_from_legacy_iter(__FUNCTION__, iter, event_array, length)) + != CALENDAR_ERROR_NONE) + return ret; return CALENDAR_ERROR_NONE; } -int calendar_set_db_changed_cb(calendar_db_changed_cb callback, void* user_data) +int calendar_event_search_all_day_extend_instance_by_period(int calendar_book_db_id, + int period_start_year, int period_start_month, int period_start_day, + int period_end_year, int period_end_month, int period_end_day, + calendar_event_h **event_array, int *length) { + CALENDAR_NULL_ARG_CHECK(event_array); + CALENDAR_NULL_ARG_CHECK(length); + + cal_iter *iter = NULL; + int ret = calendar_svc_event_get_allday_list_by_period(calendar_book_db_id, CALS_LIST_PERIOD_ALLDAY_OSP, + period_start_year, period_start_month, period_start_day, + period_end_year, period_end_month, period_end_day, &iter); + if (CAL_SUCCESS != ret) { + LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_DB_FAILED); + return CALENDAR_ERROR_DB_FAILED; + } + + if ((ret = _get_h_array_from_legacy_iter(__FUNCTION__, iter, event_array, length)) + != CALENDAR_ERROR_NONE) + return ret; + + return CALENDAR_ERROR_NONE; +} + +int calendar_add_db_changed_cb(calendar_db_changed_cb callback, calendar_db_changed_cb_type_e type, void* user_data) +{ + int ret; CALENDAR_NULL_ARG_CHECK(callback); - if(calendar_svc_subscribe_change(callback, user_data) == CAL_SUCCESS) { + + switch(type) { + case CALENDAR_DB_CHANGED_CB_TYPE_CALENDAR_BOOK: + ret = calendar_svc_subscribe_db_change(CAL_STRUCT_CALENDAR, callback, user_data); + break; + case CALENDAR_DB_CHANGED_CB_TYPE_EVENT: + ret = calendar_svc_subscribe_db_change(CAL_STRUCT_SCHEDULE, callback, user_data); + break; + case CALENDAR_DB_CHANGED_CB_TYPE_TODO: + ret = calendar_svc_subscribe_db_change(CAL_STRUCT_TODO, callback, user_data); + break; + default: + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + break; + } + + if(ret == CAL_SUCCESS) { return CALENDAR_ERROR_NONE; } - LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } -int calendar_unset_db_changed_cb(calendar_db_changed_cb callback) +int calendar_remove_db_changed_cb(calendar_db_changed_cb callback, calendar_db_changed_cb_type_e type) { + int ret; CALENDAR_NULL_ARG_CHECK(callback); - if(calendar_svc_unsubscribe_change(callback) == CAL_SUCCESS) { + + switch(type) { + case CALENDAR_DB_CHANGED_CB_TYPE_CALENDAR_BOOK: + ret = calendar_svc_unsubscribe_db_change(CAL_STRUCT_CALENDAR, callback); + break; + case CALENDAR_DB_CHANGED_CB_TYPE_EVENT: + ret = calendar_svc_unsubscribe_db_change(CAL_STRUCT_SCHEDULE, callback); + break; + case CALENDAR_DB_CHANGED_CB_TYPE_TODO: + ret = calendar_svc_unsubscribe_db_change(CAL_STRUCT_TODO, callback); + break; + default: + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + break; + } + + if(ret == CAL_SUCCESS) { return CALENDAR_ERROR_NONE; } - LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } -int calendar_event_get_last_modified_time(calendar_event_h event, struct tm *reviedtime) +int calendar_get_db_version(int* calendar_db_version) { - struct tm *tmp_date = NULL; + CALENDAR_NULL_ARG_CHECK(calendar_db_version); - CALENDAR_NULL_ARG_CHECK(event); - CALENDAR_NULL_ARG_CHECK(reviedtime); + if (calendar_svc_begin_trans() != CAL_SUCCESS) { + LOGE("%s] CALENDAR_ERROR_NO_DATA(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); + return CALENDAR_ERROR_DB_FAILED; + } + *calendar_db_version = calendar_svc_end_trans(true); + return CALENDAR_ERROR_NONE; +} - tmp_date = calendar_svc_struct_get_tm((cal_struct*)((calendar_event_s*)event)->event_legacy, - CAL_VALUE_GMT_LAST_MODIFIED_TIME, CAL_TZ_FLAG_LOCAL); - - if (tmp_date == NULL) { - LOGE("[%s] CALENDAR_ERROR_NO_DATA(0x%08x)", __FUNCTION__, CALENDAR_ERROR_NO_DATA); - return CALENDAR_ERROR_NO_DATA; - } +int calendar_event_get_last_modified_time(calendar_event_h event, long long int *modified_time) +{ + CALENDAR_NULL_ARG_CHECK(event); + CALENDAR_NULL_ARG_CHECK(modified_time); - *reviedtime = *tmp_date; + *modified_time = calendar_svc_struct_get_lli((cal_struct*)((calendar_event_s*)event)->event_legacy, + CALS_VALUE_LLI_LASTMOD); return CALENDAR_ERROR_NONE; } @@ -1128,7 +2268,7 @@ int calendar_event_get_visibility(calendar_event_h event, calendar_visibility_e CALENDAR_NULL_ARG_CHECK(event); CALENDAR_NULL_ARG_CHECK(visibility); - *visibility = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)event)->event_legacy, + *visibility = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_INT_SENSITIVITY); return CALENDAR_ERROR_NONE; @@ -1136,13 +2276,13 @@ int calendar_event_get_visibility(calendar_event_h event, calendar_visibility_e int calendar_event_set_visibility(calendar_event_h event, calendar_visibility_e visibility) { - int ret_val = CALENDAR_ERROR_NONE; + int ret = CALENDAR_ERROR_NONE; CALENDAR_NULL_ARG_CHECK(event); - ret_val = calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)event)->event_legacy, + ret = calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_INT_SENSITIVITY, visibility); - if (ret_val != CAL_SUCCESS) + if (ret != CAL_SUCCESS) { LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; @@ -1151,54 +2291,95 @@ int calendar_event_set_visibility(calendar_event_h event, calendar_visibility_e return CALENDAR_ERROR_NONE; } -int calendar_query_event_by_time_last_modified(calendar_foreach_query_event_cb callback, int calendar_db_id, struct tm time, void *user_data) +int calendar_event_search_event_by_version(int calendar_book_db_id, int calendar_db_version, + pcalendar_modified_event_s **modified_event_array, int *length) { - CALENDAR_NULL_ARG_CHECK(callback); - int ret_val = 0; - cal_iter* iter = NULL; - bool callback_return = true; - - int account_id = _calendar_get_account_db_id(calendar_db_id); - CONTACTS_INVALID_ARG_CHECK(account_id == -2); + CALENDAR_NULL_ARG_CHECK(modified_event_array); + CALENDAR_NULL_ARG_CHECK(length); - //fetch from DB - time_t timestamp = mktime(&time); - ret_val = calendar_svc_get_updated_event_list (account_id, timestamp, &iter); + int i, ret; + int is_error = 0; + GList *l = NULL; + GList *cursor; + cal_iter *iter = NULL; + cal_struct *cs = NULL; + calendar_modified_event_s *cme; + pcalendar_modified_event_s *p; + *length = 0; - if (ret_val != CAL_SUCCESS) { - LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); + ret = calendar_svc_event_get_changes(calendar_book_db_id, calendar_db_version, &iter); + if (CAL_SUCCESS != ret) { + LOGE("[%s] CALLENDAR_ERROR_DB_FAILED(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_DB_FAILED); return CALENDAR_ERROR_DB_FAILED; } - - if (iter == NULL) { - LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); - return CALENDAR_ERROR_DB_FAILED; - } else { - while (calendar_svc_iter_next(iter) == CAL_SUCCESS) - { - calendar_event_s cal_event_from_db = {0,}; - if(calendar_svc_iter_get_info(iter, (cal_struct**)&cal_event_from_db.event_legacy) != CAL_SUCCESS) { - calendar_svc_iter_remove(&iter); - return CALENDAR_ERROR_NONE; // consider this as no data - } - - if(cal_event_from_db.event_legacy == NULL) { - calendar_svc_iter_remove(&iter); - break; - } - - //execute callback - callback_return = callback((calendar_event_h)&cal_event_from_db, user_data); - calendar_svc_struct_free((cal_struct**)&cal_event_from_db.event_legacy); - if(callback_return == false) { - break; - } - } - calendar_svc_iter_remove(&iter); - return CALENDAR_ERROR_NONE; - } + /* get event_db_id and append to glist */ + while (calendar_svc_iter_next(iter) == CAL_SUCCESS) { + if(calendar_svc_iter_get_info(iter, &cs) != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY); + is_error = 1; + break; + } + cme = calloc(1, sizeof(calendar_modified_event_s)); + if (cme == NULL) { + LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY); + is_error = 1; + break; + } + + cme->modified_status = calendar_svc_struct_get_int(cs, CALS_STRUCT_UPDATED_INT_TYPE); + cme->event_db_id = calendar_svc_struct_get_int(cs, CALS_STRUCT_UPDATED_INT_ID); + cme->calendar_db_version = calendar_svc_struct_get_int(cs, + CALS_STRUCT_UPDATED_INT_VERSION); + cme->calendar_book_db_id = calendar_svc_struct_get_int(cs, + CALS_STRUCT_UPDATED_INT_CALENDAR_ID); + + l = g_list_append(l, cme); + calendar_svc_struct_free(&cs); + } + calendar_svc_iter_remove(&iter); + + if (is_error) { + LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY); + g_list_free_full(l, free); + return CALENDAR_ERROR_OUT_OF_MEMORY; + } + + /* if there is no data */ + if (l == NULL) { + *length = 0; + return CALENDAR_ERROR_NONE; + } + + /* malloc array and fill data */ + *length = g_list_length(l); + + /* plus 1 to fill null pointer*/ + p = calloc(*length + 1, sizeof(pcalendar_modified_event_s)); + if (p == NULL) { + LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", + __FUNCTION__,CALENDAR_ERROR_OUT_OF_MEMORY); + g_list_free_full(l, free); + return CALENDAR_ERROR_OUT_OF_MEMORY; + } + + cursor = l; + for (i = 0; cursor; i++) { + p[i] = (calendar_modified_event_s*)(cursor->data); + cursor = g_list_next(cursor); + } + /* free list after allocation */ + g_list_free(l); + + /* fill NULL pointer to indicate end of array */ + p[i] = NULL; + + *modified_event_array = p; return CALENDAR_ERROR_NONE; } @@ -1207,24 +2388,21 @@ int calendar_event_get_timezone(calendar_event_h event, char** timezone_name) CALENDAR_NULL_ARG_CHECK(event); CALENDAR_NULL_ARG_CHECK(timezone_name); -// *timezone_offset = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)event)->event_legacy, -// CAL_VALUE_INT_TIMEZONE); - *timezone_name = _calendar_safe_strdup(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)event)->event_legacy, - CAL_VALUE_TXT_TZ_NAME)); + *timezone_name = _calendar_safe_strdup(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)event)->event_legacy, + CALS_VALUE_TXT_DTSTART_TZID)); return CALENDAR_ERROR_NONE; } int calendar_event_set_timezone(calendar_event_h event, const char* timezone_name) { - int ret_val = CALENDAR_ERROR_NONE; + int ret = CALENDAR_ERROR_NONE; CALENDAR_NULL_ARG_CHECK(event); CALENDAR_NULL_ARG_CHECK(timezone_name); - ret_val = calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_INT_TIMEZONE, 0); - ret_val = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_TXT_TZ_NAME, timezone_name); - if (ret_val != CAL_SUCCESS) + ret = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)event)->event_legacy, CALS_VALUE_TXT_DTSTART_TZID, timezone_name); + if (ret != CAL_SUCCESS) { LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; @@ -1233,393 +2411,96 @@ int calendar_event_set_timezone(calendar_event_h event, const char* timezone_nam return CALENDAR_ERROR_NONE; } -typedef struct _calendar_time_zone_st _calendar_time_zone_s; -struct _calendar_time_zone_st -{ - char* city; - char* country; - char* gmt; - char* tz_path; -}; -const _calendar_time_zone_s _calendar_time_zone_array[] = -{ - {"Abidjan", "Ivory Coast", "GMT+0", "Africa/Abidjan"}, - {"Abu Dhabi", "United Arab Emirates", "GMT+4", "Asia/Dubai"}, - {"Accra", "Ghana", "GMT-10", "Africa/Accra"}, - {"Addis Ababa", "Ethiopia", "GMT+3", "Africa/Addis_Ababa"}, - {"Adelaide", "Australia", "GMT+9:30", "Australia/Adelaide"}, - {"Alaska", "United States of America", "GMT-9", "America/Nome"}, - {"Algiers", "Algeria", "GMT+1", "Africa/Algiers"}, - {"Almaty", "Kazakhstan", "GMT+6", "Asia/Almaty"}, - {"Ambon", "Indonesia", "GMT+1", "Asia/Jayapura"}, - {"Amman", "Jordan", "GMT+2", "Asia/Amman"}, - {"Amsterdam", "Netherlands", "GMT+1", "Europe/Amsterdam"}, - {"Anadyr", "Russia ", "GMT+12", "Asia/Anadyr"}, - {"Anchorage", "United States of America", "GMT-9", "America/Anchorage"}, - {"Ankara", "Turkey", "GMT+2", "Asia/Istanbul"}, - {"Antananarivo", "Madagascar", "GMT+3", "Indian/Antananarivo"}, - {"Ashgabat", "Turkmenistan", "GMT+5", "Asia/Ashgabat"}, - {"Asmera", "Eritrea", "GMT+3", "Africa/Asmara"/* not in zone.tab */ }, - {"Astana", "Kazakhstan", "GMT+6", "Asia/Almaty"/* not in zone.tab */ }, - {"Asuncion", "Paraguay", "GMT-4", "America/Asuncion"}, - {"Athens", "Greece", "GMT+2", "Europe/Athens"}, - {"Auckland", "New Zealand", "GMT+12", "Pacific/Auckland"}, - {"Austin", "United States of America", "GMT-6", "CST6CDT"}, - {"Azores", "Portugal", "GMT-1", "Atlantic/Azores"}, - {"Baghdad", "Iraq", "GMT+3", "Asia/Baghdad"}, - {"Baku", "Azerbaijan", "GMT+4", "Asia/Baku"}, - {"Baltimore", "United States of America", "GMT-5", "EST5EDT"}, - {"Bamako", "Mali", "GMT+0", "Africa/Bamako"}, - {"Bangkok", "Thailand", "GMT+7", "Asia/Bangkok"}, - {"Bangui", "Central African Republic", "GMT+1", "Africa/Bangui"}, - {"Barcelona", "Spain", "GMT+2", "Europe/Madrid"}, - {"Bari", "Italy", "GMT+1", "Europe/Rome"}, - {"Basse-Terre", "Guadeloupe", "GMT-4", "America/Guadeloupe"}, - {"Beijing", "China", "GMT+8", "Asia/Shanghai"}, - {"Beirut", "Lebanon", "GMT+2", "Asia/Beirut"}, - {"Belgrade", "Serbia", "GMT+1", "Europe/Belgrade"}, - {"Belize City", "Belize", "GMT-6", "America/Belize"}, - {"Berlin", "Germany", "GMT+1", "Europe/Berlin"}, - {"Bern", "Switzerland", "GMT+1", "Europe/Zurich"}, - {"Bishkek", "Kyrgyzstan", "GMT+6", "Asia/Bishkek"}, - {"Bissau", "Guinea Bissau", "GMT+0", "Africa/Bissau"}, - {"Bogota", "Colombia", "GMT-5", "America/Bogota"}, - {"Bologna", "Italy", "GMT+1", "Europe/Rome"}, - {"Boston", "United States of America", "GMT-5", "EST5EDT"}, - {"Brasilia", "Brazil", "GMT-3", "America/Sao_Paulo"}, - {"Bratislava", "Slovakia", "GMT+2", "Europe/Bratislava"}, - {"Bridgetown", "Barbados", "GMT-4", "America/Barbados"}, - {"Brisbane", "Australia", "GMT+10", "Australia/Brisbane"}, - {"Brussels", "Belgium", "GMT+1", "Europe/Brussels"}, - {"Bucharest", "Romania", "GMT+3", "Europe/Bucharest"}, - {"Budapest", "Hungary", "GMT+1", "Europe/Budapest"}, - {"Buenos Aires", "Argentina", "GMT-3", "America/Argentina/Buenos_Aires"}, - {"Cairo", "Egypt", "GMT+2", "Africa/Cairo"}, - {"Calgary", "Canada", "GMT-7", "MST7MDT"}, - {"Canary Islands", "Spain", "GMT+0", "Atlantic/Canary"}, - {"Canberra", "Australia", "GMT+10", "Australia/Canberra"}, - {"Canton", "China", "GMT+8", "Asia/Shanghai"}, - {"Cape Town", "Republic of South Africa", "GMT+2", "Africa/Johannesburg"}, - {"Caracas", "Venezuela", "GMT-4:30", "America/Caracas"}, - {"Cardiff", "Wales", "GMT+0", "Europe/London"}, - {"Casablanca", "Morocco", "GMT+0", "Africa/Casablanca"}, - {"Catanzaro", "Italy", "GMT+1", "Europe/Rome"}, - {"Cayenne", "French Guiana", "GMT-3", "America/Cayenne"}, - {"Charlotte", "United States of America", "GMT-5", "EST5EDT"}, - {"Charlotte Amalie", "United States Virgin Islands ", "GMT-5:30", "America/St_Thomas"}, - {"Chelyabinsk", "Russia ", "GMT+5", "Asia/Yekaterinburg"}, - {"Chennai", "India", "GMT+5:30", "Asia/Kolkata"}, - {"Chicago", "United States of America", "GMT-6", "America/Chicago"}, - {"Chisinau", "Moldova", "GMT+2", "Europe/Chisinau"}, - {"Chita", "Russia", "GMT+9", "Asia/Yakutsk"}, - {"Cleveland", "United States of America", "GMT-5", "EST5EDT"}, - {"Colombo", "Sri Lanka", "GMT+5:30", "Asia/Colombo"}, - {"Columbus", "United States of America", "GMT-5", "EST5EDT"}, - {"Conakry", "Guinea", "GMT+1", "Africa/Conakry"}, - {"Copenhagen", "Denmark", "GMT+1", "Europe/Copenhagen"}, - {"Cork", "Ireland", "GMT+0", "Europe/Dublin"}, - {"Crotone", "Italy", "GMT+1", "Europe/Rome"}, - {"Dakar", "Senegal", "GMT+0", "Africa/Dakar"}, - {"Dallas", "United States of America", "GMT-6", "CST6CDT"}, - {"Damascus", "Syria", "GMT+2", "Asia/Damascus"}, - {"Dar es Salaam", "Tanzania", "GMT+3", "Africa/Dar_es_Salaam"}, - {"Darwin", "Australia", "GMT+9:30", "Australia/Darwin"}, - {"Delhi", "India", "GMT+5:30", "Asia/Kolkata"}, - {"Denpasar", "Indonesia", "GMT+8", "Asia/Makassar"}, - {"Denver", "United States of America", "GMT-7", "America/Denver"}, - {"Detroit", "United States of America", "GMT-5", "America/Detroit"}, - {"Dhaka", "Bangladesh", "GMT+6", "Asia/Dhaka"}, - {"Diego Garcia", "United Kingdom", "GMT+5", "Indian/Chagos"/* not in zone.tab */ }, - {"Djibouti", "Djibouti", "GMT+3", "Africa/Djibouti"}, - {"Doha", "Qatar", "GMT+3", "Asia/Qatar"}, - {"Douala", "Cameroon", "GMT+1", "Africa/Douala"}, - {"Dubai", "United Arab Emirates", "GMT+4", "Asia/Dubai"}, - {"Dublin", "Ireland", "GMT+0", "Europe/Dublin"}, - {"Dushanbe", "Tajikistan", "GMT+5", "Asia/Dushanbe"}, - {"Easter Island", "Chile", "GMT-6", "Pacific/Easter"}, - {"Edinburgh", "Scotland", "GMT+0", "Europe/London"}, - {"El Paso", "United States of America", "GMT-7", "MST7MDT"}, - {"Florence", "Italy", "GMT+1", "Europe/Rome"}, - {"Fort-de-France", "Martinique", "GMT-4", "America/Martinique"}, - {"Freetown", "Sierra Leone", "GMT+0", "Africa/Freetown"}, - {"Gaborone", "Botswana", "GMT+2", "Africa/Gaborone"}, - {"Galapagos Islands", "Ecuador", "GMT-7", "Pacific/Galapagos"}, - {"Geneva", "Switzerland", "GMT+1", "Europe/Paris"}, - {"Genoa", "Italy", "GMT+1", "Europe/Rome"}, - {"Georgetown", "Guyana", "GMT-4", "America/Guyana"}, - {"Grytviken", "South Georgia", "GMT-2", "Atlantic/South_Georgia"}, - {"Guam", "United States of America", "GMT+10", "Pacific/Guam"}, - {"Guatemala City", "Guatemala", "GMT-6", "America/Guatemala"}, - {"Gustavia", "Saint Barthelemy", "GMT-4", "America/Antigua"}, - {"Halifax", "Canada", "GMT-4", "America/Halifax"}, - {"Hamburg", "Germany", "GMT+1", "Europe/Berlin"}, - {"Hanoi", "Vietnam", "GMT+7", "Asia/Ho_Chi_Minh"}, - {"Harare", "Zimbabwe", "GMT+2", "Africa/Harare"}, - {"Havana", "Cuba", "GMT-5", "America/Havana"}, - {"Hawaii", "United States of America", "GMT-10", "Pacific/Honolulu"}, - {"Helsinki", "Finland", "GMT+2", "Europe/Helsinki"}, - {"Hobart", "Australia", "GMT+10", "Australia/Hobart"}, - {"Hong Kong", "China", "GMT+8", "Asia/Hong_Kong"}, - {"Honolulu", "United States of America", "GMT-10", "Pacific/Honolulu"}, - {"Houston", "United States of America", "GMT-6", "CST6CDT"}, - {"Hovd", "Mongolia", "GMT+8", "Asia/Hovd"}, - {"Indianapolis", "United States of America", "GMT-5", "America/Indiana/Indianapolis"}, - {"Irkutsk", "Russia ", "GMT+8", "Asia/Irkutsk"}, - {"Islamabad", "Pakistan", "GMT+5", "Asia/Karachi"}, - {"Istanbul", "Turkey", "GMT+2", "Europe/Istanbul"}, - {"Izhevsk", "Russia ", "GMT+4", "Europe/Moscow"}, - {"Jakarta", "Indonesia", "GMT+7", "Asia/Jakarta"}, - {"Jeddah", "Saudi Arabia", "GMT+3", "Asia/Riyadh"}, - {"Jerusalem", "Israel", "GMT+2", "Asia/Jerusalem"}, - {"Johannesburg", "South Africa", "GMT+2", "Africa/Johannesburg"}, - {"Kabul", "Afghanistan", "GMT+4:30", "Asia/Kabul"}, - {"Kaliningrad", "Russia", "GMT+2", "Europe/Kaliningrad"}, - {"Kamchatka", "Russia ", "GMT+12", "Asia/Kamchatka"}, - {"Kampala", "Uganda", "GMT+3", "Africa/Kampala"}, - {"Karachi", "Pakistan", "GMT+5", "Asia/Karachi"}, - {"Kathmandu", "Nepal", "GMT+5:45", "Asia/Kathmandu"}, - {"Khabarovsk", "Russia ", "GMT+10", "Asia/Vladivostok"}, - {"Kharkiv", "Ukraine", "GMT+2", "Europe/Kiev"}, - {"Khartoum", "Sudan", "GMT+3", "Africa/Khartoum"}, - {"Kiev", "Ukraine", "GMT+2", "Europe/Kiev"}, - {"Kingston", "Canada", "GMT-5", "America/Toronto"}, /* not in zone.tab */ - {"Kingston", "Jamaica", "GMT-5", "America/Jamaica"}, - {"Kinshasa", "Democratic Republic of the Congo", "GMT+1", "Africa/Kinshasa"}, - {"Kolkata", "India", "GMT+5:30", "Asia/Kolkata"}, - {"Krasnoyarsk", "Russia ", "GMT+7", "Asia/Krasnoyarsk"}, - {"Kuala Lumpur", "Malaysia", "GMT+8", "Asia/Kuala_Lumpur"}, - {"Kuwait", "Kuwait", "GMT+3", "Asia/Kuwait"}, - {"Kyiv", "Ukraine", "GMT+2", "Europe/Kiev"/* not in zone.tab */ }, - {"Los Angeles", "United States of America", "GMT-7", "America/Los_Angeles"}, - {"La Paz", "Bolivia", "GMT-4", "America/La_Paz"}, - {"Lagos", "Nigeria", "GMT+1", "Africa/Lagos"}, - {"Las Vegas", "United States of America", "GMT-8", "PST8PDT"}, - {"Lima", "Peru", "GMT-5", "America/Lima"}, - {"Lisbon", "Portugal", "GMT+0", "Europe/Lisbon"}, - {"Ljubljana", "Slovakia", "GMT+1", "Europe/Ljubljana"}, - {"London", "United Kingdom", "GMT+0", "Europe/London"}, - {"Longhua", "China", "GMT+8", "Asia/Shanghai"}, - {"Louisville", "United States of America", "GMT-5", "America/Kentucky/Louisville"}, - {"Luanda", "Angola", "GMT+1", "Africa/Luanda"}, - {"Lubumbashi", "Democratic Republic of the Congo", "GMT+2", "Africa/Lubumbashi"}, - {"Lusaka", "Zambia", "GMT+2", "Africa/Lusaka"}, - {"Luxembourg", "Luxembourg", "GMT+1", "Europe/Luxembourg"}, - {"Lviv", "Ukraine", "GMT+2", "Europe/Kiev"}, - {"Macau", "China", "GMT+8", "Asia/Macau"}, - {"Madrid", "Spain", "GMT+2", "Europe/Madrid"}, - {"Magadan", "Russia ", "GMT+11", "Asia/Magadan"}, - {"Malabo", "Equaorial Guinea", "GMT+1", "Africa/Malabo"}, - {"Male", "Maldives", "GMT+5", "Indian/Maldives"}, - {"Managua", "Nicaragua", "GMT-6", "America/Managua"}, - {"Manama", "Bahrain", "GMT+3", "Asia/Bahrain"}, - {"Manila", "Philippines", "GMT+8", "Asia/Manila"}, - {"Maputo", "Mozambique", "GMT+2", "Africa/Maputo"}, - {"Marigot", "Saint Martin", "GMT-4", "America/Marigot"}, - {"Mazatlan", "Mexico", "GMT-7", "America/Mazatlan"}, - {"Mecca", "Saudi Arabia", "GMT+3", "Asia/Riyadh"}, - {"Melbourne", "Australia", "GMT+10", "Australia/Melbourne"}, - {"Memphis", "United States of America", "GMT-6", "CST6CDT"}, - {"Messina", "Italy", "GMT+1", "Europe/Rome"}, - {"Mexico City", "Mexico", "GMT-6", "America/Mexico_City"}, - {"Miami", "United States of America", "GMT-5", "EST5EDT"}, - {"Mid-Atlantic", "United States of America", "GMT-2", "America/New_York"/* not in zone.tab */ }, - {"Midway Atoll", "United States of America", "GMT-11", "Pacific/Midway"}, - {"Milan", "Italy", "GMT+1", "Europe/Rome"}, - {"Milwaukee", "United States of America", "GMT-6", "CST6CDT"}, - {"Minsk", "Belarus", "GMT+2", "Europe/Minsk"}, - {"Mogadishu", "Somalia", "GMT+2", "Africa/Mogadishu"}, - {"Monrovia", "Liberia", "GMT+0", "Africa/Monrovia"}, - {"Montevideo", "Uruguay", "GMT-3", "America/Montevideo"}, - {"Montreal", "Canada", "GMT-5", "America/Montreal"}, - {"Moscow", "Russia ", "GMT+3", "Europe/Moscow"}, - {"Mumbai", "India", "GMT+5:30", "Asia/Kolkata"}, - {"Munich", "Germany", "GMT+1", "Europe/Berlin"}, - {"Muscat", "Oman", "GMT+4", "Asia/Muscat"}, - {"Nairobi", "Kenya", "GMT+3", "Africa/Nairobi"}, - {"Naples", "Italy", "GMT+1", "Europe/Rome"}, - {"Naters", "Switzerland", "GMT+1", "Europe/Zurich"}, - {"Ndjamena", "Chad", "GMT+1", "Africa/Ndjamena"}, - {"New Delhi", "India", "GMT+5:30", "Asia/Kolkata"/* not in zone.tab */ }, - {"New York", "United States of America", "GMT-4", "America/New_York"}, - {"Newfoundland", "Canada", "GMT-3:30", "America/St_Johns"}, - {"Niamey", "Niger", "GMT+1", "Africa/Niamey"}, - {"Nouakchott", "Mauritania", "GMT+1", "Africa/Nouakchott"}, - {"Noumea", "New Caledonia", "GMT+11", "Pacific/Noumea"}, - {"Novokuznetsk", "Russia", "GMT+7", "Asia/Novokuznetsk"}, - {"Novosibirsk", "Russia", "GMT+6", "Asia/Novosibirsk"}, - {"Nuku'alofa", "Tonga", "GMT+13", "Pacific/Tongatapu"}, - {"Nuuk", "Greenland", "GMT-3", "America/Godthab"}, - {"Omsk", "Russia", "GMT+6", "Asia/Omsk"}, - {"Osaka", "Japan", "GMT+9", "Asia/Tokyo"}, - {"Ottawa", "Canada", "GMT-5", "EST5EDT"}, - {"Ouagadougou", "Burkina Faso", "GMT+0", "Africa/Ouagadougou"}, - {"Pago Pago", "Independent State of Samoa", "GMT-11", "Pacific/Pago_Pago"}, - {"Palermo", "Italy", "GMT+1", "Europe/Rome"}, - {"Panama City", "Panama", "GMT-6", "America/Panama"}, - {"Paramaribo", "Surinam", "GMT-3", "America/Paramaribo"}, - {"Paris", "France", "GMT+1", "Europe/Paris"}, - {"Perm", "Russia", "GMT+5", "Asia/Yekaterinburg"}, - {"Perth", "Australia", "GMT+8", "Australia/Perth"}, - {"Petropavlovsk-Kamchatskiy", "Russia ", "GMT+12", "Asia/Kamchatka"}, - {"Philadelphia", "United States of America", "GMT-5", "EST5EDT"}, - {"Phnom Penh ", "Cambodia", "GMT-5", "Asia/Phnom_Penh"}, - {"Phoenix", "United States of America", "GMT-7", "America/Phoenix"}, - {"Podgorica", "Montenegro", "GMT+1", "Europe/Podgorica"}, - {"Ponta Delgada", "Portugal", "GMT-1", "Atlantic/Azores"}, - {"Port Louis", "Mauritius", "GMT+4", "Indian/Mauritius"}, - {"Port-au-Prince", "Haiti", "GMT-5", "America/Port-au-Prince"}, - {"Portland", "United States of America", "GMT-8", "PST8PDT"}, - {"Prague", "Czech Republic", "GMT+1", "Europe/Prague"}, - {"Pyongyang", "North Korea", "GMT+9", "Asia/Pyongyang"}, - {"Quito", "Ecuador", "GMT-5", "America/Guayaquil"}, - {"Rabat", "Morocco", "GMT+0", "Africa/Casablanca"}, - {"Rangoon", "Burma", "GMT+6:30", "Asia/Rangoon"}, - {"Recife", "Brazil", "GMT-3", "America/Recife"}, - {"Regina", "Canada", "GMT-6", "America/Regina"}, - {"Reykjavik", "Iceland", "GMT+0", "Atlantic/Reykjavik"}, - {"Riga", "Latvia", "GMT+2", "Europe/Riga"}, - {"Rio de Janeiro", "Brazil", "GMT-2", "America/Sao_Paulo"}, - {"Riyadh", "Saudi Arabia", "GMT+3", "Asia/Riyadh"}, - {"Rome", "Italy", "GMT+1", "Europe/Rome"}, - {"Saint-Denis", "Reunion Island", "GMT+4", "Indian/Reunion"}, - {"Samara", "Russia ", "GMT+4", "Europe/Samara"}, - {"San Antonio", "United States of America", "GMT-6", "CST6CDT"}, - {"San Diego", "United States of America", "GMT-8", "PST8PDT"}, - {"San Francisco", "United States of America", "GMT-8", "America/Los_Angeles"}, - {"San Jose", "United States of America", "GMT-8", "PST8PDT"}, - {"San Jose", "Costa Rica", "GMT-6", "America/Costa_Rica"}, - {"San Juan", "Puerto Rico", "GMT-4", "America/Puerto_Rico"}, - {"San Marino", "Italy", "GMT+1", "Europe/San_Marino"}, - {"San Salvador", "El Salvador", "GMT-6", "America/El_Salvador"}, - {"Sanaa", "Yemen", "GMT+3", "Asia/Aden"/* not in zone.tab */ }, - {"Santiago", "Chile", "GMT-4", "America/Santiago"}, - {"Santo Domingo", "Dominican Republic", "GMT-4", "America/Santo_Domingo"}, - {"Sao Paulo", "Brazil", "GMT-2", "America/Sao_Paulo"}, - {"Seattle", "United States of America", "GMT-8", "PST8PDT"}, - {"Seoul", "Republic of Korea", "GMT+9", "Asia/Seoul"}, - {"Shanghai", "China", "GMT+8", "Asia/Shanghai"}, - {"Shenzhen", "China", "GMT+8", "Asia/Shanghai"}, - {"Singapore", "Republic of Singapore", "GMT+8", "Asia/Singapore"}, - {"Skopje", "Macedonia", "GMT+1", "Europe/Skopje"}, - {"Sofia ", "Bulgaria", "GMT+3", "Europe/Sofia"}, - {"St. John's", "Antigua and Barbuda", "GMT-4", "America/Antigua"}, - {"St. John's", "Canada", "GMT-3:30", "America/St_Johns"}, - {"St. Petersburg", "Russia", "GMT+3", "Europe/Moscow"}, - {"Stockholm", "Sweden", "GMT+2", "Europe/Stockholm"}, - {"Suva", "Fiji", "GMT+12", "Pacific/Fiji"}, - {"Sydney", "Australia", "GMT+11", "Australia/Sydney"}, - {"Tahiti", "French Polynesia", "GMT-10", "Pacific/Tahiti"}, - {"Taipei", "Taiwan", "GMT+8", "Asia/Taipei"}, - {"Tallinn", "Estonia", "GMT+2", "Europe/Tallinn"}, - {"Tarawa", "Kiribati", "GMT+12", "Pacific/Tarawa"}, - {"Tashkent", "Uzbekistan", "GMT+5", "Asia/Tashkent"}, - {"Tbilisi", "Georgia", "GMT+4", "Asia/Tbilisi"}, - {"Tegucigalpa", "Honduras", "GMT-6", "America/Tegucigalpa"}, - {"Tehran", "Iran", "GMT+3:30", "Asia/Tehran"}, - {"Thanh Pho Ho Chi Minh", "Vietnam", "GMT+7", "Asia/Ho_Chi_Minh"}, - {"The Settlement", "British Virgin Islands ", "GMT-4", "America/Tortola"}, - {"Tientsin", "China", "GMT+8", "Asia/Shanghai"/* not in zone.tab */ }, - {"Tijuana", "Mexico", "GMT-5", "America/Tijuana"}, - {"Tokyo", "Japan", "GMT+9", "Asia/Tokyo"}, - {"Toronto", "Canada", "GMT-4", "America/Toronto"}, - {"Trehet", "France", "GMT+1", "Europe/Paris"/* not in zone.tab */ }, - {"Tripoli", "Libya", "GMT+2", "Africa/Tripoli"}, - {"Tunis", "Tunisia", "GMT+2", "Africa/Tunis"}, - {"Turin", "Italy", "GMT+1", "Europe/Rome"}, - {"Ufa", "Bashkiriya", "GMT+5", "Asia/Yekaterinburg"}, - {"Ulan Bator", "Mongolia", "GMT+8", "Asia/Ulan_Bator"}, - {"Vaduz", "Liechtenstein", "GMT+1", "Europe/Vaduz"}, - {"Valletta", "Malta", "GMT+1", "Europe/Malta"}, - {"Vancouver", "Canada", "GMT-8", "America/Vancouver"}, - {"Verona", "Italy", "GMT+1", "Europe/Rome"}, - {"Victoria", "Seychelles", "GMT+4", "Australia/Melbourne"}, - {"Vienna", "Austria", "GMT+1", "Europe/Vienna"}, - {"Vilnius", "Lithuania", "GMT+3", "Europe/Vilnius"}, - {"Vladivostok", "Russia ", "GMT+10", "Asia/Vladivostok"}, - {"Volgograd", "Russia ", "GMT+4", "Europe/Volgograd"}, - {"Warsaw", "Poland", "GMT+2", "Europe/Warsaw"}, - {"Washington, D.C.", "United States of America", "GMT-5", "EST5EDT"}, - {"Wellington", "New Zealand", "GMT+12", "Pacific/Auckland"}, - {"Winnipeg", "Canada", "GMT-5", "America/Winnipeg"}, - {"Yakutsk", "Russia ", "GMT+9", "Asia/Yakutsk"}, - {"Yamoussoukro", "Ivory Coast", "GMT+0", "Africa/Abidjan"}, - {"Yaounde", "Cameroon", "GMT+1", "Africa/Douala"/* not in zone.tab */ }, - {"Yekaterinburg", "Russia ", "GMT+5", "Asia/Yekaterinburg"}, - {"Yerevan", "Armenia", "GMT+5", "Asia/Yerevan"}, - {"Yuzhno-Sakhalinsk", "Russia ", "GMT+11", "Asia/Sakhalin"}, - {"Zagreb", "Croatia", "GMT+1", "Europe/Zagreb"}, - {"Zurich", "Switzerland", "GMT+1", "Europe/Zurich"}, - {NULL, NULL, NULL, NULL} -}; - -#define _calendar_timezone_dumpfile_path "/opt/share/zoneinfo/" - -int calendar_foreach_timezone(calendar_foreach_timezone_cb callback, void* user_data) +int calendar_event_get_event_array_from_vcalendar(const char *vcalendar_stream, calendar_event_h **event_array, int *length) { - CALENDAR_NULL_ARG_CHECK(callback); - - int i = 0; - char temp_filepath[256]; // normal char definition - while(_calendar_time_zone_array[i].city != NULL) - { - calendar_foreach_timezone_s timezone; - timezone.timezone_name = _calendar_safe_strdup(_calendar_time_zone_array[i].tz_path); - timezone.city_name = _calendar_safe_strdup(_calendar_time_zone_array[i].city); - timezone.country_name = _calendar_safe_strdup(_calendar_time_zone_array[i].country); - timezone.time_offset = _calendar_safe_strdup(_calendar_time_zone_array[i].gmt); - // all structure members has proper string value. - snprintf(temp_filepath, sizeof(temp_filepath), "%s%s", - _calendar_timezone_dumpfile_path, _calendar_time_zone_array[i].tz_path); // proper snprintf - timezone.timezone_detail_filepath = _calendar_safe_strdup(temp_filepath); - - bool callback_return = callback(&timezone, user_data); - - _calendar_safe_free(timezone.timezone_name); - _calendar_safe_free(timezone.city_name); - _calendar_safe_free(timezone.country_name); - _calendar_safe_free(timezone.time_offset); - _calendar_safe_free(timezone.timezone_detail_filepath); - - if(callback_return == false) - break; - - i++; + CALENDAR_NULL_ARG_CHECK(event_array); + CALENDAR_NULL_ARG_CHECK(vcalendar_stream); + + int i, ret; + GList *schedules = NULL; + GList *cursor; + calendar_event_s *ces; + calendar_event_h *ceh; + + ret = calendar_svc_read_schedules(vcalendar_stream, &schedules); + if (CAL_SUCCESS != ret) { + LOGE("[%s] CALENDAR_ERROR_READ_SCHEDULES(errno:%d)\n", + __FUNCTION__, ret); + return CALENDAR_ERROR_DB_FAILED; } - return CALENDAR_ERROR_NONE; -} + if (schedules == NULL) { + LOGW("[%s] CALENDAR_ERROR_NO_SCHEDULES", __FUNCTION__); + *event_array = NULL; + *length = 0; + return CALENDAR_ERROR_NONE; + } -int calendar_event_get_from_vcalendar(const char *vcalendar_stream, calendar_event_h *event) -{ - CALENDAR_NULL_ARG_CHECK(event); - CALENDAR_NULL_ARG_CHECK(vcalendar_stream); - *event = malloc(sizeof(calendar_event_s)); - if (*event == NULL) { - LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY); + *length = g_list_length(schedules); + + ceh = calloc(*length + 1, sizeof(calendar_event_h)); + if (ceh == NULL) { + LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY); + g_list_free(schedules); return CALENDAR_ERROR_OUT_OF_MEMORY; } - memset(*event, 0, sizeof(calendar_event_s)); - if(calendar_svc_util_convert_vcs_to_event(vcalendar_stream, 0, (cal_struct**)&(*(calendar_event_s**)event)->event_legacy) != CAL_SUCCESS) { - free(*event); - *event = NULL; + /* allocate list to array */ + cursor = schedules; + for (i = 0; cursor; i++) { + ces = calloc(1, sizeof(calendar_event_s)); + if (ces == NULL) { + LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY); + break; + } - LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); - return CALENDAR_ERROR_INVALID_PARAMETER; + ceh[i] = (calendar_event_h)ces; + ces->event_legacy = (calendar_event_legacy_s *)cursor->data; + cursor = g_list_next(cursor); } + g_list_free(schedules); + + ceh[i] = NULL; + + *event_array = ceh; return CALENDAR_ERROR_NONE; } -int calendar_event_get_vcalendar_from_event(calendar_event_h event, char **vcalendar_stream) +int calendar_event_get_vcalendar_from_db(int *event_db_id_array, int length, char **vcalendar_stream) { - CALENDAR_NULL_ARG_CHECK(event); + CALENDAR_NULL_ARG_CHECK(event_db_id_array); CALENDAR_NULL_ARG_CHECK(vcalendar_stream); - if(calendar_svc_util_convert_event_to_vcs((cal_struct*)((calendar_event_s*)event)->event_legacy, - vcalendar_stream, NULL) != CAL_SUCCESS) { - LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); - return CALENDAR_ERROR_INVALID_PARAMETER; + int i, ret; + GList *schedules = NULL; + cal_struct *cs = NULL; + + if (length < 1) { + LOGD("[%s] EVENT_DB_LENGTH is 0", __FUNCTION__); + return CALENDAR_ERROR_NONE; + } + + for (i = 0; i < length; i++) { + ret = calendar_svc_get(CAL_STRUCT_SCHEDULE, event_db_id_array[i], NULL, &cs); + if (CAL_SUCCESS != ret) { + LOGE("[%s] CALENDAR_ERROR_GET_EVENT(errno:%d)", __FUNCTION__, ret); + break; + } + if (cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_GET_EVENT", __FUNCTION__); + break; + } + schedules = g_list_append(schedules, cs); } + + ret = calendar_svc_write_schedules(schedules, vcalendar_stream); + if (CAL_SUCCESS != ret) { + LOGE("[%s] CALENDAR_ERROR_WRITE_SCHEDDULES", __FUNCTION__); + return CALENDAR_ERROR_DB_FAILED; + } + return CALENDAR_ERROR_NONE; } @@ -1642,28 +2523,27 @@ int calendar_todo_create(calendar_todo_h *todo) LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY); return CALENDAR_ERROR_OUT_OF_MEMORY; } - calendar_svc_struct_set_int((cal_struct*)(*(calendar_event_s**)todo)->event_legacy, CAL_VALUE_INT_TIMEZONE, 100); // set default timezone return CALENDAR_ERROR_NONE; } int calendar_todo_destroy(calendar_todo_h todo) { - int ret_val = CALENDAR_ERROR_NONE; + int ret = CALENDAR_ERROR_NONE; CALENDAR_NULL_ARG_CHECK(todo); - ret_val = calendar_svc_struct_free((cal_struct **)&((calendar_event_s*)todo)->event_legacy); - - if (ret_val != CAL_SUCCESS) + ret = calendar_svc_struct_free((cal_struct **)&((calendar_event_s*)todo)->event_legacy); + + if (ret != CAL_SUCCESS) { LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); - ret_val = CALENDAR_ERROR_INVALID_PARAMETER; + ret = CALENDAR_ERROR_INVALID_PARAMETER; } else { free(todo); - ret_val = CALENDAR_ERROR_NONE; + ret = CALENDAR_ERROR_NONE; } - return ret_val; + return ret; } int calendar_todo_get_db_id(calendar_todo_h todo, int *db_id) @@ -1678,12 +2558,12 @@ int calendar_todo_get_db_id(calendar_todo_h todo, int *db_id) return CALENDAR_ERROR_NONE; } -int calendar_todo_get_calendar_db_id(calendar_todo_h todo, int *calendar_db_id) +int calendar_todo_get_calendar_book_db_id(calendar_todo_h todo, int *calendar_db_id) { CALENDAR_NULL_ARG_CHECK(todo); CALENDAR_NULL_ARG_CHECK(calendar_db_id); - *calendar_db_id = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)todo)->event_legacy, + *calendar_db_id = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)todo)->event_legacy, (char*)CAL_VALUE_INT_CALENDAR_ID); if(*calendar_db_id < 0) *calendar_db_id = 0; @@ -1695,21 +2575,21 @@ int calendar_todo_insert_to_db(calendar_todo_h todo, int calendar_db_id, int *to CALENDAR_NULL_ARG_CHECK(todo); CALENDAR_NULL_ARG_CHECK(todo_id); - int ret_val = CALENDAR_ERROR_NONE; + int ret = CALENDAR_ERROR_NONE; int account_db_id = _calendar_get_account_db_id(calendar_db_id); - CONTACTS_INVALID_ARG_CHECK(account_db_id == -2); + CALENDAR_INVALID_ARG_CHECK(account_db_id == -2); calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_INT_CALENDAR_ID, calendar_db_id); calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_INT_ACCOUNT_ID, account_db_id); - - ret_val = calendar_svc_insert((cal_struct*)((calendar_event_s*)todo)->event_legacy); - if (ret_val < 0) + + ret = calendar_svc_insert((cal_struct*)((calendar_event_s*)todo)->event_legacy); + if (ret < 0) { LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); return CALENDAR_ERROR_DB_FAILED; } - *todo_id = ret_val; + *todo_id = ret; return CALENDAR_ERROR_NONE; } @@ -1719,25 +2599,25 @@ int calendar_todo_delete_from_db(int todo_id) LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } - - int ret_val = CALENDAR_ERROR_NONE; - - ret_val = calendar_svc_delete(CAL_STRUCT_TODO, todo_id); - - if (ret_val == CAL_SUCCESS) { - ret_val = CALENDAR_ERROR_NONE; - } - else { + + int ret = CALENDAR_ERROR_NONE; + + ret = calendar_svc_delete(CAL_STRUCT_TODO, todo_id); + + if (ret == CAL_SUCCESS) { + ret = CALENDAR_ERROR_NONE; + } + else { LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); - ret_val = CALENDAR_ERROR_DB_FAILED; - } + ret = CALENDAR_ERROR_DB_FAILED; + } - return ret_val; + return ret; } int calendar_todo_update_to_db(calendar_todo_h todo) { - int ret_val = CALENDAR_ERROR_NONE; + int ret = CALENDAR_ERROR_NONE; CALENDAR_NULL_ARG_CHECK(todo); if((cal_struct*)((calendar_event_s*)todo)->event_legacy == NULL) { @@ -1745,9 +2625,9 @@ int calendar_todo_update_to_db(calendar_todo_h todo) return CALENDAR_ERROR_NO_DATA; } - ret_val = calendar_svc_update((cal_struct*)((calendar_event_s*)todo)->event_legacy); + ret = calendar_svc_update((cal_struct*)((calendar_event_s*)todo)->event_legacy); - if (ret_val != CAL_SUCCESS) { + if (ret != CAL_SUCCESS) { LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); return CALENDAR_ERROR_DB_FAILED; } @@ -1780,7 +2660,7 @@ int calendar_todo_get_priority(calendar_todo_h todo, calendar_todo_priority_e *p CALENDAR_NULL_ARG_CHECK(todo); CALENDAR_NULL_ARG_CHECK(priority); - *priority = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)todo)->event_legacy, + *priority = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_INT_PRIORITY); return CALENDAR_ERROR_NONE; @@ -1788,13 +2668,13 @@ int calendar_todo_get_priority(calendar_todo_h todo, calendar_todo_priority_e *p int calendar_todo_set_priority(calendar_todo_h todo, calendar_todo_priority_e priority) { - int ret_val = CALENDAR_ERROR_NONE; + int ret = CALENDAR_ERROR_NONE; CALENDAR_NULL_ARG_CHECK(todo); - ret_val = calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)todo)->event_legacy, + ret = calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_INT_PRIORITY, priority); - if (ret_val != CAL_SUCCESS) { + if (ret != CAL_SUCCESS) { LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } @@ -1807,58 +2687,21 @@ int calendar_todo_get_status(calendar_todo_h todo, calendar_todo_status_e *statu CALENDAR_NULL_ARG_CHECK(todo); CALENDAR_NULL_ARG_CHECK(status); - int legacy_status = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)todo)->event_legacy, + *status = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_INT_TASK_STATUS); - switch(legacy_status) { - case CALS_TODO_STATUS_NEEDS_ACTION: - *status = CALENDAR_TODO_STATUS_NEEDS_ACTION; - break; - case CALS_TODO_STATUS_COMPLETED: - *status = CALENDAR_TODO_STATUS_COMPLETED; - break; - case CALS_TODO_STATUS_IN_PROCESS: - *status = CALENDAR_TODO_STATUS_IN_PROCESS; - break; - case CALS_TODO_STATUS_CANCELLED: - *status = CALENDAR_TODO_STATUS_CANCELED; - break; - default: - *status = CALENDAR_TODO_STATUS_NONE; - break; - } - return CALENDAR_ERROR_NONE; } int calendar_todo_set_status(calendar_todo_h todo, calendar_todo_status_e status) { - int ret_val = CALENDAR_ERROR_NONE; + int ret = CALENDAR_ERROR_NONE; CALENDAR_NULL_ARG_CHECK(todo); - int legacy_status = CALS_STATUS_NONE; - switch(status) { - case CALENDAR_TODO_STATUS_NEEDS_ACTION: - legacy_status = CALS_TODO_STATUS_NEEDS_ACTION; - break; - case CALENDAR_TODO_STATUS_COMPLETED: - legacy_status = CALS_TODO_STATUS_COMPLETED; - break; - case CALENDAR_TODO_STATUS_IN_PROCESS: - legacy_status = CALS_TODO_STATUS_IN_PROCESS; - break; - case CALENDAR_TODO_STATUS_CANCELED: - legacy_status = CALS_TODO_STATUS_CANCELLED; - break; - default: - legacy_status = CALENDAR_TODO_STATUS_NONE; - break; - } - - ret_val = calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)todo)->event_legacy, - CAL_VALUE_INT_TASK_STATUS, legacy_status); - if (ret_val != CAL_SUCCESS) { + ret = calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)todo)->event_legacy, + CAL_VALUE_INT_TASK_STATUS, status); + if (ret != CAL_SUCCESS) { LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } @@ -1871,7 +2714,7 @@ int calendar_todo_get_visibility(calendar_todo_h todo, calendar_visibility_e *vi CALENDAR_NULL_ARG_CHECK(todo); CALENDAR_NULL_ARG_CHECK(visibility); - *visibility = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)todo)->event_legacy, + *visibility = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_INT_SENSITIVITY); return CALENDAR_ERROR_NONE; @@ -1879,13 +2722,13 @@ int calendar_todo_get_visibility(calendar_todo_h todo, calendar_visibility_e *vi int calendar_todo_set_visibility(calendar_todo_h todo, calendar_visibility_e visibility) { - int ret_val = CALENDAR_ERROR_NONE; + int ret = CALENDAR_ERROR_NONE; CALENDAR_NULL_ARG_CHECK(todo); - ret_val = calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)todo)->event_legacy, + ret = calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_INT_SENSITIVITY, visibility); - if (ret_val != CAL_SUCCESS) { + if (ret != CAL_SUCCESS) { LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } @@ -1901,17 +2744,43 @@ int calendar_todo_get_subject(calendar_todo_h todo, char **subject) *subject = NULL; *subject = _calendar_safe_strdup(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_TXT_SUMMARY)); - return CALENDAR_ERROR_NONE; + return CALENDAR_ERROR_NONE; } int calendar_todo_set_subject(calendar_todo_h todo, const char *subject) { - int ret_val = CALENDAR_ERROR_NONE; + int ret = CALENDAR_ERROR_NONE; + CALENDAR_NULL_ARG_CHECK(todo); + + ret = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_TXT_SUMMARY, subject); + + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + return CALENDAR_ERROR_NONE; +} + +int calendar_todo_get_categories(calendar_todo_h todo, char **categories) +{ CALENDAR_NULL_ARG_CHECK(todo); + CALENDAR_NULL_ARG_CHECK(categories); - ret_val = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_TXT_SUMMARY, subject); + *categories = NULL; + *categories = _calendar_safe_strdup(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_TXT_CATEGORIES)); - if (ret_val != CAL_SUCCESS) { + return CALENDAR_ERROR_NONE; +} + +int calendar_todo_set_categories(calendar_todo_h todo, const char *categories) +{ + int ret = CALENDAR_ERROR_NONE; + CALENDAR_NULL_ARG_CHECK(todo); + + ret = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_TXT_CATEGORIES, categories); + + if (ret != CAL_SUCCESS) { LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } @@ -1924,21 +2793,24 @@ int calendar_todo_get_description(calendar_todo_h todo, char **description) CALENDAR_NULL_ARG_CHECK(todo); CALENDAR_NULL_ARG_CHECK(description); - *description = NULL; - *description = _calendar_safe_strdup(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_TXT_DESCRIPTION)); + *description = _calendar_safe_strdup( + calendar_svc_struct_get_str( + (cal_struct*)((calendar_event_s*)todo)->event_legacy, + CAL_VALUE_TXT_DESCRIPTION) + ); - return CALENDAR_ERROR_NONE; + return CALENDAR_ERROR_NONE; } int calendar_todo_set_description(calendar_todo_h todo, const char *description) { - int ret_val = CALENDAR_ERROR_NONE; + int ret = CALENDAR_ERROR_NONE; CALENDAR_NULL_ARG_CHECK(todo); - ret_val = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_TXT_DESCRIPTION, description); + ret = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_TXT_DESCRIPTION, description); - if (ret_val != CAL_SUCCESS) { + if (ret != CAL_SUCCESS) { LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } @@ -1947,164 +2819,371 @@ int calendar_todo_set_description(calendar_todo_h todo, const char *description) } int calendar_todo_get_location(calendar_todo_h todo, char **location) -{ +{ CALENDAR_NULL_ARG_CHECK(todo); CALENDAR_NULL_ARG_CHECK(location); - *location = NULL; - *location = _calendar_safe_strdup(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)todo)->event_legacy, - CAL_VALUE_TXT_LOCATION)); - - return CALENDAR_ERROR_NONE; + *location = _calendar_safe_strdup( + calendar_svc_struct_get_str( + (cal_struct*)((calendar_event_s*)todo)->event_legacy, + CAL_VALUE_TXT_LOCATION) + ); + + return CALENDAR_ERROR_NONE; } int calendar_todo_set_location(calendar_todo_h todo, const char *location) -{ - int ret_val = CALENDAR_ERROR_NONE; +{ + int ret = CALENDAR_ERROR_NONE; CALENDAR_NULL_ARG_CHECK(todo); - ret_val = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)todo)->event_legacy, + ret = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_TXT_LOCATION, location); - - if (ret_val != CAL_SUCCESS) { + + if (ret != CAL_SUCCESS) { LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } - return CALENDAR_ERROR_NONE; + return CALENDAR_ERROR_NONE; } -int calendar_todo_get_last_modified_time(calendar_todo_h todo, struct tm *reviedtime) +int calendar_todo_get_last_modified_time(calendar_todo_h todo, long long int *modified_time) { - struct tm *tmp_date = NULL; - CALENDAR_NULL_ARG_CHECK(todo); - CALENDAR_NULL_ARG_CHECK(reviedtime); - - tmp_date = calendar_svc_struct_get_tm((cal_struct*)((calendar_event_s*)todo)->event_legacy, - CAL_VALUE_GMT_LAST_MODIFIED_TIME, CAL_TZ_FLAG_LOCAL); - - if (tmp_date == NULL) { - LOGE("[%s] CALENDAR_ERROR_NO_DATA(0x%08x)", __FUNCTION__, CALENDAR_ERROR_NO_DATA); - return CALENDAR_ERROR_NO_DATA; - } + CALENDAR_NULL_ARG_CHECK(modified_time); - *reviedtime = *tmp_date; + *modified_time = calendar_svc_struct_get_lli((cal_struct*)((calendar_event_s*)todo)->event_legacy, + CALS_VALUE_LLI_LASTMOD); return CALENDAR_ERROR_NONE; } - + int calendar_todo_get_timezone(calendar_todo_h todo, char** timezone_name) { CALENDAR_NULL_ARG_CHECK(todo); CALENDAR_NULL_ARG_CHECK(timezone_name); -// *timezone_offset = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)event)->event_legacy, -// CAL_VALUE_INT_TIMEZONE); - *timezone_name = _calendar_safe_strdup(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)todo)->event_legacy, - CAL_VALUE_TXT_TZ_NAME)); + *timezone_name = _calendar_safe_strdup(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)todo)->event_legacy, + CALS_VALUE_TXT_DTSTART_TZID)); return CALENDAR_ERROR_NONE; } - + int calendar_todo_set_timezone(calendar_todo_h todo, const char* timezone_name) { - int ret_val = CALENDAR_ERROR_NONE; + int ret = CALENDAR_ERROR_NONE; CALENDAR_NULL_ARG_CHECK(todo); CALENDAR_NULL_ARG_CHECK(timezone_name); - ret_val = calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_INT_TIMEZONE, 0); - ret_val = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_TXT_TZ_NAME, timezone_name); - if (ret_val != CAL_SUCCESS) { + ret = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)todo)->event_legacy, CALS_VALUE_TXT_DTSTART_TZID, timezone_name); + if (ret != CAL_SUCCESS) { LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } return CALENDAR_ERROR_NONE; } - -int calendar_todo_get_start_time(calendar_todo_h todo, struct tm *start_time) + +int calendar_todo_get_start_time(calendar_todo_h todo, long long int *start_time) { CALENDAR_NULL_ARG_CHECK(todo); CALENDAR_NULL_ARG_CHECK(start_time); - - if(calendar_svc_struct_get_tm((cal_struct*)((calendar_event_s*)todo)->event_legacy, - CAL_VALUE_GMT_START_DATE_TIME, CAL_TZ_FLAG_LOCAL) == NULL) { - LOGE("[%s] CALENDAR_ERROR_NO_DATA(0x%08x)", __FUNCTION__, CALENDAR_ERROR_NO_DATA); + + cal_struct *cs; + long long int lli; + + cs = (cal_struct*)((calendar_event_s*)todo)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + lli = calendar_svc_struct_get_lli(cs, CALS_VALUE_LLI_DTSTART_UTIME); + if (lli == CALS_TODO_NO_DUE_DATE) { return CALENDAR_ERROR_NO_DATA; } - memcpy(start_time, calendar_svc_struct_get_tm((cal_struct*)((calendar_event_s*)todo)->event_legacy, - CAL_VALUE_GMT_START_DATE_TIME, CAL_TZ_FLAG_LOCAL), sizeof(struct tm)); // proper memcpy - + *start_time = lli; return CALENDAR_ERROR_NONE; } -int calendar_todo_set_start_time(calendar_todo_h todo, struct tm start_time) +int calendar_todo_set_start_time(calendar_todo_h todo, long long int start_time) { - int ret_val = CALENDAR_ERROR_NONE; + int ret = CALENDAR_ERROR_NONE; CALENDAR_NULL_ARG_CHECK(todo); - ret_val = calendar_svc_struct_set_tm((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_GMT_START_DATE_TIME, - CAL_TZ_FLAG_LOCAL, &start_time); - if(ret_val != CAL_SUCCESS) { + ret = calendar_svc_struct_set_lli((cal_struct*)((calendar_event_s*)todo)->event_legacy, CALS_VALUE_LLI_DTSTART_UTIME, + start_time); + if(ret != CAL_SUCCESS) { LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } - + return CALENDAR_ERROR_NONE; } -int calendar_todo_get_due_time(calendar_todo_h todo, struct tm *due_time) +int calendar_todo_get_due_time(calendar_todo_h todo, long long int *due_time) { CALENDAR_NULL_ARG_CHECK(todo); CALENDAR_NULL_ARG_CHECK(due_time); - - if(calendar_svc_struct_get_tm((cal_struct*)((calendar_event_s*)todo)->event_legacy, - CAL_VALUE_GMT_END_DATE_TIME, CAL_TZ_FLAG_LOCAL) == NULL) { - LOGE("[%s] CALENDAR_ERROR_NO_DATA(0x%08x)", __FUNCTION__, CALENDAR_ERROR_NO_DATA); + + cal_struct *cs; + long long int lli; + + cs = (cal_struct*)((calendar_event_s*)todo)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + lli = calendar_svc_struct_get_lli(cs, CALS_VALUE_LLI_DTEND_UTIME); + if (lli == CALS_TODO_NO_DUE_DATE) { return CALENDAR_ERROR_NO_DATA; } - memcpy(due_time, calendar_svc_struct_get_tm((cal_struct*)((calendar_event_s*)todo)->event_legacy, - CAL_VALUE_GMT_END_DATE_TIME, CAL_TZ_FLAG_LOCAL), sizeof(struct tm)); // proper memcpy - + *due_time = lli; return CALENDAR_ERROR_NONE; } -int calendar_todo_set_due_time(calendar_todo_h todo, struct tm due_time) +int calendar_todo_set_due_time(calendar_todo_h todo, long long int due_time) { - int ret_val = CALENDAR_ERROR_NONE; + int ret = CALENDAR_ERROR_NONE; CALENDAR_NULL_ARG_CHECK(todo); - ret_val = calendar_svc_struct_set_tm((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_GMT_END_DATE_TIME, - CAL_TZ_FLAG_LOCAL, &due_time); - if(ret_val != CAL_SUCCESS) { + ret = calendar_svc_struct_set_lli((cal_struct*)((calendar_event_s*)todo)->event_legacy, CALS_VALUE_LLI_DTEND_UTIME, + due_time); + if(ret != CAL_SUCCESS) { LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); return CALENDAR_ERROR_INVALID_PARAMETER; } - + return CALENDAR_ERROR_NONE; } -int calendar_foreach_todo_from_db(calendar_foreach_query_todo_cb callback, void *user_data) +int calendar_todo_get_total_count_from_db(int calendar_book_db_id, int todo_priority, int todo_status, int *count) { - CALENDAR_NULL_ARG_CHECK(callback); + CALENDAR_NULL_ARG_CHECK(count); + + int ret; + cal_iter *iter = NULL; + *count = 0; + + ret = calendar_svc_todo_get_iter(calendar_book_db_id, + todo_priority, todo_status, CALS_TODO_LIST_ORDER_END_DATE, &iter); + + if (CAL_SUCCESS != ret) { + LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_DB_FAILED); + return CALENDAR_ERROR_DB_FAILED; + } + + if ((ret = _get_count_from_legacy_iter(__FUNCTION__, iter, count)) + != CALENDAR_ERROR_NONE) + return ret; - return _calendar_todo_foreach(callback, ALL_ACCOUNT_ID, ALL_CALENDAR_ID, user_data); + return CALENDAR_ERROR_NONE; } -int calendar_query_todo_by_calendar(calendar_foreach_query_todo_cb callback, int calendar_db_id, void *user_data) + +int calendar_todo_get_total_count_by_duedate_range(int calendar_book_db_id, // TODO + long long int start_duedate_range, long long int end_duedate_range, + int todo_priority, int todo_status, int *count) { - CALENDAR_NULL_ARG_CHECK(callback); - CONTACTS_INVALID_ARG_CHECK(calendar_db_id < 1); - int account_db_id = _calendar_get_account_db_id(calendar_db_id); - CONTACTS_INVALID_ARG_CHECK(account_db_id == -2); - - return _calendar_todo_foreach(callback, account_db_id, calendar_db_id, user_data); + CALENDAR_NULL_ARG_CHECK(count); + + int ret; + + ret = calendar_svc_todo_get_count_by_period(calendar_book_db_id, + start_duedate_range, end_duedate_range, + todo_priority, todo_status, count); + if (ret != CAL_SUCCESS) { + LOGE("Failed to get count by period"); + return CALENDAR_ERROR_DB_FAILED; + } + + if (*count < 1) { + LOGD("No data"); +// return CALENDAR_ERROR_NO_DATA; check s1-7153 + } + return CALENDAR_ERROR_NONE; +} + +int calendar_todo_free_todo_array(calendar_todo_h *todo_array) +{ + int i; + CALENDAR_NULL_ARG_CHECK(todo_array); + + for (i = 0; todo_array[i]; i++) { + calendar_svc_struct_free(((cal_struct**)&((calendar_event_s*)(todo_array[i]))->event_legacy)); + } + free(todo_array); + return CALENDAR_ERROR_NONE; +} + +int calendar_todo_free_modified_todo_array(pcalendar_modified_todo_s *modified_todo_array) +{ + CALENDAR_NULL_ARG_CHECK(modified_todo_array); + + int i = 0; + pcalendar_modified_todo_s *p; + + p = modified_todo_array; + + if (p) { + while (p[i]) { + free(p[i]); + i++; + } + free(p); + } + + return CALENDAR_ERROR_NONE; +} + +int calendar_todo_search_todo_by_calendar_book(int calendar_book_db_id, + int todo_priority, int todo_status, calendar_todo_h **todo_array, int *length) +{ + CALENDAR_NULL_ARG_CHECK(todo_array); + CALENDAR_NULL_ARG_CHECK(length); + + int ret; + cal_iter *iter = NULL; + *todo_array = NULL; + *length = 0; + + ret = calendar_svc_todo_get_iter(calendar_book_db_id, + todo_priority, todo_status, CALS_TODO_LIST_ORDER_END_DATE, &iter); + + if (CAL_SUCCESS != ret) { + LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_DB_FAILED); + return CALENDAR_ERROR_DB_FAILED; + } + + if ((ret = _get_h_array_from_legacy_iter(__FUNCTION__, iter, todo_array, length)) + != CALENDAR_ERROR_NONE) + return ret; + + return CALENDAR_ERROR_NONE; +} + +int calendar_todo_search_todo_by_duedate_range(int calendar_book_db_id, + long long int start_duedate_range, long long int end_duedate_range, + int todo_priority, int todo_status, calendar_todo_h **todo_array, int *length) +{ + CALENDAR_NULL_ARG_CHECK(todo_array); + CALENDAR_NULL_ARG_CHECK(length); + + int ret; + cal_iter *iter = NULL; + *todo_array = NULL; + *length = 0; + + ret = calendar_svc_todo_get_list_by_period(calendar_book_db_id, + start_duedate_range, end_duedate_range, + todo_priority, todo_status, &iter); + + if (CAL_SUCCESS != ret) { + LOGE("[%s] CALLENDAR_ERROR_DB_FAILED(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_DB_FAILED); + return CALENDAR_ERROR_DB_FAILED; + } + + if ((ret = _get_h_array_from_legacy_iter(__FUNCTION__, iter, todo_array, length)) + != CALENDAR_ERROR_NONE) + return ret; + + return CALENDAR_ERROR_NONE; } -int calendar_get_from_db(int calendar_db_id, calendar_h *calendar) +int calendar_todo_search_todo_by_version(int calendar_book_db_id, int calendar_db_version, + pcalendar_modified_todo_s **modified_todo_array, int *length) { - CONTACTS_INVALID_ARG_CHECK(calendar_db_id < 1); + CALENDAR_NULL_ARG_CHECK(modified_todo_array); + CALENDAR_NULL_ARG_CHECK(length); + + int i, ret; + int is_error = 0; + GList *l = NULL; + GList *cursor; + cal_iter *iter = NULL; + cal_struct *cs = NULL; + calendar_modified_todo_s *cmt; + pcalendar_modified_todo_s *p; + *length = 0; + + ret = calendar_svc_todo_get_changes(calendar_book_db_id, calendar_db_version, &iter); + if (CAL_SUCCESS != ret) { + LOGE("[%s] CALLENDAR_ERROR_DB_FAILED(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_DB_FAILED); + return CALENDAR_ERROR_DB_FAILED; + } + + /* get event_db_id and append to glist */ + while (calendar_svc_iter_next(iter) == CAL_SUCCESS) { + if(calendar_svc_iter_get_info(iter, &cs) != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY); + is_error = 1; + break; + } + + cmt = calloc(1, sizeof(calendar_modified_todo_s)); + if (cmt == NULL) { + LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY); + is_error = 1; + break; + } + + cmt->modified_status = calendar_svc_struct_get_int(cs, CALS_STRUCT_UPDATED_INT_TYPE); + cmt->todo_db_id = calendar_svc_struct_get_int(cs, CALS_STRUCT_UPDATED_INT_ID); + cmt->calendar_db_version = calendar_svc_struct_get_int(cs, + CALS_STRUCT_UPDATED_INT_VERSION); + cmt->calendar_book_db_id = calendar_svc_struct_get_int(cs, + CALS_STRUCT_UPDATED_INT_CALENDAR_ID); + + l = g_list_append(l, cmt); + calendar_svc_struct_free(&cs); + } + calendar_svc_iter_remove(&iter); + + if (is_error) { + LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY); + g_list_free_full(l, free); + return CALENDAR_ERROR_OUT_OF_MEMORY; + } + + /* malloc array and fill data */ + *length = g_list_length(l); + + /* plus 1 to set end of array as checking id -1 */ + p = calloc(*length + 1, sizeof(pcalendar_modified_todo_s)); + if (p == NULL) { + g_list_free_full(l, free); + return CALENDAR_ERROR_OUT_OF_MEMORY; + } + + cursor = l; + for (i = 0; cursor; i++) { + p[i] = (pcalendar_modified_todo_s)(cursor->data); + cursor = g_list_next(cursor); + } + /* free list after allocation */ + g_list_free(l); + + /* fill NULL pointer to indicate end of array */ + p[i] = NULL; + + *modified_todo_array = p; + return CALENDAR_ERROR_NONE; +} + +int calendar_book_get_from_db(int calendar_db_id, calendar_book_h *calendar) +{ + CALENDAR_INVALID_ARG_CHECK(calendar_db_id < 1); CALENDAR_NULL_ARG_CHECK(calendar); *calendar = malloc(sizeof(calendar_event_s)); @@ -2124,25 +3203,98 @@ int calendar_get_from_db(int calendar_db_id, calendar_h *calendar) return CALENDAR_ERROR_NONE; } -int calendar_destroy(calendar_h calendar) +int calendar_book_create(calendar_book_h *calendar) +{ + CALENDAR_NULL_ARG_CHECK(calendar); + + *calendar = malloc(sizeof(calendar_event_s)); + if (*calendar == NULL) { + LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY); + return CALENDAR_ERROR_OUT_OF_MEMORY; + } + + memset(*calendar, 0, sizeof(calendar_event_s)); + (*(calendar_event_s**)calendar)->event_legacy = (calendar_event_legacy_s*)(calendar_svc_struct_new(CAL_STRUCT_CALENDAR)); + return CALENDAR_ERROR_NONE; +} + +int calendar_book_insert_to_db(calendar_book_h calendar, int *calendar_db_id) +{ + CALENDAR_NULL_ARG_CHECK(calendar); + int index = -1; + + index = calendar_svc_insert( + (cal_struct*)((calendar_event_s*)calendar)->event_legacy + ); + *calendar_db_id = index; + return CALENDAR_ERROR_NONE; +} + +int calendar_book_update_to_db(calendar_book_h calendar) +{ + CALENDAR_NULL_ARG_CHECK(calendar); + + int ret = CALENDAR_ERROR_NONE; + + if((cal_struct*)((calendar_event_s*)calendar)->event_legacy == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + ret = calendar_svc_update( + (cal_struct*)((calendar_event_s*)calendar)->event_legacy + ); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); + return CALENDAR_ERROR_DB_FAILED; + } + + return CALENDAR_ERROR_NONE; +} + +// TOREM +int calendar_book_set_is_default(calendar_book_h calendar, bool is_default) { CALENDAR_NULL_ARG_CHECK(calendar); - int ret_val = CALENDAR_ERROR_NONE; +/* + is_default = calendar_svc_struct_get_int( + (cal_struct*)((calendar_event_s*)calendar)->event_legacy, + CAL_TABLE_INT_VISIBILITY); +*/ + + return CALENDAR_ERROR_NONE; +} + +int calendar_book_set_is_visible(calendar_book_h calendar, bool is_visible) +{ + CALENDAR_NULL_ARG_CHECK(calendar); + + is_visible = calendar_svc_struct_get_int( + (cal_struct*)((calendar_event_s*)calendar)->event_legacy, + CAL_TABLE_INT_VISIBILITY); - ret_val = calendar_svc_struct_free((cal_struct **)&((calendar_event_s*)calendar)->event_legacy); - - if (ret_val != CAL_SUCCESS) { + return CALENDAR_ERROR_NONE; +} + +int calendar_book_destroy(calendar_book_h calendar) +{ + CALENDAR_NULL_ARG_CHECK(calendar); + int ret = CALENDAR_ERROR_NONE; + + ret = calendar_svc_struct_free((cal_struct **)&((calendar_event_s*)calendar)->event_legacy); + + if (ret != CAL_SUCCESS) { LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); - ret_val = CALENDAR_ERROR_INVALID_PARAMETER; + ret = CALENDAR_ERROR_INVALID_PARAMETER; } else { free(calendar); - ret_val = CALENDAR_ERROR_NONE; + ret = CALENDAR_ERROR_NONE; } - return ret_val; + return ret; } -int calendar_get_db_id(calendar_h calendar, int *calendar_db_id) +int calendar_book_get_db_id(calendar_book_h calendar, int *calendar_db_id) { CALENDAR_NULL_ARG_CHECK(calendar); CALENDAR_NULL_ARG_CHECK(calendar_db_id); @@ -2153,7 +3305,7 @@ int calendar_get_db_id(calendar_h calendar, int *calendar_db_id) return CALENDAR_ERROR_NONE; } -int calendar_get_is_default(calendar_h calendar, bool *is_default) +int calendar_book_get_is_default(calendar_book_h calendar, bool *is_default) { CALENDAR_NULL_ARG_CHECK(calendar); CALENDAR_NULL_ARG_CHECK(is_default); @@ -2167,18 +3319,40 @@ int calendar_get_is_default(calendar_h calendar, bool *is_default) return CALENDAR_ERROR_NONE; } -int calendar_get_name(calendar_h calendar, char **calendar_name) +int calendar_book_get_name(calendar_book_h calendar, char **calendar_name) { CALENDAR_NULL_ARG_CHECK(calendar); CALENDAR_NULL_ARG_CHECK(calendar_name); *calendar_name = NULL; - *calendar_name = _calendar_safe_strdup(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)calendar)->event_legacy, CAL_TABLE_TXT_NAME)); + *calendar_name = _calendar_safe_strdup( + calendar_svc_struct_get_str( + (cal_struct*)((calendar_event_s*)calendar)->event_legacy, + CAL_TABLE_TXT_NAME)); return CALENDAR_ERROR_NONE; } -int calendar_get_is_visibile(calendar_h calendar, bool *is_visible) +int calendar_book_set_name(calendar_book_h calendar, const char *calnedar_name) +{ + int ret = CALENDAR_ERROR_NONE; + + CALENDAR_NULL_ARG_CHECK(calendar); + + ret = calendar_svc_struct_set_str( + (cal_struct*)((calendar_event_s*)calendar)->event_legacy, + CAL_TABLE_TXT_NAME, calnedar_name); + + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + return CALENDAR_ERROR_NONE; +} + +int calendar_book_get_is_visible(calendar_book_h calendar, bool *is_visible) { CALENDAR_NULL_ARG_CHECK(calendar); CALENDAR_NULL_ARG_CHECK(is_visible); @@ -2188,87 +3362,362 @@ int calendar_get_is_visibile(calendar_h calendar, bool *is_visible) return CALENDAR_ERROR_NONE; } -int calendar_get_color(calendar_h calendar, unsigned char *red, unsigned char *green, unsigned char *blue) +int calendar_book_set_color(calendar_book_h calendar_book, unsigned char red, unsigned char green, unsigned char blue) +{ + CALENDAR_NULL_ARG_CHECK(calendar_book); + + int ret; + char buf[32] = {0, }; + + snprintf(buf, sizeof(buf), "%d.%d.%d.%d", (int)red, (int)green, (int)blue, 0); + ret = calendar_svc_struct_set_str( + (cal_struct*)((calendar_event_s*)calendar_book)->event_legacy, + CAL_TABLE_TXT_COLOR, buf); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + return CALENDAR_ERROR_NONE; +} + +int calendar_book_unset_color(calendar_book_h calendar_book) +{ + CALENDAR_NULL_ARG_CHECK(calendar_book); + + int ret; + ret = calendar_svc_struct_set_str( + (cal_struct*)((calendar_event_s*)calendar_book)->event_legacy, + CAL_TABLE_TXT_COLOR, ""); + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + return CALENDAR_ERROR_NONE; +} + +int calendar_book_get_color(calendar_book_h calendar, unsigned char *red, unsigned char *green, unsigned char *blue) { CALENDAR_NULL_ARG_CHECK(calendar); CALENDAR_NULL_ARG_CHECK(red); CALENDAR_NULL_ARG_CHECK(green); CALENDAR_NULL_ARG_CHECK(blue); - _calendar_parse_color(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)calendar)->event_legacy, CAL_TABLE_TXT_COLOR), - red, green, blue); + char *color = NULL; + + color = calendar_svc_struct_get_str( + (cal_struct*)((calendar_event_s*)calendar)->event_legacy, CAL_TABLE_TXT_COLOR); + if (color == NULL || strlen(color) < 1) { + *red = *green = *blue = 0; + return CALENDAR_ERROR_NO_DATA; + } + + _calendar_parse_color(color, red, green, blue); return CALENDAR_ERROR_NONE; } -int calendar_get_account_db_id(calendar_h calendar, int *account_db_id) +int calendar_book_get_account_db_id(calendar_book_h calendar, int *account_db_id) { CALENDAR_NULL_ARG_CHECK(calendar); CALENDAR_NULL_ARG_CHECK(account_db_id); - *account_db_id = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)calendar)->event_legacy, CAL_TABLE_INT_ACCOUNT_ID) == 1 ? true : false; + *account_db_id = calendar_svc_struct_get_int( + (cal_struct*)((calendar_event_s*)calendar)->event_legacy, + CAL_TABLE_INT_ACCOUNT_ID) == 1 ? true : false; return CALENDAR_ERROR_NONE; } -int calendar_foreach_calendar_from_db(calendar_foreach_query_calendar_cb callback, void *user_data) +int calendar_book_set_account_db_id(calendar_book_h calendar, int account_db_id) { - CALENDAR_NULL_ARG_CHECK(callback); + int ret = CALENDAR_ERROR_NONE; + + CALENDAR_NULL_ARG_CHECK(calendar); + ret = calendar_svc_struct_set_int( + (cal_struct*)((calendar_event_s*)calendar)->event_legacy, + CAL_TABLE_INT_ACCOUNT_ID, account_db_id); + if (ret != CAL_SUCCESS) + { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + return CALENDAR_ERROR_NONE; +} + +int calendar_book_get_type(calendar_book_h calendar, int *calendar_type) +{ + CALENDAR_NULL_ARG_CHECK(calendar); + CALENDAR_NULL_ARG_CHECK(calendar_type); + + *calendar_type = calendar_svc_struct_get_int( + (cal_struct*)((calendar_event_s*)calendar)->event_legacy, + CAL_TABLE_INT_STORE_TYPE); + return CALENDAR_ERROR_NONE; +} + +int calendar_book_set_type(calendar_book_h calendar, int calendar_type) +{ + int ret = CALENDAR_ERROR_NONE; + + CALENDAR_NULL_ARG_CHECK(calendar); + ret = calendar_svc_struct_set_int( + (cal_struct*)((calendar_event_s*)calendar)->event_legacy, + CAL_TABLE_INT_STORE_TYPE, calendar_type); + if (ret != CAL_SUCCESS) + { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + return CALENDAR_ERROR_NONE; +} + +int calendar_book_free_calendar_book_array(calendar_book_h *calendar_book_array) // TODO +{ + int i; + calendar_book_h c; + + CALENDAR_NULL_ARG_CHECK(calendar_book_array); + + c = calendar_book_array[0]; + for (i = 0; c ; c = calendar_book_array[++i] ) + calendar_book_destroy(c); + free(calendar_book_array); + + return CALENDAR_ERROR_NONE; +} + +//int calendar_foreach_calendar_book_from_db(calendar_foreach_query_calendar_book_cb callback, void *user_data) +//{ +// CALENDAR_NULL_ARG_CHECK(callback); +// +// int ret = CALENDAR_ERROR_NONE; +// cal_iter* iter = NULL; +// bool callback_return = true; +// +// //fetch from DB +// ret = calendar_svc_get_all(ALL_ACCOUNT_ID, ALL_CALENDAR_ID, CAL_STRUCT_CALENDAR, &iter); +// +// if (ret != CAL_SUCCESS) { +// LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); +// return CALENDAR_ERROR_DB_FAILED; +// } +// +// if (iter == NULL) { +// LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); +// return CALENDAR_ERROR_DB_FAILED; +// } else { +// while (calendar_svc_iter_next(iter) == CAL_SUCCESS) { +// cal_struct *calendar_struct = NULL; +// if(calendar_svc_iter_get_info(iter, &calendar_struct) != CAL_SUCCESS) { +// calendar_svc_iter_remove(&iter); +// return CALENDAR_ERROR_NONE; // consider this as no data +// } +// +// if(calendar_struct == NULL) { +// calendar_svc_iter_remove(&iter); +// return CALENDAR_ERROR_NONE; // consider this as no data +// } +// +// calendar_query_calendar_book_s query_data; +// +// query_data.calendar_db_id = calendar_svc_struct_get_int(calendar_struct, CAL_TABLE_INT_INDEX); +// query_data.calendar_name = _calendar_safe_strdup(calendar_svc_struct_get_str(calendar_struct, CAL_TABLE_TXT_NAME)); +// query_data.calendar_is_default = query_data.calendar_db_id == 1 ? true : false; +// query_data.calendar_is_visible = calendar_svc_struct_get_int(calendar_struct, CAL_TABLE_INT_VISIBILITY) == 1 ? true : false; +// _calendar_parse_color(calendar_svc_struct_get_str(calendar_struct, CAL_TABLE_TXT_COLOR), +// &query_data.calendar_color_red, &query_data.calendar_color_green, &query_data.calendar_color_blue); +// query_data.account_db_id = calendar_svc_struct_get_int(calendar_struct, CAL_TABLE_INT_ACCOUNT_ID); +// +// //execute callback +// callback_return = callback(&query_data, user_data); +// +// _calendar_safe_free(query_data.calendar_name); +// +// calendar_svc_struct_free(&calendar_struct); +// +// if(callback_return == false) { +// break; +// } +// } +// calendar_svc_iter_remove(&iter); +// +// return CALENDAR_ERROR_NONE; +// } +// return CALENDAR_ERROR_NONE; +//} + +int calendar_book_get_all_calendar_book(calendar_book_h **calendar_book_array, int *length) +{ + CALENDAR_NULL_ARG_CHECK(calendar_book_array); + CALENDAR_NULL_ARG_CHECK(length); + + int ret = CALENDAR_ERROR_NONE; + cal_iter* iter = NULL; - int ret_val = CALENDAR_ERROR_NONE; - cal_iter* iter = NULL; - bool callback_return = true; + //fetch from DB + ret = calendar_svc_get_all(ALL_ACCOUNT_ID, ALL_CALENDAR_ID, CAL_STRUCT_CALENDAR, &iter); + if (CAL_SUCCESS != ret) { + LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_DB_FAILED); + return CALENDAR_ERROR_DB_FAILED; + } + + if ((ret = _get_h_array_from_legacy_iter(__FUNCTION__, iter, calendar_book_array, length)) + != CALENDAR_ERROR_NONE) + return ret; + + return CALENDAR_ERROR_NONE; +} + +int calendar_book_search_calendar_book_by_account(int account_db_id, calendar_book_h **calendar_book_array, int *length) +{ + CALENDAR_NULL_ARG_CHECK(calendar_book_array); + CALENDAR_NULL_ARG_CHECK(length); + + int ret = CALENDAR_ERROR_NONE; + cal_iter* iter = NULL; //fetch from DB - ret_val = calendar_svc_get_all(ALL_ACCOUNT_ID, ALL_CALENDAR_ID, CAL_STRUCT_CALENDAR, &iter); + ret = calendar_svc_get_all(account_db_id, ALL_CALENDAR_ID, CAL_STRUCT_CALENDAR, &iter); + if (CAL_SUCCESS != ret) { + LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_DB_FAILED); + return CALENDAR_ERROR_DB_FAILED; + } - if (ret_val != CAL_SUCCESS) { - LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); - return CALENDAR_ERROR_DB_FAILED; + if ((ret = _get_h_array_from_legacy_iter(__FUNCTION__, iter, calendar_book_array, length)) + != CALENDAR_ERROR_NONE) + return ret; + + return CALENDAR_ERROR_NONE; + +} + +int calendar_event_get_is_recurrence(calendar_event_h event, bool *is_recurrence) +{ + CALENDAR_NULL_ARG_CHECK(event); + CALENDAR_NULL_ARG_CHECK(is_recurrence); + + int is_recur; + + is_recur = calendar_svc_struct_get_int( + (cal_struct*)((calendar_event_s*)event)->event_legacy, + CALS_VALUE_INT_RRULE_ID); + *is_recurrence = is_recur > 0 ? 1 : 0; + + return CALENDAR_ERROR_NONE; + +} + +int calendar_event_get_all_day_recurrence_until_date(calendar_event_h event, + int *until_year, int *until_month, int *until_day) +{ + int y, m, d; + + CALENDAR_NULL_ARG_CHECK(event); + CALENDAR_NULL_ARG_CHECK(until_year); + CALENDAR_NULL_ARG_CHECK(until_month); + CALENDAR_NULL_ARG_CHECK(until_day); + + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; } - - if (iter == NULL) { - LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); - return CALENDAR_ERROR_DB_FAILED; - } else { - while (calendar_svc_iter_next(iter) == CAL_SUCCESS) { - cal_struct *calendar_struct = NULL; - if(calendar_svc_iter_get_info(iter, &calendar_struct) != CAL_SUCCESS) { - calendar_svc_iter_remove(&iter); - return CALENDAR_ERROR_NONE; // consider this as no data - } - - if(calendar_struct == NULL) { - calendar_svc_iter_remove(&iter); - return CALENDAR_ERROR_NONE; // consider this as no data - } + y = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_RRULE_UNTIL_YEAR); + m = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_RRULE_UNTIL_MONTH); + d = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_RRULE_UNTIL_MDAY); - calendar_query_calendar_s query_data; - - query_data.calendar_db_id = calendar_svc_struct_get_int(calendar_struct, CAL_TABLE_INT_INDEX); - query_data.calendar_name = _calendar_safe_strdup(calendar_svc_struct_get_str(calendar_struct, CAL_TABLE_TXT_NAME)); - query_data.calendar_is_default = query_data.calendar_db_id == 1 ? true : false; - query_data.calendar_is_visible = calendar_svc_struct_get_int(calendar_struct, CAL_TABLE_INT_VISIBILITY) == 1 ? true : false; - _calendar_parse_color(calendar_svc_struct_get_str(calendar_struct, CAL_TABLE_TXT_COLOR), - &query_data.calendar_color_red, &query_data.calendar_color_green, &query_data.calendar_color_blue); - query_data.account_db_id = calendar_svc_struct_get_int(calendar_struct, CAL_TABLE_INT_ACCOUNT_ID); - - //execute callback - callback_return = callback(&query_data, user_data); - - _calendar_safe_free(query_data.calendar_name); - - calendar_svc_struct_free(&calendar_struct); - - if(callback_return == false) { - break; - } - } - calendar_svc_iter_remove(&iter); - - return CALENDAR_ERROR_NONE; - } - return CALENDAR_ERROR_NONE; + if (y == 0 && m == 0 && d == 0) { + return CALENDAR_ERROR_NO_DATA; + } + *until_year = y; + *until_month = m; + *until_day = d; - + return CALENDAR_ERROR_NONE; +} + +int calendar_event_set_all_day_recurrence_until_date(calendar_event_h event, + int until_year, int until_month, int until_day) +{ + CALENDAR_NULL_ARG_CHECK(event); + + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)event)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_RANGE_TYPE, CALS_RANGE_UNTIL); + calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_UNTIL_TYPE, CALS_TIME_LOCALTIME); + calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_UNTIL_YEAR, until_year); + calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_UNTIL_MONTH, until_month); + calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_UNTIL_MDAY, until_day); + + return CALENDAR_ERROR_NONE; +} + +int calendar_todo_unset_start_time(calendar_todo_h todo) +{ + CALENDAR_NULL_ARG_CHECK(todo); + + int ret; + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)todo)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + ret = calendar_svc_struct_set_lli(cs, + CALS_VALUE_LLI_DTSTART_UTIME, CALS_TODO_NO_DUE_DATE); + + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + return CALENDAR_ERROR_NONE; +} + +int calendar_todo_unset_due_time(calendar_todo_h todo) +{ + CALENDAR_NULL_ARG_CHECK(todo); + + int ret; + cal_struct *cs; + + cs = (cal_struct*)((calendar_event_s*)todo)->event_legacy; + if(cs == NULL) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + + ret = calendar_svc_struct_set_lli(cs, + CALS_VALUE_LLI_DTEND_UTIME, CALS_TODO_NO_DUE_DATE); + + if (ret != CAL_SUCCESS) { + LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", + __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER); + return CALENDAR_ERROR_INVALID_PARAMETER; + } + return CALENDAR_ERROR_NONE; } + + diff --git a/src/calendar_private.c b/src/calendar_private.c index 239e2f2..d8ba7dc 100755 --- a/src/calendar_private.c +++ b/src/calendar_private.c @@ -11,18 +11,19 @@ * 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. + * limitations under the License. */ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <calendar.h> -#include <calendar_private.h> #include <calendar-svc-provider.h> #include <dlog.h> +#include "calendar_private.h" +#include "calendar.h" + #ifdef LOG_TAG #undef LOG_TAG #endif @@ -35,7 +36,7 @@ GList* _calendar_glist_next_until_not_deleted(GList* list) { if(list == NULL) return NULL; - + GList* glist = list; cal_value* value = glist->data; if(value == NULL) @@ -55,146 +56,210 @@ GList* _calendar_glist_next_until_not_deleted(GList* list) return glist; } -int _calendar_event_foreach(calendar_foreach_query_event_cb callback, int account_db_id, int calendar_db_id, void* user_data) -{ - int ret_val = CALENDAR_ERROR_NONE; - cal_iter* iter = NULL; - bool callback_return = true; - - //fetch from DB - ret_val = calendar_svc_get_all(account_db_id, calendar_db_id, CAL_STRUCT_SCHEDULE, &iter); - - if (ret_val != CAL_SUCCESS) { - LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); - return CALENDAR_ERROR_DB_FAILED; - } - - if (iter == NULL) { - LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); - return CALENDAR_ERROR_DB_FAILED; - } else { - while (calendar_svc_iter_next(iter) == CAL_SUCCESS) { - calendar_event_s cal_event_from_db = {0,}; - if(calendar_svc_iter_get_info(iter, (cal_struct**)&cal_event_from_db.event_legacy) != CAL_SUCCESS) { - calendar_svc_iter_remove(&iter); - return CALENDAR_ERROR_NONE; // consider this as no data - } - - if(cal_event_from_db.event_legacy == NULL) { - calendar_svc_iter_remove(&iter); - return CALENDAR_ERROR_NONE; // consider this as no data - } - - //execute callback - callback_return = callback((calendar_event_h)&cal_event_from_db, user_data); - - calendar_svc_struct_free((cal_struct**)&cal_event_from_db.event_legacy); - - if(callback_return == false) { - break; - } - } - calendar_svc_iter_remove(&iter); - - return CALENDAR_ERROR_NONE; - } - return CALENDAR_ERROR_NONE; -} - -int _calendar_todo_foreach(calendar_foreach_query_todo_cb callback, int account_db_id, int calendar_db_id, void* user_data) -{ - int ret_val = CALENDAR_ERROR_NONE; - cal_iter* iter = NULL; - bool callback_return = true; - - //fetch from DB - ret_val = calendar_svc_get_all(account_db_id, calendar_db_id, CAL_STRUCT_TODO, &iter); - - if (ret_val != CAL_SUCCESS) { - LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); - return CALENDAR_ERROR_DB_FAILED; - } - - if (iter == NULL) { - LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); - return CALENDAR_ERROR_DB_FAILED; - } else { - while (calendar_svc_iter_next(iter) == CAL_SUCCESS) { - calendar_event_s cal_event_from_db = {0,}; - if(calendar_svc_iter_get_info(iter, (cal_struct**)&cal_event_from_db.event_legacy) != CAL_SUCCESS) { - calendar_svc_iter_remove(&iter); - return CALENDAR_ERROR_NONE; // consider this as no data - } - - if(cal_event_from_db.event_legacy == NULL) { - calendar_svc_iter_remove(&iter); - return CALENDAR_ERROR_NONE; // consider this as no data - } - - //execute callback - callback_return = callback((calendar_todo_h)&cal_event_from_db, user_data); - - calendar_svc_struct_free((cal_struct**)&cal_event_from_db.event_legacy); - - if(callback_return == false) { - break; - } - } - calendar_svc_iter_remove(&iter); - - return CALENDAR_ERROR_NONE; - } - return CALENDAR_ERROR_NONE; -} - -int _calendar_event_query(calendar_foreach_query_event_cb callback, int calendar_db_id, char* option, const char* string_to_find, void* user_data) -{ - int ret_val = 0; - cal_iter* iter = NULL; - bool callback_return = true; - - int account_id = _calendar_get_account_db_id(calendar_db_id); - CONTACTS_INVALID_ARG_CHECK(account_id == -2); - - //fetch from DB - ret_val = calendar_svc_find_event_list(account_id, option, string_to_find, &iter); - - if (ret_val != CAL_SUCCESS) { - LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); - return CALENDAR_ERROR_DB_FAILED; - } - - if (iter == NULL) { - LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); - return CALENDAR_ERROR_DB_FAILED; - } else { - while (calendar_svc_iter_next(iter) == CAL_SUCCESS) { - calendar_event_s cal_event_from_db = {0,}; - if(calendar_svc_iter_get_info(iter, (cal_struct**)&cal_event_from_db.event_legacy) != CAL_SUCCESS) { - calendar_svc_iter_remove(&iter); - return CALENDAR_ERROR_NONE; // consider this as no data - } - - if(cal_event_from_db.event_legacy == NULL) { - calendar_svc_iter_remove(&iter); - return CALENDAR_ERROR_NONE; // consider this as no data - } - - //execute callback - callback_return = callback((calendar_event_h)&cal_event_from_db, user_data); - - calendar_svc_struct_free((cal_struct**)&cal_event_from_db.event_legacy); - if(callback_return == false) { - break; - } - } - calendar_svc_iter_remove(&iter); - - return CALENDAR_ERROR_NONE; - } - - return CALENDAR_ERROR_NONE; -} +//int _calendar_event_foreach(calendar_foreach_query_event_cb callback, int account_db_id, int calendar_db_id, void* user_data) +//{ +// int ret_val = CALENDAR_ERROR_NONE; +// cal_iter* iter = NULL; +// bool callback_return = true; +// +// //fetch from DB +// ret_val = calendar_svc_get_all(account_db_id, calendar_db_id, CAL_STRUCT_SCHEDULE, &iter); +// +// if (ret_val != CAL_SUCCESS) { +// LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); +// return CALENDAR_ERROR_DB_FAILED; +// } +// +// if (iter == NULL) { +// LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); +// return CALENDAR_ERROR_DB_FAILED; +// } else { +// while (calendar_svc_iter_next(iter) == CAL_SUCCESS) { +// calendar_event_s cal_event_from_db = {0,}; +// if(calendar_svc_iter_get_info(iter, (cal_struct**)&cal_event_from_db.event_legacy) != CAL_SUCCESS) { +// calendar_svc_iter_remove(&iter); +// return CALENDAR_ERROR_NONE; // consider this as no data +// } +// +// if(cal_event_from_db.event_legacy == NULL) { +// calendar_svc_iter_remove(&iter); +// return CALENDAR_ERROR_NONE; // consider this as no data +// } +// +// //execute callback +// callback_return = callback((calendar_event_h)&cal_event_from_db, user_data); +// +// calendar_svc_struct_free((cal_struct**)&cal_event_from_db.event_legacy); +// +// if(callback_return == false) { +// break; +// } +// } +// calendar_svc_iter_remove(&iter); +// +// return CALENDAR_ERROR_NONE; +// } +// return CALENDAR_ERROR_NONE; +//} +// +//int _calendar_todo_foreach(calendar_foreach_query_todo_cb callback, int account_db_id, int calendar_db_id, void* user_data) +//{ +// int ret_val = CALENDAR_ERROR_NONE; +// cal_iter* iter = NULL; +// bool callback_return = true; +// +// //fetch from DB +// ret_val = calendar_svc_get_all(account_db_id, calendar_db_id, CAL_STRUCT_TODO, &iter); +// +// if (ret_val != CAL_SUCCESS) { +// LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); +// return CALENDAR_ERROR_DB_FAILED; +// } +// +// if (iter == NULL) { +// LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); +// return CALENDAR_ERROR_DB_FAILED; +// } else { +// while (calendar_svc_iter_next(iter) == CAL_SUCCESS) { +// calendar_event_s cal_event_from_db = {0,}; +// if(calendar_svc_iter_get_info(iter, (cal_struct**)&cal_event_from_db.event_legacy) != CAL_SUCCESS) { +// calendar_svc_iter_remove(&iter); +// return CALENDAR_ERROR_NONE; // consider this as no data +// } +// +// if(cal_event_from_db.event_legacy == NULL) { +// calendar_svc_iter_remove(&iter); +// return CALENDAR_ERROR_NONE; // consider this as no data +// } +// +// //execute callback +// callback_return = callback((calendar_todo_h)&cal_event_from_db, user_data); +// +// calendar_svc_struct_free((cal_struct**)&cal_event_from_db.event_legacy); +// +// if(callback_return == false) { +// break; +// } +// } +// calendar_svc_iter_remove(&iter); +// +// return CALENDAR_ERROR_NONE; +// } +// return CALENDAR_ERROR_NONE; +//} +// +//int _calendar_calendar_query(calendar_foreach_query_calendar_book_cb callback, +// int account_db_id, int calendar_db_id, +// const char* string_to_find, void* user_data) +//{ +// int ret_val = 0; +// cal_iter* iter = NULL; +// bool callback_return = true; +// int search_field; +// +// search_field = CALS_SEARCH_FIELD_NONE; +// search_field |= CALS_SEARCH_FIELD_SUMMARY; +// search_field |= CALS_SEARCH_FIELD_DESCRIPTION; +// search_field |= CALS_SEARCH_FIELD_LOCATION; +// search_field |= CALS_SEARCH_FIELD_ATTENDEE; +// +// ret_val = calendar_svc_event_search(search_field, string_to_find, &iter); +// +// if (ret_val != CAL_SUCCESS) { +// LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); +// return CALENDAR_ERROR_DB_FAILED; +// } +// +// if (iter == NULL) { +// LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); +// return CALENDAR_ERROR_DB_FAILED; +// } else { +// while (calendar_svc_iter_next(iter) == CAL_SUCCESS) { +// cal_struct *calendar_struct = NULL; +// if(calendar_svc_iter_get_info(iter, &calendar_struct) != CAL_SUCCESS) { +// calendar_svc_iter_remove(&iter); +// return CALENDAR_ERROR_NONE; // consider this as no data +// } +// +// if(calendar_struct == NULL) { +// calendar_svc_iter_remove(&iter); +// return CALENDAR_ERROR_NONE; // consider this as no data +// } +// +// calendar_query_calendar_book_s query_data; +// +// query_data.calendar_db_id = calendar_svc_struct_get_int(calendar_struct, CAL_TABLE_INT_INDEX); +// query_data.calendar_name = _calendar_safe_strdup(calendar_svc_struct_get_str(calendar_struct, CAL_TABLE_TXT_NAME)); +// query_data.calendar_is_default = query_data.calendar_db_id == 1 ? true : false; +// query_data.calendar_is_visible = calendar_svc_struct_get_int(calendar_struct, CAL_TABLE_INT_VISIBILITY) == 1 ? true : false; +// _calendar_parse_color(calendar_svc_struct_get_str(calendar_struct, CAL_TABLE_TXT_COLOR), +// &query_data.calendar_color_red, &query_data.calendar_color_green, &query_data.calendar_color_blue); +// query_data.account_db_id = calendar_svc_struct_get_int(calendar_struct, CAL_TABLE_INT_ACCOUNT_ID); +// +// //execute callback +// callback_return = callback(&query_data, user_data); +// +// _calendar_safe_free(query_data.calendar_name); +// +// calendar_svc_struct_free(&calendar_struct); +// +// if(callback_return == false) { +// break; +// } +// } +// calendar_svc_iter_remove(&iter); +// +// return CALENDAR_ERROR_NONE; +// } +// return CALENDAR_ERROR_NONE; +//} +// +//int _calendar_event_query(calendar_foreach_query_event_cb callback, int calendar_db_id, char* option, const char* string_to_find, void* user_data) +//{ +// int ret_val = 0; +// cal_iter* iter = NULL; +// bool callback_return = true; +// +// int account_id = _calendar_get_account_db_id(calendar_db_id); +// CALENDAR_INVALID_ARG_CHECK(account_id == -2); +// +// //fetch from DB +// ret_val = calendar_svc_find_event_list(account_id, option, string_to_find, &iter); +// +// if (ret_val != CAL_SUCCESS) { +// LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); +// return CALENDAR_ERROR_DB_FAILED; +// } +// +// if (iter == NULL) { +// LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED); +// return CALENDAR_ERROR_DB_FAILED; +// } +// +// while (calendar_svc_iter_next(iter) == CAL_SUCCESS) { +// calendar_event_s cal_event_from_db = {0,}; +// if(calendar_svc_iter_get_info(iter, (cal_struct**)&cal_event_from_db.event_legacy) != CAL_SUCCESS) { +// calendar_svc_iter_remove(&iter); +// return CALENDAR_ERROR_NONE; // consider this as no data +// } +// +// if(cal_event_from_db.event_legacy == NULL) { +// calendar_svc_iter_remove(&iter); +// return CALENDAR_ERROR_NONE; // consider this as no data +// } +// +// //execute callback +// callback_return = callback((calendar_event_h)&cal_event_from_db, user_data); +// +// calendar_svc_struct_free((cal_struct**)&cal_event_from_db.event_legacy); +// if(callback_return == false) { +// break; +// } +// } +// calendar_svc_iter_remove(&iter); +// +// return CALENDAR_ERROR_NONE; +//} int _calendar_get_account_db_id(int calendar_db_id) { @@ -223,7 +288,7 @@ void _calendar_parse_color(char* color_string, unsigned char* red, unsigned char *red = 0; *green = 0; *blue = 0; - + if(color_string == NULL) { return; } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100755 index 0000000..8536081 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,55 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +SET(fw_name "capi-social-calendar") +SET(fw_test "${fw_name}-test") + +INCLUDE(FindPkgConfig) +pkg_check_modules(${fw_test} REQUIRED glib-2.0 capi-social-calendar calendar-service) +FOREACH(flag ${${fw_test}_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall") +INCLUDE_DIRECTORIES(../include) + +#ADD_EXECUTABLE("social-calendar" calendar_test.c) +#TARGET_LINK_LIBRARIES("social-calendar" ${fw_name} ${${fw_test}_LDFLAGS}) + +aux_source_directory(. sources) +FOREACH(src ${sources}) + GET_FILENAME_COMPONENT(src_name ${src} NAME_WE) + MESSAGE("${src_name}") + ADD_EXECUTABLE(${src_name} ${src}) + TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS} ${fw_name}) +ENDFOREACH() + +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/test/calendar_test.c b/test/calendar_test.c new file mode 100755 index 0000000..aae2235 --- /dev/null +++ b/test/calendar_test.c @@ -0,0 +1,464 @@ +/* + * 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 <tizen.h> +#include <calendar.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <calendar-svc-provider.h> + +static char* calendar_error_e_2_string(int error) +{ + switch(error) + { + case CALENDAR_ERROR_OUT_OF_MEMORY: return "CALENDAR_ERROR_OUT_OF_MEMORY"; + case CALENDAR_ERROR_ITERATOR_END: return "CALENDAR_ERROR_ITERATOR_END"; + case CALENDAR_ERROR_INVALID_PARAMETER: return "CALENDAR_ERROR_INVALID_PARAMETER"; + case CALENDAR_ERROR_DB_FAILED: return "CALENDAR_ERROR_DB_FAILED"; + case CALENDAR_ERROR_NONE: return "CALENDAR_ERROR_NONE"; + case CALENDAR_ERROR_NO_DATA: return "CALENDAR_ERROR_NO_DATA"; + } + return "UNKNOWN-CALENDAR-ERROR"; +} + +void print_detail_event(calendar_event_h event) +{ + char *subject = NULL; + char *name = NULL; + char *description = NULL; + calendar_attendee_iterator_h iterator = NULL; + calendar_attendee_h attendee = NULL; + + printf("\t # ---------------------------------- #\n"); + calendar_event_get_subject(event, &subject); + printf("\t # subject : %s\n", subject); + if(subject != NULL) + free(subject); + calendar_event_get_description(event, &description); + printf("\t # description : %s\n", description); + if(description != NULL) + free(description); + bool is_all_day_event = false; + calendar_event_get_is_all_day_event(event, &is_all_day_event); + if(is_all_day_event == true) { + struct tm start_time; + calendar_event_get_start_time(event, &start_time); + printf("# %d-%d-%d, all day\n", start_time.tm_year + 1900, start_time.tm_mon + 1, start_time.tm_mday); + } else { + struct tm start_time; + struct tm end_time; + calendar_event_get_start_time(event, &start_time); + calendar_event_get_end_time(event, &end_time); + printf("\t # start %d-%d-%d %d:%d:%d\n", start_time.tm_year + 1900, start_time.tm_mon + 1, start_time.tm_mday, + start_time.tm_hour, start_time.tm_min, start_time.tm_sec); + printf("\t # end %d-%d-%d %d:%d:%d\n", end_time.tm_year + 1900, end_time.tm_mon + 1, end_time.tm_mday, + end_time.tm_hour, end_time.tm_min, end_time.tm_sec); + } + + calendar_event_get_attendee_iterator(event, &iterator); + if(iterator == NULL) { + return; + } + while(calendar_attendee_iterator_has_next(iterator)) { + calendar_attendee_iterator_next(&iterator, &attendee); + calendar_attendee_get_name(attendee, &name); + printf("\t # attendee : %s\n", name); + if(name != NULL) + free(name); + } +} + +void print_detail_timezone_event(calendar_event_h event) +{ + char* timezone_name = NULL; + calendar_event_get_timezone(event, &timezone_name); + printf("\t\t timezone_name = %s\n", timezone_name); + if(timezone_name != NULL) + free(timezone_name); +} + +bool get_all_event_callback(calendar_event_h event, void *user_data) +{ + printf("\t #get_all_event_callback()\n"); +// print_detail_event(event); + print_detail_timezone_event(event); + printf("\t #get_all_event_callback() end\n"); + return true; +} + +#include <calendar_private.h> +void test_insert() +{ + calendar_event_h event = NULL; + calendar_attendee_h attendee1 = NULL; + calendar_attendee_h attendee2 = NULL; + + int id = 0; + struct tm tm_now = {0,}; + int ret = 0; + + ret = calendar_event_create(&event); + printf("\tcalendar_event_create() ret = %d\n", ret); + + ret = calendar_event_set_subject(event, "test subject"); + printf("\tcalendar_event_set_subject() ret = %d\n", ret); + + ret = calendar_event_set_description(event, "test description"); + printf("\tcalendar_event_set_description() ret = %d\n", ret); + + ret = calendar_event_set_location(event, "Suwon"); + printf("\tcalendar_event_set_location() ret = %d\n", ret); + + tm_now.tm_year = 112; // 2011 + tm_now.tm_mon = 0; // Aug + tm_now.tm_mday = 26; // 27th + tm_now.tm_hour = 10; // 10am + ret = calendar_event_set_start_time(event, tm_now); + printf("\tcalendar_event_set_start_time() ret = %d\n", ret); + tm_now.tm_hour = 12; // 12am + ret = calendar_event_set_end_time(event, tm_now); + printf("\tcalendar_event_set_end_time() ret = %d\n", ret); +// ret = calendar_event_set_is_all_day_event(event, true); +// printf("\tcalendar_event_set_is_all_day_event() ret = %d\n", ret); + + ret = calendar_event_set_timezone(event, "Asia/Shanghai"); + printf("\tcalendar_set_timezone() ret = %d\n", ret); + + + ret = calendar_event_add_attendee(event, &attendee1); + printf("\tcalendar_event_add_attendee() ret = %d\n", ret); + ret = calendar_attendee_set_name(attendee1, "sora lee"); + printf("\tcalendar_attendee_set_name() ret = %d\n", ret); + ret = calendar_attendee_set_email(attendee1, "sl@sl.com"); + printf("\tcalendar_attendee_set_email() ret = %d\n", ret); +// ret = calendar_event_add_attendee(event, attendee1); +// printf("\tcalendar_event_add_attendee() ret = %d\n", ret); + + + ret = calendar_event_add_attendee(event, &attendee2); + printf("\tcalendar_event_add_attendee() ret = %d\n", ret); + ret = calendar_attendee_set_name(attendee2, "dohyun yoon"); + printf("\tcalendar_attendee_set_name() ret = %d\n", ret); + ret = calendar_attendee_set_email(attendee2, "dy@dy.com"); + printf("\tcalendar_attendee_set_email() ret = %d\n", ret); +// ret = calendar_event_add_attendee(event, attendee2); +// printf("\tcalendar_event_add_attendee() ret = %d\n", ret); + + calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_INT_CALENDAR_ID, 2); + calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_INT_ACCOUNT_ID, 1); + ret = calendar_event_insert_to_db(event, 1, &id); + printf("\tcalendar_event_insert_to_db() ret = %d, id = %d\n", ret, id); + + ret = calendar_event_destroy(event); + printf("\tcalendar_event_destroy() ret = %d\n", ret); +} + +int g_recurrence_event_id = 0; + +void test_insert2() +{ + calendar_event_h event = NULL; + calendar_attendee_h attendee1 = NULL; + calendar_attendee_h attendee2 = NULL; + + int id = 0; + struct tm tm_start = {0}; + struct tm tm_end = {0}; + struct tm tm_recurrence = {0}; + int ret = 0; + + ret = calendar_event_create(&event); + printf("\tcalendar_event_create() ret = %d\n", ret); + + ret = calendar_event_set_subject(event, "Hospital"); + printf("\tcalendar_event_set_subject() ret = %d\n", ret); + + ret = calendar_event_set_description(event, "I have to"); + printf("\tcalendar_event_set_description() ret = %d\n", ret); + + ret = calendar_event_set_location(event, "Seoul"); + printf("\tcalendar_event_set_location() ret = %d\n", ret); + + tm_start.tm_year = 112; // 2011 + tm_start.tm_mon = 0; // may + tm_start.tm_mday = 23; // 23th + tm_start.tm_hour = 10; // 10am + + tm_end.tm_year = 112; // 2011 + tm_end.tm_mon = 0; // may + tm_end.tm_mday = 23; // 23th + tm_end.tm_hour = 11; // 11am + ret = calendar_event_set_start_time(event, tm_start); + printf("\tcalendar_event_set_start_time() ret = %d\n", ret); + ret = calendar_event_set_end_time(event, tm_end); + printf("\tcalendar_event_set_end_time() ret = %d\n", ret); + + memcpy(&tm_recurrence, &tm_end, sizeof(tm_recurrence)); // proper memcpy + tm_recurrence.tm_mon = 9; // Oct + ret = calendar_event_set_recurrence_until_date(event, tm_recurrence); + printf("\tcalendar_event_set_recurrence_until_date() ret = %d\n", ret); + ret = calendar_event_set_recurrence_frequency(event, CALENDAR_RECURRENCE_WEEKLY); + printf("\tcalendar_event_set_recurrence_frequency() ret = %d\n", ret); + ret = calendar_event_set_recurrence_week_flag(event, CALENDAR_WEEK_FLAG_MON | CALENDAR_WEEK_FLAG_WED); + printf("\tcalendar_event_set_recurrence_week_flag() ret = %d\n", ret); + int week_flag = 0; + ret = calendar_event_get_recurrence_week_flag(event, &week_flag); + printf("\tcalendar_event_set_recurrence_week_flag() ret = %d, week_flag=%d\n", ret, week_flag); + + ret = calendar_event_add_attendee(event, &attendee1); + printf("\tcalendar_event_add_attendee() ret = %d\n", ret); + ret = calendar_attendee_set_name(attendee1, "Andrew Lim"); + printf("\tcalendar_attendee_set_name() ret = %d\n", ret); + ret = calendar_attendee_set_email(attendee1, "al@al.com"); + printf("\tcalendar_attendee_set_email() ret = %d\n", ret); +// ret = calendar_event_add_attendee(event, attendee1); +// printf("\tcalendar_event_add_attendee() ret = %d\n", ret); + + + ret = calendar_event_add_attendee(event, &attendee2); + printf("\tcalendar_event_add_attendee() ret = %d\n", ret); + ret = calendar_attendee_set_name(attendee2, "Big joe"); + printf("\tcalendar_attendee_set_name() ret = %d\n", ret); + ret = calendar_attendee_set_email(attendee2, "bj@bj.com"); + printf("\tcalendar_attendee_set_email() ret = %d\n", ret); +// ret = calendar_event_add_attendee(event, attendee2); +// printf("\tcalendar_event_add_attendee() ret = %d\n", ret); + + print_detail_event(event); + + ret = calendar_event_insert_to_db(event, 1, &id); + printf("\tcalendar_event_insert_to_db() ret = %d, id = %d\n", ret, id); + g_recurrence_event_id = id; + +// ret = calendar_event_delete_from_db(id); +// printf("\tcalendar_event_delete_from_db() ret = %d, id = %d\n", ret, id); + +// ret = calendar_event_set_subject(event, "G. Hospital"); +// printf("\tcalendar_event_set_subject() ret = %d\n", ret); + +// ret = calendar_event_update_to_db(event); +// printf("\tcalendar_event_update_to_db() ret = %d, id = %d\n", ret, id); + + ret = calendar_event_destroy(event); + printf("\tcalendar_event_destroy() ret = %d\n", ret); +} + +bool delete_all_event_callback(calendar_event_h event, void *user_data) +{ + int id = -1; + int ret = 0; + ret = calendar_event_get_db_id(event, &id); + printf("\tcalendar_event_get_db_id() ret = %d\n", ret); + ret = calendar_event_delete_from_db(id); + printf("\tcalendar_event_delete_from_db() ret = %d\n", ret); + return true; +} + +void test_delete_all() +{ + printf("-------- test_delete_all ------------\n"); + calendar_foreach_event_from_db(delete_all_event_callback, NULL); + printf("-------- test_delete_all END --------\n"); +} + +void subscribing(void* data) +{ + +} + +void vcalendar_test() +{ + calendar_event_h event = NULL; + calendar_attendee_h attendee1 = NULL; + calendar_attendee_h attendee2 = NULL; + char* vcalendar_stream = NULL; + + struct tm tm_now = {0,}; + int ret = 0; + + ret = calendar_event_create(&event); + + ret = calendar_event_set_subject(event, "test subject"); + + ret = calendar_event_set_description(event, "test description"); + + ret = calendar_event_set_location(event, "Suwon"); + + tm_now.tm_year = 111; // 2011 + tm_now.tm_mon = 7; // Aug + tm_now.tm_mday = 26; // 27th + tm_now.tm_hour = 10; // 10am + ret = calendar_event_set_start_time(event, tm_now); + tm_now.tm_hour = 12; // 12am + ret = calendar_event_set_end_time(event, tm_now); + + ret = calendar_event_set_timezone(event, "Asia/Shanghai"); + + + ret = calendar_event_add_attendee(event, &attendee1); + ret = calendar_attendee_set_name(attendee1, "sora lee"); + ret = calendar_attendee_set_email(attendee1, "sl@sl.com"); + + + ret = calendar_event_add_attendee(event, &attendee2); + ret = calendar_attendee_set_name(attendee2, "dohyun yoon"); + ret = calendar_attendee_set_email(attendee2, "dy@dy.com"); + + ret = calendar_event_get_vcalendar_from_event(event, &vcalendar_stream); + printf("calendar_event_get_vcalendar_from_event, ret = %d\n", ret); + printf("vcalendar_stream = %s\n", vcalendar_stream); + calendar_event_destroy(event); + + ret = calendar_event_get_from_vcalendar(vcalendar_stream, &event); + printf("calendar_event_get_from_vcalendar, ret = %d\n", ret); + char* subject = NULL; + ret = calendar_event_get_subject(event, &subject); + printf("calendar_event_get_subject, ret = %d, subject = %s\n", ret, subject); + free(subject); + + free(vcalendar_stream); + calendar_event_destroy(event); +} +/* +void print_recurrence_event_date() +{ + int ret = 0; + calendar_event_h event = NULL; + ret = calendar_event_get_from_db(g_recurrence_event_id, &event); + printf("calendar_event_get_from_db, ret = %d\n", ret); + struct tm start = {0}; + struct tm end = {0}; + struct tm next_start = {0}; + struct tm next_end = {0}; + calendar_event_get_start_time(event, &start); + calendar_event_get_end_time(event, &end); + printf("%.4d-%.2d-%.2d %.2d:%.2d:%.2d ~ %.4d-%.2d-%.2d %.2d:%.2d:%.2d\n", + start.tm_year + 1900, start.tm_mon + 1, start.tm_mday + 1, start.tm_hour, start.tm_min, start.tm_sec, + end.tm_year + 1900, end.tm_mon + 1, end.tm_mday + 1, end.tm_hour, end.tm_min, end.tm_sec + ); + while(calendar_event_get_next_recurrence_time(event, start, end, &next_start, &next_end) == CALENDAR_ERROR_NONE) { + memcpy(&start, &next_start, sizeof(struct tm)); + memcpy(&end, &next_end, sizeof(struct tm)); + + printf("%.4d-%.2d-%.2d %.2d:%.2d:%.2d ~ %.4d-%.2d-%.2d %.2d:%.2d:%.2d\n", + start.tm_year + 1900, start.tm_mon + 1, start.tm_mday + 1, start.tm_hour, start.tm_min, start.tm_sec, + end.tm_year + 1900, end.tm_mon + 1, end.tm_mday + 1, end.tm_hour, end.tm_min, end.tm_sec + ); + + } +} +*/ + +int main(int argc, char *argv[]) +{ + printf("test 20110711 1\n"); + +// vcalendar_test(); +#if 0 + int ret = 0; + ret = calendar_connect(); + printf("calendar_connect() ret = %d\n", ret); + + cal_iter* iter = NULL; + ret = calendar_svc_get_all(ALL_ACCOUNT_ID, 0, CAL_STRUCT_CALENDAR, &iter); + printf("calendar_svc_get_all() ret = %d\n", ret); + if (iter == NULL) { + printf("iter == NULL\n"); + } else { + while (calendar_svc_iter_next(iter) == CAL_SUCCESS) { + cal_struct *calendar = NULL; + if(calendar_svc_iter_get_info(iter, &calendar) != CAL_SUCCESS) { + calendar_svc_iter_remove(&iter); + printf("calendar_svc_iter_get_info(iter, (cal_struct**)&calendar) != CAL_SUCCESS\n"); + } + + int index = calendar_svc_struct_get_int(calendar, CAL_TABLE_INT_INDEX); + int account_id = calendar_svc_struct_get_int(calendar, CAL_TABLE_INT_ACCOUNT_ID); + char* calendar_id = calendar_svc_struct_get_str(calendar, CAL_TABLE_TXT_CALENDAR_ID); + char* calendar_name = calendar_svc_struct_get_str(calendar, CAL_TABLE_TXT_NAME); + int visibility = calendar_svc_struct_get_int(calendar, CAL_TABLE_INT_VISIBILITY); + printf("index = %d, account_id = %d, calendar_id = %s, calendar_name = %s, visibility = %d\n", index, account_id, calendar_id, calendar_name, visibility); + + calendar_svc_struct_free(&calendar); + } + calendar_svc_iter_remove(&iter); + } + + printf("-------------------------------------\n"); + iter = NULL; + ret = calendar_svc_get_all(LOCAL_ACCOUNT_ID, DEFAULT_CALENDAR_ID, CAL_STRUCT_CALENDAR, &iter); + printf("calendar_svc_get_all() ret = %d\n", ret); + if (iter == NULL) { + printf("iter == NULL\n"); + } else { + while (calendar_svc_iter_next(iter) == CAL_SUCCESS) { + cal_struct *calendar = NULL; + if(calendar_svc_iter_get_info(iter, &calendar) != CAL_SUCCESS) { + calendar_svc_iter_remove(&iter); + printf("calendar_svc_iter_get_info(iter, (cal_struct**)&calendar) != CAL_SUCCESS\n"); + } + + int index = calendar_svc_struct_get_int(calendar, CAL_TABLE_INT_INDEX); + int account_id = calendar_svc_struct_get_int(calendar, CAL_TABLE_INT_ACCOUNT_ID); + char* calendar_id = calendar_svc_struct_get_str(calendar, CAL_TABLE_TXT_CALENDAR_ID); + char* calendar_name = calendar_svc_struct_get_str(calendar, CAL_TABLE_TXT_NAME); + int visibility = calendar_svc_struct_get_int(calendar, CAL_TABLE_INT_VISIBILITY); + printf("index = %d, account_id = %d, calendar_id = %s, calendar_name = %s, visibility = %d\n", index, account_id, calendar_id, calendar_name, visibility); + + calendar_svc_struct_free(&calendar); + } + calendar_svc_iter_remove(&iter); + } + + ret = calendar_disconnect(); + printf("calendar_disconnect() ret = %d\n", ret); +#endif + + +#if 1 + int ret = 0; + ret = calendar_connect(); + printf("calendar_connect() ret = %d\n", ret); + + + test_delete_all(); +// calendar_event_api_test(); + + test_insert(); + test_insert2(); +// print_recurrence_event_date(g_recurrence_event_id); + + printf("-------- calendar_foreach_event_from_db ------------\n"); + ret = calendar_foreach_event_from_db(get_all_event_callback, NULL); + printf("-------- calendar_foreach_event_from_db END --------\n"); + +// printf("------------- find description -------------\n"); +// ret = calendar_query_event_by_description(get_all_event_callback, "test", NULL); +// printf("------------- find description END ---------\n"); +// printf("\tcalendar_foreach_calendar_event_from_db() ret = %d\n", ret); + +// printf("-------- calendar_foreach_timezone ------------\n"); +// ret = calendar_foreach_timezone(get_all_timezone_cb, NULL); +// printf("-------- calendar_foreach_timezone END --------\n"); + + ret = calendar_disconnect(); + printf("calendar_disconnect() ret = %d\n", ret); +#endif + calendar_error_e_2_string(0); + return 0; +} + |