CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(calendar-service C CXX)
-#IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
-# SET(CMAKE_BUILD_TYPE "Release")
-#ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
-#MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
-
SET(DEST_INCLUDE_DIR "include/calendar-service")
SET(SRC_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/include")
SET(EXEC_PREFIX "\${prefix}")
SET(LIBDIR ${LIB_INSTALL_DIR})
SET(INCLUDEDIR "\${prefix}/${DEST_INCLUDE_DIR}")
-SET(VERSION_MAJOR 0)
-SET(VERSION "${VERSION_MAJOR}.1.15")
+
+EXECUTE_PROCESS(COMMAND build-util/generator.sh)
#INCLUDE_DIRECTORIES(${SRC_INCLUDE_DIR})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -I${CMAKE_SOURCE_DIR}/include")
INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED glib-2.0 sqlite3 vconf dlog db-util alarm-service icu-i18n appsvc bundle libtzplatform-config)
+pkg_check_modules(pkgs REQUIRED
+ glib-2.0
+ db-util
+ sqlite3
+ vconf
+ alarm-service
+ icu-i18n
+ contacts-service2
+ security-server
+ capi-appfw-package-manager
+ libtzplatform-config
+ )
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -fdata-sections -ffunction-sections -Wl,--gc-sections")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
#SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
-#SET(CMAKE_C_FLAGS_RELEASE "-mabi=aapcs-linux -march=armv7-a -msoft-float -O2")
ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
-#header
+# Install header file
FILE(GLOB HEADER_FILES ${SRC_INCLUDE_DIR}/calendar*.h)
-INSTALL(FILES ${HEADER_FILES} DESTINATION ${INCLUDEDIR})
INSTALL(FILES ${HEADER_FILES} DESTINATION ${INCLUDEDIR}2)
-# for immigration
-SET(IMMIGRATION "calendar-service2")
-CONFIGURE_FILE(calendar.pc.in calendar.pc @ONLY)
-INSTALL(FILES calendar.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+# Install DB file
+FILE(GLOB DB_FILES ${CMAKE_SOURCE_DIR}/build-util/.calendar-svc.db*)
+INSTALL(FILES ${DB_FILES} DESTINATION /opt/usr/dbspace)
-ADD_SUBDIRECTORY(schema)
+#ADD_SUBDIRECTORY(schema)
ADD_SUBDIRECTORY(client)
ADD_SUBDIRECTORY(server)
-#ADD_SUBDIRECTORY(native)
-ADD_SUBDIRECTORY(dft)
/*
* Calendar Service
*
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2010 - 2012 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.
if (fp == NULL)
exit(EXIT_FAILURE);
- printf("static const char *schema_query = \"\\\n");
-
do{
c = fgetc(fp);
switch (c)
break;
}
}while(EOF != c);
- printf("\";\n");
exit(EXIT_SUCCESS);
}
CC = gcc
-REQUIRED_PKG = db-util
+REQUIRED_PKG =
CFLAGS = -g -Wall #-fprofile-arcs -ftest-coverage
LDFLAGS =
ifdef REQUIRED_PKG
CFLAGS += $(shell pkg-config --cflags $(REQUIRED_PKG))
- LDFLAGS += -L$(shell pkg-config --variable=libdir $(REQUIRED_PKG))
+ LDFLAGS += -L$(pkg-config --libs $(REQUIRED_PKG))
LDFLAGS += $(shell pkg-config --libs $(REQUIRED_PKG))
-
endif
-SRCS = $(wildcard ../initdb.c)
+SRCS = $(wildcard *.c)
OBJECTS = $(SRCS:.c=.o)
TARGETS = $(OBJECTS:.o=)
#
# Calendar Service
#
-# Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+# Copyright (c) 2010 - 2012 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.
#!/bin/sh
-echo "###### API Generator #####"
+echo "###### DB Generator #####"
-cd header-gen
+cd build-util
make
-# Schema
-./schema-header-gen ../schema.sql > ../schema.h
+# Make DB schema for generating DB file when running calendar server daemon
+echo "static const char *schema_query = \"\\" > ../server/schema.h
+./DB-schema-gen ./schema.sql >> ../server/schema.h
+echo \"\; >> ../server/schema.h
-make clean
-
-# Make DB
-cd ../db-gen
-make
-../initdb ../
+# Make DB file at builing time
+sqlite3 .calendar-svc.db < schema.sql
make clean
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
+PRAGMA user_version = 105;
CREATE TABLE schedule_table
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
-account_id INTEGER,
type INTEGER,
summary TEXT,
description TEXT,
latitude DOUBLE,
longitude DOUBLE,
email_id INTEGER,
-availability INTEGER,
created_time INTEGER,
completed_time INTEGER,
progress INTEGER,
is_deleted INTEGER DEFAULT 0,
dtstart_type INTEGER,
dtstart_utime INTEGER,
-dtstart_datetime TEXT,
+dtstart_datetime DATE,
dtstart_tzid TEXT,
dtend_type INTEGER,
dtend_utime INTEGER,
-dtend_datetime TEXT,
+dtend_datetime DATE,
dtend_tzid TEXT,
last_mod INTEGER,
rrule_id INTEGER DEFAULT 0,
sync_data1 TEXT,
sync_data2 TEXT,
sync_data3 TEXT,
-sync_data4 TEXT
+sync_data4 TEXT,
+has_exception INTEGER DEFAULT 0,
+has_extended INTEGER DEFAULT 0,
+freq INTEGER DEFAULT 0,
+is_allday INTEGER DEFAULT 0
);
CREATE INDEX sch_idx1 ON schedule_table(type);
CREATE INDEX sch_idx2 ON schedule_table(calendar_id);
-CREATE TRIGGER trg_sch_del AFTER DELETE ON schedule_table
+CREATE INDEX sch_idx3 ON schedule_table(sync_data4);
+
+CREATE TRIGGER trg_original_mod AFTER UPDATE OF is_deleted ON schedule_table
+ BEGIN
+ DELETE FROM normal_instance_table WHERE event_id = (SELECT rowid FROM schedule_table WHERE original_event_id = old.id);
+ DELETE FROM allday_instance_table WHERE event_id = (SELECT rowid FROM schedule_table WHERE original_event_id = old.id);
+ UPDATE schedule_table SET is_deleted = 1 WHERE original_event_id = old.id;
+ END;
+
+CREATE TRIGGER trg_schedule_del AFTER DELETE ON schedule_table
BEGIN
DELETE FROM rrule_table WHERE event_id = old.id;
DELETE FROM alarm_table WHERE event_id = old.id;
DELETE FROM extended_table WHERE record_id = old.id AND record_type = 3;
END;
-CREATE TRIGGER trig_original_mod AFTER UPDATE OF is_deleted ON schedule_table
+-- type + 1: is cal_record_type_e = cal_sch_type_e + 1
+CREATE TRIGGER trg_schedule_del2 AFTER DELETE ON schedule_table
+ WHEN old.is_deleted = 0 AND old.calendar_id = (SELECT id FROM calendar_table WHERE id = old.calendar_id)
BEGIN
- DELETE FROM normal_instance_table WHERE event_id = (SELECT rowid FROM schedule_table WHERE original_event_id = old.id);
- DELETE FROM allday_instance_table WHERE event_id = (SELECT rowid FROM schedule_table WHERE original_event_id = old.id);
- UPDATE schedule_table SET is_deleted = 1 WHERE original_event_id = old.id;
+ INSERT INTO deleted_table VALUES(old.id, old.type + 1, old.calendar_id, (SELECT ver FROM version_table) + 1, old.created_ver, old.original_event_id);
+ END;
+
+CREATE TRIGGER trg_schedule_del3 AFTER DELETE ON schedule_table
+ WHEN old.is_deleted = 1 AND old.calendar_id = (SELECT id FROM calendar_table WHERE id = old.calendar_id)
+ BEGIN
+ INSERT INTO deleted_table VALUES(old.id, old.type + 1, old.calendar_id, old.changed_ver, old.created_ver, old.original_event_id);
END;
CREATE TABLE rrule_table
dtend_utime INTEGER
);
CREATE INDEX n_i_idx1 ON normal_instance_table(event_id, dtstart_utime);
-CREATE INDEX n_i_idx2 ON normal_instance_table(dtstart_utime);
+--CREATE INDEX n_i_idx2 ON normal_instance_table(dtstart_utime);
+CREATE INDEX n_i_idx3 ON normal_instance_table (dtend_utime, dtstart_utime);
+CREATE INDEX n_i_idx4 ON normal_instance_table (dtstart_utime, dtend_utime);
CREATE TABLE allday_instance_table
(
event_id INTEGER,
-dtstart_datetime TEXT,
-dtend_datetime TEXT
+dtstart_datetime DATE,
+dtend_datetime DATE
);
CREATE INDEX a_i_idx1 ON allday_instance_table(event_id, dtstart_datetime);
-CREATE INDEX a_i_idx2 ON allday_instance_table(dtstart_datetime);
+--CREATE INDEX a_i_idx2 ON allday_instance_table(dtstart_datetime);
+CREATE INDEX a_i_idx3 ON allday_instance_table (dtend_datetime, dtstart_datetime);
+CREATE INDEX a_i_idx4 ON allday_instance_table (dtstart_datetime, dtend_datetime);
CREATE TABLE attendee_table
(
attendee_email TEXT,
attendee_number TEXT,
attendee_status INTEGER,
-attendee_type INTEGER,
attendee_ct_index INTEGER,
attendee_role INTEGER,
attendee_rsvp INTEGER,
attendee_group TEXT,
attendee_delegator_uri TEXT,
-attendee_delegate_uri TEXT,
-attendee_uid TEXT
+attendee_uid TEXT,
+attendee_cutype INTEGER,
+attendee_delegatee_uri TEXT,
+attendee_member TEXT
);
+CREATE INDEX attendee_idx1 on attendee_table(event_id);
+
CREATE TABLE calendar_table
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
sync_data2 TEXT,
sync_data3 TEXT,
sync_data4 TEXT,
-deleted INTEGER DEFAULT 0
+deleted INTEGER DEFAULT 0,
+mode INTEGER DEFAULT 0,
+owner_label TEXT
);
CREATE TABLE timezone_table
CREATE TABLE alarm_table
(
event_id INTEGER,
-alarm_time INTEGER,
remind_tick INTEGER,
remind_tick_unit INTEGER,
-alarm_tone TEXT,
alarm_description TEXT,
alarm_type INTEGER,
-alarm_id INTEGER default 0
+alarm_id INTEGER DEFAULT 0,
+alarm_summary TEXT,
+alarm_action INTEGER DEFAULT 0,
+alarm_attach TEXT,
+alarm_utime INTEGER,
+alarm_datetime DATE
);
-CREATE TABLE reminder_table
-(
-pkgname TEXT NOT NULL,
-onoff INTEGER default 1,
-key TEXT,
-value TEXT
-);
-INSERT INTO reminder_table VALUES('org.tizen.calendar', 1, NULL, NULL);
-
CREATE TABLE extended_table
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
schedule_id INTEGER,
schedule_type INTEGER,
calendar_id INTEGER,
-deleted_ver INTEGER
+deleted_ver INTEGER,
+created_ver INTEGER,
+original_event_id INTEGER DEFAULT -1
);
CREATE INDEX deleted_schedule_ver_idx ON deleted_table(deleted_ver);
CREATE TABLE version_table
(
-ver INTEGER PRIMARY KEY
+ver INTEGER PRIMARY KEY,
+contacts_ver INTEGER DEFAULT 0
);
-INSERT INTO version_table VALUES(0);
+INSERT INTO version_table VALUES(0, 0);
-INSERT INTO calendar_table VALUES(1,0,0,'Default event calendar' ,0,'224.167.79.255',0,1,1,0,-1,1,0,0,0,0,0);
-INSERT INTO calendar_table VALUES(2,0,0,'Default todo calendar' ,0,'41.177.227.255',0,1,1,0,-1,2,0,0,0,0,0);
-INSERT INTO calendar_table VALUES(3,0,0,'Default birthday calendar',0,'141.17.27.255' ,0,1,0,0,-1,1,0,0,0,0,0);
+INSERT INTO calendar_table VALUES(1,0,0,'Default event calendar' ,0,'224.167.79.255',0,1,1,0,-1,1,0,0,0,0,0,0,'calendar');
+INSERT INTO calendar_table VALUES(2,0,0,'Default todo calendar' ,0,'41.177.227.255',0,1,1,0,-1,2,0,0,0,0,0,0,'calendar');
+INSERT INTO calendar_table VALUES(3,0,0,'Default birthday calendar',0,'141.17.27.255' ,0,1,0,0,-1,1,0,0,0,0,0,0,'calendar');
--- /dev/null
+<manifest>
+ <define>
+ <domain name="calendar-service"/>
+ <provide>
+ <label name="calendar-service::initdb" />
+ <label name="calendar-service::db" />
+ <label name="calendar-service::svc" />
+ </provide>
+ <request>
+ <smack request="calendar-service::initdb" type="rwxatl"/>
+ <smack request="calendar-service::db" type="rwxatl"/>
+ <smack request="calendar-service::svc" type="rwxatl"/>
+ <smack request="sys-assert::core" type="rwxat"/>
+ <smack request="contacts-service::svc" type="rw"/>
+ <smack request="pkgmgr" type="r"/>
+ <smack request="pkgmgr::db" type="rw"/>
+ <smack request="libaccounts-svc" type="r"/>
+ <smack request="libaccounts-svc::db" type="rl"/>
+ <smack request="libaccounts-svc::check_read" type="r"/>
+ <smack request="alarm-server::alarm" type="rw"/>
+ <smack request="security-server::api-cookie-check" type="w"/>
+ </request>
+ </define>
+ <assign>
+ <filesystem path="/usr/lib/*" label="_" exec_label="none"/>
+ <filesystem path="/opt/usr/dbspace/.calendar-svc.db" label="calendar-service::db" />
+ <filesystem path="/opt/usr/dbspace/.calendar-svc.db-journal" label="calendar-service::db" />
+ <filesystem path="/opt/usr/data/calendar-svc/.CALENDAR_SVC_CALENDAR_CHANGED" label="calendar-service::svc" />
+ <filesystem path="/opt/usr/data/calendar-svc/.CALENDAR_SVC_EVENT_CHANGED" label="calendar-service::svc" />
+ <filesystem path="/opt/usr/data/calendar-svc/.CALENDAR_SVC_TODO_CHANGED" label="calendar-service::svc" />
+ </assign>
+ <request>
+ <domain name="calendar-service" />
+ </request>
+</manifest>
+++ /dev/null
-# Package Information for pkg-config
-
-prefix=@PREFIX@
-exec_prefix=@EXEC_PREFIX@
-libdir=@LIBDIR@
-includedir=@INCLUDEDIR@
-
-Name: @PROJECT_NAME@
-Description: @PROJECT_NAME@ library
-Version: @VERSION@
-Requires: glib-2.0 alarm-service
-Libs: -L${libdir} -l@PROJECT_NAME@
-Cflags: -I${includedir}
+++ /dev/null
-# Package Information for pkg-config
-
-prefix=@PREFIX@
-exec_prefix=@EXEC_PREFIX@
-libdir=@LIBDIR@
-includedir=@INCLUDEDIR@
-
-Name: @IMMIGRATION@
-Description: @IMMIGRATION@ library
-Version: @VERSION@
-Requires: glib-2.0 alarm-service
-Libs: -L${libdir} -l@IMMIGRATION@
-Cflags: -I${includedir}
${CMAKE_SOURCE_DIR}/common/ipc/cal_ipc_marshal_calendar.c
${CMAKE_SOURCE_DIR}/common/ipc/cal_ipc_marshal_event.c
${CMAKE_SOURCE_DIR}/common/ipc/cal_ipc_marshal_instance_allday.c
+ ${CMAKE_SOURCE_DIR}/common/ipc/cal_ipc_marshal_instance_allday_extended.c
${CMAKE_SOURCE_DIR}/common/ipc/cal_ipc_marshal_instance_normal.c
+ ${CMAKE_SOURCE_DIR}/common/ipc/cal_ipc_marshal_instance_normal_extended.c
${CMAKE_SOURCE_DIR}/common/ipc/cal_ipc_marshal_search.c
${CMAKE_SOURCE_DIR}/common/ipc/cal_ipc_marshal_timezone.c
${CMAKE_SOURCE_DIR}/common/ipc/cal_ipc_marshal_todo.c
${CMAKE_SOURCE_DIR}/common/cal_record_updated_info.c
${CMAKE_SOURCE_DIR}/common/cal_record_instance_normal.c
${CMAKE_SOURCE_DIR}/common/cal_record_instance_allday.c
+ ${CMAKE_SOURCE_DIR}/common/cal_record_instance_normal_extended.c
+ ${CMAKE_SOURCE_DIR}/common/cal_record_instance_allday_extended.c
${CMAKE_SOURCE_DIR}/common/cal_record_extended.c
${CMAKE_SOURCE_DIR}/common/cal_view.c
${CMAKE_SOURCE_DIR}/common/cal_filter.c
)
INCLUDE(FindPkgConfig)
-pkg_check_modules(service2_pkgs REQUIRED pims-ipc dlog capi-base-common)
+pkg_check_modules(service2_pkgs REQUIRED
+ pims-ipc
+ dlog
+ capi-base-common
+ )
FOREACH(flag ${service2_pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
ADD_LIBRARY(${CALSVC2} SHARED ${SRCS})
-SET_TARGET_PROPERTIES(${CALSVC2} PROPERTIES SOVERSION ${VERSION_MAJOR})
-SET_TARGET_PROPERTIES(${CALSVC2} PROPERTIES VERSION ${VERSION})
+SET_TARGET_PROPERTIES(${CALSVC2} PROPERTIES SOVERSION ${MAJORVER})
+SET_TARGET_PROPERTIES(${CALSVC2} PROPERTIES VERSION ${FULLVER})
TARGET_LINK_LIBRARIES(${CALSVC2} ${service2_pkgs_LDFLAGS})
INSTALL(TARGETS ${CALSVC2} DESTINATION ${LIB_INSTALL_DIR})
#include <stdlib.h> //calloc
#include <pims-ipc.h>
#include <glib-object.h> //g_type_init
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
#include "calendar_service.h"
#include "calendar_db.h"
-#include "calendar_types2.h"
+#include "calendar_types.h"
#include "cal_internal.h"
#include "cal_typedef.h"
#include "cal_client_ipc.h"
typedef struct {
- calendar_db_result_cb callback;
- void *user_data;
+ calendar_db_result_cb callback;
+ void *user_data;
}cal_client_db_async_userdata_s;
typedef struct {
- calendar_db_insert_result_cb callback;
- void *user_data;
+ calendar_db_insert_result_cb callback;
+ void *user_data;
}cal_client_db_async_insert_userdata_s;
#define CAL_IPC_DATA_FREE(ptr) \
- do { \
- if (ptr) \
- pims_ipc_data_destroy(ptr); \
- ptr = NULL; \
- } while(0)
+ do { \
+ if (ptr) \
+ pims_ipc_data_destroy(ptr); \
+ ptr = NULL; \
+ } while(0)
+
+#define __CAL_CLIENT_ACCESS_MAX 10
+#define __CAL_CLIENT_ALLOW_USEC 25000
+
+#define CAL_LIMIT_ACCESS_FRONT(uri) \
+ int is_schedule = 0; \
+do { \
+ if (!strncmp(uri, CALENDAR_VIEW_EVENT, strlen(CALENDAR_VIEW_EVENT))) \
+ { \
+ is_schedule = 1; \
+ struct timeval hold = {0}; \
+ struct timeval diff = {0}; \
+ gettimeofday(&hold, NULL); \
+ timersub(&hold, &__g_release_time, &diff); \
+ DBG("%ld.%ld sec", diff.tv_sec, diff.tv_usec); \
+ if (diff.tv_sec / 1000 == 0 && diff.tv_usec < __CAL_CLIENT_ALLOW_USEC) \
+ { \
+ if (__g_access_count < __CAL_CLIENT_ACCESS_MAX) \
+ { \
+ __g_access_count++; \
+ DBG("--count (%d)", __g_access_count); \
+ } \
+ else \
+ { \
+ DBG("--sleep"); \
+ usleep(200000); \
+ __g_access_count = 0; \
+ timerclear(&__g_release_time); \
+ } \
+ } \
+ else \
+ { \
+ DBG("--reset"); \
+ __g_access_count = 0; \
+ timerclear(&__g_release_time); \
+ } \
+ } \
+} while(0)
+
+#define CAL_LIMIT_ACCESS_BACK \
+ do { \
+ if (is_schedule) \
+ { \
+ gettimeofday(&__g_release_time, NULL); \
+ } \
+ } while(0)
+
+
+static int __g_access_count;
+static struct timeval __g_release_time;
void __cal_client_db_insert_records_cb(pims_ipc_h ipc, pims_ipc_data_h data_out, void *userdata);
void __cal_client_db_insert_records_cb(pims_ipc_h ipc, pims_ipc_data_h data_out, void *userdata)
{
- cal_client_db_async_insert_userdata_s *sync_data = (cal_client_db_async_insert_userdata_s *)userdata;
- int ret = CALENDAR_ERROR_NONE;
-
- int count = 0;
- int *id = 0;
-
- if (sync_data == NULL)
- {
- ERR("sync_data is NULL");
- return;
- }
-
- if (data_out)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(data_out,&size);
-
- if (ret == CALENDAR_ERROR_NONE )
- {
- int i=0;
- unsigned int size = 0;
-
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(data_out,&size);
- _cal_client_ipc_set_change_version(transaction_ver);
-
- count = *(int*) pims_ipc_data_get(data_out,&size);
-
- id = calloc(1, sizeof(int)*count);
-
- if (id)
- {
- for(i=0;i<count;i++)
- {
- id[i] = *(unsigned int*) pims_ipc_data_get(data_out,&size);
- }
- }
- else
- {
- count = 0;
- }
- }
-
- }
- else
- {
- ret = CALENDAR_ERROR_IPC;
- ERR("async cb is no data");
- }
-
- if (sync_data->callback)
- {
- sync_data->callback(ret, id, count, sync_data->user_data);
- }
+ cal_client_db_async_insert_userdata_s *sync_data = (cal_client_db_async_insert_userdata_s *)userdata;
+ int ret = CALENDAR_ERROR_NONE;
+
+ int count = 0;
+ int *id = 0;
+
+ if (sync_data == NULL)
+ {
+ ERR("sync_data is NULL");
+ return;
+ }
+
+ if (data_out)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(data_out,&size);
+
+ if (ret == CALENDAR_ERROR_NONE )
+ {
+ int i=0;
+ unsigned int size = 0;
+
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(data_out,&size);
+ _cal_client_ipc_set_change_version(transaction_ver);
+
+ count = *(int*) pims_ipc_data_get(data_out,&size);
+
+ id = calloc(1, sizeof(int)*count);
+
+ if (id)
+ {
+ for(i=0;i<count;i++)
+ {
+ id[i] = *(unsigned int*) pims_ipc_data_get(data_out,&size);
+ }
+ }
+ else
+ {
+ count = 0;
+ }
+ }
+
+ }
+ else
+ {
+ ret = CALENDAR_ERROR_IPC;
+ ERR("async cb is no data");
+ }
+
+ if (sync_data->callback)
+ {
+ sync_data->callback(ret, id, count, sync_data->user_data);
+ }
_cal_inotify_call_pending_callback();
- CAL_FREE(id);
+ CAL_FREE(id);
- CAL_FREE(sync_data);
+ CAL_FREE(sync_data);
- return ;
+ return ;
}
void __cal_client_db_update_records_cb(pims_ipc_h ipc, pims_ipc_data_h data_out, void *userdata)
{
- cal_client_db_async_userdata_s *sync_data = (cal_client_db_async_userdata_s *)userdata;
- int ret = CALENDAR_ERROR_NONE;
-
- if (sync_data == NULL)
- {
- ERR("sync_data is NULL");
- return;
- }
-
- if (data_out)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(data_out,&size);
-
- if (ret == CALENDAR_ERROR_NONE)
- {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(data_out,&size);
- _cal_client_ipc_set_change_version(transaction_ver);
- }
- }
- else
- {
- ret = CALENDAR_ERROR_IPC;
- ERR("async cb is no data");
- }
-
- if (sync_data->callback)
- {
- sync_data->callback(ret, sync_data->user_data);
- }
+ cal_client_db_async_userdata_s *sync_data = (cal_client_db_async_userdata_s *)userdata;
+ int ret = CALENDAR_ERROR_NONE;
+
+ if (sync_data == NULL)
+ {
+ ERR("sync_data is NULL");
+ return;
+ }
+
+ if (data_out)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(data_out,&size);
+
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(data_out,&size);
+ _cal_client_ipc_set_change_version(transaction_ver);
+ }
+ }
+ else
+ {
+ ret = CALENDAR_ERROR_IPC;
+ ERR("async cb is no data");
+ }
+
+ if (sync_data->callback)
+ {
+ sync_data->callback(ret, sync_data->user_data);
+ }
_cal_inotify_call_pending_callback();
- CAL_FREE(sync_data);
+ CAL_FREE(sync_data);
- return ;
+ return ;
}
void __cal_client_db_delete_records_cb(pims_ipc_h ipc, pims_ipc_data_h data_out, void *userdata)
{
- cal_client_db_async_userdata_s *sync_data = (cal_client_db_async_userdata_s *)userdata;
- int ret = CALENDAR_ERROR_NONE;
-
- if (sync_data == NULL)
- {
- ERR("sync_data is NULL");
- return;
- }
-
- if (data_out)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(data_out,&size);
-
- if (ret == CALENDAR_ERROR_NONE)
- {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(data_out,&size);
- _cal_client_ipc_set_change_version(transaction_ver);
- }
- }
- else
- {
- ret = CALENDAR_ERROR_IPC;
- ERR("async cb is no data");
- }
-
- if (sync_data->callback)
- {
- sync_data->callback(ret, sync_data->user_data);
- }
+ cal_client_db_async_userdata_s *sync_data = (cal_client_db_async_userdata_s *)userdata;
+ int ret = CALENDAR_ERROR_NONE;
+
+ if (sync_data == NULL)
+ {
+ ERR("sync_data is NULL");
+ return;
+ }
+
+ if (data_out)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(data_out,&size);
+
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(data_out,&size);
+ _cal_client_ipc_set_change_version(transaction_ver);
+ }
+ }
+ else
+ {
+ ret = CALENDAR_ERROR_IPC;
+ ERR("async cb is no data");
+ }
+
+ if (sync_data->callback)
+ {
+ sync_data->callback(ret, sync_data->user_data);
+ }
_cal_inotify_call_pending_callback();
- CAL_FREE(sync_data);
+ CAL_FREE(sync_data);
- return ;
+ return ;
}
void __cal_client_db_insert_vcalendars_cb(pims_ipc_h ipc, pims_ipc_data_h data_out, void *userdata)
{
- cal_client_db_async_insert_userdata_s *sync_data = (cal_client_db_async_insert_userdata_s *)userdata;
- int ret = CALENDAR_ERROR_NONE;
-
- int count = 0;
- int *id = 0;
-
- if (sync_data == NULL)
- {
- ERR("sync_data is NULL");
- return;
- }
-
- if (data_out)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(data_out,&size);
-
- if (ret == CALENDAR_ERROR_NONE )
- {
- int i=0;
- unsigned int size = 0;
-
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(data_out,&size);
- _cal_client_ipc_set_change_version(transaction_ver);
-
- count = *(int*) pims_ipc_data_get(data_out,&size);
-
- id = calloc(1, sizeof(int)*count);
-
- if (id)
- {
- for(i=0;i<count;i++)
- {
- id[i] = *(unsigned int*) pims_ipc_data_get(data_out,&size);
- }
- }
- else
- {
- count = 0;
- }
- }
- }
- else
- {
- ret = CALENDAR_ERROR_IPC;
- ERR("async cb is no data");
- }
-
- if (sync_data->callback)
- {
- sync_data->callback(ret, id, count, sync_data->user_data);
- }
-
- _cal_inotify_call_pending_callback();
-
- CAL_FREE(id);
-
- CAL_FREE(sync_data);
-
- return ;
+ cal_client_db_async_insert_userdata_s *sync_data = (cal_client_db_async_insert_userdata_s *)userdata;
+ int ret = CALENDAR_ERROR_NONE;
+
+ int count = 0;
+ int *id = 0;
+
+ if (sync_data == NULL)
+ {
+ ERR("sync_data is NULL");
+ return;
+ }
+
+ if (data_out)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(data_out,&size);
+
+ if (ret == CALENDAR_ERROR_NONE )
+ {
+ int i=0;
+ unsigned int size = 0;
+
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(data_out,&size);
+ _cal_client_ipc_set_change_version(transaction_ver);
+
+ count = *(int*) pims_ipc_data_get(data_out,&size);
+
+ id = calloc(1, sizeof(int)*count);
+
+ if (id)
+ {
+ for(i=0;i<count;i++)
+ {
+ id[i] = *(unsigned int*) pims_ipc_data_get(data_out,&size);
+ }
+ }
+ else
+ {
+ count = 0;
+ }
+ }
+ }
+ else
+ {
+ ret = CALENDAR_ERROR_IPC;
+ ERR("async cb is no data");
+ }
+
+ if (sync_data->callback)
+ {
+ sync_data->callback(ret, id, count, sync_data->user_data);
+ }
+
+ _cal_inotify_call_pending_callback();
+
+ CAL_FREE(id);
+
+ CAL_FREE(sync_data);
+
+ return ;
}
void __cal_client_db_replace_vcalendars_cb(pims_ipc_h ipc, pims_ipc_data_h data_out, void *userdata)
{
- cal_client_db_async_userdata_s *sync_data = (cal_client_db_async_userdata_s *)userdata;
- int ret = CALENDAR_ERROR_NONE;
-
- if (sync_data == NULL)
- {
- ERR("sync_data is NULL");
- return;
- }
-
- if (data_out)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(data_out,&size);
-
- if (ret == CALENDAR_ERROR_NONE)
- {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(data_out,&size);
- _cal_client_ipc_set_change_version(transaction_ver);
- }
- }
- else
- {
- ret = CALENDAR_ERROR_IPC;
- ERR("async cb is no data");
- }
-
- if (sync_data->callback)
- {
- sync_data->callback(ret, sync_data->user_data);
- }
-
- _cal_inotify_call_pending_callback();
-
- CAL_FREE(sync_data);
-
- return ;
+ cal_client_db_async_userdata_s *sync_data = (cal_client_db_async_userdata_s *)userdata;
+ int ret = CALENDAR_ERROR_NONE;
+
+ if (sync_data == NULL)
+ {
+ ERR("sync_data is NULL");
+ return;
+ }
+
+ if (data_out)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(data_out,&size);
+
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(data_out,&size);
+ _cal_client_ipc_set_change_version(transaction_ver);
+ }
+ }
+ else
+ {
+ ret = CALENDAR_ERROR_IPC;
+ ERR("async cb is no data");
+ }
+
+ if (sync_data->callback)
+ {
+ sync_data->callback(ret, sync_data->user_data);
+ }
+
+ _cal_inotify_call_pending_callback();
+
+ CAL_FREE(sync_data);
+
+ return ;
}
void __cal_client_db_replace_records_cb(pims_ipc_h ipc, pims_ipc_data_h data_out, void *userdata)
{
- cal_client_db_async_userdata_s *sync_data = (cal_client_db_async_userdata_s *)userdata;
- int ret = CALENDAR_ERROR_NONE;
-
- if (sync_data == NULL)
- {
- ERR("sync_data is NULL");
- return;
- }
-
- if (data_out)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(data_out,&size);
-
- if (ret == CALENDAR_ERROR_NONE)
- {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(data_out,&size);
- _cal_client_ipc_set_change_version(transaction_ver);
- }
- }
- else
- {
- ret = CALENDAR_ERROR_IPC;
- ERR("async cb is no data");
- }
-
- if (sync_data->callback)
- {
- sync_data->callback(ret, sync_data->user_data);
- }
-
- _cal_inotify_call_pending_callback();
-
- CAL_FREE(sync_data);
-
- return ;
+ cal_client_db_async_userdata_s *sync_data = (cal_client_db_async_userdata_s *)userdata;
+ int ret = CALENDAR_ERROR_NONE;
+
+ if (sync_data == NULL)
+ {
+ ERR("sync_data is NULL");
+ return;
+ }
+
+ if (data_out)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(data_out,&size);
+
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(data_out,&size);
+ _cal_client_ipc_set_change_version(transaction_ver);
+ }
+ }
+ else
+ {
+ ret = CALENDAR_ERROR_IPC;
+ ERR("async cb is no data");
+ }
+
+ if (sync_data->callback)
+ {
+ sync_data->callback(ret, sync_data->user_data);
+ }
+
+ _cal_inotify_call_pending_callback();
+
+ CAL_FREE(sync_data);
+
+ return ;
}
API int calendar_db_insert_record( calendar_record_h record, int* id )
{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- retvm_if(record==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"record is NULL");
-
- CAL_RECORD_RESET_COMMON((cal_record_s*)record);
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- ret = _cal_ipc_marshal_record(record,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
-
- // ipc call
- if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_INSERT_RECORD, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
-
- CAL_IPC_DATA_FREE(indata);
-
- if (outdata)
- {
- //int id = 0;
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (ret == CALENDAR_ERROR_NONE)
- {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- _cal_client_ipc_set_change_version(transaction_ver);
- //unsigned int property_id = 0;
- int out_id = 0;
- //property_id = *(unsigned int*)pims_ipc_data_get(outdata,&size);
- out_id = *(int*)pims_ipc_data_get(outdata,&size);
- //_cal_record_set_int(record,property_id,id);
- if (id)
- {
- *id = out_id;
- }
- }
-
- pims_ipc_data_destroy(outdata);
- }
- else
- {
- ERR("ipc outdata is NULL");
- return CALENDAR_ERROR_IPC;
- }
-
- return ret;
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ retvm_if(record==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"record is NULL");
+
+ CAL_RECORD_RESET_COMMON((cal_record_s*)record);
+
+ cal_record_s *rec = (cal_record_s *)record;
+ CAL_LIMIT_ACCESS_FRONT(rec->view_uri);
+
+ // make indata
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL)
+ {
+ ERR("ipc data created fail !");
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+ ret = _cal_ipc_marshal_record(record,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+
+ // ipc call
+ if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_INSERT_RECORD, indata, &outdata) != 0)
+ {
+ ERR("pims_ipc_call failed");
+ CAL_IPC_DATA_FREE(indata);
+ return CALENDAR_ERROR_IPC;
+ }
+
+ CAL_IPC_DATA_FREE(indata);
+
+ if (outdata)
+ {
+ //int id = 0;
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ _cal_client_ipc_set_change_version(transaction_ver);
+ //unsigned int property_id = 0;
+ int out_id = 0;
+ //property_id = *(unsigned int*)pims_ipc_data_get(outdata,&size);
+ out_id = *(int*)pims_ipc_data_get(outdata,&size);
+ //_cal_record_set_int(record,property_id,id);
+ if (id)
+ {
+ *id = out_id;
+ }
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+ else
+ {
+ ERR("ipc outdata is NULL");
+ return CALENDAR_ERROR_IPC;
+ }
+
+ CAL_LIMIT_ACCESS_BACK;
+ return ret;
}
API int calendar_db_get_record( const char* view_uri, int id, calendar_record_h* out_record )
{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- retvm_if(view_uri==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"view_uri is NULL");
- retvm_if(id<=0,CALENDAR_ERROR_INVALID_PARAMETER,"id <= 0");
- retvm_if(out_record==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"record is NULL");
-
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- ret = _cal_ipc_marshal_char(view_uri,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- ret = _cal_ipc_marshal_int(id,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
-
- // ipc call
- if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_GET_RECORD, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
-
- CAL_IPC_DATA_FREE(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (ret == CALENDAR_ERROR_NONE)
- {
- ret = _cal_ipc_unmarshal_record(outdata,out_record);
- }
-
- pims_ipc_data_destroy(outdata);
- }
- else
- {
- ERR("ipc outdata is NULL");
- return CALENDAR_ERROR_IPC;
- }
-
- return ret;
-}
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
-API int calendar_db_update_record( calendar_record_h record )
-{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- retvm_if(record==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"record is NULL");
-
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- ret = _cal_ipc_marshal_record(record,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
-
- // ipc call
- if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_UPDATE_RECORD, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
-
- CAL_IPC_DATA_FREE(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (ret == CALENDAR_ERROR_NONE)
- {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- _cal_client_ipc_set_change_version(transaction_ver);
- }
-
- pims_ipc_data_destroy(outdata);
- }
- else
- {
- ERR("ipc outdata is NULL");
- return CALENDAR_ERROR_IPC;
- }
-
- return ret;
-}
+ retvm_if(view_uri==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"view_uri is NULL");
+ retvm_if(id<=0,CALENDAR_ERROR_INVALID_PARAMETER,"id <= 0");
+ retvm_if(out_record==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"record is NULL");
-API int calendar_db_delete_record( const char* view_uri, int id )
-{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- retvm_if(view_uri==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"view_uri is NULL");
- retvm_if(id<=0,CALENDAR_ERROR_INVALID_PARAMETER,"id <= 0");
-
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- ret = _cal_ipc_marshal_char(view_uri,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- ret = _cal_ipc_marshal_int(id,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
-
- // ipc call
- if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_DELETE_RECORD, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
-
- CAL_IPC_DATA_FREE(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (ret == CALENDAR_ERROR_NONE)
- {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- _cal_client_ipc_set_change_version(transaction_ver);
- }
-
- pims_ipc_data_destroy(outdata);
- }
- else
- {
- ERR("ipc outdata is NULL");
- return CALENDAR_ERROR_IPC;
- }
-
- return ret;
-}
+ // make indata
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL)
+ {
+ ERR("ipc data created fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+ ret = _cal_ipc_marshal_char(view_uri,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ ret = _cal_ipc_marshal_int(id,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
-API int calendar_db_get_all_records( const char* view_uri, int offset, int limit, calendar_list_h* out_list )
-{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- retvm_if(out_list==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"list is NULL");
- retvm_if(view_uri==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"view_uri is NULL");
-
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
-
- ret = _cal_ipc_marshal_char(view_uri,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- ret = _cal_ipc_marshal_int(offset,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- ret = _cal_ipc_marshal_int(limit,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
-
- // ipc call
- if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_GET_ALL_RECORDS, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
-
- CAL_IPC_DATA_FREE(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (ret == CALENDAR_ERROR_NONE)
- {
- ret = _cal_ipc_unmarshal_list(outdata,out_list);
- }
- pims_ipc_data_destroy(outdata);
- }
- else
- {
- ERR("ipc outdata is NULL");
- return CALENDAR_ERROR_IPC;
- }
-
- return ret;
-}
+ // ipc call
+ if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_GET_RECORD, indata, &outdata) != 0)
+ {
+ ERR("pims_ipc_call failed");
+ CAL_IPC_DATA_FREE(indata);
+ return CALENDAR_ERROR_IPC;
+ }
-API int calendar_db_get_records_with_query( calendar_query_h query, int offset, int limit, calendar_list_h* out_list )
-{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- retvm_if(query==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"query is NULL");
- retvm_if(out_list==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"list is NULL");
-
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- ret = _cal_ipc_marshal_query(query,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- ret = _cal_ipc_marshal_int(offset,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- ret = _cal_ipc_marshal_int(limit,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
-
- // ipc call
- if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_GET_RECORDS_WITH_QUERY, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
-
- CAL_IPC_DATA_FREE(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (ret == CALENDAR_ERROR_NONE)
- {
- ret = _cal_ipc_unmarshal_list(outdata,out_list);
- }
-
- pims_ipc_data_destroy(outdata);
- }
- else
- {
- ERR("ipc outdata is NULL");
- return CALENDAR_ERROR_IPC;
- }
-
- return ret;
-}
+ CAL_IPC_DATA_FREE(indata);
-API int calendar_db_clean_after_sync( int calendar_book_id, int calendar_db_version)
-{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- retvm_if(calendar_book_id <= 0,CALENDAR_ERROR_INVALID_PARAMETER,"calendar_book_id < 0");
-
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- ret = _cal_ipc_marshal_int(calendar_book_id,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- ret = _cal_ipc_marshal_int(calendar_db_version,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
-
- // ipc call
- if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_CLEAN_AFTER_SYNC, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
-
- CAL_IPC_DATA_FREE(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- pims_ipc_data_destroy(outdata);
- }
- else
- {
- ERR("ipc outdata is NULL");
- return CALENDAR_ERROR_IPC;
- }
-
- return ret;
-}
+ if (outdata)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
-API int calendar_db_get_count( const char* view_uri, int *out_count )
-{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- retvm_if(view_uri==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"view_uri is NULL");
- retvm_if(out_count==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"count pointer is NULL");
-
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- ret = _cal_ipc_marshal_char(view_uri,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
-
- // ipc call
- if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_GET_COUNT, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
-
- CAL_IPC_DATA_FREE(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (ret == CALENDAR_ERROR_NONE)
- {
- ret = _cal_ipc_unmarshal_int(outdata,out_count);
- }
-
- pims_ipc_data_destroy(outdata);
- }
- else
- {
- ERR("ipc outdata is NULL");
- return CALENDAR_ERROR_IPC;
- }
-
- return ret;
-}
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ ret = _cal_ipc_unmarshal_record(outdata,out_record);
+ }
-API int calendar_db_get_count_with_query( calendar_query_h query, int *out_count )
-{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- retvm_if(query==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"record is NULL");
-
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- ret = _cal_ipc_marshal_query(query,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
-
- // ipc call
- if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_GET_COUNT_WITH_QUERY, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
-
- CAL_IPC_DATA_FREE(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (ret == CALENDAR_ERROR_NONE)
- {
- ret = _cal_ipc_unmarshal_int(outdata,out_count);
- }
-
- pims_ipc_data_destroy(outdata);
- }
- else
- {
- ERR("ipc outdata is NULL");
- return CALENDAR_ERROR_IPC;
- }
-
- return ret;
+ pims_ipc_data_destroy(outdata);
+ }
+ else
+ {
+ ERR("ipc outdata is NULL");
+ return CALENDAR_ERROR_IPC;
+ }
+
+ return ret;
}
-API int calendar_db_insert_records( calendar_list_h record_list, int** record_id_array, int* count)
+API int calendar_db_update_record( calendar_record_h record )
{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- retvm_if(record_list==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"list is NULL");
-
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- ret = _cal_ipc_marshal_list(record_list,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
-
- if (_cal_client_ipc_call(CAL_IPC_MODULE,CAL_IPC_SERVER_DB_INSERT_RECORDS,
- indata,&outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
-
- CAL_IPC_DATA_FREE(indata);
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (ret == CALENDAR_ERROR_NONE)
- {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- _cal_client_ipc_set_change_version(transaction_ver);
- goto SET_DATA;
- }
-
- pims_ipc_data_destroy(outdata);
- }
- else
- {
- ERR("ipc outdata is NULL");
- return CALENDAR_ERROR_IPC;
- }
-
- return ret;
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
-SET_DATA:
- if (outdata)
- {
- int i=0;
- unsigned int size = 0;
- int *ids = NULL;
-
- if (count && record_id_array)
- {
- *count = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (*count <=0)
- {
- ERR("count is %d",*count);
- count = 0;
- pims_ipc_data_destroy(outdata);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- ids = calloc(1, sizeof(int)*(*count));
-
- if(ids == NULL)
- {
- count = 0;
- ERR("calloc fail");
- pims_ipc_data_destroy(outdata);
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- for(i=0;i<(*count);i++)
- {
- ids[i] = *(int*) pims_ipc_data_get(outdata,&size);
- }
- *record_id_array = ids;
- }
- pims_ipc_data_destroy(outdata);
- }
-
- return ret;
+ retvm_if(record==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"record is NULL");
+
+ cal_record_s *rec = (cal_record_s *)record;
+ CAL_LIMIT_ACCESS_FRONT(rec->view_uri);
+
+ // make indata
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL)
+ {
+ ERR("ipc data created fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+ ret = _cal_ipc_marshal_record(record,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+
+ // ipc call
+ if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_UPDATE_RECORD, indata, &outdata) != 0)
+ {
+ ERR("pims_ipc_call failed");
+ CAL_IPC_DATA_FREE(indata);
+ return CALENDAR_ERROR_IPC;
+ }
+
+ CAL_IPC_DATA_FREE(indata);
+
+ if (outdata)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ _cal_client_ipc_set_change_version(transaction_ver);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+ else
+ {
+ ERR("ipc outdata is NULL");
+ return CALENDAR_ERROR_IPC;
+ }
+
+ CAL_LIMIT_ACCESS_BACK;
+ return ret;
}
-API int calendar_db_insert_records_async(calendar_list_h list, calendar_db_insert_result_cb callback, void *user_data)
+API int calendar_db_delete_record( const char* view_uri, int id )
{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- cal_client_db_async_insert_userdata_s *async_data = NULL;
- calendar_list_h clone_list = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
- retvm_if(list==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"list is NULL");
- retvm_if(callback==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"list is NULL");
+ retvm_if(view_uri==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"view_uri is NULL");
+ retvm_if(id<=0,CALENDAR_ERROR_INVALID_PARAMETER,"id <= 0");
- ret = _cal_list_clone(list, &clone_list);
- if (CALENDAR_ERROR_NONE != ret)
+ CAL_LIMIT_ACCESS_FRONT(view_uri);
+
+ // make indata
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL)
{
- ERR("_cal_list_clone() failed");
+ ERR("ipc data created fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+ ret = _cal_ipc_marshal_char(view_uri,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ ret = _cal_ipc_marshal_int(id,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
return ret;
}
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- calendar_list_destroy(clone_list, true);
- return ret;
- }
- ret = _cal_ipc_marshal_list(clone_list,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- calendar_list_destroy(clone_list, true);
- return ret;
- }
-
- async_data = (cal_client_db_async_insert_userdata_s*)malloc(sizeof(cal_client_db_async_insert_userdata_s));
- if (async_data == NULL)
- {
- ERR("malloc fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- calendar_list_destroy(clone_list, true);
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- async_data->callback = callback;
- async_data->user_data = user_data;
-
- if (_cal_client_ipc_call_async(CAL_IPC_MODULE,CAL_IPC_SERVER_DB_INSERT_RECORDS,
- indata,__cal_client_db_insert_records_cb,async_data) != 0)
- {
- ERR("pims_ipc_call_async failed");
- calendar_list_destroy(clone_list, true);
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
-
- CAL_IPC_DATA_FREE(indata);
-
- calendar_list_destroy(clone_list, true);
-
- return ret;
-}
+ // ipc call
+ if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_DELETE_RECORD, indata, &outdata) != 0)
+ {
+ ERR("pims_ipc_call failed");
+ CAL_IPC_DATA_FREE(indata);
+ return CALENDAR_ERROR_IPC;
+ }
-API int calendar_db_update_records( calendar_list_h record_list)
-{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- retvm_if(record_list==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"record is NULL");
-
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- ret = _cal_ipc_marshal_list(record_list,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
-
- // ipc call
- if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_UPDATE_RECORDS, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
-
- CAL_IPC_DATA_FREE(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (ret == CALENDAR_ERROR_NONE)
- {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- _cal_client_ipc_set_change_version(transaction_ver);
- }
-
- pims_ipc_data_destroy(outdata);
- }
- else
- {
- ERR("ipc outdata is NULL");
- return CALENDAR_ERROR_IPC;
- }
-
- return ret;
+ CAL_IPC_DATA_FREE(indata);
+
+ if (outdata)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ _cal_client_ipc_set_change_version(transaction_ver);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+ else
+ {
+ ERR("ipc outdata is NULL");
+ return CALENDAR_ERROR_IPC;
+ }
+ CAL_LIMIT_ACCESS_BACK;
+
+ return ret;
}
-API int calendar_db_update_records_async( calendar_list_h list, calendar_db_result_cb callback, void *user_data)
+API int calendar_db_get_all_records( const char* view_uri, int offset, int limit, calendar_list_h* out_list )
{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- cal_client_db_async_userdata_s *async_data = NULL;
- calendar_list_h clone_list = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
- retvm_if(list==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"record is NULL");
- retvm_if(callback==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"callback is NULL");
+ retvm_if(out_list==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"list is NULL");
+ retvm_if(view_uri==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"view_uri is NULL");
- ret = _cal_list_clone(list, &clone_list);
- if (CALENDAR_ERROR_NONE != ret)
+ // make indata
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL)
{
- ERR("_cal_list_clone() failed");
+ ERR("ipc data created fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
return ret;
}
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- calendar_list_destroy(clone_list, true);
- return ret;
- }
- ret = _cal_ipc_marshal_list(clone_list,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- calendar_list_destroy(clone_list, true);
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
-
- async_data = (cal_client_db_async_userdata_s*)malloc(sizeof(cal_client_db_async_userdata_s));
- if (async_data == NULL)
- {
- ERR("malloc fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- calendar_list_destroy(clone_list, true);
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- async_data->callback = callback;
- async_data->user_data = user_data;
-
- if (_cal_client_ipc_call_async(CAL_IPC_MODULE,CAL_IPC_SERVER_DB_UPDATE_RECORDS,
- indata,__cal_client_db_update_records_cb,async_data) != 0)
- {
- ERR("pims_ipc_call_async failed");
- calendar_list_destroy(clone_list, true);
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
-
- CAL_IPC_DATA_FREE(indata);
-
- calendar_list_destroy(clone_list, true);
- return ret;
-}
+ ret = _cal_ipc_marshal_char(view_uri,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ ret = _cal_ipc_marshal_int(offset,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ ret = _cal_ipc_marshal_int(limit,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
-API int calendar_db_delete_records(const char* view_uri, int record_id_array[], int count)
-{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
- int i = 0;
-
- retvm_if(view_uri==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"view_uri is NULL");
- retvm_if(record_id_array==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"record_id_array is NULL");
- retvm_if(count<=0,CALENDAR_ERROR_INVALID_PARAMETER,"count <= 0 ");
-
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- ret = _cal_ipc_marshal_char(view_uri,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- ret = _cal_ipc_marshal_int(count,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- for (i=0;i<count;i++)
- {
- ret = _cal_ipc_marshal_int(record_id_array[i],indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- }
-
- // ipc call
- if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_DELETE_RECORDS, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
-
- CAL_IPC_DATA_FREE(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (ret == CALENDAR_ERROR_NONE)
- {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- _cal_client_ipc_set_change_version(transaction_ver);
- }
-
- pims_ipc_data_destroy(outdata);
- }
- else
- {
- ERR("ipc outdata is NULL");
- return CALENDAR_ERROR_IPC;
- }
-
- return ret;
+ // ipc call
+ if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_GET_ALL_RECORDS, indata, &outdata) != 0)
+ {
+ ERR("pims_ipc_call failed");
+ CAL_IPC_DATA_FREE(indata);
+ return CALENDAR_ERROR_IPC;
+ }
-}
+ CAL_IPC_DATA_FREE(indata);
-API int calendar_db_delete_records_async(const char* view_uri, int ids[], int count, calendar_db_result_cb callback, void *user_data)
-{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- int i = 0;
- cal_client_db_async_userdata_s *async_data = NULL;
-
- retvm_if(view_uri==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"view_uri is NULL");
- retvm_if(callback==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"callback is NULL");
-
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- ret = _cal_ipc_marshal_char(view_uri,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- ret = _cal_ipc_marshal_int(count,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- for (i=0;i<count;i++)
- {
- ret = _cal_ipc_marshal_int(ids[i],indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- }
-
- async_data = (cal_client_db_async_userdata_s*)malloc(sizeof(cal_client_db_async_userdata_s));
- if (async_data == NULL)
- {
- ERR("malloc fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- async_data->callback = callback;
- async_data->user_data = user_data;
- if (_cal_client_ipc_call_async(CAL_IPC_MODULE,CAL_IPC_SERVER_DB_DELETE_RECORDS,
- indata,__cal_client_db_delete_records_cb,async_data) != 0)
- {
- ERR("pims_ipc_call_async failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
-
- CAL_IPC_DATA_FREE(indata);
-
- return ret;
-}
+ if (outdata)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ ret = _cal_ipc_unmarshal_list(outdata,out_list);
+ }
+ pims_ipc_data_destroy(outdata);
+ }
+ else
+ {
+ ERR("ipc outdata is NULL");
+ return CALENDAR_ERROR_IPC;
+ }
-API int calendar_db_get_changes_by_version(const char* view_uri, int calendar_book_id, int calendar_db_version, calendar_list_h* record_list, int* current_calendar_db_version )
-{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- retvm_if(view_uri==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"view_uri is NULL");
- retvm_if(record_list==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"record_list is NULL");
- retvm_if(current_calendar_db_version==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"current_calendar_db_version is NULL");
-
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- ret = _cal_ipc_marshal_char(view_uri,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- ret = _cal_ipc_marshal_int(calendar_book_id,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- ret = _cal_ipc_marshal_int(calendar_db_version,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
-
- // ipc call
- if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_CHANGES_BY_VERSION, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
-
- CAL_IPC_DATA_FREE(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (ret == CALENDAR_ERROR_NONE)
- {
- ret = _cal_ipc_unmarshal_list(outdata,record_list);
-
- if (ret == CALENDAR_ERROR_NONE)
- {
- ret = _cal_ipc_unmarshal_int(outdata,current_calendar_db_version);
- }
- }
-
- pims_ipc_data_destroy(outdata);
- }
- else
- {
- ERR("ipc outdata is NULL");
- return CALENDAR_ERROR_IPC;
- }
-
- return ret;
+ return ret;
}
-API int calendar_db_get_current_version(int* calendar_db_version)
+API int calendar_db_get_records_with_query( calendar_query_h query, int offset, int limit, calendar_list_h* out_list )
{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- retvm_if(calendar_db_version==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"calendar_db_version is null");
-
- // ipc call
- if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_GET_CURRENT_VERSION, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- return CALENDAR_ERROR_IPC;
- }
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
- if (ret == CALENDAR_ERROR_NONE)
- {
- ret = _cal_ipc_unmarshal_int(outdata,calendar_db_version);
- }
- pims_ipc_data_destroy(outdata);
- }
- else
- {
- ERR("ipc outdata is NULL");
- return CALENDAR_ERROR_IPC;
- }
-
- return ret;
-}
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
-API int calendar_db_add_changed_cb(const char* view_uri, calendar_db_changed_cb callback, void* user_data )
-{
- CAL_FN_CALL;
- int ret;
- cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
-
- retv_if(NULL == view_uri || NULL == callback , CALENDAR_ERROR_INVALID_PARAMETER);
-
- type = _cal_view_get_type(view_uri);
-
- switch(type)
- {
- case CAL_RECORD_TYPE_CALENDAR:
- ret = _cal_inotify_subscribe(CAL_NOTI_TYPE_CALENDAR, CAL_NOTI_CALENDAR_CHANGED, callback, user_data);
- break;
- case CAL_RECORD_TYPE_EVENT:
- ret = _cal_inotify_subscribe(CAL_NOTI_TYPE_EVENT, CAL_NOTI_EVENT_CHANGED, callback, user_data);
- break;
- case CAL_RECORD_TYPE_TODO:
- ret = _cal_inotify_subscribe(CAL_NOTI_TYPE_TODO, CAL_NOTI_TODO_CHANGED, callback, user_data);
- break;
- default:
- ERR("Invalid view_uri(%s)", view_uri);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- retvm_if(CALENDAR_ERROR_NONE != ret, ret, "_cal_inotify_subscribe() Failed(%d)", ret);
-
- return CALENDAR_ERROR_NONE;
-}
+ retvm_if(query==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"query is NULL");
+ retvm_if(out_list==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"list is NULL");
-API int calendar_db_remove_changed_cb( const char* view_uri, calendar_db_changed_cb callback, void* user_data )
-{
- CAL_FN_CALL;
- int ret;
- cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
-
- retv_if(NULL == view_uri || NULL == callback , CALENDAR_ERROR_INVALID_PARAMETER);
-
- type = _cal_view_get_type(view_uri);
-
- switch(type)
- {
- case CAL_RECORD_TYPE_CALENDAR:
- ret = _cal_inotify_unsubscribe_with_data(CAL_NOTI_CALENDAR_CHANGED, callback, user_data);
- break;
- case CAL_RECORD_TYPE_EVENT:
- ret = _cal_inotify_unsubscribe_with_data(CAL_NOTI_EVENT_CHANGED, callback, user_data);
- break;
- case CAL_RECORD_TYPE_TODO:
- ret = _cal_inotify_unsubscribe_with_data(CAL_NOTI_TODO_CHANGED, callback, user_data);
- break;
- default:
- ERR("Invalid view_uri(%s)", view_uri);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- retvm_if(CALENDAR_ERROR_NONE != ret, ret, "_cal_inotify_unsubscribe_with_data() Failed(%d)", ret);
-
- return CALENDAR_ERROR_NONE;
-}
+ // make indata
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL)
+ {
+ ERR("ipc data created fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+ ret = _cal_ipc_marshal_query(query,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ ret = _cal_ipc_marshal_int(offset,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ ret = _cal_ipc_marshal_int(limit,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
-API int calendar_db_insert_vcalendars(const char* vcalendar_stream, int **record_id_array, int *count)
-{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
- int i = 0;
-
- retvm_if(NULL == vcalendar_stream, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- ret = _cal_ipc_marshal_char(vcalendar_stream,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- // ipc call
- if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_INSERT_VCALENDARS, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
- CAL_IPC_DATA_FREE(indata);
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (ret == CALENDAR_ERROR_NONE)
- {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- _cal_client_ipc_set_change_version(transaction_ver);
- }
-
- if (ret == CALENDAR_ERROR_NONE && count != NULL && record_id_array != NULL)
- {
- int *ids = NULL;
-
- *count = *(int*) pims_ipc_data_get(outdata,&size);
-
- ids = (int*)malloc(sizeof(int)*(*count));
- if(ids == NULL)
- {
- pims_ipc_data_destroy(outdata);
- ERR("malloc fail");
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- for(i=0;i<(*count);i++)
- {
- ids[i] = *(int*) pims_ipc_data_get(outdata,&size);
- }
-
- *record_id_array = ids;
- }
- pims_ipc_data_destroy(outdata);
- }
- else
- {
- ERR("ipc outdata is NULL");
- return CALENDAR_ERROR_IPC;
- }
-
- return ret;
-}
+ // ipc call
+ if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_GET_RECORDS_WITH_QUERY, indata, &outdata) != 0)
+ {
+ ERR("pims_ipc_call failed");
+ CAL_IPC_DATA_FREE(indata);
+ return CALENDAR_ERROR_IPC;
+ }
-API int calendar_db_insert_vcalendars_async(const char* vcalendar_stream, calendar_db_insert_result_cb callback, void *user_data)
-{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- cal_client_db_async_insert_userdata_s *async_data = NULL;
-
- retvm_if(vcalendar_stream==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"list is NULL");
- retvm_if(callback==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"list is NULL");
-
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- ret = _cal_ipc_marshal_char(vcalendar_stream,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
-
- return ret;
- }
-
- async_data = (cal_client_db_async_insert_userdata_s*)malloc(sizeof(cal_client_db_async_insert_userdata_s));
- if (async_data == NULL)
- {
- ERR("malloc fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- async_data->callback = callback;
- async_data->user_data = user_data;
-
- if (_cal_client_ipc_call_async(CAL_IPC_MODULE,CAL_IPC_SERVER_DB_INSERT_VCALENDARS,
- indata,__cal_client_db_insert_vcalendars_cb,async_data) != 0)
- {
- ERR("pims_ipc_call_async failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
-
- CAL_IPC_DATA_FREE(indata);
-
- return ret;
-}
+ CAL_IPC_DATA_FREE(indata);
-API int calendar_db_replace_vcalendars(const char* vcalendar_stream, int *record_id_array, int count)
-{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
- int i = 0;
-
- retvm_if(NULL == vcalendar_stream, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == record_id_array, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(count <= 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- ret = _cal_ipc_marshal_char(vcalendar_stream,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- ret = _cal_ipc_marshal_int(count,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- for(i=0;i<count;i++)
- {
- ret = _cal_ipc_marshal_int(record_id_array[i],indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- }
-
- // ipc call
- if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_REPLACE_VCALENDARS, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
- CAL_IPC_DATA_FREE(indata);
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- if (ret == CALENDAR_ERROR_NONE)
- {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- _cal_client_ipc_set_change_version(transaction_ver);
- }
-
- pims_ipc_data_destroy(outdata);
- }
- else
- {
- ERR("ipc outdata is NULL");
- return CALENDAR_ERROR_IPC;
- }
-
- return ret;
-}
+ if (outdata)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
-API int calendar_db_replace_vcalendars_async(const char* vcalendar_stream, int *record_id_array, int count, calendar_db_result_cb callback, void *user_data)
-{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- cal_client_db_async_userdata_s *async_data = NULL;
- int i = 0;
-
- retvm_if(NULL == vcalendar_stream, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == record_id_array, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(count <= 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- ret = _cal_ipc_marshal_char(vcalendar_stream,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- ret = _cal_ipc_marshal_int(count,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- for(i=0;i<count;i++)
- {
- ret = _cal_ipc_marshal_int(record_id_array[i],indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- }
-
- async_data = (cal_client_db_async_userdata_s*)malloc(sizeof(cal_client_db_async_userdata_s));
- if (async_data == NULL)
- {
- ERR("malloc fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- async_data->callback = callback;
- async_data->user_data = user_data;
-
- if (_cal_client_ipc_call_async(CAL_IPC_MODULE,CAL_IPC_SERVER_DB_REPLACE_VCALENDARS,
- indata,__cal_client_db_replace_vcalendars_cb,async_data) != 0)
- {
- ERR("pims_ipc_call_async failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
-
- CAL_IPC_DATA_FREE(indata);
-
- return ret;
-}
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ ret = _cal_ipc_unmarshal_list(outdata,out_list);
+ }
-API int calendar_db_replace_record(calendar_record_h record, int record_id)
-{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- retvm_if(record==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"record is NULL");
- retvm_if(record_id < 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- ret = _cal_ipc_marshal_record(record,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- ret = _cal_ipc_marshal_int(record_id,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
-
- // ipc call
- if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_REPLACE_RECORD, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
-
- CAL_IPC_DATA_FREE(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
- if (ret == CALENDAR_ERROR_NONE)
- {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- _cal_client_ipc_set_change_version(transaction_ver);
- }
- pims_ipc_data_destroy(outdata);
- }
- else
- {
- ERR("ipc outdata is NULL");
- return CALENDAR_ERROR_IPC;
- }
-
- return ret;
-}
+ pims_ipc_data_destroy(outdata);
+ }
+ else
+ {
+ ERR("ipc outdata is NULL");
+ return CALENDAR_ERROR_IPC;
+ }
-API int calendar_db_replace_records(calendar_list_h record_list, int *record_id_array, int count)
-{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
- int i = 0;
-
- retvm_if(record_list==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"record is NULL");
- retvm_if(record_id_array==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"record_id_array is NULL");
- retvm_if(count <= 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- ret = _cal_ipc_marshal_list(record_list,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- ret = _cal_ipc_marshal_int(count,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- for(i=0;i<count;i++)
- {
- ret = _cal_ipc_marshal_int(record_id_array[i],indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- }
-
- // ipc call
- if (_cal_client_ipc_call( CAL_IPC_MODULE, CAL_IPC_SERVER_DB_REPLACE_RECORDS, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
-
- CAL_IPC_DATA_FREE(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
- if (ret == CALENDAR_ERROR_NONE)
- {
- int transaction_ver = 0;
- transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
- _cal_client_ipc_set_change_version(transaction_ver);
- }
- pims_ipc_data_destroy(outdata);
- }
- else
- {
- ERR("ipc outdata is NULL");
- return CALENDAR_ERROR_IPC;
- }
-
- return ret;
+ return ret;
}
-API int calendar_db_replace_records_async(calendar_list_h record_list, int *record_id_array, int count, calendar_db_result_cb callback, void *user_data)
+API int calendar_db_clean_after_sync( int calendar_book_id, int calendar_db_version)
{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- cal_client_db_async_userdata_s *async_data = NULL;
- int i = 0;
-
- retvm_if(NULL == record_list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == record_id_array, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(count <= 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- // make indata
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- ret = _cal_ipc_marshal_list(record_list,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- ret = _cal_ipc_marshal_int(count,indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- for(i=0;i<count;i++)
- {
- ret = _cal_ipc_marshal_int(record_id_array[i],indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- }
-
- async_data = (cal_client_db_async_userdata_s*)malloc(sizeof(cal_client_db_async_userdata_s));
- if (async_data == NULL)
- {
- ERR("malloc fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- async_data->callback = callback;
- async_data->user_data = user_data;
-
- if (_cal_client_ipc_call_async(CAL_IPC_MODULE,CAL_IPC_SERVER_DB_REPLACE_RECORDS,
- indata,__cal_client_db_replace_records_cb,async_data) != 0)
- {
- ERR("pims_ipc_call_async failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
-
- CAL_IPC_DATA_FREE(indata);
-
- return ret;
-}
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ retvm_if(calendar_book_id <= 0,CALENDAR_ERROR_INVALID_PARAMETER,"calendar_book_id < 0");
+
+ // make indata
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL)
+ {
+ ERR("ipc data created fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+ ret = _cal_ipc_marshal_int(calendar_book_id,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ ret = _cal_ipc_marshal_int(calendar_db_version,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+
+ // ipc call
+ if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_CLEAN_AFTER_SYNC, indata, &outdata) != 0)
+ {
+ ERR("pims_ipc_call failed");
+ CAL_IPC_DATA_FREE(indata);
+ return CALENDAR_ERROR_IPC;
+ }
+
+ CAL_IPC_DATA_FREE(indata);
+
+ if (outdata)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ pims_ipc_data_destroy(outdata);
+ }
+ else
+ {
+ ERR("ipc outdata is NULL");
+ return CALENDAR_ERROR_IPC;
+ }
+
+ return ret;
+}
+
+API int calendar_db_get_count( const char* view_uri, int *out_count )
+{
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ retvm_if(view_uri==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"view_uri is NULL");
+ retvm_if(out_count==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"count pointer is NULL");
+
+ // make indata
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL)
+ {
+ ERR("ipc data created fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+ ret = _cal_ipc_marshal_char(view_uri,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+
+ // ipc call
+ if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_GET_COUNT, indata, &outdata) != 0)
+ {
+ ERR("pims_ipc_call failed");
+ CAL_IPC_DATA_FREE(indata);
+ return CALENDAR_ERROR_IPC;
+ }
+
+ CAL_IPC_DATA_FREE(indata);
+
+ if (outdata)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ ret = _cal_ipc_unmarshal_int(outdata,out_count);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+ else
+ {
+ ERR("ipc outdata is NULL");
+ return CALENDAR_ERROR_IPC;
+ }
+
+ return ret;
+}
+
+API int calendar_db_get_count_with_query( calendar_query_h query, int *out_count )
+{
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ retvm_if(query==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"record is NULL");
+
+ // make indata
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL)
+ {
+ ERR("ipc data created fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+ ret = _cal_ipc_marshal_query(query,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+
+ // ipc call
+ if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_GET_COUNT_WITH_QUERY, indata, &outdata) != 0)
+ {
+ ERR("pims_ipc_call failed");
+ CAL_IPC_DATA_FREE(indata);
+ return CALENDAR_ERROR_IPC;
+ }
+
+ CAL_IPC_DATA_FREE(indata);
+
+ if (outdata)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ ret = _cal_ipc_unmarshal_int(outdata,out_count);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+ else
+ {
+ ERR("ipc outdata is NULL");
+ return CALENDAR_ERROR_IPC;
+ }
+
+ return ret;
+}
+
+API int calendar_db_insert_records( calendar_list_h record_list, int** record_id_array, int* count)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ retvm_if(record_list==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"list is NULL");
+
+ // make indata
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL)
+ {
+ ERR("ipc data created fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+ ret = _cal_ipc_marshal_list(record_list,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+
+ if (_cal_client_ipc_call(CAL_IPC_MODULE,CAL_IPC_SERVER_DB_INSERT_RECORDS,
+ indata,&outdata) != 0)
+ {
+ ERR("pims_ipc_call failed");
+ CAL_IPC_DATA_FREE(indata);
+ return CALENDAR_ERROR_IPC;
+ }
+
+ CAL_IPC_DATA_FREE(indata);
+ if (outdata)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ _cal_client_ipc_set_change_version(transaction_ver);
+ goto SET_DATA;
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+ else
+ {
+ ERR("ipc outdata is NULL");
+ return CALENDAR_ERROR_IPC;
+ }
+
+ return ret;
+
+SET_DATA:
+ if (outdata)
+ {
+ int i=0;
+ unsigned int size = 0;
+ int *ids = NULL;
+
+ if (count && record_id_array)
+ {
+ *count = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (*count <=0)
+ {
+ ERR("count is %d",*count);
+ count = 0;
+ pims_ipc_data_destroy(outdata);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ ids = calloc(1, sizeof(int)*(*count));
+
+ if(ids == NULL)
+ {
+ count = 0;
+ ERR("calloc fail");
+ pims_ipc_data_destroy(outdata);
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+ for(i=0;i<(*count);i++)
+ {
+ ids[i] = *(int*) pims_ipc_data_get(outdata,&size);
+ }
+ *record_id_array = ids;
+ }
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
+}
+
+API int calendar_db_insert_records_async(calendar_list_h list, calendar_db_insert_result_cb callback, void *user_data)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ cal_client_db_async_insert_userdata_s *async_data = NULL;
+ calendar_list_h clone_list = NULL;
+ bool result = false;
+
+ retvm_if(list==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"list is NULL");
+
+ ret = cal_client_ipc_client_check_permission(CAL_PERMISSION_WRITE, &result);
+ retvm_if(CALENDAR_ERROR_NONE != ret, ret, "ctsvc_ipc_client_check_permission fail (%d)", ret);
+ retvm_if(result == false, CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied (calendar read)");
+
+ ret = _cal_list_clone(list, &clone_list);
+ if (CALENDAR_ERROR_NONE != ret)
+ {
+ ERR("_cal_list_clone() failed");
+ return ret;
+ }
+
+ // make indata
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL)
+ {
+ ERR("ipc data created fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ calendar_list_destroy(clone_list, true);
+ return ret;
+ }
+ ret = _cal_ipc_marshal_list(clone_list,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ calendar_list_destroy(clone_list, true);
+ return ret;
+ }
+
+ async_data = (cal_client_db_async_insert_userdata_s*)malloc(sizeof(cal_client_db_async_insert_userdata_s));
+ if (async_data == NULL)
+ {
+ ERR("malloc fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ calendar_list_destroy(clone_list, true);
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ async_data->callback = callback;
+ async_data->user_data = user_data;
+
+ if (_cal_client_ipc_call_async(CAL_IPC_MODULE,CAL_IPC_SERVER_DB_INSERT_RECORDS,
+ indata,__cal_client_db_insert_records_cb,async_data) != 0)
+ {
+ ERR("pims_ipc_call_async failed");
+ calendar_list_destroy(clone_list, true);
+ CAL_IPC_DATA_FREE(indata);
+ CAL_FREE(async_data);
+ return CALENDAR_ERROR_IPC;
+ }
+
+ CAL_IPC_DATA_FREE(indata);
+
+ calendar_list_destroy(clone_list, true);
+
+ return ret;
+}
+
+API int calendar_db_update_records( calendar_list_h record_list)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ retvm_if(record_list==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"record is NULL");
+
+ // make indata
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL)
+ {
+ ERR("ipc data created fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+ ret = _cal_ipc_marshal_list(record_list,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+
+ // ipc call
+ if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_UPDATE_RECORDS, indata, &outdata) != 0)
+ {
+ ERR("pims_ipc_call failed");
+ CAL_IPC_DATA_FREE(indata);
+ return CALENDAR_ERROR_IPC;
+ }
+
+ CAL_IPC_DATA_FREE(indata);
+
+ if (outdata)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ _cal_client_ipc_set_change_version(transaction_ver);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+ else
+ {
+ ERR("ipc outdata is NULL");
+ return CALENDAR_ERROR_IPC;
+ }
+
+ return ret;
+
+}
+
+API int calendar_db_update_records_async( calendar_list_h list, calendar_db_result_cb callback, void *user_data)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ cal_client_db_async_userdata_s *async_data = NULL;
+ calendar_list_h clone_list = NULL;
+ bool result = false;
+
+ retvm_if(list==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"record is NULL");
+
+ ret = cal_client_ipc_client_check_permission(CAL_PERMISSION_WRITE, &result);
+ retvm_if(CALENDAR_ERROR_NONE != ret, ret, "ctsvc_ipc_client_check_permission fail (%d)", ret);
+ retvm_if(result == false, CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied (calendar read)");
+
+ ret = _cal_list_clone(list, &clone_list);
+ if (CALENDAR_ERROR_NONE != ret)
+ {
+ ERR("_cal_list_clone() failed");
+ return ret;
+ }
+
+ // make indata
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL)
+ {
+ ERR("ipc data created fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ calendar_list_destroy(clone_list, true);
+ return ret;
+ }
+ ret = _cal_ipc_marshal_list(clone_list,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ calendar_list_destroy(clone_list, true);
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+
+ async_data = (cal_client_db_async_userdata_s*)malloc(sizeof(cal_client_db_async_userdata_s));
+ if (async_data == NULL)
+ {
+ ERR("malloc fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ calendar_list_destroy(clone_list, true);
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ async_data->callback = callback;
+ async_data->user_data = user_data;
+
+ if (_cal_client_ipc_call_async(CAL_IPC_MODULE,CAL_IPC_SERVER_DB_UPDATE_RECORDS,
+ indata,__cal_client_db_update_records_cb,async_data) != 0)
+ {
+ ERR("pims_ipc_call_async failed");
+ calendar_list_destroy(clone_list, true);
+ CAL_IPC_DATA_FREE(indata);
+ CAL_FREE(async_data);
+ return CALENDAR_ERROR_IPC;
+ }
+
+ CAL_IPC_DATA_FREE(indata);
+
+ calendar_list_destroy(clone_list, true);
+ return ret;
+}
+
+API int calendar_db_delete_records(const char* view_uri, int record_id_array[], int count)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+ int i = 0;
+
+ retvm_if(view_uri==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"view_uri is NULL");
+ retvm_if(record_id_array==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"record_id_array is NULL");
+ retvm_if(count<=0,CALENDAR_ERROR_INVALID_PARAMETER,"count <= 0 ");
+
+ // make indata
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL)
+ {
+ ERR("ipc data created fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+ ret = _cal_ipc_marshal_char(view_uri,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ ret = _cal_ipc_marshal_int(count,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ for (i=0;i<count;i++)
+ {
+ ret = _cal_ipc_marshal_int(record_id_array[i],indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ }
+
+ // ipc call
+ if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_DELETE_RECORDS, indata, &outdata) != 0)
+ {
+ ERR("pims_ipc_call failed");
+ CAL_IPC_DATA_FREE(indata);
+ return CALENDAR_ERROR_IPC;
+ }
+
+ CAL_IPC_DATA_FREE(indata);
+
+ if (outdata)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ _cal_client_ipc_set_change_version(transaction_ver);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+ else
+ {
+ ERR("ipc outdata is NULL");
+ return CALENDAR_ERROR_IPC;
+ }
+
+ return ret;
+
+}
+
+API int calendar_db_delete_records_async(const char* view_uri, int ids[], int count, calendar_db_result_cb callback, void *user_data)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ int i = 0;
+ cal_client_db_async_userdata_s *async_data = NULL;
+ bool result = false;
+
+ retvm_if(view_uri==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"view_uri is NULL");
+ retvm_if(ids==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"ids is NULL");
+ retvm_if(count <= 0,CALENDAR_ERROR_INVALID_PARAMETER,"count is 0");
+
+ ret = cal_client_ipc_client_check_permission(CAL_PERMISSION_WRITE, &result);
+ retvm_if(CALENDAR_ERROR_NONE != ret, ret, "ctsvc_ipc_client_check_permission fail (%d)", ret);
+ retvm_if(result == false, CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied (calendar read)");
+
+ // make indata
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL)
+ {
+ ERR("ipc data created fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+ ret = _cal_ipc_marshal_char(view_uri,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ ret = _cal_ipc_marshal_int(count,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ for (i=0;i<count;i++)
+ {
+ ret = _cal_ipc_marshal_int(ids[i],indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ }
+
+ async_data = (cal_client_db_async_userdata_s*)malloc(sizeof(cal_client_db_async_userdata_s));
+ if (async_data == NULL)
+ {
+ ERR("malloc fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ async_data->callback = callback;
+ async_data->user_data = user_data;
+ if (_cal_client_ipc_call_async(CAL_IPC_MODULE,CAL_IPC_SERVER_DB_DELETE_RECORDS,
+ indata,__cal_client_db_delete_records_cb,async_data) != 0)
+ {
+ ERR("pims_ipc_call_async failed");
+ CAL_IPC_DATA_FREE(indata);
+ CAL_FREE(async_data);
+ return CALENDAR_ERROR_IPC;
+ }
+
+ CAL_IPC_DATA_FREE(indata);
+
+ return ret;
+}
+
+API int calendar_db_get_changes_by_version(const char* view_uri, int calendar_book_id, int calendar_db_version, calendar_list_h* record_list, int* current_calendar_db_version )
+{
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ retvm_if(view_uri==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"view_uri is NULL");
+ retvm_if(record_list==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"record_list is NULL");
+ retvm_if(current_calendar_db_version==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"current_calendar_db_version is NULL");
+
+ // make indata
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL)
+ {
+ ERR("ipc data created fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+ ret = _cal_ipc_marshal_char(view_uri,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ ret = _cal_ipc_marshal_int(calendar_book_id,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ ret = _cal_ipc_marshal_int(calendar_db_version,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+
+ // ipc call
+ if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_CHANGES_BY_VERSION, indata, &outdata) != 0)
+ {
+ ERR("pims_ipc_call failed");
+ CAL_IPC_DATA_FREE(indata);
+ return CALENDAR_ERROR_IPC;
+ }
+
+ CAL_IPC_DATA_FREE(indata);
+
+ if (outdata)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ ret = _cal_ipc_unmarshal_list(outdata,record_list);
+
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ ret = _cal_ipc_unmarshal_int(outdata,current_calendar_db_version);
+ }
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+ else
+ {
+ ERR("ipc outdata is NULL");
+ return CALENDAR_ERROR_IPC;
+ }
+
+ return ret;
+}
+
+API int calendar_db_get_current_version(int* calendar_db_version)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ retvm_if(calendar_db_version==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"calendar_db_version is null");
+
+ // ipc call
+ if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_GET_CURRENT_VERSION, indata, &outdata) != 0)
+ {
+ ERR("pims_ipc_call failed");
+ return CALENDAR_ERROR_IPC;
+ }
+
+ if (outdata)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ ret = _cal_ipc_unmarshal_int(outdata,calendar_db_version);
+ }
+ pims_ipc_data_destroy(outdata);
+ }
+ else
+ {
+ ERR("ipc outdata is NULL");
+ return CALENDAR_ERROR_IPC;
+ }
+
+ return ret;
+}
+
+API int calendar_db_add_changed_cb(const char* view_uri, calendar_db_changed_cb callback, void* user_data )
+{
+ CAL_FN_CALL;
+ int ret;
+ cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
+
+ retv_if(NULL == view_uri || NULL == callback , CALENDAR_ERROR_INVALID_PARAMETER);
+
+ type = _cal_view_get_type(view_uri);
+
+ switch(type)
+ {
+ case CAL_RECORD_TYPE_CALENDAR:
+ ret = _cal_inotify_subscribe(CAL_NOTI_TYPE_CALENDAR, CAL_NOTI_CALENDAR_CHANGED, callback, user_data);
+ break;
+ case CAL_RECORD_TYPE_EVENT:
+ ret = _cal_inotify_subscribe(CAL_NOTI_TYPE_EVENT, CAL_NOTI_EVENT_CHANGED, callback, user_data);
+ break;
+ case CAL_RECORD_TYPE_TODO:
+ ret = _cal_inotify_subscribe(CAL_NOTI_TYPE_TODO, CAL_NOTI_TODO_CHANGED, callback, user_data);
+ break;
+ default:
+ ERR("Invalid view_uri(%s)", view_uri);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ retvm_if(CALENDAR_ERROR_NONE != ret, ret, "_cal_inotify_subscribe() Failed(%d)", ret);
+
+ return CALENDAR_ERROR_NONE;
+}
+
+API int calendar_db_remove_changed_cb( const char* view_uri, calendar_db_changed_cb callback, void* user_data )
+{
+ CAL_FN_CALL;
+ int ret;
+ cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
+
+ retv_if(NULL == view_uri || NULL == callback , CALENDAR_ERROR_INVALID_PARAMETER);
+
+ type = _cal_view_get_type(view_uri);
+
+ switch(type)
+ {
+ case CAL_RECORD_TYPE_CALENDAR:
+ ret = _cal_inotify_unsubscribe_with_data(CAL_NOTI_CALENDAR_CHANGED, callback, user_data);
+ break;
+ case CAL_RECORD_TYPE_EVENT:
+ ret = _cal_inotify_unsubscribe_with_data(CAL_NOTI_EVENT_CHANGED, callback, user_data);
+ break;
+ case CAL_RECORD_TYPE_TODO:
+ ret = _cal_inotify_unsubscribe_with_data(CAL_NOTI_TODO_CHANGED, callback, user_data);
+ break;
+ default:
+ ERR("Invalid view_uri(%s)", view_uri);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ retvm_if(CALENDAR_ERROR_NONE != ret, ret, "_cal_inotify_unsubscribe_with_data() Failed(%d)", ret);
+
+ return CALENDAR_ERROR_NONE;
+}
+
+API int calendar_db_insert_vcalendars(const char* vcalendar_stream, int **record_id_array, int *count)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+ int i = 0;
+
+ retvm_if(NULL == vcalendar_stream, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ // make indata
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL)
+ {
+ ERR("ipc data created fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+ ret = _cal_ipc_marshal_char(vcalendar_stream,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ // ipc call
+ if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_INSERT_VCALENDARS, indata, &outdata) != 0)
+ {
+ ERR("pims_ipc_call failed");
+ CAL_IPC_DATA_FREE(indata);
+ return CALENDAR_ERROR_IPC;
+ }
+ CAL_IPC_DATA_FREE(indata);
+ if (outdata)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ _cal_client_ipc_set_change_version(transaction_ver);
+ }
+
+ if (ret == CALENDAR_ERROR_NONE && count != NULL && record_id_array != NULL)
+ {
+ int *ids = NULL;
+
+ *count = *(int*) pims_ipc_data_get(outdata,&size);
+
+ ids = (int*)malloc(sizeof(int)*(*count));
+ if(ids == NULL)
+ {
+ pims_ipc_data_destroy(outdata);
+ ERR("malloc fail");
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+ for(i=0;i<(*count);i++)
+ {
+ ids[i] = *(int*) pims_ipc_data_get(outdata,&size);
+ }
+
+ *record_id_array = ids;
+ }
+ pims_ipc_data_destroy(outdata);
+ }
+ else
+ {
+ ERR("ipc outdata is NULL");
+ return CALENDAR_ERROR_IPC;
+ }
+
+ return ret;
+}
+
+API int calendar_db_insert_vcalendars_async(const char* vcalendar_stream, calendar_db_insert_result_cb callback, void *user_data)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ cal_client_db_async_insert_userdata_s *async_data = NULL;
+ bool result = false;
+
+ retvm_if(vcalendar_stream==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"list is NULL");
+
+ ret = cal_client_ipc_client_check_permission(CAL_PERMISSION_WRITE, &result);
+ retvm_if(CALENDAR_ERROR_NONE != ret, ret, "ctsvc_ipc_client_check_permission fail (%d)", ret);
+ retvm_if(result == false, CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied (calendar read)");
+
+ // make indata
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL)
+ {
+ ERR("ipc data created fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+ ret = _cal_ipc_marshal_char(vcalendar_stream,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+
+ return ret;
+ }
+
+ async_data = (cal_client_db_async_insert_userdata_s*)malloc(sizeof(cal_client_db_async_insert_userdata_s));
+ if (async_data == NULL)
+ {
+ ERR("malloc fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ async_data->callback = callback;
+ async_data->user_data = user_data;
+
+ if (_cal_client_ipc_call_async(CAL_IPC_MODULE,CAL_IPC_SERVER_DB_INSERT_VCALENDARS,
+ indata,__cal_client_db_insert_vcalendars_cb,async_data) != 0)
+ {
+ ERR("pims_ipc_call_async failed");
+ CAL_IPC_DATA_FREE(indata);
+ CAL_FREE(async_data);
+ return CALENDAR_ERROR_IPC;
+ }
+
+ CAL_IPC_DATA_FREE(indata);
+
+ return ret;
+}
+
+API int calendar_db_replace_vcalendars(const char* vcalendar_stream, int *record_id_array, int count)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+ int i = 0;
+
+ retvm_if(NULL == vcalendar_stream, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == record_id_array, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(count <= 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ // make indata
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL)
+ {
+ ERR("ipc data created fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+ ret = _cal_ipc_marshal_char(vcalendar_stream,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ ret = _cal_ipc_marshal_int(count,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ for(i=0;i<count;i++)
+ {
+ ret = _cal_ipc_marshal_int(record_id_array[i],indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ }
+
+ // ipc call
+ if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_REPLACE_VCALENDARS, indata, &outdata) != 0)
+ {
+ ERR("pims_ipc_call failed");
+ CAL_IPC_DATA_FREE(indata);
+ return CALENDAR_ERROR_IPC;
+ }
+ CAL_IPC_DATA_FREE(indata);
+ if (outdata)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ _cal_client_ipc_set_change_version(transaction_ver);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+ else
+ {
+ ERR("ipc outdata is NULL");
+ return CALENDAR_ERROR_IPC;
+ }
+
+ return ret;
+}
+
+API int calendar_db_replace_vcalendars_async(const char* vcalendar_stream, int *record_id_array, int count, calendar_db_result_cb callback, void *user_data)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ cal_client_db_async_userdata_s *async_data = NULL;
+ int i = 0;
+ bool result = false;
+
+ retvm_if(NULL == vcalendar_stream, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == record_id_array, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(count <= 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ ret = cal_client_ipc_client_check_permission(CAL_PERMISSION_WRITE, &result);
+ retvm_if(CALENDAR_ERROR_NONE != ret, ret, "ctsvc_ipc_client_check_permission fail (%d)", ret);
+ retvm_if(result == false, CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied (calendar read)");
+
+ // make indata
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL)
+ {
+ ERR("ipc data created fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+ ret = _cal_ipc_marshal_char(vcalendar_stream,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ ret = _cal_ipc_marshal_int(count,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ for(i=0;i<count;i++)
+ {
+ ret = _cal_ipc_marshal_int(record_id_array[i],indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ }
+
+ async_data = (cal_client_db_async_userdata_s*)malloc(sizeof(cal_client_db_async_userdata_s));
+ if (async_data == NULL)
+ {
+ ERR("malloc fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ async_data->callback = callback;
+ async_data->user_data = user_data;
+
+ if (_cal_client_ipc_call_async(CAL_IPC_MODULE,CAL_IPC_SERVER_DB_REPLACE_VCALENDARS,
+ indata,__cal_client_db_replace_vcalendars_cb,async_data) != 0)
+ {
+ ERR("pims_ipc_call_async failed");
+ CAL_IPC_DATA_FREE(indata);
+ CAL_FREE(async_data);
+ return CALENDAR_ERROR_IPC;
+ }
+
+ CAL_IPC_DATA_FREE(indata);
+
+ return ret;
+}
+
+API int calendar_db_replace_record(calendar_record_h record, int record_id)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ retvm_if(record==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"record is NULL");
+ retvm_if(record_id < 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ cal_record_s *rec = (cal_record_s *)record;
+ CAL_LIMIT_ACCESS_FRONT(rec->view_uri);
+
+ // make indata
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL)
+ {
+ ERR("ipc data created fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+ ret = _cal_ipc_marshal_record(record,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ ret = _cal_ipc_marshal_int(record_id,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+
+ // ipc call
+ if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_REPLACE_RECORD, indata, &outdata) != 0)
+ {
+ ERR("pims_ipc_call failed");
+ CAL_IPC_DATA_FREE(indata);
+ return CALENDAR_ERROR_IPC;
+ }
+
+ CAL_IPC_DATA_FREE(indata);
+
+ if (outdata)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ _cal_client_ipc_set_change_version(transaction_ver);
+ }
+ pims_ipc_data_destroy(outdata);
+ }
+ else
+ {
+ ERR("ipc outdata is NULL");
+ return CALENDAR_ERROR_IPC;
+ }
+
+ CAL_LIMIT_ACCESS_BACK;
+
+ return ret;
+}
+
+API int calendar_db_replace_records(calendar_list_h record_list, int *record_id_array, int count)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+ int i = 0;
+
+ retvm_if(record_list==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"record is NULL");
+ retvm_if(record_id_array==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"record_id_array is NULL");
+ retvm_if(count <= 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ // make indata
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL)
+ {
+ ERR("ipc data created fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+ ret = _cal_ipc_marshal_list(record_list,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ ret = _cal_ipc_marshal_int(count,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ for(i=0;i<count;i++)
+ {
+ ret = _cal_ipc_marshal_int(record_id_array[i],indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ }
+
+ // ipc call
+ if (_cal_client_ipc_call( CAL_IPC_MODULE, CAL_IPC_SERVER_DB_REPLACE_RECORDS, indata, &outdata) != 0)
+ {
+ ERR("pims_ipc_call failed");
+ CAL_IPC_DATA_FREE(indata);
+ return CALENDAR_ERROR_IPC;
+ }
+
+ CAL_IPC_DATA_FREE(indata);
+
+ if (outdata)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ int transaction_ver = 0;
+ transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
+ _cal_client_ipc_set_change_version(transaction_ver);
+ }
+ pims_ipc_data_destroy(outdata);
+ }
+ else
+ {
+ ERR("ipc outdata is NULL");
+ return CALENDAR_ERROR_IPC;
+ }
+
+ return ret;
+}
+
+API int calendar_db_replace_records_async(calendar_list_h record_list, int *record_id_array, int count, calendar_db_result_cb callback, void *user_data)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ cal_client_db_async_userdata_s *async_data = NULL;
+ int i = 0;
+ bool result = false;
+
+ retvm_if(NULL == record_list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: list is NULL");
+ retvm_if(NULL == record_id_array, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: id is NULL");
+ retvm_if(count <= 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: count <= 0");
+
+ ret = cal_client_ipc_client_check_permission(CAL_PERMISSION_WRITE, &result);
+ retvm_if(CALENDAR_ERROR_NONE != ret, ret, "ctsvc_ipc_client_check_permission fail (%d)", ret);
+ retvm_if(result == false, CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied (calendar read)");
+
+ // make indata
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL)
+ {
+ ERR("ipc data created fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+ ret = _cal_ipc_marshal_list(record_list,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ ret = _cal_ipc_marshal_int(count,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ for(i=0;i<count;i++)
+ {
+ ret = _cal_ipc_marshal_int(record_id_array[i],indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ }
+
+ async_data = (cal_client_db_async_userdata_s*)malloc(sizeof(cal_client_db_async_userdata_s));
+ if (async_data == NULL)
+ {
+ ERR("malloc fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ async_data->callback = callback;
+ async_data->user_data = user_data;
+
+ if (_cal_client_ipc_call_async(CAL_IPC_MODULE,CAL_IPC_SERVER_DB_REPLACE_RECORDS,
+ indata,__cal_client_db_replace_records_cb,async_data) != 0)
+ {
+ ERR("pims_ipc_call_async failed");
+ CAL_IPC_DATA_FREE(indata);
+ CAL_FREE(async_data);
+ return CALENDAR_ERROR_IPC;
+ }
+
+ CAL_IPC_DATA_FREE(indata);
+
+ return ret;
+}
API int calendar_db_get_last_change_version(int* last_version)
{
- int ret = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
+ bool result = false;
+ retvm_if(NULL == last_version, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ *last_version = 0;
+
+ ret = cal_client_ipc_client_check_permission(CAL_PERMISSION_READ, &result);
+ retvm_if(CALENDAR_ERROR_NONE != ret, ret, "cal_client_ipc_client_check_permission() is fail (%d)", ret);
+ retvm_if(result == false, CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied (calendar read)");
+
+ *last_version = _cal_client_ipc_get_change_version();
+ return ret;
+}
+
+API int calendar_db_get_changes_exception_by_version(const char* view_uri, int original_event_id, int calendar_db_version, calendar_list_h* record_list)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ retvm_if(view_uri==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"view_uri is NULL");
+ retvm_if(record_list==NULL,CALENDAR_ERROR_INVALID_PARAMETER,"record_list is NULL");
+
+ // make indata
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL)
+ {
+ ERR("ipc data created fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+ ret = _cal_ipc_marshal_char(view_uri,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ ret = _cal_ipc_marshal_int(original_event_id,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+ ret = _cal_ipc_marshal_int(calendar_db_version,indata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("marshal fail");
+ CAL_IPC_DATA_FREE(indata);
+ return ret;
+ }
+
+ // ipc call
+ if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_CHANGES_EXCEPTION, indata, &outdata) != 0)
+ {
+ ERR("pims_ipc_call failed");
+ CAL_IPC_DATA_FREE(indata);
+ return CALENDAR_ERROR_IPC;
+ }
+
+ CAL_IPC_DATA_FREE(indata);
+
+ if (outdata)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ ret = _cal_ipc_unmarshal_list(outdata,record_list);
+ }
+
+ pims_ipc_data_destroy(outdata);
+ }
+ else
+ {
+ ERR("ipc outdata is NULL");
+ return CALENDAR_ERROR_IPC;
+ }
+
+ return ret;
+}
+
+#ifdef CAL_MEMORY_TEST
+API int calendar_destroy(void)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+
+ // make indata
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL)
+ {
+ ERR("ipc data created fail !");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+
+ // ipc call
+ if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DESTROY, indata, &outdata) != 0)
+ {
+ ERR("pims_ipc_call failed");
+ CAL_IPC_DATA_FREE(indata);
+ return CALENDAR_ERROR_IPC;
+ }
+
+ CAL_IPC_DATA_FREE(indata);
+
+ if (outdata)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ pims_ipc_data_destroy(outdata);
+ }
+ else
+ {
+ ERR("ipc outdata is NULL");
+ return CALENDAR_ERROR_IPC;
+ }
- retvm_if(NULL == last_version, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- *last_version = _cal_client_ipc_get_change_version();
- return ret;
+ return ret;
}
+#endif //#ifdef CAL_MEMORY_TEST
#include <stdlib.h> //calloc
#include <pims-ipc.h>
#include <glib-object.h> //g_type_init
+#include <security-server.h>
+#include <errno.h>
#include "calendar_service.h"
#include "calendar_db.h"
-#include "calendar_types2.h"
+#include "calendar_types.h"
#include "cal_internal.h"
#include "cal_typedef.h"
void __cal_client_ipc_lock(void);
void __cal_client_ipc_unlock(void);
+static int __cal_client_ipc_get_cookie_for_access_control(pims_ipc_data_h *indata)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ size_t cookie_size =0;
+ pims_ipc_data_h data;
+
+ cookie_size = security_server_get_cookie_size();
+ retvm_if(cookie_size<=0,CALENDAR_ERROR_NOT_PERMITTED,"get cookie_size fail");
+
+ char cookie[256] = {0,};
+ char *e_cookie = NULL;
+ ret = security_server_request_cookie(cookie, cookie_size);
+ retvm_if(ret<0,CALENDAR_ERROR_NOT_PERMITTED,"get cookie fail");
+
+ data = pims_ipc_data_create(0);
+ retvm_if(data==NULL,CALENDAR_ERROR_OUT_OF_MEMORY,"ipc data created fail!");
+
+ ret = _cal_ipc_marshal_int(cookie_size, data);
+
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("ipc marshal fail");
+ pims_ipc_data_destroy(data);
+ return ret;
+ }
+ e_cookie = g_base64_encode((const guchar *)cookie, cookie_size);
+ if (e_cookie == NULL)
+ {
+ ERR("base64 encode fail");
+ pims_ipc_data_destroy(data);
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+
+ ret = _cal_ipc_marshal_char(e_cookie, data);
+ CAL_FREE(e_cookie);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("ipc marshal fail");
+ pims_ipc_data_destroy(data);
+ return ret;
+ }
+
+ *indata = data;
+
+ return CALENDAR_ERROR_NONE;
+}
+
API int calendar_connect(void)
{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
- pims_ipc_h ipc_handle = NULL;
-
- CAL_FN_CALL;
-
- _cal_mutex_lock(CAL_MUTEX_CONNECTION);
- // ipc create
- if (calendar_ipc == NULL)
- {
- ipc_handle = pims_ipc_create(CAL_IPC_SOCKET_PATH);
- if (ipc_handle == NULL)
- {
- ERR("pims_ipc_create() Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- goto ERROR_RETURN;
- }
- }
- else
- {
- calendar_connection_count++;
- CAL_DBG("calendar already connected = %d",calendar_connection_count);
- ret = CALENDAR_ERROR_NONE;
- _cal_mutex_unlock(CAL_MUTEX_CONNECTION);
- return ret;
- }
-
- // ipc call
- if (pims_ipc_call(ipc_handle, CAL_IPC_MODULE, CAL_IPC_SERVER_CONNECT, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- ret = CALENDAR_ERROR_IPC;
- goto ERROR_RETURN;
- }
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- pims_ipc_data_destroy(outdata);
-
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_connect return (%d)",ret);
- goto ERROR_RETURN;
- }
- }
- else
- {
- ERR("ipc outdata is NULL");
- ret = CALENDAR_ERROR_IPC;
- goto ERROR_RETURN;
- }
-
- g_type_init(); // added for alarmmgr
-
- if (_cal_inotify_initialize() != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_inotify_initialize failed");
- }
-
- _cal_view_initialize();
-
- if (0 == calendar_connection_count)
- {
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+ pims_ipc_h ipc_handle = NULL;
+
+ CAL_FN_CALL;
+
+ _cal_mutex_lock(CAL_MUTEX_CONNECTION);
+ // ipc create
+ if (calendar_ipc == NULL)
+ {
+ ipc_handle = pims_ipc_create(CAL_IPC_SOCKET_PATH);
+ if (ipc_handle == NULL)
+ {
+ if (errno == EACCES)
+ {
+ ERR("pims_ipc_create() Failed : Permission denied");
+ ret = CALENDAR_ERROR_PERMISSION_DENIED;
+ }
+ else
+ {
+ ERR("pims_ipc_create() Failed(%d)", CALENDAR_ERROR_IPC);
+ ret = CALENDAR_ERROR_IPC;
+ }
+ goto ERROR_RETURN;
+ }
+ }
+ else
+ {
+ calendar_connection_count++;
+ CAL_DBG("calendar already connected = %d",calendar_connection_count);
+ ret = CALENDAR_ERROR_NONE;
+ _cal_mutex_unlock(CAL_MUTEX_CONNECTION);
+ return ret;
+ }
+
+ ret = __cal_client_ipc_get_cookie_for_access_control(&indata);
+ if( ret != CALENDAR_ERROR_NONE)
+ {
+ goto ERROR_RETURN;
+ }
+
+ // ipc call
+ if (pims_ipc_call(ipc_handle, CAL_IPC_MODULE, CAL_IPC_SERVER_CONNECT, indata, &outdata) != 0)
+ {
+ ERR("pims_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ ret = CALENDAR_ERROR_IPC;
+ goto ERROR_RETURN;
+ }
+
+ pims_ipc_data_destroy(indata);
+ indata = NULL;
+
+ if (outdata)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ pims_ipc_data_destroy(outdata);
+
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("calendar_connect return (%d)",ret);
+ goto ERROR_RETURN;
+ }
+ }
+ else
+ {
+ ERR("ipc outdata is NULL");
+ ret = CALENDAR_ERROR_IPC;
+ goto ERROR_RETURN;
+ }
+
+ g_type_init(); // added for alarmmgr
+
+ if (_cal_inotify_initialize() != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_inotify_initialize failed");
+ }
+
+ _cal_view_initialize();
+
+ if (0 == calendar_connection_count)
+ {
_cal_client_reminder_create_for_subscribe();
}
- calendar_connection_count++;
- calendar_ipc = ipc_handle;
- _cal_mutex_unlock(CAL_MUTEX_CONNECTION);
+ calendar_connection_count++;
+ calendar_ipc = ipc_handle;
+ calendar_change_version = 0;
+ _cal_mutex_unlock(CAL_MUTEX_CONNECTION);
return ret;
ERROR_RETURN:
- if (ipc_handle != NULL)
- {
- pims_ipc_destroy(ipc_handle);
- ipc_handle = NULL;
- }
+ if (ipc_handle != NULL)
+ {
+ pims_ipc_destroy(ipc_handle);
+ ipc_handle = NULL;
+ }
_cal_mutex_unlock(CAL_MUTEX_CONNECTION);
return ret;
}
API int calendar_disconnect(void)
{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- CAL_FN_CALL;
- _cal_mutex_lock(CAL_MUTEX_CONNECTION);
-
- if (calendar_ipc == NULL)
- {
- ERR("calendar not connected");
- ret = CALENDAR_ERROR_NOT_PERMITTED;
- goto ERROR_RETURN;
- }
-
- if (calendar_connection_count > 1)
- {
- calendar_connection_count--;
- CAL_DBG("calendar connect count -1 = %d",calendar_connection_count);
- ret = CALENDAR_ERROR_NONE;
- goto ERROR_RETURN;
- }
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ CAL_FN_CALL;
+ _cal_mutex_lock(CAL_MUTEX_CONNECTION);
+
+ if (calendar_ipc == NULL)
+ {
+ ERR("calendar not connected");
+ ret = CALENDAR_ERROR_NOT_PERMITTED;
+ goto ERROR_RETURN;
+ }
+
+ if (calendar_connection_count > 1)
+ {
+ calendar_connection_count--;
+ CAL_DBG("calendar connect count -1 = %d",calendar_connection_count);
+ ret = CALENDAR_ERROR_NONE;
+ goto ERROR_RETURN;
+ }
else
{
+ calendar_connection_count--;
_cal_client_reminder_destroy_for_subscribe();
}
- // ipc call
- if (pims_ipc_call(calendar_ipc, CAL_IPC_MODULE, CAL_IPC_SERVER_DISCONNECT, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- ret = CALENDAR_ERROR_NOT_PERMITTED;
- goto ERROR_RETURN;
- }
+ // ipc call
+ if (pims_ipc_call(calendar_ipc, CAL_IPC_MODULE, CAL_IPC_SERVER_DISCONNECT, indata, &outdata) != 0)
+ {
+ ERR("pims_ipc_call failed");
+ ret = CALENDAR_ERROR_NOT_PERMITTED;
+ goto ERROR_RETURN;
+ }
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
+ if (outdata)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
- pims_ipc_data_destroy(outdata);
+ pims_ipc_data_destroy(outdata);
- }
- else
- {
- ERR("ipc outdata is NULL");
- ret = CALENDAR_ERROR_IPC;
- goto ERROR_RETURN;
- }
+ }
+ else
+ {
+ ERR("ipc outdata is NULL");
+ ret = CALENDAR_ERROR_IPC;
+ goto ERROR_RETURN;
+ }
- if (calendar_ipc && ret == CALENDAR_ERROR_NONE)
- {
- pims_ipc_destroy(calendar_ipc);
- calendar_ipc = NULL;
+ if (calendar_ipc && ret == CALENDAR_ERROR_NONE)
+ {
+ pims_ipc_destroy(calendar_ipc);
+ calendar_ipc = NULL;
- _cal_inotify_finalize();
- _cal_view_finalize();
- }
+ _cal_inotify_finalize();
+ _cal_view_finalize();
+ }
ERROR_RETURN:
- _cal_mutex_unlock(CAL_MUTEX_CONNECTION);
- return ret;
+ _cal_mutex_unlock(CAL_MUTEX_CONNECTION);
+ return ret;
}
API int calendar_connect_on_thread(void)
{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- CAL_FN_CALL;
-
- // ipc create
- if (calendar_ipc_thread == NULL)
- {
- calendar_ipc_thread = pims_ipc_create(CAL_IPC_SOCKET_PATH);
- if (calendar_ipc_thread == NULL)
- {
- ERR("pims_ipc_create() Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- goto ERROR_RETURN;
- }
- }
- else
- {
- CAL_DBG("calendar already connected");
- ret = CALENDAR_ERROR_NONE;
- goto ERROR_RETURN;
- }
-
- // ipc call
- if (pims_ipc_call(calendar_ipc_thread, CAL_IPC_MODULE, CAL_IPC_SERVER_CONNECT, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- ret = CALENDAR_ERROR_IPC;
- goto ERROR_RETURN;
- }
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- pims_ipc_data_destroy(outdata);
-
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_connect return (%d)",ret);
- goto ERROR_RETURN;
- }
- }
- else
- {
- ERR("ipc outdata is NULL");
- ret = CALENDAR_ERROR_IPC;
- goto ERROR_RETURN;
- }
-
- if (_cal_inotify_initialize() != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_inotify_initialize failed");
- }
-
- _cal_view_initialize();
- return ret;
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ CAL_FN_CALL;
+
+ // ipc create
+ if (calendar_ipc_thread == NULL)
+ {
+ calendar_ipc_thread = pims_ipc_create(CAL_IPC_SOCKET_PATH);
+ if (calendar_ipc_thread == NULL)
+ {
+ if (errno == EACCES) {
+ ERR("pims_ipc_create() Failed(%d)", CALENDAR_ERROR_PERMISSION_DENIED);
+ ret = CALENDAR_ERROR_PERMISSION_DENIED;
+ goto ERROR_RETURN;
+ }
+ else {
+ ERR("pims_ipc_create() Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ goto ERROR_RETURN;
+ }
+ }
+ }
+ else
+ {
+ CAL_DBG("calendar already connected");
+ ret = CALENDAR_ERROR_NONE;
+ goto ERROR_RETURN;
+ }
+
+ ret = __cal_client_ipc_get_cookie_for_access_control(&indata);
+ if( ret != CALENDAR_ERROR_NONE)
+ {
+ goto ERROR_RETURN;
+ }
+
+ // ipc call
+ if (pims_ipc_call(calendar_ipc_thread, CAL_IPC_MODULE, CAL_IPC_SERVER_CONNECT, indata, &outdata) != 0)
+ {
+ ERR("pims_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ ret = CALENDAR_ERROR_IPC;
+ goto ERROR_RETURN;
+ }
+
+ pims_ipc_data_destroy(indata);
+ indata = NULL;
+
+ if (outdata)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ pims_ipc_data_destroy(outdata);
+
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("calendar_connect return (%d)",ret);
+ goto ERROR_RETURN;
+ }
+ }
+ else
+ {
+ ERR("ipc outdata is NULL");
+ ret = CALENDAR_ERROR_IPC;
+ goto ERROR_RETURN;
+ }
+
+ if (_cal_inotify_initialize() != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_inotify_initialize failed");
+ }
+
+ _cal_view_initialize();
+ calendar_change_version_thread = 0;
+ return ret;
ERROR_RETURN:
- if (calendar_ipc_thread != NULL)
- {
- pims_ipc_destroy(calendar_ipc_thread);
- calendar_ipc_thread = NULL;
- }
+ if (calendar_ipc_thread != NULL)
+ {
+ pims_ipc_destroy(calendar_ipc_thread);
+ calendar_ipc_thread = NULL;
+ }
- return ret;
+ return ret;
}
API int calendar_disconnect_on_thread(void)
{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- retvm_if(calendar_ipc_thread==NULL,CALENDAR_ERROR_NOT_PERMITTED,"calendar_thread not connected");
-
- CAL_FN_CALL;
-
- // ipc call
- if (pims_ipc_call(calendar_ipc_thread, CAL_IPC_MODULE, CAL_IPC_SERVER_DISCONNECT, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- ret = CALENDAR_ERROR_NOT_PERMITTED;
- goto ERROR_RETURN;
- }
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- pims_ipc_data_destroy(outdata);
-
- }
- else
- {
- ERR("ipc outdata is NULL");
- ret = CALENDAR_ERROR_IPC;
- goto ERROR_RETURN;
- }
-
- if (calendar_ipc_thread && ret == CALENDAR_ERROR_NONE)
- {
- pims_ipc_destroy(calendar_ipc_thread);
- calendar_ipc_thread = NULL;
-
- _cal_inotify_finalize();
- _cal_view_finalize();
- }
-
- return ret;
+ int ret = CALENDAR_ERROR_NONE;
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+
+ retvm_if(calendar_ipc_thread==NULL,CALENDAR_ERROR_NOT_PERMITTED,"calendar_thread not connected");
+
+ CAL_FN_CALL;
+
+ // ipc call
+ if (pims_ipc_call(calendar_ipc_thread, CAL_IPC_MODULE, CAL_IPC_SERVER_DISCONNECT, indata, &outdata) != 0)
+ {
+ ERR("pims_ipc_call failed");
+ ret = CALENDAR_ERROR_NOT_PERMITTED;
+ goto ERROR_RETURN;
+ }
+
+ if (outdata)
+ {
+ // check outdata
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ pims_ipc_data_destroy(outdata);
+
+ }
+ else
+ {
+ ERR("ipc outdata is NULL");
+ ret = CALENDAR_ERROR_IPC;
+ goto ERROR_RETURN;
+ }
+
+ if (calendar_ipc_thread && ret == CALENDAR_ERROR_NONE)
+ {
+ pims_ipc_destroy(calendar_ipc_thread);
+ calendar_ipc_thread = NULL;
+
+ _cal_inotify_finalize();
+ _cal_view_finalize();
+ }
+
+ return ret;
ERROR_RETURN:
- return ret;
+ return ret;
}
API int calendar_connect_with_flags(unsigned int flags)
{
- int ret = CALENDAR_ERROR_NONE;
-
- ret = calendar_connect();
- if (ret != CALENDAR_ERROR_NONE)
- {
- if (flags & CALENDAR_CONNECT_FLAG_RETRY)
- {
- int retry_time = 500;
- int i = 0;
- for(i=0;i<9;i++)
- {
- usleep(retry_time*1000);
- ret = calendar_connect();
- DBG("retry cnt=%d, ret=%x",(i+1), ret);
- if (ret == CALENDAR_ERROR_NONE)
- break;
- if (i>6)
- retry_time += 30000;
- else
- retry_time *= 2;
- }
-
- }
- }
-
- return ret;
+ int ret = CALENDAR_ERROR_NONE;
+
+ ret = calendar_connect();
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ if (flags & CALENDAR_CONNECT_FLAG_RETRY)
+ {
+ int retry_time = 500;
+ int i = 0;
+ for(i=0;i<9;i++)
+ {
+ usleep(retry_time*1000);
+ ret = calendar_connect();
+ DBG("retry cnt=%d, ret=%x",(i+1), ret);
+ if (ret == CALENDAR_ERROR_NONE)
+ break;
+ if (i>6)
+ retry_time += 30000;
+ else
+ retry_time *= 2;
+ }
+
+ }
+ }
+
+ return ret;
}
bool _cal_client_ipc_is_call_inprogress(void)
pims_ipc_h __cal_client_ipc_get_handle(void)
{
- if (calendar_ipc_thread == NULL)
- {
- return calendar_ipc;
- }
- return calendar_ipc_thread;
+ if (calendar_ipc_thread == NULL)
+ {
+ return calendar_ipc;
+ }
+ return calendar_ipc_thread;
}
void __cal_client_ipc_lock(void)
{
- if (calendar_ipc_thread == NULL)
- {
- _cal_mutex_lock(CAL_MUTEX_PIMS_IPC_CALL);
- }
+ if (calendar_ipc_thread == NULL)
+ {
+ _cal_mutex_lock(CAL_MUTEX_PIMS_IPC_CALL);
+ }
}
void __cal_client_ipc_unlock(void)
{
- if (calendar_ipc_thread == NULL)
- {
- _cal_mutex_unlock(CAL_MUTEX_PIMS_IPC_CALL);
- }
+ if (calendar_ipc_thread == NULL)
+ {
+ _cal_mutex_unlock(CAL_MUTEX_PIMS_IPC_CALL);
+ }
}
int _cal_client_ipc_call(char *module, char *function, pims_ipc_h data_in,
- pims_ipc_data_h *data_out)
+ pims_ipc_data_h *data_out)
{
- int ret = 0;
- pims_ipc_h ipc_handle = __cal_client_ipc_get_handle();
+ int ret = 0;
+ pims_ipc_h ipc_handle = __cal_client_ipc_get_handle();
- __cal_client_ipc_lock();
+ __cal_client_ipc_lock();
- ret = pims_ipc_call(ipc_handle, module, function, data_in, data_out);
+ ret = pims_ipc_call(ipc_handle, module, function, data_in, data_out);
- __cal_client_ipc_unlock();
+ __cal_client_ipc_unlock();
- return ret;
+ return ret;
}
int _cal_client_ipc_call_async(char *module, char *function, pims_ipc_h data_in,
- pims_ipc_call_async_cb callback, void *userdata)
+ pims_ipc_call_async_cb callback, void *userdata)
{
- int ret = 0;
- pims_ipc_h ipc_handle = __cal_client_ipc_get_handle();
+ int ret = 0;
+ pims_ipc_h ipc_handle = __cal_client_ipc_get_handle();
- __cal_client_ipc_lock();
+ __cal_client_ipc_lock();
- ret = pims_ipc_call_async(ipc_handle, module, function, data_in, callback, userdata);
+ ret = pims_ipc_call_async(ipc_handle, module, function, data_in, callback, userdata);
- __cal_client_ipc_unlock();
+ __cal_client_ipc_unlock();
- return ret;
+ return ret;
}
void _cal_client_ipc_set_change_version(int version)
{
- if (calendar_ipc_thread == NULL)
- {
- calendar_change_version = version;
- CAL_DBG("change_version=%d",version);
- return ;
- }
- calendar_change_version_thread = version;
- CAL_DBG("change_version=%d",version);
+ if (calendar_ipc_thread == NULL)
+ {
+ calendar_change_version = version;
+ CAL_DBG("change_version=%d",version);
+ return ;
+ }
+ calendar_change_version_thread = version;
+ CAL_DBG("change_version=%d",version);
}
int _cal_client_ipc_get_change_version(void)
{
- if (calendar_ipc_thread == NULL)
- {
- return calendar_change_version;
- }
- return calendar_change_version_thread;
+ if (calendar_ipc_thread == NULL)
+ {
+ return calendar_change_version;
+ }
+ return calendar_change_version_thread;
+
+}
+
+int cal_client_ipc_client_check_permission(int permission, bool *result)
+{
+ pims_ipc_data_h indata = NULL;
+ pims_ipc_data_h outdata = NULL;
+ int ret;
+
+ if (result)
+ *result = false;
+
+ indata = pims_ipc_data_create(0);
+ if (indata == NULL) {
+ ERR("ipc data created fail !");
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+ ret = _cal_ipc_marshal_int(permission, indata);
+ if (ret != CALENDAR_ERROR_NONE) {
+ ERR("marshal fail");
+ pims_ipc_data_destroy(indata);
+ return ret;
+ }
+
+ if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_CHECK_PERMISSION, indata, &outdata) != 0) {
+ ERR("_cal_client_ipc_call failed");
+ pims_ipc_data_destroy(indata);
+ return CALENDAR_ERROR_IPC;
+ }
+
+ pims_ipc_data_destroy(indata);
+
+ if (outdata) {
+ unsigned int size = 0;
+ ret = *(int*) pims_ipc_data_get(outdata,&size);
+
+ if (ret == CALENDAR_ERROR_NONE) {
+ if (result)
+ *result = *(bool*) pims_ipc_data_get(outdata, &size);
+ }
+ pims_ipc_data_destroy(outdata);
+ }
+
+ return ret;
}
bool _cal_client_ipc_is_call_inprogress(void);
int _cal_client_ipc_call(char *module, char *function, pims_ipc_h data_in,
- pims_ipc_data_h *data_out);
+ pims_ipc_data_h *data_out);
int _cal_client_ipc_call_async(char *module, char *function, pims_ipc_h data_in,
- pims_ipc_call_async_cb callback, void *userdata);
+ pims_ipc_call_async_cb callback, void *userdata);
void _cal_client_ipc_set_change_version(int version);
int _cal_client_ipc_get_change_version(void);
+int cal_client_ipc_client_check_permission(int permission, bool *result);
+
#endif // __CAL_CLIENT_IPC_H__
#include "calendar_service.h"
#include "calendar_db.h"
-#include "calendar_types2.h"
+#include "calendar_types.h"
#include "calendar_reminder.h"
#include "cal_internal.h"
#include "cal_client_ipc.h"
-#define CAL_IPC_DATA_FREE(ptr) \
- do { \
- if (ptr) \
- pims_ipc_data_destroy(ptr); \
- ptr = NULL; \
- } while(0)
-
-API int calendar_reminder_add_receiver(const char *pkgname, const char *extra_data_key, const char *extra_data_value)
-{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- retvm_if(NULL == pkgname, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- // make data
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- ret = _cal_ipc_marshal_char(pkgname, indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- ret = _cal_ipc_marshal_char(extra_data_key, indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
- ret = _cal_ipc_marshal_char(extra_data_value, indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
-
- // ipc call
- if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_REGISTER_REMINDER, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
- CAL_IPC_DATA_FREE(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- pims_ipc_data_destroy(outdata);
- }
- else
- {
- ERR("ipc outdata is NULL");
- return CALENDAR_ERROR_IPC;
- }
-
- return ret;
-}
-
-API int calendar_reminder_remove_receiver(const char *pkgname)
-{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- retvm_if(NULL == pkgname, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- // make data
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- ret = _cal_ipc_marshal_char(pkgname, indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
-
- // ipc call
- if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_UNREGISTER_REMINDER, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
- CAL_IPC_DATA_FREE(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- pims_ipc_data_destroy(outdata);
- }
- else
- {
- ERR("ipc outdata is NULL");
- return CALENDAR_ERROR_IPC;
- }
-
- return ret;
-}
-
-API int calendar_reminder_activate_receiver(const char *pkgname)
-{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- retvm_if(NULL == pkgname, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- // make data
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- ret = _cal_ipc_marshal_char(pkgname, indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
-
- // ipc call
- if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_ACTIVATE_REMINDER, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
- CAL_IPC_DATA_FREE(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- pims_ipc_data_destroy(outdata);
- }
- else
- {
- ERR("ipc outdata is NULL");
- return CALENDAR_ERROR_IPC;
- }
-
- return ret;
-}
-
-API int calendar_reminder_deactivate_receiver(const char *pkgname)
-{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- retvm_if(NULL == pkgname, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- // make data
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- ret = _cal_ipc_marshal_char(pkgname, indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
-
- // ipc call
- if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_DEACTIVATE_REMINDER, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
- CAL_IPC_DATA_FREE(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- pims_ipc_data_destroy(outdata);
- }
- else
- {
- ERR("ipc outdata is NULL");
- return CALENDAR_ERROR_IPC;
- }
-
- return ret;
-}
-
-API int calendar_reminder_has_receiver(const char *pkgname)
-{
- int ret = CALENDAR_ERROR_NONE;
- pims_ipc_data_h indata = NULL;
- pims_ipc_data_h outdata = NULL;
-
- retvm_if(NULL == pkgname, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- // make data
- indata = pims_ipc_data_create(0);
- if (indata == NULL)
- {
- ERR("ipc data created fail !");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- ret = _cal_ipc_marshal_char(pkgname, indata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("marshal fail");
- CAL_IPC_DATA_FREE(indata);
- return ret;
- }
-
- // ipc call
- if (_cal_client_ipc_call(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_HAS_REMINDER, indata, &outdata) != 0)
- {
- ERR("pims_ipc_call failed");
- CAL_IPC_DATA_FREE(indata);
- return CALENDAR_ERROR_IPC;
- }
- CAL_IPC_DATA_FREE(indata);
-
- if (outdata)
- {
- // check outdata
- unsigned int size = 0;
- ret = *(int*) pims_ipc_data_get(outdata,&size);
-
- pims_ipc_data_destroy(outdata);
- }
- else
- {
- ERR("ipc outdata is NULL");
- return CALENDAR_ERROR_IPC;
- }
-
- return ret;
-}
-
-// for reminder callback
-
typedef struct {
calendar_reminder_cb cb;
void *user_data;
} callback_info_s;
-typedef struct {
- char *view_uri;
- GSList *callbacks;
-} subscribe_info_s;
static pims_ipc_h __ipc = NULL;
static GSList *__subscribe_list = NULL;
int _cal_client_reminder_create_for_subscribe(void)
{
_cal_mutex_lock(CAL_MUTEX_PIMS_IPC_PUBSUB);
- if (!__ipc)
- {
+ if (!__ipc) {
__ipc = pims_ipc_create_for_subscribe(CAL_IPC_SOCKET_PATH_FOR_SUBSCRIPTION);
- if (!__ipc)
- {
+ if (!__ipc) {
ERR("pims_ipc_create_for_subscribe");
_cal_mutex_unlock(CAL_MUTEX_PIMS_IPC_PUBSUB);
return CALENDAR_ERROR_IPC;
unsigned int size = 0;
const char *str = NULL;
int len = 0;
- subscribe_info_s *info = user_data;
- if (data)
- {
+ if (data) {
len = (int)pims_ipc_data_get(data, &size);
- if (0 == len)
- {
+ if (0 == len) {
ERR("pims_ipc_data_get() failed");
return;
}
str = (const char *)pims_ipc_data_get(data, &size);
- if (!str)
- {
+ if (!str) {
ERR("pims_ipc_data_get() failed");
return;
}
}
- if (info)
- {
+
+ if (__subscribe_list) {
GSList *l = NULL;
- for (l = info->callbacks; l; l = l->next)
- {
+ for (l = __subscribe_list; l; l = l->next) {
callback_info_s *cb_info = l->data;
if (NULL == cb_info) continue;
API int calendar_reminder_add_cb(calendar_reminder_cb callback, void *user_data)
{
GSList *it = NULL;
- subscribe_info_s *info = NULL;
callback_info_s *cb_info = NULL;
+ int ret;
+ bool result = false;
- _cal_mutex_lock(CAL_MUTEX_PIMS_IPC_PUBSUB);
+ if (NULL == callback) {
+ ERR("Invalid parameter: callback is NULL");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- for (it = __subscribe_list; it; it = it->next)
- {
- if (NULL == it->data) continue;
+ ret = cal_client_ipc_client_check_permission(CAL_PERMISSION_READ, &result);
+ retvm_if(CALENDAR_ERROR_NONE != ret, ret, "ctsvc_ipc_client_check_permission fail (%d)", ret);
+ retvm_if(result == false, CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied (calendar read)");
- info = it->data;
- if (strcmp(info->view_uri, CAL_NOTI_REMINDER_CAHNGED) == 0)
- break;
- else
- info = NULL;
- }
- if (NULL == info)
- {
- info = calloc(1, sizeof(subscribe_info_s));
- if (NULL == info)
- {
- ERR("calloc() failed");
- _cal_mutex_unlock(CAL_MUTEX_PIMS_IPC_PUBSUB);
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
+ _cal_mutex_lock(CAL_MUTEX_PIMS_IPC_PUBSUB);
+
+ if (!__subscribe_list) {
if (pims_ipc_subscribe(__ipc, CAL_IPC_MODULE_FOR_SUBSCRIPTION, (char *)CAL_NOTI_REMINDER_CAHNGED,
- __cal_client_reminder_subscribe_callback, (void *)info) != 0)
- {
+ __cal_client_reminder_subscribe_callback, NULL) != 0) {
ERR("pims_ipc_subscribe() failed");
- free(info);
_cal_mutex_unlock(CAL_MUTEX_PIMS_IPC_PUBSUB);
return CALENDAR_ERROR_IPC;
}
- info->view_uri = strdup(CAL_NOTI_REMINDER_CAHNGED);
- __subscribe_list = g_slist_append(__subscribe_list, info);
+ }
+
+ // Check duplication
+ for (it = __subscribe_list; it; it = it->next) {
+ if (NULL == it->data) continue;
+
+ callback_info_s *cb_info = it->data;
+ if (callback == cb_info->cb && user_data == cb_info->user_data) {
+ ERR("The same callback(%s) is already exist");
+ _cal_mutex_unlock(CAL_MUTEX_PIMS_IPC_PUBSUB);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
}
cb_info = calloc(1, sizeof(callback_info_s));
cb_info->user_data = user_data;
cb_info->cb = callback;
- info->callbacks = g_slist_append(info->callbacks, cb_info);
+ __subscribe_list = g_slist_append(__subscribe_list, cb_info);
_cal_mutex_unlock(CAL_MUTEX_PIMS_IPC_PUBSUB);
+
return CALENDAR_ERROR_NONE;
}
API int calendar_reminder_remove_cb(calendar_reminder_cb callback, void *user_data)
{
GSList *it = NULL;
- subscribe_info_s *info = NULL;
+
+ if (NULL == callback) {
+ ERR("Invalid parameter: callback is NULL");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
_cal_mutex_lock(CAL_MUTEX_PIMS_IPC_PUBSUB);
- for (it = __subscribe_list; it; it = it->next)
- {
+ for (it = __subscribe_list; it; it = it->next) {
if (NULL == it->data) continue;
- info = it->data;
- if (strcmp(info->view_uri, CAL_NOTI_REMINDER_CAHNGED) == 0)
+ callback_info_s *cb_info = it->data;
+ if (callback == cb_info->cb && user_data == cb_info->user_data) {
+ __subscribe_list = g_slist_remove(__subscribe_list, cb_info);
+ free(cb_info);
break;
- else
- info = NULL;
- }
- if (info)
- {
- GSList *l = NULL;
- for (l = info->callbacks; l; l = l->next)
- {
- callback_info_s *cb_info = l->data;
- if (callback == cb_info->cb && user_data == cb_info->user_data)
- {
- info->callbacks = g_slist_remove(info->callbacks, cb_info);
- break;
- }
- }
- if (g_slist_length(info->callbacks) == 0)
- {
- __subscribe_list = g_slist_remove(__subscribe_list, info);
- free(info->view_uri);
- free(info);
}
}
+
+ if (g_slist_length(__subscribe_list) == 0) {
+ pims_ipc_unsubscribe(__ipc, CAL_IPC_MODULE_FOR_SUBSCRIPTION, (char *)CAL_NOTI_REMINDER_CAHNGED);
+ g_slist_free(__subscribe_list);
+ __subscribe_list = NULL;
+ }
+
_cal_mutex_unlock(CAL_MUTEX_PIMS_IPC_PUBSUB);
+
return CALENDAR_ERROR_NONE;
}
Name: @CALSVC2@
Description: @CALSVC2@ library
-Version: @VERSION@
-Requires: glib-2.0 alarm-service
+Version: @FULLVER@
+Requires: glib-2.0 alarm-service capi-base-common
Libs: -L${libdir} -l@CALSVC2@
-Cflags: -I${includedir}
+Cflags: -I${includedir}2
#include "cal_filter.h"
static int __cal_filter_create_attribute(cal_composite_filter_s *com_filter, unsigned int property_id,
- int match, int filter_type, cal_attribute_filter_s **out_filter);
+ int match, int filter_type, cal_attribute_filter_s **out_filter);
static int __cal_filter_destroy_composite(cal_composite_filter_s* filter);
static int __cal_filter_destroy_attribute(cal_attribute_filter_s* filter);
static int __cal_filter_clone_composite(cal_composite_filter_s* filter,
- cal_composite_filter_s **out_filter);
+ cal_composite_filter_s **out_filter);
static int __cal_filter_clone_attribute(cal_attribute_filter_s* filter,
- cal_attribute_filter_s **out_filter);
+ cal_attribute_filter_s **out_filter);
-API int calendar_filter_create( const char* view_uri, calendar_filter_h* out_filter )
+API int calendar_filter_create(const char* view_uri, calendar_filter_h* out_filter)
{
- cal_composite_filter_s *com_filter;
+ cal_composite_filter_s *com_filter;
- retv_if(NULL == view_uri || NULL == out_filter, CALENDAR_ERROR_INVALID_PARAMETER);
- com_filter = (cal_composite_filter_s *)calloc(1, sizeof(cal_composite_filter_s));
+ retv_if(NULL == view_uri || NULL == out_filter, CALENDAR_ERROR_INVALID_PARAMETER);
+ com_filter = (cal_composite_filter_s *)calloc(1, sizeof(cal_composite_filter_s));
+ retv_if(NULL == com_filter, CALENDAR_ERROR_OUT_OF_MEMORY);
- com_filter->filter_type = CAL_FILTER_COMPOSITE;
- com_filter->view_uri = strdup(view_uri);
- com_filter->properties = (cal_property_info_s *)_cal_view_get_property_info(view_uri, &com_filter->property_count);
- *out_filter = (calendar_filter_h)com_filter;
- return CALENDAR_ERROR_NONE;
+ com_filter->filter_type = CAL_FILTER_COMPOSITE;
+ com_filter->view_uri = strdup(view_uri);
+ com_filter->properties = (cal_property_info_s *)_cal_view_get_property_info(view_uri, &com_filter->property_count);
+ *out_filter = (calendar_filter_h)com_filter;
+ return CALENDAR_ERROR_NONE;
}
-API int calendar_filter_add_operator( calendar_filter_h filter, calendar_filter_operator_e op )
+API int calendar_filter_add_operator(calendar_filter_h filter, calendar_filter_operator_e op)
{
- cal_composite_filter_s *com_filter;
+ cal_composite_filter_s *com_filter;
- retv_if(NULL == filter, CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(NULL == filter, CALENDAR_ERROR_INVALID_PARAMETER);
+ retvm_if(op >= CALENDAR_FILTER_OPERATOR_MAX, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: operator(%d)", op);
- com_filter = (cal_composite_filter_s*)filter;
+ com_filter = (cal_composite_filter_s*)filter;
- retvm_if(g_slist_length(com_filter->filter_ops) != (g_slist_length(com_filter->filters)-1),
- CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter : Please check the operator of filter");
- com_filter->filter_ops = g_slist_append(com_filter->filter_ops, (void*)op );
- return CALENDAR_ERROR_NONE;
+ retvm_if(g_slist_length(com_filter->filter_ops) != (g_slist_length(com_filter->filters)-1),
+ CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter : Please check the operator of filter");
+ com_filter->filter_ops = g_slist_append(com_filter->filter_ops, (void*)op);
+ return CALENDAR_ERROR_NONE;
}
-API int calendar_filter_add_filter( calendar_filter_h filter, calendar_filter_h add_filter)
+API int calendar_filter_add_filter(calendar_filter_h filter, calendar_filter_h add_filter)
{
- cal_composite_filter_s *com_filter;
- cal_composite_filter_s *com_filter2;
- calendar_filter_h f = NULL;
- int ret = CALENDAR_ERROR_NONE;
+ cal_composite_filter_s *com_filter;
+ cal_composite_filter_s *com_filter2;
+ calendar_filter_h f = NULL;
+ int ret = CALENDAR_ERROR_NONE;
- retv_if(NULL == filter || NULL == add_filter, CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(NULL == filter || NULL == add_filter, CALENDAR_ERROR_INVALID_PARAMETER);
- com_filter = (cal_composite_filter_s*)filter;
- com_filter2 = (cal_composite_filter_s*)add_filter;
+ com_filter = (cal_composite_filter_s*)filter;
+ com_filter2 = (cal_composite_filter_s*)add_filter;
- retvm_if(g_slist_length(com_filter->filter_ops) != g_slist_length(com_filter->filters),
- CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter :Please check the operator of filter");
- retvm_if (0 != strcmp(com_filter->view_uri, com_filter2->view_uri), CALENDAR_ERROR_INVALID_PARAMETER,
- "The filter view_uri is different (filter1:%s, filter2:%s)", com_filter->view_uri, com_filter2->view_uri);
+ retvm_if(g_slist_length(com_filter->filter_ops) != g_slist_length(com_filter->filters),
+ CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter :Please check the operator of filter");
+ retvm_if (0 != strcmp(com_filter->view_uri, com_filter2->view_uri), CALENDAR_ERROR_INVALID_PARAMETER,
+ "The filter view_uri is different (filter1:%s, filter2:%s)", com_filter->view_uri, com_filter2->view_uri);
- ret = _cal_filter_clone(add_filter, &f);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
+ ret = _cal_filter_clone(add_filter, &f);
+ retv_if(ret != CALENDAR_ERROR_NONE, ret);
- com_filter->filters = g_slist_append(com_filter->filters, f);
+ com_filter->filters = g_slist_append(com_filter->filters, f);
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
-static int __cal_filter_create_attribute(cal_composite_filter_s *com_filter, unsigned int property_id,
- int match, int filter_type, cal_attribute_filter_s **out_filter)
+static int __cal_filter_create_attribute(cal_composite_filter_s *com_filter, unsigned int property_id, int match, int filter_type, cal_attribute_filter_s **out_filter)
{
- cal_attribute_filter_s *filter;
- //int type;
- //bool find = false;
+ cal_attribute_filter_s *filter;
+ //int type;
+ //bool find = false;
- retvm_if(g_slist_length(com_filter->filter_ops) != g_slist_length(com_filter->filters),
- CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter :Please check the operator of filter");
+ retvm_if(g_slist_length(com_filter->filter_ops) != g_slist_length(com_filter->filters),
+ CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter :Please check the operator of filter");
- filter = (cal_attribute_filter_s *)calloc(1, sizeof(cal_attribute_filter_s));
- filter->filter_type = filter_type;
- filter->property_id = property_id;
- filter->match = match;
+ filter = (cal_attribute_filter_s *)calloc(1, sizeof(cal_attribute_filter_s));
+ filter->filter_type = filter_type;
+ filter->property_id = property_id;
+ filter->match = match;
- com_filter->filters = g_slist_append(com_filter->filters, filter);
- *out_filter = filter;
- return CALENDAR_ERROR_NONE;
+ com_filter->filters = g_slist_append(com_filter->filters, filter);
+ *out_filter = filter;
+ return CALENDAR_ERROR_NONE;
}
-API int calendar_filter_add_str( calendar_filter_h filter, unsigned int property_id, calendar_match_str_flag_e match, const char* match_value )
+API int calendar_filter_add_str(calendar_filter_h filter, unsigned int property_id, calendar_match_str_flag_e match, const char* match_value)
{
- cal_composite_filter_s *com_filter;
- cal_attribute_filter_s *str_filter;
- int ret;
- bool bcheck;
-
- retv_if(NULL == filter || NULL == match_value, CALENDAR_ERROR_INVALID_PARAMETER);
-
- bcheck = CAL_PROPERTY_CHECK_DATA_TYPE(property_id,CAL_PROPERTY_DATA_TYPE_STR);
- retvm_if(false == bcheck, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid parameter : property_id(%d) is not supported)", property_id);
-
- bcheck = CAL_PROPERTY_CHECK_FLAGS(property_id,CAL_PROPERTY_FLAGS_PROJECTION);
- retvm_if(true == bcheck, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid parameter : property_id(%d) is not supported)", property_id);
-
- com_filter = (cal_composite_filter_s*)filter;
- ret = __cal_filter_create_attribute(com_filter, property_id, match, CAL_FILTER_STR, &str_filter);
- retvm_if(CALENDAR_ERROR_NONE !=ret, ret,
- "Invalid parameter : The paramter is not proper (view_uri:, property_id:%d, match:%d, match_value :%s",
- property_id, match, match_value);
-
- str_filter->value.s = SAFE_STRDUP(match_value);
- return CALENDAR_ERROR_NONE;
+ cal_composite_filter_s *com_filter;
+ cal_attribute_filter_s *str_filter;
+ int ret;
+ bool bcheck;
+
+ retv_if(NULL == filter || NULL == match_value, CALENDAR_ERROR_INVALID_PARAMETER);
+ retvm_if(match >= CALENDAR_MATCH_STR_MAX, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: check match value(%d)", match);
+
+ bcheck = CAL_PROPERTY_CHECK_DATA_TYPE(property_id,CAL_PROPERTY_DATA_TYPE_STR);
+ retvm_if(false == bcheck, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Invalid parameter : property_id(%d) is not supported)", property_id);
+
+ bcheck = CAL_PROPERTY_CHECK_FLAGS(property_id,CAL_PROPERTY_FLAGS_PROJECTION);
+ retvm_if(true == bcheck, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Invalid parameter : property_id(%d) is not supported)", property_id);
+
+ com_filter = (cal_composite_filter_s*)filter;
+ ret = __cal_filter_create_attribute(com_filter, property_id, match, CAL_FILTER_STR, &str_filter);
+ retvm_if(CALENDAR_ERROR_NONE !=ret, ret,
+ "Invalid parameter : The paramter is not proper (view_uri:, property_id:%d, match:%d, match_value :%s",
+ property_id, match, match_value);
+
+ str_filter->value.s = SAFE_STRDUP(match_value);
+ return CALENDAR_ERROR_NONE;
}
-API int calendar_filter_add_int( calendar_filter_h filter, unsigned int property_id, calendar_match_int_flag_e match, int match_value )
+API int calendar_filter_add_int(calendar_filter_h filter, unsigned int property_id, calendar_match_int_flag_e match, int match_value)
{
- cal_composite_filter_s *com_filter;
- cal_attribute_filter_s *int_filter;
- int ret;
- bool bcheck;
+ cal_composite_filter_s *com_filter;
+ cal_attribute_filter_s *int_filter;
+ int ret;
+ bool bcheck;
- retv_if(NULL == filter, CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(NULL == filter, CALENDAR_ERROR_INVALID_PARAMETER);
+ retvm_if(match >= CALENDAR_MATCH_INT_MAX, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: check match value(%d)", match);
- bcheck = CAL_PROPERTY_CHECK_DATA_TYPE(property_id,CAL_PROPERTY_DATA_TYPE_INT);
- retvm_if(false == bcheck, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid parameter : property_id(%d) is not supported)", property_id);
+ bcheck = CAL_PROPERTY_CHECK_DATA_TYPE(property_id,CAL_PROPERTY_DATA_TYPE_INT);
+ retvm_if(false == bcheck, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Invalid parameter : property_id(%d) is not supported)", property_id);
- bcheck = CAL_PROPERTY_CHECK_FLAGS(property_id,CAL_PROPERTY_FLAGS_PROJECTION);
- retvm_if(true == bcheck, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid parameter : property_id(%d) is not supported)", property_id);
+ bcheck = CAL_PROPERTY_CHECK_FLAGS(property_id,CAL_PROPERTY_FLAGS_PROJECTION);
+ retvm_if(true == bcheck, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Invalid parameter : property_id(%d) is not supported)", property_id);
- com_filter = (cal_composite_filter_s*)filter;
- ret = __cal_filter_create_attribute(com_filter, property_id, match, CAL_FILTER_INT, &int_filter);
- retvm_if(CALENDAR_ERROR_NONE !=ret, ret,
- "Invalid parameter : The paramter is not proper (view_uri:, property_id:%d, match:%d, match_value :%d",
- property_id, match, match_value);
+ com_filter = (cal_composite_filter_s*)filter;
+ ret = __cal_filter_create_attribute(com_filter, property_id, match, CAL_FILTER_INT, &int_filter);
+ retvm_if(CALENDAR_ERROR_NONE !=ret, ret,
+ "Invalid parameter : The paramter is not proper (view_uri:, property_id:%d, match:%d, match_value :%d",
+ property_id, match, match_value);
- int_filter->value.i = match_value;
+ int_filter->value.i = match_value;
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
-API int calendar_filter_add_double( calendar_filter_h filter, unsigned int property_id, calendar_match_int_flag_e match, double match_value )
+API int calendar_filter_add_double(calendar_filter_h filter, unsigned int property_id, calendar_match_int_flag_e match, double match_value)
{
- cal_composite_filter_s *com_filter;
- cal_attribute_filter_s *int_filter;
- int ret;
- bool bcheck;
+ cal_composite_filter_s *com_filter;
+ cal_attribute_filter_s *int_filter;
+ int ret;
+ bool bcheck;
- retv_if(NULL == filter, CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(NULL == filter, CALENDAR_ERROR_INVALID_PARAMETER);
+ retvm_if(match >= CALENDAR_MATCH_INT_MAX, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: check match value(%d)", match);
- bcheck = CAL_PROPERTY_CHECK_DATA_TYPE(property_id,CAL_PROPERTY_DATA_TYPE_DOUBLE);
- retvm_if(false == bcheck, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid parameter : property_id(%d) is not supported)", property_id);
+ bcheck = CAL_PROPERTY_CHECK_DATA_TYPE(property_id,CAL_PROPERTY_DATA_TYPE_DOUBLE);
+ retvm_if(false == bcheck, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Invalid parameter : property_id(%d) is not supported)", property_id);
- bcheck = CAL_PROPERTY_CHECK_FLAGS(property_id,CAL_PROPERTY_FLAGS_PROJECTION);
- retvm_if(true == bcheck, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid parameter : property_id(%d) is not supported)", property_id);
+ bcheck = CAL_PROPERTY_CHECK_FLAGS(property_id,CAL_PROPERTY_FLAGS_PROJECTION);
+ retvm_if(true == bcheck, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Invalid parameter : property_id(%d) is not supported)", property_id);
- com_filter = (cal_composite_filter_s*)filter;
- ret = __cal_filter_create_attribute(com_filter, property_id, match, CAL_FILTER_DOUBLE, &int_filter);
- retvm_if(CALENDAR_ERROR_NONE !=ret, ret,
- "Invalid parameter : The paramter is not proper (view_uri:, property_id:%d, match:%d, match_value :%d",
- property_id, match, match_value);
+ com_filter = (cal_composite_filter_s*)filter;
+ ret = __cal_filter_create_attribute(com_filter, property_id, match, CAL_FILTER_DOUBLE, &int_filter);
+ retvm_if(CALENDAR_ERROR_NONE !=ret, ret,
+ "Invalid parameter : The paramter is not proper (view_uri:, property_id:%d, match:%d, match_value :%d",
+ property_id, match, match_value);
- int_filter->value.d = match_value;
+ int_filter->value.d = match_value;
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
-API int calendar_filter_add_lli( calendar_filter_h filter, unsigned int property_id, calendar_match_int_flag_e match, long long int match_value )
+API int calendar_filter_add_lli(calendar_filter_h filter, unsigned int property_id, calendar_match_int_flag_e match, long long int match_value)
{
- cal_composite_filter_s *com_filter;
- cal_attribute_filter_s *int_filter;
- int ret;
- bool bcheck;
+ cal_composite_filter_s *com_filter;
+ cal_attribute_filter_s *int_filter;
+ int ret;
+ bool bcheck;
- retv_if(NULL == filter, CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(NULL == filter, CALENDAR_ERROR_INVALID_PARAMETER);
+ retvm_if(match >= CALENDAR_MATCH_INT_MAX, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: check match value(%d)", match);
- bcheck = CAL_PROPERTY_CHECK_DATA_TYPE(property_id,CAL_PROPERTY_DATA_TYPE_LLI);
- retvm_if(false == bcheck, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid parameter : property_id(%d) is not supported)", property_id);
+ bcheck = CAL_PROPERTY_CHECK_DATA_TYPE(property_id,CAL_PROPERTY_DATA_TYPE_LLI);
+ retvm_if(false == bcheck, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Invalid parameter : property_id(%d) is not supported)", property_id);
- bcheck = CAL_PROPERTY_CHECK_FLAGS(property_id,CAL_PROPERTY_FLAGS_PROJECTION);
- retvm_if(true == bcheck, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid parameter : property_id(%d) is not supported)", property_id);
+ bcheck = CAL_PROPERTY_CHECK_FLAGS(property_id,CAL_PROPERTY_FLAGS_PROJECTION);
+ retvm_if(true == bcheck, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Invalid parameter : property_id(%d) is not supported)", property_id);
- com_filter = (cal_composite_filter_s*)filter;
- ret = __cal_filter_create_attribute(com_filter, property_id, match, CAL_FILTER_LLI, &int_filter);
- retvm_if(CALENDAR_ERROR_NONE !=ret, ret,
- "Invalid parameter : The paramter is not proper (view_uri:, property_id:%d, match:%d, match_value :%d",
- property_id, match, match_value);
+ com_filter = (cal_composite_filter_s*)filter;
+ ret = __cal_filter_create_attribute(com_filter, property_id, match, CAL_FILTER_LLI, &int_filter);
+ retvm_if(CALENDAR_ERROR_NONE !=ret, ret,
+ "Invalid parameter : The paramter is not proper (view_uri:, property_id:%d, match:%d, match_value :%d",
+ property_id, match, match_value);
- int_filter->value.lli = match_value;
+ int_filter->value.lli = match_value;
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
-API int calendar_filter_add_caltime( calendar_filter_h filter, unsigned int property_id, calendar_match_int_flag_e match, calendar_time_s match_value )
+API int calendar_filter_add_caltime(calendar_filter_h filter, unsigned int property_id, calendar_match_int_flag_e match, calendar_time_s match_value)
{
- cal_composite_filter_s *com_filter;
- cal_attribute_filter_s *int_filter;
- int ret;
- bool bcheck;
+ cal_composite_filter_s *com_filter;
+ cal_attribute_filter_s *int_filter;
+ int ret;
+ bool bcheck;
- retv_if(NULL == filter, CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(NULL == filter, CALENDAR_ERROR_INVALID_PARAMETER);
+ retvm_if(match >= CALENDAR_MATCH_INT_MAX, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: check match value(%d)", match);
- bcheck = CAL_PROPERTY_CHECK_DATA_TYPE(property_id,CAL_PROPERTY_DATA_TYPE_CALTIME);
- retvm_if(false == bcheck, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid parameter : property_id(%d) is not supported)", property_id);
+ bcheck = CAL_PROPERTY_CHECK_DATA_TYPE(property_id,CAL_PROPERTY_DATA_TYPE_CALTIME);
+ retvm_if(false == bcheck, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Invalid parameter : property_id(%d) is not supported)", property_id);
- bcheck = CAL_PROPERTY_CHECK_FLAGS(property_id,CAL_PROPERTY_FLAGS_PROJECTION);
- retvm_if(true == bcheck, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid parameter : property_id(%d) is not supported)", property_id);
+ bcheck = CAL_PROPERTY_CHECK_FLAGS(property_id,CAL_PROPERTY_FLAGS_PROJECTION);
+ retvm_if(true == bcheck, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Invalid parameter : property_id(%d) is not supported)", property_id);
- com_filter = (cal_composite_filter_s*)filter;
- ret = __cal_filter_create_attribute(com_filter, property_id, match, CAL_FILTER_CALTIME, &int_filter);
- retvm_if(CALENDAR_ERROR_NONE !=ret, ret,
- "Invalid parameter : The paramter is not proper (view_uri:, property_id:%d, match:%d, match_value :%d",
- property_id, match, match_value);
+ com_filter = (cal_composite_filter_s*)filter;
+ ret = __cal_filter_create_attribute(com_filter, property_id, match, CAL_FILTER_CALTIME, &int_filter);
+ retvm_if(CALENDAR_ERROR_NONE !=ret, ret,
+ "Invalid parameter : The paramter is not proper (view_uri:, property_id:%d, match:%d, match_value :%d",
+ property_id, match, match_value);
- int_filter->value.caltime = match_value;
+ int_filter->value.caltime = match_value;
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
-API int calendar_filter_destroy( calendar_filter_h filter )
+API int calendar_filter_destroy(calendar_filter_h filter)
{
- retv_if(NULL == filter, CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(NULL == filter, CALENDAR_ERROR_INVALID_PARAMETER);
- return __cal_filter_destroy_composite((cal_composite_filter_s*)filter);
+ return __cal_filter_destroy_composite((cal_composite_filter_s*)filter);
}
int _cal_filter_clone(calendar_filter_h filter, calendar_filter_h* out_filter)
{
- retv_if(NULL == filter || NULL == out_filter, CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(NULL == filter || NULL == out_filter, CALENDAR_ERROR_INVALID_PARAMETER);
- return __cal_filter_clone_composite((cal_composite_filter_s*)filter, (cal_composite_filter_s**)out_filter);
+ return __cal_filter_clone_composite((cal_composite_filter_s*)filter, (cal_composite_filter_s**)out_filter);
}
static int __cal_filter_destroy_composite(cal_composite_filter_s* filter)
{
- GSList *cursor = NULL;
-
- retv_if(NULL == filter, CALENDAR_ERROR_INVALID_PARAMETER);
- for(cursor=filter->filters;cursor;cursor=cursor->next)
- {
- cal_filter_s *src = (cal_filter_s *)cursor->data;
- if (src == NULL)
- continue;
- if (src->filter_type == CAL_FILTER_COMPOSITE)
- {
- __cal_filter_destroy_composite((cal_composite_filter_s*)src);
- }
- else
- {
- __cal_filter_destroy_attribute((cal_attribute_filter_s*)src);
- }
-
- }
- CAL_FREE(filter->view_uri);
- g_slist_free(filter->filters);
- g_slist_free(filter->filter_ops);
- CAL_FREE(filter);
-
- return CALENDAR_ERROR_NONE;
+ GSList *cursor = NULL;
+
+ retv_if(NULL == filter, CALENDAR_ERROR_INVALID_PARAMETER);
+ for(cursor=filter->filters;cursor;cursor=cursor->next)
+ {
+ cal_filter_s *src = (cal_filter_s *)cursor->data;
+ if (src == NULL)
+ continue;
+ if (src->filter_type == CAL_FILTER_COMPOSITE)
+ {
+ __cal_filter_destroy_composite((cal_composite_filter_s*)src);
+ }
+ else
+ {
+ __cal_filter_destroy_attribute((cal_attribute_filter_s*)src);
+ }
+
+ }
+ CAL_FREE(filter->view_uri);
+ g_slist_free(filter->filters);
+ g_slist_free(filter->filter_ops);
+ CAL_FREE(filter);
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_filter_destroy_attribute(cal_attribute_filter_s* filter)
{
- retv_if(NULL == filter, CALENDAR_ERROR_INVALID_PARAMETER);
-
- if (filter->filter_type == CAL_FILTER_STR)
- {
- CAL_FREE(filter->value.s);
- }
- CAL_FREE(filter);
- return CALENDAR_ERROR_NONE;
+ retv_if(NULL == filter, CALENDAR_ERROR_INVALID_PARAMETER);
+
+ if (filter->filter_type == CAL_FILTER_STR)
+ {
+ CAL_FREE(filter->value.s);
+ }
+ CAL_FREE(filter);
+ return CALENDAR_ERROR_NONE;
}
static int __cal_filter_clone_composite(cal_composite_filter_s* filter,
- cal_composite_filter_s **out_filter)
+ cal_composite_filter_s **out_filter)
{
- GSList *cursor;
- cal_composite_filter_s *out;
- int ret = CALENDAR_ERROR_NONE;
-
- ret = calendar_filter_create(filter->view_uri, (calendar_filter_h *)&out);
- retv_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_OUT_OF_MEMORY);
-
- for(cursor=filter->filters; cursor ; cursor=cursor->next)
- {
- cal_filter_s *src = (cal_filter_s *)cursor->data;
- cal_filter_s *dest = NULL;
-
- if (src == NULL)
- continue;
-
- if (src->filter_type == CAL_FILTER_COMPOSITE)
- {
- ret = __cal_filter_clone_composite((cal_composite_filter_s *)src,
- (cal_composite_filter_s **)&dest);
- }
- else
- {
- ret = __cal_filter_clone_attribute((cal_attribute_filter_s *)src,
- (cal_attribute_filter_s **)&dest);
- }
- if (ret == CALENDAR_ERROR_NONE)
- {
- out->filters = g_slist_append(out->filters, dest);
- }
- else
- {
- calendar_filter_destroy((calendar_filter_h)out);
- return ret;
- }
- }
-
- out->filter_ops = g_slist_copy(filter->filter_ops);
- *out_filter = out;
-
- return CALENDAR_ERROR_NONE;
+ GSList *cursor;
+ cal_composite_filter_s *out;
+ int ret = CALENDAR_ERROR_NONE;
+
+ ret = calendar_filter_create(filter->view_uri, (calendar_filter_h *)&out);
+ retv_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_OUT_OF_MEMORY);
+
+ for(cursor=filter->filters; cursor ; cursor=cursor->next)
+ {
+ cal_filter_s *src = (cal_filter_s *)cursor->data;
+ cal_filter_s *dest = NULL;
+
+ if (src == NULL)
+ continue;
+
+ if (src->filter_type == CAL_FILTER_COMPOSITE)
+ {
+ ret = __cal_filter_clone_composite((cal_composite_filter_s *)src,
+ (cal_composite_filter_s **)&dest);
+ }
+ else
+ {
+ ret = __cal_filter_clone_attribute((cal_attribute_filter_s *)src,
+ (cal_attribute_filter_s **)&dest);
+ }
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ out->filters = g_slist_append(out->filters, dest);
+ }
+ else
+ {
+ calendar_filter_destroy((calendar_filter_h)out);
+ return ret;
+ }
+ }
+
+ out->filter_ops = g_slist_copy(filter->filter_ops);
+ *out_filter = out;
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_filter_clone_attribute(cal_attribute_filter_s* filter,
- cal_attribute_filter_s **out_filter)
+ cal_attribute_filter_s **out_filter)
{
- cal_attribute_filter_s *out;
- out = (cal_attribute_filter_s *)calloc(1, sizeof(cal_attribute_filter_s));
- retv_if(NULL == out, CALENDAR_ERROR_OUT_OF_MEMORY);
-
- out->filter_type = filter->filter_type;
- out->match = filter->match;
- out->property_id = filter->property_id;
- switch(filter->filter_type)
- {
- case CAL_FILTER_STR:
- out->value.s = SAFE_STRDUP(filter->value.s);
- break;
- case CAL_FILTER_INT:
- out->value.i = filter->value.i;
- break;
- case CAL_FILTER_DOUBLE:
- out->value.d = filter->value.d;
- break;
- case CAL_FILTER_LLI:
- out->value.lli = filter->value.lli;
- break;
- case CAL_FILTER_CALTIME:
- out->value.caltime = filter->value.caltime;
- break;
- default:
- break;
- }
-
- *out_filter = out;
- return CALENDAR_ERROR_NONE;
+ cal_attribute_filter_s *out;
+ out = (cal_attribute_filter_s *)calloc(1, sizeof(cal_attribute_filter_s));
+ retv_if(NULL == out, CALENDAR_ERROR_OUT_OF_MEMORY);
+
+ out->filter_type = filter->filter_type;
+ out->match = filter->match;
+ out->property_id = filter->property_id;
+ switch(filter->filter_type)
+ {
+ case CAL_FILTER_STR:
+ out->value.s = SAFE_STRDUP(filter->value.s);
+ break;
+ case CAL_FILTER_INT:
+ out->value.i = filter->value.i;
+ break;
+ case CAL_FILTER_DOUBLE:
+ out->value.d = filter->value.d;
+ break;
+ case CAL_FILTER_LLI:
+ out->value.lli = filter->value.lli;
+ break;
+ case CAL_FILTER_CALTIME:
+ out->value.caltime = filter->value.caltime;
+ break;
+ default:
+ break;
+ }
+
+ *out_filter = out;
+ return CALENDAR_ERROR_NONE;
}
void _cal_inotify_call_pending_callback(void)
{
- noti_info *noti;
- GSList *cursor = NULL;
+ noti_info *noti;
+ GSList *cursor = NULL;
- cursor = noti_list;
- while (cursor)
- {
+ cursor = noti_list;
+ while (cursor)
+ {
noti = (noti_info *)cursor->data;
if (noti->callback && noti->blocked)
{
static inline void _handle_callback(GSList *noti_list, int wd, uint32_t mask)
{
- noti_info *noti;
- GSList *cursor;
-
- cursor = noti_list;
- while (cursor)
- {
- noti = (noti_info *)cursor->data;
- if (noti->wd == wd)
+ noti_info *noti;
+ GSList *cursor;
+
+ cursor = noti_list;
+ while (cursor)
+ {
+ noti = (noti_info *)cursor->data;
+ if (noti->wd == wd)
{
#ifdef CAL_IPC_CLIENT
if (_cal_client_ipc_is_call_inprogress())
}
#endif
- if ((mask & IN_CLOSE_WRITE) && noti->callback)
- {
- switch(noti->noti_type)
- {
- case CAL_NOTI_TYPE_CALENDAR:
- noti->callback(CALENDAR_VIEW_CALENDAR, noti->cb_data);
- break;
- case CAL_NOTI_TYPE_EVENT:
- noti->callback(CALENDAR_VIEW_EVENT, noti->cb_data);
- break;
- case CAL_NOTI_TYPE_TODO:
- noti->callback(CALENDAR_VIEW_TODO, noti->cb_data);
- break;
- default:
- break;
- }
- }
- }
- cursor = cursor->next;
- }
+ if ((mask & IN_CLOSE_WRITE) && noti->callback)
+ {
+ switch(noti->noti_type)
+ {
+ case CAL_NOTI_TYPE_CALENDAR:
+ noti->callback(CALENDAR_VIEW_CALENDAR, noti->cb_data);
+ break;
+ case CAL_NOTI_TYPE_EVENT:
+ noti->callback(CALENDAR_VIEW_EVENT, noti->cb_data);
+ break;
+ case CAL_NOTI_TYPE_TODO:
+ noti->callback(CALENDAR_VIEW_TODO, noti->cb_data);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ cursor = cursor->next;
+ }
}
static gboolean _inotify_gio_cb(GIOChannel *src, GIOCondition cond, gpointer data)
{
- int fd, ret;
- struct inotify_event ie;
- char name[FILENAME_MAX] = {0};
-
- fd = g_io_channel_unix_get_fd(src);
-
- while (0 < (ret = read(fd, &ie, sizeof(ie))))
- {
- if (sizeof(ie) == ret)
- {
- if (noti_list)
- _handle_callback(noti_list, ie.wd, ie.mask);
-
- while (0 != ie.len)
- {
- ret = read(fd, name, (ie.len<sizeof(name))?ie.len:sizeof(name));
- if (-1 == ret)
- {
- if (EINTR == errno)
- continue;
- else
- return TRUE;
- }
- if (ret > ie.len)
- {
- ie.len = 0;
- }
- else
- {
- ie.len -= ret;
- }
- }
- }
- else
- {
- while (ret < sizeof(ie))
- {
- int read_size;
- read_size = read(fd, name, sizeof(ie)-ret);
- if (-1 == read_size)
- {
- if (EINTR == errno)
- continue;
- else
- return TRUE;
- }
- ret += read_size;
- }
- }
- }
-
- return TRUE;
+ int fd, ret;
+ struct inotify_event ie;
+ char name[FILENAME_MAX] = {0};
+
+ fd = g_io_channel_unix_get_fd(src);
+
+ while (0 < (ret = read(fd, &ie, sizeof(ie))))
+ {
+ if (sizeof(ie) == ret)
+ {
+ if (noti_list)
+ _handle_callback(noti_list, ie.wd, ie.mask);
+
+ while (0 != ie.len)
+ {
+ ret = read(fd, name, (ie.len<sizeof(name))?ie.len:sizeof(name));
+ if (-1 == ret)
+ {
+ if (EINTR == errno)
+ continue;
+ else
+ return TRUE;
+ }
+ if (ret > ie.len)
+ {
+ ie.len = 0;
+ }
+ else
+ {
+ ie.len -= ret;
+ }
+ }
+ }
+ else
+ {
+ while (ret < sizeof(ie))
+ {
+ int read_size;
+ read_size = read(fd, name, sizeof(ie)-ret);
+ if (-1 == read_size)
+ {
+ if (EINTR == errno)
+ continue;
+ else
+ return TRUE;
+ }
+ ret += read_size;
+ }
+ }
+ }
+
+ return TRUE;
}
static inline int _inotify_attach_handler(int fd)
{
- guint ret;
- GIOChannel *channel;
+ guint ret;
+ GIOChannel *channel;
- if (fd < 0)
- {
- ERR("Invalid argument: fd is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
+ if (fd < 0)
+ {
+ ERR("Invalid argument: fd is NULL");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- channel = g_io_channel_unix_new(fd);
- if (channel == NULL)
- {
- ERR("Failed to new channel");
- return -1; // CALENDAR_ERROR_FAILED_INOTIFY
- }
+ channel = g_io_channel_unix_new(fd);
+ if (channel == NULL)
+ {
+ ERR("Failed to new channel");
+ return -1; // CALENDAR_ERROR_FAILED_INOTIFY
+ }
- g_io_channel_set_flags(channel, G_IO_FLAG_NONBLOCK, NULL);
+ g_io_channel_set_flags(channel, G_IO_FLAG_NONBLOCK, NULL);
- ret = g_io_add_watch(channel, G_IO_IN, _inotify_gio_cb, NULL);
- g_io_channel_unref(channel);
+ ret = g_io_add_watch(channel, G_IO_IN, _inotify_gio_cb, NULL);
+ g_io_channel_unref(channel);
- return ret;
+ return ret;
}
int _cal_inotify_initialize(void)
{
- int ret;
+ int ret;
#ifdef CAL_IPC_CLIENT
- _cal_mutex_lock(CAL_MUTEX_INOTIFY);
- calendar_inoti_count++;
-
- if (calendar_inoti_count > 1)
- {
- CAL_DBG("inotify count =%d",calendar_inoti_count);
- _cal_mutex_unlock(CAL_MUTEX_INOTIFY);
- return CALENDAR_ERROR_NONE;
- }
- CAL_DBG("inotify count =%d",calendar_inoti_count);
- _cal_mutex_unlock(CAL_MUTEX_INOTIFY);
+ _cal_mutex_lock(CAL_MUTEX_INOTIFY);
+ calendar_inoti_count++;
+
+ if (calendar_inoti_count > 1)
+ {
+ CAL_DBG("inotify count =%d",calendar_inoti_count);
+ _cal_mutex_unlock(CAL_MUTEX_INOTIFY);
+ return CALENDAR_ERROR_NONE;
+ }
+ CAL_DBG("inotify count =%d",calendar_inoti_count);
+ _cal_mutex_unlock(CAL_MUTEX_INOTIFY);
#endif
- inoti_fd = inotify_init();
- if (inoti_fd == -1)
- {
- ERR("Failed to init inotify(err:%d)", errno);
+ inoti_fd = inotify_init();
+ if (inoti_fd == -1)
+ {
+ ERR("Failed to init inotify(err:%d)", errno);
#ifdef CAL_IPC_CLIENT
- _cal_mutex_lock(CAL_MUTEX_INOTIFY);
- calendar_inoti_count = 0;
- _cal_mutex_unlock(CAL_MUTEX_INOTIFY);
+ _cal_mutex_lock(CAL_MUTEX_INOTIFY);
+ calendar_inoti_count = 0;
+ _cal_mutex_unlock(CAL_MUTEX_INOTIFY);
#endif
- return -1; // CALENDAR_ERROR_FAILED_INOTIFY;
- }
-
- ret = fcntl(inoti_fd, F_SETFD, FD_CLOEXEC);
- warn_if(ret < 0, "fcntl failed(%d)", ret);
- ret = fcntl(inoti_fd, F_SETFL, O_NONBLOCK);
- warn_if(ret < 0, "fcntl failed(%d)", ret);
-
- inoti_handler = _inotify_attach_handler(inoti_fd);
- if (inoti_handler <= 0)
- {
- ERR("_inotify_attach_handler() Failed");
- close(inoti_fd);
- inoti_fd = -1;
- inoti_handler = 0;
+ return -1; // CALENDAR_ERROR_FAILED_INOTIFY;
+ }
+
+ ret = fcntl(inoti_fd, F_SETFD, FD_CLOEXEC);
+ warn_if(ret < 0, "fcntl failed(%d)", ret);
+ ret = fcntl(inoti_fd, F_SETFL, O_NONBLOCK);
+ warn_if(ret < 0, "fcntl failed(%d)", ret);
+
+ inoti_handler = _inotify_attach_handler(inoti_fd);
+ if (inoti_handler <= 0)
+ {
+ ERR("_inotify_attach_handler() Failed");
+ close(inoti_fd);
+ inoti_fd = -1;
+ inoti_handler = 0;
#ifdef CAL_IPC_CLIENT
- _cal_mutex_lock(CAL_MUTEX_INOTIFY);
- calendar_inoti_count = 0;
- _cal_mutex_unlock(CAL_MUTEX_INOTIFY);
+ _cal_mutex_lock(CAL_MUTEX_INOTIFY);
+ calendar_inoti_count = 0;
+ _cal_mutex_unlock(CAL_MUTEX_INOTIFY);
#endif
- return -1; // CALENDAR_ERROR_FAILED_INOTIFY
- }
+ return -1; // CALENDAR_ERROR_FAILED_INOTIFY
+ }
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static inline int __cal_inotify_get_wd(int fd, const char *notipath)
{
- return inotify_add_watch(fd, notipath, IN_ACCESS);
+ return inotify_add_watch(fd, notipath, IN_ACCESS);
}
static inline int __cal_inotify_add_watch(int fd, const char *notipath)
{
- int ret;
+ int ret;
- ret = inotify_add_watch(fd, notipath, IN_CLOSE_WRITE);
- if (ret < 0)
- {
- ERR("Failed to add watch(ret:%d)", ret);
- return -1; // CALENDAR_ERROR_FAILED_INOTIFY
- }
+ ret = inotify_add_watch(fd, notipath, IN_CLOSE_WRITE);
+ if (ret < 0)
+ {
+ ERR("Failed to add watch(ret:%d)", ret);
+ return -1; // CALENDAR_ERROR_FAILED_INOTIFY
+ }
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
int _cal_inotify_subscribe(cal_noti_type_e type, const char *path, calendar_db_changed_cb callback, void *data)
{
- int ret, wd;
- noti_info *noti, *same_noti = NULL;
- GSList *cursor;
-
- if (path == NULL)
- {
- ERR("Invalid argument: path is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (callback == NULL)
- {
- ERR("Invalid argument: callback is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- if (inoti_fd < 0)
- {
- ERR("Invalid argument: iinoti_fd(%d) is invalid", inoti_fd);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- wd = __cal_inotify_get_wd(inoti_fd, path);
- if (wd == -1)
- {
- ERR("Failed to get wd(err:%d)", errno);
- return -1; // CALENDAR_ERROR_FAILED_INOTIFY
- }
-
- cursor = noti_list;
- while (cursor)
- {
- if (cursor->data == NULL)
- {
- DBG("No data exist");
- cursor = cursor->next;
- continue;
- }
-
- same_noti = cursor->data;
- if (same_noti->wd == wd && same_noti->callback == callback && same_noti->cb_data == data) {
- break;
-
- }
- else
- {
- same_noti = NULL;
- }
-
- cursor = cursor->next;
- }
-
- if (same_noti)
- {
- __cal_inotify_add_watch(inoti_fd, path);
- ERR("The same callback(%s) is already exist", path);
- return -1; //CAL_ERR_ALREADY_EXIST;
- }
-
- ret = __cal_inotify_add_watch(inoti_fd, path);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("Failed to add watch");
- return -1; // CALENDAR_ERROR_FAILED_INOTIFY
- }
-
- noti = calloc(1, sizeof(noti_info));
- if (noti == NULL)
- {
- ERR("Failed to alloc");
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
-
- noti->wd = wd;
- noti->cb_data = data;
- noti->callback = callback;
- noti->noti_type = type;
+ int ret, wd;
+ noti_info *noti, *same_noti = NULL;
+ GSList *cursor;
+
+ if (path == NULL)
+ {
+ ERR("Invalid argument: path is NULL");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (callback == NULL)
+ {
+ ERR("Invalid argument: callback is NULL");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (inoti_fd < 0)
+ {
+ ERR("Invalid argument: iinoti_fd(%d) is invalid", inoti_fd);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ wd = __cal_inotify_get_wd(inoti_fd, path);
+ if (wd == -1)
+ {
+ ERR("Failed to get wd(err:%d)", errno);
+ if (errno == EACCES)
+ return CALENDAR_ERROR_PERMISSION_DENIED;
+ return CALENDAR_ERROR_SYSTEM;
+ }
+
+ cursor = noti_list;
+ while (cursor)
+ {
+ if (cursor->data == NULL)
+ {
+ DBG("No data exist");
+ cursor = cursor->next;
+ continue;
+ }
+
+ same_noti = cursor->data;
+ if (same_noti->wd == wd && same_noti->callback == callback && same_noti->cb_data == data) {
+ break;
+
+ }
+ else
+ {
+ same_noti = NULL;
+ }
+
+ cursor = cursor->next;
+ }
+
+ if (same_noti)
+ {
+ __cal_inotify_add_watch(inoti_fd, path);
+ ERR("The same callback(%s) is already exist", path);
+ return CALENDAR_ERROR_SYSTEM;
+ }
+
+ ret = __cal_inotify_add_watch(inoti_fd, path);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("Failed to add watch");
+ return CALENDAR_ERROR_SYSTEM;
+ }
+
+ noti = calloc(1, sizeof(noti_info));
+ if (noti == NULL)
+ {
+ ERR("Failed to alloc");
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+
+ noti->wd = wd;
+ noti->cb_data = data;
+ noti->callback = callback;
+ noti->noti_type = type;
noti->blocked = false;
- noti_list = g_slist_append(noti_list, noti);
+ noti_list = g_slist_append(noti_list, noti);
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static inline int __cal_inotify_delete_noti_with_data(GSList **noti_list, int wd,
- calendar_db_changed_cb callback, void *user_data)
+ calendar_db_changed_cb callback, void *user_data)
{
- int del_cnt, remain_cnt;
- GSList *cursor, *result;
-
- del_cnt = 0;
- remain_cnt = 0;
-
- cursor = result = *noti_list;
- while (cursor)
- {
- noti_info *noti = cursor->data;
- if (noti && wd == noti->wd)
- {
- if (callback == noti->callback && user_data == noti->cb_data) {
- cursor = cursor->next;
- result = g_slist_remove(result , noti);
- free(noti);
- del_cnt++;
- continue;
- }
- else
- {
- remain_cnt++;
- }
- }
- cursor = cursor->next;
- }
-
- if (del_cnt == 0)
- {
- ERR("Nothing to delete");
- return CALENDAR_ERROR_NO_DATA;
- }
-
- *noti_list = result;
-
- return remain_cnt;
+ int del_cnt, remain_cnt;
+ GSList *cursor, *result;
+
+ del_cnt = 0;
+ remain_cnt = 0;
+
+ cursor = result = *noti_list;
+ while (cursor)
+ {
+ noti_info *noti = cursor->data;
+ if (noti && wd == noti->wd)
+ {
+ if (callback == noti->callback && user_data == noti->cb_data) {
+ cursor = cursor->next;
+ result = g_slist_remove(result , noti);
+ free(noti);
+ del_cnt++;
+ continue;
+ }
+ else
+ {
+ remain_cnt++;
+ }
+ }
+ cursor = cursor->next;
+ }
+
+ if (del_cnt == 0)
+ {
+ ERR("Nothing to delete");
+ return CALENDAR_ERROR_NO_DATA;
+ }
+
+ *noti_list = result;
+
+ return remain_cnt;
}
static inline int __cal_notify_delete_noti(GSList **noti_list, int wd, calendar_db_changed_cb callback)
{
- int del_cnt, remain_cnt;
- GSList *cursor, *result;
-
- del_cnt = 0;
- remain_cnt = 0;
-
- cursor = result = *noti_list;
- while (cursor)
- {
- noti_info *noti = cursor->data;
- if (noti && wd == noti->wd)
- {
- if (NULL == callback || noti->callback == callback)
- {
- cursor = cursor->next;
- result = g_slist_remove(result, noti);
- free(noti);
- del_cnt++;
- continue;
- }
- else
- {
- remain_cnt++;
- }
- }
- cursor = cursor->next;
- }
-
- if (del_cnt == 0)
- {
- ERR("Nothing to delete");
- return CALENDAR_ERROR_NO_DATA;
- }
-
- *noti_list = result;
-
- return remain_cnt;
+ int del_cnt, remain_cnt;
+ GSList *cursor, *result;
+
+ del_cnt = 0;
+ remain_cnt = 0;
+
+ cursor = result = *noti_list;
+ while (cursor)
+ {
+ noti_info *noti = cursor->data;
+ if (noti && wd == noti->wd)
+ {
+ if (NULL == callback || noti->callback == callback)
+ {
+ cursor = cursor->next;
+ result = g_slist_remove(result, noti);
+ free(noti);
+ del_cnt++;
+ continue;
+ }
+ else
+ {
+ remain_cnt++;
+ }
+ }
+ cursor = cursor->next;
+ }
+
+ if (del_cnt == 0)
+ {
+ ERR("Nothing to delete");
+ return CALENDAR_ERROR_NO_DATA;
+ }
+
+ *noti_list = result;
+
+ return remain_cnt;
}
int _cal_inotify_unsubscribe_with_data(const char *path, calendar_db_changed_cb callback, void *user_data)
{
- int wd;
- int ret;
-
- if (path == NULL)
- {
- ERR("Invalid argument: path is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (callback == NULL)
- {
- ERR("Invalid argument: callback is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- if (inoti_fd < 0)
- {
- ERR("Invalid argument: iinoti_fd(%d) is invalid", inoti_fd);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- wd = __cal_inotify_get_wd(inoti_fd, path);
- if (wd == -1)
- {
- ERR("Failed to get wd(err:%d)", errno);
- return -1; // CALENDAR_ERROR_FAILED_INOTIFY
- }
-
- ret = __cal_inotify_delete_noti_with_data(¬i_list, wd, callback, user_data);
- if (ret != CALENDAR_ERROR_NONE)
- {
- WARN("Failed to delete noti(err:%d)", ret);
- return __cal_inotify_add_watch(inoti_fd, path);
- }
-
- return inotify_rm_watch(inoti_fd, wd);
+ int wd;
+ int ret;
+
+ if (path == NULL)
+ {
+ ERR("Invalid argument: path is NULL");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (callback == NULL)
+ {
+ ERR("Invalid argument: callback is NULL");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (inoti_fd < 0)
+ {
+ ERR("Invalid argument: iinoti_fd(%d) is invalid", inoti_fd);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ wd = __cal_inotify_get_wd(inoti_fd, path);
+ if (wd == -1)
+ {
+ ERR("Failed to get wd(err:%d)", errno);
+ if (errno == EACCES)
+ return CALENDAR_ERROR_PERMISSION_DENIED;
+ return CALENDAR_ERROR_SYSTEM;
+ }
+
+ ret = __cal_inotify_delete_noti_with_data(¬i_list, wd, callback, user_data);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ WARN("Failed to delete noti(err:%d)", ret);
+ return __cal_inotify_add_watch(inoti_fd, path);
+ }
+
+ ret = inotify_rm_watch(inoti_fd, wd);
+ return (ret == 0) ? CALENDAR_ERROR_NONE : CALENDAR_ERROR_SYSTEM;
}
static inline gboolean __cal_inotify_detach_handler(guint id)
{
- return g_source_remove(id);
+ return g_source_remove(id);
}
static void __clear_nslot_list(gpointer data, gpointer user_data)
{
- free(data);
+ free(data);
}
void _cal_inotify_finalize(void)
{
#ifdef CAL_IPC_CLIENT
- _cal_mutex_lock(CAL_MUTEX_INOTIFY);
- calendar_inoti_count--;
-
- if (calendar_inoti_count > 0)
- {
- CAL_DBG("inotify count =%d",calendar_inoti_count);
- _cal_mutex_unlock(CAL_MUTEX_INOTIFY);
- return ;
- }
- CAL_DBG("inotify count =%d",calendar_inoti_count);
- _cal_mutex_unlock(CAL_MUTEX_INOTIFY);
+ _cal_mutex_lock(CAL_MUTEX_INOTIFY);
+ calendar_inoti_count--;
+
+ if (calendar_inoti_count > 0)
+ {
+ CAL_DBG("inotify count =%d",calendar_inoti_count);
+ _cal_mutex_unlock(CAL_MUTEX_INOTIFY);
+ return ;
+ }
+ CAL_DBG("inotify count =%d",calendar_inoti_count);
+ _cal_mutex_unlock(CAL_MUTEX_INOTIFY);
#endif
- if (inoti_handler)
- {
- __cal_inotify_detach_handler(inoti_handler);
- inoti_handler = 0;
- }
-
- if (noti_list)
- {
- g_slist_foreach(noti_list, __clear_nslot_list, NULL);
- g_slist_free(noti_list);
- noti_list = NULL;
- }
-
- if (inoti_fd >= 0)
- {
- close(inoti_fd);
- inoti_fd = -1;
- }
+ if (inoti_handler)
+ {
+ __cal_inotify_detach_handler(inoti_handler);
+ inoti_handler = 0;
+ }
+
+ if (noti_list)
+ {
+ g_slist_foreach(noti_list, __clear_nslot_list, NULL);
+ g_slist_free(noti_list);
+ noti_list = NULL;
+ }
+
+ if (inoti_fd >= 0)
+ {
+ close(inoti_fd);
+ inoti_fd = -1;
+ }
}
#ifndef __CALENDAR_SVC_INOTIFY_H__
#define __CALENDAR_SVC_INOTIFY_H__
-#include "calendar_types2.h"
+#include "calendar_db.h"
+#include "cal_typedef.h"
#ifdef CAL_IPC_CLIENT
void _cal_inotify_call_pending_callback(void);
#include <stdio.h>
#include <string.h>
-#define EVENT_UPDATE "calendar_event_update"
-#define CALENDARBOOK_UPDATE "calendar_book_update"
-#define TASK_UPDATE "task_update"
-
-#define PKG_CALENDAR_APP "org.tizen.calendar"
-
#ifndef API
#define API __attribute__ ((visibility("default")))
#endif
#define LOG_TAG "CALENDAR_SVC"
#include <dlog.h>
+
+#define COLOR_GREEN "\033[0;32m"
+#define COLOR_END "\033[0;m"
+
+#define ENTER() SLOGD(COLOR_GREEN"BEGIN >>>>"COLOR_END)
+#define LEAVE() SLOGD(COLOR_GREEN"END <<<<"COLOR_END)
+
#define DLOG(prio, fmt, arg...) \
- do { SLOG(prio, LOG_TAG, fmt, ##arg); } while(0);
+ do { SLOG(prio, LOG_TAG, fmt, ##arg); } while(0);
#define INFO(fmt, arg...) SLOGI(fmt, ##arg)
-#define WARN(fmt, arg...) SLOGW("%s:%d " fmt, __FUNCTION__, __LINE__, ##arg)
-#define ERR(fmt, arg...) SLOGE("%s:%d " fmt, __FUNCTION__, __LINE__, ##arg)
-#define DBG(fmt, arg...) SLOGD("%s:" fmt, __FUNCTION__, ##arg)
-#define VERBOSE(fmt, arg...) SLOGV(fmt, ##arg)
+#define WARN(fmt, arg...) SLOGW(fmt, ##arg)
+#define ERR(fmt, arg...) SLOGE(fmt, ##arg)
+#define DBG(fmt, arg...) SLOGD(fmt, ##arg)
+#define SEC_INFO(fmt, arg...) SECURE_LOGI(fmt, ##arg)
+#define SEC_ERR(fmt, arg...) SECURE_LOGE(fmt, ##arg)
+#define SEC_DBG(fmt, arg...) SECURE_LOGD(fmt, ##arg)
//#define CAL_DEBUGGING
#ifdef CAL_DEBUGGING
- #if defined(CAL_IPC_SERVER)
- #define CAL_FN_CALL DBG("SERVER:>>>>>>>>%s called", __FUNCTION__)
- #define CAL_FN_END DBG("SERVER:<<<<<<<<%s ended", __FUNCTION__)
- #define CAL_FN_CALL_VERBOSE VERBOSE("SERVER:>>>>>>>>%s called", __FUNCTION__)
- #elif defined(CAL_IPC_CLIENT)
- #define CAL_FN_CALL DBG("CLIENT:>>>>>>>>%s called", __FUNCTION__)
- #define CAL_FN_END DBG("CLIENT:<<<<<<<<%s ended", __FUNCTION__)
- #define CAL_FN_CALL_VERBOSE VERBOSE("CLIENT:>>>>>>>>%s called", __FUNCTION__)
- #else
- #define CAL_FN_CALL DBG(">>>>>>>>%s called", __FUNCTION__)
- #define CAL_FN_END DBG("<<<<<<<<%s ended", __FUNCTION__)
- #define CAL_FN_CALL_VERBOSE VERBOSE(">>>>>>>>%s called", __FUNCTION__)
- #endif
-
- #if defined(CAL_IPC_SERVER)
- #define CAL_DBG(fmt, arg...) DBG("SERVER:%d " fmt, __LINE__, ##arg)
- #define CAL_VERBOSE(fmt, arg...) VERBOSE("SERVER:%d " fmt, __LINE__, ##arg)
- #elif defined(CAL_IPC_CLIENT)
- #define CAL_DBG(fmt, arg...) DBG("CLIENT:%d " fmt, __LINE__, ##arg)
- #define CAL_VERBOSE(fmt, arg...) VERBOSE("CLIENT:%d " fmt, __LINE__, ##arg)
- #else
- #define CAL_DBG(fmt, arg...) DBG("%d " fmt, __LINE__, ##arg)
- #define CAL_VERBOSE(fmt, arg...) VERBOSE("%d " fmt, __LINE__, ##arg)
- #endif
+#if defined(CAL_IPC_SERVER)
+#define CAL_FN_CALL DBG("SERVER:>>>>>>>>%s called", __FUNCTION__)
+#define CAL_FN_END DBG("SERVER:<<<<<<<<%s ended", __FUNCTION__)
+#elif defined(CAL_IPC_CLIENT)
+#define CAL_FN_CALL DBG("CLIENT:>>>>>>>>%s called", __FUNCTION__)
+#define CAL_FN_END DBG("CLIENT:<<<<<<<<%s ended", __FUNCTION__)
+#else
+#define CAL_FN_CALL DBG(">>>>>>>>%s called", __FUNCTION__)
+#define CAL_FN_END DBG("<<<<<<<<%s ended", __FUNCTION__)
+#endif
+
+#if defined(CAL_IPC_SERVER)
+#define CAL_DBG(fmt, arg...) DBG("SERVER:%d " fmt, __LINE__, ##arg)
+#elif defined(CAL_IPC_CLIENT)
+#define CAL_DBG(fmt, arg...) DBG("CLIENT:%d " fmt, __LINE__, ##arg)
+#else
+#define CAL_DBG(fmt, arg...) DBG("%d " fmt, __LINE__, ##arg)
+#endif
#else /* CAL_DEBUGGING */
#define CAL_FN_CALL
#define CAL_FN_END
#define CAL_DBG(fmt, arg...)
#endif /* CAL_DEBUGGING */
-
-#define TMDUMP(_X_)\
-{\
- ERR("tm(%d/%d/%d %d:%d)",(_X_).tm_year+1900,(_X_).tm_mon+1,(_X_).tm_mday,(_X_).tm_hour,(_X_).tm_min);\
-}
-
#define warn_if(expr, fmt, arg...) do { \
if (expr) { \
WARN(fmt, ##arg); \
} while (0)
#define retex_if(expr, val, fmt, arg...) do { \
- if(expr) { \
- ERR(fmt, ##arg); \
- val; \
- goto CATCH; \
- } \
- } while (0);
+ if(expr) { \
+ ERR(fmt, ##arg); \
+ val; \
+ goto CATCH; \
+ } \
+} while (0);
#define CAL_PROFILE
#ifdef CAL_PROFILE
#endif
#define CAL_FREE(ptr) \
- do { \
- if (ptr) \
- free(ptr); \
- ptr = NULL; \
- } while(0)
-
-#define ASSERT_NOT_REACHED(fmt, arg...) do { \
- ERR(fmt, ##arg); \
- g_assert_not_reached(); \
-} while(0)
+ do { \
+ if (ptr) \
+ free(ptr); \
+ ptr = NULL; \
+ } while(0)
+
// Thread-local storage
#if defined(CAL_IPC_SERVER)
API int calendar_list_create( calendar_list_h* out_list )
{
+ if (NULL == out_list)
+ {
+ ERR("Invalid parameter: list is NULL");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
cal_list_s *l;
l = (cal_list_s *)calloc(1, sizeof(cal_list_s));
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- l = (cal_list_s *)list;
+ l = (cal_list_s *)list;
*count = l->count;
return CALENDAR_ERROR_NONE;
cursor = l->record;
while (cursor) {
if (cursor->data == record) {
- DBG("Found record and remove");
- l->record = g_list_remove(l->record,cursor->data);
- //calendar_record_destroy((calendar_record_h)(cursor->data));
+ l->cursor = cursor->next;
+ l->record = g_list_remove(l->record, cursor->data);
l->count--;
return CALENDAR_ERROR_NONE;
}
l = (cal_list_s *)list;
if (l->cursor == NULL) {
- ERR("No current data");
*record = NULL;
return CALENDAR_ERROR_NO_DATA;
}
l = (cal_list_s *)list;
l->cursor = g_list_next(l->cursor);
if (l->cursor == NULL) {
- DBG("No next list");
+ //DBG("No next list");
return CALENDAR_ERROR_NO_DATA;
}
if (delete_record == true)
{
- cursor = l->record;
-
- while (cursor)
- {
- if (cursor->data)
- {
- calendar_record_destroy((calendar_record_h)(cursor->data), true);
- }
- cursor = cursor->next;
- }
+ cursor = l->record;
+
+ while (cursor)
+ {
+ if (cursor->data)
+ {
+ calendar_record_destroy((calendar_record_h)(cursor->data), true);
+ }
+ cursor = cursor->next;
+ }
}
if(l->record)
{
- g_list_free(l->record);
+ g_list_free(l->record);
}
CAL_FREE(l);
int _cal_list_clone(calendar_list_h list, calendar_list_h *out_list)
{
- int ret = CALENDAR_ERROR_NONE;
- int count = 0, i = 0;
+ int ret = CALENDAR_ERROR_NONE;
+ int count = 0, i = 0;
calendar_list_h l = NULL;
if (NULL == list || NULL == out_list)
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- ret = calendar_list_get_count(list, &count);
+ ret = calendar_list_get_count(list, &count);
if (CALENDAR_ERROR_NONE != ret)
{
return ret;
}
- ret = calendar_list_first(list);
+ ret = calendar_list_first(list);
if (CALENDAR_ERROR_NONE != ret)
{
return ret;
}
- ret = calendar_list_create(&l);
+ ret = calendar_list_create(&l);
if (CALENDAR_ERROR_NONE != ret)
{
return ret;
}
- for(i = 0; i < count; i++)
- {
- calendar_record_h record = NULL;
- calendar_record_h clone_record = NULL;
- if (calendar_list_get_current_record_p(list,&record) != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_list_get_count fail");
- calendar_list_destroy(l, true);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- if (calendar_record_clone(record, &clone_record) != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_list_get_count fail");
- calendar_list_destroy(l, true);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- if (calendar_list_add(l, clone_record) != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_list_get_count fail");
- calendar_list_destroy(l, true);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- calendar_list_next(list);
- }
+ for(i = 0; i < count; i++)
+ {
+ calendar_record_h record = NULL;
+ calendar_record_h clone_record = NULL;
+ if (calendar_list_get_current_record_p(list,&record) != CALENDAR_ERROR_NONE)
+ {
+ ERR("calendar_list_get_count fail");
+ calendar_list_destroy(l, true);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (calendar_record_clone(record, &clone_record) != CALENDAR_ERROR_NONE)
+ {
+ ERR("calendar_list_get_count fail");
+ calendar_list_destroy(l, true);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (calendar_list_add(l, clone_record) != CALENDAR_ERROR_NONE)
+ {
+ ERR("calendar_list_get_count fail");
+ calendar_list_destroy(l, true);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ calendar_list_next(list);
+ }
*out_list = l;
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
+
+int _cal_list_get_nth_record_p(cal_list_s *list_s, int index, calendar_record_h *record)
+{
+ retv_if(index < 0, CALENDAR_ERROR_INVALID_PARAMETER);
+
+ retv_if(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
+ *record = NULL;
+
+ retv_if(NULL == list_s, CALENDAR_ERROR_INVALID_PARAMETER);
+
+ if (index < list_s->count) {
+ *record = g_list_nth_data(list_s->record, index);
+ return CALENDAR_ERROR_NONE;
+ }
+
+ ERR("Check index(%d) > count(%d)", index, list_s->count);
+ return CALENDAR_ERROR_NO_DATA;
+}
+
+int _cal_list_clear(cal_list_s *list_s)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ calendar_record_h record = NULL;
+ calendar_list_h list = (calendar_list_h)list_s;
+ retv_if(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER);
+
+ calendar_list_first(list);
+ while (CALENDAR_ERROR_NONE == calendar_list_get_current_record_p(list, &record)) {
+ ret = calendar_list_remove(list, record);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("calendar_list_remove() Failed(%d)", ret);
+ break;
+ }
+ }
+ return ret;
+}
+
#include "calendar_list.h"
int _cal_list_clone(calendar_list_h list, calendar_list_h *out_list);
+int _cal_list_get_nth_record_p(cal_list_s *list_s, int index, calendar_record_h *record);
+int _cal_list_clear(cal_list_s *list_s);
#endif // __CALENDAR_SVC_LIST_H__
static pthread_mutex_t __cal_pims_ipc_call_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t __cal_inotify_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t __cal_pims_ipc_pubsub_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t __cal_access_control_mutex = PTHREAD_MUTEX_INITIALIZER;
static inline pthread_mutex_t* __cal_mutex_get_mutex(int type)
{
- pthread_mutex_t *ret_val;
+ pthread_mutex_t *ret_val;
- switch (type) {
- case CAL_MUTEX_PROPERTY_HASH:
- ret_val = &__cal_property_hash_mutex;
- break;
- case CAL_MUTEX_CONNECTION:
- ret_val = &__cal_connection_mutex;
- break;
- case CAL_MUTEX_PIMS_IPC_CALL:
- ret_val = &__cal_pims_ipc_call_mutex;
- break;
- case CAL_MUTEX_INOTIFY:
- ret_val = &__cal_inotify_mutex;
- break;
+ switch (type) {
+ case CAL_MUTEX_PROPERTY_HASH:
+ ret_val = &__cal_property_hash_mutex;
+ break;
+ case CAL_MUTEX_CONNECTION:
+ ret_val = &__cal_connection_mutex;
+ break;
+ case CAL_MUTEX_PIMS_IPC_CALL:
+ ret_val = &__cal_pims_ipc_call_mutex;
+ break;
+ case CAL_MUTEX_INOTIFY:
+ ret_val = &__cal_inotify_mutex;
+ break;
case CAL_MUTEX_PIMS_IPC_PUBSUB:
ret_val = &__cal_pims_ipc_pubsub_mutex;
break;
- default:
- ERR("unknown type(%d)", type);
- ret_val = NULL;
- break;
- }
- return ret_val;
+ case CAL_MUTEX_ACCESS_CONTROL:
+ ret_val = &__cal_access_control_mutex;
+ break;
+ default:
+ ERR("unknown type(%d)", type);
+ ret_val = NULL;
+ break;
+ }
+ return ret_val;
}
void _cal_mutex_lock(int type)
{
- int ret;
- pthread_mutex_t *mutex;
+ int ret;
+ pthread_mutex_t *mutex;
- mutex = __cal_mutex_get_mutex(type);
+ mutex = __cal_mutex_get_mutex(type);
- if (mutex != NULL)
- {
- ret = pthread_mutex_lock(mutex);
- retm_if(ret, "mutex_lock Failed(%d)", ret);
- }
+ if (mutex != NULL)
+ {
+ ret = pthread_mutex_lock(mutex);
+ retm_if(ret, "mutex_lock Failed(%d)", ret);
+ }
}
void _cal_mutex_unlock(int type)
{
- int ret;
- pthread_mutex_t *mutex;
+ int ret;
+ pthread_mutex_t *mutex;
- mutex = __cal_mutex_get_mutex(type);
+ mutex = __cal_mutex_get_mutex(type);
- if (mutex != NULL)
- {
- ret = pthread_mutex_unlock(mutex);
- retm_if(ret, "mutex_unlock Failed(%d)", ret);
- }
+ if (mutex != NULL)
+ {
+ ret = pthread_mutex_unlock(mutex);
+ retm_if(ret, "mutex_unlock Failed(%d)", ret);
+ }
}
#define __CALENDAR_SVC_MUTEX_H__
enum {
- CAL_MUTEX_CONNECTION,
- CAL_MUTEX_PIMS_IPC_CALL,
- CAL_MUTEX_INOTIFY,
- CAL_MUTEX_PROPERTY_HASH,
+ CAL_MUTEX_CONNECTION,
+ CAL_MUTEX_PIMS_IPC_CALL,
+ CAL_MUTEX_INOTIFY,
+ CAL_MUTEX_PROPERTY_HASH,
CAL_MUTEX_PIMS_IPC_PUBSUB,
+ CAL_MUTEX_ACCESS_CONTROL,
};
void _cal_mutex_lock(int type);
#include "cal_query.h"
static bool __cal_query_property_check(const cal_property_info_s *properties,
- int count, unsigned int property_id);
-
-static bool __cal_query_property_check(const cal_property_info_s *properties,
- int count, unsigned int property_id)
+ int count, unsigned int property_id)
{
- int i;
-
- for (i=0;i<count;i++)
- {
- cal_property_info_s *p = (cal_property_info_s*)&(properties[i]);
- if (property_id == p->property_id) {
- return true;
- }
- }
- return false;
+ int i;
+
+ for (i=0;i<count;i++)
+ {
+ cal_property_info_s *p = (cal_property_info_s*)&(properties[i]);
+ if (property_id == p->property_id) {
+ return true;
+ }
+ }
+ return false;
}
API int calendar_query_create( const char* view_uri, calendar_query_h* out_query )
{
- cal_query_s *query;
+ cal_query_s *query;
+
+ retv_if(NULL == view_uri || NULL == out_query, CALENDAR_ERROR_INVALID_PARAMETER);
- retv_if(NULL == view_uri || NULL == out_query, CALENDAR_ERROR_INVALID_PARAMETER);
+ query = (cal_query_s *)calloc(1, sizeof(cal_query_s));
+ retv_if(NULL == query, CALENDAR_ERROR_OUT_OF_MEMORY);
- query = (cal_query_s *)calloc(1, sizeof(cal_query_s));
- query->view_uri = strdup(view_uri);
- query->properties = (cal_property_info_s *)_cal_view_get_property_info(view_uri, &query->property_count);
- *out_query = (calendar_query_h)query;
+ query->view_uri = strdup(view_uri);
+ query->properties = (cal_property_info_s *)_cal_view_get_property_info(view_uri, &query->property_count);
+ *out_query = (calendar_query_h)query;
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
API int calendar_query_set_projection(calendar_query_h query, unsigned int property_ids[], int count)
{
- cal_query_s *que = NULL;
- int i;
- bool find;
+ cal_query_s *que = NULL;
+ int i;
+ bool find;
- retv_if(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER);
- que = (cal_query_s *)query;
+ retv_if(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER);
+ retvm_if(NULL == property_ids, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid paramter: property_ids is NULL");
+ retvm_if(count < 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: check count(%d)", count);
- for (i=0;i<count;i++)
- {
- find = __cal_query_property_check(que->properties, que->property_count, property_ids[i]);
- retvm_if(false == find, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid parameter : property_id(%d) is not supported on view_uri(%s)", property_ids[i], que->view_uri);
+ que = (cal_query_s *)query;
- find = CAL_PROPERTY_CHECK_FLAGS(property_ids[i], CAL_PROPERTY_FLAGS_FILTER);
- retvm_if(true == find, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid parameter : property_id(%d) is not supported on view_uri(%s)", property_ids[i], que->view_uri);
- }
+ for (i=0;i<count;i++)
+ {
+ find = __cal_query_property_check(que->properties, que->property_count, property_ids[i]);
+ retvm_if(false == find, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Invalid parameter : property_id(%d) is not supported on view_uri(%s)", property_ids[i], que->view_uri);
+
+ find = CAL_PROPERTY_CHECK_FLAGS(property_ids[i], CAL_PROPERTY_FLAGS_FILTER);
+ retvm_if(true == find, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Invalid parameter : property_id(%d) is not supported on view_uri(%s)", property_ids[i], que->view_uri);
+ }
- CAL_FREE(que->projection);
+ CAL_FREE(que->projection);
- que->projection = calloc(count, sizeof(unsigned int));
- memcpy(que->projection, property_ids, sizeof(unsigned int) * count);
- que->projection_count = count;
+ que->projection = calloc(count, sizeof(unsigned int));
+ memcpy(que->projection, property_ids, sizeof(unsigned int) * count);
+ que->projection_count = count;
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
API int calendar_query_set_distinct(calendar_query_h query, bool set)
{
- cal_query_s *que = NULL;
+ cal_query_s *que = NULL;
- retv_if(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER);
- que = (cal_query_s *)query;
+ retv_if(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER);
+ que = (cal_query_s *)query;
- que->distinct = set;
+ que->distinct = set;
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
API int calendar_query_set_filter(calendar_query_h query, calendar_filter_h filter)
{
- cal_query_s *que;
- calendar_filter_h new_filter;
- int ret = CALENDAR_ERROR_NONE;
+ cal_query_s *que;
+ calendar_filter_h new_filter;
+ int ret = CALENDAR_ERROR_NONE;
- retv_if(NULL == query || NULL == filter, CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(NULL == query || NULL == filter, CALENDAR_ERROR_INVALID_PARAMETER);
- que = (cal_query_s *)query;
+ que = (cal_query_s *)query;
if(((cal_composite_filter_s*)filter)->filters == NULL)
{
return CALENDAR_ERROR_NO_DATA;
}
- ret = _cal_filter_clone(filter,&new_filter);
- retv_if(ret!=CALENDAR_ERROR_NONE, ret);
+ ret = _cal_filter_clone(filter,&new_filter);
+ retv_if(ret!=CALENDAR_ERROR_NONE, ret);
- if (que->filter)
- {
- calendar_filter_destroy((calendar_filter_h)que->filter);
- }
+ if (que->filter)
+ {
+ calendar_filter_destroy((calendar_filter_h)que->filter);
+ }
- que->filter = (cal_composite_filter_s*)new_filter;
+ que->filter = (cal_composite_filter_s*)new_filter;
- return ret;
+ return ret;
}
API int calendar_query_set_sort(calendar_query_h query, unsigned int property_id, bool asc)
{
- cal_query_s *que;
- bool find = false;
+ cal_query_s *que;
+ bool find = false;
- retv_if(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER);
- que = (cal_query_s *)query;
+ retv_if(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER);
+ que = (cal_query_s *)query;
- find = __cal_query_property_check(que->properties, que->property_count, property_id);
- retvm_if(false == find, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid paramter : property_id(%d) is not supported on view_uri(%s)", property_id, que->view_uri);
+ find = __cal_query_property_check(que->properties, que->property_count, property_id);
+ retvm_if(false == find, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Invalid paramter : property_id(%d) is not supported on view_uri(%s)", property_id, que->view_uri);
- que->sort_property_id = property_id;
- que->asc = asc;
+ que->sort_property_id = property_id;
+ que->asc = asc;
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
API int calendar_query_destroy( calendar_query_h query )
{
- cal_query_s *que;
+ cal_query_s *que;
- retv_if(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER);
- que = (cal_query_s *)query;
+ retv_if(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER);
+ que = (cal_query_s *)query;
- if (que->filter)
- {
- calendar_filter_destroy((calendar_filter_h)que->filter);
- }
+ if (que->filter)
+ {
+ calendar_filter_destroy((calendar_filter_h)que->filter);
+ }
- CAL_FREE(que->view_uri);
- CAL_FREE(que->projection);
- CAL_FREE(que);
+ CAL_FREE(que->view_uri);
+ CAL_FREE(que->projection);
+ CAL_FREE(que);
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
int _cal_query_clone(calendar_query_h query, calendar_query_h* out_query)
{
- cal_query_s *que;
- cal_query_s *out_que;
- cal_filter_s *out_filter = NULL;
- int ret = CALENDAR_ERROR_NONE;
-
- retv_if(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER);
- que = (cal_query_s *)query;
-
- ret = calendar_query_create(que->view_uri, out_query);
- retv_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_OUT_OF_MEMORY);
- out_que = (cal_query_s *)*out_query;
-
- if (que->filter)
- {
- _cal_filter_clone((calendar_filter_h)que->filter,(calendar_filter_h*)&out_filter);
- }
-
- if (que->projection_count > 0)
- {
- out_que->projection = calloc(que->projection_count, sizeof(unsigned int));
- memcpy(out_que->projection, que->projection , sizeof(unsigned int) * que->projection_count);
- out_que->projection_count = que->projection_count;
- }
- out_que->sort_property_id = que->sort_property_id;
- out_que->asc = que->asc;
-
- return CALENDAR_ERROR_NONE;
+ cal_query_s *que;
+ cal_query_s *out_que;
+ cal_filter_s *out_filter = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+
+ retv_if(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER);
+ que = (cal_query_s *)query;
+
+ ret = calendar_query_create(que->view_uri, out_query);
+ retv_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_OUT_OF_MEMORY);
+ out_que = (cal_query_s *)*out_query;
+
+ if (que->filter)
+ {
+ _cal_filter_clone((calendar_filter_h)que->filter,(calendar_filter_h*)&out_filter);
+ }
+
+ if (que->projection_count > 0)
+ {
+ out_que->projection = calloc(que->projection_count, sizeof(unsigned int));
+ memcpy(out_que->projection, que->projection , sizeof(unsigned int) * que->projection_count);
+ out_que->projection_count = que->projection_count;
+ }
+ out_que->sort_property_id = que->sort_property_id;
+ out_que->asc = que->asc;
+
+ return CALENDAR_ERROR_NONE;
}
#include "cal_record.h"
#define __CHECK_READ_ONLY_PROPERTY() \
- if (CAL_PROPERTY_CHECK_FLAGS(property_id,CAL_PROPERTY_FLAGS_READ_ONLY) == true) \
- { \
- ERR("Invalid parameter: Don't try to change read-only property."); \
- return CALENDAR_ERROR_NOT_PERMITTED; \
- }
+ if (CAL_PROPERTY_CHECK_FLAGS(property_id,CAL_PROPERTY_FLAGS_READ_ONLY) == true) \
+{ \
+ ERR("Invalid parameter: Don't try to change read-only property."); \
+ return CALENDAR_ERROR_NOT_PERMITTED; \
+}
extern cal_record_plugin_cb_s _cal_record_calendar_plugin_cb;
extern cal_record_plugin_cb_s _cal_record_event_plugin_cb;
extern cal_record_plugin_cb_s _cal_record_updated_info_plugin_cb;
extern cal_record_plugin_cb_s _cal_record_instance_normal_plugin_cb;
extern cal_record_plugin_cb_s _cal_record_instance_allday_plugin_cb;
+extern cal_record_plugin_cb_s _cal_record_instance_normal_extended_plugin_cb;
+extern cal_record_plugin_cb_s _cal_record_instance_allday_extended_plugin_cb;
extern cal_record_plugin_cb_s _cal_record_search_plugin_cb;
extern cal_record_plugin_cb_s _cal_record_extended_plugin_cb;
case CAL_RECORD_TYPE_TIMEZONE:
return (&_cal_record_timezone_plugin_cb);
case CAL_RECORD_TYPE_INSTANCE_NORMAL:
- return (&_cal_record_instance_normal_plugin_cb);
+ return (&_cal_record_instance_normal_plugin_cb);
case CAL_RECORD_TYPE_INSTANCE_ALLDAY:
- return (&_cal_record_instance_allday_plugin_cb);
+ return (&_cal_record_instance_allday_plugin_cb);
+ case CAL_RECORD_TYPE_INSTANCE_NORMAL_EXTENDED:
+ return (&_cal_record_instance_normal_extended_plugin_cb);
+ case CAL_RECORD_TYPE_INSTANCE_ALLDAY_EXTENDED:
+ return (&_cal_record_instance_allday_extended_plugin_cb);
case CAL_RECORD_TYPE_UPDATED_INFO:
- return (&_cal_record_updated_info_plugin_cb);
- case CAL_RECORD_TYPE_SEARCH:
- return (&_cal_record_search_plugin_cb);
- case CAL_RECORD_TYPE_EXTENDED:
- return (&_cal_record_extended_plugin_cb);
+ return (&_cal_record_updated_info_plugin_cb);
+ case CAL_RECORD_TYPE_SEARCH:
+ return (&_cal_record_search_plugin_cb);
+ case CAL_RECORD_TYPE_EXTENDED:
+ return (&_cal_record_extended_plugin_cb);
default:
return NULL;
}
if (_record->properties_flags == NULL)
{
- int count = 0;
- _cal_view_get_property_info(_record->view_uri,&count);
-
- if (count > 0)
- {
- _record->properties_flags = calloc(count, sizeof(char));
- _record->properties_max_count = count;
- if (_record->properties_flags == NULL)
- {
- ERR("calloc fail");
- return ;
- }
- }
- else
- {
- ERR("get property_info_fail");
- return ;
- }
+ int count = 0;
+ _cal_view_get_property_info(_record->view_uri,&count);
+
+ if (count > 0)
+ {
+ _record->properties_flags = calloc(count, sizeof(char));
+ _record->properties_max_count = count;
+ if (_record->properties_flags == NULL)
+ {
+ ERR("calloc fail");
+ return ;
+ }
+ }
+ else
+ {
+ ERR("get property_info_fail");
+ return ;
+ }
}
_record->properties_flags[index] |= flag;
if (_record->properties_flags == NULL)
{
- if (flag == CAL_PROPERTY_FLAG_PROJECTION)
- return true;
- else
- return false;
+ if (flag == CAL_PROPERTY_FLAG_PROJECTION)
+ return true;
+ else
+ return false;
}
- if (flag == CAL_PROPERTY_FLAG_PROJECTION)
- {
- if (_record->property_flag & CAL_PROPERTY_FLAG_PROJECTION )
- {
- if (_record->properties_flags[index] & CAL_PROPERTY_FLAG_PROJECTION )
- return true;
- else
- return false;
- }
-
- return true;
- }
+ if (flag == CAL_PROPERTY_FLAG_PROJECTION)
+ {
+ if (_record->property_flag & CAL_PROPERTY_FLAG_PROJECTION )
+ {
+ if (_record->properties_flags[index] & CAL_PROPERTY_FLAG_PROJECTION )
+ return true;
+ else
+ return false;
+ }
+
+ return true;
+ }
return (_record->properties_flags[index] & flag) ? true : false;
CAL_FREE(_record->properties_flags);
_record->properties_flags = calloc(properties_max_count, sizeof(char));
- retvm_if(NULL == _record->properties_flags, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc fail");
+ retvm_if(NULL == _record->properties_flags, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc fail");
_record->properties_max_count = properties_max_count;
API int calendar_record_create( const char* view_uri, calendar_record_h* out_record )
{
- int ret = CALENDAR_ERROR_NONE;
- cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
+ int ret = CALENDAR_ERROR_NONE;
+ cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
- retvm_if(NULL == view_uri || NULL == out_record, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == view_uri || NULL == out_record, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- type =_cal_view_get_type(view_uri);
- retv_if(CAL_RECORD_TYPE_INVALID == type, CALENDAR_ERROR_INVALID_PARAMETER);
+ type =_cal_view_get_type(view_uri);
+ retv_if(CAL_RECORD_TYPE_INVALID == type, CALENDAR_ERROR_INVALID_PARAMETER);
- cal_record_plugin_cb_s *plugin_cb = _cal_record_get_plugin_cb(type);
- retvm_if(NULL == plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == plugin_cb->create, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
+ cal_record_plugin_cb_s *plugin_cb = _cal_record_get_plugin_cb(type);
+ retvm_if(NULL == plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == plugin_cb->create, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted in [%s]", view_uri);
- ret = plugin_cb->create(out_record);
+ ret = plugin_cb->create(out_record);
- if(ret == CALENDAR_ERROR_NONE)
- {
- CAL_RECORD_INIT_COMMON((cal_record_s*)*out_record, type, plugin_cb, _cal_view_get_uri(view_uri));
- }
+ if(ret == CALENDAR_ERROR_NONE)
+ {
+ CAL_RECORD_INIT_COMMON((cal_record_s*)*out_record, type, plugin_cb, _cal_view_get_uri(view_uri));
+ }
- return ret;
+ return ret;
}
API int calendar_record_destroy( calendar_record_h record, bool delete_child )
cal_record_s *temp = (cal_record_s*)(record);
retvm_if(NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == temp->plugin_cb->destroy, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
+ retvm_if(NULL == temp->plugin_cb->destroy, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted in [%s]", temp->view_uri);
CAL_FREE(temp->properties_flags);
cal_record_s *temp = (cal_record_s*)(record);
retvm_if(NULL == record || NULL == temp->plugin_cb || NULL == out_record, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == temp->plugin_cb->clone, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
+ retvm_if(NULL == temp->plugin_cb->clone, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted in [%s]", temp->view_uri);
ret = temp->plugin_cb->clone(record, out_record);
API int calendar_record_get_uri_p( calendar_record_h record, char** out_str )
{
- int ret = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
- cal_record_s *temp = (cal_record_s*)(record);
+ cal_record_s *temp = (cal_record_s*)(record);
- retvm_if(NULL == record || NULL == out_str, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == record || NULL == out_str, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- *out_str = (char*)(temp->view_uri);
+ *out_str = (char*)(temp->view_uri);
- return ret;
+ return ret;
}
// Record get/set int,str, etc..
cal_record_s *temp = (cal_record_s*)(record);
retvm_if(NULL == record || NULL == temp->plugin_cb || NULL == out_str, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == temp->plugin_cb->get_str, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
+ retvm_if(NULL == temp->plugin_cb->get_str, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
retvm_if(false == _cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
ret = temp->plugin_cb->get_str(record, property_id, out_str);
cal_record_s *temp = (cal_record_s*)(record);
retvm_if(NULL == record || NULL == temp->plugin_cb || NULL == out_str, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == temp->plugin_cb->get_str_p, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
+ retvm_if(NULL == temp->plugin_cb->get_str_p, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
retvm_if(false == _cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
ret = temp->plugin_cb->get_str_p(record, property_id, out_str);
cal_record_s *temp = (cal_record_s*)(record);
retvm_if(NULL == record || NULL == temp->plugin_cb || NULL == out_value, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == temp->plugin_cb->get_int, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
+ retvm_if(NULL == temp->plugin_cb->get_int, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
retvm_if(false == _cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
ret = temp->plugin_cb->get_int(record, property_id, out_value);
cal_record_s *temp = (cal_record_s*)(record);
retvm_if(NULL == record || NULL == temp->plugin_cb || NULL == out_value, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == temp->plugin_cb->get_double, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
+ retvm_if(NULL == temp->plugin_cb->get_double, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
retvm_if(false == _cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
ret = temp->plugin_cb->get_double(record, property_id, out_value);
cal_record_s *temp = (cal_record_s*)(record);
retvm_if(NULL == record || NULL == temp->plugin_cb || NULL == out_value, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == temp->plugin_cb->get_lli, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
+ retvm_if(NULL == temp->plugin_cb->get_lli, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
retvm_if(false == _cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
ret = temp->plugin_cb->get_lli(record, property_id, out_value);
cal_record_s *temp = (cal_record_s*)(record);
retvm_if(NULL == record || NULL == temp->plugin_cb || NULL == out_value, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == temp->plugin_cb->get_caltime, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
+ retvm_if(NULL == temp->plugin_cb->get_caltime, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
retvm_if(false == _cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
ret = temp->plugin_cb->get_caltime(record, property_id, out_value);
API int calendar_record_set_str( calendar_record_h record, unsigned int property_id, const char* value )
{
- retvm_if(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- __CHECK_READ_ONLY_PROPERTY();
+ retvm_if(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ __CHECK_READ_ONLY_PROPERTY();
- int ret = _cal_record_set_str(record, property_id, value);
+ int ret = _cal_record_set_str(record, property_id, value);
return ret;
}
API int calendar_record_set_int( calendar_record_h record, unsigned int property_id, int value )
{
- retvm_if(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- __CHECK_READ_ONLY_PROPERTY();
+ retvm_if(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ __CHECK_READ_ONLY_PROPERTY();
- int ret = _cal_record_set_int(record, property_id, value);
+ int ret = _cal_record_set_int(record, property_id, value);
- return ret;
+ return ret;
}
API int calendar_record_set_double( calendar_record_h record, unsigned int property_id, double value )
{
- retvm_if(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- __CHECK_READ_ONLY_PROPERTY();
+ retvm_if(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ __CHECK_READ_ONLY_PROPERTY();
- int ret = _cal_record_set_double(record, property_id, value);
+ int ret = _cal_record_set_double(record, property_id, value);
- return ret;
+ return ret;
}
API int calendar_record_set_lli( calendar_record_h record, unsigned int property_id, long long int value )
{
- retvm_if(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- __CHECK_READ_ONLY_PROPERTY();
+ retvm_if(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ __CHECK_READ_ONLY_PROPERTY();
- int ret = _cal_record_set_lli(record, property_id, value);
+ int ret = _cal_record_set_lli(record, property_id, value);
- return ret;
+ return ret;
}
API int calendar_record_set_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s value )
{
- retvm_if(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- __CHECK_READ_ONLY_PROPERTY();
+ retvm_if(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ __CHECK_READ_ONLY_PROPERTY();
- int ret = _cal_record_set_caltime(record, property_id, value);
+ int ret = _cal_record_set_caltime(record, property_id, value);
- return ret;
+ return ret;
}
// Record get/set child records
cal_record_s *temp = (cal_record_s*)(record);
retvm_if(NULL == record || NULL == temp->plugin_cb || NULL == child_record, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == temp->plugin_cb->add_child_record, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
+ retvm_if(NULL == temp->plugin_cb->add_child_record, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
retvm_if(false == _cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
ret = temp->plugin_cb->add_child_record(record, property_id, child_record);
cal_record_s *temp = (cal_record_s*)(record);
retvm_if(NULL == record || NULL == temp->plugin_cb || NULL == child_record, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == temp->plugin_cb->remove_child_record, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
+ retvm_if(NULL == temp->plugin_cb->remove_child_record, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
retvm_if(false == _cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
ret = temp->plugin_cb->remove_child_record(record, property_id, child_record);
cal_record_s *temp = (cal_record_s*)(record);
retvm_if(NULL == record || NULL == temp->plugin_cb || NULL == count, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == temp->plugin_cb->get_child_record_count, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
+ retvm_if(NULL == temp->plugin_cb->get_child_record_count, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
retvm_if(false == _cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
ret = temp->plugin_cb->get_child_record_count(record, property_id, count);
cal_record_s *temp = (cal_record_s*)(record);
retvm_if(NULL == record || NULL == temp->plugin_cb || NULL == child_record, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == temp->plugin_cb->get_child_record_at_p, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
+ retvm_if(NULL == temp->plugin_cb->get_child_record_at_p, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
retvm_if(false == _cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
ret = temp->plugin_cb->get_child_record_at_p(record, property_id, index, child_record);
cal_record_s *temp = (cal_record_s*)(record);
retvm_if(NULL == record || NULL == temp->plugin_cb || NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == temp->plugin_cb->clone_child_record_list, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
+ retvm_if(NULL == temp->plugin_cb->clone_child_record_list, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
retvm_if(false == _cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
ret = temp->plugin_cb->clone_child_record_list(record, property_id, out_list);
int _cal_record_set_str( calendar_record_h record, unsigned int property_id, const char* value )
{
- int ret = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
- cal_record_s *temp = (cal_record_s*)(record);
+ cal_record_s *temp = (cal_record_s*)(record);
- retvm_if(NULL == record || NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == temp->plugin_cb->set_str, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
- retvm_if(false == _cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
+ retvm_if(NULL == record || NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == temp->plugin_cb->set_str, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
+ retvm_if(false == _cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
- ret = temp->plugin_cb->set_str(record, property_id, value);
- if (ret == CALENDAR_ERROR_NONE)
- {
- __cal_record_set_property_flag(record,property_id,CAL_PROPERTY_FLAG_DIRTY);
- }
- return ret;
+ ret = temp->plugin_cb->set_str(record, property_id, value);
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ __cal_record_set_property_flag(record,property_id,CAL_PROPERTY_FLAG_DIRTY);
+ }
+ return ret;
}
int _cal_record_set_int( calendar_record_h record, unsigned int property_id, int value )
{
- int ret = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
- cal_record_s *temp = (cal_record_s*)(record);
+ cal_record_s *temp = (cal_record_s*)(record);
- retvm_if(NULL == record || NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == temp->plugin_cb->set_int, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
- retvm_if(false == _cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
+ retvm_if(NULL == record || NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == temp->plugin_cb->set_int, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
+ retvm_if(false == _cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
- ret = temp->plugin_cb->set_int(record, property_id, value);
- if (ret == CALENDAR_ERROR_NONE)
- {
- __cal_record_set_property_flag(record,property_id,CAL_PROPERTY_FLAG_DIRTY);
- }
- return ret;
+ ret = temp->plugin_cb->set_int(record, property_id, value);
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ __cal_record_set_property_flag(record,property_id,CAL_PROPERTY_FLAG_DIRTY);
+ }
+ return ret;
}
int _cal_record_set_double( calendar_record_h record, unsigned int property_id, double value )
{
- int ret = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
- cal_record_s *temp = (cal_record_s*)(record);
+ cal_record_s *temp = (cal_record_s*)(record);
- retvm_if(NULL == record || NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == temp->plugin_cb->set_double, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
- retvm_if(false == _cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
+ retvm_if(NULL == record || NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == temp->plugin_cb->set_double, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
+ retvm_if(false == _cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
- ret = temp->plugin_cb->set_double(record, property_id, value);
- if (ret == CALENDAR_ERROR_NONE)
- {
- __cal_record_set_property_flag(record,property_id,CAL_PROPERTY_FLAG_DIRTY);
- }
- return ret;
+ ret = temp->plugin_cb->set_double(record, property_id, value);
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ __cal_record_set_property_flag(record,property_id,CAL_PROPERTY_FLAG_DIRTY);
+ }
+ return ret;
}
int _cal_record_set_lli( calendar_record_h record, unsigned int property_id, long long int value )
{
- int ret = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
- cal_record_s *temp = (cal_record_s*)(record);
+ cal_record_s *temp = (cal_record_s*)(record);
- retvm_if(NULL == record || NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == temp->plugin_cb->set_lli, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
- retvm_if(false == _cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
+ retvm_if(NULL == record || NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == temp->plugin_cb->set_lli, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
+ retvm_if(false == _cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
- ret = temp->plugin_cb->set_lli(record, property_id, value);
- if (ret == CALENDAR_ERROR_NONE)
- {
- __cal_record_set_property_flag(record,property_id,CAL_PROPERTY_FLAG_DIRTY);
- }
- return ret;
+ ret = temp->plugin_cb->set_lli(record, property_id, value);
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ __cal_record_set_property_flag(record,property_id,CAL_PROPERTY_FLAG_DIRTY);
+ }
+ return ret;
}
int _cal_record_set_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s value )
{
- int ret = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
- cal_record_s *temp = (cal_record_s*)(record);
+ cal_record_s *temp = (cal_record_s*)(record);
- retvm_if(NULL == record || NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == temp->plugin_cb->set_caltime, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
- retvm_if(false == _cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
+ retvm_if(NULL == record || NULL == temp->plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == temp->plugin_cb->set_caltime, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted(%x) in [%s]", property_id, temp->view_uri);
+ retvm_if(false == _cal_record_check_property_flag(record, property_id,CAL_PROPERTY_FLAG_PROJECTION), CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
- ret = temp->plugin_cb->set_caltime(record, property_id, value);
- if (ret == CALENDAR_ERROR_NONE)
- {
- __cal_record_set_property_flag(record,property_id,CAL_PROPERTY_FLAG_DIRTY);
- }
- return ret;
+ ret = temp->plugin_cb->set_caltime(record, property_id, value);
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ __cal_record_set_property_flag(record,property_id,CAL_PROPERTY_FLAG_DIRTY);
+ }
+ return ret;
}
typedef enum
{
- CAL_RECORD_TYPE_INVALID = 0,
- CAL_RECORD_TYPE_CALENDAR,
- CAL_RECORD_TYPE_EVENT ,
- CAL_RECORD_TYPE_TODO,
- CAL_RECORD_TYPE_TIMEZONE,
- CAL_RECORD_TYPE_ATTENDEE,
- CAL_RECORD_TYPE_ALARM,
- CAL_RECORD_TYPE_INSTANCE_NORMAL,
- CAL_RECORD_TYPE_INSTANCE_ALLDAY,
- CAL_RECORD_TYPE_UPDATED_INFO,
- CAL_RECORD_TYPE_SEARCH,
- CAL_RECORD_TYPE_EXTENDED,
-
+ CAL_RECORD_TYPE_INVALID = 0,
+ CAL_RECORD_TYPE_CALENDAR,
+ CAL_RECORD_TYPE_EVENT ,
+ CAL_RECORD_TYPE_TODO,
+ CAL_RECORD_TYPE_TIMEZONE,
+ CAL_RECORD_TYPE_ATTENDEE,
+ CAL_RECORD_TYPE_ALARM,
+ CAL_RECORD_TYPE_INSTANCE_NORMAL,
+ CAL_RECORD_TYPE_INSTANCE_ALLDAY,
+ CAL_RECORD_TYPE_INSTANCE_NORMAL_EXTENDED,
+ CAL_RECORD_TYPE_INSTANCE_ALLDAY_EXTENDED,
+ CAL_RECORD_TYPE_UPDATED_INFO,
+ CAL_RECORD_TYPE_SEARCH,
+ CAL_RECORD_TYPE_EXTENDED,
} cal_record_type_e;
typedef int (*cal_record_create_cb)( calendar_record_h* out_record );
} cal_record_plugin_cb_s;
typedef struct {
- cal_record_type_e type;
- cal_record_plugin_cb_s *plugin_cb;
- const char* view_uri;
+ cal_record_type_e type;
+ cal_record_plugin_cb_s *plugin_cb;
+ const char* view_uri;
unsigned int properties_max_count;
unsigned char *properties_flags;
unsigned char property_flag;
} cal_record_s;
#define CAL_RECORD_INIT_COMMON(common, intype, cb, uri) do {\
- (common)->type = (intype);\
- (common)->plugin_cb = (cb);\
- (common)->view_uri = (uri);\
- (common)->properties_max_count = 0;\
- (common)->properties_flags = NULL;\
- (common)->property_flag = 0;\
+ (common)->type = (intype);\
+ (common)->plugin_cb = (cb);\
+ (common)->view_uri = (uri);\
+ (common)->properties_max_count = 0;\
+ (common)->properties_flags = NULL;\
+ (common)->property_flag = 0;\
} while (0)
#define CAL_RECORD_COPY_COMMON(dst, src) do {\
- (dst)->type = (src)->type;\
- (dst)->plugin_cb = (src)->plugin_cb;\
- (dst)->view_uri = (src)->view_uri;\
- (dst)->properties_max_count = (src)->properties_max_count;\
+ (dst)->type = (src)->type;\
+ (dst)->plugin_cb = (src)->plugin_cb;\
+ (dst)->view_uri = (src)->view_uri;\
+ (dst)->properties_max_count = (src)->properties_max_count;\
if ((src)->properties_flags) \
- {\
- (dst)->properties_flags = calloc((dst)->properties_max_count, sizeof(char));\
- if ((dst)->properties_flags)\
- memcpy((dst)->properties_flags,(src)->properties_flags,sizeof(char)*(dst)->properties_max_count);\
- }\
- (dst)->property_flag = (src)->property_flag;\
+ {\
+ (dst)->properties_flags = calloc((dst)->properties_max_count, sizeof(char));\
+ if ((dst)->properties_flags)\
+ memcpy((dst)->properties_flags,(src)->properties_flags,sizeof(char)*(dst)->properties_max_count);\
+ }\
+ (dst)->property_flag = (src)->property_flag;\
} while (0)
#define CAL_RECORD_RESET_COMMON(src) do {\
- if ((src)->properties_flags) \
- {\
- free((src)->properties_flags); \
- (src)->properties_max_count = 0;\
- (src)->properties_flags = NULL;\
- (src)->property_flag = 0;\
- }\
+ if ((src)->properties_flags) \
+ {\
+ free((src)->properties_flags); \
+ (src)->properties_max_count = 0;\
+ (src)->properties_flags = NULL;\
+ (src)->property_flag = 0;\
+ }\
} while (0)
cal_record_plugin_cb_s* _cal_record_get_plugin_cb(cal_record_type_e type);
static int __cal_record_alarm_get_str( calendar_record_h record, unsigned int property_id, char** out_str );
static int __cal_record_alarm_get_str_p( calendar_record_h record, unsigned int property_id, char** out_str );
static int __cal_record_alarm_get_int( calendar_record_h record, unsigned int property_id, int* out_value );
-static int __cal_record_alarm_get_lli( calendar_record_h record, unsigned int property_id, long long int* out_value );
+static int __cal_record_alarm_get_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s* out_value );
static int __cal_record_alarm_set_str( calendar_record_h record, unsigned int property_id, const char* value );
static int __cal_record_alarm_set_int( calendar_record_h record, unsigned int property_id, int value );
-static int __cal_record_alarm_set_lli( calendar_record_h record, unsigned int property_id, long long int value );
+static int __cal_record_alarm_set_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s value );
cal_record_plugin_cb_s _cal_record_alarm_plugin_cb = {
.create = __cal_record_alarm_create,
.get_str_p = __cal_record_alarm_get_str_p,
.get_int = __cal_record_alarm_get_int,
.get_double = NULL,
- .get_lli = __cal_record_alarm_get_lli,
- .get_caltime = NULL,
+ .get_lli = NULL,
+ .get_caltime = __cal_record_alarm_get_caltime,
.set_str = __cal_record_alarm_set_str,
.set_int = __cal_record_alarm_set_int,
.set_double = NULL,
- .set_lli = __cal_record_alarm_set_lli,
- .set_caltime = NULL,
+ .set_lli = NULL,
+ .set_caltime = __cal_record_alarm_set_caltime,
.add_child_record = NULL,
.remove_child_record = NULL,
.get_child_record_count = NULL,
static int __cal_record_alarm_create(calendar_record_h* out_record )
{
cal_alarm_s *temp = NULL;
- int ret= CALENDAR_ERROR_NONE, type = 0;
-
- type = CAL_RECORD_TYPE_ALARM;
+ int ret= CALENDAR_ERROR_NONE;
temp = (cal_alarm_s*)calloc(1,sizeof(cal_alarm_s));
retvm_if(NULL == temp, CALENDAR_ERROR_OUT_OF_MEMORY, "malloc(cal_alarm_s:sch) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
static void __cal_record_alarm_struct_free(cal_alarm_s *record)
{
- CAL_FREE(record->alarm_tone);
CAL_FREE(record->alarm_description);
+ CAL_FREE(record->alarm_summary);
+ CAL_FREE(record->alarm_attach);
CAL_FREE(record);
}
static int __cal_record_alarm_destroy( calendar_record_h record, bool delete_child )
{
- int ret = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
- cal_alarm_s *temp = (cal_alarm_s*)(record);
+ cal_alarm_s *temp = (cal_alarm_s*)(record);
- __cal_record_alarm_struct_free(temp);
+ __cal_record_alarm_struct_free(temp);
return ret;
}
CAL_RECORD_COPY_COMMON(&(out_data->common), &(src_data->common));
- out_data->alarm_id = src_data->alarm_id;
- out_data->event_id = src_data->event_id;
- out_data->alarm_type = src_data->alarm_type;
+ out_data->parent_id = src_data->parent_id;
out_data->is_deleted = src_data->is_deleted;
- out_data->alarm_time = src_data->alarm_time;
out_data->remind_tick = src_data->remind_tick;
out_data->remind_tick_unit = src_data->remind_tick_unit;
- out_data->alarm_tone = SAFE_STRDUP(src_data->alarm_tone);
out_data->alarm_description = SAFE_STRDUP(src_data->alarm_description);
+ out_data->alarm_summary = SAFE_STRDUP(src_data->alarm_summary);
+ out_data->alarm_action = src_data->alarm_action;
+ out_data->alarm_attach = SAFE_STRDUP(src_data->alarm_attach);
+ out_data->alarm = src_data->alarm;
- *out_record = (calendar_record_h)out_data;
+ *out_record = (calendar_record_h)out_data;
return CALENDAR_ERROR_NONE;
}
cal_alarm_s *rec = (cal_alarm_s*)(record);
switch( property_id )
{
- case CAL_PROPERTY_ALARM_TONE:
- *out_str = SAFE_STRDUP(rec->alarm_tone);
- break;
case CAL_PROPERTY_ALARM_DESCRIPTION:
*out_str = SAFE_STRDUP(rec->alarm_description);
break;
+ case CAL_PROPERTY_ALARM_SUMMARY:
+ *out_str = SAFE_STRDUP(rec->alarm_summary);
+ break;
+ case CAL_PROPERTY_ALARM_ATTACH:
+ *out_str = SAFE_STRDUP(rec->alarm_attach);
+ break;
default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
+ ERR("invalid parameter (property:%d)",property_id);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
cal_alarm_s *rec = (cal_alarm_s*)(record);
switch( property_id )
{
- case CAL_PROPERTY_ALARM_TONE:
- *out_str = (rec->alarm_tone);
- break;
case CAL_PROPERTY_ALARM_DESCRIPTION:
*out_str = (rec->alarm_description);
break;
+ case CAL_PROPERTY_ALARM_SUMMARY:
+ *out_str = (rec->alarm_summary);
+ break;
+ case CAL_PROPERTY_ALARM_ATTACH:
+ *out_str = (rec->alarm_attach);
+ break;
default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
+ ERR("invalid parameter (property:%d)",property_id);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
cal_alarm_s *rec = (cal_alarm_s*)(record);
switch( property_id )
{
- case CAL_PROPERTY_ALARM_TYPE:
- *out_value = (rec->alarm_type);
- break;
case CAL_PROPERTY_ALARM_TICK:
*out_value = (rec->remind_tick);
break;
case CAL_PROPERTY_ALARM_TICK_UNIT:
*out_value = (rec->remind_tick_unit);
break;
- case CAL_PROPERTY_ALARM_ID:
- *out_value = (rec->alarm_id);
+ case CAL_PROPERTY_ALARM_PARENT_ID:
+ *out_value = (rec->parent_id);
+ break;
+ case CAL_PROPERTY_ALARM_ACTION:
+ *out_value = (rec->alarm_action);
break;
- case CAL_PROPERTY_ALARM_EVENT_TODO_ID:
- *out_value = (rec->event_id);
- break;
default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
+ ERR("invalid parameter (property:%d)",property_id);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
return CALENDAR_ERROR_NONE;
}
-static int __cal_record_alarm_get_lli( calendar_record_h record, unsigned int property_id, long long int* out_value )
+static int __cal_record_alarm_get_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s* out_value )
{
cal_alarm_s *rec = (cal_alarm_s*)(record);
switch( property_id )
{
- case CAL_PROPERTY_ALARM_TIME:
- *out_value = (rec->alarm_time);
+ case CAL_PROPERTY_ALARM_ALARM:
+ *out_value = rec->alarm;
break;
default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
+ ERR("invalid parameter (property:%d)",property_id);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
-
return CALENDAR_ERROR_NONE;
}
cal_alarm_s *rec = (cal_alarm_s*)(record);
switch( property_id )
{
- case CAL_PROPERTY_ALARM_TONE:
- CAL_FREE(rec->alarm_tone);
- rec->alarm_tone = SAFE_STRDUP(value);
- break;
case CAL_PROPERTY_ALARM_DESCRIPTION:
CAL_FREE(rec->alarm_description);
rec->alarm_description = SAFE_STRDUP(value);
break;
+ case CAL_PROPERTY_ALARM_SUMMARY:
+ CAL_FREE(rec->alarm_summary);
+ rec->alarm_summary = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_ALARM_ATTACH:
+ CAL_FREE(rec->alarm_attach);
+ rec->alarm_attach = SAFE_STRDUP(value);
+ break;
default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
+ ERR("invalid parameter (property:%d)",property_id);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
cal_alarm_s *rec = (cal_alarm_s*)(record);
switch( property_id )
{
- case CAL_PROPERTY_ALARM_TYPE:
- (rec->alarm_type)=value;
- break;
case CAL_PROPERTY_ALARM_TICK:
(rec->remind_tick)=value;
break;
case CAL_PROPERTY_ALARM_TICK_UNIT:
- (rec->remind_tick_unit)=value;
+ switch (value)
+ {
+ case CALENDAR_ALARM_NONE:
+ case CALENDAR_ALARM_TIME_UNIT_SPECIFIC:
+ case CALENDAR_ALARM_TIME_UNIT_MINUTE:
+ case CALENDAR_ALARM_TIME_UNIT_HOUR:
+ case CALENDAR_ALARM_TIME_UNIT_DAY:
+ case CALENDAR_ALARM_TIME_UNIT_WEEK:
+ (rec->remind_tick_unit)=value;
+ break;
+ default:
+ ERR("invalid parameter (value:%d)", value);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ case CAL_PROPERTY_ALARM_PARENT_ID:
+ (rec->parent_id) = value;
break;
- case CAL_PROPERTY_ALARM_ID:
- (rec->alarm_id) = value;
+ case CAL_PROPERTY_ALARM_ACTION:
+ switch (value)
+ {
+ case CALENDAR_ALARM_ACTION_AUDIO:
+ case CALENDAR_ALARM_ACTION_DISPLAY:
+ case CALENDAR_ALARM_ACTION_EMAIL:
+ (rec->alarm_action) = value;
+ break;
+ default:
+ ERR("invalid parameter (value:%d)", value);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
break;
- case CAL_PROPERTY_ALARM_EVENT_TODO_ID:
- (rec->event_id) = value;
- break;
default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
+ ERR("invalid parameter (property:%d)",property_id);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
return CALENDAR_ERROR_NONE;
}
-static int __cal_record_alarm_set_lli( calendar_record_h record, unsigned int property_id, long long int value )
+static int __cal_record_alarm_set_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s value )
{
cal_alarm_s *rec = (cal_alarm_s*)(record);
switch( property_id )
{
- case CAL_PROPERTY_ALARM_TIME:
- (rec->alarm_time) = value;
+ case CAL_PROPERTY_ALARM_ALARM:
+ rec->alarm = value;
break;
default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
+ ERR("invalid parameter (property:%d)",property_id);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
-
return CALENDAR_ERROR_NONE;
+
}
static int __cal_record_attendee_create(calendar_record_h* out_record )
{
cal_attendee_s *temp = NULL;
- int ret= CALENDAR_ERROR_NONE, type = 0;
-
- type = CAL_RECORD_TYPE_ATTENDEE;
+ int ret= CALENDAR_ERROR_NONE;
temp = (cal_attendee_s*)calloc(1,sizeof(cal_attendee_s));
retvm_if(NULL == temp, CALENDAR_ERROR_OUT_OF_MEMORY, "malloc(cal_attendee_s:sch) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
__cal_record_attendee_struct_init(temp);
- *out_record = (calendar_record_h)temp;
+ *out_record = (calendar_record_h)temp;
return ret;
}
CAL_FREE(record->attendee_uid);
CAL_FREE(record->attendee_group);
CAL_FREE(record->attendee_email);
- CAL_FREE(record->attendee_delegate_uri);
+ CAL_FREE(record->attendee_delegatee_uri);
CAL_FREE(record->attendee_delegator_uri);
CAL_FREE(record->attendee_name);
+ CAL_FREE(record->attendee_member);
CAL_FREE(record);
}
static int __cal_record_attendee_destroy( calendar_record_h record, bool delete_child )
{
- int ret = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
- cal_attendee_s *temp = (cal_attendee_s*)(record);
+ cal_attendee_s *temp = (cal_attendee_s*)(record);
- __cal_record_attendee_struct_free(temp);
+ __cal_record_attendee_struct_free(temp);
return ret;
}
CAL_RECORD_COPY_COMMON(&(out_data->common), &(src_data->common));
- out_data->event_id = src_data->event_id;
- out_data->attendee_type = src_data->attendee_type;
+ out_data->parent_id = src_data->parent_id;
+ out_data->attendee_cutype = src_data->attendee_cutype;
out_data->attendee_ct_index = src_data->attendee_ct_index;
out_data->attendee_role = src_data->attendee_role;
out_data->attendee_status = src_data->attendee_status;
out_data->attendee_uid = SAFE_STRDUP(src_data->attendee_uid);
out_data->attendee_group = SAFE_STRDUP(src_data->attendee_group);
out_data->attendee_email = SAFE_STRDUP(src_data->attendee_email);
- out_data->attendee_delegate_uri = SAFE_STRDUP(src_data->attendee_delegate_uri);
+ out_data->attendee_delegatee_uri = SAFE_STRDUP(src_data->attendee_delegatee_uri);
out_data->attendee_delegator_uri = SAFE_STRDUP(src_data->attendee_delegator_uri);
out_data->attendee_name = SAFE_STRDUP(src_data->attendee_name);
+ out_data->attendee_member = SAFE_STRDUP(src_data->attendee_member);
- *out_record = (calendar_record_h)out_data;
+ *out_record = (calendar_record_h)out_data;
return CALENDAR_ERROR_NONE;
}
case CAL_PROPERTY_ATTENDEE_EMAIL:
*out_str = SAFE_STRDUP(rec->attendee_email);
break;
- case CAL_PROPERTY_ATTENDEE_DELEGATE_URI:
- *out_str = SAFE_STRDUP(rec->attendee_delegate_uri);
+ case CAL_PROPERTY_ATTENDEE_DELEGATEE_URI:
+ *out_str = SAFE_STRDUP(rec->attendee_delegatee_uri);
break;
case CAL_PROPERTY_ATTENDEE_DELEGATOR_URI:
*out_str = SAFE_STRDUP(rec->attendee_delegator_uri);
case CAL_PROPERTY_ATTENDEE_NAME:
*out_str = SAFE_STRDUP(rec->attendee_name);
break;
+ case CAL_PROPERTY_ATTENDEE_MEMBER:
+ *out_str = SAFE_STRDUP(rec->attendee_member);
+ break;
default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
+ ERR("invalid parameter (property:%d)",property_id);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
case CAL_PROPERTY_ATTENDEE_EMAIL:
*out_str = (rec->attendee_email);
break;
- case CAL_PROPERTY_ATTENDEE_DELEGATE_URI:
- *out_str = (rec->attendee_delegate_uri);
+ case CAL_PROPERTY_ATTENDEE_DELEGATEE_URI:
+ *out_str = (rec->attendee_delegatee_uri);
break;
case CAL_PROPERTY_ATTENDEE_DELEGATOR_URI:
*out_str = (rec->attendee_delegator_uri);
case CAL_PROPERTY_ATTENDEE_NAME:
*out_str = (rec->attendee_name);
break;
+ case CAL_PROPERTY_ATTENDEE_MEMBER:
+ *out_str = (rec->attendee_member);
+ break;
default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
+ ERR("invalid parameter (property:%d)",property_id);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
cal_attendee_s *rec = (cal_attendee_s*)(record);
switch( property_id )
{
- //case CAL_PROPERTY_CALENDAR_ID:
- // *out_value = (rec->event_id);
- // break;
- case CAL_PROPERTY_ATTENDEE_TYPE:
- *out_value = (rec->attendee_type);
+ case CAL_PROPERTY_ATTENDEE_CUTYPE:
+ *out_value = (rec->attendee_cutype);
break;
case CAL_PROPERTY_ATTENDEE_CT_INDEX:
*out_value = (rec->attendee_ct_index);
case CAL_PROPERTY_ATTENDEE_RSVP:
*out_value = (rec->attendee_rsvp);
break;
- case CAL_PROPERTY_ATTENDEE_EVENT_ID:
- *out_value = (rec->event_id);
- break;
+ case CAL_PROPERTY_ATTENDEE_PARENT_ID:
+ *out_value = (rec->parent_id);
+ break;
default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
+ ERR("invalid parameter (property:%d)",property_id);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
CAL_FREE(rec->attendee_email);
rec->attendee_email = SAFE_STRDUP(value);
break;
- case CAL_PROPERTY_ATTENDEE_DELEGATE_URI:
- CAL_FREE(rec->attendee_delegate_uri);
- rec->attendee_delegate_uri = SAFE_STRDUP(value);
+ case CAL_PROPERTY_ATTENDEE_DELEGATEE_URI:
+ CAL_FREE(rec->attendee_delegatee_uri);
+ rec->attendee_delegatee_uri = SAFE_STRDUP(value);
break;
case CAL_PROPERTY_ATTENDEE_DELEGATOR_URI:
CAL_FREE(rec->attendee_delegator_uri);
CAL_FREE(rec->attendee_name);
rec->attendee_name = SAFE_STRDUP(value);
break;
+ case CAL_PROPERTY_ATTENDEE_MEMBER:
+ CAL_FREE(rec->attendee_member);
+ rec->attendee_member = SAFE_STRDUP(value);
+ break;
default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
+ ERR("invalid parameter (property:%d)",property_id);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
cal_attendee_s *rec = (cal_attendee_s*)(record);
switch( property_id )
{
- //case CAL_PROPERTY_CALENDAR_ID:
- // *out_value = (rec->event_id);
- // break;
- case CAL_PROPERTY_ATTENDEE_TYPE:
- (rec->attendee_type) = value;
+ case CAL_PROPERTY_ATTENDEE_CUTYPE:
+ (rec->attendee_cutype) = value;
break;
case CAL_PROPERTY_ATTENDEE_CT_INDEX:
(rec->attendee_ct_index) = value;
case CAL_PROPERTY_ATTENDEE_RSVP:
(rec->attendee_rsvp) = value;
break;
- case CAL_PROPERTY_ATTENDEE_EVENT_ID:
- (rec->event_id) = value;
- break;
+ case CAL_PROPERTY_ATTENDEE_PARENT_ID:
+ (rec->parent_id) = value;
+ break;
default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
+ ERR("invalid parameter (property:%d)",property_id);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
static int __cal_record_calendar_create( calendar_record_h* out_record )
{
cal_calendar_s *temp = NULL;
- int ret= CALENDAR_ERROR_NONE, type = 0;
-
- type = CAL_RECORD_TYPE_CALENDAR;
+ int ret= CALENDAR_ERROR_NONE;
temp = (cal_calendar_s*)calloc(1,sizeof(cal_calendar_s));
retvm_if(NULL == temp, CALENDAR_ERROR_OUT_OF_MEMORY, "malloc(cal_calendar_s) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
static int __cal_record_calendar_destroy( calendar_record_h record, bool delete_child )
{
- int ret = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
cal_calendar_s *temp = (cal_calendar_s*)(record);
- __cal_record_calendar_struct_free(temp);
+ __cal_record_calendar_struct_free(temp);
- return ret;
+ return ret;
}
static int __cal_record_calendar_clone( calendar_record_h record, calendar_record_h* out_record )
out_data->sync_data2 = SAFE_STRDUP(src_data->sync_data2);
out_data->sync_data3 = SAFE_STRDUP(src_data->sync_data3);
out_data->sync_data4 = SAFE_STRDUP(src_data->sync_data4);
+ out_data->mode = src_data->mode;
- *out_record = (calendar_record_h)out_data;
+ *out_record = (calendar_record_h)out_data;
return CALENDAR_ERROR_NONE;
}
*out_str = SAFE_STRDUP(cal_rec->sync_data4);
break;
default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
+ ERR("invalid parameter (property:%d)",property_id);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
*out_str = (cal_rec->sync_data4);
break;
default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
+ ERR("invalid parameter (property:%d)",property_id);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
case CAL_PROPERTY_CALENDAR_VISIBILITY:
*out_value = (cal_rec->visibility);
break;
- case CAL_PROPERTY_CALENDAR_IS_DELETED:
- *out_value = (cal_rec->is_deleted);
- break;
case CAL_PROPERTY_CALENDAR_ACCOUNT_ID:
*out_value = (cal_rec->account_id);
break;
*out_value = (cal_rec->store_type);
break;
case CAL_PROPERTY_CALENDAR_SYNC_EVENT:
- *out_value = (cal_rec->sync_event);
- break;
+ *out_value = (cal_rec->sync_event);
+ break;
+ case CAL_PROPERTY_CALENDAR_MODE:
+ *out_value = (cal_rec->mode);
+ break;
default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
+ ERR("invalid parameter (property:%d)",property_id);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
cal_rec->sync_data4 = SAFE_STRDUP(value);
break;
default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
+ ERR("invalid parameter (property:%d)",property_id);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
static int __cal_record_calendar_set_int( calendar_record_h record, unsigned int property_id, int value )
{
cal_calendar_s *cal_rec = (cal_calendar_s*)(record);
- switch( property_id )
- {
+ switch( property_id ) {
case CAL_PROPERTY_CALENDAR_ID:
(cal_rec->index) = value;
break;
case CAL_PROPERTY_CALENDAR_VISIBILITY:
(cal_rec->visibility) = value;
break;
- case CAL_PROPERTY_CALENDAR_IS_DELETED:
- (cal_rec->is_deleted) = value;
- break;
case CAL_PROPERTY_CALENDAR_ACCOUNT_ID:
+ retvm_if(cal_rec->index > 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter : property_id(%d) is a write-once value (calendar)", property_id);
(cal_rec->account_id) = value;
break;
case CAL_PROPERTY_CALENDAR_STORE_TYPE:
- (cal_rec->store_type) = value;
+ switch (value) {
+ case CALENDAR_BOOK_TYPE_NONE:
+ case CALENDAR_BOOK_TYPE_EVENT:
+ case CALENDAR_BOOK_TYPE_TODO:
+ (cal_rec->store_type) = value;
+ break;
+ default:
+ ERR("Invalid parameter : store type is invalid value (%d)", value);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ case CAL_PROPERTY_CALENDAR_SYNC_EVENT:
+ switch (value) {
+ case CALENDAR_BOOK_SYNC_EVENT_FOR_ME:
+ case CALENDAR_BOOK_SYNC_EVENT_FOR_EVERY_AND_REMAIN:
+ case CALENDAR_BOOK_SYNC_EVENT_FOR_EVERY_AND_DELETE:
+ (cal_rec->sync_event) = value;
+ break;
+ default:
+ ERR("Invalid parameter : sync event is invalid value (%d)", value);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ case CAL_PROPERTY_CALENDAR_MODE:
+ retvm_if (value != CALENDAR_BOOK_MODE_NONE && value != CALENDAR_BOOK_MODE_RECORD_READONLY,
+ CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter : mode type is invalid value (%d)", value);
+ (cal_rec->mode) = value;
break;
- case CAL_PROPERTY_CALENDAR_SYNC_EVENT:
- (cal_rec->sync_event) = value;
- break;
default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
+ ERR("invalid parameter (property:%d)",property_id);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
#include "cal_internal.h"
#include "cal_typedef.h"
#include "cal_view.h"
-
+#include "cal_list.h"
#include "cal_record.h"
static int __cal_record_event_create( calendar_record_h* out_record );
static int __cal_record_event_clone_child_record_list( calendar_record_h record, unsigned int property_id, calendar_list_h* out_list );
cal_record_plugin_cb_s _cal_record_event_plugin_cb = {
- .create = __cal_record_event_create,
- .destroy = __cal_record_event_destroy,
- .clone = __cal_record_event_clone,
- .get_str = __cal_record_event_get_str,
- .get_str_p = __cal_record_event_get_str_p,
- .get_int = __cal_record_event_get_int,
- .get_double = __cal_record_event_get_double,
- .get_lli = __cal_record_event_get_lli,
- .get_caltime = __cal_record_event_get_caltime,
- .set_str = __cal_record_event_set_str,
- .set_int = __cal_record_event_set_int,
- .set_double = __cal_record_event_set_double,
- .set_lli = __cal_record_event_set_lli,
- .set_caltime = __cal_record_event_set_caltime,
- .add_child_record = __cal_record_event_add_child_record,
- .remove_child_record = __cal_record_event_remove_child_record,
- .get_child_record_count = __cal_record_event_get_child_record_count,
- .get_child_record_at_p = __cal_record_event_get_child_record_at_p,
- .clone_child_record_list = __cal_record_event_clone_child_record_list
+ .create = __cal_record_event_create,
+ .destroy = __cal_record_event_destroy,
+ .clone = __cal_record_event_clone,
+ .get_str = __cal_record_event_get_str,
+ .get_str_p = __cal_record_event_get_str_p,
+ .get_int = __cal_record_event_get_int,
+ .get_double = __cal_record_event_get_double,
+ .get_lli = __cal_record_event_get_lli,
+ .get_caltime = __cal_record_event_get_caltime,
+ .set_str = __cal_record_event_set_str,
+ .set_int = __cal_record_event_set_int,
+ .set_double = __cal_record_event_set_double,
+ .set_lli = __cal_record_event_set_lli,
+ .set_caltime = __cal_record_event_set_caltime,
+ .add_child_record = __cal_record_event_add_child_record,
+ .remove_child_record = __cal_record_event_remove_child_record,
+ .get_child_record_count = __cal_record_event_get_child_record_count,
+ .get_child_record_at_p = __cal_record_event_get_child_record_at_p,
+ .clone_child_record_list = __cal_record_event_clone_child_record_list
};
static void __cal_record_event_struct_init(cal_event_s *record)
{
- memset(record,0,sizeof(cal_event_s));
-
- record->meeting_status = CALENDAR_MEETING_STATUS_NOTMEETING;
- record->calendar_id = DEFAULT_EVENT_CALENDAR_BOOK_ID;
-
- record->index = CAL_INVALID_ID;
- record->timezone = 0;
- record->contact_id = CAL_INVALID_ID;
- record->attendee_list = NULL;
- record->busy_status = 2;
- record->summary = NULL;
- record->description = NULL;
- record->location= NULL;
- record->categories = NULL;
- record->exdate = NULL;
- record->organizer_email = NULL;
- record->organizer_name = NULL;
- record->uid= NULL;
- record->original_event_id = CAL_INVALID_ID;
+ memset(record,0,sizeof(cal_event_s));
+
+ record->meeting_status = CALENDAR_MEETING_STATUS_NOTMEETING;
+ record->calendar_id = DEFAULT_EVENT_CALENDAR_BOOK_ID;
+
+ record->index = CAL_INVALID_ID;
+ record->timezone = 0;
+ record->contact_id = CAL_INVALID_ID;
+ record->busy_status = 2;
+ record->summary = NULL;
+ record->description = NULL;
+ record->location= NULL;
+ record->categories = NULL;
+ record->exdate = NULL;
+ record->organizer_email = NULL;
+ record->organizer_name = NULL;
+ record->uid= NULL;
+ record->original_event_id = CAL_INVALID_ID;
record->event_status = CALENDAR_EVENT_STATUS_NONE;
- record->is_deleted = 0;
- record->priority = CALENDAR_EVENT_PRIORITY_NONE;
- record->latitude = CALENDAR_RECORD_NO_COORDINATE; // set default 1000 out of range(-180 ~ 180)
- record->longitude = CALENDAR_RECORD_NO_COORDINATE; // set default 1000 out of range(-180 ~ 180)
- record->freq = CALENDAR_RECURRENCE_NONE;
- record->wkst = CALENDAR_SUNDAY;
- record->until_utime = CALENDAR_RECORD_NO_UNTIL;
+ record->is_deleted = 0;
+ record->priority = CALENDAR_EVENT_PRIORITY_NONE;
+ record->latitude = CALENDAR_RECORD_NO_COORDINATE; // set default 1000 out of range(-180 ~ 180)
+ record->longitude = CALENDAR_RECORD_NO_COORDINATE; // set default 1000 out of range(-180 ~ 180)
+ record->freq = CALENDAR_RECURRENCE_NONE;
+ record->until.time.utime = CALENDAR_RECORD_NO_UNTIL;
+
+ record->alarm_list = calloc(1, sizeof(cal_list_s));
+ record->attendee_list = calloc(1, sizeof(cal_list_s));
+ record->exception_list = calloc(1, sizeof(cal_list_s));
+ record->extended_list = calloc(1, sizeof(cal_list_s));
- return ;
+ return ;
}
static int __cal_record_event_create( calendar_record_h* out_record )
{
- cal_event_s *temp = NULL;
- int ret= CALENDAR_ERROR_NONE, type = 0;
+ cal_event_s *temp = NULL;
+ int ret= CALENDAR_ERROR_NONE;
- type = CAL_RECORD_TYPE_EVENT;
+ temp = (cal_event_s*)calloc(1, sizeof(cal_event_s));
+ retvm_if(NULL == temp, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_event_s:sch) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
- temp = (cal_event_s*)calloc(1, sizeof(cal_event_s));
- retvm_if(NULL == temp, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_event_s:sch) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
+ __cal_record_event_struct_init(temp);
- __cal_record_event_struct_init(temp);
+ *out_record = (calendar_record_h)temp;
- *out_record = (calendar_record_h)temp;
-
- return ret;
+ return ret;
}
static void __cal_record_event_struct_free(cal_event_s *record, bool delete_child)
{
- CAL_FREE(record->summary);
- CAL_FREE(record->description);
- CAL_FREE(record->location);
- CAL_FREE(record->categories);
- CAL_FREE(record->exdate);
- CAL_FREE(record->uid);
- CAL_FREE(record->organizer_name);
- CAL_FREE(record->organizer_email);
- CAL_FREE(record->start_tzid);
- CAL_FREE(record->end_tzid);
-
- CAL_FREE(record->bysecond);
- CAL_FREE(record->byminute);
- CAL_FREE(record->byhour);
- CAL_FREE(record->byday);
- CAL_FREE(record->bymonthday);
- CAL_FREE(record->byyearday);
- CAL_FREE(record->byweekno);
- CAL_FREE(record->bymonth);
- CAL_FREE(record->bysetpos);
-
- CAL_FREE(record->recurrence_id);
- CAL_FREE(record->rdate);
- CAL_FREE(record->sync_data1);
- CAL_FREE(record->sync_data2);
- CAL_FREE(record->sync_data3);
- CAL_FREE(record->sync_data4);
-
- if (delete_child == true)
- {
- if ( record->alarm_list )
- {
- GList *alarm_list = g_list_first(record->alarm_list);
- calendar_record_h alarm_child_record = NULL;
- while (alarm_list)
- {
- alarm_child_record = (calendar_record_h)alarm_list->data;
- if (alarm_child_record == NULL)
- {
- alarm_list = g_list_next(alarm_list);
- continue;
- }
-
- calendar_record_destroy(alarm_child_record, true);
-
- alarm_list = g_list_next(alarm_list);
- }
- g_list_free(record->alarm_list);
- record->alarm_list = NULL;
- }
-
- if( record->attendee_list )
- {
- GList * attendee_list = g_list_first(record->attendee_list);
- calendar_record_h attendee = NULL;
-
- while (attendee_list)
- {
- attendee = (calendar_record_h)attendee_list->data;
- if (attendee == NULL)
- {
- attendee_list = g_list_next(attendee_list);
- continue;
- }
-
- calendar_record_destroy(attendee, true);
-
- attendee_list = g_list_next(attendee_list);
- }
- g_list_free(record->attendee_list);
- record->attendee_list = NULL;
- }
- if( record->exception_list )
- {
- GList * exception_list = g_list_first(record->exception_list);
- calendar_record_h exception = NULL;
-
- while (exception_list)
- {
- exception = (calendar_record_h)exception_list->data;
- if (exception == NULL)
- {
- exception_list = g_list_next(exception_list);
- continue;
- }
-
- calendar_record_destroy(exception, true);
-
- exception_list = g_list_next(exception_list);
- }
- g_list_free(record->exception_list);
- record->exception_list = NULL;
- }
- if( record->extended_list )
- {
- GList * extended_list = g_list_first(record->extended_list);
- calendar_record_h extended = NULL;
-
- while (extended_list)
- {
- extended = (calendar_record_h)extended_list->data;
- if (extended == NULL)
- {
- extended_list = g_list_next(extended_list);
- continue;
- }
-
- calendar_record_destroy(extended, true);
-
- extended_list = g_list_next(extended_list);
- }
- g_list_free(record->extended_list);
- record->extended_list = NULL;
- }
- }
-
- CAL_FREE(record);
+ CAL_FREE(record->summary);
+ CAL_FREE(record->description);
+ CAL_FREE(record->location);
+ CAL_FREE(record->categories);
+ CAL_FREE(record->exdate);
+ CAL_FREE(record->uid);
+ CAL_FREE(record->organizer_name);
+ CAL_FREE(record->organizer_email);
+ CAL_FREE(record->start_tzid);
+ CAL_FREE(record->end_tzid);
+
+ CAL_FREE(record->bysecond);
+ CAL_FREE(record->byminute);
+ CAL_FREE(record->byhour);
+ CAL_FREE(record->byday);
+ CAL_FREE(record->bymonthday);
+ CAL_FREE(record->byyearday);
+ CAL_FREE(record->byweekno);
+ CAL_FREE(record->bymonth);
+ CAL_FREE(record->bysetpos);
+
+ CAL_FREE(record->recurrence_id);
+ CAL_FREE(record->rdate);
+ CAL_FREE(record->sync_data1);
+ CAL_FREE(record->sync_data2);
+ CAL_FREE(record->sync_data3);
+ CAL_FREE(record->sync_data4);
+
+ calendar_list_destroy((calendar_list_h)record->alarm_list, delete_child);
+ calendar_list_destroy((calendar_list_h)record->attendee_list, delete_child);
+ calendar_list_destroy((calendar_list_h)record->exception_list, delete_child);
+ calendar_list_destroy((calendar_list_h)record->extended_list, delete_child);
+
+ CAL_FREE(record);
}
static int __cal_record_event_destroy( calendar_record_h record, bool delete_child )
{
- int ret = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
- cal_event_s *temp = (cal_event_s*)(record);
+ cal_event_s *temp = (cal_event_s*)(record);
- __cal_record_event_struct_free(temp, delete_child);
+ __cal_record_event_struct_free(temp, delete_child);
- return ret;
+ return ret;
}
static int __cal_record_event_clone( calendar_record_h record, calendar_record_h* out_record )
{
- cal_event_s *out_data = NULL;
- cal_event_s *src_data = NULL;
-
- src_data = (cal_event_s*)(record);
-
- out_data = calloc(1, sizeof(cal_event_s));
- retvm_if(NULL == out_data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_event_s) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
-
- CAL_RECORD_COPY_COMMON(&(out_data->common), &(src_data->common));
-
- out_data->index = src_data->index;
- out_data->calendar_id = src_data->calendar_id;
-
- out_data->summary = SAFE_STRDUP(src_data->summary);
- out_data->description = SAFE_STRDUP(src_data->description);
- out_data->location = SAFE_STRDUP(src_data->location);
- out_data->categories = SAFE_STRDUP(src_data->categories);
- out_data->exdate = SAFE_STRDUP(src_data->exdate);
-
- out_data->event_status = src_data->event_status;
- out_data->priority = src_data->priority;
- out_data->timezone = src_data->timezone;
- out_data->contact_id = src_data->contact_id;
- out_data->busy_status = src_data->busy_status;
- out_data->sensitivity = src_data->sensitivity;
- out_data->meeting_status = src_data->meeting_status;
-
- out_data->uid = SAFE_STRDUP(src_data->uid);
- out_data->organizer_name = SAFE_STRDUP(src_data->organizer_name);
- out_data->organizer_email = SAFE_STRDUP(src_data->organizer_email);
-
- out_data->original_event_id = src_data->original_event_id;
- out_data->latitude = src_data->latitude;
- out_data->longitude = src_data->longitude;
- out_data->email_id = src_data->email_id;
- out_data->created_time = src_data->created_time;
- //out_data->completed_time = src_data->completed_time;
- //out_data->progress = src_data->progress;
- out_data->is_deleted = src_data->is_deleted;
- //out_data->duration = src_data->duration;
- out_data->last_mod = src_data->last_mod;
- //out_data->has_rrule = src_data->has_rrule;
- out_data->freq = src_data->freq;
- out_data->range_type = src_data->range_type;
- out_data->until_type = src_data->until_type;
- out_data->until_utime = src_data->until_utime;
- out_data->until_year = src_data->until_year;
- out_data->until_month = src_data->until_month;
- out_data->until_mday = src_data->until_mday;
- out_data->count = src_data->count;
- out_data->interval = src_data->interval;
- out_data->bysecond = SAFE_STRDUP(src_data->bysecond);
- out_data->byminute = SAFE_STRDUP(src_data->byminute);
- out_data->byhour = SAFE_STRDUP(src_data->byhour);
- out_data->byday = SAFE_STRDUP(src_data->byday);
- out_data->bymonthday = SAFE_STRDUP(src_data->bymonthday);
- out_data->byyearday = SAFE_STRDUP(src_data->byyearday);
- out_data->byweekno = SAFE_STRDUP(src_data->byweekno);
- out_data->bymonth = SAFE_STRDUP(src_data->bymonth);
- out_data->bysetpos = SAFE_STRDUP(src_data->bysetpos);
- out_data->wkst = src_data->wkst;
- out_data->recurrence_id = SAFE_STRDUP(src_data->recurrence_id);
- out_data->rdate = SAFE_STRDUP(src_data->rdate);
- out_data->has_attendee = src_data->has_attendee;
- out_data->has_alarm = src_data->has_alarm;
- out_data->system_type = src_data->system_type;
- out_data->updated = src_data->updated;
-
- out_data->sync_data1 = SAFE_STRDUP(src_data->sync_data1);
- out_data->sync_data2 = SAFE_STRDUP(src_data->sync_data2);
- out_data->sync_data3 = SAFE_STRDUP(src_data->sync_data3);
- out_data->sync_data4 = SAFE_STRDUP(src_data->sync_data4);
-
- out_data->start = src_data->start;
- out_data->start_tzid = SAFE_STRDUP(src_data->start_tzid);
- out_data->end = src_data->end;
- out_data->end_tzid = SAFE_STRDUP(src_data->end_tzid);
-
- if( src_data->alarm_list )
- {
- GList *alarm_list = g_list_first(src_data->alarm_list);
- calendar_record_h alarm_child_record;
-
- while (alarm_list)
- {
- calendar_record_h child_clone = NULL;
- alarm_child_record = (calendar_record_h)alarm_list->data;
- if (alarm_child_record == NULL)
- {
- alarm_list = g_list_next(alarm_list);
- continue;
- }
- if (calendar_record_clone(alarm_child_record, &child_clone) == CALENDAR_ERROR_NONE)
- {
-
- calendar_record_add_child_record((calendar_record_h)out_data,
- CAL_PROPERTY_EVENT_CALENDAR_ALARM,child_clone);
-
- }
- alarm_list = g_list_next(alarm_list);
- }
-
- }
-
- if( src_data->attendee_list )
- {
- GList * attendee_list = src_data->attendee_list;
- calendar_record_h attendee_child = NULL;
-
- while (attendee_list)
- {
- calendar_record_h child_clone = NULL;
- attendee_child = (calendar_record_h)attendee_list->data;
- if (attendee_child == NULL)
- {
- attendee_list = g_list_next(attendee_list);
- continue;
- }
- if (calendar_record_clone(attendee_child, &child_clone) == CALENDAR_ERROR_NONE)
- {
-
- calendar_record_add_child_record((calendar_record_h)out_data,
- CAL_PROPERTY_EVENT_CALENDAR_ATTENDEE,child_clone);
-
- }
- attendee_list = g_list_next(attendee_list);
- }
-
- }
-
- if( src_data->exception_list )
- {
- GList * exception_list = src_data->exception_list;
- calendar_record_h exception = NULL;
-
- while (exception_list)
- {
- calendar_record_h child_clone = NULL;
- exception = (calendar_record_h)exception_list->data;
- if (exception == NULL)
- {
- exception_list = g_list_next(exception_list);
- continue;
- }
- if (calendar_record_clone(exception, &child_clone) == CALENDAR_ERROR_NONE)
- {
-
- calendar_record_add_child_record((calendar_record_h)out_data,
- CAL_PROPERTY_EVENT_EXCEPTION,child_clone);
-
- }
- exception_list = g_list_next(exception_list);
- }
-
- }
-
- if( src_data->extended_list )
- {
- GList * extended_list = src_data->extended_list;
- calendar_record_h extended = NULL;
-
- while (extended_list)
- {
- calendar_record_h child_clone = NULL;
- extended = (calendar_record_h)extended_list->data;
- if (extended == NULL)
- {
- extended_list = g_list_next(extended_list);
- continue;
- }
- if (calendar_record_clone(extended, &child_clone) == CALENDAR_ERROR_NONE)
- {
-
- calendar_record_add_child_record((calendar_record_h)out_data,
- CAL_PROPERTY_EVENT_EXTENDED,child_clone);
-
- }
- extended_list = g_list_next(extended_list);
- }
-
- }
-
- *out_record = (calendar_record_h)out_data;
-
- return CALENDAR_ERROR_NONE;
+ cal_event_s *out_data = NULL;
+ cal_event_s *src_data = NULL;
+
+ src_data = (cal_event_s*)(record);
+
+ out_data = calloc(1, sizeof(cal_event_s));
+ retvm_if(NULL == out_data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_event_s) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
+
+ CAL_RECORD_COPY_COMMON(&(out_data->common), &(src_data->common));
+
+ out_data->index = src_data->index;
+ out_data->calendar_id = src_data->calendar_id;
+
+ out_data->summary = SAFE_STRDUP(src_data->summary);
+ out_data->description = SAFE_STRDUP(src_data->description);
+ out_data->location = SAFE_STRDUP(src_data->location);
+ out_data->categories = SAFE_STRDUP(src_data->categories);
+ out_data->exdate = SAFE_STRDUP(src_data->exdate);
+
+ out_data->event_status = src_data->event_status;
+ out_data->priority = src_data->priority;
+ out_data->timezone = src_data->timezone;
+ out_data->contact_id = src_data->contact_id;
+ out_data->busy_status = src_data->busy_status;
+ out_data->sensitivity = src_data->sensitivity;
+ out_data->meeting_status = src_data->meeting_status;
+
+ out_data->uid = SAFE_STRDUP(src_data->uid);
+ out_data->organizer_name = SAFE_STRDUP(src_data->organizer_name);
+ out_data->organizer_email = SAFE_STRDUP(src_data->organizer_email);
+
+ out_data->original_event_id = src_data->original_event_id;
+ out_data->latitude = src_data->latitude;
+ out_data->longitude = src_data->longitude;
+ out_data->email_id = src_data->email_id;
+ out_data->created_time = src_data->created_time;
+ out_data->is_deleted = src_data->is_deleted;
+ out_data->last_mod = src_data->last_mod;
+ out_data->freq = src_data->freq;
+ out_data->range_type = src_data->range_type;
+ out_data->until = src_data->until;
+
+ out_data->count = src_data->count;
+ out_data->interval = src_data->interval;
+ out_data->bysecond = SAFE_STRDUP(src_data->bysecond);
+ out_data->byminute = SAFE_STRDUP(src_data->byminute);
+ out_data->byhour = SAFE_STRDUP(src_data->byhour);
+ out_data->byday = SAFE_STRDUP(src_data->byday);
+ out_data->bymonthday = SAFE_STRDUP(src_data->bymonthday);
+ out_data->byyearday = SAFE_STRDUP(src_data->byyearday);
+ out_data->byweekno = SAFE_STRDUP(src_data->byweekno);
+ out_data->bymonth = SAFE_STRDUP(src_data->bymonth);
+ out_data->bysetpos = SAFE_STRDUP(src_data->bysetpos);
+ out_data->wkst = src_data->wkst;
+ out_data->recurrence_id = SAFE_STRDUP(src_data->recurrence_id);
+ out_data->rdate = SAFE_STRDUP(src_data->rdate);
+ out_data->has_attendee = src_data->has_attendee;
+ out_data->has_alarm = src_data->has_alarm;
+ out_data->system_type = src_data->system_type;
+ out_data->updated = src_data->updated;
+
+ out_data->sync_data1 = SAFE_STRDUP(src_data->sync_data1);
+ out_data->sync_data2 = SAFE_STRDUP(src_data->sync_data2);
+ out_data->sync_data3 = SAFE_STRDUP(src_data->sync_data3);
+ out_data->sync_data4 = SAFE_STRDUP(src_data->sync_data4);
+
+ out_data->start = src_data->start;
+ out_data->start_tzid = SAFE_STRDUP(src_data->start_tzid);
+ out_data->end = src_data->end;
+ out_data->end_tzid = SAFE_STRDUP(src_data->end_tzid);
+
+ _cal_list_clone((calendar_list_h)src_data->alarm_list, (calendar_list_h *)&out_data->alarm_list);
+ _cal_list_clone((calendar_list_h)src_data->attendee_list, (calendar_list_h *)&out_data->attendee_list);
+ _cal_list_clone((calendar_list_h)src_data->exception_list, (calendar_list_h *)&out_data->exception_list);
+ _cal_list_clone((calendar_list_h)src_data->extended_list, (calendar_list_h *)&out_data->extended_list);
+
+ *out_record = (calendar_record_h)out_data;
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_event_get_str( calendar_record_h record, unsigned int property_id, char** out_str )
{
- cal_event_s *rec = (cal_event_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_EVENT_SUMMARY:
- *out_str = SAFE_STRDUP(rec->summary);
- break;
- case CAL_PROPERTY_EVENT_DESCRIPTION:
- *out_str = SAFE_STRDUP(rec->description);
- break;
- case CAL_PROPERTY_EVENT_LOCATION:
- *out_str = SAFE_STRDUP(rec->location);
- break;
- case CAL_PROPERTY_EVENT_CATEGORIES:
- *out_str = SAFE_STRDUP(rec->categories);
- break;
- case CAL_PROPERTY_EVENT_EXDATE:
- *out_str = SAFE_STRDUP(rec->exdate);
- break;
- case CAL_PROPERTY_EVENT_UID:
- *out_str = SAFE_STRDUP(rec->uid);
- break;
- case CAL_PROPERTY_EVENT_ORGANIZER_NAME:
- *out_str = SAFE_STRDUP(rec->organizer_name);
- break;
- case CAL_PROPERTY_EVENT_ORGANIZER_EMAIL:
- *out_str = SAFE_STRDUP(rec->organizer_email);
- break;
- case CAL_PROPERTY_EVENT_BYSECOND:
- *out_str = SAFE_STRDUP(rec->bysecond);
- break;
- case CAL_PROPERTY_EVENT_BYMINUTE:
- *out_str = SAFE_STRDUP(rec->byminute);
- break;
- case CAL_PROPERTY_EVENT_BYHOUR:
- *out_str = SAFE_STRDUP(rec->byhour);
- break;
- case CAL_PROPERTY_EVENT_BYDAY:
- *out_str = SAFE_STRDUP(rec->byday);
- break;
- case CAL_PROPERTY_EVENT_BYMONTHDAY:
- *out_str = SAFE_STRDUP(rec->bymonthday);
- break;
- case CAL_PROPERTY_EVENT_BYYEARDAY:
- *out_str = SAFE_STRDUP(rec->byyearday);
- break;
- case CAL_PROPERTY_EVENT_BYWEEKNO:
- *out_str = SAFE_STRDUP(rec->byweekno);
- break;
- case CAL_PROPERTY_EVENT_BYMONTH:
- *out_str = SAFE_STRDUP(rec->bymonth);
- break;
- case CAL_PROPERTY_EVENT_BYSETPOS:
- *out_str = SAFE_STRDUP(rec->bysetpos);
- break;
- case CAL_PROPERTY_EVENT_RECURRENCE_ID:
- *out_str = SAFE_STRDUP(rec->recurrence_id);
- break;
- case CAL_PROPERTY_EVENT_RDATE:
- *out_str = SAFE_STRDUP(rec->rdate);
- break;
- case CAL_PROPERTY_EVENT_SYNC_DATA1:
- *out_str = SAFE_STRDUP(rec->sync_data1);
- break;
- case CAL_PROPERTY_EVENT_SYNC_DATA2:
- *out_str = SAFE_STRDUP(rec->sync_data2);
- break;
- case CAL_PROPERTY_EVENT_SYNC_DATA3:
- *out_str = SAFE_STRDUP(rec->sync_data3);
- break;
- case CAL_PROPERTY_EVENT_SYNC_DATA4:
- *out_str = SAFE_STRDUP(rec->sync_data4);
- break;
- case CAL_PROPERTY_EVENT_START_TZID:
- *out_str = SAFE_STRDUP(rec->start_tzid);
- break;
- case CAL_PROPERTY_EVENT_END_TZID:
- *out_str = SAFE_STRDUP(rec->end_tzid);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_event_s *rec = (cal_event_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_EVENT_SUMMARY:
+ *out_str = SAFE_STRDUP(rec->summary);
+ break;
+ case CAL_PROPERTY_EVENT_DESCRIPTION:
+ *out_str = SAFE_STRDUP(rec->description);
+ break;
+ case CAL_PROPERTY_EVENT_LOCATION:
+ *out_str = SAFE_STRDUP(rec->location);
+ break;
+ case CAL_PROPERTY_EVENT_CATEGORIES:
+ *out_str = SAFE_STRDUP(rec->categories);
+ break;
+ case CAL_PROPERTY_EVENT_EXDATE:
+ *out_str = SAFE_STRDUP(rec->exdate);
+ break;
+ case CAL_PROPERTY_EVENT_UID:
+ *out_str = SAFE_STRDUP(rec->uid);
+ break;
+ case CAL_PROPERTY_EVENT_ORGANIZER_NAME:
+ *out_str = SAFE_STRDUP(rec->organizer_name);
+ break;
+ case CAL_PROPERTY_EVENT_ORGANIZER_EMAIL:
+ *out_str = SAFE_STRDUP(rec->organizer_email);
+ break;
+ case CAL_PROPERTY_EVENT_BYSECOND:
+ *out_str = SAFE_STRDUP(rec->bysecond);
+ break;
+ case CAL_PROPERTY_EVENT_BYMINUTE:
+ *out_str = SAFE_STRDUP(rec->byminute);
+ break;
+ case CAL_PROPERTY_EVENT_BYHOUR:
+ *out_str = SAFE_STRDUP(rec->byhour);
+ break;
+ case CAL_PROPERTY_EVENT_BYDAY:
+ *out_str = SAFE_STRDUP(rec->byday);
+ break;
+ case CAL_PROPERTY_EVENT_BYMONTHDAY:
+ *out_str = SAFE_STRDUP(rec->bymonthday);
+ break;
+ case CAL_PROPERTY_EVENT_BYYEARDAY:
+ *out_str = SAFE_STRDUP(rec->byyearday);
+ break;
+ case CAL_PROPERTY_EVENT_BYWEEKNO:
+ *out_str = SAFE_STRDUP(rec->byweekno);
+ break;
+ case CAL_PROPERTY_EVENT_BYMONTH:
+ *out_str = SAFE_STRDUP(rec->bymonth);
+ break;
+ case CAL_PROPERTY_EVENT_BYSETPOS:
+ *out_str = SAFE_STRDUP(rec->bysetpos);
+ break;
+ case CAL_PROPERTY_EVENT_RECURRENCE_ID:
+ *out_str = SAFE_STRDUP(rec->recurrence_id);
+ break;
+ case CAL_PROPERTY_EVENT_RDATE:
+ *out_str = SAFE_STRDUP(rec->rdate);
+ break;
+ case CAL_PROPERTY_EVENT_SYNC_DATA1:
+ *out_str = SAFE_STRDUP(rec->sync_data1);
+ break;
+ case CAL_PROPERTY_EVENT_SYNC_DATA2:
+ *out_str = SAFE_STRDUP(rec->sync_data2);
+ break;
+ case CAL_PROPERTY_EVENT_SYNC_DATA3:
+ *out_str = SAFE_STRDUP(rec->sync_data3);
+ break;
+ case CAL_PROPERTY_EVENT_SYNC_DATA4:
+ *out_str = SAFE_STRDUP(rec->sync_data4);
+ break;
+ case CAL_PROPERTY_EVENT_START_TZID:
+ *out_str = SAFE_STRDUP(rec->start_tzid);
+ break;
+ case CAL_PROPERTY_EVENT_END_TZID:
+ *out_str = SAFE_STRDUP(rec->end_tzid);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_event_get_str_p( calendar_record_h record, unsigned int property_id, char** out_str )
{
- cal_event_s *rec = (cal_event_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_EVENT_SUMMARY:
- *out_str = (rec->summary);
- break;
- case CAL_PROPERTY_EVENT_DESCRIPTION:
- *out_str = (rec->description);
- break;
- case CAL_PROPERTY_EVENT_LOCATION:
- *out_str = (rec->location);
- break;
- case CAL_PROPERTY_EVENT_CATEGORIES:
- *out_str = (rec->categories);
- break;
- case CAL_PROPERTY_EVENT_EXDATE:
- *out_str = (rec->exdate);
- break;
- case CAL_PROPERTY_EVENT_UID:
- *out_str = (rec->uid);
- break;
- case CAL_PROPERTY_EVENT_ORGANIZER_NAME:
- *out_str = (rec->organizer_name);
- break;
- case CAL_PROPERTY_EVENT_ORGANIZER_EMAIL:
- *out_str = (rec->organizer_email);
- break;
- case CAL_PROPERTY_EVENT_BYSECOND:
- *out_str = (rec->bysecond);
- break;
- case CAL_PROPERTY_EVENT_BYMINUTE:
- *out_str = (rec->byminute);
- break;
- case CAL_PROPERTY_EVENT_BYHOUR:
- *out_str = (rec->byhour);
- break;
- case CAL_PROPERTY_EVENT_BYDAY:
- *out_str = (rec->byday);
- break;
- case CAL_PROPERTY_EVENT_BYMONTHDAY:
- *out_str = (rec->bymonthday);
- break;
- case CAL_PROPERTY_EVENT_BYYEARDAY:
- *out_str = (rec->byyearday);
- break;
- case CAL_PROPERTY_EVENT_BYWEEKNO:
- *out_str = (rec->byweekno);
- break;
- case CAL_PROPERTY_EVENT_BYMONTH:
- *out_str = (rec->bymonth);
- break;
- case CAL_PROPERTY_EVENT_BYSETPOS:
- *out_str = (rec->bysetpos);
- break;
- case CAL_PROPERTY_EVENT_RECURRENCE_ID:
- *out_str = (rec->recurrence_id);
- break;
- case CAL_PROPERTY_EVENT_RDATE:
- *out_str = (rec->rdate);
- break;
- case CAL_PROPERTY_EVENT_SYNC_DATA1:
- *out_str = (rec->sync_data1);
- break;
- case CAL_PROPERTY_EVENT_SYNC_DATA2:
- *out_str = (rec->sync_data2);
- break;
- case CAL_PROPERTY_EVENT_SYNC_DATA3:
- *out_str = (rec->sync_data3);
- break;
- case CAL_PROPERTY_EVENT_SYNC_DATA4:
- *out_str = (rec->sync_data4);
- break;
- case CAL_PROPERTY_EVENT_START_TZID:
- *out_str = (rec->start_tzid);
- break;
- case CAL_PROPERTY_EVENT_END_TZID:
- *out_str = (rec->end_tzid);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_event_s *rec = (cal_event_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_EVENT_SUMMARY:
+ *out_str = (rec->summary);
+ break;
+ case CAL_PROPERTY_EVENT_DESCRIPTION:
+ *out_str = (rec->description);
+ break;
+ case CAL_PROPERTY_EVENT_LOCATION:
+ *out_str = (rec->location);
+ break;
+ case CAL_PROPERTY_EVENT_CATEGORIES:
+ *out_str = (rec->categories);
+ break;
+ case CAL_PROPERTY_EVENT_EXDATE:
+ *out_str = (rec->exdate);
+ break;
+ case CAL_PROPERTY_EVENT_UID:
+ *out_str = (rec->uid);
+ break;
+ case CAL_PROPERTY_EVENT_ORGANIZER_NAME:
+ *out_str = (rec->organizer_name);
+ break;
+ case CAL_PROPERTY_EVENT_ORGANIZER_EMAIL:
+ *out_str = (rec->organizer_email);
+ break;
+ case CAL_PROPERTY_EVENT_BYSECOND:
+ *out_str = (rec->bysecond);
+ break;
+ case CAL_PROPERTY_EVENT_BYMINUTE:
+ *out_str = (rec->byminute);
+ break;
+ case CAL_PROPERTY_EVENT_BYHOUR:
+ *out_str = (rec->byhour);
+ break;
+ case CAL_PROPERTY_EVENT_BYDAY:
+ *out_str = (rec->byday);
+ break;
+ case CAL_PROPERTY_EVENT_BYMONTHDAY:
+ *out_str = (rec->bymonthday);
+ break;
+ case CAL_PROPERTY_EVENT_BYYEARDAY:
+ *out_str = (rec->byyearday);
+ break;
+ case CAL_PROPERTY_EVENT_BYWEEKNO:
+ *out_str = (rec->byweekno);
+ break;
+ case CAL_PROPERTY_EVENT_BYMONTH:
+ *out_str = (rec->bymonth);
+ break;
+ case CAL_PROPERTY_EVENT_BYSETPOS:
+ *out_str = (rec->bysetpos);
+ break;
+ case CAL_PROPERTY_EVENT_RECURRENCE_ID:
+ *out_str = (rec->recurrence_id);
+ break;
+ case CAL_PROPERTY_EVENT_RDATE:
+ *out_str = (rec->rdate);
+ break;
+ case CAL_PROPERTY_EVENT_SYNC_DATA1:
+ *out_str = (rec->sync_data1);
+ break;
+ case CAL_PROPERTY_EVENT_SYNC_DATA2:
+ *out_str = (rec->sync_data2);
+ break;
+ case CAL_PROPERTY_EVENT_SYNC_DATA3:
+ *out_str = (rec->sync_data3);
+ break;
+ case CAL_PROPERTY_EVENT_SYNC_DATA4:
+ *out_str = (rec->sync_data4);
+ break;
+ case CAL_PROPERTY_EVENT_START_TZID:
+ *out_str = (rec->start_tzid);
+ break;
+ case CAL_PROPERTY_EVENT_END_TZID:
+ *out_str = (rec->end_tzid);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_event_get_int( calendar_record_h record, unsigned int property_id, int* out_value )
{
- cal_event_s *rec = (cal_event_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_EVENT_ID:
- *out_value = (rec->index);
- break;
- case CAL_PROPERTY_EVENT_CALENDAR_ID:
- *out_value = (rec->calendar_id);
- break;
- case CAL_PROPERTY_EVENT_EVENT_STATUS:
- *out_value = (rec->event_status);
- break;
- //priority
- case CAL_PROPERTY_EVENT_PRIORITY:
- *out_value = (rec->priority);
- break;
- //timezone
- case CAL_PROPERTY_EVENT_TIMEZONE:
- *out_value = (rec->timezone);
- break;
- //contact_id
- case CAL_PROPERTY_EVENT_CONTACT_ID:
- *out_value = (rec->contact_id);
- break;
- //busy_status
- case CAL_PROPERTY_EVENT_BUSY_STATUS:
- *out_value = (rec->busy_status);
- break;
- //sensitivity
- case CAL_PROPERTY_EVENT_SENSITIVITY:
- *out_value = (rec->sensitivity);
- break;
- //meeting_status
- case CAL_PROPERTY_EVENT_MEETING_STATUS:
- *out_value = (rec->meeting_status);
- break;
- //original_event_id
- case CAL_PROPERTY_EVENT_ORIGINAL_EVENT_ID:
- *out_value = (rec->original_event_id);
- break;
- //email_id
- case CAL_PROPERTY_EVENT_EMAIL_ID:
- *out_value = (rec->email_id);
- break;
- //is_deleted
- case CAL_PROPERTY_EVENT_IS_DELETED:
- *out_value = (rec->is_deleted);
- break;
- //freq
- case CAL_PROPERTY_EVENT_FREQ:
- *out_value = (rec->freq);
- break;
- //range_type
- case CAL_PROPERTY_EVENT_RANGE_TYPE:
- *out_value = (rec->range_type);
- break;
- //count
- case CAL_PROPERTY_EVENT_COUNT:
- *out_value = (rec->count);
- break;
- //interval
- case CAL_PROPERTY_EVENT_INTERVAL:
- *out_value = (rec->interval);
- break;
- //wkst
- case CAL_PROPERTY_EVENT_WKST:
- *out_value = (rec->wkst);
- break;
- //has_attendee
- case CAL_PROPERTY_EVENT_HAS_ATTENDEE:
- *out_value = (rec->has_attendee);
- break;
- //has_alarm
- case CAL_PROPERTY_EVENT_HAS_ALARM:
- *out_value = (rec->has_alarm);
- break;
- case CAL_PROPERTY_EVENT_CALENDAR_SYSTEM_TYPE:
- *out_value = (rec->system_type);
- break;
- case CAL_PROPERTY_EVENT_IS_ALLDAY:
- *out_value = (rec->start.type);
- break;
- default:
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_event_s *rec = (cal_event_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_EVENT_ID:
+ *out_value = (rec->index);
+ break;
+ case CAL_PROPERTY_EVENT_CALENDAR_ID:
+ *out_value = (rec->calendar_id);
+ break;
+ case CAL_PROPERTY_EVENT_EVENT_STATUS:
+ *out_value = (rec->event_status);
+ break;
+ case CAL_PROPERTY_EVENT_PRIORITY:
+ *out_value = (rec->priority);
+ break;
+ case CAL_PROPERTY_EVENT_TIMEZONE:
+ *out_value = (rec->timezone);
+ break;
+ case CAL_PROPERTY_EVENT_CONTACT_ID:
+ *out_value = (rec->contact_id);
+ break;
+ case CAL_PROPERTY_EVENT_BUSY_STATUS:
+ *out_value = (rec->busy_status);
+ break;
+ case CAL_PROPERTY_EVENT_SENSITIVITY:
+ *out_value = (rec->sensitivity);
+ break;
+ case CAL_PROPERTY_EVENT_MEETING_STATUS:
+ *out_value = (rec->meeting_status);
+ break;
+ case CAL_PROPERTY_EVENT_ORIGINAL_EVENT_ID:
+ *out_value = (rec->original_event_id);
+ break;
+ case CAL_PROPERTY_EVENT_EMAIL_ID:
+ *out_value = (rec->email_id);
+ break;
+ case CAL_PROPERTY_EVENT_IS_DELETED:
+ *out_value = (rec->is_deleted);
+ break;
+ case CAL_PROPERTY_EVENT_FREQ:
+ *out_value = (rec->freq);
+ break;
+ case CAL_PROPERTY_EVENT_RANGE_TYPE:
+ *out_value = (rec->range_type);
+ break;
+ case CAL_PROPERTY_EVENT_COUNT:
+ *out_value = (rec->count);
+ break;
+ case CAL_PROPERTY_EVENT_INTERVAL:
+ *out_value = (rec->interval);
+ break;
+ case CAL_PROPERTY_EVENT_WKST:
+ *out_value = (rec->wkst);
+ break;
+ case CAL_PROPERTY_EVENT_HAS_ATTENDEE:
+ *out_value = (rec->has_attendee);
+ break;
+ case CAL_PROPERTY_EVENT_HAS_ALARM:
+ *out_value = (rec->has_alarm);
+ break;
+ case CAL_PROPERTY_EVENT_CALENDAR_SYSTEM_TYPE:
+ *out_value = (rec->system_type);
+ break;
+ case CAL_PROPERTY_EVENT_IS_ALLDAY:
+ *out_value = (rec->is_allday);
+ break;
+ default:
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_event_get_double( calendar_record_h record, unsigned int property_id, double* out_value )
{
- cal_event_s *rec = (cal_event_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_EVENT_LATITUDE:
- *out_value = (rec->latitude);
- break;
- case CAL_PROPERTY_EVENT_LONGITUDE:
- *out_value = (rec->longitude);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_event_s *rec = (cal_event_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_EVENT_LATITUDE:
+ *out_value = (rec->latitude);
+ break;
+ case CAL_PROPERTY_EVENT_LONGITUDE:
+ *out_value = (rec->longitude);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_event_get_lli( calendar_record_h record, unsigned int property_id, long long int* out_value )
{
- cal_event_s *rec = (cal_event_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_EVENT_CREATED_TIME:
- *out_value = (rec->created_time);
- break;
- case CAL_PROPERTY_EVENT_LAST_MODIFIED_TIME:
- *out_value = (rec->last_mod);
- break;
- default:
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_event_s *rec = (cal_event_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_EVENT_CREATED_TIME:
+ *out_value = (rec->created_time);
+ break;
+ case CAL_PROPERTY_EVENT_LAST_MODIFIED_TIME:
+ *out_value = (rec->last_mod);
+ break;
+ default:
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_event_get_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s* out_value )
{
- cal_event_s *rec = (cal_event_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_EVENT_START:
- *out_value = rec->start;
- break;
- case CAL_PROPERTY_EVENT_END:
- *out_value = rec->end;
- break;
- case CAL_PROPERTY_EVENT_UNTIL:
- if (rec->until_type == CALENDAR_TIME_UTIME)
- {
- CAL_CALTIME_SET_UTIME(*out_value, rec->until_utime);
- }
- else
- {
- CAL_CALTIME_SET_DATE(*out_value, rec->until_year,rec->until_month,rec->until_mday);
- }
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_event_s *rec = (cal_event_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_EVENT_START:
+ *out_value = rec->start;
+ break;
+ case CAL_PROPERTY_EVENT_END:
+ *out_value = rec->end;
+ break;
+ case CAL_PROPERTY_EVENT_UNTIL:
+ *out_value = rec->until;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_event_set_str( calendar_record_h record, unsigned int property_id, const char* value )
{
- cal_event_s *rec = (cal_event_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_EVENT_SUMMARY:
- CAL_FREE(rec->summary);
- rec->summary = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_EVENT_DESCRIPTION:
- CAL_FREE(rec->description);
- rec->description = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_EVENT_LOCATION:
- CAL_FREE(rec->location);
- rec->location = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_EVENT_CATEGORIES:
- CAL_FREE(rec->categories);
- rec->categories = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_EVENT_EXDATE:
- CAL_FREE(rec->exdate);
- rec->exdate = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_EVENT_UID:
- CAL_FREE(rec->uid);
- rec->uid = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_EVENT_ORGANIZER_NAME:
- CAL_FREE(rec->organizer_name);
- rec->organizer_name = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_EVENT_ORGANIZER_EMAIL:
- CAL_FREE(rec->organizer_email);
- rec->organizer_email = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_EVENT_BYSECOND:
- CAL_FREE(rec->bysecond);
- rec->bysecond = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_EVENT_BYMINUTE:
- CAL_FREE(rec->byminute);
- rec->byminute = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_EVENT_BYHOUR:
- CAL_FREE(rec->byhour);
- rec->byhour = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_EVENT_BYDAY:
- CAL_FREE(rec->byday);
- rec->byday = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_EVENT_BYMONTHDAY:
- CAL_FREE(rec->bymonthday);
- rec->bymonthday = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_EVENT_BYYEARDAY:
- CAL_FREE(rec->byyearday);
- rec->byyearday = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_EVENT_BYWEEKNO:
- CAL_FREE(rec->byweekno);
- rec->byweekno = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_EVENT_BYMONTH:
- CAL_FREE(rec->bymonth);
- rec->bymonth = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_EVENT_BYSETPOS:
- CAL_FREE(rec->bysetpos);
- rec->bysetpos = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_EVENT_RECURRENCE_ID:
- CAL_FREE(rec->recurrence_id);
- rec->recurrence_id = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_EVENT_RDATE:
- CAL_FREE(rec->rdate);
- rec->rdate = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_EVENT_SYNC_DATA1:
- CAL_FREE(rec->sync_data1);
- rec->sync_data1 = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_EVENT_SYNC_DATA2:
- CAL_FREE(rec->sync_data2);
- rec->sync_data2 = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_EVENT_SYNC_DATA3:
- CAL_FREE(rec->sync_data3);
- rec->sync_data3 = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_EVENT_SYNC_DATA4:
- CAL_FREE(rec->sync_data4);
- rec->sync_data4 = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_EVENT_START_TZID:
- CAL_FREE(rec->start_tzid);
- rec->start_tzid = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_EVENT_END_TZID:
- CAL_FREE(rec->end_tzid);
- rec->end_tzid = SAFE_STRDUP(value);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_event_s *rec = (cal_event_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_EVENT_SUMMARY:
+ CAL_FREE(rec->summary);
+ rec->summary = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_EVENT_DESCRIPTION:
+ CAL_FREE(rec->description);
+ rec->description = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_EVENT_LOCATION:
+ CAL_FREE(rec->location);
+ rec->location = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_EVENT_CATEGORIES:
+ CAL_FREE(rec->categories);
+ rec->categories = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_EVENT_EXDATE:
+ CAL_FREE(rec->exdate);
+ rec->exdate = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_EVENT_UID:
+ CAL_FREE(rec->uid);
+ rec->uid = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_EVENT_ORGANIZER_NAME:
+ CAL_FREE(rec->organizer_name);
+ rec->organizer_name = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_EVENT_ORGANIZER_EMAIL:
+ CAL_FREE(rec->organizer_email);
+ rec->organizer_email = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_EVENT_BYSECOND:
+ CAL_FREE(rec->bysecond);
+ rec->bysecond = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_EVENT_BYMINUTE:
+ CAL_FREE(rec->byminute);
+ rec->byminute = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_EVENT_BYHOUR:
+ CAL_FREE(rec->byhour);
+ rec->byhour = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_EVENT_BYDAY:
+ CAL_FREE(rec->byday);
+ rec->byday = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_EVENT_BYMONTHDAY:
+ CAL_FREE(rec->bymonthday);
+ rec->bymonthday = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_EVENT_BYYEARDAY:
+ CAL_FREE(rec->byyearday);
+ rec->byyearday = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_EVENT_BYWEEKNO:
+ CAL_FREE(rec->byweekno);
+ rec->byweekno = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_EVENT_BYMONTH:
+ CAL_FREE(rec->bymonth);
+ rec->bymonth = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_EVENT_BYSETPOS:
+ CAL_FREE(rec->bysetpos);
+ rec->bysetpos = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_EVENT_RECURRENCE_ID:
+ CAL_FREE(rec->recurrence_id);
+ rec->recurrence_id = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_EVENT_RDATE:
+ CAL_FREE(rec->rdate);
+ rec->rdate = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_EVENT_SYNC_DATA1:
+ CAL_FREE(rec->sync_data1);
+ rec->sync_data1 = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_EVENT_SYNC_DATA2:
+ CAL_FREE(rec->sync_data2);
+ rec->sync_data2 = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_EVENT_SYNC_DATA3:
+ CAL_FREE(rec->sync_data3);
+ rec->sync_data3 = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_EVENT_SYNC_DATA4:
+ CAL_FREE(rec->sync_data4);
+ rec->sync_data4 = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_EVENT_START_TZID:
+ CAL_FREE(rec->start_tzid);
+ rec->start_tzid = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_EVENT_END_TZID:
+ CAL_FREE(rec->end_tzid);
+ rec->end_tzid = SAFE_STRDUP(value);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_event_set_int( calendar_record_h record, unsigned int property_id, int value )
{
- cal_event_s *rec = (cal_event_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_EVENT_ID:
- (rec->index) = value;
- break;
- case CAL_PROPERTY_EVENT_CALENDAR_ID:
- (rec->calendar_id) = value;
- break;
- case CAL_PROPERTY_EVENT_EVENT_STATUS:
- switch (value)
- {
+ cal_event_s *rec = (cal_event_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_EVENT_ID:
+ (rec->index) = value;
+ break;
+ case CAL_PROPERTY_EVENT_CALENDAR_ID:
+ (rec->calendar_id) = value;
+ break;
+ case CAL_PROPERTY_EVENT_EVENT_STATUS:
+ switch (value) {
case CALENDAR_EVENT_STATUS_NONE:
case CALENDAR_EVENT_STATUS_TENTATIVE:
case CALENDAR_EVENT_STATUS_CONFIRMED:
return CALENDAR_ERROR_INVALID_PARAMETER;
}
break;
- //priority
- case CAL_PROPERTY_EVENT_PRIORITY:
- (rec->priority) = value;
- break;
- //timezone
- case CAL_PROPERTY_EVENT_TIMEZONE:
- (rec->timezone) = value;
- break;
- //contact_id
- case CAL_PROPERTY_EVENT_CONTACT_ID:
- (rec->contact_id) = value;
- break;
- //busy_status
- case CAL_PROPERTY_EVENT_BUSY_STATUS:
- switch (value)
- {
+ case CAL_PROPERTY_EVENT_PRIORITY:
+ switch (value) {
+ case CALENDAR_EVENT_PRIORITY_NONE:
+ case CALENDAR_EVENT_PRIORITY_LOW:
+ case CALENDAR_EVENT_PRIORITY_NORMAL:
+ case CALENDAR_EVENT_PRIORITY_HIGH:
+ (rec->priority) = value;
+ break;
+ default:
+ ERR("invalid parameter (value:%d)", value);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ case CAL_PROPERTY_EVENT_TIMEZONE:
+ (rec->timezone) = value;
+ break;
+ case CAL_PROPERTY_EVENT_CONTACT_ID:
+ (rec->contact_id) = value;
+ break;
+ case CAL_PROPERTY_EVENT_BUSY_STATUS:
+ switch (value) {
case CALENDAR_EVENT_BUSY_STATUS_FREE:
case CALENDAR_EVENT_BUSY_STATUS_BUSY:
case CALENDAR_EVENT_BUSY_STATUS_UNAVAILABLE:
case CALENDAR_EVENT_BUSY_STATUS_TENTATIVE:
- (rec->busy_status) = value;
+ (rec->busy_status) = value;
break;
default:
ERR("invalid parameter (value:%d)", value);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- break;
- //sensitivity
- case CAL_PROPERTY_EVENT_SENSITIVITY:
- switch (value)
- {
+ break;
+ case CAL_PROPERTY_EVENT_SENSITIVITY:
+ switch (value) {
case CALENDAR_SENSITIVITY_PUBLIC:
case CALENDAR_SENSITIVITY_PRIVATE:
case CALENDAR_SENSITIVITY_CONFIDENTIAL:
- (rec->sensitivity) = value;
+ (rec->sensitivity) = value;
break;
default:
ERR("invalid parameter (value:%d)", value);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- break;
- //meeting_status
- case CAL_PROPERTY_EVENT_MEETING_STATUS:
- switch (value)
- {
+ break;
+ case CAL_PROPERTY_EVENT_MEETING_STATUS:
+ switch (value) {
case CALENDAR_MEETING_STATUS_NOTMEETING:
case CALENDAR_MEETING_STATUS_MEETING:
case CALENDAR_MEETING_STATUS_RECEIVED:
case CALENDAR_MEETING_STATUS_CANCELED:
- (rec->meeting_status) = value;
+ (rec->meeting_status) = value;
break;
default:
ERR("invalid parameter (value:%d)", value);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- break;
- //original_event_id
- case CAL_PROPERTY_EVENT_ORIGINAL_EVENT_ID:
- (rec->original_event_id) = value;
- break;
- //email_id
- case CAL_PROPERTY_EVENT_EMAIL_ID:
- (rec->email_id) = value;
- break;
- //is_deleted
- case CAL_PROPERTY_EVENT_IS_DELETED:
- (rec->is_deleted) = value;
- break;
- //freq
- case CAL_PROPERTY_EVENT_FREQ:
- switch (value)
- {
+ break;
+ case CAL_PROPERTY_EVENT_ORIGINAL_EVENT_ID:
+ (rec->original_event_id) = value;
+ break;
+ case CAL_PROPERTY_EVENT_EMAIL_ID:
+ (rec->email_id) = value;
+ break;
+ case CAL_PROPERTY_EVENT_IS_DELETED:
+ (rec->is_deleted) = value;
+ break;
+ case CAL_PROPERTY_EVENT_FREQ:
+ switch (value) {
case CALENDAR_RECURRENCE_NONE:
case CALENDAR_RECURRENCE_DAILY:
case CALENDAR_RECURRENCE_WEEKLY:
case CALENDAR_RECURRENCE_MONTHLY:
case CALENDAR_RECURRENCE_YEARLY:
- (rec->freq) = value;
+ (rec->freq) = value;
break;
default:
ERR("invalid parameter (value:%d)", value);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- break;
- //range_type
- case CAL_PROPERTY_EVENT_RANGE_TYPE:
- switch (value)
- {
+ break;
+ case CAL_PROPERTY_EVENT_RANGE_TYPE:
+ switch (value) {
case CALENDAR_RANGE_UNTIL:
case CALENDAR_RANGE_COUNT:
case CALENDAR_RANGE_NONE:
- (rec->range_type) = value;
+ (rec->range_type) = value;
break;
default:
ERR("invalid parameter (value:%d)", value);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- break;
- //count
- case CAL_PROPERTY_EVENT_COUNT:
- (rec->count) = value;
- break;
- //interval
- case CAL_PROPERTY_EVENT_INTERVAL:
- (rec->interval) = value;
- break;
- //wkst
- case CAL_PROPERTY_EVENT_WKST:
- switch (value)
- {
+ break;
+ case CAL_PROPERTY_EVENT_COUNT:
+ (rec->count) = value;
+ break;
+ case CAL_PROPERTY_EVENT_INTERVAL:
+ (rec->interval) = value;
+ break;
+ case CAL_PROPERTY_EVENT_WKST:
+ switch (value) {
case CALENDAR_SUNDAY:
case CALENDAR_MONDAY:
case CALENDAR_TUESDAY:
case CALENDAR_THURSDAY:
case CALENDAR_FRIDAY:
case CALENDAR_SATURDAY:
- (rec->wkst) = value;
+ (rec->wkst) = value;
break;
default:
ERR("invalid parameter (value:%d)", value);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- break;
- //has_attendee
- case CAL_PROPERTY_EVENT_HAS_ATTENDEE:
- (rec->has_attendee) = value;
- break;
- //has_alarm
- case CAL_PROPERTY_EVENT_HAS_ALARM:
- (rec->has_alarm) = value;
- break;
- case CAL_PROPERTY_EVENT_CALENDAR_SYSTEM_TYPE:
- switch (value)
- {
+ break;
+ case CAL_PROPERTY_EVENT_HAS_ATTENDEE:
+ (rec->has_attendee) = value;
+ break;
+ case CAL_PROPERTY_EVENT_HAS_ALARM:
+ (rec->has_alarm) = value;
+ break;
+ case CAL_PROPERTY_EVENT_CALENDAR_SYSTEM_TYPE:
+ switch (value) {
case CALENDAR_SYSTEM_NONE:
case CALENDAR_SYSTEM_GREGORIAN:
case CALENDAR_SYSTEM_EAST_ASIAN_LUNISOLAR:
- (rec->system_type) = value;
+ (rec->system_type) = value;
break;
default:
ERR("invalid parameter (value:%d)", value);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- break;
- case CAL_PROPERTY_EVENT_IS_ALLDAY:
- (rec->start.type) = value;
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ break;
+ case CAL_PROPERTY_EVENT_IS_ALLDAY:
+ (rec->is_allday) = value;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_event_set_double( calendar_record_h record, unsigned int property_id, double value )
{
- cal_event_s *rec = (cal_event_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_EVENT_LATITUDE:
- (rec->latitude) = value;
- break;
- case CAL_PROPERTY_EVENT_LONGITUDE:
- (rec->longitude) = value;
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_event_s *rec = (cal_event_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_EVENT_LATITUDE:
+ (rec->latitude) = value;
+ break;
+ case CAL_PROPERTY_EVENT_LONGITUDE:
+ (rec->longitude) = value;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_event_set_lli( calendar_record_h record, unsigned int property_id, long long int value )
{
- cal_event_s *rec = (cal_event_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_EVENT_CREATED_TIME:
- (rec->created_time) = value;
- break;
- case CAL_PROPERTY_EVENT_LAST_MODIFIED_TIME:
- (rec->last_mod) = value;
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_event_s *rec = (cal_event_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_EVENT_CREATED_TIME:
+ (rec->created_time) = value;
+ break;
+ case CAL_PROPERTY_EVENT_LAST_MODIFIED_TIME:
+ (rec->last_mod) = value;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_event_set_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s value )
{
- cal_event_s *rec = (cal_event_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_EVENT_START:
- rec->start = value;
- break;
- case CAL_PROPERTY_EVENT_END:
- rec->end = value;
- break;
- case CAL_PROPERTY_EVENT_UNTIL:
- (rec->until_type) = value.type;
- if(value.type == CALENDAR_TIME_UTIME)
- {
- (rec->until_utime) = value.time.utime;
- (rec->until_year) = 0;
- (rec->until_month) = 0;
- (rec->until_mday) = 0;
- }
- else
- {
- (rec->until_utime) = 0;
- (rec->until_year) = value.time.date.year;
- (rec->until_month) = value.time.date.month;
- (rec->until_mday) = value.time.date.mday ;
- }
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_event_s *rec = (cal_event_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_EVENT_START:
+ rec->start = value;
+ break;
+
+ case CAL_PROPERTY_EVENT_END:
+ rec->end = value;
+ break;
+
+ case CAL_PROPERTY_EVENT_UNTIL:
+ rec->until = value;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_record_event_reset_child_record_id(calendar_record_h child_record)
+{
+ cal_record_s *record = (cal_record_s*)child_record;
+ retv_if(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
+
+ switch (record->type) {
+ case CAL_RECORD_TYPE_ALARM:
+ ((cal_alarm_s *)record)->id = 0;
+ break;
+ case CAL_RECORD_TYPE_ATTENDEE:
+ ((cal_attendee_s *)record)->id = 0;
+ break;
+ case CAL_RECORD_TYPE_EXTENDED:
+ ((cal_extended_s *)record)->id = 0;
+ break;
+ case CAL_RECORD_TYPE_EVENT:
+ ((cal_event_s *)record)->index = 0;
+ break;
+ default:
+ ERR("Invalid child record type (%d)", record->type);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_event_add_child_record( calendar_record_h record, unsigned int property_id, calendar_record_h child_record )
{
- cal_event_s *rec = (cal_event_s*)(record);
-
- switch( property_id )
- {
- case CAL_PROPERTY_EVENT_CALENDAR_ALARM:
- rec->alarm_list = g_list_append(rec->alarm_list,child_record);
- rec->has_alarm = 1;
- break;
- case CAL_PROPERTY_EVENT_CALENDAR_ATTENDEE:
- rec->attendee_list = g_list_append(rec->attendee_list,child_record);
- rec->has_attendee = 1;
- break;
- case CAL_PROPERTY_EVENT_EXCEPTION:
- rec->exception_list = g_list_append(rec->exception_list,child_record);
- break;
- case CAL_PROPERTY_EVENT_EXTENDED:
- rec->extended_list = g_list_append(rec->extended_list,child_record);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
+ cal_event_s *rec = (cal_event_s*)(record);
+ __cal_record_event_reset_child_record_id(child_record);
+
+ switch( property_id ) {
+ case CAL_PROPERTY_EVENT_CALENDAR_ALARM:
+ ret = calendar_list_add((calendar_list_h)rec->alarm_list, child_record);
+ rec->has_alarm = 1;
+ break;
+ case CAL_PROPERTY_EVENT_CALENDAR_ATTENDEE:
+ ret = calendar_list_add((calendar_list_h)rec->attendee_list, child_record);
+ rec->has_attendee = 1;
+ break;
+ case CAL_PROPERTY_EVENT_EXCEPTION:
+ calendar_list_destroy((calendar_list_h)((cal_event_s *)child_record)->exception_list, true);
+ ((cal_event_s *)child_record)->exception_list = calloc(1, sizeof(cal_list_s));
+ ret = calendar_list_add((calendar_list_h)rec->exception_list, child_record);
+ break;
+ case CAL_PROPERTY_EVENT_EXTENDED:
+ ret = calendar_list_add((calendar_list_h)rec->extended_list, child_record);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return ret;
}
static int __cal_record_event_remove_child_record( calendar_record_h record, unsigned int property_id, calendar_record_h child_record )
{
- cal_event_s *rec = (cal_event_s*)(record);
- //GList* node = NULL;
-
- switch( property_id )
- {
- case CAL_PROPERTY_EVENT_CALENDAR_ALARM:
- rec->alarm_list = g_list_remove(rec->alarm_list,child_record);
- if (g_list_length(rec->alarm_list) == 0)
- {
- rec->has_alarm = 0;
- }
- break;
- case CAL_PROPERTY_EVENT_CALENDAR_ATTENDEE:
- rec->attendee_list = g_list_remove(rec->attendee_list,child_record);
- if (g_list_length(rec->attendee_list) == 0)
- {
- rec->has_attendee = 0;
- }
- break;
- case CAL_PROPERTY_EVENT_EXCEPTION:
- rec->exception_list = g_list_remove(rec->exception_list,child_record);
- break;
- case CAL_PROPERTY_EVENT_EXTENDED:
- rec->extended_list = g_list_remove(rec->extended_list,child_record);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
+ cal_event_s *rec = (cal_event_s *)record;
+ switch (property_id) {
+ case CAL_PROPERTY_EVENT_CALENDAR_ALARM:
+ ret = calendar_list_remove((calendar_list_h)rec->alarm_list, child_record);
+ if (rec->alarm_list->count == 0)
+ rec->has_alarm = 0;
+ break;
+ case CAL_PROPERTY_EVENT_CALENDAR_ATTENDEE:
+ ret = calendar_list_remove((calendar_list_h)rec->attendee_list, child_record);
+ if (rec->attendee_list->count == 0)
+ rec->has_attendee = 0;
+ break;
+ case CAL_PROPERTY_EVENT_EXCEPTION:
+ ret = calendar_list_remove((calendar_list_h)rec->exception_list, child_record);
+ break;
+ case CAL_PROPERTY_EVENT_EXTENDED:
+ ret = calendar_list_remove((calendar_list_h)rec->extended_list, child_record);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return ret;
}
static int __cal_record_event_get_child_record_count( calendar_record_h record, unsigned int property_id, unsigned int* count )
{
- cal_event_s *rec = (cal_event_s*)(record);
- *count = 0;
-
- switch( property_id )
- {
- case CAL_PROPERTY_EVENT_CALENDAR_ALARM:
- if (rec->alarm_list)
- {
- *count = g_list_length(rec->alarm_list);
- }
- break;
- case CAL_PROPERTY_EVENT_CALENDAR_ATTENDEE:
- if (rec->attendee_list)
- {
- *count = g_list_length(rec->attendee_list);
- }
- break;
- case CAL_PROPERTY_EVENT_EXCEPTION:
- if (rec->exception_list)
- {
- *count = g_list_length(rec->exception_list);
- }
- break;
- case CAL_PROPERTY_EVENT_EXTENDED:
- if (rec->extended_list)
- {
- *count = g_list_length(rec->extended_list);
- }
- break;
- default:
- *count = 0;
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
+ cal_event_s *rec = (cal_event_s *)record;
+
+ retv_if(NULL == count, CALENDAR_ERROR_INVALID_PARAMETER);
+ *count = 0;
+
+ switch (property_id) {
+ case CAL_PROPERTY_EVENT_CALENDAR_ALARM:
+ ret = calendar_list_get_count((calendar_list_h)rec->alarm_list, (int *)count);
+ break;
+ case CAL_PROPERTY_EVENT_CALENDAR_ATTENDEE:
+ ret = calendar_list_get_count((calendar_list_h)rec->attendee_list, (int *)count);
+ break;
+ case CAL_PROPERTY_EVENT_EXCEPTION:
+ ret = calendar_list_get_count((calendar_list_h)rec->exception_list, (int *)count);
+ break;
+ case CAL_PROPERTY_EVENT_EXTENDED:
+ ret = calendar_list_get_count((calendar_list_h)rec->extended_list, (int *)count);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return ret;
}
-static int __cal_record_event_get_child_record_at_p( calendar_record_h record, unsigned int property_id, int index, calendar_record_h* child_record )
+static int __cal_record_event_get_child_record_at_p( calendar_record_h record, unsigned int property_id, int index, calendar_record_h* child_record)
{
- cal_event_s *rec = (cal_event_s*)(record);
-
- switch( property_id )
- {
- case CAL_PROPERTY_EVENT_CALENDAR_ALARM:
- *child_record = g_list_nth_data(rec->alarm_list,index);
- break;
- case CAL_PROPERTY_EVENT_CALENDAR_ATTENDEE:
- *child_record = g_list_nth_data(rec->attendee_list,index);
- break;
- case CAL_PROPERTY_EVENT_EXCEPTION:
- *child_record = g_list_nth_data(rec->exception_list,index);
- break;
- case CAL_PROPERTY_EVENT_EXTENDED:
- *child_record = g_list_nth_data(rec->extended_list,index);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ int ret;
+ cal_event_s *rec = (cal_event_s*)(record);
+
+ retv_if(NULL == child_record, CALENDAR_ERROR_INVALID_PARAMETER);
+ *child_record = NULL;
+
+ switch (property_id) {
+ case CAL_PROPERTY_EVENT_CALENDAR_ALARM:
+ ret = _cal_list_get_nth_record_p(rec->alarm_list, index, child_record);
+ break;
+ case CAL_PROPERTY_EVENT_CALENDAR_ATTENDEE:
+ ret = _cal_list_get_nth_record_p(rec->attendee_list, index, child_record);
+ break;
+ case CAL_PROPERTY_EVENT_EXCEPTION:
+ ret = _cal_list_get_nth_record_p(rec->exception_list, index, child_record);
+ break;
+ case CAL_PROPERTY_EVENT_EXTENDED:
+ ret = _cal_list_get_nth_record_p(rec->extended_list, index, child_record);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return ret;
}
static int __cal_record_event_clone_child_record_list( calendar_record_h record, unsigned int property_id, calendar_list_h* out_list )
{
- cal_event_s *rec = (cal_event_s*)(record);
- int ret = CALENDAR_ERROR_NONE;
- calendar_list_h list;
- int count = 0;
-
- ret = calendar_list_create(&list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_list_create fail");
- return ret;
- }
-
- switch( property_id )
- {
+ int ret;
+ cal_event_s *rec = (cal_event_s*)(record);
+
+ retv_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER);
+ *out_list = NULL;
+
+ switch (property_id) {
case CAL_PROPERTY_EVENT_CALENDAR_ALARM:
- {
- count = g_list_length(rec->alarm_list);
- if (count <=0 )
- {
- calendar_list_destroy(list, true);
- return CALENDAR_ERROR_NO_DATA;
- }
- GList *alarm_list = rec->alarm_list;
- calendar_record_h alarm_child_record;
- calendar_record_h alarm_record = NULL;
- while (alarm_list)
- {
- alarm_child_record = (calendar_record_h)alarm_list->data;
- if (alarm_child_record == NULL)
- {
- alarm_list = g_list_next(alarm_list);
- continue;
- }
-
- if ( calendar_record_clone(alarm_child_record,&alarm_record) == CALENDAR_ERROR_NONE )
- {
- calendar_list_add(list,alarm_record);
- }
- alarm_record = NULL;
-
- alarm_list = g_list_next(alarm_list);
- }
- *out_list = (calendar_list_h)list;
- }
- break;
+ ret = _cal_list_clone((calendar_list_h)rec->alarm_list, out_list);
+ break;
case CAL_PROPERTY_EVENT_CALENDAR_ATTENDEE:
- {
- count = g_list_length(rec->attendee_list);
- if (count <=0 )
- {
- calendar_list_destroy(list, true);
- return CALENDAR_ERROR_NO_DATA;
- }
- GList *attendee_list = rec->attendee_list;
- calendar_record_h attendee_child_record;
- calendar_record_h attendee_record = NULL;
- while (attendee_list)
- {
- attendee_child_record = (calendar_record_h)attendee_list->data;
- if (attendee_child_record == NULL)
- {
- attendee_list = g_list_next(attendee_list);
- continue;
- }
-
- if ( calendar_record_clone(attendee_child_record,&attendee_record) == CALENDAR_ERROR_NONE )
- {
- calendar_list_add(list,attendee_record);
- }
- attendee_record = NULL;
-
- attendee_list = g_list_next(attendee_list);
- }
- *out_list = (calendar_list_h)list;
- }
- break;
- case CAL_PROPERTY_EVENT_EXCEPTION:
- {
- count = g_list_length(rec->exception_list);
- if (count <=0 )
- {
- calendar_list_destroy(list, true);
- return CALENDAR_ERROR_NO_DATA;
- }
- GList *exception_list = rec->exception_list;
- calendar_record_h child_record;
- calendar_record_h record = NULL;
- while (exception_list)
- {
- child_record = (calendar_record_h)exception_list->data;
- if (child_record == NULL)
- {
- exception_list = g_list_next(exception_list);
- continue;
- }
-
- if ( calendar_record_clone(child_record,&record) == CALENDAR_ERROR_NONE )
- {
- calendar_list_add(list,record);
- }
- record = NULL;
-
- exception_list = g_list_next(exception_list);
- }
- *out_list = (calendar_list_h)list;
- }
- break;
- case CAL_PROPERTY_EVENT_EXTENDED:
- {
- count = g_list_length(rec->extended_list);
- if (count <=0 )
- {
- calendar_list_destroy(list, true);
- return CALENDAR_ERROR_NO_DATA;
- }
- GList *extended_list = rec->extended_list;
- calendar_record_h child_record;
- calendar_record_h record = NULL;
- while (extended_list)
- {
- child_record = (calendar_record_h)extended_list->data;
- if (child_record == NULL)
- {
- extended_list = g_list_next(extended_list);
- continue;
- }
-
- if ( calendar_record_clone(child_record,&record) == CALENDAR_ERROR_NONE )
- {
- calendar_list_add(list,record);
- }
- record = NULL;
-
- extended_list = g_list_next(extended_list);
- }
- *out_list = (calendar_list_h)list;
- }
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ ret = _cal_list_clone((calendar_list_h)rec->attendee_list, out_list);
+ break;
+ case CAL_PROPERTY_EVENT_EXCEPTION:
+ ret = _cal_list_clone((calendar_list_h)rec->exception_list, out_list);
+ break;
+ case CAL_PROPERTY_EVENT_EXTENDED:
+ ret = _cal_list_clone((calendar_list_h)rec->extended_list, out_list);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)", property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return ret;
}
static int __cal_record_extended_set_int( calendar_record_h record, unsigned int property_id, int value );
cal_record_plugin_cb_s _cal_record_extended_plugin_cb = {
- .create = __cal_record_extended_create,
- .destroy = __cal_record_extended_destroy,
- .clone = __cal_record_extended_clone,
- .get_str = __cal_record_extended_get_str,
- .get_str_p = __cal_record_extended_get_str_p,
- .get_int = __cal_record_extended_get_int,
- .get_double = NULL,
- .get_lli = NULL,
- .get_caltime = NULL,
- .set_str = __cal_record_extended_set_str,
- .set_int = __cal_record_extended_set_int,
- .set_double = NULL,
- .set_lli = NULL,
- .set_caltime = NULL,
- .add_child_record = NULL,
- .remove_child_record = NULL,
- .get_child_record_count = NULL,
- .get_child_record_at_p = NULL,
- .clone_child_record_list = NULL
+ .create = __cal_record_extended_create,
+ .destroy = __cal_record_extended_destroy,
+ .clone = __cal_record_extended_clone,
+ .get_str = __cal_record_extended_get_str,
+ .get_str_p = __cal_record_extended_get_str_p,
+ .get_int = __cal_record_extended_get_int,
+ .get_double = NULL,
+ .get_lli = NULL,
+ .get_caltime = NULL,
+ .set_str = __cal_record_extended_set_str,
+ .set_int = __cal_record_extended_set_int,
+ .set_double = NULL,
+ .set_lli = NULL,
+ .set_caltime = NULL,
+ .add_child_record = NULL,
+ .remove_child_record = NULL,
+ .get_child_record_count = NULL,
+ .get_child_record_at_p = NULL,
+ .clone_child_record_list = NULL
};
static void __cal_record_extended_struct_init(cal_extended_s *record)
{
- memset(record,0,sizeof(cal_extended_s));
+ memset(record,0,sizeof(cal_extended_s));
}
static int __cal_record_extended_create( calendar_record_h* out_record )
{
- cal_extended_s *temp = NULL;
- int ret= CALENDAR_ERROR_NONE, type = 0;
+ cal_extended_s *temp = NULL;
+ int ret= CALENDAR_ERROR_NONE;
- type = CAL_RECORD_TYPE_EXTENDED;
+ temp = (cal_extended_s*)calloc(1,sizeof(cal_extended_s));
+ retvm_if(NULL == temp, CALENDAR_ERROR_OUT_OF_MEMORY, "malloc(cal_extended_s) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
- temp = (cal_extended_s*)calloc(1,sizeof(cal_extended_s));
- retvm_if(NULL == temp, CALENDAR_ERROR_OUT_OF_MEMORY, "malloc(cal_extended_s) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
+ __cal_record_extended_struct_init(temp);
- __cal_record_extended_struct_init(temp);
+ *out_record = (calendar_record_h)temp;
- *out_record = (calendar_record_h)temp;
-
- return ret;
+ return ret;
}
static void __cal_record_extended_struct_free(cal_extended_s *record)
{
- CAL_FREE(record->key);
- CAL_FREE(record->value);
- CAL_FREE(record);
+ CAL_FREE(record->key);
+ CAL_FREE(record->value);
+ CAL_FREE(record);
}
static int __cal_record_extended_destroy( calendar_record_h record, bool delete_child )
{
- int ret = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
- cal_extended_s *temp = (cal_extended_s*)(record);
+ cal_extended_s *temp = (cal_extended_s*)(record);
- __cal_record_extended_struct_free(temp);
+ __cal_record_extended_struct_free(temp);
- return ret;
+ return ret;
}
static int __cal_record_extended_clone( calendar_record_h record, calendar_record_h* out_record )
{
- cal_extended_s *out_data = NULL;
- cal_extended_s *src_data = NULL;
+ cal_extended_s *out_data = NULL;
+ cal_extended_s *src_data = NULL;
- src_data = (cal_extended_s*)(record);
+ src_data = (cal_extended_s*)(record);
- out_data = calloc(1, sizeof(cal_extended_s));
- retvm_if(NULL == out_data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_extended_s) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
+ out_data = calloc(1, sizeof(cal_extended_s));
+ retvm_if(NULL == out_data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_extended_s) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
- CAL_RECORD_COPY_COMMON(&(out_data->common), &(src_data->common));
+ CAL_RECORD_COPY_COMMON(&(out_data->common), &(src_data->common));
- out_data->id = src_data->id;
- out_data->record_id = src_data->record_id;
- out_data->record_type = src_data->record_type;
- out_data->key = SAFE_STRDUP(src_data->key);
- out_data->value = SAFE_STRDUP(src_data->value);
+ out_data->id = src_data->id;
+ out_data->record_id = src_data->record_id;
+ out_data->record_type = src_data->record_type;
+ out_data->key = SAFE_STRDUP(src_data->key);
+ out_data->value = SAFE_STRDUP(src_data->value);
- *out_record = (calendar_record_h)out_data;
+ *out_record = (calendar_record_h)out_data;
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_extended_get_str( calendar_record_h record, unsigned int property_id, char** out_str )
{
- cal_extended_s *rec = (cal_extended_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_EXTENDED_KEY:
- *out_str = SAFE_STRDUP(rec->key);
- break;
- case CAL_PROPERTY_EXTENDED_VALUE:
- *out_str = SAFE_STRDUP(rec->value);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_extended_s *rec = (cal_extended_s*)(record);
+ switch( property_id )
+ {
+ case CAL_PROPERTY_EXTENDED_KEY:
+ *out_str = SAFE_STRDUP(rec->key);
+ break;
+ case CAL_PROPERTY_EXTENDED_VALUE:
+ *out_str = SAFE_STRDUP(rec->value);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_extended_get_str_p( calendar_record_h record, unsigned int property_id, char** out_str )
{
- cal_extended_s *rec = (cal_extended_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_EXTENDED_KEY:
- *out_str = (rec->key);
- break;
- case CAL_PROPERTY_EXTENDED_VALUE:
- *out_str = (rec->value);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_extended_s *rec = (cal_extended_s*)(record);
+ switch( property_id )
+ {
+ case CAL_PROPERTY_EXTENDED_KEY:
+ *out_str = (rec->key);
+ break;
+ case CAL_PROPERTY_EXTENDED_VALUE:
+ *out_str = (rec->value);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_extended_get_int( calendar_record_h record, unsigned int property_id, int* out_value )
{
- cal_extended_s *rec = (cal_extended_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_EXTENDED_ID:
- *out_value = (rec->id);
- break;
- case CAL_PROPERTY_EXTENDED_RECORD_ID:
- *out_value = (rec->record_id);
- break;
- case CAL_PROPERTY_EXTENDED_RECORD_TYPE:
- *out_value = (rec->record_type);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_extended_s *rec = (cal_extended_s*)(record);
+ switch( property_id )
+ {
+ case CAL_PROPERTY_EXTENDED_ID:
+ *out_value = (rec->id);
+ break;
+ case CAL_PROPERTY_EXTENDED_RECORD_ID:
+ *out_value = (rec->record_id);
+ break;
+ case CAL_PROPERTY_EXTENDED_RECORD_TYPE:
+ *out_value = (rec->record_type);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_extended_set_str( calendar_record_h record, unsigned int property_id, const char* value )
{
- cal_extended_s *rec = (cal_extended_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_EXTENDED_KEY:
- CAL_FREE(rec->key);
- rec->key = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_EXTENDED_VALUE:
- CAL_FREE(rec->value);
- rec->value = SAFE_STRDUP(value);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_extended_s *rec = (cal_extended_s*)(record);
+ switch( property_id )
+ {
+ case CAL_PROPERTY_EXTENDED_KEY:
+ CAL_FREE(rec->key);
+ rec->key = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_EXTENDED_VALUE:
+ CAL_FREE(rec->value);
+ rec->value = SAFE_STRDUP(value);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_extended_set_int( calendar_record_h record, unsigned int property_id, int value )
{
- cal_extended_s *rec = (cal_extended_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_EXTENDED_ID:
- (rec->id) = value;
- break;
- case CAL_PROPERTY_EXTENDED_RECORD_ID:
- (rec->record_id) = value;
- break;
- case CAL_PROPERTY_EXTENDED_RECORD_TYPE:
- (rec->record_type) = value;
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_extended_s *rec = (cal_extended_s*)(record);
+ switch( property_id )
+ {
+ case CAL_PROPERTY_EXTENDED_ID:
+ (rec->id) = value;
+ break;
+ case CAL_PROPERTY_EXTENDED_RECORD_ID:
+ retvm_if(rec->id > 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter : property_id(%d) is a write-once value (calendar)", property_id);
+ (rec->record_id) = value;
+ break;
+ case CAL_PROPERTY_EXTENDED_RECORD_TYPE:
+ (rec->record_type) = value;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_instance_allday_set_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s value );
cal_record_plugin_cb_s _cal_record_instance_allday_plugin_cb = {
- .create = __cal_record_instance_allday_create,
- .destroy = __cal_record_instance_allday_destroy,
- .clone = __cal_record_instance_allday_clone,
- .get_str = __cal_record_instance_allday_get_str,
- .get_str_p = __cal_record_instance_allday_get_str_p,
- .get_int = __cal_record_instance_allday_get_int,
- .get_double = __cal_record_instance_allday_get_double,
- .get_lli = __cal_record_instance_allday_get_lli,
- .get_caltime = __cal_record_instance_allday_get_caltime,
- .set_str = __cal_record_instance_allday_set_str,
- .set_int = __cal_record_instance_allday_set_int,
- .set_double = __cal_record_instance_allday_set_double,
- .set_lli = __cal_record_instance_allday_set_lli,
- .set_caltime = __cal_record_instance_allday_set_caltime,
- .add_child_record = NULL,
- .remove_child_record = NULL,
- .get_child_record_count = NULL,
- .get_child_record_at_p = NULL,
- .clone_child_record_list = NULL
+ .create = __cal_record_instance_allday_create,
+ .destroy = __cal_record_instance_allday_destroy,
+ .clone = __cal_record_instance_allday_clone,
+ .get_str = __cal_record_instance_allday_get_str,
+ .get_str_p = __cal_record_instance_allday_get_str_p,
+ .get_int = __cal_record_instance_allday_get_int,
+ .get_double = __cal_record_instance_allday_get_double,
+ .get_lli = __cal_record_instance_allday_get_lli,
+ .get_caltime = __cal_record_instance_allday_get_caltime,
+ .set_str = __cal_record_instance_allday_set_str,
+ .set_int = __cal_record_instance_allday_set_int,
+ .set_double = __cal_record_instance_allday_set_double,
+ .set_lli = __cal_record_instance_allday_set_lli,
+ .set_caltime = __cal_record_instance_allday_set_caltime,
+ .add_child_record = NULL,
+ .remove_child_record = NULL,
+ .get_child_record_count = NULL,
+ .get_child_record_at_p = NULL,
+ .clone_child_record_list = NULL
};
static void __cal_record_instance_allday_struct_init(cal_instance_allday_s* record)
{
- memset(record,0,sizeof(cal_instance_allday_s));
+ memset(record,0,sizeof(cal_instance_allday_s));
- record->event_status = CALENDAR_EVENT_STATUS_NONE;
- record->calendar_id = DEFAULT_EVENT_CALENDAR_BOOK_ID;
- record->event_id = CAL_INVALID_ID;
+ record->event_status = CALENDAR_EVENT_STATUS_NONE;
+ record->calendar_id = DEFAULT_EVENT_CALENDAR_BOOK_ID;
+ record->event_id = CAL_INVALID_ID;
- record->busy_status = 2;
- record->summary = NULL;
- record->description = NULL;
- record->location= NULL;
+ record->busy_status = 2;
+ record->summary = NULL;
+ record->description = NULL;
+ record->location= NULL;
- record->latitude = 1000; // set default 1000 out of range(-180 ~ 180)
- record->longitude = 1000; // set default 1000 out of range(-180 ~ 180)
+ record->latitude = 1000; // set default 1000 out of range(-180 ~ 180)
+ record->longitude = 1000; // set default 1000 out of range(-180 ~ 180)
- return;
+ return;
}
static int __cal_record_instance_allday_create( calendar_record_h* out_record )
{
- cal_instance_allday_s *temp = NULL;
- int ret= CALENDAR_ERROR_NONE, type = 0;
+ cal_instance_allday_s *temp = NULL;
+ int ret= CALENDAR_ERROR_NONE;
- type = CAL_RECORD_TYPE_INSTANCE_ALLDAY;
+ temp = (cal_instance_allday_s*)calloc(1,sizeof(cal_instance_allday_s));
+ retvm_if(NULL == temp, CALENDAR_ERROR_OUT_OF_MEMORY, "malloc(cal_instance_allday_s:sch) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
- temp = (cal_instance_allday_s*)calloc(1,sizeof(cal_instance_allday_s));
- retvm_if(NULL == temp, CALENDAR_ERROR_OUT_OF_MEMORY, "malloc(cal_instance_allday_s:sch) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
+ __cal_record_instance_allday_struct_init(temp);
- __cal_record_instance_allday_struct_init(temp);
+ *out_record = (calendar_record_h)temp;
- *out_record = (calendar_record_h)temp;
-
- return ret;
+ return ret;
}
static void __cal_record_instance_allday_struct_free(cal_instance_allday_s *record)
{
- CAL_FREE(record->summary);
- CAL_FREE(record->description);
- CAL_FREE(record->location);
+ CAL_FREE(record->summary);
+ CAL_FREE(record->description);
+ CAL_FREE(record->location);
+ CAL_FREE(record->sync_data1);
- CAL_FREE(record);
+ CAL_FREE(record);
}
static int __cal_record_instance_allday_destroy( calendar_record_h record, bool delete_child )
{
- int ret = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
- cal_instance_allday_s *temp = (cal_instance_allday_s*)(record);
+ cal_instance_allday_s *temp = (cal_instance_allday_s*)(record);
- __cal_record_instance_allday_struct_free(temp);
+ __cal_record_instance_allday_struct_free(temp);
- return ret;
+ return ret;
}
static int __cal_record_instance_allday_clone( calendar_record_h record, calendar_record_h* out_record )
{
- cal_instance_allday_s *out_data = NULL;
- cal_instance_allday_s *src_data = NULL;
-
- src_data = (cal_instance_allday_s*)(record);
-
- out_data = calloc(1, sizeof(cal_instance_allday_s));
- retvm_if(NULL == out_data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_instance_allday_s) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
-
- CAL_RECORD_COPY_COMMON(&(out_data->common), &(src_data->common));
-
- out_data->event_id = src_data->event_id;
- out_data->calendar_id = src_data->calendar_id;
- out_data->dtstart_type = src_data->dtstart_type;
- out_data->dtstart_year = src_data->dtstart_year;
- out_data->dtstart_month = src_data->dtstart_month;
- out_data->dtstart_mday = src_data->dtstart_mday;
- out_data->dtend_type = src_data->dtend_type;
- out_data->dtend_year = src_data->dtend_year;
- out_data->dtend_month = src_data->dtend_month;
- out_data->dtend_mday = src_data->dtend_mday;
- out_data->summary = SAFE_STRDUP(src_data->summary);
- out_data->description = SAFE_STRDUP(src_data->description);
- out_data->location = SAFE_STRDUP(src_data->location);
- out_data->busy_status = src_data->busy_status;
- out_data->event_status = src_data->event_status;
- out_data->priority = src_data->priority;
- out_data->sensitivity = src_data->sensitivity;
- out_data->has_rrule = src_data->has_rrule;
- out_data->latitude = src_data->latitude;
- out_data->longitude = src_data->longitude;
- out_data->has_alarm = src_data->has_alarm;
- out_data->original_event_id = src_data->original_event_id;
- out_data->last_mod = src_data->last_mod;
-
- *out_record = (calendar_record_h)out_data;
-
- return CALENDAR_ERROR_NONE;
+ cal_instance_allday_s *out_data = NULL;
+ cal_instance_allday_s *src_data = NULL;
+
+ src_data = (cal_instance_allday_s*)(record);
+
+ out_data = calloc(1, sizeof(cal_instance_allday_s));
+ retvm_if(NULL == out_data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_instance_allday_s) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
+
+ CAL_RECORD_COPY_COMMON(&(out_data->common), &(src_data->common));
+
+ out_data->event_id = src_data->event_id;
+ out_data->calendar_id = src_data->calendar_id;
+ out_data->start = src_data->start;
+ out_data->end = src_data->end;
+ out_data->summary = SAFE_STRDUP(src_data->summary);
+ out_data->description = SAFE_STRDUP(src_data->description);
+ out_data->location = SAFE_STRDUP(src_data->location);
+ out_data->busy_status = src_data->busy_status;
+ out_data->event_status = src_data->event_status;
+ out_data->priority = src_data->priority;
+ out_data->sensitivity = src_data->sensitivity;
+ out_data->has_rrule = src_data->has_rrule;
+ out_data->latitude = src_data->latitude;
+ out_data->longitude = src_data->longitude;
+ out_data->has_alarm = src_data->has_alarm;
+ out_data->original_event_id = src_data->original_event_id;
+ out_data->last_mod = src_data->last_mod;
+ out_data->sync_data1 = SAFE_STRDUP(src_data->sync_data1);
+
+ *out_record = (calendar_record_h)out_data;
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_instance_allday_get_str( calendar_record_h record, unsigned int property_id, char** out_str )
{
- cal_instance_allday_s *rec = (cal_instance_allday_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_INSTANCE_ALLDAY_SUMMARY:
- *out_str = SAFE_STRDUP(rec->summary);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_DESCRIPTION:
- *out_str = SAFE_STRDUP(rec->description);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_LOCATION:
- *out_str = SAFE_STRDUP(rec->location);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_instance_allday_s *rec = (cal_instance_allday_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_ALLDAY_SUMMARY:
+ *out_str = SAFE_STRDUP(rec->summary);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_DESCRIPTION:
+ *out_str = SAFE_STRDUP(rec->description);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_LOCATION:
+ *out_str = SAFE_STRDUP(rec->location);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_SYNC_DATA1:
+ *out_str = SAFE_STRDUP(rec->sync_data1);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_instance_allday_get_str_p( calendar_record_h record, unsigned int property_id, char** out_str )
{
- cal_instance_allday_s *rec = (cal_instance_allday_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_INSTANCE_ALLDAY_SUMMARY:
- *out_str = (rec->summary);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_DESCRIPTION:
- *out_str = (rec->description);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_LOCATION:
- *out_str = (rec->location);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_instance_allday_s *rec = (cal_instance_allday_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_ALLDAY_SUMMARY:
+ *out_str = (rec->summary);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_DESCRIPTION:
+ *out_str = (rec->description);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_LOCATION:
+ *out_str = (rec->location);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_SYNC_DATA1:
+ *out_str = (rec->sync_data1);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_instance_allday_get_int( calendar_record_h record, unsigned int property_id, int* out_value )
{
- cal_instance_allday_s *rec = (cal_instance_allday_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_ID:
- *out_value = (rec->event_id);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_CALENDAR_ID:
- *out_value = (rec->calendar_id);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_BUSY_STATUS:
- *out_value = (rec->busy_status);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_STATUS:
- *out_value = (rec->event_status);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_PRIORITY:
- *out_value = (rec->priority);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_SENSITIVITY:
- *out_value = (rec->sensitivity);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_HAS_RRULE:
- *out_value = (rec->has_rrule);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_HAS_ALARM:
- *out_value = (rec->has_alarm);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_ORIGINAL_EVENT_ID:
- *out_value = (rec->original_event_id);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_instance_allday_s *rec = (cal_instance_allday_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_ID:
+ *out_value = (rec->event_id);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_CALENDAR_ID:
+ *out_value = (rec->calendar_id);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_BUSY_STATUS:
+ *out_value = (rec->busy_status);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_STATUS:
+ *out_value = (rec->event_status);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_PRIORITY:
+ *out_value = (rec->priority);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_SENSITIVITY:
+ *out_value = (rec->sensitivity);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_HAS_RRULE:
+ *out_value = (rec->has_rrule);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_HAS_ALARM:
+ *out_value = (rec->has_alarm);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_ORIGINAL_EVENT_ID:
+ *out_value = (rec->original_event_id);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_IS_ALLDAY:
+ *out_value = (rec->is_allday);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_instance_allday_get_double( calendar_record_h record, unsigned int property_id, double* out_value )
{
- cal_instance_allday_s *rec = (cal_instance_allday_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_INSTANCE_ALLDAY_LATITUDE:
- *out_value = (rec->latitude);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_LONGITUDE:
- *out_value = (rec->longitude);
- break;
-
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_instance_allday_s *rec = (cal_instance_allday_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_ALLDAY_LATITUDE:
+ *out_value = (rec->latitude);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_LONGITUDE:
+ *out_value = (rec->longitude);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_instance_allday_get_lli( calendar_record_h record, unsigned int property_id, long long int* out_value )
{
- cal_instance_allday_s *rec = (cal_instance_allday_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_INSTANCE_ALLDAY_LAST_MODIFIED_TIME:
- *out_value = (rec->last_mod);
- break;
- default:
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_instance_allday_s *rec = (cal_instance_allday_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_ALLDAY_LAST_MODIFIED_TIME:
+ *out_value = (rec->last_mod);
+ break;
+ default:
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_instance_allday_get_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s* out_value )
{
- cal_instance_allday_s *rec = (cal_instance_allday_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_INSTANCE_ALLDAY_START:
- CAL_CALTIME_SET_DATE(*out_value,(rec->dtstart_year),(rec->dtstart_month),(rec->dtstart_mday));
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_END:
- CAL_CALTIME_SET_DATE(*out_value,(rec->dtend_year),(rec->dtend_month),(rec->dtend_mday));
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_instance_allday_s *rec = (cal_instance_allday_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_ALLDAY_START:
+ *out_value = rec->start;
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_END:
+ *out_value = rec->end;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_instance_allday_set_str( calendar_record_h record, unsigned int property_id, const char* value )
{
- cal_instance_allday_s *rec = (cal_instance_allday_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_INSTANCE_ALLDAY_SUMMARY:
- CAL_FREE(rec->summary);
- rec->summary = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_DESCRIPTION:
- CAL_FREE(rec->description);
- rec->description = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_LOCATION:
- CAL_FREE(rec->location);
- rec->location = SAFE_STRDUP(value);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_instance_allday_s *rec = (cal_instance_allday_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_ALLDAY_SUMMARY:
+ CAL_FREE(rec->summary);
+ rec->summary = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_DESCRIPTION:
+ CAL_FREE(rec->description);
+ rec->description = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_LOCATION:
+ CAL_FREE(rec->location);
+ rec->location = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_SYNC_DATA1:
+ CAL_FREE(rec->sync_data1);
+ rec->sync_data1 = SAFE_STRDUP(value);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_instance_allday_set_int( calendar_record_h record, unsigned int property_id, int value )
{
- cal_instance_allday_s *rec = (cal_instance_allday_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_ID:
- (rec->event_id) = value;
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_CALENDAR_ID:
- (rec->calendar_id) = value;
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_BUSY_STATUS:
- (rec->busy_status) = value;
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_STATUS:
- (rec->event_status) = value;
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_PRIORITY:
- (rec->priority) = value;
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_SENSITIVITY:
- (rec->sensitivity) = value;
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_HAS_RRULE:
- (rec->has_rrule) = value;
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_HAS_ALARM:
- (rec->has_alarm) = value;
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_ORIGINAL_EVENT_ID:
- (rec->original_event_id) = value;
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_instance_allday_s *rec = (cal_instance_allday_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_ID:
+ (rec->event_id) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_CALENDAR_ID:
+ (rec->calendar_id) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_BUSY_STATUS:
+ (rec->busy_status) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_STATUS:
+ (rec->event_status) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_PRIORITY:
+ (rec->priority) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_SENSITIVITY:
+ (rec->sensitivity) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_HAS_RRULE:
+ (rec->has_rrule) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_HAS_ALARM:
+ (rec->has_alarm) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_ORIGINAL_EVENT_ID:
+ (rec->original_event_id) = value;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_instance_allday_set_double( calendar_record_h record, unsigned int property_id, double value )
{
- cal_instance_allday_s *rec = (cal_instance_allday_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_INSTANCE_ALLDAY_LATITUDE:
- (rec->latitude) = value;
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_LONGITUDE:
- (rec->longitude) = value;
- break;
-
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_instance_allday_s *rec = (cal_instance_allday_s*)(record);
+ switch( property_id )
+ {
+ case CAL_PROPERTY_INSTANCE_ALLDAY_LATITUDE:
+ (rec->latitude) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_LONGITUDE:
+ (rec->longitude) = value;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_instance_allday_set_lli( calendar_record_h record, unsigned int property_id, long long int value )
{
- cal_instance_allday_s *rec = (cal_instance_allday_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_INSTANCE_ALLDAY_LAST_MODIFIED_TIME:
- (rec->last_mod) = value;
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_instance_allday_s *rec = (cal_instance_allday_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_ALLDAY_LAST_MODIFIED_TIME:
+ (rec->last_mod) = value;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_instance_allday_set_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s value )
{
- cal_instance_allday_s *rec = (cal_instance_allday_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_INSTANCE_ALLDAY_START:
- (rec->dtstart_type) = CALENDAR_TIME_LOCALTIME;//value.type;
- (rec->dtstart_year) = value.time.date.year;
- (rec->dtstart_month) = value.time.date.month;
- (rec->dtstart_mday) = value.time.date.mday ;
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_END:
- (rec->dtend_type) = CALENDAR_TIME_LOCALTIME;//value.type;
- (rec->dtend_year) = value.time.date.year;
- (rec->dtend_month) = value.time.date.month;
- (rec->dtend_mday) = value.time.date.mday ;
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_instance_allday_s *rec = (cal_instance_allday_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_ALLDAY_START:
+ rec->start = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_END:
+ rec->end = value;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
--- /dev/null
+/*
+ * Calendar Service
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <stdlib.h> //calloc
+#include <stdbool.h> //bool
+#include <string.h>
+
+#include "cal_internal.h"
+#include "cal_typedef.h"
+#include "cal_view.h"
+
+#include "cal_record.h"
+
+static int __cal_record_instance_allday_extended_create( calendar_record_h* out_record );
+static int __cal_record_instance_allday_extended_destroy( calendar_record_h record, bool delete_child );
+static int __cal_record_instance_allday_extended_clone( calendar_record_h record, calendar_record_h* out_record );
+static int __cal_record_instance_allday_extended_get_str( calendar_record_h record, unsigned int property_id, char** out_str );
+static int __cal_record_instance_allday_extended_get_str_p( calendar_record_h record, unsigned int property_id, char** out_str );
+static int __cal_record_instance_allday_extended_get_int( calendar_record_h record, unsigned int property_id, int* out_value );
+static int __cal_record_instance_allday_extended_get_double( calendar_record_h record, unsigned int property_id, double* out_value );
+static int __cal_record_instance_allday_extended_get_lli( calendar_record_h record, unsigned int property_id, long long int* out_value );
+static int __cal_record_instance_allday_extended_get_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s* out_value );
+static int __cal_record_instance_allday_extended_set_str( calendar_record_h record, unsigned int property_id, const char* value );
+static int __cal_record_instance_allday_extended_set_int( calendar_record_h record, unsigned int property_id, int value );
+static int __cal_record_instance_allday_extended_set_double( calendar_record_h record, unsigned int property_id, double value );
+static int __cal_record_instance_allday_extended_set_lli( calendar_record_h record, unsigned int property_id, long long int value );
+static int __cal_record_instance_allday_extended_set_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s value );
+
+cal_record_plugin_cb_s _cal_record_instance_allday_extended_plugin_cb = {
+ .create = __cal_record_instance_allday_extended_create,
+ .destroy = __cal_record_instance_allday_extended_destroy,
+ .clone = __cal_record_instance_allday_extended_clone,
+ .get_str = __cal_record_instance_allday_extended_get_str,
+ .get_str_p = __cal_record_instance_allday_extended_get_str_p,
+ .get_int = __cal_record_instance_allday_extended_get_int,
+ .get_double = __cal_record_instance_allday_extended_get_double,
+ .get_lli = __cal_record_instance_allday_extended_get_lli,
+ .get_caltime = __cal_record_instance_allday_extended_get_caltime,
+ .set_str = __cal_record_instance_allday_extended_set_str,
+ .set_int = __cal_record_instance_allday_extended_set_int,
+ .set_double = __cal_record_instance_allday_extended_set_double,
+ .set_lli = __cal_record_instance_allday_extended_set_lli,
+ .set_caltime = __cal_record_instance_allday_extended_set_caltime,
+ .add_child_record = NULL,
+ .remove_child_record = NULL,
+ .get_child_record_count = NULL,
+ .get_child_record_at_p = NULL,
+ .clone_child_record_list = NULL
+};
+
+static void __cal_record_instance_allday_extended_struct_init(cal_instance_allday_extended_s* record)
+{
+ memset(record,0,sizeof(cal_instance_allday_extended_s));
+
+ record->event_status = CALENDAR_EVENT_STATUS_NONE;
+ record->calendar_id = DEFAULT_EVENT_CALENDAR_BOOK_ID;
+ record->event_id = CAL_INVALID_ID;
+
+ record->busy_status = 2;
+ record->summary = NULL;
+ record->description = NULL;
+ record->location= NULL;
+
+ record->latitude = 1000; // set default 1000 out of range(-180 ~ 180)
+ record->longitude = 1000; // set default 1000 out of range(-180 ~ 180)
+
+ return;
+}
+
+static int __cal_record_instance_allday_extended_create( calendar_record_h* out_record )
+{
+ cal_instance_allday_extended_s *temp = NULL;
+ int ret= CALENDAR_ERROR_NONE;
+
+ temp = (cal_instance_allday_extended_s*)calloc(1,sizeof(cal_instance_allday_extended_s));
+ retvm_if(NULL == temp, CALENDAR_ERROR_OUT_OF_MEMORY, "malloc(cal_instance_allday_extended_s:sch) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
+
+ __cal_record_instance_allday_extended_struct_init(temp);
+
+ *out_record = (calendar_record_h)temp;
+
+ return ret;
+}
+
+static void __cal_record_instance_allday_extended_struct_free(cal_instance_allday_extended_s *record)
+{
+ CAL_FREE(record->summary);
+ CAL_FREE(record->description);
+ CAL_FREE(record->location);
+ CAL_FREE(record->organizer_name);
+ CAL_FREE(record->categories);
+ CAL_FREE(record->sync_data1);
+ CAL_FREE(record->sync_data2);
+ CAL_FREE(record->sync_data3);
+ CAL_FREE(record->sync_data4);
+
+ CAL_FREE(record);
+}
+
+static int __cal_record_instance_allday_extended_destroy( calendar_record_h record, bool delete_child )
+{
+ int ret = CALENDAR_ERROR_NONE;
+
+ cal_instance_allday_extended_s *temp = (cal_instance_allday_extended_s*)(record);
+
+ __cal_record_instance_allday_extended_struct_free(temp);
+
+ return ret;
+}
+
+static int __cal_record_instance_allday_extended_clone( calendar_record_h record, calendar_record_h* out_record )
+{
+ cal_instance_allday_extended_s *out_data = NULL;
+ cal_instance_allday_extended_s *src_data = NULL;
+
+ src_data = (cal_instance_allday_extended_s*)(record);
+
+ out_data = calloc(1, sizeof(cal_instance_allday_extended_s));
+ retvm_if(NULL == out_data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_instance_allday_extended_s) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
+
+ CAL_RECORD_COPY_COMMON(&(out_data->common), &(src_data->common));
+
+ out_data->event_id = src_data->event_id;
+ out_data->calendar_id = src_data->calendar_id;
+ out_data->start = src_data->start;
+ out_data->end = src_data->end;
+ out_data->summary = SAFE_STRDUP(src_data->summary);
+ out_data->description = SAFE_STRDUP(src_data->description);
+ out_data->location = SAFE_STRDUP(src_data->location);
+ out_data->busy_status = src_data->busy_status;
+ out_data->event_status = src_data->event_status;
+ out_data->priority = src_data->priority;
+ out_data->sensitivity = src_data->sensitivity;
+ out_data->has_rrule = src_data->has_rrule;
+ out_data->latitude = src_data->latitude;
+ out_data->longitude = src_data->longitude;
+ out_data->has_alarm = src_data->has_alarm;
+ out_data->original_event_id = src_data->original_event_id;
+ out_data->last_mod = src_data->last_mod;
+ out_data->organizer_name = SAFE_STRDUP(src_data->organizer_name);
+ out_data->categories = SAFE_STRDUP(src_data->categories);
+ out_data->sync_data1 = SAFE_STRDUP(src_data->sync_data1);
+ out_data->sync_data2 = SAFE_STRDUP(src_data->sync_data2);
+ out_data->sync_data3 = SAFE_STRDUP(src_data->sync_data3);
+ out_data->sync_data4 = SAFE_STRDUP(src_data->sync_data4);
+
+ *out_record = (calendar_record_h)out_data;
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_record_instance_allday_extended_get_str( calendar_record_h record, unsigned int property_id, char** out_str )
+{
+ cal_instance_allday_extended_s *rec = (cal_instance_allday_extended_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SUMMARY:
+ *out_str = SAFE_STRDUP(rec->summary);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_DESCRIPTION:
+ *out_str = SAFE_STRDUP(rec->description);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_LOCATION:
+ *out_str = SAFE_STRDUP(rec->location);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA1:
+ *out_str = SAFE_STRDUP(rec->sync_data1);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_ORGANIZER_NAME:
+ *out_str = SAFE_STRDUP(rec->organizer_name);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_CATEGORIES:
+ *out_str = SAFE_STRDUP(rec->categories);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA2:
+ *out_str = SAFE_STRDUP(rec->sync_data2);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA3:
+ *out_str = SAFE_STRDUP(rec->sync_data3);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA4:
+ *out_str = SAFE_STRDUP(rec->sync_data4);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_record_instance_allday_extended_get_str_p( calendar_record_h record, unsigned int property_id, char** out_str )
+{
+ cal_instance_allday_extended_s *rec = (cal_instance_allday_extended_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SUMMARY:
+ *out_str = (rec->summary);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_DESCRIPTION:
+ *out_str = (rec->description);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_LOCATION:
+ *out_str = (rec->location);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA1:
+ *out_str = (rec->sync_data1);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_ORGANIZER_NAME:
+ *out_str = (rec->organizer_name);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_CATEGORIES:
+ *out_str = (rec->categories);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA2:
+ *out_str = (rec->sync_data2);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA3:
+ *out_str = (rec->sync_data3);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA4:
+ *out_str = (rec->sync_data4);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_record_instance_allday_extended_get_int( calendar_record_h record, unsigned int property_id, int* out_value )
+{
+ cal_instance_allday_extended_s *rec = (cal_instance_allday_extended_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_EVENT_ID:
+ *out_value = (rec->event_id);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_CALENDAR_ID:
+ *out_value = (rec->calendar_id);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_BUSY_STATUS:
+ *out_value = (rec->busy_status);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_EVENT_STATUS:
+ *out_value = (rec->event_status);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_PRIORITY:
+ *out_value = (rec->priority);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SENSITIVITY:
+ *out_value = (rec->sensitivity);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_HAS_RRULE:
+ *out_value = (rec->has_rrule);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_HAS_ALARM:
+ *out_value = (rec->has_alarm);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_ORIGINAL_EVENT_ID:
+ *out_value = (rec->original_event_id);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_HAS_ATTENDEE:
+ *out_value = (rec->has_attendee);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_IS_ALLDAY:
+ *out_value = (rec->is_allday);
+ break;
+
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_record_instance_allday_extended_get_double( calendar_record_h record, unsigned int property_id, double* out_value )
+{
+ cal_instance_allday_extended_s *rec = (cal_instance_allday_extended_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_LATITUDE:
+ *out_value = (rec->latitude);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_LONGITUDE:
+ *out_value = (rec->longitude);
+ break;
+
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_record_instance_allday_extended_get_lli( calendar_record_h record, unsigned int property_id, long long int* out_value )
+{
+ cal_instance_allday_extended_s *rec = (cal_instance_allday_extended_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_LAST_MODIFIED_TIME:
+ *out_value = (rec->last_mod);
+ break;
+ default:
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_record_instance_allday_extended_get_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s* out_value )
+{
+ cal_instance_allday_extended_s *rec = (cal_instance_allday_extended_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_START:
+ *out_value = rec->start;
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_END:
+ *out_value = rec->end;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_record_instance_allday_extended_set_str( calendar_record_h record, unsigned int property_id, const char* value )
+{
+ cal_instance_allday_extended_s *rec = (cal_instance_allday_extended_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SUMMARY:
+ CAL_FREE(rec->summary);
+ rec->summary = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_DESCRIPTION:
+ CAL_FREE(rec->description);
+ rec->description = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_LOCATION:
+ CAL_FREE(rec->location);
+ rec->location = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA1:
+ CAL_FREE(rec->sync_data1);
+ rec->sync_data1 = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_ORGANIZER_NAME:
+ CAL_FREE(rec->organizer_name);
+ rec->organizer_name = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_CATEGORIES:
+ CAL_FREE(rec->categories);
+ rec->categories = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA2:
+ CAL_FREE(rec->sync_data2);
+ rec->sync_data2 = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA3:
+ CAL_FREE(rec->sync_data3);
+ rec->sync_data3 = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA4:
+ CAL_FREE(rec->sync_data4);
+ rec->sync_data4 = SAFE_STRDUP(value);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_record_instance_allday_extended_set_int( calendar_record_h record, unsigned int property_id, int value )
+{
+ cal_instance_allday_extended_s *rec = (cal_instance_allday_extended_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_EVENT_ID:
+ (rec->event_id) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_CALENDAR_ID:
+ (rec->calendar_id) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_BUSY_STATUS:
+ (rec->busy_status) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_EVENT_STATUS:
+ (rec->event_status) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_PRIORITY:
+ (rec->priority) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SENSITIVITY:
+ (rec->sensitivity) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_HAS_RRULE:
+ (rec->has_rrule) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_HAS_ALARM:
+ (rec->has_alarm) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_ORIGINAL_EVENT_ID:
+ (rec->original_event_id) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_HAS_ATTENDEE:
+ (rec->has_attendee) = value;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_record_instance_allday_extended_set_double( calendar_record_h record, unsigned int property_id, double value )
+{
+ cal_instance_allday_extended_s *rec = (cal_instance_allday_extended_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_LATITUDE:
+ (rec->latitude) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_LONGITUDE:
+ (rec->longitude) = value;
+ break;
+
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_record_instance_allday_extended_set_lli( calendar_record_h record, unsigned int property_id, long long int value )
+{
+ cal_instance_allday_extended_s *rec = (cal_instance_allday_extended_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_LAST_MODIFIED_TIME:
+ (rec->last_mod) = value;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_record_instance_allday_extended_set_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s value )
+{
+ cal_instance_allday_extended_s *rec = (cal_instance_allday_extended_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_START:
+ rec->start = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_END:
+ rec->end = value;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
static int __cal_record_instance_normal_set_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s value );
cal_record_plugin_cb_s _cal_record_instance_normal_plugin_cb = {
- .create = __cal_record_instance_normal_create,
- .destroy = __cal_record_instance_normal_destroy,
- .clone = __cal_record_instance_normal_clone,
- .get_str = __cal_record_instance_normal_get_str,
- .get_str_p = __cal_record_instance_normal_get_str_p,
- .get_int = __cal_record_instance_normal_get_int,
- .get_double = __cal_record_instance_normal_get_double,
- .get_lli = __cal_record_instance_normal_get_lli,
- .get_caltime = __cal_record_instance_normal_get_caltime,
- .set_str = __cal_record_instance_normal_set_str,
- .set_int = __cal_record_instance_normal_set_int,
- .set_double = __cal_record_instance_normal_set_double,
- .set_lli = __cal_record_instance_normal_set_lli,
- .set_caltime = __cal_record_instance_normal_set_caltime,
- .add_child_record = NULL,
- .remove_child_record = NULL,
- .get_child_record_count = NULL,
- .get_child_record_at_p = NULL,
- .clone_child_record_list = NULL
+ .create = __cal_record_instance_normal_create,
+ .destroy = __cal_record_instance_normal_destroy,
+ .clone = __cal_record_instance_normal_clone,
+ .get_str = __cal_record_instance_normal_get_str,
+ .get_str_p = __cal_record_instance_normal_get_str_p,
+ .get_int = __cal_record_instance_normal_get_int,
+ .get_double = __cal_record_instance_normal_get_double,
+ .get_lli = __cal_record_instance_normal_get_lli,
+ .get_caltime = __cal_record_instance_normal_get_caltime,
+ .set_str = __cal_record_instance_normal_set_str,
+ .set_int = __cal_record_instance_normal_set_int,
+ .set_double = __cal_record_instance_normal_set_double,
+ .set_lli = __cal_record_instance_normal_set_lli,
+ .set_caltime = __cal_record_instance_normal_set_caltime,
+ .add_child_record = NULL,
+ .remove_child_record = NULL,
+ .get_child_record_count = NULL,
+ .get_child_record_at_p = NULL,
+ .clone_child_record_list = NULL
};
static void __cal_record_instance_normal_struct_init(cal_instance_normal_s* record)
{
- memset(record,0,sizeof(cal_instance_normal_s));
+ memset(record,0,sizeof(cal_instance_normal_s));
- record->event_status = CALENDAR_EVENT_STATUS_NONE;
- record->calendar_id = DEFAULT_EVENT_CALENDAR_BOOK_ID;
- record->event_id = CAL_INVALID_ID;
+ record->event_status = CALENDAR_EVENT_STATUS_NONE;
+ record->calendar_id = DEFAULT_EVENT_CALENDAR_BOOK_ID;
+ record->event_id = CAL_INVALID_ID;
- record->busy_status = 2;
- record->summary = NULL;
- record->description = NULL;
- record->location= NULL;
+ record->busy_status = 2;
+ record->summary = NULL;
+ record->description = NULL;
+ record->location= NULL;
- record->latitude = 1000; // set default 1000 out of range(-180 ~ 180)
- record->longitude = 1000; // set default 1000 out of range(-180 ~ 180)
+ record->latitude = 1000; // set default 1000 out of range(-180 ~ 180)
+ record->longitude = 1000; // set default 1000 out of range(-180 ~ 180)
- return ;
+ return ;
}
static int __cal_record_instance_normal_create( calendar_record_h* out_record )
{
- cal_instance_normal_s *temp = NULL;
- int ret= CALENDAR_ERROR_NONE, type = 0;
+ cal_instance_normal_s *temp = NULL;
+ int ret= CALENDAR_ERROR_NONE;
- type = CAL_RECORD_TYPE_INSTANCE_NORMAL;
+ temp = (cal_instance_normal_s*)calloc(1,sizeof(cal_instance_normal_s));
+ retvm_if(NULL == temp, CALENDAR_ERROR_OUT_OF_MEMORY, "malloc(cal_instance_normal_s:sch) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
- temp = (cal_instance_normal_s*)calloc(1,sizeof(cal_instance_normal_s));
- retvm_if(NULL == temp, CALENDAR_ERROR_OUT_OF_MEMORY, "malloc(cal_instance_normal_s:sch) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
+ __cal_record_instance_normal_struct_init(temp);
- __cal_record_instance_normal_struct_init(temp);
+ *out_record = (calendar_record_h)temp;
- *out_record = (calendar_record_h)temp;
-
- return ret;
+ return ret;
}
static void __cal_record_instance_normal_struct_free(cal_instance_normal_s *record)
{
- CAL_FREE(record->summary);
- CAL_FREE(record->description);
- CAL_FREE(record->location);
+ CAL_FREE(record->summary);
+ CAL_FREE(record->description);
+ CAL_FREE(record->location);
+ CAL_FREE(record->sync_data1);
- CAL_FREE(record);
+ CAL_FREE(record);
}
static int __cal_record_instance_normal_destroy( calendar_record_h record, bool delete_child )
{
- cal_instance_normal_s *temp = (cal_instance_normal_s*)(record);
+ cal_instance_normal_s *temp = (cal_instance_normal_s*)(record);
- __cal_record_instance_normal_struct_free(temp);
+ __cal_record_instance_normal_struct_free(temp);
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_instance_normal_clone( calendar_record_h record, calendar_record_h* out_record )
{
- cal_instance_normal_s *out_data = NULL;
- cal_instance_normal_s *src_data = NULL;
-
- src_data = (cal_instance_normal_s*)(record);
-
- out_data = calloc(1, sizeof(cal_instance_normal_s));
- retvm_if(NULL == out_data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_instance_normal_s) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
-
- CAL_RECORD_COPY_COMMON(&(out_data->common), &(src_data->common));
-
- out_data->event_id = src_data->event_id;
- out_data->calendar_id = src_data->calendar_id;
- out_data->dtstart_type = src_data->dtstart_type;
- out_data->dtstart_utime = src_data->dtstart_utime;
- out_data->dtend_type = src_data->dtend_type;
- out_data->dtend_utime = src_data->dtend_utime;
- out_data->summary = SAFE_STRDUP(src_data->summary);
- out_data->description = SAFE_STRDUP(src_data->description);
- out_data->location = SAFE_STRDUP(src_data->location);
- out_data->busy_status = src_data->busy_status;
- out_data->event_status = src_data->event_status;
- out_data->priority = src_data->priority;
- out_data->sensitivity = src_data->sensitivity;
- out_data->has_rrule = src_data->has_rrule;
- out_data->latitude = src_data->latitude;
- out_data->longitude = src_data->longitude;
- out_data->has_alarm = src_data->has_alarm;
- out_data->original_event_id = src_data->original_event_id;
- out_data->last_mod = src_data->last_mod;
-
- *out_record = (calendar_record_h)out_data;
-
- return CALENDAR_ERROR_NONE;
+ cal_instance_normal_s *out_data = NULL;
+ cal_instance_normal_s *src_data = NULL;
+
+ src_data = (cal_instance_normal_s*)(record);
+
+ out_data = calloc(1, sizeof(cal_instance_normal_s));
+ retvm_if(NULL == out_data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_instance_normal_s) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
+
+ CAL_RECORD_COPY_COMMON(&(out_data->common), &(src_data->common));
+
+ out_data->event_id = src_data->event_id;
+ out_data->calendar_id = src_data->calendar_id;
+ out_data->start = src_data->start;
+ out_data->end = src_data->end;
+ out_data->summary = SAFE_STRDUP(src_data->summary);
+ out_data->description = SAFE_STRDUP(src_data->description);
+ out_data->location = SAFE_STRDUP(src_data->location);
+ out_data->busy_status = src_data->busy_status;
+ out_data->event_status = src_data->event_status;
+ out_data->priority = src_data->priority;
+ out_data->sensitivity = src_data->sensitivity;
+ out_data->has_rrule = src_data->has_rrule;
+ out_data->latitude = src_data->latitude;
+ out_data->longitude = src_data->longitude;
+ out_data->has_alarm = src_data->has_alarm;
+ out_data->original_event_id = src_data->original_event_id;
+ out_data->last_mod = src_data->last_mod;
+ out_data->sync_data1 = SAFE_STRDUP(src_data->sync_data1);
+
+ *out_record = (calendar_record_h)out_data;
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_instance_normal_get_str( calendar_record_h record, unsigned int property_id, char** out_str )
{
- cal_instance_normal_s *rec = (cal_instance_normal_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_INSTANCE_NORMAL_SUMMARY:
- *out_str = SAFE_STRDUP(rec->summary);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_DESCRIPTION:
- *out_str = SAFE_STRDUP(rec->description);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_LOCATION:
- *out_str = SAFE_STRDUP(rec->location);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_instance_normal_s *rec = (cal_instance_normal_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_NORMAL_SUMMARY:
+ *out_str = SAFE_STRDUP(rec->summary);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_DESCRIPTION:
+ *out_str = SAFE_STRDUP(rec->description);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_LOCATION:
+ *out_str = SAFE_STRDUP(rec->location);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_SYNC_DATA1:
+ *out_str = SAFE_STRDUP(rec->sync_data1);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_instance_normal_get_str_p( calendar_record_h record, unsigned int property_id, char** out_str )
{
- cal_instance_normal_s *rec = (cal_instance_normal_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_INSTANCE_NORMAL_SUMMARY:
- *out_str = (rec->summary);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_DESCRIPTION:
- *out_str = (rec->description);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_LOCATION:
- *out_str = (rec->location);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_instance_normal_s *rec = (cal_instance_normal_s*)(record);
+ switch( property_id )
+ {
+ case CAL_PROPERTY_INSTANCE_NORMAL_SUMMARY:
+ *out_str = (rec->summary);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_DESCRIPTION:
+ *out_str = (rec->description);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_LOCATION:
+ *out_str = (rec->location);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_SYNC_DATA1:
+ *out_str = (rec->sync_data1);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_instance_normal_get_int( calendar_record_h record, unsigned int property_id, int* out_value )
{
- cal_instance_normal_s *rec = (cal_instance_normal_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_INSTANCE_NORMAL_EVENT_ID:
- *out_value = (rec->event_id);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_CALENDAR_ID:
- *out_value = (rec->calendar_id);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_BUSY_STATUS:
- *out_value = (rec->busy_status);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_EVENT_STATUS:
- *out_value = (rec->event_status);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_PRIORITY:
- *out_value = (rec->priority);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_SENSITIVITY:
- *out_value = (rec->sensitivity);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_HAS_RRULE:
- *out_value = (rec->has_rrule);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_HAS_ALARM:
- *out_value = (rec->has_alarm);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_ORIGINAL_EVENT_ID:
- *out_value = (rec->original_event_id);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_instance_normal_s *rec = (cal_instance_normal_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_NORMAL_EVENT_ID:
+ *out_value = (rec->event_id);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_CALENDAR_ID:
+ *out_value = (rec->calendar_id);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_BUSY_STATUS:
+ *out_value = (rec->busy_status);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EVENT_STATUS:
+ *out_value = (rec->event_status);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_PRIORITY:
+ *out_value = (rec->priority);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_SENSITIVITY:
+ *out_value = (rec->sensitivity);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_HAS_RRULE:
+ *out_value = (rec->has_rrule);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_HAS_ALARM:
+ *out_value = (rec->has_alarm);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_ORIGINAL_EVENT_ID:
+ *out_value = (rec->original_event_id);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_instance_normal_get_double( calendar_record_h record, unsigned int property_id, double* out_value )
{
- cal_instance_normal_s *rec = (cal_instance_normal_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_INSTANCE_NORMAL_LATITUDE:
- *out_value = (rec->latitude);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_LONGITUDE:
- *out_value = (rec->longitude);
- break;
-
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_instance_normal_s *rec = (cal_instance_normal_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_NORMAL_LATITUDE:
+ *out_value = (rec->latitude);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_LONGITUDE:
+ *out_value = (rec->longitude);
+ break;
+
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_instance_normal_get_lli( calendar_record_h record, unsigned int property_id, long long int* out_value )
{
- cal_instance_normal_s *rec = (cal_instance_normal_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_INSTANCE_NORMAL_LAST_MODIFIED_TIME:
- *out_value = (rec->last_mod);
- break;
- default:
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_instance_normal_s *rec = (cal_instance_normal_s*)(record);
+ switch( property_id )
+ {
+ case CAL_PROPERTY_INSTANCE_NORMAL_LAST_MODIFIED_TIME:
+ *out_value = (rec->last_mod);
+ break;
+ default:
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_instance_normal_get_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s* out_value )
{
- cal_instance_normal_s *rec = (cal_instance_normal_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_INSTANCE_NORMAL_START:
- CAL_CALTIME_SET_UTIME(*out_value,(rec->dtstart_utime));
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_END:
- CAL_CALTIME_SET_UTIME(*out_value,(rec->dtend_utime));
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_instance_normal_s *rec = (cal_instance_normal_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_NORMAL_START:
+ *out_value = rec->start;
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_END:
+ *out_value = rec->end;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_instance_normal_set_str( calendar_record_h record, unsigned int property_id, const char* value )
{
- cal_instance_normal_s *rec = (cal_instance_normal_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_INSTANCE_NORMAL_SUMMARY:
- CAL_FREE(rec->summary);
- rec->summary = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_DESCRIPTION:
- CAL_FREE(rec->description);
- rec->description = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_LOCATION:
- CAL_FREE(rec->location);
- rec->location = SAFE_STRDUP(value);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_instance_normal_s *rec = (cal_instance_normal_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_NORMAL_SUMMARY:
+ CAL_FREE(rec->summary);
+ rec->summary = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_DESCRIPTION:
+ CAL_FREE(rec->description);
+ rec->description = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_LOCATION:
+ CAL_FREE(rec->location);
+ rec->location = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_SYNC_DATA1:
+ CAL_FREE(rec->sync_data1);
+ rec->sync_data1 = SAFE_STRDUP(value);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_instance_normal_set_int( calendar_record_h record, unsigned int property_id, int value )
{
- cal_instance_normal_s *rec = (cal_instance_normal_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_INSTANCE_NORMAL_EVENT_ID:
- (rec->event_id) = value;
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_CALENDAR_ID:
- (rec->calendar_id) = value;
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_BUSY_STATUS:
- (rec->busy_status) = value;
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_EVENT_STATUS:
- (rec->event_status) = value;
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_PRIORITY:
- (rec->priority) = value;
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_SENSITIVITY:
- (rec->sensitivity) = value;
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_HAS_RRULE:
- (rec->has_rrule) = value;
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_HAS_ALARM:
- (rec->has_alarm) = value;
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_ORIGINAL_EVENT_ID:
- (rec->original_event_id) = value;
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_instance_normal_s *rec = (cal_instance_normal_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_NORMAL_EVENT_ID:
+ (rec->event_id) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_CALENDAR_ID:
+ (rec->calendar_id) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_BUSY_STATUS:
+ (rec->busy_status) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EVENT_STATUS:
+ (rec->event_status) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_PRIORITY:
+ (rec->priority) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_SENSITIVITY:
+ (rec->sensitivity) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_HAS_RRULE:
+ (rec->has_rrule) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_HAS_ALARM:
+ (rec->has_alarm) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_ORIGINAL_EVENT_ID:
+ (rec->original_event_id) = value;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_instance_normal_set_double( calendar_record_h record, unsigned int property_id, double value )
{
- cal_instance_normal_s *rec = (cal_instance_normal_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_INSTANCE_NORMAL_LATITUDE:
- (rec->latitude) = value;
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_LONGITUDE:
- (rec->longitude) = value;
- break;
-
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_instance_normal_s *rec = (cal_instance_normal_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_NORMAL_LATITUDE:
+ (rec->latitude) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_LONGITUDE:
+ (rec->longitude) = value;
+ break;
+
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_instance_normal_set_lli( calendar_record_h record, unsigned int property_id, long long int value )
{
- cal_instance_normal_s *rec = (cal_instance_normal_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_INSTANCE_NORMAL_LAST_MODIFIED_TIME:
- (rec->last_mod) = value;
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_instance_normal_s *rec = (cal_instance_normal_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_NORMAL_LAST_MODIFIED_TIME:
+ (rec->last_mod) = value;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_instance_normal_set_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s value )
{
- cal_instance_normal_s *rec = (cal_instance_normal_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_INSTANCE_NORMAL_START:
- (rec->dtstart_type) = CALENDAR_TIME_UTIME;//value.type;
- (rec->dtstart_utime) = value.time.utime;
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_END:
- (rec->dtend_type) = CALENDAR_TIME_UTIME;//value.type;
- (rec->dtend_utime) = value.time.utime;
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_instance_normal_s *rec = (cal_instance_normal_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_NORMAL_START:
+ rec->start = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_END:
+ rec->end = value;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
--- /dev/null
+/*
+ * Calendar Service
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <stdlib.h> //calloc
+#include <stdbool.h> //bool
+#include <string.h>
+
+#include "cal_internal.h"
+#include "cal_typedef.h"
+#include "cal_view.h"
+
+#include "cal_record.h"
+
+static int __cal_record_instance_normal_extended_create( calendar_record_h* out_record );
+static int __cal_record_instance_normal_extended_destroy( calendar_record_h record, bool delete_child );
+static int __cal_record_instance_normal_extended_clone( calendar_record_h record, calendar_record_h* out_record );
+static int __cal_record_instance_normal_extended_get_str( calendar_record_h record, unsigned int property_id, char** out_str );
+static int __cal_record_instance_normal_extended_get_str_p( calendar_record_h record, unsigned int property_id, char** out_str );
+static int __cal_record_instance_normal_extended_get_int( calendar_record_h record, unsigned int property_id, int* out_value );
+static int __cal_record_instance_normal_extended_get_double( calendar_record_h record, unsigned int property_id, double* out_value );
+static int __cal_record_instance_normal_extended_get_lli( calendar_record_h record, unsigned int property_id, long long int* out_value );
+static int __cal_record_instance_normal_extended_get_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s* out_value );
+static int __cal_record_instance_normal_extended_set_str( calendar_record_h record, unsigned int property_id, const char* value );
+static int __cal_record_instance_normal_extended_set_int( calendar_record_h record, unsigned int property_id, int value );
+static int __cal_record_instance_normal_extended_set_double( calendar_record_h record, unsigned int property_id, double value );
+static int __cal_record_instance_normal_extended_set_lli( calendar_record_h record, unsigned int property_id, long long int value );
+static int __cal_record_instance_normal_extended_set_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s value );
+
+cal_record_plugin_cb_s _cal_record_instance_normal_extended_plugin_cb = {
+ .create = __cal_record_instance_normal_extended_create,
+ .destroy = __cal_record_instance_normal_extended_destroy,
+ .clone = __cal_record_instance_normal_extended_clone,
+ .get_str = __cal_record_instance_normal_extended_get_str,
+ .get_str_p = __cal_record_instance_normal_extended_get_str_p,
+ .get_int = __cal_record_instance_normal_extended_get_int,
+ .get_double = __cal_record_instance_normal_extended_get_double,
+ .get_lli = __cal_record_instance_normal_extended_get_lli,
+ .get_caltime = __cal_record_instance_normal_extended_get_caltime,
+ .set_str = __cal_record_instance_normal_extended_set_str,
+ .set_int = __cal_record_instance_normal_extended_set_int,
+ .set_double = __cal_record_instance_normal_extended_set_double,
+ .set_lli = __cal_record_instance_normal_extended_set_lli,
+ .set_caltime = __cal_record_instance_normal_extended_set_caltime,
+ .add_child_record = NULL,
+ .remove_child_record = NULL,
+ .get_child_record_count = NULL,
+ .get_child_record_at_p = NULL,
+ .clone_child_record_list = NULL
+};
+
+static void __cal_record_instance_normal_extended_struct_init(cal_instance_normal_extended_s* record)
+{
+ memset(record,0,sizeof(cal_instance_normal_extended_s));
+
+ record->event_status = CALENDAR_EVENT_STATUS_NONE;
+ record->calendar_id = DEFAULT_EVENT_CALENDAR_BOOK_ID;
+ record->event_id = CAL_INVALID_ID;
+
+ record->busy_status = 2;
+ record->summary = NULL;
+ record->description = NULL;
+ record->location= NULL;
+
+ record->latitude = 1000; // set default 1000 out of range(-180 ~ 180)
+ record->longitude = 1000; // set default 1000 out of range(-180 ~ 180)
+
+ return ;
+}
+
+static int __cal_record_instance_normal_extended_create( calendar_record_h* out_record )
+{
+ cal_instance_normal_extended_s *temp = NULL;
+ int ret= CALENDAR_ERROR_NONE;
+
+ temp = (cal_instance_normal_extended_s*)calloc(1,sizeof(cal_instance_normal_extended_s));
+ retvm_if(NULL == temp, CALENDAR_ERROR_OUT_OF_MEMORY, "malloc(cal_instance_normal_extended_s:sch) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
+
+ __cal_record_instance_normal_extended_struct_init(temp);
+
+ *out_record = (calendar_record_h)temp;
+
+ return ret;
+}
+
+static void __cal_record_instance_normal_extended_struct_free(cal_instance_normal_extended_s *record)
+{
+ CAL_FREE(record->summary);
+ CAL_FREE(record->description);
+ CAL_FREE(record->location);
+ CAL_FREE(record->organizer_name);
+ CAL_FREE(record->categories);
+ CAL_FREE(record->sync_data1);
+ CAL_FREE(record->sync_data2);
+ CAL_FREE(record->sync_data3);
+ CAL_FREE(record->sync_data4);
+
+ CAL_FREE(record);
+}
+
+static int __cal_record_instance_normal_extended_destroy( calendar_record_h record, bool delete_child )
+{
+ cal_instance_normal_extended_s *temp = (cal_instance_normal_extended_s*)(record);
+
+ __cal_record_instance_normal_extended_struct_free(temp);
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_record_instance_normal_extended_clone( calendar_record_h record, calendar_record_h* out_record )
+{
+ cal_instance_normal_extended_s *out_data = NULL;
+ cal_instance_normal_extended_s *src_data = NULL;
+
+ src_data = (cal_instance_normal_extended_s*)(record);
+
+ out_data = calloc(1, sizeof(cal_instance_normal_extended_s));
+ retvm_if(NULL == out_data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_instance_normal_extended_s) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
+
+ CAL_RECORD_COPY_COMMON(&(out_data->common), &(src_data->common));
+
+ out_data->event_id = src_data->event_id;
+ out_data->calendar_id = src_data->calendar_id;
+ out_data->start = src_data->start;
+ out_data->end = src_data->end;
+ out_data->summary = SAFE_STRDUP(src_data->summary);
+ out_data->description = SAFE_STRDUP(src_data->description);
+ out_data->location = SAFE_STRDUP(src_data->location);
+ out_data->busy_status = src_data->busy_status;
+ out_data->event_status = src_data->event_status;
+ out_data->priority = src_data->priority;
+ out_data->sensitivity = src_data->sensitivity;
+ out_data->has_rrule = src_data->has_rrule;
+ out_data->latitude = src_data->latitude;
+ out_data->longitude = src_data->longitude;
+ out_data->has_alarm = src_data->has_alarm;
+ out_data->original_event_id = src_data->original_event_id;
+ out_data->last_mod = src_data->last_mod;
+ out_data->organizer_name = SAFE_STRDUP(src_data->organizer_name);
+ out_data->categories = SAFE_STRDUP(src_data->categories);
+ out_data->sync_data1 = SAFE_STRDUP(src_data->sync_data1);
+ out_data->sync_data2 = SAFE_STRDUP(src_data->sync_data2);
+ out_data->sync_data3 = SAFE_STRDUP(src_data->sync_data3);
+ out_data->sync_data4 = SAFE_STRDUP(src_data->sync_data4);
+
+ *out_record = (calendar_record_h)out_data;
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_record_instance_normal_extended_get_str( calendar_record_h record, unsigned int property_id, char** out_str )
+{
+ cal_instance_normal_extended_s *rec = (cal_instance_normal_extended_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SUMMARY:
+ *out_str = SAFE_STRDUP(rec->summary);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_DESCRIPTION:
+ *out_str = SAFE_STRDUP(rec->description);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LOCATION:
+ *out_str = SAFE_STRDUP(rec->location);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA1:
+ *out_str = SAFE_STRDUP(rec->sync_data1);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_ORGANIZER_NAME:
+ *out_str = SAFE_STRDUP(rec->organizer_name);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_CATEGORIES:
+ *out_str = SAFE_STRDUP(rec->categories);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA2:
+ *out_str = SAFE_STRDUP(rec->sync_data2);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA3:
+ *out_str = SAFE_STRDUP(rec->sync_data3);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA4:
+ *out_str = SAFE_STRDUP(rec->sync_data4);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_record_instance_normal_extended_get_str_p( calendar_record_h record, unsigned int property_id, char** out_str )
+{
+ cal_instance_normal_extended_s *rec = (cal_instance_normal_extended_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SUMMARY:
+ *out_str = (rec->summary);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_DESCRIPTION:
+ *out_str = (rec->description);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LOCATION:
+ *out_str = (rec->location);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA1:
+ *out_str = (rec->sync_data1);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_ORGANIZER_NAME:
+ *out_str = (rec->organizer_name);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_CATEGORIES:
+ *out_str = (rec->categories);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA2:
+ *out_str = (rec->sync_data2);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA3:
+ *out_str = (rec->sync_data3);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA4:
+ *out_str = (rec->sync_data4);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_record_instance_normal_extended_get_int( calendar_record_h record, unsigned int property_id, int* out_value )
+{
+ cal_instance_normal_extended_s *rec = (cal_instance_normal_extended_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_EVENT_ID:
+ *out_value = (rec->event_id);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_CALENDAR_ID:
+ *out_value = (rec->calendar_id);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_BUSY_STATUS:
+ *out_value = (rec->busy_status);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_EVENT_STATUS:
+ *out_value = (rec->event_status);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_PRIORITY:
+ *out_value = (rec->priority);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SENSITIVITY:
+ *out_value = (rec->sensitivity);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_HAS_RRULE:
+ *out_value = (rec->has_rrule);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_HAS_ALARM:
+ *out_value = (rec->has_alarm);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_ORIGINAL_EVENT_ID:
+ *out_value = (rec->original_event_id);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_HAS_ATTENDEE:
+ *out_value = (rec->has_attendee);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_record_instance_normal_extended_get_double( calendar_record_h record, unsigned int property_id, double* out_value )
+{
+ cal_instance_normal_extended_s *rec = (cal_instance_normal_extended_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LATITUDE:
+ *out_value = (rec->latitude);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LONGITUDE:
+ *out_value = (rec->longitude);
+ break;
+
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_record_instance_normal_extended_get_lli( calendar_record_h record, unsigned int property_id, long long int* out_value )
+{
+ cal_instance_normal_extended_s *rec = (cal_instance_normal_extended_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LAST_MODIFIED_TIME:
+ *out_value = (rec->last_mod);
+ break;
+ default:
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_record_instance_normal_extended_get_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s* out_value )
+{
+ cal_instance_normal_extended_s *rec = (cal_instance_normal_extended_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_START:
+ *out_value = rec->start;
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_END:
+ *out_value = rec->end;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_record_instance_normal_extended_set_str( calendar_record_h record, unsigned int property_id, const char* value )
+{
+ cal_instance_normal_extended_s *rec = (cal_instance_normal_extended_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SUMMARY:
+ CAL_FREE(rec->summary);
+ rec->summary = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_DESCRIPTION:
+ CAL_FREE(rec->description);
+ rec->description = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LOCATION:
+ CAL_FREE(rec->location);
+ rec->location = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA1:
+ CAL_FREE(rec->sync_data1);
+ rec->sync_data1 = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_ORGANIZER_NAME:
+ CAL_FREE(rec->organizer_name);
+ rec->organizer_name = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_CATEGORIES:
+ CAL_FREE(rec->categories);
+ rec->categories = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA2:
+ CAL_FREE(rec->sync_data2);
+ rec->sync_data2 = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA3:
+ CAL_FREE(rec->sync_data3);
+ rec->sync_data3 = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA4:
+ CAL_FREE(rec->sync_data4);
+ rec->sync_data4 = SAFE_STRDUP(value);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_record_instance_normal_extended_set_int( calendar_record_h record, unsigned int property_id, int value )
+{
+ cal_instance_normal_extended_s *rec = (cal_instance_normal_extended_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_EVENT_ID:
+ (rec->event_id) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_CALENDAR_ID:
+ (rec->calendar_id) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_BUSY_STATUS:
+ (rec->busy_status) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_EVENT_STATUS:
+ (rec->event_status) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_PRIORITY:
+ (rec->priority) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SENSITIVITY:
+ (rec->sensitivity) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_HAS_RRULE:
+ (rec->has_rrule) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_HAS_ALARM:
+ (rec->has_alarm) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_ORIGINAL_EVENT_ID:
+ (rec->original_event_id) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_HAS_ATTENDEE:
+ (rec->has_attendee) = value;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_record_instance_normal_extended_set_double( calendar_record_h record, unsigned int property_id, double value )
+{
+ cal_instance_normal_extended_s *rec = (cal_instance_normal_extended_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LATITUDE:
+ (rec->latitude) = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LONGITUDE:
+ (rec->longitude) = value;
+ break;
+
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_record_instance_normal_extended_set_lli( calendar_record_h record, unsigned int property_id, long long int value )
+{
+ cal_instance_normal_extended_s *rec = (cal_instance_normal_extended_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LAST_MODIFIED_TIME:
+ (rec->last_mod) = value;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_record_instance_normal_extended_set_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s value )
+{
+ cal_instance_normal_extended_s *rec = (cal_instance_normal_extended_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_START:
+ rec->start = value;
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_END:
+ rec->end = value;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
static int __cal_record_search_set_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s value );
cal_record_plugin_cb_s _cal_record_search_plugin_cb = {
- .create = __cal_record_search_create,
- .destroy = __cal_record_search_destroy,
- .clone = __cal_record_search_clone,
- .get_str = __cal_record_search_get_str,
- .get_str_p = __cal_record_search_get_str_p,
- .get_int = __cal_record_search_get_int,
- .get_double = __cal_record_search_get_double,
- .get_lli = __cal_record_search_get_lli,
- .get_caltime = __cal_record_search_get_caltime,
- .set_str = __cal_record_search_set_str,
- .set_int = __cal_record_search_set_int,
- .set_double = __cal_record_search_set_double,
- .set_lli = __cal_record_search_set_lli,
- .set_caltime = __cal_record_search_set_caltime,
- .add_child_record = NULL,
- .remove_child_record = NULL,
- .get_child_record_count = NULL,
- .get_child_record_at_p = NULL,
- .clone_child_record_list = NULL
+ .create = __cal_record_search_create,
+ .destroy = __cal_record_search_destroy,
+ .clone = __cal_record_search_clone,
+ .get_str = __cal_record_search_get_str,
+ .get_str_p = __cal_record_search_get_str_p,
+ .get_int = __cal_record_search_get_int,
+ .get_double = __cal_record_search_get_double,
+ .get_lli = __cal_record_search_get_lli,
+ .get_caltime = __cal_record_search_get_caltime,
+ .set_str = __cal_record_search_set_str,
+ .set_int = __cal_record_search_set_int,
+ .set_double = __cal_record_search_set_double,
+ .set_lli = __cal_record_search_set_lli,
+ .set_caltime = __cal_record_search_set_caltime,
+ .add_child_record = NULL,
+ .remove_child_record = NULL,
+ .get_child_record_count = NULL,
+ .get_child_record_at_p = NULL,
+ .clone_child_record_list = NULL
};
static int __cal_record_search_create( calendar_record_h* out_record )
{
- cal_search_s *temp = NULL;
- int ret= CALENDAR_ERROR_NONE;
- cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
+ cal_search_s *temp = NULL;
+ int ret= CALENDAR_ERROR_NONE;
- type = CAL_RECORD_TYPE_SEARCH;
+ temp = (cal_search_s*)calloc(1, sizeof(cal_search_s));
+ retvm_if(NULL == temp, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_search_s:sch) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
- temp = (cal_search_s*)calloc(1, sizeof(cal_search_s));
- retvm_if(NULL == temp, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_search_s:sch) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
+ *out_record = (calendar_record_h)temp;
- *out_record = (calendar_record_h)temp;
-
- return ret;
+ return ret;
}
static int __cal_record_search_destroy( calendar_record_h record, bool delete_child )
{
- int ret = CALENDAR_ERROR_NONE;
- GSList *cursor;
+ int ret = CALENDAR_ERROR_NONE;
+ GSList *cursor;
- cal_search_s *temp = (cal_search_s*)(record);
+ cal_search_s *temp = (cal_search_s*)(record);
- for(cursor = temp->values;cursor;cursor=cursor->next)
- {
- cal_search_value_s *data = cursor->data;
- if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_STR) == true)
- {
- CAL_FREE(data->value.s);
- }
- CAL_FREE(data);
- }
+ for(cursor = temp->values;cursor;cursor=cursor->next)
+ {
+ cal_search_value_s *data = cursor->data;
+ if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_STR) == true)
+ {
+ CAL_FREE(data->value.s);
+ }
+ CAL_FREE(data);
+ }
- g_slist_free(temp->values);
- CAL_FREE(temp);
+ g_slist_free(temp->values);
+ CAL_FREE(temp);
- return ret;
+ return ret;
}
static int __cal_record_search_clone( calendar_record_h record, calendar_record_h* out_record )
{
- int ret = CALENDAR_ERROR_NONE;
- cal_search_s *out_data = NULL;
- cal_search_s *src_data = NULL;
- GSList *cursor;
-
- src_data = (cal_search_s*)(record);
-
- out_data = calloc(1, sizeof(cal_search_s));
- retvm_if(NULL == out_data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_search_s) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
-
- CAL_RECORD_COPY_COMMON(&(out_data->common), &(src_data->common));
-
- for(cursor = src_data->values;cursor;cursor=cursor->next)
- {
- cal_search_value_s *src = cursor->data;
- cal_search_value_s *dest = calloc(1, sizeof(cal_search_value_s));
- if (dest == NULL)
- {
- CAL_FREE(out_data);
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- dest->property_id = src->property_id;
- if (CAL_PROPERTY_CHECK_DATA_TYPE(src->property_id, CAL_PROPERTY_DATA_TYPE_STR) == true)
- {
- dest->value.s = SAFE_STRDUP(src->value.s);
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(src->property_id, CAL_PROPERTY_DATA_TYPE_INT) == true)
- {
- dest->value.i = src->value.i;
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(src->property_id, CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
- {
- dest->value.d = src->value.d;
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(src->property_id, CAL_PROPERTY_DATA_TYPE_LLI) == true)
- {
- dest->value.lli = src->value.lli;
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(src->property_id, CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
- {
- dest->value.caltime = src->value.caltime;
- }
- else
- {
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",src->property_id);
- CAL_FREE(out_data);
- CAL_FREE(dest);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- out_data->values = g_slist_append(out_data->values, dest);
- }
-
- *out_record = (calendar_record_h)out_data;
-
- return CALENDAR_ERROR_NONE;
+ cal_search_s *out_data = NULL;
+ cal_search_s *src_data = NULL;
+ GSList *cursor;
+
+ src_data = (cal_search_s*)(record);
+
+ out_data = calloc(1, sizeof(cal_search_s));
+ retvm_if(NULL == out_data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_search_s) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
+
+ CAL_RECORD_COPY_COMMON(&(out_data->common), &(src_data->common));
+
+ for(cursor = src_data->values;cursor;cursor=cursor->next)
+ {
+ cal_search_value_s *src = cursor->data;
+ cal_search_value_s *dest = calloc(1, sizeof(cal_search_value_s));
+ if (dest == NULL)
+ {
+ CAL_FREE(out_data);
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+ dest->property_id = src->property_id;
+ if (CAL_PROPERTY_CHECK_DATA_TYPE(src->property_id, CAL_PROPERTY_DATA_TYPE_STR) == true)
+ {
+ dest->value.s = SAFE_STRDUP(src->value.s);
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(src->property_id, CAL_PROPERTY_DATA_TYPE_INT) == true)
+ {
+ dest->value.i = src->value.i;
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(src->property_id, CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
+ {
+ dest->value.d = src->value.d;
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(src->property_id, CAL_PROPERTY_DATA_TYPE_LLI) == true)
+ {
+ dest->value.lli = src->value.lli;
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(src->property_id, CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
+ {
+ dest->value.caltime = src->value.caltime;
+ }
+ else
+ {
+// ERR("invalid parameter (property:%d)",src->property_id);
+ CAL_FREE(dest);
+ continue;
+ }
+
+ out_data->values = g_slist_append(out_data->values, dest);
+ }
+
+ *out_record = (calendar_record_h)out_data;
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_search_get_str( calendar_record_h record, unsigned int property_id, char** out_str )
{
- cal_search_s *rec = (cal_search_s*)(record);
- GSList *cursor;
-
- for(cursor = rec->values;cursor;cursor=cursor->next)
- {
- cal_search_value_s *data = cursor->data;
- if (data->property_id == property_id)
- {
- if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_STR) == true)
- {
- *out_str = SAFE_STRDUP(data->value.s);
- }
- else
- {
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",data->property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_search_s *rec = (cal_search_s*)(record);
+ GSList *cursor;
+
+ for(cursor = rec->values;cursor;cursor=cursor->next)
+ {
+ cal_search_value_s *data = cursor->data;
+ if (data->property_id == property_id)
+ {
+ if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_STR) == true)
+ {
+ *out_str = SAFE_STRDUP(data->value.s);
+ break;
+ }
+ else
+ {
+ ERR("invalid parameter (property:%d)",data->property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_search_get_str_p( calendar_record_h record, unsigned int property_id, char** out_str )
{
- cal_search_s *rec = (cal_search_s*)(record);
- GSList *cursor;
-
- for(cursor = rec->values;cursor;cursor=cursor->next)
- {
- cal_search_value_s *data = cursor->data;
- if (data->property_id == property_id)
- {
- if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_STR) == true)
- {
- *out_str = (data->value.s);
- }
- else
- {
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",data->property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_search_s *rec = (cal_search_s*)(record);
+ GSList *cursor;
+
+ for(cursor = rec->values;cursor;cursor=cursor->next)
+ {
+ cal_search_value_s *data = cursor->data;
+ if (data->property_id == property_id)
+ {
+ if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_STR) == true)
+ {
+ *out_str = (data->value.s);
+ break;
+ }
+ else
+ {
+ ERR("invalid parameter (property:%d)",data->property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_search_get_int( calendar_record_h record, unsigned int property_id, int* out_value )
{
- cal_search_s *rec = (cal_search_s*)(record);
- GSList *cursor;
-
- for(cursor = rec->values;cursor;cursor=cursor->next)
- {
- cal_search_value_s *data = cursor->data;
- if (data->property_id == property_id)
- {
- if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_INT) == true)
- {
- *out_value = (data->value.i);
- }
- else
- {
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",data->property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_search_s *rec = (cal_search_s*)(record);
+ GSList *cursor;
+
+ for(cursor = rec->values;cursor;cursor=cursor->next)
+ {
+ cal_search_value_s *data = cursor->data;
+ if (data->property_id == property_id)
+ {
+ if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_INT) == true)
+ {
+ *out_value = (data->value.i);
+ break;
+ }
+ else
+ {
+ ERR("invalid parameter (property:%d)",data->property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_search_get_double( calendar_record_h record, unsigned int property_id, double* out_value )
{
- cal_search_s *rec = (cal_search_s*)(record);
- GSList *cursor;
-
- for(cursor = rec->values;cursor;cursor=cursor->next)
- {
- cal_search_value_s *data = cursor->data;
- if (data->property_id == property_id)
- {
- if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
- {
- *out_value = (data->value.d);
- }
- else
- {
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",data->property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_search_s *rec = (cal_search_s*)(record);
+ GSList *cursor;
+
+ for(cursor = rec->values;cursor;cursor=cursor->next)
+ {
+ cal_search_value_s *data = cursor->data;
+ if (data->property_id == property_id)
+ {
+ if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
+ {
+ *out_value = (data->value.d);
+ break;
+ }
+ else
+ {
+ ERR("invalid parameter (property:%d)",data->property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_search_get_lli( calendar_record_h record, unsigned int property_id, long long int* out_value )
{
- cal_search_s *rec = (cal_search_s*)(record);
- GSList *cursor;
-
- for(cursor = rec->values;cursor;cursor=cursor->next)
- {
- cal_search_value_s *data = cursor->data;
- if (data->property_id == property_id)
- {
- if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_LLI) == true)
- {
- *out_value = (data->value.lli);
- }
- else
- {
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",data->property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_search_s *rec = (cal_search_s*)(record);
+ GSList *cursor;
+
+ for(cursor = rec->values;cursor;cursor=cursor->next)
+ {
+ cal_search_value_s *data = cursor->data;
+ if (data->property_id == property_id)
+ {
+ if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_LLI) == true)
+ {
+ *out_value = (data->value.lli);
+ break;
+ }
+ else
+ {
+ ERR("invalid parameter (property:%d)",data->property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_search_get_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s* out_value )
{
- cal_search_s *rec = (cal_search_s*)(record);
- GSList *cursor;
-
- for(cursor = rec->values;cursor;cursor=cursor->next)
- {
- cal_search_value_s *data = cursor->data;
- if (data->property_id == property_id)
- {
- if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
- {
- *out_value = (data->value.caltime);
- }
- else
- {
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",data->property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_search_s *rec = (cal_search_s*)(record);
+ GSList *cursor;
+
+ for(cursor = rec->values;cursor;cursor=cursor->next)
+ {
+ cal_search_value_s *data = cursor->data;
+ if (data->property_id == property_id)
+ {
+ if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
+ {
+ *out_value = (data->value.caltime);
+ break;
+ }
+ else
+ {
+ ERR("invalid parameter (property:%d)",data->property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_search_set_str( calendar_record_h record, unsigned int property_id, const char* value )
{
- cal_search_s *rec = (cal_search_s*)(record);
- GSList *cursor;
- cal_search_value_s *data = NULL;
-
- for(cursor = rec->values;cursor;cursor=cursor->next)
- {
- data = cursor->data;
- if (data->property_id == property_id)
- {
- if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_STR) == true)
- {
- CAL_FREE(data->value.s);
- (data->value.s) = SAFE_STRDUP(value);
- return CALENDAR_ERROR_NONE;
- }
- else
- {
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",data->property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- }
-
- data = calloc(1, sizeof(cal_search_value_s));
- retvm_if(NULL == data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_search_s) Failed");
- data->property_id = property_id;
- data->value.s = SAFE_STRDUP(value);
- rec->values = g_slist_append(rec->values, data);
-
- return CALENDAR_ERROR_NONE;
+ cal_search_s *rec = (cal_search_s*)(record);
+ GSList *cursor;
+ cal_search_value_s *data = NULL;
+
+ for(cursor = rec->values;cursor;cursor=cursor->next)
+ {
+ data = cursor->data;
+ if (data->property_id == property_id)
+ {
+ if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_STR) == true)
+ {
+ CAL_FREE(data->value.s);
+ (data->value.s) = SAFE_STRDUP(value);
+ return CALENDAR_ERROR_NONE;
+ }
+ else
+ {
+ ERR("invalid parameter (property:%d)",data->property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ }
+
+ data = calloc(1, sizeof(cal_search_value_s));
+ retvm_if(NULL == data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_search_s) Failed");
+ data->property_id = property_id;
+ data->value.s = SAFE_STRDUP(value);
+ rec->values = g_slist_append(rec->values, data);
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_search_set_int( calendar_record_h record, unsigned int property_id, int value )
{
- cal_search_s *rec = (cal_search_s*)(record);
- GSList *cursor;
- cal_search_value_s *data = NULL;
-
- for(cursor = rec->values;cursor;cursor=cursor->next)
- {
- data = cursor->data;
- if (data->property_id == property_id)
- {
- if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_INT) == true)
- {
- (data->value.i) = value;
- return CALENDAR_ERROR_NONE;
- }
- else
- {
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",data->property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- }
-
- data = calloc(1, sizeof(cal_search_value_s));
- retvm_if(NULL == data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_search_s) Failed");
- data->property_id = property_id;
- (data->value.i) = value;
- rec->values = g_slist_append(rec->values, data);
-
- return CALENDAR_ERROR_NONE;
+ cal_search_s *rec = (cal_search_s*)(record);
+ GSList *cursor;
+ cal_search_value_s *data = NULL;
+
+ for(cursor = rec->values;cursor;cursor=cursor->next)
+ {
+ data = cursor->data;
+ if (data->property_id == property_id)
+ {
+ if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_INT) == true)
+ {
+ (data->value.i) = value;
+ return CALENDAR_ERROR_NONE;
+ }
+ else
+ {
+ ERR("invalid parameter (property:%d)",data->property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ }
+
+ data = calloc(1, sizeof(cal_search_value_s));
+ retvm_if(NULL == data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_search_s) Failed");
+ data->property_id = property_id;
+ (data->value.i) = value;
+ rec->values = g_slist_append(rec->values, data);
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_search_set_double( calendar_record_h record, unsigned int property_id, double value )
{
- cal_search_s *rec = (cal_search_s*)(record);
- GSList *cursor;
- cal_search_value_s *data = NULL;
-
- for(cursor = rec->values;cursor;cursor=cursor->next)
- {
- data = cursor->data;
- if (data->property_id == property_id)
- {
- if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
- {
- (data->value.d) = value;
- return CALENDAR_ERROR_NONE;
- }
- else
- {
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",data->property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- }
-
- data = calloc(1, sizeof(cal_search_value_s));
- retvm_if(NULL == data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_search_s) Failed");
- data->property_id = property_id;
- (data->value.d) = value;
- rec->values = g_slist_append(rec->values, data);
-
- return CALENDAR_ERROR_NONE;
+ cal_search_s *rec = (cal_search_s*)(record);
+ GSList *cursor;
+ cal_search_value_s *data = NULL;
+
+ for(cursor = rec->values;cursor;cursor=cursor->next)
+ {
+ data = cursor->data;
+ if (data->property_id == property_id)
+ {
+ if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
+ {
+ (data->value.d) = value;
+ return CALENDAR_ERROR_NONE;
+ }
+ else
+ {
+ ERR("invalid parameter (property:%d)",data->property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ }
+
+ data = calloc(1, sizeof(cal_search_value_s));
+ retvm_if(NULL == data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_search_s) Failed");
+ data->property_id = property_id;
+ (data->value.d) = value;
+ rec->values = g_slist_append(rec->values, data);
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_search_set_lli( calendar_record_h record, unsigned int property_id, long long int value )
{
- cal_search_s *rec = (cal_search_s*)(record);
- GSList *cursor;
- cal_search_value_s *data = NULL;
-
- for(cursor = rec->values;cursor;cursor=cursor->next)
- {
- data = cursor->data;
- if (data->property_id == property_id)
- {
- if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_LLI) == true)
- {
- (data->value.lli) = value;
- return CALENDAR_ERROR_NONE;
- }
- else
- {
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",data->property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- }
-
- data = calloc(1, sizeof(cal_search_value_s));
- retvm_if(NULL == data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_search_s) Failed");
- data->property_id = property_id;
- (data->value.lli) = value;
- rec->values = g_slist_append(rec->values, data);
-
- return CALENDAR_ERROR_NONE;
+ cal_search_s *rec = (cal_search_s*)(record);
+ GSList *cursor;
+ cal_search_value_s *data = NULL;
+
+ for(cursor = rec->values;cursor;cursor=cursor->next)
+ {
+ data = cursor->data;
+ if (data->property_id == property_id)
+ {
+ if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_LLI) == true)
+ {
+ (data->value.lli) = value;
+ return CALENDAR_ERROR_NONE;
+ }
+ else
+ {
+ ERR("invalid parameter (property:%d)",data->property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ }
+
+ data = calloc(1, sizeof(cal_search_value_s));
+ retvm_if(NULL == data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_search_s) Failed");
+ data->property_id = property_id;
+ (data->value.lli) = value;
+ rec->values = g_slist_append(rec->values, data);
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_search_set_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s value )
{
- cal_search_s *rec = (cal_search_s*)(record);
- GSList *cursor;
- cal_search_value_s *data = NULL;
-
- for(cursor = rec->values;cursor;cursor=cursor->next)
- {
- data = cursor->data;
- if (data->property_id == property_id)
- {
- if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
- {
- (data->value.caltime) = value;
- return CALENDAR_ERROR_NONE;
- }
- else
- {
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",data->property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- }
-
- data = calloc(1, sizeof(cal_search_value_s));
- retvm_if(NULL == data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_search_s) Failed");
- data->property_id = property_id;
- (data->value.caltime) = value;
- rec->values = g_slist_append(rec->values, data);
-
- return CALENDAR_ERROR_NONE;
+ cal_search_s *rec = (cal_search_s*)(record);
+ GSList *cursor;
+ cal_search_value_s *data = NULL;
+
+ for(cursor = rec->values;cursor;cursor=cursor->next)
+ {
+ data = cursor->data;
+ if (data->property_id == property_id)
+ {
+ if (CAL_PROPERTY_CHECK_DATA_TYPE(data->property_id, CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
+ {
+ (data->value.caltime) = value;
+ return CALENDAR_ERROR_NONE;
+ }
+ else
+ {
+ ERR("invalid parameter (property:%d)",data->property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ }
+
+ data = calloc(1, sizeof(cal_search_value_s));
+ retvm_if(NULL == data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_search_s) Failed");
+ data->property_id = property_id;
+ (data->value.caltime) = value;
+ rec->values = g_slist_append(rec->values, data);
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_timezone_set_int( calendar_record_h record, unsigned int property_id, int value );
cal_record_plugin_cb_s _cal_record_timezone_plugin_cb = {
- .create = __cal_record_timezone_create,
- .destroy = __cal_record_timezone_destroy,
- .clone = __cal_record_timezone_clone,
- .get_str = __cal_record_timezone_get_str,
- .get_str_p = __cal_record_timezone_get_str_p,
- .get_int = __cal_record_timezone_get_int,
- .get_double = NULL,
- .get_lli = NULL,
- .get_caltime = NULL,
- .set_str = __cal_record_timezone_set_str,
- .set_int = __cal_record_timezone_set_int,
- .set_double = NULL,
- .set_lli = NULL,
- .set_caltime = NULL,
- .add_child_record = NULL,
- .remove_child_record = NULL,
- .get_child_record_count = NULL,
- .get_child_record_at_p = NULL,
- .clone_child_record_list = NULL
+ .create = __cal_record_timezone_create,
+ .destroy = __cal_record_timezone_destroy,
+ .clone = __cal_record_timezone_clone,
+ .get_str = __cal_record_timezone_get_str,
+ .get_str_p = __cal_record_timezone_get_str_p,
+ .get_int = __cal_record_timezone_get_int,
+ .get_double = NULL,
+ .get_lli = NULL,
+ .get_caltime = NULL,
+ .set_str = __cal_record_timezone_set_str,
+ .set_int = __cal_record_timezone_set_int,
+ .set_double = NULL,
+ .set_lli = NULL,
+ .set_caltime = NULL,
+ .add_child_record = NULL,
+ .remove_child_record = NULL,
+ .get_child_record_count = NULL,
+ .get_child_record_at_p = NULL,
+ .clone_child_record_list = NULL
};
static void __cal_record_timezone_struct_init(cal_timezone_s *record)
{
memset(record,0,sizeof(cal_timezone_s));
- record->calendar_id = DEFAULT_EVENT_CALENDAR_BOOK_ID;
+ record->calendar_id = DEFAULT_EVENT_CALENDAR_BOOK_ID;
}
static int __cal_record_timezone_create( calendar_record_h* out_record )
{
cal_timezone_s *temp = NULL;
- int ret= CALENDAR_ERROR_NONE, type = 0;
-
- type = CAL_RECORD_TYPE_TIMEZONE;
+ int ret= CALENDAR_ERROR_NONE;
temp = (cal_timezone_s*)calloc(1,sizeof(cal_timezone_s));
retvm_if(NULL == temp, CALENDAR_ERROR_OUT_OF_MEMORY, "malloc(cal_timezone_s) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
__cal_record_timezone_struct_init(temp);
- *out_record = (calendar_record_h)temp;
+ *out_record = (calendar_record_h)temp;
return ret;
}
static int __cal_record_timezone_destroy( calendar_record_h record, bool delete_child )
{
- int ret = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
cal_timezone_s *temp = (cal_timezone_s*)(record);
- __cal_record_timezone_struct_free(temp);
+ __cal_record_timezone_struct_free(temp);
return ret;
}
out_data->day_light_bias = src_data->day_light_bias;
out_data->calendar_id = src_data->calendar_id;
- *out_record = (calendar_record_h)out_data;
+ *out_record = (calendar_record_h)out_data;
return CALENDAR_ERROR_NONE;
}
*out_str = SAFE_STRDUP(rec->day_light_name);
break;
default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
+ ERR("invalid parameter (property:%d)",property_id);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
*out_str = (rec->day_light_name);
break;
default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
+ ERR("invalid parameter (property:%d)",property_id);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
*out_value = (rec->calendar_id);
break;
default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
+ ERR("invalid parameter (property:%d)",property_id);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
rec->day_light_name = SAFE_STRDUP(value);
break;
default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
+ ERR("invalid parameter (property:%d)",property_id);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
(rec->calendar_id) = value;
break;
default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
+ ERR("invalid parameter (property:%d)",property_id);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
#include "cal_internal.h"
#include "cal_typedef.h"
#include "cal_view.h"
+#include "cal_list.h"
#include "cal_record.h"
static int __cal_record_todo_clone_child_record_list( calendar_record_h record, unsigned int property_id, calendar_list_h* out_list );
cal_record_plugin_cb_s _cal_record_todo_plugin_cb = {
- .create = __cal_record_todo_create,
- .destroy = __cal_record_todo_destroy,
- .clone = __cal_record_todo_clone,
- .get_str = __cal_record_todo_get_str,
- .get_str_p = __cal_record_todo_get_str_p,
- .get_int = __cal_record_todo_get_int,
- .get_double = __cal_record_todo_get_double,
- .get_lli = __cal_record_todo_get_lli,
- .get_caltime = __cal_record_todo_get_caltime,
- .set_str = __cal_record_todo_set_str,
- .set_int = __cal_record_todo_set_int,
- .set_double = __cal_record_todo_set_double,
- .set_lli = __cal_record_todo_set_lli,
- .set_caltime = __cal_record_todo_set_caltime,
- .add_child_record = __cal_record_todo_add_child_record,
- .remove_child_record = __cal_record_todo_remove_child_record,
- .get_child_record_count = __cal_record_todo_get_child_record_count,
- .get_child_record_at_p = __cal_record_todo_get_child_record_at_p,
- .clone_child_record_list = __cal_record_todo_clone_child_record_list
+ .create = __cal_record_todo_create,
+ .destroy = __cal_record_todo_destroy,
+ .clone = __cal_record_todo_clone,
+ .get_str = __cal_record_todo_get_str,
+ .get_str_p = __cal_record_todo_get_str_p,
+ .get_int = __cal_record_todo_get_int,
+ .get_double = __cal_record_todo_get_double,
+ .get_lli = __cal_record_todo_get_lli,
+ .get_caltime = __cal_record_todo_get_caltime,
+ .set_str = __cal_record_todo_set_str,
+ .set_int = __cal_record_todo_set_int,
+ .set_double = __cal_record_todo_set_double,
+ .set_lli = __cal_record_todo_set_lli,
+ .set_caltime = __cal_record_todo_set_caltime,
+ .add_child_record = __cal_record_todo_add_child_record,
+ .remove_child_record = __cal_record_todo_remove_child_record,
+ .get_child_record_count = __cal_record_todo_get_child_record_count,
+ .get_child_record_at_p = __cal_record_todo_get_child_record_at_p,
+ .clone_child_record_list = __cal_record_todo_clone_child_record_list
};
static void __cal_record_todo_struct_init(cal_todo_s *record)
{
- memset(record,0,sizeof(cal_todo_s));
-
- record->todo_status = CALENDAR_TODO_STATUS_NONE;
- record->calendar_id = DEFAULT_TODO_CALENDAR_BOOK_ID;
-
- record->index = CAL_INVALID_ID;
- record->summary = NULL;
- record->description = NULL;
- record->location= NULL;
- record->categories = NULL;
- record->uid= NULL;
- record->is_deleted = 0;
- record->latitude = 1000; // set default 1000 out of range(-180 ~ 180)
- record->longitude = 1000; // set default 1000 out of range(-180 ~ 180)
- record->priority = CALENDAR_TODO_PRIORITY_NONE;
- record->freq = CALENDAR_RECURRENCE_NONE;
- record->until_utime = CALENDAR_RECORD_NO_UNTIL;
- record->start.time.utime = CALENDAR_TODO_NO_START_DATE;
- record->due.time.utime = CALENDAR_TODO_NO_DUE_DATE;
-
- return ;
+ memset(record,0,sizeof(cal_todo_s));
+
+ record->todo_status = CALENDAR_TODO_STATUS_NONE;
+ record->calendar_id = DEFAULT_TODO_CALENDAR_BOOK_ID;
+
+ record->index = CAL_INVALID_ID;
+ record->summary = NULL;
+ record->description = NULL;
+ record->location= NULL;
+ record->categories = NULL;
+ record->uid= NULL;
+ record->is_deleted = 0;
+ record->latitude = CALENDAR_RECORD_NO_COORDINATE; // set default 1000 out of range(-180 ~ 180)
+ record->longitude = CALENDAR_RECORD_NO_COORDINATE; // set default 1000 out of range(-180 ~ 180)
+ record->priority = CALENDAR_TODO_PRIORITY_NONE;
+ record->freq = CALENDAR_RECURRENCE_NONE;
+ record->start.time.utime = CALENDAR_TODO_NO_START_DATE;
+ record->due.time.utime = CALENDAR_TODO_NO_DUE_DATE;
+ record->until.time.utime = CALENDAR_RECORD_NO_UNTIL;
+
+ record->alarm_list = calloc(1, sizeof(cal_list_s));
+ record->attendee_list = calloc(1, sizeof(cal_list_s));
+ record->extended_list = calloc(1, sizeof(cal_list_s));
+
+ return ;
}
static int __cal_record_todo_create( calendar_record_h* out_record )
{
- cal_todo_s *temp = NULL;
- int ret= CALENDAR_ERROR_NONE, type = 0;
+ cal_todo_s *temp = NULL;
+ int ret= CALENDAR_ERROR_NONE;
- type = CAL_RECORD_TYPE_TODO;
+ temp = (cal_todo_s*)calloc(1,sizeof(cal_todo_s));
+ retvm_if(NULL == temp, CALENDAR_ERROR_OUT_OF_MEMORY, "malloc(cal_todo_s) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
- temp = (cal_todo_s*)calloc(1,sizeof(cal_todo_s));
- retvm_if(NULL == temp, CALENDAR_ERROR_OUT_OF_MEMORY, "malloc(cal_todo_s) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
+ __cal_record_todo_struct_init(temp);
- __cal_record_todo_struct_init(temp);
+ *out_record = (calendar_record_h)temp;
- *out_record = (calendar_record_h)temp;
-
- return ret;
+ return ret;
}
static void __cal_record_todo_struct_free(cal_todo_s *record, bool delete_child)
{
- CAL_FREE(record->summary);
- CAL_FREE(record->description);
- CAL_FREE(record->location);
- CAL_FREE(record->categories);
- CAL_FREE(record->uid);
- CAL_FREE(record->start_tzid);
- CAL_FREE(record->due_tzid);
-
- CAL_FREE(record->bysecond);
- CAL_FREE(record->byminute);
- CAL_FREE(record->byhour);
- CAL_FREE(record->byday);
- CAL_FREE(record->bymonthday);
- CAL_FREE(record->byyearday);
- CAL_FREE(record->byweekno);
- CAL_FREE(record->bymonth);
- CAL_FREE(record->bysetpos);
-
- CAL_FREE(record->sync_data1);
- CAL_FREE(record->sync_data2);
- CAL_FREE(record->sync_data3);
- CAL_FREE(record->sync_data4);
-
- CAL_FREE(record->organizer_name);
- CAL_FREE(record->organizer_email);
-
- if (delete_child == true)
- {
- if( record->alarm_list )
- {
- GList *alarm_list = record->alarm_list;
- calendar_record_h alarm_child_record = NULL;
- while (alarm_list)
- {
- alarm_child_record = (calendar_record_h)alarm_list->data;
- if (alarm_child_record == NULL)
- {
- alarm_list = g_list_next(alarm_list);
- continue;
- }
-
- calendar_record_destroy(alarm_child_record, true);
-
- alarm_list = g_list_next(alarm_list);
- }
- g_list_free(record->alarm_list);
- record->alarm_list = NULL;
- }
-
- if( record->attendee_list )
- {
- GList * attendee_list = g_list_first(record->attendee_list);
- calendar_record_h attendee = NULL;
-
- while (attendee_list)
- {
- attendee = (calendar_record_h)attendee_list->data;
- if (attendee == NULL)
- {
- attendee_list = g_list_next(attendee_list);
- continue;
- }
-
- calendar_record_destroy(attendee, true);
-
- attendee_list = g_list_next(attendee_list);
- }
- g_list_free(record->attendee_list);
- record->attendee_list = NULL;
- }
- if( record->extended_list )
- {
- GList * extended_list = g_list_first(record->extended_list);
- calendar_record_h extended = NULL;
-
- while (extended_list)
- {
- extended = (calendar_record_h)extended_list->data;
- if (extended == NULL)
- {
- extended_list = g_list_next(extended_list);
- continue;
- }
-
- calendar_record_destroy(extended, true);
-
- extended_list = g_list_next(extended_list);
- }
- g_list_free(record->extended_list);
- record->extended_list = NULL;
- }
- }
-
- CAL_FREE(record);
+ CAL_FREE(record->summary);
+ CAL_FREE(record->description);
+ CAL_FREE(record->location);
+ CAL_FREE(record->categories);
+ CAL_FREE(record->uid);
+ CAL_FREE(record->start_tzid);
+ CAL_FREE(record->due_tzid);
+
+ CAL_FREE(record->bysecond);
+ CAL_FREE(record->byminute);
+ CAL_FREE(record->byhour);
+ CAL_FREE(record->byday);
+ CAL_FREE(record->bymonthday);
+ CAL_FREE(record->byyearday);
+ CAL_FREE(record->byweekno);
+ CAL_FREE(record->bymonth);
+ CAL_FREE(record->bysetpos);
+
+ CAL_FREE(record->sync_data1);
+ CAL_FREE(record->sync_data2);
+ CAL_FREE(record->sync_data3);
+ CAL_FREE(record->sync_data4);
+
+ CAL_FREE(record->organizer_name);
+ CAL_FREE(record->organizer_email);
+
+ calendar_list_destroy((calendar_list_h)record->alarm_list, delete_child);
+ calendar_list_destroy((calendar_list_h)record->attendee_list, delete_child);
+ calendar_list_destroy((calendar_list_h)record->extended_list, delete_child);
+
+ CAL_FREE(record);
}
static int __cal_record_todo_destroy( calendar_record_h record, bool delete_child )
{
- int ret = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
- cal_todo_s *temp = (cal_todo_s*)(record);
+ cal_todo_s *temp = (cal_todo_s*)(record);
- __cal_record_todo_struct_free(temp, delete_child);
+ __cal_record_todo_struct_free(temp, delete_child);
- return ret;
+ return ret;
}
static int __cal_record_todo_clone( calendar_record_h record, calendar_record_h* out_record )
{
- cal_todo_s *out_data = NULL;
- cal_todo_s *src_data = NULL;
-
- src_data = (cal_todo_s*)(record);
-
- out_data = calloc(1, sizeof(cal_todo_s));
- retvm_if(NULL == out_data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_todo_s) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
-
-
- CAL_RECORD_COPY_COMMON(&(out_data->common), &(src_data->common));
-
- out_data->index = src_data->index;
- out_data->summary = SAFE_STRDUP(src_data->summary);
- out_data->description = SAFE_STRDUP(src_data->description);
- out_data->location = SAFE_STRDUP(src_data->location);
- out_data->categories = SAFE_STRDUP(src_data->categories);
-
- out_data->todo_status = src_data->todo_status;
- out_data->priority = src_data->priority;
- out_data->sensitivity = src_data->sensitivity;
-
- out_data->uid = SAFE_STRDUP(src_data->uid);
-
- out_data->calendar_id = src_data->calendar_id;
- out_data->latitude = src_data->latitude;
- out_data->longitude = src_data->longitude;
-
- out_data->created_time = src_data->created_time;
- out_data->completed_time = src_data->completed_time;
- out_data->progress = src_data->progress;
- out_data->is_deleted = src_data->is_deleted;
- out_data->last_mod = src_data->last_mod;
-
- out_data->freq = src_data->freq;
- out_data->range_type = src_data->range_type;
- out_data->until_type = src_data->until_type;
- out_data->until_utime = src_data->until_utime;
- out_data->until_year = src_data->until_year;
- out_data->until_month = src_data->until_month;
- out_data->until_mday = src_data->until_mday;
- out_data->count = src_data->count;
- out_data->interval = src_data->interval;
- out_data->bysecond = SAFE_STRDUP(src_data->bysecond);
- out_data->byminute = SAFE_STRDUP(src_data->byminute);
- out_data->byhour = SAFE_STRDUP(src_data->byhour);
- out_data->byday = SAFE_STRDUP(src_data->byday);
- out_data->bymonthday = SAFE_STRDUP(src_data->bymonthday);
- out_data->byyearday = SAFE_STRDUP(src_data->byyearday);
- out_data->byweekno = SAFE_STRDUP(src_data->byweekno);
- out_data->bymonth = SAFE_STRDUP(src_data->bymonth);
- out_data->bysetpos = SAFE_STRDUP(src_data->bysetpos);
- out_data->wkst = src_data->wkst;
- out_data->has_alarm = src_data->has_alarm;
- out_data->updated = src_data->updated;
-
- out_data->sync_data1 = SAFE_STRDUP(src_data->sync_data1);
- out_data->sync_data2 = SAFE_STRDUP(src_data->sync_data2);
- out_data->sync_data3 = SAFE_STRDUP(src_data->sync_data3);
- out_data->sync_data4 = SAFE_STRDUP(src_data->sync_data4);
-
- out_data->start = src_data->start;
- out_data->start_tzid = SAFE_STRDUP(src_data->start_tzid);
- out_data->due = src_data->due;
- out_data->due_tzid = SAFE_STRDUP(src_data->due_tzid);
-
- out_data->organizer_name = SAFE_STRDUP(src_data->organizer_name);
- out_data->organizer_email = SAFE_STRDUP(src_data->organizer_email);
- out_data->has_attendee = src_data->has_attendee;
-
- if( src_data->alarm_list )
- {
- GList *alarm_list = src_data->alarm_list;
- calendar_record_h alarm_child_record;
-
- while (alarm_list)
- {
- calendar_record_h child_clone = NULL;
- alarm_child_record = (calendar_record_h)alarm_list->data;
- if (alarm_child_record == NULL)
- {
- alarm_list = g_list_next(alarm_list);
- continue;
- }
- if (calendar_record_clone(alarm_child_record, &child_clone) == CALENDAR_ERROR_NONE)
- {
- calendar_record_add_child_record((calendar_record_h)out_data,
- CAL_PROPERTY_TODO_CALENDAR_ALARM,child_clone);
-
- }
- alarm_list = g_list_next(alarm_list);
- }
-
- }
-
- if( src_data->attendee_list )
- {
- GList * attendee_list = src_data->attendee_list;
- calendar_record_h attendee_child = NULL;
-
- while (attendee_list)
- {
- calendar_record_h child_clone = NULL;
- attendee_child = (calendar_record_h)attendee_list->data;
- if (attendee_child == NULL)
- {
- attendee_list = g_list_next(attendee_list);
- continue;
- }
- if (calendar_record_clone(attendee_child, &child_clone) == CALENDAR_ERROR_NONE)
- {
-
- calendar_record_add_child_record((calendar_record_h)out_data,
- CAL_PROPERTY_TODO_CALENDAR_ATTENDEE,child_clone);
-
- }
- attendee_list = g_list_next(attendee_list);
- }
-
- }
-
- if( src_data->extended_list )
- {
- GList * extended_list = src_data->extended_list;
- calendar_record_h extended = NULL;
-
- while (extended_list)
- {
- calendar_record_h child_clone = NULL;
- extended = (calendar_record_h)extended_list->data;
- if (extended == NULL)
- {
- extended_list = g_list_next(extended_list);
- continue;
- }
- if (calendar_record_clone(extended, &child_clone) == CALENDAR_ERROR_NONE)
- {
-
- calendar_record_add_child_record((calendar_record_h)out_data,
- CAL_PROPERTY_TODO_EXTENDED,child_clone);
-
- }
- extended_list = g_list_next(extended_list);
- }
-
- }
-
- *out_record = (calendar_record_h)out_data;
-
- return CALENDAR_ERROR_NONE;
+ cal_todo_s *out_data = NULL;
+ cal_todo_s *src_data = NULL;
+
+ src_data = (cal_todo_s*)(record);
+
+ out_data = calloc(1, sizeof(cal_todo_s));
+ retvm_if(NULL == out_data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_todo_s) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
+
+
+ CAL_RECORD_COPY_COMMON(&(out_data->common), &(src_data->common));
+
+ out_data->index = src_data->index;
+ out_data->summary = SAFE_STRDUP(src_data->summary);
+ out_data->description = SAFE_STRDUP(src_data->description);
+ out_data->location = SAFE_STRDUP(src_data->location);
+ out_data->categories = SAFE_STRDUP(src_data->categories);
+
+ out_data->todo_status = src_data->todo_status;
+ out_data->priority = src_data->priority;
+ out_data->sensitivity = src_data->sensitivity;
+
+ out_data->uid = SAFE_STRDUP(src_data->uid);
+
+ out_data->calendar_id = src_data->calendar_id;
+ out_data->latitude = src_data->latitude;
+ out_data->longitude = src_data->longitude;
+
+ out_data->created_time = src_data->created_time;
+ out_data->completed_time = src_data->completed_time;
+ out_data->progress = src_data->progress;
+ out_data->is_deleted = src_data->is_deleted;
+ out_data->last_mod = src_data->last_mod;
+
+ out_data->freq = src_data->freq;
+ out_data->range_type = src_data->range_type;
+ out_data->until = src_data->until;
+ out_data->count = src_data->count;
+ out_data->interval = src_data->interval;
+ out_data->bysecond = SAFE_STRDUP(src_data->bysecond);
+ out_data->byminute = SAFE_STRDUP(src_data->byminute);
+ out_data->byhour = SAFE_STRDUP(src_data->byhour);
+ out_data->byday = SAFE_STRDUP(src_data->byday);
+ out_data->bymonthday = SAFE_STRDUP(src_data->bymonthday);
+ out_data->byyearday = SAFE_STRDUP(src_data->byyearday);
+ out_data->byweekno = SAFE_STRDUP(src_data->byweekno);
+ out_data->bymonth = SAFE_STRDUP(src_data->bymonth);
+ out_data->bysetpos = SAFE_STRDUP(src_data->bysetpos);
+ out_data->wkst = src_data->wkst;
+ out_data->has_alarm = src_data->has_alarm;
+ out_data->updated = src_data->updated;
+
+ out_data->sync_data1 = SAFE_STRDUP(src_data->sync_data1);
+ out_data->sync_data2 = SAFE_STRDUP(src_data->sync_data2);
+ out_data->sync_data3 = SAFE_STRDUP(src_data->sync_data3);
+ out_data->sync_data4 = SAFE_STRDUP(src_data->sync_data4);
+
+ out_data->start = src_data->start;
+ out_data->start_tzid = SAFE_STRDUP(src_data->start_tzid);
+ out_data->due = src_data->due;
+ out_data->due_tzid = SAFE_STRDUP(src_data->due_tzid);
+
+ out_data->organizer_name = SAFE_STRDUP(src_data->organizer_name);
+ out_data->organizer_email = SAFE_STRDUP(src_data->organizer_email);
+ out_data->has_attendee = src_data->has_attendee;
+
+ _cal_list_clone((calendar_list_h)src_data->alarm_list, (calendar_list_h *)&out_data->alarm_list);
+ _cal_list_clone((calendar_list_h)src_data->attendee_list, (calendar_list_h *)&out_data->attendee_list);
+ _cal_list_clone((calendar_list_h)src_data->extended_list, (calendar_list_h *)&out_data->extended_list);
+
+ *out_record = (calendar_record_h)out_data;
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_todo_get_str( calendar_record_h record, unsigned int property_id, char** out_str )
{
- cal_todo_s *rec = (cal_todo_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_TODO_SUMMARY:
- *out_str = SAFE_STRDUP(rec->summary);
- break;
- case CAL_PROPERTY_TODO_DESCRIPTION:
- *out_str = SAFE_STRDUP(rec->description);
- break;
- case CAL_PROPERTY_TODO_LOCATION:
- *out_str = SAFE_STRDUP(rec->location);
- break;
- case CAL_PROPERTY_TODO_CATEGORIES:
- *out_str = SAFE_STRDUP(rec->categories);
- break;
-
- case CAL_PROPERTY_TODO_UID:
- *out_str = SAFE_STRDUP(rec->uid);
- break;
-
- case CAL_PROPERTY_TODO_BYSECOND:
- *out_str = SAFE_STRDUP(rec->bysecond);
- break;
- case CAL_PROPERTY_TODO_BYMINUTE:
- *out_str = SAFE_STRDUP(rec->byminute);
- break;
- case CAL_PROPERTY_TODO_BYHOUR:
- *out_str = SAFE_STRDUP(rec->byhour);
- break;
- case CAL_PROPERTY_TODO_BYDAY:
- *out_str = SAFE_STRDUP(rec->byday);
- break;
- case CAL_PROPERTY_TODO_BYMONTHDAY:
- *out_str = SAFE_STRDUP(rec->bymonthday);
- break;
- case CAL_PROPERTY_TODO_BYYEARDAY:
- *out_str = SAFE_STRDUP(rec->byyearday);
- break;
- case CAL_PROPERTY_TODO_BYWEEKNO:
- *out_str = SAFE_STRDUP(rec->byweekno);
- break;
- case CAL_PROPERTY_TODO_BYMONTH:
- *out_str = SAFE_STRDUP(rec->bymonth);
- break;
- case CAL_PROPERTY_TODO_BYSETPOS:
- *out_str = SAFE_STRDUP(rec->bysetpos);
- break;
-
- case CAL_PROPERTY_TODO_SYNC_DATA1:
- *out_str = SAFE_STRDUP(rec->sync_data1);
- break;
- case CAL_PROPERTY_TODO_SYNC_DATA2:
- *out_str = SAFE_STRDUP(rec->sync_data2);
- break;
- case CAL_PROPERTY_TODO_SYNC_DATA3:
- *out_str = SAFE_STRDUP(rec->sync_data3);
- break;
- case CAL_PROPERTY_TODO_SYNC_DATA4:
- *out_str = SAFE_STRDUP(rec->sync_data4);
- break;
- case CAL_PROPERTY_TODO_START_TZID:
- *out_str = SAFE_STRDUP(rec->start_tzid);
- break;
- case CAL_PROPERTY_TODO_DUE_TZID:
- *out_str = SAFE_STRDUP(rec->due_tzid);
- break;
- case CAL_PROPERTY_TODO_ORGANIZER_NAME:
- *out_str = SAFE_STRDUP(rec->organizer_name);
- break;
- case CAL_PROPERTY_TODO_ORGANIZER_EMAIL:
- *out_str = SAFE_STRDUP(rec->organizer_email);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_todo_s *rec = (cal_todo_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_TODO_SUMMARY:
+ *out_str = SAFE_STRDUP(rec->summary);
+ break;
+ case CAL_PROPERTY_TODO_DESCRIPTION:
+ *out_str = SAFE_STRDUP(rec->description);
+ break;
+ case CAL_PROPERTY_TODO_LOCATION:
+ *out_str = SAFE_STRDUP(rec->location);
+ break;
+ case CAL_PROPERTY_TODO_CATEGORIES:
+ *out_str = SAFE_STRDUP(rec->categories);
+ break;
+ case CAL_PROPERTY_TODO_UID:
+ *out_str = SAFE_STRDUP(rec->uid);
+ break;
+ case CAL_PROPERTY_TODO_BYSECOND:
+ *out_str = SAFE_STRDUP(rec->bysecond);
+ break;
+ case CAL_PROPERTY_TODO_BYMINUTE:
+ *out_str = SAFE_STRDUP(rec->byminute);
+ break;
+ case CAL_PROPERTY_TODO_BYHOUR:
+ *out_str = SAFE_STRDUP(rec->byhour);
+ break;
+ case CAL_PROPERTY_TODO_BYDAY:
+ *out_str = SAFE_STRDUP(rec->byday);
+ break;
+ case CAL_PROPERTY_TODO_BYMONTHDAY:
+ *out_str = SAFE_STRDUP(rec->bymonthday);
+ break;
+ case CAL_PROPERTY_TODO_BYYEARDAY:
+ *out_str = SAFE_STRDUP(rec->byyearday);
+ break;
+ case CAL_PROPERTY_TODO_BYWEEKNO:
+ *out_str = SAFE_STRDUP(rec->byweekno);
+ break;
+ case CAL_PROPERTY_TODO_BYMONTH:
+ *out_str = SAFE_STRDUP(rec->bymonth);
+ break;
+ case CAL_PROPERTY_TODO_BYSETPOS:
+ *out_str = SAFE_STRDUP(rec->bysetpos);
+ break;
+ case CAL_PROPERTY_TODO_SYNC_DATA1:
+ *out_str = SAFE_STRDUP(rec->sync_data1);
+ break;
+ case CAL_PROPERTY_TODO_SYNC_DATA2:
+ *out_str = SAFE_STRDUP(rec->sync_data2);
+ break;
+ case CAL_PROPERTY_TODO_SYNC_DATA3:
+ *out_str = SAFE_STRDUP(rec->sync_data3);
+ break;
+ case CAL_PROPERTY_TODO_SYNC_DATA4:
+ *out_str = SAFE_STRDUP(rec->sync_data4);
+ break;
+ case CAL_PROPERTY_TODO_START_TZID:
+ *out_str = SAFE_STRDUP(rec->start_tzid);
+ break;
+ case CAL_PROPERTY_TODO_DUE_TZID:
+ *out_str = SAFE_STRDUP(rec->due_tzid);
+ break;
+ case CAL_PROPERTY_TODO_ORGANIZER_NAME:
+ *out_str = SAFE_STRDUP(rec->organizer_name);
+ break;
+ case CAL_PROPERTY_TODO_ORGANIZER_EMAIL:
+ *out_str = SAFE_STRDUP(rec->organizer_email);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_todo_get_str_p( calendar_record_h record, unsigned int property_id, char** out_str )
{
- cal_todo_s *rec = (cal_todo_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_TODO_SUMMARY:
- *out_str = (rec->summary);
- break;
- case CAL_PROPERTY_TODO_DESCRIPTION:
- *out_str = (rec->description);
- break;
- case CAL_PROPERTY_TODO_LOCATION:
- *out_str = (rec->location);
- break;
- case CAL_PROPERTY_TODO_CATEGORIES:
- *out_str = (rec->categories);
- break;
-
- case CAL_PROPERTY_TODO_UID:
- *out_str = (rec->uid);
- break;
-
- case CAL_PROPERTY_TODO_BYSECOND:
- *out_str = (rec->bysecond);
- break;
- case CAL_PROPERTY_TODO_BYMINUTE:
- *out_str = (rec->byminute);
- break;
- case CAL_PROPERTY_TODO_BYHOUR:
- *out_str = (rec->byhour);
- break;
- case CAL_PROPERTY_TODO_BYDAY:
- *out_str = (rec->byday);
- break;
- case CAL_PROPERTY_TODO_BYMONTHDAY:
- *out_str = (rec->bymonthday);
- break;
- case CAL_PROPERTY_TODO_BYYEARDAY:
- *out_str = (rec->byyearday);
- break;
- case CAL_PROPERTY_TODO_BYWEEKNO:
- *out_str = (rec->byweekno);
- break;
- case CAL_PROPERTY_TODO_BYMONTH:
- *out_str = (rec->bymonth);
- break;
- case CAL_PROPERTY_TODO_BYSETPOS:
- *out_str = (rec->bysetpos);
- break;
-
- case CAL_PROPERTY_TODO_SYNC_DATA1:
- *out_str = (rec->sync_data1);
- break;
- case CAL_PROPERTY_TODO_SYNC_DATA2:
- *out_str = (rec->sync_data2);
- break;
- case CAL_PROPERTY_TODO_SYNC_DATA3:
- *out_str = (rec->sync_data3);
- break;
- case CAL_PROPERTY_TODO_SYNC_DATA4:
- *out_str = (rec->sync_data4);
- break;
- case CAL_PROPERTY_TODO_START_TZID:
- *out_str = (rec->start_tzid);
- break;
- case CAL_PROPERTY_TODO_DUE_TZID:
- *out_str = (rec->due_tzid);
- break;
- case CAL_PROPERTY_TODO_ORGANIZER_NAME:
- *out_str = (rec->organizer_name);
- break;
- case CAL_PROPERTY_TODO_ORGANIZER_EMAIL:
- *out_str = (rec->organizer_email);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_todo_s *rec = (cal_todo_s*)(record);
+ switch( property_id )
+ {
+ case CAL_PROPERTY_TODO_SUMMARY:
+ *out_str = (rec->summary);
+ break;
+ case CAL_PROPERTY_TODO_DESCRIPTION:
+ *out_str = (rec->description);
+ break;
+ case CAL_PROPERTY_TODO_LOCATION:
+ *out_str = (rec->location);
+ break;
+ case CAL_PROPERTY_TODO_CATEGORIES:
+ *out_str = (rec->categories);
+ break;
+ case CAL_PROPERTY_TODO_UID:
+ *out_str = (rec->uid);
+ break;
+ case CAL_PROPERTY_TODO_BYSECOND:
+ *out_str = (rec->bysecond);
+ break;
+ case CAL_PROPERTY_TODO_BYMINUTE:
+ *out_str = (rec->byminute);
+ break;
+ case CAL_PROPERTY_TODO_BYHOUR:
+ *out_str = (rec->byhour);
+ break;
+ case CAL_PROPERTY_TODO_BYDAY:
+ *out_str = (rec->byday);
+ break;
+ case CAL_PROPERTY_TODO_BYMONTHDAY:
+ *out_str = (rec->bymonthday);
+ break;
+ case CAL_PROPERTY_TODO_BYYEARDAY:
+ *out_str = (rec->byyearday);
+ break;
+ case CAL_PROPERTY_TODO_BYWEEKNO:
+ *out_str = (rec->byweekno);
+ break;
+ case CAL_PROPERTY_TODO_BYMONTH:
+ *out_str = (rec->bymonth);
+ break;
+ case CAL_PROPERTY_TODO_BYSETPOS:
+ *out_str = (rec->bysetpos);
+ break;
+ case CAL_PROPERTY_TODO_SYNC_DATA1:
+ *out_str = (rec->sync_data1);
+ break;
+ case CAL_PROPERTY_TODO_SYNC_DATA2:
+ *out_str = (rec->sync_data2);
+ break;
+ case CAL_PROPERTY_TODO_SYNC_DATA3:
+ *out_str = (rec->sync_data3);
+ break;
+ case CAL_PROPERTY_TODO_SYNC_DATA4:
+ *out_str = (rec->sync_data4);
+ break;
+ case CAL_PROPERTY_TODO_START_TZID:
+ *out_str = (rec->start_tzid);
+ break;
+ case CAL_PROPERTY_TODO_DUE_TZID:
+ *out_str = (rec->due_tzid);
+ break;
+ case CAL_PROPERTY_TODO_ORGANIZER_NAME:
+ *out_str = (rec->organizer_name);
+ break;
+ case CAL_PROPERTY_TODO_ORGANIZER_EMAIL:
+ *out_str = (rec->organizer_email);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_todo_get_int( calendar_record_h record, unsigned int property_id, int* out_value )
{
- cal_todo_s *rec = (cal_todo_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_TODO_ID:
- *out_value = (rec->index);
- break;
- case CAL_PROPERTY_TODO_CALENDAR_ID:
- *out_value = (rec->calendar_id);
- break;
- case CAL_PROPERTY_TODO_TODO_STATUS:
- *out_value = (rec->todo_status);
- break;
-
- case CAL_PROPERTY_TODO_PRIORITY:
- *out_value = (rec->priority);
- break;
- //sensitivity
- case CAL_PROPERTY_TODO_SENSITIVITY:
- *out_value = (rec->sensitivity);
- break;
-
- case CAL_PROPERTY_TODO_PROGRESS:
- *out_value = (rec->progress);
- break;
- //is_deleted
- case CAL_PROPERTY_TODO_IS_DELETED:
- *out_value = (rec->is_deleted);
- break;
- //freq
- case CAL_PROPERTY_TODO_FREQ:
- *out_value = (rec->freq);
- break;
- //range_type
- case CAL_PROPERTY_TODO_RANGE_TYPE:
- *out_value = (rec->range_type);
- break;
- //count
- case CAL_PROPERTY_TODO_COUNT:
- *out_value = (rec->count);
- break;
- //interval
- case CAL_PROPERTY_TODO_INTERVAL:
- *out_value = (rec->interval);
- break;
- //wkst
- case CAL_PROPERTY_TODO_WKST:
- *out_value = (rec->wkst);
- break;
-
- //has_alarm
- case CAL_PROPERTY_TODO_HAS_ALARM:
- *out_value = (rec->has_alarm);
- break;
- case CAL_PROPERTY_TODO_HAS_ATTENDEE:
- *out_value = (rec->has_attendee);
- break;
- case CAL_PROPERTY_TODO_IS_ALLDAY:
- *out_value = (rec->due.type);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_todo_s *rec = (cal_todo_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_TODO_ID:
+ *out_value = (rec->index);
+ break;
+ case CAL_PROPERTY_TODO_CALENDAR_ID:
+ *out_value = (rec->calendar_id);
+ break;
+ case CAL_PROPERTY_TODO_TODO_STATUS:
+ *out_value = (rec->todo_status);
+ break;
+ case CAL_PROPERTY_TODO_PRIORITY:
+ *out_value = (rec->priority);
+ break;
+ case CAL_PROPERTY_TODO_SENSITIVITY:
+ *out_value = (rec->sensitivity);
+ break;
+ case CAL_PROPERTY_TODO_PROGRESS:
+ *out_value = (rec->progress);
+ break;
+ case CAL_PROPERTY_TODO_IS_DELETED:
+ *out_value = (rec->is_deleted);
+ break;
+ case CAL_PROPERTY_TODO_FREQ:
+ *out_value = (rec->freq);
+ break;
+ case CAL_PROPERTY_TODO_RANGE_TYPE:
+ *out_value = (rec->range_type);
+ break;
+ case CAL_PROPERTY_TODO_COUNT:
+ *out_value = (rec->count);
+ break;
+ case CAL_PROPERTY_TODO_INTERVAL:
+ *out_value = (rec->interval);
+ break;
+ case CAL_PROPERTY_TODO_WKST:
+ *out_value = (rec->wkst);
+ break;
+ case CAL_PROPERTY_TODO_HAS_ALARM:
+ *out_value = (rec->has_alarm);
+ break;
+ case CAL_PROPERTY_TODO_HAS_ATTENDEE:
+ *out_value = (rec->has_attendee);
+ break;
+ case CAL_PROPERTY_TODO_IS_ALLDAY:
+ *out_value = (rec->is_allday);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_todo_get_double( calendar_record_h record, unsigned int property_id, double* out_value )
{
- cal_todo_s *rec = (cal_todo_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_TODO_LATITUDE:
- *out_value = (rec->latitude);
- break;
- case CAL_PROPERTY_TODO_LONGITUDE:
- *out_value = (rec->longitude);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_todo_s *rec = (cal_todo_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_TODO_LATITUDE:
+ *out_value = (rec->latitude);
+ break;
+ case CAL_PROPERTY_TODO_LONGITUDE:
+ *out_value = (rec->longitude);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_todo_get_lli( calendar_record_h record, unsigned int property_id, long long int* out_value )
{
- cal_todo_s *rec = (cal_todo_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_TODO_CREATED_TIME:
- *out_value = (rec->created_time);
- break;
- case CAL_PROPERTY_TODO_LAST_MODIFIED_TIME:
- *out_value = (rec->last_mod);
- break;
- case CAL_PROPERTY_TODO_COMPLETED_TIME:
- *out_value = (rec->completed_time);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_todo_s *rec = (cal_todo_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_TODO_CREATED_TIME:
+ *out_value = (rec->created_time);
+ break;
+ case CAL_PROPERTY_TODO_LAST_MODIFIED_TIME:
+ *out_value = (rec->last_mod);
+ break;
+ case CAL_PROPERTY_TODO_COMPLETED_TIME:
+ *out_value = (rec->completed_time);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_todo_get_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s* out_value )
{
- cal_todo_s *rec = (cal_todo_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_TODO_START:
- *out_value = rec->start;
- break;
- case CAL_PROPERTY_TODO_DUE:
- *out_value = rec->due;
- break;
- case CAL_PROPERTY_TODO_UNTIL:
- if (rec->until_type == CALENDAR_TIME_UTIME)
- {
- CAL_CALTIME_SET_UTIME(*out_value, rec->until_utime);
- }
- else
- {
- CAL_CALTIME_SET_DATE(*out_value, rec->until_year,rec->until_month,rec->until_mday);
- }
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_todo_s *rec = (cal_todo_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_TODO_START:
+ *out_value = rec->start;
+ break;
+ case CAL_PROPERTY_TODO_DUE:
+ *out_value = rec->due;
+ break;
+ case CAL_PROPERTY_TODO_UNTIL:
+ *out_value = rec->until;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_todo_set_str( calendar_record_h record, unsigned int property_id, const char* value )
{
- cal_todo_s *rec = (cal_todo_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_TODO_SUMMARY:
- CAL_FREE(rec->summary);
- rec->summary = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_TODO_DESCRIPTION:
- CAL_FREE(rec->description);
- rec->description = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_TODO_LOCATION:
- CAL_FREE(rec->location);
- rec->location = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_TODO_CATEGORIES:
- CAL_FREE(rec->categories);
- rec->categories = SAFE_STRDUP(value);
- break;
-
- case CAL_PROPERTY_TODO_UID:
- CAL_FREE(rec->uid);
- rec->uid = SAFE_STRDUP(value);
- break;
-
- case CAL_PROPERTY_TODO_BYSECOND:
- CAL_FREE(rec->bysecond);
- rec->bysecond = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_TODO_BYMINUTE:
- CAL_FREE(rec->byminute);
- rec->byminute = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_TODO_BYHOUR:
- CAL_FREE(rec->byhour);
- rec->byhour = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_TODO_BYDAY:
- CAL_FREE(rec->byday);
- rec->byday = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_TODO_BYMONTHDAY:
- CAL_FREE(rec->bymonthday);
- rec->bymonthday = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_TODO_BYYEARDAY:
- CAL_FREE(rec->byyearday);
- rec->byyearday = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_TODO_BYWEEKNO:
- CAL_FREE(rec->byweekno);
- rec->byweekno = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_TODO_BYMONTH:
- CAL_FREE(rec->bymonth);
- rec->bymonth = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_TODO_BYSETPOS:
- CAL_FREE(rec->bysetpos);
- rec->bysetpos = SAFE_STRDUP(value);
- break;
-
- case CAL_PROPERTY_TODO_SYNC_DATA1:
- CAL_FREE(rec->sync_data1);
- rec->sync_data1 = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_TODO_SYNC_DATA2:
- CAL_FREE(rec->sync_data2);
- rec->sync_data2 = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_TODO_SYNC_DATA3:
- CAL_FREE(rec->sync_data3);
- rec->sync_data3 = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_TODO_SYNC_DATA4:
- CAL_FREE(rec->sync_data4);
- rec->sync_data4 = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_TODO_START_TZID:
- CAL_FREE(rec->start_tzid);
- rec->start_tzid = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_TODO_DUE_TZID:
- CAL_FREE(rec->due_tzid);
- rec->due_tzid = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_TODO_ORGANIZER_NAME:
- CAL_FREE(rec->organizer_name);
- rec->organizer_name = SAFE_STRDUP(value);
- break;
- case CAL_PROPERTY_TODO_ORGANIZER_EMAIL:
- CAL_FREE(rec->organizer_email);
- rec->organizer_email = SAFE_STRDUP(value);
- break;
- default:
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_todo_s *rec = (cal_todo_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_TODO_SUMMARY:
+ CAL_FREE(rec->summary);
+ rec->summary = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_TODO_DESCRIPTION:
+ CAL_FREE(rec->description);
+ rec->description = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_TODO_LOCATION:
+ CAL_FREE(rec->location);
+ rec->location = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_TODO_CATEGORIES:
+ CAL_FREE(rec->categories);
+ rec->categories = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_TODO_UID:
+ CAL_FREE(rec->uid);
+ rec->uid = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_TODO_BYSECOND:
+ CAL_FREE(rec->bysecond);
+ rec->bysecond = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_TODO_BYMINUTE:
+ CAL_FREE(rec->byminute);
+ rec->byminute = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_TODO_BYHOUR:
+ CAL_FREE(rec->byhour);
+ rec->byhour = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_TODO_BYDAY:
+ CAL_FREE(rec->byday);
+ rec->byday = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_TODO_BYMONTHDAY:
+ CAL_FREE(rec->bymonthday);
+ rec->bymonthday = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_TODO_BYYEARDAY:
+ CAL_FREE(rec->byyearday);
+ rec->byyearday = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_TODO_BYWEEKNO:
+ CAL_FREE(rec->byweekno);
+ rec->byweekno = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_TODO_BYMONTH:
+ CAL_FREE(rec->bymonth);
+ rec->bymonth = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_TODO_BYSETPOS:
+ CAL_FREE(rec->bysetpos);
+ rec->bysetpos = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_TODO_SYNC_DATA1:
+ CAL_FREE(rec->sync_data1);
+ rec->sync_data1 = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_TODO_SYNC_DATA2:
+ CAL_FREE(rec->sync_data2);
+ rec->sync_data2 = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_TODO_SYNC_DATA3:
+ CAL_FREE(rec->sync_data3);
+ rec->sync_data3 = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_TODO_SYNC_DATA4:
+ CAL_FREE(rec->sync_data4);
+ rec->sync_data4 = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_TODO_START_TZID:
+ CAL_FREE(rec->start_tzid);
+ rec->start_tzid = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_TODO_DUE_TZID:
+ CAL_FREE(rec->due_tzid);
+ rec->due_tzid = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_TODO_ORGANIZER_NAME:
+ CAL_FREE(rec->organizer_name);
+ rec->organizer_name = SAFE_STRDUP(value);
+ break;
+ case CAL_PROPERTY_TODO_ORGANIZER_EMAIL:
+ CAL_FREE(rec->organizer_email);
+ rec->organizer_email = SAFE_STRDUP(value);
+ break;
+ default:
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_todo_set_int( calendar_record_h record, unsigned int property_id, int value )
{
- cal_todo_s *rec = (cal_todo_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_TODO_ID:
- (rec->index) = value;
- break;
- case CAL_PROPERTY_TODO_CALENDAR_ID:
- (rec->calendar_id) = value;
- break;
- case CAL_PROPERTY_TODO_TODO_STATUS:
- switch (value)
- {
+ cal_todo_s *rec = (cal_todo_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_TODO_ID:
+ (rec->index) = value;
+ break;
+ case CAL_PROPERTY_TODO_CALENDAR_ID:
+ (rec->calendar_id) = value;
+ break;
+ case CAL_PROPERTY_TODO_TODO_STATUS:
+ switch (value) {
case CALENDAR_TODO_STATUS_NONE:
case CALENDAR_TODO_STATUS_NEEDS_ACTION:
case CALENDAR_TODO_STATUS_COMPLETED:
ERR("invalid parameter (value:%d)", value);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- break;
- //priority
- case CAL_PROPERTY_TODO_PRIORITY:
- (rec->priority) = value;
- break;
-
- //sensitivity
- case CAL_PROPERTY_TODO_SENSITIVITY:
- (rec->sensitivity) = value;
- break;
- case CAL_PROPERTY_TODO_PROGRESS:
- (rec->progress) = value;
- break;
- //is_deleted
- case CAL_PROPERTY_TODO_IS_DELETED:
- (rec->is_deleted) = value;
- break;
- //freq
- case CAL_PROPERTY_TODO_FREQ:
- switch (value)
- {
+ break;
+ case CAL_PROPERTY_TODO_PRIORITY:
+ switch (value) {
+ case CALENDAR_TODO_PRIORITY_NONE:
+ case CALENDAR_TODO_PRIORITY_LOW:
+ case CALENDAR_TODO_PRIORITY_NORMAL:
+ case CALENDAR_TODO_PRIORITY_HIGH:
+ (rec->priority) = value;
+ break;
+ default:
+ ERR("invalid parameter (value:%d)", value);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ case CAL_PROPERTY_TODO_SENSITIVITY:
+ (rec->sensitivity) = value;
+ break;
+ case CAL_PROPERTY_TODO_PROGRESS:
+ (rec->progress) = value;
+ break;
+ case CAL_PROPERTY_TODO_IS_DELETED:
+ (rec->is_deleted) = value;
+ break;
+ case CAL_PROPERTY_TODO_FREQ:
+ switch (value) {
case CALENDAR_RECURRENCE_NONE:
case CALENDAR_RECURRENCE_DAILY:
case CALENDAR_RECURRENCE_WEEKLY:
case CALENDAR_RECURRENCE_MONTHLY:
case CALENDAR_RECURRENCE_YEARLY:
- (rec->freq) = value;
+ (rec->freq) = value;
break;
default:
ERR("invalid parameter (value:%d)", value);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- break;
- //range_type
- case CAL_PROPERTY_TODO_RANGE_TYPE:
- switch (value)
- {
+ break;
+ case CAL_PROPERTY_TODO_RANGE_TYPE:
+ switch (value) {
case CALENDAR_RANGE_UNTIL:
case CALENDAR_RANGE_COUNT:
case CALENDAR_RANGE_NONE:
- (rec->range_type) = value;
+ (rec->range_type) = value;
break;
default:
ERR("invalid parameter (value:%d)", value);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- break;
- //count
- case CAL_PROPERTY_TODO_COUNT:
- (rec->count) = value;
- break;
- //interval
- case CAL_PROPERTY_TODO_INTERVAL:
- (rec->interval) = value;
- break;
- //wkst
- case CAL_PROPERTY_TODO_WKST:
- switch (value)
- {
+ break;
+ case CAL_PROPERTY_TODO_COUNT:
+ (rec->count) = value;
+ break;
+ case CAL_PROPERTY_TODO_INTERVAL:
+ (rec->interval) = value;
+ break;
+ case CAL_PROPERTY_TODO_WKST:
+ switch (value) {
case CALENDAR_SUNDAY:
case CALENDAR_MONDAY:
case CALENDAR_TUESDAY:
case CALENDAR_THURSDAY:
case CALENDAR_FRIDAY:
case CALENDAR_SATURDAY:
- (rec->wkst) = value;
+ (rec->wkst) = value;
break;
default:
ERR("invalid parameter (value:%d)", value);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- break;
- //has_alarm
- case CAL_PROPERTY_TODO_HAS_ALARM:
- (rec->has_alarm) = value;
- break;
- case CAL_PROPERTY_TODO_HAS_ATTENDEE:
- (rec->has_attendee) = value;
- break;
- case CAL_PROPERTY_TODO_IS_ALLDAY:
- (rec->due.type) = value;
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ break;
+ case CAL_PROPERTY_TODO_HAS_ALARM:
+ (rec->has_alarm) = value;
+ break;
+ case CAL_PROPERTY_TODO_HAS_ATTENDEE:
+ (rec->has_attendee) = value;
+ break;
+ case CAL_PROPERTY_TODO_IS_ALLDAY:
+ (rec->is_allday) = value;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_todo_set_double( calendar_record_h record, unsigned int property_id, double value )
{
- cal_todo_s *rec = (cal_todo_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_TODO_LATITUDE:
- (rec->latitude) = value;
- break;
- case CAL_PROPERTY_TODO_LONGITUDE:
- (rec->longitude) = value;
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_todo_s *rec = (cal_todo_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_TODO_LATITUDE:
+ (rec->latitude) = value;
+ break;
+ case CAL_PROPERTY_TODO_LONGITUDE:
+ (rec->longitude) = value;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_todo_set_lli( calendar_record_h record, unsigned int property_id, long long int value )
{
- cal_todo_s *rec = (cal_todo_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_TODO_CREATED_TIME:
- (rec->created_time) = value;
- break;
- case CAL_PROPERTY_TODO_LAST_MODIFIED_TIME:
- (rec->last_mod) = value;
- break;
- case CAL_PROPERTY_TODO_COMPLETED_TIME:
- (rec->completed_time) = value;
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_todo_s *rec = (cal_todo_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_TODO_CREATED_TIME:
+ (rec->created_time) = value;
+ break;
+ case CAL_PROPERTY_TODO_LAST_MODIFIED_TIME:
+ (rec->last_mod) = value;
+ break;
+ case CAL_PROPERTY_TODO_COMPLETED_TIME:
+ (rec->completed_time) = value;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_todo_set_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s value )
{
- cal_todo_s *rec = (cal_todo_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_TODO_START:
- (rec->start) = value;
- break;
- case CAL_PROPERTY_TODO_DUE:
- (rec->due) = value;
- break;
- case CAL_PROPERTY_TODO_UNTIL:
- (rec->until_type) = value.type;;
- if(value.type == CALENDAR_TIME_UTIME)
- {
- (rec->until_utime) = value.time.utime;
- (rec->until_year) = 0;
- (rec->until_month) = 0;
- (rec->until_mday) = 0;
- }
- else
- {
- (rec->until_utime) = 0;
- (rec->until_year) = value.time.date.year;
- (rec->until_month) = value.time.date.month;
- (rec->until_mday) = value.time.date.mday ;
- }
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_todo_s *rec = (cal_todo_s*)(record);
+ switch( property_id ) {
+ case CAL_PROPERTY_TODO_START:
+ (rec->start) = value;
+ break;
+ case CAL_PROPERTY_TODO_DUE:
+ (rec->due) = value;
+ break;
+ case CAL_PROPERTY_TODO_UNTIL:
+ (rec->until) = value;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
+static int __cal_record_todo_reset_child_record_id(calendar_record_h child_record)
+{
+ cal_record_s *record = (cal_record_s*)child_record;
+ retv_if(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
+
+ switch (record->type) {
+ case CAL_RECORD_TYPE_ALARM:
+ ((cal_alarm_s *)record)->id = 0;
+ break;
+ case CAL_RECORD_TYPE_ATTENDEE:
+ ((cal_attendee_s *)record)->id = 0;
+ break;
+ case CAL_RECORD_TYPE_EXTENDED:
+ ((cal_extended_s *)record)->id = 0;
+ break;
+ default:
+ ERR("Invalid child record type (%d)", record->type);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+
static int __cal_record_todo_add_child_record( calendar_record_h record, unsigned int property_id, calendar_record_h child_record )
{
- cal_todo_s *rec = (cal_todo_s*)(record);
-
- switch( property_id )
- {
- case CAL_PROPERTY_TODO_CALENDAR_ALARM:
- rec->alarm_list = g_list_append(rec->alarm_list,child_record);
- rec->has_alarm = 1;
- break;
- case CAL_PROPERTY_TODO_CALENDAR_ATTENDEE:
- rec->attendee_list = g_list_append(rec->attendee_list,child_record);
- rec->has_attendee = 1;
- break;
- case CAL_PROPERTY_TODO_EXTENDED:
- rec->extended_list = g_list_append(rec->extended_list,child_record);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
+ cal_todo_s *rec = (cal_todo_s*)(record);
+ __cal_record_todo_reset_child_record_id(child_record);
+
+ switch( property_id ) {
+ case CAL_PROPERTY_TODO_CALENDAR_ALARM:
+ ret = calendar_list_add((calendar_list_h)rec->alarm_list, child_record);
+ rec->has_alarm = 1;
+ break;
+ case CAL_PROPERTY_TODO_CALENDAR_ATTENDEE:
+ ret = calendar_list_add((calendar_list_h)rec->attendee_list, child_record);
+ rec->has_attendee = 1;
+ break;
+ case CAL_PROPERTY_TODO_EXTENDED:
+ ret = calendar_list_add((calendar_list_h)rec->extended_list, child_record);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return ret;
}
static int __cal_record_todo_remove_child_record( calendar_record_h record, unsigned int property_id, calendar_record_h child_record )
{
- cal_todo_s *rec = (cal_todo_s*)(record);
- //GList* node = NULL;
-
- switch( property_id )
- {
- case CAL_PROPERTY_TODO_CALENDAR_ALARM:
- //node = g_list_find(rec->alarm_list,child_record);
- rec->alarm_list = g_list_remove(rec->alarm_list,child_record);
- if (g_list_length(rec->alarm_list) == 0)
- {
- rec->has_alarm = 0;
- }
- break;
- case CAL_PROPERTY_TODO_CALENDAR_ATTENDEE:
- rec->attendee_list = g_list_remove(rec->attendee_list,child_record);
- if (g_list_length(rec->attendee_list) == 0)
- {
- rec->has_attendee = 0;
- }
- break;
- case CAL_PROPERTY_TODO_EXTENDED:
- rec->extended_list = g_list_remove(rec->extended_list,child_record);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
+ cal_todo_s *rec = (cal_todo_s *)record;
+
+ switch (property_id) {
+ case CAL_PROPERTY_TODO_CALENDAR_ALARM:
+ ret = calendar_list_remove((calendar_list_h)rec->alarm_list, child_record);
+ if (rec->alarm_list->count == 0)
+ rec->has_alarm = 0;
+ break;
+ case CAL_PROPERTY_TODO_CALENDAR_ATTENDEE:
+ ret = calendar_list_remove((calendar_list_h)rec->attendee_list, child_record);
+ if (rec->attendee_list->count == 0)
+ rec->has_attendee = 0;
+ break;
+ case CAL_PROPERTY_TODO_EXTENDED:
+ ret = calendar_list_remove((calendar_list_h)rec->extended_list, child_record);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return ret;
}
static int __cal_record_todo_get_child_record_count( calendar_record_h record, unsigned int property_id , unsigned int* count )
{
- cal_todo_s *rec = (cal_todo_s*)(record);
- *count = 0;
-
- switch( property_id )
- {
- case CAL_PROPERTY_TODO_CALENDAR_ALARM:
- if (rec->alarm_list)
- {
- *count = g_list_length(rec->alarm_list);
- }
- break;
- case CAL_PROPERTY_TODO_CALENDAR_ATTENDEE:
- if (rec->attendee_list)
- {
- *count = g_list_length(rec->attendee_list);
- }
- break;
- case CAL_PROPERTY_TODO_EXTENDED:
- if (rec->extended_list)
- {
- *count = g_list_length(rec->extended_list);
- }
- break;
- default:
- *count = 0;
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
+ cal_todo_s *rec = (cal_todo_s *)record;
+
+ retv_if(NULL == count, CALENDAR_ERROR_INVALID_PARAMETER);
+ *count = 0;
+
+ switch (property_id) {
+ case CAL_PROPERTY_TODO_CALENDAR_ALARM:
+ ret = calendar_list_get_count((calendar_list_h)rec->alarm_list, (int *)count);
+ break;
+ case CAL_PROPERTY_TODO_CALENDAR_ATTENDEE:
+ ret = calendar_list_get_count((calendar_list_h)rec->attendee_list, (int *)count);
+ break;
+ case CAL_PROPERTY_TODO_EXTENDED:
+ ret = calendar_list_get_count((calendar_list_h)rec->extended_list, (int *)count);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return ret;
}
static int __cal_record_todo_get_child_record_at_p( calendar_record_h record, unsigned int property_id, int index, calendar_record_h* child_record )
{
- cal_todo_s *rec = (cal_todo_s*)(record);
-
- switch( property_id )
- {
- case CAL_PROPERTY_TODO_CALENDAR_ALARM:
- *child_record = g_list_nth_data(rec->alarm_list,index);
- break;
- case CAL_PROPERTY_TODO_CALENDAR_ATTENDEE:
- *child_record = g_list_nth_data(rec->attendee_list,index);
- break;
- case CAL_PROPERTY_TODO_EXTENDED:
- *child_record = g_list_nth_data(rec->extended_list,index);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ int ret;
+ cal_todo_s *rec = (cal_todo_s*)(record);
+
+ retv_if(NULL == child_record, CALENDAR_ERROR_INVALID_PARAMETER);
+ *child_record = NULL;
+
+ switch (property_id) {
+ case CAL_PROPERTY_TODO_CALENDAR_ALARM:
+ ret = _cal_list_get_nth_record_p(rec->alarm_list, index, child_record);
+ break;
+ case CAL_PROPERTY_TODO_CALENDAR_ATTENDEE:
+ ret = _cal_list_get_nth_record_p(rec->attendee_list, index, child_record);
+ break;
+ case CAL_PROPERTY_TODO_EXTENDED:
+ ret = _cal_list_get_nth_record_p(rec->extended_list, index, child_record);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return ret;
}
static int __cal_record_todo_clone_child_record_list( calendar_record_h record, unsigned int property_id, calendar_list_h* out_list )
{
- cal_todo_s *rec = (cal_todo_s*)(record);
- int ret = CALENDAR_ERROR_NONE;
- calendar_list_h list;
- int count = 0;
-
- ret = calendar_list_create(&list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_list_create fail");
- return ret;
- }
-
- switch( property_id )
- {
- case CAL_PROPERTY_TODO_CALENDAR_ALARM:
- {
- count = g_list_length(rec->alarm_list);
- if (count <=0 )
- {
- calendar_list_destroy(list, true);
- return CALENDAR_ERROR_NO_DATA;
- }
- GList *alarm_list = rec->alarm_list;
- calendar_record_h alarm_child_record;
- calendar_record_h alarm_record = NULL;
- while (alarm_list)
- {
- alarm_child_record = (calendar_record_h)alarm_list->data;
- if (alarm_child_record == NULL)
- {
- alarm_list = g_list_next(alarm_list);
- continue;
- }
-
- if ( calendar_record_clone(alarm_child_record,&alarm_record) == CALENDAR_ERROR_NONE )
- {
- calendar_list_add(list,alarm_record);
- }
- alarm_record = NULL;
-
- alarm_list = g_list_next(alarm_list);
- }
- *out_list = (calendar_list_h)list;
- }
- break;
- case CAL_PROPERTY_TODO_CALENDAR_ATTENDEE:
- {
- count = g_list_length(rec->attendee_list);
- if (count <=0 )
- {
- calendar_list_destroy(list, true);
- return CALENDAR_ERROR_NO_DATA;
- }
- GList *attendee_list = rec->attendee_list;
- calendar_record_h attendee_child_record;
- calendar_record_h attendee_record = NULL;
- while (attendee_list)
- {
- attendee_child_record = (calendar_record_h)attendee_list->data;
- if (attendee_child_record == NULL)
- {
- attendee_list = g_list_next(attendee_list);
- continue;
- }
-
- if ( calendar_record_clone(attendee_child_record,&attendee_record) == CALENDAR_ERROR_NONE )
- {
- calendar_list_add(list,attendee_record);
- }
- attendee_record = NULL;
-
- attendee_list = g_list_next(attendee_list);
- }
- *out_list = (calendar_list_h)list;
- }
- break;
- case CAL_PROPERTY_TODO_EXTENDED:
- {
- count = g_list_length(rec->extended_list);
- if (count <=0 )
- {
- calendar_list_destroy(list, true);
- return CALENDAR_ERROR_NO_DATA;
- }
- GList *extended_list = rec->extended_list;
- calendar_record_h child_record;
- calendar_record_h record = NULL;
- while (extended_list)
- {
- child_record = (calendar_record_h)extended_list->data;
- if (child_record == NULL)
- {
- extended_list = g_list_next(extended_list);
- continue;
- }
-
- if ( calendar_record_clone(child_record,&record) == CALENDAR_ERROR_NONE )
- {
- calendar_list_add(list,record);
- }
- record = NULL;
-
- extended_list = g_list_next(extended_list);
- }
- *out_list = (calendar_list_h)list;
- }
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ int ret;
+ cal_todo_s *rec = (cal_todo_s*)(record);
+
+ retv_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER);
+ *out_list = NULL;
+
+ switch (property_id) {
+ case CAL_PROPERTY_TODO_CALENDAR_ALARM:
+ ret = _cal_list_clone((calendar_list_h)rec->alarm_list, out_list);
+ break;
+ case CAL_PROPERTY_TODO_CALENDAR_ATTENDEE:
+ ret = _cal_list_clone((calendar_list_h)rec->attendee_list, out_list);
+ break;
+ case CAL_PROPERTY_TODO_EXTENDED:
+ ret = _cal_list_clone((calendar_list_h)rec->extended_list, out_list);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)", property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return ret;
}
static int __cal_record_updated_info_set_int( calendar_record_h record, unsigned int property_id, int value );
cal_record_plugin_cb_s _cal_record_updated_info_plugin_cb = {
- .create = __cal_record_updated_info_create,
- .destroy = __cal_record_updated_info_destroy,
- .clone = __cal_record_updated_info_clone,
- .get_str = NULL,
- .get_str_p = NULL,
- .get_int = __cal_record_updated_info_get_int,
- .get_double = NULL,
- .get_lli = NULL,
- .get_caltime = NULL,
- .set_str = NULL,
- .set_int = __cal_record_updated_info_set_int,
- .set_double = NULL,
- .set_lli = NULL,
- .set_caltime = NULL,
- .add_child_record = NULL,
- .remove_child_record = NULL,
- .get_child_record_count = NULL,
- .get_child_record_at_p = NULL,
- .clone_child_record_list = NULL
+ .create = __cal_record_updated_info_create,
+ .destroy = __cal_record_updated_info_destroy,
+ .clone = __cal_record_updated_info_clone,
+ .get_str = NULL,
+ .get_str_p = NULL,
+ .get_int = __cal_record_updated_info_get_int,
+ .get_double = NULL,
+ .get_lli = NULL,
+ .get_caltime = NULL,
+ .set_str = NULL,
+ .set_int = __cal_record_updated_info_set_int,
+ .set_double = NULL,
+ .set_lli = NULL,
+ .set_caltime = NULL,
+ .add_child_record = NULL,
+ .remove_child_record = NULL,
+ .get_child_record_count = NULL,
+ .get_child_record_at_p = NULL,
+ .clone_child_record_list = NULL
};
static int __cal_record_updated_info_create( calendar_record_h* out_record )
{
- cal_updated_info_s *temp = NULL;
- int ret= CALENDAR_ERROR_NONE, type = 0;
+ cal_updated_info_s *temp = NULL;
+ int ret= CALENDAR_ERROR_NONE;
- type = CAL_RECORD_TYPE_UPDATED_INFO;
+ temp = (cal_updated_info_s*)calloc(1,sizeof(cal_updated_info_s));
+ retvm_if(NULL == temp, CALENDAR_ERROR_OUT_OF_MEMORY, "malloc(cal_updated_info_s:sch) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
- temp = (cal_updated_info_s*)calloc(1,sizeof(cal_updated_info_s));
- retvm_if(NULL == temp, CALENDAR_ERROR_OUT_OF_MEMORY, "malloc(cal_updated_info_s:sch) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
+ *out_record = (calendar_record_h)temp;
- *out_record = (calendar_record_h)temp;
-
- return ret;
+ return ret;
}
static int __cal_record_updated_info_destroy( calendar_record_h record, bool delete_child )
{
- int ret = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
- cal_updated_info_s *temp = (cal_updated_info_s*)(record);
+ cal_updated_info_s *temp = (cal_updated_info_s*)(record);
- CAL_FREE(temp);
+ CAL_FREE(temp);
- return ret;
+ return ret;
}
static int __cal_record_updated_info_clone( calendar_record_h record, calendar_record_h* out_record )
{
- cal_updated_info_s *out_data = NULL;
- cal_updated_info_s *src_data = NULL;
+ cal_updated_info_s *out_data = NULL;
+ cal_updated_info_s *src_data = NULL;
- src_data = (cal_updated_info_s*)(record);
+ src_data = (cal_updated_info_s*)(record);
- out_data = calloc(1, sizeof(cal_updated_info_s));
- retvm_if(NULL == out_data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_updated_info_s) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
+ out_data = calloc(1, sizeof(cal_updated_info_s));
+ retvm_if(NULL == out_data, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc(cal_updated_info_s) Failed(%d)", CALENDAR_ERROR_OUT_OF_MEMORY);
- CAL_RECORD_COPY_COMMON(&(out_data->common), &(src_data->common));
+ CAL_RECORD_COPY_COMMON(&(out_data->common), &(src_data->common));
- out_data->type = src_data->type;
- out_data->id = src_data->id;
- out_data->calendar_id = src_data->calendar_id;
- out_data->version = src_data->version;
+ out_data->type = src_data->type;
+ out_data->id = src_data->id;
+ out_data->calendar_id = src_data->calendar_id;
+ out_data->version = src_data->version;
- *out_record = (calendar_record_h)out_data;
+ *out_record = (calendar_record_h)out_data;
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_updated_info_get_int( calendar_record_h record, unsigned int property_id, int* out_value )
{
- cal_updated_info_s *rec = (cal_updated_info_s*)(record);
-
- switch( property_id )
- {
- case CAL_PROPERTY_UPDATED_INFO_ID:
- *out_value = (rec->id);
- break;
- case CAL_PROPERTY_UPDATED_INFO_CALENDAR_ID:
- *out_value = (rec->calendar_id);
- break;
- case CAL_PROPERTY_UPDATED_INFO_TYPE:
- *out_value = (rec->type);
- break;
- case CAL_PROPERTY_UPDATED_INFO_VERSION:
- *out_value = (rec->version);
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_updated_info_s *rec = (cal_updated_info_s*)(record);
+
+ switch( property_id )
+ {
+ case CAL_PROPERTY_UPDATED_INFO_ID:
+ *out_value = (rec->id);
+ break;
+ case CAL_PROPERTY_UPDATED_INFO_CALENDAR_ID:
+ *out_value = (rec->calendar_id);
+ break;
+ case CAL_PROPERTY_UPDATED_INFO_TYPE:
+ *out_value = (rec->type);
+ break;
+ case CAL_PROPERTY_UPDATED_INFO_VERSION:
+ *out_value = (rec->version);
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_record_updated_info_set_int( calendar_record_h record, unsigned int property_id, int value )
{
- cal_updated_info_s *rec = (cal_updated_info_s*)(record);
- switch( property_id )
- {
- case CAL_PROPERTY_UPDATED_INFO_ID:
- (rec->id) = value;
- break;
- case CAL_PROPERTY_UPDATED_INFO_CALENDAR_ID:
- (rec->calendar_id) = value;
- break;
- case CAL_PROPERTY_UPDATED_INFO_TYPE:
- (rec->type) = value;
- break;
- case CAL_PROPERTY_UPDATED_INFO_VERSION:
- (rec->version) = value;
- break;
- default:
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_updated_info_s *rec = (cal_updated_info_s*)(record);
+ switch( property_id )
+ {
+ case CAL_PROPERTY_UPDATED_INFO_ID:
+ (rec->id) = value;
+ break;
+ case CAL_PROPERTY_UPDATED_INFO_CALENDAR_ID:
+ (rec->calendar_id) = value;
+ break;
+ case CAL_PROPERTY_UPDATED_INFO_TYPE:
+ (rec->type) = value;
+ break;
+ case CAL_PROPERTY_UPDATED_INFO_VERSION:
+ (rec->version) = value;
+ break;
+ default:
+ ERR("invalid parameter (property:%d)",property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
#include <string.h>
#include <stdlib.h>
+#include <unistd.h>
#include <unicode/utypes.h>
#include <unicode/ucal.h>
#include <unicode/uloc.h>
#include <unicode/ustdio.h>
#include <unicode/udat.h>
#include <unicode/rbtz.h>
+#include <unicode/uclean.h>
-#include "calendar2.h"
+#include "calendar.h"
#include "cal_internal.h"
#include "cal_typedef.h"
#define ms2sec(ms) (long long int)(ms / 1000.0)
#define sec2ms(s) (s * 1000.0)
+static UCalendar *_g_ucal_gmt = NULL;
+
int _cal_time_is_registered_tzid(const char *tzid)
{
- int is_found = 0;
+ int is_found = false;
int i;
UErrorCode ec = U_ZERO_ERROR;
if (NULL == tzid)
{
ERR("tzid is NULL");
- return is_found;
+ return false;
}
StringEnumeration* s = TimeZone::createEnumeration();
unicode_tzid->extract(buf, sizeof(buf), NULL, ec);
if (!strncmp(tzid, buf, strlen(buf)))
{
- is_found = 1;
+ is_found = true;
break;
}
}
return is_found;
}
+void _cal_time_get_registered_tzid_with_offset(int offset, char *registered_tzid, int tzid_size) // offset unit: second
+{
+ UErrorCode ec = U_ZERO_ERROR;
+
+ retm_if (NULL == registered_tzid, "Invalid parameter: registered_tzid is NULL");
+
+ StringEnumeration* s = TimeZone::createEnumeration(sec2ms(offset));
+ if (0 == s->count(ec)) {
+ DBG("No tzid of offset(%d)sec", offset);
+ return;
+ }
+
+ const UnicodeString *unicode_tzid = s->snext(ec);
+ unicode_tzid->extract(registered_tzid, tzid_size, NULL, ec);
+ delete s;
+}
+
int _cal_time_get_timezone_from_table(const char *tzid, calendar_record_h *timezone, int *timezone_id)
{
int ret = CALENDAR_ERROR_NONE;
if (NULL == tzid || strlen(tzid) == 0)
{
- ERR("tzid is NULL");
+ DBG("tzid is NULL");
return CALENDAR_ERROR_INVALID_PARAMETER;
}
if (tz->day_light_bias == 0)
{
char buf[128] = {0};
- snprintf(buf, sizeof(buf), "ETC/GMT%c%d",
- gmtoffset < 0 ? '-' : '+',
+ snprintf(buf, sizeof(buf), "Etc/GMT%c%d",
+ gmtoffset < 0 ? '+' : '-',
tz->tz_offset_from_gmt / 60);
DBG("No dayligit, set like tzid[%s]", buf);
*like_tzid = strdup(buf);
return CALENDAR_ERROR_NONE;
}
-UCalendar *_cal_time_get_ucal(const char *tzid, int wkst)
+UCalendar *_cal_time_open_ucal(int calendar_system_type, const char *tzid, int wkst)
{
- int ret = CALENDAR_ERROR_NONE;
- char *like_tzid = NULL;
- UCalendar *ucal = NULL;
+ UChar utf16_timezone[64] = {0};
+ u_uastrncpy(utf16_timezone, tzid, sizeof(utf16_timezone));
+
UErrorCode status = U_ZERO_ERROR;
- UChar *utzid = NULL;
+ UCalendar *ucal = NULL;
- if (tzid == NULL)
+ char localeBuf[ULOC_LOCALE_IDENTIFIER_CAPACITY] = {0};
+
+ switch (calendar_system_type)
{
- DBG("tzid is NULL so set gmt");
- tzid = CAL_TZID_GMT;
+ case CALENDAR_SYSTEM_EAST_ASIAN_LUNISOLAR:
+ uloc_setKeywordValue("calendar", "chinese", localeBuf, ULOC_LOCALE_IDENTIFIER_CAPACITY, &status);
+ ucal = ucal_open(utf16_timezone, -1, localeBuf, UCAL_TRADITIONAL, &status);
+ break;
+
+ default: // include CALENDAR_SYSTEM_NONE, CALENDAR_SYSTEM_GREGORIAN
+ ucal = ucal_open(utf16_timezone, -1, uloc_getDefault(), UCAL_GREGORIAN, &status);
+ break;
}
- utzid = (UChar*)calloc(strlen(tzid) + 1, sizeof(UChar));
- if (utzid == NULL)
- {
- ERR("Failed to calloc");
+ if (U_FAILURE(status)) {
+ ERR("ucal_open failed (%s)", u_errorName(status));
return NULL;
}
- u_uastrcpy(utzid, tzid);
- if (_cal_time_is_registered_tzid(tzid) == 0)
+ if (wkst >= CALENDAR_SUNDAY && wkst <= CALENDAR_SATURDAY)
{
- DBG("Not registered tzid so try to find from timezone table");
+ DBG("set wkst(%d)", wkst);
+ ucal_setAttribute(ucal, UCAL_FIRST_DAY_OF_WEEK, wkst);
+ }
- calendar_record_h timezone = NULL;
- ret = _cal_time_get_timezone_from_table(tzid, &timezone, NULL);
- if (ret == CALENDAR_ERROR_NONE)
- {
- DBG("Found something in the timezone table");
- ret = __cal_time_get_like_utzid(utzid, u_strlen(utzid), tzid, timezone, &like_tzid);
- if (ret != CALENDAR_ERROR_NONE)
- {
- DBG("Failed to find matched tzid with the found tzid, so set GMT");
- like_tzid = strdup(CAL_TZID_GMT);
- }
- DBG("Found matched tzid with the found tzid[%s]", like_tzid);
- }
- else
- {
- ERR("Failed to find timezone from table with this tzid[%s], so set gmt", tzid);
- like_tzid = strdup(CAL_TZID_GMT);
- }
- CAL_FREE(utzid);
+ return ucal;
+}
- DBG("[%s]", like_tzid);
- utzid = (UChar*)calloc(strlen(like_tzid) + 1, sizeof(UChar));
- if (utzid == NULL)
- {
- ERR("Failed to calloc");
- CAL_FREE(like_tzid);
- return NULL;
- }
- u_uastrcpy(utzid, like_tzid);
- CAL_FREE(like_tzid);
- }
- else
- {
- DBG("This tzid is valid");
- }
+UCalendar *_cal_time_get_ucal(const char *tzid, int wkst)
+{
+ UChar utf16_timezone[64] = {0};
+ u_uastrncpy(utf16_timezone, tzid, sizeof(utf16_timezone));
- // get ucal
- ucal = ucal_open(utzid, u_strlen(utzid), "en_US", UCAL_TRADITIONAL, &status);
+ UErrorCode status = U_ZERO_ERROR;
+ UCalendar *ucal = NULL;
+ ucal = ucal_open(utf16_timezone, -1, uloc_getDefault(), UCAL_GREGORIAN, &status);
if (U_FAILURE(status)) {
ERR("ucal_open failed (%s)", u_errorName(status));
- CAL_FREE(utzid);
return NULL;
}
- CAL_FREE(utzid);
if (wkst >= CALENDAR_SUNDAY && wkst <= CALENDAR_SATURDAY)
{
- DBG("set wkst(%d)", wkst);
ucal_setAttribute(ucal, UCAL_FIRST_DAY_OF_WEEK, wkst);
}
break;
case CALENDAR_TIME_LOCALTIME:
- ucal_setDate(ucal,
+ ucal_setDateTime(ucal,
ct->time.date.year,
ct->time.date.month -1,
ct->time.date.mday,
+ ct->time.date.hour,
+ ct->time.date.minute,
+ ct->time.date.second,
&status);
retm_if(U_FAILURE(status), "ucal_setMillis() failed(%s)",
u_errorName(status));
}
}
-char * _cal_time_extract_by(const char *tzid, int wkst, calendar_time_s *ct, int field)
+char* _cal_time_extract_by(int calendar_system_type, const char *tzid, int wkst, calendar_time_s *ct, int field)
{
int vali;
char buf[8] = {0};
UCalendar *ucal = NULL;
UErrorCode status = U_ZERO_ERROR;
- ucal = _cal_time_get_ucal(tzid, wkst);
+ ucal = _cal_time_open_ucal(calendar_system_type, tzid, wkst);
+ if (NULL == ucal) {
+ ERR("_cal_time_open_ucal() is failed");
+ return NULL;
+ }
_cal_time_set_caltime(ucal, ct);
switch (field)
break;
}
+ ucal_close(ucal);
return strdup(buf);
}
-char * _cal_time_convert_ltos(const char *tzid, long long int lli)
+char* _cal_time_convert_ltos(const char *tzid, long long int lli, int is_allday)
{
int y, mon, d, h, min, s;
char buf[32] = {0};
ucal_setMillis(ucal, sec2ms(lli), &status);
if (U_FAILURE(status)) {
ERR("ucal_setMillis failed (%s)", u_errorName(status));
+ ucal_close(ucal);
return NULL;
}
if (!strncmp(tzid, CAL_TZID_GMT, strlen(CAL_TZID_GMT)))
{
- snprintf(buf, sizeof(buf), "%04d%02d%02dT%02d%02d%02dZ",
- y, mon, d, h, min, s);
+ snprintf(buf, sizeof(buf), "%04d%02d%02dT%02d%02d%02d%s", y, mon, d, h, min, s,
+ is_allday ? "" : "Z");
}
else
{
- snprintf(buf, sizeof(buf), "%04d%02d%02dT%02d%02d%02d",
- y, mon, d, h, min, s);
+ snprintf(buf, sizeof(buf), "%04d%02d%02dT%02d%02d%02d", y, mon, d, h, min, s);
}
ucal_close(ucal);
int temp = 0;
int temp2 = 0;
temp = ucal_get(ucal, UCAL_DAY_OF_WEEK_IN_MONTH, &status);
- ucal_add(ucal, UCAL_DATE, 7, &status);
+ ucal_add(ucal, UCAL_DAY_OF_YEAR, 7, &status);
temp2 = ucal_get(ucal, UCAL_DAY_OF_WEEK_IN_MONTH, &status);
DBG("temp(%d) temp2(%d)", temp, temp2);
*nth = temp2 == 1 ? -1 : temp;
return ms2sec(ucal_getNow());
}
+int _cal_time_get_next_date(calendar_time_s *today, calendar_time_s *next)
+{
+ if (NULL == today || NULL == next)
+ {
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ UCalendar *ucal = NULL;
+ UErrorCode status = U_ZERO_ERROR;
+ UChar *utzid = NULL;
+ const char *tzid = CAL_TZID_GMT;
+
+ utzid = (UChar*)calloc(strlen(tzid) + 1, sizeof(UChar));
+ if (utzid == NULL)
+ {
+ ERR("Failed to calloc");
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+ u_uastrcpy(utzid, tzid);
+ ucal = ucal_open(utzid, u_strlen(utzid), "en_US", UCAL_TRADITIONAL, &status);
+ if (U_FAILURE(status)) {
+ ERR("ucal_open failed (%s)", u_errorName(status));
+ CAL_FREE(utzid);
+ return status;
+ }
+
+ switch (today->type)
+ {
+ case CALENDAR_TIME_UTIME:
+
+ break;
+
+ case CALENDAR_TIME_LOCALTIME:
+ ucal_setDateTime(ucal,
+ today->time.date.year,
+ today->time.date.month-1,
+ today->time.date.mday,
+ today->time.date.hour,
+ today->time.date.minute,
+ today->time.date.second,
+ &status);
+ DBG("today %04d/%02d/%02d %02d:%02d:%02d",
+ today->time.date.year, today->time.date.month, today->time.date.mday,
+ today->time.date.hour, today->time.date.minute, today->time.date.second);
+ ucal_add(ucal, UCAL_DAY_OF_YEAR, 1, &status);
+ next->time.date.year = ucal_get(ucal, UCAL_YEAR, &status);
+ next->time.date.month = ucal_get(ucal, UCAL_MONTH, &status) + 1;
+ next->time.date.mday = ucal_get(ucal, UCAL_DATE, &status);
+ next->time.date.hour = ucal_get(ucal, UCAL_HOUR_OF_DAY, &status);
+ next->time.date.minute = ucal_get(ucal, UCAL_MINUTE, &status);
+ next->time.date.second = ucal_get(ucal, UCAL_SECOND, &status);
+ DBG("next %04d/%02d/%02d %02d:%02d:%02d",
+ next->time.date.year, next->time.date.month, next->time.date.mday,
+ next->time.date.hour, next->time.date.minute, next->time.date.second);
+ break;
+ }
+
+ CAL_FREE(utzid);
+
+ return CALENDAR_ERROR_NONE;
+}
+
+int _cal_time_get_next_time(UCalendar *ucal, int offset, int freq, calendar_time_s *next)
+{
+ UErrorCode status = U_ZERO_ERROR;
+ if (NULL == next)
+ {
+ ERR("Invalid parameter: next is NULL");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ switch (next->type)
+ {
+ case CALENDAR_TIME_UTIME:
+ ucal_setMillis(ucal, sec2ms(next->time.utime), &status);
+ break;
+
+ case CALENDAR_TIME_LOCALTIME:
+ ucal_setDateTime(ucal,
+ next->time.date.year,
+ next->time.date.month - 1,
+ next->time.date.mday,
+ next->time.date.hour,
+ next->time.date.minute,
+ next->time.date.second,
+ &status);
+ break;
+ }
+
+ UCalendarDateFields unit = UCAL_DATE;
+ switch (freq)
+ {
+ case CALENDAR_RECURRENCE_YEARLY:
+ DBG("CALENDAR_RECURRENCE_YEARLY:");
+ unit = UCAL_YEAR;
+ break;
+ case CALENDAR_RECURRENCE_MONTHLY:
+ DBG("CALENDAR_RECURRENCE_MONTHLY:");
+ unit = UCAL_MONTH;
+ break;
+ case CALENDAR_RECURRENCE_WEEKLY:
+ DBG("CALENDAR_RECURRENCE_WEEKLY:");
+ unit = UCAL_WEEK_OF_YEAR;
+ break;
+ case CALENDAR_RECURRENCE_DAILY:
+ DBG("CALENDAR_RECURRENCE_DAILY:");
+ unit = UCAL_DATE;
+ break;
+ default:
+ ERR("Invalid unit");
+ break;
+ }
+ ucal_add(ucal, unit, offset, &status);
+
+ switch (next->type)
+ {
+ case CALENDAR_TIME_UTIME:
+ next->time.utime = ms2sec(ucal_getMillis(ucal, &status));
+ DBG("next utime(%lld)", next->time.utime);
+ break;
+
+ case CALENDAR_TIME_LOCALTIME:
+ next->time.date.year = ucal_get(ucal, UCAL_YEAR, &status);
+ next->time.date.month = ucal_get(ucal, UCAL_MONTH, &status) + 1;
+ next->time.date.mday = ucal_get(ucal, UCAL_DATE, &status);
+ next->time.date.hour = ucal_get(ucal, UCAL_HOUR_OF_DAY, &status);
+ next->time.date.minute = ucal_get(ucal, UCAL_MINUTE, &status);
+ next->time.date.second = ucal_get(ucal, UCAL_SECOND, &status);
+ DBG("next date(%04d/%02d/%02d %02d:%02d:%02d)",
+ next->time.date.year, next->time.date.month, next->time.date.mday,
+ next->time.date.hour, next->time.date.minute, next->time.date.second);
+ break;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+/*
+ * Read link of /opt/etc/localtime,
+ * and get timezone "Asia/Seoul" from the string (ig. "/usr/share/zoneinfo/Asia/Seoul")
+ */
+char* _cal_time_get_timezone(void)
+{
+ char buf[256] = {0};
+ ssize_t len = readlink("/opt/etc/localtime", buf, sizeof(buf)-1);
+ if (-1 == len)
+ {
+ ERR("readlink() failed");
+ return NULL;
+ }
+ buf[len] = '\0';
+ return g_strdup(buf + strlen("/usr/share/zoneinfo/"));
+}
+
+long long int _cal_time_get_utime(UCalendar *ucal, int y, int mon, int d, int h, int min, int s)
+{
+ UErrorCode status = U_ZERO_ERROR;
+ if (ucal)
+ {
+ ucal_set(ucal, UCAL_YEAR, y);
+ ucal_set(ucal, UCAL_MONTH, mon -1);
+ ucal_set(ucal, UCAL_DATE, d);
+ ucal_set(ucal, UCAL_HOUR_OF_DAY, h);
+ ucal_set(ucal, UCAL_MINUTE, min);
+ ucal_set(ucal, UCAL_SECOND, s);
+ ucal_set(ucal, UCAL_MILLISECOND, 0);
+ return ms2sec(ucal_getMillis(ucal, &status));
+ }
+ return 0;
+}
+
+int _cal_time_get_component_from_lli(UCalendar *ucal, long long int lli, int *year, int *month, int *mday, int *hour, int *minute, int *second)
+{
+ UErrorCode status = U_ZERO_ERROR;
+
+ ucal_setMillis(ucal, sec2ms(lli), &status);
+
+ if (year) *year = ucal_get(ucal, UCAL_YEAR, &status);
+ if (month) *month = ucal_get(ucal, UCAL_MONTH, &status) +1;
+ if (mday) *mday = ucal_get(ucal, UCAL_DATE, &status);
+ if (hour) *hour = ucal_get(ucal, UCAL_DATE, &status);
+ if (minute) *minute = ucal_get(ucal, UCAL_DATE, &status);
+ if (second) *second = ucal_get(ucal, UCAL_DATE, &status);
+
+ return CALENDAR_ERROR_NONE;
+}
+
+void _cal_time_u_cleanup(void)
+{
+ u_cleanup();
+}
+
+void _cal_time_get_tz_offset(const char *tz, time_t *zone_offset, time_t *dst_offset)
+{
+ UErrorCode status = U_ZERO_ERROR;
+ UCalendar *ucal = NULL;
+
+ ucal = _cal_time_get_ucal(tz, -1);
+ int32_t zone = ucal_get(ucal, UCAL_ZONE_OFFSET, &status);
+ int32_t dst = ucal_get(ucal, UCAL_DST_OFFSET, &status);
+ ucal_close(ucal);
+
+ if (zone_offset) *zone_offset = ms2sec(zone);
+ if (dst_offset) *dst_offset = ms2sec(dst);
+}
+
+bool _cal_time_in_dst(const char *tz, long long int t)
+{
+ UErrorCode status = U_ZERO_ERROR;
+ UCalendar *ucal = NULL;
+
+ ucal = _cal_time_get_ucal(tz, -1);
+ ucal_setMillis(ucal, sec2ms(t), &status);
+ bool is_dst = ucal_inDaylightTime(ucal, &status);
+ ucal_close(ucal);
+
+ return is_dst;
+}
+
+int _cal_time_init(void)
+{
+ UCalendar *ucal = NULL;
+
+ if (NULL == _g_ucal_gmt) {
+ ucal = _cal_time_get_ucal(NULL, -1);
+ retvm_if (NULL == ucal, CALENDAR_ERROR_SYSTEM, "_cal_time_get_ucal() is failed");
+ _g_ucal_gmt = ucal;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+void _cal_time_fini(void)
+{
+ if (_g_ucal_gmt) {
+ ucal_close(_g_ucal_gmt);
+ _g_ucal_gmt = NULL;
+ }
+}
+
+static UCalendar* __get_gmt_ucal(void)
+{
+ if (NULL == _g_ucal_gmt) {
+ _cal_time_init();
+ }
+ return _g_ucal_gmt;
+}
+
+long long int _cal_time_convert_lli(char *p)
+{
+ UErrorCode status = U_ZERO_ERROR;
+
+ if (p && *p) {
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
+ sscanf(p, "%04d%02d%02dT%02d%02d%02dZ", &y, &m, &d, &h, &n, &s);
+
+ UCalendar *ucal = __get_gmt_ucal();
+ ucal_setDateTime(ucal, y, m -1, d, h, n, s, &status);
+ return ms2sec(ucal_getMillis(ucal, &status));
+ }
+ return 0;
+}
+
+void _cal_time_modify_caltime(calendar_time_s *caltime, long long int diff)
+{
+ UErrorCode status = U_ZERO_ERROR;
+ retm_if (NULL == caltime, "Invalid parameter: caltime is NULL");
+
+ UCalendar *ucal = __get_gmt_ucal();
+ long long int lli = 0;
+ switch (caltime->type)
+ {
+ case CALENDAR_TIME_UTIME:
+ DBG("Before (%lld)", caltime->time.utime);
+ caltime->time.utime += diff;
+ DBG("After (%lld)", caltime->time.utime);
+ break;
+
+ case CALENDAR_TIME_LOCALTIME:
+ DBG("Before %04d%02d%02dT%02d%02d%02d%s", caltime->time.date.year, caltime->time.date.month, caltime->time.date.mday,
+ caltime->time.date.hour, caltime->time.date.minute, caltime->time.date.second);
+
+ ucal_setDateTime(ucal, caltime->time.date.year, caltime->time.date.month - 1, caltime->time.date.mday,
+ caltime->time.date.hour, caltime->time.date.minute, caltime->time.date.second, &status);
+ lli = ms2sec(ucal_getMillis(ucal, &status));
+ lli += diff;
+ ucal_setMillis(ucal, sec2ms(lli), &status);
+ caltime->time.date.year = ucal_get(ucal, UCAL_YEAR, &status);
+ caltime->time.date.month = ucal_get(ucal, UCAL_MONTH, &status) + 1;
+ caltime->time.date.mday = ucal_get(ucal, UCAL_DATE, &status);
+ caltime->time.date.hour = ucal_get(ucal, UCAL_HOUR_OF_DAY, &status);
+ caltime->time.date.minute = ucal_get(ucal, UCAL_MINUTE, &status);
+ caltime->time.date.second = ucal_get(ucal, UCAL_SECOND, &status);
+
+ DBG("After %04d%02d%02dT%02d%02d%02d%s", caltime->time.date.year, caltime->time.date.month, caltime->time.date.mday,
+ caltime->time.date.hour, caltime->time.date.minute, caltime->time.date.second);
+ break;
+ }
+}
+
+void _cal_time_get_nth_wday(long long int t, int *nth, int *wday)
+{
+ retm_if (NULL == nth, "Invalid parameter: nth is NULL");
+ retm_if (NULL == wday, "Invalid parameter: wday is NULL");
+
+ UErrorCode status = U_ZERO_ERROR;
+ UCalendar *ucal = __get_gmt_ucal();
+ ucal_setMillis(ucal, sec2ms(t), &status);
+ *wday = ucal_get(ucal, UCAL_DAY_OF_WEEK, &status);
+ // check if nth is last
+ int this_week = ucal_get(ucal, UCAL_DAY_OF_WEEK_IN_MONTH, &status);
+ ucal_add(ucal, UCAL_DAY_OF_YEAR, 7, &status);
+ int next_week = ucal_get(ucal, UCAL_DAY_OF_WEEK_IN_MONTH, &status);
+ *nth = next_week == 1 ? -1 : this_week;
+ DBG("nth(%d) wday(%d)", *nth, *wday);
+}
+
+void _cal_time_get_datetime(long long int t, int *y, int *m, int *d, int *h, int *n, int *s)
+{
+ UErrorCode status = U_ZERO_ERROR;
+ UCalendar *ucal = __get_gmt_ucal();
+
+ ucal_setMillis(ucal, sec2ms(t), &status);
+ if (y) *y = ucal_get(ucal, UCAL_YEAR, &status);
+ if (m) *m = ucal_get(ucal, UCAL_MONTH, &status) + 1;
+ if (d) *d = ucal_get(ucal, UCAL_DATE, &status);
+ if (h) *h = ucal_get(ucal, UCAL_HOUR_OF_DAY, &status);
+ if (n) *n = ucal_get(ucal, UCAL_MINUTE, &status);
+ if (s) *s = ucal_get(ucal, UCAL_SECOND, &status);
+ DBG("%04d%02d%02dT%02d%02d%02d", *y, *m, *d, *h, *n, *s);
+}
+
+void _cal_time_get_local_datetime(char *tzid, long long int t, int *y, int *m, int *d, int *h, int *n, int *s)
+{
+ UErrorCode status = U_ZERO_ERROR;
+ UCalendar *ucal = _cal_time_get_ucal(tzid, 0);
+ ucal_setMillis(ucal, sec2ms(t), &status);
+ if (y) *y = ucal_get(ucal, UCAL_YEAR, &status);
+ if (m) *m = ucal_get(ucal, UCAL_MONTH, &status) + 1;
+ if (d) *d = ucal_get(ucal, UCAL_DATE, &status);
+ if (h) *h = ucal_get(ucal, UCAL_HOUR_OF_DAY, &status);
+ if (n) *n = ucal_get(ucal, UCAL_MINUTE, &status);
+ if (s) *s = ucal_get(ucal, UCAL_SECOND, &status);
+ ucal_close(ucal);
+}
+
+bool _cal_time_is_available_tzid(char *tzid)
+{
+ UErrorCode ec = U_ZERO_ERROR;
+ StringEnumeration* s = TimeZone::createEnumeration();
+ int32_t s_count = s->count(ec);
+
+ int len = strlen(tzid);
+ int i, j;
+ for (i = 0; i < s_count; i++) {
+ char buf[32] = {0};
+ const UnicodeString *unicode_tzid = s->snext(ec);
+ for (j = 0; j < unicode_tzid->length(); j++) {
+ buf[j] = unicode_tzid->charAt(j);
+ }
+ buf[j] = '\0';
+ if (!strncmp(buf, tzid, len)) {
+ return true;
+ }
+ }
+ return false;
+}
+
#endif
int _cal_time_is_registered_tzid(const char *tzid);
+void _cal_time_get_registered_tzid_with_offset(int offset, char *registered_tzid, int tzid_size);
UCalendar *_cal_time_get_ucal(const char *tzid, int wkst);
-char * _cal_time_extract_by(const char *tzid, int wkst, calendar_time_s *ct, int field);
-char * _cal_time_convert_ltos(const char *tzid, long long int lli);
+char* _cal_time_extract_by(int calendar_system_type, const char *tzid, int wkst, calendar_time_s *ct, int field);
+char* _cal_time_convert_ltos(const char *tzid, long long int lli, int is_allday);
long long int _cal_time_convert_itol(const char *tzid, int y, int m, int d, int h, int min, int s);
int _cal_time_utoi(long long int utime, char *tzid, int *y, int *m, int *d, int *h, int *min, int *s);
long long int _cal_time_convert_stol(char *tzid, char *datetime);
long long int _cal_time_get_now(void);
int _cal_time_get_timezone_from_table(const char *tzid, calendar_record_h *timezone, int *timezone_id);
int _cal_time_get_like_tzid(const char *tzid, calendar_record_h timezone, char **like_tzid);
+int _cal_time_get_next_date(calendar_time_s *today, calendar_time_s *next);
+char* _cal_time_get_timezone(void);
+long long int _cal_time_get_utime(UCalendar *ucal, int y, int mon, int d, int h, int min, int s);
+int _cal_time_get_component_from_lli(UCalendar *ucal, long long int lli, int *year, int *month, int *mday, int *hour, int *minute, int *second);
+int _cal_time_get_next_time(UCalendar *ucal, int offset, int freq, calendar_time_s *next);
+void _cal_time_u_cleanup(void);
+void _cal_time_get_tz_offset(const char *tz, time_t *zone_offset, time_t *dst_offset);
+bool _cal_time_in_dst(const char *tz, long long int t);
+UCalendar* _cal_time_open_ucal(int calendar_system_type, const char *tzid, int wkst);
+int _cal_time_init(void);
+void _cal_time_fini(void);
+long long int _cal_time_convert_lli(char *p);
+void _cal_time_modify_caltime(calendar_time_s *caltime, long long int diff);
+void _cal_time_get_nth_wday(long long int t, int *nth, int *wday);
+void _cal_time_get_datetime(long long int t, int *y, int *m, int *d, int *h, int *n, int *s);
+void _cal_time_get_local_datetime(char *tzid, long long int t, int *y, int *m, int *d, int *h, int *n, int *s);
+bool _cal_time_is_available_tzid(char *tzid);
enum cal_extract_field {
CAL_MONTH,
#define CAL_NOTI_TODO_CHANGED tzplatform_mkpath(TZ_USER_DATA,"calendar-svc/.CALENDAR_SVC_TODO_CHANGED")
#define CAL_NOTI_CALENDAR_CHANGED tzplatform_mkpath(TZ_USER_DATA,"calendar-svc/.CALENDAR_SVC_CALENDAR_CHANGED")
#define CAL_NOTI_REMINDER_CAHNGED "reminder"
+#define CAL_FORMAT_LOCAL_DATETIME "%04d-%02d-%02dT%02d:%02d:%02d"
/**
* @enum cal_priority_e
CAL_PRIORITY_HIGH /**< priority high */
}cal_priority_e;
-///////////calendar-svc-provider.h
-// 우선 기존 동작되는 define, enum 을 가져와서 정리.. 향후 calendar_types.h 로 오픈되어야 하는것과 동일 사용
+typedef enum
+{
+ CAL_PERMISSION_NONE = 0x00,
+ CAL_PERMISSION_READ = 0x01,
+ CAL_PERMISSION_WRITE = 0x02,
+} cal_permission_e;
#define LOCAL_ACCOUNT_ID -1
#define CAL_INVALID_ID (-1)
-/**
- * This enumeration defines lart type.
- */
-typedef enum
-{
- CAL_ALERT_MELODY = 0, /**< alarm type is melody */
- CAL_ALERT_MUTE, /**< alarm type is mute */
- CAL_ALERT_INCREASING_MELODY, /**< alarm type is increasing melody */
- CAL_ALERT_VIBRATION, /**< alarm type is vibrate */
- CAL_ALERT_VIBRATION_THEN_MELODY, /**< alarm type is vibrate then melody */
- CAL_ALERT_VIBMELODY, /**< alarm type is melody with vibrate */
- CAL_ALERT_VIB_INCREASING_MELODY /**< alarm type is increasing melody */
-} cal_alert_type_e;
-/**
- * This enumeration defines Remind Tick Unit for schedule.
- * Ex. remindTick = 1, remindTickUnit = CAL_SCH_TIME_UNIT_MIN, Organizer alarms
- * 1 minute before schedule starting time.
- */
-typedef enum /* use with *60 */
-{
- CAL_SCH_TIME_UNIT_OFF = -1, /**< off */
- CAL_SCH_TIME_UNIT_MIN = 1, /**< Minute */
- CAL_SCH_TIME_UNIT_HOUR = 60, /**< Hour 60 * 60 */
- CAL_SCH_TIME_UNIT_DAY = 1440, /**< Day 60 * 60 *24 */
- CAL_SCH_TIME_UNIT_WEEK = 10080, /**< Week DAY * 7 */
- CAL_SCH_TIME_UNIT_MONTH, /**< Month - will be removed*/
- CAL_SCH_TIME_UNIT_SPECIFIC /**< using alarm time */
-} cal_sch_remind_tick_unit_e;
-
typedef enum
{
- CAL_SCH_TYPE_NONE=0, /**< None type */
- CAL_SCH_TYPE_EVENT, /**< schedule event type */
- CAL_SCH_TYPE_TODO, /**< task event type */
- CAL_SCH_TYPE_MAX, /**< max type */
+ CAL_SCH_TYPE_NONE=0, /**< None type */
+ CAL_SCH_TYPE_EVENT, /**< schedule event type */
+ CAL_SCH_TYPE_TODO, /**< task event type */
+ CAL_SCH_TYPE_MAX, /**< max type */
} cal_sch_type_e;
-/*
-enum cal_freq {
- CAL_FREQ_ONCE = 0x0,
- CAL_FREQ_YEARLY,
- CAL_FREQ_MONTHLY,
- CAL_FREQ_WEEKLY,
- CAL_FREQ_DAILY,
- CAL_FREQ_HOURLY,
- CAL_FREQ_MINUTELY,
- CAL_FREQ_SECONDLY,
-};
-*/
-/////////////////
-
+typedef struct {
+ int count;
+ GList *record;
+ GList *cursor;
+} cal_list_s;
/**
* This structure defines schedule information.
double latitude;
double longitude;
int email_id;
- //int availability;
long long int created_time;
- //long long int completed_time;
- //int progress;
int is_deleted; /**< for sync */
- //int duration;
long long int last_mod;
- //int has_rrule; //int rrule_id;
int freq;
int range_type;
- int until_type;
- long long int until_utime;
- int until_year;
- int until_month;
- int until_mday;
+ calendar_time_s until;
int count;
int interval;
char *bysecond;
char* start_tzid;
calendar_time_s end;
char* end_tzid;
- GList *alarm_list;
- GList *attendee_list; /**< collection of attendee */
-
- GList *exception_list;
- GList *extended_list;
+ int is_allday;
+ cal_list_s *alarm_list;
+ cal_list_s *attendee_list;
+ cal_list_s *exception_list;
+ cal_list_s *extended_list;
}cal_event_s;
typedef struct
int progress;
int is_deleted; /**< for sync */
long long int last_mod;
- //int has_rrule; //int rrule_id;
int freq;
int range_type;
- int until_type;
- long long int until_utime;
- int until_year;
- int until_month;
- int until_mday;
+ calendar_time_s until;
int count;
int interval;
char *bysecond;
char *bysetpos;
int wkst;
int has_alarm;
+ int system_type;
long updated;
char *sync_data1;
char *sync_data2;
char* start_tzid;
calendar_time_s due;
char* due_tzid;
- GList *alarm_list;
- char *organizer_name;
- char *organizer_email;
- int has_attendee;
- GList *attendee_list;
- GList *extended_list;
+ char *organizer_name;
+ char *organizer_email;
+ int has_attendee;
+ int is_allday;
+
+ cal_list_s *alarm_list;
+ cal_list_s *attendee_list;
+ cal_list_s *extended_list;
}cal_todo_s;
typedef struct
{
int freq;
int range_type;
- int until_type;
- long long int until_utime;
- int until_year;
- int until_month;
- int until_mday;
+ calendar_time_s until;
int count;
int interval;
char *bysecond;
typedef struct
{
cal_record_s common;
- int event_id;
+ int id; /* Internal property. Do not add to view_uri property */
+ int parent_id;
char *attendee_number;
- int attendee_type;
+ int attendee_cutype;
int attendee_ct_index;
char *attendee_uid;
- //int is_deleted;
/* ical spec from here */
char *attendee_group; /* cutype */
int attendee_role; /* role */
int attendee_status; /* partstat: ACCEPTED, DECLINED.. */
int attendee_rsvp; /* rsvp */
- char *attendee_delegate_uri; /* delfrom */
+ char *attendee_delegatee_uri; /* delfrom */
char *attendee_delegator_uri; /* delto */
/* sentby */
char *attendee_name; /* cn */
+ char *attendee_member; /* member */
}cal_attendee_s;
typedef struct
{
cal_record_s common;
- int alarm_id; /**< Alarm id */
- int event_id;
- cal_alert_type_e alarm_type; /**< Alert type(see 'cal_alert_type_t') */
+ int id; /* Internal property. Do not add to view_uri property */
+ int parent_id;
int is_deleted;
- /* audio */
- /* -- trigger */
- long long int alarm_time;
int remind_tick;
int remind_tick_unit;
- /* --attach */
- char *alarm_tone; /**< Alert Sound File Name */
- /* display */
char *alarm_description; /**< Alert description */
-
-
- /* email */
-
+ char *alarm_summary;
+ int alarm_action;
+ char *alarm_attach;
+ calendar_time_s alarm;
}cal_alarm_s;
//This is the calendar schema
char *sync_data2;
char *sync_data3;
char *sync_data4;
+ int mode;
} cal_calendar_s;
cal_record_s common;
int event_id;
int calendar_id;
- int dtstart_type;
- long long int dtstart_utime;
- int dtend_type;
- long long int dtend_utime;
+ calendar_time_s start;
+ calendar_time_s end;
char *summary;
char *description;
char *location;
int has_alarm;
int original_event_id;
long long int last_mod;
+ char *sync_data1;
} cal_instance_normal_s;
typedef struct
cal_record_s common;
int event_id;
int calendar_id;
- int dtstart_type;
- int dtstart_year;
- int dtstart_month;
- int dtstart_mday;
- int dtend_type;
- int dtend_year;
- int dtend_month;
- int dtend_mday;
+ calendar_time_s start;
+ calendar_time_s end;
char *summary;
char *description;
char *location;
int has_alarm;
int original_event_id;
long long int last_mod;
+ char *sync_data1;
+ int is_allday;
} cal_instance_allday_s;
-/*
typedef struct
{
- int index;
+ cal_record_s common;
+ int event_id;
int calendar_id;
- int dtstart_type;
- long long int dtstart_utime;
- int dtend_type;
- long long int dtend_utime;
- long long int alarm_utime;
- int alarm_id;
-}cal_instance_normal_alarm_s;
-*/
+ calendar_time_s start;
+ calendar_time_s end;
+ char *summary;
+ char *description;
+ char *location;
+ int busy_status;
+ int event_status;
+ int priority;
+ int sensitivity;
+ int has_rrule; //rrule_id;
+ double latitude;
+ double longitude;
+ int has_alarm;
+ int original_event_id;
+ long long int last_mod;
+ char *organizer_name;
+ char *categories;
+ int has_attendee;
+ char *sync_data1;
+ char *sync_data2;
+ char *sync_data3;
+ char *sync_data4;
+} cal_instance_normal_extended_s;
+
+typedef struct
+{
+ cal_record_s common;
+ int event_id;
+ int calendar_id;
+ calendar_time_s start;
+ calendar_time_s end;
+ char *summary;
+ char *description;
+ char *location;
+ int busy_status;
+ int event_status;
+ int priority;
+ int sensitivity;
+ int has_rrule; //rrule_id;
+ double latitude;
+ double longitude;
+ int has_alarm;
+ int original_event_id;
+ long long int last_mod;
+ char *sync_data1;
+ char *organizer_name;
+ char *categories;
+ int has_attendee;
+ char *sync_data2;
+ char *sync_data3;
+ char *sync_data4;
+ int is_allday;
+} cal_instance_allday_extended_s;
typedef struct
{
int version;
}cal_updated_info_s;
-typedef struct {
- int count;
- GList *record;
- GList *cursor;
-} cal_list_s;
-
typedef enum
{
CAL_NOTI_TYPE_EVENT = 0x0,
}cal_noti_type_e;
typedef struct{
- unsigned int property_id;
- const char* fields; // DB field
+ unsigned int property_id;
+ const char* fields; // DB field
}cal_property_info_s;
typedef enum {
- CAL_FILTER_STR,
- CAL_FILTER_INT,
- CAL_FILTER_DOUBLE,
- CAL_FILTER_LLI,
- CAL_FILTER_CALTIME,
- CAL_FILTER_COMPOSITE,
+ CAL_FILTER_STR,
+ CAL_FILTER_INT,
+ CAL_FILTER_DOUBLE,
+ CAL_FILTER_LLI,
+ CAL_FILTER_CALTIME,
+ CAL_FILTER_COMPOSITE,
}cal_filter_type_e;
typedef struct {
- int filter_type; // composite
- //bool embedded;
+ int filter_type; // composite
}cal_filter_s;
typedef struct {
- int filter_type;
- //bool embedded;
- char *view_uri;
- GSList *filter_ops; //calendar_filter_operator_e op;
- GSList *filters; //calendar_filter_h l_filter;
- cal_property_info_s *properties;
- int property_count;
+ int filter_type;
+ char *view_uri;
+ GSList *filter_ops; //calendar_filter_operator_e op;
+ GSList *filters; //calendar_filter_h l_filter;
+ cal_property_info_s *properties;
+ int property_count;
}cal_composite_filter_s;
typedef struct {
- int filter_type; //cal_filter_type_e
- int property_id;
- int match; //calendar_match_str_flag_e or calendar_match_int_flag_e
- union {
- int i;
- char *s;
- double d;
- long long int lli;
- calendar_time_s caltime;
- }value;
+ int filter_type; //cal_filter_type_e
+ int property_id;
+ int match; //calendar_match_str_flag_e or calendar_match_int_flag_e
+ union {
+ int i;
+ char *s;
+ double d;
+ long long int lli;
+ calendar_time_s caltime;
+ }value;
}cal_attribute_filter_s;
typedef struct {
- char* view_uri;
- //GSList *filter_ops;
- //GSList *filters;
- cal_composite_filter_s* filter;
- int projection_count;
- unsigned int *projection;
- int sort_property_id;
- bool asc;
- cal_property_info_s *properties;
- int property_count;
- bool distinct;
+ char* view_uri;
+ cal_composite_filter_s* filter;
+ int projection_count;
+ unsigned int *projection;
+ int sort_property_id;
+ bool asc;
+ cal_property_info_s *properties;
+ int property_count;
+ bool distinct;
}cal_query_s;
#define CAL_CALTIME_SET_UTIME(dest, src_utime) do {\
- (dest).type = CALENDAR_TIME_UTIME; \
- (dest).time.utime = src_utime; \
+ (dest).type = CALENDAR_TIME_UTIME; \
+ (dest).time.utime = src_utime; \
} while(0)
#define CAL_CALTIME_SET_DATE(dest, src_year, src_month, src_mday) do {\
- (dest).type = CALENDAR_TIME_LOCALTIME; \
- (dest).time.date.year = src_year; \
- (dest).time.date.month = src_month; \
- (dest).time.date.mday = src_mday; \
+ (dest).type = CALENDAR_TIME_LOCALTIME; \
+ (dest).time.date.year = src_year; \
+ (dest).time.date.month = src_month; \
+ (dest).time.date.mday = src_mday; \
} while(0)
typedef struct {
- int property_id;
- union {
- int i;
- char *s;
- double d;
- long long int lli;
- calendar_time_s caltime;
- }value;
+ int property_id;
+ union {
+ int i;
+ char *s;
+ double d;
+ long long int lli;
+ calendar_time_s caltime;
+ }value;
}cal_search_value_s;
typedef struct {
- cal_record_s common;
- GSList *values;
+ cal_record_s common;
+ GSList *values;
}cal_search_s;
typedef struct {
- cal_record_s common;
- int id;
- int record_id;
- int record_type;
- char* key;
- char* value;
+ cal_record_s common;
+ int id;
+ int record_id;
+ int record_type;
+ char* key;
+ char* value;
}cal_extended_s;
/**
#define ICALENAR_BUFFER_MAX (1024*1024)
+/*
+ * vcalendar should not have multi version: ver1.0 or 2.0 only.
+ * could have multi timezone events: MULTI BEGIN:VCALENDAR.
+ */
API int calendar_vcalendar_make_from_records(calendar_list_h list, char **vcalendar_stream)
{
int ret;
cal_make_s *b;
- char *ical;
+ char *ical = NULL;
retvm_if(list == NULL, CALENDAR_ERROR_INVALID_PARAMETER,
"Invalid argument: calendar_list_h is NULL");
b = _cal_vcalendar_make_new();
retvm_if(!b, CALENDAR_ERROR_OUT_OF_MEMORY,
- "_cal_vcalendar_make_new() Failed");
+ "_cal_vcalendar_make_new() Failed");
ret = _cal_vcalendar_make_vcalendar(b, list);
if (!*ical) {
ERR("No ical data");
+ free(ical);
return CALENDAR_ERROR_NO_DATA;
}
return CALENDAR_ERROR_NONE;
}
+static const char* __calendar_vcalendar_get_vcalendar_object(const char *original, char **pvcalendar_object)
+{
+ int len = 0;
+ const char *vcal_start = original;
+ const char *vcal_cursor = NULL;
+ bool new_line = false;
+ char *vcalendar_object = NULL;
+
+ retv_if(NULL == pvcalendar_object, original);
+ *pvcalendar_object = NULL;
+
+ while ('\n' == *vcal_start || '\r' == *vcal_start)
+ vcal_start++;
+
+ if (strncmp(vcal_start, "BEGIN:VCALENDAR", strlen("BEGIN:VCALENDAR")))
+ return vcal_start;
+
+ vcal_start += strlen("BEGIN:VCALENDAR");
+ while ('\n' == *vcal_start || '\r' == *vcal_start)
+ vcal_start++;
+ vcal_cursor = vcal_start;
+
+ while (*vcal_cursor) {
+ if (new_line) {
+ if (0 == strncmp(vcal_cursor, "END:VCALENDAR", strlen("END:VCALENDAR"))) {
+ vcal_cursor += strlen("END:VCALENDAR");
+ while ('\r' == *vcal_cursor || '\n' == *vcal_cursor) {
+ new_line = true;
+ vcal_cursor++;
+ }
+
+ len = (int)vcal_cursor - (int)vcal_start;
+ vcalendar_object = calloc(len + 1, sizeof(char));
+ memcpy(vcalendar_object, vcal_start, len);
+ *pvcalendar_object = vcalendar_object;
+
+ return vcal_cursor;
+ }
+ new_line = false;
+ }
+ vcal_cursor++;
+ while ('\r' == *vcal_cursor || '\n' == *vcal_cursor) {
+ new_line = true;
+ vcal_cursor++;
+ }
+ }
+ return vcal_cursor;
+}
+
/*
* parse from here
*/
-
API int calendar_vcalendar_parse_to_calendar(const char* vcalendar_stream, calendar_list_h *out_list)
{
- char *prop, *cont;
- char *stream = NULL;
- char *cursor = NULL;
+ int count = 0;
+ const char *cursor = NULL;
+ char *vcalendar_object = NULL;
+ calendar_error_e err;
calendar_list_h list = NULL;
retvm_if(vcalendar_stream == NULL, CALENDAR_ERROR_INVALID_PARAMETER,
retvm_if(out_list == NULL, CALENDAR_ERROR_INVALID_PARAMETER,
"Invalid argument: calendar_list_h * is NULL");
- stream = strdup(vcalendar_stream);
- cursor = stream;
+ // get vcalendar object
+ cursor = vcalendar_stream;
- cursor = _cal_vcalendar_parse_remove_space(cursor);
- if (cursor == NULL) {
- ERR("_cal_vcalendar_parse_remove_space() failed");
- CAL_FREE(stream);
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- _cal_vcalendar_parse_unfolding(cursor);
-
- cursor = _cal_vcalendar_parse_read_line(cursor, &prop, &cont);
- if (cursor == NULL) {
- ERR("_cal_vcalendar_parse_read_line() failed");
- CAL_FREE(prop);
- CAL_FREE(cont);
- CAL_FREE(stream);
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
+ int ret = 0;
+ ret = calendar_list_create(&list);
+ retvm_if (CALENDAR_ERROR_NONE != ret, ret, "Failed to calendar_list_create()");
- if (strncmp(prop, "BEGIN", strlen("BEGIN")) ||
- strncmp(cont + 1, "VCALENDAR", strlen("VCALENDAR"))) {
- ERR("Failed to find BEGIN:VCALDENDAR [%s][%s]", prop, cont);
- CAL_FREE(prop);
- CAL_FREE(cont);
- return -1;
- }
- CAL_FREE(prop);
- CAL_FREE(cont);
+ _cal_time_init();
- _cal_vcalendar_parse_vcalendar(&list, cursor);
- if (list == NULL) {
- ERR("No schedules");
- CAL_FREE(stream);
- return CALENDAR_ERROR_NO_DATA;
- }
+ while (NULL != (cursor = __calendar_vcalendar_get_vcalendar_object(cursor, &vcalendar_object))) {
+ if (NULL == vcalendar_object)
+ break;
+ err = _cal_vcalendar_parse_vcalendar_object(vcalendar_object, list, NULL);
+ if (CALENDAR_ERROR_NONE != err) {
+ ERR("_cal_vcalendar_parse_vcalendar_object() failed(%d)", err);
+ calendar_list_destroy(list, true);
+ free(vcalendar_object);
+ _cal_time_fini();
+ return err;
+ }
+ free(vcalendar_object);
+ }
+ calendar_list_get_count(list, &count);
+ if (count <= 0) {
+ calendar_list_destroy(list, true);
+ _cal_time_fini();
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
calendar_list_first(list);
*out_list = list;
-
- CAL_FREE(stream);
+ _cal_time_fini();
return CALENDAR_ERROR_NONE;
}
API int calendar_vcalendar_parse_to_calendar_foreach(const char *vcalendar_file_path, calendar_vcalendar_parse_cb callback, void *user_data)
{
- FILE *file;
- int ret = CALENDAR_ERROR_NONE;
- int buf_size, len;
- char *stream;
- char buf[1024];
-
- retvm_if(vcalendar_file_path == NULL, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid argument: vcalendar_file_path is NULL");
- retvm_if(callback == NULL, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid argument: callback is NULL");
-
- file = fopen(vcalendar_file_path, "r");
-
- retvm_if(file == NULL, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid argument: no file");
-
- len = 0;
- buf_size = ICALENAR_BUFFER_MAX;
- stream = malloc(ICALENAR_BUFFER_MAX);
-
- while (fgets(buf, sizeof(buf), file))
- {
- if (len + sizeof(buf) < buf_size)
- {
- len += snprintf(stream + len, strlen(buf) +1, "%s", buf);
- }
- else
- {
- char *new_stream;
- buf_size *= 2;
- new_stream = realloc(stream, buf_size);
- if (new_stream)
- {
- stream = new_stream;
- } else
- {
- if (stream) free(stream);
- fclose(file);
- ERR("out of memory");
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- len += snprintf(stream + len, strlen(buf) +1, "%s", buf);
- }
-
- if (!strncmp(buf, "END:VCALENDAR", strlen("END:VCALENDAR")))
- {
- DBG("end vcalendar");
- calendar_list_h list = NULL;
- int count = 0, i = 0;
-
- if (calendar_vcalendar_parse_to_calendar(stream, &list) != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_vcalendar_parse_to_calendar fail");
- if (stream) free(stream);
- fclose(file);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- ret = calendar_list_get_count(list, &count);
- if (ret != CALENDAR_ERROR_NONE || count < 1)
- {
- ERR("calendar_list_get_count() failed");
+ FILE *file;
+ int buf_size, len;
+ char *stream;
+ char buf[1024];
+ vcalendar_foreach_s *foreach_data = NULL;
+
+ retvm_if(vcalendar_file_path == NULL, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Invalid argument: vcalendar_file_path is NULL");
+ retvm_if(callback == NULL, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Invalid argument: callback is NULL");
+
+ int ret = 0;
+ calendar_list_h list = NULL;
+ ret = calendar_list_create(&list);
+ retvm_if (CALENDAR_ERROR_NONE != ret, ret, "Failed to calendar_list_create()");
+
+ file = fopen(vcalendar_file_path, "r");
+ if (file == NULL) {
+ ERR("Invalid argument: no file");
+ calendar_list_destroy(list, true);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ len = 0;
+ buf_size = ICALENAR_BUFFER_MAX;
+ stream = malloc(ICALENAR_BUFFER_MAX);
+
+ foreach_data = calloc(1, sizeof(vcalendar_foreach_s));
+ foreach_data->callback = callback;
+ foreach_data->user_data = user_data;
+ foreach_data->ret = true;
+
+ while (fgets(buf, sizeof(buf), file)) {
+ if (len + sizeof(buf) < buf_size) {
+ len += snprintf(stream + len, strlen(buf) +1, "%s", buf);
+ }
+ else {
+ char *new_stream;
+ buf_size *= 2;
+ new_stream = realloc(stream, buf_size);
+ if (new_stream) {
+ stream = new_stream;
+ }
+ else {
+ free(stream);
+ fclose(file);
+ free(foreach_data);
+ calendar_list_destroy(list, true);
+ ERR("out of memory");
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+ len += snprintf(stream + len, strlen(buf) +1, "%s", buf);
+ }
+
+ if (0 == strncmp(buf, "END:VCALENDAR", strlen("END:VCALENDAR"))) {
+ DBG("end vcalendar");
+ int err;
+ char *vcalendar_object = NULL;
+ __calendar_vcalendar_get_vcalendar_object(stream, &vcalendar_object);
+ err = _cal_vcalendar_parse_vcalendar_object(vcalendar_object, list, foreach_data);
+ if (CALENDAR_ERROR_NONE != err || false == foreach_data->ret) {
+ ERR("_cal_vcalendar_parse_vcalendar_object() failed(%d)", err);
calendar_list_destroy(list, true);
- if (stream) free(stream);
+ free(vcalendar_object);
+ free(stream);
+ free(foreach_data);
fclose(file);
- return ret;
+ return err;
}
+ free(vcalendar_object);
+ len = 0;
+ }
+ }
+
+ calendar_list_destroy(list, true);
+ free(stream);
+ free(foreach_data);
+ fclose(file);
- DBG("vcalendar has count(%d)", count);
- calendar_list_first(list);
- for(i = 0; i < count; i++)
- {
- calendar_record_h record = NULL;
- if (calendar_list_get_current_record_p(list,&record) != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_list_get_count fail");
- calendar_list_destroy(list, true);
- if (stream) free(stream);
- fclose(file);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (!callback(record, user_data))
- {
- ERR("callback is false");
- calendar_list_destroy(list, true);
- if (stream) free(stream);
- fclose(file);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- calendar_list_next(list);
- }
-
- calendar_list_destroy(list, true);
- len = 0;
- }
- }
- if (stream) free(stream);
- fclose(file);
-
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
#include <stdlib.h>
#include "calendar_list.h"
+#include "calendar_db.h"
#include "cal_internal.h"
#include "cal_typedef.h"
#include "cal_vcalendar.h"
#include "cal_vcalendar_make.h"
+#define VCAL_DATETIME_FORMAT_YYYYMMDD "%04d%02d%02d"
+#define VCAL_DATETIME_FORMAT_YYYYMMDDTHHMMSS "%04d%02d%02dT%02d%02d%02d"
+#define VCAL_DATETIME_FORMAT_YYYYMMDDTHHMMSSZ "%04d%02d%02dT%02d%02d%02dZ"
+
+enum {
+ VCAL_VER_1 = 1,
+ VCAL_VER_2 = 2,
+};
+
typedef enum
{
EVENT_ATTENDEE_REQ_PARTICIPANT_ROLE=0,
{
b->data = realloc(b->data, b->size + n);
- retvm_if(!b->data, CALENDAR_ERROR_OUT_OF_MEMORY,
- "Failed to realloc");
+ retvm_if(!b->data, CALENDAR_ERROR_OUT_OF_MEMORY, "Failed to realloc");
b->size += n;
return CALENDAR_ERROR_NONE;
{
int ret;
ret = __cal_vcalendar_make_alloc(b, _strlen(b->lbuf) + 3);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
+ retv_if(CALENDAR_ERROR_NONE != ret, ret);
strncat(b->data, b->lbuf, b->size - _strlen(b->data) - 1);
strncat(b->data, "\r\n ", b->size - _strlen(b->data) - 1);
k += remain_lbuf - 1;
remain_str -= remain_lbuf - 1;
ret = __cal_vcalendar_make_folding(b);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
+ retv_if(CALENDAR_ERROR_NONE != ret, ret);
remain_lbuf = sizeof(b->lbuf);
}
{
int ret;
ret = __cal_vcalendar_make_alloc(b, _strlen(b->lbuf) + 2);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
+ retv_if(CALENDAR_ERROR_NONE != ret, ret);
strncat(b->data, b->lbuf, b->size - _strlen(b->data) - 1);
strncat(b->data, "\r\n", b->size - _strlen(b->data) - 1);
if (s1) {
ret = __cal_vcalendar_make_set_str(b, s1);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
+ retv_if(CALENDAR_ERROR_NONE != ret, ret);
}
if (s2) {
ret = __cal_vcalendar_make_set_str(b, s2);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
+ retv_if(CALENDAR_ERROR_NONE != ret, ret);
}
return __cal_vcalendar_make_flush(b);
}
-char *_cal_vcalendar_make_get_data(cal_make_s *b)
+char* _cal_vcalendar_make_get_data(cal_make_s *b)
{
if (!b || !b->data)
return NULL;
free(*b);
b = NULL;
}
-
-static const char *__cal_vcalendar_make_itos(int y, int m, int d)
-{
- static char buf[9];
- snprintf(buf, sizeof(buf), "%04d%02d%02d", y, m, d);
- return buf;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-static inline int __cal_vcalendar_make_class(cal_make_s *b, int v)
-{
- const char *c;
- // TODO : Need to define enumeration of class property
- switch(v) {
- case 0:
- c = "PUBLIC"; break;
- case 1:
- c = "PRIVATE"; break;
- case 2:
- c = "CONFIDENTIAL"; break;
- default:
- c = "PUBLIC"; break;
- }
- __cal_vcalendar_make_printf(b, "CLASS:", c);
- return CALENDAR_ERROR_NONE;
-}
-
-static inline int __cal_vcalendar_make_transp(cal_make_s *b, int v)
-{
- // TODO : Need to define enumeration of transp property
- __cal_vcalendar_make_printf(b, "TRANSP:", v? "OPAQUE":"TRANSPARENT");
- return CALENDAR_ERROR_NONE;
-}
-
-static inline int __cal_vcalendar_make_created(cal_make_s *b, long long int t)
+static void __get_str_utime(long long int t, char *out_str, int size)
{
- char* tmp_tzid = NULL;
- tmp_tzid = _cal_time_convert_ltos(NULL, t);
- if (tmp_tzid)
- {
- __cal_vcalendar_make_printf(b, "CREATED:", tmp_tzid);
- CAL_FREE(tmp_tzid);
- }
- return CALENDAR_ERROR_NONE;
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
+ _cal_time_get_datetime(t, &y, &m, &d, &h, &n, &s);
+ snprintf(out_str, size, ":"VCAL_DATETIME_FORMAT_YYYYMMDDTHHMMSSZ, y, m, d, h, n, s);
}
-static inline int __cal_vcalendar_make_dtstart(int version, cal_make_s *b, char *tzid, calendar_time_s *caltime)
+static int __cal_vcalendar_make_time(cal_make_s *b, char *tzid, calendar_time_s *t, const char *prop)
{
- retvm_if(caltime == NULL, -1, "Invalid argument: calendar_time_s is NULL");
+ retvm_if (NULL == b, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: b is NULL");
+ retvm_if (NULL == t, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: t is NULL");
- if (caltime->time.utime == CALENDAR_TODO_NO_START_DATE)
- {
+ if (CALENDAR_TIME_UTIME == t->type && CALENDAR_TODO_NO_START_DATE == t->time.utime) {
DBG("No start date");
return CALENDAR_ERROR_NONE;
}
- switch (caltime->type)
+ char buf[256] = {0};
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
+ switch (b->version)
{
- case CALENDAR_TIME_UTIME:
- {
- char* str_time = NULL;
- if (version != 1 && NULL != tzid && strlen(tzid) > 0)
- {
- str_time = _cal_time_convert_ltos(tzid, caltime->time.utime);
- if (str_time)
- {
- char buf[128] = {0};
- snprintf(buf, sizeof(buf), "DTSTART;TZID=%s:", tzid);
- __cal_vcalendar_make_printf(b, buf, str_time);
- CAL_FREE(str_time);
- }
- }
- else
- {
- str_time = _cal_time_convert_ltos(NULL, caltime->time.utime);
- if (str_time)
- {
- __cal_vcalendar_make_printf(b, "DTSTART:", str_time);
- CAL_FREE(str_time);
- }
- }
- }
- break;
-
- case CALENDAR_TIME_LOCALTIME:
- if (version == 1)
+ case VCAL_VER_1:
+ switch (t->type)
{
- char buf[16] = {0};
- snprintf(buf, sizeof(buf), "%04d%02d%02dT000000",
- caltime->time.date.year, caltime->time.date.month, caltime->time.date.mday);
- __cal_vcalendar_make_printf(b, "DTSTART:", buf);
-
+ case CALENDAR_TIME_UTIME:
+ _cal_time_get_datetime(t->time.utime, &y, &m, &d, &h, &n, &s);
+ snprintf(buf, sizeof(buf), ":"VCAL_DATETIME_FORMAT_YYYYMMDDTHHMMSSZ, y, m, d, h, n, s);
+ break;
+ case CALENDAR_TIME_LOCALTIME:
+ snprintf(buf, sizeof(buf), ":"VCAL_DATETIME_FORMAT_YYYYMMDDTHHMMSS,
+ t->time.date.year, t->time.date.month, t->time.date.mday,
+ t->time.date.hour, t->time.date.minute, t->time.date.second);
+ break;
}
- else
+ break;
+ case VCAL_VER_2:
+ switch (t->type)
{
- __cal_vcalendar_make_printf(b, "DTSTART;VALUE=DATE:",
- __cal_vcalendar_make_itos(caltime->time.date.year,
- caltime->time.date.month, caltime->time.date.mday));
+ case CALENDAR_TIME_UTIME:
+ if (NULL == tzid || '\0' == *tzid) {
+ _cal_time_get_datetime(t->time.utime, &y, &m, &d, &h, &n, &s);
+ snprintf(buf, sizeof(buf), ":"VCAL_DATETIME_FORMAT_YYYYMMDDTHHMMSSZ, y, m, d, h, n, s);
+ } else {
+ _cal_time_get_local_datetime(tzid, t->time.utime, &y, &m, &d, &h, &n, &s);
+ snprintf(buf, sizeof(buf), ";TZID=%s:"VCAL_DATETIME_FORMAT_YYYYMMDDTHHMMSS, tzid, y, m, d, h, n, s);
+ }
+ break;
+ case CALENDAR_TIME_LOCALTIME:
+ snprintf(buf, sizeof(buf), VCAL_DATETIME_FORMAT_YYYYMMDDTHHMMSS,
+ t->time.date.year, t->time.date.month, t->time.date.mday,
+ t->time.date.hour, t->time.date.minute, t->time.date.second);
+ break;
}
break;
}
-
- return CALENDAR_ERROR_NONE;
-}
-
-static inline int __cal_vcalendar_make_last_mod(cal_make_s *b, long long int lli)
-{
- char* tmp_tzid = NULL;
- tmp_tzid = _cal_time_convert_ltos(NULL, lli);
- if (tmp_tzid)
- {
- __cal_vcalendar_make_printf(b, "LAST-MODIFIED:",tmp_tzid);
- CAL_FREE(tmp_tzid);
- }
+ __cal_vcalendar_make_printf(b, prop, buf);
return CALENDAR_ERROR_NONE;
}
-int __cal_vcalendar_make_organizer(cal_make_s *b, char *cn, char *address)
+static void __encode_escaped_char(char *p, char **r)
{
- int ret;
+ retm_if (NULL == p || '\0' == *p, "Invalid parameter:p is NULL");
- ret = __cal_vcalendar_make_set_str(b, "ORGANIZER");
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
- if (cn && *cn)
- {
- ret = __cal_vcalendar_make_set_str(b, ";CN=");
- ret = __cal_vcalendar_make_set_str(b, cn);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
- }
+ int len = strlen(p) * 2;
+ char *q = calloc(len, sizeof(char));
+ retm_if (NULL == q, "calloc() is failed");
+ *r = q;
- if (address && *address)
- {
- ret = __cal_vcalendar_make_set_str(b, ":mailto:");
- ret = __cal_vcalendar_make_set_str(b, address);
+ DBG("Before [%s]", p);
+ while ('\0' != *p) {
+ if ('\r' == *p && '\n' == *(p + 1)) break;
+ switch (*p)
+ {
+ case '\n':
+ *q = '\\';
+ *(q +1) = 'n';
+ q++;
+ break;
+ case ';':
+ *q = '\\';
+ *(q +1) = ';';
+ q++;
+ break;
+ case ',':
+ *q = '\\';
+ *(q +1) = ',';
+ q++;
+ break;
+ case '\\':
+ *q = '\\';
+ *(q +1) = '\\';
+ q++;
+ break;
+ }
+ *q = *p;
+ q++;
+ p++;
}
- __cal_vcalendar_make_flush(b);
- return CALENDAR_ERROR_NONE;
+ *q = '\0';
+ DBG("After [%s]", *r);
}
-static inline int __cal_vcalendar_make_priority(cal_make_s *b, int v)
+static const char* vl_tick(calendar_alarm_time_unit_type_e unit, int tick)
{
- int prio = 0;
- char tmp[2];
+ static char buf[32] = {0};
- switch (v)
- {
- case CALENDAR_EVENT_PRIORITY_HIGH:
- prio = 3; // one out of 1 ~ 4.
+ int i = 0;
+ if (tick > 0) {
+ *buf = '-';
+ i++;
+
+ } else {
+ tick = -tick;
+ }
+
+ switch (unit) {
+ case CALENDAR_ALARM_TIME_UNIT_WEEK:
+ snprintf(buf + i, sizeof(buf) - i, "P%dW", tick);
break;
- case CALENDAR_EVENT_PRIORITY_NORMAL:
- prio = 5;
+ case CALENDAR_ALARM_TIME_UNIT_DAY:
+ snprintf(buf + i, sizeof(buf) - i, "P%dD", tick);
break;
- case CALENDAR_EVENT_PRIORITY_LOW:
- prio = 7; // one out of 6 ~ 9.
+ case CALENDAR_ALARM_TIME_UNIT_HOUR:
+ snprintf(buf + i, sizeof(buf) - i, "PT%dH", tick);
break;
- default:
- prio = 0; // means none.
+ case CALENDAR_ALARM_TIME_UNIT_MINUTE:
+ snprintf(buf + i, sizeof(buf) - i, "PT%dM", tick);
break;
+ default:
+ buf[0] = '\0';
}
- snprintf(tmp, sizeof(tmp), "%d", prio);
- __cal_vcalendar_make_printf(b, "PRIORITY:", tmp);
- return CALENDAR_ERROR_NONE;
+ return buf;
}
-int __cal_vcalendar_make_dtstamp(cal_make_s *b, char *tzid)
+int __cal_vcalendar_make_audio(cal_make_s *b, calendar_record_h alarm)
{
- char* tmp_tzid = NULL;
- tmp_tzid = _cal_time_convert_ltos(tzid, _cal_time_get_now());
- if (tmp_tzid)
- {
- __cal_vcalendar_make_printf(b, "DTSTAMP:", tmp_tzid);
- CAL_FREE(tmp_tzid);
- }
+ retvm_if (NULL == b, CALENDAR_ERROR_INVALID_PARAMETER, "b is NULL");
+ retvm_if (NULL == alarm, CALENDAR_ERROR_INVALID_PARAMETER, "alarm is NULL");
+
+ int ret = 0;
+ int unit = 0;
+ ret = calendar_record_get_int(alarm, _calendar_alarm.tick_unit, &unit);
+ retvm_if (CALENDAR_ERROR_NONE != ret, ret, "failed to get unit");
+
+ if (CALENDAR_ALARM_TIME_UNIT_SPECIFIC == unit) {
+ calendar_time_s at = {0};
+ ret = calendar_record_get_caltime(alarm, _calendar_alarm.alarm_time, &at);
+ warn_if (CALENDAR_ERROR_NONE != ret, "failed to get alarm_time");
+
+ if (CALENDAR_TIME_UTIME == at.type) {
+ char *datetime = _cal_time_convert_ltos(NULL, at.time.utime, 0);
+ __cal_vcalendar_make_printf(b, "TRIGGER;VALUE=DATE-TIME:", datetime);
+ free(datetime);
+
+ } else {
+ char datetime[32] = {0};
+ snprintf(datetime, sizeof(datetime), "%04d%02d%02dT%02d%02d%02d",
+ at.time.date.year, at.time.date.month, at.time.date.mday,
+ at.time.date.hour, at.time.date.minute, at.time.date.second);
+ __cal_vcalendar_make_printf(b, "TRIGGER;VALUE=DATE-TIME:", datetime);
+ }
+
+ } else {
+ int tick = 0;
+ ret = calendar_record_get_int(alarm, _calendar_alarm.tick, &tick);
+ warn_if (CALENDAR_ERROR_NONE != ret, "failed to get tick");
+ __cal_vcalendar_make_printf(b, "TRIGGER:", vl_tick(unit, tick));
+ }
return CALENDAR_ERROR_NONE;
}
-static inline int __cal_vcalendar_make_dtend(int version, cal_make_s *b, char *tzid, calendar_time_s *caltime)
+/* alarm in ver1.0
+ * aalarm: runTime, snoozeTime, repeatCount, audioContent (AALARM;TYPE=WAVE;VALUE=URL:19960415T235959; ; ; file:///mmedia/taps.wav)
+ * dalarm: runTime, snoozeTime, repeatCount, displayString
+ * malarm: runTime, snoozeTime, repeatCount, addressString, noteString
+ * palarm: runTime, snoozeTime, repeatCount, procedureName
+ */
+static void __cal_vcalendar_make_aalarm(cal_make_s *b, calendar_record_h record, calendar_record_h alarm)
{
- retvm_if(caltime == NULL, -1, "Invalid argument: calendar_time_s is NULL");
+ retm_if (NULL == b, "b is NULL");
+ retm_if (NULL == record, "record is NULL");
+ retm_if (alarm == NULL, "alarm is NULL");
- if (caltime->time.utime == CALENDAR_TODO_NO_DUE_DATE)
- {
- DBG("No start date");
- return CALENDAR_ERROR_NONE;
- }
+ int ret = CALENDAR_ERROR_NONE;
- switch (caltime->type)
- {
- case CALENDAR_TIME_UTIME:
- {
- char* str_time = NULL;
- if (version != 1 && NULL != tzid && strlen(tzid) > 0)
- {
- str_time = _cal_time_convert_ltos(tzid, caltime->time.utime);
- if (str_time)
- {
- char buf[128] = {0};
- snprintf(buf, sizeof(buf), "DTEND;TZID=%s:", tzid);
- __cal_vcalendar_make_printf(b, buf, str_time);
- CAL_FREE(str_time);
- }
- }
- else
- {
- str_time = _cal_time_convert_ltos(NULL, caltime->time.utime);
- if (str_time)
- {
- __cal_vcalendar_make_printf(b, "DTEND:", str_time);
- CAL_FREE(str_time);
- }
- }
- }
- break;
+ // set alarm
+ int unit = 0;
+ ret = calendar_record_get_int(alarm, _calendar_alarm.tick_unit, &unit);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() is failed(%d)", ret);
+
+ char datetime[32] = {0};
+ if (CALENDAR_ALARM_TIME_UNIT_SPECIFIC == unit) {
+ calendar_time_s at = {0};
+ ret = calendar_record_get_caltime(alarm, _calendar_alarm.alarm_time, &at);
+ warn_if (CALENDAR_ERROR_NONE != ret, "failed to get alarm_time");
+
+ if (CALENDAR_TIME_UTIME == at.type) {
+ char *buf = _cal_time_convert_ltos(NULL, at.time.utime, 0);
+ snprintf(datetime, sizeof(datetime), "%s;;;", buf);
+ free(buf);
+
+ } else {
+ snprintf(datetime, sizeof(datetime), "%04d%02d%02dT%02d%02d%02d;;;",
+ at.time.date.year, at.time.date.month, at.time.date.mday,
+ at.time.date.hour, at.time.date.minute, at.time.date.second);
+ }
- case CALENDAR_TIME_LOCALTIME:
- if (version == 1)
- {
- char buf[16] = {0};
- snprintf(buf, sizeof(buf), "%04d%02d%02dT000000",
- caltime->time.date.year, caltime->time.date.month, caltime->time.date.mday);
- __cal_vcalendar_make_printf(b, "DTEND:", buf);
+ } else { // has tick, unit
+ int tick = 0;
+ ret = calendar_record_get_int(alarm, _calendar_alarm.tick, &tick);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() is failed(%d)", ret);
+
+ char *uri = NULL;
+ ret = calendar_record_get_uri_p(record, &uri);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_uri_p() failed(%d)", ret);
+
+ calendar_time_s st = {0};
+ if (!strncmp(uri, _calendar_event._uri, strlen(_calendar_event._uri))) {
+ ret = calendar_record_get_caltime(record, _calendar_event.start_time, &st);
+ retm_if (CALENDAR_ERROR_NONE != ret, "Failed to get start");
+ } else if (!strncmp(uri, _calendar_todo._uri, strlen(_calendar_todo._uri))) {
+ ret = calendar_record_get_caltime(record, _calendar_todo.due_time, &st);
+ retm_if (CALENDAR_ERROR_NONE != ret, "Failed to get due");
}
- else
- {
- __cal_vcalendar_make_printf(b, "DTEND;VALUE=DATE:",
- __cal_vcalendar_make_itos(caltime->time.date.year,
- caltime->time.date.month, caltime->time.date.mday));
+
+ if (CALENDAR_TIME_UTIME == st.type) {
+ long long int lli = st.time.utime - (tick * unit);
+ char *buf = _cal_time_convert_ltos(NULL, lli, 0);
+ snprintf(datetime, sizeof(datetime), "%s;;;", buf);
+ free(buf);
+ DBG("aalarm: [%s] = (%lld) - (tick(%d) * unit(%d))", datetime, st.time.utime, tick, unit);
+
+ } else {
+ struct tm tm = {0};
+ tm.tm_year = st.time.date.year - 1900;
+ tm.tm_mon = st.time.date.month - 1;
+ tm.tm_mday = st.time.date.mday;
+ tm.tm_hour = st.time.date.hour;
+ tm.tm_min = st.time.date.minute;
+ tm.tm_sec = st.time.date.second;
+ time_t tt = mktime(&tm);
+ tt -= (tick * unit);
+ localtime_r(&tt, &tm);
+
+ snprintf(datetime, sizeof(datetime), "%04d%02d%02dT%02d%02d%02d",
+ tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
+ tm.tm_hour, tm.tm_min, tm.tm_sec);
+
+ DBG("aalarm: [%s]", datetime);
}
+ }
+ __cal_vcalendar_make_printf(b, "AALARM:", datetime);
+}
+
+static void __cal_vcalendar_make_alarm(cal_make_s *b, calendar_record_h alarm)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == alarm, "Invalid parameter: record is NULL");
+
+ int ret;
+
+ // TODO : No action type is defined
+ ret = __cal_vcalendar_make_printf(b, "BEGIN:VALARM", NULL);
+ retm_if(CALENDAR_ERROR_NONE != ret, "__cal_vcalendar_make_printf() is failed(%d)", ret);
+
+ ret = __cal_vcalendar_make_audio(b, alarm);
+ retm_if(CALENDAR_ERROR_NONE != ret, "__cal_vcalendar_make_audio() is failed(%d)", ret);
+
+ int action = 0;
+ ret = calendar_record_get_int(alarm, _calendar_alarm.action, &action);
+ retm_if(CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() is failed(%d)", ret);
+ switch (action)
+ {
+ default:
+ case CALENDAR_ALARM_ACTION_AUDIO:
+ ret = __cal_vcalendar_make_printf(b, "ACTION:", "AUDIO");
+ break;
+ case CALENDAR_ALARM_ACTION_DISPLAY:
+ ret = __cal_vcalendar_make_printf(b, "ACTION:", "DISPLAY");
+ break;
+ case CALENDAR_ALARM_ACTION_EMAIL:
+ ret = __cal_vcalendar_make_printf(b, "ACTION:", "EMAIL");
break;
}
+ retm_if(CALENDAR_ERROR_NONE != ret, "__cal_vcalendar_make_printf() is failed(%d)", ret);
- return CALENDAR_ERROR_NONE;
+ char *summary = NULL;
+ ret = calendar_record_get_str_p(alarm, _calendar_alarm.summary, &summary);
+ if (summary && *summary) {
+ ret = __cal_vcalendar_make_printf(b, "SUMMARY:", summary);
+ retm_if(CALENDAR_ERROR_NONE != ret, "__cal_vcalendar_make_printf() is failed(%d)", ret);
+ }
+
+ char *description = NULL;
+ ret = calendar_record_get_str_p(alarm, _calendar_alarm.description, &description);
+ if (description && *description) {
+ ret = __cal_vcalendar_make_printf(b, "DESCRIPTION:", description);
+ retm_if(CALENDAR_ERROR_NONE != ret, "__cal_vcalendar_make_printf() is failed(%d)", ret);
+ }
+
+ __cal_vcalendar_make_printf(b, "END:VALARM", NULL);
}
-static inline int __cal_vcalendar_make_due(int version, cal_make_s *b, char *tzid, calendar_time_s *caltime)
+int __cal_vcalendar_make_rrule_append_mday(char *buf, char *mday)
{
- retvm_if(caltime == NULL, -1, "Invalid argument: calendar_time_s is NULL");
+ int i;
+ int num;
+ int length = 0;
+ char **t = NULL;
+ char *p = NULL;
- if (caltime->time.utime == CALENDAR_TODO_NO_DUE_DATE)
+ if (NULL == buf || NULL == mday)
{
- DBG("No due date");
- return CALENDAR_ERROR_NONE;
+ ERR("Invalid parameter");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
}
- switch (caltime->type)
+ t = g_strsplit_set(mday, " ,", -1);
+ if (!t) {
+ ERR("g_strsplit_set() is failed");
+ g_strfreev(t);
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+ length = g_strv_length(t);
+ for (i = 0; i < length; i++)
{
- case CALENDAR_TIME_UTIME:
- {
- char* str_time = NULL;
- if (version != 1 && NULL != tzid && strlen(tzid) > 0)
- {
- str_time = _cal_time_convert_ltos(tzid, caltime->time.utime);
- if (str_time)
- {
- char buf[128] = {0};
- snprintf(buf, sizeof(buf), "DUE;TZID=%s:", tzid);
- __cal_vcalendar_make_printf(b, buf, str_time);
- CAL_FREE(str_time);
- }
- }
- else
- {
- str_time = _cal_time_convert_ltos(NULL, caltime->time.utime);
- if (str_time)
- {
- __cal_vcalendar_make_printf(b, "DUE:", str_time);
- CAL_FREE(str_time);
- }
- }
- }
- break;
+ if (*t[i] == '\0') continue;
- case CALENDAR_TIME_LOCALTIME:
- if (version == 1)
+ p = t[i];
+ num = atoi(p);
+ if (num > 0)
{
- char buf[16] = {0};
- snprintf(buf, sizeof(buf), "%04d%02d%02dT000000",
- caltime->time.date.year, caltime->time.date.month, caltime->time.date.mday);
- __cal_vcalendar_make_printf(b, "DUE:", buf);
-
+ strcat(buf, p);
}
else
{
- __cal_vcalendar_make_printf(b, "DUE:",
- __cal_vcalendar_make_itos(caltime->time.date.year,
- caltime->time.date.month, caltime->time.date.mday));
+ strcat(buf, p + 1);
+ strcat(buf, "-");
}
- break;
+ strcat(buf, " ");
}
+ g_strfreev(t);
return CALENDAR_ERROR_NONE;
}
-static inline int __cal_vcalendar_make_exdate(cal_make_s *b, char *s)
+static void __cal_vcalendar_make_rrule_append_setpos(calendar_record_h record, char *buf)
{
- __cal_vcalendar_make_printf(b, "EXDATE:", s);
- return CALENDAR_ERROR_NONE;
-}
+ int ret = CALENDAR_ERROR_NONE;
+ char *bysetpos = NULL;
-int __cal_vcalendar_make_attendee(cal_make_s *b, calendar_record_h attendee)
-{
- int ret;
- int role, status, rsvp;
- char *group = NULL;
- char *delegate_uri = NULL;
- char *delegator_uri = NULL;
- char *name = NULL;
- char *email = NULL;
+ ret = calendar_record_get_str_p(record, _calendar_event.bysetpos, &bysetpos);
+ retm_if(CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() failed(%d)", ret);
- retvm_if(attendee == NULL, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid argument: attendee is NULL");
+ if (bysetpos && '\0' != bysetpos[0]) {
+ // in ver1.0, "3, 5, -4" -> "3+ 5+ 4-"
+ char **t = NULL;
+ t = g_strsplit_set(bysetpos, " ,", -1);
- ret = __cal_vcalendar_make_set_str(b, "ATTENDEE");
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
+ int len = g_strv_length(t);
- ret = calendar_record_get_str_p(attendee, _calendar_attendee.group, &group);
+ int i;
+ for (i = 0; i < len; i++) {
+ if (*t[i] == '\0') continue;
- if (group && *group) {
- ret = __cal_vcalendar_make_set_str(b, ";CUTYPE=");
- ret = __cal_vcalendar_make_set_str(b, group);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
- }
+ int setpos = atoi(t[i]);
+ DBG("%d", setpos);
- // TODO : NO 'member' member in cal_participant_info_t
+ if (setpos == 0) {
+ DBG("Invalid setpos(0)");
+ continue;
+ }
+ char tmp[32] = {0};
+ snprintf(tmp, sizeof(tmp), "%d%s ", setpos * (setpos < 0 ? -1 : 1), setpos < 0 ? "-" : "+");
+ strcat(buf, tmp);
+ }
+ g_strfreev(t);
+ } else {
+ // in ver2.0, 3TH should be changed to setpos:3, byday:TH
+ char *byday = NULL;
+ ret = calendar_record_get_str_p(record, _calendar_event.byday, &byday);
+ retm_if(CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() failed(%d)", ret);
+ if (NULL == byday || '\0' == byday[0])
+ {
+ strcat(buf, "1+ ");
+ return;
+ }
- ret = calendar_record_get_int(attendee, _calendar_attendee.role, &role);
- {
- ret = __cal_vcalendar_make_set_str(b, ";ROLE=");
- ret = __cal_vcalendar_make_set_str(b, _att_role[role]);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
+ int len = strlen(byday);
+
+ bool is_working = true;
+ bool is_extracted = false;
+ int i = 0;
+ int digit = 0;
+ int sign = 0;
+ while (i <= len) {
+ // extract -1, 1 from 1SU,-1SU
+ if ((byday[i] >= '1' && byday[i] <= '9')) {
+ is_working = false;
+ digit++;
+ } else if ('+' == byday[i]) {
+ is_working = false;
+ sign = 1;
+ } else if ('-' == byday[i]) {
+ is_working = false;
+ sign = -1;
+ } else {
+ if (false == is_working) {
+ is_extracted = true;
+ is_working = true;
+ char num[32] = {0};
+ snprintf(num, digit +1, "%s", byday +i -digit);
+ strcat(num, (-1 == sign) ? "- " : "+ "); // get '3'
+ if (NULL == strstr(buf, num)) {
+ strcat(buf, num);
+ }
+ digit = 0;
+ sign = 0;
+ }
+ }
+ i++;
+ }
+ if (false == is_extracted) {
+ strcat(buf, "1+ ");
+ return;
+ }
}
+}
- ret = calendar_record_get_int(attendee, _calendar_attendee.status, &status);
- {
- ret = __cal_vcalendar_make_set_str(b, ";PARTSTAT=");
- ret = __cal_vcalendar_make_set_str(b, _att_st[status]);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
- }
+void __cal_vcalendar_make_rrule_append_text_wday(int rrule_type, char *buf, char *wday)
+{
+ int i, j;
+ int length = 0;
+ char **t = NULL;
+ char *p = NULL;
- ret = calendar_record_get_int(attendee, _calendar_attendee.rsvp, &rsvp);
- {
- ret = __cal_vcalendar_make_set_str(b, ";RSVP=");
- ret = __cal_vcalendar_make_set_str(b, rsvp ? "TRUE" : "FALSE");
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
+ t = g_strsplit_set(wday, " ,", -1);
+ if (!t) {
+ ERR("g_strsplit_set() is failed");
+ g_strfreev(t);
+ return;
}
-
- ret = calendar_record_get_str_p(attendee, _calendar_attendee.delegate_uri, &delegate_uri);
- if (delegate_uri && *delegate_uri)
+ length = g_strv_length(t);
+ for (i = 0; i < length; i++)
{
- ret = __cal_vcalendar_make_set_str(b, ";DELEGATED-TO=");
- ret = __cal_vcalendar_make_set_str(b, delegate_uri);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
- }
+ if (*t[i] == '\0')
+ continue;
- ret = calendar_record_get_str_p(attendee, _calendar_attendee.delegator_uri, &delegator_uri);
- if (delegator_uri && *delegator_uri)
- {
- ret = __cal_vcalendar_make_set_str(b, ";DELEGATED-FROM=");
- ret = __cal_vcalendar_make_set_str(b, delegator_uri);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
+ p = t[i];
+ while (*p == ' ') // del space
+ p++;
+
+ j = 0;
+ while (p[j] == '+' || p[j] == '-' || (p[j] >= '1' && p[j] <= '9')) // get number length
+ j++;
+ if (strstr(buf, p +j)) // already appended
+ continue;
+ strcat(buf, p + j);
+ strcat(buf, " ");
}
+ g_strfreev(t);
- // TODO : No 'sentby' member in cal_participant_info_t
+ return;
+}
- ret = calendar_record_get_str_p(attendee, _calendar_attendee.name, &name);
- if (name && *name) {
- ret = __cal_vcalendar_make_set_str(b, ";CN=");
- ret = __cal_vcalendar_make_set_str(b, name);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
- }
+void __cal_vcalendar_make_rrule_append_wkst(char *buf, calendar_record_h record)
+{
+ const char wday[7][3] = {"SU", "MO", "TU", "WE", "TH", "FR", "SA"};
+ int wkst = 0;
+ calendar_record_get_int(record, _calendar_event.wkst, &wkst);
+ if (wkst < CALENDAR_SUNDAY || wkst > CALENDAR_SATURDAY)
+ return;
- ret = calendar_record_get_str_p(attendee, _calendar_attendee.email, &email);
- if (email && *email)
- {
- ret = __cal_vcalendar_make_set_str(b, ":mailto:");
- ret = __cal_vcalendar_make_set_str(b, email);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
- }
- __cal_vcalendar_make_flush(b);
- return CALENDAR_ERROR_NONE;
+ DBG("wkst(%d) [%s]", wkst, wday[wkst - 1]);
+ strcat(buf, "WKST=");
+ strcat(buf, wday[wkst - 1]); // CALENDAR_SUNDAY is 1 not 0
+ strcat(buf, " ");
}
-static const char *vl_dur(calendar_alarm_time_unit_type_e unit, int dur)
+int __cal_vcalendar_make_rrule_append_wday(int rrule_type, char *buf, char *wday)
{
- static char buf[8];
- int i = 0;
- char d[5];
+ int i, j;
+ int num = 0, num_past;
+ int length = 0;
+ char **t = NULL;
+ char *p = NULL;
+ char buf_temp[8] = {0};
- if (dur < 0) {
- *buf = '-';
- i++;
- dur = -dur;
+ if (NULL == buf || NULL == wday) {
+ ERR("Invalid parameter");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
}
- snprintf(d, sizeof(d), "%d", dur);
-
- *(buf + i) = 'P';
- i++;
-
- switch (unit) {
- case CALENDAR_ALARM_TIME_UNIT_WEEK:
- snprintf(buf + i, sizeof(buf) - i, "%sW", d);
- break;
- case CALENDAR_ALARM_TIME_UNIT_DAY:
- snprintf(buf + i, sizeof(buf) - i, "%sD", d);
- break;
- case CALENDAR_ALARM_TIME_UNIT_HOUR:
- snprintf(buf + i, sizeof(buf) - i, "T%sH", d);
- break;
- case CALENDAR_ALARM_TIME_UNIT_MINUTE:
- snprintf(buf + i, sizeof(buf) - i, "T%sM", d);
- break;
- default:
- buf[0] = '\0';
- }
-
- return buf;
-}
-
-int __cal_vcalendar_make_trigger(cal_make_s *b, int unit, int dur, long long int t)
-{
- retvm_if(unit < 0, CALENDAR_ERROR_NO_DATA, "tick unit is invalid");
-
- if (unit == CALENDAR_ALARM_TIME_UNIT_SPECIFIC)
- {
- char* tmp_tzid = NULL;
- tmp_tzid = _cal_time_convert_ltos(NULL, t);
- if (tmp_tzid)
- {
- __cal_vcalendar_make_printf(b, "TRIGGER;VALUE=DATE-TIME:",tmp_tzid);
- CAL_FREE(tmp_tzid);
- }
-
- }
- else
- {
- __cal_vcalendar_make_printf(b, "TRIGGER:", vl_dur(unit, dur));
- }
- return CALENDAR_ERROR_NONE;
-}
-
-int __cal_vcalendar_make_action(cal_make_s *b)
-{
- return __cal_vcalendar_make_printf(b, "ACTION:", "AUDIO");
-}
-
-int __cal_vcalendar_make_audio(cal_make_s *b, calendar_record_h alarm)
-{
- int ret;
- int tick, unit;
- long long int utime;
-
- ret = __cal_vcalendar_make_action(b);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
-
- ret = calendar_record_get_int(alarm, _calendar_alarm.tick, &tick);
- ret = calendar_record_get_int(alarm, _calendar_alarm.tick_unit, &unit);
- ret = calendar_record_get_lli(alarm, _calendar_alarm.time, &utime);
-
- ret = __cal_vcalendar_make_trigger(b, unit, tick, utime);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
-
- // TODO : Support duration
- // TODO : Support repeat (snooze)
- return CALENDAR_ERROR_NONE;
-}
-
-// ver 1.0 aalarm
-int __cal_vcalendar_make_aalarm(cal_make_s *b, calendar_record_h record, calendar_record_h alarm)
-{
- int ret;
- int type;
- int tick, unit;
- char *uri = NULL;
- long long int utime;
- calendar_time_s caltime = {0};
- retvm_if(alarm == NULL, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid argument: alarm is NULL");
-
- ret = calendar_record_get_uri_p(record, &uri);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_get_uri_p() failed");
- return ret;
- }
-
- if (!strncmp(uri, _calendar_event._uri, strlen(_calendar_event._uri)))
- {
- type = CALENDAR_RECORD_TYPE_EVENT;
- }
- else if (!strncmp(uri, _calendar_todo._uri, strlen(_calendar_todo._uri)))
- {
- type = CALENDAR_RECORD_TYPE_TODO;
- }
- else
- {
- ERR("Invalid type(%s)", uri);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- ret = calendar_record_get_int(alarm, _calendar_alarm.tick_unit, &unit);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_get_int() failed");
- return ret;
- }
- ret = calendar_record_get_int(alarm, _calendar_alarm.tick, &tick);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_get_int() failed");
- return ret;
- }
-
- switch (unit)
- {
- case CALENDAR_ALARM_TIME_UNIT_SPECIFIC:
- ret = calendar_record_get_lli(alarm, _calendar_alarm.time, &utime);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_get_lli() failed");
- return ret;
- }
- break;
-
- default:
- switch (type)
- {
- case CALENDAR_RECORD_TYPE_EVENT:
- ret = calendar_record_get_caltime(record, _calendar_event.start_time, &caltime);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_get_caltime() failed");
- return ret;
- }
- switch (caltime.type)
- {
- case CALENDAR_TIME_UTIME:
- utime = caltime.time.utime - (tick * unit);
- break;
-
- case CALENDAR_TIME_LOCALTIME:
- utime = _cal_time_convert_itol(NULL, caltime.time.date.year,
- caltime.time.date.month, caltime.time.date.mday, 0, 0, 0);
- utime -= (tick * unit);
- break;
- }
- break;
-
- case CALENDAR_RECORD_TYPE_TODO:
- ret = calendar_record_get_caltime(record, _calendar_todo.due_time, &caltime);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_get_caltime() failed");
- return ret;
- }
- switch (caltime.type)
- {
- case CALENDAR_TIME_UTIME:
- utime = caltime.time.utime - (tick * unit);
- break;
-
- case CALENDAR_TIME_LOCALTIME:
- utime = _cal_time_convert_itol(NULL, caltime.time.date.year,
- caltime.time.date.month, caltime.time.date.mday, 0, 0, 0);
- utime -= (tick * unit);
- break;
- }
- break;
- }
- break;
- }
-
- char *calstr = _cal_time_convert_ltos(NULL, utime);
- DBG("[%s]", calstr);
-
- ret = __cal_vcalendar_make_printf(b, "AALARM:", calstr);
- CAL_FREE(calstr);
-
- return CALENDAR_ERROR_NONE;
-}
-
-int __cal_vcalendar_make_alarm(cal_make_s *b, calendar_record_h alarm)
-{
- int ret;
- retvm_if(alarm == NULL, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid argument: alarm is NULL");
-
- // TODO : No action type is defined
- ret = __cal_vcalendar_make_printf(b, "BEGIN:VALARM", NULL);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
-
- ret = __cal_vcalendar_make_audio(b, alarm);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
-
- // TODO : Display
- // TODO : Email
- // TODO : Proc
-
- __cal_vcalendar_make_printf(b, "END:VALARM", NULL);
- return CALENDAR_ERROR_NONE;
-}
-
-int __cal_vcalendar_make_rrule_append_mday(char *buf, char *mday)
-{
- int i;
- int num;
- int length = 0;
- char **t;
- char *p;
-
- if (NULL == buf || NULL == mday)
- {
- ERR("Invalid parameter");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- t = g_strsplit(mday, ",", -1);
- if (!t) {
- ERR("g_strsplit failed");
- g_strfreev(t);
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- length = g_strv_length(t);
- for (i = 0; i < length; i++)
- {
- p = t[i];
- while (*p == ' ')
- {
- p++;
- }
- num = atoi(p);
- if (num > 0)
- {
- strcat(buf, p);
- }
- else
- {
- strcat(buf, p + 1);
- strcat(buf, "-");
- }
- strcat(buf, " ");
- }
- g_strfreev(t);
-
- return CALENDAR_ERROR_NONE;
-}
-
-int __cal_vcalendar_make_rrule_append_wday(char *buf, char *wday)
-{
- int i, j;
- int num, num_past;
- int length = 0;
- char **t;
- char *p;
- char buf_temp[8] = {0};
-
num_past = 0;
- t = g_strsplit(wday, ",", -1);
+ t = g_strsplit_set(wday, " ,", -1);
if (!t) {
- ERR("g_strsplit failed");
+ ERR("g_strsplit_set() is failed");
g_strfreev(t);
return CALENDAR_ERROR_OUT_OF_MEMORY;
}
length = g_strv_length(t);
+ DBG("len(%d)", length);
+
for (i = 0; i < length; i++)
{
+ if (*t[i] == '\0') continue;
+
p = t[i];
- while (*p == ' ') // del space
- {
- p++;
- }
j = 0; // get number
while (p[j] == '+' || p[j] == '-' || (p[j] >= '1' && p[j] <= '9'))
- {
j++;
- }
+
if (j > 0)
{
- if (*p == '-')
+ if (CALENDAR_RECURRENCE_WEEKLY == rrule_type)
{
- snprintf(buf_temp, j, "%s", p + 1);
- num = atoi(buf_temp);
- if (0 == i)
- {
- num_past = num;
- strcat(buf, buf_temp);
- strcat(buf, "-");
- strcat(buf, " ");
- }
+ num_past = num;
}
else
{
- snprintf(buf_temp, j + 1, "%s", p);
- num = atoi(buf_temp);
- if (0 == i)
+ if (*p == '-')
{
- num_past = num;
- strcat(buf, buf_temp);
- strcat(buf, " ");
+ snprintf(buf_temp, j + 1, "%s", p + 1);
+ num = atoi(buf_temp);
+ if (0 == i)
+ {
+ num_past = num;
+ strcat(buf, buf_temp);
+ strcat(buf, "-");
+ strcat(buf, " ");
+ }
+ }
+ else
+ {
+ snprintf(buf_temp, j + 1, "%s", p);
+ num = atoi(buf_temp);
+ if (0 == i)
+ {
+ num_past = num;
+ strcat(buf, buf_temp);
+ strcat(buf, "+");
+ strcat(buf, " ");
+ }
}
}
if (num_past == num)
strcat(buf, p);
strcat(buf, " ");
}
+ DBG("[%s]", buf);
}
g_strfreev(t);
return CALENDAR_ERROR_NONE;
}
+static void __make_begin(cal_make_s *b, calendar_record_h record)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+
+ int ret = 0;
+ switch (b->type)
+ {
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = __cal_vcalendar_make_printf(b, "BEGIN:VEVENT", NULL);
+ retm_if(CALENDAR_ERROR_NONE != ret, "__cal_vcalendar_make_printf() is failed(%d)", ret);
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = __cal_vcalendar_make_printf(b, "BEGIN:VTODO", NULL);
+ retm_if (CALENDAR_ERROR_NONE != ret, "__cal_vcalendar_make_printf() is failed(%d)", ret);
+ break;
+ }
+}
+
+static void __make_dtstart(cal_make_s *b, calendar_record_h record)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+
+ int ret = 0;
+ char *tzid = NULL;
+ calendar_time_s ct = {0};
+ switch (b->type)
+ {
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = calendar_record_get_str_p(record, _calendar_event.start_tzid, &tzid);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() is failed(%d)", ret);
+ ret = calendar_record_get_caltime(record, _calendar_event.start_time, &ct);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_caltime() is failed(%d)", ret);
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = calendar_record_get_str_p(record, _calendar_todo.start_tzid, &tzid);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() is failed(%d)", ret);
+ ret = calendar_record_get_caltime(record, _calendar_todo.start_time, &ct);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_caltime() is failed(%d)", ret);
+ break;
+ }
+ if (tzid && *tzid) {
+ __cal_vcalendar_make_time(b, tzid, &ct, "DTSTART");
+ }
+}
+
+static void __make_dtend(cal_make_s *b, calendar_record_h record)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+
+ int ret = 0;
+ char *tzid = NULL;
+ calendar_time_s ct = {0};
+ switch (b->type)
+ {
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = calendar_record_get_str_p(record, _calendar_event.end_tzid, &tzid);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() is failed(%d)", ret);
+ ret = calendar_record_get_caltime(record, _calendar_event.end_time, &ct);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_caltime() is failed(%d)", ret);
+ if (tzid && *tzid) {
+ __cal_vcalendar_make_time(b, tzid, &ct, "DTEND");
+ }
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = calendar_record_get_str_p(record, _calendar_todo.due_tzid, &tzid);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() is failed(%d)", ret);
+ ret = calendar_record_get_caltime(record, _calendar_todo.due_time, &ct);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_caltime() is failed(%d)", ret);
+ if (tzid && *tzid) {
+ __cal_vcalendar_make_time(b, tzid, &ct, "DUE");
+ }
+ break;
+ }
+}
+
+static void __make_sensitivity(cal_make_s *b, calendar_record_h record)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+
+ int ret = 0;
+ int value = 0;
+ switch (b->type)
+ {
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = calendar_record_get_int(record, _calendar_event.sensitivity, &value);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() is failed(%d)", ret);
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = calendar_record_get_int(record, _calendar_todo.sensitivity, &value);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() is failed(%d)", ret);
+ break;
+ }
+ char *sensitivity = NULL;
+ switch (value)
+ {
+ case CALENDAR_SENSITIVITY_PUBLIC:
+ sensitivity = "PUBLIC";
+ break;
+ case CALENDAR_SENSITIVITY_PRIVATE:
+ sensitivity = "PRIVATE";
+ break;
+ case CALENDAR_SENSITIVITY_CONFIDENTIAL:
+ sensitivity = "CONFIDENTIAL";
+ break;
+ default:
+ ERR("Invalid sensitivity(%d)", value);
+ return;
+ }
+ __cal_vcalendar_make_printf(b, "CLASS:", sensitivity);
+}
+
int __cal_vcalendar_make_rrule_append_until(char *buf, calendar_record_h record)
{
int ret;
case CALENDAR_RANGE_UNTIL:
memset(&caltime, 0x0, sizeof(calendar_time_s));
+
ret = calendar_record_get_caltime(record, _calendar_event.until_time, &caltime);
if (CALENDAR_ERROR_NONE != ret)
{
switch (caltime.type)
{
case CALENDAR_TIME_UTIME:
- until_str = _cal_time_convert_ltos(NULL, caltime.time.utime);
+ until_str = _cal_time_convert_ltos(NULL, caltime.time.utime, 0);
snprintf(buf_range, sizeof(buf_range), "%s", until_str);
CAL_FREE(until_str);
break;
case CALENDAR_TIME_LOCALTIME:
- snprintf(buf_range, sizeof(buf_range), "%04d%02d%02dT000000Z",
- caltime.time.date.year, caltime.time.date.month, caltime.time.date.mday);
+ snprintf(buf_range, sizeof(buf_range), "%04d%02d%02dT%02d%02d%02d",
+ caltime.time.date.year, caltime.time.date.month, caltime.time.date.mday,
+ caltime.time.date.hour, caltime.time.date.minute, caltime.time.date.second);
break;
}
break;
return CALENDAR_ERROR_NONE;
}
-
-static int __cal_vcalendar_make_rrule_ver1(cal_make_s *b, calendar_record_h record)
+static void __make_rrule_ver1_default(calendar_record_h record, int freq, int interval, char *buf, int buf_size)
{
- int ret;
- int freq;
- int interval = 0;
- char *byyearday = NULL;
- char *bymonth = NULL;
- char *bymonthday = NULL;
- char *byday = NULL;
- char buf[512] = {0};
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
- ret = calendar_record_get_int(record, _calendar_event.freq, &freq);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_get_int() failed");
- return ret;
- }
- ret = calendar_record_get_int(record, _calendar_event.interval, &interval);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_get_int() failed");
- return ret;
- }
- ret = calendar_record_get_str_p(record, _calendar_event.bymonthday, &byyearday);
- if (CALENDAR_ERROR_NONE != ret)
+ int ret = 0;
+ calendar_time_s caltime = {0};
+ ret = calendar_record_get_caltime(record, _calendar_event.start_time, &caltime);
+ warn_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_caltime() is failed(%d)", ret);
+
+ switch (freq)
{
- ERR("calendar_record_get_str_p() failed");
- return ret;
+ case CALENDAR_RECURRENCE_YEARLY:
+ snprintf(buf, buf_size, "YD%d ", interval);
+ break;
+ case CALENDAR_RECURRENCE_MONTHLY:
+ snprintf(buf, buf_size, "MD%d ", interval);
+ break;
}
- ret = calendar_record_get_str_p(record, _calendar_event.bymonth, &bymonth);
- if (CALENDAR_ERROR_NONE != ret)
+
+ char *tzid = NULL;
+ int d = 0;
+ switch (caltime.type)
{
- ERR("calendar_record_get_str_p() failed");
- return ret;
+ case CALENDAR_TIME_UTIME:
+ calendar_record_get_str_p(record, _calendar_event.start_tzid, &tzid);
+ _cal_time_get_local_datetime(tzid, caltime.time.utime, NULL, NULL, &d, NULL, NULL, NULL);
+ break;
+ case CALENDAR_TIME_LOCALTIME:
+ d = caltime.time.date.mday;
+ break;
}
+ char mday[32] = {0};
+ snprintf(mday, sizeof(mday), "%d", d);
+ __cal_vcalendar_make_rrule_append_mday(buf, mday);
+}
+
+static void __make_rrule_ver1(cal_make_s *b, calendar_record_h record)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+
+ int ret = 0;
+ char buf[1024] = {0};
+
+ int freq = 0;
+ ret = calendar_record_get_int(record, _calendar_event.freq, &freq);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() is failed(%d)", ret);
+
+ int interval = 1;
+ ret = calendar_record_get_int(record, _calendar_event.interval, &interval);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() is failed(%d)", ret);
+ interval = interval > 0 ? interval : 1;
+
+ char *byyearday = NULL;
+ ret = calendar_record_get_str_p(record, _calendar_event.byyearday, &byyearday);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() is failed(%d)", ret);
+
+ char *bymonth = NULL;
+ ret = calendar_record_get_str_p(record, _calendar_event.bymonth, &bymonth);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() is failed(%d)", ret);
+
+ char *byday = NULL;
ret = calendar_record_get_str_p(record, _calendar_event.byday, &byday);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_get_str_p() failed");
- return ret;
- }
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() is failed(%d)", ret);
+
+ char *bymonthday = NULL;
ret = calendar_record_get_str_p(record, _calendar_event.bymonthday, &bymonthday);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_get_str_p() failed");
- return ret;
- }
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() is failed(%d)", ret);
- switch (freq) {
- case CALENDAR_RECURRENCE_DAILY:
- snprintf(buf, sizeof(buf), "D%d ", interval);
- break;
+ switch (freq)
+ {
+ case CALENDAR_RECURRENCE_YEARLY:
+ if (bymonth && *bymonth) {
+ snprintf(buf, sizeof(buf), "YM%d ", interval);
+ __cal_vcalendar_make_rrule_append_mday(buf, bymonth);
- case CALENDAR_RECURRENCE_WEEKLY:
- snprintf(buf, sizeof(buf), "W%d ", interval);
- __cal_vcalendar_make_rrule_append_wday(buf, byday);
+ char tmp[512] = {0};
+ if (byday && *byday) {
+ // ex> YM1 6 MP1 1+ TH
+ snprintf(tmp, sizeof(tmp), "MP%d ", interval);
+ strcat(buf, tmp);
+ __cal_vcalendar_make_rrule_append_setpos(record, buf);
+ __cal_vcalendar_make_rrule_append_text_wday(CALENDAR_RECURRENCE_MONTHLY, buf, byday);
+ } else if (bymonthday && *bymonthday) {
+ // ex> YM1 2 MD 1
+ snprintf(tmp, sizeof(tmp), "MD%d ", interval);
+ strcat(buf, tmp);
+ __cal_vcalendar_make_rrule_append_mday(buf, bymonthday);
+ } else {
+ ERR("Out of scope");
+ __make_rrule_ver1_default(record, freq, interval, buf, sizeof(buf));
+ }
+ } else if (byyearday && *byyearday) {
+ snprintf(buf, sizeof(buf), "YD%d ", interval);
+ __cal_vcalendar_make_rrule_append_mday(buf, byyearday);
+ } else {
+ ERR("Out of scope");
+ __make_rrule_ver1_default(record, freq, interval, buf, sizeof(buf));
+ }
break;
case CALENDAR_RECURRENCE_MONTHLY:
- if (byday)
- {
+ if (byday && *byday) {
snprintf(buf, sizeof(buf), "MP%d ", interval);
- __cal_vcalendar_make_rrule_append_wday(buf, byday);
- }
- else if (bymonthday)
- {
+ __cal_vcalendar_make_rrule_append_setpos(record, buf);
+ __cal_vcalendar_make_rrule_append_text_wday(CALENDAR_RECURRENCE_MONTHLY, buf, byday);
+ } else if (bymonthday && *bymonthday) {
snprintf(buf, sizeof(buf), "MD%d ", interval);
__cal_vcalendar_make_rrule_append_mday(buf, bymonthday);
- }
- else
- {
- ERR("Invalid parameter");
+ } else {
+ ERR("Out of scope, so set as bymonthday");
+ __make_rrule_ver1_default(record, freq, interval, buf, sizeof(buf));
}
break;
- case CALENDAR_RECURRENCE_YEARLY:
- if (bymonth)
- {
- snprintf(buf, sizeof(buf), "YM%d ", interval);
- __cal_vcalendar_make_rrule_append_mday(buf, bymonth);
- }
- else if (byyearday)
- {
- snprintf(buf, sizeof(buf), "YD%d ", interval);
- __cal_vcalendar_make_rrule_append_mday(buf, byyearday);
- }
- else
- {
- ERR("Invalid parameter");
- }
+ case CALENDAR_RECURRENCE_WEEKLY:
+ snprintf(buf, sizeof(buf), "W%d ", interval);
+ __cal_vcalendar_make_rrule_append_wday(CALENDAR_RECURRENCE_WEEKLY, buf, byday);
+ break;
+
+ case CALENDAR_RECURRENCE_DAILY:
+ snprintf(buf, sizeof(buf), "D%d ", interval);
break;
default:
- ERR("Invalid parameter");
+ ERR("Out of scope");
break;
}
- __cal_vcalendar_make_rrule_append_until(buf, record);
-
- return __cal_vcalendar_make_printf(b, "RRULE:", buf);
+ if (*buf) {
+ __cal_vcalendar_make_rrule_append_wkst(buf, record);
+ __cal_vcalendar_make_rrule_append_until(buf, record);
+ __cal_vcalendar_make_printf(b, "RRULE:", buf);
+ }
}
-static int __cal_vcalendar_make_rrule(cal_make_s *b, int freq, calendar_record_h record)
+static void __make_rrule_ver2(cal_make_s *b, calendar_record_h record)
{
- int ret;
- int num;
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+
+ int ret = 0;
char *text = NULL;
- char buf[1024] = {0};
char tmp[32] = {0};
calendar_time_s caltime = {0};
+ int freq = 0;
+ ret = calendar_record_get_int(record, _calendar_event.freq, &freq);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() is failed(%d)", ret);
+
switch (freq) {
case CALENDAR_RECURRENCE_DAILY:
- strcat(buf, "FREQ=DAILY");
+ __cal_vcalendar_make_set_str(b, "RRULE:FREQ=DAILY");
break;
case CALENDAR_RECURRENCE_WEEKLY:
- strcat(buf, "FREQ=WEEKLY");
+ __cal_vcalendar_make_set_str(b, "RRULE:FREQ=WEEKLY");
break;
case CALENDAR_RECURRENCE_MONTHLY:
- strcat(buf, "FREQ=MONTHLY");
+ __cal_vcalendar_make_set_str(b, "RRULE:FREQ=MONTHLY");
break;
case CALENDAR_RECURRENCE_YEARLY:
- strcat(buf, "FREQ=YEARLY");
+ __cal_vcalendar_make_set_str(b, "RRULE:FREQ=YEARLY");
break;
default:
- break;
+ return;
}
- ret = calendar_record_get_int(record, _calendar_event.interval, &num);
- snprintf(tmp, sizeof(tmp), "%d", num);
- strcat(buf, ";INTERVAL=");
- strcat(buf, tmp);
+ int interval = 1;
+ ret = calendar_record_get_int(record, _calendar_event.interval, &interval);
+ warn_if(CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() Failed(%d)", ret);
+ interval = interval > 0 ? interval : 1;
+ snprintf(tmp, sizeof(tmp), ";INTERVAL=%d", interval);
+ __cal_vcalendar_make_set_str(b, tmp);
ret = calendar_record_get_str_p(record, _calendar_event.bysecond, &text);
- if (text) {
- strcat(buf, ";BYSECOND=");
- strcat(buf, text);
+ warn_if(CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() Failed(%d)", ret);
+ if (text && *text) {
+ DBG("BYSECOND= [%s]", text);
+ __cal_vcalendar_make_set_str(b, ";BYSECOND=");
+ __cal_vcalendar_make_set_str(b, text);
text = NULL;
}
ret = calendar_record_get_str_p(record, _calendar_event.byminute, &text);
- if (text) {
- strcat(buf, ";BYMINUTE=");
- strcat(buf, text);
+ warn_if(CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() Failed(%d)", ret);
+ if (text && *text) {
+ DBG("BYMINUTE= [%s]", text);
+ __cal_vcalendar_make_set_str(b, ";BYMINUTE=");
+ __cal_vcalendar_make_set_str(b, text);
text = NULL;
}
ret = calendar_record_get_str_p(record, _calendar_event.byhour, &text);
- if (text) {
- strcat(buf, ";BYHOUR=");
- strcat(buf, text);
+ warn_if(CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() Failed(%d)", ret);
+ if (text && *text) {
+ DBG("BYHOUR= [%s]", text);
+ __cal_vcalendar_make_set_str(b, ";BYHOUR=");
+ __cal_vcalendar_make_set_str(b, text);
text = NULL;
}
ret = calendar_record_get_str_p(record, _calendar_event.byday, &text);
- if (text) {
- strcat(buf, ";BYDAY=");
- strcat(buf, text);
+ warn_if(CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() Failed(%d)", ret);
+ if (text && *text) {
+ DBG("BYDAY= [%s]", text);
+ __cal_vcalendar_make_set_str(b, ";BYDAY=");
+ __cal_vcalendar_make_set_str(b, text);
text = NULL;
}
ret = calendar_record_get_str_p(record, _calendar_event.bymonthday, &text);
- if (text) {
- strcat(buf, ";BYMONTHDAY=");
- strcat(buf, text);
+ warn_if(CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() Failed(%d)", ret);
+ if (text && *text) {
+ DBG("BYMONTHDAY= [%s]", text);
+ __cal_vcalendar_make_set_str(b, ";BYMONTHDAY=");
+ __cal_vcalendar_make_set_str(b, text);
text = NULL;
}
ret = calendar_record_get_str_p(record, _calendar_event.byyearday, &text);
- if (text) {
- strcat(buf, ";BYYEARDAY=");
- strcat(buf, text);
+ warn_if(CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() Failed(%d)", ret);
+ if (text && *text) {
+ DBG("BYYEARDAY= [%s]", text);
+ __cal_vcalendar_make_set_str(b, ";BYYEARDAY=");
+ __cal_vcalendar_make_set_str(b, text);
text = NULL;
}
ret = calendar_record_get_str_p(record, _calendar_event.byweekno, &text);
- if (text) {
- strcat(buf, ";BYWEEKNO=");
- strcat(buf, text);
+ warn_if(CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() Failed(%d)", ret);
+ if (text && *text) {
+ DBG("BYWEEKNO= [%s]", text);
+ __cal_vcalendar_make_set_str(b, ";BYWEEKNO=");
+ __cal_vcalendar_make_set_str(b, text);
text = NULL;
}
ret = calendar_record_get_str_p(record, _calendar_event.bymonth, &text);
- if (text) {
- strcat(buf, ";BYMONTH=");
- strcat(buf, text);
+ warn_if(CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() Failed(%d)", ret);
+ if (text && *text) {
+ DBG("BYMONTH= [%s]", text);
+ __cal_vcalendar_make_set_str(b, ";BYMONTH=");
+ __cal_vcalendar_make_set_str(b, text);
text = NULL;
}
ret = calendar_record_get_str_p(record, _calendar_event.bysetpos, &text);
- if (text) {
- strcat(buf, ";BYSETPOS=");
- strcat(buf, text);
+ warn_if(CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() Failed(%d)", ret);
+ if (text && *text) {
+ DBG("BYSETPOS= [%s]", text);
+ __cal_vcalendar_make_set_str(b, ";BYSETPOS=");
+ __cal_vcalendar_make_set_str(b, text);
text = NULL;
}
- num = CALENDAR_SUNDAY; // default set
- ret = calendar_record_get_int(record, _calendar_event.wkst, &num);
- strcat(buf, ";WKST=");
- switch (num) {
- case CALENDAR_SUNDAY:
- strcat(buf, "SU");
- break;
- case CALENDAR_MONDAY:
- strcat(buf, "MO");
- break;
- case CALENDAR_TUESDAY:
- strcat(buf, "TU");
- break;
- case CALENDAR_WEDNESDAY:
- strcat(buf, "WE");
- break;
- case CALENDAR_THURSDAY:
- strcat(buf, "TH");
- break;
- case CALENDAR_FRIDAY:
- strcat(buf, "FR");
- break;
- case CALENDAR_SATURDAY:
- strcat(buf, "SA");
- break;
+ int wkst = 0;
+ ret = calendar_record_get_int(record, _calendar_event.wkst, &wkst);
+ warn_if(CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() Failed(%d)", ret);
+ if (wkst >= CALENDAR_SUNDAY && wkst <= CALENDAR_SATURDAY) {
+ __cal_vcalendar_make_set_str(b, ";WKST=");
+ switch (wkst) {
+ case CALENDAR_SUNDAY:
+ __cal_vcalendar_make_set_str(b, "SU");
+ break;
+ case CALENDAR_MONDAY:
+ __cal_vcalendar_make_set_str(b, "MO");
+ break;
+ case CALENDAR_TUESDAY:
+ __cal_vcalendar_make_set_str(b, "TU");
+ break;
+ case CALENDAR_WEDNESDAY:
+ __cal_vcalendar_make_set_str(b, "WE");
+ break;
+ case CALENDAR_THURSDAY:
+ __cal_vcalendar_make_set_str(b, "TH");
+ break;
+ case CALENDAR_FRIDAY:
+ __cal_vcalendar_make_set_str(b, "FR");
+ break;
+ case CALENDAR_SATURDAY:
+ __cal_vcalendar_make_set_str(b, "SA");
+ break;
+ }
}
- ret = calendar_record_get_int(record, _calendar_event.range_type, &num);
- switch (num) {
+ int range_type = 0;
+ int count = 0;
+ ret = calendar_record_get_int(record, _calendar_event.range_type, &range_type);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() Failed(%d)", ret);
+ switch (range_type) {
case CALENDAR_RANGE_COUNT:
- ret = calendar_record_get_int(record, _calendar_event.count, &num);
- snprintf(tmp, sizeof(tmp), "%d", num);
- strcat(buf, ";COUNT=");
- strcat(buf, tmp);
+ ret = calendar_record_get_int(record, _calendar_event.count, &count);
+ warn_if(CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() Failed(%d)", ret);
+ snprintf(tmp, sizeof(tmp), ";COUNT=%d", count);
+ __cal_vcalendar_make_set_str(b, tmp);
break;
case CALENDAR_RANGE_UNTIL:
ret = calendar_record_get_caltime(record, _calendar_event.until_time, &caltime);
-
- if (caltime.type == CALENDAR_TIME_UTIME)
- {
- char *tmp_tzid = NULL;
- tmp_tzid = _cal_time_convert_ltos(NULL, caltime.time.utime);
- if (tmp_tzid)
- {
- snprintf(tmp, sizeof(tmp), "%s", tmp_tzid);
- CAL_FREE(tmp_tzid);
- }
- }
- else
- {
- snprintf(tmp, sizeof(tmp), "%04d%02d%02dT000000Z",
+ warn_if(CALENDAR_ERROR_NONE != ret, "calendar_record_get_caltime() Failed(%d)", ret);
+
+ if (caltime.type == CALENDAR_TIME_UTIME) {
+ char *tmp_tzid = NULL;
+ tmp_tzid = _cal_time_convert_ltos(NULL, caltime.time.utime, 0);
+ if (tmp_tzid) {
+ snprintf(tmp, sizeof(tmp), ";UNTIL=%s", tmp_tzid);
+ CAL_FREE(tmp_tzid);
+ }
+ } else {
+ snprintf(tmp, sizeof(tmp), ";UNTIL=%04d%02d%02dT%02d%02d%02dZ",
caltime.time.date.year,
caltime.time.date.month,
- caltime.time.date.mday);
+ caltime.time.date.mday,
+ caltime.time.date.hour,
+ caltime.time.date.minute,
+ caltime.time.date.second);
}
- strcat(buf, ";UNTIL=");
- strcat(buf, tmp);
+ __cal_vcalendar_make_set_str(b, tmp);
break;
case CALENDAR_RANGE_NONE:
break;
- default:
+ }
+ __cal_vcalendar_make_flush(b);
+}
+
+static void __make_rrule(cal_make_s *b, calendar_record_h record)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+
+ switch (b->type)
+ {
+ case CALENDAR_BOOK_TYPE_EVENT:
+ switch (b->version)
+ {
+ case VCAL_VER_1:
+ __make_rrule_ver1(b, record);
+ break;
+ case VCAL_VER_2:
+ __make_rrule_ver2(b, record);
+ break;
+ }
break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ERR("No rrule in todo");
+ return;
}
- return __cal_vcalendar_make_printf(b, "RRULE:", buf);
}
-/////////////////////////////////////////////////////////////////////////////
-int __cal_vcalendar_make_child_extended(cal_make_s *b, calendar_record_h child)
+int __cal_vcalendar_make_attendee(cal_make_s *b, calendar_record_h attendee)
{
int ret;
- char *key = NULL;
- char *value = NULL;
- if (NULL == child)
+
+ retvm_if(attendee == NULL, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid argument: attendee is NULL");
+
+ ret = __cal_vcalendar_make_set_str(b, "ATTENDEE");
+ retv_if(CALENDAR_ERROR_NONE != ret, ret);
+
+ int cutype = 0;
+ ret = calendar_record_get_int(attendee, _calendar_attendee.cutype, &cutype);
+ ret = __cal_vcalendar_make_set_str(b, ";CUTYPE=");
+ switch (cutype)
{
- ERR("Invalid argument: child is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
+ case CALENDAR_ATTENDEE_CUTYPE_INDIVIDUAL:
+ ret = __cal_vcalendar_make_set_str(b, "INDIVIDUAL");
+ break;
+ case CALENDAR_ATTENDEE_CUTYPE_GROUP:
+ ret = __cal_vcalendar_make_set_str(b, "GROUP");
+ break;
+ case CALENDAR_ATTENDEE_CUTYPE_RESOURCE:
+ ret = __cal_vcalendar_make_set_str(b, "RESOURCE");
+ break;
+ case CALENDAR_ATTENDEE_CUTYPE_ROOM:
+ ret = __cal_vcalendar_make_set_str(b, "ROOM");
+ break;
+ case CALENDAR_ATTENDEE_CUTYPE_UNKNOWN:
+ ret = __cal_vcalendar_make_set_str(b, "UNKNOWN");
+ break;
}
+ retv_if(CALENDAR_ERROR_NONE != ret, ret);
- ret = calendar_record_get_str_p(child, _calendar_extended_property.key, &key);
- if (CALENDAR_ERROR_NONE != ret)
+ char *member = NULL;
+ ret = calendar_record_get_str_p(attendee, _calendar_attendee.member, &member);
+ if (member && *member) {
+ ret = __cal_vcalendar_make_set_str(b, ";MEMBER=");
+ ret = __cal_vcalendar_make_set_str(b, member);
+ retv_if(CALENDAR_ERROR_NONE != ret, ret);
+ }
+
+ int role = 0;
+ ret = calendar_record_get_int(attendee, _calendar_attendee.role, &role);
{
- ERR("calendar_record_get_str_p() failed");
- return ret;
+ ret = __cal_vcalendar_make_set_str(b, ";ROLE=");
+ ret = __cal_vcalendar_make_set_str(b, _att_role[role]);
+ retv_if(CALENDAR_ERROR_NONE != ret, ret);
}
- if (NULL == key || strncmp(key, "X-", strlen("X-")))
+
+ int status = 0;
+ ret = calendar_record_get_int(attendee, _calendar_attendee.status, &status);
{
- DBG("Not extended for vcalendar[%s]", key);
- return CALENDAR_ERROR_NONE;
+ ret = __cal_vcalendar_make_set_str(b, ";PARTSTAT=");
+ ret = __cal_vcalendar_make_set_str(b, _att_st[status]);
+ retv_if(CALENDAR_ERROR_NONE != ret, ret);
}
- ret = calendar_record_get_str_p(child, _calendar_extended_property.value, &value);
- if (CALENDAR_ERROR_NONE != ret)
+ int rsvp = 0;
+ ret = calendar_record_get_int(attendee, _calendar_attendee.rsvp, &rsvp);
{
- ERR("calendar_record_get_str_p() failed");
- return ret;
+ ret = __cal_vcalendar_make_set_str(b, ";RSVP=");
+ ret = __cal_vcalendar_make_set_str(b, rsvp ? "TRUE" : "FALSE");
+ retv_if(CALENDAR_ERROR_NONE != ret, ret);
}
- ret = __cal_vcalendar_make_printf(b, key, value);
- if (CALENDAR_ERROR_NONE != ret)
+
+ char *delegatee_uri = NULL;
+ ret = calendar_record_get_str_p(attendee, _calendar_attendee.delegatee_uri, &delegatee_uri);
+ if (delegatee_uri && *delegatee_uri)
{
- ERR("__cal_vcalendar_make_printf() failed");
- return ret;
+ ret = __cal_vcalendar_make_set_str(b, ";DELEGATED-TO=");
+ ret = __cal_vcalendar_make_set_str(b, delegatee_uri);
+ retv_if(CALENDAR_ERROR_NONE != ret, ret);
+ }
+
+ char *delegator_uri = NULL;
+ ret = calendar_record_get_str_p(attendee, _calendar_attendee.delegator_uri, &delegator_uri);
+ if (delegator_uri && *delegator_uri)
+ {
+ ret = __cal_vcalendar_make_set_str(b, ";DELEGATED-FROM=");
+ ret = __cal_vcalendar_make_set_str(b, delegator_uri);
+ retv_if(CALENDAR_ERROR_NONE != ret, ret);
+ }
+
+ // TODO : No 'sentby' member in cal_participant_info_t
+
+ char *name = NULL;
+ ret = calendar_record_get_str_p(attendee, _calendar_attendee.name, &name);
+ if (name && *name) {
+ ret = __cal_vcalendar_make_set_str(b, ";CN=");
+ ret = __cal_vcalendar_make_set_str(b, name);
+ retv_if(CALENDAR_ERROR_NONE != ret, ret);
+ }
+
+ char *email = NULL;
+ ret = calendar_record_get_str_p(attendee, _calendar_attendee.email, &email);
+ if (email && *email)
+ {
+ ret = __cal_vcalendar_make_set_str(b, ":mailto:");
+ ret = __cal_vcalendar_make_set_str(b, email);
+ retv_if(CALENDAR_ERROR_NONE != ret, ret);
}
+ __cal_vcalendar_make_flush(b);
return CALENDAR_ERROR_NONE;
}
-int __cal_vcalendar_make_printf_str_p(calendar_record_h record, unsigned int property_id, cal_make_s *b, const char *property_str)
+static void __make_attendee(cal_make_s *b, calendar_record_h record)
{
- int ret;
- char *strval = NULL;
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
- ret = calendar_record_get_str_p(record, property_id, &strval);
- if (CALENDAR_ERROR_NONE != ret)
+ int ret = 0;
+ unsigned int count = 0;
+ int i;
+ switch (b->type)
{
- ERR("calendar_record_get_str_p() failed(ret:%d): categories", ret);
- return ret;
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = calendar_record_get_child_record_count(record, _calendar_event.calendar_attendee, &count);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_child_record_count() is failed(%d)", ret);
+ for (i = 0; i < count; i++) {
+ calendar_record_h child = NULL;
+ ret = calendar_record_get_child_record_at_p(record, _calendar_event.calendar_attendee, i, &child);
+ ret = __cal_vcalendar_make_attendee(b, child);
+ }
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = calendar_record_get_child_record_count(record, _calendar_todo.calendar_attendee, &count);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_child_record_count() is failed(%d)", ret);
+ for (i = 0; i < count; i++) {
+ calendar_record_h child = NULL;
+ ret = calendar_record_get_child_record_at_p(record, _calendar_todo.calendar_attendee, i, &child);
+ ret = __cal_vcalendar_make_attendee(b, child);
+ }
+ break;
+ }
+}
+
+static void __make_alarm_ver1(cal_make_s *b, calendar_record_h record)
+{
+ // In ver 1.0, only first alarm will be dealt with.
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+
+ int ret = 0;
+ unsigned int count = 0;
+ int i;
+ switch (b->type)
+ {
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = calendar_record_get_child_record_count(record, _calendar_event.calendar_alarm, &count);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_child_record_count() is failed(%d)", ret);
+ for (i = 0; i < count; i++) {
+ calendar_record_h child = NULL;
+ ret = calendar_record_get_child_record_at_p(record, _calendar_event.calendar_alarm, i, &child);
+ warn_if(CALENDAR_ERROR_NONE != ret, "Failed to get child alarm(%d)", ret);
+
+ __cal_vcalendar_make_aalarm(b, record, child);
+ }
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = calendar_record_get_child_record_count(record, _calendar_todo.calendar_alarm, &count);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_child_record_count() is failed(%d)", ret);
+ for (i = 0; i < count; i++) {
+ calendar_record_h child = NULL;
+ ret = calendar_record_get_child_record_at_p(record, _calendar_todo.calendar_alarm, i, &child);
+ warn_if(CALENDAR_ERROR_NONE != ret, "Failed to get child alarm(%d)", ret);
+
+ __cal_vcalendar_make_aalarm(b, record, child);
+ }
+ break;
+ }
+}
+
+static void __make_alarm_ver2(cal_make_s *b, calendar_record_h record)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+
+ int ret = 0;
+ unsigned int count = 0;
+ int i;
+ switch (b->type)
+ {
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = calendar_record_get_child_record_count(record, _calendar_event.calendar_alarm, &count);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_child_record_count() is failed(%d)", ret);
+ for (i = 0; i < count; i++) {
+ calendar_record_h child = NULL;
+ ret = calendar_record_get_child_record_at_p(record, _calendar_event.calendar_alarm, i, &child);
+ warn_if(CALENDAR_ERROR_NONE != ret, "Failed to get child alarm(%d)", ret);
+
+ __cal_vcalendar_make_alarm(b, child);
+ }
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = calendar_record_get_child_record_count(record, _calendar_todo.calendar_alarm, &count);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_child_record_count() is failed(%d)", ret);
+ for (i = 0; i < count; i++) {
+ calendar_record_h child = NULL;
+ ret = calendar_record_get_child_record_at_p(record, _calendar_todo.calendar_alarm, i, &child);
+ warn_if(CALENDAR_ERROR_NONE != ret, "Failed to get child alarm(%d)", ret);
+
+ __cal_vcalendar_make_alarm(b, child);
+ }
+ break;
+ }
+}
+
+static void __make_alarm(cal_make_s *b, calendar_record_h record)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+
+ switch (b->type)
+ {
+ case CALENDAR_BOOK_TYPE_EVENT:
+ switch (b->version)
+ {
+ case VCAL_VER_1:
+ __make_alarm_ver1(b, record);
+ break;
+ case VCAL_VER_2:
+ __make_alarm_ver2(b, record);
+ break;
+ }
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ERR("No rrule in todo");
+ return;
+ }
+
+}
+static void __make_created_time(cal_make_s *b, calendar_record_h record)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+
+ int ret = 0;
+ long long int value = 0;
+ switch (b->type)
+ {
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = calendar_record_get_lli(record, _calendar_event.created_time, &value);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_lli() is failed(%d)", ret);
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = calendar_record_get_lli(record, _calendar_todo.created_time, &value);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_lli() is failed(%d)", ret);
+ break;
+ }
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
+ _cal_time_get_datetime(value, &y, &m, &d, &h, &n, &s);
+ char buf[128] = {0};
+ snprintf(buf, sizeof(buf), VCAL_DATETIME_FORMAT_YYYYMMDDTHHMMSSZ, y, m, d, h, n, s);
+
+ switch (b->version)
+ {
+ case VCAL_VER_1:
+ __cal_vcalendar_make_printf(b, "DCREATED:", buf);
+ break;
+ case VCAL_VER_2:
+ __cal_vcalendar_make_printf(b, "CREATED:", buf);
+ break;
+ }
+}
+
+static void __make_summary(cal_make_s *b, calendar_record_h record)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+
+ int ret = 0;
+ char *value = NULL;
+ switch (b->type)
+ {
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = calendar_record_get_str_p(record, _calendar_event.summary, &value);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() is failed(%d)", ret);
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = calendar_record_get_str_p(record, _calendar_todo.summary, &value);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() is failed(%d)", ret);
+ break;
+ }
+ if (value && *value) {
+ char *summary = NULL;
+ __encode_escaped_char(value, &summary);
+ __cal_vcalendar_make_printf(b, "SUMMARY:", summary);
+ free(summary);
+ }
+}
+
+static void __make_description(cal_make_s *b, calendar_record_h record)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+
+ int ret = 0;
+ char *value = NULL;
+ switch (b->type)
+ {
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = calendar_record_get_str_p(record, _calendar_event.description, &value);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() is failed(%d)", ret);
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = calendar_record_get_str_p(record, _calendar_todo.description, &value);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() is failed(%d)", ret);
+ break;
+ }
+ if (value && *value) {
+ char *description = NULL;
+ __encode_escaped_char(value, &description);
+ __cal_vcalendar_make_printf(b, "DESCRIPTION:", description);
+ free(description);
+ }
+}
+
+static void __make_location(cal_make_s *b, calendar_record_h record)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+
+ int ret = 0;
+ char *value = NULL;
+ switch (b->type)
+ {
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = calendar_record_get_str_p(record, _calendar_event.location, &value);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() is failed(%d)", ret);
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = calendar_record_get_str_p(record, _calendar_todo.location, &value);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() is failed(%d)", ret);
+ break;
}
- if (strval && (strlen(strval) > 0))
- {
- ret = __cal_vcalendar_make_printf(b, property_str, strval);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("__cal_vcalendar_make_printf() failed(ret:%d)", ret);
- return ret;
- }
+ if (value && *value) {
+ char *location = NULL;
+ __encode_escaped_char(value, &location);
+ __cal_vcalendar_make_printf(b, "LOCATION:", location);
+ free(location);
}
- return CALENDAR_ERROR_NONE;
}
-int __cal_vcalendar_make_schedule(int version, cal_make_s *b, calendar_record_h record)
+static void __make_organizer(cal_make_s *b, calendar_record_h record)
{
- int ret;
- int freq;
- int intval;
- char *strval = NULL;
- char *strval2 = NULL;
- calendar_time_s caltime = {0};
- char *uri = NULL;
- char *tzid = NULL;
-
- ret = calendar_record_get_uri_p(record, &uri);
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
- //_cal_db_rrule_fill_record(record);
+ if (VCAL_VER_1 == b->version) // Invalid component in ver 1
+ return;
- ret = __cal_vcalendar_make_printf(b, "BEGIN:VEVENT", NULL);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
+ int ret = 0;
+ char *name = NULL;
+ char *email = NULL;
+ switch (b->type)
+ {
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = calendar_record_get_str_p(record, _calendar_event.organizer_name, &name);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() is failed(%d)", ret);
+ ret = calendar_record_get_str_p(record, _calendar_event.organizer_email, &email);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() is failed(%d)", ret);
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = calendar_record_get_str_p(record, _calendar_todo.organizer_name, &name);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() is failed(%d)", ret);
+ ret = calendar_record_get_str_p(record, _calendar_todo.organizer_email, &email);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() is failed(%d)", ret);
+ break;
+ }
+ if ((NULL == name || '\0' == *name) && (NULL == email || '\0' == *email))
+ return;
- // sensitivity
- ret = calendar_record_get_int(record, _calendar_event.sensitivity, &intval);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1,
- "Failed to get sensitivity(%d)", ret);
+ char buf[128] = {0};
+ snprintf(buf, sizeof(buf), "ORGANIZER%s%s%s%s",
+ (name && *name) ? ";CN=" : "",
+ (name && *name) ? name : "",
+ (email && *email) ? ":MAILTO:" : "",
+ (email && *email) ? email : "");
- __cal_vcalendar_make_class(b, intval);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
+ __cal_vcalendar_make_printf(b, buf, NULL);
+}
- // busy_status
- ret = calendar_record_get_int(record, _calendar_event.busy_status, &intval);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1,
- "Failed to get busy_status(%d)", ret);
+static void __make_last_modified(cal_make_s *b, calendar_record_h record)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
- ret = __cal_vcalendar_make_transp(b, intval);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
+ if (VCAL_VER_1 == b->version) // kies want to skip
+ return;
- // dtstart_type
- ret = calendar_record_get_str_p(record, _calendar_event.start_tzid, &tzid);
- ret = calendar_record_get_caltime(record, _calendar_event.start_time, &caltime);
- if (ret != CALENDAR_ERROR_NONE) {
- ERR("Failed to get start_time(%d)", ret);
- return -1;
+ int ret = 0;
+ long long int value = 0;
+ switch (b->type)
+ {
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = calendar_record_get_lli(record, _calendar_event.last_modified_time, &value);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_lli() is failed(%d)", ret);
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = calendar_record_get_lli(record, _calendar_todo.last_modified_time, &value);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_lli() is failed(%d)", ret);
+ break;
}
- ret = __cal_vcalendar_make_dtstart(version, b, tzid, &caltime);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1, "Failed to get dtstart(%d)", ret);
-
- // created_time
-/* keis want to skip for there potential error.
- ret = calendar_record_get_lli(record, _calendar_event.created_time, &llival);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1,
- "Failed to get created_time(%d)", ret);
-
- ret = __cal_vcalendar_make_created(b, llival);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
-*/
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
+ _cal_time_get_datetime(value, &y, &m, &d, &h, &n, &s);
+ char buf[128] = {0};
+ snprintf(buf, sizeof(buf), VCAL_DATETIME_FORMAT_YYYYMMDDTHHMMSSZ, y, m, d, h, n, s);
+ __cal_vcalendar_make_printf(b, "LAST-MODIFIED:", buf);
+}
- // description
- __cal_vcalendar_make_printf_str_p(record, _calendar_event.description, b, "DESCRIPTION:");
+static void __make_status(cal_make_s *b, calendar_record_h record)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
- // rrule
- ret = calendar_record_get_int(record, _calendar_event.freq, &freq);
- retvm_if(ret != CALENDAR_ERROR_NONE, ret,
- "Failed to get last_modified_time(%d)", ret);
- if (freq)
+ int ret = 0;
+ int value = 0;
+ char *status = NULL;
+ switch (b->type)
{
- switch (version)
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = calendar_record_get_int(record, _calendar_event.event_status, &value);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() is failed(%d)", ret);
+ switch (value)
{
- case 1:
- ret = __cal_vcalendar_make_rrule_ver1(b, record);
+ case CALENDAR_EVENT_STATUS_NONE:
+ DBG("None status");
+ break;
+ case CALENDAR_EVENT_STATUS_TENTATIVE:
+ status = "TENTATIVE";
+ break;
+ case CALENDAR_EVENT_STATUS_CONFIRMED:
+ status = "CONFIRMED";
+ break;
+ case CALENDAR_EVENT_STATUS_CANCELLED:
+ status = "CANCELLED";
+ break;
+ }
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = calendar_record_get_int(record, _calendar_todo.todo_status, &value);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() is failed(%d)", ret);
+ switch (value)
+ {
+ case CALENDAR_TODO_STATUS_NONE:
+ DBG("None status");
+ break;
+ case CALENDAR_TODO_STATUS_NEEDS_ACTION:
+ status = (VCAL_VER_1 == b->version) ? "NEEDS ACTION" : "NEEDS-ACTION";
+ break;
+ case CALENDAR_TODO_STATUS_COMPLETED:
+ status = "COMPLETED";
+ break;
+ case CALENDAR_TODO_STATUS_IN_PROCESS:
+ status = (VCAL_VER_1 == b->version) ? NULL : "IN-PROCESS";
+ break;
+ case CALENDAR_TODO_STATUS_CANCELED:
+ status = (VCAL_VER_1 == b->version) ? NULL : "CANCELLED";
break;
-
- default:
- __cal_vcalendar_make_rrule(b, freq, record);
}
+ break;
}
+ if (status && *status)
+ __cal_vcalendar_make_printf(b, "STATUS:", status);
+}
- // last_mod
-/* keis want to skip for there potential error.
- ret = calendar_record_get_lli(record, _calendar_event.last_modified_time, &llival);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1,
- "Failed to get last_modified_time(%d)", ret);
-
- ret = __cal_vcalendar_make_last_mod(b, llival);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
-*/
- // location
- __cal_vcalendar_make_printf_str_p(record, _calendar_event.location, b, "LOCATION:");
+static void __make_completed(cal_make_s *b, calendar_record_h record)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
- // organizer email
- strval = NULL;
- strval2 = NULL;
- ret = calendar_record_get_str_p(record, _calendar_event.organizer_name, &strval);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1,
- "Failed to get organizer_name(%d)", ret);
+ if (CALENDAR_BOOK_TYPE_EVENT == b->type) // Invalid component in event
+ return;
- ret = calendar_record_get_str_p(record, _calendar_event.organizer_email, &strval2);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1,
- "Failed to get organizer_email(%d)", ret);
+ int ret = 0;
+ long long int value = 0;
+ ret = calendar_record_get_lli(record, _calendar_todo.completed_time, &value);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() is failed(%d)", ret);
+
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
+ _cal_time_get_datetime(value, &y, &m, &d, &h, &n, &s);
+ char buf[128] = {0};
+ snprintf(buf, sizeof(buf), VCAL_DATETIME_FORMAT_YYYYMMDDTHHMMSSZ, y, m, d, h, n, s);
+ __cal_vcalendar_make_printf(b, "COMPLETED", buf);
+}
- if (strval || strval2) {
- ret = __cal_vcalendar_make_organizer(b, strval, strval2);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
+static void __make_priority(cal_make_s *b, calendar_record_h record)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
- } else {
- DBG("No organizer name or email");
+ int ret = 0;
+ int value = 0;
+ switch (b->type)
+ {
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = calendar_record_get_int(record, _calendar_event.priority, &value);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() is failed(%d)", ret);
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = calendar_record_get_int(record, _calendar_todo.priority, &value);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() is failed(%d)", ret);
+ break;
}
+ int priority = 0;
+ switch (b->version)
+ {
+ case VCAL_VER_1:
+ switch (value)
+ {
+ case CALENDAR_EVENT_PRIORITY_HIGH:
+ priority = 2;
+ break;
+ case CALENDAR_EVENT_PRIORITY_NORMAL:
+ priority = 1;
+ break;
+ case CALENDAR_EVENT_PRIORITY_LOW:
+ priority = 0;
+ break;
+ default:
+ priority = 0;
+ break;
+ }
+ break;
+ case VCAL_VER_2:
+ switch (value)
+ {
+ case CALENDAR_EVENT_PRIORITY_HIGH: // in version 2.0, one out of 1 ~ 4.
+ priority = 3;
+ break;
+ case CALENDAR_EVENT_PRIORITY_NORMAL:
+ priority = 5;
+ break;
+ case CALENDAR_EVENT_PRIORITY_LOW: // in version 2, one out of 6 ~ 9.
+ priority = 7;
+ break;
+ default:
+ priority = 0;
+ break;
+ }
+ break;
+ }
+ char buf[128] = {0};
+ snprintf(buf, sizeof(buf), "PRIORITY:%d", priority);
+ __cal_vcalendar_make_printf(b, buf, NULL);
+}
- // priority
- ret = calendar_record_get_int(record, _calendar_event.priority, &intval);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1,
- "Failed to get priority(%d)", ret);
-
- DBG("priority(%d)", intval);
- ret = __cal_vcalendar_make_priority(b, intval);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
-
- // TODO : seq
+static void __make_dtstamp(cal_make_s *b, calendar_record_h record)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
- // dtstamp
-/* keis want to skip for there potential error.
- ret = __cal_vcalendar_make_dtstamp(b, tzid);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
-*/
+ if (VCAL_VER_1 == b->version) // Not support in ver 1
+ return;
- // summary
- __cal_vcalendar_make_printf_str_p(record, _calendar_event.summary, b, "SUMMARY:");
+ long long int t = _cal_time_get_now();
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
+ _cal_time_get_datetime(t, &y, &m, &d, &h, &n, &s);
+ char buf[128] = {0};
+ snprintf(buf, sizeof(buf), VCAL_DATETIME_FORMAT_YYYYMMDDTHHMMSSZ, y, m, d, h, n, s);
+ __cal_vcalendar_make_printf(b, "DTSTAMP:", buf);
+}
- // dtend
- ret = calendar_record_get_caltime(record, _calendar_event.end_time, &caltime);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1,
- "Failed to get end_time(%d)", ret);
+static void __make_categories(cal_make_s *b, calendar_record_h record)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
- ret = __cal_vcalendar_make_dtend(version, b, tzid, &caltime);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1, "Failed to get end(%d)", ret);
+ int ret = 0;
+ char *value = NULL;
+ switch (b->type)
+ {
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = calendar_record_get_str_p(record, _calendar_event.categories, &value);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() is failed(%d)", ret);
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = calendar_record_get_str_p(record, _calendar_todo.categories, &value);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() is failed(%d)", ret);
+ break;
+ }
+ if (value && *value)
+ __cal_vcalendar_make_printf(b, "CATEGORIES:", value);
+}
- // categories
- __cal_vcalendar_make_printf_str_p(record, _calendar_event.categories, b, "CATEGORIES:");
+static char* __get_new_uid(void)
+{
+ long long int t = _cal_time_get_now();
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
+ _cal_time_get_datetime(t, &y, &m, &d, &h, &n, &s);
+ char buf[128] = {0};
+ snprintf(buf, sizeof(buf), VCAL_DATETIME_FORMAT_YYYYMMDDTHHMMSSZ"@tizen.org", y, m, d, h, n, s);
+ return strdup(buf);
+}
+static char* __get_parent_uid(int parent_id)
+{
+ calendar_record_h record = NULL;
+ calendar_db_get_record(_calendar_event._uri, parent_id, &record);
- // uid
- __cal_vcalendar_make_printf_str_p(record, _calendar_event.uid, b, "UID:");
+ char *uid = NULL;
+ calendar_record_get_str(record, _calendar_event.uid, &uid);
+ calendar_record_destroy(record, true);
- // exdate
- __cal_vcalendar_make_printf_str_p(record, _calendar_event.exdate, b, "EXDATE:");
+ if (NULL == uid || '\0' == *uid) {
+ if (uid) free(uid);
+ return NULL;
+ }
+ return uid;
+}
+static void __set_parent_uid(int parent_id, char *uid)
+{
+ calendar_record_h record = NULL;
+ calendar_db_get_record(_calendar_event._uri, parent_id, &record);
+ calendar_record_set_str(record, _calendar_event.uid, uid);
+ calendar_db_update_record(record);
+ calendar_record_destroy(record, true);
+}
+static void __set_child_uid(calendar_record_h record, char *uid)
+{
+ calendar_record_set_str(record, _calendar_event.uid, uid);
+ calendar_db_update_record(record);
+}
+static void __make_uid(cal_make_s *b, calendar_record_h record)
+{
+ ENTER();
+ char *uid = NULL;
+
+ // search if original_event_id > 0.
+ int original_event_id = 0;
+ calendar_record_get_int(record, _calendar_event.original_event_id, &original_event_id);
+ char *recurrence_id = NULL;
+ if (original_event_id < 0) {
+ DBG("This is parent event: original_event_id < 0");
+ calendar_record_get_str_p(record, _calendar_event.uid, &uid);
+ if (uid && *uid) {
+ __cal_vcalendar_make_printf(b, "UID:", uid);
+ } else {
+ uid = __get_new_uid();
+ __cal_vcalendar_make_printf(b, "UID:", uid);
+ free(uid);
+ }
+ if (VCAL_VER_1 == b->version) // ver 1.0 does not support: recurrence-id
+ return;
- unsigned int count;
- calendar_record_h child = NULL;
+ calendar_record_get_str_p(record, _calendar_event.recurrence_id, &recurrence_id);
+ if (recurrence_id && *recurrence_id) {
+ if (*recurrence_id >= '0' && *recurrence_id <= '9')
+ __cal_vcalendar_make_printf(b, "RECURRENCE-ID:", recurrence_id);
+ else
+ __cal_vcalendar_make_printf(b, "RECURRENCE-ID;", recurrence_id);
+ }
+ return;
+ }
- // attendee
- count = 0;
- ret = calendar_record_get_child_record_count(record,
- _calendar_event.calendar_attendee, &count);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1,
- "Failed to get child count(%d)", ret);
+ // if original_event_id > 0, get parent uid.
+ uid = __get_parent_uid(original_event_id);
+ if (NULL == uid || '\0' == *uid) {
+ uid = __get_new_uid();
+ __set_parent_uid(original_event_id, uid);
+ }
+ __set_child_uid(record, uid);
+ __cal_vcalendar_make_printf(b, "UID:", uid);
- while (count > 0)
- {
- count--;
- ret = calendar_record_get_child_record_at_p(record,
- _calendar_event.calendar_attendee, count, &child);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1,
- "Failed to get child attendee(%d)", ret);
+ if (VCAL_VER_1 == b->version) // ver 1.0 does not support: recurrence-id
+ return;
- ret = __cal_vcalendar_make_attendee(b, child);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
- }
- if (count <= 0)
- {
- DBG("No attendee");
- }
+ if (*recurrence_id >= '0' && *recurrence_id <= '9')
+ __cal_vcalendar_make_printf(b, "RECURRENCE-ID:", recurrence_id);
+ else
+ __cal_vcalendar_make_printf(b, "RECURRENCE-ID;", recurrence_id);
+}
+static void __make_exdate(cal_make_s *b, calendar_record_h record)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
- // alarm
- count = 0;
- switch (version)
+ int ret = 0;
+ char *value = NULL;
+ switch (b->type)
{
- case 1:
- // In ver 1.0, only first alarm will be dealt with.
- ret = calendar_record_get_child_record_count(record, _calendar_event.calendar_alarm, &count);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1, "Failed to get child count(%d)", ret);
- if (count > 0)
- {
- ret = calendar_record_get_child_record_at_p(record, _calendar_event.calendar_alarm, 0, &child);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1, "Failed to get child alarm(%d)", ret);
-
- ret = __cal_vcalendar_make_aalarm(b, record, child);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
- }
- else
- {
- DBG("No alarm in ver1.0");
- }
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = calendar_record_get_str_p(record, _calendar_event.exdate, &value);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() is failed(%d)", ret);
break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ERR("Not support exdate in TODO");
+ break;
+ }
+ if (value && *value)
+ __cal_vcalendar_make_printf(b, "EXDATE:", value);
+}
- default:
- ret = calendar_record_get_child_record_count(record, _calendar_event.calendar_alarm, &count);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1, "Failed to get child count(%d)", ret);
+static void __cal_vcalendar_make_child_extended(cal_make_s *b, calendar_record_h child, bool *has_lunar)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == child, "Invalid parameter: record is NULL");
- while (count > 0)
- {
- count--;
- ret = calendar_record_get_child_record_at_p(record, _calendar_event.calendar_alarm, count, &child);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1, "Failed to get child alarm(%d)", ret);
+ int ret = 0;;
+ char *key = NULL;
+ char *value = NULL;
- ret = __cal_vcalendar_make_alarm(b, child);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
- }
+ ret = calendar_record_get_str_p(child, _calendar_extended_property.key, &key);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() is failed(%d)", ret);
+ if (NULL == key || '\0' == *key || (0 != strncmp(key, "X-", strlen("X-")))) {
+ DBG("Not extended for vcalendar[%s]", key);
+ return;
+ }
- if (count <= 0)
- {
- DBG("No alarm in ver2.0");
+ ret = calendar_record_get_str_p(child, _calendar_extended_property.value, &value);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() is failed(%d)", ret);
+
+ // check lunar: will handle next
+ if (has_lunar) {
+ if ((!strncmp(key, "X-LUNAR", strlen("X-LUNAR")) && !strncmp(value, ":SET", strlen(":SET"))) ||
+ (!strncmp(key, "X-LUNAR:", strlen("X-LUNAR:")) && !strncmp(value, "SET", strlen("SET")))) {
+ *has_lunar = true;
+ return;
}
}
- // extended
- count = 0;
- ret = calendar_record_get_child_record_count(record, _calendar_event.extended, &count);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1, "Failed to get child count(%d)", ret);
+ ret = __cal_vcalendar_make_printf(b, key, value);
+ retm_if (CALENDAR_ERROR_NONE != ret, "__cal_vcalendar_make_printf() is failed(%d)", ret);
+}
+
+static void __make_extended(cal_make_s *b, calendar_record_h record)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
- while (count > 0)
+ int ret = 0;
+ unsigned int count = 0;
+ int i;
+ bool has_lunar = false;
+ int calendar_system_type = 0;
+ switch (b->type)
{
- count--;
- ret = calendar_record_get_child_record_at_p(record, _calendar_event.extended, count, &child);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1, "Failed to get child alarm(%d)", ret);
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = calendar_record_get_child_record_count(record, _calendar_event.extended, &count);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_child_record_count() is failed(%d)", ret);
+ for (i = 0; i < count; i++) {
+ calendar_record_h child = NULL;
+ ret = calendar_record_get_child_record_at_p(record, _calendar_event.extended, i, &child);
+ warn_if(CALENDAR_ERROR_NONE != ret, "Failed to get child alarm(%d)", ret);
+
+ __cal_vcalendar_make_child_extended(b, child, &has_lunar);
+ }
- ret = __cal_vcalendar_make_child_extended(b, child);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
- }
+ // lunar
+ ret = calendar_record_get_int(record, _calendar_event.calendar_system_type, &calendar_system_type);
+ retm_if (CALENDAR_ERROR_NONE != ret, "Failed to get calendar_record_type(%d)", ret);
- if (count <= 0)
- {
- DBG("No extended");
+ if (true == has_lunar || CALENDAR_SYSTEM_EAST_ASIAN_LUNISOLAR == calendar_system_type)
+ __cal_vcalendar_make_printf(b, "X-LUNAR:SET", NULL);
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = calendar_record_get_child_record_count(record, _calendar_todo.extended, &count);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_child_record_count() is failed(%d)", ret);
+ for (i = 0; i < count; i++) {
+ calendar_record_h child = NULL;
+ ret = calendar_record_get_child_record_at_p(record, _calendar_todo.extended, i, &child);
+ warn_if(CALENDAR_ERROR_NONE != ret, "Failed to get child alarm(%d)", ret);
+
+ __cal_vcalendar_make_child_extended(b, child, NULL);
+ }
+ break;
}
-
- return __cal_vcalendar_make_printf(b, "END:VEVENT", NULL);
}
-int __cal_vcalendar_make_todo(int version, cal_make_s *b, calendar_record_h record)
+static void __make_end(cal_make_s *b, calendar_record_h record)
{
- int ret;
- int intval;
- calendar_time_s caltime = {0};
- char *uri = NULL;
- char *tzid = NULL;
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
- ret = calendar_record_get_uri_p(record, &uri);
-
- //_cal_db_rrule_fill_record(record);
-
- ret = __cal_vcalendar_make_printf(b, "BEGIN:VTODO", NULL);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
+ int ret = 0;
+ switch (b->type)
+ {
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = __cal_vcalendar_make_printf(b, "END:VEVENT", NULL);
+ retm_if(CALENDAR_ERROR_NONE != ret, "__cal_vcalendar_make_printf() is failed(%d)", ret);
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = __cal_vcalendar_make_printf(b, "END:VTODO", NULL);
+ retm_if (CALENDAR_ERROR_NONE != ret, "__cal_vcalendar_make_printf() is failed(%d)", ret);
+ break;
+ }
+}
- // sensitivity
- ret = calendar_record_get_int(record, _calendar_todo.sensitivity, &intval);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1,
- "Failed to get sensitivity(%d)", ret);
- __cal_vcalendar_make_class(b, intval);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
+static void __cal_vcalendar_make_schedule(cal_make_s *b, calendar_record_h record)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+
+ __make_begin(b, record);
+ __make_summary(b, record);
+ __make_dtstart(b, record);
+ __make_dtend(b, record);
+ __make_rrule(b, record); // only event
+ __make_sensitivity(b, record);
+ __make_created_time(b, record);
+ __make_description(b, record);
+ __make_location(b, record);
+ __make_organizer(b, record);
+ __make_last_modified(b, record);
+ __make_status(b, record);
+ __make_completed(b, record); // only todo
+ __make_priority(b, record);
+ __make_dtstamp(b, record);
+ __make_categories(b, record);
+ __make_uid(b, record);
+ __make_exdate(b, record); // only event
+ __make_attendee(b, record);
+ __make_alarm(b, record);
+ __make_extended(b, record);
+ __make_end(b, record);
- // dtstart_type
- ret = calendar_record_get_str_p(record, _calendar_todo.start_tzid, &tzid);
- ret = calendar_record_get_caltime(record, _calendar_todo.start_time, &caltime);
- if (ret != CALENDAR_ERROR_NONE) {
- ERR("Failed to get start_time(%d)", ret);
- return -1;
- }
- ret = __cal_vcalendar_make_dtstart(version, b, tzid, &caltime);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1,
- "Failed to get dtstart(%d)", ret);
+}
- // created_time
-/* keis want to skip for there potential error.
- ret = calendar_record_get_lli(record, _calendar_todo.created_time, &llival);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1,
- "Failed to get created_time(%d)", ret);
+static void __append_header(cal_make_s *b)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
- ret = __cal_vcalendar_make_created(b, llival);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
-*/
+ int ret = 0;
- // description
- __cal_vcalendar_make_printf_str_p(record, _calendar_todo.description, b, "DESCRIPTION:");
+ ret = __cal_vcalendar_make_printf(b, "BEGIN:VCALENDAR", NULL);
+ retm_if (CALENDAR_ERROR_NONE != ret, "__cal_vcalendar_make_printf() is failed(%d)", ret);
+ ret = __cal_vcalendar_make_printf(b, "PRODID:vCal ID Default", NULL);
+ retm_if (CALENDAR_ERROR_NONE != ret, "__cal_vcalendar_make_printf() is failed(%d)", ret);
- // TODO : geo
+ char buf[32] = {0};
+ snprintf(buf, sizeof(buf), "VERSION:%d.0", b->version);
+ ret = __cal_vcalendar_make_printf(b, buf, NULL);
+ retm_if (CALENDAR_ERROR_NONE != ret, "__cal_vcalendar_make_printf() is failed(%d)", ret);
+}
- // last_mod
-/* keis want to skip for there potential error.
- ret = calendar_record_get_lli(record, _calendar_todo.last_modified_time, &llival);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1,
- "Failed to get last_modified_time(%d)", ret);
+static void __make_footer(cal_make_s *b)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
- ret = __cal_vcalendar_make_last_mod(b, llival);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
-*/
+ int ret = 0;
+ ret = __cal_vcalendar_make_printf(b, "END:VCALENDAR", NULL);
+ retm_if(CALENDAR_ERROR_NONE != ret, "__cal_vcalendar_make_printf() is failed(%d)", ret);
+}
- // location
- __cal_vcalendar_make_printf_str_p(record, _calendar_todo.location, b, "LOCATION:");
+static void __make_tz(cal_make_s *b, char *tzid, long long int created)
+{
+ retm_if (NULL == b, "Invalid parameter: cal_make_s is NULL");
+ retm_if (NULL == tzid || '\0' == *tzid, "Invalid parameter: tzid is NULL");
- // priority
- ret = calendar_record_get_int(record, _calendar_todo.priority, &intval);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1,
- "Failed to get priority(%d)", ret);
+ int ret = 0;
- DBG("priority(%d)", intval);
- ret = __cal_vcalendar_make_priority(b, intval);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
+ time_t zone = 0;
+ time_t dst = 0;
+ _cal_time_get_tz_offset(tzid, &zone, &dst);
+ DBG("offset zone(%ld), dst (%ld)", zone, dst);
- // TODO : seq
+ bool in_dst = _cal_time_in_dst(tzid, created);
+ dst = in_dst ? dst : 0; // dst in TZ is depending on created time.
+ DBG("tzid[%s] created time(%lld) in_dst(%d)", tzid, created, in_dst);
- // dtstamp
-/* keis want to skip for there potential error.
- ret = __cal_vcalendar_make_dtstamp(b, tzid);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
-*/
+ int h = (zone / 3600) + (dst / 3600);
+ int m = (zone % 3600) / 60 + (dst % 3600) / 60;
- // summary
- __cal_vcalendar_make_printf_str_p(record, _calendar_todo.summary, b, "SUMMARY:");
+ char buf[32] = {0};
+ snprintf(buf, sizeof(buf), "TZ:%s%02d:%02d",
+ h == 0 ? "" : (h < 0 ? "-" : "+"),
+ h < 0 ? (-1 * h) : h, m < 0 ? (-1 * m) : m);
- // dtend
- ret = calendar_record_get_caltime(record, _calendar_todo.due_time, &caltime);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1,
- "Failed to get due_time(%d)", ret);
+ ret = __cal_vcalendar_make_printf(b, buf, NULL);
+ retm_if(CALENDAR_ERROR_NONE != ret, "__cal_vcalendar_make_printf() is failed");
+ DBG("append tzid[%s]", buf);
+}
- ret = __cal_vcalendar_make_due(version, b, tzid, &caltime);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1, "__cal_vcalendar_make_due() failed(%d)", ret);
+static void __devide_vcalendar_with_header(cal_make_s *b, calendar_record_h record)
+{
+ retm_if (NULL == b, "cal_make_s is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
- // categories
- __cal_vcalendar_make_printf_str_p(record, _calendar_todo.categories, b, "CATEGORIES:");
+ if (2 == b->version)
+ return;
- // uid
- __cal_vcalendar_make_printf_str_p(record, _calendar_todo.uid, b, "UID:");
+ int ret = 0;
+ char *uri = NULL;
+ ret = calendar_record_get_uri_p(record, &uri);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_uri_p() is failed(%d)", ret);
- // alarm
- unsigned int count;
- calendar_record_h child = NULL;
+ char *tzid = NULL;
+ long long int created = 0;
- switch (version)
+ switch (b->type)
{
- case 1:
- // In ver 1.0, only first alarm will be dealt with.
- ret = calendar_record_get_child_record_count(record, _calendar_todo.calendar_alarm, &count);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1, "Failed to get child count(%d)", ret);
- if (count > 0)
- {
- ret = calendar_record_get_child_record_at_p(record, _calendar_todo.calendar_alarm, 0, &child);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1, "Failed to get child alarm(%d)", ret);
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = calendar_record_get_str_p(record, _calendar_event.start_tzid, &tzid);
+ warn_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() is failed(%d)", ret);
+ ret = calendar_record_get_lli(record, _calendar_event.created_time, &created);
+ warn_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_lli() is failed(%d)", ret);
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = calendar_record_get_str_p(record, _calendar_todo.due_tzid, &tzid);
+ warn_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_str_p() is failed(%d)", ret);
+ ret = calendar_record_get_lli(record, _calendar_todo.created_time, &created);
+ warn_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_lli() is failed(%d)", ret);
+ break;
+ }
- ret = __cal_vcalendar_make_aalarm(b, record, child);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
- }
- else
- {
- DBG("No alarm in ver1.0");
+ if (NULL == tzid || '\0' == *tzid) {
+ DBG("No tzid");
+ return;
+ }
+
+ if (NULL == b->timezone_tzid || '\0' == *b->timezone_tzid) { // new start of vcalendar
+ __make_tz(b, tzid, created);
+ b->timezone_tzid = strdup(tzid);
+ } else { // not first vcalendar
+ if (0 != strncmp(b->timezone_tzid, tzid, strlen(tzid))) { // different tzid
+ __make_footer(b);
+ __append_header(b);
+ __make_tz(b, tzid, created);
+ if (b->timezone_tzid)
+ free(b->timezone_tzid);
+ b->timezone_tzid = strdup(tzid);
+ } else {
+ DBG("same as before, skip");
}
- break;
+ }
+}
+static int __make_vcalendar(cal_make_s *b, calendar_list_h list)
+{
+ retvm_if (NULL == b, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: cal_make_s is NULL");
+ retvm_if (NULL == list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid paramter: list is NULL");
- default:
- ret = calendar_record_get_child_record_count(record, _calendar_todo.calendar_alarm, &count);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1, "Failed to get child count(%d)", ret);
+ int ret = CALENDAR_ERROR_NONE;
+ calendar_record_h record = NULL;
- while (count > 0)
- {
- count--;
- ret = calendar_record_get_child_record_at_p(record, _calendar_todo.calendar_alarm, count, &child);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1, "Failed to get child alarm(%d)", ret);
+ __append_header(b);
- ret = __cal_vcalendar_make_alarm(b, child);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
- }
+ // start
+ ret = calendar_list_first(list);
+ retvm_if (CALENDAR_ERROR_NONE != ret, ret, "calendar_list_first() Failed");
+ do {
+ ret = calendar_list_get_current_record_p(list, &record);
+ if (CALENDAR_ERROR_NONE != ret) break;
- if (count <= 0)
- {
- DBG("No alarm in ver2.0");
- }
- }
+ // start vcalendar
+ char *uri = NULL;
+ ret = calendar_record_get_uri_p(record, &uri);
+ DBG("uri[%s]", uri);
- // extended
- count = 0;
- ret = calendar_record_get_child_record_count(record, _calendar_todo.extended, &count);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1, "Failed to get child count(%d)", ret);
+ if (!strcmp(uri, _calendar_event._uri)) {
+ b->type = CALENDAR_BOOK_TYPE_EVENT;
+ __devide_vcalendar_with_header(b, record);
+ __cal_vcalendar_make_schedule(b, record);
- while (count > 0)
- {
- count--;
- ret = calendar_record_get_child_record_at_p(record, _calendar_todo.extended, count, &child);
- retvm_if(ret != CALENDAR_ERROR_NONE, -1, "Failed to get child alarm(%d)", ret);
+ } else if (!strcmp(uri, _calendar_todo._uri)) {
+ b->type = CALENDAR_BOOK_TYPE_TODO;
+ __devide_vcalendar_with_header(b, record);
+ __cal_vcalendar_make_schedule(b, record);
- ret = __cal_vcalendar_make_child_extended(b, child);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
- }
- if (count <= 0)
- {
- DBG("No extended");
- }
+ } else if (!strcmp(uri, _calendar_extended_property._uri)) {
+ cal_extended_s *extended = (cal_extended_s *)record;
+ if (!strncmp(extended->key, "VERSION", strlen("VERSION"))) continue;
- return __cal_vcalendar_make_printf(b, "END:VTODO", NULL);
-}
+ ret = __cal_vcalendar_make_printf(b, extended->key, extended->value);
+ if (CALENDAR_ERROR_NONE != ret) break;
-int __cal_vcalendar_make_parent_extended(cal_make_s *b, calendar_list_h list, int *has_extended, int *version)
-{
- int ret = CALENDAR_ERROR_NONE;
- GList *l = NULL;
- cal_list_s *cal_list = (cal_list_s *)list;
+ DBG("extended key[%s] value[%s]", extended->key, extended->value);
- if (NULL == list)
- {
- ERR("Invalid parameter: list is NULL");
- return CALENDAR_ERROR_DB_FAILED;
- }
+ } else if (!strcmp(uri, _calendar_timezone._uri)) {
+ DBG("Not support timezone");
- l = g_list_first(cal_list->record);
- while (l)
- {
- char *uri = NULL;
- calendar_record_h record = (calendar_record_h)l->data;
- calendar_record_get_uri_p(record, &uri);
- if (strncmp(uri, _calendar_extended_property._uri, strlen(_calendar_extended_property._uri)))
- {
- l = g_list_next(l);
- continue;
- }
+ } else if (!strcmp(uri, _calendar_book._uri)) {
+ DBG("Not support calendar");
- *has_extended = 1;
- cal_extended_s *extended = (cal_extended_s *)record;
- if (NULL == extended)
- {
- ERR("extended is NULL");
- return CALENDAR_ERROR_DB_FAILED;
+ } else {
+ DBG("Unable to understand uri[%s]", uri);
}
- ret = __cal_vcalendar_make_printf(b, extended->key, extended->value);
- DBG("extended key[%s] value[%s]", extended->key, extended->value);
- if (!strncmp(extended->key, "VERSION", strlen("VERSION")))
- {
- if (strstr(extended->value, "1.0"))
- {
- *version = 1;
- }
- else
- {
- *version = 2;
- }
- DBG("version (%s)", extended->value);
- break;
- }
- l = g_list_next(l);
- }
+ } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+ __make_footer(b);
+
return CALENDAR_ERROR_NONE;
}
int _cal_vcalendar_make_vcalendar(cal_make_s *b, calendar_list_h list)
{
- int ret;
- int version = 0;
- int has_extended = 0;
- char *uri = NULL;
- calendar_record_h record;
-
- ret = __cal_vcalendar_make_printf(b, "BEGIN:VCALENDAR", NULL);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
+ retvm_if (NULL == list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid paramter:list is NULL");
- ret = __cal_vcalendar_make_parent_extended(b, list, &has_extended, &version);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
-
- if (has_extended == 0)
- {
-/* keis want to skip for there potential error.
- ret = __cal_vcalendar_make_printf(b, "CALSCALE:GREGORIAN", NULL);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
-
- ret = __cal_vcalendar_make_printf(b, "PRODID:-//Samsung Electronics//Calendar//EN", NULL);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
-*/
+ int ret = CALENDAR_ERROR_NONE;
+ calendar_record_h record = NULL;
- ret = __cal_vcalendar_make_printf(b, "VERSION:2.0", NULL);
- retv_if(ret != CALENDAR_ERROR_NONE, ret);
- }
+ int version = 2; // set default as ver 2.0
ret = calendar_list_first(list);
- retvm_if(ret != CALENDAR_ERROR_NONE, ret,
- "calendar_list_first() Failed");
-
- do
- {
+ retvm_if (CALENDAR_ERROR_NONE != ret, ret, "calendar_list_first() Failed");
+ do {
ret = calendar_list_get_current_record_p(list, &record);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("Failed to get current record(%d)", ret);
- break;
- }
- ret = calendar_record_get_uri_p(record, &uri);
- if (!strcmp(uri, CALENDAR_VIEW_EVENT))
- {
- ret = __cal_vcalendar_make_schedule(version, b, record);
+ if(CALENDAR_ERROR_NONE != ret) break;
- }
- else if (!strcmp(uri, CALENDAR_VIEW_TODO))
- {
- ret = __cal_vcalendar_make_todo(version, b, record);
-
- }
+ char *uri = NULL;
+ ret = calendar_record_get_uri_p(record, &uri);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("__cal_vcalendar_make_schedule() Failed(%d)", ret);
- break;
+ if (!strcmp(uri, _calendar_extended_property._uri)) {
+ cal_extended_s *extended = (cal_extended_s *)record;
+ if (!strncmp(extended->key, "VERSION", strlen("VERSION"))) {
+ version = strstr(extended->value, "1.0") ? 1 : 2;
+ break;
+ }
}
} while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+ b->version = version;
+ DBG("make as version(%d)", version);
- __cal_vcalendar_make_printf(b, "END:VCALENDAR", NULL);
-
+ __make_vcalendar(b, list);
return CALENDAR_ERROR_NONE;
}
-
int size;
char *data;
char lbuf[76];
+ char *timezone_tzid; // TZ(ver1) VTIMEZONE(ver2)
+ int type; // event or todo
+ int version;
} cal_make_s ;
-cal_make_s *_cal_vcalendar_make_new(void);
+cal_make_s* _cal_vcalendar_make_new(void);
int _cal_vcalendar_make_vcalendar(cal_make_s *b, calendar_list_h list);
-char *_cal_vcalendar_make_get_data(cal_make_s *b);
+char* _cal_vcalendar_make_get_data(cal_make_s *b);
void _cal_vcalendar_make_free(cal_make_s **b);
#endif // __CALENDAR_SVC_VCALENDAR_MAKE_H__
#include "cal_record.h"
#include "cal_view.h"
#include "cal_time.h"
-
#include "cal_vcalendar.h"
#include "cal_vcalendar_parse.h"
-enum {
- ENCODE_NONE = 0x0,
- ENCODE_BASE64,
- ENCODE_QUOTED_PRINTABLE,
- ENCODE_MAX,
-};
+#define VCAL_LF 0x0A // \n
+#define VCAL_CR 0x0D // \r
-struct _prop_func {
- char *prop;
- int (*func)(int *val, void *data);
-};
+#define VCAL_DATETIME_FORMAT_YYYYMMDD "%04d%02d%02d"
+#define VCAL_DATETIME_FORMAT_YYYYMMDDTHHMMSS "%04d%02d%02dT%02d%02d%02d"
+#define VCAL_DATETIME_FORMAT_YYYYMMDDTHHMMSSZ "%04d%02d%02dT%02d%02d%02dZ"
-struct _vcalendar_func {
- char *prop;
- int (*func)(int type, calendar_list_h list, calendar_record_h event, char *prop, char *cont);
+struct user_data {
+ char *timezone_tzid; // TZ(ver1) VTIMEZONE(ver2)
+ char *datetime_tzid; // in vevent, vtodo as param: TZID=US-Eastern
+ int version;
+ int type; // event, todo
+ bool is_allday;
};
-struct _record_func {
- char *prop;
- int (*func)(calendar_record_h record, void *data);
+enum {
+ VCAL_RELATED_NONE,
+ VCAL_RELATED_START,
+ VCAL_RELATED_END,
};
-char *_cal_vcalendar_parse_vcalendar(calendar_list_h *list_sch, void *data);
-char *_cal_vcalendar_parse_vevent(int type, calendar_list_h *list_sch, void *data);
-char *_cal_vcalendar_parse_vtodo(int type, calendar_list_h *list_sch, void *data);
-char *_cal_vcalendar_parse_valarm(int type, calendar_record_h record, void *data);
-
enum {
- VCAL_PRODID = 0x0,
- VCAL_VERSION,
-// VCAL_CALSCALE,
-// VCAL_METHOD,
- VCAL_MAX,
+ VCAL_RECURRENCE_NONE,
+ VCAL_RECURRENCE_YEARLY_BYYEARDAY,
+ VCAL_RECURRENCE_YEARLY_BYWEEKLY,
+ VCAL_RECURRENCE_YEARLY_BYMONTH,
+ VCAL_RECURRENCE_YEARLY_BYMONTHDAY,
+ VCAL_RECURRENCE_YEARLY_BYDAY,
+ VCAL_RECURRENCE_MONTHLY_BYMONTHDAY,
+ VCAL_RECURRENCE_MONTHLY_BYDAY,
+ VCAL_RECURRENCE_WEEKLY,
+ VCAL_RECURRENCE_DAILY,
};
-static int __cal_vcalendar_parse_prodid(int *val, void *data);
-static int __cal_vcalendar_parse_version(int *val, void *data);
-
-struct _prop_func _basic_funcs[VCAL_MAX] =
-{
- {"PRODID", __cal_vcalendar_parse_prodid },
- {"VERSION", __cal_vcalendar_parse_version }//,
-// {"CALSCALE", __cal_vcalendar_parse_calscale },
-// {"METHOD", __cal_vcalendar_parse_method }
+enum {
+ VCAL_VER_1 = 1,
+ VCAL_VER_2 = 2,
};
-static int __cal_vcalendar_parse_dtstamp(int type, calendar_list_h list, calendar_record_h event, char *prop, char *cont);
-static int __cal_vcalendar_parse_uid(int type, calendar_list_h list, calendar_record_h record, char *prop, char *cont);
-static int __cal_vcalendar_parse_dtstart(int type, calendar_list_h list, calendar_record_h event, char *prop, char *cont);
-static int __cal_vcalendar_parse_created(int type, calendar_list_h list, calendar_record_h event, char *prop, char *cont);
-static int __cal_vcalendar_parse_description(int type, calendar_list_h list, calendar_record_h event, char *prop, char *cont);
-static int __cal_vcalendar_parse_last_mod(int type, calendar_list_h list, calendar_record_h event, char *prop, char *cont);
-static int __cal_vcalendar_parse_location(int type, calendar_list_h list, calendar_record_h event, char *prop, char *cont);
-static int __cal_vcalendar_parse_priority(int type, calendar_list_h list, calendar_record_h event, char *prop, char *cont);
-static int __cal_vcalendar_parse_status(int type, calendar_list_h list, calendar_record_h event, char *prop, char *cont);
-static int __cal_vcalendar_parse_summary(int type, calendar_list_h list, calendar_record_h event, char *prop, char *cont);
-static int __cal_vcalendar_parse_rrule(int type, calendar_list_h list, calendar_record_h event, char *prop, char *cont);
-static int __cal_vcalendar_parse_dtend(int type, calendar_list_h list, calendar_record_h event, char *prop, char *cont);
-static int __cal_vcalendar_parse_due(int type, calendar_list_h list, calendar_record_h record, char *prop, char *cont);
-
-static int __cal_vcalendar_parse_completed(int type, calendar_list_h list, calendar_record_h event, char *prop, char *cont);
-static int __cal_vcalendar_parse_percent(int type, calendar_list_h list, calendar_record_h event, char *prop, char *cont);
-
-static int __cal_vcalendar_parse_attendee(int type, calendar_list_h list, calendar_record_h event, char *prop, char *cont);
-static int __cal_vcalendar_parse_categories(int type, calendar_list_h list, calendar_record_h event, char *prop, char *cont);
-static int __cal_vcalendar_parse_aalarm(int type, calendar_list_h list, calendar_record_h event, char *prop, char *cont);
-static int __cal_vcalendar_parse_extended(int type, calendar_list_h list, calendar_record_h record, char *prop, char *cont);
-
enum {
- VEVE_DTSTAMP = 0x0,
- VEVE_UID,
- VEVE_DTSTART,
- VEVE_CREATED,
- VEVE_DESCRIPTION,
- VEVE_LAST_MOD,
- VEVE_LOCATION,
- VEVE_PRIORITY,
- VEVE_STATUS,
- VEVE_SUMMARY,
- VEVE_RRULE,
- VEVE_DTEND,
- VEVE_DUE,
- VEVE_ATTENDEE,
- VEVE_CATEGORIES,
- VEVE_AALARM, /* for ver 1.0 */
- VEVE_EXTENDED,
- VEVE_MAX,
+ VCAL_DATETIME_LENGTH_YYYYMMDD = 8,
+ VCAL_DATETIME_LENGTH_YYYYMMDDTHHMMSS = 15,
+ VCAL_DATETIME_LENGTH_YYYYMMDDTHHMMSSZ = 16,
};
-struct _vcalendar_func _vevent_funcs[VEVE_MAX] =
-{
- { "DTSTAMP", __cal_vcalendar_parse_dtstamp },
- { "UID", __cal_vcalendar_parse_uid },
- { "DTSTART", __cal_vcalendar_parse_dtstart },
- { "CREATED", __cal_vcalendar_parse_created },
- { "DESCRIPTION", __cal_vcalendar_parse_description },
- { "LAST-MOD", __cal_vcalendar_parse_last_mod },
- { "LOCATION", __cal_vcalendar_parse_location },
- { "PRIORITY", __cal_vcalendar_parse_priority },
- { "STATUS", __cal_vcalendar_parse_status },
- { "SUMMARY", __cal_vcalendar_parse_summary },
- { "RRULE", __cal_vcalendar_parse_rrule },
- { "DTEND", __cal_vcalendar_parse_dtend },
- { "DUE", __cal_vcalendar_parse_due },
- { "ATTENDEE", __cal_vcalendar_parse_attendee },
- { "CATEGORIES", __cal_vcalendar_parse_categories },
- { "AALARM", __cal_vcalendar_parse_aalarm },
- { "X-", __cal_vcalendar_parse_extended },
+enum {
+ VCAL_COMPONENT_NONE,
+ VCAL_COMPONENT_VEVENT,
+ VCAL_COMPONENT_VTODO,
+ VCAL_COMPONENT_VJOURNAL,
+ VCAL_COMPONENT_VFREEBUSY,
+ VCAL_COMPONENT_VTIMEZONE,
+ VCAL_COMPONENT_MAX,
};
-static int __cal_vcalendar_parse_action(calendar_record_h alarm, void *data);
-static int __cal_vcalendar_parse_trigger(calendar_record_h alarm, void *data);
-static int __cal_vcalendar_parse_repeat(calendar_record_h alarm, void *data);
-static int __cal_vcalendar_parse_duration_alarm(calendar_record_h alarm, void *data);
-static int __cal_vcalendar_parse_attach_alarm(calendar_record_h alarm, void *data);
-static int __cal_vcalendar_parse_summary_alarm(calendar_record_h alarm, void *data);
-
enum {
- VALA_ACTION = 0x0,
- VALA_TRIGGER,
- VALA_REPEAT,
- VALA_DURATION,
- VALA_ATTACH,
-// VALA_DESCRIPTION,
- VALA_SUMMARY,
-// VALA_ATTENDEE,
- VALA_MAX,
+ VCAL_PROPERTY_NONE,
+ VCAL_PROPERTY_VERSION,
+ VCAL_PROPERTY_TZ,
+ VCAL_PROPERTY_BEGIN,
+ VCAL_PROPERTY_END,
+ VCAL_PROPERTY_MAX,
};
-struct _record_func _valarm_funcs[VALA_MAX] =
-{
- { "ACTION", __cal_vcalendar_parse_action },
- { "TRIGGER", __cal_vcalendar_parse_trigger },
- { "REPEAT", __cal_vcalendar_parse_repeat },
- { "DURATION", __cal_vcalendar_parse_duration_alarm },
- { "ATTACH", __cal_vcalendar_parse_attach_alarm },
-// { "DESCRIPTION", __cal_vcalendar_parse_description },
- { "SUMMARY", __cal_vcalendar_parse_summary_alarm },
-// { "ATTENDEE", __cal_vcalendar_parse_attendee },
+enum {
+ VCAL_COMPONENT_PROPERTY_NONE,
+ VCAL_COMPONENT_PROPERTY_DTSTAMP,
+ VCAL_COMPONENT_PROPERTY_UID,
+ VCAL_COMPONENT_PROPERTY_RECURRENCE_ID,
+ VCAL_COMPONENT_PROPERTY_DTSTART,
+ VCAL_COMPONENT_PROPERTY_CREATED, // for ver 2: created
+ VCAL_COMPONENT_PROPERTY_DCREATED, // for ver 1: created
+ VCAL_COMPONENT_PROPERTY_DESCRIPTION,
+ VCAL_COMPONENT_PROPERTY_LAST_MODIFIED,
+ VCAL_COMPONENT_PROPERTY_LOCATION,
+ VCAL_COMPONENT_PROPERTY_PRIORITY,
+ VCAL_COMPONENT_PROPERTY_STATUS,
+ VCAL_COMPONENT_PROPERTY_SUMMARY,
+ VCAL_COMPONENT_PROPERTY_RRULE,
+ VCAL_COMPONENT_PROPERTY_DTEND,
+ VCAL_COMPONENT_PROPERTY_DUE,
+ VCAL_COMPONENT_PROPERTY_ATTENDEE,
+ VCAL_COMPONENT_PROPERTY_CATEGORIES,
+ VCAL_COMPONENT_PROPERTY_DALARM, // for ver 1: display alarm
+ VCAL_COMPONENT_PROPERTY_MALARM, // for ver 1: mail alarm
+ VCAL_COMPONENT_PROPERTY_AALARM, // for ver 1: audio alarm
+ VCAL_COMPONENT_PROPERTY_EXDATE,
+ VCAL_COMPONENT_PROPERTY_X_ALLDAY,
+ VCAL_COMPONENT_PROPERTY_X_LUNAR,
+ VCAL_COMPONENT_PROPERTY_BEGIN,
+ VCAL_COMPONENT_PROPERTY_END,
+ VCAL_COMPONENT_PROPERTY_EXTENDED,
+ VCAL_COMPONENT_PROPERTY_MAX,
};
enum {
- VTODO_DTSTAMP = 0x0,
- VTODO_UID,
-// VTODO_CLASS,
- VTODO_COMPLETED,
- VTODO_CREATED,
- VTODO_DESCRIPTION,
- VTODO_DTSTART,
-// VTODO_GEO,
- VTODO_LAST_MOD,
- VTODO_LOCATION,
-// VTODO_ORGANIZER,
- VTODO_PERCENT,
- VTODO_PRIORITY,
-// VTODO_RECURID,
-// VTODO_SEQ,
- VTODO_STATUS,
- VTODO_SUMMARY,
-// VTODO_URL,
-// VTODO_RRULE,
- VTODO_DUE,
-// VTODO_DURATION,
-// VTODO_ATTACH,
-// VTODO_ATTENDEE,
-// VTODO_CATEGORIES,
-// VTODO_COMMENT,
-// VTODO_CONTACT,
-// VTODO_EXDATE,
-// VTODO_RSTATUS,
-// VTODO_RELATED,
-// VTODO_RESOURCES,
-// VTODO_RDATE,
-// VTODO_X_PROP,
-// VTODO_IANA_PROP,
- VTODO_AALARM, /* for ver 1.0 */
- VTODO_EXTENDED,
- VTODO_MAX,
+ VCAL_COMPONENT_PROPERTY_VALARM_NONE,
+ VCAL_COMPONENT_PROPERTY_VALARM_ACTION,
+ VCAL_COMPONENT_PROPERTY_VALARM_TRIGGER,
+ VCAL_COMPONENT_PROPERTY_VALARM_REPEAT,
+ VCAL_COMPONENT_PROPERTY_VALARM_ATTACH,
+ VCAL_COMPONENT_PROPERTY_VALARM_DESCRIPTION,
+ VCAL_COMPONENT_PROPERTY_VALARM_SUMMARY,
+ VCAL_COMPONENT_PROPERTY_VALARM_DURATION,
+ VCAL_COMPONENT_PROPERTY_VALARM_END,
+ VCAL_COMPONENT_PROPERTY_VALARM_MAX,
};
-struct _vcalendar_func _vtodo_funcs[VTODO_MAX] =
-{
- { "DTSTAMP", __cal_vcalendar_parse_dtstamp },
- { "UID", __cal_vcalendar_parse_uid },
- { "COMPLETED", __cal_vcalendar_parse_completed },
- { "CREATED", __cal_vcalendar_parse_created },
- { "DESCRIPTION", __cal_vcalendar_parse_description },
- { "DTSTART", __cal_vcalendar_parse_dtstart },
- { "LAST-MOD", __cal_vcalendar_parse_last_mod },
- { "LOCATION", __cal_vcalendar_parse_location },
- { "PERCENT", __cal_vcalendar_parse_percent },
- { "PRIORITY", __cal_vcalendar_parse_priority },
- { "STATUS", __cal_vcalendar_parse_status },
- { "SUMMARY", __cal_vcalendar_parse_summary },
- { "DUE", __cal_vcalendar_parse_due },
- { "AALARM", __cal_vcalendar_parse_aalarm },
- { "X-", __cal_vcalendar_parse_extended },
+enum {
+ VCAL_ENCODING_BASE64,
+ VCAL_ENCODING_QUOTED_PRINTABLE,
+ VCAL_ENCODING_MAX,
};
-static int __cal_vcalendar_parse_freq(calendar_record_h event, void *data);
-static int __cal_vcalendar_parse_until(calendar_record_h event, void *data);
-static int __cal_vcalendar_parse_count(calendar_record_h event, void *data);
-static int __cal_vcalendar_parse_interval(calendar_record_h event, void *data);
-static int __cal_vcalendar_parse_bysecond(calendar_record_h event, void *data);
-static int __cal_vcalendar_parse_byminute(calendar_record_h event, void *data);
-static int __cal_vcalendar_parse_byhour(calendar_record_h event, void *data);
-static int __cal_vcalendar_parse_byday(calendar_record_h event, void *data);
-static int __cal_vcalendar_parse_bymonthday(calendar_record_h event, void *data);
-static int __cal_vcalendar_parse_byyearday(calendar_record_h event, void *data);
-static int __cal_vcalendar_parse_byweekno(calendar_record_h event, void *data);
-static int __cal_vcalendar_parse_bymonth(calendar_record_h event, void *data);
-static int __cal_vcalendar_parse_bysetpos(calendar_record_h event, void *data);
-static int __cal_vcalendar_parse_wkst(calendar_record_h event, void *data);
-
enum {
- RRULE_FREQ = 0x0,
- RRULE_UNTIL,
- RRULE_COUNT,
- RRULE_INTERVAL,
- RRULE_BYSECOND,
- RRULE_BYMINUTE,
- RRULE_BYHOUR,
- RRULE_BYDAY,
- RRULE_BYMONTHDAY,
- RRULE_BYYEARDAY,
- RRULE_BYWEEKNO,
- RRULE_BYMONTH,
- RRULE_BYSETPOS,
- RRULE_WKST,
- RRULE_MAX,
+ VCAL_CHARSET_UTF_8,
+ VCAL_CHARSET_UTF_16,
+ VCAL_CHARSET_UTF_MAX,
};
-struct _record_func _rrule_funcs[RRULE_MAX] =
-{
- { "FREQ=", __cal_vcalendar_parse_freq },
- { "UNTIL=", __cal_vcalendar_parse_until },
- { "COUNT=", __cal_vcalendar_parse_count },
- { "INTERVAL=", __cal_vcalendar_parse_interval },
- { "BYSECOND=", __cal_vcalendar_parse_bysecond },
- { "BYMINUTE=", __cal_vcalendar_parse_byminute },
- { "BYHOUR=", __cal_vcalendar_parse_byhour },
- { "BYDAY=", __cal_vcalendar_parse_byday },
- { "BYMONTHDAY=", __cal_vcalendar_parse_bymonthday },
- { "BYYEARDAY=", __cal_vcalendar_parse_byyearday },
- { "BYWEEKNO=", __cal_vcalendar_parse_byweekno },
- { "BYMONTH=", __cal_vcalendar_parse_bymonth },
- { "BYSETPOS=", __cal_vcalendar_parse_bysetpos },
- { "WKST=", __cal_vcalendar_parse_wkst }
+enum {
+ VCAL_COMPONENT_PROPERTY_VTIMEZONE_NONE,
+ VCAL_COMPONENT_PROPERTY_VTIMEZONE_DTSTART,
+ VCAL_COMPONENT_PROPERTY_VTIMEZONE_TZOFFSETFROM,
+ VCAL_COMPONENT_PROPERTY_VTIMEZONE_TZOFFSETTO,
+ VCAL_COMPONENT_PROPERTY_VTIMEZONE_TZNAME,
+ VCAL_COMPONENT_PROPERTY_VTIMEZONE_RDATE,
+ VCAL_COMPONENT_PROPERTY_VTIMEZONE_END,
+ VCAL_COMPONENT_PROPERTY_VTIMEZONE_MAX,
};
-static int __cal_vcalendar_parse_trig_related(calendar_record_h event, void *data);
-static int __cal_vcalendar_parse_trig_value(calendar_record_h event, void *data);
-
-enum {
- TRIG_RELATED = 0x0,
- TRIG_VALUE,
- TRIG_MAX,
+static const char *vcal_component[VCAL_COMPONENT_MAX] = {0};
+static void __init_component(void)
+{
+ if (NULL == *vcal_component) {
+ vcal_component[VCAL_COMPONENT_VEVENT] = "VEVENT";
+ vcal_component[VCAL_COMPONENT_VTODO] = "VTODO";
+ vcal_component[VCAL_COMPONENT_VJOURNAL] = "VJOURNAL";
+ vcal_component[VCAL_COMPONENT_VFREEBUSY] = "VFREEBUSY";
+ vcal_component[VCAL_COMPONENT_VTIMEZONE] = "VTIMEZONE";
+ }
+}
+
+static const char *vcal_property[VCAL_PROPERTY_MAX] = {0};
+static void __init_property(void)
+{
+ if (NULL == *vcal_property) {
+ vcal_property[VCAL_PROPERTY_VERSION] = "VERSION";
+ vcal_property[VCAL_PROPERTY_TZ] = "TZ";
+ vcal_property[VCAL_PROPERTY_BEGIN] = "BEGIN";
+ vcal_property[VCAL_PROPERTY_END] = "END";
+ }
+}
+
+static const char *component_property[VCAL_COMPONENT_PROPERTY_MAX] = {0};
+static void __init_component_property(void)
+{
+ if (NULL == *component_property) {
+ component_property[VCAL_COMPONENT_PROPERTY_DTSTAMP] = "DTSTAMP";
+ component_property[VCAL_COMPONENT_PROPERTY_UID] = "UID";
+ component_property[VCAL_COMPONENT_PROPERTY_RECURRENCE_ID] = "RECURRENCE-ID";
+ component_property[VCAL_COMPONENT_PROPERTY_DTSTART] = "DTSTART";
+ component_property[VCAL_COMPONENT_PROPERTY_CREATED] = "CREATED"; // for ver 2: created
+ component_property[VCAL_COMPONENT_PROPERTY_DCREATED] = "DCREATED"; // for ver 1: created
+ component_property[VCAL_COMPONENT_PROPERTY_DESCRIPTION] = "DESCRIPTION";
+ component_property[VCAL_COMPONENT_PROPERTY_LAST_MODIFIED] = "LAST-MODIFIED";
+ component_property[VCAL_COMPONENT_PROPERTY_LOCATION] = "LOCATION";
+ component_property[VCAL_COMPONENT_PROPERTY_PRIORITY] = "PRIORITY";
+ component_property[VCAL_COMPONENT_PROPERTY_STATUS] = "STATUS";
+ component_property[VCAL_COMPONENT_PROPERTY_SUMMARY] = "SUMMARY";
+ component_property[VCAL_COMPONENT_PROPERTY_RRULE] = "RRULE";
+ component_property[VCAL_COMPONENT_PROPERTY_DTEND] = "DTEND";
+ component_property[VCAL_COMPONENT_PROPERTY_DUE] = "DUE";
+ component_property[VCAL_COMPONENT_PROPERTY_ATTENDEE] = "ATTENDEE";
+ component_property[VCAL_COMPONENT_PROPERTY_CATEGORIES] = "CATEGORIES";
+ component_property[VCAL_COMPONENT_PROPERTY_DALARM] = "DALARM";
+ component_property[VCAL_COMPONENT_PROPERTY_MALARM] = "MALARM";
+ component_property[VCAL_COMPONENT_PROPERTY_AALARM] = "AALARM";
+ component_property[VCAL_COMPONENT_PROPERTY_EXDATE] = "EXDATE";
+ component_property[VCAL_COMPONENT_PROPERTY_X_ALLDAY] = "X-ALLDAY";
+ component_property[VCAL_COMPONENT_PROPERTY_X_LUNAR] = "X-LUNAR";
+ component_property[VCAL_COMPONENT_PROPERTY_BEGIN] = "BEGIN"; // start alarm component
+ component_property[VCAL_COMPONENT_PROPERTY_END] = "END"; // exit record component
+ component_property[VCAL_COMPONENT_PROPERTY_EXTENDED] = "X-";
+ }
};
-struct _record_func _trig_funcs[TRIG_MAX] =
+static const char *component_property_valarm[VCAL_COMPONENT_PROPERTY_VALARM_MAX] = {0};
+static void __init_component_property_valarm(void)
+{
+ if (NULL == *component_property_valarm) {
+ component_property_valarm[VCAL_COMPONENT_PROPERTY_VALARM_ACTION] = "ACTION";
+ component_property_valarm[VCAL_COMPONENT_PROPERTY_VALARM_TRIGGER] = "TRIGGER";
+ component_property_valarm[VCAL_COMPONENT_PROPERTY_VALARM_REPEAT] = "REPEAT";
+ component_property_valarm[VCAL_COMPONENT_PROPERTY_VALARM_ATTACH] = "ATTACH";
+ component_property_valarm[VCAL_COMPONENT_PROPERTY_VALARM_DESCRIPTION] = "DESCRIPTION";
+ component_property_valarm[VCAL_COMPONENT_PROPERTY_VALARM_SUMMARY] = "SUMMARY";
+ component_property_valarm[VCAL_COMPONENT_PROPERTY_VALARM_DURATION] = "DURATION";
+ component_property_valarm[VCAL_COMPONENT_PROPERTY_VALARM_END] = "END";
+ }
+}
+
+static const char *component_property_vtimezone[VCAL_COMPONENT_PROPERTY_VTIMEZONE_MAX] = {0};
+static void __init_component_property_vtimezone(void)
{
- { "RELATED=", __cal_vcalendar_parse_trig_related },
- { "VALUE=", __cal_vcalendar_parse_trig_value }
+ if (NULL == *component_property_vtimezone) {
+ component_property_vtimezone[VCAL_COMPONENT_PROPERTY_VTIMEZONE_DTSTART] = "DTSTART";
+ component_property_vtimezone[VCAL_COMPONENT_PROPERTY_VTIMEZONE_TZOFFSETFROM] = "TZOFFSETFROM";
+ component_property_vtimezone[VCAL_COMPONENT_PROPERTY_VTIMEZONE_TZOFFSETTO] = "TZOFFSETTO";
+ component_property_vtimezone[VCAL_COMPONENT_PROPERTY_VTIMEZONE_TZNAME] = "TZNAME";
+ component_property_vtimezone[VCAL_COMPONENT_PROPERTY_VTIMEZONE_RDATE] = "RDATE";
+ component_property_vtimezone[VCAL_COMPONENT_PROPERTY_VTIMEZONE_END] = "END";
+ }
};
-static int __cal_vcalendar_parse_charset(int *val, void *data);
-static int __cal_vcalendar_parse_encoding(int *val, void *data);
+static inline void __print_cursor(char *cursor, int line)
+{
+ int i;
+ DBG("(%d)", line);
+ for (i = 0; i < 5; i++) {
+ if (VCAL_CR == *(cursor + i) || VCAL_LF == *(cursor + i)) break;
+ DBG("[%c]", *(cursor + i));
+ }
+}
+static inline void __free_user_data(struct user_data *ud)
+{
+ if (ud) {
+ if (ud->timezone_tzid) free(ud->timezone_tzid);
+ if (ud->datetime_tzid) free(ud->datetime_tzid);
+ free(ud);
+ }
+}
-enum {
- TEXT_CHARSET = 0x0,
- TEXT_ENCODING,
- TEXT_MAX,
-};
+static inline char* __remove_empty_line(char *src)
+{
+ while (*src) {
+ if ('\n' != *src && '\r' != *src)
+ break;
+ src++;
+ }
+ return src;
+}
-struct _prop_func _optional_funcs[TEXT_MAX] =
+static inline char* __remove_invalid_space(char *src)
{
- { "CHARSET=", __cal_vcalendar_parse_charset },
- { "ENCODING=", __cal_vcalendar_parse_encoding },
-};
+ bool start = false;
+ while (*src) {
+ switch (*src) {
+ case ' ':
+ case ':':
+ case ';':
+ src++;
+ break;
+ default:
+ start = true;
+ break;
+ }
+ if (start) break;
+ }
+ return src;
+}
-//util //////////////////////////////////////////////////////////////////////
+static inline char* __crlf(char *p)
+{
+ ENTER();
+ while (VCAL_LF != *p) {
+ if ('\0' == *p) {
+ return NULL;
+ }
+ p++;
+ }
+ return p +1;
+}
-char *_cal_vcalendar_parse_remove_space(char *src)
+static void __get_rest_string(char *p, char **value)
{
- while (*src) {
- if ('\n' != *src && '\r' != *src) {
+ retm_if (NULL == p || '\0' == *p, "Invalid parameter: p is NULL");
+ retm_if (NULL == value, "Invalid parameter: p is NULL");
+
+ int i = 0;
+ while (VCAL_LF != *(p +i)) {
+ if ('\0' == *(p + i)) {
+ return;
+ }
+ if (VCAL_CR == *(p + i -1)) {
+ break;
+ } else {
+ i++;
break;
}
+ i++;
+ }
+ char *v = calloc(i, sizeof(char));
+ retm_if (NULL == v, "calloc() is failed");
+ snprintf(v, i, "%s", p);
+ *value = strdup(v);
+}
+
+static char* __get_value(char *cursor, char **value)
+{
+ retvm_if (NULL == cursor, NULL, "Invalid parameter: cursor is NULL");
+ retvm_if (NULL == value, NULL, "Invalid parameter: value is NULL");
+
+ int offset = 0;
+ while (':' != *(cursor + offset) && ';' != *(cursor + offset)) {
+ // offset: length until ';' or ':'
+ offset++;
+ }
+
+ int i = 0;
+ while (VCAL_LF != *(cursor + offset + i)) {
+ if ('\0' == *(cursor + offset + i)) {
+ return NULL;
+ }
+ i++;
+ }
+
+ char *p = calloc(i + 1, sizeof(char));
+ retvm_if (NULL == p, NULL, "calloc() is failed");
+
+ if (VCAL_CR == *(cursor + offset + i -1)) {
+ memcpy(p, cursor + offset, i -1);
+
+ } else {
+ memcpy(p, cursor + offset, i);
+ }
+ *value = strdup(p);
+ DBG("offset(%d) len(%d) value[%s]", offset, i, *value);
+
+ return cursor + offset + i +1;
+}
+
+static char* __check_word(char *src, const char *word)
+{
+ retvm_if (NULL == src, NULL, "Invalid parameter: src is NULL");
+
+ src = __remove_empty_line(src);
+ src = __remove_invalid_space(src);
+
+ while (*src == *word) {
src++;
+ word++;
+
+ if ('\0' == *src || '\0' == *word)
+ break;
}
- return src;
+
+ if ('\0' == *word)
+ return src;
+ else
+ return NULL;
+}
+
+/*
+ * Change '-' to '/' as icu format to be recognized in icu library.
+ * ig. US-Easten -> US/Eastern
+ */
+static inline void __adjust_tzid(char *p)
+{
+ DBG("Before [%s]", p);
+ int i = 0;
+ while (*(p +i)) {
+ if ('-' == *(p +i)) {
+ if ('1' <= *(p +i +1) && '9' >= *(p +i +1)) {
+ i++;
+ } else {
+ *(p +i) = '/';
+ }
+ }
+ i++;
+ }
+ DBG("After [%s]", p);
+}
+
+static void __unfolding(char *p)
+{
+ retm_if(p == NULL || '\0' == *p, "Invalid parameter: p is NULL");
+
+ char *q = p;
+ while ('\0' != *p) {
+ switch (*p)
+ {
+ case '=':
+ if (VCAL_LF == *(p +1) && ' ' == *(p +2)) // ver1.0:out of spec, but allowed exceptional case
+ p += 3;
+ else if (VCAL_CR == *(p +1) && VCAL_LF == *(p +2) && ' ' == *(p +3)) // ver1.0:in spec case
+ p += 4;
+ else ;
+ break;
+
+ case VCAL_LF:
+ if (' ' == *(p + 1)) // ver2.0:out of spec, but allowed exceptional case
+ p += 2;
+ else if ('\t' == *(p + 1)) // ver2.0:out of spec, but allowed exceptional case
+ p += 2;
+ else ;
+ break;
+
+ case VCAL_CR:
+ if ('\n' == *(p + 1) && ' ' == *(p + 2)) // ver2.0:in spec case
+ p += 3;
+ else if ('\n' == *(p + 1) && '\t' == *(p + 2)) // ver2.0:out of spec, but allowed exceptional case
+ p += 3;
+ else ;
+ break;
+ }
+
+ *q = *p;
+ p++;
+ q++;
+ }
+}
+
+static void __decode_escaped_char(char *p)
+{
+ retm_if (NULL == p || '\0' == *p, "Invalid parameter:p is NULL");
+
+ DBG("Before [%s]", p);
+ char *q = p;
+ while ('\0' != *p) {
+ if ('\\' == *p && *(p +1)) {
+ switch (*(p +1))
+ {
+ case '\\':
+ *q = '\\';
+ p++;
+ break;
+
+ case 'n':
+ case 'N':
+ *q = '\n';
+ p++;
+ break;
+
+ case ';':
+ *q = ';';
+ p++;
+ break;
+
+ case ',':
+ *q = ',';
+ p++;
+ break;
+ }
+ } else {
+ *q = *p;
+ }
+ q++;
+ p++;
+ }
+ *q = '\0';
+}
+
+static void __decode_base64(char *p)
+{
+ retm_if (NULL == p || '\0' == *p, "Invalid parameter: p is NULL");
+
+ DBG("Before [%s]", p);
+ guchar *buf = NULL;
+ gsize size = 0;
+ buf = g_base64_decode(p, &size);
+ if (0 == size) {
+ g_free(buf);
+ return;
+ }
+ if (strlen(p) < size) {
+ ERR("out of size");
+ return;
+ }
+
+ snprintf(p, size + 1, "%s%c", buf, '\0');
+ g_free(buf);
+ DBG("After [%s]", p);
}
-static char __cal_vcalendar_parse_decode_hexa(char *p)
+static char __decode_hexa(char *p)
{
int i;
char decoded[2] = {0x00, 0x00};
break;
}
}
-
return (char)((decoded[0] << 4) + decoded[1]);
}
-static int __cal_vcalendar_parse_decode_quoted_printable(char *p, int *len)
+static void __decode_quoted_printable(char *p)
{
+ retm_if (NULL == p || '\0' == *p, "Invalid parameter: p is NULL");
+
int i = 0, j = 0;
char ch;
+ DBG("Before[%s]", p);
while (p[i]) {
if (p[i] == '=') {
if (p[i+1] == 0x09 || p[i+1] == 0x20) {
j++;
i += 6;
} else {
- ch = __cal_vcalendar_parse_decode_hexa(&p[i+1]);
+ ch = __decode_hexa(p +i +1);
p[j] = ch;
j++;
i += 3;
}
}
p[j] = '\0';
- *len = i;
- return CALENDAR_ERROR_NONE;
+ DBG("After[%s]", p);
}
-////////////////////////////////////////////////////////////////////////
-
-int _cal_vcalendar_parse_unfolding(char *stream)
+static char* __decode_charset(char *p)
{
- char *p;
+ char **t = NULL;
+ t = g_strsplit(p, ":", 2);
+ retvm_if (NULL == t, NULL, "g_strsplit() is failed");
- retv_if(stream == NULL, CALENDAR_ERROR_INVALID_PARAMETER);
+ if ('\0' == *t[0]) { // no param
+ g_strfreev(t);
+ return p + 1;
+ }
- p = stream;
- while ('\0' != *p) {
- if ('=' == *p && '\r' == *(p + 1) && '\n' == *(p + 2)) // ver 1.0
- {
- p += 3;
- }
- else if ('=' == *p && '\n' == *(p + 1)) // ver 1.0 not spec but allow
- {
- p += 2;
- }
- else if ('\r' == *p && '\n' == *(p + 1) && ' ' == *(p + 2)) // ver 2.0
- {
- p += 2;
- }
- else if ('\n' == *p && ' ' == *(p + 1)) // ver 2.0 not spec but allow
- {
- p += 1;
- }
- else
- {
+ // param start
+ int len_param = strlen(t[0]);
+
+ char **s = NULL;
+ s = g_strsplit(t[0], ";", -1);
+ if (NULL == s) {
+ ERR("g_strsplit() failed");
+ g_strfreev(t);
+ return NULL;
+ }
+ int count_param = g_strv_length(s);
+ DBG("count_param(%d)", count_param);
+ int i;
+ for (i = 0; i < count_param; i++) {
+ if (NULL == s[i] || '\0' == *s[i]) continue;
+ if (!strncmp(s[i], "ENCODING=BASE64", strlen("ENCODING=BASE64"))) {
+ __decode_base64(p + len_param + 1);
+ } else if (!strncmp(s[i], "ENCODING=QUOTED-PRINTABLE", strlen("ENCODING=QUOTED-PRINTABLE"))) {
+ __decode_quoted_printable(p + len_param + 1);
+ } else {
+ DBG("skip param[%s]", t[i]);
}
- *stream = *p;
- stream++;
- p++;
}
- return CALENDAR_ERROR_NONE;
+ __decode_escaped_char(p + len_param + 1);
+ DBG("[%s]", p + len_param + 1);
+ g_strfreev(s);
+ // param end
+
+ g_strfreev(t);
+ return p + len_param + 1;
}
-char *_cal_vcalendar_parse_read_line(char *stream, char **prop, char **cont)
+static char* __decode_datetime(char *p, struct user_data *ud)
{
- int i;
- char *p, *q;
- int out;
+ char **t = NULL;
+ t = g_strsplit(p, ":", -1);
+ retvm_if (NULL == t, NULL, "g_strsplit() is failed");
- /* skip space */
- p = stream;
- q = p;
- out = 0;
- while (*p) {
- switch (*p) {
- case ' ':
- break;
- default:
- out = 1;
- break;
- }
- if (out == 1) {
- break;
- }
- p++;
+ if ('\0' == *t[0]) { // no param
+ g_strfreev(t);
+ return p + 1;
}
+ int count = g_strv_length(t);
+ int len_param = strlen(t[count -1]);
+ *(p + strlen(p) - len_param -1) = '\0';
+ g_strfreev(t);
- i = 0;
- out = 0;
- q = p;
- while (*p) {
- switch (*p) {
- case ';':
- case ':':
- out = 1;
- break;
- default:
- i++;
- break;
- }
- if (out == 1) {
- i++;
- break;
+ // param start
+ char **s = NULL;
+ s = g_strsplit(p, ";", -1);
+ retvm_if (NULL == s, p + strlen(p) - len_param, "g_strsplit() failed");
+
+ int count_param = g_strv_length(s);
+ DBG("count_param(%d)", count_param);
+ int i;
+ for (i = 0; i < count_param; i++) {
+ if (NULL == s[i] || '\0' == *s[i]) continue;
+
+ if (!strncmp(s[i], "TZID=", strlen("TZID="))) {
+ char *tzid = strdup(s[i] + strlen("TZID="));
+ __adjust_tzid(tzid);
+ DBG("[%s]", tzid);
+ if (false == _cal_time_is_available_tzid(tzid)) {
+ ERR("---Invalid tzid[%s]", tzid);
+ if (ud->timezone_tzid && *ud->timezone_tzid) {
+ ud->datetime_tzid = strdup(ud->timezone_tzid);
+ free(tzid);
+ DBG("set datetime_tzid[%s] as timezone_tzid", ud->datetime_tzid);
+ } else {
+ ERR("Unable to pase[%s]", tzid);
+ free(tzid);
+ }
+ } else {
+ DBG("---Vaild tzid[%s]", tzid);
+ ud->datetime_tzid = tzid;
+ }
+ } else {
+ DBG("skip [%s]", s[i]);
}
- p++;
}
+ g_strfreev(s);
+ // param end
- if (0 < i) {
- *prop = calloc(1, i);
- snprintf(*prop, i, "%s", q);
- } else {
- *prop = NULL;
- *cont = NULL;
- return NULL;
- }
+ DBG("(%d) (%d) [%s]", strlen(p), len_param, p + strlen(p) +1);
+ return p + strlen(p) +1;
+}
- i = 0;
- out = 0;
- q = p;
+static void __decode_duration(char *cursor, int len, int *tick, int *unit)
+{
+ retm_if (NULL == cursor || '\0' == *cursor, "Invalid parameter: cursor is NULL");
+ retm_if (NULL == tick, "Invalid parameter: tick is NULL");
+ retm_if (NULL == unit, "Invalid parameter: unit is NULL");
- while (*p) {
- switch (*p) {
- case '\n': // not spec but allow
- p += 1 ;
- out = 1;
+ char buf[8] = {0};
+ int sign = 1;
+ int digit = 0;
+ int t = 0, u = 0;
+ int i;
+ for (i = 0; i < len; i++) {
+ switch (*(cursor + i))
+ {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ digit++;
break;
- case '\r':
- if ('\n' == *(p + 1)) {
- p += 2;
- out = 1;
- }
+ case '+':
break;
- case '\0':
+ case '-':
+ sign = -1;
break;
- default:
- i++;
+ case 'P':
break;
- }
- if (out == 1) {
- i++;
+ case 'T':
break;
- }
- p++;
- }
-
- if (0 < i) {
- *cont = calloc(1, i);
- snprintf(*cont, i, "%s", q);
+ case 'W':
+ u = CALENDAR_ALARM_TIME_UNIT_WEEK;
+ snprintf(buf, digit + 1, "%s", cursor + i - digit);
+ t = atoi(buf) * u;
+ DBG("[%s] (%d)", buf, t);
+ digit = 0;
+ break;
+ case 'D':
+ u = CALENDAR_ALARM_TIME_UNIT_DAY;
+ snprintf(buf, digit + 1, "%s", cursor + i - digit);
+ t += atoi(buf) * u;
+ DBG("[%s] (%d)", buf, t);
+ digit = 0;
+ break;
+ case 'H':
+ u = CALENDAR_ALARM_TIME_UNIT_HOUR;
+ snprintf(buf, digit + 1, "%s", cursor + i - digit);
+ t += atoi(buf) * u;
+ DBG("[%s] (%d)", buf, t);
+ digit = 0;
+ break;
+ case 'M':
+ u = CALENDAR_ALARM_TIME_UNIT_MINUTE;
+ snprintf(buf, digit + 1, "%s", cursor + i - digit);
+ t += atoi(buf) * u;
+ DBG("[%s] (%d)", buf, t);
+ digit = 0;
+ break;
+ case 'S':
+ u = CALENDAR_ALARM_TIME_UNIT_SPECIFIC;
+ snprintf(buf, digit + 1, "%s", cursor + i - digit);
+ t += atoi(buf) * u;
+ DBG("[%s] (%d)", buf, t);
+ digit = 0;
+ break;
+ default:
+ ERR("Invalid value");
+ break;
+ }
+ }
+ if (0 == (t % CALENDAR_ALARM_TIME_UNIT_WEEK)) {
+ *tick = (sign * t) / CALENDAR_ALARM_TIME_UNIT_WEEK;
+ *unit = CALENDAR_ALARM_TIME_UNIT_WEEK;
+ } else if (0 == (t % CALENDAR_ALARM_TIME_UNIT_DAY)) {
+ *tick = (sign * t) / CALENDAR_ALARM_TIME_UNIT_DAY;
+ *unit = CALENDAR_ALARM_TIME_UNIT_DAY;
+ } else if (0 == (t % CALENDAR_ALARM_TIME_UNIT_HOUR)) {
+ *tick = (sign * t) / CALENDAR_ALARM_TIME_UNIT_HOUR;
+ *unit = CALENDAR_ALARM_TIME_UNIT_HOUR;
+ } else if (0 == (t % CALENDAR_ALARM_TIME_UNIT_MINUTE)) {
+ *tick = (sign * t) / CALENDAR_ALARM_TIME_UNIT_MINUTE;
+ *unit = CALENDAR_ALARM_TIME_UNIT_MINUTE;
} else {
- *prop = NULL;
- *cont = NULL;
- return NULL;
+ *tick = (sign * t);
+ *unit = CALENDAR_ALARM_TIME_UNIT_SPECIFIC;
}
-
- DBG("%s][%s\n", *prop, *cont);
- return p;
+ DBG("tick(%d), unit(%d)", *tick, *unit);
}
-// start parse func ////////////////////////////////////////////////////
-/* vcalendar */////////////////////////////////////////////////
-
-static int __cal_vcalendar_parse_prodid(int *val, void *data)
+static bool __is_digit(char *p)
{
- return CALENDAR_ERROR_NONE;
+ while (*p) {
+ if ((*p < '0' || '9' < *p) && '+' != *p && '-' != *p)
+ return false;
+ p++;
+ }
+ return true;
}
-static int __cal_vcalendar_parse_version(int *val, void *data)
+static char* __get_index(char *cursor, const char **array, int len, int *index)
{
- char *p = (char *)data;
+ retvm_if (NULL == index, NULL, "Invalid parameter: index is NULL");
- p++;
- DBG("version[%s]", p);
- if (strstr(p, "1.0"))
- {
- DBG("version 1.0");
+ int i;
+ char *new = NULL;
+ for (i = 1; i < len; i++) {
+ new = __check_word(cursor, array[i]);
+ if (new) break;
}
- else
- {
- DBG("version 2.0");
+ if (len == i) {
+ *index = 0;
+ return cursor;
}
- return CALENDAR_ERROR_NONE;
+ *index = i;
+ DBG("index(%d) [%s]", i, array[i]);
+ return cursor + strlen(array[i]);
}
-/* vevnt */////////////////////////////////////////////////
-static int __cal_vcalendar_parse_dtstamp(int type, calendar_list_h list, calendar_record_h event, char *prop, char *cont)
+static int __get_version(char *value, int *version)
{
- return CALENDAR_ERROR_NONE;
+ ENTER();
+
+ retvm_if (NULL == value, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: value is NULL");
+ retvm_if (NULL == version, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: version is NULL");
+
+ if (!strncmp(value, ":1.0", strlen(":1.0"))) {
+ *version = 1;
+ } else {
+ *version = 2;
+ }
+ DBG("version(%d)", *version);
}
-static int __cal_vcalendar_parse_uid(int type, calendar_list_h list, calendar_record_h record, char *prop, char *cont)
+static void __get_caltime(char *p, calendar_time_s *caltime, struct user_data *ud)
{
- int ret;
- char *p = (char *)cont;
+ retm_if (NULL == p || '\0' == *p, "Invalid parameter: p is NULL");
+ retm_if (NULL == caltime, "Invalid parameter: caltime is NULL");
+ retm_if (NULL == ud, "Invalid parameter: ud is NULL");
- p++;
-
- switch (type)
+ switch (strlen(p))
{
- case CALENDAR_BOOK_TYPE_EVENT:
- ret = _cal_record_set_str(record, _calendar_event.uid, p);
+ case VCAL_DATETIME_LENGTH_YYYYMMDD:
+ caltime->type = CALENDAR_TIME_LOCALTIME;
+ sscanf(p, VCAL_DATETIME_FORMAT_YYYYMMDD,
+ &(caltime->time.date.year), &(caltime->time.date.month), &(caltime->time.date.mday));
+ caltime->time.date.hour = 0;
+ caltime->time.date.minute = 0;
+ caltime->time.date.second = 0;
+ DBG("%04d%02d%02dT%02d%02d%02d", caltime->time.date.year, caltime->time.date.month, caltime->time.date.mday,
+ caltime->time.date.hour, caltime->time.date.minute, caltime->time.date.second);
break;
- case CALENDAR_BOOK_TYPE_TODO:
- ret = _cal_record_set_str(record, _calendar_todo.uid, p);
+ case VCAL_DATETIME_LENGTH_YYYYMMDDTHHMMSS:
+ sscanf(p, VCAL_DATETIME_FORMAT_YYYYMMDDTHHMMSS,
+ &(caltime->time.date.year), &(caltime->time.date.month), &(caltime->time.date.mday),
+ &(caltime->time.date.hour), &(caltime->time.date.minute), &(caltime->time.date.second));
+ if (NULL == ud->datetime_tzid || '\0' == *ud->datetime_tzid) {
+ if (NULL == ud->timezone_tzid || '\0' == *ud->timezone_tzid) {
+ caltime->type = CALENDAR_TIME_LOCALTIME;
+ if (ud->is_allday) {
+ caltime->time.date.hour = 0;
+ caltime->time.date.minute = 0;
+ caltime->time.date.second = 0;
+ }
+ DBG("%04d%02d%02dT%02d%02d%02d", caltime->time.date.year, caltime->time.date.month, caltime->time.date.mday,
+ caltime->time.date.hour, caltime->time.date.minute, caltime->time.date.second);
+ } else {
+ caltime->type = CALENDAR_TIME_UTIME;
+ caltime->time.utime = _cal_time_convert_itol(ud->timezone_tzid,
+ caltime->time.date.year, caltime->time.date.month, caltime->time.date.mday,
+ caltime->time.date.hour, caltime->time.date.minute, caltime->time.date.second);
+ DBG("timezone_tzid[%s] (%lld)", ud->timezone_tzid, caltime->time.utime);
+ }
+ } else {
+ caltime->type = CALENDAR_TIME_UTIME;
+ caltime->time.utime = _cal_time_convert_itol(ud->datetime_tzid,
+ caltime->time.date.year, caltime->time.date.month, caltime->time.date.mday,
+ caltime->time.date.hour, caltime->time.date.minute, caltime->time.date.second);
+ DBG("datetime_tzid[%s] (%lld)", ud->datetime_tzid, caltime->time.utime);
+ }
+ break;
+ case VCAL_DATETIME_LENGTH_YYYYMMDDTHHMMSSZ:
+ if (ud->is_allday) {
+ caltime->type = CALENDAR_TIME_LOCALTIME;
+ sscanf(p, VCAL_DATETIME_FORMAT_YYYYMMDDTHHMMSSZ,
+ &(caltime->time.date.year), &(caltime->time.date.month), &(caltime->time.date.mday),
+ &(caltime->time.date.hour), &(caltime->time.date.minute), &(caltime->time.date.second));
+ caltime->time.date.hour = 0;
+ caltime->time.date.minute = 0;
+ caltime->time.date.second = 0;
+ DBG("%04d%02d%02dT%02d%02d%02d", caltime->time.date.year, caltime->time.date.month, caltime->time.date.mday,
+ caltime->time.date.hour, caltime->time.date.minute, caltime->time.date.second);
+ } else {
+ caltime->type = CALENDAR_TIME_UTIME;
+ caltime->time.utime = _cal_time_convert_lli(p);
+ DBG("(%lld)", caltime->time.utime);
+ }
break;
}
- return CALENDAR_ERROR_NONE;
}
-static int __cal_vcalendar_parse_get_tzid_from_list(calendar_list_h list, const char *tzid, calendar_record_h *timezone)
+/*
+ * TZ:+05
+ * TZ:
+ * TZ:+5
+ * TZ:5:30
+ * TZ:+05:30
+ */
+static void __parse_tz(const char *tz, int *h, int *m)
{
- GList *l = NULL;
-
- if (list == NULL || tzid == NULL)
- {
- return -1;
- }
-
- cal_list_s *cal_list = (cal_list_s *)list;
- l = g_list_first(cal_list->record);
+ retm_if(NULL == tz, "Invalid parameter: tz is NULL");
- while (l)
- {
- char *uri = NULL;
- calendar_record_h record = (calendar_record_h)l->data;
- calendar_record_get_uri_p(record, &uri);
- if (strncmp(uri, _calendar_timezone._uri, strlen(_calendar_timezone._uri)))
- {
- l = g_list_next(l);
- continue;
- }
+ char **t = g_strsplit(tz, ":", -1);
+ retm_if(NULL == t, "g_strsplit() is NULL");
- cal_timezone_s *tz = (cal_timezone_s *)record;
- if (!strncmp(tz->standard_name, tzid, strlen(tzid)))
- {
- DBG("Found same tzid[%s] in the list", tzid);
- *timezone = record;
- break;
- }
+ int sign = 0;
+ if (*t[0] == '-') sign = -1;
+ else if (*t[0] == '+') sign = 1;
+ else sign = 0;
- l = g_list_next(l);
+ if (0 == strlen(t[0])) {
+ ERR("No hour");
+ g_strfreev(t);
+ return;
}
- return CALENDAR_ERROR_NONE;
-}
-
-static char *__cal_vcalendar_parse_dtstart_tzid(char *q)
-{
- int i, j;
- int len = 0;
- int has_quot = 0; // to remove quotation(ex> "abc" -> abc)
- char *s = NULL;
-
- if (NULL == q)
- {
- ERR("Invalid parameter");
- return NULL;
+ char buf[8] = {0};
+ if (sign) {
+ snprintf(buf, strlen(t[0]), "%s", t[0] + 1);
+ } else {
+ sign = 1;
+ snprintf(buf, strlen(t[0]) + 1, "%s", t[0]);
}
+ if (h) *h = sign * atoi(buf);
- // TZID="Korea("GMT+9")": 21 - 5
- j = strlen("TZID=");
- len = strlen(q);
- // alloc except "TZID=" string.
- s = calloc(len - j + 1, sizeof(char));
- if (NULL == s)
- {
- ERR("calloc() failed");
- return NULL;
- }
- for (i = 0; i < len -j; i++)
- {
- if (q[j + i] == '\"' && has_quot == 0)
- {
- j++;
- has_quot = 1;
- }
- else if (i == (len -j -1) && q[i] == '\"' && has_quot == 1)
- {
- break;
- }
- s[i] = q[j + i];
+ if (1 == g_strv_length(t)) {
+ if (m) *m = 0;
+ g_strfreev(t);
+ return;
}
- s[i] = '\0';
- return s;
+
+ snprintf(buf, strlen(t[1]) + 1, "%s", t[1]);
+ if (m) *m = atoi(buf);
+
+ g_strfreev(t);
}
-int __cal_vcalendar_parse_dtstart_value(char *q, calendar_time_s *caltime)
+static void __get_tz(char *value, char **tz)
{
- int j;
+ retm_if (NULL == value, "Invalid parameter: cursor is NULL");
+ retm_if (NULL == tz, "Invalid parameter: tz is NULL");
- if (NULL == q || NULL == caltime)
- {
- ERR("Invalid parameter");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
+ int h = 0, m = 0;
+ __parse_tz(value +1, &h, &m); // +1 to skip ':'
- j = strlen("VALUE=");
+ char buf[32] = {0};
+ if (0 == m) {
+ snprintf(buf, sizeof(buf), "Etc/GMT%c%d", h < 0 ? '+' : '-', h);
- if (!strncmp(&q[j], "DATE-TIME", strlen("DATE-TIME")))
- {
- caltime->type = CALENDAR_TIME_UTIME;
- }
- else
- {
- caltime->type = CALENDAR_TIME_LOCALTIME;
+ } else {
+ _cal_time_get_registered_tzid_with_offset(h * 3600 + m * 60, buf, sizeof(buf));
}
- return CALENDAR_ERROR_NONE;
+ DBG("set tzid [%s]", buf);
+
+ *tz = strdup(buf);
}
-int __cal_vcalendar_parse_time_utime(calendar_list_h list, char *q, char *tzid, calendar_time_s *caltime)
+static void __work_component_property_dtstamp(char *value, calendar_record_h record, struct user_data *ud)
{
- int len = 0;
- int y, m, d, h, min, s;
-
- if (NULL == q || NULL == caltime)
- {
- ERR("Invalid parameter");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
+ return;
+}
- len = strlen(q);
+static void __work_component_property_uid(char *value, calendar_record_h record, struct user_data *ud)
+{
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+ retm_if (NULL == ud, "Invalid parameter: ud is NULL");
- switch (caltime->type)
+ int ret = 0;
+ value = __decode_charset(value);
+ switch (ud->type)
{
- case CALENDAR_TIME_LOCALTIME:
- sscanf(q, "%04d%02d%02d", &y, &m, &d);
- caltime->time.date.year = y;
- caltime->time.date.month = m;
- caltime->time.date.mday = d;
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = _cal_record_set_str(record, _calendar_event.uid, value);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() Failed(%d)", ret);
break;
-
- case CALENDAR_TIME_UTIME:
- if (strlen("YYYYMMDDTHHMMSSZ") == len)
- {
- sscanf(q, "%04d%02d%02dT%02d%02d%02dZ", &y, &m, &d, &h, &min, &s);
- DBG("get GMT time[%04d/%02d/%02d %02d:%02d:%02d]", y, m, d, h, min, s);
- }
- else
- {
- sscanf(q, "%04d%02d%02dT%02d%02d%02d", &y, &m, &d, &h, &min, &s);
- DBG("get local time[%04d/%02d/%02d %02d:%02d:%02d]", y, m, d, h, min, s);
- }
-
- if (NULL == tzid || strlen("YYYYMMDDTHHMMSSZ") == len)
- {
- // Z means GMT
- caltime->time.utime = _cal_time_convert_itol(NULL, y, m, d, h, min, s);
- }
- else
- {
- if (_cal_time_is_registered_tzid(tzid))
- {
- caltime->time.utime = _cal_time_convert_itol(tzid, y, m, d, h, min, s);
- }
- else
- {
- char *like_tzid = NULL;
- calendar_record_h timezone = NULL;
- // try get timezone info from the list
- __cal_vcalendar_parse_get_tzid_from_list(list, tzid, &timezone);
- if (timezone)
- {
- DBG("Found from the list");
- _cal_time_get_like_tzid(tzid, timezone, &like_tzid);
- caltime->time.utime = _cal_time_convert_itol(like_tzid, y, m, d, h, min, s);
- DBG("[%s]", like_tzid);
- CAL_FREE(like_tzid);
- like_tzid = NULL;
- }
- else
- {
- DBG("Nowhere to find");
- caltime->time.utime = _cal_time_convert_itol(tzid, y, m, d, h, min, s);
- }
- }
- }
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = _cal_record_set_str(record, _calendar_todo.uid, value);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() Failed(%d)", ret);
break;
}
- return CALENDAR_ERROR_NONE;
}
-int __cal_vcalendar_parse_time_due(int version, calendar_list_h list, char *q, char *tzid, calendar_time_s *caltime)
+static void __work_component_property_recurrence_id(char *value, calendar_record_h record, struct user_data *ud)
{
- int len = 0;
- int y, m, d, h, min, s;
-
- if (NULL == q || NULL == caltime)
- {
- ERR("Invalid parameter");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+ retm_if (NULL == ud, "Invalid parameter: ud is NULL");
- len = strlen(q);
-
- switch (caltime->type)
+ int ret = 0;
+ switch (ud->type)
{
- case CALENDAR_TIME_LOCALTIME:
- sscanf(q, "%04d%02d%02d", &y, &m, &d);
- caltime->time.date.year = y;
- caltime->time.date.month = m;
- caltime->time.date.mday = d;
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = _cal_record_set_str(record, _calendar_event.recurrence_id, value +1);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() Failed(%d)", ret);
break;
-
- case CALENDAR_TIME_UTIME:
- if (strlen("YYYYMMDDTHHMMSSZ") == len)
- {
- sscanf(q, "%04d%02d%02dT%02d%02d%02dZ", &y, &m, &d, &h, &min, &s);
- DBG("get GMT time[%04d/%02d/%02d %02d:%02d:%02d]", y, m, d, h, min, s);
- }
- else
- {
- sscanf(q, "%04d%02d%02dT%02d%02d%02d", &y, &m, &d, &h, &min, &s);
- DBG("get local time[%04d/%02d/%02d %02d:%02d:%02d]", y, m, d, h, min, s);
- }
-
- if (1 == version)
- {
- if (strlen("YYYYMMDDTHHMMSSZ") == len)
- {
- int gety = 0, getm = 0, getd = 0;
- char *tzid = vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID);
- long long int lli = _cal_time_convert_itol(CAL_TZID_GMT, y, m, d, h, min, s);
- _cal_time_utoi(lli, tzid, &gety, &getm, &getd, NULL, NULL, NULL);
-
- caltime->type = CALENDAR_TIME_LOCALTIME;
- caltime->time.date.year = gety;
- caltime->time.date.month = getm;
- caltime->time.date.mday = getd;
- }
- else
- {
- caltime->type = CALENDAR_TIME_LOCALTIME;
- caltime->time.date.year = y;
- caltime->time.date.month = m;
- caltime->time.date.mday = d;
- }
- break;
- }
-
- if (NULL == tzid || strlen("YYYYMMDDTHHMMSSZ") == len)
- {
- // Z means GMT
- caltime->time.utime = _cal_time_convert_itol(NULL, y, m, d, h, min, s);
- }
- else
- {
- if (_cal_time_is_registered_tzid(tzid))
- {
- caltime->time.utime = _cal_time_convert_itol(tzid, y, m, d, h, min, s);
- }
- else
- {
- char *like_tzid = NULL;
- calendar_record_h timezone = NULL;
- // try get timezone info from the list
- __cal_vcalendar_parse_get_tzid_from_list(list, tzid, &timezone);
- if (timezone)
- {
- DBG("Found from the list");
- _cal_time_get_like_tzid(tzid, timezone, &like_tzid);
- caltime->time.utime = _cal_time_convert_itol(like_tzid, y, m, d, h, min, s);
- DBG("[%s]", like_tzid);
- CAL_FREE(like_tzid);
- like_tzid = NULL;
- }
- else
- {
- DBG("Nowhere to find");
- caltime->time.utime = _cal_time_convert_itol(tzid, y, m, d, h, min, s);
- }
- }
- }
+ case CALENDAR_BOOK_TYPE_TODO:
+ DBG("Not supported in todo");
break;
}
- return CALENDAR_ERROR_NONE;
}
-static int __cal_vcalendar_parse_dtstart(int type, calendar_list_h list, calendar_record_h record, char *prop, char *cont)
+static void __work_component_property_dtstart(char *value, calendar_record_h record, struct user_data *ud)
{
- int ret;
- int i;
- int len = 0;
- char *p = (char *)cont;
- char **t;
- char *str_tzid = NULL;
-
- p++;
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+ retm_if (NULL == ud, "Invalid parameter: ud is NULL");
+ value = __decode_datetime(value, ud);
calendar_time_s caltime = {0};
+ __get_caltime(value, &caltime, ud);
- t = g_strsplit_set(p, ";:", -1);
- if (NULL == t)
- {
- ERR("g_strsplit_set() failed");
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
-
- len = g_strv_length(t);
- for (i = 0; i < len; i++)
- {
- DBG("get string[%s]", t[i]);
- if (!strncmp(t[i], "TZID=", strlen("TZID=")) && NULL == str_tzid)
- {
- str_tzid = __cal_vcalendar_parse_dtstart_tzid(t[i]);
- DBG("str_tzid[%s]", str_tzid);
- }
- else if (!strncmp(t[i], "VALUE=", strlen("VALUE")))
- {
- DBG("get value");
- __cal_vcalendar_parse_dtstart_value(t[i], &caltime);
- }
- else if (*t[i] >= '1' && *t[i] <= '9')
- {
- DBG("get time");
- __cal_vcalendar_parse_time_utime(list, t[i], str_tzid, &caltime);
- }
- else
- {
- ERR("Unable to parsing[%s]", t[i]);
- }
- }
+ int ret = 0;
+ char *tzid = NULL;
+ tzid = ud->datetime_tzid ? ud->datetime_tzid : (ud->timezone_tzid ? ud->timezone_tzid : NULL);
- if (NULL == str_tzid)
- {
- // if tzid is not set, set GMT
- str_tzid = strdup(CAL_TZID_GMT);
- }
- switch (type)
+ switch (ud->type)
{
case CALENDAR_BOOK_TYPE_EVENT:
- ret = _cal_record_set_str(record, _calendar_event.start_tzid, str_tzid);
+ if (tzid && *tzid) {
+ ret = _cal_record_set_str(record, _calendar_event.start_tzid, tzid);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() Failed(%d)", ret);
+ }
ret = _cal_record_set_caltime(record, _calendar_event.start_time, caltime);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_caltime() Failed(%d)", ret);
break;
case CALENDAR_BOOK_TYPE_TODO:
- ret = _cal_record_set_str(record, _calendar_todo.start_tzid, str_tzid);
+ if (tzid && *tzid) {
+ ret = _cal_record_set_str(record, _calendar_todo.start_tzid, tzid);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() Failed(%d)", ret);
+ }
ret = _cal_record_set_caltime(record, _calendar_todo.start_time, caltime);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_caltime() Failed(%d)", ret);
break;
}
- if (str_tzid) free(str_tzid);
- g_strfreev(t);
-
- return CALENDAR_ERROR_NONE;
}
-static int __cal_vcalendar_parse_created(int type, calendar_list_h list, calendar_record_h record, char *prop, char *cont)
+static void __work_component_property_created(char *value, calendar_record_h record, struct user_data *ud)
{
- int ret;
- char *p = (char *)cont;
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+ retm_if (NULL == ud, "Invalid parameter: ud is NULL");
- p++;
- switch (type)
+ int ret = 0;
+ switch (ud->type)
{
case CALENDAR_BOOK_TYPE_EVENT:
- ret = _cal_record_set_lli(record, _calendar_event.created_time,
- _cal_time_convert_stol(NULL, p));
+ ret = _cal_record_set_lli(record, _calendar_event.created_time, _cal_time_convert_lli(value));
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_lli() Failed(%d)", ret);
break;
+
case CALENDAR_BOOK_TYPE_TODO:
- ret = _cal_record_set_lli(record, _calendar_todo.created_time,
- _cal_time_convert_stol(NULL, p));
+ ret = _cal_record_set_lli(record, _calendar_todo.created_time, _cal_time_convert_lli(value));
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_lli() Failed(%d)", ret);
break;
}
-
- return CALENDAR_ERROR_NONE;
}
-static int __work_description_switch(int me, int mode, char *buf, int *charset, int *encoding)
+static void __work_component_property_description(char *value, calendar_record_h record, struct user_data *ud)
{
- switch (mode) {
- case 1:
- case 2:
- if (!strncmp(buf, "CHARSET=UTF-8", strlen("CHARSET=UTF-8"))) {
- DBG("CHARSET=UTF-8");
- *charset = 1;
-
- } else if (!strncmp(buf, "CHARSET=UTF-16", strlen("CHARSET=UTF-16"))) {
- DBG("CHARSET=UTF-16");
- *charset = 1;
-
- } else if (!strncmp(buf, "ENCODING=BASE64", strlen("ENCODING=BASE64"))) {
- DBG("ENCODE_BASE64");
- *encoding = ENCODE_BASE64;
-
- } else if (!strncmp(buf, "ENCODING=QUOTED-PRINTABLE", strlen("ENCODING=QUOTED-PRINTABLE"))) {
- DBG("ENCODE_QUOTED_PRINTABLE");
- *encoding = ENCODE_QUOTED_PRINTABLE;
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+ retm_if (NULL == ud, "Invalid parameter: ud is NULL");
- } else {
-
- }
- mode = 0;
+ int ret = 0;
+ value = __decode_charset(value);
+ switch (ud->type)
+ {
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = _cal_record_set_str(record, _calendar_event.description, value);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() Failed(%d)", ret);
break;
- default:
- mode = me;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = _cal_record_set_str(record, _calendar_todo.description, value);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() Failed(%d)", ret);
break;
}
- return mode;
}
-static int __cal_vcalendar_parse_description(int type, calendar_list_h list, calendar_record_h record, char *prop, char *cont)
+static void __work_component_property_last_modified(char *value, calendar_record_h record, struct user_data *ud)
{
- int i = 0, j;
- int ret;
- int len;
- int out;
- int mode;
- int charset, encoding;
- char buf[64] = {0};
- char *p = (char *)cont;
-
- if (p[i + 1] == '\0')
- {
- ERR("Invalid parameter");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- i = j = 0;
- out = 0;
- mode = 0;
- charset = encoding = 0;
- while (p[i] != '\0') {
- switch (p[i]) {
- case ':':
- mode = 1;
- out = 1;
- break;
-
- case ';':
- buf[j] = '\0';
- mode = __work_description_switch(2, mode, buf, &charset, &encoding);
- j = 0;
- break;
-
- default:
- buf[j] = p[i];
- j++;
- break;
- }
- i++;
-
- if (out) {
- DBG("out");
- break;
- }
- }
- __work_description_switch(0, mode, buf, &charset, &encoding);
-
- DBG("charset(%d) encoding(%d)", charset, encoding);
- if (encoding) {
- __cal_vcalendar_parse_decode_quoted_printable(p+i, &len);
- }
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+ retm_if (NULL == ud, "Invalid parameter: ud is NULL");
- switch (type)
+ int ret = 0;
+ switch (ud->type)
{
case CALENDAR_BOOK_TYPE_EVENT:
- ret = _cal_record_set_str(record, _calendar_event.description, p + i);
+ ret = _cal_record_set_lli(record, _calendar_event.last_modified_time, _cal_time_convert_lli(value));
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_lli() Failed(%d)", ret);
break;
case CALENDAR_BOOK_TYPE_TODO:
- ret = _cal_record_set_str(record, _calendar_todo.description, p + i);
+ ret = _cal_record_set_lli(record, _calendar_todo.last_modified_time, _cal_time_convert_lli(value));
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_lli() Failed(%d)", ret);
break;
}
-
- return CALENDAR_ERROR_NONE;
}
-static int __cal_vcalendar_parse_last_mod(int type, calendar_list_h list, calendar_record_h record, char *prop, char *cont)
+static void __work_component_property_location(char *value, calendar_record_h record, struct user_data *ud)
{
- int ret;
- char *p = (char *)cont;
-
- p++;
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+ retm_if (NULL == ud, "Invalid parameter: ud is NULL");
- switch (type)
+ int ret = 0;
+ value = __decode_charset(value);
+ switch (ud->type)
{
case CALENDAR_BOOK_TYPE_EVENT:
- ret = _cal_record_set_lli(record, _calendar_event.last_modified_time,
- _cal_time_convert_stol(NULL, p));
+ ret = _cal_record_set_str(record, _calendar_event.location, value);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() Failed(%d)", ret);
break;
case CALENDAR_BOOK_TYPE_TODO:
- ret = _cal_record_set_lli(record, _calendar_todo.last_modified_time,
- _cal_time_convert_stol(NULL, p));
+ ret = _cal_record_set_str(record, _calendar_todo.location, value);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() Failed(%d)", ret);
break;
}
- return CALENDAR_ERROR_NONE;
-}
-
-inline void __cal_vcalendar_parse_get_optional(char *p, int *encoding)
-{
- int i;
-
- for (i = 0; i < TEXT_MAX; i++) {
- if (!strncmp(p, _optional_funcs[i].prop, strlen(_optional_funcs[i].prop))) {
- int j = 0;
- char buf[64] = {0, };
- p += strlen(_optional_funcs[i].prop);
- while (p[j] != ':' && p[j] != ';' && p[j] != '\n' && p[j] != '\0') {
- buf[j] = p[j];
- j++;
- }
- if (p[j] != '\0') {
- buf[j] = '\0';
- }
-
- p += j;
- _optional_funcs[i].func(encoding, buf);
- break;
- } else {
-
- }
- }
}
-static int __cal_vcalendar_parse_location(int type, calendar_list_h list, calendar_record_h record, char *prop, char *cont)
+static int __decode_priority(char *value, struct user_data *ud)
{
- int i = 0, j;
- int ret;
- int len;
- int out;
- int mode;
- int charset, encoding;
- char buf[64] = {0};
- char *p = (char *)cont;
+ int original_priority = atoi(value);
+ int modified_priority = 0;
- if (p[i + 1] == '\0')
+ switch (ud->version)
{
- ERR("Invalid parameter");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- i = j = 0;
- out = 0;
- mode = 0;
- charset = encoding = 0;
- while (p[i] != '\0') {
- switch (p[i]) {
- case ':':
- mode = 1;
- out = 1;
+ case VCAL_VER_1:
+ switch (original_priority)
+ {
+ case 0:
+ modified_priority = CALENDAR_TODO_PRIORITY_LOW;
break;
-
- case ';':
- buf[j] = '\0';
- mode = __work_description_switch(2, mode, buf, &charset, &encoding);
- j = 0;
+ case 1:
+ modified_priority = CALENDAR_TODO_PRIORITY_NORMAL;
+ break;
+ case 2:
+ modified_priority = CALENDAR_TODO_PRIORITY_HIGH;
break;
-
default:
- buf[j] = p[i];
- j++;
+ DBG("Unable to parse [%s]", value);
+ modified_priority = CALENDAR_TODO_PRIORITY_NONE;
break;
}
- i++;
+ break;
- if (out) {
- DBG("out");
+ case VCAL_VER_2:
+ default:
+ switch (original_priority)
+ {
+ case 1 ... 4:
+ modified_priority = CALENDAR_TODO_PRIORITY_HIGH;
+ break;
+ case 5:
+ modified_priority = CALENDAR_TODO_PRIORITY_NORMAL;
+ break;
+ case 6 ... 9:
+ modified_priority = CALENDAR_TODO_PRIORITY_LOW;
+ break;
+ default:
+ DBG("Unable to parse [%s]", value);
+ modified_priority = CALENDAR_TODO_PRIORITY_NONE;
break;
}
- }
- __work_description_switch(0, mode, buf, &charset, &encoding);
-
- DBG("charset(%d) encoding(%d)", charset, encoding);
- if (encoding) {
- __cal_vcalendar_parse_decode_quoted_printable(p+i, &len);
- }
-
- switch (type)
- {
- case CALENDAR_BOOK_TYPE_EVENT:
- ret = _cal_record_set_str(record, _calendar_event.location, p + i);
- break;
- case CALENDAR_BOOK_TYPE_TODO:
- ret = _cal_record_set_str(record, _calendar_todo.location, p + i);
break;
}
-
- return CALENDAR_ERROR_NONE;
+ DBG("convert priority(%d) -> (%d)", original_priority, modified_priority);
+ return modified_priority;
}
-static int __cal_vcalendar_parse_priority(int type, calendar_list_h list, calendar_record_h record, char *prop, char *cont)
+static void __work_component_property_priority(char *value, calendar_record_h record, struct user_data *ud)
{
- int ret;
- int prio = 0;
- char *p = (char *)cont;
-
- p++;
- if (p[0] < '0' || p[0] > '9') {
- DBG("warning check range\n");
- return -1;
- }
-
- DBG("priority(%d)", atoi(p));
- switch (atoi(p))
- {
- case 1:
- case 2:
- case 3:
- case 4:
- prio = CALENDAR_TODO_PRIORITY_HIGH;
- break;
- case 5:
- prio = CALENDAR_TODO_PRIORITY_NORMAL;
- break;
- case 6:
- case 7:
- case 8:
- case 9:
- prio = CALENDAR_TODO_PRIORITY_LOW;
- break;
- default:
- prio = CALENDAR_TODO_PRIORITY_NONE;
- break;
- }
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+ retm_if (NULL == ud, "Invalid parameter: ud is NULL");
+ retm_if (*value < '0' || *value > '9', "out of range[%s]", value);
- DBG("convert to priority(%d)", prio);
- switch (type)
+ int ret = 0;
+ int modified_priority = __decode_priority(value, ud);
+ switch (ud->type)
{
case CALENDAR_BOOK_TYPE_EVENT:
-
- ret = _cal_record_set_int(record, _calendar_event.priority, prio);
+ ret = _cal_record_set_int(record, _calendar_event.priority, modified_priority);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
break;
case CALENDAR_BOOK_TYPE_TODO:
- ret = _cal_record_set_int(record, _calendar_todo.priority, prio);
+ ret = _cal_record_set_int(record, _calendar_todo.priority, modified_priority);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
break;
}
- return CALENDAR_ERROR_NONE;
}
-static int __cal_vcalendar_parse_status(int type, calendar_list_h list, calendar_record_h record, char *prop, char *cont)
+static void __work_component_property_status(char *value, calendar_record_h record, struct user_data *ud)
{
- int ret;
- int status;
- char *p = (char *)cont;
-
- p++;
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+ retm_if (NULL == ud, "Invalid parameter: ud is NULL");
- switch (type)
+ int ret = 0;
+ int status = 0;
+ switch (ud->type)
{
case CALENDAR_BOOK_TYPE_EVENT:
- if (!strncmp(p, "TENTATIVE", strlen("TENTATIVE")))
- {
+ if (!strncmp(value, ":TENTATIVE", strlen(":TENTATIVE"))) {
status = CALENDAR_EVENT_STATUS_TENTATIVE;
- }
- else if (!strncmp(p, "CONFIRMED", strlen("CONFIRMED")))
- {
+ } else if (!strncmp(value, ":CONFIRMED", strlen(":CONFIRMED"))) {
status = CALENDAR_EVENT_STATUS_CONFIRMED;
- }
- else if (!strncmp(p, "CANCELLED", strlen("CANCELLED")))
- {
+ } else if (!strncmp(value, ":CANCELLED", strlen(":CANCELLED"))) {
status = CALENDAR_EVENT_STATUS_CANCELLED;
- }
- else
- {
+ } else {
status = CALENDAR_EVENT_STATUS_NONE;
}
ret = _cal_record_set_int(record, _calendar_event.event_status, status);
-
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
break;
-
case CALENDAR_BOOK_TYPE_TODO:
- if (!strncmp(p, "NEEDS-ACTION", strlen("NEEDS-ACTION"))) // for ver2.0
- {
+ if (!strncmp(value, ":NEEDS-ACTION", strlen(":NEEDS-ACTION"))) {
status = CALENDAR_TODO_STATUS_NEEDS_ACTION;
- }
- else if (!strncmp(p, "NEEDS ACTION", strlen("NEEDS ACTION"))) // for ver1.0
- {
+ } else if (!strncmp(value, ":NEEDS ACTION", strlen(":NEEDS ACTION"))) {
status = CALENDAR_TODO_STATUS_NEEDS_ACTION;
- }
- else if (!strncmp(p, "COMPLETED", strlen("COMPLETED")))
- {
+ } else if (!strncmp(value, ":COMPLETED", strlen(":COMPLETED"))) {
status = CALENDAR_TODO_STATUS_COMPLETED;
- }
- else if (!strncmp(p, "IN-PROCESS", strlen("IN-PROCESS")))
- {
+ } else if (!strncmp(value, ":IN-PROCESS", strlen(":IN-PROCESS"))) {
status = CALENDAR_TODO_STATUS_IN_PROCESS;
- }
- else if (!strncmp(p, "CANCELLED", strlen("CANCELLED")))
- {
+ } else if (!strncmp(value, ":CANCELLED", strlen(":CANCELLED"))) {
status = CALENDAR_TODO_STATUS_CANCELED;
- }
- else
- {
+ } else {
status = CALENDAR_TODO_STATUS_NONE;
}
ret = _cal_record_set_int(record, _calendar_todo.todo_status, status);
-
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
break;
}
-
- return CALENDAR_ERROR_NONE;
}
-static int __cal_vcalendar_parse_summary(int type, calendar_list_h list, calendar_record_h record, char *prop, char *cont)
+static void __work_component_property_summary(char *value, calendar_record_h record, struct user_data *ud)
{
- int ret;
- int i = 0, j;
- int len;
- int out;
- int mode;
- int charset, encoding;
- char buf[64] = {0};
- char *p = (char *)cont;
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+ retm_if (NULL == ud, "Invalid parameter: ud is NULL");
- if (p[i + 1] == '\0')
+ int ret = 0;
+ value = __decode_charset(value);
+ switch (ud->type)
{
- ERR("Invalid parameter");
- return CALENDAR_ERROR_INVALID_PARAMETER;
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = _cal_record_set_str(record, _calendar_event.summary, value);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() Failed(%d)", ret);
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = _cal_record_set_str(record, _calendar_todo.summary, value);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() Failed(%d)", ret);
+ break;
}
+}
- i = j = 0;
- out = 0;
- mode = 0;
- charset = encoding = 0;
- while (p[i] != '\0') {
- switch (p[i]) {
- case ':':
- mode = 1;
- out = 1;
- break;
-
- case ';':
- buf[j] = '\0';
- mode = __work_description_switch(2, mode, buf, &charset, &encoding);
- j = 0;
- break;
-
- default:
- buf[j] = p[i];
- j++;
- break;
- }
- i++;
+static bool __is_wday_string(char *p)
+{
+ retvm_if (NULL == p || '\0' == *p, false, "Invalid parameter: p is NULL");
- if (out) {
- break;
- }
+ if ('S' == *p && 'U' == *(p +1)) {
+ return true;
+ } else if ('M' == *p && 'O' == *(p +1)) {
+ return true;
+ } else if ('T' == *p && 'U' == *(p +1)) {
+ return true;
+ } else if ('W' == *p && 'E' == *(p +1)) {
+ return true;
+ } else if ('T' == *p && 'H' == *(p +1)) {
+ return true;
+ } else if ('F' == *p && 'R' == *(p +1)) {
+ return true;
+ } else if ('S' == *p && 'A' == *(p +1)) {
+ return true;
+ } else {
+ return false;
}
- __work_description_switch(0, mode, buf, &charset, &encoding);
+}
- DBG("charset(%d) encoding(%d)", charset, encoding);
- if (encoding) {
- __cal_vcalendar_parse_decode_quoted_printable(p+i, &len);
+static int __get_frequency(char *p)
+{
+ if ('Y' == *p && 'M' == *(p +1)) {
+ return VCAL_RECURRENCE_YEARLY_BYMONTH;
+ } else if ('Y' == *p && 'D' == *(p +1)) {
+ return VCAL_RECURRENCE_YEARLY_BYYEARDAY;
+ } else if ('M' == *p && 'P' == *(p +1)) {
+ return VCAL_RECURRENCE_MONTHLY_BYDAY;
+ } else if ('M' == *p && 'D' == *(p +1)) {
+ return VCAL_RECURRENCE_MONTHLY_BYMONTHDAY;
+ } else if ('W' == *p && 'E' != *(p +1)) { // check 'E' for WE(Wednesday)
+ return VCAL_RECURRENCE_WEEKLY;
+ } else if ('D' == *p) {
+ return VCAL_RECURRENCE_DAILY;
+ } else {
+ return VCAL_RECURRENCE_NONE;
}
+}
+
+static void __set_bystr(int freq_mode, calendar_record_h record, char *bystr)
+{
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+ retm_if (NULL == bystr || '\0' == *bystr, "Invalid parameter: bystr is NULL");
- switch (type)
+ DBG("bystr[%s]", bystr);
+ bystr[strlen(bystr) -1] = '\0'; // to remove ','
+ int ret = 0;
+ switch (freq_mode)
{
- case CALENDAR_BOOK_TYPE_EVENT:
- ret = _cal_record_set_str(record, _calendar_event.summary, p + i);
+ case VCAL_RECURRENCE_YEARLY_BYMONTH:
+ ret = _cal_record_set_str(record, _calendar_event.bymonth, bystr);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() Failed(%d)", ret);
break;
- case CALENDAR_BOOK_TYPE_TODO:
- ret = _cal_record_set_str(record, _calendar_todo.summary, p + i);
+ case VCAL_RECURRENCE_YEARLY_BYYEARDAY:
+ ret = _cal_record_set_str(record, _calendar_event.byyearday, bystr);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() Failed(%d)", ret);
+ break;
+ case VCAL_RECURRENCE_MONTHLY_BYMONTHDAY:
+ ret = _cal_record_set_str(record, _calendar_event.bymonthday, bystr);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() Failed(%d)", ret);
+ break;
+ case VCAL_RECURRENCE_MONTHLY_BYDAY:
+ ret = _cal_record_set_str(record, _calendar_event.byday, bystr);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() Failed(%d)", ret);
+ break;
+ case VCAL_RECURRENCE_WEEKLY:
+ ret = _cal_record_set_str(record, _calendar_event.byday, bystr);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() Failed(%d)", ret);
+ break;
+ case VCAL_RECURRENCE_DAILY:
break;
}
-
- DBG("summary(%s)\n", p + i);
- return CALENDAR_ERROR_NONE;
}
-enum {
- __RRULE_VER1_MODE_FREQ = 0x0,
- __RRULE_VER1_MODE_BY,
- __RRULE_VER1_MODE_UNTIL,
- __RRULE_VER1_MODE_OUT,
-};
+/*
+ * Yearly |bymonth |YM1 6 7 #10
+ * |YM1 1 6 12 #5 MP1 1+ MO 1- FR
+ * Yearly |byyearday |YD3 1 100 200 #10
+ * Monthly|byposition|MP2 1+ SU 1- SU #10
+ * Monthly|byday |MD1 1 1- #10
+ * Weekly | |W2 MO WE FR 19941224T000000Z
+ * Daly | |D2 #0
+ */
+static void __work_component_property_rrule_ver_1(char *value, calendar_record_h record, struct user_data *ud)
+{
+ ENTER();
-enum {
- __RRULE_VER1_BYYEARDAY = 0,
- __RRULE_VER1_BYMONTH,
- __RRULE_VER1_BYMONTHDAY,
- __RRULE_VER1_BYDAY,
-};
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+ retm_if (NULL == ud, "Invalid parameter: ud is NULL");
+
+ int ret = 0;
+ char **t = NULL;
+ t = g_strsplit_set(value, ": ", -1);
+ retm_if (NULL == t, "g_strsplit_set() is failed");
+
+ // start
+ int len = g_strv_length(t);
+
+ int frequency = 0;
+ int freq_mode = 0;
+ bool has_by = false;
+
+ char bystr[1024] = {0};
+ int len_str = 0;
+
+ int week[5] = {0};
+ int week_index = 0;
-static int __cal_vcalendar_parse_rrule_ver1(calendar_record_h record, char *p)
-{
- DBG("This is rrule for ver 1.0");
- int ret;
int i;
- int length;
- int freq = CALENDAR_RECURRENCE_NONE;
- int mode = 0; // 0:freq, 1:nth 2:bystr 3:range
- int interval = 0;
- unsigned int byint = 0; // 1:bymonthday 2:byday 3:bymonth 4:byyearday
- int len;
- int num = 0;
- int y, mon, d, h, min, s;
- int nth_week = 0;
- char **t;
- char *r = NULL, *q = NULL;
- char buf_by[256] = {0};
- calendar_time_s ut = {0};
- cal_event_s *event = (cal_event_s *)record;
-
- p++;
- t = g_strsplit(p, " ", -1);
- if (!t) {
- ERR("g_strsplit failed");
- g_strfreev(t);
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- length = g_strv_length(t);
- for (i = 0; i < length; i++)
- {
- if (t[i] == NULL || strlen(t[i]) == 0)
- {
- continue;
- }
+ for (i = 0; i < len; i++) {
+ if (NULL == t[i] || '\0' == *t[i]) continue;
+ DBG("[%s]", t[i]);
- switch (mode)
- {
- case __RRULE_VER1_MODE_FREQ: // freq
- mode = __RRULE_VER1_MODE_BY;
- if (*t[i] == 'D')
- {
- DBG("CALENDAR_RECURRENCE_DAILY");
- freq = CALENDAR_RECURRENCE_DAILY;
- interval = strlen(t[i]) == 1 ? 1 : atoi(t[i] + 1);
- byint = __RRULE_VER1_BYMONTHDAY;
- }
- else if (*t[i] == 'W')
- {
- DBG("CALENDAR_RECURRENCE_WEEKLY");
- freq = CALENDAR_RECURRENCE_WEEKLY;
- interval = strlen(t[i]) == 1 ? 1 : atoi(t[i] + 1);
- byint = __RRULE_VER1_BYDAY;
- }
- else if (*t[i] == 'M'&& *(t[i] + 1) == 'P')
- {
- DBG("CALENDAR_RECURRENCE_MONTHLY");
- freq = CALENDAR_RECURRENCE_MONTHLY;
- interval = strlen(t[i]) == 2 ? 1 : atoi(t[i] + 2);
- byint = __RRULE_VER1_BYDAY;
- }
- else if (*t[i] == 'M'&& *(t[i] + 1) == 'D')
- {
- DBG("CALENDAR_RECURRENCE_MONTHLY");
- freq = CALENDAR_RECURRENCE_MONTHLY;
- interval = strlen(t[i]) == 2 ? 1 : atoi(t[i] + 2);
- byint = __RRULE_VER1_BYMONTHDAY;
- }
- else if (*t[i] == 'Y'&& *(t[i] + 1) == 'M')
- {
- DBG("CALENDAR_RECURRENCE_YEARLY");
- freq = CALENDAR_RECURRENCE_YEARLY;
- interval = strlen(t[i]) == 2 ? 1 : atoi(t[i] + 2);
- byint = __RRULE_VER1_BYMONTH;
- }
- else if (*t[i] == 'Y'&& *(t[i] + 1) == 'D')
- {
- DBG("CALENDAR_RECURRENCE_YEARLY");
- freq = CALENDAR_RECURRENCE_YEARLY;
- interval = strlen(t[i]) == 2 ? 1 : atoi(t[i] + 2);
- byint = __RRULE_VER1_BYYEARDAY;
+ if (true == __is_wday_string(t[i])) {
+ has_by = true;
+ if (week_index) {
+ int j = 0;
+ for (j = 0; j < week_index; j++) {
+ len_str += snprintf(bystr + len_str, sizeof(bystr) - len_str, "%d%s,", week[j], t[i]);
+ }
+ } else {
+ len_str += snprintf(bystr + len_str, sizeof(bystr) - len_str, "%s,", t[i]);
}
- else
- {
- ERR("Invalid ");
+ DBG("[%s] week_index(%d)", bystr, week_index);
+ } else if ('L' == *t[i] && 'D' == *(t[i] +1)) { // last day
+ has_by = true;
+ len_str += snprintf(bystr + len_str, sizeof(bystr) - len_str, "%s,", "-1");
+
+ } else if ('W' == *t[i] && 'K' == *(t[i] +1) && 'S' == *(t[i] +2) && 'T' == *(t[i] +3)) { // +4 is '='
+ if ('S' == *(t[i] +5) && 'U' == *(t[i] +6)) {
+ ret = _cal_record_set_int(record, _calendar_event.wkst, CALENDAR_SUNDAY);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if ('M' == *(t[i] +5)) {
+ ret = _cal_record_set_int(record, _calendar_event.wkst, CALENDAR_MONDAY);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if ('T' == *(t[i] +5) && 'U' == *(t[i] +6)) {
+ ret = _cal_record_set_int(record, _calendar_event.wkst, CALENDAR_TUESDAY);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if ('W' == *(t[i] +5)) {
+ ret = _cal_record_set_int(record, _calendar_event.wkst, CALENDAR_WEDNESDAY);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if ('T' == *(t[i] +5) && 'H' == *(t[i] +6)) {
+ ret = _cal_record_set_int(record, _calendar_event.wkst, CALENDAR_THURSDAY);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if ('F' == *(t[i] +5)) {
+ ret = _cal_record_set_int(record, _calendar_event.wkst, CALENDAR_FRIDAY);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if ('S' == *(t[i] +5) && 'A' == *(t[i] +6)) {
+ ret = _cal_record_set_int(record, _calendar_event.wkst, CALENDAR_SATURDAY);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else {
+ ERR("Invalid parameter[ %s ]", t[i]);
}
- ret = _cal_record_set_int(record, _calendar_event.freq, freq);
- DBG("interval(%d)", interval);
- ret = _cal_record_set_int(record, _calendar_event.interval, interval);
- break;
+ } else if (true == __is_digit(t[i])) {
- case __RRULE_VER1_MODE_BY: // num
- switch (byint)
+ char buf[8] = {0};
+ bool exit_loop = false;
+ int sign = 1;
+ int j = 0;
+ switch(freq_mode)
{
- case __RRULE_VER1_BYDAY:
- DBG("__RRULE_VER1_BYDAY:[%s]", t[i]);
- if (strstr(t[i], "MO") || strstr(t[i], "TU") || strstr(t[i], "WE")
- || strstr(t[i], "TH") || strstr(t[i], "FR")
- || strstr(t[i], "SA") || strstr(t[i], "SU"))
- {
- if (NULL == r)
- {
- len = strlen(t[i]) + 1;
- len += (nth_week == 0) ? 0 : 8; // 8 is buf
- r = calloc(len, sizeof(char));
- if (NULL == r)
- {
- ERR("calloc() failed");
- g_strfreev(t);
- return CALENDAR_ERROR_DB_FAILED;
- }
- if (0 == nth_week)
- {
- snprintf(r, len, "%s", t[i]);
- }
- else
- {
- snprintf(r, len, "%d%s", nth_week, t[i]);
- }
- }
- else
- {
- len = strlen(r) + strlen(t[i]) + 2;
- len += (nth_week == 0) ? 0 : 8; // 8 is buf
- q = calloc(len, sizeof(char));
- if (NULL == q)
- {
- ERR("calloc() failed");
- CAL_FREE(r);
- g_strfreev(t);
- return CALENDAR_ERROR_DB_FAILED;
- }
- if (0 == nth_week)
- {
- snprintf(q, len, "%s,%s", r, t[i]);
- }
- else
- {
- snprintf(q, len, "%s,%d%s", r, nth_week, t[i]);
- }
- CAL_FREE(r);
- r = q;
- }
+ case VCAL_RECURRENCE_MONTHLY_BYDAY:
+ case VCAL_RECURRENCE_WEEKLY:
+ if (true == has_by) {
+ week_index = 0;
}
- else if (*t[i] >= '1' && *t[i] <= '9' && strlen(t[i]) < strlen("YYYYMMDD"))
- {
- // MP1 1+ 1- FR: first Friday and last Friday
- DBG("Unable to handle multi week");
- int len = strlen(t[i]);
- char buf[8] = {0};
- if (*t[len -1] == '-')
- {
- // if 5+, buf has 5 because of len is 2 including '\0'
- snprintf(buf, len, "%s", t[i]);
- nth_week = atoi(buf);
- DBG("-(%d)", nth_week);
- nth_week *= -1;
- }
- else if (*t[len -1] == '+')
- {
- snprintf(buf, len, "%s", t[i]);
- nth_week = atoi(buf);
- DBG("(%d)", nth_week);
- }
- else
+ while (*(t[i] +j)) {
+ switch (*(t[i] +j))
{
- snprintf(buf, sizeof(buf), "%s", t[i]);
- nth_week = atoi(buf);
- DBG("(%d)", nth_week);
+ case '+':
+ exit_loop = true;
+ sign = 1;
+ break;
+ case '-':
+ exit_loop = true;
+ sign = -1;
+ break;
+ default:
+ break;
}
+ if (true == exit_loop) break;
+ j++;
}
- else
- {
- DBG("final string[%s]", t[i]);
- if (r)
+ snprintf(buf, j +1, "%s", t[i]);
+ week[week_index] = atoi(buf) * sign;
+ week_index++;
+ break;
+ default:
+ has_by = true;
+ while (*(t[i] +j)) {
+ switch (*(t[i] +j))
{
- ret = _cal_record_set_str(record, _calendar_event.byday, r);
- CAL_FREE(r);
+ case '+':
+ exit_loop = true;
+ sign = 1;
+ break;
+ case '-':
+ exit_loop = true;
+ sign = -1;
+ break;
+ default:
+ break;
}
- i--;
- mode = __RRULE_VER1_MODE_UNTIL;
+ if (true == exit_loop) break;
+ j++;
}
+ snprintf(buf, j +1, "%s", t[i]);
+ len_str += snprintf(bystr + len_str, sizeof(bystr) - len_str, "%d,", (atoi(buf) * sign));
break;
-
- case __RRULE_VER1_BYYEARDAY:
- case __RRULE_VER1_BYMONTH:
- case __RRULE_VER1_BYMONTHDAY:
- DBG("Not __RRULE_VER1_BYDAY:");
- if (*t[i] > '1' && *t[i] < '9'&& strlen(t[i]) < 4)
- {
- if (NULL == r)
- {
- len = strlen(t[i]) + 1;
- r = calloc(len, sizeof(char));
- if (NULL == r)
- {
- ERR("calloc() failed");
- g_strfreev(t);
- return CALENDAR_ERROR_DB_FAILED;
- }
- snprintf(r, len, "%s", t[i]);
- }
- else
+ }
+ } else {
+ if (true == has_by) {
+ __set_bystr(freq_mode, record, bystr);
+ week_index = 0;
+ memset(bystr, 0x0, strlen(bystr));
+ len_str = 0;
+ has_by = false;
+ }
+ if (VCAL_RECURRENCE_NONE != (freq_mode = __get_frequency(t[i]))) {
+ if (0 == frequency) {
+ int interval = 0;
+ switch (freq_mode)
{
- len = strlen(r) + strlen(t[i]) + 2;
- q = calloc(len, sizeof(char));
- if (NULL == r)
- {
- ERR("calloc() failed");
- g_strfreev(t);
- return CALENDAR_ERROR_DB_FAILED;
- }
- snprintf(q, len, "%s,%s", r, t[i]);
- CAL_FREE(r);
- r = q;
+ case VCAL_RECURRENCE_YEARLY_BYMONTH:
+ frequency = CALENDAR_RECURRENCE_YEARLY;
+ interval = ('\0' == *(t[i] +2)) ? 1 : atoi(t[i] +2);
+ break;
+ case VCAL_RECURRENCE_YEARLY_BYYEARDAY:
+ frequency = CALENDAR_RECURRENCE_YEARLY;
+ interval = ('\0' == *(t[i] +2)) ? 1 : atoi(t[i] +2);
+ break;
+ case VCAL_RECURRENCE_MONTHLY_BYDAY:
+ frequency = CALENDAR_RECURRENCE_MONTHLY;
+ interval = ('\0' == *(t[i] +2)) ? 1 : atoi(t[i] +2);
+ break;
+ case VCAL_RECURRENCE_MONTHLY_BYMONTHDAY:
+ frequency = CALENDAR_RECURRENCE_MONTHLY;
+ interval = ('\0' == *(t[i] +2)) ? 1 : atoi(t[i] +2);
+ break;
+ case VCAL_RECURRENCE_WEEKLY:
+ frequency = CALENDAR_RECURRENCE_WEEKLY;
+ interval = ('\0' == *(t[i] +1)) ? 1 : atoi(t[i] +1);
+ break;
+ case VCAL_RECURRENCE_DAILY:
+ frequency = CALENDAR_RECURRENCE_DAILY;
+ interval = ('\0' == *(t[i] +1)) ? 1 : atoi(t[i] +1);
+ break;
}
+ ret = _cal_record_set_int(record, _calendar_event.freq, frequency);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ ret = _cal_record_set_int(record, _calendar_event.interval, interval);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ DBG("frequency[%d] interval(%d)", frequency, interval);
}
- else
- {
- if (r)
- {
- switch (byint)
- {
- case __RRULE_VER1_BYYEARDAY:
- ret = _cal_record_set_str(record, _calendar_event.byyearday, r);
- break;
- case __RRULE_VER1_BYMONTH:
- ret = _cal_record_set_str(record, _calendar_event.bymonth, r);
- break;
- case __RRULE_VER1_BYMONTHDAY:
- ret = _cal_record_set_str(record, _calendar_event.bymonthday, r);
- break;
+ } else {
+ if ('0' <= *t[i] && *t[i] <= '9' && strlen("YYYYMMDDTHHMMSS") <= strlen(t[i])) { // until
+ DBG("until");
+ calendar_time_s caltime = {0};
+ __get_caltime(t[i], &caltime, ud);
+ ret = _cal_record_set_int(record, _calendar_event.range_type, CALENDAR_RANGE_UNTIL);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ ret = _cal_record_set_caltime(record, _calendar_event.until_time, caltime);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_caltime() is failed(%d)", ret);
+
+ } else if ('#' == *t[i]) { // count
+ if (true == __is_digit(t[i] +1)) {
+ if (0 == atoi(t[i] +1)) {
+ DBG("endless");
+ ret = _cal_record_set_int(record, _calendar_event.range_type, CALENDAR_RANGE_NONE);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else {
+ DBG("count (%d)", atoi(t[i] +1));
+ ret = _cal_record_set_int(record, _calendar_event.range_type, CALENDAR_RANGE_COUNT);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ ret = _cal_record_set_int(record, _calendar_event.count, atoi(t[i] +1));
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
}
- CAL_FREE(r);
+ } else {
+ ERR("Unable to parse count[%s]", t[i]);
}
- i--;
- mode = __RRULE_VER1_MODE_UNTIL;
- }
- break;
- }
- break;
-
- case __RRULE_VER1_MODE_UNTIL: // until
- mode = __RRULE_VER1_MODE_OUT; // out
- if (*t[i] == '#')
- {
- num = atoi(t[i] + 1);
- if (num == 0)
- {
- DBG("CALENDAR_RANGE_NONE");
- ret = _cal_record_set_int(record, _calendar_event.range_type, CALENDAR_RANGE_NONE);
- }
- else
- {
- DBG("CALENDAR_RANGE_COUNT(%d)", num);
- ret = _cal_record_set_int(record, _calendar_event.range_type, CALENDAR_RANGE_COUNT);
- ret = _cal_record_set_int(record, _calendar_event.count, num);
- }
- }
- else
- {
- sscanf(t[i], "%4d%2d%2dT%2d%2d%2d", &y, &mon, &d, &h, &min, &s);
- DBG("get until %04d/%02d/%02d %02d:%02d:%02d", y, mon, d, h, min, s);
- switch (event->start.type)
- {
- case CALENDAR_TIME_UTIME:
- ut.type = CALENDAR_TIME_UTIME;
- ut.time.utime = _cal_time_convert_itol(event->start_tzid,
- y, mon, d, h, min, s);
- DBG("CALENDAR_RANGE_UNTIL(%lld)", ut.time.utime);
- break;
- case CALENDAR_TIME_LOCALTIME:
- ut.type = CALENDAR_TIME_LOCALTIME;
- ut.time.date.year = y;
- ut.time.date.month = mon;
- ut.time.date.mday = d;
- DBG("CALENDAR_RANGE_UNTIL(%04d/%02d/%02d)", y, mon, d);
- break;
+ } else {
+ DBG("Invalid");
}
- ret = _cal_record_set_int(record, _calendar_event.range_type, CALENDAR_RANGE_UNTIL);
- ret = _cal_record_set_caltime(record, _calendar_event.until_time, ut);
}
- break;
-
- default:
- mode = __RRULE_VER1_MODE_OUT;
- break;
- }
-
- if (mode == __RRULE_VER1_MODE_OUT)
- {
- break;
}
}
-
- if (strlen(buf_by) > 0)
- {
- DBG("bystr[%s]", buf_by);
- ret = _cal_record_set_str(record, byint, buf_by);
+ if (true == has_by) {
+ __set_bystr(freq_mode, record, bystr);
}
- CAL_FREE(r);
+ // end
+
g_strfreev(t);
- return CALENDAR_ERROR_NONE;
}
-static int __cal_vcalendar_parse_rrule(int type, calendar_list_h list, calendar_record_h record, char *prop, char *cont)
+static void __work_component_property_rrule_ver_2(char *value, calendar_record_h record, struct user_data *ud)
{
- int ret;
- int i, j, k;
- int mode;
- int version = 0;
- char buf[64] = {0};
- char *p = (char *)cont;
-
- i = j = 0;
- mode = 0;
-
- if (p[i + 1] == '\0')
- {
- ERR("Invalid parameter");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- if (strstr(p, "FREQ=")) {
- DBG("This is version 2");
- version = 2;
- } else {
- DBG("This is version 1");
- version = 1;
- }
-
- if (version == 2) {
- i = j = 0;
- ret = _cal_record_set_int(record, _calendar_event.interval, 1);
- /* this is for ver 2 */
- while (p[i] != '\0') {
- DBG("[%c](%d)", p[i], i);
- switch (p[i]) {
- case ':':
- case ';':
- buf[j] = '\0';
- if (strlen(buf) < 1) {
- break;
- }
+ int ret = 0;
+ char **t = NULL;
+ t = g_strsplit_set(value, ";:", -1);
+ retm_if (NULL == t, "g_strsplit_set() is failed");
- for (k = 0; k < RRULE_MAX; k++) {
- if (!strncmp(buf, _rrule_funcs[k].prop, strlen(_rrule_funcs[k].prop))) {
- _rrule_funcs[k].func(record, buf + strlen(_rrule_funcs[k].prop));
- break;
- }
- }
- j = 0;
- break;
+ ret = _cal_record_set_int(record, _calendar_event.range_type, CALENDAR_RANGE_NONE);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
- default:
- buf[j] = p[i];
- j++;
- break;
+ // start
+ int len = g_strv_length(t);
+ int i;
+ for (i = 0; i < len; i++) {
+ if (NULL == t[i] || '\0' == *t[i]) continue;
+
+ if (!strncmp(t[i], "FREQ=", strlen("FREQ="))) {
+ int frequency = 0;
+ if (!strncmp(t[i] + strlen("FREQ"), "=YEARLY", strlen("=YEARLY"))) {
+ frequency = CALENDAR_RECURRENCE_YEARLY;
+ } else if (!strncmp(t[i] + strlen("FREQ"), "=MONTHLY", strlen("=MONTHLY"))) {
+ frequency = CALENDAR_RECURRENCE_MONTHLY;
+ } else if (!strncmp(t[i] + strlen("FREQ"), "=WEEKLY", strlen("=WEEKLY"))) {
+ frequency = CALENDAR_RECURRENCE_WEEKLY;
+ } else if (!strncmp(t[i] + strlen("FREQ"), "=DAILY", strlen("=DAILY"))) {
+ frequency = CALENDAR_RECURRENCE_DAILY;
+ } else {
+ frequency = CALENDAR_RECURRENCE_NONE;
}
- i++;
- }
-
- buf[j] = '\0';
- for (i = 0; i < RRULE_MAX; i++) {
- if (!strncmp(buf, _rrule_funcs[i].prop, strlen(_rrule_funcs[i].prop))) {
- version = 2;
- _rrule_funcs[i].func(record, buf + strlen(_rrule_funcs[i].prop));
- break;
+ DBG("frequency(%d) [%s]", frequency, t[i] + strlen("FREQ") + 1);
+ ret = _cal_record_set_int(record, _calendar_event.freq, frequency);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+
+ } else if (!strncmp(t[i], "UNTIL=", strlen("UNTIL="))) {
+ calendar_time_s caltime = {0};
+ __get_caltime(t[i] + strlen("UNTIL="), &caltime, ud);
+ ret = _cal_record_set_caltime(record, _calendar_event.until_time, caltime);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_caltime() is failed(%d)", ret);
+ ret = _cal_record_set_int(record, _calendar_event.range_type, CALENDAR_RANGE_UNTIL);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if (!strncmp(t[i], "COUNT=", strlen("COUNT="))) {
+ int count = atoi(t[i] + strlen("COUNT="));
+ if (count < 1) count = 1;
+ ret = _cal_record_set_int(record, _calendar_event.count, count);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ ret = _cal_record_set_int(record, _calendar_event.range_type, CALENDAR_RANGE_COUNT);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if (!strncmp(t[i], "INTERVAL=", strlen("INTERVAL="))) {
+ int interval = atoi(t[i] + strlen("INTERVAL="));
+ if (interval < 1) interval = 1;
+ ret = _cal_record_set_int(record, _calendar_event.interval, interval);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if (!strncmp(t[i], "BYYEARDAY=", strlen("BYYEARDAY="))) {
+ ret = _cal_record_set_str(record, _calendar_event.byyearday, t[i] + strlen("BYYEARDAY="));
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() is failed(%d)", ret);
+ } else if (!strncmp(t[i], "BYWEEKNO=", strlen("BYWEEKNO="))) {
+ ret = _cal_record_set_str(record, _calendar_event.byweekno, t[i] + strlen("BYWEEKNO="));
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() is failed(%d)", ret);
+ } else if (!strncmp(t[i], "BYMONTH=", strlen("BYMONTH="))) {
+ ret = _cal_record_set_str(record, _calendar_event.bymonth, t[i] + strlen("BYMONTH="));
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() is failed(%d)", ret);
+ } else if (!strncmp(t[i], "BYMONTHDAY=", strlen("BYMONTHDAY="))) {
+ ret = _cal_record_set_str(record, _calendar_event.bymonthday, t[i] + strlen("BYMONTHDAY="));
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() is failed(%d)", ret);
+ } else if (!strncmp(t[i], "BYDAY=", strlen("BYDAY="))) {
+ ret = _cal_record_set_str(record, _calendar_event.byday, t[i] + strlen("BYDAY="));
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() is failed(%d)", ret);
+ } else if (!strncmp(t[i], "BYSETPOS=", strlen("BYSETPOS="))) {
+ ret = _cal_record_set_str(record, _calendar_event.bysetpos, t[i] + strlen("BYSETPOS="));
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() is failed(%d)", ret);
+ } else if (!strncmp(t[i], "WKST=", strlen("WKST="))) {
+ if (!strncmp(t[i] + strlen("WKST="), "SU", strlen("SU"))) {
+ ret = _cal_record_set_int(record, _calendar_event.wkst, CALENDAR_SUNDAY);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if (!strncmp(t[i] + strlen("WKST="), "MO", strlen("MO"))) {
+ ret = _cal_record_set_int(record, _calendar_event.wkst, CALENDAR_MONDAY);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if (!strncmp(t[i] + strlen("WKST="), "TU", strlen("TU"))) {
+ ret = _cal_record_set_int(record, _calendar_event.wkst, CALENDAR_TUESDAY);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if (!strncmp(t[i] + strlen("WKST="), "WE", strlen("WE"))) {
+ ret = _cal_record_set_int(record, _calendar_event.wkst, CALENDAR_WEDNESDAY);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if (!strncmp(t[i] + strlen("WKST="), "TH", strlen("TH"))) {
+ ret = _cal_record_set_int(record, _calendar_event.wkst, CALENDAR_THURSDAY);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if (!strncmp(t[i] + strlen("WKST="), "FR", strlen("FR"))) {
+ ret = _cal_record_set_int(record, _calendar_event.wkst, CALENDAR_FRIDAY);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if (!strncmp(t[i] + strlen("WKST="), "SA", strlen("SA"))) {
+ ret = _cal_record_set_int(record, _calendar_event.wkst, CALENDAR_SATURDAY);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else {
+ DBG("Unable to parse[%s]", t[i]);
}
- }
- return CALENDAR_ERROR_NONE;
- }
-
- // for ver 1.0
- __cal_vcalendar_parse_rrule_ver1(record, p);
-
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_vcalendar_parse_dtend(int type, calendar_list_h list, calendar_record_h record, char *prop, char *cont)
-{
- int ret;
- int i;
- int len = 0;
- char *p = (char *)cont;
- char **t;
- char *str_tzid = NULL;
-
- p++;
-
- calendar_time_s caltime = {0};
-
- t = g_strsplit_set(p, ";:", -1);
- if (NULL == t)
- {
- ERR("g_strsplit_set() failed");
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
-
- len = g_strv_length(t);
- for (i = 0; i < len; i++)
- {
- DBG("get string[%s]", t[i]);
- if (!strncmp(t[i], "TZID=", strlen("TZID=")) && NULL == str_tzid)
- {
- str_tzid = __cal_vcalendar_parse_dtstart_tzid(t[i]);
- DBG("str_tzid[%s]", str_tzid);
- }
- else if (!strncmp(t[i], "VALUE=", strlen("VALUE")))
- {
- DBG("get value");
- __cal_vcalendar_parse_dtstart_value(t[i], &caltime);
- }
- else if (*t[i] >= '1' && *t[i] <= '9')
- {
- DBG("get time");
- __cal_vcalendar_parse_time_utime(list, t[i], str_tzid, &caltime);
- }
- else
- {
- ERR("Unable to parsing[%s]", t[i]);
+ } else {
+ DBG("Unable to parse[%s]", t[i]);
}
}
+ // end
- if (NULL == str_tzid)
- {
- // if tzid is not set, set GMT
- str_tzid = strdup(CAL_TZID_GMT);
- }
- switch (type)
- {
- case CALENDAR_BOOK_TYPE_EVENT:
- ret = _cal_record_set_str(record, _calendar_event.end_tzid, str_tzid);
- ret = _cal_record_set_caltime(record, _calendar_event.end_time, caltime);
- break;
- case CALENDAR_BOOK_TYPE_TODO:
- ret = _cal_record_set_str(record, _calendar_todo.due_tzid, str_tzid);
- ret = _cal_record_set_caltime(record, _calendar_todo.due_time, caltime);
- break;
- }
- if (str_tzid) free(str_tzid);
g_strfreev(t);
-
- return CALENDAR_ERROR_NONE;
}
-static int __cal_vcalendar_parse_due(int type, calendar_list_h list, calendar_record_h record, char *prop, char *cont)
+static void __work_component_property_rrule(char *value, calendar_record_h record, struct user_data *ud)
{
- int ret;
- int i;
- int len = 0;
- char *p = (char *)cont;
- char **t;
- char *str_tzid = NULL;
- int version = 1;
-
- p++;
+ ENTER();
- calendar_time_s caltime = {0};
-
- t = g_strsplit_set(p, ";:", -1);
- if (NULL == t)
- {
- ERR("g_strsplit_set() failed");
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
-
- len = g_strv_length(t);
- for (i = 0; i < len; i++)
- {
- DBG("get string[%s]", t[i]);
- if (!strncmp(t[i], "TZID=", strlen("TZID=")) && NULL == str_tzid)
- {
- str_tzid = __cal_vcalendar_parse_dtstart_tzid(t[i]);
- DBG("str_tzid[%s]", str_tzid);
- }
- else if (!strncmp(t[i], "VALUE=", strlen("VALUE")))
- {
- DBG("get value");
- version = 2;
- __cal_vcalendar_parse_dtstart_value(t[i], &caltime);
- }
- else if (*t[i] >= '1' && *t[i] <= '9')
- {
- DBG("get time");
- __cal_vcalendar_parse_time_due(version, list, t[i], str_tzid, &caltime);
- }
- else
- {
- ERR("Unable to parsing[%s]", t[i]);
- }
- }
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+ retm_if (NULL == ud, "Invalid parameter: ud is NULL");
- if (NULL == str_tzid)
- {
- // if tzid is not set, set GMT
- str_tzid = strdup(CAL_TZID_GMT);
- }
- switch (type)
+ switch (ud->type)
{
case CALENDAR_BOOK_TYPE_EVENT:
- ret = _cal_record_set_str(record, _calendar_event.end_tzid, str_tzid);
- ret = _cal_record_set_caltime(record, _calendar_event.end_time, caltime);
- break;
- case CALENDAR_BOOK_TYPE_TODO:
- ret = _cal_record_set_str(record, _calendar_todo.due_tzid, str_tzid);
- ret = _cal_record_set_caltime(record, _calendar_todo.due_time, caltime);
- break;
- }
- if (str_tzid) free(str_tzid);
- g_strfreev(t);
-
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_vcalendar_parse_completed(int type, calendar_list_h list, calendar_record_h event, char *prop, char *cont)
-{
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_vcalendar_parse_percent(int type, calendar_list_h list, calendar_record_h event, char *prop, char *cont)
-{
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_vcalendar_parse_attendee_role(char *p, int *role)
-{
- if (NULL == p)
- {
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- if (!strncmp(p, "REQ-PARTICIPANT", strlen("REQ-PARTICIPANT")))
- {
- *role = CALENDAR_ATTENDEE_ROLE_REQ_PARTICIPANT;
- }
- else if (!strncmp(p, "OPT-PARTICIPANT", strlen("OPT-PARTICIPANT")))
- {
- *role = CALENDAR_ATTENDEE_ROLE_OPT_PARTICIPANT;
- }
- else if (!strncmp(p, "NON-PARTICIPANT", strlen("NON-PARTICIPANT")))
- {
- *role = CALENDAR_ATTENDEE_ROLE_NON_PARTICIPANT;
- }
- else if (!strncmp(p, "CHAIR", strlen("CHAIR")))
- {
- *role = CALENDAR_ATTENDEE_ROLE_CHAIR;
- }
- else
- {
- }
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_vcalendar_parse_attendee_partstat(char *p, int *stat)
-{
- if (NULL == p)
- {
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- if (!strncmp(p, "NEEDS-ACTION", strlen("NEEDS-ACTION")))
- {
- *stat = CALENDAR_ATTENDEE_STATUS_PENDING;
- }
- else if (!strncmp(p, "ACCEPTED", strlen("ACCEPTED")))
- {
- *stat = CALENDAR_ATTENDEE_STATUS_ACCEPTED;
- }
- else if (!strncmp(p, "DECLINED", strlen("DECLINED")))
- {
- *stat = CALENDAR_ATTENDEE_STATUS_DECLINED;
- }
- else if (!strncmp(p, "TENTATIVE", strlen("TENTATIVE")))
- {
- *stat = CALENDAR_ATTENDEE_STATUS_TENTATIVE;
- }
- else if (!strncmp(p, "DELEGATED", strlen("DELEGATED")))
- {
- *stat = CALENDAR_ATTENDEE_STATUS_DELEGATED;
- }
- else if (!strncmp(p, "COMPLETED", strlen("COMPLETED")))
- {
- *stat = CALENDAR_ATTENDEE_STATUS_COMPLETED;
- }
- else if (!strncmp(p, "IN-PROCESS", strlen("IN-PROCESS")))
- {
- *stat = CALENDAR_ATTENDEE_STATUS_IN_PROCESS;
- }
- else
- {
- ERR("Unable to parse[%s]", p);
- }
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_vcalendar_parse_attendee_mailto(char *p, calendar_record_h attendee)
-{
- if (NULL == p || NULL == attendee)
- {
- ERR("Invalid parameter");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- p++; // to remove ':'
- _cal_record_set_str(attendee, _calendar_attendee.email, p);
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_vcalendar_parse_attendee_param(char *p, calendar_record_h attendee)
-{
- int i;
- int len = 0;
- char **t;
-
- if (NULL == p || NULL == attendee)
- {
- ERR("Invalid parameter");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- DBG("attendee param[%s]", p);
- t = g_strsplit_set(p, ";:", -1);
- if (NULL == t)
- {
- ERR("g_strsplit_set() failed");
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
-
- len = g_strv_length(t);
- for (i = 0; i < len; i++)
- {
- DBG("get string[%s]", t[i]);
- if (!strncmp(t[i], "CUTYPE=", strlen("CUTYPE=")))
- {
- }
- else if (!strncmp(t[i], "MEMBER=", strlen("MEMBER=")))
- {
- }
- else if (!strncmp(t[i], "ROLE=", strlen("ROLE=")))
- {
- int role = 0;
- __cal_vcalendar_parse_attendee_role(t[i] + strlen("ROLE="), &role);
- _cal_record_set_int(attendee, _calendar_attendee.role, role);
- }
- else if (!strncmp(t[i], "PARTSTAT=", strlen("PARTSTAT=")))
- {
- int stat = 0;
- __cal_vcalendar_parse_attendee_partstat(t[i] + strlen("PARTSTAT="), &stat);
- _cal_record_set_int(attendee, _calendar_attendee.status, stat);
- }
- else if (!strncmp(t[i], "RSVP=", strlen("RSVP=")))
- {
- }
- else if (!strncmp(t[i], "DELTO=", strlen("DELTO=")))
- {
- DBG("[%s]", t[i] + strlen("DELTO="));
- _cal_record_set_str(attendee, _calendar_attendee.delegate_uri, t[i] + strlen("DELTO="));
- }
- else if (!strncmp(t[i], "DELFROM=", strlen("DELFROM=")))
- {
- DBG("[%s]", t[i] + strlen("DELFROM="));
- _cal_record_set_str(attendee, _calendar_attendee.delegator_uri, t[i] + strlen("DELFROM="));
- }
- else if (!strncmp(t[i], "SENT-BY=", strlen("SENT-BY=")))
- {
- }
- else if (!strncmp(t[i], "CN=", strlen("CN=")))
- {
- DBG("[%s]", t[i] + strlen("CN="));
- _cal_record_set_str(attendee, _calendar_attendee.name, t[i] + strlen("CN="));
- }
- else if (!strncmp(t[i], "DIR=", strlen("DIR=")))
- {
- }
- else
- {
- DBG("No macthed field[%s]", t[i]);
- }
- }
- g_strfreev(t);
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_vcalendar_parse_attendee(int type, calendar_list_h list, calendar_record_h event, char *prop, char *cont)
-{
- int i;
- int ret;
- int len = 0;
- char *p = (char *)cont;
- char **t;
-
- p++;
-
- // divide mailto firstly.
- t = g_strsplit(p, ":mailto", -1);
- {
- if (NULL == t)
- {
- ERR("g_strsplit_set() failed");
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- }
-
- calendar_record_h attendee = NULL;
- ret = calendar_record_create(_calendar_attendee._uri, &attendee);
- if (NULL == attendee)
- {
- ERR("Failed to create attedee(ret:%d)", ret);
- return ret;
- }
-
- len = g_strv_length(t);
- for (i = 0; i < len; i++)
- {
- if (*t[i] == ':')
- {
- __cal_vcalendar_parse_attendee_mailto(t[i], attendee);
- }
- else
- {
- __cal_vcalendar_parse_attendee_param(t[i], attendee);
- }
- }
-
- ret = calendar_record_add_child_record(event, _calendar_event.calendar_attendee, attendee);
-
- g_strfreev(t);
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_vcalendar_parse_categories(int type, calendar_list_h list, calendar_record_h event, char *prop, char *cont)
-{
- char *p = (char *)cont;
- int encoding = 0;
-
- while (*p != '\n' && *p != '\r' && *p != '\0') {
- if ( *p == ':') {
- p++;
- if (encoding == ENCODE_BASE64) {
- gsize len;
- _cal_record_set_str(event, _calendar_event.categories,
- (char *)g_base64_decode(p, &len));
-
- } else if (encoding == ENCODE_QUOTED_PRINTABLE) {
- int len;
- __cal_vcalendar_parse_decode_quoted_printable(p, &len);
- _cal_record_set_str(event, _calendar_event.categories, p);
-
- } else {
- _cal_record_set_str(event, _calendar_event.categories, p);
- }
- break;
-
- } else if (*p == ';') {
- p++;
- __cal_vcalendar_parse_get_optional(p, &encoding);
-
- } else {
- p++;
- }
- }
- DBG("type(%d)categories(%s)\n", type, p);
-
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_vcalendar_parse_extended(int type, calendar_list_h list, calendar_record_h record, char *prop, char *cont)
-{
- int ret;
- int id;
- calendar_record_h extended = NULL;
-
- ret = calendar_record_create(_calendar_extended_property._uri, &extended);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_create() failed");
- return ret;
- }
-
- DBG("key[%s]value[%s]", prop, cont);
- ret = calendar_record_set_str(extended, _calendar_extended_property.key, prop);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_set_str() failed");
- return ret;
- }
- ret = calendar_record_set_str(extended, _calendar_extended_property.value, cont);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_set_str() failed");
- return ret;
- }
-
- switch (type)
- {
- case CALENDAR_BOOK_TYPE_EVENT:
- ret = calendar_record_get_int(record, _calendar_event.id, &id);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_get_int() failed");
- return ret;
- }
- ret = calendar_record_add_child_record(record, _calendar_event.extended, extended);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_add_child_record() failed");
- return ret;
- }
- break;
-
- case CALENDAR_BOOK_TYPE_TODO:
- ret = calendar_record_get_int(record, _calendar_todo.id, &id);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_get_int() failed");
- return ret;
- }
- ret = calendar_record_add_child_record(record, _calendar_todo.extended, extended);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_add_child_record() failed");
- return ret;
- }
- break;
- }
-
- return CALENDAR_ERROR_NONE;
-}
-
-/*
- For ver 1.0 aalarm
- alarmparts = 0*3(strnosemi ";") strnosemi
- ; runTime, snoozeTime, repeatCount, audioContent
-*/
-enum {
- __AALARM_INVALID = 0,
- __AALARM_RUNTIME,
- __AALARM_TYPE,
- __AALARM_VALUE,
- __AALARM_SNOOZETIME,
- __AALARM_REPEATCOUNT,
- __AALARM_AUDIOCONTENT,
-};
-static int __cal_vcalendar_parse_aalarm(int type, calendar_list_h list, calendar_record_h record, char *prop, char *cont)
-{
- int ret;
- int i = 0, j = 0;
- int part = 0;
- int y, mon, d, h, min, s;
- char t, z;
- char buf[64] = {0};
- char *p = (char *)cont;
-
- if (p[i + 1] == '\0')
- {
- ERR("Invalid parameter");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- while (p[i] != '\0')
- {
- // select part
- switch (p[i])
- {
- case ':':
- i++;
- part = __AALARM_RUNTIME;
- break;
-
- case ';':
- i++;
- if (!strncmp(p, "TYPE=", strlen("TYPE=")))
- {
- part = __AALARM_TYPE;
- }
- else if (!strncmp(p, "VALUE=", strlen("VALUE=")))
- {
- part = __AALARM_VALUE;
- }
- else if (p[i] == 'P')
- {
- part = __AALARM_SNOOZETIME; // Period
- }
- else if (p[i] >= '0' && p[i] < '9')
- {
- part = __AALARM_REPEATCOUNT; // repeatCount
- }
- else
- {
- part = __AALARM_AUDIOCONTENT;
- }
- break;
-
- default:
- ERR("Error");
- i++;
- break;
- }
-
- // extract value
- j = 0;
- while (p[i] != '\0' && p[i] != ':' && p[i] != ';')
- {
- buf[j] = p[i];
- j++;
- i++;
- }
- buf[j] = '\0';
-
- DBG("part(%d) value[%s]", part, buf);
- // work part
- switch (part)
- {
- case __AALARM_INVALID:
- break;
-
- case __AALARM_RUNTIME:
- y = mon = d = h = min = s = 0;
- if (strlen(buf) < strlen("YYYYMMDD"))
- {
- ERR("Invalid until[%s]", buf);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- sscanf(buf, "%04d%02d%02d%c%02d%02d%02d%c", &y, &mon, &d, &t, &h, &min, &s, &z);
- DBG("%d %d %d %d %d %d", y, mon, d, h, min, s);
- break;
-
- case __AALARM_TYPE:
- break;
-
- case __AALARM_VALUE:
- break;
-
- case __AALARM_SNOOZETIME:
- break;
-
- case __AALARM_REPEATCOUNT:
- break;
-
- case __AALARM_AUDIOCONTENT:
- break;
-
- }
- }
-
- char *tzid = NULL;
- long long int run_utime = 0;
- int diff = 0;
- int tick = 0, unit = 0;
- calendar_record_h alarm = NULL;
- calendar_time_s caltime = {0};
- switch (type)
- {
- case VCALENDAR_TYPE_VEVENT:
- ret = calendar_record_get_caltime(record, _calendar_event.start_time, &caltime);
- if (z != 'Z')
- {
- ret = calendar_record_get_str_p(record, _calendar_event.start_tzid, &tzid);
- run_utime = _cal_time_convert_itol(tzid, y, mon, d, h, min, s);
- if (tzid) free(tzid);
- }
- else
- {
- run_utime = _cal_time_convert_itol(NULL, y, mon, d, h, min, s);
- }
-
- switch (caltime.type)
- {
- case CALENDAR_TIME_UTIME:
- diff = (int)(caltime.time.utime - run_utime);
- DBG("diff(%d) = (%lld) - (%lld)", diff, caltime.time.utime, run_utime);
-
- if (diff / (60 * 60 * 24 * 7) > 0)
- {
- unit = CALENDAR_ALARM_TIME_UNIT_WEEK;
- tick = diff /(60 * 60 * 24 * 7);
- }
- else if (diff / (60 * 60 * 24 ) > 0)
- {
- unit = CALENDAR_ALARM_TIME_UNIT_DAY;
- tick = diff /(60 * 60 * 24);
- }
- else if (diff / (60 * 60) > 0)
- {
- unit = CALENDAR_ALARM_TIME_UNIT_HOUR;
- tick = diff / (60 * 60);
- }
- else
- {
- unit = CALENDAR_ALARM_TIME_UNIT_MINUTE;
- tick = diff / 60;
- }
- break;
-
- case CALENDAR_TIME_LOCALTIME:
- break;
- }
-
- ret = calendar_record_create(_calendar_alarm._uri, &alarm);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_create() failed");
- return ret;
- }
- calendar_record_set_int(alarm, _calendar_alarm.tick, tick);
- calendar_record_set_int(alarm, _calendar_alarm.tick_unit, unit);
- calendar_record_add_child_record(record, _calendar_event.calendar_alarm, alarm);
- break;
-
- case VCALENDAR_TYPE_VTODO:
- ret = calendar_record_get_caltime(record, _calendar_todo.due_time, &caltime);
- if (z != 'Z')
- {
- ret = calendar_record_get_str_p(record, _calendar_todo.due_tzid, &tzid);
- run_utime = _cal_time_convert_itol(tzid, y, mon, d, h, min, s);
- if (tzid) free(tzid);
- }
- else
+ switch (ud->version)
{
- run_utime = _cal_time_convert_itol(NULL, y, mon, d, h, min, s);
- }
-
- switch (caltime.type)
- {
- case CALENDAR_TIME_UTIME:
- diff = (int)(caltime.time.utime - run_utime);
-
- if (diff / (60 * 60 * 24 * 7) > 0)
- {
- unit = CALENDAR_ALARM_TIME_UNIT_WEEK;
- tick = diff /(60 * 60 * 24 * 7);
- }
- else if (diff / (60 * 60 * 24 ) > 0)
- {
- unit = CALENDAR_ALARM_TIME_UNIT_DAY;
- tick = diff /(60 * 60 * 24);
- }
- else if (diff / (60 * 60) > 0)
- {
- unit = CALENDAR_ALARM_TIME_UNIT_HOUR;
- tick = diff / (60 * 60);
- }
- else
- {
- unit = CALENDAR_ALARM_TIME_UNIT_MINUTE;
- tick = diff / 60;
- }
+ case VCAL_VER_1:
+ __work_component_property_rrule_ver_1(value, record, ud);
break;
-
- break;
- case CALENDAR_TIME_LOCALTIME:
- break;
- }
- ret = calendar_record_create(_calendar_alarm._uri, &alarm);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_create() failed");
- return ret;
- }
- calendar_record_set_int(alarm, _calendar_alarm.tick, tick);
- calendar_record_set_int(alarm, _calendar_alarm.tick_unit, unit);
- calendar_record_add_child_record(record, _calendar_todo.calendar_alarm, alarm);
- break;
- }
-
- return CALENDAR_ERROR_NONE;
-}
-/* end */
-
-
-enum {
- WEEKNAME2_SA = 0x0,
- WEEKNAME2_FR,
- WEEKNAME2_TH,
- WEEKNAME2_WE,
- WEEKNAME2_TU,
- WEEKNAME2_MO,
- WEEKNAME2_SU,
- WEEKNAME2_MAX,
-};
-const char weekname2[WEEKNAME2_MAX][3] = {"SA", "FR", "TH", "WE", "TU", "MO", "SU"};
-
-//alarm////////////////////////////////////////////////////////////
-static int __cal_vcalendar_parse_action(calendar_record_h alarm, void *data)
-{
- return CALENDAR_ERROR_NONE;
-}
-
-static char *__cal_vcalendar_parse_extract_duration(char *p, int *dur_t, char *dur)
-{
- char du = '0';
- char buf[8] = {0, };
- int i = 0, c, d = 1;
- int t = 0;
-
- DBG("%s", p);
- while (*p != '\0' && *p != '\n') {
- switch (*p) {
- case '+':
- d = 1;
- break;
- case '-':
- d = -1;
- break;
- case 'P':
- i = 0;
- break;
- case 'T':
- break;
- case 'W':
- du = 'W';
- c = atoi(buf);
- t += c * 7 * 24 * 60 * 60;
- memset(buf, 0x0, sizeof(buf));
- i = 0;
- break;
- case 'D':
- du = 'D';
- c = atoi(buf);
- t += c * 24 * 60 * 60;
- memset(buf, 0x0, sizeof(buf));
- i = 0;
- break;
- case 'H':
- du = 'H';
- c = atoi(buf);
- t += c * 60 * 60;
- memset(buf, 0x0, sizeof(buf));
- i = 0;
- break;
- case 'M':
- du = 'M';
- c = atoi(buf);
- t += c * 60;
- memset(buf, 0x0, sizeof(buf));
- i = 0;
- break;
- case 'S':
- du = 'S';
- c = atoi(buf);
- t += c;
- memset(buf, 0x0, sizeof(buf));
- i = 0;
- break;
- default:
- buf[i] = *p;
- i++;
+ case VCAL_VER_2:
+ __work_component_property_rrule_ver_2(value, record, ud);
break;
-
}
- p++;
- }
- t *= d;
- *dur_t = t;
-
- if (dur) {
- *dur = du;
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ DBG("Not support rrule in todo");
+ break;
}
-
- return p;
}
-static int __cal_vcalendar_parse_trigger_time(calendar_record_h alarm, char *p)
+static void __work_component_property_dtend(char *value, calendar_record_h record, struct user_data *ud)
{
- char t = 0, z;
- int y, mon, d, h, min, s;
- int tick, unit;
- cal_alarm_s *_alarm = (cal_alarm_s *)alarm;
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+ retm_if (NULL == ud, "Invalid parameter: ud is NULL");
- if (NULL == alarm || NULL == p)
- {
- ERR("Invalid parameter");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
+ value = __decode_datetime(value, ud);
+ calendar_time_s caltime = {0};
+ __get_caltime(value, &caltime, ud);
- sscanf(p, "%4d%2d%2d%c%2d%2d%2d%c", &y, &mon, &d, &t, &h, &min, &s, &z);
+ int ret = 0;
+ char *tzid = NULL;
+ tzid = ud->datetime_tzid ? ud->datetime_tzid : (ud->timezone_tzid ? ud->timezone_tzid : NULL);
- tick = _alarm->remind_tick;
- unit = _alarm->remind_tick_unit;
- switch (unit)
+ switch (ud->type)
{
- case CALENDAR_ALARM_TIME_UNIT_WEEK:
- mon += tick;
- break;
- case CALENDAR_ALARM_TIME_UNIT_DAY:
- d += tick;
- break;
- case CALENDAR_ALARM_TIME_UNIT_HOUR:
- h += tick;
- break;
- case CALENDAR_ALARM_TIME_UNIT_MINUTE:
- min += tick;
+ case CALENDAR_BOOK_TYPE_EVENT:
+ if (tzid && *tzid) {
+ ret = _cal_record_set_str(record, _calendar_event.end_tzid, tzid);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() Failed(%d)", ret);
+ }
+ ret = _cal_record_set_caltime(record, _calendar_event.end_time, caltime);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_caltime() Failed(%d)", ret);
break;
- case CALENDAR_ALARM_TIME_UNIT_SPECIFIC:
- default:
+ case CALENDAR_BOOK_TYPE_TODO:
+ if (tzid && *tzid) {
+ ret = _cal_record_set_str(record, _calendar_todo.due_tzid, tzid);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() Failed(%d)", ret);
+ }
+ ret = _cal_record_set_caltime(record, _calendar_todo.due_time, caltime);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_caltime() Failed(%d)", ret);
break;
}
+}
- if (t == 0)
- {
- int datetime = y *10000 + mon *100 + d;
- _cal_record_set_lli(alarm, _calendar_alarm.time, datetime);
- DBG("DATE(%d)", datetime);
- }
- else
- {
- long long int lli = _cal_time_convert_itol(NULL, y, mon, d, h, min, s);
- _cal_record_set_lli(alarm, _calendar_alarm.time, lli);
- DBG("DATE-TIME(%lld)", lli);
+// attendee
+static void __work_component_property_attendee_cutype(calendar_record_h attendee, char *value)
+{
+ retm_if (NULL == attendee, "Invalid parameter: attendee is NULL");
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+
+ int ret = 0;
+DBG("[%s]", value);
+ if (!strncmp(value, "INDIVIDUAL", strlen("INDIVIDUAL"))) {
+ ret = _cal_record_set_int(attendee, _calendar_attendee.cutype, CALENDAR_ATTENDEE_CUTYPE_INDIVIDUAL);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if (!strncmp(value, "GROUP", strlen("GROUP"))) {
+ ret = _cal_record_set_int(attendee, _calendar_attendee.cutype, CALENDAR_ATTENDEE_CUTYPE_GROUP);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if (!strncmp(value, "RESOURCE", strlen("RESOURCE"))) {
+ ret = _cal_record_set_int(attendee, _calendar_attendee.cutype, CALENDAR_ATTENDEE_CUTYPE_RESOURCE);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if (!strncmp(value, "ROOM", strlen("ROOM"))) {
+ ret = _cal_record_set_int(attendee, _calendar_attendee.cutype, CALENDAR_ATTENDEE_CUTYPE_ROOM);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if (!strncmp(value, "UNKNOWN", strlen("UNKNOWN"))) {
+ ret = _cal_record_set_int(attendee, _calendar_attendee.cutype, CALENDAR_ATTENDEE_CUTYPE_UNKNOWN);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else {
+ ERR("Invalid value[%s]", value);
}
- return CALENDAR_ERROR_NONE;
}
-
-static int __cal_vcalendar_parse_duration_alarm(calendar_record_h alarm, void *data)
+static void __work_component_property_attendee_member(calendar_record_h attendee, char *value)
{
- int ret = CALENDAR_ERROR_NONE;
- char *p = (char *)data;
- char dur;
- int dur_t;
- int tick, unit;
+ retm_if (NULL == attendee, "Invalid parameter: attendee is NULL");
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
- p++;
+ int ret = _cal_record_set_str(attendee, _calendar_attendee.member, value);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() Failed(%d)", ret);
+}
+static void __work_component_property_attendee_role(calendar_record_h attendee, char *value)
+{
+ retm_if (NULL == attendee, "Invalid parameter: attendee is NULL");
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
- __cal_vcalendar_parse_extract_duration(p, &dur_t, &dur);
- switch (dur) {
- case 'W':
- tick = dur_t/(7 *24 *60 *60);
- unit = CALENDAR_ALARM_TIME_UNIT_WEEK;
- break;
- case 'D':
- tick = dur_t/(24 *60 *60);
- unit = CALENDAR_ALARM_TIME_UNIT_DAY;
- break;
- case 'H':
- tick = dur_t/(60 *60);
- unit = CALENDAR_ALARM_TIME_UNIT_HOUR;
- break;
- case 'M':
- tick = dur_t/(60);
- unit = CALENDAR_ALARM_TIME_UNIT_MINUTE;
- break;
- default:
- tick = 1;
- unit = CALENDAR_ALARM_NONE;;
- break;
+ int ret = 0;
+ if (!strncmp(value, "REQ-PARTICIPANT", strlen("REQ-PARTICIPANT"))) {
+ ret = _cal_record_set_int(attendee, _calendar_attendee.cutype, CALENDAR_ATTENDEE_ROLE_REQ_PARTICIPANT);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if (!strncmp(value, "OPT-PARTICIPANT", strlen("OPT-PARTICIPANT"))) {
+ ret = _cal_record_set_int(attendee, _calendar_attendee.cutype, CALENDAR_ATTENDEE_ROLE_OPT_PARTICIPANT);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if (!strncmp(value, "NON-PARTICIPANT", strlen("NON-PARTICIPANT"))) {
+ ret = _cal_record_set_int(attendee, _calendar_attendee.cutype, CALENDAR_ATTENDEE_ROLE_NON_PARTICIPANT);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if (!strncmp(value, "CHAIR", strlen("CHAIR"))) {
+ ret = _cal_record_set_int(attendee, _calendar_attendee.cutype, CALENDAR_ATTENDEE_ROLE_CHAIR);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else {
+ ERR("Invalid value[%s]", value);
+ }
+}
+static void __work_component_property_attendee_partstat(calendar_record_h attendee, char *value)
+{
+ retm_if (NULL == attendee, "Invalid parameter: attendee is NULL");
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+
+ int ret = 0;
+ if (!strncmp(value, "NEEDS-ACTION", strlen("NEEDS-ACTION"))) {
+ ret = _cal_record_set_int(attendee, _calendar_attendee.cutype, CALENDAR_ATTENDEE_STATUS_PENDING);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if (!strncmp(value, "ACCEPTED", strlen("ACCEPTED"))) {
+ ret = _cal_record_set_int(attendee, _calendar_attendee.cutype, CALENDAR_ATTENDEE_STATUS_ACCEPTED);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if (!strncmp(value, "DECLINED", strlen("DECLINED"))) {
+ ret = _cal_record_set_int(attendee, _calendar_attendee.cutype, CALENDAR_ATTENDEE_STATUS_DECLINED);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if (!strncmp(value, "TENTATIVE", strlen("TENTATIVE"))) {
+ ret = _cal_record_set_int(attendee, _calendar_attendee.cutype, CALENDAR_ATTENDEE_STATUS_TENTATIVE);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if (!strncmp(value, "DELEGATED", strlen("DELEGATED"))) {
+ ret = _cal_record_set_int(attendee, _calendar_attendee.cutype, CALENDAR_ATTENDEE_STATUS_DELEGATED);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if (!strncmp(value, "COMPLETED", strlen("COMPLETED"))) {
+ ret = _cal_record_set_int(attendee, _calendar_attendee.cutype, CALENDAR_ATTENDEE_STATUS_COMPLETED);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else if (!strncmp(value, "IN-PROCESS", strlen("IN-PROCESS"))) {
+ ret = _cal_record_set_int(attendee, _calendar_attendee.cutype, CALENDAR_ATTENDEE_STATUS_IN_PROCESS);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else {
+ ERR("Invalid value[%s]", value);
}
+}
+static void __work_component_property_attendee_rsvp(calendar_record_h attendee, char *value)
+{
+ retm_if (NULL == attendee, "Invalid parameter: attendee is NULL");
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
- ret = _cal_record_set_int(alarm, _calendar_alarm.tick, tick);
- ret = _cal_record_set_int(alarm, _calendar_alarm.tick_unit, unit);
- DBG("tick(%d) unit(%d)", tick, unit);
+ int ret = 0;
+ if (!strncmp(value, "TRUE", strlen("TRUE"))) {
+ ret = _cal_record_set_int(attendee, _calendar_attendee.rsvp, 1);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ } else {
+ ret = _cal_record_set_int(attendee, _calendar_attendee.rsvp, 0);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ }
+}
+static void __work_component_property_attendee_delegated_to(calendar_record_h attendee, char *value)
+{
+ retm_if (NULL == attendee, "Invalid parameter: attendee is NULL");
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
- return ret;
+ int ret = 0;
+ ret = _cal_record_set_str(attendee, _calendar_attendee.delegatee_uri, value);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() is failed");
}
+static void __work_component_property_attendee_delegated_from(calendar_record_h attendee, char *value)
+{
+ retm_if (NULL == attendee, "Invalid parameter: attendee is NULL");
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
-static int __cal_vcalendar_parse_trigger(calendar_record_h alarm, void *data)
+ int ret = 0;
+ ret = _cal_record_set_str(attendee, _calendar_attendee.delegator_uri, value);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() is failed");
+}
+static void __work_component_property_attendee_sent_by(calendar_record_h attendee, char *value)
{
- int i = 0, out = 0;
- char *p = (char *)data;
+ return;
+}
+static void __work_component_property_attendee_cn(calendar_record_h attendee, char *value)
+{
+ retm_if (NULL == attendee, "Invalid parameter: attendee is NULL");
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
- p++;
+ int ret = 0;
+ ret = _cal_record_set_str(attendee, _calendar_attendee.name, value);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() is failed");
+}
+static void __work_component_property_attendee_dir(calendar_record_h attendee, char *value)
+{
+ return;
+}
+static void __work_component_property_attendee_mailto(calendar_record_h attendee, char *value)
+{
+ retm_if (NULL == attendee, "Invalid parameter: attendee is NULL");
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
- // default unit
- _cal_record_set_int(alarm, _calendar_alarm.tick_unit, CALENDAR_ALARM_TIME_UNIT_SPECIFIC);
+ int ret = 0;
+ ret = _cal_record_set_str(attendee, _calendar_attendee.email, value);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() is failed");
+}
+/*
+ * example
+ * ATTENDEE;ROLE=REQ-PARTICIPANT;DELEGATED-FROM="MAILTO:bob@host.com";PARTSTAT=ACCEPTED;CN=Jane Doe:MAILTO:jdoe@host1.com
+ * ATTENDEE;CN=John Smith;DIR="ldap://host.com:6666/o=eDABC%20Industries,c=3DUS??(cn=3DBJim%20Dolittle)":MAILTO:jimdo@host1.com
+ * ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:MAILTO:employee-A@host.com
+ * ATTENDEE;CN=MAILTO:MAILTO:MAILTO@host.com
+ */
+static void __work_component_property_attendee(char *value, calendar_record_h record, struct user_data *ud)
+{
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+ retm_if (NULL == ud, "Invalid parameter: ud is NULL");
- while (*p != '\n' && *p != '\r' && *p != '\0') {
+ int ret = 0;
+ calendar_record_h attendee = NULL;
+ ret = calendar_record_create(_calendar_attendee._uri, &attendee);
+ retm_if (CALENDAR_ERROR_NONE != ret, "calendar_record_create() is failed(%d)", ret);
- for (i = 0; i < TRIG_MAX; i++) {
- if (!strncmp(p, _trig_funcs[i].prop, strlen(_trig_funcs[i].prop))) {
- out = 1;
- int j = 0;
- char buf[64] = {0, };
- p += strlen(_trig_funcs[i].prop);
- while (p[j] != ';' && p[j] != '\n' && p[j] != '\0') {
- buf[j] = p[j];
- j++;
- }
- if (p[j] != '\0') {
- buf[j] = '\0';
- }
+ char **t = NULL;
+ t = g_strsplit(value, ";", -1);
+ retm_if (NULL == t, "g_strsplit() is failed");
- p += j;
- _trig_funcs[i].func(alarm, buf);
- break;
- }
- }
- if (out == 1) {
- break;
+ int len = g_strv_length(t);
+DBG("len(%d)", len);
+ int i;
+ for (i = 0; i < len; i++) {
+ if (NULL == t[i] || '\0' == *t[i]) continue;
+
+ if (!strncmp(t[i], "CUTYPE", strlen("CUTYPE"))) {
+ __work_component_property_attendee_cutype(attendee, t[i] + strlen("CUTYPE") +1);
+ } else if (!strncmp(t[i], "MEMBER", strlen("MEMBER"))) {
+ __work_component_property_attendee_member(attendee, t[i] + strlen("MEMBER") +1);
+ } else if (!strncmp(t[i], "ROLE", strlen("ROLE"))) {
+ __work_component_property_attendee_role(attendee, t[i] + strlen("ROLE") +1);
+ } else if (!strncmp(t[i], "PARTSTAT", strlen("PARTSTAT"))) {
+ __work_component_property_attendee_partstat(attendee, t[i] + strlen("PARTSTAT") +1);
+ } else if (!strncmp(t[i], "RSVP", strlen("RSVP"))) {
+ __work_component_property_attendee_rsvp(attendee, t[i] + strlen("RSVP") +1);
+ } else if (!strncmp(t[i], "DELEGATED-TO", strlen("DELEGATED-TO"))) {
+ __work_component_property_attendee_delegated_to(attendee, t[i] + strlen("DELEGATED-TO") +1);
+ } else if (!strncmp(t[i], "DELEGATED-FROM", strlen("DELEGATED-FROM"))) {
+ __work_component_property_attendee_delegated_from(attendee, t[i] + strlen("DELEGATED-FROM") +1);
+ } else if (!strncmp(t[i], "SENT_BY", strlen("SENT_BY"))) {
+ __work_component_property_attendee_sent_by(attendee, t[i] + strlen("SENT_BY") +1);
+ } else if (!strncmp(t[i], "CN", strlen("CN"))) {
+ __work_component_property_attendee_cn(attendee, t[i] + strlen("CN") +1);
+ } else if (!strncmp(t[i], "DIR", strlen("DIR"))) {
+ __work_component_property_attendee_dir(attendee, t[i] + strlen("DIR") +1);
+ } else if (!strncmp(t[0], ":MAILTO", strlen(":MAILTO"))) {
+ __work_component_property_attendee_mailto(attendee, t[i] + strlen(":MAILTO") +1);
+ } else {
+ ERR("Invalid value[%s]", t[i]);
}
+ }
+ g_strfreev(t);
- if (*p >= '1' && *p <= '9')
- {
- __cal_vcalendar_parse_trigger_time(alarm, p);
- }
- else
- {
- __cal_vcalendar_parse_duration_alarm(alarm, p);
- }
+ switch (ud->type)
+ {
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = calendar_record_add_child_record(record, _calendar_event.calendar_attendee, attendee);
+ warn_if (CALENDAR_ERROR_NONE != ret, "calendar_record_add_child_record() Failed(%d)", ret);
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = calendar_record_add_child_record(record, _calendar_event.calendar_attendee, attendee);
+ warn_if (CALENDAR_ERROR_NONE != ret, "calendar_record_add_child_record() Failed(%d)", ret);
break;
}
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_vcalendar_parse_repeat(calendar_record_h alarm, void *data)
-{
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_vcalendar_parse_attach_alarm(calendar_record_h alarm, void *data)
-{
- return CALENDAR_ERROR_NONE;
}
-static int __cal_vcalendar_parse_summary_alarm(calendar_record_h alarm, void *data)
+static void __work_component_property_categories(char *value, calendar_record_h record, struct user_data *ud)
{
- int ret;
- char *p = (char *)data;
-
- p++;
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+ retm_if (NULL == ud, "Invalid parameter: ud is NULL");
- ret = _cal_record_set_str(alarm, _calendar_alarm.description, p);
- DBG("alarm description[%s]", p);
- return CALENDAR_ERROR_NONE;
+ int ret = 0;
+ value = __decode_charset(value);
+ switch (ud->type)
+ {
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = _cal_record_set_str(record, _calendar_event.categories, value);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() Failed(%d)", ret);
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = _cal_record_set_str(record, _calendar_todo.categories, value);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() Failed(%d)", ret);
+ break;
+ }
}
-
-//rrule////////////////////////////////////////////////////////////
-static int __cal_vcalendar_parse_freq(calendar_record_h event, void *data)
+/*
+ * for ver 1.0
+ * dalarmparts = 0*3(strnosemi ";") strnosemi; runTime, snoozeTime, repeatCount, displayString
+ * DALARM:19960415T235000;PT5M;2;Your Taxes Are Due !!!
+ */
+static void __work_component_property_dalarm(char *value, calendar_record_h record, struct user_data *ud)
{
- int ret;
- int freq = -1;
- char *p = (char *)data;
+ // diff with aalarm:
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+ retm_if (NULL == ud, "Invalid parameter: ud is NULL");
- DBG("%s\n", (char *)data);
- if (!strncmp(p, "YEARLY", strlen("YEARLY"))) {
- freq = CALENDAR_RECURRENCE_YEARLY;
+ int ret = 0;
+ char **t = NULL;
+ t = g_strsplit_set(value, ";:", -1);
+ retm_if (NULL == t, "g_strsplit_set() is failed");
- } else if (!strncmp(p, "MONTHLY", strlen("MONTHLY"))) {
- freq = CALENDAR_RECURRENCE_MONTHLY;
-
- } else if (!strncmp(p, "WEEKLY", strlen("WEEKLY"))) {
- freq = CALENDAR_RECURRENCE_WEEKLY;
-
- } else if (!strncmp(p, "DAILY", strlen("DAILY"))) {
- freq = CALENDAR_RECURRENCE_DAILY;
+ calendar_record_h alarm = NULL;
+ ret = calendar_record_create(_calendar_alarm._uri, &alarm);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("calendar_record_create() is failed(%d)", ret);
+ g_strfreev(t);
+ return;
+ }
+ ret = _cal_record_set_int(alarm, _calendar_alarm.action, CALENDAR_ALARM_ACTION_DISPLAY);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() is failed(%d)", ret);
- } else if (!strncmp(p, "HOURLY", strlen("HOURLY"))) {
- freq = CALENDAR_RECURRENCE_NONE;
+ int len = g_strv_length(t);
+ int i;
+ int index = 0;
+ for (i = 0; i < len; i++) {
+ if (index) index++;
+ if (NULL == t[i] || '\0' == *t[i]) continue;
- } else if (!strncmp(p, "MINUTELY", strlen("MINUTELY"))) {
- freq = CALENDAR_RECURRENCE_NONE;
+ if ('0' <= *t[i] && *t[i] <= '9' && strlen(t[i]) > strlen("PTM")) { // runTime
+ index = 1;
+ calendar_time_s caltime = {0};
+ __get_caltime(t[i], &caltime, ud);
+ ret = _cal_record_set_caltime(alarm, _calendar_alarm.alarm_time, caltime);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_caltime() is failed(%d)", ret);
+ ret = _cal_record_set_int(alarm, _calendar_alarm.tick_unit, CALENDAR_ALARM_TIME_UNIT_SPECIFIC);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() is failed(%d)", ret);
- } else if (!strncmp(p, "SECONDLY", strlen("SECONDLY"))) {
- freq = CALENDAR_RECURRENCE_NONE;
+ } else if (4 == index) { // displayString
+ DBG("displayString [%s]", t[i]);
+ ret = _cal_record_set_str(alarm, _calendar_alarm.summary, t[i]);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() is failed(%d)", ret);
- } else {
- freq = CALENDAR_RECURRENCE_NONE;
+ } else { // TYPE, VALUE
+ }
}
- ret = _cal_record_set_int(event, _calendar_event.freq, freq);
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_vcalendar_parse_until(calendar_record_h event, void *data)
-{
- int ret;
- calendar_time_s stime;
- calendar_time_s until;
- int y, mon, d, h, min, s;
- char *tzid;
- char t, z;
- char *p = (char *)data;
-
- /* until value type has the same value as the dtstart */
- ret = _cal_record_set_int(event, _calendar_event.range_type, CALENDAR_RANGE_UNTIL);
- ret = calendar_record_get_str_p(event, _calendar_event.start_tzid, &tzid);
- ret = calendar_record_get_caltime(event, _calendar_event.start_time, &stime);
- until.type = stime.type;
+ if (0 == index) {
+ DBG("No alarm");
+ calendar_record_destroy(alarm, true);
+ g_strfreev(t);
+ return;
+ }
- switch (stime.type)
+ switch (ud->type)
{
- case CALENDAR_TIME_UTIME:
- until.time.utime = _cal_time_convert_stol(tzid, p);
+ case VCALENDAR_TYPE_VEVENT:
+ ret = calendar_record_add_child_record(record, _calendar_event.calendar_alarm, alarm);
+ warn_if (CALENDAR_ERROR_NONE != ret, "calendar_record_add_child_record() is failed(%d)", ret);
break;
-
- case CALENDAR_TIME_LOCALTIME:
- sscanf(p, "%4d%2d%2d%c%2d%2d%2d%c", &y, &mon, &d, &t, &h, &min, &s, &z);
- until.time.date.year = y;
- until.time.date.month = mon;
- until.time.date.mday = d;
-
+ case VCALENDAR_TYPE_VTODO:
+ ret = calendar_record_add_child_record(record, _calendar_todo.calendar_alarm, alarm);
+ warn_if (CALENDAR_ERROR_NONE != ret, "calendar_record_add_child_record() is failed(%d)", ret);
break;
}
- ret = _cal_record_set_caltime(event, _calendar_event.until_time, until);
-
- return CALENDAR_ERROR_NONE;
+ g_strfreev(t);
}
-static int __cal_vcalendar_parse_count(calendar_record_h event, void *data)
+/*
+ * for ver 1.0
+ * malarmparts = 0*4(strnosemi ";") strnosemi; runTime, snoozeTime, repeatCount, addressString, noteString
+ */
+static void __work_component_property_malarm(char *value, calendar_record_h record, struct user_data *ud)
{
- int ret;
- int c;
- char *p = (char *)data;
+ // diff with aalarm: action
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+ retm_if (NULL == ud, "Invalid parameter: ud is NULL");
- DBG("%s\n", (char *)data);
- ret = _cal_record_set_int(event, _calendar_event.range_type, CALENDAR_RANGE_COUNT);
- c = atoi(p);
- ret = _cal_record_set_int(event, _calendar_event.count, c < 0 ? 0 : c);
- return ret;
-}
+ int ret = 0;
+ char **t = NULL;
+ t = g_strsplit_set(value, ";:", -1);
+ retm_if (NULL == t, "g_strsplit_set() is failed");
-static int __cal_vcalendar_parse_interval(calendar_record_h event, void *data)
-{
- DBG("%s\n", (char *)data);
- int c;
- char *p = (char *)data;
+ calendar_record_h alarm = NULL;
+ ret = calendar_record_create(_calendar_alarm._uri, &alarm);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("calendar_record_create() is failed(%d)", ret);
+ g_strfreev(t);
+ return;
+ }
+ ret = _cal_record_set_int(alarm, _calendar_alarm.action, CALENDAR_ALARM_ACTION_EMAIL);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() is failed(%d)", ret);
- c = atoi(p);
- return _cal_record_set_int(event, _calendar_event.interval, c < 0 ? 0 : c);
-}
+ int len = g_strv_length(t);
+ int i;
+ int index = 0;
+ for (i = 0; i < len; i++) {
+ if (index) index++;
+ if (NULL == t[i] || '\0' == *t[i]) continue;
-static int __cal_vcalendar_parse_bysecond(calendar_record_h event, void *data)
-{
- DBG("%s\n", (char *)data);
- return _cal_record_set_str(event, _calendar_event.bysecond, (char *)data);
-}
+ if ('0' <= *t[i] && *t[i] <= '9' && strlen(t[i]) > strlen("PTM")) { // runTime
+ index = 1;
+ calendar_time_s caltime = {0};
+ __get_caltime(t[i], &caltime, ud);
+ ret = _cal_record_set_caltime(alarm, _calendar_alarm.alarm_time, caltime);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_caltime() is failed(%d)", ret);
+ ret = _cal_record_set_int(alarm, _calendar_alarm.tick_unit, CALENDAR_ALARM_TIME_UNIT_SPECIFIC);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() is failed(%d)", ret);
-static int __cal_vcalendar_parse_byminute(calendar_record_h event, void *data)
-{
- DBG("%s\n", (char *)data);
- return _cal_record_set_str(event, _calendar_event.byminute, (char *)data);
-}
+ } else if (4 == index) { // addressString
+ DBG("addressString [%s]", t[i]);
+ ret = _cal_record_set_str(alarm, _calendar_alarm.attach, t[i]);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() is failed(%d)", ret);
-static int __cal_vcalendar_parse_byhour(calendar_record_h event, void *data)
-{
- DBG("%s\n", (char *)data);
- return _cal_record_set_str(event, _calendar_event.byhour, (char *)data);
-}
+ } else if (5 == index) { // noteString
+ DBG("noteString [%s]", t[i]);
+ ret = _cal_record_set_str(alarm, _calendar_alarm.description, t[i]);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() is failed(%d)", ret);
-static int __cal_vcalendar_parse_byday(calendar_record_h event, void *data)
-{
- DBG("%s\n", (char *)data);
- return _cal_record_set_str(event, _calendar_event.byday, (char *)data);
-}
+ } else { // TYPE, VALUE
-static int __cal_vcalendar_parse_bymonthday(calendar_record_h event, void *data)
-{
- DBG("%s\n", (char *)data);
- return _cal_record_set_str(event, _calendar_event.bymonthday, (char *)data);
-}
+ }
+ }
-static int __cal_vcalendar_parse_byyearday(calendar_record_h event, void *data)
-{
- DBG("%s\n", (char *)data);
- return _cal_record_set_str(event, _calendar_event.byyearday, (char *)data);
-}
+ if (0 == index) {
+ DBG("No alarm");
+ calendar_record_destroy(alarm, true);
+ g_strfreev(t);
+ return;
+ }
-static int __cal_vcalendar_parse_byweekno(calendar_record_h event, void *data)
-{
- DBG("%s\n", (char *)data);
- return _cal_record_set_str(event, _calendar_event.byweekno, (char *)data);
+ switch (ud->type)
+ {
+ case VCALENDAR_TYPE_VEVENT:
+ ret = calendar_record_add_child_record(record, _calendar_event.calendar_alarm, alarm);
+ warn_if (CALENDAR_ERROR_NONE != ret, "calendar_record_add_child_record() is failed(%d)", ret);
+ break;
+ case VCALENDAR_TYPE_VTODO:
+ ret = calendar_record_add_child_record(record, _calendar_todo.calendar_alarm, alarm);
+ warn_if (CALENDAR_ERROR_NONE != ret, "calendar_record_add_child_record() is failed(%d)", ret);
+ break;
+ }
+ g_strfreev(t);
}
-
-static int __cal_vcalendar_parse_bymonth(calendar_record_h event, void *data)
+/*
+ * for ver 1.0
+ * aalarmparts = 0*3(strnosemi ";") strnosemi; runTime, snoozeTime, repeatCount, audioContent
+ * AALARM;TYPE=WAVE;VALUE=URL:19960415T235959; ; ; file:///mmedia/taps.wav
+ * AALARM;TYPE=WAVE;VALUE=CONTENT-ID:19960903T060000;PT15M;4;<jsmith.part2.=960901T083000.xyzMail@host1.com>
+ */
+static void __work_component_property_aalarm(char *value, calendar_record_h record, struct user_data *ud)
{
- DBG("%s\n", (char *)data);
- return _cal_record_set_str(event, _calendar_event.bymonth, (char *)data);
-}
+ ENTER();
-static int __cal_vcalendar_parse_bysetpos(calendar_record_h event, void *data)
-{
- DBG("%s\n", (char *)data);
- return _cal_record_set_str(event, _calendar_event.bysetpos, (char *)data);
-}
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+ retm_if (NULL == ud, "Invalid parameter: ud is NULL");
-static int __cal_vcalendar_parse_wkst(calendar_record_h event, void *data)
-{
- DBG("%s\n", (char *)data);
- int wkst;
- char *p = (char *)data;
+ int ret = 0;
+ char **t = NULL;
+ t = g_strsplit_set(value, ";:", -1);
+ retm_if (NULL == t, "g_strsplit_set() is failed");
- if (!strncmp(p, "SU", strlen("SU"))) {
- wkst = CALENDAR_SUNDAY;
+ calendar_record_h alarm = NULL;
+ ret = calendar_record_create(_calendar_alarm._uri, &alarm);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("calendar_record_create() is failed(%d)", ret);
+ g_strfreev(t);
+ return;
+ }
+ ret = _cal_record_set_int(alarm, _calendar_alarm.action, CALENDAR_ALARM_ACTION_AUDIO);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() is failed(%d)", ret);
- } else if (!strncmp(p, "MO", strlen("MO"))) {
- wkst = CALENDAR_MONDAY;
+ int len = g_strv_length(t);
+ int i;
+ int index = 0;
+ for (i = 0; i < len; i++) {
+ if (index) index++;
+ if (NULL == t[i] || '\0' == *t[i]) continue;
+
+ if ('0' <= *t[i] && *t[i] <= '9' && strlen(t[i]) > strlen("PTM")) { // runTime
+ index = 1;
+ calendar_time_s caltime = {0};
+ __get_caltime(t[i], &caltime, ud);
+ ret = _cal_record_set_caltime(alarm, _calendar_alarm.alarm_time, caltime);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_caltime() is failed(%d)", ret);
+ ret = _cal_record_set_int(alarm, _calendar_alarm.tick_unit, CALENDAR_ALARM_TIME_UNIT_SPECIFIC);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() is failed(%d)", ret);
+ } else if (4 == index) { //audioContent
+ DBG("Content [%s]", t[i]);
+ ret = _cal_record_set_str(alarm, _calendar_alarm.attach, t[i]);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() is failed(%d)", ret);
+ } else { // TYPE, VALUE
+ }
+ }
+
+ if (0 == index) {
+ DBG("No alarm");
+ calendar_record_destroy(alarm, true);
+ g_strfreev(t);
+ return;
+ }
- } else if (!strncmp(p, "TU", strlen("TU"))) {
- wkst = CALENDAR_TUESDAY;
+ switch (ud->type)
+ {
+ case VCALENDAR_TYPE_VEVENT:
+ ret = calendar_record_add_child_record(record, _calendar_event.calendar_alarm, alarm);
+ warn_if (CALENDAR_ERROR_NONE != ret, "calendar_record_add_child_record() is failed(%d)", ret);
+ break;
+ case VCALENDAR_TYPE_VTODO:
+ ret = calendar_record_add_child_record(record, _calendar_todo.calendar_alarm, alarm);
+ warn_if (CALENDAR_ERROR_NONE != ret, "calendar_record_add_child_record() is failed(%d)", ret);
+ break;
+ }
+ g_strfreev(t);
+}
- } else if (!strncmp(p, "WE", strlen("WE"))) {
- wkst = CALENDAR_WEDNESDAY;
+static void __work_component_property_exdate(char *value, calendar_record_h record, struct user_data *ud)
+{
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+ retm_if (NULL == ud, "Invalid parameter: ud is NULL");
- } else if (!strncmp(p, "TH", strlen("TH"))) {
- wkst = CALENDAR_THURSDAY;
+ int ret = 0;
+ switch (ud->type)
+ {
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = _cal_record_set_str(record, _calendar_event.exdate, value + 1);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() Failed(%d)", ret);
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ERR("No exdate in todo");
+ break;
+ }
+}
- } else if (!strncmp(p, "FR", strlen("FR"))) {
- wkst = CALENDAR_FRIDAY;
+static void __work_component_property_x_allday(char *value, calendar_record_h record, struct user_data *ud)
+{
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+ retm_if (NULL == ud, "Invalid parameter: ud is NULL");
- } else if (!strncmp(p, "SA", strlen("SA"))) {
- wkst = CALENDAR_SATURDAY;
+ int ret = 0;
+ if (!strncmp(value, ":SET", strlen(":SET"))) {
+ DBG("x-allday: set");
+ ud->is_allday = true;
- } else {
- wkst = -1;
+ calendar_time_s caltime = {0};
+ switch (ud->type)
+ {
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = calendar_record_get_caltime(record, _calendar_event.start_time, &caltime);
+ warn_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_caltime() is failed");
+ if (CALENDAR_TIME_LOCALTIME == caltime.type) {
+ caltime.time.date.hour = 0;
+ caltime.time.date.minute = 0;
+ caltime.time.date.second = 0;
+ ret = _cal_record_set_caltime(record, _calendar_event.start_time, caltime);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_caltime() is failed");
+ }
+ ret = calendar_record_get_caltime(record, _calendar_event.end_time, &caltime);
+ warn_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_caltime() is failed");
+ if (CALENDAR_TIME_LOCALTIME == caltime.type) {
+ caltime.time.date.hour = 0;
+ caltime.time.date.minute = 0;
+ caltime.time.date.second = 0;
+ ret = _cal_record_set_caltime(record, _calendar_event.end_time, caltime);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_caltime() is failed");
+ }
+ ret = calendar_record_get_caltime(record, _calendar_event.until_time, &caltime);
+ warn_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_caltime() is failed");
+ if (CALENDAR_TIME_LOCALTIME == caltime.type) {
+ caltime.time.date.hour = 0;
+ caltime.time.date.minute = 0;
+ caltime.time.date.second = 0;
+ ret = _cal_record_set_caltime(record, _calendar_event.until_time, caltime);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_caltime() is failed");
+ }
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = calendar_record_get_caltime(record, _calendar_todo.start_time, &caltime);
+ warn_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_caltime() is failed");
+ if (CALENDAR_TIME_LOCALTIME == caltime.type) {
+ caltime.time.date.hour = 0;
+ caltime.time.date.minute = 0;
+ caltime.time.date.second = 0;
+ ret = _cal_record_set_caltime(record, _calendar_todo.start_time, caltime);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_caltime() is failed");
+ }
+ ret = calendar_record_get_caltime(record, _calendar_todo.due_time, &caltime);
+ warn_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_caltime() is failed");
+ if (CALENDAR_TIME_LOCALTIME == caltime.type) {
+ caltime.time.date.hour = 0;
+ caltime.time.date.minute = 0;
+ caltime.time.date.second = 0;
+ ret = _cal_record_set_caltime(record, _calendar_todo.due_time, caltime);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_caltime() is failed");
+ }
+ break;
+ }
}
- return _cal_record_set_int(event, _calendar_event.wkst, wkst);
}
-static int __get_tick_unit(char *p, int *tick, int *unit)
+static void __work_component_property_x_lunar(char *value, calendar_record_h record, struct user_data *ud)
{
- int d, c, i = 0; /* direct, const, i */
- int t, u; /* tick, unit */
- char buf[8] = {0};
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+ retm_if (NULL == ud, "Invalid parameter: ud is NULL");
- t = 0;
- c = 0;
- u = CAL_SCH_TIME_UNIT_OFF;
- while (*p != '\0' && *p != '\n') {
- switch (*p) {
- case '+':
- d = 1;
- break;
- case '-':
- d = -1;
- break;
- case 'P':
- i = 0;
- break;
- case 'T':
- break;
- case 'W':
- c = atoi(buf);
- DBG("W tick(%d)", c);
- if (c == 0) break;
- u = CALENDAR_ALARM_TIME_UNIT_WEEK;
- t += c;
- i = 0;
- break;
- case 'D':
- c = atoi(buf);
- DBG("D tick(%d)", c);
- if (c == 0) break;
- u = CALENDAR_ALARM_TIME_UNIT_DAY;
- t += c;
- i = 0;
- break;
- case 'H':
- c = atoi(buf);
- DBG("H tick(%d)", c);
- if (c == 0) break;
- u = CALENDAR_ALARM_TIME_UNIT_HOUR;
- t += c;
- i = 0;
- break;
- case 'M':
- c = atoi(buf);
- DBG("M tick(%d)", c);
- if (c == 0) break;
- u = CALENDAR_ALARM_TIME_UNIT_MINUTE;
- t += c;
- i = 0;
- break;
- case 'S':
- i = 0;
+ int ret = 0;
+ if (!strncmp(value, ":SET", strlen(":SET"))) {
+ DBG("x-lunar: set");
+ switch (ud->type)
+ {
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = _cal_record_set_int(record, _calendar_event.calendar_system_type, CALENDAR_SYSTEM_EAST_ASIAN_LUNISOLAR);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
break;
- default:
- buf[i] = *p;
- i++;
+ case CALENDAR_BOOK_TYPE_TODO:
+ DBG("Not supported lunar in todo");
break;
}
- p++;
}
- if (t != c) {
- u = CALENDAR_ALARM_TIME_UNIT_SPECIFIC;
- }
- *tick = t;
- *unit = u;
- DBG("get tic(%d) unit(%d)", t, u);
-
- return CALENDAR_ERROR_NONE;
}
-static int __cal_vcalendar_parse_trig_related(calendar_record_h alarm, void *data)
+// valarm
+static void __work_component_property_valarm_action(char *value, calendar_record_h alarm, struct user_data *ud)
{
- DBG("%s\n", (char *)data);
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == alarm, "Invalid parameter: record is NULL");
- int tick = 0, unit;
- char *p = (char *)data;
+ const char *prop[CALENDAR_ALARM_ACTION_MAX] = {":AUDIO", ":DISPLAY", ":EMAIL"};
- if (p == NULL) {
- return -1;
+ int ret = 0;
+ int i;
+ for (i = 0; i < CALENDAR_ALARM_ACTION_MAX; i++) {
+ if (!strncmp(value, prop[i], strlen(prop[i]))) {
+ ret = _cal_record_set_int(alarm, _calendar_alarm.action, i);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ break;
+ }
}
+}
- if (!strncmp(p, "START", strlen("START") + 1)) {
- p += strlen("START") + 1;
- DBG("related start and value[%s]", p);
+static void __work_component_property_valarm_trigger(char *value, calendar_record_h record, calendar_record_h alarm, struct user_data *ud)
+{
+ ENTER();
- } else if (!strncmp(p, "END", strlen("END") +1)) {
- p += strlen("END") + 1;
- DBG("related end and value[%s]", p);
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == alarm, "Invalid parameter: record is NULL");
+ retm_if (NULL == ud, "Invalid parameter: ud is NULL");
- } else {
- DBG("no related and value[%s]", p);
+ int ret = 0;
+ char **t = NULL;
+ t = g_strsplit_set(value, ";:", -1);
+ retm_if (NULL == t, "g_strsplit_set() is failed");
+ int related = VCAL_RELATED_NONE;
+ // start
+ int len = g_strv_length(t);
+ int i;
+ for (i = 0; i < len; i++) {
+ if (NULL == t[i] || '\0' == *t[i]) continue;
+
+ if (!strncmp(t[i], "RELATED", strlen("RELATED"))) {
+ if (!strncmp(t[i] + strlen("RELATED"), "=START", strlen("=START")))
+ related = VCAL_RELATED_START;
+ else if (!strncmp(t[i] + strlen("RELATED"), "=END", strlen("=END")))
+ related = VCAL_RELATED_END;
+ else
+ ERR("Invalid related:[%s]", t[i]);
+ } else if (!strncmp(t[i], "VALUE", strlen("VALUE"))) {
+ // do nothing
+ } else {
+ if ('0' <= *t[i] && *t[i] <= '9' && strlen(t[i]) >= strlen("YYYYDDMM")) {
+ calendar_time_s caltime = {0};
+ __get_caltime(t[i], &caltime, ud);
+ ret = _cal_record_set_caltime(alarm, _calendar_alarm.alarm_time, caltime);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_caltime() is failed(%d)", ret);
+ ret = _cal_record_set_int(alarm, _calendar_alarm.tick_unit, CALENDAR_ALARM_TIME_UNIT_SPECIFIC);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() is failed(%d)", ret);
+ } else {
+ int unit = 0;
+ int tick = 0;
+ __decode_duration(t[i], strlen(t[i]), &tick, &unit);
+ if (CALENDAR_ALARM_TIME_UNIT_SPECIFIC == unit || tick > 0) {
+ if (CALENDAR_ALARM_TIME_UNIT_SPECIFIC == unit) DBG("alarm tick is second, changed as specific.");
+ if (tick > 0) DBG("alarm is set after start/end time(%d).", tick);
+
+ calendar_time_s caltime = {0};
+ if (VCAL_RELATED_NONE == related) {
+ switch (ud->type)
+ {
+ case CALENDAR_BOOK_TYPE_EVENT:
+ related = VCAL_RELATED_START;
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ related = VCAL_RELATED_END;
+ break;
+ }
+ }
+ switch (related)
+ {
+ case VCAL_RELATED_START:
+ ret = calendar_record_get_caltime(record, _calendar_event.start_time, &caltime);
+ warn_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_caltime() is failed(%d)", ret);
+ _cal_time_modify_caltime(&caltime, tick * unit);
+ ret = _cal_record_set_caltime(record, _calendar_event.start_time, caltime);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_caltime() is failed(%d)", ret);
+ break;
+ case VCAL_RELATED_END:
+ ret = calendar_record_get_caltime(record, _calendar_event.end_time, &caltime);
+ warn_if (CALENDAR_ERROR_NONE != ret, "calendar_record_get_caltime() is failed(%d)", ret);
+ _cal_time_modify_caltime(&caltime, tick * unit);
+ ret = _cal_record_set_caltime(record, _calendar_event.end_time, caltime);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_caltime() is failed(%d)", ret);
+ break;
+ }
+ ret = _cal_record_set_int(alarm, _calendar_alarm.tick_unit, CALENDAR_ALARM_TIME_UNIT_SPECIFIC);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() is failed(%d)", ret);
+ } else {
+ ret = _cal_record_set_int(alarm, _calendar_alarm.tick, (-1 * tick));
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() is failed(%d)", ret);
+ ret = _cal_record_set_int(alarm, _calendar_alarm.tick_unit, unit);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() is failed(%d)", ret);
+ }
+ }
+ }
}
- __get_tick_unit(p, &tick, &unit);
- _cal_record_set_int(alarm, _calendar_alarm.tick, tick);
- _cal_record_set_int(alarm, _calendar_alarm.tick_unit, unit);
+ // end
- return CALENDAR_ERROR_NONE;
+ g_strfreev(t);
}
-long long int _get_utime_from_datetime(char *tzid, char *p)
+static void __work_component_property_valarm_repeat(char *value, calendar_record_h alarm, struct user_data *ud)
{
- int y, mon, d, h, min, s;
- int len;
- char t, z;
- if (p == NULL) {
- return -1;
- }
- len = strlen(p);
- if (len < strlen("YYYYMMDDTHHMMSS")) {
- return -1;
- }
+ return;
+}
- sscanf(p, "%04d%02d%02d%c%02d%02d%02d%c",
- &y, &mon, &d, &t, &h, &min, &s, &z);
+static void __work_component_property_valarm_attach(char *value, calendar_record_h alarm, struct user_data *ud)
+{
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == alarm, "Invalid parameter: record is NULL");
- return _cal_time_convert_itol(tzid, y, mon, d, h, min, s);
+ int ret = _cal_record_set_str(alarm, _calendar_alarm.attach, value + 1);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() Failed(%d)", ret);
}
-static int __cal_vcalendar_parse_trig_value(calendar_record_h alarm, void *data)
+static void __work_component_property_valarm_description(char *value, calendar_record_h alarm, struct user_data *ud)
{
- DBG("%s\n", (char *)data);
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == alarm, "Invalid parameter: record is NULL");
- int ret;
- char *p = (char *)data;
+ int ret = _cal_record_set_str(alarm, _calendar_alarm.description, value + 1);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() Failed(%d)", ret);
+}
- if (!strncmp(p, "DATE-TIME", strlen("DATE-TIME") + 1)) {
- p += strlen("DATE-TIME") + 1;
- ret = _cal_record_set_int(alarm, _calendar_alarm.tick_unit, CALENDAR_ALARM_TIME_UNIT_SPECIFIC);
- ret = _cal_record_set_lli(alarm, _calendar_alarm.time, _cal_time_convert_stol(NULL, p));
- } else {
+static void __work_component_property_valarm_summary(char *value, calendar_record_h alarm, struct user_data *ud)
+{
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == alarm, "Invalid parameter: record is NULL");
- }
- return CALENDAR_ERROR_NONE;
+ int ret = _cal_record_set_str(alarm, _calendar_alarm.summary, value);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() Failed(%d)", ret);
}
-static int __cal_vcalendar_parse_charset(int *val, void *data)
+static void __work_component_property_valarm_duration(char *value, calendar_record_h alarm, struct user_data *ud)
{
- DBG("%s\n", (char *)data);
- return CALENDAR_ERROR_NONE;
+ return;
}
-static int __cal_vcalendar_parse_encoding(int *val, void *data)
+static char* __work_component_property_begin(char *cursor, calendar_record_h record, struct user_data *ud)
{
- char *p = (char *)data;
- *val = 0;
+ ENTER();
- if (!strncmp(p, "BASE64", strlen("BASE64"))) {
- DBG("ENCODE_BASE64");
- *val = ENCODE_BASE64;
-
- } else if (!strncmp(p, "QUOTED-PRINTABLE", strlen("QUOTED-PRINTABLE"))){
- DBG("ENCODE_QUOTED_PRINTABLE");
- *val = ENCODE_QUOTED_PRINTABLE;
+ retvm_if (NULL == cursor, NULL, "Invalid parameter: cursor is NULL");
+ retvm_if (NULL == record, NULL, "Invalid parameter: record is NULL");
+ retvm_if (NULL == ud, NULL, "Invalid parameter: user_data is NULL");
+ if (0 != strncmp(cursor, ":VALARM", strlen(":VALARM"))) {
+ DBG("this is not valarm");
+ return __crlf(cursor);
}
- return CALENDAR_ERROR_NONE;
-}
-
-// end parse func////////////////////////////////////////////////////////////////
-char *_cal_vcalendar_parse_vevent(int type, calendar_list_h *list_sch, void *data)
-{
- DBG("[%s]", __func__);
- int i;
- int ret;
- char *prop = NULL, *cont = NULL;
- char *cursor = (char *)data;
- calendar_record_h event = NULL;
+ __init_component_property_valarm();
- ret = calendar_record_create(_calendar_event._uri, &event);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_create() failed");
- return NULL;
- }
+ int ret = 0;
+ calendar_record_h alarm = NULL;
+ ret = calendar_record_create(_calendar_alarm._uri, &alarm);
+ retvm_if (CALENDAR_ERROR_NONE != ret, NULL, "calendar_record_create() is failed(%d)", ret);
- while ((cursor = _cal_vcalendar_parse_read_line(cursor, &prop, &cont))) {
- if (!strncmp(cont + 1, "VALARM", strlen("VALARM"))) {
- if (!strncmp(cont + 1, "VALARM", strlen("VALARM"))) {
- cursor = _cal_vcalendar_parse_valarm(VCALENDAR_TYPE_VEVENT, event, cursor);
- } else {
- break;
- }
+ cursor = __crlf(cursor); // crlf: BEGIN:VALARM
+ bool exit_loop = false;
+ while (cursor) {
+ int index = 0;
+ cursor = __get_index(cursor, component_property_valarm, VCAL_COMPONENT_PROPERTY_VALARM_MAX, &index);
- } else if (!strncmp(prop, "END", strlen("END"))) {
+ char *value = NULL;
+ switch (index)
+ {
+ case VCAL_COMPONENT_PROPERTY_VALARM_ACTION:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_valarm_action(value, alarm, ud);
+ free(value);
+ value = NULL;
break;
- } else {
- for (i = 0; i < VEVE_MAX; i++) {
- if (!strncmp(prop, _vevent_funcs[i].prop, strlen(_vevent_funcs[i].prop))) {
- _vevent_funcs[i].func(type, *list_sch, event, prop, cont);
- break;
- }
- }
- }
-
- CAL_FREE(prop);
- CAL_FREE(cont);
- }
-
- CAL_FREE(prop);
- CAL_FREE(cont);
-
- DBG("event add to the list");
- ret = calendar_list_add(*list_sch, event);
+ case VCAL_COMPONENT_PROPERTY_VALARM_TRIGGER:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_valarm_trigger(value, record, alarm, ud);
+ free(value);
+ value = NULL;
+ break;
- return cursor;
-}
+ case VCAL_COMPONENT_PROPERTY_VALARM_REPEAT:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_valarm_repeat(value, alarm, ud);
+ free(value);
+ value = NULL;
+ break;
-char *_cal_vcalendar_parse_vtodo(int type, calendar_list_h *list_sch, void *data)
-{
- int i;
- int ret;
- char *prop = NULL, *cont = NULL;
- char *cursor = (char *)data;
- calendar_record_h todo = NULL;
+ case VCAL_COMPONENT_PROPERTY_VALARM_ATTACH:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_valarm_attach(value, alarm, ud);
+ free(value);
+ value = NULL;
+ break;
- ret = calendar_record_create(_calendar_todo._uri, &todo);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_create() failed");
- return NULL;
- }
+ case VCAL_COMPONENT_PROPERTY_VALARM_DESCRIPTION:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_valarm_description(value, alarm, ud);
+ free(value);
+ value = NULL;
+ break;
- /* do until meet BEGIN */
- while ((cursor = _cal_vcalendar_parse_read_line(cursor, &prop, &cont))) {
- if (!strncmp(prop, "BEGIN", strlen("BEGIN"))) {
+ case VCAL_COMPONENT_PROPERTY_VALARM_SUMMARY:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_valarm_summary(value, alarm, ud);
+ free(value);
+ value = NULL;
+ break;
- if (!strncmp(cont + 1, "VALARM", strlen("VALARM"))) {
- cursor = _cal_vcalendar_parse_valarm(VCALENDAR_TYPE_VTODO, todo, cursor);
- } else {
- break;
- }
+ case VCAL_COMPONENT_PROPERTY_VALARM_DURATION:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_valarm_duration(value, alarm, ud);
+ free(value);
+ value = NULL;
+ break;
- } else if (!strncmp(prop, "END", strlen("END"))) {
+ case VCAL_COMPONENT_PROPERTY_VALARM_END:
+ DBG("exit valarm");
+ exit_loop = true;
break;
- } else {
- for (i = 0; i < VTODO_MAX; i++) {
- if (!strncmp(prop, _vtodo_funcs[i].prop, strlen(_vtodo_funcs[i].prop))) {
- _vtodo_funcs[i].func(type, *list_sch, todo, prop, cont);
- break;
- }
- }
+ default:
+ ERR("Invalid index(%d)", index);
+ cursor = __crlf(cursor);
+ break;
}
- CAL_FREE(prop);
- CAL_FREE(cont);
+ if (true == exit_loop) break;
}
- CAL_FREE(prop);
- CAL_FREE(cont);
-
- ret = calendar_list_add(*list_sch, todo);
+ switch (ud->type)
+ {
+ case VCALENDAR_TYPE_VEVENT:
+ ret = calendar_record_add_child_record(record, _calendar_event.calendar_alarm, alarm);
+ break;
+ case VCALENDAR_TYPE_VTODO:
+ ret = calendar_record_add_child_record(record, _calendar_todo.calendar_alarm, alarm);
+ break;
+ }
+ retvm_if (CALENDAR_ERROR_NONE != ret, NULL, "calendar_record_add_child_record() is failed(%d)", ret);
+ return cursor;
+}
+static char* __work_component_vevent(char *cursor, calendar_record_h record, struct user_data *ud)
+{
+ retvm_if (NULL == cursor, NULL, "Invalid parameter: cursor is NULL");
+ retvm_if (NULL == record, NULL, "Invalid parameter: record is NULL");
+
+ bool exit_loop = false;
+ while (cursor) {
+ int index = 0;
+ cursor = __get_index(cursor, component_property, VCAL_COMPONENT_PROPERTY_MAX, &index);
+
+ char *value = NULL;
+ switch (index)
+ {
+ case VCAL_COMPONENT_PROPERTY_DTSTAMP:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_dtstamp(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_UID:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_uid(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_RECURRENCE_ID:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_recurrence_id(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_DTSTART:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_dtstart(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_CREATED:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_created(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_DCREATED:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_created(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_DESCRIPTION:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_description(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_LAST_MODIFIED:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_last_modified(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_LOCATION:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_location(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_PRIORITY:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_priority(value + 1, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_STATUS:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_status(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_SUMMARY:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_summary(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_RRULE:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_rrule(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_DTEND:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_dtend(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_DUE:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_dtend(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_ATTENDEE:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_attendee(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_CATEGORIES:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_categories(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_DALARM:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_dalarm(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_MALARM:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_malarm(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_AALARM:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_aalarm(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_EXDATE:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_exdate(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_X_ALLDAY:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_x_allday(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_X_LUNAR:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_x_lunar(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_BEGIN:
+ cursor = __work_component_property_begin(cursor, record, ud);
+ if (NULL == cursor)
+ cursor = __crlf(cursor);
+ break;
+ case VCAL_COMPONENT_PROPERTY_END:
+ DBG("exit record");
+ cursor = __crlf(cursor);
+ exit_loop = true;
+ break;
+ case VCAL_COMPONENT_PROPERTY_EXTENDED:
+ cursor = __get_value(cursor, &value);
+ free(value);
+ value = NULL;
+ break;
+ default:
+ cursor = __crlf(cursor);
+ break;
+ }
+ if (true == exit_loop) break;
+ }
return cursor;
}
-char *_cal_vcalendar_parse_valarm(int type, calendar_record_h record, void *data)
+static char* __work_component_vjournal(char *cursor, calendar_record_h record, struct user_data *ud)
{
- int ret;
- int i;
- char *prop = NULL, *cont = NULL;
- char *cursor = (char *)data;
- calendar_record_h alarm = NULL;
+ retvm_if (NULL == cursor, NULL, "Invalid parameter: cursor is NULL");
- ret = calendar_record_create(_calendar_alarm._uri, &alarm);
+ DBG("Not supported vjournal");
- while ((cursor = _cal_vcalendar_parse_read_line(cursor, &prop, &cont))) {
- if (!strncmp(prop, "BEGIN", strlen("BEGIN"))) {
+ bool exit_loop = false;
+ while (cursor) {
+ int index = 0;
+ cursor = __get_index(cursor, component_property, VCAL_COMPONENT_PROPERTY_MAX, &index);
+ switch (index)
+ {
+ case VCAL_COMPONENT_PROPERTY_END:
+ DBG("exit record");
+ cursor = __crlf(cursor);
+ exit_loop = true;
break;
- } else if (!strncmp(prop, "END", strlen("END"))) {
+ default:
+ cursor = __crlf(cursor);
break;
-
- }
-
- for (i = 0; i < VALA_MAX; i++) {
- if (!strncmp(prop, _valarm_funcs[i].prop, strlen(_valarm_funcs[i].prop))) {
- _valarm_funcs[i].func(alarm, cont);
- break;
- }
}
- CAL_FREE(prop);
- CAL_FREE(cont);
+ if (true == exit_loop) break;
}
+ return cursor;
+}
- switch (type) {
- case VCALENDAR_TYPE_VEVENT:
- ret = calendar_record_add_child_record(record, _calendar_event.calendar_alarm, alarm);
- break;
- case VCALENDAR_TYPE_VTODO:
- ret = calendar_record_add_child_record(record, _calendar_todo.calendar_alarm, alarm);
- break;
- }
+static char* __work_component_vfreebusy(char *cursor, calendar_record_h record, struct user_data *ud)
+{
+ retvm_if (NULL == cursor, NULL, "Invalid parameter: cursor is NULL");
- CAL_FREE(prop);
- CAL_FREE(cont);
+ DBG("Not supported vfreebusy");
+ bool exit_loop = false;
+ while (cursor) {
+ int index = 0;
+ cursor = __get_index(cursor, component_property, VCAL_COMPONENT_PROPERTY_MAX, &index);
+ switch (index)
+ {
+ case VCAL_COMPONENT_PROPERTY_END:
+ DBG("exit record");
+ cursor = __crlf(cursor);
+ exit_loop = true;
+ break;
+
+ default:
+ cursor = __crlf(cursor);
+ break;
+ }
+ if (true == exit_loop) break;
+ }
return cursor;
}
-/*
- * parse vtimezone
- */
-enum {
- VTIMEZONE_STD_DTSTART = 0x0,
- VTIMEZONE_STD_TZOFFSETFROM,
- VTIMEZONE_STD_TZOFFSETTO,
- VTIMEZONE_STD_MAX,
-};
-
-static int __cal_vcalendar_parse_vtimezone_std_dtstart(calendar_record_h timezone, void *data)
+static void __work_component_property_vtimezone_standard_dtstart(char *value, calendar_record_h record, struct user_data *ud)
{
- int y, mon, d, h, min, s;
- int nth = 0, wday = 0;
- long long int utime;
- char t, z;
- char *p = (char *)data;
+ ENTER();
- if (NULL == timezone)
- {
- ERR("Invalid parameter");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- sscanf(p +1, "%04d%02d%02d%c%02d%02d%02d%c", &y, &mon, &d, &t, &h, &min, &s, &z);
- utime = _cal_time_convert_itol(NULL, y, mon, d, h, min, s);
- _cal_time_ltoi2(NULL, utime, &nth, &wday);
- DBG("timezone dtstart(%04d-%02d-%02d %02d:%02d:%02d", y, mon, d, h, min, s);
- DBG("timezone day of week(%d/%d)", nth, wday);
- _cal_record_set_int(timezone, _calendar_timezone.standard_start_month, mon);
- _cal_record_set_int(timezone, _calendar_timezone.standard_start_position_of_week, nth);
- _cal_record_set_int(timezone, _calendar_timezone.standard_start_day, wday);
- _cal_record_set_int(timezone, _calendar_timezone.standard_start_hour, h);
- return CALENDAR_ERROR_NONE;
-}
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
-static int __cal_vcalendar_parse_vtimezone_std_tzoffsetfrom(calendar_record_h timezone, void *data)
+ int ret = 0;
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
+ sscanf(value +1, VCAL_DATETIME_FORMAT_YYYYMMDDTHHMMSS, &y, &m, &d, &h, &n, &s);
+ ret = _cal_record_set_int(record, _calendar_timezone.standard_start_month, m);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ ret = _cal_record_set_int(record, _calendar_timezone.standard_start_hour, h);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+
+ long long int t = _cal_time_convert_lli(value +1);
+ int nth = 0, wday = 0;
+ _cal_time_get_nth_wday(t, &nth, &wday);
+ ret = _cal_record_set_int(record, _calendar_timezone.standard_start_position_of_week, nth);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ ret = _cal_record_set_int(record, _calendar_timezone.standard_start_day, wday);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+}
+static void __work_component_property_vtimezone_standard_tzoffsetfrom(char *value, calendar_record_h record, struct user_data *ud)
{
- return 0;
+ return;
}
-
-static int __cal_vcalendar_parse_vtimezone_std_tzoffsetto(calendar_record_h timezone, void *data)
+static void __work_component_property_vtimezone_standard_tzoffsetto(char *value, calendar_record_h record, struct user_data *ud)
{
- int h, m;
- char *p = (char *)data;
+ ENTER();
+
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+
char c;
- cal_timezone_s *tz = (cal_timezone_s *)timezone;
+ int h = 0, m = 0;
+ sscanf(value, "%c%02d%02d", &c, &h, &m);
- if (NULL == timezone)
- {
- ERR("Invalid parameter");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
+ int offset = h * 60 + m;
+ if ('-' == c) offset *= -1;
- sscanf(p +1, "%c%02d%02d", &c, &h, &m);
- DBG("timezone standard offsetto(%c)(%02d)(%02d)", c, h, m);
- if (c == '-')
- {
- h *= -1;
- }
- if (tz->day_light_bias)
- {
- // this means daylight is set before gmt offset
- _cal_record_set_int(timezone, _calendar_timezone.day_light_bias,
- tz->day_light_bias - (h * 60 + m));
+ int ret = 0;
+ ret = _cal_record_set_int(record, _calendar_timezone.standard_bias, offset);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ ret = _cal_record_set_int(record, _calendar_timezone.tz_offset_from_gmt, offset);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+
+ if (NULL == ud->timezone_tzid || '\0' == *ud->timezone_tzid) {
+ char buf[32] = {0};
+ snprintf(buf, sizeof(buf), "Etc/GMT%c%d", offset < 0 ? '+' : '-', h);
+ ud->timezone_tzid = strdup(buf);
+ __adjust_tzid(ud->timezone_tzid);
+ DBG("timezone_tzid[%s]", ud->timezone_tzid);
}
- _cal_record_set_int(timezone, _calendar_timezone.tz_offset_from_gmt, h * 60 + m);
- return CALENDAR_ERROR_NONE;
}
-
-struct _record_func _vtimezone_std[VTIMEZONE_STD_MAX] =
+static void __work_component_property_vtimezone_standard_tzname(char *value, calendar_record_h record, struct user_data *ud)
{
- {"DTSTART", __cal_vcalendar_parse_vtimezone_std_dtstart },
- {"TZOFFSETFROM", __cal_vcalendar_parse_vtimezone_std_tzoffsetfrom },
- {"TZOFFSETTO", __cal_vcalendar_parse_vtimezone_std_tzoffsetto }
-};
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
-char *_cal_vcalendar_parse_standard(calendar_record_h timezone, void *data)
+ int ret = _cal_record_set_str(record, _calendar_timezone.standard_name, value);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() is failed(%d)", ret);
+}
+static void __work_component_property_vtimezone_standard_rdate(char *value, calendar_record_h record, struct user_data *ud)
{
- DBG("[%s]", __func__);
- int i;
- char *prop = NULL, *cont = NULL;
- char *cursor = (char *)data;
+ return;
+}
+static char* __work_component_vtimezone_standard(char *cursor, calendar_record_h record, struct user_data *ud)
+{
+ ENTER();
- while ((cursor = _cal_vcalendar_parse_read_line(cursor, &prop, &cont))) {
- if (!strncmp(prop, "END", strlen("END"))) {
- break;
- }
+ retvm_if (NULL == cursor || '\0' == *cursor, __crlf(cursor), "Invalid parameter: cursor is NULL");
+ retvm_if (NULL == record, __crlf(cursor), "Invalid parameter: record is NULL");
+
+ cursor = __crlf(cursor);
+ bool exit_loop = false;
+ while (cursor) {
+ int index = 0;
+ cursor = __get_index(cursor, component_property_vtimezone, VCAL_COMPONENT_PROPERTY_VTIMEZONE_MAX, &index);
- for (i = 0; i < VTIMEZONE_STD_MAX; i++)
+ char *value = NULL;
+ switch (index)
{
- if (!strncmp(prop, _vtimezone_std[i].prop, strlen(_vtimezone_std[i].prop))) {
- _vtimezone_std[i].func(timezone, cont);
- break;
- }
+ case VCAL_COMPONENT_PROPERTY_VTIMEZONE_DTSTART:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_vtimezone_standard_dtstart(value +1, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_VTIMEZONE_TZOFFSETFROM:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_vtimezone_standard_tzoffsetfrom(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_VTIMEZONE_TZOFFSETTO:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_vtimezone_standard_tzoffsetto(value +1, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_VTIMEZONE_TZNAME:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_vtimezone_standard_tzname(value +1, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_VTIMEZONE_RDATE:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_vtimezone_standard_rdate(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_VTIMEZONE_END:
+ cursor = __crlf(cursor);
+ exit_loop = true;
+ break;
+ default:
+ cursor = __crlf(cursor);
+ break;
}
-
- CAL_FREE(prop);
- CAL_FREE(cont);
+ if (true == exit_loop) break;
}
-
- CAL_FREE(prop);
- CAL_FREE(cont);
-
return cursor;
}
-enum {
- VTIMEZONE_DST_DTSTART = 0x0,
- VTIMEZONE_DST_TZOFFSETFROM,
- VTIMEZONE_DST_TZOFFSETTO,
- VTIMEZONE_DST_MAX,
-};
-
-static int __cal_vcalendar_parse_vtimezone_dst_dtstart(calendar_record_h timezone, void *data)
+static void __work_component_property_vtimezone_daylight_dtstart(char *value, calendar_record_h record, struct user_data *ud)
{
- int y, mon, d, h, min, s;
- int nth = 0, wday = 0;
- long long int utime;
- char t, z;
- char *p = (char *)data;
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
- if (NULL == timezone)
- {
- ERR("Invalid parameter");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- sscanf(p +1, "%04d%02d%02d%c%02d%02d%02d%c", &y, &mon, &d, &t, &h, &min, &s, &z);
- utime = _cal_time_convert_itol(NULL, y, mon, d, h, min, s);
- _cal_time_ltoi2(NULL, utime, &nth, &wday);
- DBG("timezone daylight(%04d-%02d-%02d %02d:%02d:%02d", y, mon, d, h, min, s);
- DBG("timezone daylight day of week(%dth/%d)", nth, wday);
- _cal_record_set_int(timezone, _calendar_timezone.day_light_start_month, mon);
- _cal_record_set_int(timezone, _calendar_timezone.day_light_start_position_of_week, nth);
- _cal_record_set_int(timezone, _calendar_timezone.day_light_start_day, wday);
- _cal_record_set_int(timezone, _calendar_timezone.day_light_start_hour, h);
- return CALENDAR_ERROR_NONE;
-}
+ int ret = 0;
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
+ sscanf(value +1, VCAL_DATETIME_FORMAT_YYYYMMDDTHHMMSS, &y, &m, &d, &h, &n, &s);
+ ret = _cal_record_set_int(record, _calendar_timezone.day_light_start_month, m);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ ret = _cal_record_set_int(record, _calendar_timezone.day_light_start_hour, h);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
-static int __cal_vcalendar_parse_vtimezone_dst_tzoffsetfrom(calendar_record_h timezone, void *data)
+ long long int t = _cal_time_convert_lli(value +1);
+ int nth = 0, wday = 0;
+ _cal_time_get_nth_wday(t, &nth, &wday);
+ ret = _cal_record_set_int(record, _calendar_timezone.day_light_start_position_of_week, nth);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+ ret = _cal_record_set_int(record, _calendar_timezone.day_light_start_day, wday);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+}
+static void __work_component_property_vtimezone_daylight_tzoffsetfrom(char *value, calendar_record_h record, struct user_data *ud)
{
- return 0;
+ return;
}
-
-static int __cal_vcalendar_parse_vtimezone_dst_tzoffsetto(calendar_record_h timezone, void *data)
+static void __work_component_property_vtimezone_daylight_tzoffsetto(char *value, calendar_record_h record, struct user_data *ud)
{
- int h, m;
- char *p = (char *)data;
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
+
char c;
- cal_timezone_s *tz = (cal_timezone_s *)timezone;
+ int h = 0, m = 0;
+ sscanf(value, "%c%02d%02d", &c, &h, &m);
- if (NULL == timezone)
- {
- ERR("Invalid parameter");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
+ int offset = h * 60 + m;
+ if ('-' == c) offset *= -1;
- sscanf(p +1, "%c%02d%02d", &c, &h, &m);
- DBG("timezone offsetto(%c)(%02d)(%02d)", c, h, m);
- if (c == '-')
- {
- h *= -1;
- }
- _cal_record_set_int(timezone, _calendar_timezone.day_light_bias,
- (h * 60 + m) - tz->tz_offset_from_gmt);
- return CALENDAR_ERROR_NONE;
+ int ret = ret = _cal_record_set_int(record, _calendar_timezone.day_light_bias, offset);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_record_set_int() Failed(%d)", ret);
+DBG("offset(%d)", offset);
}
-
-struct _record_func _vtimezone_dst[VTIMEZONE_STD_MAX] =
+static void __work_component_property_vtimezone_daylight_tzname(char *value, calendar_record_h record, struct user_data *ud)
{
- {"DTSTART", __cal_vcalendar_parse_vtimezone_dst_dtstart },
- {"TZOFFSETFROM", __cal_vcalendar_parse_vtimezone_dst_tzoffsetfrom },
- {"TZOFFSETTO", __cal_vcalendar_parse_vtimezone_dst_tzoffsetto }
-};
+ retm_if (NULL == value || '\0' == *value, "Invalid parameter: value is NULL");
+ retm_if (NULL == record, "Invalid parameter: record is NULL");
-char *_cal_vcalendar_parse_daylight(calendar_record_h timezone, void *data)
+ int ret = _cal_record_set_str(record, _calendar_timezone.day_light_name, value);
+ warn_if (CALENDAR_ERROR_NONE != ret, "_cal_record_set_str() is failed(%d)", ret);
+}
+static void __work_component_property_vtimezone_daylight_rdate(char *value, calendar_record_h record, struct user_data *ud)
{
- DBG("[%s]", __func__);
- int i;
- char *prop = NULL, *cont = NULL;
- char *cursor = (char *)data;
+ return;
+}
+static char* __work_component_vtimezone_daylight(char *cursor, calendar_record_h record, struct user_data *ud)
+{
+ retvm_if (NULL == cursor || '\0' == *cursor, __crlf(cursor), "Invalid parameter: cursor is NULL");
+ retvm_if (NULL == record, __crlf(cursor), "Invalid parameter: record is NULL");
- while ((cursor = _cal_vcalendar_parse_read_line(cursor, &prop, &cont))) {
- if (!strncmp(prop, "END", strlen("END"))) {
- break;
- }
+ cursor = __crlf(cursor);
+ bool exit_loop = false;
+ while (cursor) {
+ int index = 0;
+ cursor = __get_index(cursor, component_property_vtimezone, VCAL_COMPONENT_PROPERTY_VTIMEZONE_MAX, &index);
- for (i = 0; i < VTIMEZONE_DST_MAX; i++)
+ char *value = NULL;
+ switch (index)
{
- if (!strncmp(prop, _vtimezone_dst[i].prop, strlen(_vtimezone_dst[i].prop))) {
- _vtimezone_dst[i].func(timezone, cont);
- break;
- }
+ case VCAL_COMPONENT_PROPERTY_VTIMEZONE_DTSTART:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_vtimezone_daylight_dtstart(value +1, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_VTIMEZONE_TZOFFSETFROM:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_vtimezone_daylight_tzoffsetfrom(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_VTIMEZONE_TZOFFSETTO:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_vtimezone_daylight_tzoffsetto(value +1, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_VTIMEZONE_TZNAME:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_vtimezone_daylight_tzname(value +1, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_VTIMEZONE_RDATE:
+ cursor = __get_value(cursor, &value);
+ __work_component_property_vtimezone_daylight_rdate(value, record, ud);
+ free(value);
+ value = NULL;
+ break;
+ case VCAL_COMPONENT_PROPERTY_VTIMEZONE_END:
+ cursor = __crlf(cursor);
+ exit_loop = true;
+ break;
+ default:
+ cursor = __crlf(cursor);
+ break;
}
-
- CAL_FREE(prop);
- CAL_FREE(cont);
+ if (true == exit_loop) break;
}
-
- CAL_FREE(prop);
- CAL_FREE(cont);
-
return cursor;
}
-char *_cal_vcalendar_parse_vtimezone(int ver, calendar_list_h *list_sch, void *data)
+static char* __work_component_vtimezone(char *cursor, calendar_record_h record, struct user_data *ud)
{
- int ret = CALENDAR_ERROR_NONE;
- char *prop = NULL, *cont = NULL;
- char *cursor = (char *)data;
- calendar_record_h timezone = NULL;
+ ENTER();
- ret = calendar_record_create(_calendar_timezone._uri, &timezone);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_create() failed");
- return NULL;
- }
+ retvm_if (NULL == cursor, NULL, "Invalid parameter: cursor is NULL");
+ retvm_if (NULL == record, NULL, "Invalid parameter: record is NULL");
- while ((cursor = _cal_vcalendar_parse_read_line(cursor, &prop, &cont)))
- {
- if (!strncmp(prop, "TZID", strlen("TZID")))
- {
- _cal_record_set_str(timezone, _calendar_timezone.standard_name, cont +1);
- _cal_record_set_str(timezone, _calendar_timezone.day_light_name, cont +1);
- DBG("name[%s]", cont +1);
- }
- else if (!strncmp(prop, "BEGIN", strlen("BEGIN")))
- {
- if (!strncmp(cont + 1, "STANDARD", strlen("STANDARD")))
- {
- cursor = _cal_vcalendar_parse_standard(timezone, cursor);
- }
- else if (!strncmp(cont + 1, "DAYLIGHT", strlen("DAYLIGHT")))
- {
- cursor = _cal_vcalendar_parse_daylight(timezone, cursor);
- }
- else
- {
- DBG("Error");
+ __init_component_property_vtimezone();
+
+ while (cursor) {
+ if (!strncmp(cursor, "TZID:", strlen("TZID:"))) {
+ char *p = cursor + strlen("TZID");
+ if (NULL == p || '\0' == *p) {
+ ERR("Inavlid tzid");
+ cursor = __crlf(cursor);
+ continue;
}
- }
- else if (!strncmp(prop, "END", strlen("END")))
- {
- if (!strncmp(cont + 1, "VTIMEZONE", strlen("VTIMEZONE")))
- {
- break;
+ if (ud->timezone_tzid) {
+ free(ud->timezone_tzid);
+ ud->timezone_tzid = NULL;
}
- else
- {
- DBG("Error");
+ char *value = NULL;
+ cursor = __get_value(p, &value);
+ __adjust_tzid(value);
+ DBG("tzid[%s]", value +1);
+ if (true == _cal_time_is_available_tzid(value +1)) {
+ ud->timezone_tzid = strdup(value +1);
+ } else {
+ DBG("Invalid tzid string[%s]", value +1);
}
+ free(value);
+ } else if (!strncmp(cursor, "BEGIN:STANDARD", strlen("BEGIN:STANDARD"))) {
+ cursor = __work_component_vtimezone_standard(cursor, record, ud);
+ } else if (!strncmp(cursor, "BEGIN:DAYLIGHT", strlen("BEGIN:DAYLIGHT"))) {
+ cursor = __work_component_vtimezone_daylight(cursor, record, ud);
+ } else if (!strncmp(cursor, "END", strlen("END"))) {
+ cursor = __crlf(cursor);
+ break;
+ } else {
+ DBG("Unable to parse");
+ __print_cursor(cursor, __LINE__);
+ cursor = __crlf(cursor);
}
- else
- {
- DBG("Error");
- }
- CAL_FREE(prop);
- CAL_FREE(cont);
}
+ return cursor;
+}
+
+static char* __work_property_begin(char *cursor, calendar_record_h *out_record, struct user_data *ud)
+{
+ ENTER();
+ retvm_if (NULL == cursor || '\0' == *cursor, NULL, "Invalid parameter: cursor is NULL");
+ retvm_if (NULL == out_record, NULL, "Invalid parameter: out_record is NULL");
+ retvm_if (NULL == ud, NULL, "Invalid parameter: ud is NULL");
+
+ int ret = 0;
+ int index = 0;
+ cursor = __get_index(cursor +1, vcal_component, VCAL_COMPONENT_MAX, &index);
+ cursor = __crlf(cursor);
+ calendar_record_h record = NULL;
+ switch (index)
+ {
+ case VCAL_COMPONENT_VEVENT:
+ ret = calendar_record_create(_calendar_event._uri, &record);
+ retvm_if (CALENDAR_ERROR_NONE != ret, NULL, "calendar_record_create() is failed(%d)", ret);
+ ud->type = CALENDAR_BOOK_TYPE_EVENT;
+ cursor = __work_component_vevent(cursor, record, ud);
+ break;
- CAL_FREE(prop);
- CAL_FREE(cont);
+ case VCAL_COMPONENT_VTODO:
+ ret = calendar_record_create(_calendar_todo._uri, &record);
+ retvm_if (CALENDAR_ERROR_NONE != ret, NULL, "calendar_record_create() is failed(%d)", ret);
+ ud->type = CALENDAR_BOOK_TYPE_TODO;
+ cursor = __work_component_vevent(cursor, record, ud); // same as event
+ break;
+
+ case VCAL_COMPONENT_VJOURNAL:
+ cursor = __work_component_vjournal(cursor, record, ud);
+ break;
- DBG("add timezone to the list");
- calendar_list_add(*list_sch, timezone);
+ case VCAL_COMPONENT_VFREEBUSY:
+ cursor = __work_component_vfreebusy(cursor, record, ud);
+ break;
+ case VCAL_COMPONENT_VTIMEZONE:
+ ret = calendar_record_create(_calendar_timezone._uri, &record);
+ retvm_if (CALENDAR_ERROR_NONE != ret, NULL, "calendar_record_create() is failed(%d)", ret);
+ cursor = __work_component_vtimezone(cursor, record, ud);
+ break;
+ }
+ *out_record = record;
return cursor;
}
-/*
- * parses vcalendar and appends record to the list.
- */
-char *_cal_vcalendar_parse_vcalendar(calendar_list_h *list, void *data)
+int _cal_vcalendar_parse_vcalendar_object(char *stream, calendar_list_h list, vcalendar_foreach_s *foreach_data)
{
- DBG("[%s]", __func__);
- int ret = CALENDAR_ERROR_NONE;
- char *prop = NULL, *cont = NULL;
- char *cursor = (char *)data;
- char *p = cursor;
- calendar_list_h l = NULL;
+ ENTER();
- if (NULL == list)
- {
- ERR("Invalid parameter: list is NULL");
- return NULL;
- }
+ retvm_if (NULL == stream, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: stream is NULL");
+ retvm_if (NULL == list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: list is NULL");
- ret = calendar_list_create(&l);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_list_create() failed");
- return NULL;
- }
+ __init_component();
+ __init_property();
+ __init_component_property();
+ __unfolding(stream);
- while ((cursor = _cal_vcalendar_parse_read_line(cursor, &prop, &cont))) {
- if (prop == NULL || cont == NULL)
- {
- ERR("Failed to parse");
- break;
- }
- if (!strncmp(prop, "BEGIN", strlen("BEGIN"))) {
- CAL_FREE(prop);
- CAL_FREE(cont);
- break;
- }
+ struct user_data *ud = calloc(1, sizeof(struct user_data));
+ retvm_if (NULL == ud, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc() is failed");
+ ud->version = VCAL_VER_2; // default
- calendar_record_h extended = NULL;
- ret = calendar_record_create(_calendar_extended_property._uri, &extended);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_create() failed");
- CAL_FREE(prop);
- CAL_FREE(cont);
- break;
- }
+ calendar_record_h record = NULL;
- ret = calendar_record_set_str(extended, _calendar_extended_property.key, prop);
- if (CALENDAR_ERROR_NONE != ret)
+ int count = 0;
+ bool exit_loop = false;
+ char *cursor = (char *)stream;
+ while (cursor) {
+ int index = 0;
+ char *value = NULL;
+ cursor = __get_index(cursor, vcal_property, VCAL_PROPERTY_MAX, &index);
+ switch (index)
{
- ERR("calendar_record_set_str() failed");
- CAL_FREE(prop);
- CAL_FREE(cont);
- calendar_record_destroy(extended, true);
+ case VCAL_PROPERTY_VERSION:
+ cursor = __get_value(cursor, &value);
+ __get_version(value, &ud->version);
+ free(value);
+ value = NULL;
break;
- }
- ret = calendar_record_set_str(extended, _calendar_extended_property.value, cont);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_set_str() failed");
- CAL_FREE(prop);
- CAL_FREE(cont);
- calendar_record_destroy(extended, true);
+ case VCAL_PROPERTY_TZ:
+ cursor = __get_value(cursor, &value);
+ __get_tz(value + 1, &ud->timezone_tzid);
+ __adjust_tzid(ud->timezone_tzid);
+ DBG("timezone_tzid[%s]", ud->timezone_tzid);
+ free(value);
+ value = NULL;
break;
- }
- ret = calendar_list_add(l, extended);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_set_str() failed");
- CAL_FREE(prop);
- CAL_FREE(cont);
- calendar_record_destroy(extended, true);
+ case VCAL_PROPERTY_BEGIN: // BEGIN:VEVENT
+ cursor = __work_property_begin(cursor, &record, ud);
+ calendar_list_add(list, record);
+ count++;
+ if (foreach_data) {
+ foreach_data->ret = foreach_data->callback(record, foreach_data->user_data);
+ if (false == foreach_data->ret)
+ exit_loop = true;
+ }
break;
- }
- CAL_FREE(prop);
- CAL_FREE(cont);
- p = cursor;
- }
-
- cursor = p;
- while ((cursor = _cal_vcalendar_parse_read_line(cursor, &prop, &cont))) {
- if (prop == NULL || cont == NULL)
- {
- ERR("Failed to parse");
+ case VCAL_PROPERTY_END: // END:VCALENDAR
+ DBG("exit VCALENDAR");
+ // fini vcalendar
+ exit_loop = true;
break;
- }
- if (!strncmp(prop, "BEGIN", strlen("BEGIN"))) {
-
- if (!strncmp(cont + 1, "VEVENT", strlen("VEVENT"))) {
- cursor = _cal_vcalendar_parse_vevent(CALENDAR_BOOK_TYPE_EVENT, &l, cursor);
-
- } else if (!strncmp(cont + 1, "VTODO", strlen("VTODO"))) {
- cursor = _cal_vcalendar_parse_vtodo(CALENDAR_BOOK_TYPE_TODO, &l, cursor);
-
- } else if (!strncmp(cont + 1, "VTIMEZONE", strlen("VTIMEZONE"))) {
- cursor = _cal_vcalendar_parse_vtimezone(CALENDAR_BOOK_TYPE_NONE, &l, cursor);
-/*
- } else if (!strncmp(cont + 1, "VFREEBUSY", strlen("VFREEBUSY"))) {
-*/
- } else {
-
- }
- } else if (!strncmp(prop, "END:VCALENDAR", strlen("END:VCALENDAR"))) {
- CAL_FREE(prop);
- CAL_FREE(cont);
+ default:
+ DBG("skip invalid property, index(%d)", index);
+ cursor = __crlf(cursor);
break;
}
-
- CAL_FREE(prop);
- CAL_FREE(cont);
+ if (true == exit_loop) break;
}
- CAL_FREE(prop);
- CAL_FREE(cont);
- *list = l;
+ DBG("count(%d)", count);
+ if (0 == count)
+ DBG("No record");
- return cursor;
+ return CALENDAR_ERROR_NONE;
}
-
#include "calendar_vcalendar.h"
-char *_cal_vcalendar_parse_remove_space(char *src);
+typedef struct {
+ calendar_vcalendar_parse_cb callback;
+ void *user_data;
+ bool ret;
+} vcalendar_foreach_s;
+
+char* _cal_vcalendar_parse_remove_space(char *src);
int _cal_vcalendar_parse_unfolding(char *stream);
-char *_cal_vcalendar_parse_read_line(char *stream, char **prop, char **cont);
-char *_cal_vcalendar_parse_vcalendar(calendar_list_h *list_sch, void *data);
+char* _cal_vcalendar_parse_read_line(char *stream, char **line);
+char* _cal_vcalendar_parse_read_key_value(char *stream, char **prop, char **cont);
+int _cal_vcalendar_parse_vcalendar_object(char *vcalendar_object_stream, calendar_list_h list, vcalendar_foreach_s *foreach_data);
#endif // __CALENDAR_SVC_VCALENDAR_PARSE_H__
// !! TODO : please check ids number
API const _calendar_book_property_ids _calendar_book =
{
- ._uri = CALENDAR_VIEW_CALENDAR,
- .id = CAL_PROPERTY_CALENDAR_ID,
- .uid = CAL_PROPERTY_CALENDAR_UID,
- .name = CAL_PROPERTY_CALENDAR_NAME,
- .description = CAL_PROPERTY_CALENDAR_DESCRIPTION,
- .color = CAL_PROPERTY_CALENDAR_COLOR,
- .location = CAL_PROPERTY_CALENDAR_LOCATION,
- .visibility = CAL_PROPERTY_CALENDAR_VISIBILITY,
- .sync_event = CAL_PROPERTY_CALENDAR_SYNC_EVENT,
- .is_deleted = CAL_PROPERTY_CALENDAR_IS_DELETED,
- .account_id = CAL_PROPERTY_CALENDAR_ACCOUNT_ID,
- .store_type = CAL_PROPERTY_CALENDAR_STORE_TYPE,
- .sync_data1 = CAL_PROPERTY_CALENDAR_SYNC_DATA1,
- .sync_data2 = CAL_PROPERTY_CALENDAR_SYNC_DATA2,
- .sync_data3 = CAL_PROPERTY_CALENDAR_SYNC_DATA3,
- .sync_data4 = CAL_PROPERTY_CALENDAR_SYNC_DATA4
+ ._uri = CALENDAR_VIEW_CALENDAR,
+ .id = CAL_PROPERTY_CALENDAR_ID,
+ .uid = CAL_PROPERTY_CALENDAR_UID,
+ .name = CAL_PROPERTY_CALENDAR_NAME,
+ .description = CAL_PROPERTY_CALENDAR_DESCRIPTION,
+ .color = CAL_PROPERTY_CALENDAR_COLOR,
+ .location = CAL_PROPERTY_CALENDAR_LOCATION,
+ .visibility = CAL_PROPERTY_CALENDAR_VISIBILITY,
+ .sync_event = CAL_PROPERTY_CALENDAR_SYNC_EVENT,
+ .account_id = CAL_PROPERTY_CALENDAR_ACCOUNT_ID,
+ .store_type = CAL_PROPERTY_CALENDAR_STORE_TYPE,
+ .sync_data1 = CAL_PROPERTY_CALENDAR_SYNC_DATA1,
+ .sync_data2 = CAL_PROPERTY_CALENDAR_SYNC_DATA2,
+ .sync_data3 = CAL_PROPERTY_CALENDAR_SYNC_DATA3,
+ .sync_data4 = CAL_PROPERTY_CALENDAR_SYNC_DATA4,
+ .mode = CAL_PROPERTY_CALENDAR_MODE
};
+
API const _calendar_event_property_ids _calendar_event =
{
- ._uri = CALENDAR_VIEW_EVENT,
- .id = CAL_PROPERTY_EVENT_ID,
- .calendar_book_id = CAL_PROPERTY_EVENT_CALENDAR_ID,
- .summary = CAL_PROPERTY_EVENT_SUMMARY,
- .description = CAL_PROPERTY_EVENT_DESCRIPTION,
- .location = CAL_PROPERTY_EVENT_LOCATION,
- .categories = CAL_PROPERTY_EVENT_CATEGORIES,
- .exdate = CAL_PROPERTY_EVENT_EXDATE,
- .event_status = CAL_PROPERTY_EVENT_EVENT_STATUS,
- .priority = CAL_PROPERTY_EVENT_PRIORITY,
- .timezone = CAL_PROPERTY_EVENT_TIMEZONE,
- .person_id = CAL_PROPERTY_EVENT_CONTACT_ID,
- .busy_status = CAL_PROPERTY_EVENT_BUSY_STATUS,
- .sensitivity = CAL_PROPERTY_EVENT_SENSITIVITY,
- .uid = CAL_PROPERTY_EVENT_UID,
- .organizer_name = CAL_PROPERTY_EVENT_ORGANIZER_NAME,
- .organizer_email = CAL_PROPERTY_EVENT_ORGANIZER_EMAIL,
- .meeting_status = CAL_PROPERTY_EVENT_MEETING_STATUS,
- .original_event_id = CAL_PROPERTY_EVENT_ORIGINAL_EVENT_ID,
- .latitude = CAL_PROPERTY_EVENT_LATITUDE,
- .longitude = CAL_PROPERTY_EVENT_LONGITUDE,
- .email_id = CAL_PROPERTY_EVENT_EMAIL_ID,
- .created_time = CAL_PROPERTY_EVENT_CREATED_TIME,
- .last_modified_time = CAL_PROPERTY_EVENT_LAST_MODIFIED_TIME,
- .is_deleted = CAL_PROPERTY_EVENT_IS_DELETED,
- //CAL_PROPERTY_EVENT_HAS_RRULE,
- .freq = CAL_PROPERTY_EVENT_FREQ,
- .range_type = CAL_PROPERTY_EVENT_RANGE_TYPE,
- .until_time = CAL_PROPERTY_EVENT_UNTIL,
- .count = CAL_PROPERTY_EVENT_COUNT,
- .interval = CAL_PROPERTY_EVENT_INTERVAL,
- .bysecond = CAL_PROPERTY_EVENT_BYSECOND,
- .byminute = CAL_PROPERTY_EVENT_BYMINUTE,
- .byhour = CAL_PROPERTY_EVENT_BYHOUR,
- .byday = CAL_PROPERTY_EVENT_BYDAY,
- .bymonthday = CAL_PROPERTY_EVENT_BYMONTHDAY,
- .byyearday = CAL_PROPERTY_EVENT_BYYEARDAY,
- .byweekno = CAL_PROPERTY_EVENT_BYWEEKNO,
- .bymonth = CAL_PROPERTY_EVENT_BYMONTH,
- .bysetpos = CAL_PROPERTY_EVENT_BYSETPOS,
- .wkst = CAL_PROPERTY_EVENT_WKST,
- .recurrence_id = CAL_PROPERTY_EVENT_RECURRENCE_ID,
- .rdate = CAL_PROPERTY_EVENT_RDATE,
- .has_attendee = CAL_PROPERTY_EVENT_HAS_ATTENDEE,
- .has_alarm = CAL_PROPERTY_EVENT_HAS_ALARM,
- .calendar_system_type = CAL_PROPERTY_EVENT_CALENDAR_SYSTEM_TYPE,
- .sync_data1 = CAL_PROPERTY_EVENT_SYNC_DATA1,
- .sync_data2 = CAL_PROPERTY_EVENT_SYNC_DATA2,
- .sync_data3 = CAL_PROPERTY_EVENT_SYNC_DATA3,
- .sync_data4 = CAL_PROPERTY_EVENT_SYNC_DATA4,
- .start_time = CAL_PROPERTY_EVENT_START,
- .start_tzid = CAL_PROPERTY_EVENT_START_TZID,
- .end_time = CAL_PROPERTY_EVENT_END,
- .end_tzid = CAL_PROPERTY_EVENT_END_TZID,
- .calendar_alarm = CAL_PROPERTY_EVENT_CALENDAR_ALARM,
- .calendar_attendee = CAL_PROPERTY_EVENT_CALENDAR_ATTENDEE,
- .exception = CAL_PROPERTY_EVENT_EXCEPTION,
- .extended = CAL_PROPERTY_EVENT_EXTENDED,
- .is_allday = CAL_PROPERTY_EVENT_IS_ALLDAY
+ ._uri = CALENDAR_VIEW_EVENT,
+ .id = CAL_PROPERTY_EVENT_ID,
+ .calendar_book_id = CAL_PROPERTY_EVENT_CALENDAR_ID,
+ .summary = CAL_PROPERTY_EVENT_SUMMARY,
+ .description = CAL_PROPERTY_EVENT_DESCRIPTION,
+ .location = CAL_PROPERTY_EVENT_LOCATION,
+ .categories = CAL_PROPERTY_EVENT_CATEGORIES,
+ .exdate = CAL_PROPERTY_EVENT_EXDATE,
+ .event_status = CAL_PROPERTY_EVENT_EVENT_STATUS,
+ .priority = CAL_PROPERTY_EVENT_PRIORITY,
+ .timezone = CAL_PROPERTY_EVENT_TIMEZONE,
+ .person_id = CAL_PROPERTY_EVENT_CONTACT_ID,
+ .busy_status = CAL_PROPERTY_EVENT_BUSY_STATUS,
+ .sensitivity = CAL_PROPERTY_EVENT_SENSITIVITY,
+ .uid = CAL_PROPERTY_EVENT_UID,
+ .organizer_name = CAL_PROPERTY_EVENT_ORGANIZER_NAME,
+ .organizer_email = CAL_PROPERTY_EVENT_ORGANIZER_EMAIL,
+ .meeting_status = CAL_PROPERTY_EVENT_MEETING_STATUS,
+ .original_event_id = CAL_PROPERTY_EVENT_ORIGINAL_EVENT_ID,
+ .latitude = CAL_PROPERTY_EVENT_LATITUDE,
+ .longitude = CAL_PROPERTY_EVENT_LONGITUDE,
+ .email_id = CAL_PROPERTY_EVENT_EMAIL_ID,
+ .created_time = CAL_PROPERTY_EVENT_CREATED_TIME,
+ .last_modified_time = CAL_PROPERTY_EVENT_LAST_MODIFIED_TIME,
+ .is_deleted = CAL_PROPERTY_EVENT_IS_DELETED,
+ .freq = CAL_PROPERTY_EVENT_FREQ,
+ .range_type = CAL_PROPERTY_EVENT_RANGE_TYPE,
+ .until_time = CAL_PROPERTY_EVENT_UNTIL,
+ .count = CAL_PROPERTY_EVENT_COUNT,
+ .interval = CAL_PROPERTY_EVENT_INTERVAL,
+ .bysecond = CAL_PROPERTY_EVENT_BYSECOND,
+ .byminute = CAL_PROPERTY_EVENT_BYMINUTE,
+ .byhour = CAL_PROPERTY_EVENT_BYHOUR,
+ .byday = CAL_PROPERTY_EVENT_BYDAY,
+ .bymonthday = CAL_PROPERTY_EVENT_BYMONTHDAY,
+ .byyearday = CAL_PROPERTY_EVENT_BYYEARDAY,
+ .byweekno = CAL_PROPERTY_EVENT_BYWEEKNO,
+ .bymonth = CAL_PROPERTY_EVENT_BYMONTH,
+ .bysetpos = CAL_PROPERTY_EVENT_BYSETPOS,
+ .wkst = CAL_PROPERTY_EVENT_WKST,
+ .recurrence_id = CAL_PROPERTY_EVENT_RECURRENCE_ID,
+ .rdate = CAL_PROPERTY_EVENT_RDATE,
+ .has_attendee = CAL_PROPERTY_EVENT_HAS_ATTENDEE,
+ .has_alarm = CAL_PROPERTY_EVENT_HAS_ALARM,
+ .calendar_system_type = CAL_PROPERTY_EVENT_CALENDAR_SYSTEM_TYPE,
+ .sync_data1 = CAL_PROPERTY_EVENT_SYNC_DATA1,
+ .sync_data2 = CAL_PROPERTY_EVENT_SYNC_DATA2,
+ .sync_data3 = CAL_PROPERTY_EVENT_SYNC_DATA3,
+ .sync_data4 = CAL_PROPERTY_EVENT_SYNC_DATA4,
+ .start_time = CAL_PROPERTY_EVENT_START,
+ .start_tzid = CAL_PROPERTY_EVENT_START_TZID,
+ .end_time = CAL_PROPERTY_EVENT_END,
+ .end_tzid = CAL_PROPERTY_EVENT_END_TZID,
+ .calendar_alarm = CAL_PROPERTY_EVENT_CALENDAR_ALARM,
+ .calendar_attendee = CAL_PROPERTY_EVENT_CALENDAR_ATTENDEE,
+ .exception = CAL_PROPERTY_EVENT_EXCEPTION,
+ .extended = CAL_PROPERTY_EVENT_EXTENDED,
+ .is_allday = CAL_PROPERTY_EVENT_IS_ALLDAY
};
+
API const _calendar_todo_property_ids _calendar_todo =
{
- ._uri = CALENDAR_VIEW_TODO,
- .id = CAL_PROPERTY_TODO_ID,
- .calendar_book_id = CAL_PROPERTY_TODO_CALENDAR_ID,
- .summary = CAL_PROPERTY_TODO_SUMMARY,
- .description = CAL_PROPERTY_TODO_DESCRIPTION,
- .location = CAL_PROPERTY_TODO_LOCATION,
- .categories = CAL_PROPERTY_TODO_CATEGORIES,
- .todo_status = CAL_PROPERTY_TODO_TODO_STATUS,
- .priority = CAL_PROPERTY_TODO_PRIORITY,
- .sensitivity = CAL_PROPERTY_TODO_SENSITIVITY,
- .uid = CAL_PROPERTY_TODO_UID,
- .latitude = CAL_PROPERTY_TODO_LATITUDE,
- .longitude = CAL_PROPERTY_TODO_LONGITUDE,
- .created_time = CAL_PROPERTY_TODO_CREATED_TIME,
- .last_modified_time = CAL_PROPERTY_TODO_LAST_MODIFIED_TIME,
- .completed_time = CAL_PROPERTY_TODO_COMPLETED_TIME,
- .progress = CAL_PROPERTY_TODO_PROGRESS,
- .is_deleted = CAL_PROPERTY_TODO_IS_DELETED,
- //CAL_PROPERTY_TODO_HAS_RRULE,
- .freq = CAL_PROPERTY_TODO_FREQ,
- .range_type = CAL_PROPERTY_TODO_RANGE_TYPE,
- .until_time = CAL_PROPERTY_TODO_UNTIL,
- .count = CAL_PROPERTY_TODO_COUNT,
- .interval = CAL_PROPERTY_TODO_INTERVAL,
- .bysecond = CAL_PROPERTY_TODO_BYSECOND,
- .byminute = CAL_PROPERTY_TODO_BYMINUTE,
- .byhour = CAL_PROPERTY_TODO_BYHOUR,
- .byday = CAL_PROPERTY_TODO_BYDAY,
- .bymonthday = CAL_PROPERTY_TODO_BYMONTHDAY,
- .byyearday = CAL_PROPERTY_TODO_BYYEARDAY,
- .byweekno = CAL_PROPERTY_TODO_BYWEEKNO,
- .bymonth = CAL_PROPERTY_TODO_BYMONTH,
- .bysetpos = CAL_PROPERTY_TODO_BYSETPOS,
- .wkst = CAL_PROPERTY_TODO_WKST,
- .has_alarm = CAL_PROPERTY_TODO_HAS_ALARM,
- .sync_data1 = CAL_PROPERTY_TODO_SYNC_DATA1,
- .sync_data2 = CAL_PROPERTY_TODO_SYNC_DATA2,
- .sync_data3 = CAL_PROPERTY_TODO_SYNC_DATA3,
- .sync_data4 = CAL_PROPERTY_TODO_SYNC_DATA4,
- .start_time = CAL_PROPERTY_TODO_START,
- .start_tzid = CAL_PROPERTY_TODO_START_TZID,
- .due_time = CAL_PROPERTY_TODO_DUE,
- .due_tzid = CAL_PROPERTY_TODO_DUE_TZID,
- .calendar_alarm = CAL_PROPERTY_TODO_CALENDAR_ALARM,
- .organizer_name = CAL_PROPERTY_TODO_ORGANIZER_NAME,
- .organizer_email = CAL_PROPERTY_TODO_ORGANIZER_EMAIL,
- .has_attendee = CAL_PROPERTY_TODO_HAS_ATTENDEE,
- .calendar_attendee = CAL_PROPERTY_TODO_CALENDAR_ATTENDEE,
- .extended = CAL_PROPERTY_TODO_EXTENDED,
- .is_allday = CAL_PROPERTY_TODO_IS_ALLDAY
+ ._uri = CALENDAR_VIEW_TODO,
+ .id = CAL_PROPERTY_TODO_ID,
+ .calendar_book_id = CAL_PROPERTY_TODO_CALENDAR_ID,
+ .summary = CAL_PROPERTY_TODO_SUMMARY,
+ .description = CAL_PROPERTY_TODO_DESCRIPTION,
+ .location = CAL_PROPERTY_TODO_LOCATION,
+ .categories = CAL_PROPERTY_TODO_CATEGORIES,
+ .todo_status = CAL_PROPERTY_TODO_TODO_STATUS,
+ .priority = CAL_PROPERTY_TODO_PRIORITY,
+ .sensitivity = CAL_PROPERTY_TODO_SENSITIVITY,
+ .uid = CAL_PROPERTY_TODO_UID,
+ .latitude = CAL_PROPERTY_TODO_LATITUDE,
+ .longitude = CAL_PROPERTY_TODO_LONGITUDE,
+ .created_time = CAL_PROPERTY_TODO_CREATED_TIME,
+ .last_modified_time = CAL_PROPERTY_TODO_LAST_MODIFIED_TIME,
+ .completed_time = CAL_PROPERTY_TODO_COMPLETED_TIME,
+ .progress = CAL_PROPERTY_TODO_PROGRESS,
+ .is_deleted = CAL_PROPERTY_TODO_IS_DELETED,
+ .freq = CAL_PROPERTY_TODO_FREQ,
+ .range_type = CAL_PROPERTY_TODO_RANGE_TYPE,
+ .until_time = CAL_PROPERTY_TODO_UNTIL,
+ .count = CAL_PROPERTY_TODO_COUNT,
+ .interval = CAL_PROPERTY_TODO_INTERVAL,
+ .bysecond = CAL_PROPERTY_TODO_BYSECOND,
+ .byminute = CAL_PROPERTY_TODO_BYMINUTE,
+ .byhour = CAL_PROPERTY_TODO_BYHOUR,
+ .byday = CAL_PROPERTY_TODO_BYDAY,
+ .bymonthday = CAL_PROPERTY_TODO_BYMONTHDAY,
+ .byyearday = CAL_PROPERTY_TODO_BYYEARDAY,
+ .byweekno = CAL_PROPERTY_TODO_BYWEEKNO,
+ .bymonth = CAL_PROPERTY_TODO_BYMONTH,
+ .bysetpos = CAL_PROPERTY_TODO_BYSETPOS,
+ .wkst = CAL_PROPERTY_TODO_WKST,
+ .has_alarm = CAL_PROPERTY_TODO_HAS_ALARM,
+ .sync_data1 = CAL_PROPERTY_TODO_SYNC_DATA1,
+ .sync_data2 = CAL_PROPERTY_TODO_SYNC_DATA2,
+ .sync_data3 = CAL_PROPERTY_TODO_SYNC_DATA3,
+ .sync_data4 = CAL_PROPERTY_TODO_SYNC_DATA4,
+ .start_time = CAL_PROPERTY_TODO_START,
+ .start_tzid = CAL_PROPERTY_TODO_START_TZID,
+ .due_time = CAL_PROPERTY_TODO_DUE,
+ .due_tzid = CAL_PROPERTY_TODO_DUE_TZID,
+ .calendar_alarm = CAL_PROPERTY_TODO_CALENDAR_ALARM,
+ .organizer_name = CAL_PROPERTY_TODO_ORGANIZER_NAME,
+ .organizer_email = CAL_PROPERTY_TODO_ORGANIZER_EMAIL,
+ .has_attendee = CAL_PROPERTY_TODO_HAS_ATTENDEE,
+ .calendar_attendee = CAL_PROPERTY_TODO_CALENDAR_ATTENDEE,
+ .extended = CAL_PROPERTY_TODO_EXTENDED,
+ .is_allday = CAL_PROPERTY_TODO_IS_ALLDAY
};
API const _calendar_timezone_property_ids _calendar_timezone =
{
- ._uri = CALENDAR_VIEW_TIMEZONE,
- .id = CAL_PROPERTY_TIMEZONE_ID,
- .calendar_book_id = CAL_PROPERTY_TIMEZONE_CALENDAR_ID,
- .tz_offset_from_gmt = CAL_PROPERTY_TIMEZONE_TZ_OFFSET_FROM_GMT,
- .standard_name = CAL_PROPERTY_TIMEZONE_STANDARD_NAME,
- .standard_start_month = CAL_PROPERTY_TIMEZONE_STD_START_MONTH,
- .standard_start_position_of_week = CAL_PROPERTY_TIMEZONE_STD_START_POSITION_OF_WEEK,
- .standard_start_day = CAL_PROPERTY_TIMEZONE_STD_START_DAY,
- .standard_start_hour = CAL_PROPERTY_TIMEZONE_STD_START_HOUR,
- .standard_bias = CAL_PROPERTY_TIMEZONE_STANDARD_BIAS,
- .day_light_name = CAL_PROPERTY_TIMEZONE_DAY_LIGHT_NAME,
- .day_light_start_month = CAL_PROPERTY_TIMEZONE_DAY_LIGHT_START_MONTH,
- .day_light_start_position_of_week = CAL_PROPERTY_TIMEZONE_DAY_LIGHT_START_POSITION_OF_WEEK,
- .day_light_start_day = CAL_PROPERTY_TIMEZONE_DAY_LIGHT_START_DAY,
- .day_light_start_hour = CAL_PROPERTY_TIMEZONE_DAY_LIGHT_START_HOUR,
- .day_light_bias = CAL_PROPERTY_TIMEZONE_DAY_LIGHT_BIAS,
+ ._uri = CALENDAR_VIEW_TIMEZONE,
+ .id = CAL_PROPERTY_TIMEZONE_ID,
+ .calendar_book_id = CAL_PROPERTY_TIMEZONE_CALENDAR_ID,
+ .tz_offset_from_gmt = CAL_PROPERTY_TIMEZONE_TZ_OFFSET_FROM_GMT,
+ .standard_name = CAL_PROPERTY_TIMEZONE_STANDARD_NAME,
+ .standard_start_month = CAL_PROPERTY_TIMEZONE_STD_START_MONTH,
+ .standard_start_position_of_week = CAL_PROPERTY_TIMEZONE_STD_START_POSITION_OF_WEEK,
+ .standard_start_day = CAL_PROPERTY_TIMEZONE_STD_START_DAY,
+ .standard_start_hour = CAL_PROPERTY_TIMEZONE_STD_START_HOUR,
+ .standard_bias = CAL_PROPERTY_TIMEZONE_STANDARD_BIAS,
+ .day_light_name = CAL_PROPERTY_TIMEZONE_DAY_LIGHT_NAME,
+ .day_light_start_month = CAL_PROPERTY_TIMEZONE_DAY_LIGHT_START_MONTH,
+ .day_light_start_position_of_week = CAL_PROPERTY_TIMEZONE_DAY_LIGHT_START_POSITION_OF_WEEK,
+ .day_light_start_day = CAL_PROPERTY_TIMEZONE_DAY_LIGHT_START_DAY,
+ .day_light_start_hour = CAL_PROPERTY_TIMEZONE_DAY_LIGHT_START_HOUR,
+ .day_light_bias = CAL_PROPERTY_TIMEZONE_DAY_LIGHT_BIAS
};
+
API const _calendar_attendee_property_ids _calendar_attendee =
{
- ._uri = CALENDAR_VIEW_ATTENDEE,
- .event_id = CAL_PROPERTY_ATTENDEE_EVENT_ID,
- .number = CAL_PROPERTY_ATTENDEE_NUMBER,
- .type = CAL_PROPERTY_ATTENDEE_TYPE,
- .person_id = CAL_PROPERTY_ATTENDEE_CT_INDEX,
- .uid = CAL_PROPERTY_ATTENDEE_UID,
- .group = CAL_PROPERTY_ATTENDEE_GROUP,
- .email = CAL_PROPERTY_ATTENDEE_EMAIL,
- .role = CAL_PROPERTY_ATTENDEE_ROLE,
- .status = CAL_PROPERTY_ATTENDEE_STATUS,
- .rsvp = CAL_PROPERTY_ATTENDEE_RSVP,
- .delegate_uri = CAL_PROPERTY_ATTENDEE_DELEGATE_URI,
- .delegator_uri = CAL_PROPERTY_ATTENDEE_DELEGATOR_URI,
- .name = CAL_PROPERTY_ATTENDEE_NAME
+ ._uri = CALENDAR_VIEW_ATTENDEE,
+ .parent_id = CAL_PROPERTY_ATTENDEE_PARENT_ID,
+ .number = CAL_PROPERTY_ATTENDEE_NUMBER,
+ .cutype = CAL_PROPERTY_ATTENDEE_CUTYPE,
+ .person_id = CAL_PROPERTY_ATTENDEE_CT_INDEX,
+ .uid = CAL_PROPERTY_ATTENDEE_UID,
+ .group = CAL_PROPERTY_ATTENDEE_GROUP,
+ .email = CAL_PROPERTY_ATTENDEE_EMAIL,
+ .role = CAL_PROPERTY_ATTENDEE_ROLE,
+ .status = CAL_PROPERTY_ATTENDEE_STATUS,
+ .rsvp = CAL_PROPERTY_ATTENDEE_RSVP,
+ .delegatee_uri = CAL_PROPERTY_ATTENDEE_DELEGATEE_URI,
+ .delegator_uri = CAL_PROPERTY_ATTENDEE_DELEGATOR_URI,
+ .name = CAL_PROPERTY_ATTENDEE_NAME,
+ .member = CAL_PROPERTY_ATTENDEE_MEMBER
};
+
API const _calendar_alarm_property_ids _calendar_alarm =
{
- ._uri = CALENDAR_VIEW_ALARM,
- .event_id = CAL_PROPERTY_ALARM_EVENT_TODO_ID,
- .todo_id = CAL_PROPERTY_ALARM_EVENT_TODO_ID,
- .type = CAL_PROPERTY_ALARM_TYPE,
- .time = CAL_PROPERTY_ALARM_TIME,
- .tick = CAL_PROPERTY_ALARM_TICK,
- .tick_unit = CAL_PROPERTY_ALARM_TICK_UNIT,
- .tone = CAL_PROPERTY_ALARM_TONE,
- .description = CAL_PROPERTY_ALARM_DESCRIPTION,
- .alarm_id = CAL_PROPERTY_ALARM_ID
-};
-API const _calendar_instance_normal_property_ids _calendar_instance_normal =
-{
- ._uri = CALENDAR_VIEW_INSTANCE_NORMAL,
- .event_id = CAL_PROPERTY_INSTANCE_NORMAL_EVENT_ID,
- .start_time = CAL_PROPERTY_INSTANCE_NORMAL_START,
- .end_time = CAL_PROPERTY_INSTANCE_NORMAL_END,
- .summary = CAL_PROPERTY_INSTANCE_NORMAL_SUMMARY,
- .location = CAL_PROPERTY_INSTANCE_NORMAL_LOCATION,
- .calendar_book_id = CAL_PROPERTY_INSTANCE_NORMAL_CALENDAR_ID,
- .description = CAL_PROPERTY_INSTANCE_NORMAL_DESCRIPTION,
- .busy_status = CAL_PROPERTY_INSTANCE_NORMAL_BUSY_STATUS,
- .event_status = CAL_PROPERTY_INSTANCE_NORMAL_EVENT_STATUS,
- .priority = CAL_PROPERTY_INSTANCE_NORMAL_PRIORITY,
- .sensitivity = CAL_PROPERTY_INSTANCE_NORMAL_SENSITIVITY,
- .has_rrule = CAL_PROPERTY_INSTANCE_NORMAL_HAS_RRULE,
- .latitude = CAL_PROPERTY_INSTANCE_NORMAL_LATITUDE,
- .longitude = CAL_PROPERTY_INSTANCE_NORMAL_LONGITUDE,
- .has_alarm = CAL_PROPERTY_INSTANCE_NORMAL_HAS_ALARM,
- .original_event_id = CAL_PROPERTY_INSTANCE_NORMAL_ORIGINAL_EVENT_ID,
- .last_modified_time = CAL_PROPERTY_INSTANCE_NORMAL_LAST_MODIFIED_TIME
-};
-API const _calendar_instance_allday_property_ids _calendar_instance_allday =
-{
- ._uri = CALENDAR_VIEW_INSTANCE_ALLDAY,
- .event_id = CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_ID,
- .start_time = CAL_PROPERTY_INSTANCE_ALLDAY_START,
- .end_time = CAL_PROPERTY_INSTANCE_ALLDAY_END,
- .summary = CAL_PROPERTY_INSTANCE_ALLDAY_SUMMARY,
- .location = CAL_PROPERTY_INSTANCE_ALLDAY_LOCATION,
- .calendar_book_id = CAL_PROPERTY_INSTANCE_ALLDAY_CALENDAR_ID,
- .description = CAL_PROPERTY_INSTANCE_ALLDAY_DESCRIPTION,
- .busy_status = CAL_PROPERTY_INSTANCE_ALLDAY_BUSY_STATUS,
- .event_status = CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_STATUS,
- .priority = CAL_PROPERTY_INSTANCE_ALLDAY_PRIORITY,
- .sensitivity = CAL_PROPERTY_INSTANCE_ALLDAY_SENSITIVITY,
- .has_rrule = CAL_PROPERTY_INSTANCE_ALLDAY_HAS_RRULE,
- .latitude = CAL_PROPERTY_INSTANCE_ALLDAY_LATITUDE,
- .longitude = CAL_PROPERTY_INSTANCE_ALLDAY_LONGITUDE,
- .has_alarm = CAL_PROPERTY_INSTANCE_ALLDAY_HAS_ALARM,
- .original_event_id = CAL_PROPERTY_INSTANCE_ALLDAY_ORIGINAL_EVENT_ID,
- .last_modified_time = CAL_PROPERTY_INSTANCE_ALLDAY_LAST_MODIFIED_TIME
+ ._uri = CALENDAR_VIEW_ALARM,
+ .parent_id = CAL_PROPERTY_ALARM_PARENT_ID,
+ .tick = CAL_PROPERTY_ALARM_TICK,
+ .tick_unit = CAL_PROPERTY_ALARM_TICK_UNIT,
+ .description = CAL_PROPERTY_ALARM_DESCRIPTION,
+ .summary = CAL_PROPERTY_ALARM_SUMMARY,
+ .action = CAL_PROPERTY_ALARM_ACTION,
+ .attach = CAL_PROPERTY_ALARM_ATTACH,
+ .alarm_time = CAL_PROPERTY_ALARM_ALARM,
};
+
API const _calendar_updated_info_property_ids _calendar_updated_info =
{
- ._uri = CALENDAR_VIEW_UPDATED_INFO,
- .id = CAL_PROPERTY_UPDATED_INFO_ID,
- .calendar_book_id = CAL_PROPERTY_UPDATED_INFO_CALENDAR_ID,
- .modified_status = CAL_PROPERTY_UPDATED_INFO_TYPE,
- .version = CAL_PROPERTY_UPDATED_INFO_VERSION
+ ._uri = CALENDAR_VIEW_UPDATED_INFO,
+ .id = CAL_PROPERTY_UPDATED_INFO_ID,
+ .calendar_book_id = CAL_PROPERTY_UPDATED_INFO_CALENDAR_ID,
+ .modified_status = CAL_PROPERTY_UPDATED_INFO_TYPE,
+ .version = CAL_PROPERTY_UPDATED_INFO_VERSION
};
API const _calendar_event_calendar_book_property_ids _calendar_event_calendar_book =
{
- ._uri = CALENDAR_VIEW_EVENT_CALENDAR,
- .event_id = CAL_PROPERTY_EVENT_ID,
- .calendar_book_id = CAL_PROPERTY_EVENT_CALENDAR_ID,
- .summary = CAL_PROPERTY_EVENT_SUMMARY,
- .description = CAL_PROPERTY_EVENT_DESCRIPTION,
- .location = CAL_PROPERTY_EVENT_LOCATION,
- .categories = CAL_PROPERTY_EVENT_CATEGORIES,
- .exdate = CAL_PROPERTY_EVENT_EXDATE,
- .event_status = CAL_PROPERTY_EVENT_EVENT_STATUS,
- .priority = CAL_PROPERTY_EVENT_PRIORITY,
- .timezone = CAL_PROPERTY_EVENT_TIMEZONE,
- .person_id = CAL_PROPERTY_EVENT_CONTACT_ID,
- .busy_status = CAL_PROPERTY_EVENT_BUSY_STATUS,
- .sensitivity = CAL_PROPERTY_EVENT_SENSITIVITY,
- .uid = CAL_PROPERTY_EVENT_UID,
- .organizer_name = CAL_PROPERTY_EVENT_ORGANIZER_NAME,
- .organizer_email = CAL_PROPERTY_EVENT_ORGANIZER_EMAIL,
- .meeting_status = CAL_PROPERTY_EVENT_MEETING_STATUS,
- .original_event_id = CAL_PROPERTY_EVENT_ORIGINAL_EVENT_ID,
- .latitude = CAL_PROPERTY_EVENT_LATITUDE,
- .longitude = CAL_PROPERTY_EVENT_LONGITUDE,
- .email_id = CAL_PROPERTY_EVENT_EMAIL_ID,
- .created_time = CAL_PROPERTY_EVENT_CREATED_TIME,
- .last_modified_time = CAL_PROPERTY_EVENT_LAST_MODIFIED_TIME,
- .is_deleted = CAL_PROPERTY_EVENT_IS_DELETED,
- //CAL_PROPERTY_EVENT_HAS_RRULE,
- .freq = CAL_PROPERTY_EVENT_FREQ,
- .range_type = CAL_PROPERTY_EVENT_RANGE_TYPE,
- .until_time = CAL_PROPERTY_EVENT_UNTIL,
- .count = CAL_PROPERTY_EVENT_COUNT,
- .interval = CAL_PROPERTY_EVENT_INTERVAL,
- .bysecond = CAL_PROPERTY_EVENT_BYSECOND,
- .byminute = CAL_PROPERTY_EVENT_BYMINUTE,
- .byhour = CAL_PROPERTY_EVENT_BYHOUR,
- .byday = CAL_PROPERTY_EVENT_BYDAY,
- .bymonthday = CAL_PROPERTY_EVENT_BYMONTHDAY,
- .byyearday = CAL_PROPERTY_EVENT_BYYEARDAY,
- .byweekno = CAL_PROPERTY_EVENT_BYWEEKNO,
- .bymonth = CAL_PROPERTY_EVENT_BYMONTH,
- .bysetpos = CAL_PROPERTY_EVENT_BYSETPOS,
- .wkst = CAL_PROPERTY_EVENT_WKST,
- .recurrence_id = CAL_PROPERTY_EVENT_RECURRENCE_ID,
- .rdate = CAL_PROPERTY_EVENT_RDATE,
- .has_attendee = CAL_PROPERTY_EVENT_HAS_ATTENDEE,
- .has_alarm = CAL_PROPERTY_EVENT_HAS_ALARM,
- .calendar_system_type = CAL_PROPERTY_EVENT_CALENDAR_SYSTEM_TYPE,
- .sync_data1 = CAL_PROPERTY_EVENT_SYNC_DATA1,
- .sync_data2 = CAL_PROPERTY_EVENT_SYNC_DATA2,
- .sync_data3 = CAL_PROPERTY_EVENT_SYNC_DATA3,
- .sync_data4 = CAL_PROPERTY_EVENT_SYNC_DATA4,
- .start_time = CAL_PROPERTY_EVENT_START,
- .start_tzid = CAL_PROPERTY_EVENT_START_TZID,
- .end_time = CAL_PROPERTY_EVENT_END,
- .end_tzid = CAL_PROPERTY_EVENT_END_TZID,
- .is_allday = CAL_PROPERTY_EVENT_IS_ALLDAY,
- .calendar_book_visibility = CAL_PROPERTY_CALENDAR_VISIBILITY | CAL_PROPERTY_FLAGS_FILTER,
- .calendar_book_account_id = CAL_PROPERTY_CALENDAR_ACCOUNT_ID | CAL_PROPERTY_FLAGS_FILTER,
+ ._uri = CALENDAR_VIEW_EVENT_CALENDAR,
+ .event_id = CAL_PROPERTY_EVENT_ID,
+ .calendar_book_id = CAL_PROPERTY_EVENT_CALENDAR_ID,
+ .summary = CAL_PROPERTY_EVENT_SUMMARY,
+ .description = CAL_PROPERTY_EVENT_DESCRIPTION,
+ .location = CAL_PROPERTY_EVENT_LOCATION,
+ .categories = CAL_PROPERTY_EVENT_CATEGORIES,
+ .exdate = CAL_PROPERTY_EVENT_EXDATE,
+ .event_status = CAL_PROPERTY_EVENT_EVENT_STATUS,
+ .priority = CAL_PROPERTY_EVENT_PRIORITY,
+ .timezone = CAL_PROPERTY_EVENT_TIMEZONE,
+ .person_id = CAL_PROPERTY_EVENT_CONTACT_ID,
+ .busy_status = CAL_PROPERTY_EVENT_BUSY_STATUS,
+ .sensitivity = CAL_PROPERTY_EVENT_SENSITIVITY,
+ .uid = CAL_PROPERTY_EVENT_UID,
+ .organizer_name = CAL_PROPERTY_EVENT_ORGANIZER_NAME,
+ .organizer_email = CAL_PROPERTY_EVENT_ORGANIZER_EMAIL,
+ .meeting_status = CAL_PROPERTY_EVENT_MEETING_STATUS,
+ .original_event_id = CAL_PROPERTY_EVENT_ORIGINAL_EVENT_ID,
+ .latitude = CAL_PROPERTY_EVENT_LATITUDE,
+ .longitude = CAL_PROPERTY_EVENT_LONGITUDE,
+ .email_id = CAL_PROPERTY_EVENT_EMAIL_ID,
+ .created_time = CAL_PROPERTY_EVENT_CREATED_TIME,
+ .last_modified_time = CAL_PROPERTY_EVENT_LAST_MODIFIED_TIME,
+ .freq = CAL_PROPERTY_EVENT_FREQ,
+ .range_type = CAL_PROPERTY_EVENT_RANGE_TYPE,
+ .until_time = CAL_PROPERTY_EVENT_UNTIL,
+ .count = CAL_PROPERTY_EVENT_COUNT,
+ .interval = CAL_PROPERTY_EVENT_INTERVAL,
+ .bysecond = CAL_PROPERTY_EVENT_BYSECOND,
+ .byminute = CAL_PROPERTY_EVENT_BYMINUTE,
+ .byhour = CAL_PROPERTY_EVENT_BYHOUR,
+ .byday = CAL_PROPERTY_EVENT_BYDAY,
+ .bymonthday = CAL_PROPERTY_EVENT_BYMONTHDAY,
+ .byyearday = CAL_PROPERTY_EVENT_BYYEARDAY,
+ .byweekno = CAL_PROPERTY_EVENT_BYWEEKNO,
+ .bymonth = CAL_PROPERTY_EVENT_BYMONTH,
+ .bysetpos = CAL_PROPERTY_EVENT_BYSETPOS,
+ .wkst = CAL_PROPERTY_EVENT_WKST,
+ .recurrence_id = CAL_PROPERTY_EVENT_RECURRENCE_ID,
+ .rdate = CAL_PROPERTY_EVENT_RDATE,
+ .has_attendee = CAL_PROPERTY_EVENT_HAS_ATTENDEE,
+ .has_alarm = CAL_PROPERTY_EVENT_HAS_ALARM,
+ .calendar_system_type = CAL_PROPERTY_EVENT_CALENDAR_SYSTEM_TYPE,
+ .sync_data1 = CAL_PROPERTY_EVENT_SYNC_DATA1,
+ .sync_data2 = CAL_PROPERTY_EVENT_SYNC_DATA2,
+ .sync_data3 = CAL_PROPERTY_EVENT_SYNC_DATA3,
+ .sync_data4 = CAL_PROPERTY_EVENT_SYNC_DATA4,
+ .start_time = CAL_PROPERTY_EVENT_START,
+ .start_tzid = CAL_PROPERTY_EVENT_START_TZID,
+ .end_time = CAL_PROPERTY_EVENT_END,
+ .end_tzid = CAL_PROPERTY_EVENT_END_TZID,
+ .is_allday = CAL_PROPERTY_EVENT_IS_ALLDAY,
+ .calendar_book_visibility = CAL_PROPERTY_CALENDAR_VISIBILITY | CAL_PROPERTY_FLAGS_FILTER,
+ .calendar_book_account_id = CAL_PROPERTY_CALENDAR_ACCOUNT_ID | CAL_PROPERTY_FLAGS_FILTER
};
API const _calendar_todo_calendar_book_property_ids _calendar_todo_calendar_book =
{
- ._uri = CALENDAR_VIEW_TODO_CALENDAR,
- .todo_id = CAL_PROPERTY_TODO_ID,
- .calendar_book_id = CAL_PROPERTY_TODO_CALENDAR_ID,
- .summary = CAL_PROPERTY_TODO_SUMMARY,
- .description = CAL_PROPERTY_TODO_DESCRIPTION,
- .location = CAL_PROPERTY_TODO_LOCATION,
- .categories = CAL_PROPERTY_TODO_CATEGORIES,
- .todo_status = CAL_PROPERTY_TODO_TODO_STATUS,
- .priority = CAL_PROPERTY_TODO_PRIORITY,
- .sensitivity = CAL_PROPERTY_TODO_SENSITIVITY,
- .uid = CAL_PROPERTY_TODO_UID,
- .latitude = CAL_PROPERTY_TODO_LATITUDE,
- .longitude = CAL_PROPERTY_TODO_LONGITUDE,
- .created_time = CAL_PROPERTY_TODO_CREATED_TIME,
- .last_modified_time = CAL_PROPERTY_TODO_LAST_MODIFIED_TIME,
- .completed_time = CAL_PROPERTY_TODO_COMPLETED_TIME,
- .progress = CAL_PROPERTY_TODO_PROGRESS,
- .is_deleted = CAL_PROPERTY_TODO_IS_DELETED,
- //CAL_PROPERTY_TODO_HAS_RRULE,
- .freq = CAL_PROPERTY_TODO_FREQ,
- .range_type = CAL_PROPERTY_TODO_RANGE_TYPE,
- .until_time = CAL_PROPERTY_TODO_UNTIL,
- .count = CAL_PROPERTY_TODO_COUNT,
- .interval = CAL_PROPERTY_TODO_INTERVAL,
- .bysecond = CAL_PROPERTY_TODO_BYSECOND,
- .byminute = CAL_PROPERTY_TODO_BYMINUTE,
- .byhour = CAL_PROPERTY_TODO_BYHOUR,
- .byday = CAL_PROPERTY_TODO_BYDAY,
- .bymonthday = CAL_PROPERTY_TODO_BYMONTHDAY,
- .byyearday = CAL_PROPERTY_TODO_BYYEARDAY,
- .byweekno = CAL_PROPERTY_TODO_BYWEEKNO,
- .bymonth = CAL_PROPERTY_TODO_BYMONTH,
- .bysetpos = CAL_PROPERTY_TODO_BYSETPOS,
- .wkst = CAL_PROPERTY_TODO_WKST,
- .has_alarm = CAL_PROPERTY_TODO_HAS_ALARM,
- .sync_data1 = CAL_PROPERTY_TODO_SYNC_DATA1,
- .sync_data2 = CAL_PROPERTY_TODO_SYNC_DATA2,
- .sync_data3 = CAL_PROPERTY_TODO_SYNC_DATA3,
- .sync_data4 = CAL_PROPERTY_TODO_SYNC_DATA4,
- .start_time = CAL_PROPERTY_TODO_START,
- .start_tzid = CAL_PROPERTY_TODO_START_TZID,
- .due_time = CAL_PROPERTY_TODO_DUE,
- .due_tzid = CAL_PROPERTY_TODO_DUE_TZID,
- .organizer_name = CAL_PROPERTY_TODO_ORGANIZER_NAME,
- .organizer_email = CAL_PROPERTY_TODO_ORGANIZER_EMAIL,
- .has_attendee = CAL_PROPERTY_TODO_HAS_ATTENDEE,
- .is_allday = CAL_PROPERTY_TODO_IS_ALLDAY,
- .calendar_book_visibility = CAL_PROPERTY_CALENDAR_VISIBILITY | CAL_PROPERTY_FLAGS_FILTER,
- .calendar_book_account_id = CAL_PROPERTY_CALENDAR_ACCOUNT_ID | CAL_PROPERTY_FLAGS_FILTER,
+ ._uri = CALENDAR_VIEW_TODO_CALENDAR,
+ .todo_id = CAL_PROPERTY_TODO_ID,
+ .calendar_book_id = CAL_PROPERTY_TODO_CALENDAR_ID,
+ .summary = CAL_PROPERTY_TODO_SUMMARY,
+ .description = CAL_PROPERTY_TODO_DESCRIPTION,
+ .location = CAL_PROPERTY_TODO_LOCATION,
+ .categories = CAL_PROPERTY_TODO_CATEGORIES,
+ .todo_status = CAL_PROPERTY_TODO_TODO_STATUS,
+ .priority = CAL_PROPERTY_TODO_PRIORITY,
+ .sensitivity = CAL_PROPERTY_TODO_SENSITIVITY,
+ .uid = CAL_PROPERTY_TODO_UID,
+ .latitude = CAL_PROPERTY_TODO_LATITUDE,
+ .longitude = CAL_PROPERTY_TODO_LONGITUDE,
+ .created_time = CAL_PROPERTY_TODO_CREATED_TIME,
+ .last_modified_time = CAL_PROPERTY_TODO_LAST_MODIFIED_TIME,
+ .completed_time = CAL_PROPERTY_TODO_COMPLETED_TIME,
+ .progress = CAL_PROPERTY_TODO_PROGRESS,
+ .freq = CAL_PROPERTY_TODO_FREQ,
+ .range_type = CAL_PROPERTY_TODO_RANGE_TYPE,
+ .until_time = CAL_PROPERTY_TODO_UNTIL,
+ .count = CAL_PROPERTY_TODO_COUNT,
+ .interval = CAL_PROPERTY_TODO_INTERVAL,
+ .bysecond = CAL_PROPERTY_TODO_BYSECOND,
+ .byminute = CAL_PROPERTY_TODO_BYMINUTE,
+ .byhour = CAL_PROPERTY_TODO_BYHOUR,
+ .byday = CAL_PROPERTY_TODO_BYDAY,
+ .bymonthday = CAL_PROPERTY_TODO_BYMONTHDAY,
+ .byyearday = CAL_PROPERTY_TODO_BYYEARDAY,
+ .byweekno = CAL_PROPERTY_TODO_BYWEEKNO,
+ .bymonth = CAL_PROPERTY_TODO_BYMONTH,
+ .bysetpos = CAL_PROPERTY_TODO_BYSETPOS,
+ .wkst = CAL_PROPERTY_TODO_WKST,
+ .has_alarm = CAL_PROPERTY_TODO_HAS_ALARM,
+ .sync_data1 = CAL_PROPERTY_TODO_SYNC_DATA1,
+ .sync_data2 = CAL_PROPERTY_TODO_SYNC_DATA2,
+ .sync_data3 = CAL_PROPERTY_TODO_SYNC_DATA3,
+ .sync_data4 = CAL_PROPERTY_TODO_SYNC_DATA4,
+ .start_time = CAL_PROPERTY_TODO_START,
+ .start_tzid = CAL_PROPERTY_TODO_START_TZID,
+ .due_time = CAL_PROPERTY_TODO_DUE,
+ .due_tzid = CAL_PROPERTY_TODO_DUE_TZID,
+ .organizer_name = CAL_PROPERTY_TODO_ORGANIZER_NAME,
+ .organizer_email = CAL_PROPERTY_TODO_ORGANIZER_EMAIL,
+ .has_attendee = CAL_PROPERTY_TODO_HAS_ATTENDEE,
+ .is_allday = CAL_PROPERTY_TODO_IS_ALLDAY,
+ .calendar_book_visibility = CAL_PROPERTY_CALENDAR_VISIBILITY | CAL_PROPERTY_FLAGS_FILTER,
+ .calendar_book_account_id = CAL_PROPERTY_CALENDAR_ACCOUNT_ID | CAL_PROPERTY_FLAGS_FILTER
};
API const _calendar_event_calendar_book_attendee_property_ids _calendar_event_calendar_book_attendee =
{
- ._uri = CALENDAR_VIEW_EVENT_CALENDAR_ATTENDEE,
- .event_id = CAL_PROPERTY_EVENT_ID,
- .calendar_book_id = CAL_PROPERTY_EVENT_CALENDAR_ID,
- .summary = CAL_PROPERTY_EVENT_SUMMARY,
- .description = CAL_PROPERTY_EVENT_DESCRIPTION,
- .location = CAL_PROPERTY_EVENT_LOCATION,
- .categories = CAL_PROPERTY_EVENT_CATEGORIES,
- .exdate = CAL_PROPERTY_EVENT_EXDATE,
- .event_status = CAL_PROPERTY_EVENT_EVENT_STATUS,
- .priority = CAL_PROPERTY_EVENT_PRIORITY,
- .timezone = CAL_PROPERTY_EVENT_TIMEZONE,
- .person_id = CAL_PROPERTY_EVENT_CONTACT_ID,
- .busy_status = CAL_PROPERTY_EVENT_BUSY_STATUS,
- .sensitivity = CAL_PROPERTY_EVENT_SENSITIVITY,
- .uid = CAL_PROPERTY_EVENT_UID,
- .organizer_name = CAL_PROPERTY_EVENT_ORGANIZER_NAME,
- .organizer_email = CAL_PROPERTY_EVENT_ORGANIZER_EMAIL,
- .meeting_status = CAL_PROPERTY_EVENT_MEETING_STATUS,
- .original_event_id = CAL_PROPERTY_EVENT_ORIGINAL_EVENT_ID,
- .latitude = CAL_PROPERTY_EVENT_LATITUDE,
- .longitude = CAL_PROPERTY_EVENT_LONGITUDE,
- .email_id = CAL_PROPERTY_EVENT_EMAIL_ID,
- .created_time = CAL_PROPERTY_EVENT_CREATED_TIME,
- .last_modified_time = CAL_PROPERTY_EVENT_LAST_MODIFIED_TIME,
- .is_deleted = CAL_PROPERTY_EVENT_IS_DELETED,
- //CAL_PROPERTY_EVENT_HAS_RRULE,
- .freq = CAL_PROPERTY_EVENT_FREQ,
- .range_type = CAL_PROPERTY_EVENT_RANGE_TYPE,
- .until_time = CAL_PROPERTY_EVENT_UNTIL,
- .count = CAL_PROPERTY_EVENT_COUNT,
- .interval = CAL_PROPERTY_EVENT_INTERVAL,
- .bysecond = CAL_PROPERTY_EVENT_BYSECOND,
- .byminute = CAL_PROPERTY_EVENT_BYMINUTE,
- .byhour = CAL_PROPERTY_EVENT_BYHOUR,
- .byday = CAL_PROPERTY_EVENT_BYDAY,
- .bymonthday = CAL_PROPERTY_EVENT_BYMONTHDAY,
- .byyearday = CAL_PROPERTY_EVENT_BYYEARDAY,
- .byweekno = CAL_PROPERTY_EVENT_BYWEEKNO,
- .bymonth = CAL_PROPERTY_EVENT_BYMONTH,
- .bysetpos = CAL_PROPERTY_EVENT_BYSETPOS,
- .wkst = CAL_PROPERTY_EVENT_WKST,
- .recurrence_id = CAL_PROPERTY_EVENT_RECURRENCE_ID,
- .rdate = CAL_PROPERTY_EVENT_RDATE,
- .has_attendee = CAL_PROPERTY_EVENT_HAS_ATTENDEE,
- .has_alarm = CAL_PROPERTY_EVENT_HAS_ALARM,
- .calendar_system_type = CAL_PROPERTY_EVENT_CALENDAR_SYSTEM_TYPE,
- .sync_data1 = CAL_PROPERTY_EVENT_SYNC_DATA1,
- .sync_data2 = CAL_PROPERTY_EVENT_SYNC_DATA2,
- .sync_data3 = CAL_PROPERTY_EVENT_SYNC_DATA3,
- .sync_data4 = CAL_PROPERTY_EVENT_SYNC_DATA4,
- .start_time = CAL_PROPERTY_EVENT_START,
- .start_tzid = CAL_PROPERTY_EVENT_START_TZID,
- .end_time = CAL_PROPERTY_EVENT_END,
- .end_tzid = CAL_PROPERTY_EVENT_END_TZID,
- .is_allday = CAL_PROPERTY_EVENT_IS_ALLDAY,
- .calendar_book_visibility = CAL_PROPERTY_CALENDAR_VISIBILITY | CAL_PROPERTY_FLAGS_FILTER,
- .calendar_book_account_id = CAL_PROPERTY_CALENDAR_ACCOUNT_ID | CAL_PROPERTY_FLAGS_FILTER,
- .attendee_email = CAL_PROPERTY_ATTENDEE_EMAIL | CAL_PROPERTY_FLAGS_FILTER,
- .attendee_name = CAL_PROPERTY_ATTENDEE_NAME | CAL_PROPERTY_FLAGS_FILTER
+ ._uri = CALENDAR_VIEW_EVENT_CALENDAR_ATTENDEE,
+ .event_id = CAL_PROPERTY_EVENT_ID,
+ .calendar_book_id = CAL_PROPERTY_EVENT_CALENDAR_ID,
+ .summary = CAL_PROPERTY_EVENT_SUMMARY,
+ .description = CAL_PROPERTY_EVENT_DESCRIPTION,
+ .location = CAL_PROPERTY_EVENT_LOCATION,
+ .categories = CAL_PROPERTY_EVENT_CATEGORIES,
+ .exdate = CAL_PROPERTY_EVENT_EXDATE,
+ .event_status = CAL_PROPERTY_EVENT_EVENT_STATUS,
+ .priority = CAL_PROPERTY_EVENT_PRIORITY,
+ .timezone = CAL_PROPERTY_EVENT_TIMEZONE,
+ .person_id = CAL_PROPERTY_EVENT_CONTACT_ID,
+ .busy_status = CAL_PROPERTY_EVENT_BUSY_STATUS,
+ .sensitivity = CAL_PROPERTY_EVENT_SENSITIVITY,
+ .uid = CAL_PROPERTY_EVENT_UID,
+ .organizer_name = CAL_PROPERTY_EVENT_ORGANIZER_NAME,
+ .organizer_email = CAL_PROPERTY_EVENT_ORGANIZER_EMAIL,
+ .meeting_status = CAL_PROPERTY_EVENT_MEETING_STATUS,
+ .original_event_id = CAL_PROPERTY_EVENT_ORIGINAL_EVENT_ID,
+ .latitude = CAL_PROPERTY_EVENT_LATITUDE,
+ .longitude = CAL_PROPERTY_EVENT_LONGITUDE,
+ .email_id = CAL_PROPERTY_EVENT_EMAIL_ID,
+ .created_time = CAL_PROPERTY_EVENT_CREATED_TIME,
+ .last_modified_time = CAL_PROPERTY_EVENT_LAST_MODIFIED_TIME,
+ .freq = CAL_PROPERTY_EVENT_FREQ,
+ .range_type = CAL_PROPERTY_EVENT_RANGE_TYPE,
+ .until_time = CAL_PROPERTY_EVENT_UNTIL,
+ .count = CAL_PROPERTY_EVENT_COUNT,
+ .interval = CAL_PROPERTY_EVENT_INTERVAL,
+ .bysecond = CAL_PROPERTY_EVENT_BYSECOND,
+ .byminute = CAL_PROPERTY_EVENT_BYMINUTE,
+ .byhour = CAL_PROPERTY_EVENT_BYHOUR,
+ .byday = CAL_PROPERTY_EVENT_BYDAY,
+ .bymonthday = CAL_PROPERTY_EVENT_BYMONTHDAY,
+ .byyearday = CAL_PROPERTY_EVENT_BYYEARDAY,
+ .byweekno = CAL_PROPERTY_EVENT_BYWEEKNO,
+ .bymonth = CAL_PROPERTY_EVENT_BYMONTH,
+ .bysetpos = CAL_PROPERTY_EVENT_BYSETPOS,
+ .wkst = CAL_PROPERTY_EVENT_WKST,
+ .recurrence_id = CAL_PROPERTY_EVENT_RECURRENCE_ID,
+ .rdate = CAL_PROPERTY_EVENT_RDATE,
+ .has_attendee = CAL_PROPERTY_EVENT_HAS_ATTENDEE,
+ .has_alarm = CAL_PROPERTY_EVENT_HAS_ALARM,
+ .calendar_system_type = CAL_PROPERTY_EVENT_CALENDAR_SYSTEM_TYPE,
+ .sync_data1 = CAL_PROPERTY_EVENT_SYNC_DATA1,
+ .sync_data2 = CAL_PROPERTY_EVENT_SYNC_DATA2,
+ .sync_data3 = CAL_PROPERTY_EVENT_SYNC_DATA3,
+ .sync_data4 = CAL_PROPERTY_EVENT_SYNC_DATA4,
+ .start_time = CAL_PROPERTY_EVENT_START,
+ .start_tzid = CAL_PROPERTY_EVENT_START_TZID,
+ .end_time = CAL_PROPERTY_EVENT_END,
+ .end_tzid = CAL_PROPERTY_EVENT_END_TZID,
+ .is_allday = CAL_PROPERTY_EVENT_IS_ALLDAY,
+ .calendar_book_visibility = CAL_PROPERTY_CALENDAR_VISIBILITY | CAL_PROPERTY_FLAGS_FILTER,
+ .calendar_book_account_id = CAL_PROPERTY_CALENDAR_ACCOUNT_ID | CAL_PROPERTY_FLAGS_FILTER,
+ .attendee_email = CAL_PROPERTY_ATTENDEE_EMAIL | CAL_PROPERTY_FLAGS_FILTER,
+ .attendee_name = CAL_PROPERTY_ATTENDEE_NAME | CAL_PROPERTY_FLAGS_FILTER,
+ .attendee_member = CAL_PROPERTY_ATTENDEE_MEMBER | CAL_PROPERTY_FLAGS_FILTER
+};
+
+API const _calendar_instance_utime_calendar_book_property_ids _calendar_instance_utime_calendar_book =
+{
+ ._uri = CALENDAR_VIEW_INSTANCE_UTIME_CALENDAR,
+ .event_id = CAL_PROPERTY_INSTANCE_NORMAL_EVENT_ID,
+ .start_time = CAL_PROPERTY_INSTANCE_NORMAL_START,
+ .end_time = CAL_PROPERTY_INSTANCE_NORMAL_END,
+ .summary = CAL_PROPERTY_INSTANCE_NORMAL_SUMMARY,
+ .location = CAL_PROPERTY_INSTANCE_NORMAL_LOCATION,
+ .calendar_book_id = CAL_PROPERTY_INSTANCE_NORMAL_CALENDAR_ID,
+ .description = CAL_PROPERTY_INSTANCE_NORMAL_DESCRIPTION,
+ .busy_status = CAL_PROPERTY_INSTANCE_NORMAL_BUSY_STATUS,
+ .event_status = CAL_PROPERTY_INSTANCE_NORMAL_EVENT_STATUS,
+ .priority = CAL_PROPERTY_INSTANCE_NORMAL_PRIORITY,
+ .sensitivity = CAL_PROPERTY_INSTANCE_NORMAL_SENSITIVITY,
+ .has_rrule = CAL_PROPERTY_INSTANCE_NORMAL_HAS_RRULE,
+ .latitude = CAL_PROPERTY_INSTANCE_NORMAL_LATITUDE,
+ .longitude = CAL_PROPERTY_INSTANCE_NORMAL_LONGITUDE,
+ .has_alarm = CAL_PROPERTY_INSTANCE_NORMAL_HAS_ALARM,
+ .original_event_id = CAL_PROPERTY_INSTANCE_NORMAL_ORIGINAL_EVENT_ID,
+ .calendar_book_visibility = CAL_PROPERTY_CALENDAR_VISIBILITY | CAL_PROPERTY_FLAGS_FILTER,
+ .calendar_book_account_id = CAL_PROPERTY_CALENDAR_ACCOUNT_ID | CAL_PROPERTY_FLAGS_FILTER,
+ .last_modified_time = CAL_PROPERTY_INSTANCE_NORMAL_LAST_MODIFIED_TIME,
+ .sync_data1 = CAL_PROPERTY_INSTANCE_NORMAL_SYNC_DATA1
};
-API const _calendar_instance_normal_calendar_book_property_ids _calendar_instance_normal_calendar_book =
+API const _calendar_instance_localtime_calendar_book_property_ids _calendar_instance_localtime_calendar_book =
{
- ._uri = CALENDAR_VIEW_INSTANCE_NORMAL_CALENDAR,
- .event_id = CAL_PROPERTY_INSTANCE_NORMAL_EVENT_ID,
- .start_time = CAL_PROPERTY_INSTANCE_NORMAL_START,
- .end_time = CAL_PROPERTY_INSTANCE_NORMAL_END,
- .summary = CAL_PROPERTY_INSTANCE_NORMAL_SUMMARY,
- .location = CAL_PROPERTY_INSTANCE_NORMAL_LOCATION,
- .calendar_book_id = CAL_PROPERTY_INSTANCE_NORMAL_CALENDAR_ID,
- .description = CAL_PROPERTY_INSTANCE_NORMAL_DESCRIPTION,
- .busy_status = CAL_PROPERTY_INSTANCE_NORMAL_BUSY_STATUS,
- .event_status = CAL_PROPERTY_INSTANCE_NORMAL_EVENT_STATUS,
- .priority = CAL_PROPERTY_INSTANCE_NORMAL_PRIORITY,
- .sensitivity = CAL_PROPERTY_INSTANCE_NORMAL_SENSITIVITY,
- .has_rrule = CAL_PROPERTY_INSTANCE_NORMAL_HAS_RRULE,
- .latitude = CAL_PROPERTY_INSTANCE_NORMAL_LATITUDE,
- .longitude = CAL_PROPERTY_INSTANCE_NORMAL_LONGITUDE,
- .has_alarm = CAL_PROPERTY_INSTANCE_NORMAL_HAS_ALARM,
- .original_event_id = CAL_PROPERTY_INSTANCE_NORMAL_ORIGINAL_EVENT_ID,
- .calendar_book_visibility = CAL_PROPERTY_CALENDAR_VISIBILITY | CAL_PROPERTY_FLAGS_FILTER,
- .calendar_book_account_id = CAL_PROPERTY_CALENDAR_ACCOUNT_ID | CAL_PROPERTY_FLAGS_FILTER,
- .last_modified_time = CAL_PROPERTY_INSTANCE_NORMAL_LAST_MODIFIED_TIME
+ ._uri = CALENDAR_VIEW_INSTANCE_LOCALTIME_CALENDAR,
+ .event_id = CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_ID,
+ .start_time = CAL_PROPERTY_INSTANCE_ALLDAY_START,
+ .end_time = CAL_PROPERTY_INSTANCE_ALLDAY_END,
+ .summary = CAL_PROPERTY_INSTANCE_ALLDAY_SUMMARY,
+ .location = CAL_PROPERTY_INSTANCE_ALLDAY_LOCATION,
+ .calendar_book_id = CAL_PROPERTY_INSTANCE_ALLDAY_CALENDAR_ID,
+ .description = CAL_PROPERTY_INSTANCE_ALLDAY_DESCRIPTION,
+ .busy_status = CAL_PROPERTY_INSTANCE_ALLDAY_BUSY_STATUS,
+ .event_status = CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_STATUS,
+ .priority = CAL_PROPERTY_INSTANCE_ALLDAY_PRIORITY,
+ .sensitivity = CAL_PROPERTY_INSTANCE_ALLDAY_SENSITIVITY,
+ .has_rrule = CAL_PROPERTY_INSTANCE_ALLDAY_HAS_RRULE,
+ .latitude = CAL_PROPERTY_INSTANCE_ALLDAY_LATITUDE,
+ .longitude = CAL_PROPERTY_INSTANCE_ALLDAY_LONGITUDE,
+ .has_alarm = CAL_PROPERTY_INSTANCE_ALLDAY_HAS_ALARM,
+ .original_event_id = CAL_PROPERTY_INSTANCE_ALLDAY_ORIGINAL_EVENT_ID,
+ .calendar_book_visibility = CAL_PROPERTY_CALENDAR_VISIBILITY | CAL_PROPERTY_FLAGS_FILTER,
+ .calendar_book_account_id = CAL_PROPERTY_CALENDAR_ACCOUNT_ID | CAL_PROPERTY_FLAGS_FILTER,
+ .last_modified_time = CAL_PROPERTY_INSTANCE_ALLDAY_LAST_MODIFIED_TIME,
+ .sync_data1 = CAL_PROPERTY_INSTANCE_ALLDAY_SYNC_DATA1,
+ .is_allday = CAL_PROPERTY_INSTANCE_ALLDAY_IS_ALLDAY
};
-API const _calendar_instance_allday_calendar_book_property_ids _calendar_instance_allday_calendar_book =
+API const _calendar_instance_utime_calendar_book_extended_property_ids _calendar_instance_utime_calendar_book_extended =
{
- ._uri = CALENDAR_VIEW_INSTANCE_ALLDAY_CALENDAR,
- .event_id = CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_ID,
- .start_time = CAL_PROPERTY_INSTANCE_ALLDAY_START,
- .end_time = CAL_PROPERTY_INSTANCE_ALLDAY_END,
- .summary = CAL_PROPERTY_INSTANCE_ALLDAY_SUMMARY,
- .location = CAL_PROPERTY_INSTANCE_ALLDAY_LOCATION,
- .calendar_book_id = CAL_PROPERTY_INSTANCE_ALLDAY_CALENDAR_ID,
- .description = CAL_PROPERTY_INSTANCE_ALLDAY_DESCRIPTION,
- .busy_status = CAL_PROPERTY_INSTANCE_ALLDAY_BUSY_STATUS,
- .event_status = CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_STATUS,
- .priority = CAL_PROPERTY_INSTANCE_ALLDAY_PRIORITY,
- .sensitivity = CAL_PROPERTY_INSTANCE_ALLDAY_SENSITIVITY,
- .has_rrule = CAL_PROPERTY_INSTANCE_ALLDAY_HAS_RRULE,
- .latitude = CAL_PROPERTY_INSTANCE_ALLDAY_LATITUDE,
- .longitude = CAL_PROPERTY_INSTANCE_ALLDAY_LONGITUDE,
- .has_alarm = CAL_PROPERTY_INSTANCE_ALLDAY_HAS_ALARM,
- .original_event_id = CAL_PROPERTY_INSTANCE_ALLDAY_ORIGINAL_EVENT_ID,
- .calendar_book_visibility = CAL_PROPERTY_CALENDAR_VISIBILITY | CAL_PROPERTY_FLAGS_FILTER,
- .calendar_book_account_id = CAL_PROPERTY_CALENDAR_ACCOUNT_ID | CAL_PROPERTY_FLAGS_FILTER,
- .last_modified_time = CAL_PROPERTY_INSTANCE_ALLDAY_LAST_MODIFIED_TIME
+ ._uri = CALENDAR_VIEW_INSTANCE_UTIME_CALENDAR_EXTENDED,
+ .event_id = CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_EVENT_ID,
+ .start_time = CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_START,
+ .end_time = CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_END,
+ .summary = CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SUMMARY,
+ .location = CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LOCATION,
+ .calendar_book_id = CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_CALENDAR_ID,
+ .description = CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_DESCRIPTION,
+ .busy_status = CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_BUSY_STATUS,
+ .event_status = CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_EVENT_STATUS,
+ .priority = CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_PRIORITY,
+ .sensitivity = CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SENSITIVITY,
+ .has_rrule = CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_HAS_RRULE,
+ .latitude = CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LATITUDE,
+ .longitude = CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LONGITUDE,
+ .has_alarm = CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_HAS_ALARM,
+ .original_event_id = CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_ORIGINAL_EVENT_ID,
+ .calendar_book_visibility = CAL_PROPERTY_CALENDAR_VISIBILITY | CAL_PROPERTY_FLAGS_FILTER,
+ .calendar_book_account_id = CAL_PROPERTY_CALENDAR_ACCOUNT_ID | CAL_PROPERTY_FLAGS_FILTER,
+ .last_modified_time = CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LAST_MODIFIED_TIME,
+ .sync_data1 = CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA1,
+ .organizer_name = CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_ORGANIZER_NAME,
+ .categories = CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_CATEGORIES,
+ .has_attendee = CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_HAS_ATTENDEE,
+ .sync_data2 = CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA2,
+ .sync_data3 = CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA3,
+ .sync_data4 = CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA4
+};
+
+API const _calendar_instance_localtime_calendar_book_extended_property_ids _calendar_instance_localtime_calendar_book_extended =
+{
+ ._uri = CALENDAR_VIEW_INSTANCE_LOCALTIME_CALENDAR_EXTENDED,
+ .event_id = CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_EVENT_ID,
+ .start_time = CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_START,
+ .end_time = CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_END,
+ .summary = CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SUMMARY,
+ .location = CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_LOCATION,
+ .calendar_book_id = CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_CALENDAR_ID,
+ .description = CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_DESCRIPTION,
+ .busy_status = CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_BUSY_STATUS,
+ .event_status = CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_EVENT_STATUS,
+ .priority = CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_PRIORITY,
+ .sensitivity = CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SENSITIVITY,
+ .has_rrule = CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_HAS_RRULE,
+ .latitude = CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_LATITUDE,
+ .longitude = CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_LONGITUDE,
+ .has_alarm = CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_HAS_ALARM,
+ .original_event_id = CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_ORIGINAL_EVENT_ID,
+ .calendar_book_visibility = CAL_PROPERTY_CALENDAR_VISIBILITY | CAL_PROPERTY_FLAGS_FILTER,
+ .calendar_book_account_id = CAL_PROPERTY_CALENDAR_ACCOUNT_ID | CAL_PROPERTY_FLAGS_FILTER,
+ .last_modified_time = CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_LAST_MODIFIED_TIME,
+ .sync_data1 = CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA1,
+ .organizer_name= CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_ORGANIZER_NAME,
+ .categories = CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_CATEGORIES,
+ .has_attendee = CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_HAS_ATTENDEE,
+ .sync_data2 = CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA2,
+ .sync_data3 = CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA3,
+ .sync_data4 = CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA4,
+ .is_allday = CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_IS_ALLDAY
};
API const _calendar_extended_property_property_ids _calendar_extended_property =
{
- ._uri = CALENDAR_VIEW_EXTENDED,
- .id = CAL_PROPERTY_EXTENDED_ID,
- .record_id = CAL_PROPERTY_EXTENDED_RECORD_ID,
- .record_type = CAL_PROPERTY_EXTENDED_RECORD_TYPE,
- .key = CAL_PROPERTY_EXTENDED_KEY,
- .value = CAL_PROPERTY_EXTENDED_VALUE
+ ._uri = CALENDAR_VIEW_EXTENDED,
+ .id = CAL_PROPERTY_EXTENDED_ID,
+ .record_id = CAL_PROPERTY_EXTENDED_RECORD_ID,
+ .record_type = CAL_PROPERTY_EXTENDED_RECORD_TYPE,
+ .key = CAL_PROPERTY_EXTENDED_KEY,
+ .value = CAL_PROPERTY_EXTENDED_VALUE
};
//////////////////////
// cal_property_info_s
const cal_property_info_s __property_calendar_book[] = {
- {CAL_PROPERTY_CALENDAR_ID , "id"},
- {CAL_PROPERTY_CALENDAR_UID , "uid"},
- {CAL_PROPERTY_CALENDAR_NAME , "name"},
- {CAL_PROPERTY_CALENDAR_DESCRIPTION , "description"},
- {CAL_PROPERTY_CALENDAR_COLOR , "color"},
- {CAL_PROPERTY_CALENDAR_LOCATION , "location"},
- {CAL_PROPERTY_CALENDAR_VISIBILITY , "visibility"},
- {CAL_PROPERTY_CALENDAR_SYNC_EVENT , "sync_event"},
- {CAL_PROPERTY_CALENDAR_IS_DELETED , "is_deleted"},
- {CAL_PROPERTY_CALENDAR_ACCOUNT_ID , "account_id"},
- {CAL_PROPERTY_CALENDAR_STORE_TYPE , "store_type"},
- {CAL_PROPERTY_CALENDAR_SYNC_DATA1 , "sync_data1"},
- {CAL_PROPERTY_CALENDAR_SYNC_DATA2 , "sync_data2"},
- {CAL_PROPERTY_CALENDAR_SYNC_DATA3 , "sync_data3"},
- {CAL_PROPERTY_CALENDAR_SYNC_DATA4 , "sync_data4"},
+ {CAL_PROPERTY_CALENDAR_ID , "id"},
+ {CAL_PROPERTY_CALENDAR_UID , "uid"},
+ {CAL_PROPERTY_CALENDAR_NAME , "name"},
+ {CAL_PROPERTY_CALENDAR_DESCRIPTION , "description"},
+ {CAL_PROPERTY_CALENDAR_COLOR , "color"},
+ {CAL_PROPERTY_CALENDAR_LOCATION , "location"},
+ {CAL_PROPERTY_CALENDAR_VISIBILITY , "visibility"},
+ {CAL_PROPERTY_CALENDAR_SYNC_EVENT , "sync_event"},
+ {CAL_PROPERTY_CALENDAR_ACCOUNT_ID , "account_id"},
+ {CAL_PROPERTY_CALENDAR_STORE_TYPE , "store_type"},
+ {CAL_PROPERTY_CALENDAR_SYNC_DATA1 , "sync_data1"},
+ {CAL_PROPERTY_CALENDAR_SYNC_DATA2 , "sync_data2"},
+ {CAL_PROPERTY_CALENDAR_SYNC_DATA3 , "sync_data3"},
+ {CAL_PROPERTY_CALENDAR_SYNC_DATA4 , "sync_data4"},
+ {CAL_PROPERTY_CALENDAR_MODE, "mode"},
};
const cal_property_info_s __property_event[] =
{
- {CAL_PROPERTY_EVENT_ID, "id"},
- {CAL_PROPERTY_EVENT_CALENDAR_ID, "calendar_id"},
- {CAL_PROPERTY_EVENT_SUMMARY, "summary"},
- {CAL_PROPERTY_EVENT_DESCRIPTION, "description"},
- {CAL_PROPERTY_EVENT_LOCATION, "location"},
- {CAL_PROPERTY_EVENT_CATEGORIES, "categories"},
- {CAL_PROPERTY_EVENT_EXDATE, "exdate"},
- {CAL_PROPERTY_EVENT_EVENT_STATUS, "task_status"},
- {CAL_PROPERTY_EVENT_PRIORITY, "priority"},
- {CAL_PROPERTY_EVENT_TIMEZONE, "timezone"},
- {CAL_PROPERTY_EVENT_CONTACT_ID, "contact_id"},
- {CAL_PROPERTY_EVENT_BUSY_STATUS, "busy_status"},
- {CAL_PROPERTY_EVENT_SENSITIVITY, "sensitivity"},
- {CAL_PROPERTY_EVENT_UID, "uid"},
- {CAL_PROPERTY_EVENT_ORGANIZER_NAME, "organizer_name"},
- {CAL_PROPERTY_EVENT_ORGANIZER_EMAIL, "organizer_email"},
- {CAL_PROPERTY_EVENT_MEETING_STATUS, "meeting_status"},
- {CAL_PROPERTY_EVENT_ORIGINAL_EVENT_ID, "original_event_id"},
- {CAL_PROPERTY_EVENT_LATITUDE, "latitude"},
- {CAL_PROPERTY_EVENT_LONGITUDE, "longitude"},
- {CAL_PROPERTY_EVENT_EMAIL_ID, "email_id"},
- {CAL_PROPERTY_EVENT_CREATED_TIME, "created_time"},
- {CAL_PROPERTY_EVENT_LAST_MODIFIED_TIME, "last_mod"},
- {CAL_PROPERTY_EVENT_IS_DELETED, "is_deleted"},
- {CAL_PROPERTY_EVENT_FREQ, "freq"},
- {CAL_PROPERTY_EVENT_RANGE_TYPE, "range_type"},
- {CAL_PROPERTY_EVENT_UNTIL, "until_type, until_utime, until_datetime"},
- {CAL_PROPERTY_EVENT_COUNT, "count"},
- {CAL_PROPERTY_EVENT_INTERVAL, "interval"},
- {CAL_PROPERTY_EVENT_BYSECOND, "bysecond"},
- {CAL_PROPERTY_EVENT_BYMINUTE, "byminute"},
- {CAL_PROPERTY_EVENT_BYHOUR, "byhour"},
- {CAL_PROPERTY_EVENT_BYDAY, "byday"},
- {CAL_PROPERTY_EVENT_BYMONTHDAY, "bymonthday"},
- {CAL_PROPERTY_EVENT_BYYEARDAY, "byyearday"},
- {CAL_PROPERTY_EVENT_BYWEEKNO, "byweekno"},
- {CAL_PROPERTY_EVENT_BYMONTH, "bymonth"},
- {CAL_PROPERTY_EVENT_BYSETPOS, "bysetpos"},
- {CAL_PROPERTY_EVENT_WKST, "wkst"},
- {CAL_PROPERTY_EVENT_RECURRENCE_ID, "recurrence_id"},
- {CAL_PROPERTY_EVENT_RDATE, "rdate"},
- {CAL_PROPERTY_EVENT_HAS_ATTENDEE, "has_attendee"},
- {CAL_PROPERTY_EVENT_HAS_ALARM, "has_alarm"},
- {CAL_PROPERTY_EVENT_SYNC_DATA1, "sync_data1"},
- {CAL_PROPERTY_EVENT_SYNC_DATA2, "sync_data2"},
- {CAL_PROPERTY_EVENT_SYNC_DATA3, "sync_data3"},
- {CAL_PROPERTY_EVENT_SYNC_DATA4, "sync_data4"},
- {CAL_PROPERTY_EVENT_START, "dtstart_type, dtstart_utime, dtstart_datetime"},
- {CAL_PROPERTY_EVENT_END, "dtend_type, dtend_utime, dtend_datetime"},
- {CAL_PROPERTY_EVENT_CALENDAR_ALARM, NULL},
- {CAL_PROPERTY_EVENT_CALENDAR_ATTENDEE, NULL},
- {CAL_PROPERTY_EVENT_CALENDAR_SYSTEM_TYPE, "system_type"},
- {CAL_PROPERTY_EVENT_START_TZID, "dtstart_tzid"},
- {CAL_PROPERTY_EVENT_END_TZID, "dtend_tzid"},
- {CAL_PROPERTY_EVENT_EXCEPTION, NULL},
- {CAL_PROPERTY_EVENT_EXTENDED, NULL},
- {CAL_PROPERTY_EVENT_IS_ALLDAY, "dtstart_type"},
+ {CAL_PROPERTY_EVENT_ID, "id"},
+ {CAL_PROPERTY_EVENT_CALENDAR_ID, "calendar_id"},
+ {CAL_PROPERTY_EVENT_SUMMARY, "summary"},
+ {CAL_PROPERTY_EVENT_DESCRIPTION, "description"},
+ {CAL_PROPERTY_EVENT_LOCATION, "location"},
+ {CAL_PROPERTY_EVENT_CATEGORIES, "categories"},
+ {CAL_PROPERTY_EVENT_EXDATE, "exdate"},
+ {CAL_PROPERTY_EVENT_EVENT_STATUS, "task_status"},
+ {CAL_PROPERTY_EVENT_PRIORITY, "priority"},
+ {CAL_PROPERTY_EVENT_TIMEZONE, "timezone"},
+ {CAL_PROPERTY_EVENT_CONTACT_ID, "contact_id"},
+ {CAL_PROPERTY_EVENT_BUSY_STATUS, "busy_status"},
+ {CAL_PROPERTY_EVENT_SENSITIVITY, "sensitivity"},
+ {CAL_PROPERTY_EVENT_UID, "uid"},
+ {CAL_PROPERTY_EVENT_ORGANIZER_NAME, "organizer_name"},
+ {CAL_PROPERTY_EVENT_ORGANIZER_EMAIL, "organizer_email"},
+ {CAL_PROPERTY_EVENT_MEETING_STATUS, "meeting_status"},
+ {CAL_PROPERTY_EVENT_ORIGINAL_EVENT_ID, "original_event_id"},
+ {CAL_PROPERTY_EVENT_LATITUDE, "latitude"},
+ {CAL_PROPERTY_EVENT_LONGITUDE, "longitude"},
+ {CAL_PROPERTY_EVENT_EMAIL_ID, "email_id"},
+ {CAL_PROPERTY_EVENT_CREATED_TIME, "created_time"},
+ {CAL_PROPERTY_EVENT_LAST_MODIFIED_TIME, "last_mod"},
+ {CAL_PROPERTY_EVENT_IS_DELETED, "is_deleted"},
+ {CAL_PROPERTY_EVENT_FREQ, "freq"},
+ {CAL_PROPERTY_EVENT_RANGE_TYPE, "range_type"},
+ {CAL_PROPERTY_EVENT_UNTIL, "until_type,until_utime,until_datetime"},
+ {CAL_PROPERTY_EVENT_COUNT, "count"},
+ {CAL_PROPERTY_EVENT_INTERVAL, "interval"},
+ {CAL_PROPERTY_EVENT_BYSECOND, "bysecond"},
+ {CAL_PROPERTY_EVENT_BYMINUTE, "byminute"},
+ {CAL_PROPERTY_EVENT_BYHOUR, "byhour"},
+ {CAL_PROPERTY_EVENT_BYDAY, "byday"},
+ {CAL_PROPERTY_EVENT_BYMONTHDAY, "bymonthday"},
+ {CAL_PROPERTY_EVENT_BYYEARDAY, "byyearday"},
+ {CAL_PROPERTY_EVENT_BYWEEKNO, "byweekno"},
+ {CAL_PROPERTY_EVENT_BYMONTH, "bymonth"},
+ {CAL_PROPERTY_EVENT_BYSETPOS, "bysetpos"},
+ {CAL_PROPERTY_EVENT_WKST, "wkst"},
+ {CAL_PROPERTY_EVENT_RECURRENCE_ID, "recurrence_id"},
+ {CAL_PROPERTY_EVENT_RDATE, "rdate"},
+ {CAL_PROPERTY_EVENT_HAS_ATTENDEE, "has_attendee"},
+ {CAL_PROPERTY_EVENT_HAS_ALARM, "has_alarm"},
+ {CAL_PROPERTY_EVENT_SYNC_DATA1, "sync_data1"},
+ {CAL_PROPERTY_EVENT_SYNC_DATA2, "sync_data2"},
+ {CAL_PROPERTY_EVENT_SYNC_DATA3, "sync_data3"},
+ {CAL_PROPERTY_EVENT_SYNC_DATA4, "sync_data4"},
+ {CAL_PROPERTY_EVENT_START, "dtstart_type,dtstart_utime,dtstart_datetime"},
+ {CAL_PROPERTY_EVENT_END, "dtend_type,dtend_utime,dtend_datetime"},
+ {CAL_PROPERTY_EVENT_CALENDAR_ALARM, NULL},
+ {CAL_PROPERTY_EVENT_CALENDAR_ATTENDEE, NULL},
+ {CAL_PROPERTY_EVENT_CALENDAR_SYSTEM_TYPE, "system_type"},
+ {CAL_PROPERTY_EVENT_START_TZID, "dtstart_tzid"},
+ {CAL_PROPERTY_EVENT_END_TZID, "dtend_tzid"},
+ {CAL_PROPERTY_EVENT_EXCEPTION, NULL},
+ {CAL_PROPERTY_EVENT_EXTENDED, NULL},
+ {CAL_PROPERTY_EVENT_IS_ALLDAY, "is_allday"},
};
const cal_property_info_s __property_todo[] =
{
- {CAL_PROPERTY_TODO_ID, "id"},
- {CAL_PROPERTY_TODO_CALENDAR_ID, "calendar_id"},
- {CAL_PROPERTY_TODO_SUMMARY, "summary"},
- {CAL_PROPERTY_TODO_DESCRIPTION, "description"},
- {CAL_PROPERTY_TODO_LOCATION, "location"},
- {CAL_PROPERTY_TODO_CATEGORIES, "categories"},
- {CAL_PROPERTY_TODO_TODO_STATUS, "task_status"},
- {CAL_PROPERTY_TODO_PRIORITY, "priority"},
- {CAL_PROPERTY_TODO_SENSITIVITY, "sensitivity"},
- {CAL_PROPERTY_TODO_UID, "uid"},
- {CAL_PROPERTY_TODO_LATITUDE, "latitude"},
- {CAL_PROPERTY_TODO_LONGITUDE, "longitude"},
- {CAL_PROPERTY_TODO_PROGRESS, "progress"},
- {CAL_PROPERTY_TODO_CREATED_TIME, "created_time"},
- {CAL_PROPERTY_TODO_LAST_MODIFIED_TIME, "last_mod"},
- {CAL_PROPERTY_TODO_COMPLETED_TIME, "completed_time"},
- {CAL_PROPERTY_TODO_IS_DELETED, "is_deleted"},
- {CAL_PROPERTY_TODO_FREQ, "freq"},
- {CAL_PROPERTY_TODO_RANGE_TYPE, "range_type"},
- {CAL_PROPERTY_TODO_UNTIL, "until_type, until_utime, until_datetime"},
- {CAL_PROPERTY_TODO_COUNT, "count"},
- {CAL_PROPERTY_TODO_INTERVAL, "interval"},
- {CAL_PROPERTY_TODO_BYSECOND, "bysecond"},
- {CAL_PROPERTY_TODO_BYMINUTE, "byminute"},
- {CAL_PROPERTY_TODO_BYHOUR, "byhour"},
- {CAL_PROPERTY_TODO_BYDAY, "byday"},
- {CAL_PROPERTY_TODO_BYMONTHDAY, "bymonthday"},
- {CAL_PROPERTY_TODO_BYYEARDAY, "byyearday"},
- {CAL_PROPERTY_TODO_BYWEEKNO, "byweekno"},
- {CAL_PROPERTY_TODO_BYMONTH, "bymonth"},
- {CAL_PROPERTY_TODO_BYSETPOS, "bysetpos"},
- {CAL_PROPERTY_TODO_WKST, "wkst"},
- {CAL_PROPERTY_TODO_HAS_ALARM, "has_alarm"},
- {CAL_PROPERTY_TODO_SYNC_DATA1, "sync_data1"},
- {CAL_PROPERTY_TODO_SYNC_DATA2, "sync_data2"},
- {CAL_PROPERTY_TODO_SYNC_DATA3, "sync_data3"},
- {CAL_PROPERTY_TODO_SYNC_DATA4, "sync_data4"},
- {CAL_PROPERTY_TODO_START, "dtstart_type, dtstart_utime, dtstart_datetime"},
- {CAL_PROPERTY_TODO_DUE, "dtend_type, dtend_utime, dtend_datetime"},
- {CAL_PROPERTY_TODO_CALENDAR_ALARM, NULL},
- {CAL_PROPERTY_TODO_START_TZID, "dtstart_tzid"},
- {CAL_PROPERTY_TODO_DUE_TZID, "dtend_tzid"},
- {CAL_PROPERTY_TODO_ORGANIZER_NAME, "organizer_name"},
- {CAL_PROPERTY_TODO_ORGANIZER_EMAIL, "organizer_email"},
- {CAL_PROPERTY_TODO_HAS_ATTENDEE, "has_attendee"},
- {CAL_PROPERTY_TODO_CALENDAR_ATTENDEE, NULL},
- {CAL_PROPERTY_TODO_EXTENDED, NULL},
- {CAL_PROPERTY_TODO_IS_ALLDAY, "dtend_type"},
+ {CAL_PROPERTY_TODO_ID, "id"},
+ {CAL_PROPERTY_TODO_CALENDAR_ID, "calendar_id"},
+ {CAL_PROPERTY_TODO_SUMMARY, "summary"},
+ {CAL_PROPERTY_TODO_DESCRIPTION, "description"},
+ {CAL_PROPERTY_TODO_LOCATION, "location"},
+ {CAL_PROPERTY_TODO_CATEGORIES, "categories"},
+ {CAL_PROPERTY_TODO_TODO_STATUS, "task_status"},
+ {CAL_PROPERTY_TODO_PRIORITY, "priority"},
+ {CAL_PROPERTY_TODO_SENSITIVITY, "sensitivity"},
+ {CAL_PROPERTY_TODO_UID, "uid"},
+ {CAL_PROPERTY_TODO_LATITUDE, "latitude"},
+ {CAL_PROPERTY_TODO_LONGITUDE, "longitude"},
+ {CAL_PROPERTY_TODO_PROGRESS, "progress"},
+ {CAL_PROPERTY_TODO_CREATED_TIME, "created_time"},
+ {CAL_PROPERTY_TODO_LAST_MODIFIED_TIME, "last_mod"},
+ {CAL_PROPERTY_TODO_COMPLETED_TIME, "completed_time"},
+ {CAL_PROPERTY_TODO_IS_DELETED, "is_deleted"},
+ {CAL_PROPERTY_TODO_FREQ, "freq"},
+ {CAL_PROPERTY_TODO_RANGE_TYPE, "range_type"},
+ {CAL_PROPERTY_TODO_UNTIL, "until_type,until_utime,until_datetime"},
+ {CAL_PROPERTY_TODO_COUNT, "count"},
+ {CAL_PROPERTY_TODO_INTERVAL, "interval"},
+ {CAL_PROPERTY_TODO_BYSECOND, "bysecond"},
+ {CAL_PROPERTY_TODO_BYMINUTE, "byminute"},
+ {CAL_PROPERTY_TODO_BYHOUR, "byhour"},
+ {CAL_PROPERTY_TODO_BYDAY, "byday"},
+ {CAL_PROPERTY_TODO_BYMONTHDAY, "bymonthday"},
+ {CAL_PROPERTY_TODO_BYYEARDAY, "byyearday"},
+ {CAL_PROPERTY_TODO_BYWEEKNO, "byweekno"},
+ {CAL_PROPERTY_TODO_BYMONTH, "bymonth"},
+ {CAL_PROPERTY_TODO_BYSETPOS, "bysetpos"},
+ {CAL_PROPERTY_TODO_WKST, "wkst"},
+ {CAL_PROPERTY_TODO_HAS_ALARM, "has_alarm"},
+ {CAL_PROPERTY_TODO_SYNC_DATA1, "sync_data1"},
+ {CAL_PROPERTY_TODO_SYNC_DATA2, "sync_data2"},
+ {CAL_PROPERTY_TODO_SYNC_DATA3, "sync_data3"},
+ {CAL_PROPERTY_TODO_SYNC_DATA4, "sync_data4"},
+ {CAL_PROPERTY_TODO_START, "dtstart_type,dtstart_utime,dtstart_datetime"},
+ {CAL_PROPERTY_TODO_DUE, "dtend_type,dtend_utime,dtend_datetime"},
+ {CAL_PROPERTY_TODO_CALENDAR_ALARM, NULL},
+ {CAL_PROPERTY_TODO_START_TZID, "dtstart_tzid"},
+ {CAL_PROPERTY_TODO_DUE_TZID, "dtend_tzid"},
+ {CAL_PROPERTY_TODO_ORGANIZER_NAME, "organizer_name"},
+ {CAL_PROPERTY_TODO_ORGANIZER_EMAIL, "organizer_email"},
+ {CAL_PROPERTY_TODO_HAS_ATTENDEE, "has_attendee"},
+ {CAL_PROPERTY_TODO_CALENDAR_ATTENDEE, NULL},
+ {CAL_PROPERTY_TODO_EXTENDED, NULL},
+ {CAL_PROPERTY_TODO_IS_ALLDAY, "dtend_type"},
};
const cal_property_info_s __property_timezone[] =
{
- {CAL_PROPERTY_TIMEZONE_ID, "id"},
- {CAL_PROPERTY_TIMEZONE_TZ_OFFSET_FROM_GMT, "tz_offset_from_gmt"},
- {CAL_PROPERTY_TIMEZONE_STANDARD_NAME, "standard_name"},
- {CAL_PROPERTY_TIMEZONE_STD_START_MONTH, "std_start_month"},
- {CAL_PROPERTY_TIMEZONE_STD_START_POSITION_OF_WEEK, "std_start_position_of_week"},
- {CAL_PROPERTY_TIMEZONE_STD_START_DAY, "std_start_day"},
- {CAL_PROPERTY_TIMEZONE_STD_START_HOUR, "std_start_hour"},
- {CAL_PROPERTY_TIMEZONE_STANDARD_BIAS, "standard_bias"},
- {CAL_PROPERTY_TIMEZONE_DAY_LIGHT_NAME, "day_light_name"},
- {CAL_PROPERTY_TIMEZONE_DAY_LIGHT_START_MONTH, "day_light_start_month"},
- {CAL_PROPERTY_TIMEZONE_DAY_LIGHT_START_POSITION_OF_WEEK, "day_light_start_position_of_week"},
- {CAL_PROPERTY_TIMEZONE_DAY_LIGHT_START_DAY, "day_light_start_day"},
- {CAL_PROPERTY_TIMEZONE_DAY_LIGHT_START_HOUR, "day_light_start_hour"},
- {CAL_PROPERTY_TIMEZONE_DAY_LIGHT_BIAS, "day_light_bias"},
- {CAL_PROPERTY_TIMEZONE_CALENDAR_ID, "calendar_id"},
+ {CAL_PROPERTY_TIMEZONE_ID, "id"},
+ {CAL_PROPERTY_TIMEZONE_TZ_OFFSET_FROM_GMT, "tz_offset_from_gmt"},
+ {CAL_PROPERTY_TIMEZONE_STANDARD_NAME, "standard_name"},
+ {CAL_PROPERTY_TIMEZONE_STD_START_MONTH, "std_start_month"},
+ {CAL_PROPERTY_TIMEZONE_STD_START_POSITION_OF_WEEK, "std_start_position_of_week"},
+ {CAL_PROPERTY_TIMEZONE_STD_START_DAY, "std_start_day"},
+ {CAL_PROPERTY_TIMEZONE_STD_START_HOUR, "std_start_hour"},
+ {CAL_PROPERTY_TIMEZONE_STANDARD_BIAS, "standard_bias"},
+ {CAL_PROPERTY_TIMEZONE_DAY_LIGHT_NAME, "day_light_name"},
+ {CAL_PROPERTY_TIMEZONE_DAY_LIGHT_START_MONTH, "day_light_start_month"},
+ {CAL_PROPERTY_TIMEZONE_DAY_LIGHT_START_POSITION_OF_WEEK, "day_light_start_position_of_week"},
+ {CAL_PROPERTY_TIMEZONE_DAY_LIGHT_START_DAY, "day_light_start_day"},
+ {CAL_PROPERTY_TIMEZONE_DAY_LIGHT_START_HOUR, "day_light_start_hour"},
+ {CAL_PROPERTY_TIMEZONE_DAY_LIGHT_BIAS, "day_light_bias"},
+ {CAL_PROPERTY_TIMEZONE_CALENDAR_ID, "calendar_id"},
};
const cal_property_info_s __property_attendee[] =
{
- {CAL_PROPERTY_ATTENDEE_NUMBER, "attendee_number"},
- {CAL_PROPERTY_ATTENDEE_TYPE, "attendee_type"},
- {CAL_PROPERTY_ATTENDEE_CT_INDEX, "attendee_ct_index"},
- {CAL_PROPERTY_ATTENDEE_UID, "attendee_uid"},
- {CAL_PROPERTY_ATTENDEE_GROUP, "attendee_group"},
- {CAL_PROPERTY_ATTENDEE_EMAIL, "attendee_email"},
- {CAL_PROPERTY_ATTENDEE_ROLE, "attendee_role"},
- {CAL_PROPERTY_ATTENDEE_STATUS, "attendee_status"},
- {CAL_PROPERTY_ATTENDEE_RSVP, "attendee_rsvp"},
- {CAL_PROPERTY_ATTENDEE_DELEGATE_URI, "attendee_delegate_uri"},
- {CAL_PROPERTY_ATTENDEE_DELEGATOR_URI, "attendee_delegator_uri"},
- {CAL_PROPERTY_ATTENDEE_NAME, "attendee_name"},
- {CAL_PROPERTY_ATTENDEE_EVENT_ID, "event_id"},
+ {CAL_PROPERTY_ATTENDEE_NUMBER, "attendee_number"},
+ {CAL_PROPERTY_ATTENDEE_CUTYPE, "attendee_cutype"},
+ {CAL_PROPERTY_ATTENDEE_CT_INDEX, "attendee_ct_index"},
+ {CAL_PROPERTY_ATTENDEE_UID, "attendee_uid"},
+ {CAL_PROPERTY_ATTENDEE_GROUP, "attendee_group"},
+ {CAL_PROPERTY_ATTENDEE_EMAIL, "attendee_email"},
+ {CAL_PROPERTY_ATTENDEE_ROLE, "attendee_role"},
+ {CAL_PROPERTY_ATTENDEE_STATUS, "attendee_status"},
+ {CAL_PROPERTY_ATTENDEE_RSVP, "attendee_rsvp"},
+ {CAL_PROPERTY_ATTENDEE_DELEGATEE_URI, "attendee_delegatee_uri"},
+ {CAL_PROPERTY_ATTENDEE_DELEGATOR_URI, "attendee_delegator_uri"},
+ {CAL_PROPERTY_ATTENDEE_NAME, "attendee_name"},
+ {CAL_PROPERTY_ATTENDEE_MEMBER, "attendee_member"},
+ {CAL_PROPERTY_ATTENDEE_PARENT_ID, "parent_id"},
};
const cal_property_info_s __property_alarm[] =
{
- {CAL_PROPERTY_ALARM_TYPE, "alarm_type"},
- {CAL_PROPERTY_ALARM_TIME, "alarm_time"},
- {CAL_PROPERTY_ALARM_TICK, "remind_tick"},
- {CAL_PROPERTY_ALARM_TICK_UNIT, "remind_tick_unit"},
- {CAL_PROPERTY_ALARM_TONE, "alarm_tone"},
- {CAL_PROPERTY_ALARM_DESCRIPTION, "alarm_description"},
- {CAL_PROPERTY_ALARM_ID, "alarm_id"},
- {CAL_PROPERTY_ALARM_EVENT_TODO_ID, "event_id"},
+ {CAL_PROPERTY_ALARM_TICK, "remind_tick"},
+ {CAL_PROPERTY_ALARM_TICK_UNIT, "remind_tick_unit"},
+ {CAL_PROPERTY_ALARM_DESCRIPTION, "alarm_description"},
+ {CAL_PROPERTY_ALARM_PARENT_ID, "parent_id"},
+ {CAL_PROPERTY_ALARM_SUMMARY, "alarm_summary"},
+ {CAL_PROPERTY_ALARM_ACTION, "alarm_action"},
+ {CAL_PROPERTY_ALARM_ATTACH, "alarm_attach"},
+ {CAL_PROPERTY_ALARM_ALARM, "alarm_type,alarm_utime,alarm_datetime"},
};
-const cal_property_info_s __property_instance_normal[] =
+const cal_property_info_s __property_updated_info[] =
{
- {CAL_PROPERTY_INSTANCE_NORMAL_EVENT_ID, "event_id"},
- {CAL_PROPERTY_INSTANCE_NORMAL_START, "dtstart_type, dtstart_utime, dtstart_datetime"},
- {CAL_PROPERTY_INSTANCE_NORMAL_END, "dtend_type, dtend_utime, dtend_datetime"},
- {CAL_PROPERTY_INSTANCE_NORMAL_SUMMARY, "summary"},
- {CAL_PROPERTY_INSTANCE_NORMAL_LOCATION, "location"},
- {CAL_PROPERTY_INSTANCE_NORMAL_CALENDAR_ID, "calendar_id"},
- {CAL_PROPERTY_INSTANCE_NORMAL_DESCRIPTION, "description"},
- {CAL_PROPERTY_INSTANCE_NORMAL_BUSY_STATUS, "busy_status"},
- {CAL_PROPERTY_INSTANCE_NORMAL_EVENT_STATUS, "task_status"},
- {CAL_PROPERTY_INSTANCE_NORMAL_PRIORITY, "priority"},
- {CAL_PROPERTY_INSTANCE_NORMAL_SENSITIVITY, "sensitivity"},
- {CAL_PROPERTY_INSTANCE_NORMAL_HAS_RRULE, "rrule_id"},
- {CAL_PROPERTY_INSTANCE_NORMAL_LATITUDE, "latitude"},
- {CAL_PROPERTY_INSTANCE_NORMAL_LONGITUDE, "longitude"},
- {CAL_PROPERTY_INSTANCE_NORMAL_HAS_ALARM, "has_alarm"},
- {CAL_PROPERTY_INSTANCE_NORMAL_ORIGINAL_EVENT_ID, "original_event_id"},
- {CAL_PROPERTY_INSTANCE_NORMAL_LAST_MODIFIED_TIME, "last_mod"},
+ {CAL_PROPERTY_UPDATED_INFO_ID, "id"},
+ {CAL_PROPERTY_UPDATED_INFO_CALENDAR_ID, "calendar_id"},
+ {CAL_PROPERTY_UPDATED_INFO_TYPE, "type"},
+ {CAL_PROPERTY_UPDATED_INFO_VERSION, "ver"},
};
-const cal_property_info_s __property_instance_allday[] =
+const cal_property_info_s __property_search_event_calendar[] =
{
- {CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_ID, "event_id"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_START, "dtstart_type, dtstart_utime, dtstart_datetime"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_END, "dtend_type, dtend_utime, dtend_datetime"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_SUMMARY, "summary"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_LOCATION, "location"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_CALENDAR_ID, "calendar_id"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_DESCRIPTION, "description"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_BUSY_STATUS, "busy_status"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_STATUS, "task_status"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_PRIORITY, "priority"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_SENSITIVITY, "sensitivity"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_HAS_RRULE, "rrule_id"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_LATITUDE, "latitude"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_LONGITUDE, "longitude"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_HAS_ALARM, "has_alarm"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_ORIGINAL_EVENT_ID, "original_event_id"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_LAST_MODIFIED_TIME, "last_mod"},
+ {CAL_PROPERTY_EVENT_ID, "id"},
+ {CAL_PROPERTY_EVENT_CALENDAR_ID, "calendar_id"},
+ {CAL_PROPERTY_EVENT_SUMMARY, "summary"},
+ {CAL_PROPERTY_EVENT_DESCRIPTION, "description"},
+ {CAL_PROPERTY_EVENT_LOCATION, "location"},
+ {CAL_PROPERTY_EVENT_CATEGORIES, "categories"},
+ {CAL_PROPERTY_EVENT_EXDATE, "exdate"},
+ {CAL_PROPERTY_EVENT_EVENT_STATUS, "task_status"},
+ {CAL_PROPERTY_EVENT_PRIORITY, "priority"},
+ {CAL_PROPERTY_EVENT_TIMEZONE, "timezone"},
+ {CAL_PROPERTY_EVENT_CONTACT_ID, "contact_id"},
+ {CAL_PROPERTY_EVENT_BUSY_STATUS, "busy_status"},
+ {CAL_PROPERTY_EVENT_SENSITIVITY, "sensitivity"},
+ {CAL_PROPERTY_EVENT_UID, "uid"},
+ {CAL_PROPERTY_EVENT_ORGANIZER_NAME, "organizer_name"},
+ {CAL_PROPERTY_EVENT_ORGANIZER_EMAIL, "organizer_email"},
+ {CAL_PROPERTY_EVENT_MEETING_STATUS, "meeting_status"},
+ {CAL_PROPERTY_EVENT_ORIGINAL_EVENT_ID, "original_event_id"},
+ {CAL_PROPERTY_EVENT_LATITUDE, "latitude"},
+ {CAL_PROPERTY_EVENT_LONGITUDE, "longitude"},
+ {CAL_PROPERTY_EVENT_EMAIL_ID, "email_id"},
+ {CAL_PROPERTY_EVENT_CREATED_TIME, "created_time"},
+ {CAL_PROPERTY_EVENT_LAST_MODIFIED_TIME, "last_mod"},
+ {CAL_PROPERTY_EVENT_FREQ, "freq"},
+ {CAL_PROPERTY_EVENT_RANGE_TYPE, "range_type"},
+ {CAL_PROPERTY_EVENT_UNTIL, "until_type,until_utime,until_datetime"},
+ {CAL_PROPERTY_EVENT_COUNT, "count"},
+ {CAL_PROPERTY_EVENT_INTERVAL, "interval"},
+ {CAL_PROPERTY_EVENT_BYSECOND, "bysecond"},
+ {CAL_PROPERTY_EVENT_BYMINUTE, "byminute"},
+ {CAL_PROPERTY_EVENT_BYHOUR, "byhour"},
+ {CAL_PROPERTY_EVENT_BYDAY, "byday"},
+ {CAL_PROPERTY_EVENT_BYMONTHDAY, "bymonthday"},
+ {CAL_PROPERTY_EVENT_BYYEARDAY, "byyearday"},
+ {CAL_PROPERTY_EVENT_BYWEEKNO, "byweekno"},
+ {CAL_PROPERTY_EVENT_BYMONTH, "bymonth"},
+ {CAL_PROPERTY_EVENT_BYSETPOS, "bysetpos"},
+ {CAL_PROPERTY_EVENT_WKST, "wkst"},
+ {CAL_PROPERTY_EVENT_RECURRENCE_ID, "recurrence_id"},
+ {CAL_PROPERTY_EVENT_RDATE, "rdate"},
+ {CAL_PROPERTY_EVENT_HAS_ATTENDEE, "has_attendee"},
+ {CAL_PROPERTY_EVENT_HAS_ALARM, "has_alarm"},
+ {CAL_PROPERTY_EVENT_SYNC_DATA1, "sync_data1"},
+ {CAL_PROPERTY_EVENT_SYNC_DATA2, "sync_data2"},
+ {CAL_PROPERTY_EVENT_SYNC_DATA3, "sync_data3"},
+ {CAL_PROPERTY_EVENT_SYNC_DATA4, "sync_data4"},
+ {CAL_PROPERTY_EVENT_START, "dtstart_type,dtstart_utime,dtstart_datetime"},
+ {CAL_PROPERTY_EVENT_END, "dtend_type,dtend_utime,dtend_datetime"},
+ {CAL_PROPERTY_EVENT_CALENDAR_SYSTEM_TYPE, "system_type"},
+ {CAL_PROPERTY_EVENT_START_TZID, "dtstart_tzid"},
+ {CAL_PROPERTY_EVENT_END_TZID, "dtend_tzid"},
+ {CAL_PROPERTY_EVENT_IS_ALLDAY, "is_allday"},
+ {(CAL_PROPERTY_CALENDAR_VISIBILITY|CAL_PROPERTY_FLAGS_FILTER), "visibility"},
+ {(CAL_PROPERTY_CALENDAR_ACCOUNT_ID|CAL_PROPERTY_FLAGS_FILTER), "account_id"},
};
-const cal_property_info_s __property_updated_info[] =
+const cal_property_info_s __property_search_todo_calendar[] =
{
- {CAL_PROPERTY_UPDATED_INFO_ID, "id"},
- {CAL_PROPERTY_UPDATED_INFO_CALENDAR_ID, "calendar_id"},
- {CAL_PROPERTY_UPDATED_INFO_TYPE, "type"},
- {CAL_PROPERTY_UPDATED_INFO_VERSION, "ver"},
+ {CAL_PROPERTY_TODO_ID, "id"},
+ {CAL_PROPERTY_TODO_CALENDAR_ID, "calendar_id"},
+ {CAL_PROPERTY_TODO_SUMMARY, "summary"},
+ {CAL_PROPERTY_TODO_DESCRIPTION, "description"},
+ {CAL_PROPERTY_TODO_LOCATION, "location"},
+ {CAL_PROPERTY_TODO_CATEGORIES, "categories"},
+ {CAL_PROPERTY_TODO_TODO_STATUS, "task_status"},
+ {CAL_PROPERTY_TODO_PRIORITY, "priority"},
+ {CAL_PROPERTY_TODO_SENSITIVITY, "sensitivity"},
+ {CAL_PROPERTY_TODO_UID, "uid"},
+ {CAL_PROPERTY_TODO_LATITUDE, "latitude"},
+ {CAL_PROPERTY_TODO_LONGITUDE, "longitude"},
+ {CAL_PROPERTY_TODO_PROGRESS, "progress"},
+ {CAL_PROPERTY_TODO_CREATED_TIME, "created_time"},
+ {CAL_PROPERTY_TODO_LAST_MODIFIED_TIME, "last_mod"},
+ {CAL_PROPERTY_TODO_COMPLETED_TIME, "completed_time"},
+ {CAL_PROPERTY_TODO_FREQ, "freq"},
+ {CAL_PROPERTY_TODO_RANGE_TYPE, "range_type"},
+ {CAL_PROPERTY_TODO_UNTIL, "until_type,until_utime,until_datetime"},
+ {CAL_PROPERTY_TODO_COUNT, "count"},
+ {CAL_PROPERTY_TODO_INTERVAL, "interval"},
+ {CAL_PROPERTY_TODO_BYSECOND, "bysecond"},
+ {CAL_PROPERTY_TODO_BYMINUTE, "byminute"},
+ {CAL_PROPERTY_TODO_BYHOUR, "byhour"},
+ {CAL_PROPERTY_TODO_BYDAY, "byday"},
+ {CAL_PROPERTY_TODO_BYMONTHDAY, "bymonthday"},
+ {CAL_PROPERTY_TODO_BYYEARDAY, "byyearday"},
+ {CAL_PROPERTY_TODO_BYWEEKNO, "byweekno"},
+ {CAL_PROPERTY_TODO_BYMONTH, "bymonth"},
+ {CAL_PROPERTY_TODO_BYSETPOS, "bysetpos"},
+ {CAL_PROPERTY_TODO_WKST, "wkst"},
+ {CAL_PROPERTY_TODO_HAS_ALARM, "has_alarm"},
+ {CAL_PROPERTY_TODO_SYNC_DATA1, "sync_data1"},
+ {CAL_PROPERTY_TODO_SYNC_DATA2, "sync_data2"},
+ {CAL_PROPERTY_TODO_SYNC_DATA3, "sync_data3"},
+ {CAL_PROPERTY_TODO_SYNC_DATA4, "sync_data4"},
+ {CAL_PROPERTY_TODO_START, "dtstart_type,dtstart_utime,dtstart_datetime"},
+ {CAL_PROPERTY_TODO_DUE, "dtend_type,dtend_utime,dtend_datetime"},
+ {CAL_PROPERTY_TODO_START_TZID, "dtstart_tzid"},
+ {CAL_PROPERTY_TODO_DUE_TZID, "dtend_tzid"},
+ {CAL_PROPERTY_TODO_ORGANIZER_NAME, "organizer_name"},
+ {CAL_PROPERTY_TODO_ORGANIZER_EMAIL, "organizer_email"},
+ {CAL_PROPERTY_TODO_HAS_ATTENDEE, "has_attendee"},
+ {CAL_PROPERTY_TODO_IS_ALLDAY, "dtend_type"},
+ {(CAL_PROPERTY_CALENDAR_VISIBILITY|CAL_PROPERTY_FLAGS_FILTER), "visibility"},
+ {(CAL_PROPERTY_CALENDAR_ACCOUNT_ID|CAL_PROPERTY_FLAGS_FILTER), "account_id"},
};
-const cal_property_info_s __property_search_event_calendar[] =
+const cal_property_info_s __property_search_event_calendar_attendee[] =
{
- {CAL_PROPERTY_EVENT_ID, "id"},
- {CAL_PROPERTY_EVENT_CALENDAR_ID, "calendar_id"},
- {CAL_PROPERTY_EVENT_SUMMARY, "summary"},
- {CAL_PROPERTY_EVENT_DESCRIPTION, "description"},
- {CAL_PROPERTY_EVENT_LOCATION, "location"},
- {CAL_PROPERTY_EVENT_CATEGORIES, "categories"},
- {CAL_PROPERTY_EVENT_EXDATE, "exdate"},
- {CAL_PROPERTY_EVENT_EVENT_STATUS, "task_status"},
- {CAL_PROPERTY_EVENT_PRIORITY, "priority"},
- {CAL_PROPERTY_EVENT_TIMEZONE, "timezone"},
- {CAL_PROPERTY_EVENT_CONTACT_ID, "contact_id"},
- {CAL_PROPERTY_EVENT_BUSY_STATUS, "busy_status"},
- {CAL_PROPERTY_EVENT_SENSITIVITY, "sensitivity"},
- {CAL_PROPERTY_EVENT_UID, "uid"},
- {CAL_PROPERTY_EVENT_ORGANIZER_NAME, "organizer_name"},
- {CAL_PROPERTY_EVENT_ORGANIZER_EMAIL, "organizer_email"},
- {CAL_PROPERTY_EVENT_MEETING_STATUS, "meeting_status"},
- {CAL_PROPERTY_EVENT_ORIGINAL_EVENT_ID, "original_event_id"},
- {CAL_PROPERTY_EVENT_LATITUDE, "latitude"},
- {CAL_PROPERTY_EVENT_LONGITUDE, "longitude"},
- {CAL_PROPERTY_EVENT_EMAIL_ID, "email_id"},
- {CAL_PROPERTY_EVENT_CREATED_TIME, "created_time"},
- {CAL_PROPERTY_EVENT_LAST_MODIFIED_TIME, "last_mod"},
- {CAL_PROPERTY_EVENT_IS_DELETED, "is_deleted"},
- {CAL_PROPERTY_EVENT_FREQ, "freq"},
- {CAL_PROPERTY_EVENT_RANGE_TYPE, "range_type"},
- {CAL_PROPERTY_EVENT_UNTIL, "until_type, until_utime, until_datetime"},
- {CAL_PROPERTY_EVENT_COUNT, "count"},
- {CAL_PROPERTY_EVENT_INTERVAL, "interval"},
- {CAL_PROPERTY_EVENT_BYSECOND, "bysecond"},
- {CAL_PROPERTY_EVENT_BYMINUTE, "byminute"},
- {CAL_PROPERTY_EVENT_BYHOUR, "byhour"},
- {CAL_PROPERTY_EVENT_BYDAY, "byday"},
- {CAL_PROPERTY_EVENT_BYMONTHDAY, "bymonthday"},
- {CAL_PROPERTY_EVENT_BYYEARDAY, "byyearday"},
- {CAL_PROPERTY_EVENT_BYWEEKNO, "byweekno"},
- {CAL_PROPERTY_EVENT_BYMONTH, "bymonth"},
- {CAL_PROPERTY_EVENT_BYSETPOS, "bysetpos"},
- {CAL_PROPERTY_EVENT_WKST, "wkst"},
- {CAL_PROPERTY_EVENT_RECURRENCE_ID, "recurrence_id"},
- {CAL_PROPERTY_EVENT_RDATE, "rdate"},
- {CAL_PROPERTY_EVENT_HAS_ATTENDEE, "has_attendee"},
- {CAL_PROPERTY_EVENT_HAS_ALARM, "has_alarm"},
- {CAL_PROPERTY_EVENT_SYNC_DATA1, "sync_data1"},
- {CAL_PROPERTY_EVENT_SYNC_DATA2, "sync_data2"},
- {CAL_PROPERTY_EVENT_SYNC_DATA3, "sync_data3"},
- {CAL_PROPERTY_EVENT_SYNC_DATA4, "sync_data4"},
- {CAL_PROPERTY_EVENT_START, "dtstart_type, dtstart_utime, dtstart_datetime"},
- {CAL_PROPERTY_EVENT_END, "dtend_type, dtend_utime, dtend_datetime"},
- {CAL_PROPERTY_EVENT_CALENDAR_SYSTEM_TYPE, "system_type"},
- {CAL_PROPERTY_EVENT_START_TZID, "dtstart_tzid"},
- {CAL_PROPERTY_EVENT_END_TZID, "dtend_tzid"},
- {CAL_PROPERTY_EVENT_IS_ALLDAY, "dtstart_type"},
- {(CAL_PROPERTY_CALENDAR_VISIBILITY|CAL_PROPERTY_FLAGS_FILTER) , "visibility"},
- {(CAL_PROPERTY_CALENDAR_ACCOUNT_ID|CAL_PROPERTY_FLAGS_FILTER) , "account_id"},
+ {CAL_PROPERTY_EVENT_ID, "id"},
+ {CAL_PROPERTY_EVENT_CALENDAR_ID, "calendar_id"},
+ {CAL_PROPERTY_EVENT_SUMMARY, "summary"},
+ {CAL_PROPERTY_EVENT_DESCRIPTION, "description"},
+ {CAL_PROPERTY_EVENT_LOCATION, "location"},
+ {CAL_PROPERTY_EVENT_CATEGORIES, "categories"},
+ {CAL_PROPERTY_EVENT_EXDATE, "exdate"},
+ {CAL_PROPERTY_EVENT_EVENT_STATUS, "task_status"},
+ {CAL_PROPERTY_EVENT_PRIORITY, "priority"},
+ {CAL_PROPERTY_EVENT_TIMEZONE, "timezone"},
+ {CAL_PROPERTY_EVENT_CONTACT_ID, "contact_id"},
+ {CAL_PROPERTY_EVENT_BUSY_STATUS, "busy_status"},
+ {CAL_PROPERTY_EVENT_SENSITIVITY, "sensitivity"},
+ {CAL_PROPERTY_EVENT_UID, "uid"},
+ {CAL_PROPERTY_EVENT_ORGANIZER_NAME, "organizer_name"},
+ {CAL_PROPERTY_EVENT_ORGANIZER_EMAIL, "organizer_email"},
+ {CAL_PROPERTY_EVENT_MEETING_STATUS, "meeting_status"},
+ {CAL_PROPERTY_EVENT_ORIGINAL_EVENT_ID, "original_event_id"},
+ {CAL_PROPERTY_EVENT_LATITUDE, "latitude"},
+ {CAL_PROPERTY_EVENT_LONGITUDE, "longitude"},
+ {CAL_PROPERTY_EVENT_EMAIL_ID, "email_id"},
+ {CAL_PROPERTY_EVENT_CREATED_TIME, "created_time"},
+ {CAL_PROPERTY_EVENT_LAST_MODIFIED_TIME, "last_mod"},
+ {CAL_PROPERTY_EVENT_FREQ, "freq"},
+ {CAL_PROPERTY_EVENT_RANGE_TYPE, "range_type"},
+ {CAL_PROPERTY_EVENT_UNTIL, "until_type,until_utime,until_datetime"},
+ {CAL_PROPERTY_EVENT_COUNT, "count"},
+ {CAL_PROPERTY_EVENT_INTERVAL, "interval"},
+ {CAL_PROPERTY_EVENT_BYSECOND, "bysecond"},
+ {CAL_PROPERTY_EVENT_BYMINUTE, "byminute"},
+ {CAL_PROPERTY_EVENT_BYHOUR, "byhour"},
+ {CAL_PROPERTY_EVENT_BYDAY, "byday"},
+ {CAL_PROPERTY_EVENT_BYMONTHDAY, "bymonthday"},
+ {CAL_PROPERTY_EVENT_BYYEARDAY, "byyearday"},
+ {CAL_PROPERTY_EVENT_BYWEEKNO, "byweekno"},
+ {CAL_PROPERTY_EVENT_BYMONTH, "bymonth"},
+ {CAL_PROPERTY_EVENT_BYSETPOS, "bysetpos"},
+ {CAL_PROPERTY_EVENT_WKST, "wkst"},
+ {CAL_PROPERTY_EVENT_RECURRENCE_ID, "recurrence_id"},
+ {CAL_PROPERTY_EVENT_RDATE, "rdate"},
+ {CAL_PROPERTY_EVENT_HAS_ATTENDEE, "has_attendee"},
+ {CAL_PROPERTY_EVENT_HAS_ALARM, "has_alarm"},
+ {CAL_PROPERTY_EVENT_SYNC_DATA1, "sync_data1"},
+ {CAL_PROPERTY_EVENT_SYNC_DATA2, "sync_data2"},
+ {CAL_PROPERTY_EVENT_SYNC_DATA3, "sync_data3"},
+ {CAL_PROPERTY_EVENT_SYNC_DATA4, "sync_data4"},
+ {CAL_PROPERTY_EVENT_START, "dtstart_type,dtstart_utime,dtstart_datetime"},
+ {CAL_PROPERTY_EVENT_END, "dtend_type,dtend_utime,dtend_datetime"},
+ {CAL_PROPERTY_EVENT_CALENDAR_SYSTEM_TYPE, "system_type"},
+ {CAL_PROPERTY_EVENT_START_TZID, "dtstart_tzid"},
+ {CAL_PROPERTY_EVENT_END_TZID, "dtend_tzid"},
+ {CAL_PROPERTY_EVENT_IS_ALLDAY, "is_allday"},
+ {(CAL_PROPERTY_CALENDAR_VISIBILITY|CAL_PROPERTY_FLAGS_FILTER), "visibility"},
+ {(CAL_PROPERTY_CALENDAR_ACCOUNT_ID|CAL_PROPERTY_FLAGS_FILTER), "account_id"},
+ {(CAL_PROPERTY_ATTENDEE_EMAIL|CAL_PROPERTY_FLAGS_FILTER), "attendee_email"},
+ {(CAL_PROPERTY_ATTENDEE_NAME|CAL_PROPERTY_FLAGS_FILTER), "attendee_name"},
+ {(CAL_PROPERTY_ATTENDEE_MEMBER|CAL_PROPERTY_FLAGS_FILTER), "attendee_member"},
};
-const cal_property_info_s __property_search_todo_calendar[] =
+const cal_property_info_s __property_search_instance_utime_calendar[] =
{
- {CAL_PROPERTY_TODO_ID, "id"},
- {CAL_PROPERTY_TODO_CALENDAR_ID, "calendar_id"},
- {CAL_PROPERTY_TODO_SUMMARY, "summary"},
- {CAL_PROPERTY_TODO_DESCRIPTION, "description"},
- {CAL_PROPERTY_TODO_LOCATION, "location"},
- {CAL_PROPERTY_TODO_CATEGORIES, "categories"},
- {CAL_PROPERTY_TODO_TODO_STATUS, "task_status"},
- {CAL_PROPERTY_TODO_PRIORITY, "priority"},
- {CAL_PROPERTY_TODO_SENSITIVITY, "sensitivity"},
- {CAL_PROPERTY_TODO_UID, "uid"},
- {CAL_PROPERTY_TODO_LATITUDE, "latitude"},
- {CAL_PROPERTY_TODO_LONGITUDE, "longitude"},
- {CAL_PROPERTY_TODO_PROGRESS, "progress"},
- {CAL_PROPERTY_TODO_CREATED_TIME, "created_time"},
- {CAL_PROPERTY_TODO_LAST_MODIFIED_TIME, "last_mod"},
- {CAL_PROPERTY_TODO_COMPLETED_TIME, "completed_time"},
- {CAL_PROPERTY_TODO_IS_DELETED, "is_deleted"},
- {CAL_PROPERTY_TODO_FREQ, "freq"},
- {CAL_PROPERTY_TODO_RANGE_TYPE, "range_type"},
- {CAL_PROPERTY_TODO_UNTIL, "until_type, until_utime, until_datetime"},
- {CAL_PROPERTY_TODO_COUNT, "count"},
- {CAL_PROPERTY_TODO_INTERVAL, "interval"},
- {CAL_PROPERTY_TODO_BYSECOND, "bysecond"},
- {CAL_PROPERTY_TODO_BYMINUTE, "byminute"},
- {CAL_PROPERTY_TODO_BYHOUR, "byhour"},
- {CAL_PROPERTY_TODO_BYDAY, "byday"},
- {CAL_PROPERTY_TODO_BYMONTHDAY, "bymonthday"},
- {CAL_PROPERTY_TODO_BYYEARDAY, "byyearday"},
- {CAL_PROPERTY_TODO_BYWEEKNO, "byweekno"},
- {CAL_PROPERTY_TODO_BYMONTH, "bymonth"},
- {CAL_PROPERTY_TODO_BYSETPOS, "bysetpos"},
- {CAL_PROPERTY_TODO_WKST, "wkst"},
- {CAL_PROPERTY_TODO_HAS_ALARM, "has_alarm"},
- {CAL_PROPERTY_TODO_SYNC_DATA1, "sync_data1"},
- {CAL_PROPERTY_TODO_SYNC_DATA2, "sync_data2"},
- {CAL_PROPERTY_TODO_SYNC_DATA3, "sync_data3"},
- {CAL_PROPERTY_TODO_SYNC_DATA4, "sync_data4"},
- {CAL_PROPERTY_TODO_START, "dtstart_type, dtstart_utime, dtstart_datetime"},
- {CAL_PROPERTY_TODO_DUE, "dtend_type, dtend_utime, dtend_datetime"},
- {CAL_PROPERTY_TODO_START_TZID, "dtstart_tzid"},
- {CAL_PROPERTY_TODO_DUE_TZID, "dtend_tzid"},
- {CAL_PROPERTY_TODO_ORGANIZER_NAME, "organizer_name"},
- {CAL_PROPERTY_TODO_ORGANIZER_EMAIL, "organizer_email"},
- {CAL_PROPERTY_TODO_HAS_ATTENDEE, "has_attendee"},
- {CAL_PROPERTY_TODO_IS_ALLDAY, "dtend_type"},
- {(CAL_PROPERTY_CALENDAR_VISIBILITY|CAL_PROPERTY_FLAGS_FILTER) , "visibility"},
- {(CAL_PROPERTY_CALENDAR_ACCOUNT_ID|CAL_PROPERTY_FLAGS_FILTER) , "account_id"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EVENT_ID, "event_id"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_START, "dtstart_type,dtstart_utime,dtstart_datetime"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_END, "dtend_type,dtend_utime,dtend_datetime"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_SUMMARY, "summary"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_LOCATION, "location"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_CALENDAR_ID, "calendar_id"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_DESCRIPTION, "description"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_BUSY_STATUS, "busy_status"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EVENT_STATUS, "task_status"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_PRIORITY, "priority"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_SENSITIVITY, "sensitivity"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_HAS_RRULE, "rrule_id"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_LATITUDE, "latitude"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_LONGITUDE, "longitude"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_HAS_ALARM, "has_alarm"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_ORIGINAL_EVENT_ID, "original_event_id"},
+ {(CAL_PROPERTY_CALENDAR_VISIBILITY|CAL_PROPERTY_FLAGS_FILTER), "visibility"},
+ {(CAL_PROPERTY_CALENDAR_ACCOUNT_ID|CAL_PROPERTY_FLAGS_FILTER), "account_id"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_LAST_MODIFIED_TIME, "last_mod"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_SYNC_DATA1, "sync_data1"},
};
-const cal_property_info_s __property_search_event_calendar_attendee[] =
+const cal_property_info_s __property_search_instance_localtime_calendar[] =
{
- {CAL_PROPERTY_EVENT_ID, "id"},
- {CAL_PROPERTY_EVENT_CALENDAR_ID, "calendar_id"},
- {CAL_PROPERTY_EVENT_SUMMARY, "summary"},
- {CAL_PROPERTY_EVENT_DESCRIPTION, "description"},
- {CAL_PROPERTY_EVENT_LOCATION, "location"},
- {CAL_PROPERTY_EVENT_CATEGORIES, "categories"},
- {CAL_PROPERTY_EVENT_EXDATE, "exdate"},
- {CAL_PROPERTY_EVENT_EVENT_STATUS, "task_status"},
- {CAL_PROPERTY_EVENT_PRIORITY, "priority"},
- {CAL_PROPERTY_EVENT_TIMEZONE, "timezone"},
- {CAL_PROPERTY_EVENT_CONTACT_ID, "contact_id"},
- {CAL_PROPERTY_EVENT_BUSY_STATUS, "busy_status"},
- {CAL_PROPERTY_EVENT_SENSITIVITY, "sensitivity"},
- {CAL_PROPERTY_EVENT_UID, "uid"},
- {CAL_PROPERTY_EVENT_ORGANIZER_NAME, "organizer_name"},
- {CAL_PROPERTY_EVENT_ORGANIZER_EMAIL, "organizer_email"},
- {CAL_PROPERTY_EVENT_MEETING_STATUS, "meeting_status"},
- {CAL_PROPERTY_EVENT_ORIGINAL_EVENT_ID, "original_event_id"},
- {CAL_PROPERTY_EVENT_LATITUDE, "latitude"},
- {CAL_PROPERTY_EVENT_LONGITUDE, "longitude"},
- {CAL_PROPERTY_EVENT_EMAIL_ID, "email_id"},
- {CAL_PROPERTY_EVENT_CREATED_TIME, "created_time"},
- {CAL_PROPERTY_EVENT_LAST_MODIFIED_TIME, "last_mod"},
- {CAL_PROPERTY_EVENT_IS_DELETED, "is_deleted"},
- {CAL_PROPERTY_EVENT_FREQ, "freq"},
- {CAL_PROPERTY_EVENT_RANGE_TYPE, "range_type"},
- {CAL_PROPERTY_EVENT_UNTIL, "until_type, until_utime, until_datetime"},
- {CAL_PROPERTY_EVENT_COUNT, "count"},
- {CAL_PROPERTY_EVENT_INTERVAL, "interval"},
- {CAL_PROPERTY_EVENT_BYSECOND, "bysecond"},
- {CAL_PROPERTY_EVENT_BYMINUTE, "byminute"},
- {CAL_PROPERTY_EVENT_BYHOUR, "byhour"},
- {CAL_PROPERTY_EVENT_BYDAY, "byday"},
- {CAL_PROPERTY_EVENT_BYMONTHDAY, "bymonthday"},
- {CAL_PROPERTY_EVENT_BYYEARDAY, "byyearday"},
- {CAL_PROPERTY_EVENT_BYWEEKNO, "byweekno"},
- {CAL_PROPERTY_EVENT_BYMONTH, "bymonth"},
- {CAL_PROPERTY_EVENT_BYSETPOS, "bysetpos"},
- {CAL_PROPERTY_EVENT_WKST, "wkst"},
- {CAL_PROPERTY_EVENT_RECURRENCE_ID, "recurrence_id"},
- {CAL_PROPERTY_EVENT_RDATE, "rdate"},
- {CAL_PROPERTY_EVENT_HAS_ATTENDEE, "has_attendee"},
- {CAL_PROPERTY_EVENT_HAS_ALARM, "has_alarm"},
- {CAL_PROPERTY_EVENT_SYNC_DATA1, "sync_data1"},
- {CAL_PROPERTY_EVENT_SYNC_DATA2, "sync_data2"},
- {CAL_PROPERTY_EVENT_SYNC_DATA3, "sync_data3"},
- {CAL_PROPERTY_EVENT_SYNC_DATA4, "sync_data4"},
- {CAL_PROPERTY_EVENT_START, "dtstart_type, dtstart_utime, dtstart_datetime"},
- {CAL_PROPERTY_EVENT_END, "dtend_type, dtend_utime, dtend_datetime"},
- {CAL_PROPERTY_EVENT_CALENDAR_SYSTEM_TYPE, "system_type"},
- {CAL_PROPERTY_EVENT_START_TZID, "dtstart_tzid"},
- {CAL_PROPERTY_EVENT_END_TZID, "dtend_tzid"},
- {CAL_PROPERTY_EVENT_IS_ALLDAY, "dtstart_type"},
- {(CAL_PROPERTY_CALENDAR_VISIBILITY|CAL_PROPERTY_FLAGS_FILTER) , "visibility"},
- {(CAL_PROPERTY_CALENDAR_ACCOUNT_ID|CAL_PROPERTY_FLAGS_FILTER) , "account_id"},
- {(CAL_PROPERTY_ATTENDEE_EMAIL|CAL_PROPERTY_FLAGS_FILTER), "attendee_email"},
- {(CAL_PROPERTY_ATTENDEE_NAME|CAL_PROPERTY_FLAGS_FILTER), "attendee_name"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_ID, "event_id"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_START, "dtstart_type,dtstart_utime,dtstart_datetime"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_END, "dtend_type,dtend_utime,dtend_datetime"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_SUMMARY, "summary"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_LOCATION, "location"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_CALENDAR_ID, "calendar_id"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_DESCRIPTION, "description"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_BUSY_STATUS, "busy_status"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_STATUS, "task_status"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_PRIORITY, "priority"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_SENSITIVITY, "sensitivity"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_HAS_RRULE, "rrule_id"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_LATITUDE, "latitude"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_LONGITUDE, "longitude"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_HAS_ALARM, "has_alarm"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_ORIGINAL_EVENT_ID, "original_event_id"},
+ {(CAL_PROPERTY_CALENDAR_VISIBILITY|CAL_PROPERTY_FLAGS_FILTER), "visibility"},
+ {(CAL_PROPERTY_CALENDAR_ACCOUNT_ID|CAL_PROPERTY_FLAGS_FILTER), "account_id"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_LAST_MODIFIED_TIME, "last_mod"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_SYNC_DATA1, "sync_data1"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_IS_ALLDAY, "is_allday"},
};
-const cal_property_info_s __property_search_instance_normal_calendar[] =
+const cal_property_info_s __property_search_instance_utime_calendar_extended[] =
{
- {CAL_PROPERTY_INSTANCE_NORMAL_EVENT_ID, "event_id"},
- {CAL_PROPERTY_INSTANCE_NORMAL_START, "dtstart_type, dtstart_utime, dtstart_datetime"},
- {CAL_PROPERTY_INSTANCE_NORMAL_END, "dtend_type, dtend_utime, dtend_datetime"},
- {CAL_PROPERTY_INSTANCE_NORMAL_SUMMARY, "summary"},
- {CAL_PROPERTY_INSTANCE_NORMAL_LOCATION, "location"},
- {CAL_PROPERTY_INSTANCE_NORMAL_CALENDAR_ID, "calendar_id"},
- {CAL_PROPERTY_INSTANCE_NORMAL_DESCRIPTION, "description"},
- {CAL_PROPERTY_INSTANCE_NORMAL_BUSY_STATUS, "busy_status"},
- {CAL_PROPERTY_INSTANCE_NORMAL_EVENT_STATUS, "task_status"},
- {CAL_PROPERTY_INSTANCE_NORMAL_PRIORITY, "priority"},
- {CAL_PROPERTY_INSTANCE_NORMAL_SENSITIVITY, "sensitivity"},
- {CAL_PROPERTY_INSTANCE_NORMAL_HAS_RRULE, "rrule_id"},
- {CAL_PROPERTY_INSTANCE_NORMAL_LATITUDE, "latitude"},
- {CAL_PROPERTY_INSTANCE_NORMAL_LONGITUDE, "longitude"},
- {CAL_PROPERTY_INSTANCE_NORMAL_HAS_ALARM, "has_alarm"},
- {CAL_PROPERTY_INSTANCE_NORMAL_ORIGINAL_EVENT_ID, "original_event_id"},
- {(CAL_PROPERTY_CALENDAR_VISIBILITY|CAL_PROPERTY_FLAGS_FILTER) , "visibility"},
- {(CAL_PROPERTY_CALENDAR_ACCOUNT_ID|CAL_PROPERTY_FLAGS_FILTER) , "account_id"},
- {CAL_PROPERTY_INSTANCE_NORMAL_LAST_MODIFIED_TIME, "last_mod"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_EVENT_ID, "event_id"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_START, "dtstart_type,dtstart_utime,dtstart_datetime"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_END, "dtend_type,dtend_utime,dtend_datetime"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SUMMARY, "summary"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LOCATION, "location"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_CALENDAR_ID, "calendar_id"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_DESCRIPTION, "description"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_BUSY_STATUS, "busy_status"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_EVENT_STATUS, "task_status"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_PRIORITY, "priority"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SENSITIVITY, "sensitivity"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_HAS_RRULE, "rrule_id"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LATITUDE, "latitude"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LONGITUDE, "longitude"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_HAS_ALARM, "has_alarm"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_ORIGINAL_EVENT_ID, "original_event_id"},
+ {(CAL_PROPERTY_CALENDAR_VISIBILITY|CAL_PROPERTY_FLAGS_FILTER), "visibility"},
+ {(CAL_PROPERTY_CALENDAR_ACCOUNT_ID|CAL_PROPERTY_FLAGS_FILTER), "account_id"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LAST_MODIFIED_TIME, "last_mod"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA1, "sync_data1"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_ORGANIZER_NAME, "organizer_name"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_CATEGORIES, "categories"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_HAS_ATTENDEE, "has_attendee"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA2, "sync_data2"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA3, "sync_data3"},
+ {CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA4, "sync_data4"},
};
-const cal_property_info_s __property_search_instance_allday_calendar[] =
+const cal_property_info_s __property_search_instance_localtime_calendar_extended[] =
{
- {CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_ID, "event_id"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_START, "dtstart_type, dtstart_utime, dtstart_datetime"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_END, "dtend_type, dtend_utime, dtend_datetime"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_SUMMARY, "summary"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_LOCATION, "location"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_CALENDAR_ID, "calendar_id"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_DESCRIPTION, "description"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_BUSY_STATUS, "busy_status"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_STATUS, "task_status"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_PRIORITY, "priority"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_SENSITIVITY, "sensitivity"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_HAS_RRULE, "rrule_id"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_LATITUDE, "latitude"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_LONGITUDE, "longitude"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_HAS_ALARM, "has_alarm"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_ORIGINAL_EVENT_ID, "original_event_id"},
- {(CAL_PROPERTY_CALENDAR_VISIBILITY|CAL_PROPERTY_FLAGS_FILTER) , "visibility"},
- {(CAL_PROPERTY_CALENDAR_ACCOUNT_ID|CAL_PROPERTY_FLAGS_FILTER) , "account_id"},
- {CAL_PROPERTY_INSTANCE_ALLDAY_LAST_MODIFIED_TIME, "last_mod"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_EVENT_ID, "event_id"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_START, "dtstart_type,dtstart_utime,dtstart_datetime"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_END, "dtend_type,dtend_utime,dtend_datetime"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SUMMARY, "summary"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_LOCATION, "location"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_CALENDAR_ID, "calendar_id"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_DESCRIPTION, "description"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_BUSY_STATUS, "busy_status"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_EVENT_STATUS, "task_status"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_PRIORITY, "priority"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SENSITIVITY, "sensitivity"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_HAS_RRULE, "rrule_id"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_LATITUDE, "latitude"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_LONGITUDE, "longitude"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_HAS_ALARM, "has_alarm"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_ORIGINAL_EVENT_ID, "original_event_id"},
+ {(CAL_PROPERTY_CALENDAR_VISIBILITY|CAL_PROPERTY_FLAGS_FILTER), "visibility"},
+ {(CAL_PROPERTY_CALENDAR_ACCOUNT_ID|CAL_PROPERTY_FLAGS_FILTER), "account_id"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_LAST_MODIFIED_TIME, "last_mod"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA1, "sync_data1"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_ORGANIZER_NAME, "organizer_name"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_CATEGORIES, "categories"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_HAS_ATTENDEE, "has_attendee"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA2, "sync_data2"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA3, "sync_data3"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA4, "sync_data4"},
+ {CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_IS_ALLDAY, "is_allday"},
};
const cal_property_info_s __property_extended[] =
{
- {CAL_PROPERTY_EXTENDED_ID, "id"},
- {CAL_PROPERTY_EXTENDED_RECORD_ID, "record_id"},
- {CAL_PROPERTY_EXTENDED_RECORD_TYPE, "record_type"},
- {CAL_PROPERTY_EXTENDED_KEY, "key"},
- {CAL_PROPERTY_EXTENDED_VALUE, "value"},
+ {CAL_PROPERTY_EXTENDED_ID, "id"},
+ {CAL_PROPERTY_EXTENDED_RECORD_ID, "record_id"},
+ {CAL_PROPERTY_EXTENDED_RECORD_TYPE, "record_type"},
+ {CAL_PROPERTY_EXTENDED_KEY, "key"},
+ {CAL_PROPERTY_EXTENDED_VALUE, "value"},
};
typedef struct {
- char *view_uri;
- cal_record_type_e type;
- cal_property_info_s *properties;
- int property_count;
+ char *view_uri;
+ cal_record_type_e type;
+ cal_property_info_s *properties;
+ int property_count;
}cal_view_uri_info_s;
#define PTR_COUNT(X) (void*)(X), sizeof(X)/sizeof(cal_property_info_s)
static const cal_view_uri_info_s __tables[] = {
- {CALENDAR_VIEW_CALENDAR, CAL_RECORD_TYPE_CALENDAR, PTR_COUNT(__property_calendar_book) },
- {CALENDAR_VIEW_EVENT, CAL_RECORD_TYPE_EVENT, PTR_COUNT(__property_event) },
- {CALENDAR_VIEW_TODO, CAL_RECORD_TYPE_TODO, PTR_COUNT(__property_todo) },
- {CALENDAR_VIEW_TIMEZONE, CAL_RECORD_TYPE_TIMEZONE, PTR_COUNT(__property_timezone) },
- {CALENDAR_VIEW_ATTENDEE, CAL_RECORD_TYPE_ATTENDEE, PTR_COUNT(__property_attendee) },
- {CALENDAR_VIEW_ALARM, CAL_RECORD_TYPE_ALARM, PTR_COUNT(__property_alarm) },
- {CALENDAR_VIEW_INSTANCE_NORMAL, CAL_RECORD_TYPE_INSTANCE_NORMAL, PTR_COUNT(__property_instance_normal) },
- {CALENDAR_VIEW_INSTANCE_ALLDAY, CAL_RECORD_TYPE_INSTANCE_ALLDAY, PTR_COUNT(__property_instance_allday) },
- {CALENDAR_VIEW_UPDATED_INFO, CAL_RECORD_TYPE_UPDATED_INFO, PTR_COUNT(__property_updated_info) },
- {CALENDAR_VIEW_EVENT_CALENDAR, CAL_RECORD_TYPE_SEARCH, PTR_COUNT(__property_search_event_calendar) },
- {CALENDAR_VIEW_TODO_CALENDAR, CAL_RECORD_TYPE_SEARCH, PTR_COUNT(__property_search_todo_calendar ) },
- {CALENDAR_VIEW_EVENT_CALENDAR_ATTENDEE, CAL_RECORD_TYPE_SEARCH, PTR_COUNT(__property_search_event_calendar_attendee) },
- {CALENDAR_VIEW_INSTANCE_NORMAL_CALENDAR, CAL_RECORD_TYPE_INSTANCE_NORMAL, PTR_COUNT(__property_search_instance_normal_calendar) },
- {CALENDAR_VIEW_INSTANCE_ALLDAY_CALENDAR, CAL_RECORD_TYPE_INSTANCE_ALLDAY, PTR_COUNT(__property_search_instance_allday_calendar) },
- {CALENDAR_VIEW_EXTENDED, CAL_RECORD_TYPE_EXTENDED, PTR_COUNT(__property_extended) },
+ {CALENDAR_VIEW_CALENDAR, CAL_RECORD_TYPE_CALENDAR, PTR_COUNT(__property_calendar_book) },
+ {CALENDAR_VIEW_EVENT, CAL_RECORD_TYPE_EVENT, PTR_COUNT(__property_event) },
+ {CALENDAR_VIEW_TODO, CAL_RECORD_TYPE_TODO, PTR_COUNT(__property_todo) },
+ {CALENDAR_VIEW_TIMEZONE, CAL_RECORD_TYPE_TIMEZONE, PTR_COUNT(__property_timezone) },
+ {CALENDAR_VIEW_ATTENDEE, CAL_RECORD_TYPE_ATTENDEE, PTR_COUNT(__property_attendee) },
+ {CALENDAR_VIEW_ALARM, CAL_RECORD_TYPE_ALARM, PTR_COUNT(__property_alarm) },
+ {CALENDAR_VIEW_UPDATED_INFO, CAL_RECORD_TYPE_UPDATED_INFO, PTR_COUNT(__property_updated_info) },
+ {CALENDAR_VIEW_EVENT_CALENDAR, CAL_RECORD_TYPE_SEARCH, PTR_COUNT(__property_search_event_calendar) },
+ {CALENDAR_VIEW_TODO_CALENDAR, CAL_RECORD_TYPE_SEARCH, PTR_COUNT(__property_search_todo_calendar ) },
+ {CALENDAR_VIEW_EVENT_CALENDAR_ATTENDEE, CAL_RECORD_TYPE_SEARCH, PTR_COUNT(__property_search_event_calendar_attendee) },
+ {CALENDAR_VIEW_INSTANCE_UTIME_CALENDAR, CAL_RECORD_TYPE_INSTANCE_NORMAL, PTR_COUNT(__property_search_instance_utime_calendar) },
+ {CALENDAR_VIEW_INSTANCE_LOCALTIME_CALENDAR, CAL_RECORD_TYPE_INSTANCE_ALLDAY, PTR_COUNT(__property_search_instance_localtime_calendar) },
+ {CALENDAR_VIEW_INSTANCE_UTIME_CALENDAR_EXTENDED, CAL_RECORD_TYPE_INSTANCE_NORMAL_EXTENDED, PTR_COUNT(__property_search_instance_utime_calendar_extended) },
+ {CALENDAR_VIEW_INSTANCE_LOCALTIME_CALENDAR_EXTENDED, CAL_RECORD_TYPE_INSTANCE_ALLDAY_EXTENDED, PTR_COUNT(__property_search_instance_localtime_calendar_extended) },
+ {CALENDAR_VIEW_EXTENDED, CAL_RECORD_TYPE_EXTENDED, PTR_COUNT(__property_extended) },
};
//////////////////////
static bool cal_uri_property_flag = false;
static GHashTable *cal_uri_property_hash = NULL;
+#ifdef CAL_IPC_CLIENT
+static int calendar_view_count = 0;
+#endif
void _cal_view_initialize(void)
{
- bool bmutex = false;
+ bool bmutex = false;
+
+#ifdef CAL_IPC_CLIENT
+ _cal_mutex_lock(CAL_MUTEX_PROPERTY_HASH);
+ calendar_view_count++;
+ _cal_mutex_unlock(CAL_MUTEX_PROPERTY_HASH);
+#endif
- if (cal_uri_property_flag == false)
- {
- _cal_mutex_lock(CAL_MUTEX_PROPERTY_HASH);
- bmutex = true;
- }
+ if (cal_uri_property_flag == false)
+ {
+ _cal_mutex_lock(CAL_MUTEX_PROPERTY_HASH);
+ bmutex = true;
+ }
- if ( cal_uri_property_hash == NULL)
- {
- cal_uri_property_hash = g_hash_table_new(g_str_hash, g_str_equal);
- if (cal_uri_property_hash)
- {
- g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_CALENDAR, GINT_TO_POINTER(&(__tables[0])) );
- g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_EVENT, GINT_TO_POINTER(&(__tables[1])) );
- g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_TODO, GINT_TO_POINTER(&(__tables[2])) );
- g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_TIMEZONE, GINT_TO_POINTER(&(__tables[3])));
- g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_ATTENDEE, GINT_TO_POINTER(&(__tables[4])));
- g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_ALARM, GINT_TO_POINTER(&(__tables[5])));
- g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_INSTANCE_NORMAL, GINT_TO_POINTER(&(__tables[6])));
- g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_INSTANCE_ALLDAY, GINT_TO_POINTER(&(__tables[7])));
- g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_UPDATED_INFO, GINT_TO_POINTER(&(__tables[8])));
- g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_EVENT_CALENDAR, GINT_TO_POINTER(&(__tables[9])));
- g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_TODO_CALENDAR, GINT_TO_POINTER(&(__tables[10])));
- g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_EVENT_CALENDAR_ATTENDEE, GINT_TO_POINTER(&(__tables[11])));
- g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_INSTANCE_NORMAL_CALENDAR, GINT_TO_POINTER(&(__tables[12])));
- g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_INSTANCE_ALLDAY_CALENDAR, GINT_TO_POINTER(&(__tables[13])));
- g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_EXTENDED, GINT_TO_POINTER(&(__tables[14])));
- }
- }
+ if ( cal_uri_property_hash == NULL)
+ {
+ cal_uri_property_hash = g_hash_table_new(g_str_hash, g_str_equal);
+ if (cal_uri_property_hash)
+ {
+ g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_CALENDAR, GINT_TO_POINTER(&(__tables[0])) );
+ g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_EVENT, GINT_TO_POINTER(&(__tables[1])) );
+ g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_TODO, GINT_TO_POINTER(&(__tables[2])) );
+ g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_TIMEZONE, GINT_TO_POINTER(&(__tables[3])));
+ g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_ATTENDEE, GINT_TO_POINTER(&(__tables[4])));
+ g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_ALARM, GINT_TO_POINTER(&(__tables[5])));
+ g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_UPDATED_INFO, GINT_TO_POINTER(&(__tables[6])));
+ g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_EVENT_CALENDAR, GINT_TO_POINTER(&(__tables[7])));
+ g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_TODO_CALENDAR, GINT_TO_POINTER(&(__tables[8])));
+ g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_EVENT_CALENDAR_ATTENDEE, GINT_TO_POINTER(&(__tables[9])));
+ g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_INSTANCE_UTIME_CALENDAR, GINT_TO_POINTER(&(__tables[10])));
+ g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_INSTANCE_LOCALTIME_CALENDAR, GINT_TO_POINTER(&(__tables[11])));
+ g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_INSTANCE_UTIME_CALENDAR_EXTENDED, GINT_TO_POINTER(&(__tables[12])));
+ g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_INSTANCE_LOCALTIME_CALENDAR_EXTENDED, GINT_TO_POINTER(&(__tables[13])));
+ g_hash_table_insert(cal_uri_property_hash, CALENDAR_VIEW_EXTENDED, GINT_TO_POINTER(&(__tables[14])));
+ }
+ }
- if (bmutex == true)
- {
- cal_uri_property_flag = true;
- _cal_mutex_unlock(CAL_MUTEX_PROPERTY_HASH);
- }
+ if (bmutex == true)
+ {
+ cal_uri_property_flag = true;
+ _cal_mutex_unlock(CAL_MUTEX_PROPERTY_HASH);
+ }
return ;
}
cal_record_type_e _cal_view_get_type(const char *view_uri)
{
- cal_view_uri_info_s* view_uri_info = NULL;
- cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
+ cal_view_uri_info_s* view_uri_info = NULL;
+ cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
- if(cal_uri_property_hash){
- view_uri_info = g_hash_table_lookup(cal_uri_property_hash, view_uri);
- if( view_uri_info ) {
- type = view_uri_info->type;
- //CAL_DBG("%s:%d",view_uri,type);
- }
+ if(cal_uri_property_hash){
+ view_uri_info = g_hash_table_lookup(cal_uri_property_hash, view_uri);
+ if( view_uri_info ) {
+ type = view_uri_info->type;
+ //CAL_DBG("%s:%d",view_uri,type);
+ }
else
{
ERR("g_hash_table_lookup() failed");
}
- }
+ }
else
{
- ERR("Unable to get cal_uri_property_hash");
+ ERR("Unable to get cal_uri_property_hash[%s]", view_uri);
}
return type;
void _cal_view_finalize(void)
{
-#if 0
- if( cal_uri_property_hash != NULL) {
- g_hash_table_destroy(cal_uri_property_hash);
- cal_uri_property_hash = NULL;
- }
+#ifdef CAL_IPC_CLIENT
+ _cal_mutex_lock(CAL_MUTEX_PROPERTY_HASH);
+ if (calendar_view_count <= 0)
+ {
+ _cal_mutex_unlock(CAL_MUTEX_PROPERTY_HASH);
+ return ;
+ }
+ calendar_view_count--;
+
+ if (calendar_view_count == 0)
+ {
+ if (cal_uri_property_hash != NULL) {
+ g_hash_table_destroy(cal_uri_property_hash);
+ cal_uri_property_hash = NULL;
+ }
+ }
+ _cal_mutex_unlock(CAL_MUTEX_PROPERTY_HASH);
#endif
}
const cal_property_info_s* _cal_view_get_property_info(const char *view_uri, int *count)
{
- cal_property_info_s* tmp = NULL;
- cal_view_uri_info_s* view_uri_info = NULL;
+ cal_property_info_s* tmp = NULL;
+ cal_view_uri_info_s* view_uri_info = NULL;
- if(cal_uri_property_hash){
- view_uri_info = g_hash_table_lookup(cal_uri_property_hash, view_uri);
- if( view_uri_info ) {
- tmp = view_uri_info->properties;
- *count = view_uri_info->property_count;
- }
- }
+ if(cal_uri_property_hash){
+ view_uri_info = g_hash_table_lookup(cal_uri_property_hash, view_uri);
+ if( view_uri_info ) {
+ tmp = view_uri_info->properties;
+ *count = view_uri_info->property_count;
+ }
+ }
- return tmp;
+ return tmp;
}
const char* _cal_view_get_uri(const char *view_uri)
{
- cal_view_uri_info_s* view_uri_info = NULL;
+ cal_view_uri_info_s* view_uri_info = NULL;
- if(cal_uri_property_hash){
- view_uri_info = g_hash_table_lookup(cal_uri_property_hash, view_uri);
- if( view_uri_info ) {
- return view_uri_info->view_uri;
- }
- }
+ if(cal_uri_property_hash){
+ view_uri_info = g_hash_table_lookup(cal_uri_property_hash, view_uri);
+ if( view_uri_info ) {
+ return view_uri_info->view_uri;
+ }
+ }
- return NULL;
+ return NULL;
}
#include "calendar_view.h"
-_CALENDAR_BEGIN_VIEW()
- _CALENDAR_PROPERTY_INT( event_id )
- _CALENDAR_PROPERTY_CALTIME( start_time )
- _CALENDAR_PROPERTY_CALTIME( end_time )
- _CALENDAR_PROPERTY_STR( summary )
- _CALENDAR_PROPERTY_STR( location )
- _CALENDAR_PROPERTY_INT( calendar_book_id )
- _CALENDAR_PROPERTY_STR( description )
- _CALENDAR_PROPERTY_INT( busy_status )
- _CALENDAR_PROPERTY_INT( event_status )
- _CALENDAR_PROPERTY_INT( priority )
- _CALENDAR_PROPERTY_INT( sensitivity )
- _CALENDAR_PROPERTY_INT( has_rrule )
- _CALENDAR_PROPERTY_DOUBLE( latitude )
- _CALENDAR_PROPERTY_DOUBLE( longitude )
- _CALENDAR_PROPERTY_INT( has_alarm )
- _CALENDAR_PROPERTY_INT( original_event_id )
- _CALENDAR_PROPERTY_LLI( last_modified_time )
-_CALENDAR_END_VIEW( _calendar_instance_normal ) // read_only
-
-_CALENDAR_BEGIN_VIEW()
- _CALENDAR_PROPERTY_INT( event_id )
- _CALENDAR_PROPERTY_CALTIME( start_time )
- _CALENDAR_PROPERTY_CALTIME( end_time )
- _CALENDAR_PROPERTY_STR( summary )
- _CALENDAR_PROPERTY_STR( location )
- _CALENDAR_PROPERTY_INT( calendar_book_id )
- _CALENDAR_PROPERTY_STR( description )
- _CALENDAR_PROPERTY_INT( busy_status )
- _CALENDAR_PROPERTY_INT( event_status )
- _CALENDAR_PROPERTY_INT( priority )
- _CALENDAR_PROPERTY_INT( sensitivity )
- _CALENDAR_PROPERTY_INT( has_rrule )
- _CALENDAR_PROPERTY_DOUBLE( latitude )
- _CALENDAR_PROPERTY_DOUBLE( longitude )
- _CALENDAR_PROPERTY_INT( has_alarm )
- _CALENDAR_PROPERTY_INT( original_event_id )
- _CALENDAR_PROPERTY_LLI( last_modified_time )
-_CALENDAR_END_VIEW( _calendar_instance_allday ) // read_only
-
// db record view // get, get_list, insert, update, delete, filter
#define CALENDAR_VIEW_CALENDAR "tizen.calendar_view.calendar"
#define CALENDAR_VIEW_EVENT "tizen.calendar_view.event"
#define CALENDAR_VIEW_ATTENDEE "tizen.calendar_view.attendee"
#define CALENDAR_VIEW_ALARM "tizen.calendar_view.alarm"
-// logical view // get_list, filter
-#define CALENDAR_VIEW_INSTANCE_NORMAL "tizen.calendar_view.instance_normal"
-#define CALENDAR_VIEW_INSTANCE_ALLDAY "tizen.calendar_view.instance_allday"
-
// updated info // get_list
#define CALENDAR_VIEW_UPDATED_INFO "tizen.calendar_view.updated_info"
// extended_table
-#define CALENDAR_VIEW_EXTENDED "tizen,calendar_view.extended_property"
+#define CALENDAR_VIEW_EXTENDED "tizen.calendar_view.extended_property"
// only for query (filter)
#define CALENDAR_VIEW_EVENT_CALENDAR "tizen.calendar_view.event/calendar"
-#define CALENDAR_VIEW_TODO_CALENDAR "tizen.calendar_view.todo/calendar"
+#define CALENDAR_VIEW_TODO_CALENDAR "tizen.calendar_view.todo/calendar"
#define CALENDAR_VIEW_EVENT_CALENDAR_ATTENDEE "tizen.calendar_view.event/calendar/attendee"
-#define CALENDAR_VIEW_INSTANCE_NORMAL_CALENDAR "tizen.calendar_view.instance_normal/calendar"
-#define CALENDAR_VIEW_INSTANCE_ALLDAY_CALENDAR "tizen.calendar_view.instance_allday/calendar"
+#define CALENDAR_VIEW_INSTANCE_UTIME_CALENDAR "tizen.calendar_view.instance_utime/calendar"
+#define CALENDAR_VIEW_INSTANCE_LOCALTIME_CALENDAR "tizen.calendar_view.instance_localtime/calendar"
+#define CALENDAR_VIEW_INSTANCE_UTIME_CALENDAR_EXTENDED "tizen.calendar_view.extended/instance_utime/calendar"
+#define CALENDAR_VIEW_INSTANCE_LOCALTIME_CALENDAR_EXTENDED "tizen.calendar_view.extended/instance_localtime/calendar"
// for type check // data_type mask 0x000FF000
#define CAL_PROPERTY_DATA_TYPE_MASK 0x000FF000
#define CAL_PROPERTY_DATA_TYPE_CALTIME 0x00005000
#define CAL_PROPERTY_DATA_TYPE_REC 0x00006000
#define CAL_PROPERTY_CHECK_DATA_TYPE(property_id,data_type) \
- ((property_id&CAL_PROPERTY_DATA_TYPE_MASK) == data_type ? true : false)
+ ((property_id&CAL_PROPERTY_DATA_TYPE_MASK) == data_type ? true : false)
// for property // 0xFF000000
#define CAL_PROPERTY_MASK 0xFF000000
#define CAL_PROPERTY_CALENDAR 0x01000000
#define CAL_PROPERTY_INSTANCE_ALLDAY 0x08000000
#define CAL_PROPERTY_UPDATED_INFO 0x09000000
#define CAL_PROPERTY_EXTENDED 0x0A000000
+#define CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED 0x0B000000
+#define CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED 0x0C000000
#define CAL_PROPERTY_CHECK(property_id,data_type) \
- ((property_id&CAL_PROPERTY_MASK) == data_type ? true : false)
+ ((property_id&CAL_PROPERTY_MASK) == data_type ? true : false)
#define CAL_PROPERTY_FLAGS_MASK 0x00F00000
#define CAL_PROPERTY_FLAGS_FILTER 0x00100000
#define CAL_PROPERTY_FLAGS_PROJECTION 0x00200000
#define CAL_PROPERTY_FLAGS_READ_ONLY 0x00300000
#define CAL_PROPERTY_CHECK_FLAGS(property_id,data_type) \
- ((property_id&CAL_PROPERTY_FLAGS_MASK) == data_type ? true : false)
+ ((property_id&CAL_PROPERTY_FLAGS_MASK) == data_type ? true : false)
typedef enum {
CAL_PROPERTY_CALENDAR_ID = (CAL_PROPERTY_CALENDAR|CAL_PROPERTY_DATA_TYPE_INT|CAL_PROPERTY_FLAGS_READ_ONLY),
CAL_PROPERTY_CALENDAR_LOCATION = (CAL_PROPERTY_CALENDAR|CAL_PROPERTY_DATA_TYPE_STR) +5,
CAL_PROPERTY_CALENDAR_VISIBILITY = (CAL_PROPERTY_CALENDAR|CAL_PROPERTY_DATA_TYPE_INT) +6,
CAL_PROPERTY_CALENDAR_SYNC_EVENT = (CAL_PROPERTY_CALENDAR|CAL_PROPERTY_DATA_TYPE_INT) +7,
- CAL_PROPERTY_CALENDAR_IS_DELETED = (CAL_PROPERTY_CALENDAR|CAL_PROPERTY_DATA_TYPE_INT) +8,
- CAL_PROPERTY_CALENDAR_ACCOUNT_ID = (CAL_PROPERTY_CALENDAR|CAL_PROPERTY_DATA_TYPE_INT) +9,
- CAL_PROPERTY_CALENDAR_STORE_TYPE = (CAL_PROPERTY_CALENDAR|CAL_PROPERTY_DATA_TYPE_INT) +10,
- CAL_PROPERTY_CALENDAR_SYNC_DATA1 = (CAL_PROPERTY_CALENDAR|CAL_PROPERTY_DATA_TYPE_STR) +11,
- CAL_PROPERTY_CALENDAR_SYNC_DATA2 = (CAL_PROPERTY_CALENDAR|CAL_PROPERTY_DATA_TYPE_STR) +12,
- CAL_PROPERTY_CALENDAR_SYNC_DATA3 = (CAL_PROPERTY_CALENDAR|CAL_PROPERTY_DATA_TYPE_STR) +13,
- CAL_PROPERTY_CALENDAR_SYNC_DATA4 = (CAL_PROPERTY_CALENDAR|CAL_PROPERTY_DATA_TYPE_STR) +14,
+ CAL_PROPERTY_CALENDAR_ACCOUNT_ID = (CAL_PROPERTY_CALENDAR|CAL_PROPERTY_DATA_TYPE_INT) +8,
+ CAL_PROPERTY_CALENDAR_STORE_TYPE = (CAL_PROPERTY_CALENDAR|CAL_PROPERTY_DATA_TYPE_INT) +9,
+ CAL_PROPERTY_CALENDAR_SYNC_DATA1 = (CAL_PROPERTY_CALENDAR|CAL_PROPERTY_DATA_TYPE_STR) +10,
+ CAL_PROPERTY_CALENDAR_SYNC_DATA2 = (CAL_PROPERTY_CALENDAR|CAL_PROPERTY_DATA_TYPE_STR) +11,
+ CAL_PROPERTY_CALENDAR_SYNC_DATA3 = (CAL_PROPERTY_CALENDAR|CAL_PROPERTY_DATA_TYPE_STR) +12,
+ CAL_PROPERTY_CALENDAR_SYNC_DATA4 = (CAL_PROPERTY_CALENDAR|CAL_PROPERTY_DATA_TYPE_STR) +13,
+ CAL_PROPERTY_CALENDAR_MODE = (CAL_PROPERTY_CALENDAR|CAL_PROPERTY_DATA_TYPE_INT) +14,
CAL_PROPERTY_EVENT_ID = (CAL_PROPERTY_EVENT|CAL_PROPERTY_DATA_TYPE_INT|CAL_PROPERTY_FLAGS_READ_ONLY),
CAL_PROPERTY_EVENT_CALENDAR_ID = (CAL_PROPERTY_EVENT|CAL_PROPERTY_DATA_TYPE_INT) +1,
CAL_PROPERTY_EVENT_LONGITUDE = (CAL_PROPERTY_EVENT|CAL_PROPERTY_DATA_TYPE_DOUBLE) +19,
CAL_PROPERTY_EVENT_EMAIL_ID = (CAL_PROPERTY_EVENT|CAL_PROPERTY_DATA_TYPE_INT) +20,
CAL_PROPERTY_EVENT_CREATED_TIME = (CAL_PROPERTY_EVENT|CAL_PROPERTY_DATA_TYPE_LLI) +21,
- CAL_PROPERTY_EVENT_LAST_MODIFIED_TIME = (CAL_PROPERTY_EVENT|CAL_PROPERTY_DATA_TYPE_LLI) +22,
+ CAL_PROPERTY_EVENT_LAST_MODIFIED_TIME = (CAL_PROPERTY_EVENT|CAL_PROPERTY_DATA_TYPE_LLI|CAL_PROPERTY_FLAGS_READ_ONLY) +22,
CAL_PROPERTY_EVENT_IS_DELETED = (CAL_PROPERTY_EVENT|CAL_PROPERTY_DATA_TYPE_INT|CAL_PROPERTY_FLAGS_READ_ONLY) +23,
CAL_PROPERTY_EVENT_FREQ = (CAL_PROPERTY_EVENT|CAL_PROPERTY_DATA_TYPE_INT) +24,
CAL_PROPERTY_EVENT_RANGE_TYPE = (CAL_PROPERTY_EVENT|CAL_PROPERTY_DATA_TYPE_INT) +25,
CAL_PROPERTY_EVENT_END = (CAL_PROPERTY_EVENT|CAL_PROPERTY_DATA_TYPE_CALTIME) +48,
CAL_PROPERTY_EVENT_CALENDAR_ALARM = (CAL_PROPERTY_EVENT|CAL_PROPERTY_DATA_TYPE_REC) +49,
CAL_PROPERTY_EVENT_CALENDAR_ATTENDEE = (CAL_PROPERTY_EVENT|CAL_PROPERTY_DATA_TYPE_REC) +50,
- CAL_PROPERTY_EVENT_CALENDAR_SYSTEM_TYPE = (CAL_PROPERTY_EVENT|CAL_PROPERTY_DATA_TYPE_INT) +51,
- CAL_PROPERTY_EVENT_START_TZID = (CAL_PROPERTY_EVENT|CAL_PROPERTY_DATA_TYPE_STR) +52,
- CAL_PROPERTY_EVENT_END_TZID = (CAL_PROPERTY_EVENT|CAL_PROPERTY_DATA_TYPE_STR) +53,
- CAL_PROPERTY_EVENT_EXCEPTION = (CAL_PROPERTY_EVENT|CAL_PROPERTY_DATA_TYPE_REC) +54,
- CAL_PROPERTY_EVENT_EXTENDED = (CAL_PROPERTY_EVENT|CAL_PROPERTY_DATA_TYPE_REC) +55,
- CAL_PROPERTY_EVENT_IS_ALLDAY = (CAL_PROPERTY_EVENT|CAL_PROPERTY_DATA_TYPE_INT|CAL_PROPERTY_FLAGS_READ_ONLY) +56,
+ CAL_PROPERTY_EVENT_CALENDAR_SYSTEM_TYPE = (CAL_PROPERTY_EVENT|CAL_PROPERTY_DATA_TYPE_INT) +51,
+ CAL_PROPERTY_EVENT_START_TZID = (CAL_PROPERTY_EVENT|CAL_PROPERTY_DATA_TYPE_STR) +52,
+ CAL_PROPERTY_EVENT_END_TZID = (CAL_PROPERTY_EVENT|CAL_PROPERTY_DATA_TYPE_STR) +53,
+ CAL_PROPERTY_EVENT_EXCEPTION = (CAL_PROPERTY_EVENT|CAL_PROPERTY_DATA_TYPE_REC) +54,
+ CAL_PROPERTY_EVENT_EXTENDED = (CAL_PROPERTY_EVENT|CAL_PROPERTY_DATA_TYPE_REC) +55,
+ CAL_PROPERTY_EVENT_IS_ALLDAY = (CAL_PROPERTY_EVENT|CAL_PROPERTY_DATA_TYPE_INT|CAL_PROPERTY_FLAGS_READ_ONLY) +56,
CAL_PROPERTY_TODO_ID =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_INT|CAL_PROPERTY_FLAGS_READ_ONLY),
CAL_PROPERTY_TODO_CALENDAR_ID =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_INT) +1,
CAL_PROPERTY_TODO_LONGITUDE =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_DOUBLE) +11,
CAL_PROPERTY_TODO_PROGRESS =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_INT) +12,
CAL_PROPERTY_TODO_CREATED_TIME =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_LLI) +13,
- CAL_PROPERTY_TODO_LAST_MODIFIED_TIME =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_LLI) +14,
+ CAL_PROPERTY_TODO_LAST_MODIFIED_TIME =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_LLI|CAL_PROPERTY_FLAGS_READ_ONLY) +14,
CAL_PROPERTY_TODO_COMPLETED_TIME =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_LLI) +15,
CAL_PROPERTY_TODO_IS_DELETED =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_INT|CAL_PROPERTY_FLAGS_READ_ONLY) +16,
CAL_PROPERTY_TODO_FREQ =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_INT) +17,
CAL_PROPERTY_TODO_START =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_CALTIME) +37,
CAL_PROPERTY_TODO_DUE =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_CALTIME) +38,
CAL_PROPERTY_TODO_CALENDAR_ALARM =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_REC) +39,
- CAL_PROPERTY_TODO_START_TZID =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_STR) +40,
- CAL_PROPERTY_TODO_DUE_TZID =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_STR) +41,
- CAL_PROPERTY_TODO_ORGANIZER_NAME =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_STR) +42,
- CAL_PROPERTY_TODO_ORGANIZER_EMAIL =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_STR) +43,
- CAL_PROPERTY_TODO_HAS_ATTENDEE =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_INT|CAL_PROPERTY_FLAGS_READ_ONLY) +44,
- CAL_PROPERTY_TODO_CALENDAR_ATTENDEE =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_REC) +45,
- CAL_PROPERTY_TODO_EXTENDED =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_REC) +46,
- CAL_PROPERTY_TODO_IS_ALLDAY =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_INT|CAL_PROPERTY_FLAGS_READ_ONLY) +47,
+ CAL_PROPERTY_TODO_START_TZID =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_STR) +40,
+ CAL_PROPERTY_TODO_DUE_TZID =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_STR) +41,
+ CAL_PROPERTY_TODO_ORGANIZER_NAME =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_STR) +42,
+ CAL_PROPERTY_TODO_ORGANIZER_EMAIL =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_STR) +43,
+ CAL_PROPERTY_TODO_HAS_ATTENDEE =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_INT|CAL_PROPERTY_FLAGS_READ_ONLY) +44,
+ CAL_PROPERTY_TODO_CALENDAR_ATTENDEE =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_REC) +45,
+ CAL_PROPERTY_TODO_EXTENDED =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_REC) +46,
+ CAL_PROPERTY_TODO_IS_ALLDAY =(CAL_PROPERTY_TODO|CAL_PROPERTY_DATA_TYPE_INT|CAL_PROPERTY_FLAGS_READ_ONLY) +47,
- CAL_PROPERTY_TIMEZONE_ID =(CAL_PROPERTY_TIMEZONE|CAL_PROPERTY_DATA_TYPE_INT|CAL_PROPERTY_FLAGS_READ_ONLY),
+ CAL_PROPERTY_TIMEZONE_ID =(CAL_PROPERTY_TIMEZONE|CAL_PROPERTY_DATA_TYPE_INT|CAL_PROPERTY_FLAGS_READ_ONLY),
CAL_PROPERTY_TIMEZONE_TZ_OFFSET_FROM_GMT =(CAL_PROPERTY_TIMEZONE|CAL_PROPERTY_DATA_TYPE_INT)+1,
CAL_PROPERTY_TIMEZONE_STANDARD_NAME =(CAL_PROPERTY_TIMEZONE|CAL_PROPERTY_DATA_TYPE_STR)+2,
CAL_PROPERTY_TIMEZONE_STD_START_MONTH =(CAL_PROPERTY_TIMEZONE|CAL_PROPERTY_DATA_TYPE_INT)+3,
CAL_PROPERTY_TIMEZONE_DAY_LIGHT_BIAS =(CAL_PROPERTY_TIMEZONE|CAL_PROPERTY_DATA_TYPE_INT)+13,
CAL_PROPERTY_TIMEZONE_CALENDAR_ID =(CAL_PROPERTY_TIMEZONE|CAL_PROPERTY_DATA_TYPE_INT)+14,
-
CAL_PROPERTY_ATTENDEE_NUMBER =(CAL_PROPERTY_ATTENDEE|CAL_PROPERTY_DATA_TYPE_STR),
- CAL_PROPERTY_ATTENDEE_TYPE =(CAL_PROPERTY_ATTENDEE|CAL_PROPERTY_DATA_TYPE_INT)+1,
+ CAL_PROPERTY_ATTENDEE_CUTYPE =(CAL_PROPERTY_ATTENDEE|CAL_PROPERTY_DATA_TYPE_INT)+1,
CAL_PROPERTY_ATTENDEE_CT_INDEX =(CAL_PROPERTY_ATTENDEE|CAL_PROPERTY_DATA_TYPE_INT)+2,
CAL_PROPERTY_ATTENDEE_UID =(CAL_PROPERTY_ATTENDEE|CAL_PROPERTY_DATA_TYPE_STR)+3,
CAL_PROPERTY_ATTENDEE_GROUP =(CAL_PROPERTY_ATTENDEE|CAL_PROPERTY_DATA_TYPE_STR)+4,
CAL_PROPERTY_ATTENDEE_ROLE =(CAL_PROPERTY_ATTENDEE|CAL_PROPERTY_DATA_TYPE_INT)+6,
CAL_PROPERTY_ATTENDEE_STATUS =(CAL_PROPERTY_ATTENDEE|CAL_PROPERTY_DATA_TYPE_INT)+7,
CAL_PROPERTY_ATTENDEE_RSVP =(CAL_PROPERTY_ATTENDEE|CAL_PROPERTY_DATA_TYPE_INT)+8,
- CAL_PROPERTY_ATTENDEE_DELEGATE_URI =(CAL_PROPERTY_ATTENDEE|CAL_PROPERTY_DATA_TYPE_STR)+9,
+ CAL_PROPERTY_ATTENDEE_DELEGATEE_URI =(CAL_PROPERTY_ATTENDEE|CAL_PROPERTY_DATA_TYPE_STR)+9,
CAL_PROPERTY_ATTENDEE_DELEGATOR_URI =(CAL_PROPERTY_ATTENDEE|CAL_PROPERTY_DATA_TYPE_STR)+10,
CAL_PROPERTY_ATTENDEE_NAME =(CAL_PROPERTY_ATTENDEE|CAL_PROPERTY_DATA_TYPE_STR)+11,
- CAL_PROPERTY_ATTENDEE_EVENT_ID =(CAL_PROPERTY_ATTENDEE|CAL_PROPERTY_DATA_TYPE_INT)+12,
+ CAL_PROPERTY_ATTENDEE_MEMBER =(CAL_PROPERTY_ATTENDEE|CAL_PROPERTY_DATA_TYPE_STR)+12,
+ CAL_PROPERTY_ATTENDEE_PARENT_ID =(CAL_PROPERTY_ATTENDEE|CAL_PROPERTY_DATA_TYPE_INT|CAL_PROPERTY_FLAGS_READ_ONLY)+13,
- CAL_PROPERTY_ALARM_TYPE =(CAL_PROPERTY_ALARM|CAL_PROPERTY_DATA_TYPE_INT),
- CAL_PROPERTY_ALARM_TIME =(CAL_PROPERTY_ALARM|CAL_PROPERTY_DATA_TYPE_LLI)+1,
- CAL_PROPERTY_ALARM_TICK =(CAL_PROPERTY_ALARM|CAL_PROPERTY_DATA_TYPE_INT)+2,
- CAL_PROPERTY_ALARM_TICK_UNIT =(CAL_PROPERTY_ALARM|CAL_PROPERTY_DATA_TYPE_INT)+3,
- CAL_PROPERTY_ALARM_TONE =(CAL_PROPERTY_ALARM|CAL_PROPERTY_DATA_TYPE_STR)+4,
- CAL_PROPERTY_ALARM_DESCRIPTION =(CAL_PROPERTY_ALARM|CAL_PROPERTY_DATA_TYPE_STR)+5,
- CAL_PROPERTY_ALARM_ID =(CAL_PROPERTY_ALARM|CAL_PROPERTY_DATA_TYPE_INT)+6,
- CAL_PROPERTY_ALARM_EVENT_TODO_ID =(CAL_PROPERTY_ALARM|CAL_PROPERTY_DATA_TYPE_INT)+7,
+ CAL_PROPERTY_ALARM_TICK =(CAL_PROPERTY_ALARM|CAL_PROPERTY_DATA_TYPE_INT),
+ CAL_PROPERTY_ALARM_TICK_UNIT =(CAL_PROPERTY_ALARM|CAL_PROPERTY_DATA_TYPE_INT)+1,
+ CAL_PROPERTY_ALARM_DESCRIPTION =(CAL_PROPERTY_ALARM|CAL_PROPERTY_DATA_TYPE_STR)+2,
+ CAL_PROPERTY_ALARM_PARENT_ID =(CAL_PROPERTY_ALARM|CAL_PROPERTY_DATA_TYPE_INT|CAL_PROPERTY_FLAGS_READ_ONLY)+3,
+ CAL_PROPERTY_ALARM_SUMMARY =(CAL_PROPERTY_ALARM|CAL_PROPERTY_DATA_TYPE_STR)+4,
+ CAL_PROPERTY_ALARM_ACTION =(CAL_PROPERTY_ALARM|CAL_PROPERTY_DATA_TYPE_INT)+5,
+ CAL_PROPERTY_ALARM_ATTACH =(CAL_PROPERTY_ALARM|CAL_PROPERTY_DATA_TYPE_STR)+6,
+ CAL_PROPERTY_ALARM_ALARM =(CAL_PROPERTY_ALARM|CAL_PROPERTY_DATA_TYPE_CALTIME)+7,
- CAL_PROPERTY_INSTANCE_NORMAL_EVENT_ID =(CAL_PROPERTY_INSTANCE_NORMAL|CAL_PROPERTY_DATA_TYPE_INT),
+ CAL_PROPERTY_INSTANCE_NORMAL_EVENT_ID =(CAL_PROPERTY_INSTANCE_NORMAL|CAL_PROPERTY_DATA_TYPE_INT),
CAL_PROPERTY_INSTANCE_NORMAL_START =(CAL_PROPERTY_INSTANCE_NORMAL|CAL_PROPERTY_DATA_TYPE_CALTIME) +1,
CAL_PROPERTY_INSTANCE_NORMAL_END =(CAL_PROPERTY_INSTANCE_NORMAL|CAL_PROPERTY_DATA_TYPE_CALTIME) +2,
CAL_PROPERTY_INSTANCE_NORMAL_SUMMARY =(CAL_PROPERTY_INSTANCE_NORMAL|CAL_PROPERTY_DATA_TYPE_STR)+3,
CAL_PROPERTY_INSTANCE_NORMAL_HAS_ALARM =(CAL_PROPERTY_INSTANCE_NORMAL|CAL_PROPERTY_DATA_TYPE_INT)+14,
CAL_PROPERTY_INSTANCE_NORMAL_ORIGINAL_EVENT_ID =(CAL_PROPERTY_INSTANCE_NORMAL|CAL_PROPERTY_DATA_TYPE_INT)+15,
CAL_PROPERTY_INSTANCE_NORMAL_LAST_MODIFIED_TIME =(CAL_PROPERTY_INSTANCE_NORMAL|CAL_PROPERTY_DATA_TYPE_LLI)+16,
+ CAL_PROPERTY_INSTANCE_NORMAL_SYNC_DATA1 =(CAL_PROPERTY_INSTANCE_NORMAL|CAL_PROPERTY_DATA_TYPE_STR)+17,
- CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_ID =(CAL_PROPERTY_INSTANCE_NORMAL|CAL_PROPERTY_DATA_TYPE_INT),
+ CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_ID =(CAL_PROPERTY_INSTANCE_ALLDAY|CAL_PROPERTY_DATA_TYPE_INT),
CAL_PROPERTY_INSTANCE_ALLDAY_START =(CAL_PROPERTY_INSTANCE_ALLDAY|CAL_PROPERTY_DATA_TYPE_CALTIME) +1,
- CAL_PROPERTY_INSTANCE_ALLDAY_END =(CAL_PROPERTY_INSTANCE_ALLDAY|CAL_PROPERTY_DATA_TYPE_CALTIME) +2,
+ CAL_PROPERTY_INSTANCE_ALLDAY_END =(CAL_PROPERTY_INSTANCE_ALLDAY|CAL_PROPERTY_DATA_TYPE_CALTIME) +2,
CAL_PROPERTY_INSTANCE_ALLDAY_SUMMARY =(CAL_PROPERTY_INSTANCE_ALLDAY|CAL_PROPERTY_DATA_TYPE_STR)+3,
CAL_PROPERTY_INSTANCE_ALLDAY_LOCATION =(CAL_PROPERTY_INSTANCE_ALLDAY|CAL_PROPERTY_DATA_TYPE_STR)+4,
CAL_PROPERTY_INSTANCE_ALLDAY_CALENDAR_ID =(CAL_PROPERTY_INSTANCE_ALLDAY|CAL_PROPERTY_DATA_TYPE_INT)+5,
CAL_PROPERTY_INSTANCE_ALLDAY_HAS_ALARM =(CAL_PROPERTY_INSTANCE_ALLDAY|CAL_PROPERTY_DATA_TYPE_INT)+14,
CAL_PROPERTY_INSTANCE_ALLDAY_ORIGINAL_EVENT_ID =(CAL_PROPERTY_INSTANCE_ALLDAY|CAL_PROPERTY_DATA_TYPE_INT)+15,
CAL_PROPERTY_INSTANCE_ALLDAY_LAST_MODIFIED_TIME =(CAL_PROPERTY_INSTANCE_ALLDAY|CAL_PROPERTY_DATA_TYPE_LLI)+16,
+ CAL_PROPERTY_INSTANCE_ALLDAY_SYNC_DATA1 =(CAL_PROPERTY_INSTANCE_ALLDAY|CAL_PROPERTY_DATA_TYPE_STR)+17,
+ CAL_PROPERTY_INSTANCE_ALLDAY_IS_ALLDAY =(CAL_PROPERTY_INSTANCE_ALLDAY|CAL_PROPERTY_DATA_TYPE_INT|CAL_PROPERTY_FLAGS_READ_ONLY)+18,
+
+ CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_EVENT_ID =(CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED|CAL_PROPERTY_DATA_TYPE_INT),
+ CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_START =(CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED|CAL_PROPERTY_DATA_TYPE_CALTIME) +1,
+ CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_END =(CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED|CAL_PROPERTY_DATA_TYPE_CALTIME) +2,
+ CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SUMMARY =(CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED|CAL_PROPERTY_DATA_TYPE_STR)+3,
+ CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LOCATION =(CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED|CAL_PROPERTY_DATA_TYPE_STR)+4,
+ CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_CALENDAR_ID =(CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED|CAL_PROPERTY_DATA_TYPE_INT)+5,
+ CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_DESCRIPTION =(CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED|CAL_PROPERTY_DATA_TYPE_STR)+6,
+ CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_BUSY_STATUS =(CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED|CAL_PROPERTY_DATA_TYPE_INT)+7,
+ CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_EVENT_STATUS =(CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED|CAL_PROPERTY_DATA_TYPE_INT)+8,
+ CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_PRIORITY =(CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED|CAL_PROPERTY_DATA_TYPE_INT)+9,
+ CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SENSITIVITY =(CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED|CAL_PROPERTY_DATA_TYPE_INT)+10,
+ CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_HAS_RRULE =(CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED|CAL_PROPERTY_DATA_TYPE_INT)+11,
+ CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LATITUDE =(CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED|CAL_PROPERTY_DATA_TYPE_DOUBLE)+12,
+ CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LONGITUDE =(CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED|CAL_PROPERTY_DATA_TYPE_DOUBLE)+13,
+ CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_HAS_ALARM =(CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED|CAL_PROPERTY_DATA_TYPE_INT)+14,
+ CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_ORIGINAL_EVENT_ID =(CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED|CAL_PROPERTY_DATA_TYPE_INT)+15,
+ CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LAST_MODIFIED_TIME =(CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED|CAL_PROPERTY_DATA_TYPE_LLI)+16,
+ CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA1 =(CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED|CAL_PROPERTY_DATA_TYPE_STR)+17,
+ CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_ORGANIZER_NAME =(CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED|CAL_PROPERTY_DATA_TYPE_STR)+18,
+ CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_CATEGORIES =(CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED|CAL_PROPERTY_DATA_TYPE_STR)+19,
+ CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_HAS_ATTENDEE =(CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED|CAL_PROPERTY_DATA_TYPE_INT)+20,
+ CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA2 =(CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED|CAL_PROPERTY_DATA_TYPE_STR)+21,
+ CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA3 =(CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED|CAL_PROPERTY_DATA_TYPE_STR)+22,
+ CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA4 =(CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED|CAL_PROPERTY_DATA_TYPE_STR)+23,
+
+ CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_EVENT_ID =(CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED|CAL_PROPERTY_DATA_TYPE_INT),
+ CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_START =(CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED|CAL_PROPERTY_DATA_TYPE_CALTIME) +1,
+ CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_END =(CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED|CAL_PROPERTY_DATA_TYPE_CALTIME) +2,
+ CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SUMMARY =(CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED|CAL_PROPERTY_DATA_TYPE_STR)+3,
+ CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_LOCATION =(CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED|CAL_PROPERTY_DATA_TYPE_STR)+4,
+ CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_CALENDAR_ID =(CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED|CAL_PROPERTY_DATA_TYPE_INT)+5,
+ CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_DESCRIPTION =(CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED|CAL_PROPERTY_DATA_TYPE_STR)+6,
+ CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_BUSY_STATUS =(CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED|CAL_PROPERTY_DATA_TYPE_INT)+7,
+ CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_EVENT_STATUS =(CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED|CAL_PROPERTY_DATA_TYPE_INT)+8,
+ CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_PRIORITY =(CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED|CAL_PROPERTY_DATA_TYPE_INT)+9,
+ CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SENSITIVITY =(CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED|CAL_PROPERTY_DATA_TYPE_INT)+10,
+ CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_HAS_RRULE =(CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED|CAL_PROPERTY_DATA_TYPE_INT)+11,
+ CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_LATITUDE =(CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED|CAL_PROPERTY_DATA_TYPE_DOUBLE)+12,
+ CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_LONGITUDE =(CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED|CAL_PROPERTY_DATA_TYPE_DOUBLE)+13,
+ CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_HAS_ALARM =(CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED|CAL_PROPERTY_DATA_TYPE_INT)+14,
+ CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_ORIGINAL_EVENT_ID =(CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED|CAL_PROPERTY_DATA_TYPE_INT)+15,
+ CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_LAST_MODIFIED_TIME =(CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED|CAL_PROPERTY_DATA_TYPE_LLI)+16,
+ CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA1 =(CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED|CAL_PROPERTY_DATA_TYPE_STR)+17,
+ CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_ORGANIZER_NAME =(CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED|CAL_PROPERTY_DATA_TYPE_STR)+18,
+ CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_CATEGORIES =(CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED|CAL_PROPERTY_DATA_TYPE_STR)+19,
+ CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_HAS_ATTENDEE =(CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED|CAL_PROPERTY_DATA_TYPE_INT)+20,
+ CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA2 =(CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED|CAL_PROPERTY_DATA_TYPE_STR)+21,
+ CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA3 =(CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED|CAL_PROPERTY_DATA_TYPE_STR)+22,
+ CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA4 =(CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED|CAL_PROPERTY_DATA_TYPE_STR)+23,
+ CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_IS_ALLDAY =(CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED|CAL_PROPERTY_DATA_TYPE_INT|CAL_PROPERTY_FLAGS_READ_ONLY)+24,
+
CAL_PROPERTY_UPDATED_INFO_ID =(CAL_PROPERTY_UPDATED_INFO|CAL_PROPERTY_DATA_TYPE_INT),
CAL_PROPERTY_UPDATED_INFO_CALENDAR_ID =(CAL_PROPERTY_UPDATED_INFO|CAL_PROPERTY_DATA_TYPE_INT)+1,
*
*/
-#include <tzplatform_config.h>
-
#ifndef __CAL_IPC_H__
#define __CAL_IPC_H__
#define CAL_IPC_SERVICE "cal_svc_ipc"
-#define CAL_IPC_SOCKET_PATH tzplatform_mkpath(TZ_USER_DATA, "calendar-svc/."CAL_IPC_SERVICE)
-#define CAL_IPC_SOCKET_PATH_FOR_SUBSCRIPTION tzplatform_mkpath(TZ_USER_DATA, "calendar-svc/."CAL_IPC_SERVICE"_for_subscription")
+#define CAL_IPC_SOCKET_PATH "/tmp/."CAL_IPC_SERVICE
+#define CAL_IPC_SOCKET_PATH_FOR_SUBSCRIPTION "/tmp/."CAL_IPC_SERVICE"_for_subscription"
#define CAL_IPC_MODULE "cal_ipc_module"
#define CAL_IPC_MODULE_FOR_SUBSCRIPTION CAL_IPC_MODULE"_for_subscription"
#define CAL_IPC_SERVER_CONNECT "connect"
#define CAL_IPC_SERVER_DISCONNECT "disconnect"
+#define CAL_IPC_SERVER_CHECK_PERMISSION "check_permission"
+
#define CAL_IPC_SERVER_DB_INSERT_RECORD "insert_record"
#define CAL_IPC_SERVER_DB_GET_RECORD "get_record"
#define CAL_IPC_SERVER_DB_UPDATE_RECORD "update_record"
#define CAL_IPC_SERVER_DB_REPLACE_VCALENDARS "replace_vcalendars"
#define CAL_IPC_SERVER_DB_REPLACE_RECORD "replace_record"
#define CAL_IPC_SERVER_DB_REPLACE_RECORDS "replace_records"
+#define CAL_IPC_SERVER_DB_CHANGES_EXCEPTION "changes_exception"
-#define CAL_IPC_SERVER_DB_REGISTER_REMINDER "register_reminder"
-#define CAL_IPC_SERVER_DB_UNREGISTER_REMINDER "unregister_reminder"
-#define CAL_IPC_SERVER_DB_ACTIVATE_REMINDER "activate_reminder"
-#define CAL_IPC_SERVER_DB_DEACTIVATE_REMINDER "deactivate_reminder"
-#define CAL_IPC_SERVER_DB_HAS_REMINDER "has_reminder"
-
+#ifdef CAL_MEMORY_TEST
+#define CAL_IPC_SERVER_DESTROY "destroy"
+#endif // #ifdef CAL_MEMORY_TEST
#endif /*__CAL_IPC_H__*/
extern cal_ipc_marshal_record_plugin_cb_s _cal_ipc_record_timezone_plugin_cb;
extern cal_ipc_marshal_record_plugin_cb_s _cal_ipc_record_updated_info_plugin_cb;
extern cal_ipc_marshal_record_plugin_cb_s _cal_ipc_record_instance_normal_plugin_cb;
+extern cal_ipc_marshal_record_plugin_cb_s _cal_ipc_record_instance_normal_extended_plugin_cb;
extern cal_ipc_marshal_record_plugin_cb_s _cal_ipc_record_instance_allday_plugin_cb;
+extern cal_ipc_marshal_record_plugin_cb_s _cal_ipc_record_instance_allday_extended_plugin_cb;
extern cal_ipc_marshal_record_plugin_cb_s _cal_ipc_record_search_plugin_cb;
extern cal_ipc_marshal_record_plugin_cb_s _cal_ipc_record_extended_plugin_cb;
static cal_ipc_marshal_record_plugin_cb_s* __cal_ipc_marshal_get_plugin_cb(cal_record_type_e type)
{
- switch (type)
- {
- case CAL_RECORD_TYPE_CALENDAR:
- return (&_cal_ipc_record_calendar_plugin_cb);
- case CAL_RECORD_TYPE_EVENT:
- return (&_cal_ipc_record_event_plugin_cb);
- case CAL_RECORD_TYPE_TODO:
- return (&_cal_ipc_record_todo_plugin_cb);
- case CAL_RECORD_TYPE_ALARM:
- return (&_cal_ipc_record_alarm_plugin_cb);
- case CAL_RECORD_TYPE_ATTENDEE:
- return (&_cal_ipc_record_attendee_plugin_cb);
- case CAL_RECORD_TYPE_TIMEZONE:
- return (&_cal_ipc_record_timezone_plugin_cb);
- case CAL_RECORD_TYPE_INSTANCE_NORMAL:
- return (&_cal_ipc_record_instance_normal_plugin_cb);
- case CAL_RECORD_TYPE_INSTANCE_ALLDAY:
- return (&_cal_ipc_record_instance_allday_plugin_cb);
- case CAL_RECORD_TYPE_UPDATED_INFO:
- return (&_cal_ipc_record_updated_info_plugin_cb);
- case CAL_RECORD_TYPE_SEARCH:
- return (&_cal_ipc_record_search_plugin_cb);
- case CAL_RECORD_TYPE_EXTENDED:
- return (&_cal_ipc_record_extended_plugin_cb);
- default:
- return NULL;
- }
+ switch (type)
+ {
+ case CAL_RECORD_TYPE_CALENDAR:
+ return (&_cal_ipc_record_calendar_plugin_cb);
+ case CAL_RECORD_TYPE_EVENT:
+ return (&_cal_ipc_record_event_plugin_cb);
+ case CAL_RECORD_TYPE_TODO:
+ return (&_cal_ipc_record_todo_plugin_cb);
+ case CAL_RECORD_TYPE_ALARM:
+ return (&_cal_ipc_record_alarm_plugin_cb);
+ case CAL_RECORD_TYPE_ATTENDEE:
+ return (&_cal_ipc_record_attendee_plugin_cb);
+ case CAL_RECORD_TYPE_TIMEZONE:
+ return (&_cal_ipc_record_timezone_plugin_cb);
+ case CAL_RECORD_TYPE_INSTANCE_NORMAL:
+ return (&_cal_ipc_record_instance_normal_plugin_cb);
+ case CAL_RECORD_TYPE_INSTANCE_ALLDAY:
+ return (&_cal_ipc_record_instance_allday_plugin_cb);
+ case CAL_RECORD_TYPE_INSTANCE_NORMAL_EXTENDED:
+ return (&_cal_ipc_record_instance_normal_extended_plugin_cb);
+ case CAL_RECORD_TYPE_INSTANCE_ALLDAY_EXTENDED:
+ return (&_cal_ipc_record_instance_allday_extended_plugin_cb);
+ case CAL_RECORD_TYPE_UPDATED_INFO:
+ return (&_cal_ipc_record_updated_info_plugin_cb);
+ case CAL_RECORD_TYPE_SEARCH:
+ return (&_cal_ipc_record_search_plugin_cb);
+ case CAL_RECORD_TYPE_EXTENDED:
+ return (&_cal_ipc_record_extended_plugin_cb);
+ default:
+ return NULL;
+ }
}
-static int __cal_ipc_unmarshal_composite_filter(const pims_ipc_data_h ipc_data, cal_composite_filter_s* filter)
+static void __cal_ipc_unmarshal_composite_filter_free(cal_composite_filter_s* filter)
{
- int ret = CALENDAR_ERROR_NONE;
- unsigned int size = 0;
- char* str = NULL;
- int count =0, i=0;
- cal_filter_type_e filter_type = CAL_FILTER_COMPOSITE;
- calendar_filter_operator_e op = CALENDAR_FILTER_OPERATOR_AND;
+ if (filter->filters) {
+ GSList *cursor = NULL;
+ for(cursor=filter->filters;cursor;cursor=cursor->next) {
+ cal_filter_s *src = (cal_filter_s*)cursor->data;
+ if (src->filter_type == CAL_FILTER_COMPOSITE)
+ __cal_ipc_unmarshal_composite_filter_free((cal_composite_filter_s *)src);
+ else {
+ cal_attribute_filter_s *attr = (cal_attribute_filter_s *)src;
+ if (attr->filter_type == CAL_FILTER_STR)
+ free(attr->value.s);
+ }
+ free(src);
+ }
+ g_slist_free(filter->filters);
+ }
+
+ if (filter->filter_ops) {
+ g_slist_free(filter->filter_ops);
+ }
+
+ free(filter->view_uri);
+}
-/*
- if (_cal_ipc_unmarshal_int(ipc_data,&(filter->filter_type)) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-*/
- filter->filter_type = CAL_FILTER_COMPOSITE;
-
- // view_uri
- str = (char*)pims_ipc_data_get(ipc_data,&size);
- filter->view_uri = strdup(str);
-
- // filters
- if (_cal_ipc_unmarshal_int(ipc_data,&count) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- for(i=0;i<count;i++)
- {
- if (_cal_ipc_unmarshal_int(ipc_data,(int*)&filter_type) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- goto ERROR_RETURN;
- }
- if (filter_type == CAL_FILTER_COMPOSITE)
- {
- cal_composite_filter_s* com_filter = NULL;
- com_filter = (cal_composite_filter_s*)calloc(1,sizeof(cal_composite_filter_s));
- if (com_filter == NULL)
- {
- ERR("malloc fail");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- goto ERROR_RETURN;
- }
- if (__cal_ipc_unmarshal_composite_filter(ipc_data, com_filter) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- CAL_FREE(com_filter);
- goto ERROR_RETURN;
- }
- filter->filters = g_slist_append(filter->filters,com_filter);
- }
- else
- {
- cal_attribute_filter_s* attr_filter = NULL;
- attr_filter = (cal_attribute_filter_s*)calloc(1,sizeof(cal_attribute_filter_s));
- if (attr_filter == NULL)
- {
- ERR("malloc fail");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- goto ERROR_RETURN;
- }
- if (__cal_ipc_unmarshal_attribute_filter(ipc_data, filter_type, attr_filter) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- CAL_FREE(attr_filter);
- goto ERROR_RETURN;
- }
- filter->filters = g_slist_append(filter->filters,attr_filter);
- }
- }
-
- // filters
- if (_cal_ipc_unmarshal_int(ipc_data,&count) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- goto ERROR_RETURN;
- }
-
- for(i=0;i<count;i++)
- {
- if (_cal_ipc_unmarshal_int(ipc_data,(int*)&op) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- goto ERROR_RETURN;
- }
- filter->filter_ops = g_slist_append(filter->filter_ops, (void*)op);
- }
-
- // properties //property_count
- filter->properties = (cal_property_info_s *)_cal_view_get_property_info(filter->view_uri, &filter->property_count);
-
- return CALENDAR_ERROR_NONE;
+static int __cal_ipc_unmarshal_composite_filter(const pims_ipc_data_h ipc_data, cal_composite_filter_s* filter)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ unsigned int size = 0;
+ char* str = NULL;
+ int count =0, i=0;
+ cal_filter_type_e filter_type = CAL_FILTER_COMPOSITE;
+ calendar_filter_operator_e op = CALENDAR_FILTER_OPERATOR_AND;
+
+ retvm_if(filter==NULL, CALENDAR_ERROR_INVALID_PARAMETER, "filter is NULL");
+
+ filter->filter_type = CAL_FILTER_COMPOSITE;
+
+ // view_uri
+ str = (char*)pims_ipc_data_get(ipc_data,&size);
+ CAL_FREE(filter->view_uri);
+ filter->view_uri = strdup(str);
+
+ // filters
+ if (_cal_ipc_unmarshal_int(ipc_data,&count) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ for(i=0;i<count;i++) {
+ if (_cal_ipc_unmarshal_int(ipc_data,(int*)&filter_type) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ goto ERROR_RETURN;
+ }
+ if (filter_type == CAL_FILTER_COMPOSITE) {
+ cal_composite_filter_s* com_filter = NULL;
+ com_filter = (cal_composite_filter_s*)calloc(1,sizeof(cal_composite_filter_s));
+ if (com_filter == NULL) {
+ ERR("malloc fail");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ goto ERROR_RETURN;
+ }
+ if (__cal_ipc_unmarshal_composite_filter(ipc_data, com_filter) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ CAL_FREE(com_filter);
+ goto ERROR_RETURN;
+ }
+ filter->filters = g_slist_append(filter->filters,com_filter);
+ }
+ else {
+ cal_attribute_filter_s* attr_filter = NULL;
+ attr_filter = (cal_attribute_filter_s*)calloc(1,sizeof(cal_attribute_filter_s));
+ if (attr_filter == NULL) {
+ ERR("malloc fail");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ goto ERROR_RETURN;
+ }
+ if (__cal_ipc_unmarshal_attribute_filter(ipc_data, filter_type, attr_filter) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ CAL_FREE(attr_filter);
+ goto ERROR_RETURN;
+ }
+ filter->filters = g_slist_append(filter->filters,attr_filter);
+ }
+ }
+
+ // filters
+ if (_cal_ipc_unmarshal_int(ipc_data,&count) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ goto ERROR_RETURN;
+ }
+
+ for(i=0;i<count;i++) {
+ if (_cal_ipc_unmarshal_int(ipc_data,(int*)&op) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ goto ERROR_RETURN;
+ }
+ filter->filter_ops = g_slist_append(filter->filter_ops, (void*)op);
+ }
+
+ // properties //property_count
+ filter->properties = (cal_property_info_s *)_cal_view_get_property_info(filter->view_uri, &filter->property_count);
+
+ return CALENDAR_ERROR_NONE;
ERROR_RETURN:
- if (filter->filters)
- {
- GSList *cursor = NULL;
- for(cursor=filter->filters;cursor;cursor=cursor->next)
- {
- cal_filter_s *src = (cal_filter_s*)cursor->data;
- CAL_FREE(src);
- }
- g_slist_free(filter->filters);
- }
-
- if (filter->filter_ops)
- {
- g_slist_free(filter->filter_ops);
- }
-
- return ret;
+ __cal_ipc_unmarshal_composite_filter_free(filter);
+
+ return ret;
}
static int __cal_ipc_marshal_composite_filter(const cal_composite_filter_s* filter, pims_ipc_data_h ipc_data)
{
- if (_cal_ipc_marshal_int((filter->filter_type),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- // view_uri
- int length = strlen(filter->view_uri);
- if (pims_ipc_data_put(ipc_data,(void*)filter->view_uri,length+1) < 0)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- // filter->filters
- if (filter->filters)
- {
- int count = g_slist_length(filter->filters);
- GSList *cursor = filter->filters;
- cal_filter_s* child_filter;
-
- if (_cal_ipc_marshal_int(count,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- while (cursor)
- {
- child_filter = (cal_filter_s*)cursor->data;
-
- if (child_filter->filter_type == CAL_FILTER_COMPOSITE)
- {
- if (__cal_ipc_marshal_composite_filter((cal_composite_filter_s*)child_filter, ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("__cal_ipc_marshal_composite_filter fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
- if (__cal_ipc_marshal_attribute_filter((cal_attribute_filter_s*)child_filter, ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("__cal_ipc_marshal_attribute_filter fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- cursor = g_slist_next(cursor);
- }
- }
- else
- {
- if (_cal_ipc_marshal_int(0,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
-
- if (filter->filter_ops)
- {
- int count = g_slist_length(filter->filter_ops);
- GSList *cursor = filter->filter_ops;
-
- if (_cal_ipc_marshal_int(count,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- while (cursor)
- {
- calendar_filter_operator_e op = (calendar_filter_operator_e)cursor->data;
-
- if (_cal_ipc_marshal_int(op,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- cursor = g_slist_next(cursor);
- }
- }
- else
- {
- if (_cal_ipc_marshal_int(0,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
-
- // properties //property_count
-
- return CALENDAR_ERROR_NONE;
+ if (_cal_ipc_marshal_int((filter->filter_type),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ // view_uri
+ int length = strlen(filter->view_uri);
+ if (pims_ipc_data_put(ipc_data,(void*)filter->view_uri,length+1) < 0) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ // filter->filters
+ if (filter->filters) {
+ int count = g_slist_length(filter->filters);
+ GSList *cursor = filter->filters;
+ cal_filter_s* child_filter;
+
+ if (_cal_ipc_marshal_int(count,ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ while (cursor) {
+ child_filter = (cal_filter_s*)cursor->data;
+
+ if (child_filter->filter_type == CAL_FILTER_COMPOSITE) {
+ if (__cal_ipc_marshal_composite_filter((cal_composite_filter_s*)child_filter, ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("__cal_ipc_marshal_composite_filter fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ else {
+ if (__cal_ipc_marshal_attribute_filter((cal_attribute_filter_s*)child_filter, ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("__cal_ipc_marshal_attribute_filter fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ cursor = g_slist_next(cursor);
+ }
+ }
+ else {
+ if (_cal_ipc_marshal_int(0,ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+
+ if (filter->filter_ops) {
+ int count = g_slist_length(filter->filter_ops);
+ GSList *cursor = filter->filter_ops;
+
+ if (_cal_ipc_marshal_int(count,ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ while (cursor) {
+ calendar_filter_operator_e op = (calendar_filter_operator_e)cursor->data;
+
+ if (_cal_ipc_marshal_int(op,ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ cursor = g_slist_next(cursor);
+ }
+ }
+ else {
+ if (_cal_ipc_marshal_int(0,ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+
+ // properties //property_count
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_ipc_unmarshal_attribute_filter(const pims_ipc_data_h ipc_data, const cal_filter_type_e filter_type, cal_attribute_filter_s* filter)
{
- filter->filter_type = filter_type;
- if (_cal_ipc_unmarshal_int(ipc_data,&filter->property_id) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_unmarshal_int(ipc_data,&filter->match) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- switch(filter->filter_type)
- {
- case CAL_FILTER_STR:
- if (_cal_ipc_unmarshal_char(ipc_data,&filter->value.s) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- break;
- case CAL_FILTER_INT:
- if (_cal_ipc_unmarshal_int(ipc_data,&filter->value.i) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- break;
- case CAL_FILTER_DOUBLE:
- if (_cal_ipc_unmarshal_double(ipc_data,&filter->value.d) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- break;
- case CAL_FILTER_LLI:
- if (_cal_ipc_unmarshal_lli(ipc_data,&filter->value.lli) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- break;
- case CAL_FILTER_CALTIME:
- if (_cal_ipc_unmarshal_caltime(ipc_data,&filter->value.caltime) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- break;
- default:
- break;
- }
- return CALENDAR_ERROR_NONE;
+ filter->filter_type = filter_type;
+
+ if (_cal_ipc_unmarshal_int(ipc_data,&filter->property_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_unmarshal_int(ipc_data,&filter->match) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ switch(filter->filter_type) {
+ case CAL_FILTER_STR:
+ if (_cal_ipc_unmarshal_char(ipc_data,&filter->value.s) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ case CAL_FILTER_INT:
+ if (_cal_ipc_unmarshal_int(ipc_data,&filter->value.i) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ case CAL_FILTER_DOUBLE:
+ if (_cal_ipc_unmarshal_double(ipc_data,&filter->value.d) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ case CAL_FILTER_LLI:
+ if (_cal_ipc_unmarshal_lli(ipc_data,&filter->value.lli) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ case CAL_FILTER_CALTIME:
+ if (_cal_ipc_unmarshal_caltime(ipc_data,&filter->value.caltime) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ default:
+ break;
+ }
+ return CALENDAR_ERROR_NONE;
}
static int __cal_ipc_marshal_attribute_filter(const cal_attribute_filter_s* filter, pims_ipc_data_h ipc_data)
{
- if (_cal_ipc_marshal_int((filter->filter_type),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_marshal_int((filter->property_id),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_marshal_int((filter->match),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- switch(filter->filter_type)
- {
- case CAL_FILTER_STR:
- if (_cal_ipc_marshal_char((filter->value.s),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- break;
- case CAL_FILTER_INT:
- if (_cal_ipc_marshal_int((filter->value.i),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- break;
- case CAL_FILTER_DOUBLE:
- if (_cal_ipc_marshal_double((filter->value.d),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- break;
- case CAL_FILTER_LLI:
- if (_cal_ipc_marshal_lli((filter->value.lli),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- break;
- case CAL_FILTER_CALTIME:
- if (_cal_ipc_marshal_caltime((filter->value.caltime),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- break;
- default:
- break;
- }
-
- return CALENDAR_ERROR_NONE;
+ if (_cal_ipc_marshal_int((filter->filter_type),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_marshal_int((filter->property_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_marshal_int((filter->match),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ switch(filter->filter_type) {
+ case CAL_FILTER_STR:
+ if (_cal_ipc_marshal_char((filter->value.s),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ case CAL_FILTER_INT:
+ if (_cal_ipc_marshal_int((filter->value.i),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ case CAL_FILTER_DOUBLE:
+ if (_cal_ipc_marshal_double((filter->value.d),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ case CAL_FILTER_LLI:
+ if (_cal_ipc_marshal_lli((filter->value.lli),ipc_data) != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ case CAL_FILTER_CALTIME:
+ if (_cal_ipc_marshal_caltime((filter->value.caltime),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ default:
+ break;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
int _cal_ipc_unmarshal_record(const pims_ipc_data_h ipc_data, calendar_record_h* precord)
{
- int ret = CALENDAR_ERROR_NONE;
- cal_record_s common = {0,};
- cal_record_s *pcommon = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ cal_record_s common = {0,};
+ cal_record_s *pcommon = NULL;
- if (_cal_ipc_unmarshal_record_common(ipc_data,&common) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
+ retv_if(NULL == ipc_data, CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(NULL == precord, CALENDAR_ERROR_INVALID_PARAMETER);
- retvm_if(NULL == precord || NULL == ipc_data, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ if (_cal_ipc_unmarshal_record_common(ipc_data,&common) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- cal_ipc_marshal_record_plugin_cb_s *plugin_cb = __cal_ipc_marshal_get_plugin_cb(common.type);
+ cal_ipc_marshal_record_plugin_cb_s *plugin_cb = __cal_ipc_marshal_get_plugin_cb(common.type);
- retvm_if(NULL == plugin_cb || NULL == plugin_cb->unmarshal_record, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ if (NULL == plugin_cb || NULL == plugin_cb->unmarshal_record) {
+ ERR("Invalid parameter");
+ free(common.properties_flags);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- ret = calendar_record_create(common.view_uri, precord);
- retvm_if(ret != CALENDAR_ERROR_NONE, ret, "record create fail");
+ ret = calendar_record_create(common.view_uri, precord);
+ retvm_if(ret != CALENDAR_ERROR_NONE, ret, "record create fail");
- pcommon = (cal_record_s*)(*precord);
- pcommon->properties_max_count = common.properties_max_count;
- pcommon->properties_flags = common.properties_flags;
+ pcommon = (cal_record_s*)(*precord);
+ pcommon->properties_max_count = common.properties_max_count;
+ pcommon->properties_flags = common.properties_flags;
- ret = plugin_cb->unmarshal_record(ipc_data, *precord);
+ ret = plugin_cb->unmarshal_record(ipc_data, *precord);
- if (ret != CALENDAR_ERROR_NONE)
- {
- calendar_record_destroy(*precord,true);
- *precord = NULL;
- ERR("_cal_ipc_unmarshal fail");
- }
+ if (ret != CALENDAR_ERROR_NONE) {
+ calendar_record_destroy(*precord,true);
+ *precord = NULL;
+ ERR("_cal_ipc_unmarshal fail");
+ }
- return ret;
+ return ret;
}
int _cal_ipc_marshal_record(const calendar_record_h record, pims_ipc_data_h ipc_data)
{
- int ret = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
+
+ cal_record_s *temp = (cal_record_s*)(record);
- cal_record_s *temp = (cal_record_s*)(record);
+ retvm_if(NULL == record || NULL == ipc_data, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == record || NULL == ipc_data, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ if (_cal_ipc_marshal_record_common(temp,ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- cal_ipc_marshal_record_plugin_cb_s *plugin_cb = __cal_ipc_marshal_get_plugin_cb(temp->type);
+ cal_ipc_marshal_record_plugin_cb_s *plugin_cb = __cal_ipc_marshal_get_plugin_cb(temp->type);
- retvm_if(NULL == plugin_cb || NULL == plugin_cb->marshal_record, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == plugin_cb || NULL == plugin_cb->marshal_record, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- ret = plugin_cb->marshal_record(record, ipc_data);
+ ret = plugin_cb->marshal_record(record, ipc_data);
- return ret;
+ return ret;
}
int _cal_ipc_marshal_record_get_primary_id(const calendar_record_h record,
- unsigned int *property_id, int *id)
+ unsigned int *property_id, int *id)
{
- int ret = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
- cal_record_s *temp = (cal_record_s*)(record);
+ cal_record_s *temp = (cal_record_s*)(record);
- retvm_if(NULL == record || NULL == property_id ||
- NULL == id, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == record || NULL == property_id ||
+ NULL == id, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- cal_ipc_marshal_record_plugin_cb_s *plugin_cb = __cal_ipc_marshal_get_plugin_cb(temp->type);
+ cal_ipc_marshal_record_plugin_cb_s *plugin_cb = __cal_ipc_marshal_get_plugin_cb(temp->type);
- retvm_if(NULL == plugin_cb || NULL == plugin_cb->get_primary_id, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == plugin_cb || NULL == plugin_cb->get_primary_id, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- ret = plugin_cb->get_primary_id(record, property_id,id);
+ ret = plugin_cb->get_primary_id(record, property_id,id);
- return ret;
+ return ret;
}
int _cal_ipc_unmarshal_char(const pims_ipc_data_h ipc_data, char** ppbufchar)
{
- int ret = CALENDAR_ERROR_NONE;
-
- void *tmp = NULL;
- unsigned int size = 0;
- char *str = NULL;
-
- int length = 0;
-
- retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
- retv_if(ppbufchar==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
-
- tmp = pims_ipc_data_get(ipc_data,&size);
- if ( tmp == NULL){
- ERR("pims_ipc_data_get fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- length = *(int*)tmp;
-
- if(length == -1)
- {
- ret = CALENDAR_ERROR_NONE;
- //CAL_DBG("string is null");
- *ppbufchar = NULL;
- return ret;
- }
-
- str = (char*)pims_ipc_data_get(ipc_data,&size);
- if (str)
- {
- *ppbufchar = SAFE_STRDUP(str);
- }
- //CAL_DBG("string set %s",*ppbufchar);
-
- return ret;
+ int ret = CALENDAR_ERROR_NONE;
+
+ void *tmp = NULL;
+ unsigned int size = 0;
+ char *str = NULL;
+
+ int length = 0;
+
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(ppbufchar==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+
+ tmp = pims_ipc_data_get(ipc_data,&size);
+ if ( tmp == NULL) {
+ ERR("pims_ipc_data_get fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ length = *(int*)tmp;
+
+ if(length == -1) {
+ ret = CALENDAR_ERROR_NONE;
+ //CAL_DBG("string is null");
+ *ppbufchar = NULL;
+ return ret;
+ }
+
+ str = (char*)pims_ipc_data_get(ipc_data,&size);
+ if (str) {
+ *ppbufchar = SAFE_STRDUP(str);
+ }
+
+ return ret;
}
int _cal_ipc_unmarshal_int(const pims_ipc_data_h data, int *pout)
{
- void *tmp = NULL;
- unsigned int size = 0;
-
- retv_if(data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
- retv_if(pout==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
-
- tmp = pims_ipc_data_get(data,&size);
- if ( tmp == NULL)
- {
- ERR("pims_ipc_data_get fail");
- return CALENDAR_ERROR_NO_DATA;
- }
- else
- {
- *pout = *(int*)tmp;
- }
- return CALENDAR_ERROR_NONE;
+ void *tmp = NULL;
+ unsigned int size = 0;
+
+ retv_if(data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(pout==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+
+ tmp = pims_ipc_data_get(data,&size);
+ if ( tmp == NULL) {
+ ERR("pims_ipc_data_get fail");
+ return CALENDAR_ERROR_NO_DATA;
+ }
+ else {
+ *pout = *(int*)tmp;
+ }
+ return CALENDAR_ERROR_NONE;
}
int _cal_ipc_unmarshal_uint(const pims_ipc_data_h data, unsigned int *pout)
{
- void *tmp = NULL;
- unsigned int size = 0;
-
- retv_if(data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
- retv_if(pout==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
-
- tmp = pims_ipc_data_get(data,&size);
- if ( tmp == NULL)
- {
- ERR("pims_ipc_data_get fail");
- return CALENDAR_ERROR_NO_DATA;
- }
- else
- {
- *pout = *(unsigned int*)tmp;
- }
- return CALENDAR_ERROR_NONE;
+ void *tmp = NULL;
+ unsigned int size = 0;
+
+ retv_if(data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(pout==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+
+ tmp = pims_ipc_data_get(data,&size);
+ if ( tmp == NULL) {
+ ERR("pims_ipc_data_get fail");
+ return CALENDAR_ERROR_NO_DATA;
+ }
+ else {
+ *pout = *(unsigned int*)tmp;
+ }
+ return CALENDAR_ERROR_NONE;
}
int _cal_ipc_unmarshal_lli(const pims_ipc_data_h data, long long int *pout)
{
- void *tmp = NULL;
- unsigned int size = 0;
-
- retv_if(data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
- retv_if(pout==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
- tmp = pims_ipc_data_get(data,&size);
- if ( tmp == NULL)
- {
- ERR("pims_ipc_data_get fail");
- return CALENDAR_ERROR_NO_DATA;
- }
- else
- {
- *pout = *(long long int*)tmp;
- }
- return CALENDAR_ERROR_NONE;
+ void *tmp = NULL;
+ unsigned int size = 0;
+
+ retv_if(data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(pout==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+ tmp = pims_ipc_data_get(data,&size);
+ if ( tmp == NULL) {
+ ERR("pims_ipc_data_get fail");
+ return CALENDAR_ERROR_NO_DATA;
+ }
+ else {
+ *pout = *(long long int*)tmp;
+ }
+ return CALENDAR_ERROR_NONE;
}
int _cal_ipc_unmarshal_long(const pims_ipc_data_h data, long *pout)
{
- void *tmp = NULL;
- unsigned int size = 0;
-
- retv_if(data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
- retv_if(pout==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
- tmp = pims_ipc_data_get(data,&size);
- if ( tmp == NULL)
- {
- ERR("pims_ipc_data_get fail");
- return CALENDAR_ERROR_NO_DATA;
- }
- else
- {
- *pout = *(long*)tmp;
- }
- return CALENDAR_ERROR_NONE;
+ void *tmp = NULL;
+ unsigned int size = 0;
+
+ retv_if(data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(pout==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+ tmp = pims_ipc_data_get(data,&size);
+ if ( tmp == NULL) {
+ ERR("pims_ipc_data_get fail");
+ return CALENDAR_ERROR_NO_DATA;
+ }
+ else {
+ *pout = *(long*)tmp;
+ }
+ return CALENDAR_ERROR_NONE;
}
int _cal_ipc_unmarshal_double(const pims_ipc_data_h data, double *pout)
{
- void *tmp = NULL;
- unsigned int size = 0;
-
- retv_if(data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
- retv_if(pout==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
- tmp = pims_ipc_data_get(data,&size);
- if ( tmp == NULL)
- {
- ERR("pims_ipc_data_get fail");
- return CALENDAR_ERROR_NO_DATA;
- }
- else
- {
- *pout = *(double*)tmp;
- }
- return CALENDAR_ERROR_NONE;
+ void *tmp = NULL;
+ unsigned int size = 0;
+
+ retv_if(data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(pout==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+ tmp = pims_ipc_data_get(data,&size);
+ if ( tmp == NULL) {
+ ERR("pims_ipc_data_get fail");
+ return CALENDAR_ERROR_NO_DATA;
+ }
+ else {
+ *pout = *(double*)tmp;
+ }
+ return CALENDAR_ERROR_NONE;
}
int _cal_ipc_unmarshal_caltime(const pims_ipc_data_h data, calendar_time_s *pout)
{
- void *tmp = NULL;
- unsigned int size = 0;
- int ret = CALENDAR_ERROR_NONE;
-
- retv_if(data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
- retv_if(pout==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
- tmp = pims_ipc_data_get(data,&size);
- if ( tmp == NULL)
- {
- ERR("pims_ipc_data_get fail");
- return CALENDAR_ERROR_NO_DATA;
- }
- else
- {
- pout->type = *(int*)tmp;
- }
-
- if (pout->type == CALENDAR_TIME_UTIME)
- {
- return _cal_ipc_unmarshal_lli(data, &(pout->time.utime));
- }
- else
- {
- ret = _cal_ipc_unmarshal_int(data, &(pout->time.date.year));
- retv_if(ret!=CALENDAR_ERROR_NONE,ret);
- ret = _cal_ipc_unmarshal_int(data, &(pout->time.date.month));
- retv_if(ret!=CALENDAR_ERROR_NONE,ret);
- ret = _cal_ipc_unmarshal_int(data, &(pout->time.date.mday));
- retv_if(ret!=CALENDAR_ERROR_NONE,ret);
- }
-
- return CALENDAR_ERROR_NONE;
+ void *tmp = NULL;
+ unsigned int size = 0;
+ int ret = CALENDAR_ERROR_NONE;
+
+ retv_if(data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(pout==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+ tmp = pims_ipc_data_get(data,&size);
+ if ( tmp == NULL) {
+ ERR("pims_ipc_data_get fail");
+ return CALENDAR_ERROR_NO_DATA;
+ }
+ else {
+ pout->type = *(int*)tmp;
+ }
+
+ if (pout->type == CALENDAR_TIME_UTIME) {
+ return _cal_ipc_unmarshal_lli(data, &(pout->time.utime));
+ }
+ else {
+ ret = _cal_ipc_unmarshal_int(data, &(pout->time.date.year));
+ retv_if(ret!=CALENDAR_ERROR_NONE,ret);
+ ret = _cal_ipc_unmarshal_int(data, &(pout->time.date.month));
+ retv_if(ret!=CALENDAR_ERROR_NONE,ret);
+ ret = _cal_ipc_unmarshal_int(data, &(pout->time.date.mday));
+ retv_if(ret!=CALENDAR_ERROR_NONE,ret);
+ ret = _cal_ipc_unmarshal_int(data, &(pout->time.date.hour));
+ retv_if(ret!=CALENDAR_ERROR_NONE,ret);
+ ret = _cal_ipc_unmarshal_int(data, &(pout->time.date.minute));
+ retv_if(ret!=CALENDAR_ERROR_NONE,ret);
+ ret = _cal_ipc_unmarshal_int(data, &(pout->time.date.second));
+ retv_if(ret!=CALENDAR_ERROR_NONE,ret);
+ }
+
+ return CALENDAR_ERROR_NONE;
}
int _cal_ipc_unmarshal_record_common(const pims_ipc_data_h ipc_data, cal_record_s* common)
{
- void *tmp = NULL;
- unsigned int size = 0;
- const char* str = NULL;
-
- retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
- tmp = pims_ipc_data_get(ipc_data,&size);
- if ( tmp == NULL)
- {
- ERR("pims_ipc_data_get fail");
- return CALENDAR_ERROR_NO_DATA;
- }
- else
- {
- common->type = *(cal_record_type_e*)tmp;
- }
-
- common->plugin_cb = _cal_record_get_plugin_cb(common->type);
-
- str = (char*)pims_ipc_data_get(ipc_data,&size);
- common->view_uri = _cal_view_get_uri(str);
-
- tmp = pims_ipc_data_get(ipc_data,&size);
-
- common->properties_max_count = *(unsigned int*)tmp;
- if (common->properties_max_count > 0)
- {
- unsigned char *tmp_properties_flags;
- tmp_properties_flags = (unsigned char*)pims_ipc_data_get(ipc_data,&size);
- common->properties_flags = calloc(common->properties_max_count, sizeof(char));
- if (common->properties_flags == NULL)
- {
- ERR("calloc fail");
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- memcpy(common->properties_flags,tmp_properties_flags,sizeof(char)*common->properties_max_count);
- }
-
- tmp = pims_ipc_data_get(ipc_data,&size);
- common->property_flag = *(unsigned char*)tmp;
-
- return CALENDAR_ERROR_NONE;
+ void *tmp = NULL;
+ unsigned int size = 0;
+ const char* str = NULL;
+
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
+ tmp = pims_ipc_data_get(ipc_data,&size);
+ if ( tmp == NULL) {
+ ERR("pims_ipc_data_get fail");
+ return CALENDAR_ERROR_NO_DATA;
+ }
+ else {
+ common->type = *(cal_record_type_e*)tmp;
+ }
+
+ common->plugin_cb = _cal_record_get_plugin_cb(common->type);
+
+ str = (char*)pims_ipc_data_get(ipc_data,&size);
+ common->view_uri = _cal_view_get_uri(str);
+
+ tmp = pims_ipc_data_get(ipc_data,&size);
+
+ common->properties_max_count = *(unsigned int*)tmp;
+ if (common->properties_max_count > 0)
+ {
+ unsigned char *tmp_properties_flags;
+ tmp_properties_flags = (unsigned char*)pims_ipc_data_get(ipc_data,&size);
+ common->properties_flags = calloc(common->properties_max_count, sizeof(char));
+ if (common->properties_flags == NULL) {
+ ERR("calloc fail");
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+ memcpy(common->properties_flags,tmp_properties_flags,sizeof(char)*common->properties_max_count);
+ }
+
+ tmp = pims_ipc_data_get(ipc_data,&size);
+ common->property_flag = *(unsigned char*)tmp;
+
+ return CALENDAR_ERROR_NONE;
}
int _cal_ipc_marshal_char(const char* bufchar, pims_ipc_data_h ipc_data)
{
- int ret = CALENDAR_ERROR_NONE;
-
- retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
-
- if( bufchar != NULL)
- {
- int length = strlen(bufchar);
- if (pims_ipc_data_put(ipc_data,(void*)&length,sizeof(int)) != 0)
- {
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- }
-
- if ( pims_ipc_data_put(ipc_data,(void*)bufchar,length+1) != 0)
- {
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- return ret;
- }
- }
- else
- {
- int length = -1;
-
- if (pims_ipc_data_put(ipc_data,(void*)&length,sizeof(int)) != 0)
- {
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- }
- return ret;
+ int ret = CALENDAR_ERROR_NONE;
+
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+
+ if( bufchar != NULL) {
+ int length = strlen(bufchar);
+ if (pims_ipc_data_put(ipc_data,(void*)&length,sizeof(int)) != 0) {
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+
+ if ( pims_ipc_data_put(ipc_data,(void*)bufchar,length+1) != 0) {
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ return ret;
+ }
+ }
+ else {
+ int length = -1;
+
+ if (pims_ipc_data_put(ipc_data,(void*)&length,sizeof(int)) != 0) {
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+ }
+ return ret;
}
int _cal_ipc_marshal_int(const int in, pims_ipc_data_h ipc_data)
{
- retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
- if (pims_ipc_data_put(ipc_data,(void*)&in,sizeof(int)) != 0)
- {
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- return CALENDAR_ERROR_NONE;
+ if (pims_ipc_data_put(ipc_data,(void*)&in,sizeof(int)) != 0) {
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+ return CALENDAR_ERROR_NONE;
}
int _cal_ipc_marshal_uint(const unsigned int in, pims_ipc_data_h ipc_data)
{
- retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
- if (pims_ipc_data_put(ipc_data,(void*)&in,sizeof(unsigned int)) != 0)
- {
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- return CALENDAR_ERROR_NONE;
+ if (pims_ipc_data_put(ipc_data,(void*)&in,sizeof(unsigned int)) != 0) {
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+ return CALENDAR_ERROR_NONE;
}
int _cal_ipc_marshal_lli(const long long int in, pims_ipc_data_h ipc_data)
{
- retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
- if (pims_ipc_data_put(ipc_data,(void*)&in,sizeof(long long int)) != 0)
- {
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- return CALENDAR_ERROR_NONE;
+ if (pims_ipc_data_put(ipc_data,(void*)&in,sizeof(long long int)) != 0) {
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+ return CALENDAR_ERROR_NONE;
}
int _cal_ipc_marshal_long(const long in, pims_ipc_data_h ipc_data)
{
- retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
- if (pims_ipc_data_put(ipc_data,(void*)&in,sizeof(long)) != 0)
- {
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- return CALENDAR_ERROR_NONE;
+ if (pims_ipc_data_put(ipc_data,(void*)&in,sizeof(long)) != 0) {
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+ return CALENDAR_ERROR_NONE;
}
int _cal_ipc_marshal_double(const double in, pims_ipc_data_h ipc_data)
{
- retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
- if (pims_ipc_data_put(ipc_data,(void*)&in,sizeof(double)) != 0)
- {
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- return CALENDAR_ERROR_NONE;
+ if (pims_ipc_data_put(ipc_data,(void*)&in,sizeof(double)) != 0) {
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+ return CALENDAR_ERROR_NONE;
}
int _cal_ipc_marshal_caltime(const calendar_time_s in, pims_ipc_data_h ipc_data)
{
- int ret = CALENDAR_ERROR_NONE;
- retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
-
- if (pims_ipc_data_put(ipc_data,(void*)&(in.type),sizeof(int)) != 0)
- {
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- if ( in.type == CALENDAR_TIME_UTIME)
- {
- return _cal_ipc_marshal_lli(in.time.utime,ipc_data);
- }
- else
- {
- ret = _cal_ipc_marshal_int(in.time.date.year,ipc_data);
- retv_if(ret!=CALENDAR_ERROR_NONE,ret);
- ret = _cal_ipc_marshal_int(in.time.date.month,ipc_data);
- retv_if(ret!=CALENDAR_ERROR_NONE,ret);
- ret = _cal_ipc_marshal_int(in.time.date.mday,ipc_data);
- retv_if(ret!=CALENDAR_ERROR_NONE,ret);
- }
-
- return CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+
+ if (pims_ipc_data_put(ipc_data,(void*)&(in.type),sizeof(int)) != 0) {
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+
+ if ( in.type == CALENDAR_TIME_UTIME) {
+ return _cal_ipc_marshal_lli(in.time.utime,ipc_data);
+ }
+ else {
+ ret = _cal_ipc_marshal_int(in.time.date.year,ipc_data);
+ retv_if(ret!=CALENDAR_ERROR_NONE,ret);
+ ret = _cal_ipc_marshal_int(in.time.date.month,ipc_data);
+ retv_if(ret!=CALENDAR_ERROR_NONE,ret);
+ ret = _cal_ipc_marshal_int(in.time.date.mday,ipc_data);
+ retv_if(ret!=CALENDAR_ERROR_NONE,ret);
+ ret = _cal_ipc_marshal_int(in.time.date.hour,ipc_data);
+ retv_if(ret!=CALENDAR_ERROR_NONE,ret);
+ ret = _cal_ipc_marshal_int(in.time.date.minute,ipc_data);
+ retv_if(ret!=CALENDAR_ERROR_NONE,ret);
+ ret = _cal_ipc_marshal_int(in.time.date.second,ipc_data);
+ retv_if(ret!=CALENDAR_ERROR_NONE,ret);
+ }
+
+ return CALENDAR_ERROR_NONE;
}
int _cal_ipc_marshal_record_common(const cal_record_s* common, pims_ipc_data_h ipc_data)
{
- retv_if(NULL == common, CALENDAR_ERROR_INVALID_PARAMETER);
- retv_if(NULL == ipc_data, CALENDAR_ERROR_INVALID_PARAMETER);
-
- if(pims_ipc_data_put(ipc_data,(void*)&common->type,sizeof(int)) < 0)
- {
- return CALENDAR_ERROR_NO_DATA;
- }
-
- int length = strlen(common->view_uri);
- if (pims_ipc_data_put(ipc_data,(void*)common->view_uri,length+1) < 0)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if(pims_ipc_data_put(ipc_data,(void*)&common->properties_max_count,sizeof(int)) < 0)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_NO_DATA;
- }
- if (common->properties_max_count > 0)
- {
- if(pims_ipc_data_put(ipc_data,(void*)common->properties_flags,sizeof(char)*common->properties_max_count) < 0)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_NO_DATA;
- }
- }
- if(pims_ipc_data_put(ipc_data,(void*)&common->property_flag,sizeof(char)) < 0)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_NO_DATA;
- }
-
- return CALENDAR_ERROR_NONE;
-}
-/*
-int _cal_ipc_unmarshal_filter(const pims_ipc_data_h ipc_data, calendar_filter_h *filter)
-{
- cal_composite_filter_s *com_filter = NULL;
-
- retv_if(NULL == filter, CALENDAR_ERROR_INVALID_PARAMETER);
- retv_if(NULL == ipc_data, CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(NULL == common, CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(NULL == ipc_data, CALENDAR_ERROR_INVALID_PARAMETER);
- // !! create filter...
- //calendar_query_create(filter);
+ if (pims_ipc_data_put(ipc_data,(void*)&common->type,sizeof(int)) < 0)
+ return CALENDAR_ERROR_NO_DATA;
- com_filter = (cal_composite_filter_s*)filter;
+ int length = strlen(common->view_uri);
- return __cal_ipc_unmarshal_composite_filter(ipc_data,com_filter);
-}
+ if (pims_ipc_data_put(ipc_data,(void*)common->view_uri,length+1) < 0) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
-int _cal_ipc_marshal_filter(const calendar_filter_h filter, pims_ipc_data_h ipc_data)
-{
- cal_composite_filter_s *com_filter = NULL;
+ if (pims_ipc_data_put(ipc_data,(void*)&common->properties_max_count,sizeof(int)) < 0) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_NO_DATA;
+ }
- retv_if(NULL == filter, CALENDAR_ERROR_INVALID_PARAMETER);
- retv_if(NULL == ipc_data, CALENDAR_ERROR_INVALID_PARAMETER);
+ if (common->properties_max_count > 0) {
+ if(pims_ipc_data_put(ipc_data,(void*)common->properties_flags,sizeof(char)*common->properties_max_count) < 0) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_NO_DATA;
+ }
+ }
- com_filter = (cal_composite_filter_s*)filter;
+ if (pims_ipc_data_put(ipc_data,(void*)&common->property_flag,sizeof(char)) < 0) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_NO_DATA;
+ }
- return __cal_ipc_marshal_composite_filter(com_filter,ipc_data);
+ return CALENDAR_ERROR_NONE;
}
-*/
+
int _cal_ipc_unmarshal_query(const pims_ipc_data_h ipc_data, calendar_query_h *query)
{
- cal_query_s *que = NULL;
- unsigned int size = 0;
- char* str = NULL;
- int count = 0, i = 0;
- int ret = CALENDAR_ERROR_NONE;
-
- retv_if(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER);
- retv_if(NULL == ipc_data, CALENDAR_ERROR_INVALID_PARAMETER);
-
- // view_uri
- str = (char*)pims_ipc_data_get(ipc_data,&size);
-
- ret = calendar_query_create(str, query);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_query_create fail");
- return ret;
- }
-
- que = (cal_query_s *) *query;
-
- if (_cal_ipc_unmarshal_int(ipc_data,&count) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- goto ERROR_RETURN;
- }
-
- if (count == 0)
- {
- que->filter = NULL;
- }
- else
- {
- calendar_filter_h filter = (calendar_filter_h)que->filter;
- if (calendar_filter_create(que->view_uri,&filter) != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_filter_create fail");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- goto ERROR_RETURN;
- }
- que->filter = (cal_composite_filter_s*)filter;
-
- // for filter_type
- if (_cal_ipc_unmarshal_int(ipc_data,&count) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- goto ERROR_RETURN;
- }
-
- if (__cal_ipc_unmarshal_composite_filter(ipc_data,que->filter) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- goto ERROR_RETURN;
- }
- }
-
- if (_cal_ipc_unmarshal_int(ipc_data,&(que->projection_count)) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- goto ERROR_RETURN;
- }
-
- if (que->projection_count > 0)
- {
- que->projection = (unsigned int*)malloc(sizeof(int)*que->projection_count);
- if (que->projection == NULL)
- {
- ERR("malloc fail");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- goto ERROR_RETURN;
- }
- for(i=0;i<que->projection_count;i++)
- {
- if (_cal_ipc_unmarshal_uint(ipc_data,&(que->projection[i])) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- goto ERROR_RETURN;
- }
- }
- }
- else
- {
- que->projection = NULL;
- }
-
- if (_cal_ipc_unmarshal_int(ipc_data,&(que->sort_property_id)) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- goto ERROR_RETURN;
- }
-
- if (_cal_ipc_unmarshal_int(ipc_data,(int*)&(que->asc)) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- goto ERROR_RETURN;
- }
-
- que->properties = (cal_property_info_s *)_cal_view_get_property_info(que->view_uri, &que->property_count);
-
- if (_cal_ipc_unmarshal_int(ipc_data,(int*)&(que->distinct)) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- goto ERROR_RETURN;
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_query_s *que = NULL;
+ unsigned int size = 0;
+ char* str = NULL;
+ int count = 0, i = 0;
+ int ret = CALENDAR_ERROR_NONE;
+
+ retv_if(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(NULL == ipc_data, CALENDAR_ERROR_INVALID_PARAMETER);
+
+ // view_uri
+ str = (char*)pims_ipc_data_get(ipc_data,&size);
+
+ ret = calendar_query_create(str, query);
+ if (ret != CALENDAR_ERROR_NONE) {
+ ERR("calendar_query_create fail");
+ return ret;
+ }
+
+ que = (cal_query_s *) *query;
+
+ if (_cal_ipc_unmarshal_int(ipc_data,&count) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ goto ERROR_RETURN;
+ }
+
+ if (count == 0) {
+ que->filter = NULL;
+ }
+ else {
+ calendar_filter_h filter = (calendar_filter_h)que->filter;
+ if (calendar_filter_create(que->view_uri,&filter) != CALENDAR_ERROR_NONE) {
+ ERR("calendar_filter_create fail");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ goto ERROR_RETURN;
+ }
+ que->filter = (cal_composite_filter_s*)filter;
+
+ // for filter_type
+ if (_cal_ipc_unmarshal_int(ipc_data,&count) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ goto ERROR_RETURN;
+ }
+
+ if (__cal_ipc_unmarshal_composite_filter(ipc_data,que->filter) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ goto ERROR_RETURN;
+ }
+ }
+
+ if (_cal_ipc_unmarshal_int(ipc_data,&(que->projection_count)) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ goto ERROR_RETURN;
+ }
+
+ if (que->projection_count > 0) {
+ que->projection = (unsigned int*)malloc(sizeof(int)*que->projection_count);
+ if (que->projection == NULL) {
+ ERR("malloc fail");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ goto ERROR_RETURN;
+ }
+
+ for(i=0;i<que->projection_count;i++) {
+ if (_cal_ipc_unmarshal_uint(ipc_data,&(que->projection[i])) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ goto ERROR_RETURN;
+ }
+ }
+ }
+ else {
+ que->projection = NULL;
+ }
+
+ if (_cal_ipc_unmarshal_int(ipc_data,&(que->sort_property_id)) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ goto ERROR_RETURN;
+ }
+
+ if (_cal_ipc_unmarshal_int(ipc_data,(int*)&(que->asc)) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ goto ERROR_RETURN;
+ }
+
+ que->properties = (cal_property_info_s *)_cal_view_get_property_info(que->view_uri, &que->property_count);
+
+ if (_cal_ipc_unmarshal_int(ipc_data,(int*)&(que->distinct)) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ goto ERROR_RETURN;
+ }
+
+ return CALENDAR_ERROR_NONE;
ERROR_RETURN:
- calendar_query_destroy(*query);
- *query = NULL;
+ calendar_query_destroy(*query);
+ *query = NULL;
- return ret;
+ return ret;
}
int _cal_ipc_marshal_query(const calendar_query_h query, pims_ipc_data_h ipc_data)
{
- cal_query_s *que = NULL;
- int i = 0;
- int length = 0;
-
- retv_if(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER);
- retv_if(NULL == ipc_data, CALENDAR_ERROR_INVALID_PARAMETER);
- que = (cal_query_s *)query;
-
- //view_uri
- length = strlen(que->view_uri);
- if (pims_ipc_data_put(ipc_data,(void*)que->view_uri,length+1) < 0)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- if (que->filter)
- {
- if (_cal_ipc_marshal_int(1,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (__cal_ipc_marshal_composite_filter(que->filter,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
- if (_cal_ipc_marshal_int(0,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
-
- if (_cal_ipc_marshal_int((que->projection_count),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- for(i=0;i<que->projection_count;i++)
- {
- if (_cal_ipc_marshal_uint((que->projection[i]),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
-
- if (_cal_ipc_marshal_int((que->sort_property_id),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- if (_cal_ipc_marshal_int((int)(que->asc),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_marshal_int((int)(que->distinct),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- //properties // property_count
-
- return CALENDAR_ERROR_NONE;
+ cal_query_s *que = NULL;
+ int i = 0;
+ int length = 0;
+
+ retv_if(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(NULL == ipc_data, CALENDAR_ERROR_INVALID_PARAMETER);
+ que = (cal_query_s *)query;
+
+ //view_uri
+ length = strlen(que->view_uri);
+ if (pims_ipc_data_put(ipc_data,(void*)que->view_uri,length+1) < 0) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (que->filter) {
+ if (_cal_ipc_marshal_int(1,ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (__cal_ipc_marshal_composite_filter(que->filter,ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ else
+ {
+ if (_cal_ipc_marshal_int(0,ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+
+ if (_cal_ipc_marshal_int((que->projection_count),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ for(i=0;i<que->projection_count;i++) {
+ if (_cal_ipc_marshal_uint((que->projection[i]),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+
+ if (_cal_ipc_marshal_int((que->sort_property_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_marshal_int((int)(que->asc),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_marshal_int((int)(que->distinct),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ //properties // property_count
+
+ return CALENDAR_ERROR_NONE;
}
int _cal_ipc_unmarshal_list(const pims_ipc_data_h ipc_data, calendar_list_h* list)
{
- int count = 0, i = 0;
- calendar_record_h record;
- int ret = CALENDAR_ERROR_NONE;
-
- retv_if(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER);
- retv_if(NULL == ipc_data, CALENDAR_ERROR_INVALID_PARAMETER);
-
- if (calendar_list_create(list) != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_list_create fail");
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
-
- if (_cal_ipc_unmarshal_int(ipc_data,&(count)) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- goto ERROR_RETURN;
- }
-
- for(i=0;i<count;i++)
- {
- if (_cal_ipc_unmarshal_record(ipc_data,&record) != CALENDAR_ERROR_NONE )
- {
- ERR("_cal_ipc_unmarshal fail");
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- goto ERROR_RETURN;
- }
-
- if (calendar_list_add(*list,record) != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_list_add fail");
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- goto ERROR_RETURN;
- }
- }
-
- calendar_list_first(*list);
-
- return CALENDAR_ERROR_NONE;
+ int count = 0, i = 0;
+ calendar_record_h record;
+ int ret = CALENDAR_ERROR_NONE;
+
+ retvm_if(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER, "list is NULL");
+ retvm_if(NULL == ipc_data, CALENDAR_ERROR_INVALID_PARAMETER, "ipc_data is NULL");
+
+ if (calendar_list_create(list) != CALENDAR_ERROR_NONE) {
+ ERR("calendar_list_create fail");
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+
+ if (_cal_ipc_unmarshal_int(ipc_data,&(count)) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ goto ERROR_RETURN;
+ }
+
+ for(i=0;i<count;i++) {
+ if (_cal_ipc_unmarshal_record(ipc_data,&record) != CALENDAR_ERROR_NONE ) {
+ ERR("_cal_ipc_unmarshal fail");
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ goto ERROR_RETURN;
+ }
+
+ if (calendar_list_add(*list,record) != CALENDAR_ERROR_NONE) {
+ ERR("calendar_list_add fail");
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ goto ERROR_RETURN;
+ }
+ }
+ calendar_list_first(*list);
+
+ return CALENDAR_ERROR_NONE;
ERROR_RETURN:
- if (*list)
- {
- calendar_list_destroy(*list, true);
- *list = NULL;
- }
+ if (*list) {
+ calendar_list_destroy(*list, true);
+ *list = NULL;
+ }
- return ret;
+ return ret;
}
int _cal_ipc_marshal_list(const calendar_list_h list, pims_ipc_data_h ipc_data)
{
- int count = 0, i = 0;
- calendar_record_h record;
- retv_if(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER);
- retv_if(NULL == ipc_data, CALENDAR_ERROR_INVALID_PARAMETER);
-
- // count
- if (calendar_list_get_count(list, &count) != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_list_get_count fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_marshal_int(count,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- calendar_list_first(list);
-
- for(i=0;i<count;i++)
- {
- if (calendar_list_get_current_record_p(list,&record) != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_list_get_count fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_marshal_record(record,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- calendar_list_next(list);
- }
-
- return CALENDAR_ERROR_NONE;
+ int count = 0, i = 0;
+ calendar_record_h record;
+ retv_if(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(NULL == ipc_data, CALENDAR_ERROR_INVALID_PARAMETER);
+
+ // count
+ if (calendar_list_get_count(list, &count) != CALENDAR_ERROR_NONE) {
+ ERR("calendar_list_get_count fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_marshal_int(count,ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ calendar_list_first(list);
+
+ for(i=0;i<count;i++) {
+ if (calendar_list_get_current_record_p(list,&record) != CALENDAR_ERROR_NONE) {
+ ERR("calendar_list_get_count fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_marshal_record(record,ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ calendar_list_next(list);
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+int _cal_ipc_unmarshal_child_list(const pims_ipc_data_h ipc_data, calendar_list_h* list)
+{
+ unsigned int i = 0;
+ int count = 0;
+ calendar_record_h record;
+
+ retv_if(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(NULL == ipc_data, CALENDAR_ERROR_INVALID_PARAMETER);
+
+ if (_cal_ipc_unmarshal_int(ipc_data,&(count)) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal_int fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ for(i=0;i<count;i++) {
+ if (_cal_ipc_unmarshal_record(ipc_data,&record) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal_record fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (calendar_list_add(*list,record) != CALENDAR_ERROR_NONE) {
+ ERR("calendar_list_add fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+
+ return CALENDAR_ERROR_NONE;
}
+
#include "cal_typedef.h"
#include "cal_record.h"
-/*
- * record
- * pims_ipc_data_h 의 경우 생성된 사항을 넘겨받아야함
- * unmarshal_record의 경우 plugin에서 struct를 alloc하여 return
- * marshal : 각 plugin에서 cal_common_s + other 같이 marshal
- * unmarshal : cal_common_s 는 먼저 marshal 하여, view_uri 만 넘겨준 이후,
- * 각 plug in에서 cal_common_s를 제외 한 사항에 대하여 unmarshal
- */
typedef int (*cal_ipc_unmarshal_record_cb)(const pims_ipc_data_h ipc_data, calendar_record_h record);
typedef int (*cal_ipc_marshal_record_cb)(const calendar_record_h record, pims_ipc_data_h ipc_data);
typedef int (*cal_ipc_marshal_record_get_primary_id_cb)(const calendar_record_h record, unsigned int *property_id, int *id);
typedef struct {
- cal_ipc_unmarshal_record_cb unmarshal_record;
- cal_ipc_marshal_record_cb marshal_record;
- cal_ipc_marshal_record_get_primary_id_cb get_primary_id;
+ cal_ipc_unmarshal_record_cb unmarshal_record;
+ cal_ipc_marshal_record_cb marshal_record;
+ cal_ipc_marshal_record_get_primary_id_cb get_primary_id;
} cal_ipc_marshal_record_plugin_cb_s;
int _cal_ipc_unmarshal_record(const pims_ipc_data_h ipc_data, calendar_record_h* precord);
int _cal_ipc_marshal_record(const calendar_record_h record, pims_ipc_data_h ipc_data);
int _cal_ipc_marshal_record_get_primary_id(const calendar_record_h record, unsigned int *property_id, int *id);
-/*
- * string
- * char의 경우 NULL 설정의 이슈로 인하여, [int:string length]+[char*] 로 넘길 수 있도록 설정..
- */
int _cal_ipc_unmarshal_char(const pims_ipc_data_h ipc_data, char** ppbufchar);
int _cal_ipc_unmarshal_int(const pims_ipc_data_h data, int *pout);
int _cal_ipc_unmarshal_uint(const pims_ipc_data_h data, unsigned int *pout);
int _cal_ipc_unmarshal_caltime(const pims_ipc_data_h data, calendar_time_s *pout);
int _cal_ipc_unmarshal_record_common(const pims_ipc_data_h ipc_data, cal_record_s* common);
-/*
- * NULL 이슈로 _cal_ipc_unmarshal_char / _cal_ipc_marshal_char 는 pair 를 이루어야함.
- */
int _cal_ipc_marshal_char(const char* bufchar, pims_ipc_data_h ipc_data);
int _cal_ipc_marshal_int(const int in, pims_ipc_data_h ipc_data);
int _cal_ipc_marshal_uint(const unsigned int in, pims_ipc_data_h ipc_data);
int _cal_ipc_marshal_caltime(const calendar_time_s in, pims_ipc_data_h ipc_data);
int _cal_ipc_marshal_record_common(const cal_record_s* common, pims_ipc_data_h ipc_data);
-/*
- * filter, query
- *
- * marsharl : view_uri + other
- * unmarshal : view_uri를 먼저 get 하고 난 이후 나머지를 ..
- */
-//int _cal_ipc_unmarshal_filter(const pims_ipc_data_h ipc_data, calendar_filter_h *filter);
-//int _cal_ipc_marshal_filter(const calendar_filter_h filter, pims_ipc_data_h ipc_data);
int _cal_ipc_unmarshal_query(const pims_ipc_data_h ipc_data, calendar_query_h *query);
int _cal_ipc_marshal_query(const calendar_query_h query, pims_ipc_data_h ipc_data);
int _cal_ipc_unmarshal_list(const pims_ipc_data_h ipc_data, calendar_list_h *list);
int _cal_ipc_marshal_list(const calendar_list_h list, pims_ipc_data_h ipc_data);
+int _cal_ipc_unmarshal_child_list(const pims_ipc_data_h ipc_data, calendar_list_h* list);
/*
* for property_id
*/
-
#define CAL_IPC_CHECK_PROPERTIES_FLAG(src) (CAL_IPC_CHECK_PROJECTION(src) || CAL_IPC_CHECK_DIRTY(src))
#define CAL_IPC_CHECK_PROJECTION(src) ((src) & (unsigned char)CAL_PROPERTY_FLAG_PROJECTION)
#define CAL_IPC_CHECK_DIRTY(src) ((src) & (unsigned char)CAL_PROPERTY_FLAG_DIRTY)
static int __cal_ipc_marshal_alarm(const calendar_record_h record, pims_ipc_data_h ipc_data);
cal_ipc_marshal_record_plugin_cb_s _cal_ipc_record_alarm_plugin_cb = {
- .unmarshal_record = __cal_ipc_unmarshal_alarm,
- .marshal_record = __cal_ipc_marshal_alarm,
- .get_primary_id = NULL
+ .unmarshal_record = __cal_ipc_unmarshal_alarm,
+ .marshal_record = __cal_ipc_marshal_alarm,
+ .get_primary_id = NULL
};
static int __cal_ipc_unmarshal_alarm(pims_ipc_data_h ipc_data, calendar_record_h record)
{
- cal_alarm_s* palarm = NULL;
- bool bpropertyflag = false;
-
- retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
- retv_if(record==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
-
- palarm = (cal_alarm_s*) record;
-
- if (palarm->common.properties_max_count > 0)
- {
- bpropertyflag = true;
- }
-
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(palarm->common.properties_flags[6]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&palarm->alarm_id) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
-
- // read only or primary/secondary key
- if (_cal_ipc_unmarshal_int(ipc_data,&palarm->event_id) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(palarm->common.properties_flags[0]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,(int*)&palarm->alarm_type) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
-
- if (_cal_ipc_unmarshal_int(ipc_data,&palarm->is_deleted) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(palarm->common.properties_flags[1]) )
- {
- if (_cal_ipc_unmarshal_lli(ipc_data,&palarm->alarm_time) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(palarm->common.properties_flags[2]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&palarm->remind_tick) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(palarm->common.properties_flags[3]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,(int*)&palarm->remind_tick_unit) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(palarm->common.properties_flags[4]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&palarm->alarm_tone) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(palarm->common.properties_flags[5]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&palarm->alarm_description) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_alarm_s* palarm = NULL;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(record==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+
+ palarm = (cal_alarm_s*) record;
+
+ // read only or primary/secondary key
+ if (_cal_ipc_unmarshal_int(ipc_data,&palarm->id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_unmarshal_int(ipc_data,&palarm->parent_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_unmarshal_int(ipc_data,&palarm->is_deleted) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_unmarshal_int(ipc_data,&palarm->remind_tick) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_unmarshal_int(ipc_data,(int*)&palarm->remind_tick_unit) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_unmarshal_char(ipc_data,&palarm->alarm_description) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_unmarshal_char(ipc_data,&palarm->alarm_summary) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_unmarshal_int(ipc_data,&palarm->alarm_action) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_unmarshal_char(ipc_data,&palarm->alarm_attach) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_unmarshal_caltime(ipc_data,&palarm->alarm) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
}
static int __cal_ipc_marshal_alarm(const calendar_record_h record, pims_ipc_data_h ipc_data)
{
- cal_alarm_s* palarm = (cal_alarm_s*) record;
- bool bpropertyflag = false;
- retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
- retv_if(palarm==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
-
- if (_cal_ipc_marshal_record_common(&(palarm->common),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (palarm->common.properties_max_count > 0)
- {
- bpropertyflag = true;
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(palarm->common.properties_flags[6]) )
- {
- if (_cal_ipc_marshal_int((palarm->alarm_id),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- // read only or primary/secondary key
- if (_cal_ipc_marshal_int((palarm->event_id),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(palarm->common.properties_flags[0]) )
- {
- if (_cal_ipc_marshal_int((palarm->alarm_type),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (_cal_ipc_marshal_int((palarm->is_deleted),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(palarm->common.properties_flags[1]) )
- {
- if (_cal_ipc_marshal_lli((palarm->alarm_time),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(palarm->common.properties_flags[2]) )
- {
- if (_cal_ipc_marshal_int((palarm->remind_tick),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(palarm->common.properties_flags[3]) )
- {
- if (_cal_ipc_marshal_int((palarm->remind_tick_unit),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(palarm->common.properties_flags[4]) )
- {
- if (_cal_ipc_marshal_char((palarm->alarm_tone),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(palarm->common.properties_flags[5]) )
- {
- if (_cal_ipc_marshal_char((palarm->alarm_description),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_alarm_s* palarm = (cal_alarm_s*) record;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(palarm==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+
+ // read only or primary/secondary key
+ if (_cal_ipc_marshal_int((palarm->id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((palarm->parent_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_marshal_int((palarm->is_deleted),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_marshal_int((palarm->remind_tick),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((palarm->remind_tick_unit),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((palarm->alarm_description),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((palarm->alarm_summary),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((palarm->alarm_action),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((palarm->alarm_attach),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_caltime((palarm->alarm),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
}
static int __cal_ipc_marshal_attendee(const calendar_record_h record, pims_ipc_data_h ipc_data);
cal_ipc_marshal_record_plugin_cb_s _cal_ipc_record_attendee_plugin_cb = {
- .unmarshal_record = __cal_ipc_unmarshal_attendee,
- .marshal_record = __cal_ipc_marshal_attendee,
- .get_primary_id = NULL
+ .unmarshal_record = __cal_ipc_unmarshal_attendee,
+ .marshal_record = __cal_ipc_marshal_attendee,
+ .get_primary_id = NULL
};
static int __cal_ipc_unmarshal_attendee(const pims_ipc_data_h ipc_data, calendar_record_h record)
{
- cal_attendee_s* pattendee = NULL;
- bool bpropertyflag = false;
- retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
- retv_if(record==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
-
- pattendee = (cal_attendee_s*) record;
-
- if (pattendee->common.properties_max_count > 0)
- {
- bpropertyflag = true;
- }
-
- // read only or primary/secondary key
- if (_cal_ipc_unmarshal_int(ipc_data,&pattendee->event_id) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pattendee->common.properties_flags[0]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pattendee->attendee_number) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pattendee->common.properties_flags[1]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pattendee->attendee_type) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pattendee->common.properties_flags[2]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pattendee->attendee_ct_index) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pattendee->common.properties_flags[3]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pattendee->attendee_uid) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pattendee->common.properties_flags[4]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pattendee->attendee_group) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pattendee->common.properties_flags[5]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pattendee->attendee_email) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pattendee->common.properties_flags[6]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pattendee->attendee_role) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pattendee->common.properties_flags[7]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pattendee->attendee_status) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pattendee->common.properties_flags[8]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pattendee->attendee_rsvp) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pattendee->common.properties_flags[9]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pattendee->attendee_delegate_uri) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pattendee->common.properties_flags[10]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pattendee->attendee_delegator_uri) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pattendee->common.properties_flags[11]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pattendee->attendee_name) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_attendee_s* pattendee = NULL;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(record==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+
+ pattendee = (cal_attendee_s*) record;
+
+ // read only or primary/secondary key
+ if (_cal_ipc_unmarshal_int(ipc_data,&pattendee->id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_unmarshal_int(ipc_data,&pattendee->parent_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_unmarshal_char(ipc_data,&pattendee->attendee_number) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_unmarshal_int(ipc_data,&pattendee->attendee_cutype) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_unmarshal_int(ipc_data,&pattendee->attendee_ct_index) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_unmarshal_char(ipc_data,&pattendee->attendee_uid) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_unmarshal_char(ipc_data,&pattendee->attendee_group) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_unmarshal_char(ipc_data,&pattendee->attendee_email) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_unmarshal_int(ipc_data,&pattendee->attendee_role) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_unmarshal_int(ipc_data,&pattendee->attendee_status) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_unmarshal_int(ipc_data,&pattendee->attendee_rsvp) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_unmarshal_char(ipc_data,&pattendee->attendee_delegatee_uri) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_unmarshal_char(ipc_data,&pattendee->attendee_delegator_uri) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_unmarshal_char(ipc_data,&pattendee->attendee_name) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_unmarshal_char(ipc_data,&pattendee->attendee_member) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_ipc_marshal_attendee(const calendar_record_h record, pims_ipc_data_h ipc_data )
{
- cal_attendee_s* pattendee = (cal_attendee_s*) record;
- bool bpropertyflag = false;
-
- retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
- retv_if(pattendee==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
-
- if (_cal_ipc_marshal_record_common(&(pattendee->common),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- if (pattendee->common.properties_max_count > 0)
- {
- bpropertyflag = true;
- }
- // read only or primary/secondary key
- if (_cal_ipc_marshal_int((pattendee->event_id),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pattendee->common.properties_flags[0]) )
- {
- if (_cal_ipc_marshal_char((pattendee->attendee_number),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pattendee->common.properties_flags[1]) )
- {
- if (_cal_ipc_marshal_int((pattendee->attendee_type),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pattendee->common.properties_flags[2]) )
- {
- if (_cal_ipc_marshal_int((pattendee->attendee_ct_index),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pattendee->common.properties_flags[3]) )
- {
- if (_cal_ipc_marshal_char((pattendee->attendee_uid),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pattendee->common.properties_flags[4]) )
- {
- if (_cal_ipc_marshal_char((pattendee->attendee_group),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pattendee->common.properties_flags[5]) )
- {
- if (_cal_ipc_marshal_char((pattendee->attendee_email),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pattendee->common.properties_flags[6]) )
- {
- if (_cal_ipc_marshal_int((pattendee->attendee_role),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pattendee->common.properties_flags[7]) )
- {
- if (_cal_ipc_marshal_int((pattendee->attendee_status),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pattendee->common.properties_flags[8]) )
- {
- if (_cal_ipc_marshal_int((pattendee->attendee_rsvp),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pattendee->common.properties_flags[9]) )
- {
- if (_cal_ipc_marshal_char((pattendee->attendee_delegate_uri),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pattendee->common.properties_flags[10]) )
- {
- if (_cal_ipc_marshal_char((pattendee->attendee_delegator_uri),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pattendee->common.properties_flags[11]) )
- {
- if (_cal_ipc_marshal_char((pattendee->attendee_name),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_attendee_s* pattendee = (cal_attendee_s*) record;
+
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(pattendee==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+
+ // read only or primary/secondary key
+ if (_cal_ipc_marshal_int((pattendee->id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_marshal_int((pattendee->parent_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_marshal_char((pattendee->attendee_number),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_marshal_int((pattendee->attendee_cutype),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_marshal_int((pattendee->attendee_ct_index),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_marshal_char((pattendee->attendee_uid),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_marshal_char((pattendee->attendee_group),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_marshal_char((pattendee->attendee_email),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_marshal_int((pattendee->attendee_role),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_marshal_int((pattendee->attendee_status),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_marshal_int((pattendee->attendee_rsvp),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_marshal_char((pattendee->attendee_delegatee_uri),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_marshal_char((pattendee->attendee_delegator_uri),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_marshal_char((pattendee->attendee_name),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (_cal_ipc_marshal_char((pattendee->attendee_member),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_ipc_marshal_calendar_get_primary_id(const calendar_record_h record, unsigned int *property_id, int *id);
cal_ipc_marshal_record_plugin_cb_s _cal_ipc_record_calendar_plugin_cb = {
- .unmarshal_record = __cal_ipc_unmarshal_calendar,
- .marshal_record = __cal_ipc_marshal_calendar,
- .get_primary_id = __cal_ipc_marshal_calendar_get_primary_id
+ .unmarshal_record = __cal_ipc_unmarshal_calendar,
+ .marshal_record = __cal_ipc_marshal_calendar,
+ .get_primary_id = __cal_ipc_marshal_calendar_get_primary_id
};
static int __cal_ipc_unmarshal_calendar(pims_ipc_data_h ipc_data, calendar_record_h record)
{
- cal_calendar_s* pcalendar = NULL;
- bool bpropertyflag = false;
- retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
- retv_if(record==NULL,CALENDAR_ERROR_NO_DATA);
+ cal_calendar_s* pcalendar = NULL;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
+ retv_if(record==NULL,CALENDAR_ERROR_NO_DATA);
- pcalendar = (cal_calendar_s*) record;
+ pcalendar = (cal_calendar_s*) record;
- if (pcalendar->common.properties_max_count > 0)
- {
- bpropertyflag = true;
- }
- // read only or primary/secondary key
- if (_cal_ipc_unmarshal_int(ipc_data,&pcalendar->index) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[10]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pcalendar->store_type) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[1]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pcalendar->uid) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pcalendar->index) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pcalendar->store_type) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pcalendar->uid) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_long(ipc_data,&pcalendar->updated) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pcalendar->name) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pcalendar->description) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pcalendar->color) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pcalendar->location) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pcalendar->visibility) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pcalendar->sync_event) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pcalendar->account_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pcalendar->sync_data1) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pcalendar->sync_data2) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pcalendar->sync_data3) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pcalendar->sync_data4) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pcalendar->mode) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- if (_cal_ipc_unmarshal_long(ipc_data,&pcalendar->updated) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[2]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pcalendar->name) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[3]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pcalendar->description) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[4]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pcalendar->color) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[5]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pcalendar->location) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[6]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pcalendar->visibility) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[7]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pcalendar->sync_event) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[8]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pcalendar->is_deleted) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[9]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pcalendar->account_id) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[11]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pcalendar->sync_data1) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[12]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pcalendar->sync_data2) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[13]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pcalendar->sync_data3) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[14]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pcalendar->sync_data4) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
-
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_ipc_marshal_calendar(const calendar_record_h record, pims_ipc_data_h ipc_data)
{
- cal_calendar_s* pcalendar = (cal_calendar_s*)record;
- bool bpropertyflag = false;
- retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
- retv_if(pcalendar==NULL,CALENDAR_ERROR_NO_DATA);
+ cal_calendar_s* pcalendar = (cal_calendar_s*)record;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
+ retv_if(pcalendar==NULL,CALENDAR_ERROR_NO_DATA);
- if (_cal_ipc_marshal_record_common(&(pcalendar->common),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (pcalendar->common.properties_max_count > 0)
- {
- bpropertyflag = true;
- }
- // read only or primary/secondary key
- if (_cal_ipc_marshal_int((pcalendar->index),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[10]) )
- {
- if (_cal_ipc_marshal_int((pcalendar->store_type),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[1]) )
- {
- if (_cal_ipc_marshal_char((pcalendar->uid),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (_cal_ipc_marshal_long((pcalendar->updated),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[2]) )
- {
- if (_cal_ipc_marshal_char((pcalendar->name),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[3]) )
- {
- if (_cal_ipc_marshal_char((pcalendar->description),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[4]) )
- {
- if (_cal_ipc_marshal_char((pcalendar->color),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[5]) )
- {
- if (_cal_ipc_marshal_char((pcalendar->location),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[6]) )
- {
- if (_cal_ipc_marshal_int((pcalendar->visibility),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[7]) )
- {
- if (_cal_ipc_marshal_int((pcalendar->sync_event),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[8]) )
- {
- if (_cal_ipc_marshal_int((pcalendar->is_deleted),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[9]) )
- {
- if (_cal_ipc_marshal_int((pcalendar->account_id),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[11]) )
- {
- if (_cal_ipc_marshal_char((pcalendar->sync_data1),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[12]) )
- {
- if (_cal_ipc_marshal_char((pcalendar->sync_data2),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[13]) )
- {
- if (_cal_ipc_marshal_char((pcalendar->sync_data3),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pcalendar->common.properties_flags[14]) )
- {
- if (_cal_ipc_marshal_char((pcalendar->sync_data4),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
+ if (_cal_ipc_marshal_int((pcalendar->index),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pcalendar->store_type),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pcalendar->uid),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_long((pcalendar->updated),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pcalendar->name),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pcalendar->description),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pcalendar->color),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pcalendar->location),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pcalendar->visibility),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pcalendar->sync_event),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pcalendar->account_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pcalendar->sync_data1),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pcalendar->sync_data2),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pcalendar->sync_data3),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pcalendar->sync_data4),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pcalendar->mode),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_ipc_marshal_calendar_get_primary_id(const calendar_record_h record, unsigned int *property_id, int *id)
{
- *property_id = CAL_PROPERTY_CALENDAR_ID;
- return calendar_record_get_int(record, *property_id, id );
+ *property_id = CAL_PROPERTY_CALENDAR_ID;
+ return calendar_record_get_int(record, *property_id, id );
}
static int __cal_ipc_marshal_event_get_primary_id(const calendar_record_h record, unsigned int *property_id, int *id);
cal_ipc_marshal_record_plugin_cb_s _cal_ipc_record_event_plugin_cb = {
- .unmarshal_record = __cal_ipc_unmarshal_event,
- .marshal_record = __cal_ipc_marshal_event,
- .get_primary_id = __cal_ipc_marshal_event_get_primary_id
+ .unmarshal_record = __cal_ipc_unmarshal_event,
+ .marshal_record = __cal_ipc_marshal_event,
+ .get_primary_id = __cal_ipc_marshal_event_get_primary_id
};
static int __cal_ipc_unmarshal_event(pims_ipc_data_h ipc_data, calendar_record_h record)
{
- cal_event_s *pevent = NULL;
- bool bpropertyflag = false;
- retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
- retv_if(record==NULL,CALENDAR_ERROR_NO_DATA);
+ cal_event_s *pevent = NULL;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
+ retv_if(record==NULL,CALENDAR_ERROR_NO_DATA);
- pevent = (cal_event_s*) record;
+ pevent = (cal_event_s*) record;
- if (pevent->common.properties_max_count > 0)
- {
- bpropertyflag = true;
- }
- // read only or primary/secondary key
- if (_cal_ipc_unmarshal_int(ipc_data,&pevent->index) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[1]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pevent->calendar_id) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[2]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pevent->summary) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[3]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pevent->description) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[4]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pevent->location) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[5]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pevent->categories) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[6]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pevent->exdate) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[7]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,(int*)&pevent->event_status) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[8]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,(int*)&pevent->priority) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[9]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pevent->timezone) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[10]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pevent->contact_id) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[11]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pevent->busy_status) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[12]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pevent->sensitivity) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[16]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pevent->meeting_status) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[13]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pevent->uid) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[14]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pevent->organizer_name) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[15]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pevent->organizer_email) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- // read only or primary/secondary key
- if (_cal_ipc_unmarshal_int(ipc_data,&pevent->original_event_id) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[18]) )
- {
- if (_cal_ipc_unmarshal_double(ipc_data,&pevent->latitude) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[19]) )
- {
- if (_cal_ipc_unmarshal_double(ipc_data,&pevent->longitude) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[20]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pevent->email_id) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[21]) )
- {
- if (_cal_ipc_unmarshal_lli(ipc_data,&pevent->created_time) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[23]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pevent->is_deleted) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[22]) )
- {
- if (_cal_ipc_unmarshal_lli(ipc_data,&pevent->last_mod) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[24]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pevent->freq) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[25]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pevent->range_type) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[26]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pevent->until_type) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_unmarshal_lli(ipc_data,&pevent->until_utime) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_unmarshal_int(ipc_data,&pevent->until_year) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_unmarshal_int(ipc_data,&pevent->until_month) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_unmarshal_int(ipc_data,&pevent->until_mday) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[27]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pevent->count) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[28]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pevent->interval) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[29]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pevent->bysecond) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[30]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pevent->byminute) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[31]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pevent->byhour) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[32]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pevent->byday) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[33]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pevent->bymonthday) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[34]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pevent->byyearday) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[35]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pevent->byweekno) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[36]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pevent->bymonth) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[37]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pevent->bysetpos) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[38]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pevent->wkst) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[39]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pevent->recurrence_id) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[40]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pevent->rdate) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[41]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pevent->has_attendee) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[42]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pevent->has_alarm) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[51]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pevent->system_type) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pevent->index) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pevent->calendar_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pevent->summary) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pevent->description) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pevent->location) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pevent->categories) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pevent->exdate) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,(int*)&pevent->event_status) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,(int*)&pevent->priority) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pevent->timezone) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pevent->contact_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pevent->busy_status) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pevent->sensitivity) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pevent->meeting_status) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pevent->uid) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pevent->organizer_name) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pevent->organizer_email) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pevent->original_event_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_double(ipc_data,&pevent->latitude) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_double(ipc_data,&pevent->longitude) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pevent->email_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_lli(ipc_data,&pevent->created_time) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pevent->is_deleted) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_lli(ipc_data,&pevent->last_mod) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pevent->freq) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pevent->range_type) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_caltime(ipc_data,&pevent->until) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pevent->count) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pevent->interval) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pevent->bysecond) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pevent->byminute) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pevent->byhour) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pevent->byday) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pevent->bymonthday) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pevent->byyearday) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pevent->byweekno) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pevent->bymonth) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pevent->bysetpos) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pevent->wkst) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pevent->recurrence_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pevent->rdate) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pevent->has_attendee) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pevent->has_alarm) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pevent->system_type) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_long(ipc_data,&pevent->updated) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pevent->sync_data1) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pevent->sync_data2) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pevent->sync_data3) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pevent->sync_data4) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_caltime(ipc_data,&pevent->start) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pevent->start_tzid) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_caltime(ipc_data,&pevent->end) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pevent->end_tzid) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pevent->is_allday) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- if (_cal_ipc_unmarshal_long(ipc_data,&pevent->updated) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
+ if (CALENDAR_ERROR_NONE != _cal_ipc_unmarshal_child_list(ipc_data, (calendar_list_h *)&pevent->alarm_list)) {
+ ERR("_cal_ipc_unmarshal_list fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (CALENDAR_ERROR_NONE != _cal_ipc_unmarshal_child_list(ipc_data, (calendar_list_h *)&pevent->attendee_list)) {
+ ERR("_cal_ipc_unmarshal_list fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (CALENDAR_ERROR_NONE != _cal_ipc_unmarshal_child_list(ipc_data, (calendar_list_h *)&pevent->exception_list)) {
+ ERR("_cal_ipc_unmarshal_list fail: exception");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (CALENDAR_ERROR_NONE != _cal_ipc_unmarshal_child_list(ipc_data, (calendar_list_h *)&pevent->extended_list)) {
+ ERR("_cal_ipc_unmarshal_list fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[43]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pevent->sync_data1) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[44]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pevent->sync_data2) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[45]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pevent->sync_data3) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[46]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pevent->sync_data4) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[47]) )
- {
- if (_cal_ipc_unmarshal_caltime(ipc_data,&pevent->start) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[52]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pevent->start_tzid) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[48]) )
- {
- if (_cal_ipc_unmarshal_caltime(ipc_data,&pevent->end) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[53]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pevent->end_tzid) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
-
- // !! alarm_list, attendee_list
- // alarm_list
- int count = 0, i = 0;
- if (_cal_ipc_unmarshal_int(ipc_data,&count) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- for(i=0;i<count;i++)
- {
- calendar_record_h alarm_child_record = NULL;
- if (_cal_ipc_unmarshal_record(ipc_data, &alarm_child_record) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- pevent->alarm_list = g_list_append(pevent->alarm_list, alarm_child_record);
- }
-
- // attendee_list
- if (_cal_ipc_unmarshal_int(ipc_data,&count) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- for(i=0;i<count;i++)
- {
- calendar_record_h attendee_child_record = NULL;
- if (_cal_ipc_unmarshal_record(ipc_data, &attendee_child_record) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- pevent->attendee_list = g_list_append(pevent->attendee_list, attendee_child_record);
- }
-
- // exception_list
- if (_cal_ipc_unmarshal_int(ipc_data,&count) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- for(i=0;i<count;i++)
- {
- calendar_record_h exception_child_record = NULL;
- if (_cal_ipc_unmarshal_record(ipc_data, &exception_child_record) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- pevent->exception_list = g_list_append(pevent->exception_list, exception_child_record);
- }
-
- // extended_list
- if (_cal_ipc_unmarshal_int(ipc_data,&count) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- for(i=0;i<count;i++)
- {
- calendar_record_h child_record = NULL;
- if (_cal_ipc_unmarshal_record(ipc_data, &child_record) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- pevent->extended_list = g_list_append(pevent->extended_list, child_record);
- }
-
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_ipc_marshal_event(const calendar_record_h record, pims_ipc_data_h ipc_data)
{
- cal_event_s* pevent = (cal_event_s*) record;
- bool bpropertyflag = false;
- retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
- retv_if(pevent==NULL,CALENDAR_ERROR_NO_DATA);
-
- if (_cal_ipc_marshal_record_common(&(pevent->common),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (pevent->common.properties_max_count > 0)
- {
- bpropertyflag = true;
- }
- // read only or primary/secondary key
- if (_cal_ipc_marshal_int((pevent->index),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[1]) )
- {
- if (_cal_ipc_marshal_int((pevent->calendar_id),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[2]) )
- {
- if (_cal_ipc_marshal_char((pevent->summary),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[3]) )
- {
- if (_cal_ipc_marshal_char((pevent->description),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[4]) )
- {
- if (_cal_ipc_marshal_char((pevent->location),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[5]) )
- {
- if (_cal_ipc_marshal_char((pevent->categories),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[6]) )
- {
- if (_cal_ipc_marshal_char((pevent->exdate),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[7]) )
- {
- if (_cal_ipc_marshal_int((pevent->event_status),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[8]) )
- {
- if (_cal_ipc_marshal_int((pevent->priority),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[9]) )
- {
- if (_cal_ipc_marshal_int((pevent->timezone),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[10]) )
- {
- if (_cal_ipc_marshal_int((pevent->contact_id),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[11]) )
- {
- if (_cal_ipc_marshal_int((pevent->busy_status),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[12]) )
- {
- if (_cal_ipc_marshal_int((pevent->sensitivity),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[16]) )
- {
- if (_cal_ipc_marshal_int((pevent->meeting_status),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[13]) )
- {
- if (_cal_ipc_marshal_char((pevent->uid),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[14]) )
- {
- if (_cal_ipc_marshal_char((pevent->organizer_name),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[15]) )
- {
- if (_cal_ipc_marshal_char((pevent->organizer_email),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- // read only or primary/secondary key
- if (_cal_ipc_marshal_int((pevent->original_event_id),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[18]) )
- {
- if (_cal_ipc_marshal_double((pevent->latitude),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[19]) )
- {
- if (_cal_ipc_marshal_double((pevent->longitude),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[20]) )
- {
- if (_cal_ipc_marshal_int((pevent->email_id),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[21]) )
- {
- if (_cal_ipc_marshal_lli((pevent->created_time),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[23]) )
- {
- if (_cal_ipc_marshal_int((pevent->is_deleted),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[22]) )
- {
- if (_cal_ipc_marshal_lli((pevent->last_mod),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[24]) )
- {
- if (_cal_ipc_marshal_int((pevent->freq),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[25]) )
- {
- if (_cal_ipc_marshal_int((pevent->range_type),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[26]) )
- {
- if (_cal_ipc_marshal_int((pevent->until_type),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_marshal_lli((pevent->until_utime),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_marshal_int((pevent->until_year),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_marshal_int((pevent->until_month),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_marshal_int((pevent->until_mday),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[27]) )
- {
- if (_cal_ipc_marshal_int((pevent->count),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[28]) )
- {
- if (_cal_ipc_marshal_int((pevent->interval),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[29]) )
- {
- if (_cal_ipc_marshal_char((pevent->bysecond),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[30]) )
- {
- if (_cal_ipc_marshal_char((pevent->byminute),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[31]) )
- {
- if (_cal_ipc_marshal_char((pevent->byhour),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[32]) )
- {
- if (_cal_ipc_marshal_char((pevent->byday),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[33]) )
- {
- if (_cal_ipc_marshal_char((pevent->bymonthday),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[34]) )
- {
- if (_cal_ipc_marshal_char((pevent->byyearday),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[35]) )
- {
- if (_cal_ipc_marshal_char((pevent->byweekno),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[36]) )
- {
- if (_cal_ipc_marshal_char((pevent->bymonth),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[37]) )
- {
- if (_cal_ipc_marshal_char((pevent->bysetpos),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[38]) )
- {
- if (_cal_ipc_marshal_int((pevent->wkst),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[39]) )
- {
- if (_cal_ipc_marshal_char((pevent->recurrence_id),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[40]) )
- {
- if (_cal_ipc_marshal_char((pevent->rdate),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[41]) )
- {
- if (_cal_ipc_marshal_int((pevent->has_attendee),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[42]) )
- {
- if (_cal_ipc_marshal_int((pevent->has_alarm),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[51]) )
- {
- if (_cal_ipc_marshal_int((pevent->system_type),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
-
- if (_cal_ipc_marshal_long((pevent->updated),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[43]) )
- {
- if (_cal_ipc_marshal_char((pevent->sync_data1),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[44]) )
- {
- if (_cal_ipc_marshal_char((pevent->sync_data2),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[45]) )
- {
- if (_cal_ipc_marshal_char((pevent->sync_data3),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[46]) )
- {
- if (_cal_ipc_marshal_char((pevent->sync_data4),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[47]) )
- {
- if (_cal_ipc_marshal_caltime((pevent->start),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[52]) )
- {
- if (_cal_ipc_marshal_char((pevent->start_tzid),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[48]) )
- {
- if (_cal_ipc_marshal_caltime((pevent->end),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pevent->common.properties_flags[53]) )
- {
- if (_cal_ipc_marshal_char((pevent->end_tzid),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- // !! alarm_list, attendee_list
- // alarm_list
- if (pevent->alarm_list)
- {
- int count = g_list_length(pevent->alarm_list);
- GList *cursor = g_list_first(pevent->alarm_list);
- calendar_record_h alarm_child_record;
-
- if (_cal_ipc_marshal_int(count,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- while (cursor)
- {
- alarm_child_record = (calendar_record_h)cursor->data;
- if (alarm_child_record == NULL)
- {
- cursor = g_list_next(cursor);
- continue;
- }
- if (_cal_ipc_marshal_record(alarm_child_record, ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- cursor = g_list_next(cursor);
- }
- }
- else
- {
- if (_cal_ipc_marshal_int(0,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
-
- if (pevent->attendee_list)
- {
- int count = g_list_length(pevent->attendee_list);
- GList *cursor = g_list_first(pevent->attendee_list);
- calendar_record_h attendee_child_record;
-
- if (_cal_ipc_marshal_int(count,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- while (cursor)
- {
- attendee_child_record = (calendar_record_h)cursor->data;
- if (attendee_child_record == NULL)
- {
- cursor = g_list_next(cursor);
- continue;
- }
- if (_cal_ipc_marshal_record(attendee_child_record, ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- cursor = g_list_next(cursor);
- }
- }
- else
- {
- if (_cal_ipc_marshal_int(0,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
-
- if (pevent->exception_list)
- {
- int count = g_list_length(pevent->exception_list);
- GList *cursor = g_list_first(pevent->exception_list);
- calendar_record_h child_record;
-
- if (_cal_ipc_marshal_int(count,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- while (cursor)
- {
- child_record = (calendar_record_h)cursor->data;
- if (child_record == NULL)
- {
- cursor = g_list_next(cursor);
- continue;
- }
- if (_cal_ipc_marshal_record(child_record, ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- cursor = g_list_next(cursor);
- }
- }
- else
- {
- if (_cal_ipc_marshal_int(0,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
+ cal_event_s* pevent = (cal_event_s*) record;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
+ retv_if(pevent==NULL,CALENDAR_ERROR_NO_DATA);
- if (pevent->extended_list)
- {
- int count = g_list_length(pevent->extended_list);
- GList *cursor = g_list_first(pevent->extended_list);
- calendar_record_h child_record;
+ if (_cal_ipc_marshal_int((pevent->index),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pevent->calendar_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pevent->summary),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pevent->description),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pevent->location),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pevent->categories),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pevent->exdate),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pevent->event_status),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pevent->priority),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pevent->timezone),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pevent->contact_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pevent->busy_status),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pevent->sensitivity),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pevent->meeting_status),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pevent->uid),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pevent->organizer_name),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pevent->organizer_email),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pevent->original_event_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_double((pevent->latitude),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_double((pevent->longitude),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pevent->email_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_lli((pevent->created_time),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pevent->is_deleted),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_lli((pevent->last_mod),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pevent->freq),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pevent->range_type),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_caltime((pevent->until),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pevent->count),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pevent->interval),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pevent->bysecond),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pevent->byminute),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pevent->byhour),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pevent->byday),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pevent->bymonthday),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pevent->byyearday),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pevent->byweekno),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pevent->bymonth),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pevent->bysetpos),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pevent->wkst),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pevent->recurrence_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pevent->rdate),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pevent->has_attendee),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pevent->has_alarm),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pevent->system_type),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_long((pevent->updated),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pevent->sync_data1),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pevent->sync_data2),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pevent->sync_data3),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pevent->sync_data4),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_caltime((pevent->start),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pevent->start_tzid),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_caltime((pevent->end),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pevent->end_tzid),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pevent->is_allday),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- if (_cal_ipc_marshal_int(count,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- while (cursor)
- {
- child_record = (calendar_record_h)cursor->data;
- if (child_record == NULL)
- {
- cursor = g_list_next(cursor);
- continue;
- }
- if (_cal_ipc_marshal_record(child_record, ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- cursor = g_list_next(cursor);
- }
- }
- else
- {
- if (_cal_ipc_marshal_int(0,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
+ if (CALENDAR_ERROR_NONE != _cal_ipc_marshal_list((calendar_list_h)pevent->alarm_list, ipc_data)) {
+ ERR("_cal_ipc_marshal_list fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (CALENDAR_ERROR_NONE != _cal_ipc_marshal_list((calendar_list_h)pevent->attendee_list, ipc_data)) {
+ ERR("_cal_ipc_marshal_list fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (CALENDAR_ERROR_NONE != _cal_ipc_marshal_list((calendar_list_h)pevent->exception_list, ipc_data)) {
+ ERR("_cal_ipc_marshal_list fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (CALENDAR_ERROR_NONE != _cal_ipc_marshal_list((calendar_list_h)pevent->extended_list, ipc_data)) {
+ ERR("_cal_ipc_marshal_list fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_ipc_marshal_event_get_primary_id(const calendar_record_h record, unsigned int *property_id, int *id)
{
- *property_id = CAL_PROPERTY_EVENT_ID;
- return calendar_record_get_int(record, *property_id, id );
+ *property_id = CAL_PROPERTY_EVENT_ID;
+ return calendar_record_get_int(record, *property_id, id );
}
static int __cal_ipc_marshal_extended_get_primary_id(const calendar_record_h record, unsigned int *property_id, int *id);
cal_ipc_marshal_record_plugin_cb_s _cal_ipc_record_extended_plugin_cb = {
- .unmarshal_record = __cal_ipc_unmarshal_extended,
- .marshal_record = __cal_ipc_marshal_extended,
- .get_primary_id = __cal_ipc_marshal_extended_get_primary_id
+ .unmarshal_record = __cal_ipc_unmarshal_extended,
+ .marshal_record = __cal_ipc_marshal_extended,
+ .get_primary_id = __cal_ipc_marshal_extended_get_primary_id
};
static int __cal_ipc_unmarshal_extended(pims_ipc_data_h ipc_data, calendar_record_h record)
{
- cal_extended_s* pextended = NULL;
- bool bpropertyflag = false;
+ cal_extended_s* pextended = NULL;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
+ retv_if(record==NULL,CALENDAR_ERROR_NO_DATA);
- retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
- retv_if(record==NULL,CALENDAR_ERROR_NO_DATA);
+ pextended = (cal_extended_s*) record;
- pextended = (cal_extended_s*) record;
+ if (_cal_ipc_unmarshal_int(ipc_data,&pextended->id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pextended->record_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pextended->record_type) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pextended->key) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pextended->value) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- if (pextended->common.properties_max_count > 0)
- {
- bpropertyflag = true;
- }
- // read only or primary/secondary key
- if (_cal_ipc_unmarshal_int(ipc_data,&pextended->id) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pextended->common.properties_flags[1]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pextended->record_id) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pextended->common.properties_flags[2]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pextended->record_type) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pextended->common.properties_flags[3]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pextended->key) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pextended->common.properties_flags[4]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pextended->value) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
-
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_ipc_marshal_extended(const calendar_record_h record, pims_ipc_data_h ipc_data)
{
- cal_extended_s* pextended = (cal_extended_s*) record;
- bool bpropertyflag = false;
- retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
- retv_if(pextended==NULL,CALENDAR_ERROR_NO_DATA);
+ cal_extended_s* pextended = (cal_extended_s*) record;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
+ retv_if(pextended==NULL,CALENDAR_ERROR_NO_DATA);
- if (_cal_ipc_marshal_record_common(&(pextended->common),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (pextended->common.properties_max_count > 0)
- {
- bpropertyflag = true;
- }
- // read only or primary/secondary key
- if (_cal_ipc_marshal_int((pextended->id),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pextended->common.properties_flags[1]) )
- {
- if (_cal_ipc_marshal_int((pextended->record_id),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pextended->common.properties_flags[2]) )
- {
- if (_cal_ipc_marshal_int((pextended->record_type),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pextended->common.properties_flags[3]) )
- {
- if (_cal_ipc_marshal_char((pextended->key),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pextended->common.properties_flags[4]) )
- {
- if (_cal_ipc_marshal_char((pextended->value),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
+ if (_cal_ipc_marshal_int((pextended->id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pextended->record_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pextended->record_type),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pextended->key),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pextended->value),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_ipc_marshal_extended_get_primary_id(const calendar_record_h record, unsigned int *property_id, int *id)
{
- *property_id = CAL_PROPERTY_EXTENDED_ID;
- return calendar_record_get_int(record, *property_id, id );
+ *property_id = CAL_PROPERTY_EXTENDED_ID;
+ return calendar_record_get_int(record, *property_id, id );
}
static int __cal_ipc_marshal_instance_allday(const calendar_record_h record, pims_ipc_data_h ipc_data);
cal_ipc_marshal_record_plugin_cb_s _cal_ipc_record_instance_allday_plugin_cb = {
- .unmarshal_record = __cal_ipc_unmarshal_instance_allday,
- .marshal_record = __cal_ipc_marshal_instance_allday,
- .get_primary_id = NULL
+ .unmarshal_record = __cal_ipc_unmarshal_instance_allday,
+ .marshal_record = __cal_ipc_marshal_instance_allday,
+ .get_primary_id = NULL
};
static int __cal_ipc_unmarshal_instance_allday(pims_ipc_data_h ipc_data, calendar_record_h record)
{
- bool bpropertyflag = false;
+ cal_instance_allday_s* pinstanceallday = NULL;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
+ retv_if(record==NULL,CALENDAR_ERROR_NO_DATA);
- cal_instance_allday_s* pinstanceallday = NULL;
- retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
- retv_if(record==NULL,CALENDAR_ERROR_NO_DATA);
+ pinstanceallday = (cal_instance_allday_s*) record;
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->event_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->calendar_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_caltime(ipc_data,&pinstanceallday->start) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_caltime(ipc_data,&pinstanceallday->end) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstanceallday->summary) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstanceallday->description) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstanceallday->location) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->busy_status) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->event_status) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->priority) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->sensitivity) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->has_rrule) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_double(ipc_data,&pinstanceallday->latitude) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_double(ipc_data,&pinstanceallday->longitude) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->has_alarm) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->original_event_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_lli(ipc_data,&pinstanceallday->last_mod) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstanceallday->sync_data1) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->is_allday) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- pinstanceallday = (cal_instance_allday_s*) record;
-
- if (pinstanceallday->common.properties_max_count > 0)
- {
- bpropertyflag = true;
- }
-
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[0]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->event_id) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[5]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->calendar_id) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[1]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->dtstart_type) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->dtstart_year) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->dtstart_month) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->dtstart_mday) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[2]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->dtend_type) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->dtend_year) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->dtend_month) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->dtend_mday) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[3]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pinstanceallday->summary) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[6]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pinstanceallday->description) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[4]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pinstanceallday->location) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[7]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->busy_status) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[8]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->event_status) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[9]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->priority) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[10]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->sensitivity) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[11]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->has_rrule) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[12]) )
- {
- if (_cal_ipc_unmarshal_double(ipc_data,&pinstanceallday->latitude) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[13]) )
- {
- if (_cal_ipc_unmarshal_double(ipc_data,&pinstanceallday->longitude) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[14]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->has_alarm) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[15]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->original_event_id) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[16]) )
- {
- if (_cal_ipc_unmarshal_lli(ipc_data,&pinstanceallday->last_mod) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
-
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_ipc_marshal_instance_allday(const calendar_record_h record, pims_ipc_data_h ipc_data)
{
- cal_instance_allday_s* pinstanceallday = (cal_instance_allday_s*) record;
- bool bpropertyflag = false;
-
- retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
- retv_if(pinstanceallday==NULL,CALENDAR_ERROR_NO_DATA);
+ cal_instance_allday_s* pinstanceallday = (cal_instance_allday_s*) record;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
+ retv_if(pinstanceallday==NULL,CALENDAR_ERROR_NO_DATA);
- if (_cal_ipc_marshal_record_common(&(pinstanceallday->common),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (pinstanceallday->common.properties_max_count > 0)
- {
- bpropertyflag = true;
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[0]) )
- {
- if (_cal_ipc_marshal_int((pinstanceallday->event_id),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[5]) )
- {
- if (_cal_ipc_marshal_int((pinstanceallday->calendar_id),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[1]) )
- {
- if (_cal_ipc_marshal_int((pinstanceallday->dtstart_type),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_marshal_int((pinstanceallday->dtstart_year),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_marshal_int((pinstanceallday->dtstart_month),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_marshal_int((pinstanceallday->dtstart_mday),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[2]) )
- {
- if (_cal_ipc_marshal_int((pinstanceallday->dtend_type),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_marshal_int((pinstanceallday->dtend_year),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_marshal_int((pinstanceallday->dtend_month),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_marshal_int((pinstanceallday->dtend_mday),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[3]) )
- {
- if (_cal_ipc_marshal_char((pinstanceallday->summary),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[6]) )
- {
- if (_cal_ipc_marshal_char((pinstanceallday->description),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[4]) )
- {
- if (_cal_ipc_marshal_char((pinstanceallday->location),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[7]) )
- {
- if (_cal_ipc_marshal_int((pinstanceallday->busy_status),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[8]) )
- {
- if (_cal_ipc_marshal_int((pinstanceallday->event_status),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[9]) )
- {
- if (_cal_ipc_marshal_int((pinstanceallday->priority),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[10]) )
- {
- if (_cal_ipc_marshal_int((pinstanceallday->sensitivity),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[11]) )
- {
- if (_cal_ipc_marshal_int((pinstanceallday->has_rrule),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[12]) )
- {
- if (_cal_ipc_marshal_double((pinstanceallday->latitude),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[13]) )
- {
- if (_cal_ipc_marshal_double((pinstanceallday->longitude),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[14]) )
- {
- if (_cal_ipc_marshal_int((pinstanceallday->has_alarm),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[15]) )
- {
- if (_cal_ipc_marshal_int((pinstanceallday->original_event_id),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstanceallday->common.properties_flags[16]) )
- {
- if (_cal_ipc_marshal_lli((pinstanceallday->last_mod),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
+ if (_cal_ipc_marshal_int((pinstanceallday->event_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstanceallday->calendar_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_caltime((pinstanceallday->start),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_caltime((pinstanceallday->end),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstanceallday->summary),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstanceallday->description),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstanceallday->location),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstanceallday->busy_status),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstanceallday->event_status),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstanceallday->priority),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstanceallday->sensitivity),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstanceallday->has_rrule),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_double((pinstanceallday->latitude),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_double((pinstanceallday->longitude),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstanceallday->has_alarm),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstanceallday->original_event_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_lli((pinstanceallday->last_mod),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstanceallday->sync_data1),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstanceallday->is_allday),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
--- /dev/null
+/*
+ * Calendar Service
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "cal_internal.h"
+#include "cal_ipc_marshal.h"
+#include "cal_view.h"
+
+static int __cal_ipc_unmarshal_instance_allday_extended(pims_ipc_data_h ipc_data, calendar_record_h record);
+static int __cal_ipc_marshal_instance_allday_extended(const calendar_record_h record, pims_ipc_data_h ipc_data);
+
+cal_ipc_marshal_record_plugin_cb_s _cal_ipc_record_instance_allday_extended_plugin_cb = {
+ .unmarshal_record = __cal_ipc_unmarshal_instance_allday_extended,
+ .marshal_record = __cal_ipc_marshal_instance_allday_extended,
+ .get_primary_id = NULL
+};
+
+static int __cal_ipc_unmarshal_instance_allday_extended(pims_ipc_data_h ipc_data, calendar_record_h record)
+{
+ cal_instance_allday_extended_s* pinstanceallday = NULL;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
+ retv_if(record==NULL,CALENDAR_ERROR_NO_DATA);
+
+ pinstanceallday = (cal_instance_allday_extended_s*) record;
+
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->event_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->calendar_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_caltime(ipc_data,&pinstanceallday->start) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_caltime(ipc_data,&pinstanceallday->end) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstanceallday->summary) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstanceallday->description) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstanceallday->location) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->busy_status) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->event_status) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->priority) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->sensitivity) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->has_rrule) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_double(ipc_data,&pinstanceallday->latitude) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_double(ipc_data,&pinstanceallday->longitude) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->has_alarm) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->original_event_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_lli(ipc_data,&pinstanceallday->last_mod) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstanceallday->sync_data1) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstanceallday->organizer_name) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstanceallday->categories) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->has_attendee) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstanceallday->sync_data2) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstanceallday->sync_data3) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstanceallday->sync_data4) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstanceallday->is_allday) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_ipc_marshal_instance_allday_extended(const calendar_record_h record, pims_ipc_data_h ipc_data)
+{
+ cal_instance_allday_extended_s* pinstanceallday = (cal_instance_allday_extended_s*) record;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
+ retv_if(pinstanceallday==NULL,CALENDAR_ERROR_NO_DATA);
+
+ if (_cal_ipc_marshal_int((pinstanceallday->event_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstanceallday->calendar_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_caltime((pinstanceallday->start),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_caltime((pinstanceallday->end),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstanceallday->summary),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstanceallday->description),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstanceallday->location),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstanceallday->busy_status),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstanceallday->event_status),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstanceallday->priority),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstanceallday->sensitivity),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstanceallday->has_rrule),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_double((pinstanceallday->latitude),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_double((pinstanceallday->longitude),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstanceallday->has_alarm),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstanceallday->original_event_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_lli((pinstanceallday->last_mod),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstanceallday->sync_data1),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstanceallday->organizer_name),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstanceallday->categories),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstanceallday->has_attendee),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstanceallday->sync_data2),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstanceallday->sync_data3),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstanceallday->sync_data4),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstanceallday->is_allday),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
static int __cal_ipc_marshal_instance_normal(const calendar_record_h record, pims_ipc_data_h ipc_data);
cal_ipc_marshal_record_plugin_cb_s _cal_ipc_record_instance_normal_plugin_cb = {
- .unmarshal_record = __cal_ipc_unmarshal_instance_normal,
- .marshal_record = __cal_ipc_marshal_instance_normal,
- .get_primary_id = NULL
+ .unmarshal_record = __cal_ipc_unmarshal_instance_normal,
+ .marshal_record = __cal_ipc_marshal_instance_normal,
+ .get_primary_id = NULL
};
static int __cal_ipc_unmarshal_instance_normal(pims_ipc_data_h ipc_data, calendar_record_h record)
{
- bool bpropertyflag = false;
+ cal_instance_normal_s* pinstancenormal = NULL;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
+ retv_if(record==NULL,CALENDAR_ERROR_NO_DATA);
- cal_instance_normal_s* pinstancenormal = NULL;
- retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
- retv_if(record==NULL,CALENDAR_ERROR_NO_DATA);
+ pinstancenormal = (cal_instance_normal_s*) record;
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->event_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->calendar_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_caltime(ipc_data,&pinstancenormal->start) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_caltime(ipc_data,&pinstancenormal->end) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstancenormal->summary) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstancenormal->description) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstancenormal->location) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->busy_status) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->event_status) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->priority) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->sensitivity) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->has_rrule) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_double(ipc_data,&pinstancenormal->latitude) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_double(ipc_data,&pinstancenormal->longitude) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->has_alarm) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->original_event_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_lli(ipc_data,&pinstancenormal->last_mod) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstancenormal->sync_data1) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- pinstancenormal = (cal_instance_normal_s*) record;
-
- if (pinstancenormal->common.properties_max_count > 0)
- {
- bpropertyflag = true;
- }
-
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[0]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->event_id) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[5]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->calendar_id) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[1]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->dtstart_type) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_unmarshal_lli(ipc_data,&pinstancenormal->dtstart_utime) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[2]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->dtend_type) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_unmarshal_lli(ipc_data,&pinstancenormal->dtend_utime) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[3]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pinstancenormal->summary) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[6]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pinstancenormal->description) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[4]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pinstancenormal->location) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[7]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->busy_status) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[8]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->event_status) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[9]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->priority) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[10]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->sensitivity) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[11]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->has_rrule) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[12]) )
- {
- if (_cal_ipc_unmarshal_double(ipc_data,&pinstancenormal->latitude) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[13]) )
- {
- if (_cal_ipc_unmarshal_double(ipc_data,&pinstancenormal->longitude) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[14]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->has_alarm) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[15]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->original_event_id) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[16]) )
- {
- if (_cal_ipc_unmarshal_lli(ipc_data,&pinstancenormal->last_mod) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
-
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_ipc_marshal_instance_normal(const calendar_record_h record, pims_ipc_data_h ipc_data)
{
- cal_instance_normal_s* pinstancenormal = (cal_instance_normal_s*) record;
- bool bpropertyflag = false;
-
- retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
- retv_if(pinstancenormal==NULL,CALENDAR_ERROR_NO_DATA);
-
- if (_cal_ipc_marshal_record_common(&(pinstancenormal->common),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (pinstancenormal->common.properties_max_count > 0)
- {
- bpropertyflag = true;
- }
+ cal_instance_normal_s* pinstancenormal = (cal_instance_normal_s*) record;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
+ retv_if(pinstancenormal==NULL,CALENDAR_ERROR_NO_DATA);
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[0]) )
- {
- if (_cal_ipc_marshal_int((pinstancenormal->event_id),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[5]) )
- {
- if (_cal_ipc_marshal_int((pinstancenormal->calendar_id),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[1]) )
- {
- if (_cal_ipc_marshal_int((pinstancenormal->dtstart_type),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_marshal_lli((pinstancenormal->dtstart_utime),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[2]) )
- {
- if (_cal_ipc_marshal_int((pinstancenormal->dtend_type),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_marshal_lli((pinstancenormal->dtend_utime),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[3]) )
- {
- if (_cal_ipc_marshal_char((pinstancenormal->summary),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[6]) )
- {
- if (_cal_ipc_marshal_char((pinstancenormal->description),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[4]) )
- {
- if (_cal_ipc_marshal_char((pinstancenormal->location),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[7]) )
- {
- if (_cal_ipc_marshal_int((pinstancenormal->busy_status),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[8]) )
- {
- if (_cal_ipc_marshal_int((pinstancenormal->event_status),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[9]) )
- {
- if (_cal_ipc_marshal_int((pinstancenormal->priority),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[10]) )
- {
- if (_cal_ipc_marshal_int((pinstancenormal->sensitivity),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[11]) )
- {
- if (_cal_ipc_marshal_int((pinstancenormal->has_rrule),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[12]) )
- {
- if (_cal_ipc_marshal_double((pinstancenormal->latitude),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[13]) )
- {
- if (_cal_ipc_marshal_double((pinstancenormal->longitude),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[14]) )
- {
- if (_cal_ipc_marshal_int((pinstancenormal->has_alarm),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[15]) )
- {
- if (_cal_ipc_marshal_int((pinstancenormal->original_event_id),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(pinstancenormal->common.properties_flags[16]) )
- {
- if (_cal_ipc_marshal_lli((pinstancenormal->last_mod),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
+ if (_cal_ipc_marshal_int((pinstancenormal->event_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstancenormal->calendar_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_caltime((pinstancenormal->start),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_caltime((pinstancenormal->end),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstancenormal->summary),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstancenormal->description),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstancenormal->location),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstancenormal->busy_status),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstancenormal->event_status),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstancenormal->priority),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstancenormal->sensitivity),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstancenormal->has_rrule),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_double((pinstancenormal->latitude),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_double((pinstancenormal->longitude),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstancenormal->has_alarm),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstancenormal->original_event_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_lli((pinstancenormal->last_mod),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstancenormal->sync_data1),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
--- /dev/null
+/*
+ * Calendar Service
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "cal_internal.h"
+#include "cal_ipc_marshal.h"
+#include "cal_view.h"
+
+static int __cal_ipc_unmarshal_instance_normal_extended(pims_ipc_data_h ipc_data, calendar_record_h record);
+static int __cal_ipc_marshal_instance_normal_extended(const calendar_record_h record, pims_ipc_data_h ipc_data);
+
+cal_ipc_marshal_record_plugin_cb_s _cal_ipc_record_instance_normal_extended_plugin_cb = {
+ .unmarshal_record = __cal_ipc_unmarshal_instance_normal_extended,
+ .marshal_record = __cal_ipc_marshal_instance_normal_extended,
+ .get_primary_id = NULL
+};
+
+static int __cal_ipc_unmarshal_instance_normal_extended(pims_ipc_data_h ipc_data, calendar_record_h record)
+{
+ cal_instance_normal_extended_s* pinstancenormal = NULL;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
+ retv_if(record==NULL,CALENDAR_ERROR_NO_DATA);
+
+ pinstancenormal = (cal_instance_normal_extended_s*) record;
+
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->event_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->calendar_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_caltime(ipc_data,&pinstancenormal->start) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_caltime(ipc_data,&pinstancenormal->end) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstancenormal->summary) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstancenormal->description) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstancenormal->location) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->busy_status) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->event_status) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->priority) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->sensitivity) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->has_rrule) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_double(ipc_data,&pinstancenormal->latitude) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_double(ipc_data,&pinstancenormal->longitude) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->has_alarm) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->original_event_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_lli(ipc_data,&pinstancenormal->last_mod) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstancenormal->sync_data1) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstancenormal->organizer_name) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstancenormal->categories) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pinstancenormal->has_attendee) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstancenormal->sync_data2) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstancenormal->sync_data3) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&pinstancenormal->sync_data4) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_ipc_marshal_instance_normal_extended(const calendar_record_h record, pims_ipc_data_h ipc_data)
+{
+ cal_instance_normal_extended_s* pinstancenormal = (cal_instance_normal_extended_s*) record;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
+ retv_if(pinstancenormal==NULL,CALENDAR_ERROR_NO_DATA);
+
+ if (_cal_ipc_marshal_int((pinstancenormal->event_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstancenormal->calendar_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_caltime((pinstancenormal->start),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_caltime((pinstancenormal->end),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstancenormal->summary),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstancenormal->description),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstancenormal->location),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstancenormal->busy_status),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstancenormal->event_status),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstancenormal->priority),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstancenormal->sensitivity),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstancenormal->has_rrule),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_double((pinstancenormal->latitude),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_double((pinstancenormal->longitude),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstancenormal->has_alarm),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstancenormal->original_event_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_lli((pinstancenormal->last_mod),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstancenormal->sync_data1),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstancenormal->organizer_name),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstancenormal->categories),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pinstancenormal->has_attendee),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstancenormal->sync_data2),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstancenormal->sync_data3),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((pinstancenormal->sync_data4),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
static int __cal_ipc_marshal_search(const calendar_record_h record, pims_ipc_data_h ipc_data);
cal_ipc_marshal_record_plugin_cb_s _cal_ipc_record_search_plugin_cb = {
- .unmarshal_record = __cal_ipc_unmarshal_search,
- .marshal_record = __cal_ipc_marshal_search,
- .get_primary_id = NULL
+ .unmarshal_record = __cal_ipc_unmarshal_search,
+ .marshal_record = __cal_ipc_marshal_search,
+ .get_primary_id = NULL
};
static int __cal_ipc_unmarshal_search_value(pims_ipc_data_h ipc_data, cal_search_value_s* pvalue);
static int __cal_ipc_unmarshal_search(pims_ipc_data_h ipc_data, calendar_record_h record)
{
- cal_search_s* psearch = NULL;
- retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
- retv_if(record==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
-
- psearch = (cal_search_s*) record;
-
- int count = 0,i = 0;
- if (_cal_ipc_unmarshal_int(ipc_data,&count) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- for(i=0;i<count;i++)
- {
- cal_search_value_s* value_data = NULL;
- value_data = calloc(1, sizeof(cal_search_value_s));
- if (value_data == NULL)
- {
- ERR("calloc fail");
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
-
- if (__cal_ipc_unmarshal_search_value(ipc_data, value_data) != CALENDAR_ERROR_NONE)
- {
- CAL_FREE(value_data);
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- psearch->values = g_slist_append(psearch->values, value_data);
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_search_s* psearch = NULL;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(record==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+
+ psearch = (cal_search_s*) record;
+
+ int count = 0,i = 0;
+ if (_cal_ipc_unmarshal_int(ipc_data,&count) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ for(i=0;i<count;i++) {
+ cal_search_value_s* value_data = NULL;
+ value_data = calloc(1, sizeof(cal_search_value_s));
+ if (value_data == NULL) {
+ ERR("calloc fail");
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+
+ if (__cal_ipc_unmarshal_search_value(ipc_data, value_data) != CALENDAR_ERROR_NONE) {
+ CAL_FREE(value_data);
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ psearch->values = g_slist_append(psearch->values, value_data);
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_ipc_marshal_search(const calendar_record_h record, pims_ipc_data_h ipc_data)
{
- cal_search_s* psearch = (cal_search_s*) record;
- retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
- retv_if(psearch==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
-
- if (_cal_ipc_marshal_record_common(&(psearch->common),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- if (psearch->values)
- {
- int count = g_slist_length(psearch->values);
- GSList *cursor = psearch->values;
- cal_search_value_s* value_data;
-
- if (_cal_ipc_marshal_int(count,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- while (cursor)
- {
- value_data = (cal_search_value_s *)cursor->data;
- if (value_data == NULL)
- {
- cursor = g_slist_next(cursor);
- continue;
- }
- if (__cal_ipc_marshal_search_value((const cal_search_value_s*)value_data, ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- cursor = g_slist_next(cursor);
- }
-
- }
- else
- {
- if (_cal_ipc_marshal_int(0,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
-
- return CALENDAR_ERROR_NONE;
+ cal_search_s* psearch = (cal_search_s*) record;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(psearch==NULL,CALENDAR_ERROR_INVALID_PARAMETER);
+
+ if (psearch->values) {
+ int count = g_slist_length(psearch->values);
+ GSList *cursor = psearch->values;
+ cal_search_value_s* value_data;
+
+ if (_cal_ipc_marshal_int(count,ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ while (cursor) {
+ value_data = (cal_search_value_s *)cursor->data;
+ if (value_data == NULL) {
+ cursor = g_slist_next(cursor);
+ continue;
+ }
+ if (__cal_ipc_marshal_search_value((const cal_search_value_s*)value_data, ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ cursor = g_slist_next(cursor);
+ }
+
+ }
+ else {
+ if (_cal_ipc_marshal_int(0,ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_ipc_unmarshal_search_value(pims_ipc_data_h ipc_data, cal_search_value_s* pvalue)
{
- if (_cal_ipc_unmarshal_int(ipc_data,&pvalue->property_id) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- if (CAL_PROPERTY_CHECK_DATA_TYPE(pvalue->property_id, CAL_PROPERTY_DATA_TYPE_STR) == true)
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&pvalue->value.s) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(pvalue->property_id, CAL_PROPERTY_DATA_TYPE_INT) == true)
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&pvalue->value.i) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(pvalue->property_id, CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
- {
- if (_cal_ipc_unmarshal_double(ipc_data,&pvalue->value.d) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(pvalue->property_id, CAL_PROPERTY_DATA_TYPE_LLI) == true)
- {
- if (_cal_ipc_unmarshal_lli(ipc_data,&pvalue->value.lli) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(pvalue->property_id, CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
- {
- if (_cal_ipc_unmarshal_caltime(ipc_data,&pvalue->value.caltime) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",pvalue->property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- return CALENDAR_ERROR_NONE;
+ if (_cal_ipc_unmarshal_int(ipc_data,&pvalue->property_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (CAL_PROPERTY_CHECK_DATA_TYPE(pvalue->property_id, CAL_PROPERTY_DATA_TYPE_STR) == true) {
+ if (_cal_ipc_unmarshal_char(ipc_data,&pvalue->value.s) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(pvalue->property_id, CAL_PROPERTY_DATA_TYPE_INT) == true) {
+ if (_cal_ipc_unmarshal_int(ipc_data,&pvalue->value.i) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(pvalue->property_id, CAL_PROPERTY_DATA_TYPE_DOUBLE) == true) {
+ if (_cal_ipc_unmarshal_double(ipc_data,&pvalue->value.d) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(pvalue->property_id, CAL_PROPERTY_DATA_TYPE_LLI) == true) {
+ if (_cal_ipc_unmarshal_lli(ipc_data,&pvalue->value.lli) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(pvalue->property_id, CAL_PROPERTY_DATA_TYPE_CALTIME) == true) {
+ if (_cal_ipc_unmarshal_caltime(ipc_data,&pvalue->value.caltime) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ else {
+ ERR("invalid parameter (property:%d)",pvalue->property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
}
static int __cal_ipc_marshal_search_value(const cal_search_value_s* pvalue, pims_ipc_data_h ipc_data)
{
- if (_cal_ipc_marshal_int(pvalue->property_id,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (CAL_PROPERTY_CHECK_DATA_TYPE(pvalue->property_id, CAL_PROPERTY_DATA_TYPE_STR) == true)
- {
- if (_cal_ipc_marshal_char(pvalue->value.s,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(pvalue->property_id, CAL_PROPERTY_DATA_TYPE_INT) == true)
- {
- if (_cal_ipc_marshal_int(pvalue->value.i,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(pvalue->property_id, CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
- {
- if (_cal_ipc_marshal_double(pvalue->value.d,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(pvalue->property_id, CAL_PROPERTY_DATA_TYPE_LLI) == true)
- {
- if (_cal_ipc_marshal_lli(pvalue->value.lli,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(pvalue->property_id, CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
- {
- if (_cal_ipc_marshal_caltime(pvalue->value.caltime,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
- ASSERT_NOT_REACHED("invalid parameter (property:%d)",pvalue->property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- return CALENDAR_ERROR_NONE;
+ if (_cal_ipc_marshal_int(pvalue->property_id,ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (CAL_PROPERTY_CHECK_DATA_TYPE(pvalue->property_id, CAL_PROPERTY_DATA_TYPE_STR) == true) {
+ if (_cal_ipc_marshal_char(pvalue->value.s,ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(pvalue->property_id, CAL_PROPERTY_DATA_TYPE_INT) == true) {
+ if (_cal_ipc_marshal_int(pvalue->value.i,ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(pvalue->property_id, CAL_PROPERTY_DATA_TYPE_DOUBLE) == true) {
+ if (_cal_ipc_marshal_double(pvalue->value.d,ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(pvalue->property_id, CAL_PROPERTY_DATA_TYPE_LLI) == true) {
+ if (_cal_ipc_marshal_lli(pvalue->value.lli,ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(pvalue->property_id, CAL_PROPERTY_DATA_TYPE_CALTIME) == true) {
+ if (_cal_ipc_marshal_caltime(pvalue->value.caltime,ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ else {
+ ERR("invalid parameter (property:%d)",pvalue->property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_ipc_marshal_timezone_get_primary_id(const calendar_record_h record, unsigned int *property_id, int *id);
cal_ipc_marshal_record_plugin_cb_s _cal_ipc_record_timezone_plugin_cb = {
- .unmarshal_record = __cal_ipc_unmarshal_timezone,
- .marshal_record = __cal_ipc_marshal_timezone,
- .get_primary_id = __cal_ipc_marshal_timezone_get_primary_id
+ .unmarshal_record = __cal_ipc_unmarshal_timezone,
+ .marshal_record = __cal_ipc_marshal_timezone,
+ .get_primary_id = __cal_ipc_marshal_timezone_get_primary_id
};
static int __cal_ipc_unmarshal_timezone(pims_ipc_data_h ipc_data, calendar_record_h record)
{
- cal_timezone_s* ptimezone = NULL;
- bool bpropertyflag = false;
+ cal_timezone_s* ptimezone = NULL;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
+ retv_if(record==NULL,CALENDAR_ERROR_NO_DATA);
- retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
- retv_if(record==NULL,CALENDAR_ERROR_NO_DATA);
+ ptimezone = (cal_timezone_s*) record;
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->index) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->tz_offset_from_gmt) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&ptimezone->standard_name) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->std_start_month) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->std_start_position_of_week) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->std_start_day) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->std_start_hour) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->standard_bias) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&ptimezone->day_light_name) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->day_light_start_month) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->day_light_start_position_of_week) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->day_light_start_day) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->day_light_start_hour) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->day_light_bias) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->calendar_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- ptimezone = (cal_timezone_s*) record;
-
- if (ptimezone->common.properties_max_count > 0)
- {
- bpropertyflag = true;
- }
- // read only or primary/secondary key
- if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->index) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[1]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->tz_offset_from_gmt) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[2]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&ptimezone->standard_name) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[3]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->std_start_month) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[4]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->std_start_position_of_week) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[5]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->std_start_day) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[6]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->std_start_hour) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[7]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->standard_bias) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[8]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&ptimezone->day_light_name) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[9]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->day_light_start_month) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[10]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->day_light_start_position_of_week) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[11]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->day_light_start_day) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[12]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->day_light_start_hour) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[13]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->day_light_bias) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[14]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&ptimezone->calendar_id) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
-
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_ipc_marshal_timezone(const calendar_record_h record, pims_ipc_data_h ipc_data)
{
- cal_timezone_s* ptimezone = (cal_timezone_s*) record;
- bool bpropertyflag = false;
- retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
- retv_if(ptimezone==NULL,CALENDAR_ERROR_NO_DATA);
+ cal_timezone_s* ptimezone = (cal_timezone_s*) record;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
+ retv_if(ptimezone==NULL,CALENDAR_ERROR_NO_DATA);
- if (_cal_ipc_marshal_record_common(&(ptimezone->common),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (ptimezone->common.properties_max_count > 0)
- {
- bpropertyflag = true;
- }
- // read only or primary/secondary key
- if (_cal_ipc_marshal_int((ptimezone->index),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[1]) )
- {
- if (_cal_ipc_marshal_int((ptimezone->tz_offset_from_gmt),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[2]) )
- {
- if (_cal_ipc_marshal_char((ptimezone->standard_name),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[3]) )
- {
- if (_cal_ipc_marshal_int((ptimezone->std_start_month),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[4]) )
- {
- if (_cal_ipc_marshal_int((ptimezone->std_start_position_of_week),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[5]) )
- {
- if (_cal_ipc_marshal_int((ptimezone->std_start_day),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[6]) )
- {
- if (_cal_ipc_marshal_int((ptimezone->std_start_hour),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[7]) )
- {
- if (_cal_ipc_marshal_int((ptimezone->standard_bias),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[8]) )
- {
- if (_cal_ipc_marshal_char((ptimezone->day_light_name),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[9]) )
- {
- if (_cal_ipc_marshal_int((ptimezone->day_light_start_month),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[10]) )
- {
- if (_cal_ipc_marshal_int((ptimezone->day_light_start_position_of_week),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[11]) )
- {
- if (_cal_ipc_marshal_int((ptimezone->day_light_start_day),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[12]) )
- {
- if (_cal_ipc_marshal_int((ptimezone->day_light_start_hour),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[13]) )
- {
- if (_cal_ipc_marshal_int((ptimezone->day_light_bias),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptimezone->common.properties_flags[14]) )
- {
- if (_cal_ipc_marshal_int((ptimezone->calendar_id),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
+ if (_cal_ipc_marshal_int((ptimezone->index),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptimezone->tz_offset_from_gmt),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((ptimezone->standard_name),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptimezone->std_start_month),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptimezone->std_start_position_of_week),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptimezone->std_start_day),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptimezone->std_start_hour),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptimezone->standard_bias),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((ptimezone->day_light_name),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptimezone->day_light_start_month),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptimezone->day_light_start_position_of_week),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptimezone->day_light_start_day),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptimezone->day_light_start_hour),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptimezone->day_light_bias),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptimezone->calendar_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_ipc_marshal_timezone_get_primary_id(const calendar_record_h record, unsigned int *property_id, int *id)
{
- *property_id = CAL_PROPERTY_TIMEZONE_ID;
- return calendar_record_get_int(record, *property_id, id );
+ *property_id = CAL_PROPERTY_TIMEZONE_ID;
+ return calendar_record_get_int(record, *property_id, id );
}
static int __cal_ipc_marshal_todo_get_primary_id(const calendar_record_h record, unsigned int *property_id, int *id);
cal_ipc_marshal_record_plugin_cb_s _cal_ipc_record_todo_plugin_cb = {
- .unmarshal_record = __cal_ipc_unmarshal_todo,
- .marshal_record = __cal_ipc_marshal_todo,
- .get_primary_id = __cal_ipc_marshal_todo_get_primary_id
+ .unmarshal_record = __cal_ipc_unmarshal_todo,
+ .marshal_record = __cal_ipc_marshal_todo,
+ .get_primary_id = __cal_ipc_marshal_todo_get_primary_id
};
static int __cal_ipc_unmarshal_todo(pims_ipc_data_h ipc_data, calendar_record_h record)
{
- cal_todo_s* ptodo = NULL;
- bool bpropertyflag = false;
- retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
- retv_if(record==NULL,CALENDAR_ERROR_NO_DATA);
+ cal_todo_s* ptodo = NULL;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
+ retv_if(record==NULL,CALENDAR_ERROR_NO_DATA);
- ptodo = (cal_todo_s*) record;
+ ptodo = (cal_todo_s*) record;
- if (ptodo->common.properties_max_count > 0)
- {
- bpropertyflag = true;
- }
- // read only or primary/secondary key
- if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->index) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[1]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->calendar_id) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[2]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->summary) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[3]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->description) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[4]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->location) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[5]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->categories) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[6]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,(int*)&ptodo->todo_status) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[7]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,(int*)&ptodo->priority) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[8]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->sensitivity) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[9]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->uid) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[10]) )
- {
- if (_cal_ipc_unmarshal_double(ipc_data,&ptodo->latitude) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[11]) )
- {
- if (_cal_ipc_unmarshal_double(ipc_data,&ptodo->longitude) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[13]) )
- {
- if (_cal_ipc_unmarshal_lli(ipc_data,&ptodo->created_time) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[15]) )
- {
- if (_cal_ipc_unmarshal_lli(ipc_data,&ptodo->completed_time) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[12]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->progress) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[16]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->is_deleted) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[14]) )
- {
- if (_cal_ipc_unmarshal_lli(ipc_data,&ptodo->last_mod) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[17]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->freq) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[18]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->range_type) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[19]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->until_type) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_unmarshal_lli(ipc_data,&ptodo->until_utime) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->until_year) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->until_month) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->until_mday) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[20]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->count) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[21]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->interval) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[22]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->bysecond) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[23]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->byminute) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[24]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->byhour) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[25]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->byday) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[26]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->bymonthday) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[27]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->byyearday) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[28]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->byweekno) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[29]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->bymonth) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[30]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->bysetpos) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[31]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->wkst) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[32]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->has_alarm) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->index) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->calendar_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->summary) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->description) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->location) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->categories) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,(int*)&ptodo->todo_status) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,(int*)&ptodo->priority) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->sensitivity) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->uid) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_double(ipc_data,&ptodo->latitude) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_double(ipc_data,&ptodo->longitude) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_lli(ipc_data,&ptodo->created_time) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_lli(ipc_data,&ptodo->completed_time) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->progress) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->is_deleted) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_lli(ipc_data,&ptodo->last_mod) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->freq) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->range_type) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_caltime(ipc_data,&ptodo->until) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->count) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->interval) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->bysecond) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->byminute) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->byhour) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->byday) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->bymonthday) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->byyearday) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->byweekno) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->bymonth) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->bysetpos) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->wkst) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->has_alarm) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_long(ipc_data,&ptodo->updated) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->sync_data1) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->sync_data2) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->sync_data3) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->sync_data4) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_caltime(ipc_data,&ptodo->start) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->start_tzid) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_caltime(ipc_data,&ptodo->due) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->due_tzid) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->organizer_name) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->organizer_email) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->has_attendee) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->is_allday) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- if (_cal_ipc_unmarshal_long(ipc_data,&ptodo->updated) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
+ if (CALENDAR_ERROR_NONE != _cal_ipc_unmarshal_list(ipc_data, (calendar_list_h *)&ptodo->alarm_list)) {
+ ERR("_cal_ipc_unmarshal_list fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (CALENDAR_ERROR_NONE != _cal_ipc_unmarshal_list(ipc_data, (calendar_list_h *)&ptodo->attendee_list)) {
+ ERR("_cal_ipc_unmarshal_list fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (CALENDAR_ERROR_NONE != _cal_ipc_unmarshal_list(ipc_data, (calendar_list_h *)&ptodo->extended_list)) {
+ ERR("_cal_ipc_unmarshal_list fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[33]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->sync_data1) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[34]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->sync_data2) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[35]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->sync_data3) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[36]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->sync_data4) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[37]) )
- {
- if (_cal_ipc_unmarshal_caltime(ipc_data,&ptodo->start) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[40]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->start_tzid) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[38]) )
- {
- if (_cal_ipc_unmarshal_caltime(ipc_data,&ptodo->due) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[41]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->due_tzid) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[42]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->organizer_name) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[43]) )
- {
- if (_cal_ipc_unmarshal_char(ipc_data,&ptodo->organizer_email) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[44]) )
- {
- if (_cal_ipc_unmarshal_int(ipc_data,&ptodo->has_attendee) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
-
- // !! alarm_list
- int count = 0, i = 0;
- if (_cal_ipc_unmarshal_int(ipc_data,&count) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- for(i=0;i<count;i++)
- {
- calendar_record_h alarm_child_record = NULL;
-
- if (_cal_ipc_unmarshal_record(ipc_data, &alarm_child_record) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- ptodo->alarm_list = g_list_append(ptodo->alarm_list, alarm_child_record);
- }
-
- // attendee_list
- if (_cal_ipc_unmarshal_int(ipc_data,&count) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- for(i=0;i<count;i++)
- {
- calendar_record_h attendee_child_record = NULL;
- if (_cal_ipc_unmarshal_record(ipc_data, &attendee_child_record) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- ptodo->attendee_list = g_list_append(ptodo->attendee_list, attendee_child_record);
- }
-
- //extended
- if (_cal_ipc_unmarshal_int(ipc_data,&count) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- for(i=0;i<count;i++)
- {
- calendar_record_h child_record = NULL;
- if (_cal_ipc_unmarshal_record(ipc_data, &child_record) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- ptodo->extended_list = g_list_append(ptodo->extended_list, child_record);
- }
-
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_ipc_marshal_todo(const calendar_record_h record, pims_ipc_data_h ipc_data)
{
- cal_todo_s* ptodo = (cal_todo_s*)record;
- bool bpropertyflag = false;
- retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
- retv_if(ptodo==NULL,CALENDAR_ERROR_NO_DATA);
-
- if (_cal_ipc_marshal_record_common(&(ptodo->common),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (ptodo->common.properties_max_count > 0)
- {
- bpropertyflag = true;
- }
- // read only or primary/secondary key
- if (_cal_ipc_marshal_int((ptodo->index),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[1]) )
- {
- if (_cal_ipc_marshal_int((ptodo->calendar_id),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[2]) )
- {
- if (_cal_ipc_marshal_char((ptodo->summary),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[3]) )
- {
- if (_cal_ipc_marshal_char((ptodo->description),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[4]) )
- {
- if (_cal_ipc_marshal_char((ptodo->location),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[5]) )
- {
- if (_cal_ipc_marshal_char((ptodo->categories),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[6]) )
- {
- if (_cal_ipc_marshal_int((ptodo->todo_status),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[7]) )
- {
- if (_cal_ipc_marshal_int((ptodo->priority),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[8]) )
- {
- if (_cal_ipc_marshal_int((ptodo->sensitivity),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[9]) )
- {
- if (_cal_ipc_marshal_char((ptodo->uid),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[10]) )
- {
- if (_cal_ipc_marshal_double((ptodo->latitude),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[11]) )
- {
- if (_cal_ipc_marshal_double((ptodo->longitude),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[13]) )
- {
- if (_cal_ipc_marshal_lli((ptodo->created_time),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[15]) )
- {
- if (_cal_ipc_marshal_lli((ptodo->completed_time),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[12]) )
- {
- if (_cal_ipc_marshal_int((ptodo->progress),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[16]) )
- {
- if (_cal_ipc_marshal_int((ptodo->is_deleted),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[14]) )
- {
- if (_cal_ipc_marshal_lli((ptodo->last_mod),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[17]) )
- {
- if (_cal_ipc_marshal_int((ptodo->freq),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[18]) )
- {
- if (_cal_ipc_marshal_int((ptodo->range_type),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[19]) )
- {
- if (_cal_ipc_marshal_int((ptodo->until_type),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_marshal_lli((ptodo->until_utime),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_marshal_int((ptodo->until_year),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_marshal_int((ptodo->until_month),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_marshal_int((ptodo->until_mday),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[20]) )
- {
- if (_cal_ipc_marshal_int((ptodo->count),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[21]) )
- {
- if (_cal_ipc_marshal_int((ptodo->interval),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[22]) )
- {
- if (_cal_ipc_marshal_char((ptodo->bysecond),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[23]) )
- {
- if (_cal_ipc_marshal_char((ptodo->byminute),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[24]) )
- {
- if (_cal_ipc_marshal_char((ptodo->byhour),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[25]) )
- {
- if (_cal_ipc_marshal_char((ptodo->byday),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[26]) )
- {
- if (_cal_ipc_marshal_char((ptodo->bymonthday),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[27]) )
- {
- if (_cal_ipc_marshal_char((ptodo->byyearday),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[28]) )
- {
- if (_cal_ipc_marshal_char((ptodo->byweekno),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[29]) )
- {
- if (_cal_ipc_marshal_char((ptodo->bymonth),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[30]) )
- {
- if (_cal_ipc_marshal_char((ptodo->bysetpos),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[31]) )
- {
- if (_cal_ipc_marshal_int((ptodo->wkst),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[32]) )
- {
- if (_cal_ipc_marshal_int((ptodo->has_alarm),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
-
- if (_cal_ipc_marshal_long((ptodo->updated),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[33]) )
- {
- if (_cal_ipc_marshal_char((ptodo->sync_data1),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[34]) )
- {
- if (_cal_ipc_marshal_char((ptodo->sync_data2),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[35]) )
- {
- if (_cal_ipc_marshal_char((ptodo->sync_data3),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[36]) )
- {
- if (_cal_ipc_marshal_char((ptodo->sync_data4),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[37]) )
- {
- if (_cal_ipc_marshal_caltime((ptodo->start),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[40]) )
- {
- if (_cal_ipc_marshal_char((ptodo->start_tzid),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[38]) )
- {
- if (_cal_ipc_marshal_caltime((ptodo->due),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[41]) )
- {
- if (_cal_ipc_marshal_char((ptodo->due_tzid),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[42]) )
- {
- if (_cal_ipc_marshal_char((ptodo->organizer_name),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[43]) )
- {
- if (_cal_ipc_marshal_char((ptodo->organizer_email),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- if (bpropertyflag == false || CAL_IPC_CHECK_PROPERTIES_FLAG(ptodo->common.properties_flags[44]) )
- {
- if (_cal_ipc_marshal_int((ptodo->has_attendee),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- // !! alarm_list
- if (ptodo->alarm_list)
- {
- int count = g_list_length(ptodo->alarm_list);
- GList *cursor = g_list_first(ptodo->alarm_list);
- calendar_record_h alarm_child_record;
-
- if (_cal_ipc_marshal_int(count,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- while (cursor)
- {
- alarm_child_record = (calendar_record_h)cursor->data;
- if (alarm_child_record == NULL)
- {
- cursor = g_list_next(cursor);
- continue;
- }
- if (_cal_ipc_marshal_record(alarm_child_record, ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- cursor = g_list_next(cursor);
- }
- }
- else
- {
- if (_cal_ipc_marshal_int(0,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
-
- if (ptodo->attendee_list)
- {
- int count = g_list_length(ptodo->attendee_list);
- GList *cursor = g_list_first(ptodo->attendee_list);
- calendar_record_h attendee_child_record;
-
- if (_cal_ipc_marshal_int(count,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- while (cursor)
- {
- attendee_child_record = (calendar_record_h)cursor->data;
- if (attendee_child_record == NULL)
- {
- cursor = g_list_next(cursor);
- continue;
- }
- if (_cal_ipc_marshal_record(attendee_child_record, ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- cursor = g_list_next(cursor);
- }
- }
- else
- {
- if (_cal_ipc_marshal_int(0,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
+ cal_todo_s* ptodo = (cal_todo_s*)record;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
+ retv_if(ptodo==NULL,CALENDAR_ERROR_NO_DATA);
- if (ptodo->extended_list)
- {
- int count = g_list_length(ptodo->extended_list);
- GList *cursor = g_list_first(ptodo->extended_list);
- calendar_record_h child_record;
+ if (_cal_ipc_marshal_int((ptodo->index),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptodo->calendar_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((ptodo->summary),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((ptodo->description),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((ptodo->location),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((ptodo->categories),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptodo->todo_status),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptodo->priority),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptodo->sensitivity),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((ptodo->uid),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_double((ptodo->latitude),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_double((ptodo->longitude),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_lli((ptodo->created_time),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_lli((ptodo->completed_time),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptodo->progress),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptodo->is_deleted),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_lli((ptodo->last_mod),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptodo->freq),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptodo->range_type),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_caltime((ptodo->until),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptodo->count),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptodo->interval),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((ptodo->bysecond),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((ptodo->byminute),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((ptodo->byhour),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((ptodo->byday),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((ptodo->bymonthday),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((ptodo->byyearday),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((ptodo->byweekno),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((ptodo->bymonth),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((ptodo->bysetpos),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptodo->wkst),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptodo->has_alarm),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_long((ptodo->updated),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((ptodo->sync_data1),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((ptodo->sync_data2),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((ptodo->sync_data3),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((ptodo->sync_data4),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_caltime((ptodo->start),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((ptodo->start_tzid),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_caltime((ptodo->due),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((ptodo->due_tzid),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((ptodo->organizer_name),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_char((ptodo->organizer_email),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptodo->has_attendee),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((ptodo->is_allday),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- if (_cal_ipc_marshal_int(count,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- while (cursor)
- {
- child_record = (calendar_record_h)cursor->data;
- if (child_record == NULL)
- {
- cursor = g_list_next(cursor);
- continue;
- }
- if (_cal_ipc_marshal_record(child_record, ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- cursor = g_list_next(cursor);
- }
- }
- else
- {
- if (_cal_ipc_marshal_int(0,ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
+ if (CALENDAR_ERROR_NONE != _cal_ipc_marshal_list((calendar_list_h)ptodo->alarm_list, ipc_data)) {
+ ERR("_cal_ipc_marshal_list fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (CALENDAR_ERROR_NONE != _cal_ipc_marshal_list((calendar_list_h)ptodo->attendee_list, ipc_data)) {
+ ERR("_cal_ipc_marshal_list fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (CALENDAR_ERROR_NONE != _cal_ipc_marshal_list((calendar_list_h)ptodo->extended_list, ipc_data)) {
+ ERR("_cal_ipc_marshal_list fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_ipc_marshal_todo_get_primary_id(const calendar_record_h record, unsigned int *property_id, int *id)
{
- *property_id = CAL_PROPERTY_TODO_ID;
- return calendar_record_get_int(record, *property_id, id );
+ *property_id = CAL_PROPERTY_TODO_ID;
+ return calendar_record_get_int(record, *property_id, id );
}
static int __cal_ipc_marshal_updated_info(const calendar_record_h record, pims_ipc_data_h ipc_data);
cal_ipc_marshal_record_plugin_cb_s _cal_ipc_record_updated_info_plugin_cb = {
- .unmarshal_record = __cal_ipc_unmarshal_updated_info,
- .marshal_record = __cal_ipc_marshal_updated_info,
- .get_primary_id = NULL
+ .unmarshal_record = __cal_ipc_unmarshal_updated_info,
+ .marshal_record = __cal_ipc_marshal_updated_info,
+ .get_primary_id = NULL
};
static int __cal_ipc_unmarshal_updated_info(pims_ipc_data_h ipc_data, calendar_record_h record)
{
- cal_updated_info_s* pupdatedinfo = NULL;
- retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
- retv_if(record==NULL,CALENDAR_ERROR_NO_DATA);
+ cal_updated_info_s* pupdatedinfo = NULL;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
+ retv_if(record==NULL,CALENDAR_ERROR_NO_DATA);
- pupdatedinfo = (cal_updated_info_s*) record;
+ pupdatedinfo = (cal_updated_info_s*) record;
- if (_cal_ipc_unmarshal_int(ipc_data,&pupdatedinfo->type) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_unmarshal_int(ipc_data,&pupdatedinfo->id) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_unmarshal_int(ipc_data,&pupdatedinfo->calendar_id) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_unmarshal_int(ipc_data,&pupdatedinfo->version) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pupdatedinfo->type) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pupdatedinfo->id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pupdatedinfo->calendar_id) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_unmarshal_int(ipc_data,&pupdatedinfo->version) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_ipc_marshal_updated_info(const calendar_record_h record, pims_ipc_data_h ipc_data)
{
- cal_updated_info_s* pupdatedinfo = (cal_updated_info_s*) record;
- retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
- retv_if(pupdatedinfo==NULL,CALENDAR_ERROR_NO_DATA);
+ cal_updated_info_s* pupdatedinfo = (cal_updated_info_s*) record;
+ retv_if(ipc_data==NULL,CALENDAR_ERROR_NO_DATA);
+ retv_if(pupdatedinfo==NULL,CALENDAR_ERROR_NO_DATA);
- if (_cal_ipc_marshal_record_common(&(pupdatedinfo->common),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_marshal_int((pupdatedinfo->type),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_marshal_int((pupdatedinfo->id),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_marshal_int((pupdatedinfo->calendar_id),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (_cal_ipc_marshal_int((pupdatedinfo->version),ipc_data) != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
+ if (_cal_ipc_marshal_int((pupdatedinfo->type),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pupdatedinfo->id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pupdatedinfo->calendar_id),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (_cal_ipc_marshal_int((pupdatedinfo->version),ipc_data) != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
+++ /dev/null
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(dft-calendar C)
-
-SET(TC_SRCS
- ./src/dft_main.c
- ./src/dft_util.c
- )
-
-SET(PREFIX "/usr")
-SET(BINDIR "${PREFIX}/bin")
-SET(OPTDIR "/usr/share/calendar-svc")
-
-SET(LIBNAME calendar-service2)
-
-IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
- SET(CMAKE_BUILD_TYPE "Release")
-ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
-MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
-
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
-LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/api)
-LINK_DIRECTORIES(${CMAKE_SOURCE_DIR})
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(tc_pkgs REQUIRED
- dlog
- glib-2.0
- )
-
-FOREACH(flag ${tc_pkgs_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
-SET(CMAKE_C_FLAGS_RELEASE "-O2")
-
-FIND_PROGRAM(UNAME NAMES uname)
-EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
-IF("${ARCH}" STREQUAL "arm")
- ADD_DEFINITIONS("-DTARGET")
- MESSAGE("add -DTARGET")
-ENDIF("${ARCH}" STREQUAL "arm")
-
-ADD_DEFINITIONS("-DTC_LOG_PRINTF")
-SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed")
-
-ADD_EXECUTABLE(${PROJECT_NAME} ${TC_SRCS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${tc_pkgs_LDFLAGS} ${LIBNAME})
-
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${OPTDIR})
-
+++ /dev/null
-/*
- * Calendar Service
- *
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <calendar2.h>
-
-#include "dft_util.h"
-
-#define MAX_COLS 32768
-
-static void __dft_calendar_help(void)
-{
- printf("usage: dft-calendar path(string) count(int)\n"
- "eg. dft-calendar \"./calendar.txt\" 10\n");
-}
-
-// get type depending on file name.
-static int __dft_get_file_type(char *path)
-{
- char *p, *q = NULL;
- char dl = '/';
-
- q = p = path;
- while (*p)
- {
- if (*p == dl)
- {
- q = p;
- }
- p++;
- }
- if (strstr(q, "event") || strstr(q, "schedule"))
- {
- return CALENDAR_BOOK_TYPE_EVENT;
- }
- else if (strstr(q, "todo") || strstr(q, "task"))
- {
- return CALENDAR_BOOK_TYPE_TODO;
- }
- else
- {
- printf("set default type\n");
- return CALENDAR_BOOK_TYPE_EVENT;
- }
- return -1;
-}
-
-static int __dft_event_set_1(calendar_record_h event, int book_id, char *subject, char *location)
-{
- int ret;
-
- ret = calendar_record_set_int(event, _calendar_event.calendar_book_id, book_id);
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_event.calendar_book_id\n");
- return -1;
- }
- ret = calendar_record_set_str(event, _calendar_event.summary, subject);
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_event.summary\n");
- return -1;
- }
- ret = calendar_record_set_str(event, _calendar_event.location, location);
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_event.location\n");
- return -1;
- }
- return 0;
-}
-
-static int __dft_event_set_2(calendar_record_h event, char *allday, char *sdate, char *stime, char *edate, char *etime)
-{
- int ret;
- int y, m, d;
- calendar_time_s st = {0}, et = {0};
-
- if (!strncmp(allday, "Off", sizeof("Off")))
- {
- st.type = CALENDAR_TIME_UTIME;
- st.time.utime = _convert_to_utime(sdate, stime);
- ret = calendar_record_set_str(event, _calendar_event.start_tzid, "Asia/Seoul");
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_event.start_tzid\n");
- return -1;
- }
- ret = calendar_record_set_caltime(event, _calendar_event.start_time, st);
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_event.start_time\n");
- return -1;
- }
-
- et.type = CALENDAR_TIME_UTIME;
- et.time.utime = _convert_to_utime(edate, etime);
- ret = calendar_record_set_str(event, _calendar_event.end_tzid, "Asia/Seoul");
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_event.end_tzid\n");
- return -1;
- }
- ret = calendar_record_set_caltime(event, _calendar_event.end_time, et);
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_event.end_time\n");
- return -1;
- }
- } else {
- _convert_to_datetime(sdate, &y, &m, &d);
- st.type = CALENDAR_TIME_LOCALTIME;
- st.time.date.year = y;
- st.time.date.month = m;
- st.time.date.mday = d;
- ret = calendar_record_set_str(event, _calendar_event.start_tzid, "Asia/Seoul");
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_event.start_tzid\n");
- return -1;
- }
- ret = calendar_record_set_caltime(event, _calendar_event.start_time, st);
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_event.start_time\n");
- return -1;
- }
-
- _convert_to_datetime(edate, &y, &m, &d);
- et.type = CALENDAR_TIME_LOCALTIME;
- et.time.date.year = y;
- et.time.date.month = m;
- et.time.date.mday = d;
- ret = calendar_record_set_str(event, _calendar_event.end_tzid, "Asia/Seoul");
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_event.end_tzid\n");
- return -1;
- }
- ret = calendar_record_set_caltime(event, _calendar_event.end_time, et);
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_event.end_time\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int __dft_event_set_3(calendar_record_h event, int occurence, int status, int sensitivity)
-{
- int ret;
-
- switch (occurence)
- {
- case CALENDAR_RECURRENCE_NONE:
- case CALENDAR_RECURRENCE_DAILY:
- case CALENDAR_RECURRENCE_WEEKLY:
- case CALENDAR_RECURRENCE_MONTHLY:
- case CALENDAR_RECURRENCE_YEARLY:
- break;
- default:
- printf("Out of range, so set CALENDAR_RECURRENCE_NONE\n");
- occurence = CALENDAR_RECURRENCE_NONE;
- break;
- }
- ret = calendar_record_set_int(event, _calendar_event.count, occurence);
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_event.count\n");
- return -1;
- }
- switch (status)
- {
- case CALENDAR_EVENT_BUSY_STATUS_FREE:
- case CALENDAR_EVENT_BUSY_STATUS_BUSY:
- case CALENDAR_EVENT_BUSY_STATUS_UNAVAILABLE:
- case CALENDAR_EVENT_BUSY_STATUS_TENTATIVE:
- break;
- default:
- printf("Out of range, so set CALENDAR_EVENT_BUSY_STATUS_FREE\n");
- status = CALENDAR_EVENT_BUSY_STATUS_FREE;
- break;
- }
- ret = calendar_record_set_int(event, _calendar_event.busy_status, status);
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_event.busy_status\n");
- return -1;
- }
-
- switch (sensitivity)
- {
- case CALENDAR_SENSITIVITY_PUBLIC:
- case CALENDAR_SENSITIVITY_PRIVATE:
- case CALENDAR_SENSITIVITY_CONFIDENTIAL:
- break;
- default:
- printf("Out of range, so set CALENDAR_SENSITIVITY_PUBLIC\n");
- sensitivity = CALENDAR_SENSITIVITY_PUBLIC;
- break;
- }
- ret = calendar_record_set_int(event, _calendar_event.sensitivity, sensitivity);
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_event.sensitivity\n");
- return -1;
- }
- return 0;
-}
-
-static int __dft_todo_set_1(calendar_record_h todo, int book_id, char *subject, char *location)
-{
- int ret;
-
- ret = calendar_record_set_int(todo, _calendar_todo.calendar_book_id, book_id);
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_todo.calendar_book_id\n");
- return -1;
- }
- ret = calendar_record_set_str(todo, _calendar_todo.summary, subject);
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_todo.summary\n");
- return -1;
- }
- ret = calendar_record_set_str(todo, _calendar_todo.location, location);
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_todo.location\n");
- return -1;
- }
- return 0;
-}
-
-static int __dft_todo_set_2(calendar_record_h todo, char *allday, char *sdate, char *stime, char *edate, char *etime)
-{
- int ret;
- int y, m, d;
- calendar_time_s st = {0}, et = {0};
-
- if (!strncmp(allday, "Off", sizeof("Off")))
- {
- st.type = CALENDAR_TIME_UTIME;
- st.time.utime = _convert_to_utime(sdate, stime);
- ret = calendar_record_set_str(todo, _calendar_todo.start_tzid, "Asia/Seoul");
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_todo.start_tzid\n");
- return -1;
- }
- ret = calendar_record_set_caltime(todo, _calendar_todo.start_time, st);
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_todo.start_time\n");
- return -1;
- }
-
- et.type = CALENDAR_TIME_UTIME;
- et.time.utime = _convert_to_utime(edate, etime);
- ret = calendar_record_set_str(todo, _calendar_todo.due_tzid, "Asia/Seoul");
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_todo.due_tzid\n");
- return -1;
- }
- ret = calendar_record_set_caltime(todo, _calendar_todo.due_time, et);
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_todo.due_time\n");
- return -1;
- }
- } else {
- _convert_to_datetime(sdate, &y, &m, &d);
- st.type = CALENDAR_TIME_LOCALTIME;
- st.time.date.year = y;
- st.time.date.month = m;
- st.time.date.mday = d;
- ret = calendar_record_set_str(todo, _calendar_todo.start_tzid, "Asia/Seoul");
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_todo.start_tzid\n");
- return -1;
- }
- ret = calendar_record_set_caltime(todo, _calendar_todo.start_time, st);
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_todo.start_time\n");
- return -1;
- }
-
- _convert_to_datetime(edate, &y, &m, &d);
- et.type = CALENDAR_TIME_LOCALTIME;
- et.time.date.year = y;
- et.time.date.month = m;
- et.time.date.mday = d;
- ret = calendar_record_set_str(todo, _calendar_todo.due_tzid, "Asia/Seoul");
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_todo.due_tzid\n");
- return -1;
- }
- ret = calendar_record_set_caltime(todo, _calendar_todo.due_time, et);
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_todo.due_time\n");
- return -1;
- }
- }
- return 0;
-}
-
-static int __dft_todo_set_3(calendar_record_h todo, int occurence, int status, int sensitivity)
-{
- int ret;
-
- switch (occurence)
- {
- case CALENDAR_RECURRENCE_NONE:
- case CALENDAR_RECURRENCE_DAILY:
- case CALENDAR_RECURRENCE_WEEKLY:
- case CALENDAR_RECURRENCE_MONTHLY:
- case CALENDAR_RECURRENCE_YEARLY:
- break;
- default:
- printf("Out of range, so set CALENDAR_RECURRENCE_NONE\n");
- occurence = CALENDAR_RECURRENCE_NONE;
- break;
- }
- ret = calendar_record_set_int(todo, _calendar_todo.count, occurence);
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_todo.count\n");
- return -1;
- }
-
- switch (status)
- {
- case CALENDAR_TODO_STATUS_NONE:
- case CALENDAR_TODO_STATUS_NEEDS_ACTION:
- case CALENDAR_TODO_STATUS_COMPLETED:
- case CALENDAR_TODO_STATUS_IN_PROCESS:
- case CALENDAR_TODO_STATUS_CANCELED:
- break;
- default:
- printf("Out of range, so set ALENDAR_TODO_STATUS_NEEDS_ACTION\n");
- status = CALENDAR_TODO_STATUS_NEEDS_ACTION;
- break;
- }
- ret = calendar_record_set_int(todo, _calendar_todo.todo_status, status);
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_todo.todo_status\n");
- return -1;
- }
-
- switch (sensitivity)
- {
- case CALENDAR_SENSITIVITY_PUBLIC:
- case CALENDAR_SENSITIVITY_PRIVATE:
- case CALENDAR_SENSITIVITY_CONFIDENTIAL:
- break;
- default:
- printf("Out of range, so set CALENDAR_SENSITIVITY_PUBLIC\n");
- sensitivity = CALENDAR_SENSITIVITY_PUBLIC;
- break;
- }
- ret = calendar_record_set_int(todo, _calendar_todo.sensitivity, sensitivity);
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("failed to set _calendar_todo.sensitivity\n");
- return -1;
- }
- return 0;
-}
-
-int main(int argc, char **argv)
-{
- FILE *file;
- int ret;
- int cnt;
- int type;
- char path[256] = {0};
- char _cnt[16] = {0};
-
- char subject[MAX_COLS];
- char location[MAX_COLS];
- char sdate[16];
- char stime[16];
- char edate[16];
- char etime[16];
- char allday[16];
- int occurence;
- char reminder[16];
- int reminder_value;
- int category;
- int status;
- int sensitivity;
- char description[MAX_COLS];
- calendar_record_h record = NULL;
-
- printf("argc(%d)\n", argc);
-
- if (argc != 3) {
- printf("Check parameters.\n");
- __dft_calendar_help();
- return -1;
- }
-
- snprintf(path, sizeof(path), "%s", argv[1]);
- snprintf(_cnt, sizeof(_cnt), "%s", argv[2]);
- cnt = atoi(_cnt);
-
- type = __dft_get_file_type(argv[1]);
- if (type != CALENDAR_BOOK_TYPE_EVENT && type != CALENDAR_BOOK_TYPE_TODO)
- {
- printf("Invalid book type");
- return -1;
- }
-
- if (cnt <= 0) {
- printf("Invalid count(%d)\n", cnt);
- return -1;
- }
-
- file = fopen(path, "r");
- if (file == NULL) {
- printf("Failed to open file(%s)\n", path);
- return -1;
- }
-
- ret = calendar_connect();
- if (CALENDAR_ERROR_NONE != ret)
- {
- printf("calendar_connect() failed\n");
- fclose(file);
- return -1;
- }
-
- while ( !feof(file) && fscanf(file,
- "%32767[^\t]\t %32767[^\t]\t "
- "%s %s %s %s"
- "%s %d "
- "%s %d "
- "%d %d %d "
- "%32767[^\0] ",
- subject, location,
- sdate, stime, edate, etime,
- allday, &occurence,
- reminder, &reminder_value,
- &category, &status, &sensitivity,
- description) > 1) {
-
- switch (type)
- {
- case CALENDAR_BOOK_TYPE_EVENT:
- ret = CALENDAR_ERROR_NONE;
-
- ret |= calendar_record_create(_calendar_event._uri, &record);
- ret |= __dft_event_set_1(record, 1, subject, location);
- ret |= __dft_event_set_2(record, allday, sdate, stime, edate, etime);
- ret |= __dft_event_set_3(record, occurence, status, sensitivity);
- ret |= calendar_db_insert_record(record, NULL);
- ret |= calendar_record_destroy(record, true);
-
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("__dft_work_event() failed\n");
- return -1;
- }
- break;
-
- case CALENDAR_BOOK_TYPE_TODO:
- ret = CALENDAR_ERROR_NONE;
-
- ret |= calendar_record_create(_calendar_todo._uri, &record);
- ret |= __dft_todo_set_1(record, 1, subject, location);
- ret |= __dft_todo_set_2(record, allday, sdate, stime, edate, etime);
- ret |= __dft_todo_set_3(record, occurence, status, sensitivity);
- ret |= calendar_db_insert_record(record, NULL);
- ret |= calendar_record_destroy(record, true);
-
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("__dft_work_todo() failed\n");
- return -1;
- }
- break;
- }
-
- cnt--;
- if (cnt <= 0) {
- break;
- }
- }
-
- fclose(file);
- ret = calendar_disconnect();
- if(CALENDAR_ERROR_NONE != ret)
- {
- printf("calendar_disconnect() failed \n");
- return -1;
- }
- return 0;
-}
+++ /dev/null
-/*
- * Calendar Service
- *
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-#include <unicode/ucal.h>
-#include <unicode/ustring.h>
-#include <unicode/ustdio.h>
-#include <unicode/udat.h>
-#include <sys/types.h>
-
-#define ms2sec(ms) (long long int)(ms / 1000.0)
-#define sec2ms(s) (s * 1000.0)
-
-long long int _convert_to_utime(char *date, char *time)
-{
- int y, mon, d, h, min;
- char buf[8];
- UErrorCode status = U_ZERO_ERROR;
- UCalendar *cal;
- UDate ud;
-
- if (date == NULL) {
- printf("Invalid argument: data is NULL\n");
- return -1;
- }
-
- if (time == NULL) {
- printf("Invalid argument: time is NULL\n");
- return -1;
- }
-
- cal = ucal_open(NULL, -1, NULL, UCAL_TRADITIONAL, &status);
- if (U_FAILURE(status)) {
- printf("ucal_open failed (%s)", u_errorName(status));
- return -1;
- }
-
- snprintf(buf, 5, "%s", date + 4);
- y = atoi(buf);
- snprintf(buf, 3, "%s", date + 2);
- mon = atoi(buf);
- snprintf(buf, 3, "%s", date);
- d = atoi(buf);
-
- snprintf(buf, 3, "%s", time);
- h = atoi(buf);
- snprintf(buf, 3, "%s", time + 2);
- min = atoi(buf);
-
- ucal_setDateTime(cal, y, mon, d, h, min, 0, &status);
- if (U_FAILURE(status)) {
- printf("ucal_setDate failed (%s)", u_errorName(status));
- return -1;
- }
-
- ud = ucal_getMillis(cal, &status);
- if (U_FAILURE(status)) {
- printf("ucal_getMillis failed (%s)", u_errorName(status));
- return -1;
- }
- ucal_close(cal);
- return ms2sec(ud);
-}
-
-int _convert_to_datetime(char *date, int *y, int *m, int *d)
-{
- char buf[8];
-
- if (date == NULL) {
- printf("Invalid argument: data is NULL\n");
- return -1;
- }
-
- snprintf(buf, 5, "%s", date + 4);
- *y = atoi(buf);
- snprintf(buf, 3, "%s", date + 2);
- *m = atoi(buf);
- snprintf(buf, 3, "%s", date);
- *d = atoi(buf);
- return 0;
-}
--- /dev/null
+/*
+ * Calendar Service
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#ifndef __TIZEN_SOCIAL_CALENDAR_H__
+#define __TIZEN_SOCIAL_CALENDAR_H__
+
+#include <calendar_errors.h>
+#include <calendar_view.h>
+#include <calendar_db.h>
+#include <calendar_filter.h>
+#include <calendar_list.h>
+#include <calendar_query.h>
+#include <calendar_record.h>
+#include <calendar_service.h>
+#include <calendar_vcalendar.h>
+#include <calendar_reminder.h>
+
+#endif /* __TIZEN_SOCIAL_CALENDAR_H__ */
+++ /dev/null
-/*
- * Calendar Service
- *
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#ifndef __TIZEN_SOCIAL_CALENDAR_H__
-#define __TIZEN_SOCIAL_CALENDAR_H__
-
-#include <calendar_errors.h>
-#include <calendar_view.h>
-#include <calendar_db.h>
-#include <calendar_filter.h>
-#include <calendar_list.h>
-#include <calendar_query.h>
-#include <calendar_record.h>
-#include <calendar_service.h>
-#include <calendar_vcalendar.h>
-#include <calendar_reminder.h>
-
-#endif /* __TIZEN_SOCIAL_CALENDAR_H__ */
-
-/**
- * @ingroup CAPI_SOCIAL_FRAMEWORK
- * @defgroup CAPI_SOCIAL_CALENDAR_SVC_MODULE Calendar(New)
- *
- * @brief The Calendar Service API provides functions for managing calendars(including events, to-dos).
- * This API allows you not only to store information about calendar but also to query calendar information.
- *
- * @section CAPI_SOCIAL_CALENDARS_SVC_MODULE_HEADER Required Header
- * \#include <calendar2.h>
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_MODULE_OVERVIEW Overview
- * @section CAPI_SOCIAL_CALENDAR_SVC_MODULE_Records Records
- * An important concept in Calendar API is a record. It may be helpful to know that a record represents
- * an actual record in the internal database, but in general, you can think of a record as a structure
- * describing a single (but complex) entity, like a calendar event or a time zone. A record has
- * many properties, for example, a to-do record has the to-do's description, priority, progress,
- * created, last modified and completed time, plus many others.
- *
- * A record can also contain an identifier field, which holds an identifier of another record.
- * Setting this field's value establishes a relation between the records, for example,
- * a calendar event contains the identifier of a calendar book to which it belongs.
- *
- * Records contain properties of basic types: integer, lli (long integer, long long int), double,
- * string, bool and time. The time type holds either a long long int, or three integers
- * (year, month, day). There are setter and getter functions for each type:
- *
- * <table>
- * <tr>
- * <th> Property </th>
- * <th> Setter </th>
- * <th> Getter </th>
- * </tr>
- * <tr>
- * <td> integer </td>
- * <td> calendar_record_set_int </td>
- * <td> calendar_record_get_int </td>
- * </tr>
- * <tr>
- * <td> long integer </td>
- * <td> calendar_record_set_lli </td>
- * <td> calendar_record_get_lli </td>
- * </tr>
- * <tr>
- * <td> double </td>
- * <td> calendar_record_set_double </td>
- * <td> calendar_record_get_double </td>
- * </tr>
- * <tr>
- * <td> string </td>
- * <td> calendar_record_set_str </td>
- * <td> calendar_record_get_str </td>
- * </tr>
- * <tr>
- * <td> bool </td>
- * <td> calendar_record_set_bool </td>
- * <td> calendar_record_get_bool </td>
- * </tr>
- * <tr>
- * <td> time </td>
- * <td> calendar_record_set_time </td>
- * <td> calendar_record_get_time </td>
- * </tr>
- * </table>
- *
- * A record's type is identified by a structure called the view. For example,
- * the _calendar_event view describes the properties of the calendar event record.
- * Every view has a special field - _uri - that uniquely identifies the view.
- * In many cases you wil need to provide the _uri value to indicate what
- * type of record you wish to create or operate on.
- *
- * To use a record, you must obtain its handle. There are many ways to obtains it,
- * including creating a new record and referring to child records of a record.
- *
- * Example: the code below creates an event and inserts it into default event book
- * (see below on calendar books).
- *
- * @code
- * // create an event
- * calendar_record_h event;
- * calendar_record_create(_calendar_event._uri, &event);
- *
- * // set event summary
- * calendar_record_set_str(event, _calendar_event.summary, "Meeting");
- *
- * // put the event into the default calendar book for events
- * calendar_record_set_int(event, _calendar_event.calendar_book_id, book_id);
- *
- * // insert calendar book into the database
- * calendar_db_insert_record(event);
- * @endcode
- *
- * Records of certain type also hold 'child list' properties. If a record has
- * property of this type, it can be a parent of other records, called child records.
- * For example, attendee records can hold an event's identifier in their event_id
- * property. The event is the parent record of the child attendee records.
- *
- *
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_MODULE_Calendar_books Calendar books
- * A calendar book is a placeholder for other records in Calendar API.
- * Every event and to-do has to belong to a calendar book.
- * There are two built-in calendar books: one for events, and one for to-dos,
- * identified by DEFAULT_EVENT_CALENDAR_BOOK_ID and DEFAULT_TODO_CALENDAR_BOOK_ID,
- * respectively.
- *
- * To receive a list of existing calendar books, use the following:
- *
- * @code
- * calendar_list_h calendar_book_list = NULL;
- * calendar_db_get_all_records(_calendar_calendar_book._uri, 0, 0, &calendar_book_list);
- * @endcode
- *
- * The parameters of calendar_db_get_all_records() are:
- * - type of records you wish to receive - _uri field of the view representing desired type,
- * - index from which results should be received (0 for all records),
- * - maximum number of results (0 means no limit),
- * - a list structure to hold the results.
- *
- * The list should be destroyed later with calendar_list_destroy().
- *
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_MODULE_Events_and_instances Events and instances
- * Two important concepts are event and instance. An event record describes
- * various properties of the event, like description, categories, priority
- * and many others. It also contains information on when the event takes place,
- * there can be more than one instance of the event. Each instance has its
- * corresponding instance record.
- *
- * For example, if an event has the following properties:
- *
- * - start date on 2012-10-09 (Tuesday),
- * - frequency set to 'WEEKLY',
- * - interval set to 1,
- * - count set to 3,
- *
- * it will generate three instances:
- *
- * - 2012-10-09
- * - 2012-10-16
- * - 2012-10-22
- *
- * Interval is a multiplier of frequency, which means that if it is set to N,
- * instances occur every N weeks (or whatever was set in frequency attribute).
- *
- * The recurrence model in Calendar API is compliant with iCalendar specification
- * (<a href="http://www.ietf.org/rfc/rfc2445.txt">www.ietf.org/rfc/rfc2445.txt</a>).
- * The following event properties have the same functionality as their corresponding
- * values in iCalendar:
- *
- * @code
- * freq
- * count
- * interval
- * bysecond
- * byminute
- * byhour
- * byday
- * bymonthday
- * byyearday
- * byweekno
- * bymonth
- * bysetpos
- * wkst
- * @endcode
- *
- *
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_MODULE_Calendar_time_structure Calendar time structure
- * The calendar time structure, calendar_caltime_s, is defined as follows:
- *
- * @code
- * typedef struct
- * {
- * calendar_time_type_e type;
- * union {
- * long long int utime;
- * struct {
- * int year;
- * int month;
- * int mday;
- * } date;
- * } time;
- * } calendar_time_s;
- * @endcode
- *
- * The structure should be used when setting the calendar time type
- * (_CALENDAR_PROPERTY_CALTIME) properties of records.
- *
- * It can hold two types of data: UTC time (long long int) and date,
- * given as year, month and day of the month (three integers). These types
- * are identified by values of calendar_time_type_e, which are CALENDAR_TIME_UTIME
- * and CALENDAR_TIME_LOCALTIME, respectively. The data type determines the usage
- * of the structure.
- *
- * <table>
- * <tr>
- * <th> Identifier </th>
- * <th> Type </th>
- * <th> Name </th>
- * <th> Purpose </th>
- * </tr>
- * <tr>
- * <td> CALENDAR_TIME_UTIME </td>
- * <td> long long int </td>
- * <td> utime </td>
- * <td> UTC time, used to describe non-all-day events </td>
- * </tr>
- * <tr>
- * <td> CALENDAR_TIME_LOCALTIME </td>
- * <td> struct </td>
- * <td> date </td>
- * <td> date only (year, month and day of the month), used to describe all day events </td>
- * </tr>
- * </table>
- *
- *
- * 1. UTC time usage
- *
- * Structures with UTC time should be used for non-all-day events.
- * In such cases, the API user should convert local time to UTC time. The local
- * time zone identifier should be stored in the record, in the corresponding
- * property.
- *
- * For example, when setting starting time of an event, the local
- * time zone should be stored in start_tzid.
- *
- * When converting local time to UTC time, the function below can be useful.
- * The function converts the given date and time to the corresponding
- * UTC time, considering the given time zone (first argument).
- * The function uses UCalendar, see <a href="http://icu-project.org/apiref/icu4c/ucal_8h.html">
- * ucal_8h.html</a>
- *
- * @code
- * #define ms2sec(ms) (long long int)(ms / 1000.0)
- *
- * long long int _time_convert_itol(char *tzid, int y, int mon, int d, int h, int min, int s)
- * {
- * long long int lli;
- * UCalendar *ucal;
- * UErrorCode status = U_ZERO_ERROR;
- *
- * UChar *_tzid = NULL;
- *
- * if (tzid == NULL)
- * {
- * tzid = "Etc/GMT";
- * }
- * _tzid = (UChar*)calloc(strlen(tzid) + 1, sizeof(UChar));
- * if (_tzid == NULL)
- * {
- * return -1;
- * }
- * u_uastrcpy(_tzid, tzid);
- *
- * ucal = ucal_open(_tzid, u_strlen(_tzid), "en_US", UCAL_TRADITIONAL, &status);
- * if (U_FAILURE(status)) {
- * printf("ucal_open failed (%s)\n", u_errorName(status));
- * return -1;
- * }
- *
- * ucal_set(ucal, UCAL_YEAR, y);
- * ucal_set(ucal, UCAL_MONTH, mon -1);
- * ucal_set(ucal, UCAL_DATE, d);
- * ucal_set(ucal, UCAL_HOUR, h);
- * ucal_set(ucal, UCAL_MINUTE, min);
- * ucal_set(ucal, UCAL_SECOND, s);
- * lli = ms2sec(ucal_getMillis(ucal, &status));
- * ucal_close(ucal);
- * if (_tzid) free(_tzid);
- *
- * return lli;
- * }
- * @endcode
- *
- * Sample code:
- *
- * @code
- * // fill calendar time structures (start and end time)
- * calendar_time_s st = {0};
- * calendar_time_s et = {0};
- *
- * st.type = CALENDAR_TIME_UTIME;
- * st.time.time = _time_convert_itol("Asia/Seoul", 2012, 9, 15, 11, 0, 0);
- *
- * et.type = CALENDAR_TIME_UTIME;
- * et.time.time = _time_convert_itol("Asia/Seoul", 2012, 9, 15, 12, 0, 0);
- *
- * // create an event record
- * // ...
- *
- * // set local time zone of start time
- * calendar_record_set_str(event, _calendar_event.start_tzid, "Asia/Seoul");
- *
- * // set start time
- * calendar_record_set_time(event, _calendar_event.start_time, st);
- *
- * // set local time zone of end time
- * calendar_record_set_str(event, _calendar_event.end_tzid, "Asia/Seoul");
- *
- * // set end time
- * calendar_record_set_time(event, _calendar_event.start_time, et);
- * @endcode
- *
- *
- * 2. Date usage
- *
- * Another usage of time structure is an all day event. In case of such events,
- * the structure's type field should be set to CALENDAR_TIME_LOCALTIME.
- * Only the date (no time) will be stored. Such structures can be used to set start
- * and end time of an event.
- *
- * Both start and end time of the event should be set. Start and end time
- * do not have to be equal. If they are not, the event's duration will be more
- * than one day. Note that in such cases there are no instances created,
- * as this is still a non-recurring event.
- *
- *
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_MODULE_Creating_a_recurring_event Creating a recurring event
- * To create a recurring event in Calendar API, first you need to create
- * and fill start and end time structures.
- *
- * @code
- * calendar_time_s st = {0};
- * calendar_time_s et = {0};
- *
- * st.type = CALENDAR_TIME_UTIME;
- * st.time.time = _time_convert_itol("Asia/Seoul", 2012, 9, 15, 11, 0, 0);
- *
- * et.type = CALENDAR_TIME_UTIME;
- * et.time.time = _time_convert_itol("Asia/Seoul", 2012, 9, 15, 12, 0, 0);
- * @endcode
- *
- * Then you can create and configure an event record.
- *
- * The time structures created before should be set using the corresponding setter function.
- * Then, the remaining properties should be set - frequency, interval and count.
- *
- * The last step is inserting the event into the database. Records representing
- * instances of the event are created when the event record is inserted.
- *
- * @code
- * calendar_record_h event;
- * calendar_record_create(_calendar_event._uri, &event);
- *
- * calendar_record_set_str(event, _calendar_event.start_tzid, "Asia/Seoul");
- * calendar_record_set_time(event, _calendar_event.start_time, st);
- * calendar_record_set_str(event, _calendar_event.end_tzid, "Asia/Seoul");
- * calendar_record_set_time(event, _calendar_event.start_time, et);
- *
- * calendar_record_set_int(event, _calendar_event.freq, CALENDAR_RECURRENCE_WEEKLY);
- * calendar_record_set_int(event, _calendar_event.interval, 1)
- * calendar_record_set_int(event, _calendar_event.count, 3);
- *
- * calendar_db_insert_record(event);
- * @endcode
- *
- *
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_MODULE_Filters_and_queries Filters and queries
- * Queries are used to retrieve data which satisfies given criteria, like an integer
- * property being greater than a given value, or a string property containing a given substring.
- * The criteria are defined by creating filters and adding conditions to them, joining them
- * with logical operators. Also, instead of a condition, another filter can be added,
- * which can be used to create more complex filters.
- *
- * Operator precedence in filters determined by the order in which the
- * conditions and filters are added.
- *
- * When a filter is ready, it can be set as a property of a query.
- * Other query properties allow configuring how the returned results
- * are grouped and sorted.
- *
- * Operator precedence in filters is determined by the order in which the
- * conditions and filters are added are added.
- * For example, if the following sequence is added:
- *
- * @code
- * Condition C1
- * OR
- * Condition C2
- * AND
- * Condition C3
- * @endcode
- *
- * the result is:
- *
- * @code
- * (C1 OR C2) AND C3
- * @endcode
- *
- * Another example, the sequence:
- *
- * @code
- * Filter F1:
- * Condition C1
- * OR
- * Condition C2
- *
- * Filter F2:
- * Condition C3
- * OR
- * Condition C4
- *
- * Filter F3:
- * Condition C5
- * AND
- * F1
- * AND
- * F2
- * @endcode
- *
- * results in:
- *
- * @code
- * Filter F3:
- * (C5 AND F1) AND F2
- * @endcode
- *
- * which is:
- *
- * @code
- * Filter F3:
- * (C5 AND (C1 OR C2)) AND (C3 OR C4)
- * @endcode
- *
- * The following code creates a filter, accepting events with high priority
- * or those that include the word "meeting" in their description.
- *
- * @code
- * calendar_filter_h filter = NULL;
- *
- * // create a filter returning event type records
- * calendar_filter_create(_calendar_event._uri, &filter);
- *
- * // add 'priority equals high' condition
- * calendar_filter_add_int(filter, _calendar_event.priority, CALENDAR_MATCH_EQUAL,
- * CALENDAR_EVENT_PRIORITY_HIGH);
- *
- * // add OR operator
- * calendar_filter_add_operator(filter, CALENDAR_FILTER_OPERATOR_OR);
- *
- * // add 'description contains "meeting"' condition
- * calendar_filter_add_str(filter, _calendar_event.description, CALENDAR_MATCH_CONTAINS,
- * "meeting");
- * @endcode
- *
- * The filter should be inserted into a query and the query should be executed:
- *
- * @code
- * calendar_query_h query = NULL;
- * calendar_list_h list = NULL;
- *
- * // create a query returning event type records
- * calendar_query_create(_calendar_event._uri, &query);
- *
- * // add the filter
- * calendar_query_set_filter(query, filter);
- *
- * // execute the query, results are returned in a list
- * calendar_db_get_records_with_query(query, 0, 0, &list);
- *
- * calendar_filter_destroy(&filter);
- * calendar_query_destroy(&query);
- *
- * // use the list
- * // ...
- *
- * calendar_list_destroy(&list);
- * @endcode
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_MODULE_View_properties View properties
- * In \ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE category, you can find tables with view properties. Record types which have *_id
- * as their properties, hold identifiers of other records - e.g. attendee and alarm
- * views hold id of their corresponding events or to-dos in event_id or todo_id property repectively
- * (as children of the corresponding events or to-dos record).
- *
- * Properties of type 'record' are other records. For example, a event record has 'attendee'
- * and 'alarm', which means that records of those types can be children
- * of event type records.
- */
-
-/**
- * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
- * @defgroup CAPI_SOCIAL_CALENDAR_SVC_DATABASE_MODULE Database
- *
- * @brief The calendar database API provides the set of the definitions and interfaces that enable you to handle calendar database.
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_DATABASE_MODULE_HEADER Required Header
- * \#include <calendar2.h>
- *
- * <BR>
- */
-
-/**
- * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
- * @defgroup CAPI_SOCIAL_CALENDAR_SVC_FILTER_MODULE Filter
- *
- * @brief The calendar database API provides the set of the definitions and interfaces that enable you to handle filter.
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_FILTER_MODULE_HEADER Required Header
- * \#include <calendar2.h>
- *
- * <BR>
- */
-
-/**
- * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
- * @defgroup CAPI_SOCIAL_CALENDAR_SVC_LIST_MODULE List
- *
- * @brief This page provides information about list.
- *
- * @brief The calendar database API provides the set of the definitions and interfaces that enable you to handle list.
- * \#include <calendar2.h>
- *
- * <BR>
- */
-
-/**
- * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
- * @defgroup CAPI_SOCIAL_CALENDAR_SVC_QUERY_MODULE Query
- *
- * @brief The calendar database API provides the set of the definitions and interfaces that enable you to handle query.
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_QUERY_MODULE_HEADER Required Header
- * \#include <calendar2.h>
- *
- * <BR>
- */
-
-/**
- * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
- * @defgroup CAPI_SOCIAL_CALENDAR_SVC_RECORD_MODULE Record
- *
- * @brief The calendar record API provides the set of the definitions and interfaces that enable you to get/set data from/to calendar record handle.
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_RECORD_MODULE_HEADER Required Header
- * \#include <calendar2.h>
- *
- * <BR>
- */
-
-/**
- * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
- * @defgroup CAPI_SOCIAL_CALENDAR_SVC_REMINDER_MODULE Reminder
- *
- * @brief The calendar record API provides the set of the definitions and interfaces that enable you to get/set reminder.
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_REMINDER_MODULE_HEADER Required Header
- * \#include <calendar2.h>
- *
- * <BR>
- */
-
-/**
- * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
- * @defgroup CAPI_SOCIAL_CALENDAR_SVC_VCALENDAR_MODULE vCalendar
- *
- * @brief The calendar record API provides the set of the definitions and interfaces that enable you to get/set data from/to vCalendar.
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_VCALENDAR_MODULE_HEADER Required Header
- * \#include <calendar2.h>
- *
- * <BR>
- */
-
-/**
- * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
- * @defgroup CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE View/Property
- *
- * @brief This page provides information about views with properties.
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_OVERVIEW Overview
- * A view is a structure which describes properties of a record.
- * A record can have basic properties of four types: integer, string, boolean, long integer. Each property
- * of basic type has functions to operate on it:
- *
- * <table>
- * <tr>
- * <th>Property type</th>
- * <th>Setter</th>
- * <th>Getter</th>
- * </tr>
- * <tr>
- * <td> string </td>
- * <td> calendar_record_set_str </td>
- * <td> calendar_record_get_str </td>
- * </tr>
- * <tr>
- * <td> integer </td>
- * <td> calendar_record_set_int </td>
- * <td> calendar_record_get_int </td>
- * </tr>
- * <tr>
- * <td> boolean </td>
- * <td> calendar_record_set_bool </td>
- * <td> calendar_record_get_bool </td>
- * </tr>
- * <tr>
- * <td> long integer </td>
- * <td> calendar_record_set_lli </td>
- * <td> calendar_record_get_lli </td>
- * </tr>
- * </table>
- *
- * For long integer functions, "lli" stands for long long int, ususally used to hold UTC time.
- *
- * Below you can find tables with view properties.
- *
- * Properties of type 'record' are other records. For example, the \ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_event
- * has a 'calendar_alarm' property of type 'record'. This means that records of type calendar_alarm (\ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_alarm)
- * can be children of the event record. If a name record holds the identifier
- * of a event record in its 'event_id' property, it is the child record of the corresponding
- * event record.
- *
- * Records can have many children of a given type.
- *
- * Please refer to the main section of Calendar API for a more detailed explanation and examples.
- *
- * @section CAPI_SOCIAL_CCALENDAR_SVC_VIEW_MODULE_HEADER Required Header
- * \#include <calendar2.h>
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_book _calendar_book view
- * <table>
- * <tr>
- * <th> Type </th>
- * <th> Property ID </th>
- * <th> Read, Write </th>
- * </tr>
- * <tr><td> string </td><td> _uri </td><td> read only </td></tr>
- * <tr><td> integer </td><td> id </td><td> read only </td></tr>
- * <tr><td> string </td><td> uid </td><td> read, write </td></tr>
- * <tr><td> string </td><td> name </td><td> read, write </td></tr>
- * <tr><td> string </td><td> description </td><td> read, write </td></tr>
- * <tr><td> string </td><td> color </td><td> read, write </td></tr>
- * <tr><td> string </td><td> location </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> visibility </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> sync_event </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> is_deleted </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> account_id </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> store_type </td><td> read, write </td></tr>
- * <tr><td> string </td><td> sync_data1 </td><td> read, write </td></tr>
- * <tr><td> string </td><td> sync_data2 </td><td> read, write </td></tr>
- * <tr><td> string </td><td> sync_data3 </td><td> read, write </td></tr>
- * <tr><td> string </td><td> sync_data4 </td><td> read, write </td></tr>
- * </table>
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_event _calendar_event view
- * <table>
- * <tr>
- * <th> Type </th>
- * <th> Property ID </th>
- * <th> Read, Write </th>
- * </tr>
- * <tr><td> string </td><td> _uri </td><td> read only </td></tr>
- * <tr><td> integer </td><td> id </td><td> read only </td></tr>
- * <tr><td> integer </td><td> calendar_book_id </td><td> read, write once </td></tr>
- * <tr><td> string </td><td> summary </td><td> read, write </td></tr>
- * <tr><td> string </td><td> description </td><td> read, write </td></tr>
- * <tr><td> string </td><td> location </td><td> read, write </td></tr>
- * <tr><td> string </td><td> categories </td><td> read, write </td></tr>
- * <tr><td> string </td><td> exdate </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> event_status </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> priority </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> timezone </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> person_id </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> busy_status </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> sensitivity </td><td> read, write </td></tr>
- * <tr><td> string </td><td> uid </td><td> read, write </td></tr>
- * <tr><td> string </td><td> organizer_name </td><td> read, write </td></tr>
- * <tr><td> string </td><td> organizer_email </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> meeting_status </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> original_event_id </td><td> read, write </td></tr>
- * <tr><td> double </td><td> latitude </td><td> read, write </td></tr>
- * <tr><td> double </td><td> longitude </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> email_id </td><td> read, write </td></tr>
- * <tr><td> long long int </td><td> created_time </td><td> read, write </td></tr>
- * <tr><td> long long int </td><td> last_modified_time </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> is_deleted </td><td> read only </td></tr>
- * <tr><td> integer </td><td> freq </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> range_type </td><td> read, write </td></tr>
- * <tr><td> calendar time </td><td> until_time </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> count </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> interval </td><td> read, write </td></tr>
- * <tr><td> string </td><td> bysecond </td><td> read, write </td></tr>
- * <tr><td> string </td><td> byminute </td><td> read, write </td></tr>
- * <tr><td> string </td><td> byhour </td><td> read, write </td></tr>
- * <tr><td> string </td><td> byday </td><td> read, write </td></tr>
- * <tr><td> string </td><td> bymonthday </td><td> read, write </td></tr>
- * <tr><td> string </td><td> byyearday </td><td> read, write </td></tr>
- * <tr><td> string </td><td> byweekno </td><td> read, write </td></tr>
- * <tr><td> string </td><td> bymonth </td><td> read, write </td></tr>
- * <tr><td> string </td><td> bysetpos </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> wkst </td><td> read, write </td></tr>
- * <tr><td> string </td><td> recurrence_id </td><td> read, write </td></tr>
- * <tr><td> string </td><td> rdate </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> has_attendee </td><td> read only </td></tr>
- * <tr><td> integer </td><td> has_alarm </td><td> read only </td></tr>
- * <tr><td> integer </td><td> calendar_system_type </td><td> read, write </td></tr>
- * <tr><td> string </td><td> sync_data1 </td><td> read, write </td></tr>
- * <tr><td> string </td><td> sync_data2 </td><td> read, write </td></tr>
- * <tr><td> string </td><td> sync_data3 </td><td> read, write </td></tr>
- * <tr><td> string </td><td> sync_data4 </td><td> read, write </td></tr>
- * <tr><td> calendar time </td><td> start_time </td><td> read, write </td></tr>
- * <tr><td> string </td><td> start_tzid </td><td> read, write </td></tr>
- * <tr><td> calendar time </td><td> end_time </td><td> read, write </td></tr>
- * <tr><td> string </td><td> end_tzid </td><td> read, write </td></tr>
- * <tr><td> child list </td><td> calendar_alarm </td><td> read, write </td></tr>
- * <tr><td> child list </td><td> calendar_attendee </td><td> read, write </td></tr>
- * </table>
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_todo _calendar_todo view
- * <table>
- * <tr>
- * <th> Type </th>
- * <th> Property ID </th>
- * <th> Read, Write </th>
- * </tr>
- * <tr><td> string </td><td> _uri </td><td> read only </td></tr>
- * <tr><td> integer </td><td> id </td><td> read only </td></tr>
- * <tr><td> integer </td><td> calendar_book_id </td><td> read, write once </td></tr>
- * <tr><td> string </td><td> summary </td><td> read, write </td></tr>
- * <tr><td> string </td><td> description </td><td> read, write </td></tr>
- * <tr><td> string </td><td> location </td><td> read, write </td></tr>
- * <tr><td> string </td><td> categories </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> todo_status </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> priority </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> sensitivity </td><td> read, write </td></tr>
- * <tr><td> string </td><td> uid </td><td> read, write </td></tr>
- * <tr><td> double </td><td> latitude </td><td> read, write </td></tr>
- * <tr><td> double </td><td> longitude </td><td> read, write </td></tr>
- * <tr><td> long long int </td><td> created_time </td><td> read, write </td></tr>
- * <tr><td> long long int </td><td> last_modified_time </td><td> read, write </td></tr>
- * <tr><td> long long int </td><td> completed_time </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> progress </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> is_deleted </td><td> read only </td></tr>
- * <tr><td> integer </td><td> freq </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> range_type </td><td> read, write </td></tr>
- * <tr><td> calendar time </td><td> until_time </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> count </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> interval </td><td> read, write </td></tr>
- * <tr><td> string </td><td> bysecond </td><td> read, write </td></tr>
- * <tr><td> string </td><td> byminute </td><td> read, write </td></tr>
- * <tr><td> string </td><td> byhour </td><td> read, write </td></tr>
- * <tr><td> string </td><td> byday </td><td> read, write </td></tr>
- * <tr><td> string </td><td> bymonthday </td><td> read, write </td></tr>
- * <tr><td> string </td><td> byyearday </td><td> read, write </td></tr>
- * <tr><td> string </td><td> byweekno </td><td> read, write </td></tr>
- * <tr><td> string </td><td> bymonth </td><td> read, write </td></tr>
- * <tr><td> string </td><td> bysetpos </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> wkst </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> has_alarm </td><td> read only </td></tr>
- * <tr><td> string </td><td> sync_data1 </td><td> read, write </td></tr>
- * <tr><td> string </td><td> sync_data2 </td><td> read, write </td></tr>
- * <tr><td> string </td><td> sync_data3 </td><td> read, write </td></tr>
- * <tr><td> string </td><td> sync_data4 </td><td> read, write </td></tr>
- * <tr><td> calendar time </td><td> start_time </td><td> read, write </td></tr>
- * <tr><td> string </td><td> start_tzid </td><td> read, write </td></tr>
- * <tr><td> calendar time </td><td> due_time </td><td> read, write </td></tr>
- * <tr><td> string </td><td> due_tzid </td><td> read, write </td></tr>
- * <tr><td> child list </td><td> calendar_alarm </td><td> read, write </td></tr>
- * </table>
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_timezone _calendar_timezone view
- * <table>
- * <tr>
- * <th> Type </th>
- * <th> Property ID </th>
- * <th> Read, Write </th>
- * </tr>
- * <tr><td> string </td><td> _uri </td><td> read only </td></tr>
- * <tr><td> integer </td><td> id </td><td> read only </td></tr>
- * <tr><td> integer </td><td> calendar_book_id </td><td> read only </td></tr>
- * <tr><td> integer </td><td> tz_offset_from_gmt </td><td> read only </td></tr>
- * <tr><td> string </td><td> standard_name </td><td> read only </td></tr>
- * <tr><td> integer </td><td> standard_start_month </td><td> read only </td></tr>
- * <tr><td> integer </td><td> standard_start_position_of_week </td><td> read only </td></tr>
- * <tr><td> integer </td><td> standard_start_day </td><td> read only </td></tr>
- * <tr><td> integer </td><td> standard_start_hour </td><td> read only </td></tr>
- * <tr><td> integer </td><td> standard_bias </td><td> read only </td></tr>
- * <tr><td> string </td><td> day_light_name </td><td> read only </td></tr>
- * <tr><td> integer </td><td> day_light_start_month </td><td> read only </td></tr>
- * <tr><td> integer </td><td> day_light_start_position_of_week </td><td> read only </td></tr>
- * <tr><td> integer </td><td> day_light_start_day </td><td> read only </td></tr>
- * <tr><td> integer </td><td> day_light_start_hour </td><td> read only </td></tr>
- * <tr><td> integer </td><td> day_light_bias </td><td> read only </td></tr>
- * </table>
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_attendee _calendar_attendee view
- * <table>
- * <tr>
- * <th> Type </th>
- * <th> Property ID </th>
- * <th> Read, Write </th>
- * </tr>
- * <tr><td> string </td><td> _uri </td><td> read only </td></tr>
- * <tr><td> integer </td><td> event_id </td><td> read only </td></tr>
- * <tr><td> string </td><td> number </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> type </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> person_id </td><td> read, write </td></tr>
- * <tr><td> string </td><td> uid </td><td> read, write </td></tr>
- * <tr><td> string </td><td> group </td><td> read, write </td></tr>
- * <tr><td> string </td><td> email </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> role </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> status </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> rsvp </td><td> read, write </td></tr>
- * <tr><td> string </td><td> delegate_uri </td><td> read, write </td></tr>
- * <tr><td> string </td><td> delegator_uri </td><td> read, write </td></tr>
- * <tr><td> string </td><td> name </td><td> read, write </td></tr>
- * </table>
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_alarm _calendar_alarm view
- * <table>
- * <tr>
- * <th> Type </th>
- * <th> Property ID </th>
- * <th> Read, Write </th>
- * </tr>
- * <tr><td> string </td><td> _uri </td><td> read only </td></tr>
- * <tr><td> integer </td><td> event_id </td><td> read only </td></tr>
- * <tr><td> integer </td><td> todo_id </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> type </td><td> read, write </td></tr>
- * <tr><td> long long int </td><td> time </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> tick </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> tick_unit </td><td> read, write </td></tr>
- * <tr><td> string </td><td> tone </td><td> read, write </td></tr>
- * <tr><td> string </td><td> description </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> alarm_id </td><td> read, write </td></tr>
- * </table>
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_updated_info _calendar_updated_info view
- * <table>
- * <tr>
- * <th> Type </th>
- * <th> Property ID </th>
- * <th> Read, Write </th>
- * </tr>
- * <tr><td> string </td><td> _uri </td><td> read only </td></tr>
- * <tr><td> integer </td><td> id </td><td> read only </td></tr>
- * <tr><td> integer </td><td> calendar_book_id </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> modified_status </td><td> read, write </td></tr>
- * </table>
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_event_calendar_book _calendar_event_calendar_book view
- * <table>
- * <tr>
- * <th> Type </th>
- * <th> Property ID </th>
- * <th> Read, Write </th>
- * </tr>
- * <tr><td> string </td><td> _uri </td><td> read only </td></tr>
- * <tr><td> integer </td><td> event_id </td><td> read only </td></tr>
- * <tr><td> integer </td><td> calendar_book_id </td><td> read, write </td></tr>
- * <tr><td> string </td><td> summary </td><td> read, write </td></tr>
- * <tr><td> string </td><td> description </td><td> read, write </td></tr>
- * <tr><td> string </td><td> location </td><td> read, write </td></tr>
- * <tr><td> string </td><td> categories </td><td> read, write </td></tr>
- * <tr><td> string </td><td> exdate </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> event_status </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> priority </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> timezone </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> person_id </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> busy_status </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> sensitivity </td><td> read, write </td></tr>
- * <tr><td> string </td><td> uid </td><td> read, write </td></tr>
- * <tr><td> string </td><td> organizer_name </td><td> read, write </td></tr>
- * <tr><td> string </td><td> organizer_email </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> meeting_status </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> original_event_id </td><td> read, write </td></tr>
- * <tr><td> double </td><td> latitude </td><td> read, write </td></tr>
- * <tr><td> double </td><td> longitude </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> email_id </td><td> read, write </td></tr>
- * <tr><td> long long int </td><td> created_time </td><td> read, write </td></tr>
- * <tr><td> long long int </td><td> last_modified_time </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> is_deleted </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> freq </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> range_type </td><td> read, write </td></tr>
- * <tr><td> calendar time </td><td> until_time </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> count </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> interval </td><td> read, write </td></tr>
- * <tr><td> string </td><td> bysecond </td><td> read, write </td></tr>
- * <tr><td> string </td><td> byminute </td><td> read, write </td></tr>
- * <tr><td> string </td><td> byhour </td><td> read, write </td></tr>
- * <tr><td> string </td><td> byday </td><td> read, write </td></tr>
- * <tr><td> string </td><td> bymonthday </td><td> read, write </td></tr>
- * <tr><td> string </td><td> byyearday </td><td> read, write </td></tr>
- * <tr><td> string </td><td> byweekno </td><td> read, write </td></tr>
- * <tr><td> string </td><td> bymonth </td><td> read, write </td></tr>
- * <tr><td> string </td><td> bysetpos </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> wkst </td><td> read, write </td></tr>
- * <tr><td> string </td><td> recurrence_id </td><td> read, write </td></tr>
- * <tr><td> string </td><td> rdate </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> has_attendee </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> has_alarm </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> calendar_system_type </td><td> read, write </td></tr>
- * <tr><td> string </td><td> sync_data1 </td><td> read, write </td></tr>
- * <tr><td> string </td><td> sync_data2 </td><td> read, write </td></tr>
- * <tr><td> string </td><td> sync_data3 </td><td> read, write </td></tr>
- * <tr><td> string </td><td> sync_data4 </td><td> read, write </td></tr>
- * <tr><td> calendar time </td><td> start_time </td><td> read, write </td></tr>
- * <tr><td> string </td><td> start_tzid </td><td> read, write </td></tr>
- * <tr><td> calendar time </td><td> end_time </td><td> read, write </td></tr>
- * <tr><td> string </td><td> end_tzid </td><td> read, write </td></tr>
- * <tr><td> filter integer </td><td> calendar_book_visibility </td><td> read, write </td></tr>
- * <tr><td> filter integer </td><td> calendar_book_account_id </td><td> read, write </td></tr>
- * </table>
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_todo_calendar_book _calendar_todo_calendar_book view
- * <table>
- * <tr>
- * <th> Type </th>
- * <th> Property ID </th>
- * <th> Read, Write </th>
- * </tr>
- * <tr><td> string </td><td> _uri </td><td> read only </td></tr>
- * <tr><td> integer </td><td> todo_id </td><td> read only </td></tr>
- * <tr><td> integer </td><td> calendar_book_id </td><td> read, write </td></tr>
- * <tr><td> string </td><td> summary </td><td> read, write </td></tr>
- * <tr><td> string </td><td> description </td><td> read, write </td></tr>
- * <tr><td> string </td><td> location </td><td> read, write </td></tr>
- * <tr><td> string </td><td> categories </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> todo_status </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> priority </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> sensitivity </td><td> read, write </td></tr>
- * <tr><td> string </td><td> uid </td><td> read, write </td></tr>
- * <tr><td> double </td><td> latitude </td><td> read, write </td></tr>
- * <tr><td> double </td><td> longitude </td><td> read, write </td></tr>
- * <tr><td> long long int </td><td> created_time </td><td> read, write </td></tr>
- * <tr><td> long long int </td><td> last_modified_time </td><td> read, write </td></tr>
- * <tr><td> long long int </td><td> completed_time </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> progress </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> is_deleted </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> freq </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> range_type </td><td> read, write </td></tr>
- * <tr><td> calendar time </td><td> until_time </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> count </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> interval </td><td> read, write </td></tr>
- * <tr><td> string </td><td> bysecond </td><td> read, write </td></tr>
- * <tr><td> string </td><td> byminute </td><td> read, write </td></tr>
- * <tr><td> string </td><td> byhour </td><td> read, write </td></tr>
- * <tr><td> string </td><td> byday </td><td> read, write </td></tr>
- * <tr><td> string </td><td> bymonthday </td><td> read, write </td></tr>
- * <tr><td> string </td><td> byyearday </td><td> read, write </td></tr>
- * <tr><td> string </td><td> byweekno </td><td> read, write </td></tr>
- * <tr><td> string </td><td> bymonth </td><td> read, write </td></tr>
- * <tr><td> string </td><td> bysetpos </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> wkst </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> has_alarm </td><td> read, write </td></tr>
- * <tr><td> string </td><td> sync_data1 </td><td> read, write </td></tr>
- * <tr><td> string </td><td> sync_data2 </td><td> read, write </td></tr>
- * <tr><td> string </td><td> sync_data3 </td><td> read, write </td></tr>
- * <tr><td> string </td><td> sync_data4 </td><td> read, write </td></tr>
- * <tr><td> calendar time </td><td> start_time </td><td> read, write </td></tr>
- * <tr><td> string </td><td> start_tzid </td><td> read, write </td></tr>
- * <tr><td> calendar time </td><td> due_time </td><td> read, write </td></tr>
- * <tr><td> string </td><td> due_tzid </td><td> read, write </td></tr>
- * <tr><td> filter integer </td><td> calendar_book_visibility </td><td> read, write </td></tr>
- * <tr><td> filter integer </td><td> calendar_book_account_id </td><td> read, write </td></tr>
- * </table>
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_event_calendar_book_attendee _calendar_event_calendar_book_attendee view
- * <table>
- * <tr>
- * <th> Type </th>
- * <th> Property ID </th>
- * <th> Read, Write </th>
- * </tr>
- * <tr><td> string </td><td> _uri </td><td> read only </td></tr>
- * <tr><td> integer </td><td> event_id </td><td> read only </td></tr>
- * <tr><td> integer </td><td> calendar_book_id </td><td> read, write </td></tr>
- * <tr><td> string </td><td> summary </td><td> read, write </td></tr>
- * <tr><td> string </td><td> description </td><td> read, write </td></tr>
- * <tr><td> string </td><td> location </td><td> read, write </td></tr>
- * <tr><td> string </td><td> categories </td><td> read, write </td></tr>
- * <tr><td> string </td><td> exdate </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> event_status </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> priority </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> timezone </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> person_id </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> busy_status </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> sensitivity </td><td> read, write </td></tr>
- * <tr><td> string </td><td> uid </td><td> read, write </td></tr>
- * <tr><td> string </td><td> organizer_name </td><td> read, write </td></tr>
- * <tr><td> string </td><td> organizer_email </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> meeting_status </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> original_event_id </td><td> read, write </td></tr>
- * <tr><td> double </td><td> latitude </td><td> read, write </td></tr>
- * <tr><td> double </td><td> longitude </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> email_id </td><td> read, write </td></tr>
- * <tr><td> long long int </td><td> created_time </td><td> read, write </td></tr>
- * <tr><td> long long int </td><td> last_modified_time </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> is_deleted </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> freq </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> range_type </td><td> read, write </td></tr>
- * <tr><td> calendar time </td><td> until_time </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> count </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> interval </td><td> read, write </td></tr>
- * <tr><td> string </td><td> bysecond </td><td> read, write </td></tr>
- * <tr><td> string </td><td> byminute </td><td> read, write </td></tr>
- * <tr><td> string </td><td> byhour </td><td> read, write </td></tr>
- * <tr><td> string </td><td> byday </td><td> read, write </td></tr>
- * <tr><td> string </td><td> bymonthday </td><td> read, write </td></tr>
- * <tr><td> string </td><td> byyearday </td><td> read, write </td></tr>
- * <tr><td> string </td><td> byweekno </td><td> read, write </td></tr>
- * <tr><td> string </td><td> bymonth </td><td> read, write </td></tr>
- * <tr><td> string </td><td> bysetpos </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> wkst </td><td> read, write </td></tr>
- * <tr><td> string </td><td> recurrence_id </td><td> read, write </td></tr>
- * <tr><td> string </td><td> rdate </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> has_attendee </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> has_alarm </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> calendar_system_type </td><td> read, write </td></tr>
- * <tr><td> string </td><td> sync_data1 </td><td> read, write </td></tr>
- * <tr><td> string </td><td> sync_data2 </td><td> read, write </td></tr>
- * <tr><td> string </td><td> sync_data3 </td><td> read, write </td></tr>
- * <tr><td> string </td><td> sync_data4 </td><td> read, write </td></tr>
- * <tr><td> calendar time </td><td> start_time </td><td> read, write </td></tr>
- * <tr><td> string </td><td> start_tzid </td><td> read, write </td></tr>
- * <tr><td> calendar time </td><td> end_time </td><td> read, write </td></tr>
- * <tr><td> string </td><td> end_tzid </td><td> read, write </td></tr>
- * <tr><td> filter integer </td><td> calendar_book_visibility </td><td> read, write </td></tr>
- * <tr><td> filter integer </td><td> calendar_book_account_id </td><td> read, write </td></tr>
- * <tr><td> filter string </td><td> attendee_email </td><td> read, write </td></tr>
- * <tr><td> filter string </td><td> attendee_name </td><td> read, write </td></tr>
- * </table>
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_instance_normal_calendar_book _calendar_instance_normal_calendar_book view
- * <table>
- * <tr>
- * <th> Type </th>
- * <th> Property ID </th>
- * <th> Read, Write </th>
- * </tr>
- * <tr><td> string </td><td> _uri </td><td> read only </td></tr>
- * <tr><td> integer </td><td> event_id </td><td> read only </td></tr>
- * <tr><td> calendar time </td><td> start_time </td><td> read, write </td></tr>
- * <tr><td> calendar time </td><td> end_time </td><td> read, write </td></tr>
- * <tr><td> string </td><td> summary </td><td> read, write </td></tr>
- * <tr><td> string </td><td> location </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> calendar_book_id </td><td> read, write </td></tr>
- * <tr><td> string </td><td> description </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> busy_status </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> event_status </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> priority </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> sensitivity </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> has_rrule </td><td> read, write </td></tr>
- * <tr><td> double </td><td> latitude </td><td> read, write </td></tr>
- * <tr><td> double </td><td> longitude </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> has_alarm </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> original_event_id </td><td> read, write </td></tr>
- * <tr><td> filter integer </td><td> calendar_book_visibility </td><td> read, write </td></tr>
- * <tr><td> filter integer </td><td> calendar_book_account_id </td><td> read, write </td></tr>
- * </table>
- *
- * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_instance_allday_calendar_book _calendar_instance_allday_calendar_book view
- * <table>
- * <tr>
- * <th> Type </th>
- * <th> Property ID </th>
- * <th> Read, Write </th>
- * </tr>
- * <tr><td> string </td><td> _uri </td><td> read only </td></tr>
- * <tr><td> integer </td><td> event_id </td><td> read only </td></tr>
- * <tr><td> calendar time </td><td> start_time </td><td> read, write </td></tr>
- * <tr><td> calendar time </td><td> end_time </td><td> read, write </td></tr>
- * <tr><td> string </td><td> summary </td><td> read, write </td></tr>
- * <tr><td> string </td><td> location </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> calendar_book_id </td><td> read, write </td></tr>
- * <tr><td> string </td><td> description </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> busy_status </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> event_status </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> priority </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> sensitivity </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> has_rrule </td><td> read, write </td></tr>
- * <tr><td> double </td><td> latitude </td><td> read, write </td></tr>
- * <tr><td> double </td><td> longitude </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> has_alarm </td><td> read, write </td></tr>
- * <tr><td> integer </td><td> original_event_id </td><td> read, write </td></tr>
- * <tr><td> filter integer </td><td> calendar_book_visibility </td><td> read, write </td></tr>
- * <tr><td> filter integer </td><td> calendar_book_account_id </td><td> read, write </td></tr>
- * </table>
- *
- */
-
-
*
*/
-#ifndef __TIZEN_SOCAIL_CALENDAR_DB_H__
-#define __TIZEN_SOCAIL_CALENDAR_DB_H__
+#ifndef __TIZEN_SOCIAL_CALENDAR_DB_H__
+#define __TIZEN_SOCIAL_CALENDAR_DB_H__
-#include <calendar_types2.h>
+#include <calendar_types.h>
#ifndef API
#define API __attribute__ ((visibility("default")))
#endif
/**
+ * @file calendar_db.h
+ */
+
+/**
* @addtogroup CAPI_SOCIAL_CALENDAR_SVC_DATABASE_MODULE
* @{
*/
/**
- * @brief Inserts a record to the calendar database.
+ * @brief Called when a designated view changes.
+ * @since_tizen 2.3
+ *
+ * @param[in] view_uri The view URI
+ * @param[in] user_data The user data passed from the callback registration function
+ *
+ * @see calendar_db_add_changed_cb()
+ */
+typedef void (*calendar_db_changed_cb)(const char* view_uri, void* user_data);
+
+/**
+ * @brief Inserts a record into the calendar database.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.write
*
- * @param[in] record The record handle
- * @param[out] record_id The record ID
+ * @param[in] record The record handle
+ * @param[out] record_id The record ID
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 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
+ * @retval #CALENDAR_ERROR_FILE_NO_SPACE File system is full
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ * @retval #CALENDAR_ERROR_DB_FAILED Database operation failure
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
+ * @retval #CALENDAR_ERROR_NO_DATA Data does not exist
*
- * @pre This function requires an open connection to calendar service by calendar_connect().
+ * @pre calendar_connect() should be called to open a connection to the calendar service.
*
* @see calendar_connect()
* @see calendar_db_update_record()
* @see calendar_db_delete_record()
* @see calendar_db_get_record()
*/
-API int calendar_db_insert_record( calendar_record_h record, int* record_id );
+int calendar_db_insert_record( calendar_record_h record, int* record_id );
/**
- * @brief Gets a record from the calendar database.
+ * @brief Gets a record from the calendar database.
*
* @details This function creates a new record handle from the calendar database by the given @a record_id. \n
- * @a record will be created, which is filled with record information.
+ * @a record will be created and filled with record information.
*
- * @remarks @a record must be released with calendar_record_destroy() by you.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.read
*
- * @param[in] view_uri The view URI of a record
- * @param[in] record_id The record ID to get from database
- * @param[out] record The record handle associated with the record ID
+ * @remarks You must release @a record using calendar_record_destroy().
*
- * @return 0 on success, otherwise a negative error value.
+ * @param[in] view_uri The view URI of a record
+ * @param[in] record_id The record ID
+ * @param[out] record The record handle associated with the record ID
+ *
+ * @return @c 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
+ * @retval #CALENDAR_ERROR_FILE_NO_SPACE File system is full
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ * @retval #CALENDAR_ERROR_DB_FAILED Database operation failure
+ * @retval #CALENDAR_ERROR_DB_RECORD_NOT_FOUND Database not found
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
+ * @retval #CALENDAR_ERROR_NO_DATA Data does not exist
*
- * @pre This function requires an open connection to calendar service by calendar_connect().
+ * @pre calendar_connect() should be called to open a connection to the calendar service.
*
* @see calendar_connect()
* @see calendar_record_destroy()
*/
-API int calendar_db_get_record( const char* view_uri, int record_id, calendar_record_h* record );
+int calendar_db_get_record( const char* view_uri, int record_id, calendar_record_h* record );
/**
- * @brief Updates a record to the calendar database.
+ * @brief Updates a record in the calendar database.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.write
*
- * @param[in] record The record handle
+ * @param[in] record The record handle
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 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
+ * @retval #CALENDAR_ERROR_DB_FAILED Database operation failure
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
+ * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CALENDAR_ERROR_DB_RECORD_NOT_FOUND Database not found
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
+ * @retval #CALENDAR_ERROR_NO_DATA Data does not exist
*
- * @pre This function requires an open connection to calendar service by calendar_connect().
+ * @pre calendar_connect() should be called to open a connection to the calendar service.
*
* @see calendar_connect()
* @see calendar_db_insert_record()
* @see calendar_db_delete_record()
* @see calendar_db_get_record()
*/
-API int calendar_db_update_record( calendar_record_h record );
+int calendar_db_update_record( calendar_record_h record );
/**
- * @brief Deletes a record from the calendar database.
+ * @brief Deletes a record from the calendar database with related child records.
*
- * @param[in] view_uri The view URI of a record
- * @param[in] record_id The record ID to delete
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.write
*
- * @return 0 on success, otherwise a negative error value.
+ * @param[in] view_uri The view URI of a record
+ * @param[in] record_id The record ID to be deleted
+ *
+ * @return @c 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
+ * @retval #CALENDAR_ERROR_DB_FAILED Database operation failure
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ * @retval #CALENDAR_ERROR_DB_RECORD_NOT_FOUND Database not found
+ * @retval #CALENDAR_ERROR_FILE_NO_SPACE File system is full
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
+ * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CALENDAR_ERROR_NO_DATA Data does not exist
*
- * @pre This function requires an open connection to calendar service by calendar_connect().
+ * @pre calendar_connect() should be called to open a connection to the calendar service.
*
* @see calendar_connect()
* @see calendar_db_insert_record()
*/
-API int calendar_db_delete_record( const char* view_uri, int record_id );
+int calendar_db_delete_record( const char* view_uri, int record_id );
/**
- * @brief Retrieves all record as list
+ * @brief Retrieves all records as a list.
*
- * @remarks @a record_list must be released with calendar_list_destroy() by you.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.read
*
- * @param[in] view_uri The view URI to get records
- * @param[in] offset The index to get results from which index
- * @param[in] limit The number to limit results
- * @param[out] record_list The record list
+ * @remarks You must release @a record_list using calendar_list_destroy().
*
- * @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
+ * @param[in] view_uri The view URI to get records from
+ * @param[in] offset The index from which results are received
+ * @param[in] limit The maximum number of results(value 0 is used for all records)
+ * @param[out] record_list The record list
*
- * @pre This function requires an open connection to calendar service by calendar_connect().
+ * @return @c 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
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
+ * @retval #CALENDAR_ERROR_NO_DATA Data does not exist
+ *
+ * @pre calendar_connect() should be called to open a connection to the calendar service.
*
* @see calendar_connect()
* @see calendar_list_destroy()
*/
-API int calendar_db_get_all_records( const char* view_uri, int offset, int limit, calendar_list_h* record_list );
+int calendar_db_get_all_records( const char* view_uri, int offset, int limit, calendar_list_h* record_list );
/**
- * @brief Retrieves records with query handle
+ * @brief Retrieves records using a query handle.
*
- * @remarks @a record_list must be released with calendar_list_destroy() by you.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.read
*
- * @param[in] query The query handle to filter
- * @param[in] offset The index to get results from which index
- * @param[in] limit The number to limit results
- * @param[out] record_list The record list
+ * @remarks You must release @a record_list using calendar_list_destroy().
*
- * @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
+ * @param[in] query The query handle used to filter results
+ * @param[in] offset The index from which results are received
+ * @param[in] limit The maximum number of results(value 0 is used for all records)
+ * @param[out] record_list The record list
*
- * @pre This function requires an open connection to calendar service by calendar_connect().
+ * @return @c 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
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
+ * @retval #CALENDAR_ERROR_NO_DATA Data does not exist
+ *
+ * @pre calendar_connect() should be called to open a connection to the calendar service.
*
* @see calendar_connect()
* @see calendar_list_destroy()
*/
-API int calendar_db_get_records_with_query( calendar_query_h query, int offset, int limit, calendar_list_h* record_list );
+int calendar_db_get_records_with_query( calendar_query_h query, int offset, int limit, calendar_list_h* record_list );
/**
- * @brief Cleans data after sync
- *
- * @param[in] calendar_book_id The calendar book ID
- * @param[in] calendar_db_version The calendar database version
- *
- * @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
+ * @brief Gets the record count of a specific view.
*
- * @pre This function requires an open connection to calendar service by calendar_connect().
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.read
*
- * @see calendar_connect()
- */
-API int calendar_db_clean_after_sync( int calendar_book_id, int calendar_db_version ); // calendar_svc_clean_after_sync for EAS sync
-
-/**
- * @brief Gets records count of a specific view
+ * @param[in] view_uri The view URI to get records from
+ * @param[out] count The number of records
*
- * @param[in] view_uri The view URI to get records
- * @param[out] count The count of records
- *
- * @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
+ * @return @c 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
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
+ * @retval #CALENDAR_ERROR_NO_DATA Data does not exist
+ * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory
*
- * @pre This function requires an open connection to calendar service by calendar_connect2().
+ * @pre This function requires an open connection to the calendar service using calendar_connect2().
*
* @see calendar_connect()
*/
-API int calendar_db_get_count( const char* view_uri, int *count );
+int calendar_db_get_count( const char* view_uri, int *count );
/**
- * @brief Gets records count with a query handle
+ * @brief Gets the record count with a query handle.
*
- * @param[in] query The query handle to filter
- * @param[out] count The count of records
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.read
*
- * @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 Database operation failure
+ * @param[in] query The query handle used for filtering the results
+ * @param[out] count The number of records
+ *
+ * @return @c 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
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
+ * @retval #CALENDAR_ERROR_NO_DATA Data does not exist
+ * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory
*
- * @pre This function requires an open connection to calendar service by calendar_connect2().
+ * @pre This function requires an open connection to the calendar service using calendar_connect2().
*
* @see calendar_connect2()
*/
-API int calendar_db_get_count_with_query( calendar_query_h query, int *count );
+int calendar_db_get_count_with_query( calendar_query_h query, int *count );
/**
- * @brief Inserts multiple records as batch operation to the calendar database.
+ * @brief Inserts multiple records into the calendar database as a batch operation.
*
- * @param[in] record_list The record list handle
- * @param[out] record_id_array The record IDs
- * @param[out] count The number of record ID array
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.write
*
- * @return 0 on success, otherwise a negative error value.
+ * @param[in] record_list The record list handle
+ * @param[out] record_id_array The array of record IDs
+ * @param[out] count The number of record IDs
+ *
+ * @return @c 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
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
+ * @retval #CALENDAR_ERROR_FILE_NO_SPACE File system is full
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
+ * @retval #CALENDAR_ERROR_NO_DATA Data does not exist
+ * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory
*
- * @pre This function requires an open connection to calendar service by calendar_connect().
+ * @pre calendar_connect() should be called to open a connection to the calendar service.
*
* @see calendar_connect()
* @see calendar_db_update_records()
* @see calendar_db_delete_records()
- * @see calendar_db_insert_records_async()
*/
-API int calendar_db_insert_records( calendar_list_h record_list, int** record_id_array, int* count);
+int calendar_db_insert_records( calendar_list_h record_list, int** record_id_array, int* count);
/**
- * @brief Inserts multiple records as batch operation to the calendar database.
+ * @brief Updates multiple records into the calendar database as a batch operation.
*
- * @param[in] record_list The record list handle
- * @param[in] callback The callback function to invoke which lets you know result of batch operation
- * @param[in] user_data The user data to be passed to the callback function
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.write
+ *
+ * @param[in] record_list The record list handle
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 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
+ * @retval #CALENDAR_ERROR_NO_DATA Data does not exist
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CALENDAR_ERROR_DB_RECORD_NOT_FOUND Database not found
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
*
- * @pre This function requires an open connection to calendar service by calendar_connect().
+ * @pre calendar_connect() should be called to open a connection to the calendar service.
*
* @see calendar_connect()
- * @see calendar_db_update_records()
+ * @see calendar_db_insert_records()
* @see calendar_db_delete_records()
- * @see calendar_db_insert_result_cb
*/
-API int calendar_db_insert_records_async( calendar_list_h record_list, calendar_db_insert_result_cb callback, void *user_data);
+int calendar_db_update_records( calendar_list_h record_list);
/**
- * @brief Updates multiple records as batch operation to the calendar database.
+ * @brief Deletes multiple records with related child records from the calendar database as a batch operation.
*
- * @param[in] record_list The record list handle
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.write
+ *
+ * @param[in] view_uri The view URI of the records to delete
+ * @param[in] record_id_array The record IDs to delete
+ * @param[in] count The number of records
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 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
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
+ * @retval #CALENDAR_ERROR_DB_RECORD_NOT_FOUND Database not found
+ * @retval #CALENDAR_ERROR_FILE_NO_SPACE File system is full
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
+ * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory
*
- * @pre This function requires an open connection to calendar service by calendar_connect().
+ * @pre calendar_connect() should be called to open a connection to the calendar service.
*
* @see calendar_connect()
* @see calendar_db_insert_records()
* @see calendar_db_delete_records()
- * @see calendar_db_update_records_async()
*/
-API int calendar_db_update_records( calendar_list_h record_list);
+int calendar_db_delete_records(const char* view_uri, int record_id_array[], int count);
/**
- * @brief Updates multiple records as batch operation to the calendar database.
+ * @brief Gets the current calendar database version.
*
- * @param[in] record_list The record list handle
- * @param[in] callback The callback function to invoke which lets you know result of batch operation
- * @param[in] user_data The user data to be passed to the callback function
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.read
*
- * @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
+ * @param[out] calendar_db_version The calendar database version
+ *
+ * @return @c 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
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ * @retval ##CALENDAR_ERROR_DB_RECORD_NOT_FOUND Database not found
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
*
- * @pre This function requires an open connection to calendar service by calendar_connect().
+ * @pre This function requires an open connection to the calendar service using calendar_connect().
*
* @see calendar_connect()
- * @see calendar_db_insert_records()
- * @see calendar_db_delete_records()
- * @see calendar_db_result_cb
+ * @see calendar_db_get_changes_by_version()
+ */
+int calendar_db_get_current_version(int* calendar_db_version);
+
+/**
+ * @brief Registers a callback function to be invoked when a record changes.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.read
+ *
+ * @remarks If successive change notification produced on the view_uri are identical,
+ * then they are coalesced into a single notification if the older notification has not yet been called
+ * because default main loop is doing something.
+ * But, it means that a callback function is not called to reliably count of change.
+ * This API supports only @ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_book view, @ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_event view,
+ * @ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_todo view.
+ *
+ * @param[in] view_uri The view URI of the record to subscribe for change notifications
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #CALENDAR_ERROR_NONE Successful
+ * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_SYSTEM Error from another modules
+ * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ *
+ * @pre This function requires an open connection to the calendar service using calendar_connect().
+ * @post calendar_db_changed_cb() will be invoked when the designated view changes.
+ *
+ * @see calendar_connect()
+ * @see calendar_db_changed_cb()
+ * @see calendar_db_remove_changed_cb()
+ */
+int calendar_db_add_changed_cb(const char* view_uri, calendar_db_changed_cb callback, void* user_data );
+
+/**
+ * @brief Unregisters a callback function.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.read
+ *
+ * @param[in] view_uri The view URI of the record to subscribe for change notifications
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #CALENDAR_ERROR_NONE Successful
+ * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_SYSTEM Error from another modules
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ *
+ * @pre This function requires an open connection to the calendar service using calendar_connect().
+ *
+ * @see calendar_connect()
+ * @see calendar_db_changed_cb()
+ * @see calendar_db_add_changed_cb()
*/
-API int calendar_db_update_records_async( calendar_list_h record_list, calendar_db_result_cb callback, void *user_data);
+int calendar_db_remove_changed_cb( const char* view_uri, calendar_db_changed_cb callback, void* user_data );
/**
- * @brief Deletes multiple records as batch operation to the calendar database.
+ * @brief Retrieves records with the given calendar database version.
*
- * @param[in] view_uri The view URI of records
- * @param[in] record_id_array The record IDs to delete
- * @param[in] count The number of record ID array
+ * @details This function finds all the changed records since the given @a calendar_db_version.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.read
*
- * @return 0 on success, otherwise a negative error value.
+ * @remarks You must release @a change_record_list using calendar_list_destroy().
+ *
+ * @param[in] view_uri The view URI to get records from
+ * @param[in] calendar_book_id The calendar book ID to filter
+ * @param[in] calendar_db_version The calendar database version
+ * @param[out] record_list The record list
+ * @param[out] current_calendar_db_version The current calendar database version
+ *
+ * @return @c 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
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ * @retval #CALENDAR_ERROR_DB_RECORD_NOT_FOUND Database not found
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
*
- * @pre This function requires an open connection to calendar service by calendar_connect().
+ * @pre calendar_connect() should be called to open a connection to the calendar service.
*
* @see calendar_connect()
- * @see calendar_db_insert_records()
- * @see calendar_db_delete_records()
- * @see calendar_db_delete_records_async()
+ * @see calendar_list_destroy()
*/
-API int calendar_db_delete_records(const char* view_uri, int record_id_array[], int count);
+int calendar_db_get_changes_by_version(const char* view_uri, int calendar_book_id, int calendar_db_version, calendar_list_h* record_list, int *current_calendar_db_version );
/**
- * @brief Deletes multiple records as batch operation to the calendar database.
+ * @brief Inserts a vcalendar stream into the calendar database.
*
- * @param[in] view_uri The view URI of records
- * @param[in] record_id_array The record IDs to delete
- * @param[in] count The number of record ID array
- * @param[in] callback The callback function to invoke which lets you know result of batch operation
- * @param[in] user_data The user data to be passed to the callback function
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.write
*
- * @return 0 on success, otherwise a negative error value.
+ * @param[in] vcalendar_stream The vcalendar stream
+ * @param[out] record_id_array The record IDs to delete
+ * @param[out] count The number of record ID arrays
+ *
+ * @return @c 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
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ * @retval #CALENDAR_ERROR_NO_DATA Data does not exist
+ * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CALENDAR_ERROR_FILE_NO_SPACE File system is full
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
*
- * @pre This function requires an open connection to calendar service by calendar_connect().
+ * @pre calendar_connect() should be called to open a connection to the calendar service.
*
* @see calendar_connect()
- * @see calendar_db_insert_records()
- * @see calendar_db_delete_records()
- * @see calendar_db_result_cb()
+ * @see calendar_db_replace_vcalendars()
*/
-API int calendar_db_delete_records_async(const char* view_uri, int record_id_array[], int count, calendar_db_result_cb callback, void *user_data);
+int calendar_db_insert_vcalendars(const char* vcalendar_stream, int **record_id_array, int *count);
/**
- * @brief Gets the current calendar database version.
+ * @brief Replaces a vcalendar stream in the calendar database.
*
- * @param[out] calendar_db_version The calendar database version
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.write
*
- * @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
+ * @param[in] vcalendar_stream The vcalendar stream
+ * @param[in] record_id_array The record IDs to replace
+ * @param[in] count The number of record ID arrays
+ *
+ * @return @c 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
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CALENDAR_ERROR_NO_DATA Data does not exist
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
+ * @retval #CALENDAR_ERROR_DB_RECORD_NOT_FOUND Database not found
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
*
* @pre This function requires an open connection to the calendar service by calendar_connect().
*
* @see calendar_connect()
- * @see calendar_db_get_changes_by_version()
+ * @see calendar_db_replace_vcalendars()
*/
-API int calendar_db_get_current_version(int* calendar_db_version);
+int calendar_db_replace_vcalendars(const char* vcalendar_stream, int *record_id_array, int count);
/**
- * @brief Registers a callback function to be invoked when the record changes.
+ * @brief Replaces a record in the calendar database.
*
- * @param[in] view_uri The view URI of record to subscribe to changing notifications
- * @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.write
*
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @param[in] record The record handle
+ * @param[in] record_id The record ID
+ *
+ * @return @c 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
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ * @retval #CALENDAR_ERROR_FILE_NO_SPACE File system is full
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
+ * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory
*
- * @pre This function requires an open connection to the calendar service by calendar_connect().
- * @post calendar_db_changed_cb() will be invoked when the designated view changes.
+ * @pre calendar_connect() should be called to open a connection to the calendar service.
*
* @see calendar_connect()
- * @see calendar_db_changed_cb()
- * @see calendar_db_remove_changed_cb()
+ * @see calendar_db_update_record()
+ * @see calendar_db_delete_record()
+ * @see calendar_db_get_record()
*/
-API int calendar_db_add_changed_cb(const char* view_uri, calendar_db_changed_cb callback, void* user_data );
+int calendar_db_replace_record(calendar_record_h record, int record_id);
/**
- * @brief Unregisters a callback function.
+ * @brief Replaces multiple records in the calendar database as a batch operation.
*
- * @param[in] view_uri The view URI of record to subscribe to changing notifications
- * @param[in] callback The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.write
*
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @param[in] record_list The record list handle
+ * @param[in] record_id_array The record IDs
+ * @param[in] count The number of record ID arrays
*
- * @pre This function requires an open connection to the calendar service by calendar_connect().
+ * @return @c 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
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ * @retval #CALENDAR_ERROR_FILE_NO_SPACE File system is full
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
+ * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @pre calendar_connect() should be called to open a connection to the calendar service.
*
* @see calendar_connect()
- * @see calendar_db_changed_cb()
- * @see calendar_db_add_changed_cb()
+ * @see calendar_db_update_records()
+ * @see calendar_db_delete_records()
+ * @see calendar_db_replace_record()
*/
-API int calendar_db_remove_changed_cb( const char* view_uri, calendar_db_changed_cb callback, void* user_data );
+int calendar_db_replace_records(calendar_list_h record_list, int *record_id_array, int count);
/**
- * @brief Retrieves records with the calendar database version.
+ * @brief Gets the last successful change version of the database on the current connection.
*
- * @details This function will find all changed records since the given @a calendar_db_version
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.read
*
- * @remarks @a change_record_list must be released with calendar_list_destroy() by you.
+ * @param[out] last_change_version The calendar database version on the current connection
*
- * @param[in] view_uri The view URI to get records
- * @param[in] calendar_book_id The calendar book ID to filter
- * @param[in] calendar_db_version The calendar database version
- * @param[out] record_list The record list
- * @param[out] current_calendar_db_version The current calendar database version
- *
- * @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
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #CALENDAR_ERROR_NONE Successful
+ * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
*
- * @pre This function requires an open connection to calendar service by calendar_connect().
+ * @pre This function requires an open connection to the calendar service using calendar_connect().
*
* @see calendar_connect()
- * @see calendar_list_destroy()
+ * @see calendar_db_get_current_version()
*/
-API int calendar_db_get_changes_by_version(const char* view_uri, int calendar_book_id, int calendar_db_version, calendar_list_h* record_list, int *current_calendar_db_version );
+int calendar_db_get_last_change_version(int* last_change_version);
/**
- * @brief Inserts vcalendar stream to the calendar database.
+ * @brief Retrieves changed exception records since the given calendar database version.
+ * Exceptions are the modified or deleted instances in a recurring event.
*
- * @param[in] vcalendar_stream The vcalendar stream
- * @param[out] record_id_array The record IDs to delete
- * @param[out] count The number of record ID array
+ * @details This function finds all the changed records since the given @a calendar_db_version.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.read
+ *
+ * @remarks You must release @a change_record_list using calendar_list_destroy().
+ *
+ * @param[in] view_uri The view URI to get records from
+ * @param[in] original_event_id The original event ID
+ * @param[in] calendar_db_version The calendar database version starting from which to get records
+ * @param[out] list The record list
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 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
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
*
- * @pre This function requires an open connection to calendar service by calendar_connect().
+ * @pre calendar_connect() should be called to open a connection to the calendar service.
*
* @see calendar_connect()
- * @see calendar_db_replace_vcalendars()
+ * @see calendar_list_destroy()
*/
-API int calendar_db_insert_vcalendars(const char* vcalendar_stream, int **record_id_array, int *count);
+int calendar_db_get_changes_exception_by_version(const char* view_uri, int original_event_id, int calendar_db_version, calendar_list_h* list);
/**
- * @brief Inserts vcalendar stream to the calendar database.
+ * @internal
+ * @brief Called to get the result of a batch operation.
*
- * @param[in] vcalendar_stream The vcalendar stream
- * @param[in] callback The callback function to invoke which lets you know result of batch operation
- * @param[in] user_data The user data to be passed to the callback function
+ * @since_tizen 2.3
+ *
+ * @param[in] error Error code for the batch operation
+ * @param[in] user_data The user data passed from the batch operation
+ *
+ * @return @c true to continue with the next iteration of the loop or @c false to break out of the loop
+ *
+ * @pre calendar_db_update_records_async() will invoke this callback.
+ *
+ * @see calendar_db_update_records_async()
+ */
+typedef void (*calendar_db_result_cb)( int error, void *user_data);
+
+/**
+ * @internal
+ * @brief Called to get the result of a batch operation.
+ *
+ * @since_tizen 2.3
+ *
+ * @param[in] error Error code for the batch operation
+ * @param[in] record_id_array The record IDs for the batch operation
+ * @param[in] count The number of record ID array
+ * @param[in] user_data The user data passed from the batch operation
+ *
+ * @return @c true to continue with the next iteration of the loop or @c false to break out of the loop
+ *
+ * @pre calendar_db_insert_records_async() will invoke this callback.
+ *
+ * @see calendar_db_insert_records_async()
+ */
+typedef void (*calendar_db_insert_result_cb)( int error, int* record_id_array, int count, void *user_data);
+
+/**
+ * @internal
+ * @brief Inserts multiple records to the calendar database as a batch operation.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.write
+ *
+ * @param[in] record_list The record list handle
+ * @param[in] callback The callback function to invoke, lets you know the result of the batch operation
+ * @param[in] user_data The user data to be passed to the callback function
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 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
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
+ * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory
*
- * @pre This function requires an open connection to calendar service by calendar_connect().
+ * @pre calendar_connect() should be called to open a connection to the calendar service.
*
* @see calendar_connect()
- * @see calendar_db_replace_vcalendars()
- * @see calendar_db_insert_result_cb
+ * @see calendar_db_update_records()
+ * @see calendar_db_delete_records()
+ * @see calendar_db_insert_result_cb()
*/
-API int calendar_db_insert_vcalendars_async(const char* vcalendar_stream, calendar_db_insert_result_cb callback, void *user_data);
+int calendar_db_insert_records_async(calendar_list_h record_list, calendar_db_insert_result_cb callback, void *user_data);
/**
- * @brief Replaces vcalendar stream to the calendar database.
+ * @internal
+ * @brief Updates multiple records in the calendar database as a batch operation.
*
- * @param[in] vcalendar_stream The vcalendar stream
- * @param[in] record_id_array The record IDs to replace
- * @param[in] count The number of record ID array
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.write
+ *
+ * @param[in] record_list The record list handle
+ * @param[in] callback The callback function to invoke, lets you know result of the batch operation
+ * @param[in] user_data The user data to be passed to the callback function
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 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
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
+ * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory
*
- * @pre This function requires an open connection to calendar service by calendar_connect().
+ * @pre calendar_connect() should be called to open a connection to the calendar service.
*
* @see calendar_connect()
- * @see calendar_db_replace_vcalendars()
+ * @see calendar_db_insert_records()
+ * @see calendar_db_delete_records()
+ * @see calendar_db_result_cb()
*/
-API int calendar_db_replace_vcalendars(const char* vcalendar_stream, int *record_id_array, int count);
+int calendar_db_update_records_async(calendar_list_h record_list, calendar_db_result_cb callback, void *user_data);
/**
- * @brief Replaces vcalendar stream to the calendar database.
+ * @internal
+ * @brief Deletes multiple records with related child records from the calendar database as a batch operation .
*
- * @param[in] vcalendar_stream The vcalendar stream
- * @param[in] record_id_array The record IDs to replace
- * @param[in] count The number of record ID array
- * @param[in] callback The callback function to invoke which lets you know result of batch operation
- * @param[in] user_data The user data to be passed to the callback function
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.write
*
- * @return 0 on success, otherwise a negative error value.
+ * @param[in] view_uri The view URI of the records to delete
+ * @param[in] record_id_array The record IDs to delete
+ * @param[in] count The number of records
+ * @param[in] callback The callback function to be invoked which lets you know the result of the batch operation
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return @c 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
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
+ * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory
*
- * @pre This function requires an open connection to calendar service by calendar_connect().
+ * @pre calendar_connect() should be called to open a connection to the calendar service.
*
* @see calendar_connect()
- * @see calendar_db_replace_vcalendars()
+ * @see calendar_db_insert_records()
+ * @see calendar_db_delete_records()
+ * @see calendar_db_result_cb()
*/
-API int calendar_db_replace_vcalendars_async(const char* vcalendar_stream, int *record_id_array, int count, calendar_db_result_cb callback, void *user_data);
+int calendar_db_delete_records_async(const char* view_uri, int record_id_array[], int count, calendar_db_result_cb callback, void *user_data);
/**
- * @brief Replaces a record to the calendar database.
+ * @internal
+ * @brief Inserts a vcalendar stream to the calendar database.
*
- * @param[in] record The record handle
- * @param[in] record_id The record ID
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.write
*
- * @return 0 on success, otherwise a negative error value.
+ * @param[in] vcalendar_stream The vcalendar stream
+ * @param[in] callback The callback function to be invoked which lets you know result of batch operation
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return @c 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
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
+ * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory
*
- * @pre This function requires an open connection to calendar service by calendar_connect().
+ * @pre calendar_connect() should be called to open a connection to the calendar service.
*
* @see calendar_connect()
- * @see calendar_db_update_record()
- * @see calendar_db_delete_record()
- * @see calendar_db_get_record()
+ * @see calendar_db_replace_vcalendars()
+ * @see calendar_db_insert_result_cb
*/
-API int calendar_db_replace_record(calendar_record_h record, int record_id);
+int calendar_db_insert_vcalendars_async(const char* vcalendar_stream, calendar_db_insert_result_cb callback, void *user_data);
/**
- * @brief Replaces multiple records as batch operation to the calendar database.
+ * @internal
+ * @brief Replaces a vcalendar stream in the calendar database.
*
- * @param[in] record_list The record list handle
- * @param[in] record_id_array The record IDs
- * @param[in] count The number of record ID array
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.write
+ *
+ * @param[in] vcalendar_stream The vcalendar stream
+ * @param[in] record_id_array The record IDs to replace
+ * @param[in] count The number of record ID array
+ * @param[in] callback The callback function to be invoked which lets you know result of batch operation
+ * @param[in] user_data The user data to be passed to the callback function
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 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
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
+ * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory
*
- * @pre This function requires an open connection to calendar service by calendar_connect().
+ * @pre calendar_connect() should be called to open a connection to the calendar service.
*
* @see calendar_connect()
- * @see calendar_db_update_records()
- * @see calendar_db_delete_records()
- * @see calendar_db_replace_record()
- * @see calendar_db_replace_records_async()
+ * @see calendar_db_replace_vcalendars()
*/
-API int calendar_db_replace_records(calendar_list_h record_list, int *record_id_array, int count);
+int calendar_db_replace_vcalendars_async(const char* vcalendar_stream, int *record_id_array, int count, calendar_db_result_cb callback, void *user_data);
/**
- * @brief Replaces multiple records as batch operation to the calendar database.
+ * @internal
+ * @brief Replaces multiple records in the calendar database as a batch operation.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.write
*
* @param[in] record_list The record list handle
* @param[in] record_id_array The record IDs
* @param[in] callback The callback function to invoke which lets you know result of batch operation
* @param[in] user_data The user data to be passed to the callback function
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 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
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
+ * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory
*
- * @pre This function requires an open connection to calendar service by calendar_connect().
+ * @pre calendar_connect() should be called to open a connection to the calendar service.
*
* @see calendar_connect()
* @see calendar_db_update_records()
* @see calendar_db_replace_record()
* @see calendar_db_result_cb
*/
-API int calendar_db_replace_records_async(calendar_list_h record_list, int *record_id_array, int count, calendar_db_result_cb callback, void *user_data);
+int calendar_db_replace_records_async(calendar_list_h record_list, int *record_id_array, int count, calendar_db_result_cb callback, void *user_data);
/**
- * @brief Gets the last change calendar database version on current connection.
+ * @brief Cleans the data after sync.
*
- * @param[out] last_change_version The calendar database version on current connection
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.write
+
+ * @param[in] calendar_book_id The calendar book ID
+ * @param[in] calendar_db_version 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
+ * @return @c 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
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #CALENDAR_ERROR_FILE_NO_SPACE File system is full
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
+ * @retval #CALENDAR_ERROR_NO_DATA Data does not exist
*
- * @pre This function requires an open connection to the calendar service by calendar_connect().
+ * @pre calendar_connect() should be called to open a connection to the calendar service.
*
* @see calendar_connect()
- * @see calendar_db_get_current_version()
*/
-API int calendar_db_get_last_change_version(int* last_change_version);
+int calendar_db_clean_after_sync( int calendar_book_id, int calendar_db_version );
/**
* @}
}
#endif
-#endif /* __TIZEN_SOCAIL_CALENDAR_DB_H__ */
+#endif /* __TIZEN_SOCIAL_CALENDAR_DB_H__ */
*
*/
-#ifndef __TIZEN_SOCAIL_CALENDAR_ERROR_H__
-#define __TIZEN_SOCAIL_CALENDAR_ERROR_H__
+#ifndef __TIZEN_SOCIAL_CALENDAR_ERROR_H__
+#define __TIZEN_SOCIAL_CALENDAR_ERROR_H__
#include <tizen.h>
#endif
/**
- * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_LIST_MODULE
+ * @file calendar_errors.h
+ */
+
+/**
+ * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_COMMON_MODULE
* @{
*/
+/**
+ * @brief Enumeration for calendar errors.
+ * @since_tizen 2.3
+ */
typedef enum
{
- CALENDAR_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
- CALENDAR_ERROR_DB_FAILED = TIZEN_ERROR_SOCIAL_CLASS | 0x02, /**< No access to database */
- CALENDAR_ERROR_DB_RECORD_NOT_FOUND = TIZEN_ERROR_SOCIAL_CLASS | 0x05, /**< Not found database */
- CALENDAR_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
- CALENDAR_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
- CALENDAR_ERROR_NO_DATA = TIZEN_ERROR_SOCIAL_CLASS | 0x03, /**< Requested data does not exist */
- CALENDAR_ERROR_ITERATOR_END = TIZEN_ERROR_SOCIAL_CLASS | 0x04, /**< Iterator is on last position */
- CALENDAR_ERROR_NOW_IN_PROGRESS = TIZEN_ERROR_NOW_IN_PROGRESS, /**< Operation now in progress */
- CALENDAR_ERROR_ALREADY_IN_PROGRESS = TIZEN_ERROR_ALREADY_IN_PROGRESS, /**< Operation already in progress */
- CALENDAR_ERROR_NOT_PERMITTED = TIZEN_ERROR_NOT_PERMITTED, /**< Operation not permitted */
- CALENDAR_ERROR_IPC = TIZEN_ERROR_SOCIAL_CLASS | 0xBF, /**< Unknown IPC error */
- CALENDAR_ERROR_FILE_NO_SPACE = TIZEN_ERROR_FILE_NO_SPACE_ON_DEVICE, /**< FS Full */
+ CALENDAR_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ CALENDAR_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ CALENDAR_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ CALENDAR_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA, /**< Requested data does not exist */
+ CALENDAR_ERROR_NOW_IN_PROGRESS = TIZEN_ERROR_NOW_IN_PROGRESS, /**< Operation now in progress */
+ CALENDAR_ERROR_ALREADY_IN_PROGRESS = TIZEN_ERROR_ALREADY_IN_PROGRESS, /**< Operation already in progress */
+ CALENDAR_ERROR_NOT_PERMITTED = TIZEN_ERROR_NOT_PERMITTED, /**< Operation not permitted */
+ CALENDAR_ERROR_FILE_NO_SPACE = TIZEN_ERROR_FILE_NO_SPACE_ON_DEVICE, /**< FS is full */
+ CALENDAR_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+ CALENDAR_ERROR_DB_FAILED = TIZEN_ERROR_CALENDAR | 0x02, /**< No access to the database */
+ CALENDAR_ERROR_ITERATOR_END = TIZEN_ERROR_CALENDAR | 0x04, /**< Iterator is on the last position */
+ CALENDAR_ERROR_DB_RECORD_NOT_FOUND = TIZEN_ERROR_CALENDAR | 0x05, /**< Database not found */
+ CALENDAR_ERROR_IPC = TIZEN_ERROR_CALENDAR | 0xBF, /**< Unknown IPC error */
+ CALENDAR_ERROR_SYSTEM = TIZEN_ERROR_CALENDAR | 0xEF, /**< Error from another modules */
} calendar_error_e;
/**
}
#endif
-#endif /* __TIZEN_SOCAIL_CALENDAR_ERROR_H__ */
+#endif /* __TIZEN_SOCIAL_CALENDAR_ERROR_H__ */
*
*/
-#ifndef __TIZEN_SOCAIL_CALENDAR_FILTER_H__
-#define __TIZEN_SOCAIL_CALENDAR_FILTER_H__
+#ifndef __TIZEN_SOCIAL_CALENDAR_FILTER_H__
+#define __TIZEN_SOCIAL_CALENDAR_FILTER_H__
-#include <calendar_types2.h>
+#include <calendar_types.h>
#ifndef API
#define API __attribute__ ((visibility("default")))
#endif
/**
+ * @file calendar_filter.h
+ */
+
+/**
* @addtogroup CAPI_SOCIAL_CALENDAR_SVC_FILTER_MODULE
* @{
*/
/**
- * @brief Creates a handle to filter.
+ * @brief Creates a filter handle.
+ *
+ * @since_tizen 2.3
*
- * @remarks @a filter must be released with calendar_filter_destroy() by you.
+ * @remarks You must release @a filter using calendar_filter_destroy().
*
- * @param[in] view_uri The view URI of a filter
- * @param[out] filter The filter handle
+ * @param[in] view_uri The view URI of a filter
+ * @param[out] filter The filter handle
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 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
*
+ * @pre calendar_connect() should be called to initialize.
+ *
* @see calendar_filter_destroy()
*/
-API int calendar_filter_create( const char* view_uri, calendar_filter_h* filter );
+int calendar_filter_create( const char* view_uri, calendar_filter_h* filter );
/**
- * @brief Destroys a filter handle.
+ * @brief Destroys a filter handle.
+ *
+ * @since_tizen 2.3
*
- * @param[in] filter The filter handle
+ * @param[in] filter The filter handle
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #CALENDAR_ERROR_NONE Successful
* @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see calendar_filter_create()
*/
-API int calendar_filter_destroy( calendar_filter_h filter );
+int calendar_filter_destroy( calendar_filter_h filter );
/**
- * @brief Adds a condition for string type property
+ * @brief Adds a condition for the string type property.
+ *
+ * @since_tizen 2.3
*
- * @param[in] filter The filter handle
- * @param[in] property_id The property ID to add a condition
- * @param[in] match The match flag
- * @param[in] match_value The match value
+ * @param[in] filter The filter handle
+ * @param[in] property_id The property ID to add a condition
+ * @param[in] match The match flag
+ * @param[in] match_value The match value
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #CALENDAR_ERROR_NONE Successful
* @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see calendar_filter_add_operator()
*/
-API int calendar_filter_add_str( calendar_filter_h filter, unsigned int property_id, calendar_match_str_flag_e match, const char* match_value );
+int calendar_filter_add_str( calendar_filter_h filter, unsigned int property_id, calendar_match_str_flag_e match, const char* match_value );
/**
- * @brief Adds a condition for integer type property
+ * @brief Adds a condition for the integer type property.
*
- * @param[in] filter The filter handle
- * @param[in] property_id The property ID to add a condition
- * @param[in] match The match flag
- * @param[in] match_value The match value
+ * @since_tizen 2.3
*
- * @return 0 on success, otherwise a negative error value.
+ * @param[in] filter The filter handle
+ * @param[in] property_id The property ID to add a condition
+ * @param[in] match The match flag
+ * @param[in] match_value The match value
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #CALENDAR_ERROR_NONE Successful
* @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see calendar_filter_add_operator()
*/
-API int calendar_filter_add_int( calendar_filter_h filter, unsigned int property_id, calendar_match_int_flag_e match, int match_value );
+int calendar_filter_add_int( calendar_filter_h filter, unsigned int property_id, calendar_match_int_flag_e match, int match_value );
/**
- * @brief Adds a condition for double type property
+ * @brief Adds a condition for the double type property.
+ *
+ * @since_tizen 2.3
*
- * @param[in] filter The filter handle
- * @param[in] property_id The property ID to add a condition
- * @param[in] match The match flag
- * @param[in] match_value The match value
+ * @param[in] filter The filter handle
+ * @param[in] property_id The property ID to add a condition
+ * @param[in] match The match flag
+ * @param[in] match_value The match value
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #CALENDAR_ERROR_NONE Successful
* @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see calendar_filter_add_operator()
*/
-API int calendar_filter_add_double( calendar_filter_h filter, unsigned int property_id, calendar_match_int_flag_e match, double match_value );
+int calendar_filter_add_double( calendar_filter_h filter, unsigned int property_id, calendar_match_int_flag_e match, double match_value );
/**
- * @brief Adds a condition for long long int type property
+ * @brief Adds a condition for the long long int type property.
+ *
+ * @since_tizen 2.3
*
- * @param[in] filter The filter handle
- * @param[in] property_id The property ID to add a condition
- * @param[in] match The match flag
- * @param[in] match_value The match value
+ * @param[in] filter The filter handle
+ * @param[in] property_id The property ID to add a condition
+ * @param[in] match The match flag
+ * @param[in] match_value The match value
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #CALENDAR_ERROR_NONE Successful
* @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see calendar_filter_add_operator()
*/
-API int calendar_filter_add_lli( calendar_filter_h filter, unsigned int property_id, calendar_match_int_flag_e match, long long int match_value );
+int calendar_filter_add_lli( calendar_filter_h filter, unsigned int property_id, calendar_match_int_flag_e match, long long int match_value );
/**
- * @brief Adds a condition for calendar_time_s type property
+ * @brief Adds a condition for the calendar_time_s type property.
*
- * @param[in] filter The filter handle
- * @param[in] property_id The property ID to add a condition
- * @param[in] match The match flag
- * @param[in] match_value The match value
+ * @since_tizen 2.3
*
- * @return 0 on success, otherwise a negative error value.
+ * @param[in] filter The filter handle
+ * @param[in] property_id The property ID to add a condition
+ * @param[in] match The match flag
+ * @param[in] match_value The match value
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #CALENDAR_ERROR_NONE Successful
* @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see calendar_filter_add_operator()
*/
-API int calendar_filter_add_caltime( calendar_filter_h filter, unsigned int property_id, calendar_match_int_flag_e match, calendar_time_s match_value );
+int calendar_filter_add_caltime( calendar_filter_h filter, unsigned int property_id, calendar_match_int_flag_e match, calendar_time_s match_value );
/**
- * @brief Adds a filter handle to filter handle.
+ * @brief Adds a child filter to a parent filter.
+ *
+ * @since_tizen 2.3
*
- * @param[in] parent_filter The parent filter handle
- * @param[in] child_filter The child filter handle
+ * @param[in] parent_filter The parent filter handle
+ * @param[in] child_filter The child filter handle
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #CALENDAR_ERROR_NONE Successful
* @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see calendar_filter_add_operator()
*/
+int calendar_filter_add_filter( calendar_filter_h parent_filter, calendar_filter_h child_filter);
-API int calendar_filter_add_filter( calendar_filter_h parent_filter, calendar_filter_h child_filter);
/**
- * @brief Adds a operator between conditions
+ * @brief Adds an operator between conditions.
+ *
+ * @since_tizen 2.3
*
- * @param[in] filter The filter handle
- * @param[in] operator_type The operator type
+ * @param[in] filter The filter handle
+ * @param[in] operator_type The operator type
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #CALENDAR_ERROR_NONE Successful
* @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see calendar_filter_add_str()
* @see calendar_filter_add_int()
- * @see calendar_filter_add_bool()
+ * @see calendar_filter_add_double()
+ * @see calendar_filter_add_caltime()
+ * @see calendar_filter_add_filter()
*/
-API int calendar_filter_add_operator( calendar_filter_h filter, calendar_filter_operator_e operator_type );
+int calendar_filter_add_operator( calendar_filter_h filter, calendar_filter_operator_e operator_type );
/**
* @}
}
#endif
-#endif /* __TIZEN_SOCAIL_CALENDAR_FILTER_H__ */
+#endif /* __TIZEN_SOCIAL_CALENDAR_FILTER_H__ */
--- /dev/null
+/*
+ * Calendar Service
+ *
+ * Copyright (c) 2010 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#ifndef __TIZEN_SOCIAL_CALENDAR_INTERNAL_H__
+#define __TIZEN_SOCIAL_CALENDAR_INTERNAL_H__
+
+#endif //__TIZEN_SOCIAL_CALENDAR_INTERNAL_H__
+
+
*
*/
-#ifndef __TIZEN_SOCAIL_CALENDAR_LIST_H__
-#define __TIZEN_SOCAIL_CALENDAR_LIST_H__
+#ifndef __TIZEN_SOCIAL_CALENDAR_LIST_H__
+#define __TIZEN_SOCIAL_CALENDAR_LIST_H__
-#include <calendar_types2.h>
+#include <calendar_types.h>
#ifndef API
#define API __attribute__ ((visibility("default")))
*/
/**
- * @brief Creates a handle to the calendar list.
+ * @brief Creates a calendar list handle.
*
- * @remarks @a calendar_list must be released with calendar_list_destroy() by you.
+ * @since_tizen 2.3
*
- * @param[out] calendar_list The calendar list handle
+ * @remarks You must release @a calendar_list using calendar_list_destroy().
*
- * @return 0 on success, otherwise a negative error value.
+ * @param[out] out_list The calendar list handle
+ *
+ * @return @c 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_INVALID_PARAMETER Invalid parameter
*
* @see calendar_list_destroy()
*/
-API int calendar_list_create( calendar_list_h* out_list );
+int calendar_list_create( calendar_list_h* out_list );
/**
* @brief Destroys a calendar list handle and releases all its resources.
*
- * @param[in] calendar_list The calendar list handle
+ * @since_tizen 2.3
+ *
+ * @param[in] list The calendar list handle
+ * @param[in] delete_record If @c true, child records are destroyed automatically,
+ * otherwise @c false
*
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #CALENDAR_ERROR_NONE Successful
+ * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see calendar_list_create()
*/
-API int calendar_list_destroy( calendar_list_h list, bool delete_record );
+int calendar_list_destroy( calendar_list_h list, bool delete_record );
/**
- * @brief Retrieves count of calendar entity from a calendar list.
+ * @brief Retrieves the number of calendar entities in a calendar list.
*
- * @param[in] calendar_list The calendar list handle
- * @param[out] count The count of calendar entity
+ * @since_tizen 2.3
*
- * @return 0 on success, otherwise a negative error value.
+ * @param[in] list The calendar list handle
+ * @param[out] count The count of the calendar entity
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #CALENDAR_ERROR_NONE Successful
* @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see calendar_list_add()
*/
-API int calendar_list_get_count( calendar_list_h list, int *count );
+int calendar_list_get_count( calendar_list_h list, int *count );
/**
- * @brief Adds a record handle to calendar list handle.
+ * @brief Adds a record to the calendar list.
+ *
+ * @since_tizen 2.3
*
- * @param[in] calendar_list The calendar list handle
- * @param[in] record The record handle
+ * @param[in] list The calendar list handle
+ * @param[in] record The record handle
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #CALENDAR_ERROR_NONE Successful
* @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see calendar_list_remove()
*/
-API int calendar_list_add( calendar_list_h list, calendar_record_h record );
+int calendar_list_add( calendar_list_h list, calendar_record_h record );
/**
- * @brief Removes a record handle to calendar list handle.
- * @details If the record is current record then current record is changed the next record.\n
- * If the record is the last record then current record will be NULL.
+ * @brief Removes a record from the calendar list.
+ * @details If the record is the current record, then the current record is changed to the next record.\n
+ * If the record is the last record then the current record will be @c NULL.
+ *
+ * @since_tizen 2.3
*
- * @param[in] calendar_list The calendar list handle
- * @param[in] record The record handle
+ * @param[in] list The calendar list handle
+ * @param[in] record The record handle
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 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 Requested data does not exist
*
* @see calendar_list_add()
*/
-API int calendar_list_remove( calendar_list_h list, calendar_record_h record );
+int calendar_list_remove( calendar_list_h list, calendar_record_h record );
/**
- * @brief Retrieves a record handle from calendar list handle.
- * @details The default current record is the first record
- * @remarks The @a record handle MUST NOT destroyed by you.
- * It is destroyed automatically when the @a calendar_list is destroyed.
+ * @brief Retrieves a record from the calendar list.
+ * @details The default current record is the first record.
*
- * @param[in] calendar_list The calendar list handle
- * @param[out] record The record handle
+ * @since_tizen 2.3
*
- * @return 0 on success, otherwise a negative error value.
+ * @remarks You MUST NOT destroy the @a record handle.
+ * It is destroyed automatically when the @a list is destroyed.
+ *
+ * @param[in] list The calendar list handle
+ * @param[out] record The record handle
+ *
+ * @return @c 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 Requested data does not exist
*/
-API int calendar_list_get_current_record_p( calendar_list_h list, calendar_record_h* record );
+int calendar_list_get_current_record_p( calendar_list_h list, calendar_record_h* record );
/**
- * @brief Moves a calendar list to previous position.
+ * @brief Moves a calendar list to the previous position.
+ *
+ * @since_tizen 2.3
*
- * @param[in] calendar_list The calendar list handle
+ * @param[in] list The calendar list handle
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 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 Requested data does not exist
*
* @see calendar_list_next()
*/
-API int calendar_list_prev( calendar_list_h list );
+int calendar_list_prev( calendar_list_h list );
/**
- * @brief Moves a calendar list to next position.
+ * @brief Moves a calendar list to the next position.
*
- * @param[in] calendar_list The calendar list handle
+ * @since_tizen 2.3
*
- * @return 0 on success, otherwise a negative error value.
+ * @param[in] list The calendar list handle
+ *
+ * @return @c 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 Requested data does not exist
*
* @see calendar_list_prev()
*/
-API int calendar_list_next( calendar_list_h list );
+int calendar_list_next( calendar_list_h list );
/**
- * @brief Moves a calendar list to the first position.
+ * @brief Moves a calendar list to the first position.
+ *
+ * @since_tizen 2.3
*
- * @param[in] calendar_list The calendar list handle
+ * @param[in] list The calendar list handle
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #CALENDAR_ERROR_NONE Successful
* @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see calendar_list_last()
*/
-API int calendar_list_first( calendar_list_h list );
+int calendar_list_first( calendar_list_h list );
/**
- * @brief Moves a calendar lis tto the last position.
+ * @brief Moves a calendar list to the last position.
+ *
+ * @since_tizen 2.3
*
- * @param[in] calendar_list The calendar list handle
+ * @param[in] list The calendar list handle
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #CALENDAR_ERROR_NONE Successful
* @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see calendar_list_first()
*/
-API int calendar_list_last( calendar_list_h list );
+int calendar_list_last( calendar_list_h list );
/**
* @}
}
#endif
-#endif /* __TIZEN_SOCAIL_CALENDAR_LIST_H__ */
+#endif /* __TIZEN_SOCIAL_CALENDAR_LIST_H__ */
*
*/
-#ifndef __TIZEN_SOCAIL_CALENDAR_QUERY_H__
-#define __TIZEN_SOCAIL_CALENDAR_QUERY_H__
+#ifndef __TIZEN_SOCIAL_CALENDAR_QUERY_H__
+#define __TIZEN_SOCIAL_CALENDAR_QUERY_H__
-#include <calendar_types2.h>
+#include <calendar_types.h>
#ifndef API
#define API __attribute__ ((visibility("default")))
#endif
/**
+ * @file calendar_query.h
+ */
+
+/**
* @addtogroup CAPI_SOCIAL_CALENDAR_SVC_QUERY_MODULE
* @{
*/
/**
- * @brief Creates a query handle.
+ * @brief Creates a query handle.
+ *
+ * @since_tizen 2.3
*
- * @remarks @a query must be released with calendar_query_destroy() by you.
+ * @remarks You must release @a query using calendar_query_destroy().
*
- * @param[in] view_uri The view URI of a query
- * @param[out] query The filter handle
+ * @param[in] view_uri The view URI of a query
+ * @param[out] query The filter handle
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 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_filter_destroy()
+ * @pre calendar_connect() should be called to initialize.
+ *
+ * @see calendar_query_destroy()
*/
-API int calendar_query_create( const char* view_uri, calendar_query_h* query );
+int calendar_query_create( const char* view_uri, calendar_query_h* query );
/**
- * @brief Destroys a query handle.
+ * @brief Destroys a query handle.
*
- * @param[in] query The query handle
+ * @since_tizen 2.3
*
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @param[in] query The query handle
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #CALENDAR_ERROR_NONE Successful
+ * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see calendar_query_create()
*/
-API int calendar_query_destroy( calendar_query_h query );
+int calendar_query_destroy( calendar_query_h query );
/**
- * @brief Adds property IDs for projection.
+ * @brief Adds property IDs for projection.
*
- * @param[in] query The query handle
- * @param[in] property_id_array The property ID array
- * @param[in] count The number of property IDs
+ * @details Property IDs can be of one of the properties of view_uri which is used in calendar_query_create().
*
- * @return 0 on success, otherwise a negative error value.
+ * @since_tizen 2.3
+ *
+ * @param[in] query The query handle
+ * @param[in] property_id_array The property ID array
+ * @param[in] count The number of property IDs
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #CALENDAR_ERROR_NONE Successful
* @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
*/
-API int calendar_query_set_projection(calendar_query_h query, unsigned int property_id_array[], int count);
+int calendar_query_set_projection(calendar_query_h query, unsigned int property_id_array[], int count);
/**
- * @brief Set distinct option for projection.
+ * @brief Sets the "distinct" option for projection.
*
- * @param[in] query The query handle
- * @param[in] set Set or unset
+ * @since_tizen 2.3
+ *
+ * @param[in] query The query handle
+ * @param[in] set If @c true it is set,
+ * otherwise if @c false it is unset
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #CALENDAR_ERROR_NONE Successful
* @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
*/
-API int calendar_query_set_distinct(calendar_query_h query, bool set);
+int calendar_query_set_distinct(calendar_query_h query, bool set);
/**
- * @brief Sets a filter handle to query handle.
+ * @brief Sets the filter for a query.
*
- * @param[in] query The query handle
- * @param[in] filter The filter handle
+ * @since_tizen 2.3
*
- * @return 0 on success, otherwise a negative error value.
+ * @param[in] query The query handle
+ * @param[in] filter The filter handle
+ *
+ * @return @c 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 Requested data does not exist
*
* @see calendar_query_add_operator()
*/
-API int calendar_query_set_filter(calendar_query_h query, calendar_filter_h filter);
+int calendar_query_set_filter(calendar_query_h query, calendar_filter_h filter);
/**
- * @brief Sets sort mode.
+ * @brief Sets the sort mode for a query.
+ *
+ * @since_tizen 2.3
*
- * @param[in] query The query handle
- * @param[in] property_id The property ID to sort
- * @param[in] is_ascending Ascending or decending
+ * @param[in] query The query handle
+ * @param[in] property_id The property ID to sort
+ * @param[in] is_ascending If @c true it sorts in the ascending order,
+ * otherwise if @c false it sorts in the descending order
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #CALENDAR_ERROR_NONE Successful
* @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
*/
-API int calendar_query_set_sort(calendar_query_h query, unsigned int property_id, bool is_ascending);
+int calendar_query_set_sort(calendar_query_h query, unsigned int property_id, bool is_ascending);
/**
}
#endif
-#endif /* __TIZEN_SOCAIL_CALENDAR_QUERY_H__ */
+#endif /* __TIZEN_SOCIAL_CALENDAR_QUERY_H__ */
*
*/
-#ifndef __TIZEN_SOCAIL_CALENDAR_RECORD_H__
-#define __TIZEN_SOCAIL_CALENDAR_RECORD_H__
+#ifndef __TIZEN_SOCIAL_CALENDAR_RECORD_H__
+#define __TIZEN_SOCIAL_CALENDAR_RECORD_H__
-#include <calendar_types2.h>
+#include <calendar_types.h>
#ifndef API
#define API __attribute__ ((visibility("default")))
#endif
/**
+ * @file calendar_record.h
+ */
+
+/**
* @addtogroup CAPI_SOCIAL_CALENDAR_SVC_RECORD_MODULE
* @{
*/
/**
- * @brief Creates a handle to the record.
+ * @brief Creates a record handle.
+ *
+ * @since_tizen 2.3
*
- * @remarks @a record must be released with calendar_record_destroy() by you.
+ * @remarks You must release @a record using calendar_record_destroy().
*
- * @param[in] view_uri The view uri
- * @param[out] record The record handle
+ * @param[in] view_uri The view URI
+ * @param[out] out_record The record handle
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 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_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
+ *
+ * @pre calendar_connect() should be called to initialize.
*
* @see calendar_record_destroy()
*/
-API int calendar_record_create( const char* view_uri, calendar_record_h* out_record );
+int calendar_record_create( const char* view_uri, calendar_record_h* out_record );
/**
* @brief Destroys a record handle and releases all its resources.
*
- * @param[in] record The record handle
+ * @since_tizen 2.3
*
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @param[in] record The record handle
+ * @param[in] delete_child If @c true, child records are destroyed automatically,
+ * otherwise @c false
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #CALENDAR_ERROR_NONE Successful
+ * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
*
- * @see calendar_list_create()
+ * @see calendar_record_create()
*/
-API int calendar_record_destroy( calendar_record_h record, bool delete_child );
+int calendar_record_destroy( calendar_record_h record, bool delete_child );
/**
- * @brief Makes a clone of a record handle.
+ * @brief Makes a clone of a record handle.
*
- * @remarks @a cloned_record must be released with calendar_record_destroy() by you.
+ * @since_tizen 2.3
*
- * @param[in] record The record handle
- * @param[out] cloned_record The cloned record handle
+ * @remarks You must release @a cloned_record using calendar_record_destroy().
*
- * @return 0 on success, otherwise a negative error value.
+ * @param[in] record The record handle
+ * @param[out] out_record The cloned record handle
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #CALENDAR_ERROR_NONE Successful
* @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
*
* @see calendar_record_destroy()
*/
-API int calendar_record_clone( calendar_record_h record, calendar_record_h* out_record );
+int calendar_record_clone( calendar_record_h record, calendar_record_h* out_record );
/**
- * @brief Gets uri string from a record handle.
+ * @brief Gets a URI string from a record.
+ *
+ * @since_tizen 2.3
*
- * @param[in] record The record handle
- * @param[out] uri The uri of record
+ * @param[in] record The record handle
+ * @param[out] uri The URI of the record
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #CALENDAR_ERROR_NONE Successful
* @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
*/
-API int calendar_record_get_uri_p( calendar_record_h record, char** uri );
+int calendar_record_get_uri_p( calendar_record_h record, char** uri );
/**
- * @brief Gets a string from a record handle.
+ * @brief Gets a string from a record.
*
- * @remarks @a value must be released with free() by you.
+ * @since_tizen 2.3
*
- * @param[in] record The record handle
- * @param[in] property_id The property ID
- * @param[out] value The value to be returned
+ * @remarks You must release @a value using free().
*
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @param[in] record The record handle
+ * @param[in] property_id The property ID
+ * @param[out] out_str The result value
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #CALENDAR_ERROR_NONE Successful
+ * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
*
* @see calendar_record_get_str_p()
* @see calendar_record_set_str()
*/
-API int calendar_record_get_str( calendar_record_h record, unsigned int property_id, char** out_str );
+int calendar_record_get_str( calendar_record_h record, unsigned int property_id, char** out_str );
/**
- * @brief Gets a string pointer from a record handle.
+ * @brief Gets a string pointer from a record.
*
- * @remarks @a value MUST NOT be released by you.
+ * @since_tizen 2.3
*
- * @param[in] record The record handle
- * @param[in] property_id The property ID
- * @param[out] value The value to be returned
+ * @remarks You MUST NOT release @a value.
*
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @param[in] record The record handle
+ * @param[in] property_id The property ID
+ * @param[out] out_str The result value
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #CALENDAR_ERROR_NONE Successful
+ * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
*
* @see calendar_record_get_str()
* @see calendar_record_set_str()
*/
-API int calendar_record_get_str_p( calendar_record_h record, unsigned int property_id, char** out_str );
+int calendar_record_get_str_p( calendar_record_h record, unsigned int property_id, char** out_str );
/**
- * @brief Gets a integer from a record handle.
+ * @brief Gets an integer value from a record.
*
- * @param[in] record The record handle
- * @param[in] property_id The property ID
- * @param[out] value The value to be returned
+ * @since_tizen 2.3
*
- * @return 0 on success, otherwise a negative error value.
+ * @param[in] record The record handle
+ * @param[in] property_id The property ID
+ * @param[out] out_value The result value
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #CALENDAR_ERROR_NONE Successful
* @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
*
* @see calendar_record_set_int()
*/
-API int calendar_record_get_int( calendar_record_h record, unsigned int property_id, int* out_value );
+int calendar_record_get_int( calendar_record_h record, unsigned int property_id, int* out_value );
/**
- * @brief Gets a double from a record handle.
+ * @brief Gets a double value from a record.
+ *
+ * @since_tizen 2.3
*
- * @param[in] record The record handle
- * @param[in] property_id The property ID
- * @param[out] value The value to be returned
+ * @param[in] record The record handle
+ * @param[in] property_id The property ID
+ * @param[out] out_value The result value
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #CALENDAR_ERROR_NONE Successful
* @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
*
* @see calendar_record_set_double()
*/
-API int calendar_record_get_double( calendar_record_h record, unsigned int property_id, double* out_value );
+int calendar_record_get_double( calendar_record_h record, unsigned int property_id, double* out_value );
/**
- * @brief Gets a long long integer from a record handle.
+ * @brief Gets a long long integer value from a record.
*
- * @param[in] record The record handle
- * @param[in] property_id The property ID
- * @param[out] value The value to be returned
+ * @since_tizen 2.3
*
- * @return 0 on success, otherwise a negative error value.
+ * @param[in] record The record handle
+ * @param[in] property_id The property ID
+ * @param[out] out_value The result value
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #CALENDAR_ERROR_NONE Successful
* @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
*
* @see calendar_record_set_lli()
*/
-API int calendar_record_get_lli( calendar_record_h record, unsigned int property_id, long long int* out_value );
+int calendar_record_get_lli( calendar_record_h record, unsigned int property_id, long long int* out_value );
/**
- * @brief Gets a caltime_caltime_s from a record handle.
+ * @brief Gets a calendar_caltime_s value from a record.
+ *
+ * @since_tizen 2.3
*
- * @param[in] record The record handle
- * @param[in] property_id The property ID
- * @param[out] value The value to be returned
+ * @param[in] record The record handle
+ * @param[in] property_id The property ID
+ * @param[out] out_value The result value
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #CALENDAR_ERROR_NONE Successful
* @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
*
* @see calendar_record_set_caltime()
*/
-API int calendar_record_get_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s* out_value );
+int calendar_record_get_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s* out_value );
/**
- * @brief Sets a string to a record handle.
+ * @brief Sets a string to a record.
+ *
+ * @since_tizen 2.3
*
- * @param[in] record The record handle
- * @param[in] property_id The property ID
- * @param[in] value The value to set
+ * @param[in] record The record handle
+ * @param[in] property_id The property ID
+ * @param[in] value The value to be set
*
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #CALENDAR_ERROR_NONE Successful
+ * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
*
* @see calendar_record_get_str()
* @see calendar_record_get_str_p()
*/
-API int calendar_record_set_str( calendar_record_h record, unsigned int property_id, const char* value );
+int calendar_record_set_str( calendar_record_h record, unsigned int property_id, const char* value );
/**
- * @brief Sets a integer to a record handle.
+ * @brief Sets an integer value to a record.
*
- * @param[in] record The record handle
- * @param[in] property_id The property ID
- * @param[in] value The value to set
+ * @since_tizen 2.3
*
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @param[in] record The record handle
+ * @param[in] property_id The property ID
+ * @param[in] value The value to be set
*
- * @see calendar_record_get_double()
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #CALENDAR_ERROR_NONE Successful
+ * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
+ *
+ * @see calendar_record_get_int()
*/
-API int calendar_record_set_int( calendar_record_h record, unsigned int property_id, int value );
+int calendar_record_set_int( calendar_record_h record, unsigned int property_id, int value );
/**
- * @brief Sets a double to a record handle.
+ * @brief Sets a double value to a record.
*
- * @param[in] record The record handle
- * @param[in] property_id The property ID
- * @param[in] value The value to set
+ * @since_tizen 2.3
*
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @param[in] record The record handle
+ * @param[in] property_id The property ID
+ * @param[in] value The value to be set
*
- * @see calendar_record_get_int()
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #CALENDAR_ERROR_NONE Successful
+ * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
+ *
+ * @see calendar_record_get_double()
*/
-API int calendar_record_set_double( calendar_record_h record, unsigned int property_id, double value );
+int calendar_record_set_double( calendar_record_h record, unsigned int property_id, double value );
/**
- * @brief Sets a long long integer to a record handle.
+ * @brief Sets a long long integer value to a record.
+ *
+ * @since_tizen 2.3
*
- * @param[in] record The record handle
- * @param[in] property_id The property ID
- * @param[in] value The value to set
+ * @param[in] record The record handle
+ * @param[in] property_id The property ID
+ * @param[in] value The value to be set
*
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #CALENDAR_ERROR_NONE Successful
+ * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
*
* @see calendar_record_get_lli()
*/
-API int calendar_record_set_lli( calendar_record_h record, unsigned int property_id, long long int value );
+int calendar_record_set_lli( calendar_record_h record, unsigned int property_id, long long int value );
/**
- * @brief Sets a long calendar_time_s to a record handle.
+ * @brief Sets a calendar_time_s value to a record.
*
- * @param[in] record The record handle
- * @param[in] property_id The property ID
- * @param[in] value The value to set
+ * @since_tizen 2.3
*
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @param[in] record The record handle
+ * @param[in] property_id The property ID
+ * @param[in] value The value to be set
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #CALENDAR_ERROR_NONE Successful
+ * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
*
* @see calendar_record_get_caltime()
*/
-API int calendar_record_set_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s value );
+int calendar_record_set_caltime( calendar_record_h record, unsigned int property_id, calendar_time_s value );
/**
- * @brief Adds a child record handle to a parent record handle.
+ * @brief Adds a child record to the parent record.
+ *
+ * @since_tizen 2.3
*
* @param[in] record The parent record handle
- * @param[in] property_id The property ID
- * @param[in] child_record The child record handle to be added to parent record handle
+ * @param[in] property_id The property ID
+ * @param[in] child_record The handle of the child record to be added to the parent record
*
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #CALENDAR_ERROR_NONE Successful
+ * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
*
* @see calendar_record_remove_child_record()
*/
-API int calendar_record_add_child_record( calendar_record_h record, unsigned int property_id, calendar_record_h child_record );
+int calendar_record_add_child_record( calendar_record_h record, unsigned int property_id, calendar_record_h child_record );
/**
- * @brief Removes a child record handle from a parent record handle.
+ * @brief Removes a child record from the parent record.
*
- * @param[in] record The parent record handle
- * @param[in] property_id The property ID
- * @param[in] child_record The child record handle to be removed from parent record handle
+ * @since_tizen 2.3
*
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @param[in] record The parent record handle
+ * @param[in] property_id The property ID
+ * @param[in] child_record The handle of the child record to be removed from the parent record
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #CALENDAR_ERROR_NONE Successful
+ * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
*
* @see calendar_record_add_child_record()
*/
-API int calendar_record_remove_child_record( calendar_record_h record, unsigned int property_id, calendar_record_h child_record );
+int calendar_record_remove_child_record( calendar_record_h record, unsigned int property_id, calendar_record_h child_record );
/**
- * @brief Gets a number of child record handle from a parent record handle.
+ * @brief Gets the number of child records in a record.
+ *
+ * @since_tizen 2.3
*
* @param[in] record The parent record handle
- * @param[in] property_id The property ID
- * @param[out] count The child record count
+ * @param[in] property_id The property ID
+ * @param[out] count The child record count
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #CALENDAR_ERROR_NONE Successful
* @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
*
* @see calendar_record_add_child_record()
* @see calendar_record_remove_child_record()
*/
-API int calendar_record_get_child_record_count( calendar_record_h record, unsigned int property_id,unsigned int* count );
+int calendar_record_get_child_record_count( calendar_record_h record, unsigned int property_id,unsigned int* count );
/**
- * @brief Gets a child record handle pointer from a parent record handle.
+ * @brief Gets a child record handle pointer from the parent record.
*
- * @remarks @a child_record MUST NOT be released by you. \n It is released when the parent record handle destroyed.
+ * @since_tizen 2.3
*
- * @param[in] record The record handle
- * @param[in] property_id The property ID
- * @param[in] index The index of child record
- * @param[out] child_record The child record handle pointer to be returned
+ * @remarks You MUST NOT release @a child_record. \n It is released when the parent record handle is destroyed.
*
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @param[in] record The record handle
+ * @param[in] property_id The property ID
+ * @param[in] index The index of the child record
+ * @param[out] child_record The child record handle pointer
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #CALENDAR_ERROR_NONE Successful
+ * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
*
* @see calendar_record_add_child_record()
* @see calendar_record_remove_child_record()
* @see calendar_record_get_child_record_count()
*/
-API int calendar_record_get_child_record_at_p( calendar_record_h record, unsigned int property_id, int index, calendar_record_h* child_record );
+int calendar_record_get_child_record_at_p( calendar_record_h record, unsigned int property_id, int index, calendar_record_h* child_record );
/**
- * @brief Makes a clone of a child record list handle from a parent record handle.
+ * @brief Makes a clone of a given record's child record list.
*
- * @remarks @a cloned_list MUST be released with calendar_list_destroy() by you.
+ * @since_tizen 2.3
*
- * @param[in] record The record handle
- * @param[in] property_id The property ID
- * @param[out] cloned_list The cloned list handle
+ * @remarks You must release @a cloned_list using calendar_list_destroy().
*
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @param[in] record The record handle
+ * @param[in] property_id The property ID
+ * @param[out] out_list The cloned list handle
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #CALENDAR_ERROR_NONE Successful
+ * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
*
* @see calendar_list_destroy()
*/
-API int calendar_record_clone_child_record_list( calendar_record_h record, unsigned int property_id, calendar_list_h* out_list );
+int calendar_record_clone_child_record_list( calendar_record_h record, unsigned int property_id, calendar_list_h* out_list );
/**
* @}
}
#endif
-#endif /* __TIZEN_SOCAIL_CALENDAR_RECORD_H__ */
+#endif /* __TIZEN_SOCIAL_CALENDAR_RECORD_H__ */
*
*/
-#ifndef __TIZEN_SOCAIL_CALENDAR_REMINDER_H__
-#define __TIZEN_SOCAIL_CALENDAR_REMINDER_H__
+#ifndef __TIZEN_SOCIAL_CALENDAR_REMINDER_H__
+#define __TIZEN_SOCIAL_CALENDAR_REMINDER_H__
-#include <calendar_types2.h>
+#include <calendar_types.h>
#ifndef API
#define API __attribute__ ((visibility("default")))
#endif
/**
- * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_REMINDER_MODULE
- * @{
- */
-
-/**
- * @brief Adds a receiver to get noti when alarm alerts.
- *
- * @remarks If failed to run appsvc, added receiver will be removed from the table.
- *
- * @param[in] pkgname The package name to add.
- * @param[in] extra_data_key The user defined key to be passed via appsvc.
- * @param[in] extra_data_value THe user defined value to be passed via appsvc.
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_DB_FAILED Database operation failure
- *
- * @see calendar_reminder_remove_receiver()
- */
-API int calendar_reminder_add_receiver(const char *pkgname, const char *extra_data_key, const char *extra_data_value);
-
-/**
- * @brief Removes a receiver to get noti when alarm alerts.
- *
- * @param[in] pkgname The package name to add.
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_DB_FAILED Database operation failure
- *
- * @see calendar_reminder_remove_receiver()
+ * @file calendar_reminder.h
*/
-API int calendar_reminder_remove_receiver(const char *pkgname);
/**
- * @brief Activates a receiver to get noti when alarm alerts.
- *
- * @param[in] pkgname The package name to add.
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_DB_FAILED Database operation failure
- *
- * @see calendar_reminder_remove_receiver()
+ * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_REMINDER_MODULE
+ * @{
*/
-API int calendar_reminder_activate_receiver(const char *pkgname);
/**
- * @brief Deactivates a receiver to get noti when alarm alerts.
+ * @brief Called when an alarm is alerted.
*
- * @param[in] pkgname The package name to add.
+ * @since_tizen 2.3
*
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_DB_FAILED Database operation failure
+ * @param[in] param Value string like id=value&time=value&tick=value&unit=value&type=value
+ * @param[in] user_data The user data passed from the callback registration function
*
- * @see calendar_reminder_remove_receiver()
+ * @see calendar_reminder_add_cb()
*/
-API int calendar_reminder_deactivate_receiver(const char *pkgname);
+typedef void (*calendar_reminder_cb)(const char *param, void* user_data);
/**
- * @brief Check whether receiver exist in the table or not.
+ * @brief Adds a callback to get a notification when an alarm alerts.
*
- * @param[in] pkgname The package name to add.
+ * @since_tizen 2.3
*
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_DB_FAILED Database operation failure
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/calendar.read
*
- * @see calendar_reminder_remove_receiver()
- */
-API int calendar_reminder_has_receiver(const char *pkgname);
-
-/**
- * @brief Adds callback to get noti when alarm alerts.
+ * @param[in] callback The callback to be added
+ * @param[in] user_data The user data
*
- * @param[in] callback Callback to add.
- * @param[in] user_data The user data
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_DB_FAILED Database operation failure
+ * @return @c 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_NOT_PERMITTED Operation not permitted
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
*
* @see calendar_reminder_remove_cb()
*/
-API int calendar_reminder_add_cb(calendar_reminder_cb callback, void *user_data);
+int calendar_reminder_add_cb(calendar_reminder_cb callback, void *user_data);
/**
- * @brief Removes callback to get noti when alarm alerts.
+ * @brief Removes a callback to get a notification when an alarm alerts.
+ *
+ * @since_tizen 2.3
*
- * @param[in] callback Callback to remove.
- * @param[in] user_data The user data
+ * @param[in] callback The callback to be removed
+ * @param[in] user_data The user data
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #CALENDAR_ERROR_NONE Successful
* @retval #CALENDAR_ERROR_DB_FAILED Database operation failure
*
* @see calendar_reminder_add_cb()
*/
-API int calendar_reminder_remove_cb(calendar_reminder_cb callback, void *user_data);
+int calendar_reminder_remove_cb(calendar_reminder_cb callback, void *user_data);
/**
* @}
}
#endif
-#endif /* __TIZEN_SOCAIL_CALENDAR_REMINDER_H__ */
+#endif /* __TIZEN_SOCIAL_CALENDAR_REMINDER_H__ */
*
*/
-#ifndef __TIZEN_SOCAIL_CALENDAR_SERVICE_H__
-#define __TIZEN_SOCAIL_CALENDAR_SERVICE_H__
+#ifndef __TIZEN_SOCIAL_CALENDAR_SERVICE_H__
+#define __TIZEN_SOCIAL_CALENDAR_SERVICE_H__
#ifndef API
#define API __attribute__ ((visibility("default")))
#endif
/**
- * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_DATABASE_MODULE
+ * @file calendar_service.h
+ */
+
+/**
+ * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
+ * @defgroup CAPI_SOCIAL_CALENDAR_SVC_COMMON_MODULE Common
+ * @brief The calendar common API provides the set of definitions and interfaces to initialize and deinitialize.
+ *
+ * @section CAPI_SOCIAL_CALENDAR_SVC_COMMON_MODULE_HEADER Required Header
+ * \#include <calendar.h>
+ *
+ * <BR>
* @{
*/
/**
- * @brief Connects to the calendar service.
+ * @brief Connects to the calendar service.
+ *
+ * @since_tizen 2.3
*
- * @remarks Connection opening is necessary to access the calendar database such as fetching, inserting, or updating records.\n
- * The execution of calendar_connect() and calendar_disconnect() could slow down your application so you are recommended not to call them frequently.
+ * @remarks Opening the connection is necessary to access the calendar database and perform operations such as fetching, inserting, or updating records.\n
+ * The execution of calendar_connect() and calendar_disconnect() could slow down your application, so you are recommended not to call them frequently.
*
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_DB_FAILED Database operation failure
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #CALENDAR_ERROR_NONE Successful
+ * @retval #CALENDAR_ERROR_DB_FAILED Database operation failure
+ * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
+ * @retval #CALENDAR_ERROR_SYSTEM Error from another modules
*
* @see calendar_disconnect()
*/
-API int calendar_connect(void);
+int calendar_connect(void);
/**
- * @brief Disconnects from the calendar service.
+ * @brief Disconnects from the calendar service.
+ *
+ * @since_tizen 2.3
*
- * @remarks If there is no opened connection, this function returns #CALENDAR_ERROR_DB_FAILED.
+ * @remarks If there is no opened connection, this function returns #CALENDAR_ERROR_DB_FAILED.
*
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_DB_FAILED Database operation failure
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #CALENDAR_ERROR_NONE Successful
+ * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
*
* @see calendar_connect()
*/
-API int calendar_disconnect(void);
+int calendar_disconnect(void);
/**
- * @brief Connects to the calendar service on thread.
+ * @brief Connects to the calendar service on a thread.
*
- * @remarks Connection opening is necessary to access the calendar database such as fetching, inserting, or updating records.\n
- * The execution of calendar_connect() and calendar_disconnect() could slow down your application so you are recommended not to call them frequently.
+ * @since_tizen 2.3
*
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_DB_FAILED Database operation failure
+ * @remarks Opening a connection is necessary to access the calendar database and perform operations such as fetching, inserting, or updating records.\n
+ * On a thread environment with calendar_connect(), request in one thread could fail, while another request connection is working in the other thread.
+ * To prevent request failure, calendar_connect_on_thread() is recommended.
*
- * @see calendar_disconnect()
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #CALENDAR_ERROR_NONE Successful
+ * @retval #CALENDAR_ERROR_DB_FAILED Database operation failure
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method
+ *
+ * @see calendar_disconnect_on_thread()
*/
-API int calendar_connect_on_thread(void);
+int calendar_connect_on_thread(void);
/**
- * @brief Disconnects from the calendar service on thread.
+ * @brief Disconnects from the calendar service on a thread.
+ *
+ * @since_tizen 2.3
*
* @remarks If there is no opened connection, this function returns #CALENDAR_ERROR_DB_FAILED.
*
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_DB_FAILED Database operation failure
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #CALENDAR_ERROR_NONE Successful
+ * @retval #CALENDAR_ERROR_DB_FAILED Database operation failure
+ * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
*
- * @see calendar_connect()
+ * @see calendar_connect_on_thread()
*/
-API int calendar_disconnect_on_thread(void);
+int calendar_disconnect_on_thread(void);
/**
- * @brief Connects to the calendar service.
+ * @brief Connects to the calendar service.
+ *
+ * @since_tizen 2.3
*
- * @remarks Connection opening is necessary to access the calendar database such as fetching, inserting, or updating records.\n
- * The execution of calendar_connect() and calendar_disconnect() could slow down your application so you are recommended not to call them frequently.
+ * @remarks Opening a connection is necessary to access the calendar database and perform operations such as fetching, inserting, or updating records.\n
+ * Before the calendar-service daemon is ready, if you call calendar_connect(), it could fail.
+ * It is recommended to call this API with #CALENDAR_CONNECT_FLAG_RETRY flags in such a situation.
*
* @param[in] flags calendar_connect_flag
*
- * @return 0 on success, otherwise a negative error value.
- * @retval #CALENDAR_ERROR_NONE Successful
- * @retval #CALENDAR_ERROR_DB_FAILED Database operation failure
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #CALENDAR_ERROR_NONE Successful
+ * @retval #CALENDAR_ERROR_DB_FAILED Database operation failure
+ * @retval #CALENDAR_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CALENDAR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CALENDAR_ERROR_NOT_PERMITTED Operation not permitted
+ * @retval #CALENDAR_ERROR_PERMISSION_DENIED Permission denied. This application does not have the privilege to call this method.
+ * @retval #CALENDAR_ERROR_IPC Unknown IPC error
+ * @retval #CALENDAR_ERROR_SYSTEM Error from another modules
*
* @see calendar_disconnect(), CALENDAR_CONNECT_FLAG_RETRY
*/
-API int calendar_connect_with_flags(unsigned int flags);
+int calendar_connect_with_flags(unsigned int flags);
+
/**
* @}
*/
}
#endif
-#endif /* __TIZEN_SOCAIL_CALENDAR_SERVICE_H__ */
+#endif /* __TIZEN_SOCIAL_CALENDAR_SERVICE_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TIZEN_SOCIAL_CALENDAR_TYPES_H__
+#define __TIZEN_SOCIAL_CALENDAR_TYPES_H__
+
+#include <stdint.h>
+#include <tizen.h>
+#include <calendar_errors.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#define _CALENDAR_HANDLE(A) typedef struct __##A* A;
+
+#define _CALENDAR_BEGIN_VIEW() \
+ typedef struct{ \
+ const char* _uri;
+#define _CALENDAR_PROPERTY_INT(property_id_name) unsigned int property_id_name;
+#define _CALENDAR_PROPERTY_STR(property_id_name) unsigned int property_id_name;
+#define _CALENDAR_PROPERTY_DOUBLE(property_id_name) unsigned int property_id_name;
+#define _CALENDAR_PROPERTY_LLI(property_id_name) unsigned int property_id_name;
+#define _CALENDAR_PROPERTY_CALTIME(property_id_name) unsigned int property_id_name;
+#define _CALENDAR_PROPERTY_CHILD_MULTIPLE(property_id_name) unsigned int property_id_name;
+#define _CALENDAR_END_VIEW(name) } name##_property_ids; \
+ extern API const name##_property_ids name;
+
+#define _CALENDAR_BEGIN_READ_ONLY_VIEW() \
+ typedef struct{ \
+ const char* _uri;
+#define _CALENDAR_PROPERTY_PROJECTION_INT(property_id_name) unsigned int property_id_name;
+#define _CALENDAR_PROPERTY_PROJECTION_STR(property_id_name) unsigned int property_id_name;
+#define _CALENDAR_PROPERTY_PROJECTION_DOUBLE(property_id_name) unsigned int property_id_name;
+#define _CALENDAR_PROPERTY_PROJECTION_LLI(property_id_name) unsigned int property_id_name;
+#define _CALENDAR_PROPERTY_PROJECTION_CALTIME(property_id_name) unsigned int property_id_name;
+#define _CALENDAR_PROPERTY_FILTER_INT(property_id_name) unsigned int property_id_name;
+#define _CALENDAR_PROPERTY_FILTER_STR(property_id_name) unsigned int property_id_name;
+#define _CALENDAR_PROPERTY_FILTER_DOUBLE(property_id_name) unsigned int property_id_name;
+#define _CALENDAR_PROPERTY_FILTER_LLI(property_id_name) unsigned int property_id_name;
+#define _CALENDAR_PROPERTY_FILTER_CALTIME(property_id_name) unsigned int property_id_name;
+#define _CALENDAR_END_READ_ONLY_VIEW(name) } name##_property_ids; \
+ extern API const name##_property_ids name;
+
+_CALENDAR_HANDLE( calendar_record_h )
+_CALENDAR_HANDLE( calendar_filter_h )
+_CALENDAR_HANDLE( calendar_list_h )
+_CALENDAR_HANDLE( calendar_query_h )
+
+
+/**
+ * @file calendar_types.h
+ */
+
+/**
+ * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_DATABASE_MODULE
+ * @{
+ */
+/**
+ * @brief Definition for a calendar connect flag.
+ *
+ * @since_tizen 2.3
+ */
+#define CALENDAR_CONNECT_FLAG_NONE 0x00000000
+/**
+ * @brief Definition for a calendar connect flag.
+ *
+ * @since_tizen 2.3
+ */
+#define CALENDAR_CONNECT_FLAG_RETRY 0x00000001
+
+/**
+ * @brief Definition for a default event calendar book database ID.
+ *
+ * @since_tizen 2.3
+ */
+#define DEFAULT_EVENT_CALENDAR_BOOK_ID 1
+
+/**
+ * @brief Definition for a default to-do calendar book database ID.
+ *
+ * @since_tizen 2.3
+ */
+#define DEFAULT_TODO_CALENDAR_BOOK_ID 2
+
+/**
+ * @brief Definition for a default birthday calendar book database ID.
+ *
+ * @since_tizen 2.3
+ */
+#define DEFAULT_BIRTHDAY_CALENDAR_BOOK_ID 3
+
+/**
+ * @brief Definition for no due date of a to-do.
+ *
+ * @since_tizen 2.3
+ */
+#define CALENDAR_TODO_NO_DUE_DATE INT64_MAX
+
+/**
+ * @brief Definition for no start date of a to-do.
+ *
+ * @since_tizen 2.3
+ */
+#define CALENDAR_TODO_NO_START_DATE (-INT64_MAX)
+
+/**
+ * @brief Definition for no until of a record.
+ *
+ * @since_tizen 2.3
+ */
+#define CALENDAR_RECORD_NO_UNTIL INT64_MAX
+
+/**
+ * @brief Definition for no coordinate(latitude/longitude) of a record.
+ *
+ * @since_tizen 2.3
+ */
+#define CALENDAR_RECORD_NO_COORDINATE 1000.0
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_FILTER_MODULE
+ * @{
+ */
+
+/**
+ * @brief Definition for all calendar books.
+ *
+ * @since_tizen 2.3
+ */
+#define CALENDAR_BOOK_FILTER_ALL -1
+
+/**
+ * @brief Enumeration for the filter match type of a string.
+ *
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ CALENDAR_MATCH_EXACTLY, /**< Full string, case-sensitive */
+ CALENDAR_MATCH_FULLSTRING, /**< Full string, case-insensitive */
+ CALENDAR_MATCH_CONTAINS, /**< Sub string, case-insensitive */
+ CALENDAR_MATCH_STARTSWITH, /**< Start with, case-insensitive */
+ CALENDAR_MATCH_ENDSWITH, /**< End with, case-insensitive */
+ CALENDAR_MATCH_EXISTS, /**< IS NOT NULL */
+ CALENDAR_MATCH_STR_MAX /**< Calendar match string flag max enum count */
+} calendar_match_str_flag_e;
+
+/**
+ * @brief Enumeration for the filter match type of an integer.
+ *
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ CALENDAR_MATCH_EQUAL, /**< '=' */
+ CALENDAR_MATCH_GREATER_THAN, /**< '>' */
+ CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, /**< '>=' */
+ CALENDAR_MATCH_LESS_THAN, /**< '<' */
+ CALENDAR_MATCH_LESS_THAN_OR_EQUAL, /**< '<=' */
+ CALENDAR_MATCH_NOT_EQUAL, /**< '<>', this flag can yield poor performance */
+ CALENDAR_MATCH_NONE, /**< IS NULL */
+ CALENDAR_MATCH_INT_MAX /**< Calendar match integer flag max enum count */
+} calendar_match_int_flag_e;
+
+/**
+ * @brief Enumeration for a filter operator.
+ *
+ * @since_tizen 2.3
+ */
+typedef enum {
+ CALENDAR_FILTER_OPERATOR_AND, /**< AND */
+ CALENDAR_FILTER_OPERATOR_OR, /**< OR */
+ CALENDAR_FILTER_OPERATOR_MAX /**< Calendar filter operator max enum count */
+} calendar_filter_operator_e;
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_RECORD_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumeration for the calendar book type.
+ *
+ * @details "OR"ing is supported.
+ *
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ CALENDAR_BOOK_TYPE_NONE = 0, /**< Default calendar book type */
+ 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 Enumeration for the calendar sensitivity type.
+ *
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ CALENDAR_SENSITIVITY_PUBLIC = 0, /**< Public Sensitivity */
+ CALENDAR_SENSITIVITY_PRIVATE, /**< Private Sensitivity */
+ CALENDAR_SENSITIVITY_CONFIDENTIAL /**< Confidential Sensitivity */
+} calendar_sensitivity_e;
+
+/**
+ * @brief Enumeration for the attendee status.
+ *
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ CALENDAR_ATTENDEE_STATUS_PENDING = 0, /**< Pending status */
+ CALENDAR_ATTENDEE_STATUS_ACCEPTED, /**< Accepted status */
+ CALENDAR_ATTENDEE_STATUS_DECLINED, /**< Declined 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 max enum count */
+}calendar_attendee_status_e;
+
+/**
+ * @brief Enumeration for the attendee role.
+ *
+ * @since_tizen 2.3
+ */
+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 max enum count */
+}calendar_attendee_role_e;
+
+/**
+ * @brief Enumeration for the attendee cutype.
+ *
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ CALENDAR_ATTENDEE_CUTYPE_INDIVIDUAL = 0, /**< Individual cutype */
+ CALENDAR_ATTENDEE_CUTYPE_GROUP, /**< Group cutype */
+ CALENDAR_ATTENDEE_CUTYPE_RESOURCE, /**< Resource cutype */
+ CALENDAR_ATTENDEE_CUTYPE_ROOM, /**< Room cutype */
+ CALENDAR_ATTENDEE_CUTYPE_UNKNOWN, /**< Unknown cutype */
+ CALENDAR_ATTENDEE_CUTYPE_MAX, /**< Calendar attendee cutype max enum count */
+}calendar_attendee_cutyep_e;
+
+/**
+ * @brief Enumeration for the alarm time unit type of an event, such as minutes, hours, days, and so on.
+ *
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ CALENDAR_ALARM_NONE = -1, /**< No reminder set */
+ CALENDAR_ALARM_TIME_UNIT_SPECIFIC = 1, /**< Specific in seconds */
+ CALENDAR_ALARM_TIME_UNIT_MINUTE = 60, /**< Alarm time unit in minutes */
+ CALENDAR_ALARM_TIME_UNIT_HOUR = 3600, /**< Alarm time unit in hours */
+ CALENDAR_ALARM_TIME_UNIT_DAY = 86400, /**< Alarm time unit in days */
+ CALENDAR_ALARM_TIME_UNIT_WEEK = 604800, /**< Alarm time unit in weeks */
+} calendar_alarm_time_unit_type_e;
+
+/**
+ * @brief Enumeration for the alarm action.
+ *
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ CALENDAR_ALARM_ACTION_AUDIO = 0, /**< Audio action */
+ CALENDAR_ALARM_ACTION_DISPLAY, /**< Display action */
+ CALENDAR_ALARM_ACTION_EMAIL, /**< Email action */
+ CALENDAR_ALARM_ACTION_MAX, /**< Calenar alarm action max enum count */
+}calendar_alarm_action_e;
+
+/**
+ * @brief Enumeration for the frequency of an event's recurrence.
+ *
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ CALENDAR_RECURRENCE_NONE, /**< No recurrence event */
+ CALENDAR_RECURRENCE_DAILY, /**< An event occurs every day */
+ CALENDAR_RECURRENCE_WEEKLY, /**< An event occurs on the same day of every week \n According to the week flag, the event will recur every day of the week */
+ CALENDAR_RECURRENCE_MONTHLY, /**< An event occurs on the same day of every month */
+ CALENDAR_RECURRENCE_YEARLY /**< An event occurs on the same day of every year */
+} calendar_recurrence_frequency_e;
+
+/**
+ * @brief Enumeration for the event status.
+ *
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ CALENDAR_EVENT_STATUS_NONE = 0x01, /**< No status */
+ 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 canceled */
+}calendar_event_status_e;
+
+/**
+ * @brief Enumeration for the busy status of an event.
+ *
+ * @since_tizen 2.3
+ */
+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 Enumeration for the calendar event item's priority.
+ *
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ CALENDAR_EVENT_PRIORITY_NONE = 0x01, /**< No priority */
+ CALENDAR_EVENT_PRIORITY_LOW = 0x08, /**< Low priority */
+ CALENDAR_EVENT_PRIORITY_NORMAL = 0x04, /**< Normal priority */
+ CALENDAR_EVENT_PRIORITY_HIGH = 0x02, /**< High priority */
+} calendar_event_priority_e;
+
+/**
+ * @brief Enumeration for the calendar to-do item's priority.
+ *
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ CALENDAR_TODO_PRIORITY_NONE = 0x01, /**< No priority */
+ 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 Enumeration for the status of a to-do.
+ *
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ CALENDAR_TODO_STATUS_NONE = 0x0100, /**< No status */
+ 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;
+
+/**
+ * @brief Enumeration for the time type.
+ *
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ CALENDAR_TIME_UTIME = 0, /**< Unix time */
+ CALENDAR_TIME_LOCALTIME, /**< Local time */
+} calendar_time_type_e;
+
+/**
+ * @brief Enumeration for the range type.
+ *
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ CALENDAR_RANGE_UNTIL, /**< Range until */
+ CALENDAR_RANGE_COUNT, /**< Range count */
+ CALENDAR_RANGE_NONE, /**< No range */
+} calendar_range_type_e;
+
+/**
+ * @brief Enumeration for the system type.
+ *
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ CALENDAR_SYSTEM_NONE, /**< Locale's default calendar */
+ CALENDAR_SYSTEM_GREGORIAN, /**< Locale's default calendar */
+ CALENDAR_SYSTEM_EAST_ASIAN_LUNISOLAR, /**< East asian lunisolar calendar */
+} calendar_system_type_e;
+
+/**
+ * @brief Enumeration for the meeting status.
+ *
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ CALENDAR_MEETING_STATUS_NOTMEETING = 0, /**< No meeting */
+ CALENDAR_MEETING_STATUS_MEETING, /**< Meeting exists */
+ CALENDAR_MEETING_STATUS_RECEIVED, /**< Meeting received */
+ CALENDAR_MEETING_STATUS_CANCELED, /**< Meeting canceled */
+} calendar_meeting_status_e;
+
+/**
+ * @brief Enumeration for weekdays.
+ * @details Same value as UCalendarDaysOfWeek in ICU.
+ *
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ CALENDAR_SUNDAY = 1, /**< Sunday */
+ CALENDAR_MONDAY, /**< Monday */
+ CALENDAR_TUESDAY, /**< Tuesday */
+ CALENDAR_WEDNESDAY, /**< Wednesday */
+ CALENDAR_THURSDAY, /**< Thursday */
+ CALENDAR_FRIDAY, /**< Friday */
+ CALENDAR_SATURDAY, /**< Saturday */
+}calendar_days_of_week_e;
+
+/**
+ * @brief Enumeration for the modified status of a record.
+ *
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ CALENDAR_RECORD_MODIFIED_STATUS_INSERTED = 0, /**< The record is inserted */
+ CALENDAR_RECORD_MODIFIED_STATUS_UPDATED, /**< The record is updated */
+ CALENDAR_RECORD_MODIFIED_STATUS_DELETED /**< The record is deleted */
+}calendar_record_modified_status_e;
+
+/**
+ * @brief The structure of time.
+ *
+ * @since_tizen 2.3
+ */
+typedef struct
+{
+ calendar_time_type_e type; /**< type */
+ union {
+ long long int utime; /**< utime */
+ struct {
+ int year; /**< year */
+ int month; /**< month */
+ int mday; /**< mday */
+ int hour; /**< hour */
+ int minute; /**< minute */
+ int second; /**< second */
+ bool is_leap_month; /**< Deprecated since 2.x:leap month */
+ }date;
+ }time;
+}calendar_time_s;
+
+/**
+ * @brief Enumeration for the type of a record.
+ *
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ CALENDAR_RECORD_TYPE_NONE = 0, /**< No record type */
+ CALENDAR_RECORD_TYPE_CALENDAR_BOOK, /**< Book type */
+ CALENDAR_RECORD_TYPE_EVENT, /**< Event type */
+ CALENDAR_RECORD_TYPE_TODO, /**< Todo type */
+}calendar_record_type_e;
+
+/**
+ * @brief Enumeration for the book mode.
+ *
+ * @since_tizen 2.3
+ */
+typedef enum {
+ CALENDAR_BOOK_MODE_NONE = 0, /**< All modules can read and write records of this calendar_book */
+ CALENDAR_BOOK_MODE_RECORD_READONLY, /**< All modules can only read records of this calendar book */
+} calendar_book_mode_e;
+
+/**
+ * @brief Enumeration for the sync event type.
+ *
+ * @since_tizen 2.3
+ */
+typedef enum {
+ CALENDAR_BOOK_SYNC_EVENT_FOR_ME = 0, /**< This book would not be synced to others except me */
+ CALENDAR_BOOK_SYNC_EVENT_FOR_EVERY_AND_DELETE, /**< This book would be sync to everyone and deleted events would be disappeared on time */
+ CALENDAR_BOOK_SYNC_EVENT_FOR_EVERY_AND_REMAIN, /**< This book would be sync to everyone but deleted events would be remained. deleted events is removed by calendar_db_clean_after_sync() API*/
+} calendar_book_sync_event_type_e;
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__TIZEN_SOCIAL_CALENDAR_TYPES_H__
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __TIZEN_SOCIAL_CALENDAR_TYPES_H__
-#define __TIZEN_SOCIAL_CALENDAR_TYPES_H__
-
-#include <stdint.h>
-#include <tizen.h>
-#include <calendar_errors.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef API
-#define API __attribute__ ((visibility("default")))
-#endif
-
-#define _CALENDAR_HANDLE(A) typedef struct __##A* A;
-
-#define _CALENDAR_BEGIN_VIEW() \
- typedef struct{ \
- const char* _uri;
-#define _CALENDAR_PROPERTY_INT(property_id_name) unsigned int property_id_name;
-#define _CALENDAR_PROPERTY_STR(property_id_name) unsigned int property_id_name;
-#define _CALENDAR_PROPERTY_DOUBLE(property_id_name) unsigned int property_id_name;
-#define _CALENDAR_PROPERTY_LLI(property_id_name) unsigned int property_id_name;
-#define _CALENDAR_PROPERTY_CALTIME(property_id_name) unsigned int property_id_name;
-#define _CALENDAR_PROPERTY_CHILD_MULTIPLE(property_id_name) unsigned int property_id_name;
-#define _CALENDAR_END_VIEW(name) } name##_property_ids; \
- extern API const name##_property_ids name;
-
-#define _CALENDAR_BEGIN_READ_ONLY_VIEW() \
- typedef struct{ \
- const char* _uri;
-#define _CALENDAR_PROPERTY_PROJECTION_INT(property_id_name) unsigned int property_id_name;
-#define _CALENDAR_PROPERTY_PROJECTION_STR(property_id_name) unsigned int property_id_name;
-#define _CALENDAR_PROPERTY_PROJECTION_DOUBLE(property_id_name) unsigned int property_id_name;
-#define _CALENDAR_PROPERTY_PROJECTION_LLI(property_id_name) unsigned int property_id_name;
-#define _CALENDAR_PROPERTY_PROJECTION_CALTIME(property_id_name) unsigned int property_id_name;
-#define _CALENDAR_PROPERTY_FILTER_INT(property_id_name) unsigned int property_id_name;
-#define _CALENDAR_PROPERTY_FILTER_STR(property_id_name) unsigned int property_id_name;
-#define _CALENDAR_PROPERTY_FILTER_DOUBLE(property_id_name) unsigned int property_id_name;
-#define _CALENDAR_PROPERTY_FILTER_LLI(property_id_name) unsigned int property_id_name;
-#define _CALENDAR_PROPERTY_FILTER_CALTIME(property_id_name) unsigned int property_id_name;
-#define _CALENDAR_END_READ_ONLY_VIEW(name) } name##_property_ids; \
- extern API const name##_property_ids name;
-
-_CALENDAR_HANDLE( calendar_record_h )
-_CALENDAR_HANDLE( calendar_filter_h )
-_CALENDAR_HANDLE( calendar_list_h )
-_CALENDAR_HANDLE( calendar_query_h )
-
-/**
- * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_DATABASE_MODULE
- * @{
- */
-
-/**
- * @brief The callback function to get the result of batch operation.
- *
- * @param[in] error Error code for batch operation
- * @param[in] user_data The user data passed from the batch operation
- *
- * @return @c true to continue with the next iteration of the loop or @c false to break out of the loop.
- *
- * @pre calendar_db_update_records() will invoke this callback.
- *
- * @see calendar_db_update_records()
- */
-typedef void (*calendar_db_result_cb)( int error, void *user_data);
-
-/**
- * @brief The callback function to get the result of batch operation.
- *
- * @param[in] error Error code for batch operation
- * @param[in] record_id_array The record IDs for batch operation
- * @param[in] count The number of record ID array
- * @param[in] user_data The user data passed from the batch operation
- *
- * @return @c true to continue with the next iteration of the loop or @c false to break out of the loop.
- *
- * @pre calendar_db_insert_records() will invoke this callback.
- *
- * @see calendar_db_insert_records()
- */
-typedef void (*calendar_db_insert_result_cb)( int error, int* record_id_array, int count, void *user_data);
-
-/**
- * @brief Called when designated view changes.
- *
- * @param[in] view_uri The view uri
- * @param[in] user_data The user data passed from the callback registration function
- *
- * @see calendar_db_add_changed_cb()
- */
-typedef void (*calendar_db_changed_cb)(const char* view_uri, void* user_data);
-
-/**
- * @brief Called when alarm is alerted.
- *
- * @param[in] consta char *param
- * @param[in] user_data The user data passed from the callback registration function
- *
- * @see calendar_db_add_changed_cb()
- */
-typedef void (*calendar_reminder_cb)(const char *param, void* user_data);
-
-/**
- * @brief Definition for calendar connect flag
- */
-#define CALENDAR_CONNECT_FLAG_NONE 0x00000000
-#define CALENDAR_CONNECT_FLAG_RETRY 0x00000001
-
-/**
- * @brief Definition for default event calendar book database ID
- */
-#define DEFAULT_EVENT_CALENDAR_BOOK_ID 1
-
-/**
- * @brief Definition for default to-do calendar book database ID
- */
-#define DEFAULT_TODO_CALENDAR_BOOK_ID 2
-
-/**
- * @brief Definition for default birthday calendar book database ID
- */
-#define DEFAULT_BIRTHDAY_CALENDAR_BOOK_ID 3
-
-/**
- * @brief Definition for no due date of a to-do
- */
-#define CALENDAR_TODO_NO_DUE_DATE INT64_MAX
-
-/**
- * @brief Definition for no start date of a to-do
- */
-#define CALENDAR_TODO_NO_START_DATE (-INT64_MAX)
-
-/**
- * @brief Definition for no until of a record
- */
-#define CALENDAR_RECORD_NO_UNTIL INT64_MAX
-
-/**
- * @brief Definition for no coordinate(latitude/longitude) of a record
- */
-#define CALENDAR_RECORD_NO_COORDINATE 1000
-
-/**
- * @}
- */
-
-/**
- * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_FILTER_MODULE
- * @{
- */
-
-/**
- * @brief Definition for all calendar book
- */
-#define CALENDAR_BOOK_FILTER_ALL -1
-
-/**
- * @brief Enumerations of filter match type for string
- */
-typedef enum
-{
- CALENDAR_MATCH_EXACTLY, /**< . */
- CALENDAR_MATCH_FULLSTRING, /**< . */
- CALENDAR_MATCH_CONTAINS, /**< . */
- CALENDAR_MATCH_STARTSWITH, /**< . */
- CALENDAR_MATCH_ENDSWITH, /**< . */
- CALENDAR_MATCH_EXISTS /**< . */
-} calendar_match_str_flag_e;
-
-/**
- * @brief Enumerations of filter match type for integer
- */
-typedef enum
-{
- CALENDAR_MATCH_EQUAL, /**< . */
- CALENDAR_MATCH_GREATER_THAN, /**< . */
- CALENDAR_MATCH_GREATER_THAN_OR_EQUAL, /**< . */
- CALENDAR_MATCH_LESS_THAN, /**< . */
- CALENDAR_MATCH_LESS_THAN_OR_EQUAL, /**< . */
- CALENDAR_MATCH_NOT_EQUAL, /**< this flag can yield poor performance */
- CALENDAR_MATCH_NONE /**< . */
-} calendar_match_int_flag_e;
-
-/**
- * @brief Enumerations of filter combine type
- */
-typedef enum {
- CALENDAR_FILTER_OPERATOR_AND, /**< . */
- CALENDAR_FILTER_OPERATOR_OR /**< . */
-} calendar_filter_operator_e;
-
-/**
- * @}
- */
-
-/**
- * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_RECORD_MODULE
- * @{
- */
-
-/**
- * @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 sensitivity type.
- */
-typedef enum
-{
- CALENDAR_SENSITIVITY_PUBLIC = 0, /**< Public Sensitivity */
- CALENDAR_SENSITIVITY_PRIVATE, /**< Private Sensitivity */
- CALENDAR_SENSITIVITY_CONFIDENTIAL /**< Confidential Sensitivity */
-} calendar_sensitivity_e;
-
-/**
- * @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 Alarm time unit type of event such as minutes, hours, days, or etc.
- */
-typedef enum
-{
- CALENDAR_ALARM_NONE = -1, /**< No reminder set */
- CALENDAR_ALARM_TIME_UNIT_SPECIFIC = 1, /**< specific in sec */
- CALENDAR_ALARM_TIME_UNIT_MINUTE = 60, /**< Alarm time unit in minutes */
- CALENDAR_ALARM_TIME_UNIT_HOUR = 3600, /**< Alarm time unit in hours */
- CALENDAR_ALARM_TIME_UNIT_DAY = 86400, /**< Alarm time unit in days */
- CALENDAR_ALARM_TIME_UNIT_WEEK = 604800, /**< Alarm time unit in weeks */
- CALENDAR_ALARM_TIME_UNIT_MONTH = 18144000, /**< Alarm time unit in months */
-} calendar_alarm_time_unit_type_e;
-
-/**
- * @brief Enumerations of the frequency of event recurrence.
- */
-typedef enum
-{
- CALENDAR_RECURRENCE_NONE, /**< No recurrence event */
- 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_frequency_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_NONE = 0x01, /**< Priority none */
- CALENDAR_EVENT_PRIORITY_LOW = 0x08, /**< Low priority */
- CALENDAR_EVENT_PRIORITY_NORMAL = 0x04, /**< Normal priority */
- CALENDAR_EVENT_PRIORITY_HIGH = 0x02, /**< High priority */
-} calendar_event_priority_e;
-
-/**
- * @brief Calendar to-do item priority
- */
-typedef enum
-{
- 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 = 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;
-
-typedef enum
-{
- CALENDAR_TIME_UTIME = 0, /**< . */
- CALENDAR_TIME_LOCALTIME, /**< . */
-} calendar_time_type_e;
-
-typedef enum
-{
- CALENDAR_RANGE_UNTIL, /**< . */
- CALENDAR_RANGE_COUNT, /**< . */
- CALENDAR_RANGE_NONE, /**< . */
-} calendar_range_type_e;
-
-typedef enum
-{
- CALENDAR_SYSTEM_NONE, /**< . */
- CALENDAR_SYSTEM_GREGORIAN, /**< . */
- CALENDAR_SYSTEM_EAST_ASIAN_LUNISOLAR, /**< . */
-} calendar_system_type_e;
-
-typedef enum
-{
- CALENDAR_MEETING_STATUS_NOTMEETING = 0, /**< . */
- CALENDAR_MEETING_STATUS_MEETING, /**< . */
- CALENDAR_MEETING_STATUS_RECEIVED, /**< . */
- CALENDAR_MEETING_STATUS_CANCELED, /**< . */
-} calendar_meeting_status_e;
-
-/**
- * @brief Enumerations of weekday of month(Same value as UCalendarDaysOfWeek in ICU).
- */
-typedef enum
-{
- CALENDAR_SUNDAY = 1,
- CALENDAR_MONDAY,
- CALENDAR_TUESDAY,
- CALENDAR_WEDNESDAY,
- CALENDAR_THURSDAY,
- CALENDAR_FRIDAY,
- CALENDAR_SATURDAY,
-}calendar_days_of_week_e;
-
-// deprecated
-#define CALENDAR_EVENT_MODIFIED_STATUS_INSERTED 0
-#define CALENDAR_EVENT_MODIFIED_STATUS_UPDATED 1
-#define CALENDAR_EVENT_MODIFIED_STATUS_DELETED 2
-/**
- * @brief Enumerations of modified status for record.
- */
-typedef enum
-{
- CALENDAR_RECORD_MODIFIED_STATUS_INSERTED = 0, /**< The record is inserted */
- CALENDAR_RECORD_MODIFIED_STATUS_UPDATED, /**< The record is updated */
- CALENDAR_RECORD_MODIFIED_STATUS_DELETED /**< The record is deleted */
-}calendar_record_modified_status_e;
-
-/**
- * @brief The structure of time
- */
-typedef struct
-{
- calendar_time_type_e type;
- union {
- long long int utime;
- struct {
- int year;
- int month;
- int mday;
- }date;
- }time;
-}calendar_time_s;
-
-/**
- * @brief Enumerations of type for record.
- */
-typedef enum
-{
- CALENDAR_RECORD_TYPE_NONE = 0, /**< . */
- CALENDAR_RECORD_TYPE_CALENDAR_BOOK, /**< . */
- CALENDAR_RECORD_TYPE_EVENT, /**< . */
- CALENDAR_RECORD_TYPE_TODO, /**< . */
-}calendar_record_type_e;
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__TIZEN_SOCIAL_CALENDAR_TYPES_H__
* limitations under the License.
*
*/
-#ifndef __TIZEN_SOCAIL_CALENDAR_VCALENDAR_H__
-#define __TIZEN_SOCAIL_CALENDAR_VCALENDAR_H__
+#ifndef __TIZEN_SOCIAL_CALENDAR_VCALENDAR_H__
+#define __TIZEN_SOCIAL_CALENDAR_VCALENDAR_H__
#include <calendar_view.h>
#endif
/**
+ * @file calendar_vcalendar.h
+ */
+
+/**
* @addtogroup CAPI_SOCIAL_CALENDAR_SVC_VCALENDAR_MODULE
* @{
*/
/**
- * @brief Retrieves vcalendar stream from a calendar list.
+ * @brief Retrieves a vcalendar stream from a calendar list.
*
- * @param[in] calendar_list The calendar list handle
- * @param[out] vcalendar_stream The vcalendar stream
+ * @since_tizen 2.3
*
- * @return 0 on success, otherwise a negative error value.
+ * @param[in] calendar_list The calendar list handle
+ * @param[out] vcalendar_stream The vcalendar stream
+ *
+ * @return @c 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_NO_DATA Requested data does not exist
*/
-API int calendar_vcalendar_make_from_records(calendar_list_h calendar_list, char **vcalendar_stream);
+int calendar_vcalendar_make_from_records(calendar_list_h calendar_list, char **vcalendar_stream);
/**
- * @brief Retrieves all calendar with calendar list from vcalendar stream.
+ * @brief Retrieves all calendars from a vcalendar stream.
+ *
+ * @since_tizen 2.3
*
- * @param[in] vcalendar_stream The vcalendar stream
- * @param[out] calendar_list The calendar list handle
+ * @param[in] vcalendar_stream The vcalendar stream
+ * @param[out] calendar_list The calendar list handle
*
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 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_NO_DATA Requested data does not exist
+ *
+ * @pre calendar_connect() should be called to initialize.
+ *
*/
-API int calendar_vcalendar_parse_to_calendar(const char* vcalendar_stream, calendar_list_h *calendar_list);
+int calendar_vcalendar_parse_to_calendar(const char* vcalendar_stream, calendar_list_h *calendar_list);
/**
- * @brief The callback function to get record hadle of
+ * @brief Called to get a record handle of
* \ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_event or \ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_todo.
*
+ * @since_tizen 2.3
+ *
* @param[in] record The record handle (\ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_event or \ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_todo)
* @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.
+ * @return @c true to continue with the next iteration of the loop,
+ * otherwise @c false to break out of the loop
*
* @pre calendar_vcalendar_parse_to_calendar_foreach() will invoke this callback.
*
typedef bool (*calendar_vcalendar_parse_cb)(calendar_record_h record, void *user_data);
/**
- * @brief Retrieves all events or to-dos with record handle
+ * @brief Retrieves all events or to-dos
* (\ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_event or \ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_todo) from a vCalendar file.
*
- * @param[in] vcalendar_file_path The file path of vCalendar stream file
- * @param[in] callback The callback function to invoke
- * @param[in] user_data The user data to be passed to the callback function
+ * @since_tizen 2.3
*
- * @return 0 on success, otherwise a negative error value.
+ * @param[in] vcalendar_file_path The file path of the vCalendar stream file
+ * @param[in] callback The callback function to be invoked
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return @c 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 calendar_connect() should be called to initialize.
+ *
* @post This function invokes calendar_vcalendar_parse_cb().
*
* @see calendar_vcalendar_parse_cb()
* @see calendar_record_get_uri_p()
*/
-API int calendar_vcalendar_parse_to_calendar_foreach(const char *vcalendar_file_path, calendar_vcalendar_parse_cb callback, void *user_data);
+int calendar_vcalendar_parse_to_calendar_foreach(const char *vcalendar_file_path, calendar_vcalendar_parse_cb callback, void *user_data);
/**
* @}
}
#endif
-#endif /* __TIZEN_SOCAIL_CALENDAR_VCALENDAR_H__ */
+#endif /* __TIZEN_SOCIAL_CALENDAR_VCALENDAR_H__ */
#ifndef __TIZEN_SOCIAL_CALENDAR_VIEW_H__
#define __TIZEN_SOCIAL_CALENDAR_VIEW_H__
-#include <calendar_types2.h>
+#include <calendar_types.h>
#ifdef __cplusplus
extern "C" {
#endif
+/**
+ * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
+ * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE View/Property
+ * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_book _calendar_book view
+ * <table>
+ * <tr>
+ * <th> Type </th>
+ * <th> Property ID </th>
+ * <th> Read, Write </th>
+ * <th> Description </th>
+ * </tr>
+ * <tr><td> string </td><td> _uri </td><td> read only </td><td> Identifier of this calendar book view </td></tr>
+ * <tr><td> integer </td><td> id </td><td> read only </td><td> DB record ID of the calendar book </td></tr>
+ * <tr><td> string </td><td> uid </td><td> read, write </td><td> Unique identifier </td></tr>
+ * <tr><td> string </td><td> name </td><td> read, write </td><td> Calendar book name </td></tr>
+ * <tr><td> string </td><td> description </td><td> read, write </td><td> Calendar book description </td></tr>
+ * <tr><td> string </td><td> color </td><td> read, write </td><td> Calendar book color for UX </td></tr>
+ * <tr><td> string </td><td> location </td><td> read, write </td><td> Location of the event </td></tr>
+ * <tr><td> integer </td><td> visibility </td><td> read, write </td><td> Visibility of the calendar book for UX</td></tr>
+ * <tr><td> integer </td><td> sync_event </td><td> read, write </td><td> </td>Currently NOT Used</tr>
+ * <tr><td> integer </td><td> account_id </td><td> read, write once </td><td> Account for this calendar </td></tr>
+ * <tr><td> integer </td><td> store_type </td><td> read, write </td><td> Type of calendar contents(refer to the @ref calendar_book_type_e) </td></tr>
+ * <tr><td> string </td><td> sync_data1 </td><td> read, write </td><td> Generic data for use by syncing </td></tr>
+ * <tr><td> string </td><td> sync_data2 </td><td> read, write </td><td> Generic data for use by syncing </td></tr>
+ * <tr><td> string </td><td> sync_data3 </td><td> read, write </td><td> Generic data for use by syncing </td></tr>
+ * <tr><td> string </td><td> sync_data4 </td><td> read, write </td><td> Generic data for use by syncing </td></tr>
+ * <tr><td> integer </td><td> mode </td><td> read, write </td><td> Calendar book mode (refer to the @ref calendar_book_mode_e) </td></tr>
+ * </table>
+ */
_CALENDAR_BEGIN_VIEW()
_CALENDAR_PROPERTY_INT( id ) // read_only
_CALENDAR_PROPERTY_STR( uid )
_CALENDAR_PROPERTY_STR( location )
_CALENDAR_PROPERTY_INT( visibility )
_CALENDAR_PROPERTY_INT( sync_event )
- _CALENDAR_PROPERTY_INT( is_deleted )
_CALENDAR_PROPERTY_INT( account_id )
_CALENDAR_PROPERTY_INT( store_type )
_CALENDAR_PROPERTY_STR( sync_data1 )
_CALENDAR_PROPERTY_STR( sync_data2 )
_CALENDAR_PROPERTY_STR( sync_data3 )
_CALENDAR_PROPERTY_STR( sync_data4 )
+ _CALENDAR_PROPERTY_INT( mode )
_CALENDAR_END_VIEW( _calendar_book )
+/**
+ * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
+ * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE View/Property
+ * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_event _calendar_event view
+ * <table>
+ * <tr>
+ * <th> Type </th>
+ * <th> Property ID </th>
+ * <th> Read, Write </th>
+ * <th> Description </th>
+ * </tr>
+ * <tr><td> string </td><td> _uri </td><td> read only </td><td>Identifier of this event view</td></tr>
+ * <tr><td> integer </td><td> id </td><td> read only </td><td>DB record ID of the event</td></tr>
+ * <tr><td> integer </td><td> calendar_book_id </td><td> read, write </td><td>ID of the calendar book to which the event belongs</td></tr>
+ * <tr><td> string </td><td> summary </td><td> read, write </td><td>The short description of the event</td></tr>
+ * <tr><td> string </td><td> description </td><td> read, write </td><td>The description of the event</td></tr>
+ * <tr><td> string </td><td> location </td><td> read, write </td><td>The location of the event</td></tr>
+ * <tr><td> string </td><td> categories </td><td> read, write </td><td>The category of the event. For example APPOINTMENT, BIRTHDAY</td></tr>
+ * <tr><td> string </td><td> exdate </td><td> read, write </td><td>The exception list of the event. If this event has a recurrence rule, the instance of the exdate is removed. Format is "YYYYMMDD"(allday event) or "YYYYMMDDTHHMMSS". Multiple exceptions can be included with a comma </td></tr>
+ * <tr><td> integer </td><td> event_status </td><td> read, write </td><td>Refer to the @ref calendar_event_status_e</td></tr>
+ * <tr><td> integer </td><td> priority </td><td> read, write </td><td></td>Refer to the @ref calendar_event_priority_e</tr>
+ * <tr><td> integer </td><td> timezone </td><td> read, write </td><td>The timezone_id of the event if it exists. Refer to the @ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_timezone</td></tr>
+ * <tr><td> integer </td><td> person_id </td><td> read, write </td><td>The person_id of the event if the event is a birthday. Refer to the contacts-service</td></tr>
+ * <tr><td> integer </td><td> busy_status </td><td> read, write </td><td>Refer to the @ref calendar_event_busy_status_e</td></tr>
+ * <tr><td> integer </td><td> sensitivity </td><td> read, write </td><td>Refer to the @ref calendar_sensitivity_e </td></tr>
+ * <tr><td> string </td><td> uid </td><td> read, write </td><td>The unique ID of the event</td></tr>
+ * <tr><td> string </td><td> organizer_name </td><td> read, write </td><td>The name of organizer of the event</td></tr>
+ * <tr><td> string </td><td> organizer_email </td><td> read, write </td><td>The email address of the organizer of the event</td></tr>
+ * <tr><td> integer </td><td> meeting_status </td><td> read, write </td><td>Refer to the @ref calendar_meeting_status_e</td></tr>
+ * <tr><td> integer </td><td> original_event_id </td><td> read, write </td><td>The ID of the original event if the event is an exception.</td></tr>
+ * <tr><td> double </td><td> latitude </td><td> read, write </td><td> The latitude of the location of the event</td></tr>
+ * <tr><td> double </td><td> longitude </td><td> read, write </td><td> The longitude of the location of the event</td></tr>
+ * <tr><td> integer </td><td> email_id </td><td> read, write </td><td>ID of the email_id. Refer to the email-service.</td></tr>
+ * <tr><td> long long int </td><td> created_time </td><td> read, write </td><td> The time when the event is created</td></tr>
+ * <tr><td> long long int </td><td> last_modified_time </td><td> read only </td><td>The time when the event is updated</td></tr>
+ * <tr><td> integer </td><td> is_deleted </td><td> read only </td><td></td></tr>
+ * <tr><td> integer </td><td> freq </td><td> read, write </td><td>The frequent type of event recurrence. Refer to the @ref calendar_recurrence_frequency_e</td></tr>
+ * <tr><td> integer </td><td> range_type </td><td> read, write </td><td>Refer to the @ref calendar_range_type_e</td></tr>
+ * <tr><td> calendar time </td><td> until_time </td><td> read, write </td><td>The end time of the event recurrence. If the range_type is @ref CALENDAR_RANGE_UNTIL</td></tr>
+ * <tr><td> integer </td><td> count </td><td> read, write </td><td>The count of the event recurrence. If the range_type is @ref CALENDAR_RANGE_COUNT</td></tr>
+ * <tr><td> integer </td><td> interval </td><td> read, write </td><td>The interval of the event recurrence</td></tr>
+ * <tr><td> string </td><td> bysecond </td><td> read, write </td><td>The second list of the event recurrence. The value can be from 0 to 59. The list is seperated by commas</td></tr>
+ * <tr><td> string </td><td> byminute </td><td> read, write </td><td>The minute list of the event recurrence. The value can be from 0 to 59. The list is seperated by commas</td></tr>
+ * <tr><td> string </td><td> byhour </td><td> read, write </td><td>The hour list of the event recurrence. The value can be from 0 to 23. The list is seperated by commas</td></tr>
+ * <tr><td> string </td><td> byday </td><td> read, write </td><td>The day list of the event recurrence. The value can be SU, MO, TU, WE, TH, FR, SA. The list is seperated by commas</td></tr>
+ * <tr><td> string </td><td> bymonthday </td><td> read, write </td><td>The month day list of the event recurrence. The value can be from 1 to 31 and from -31 to -1. The list is seperated by commas</td></tr>
+ * <tr><td> string </td><td> byyearday </td><td> read, write </td><td>The year day list of the event recurrence. The value can be from 1 to 366 and from -366 to -1. The list is seperated by commas</td></tr>
+ * <tr><td> string </td><td> byweekno </td><td> read, write </td><td>The week number list of the event recurrence. The value can be from 1 to 53 and from -53 to -1. The list is seperated by commas</td></tr>
+ * <tr><td> string </td><td> bymonth </td><td> read, write </td><td>The month list of the event recurrence. The value can be from 1 to 12. The list is seperated by commas</td></tr>
+ * <tr><td> string </td><td> bysetpos </td><td> read, write </td><td>The position list of the event recurrence. The value can be from 1 to 366 and from -366 to -1. The list is seperated by commas</td></tr>
+ * <tr><td> integer </td><td> wkst </td><td> read, write </td><td>The start day of the week. Refer to the @ref calendar_days_of_week_e</td></tr>
+ * <tr><td> string </td><td> recurrence_id </td><td> read, write </td><td>RECURRENCE-ID of RFC #2445</td></tr>
+ * <tr><td> string </td><td> rdate </td><td> read, write </td><td>RDATE of RFC #2445</td></tr>
+ * <tr><td> integer </td><td> has_attendee </td><td> read only </td><td>Whether or not the event has an attendee list </td></tr>
+ * <tr><td> integer </td><td> has_alarm </td><td> read only </td><td>Whether or not the event has an alarm list </td></tr>
+ * <tr><td> integer </td><td> calendar_system_type </td><td> read, write </td><td>Refer to the @ref calendar_system_type_e</td></tr>
+ * <tr><td> string </td><td> sync_data1 </td><td> read, write </td><td>The sync data of the event. If developer need to save some information related to the event, they can use this property</td></tr>
+ * <tr><td> string </td><td> sync_data2 </td><td> read, write </td><td>The sync data of the event. If developer need to save some information related to the event, they can use this property</td></tr>
+ * <tr><td> string </td><td> sync_data3 </td><td> read, write </td><td>The sync data of the event. If developer need to save some information related to the event, they can use this property</td></tr>
+ * <tr><td> string </td><td> sync_data4 </td><td> read, write </td><td>The sync data of the event. If developer need to save some information related to the event, they can use this property</td></tr>
+ * <tr><td> calendar time </td><td> start_time </td><td> read, write </td><td>The start time of the event</td></tr>
+ * <tr><td> string </td><td> start_tzid </td><td> read, write </td><td></td>The timezone of the start_time</tr>
+ * <tr><td> calendar time </td><td> end_time </td><td> read, write </td><td>The end time of the event</td></tr>
+ * <tr><td> string </td><td> end_tzid </td><td> read, write </td><td>The timezone of the end_time</td></tr>
+ * <tr><td> child list </td><td> calendar_alarm </td><td> read, write </td><td>The alarm list of the event. Refer to the @ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_alarm</td></tr>
+ * <tr><td> child list </td><td> calendar_attendee </td><td> read, write </td><td>The attendee list of the event. Refer to the @ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_attendee</td></tr>
+ * <tr><td> child list </td><td> exception </td><td> read, write </td><td>The exception mod event list of the event</td></tr>
+ * <tr><td> child list </td><td> extended </td><td> read, write </td><td>The extended property list of the event. Refer to the @ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_extended_property</td></tr>
+ * <tr><td> interger </td><td> is_allday </td><td> read only </td><td>The event is an allday event or not </td></tr>
+ * </table>
+ */
_CALENDAR_BEGIN_VIEW()
_CALENDAR_PROPERTY_INT( id ) // read_only
_CALENDAR_PROPERTY_INT( calendar_book_id )
_CALENDAR_PROPERTY_DOUBLE( longitude )
_CALENDAR_PROPERTY_INT( email_id )
_CALENDAR_PROPERTY_LLI( created_time )
- _CALENDAR_PROPERTY_LLI( last_modified_time )
+ _CALENDAR_PROPERTY_LLI( last_modified_time ) // read_only
_CALENDAR_PROPERTY_INT( is_deleted ) // read_only
_CALENDAR_PROPERTY_INT( freq )
_CALENDAR_PROPERTY_INT( range_type )
_CALENDAR_PROPERTY_INT( is_allday ) // read only
_CALENDAR_END_VIEW( _calendar_event )
+/**
+ * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
+ * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE View/Property
+ * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_todo _calendar_todo view
+ * <table>
+ * <tr>
+ * <th> Type </th>
+ * <th> Property ID </th>
+ * <th> Read, Write </th>
+ * <th> Description </th>
+ * </tr>
+ * <tr><td> string </td><td> _uri </td><td> read only </td><td>Identifier of this todo view</td></tr>
+ * <tr><td> integer </td><td> id </td><td> read only </td><td>DB record ID of the todo</td></tr>
+ * <tr><td> integer </td><td> calendar_book_id </td><td> read, write </td><td>ID of the calendar book to which the todo belongs</td></tr>
+ * <tr><td> string </td><td> summary </td><td> read, write </td><td>The short description of the todo</td></tr>
+ * <tr><td> string </td><td> description </td><td> read, write </td><td>The description of the todo</td></tr>
+ * <tr><td> string </td><td> location </td><td> read, write </td><td>The location of the todo</td></tr>
+ * <tr><td> string </td><td> categories </td><td> read, write </td><td>The category of the todo. For example APPOINTMENT, BIRTHDAY</td></tr>
+ * <tr><td> integer </td><td> todo_status </td><td> read, write </td><td>Refer to the @ref calendar_todo_status_e</td></tr>
+ * <tr><td> integer </td><td> priority </td><td> read, write </td><td>Refer to the @ref calendar_todo_priority_e</td></tr>
+ * <tr><td> integer </td><td> sensitivity </td><td> read, write </td><td>Refer to the @ref calendar_sensitivity_e </td></tr>
+ * <tr><td> string </td><td> uid </td><td> read, write </td><td>The unique ID of the todo</td></tr>
+ * <tr><td> double </td><td> latitude </td><td> read, write </td><td>The latitude of the location of the todo</td></tr>
+ * <tr><td> double </td><td> longitude </td><td> read, write </td><td>The longitude of the location of the todo</td></tr>
+ * <tr><td> long long int </td><td> created_time </td><td> read, write </td><td>The time when the todo is created</td></tr>
+ * <tr><td> long long int </td><td> last_modified_time </td><td> read only </td><td>The time when the todo is updated</td></tr>
+ * <tr><td> long long int </td><td> completed_time </td><td> read, write </td><td>The time when the todo is completed</td></tr>
+ * <tr><td> integer </td><td> progress </td><td> read, write </td><td> The progression of the todo. The value can be from 0 to 100</td></tr>
+ * <tr><td> integer </td><td> is_deleted </td><td> read only </td><td></td></tr>
+ * <tr><td> integer </td><td> freq </td><td> read, write </td><td>The frequent type of todo recurrence. Refer to the @ref calendar_recurrence_frequency_e</td></tr>
+ * <tr><td> integer </td><td> range_type </td><td> read, write </td><td>Refer to the @ref calendar_range_type_e</td></tr>
+ * <tr><td> calendar time </td><td> until_time </td><td> read, write </td><td>The end time of the todo recurrence. If the range_type is CALENDAR_RANGE_UNTIL</td></tr>
+ * <tr><td> integer </td><td> count </td><td> read, write </td><td>The count of the todo recurrence. If the range_type is CALENDAR_RANGE_COUNT</td></tr>
+ * <tr><td> integer </td><td> interval </td><td> read, write </td><td>The interval of the todo recurrence</td></tr>
+ * <tr><td> string </td><td> bysecond </td><td> read, write </td><td>The second list of the todo recurrence. The value can be from 0 to 59. The list is seperated by commas</td></tr>
+ * <tr><td> string </td><td> byminute </td><td> read, write </td><td>The minute list of the todo recurrence. The value can be from 0 to 59. The list is seperated by commas</td></tr>
+ * <tr><td> string </td><td> byhour </td><td> read, write </td><td>The hour list of the todo recurrence. The value can be from 0 to 23. The list is seperated by commas</td></tr>
+ * <tr><td> string </td><td> byday </td><td> read, write </td><td>The day list of the todo recurrence. The value can be SU, MO, TU, WE, TH, FR, SA. The list is seperated by commas</td></tr>
+ * <tr><td> string </td><td> bymonthday </td><td> read, write </td><td>The month day list of the todo recurrence. The value can be from 1 to 31 and from -31 to -1. The list is seperated by commas</td></tr>
+ * <tr><td> string </td><td> byyearday </td><td> read, write </td><td>The year day list of the todo recurrence. The value can be from 1 to 366 and from -366 to -1. The list is seperated by commas</td></tr>
+ * <tr><td> string </td><td> byweekno </td><td> read, write </td><td>The week number list of the todo recurrence. The value can be from 1 to 53 and from -53 to -1. The list is seperated by commas</td></tr>
+ * <tr><td> string </td><td> bymonth </td><td> read, write </td><td>The month list of the todo recurrence. The value can be from 1 to 12. The list is seperated by commas</td></tr>
+ * <tr><td> string </td><td> bysetpos </td><td> read, write </td><td>The position list of the todo recurrence. The value can be from 1 to 366 and from -366 to -1. The list is seperated by commas</td></tr>
+ * <tr><td> integer </td><td> wkst </td><td> read, write </td><td>The start day of the week. Refer to the @ref calendar_days_of_week_e</td></tr>
+ * <tr><td> integer </td><td> has_alarm </td><td> read only </td><td>Whether or not the todo has an alarm list </td></tr>
+ * <tr><td> string </td><td> sync_data1 </td><td> read, write </td><td>The sync data of the todo. If developers need to save some information related to the todo, they can use this property</td></tr>
+ * <tr><td> string </td><td> sync_data2 </td><td> read, write </td><td>The sync data of the todo. If developers need to save some information related to the todo, they can use this property</td></tr>
+ * <tr><td> string </td><td> sync_data3 </td><td> read, write </td><td>The sync data of the todo. If developers need to save some information related to the todo, they can use this property</td></tr>
+ * <tr><td> string </td><td> sync_data4 </td><td> read, write </td><td>The sync data of the todo. If developers need to save some information related to the todo, they can use this property</td></tr>
+ * <tr><td> calendar time </td><td> start_time </td><td> read, write </td><td>The start time of the todo</td></tr>
+ * <tr><td> string </td><td> start_tzid </td><td> read, write </td><td></td>The timezone of the start_time</tr>
+ * <tr><td> calendar time </td><td> due_time </td><td> read, write </td><td>The due time of the todo</td></tr>
+ * <tr><td> string </td><td> due_tzid </td><td> read, write </td><td>The timezone of the due_time</td></tr>
+ * <tr><td> child list </td><td> calendar_alarm </td><td> read, write </td><td>The alarm list of the todo. Refer to the @ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_alarm</td></tr>
+ * <tr><td> string </td><td> organizer_name </td><td> read, write </td><td>The name of the organizer of the event</td></tr>
+ * <tr><td> string </td><td> organizer_email </td><td> read, write </td><td>The email address of the organizer of the event</td></tr>
+ * <tr><td> integer </td><td> has_attendee </td><td> read only </td><td>Whether or not the todo has an attendee list </td></tr>
+ * <tr><td> child list </td><td> calendar_attendee </td><td> read, write </td><td>The attendee list of the todo. Refer to the @ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_attendee</td></tr>
+ * <tr><td> child list </td><td> extended </td><td> read, write </td><td>The extended property list of the todo. Refer to the @ref CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_extended_property</td></tr>
+ * <tr><td> interger </td><td> is_allday </td><td> read only </td><td>The todo is an allday event or not </td></tr>
+ * </table>
+ */
_CALENDAR_BEGIN_VIEW()
_CALENDAR_PROPERTY_INT( id ) // read_only
_CALENDAR_PROPERTY_INT( calendar_book_id )
_CALENDAR_PROPERTY_DOUBLE( latitude )
_CALENDAR_PROPERTY_DOUBLE( longitude )
_CALENDAR_PROPERTY_LLI( created_time )
- _CALENDAR_PROPERTY_LLI( last_modified_time )
+ _CALENDAR_PROPERTY_LLI( last_modified_time ) // read_only
_CALENDAR_PROPERTY_LLI( completed_time )
_CALENDAR_PROPERTY_INT( progress )
_CALENDAR_PROPERTY_INT( is_deleted ) // read_only
_CALENDAR_PROPERTY_INT( is_allday ) // read only
_CALENDAR_END_VIEW( _calendar_todo )
+/**
+ * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
+ * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE View/Property
+ * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_timezone _calendar_timezone view
+ * <table>
+ * <tr>
+ * <th> Type </th>
+ * <th> Property ID </th>
+ * <th> Read, Write </th>
+ * <th> Description </th>
+ * </tr>
+ * <tr><td> string </td><td> _uri </td><td> read only </td><td> Identifier of this timezone view </td></tr>
+ * <tr><td> integer </td><td> id </td><td> read only </td><td> DB record ID of the timezone </td></tr>
+ * <tr><td> integer </td><td> calendar_book_id </td><td> read, write </td><td> DB record ID of a related calendar book </td></tr>
+ * <tr><td> integer </td><td> tz_offset_from_gmt </td><td> read, write </td><td> UTC offset which is in use when the onset of this time zone observance begins. Valid values are -720(-12:00) to 840(+14:00) </td></tr>
+ * <tr><td> string </td><td> standard_name </td><td> read, write </td><td> Name of the Standard Time </td></tr>
+ * <tr><td> integer </td><td> standard_start_month </td><td> read, write </td><td> Starting month of the Standard Time. Month is 0-based. eg, 0 for January </td></tr>
+ * <tr><td> integer </td><td> standard_start_position_of_week </td><td> read, write </td><td> Starting day-of-week-in-month of the Standard Time. Day is 1-based </td></tr>
+ * <tr><td> integer </td><td> standard_start_day </td><td> read, write </td><td> Starting day-of-week of the Standard Time. Valid values are 1(SUNDAY) to 7(SATURDAY) </td></tr>
+ * <tr><td> integer </td><td> standard_start_hour </td><td> read, write </td><td> Starting hour of the Standard Time. Valid values are 0 to 23 </td></tr>
+ * <tr><td> integer </td><td> standard_bias </td><td> read, write </td><td> The number of minutes added during the Standard Time </td></tr>
+ * <tr><td> string </td><td> day_light_name </td><td> read, write </td><td> Name of Daylight </td></tr>
+ * <tr><td> integer </td><td> day_light_start_month </td><td> read, write </td><td> Starting month of Daylight. Month is 0-based. eg, 0 for January </td></tr>
+ * <tr><td> integer </td><td> day_light_start_position_of_week </td><td> read, write </td><td> Starting day-of-week-in-month of Daylight. Day is 1-based </td></tr>
+ * <tr><td> integer </td><td> day_light_start_day </td><td> read, write </td><td> Starting day-of-week of Daylight. Valid values are 1(SUNDAY) to 7(SATURDAY) </td></tr>
+ * <tr><td> integer </td><td> day_light_start_hour </td><td> read, write </td><td> Starting hour of Daylight. Valid values are 0 to 23 </td></tr>
+ * <tr><td> integer </td><td> day_light_bias </td><td> read, write </td><td> The number of minutes added during Daylight Time </td></tr>
+ * </table>
+ */
_CALENDAR_BEGIN_VIEW()
_CALENDAR_PROPERTY_INT( id ) // read_only
_CALENDAR_PROPERTY_INT( calendar_book_id )
_CALENDAR_PROPERTY_INT( day_light_bias ) // diff between standard and daylight(minute)
_CALENDAR_END_VIEW( _calendar_timezone )
+/**
+ * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
+ * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE View/Property
+ * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_attendee _calendar_attendee view
+ * <table>
+ * <tr>
+ * <th> Type </th>
+ * <th> Property ID </th>
+ * <th> Read, Write </th>
+ * <th> Description </th>
+ * </tr>
+ * <tr><td> string </td><td> _uri </td><td> read only </td><td> Identifier of this calendar attendee view </td></tr>
+ * <tr><td> integer </td><td> event_id </td><td> read only </td><td> Event/TODO that the attendee belongs to </td></tr>
+ * <tr><td> string </td><td> number </td><td> read, write </td><td> The number of the attendee </td></tr>
+ * <tr><td> integer </td><td> cutype </td><td> read, write </td><td> The type of attendee (one of CALENDAR_ATTENDEE_CUTYPE_INDIVIDUAL, CALENDAR_ATTENDEE_CUTYPE_GROUP, CALENDAR_ATTENDEE_CUTYPE_RESOURCE, CALENDAR_ATTENDEE_CUTYPE_ROOM, CALENDAR_ATTENDEE_CUTYPE_UNKNOWN) </tr>
+ * <tr><td> integer </td><td> person_id </td><td> read, write </td><td> Person ID that the attendee belongs to </td></tr>
+ * <tr><td> string </td><td> uid </td><td> read, write </td><td> Unique identifier </td></tr>
+ * <tr><td> string </td><td> email </td><td> read, write </td><td> The email address of the attendee </td></tr>
+ * <tr><td> integer </td><td> role </td><td> read, write </td><td> Attendee role (one of CALENDAR_ATTENDEE_ROLE_REQ_PARTICIPANT, CALENDAR_ATTENDEE_ROLE_OPT_PARTICIPANT, CALENDAR_ATTENDEE_ROLE_NON_PARTICIPANT, CALENDAR_ATTENDEE_ROLE_CHAIR) </td></tr>
+ * <tr><td> integer </td><td> status </td><td> read, write </td><td> Attendee status (one of CALENDAR_ATTENDEE_STATUS_PENDING, CALENDAR_ATTENDEE_STATUS_ACCEPTED, CALENDAR_ATTENDEE_STATUS_DECLINED, CALENDAR_ATTENDEE_STATUS_TENTATIVE, CALENDAR_ATTENDEE_STATUS_DELEGATED, CALENDAR_ATTENDEE_STATUS_COMPLETED, CALENDAR_ATTENDEE_STATUS_IN_PROCESS) </td></tr>
+ * <tr><td> integer </td><td> rsvp </td><td> read, write </td><td> RSVP invitation reply (one of true, false) </td></tr>
+ * <tr><td> string </td><td> delegatee_uri </td><td> read, write </td><td> Delegatee (DELEGATED-TO) </td></tr>
+ * <tr><td> string </td><td> delegator_uri </td><td> read, write </td><td> Delegator (DELEGATED-FROM) </td></tr>
+ * <tr><td> string </td><td> name </td><td> read, write </td><td> Attendee name </td></tr>
+ * <tr><td> string </td><td> member </td><td> read, write </td><td> Group that the attendee belongs to </td></tr>
+ * </table>
+ */
_CALENDAR_BEGIN_VIEW()
- _CALENDAR_PROPERTY_INT( event_id )
+ _CALENDAR_PROPERTY_INT( parent_id ) // read_only
_CALENDAR_PROPERTY_STR( number )
- _CALENDAR_PROPERTY_INT( type )
+ _CALENDAR_PROPERTY_INT( cutype ) // calendar user type: INDIVIDUAL, GROUP, RESOURCE, ROOM, UNKNOWN
_CALENDAR_PROPERTY_INT( person_id )
_CALENDAR_PROPERTY_STR( uid )
_CALENDAR_PROPERTY_STR( group )
_CALENDAR_PROPERTY_INT( role )
_CALENDAR_PROPERTY_INT( status )
_CALENDAR_PROPERTY_INT( rsvp )
- _CALENDAR_PROPERTY_STR( delegate_uri )
+ _CALENDAR_PROPERTY_STR( delegatee_uri )
_CALENDAR_PROPERTY_STR( delegator_uri )
_CALENDAR_PROPERTY_STR( name )
+ _CALENDAR_PROPERTY_STR( member )
_CALENDAR_END_VIEW( _calendar_attendee )
+/**
+ * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
+ * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE View/Property
+ * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_alarm _calendar_alarm view
+ * <table>
+ * <tr>
+ * <th> Type </th>
+ * <th> Property ID </th>
+ * <th> Read, Write </th>
+ * <th> Description </th>
+ * </tr>
+ * <tr><td> string </td><td> _uri </td><td> read only </td><td> Identifier of this calendar alarm view </td></tr>
+ * <tr><td> integer </td><td> parent_id </td><td> read only </td><td> Event that the alarm belongs to </td></tr>
+ * <tr><td> integer </td><td> type </td><td> read, write </td><td> Currently NOT used </td></tr>
+ * <tr><td> long long int </td><td> time </td><td> read, write </td><td> The alarm time of the event(This represents the number of seconds elapsed since the Epoch, 1970-01-01 00:00:00 +0000(UTC)). This MUST be used with CALENDAR_ALARM_TIME_UNIT_SPECIFIC </td></tr>
+ * <tr><td> integer </td><td> tick </td><td> read, write </td><td> The number of unit before start time. This MUST be used with one of CALENDAR_ALARM_TIME_UNIT_MINUTE, CALENDAR_ALARM_TIME_UNIT_HOUR, CALENDAR_ALARM_TIME_UNIT_DAY, CALENDAR_ALARM_TIME_UNIT_WEEK. </td></tr>
+ * <tr><td> integer </td><td> tick_unit </td><td> read, write </td><td> Reminder tick time unit (one of CALENDAR_ALARM_NONE, CALENDAR_ALARM_TIME_UNIT_SPECIFIC, CALENDAR_ALARM_TIME_UNIT_MINUTE, CALENDAR_ALARM_TIME_UNIT_HOUR, CALENDAR_ALARM_TIME_UNIT_DAY, CALENDAR_ALARM_TIME_UNIT_WEEK) </td></tr>
+ * <tr><td> string </td><td> attach </td><td> read, write </td><td> Alarm tone path </td></tr>
+ * <tr><td> string </td><td> summary </td><td> read, write </td><td> Alarm summary </td></tr>
+ * <tr><td> string </td><td> description </td><td> read, write </td><td> Alarm description </td></tr>
+ * <tr><td> integer </td><td> action </td><td> read, write </td><td> Action of alarm (one of CALENDAR_ALARM_ACTION_AUDIO, CALENDAR_ALARM_ACTION_DISPLAY, CALENDAR_ALARM_ACTION_EMAIL) </td></tr>
+ * <tr><td> calendar time </td><td> alarm_time </td><td> read, write </td><td>The alarm time </td></tr>
+ * </table>
+ */
_CALENDAR_BEGIN_VIEW()
- _CALENDAR_PROPERTY_INT( event_id )
- _CALENDAR_PROPERTY_INT( todo_id )
- _CALENDAR_PROPERTY_INT( type )
- _CALENDAR_PROPERTY_LLI( time )
+ _CALENDAR_PROPERTY_INT( parent_id ) // read_only
_CALENDAR_PROPERTY_INT( tick )
_CALENDAR_PROPERTY_INT( tick_unit )
- _CALENDAR_PROPERTY_STR( tone )
_CALENDAR_PROPERTY_STR( description )
- _CALENDAR_PROPERTY_INT( alarm_id )
+ _CALENDAR_PROPERTY_STR( summary ) // emailprop: summary
+ _CALENDAR_PROPERTY_INT( action ) // AUDIO, DISPLAY, EMAIL
+ _CALENDAR_PROPERTY_STR( attach )
+ _CALENDAR_PROPERTY_CALTIME( alarm_time )
_CALENDAR_END_VIEW( _calendar_alarm )
+/**
+ * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
+ * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE View/Property
+ * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_updated_info _calendar_updated_info view (read only)
+ * <table>
+ * <tr>
+ * <th> Type </th>
+ * <th> Property ID </th>
+ * <th> Description </th>
+ * </tr>
+ * <tr><td> string </td><td> _uri </td><td> Identifier of this updated_info view </td></tr>
+ * <tr><td> integer </td><td> id </td><td> Modified event(or todo) record ID </td></tr>
+ * <tr><td> integer </td><td> calendar_book_id </td><td> Calendar book ID of the modified event(or todo) record </td></tr>
+ * <tr><td> integer </td><td> modified_status </td><td> Enumeration value of the modified status (@ref calendar_record_modified_status_e) </td></tr>
+ * <tr><td> integer </td><td> version </td><td> Version after change </td></tr>
+ * </table>
+ */
_CALENDAR_BEGIN_READ_ONLY_VIEW()
- _CALENDAR_PROPERTY_INT( id )
+ _CALENDAR_PROPERTY_INT( id ) // read_only
_CALENDAR_PROPERTY_INT( calendar_book_id )
_CALENDAR_PROPERTY_INT( modified_status )
_CALENDAR_PROPERTY_INT( version )
_CALENDAR_END_READ_ONLY_VIEW( _calendar_updated_info )
+/**
+ * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
+ * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE View/Property
+ * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_event_calendar_book _calendar_event_calendar_book view (read only)
+ * <table>
+ * <tr>
+ * <th> Type </th>
+ * <th> Property ID </th>
+ * </tr>
+ * <tr><td> string </td><td> _uri </td></tr>
+ * <tr><td> integer </td><td> event_id </td></tr>
+ * <tr><td> integer </td><td> calendar_book_id </td></tr>
+ * <tr><td> string </td><td> summary </td></tr>
+ * <tr><td> string </td><td> description </td></tr>
+ * <tr><td> string </td><td> location </td></tr>
+ * <tr><td> string </td><td> categories </td></tr>
+ * <tr><td> string </td><td> exdate </td></tr>
+ * <tr><td> integer </td><td> event_status </td></tr>
+ * <tr><td> integer </td><td> priority </td></tr>
+ * <tr><td> integer </td><td> timezone </td></tr>
+ * <tr><td> integer </td><td> person_id </td></tr>
+ * <tr><td> integer </td><td> busy_status </td></tr>
+ * <tr><td> integer </td><td> sensitivity </td></tr>
+ * <tr><td> string </td><td> uid </td></tr>
+ * <tr><td> string </td><td> organizer_name </td></tr>
+ * <tr><td> string </td><td> organizer_email </td></tr>
+ * <tr><td> integer </td><td> meeting_status </td></tr>
+ * <tr><td> integer </td><td> original_event_id </td></tr>
+ * <tr><td> double </td><td> latitude </td></tr>
+ * <tr><td> double </td><td> longitude </td></tr>
+ * <tr><td> integer </td><td> email_id </td></tr>
+ * <tr><td> long long int </td><td> created_time </td></tr>
+ * <tr><td> long long int </td><td> last_modified_time </td></tr>
+ * <tr><td> integer </td><td> freq </td></tr>
+ * <tr><td> integer </td><td> range_type </td></tr>
+ * <tr><td> calendar time </td><td> until_time </td></tr>
+ * <tr><td> integer </td><td> count </td></tr>
+ * <tr><td> integer </td><td> interval </td></tr>
+ * <tr><td> string </td><td> bysecond </td></tr>
+ * <tr><td> string </td><td> byminute </td></tr>
+ * <tr><td> string </td><td> byhour </td></tr>
+ * <tr><td> string </td><td> byday </td></tr>
+ * <tr><td> string </td><td> bymonthday </td></tr>
+ * <tr><td> string </td><td> byyearday </td></tr>
+ * <tr><td> string </td><td> byweekno </td></tr>
+ * <tr><td> string </td><td> bymonth </td></tr>
+ * <tr><td> string </td><td> bysetpos </td></tr>
+ * <tr><td> integer </td><td> wkst </td></tr>
+ * <tr><td> string </td><td> recurrence_id </td></tr>
+ * <tr><td> string </td><td> rdate </td></tr>
+ * <tr><td> integer </td><td> has_attendee </td></tr>
+ * <tr><td> integer </td><td> has_alarm </td></tr>
+ * <tr><td> integer </td><td> calendar_system_type </td></tr>
+ * <tr><td> string </td><td> sync_data1 </td></tr>
+ * <tr><td> string </td><td> sync_data2 </td></tr>
+ * <tr><td> string </td><td> sync_data3 </td></tr>
+ * <tr><td> string </td><td> sync_data4 </td></tr>
+ * <tr><td> calendar time </td><td> start_time </td></tr>
+ * <tr><td> string </td><td> start_tzid </td></tr>
+ * <tr><td> calendar time </td><td> end_time </td></tr>
+ * <tr><td> string </td><td> end_tzid </td></tr>
+ * <tr><td> filter integer </td><td> calendar_book_visibility </td></tr>
+ * <tr><td> filter integer </td><td> calendar_book_account_id </td></tr>
+ * </table>
+ */
_CALENDAR_BEGIN_READ_ONLY_VIEW()
_CALENDAR_PROPERTY_INT( event_id )
_CALENDAR_PROPERTY_INT( calendar_book_id )
_CALENDAR_PROPERTY_INT( email_id )
_CALENDAR_PROPERTY_LLI( created_time )
_CALENDAR_PROPERTY_LLI( last_modified_time )
- _CALENDAR_PROPERTY_INT( is_deleted )
_CALENDAR_PROPERTY_INT( freq )
_CALENDAR_PROPERTY_INT( range_type )
_CALENDAR_PROPERTY_CALTIME( until_time )
_CALENDAR_PROPERTY_FILTER_INT( calendar_book_account_id )
_CALENDAR_END_READ_ONLY_VIEW( _calendar_event_calendar_book )
+/**
+ * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
+ * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE View/Property
+ * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_todo_calendar_book _calendar_todo_calendar_book view (read only)
+ * <table>
+ * <tr>
+ * <th> Type </th>
+ * <th> Property ID </th>
+ * </tr>
+ * <tr><td> string </td><td> _uri </td></tr>
+ * <tr><td> integer </td><td> todo_id </td></tr>
+ * <tr><td> integer </td><td> calendar_book_id </td></tr>
+ * <tr><td> string </td><td> summary </td></tr>
+ * <tr><td> string </td><td> description </td></tr>
+ * <tr><td> string </td><td> location </td></tr>
+ * <tr><td> string </td><td> categories </td></tr>
+ * <tr><td> integer </td><td> todo_status </td></tr>
+ * <tr><td> integer </td><td> priority </td></tr>
+ * <tr><td> integer </td><td> sensitivity </td></tr>
+ * <tr><td> string </td><td> uid </td></tr>
+ * <tr><td> double </td><td> latitude </td></tr>
+ * <tr><td> double </td><td> longitude </td></tr>
+ * <tr><td> long long int </td><td> created_time </td></tr>
+ * <tr><td> long long int </td><td> last_modified_time </td></tr>
+ * <tr><td> long long int </td><td> completed_time </td></tr>
+ * <tr><td> integer </td><td> progress </td></tr>
+ * <tr><td> integer </td><td> freq </td></tr>
+ * <tr><td> integer </td><td> range_type </td></tr>
+ * <tr><td> calendar time </td><td> until_time </td></tr>
+ * <tr><td> integer </td><td> count </td></tr>
+ * <tr><td> integer </td><td> interval </td></tr>
+ * <tr><td> string </td><td> bysecond </td></tr>
+ * <tr><td> string </td><td> byminute </td></tr>
+ * <tr><td> string </td><td> byhour </td></tr>
+ * <tr><td> string </td><td> byday </td></tr>
+ * <tr><td> string </td><td> bymonthday </td></tr>
+ * <tr><td> string </td><td> byyearday </td></tr>
+ * <tr><td> string </td><td> byweekno </td></tr>
+ * <tr><td> string </td><td> bymonth </td></tr>
+ * <tr><td> string </td><td> bysetpos </td></tr>
+ * <tr><td> integer </td><td> wkst </td></tr>
+ * <tr><td> integer </td><td> has_alarm </td></tr>
+ * <tr><td> string </td><td> sync_data1 </td></tr>
+ * <tr><td> string </td><td> sync_data2 </td></tr>
+ * <tr><td> string </td><td> sync_data3 </td></tr>
+ * <tr><td> string </td><td> sync_data4 </td></tr>
+ * <tr><td> calendar time </td><td> start_time </td></tr>
+ * <tr><td> string </td><td> start_tzid </td></tr>
+ * <tr><td> calendar time </td><td> due_time </td></tr>
+ * <tr><td> string </td><td> due_tzid </td></tr>
+ * <tr><td> filter integer </td><td> calendar_book_visibility </td></tr>
+ * <tr><td> filter integer </td><td> calendar_book_account_id </td></tr>
+ * </table>
+ */
_CALENDAR_BEGIN_READ_ONLY_VIEW()
_CALENDAR_PROPERTY_INT( todo_id )
_CALENDAR_PROPERTY_INT( calendar_book_id )
_CALENDAR_PROPERTY_LLI( last_modified_time )
_CALENDAR_PROPERTY_LLI( completed_time )
_CALENDAR_PROPERTY_INT( progress )
- _CALENDAR_PROPERTY_INT( is_deleted )
_CALENDAR_PROPERTY_INT( freq )
_CALENDAR_PROPERTY_INT( range_type )
_CALENDAR_PROPERTY_CALTIME( until_time )
_CALENDAR_PROPERTY_FILTER_INT( calendar_book_account_id )
_CALENDAR_END_READ_ONLY_VIEW( _calendar_todo_calendar_book )
+/**
+ * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
+ * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE View/Property
+ * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_event_calendar_book_attendee _calendar_event_calendar_book_attendee view (read only)
+ * <table>
+ * <tr>
+ * <th> Type </th>
+ * <th> Property ID </th>
+ * </tr>
+ * <tr><td> string </td><td> _uri </td></tr>
+ * <tr><td> integer </td><td> event_id </td></tr>
+ * <tr><td> integer </td><td> calendar_book_id </td></tr>
+ * <tr><td> string </td><td> summary </td></tr>
+ * <tr><td> string </td><td> description </td></tr>
+ * <tr><td> string </td><td> location </td></tr>
+ * <tr><td> string </td><td> categories </td></tr>
+ * <tr><td> string </td><td> exdate </td></tr>
+ * <tr><td> integer </td><td> event_status </td></tr>
+ * <tr><td> integer </td><td> priority </td></tr>
+ * <tr><td> integer </td><td> timezone </td></tr>
+ * <tr><td> integer </td><td> person_id </td></tr>
+ * <tr><td> integer </td><td> busy_status </td></tr>
+ * <tr><td> integer </td><td> sensitivity </td></tr>
+ * <tr><td> string </td><td> uid </td></tr>
+ * <tr><td> string </td><td> organizer_name </td></tr>
+ * <tr><td> string </td><td> organizer_email </td></tr>
+ * <tr><td> integer </td><td> meeting_status </td></tr>
+ * <tr><td> integer </td><td> original_event_id </td></tr>
+ * <tr><td> double </td><td> latitude </td></tr>
+ * <tr><td> double </td><td> longitude </td></tr>
+ * <tr><td> integer </td><td> email_id </td></tr>
+ * <tr><td> long long int </td><td> created_time </td></tr>
+ * <tr><td> long long int </td><td> last_modified_time </td></tr>
+ * <tr><td> integer </td><td> freq </td></tr>
+ * <tr><td> integer </td><td> range_type </td></tr>
+ * <tr><td> calendar time </td><td> until_time </td></tr>
+ * <tr><td> integer </td><td> count </td></tr>
+ * <tr><td> integer </td><td> interval </td></tr>
+ * <tr><td> string </td><td> bysecond </td></tr>
+ * <tr><td> string </td><td> byminute </td></tr>
+ * <tr><td> string </td><td> byhour </td></tr>
+ * <tr><td> string </td><td> byday </td></tr>
+ * <tr><td> string </td><td> bymonthday </td></tr>
+ * <tr><td> string </td><td> byyearday </td></tr>
+ * <tr><td> string </td><td> byweekno </td></tr>
+ * <tr><td> string </td><td> bymonth </td></tr>
+ * <tr><td> string </td><td> bysetpos </td></tr>
+ * <tr><td> integer </td><td> wkst </td></tr>
+ * <tr><td> string </td><td> recurrence_id </td></tr>
+ * <tr><td> string </td><td> rdate </td></tr>
+ * <tr><td> integer </td><td> has_attendee </td></tr>
+ * <tr><td> integer </td><td> has_alarm </td></tr>
+ * <tr><td> integer </td><td> calendar_system_type </td></tr>
+ * <tr><td> string </td><td> sync_data1 </td></tr>
+ * <tr><td> string </td><td> sync_data2 </td></tr>
+ * <tr><td> string </td><td> sync_data3 </td></tr>
+ * <tr><td> string </td><td> sync_data4 </td></tr>
+ * <tr><td> calendar time </td><td> start_time </td></tr>
+ * <tr><td> string </td><td> start_tzid </td></tr>
+ * <tr><td> calendar time </td><td> end_time </td></tr>
+ * <tr><td> string </td><td> end_tzid </td></tr>
+ * <tr><td> filter integer </td><td> calendar_book_visibility </td></tr>
+ * <tr><td> filter integer </td><td> calendar_book_account_id </td></tr>
+ * <tr><td> filter string </td><td> attendee_email </td></tr>
+ * <tr><td> filter string </td><td> attendee_name </td></tr>
+ * <tr><td> filter string </td><td> attendee_member </td></tr>
+ * </table>
+ */
_CALENDAR_BEGIN_READ_ONLY_VIEW()
_CALENDAR_PROPERTY_INT( event_id )
_CALENDAR_PROPERTY_INT( calendar_book_id )
_CALENDAR_PROPERTY_INT( email_id )
_CALENDAR_PROPERTY_LLI( created_time )
_CALENDAR_PROPERTY_LLI( last_modified_time )
- _CALENDAR_PROPERTY_INT( is_deleted )
_CALENDAR_PROPERTY_INT( freq )
_CALENDAR_PROPERTY_INT( range_type )
_CALENDAR_PROPERTY_CALTIME( until_time )
_CALENDAR_PROPERTY_FILTER_INT( calendar_book_account_id )
_CALENDAR_PROPERTY_FILTER_STR( attendee_email )
_CALENDAR_PROPERTY_FILTER_STR( attendee_name )
+ _CALENDAR_PROPERTY_FILTER_STR( attendee_member )
_CALENDAR_END_READ_ONLY_VIEW( _calendar_event_calendar_book_attendee )
+/**
+ * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
+ * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE View/Property
+ * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_instance_utime_calendar_book _calendar_instance_utime_calendar_book view
+ * <table>
+ * <tr>
+ * <th> Type </th>
+ * <th> Property ID </th>
+ * </tr>
+ * <tr><td> string </td><td> _uri </td></tr>
+ * <tr><td> integer </td><td> event_id </td></tr>
+ * <tr><td> calendar time </td><td> start_time </td></tr>
+ * <tr><td> calendar time </td><td> end_time </td></tr>
+ * <tr><td> string </td><td> summary </td></tr>
+ * <tr><td> string </td><td> location </td></tr>
+ * <tr><td> integer </td><td> calendar_book_id </td></tr>
+ * <tr><td> string </td><td> description </td></tr>
+ * <tr><td> integer </td><td> busy_status </td></tr>
+ * <tr><td> integer </td><td> event_status </td></tr>
+ * <tr><td> integer </td><td> priority </td></tr>
+ * <tr><td> integer </td><td> sensitivity </td></tr>
+ * <tr><td> integer </td><td> has_rrule </td></tr>
+ * <tr><td> double </td><td> latitude </td></tr>
+ * <tr><td> double </td><td> longitude </td></tr>
+ * <tr><td> integer </td><td> has_alarm </td></tr>
+ * <tr><td> integer </td><td> original_event_id </td></tr>
+ * <tr><td> filter integer </td><td> calendar_book_visibility </td></tr>
+ * <tr><td> filter integer </td><td> calendar_book_account_id </td></tr>
+ * <tr><td> long long int </td><td> last_modified_time </td></tr>
+ * <tr><td> string </td><td> sync_data1 </td></tr>
+ * </table>
+ */
+_CALENDAR_BEGIN_READ_ONLY_VIEW()
+ _CALENDAR_PROPERTY_INT( event_id )
+ _CALENDAR_PROPERTY_CALTIME( start_time )
+ _CALENDAR_PROPERTY_CALTIME( end_time )
+ _CALENDAR_PROPERTY_STR( summary )
+ _CALENDAR_PROPERTY_STR( location )
+ _CALENDAR_PROPERTY_INT( calendar_book_id )
+ _CALENDAR_PROPERTY_STR( description )
+ _CALENDAR_PROPERTY_INT( busy_status )
+ _CALENDAR_PROPERTY_INT( event_status )
+ _CALENDAR_PROPERTY_INT( priority )
+ _CALENDAR_PROPERTY_INT( sensitivity )
+ _CALENDAR_PROPERTY_INT( has_rrule )
+ _CALENDAR_PROPERTY_DOUBLE( latitude )
+ _CALENDAR_PROPERTY_DOUBLE( longitude )
+ _CALENDAR_PROPERTY_INT( has_alarm )
+ _CALENDAR_PROPERTY_INT( original_event_id )
+ _CALENDAR_PROPERTY_FILTER_INT( calendar_book_visibility )
+ _CALENDAR_PROPERTY_FILTER_INT( calendar_book_account_id )
+ _CALENDAR_PROPERTY_LLI( last_modified_time )
+ _CALENDAR_PROPERTY_STR( sync_data1 )
+_CALENDAR_END_READ_ONLY_VIEW( _calendar_instance_utime_calendar_book )
+
+/**
+ * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
+ * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE View/Property
+ * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_instance_localtime_calendar_book _calendar_instance_localtime_calendar_book view
+ * <table>
+ * <tr>
+ * <th> Type </th>
+ * <th> Property ID </th>
+ * </tr>
+ * <tr><td> string </td><td> _uri </td></tr>
+ * <tr><td> integer </td><td> event_id </td></tr>
+ * <tr><td> calendar time </td><td> start_time </td></tr>
+ * <tr><td> calendar time </td><td> end_time </td></tr>
+ * <tr><td> string </td><td> summary </td></tr>
+ * <tr><td> string </td><td> location </td></tr>
+ * <tr><td> integer </td><td> calendar_book_id </td></tr>
+ * <tr><td> string </td><td> description </td></tr>
+ * <tr><td> integer </td><td> busy_status </td></tr>
+ * <tr><td> integer </td><td> event_status </td></tr>
+ * <tr><td> integer </td><td> priority </td></tr>
+ * <tr><td> integer </td><td> sensitivity </td></tr>
+ * <tr><td> integer </td><td> has_rrule </td></tr>
+ * <tr><td> double </td><td> latitude </td></tr>
+ * <tr><td> double </td><td> longitude </td></tr>
+ * <tr><td> integer </td><td> has_alarm </td></tr>
+ * <tr><td> integer </td><td> original_event_id </td></tr>
+ * <tr><td> filter integer </td><td> calendar_book_visibility </td></tr>
+ * <tr><td> filter integer </td><td> calendar_book_account_id </td></tr>
+ * <tr><td> long long int </td><td> last_modified_time </td></tr>
+ * <tr><td> string </td><td> sync_data1 </td></tr>
+ * <tr><td> int </td><td> is_allday </td></tr>
+ * </table>
+ */
+_CALENDAR_BEGIN_READ_ONLY_VIEW()
+ _CALENDAR_PROPERTY_INT( event_id )
+ _CALENDAR_PROPERTY_CALTIME( start_time )
+ _CALENDAR_PROPERTY_CALTIME( end_time )
+ _CALENDAR_PROPERTY_STR( summary )
+ _CALENDAR_PROPERTY_STR( location )
+ _CALENDAR_PROPERTY_INT( calendar_book_id )
+ _CALENDAR_PROPERTY_STR( description )
+ _CALENDAR_PROPERTY_INT( busy_status )
+ _CALENDAR_PROPERTY_INT( event_status )
+ _CALENDAR_PROPERTY_INT( priority )
+ _CALENDAR_PROPERTY_INT( sensitivity )
+ _CALENDAR_PROPERTY_INT( has_rrule )
+ _CALENDAR_PROPERTY_DOUBLE( latitude )
+ _CALENDAR_PROPERTY_DOUBLE( longitude )
+ _CALENDAR_PROPERTY_INT( has_alarm )
+ _CALENDAR_PROPERTY_INT( original_event_id )
+ _CALENDAR_PROPERTY_FILTER_INT( calendar_book_visibility )
+ _CALENDAR_PROPERTY_FILTER_INT( calendar_book_account_id )
+ _CALENDAR_PROPERTY_LLI( last_modified_time )
+ _CALENDAR_PROPERTY_STR( sync_data1 )
+ _CALENDAR_PROPERTY_INT( is_allday )
+_CALENDAR_END_READ_ONLY_VIEW( _calendar_instance_localtime_calendar_book )
+
+/**
+ * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
+ * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE View/Property
+ * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_instance_utime_calendar_book_extended _calendar_instance_utime_calendar_book_extended view
+ * <table>
+ * <tr>
+ * <th> Type </th>
+ * <th> Property ID </th>
+ * </tr>
+ * <tr><td> string </td><td> _uri </td></tr>
+ * <tr><td> integer </td><td> event_id </td></tr>
+ * <tr><td> calendar time </td><td> start_time </td></tr>
+ * <tr><td> calendar time </td><td> end_time </td></tr>
+ * <tr><td> string </td><td> summary </td></tr>
+ * <tr><td> string </td><td> location </td></tr>
+ * <tr><td> integer </td><td> calendar_book_id </td></tr>
+ * <tr><td> string </td><td> description </td></tr>
+ * <tr><td> integer </td><td> busy_status </td></tr>
+ * <tr><td> integer </td><td> event_status </td></tr>
+ * <tr><td> integer </td><td> priority </td></tr>
+ * <tr><td> integer </td><td> sensitivity </td></tr>
+ * <tr><td> integer </td><td> has_rrule </td></tr>
+ * <tr><td> double </td><td> latitude </td></tr>
+ * <tr><td> double </td><td> longitude </td></tr>
+ * <tr><td> integer </td><td> has_alarm </td></tr>
+ * <tr><td> integer </td><td> original_event_id </td></tr>
+ * <tr><td> filter integer </td><td> calendar_book_visibility </td></tr>
+ * <tr><td> filter integer </td><td> calendar_book_account_id </td></tr>
+ * <tr><td> string </td><td> organizer_name </td></tr>
+ * <tr><td> string </td><td> categories </td></tr>
+ * <tr><td> integer </td><td> has_attendee </td></tr>
+ * <tr><td> string </td><td> sync_data1 </td></tr>
+ * <tr><td> string </td><td> sync_data2 </td></tr>
+ * <tr><td> string </td><td> sync_data3 </td></tr>
+ * <tr><td> string </td><td> sync_data4 </td></tr>
+ * </table>
+ */
_CALENDAR_BEGIN_READ_ONLY_VIEW()
_CALENDAR_PROPERTY_INT( event_id )
_CALENDAR_PROPERTY_CALTIME( start_time )
_CALENDAR_PROPERTY_FILTER_INT( calendar_book_visibility )
_CALENDAR_PROPERTY_FILTER_INT( calendar_book_account_id )
_CALENDAR_PROPERTY_LLI( last_modified_time )
-_CALENDAR_END_READ_ONLY_VIEW( _calendar_instance_normal_calendar_book )
+ _CALENDAR_PROPERTY_STR( sync_data1 )
+ _CALENDAR_PROPERTY_STR( organizer_name )
+ _CALENDAR_PROPERTY_STR( categories )
+ _CALENDAR_PROPERTY_INT( has_attendee )
+ _CALENDAR_PROPERTY_STR( sync_data2 )
+ _CALENDAR_PROPERTY_STR( sync_data3 )
+ _CALENDAR_PROPERTY_STR( sync_data4 )
+_CALENDAR_END_READ_ONLY_VIEW( _calendar_instance_utime_calendar_book_extended )
+/**
+ * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
+ * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE View/Property
+ * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_instance_localtime_calendar_book_extended _calendar_instance_localtime_calendar_book_extended view
+ * <table>
+ * <tr>
+ * <th> Type </th>
+ * <th> Property ID </th>
+ * </tr>
+ * <tr><td> string </td><td> _uri </td></tr>
+ * <tr><td> integer </td><td> event_id </td></tr>
+ * <tr><td> calendar time </td><td> start_time </td></tr>
+ * <tr><td> calendar time </td><td> end_time </td></tr>
+ * <tr><td> string </td><td> summary </td></tr>
+ * <tr><td> string </td><td> location </td></tr>
+ * <tr><td> integer </td><td> calendar_book_id </td></tr>
+ * <tr><td> string </td><td> description </td></tr>
+ * <tr><td> integer </td><td> busy_status </td></tr>
+ * <tr><td> integer </td><td> event_status </td></tr>
+ * <tr><td> integer </td><td> priority </td></tr>
+ * <tr><td> integer </td><td> sensitivity </td></tr>
+ * <tr><td> integer </td><td> has_rrule </td></tr>
+ * <tr><td> double </td><td> latitude </td></tr>
+ * <tr><td> double </td><td> longitude </td></tr>
+ * <tr><td> integer </td><td> has_alarm </td></tr>
+ * <tr><td> integer </td><td> original_event_id </td></tr>
+ * <tr><td> filter integer </td><td> calendar_book_visibility </td></tr>
+ * <tr><td> filter integer </td><td> calendar_book_account_id </td></tr>
+ * <tr><td> string </td><td> organizer_name </td></tr>
+ * <tr><td> string </td><td> categories </td></tr>
+ * <tr><td> integer </td><td> has_attendee </td></tr>
+ * <tr><td> string </td><td> sync_data1 </td></tr>
+ * <tr><td> string </td><td> sync_data2 </td></tr>
+ * <tr><td> string </td><td> sync_data3 </td></tr>
+ * <tr><td> string </td><td> sync_data4 </td></tr>
+ * </table>
+ */
_CALENDAR_BEGIN_READ_ONLY_VIEW()
_CALENDAR_PROPERTY_INT( event_id )
_CALENDAR_PROPERTY_CALTIME( start_time )
_CALENDAR_PROPERTY_FILTER_INT( calendar_book_visibility )
_CALENDAR_PROPERTY_FILTER_INT( calendar_book_account_id )
_CALENDAR_PROPERTY_LLI( last_modified_time )
-_CALENDAR_END_READ_ONLY_VIEW( _calendar_instance_allday_calendar_book )
+ _CALENDAR_PROPERTY_STR( sync_data1 )
+ _CALENDAR_PROPERTY_STR( organizer_name )
+ _CALENDAR_PROPERTY_STR( categories )
+ _CALENDAR_PROPERTY_INT( has_attendee )
+ _CALENDAR_PROPERTY_INT( is_allday )
+ _CALENDAR_PROPERTY_STR( sync_data2 )
+ _CALENDAR_PROPERTY_STR( sync_data3 )
+ _CALENDAR_PROPERTY_STR( sync_data4 )
+_CALENDAR_END_READ_ONLY_VIEW( _calendar_instance_localtime_calendar_book_extended )
+/**
+ * @ingroup CAPI_SOCIAL_CALENDAR_SVC_MODULE
+ * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE View/Property
+ * @section CAPI_SOCIAL_CALENDAR_SVC_VIEW_MODULE_calendar_extended_property _calendar_extended_property view (read only)
+ * <table>
+ * <tr>
+ * <th> Type </th>
+ * <th> Property ID </th>
+ * <th> Read, Write </th>
+ * <th> Description </th>
+ * </tr>
+ * <tr><td> string </td><td> _uri </td><td> read only </td><td></td> Identifier of this extended_property view </tr>
+ * <tr><td> integer </td><td> id </td><td> read only </td><td> DB record ID of the extended_property </td></tr>
+ * <tr><td> integer </td><td> record_id </td><td> read,write </td><td> Related record ID </td></tr>
+ * <tr><td> integer </td><td> record_type </td><td> read, write </td><td> Enumeration value of the record type (@ref calendar_record_type_e) </td></tr>
+ * <tr><td> string </td><td> key </td><td> read, write </td><td> The key of the property </td></tr>
+ * <tr><td> string </td><td> value </td><td> read, write </td><td> The value of the property </td></tr>
+ * </table>
+ */
_CALENDAR_BEGIN_VIEW()
- _CALENDAR_PROPERTY_INT( id )
+ _CALENDAR_PROPERTY_INT( id ) // read_only
_CALENDAR_PROPERTY_INT( record_id )
_CALENDAR_PROPERTY_INT( record_type )
_CALENDAR_PROPERTY_STR( key )
${CMAKE_SOURCE_DIR}/common/cal_record_updated_info.c
${CMAKE_SOURCE_DIR}/common/cal_record_instance_normal.c
${CMAKE_SOURCE_DIR}/common/cal_record_instance_allday.c
+ ${CMAKE_SOURCE_DIR}/common/cal_record_instance_normal_extended.c
+ ${CMAKE_SOURCE_DIR}/common/cal_record_instance_allday_extended.c
${CMAKE_SOURCE_DIR}/common/cal_record_extended.c
${CMAKE_SOURCE_DIR}/common/cal_view.c
${CMAKE_SOURCE_DIR}/common/cal_filter.c
${CMAKE_SOURCE_DIR}/native/cal_db_query.c
${CMAKE_SOURCE_DIR}/native/cal_db_plugin_calendar.c
${CMAKE_SOURCE_DIR}/native/cal_db_plugin_event.c
+ ${CMAKE_SOURCE_DIR}/native/cal_db_event.c
+ ${CMAKE_SOURCE_DIR}/native/cal_db_plugin_attendee.c
+ ${CMAKE_SOURCE_DIR}/native/cal_db_plugin_alarm.c
${CMAKE_SOURCE_DIR}/native/cal_db_plugin_search.c
${CMAKE_SOURCE_DIR}/native/cal_db_plugin_timezone.c
${CMAKE_SOURCE_DIR}/native/cal_db_plugin_instance_normal.c
+ ${CMAKE_SOURCE_DIR}/native/cal_db_plugin_instance_normal_extended.c
${CMAKE_SOURCE_DIR}/native/cal_db_plugin_instance_allday.c
+ ${CMAKE_SOURCE_DIR}/native/cal_db_plugin_instance_allday_extended.c
${CMAKE_SOURCE_DIR}/native/cal_db_plugin_todo.c
${CMAKE_SOURCE_DIR}/native/cal_db_plugin_extended.c
${CMAKE_SOURCE_DIR}/native/cal_db_extended.c
${CMAKE_SOURCE_DIR}/native/cal_reminder.c
+ ${CMAKE_SOURCE_DIR}/native/cal_db_instance_helper.c
)
INCLUDE(FindPkgConfig)
-pkg_check_modules(servicenative_pkgs REQUIRED db-util appsvc alarm-service capi-base-common)
+pkg_check_modules(servicenative_pkgs REQUIRED db-util alarm-service capi-base-common)
FOREACH(flag ${servicenative_pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-ADD_LIBRARY(${CALSVCNATIVE} SHARED ${SRCS})
-SET_TARGET_PROPERTIES(${CALSVCNATIVE} PROPERTIES SOVERSION ${VERSION_MAJOR})
-SET_TARGET_PROPERTIES(${CALSVCNATIVE} PROPERTIES VERSION ${VERSION})
-TARGET_LINK_LIBRARIES(${CALSVCNATIVE} ${servicenative_pkgs_LDFLAGS})
+#ADD_LIBRARY(${CALSVCNATIVE} SHARED ${SRCS})
+#SET_TARGET_PROPERTIES(${CALSVCNATIVE} PROPERTIES SOVERSION ${VERSION_MAJOR})
+#SET_TARGET_PROPERTIES(${CALSVCNATIVE} PROPERTIES VERSION ${VERSION})
+#TARGET_LINK_LIBRARIES(${CALSVCNATIVE} ${servicenative_pkgs_LDFLAGS})
INSTALL(TARGETS ${CALSVCNATIVE} DESTINATION ${LIB_INSTALL_DIR})
--- /dev/null
+/*
+ * Calendar Service
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <pthread.h>
+#include <signal.h>
+#include <security-server.h>
+#include <sys/smack.h>
+
+#include <string.h>
+#include <pims-ipc-svc.h>
+
+#include "calendar_db.h"
+
+#include "cal_internal.h"
+#include "cal_typedef.h"
+#include "cal_view.h"
+#include "cal_time.h"
+#include "cal_record.h"
+#include "cal_mutex.h"
+#include "cal_db_util.h"
+#include "cal_db.h"
+#include "cal_access_control.h"
+#include "cal_service.h"
+
+typedef struct {
+ unsigned int thread_id;
+ char *smack_label;
+ cal_permission_e permission;
+ int *write_list;
+}calendar_permission_info_s;
+
+static GList *__thread_list = NULL;
+
+static int have_smack = -1;
+
+static calendar_permission_info_s* __cal_access_control_find_permission_info(unsigned int thread_id);
+static void __cal_access_control_set_permission_info(unsigned int thread_id, const char *cookie);
+static void __cal_access_control_disconnected_cb(pims_ipc_h ipc, void *user_data);
+
+static calendar_permission_info_s* __cal_access_control_find_permission_info(unsigned int thread_id)
+{
+ GList *cursor;
+
+ for(cursor=__thread_list;cursor;cursor=cursor->next) {
+ calendar_permission_info_s *info = NULL;
+ info = cursor->data;
+ if (info->thread_id == thread_id)
+ return info;
+ }
+ return NULL;
+}
+
+// check SMACK enable or disable
+static int __cal_have_smack(void)
+{
+ if (-1 == have_smack) {
+ if (NULL == smack_smackfs_path())
+ have_smack = 0;
+ else
+ have_smack = 1;
+ }
+ return have_smack;
+}
+
+static void __cal_access_control_set_permission_info(unsigned int thread_id, const char *cookie)
+{
+ calendar_permission_info_s *info = NULL;
+ const char *smack_label;
+ bool smack_enabled = false;
+
+ if (__cal_have_smack() == 1)
+ smack_enabled = true;
+ else
+ INFO("SAMCK disabled");
+
+ info = __cal_access_control_find_permission_info(thread_id);
+ if(info == NULL) {
+ ERR("dont' have access info of this thread(%d)", thread_id);
+ return ;
+ }
+ smack_label = info->smack_label;
+
+ if ((smack_label && 0 == strcmp(smack_label, "calendar-service")) || !smack_enabled) {
+ info->permission |= CAL_PERMISSION_READ;
+ info->permission |= CAL_PERMISSION_WRITE;
+ }
+ else if (cookie) {
+ if (SECURITY_SERVER_API_SUCCESS == security_server_check_privilege_by_cookie(cookie, "calendar-service::svc", "r"))
+ info->permission |= CAL_PERMISSION_READ;
+ if (SECURITY_SERVER_API_SUCCESS == security_server_check_privilege_by_cookie(cookie, "calendar-service::svc", "w"))
+ info->permission |= CAL_PERMISSION_WRITE;
+ }
+ SEC_INFO("Thread(0x%x), info(%p), smack :%s, permission:%d", thread_id, info, smack_label, info->permission);
+
+ CAL_FREE(info->write_list);
+
+ char query[CAL_DB_SQL_MAX_LEN] = {0,};
+ int count = 0;
+ int ret = 0;
+ sqlite3_stmt *stmt;
+ int write_index = 0;
+ snprintf(query, sizeof(query),
+ "SELECT count(id) FROM %s WHERE deleted = 0 ", CAL_TABLE_CALENDAR);
+ ret = _cal_db_util_query_get_first_int_result(query, NULL, &count);
+
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("DB get Failed");
+ return;
+ }
+
+ if (info->permission & CAL_PERMISSION_WRITE) {
+ info->write_list = calloc(count+1, sizeof(int));
+ info->write_list[0] = -1;
+ }
+
+ snprintf(query, sizeof(query),
+ "SELECT id, mode, owner_label FROM %s WHERE deleted = 0 ", CAL_TABLE_CALENDAR);
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt) {
+ ERR("DB Failed");
+ return;
+ }
+
+ while (CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
+ int id = 0;
+ int mode = 0;
+ char *temp = NULL;
+
+ id = sqlite3_column_int(stmt, 0);
+ mode = sqlite3_column_int(stmt, 1);
+ temp = (char *)sqlite3_column_text(stmt, 2);
+
+ if ( temp && ( (smack_label && 0 == strcmp(temp, smack_label)) ||
+ ( smack_label && 0 == strcmp(smack_label, "calendar-service") ) ) ) {// owner and calendar-service
+ if (info->permission & CAL_PERMISSION_WRITE)
+ info->write_list[write_index++] = id;
+ }
+ else {
+ switch(mode) {
+ case CALENDAR_BOOK_MODE_NONE:
+ if (info->permission & CAL_PERMISSION_WRITE)
+ info->write_list[write_index++] = id;
+ break;
+ case CALENDAR_BOOK_MODE_RECORD_READONLY:
+ default:
+ break;
+ }
+ }
+ } // while
+
+ if (info->permission & CAL_PERMISSION_WRITE)
+ info->write_list[write_index] = -1;
+
+ sqlite3_finalize(stmt);
+}
+
+void _cal_access_control_set_client_info(const char* smack_label, const char* cookie)
+{
+ unsigned int thread_id = (unsigned int)pthread_self();
+ calendar_permission_info_s *info = NULL;
+
+ _cal_mutex_lock(CAL_MUTEX_ACCESS_CONTROL);
+ info = __cal_access_control_find_permission_info(thread_id);
+ if (NULL == info) {
+ info = calloc(1, sizeof(calendar_permission_info_s));
+ __thread_list = g_list_append(__thread_list, info);
+ }
+ info->thread_id = thread_id;
+ CAL_FREE(info->smack_label);
+ info->smack_label = SAFE_STRDUP(smack_label);
+ __cal_access_control_set_permission_info(thread_id, cookie);
+
+ // for close DB or free access_control when client is disconnected
+ pims_ipc_svc_set_client_disconnected_cb(__cal_access_control_disconnected_cb,NULL);
+
+ _cal_mutex_unlock(CAL_MUTEX_ACCESS_CONTROL);
+}
+
+void _cal_access_control_unset_client_info(void)
+{
+ calendar_permission_info_s *find = NULL;
+
+ _cal_mutex_lock(CAL_MUTEX_ACCESS_CONTROL);
+ find = __cal_access_control_find_permission_info(pthread_self());
+ if (find) {
+ CAL_FREE(find->smack_label);
+ CAL_FREE(find->write_list);
+ __thread_list = g_list_remove(__thread_list, find);
+ free(find);
+ }
+ _cal_mutex_unlock(CAL_MUTEX_ACCESS_CONTROL);
+}
+
+bool _cal_access_control_have_permission(cal_permission_e permission)
+{
+ calendar_permission_info_s *find = NULL;
+
+ _cal_mutex_lock(CAL_MUTEX_ACCESS_CONTROL);
+ find = __cal_access_control_find_permission_info(pthread_self());
+ if (!find) {
+ _cal_mutex_unlock(CAL_MUTEX_ACCESS_CONTROL);
+ return false;
+ }
+
+ if (CAL_PERMISSION_NONE == permission) {
+ _cal_mutex_unlock(CAL_MUTEX_ACCESS_CONTROL);
+ return false;
+ }
+
+ if ((find->permission & permission) == permission) {
+ _cal_mutex_unlock(CAL_MUTEX_ACCESS_CONTROL);
+ return true;
+ }
+
+ _cal_mutex_unlock(CAL_MUTEX_ACCESS_CONTROL);
+ ERR("Does not have permission %d, this module has permission %d",
+ permission, find->permission);
+
+ return false;
+}
+
+char* _cal_access_control_get_label(void)
+{
+ unsigned int thread_id = (unsigned int)pthread_self();
+ calendar_permission_info_s *info = NULL;
+ char *tmp = NULL;
+
+ _cal_mutex_lock(CAL_MUTEX_ACCESS_CONTROL);
+ info = __cal_access_control_find_permission_info(thread_id);
+
+ if (info == NULL) {
+ _cal_mutex_unlock(CAL_MUTEX_ACCESS_CONTROL);
+ return NULL;
+ }
+ tmp = SAFE_STRDUP(info->smack_label);
+ _cal_mutex_unlock(CAL_MUTEX_ACCESS_CONTROL);
+
+ return tmp;
+}
+
+
+void _cal_access_control_reset(void)
+{
+ _cal_mutex_lock(CAL_MUTEX_ACCESS_CONTROL);
+ GList *cursor;
+ for(cursor=__thread_list;cursor;cursor=cursor->next) {
+ calendar_permission_info_s *info = NULL;
+ info = cursor->data;
+ if (info)
+ __cal_access_control_set_permission_info(info->thread_id, NULL);
+ }
+ _cal_mutex_unlock(CAL_MUTEX_ACCESS_CONTROL);
+}
+
+bool _cal_access_control_have_write_permission(int calendarbook_id)
+{
+ int i = 0;
+ calendar_permission_info_s *find = NULL;
+
+ _cal_mutex_lock(CAL_MUTEX_ACCESS_CONTROL);
+ find = __cal_access_control_find_permission_info(pthread_self());
+ if (!find) {
+ _cal_mutex_unlock(CAL_MUTEX_ACCESS_CONTROL);
+ ERR("can not found access info");
+ return false;
+ }
+
+ if (NULL == find->write_list) {
+ _cal_mutex_unlock(CAL_MUTEX_ACCESS_CONTROL);
+ ERR("there is no write access info");
+ return false;
+ }
+
+ while(1) {
+ if (find->write_list[i] == -1)
+ break;
+ if (calendarbook_id == find->write_list[i]) {
+ _cal_mutex_unlock(CAL_MUTEX_ACCESS_CONTROL);
+ return true;
+ }
+ i++;
+ }
+
+ _cal_mutex_unlock(CAL_MUTEX_ACCESS_CONTROL);
+ return false;
+}
+
+static void __cal_access_control_disconnected_cb(pims_ipc_h ipc, void *user_data)
+{
+ ENTER();
+ calendar_permission_info_s *find = NULL;
+
+ _cal_mutex_lock(CAL_MUTEX_ACCESS_CONTROL);
+ find = __cal_access_control_find_permission_info(pthread_self());
+ if (find) {
+ CAL_FREE(find->smack_label);
+ CAL_FREE(find->write_list);
+ __thread_list = g_list_remove(__thread_list, find);
+ free(find);
+ }
+ _cal_mutex_unlock(CAL_MUTEX_ACCESS_CONTROL);
+ // if client did not call disconnect function such as disconnect
+ // DB will be closed in _cal_db_internal_disconnect()
+ _cal_calendar_internal_disconnect();
+}
+
+int _cal_is_owner(int calendarbook_id)
+{
+ int ret;
+ sqlite3_stmt *stmt = NULL;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ char *owner_label = NULL;
+ char *saved_smack = NULL;
+
+ snprintf(query, sizeof(query),
+ "SELECT owner_label FROM "CAL_TABLE_CALENDAR" "
+ "WHERE id = %d", calendarbook_id);
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt) {
+ ERR("DB error : _cal_db_util_query_prepare() Failed()");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ ret = _cal_db_util_stmt_step(stmt);
+ if (CAL_DB_ROW != ret) {
+ ERR("_cal_db_util_stmt_step() Failed(%d)", ret);
+ sqlite3_finalize(stmt);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ ret = CALENDAR_ERROR_PERMISSION_DENIED;
+
+ owner_label = (char*)sqlite3_column_text(stmt, 0);
+ saved_smack = _cal_access_control_get_label();
+
+ if (owner_label && saved_smack && strcmp(owner_label, saved_smack) == 0)
+ ret = CALENDAR_ERROR_NONE;
+
+ sqlite3_finalize(stmt);
+
+ free(saved_smack);
+ return ret;
+}
+
--- /dev/null
+/*
+ * Calendar Service
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __CALENDAR_SVC_ACCESS_CONTROL_H__
+#define __CALENDAR_SVC_ACCESS_CONTROL_H__
+
+#include "cal_typedef.h"
+
+void _cal_access_control_set_client_info(const char* smack_label, const char* cookie);
+void _cal_access_control_unset_client_info(void);
+bool _cal_access_control_have_permission(cal_permission_e permission);
+
+char* _cal_access_control_get_label(void);
+
+void _cal_access_control_reset(void); // reset read_list, write_list..
+bool _cal_access_control_have_write_permission(int calendarbook_id);
+
+int _cal_is_owner(int calendarbook_id);
+
+#endif // __CALENDAR_SVC_ACCESS_CONTROL_H__
+
#include <glib-object.h>
#include <db-util.h>
+#include "cal_service.h"
#include "cal_internal.h"
#include "cal_typedef.h"
#include "cal_db.h"
_cal_view_initialize();
- DBG("db_ref_cnt(%d)", db_ref_cnt);
+ DBG("db_ref_cnt(%d)", db_ref_cnt);
return CALENDAR_ERROR_NONE;
}
{
CAL_FN_CALL;
- DBG("db_ref_cnt(%d)", db_ref_cnt);
- DBG("pthread_self=%x, db_ref_cnt=%p", pthread_self(),&db_ref_cnt );
+ DBG("db_ref_cnt(%d)", db_ref_cnt);
+ DBG("pthread_self=%x, db_ref_cnt=%p", pthread_self(),&db_ref_cnt );
retvm_if(0 == db_ref_cnt, CALENDAR_ERROR_INVALID_PARAMETER,
"Calendar service was not connected");
- if (db_ref_cnt==1) {
+ if (db_ref_cnt==1)
+ {
_cal_db_close();
db_ref_cnt = 0;
return CALENDAR_ERROR_NONE;
}
+void _cal_calendar_internal_disconnect(void)
+{
+ ENTER();
+ if (db_ref_cnt > 0)
+ {
+ _cal_db_close();
+
+ db_ref_cnt = 0;
+ }
+}
+
#ifdef CAL_NATIVE
API int calendar_db_add_changed_cb(const char* view_uri, calendar_db_changed_cb callback, void* user_data )
{
- CAL_FN_CALL;
- int ret;
- cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
-
- retv_if(NULL == view_uri || NULL == callback , CALENDAR_ERROR_INVALID_PARAMETER);
-
- type = _cal_view_get_type(view_uri);
-
- switch(type)
- {
- case CAL_RECORD_TYPE_CALENDAR:
- ret = _cal_inotify_subscribe(CAL_NOTI_TYPE_CALENDAR, CAL_NOTI_CALENDAR_CHANGED, callback, user_data);
- break;
- case CAL_RECORD_TYPE_EVENT:
- ret = _cal_inotify_subscribe(CAL_NOTI_TYPE_EVENT, CAL_NOTI_EVENT_CHANGED, callback, user_data);
- break;
- case CAL_RECORD_TYPE_TODO:
- ret = _cal_inotify_subscribe(CAL_NOTI_TYPE_TODO, CAL_NOTI_TODO_CHANGED, callback, user_data);
- break;
- default:
- ERR("Invalid view_uri(%s)", view_uri);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- retvm_if(CALENDAR_ERROR_NONE != ret, ret, "_cal_inotify_subscribe() Failed(%d)", ret);
-
- return CALENDAR_ERROR_NONE;
+ CAL_FN_CALL;
+ int ret;
+ cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
+
+ retv_if(NULL == view_uri || NULL == callback , CALENDAR_ERROR_INVALID_PARAMETER);
+
+ type = _cal_view_get_type(view_uri);
+
+ switch(type)
+ {
+ case CAL_RECORD_TYPE_CALENDAR:
+ ret = _cal_inotify_subscribe(CAL_NOTI_TYPE_CALENDAR, CAL_NOTI_CALENDAR_CHANGED, callback, user_data);
+ break;
+ case CAL_RECORD_TYPE_EVENT:
+ ret = _cal_inotify_subscribe(CAL_NOTI_TYPE_EVENT, CAL_NOTI_EVENT_CHANGED, callback, user_data);
+ break;
+ case CAL_RECORD_TYPE_TODO:
+ ret = _cal_inotify_subscribe(CAL_NOTI_TYPE_TODO, CAL_NOTI_TODO_CHANGED, callback, user_data);
+ break;
+ default:
+ ERR("Invalid view_uri(%s)", view_uri);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ retvm_if(CALENDAR_ERROR_NONE != ret, ret, "_cal_inotify_subscribe() Failed(%d)", ret);
+
+ return CALENDAR_ERROR_NONE;
}
API int calendar_db_remove_changed_cb( const char* view_uri, calendar_db_changed_cb callback, void* user_data )
{
- CAL_FN_CALL;
- int ret;
- cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
+ CAL_FN_CALL;
+ int ret;
+ cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
- retv_if(NULL == view_uri || NULL == callback , CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(NULL == view_uri || NULL == callback , CALENDAR_ERROR_INVALID_PARAMETER);
- type = _cal_view_get_type(view_uri);
+ type = _cal_view_get_type(view_uri);
- switch(type)
- {
- case CAL_RECORD_TYPE_CALENDAR:
- ret = _cal_inotify_unsubscribe_with_data(CAL_NOTI_CALENDAR_CHANGED,
+ switch(type)
+ {
+ case CAL_RECORD_TYPE_CALENDAR:
+ ret = _cal_inotify_unsubscribe_with_data(CAL_NOTI_CALENDAR_CHANGED,
callback, user_data);
- break;
- case CAL_RECORD_TYPE_EVENT:
- ret = _cal_inotify_unsubscribe_with_data(CAL_NOTI_EVENT_CHANGED,
+ break;
+ case CAL_RECORD_TYPE_EVENT:
+ ret = _cal_inotify_unsubscribe_with_data(CAL_NOTI_EVENT_CHANGED,
callback, user_data);
- break;
- case CAL_RECORD_TYPE_TODO:
- ret = _cal_inotify_unsubscribe_with_data(CAL_NOTI_TODO_CHANGED,
+ break;
+ case CAL_RECORD_TYPE_TODO:
+ ret = _cal_inotify_unsubscribe_with_data(CAL_NOTI_TODO_CHANGED,
callback, user_data);
- break;
- default:
- ERR("Invalid view_uri(%s)", view_uri);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- retvm_if(CALENDAR_ERROR_NONE != ret, ret, "_cal_inotify_unsubscribe_with_data() Failed(%d)", ret);
-
- return CALENDAR_ERROR_NONE;
+ break;
+ default:
+ ERR("Invalid view_uri(%s)", view_uri);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ retvm_if(CALENDAR_ERROR_NONE != ret, ret, "_cal_inotify_unsubscribe_with_data() Failed(%d)", ret);
+
+ return CALENDAR_ERROR_NONE;
}
API int calendar_connect_on_thread(void)
{
- CAL_FN_CALL;
- int ret = 0;
+ CAL_FN_CALL;
+ int ret = 0;
- DBG("pthread_self=%x, db_ref_cnt=%p", pthread_self(),&db_ref_cnt );
+ DBG("pthread_self=%x, db_ref_cnt=%p", pthread_self(),&db_ref_cnt );
- g_type_init(); // added for alarmmgr
+ g_type_init(); // added for alarmmgr
- if(db_ref_cnt <= 0)
- {
- ret = _cal_db_open();
- retvm_if(ret, ret, "cal_db_open() Failed(%d)", ret);
+ if(db_ref_cnt <= 0)
+ {
+ ret = _cal_db_open();
+ retvm_if(ret, ret, "cal_db_open() Failed(%d)", ret);
- db_ref_cnt = 0;
- _cal_inotify_initialize();
+ db_ref_cnt = 0;
+ _cal_inotify_initialize();
- }
- db_ref_cnt++;
+ }
+ db_ref_cnt++;
- _cal_view_initialize();
+ _cal_view_initialize();
- DBG("db_ref_cnt(%d)", db_ref_cnt);
+ DBG("db_ref_cnt(%d)", db_ref_cnt);
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
API int calendar_disconnect_on_thread(void)
{
- CAL_FN_CALL;
+ CAL_FN_CALL;
- DBG("db_ref_cnt(%d)", db_ref_cnt);
- DBG("pthread_self=%x, db_ref_cnt=%p", pthread_self(),&db_ref_cnt );
+ DBG("db_ref_cnt(%d)", db_ref_cnt);
+ DBG("pthread_self=%x, db_ref_cnt=%p", pthread_self(),&db_ref_cnt );
- retvm_if(0 == db_ref_cnt, CALENDAR_ERROR_INVALID_PARAMETER,
- "Calendar service was not connected");
+ retvm_if(0 == db_ref_cnt, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Calendar service was not connected");
- if (db_ref_cnt==1) {
- _cal_db_close();
+ if (db_ref_cnt==1) {
+ _cal_db_close();
- db_ref_cnt = 0;
+ db_ref_cnt = 0;
- _cal_inotify_finalize();
+ _cal_inotify_finalize();
- _cal_view_finalize();
- return CALENDAR_ERROR_NONE;
- }
- db_ref_cnt--;
+ _cal_view_finalize();
+ return CALENDAR_ERROR_NONE;
+ }
+ db_ref_cnt--;
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
API int calendar_connect_with_flags(unsigned int flags)
{
- int ret = CALENDAR_ERROR_NONE;
-
- ret = calendar_connect();
- if (ret != CALENDAR_ERROR_NONE)
- {
- if (flags & CALENDAR_CONNECT_FLAG_RETRY)
- {
- int retry_time = 500;
- int i = 0;
- for(i=0;i<6;i++)
- {
- usleep(retry_time*1000);
- ret = calendar_connect();
- DBG("retry cnt=%d, ret=%x",(i+1), ret);
- if (ret == CALENDAR_ERROR_NONE)
- break;
- retry_time *= 2;
- }
-
- }
- }
-
- return ret;
+ int ret = CALENDAR_ERROR_NONE;
+
+ ret = calendar_connect();
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ if (flags & CALENDAR_CONNECT_FLAG_RETRY)
+ {
+ int retry_time = 500;
+ int i = 0;
+ for(i=0;i<6;i++)
+ {
+ usleep(retry_time*1000);
+ ret = calendar_connect();
+ DBG("retry cnt=%d, ret=%x",(i+1), ret);
+ if (ret == CALENDAR_ERROR_NONE)
+ break;
+ retry_time *= 2;
+ }
+
+ }
+ }
+
+ return ret;
}
#endif
*
*/
+#include <unistd.h>
#include <glib.h>
#include <db-util.h>
#include "cal_record.h"
#include "cal_db_util.h"
#include "cal_list.h"
-
#include "cal_db.h"
+#include "cal_access_control.h"
+
+#define BULK_DEFAULT_COUNT 100
/*
* Declear DB plugin
extern cal_db_plugin_cb_s _cal_db_calendar_plugin_cb;
extern cal_db_plugin_cb_s _cal_db_event_plugin_cb;
extern cal_db_plugin_cb_s _cal_db_instance_normal_plugin_cb;
+extern cal_db_plugin_cb_s _cal_db_instance_normal_extended_plugin_cb;
extern cal_db_plugin_cb_s _cal_db_instance_allday_plugin_cb;
+extern cal_db_plugin_cb_s _cal_db_instance_allday_extended_plugin_cb;
extern cal_db_plugin_cb_s _cal_db_todo_plugin_cb;
extern cal_db_plugin_cb_s _cal_db_alarm_plugin_cb;
extern cal_db_plugin_cb_s _cal_db_attendee_plugin_cb;
static cal_db_plugin_cb_s* __cal_db_get_plugin(cal_record_type_e type);
-static void __cal_db_initialize_view_table(void);
-
#ifdef CAL_NATIVE
typedef struct {
- calendar_list_h list;
- calendar_db_insert_result_cb callback;
- void *user_data;
+ calendar_list_h list;
+ calendar_db_insert_result_cb callback;
+ void *user_data;
} __insert_records_data_s;
typedef struct {
- calendar_list_h list;
- calendar_db_result_cb callback;
- void *user_data;
+ calendar_list_h list;
+ calendar_db_result_cb callback;
+ void *user_data;
} __update_records_data_s;
typedef struct {
- const char* view_uri;
- int *ids;
- int count;
- calendar_db_result_cb callback;
- void *user_data;
+ const char* view_uri;
+ int *ids;
+ int count;
+ calendar_db_result_cb callback;
+ void *user_data;
} __delete_records_data_s;
typedef struct {
- char* vcalendar_stream;
- calendar_db_insert_result_cb callback;
- void *user_data;
+ char* vcalendar_stream;
+ calendar_db_insert_result_cb callback;
+ void *user_data;
} __insert_vcalendars_data_s;
typedef struct {
- char* vcalendar_stream;
- int *ids;
- int count;
- calendar_db_result_cb callback;
- void *user_data;
+ char* vcalendar_stream;
+ int *ids;
+ int count;
+ calendar_db_result_cb callback;
+ void *user_data;
} __replace_vcalendars_data_s;
typedef struct {
- calendar_list_h list;
- int *ids;
- int count;
- calendar_db_result_cb callback;
- void *user_data;
+ calendar_list_h list;
+ int *ids;
+ int count;
+ calendar_db_result_cb callback;
+ void *user_data;
} __replace_records_data_s;
static gboolean __cal_db_insert_records_idle(void* user_data);
static gboolean __cal_db_update_records_idle(void* user_data);
static gboolean __cal_db_insert_records_idle(void* user_data)
{
- __insert_records_data_s* callback_data = user_data;
- int ret = CALENDAR_ERROR_NONE;
- int *ids = NULL;
- int count = 0;
-
- if (callback_data == NULL)
- {
- ERR("data is NULL");
- return false;
- }
-
- ret = calendar_db_insert_records(callback_data->list, &ids, &count);
-
- if (ret == CALENDAR_ERROR_NONE)
- {
- callback_data->callback(ret, ids, count, callback_data->user_data);
- }
- else
- {
- callback_data->callback(ret, NULL, 0, callback_data->user_data);
- }
-
- calendar_list_destroy(callback_data->list, true);
- CAL_FREE(callback_data);
- CAL_FREE(ids);
- return false;
+ __insert_records_data_s* callback_data = user_data;
+ int ret = CALENDAR_ERROR_NONE;
+ int *ids = NULL;
+ int count = 0;
+
+ if (callback_data == NULL)
+ {
+ ERR("data is NULL");
+ return false;
+ }
+
+ ret = calendar_db_insert_records(callback_data->list, &ids, &count);
+
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ callback_data->callback(ret, ids, count, callback_data->user_data);
+ }
+ else
+ {
+ callback_data->callback(ret, NULL, 0, callback_data->user_data);
+ }
+
+ calendar_list_destroy(callback_data->list, true);
+ CAL_FREE(callback_data);
+ CAL_FREE(ids);
+ return false;
}
static gboolean __cal_db_update_records_idle(void* user_data)
{
- __update_records_data_s* callback_data = user_data;
- int ret = CALENDAR_ERROR_NONE;
+ __update_records_data_s* callback_data = user_data;
+ int ret = CALENDAR_ERROR_NONE;
- if (callback_data == NULL)
- {
- ERR("data is NULL");
- return false;
- }
- ret = calendar_db_update_records(callback_data->list);
+ if (callback_data == NULL)
+ {
+ ERR("data is NULL");
+ return false;
+ }
+ ret = calendar_db_update_records(callback_data->list);
- callback_data->callback(ret, callback_data->user_data);
+ callback_data->callback(ret, callback_data->user_data);
- calendar_list_destroy(callback_data->list, true);
- CAL_FREE(callback_data);
- return false;
+ calendar_list_destroy(callback_data->list, true);
+ CAL_FREE(callback_data);
+ return false;
}
static gboolean __cal_db_delete_records_idle(void* user_data)
{
- __delete_records_data_s* callback_data = user_data;
- int ret = CALENDAR_ERROR_NONE;
+ __delete_records_data_s* callback_data = user_data;
+ int ret = CALENDAR_ERROR_NONE;
- if (callback_data == NULL)
- {
- ERR("data is NULL");
- return false;
- }
- ret = calendar_db_delete_records(callback_data->view_uri,callback_data->ids,callback_data->count);
+ if (callback_data == NULL)
+ {
+ ERR("data is NULL");
+ return false;
+ }
+ ret = calendar_db_delete_records(callback_data->view_uri,callback_data->ids,callback_data->count);
- callback_data->callback(ret, callback_data->user_data);
+ callback_data->callback(ret, callback_data->user_data);
- CAL_FREE(callback_data->ids);
- CAL_FREE(callback_data);
- return false;
+ CAL_FREE(callback_data->ids);
+ CAL_FREE(callback_data);
+ return false;
}
static gboolean __cal_db_insert_vcalendars_idle(void* user_data)
{
- __insert_vcalendars_data_s* callback_data = user_data;
- int ret = CALENDAR_ERROR_NONE;
- int *ids = NULL;
- int count = 0;
-
- if (callback_data == NULL)
- {
- ERR("data is NULL");
- return false;
- }
-
- ret = calendar_db_insert_vcalendars(callback_data->vcalendar_stream, &ids, &count);
-
- if (ret == CALENDAR_ERROR_NONE)
- {
- callback_data->callback(ret, ids, count, callback_data->user_data);
- }
- else
- {
- callback_data->callback(ret, NULL, 0, callback_data->user_data);
- }
-
- CAL_FREE(callback_data->vcalendar_stream);
- CAL_FREE(callback_data);
- CAL_FREE(ids);
- return false;
+ __insert_vcalendars_data_s* callback_data = user_data;
+ int ret = CALENDAR_ERROR_NONE;
+ int *ids = NULL;
+ int count = 0;
+
+ if (callback_data == NULL)
+ {
+ ERR("data is NULL");
+ return false;
+ }
+
+ ret = calendar_db_insert_vcalendars(callback_data->vcalendar_stream, &ids, &count);
+
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ callback_data->callback(ret, ids, count, callback_data->user_data);
+ }
+ else
+ {
+ callback_data->callback(ret, NULL, 0, callback_data->user_data);
+ }
+
+ CAL_FREE(callback_data->vcalendar_stream);
+ CAL_FREE(callback_data);
+ CAL_FREE(ids);
+ return false;
}
static gboolean __cal_db_replace_vcalendars_idle(void* user_data)
{
- __replace_vcalendars_data_s* callback_data = user_data;
- int ret = CALENDAR_ERROR_NONE;
-
- if (callback_data == NULL)
- {
- ERR("data is NULL");
- return false;
- }
- ret = calendar_db_replace_vcalendars(callback_data->vcalendar_stream,
- callback_data->ids,callback_data->count);
-
- callback_data->callback(ret, callback_data->user_data);
-
- CAL_FREE(callback_data->vcalendar_stream);
- CAL_FREE(callback_data->ids);
- CAL_FREE(callback_data);
- return false;
+ __replace_vcalendars_data_s* callback_data = user_data;
+ int ret = CALENDAR_ERROR_NONE;
+
+ if (callback_data == NULL)
+ {
+ ERR("data is NULL");
+ return false;
+ }
+ ret = calendar_db_replace_vcalendars(callback_data->vcalendar_stream,
+ callback_data->ids,callback_data->count);
+
+ callback_data->callback(ret, callback_data->user_data);
+
+ CAL_FREE(callback_data->vcalendar_stream);
+ CAL_FREE(callback_data->ids);
+ CAL_FREE(callback_data);
+ return false;
}
static gboolean __cal_db_replace_records_idle(void* user_data)
{
- __replace_records_data_s* callback_data = user_data;
- int ret = CALENDAR_ERROR_NONE;
-
- if (callback_data == NULL)
- {
- ERR("data is NULL");
- return false;
- }
- ret = calendar_db_replace_records(callback_data->list,callback_data->ids,callback_data->count);
-
- callback_data->callback(ret, callback_data->user_data);
-
- calendar_list_destroy(callback_data->list, true);
- CAL_FREE(callback_data->ids);
- CAL_FREE(callback_data);
- return false;
+ __replace_records_data_s* callback_data = user_data;
+ int ret = CALENDAR_ERROR_NONE;
+
+ if (callback_data == NULL)
+ {
+ ERR("data is NULL");
+ return false;
+ }
+ ret = calendar_db_replace_records(callback_data->list,callback_data->ids,callback_data->count);
+
+ callback_data->callback(ret, callback_data->user_data);
+
+ calendar_list_destroy(callback_data->list, true);
+ CAL_FREE(callback_data->ids);
+ CAL_FREE(callback_data);
+ return false;
}
#endif
static cal_db_plugin_cb_s* __cal_db_get_plugin(cal_record_type_e type)
{
- switch (type)
- {
- case CAL_RECORD_TYPE_CALENDAR:
- return (&_cal_db_calendar_plugin_cb);
- case CAL_RECORD_TYPE_EVENT:
- return (&_cal_db_event_plugin_cb);
- case CAL_RECORD_TYPE_TODO:
- return (&_cal_db_todo_plugin_cb);
- case CAL_RECORD_TYPE_ALARM:
- return (&_cal_db_alarm_plugin_cb);
- case CAL_RECORD_TYPE_ATTENDEE:
- return (&_cal_db_attendee_plugin_cb);
- case CAL_RECORD_TYPE_TIMEZONE:
- return (&_cal_db_timezone_plugin_cb);
- case CAL_RECORD_TYPE_INSTANCE_NORMAL:
- return (&_cal_db_instance_normal_plugin_cb);
- case CAL_RECORD_TYPE_INSTANCE_ALLDAY:
- return (&_cal_db_instance_allday_plugin_cb);
- case CAL_RECORD_TYPE_SEARCH:
- return (&_cal_db_search_plugin_cb);
- case CAL_RECORD_TYPE_EXTENDED:
- return (&_cal_db_extended_plugin_cb);
- default:
- return NULL;
- }
- return NULL;
+ switch (type)
+ {
+ case CAL_RECORD_TYPE_CALENDAR:
+ return (&_cal_db_calendar_plugin_cb);
+ case CAL_RECORD_TYPE_EVENT:
+ return (&_cal_db_event_plugin_cb);
+ case CAL_RECORD_TYPE_TODO:
+ return (&_cal_db_todo_plugin_cb);
+ case CAL_RECORD_TYPE_ALARM:
+ return (&_cal_db_alarm_plugin_cb);
+ case CAL_RECORD_TYPE_ATTENDEE:
+ return (&_cal_db_attendee_plugin_cb);
+ case CAL_RECORD_TYPE_TIMEZONE:
+ return (&_cal_db_timezone_plugin_cb);
+ case CAL_RECORD_TYPE_INSTANCE_NORMAL:
+ return (&_cal_db_instance_normal_plugin_cb);
+ case CAL_RECORD_TYPE_INSTANCE_ALLDAY:
+ return (&_cal_db_instance_allday_plugin_cb);
+ case CAL_RECORD_TYPE_INSTANCE_NORMAL_EXTENDED:
+ return (&_cal_db_instance_normal_extended_plugin_cb);
+ case CAL_RECORD_TYPE_INSTANCE_ALLDAY_EXTENDED:
+ return (&_cal_db_instance_allday_extended_plugin_cb);
+ case CAL_RECORD_TYPE_SEARCH:
+ return (&_cal_db_search_plugin_cb);
+ case CAL_RECORD_TYPE_EXTENDED:
+ return (&_cal_db_extended_plugin_cb);
+ default:
+ ERR("Invalid plugin(%d)", type);
+ return NULL;
+ }
+ return NULL;
}
-static void __cal_db_initialize_view_table(void)
+void _cal_db_initialize_view_table(void)
{
- cal_db_util_error_e dbret;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
-
- /*
- * CAL_VIEW_TABLE_EVENT
- * schedule_table(type=1) + rrule_table
- */
- snprintf(query, sizeof(query),
- "CREATE VIEW IF NOT EXISTS %s AS "
- "SELECT A.*, "
- "B.freq, B.range_type, B.until_type, B.until_utime, B.until_datetime, B.count, "
- "B.interval, B.bysecond, B.byminute, B.byhour, B.byday, B.bymonthday, "
- "B.byyearday, B.byweekno, B.bymonth, B.bysetpos, B.wkst, C.deleted "
- "FROM %s as A "
- "LEFT OUTER JOIN %s B ON A.id = B.event_id "
- "JOIN %s C ON A.calendar_id = C.id "
- "WHERE A.type = %d "
- "AND C.deleted = 0 ",
- CAL_VIEW_TABLE_EVENT,
- CAL_TABLE_SCHEDULE,
- CAL_TABLE_RRULE,
- CAL_TABLE_CALENDAR,
- CAL_SCH_TYPE_EVENT);
- dbret = _cal_db_util_query_exec(query);
- CAL_DBG("%s",query);
- if (dbret != CAL_DB_OK)
- {
- ERR("create view fail");
- }
-
- /*
- * CAL_VIEW_TABLE_TODO
- * schedule_table(type=2) + rrule_table
- */
- snprintf(query, sizeof(query),
- "CREATE VIEW IF NOT EXISTS %s AS "
- "SELECT A.*, "
- "B.freq, B.range_type, B.until_type, B.until_utime, B.until_datetime, B.count, "
- "B.interval, B.bysecond, B.byminute, B.byhour, B.byday, B.bymonthday, "
- "B.byyearday, B.byweekno, B.bymonth, B.bysetpos, B.wkst, C.deleted "
- "FROM %s as A "
- "LEFT OUTER JOIN %s B ON A.id = B.event_id "
- "JOIN %s C ON A.calendar_id = C.id "
- "WHERE A.type = %d "
- "AND C.deleted = 0 ",
- CAL_VIEW_TABLE_TODO,
- CAL_TABLE_SCHEDULE,
- CAL_TABLE_RRULE,
- CAL_TABLE_CALENDAR,
- CAL_SCH_TYPE_TODO);
- dbret = _cal_db_util_query_exec(query);
- CAL_DBG("%s",query);
- if (dbret != CAL_DB_OK)
- {
- ERR("create view fail");
- }
-
- /*
- * CAL_VIEW_TABLE_NORMAL_INSTANCE : CALENDAR_VIEW_INSTANCE_NORMAL_CALENDAR
- * normal_instance_table + schedule_table(type=1) + calendar_table
- * A = normal_instace_table
- * B = schedule_table
- * C = calendar_table
- */
- snprintf(query, sizeof(query),
- "CREATE VIEW IF NOT EXISTS %s AS SELECT A.event_id, "
- "B.dtstart_type, A.dtstart_utime, B.dtstart_datetime, "
- "B.dtend_type, A.dtend_utime, B.dtend_datetime, "
- "B.summary, B.description, "
- "B.location, B.busy_status, B.task_status, B.priority, B.sensitivity, "
- "B.rrule_id, B.latitude, B.longitude, B.has_alarm, B.original_event_id, "
- "B.calendar_id, B.last_mod, "
+ int ret = CALENDAR_ERROR_NONE;
+ cal_db_util_error_e dbret;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+
+ ret = _cal_db_util_begin_trans();
+ if (CALENDAR_ERROR_NONE != ret)
+ {
+ ERR("_cal_db_util_begin_trans() failed");
+ return ;
+ }
+
+ /*
+ * CAL_VIEW_TABLE_EVENT
+ * schedule_table(type=1) + rrule_table
+ * A : schedule_table
+ * B : rrule_table
+ * C : calendar_table
+ */
+ snprintf(query, sizeof(query),
+ "CREATE VIEW IF NOT EXISTS %s AS "
+ "SELECT "CAL_QUERY_SCHEDULE_A_ALL", "
+ "B.range_type, B.until_type, B.until_utime, B.until_datetime, B.count, "
+ "B.interval, B.bysecond, B.byminute, B.byhour, B.byday, B.bymonthday, "
+ "B.byyearday, B.byweekno, B.bymonth, B.bysetpos, B.wkst, C.deleted "
+ "FROM %s as A "
+ "LEFT OUTER JOIN %s B ON A.id = B.event_id "
+ "JOIN %s C ON A.calendar_id = C.id "
+ "WHERE A.type = %d AND A.is_deleted=0 "
+ "AND C.deleted = 0 ",
+ CAL_VIEW_TABLE_EVENT,
+ CAL_TABLE_SCHEDULE,
+ CAL_TABLE_RRULE,
+ CAL_TABLE_CALENDAR,
+ CAL_SCH_TYPE_EVENT);
+ dbret = _cal_db_util_query_exec(query);
+ //SEC_DBG("%s",query);
+ if (dbret != CAL_DB_OK)
+ {
+ SEC_ERR("[%s]", query);
+ ERR("create view fail");
+ }
+
+ /*
+ * CAL_VIEW_TABLE_TODO
+ * schedule_table(type=2) + rrule_table
+ * A : schedule_table
+ * B : rrule_table
+ * C : calendar_table
+ */
+ snprintf(query, sizeof(query),
+ "CREATE VIEW IF NOT EXISTS %s AS "
+ "SELECT "CAL_QUERY_SCHEDULE_A_ALL", "
+ "B.range_type, B.until_type, B.until_utime, B.until_datetime, B.count, "
+ "B.interval, B.bysecond, B.byminute, B.byhour, B.byday, B.bymonthday, "
+ "B.byyearday, B.byweekno, B.bymonth, B.bysetpos, B.wkst, C.deleted "
+ "FROM %s as A "
+ "LEFT OUTER JOIN %s B ON A.id = B.event_id "
+ "JOIN %s C ON A.calendar_id = C.id "
+ "WHERE A.type = %d AND A.is_deleted=0 "
+ "AND C.deleted = 0 ",
+ CAL_VIEW_TABLE_TODO,
+ CAL_TABLE_SCHEDULE,
+ CAL_TABLE_RRULE,
+ CAL_TABLE_CALENDAR,
+ CAL_SCH_TYPE_TODO);
+ dbret = _cal_db_util_query_exec(query);
+ //SEC_DBG("%s",query);
+ if (dbret != CAL_DB_OK)
+ {
+ ERR("create view fail");
+ }
+
+ /*
+ * CAL_VIEW_TABLE_NORMAL_INSTANCE : CALENDAR_VIEW_INSTANCE_NORMAL_CALENDAR
+ * normal_instance_table + schedule_table(type=1) + calendar_table
+ * A = normal_instace_table
+ * B = schedule_table
+ * C = calendar_table
+ */
+ snprintf(query, sizeof(query),
+ "CREATE VIEW IF NOT EXISTS %s AS SELECT A.event_id, "
+ "B.dtstart_type, A.dtstart_utime, B.dtstart_datetime, "
+ "B.dtend_type, A.dtend_utime, B.dtend_datetime, "
+ "B.summary, B.description, "
+ "B.location, B.busy_status, B.task_status, B.priority, B.sensitivity, "
+ "B.rrule_id, B.latitude, B.longitude, B.has_alarm, B.original_event_id, "
+ "B.calendar_id, B.last_mod, "
+ "B.sync_data1, "
"C.visibility, C.account_id "
- "FROM %s as A, %s as B, %s as C "
- "ON A.event_id = B.id AND B.calendar_id = C.id "
- "where C.deleted = 0",
- CAL_VIEW_TABLE_NORMAL_INSTANCE,
- CAL_TABLE_NORMAL_INSTANCE,
- CAL_TABLE_SCHEDULE,
- CAL_TABLE_CALENDAR);
- dbret = _cal_db_util_query_exec(query);
- CAL_DBG("%s",query);
- if (dbret != CAL_DB_OK)
- {
- ERR("create view fail");
- }
-
- // CAL_VIEW_TABLE_ALLDAY_INSTANCE : CALENDAR_VIEW_INSTANCE_ALLDAY_CALENDAR
- snprintf(query, sizeof(query),
- "CREATE VIEW IF NOT EXISTS %s AS SELECT A.event_id, "
- "B.dtstart_type, B.dtstart_utime, A.dtstart_datetime, "
- "B.dtend_type, B.dtend_utime, A.dtend_datetime, "
- "B.summary, B.description, "
- "B.location, B.busy_status, B.task_status, B.priority, B.sensitivity, "
- "B.rrule_id, B.latitude, B.longitude, B.has_alarm, B.original_event_id, "
- "B.calendar_id, B.last_mod, "
- "C.visibility, C.account_id "
- "FROM %s as A, %s as B, %s as C "
- "ON A.event_id = B.id AND B.calendar_id = C.id "
- "where C.deleted = 0",
- CAL_VIEW_TABLE_ALLDAY_INSTANCE,
- CAL_TABLE_ALLDAY_INSTANCE,
- CAL_TABLE_SCHEDULE,
- CAL_TABLE_CALENDAR);
- dbret = _cal_db_util_query_exec(query);
- CAL_DBG("%s",query);
- if (dbret != CAL_DB_OK)
- {
- ERR("create view fail");
- }
-
- // event_calendar view : CALENDAR_VIEW_EVENT_CALENDAR
- snprintf(query, sizeof(query),
- "CREATE VIEW IF NOT EXISTS %s AS "
- "SELECT A.* "
- ", B.freq, B.range_type, B.until_type, B.until_utime, B.until_datetime, B.count, "
- "B.interval, B.bysecond, B.byminute, B.byhour, B.byday, B.bymonthday, "
- "B.byyearday, B.byweekno, B.bymonth, B.bysetpos, B.wkst "
- ", C.*"
- "FROM %s A "
- "JOIN %s C ON A.calendar_id = C.id "
- "LEFT OUTER JOIN %s B ON A.id = B.event_id "
- "WHERE A.type = 1 AND c.deleted = 0",
- CAL_VIEW_TABLE_EVENT_CALENDAR,
- CAL_TABLE_SCHEDULE, CAL_TABLE_CALENDAR,
- CAL_TABLE_RRULE );
- dbret = _cal_db_util_query_exec(query);
- CAL_DBG("%s",query);
- if (dbret != CAL_DB_OK)
- {
- ERR("create view fail");
- }
-
- // todo_calendar view : CALENDAR_VIEW_TODO_CALENDAR
- snprintf(query, sizeof(query),
- "CREATE VIEW IF NOT EXISTS %s AS "
- "SELECT A.* "
- ", B.freq, B.range_type, B.until_type, B.until_utime, B.until_datetime, B.count, "
- "B.interval, B.bysecond, B.byminute, B.byhour, B.byday, B.bymonthday, "
- "B.byyearday, B.byweekno, B.bymonth, B.bysetpos, B.wkst "
- ", C.*"
- "FROM %s A "
- "JOIN %s C ON A.calendar_id = C.id "
- "LEFT OUTER JOIN %s B ON A.id = B.event_id "
- "WHERE A.type = 2 AND c.deleted = 0",
- CAL_VIEW_TABLE_TODO_CALENDAR,
- CAL_TABLE_SCHEDULE, CAL_TABLE_CALENDAR,
- CAL_TABLE_RRULE);
- dbret = _cal_db_util_query_exec(query);
- CAL_DBG("%s",query);
- if (dbret != CAL_DB_OK)
- {
- ERR("create view fail");
- }
-
- // event_calendar_attendee view : CALENDAR_VIEW_EVENT_CALENDAR_ATTENDEE
- snprintf(query, sizeof(query),
- "CREATE VIEW IF NOT EXISTS %s AS "
- "SELECT A.* "
- ", D.freq, D.range_type, D.until_type, D.until_utime, D.until_datetime, D.count, "
- "D.interval, D.bysecond, D.byminute, D.byhour, D.byday, D.bymonthday, "
- "D.byyearday, D.byweekno, D.bymonth, D.bysetpos, D.wkst "
- ", B.*, C.*"
- "FROM %s A "
- "LEFT OUTER JOIN %s B ON A.id = B.event_id "
- "JOIN %s C ON A.calendar_id = C.id "
- "LEFT OUTER JOIN %s D ON A.id = D.event_id "
- "WHERE A.type = 1 AND c.deleted = 0 ",
- CAL_VIEW_TABLE_EVENT_CALENDAR_ATTENDEE,
- CAL_TABLE_SCHEDULE, CAL_TABLE_ATTENDEE, CAL_TABLE_CALENDAR,
- CAL_TABLE_RRULE );
- dbret = _cal_db_util_query_exec(query);
- CAL_DBG("%s",query);
- if (dbret != CAL_DB_OK)
- {
- ERR("create view fail");
- }
-
- return ;
+ "FROM %s as A, %s as B, %s as C "
+ "ON A.event_id = B.id AND B.calendar_id = C.id "
+ "where C.deleted = 0 AND B.is_deleted = 0 ",
+ CAL_VIEW_TABLE_NORMAL_INSTANCE,
+ CAL_TABLE_NORMAL_INSTANCE,
+ CAL_TABLE_SCHEDULE,
+ CAL_TABLE_CALENDAR);
+ dbret = _cal_db_util_query_exec(query);
+ //SEC_DBG("%s",query);
+ if (dbret != CAL_DB_OK)
+ {
+ ERR("create view fail");
+ }
+
+ // CAL_VIEW_TABLE_ALLDAY_INSTANCE : CALENDAR_VIEW_INSTANCE_ALLDAY_CALENDAR
+ snprintf(query, sizeof(query),
+ "CREATE VIEW IF NOT EXISTS %s AS SELECT A.event_id, "
+ "B.dtstart_type, B.dtstart_utime, A.dtstart_datetime, "
+ "B.dtend_type, B.dtend_utime, A.dtend_datetime, "
+ "B.summary, B.description, "
+ "B.location, B.busy_status, B.task_status, B.priority, B.sensitivity, "
+ "B.rrule_id, B.latitude, B.longitude, B.has_alarm, B.original_event_id, "
+ "B.calendar_id, B.last_mod, "
+ "B.sync_data1, B.is_allday, "
+ "C.visibility, C.account_id "
+ "FROM %s as A, %s as B, %s as C "
+ "ON A.event_id = B.id AND B.calendar_id = C.id "
+ "where C.deleted = 0 AND B.is_deleted = 0 ",
+ CAL_VIEW_TABLE_ALLDAY_INSTANCE,
+ CAL_TABLE_ALLDAY_INSTANCE,
+ CAL_TABLE_SCHEDULE,
+ CAL_TABLE_CALENDAR);
+ dbret = _cal_db_util_query_exec(query);
+ //SEC_DBG("%s",query);
+ if (dbret != CAL_DB_OK)
+ {
+ ERR("create view fail");
+ }
+
+ /*
+ * CAL_VIEW_TABLE_NORMAL_INSTANCE_EXTENDED : CALENDAR_VIEW_INSTANCE_NORMAL_CALENDAR_EXTENDED
+ * normal_instance_table + schedule_table(type=1) + calendar_table
+ * A = normal_instace_table
+ * B = schedule_table
+ * C = calendar_table
+ */
+ snprintf(query, sizeof(query),
+ "CREATE VIEW IF NOT EXISTS %s AS SELECT A.event_id, "
+ "B.dtstart_type, A.dtstart_utime, B.dtstart_datetime, "
+ "B.dtend_type, A.dtend_utime, B.dtend_datetime, "
+ "B.summary, B.description, "
+ "B.location, B.busy_status, B.task_status, B.priority, B.sensitivity, "
+ "B.rrule_id, B.latitude, B.longitude, B.has_alarm, B.original_event_id, "
+ "B.calendar_id, B.last_mod, "
+ "B.sync_data1, B.organizer_name, B.categories, B.has_attendee, B.sync_data2, B.sync_data3, B.sync_data4, "
+ "C.visibility, C.account_id "
+ "FROM %s as A, %s as B, %s as C "
+ "ON A.event_id = B.id AND B.calendar_id = C.id "
+ "where C.deleted = 0 AND B.is_deleted = 0 ",
+ CAL_VIEW_TABLE_NORMAL_INSTANCE_EXTENDED,
+ CAL_TABLE_NORMAL_INSTANCE,
+ CAL_TABLE_SCHEDULE,
+ CAL_TABLE_CALENDAR);
+ dbret = _cal_db_util_query_exec(query);
+ //SEC_DBG("%s",query);
+ if (dbret != CAL_DB_OK)
+ {
+ ERR("create view fail");
+ }
+
+ // CAL_VIEW_TABLE_ALLDAY_INSTANCE_EXTENDED : CALENDAR_VIEW_INSTANCE_ALLDAY_CALENDAR_EXTENDED
+ snprintf(query, sizeof(query),
+ "CREATE VIEW IF NOT EXISTS %s AS SELECT A.event_id, "
+ "B.dtstart_type, B.dtstart_utime, A.dtstart_datetime, "
+ "B.dtend_type, B.dtend_utime, A.dtend_datetime, "
+ "B.summary, B.description, "
+ "B.location, B.busy_status, B.task_status, B.priority, B.sensitivity, "
+ "B.rrule_id, B.latitude, B.longitude, B.has_alarm, B.original_event_id, "
+ "B.calendar_id, B.last_mod, "
+ "B.sync_data1, B.organizer_name, B.categories, B.has_attendee, B.sync_data2, B.sync_data3, B.sync_data4, B.is_allday, "
+ "C.visibility, C.account_id "
+ "FROM %s as A, %s as B, %s as C "
+ "ON A.event_id = B.id AND B.calendar_id = C.id "
+ "where C.deleted = 0 AND B.is_deleted = 0 ",
+ CAL_VIEW_TABLE_ALLDAY_INSTANCE_EXTENDED,
+ CAL_TABLE_ALLDAY_INSTANCE,
+ CAL_TABLE_SCHEDULE,
+ CAL_TABLE_CALENDAR);
+ dbret = _cal_db_util_query_exec(query);
+ //SEC_DBG("%s",query);
+ if (dbret != CAL_DB_OK)
+ {
+ ERR("create view fail");
+ }
+
+ // event_calendar view : CALENDAR_VIEW_EVENT_CALENDAR
+ // A : schedule_table
+ // B : rrule_table
+ // C : calendar_table
+ snprintf(query, sizeof(query),
+ "CREATE VIEW IF NOT EXISTS %s AS "
+ "SELECT "CAL_QUERY_SCHEDULE_A_ALL", "
+ "B.range_type, B.until_type, B.until_utime, B.until_datetime, B.count, "
+ "B.interval, B.bysecond, B.byminute, B.byhour, B.byday, B.bymonthday, "
+ "B.byyearday, B.byweekno, B.bymonth, B.bysetpos, B.wkst, "
+ "C.*"
+ "FROM %s A "
+ "JOIN %s C ON A.calendar_id = C.id "
+ "LEFT OUTER JOIN %s B ON A.id = B.event_id "
+ "WHERE A.type = 1 AND c.deleted = 0 AND A.is_deleted = 0 ",
+ CAL_VIEW_TABLE_EVENT_CALENDAR,
+ CAL_TABLE_SCHEDULE, CAL_TABLE_CALENDAR,
+ CAL_TABLE_RRULE );
+ dbret = _cal_db_util_query_exec(query);
+ //SEC_DBG("%s",query);
+ if (dbret != CAL_DB_OK)
+ {
+ ERR("create view fail");
+ }
+
+ // todo_calendar view : CALENDAR_VIEW_TODO_CALENDAR
+ // A : schedule_table
+ // B : rrule_table
+ // C : calendar_table
+ snprintf(query, sizeof(query),
+ "CREATE VIEW IF NOT EXISTS %s AS "
+ "SELECT "CAL_QUERY_SCHEDULE_A_ALL", "
+ "B.range_type, B.until_type, B.until_utime, B.until_datetime, B.count, "
+ "B.interval, B.bysecond, B.byminute, B.byhour, B.byday, B.bymonthday, "
+ "B.byyearday, B.byweekno, B.bymonth, B.bysetpos, B.wkst, "
+ "C.*"
+ "FROM %s A "
+ "JOIN %s C ON A.calendar_id = C.id "
+ "LEFT OUTER JOIN %s B ON A.id = B.event_id "
+ "WHERE A.type = 2 AND c.deleted = 0 AND A.is_deleted = 0 ",
+ CAL_VIEW_TABLE_TODO_CALENDAR,
+ CAL_TABLE_SCHEDULE, CAL_TABLE_CALENDAR,
+ CAL_TABLE_RRULE);
+ dbret = _cal_db_util_query_exec(query);
+ //SEC_DBG("%s",query);
+ if (dbret != CAL_DB_OK)
+ {
+ ERR("create view fail");
+ }
+
+ // event_calendar_attendee view : CALENDAR_VIEW_EVENT_CALENDAR_ATTENDEE
+ // A : schedule_table
+ // B : attendee_table
+ // C : calendar_table;
+ // D : rrule_table;
+ snprintf(query, sizeof(query),
+ "CREATE VIEW IF NOT EXISTS %s AS "
+ "SELECT "CAL_QUERY_SCHEDULE_A_ALL", "
+ "D.range_type, D.until_type, D.until_utime, D.until_datetime, D.count, "
+ "D.interval, D.bysecond, D.byminute, D.byhour, D.byday, D.bymonthday, "
+ "D.byyearday, D.byweekno, D.bymonth, D.bysetpos, D.wkst, "
+ "B.*, C.*"
+ "FROM %s A "
+ "LEFT OUTER JOIN %s B ON A.id = B.event_id "
+ "JOIN %s C ON A.calendar_id = C.id "
+ "LEFT OUTER JOIN %s D ON A.id = D.event_id "
+ "WHERE A.type = 1 AND c.deleted = 0 AND A.is_deleted = 0 ",
+ CAL_VIEW_TABLE_EVENT_CALENDAR_ATTENDEE,
+ CAL_TABLE_SCHEDULE, CAL_TABLE_ATTENDEE, CAL_TABLE_CALENDAR,
+ CAL_TABLE_RRULE );
+ dbret = _cal_db_util_query_exec(query);
+ //SEC_DBG("%s",query);
+ if (dbret != CAL_DB_OK)
+ {
+ ERR("create view fail");
+ }
+ _cal_db_util_end_trans(true);
+ return ;
}
int _cal_db_open(void)
{
- int ret = CALENDAR_ERROR_NONE;
- ret = _cal_db_util_open();
- if (ret == CALENDAR_ERROR_NONE)
- {
- __cal_db_initialize_view_table();
- }
- return ret;
+ int ret = CALENDAR_ERROR_NONE;
+ ret = _cal_db_util_open();
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("db open fail");
+ }
+ return ret;
}
int _cal_db_close(void)
{
- int ret = CALENDAR_ERROR_NONE;
- ret = _cal_db_util_close();
- return ret;
+ int ret = CALENDAR_ERROR_NONE;
+ ret = _cal_db_util_close();
+ return ret;
}
API int calendar_db_get_changes_by_version(const char* view_uri, int calendar_book_id, int calendar_db_version, calendar_list_h* record_list, int *current_calendar_db_version )
{
- char buf[64] = {0};
- const char *query_cur_version = "SELECT ver FROM "CAL_TABLE_VERSION;
- int transaction_ver = 0;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
- int ret = 0;
- int is_deleted = 0;
-
- retvm_if(NULL == current_calendar_db_version || NULL == view_uri || NULL == record_list,
- CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- ret = _cal_db_util_query_get_first_int_result(query_cur_version, NULL, &transaction_ver);
- if (CALENDAR_ERROR_NONE != ret)
+ const char *query_cur_version = "SELECT ver FROM "CAL_TABLE_VERSION;
+ int transaction_ver = 0;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+ int ret = 0;
+ int is_deleted = 0;
+
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_READ),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : read ");
+ retvm_if(NULL == current_calendar_db_version || NULL == view_uri || NULL == record_list,
+ CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ ret = _cal_db_util_query_get_first_int_result(query_cur_version, NULL, &transaction_ver);
+ retvm_if (CALENDAR_ERROR_NONE != ret, ret, "_cal_db_util_query_get_first_int_result() failed(%d)", ret);
+
+ char buf[64] = {0};
+ if (calendar_book_id > 0) {
+ snprintf(buf, sizeof(buf), "AND calendar_id = %d ", calendar_book_id);
+
+ } else {
+ memset(buf, 0x0, sizeof(buf));
+ }
+
+ int schedule_type = 0;
+ int record_type = 0;
+ if (strcmp(view_uri,_calendar_event._uri) == 0) {
+ schedule_type = CAL_SCH_TYPE_EVENT;
+ record_type = CAL_RECORD_TYPE_EVENT;
+
+ } else if (strcmp(view_uri,_calendar_todo._uri) == 0) {
+ schedule_type = CAL_SCH_TYPE_TODO;
+ record_type = CAL_RECORD_TYPE_TODO;
+
+ } else {
+ ERR("Invalid parameter");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ snprintf(query, sizeof(query),
+ "SELECT id, changed_ver, created_ver, is_deleted, calendar_id FROM %s "
+ "WHERE changed_ver > %d AND changed_ver <= %d AND type = %d AND original_event_id < 0 %s "
+ "UNION "
+ "SELECT schedule_id, deleted_ver, created_ver, 1, calendar_id FROM %s "
+ "WHERE deleted_ver > %d AND schedule_type = %d AND original_event_id < 0 %s ",
+ CAL_TABLE_SCHEDULE,
+ calendar_db_version, transaction_ver, schedule_type, buf,
+ CAL_TABLE_DELETED,
+ calendar_db_version, record_type, buf);
+ SEC_DBG("query[%s]", query);
+
+ ret = calendar_list_create(record_list);
+ retvm_if (ret != CALENDAR_ERROR_NONE, ret, "calendar_list_create() Failed");
+
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt)
{
- ERR("_cal_db_util_query_get_first_int_result() failed");
- return ret;
+ ERR("_cal_db_util_query_prepare() Failed");
+ calendar_list_destroy(*record_list, true);
+ *record_list = NULL;
+ return CALENDAR_ERROR_DB_FAILED;
}
- if (calendar_book_id > 0)
- {
- snprintf(buf, sizeof(buf), "AND calendar_id = %d ", calendar_book_id);
- }
- else
- {
- memset(buf, 0x0, sizeof(buf));
- }
-
- if (strcmp(view_uri,_calendar_event._uri) == 0)
- {
- snprintf(query, sizeof(query),
- "SELECT id, changed_ver, created_ver, is_deleted, calendar_id FROM %s "
- "WHERE changed_ver > %d AND changed_ver <= %d AND original_event_id = %d %s"
- "UNION "
- "SELECT schedule_id, deleted_ver, -1, 1, calendar_id FROM %s "
- "WHERE deleted_ver > %d AND schedule_type = %d %s"
- ,
- CAL_VIEW_TABLE_EVENT,
- calendar_db_version, transaction_ver, CAL_INVALID_ID, buf,
- CAL_TABLE_DELETED, calendar_db_version, CAL_RECORD_TYPE_EVENT, buf);
- DBG("event qeury[%s]", query);
- }
- else if (strcmp(view_uri,_calendar_todo._uri) == 0)
- {
- snprintf(query, sizeof(query),
- "SELECT id, changed_ver, created_ver, is_deleted, calendar_id FROM %s "
- "WHERE changed_ver > %d AND changed_ver <= %d AND original_event_id = %d %s"
- "UNION "
- "SELECT schedule_id, deleted_ver, -1, 1, calendar_id FROM %s "
- "WHERE deleted_ver > %d AND schedule_type = %d %s"
- ,
- CAL_VIEW_TABLE_TODO,
- calendar_db_version, transaction_ver, CAL_INVALID_ID, buf,
- CAL_TABLE_DELETED, calendar_db_version, CAL_RECORD_TYPE_TODO, buf);
- DBG("todo qeury[%s]", query);
- }
- else
- {
- ERR("Invalid parameter");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- ret = calendar_list_create(record_list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_list_create() Failed");
- return ret;
- }
-
- stmt = _cal_db_util_query_prepare(query);
-
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() Failed");
- calendar_list_destroy(*record_list, true);
- *record_list = NULL;
- return CALENDAR_ERROR_DB_FAILED;
- }
- retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, );
-
- while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- calendar_record_h record;
- int id = 0, calendar_id = 0,type = 0;
- int ver = 0;
- // stmt -> record
- ret = calendar_record_create(_calendar_updated_info._uri,&record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*record_list, true);
- *record_list = NULL;
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ {
+ calendar_record_h record;
+ int id = 0, calendar_id = 0,type = 0;
+ int ver = 0;
+ int created_ver = 0;
+ // stmt -> record
+ ret = calendar_record_create(_calendar_updated_info._uri,&record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ ERR("calendar_record_create() failed");
+ calendar_list_destroy(*record_list, true);
+ *record_list = NULL;
sqlite3_finalize(stmt);
- return ret;
- }
-
- id = sqlite3_column_int(stmt, 0);
- ver = sqlite3_column_int(stmt, 1);
- is_deleted = sqlite3_column_int(stmt, 3);
- if (is_deleted == 1)
- {
- type = CALENDAR_RECORD_MODIFIED_STATUS_DELETED;
- }
- else if (sqlite3_column_int(stmt, 2) != ver)
- {
- type = CALENDAR_RECORD_MODIFIED_STATUS_UPDATED;
- }
- else
- {
- type = CALENDAR_RECORD_MODIFIED_STATUS_INSERTED;
- }
-
- calendar_id = sqlite3_column_int(stmt, 4);
-
- _cal_record_set_int(record,_calendar_updated_info.id,id);
- _cal_record_set_int(record,_calendar_updated_info.calendar_book_id,calendar_id);
- _cal_record_set_int(record,_calendar_updated_info.modified_status,type);
- _cal_record_set_int(record,_calendar_updated_info.version,ver);
-
- ret = calendar_list_add(*record_list,record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*record_list, true);
- *record_list = NULL;
- calendar_record_destroy(record, true);
+ return ret;
+ }
+
+ id = sqlite3_column_int(stmt, 0);
+ ver = sqlite3_column_int(stmt, 1);
+ created_ver = sqlite3_column_int(stmt, 2);
+ is_deleted = sqlite3_column_int(stmt, 3);
+ if (is_deleted == 1)
+ {
+ type = CALENDAR_RECORD_MODIFIED_STATUS_DELETED;
+ }
+ else if (created_ver != ver)
+ {
+ type = CALENDAR_RECORD_MODIFIED_STATUS_UPDATED;
+ }
+ else
+ {
+ type = CALENDAR_RECORD_MODIFIED_STATUS_INSERTED;
+ }
+
+ calendar_id = sqlite3_column_int(stmt, 4);
+
+ if (type == CALENDAR_RECORD_MODIFIED_STATUS_DELETED && created_ver > calendar_db_version)
+ {
+ calendar_record_destroy(record, true);
+ DBG("type is deleted, created_ver(%d) > calendar_db_ver(%d), so skip", created_ver, calendar_db_version);
+ continue;
+ }
+
+ _cal_record_set_int(record,_calendar_updated_info.id,id);
+ _cal_record_set_int(record,_calendar_updated_info.calendar_book_id,calendar_id);
+ _cal_record_set_int(record,_calendar_updated_info.modified_status,type);
+ _cal_record_set_int(record,_calendar_updated_info.version,ver);
+
+ ret = calendar_list_add(*record_list,record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*record_list, true);
+ *record_list = NULL;
+ calendar_record_destroy(record, true);
sqlite3_finalize(stmt);
- return ret;
- }
- }
+ return ret;
+ }
+ }
- *current_calendar_db_version = transaction_ver;
+ *current_calendar_db_version = transaction_ver;
sqlite3_finalize(stmt);
calendar_list_first(*record_list);
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
API int calendar_db_get_current_version(int* current_version)
{
- const char *query = "SELECT ver FROM "CAL_TABLE_VERSION;
- int transaction_ver = 0;
+ const char *query = "SELECT ver FROM "CAL_TABLE_VERSION;
+ int transaction_ver = 0;
int ret;
- retvm_if(NULL == current_version, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_READ),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : read ");
+ retvm_if(NULL == current_version, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- ret = _cal_db_util_query_get_first_int_result(query, NULL, &transaction_ver);
+ ret = _cal_db_util_query_get_first_int_result(query, NULL, &transaction_ver);
if (CALENDAR_ERROR_NONE != ret)
{
- ERR("_cal_db_util_query_get_first_int_result() failed");
+ ERR("_cal_db_util_query_get_first_int_result() fail(%d)", ret);
return ret;
}
- if (current_version) *current_version = transaction_ver;
+ if (current_version) *current_version = transaction_ver;
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
API int calendar_db_insert_record( calendar_record_h record, int* id )
{
- cal_record_s *temp=NULL ;
int ret = CALENDAR_ERROR_NONE;
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_WRITE),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : write ");
retvm_if(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- temp = (cal_record_s*)(record);
-
- cal_db_plugin_cb_s* plugin_cb = __cal_db_get_plugin(temp->type);
+ cal_db_plugin_cb_s* plugin_cb = __cal_db_get_plugin(((cal_record_s *)record)->type);
retvm_if(NULL == plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
retvm_if(NULL == plugin_cb->insert_record, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
- ret = _cal_db_util_begin_trans();
- retvm_if( CALENDAR_ERROR_NONE != ret,CALENDAR_ERROR_DB_FAILED, "Db failed" );
+ ret = _cal_db_util_begin_trans();
+ retvm_if(CALENDAR_ERROR_NONE != ret,CALENDAR_ERROR_DB_FAILED, "Db failed");
ret = plugin_cb->insert_record(record, id);
- if (ret == CALENDAR_ERROR_NONE)
- {
- ret = _cal_db_util_end_trans(true);
- }
- else
- {
- _cal_db_util_end_trans(false);
- }
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ ret = _cal_db_util_end_trans(true);
+ }
+ else
+ {
+ _cal_db_util_end_trans(false);
+ }
return ret;
}
-API int calendar_db_get_record( const char* view_uri, int id, calendar_record_h* out_record )
+int _cal_db_get_record( const char* view_uri, int id, calendar_record_h* out_record )
{
int ret = CALENDAR_ERROR_NONE;
cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
return ret;
}
+API int calendar_db_get_record( const char* view_uri, int id, calendar_record_h* out_record )
+{
+
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_READ),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : read ");
+
+ return _cal_db_get_record(view_uri, id, out_record);
+}
+
API int calendar_db_update_record( calendar_record_h record )
{
cal_record_s *temp=NULL ;
int ret = CALENDAR_ERROR_NONE;
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_WRITE),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : write ");
retvm_if(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
temp = (cal_record_s*)(record);
retvm_if(NULL == plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
retvm_if(NULL == plugin_cb->update_record, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
- ret = _cal_db_util_begin_trans();
- retvm_if( CALENDAR_ERROR_NONE != ret,CALENDAR_ERROR_DB_FAILED, "Db failed" );
+ ret = _cal_db_util_begin_trans();
+ retvm_if( CALENDAR_ERROR_NONE != ret,CALENDAR_ERROR_DB_FAILED, "Db failed" );
ret = plugin_cb->update_record(record);
- if (ret == CALENDAR_ERROR_NONE)
- {
- ret = _cal_db_util_end_trans(true);
- }
- else
- {
- _cal_db_util_end_trans(false);
- }
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ ret = _cal_db_util_end_trans(true);
+ }
+ else
+ {
+ _cal_db_util_end_trans(false);
+ }
return ret;
}
int ret = CALENDAR_ERROR_NONE;
cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_WRITE),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : write ");
retvm_if(NULL == view_uri, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
type = _cal_view_get_type(view_uri);
retvm_if(NULL == plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
retvm_if(NULL == plugin_cb->delete_record, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
- ret = _cal_db_util_begin_trans();
- retvm_if( CALENDAR_ERROR_NONE != ret,CALENDAR_ERROR_DB_FAILED, "Db failed" );
+ ret = _cal_db_util_begin_trans();
+ retvm_if( CALENDAR_ERROR_NONE != ret,CALENDAR_ERROR_DB_FAILED, "Db failed" );
ret = plugin_cb->delete_record(id);
- if (ret == CALENDAR_ERROR_NONE)
- {
- ret = _cal_db_util_end_trans(true);
- }
- else
- {
- _cal_db_util_end_trans(false);
- }
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ ret = _cal_db_util_end_trans(true);
+ }
+ else
+ {
+ _cal_db_util_end_trans(false);
+ }
return ret;
}
cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
calendar_list_h list = NULL;
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_READ),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : read ");
retvm_if(NULL == view_uri, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
type = _cal_view_get_type(view_uri);
retvm_if(NULL == plugin_cb->get_all_records, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
ret = plugin_cb->get_all_records(offset,limit, &list);
- if (CALENDAR_ERROR_NONE != ret)
- {
+ if (CALENDAR_ERROR_NONE != ret)
+ {
ERR("get_all_records() failed");
return ret;
}
cal_query_s *que = NULL;
calendar_list_h list = NULL;
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_READ),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : read ");
retvm_if(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
que = (cal_query_s *)query;
retvm_if(NULL == plugin_cb->get_records_with_query, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
ret = plugin_cb->get_records_with_query(query,offset,limit, &list);
- if (CALENDAR_ERROR_NONE != ret)
- {
+ if (CALENDAR_ERROR_NONE != ret)
+ {
ERR("get_records_with_query() failed");
return ret;
}
API int calendar_db_clean_after_sync( int calendar_book_id, int calendar_db_version )
{
- int ret;
- char query[CAL_DB_SQL_MIN_LEN] = {0};
- cal_db_util_error_e dbret = CAL_DB_OK;
- int len = 0;
-
- retvm_if(calendar_book_id < 0, CALENDAR_ERROR_INVALID_PARAMETER, "calendar_id(%d) is Invalid", calendar_book_id);
-
- ret = _cal_db_util_begin_trans();
- retvm_if( CALENDAR_ERROR_NONE != ret,CALENDAR_ERROR_DB_FAILED, "Db failed" );
- // !! please check rrule_table, alarm_table, attendee_table ..
-
- /* delete event table */
- len = snprintf(query, sizeof(query), "DELETE FROM %s "
- "WHERE is_deleted = 1 AND calendar_id = %d",
- CAL_TABLE_SCHEDULE,
- calendar_book_id);
- if (calendar_db_version > 0)
- {
- len = snprintf(query+len, sizeof(query)-len, " AND changed_ver <= %d", calendar_db_version);
- }
-
- dbret = _cal_db_util_query_exec(query);
- CAL_DBG("%s",query);
- if (dbret != CAL_DB_OK)
- {
- ERR("DB failed");
- _cal_db_util_end_trans(false);
+ int ret = CALENDAR_ERROR_NONE;
+ char query[CAL_DB_SQL_MIN_LEN] = {0};
+ cal_db_util_error_e dbret = CAL_DB_OK;
+ int len = 0;
+
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_WRITE),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : write ");
+ retvm_if(calendar_book_id < 0, CALENDAR_ERROR_INVALID_PARAMETER, "calendar_id(%d) is Invalid", calendar_book_id);
+
+ ret = _cal_db_util_begin_trans();
+ if (CALENDAR_ERROR_NONE != ret)
+ {
+ ERR("_cal_db_util_begin_trans() failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ // !! please check rrule_table, alarm_table, attendee_table ..
+
+ ret = _cal_is_owner(calendar_book_id);
+ if (CALENDAR_ERROR_NONE != ret) {
+ if (CALENDAR_ERROR_PERMISSION_DENIED == ret)
+ ERR("Does not have permission of calendar_book (%d)", calendar_book_id);
+ else
+ ERR("_cal_is_owner Fail(%d)", ret);
+ _cal_db_util_end_trans(false);
+ return ret;
+ }
+
+ /* delete event table */
+ len = snprintf(query, sizeof(query), "DELETE FROM %s "
+ "WHERE is_deleted = 1 AND calendar_id = %d",
+ CAL_TABLE_SCHEDULE,
+ calendar_book_id);
+ if (calendar_db_version > 0)
+ {
+ len = snprintf(query+len, sizeof(query)-len, " AND changed_ver <= %d", calendar_db_version);
+ }
+
+ dbret = _cal_db_util_query_exec(query);
+ CAL_DBG("%s",query);
+ if (dbret != CAL_DB_OK)
+ {
+ ERR("DB failed");
+ _cal_db_util_end_trans(false);
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
- retvm_if(ret < 0, ret, "cals_query_exec() failed (%d)", ret);
-
- /* delete delete table */
- snprintf(query, sizeof(query), "DELETE FROM %s "
- "WHERE calendar_id = %d",
- CAL_TABLE_DELETED,
- calendar_book_id);
-
- dbret = _cal_db_util_query_exec(query);
- CAL_DBG("%s",query);
- if (dbret != CAL_DB_OK)
- {
- ERR("DB failed");
- _cal_db_util_end_trans(false);
+ }
+ retvm_if(ret < 0, ret, "cals_query_exec() failed (%d)", ret);
+
+ /* delete delete table */
+ snprintf(query, sizeof(query), "DELETE FROM %s "
+ "WHERE calendar_id = %d",
+ CAL_TABLE_DELETED,
+ calendar_book_id);
+
+ dbret = _cal_db_util_query_exec(query);
+ CAL_DBG("%s",query);
+ if (dbret != CAL_DB_OK)
+ {
+ ERR("DB failed");
+ _cal_db_util_end_trans(false);
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
-
- _cal_db_util_end_trans(true);
+ }
+ _cal_db_util_end_trans(true);
return CALENDAR_ERROR_NONE;
}
API int calendar_db_get_count( const char* view_uri, int *out_count )
{
- int ret = CALENDAR_ERROR_NONE;
- cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
+ int ret = CALENDAR_ERROR_NONE;
+ cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
- retvm_if(NULL == view_uri, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_READ),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : read ");
+ retvm_if(NULL == view_uri, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- type = _cal_view_get_type(view_uri);
+ type = _cal_view_get_type(view_uri);
- cal_db_plugin_cb_s* plugin_cb = __cal_db_get_plugin(type);
- retvm_if(NULL == plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == plugin_cb->get_count, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
+ cal_db_plugin_cb_s* plugin_cb = __cal_db_get_plugin(type);
+ retvm_if(NULL == plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == plugin_cb->get_count, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
- ret = plugin_cb->get_count(out_count);
- return CALENDAR_ERROR_NONE;
+ ret = plugin_cb->get_count(out_count);
+ return ret;
}
API int calendar_db_get_count_with_query( calendar_query_h query, int *out_count )
{
- int ret = CALENDAR_ERROR_NONE;
- cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
- cal_query_s *que = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
+ cal_query_s *que = NULL;
- retvm_if(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- que = (cal_query_s *)query;
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_READ),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : read ");
+ retvm_if(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ que = (cal_query_s *)query;
- type = _cal_view_get_type(que->view_uri);
+ type = _cal_view_get_type(que->view_uri);
- cal_db_plugin_cb_s* plugin_cb = __cal_db_get_plugin(type);
- retvm_if(NULL == plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == plugin_cb->get_count_with_query, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
+ cal_db_plugin_cb_s* plugin_cb = __cal_db_get_plugin(type);
+ retvm_if(NULL == plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == plugin_cb->get_count_with_query, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
- ret = plugin_cb->get_count_with_query(query, out_count);
- return CALENDAR_ERROR_NONE;
+ ret = plugin_cb->get_count_with_query(query, out_count);
+ return ret;
}
API int calendar_db_insert_records(calendar_list_h list, int** ids, int* count)
{
- int ret = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
int i;
int *_ids = NULL;
int _count = 0;
- retvm_if(NULL == list, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_WRITE),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : write ");
+ retvm_if(NULL == list, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
ret = _cal_db_util_begin_trans();
if ( ret != CALENDAR_ERROR_NONE)
_ids = calloc(_count, sizeof(int));
+ // divide count for accessing of another modules.
+ int div = (int)(_count / BULK_DEFAULT_COUNT) + 1;
+ int bulk = _count / div + 1;
+
calendar_list_first(list);
for (i = 0; i < _count; i++)
{
DBG("Not plugin");
_cal_db_util_end_trans(false);
CAL_FREE(_ids);
- ret = CALENDAR_ERROR_NOT_PERMITTED;
- return ret;
+ return CALENDAR_ERROR_NOT_PERMITTED;
}
ret = plugin_cb->insert_record(record, &_ids[i]);
if (ret != CALENDAR_ERROR_NONE)
}
DBG("insert with id(%d)", _ids[i]);
calendar_list_next(list);
+
+ if (i > bulk)
+ {
+ bulk += (_count / div + 1);
+ _cal_db_util_end_trans(true);
+ sleep(1);
+ ret = _cal_db_util_begin_trans();
+ if ( ret != CALENDAR_ERROR_NONE)
+ {
+ calendar_list_destroy(list, true);
+ CAL_FREE(_ids);
+ ERR("Db failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
}
if (ids)
if (count) *count = _count;
_cal_db_util_end_trans(true);
- return ret;
+ return ret;
}
API int calendar_db_insert_records_async(calendar_list_h list, calendar_db_insert_result_cb callback, void *user_data)
{
- retvm_if(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_WRITE),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : write ");
+ retvm_if(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
#ifdef CAL_NATIVE
- if (callback != NULL)
- {
- int ret = CALENDAR_ERROR_NONE;
- calendar_list_h out_list = NULL;
-
- ret = _cal_list_clone(list, &out_list);
- retv_if(ret!=CALENDAR_ERROR_NONE,ret);
-
- __insert_records_data_s *callback_data = NULL;
- callback_data = calloc(1,sizeof(__insert_records_data_s));
-
- if (callback_data == NULL)
- {
- ERR("calloc fail");
- calendar_list_destroy(out_list, true);
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- callback_data->list = out_list;
- callback_data->callback = callback;
- callback_data->user_data = user_data;
- g_idle_add( &__cal_db_insert_records_idle, callback_data);
- return CALENDAR_ERROR_NONE;
- }
+ if (callback != NULL)
+ {
+ int ret = CALENDAR_ERROR_NONE;
+ calendar_list_h out_list = NULL;
+
+ ret = _cal_list_clone(list, &out_list);
+ retv_if(ret!=CALENDAR_ERROR_NONE,ret);
+
+ __insert_records_data_s *callback_data = NULL;
+ callback_data = calloc(1,sizeof(__insert_records_data_s));
+
+ if (callback_data == NULL)
+ {
+ ERR("calloc fail");
+ calendar_list_destroy(out_list, true);
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+ callback_data->list = out_list;
+ callback_data->callback = callback;
+ callback_data->user_data = user_data;
+ g_idle_add( &__cal_db_insert_records_idle, callback_data);
+ return CALENDAR_ERROR_NONE;
+ }
#endif
- int ret = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
int i;
- int *ids = NULL;
+ int *ids = NULL;
int count = 0;
- retvm_if(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
ret = _cal_db_util_begin_trans();
if ( ret != CALENDAR_ERROR_NONE)
{
DBG("Not plugin");
CAL_FREE(ids);
_cal_db_util_end_trans(false);
- ret = CALENDAR_ERROR_NOT_PERMITTED;
- return ret;
+ return CALENDAR_ERROR_NOT_PERMITTED;
}
ret = plugin_cb->insert_record(record, &ids[i]);
if (ret != CALENDAR_ERROR_NONE)
CAL_FREE(ids);
_cal_db_util_end_trans(true);
- return ret;
+ return ret;
}
API int calendar_db_update_records( calendar_list_h list)
{
int i;
int count = 0;
- int ret = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
- retvm_if(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_WRITE),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : write ");
+ retvm_if(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
ret = _cal_db_util_begin_trans();
if ( ret != CALENDAR_ERROR_NONE)
calendar_list_get_count(list, &count);
DBG("update list count(%d", count);
+ // divide count for accessing of another modules.
+ int div = (int)(count / BULK_DEFAULT_COUNT) + 1;
+ int bulk = count / div + 1;
+
calendar_list_first(list);
for (i = 0; i < count; i++)
{
}
DBG("update record");
calendar_list_next(list);
+
+ if (i > bulk)
+ {
+ bulk += (count / div + 1);
+ _cal_db_util_end_trans(true);
+ sleep(1);
+ ret = _cal_db_util_begin_trans();
+ if ( ret != CALENDAR_ERROR_NONE)
+ {
+ calendar_list_destroy(list, true);
+ ERR("Db failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
}
_cal_db_util_end_trans(true);
- return ret;
+ return ret;
}
API int calendar_db_update_records_async( calendar_list_h list, calendar_db_result_cb callback, void *user_data)
{
- retvm_if(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_WRITE),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : write ");
#ifdef CAL_NATIVE
- if (callback != NULL)
- {
- int ret = CALENDAR_ERROR_NONE;
- calendar_list_h out_list = NULL;
- ret = _cal_list_clone(list, &out_list);
- retv_if(ret!=CALENDAR_ERROR_NONE,ret);
-
- __update_records_data_s *callback_data = NULL;
- callback_data = calloc(1,sizeof(__update_records_data_s));
-
- if (callback_data == NULL)
- {
- ERR("calloc fail");
- calendar_list_destroy(out_list, true);
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- callback_data->list = out_list;
- callback_data->callback = callback;
- callback_data->user_data = user_data;
- g_idle_add( &__cal_db_update_records_idle, callback_data);
- return CALENDAR_ERROR_NONE;
- }
+ if (callback != NULL)
+ {
+ int ret = CALENDAR_ERROR_NONE;
+ calendar_list_h out_list = NULL;
+ ret = _cal_list_clone(list, &out_list);
+ retv_if(ret!=CALENDAR_ERROR_NONE,ret);
+
+ __update_records_data_s *callback_data = NULL;
+ callback_data = calloc(1,sizeof(__update_records_data_s));
+
+ if (callback_data == NULL)
+ {
+ ERR("calloc fail");
+ calendar_list_destroy(out_list, true);
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+ callback_data->list = out_list;
+ callback_data->callback = callback;
+ callback_data->user_data = user_data;
+ g_idle_add( &__cal_db_update_records_idle, callback_data);
+ return CALENDAR_ERROR_NONE;
+ }
#endif
int i;
int count = 0;
- int ret = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
- retvm_if(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
ret = _cal_db_util_begin_trans();
if (ret != CALENDAR_ERROR_NONE)
}
_cal_db_util_end_trans(true);
- return ret;
+ return ret;
}
API int calendar_db_delete_records(const char* view_uri, int record_id_array[], int count)
{
- retvm_if(NULL == view_uri, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == record_id_array, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(count <= 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_WRITE),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : write ");
+ retvm_if(NULL == view_uri, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == record_id_array, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(count <= 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- int ret = CALENDAR_ERROR_NONE;
- cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
+ int ret = CALENDAR_ERROR_NONE;
+ cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
- type = _cal_view_get_type(view_uri);
+ type = _cal_view_get_type(view_uri);
- cal_db_plugin_cb_s* plugin_cb = __cal_db_get_plugin(type);
- retvm_if(NULL == plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == plugin_cb->delete_records, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
+ cal_db_plugin_cb_s* plugin_cb = __cal_db_get_plugin(type);
+ retvm_if(NULL == plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == plugin_cb->delete_records, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
- ret = _cal_db_util_begin_trans();
- retvm_if( CALENDAR_ERROR_NONE != ret,CALENDAR_ERROR_DB_FAILED, "Db failed" );
+ ret = _cal_db_util_begin_trans();
+ retvm_if( CALENDAR_ERROR_NONE != ret,CALENDAR_ERROR_DB_FAILED, "Db failed" );
- ret = plugin_cb->delete_records(record_id_array,count);
+ ret = plugin_cb->delete_records(record_id_array,count);
- if (ret == CALENDAR_ERROR_NONE)
- {
- ret = _cal_db_util_end_trans(true);
- }
- else
- {
- _cal_db_util_end_trans(false);
- }
- return ret;
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ ret = _cal_db_util_end_trans(true);
+ }
+ else
+ {
+ _cal_db_util_end_trans(false);
+ }
+ return ret;
}
API int calendar_db_delete_records_async(const char* view_uri, int ids[], int count, calendar_db_result_cb callback, void *user_data)
{
- retvm_if(NULL == view_uri, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == ids, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(count <= 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_WRITE),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : write ");
+ retvm_if(NULL == view_uri, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == ids, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(count <= 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
#ifdef CAL_NATIVE
- if (callback != NULL)
- {
- __delete_records_data_s *callback_data = NULL;
- callback_data = calloc(1,sizeof(__delete_records_data_s));
-
- if (callback_data == NULL)
- {
- ERR("calloc fail");
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- callback_data->view_uri = view_uri;
- callback_data->ids = calloc(1, sizeof(int)*count);
- if (callback_data->ids == NULL)
- {
- CAL_FREE(callback_data);
- ERR("calloc fail");
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- memcpy(callback_data->ids, ids, sizeof(int)*count);
- callback_data->count = count;
- callback_data->callback = callback;
- callback_data->user_data = user_data;
- g_idle_add( &__cal_db_delete_records_idle, callback_data);
- return CALENDAR_ERROR_NONE;
- }
+ if (callback != NULL)
+ {
+ __delete_records_data_s *callback_data = NULL;
+ callback_data = calloc(1,sizeof(__delete_records_data_s));
+
+ if (callback_data == NULL)
+ {
+ ERR("calloc fail");
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+ callback_data->view_uri = view_uri;
+ callback_data->ids = calloc(1, sizeof(int)*count);
+ if (callback_data->ids == NULL)
+ {
+ CAL_FREE(callback_data);
+ ERR("calloc fail");
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+ memcpy(callback_data->ids, ids, sizeof(int)*count);
+ callback_data->count = count;
+ callback_data->callback = callback;
+ callback_data->user_data = user_data;
+ g_idle_add( &__cal_db_delete_records_idle, callback_data);
+ return CALENDAR_ERROR_NONE;
+ }
#endif
- int ret = CALENDAR_ERROR_NONE;
- cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
+ int ret = CALENDAR_ERROR_NONE;
+ cal_record_type_e type = CAL_RECORD_TYPE_INVALID;
- type = _cal_view_get_type(view_uri);
+ type = _cal_view_get_type(view_uri);
- cal_db_plugin_cb_s* plugin_cb = __cal_db_get_plugin(type);
- retvm_if(NULL == plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == plugin_cb->delete_records, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
+ cal_db_plugin_cb_s* plugin_cb = __cal_db_get_plugin(type);
+ retvm_if(NULL == plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == plugin_cb->delete_records, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
- ret = _cal_db_util_begin_trans();
- retvm_if( CALENDAR_ERROR_NONE != ret,CALENDAR_ERROR_DB_FAILED, "Db failed" );
+ ret = _cal_db_util_begin_trans();
+ retvm_if( CALENDAR_ERROR_NONE != ret,CALENDAR_ERROR_DB_FAILED, "Db failed" );
- ret = plugin_cb->delete_records(ids,count);
+ ret = plugin_cb->delete_records(ids,count);
- if (ret == CALENDAR_ERROR_NONE)
- {
- ret = _cal_db_util_end_trans(true);
- }
- else
- {
- _cal_db_util_end_trans(false);
- }
- return ret;
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ ret = _cal_db_util_end_trans(true);
+ }
+ else
+ {
+ _cal_db_util_end_trans(false);
+ }
+ return ret;
}
API int calendar_db_insert_vcalendars(const char* vcalendar_stream, int **record_id_array, int *count)
{
- int ret = CALENDAR_ERROR_NONE;
- calendar_list_h list = NULL;
- int list_count = 0;
- int i = 0;
- int *ids = NULL;
-
- retvm_if(NULL == vcalendar_stream, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == record_id_array, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == count, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- ret = calendar_vcalendar_parse_to_calendar(vcalendar_stream, &list);
- retvm_if(ret != CALENDAR_ERROR_NONE, ret, "parse fail");
-
- ret = calendar_list_get_count(list, &list_count);
- if (ret != CALENDAR_ERROR_NONE)
- {
- calendar_list_destroy(list, true);
- ERR("get count fail");
- return ret;
- }
-
- calendar_list_first(list);
- ids = calloc(1, sizeof(int)*list_count);
- if (ids == NULL)
- {
- calendar_list_destroy(list, true);
- ERR("calloc fail");
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
-
- ret = _cal_db_util_begin_trans();
-
- if ( ret != CALENDAR_ERROR_NONE)
- {
- calendar_list_destroy(list, true);
- CAL_FREE(ids);
- ERR("Db failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
-
- for(i=0;i<list_count;i++)
- {
- calendar_record_h record = NULL;
-
- ret = calendar_list_get_current_record_p(list, &record);
- if( ret != CALENDAR_ERROR_NONE)
- {
- calendar_list_destroy(list, true);
- CAL_FREE(ids);
- ERR("list get fail");
- _cal_db_util_end_trans(false);
- return ret;
- }
-
- // insert
- ret = calendar_db_insert_record(record, &ids[i]);
- if( ret != CALENDAR_ERROR_NONE)
- {
- calendar_list_destroy(list, true);
- CAL_FREE(ids);
- ERR("list get fail");
- _cal_db_util_end_trans(false);
- return ret;
- }
-
- calendar_list_next(list);
- }
-
- _cal_db_util_end_trans(true);
-
- *record_id_array = ids;
- *count = list_count;
-
- calendar_list_destroy(list, true);
- return ret;
+ int ret = CALENDAR_ERROR_NONE;
+ calendar_list_h list = NULL;
+ int list_count = 0;
+ int i = 0;
+ int *ids = NULL;
+
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_WRITE),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : write ");
+ retvm_if(NULL == vcalendar_stream, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == record_id_array, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == count, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ ret = calendar_vcalendar_parse_to_calendar(vcalendar_stream, &list);
+ retvm_if(ret != CALENDAR_ERROR_NONE, ret, "parse fail");
+
+ ret = calendar_list_get_count(list, &list_count);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ calendar_list_destroy(list, true);
+ ERR("get count fail");
+ return ret;
+ }
+
+ calendar_list_first(list);
+ ids = calloc(1, sizeof(int)*list_count);
+ if (ids == NULL)
+ {
+ calendar_list_destroy(list, true);
+ ERR("calloc fail");
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+
+ ret = _cal_db_util_begin_trans();
+
+ if ( ret != CALENDAR_ERROR_NONE)
+ {
+ calendar_list_destroy(list, true);
+ CAL_FREE(ids);
+ ERR("Db failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ for(i=0;i<list_count;i++)
+ {
+ calendar_record_h record = NULL;
+
+ ret = calendar_list_get_current_record_p(list, &record);
+ if( ret != CALENDAR_ERROR_NONE)
+ {
+ calendar_list_destroy(list, true);
+ CAL_FREE(ids);
+ ERR("list get fail");
+ _cal_db_util_end_trans(false);
+ return ret;
+ }
+
+ // insert
+ ret = calendar_db_insert_record(record, &ids[i]);
+ if( ret != CALENDAR_ERROR_NONE)
+ {
+ calendar_list_destroy(list, true);
+ CAL_FREE(ids);
+ ERR("list get fail");
+ _cal_db_util_end_trans(false);
+ return ret;
+ }
+
+ calendar_list_next(list);
+ }
+
+ _cal_db_util_end_trans(true);
+
+ *record_id_array = ids;
+ *count = list_count;
+
+ calendar_list_destroy(list, true);
+ return ret;
}
API int calendar_db_insert_vcalendars_async(const char* vcalendar_stream, calendar_db_insert_result_cb callback, void *user_data)
{
- int ret = CALENDAR_ERROR_NONE;
- retvm_if(NULL == vcalendar_stream, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == callback, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ int ret = CALENDAR_ERROR_NONE;
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_WRITE),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : write ");
+ retvm_if(NULL == vcalendar_stream, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == callback, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
#ifdef CAL_NATIVE
- __insert_vcalendars_data_s *callback_data = NULL;
- callback_data = calloc(1,sizeof(__insert_vcalendars_data_s));
+ __insert_vcalendars_data_s *callback_data = NULL;
+ callback_data = calloc(1,sizeof(__insert_vcalendars_data_s));
- if (callback_data == NULL)
- {
- ERR("calloc fail");
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- callback_data->vcalendar_stream = SAFE_STRDUP(vcalendar_stream);
- callback_data->callback = callback;
- callback_data->user_data = user_data;
- g_idle_add( &__cal_db_insert_vcalendars_idle, callback_data);
+ if (callback_data == NULL)
+ {
+ ERR("calloc fail");
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+ callback_data->vcalendar_stream = SAFE_STRDUP(vcalendar_stream);
+ callback_data->callback = callback;
+ callback_data->user_data = user_data;
+ g_idle_add( &__cal_db_insert_vcalendars_idle, callback_data);
#endif
- return ret;
+ return ret;
}
API int calendar_db_replace_vcalendars(const char* vcalendar_stream, int *record_id_array, int count)
{
- int ret = CALENDAR_ERROR_NONE;
- calendar_list_h list = NULL;
- int list_count = 0;
- int i = 0;
-
- retvm_if(NULL == vcalendar_stream, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == record_id_array, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(count <= 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- ret = calendar_vcalendar_parse_to_calendar(vcalendar_stream, &list);
- retvm_if(ret != CALENDAR_ERROR_NONE, ret, "parse fail");
-
- ret = calendar_list_get_count(list, &list_count);
- if (ret != CALENDAR_ERROR_NONE)
- {
- calendar_list_destroy(list, true);
- ERR("get count fail");
- return ret;
- }
-
- // check count
- if (count != list_count)
- {
- calendar_list_destroy(list, true);
- ERR("get count fail vcalendar_count=%d, input count=%d", list_count, count);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- calendar_list_first(list);
-
- ret = _cal_db_util_begin_trans();
-
- if ( ret != CALENDAR_ERROR_NONE)
- {
- calendar_list_destroy(list, true);
- ERR("Db failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
-
- for(i=0;i<list_count;i++)
- {
- calendar_record_h record = NULL;
- char *view_uri = NULL;
-
- ret = calendar_list_get_current_record_p(list, &record);
- if( ret != CALENDAR_ERROR_NONE)
- {
- calendar_list_destroy(list, true);
- ERR("list get fail");
- _cal_db_util_end_trans(false);
- return ret;
- }
-
- // set_id
- ret = calendar_record_get_uri_p(record, &view_uri);
- if( ret != CALENDAR_ERROR_NONE)
- {
- calendar_list_destroy(list, true);
- ERR("record get uri fail");
- _cal_db_util_end_trans(false);
- return ret;
- }
-
- if(strcmp(view_uri, _calendar_event._uri) == 0)
- {
- ret = _cal_record_set_int(record, _calendar_event.id, record_id_array[i]);
- }
- else if(strcmp(view_uri, _calendar_todo._uri) == 0)
- {
- ret = _cal_record_set_int(record, _calendar_todo.id, record_id_array[i]);
- }
- else
- {
- calendar_list_destroy(list, true);
- ERR("record get uri(%s) fail", view_uri);
- _cal_db_util_end_trans(false);
- return ret;
- }
-
- if( ret != CALENDAR_ERROR_NONE)
- {
- calendar_list_destroy(list, true);
- ERR("record set fail");
- _cal_db_util_end_trans(false);
- return ret;
- }
-
- // update
- ret = calendar_db_update_record(record);
- if( ret != CALENDAR_ERROR_NONE)
- {
- calendar_list_destroy(list, true);
- ERR("list get fail");
- _cal_db_util_end_trans(false);
- return ret;
- }
-
- calendar_list_next(list);
- }
-
- _cal_db_util_end_trans(true);
-
- calendar_list_destroy(list, true);
-
- return ret;
+ int ret = CALENDAR_ERROR_NONE;
+ calendar_list_h list = NULL;
+ int list_count = 0;
+ int i = 0;
+
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_WRITE),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : write ");
+ retvm_if(NULL == vcalendar_stream, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == record_id_array, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(count <= 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ ret = calendar_vcalendar_parse_to_calendar(vcalendar_stream, &list);
+ retvm_if(ret != CALENDAR_ERROR_NONE, ret, "parse fail");
+
+ ret = calendar_list_get_count(list, &list_count);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ calendar_list_destroy(list, true);
+ ERR("get count fail");
+ return ret;
+ }
+
+ // check count
+ if (count != list_count)
+ {
+ calendar_list_destroy(list, true);
+ ERR("get count fail vcalendar_count=%d, input count=%d", list_count, count);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ calendar_list_first(list);
+
+ ret = _cal_db_util_begin_trans();
+ if ( ret != CALENDAR_ERROR_NONE)
+ {
+ calendar_list_destroy(list, true);
+ ERR("Db failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ // divide count for accessing of another modules.
+ int div = (int)(count / BULK_DEFAULT_COUNT) + 1;
+ int bulk = count / div + 1;
+
+ for(i = 0; i < list_count; i++)
+ {
+ calendar_record_h record = NULL;
+ char *view_uri = NULL;
+
+ ret = calendar_list_get_current_record_p(list, &record);
+ if( ret != CALENDAR_ERROR_NONE)
+ {
+ calendar_list_destroy(list, true);
+ ERR("list get fail");
+ _cal_db_util_end_trans(false);
+ return ret;
+ }
+
+ // set_id
+ ret = calendar_record_get_uri_p(record, &view_uri);
+ if( ret != CALENDAR_ERROR_NONE)
+ {
+ calendar_list_destroy(list, true);
+ ERR("record get uri fail");
+ _cal_db_util_end_trans(false);
+ return ret;
+ }
+
+ if(strcmp(view_uri, _calendar_event._uri) == 0)
+ {
+ ret = _cal_record_set_int(record, _calendar_event.id, record_id_array[i]);
+ }
+ else if(strcmp(view_uri, _calendar_todo._uri) == 0)
+ {
+ ret = _cal_record_set_int(record, _calendar_todo.id, record_id_array[i]);
+ }
+ else
+ {
+ DBG("this uri[%s] is not replacable.", view_uri);
+ calendar_list_next(list);
+ continue;
+ }
+
+ if( ret != CALENDAR_ERROR_NONE)
+ {
+ calendar_list_destroy(list, true);
+ ERR("record set fail");
+ _cal_db_util_end_trans(false);
+ return ret;
+ }
+
+ // update
+ ret = calendar_db_update_record(record);
+ if( ret != CALENDAR_ERROR_NONE)
+ {
+ calendar_list_destroy(list, true);
+ ERR("list get fail");
+ _cal_db_util_end_trans(false);
+ return ret;
+ }
+ calendar_list_next(list);
+
+ if (i > bulk)
+ {
+ bulk += (count / div + 1);
+ _cal_db_util_end_trans(true);
+ sleep(1);
+ ret = _cal_db_util_begin_trans();
+ if ( ret != CALENDAR_ERROR_NONE)
+ {
+ calendar_list_destroy(list, true);
+ ERR("Db failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ }
+
+ _cal_db_util_end_trans(true);
+
+ calendar_list_destroy(list, true);
+
+ return ret;
}
API int calendar_db_replace_vcalendars_async(const char* vcalendar_stream, int *record_id_array, int count, calendar_db_result_cb callback, void *user_data)
{
- int ret = CALENDAR_ERROR_NONE;
- retvm_if(NULL == vcalendar_stream, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == callback, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == record_id_array, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(count <= 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ int ret = CALENDAR_ERROR_NONE;
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_WRITE),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : write ");
+ retvm_if(NULL == vcalendar_stream, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == callback, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == record_id_array, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(count <= 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
#ifdef CAL_NATIVE
- __replace_vcalendars_data_s *callback_data = NULL;
- callback_data = calloc(1,sizeof(__replace_vcalendars_data_s));
-
- if (callback_data == NULL)
- {
- ERR("calloc fail");
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- callback_data->ids = calloc(1, sizeof(int)*count);
- if (callback_data->ids == NULL)
- {
- CAL_FREE(callback_data);
- ERR("calloc fail");
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- memcpy(callback_data->ids, record_id_array, sizeof(int)*count);
- callback_data->vcalendar_stream = SAFE_STRDUP(vcalendar_stream);
- callback_data->callback = callback;
- callback_data->user_data = user_data;
- callback_data->count = count;
- g_idle_add( &__cal_db_replace_vcalendars_idle, callback_data);
+ __replace_vcalendars_data_s *callback_data = NULL;
+ callback_data = calloc(1,sizeof(__replace_vcalendars_data_s));
+
+ if (callback_data == NULL)
+ {
+ ERR("calloc fail");
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+ callback_data->ids = calloc(1, sizeof(int)*count);
+ if (callback_data->ids == NULL)
+ {
+ CAL_FREE(callback_data);
+ ERR("calloc fail");
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+ memcpy(callback_data->ids, record_id_array, sizeof(int)*count);
+ callback_data->vcalendar_stream = SAFE_STRDUP(vcalendar_stream);
+ callback_data->callback = callback;
+ callback_data->user_data = user_data;
+ callback_data->count = count;
+ g_idle_add( &__cal_db_replace_vcalendars_idle, callback_data);
#endif
- return ret;
+ return ret;
}
API int calendar_db_replace_record(calendar_record_h record, int record_id)
{
- cal_record_s *temp=NULL ;
- int ret = CALENDAR_ERROR_NONE;
+ cal_record_s *temp=NULL ;
+ int ret = CALENDAR_ERROR_NONE;
- retvm_if(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(record_id < 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_WRITE),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : write ");
+ retvm_if(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(record_id < 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- temp = (cal_record_s*)(record);
+ temp = (cal_record_s*)(record);
- cal_db_plugin_cb_s* plugin_cb = __cal_db_get_plugin(temp->type);
- retvm_if(NULL == plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == plugin_cb->replace_record, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
+ cal_db_plugin_cb_s* plugin_cb = __cal_db_get_plugin(temp->type);
+ retvm_if(NULL == plugin_cb, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == plugin_cb->replace_record, CALENDAR_ERROR_NOT_PERMITTED, "Not permitted");
- ret = _cal_db_util_begin_trans();
- retvm_if( CALENDAR_ERROR_NONE != ret,CALENDAR_ERROR_DB_FAILED, "Db failed" );
+ ret = _cal_db_util_begin_trans();
+ retvm_if( CALENDAR_ERROR_NONE != ret,CALENDAR_ERROR_DB_FAILED, "Db failed" );
- ret = plugin_cb->replace_record(record, record_id);
+ ret = plugin_cb->replace_record(record, record_id);
- if (ret == CALENDAR_ERROR_NONE)
- {
- ret = _cal_db_util_end_trans(true);
- }
- else
- {
- _cal_db_util_end_trans(false);
- }
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ ret = _cal_db_util_end_trans(true);
+ }
+ else
+ {
+ _cal_db_util_end_trans(false);
+ }
- return ret;
+ return ret;
}
API int calendar_db_replace_records(calendar_list_h list, int *ids, int count)
{
int i;
- int ret = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
- retvm_if(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == ids, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(count <= 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_WRITE),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : write ");
+ retvm_if(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == ids, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(count <= 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
ret = _cal_db_util_begin_trans();
if ( ret != CALENDAR_ERROR_NONE)
ret = plugin_cb->replace_record(record, ids[i]);
if (ret != CALENDAR_ERROR_NONE)
{
- DBG("Failed to insert record");
+ DBG("Failed to replace record");
_cal_db_util_end_trans(false);
return ret;
}
calendar_list_next(list);
}
_cal_db_util_end_trans(true);
-
- return ret;
+ return ret;
}
API int calendar_db_replace_records_async(calendar_list_h record_list, int *record_id_array, int count, calendar_db_result_cb callback, void *user_data)
{
- int ret = CALENDAR_ERROR_NONE;
- retvm_if(NULL == record_list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == callback, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == record_id_array, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(count <= 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ int ret = CALENDAR_ERROR_NONE;
+
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_WRITE),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : write ");
+ retvm_if(NULL == record_list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == callback, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == record_id_array, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(count <= 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
#ifdef CAL_NATIVE
- calendar_list_h out_list = NULL;
+ calendar_list_h out_list = NULL;
- ret = _cal_list_clone(record_list, &out_list);
- retv_if(ret!=CALENDAR_ERROR_NONE,ret);
+ ret = _cal_list_clone(record_list, &out_list);
+ retv_if(ret!=CALENDAR_ERROR_NONE,ret);
- __replace_records_data_s *callback_data = NULL;
- callback_data = calloc(1,sizeof(__replace_records_data_s));
- if (callback_data == NULL)
- {
- ERR("calloc fail");
+ __replace_records_data_s *callback_data = NULL;
+ callback_data = calloc(1,sizeof(__replace_records_data_s));
+ if (callback_data == NULL)
+ {
+ ERR("calloc fail");
calendar_list_destroy(out_list, true);
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
-
- callback_data->ids = calloc(1, sizeof(int)*count);
- if (callback_data->ids == NULL)
- {
- CAL_FREE(callback_data);
- ERR("calloc fail");
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+
+ callback_data->ids = calloc(1, sizeof(int)*count);
+ if (callback_data->ids == NULL)
+ {
+ CAL_FREE(callback_data);
+ ERR("calloc fail");
calendar_list_destroy(out_list, true);
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- memcpy(callback_data->ids, record_id_array, sizeof(int)*count);
- callback_data->list = out_list;
- callback_data->callback = callback;
- callback_data->user_data = user_data;
- callback_data->count = count;
- g_idle_add( &__cal_db_replace_records_idle, callback_data);
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+ memcpy(callback_data->ids, record_id_array, sizeof(int)*count);
+ callback_data->list = out_list;
+ callback_data->callback = callback;
+ callback_data->user_data = user_data;
+ callback_data->count = count;
+ g_idle_add( &__cal_db_replace_records_idle, callback_data);
#endif
- return ret;
+ return ret;
}
API int calendar_db_get_last_change_version(int* last_version)
{
- int ret = CALENDAR_ERROR_NONE;
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_READ),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : read ");
+ retvm_if(NULL == last_version, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ *last_version = _cal_db_util_get_transaction_ver();
+ return CALENDAR_ERROR_NONE;
+}
- retvm_if(NULL == last_version, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- *last_version = _cal_db_util_get_transaction_ver();
- return ret;
+API int calendar_db_get_changes_exception_by_version(const char* view_uri, int original_event_id, int calendar_db_version, calendar_list_h* record_list)
+{
+ const char *query_cur_version = "SELECT ver FROM "CAL_TABLE_VERSION;
+ int transaction_ver = 0;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+ int ret = 0;
+ int is_deleted = 0;
+
+ retvm_if(!_cal_access_control_have_permission(CAL_PERMISSION_READ),
+ CALENDAR_ERROR_PERMISSION_DENIED, "Permission denied : read ");
+ retvm_if(NULL == view_uri || NULL == record_list || original_event_id <= 0,
+ CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ ret = _cal_db_util_query_get_first_int_result(query_cur_version, NULL, &transaction_ver);
+ retvm_if (CALENDAR_ERROR_NONE != ret, ret, "_cal_db_util_query_get_first_int_result() failed");
+
+ int schedule_type = 0;
+ int record_type = 0;
+ if (strcmp(view_uri,_calendar_event._uri) == 0) {
+ schedule_type = CAL_SCH_TYPE_EVENT;
+ record_type = CAL_RECORD_TYPE_EVENT;
+
+ } else {
+ ERR("Invalid parameter");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ snprintf(query, sizeof(query),
+ "SELECT id, changed_ver, created_ver, is_deleted, calendar_id FROM %s "
+ "WHERE changed_ver > %d AND changed_ver <= %d AND type = %d AND original_event_id = %d "
+ "UNION "
+ "SELECT schedule_id, deleted_ver, created_ver, 1, calendar_id FROM %s "
+ "WHERE deleted_ver > %d AND schedule_type = %d AND original_event_id = %d ",
+ CAL_TABLE_SCHEDULE,
+ calendar_db_version, transaction_ver, schedule_type, original_event_id,
+ CAL_TABLE_DELETED,
+ calendar_db_version, record_type, original_event_id);
+ SEC_DBG("query[%s]", query);
+
+ ret = calendar_list_create(record_list);
+ retvm_if (ret != CALENDAR_ERROR_NONE, ret, "calendar_list_create() Failed");
+
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt)
+ {
+ ERR("_cal_db_util_query_prepare() Failed");
+ calendar_list_destroy(*record_list, true);
+ *record_list = NULL;
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ {
+ calendar_record_h record;
+ int id = 0, calendar_id = 0,type = 0;
+ int ver = 0;
+ int created_ver = 0;
+ // stmt -> record
+ ret = calendar_record_create(_calendar_updated_info._uri,&record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ ERR("calendar_record_create() failed");
+ calendar_list_destroy(*record_list, true);
+ *record_list = NULL;
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+
+ id = sqlite3_column_int(stmt, 0);
+ ver = sqlite3_column_int(stmt, 1);
+ created_ver = sqlite3_column_int(stmt, 2);
+ is_deleted = sqlite3_column_int(stmt, 3);
+ if (is_deleted == 1)
+ {
+ type = CALENDAR_RECORD_MODIFIED_STATUS_DELETED;
+ }
+ else if (created_ver != ver)
+ {
+ type = CALENDAR_RECORD_MODIFIED_STATUS_UPDATED;
+ }
+ else
+ {
+ type = CALENDAR_RECORD_MODIFIED_STATUS_INSERTED;
+ }
+
+ calendar_id = sqlite3_column_int(stmt, 4);
+#if 0
+ if (type == CALENDAR_RECORD_MODIFIED_STATUS_DELETED && created_ver > calendar_db_version)
+ {
+ calendar_record_destroy(record, true);
+ continue;
+ }
+#endif
+
+ _cal_record_set_int(record,_calendar_updated_info.id,id);
+ _cal_record_set_int(record,_calendar_updated_info.calendar_book_id,calendar_id);
+ _cal_record_set_int(record,_calendar_updated_info.modified_status,type);
+ _cal_record_set_int(record,_calendar_updated_info.version,ver);
+
+ ret = calendar_list_add(*record_list,record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*record_list, true);
+ *record_list = NULL;
+ calendar_record_destroy(record, true);
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+ }
+
+ //*current_calendar_db_version = transaction_ver;
+ sqlite3_finalize(stmt);
+
+ calendar_list_first(*record_list);
+
+ return CALENDAR_ERROR_NONE;
+}
+
+int _cal_db_append_string(char **dst, char *src)
+{
+ if (NULL == dst || NULL == src)
+ {
+ ERR("Invalid parameter");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ int len_src = strlen(src);
+ if (len_src == 0)
+ {
+ DBG("src len is 0");
+ return CALENDAR_ERROR_NONE;
+ }
+ if (NULL == *dst)
+ {
+ *dst = strdup(src);
+ if (*dst == NULL)
+ {
+ ERR("strdup fail");
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+ return CALENDAR_ERROR_NONE;
+ }
+ int len_dst = strlen(*dst);
+ char *tmp = *dst;
+ tmp = (char *)realloc(tmp, len_dst + len_src + 2);
+ if (tmp == NULL)
+ {
+ ERR("strdup fail");
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+ *dst = tmp;
+ strcat(*dst, " ");
+ strcat(*dst, src);
+ return CALENDAR_ERROR_NONE;
}
+
#define CAL_DB_JOURNAL_PATH tzplatform_mkpath(TZ_USER_DB, ".calendar-svc.db-journal")
// For Security
-#define CAL_SECURITY_FILE_GROUP 6003
+#define CAL_SECURITY_FILE_GROUP 5000
#define CAL_SECURITY_DEFAULT_PERMISSION 0660
#define CAL_SECURITY_DIR_DEFAULT_PERMISSION 0770
#define CAL_DB_SQL_MAX_LEN 2048
#define CAL_DB_SQL_MIN_LEN 1024
+#define _BUFFER_ORDER 128
// DB table
#define CAL_TABLE_SCHEDULE "schedule_table"
#define CAL_TABLE_ALARM "alarm_table"
-#define CAL_REMINDER_ALERT "reminder_table"
#define CAL_TABLE_CALENDAR "calendar_table"
#define CAL_TABLE_ATTENDEE "attendee_table"
#define CAL_TABLE_TIMEZONE "timezone_table"
#define CAL_VIEW_TABLE_EVENT_CALENDAR_ATTENDEE "event_calendar_attendee_view"
#define CAL_VIEW_TABLE_NORMAL_INSTANCE "normal_instance_view"
#define CAL_VIEW_TABLE_ALLDAY_INSTANCE "allday_instance_view"
+#define CAL_VIEW_TABLE_NORMAL_INSTANCE_EXTENDED "normal_instance_view_extended"
+#define CAL_VIEW_TABLE_ALLDAY_INSTANCE_EXTENDED "allday_instance_view_extended"
+
+#define CAL_QUERY_SCHEDULE_A_ALL "A.id, A.type, A.summary, A.description, A.location, A.categories, A.exdate, A.task_status, "\
+ "A.priority, A.timezone, A.contact_id, A.busy_status, A.sensitivity, A.uid, A.organizer_name, "\
+ "A.organizer_email, A.meeting_status, A.calendar_id, A.original_event_id, A.latitude, A.longitude, "\
+ "A.email_id, A.created_time, A.completed_time, A.progress, A.changed_ver, A.created_ver, A.is_deleted, "\
+ "A.dtstart_type, A.dtstart_utime, A.dtstart_datetime, A.dtstart_tzid, "\
+ "A.dtend_type, A.dtend_utime, A.dtend_datetime, A.dtend_tzid, "\
+ "A.last_mod, A.rrule_id, A.recurrence_id, A.rdate, A.has_attendee, A.has_alarm, A.system_type, A.updated, "\
+ "A.sync_data1, A.sync_data2, A.sync_data3, A.sync_data4, A.has_exception, A.has_extended, A.freq, A.is_allday "
typedef int (*cal_db_insert_record_cb)( calendar_record_h record, int* id );
typedef int (*cal_db_get_record_cb)( int id, calendar_record_h* out_record );
typedef int (*cal_db_replace_records)(calendar_list_h record_list, int *record_id_array, int count);
typedef struct {
- bool is_query_only;
- cal_db_insert_record_cb insert_record;
- cal_db_get_record_cb get_record;
- cal_db_update_record_cb update_record;
- cal_db_delete_record_cb delete_record;
- cal_db_get_all_records_cb get_all_records;
- cal_db_get_records_with_query_cb get_records_with_query;
- cal_db_insert_records_cb insert_records;
- cal_db_update_records_cb update_records;
- cal_db_delete_records_cb delete_records;
- cal_db_get_count_cb get_count;
- cal_db_get_count_with_query_cb get_count_with_query;
- cal_db_replace_record replace_record;
- cal_db_replace_records replace_records;
+ bool is_query_only;
+ cal_db_insert_record_cb insert_record;
+ cal_db_get_record_cb get_record;
+ cal_db_update_record_cb update_record;
+ cal_db_delete_record_cb delete_record;
+ cal_db_get_all_records_cb get_all_records;
+ cal_db_get_records_with_query_cb get_records_with_query;
+ cal_db_insert_records_cb insert_records;
+ cal_db_update_records_cb update_records;
+ cal_db_delete_records_cb delete_records;
+ cal_db_get_count_cb get_count;
+ cal_db_get_count_with_query_cb get_count_with_query;
+ cal_db_replace_record replace_record;
+ cal_db_replace_records replace_records;
} cal_db_plugin_cb_s;
int _cal_db_open(void);
int _cal_db_close(void);
+int _cal_db_get_record( const char* view_uri, int record_id, calendar_record_h* record );
+int _cal_db_append_string(char **dst, char *src);
+void _cal_db_initialize_view_table(void);
+
#endif // __CALENDAR_SVC_DB_H__
*/
#include <stdlib.h>
-#include <appsvc.h>
#ifdef CAL_NATIVE
#include <alarm.h>
#endif
#include "cal_view.h"
#include "cal_time.h"
#include "cal_record.h"
+#include "cal_list.h"
#include "cal_db_util.h"
#include "cal_db.h"
#include "cal_db_instance.h"
#include "cal_db_alarm.h"
-#define ONE_DAY_SECONDS 86400L // seconds in a day
-#define ONE_WEEK_SECONDS 604800L // seconds in a week
-#define ONE_MONTH_SECONDS 2678400L // seconds in a month
-#define ONE_YEAR_SECONDS 31536000L // seconds in a year
-
-static int __cal_db_alarm_insert_record(calendar_record_h record, int* id);
-static int __cal_db_alarm_get_record(int id, calendar_record_h* out_record);
-static int __cal_db_alarm_update_record(calendar_record_h record);
-static int __cal_db_alarm_delete_record(int id);
-static int __cal_db_alarm_get_all_records(int offset, int limit, calendar_list_h* out_list);
-static int __cal_db_alarm_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* out_list);
-static int __cal_db_alarm_insert_records(const calendar_list_h list, int** ids);
-static int __cal_db_alarm_update_records(const calendar_list_h list);
-static int __cal_db_alarm_delete_records(int ids[], int count);
-static int __cal_db_alarm_get_count(int *out_count);
-static int __cal_db_alarm_get_count_with_query(calendar_query_h query, int *out_count);
-
-/*
- * static function
- */
-static void __cal_db_alarm_get_stmt(sqlite3_stmt *stmt,calendar_record_h record);
-static void __cal_db_alarm_get_property_stmt(sqlite3_stmt *stmt,
- unsigned int property, int *stmt_count, calendar_record_h record);
-static void __cal_db_alarm_get_projection_stmt(sqlite3_stmt *stmt,
- const unsigned int *projection, const int projection_count,
- calendar_record_h record);
-
-
-cal_db_plugin_cb_s _cal_db_alarm_plugin_cb = {
- .is_query_only = false,
- .insert_record=__cal_db_alarm_insert_record,
- .get_record=__cal_db_alarm_get_record,
- .update_record=__cal_db_alarm_update_record,
- .delete_record=__cal_db_alarm_delete_record,
- .get_all_records=__cal_db_alarm_get_all_records,
- .get_records_with_query=__cal_db_alarm_get_records_with_query,
- .insert_records=__cal_db_alarm_insert_records,
- .update_records=__cal_db_alarm_update_records,
- .delete_records=__cal_db_alarm_delete_records,
- .get_count=__cal_db_alarm_get_count,
- .get_count_with_query=__cal_db_alarm_get_count_with_query,
- .replace_record=NULL,
- .replace_records=NULL
-};
-
-static int __cal_db_alarm_insert_record(calendar_record_h record, int* id)
+static int __cal_db_alarm_insert_record(calendar_record_h record, int parent_id)
{
- int record_type = CALENDAR_BOOK_TYPE_EVENT;
- char query[CAL_DB_SQL_MAX_LEN];
- sqlite3_stmt *stmt;
cal_alarm_s *alarm = NULL;
- cal_db_util_error_e dbret = CAL_DB_OK;
alarm = (cal_alarm_s *)(record);
retvm_if(NULL == alarm, CALENDAR_ERROR_INVALID_PARAMETER,
"Invalid argument: cal_alarm_s is NULL");
- if (alarm->remind_tick_unit == CALENDAR_ALARM_NONE)
- {
+ if (alarm->remind_tick_unit == CALENDAR_ALARM_NONE) {
DBG("No alarm unit tick");
return CALENDAR_ERROR_NONE;
}
- else if (alarm->remind_tick_unit != CALENDAR_ALARM_TIME_UNIT_SPECIFIC)
- {
- cal_db_util_error_e dbret = CAL_DB_OK;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
- int index;
- int alarm_type = 0;
- int alarm_datetime = 0;
- long long int alarm_utime = 0;
-
- snprintf(query, sizeof(query), "SELECT type FROM %s WHERE id = %d ",
- CAL_TABLE_SCHEDULE, alarm->event_id);
- DBG("query[%s]", query);
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- dbret = _cal_db_util_stmt_step(stmt);
- if (CAL_DB_ROW != dbret)
- {
- ERR("_cal_db_util_stmt_step() failed");
- sqlite3_finalize(stmt);
- switch (dbret)
- {
- case CAL_DB_DONE:
- ERR("Failed to find record(id:%d, ret:%d)", id, dbret);
- return CALENDAR_ERROR_DB_RECORD_NOT_FOUND;
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
-
- index = 0;
- record_type = sqlite3_column_int(stmt, index++);
- sqlite3_finalize(stmt);
- stmt = NULL;
-
- switch (record_type)
- {
- case CALENDAR_BOOK_TYPE_EVENT:
- snprintf(query, sizeof(query),
- "SELECT dtstart_tzid, dtstart_type, dtstart_utime, dtstart_datetime "
- "FROM %s WHERE id = %d",
- CAL_TABLE_SCHEDULE, alarm->event_id);
-
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- dbret = _cal_db_util_stmt_step(stmt);
- if (CAL_DB_ROW != dbret)
- {
- ERR("_cal_db_util_stmt_step() failed");
- sqlite3_finalize(stmt);
- switch (dbret)
- {
- case CAL_DB_DONE:
- ERR("Failed to find record(id:%d, ret:%d)", id, dbret);
- return CALENDAR_ERROR_DB_RECORD_NOT_FOUND;
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- index = 0;
- sqlite3_column_text(stmt, index++);
- alarm_type = sqlite3_column_int(stmt, index++);
- alarm_utime = sqlite3_column_int64(stmt, index++);
- alarm_datetime = sqlite3_column_int(stmt, index++);
- sqlite3_finalize(stmt);
- stmt = NULL;
- break;
-
- case CALENDAR_BOOK_TYPE_TODO:
- snprintf(query, sizeof(query),
- "SELECT dtend_tzid, dtend_type, dtend_utime, dtend_datetime "
- " FROM %s WHERE id = %d",
- CAL_TABLE_SCHEDULE, alarm->event_id);
-
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- dbret = _cal_db_util_stmt_step(stmt);
- if (CAL_DB_ROW != dbret)
- {
- ERR("_cal_db_util_stmt_step() failed");
- sqlite3_finalize(stmt);
- switch (dbret)
- {
- case CAL_DB_DONE:
- ERR("Failed to find record(id:%d, ret:%d)", id, dbret);
- return CALENDAR_ERROR_DB_RECORD_NOT_FOUND;
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
-
- index = 0;
- sqlite3_column_text(stmt, index++);
- alarm_type = sqlite3_column_int(stmt, index++);
- alarm_utime = sqlite3_column_int64(stmt, index++);
- alarm_datetime = sqlite3_column_int(stmt, index++);
- sqlite3_finalize(stmt);
- stmt = NULL;
- break;
- }
-
- switch (alarm_type)
- {
- case CALENDAR_TIME_UTIME:
- alarm->alarm_time = alarm_utime;
- break;
-
- case CALENDAR_TIME_LOCALTIME:
- alarm->alarm_time = alarm_datetime;
- break;
- }
- }
+ cal_db_util_error_e dbret = CAL_DB_OK;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
snprintf(query, sizeof(query),
"INSERT INTO %s ("
"event_id, "
- "alarm_time, remind_tick, remind_tick_unit, "
- "alarm_tone, alarm_description, "
- "alarm_type, alarm_id "
+ "remind_tick, remind_tick_unit, "
+ "alarm_description, "
+ "alarm_type, "
+ "alarm_summary, alarm_action, alarm_attach, "
+ "alarm_utime, alarm_datetime "
") VALUES ( "
"%d, "
- "%lld, %d, %d, "
- "?, ?, "
- "%d, %d )",
+ "%d, %d, "
+ "?, "
+ "%d, "
+ "?, %d, ?, "
+ "%lld, ?)",
CAL_TABLE_ALARM,
- alarm->event_id,
- alarm->alarm_time, alarm->remind_tick, alarm->remind_tick_unit,
- alarm->alarm_type, alarm->alarm_id);
+ parent_id,
+ alarm->remind_tick, alarm->remind_tick_unit,
+ alarm->alarm.type,
+ alarm->alarm_action,
+ alarm->alarm.time.utime);
- CAL_DBG("%s",query);
+ SEC_DBG("%s",query);
stmt = _cal_db_util_query_prepare(query);
- retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "_cal_db_util_query_prepare() Failed");
-
- if (alarm->alarm_tone)
- _cal_db_util_stmt_bind_text(stmt, 1, alarm->alarm_tone);
-
- if (alarm->alarm_description)
- _cal_db_util_stmt_bind_text(stmt, 2, alarm->alarm_description);
-
- dbret = _cal_db_util_stmt_step(stmt);
- sqlite3_finalize(stmt);
-
- if (CAL_DB_DONE != dbret)
- {
- ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
+ if (NULL == stmt) {
+ DBG("_cal_db_util_query_prepare() Failed");
+ DBG("query[%s]", query);
+ return CALENDAR_ERROR_DB_FAILED;
}
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_db_alarm_get_record(int id, calendar_record_h* out_record )
-{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
- cal_db_util_error_e dbret = CAL_DB_OK;
- int ret = CALENDAR_ERROR_NONE;
+ int index = 1;
- retvm_if(id < 0, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid argument: id(%d)", id);
-
- ret = calendar_record_create(_calendar_alarm._uri, out_record);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_record_create(%d)", ret);
- return CALENDAR_ERROR_DB_FAILED;
- }
- snprintf(query, sizeof(query),
- "SELECT * FROM %s "
- "WHERE event_id = %d ",
- CAL_TABLE_ALARM,
- id);
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() Failed");
- calendar_record_destroy(*out_record, true);
- *out_record = NULL;
- return CALENDAR_ERROR_DB_FAILED;
- }
-
- dbret = _cal_db_util_stmt_step(stmt);
- if (dbret != CAL_DB_ROW)
- {
- ERR(" _cal_db_util_stmt_step() Failed(%d)", dbret);
- sqlite3_finalize(stmt);
- calendar_record_destroy(*out_record, true);
- *out_record = NULL;
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
+ if (alarm->alarm_description) {
+ _cal_db_util_stmt_bind_text(stmt, index, alarm->alarm_description);
+ DBG("description[ %s ]", alarm->alarm_description);
}
+ index++;
- __cal_db_alarm_get_stmt(stmt,*out_record);
- sqlite3_finalize(stmt);
- stmt = NULL;
-
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_db_alarm_update_record(calendar_record_h record )
-{
- cal_db_util_error_e dbret = CAL_DB_OK;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- cal_alarm_s *alarm = NULL;
- sqlite3_stmt *stmt = NULL;
-
- alarm = (cal_alarm_s *)(record);
- retvm_if(NULL == alarm, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid argument: record is NULL");
-
- snprintf(query, sizeof(query),
- "UPDATE %s SET "
- "alarm_time = %lld, "
- "remind_tick = %d, "
- "remind_tick_unit = %d, "
- "alarm_tone = ?, "
- "alarm_description = ?, "
- "alarm_type = %d, "
- "alarm_id = %d "
- "WHERE event_id = %d ",
- CAL_TABLE_ALARM,
- alarm->alarm_time,
- alarm->remind_tick,
- alarm->remind_tick_unit,
- alarm->alarm_type,
- alarm->alarm_id,
- alarm->event_id);
-
- stmt = _cal_db_util_query_prepare(query);
- retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED,
- "_cal_db_util_query_prepare() Failed");
-
- if (alarm->alarm_tone)
- {
- _cal_db_util_stmt_bind_text(stmt, 1, alarm->alarm_tone);
+ if (alarm->alarm_summary) {
+ _cal_db_util_stmt_bind_text(stmt, index, alarm->alarm_summary);
+ DBG("summary [ %s ]", alarm->alarm_summary);
}
- if (alarm->alarm_description)
- {
- _cal_db_util_stmt_bind_text(stmt, 2, alarm->alarm_description);
+ index++;
+
+ if (alarm->alarm_attach)
+ _cal_db_util_stmt_bind_text(stmt, index, alarm->alarm_attach);
+ index++;
+
+ if (CALENDAR_TIME_LOCALTIME == alarm->alarm.type) {
+ char alarm_datetime[32] = {0};
+ snprintf(alarm_datetime, sizeof(alarm_datetime), CAL_FORMAT_LOCAL_DATETIME,
+ alarm->alarm.time.date.year,
+ alarm->alarm.time.date.month,
+ alarm->alarm.time.date.mday,
+ alarm->alarm.time.date.hour,
+ alarm->alarm.time.date.minute,
+ alarm->alarm.time.date.second);
+ _cal_db_util_stmt_bind_text(stmt, index, alarm_datetime);
+ DBG("datetime [ %s ]", alarm_datetime);
}
+ index++;
dbret = _cal_db_util_stmt_step(stmt);
sqlite3_finalize(stmt);
- if (CAL_DB_DONE != dbret)
- {
- ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_db_alarm_delete_record(int id)
-{
- cal_db_util_error_e dbret = CAL_DB_OK;
- char query[CAL_DB_SQL_MAX_LEN];
-
- snprintf(query, sizeof(query),
- "DELETE FROM %s "
- "WHERE event_id = %d ",
- CAL_TABLE_ALARM,
- id);
- dbret = _cal_db_util_query_exec(query);
- if (CAL_DB_OK != dbret)
- {
- ERR("_cal_db_util_query_exec() Failed(%d)", dbret);
- switch (dbret)
- {
+ if (CAL_DB_DONE != dbret) {
+ ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
+ switch (dbret) {
case CAL_DB_ERROR_NO_SPACE:
return CALENDAR_ERROR_FILE_NO_SPACE;
default:
return CALENDAR_ERROR_NONE;
}
-static int __cal_db_alarm_get_all_records(int offset, int limit, calendar_list_h* out_list )
-{
- int ret = CALENDAR_ERROR_NONE;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- char offsetquery[CAL_DB_SQL_MAX_LEN] = {0};
- char limitquery[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
-
- retvm_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- ret = calendar_list_create(out_list);
-
- retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- if (offset > 0)
- {
- snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
- }
- if (limit > 0)
- {
- snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
- }
- snprintf(query, sizeof(query), "SELECT * FROM %s %s %s", CAL_TABLE_ALARM,limitquery,offsetquery);
-
- stmt = _cal_db_util_query_prepare(query);
-
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() Failed");
- calendar_list_destroy(*out_list, true);
- *out_list = NULL;
- return CALENDAR_ERROR_DB_FAILED;
- }
-
- while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- calendar_record_h record = NULL;
- // stmt -> record
- ret = calendar_record_create(_calendar_alarm._uri,&record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
- *out_list = NULL;
- sqlite3_finalize(stmt);
- return ret;
- }
- __cal_db_alarm_get_stmt(stmt,record);
-
- ret = calendar_list_add(*out_list,record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
- *out_list = NULL;
- calendar_record_destroy(record, true);
- sqlite3_finalize(stmt);
- return ret;
- }
- }
- sqlite3_finalize(stmt);
-
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_db_alarm_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* out_list )
-{
- cal_query_s *que = NULL;
- int ret = CALENDAR_ERROR_NONE;
- char *condition = NULL;
- char *projection = NULL;
- char *order = NULL;
- GSList *bind_text = NULL, *cursor = NULL;
- char strquery[CAL_DB_SQL_MAX_LEN] = {0};
- int len;
- sqlite3_stmt *stmt = NULL;
- int i = 0;
- char *table_name;
-
- que = (cal_query_s *)query;
-
- if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_ALARM))
- {
- table_name = SAFE_STRDUP(CAL_TABLE_ALARM);
- }
- else
- {
- ERR("uri(%s) not support get records with query",que->view_uri);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- //table_name = SAFE_STRDUP(CAL_TABLE_NORMAL_INSTANCE);
- }
-
- // make filter
- if (que->filter)
- {
- ret = _cal_db_query_create_condition(query,
- &condition, &bind_text);
- if (ret != CALENDAR_ERROR_NONE)
- {
- CAL_FREE(table_name);
- ERR("filter create fail");
- return ret;
- }
- }
-
- // make projection
- ret = _cal_db_query_create_projection(query, &projection);
-
- // query - projection
- if (projection)
- {
- len = snprintf(strquery, sizeof(strquery), "SELECT %s FROM %s", projection, table_name);
- }
- else
- {
- len = snprintf(strquery, sizeof(strquery), "SELECT * FROM %s", table_name);
- }
- CAL_FREE(table_name);
-
- // query - condition
- if (condition)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " WHERE %s", condition);
- }
-
- // ORDER
- ret = _cal_db_query_create_order(query, &order);
- if (order)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " %s", order);
- }
-
- if (0 < limit)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " LIMIT %d", limit);
- if (0 < offset)
- len += snprintf(strquery+len, sizeof(strquery)-len, " OFFSET %d", offset);
- }
-
- // query
- stmt = _cal_db_util_query_prepare(strquery);
- if (NULL == stmt)
- {
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- CAL_DBG("%s",strquery);
-
- // bind text
- if (bind_text)
- {
- len = g_slist_length(bind_text);
- for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
- {
- _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
- }
- }
-
- //
- ret = calendar_list_create(out_list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- ERR("calendar_list_create() Failed");
- sqlite3_finalize(stmt);
- return ret;
- }
-
- while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- calendar_record_h record;
- // stmt -> record
- ret = calendar_record_create(_calendar_alarm._uri,&record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
- *out_list = NULL;
-
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
- return ret;
- }
- if (que->projection_count > 0)
- {
- _cal_record_set_projection(record,
- que->projection, que->projection_count, que->property_count);
-
- __cal_db_alarm_get_projection_stmt(stmt,
- que->projection, que->projection_count,
- record);
- }
- else
- {
- __cal_db_alarm_get_stmt(stmt,record);
- }
-
- ret = calendar_list_add(*out_list,record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
- *out_list = NULL;
- calendar_record_destroy(record, true);
-
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
- return ret;
- }
- }
-
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
-
- sqlite3_finalize(stmt);
-
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_db_alarm_insert_records(const calendar_list_h list, int** ids)
+int _cal_db_alarm_insert_records(cal_list_s *list_s, int event_id)
{
- calendar_record_h record;
- int ret = 0;
-
- ret = calendar_list_first(list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("list first error");
- return ret;
- }
- do
- {
- if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
- {
- if( __cal_db_alarm_insert_record(record, NULL) != CALENDAR_ERROR_NONE)
- {
- ERR("db insert error");
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
-
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_db_alarm_update_records(const calendar_list_h list)
-{
- calendar_record_h record;
- int ret = 0;
-
- ret = calendar_list_first(list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("list first error");
- return ret;
- }
- do
- {
- if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
- {
- if( __cal_db_alarm_update_record(record) != CALENDAR_ERROR_NONE)
- {
- ERR("db insert error");
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
-
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_db_alarm_delete_records(int ids[], int count)
-{
- int i=0;
- for(i=0;i<count;i++)
- {
- if (__cal_db_alarm_delete_record(ids[i]) != CALENDAR_ERROR_NONE)
- {
- ERR("delete failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_db_alarm_get_count(int *out_count)
-{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- int count = 0;
int ret;
+ int count = 0;
+ calendar_record_h record = NULL;
+ calendar_list_h list = (calendar_list_h)list_s;
+ retv_if(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER);
- retvm_if(NULL == out_count, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- snprintf(query, sizeof(query), "SELECT count(*) FROM %s ", CAL_TABLE_ALARM);
-
- ret = _cal_db_util_query_get_first_int_result(query, NULL, &count);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("_cal_db_util_query_get_first_int_result() failed");
- return ret;
- }
- CAL_DBG("%s=%d",query,count);
-
- *out_count = count;
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_db_alarm_get_count_with_query(calendar_query_h query, int *out_count)
-{
- cal_query_s *que = NULL;
- int ret = CALENDAR_ERROR_NONE;
- char *condition = NULL;
- char strquery[CAL_DB_SQL_MAX_LEN] = {0};
- int len;
- char *table_name;
- int count = 0;
- GSList *bind_text = NULL;
-
- que = (cal_query_s *)query;
-
- if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_ALARM))
- {
- table_name = SAFE_STRDUP(CAL_TABLE_ALARM);
- }
- else
- {
- ERR("uri(%s) not support get records with query",que->view_uri);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- // make filter
- if (que->filter)
- {
- ret = _cal_db_query_create_condition(query, &condition, &bind_text);
- if (ret != CALENDAR_ERROR_NONE)
- {
- CAL_FREE(table_name);
- ERR("filter create fail");
- return ret;
- }
- }
-
- // query - select from
-
- len = snprintf(strquery, sizeof(strquery), "SELECT count(*) FROM %s", table_name);
- CAL_FREE(table_name);
-
- // query - condition
- if (condition)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " WHERE %s", condition);
- }
+ calendar_list_get_count(list, &count);
+ if (0 == count)
+ return CALENDAR_ERROR_NONE;
- // query
- ret = _cal_db_util_query_get_first_int_result(strquery, bind_text, &count);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("_cal_db_util_query_get_first_int_result() failed");
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- return ret;
+ calendar_list_first(list);
+ while (CALENDAR_ERROR_NONE == calendar_list_get_current_record_p(list, &record)) {
+ ret = __cal_db_alarm_insert_record(record, event_id);
+ retvm_if(CALENDAR_ERROR_NONE != ret, ret, "_cal_db_extended_insert_record() Failed(%d)", ret);
+ calendar_list_next(list);
}
- CAL_DBG("%s=%d",strquery,count);
-
- *out_count = count;
-
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- return CALENDAR_ERROR_NONE;
-}
-
-////////////////////////////////////////////////////////////////////////////
-static void __cal_db_alarm_get_stmt(sqlite3_stmt *stmt,calendar_record_h record)
-{
- cal_alarm_s *alarm = NULL;
- int index;
- const unsigned char *temp;
-
- alarm = (cal_alarm_s*)(record);
-
- index = 0;
- alarm->event_id = sqlite3_column_int(stmt, index++);
- alarm->alarm_time = sqlite3_column_int64(stmt, index++);
- alarm->remind_tick = sqlite3_column_int(stmt, index++);
- alarm->remind_tick_unit = sqlite3_column_int(stmt, index++);
-
- temp = sqlite3_column_text(stmt, index++);
- alarm->alarm_tone = SAFE_STRDUP(temp);
-
- temp = sqlite3_column_text(stmt, index++);
- alarm->alarm_description = SAFE_STRDUP(temp);
-
- alarm->alarm_type = sqlite3_column_int(stmt, index++);
- alarm->alarm_id = sqlite3_column_int(stmt, index++);
-
-}
-
-static void __cal_db_alarm_get_property_stmt(sqlite3_stmt *stmt,
- unsigned int property, int *stmt_count, calendar_record_h record)
-{
- cal_alarm_s *alarm = NULL;
- const unsigned char *temp;
-
- alarm = (cal_alarm_s*)(record);
-
- switch(property)
- {
- case CAL_PROPERTY_ALARM_TYPE:
- alarm->alarm_type = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_ALARM_TIME:
- alarm->alarm_time = sqlite3_column_int64(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_ALARM_TICK:
- alarm->remind_tick = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_ALARM_TICK_UNIT:
- alarm->remind_tick_unit = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_ALARM_TONE:
- temp = sqlite3_column_text(stmt, *stmt_count);
- alarm->alarm_tone = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_ALARM_DESCRIPTION:
- temp = sqlite3_column_text(stmt, *stmt_count);
- alarm->alarm_description = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_ALARM_ID:
- alarm->alarm_id = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_ALARM_EVENT_TODO_ID:
- alarm->event_id = sqlite3_column_int(stmt, *stmt_count);
- break;
- default:
- sqlite3_column_int(stmt, *stmt_count);
- break;
- }
-
- *stmt_count = *stmt_count+1;
-}
-
-static void __cal_db_alarm_get_projection_stmt(sqlite3_stmt *stmt,
- const unsigned int *projection, const int projection_count,
- calendar_record_h record)
-{
- int i=0;
- int stmt_count = 0;
-
- for(i=0;i<projection_count;i++)
- {
- __cal_db_alarm_get_property_stmt(stmt,projection[i],&stmt_count,record);
- }
+ return CALENDAR_ERROR_NONE;
}
-int _cal_db_alarm_get_records(int event_id, GList **out_list)
+int _cal_db_alarm_get_records(int parent, cal_list_s *list)
{
int ret;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
- GList *list = NULL;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
- retvm_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid parameter: GList_h is NULL");
+ retvm_if(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Invalid parameter: list is NULL");
snprintf(query, sizeof(query),
- "SELECT * FROM %s "
- "WHERE event_id = %d ",
- CAL_TABLE_ALARM,
- event_id);
+ "SELECT rowid, "
+ "remind_tick,"
+ "remind_tick_unit, "
+ "alarm_description, "
+ "alarm_type, "
+ "alarm_summary, "
+ "alarm_action, "
+ "alarm_attach, "
+ "alarm_utime, "
+ "alarm_datetime "
+ "FROM %s WHERE event_id = %d ",
+ CAL_TABLE_ALARM, parent);
stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
+ retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "_cal_db_util_query_prepare() failed");
int index = 0;
const unsigned char *temp;
calendar_record_h record = NULL;
cal_alarm_s *alarm = NULL;
- while (CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
+ while (CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
ret = calendar_record_create(_calendar_alarm._uri, &record);
- if (CALENDAR_ERROR_NONE != ret)
- {
+ if (CALENDAR_ERROR_NONE != ret) {
sqlite3_finalize(stmt);
+ _cal_list_clear(list);
return ret;
}
index = 0;
alarm = (cal_alarm_s *)(record);
- alarm->event_id = sqlite3_column_int(stmt, index++);
- alarm->alarm_time = sqlite3_column_int64(stmt, index++);
+ alarm->parent_id = parent;
+ alarm->id = sqlite3_column_int(stmt, index++);
alarm->remind_tick = sqlite3_column_int(stmt, index++);
alarm->remind_tick_unit = sqlite3_column_int(stmt, index++);
temp = sqlite3_column_text(stmt, index++);
- alarm->alarm_tone = SAFE_STRDUP(temp);
-
- temp = sqlite3_column_text(stmt, index++);
alarm->alarm_description = SAFE_STRDUP(temp);
- alarm->alarm_type = sqlite3_column_int(stmt, index++);
- alarm->alarm_id = sqlite3_column_int(stmt, index++);
-
- list = g_list_append(list, record);
- }
-
- *out_list = list;
- sqlite3_finalize(stmt);
+ alarm->alarm.type = sqlite3_column_int(stmt, index++);
- return CALENDAR_ERROR_NONE;
-}
+ temp = sqlite3_column_text(stmt, index++);
+ alarm->alarm_summary= SAFE_STRDUP(temp);
-int _cal_db_alarm_convert_gtoh(GList *glist, int id, calendar_list_h *hlist)
-{
- int ret;
- GList *g = NULL;
- calendar_list_h h = NULL;
- calendar_record_h alarm = NULL;
+ alarm->alarm_action = sqlite3_column_int(stmt, index++);
- if (glist == NULL)
- {
- DBG("No alarm");
- return CALENDAR_ERROR_NO_DATA;
- }
- ret = calendar_list_create(&h);
+ temp = sqlite3_column_text(stmt, index++);
+ alarm->alarm_attach= SAFE_STRDUP(temp);
- g = g_list_first(glist);
- while (g)
- {
- alarm = (calendar_record_h)g->data;
- if (alarm)
- {
- CAL_DBG("%d",id);
- _cal_record_set_int(alarm,_calendar_alarm.event_id,id);
- ret = calendar_list_add(h, alarm);
+ if (alarm->alarm.type == CALENDAR_TIME_UTIME) {
+ alarm->alarm.time.utime = sqlite3_column_int64(stmt,index++);
+ index++; // datetime
}
- g = g_list_next(g);
+ else {
+ index++; // utime
+ temp = sqlite3_column_text(stmt, index++);
+ if (temp) {
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
+ switch (strlen((const char*)temp))
+ {
+ case 8:
+ sscanf((const char *)temp, "%04d%02d%02d", &y, &m, &d);
+ alarm->alarm.time.date.year = y;
+ alarm->alarm.time.date.month = m;
+ alarm->alarm.time.date.mday = d;
+ break;
+
+ case 15:
+ sscanf((const char *)temp, "%04d%02d%02dT%02d%02d%02d", &y, &m, &d, &h, &n, &s);
+ alarm->alarm.time.date.year = y;
+ alarm->alarm.time.date.month = m;
+ alarm->alarm.time.date.mday = d;
+ alarm->alarm.time.date.hour = h;
+ alarm->alarm.time.date.minute = n;
+ alarm->alarm.time.date.second = s;
+ break;
+ }
+ }
+ }
+ calendar_list_add((calendar_list_h)list, record);
}
-
- *hlist = h;
+ sqlite3_finalize(stmt);
return CALENDAR_ERROR_NONE;
}
-int _cal_db_alarm_delete_with_id(int event_id)
+int _cal_db_alarm_delete_with_id(int parent_id)
{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- cal_db_util_error_e dbret = CAL_DB_OK;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ cal_db_util_error_e dbret = CAL_DB_OK;
- snprintf(query, sizeof(query), "DELETE FROM %s WHERE event_id=%d ",
- CAL_TABLE_ALARM, event_id);
+ snprintf(query, sizeof(query), "DELETE FROM %s WHERE event_id=%d ",
+ CAL_TABLE_ALARM, parent_id);
- dbret = _cal_db_util_query_exec(query);
- if (CAL_DB_OK != dbret)
- {
- ERR("_cal_db_util_query_exec() failed (%d)", dbret);
- switch (dbret)
- {
+ dbret = _cal_db_util_query_exec(query);
+ if (CAL_DB_OK != dbret) {
+ ERR("_cal_db_util_query_exec() failed (%d)", dbret);
+ switch (dbret) {
case CAL_DB_ERROR_NO_SPACE:
return CALENDAR_ERROR_FILE_NO_SPACE;
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
-
- return CALENDAR_ERROR_NONE;
+ }
+ return CALENDAR_ERROR_NONE;
}
-int _cal_db_alarm_has_alarm(GList *list)
+int _cal_db_alarm_has_alarm(cal_list_s *list_s)
{
- calendar_record_h alarm = NULL;
- int unit = CALENDAR_ALARM_NONE;
- GList *g = NULL;
- int has_alarm = 0;
-
- if (list)
- {
- g = g_list_first(list);
-
- while (g)
- {
- alarm = (calendar_record_h)g->data;
- calendar_record_get_int(alarm, _calendar_alarm.tick_unit, &unit);
- if (CALENDAR_ALARM_NONE != unit)
- {
- has_alarm = 1;
- }
- g = g_list_next(g);
- }
-
- }
-
- return has_alarm;
+ calendar_record_h alarm = NULL;
+ int has_alarm = 0;
+ calendar_list_h list = (calendar_list_h)list_s;
+
+ calendar_list_first(list);
+ while (CALENDAR_ERROR_NONE == calendar_list_get_current_record_p(list, &alarm)) {
+ int unit;
+ calendar_record_get_int(alarm, _calendar_alarm.tick_unit, &unit);
+ if (CALENDAR_ALARM_NONE != unit) {
+ has_alarm = 1;
+ break;
+ }
+ calendar_list_next(list);
+ }
+ return has_alarm;
}
#ifndef __CALENDAR_SVC_DB_ALARM_H__
#define __CALENDAR_SVC_DB_ALARM_H__
-int _cal_db_alarm_get_records(int event_id, GList **out_list);
-int _cal_db_alarm_convert_gtoh(GList *glist, int id, calendar_list_h *hlist);
+int _cal_db_alarm_get_records(int event_id, cal_list_s *list);
int _cal_db_alarm_delete_with_id(int event_id);
+int _cal_db_alarm_insert_records(cal_list_s *list_s, int event_id);
+
/*
* @param[in] list The alarm list
*
* @return 0 on none alarm, 1 on alarm.
*/
-int _cal_db_alarm_has_alarm(GList *list);
+int _cal_db_alarm_has_alarm(cal_list_s *list_s);
#endif //__CALENDAR_SVC_DB_ALARM_H__
#include "cal_typedef.h"
#include "cal_view.h"
#include "cal_record.h"
+#include "cal_list.h"
#include "cal_db_util.h"
#include "cal_db_query.h"
#include "cal_db_attendee.h"
-static int __cal_db_attendee_insert_record(calendar_record_h record, int* id);
-static int __cal_db_attendee_get_record(int id, calendar_record_h* out_record);
-static int __cal_db_attendee_update_record(calendar_record_h record);
-static int __cal_db_attendee_delete_record(int id);
-static int __cal_db_attendee_get_all_records(int offset, int limit, calendar_list_h* out_list);
-static int __cal_db_attendee_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* out_list);
-static int __cal_db_attendee_insert_records(const calendar_list_h list, int** ids);
-static int __cal_db_attendee_update_records(const calendar_list_h list);
-static int __cal_db_attendee_delete_records(int ids[], int count);
-static int __cal_db_attendee_get_count(int *out_count);
-static int __cal_db_attendee_get_count_with_query(calendar_query_h query, int *out_count);
-/*
- * static function
- */
-static void __cal_db_attendee_get_stmt(sqlite3_stmt *stmt,calendar_record_h record);
-static void __cal_db_attendee_get_property_stmt(sqlite3_stmt *stmt,
- unsigned int property, int *stmt_count, calendar_record_h record);
-static void __cal_db_attendee_get_projection_stmt(sqlite3_stmt *stmt,
- const unsigned int *projection, const int projection_count,
- calendar_record_h record);
-
-cal_db_plugin_cb_s _cal_db_attendee_plugin_cb = {
- .is_query_only = false,
- .insert_record=__cal_db_attendee_insert_record,
- .get_record=__cal_db_attendee_get_record,
- .update_record=__cal_db_attendee_update_record,
- .delete_record=__cal_db_attendee_delete_record,
- .get_all_records=__cal_db_attendee_get_all_records,
- .get_records_with_query=__cal_db_attendee_get_records_with_query,
- .insert_records=__cal_db_attendee_insert_records,
- .update_records=__cal_db_attendee_update_records,
- .delete_records=__cal_db_attendee_delete_records,
- .get_count=__cal_db_attendee_get_count,
- .get_count_with_query=__cal_db_attendee_get_count_with_query,
- .replace_record=NULL,
- .replace_records=NULL
-};
-
-static int __cal_db_attendee_insert_record(calendar_record_h record, int* id)
+static int __cal_db_attendee_insert_record(calendar_record_h record, int parent_id)
{
int index;
- cal_db_util_error_e dbret = CAL_DB_OK;
+ cal_db_util_error_e dbret = CAL_DB_OK;
char query[CAL_DB_SQL_MAX_LEN];
sqlite3_stmt *stmt;
cal_attendee_s *attendee = NULL;
"INSERT INTO %s ("
"event_id, "
"attendee_name, attendee_email, attendee_number, "
- "attendee_status, attendee_type, attendee_ct_index, "
+ "attendee_status, attendee_cutype, attendee_ct_index, "
"attendee_role, attendee_rsvp, attendee_group, "
- "attendee_delegator_uri, attendee_delegate_uri, attendee_uid "
+ "attendee_delegator_uri, attendee_delegatee_uri, "
+ "attendee_member, attendee_uid "
") VALUES ( "
"%d, "
"?, ?, ?, "
"%d, %d, %d, "
"%d, %d, ?, "
- "?, ?, ? )",
+ "?, ?, "
+ "?, ? )",
CAL_TABLE_ATTENDEE,
- attendee->event_id,
+ parent_id,
attendee->attendee_status,
- attendee->attendee_type,
+ attendee->attendee_cutype,
attendee->attendee_ct_index,
attendee->attendee_role,
attendee->attendee_rsvp);
stmt = _cal_db_util_query_prepare(query);
- retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "_cal_db_util_query_prepare() Failed");
-
- index = 1;
- if (attendee->attendee_name)
- _cal_db_util_stmt_bind_text(stmt, index, attendee->attendee_name);
- index++;
-
- if (attendee->attendee_email)
- _cal_db_util_stmt_bind_text(stmt, index, attendee->attendee_email);
- index++;
-
- if (attendee->attendee_number)
- _cal_db_util_stmt_bind_text(stmt, index, attendee->attendee_number);
- index++;
-
- if (attendee->attendee_group)
- _cal_db_util_stmt_bind_text(stmt, index, attendee->attendee_group);
- index++;
-
- if (attendee->attendee_delegator_uri)
- _cal_db_util_stmt_bind_text(stmt, index, attendee->attendee_delegator_uri);
- index++;
-
- if (attendee->attendee_delegate_uri)
- _cal_db_util_stmt_bind_text(stmt, index, attendee->attendee_delegate_uri);
- index++;
-
- if (attendee->attendee_uid)
- _cal_db_util_stmt_bind_text(stmt, index, attendee->attendee_uid);
- index++;
-
- dbret = _cal_db_util_stmt_step(stmt);
- sqlite3_finalize(stmt);
-
- if (CAL_DB_DONE != dbret)
- {
- ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
-
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_db_attendee_get_record(int id, calendar_record_h* out_record)
-{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
- cal_db_util_error_e dbret = CAL_DB_OK;
- int ret = CALENDAR_ERROR_NONE;
-
- retvm_if(id < 0, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid argument: id(%d)", id);
-
- ret = calendar_record_create(_calendar_attendee._uri, out_record);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_record_create(%d)", ret);
- return CALENDAR_ERROR_DB_FAILED;
- }
-
- snprintf(query, sizeof(query),
- "SELECT * FROM %s "
- "WHERE event_id = %d ",
- CAL_TABLE_ATTENDEE,
- id);
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() Failed");
- calendar_record_destroy(*out_record, true);
- *out_record = NULL;
- return CALENDAR_ERROR_DB_FAILED;
- }
-
- dbret = _cal_db_util_stmt_step(stmt);
- if (CAL_DB_ROW != dbret)
+ if (NULL == stmt)
{
- ERR(" _cal_db_util_stmt_step() Failed(%d)", dbret);
- sqlite3_finalize(stmt);
- calendar_record_destroy(*out_record, true);
- *out_record = NULL;
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
+ DBG("_cal_db_util_query_prepare() Failed");
+ DBG("query[%s]", query);
+ return CALENDAR_ERROR_DB_FAILED;
}
- __cal_db_attendee_get_stmt(stmt,*out_record);
-
- sqlite3_finalize(stmt);
- stmt = NULL;
-
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_db_attendee_update_record(calendar_record_h record)
-{
- int index;
- cal_db_util_error_e dbret = CAL_DB_OK;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- cal_attendee_s *attendee = NULL;
- sqlite3_stmt *stmt = NULL;
-
- attendee = (cal_attendee_s *)(record);
- retvm_if(NULL == attendee, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid argument: record is NULL");
-
- snprintf(query, sizeof(query),
- "UPDATE %s SET "
- "attendee_name = ?, "
- "attendee_email = ?, "
- "attendee_number = ?, "
- "attendee_status = %d, "
- "attendee_type = %d, "
- "attendee_ct_index = %d, "
- "attendee_role = %d, "
- "attendee_rsvp = %d, "
- "attendee_group = ?, "
- "attendee_delegator_uri = ?, "
- "attendee_delegate_uri = ?, "
- "attendee_uid = ? ",
- CAL_TABLE_ATTENDEE,
- attendee->attendee_status,
- attendee->attendee_type,
- attendee->attendee_ct_index,
- attendee->attendee_role,
- attendee->attendee_rsvp);
-
- stmt = _cal_db_util_query_prepare(query);
- retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED,
- "_cal_db_util_query_prepare() Failed");
-
index = 1;
if (attendee->attendee_name)
_cal_db_util_stmt_bind_text(stmt, index, attendee->attendee_name);
_cal_db_util_stmt_bind_text(stmt, index, attendee->attendee_delegator_uri);
index++;
- if (attendee->attendee_delegate_uri)
- _cal_db_util_stmt_bind_text(stmt, index, attendee->attendee_delegate_uri);
+ if (attendee->attendee_delegatee_uri)
+ _cal_db_util_stmt_bind_text(stmt, index, attendee->attendee_delegatee_uri);
+ index++;
+
+ if (attendee->attendee_member)
+ _cal_db_util_stmt_bind_text(stmt, index, attendee->attendee_member);
index++;
if (attendee->attendee_uid)
dbret = _cal_db_util_stmt_step(stmt);
sqlite3_finalize(stmt);
+
if (CAL_DB_DONE != dbret)
{
ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
}
}
+ attendee->parent_id = parent_id;
return CALENDAR_ERROR_NONE;
}
-static int __cal_db_attendee_delete_record(int id)
-{
- cal_db_util_error_e dbret = CAL_DB_OK;
- char query[CAL_DB_SQL_MAX_LEN];
-
- snprintf(query, sizeof(query),
- "DELETE FROM %s "
- "WHERE event_id = %d ",
- CAL_TABLE_ATTENDEE,
- id);
-
- dbret = _cal_db_util_query_exec(query);
- if (CAL_DB_OK != dbret)
- {
- ERR("_cal_db_util_query_exec() Failed(%d)", dbret);
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
-
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_db_attendee_get_all_records(int offset, int limit, calendar_list_h* out_list)
+int _cal_db_attendee_insert_records(cal_list_s *list_s, int parent_id)
{
int ret;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- char offsetquery[CAL_DB_SQL_MAX_LEN] = {0};
- char limitquery[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
-
- retvm_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid parameter: calendar_list_h is NULL");
- ret = calendar_list_create(out_list);
- retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_DB_FAILED,
- "calendar_list_create() failed");
-
- if (limit > 0)
- {
- snprintf(limitquery, sizeof(limitquery), "LIMIT %d ", limit);
- }
- if (offset > 0)
- {
- snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d ", offset);
- }
- snprintf(query, sizeof(query),
- "SELECT * FROM %s %s %s ",
- CAL_TABLE_ATTENDEE, limitquery, offsetquery);
-
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() failed");
- calendar_list_destroy(*out_list, true);
- *out_list = NULL;
- return CALENDAR_ERROR_DB_FAILED;
- }
-
+ int count = 0;
calendar_record_h record = NULL;
+ calendar_list_h list = (calendar_list_h)list_s;
- while (CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- ret = calendar_record_create(_calendar_attendee._uri, &record);
- if (CALENDAR_ERROR_NONE != ret)
- {
- calendar_list_destroy(*out_list, true);
- *out_list = NULL;
- sqlite3_finalize(stmt);
- return ret;
- }
- //
- __cal_db_attendee_get_stmt(stmt,record);
-
- ret = calendar_list_add(*out_list, record);
- if (CALENDAR_ERROR_NONE != ret)
- {
- calendar_list_destroy(*out_list, true);
- *out_list = NULL;
- calendar_record_destroy(record, true);
- sqlite3_finalize(stmt);
- return ret;
- }
- }
- sqlite3_finalize(stmt);
-
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_db_attendee_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* out_list)
-{
- cal_query_s *que = NULL;
- int ret = CALENDAR_ERROR_NONE;
- char *condition = NULL;
- char *projection = NULL;
- char *order = NULL;
- GSList *bind_text = NULL, *cursor = NULL;
- char strquery[CAL_DB_SQL_MAX_LEN] = {0};
- int len;
- sqlite3_stmt *stmt = NULL;
- int i = 0;
- char *table_name;
-
- que = (cal_query_s *)query;
-
- if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_ATTENDEE))
- {
- table_name = SAFE_STRDUP(CAL_TABLE_ATTENDEE);
- }
- else
- {
- ERR("uri(%s) not support get records with query",que->view_uri);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- //table_name = SAFE_STRDUP(CAL_TABLE_NORMAL_INSTANCE);
- }
-
- // make filter
- if (que->filter)
- {
- ret = _cal_db_query_create_condition(query,
- &condition, &bind_text);
- if (ret != CALENDAR_ERROR_NONE)
- {
- CAL_FREE(table_name);
- ERR("filter create fail");
- return ret;
- }
- }
-
- // make projection
- ret = _cal_db_query_create_projection(query, &projection);
-
- // query - projection
- if (projection)
- {
- len = snprintf(strquery, sizeof(strquery), "SELECT %s FROM %s", projection, table_name);
- }
- else
- {
- len = snprintf(strquery, sizeof(strquery), "SELECT * FROM %s", table_name);
- }
- CAL_FREE(table_name);
-
- // query - condition
- if (condition)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " WHERE %s", condition);
- }
-
- // ORDER
- ret = _cal_db_query_create_order(query, &order);
- if (order)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " %s", order);
- }
-
- if (0 < limit)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " LIMIT %d", limit);
- if (0 < offset)
- len += snprintf(strquery+len, sizeof(strquery)-len, " OFFSET %d", offset);
- }
-
- // query
- stmt = _cal_db_util_query_prepare(strquery);
- if (NULL == stmt)
- {
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- CAL_DBG("%s",strquery);
-
- // bind text
- if (bind_text)
- {
- len = g_slist_length(bind_text);
- for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
- {
- _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
- }
- }
-
- //
- ret = calendar_list_create(out_list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- ERR("calendar_list_create() Failed");
- sqlite3_finalize(stmt);
- return ret;
- }
-
- while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- calendar_record_h record;
- // stmt -> record
- ret = calendar_record_create(_calendar_attendee._uri,&record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
- *out_list = NULL;
-
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
- return ret;
- }
- if (que->projection_count > 0)
- {
- _cal_record_set_projection(record,
- que->projection, que->projection_count, que->property_count);
-
- __cal_db_attendee_get_projection_stmt(stmt,
- que->projection, que->projection_count,
- record);
- }
- else
- {
- __cal_db_attendee_get_stmt(stmt,record);
- }
-
- ret = calendar_list_add(*out_list,record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
- *out_list = NULL;
- calendar_record_destroy(record, true);
-
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
- return ret;
- }
- }
-
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
-
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_db_attendee_insert_records(const calendar_list_h list, int** ids)
-{
- calendar_record_h record;
- int ret = 0;
-
- ret = calendar_list_first(list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("list first error");
- return ret;
- }
- do
- {
- if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
- {
- if( __cal_db_attendee_insert_record(record, NULL) != CALENDAR_ERROR_NONE)
- {
- ERR("db insert error");
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
-
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_db_attendee_update_records(const calendar_list_h list)
-{
- calendar_record_h record;
- int ret = 0;
-
- ret = calendar_list_first(list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("list first error");
- return ret;
- }
- do
- {
- if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
- {
- if( __cal_db_attendee_update_record(record) != CALENDAR_ERROR_NONE)
- {
- ERR("db insert error");
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
-
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_db_attendee_delete_records(int ids[], int count)
-{
- int i=0;
- for(i=0;i<count;i++)
- {
- if (__cal_db_attendee_delete_record(ids[i]) != CALENDAR_ERROR_NONE)
- {
- ERR("delete failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- return CALENDAR_ERROR_NONE;
-}
+ retv_if(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER);
-static int __cal_db_attendee_get_count(int *out_count)
-{
- int ret;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- int count = 0;
+ calendar_list_get_count(list, &count);
+ if (0 == count)
+ return CALENDAR_ERROR_NONE;
- retvm_if(NULL == out_count, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- snprintf(query, sizeof(query), "SELECT count(*) FROM %s ", CAL_TABLE_ATTENDEE);
-
- ret = _cal_db_util_query_get_first_int_result(query, NULL, &count);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("_cal_db_util_query_get_first_int_result() failed");
- return ret;
+ calendar_list_first(list);
+ while (CALENDAR_ERROR_NONE == calendar_list_get_current_record_p(list, &record)) {
+ ret = __cal_db_attendee_insert_record(record, parent_id);
+ retvm_if(CALENDAR_ERROR_NONE != ret, ret, "_cal_db_extended_insert_record() Failed(%d)", ret);
+ calendar_list_next(list);
}
- CAL_DBG("%s=%d",query,count);
-
- *out_count = count;
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_db_attendee_get_count_with_query(calendar_query_h query, int *out_count)
-{
- cal_query_s *que = NULL;
- int ret = CALENDAR_ERROR_NONE;
- char *condition = NULL;
- char strquery[CAL_DB_SQL_MAX_LEN] = {0};
- int len;
- char *table_name;
- int count = 0;
- GSList *bind_text = NULL;
-
- que = (cal_query_s *)query;
-
- if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_ATTENDEE))
- {
- table_name = SAFE_STRDUP(CAL_TABLE_ATTENDEE);
- }
- else
- {
- ERR("uri(%s) not support get records with query",que->view_uri);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- // make filter
- if (que->filter)
- {
- ret = _cal_db_query_create_condition(query, &condition, &bind_text);
- if (ret != CALENDAR_ERROR_NONE)
- {
- CAL_FREE(table_name);
- ERR("filter create fail");
- return ret;
- }
- }
-
- // query - select from
-
- len = snprintf(strquery, sizeof(strquery), "SELECT count(*) FROM %s", table_name);
-
- CAL_FREE(table_name);
-
- // query - condition
- if (condition)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " WHERE %s", condition);
- }
-
- // query
- ret = _cal_db_util_query_get_first_int_result(strquery, bind_text, &count);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("_cal_db_util_query_get_first_int_result() failed");
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- return ret;
- }
- CAL_DBG("%s=%d",strquery,count);
-
- *out_count = count;
+ return CALENDAR_ERROR_NONE;
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- return CALENDAR_ERROR_NONE;
}
-int _cal_db_attendee_get_records(int event_id, GList **out_list)
+int _cal_db_attendee_get_records(int parent_id, cal_list_s *list)
{
int ret;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
- GList *list = NULL;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
- retvm_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid parameter: GList is NULL");
+ retvm_if(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Invalid parameter: list is NULL");
snprintf(query, sizeof(query),
- "SELECT * FROM %s "
- "WHERE event_id = %d ",
- CAL_TABLE_ATTENDEE,
- event_id);
+ "SELECT rowid, "
+ "attendee_name, "
+ "attendee_email, "
+ "attendee_number, "
+ "attendee_status, "
+ "attendee_ct_index, "
+ "attendee_role, "
+ "attendee_rsvp, "
+ "attendee_group, "
+ "attendee_delegator_uri, "
+ "attendee_uid, "
+ "attendee_cutype, "
+ "attendee_delegatee_uri, "
+ "attendee_member "
+ "FROM %s WHERE event_id = %d ",
+ CAL_TABLE_ATTENDEE, parent_id);
stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
+ retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "_cal_db_util_query_prepare() failed");
int index;
const unsigned char *temp;
calendar_record_h record = NULL;
cal_attendee_s *attendee = NULL;
- while (CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
+ while (CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
ret = calendar_record_create(_calendar_attendee._uri, &record);
- if (CALENDAR_ERROR_NONE != ret)
- {
- sqlite3_finalize(stmt);
+ if (CALENDAR_ERROR_NONE != ret) {
+ sqlite3_finalize(stmt);
+ _cal_list_clear(list);
return ret;
}
index = 0;
attendee = (cal_attendee_s *)(record);
- attendee->event_id = sqlite3_column_int(stmt, index++);
+ attendee->parent_id = parent_id;
+ attendee->id = sqlite3_column_int(stmt, index++);
temp = sqlite3_column_text(stmt, index++);
attendee->attendee_name = SAFE_STRDUP(temp);
attendee->attendee_number = SAFE_STRDUP(temp);
attendee->attendee_status = sqlite3_column_int(stmt, index++);
- attendee->attendee_type = sqlite3_column_int(stmt, index++);
attendee->attendee_ct_index = sqlite3_column_int(stmt, index++);
attendee->attendee_role = sqlite3_column_int(stmt, index++);
attendee->attendee_rsvp = sqlite3_column_int(stmt, index++);
attendee->attendee_delegator_uri = SAFE_STRDUP(temp);
temp = sqlite3_column_text(stmt, index++);
- attendee->attendee_delegate_uri = SAFE_STRDUP(temp);
-
- temp = sqlite3_column_text(stmt, index++);
attendee->attendee_uid = SAFE_STRDUP(temp);
- list = g_list_append(list, record);
- }
+ attendee->attendee_cutype = sqlite3_column_int(stmt, index++);
- sqlite3_finalize(stmt);
- *out_list = list;
- return CALENDAR_ERROR_NONE;
-}
+ temp = sqlite3_column_text(stmt, index++);
+ attendee->attendee_delegatee_uri = SAFE_STRDUP(temp);
-int _cal_db_attendee_convert_gtoh(GList *glist, int id, calendar_list_h *hlist)
-{
- int ret;
- GList *g = NULL;
- calendar_list_h h = NULL;
- calendar_record_h attendee = NULL;
+ temp = sqlite3_column_text(stmt, index++);
+ attendee->attendee_member = SAFE_STRDUP(temp);
- if (glist == NULL)
- {
- DBG("No attendee");
- return CALENDAR_ERROR_NO_DATA;
+ calendar_list_add((calendar_list_h)list, record);
}
- ret = calendar_list_create(&h);
- g = g_list_first(glist);
- while (g)
- {
- attendee = (calendar_record_h)g->data;
- if (attendee)
- {
- ret = _cal_record_set_int(attendee,_calendar_attendee.event_id,id);
- ret = calendar_list_add(h, attendee);
-
- }
- g = g_list_next(g);
- }
-
- *hlist = h;
+ sqlite3_finalize(stmt);
return CALENDAR_ERROR_NONE;
}
-int _cal_db_attendee_delete_with_id(int event_id)
+int _cal_db_attendee_delete_with_id(int parent_id)
{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- cal_db_util_error_e dbret = CAL_DB_OK;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ cal_db_util_error_e dbret = CAL_DB_OK;
- snprintf(query, sizeof(query), "DELETE FROM %s WHERE event_id=%d ",
- CAL_TABLE_ATTENDEE, event_id);
+ snprintf(query, sizeof(query), "DELETE FROM %s WHERE event_id=%d ",
+ CAL_TABLE_ATTENDEE, parent_id);
- dbret = _cal_db_util_query_exec(query);
- if (dbret != CAL_DB_OK)
+ dbret = _cal_db_util_query_exec(query);
+ if (dbret != CAL_DB_OK)
{
- ERR("_cal_db_util_query_exec() failed (%d)", dbret);
+ ERR("_cal_db_util_query_exec() failed (%d)", dbret);
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
-
- return CALENDAR_ERROR_NONE;
-}
-
-static void __cal_db_attendee_get_stmt(sqlite3_stmt *stmt,calendar_record_h record)
-{
- cal_attendee_s *attendee = NULL;
- int index;
- const unsigned char *temp;
-
- attendee = (cal_attendee_s*)(record);
- index = 0;
-
- attendee->event_id = sqlite3_column_int(stmt, index++);
-
- temp = sqlite3_column_text(stmt, index++);
- attendee->attendee_name = SAFE_STRDUP(temp);
-
- temp = sqlite3_column_text(stmt, index++);
- attendee->attendee_email = SAFE_STRDUP(temp);
-
- temp = sqlite3_column_text(stmt, index++);
- attendee->attendee_number = SAFE_STRDUP(temp);
-
- attendee->attendee_status = sqlite3_column_int(stmt, index++);
- attendee->attendee_type = sqlite3_column_int(stmt, index++);
- attendee->attendee_ct_index = sqlite3_column_int(stmt, index++);
- attendee->attendee_role = sqlite3_column_int(stmt, index++);
- attendee->attendee_rsvp = sqlite3_column_int(stmt, index++);
-
- temp = sqlite3_column_text(stmt, index++);
- attendee->attendee_group = SAFE_STRDUP(temp);
-
- temp = sqlite3_column_text(stmt, index++);
- attendee->attendee_delegator_uri = SAFE_STRDUP(temp);
-
- temp = sqlite3_column_text(stmt, index++);
- attendee->attendee_delegate_uri = SAFE_STRDUP(temp);
-
- temp = sqlite3_column_text(stmt, index++);
- attendee->attendee_uid = SAFE_STRDUP(temp);
-}
-
-static void __cal_db_attendee_get_property_stmt(sqlite3_stmt *stmt,
- unsigned int property, int *stmt_count, calendar_record_h record)
-{
- cal_attendee_s *attendee = NULL;
- const unsigned char *temp;
-
- attendee = (cal_attendee_s*)(record);
-
- switch(property)
- {
- case CAL_PROPERTY_ATTENDEE_NUMBER:
- temp = sqlite3_column_text(stmt, *stmt_count);
- attendee->attendee_number = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_ATTENDEE_TYPE:
- attendee->attendee_type = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_ATTENDEE_CT_INDEX:
- attendee->attendee_ct_index = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_ATTENDEE_UID:
- temp = sqlite3_column_text(stmt, *stmt_count);
- attendee->attendee_uid = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_ATTENDEE_GROUP:
- temp = sqlite3_column_text(stmt, *stmt_count);
- attendee->attendee_group = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_ATTENDEE_EMAIL:
- temp = sqlite3_column_text(stmt, *stmt_count);
- attendee->attendee_email = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_ATTENDEE_ROLE:
- attendee->attendee_role = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_ATTENDEE_STATUS:
- attendee->attendee_status = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_ATTENDEE_RSVP:
- attendee->attendee_rsvp = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_ATTENDEE_DELEGATE_URI:
- temp = sqlite3_column_text(stmt, *stmt_count);
- attendee->attendee_delegate_uri = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_ATTENDEE_DELEGATOR_URI:
- temp = sqlite3_column_text(stmt, *stmt_count);
- attendee->attendee_delegator_uri = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_ATTENDEE_NAME:
- temp = sqlite3_column_text(stmt, *stmt_count);
- attendee->attendee_name = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_ATTENDEE_EVENT_ID:
- attendee->event_id = sqlite3_column_int(stmt, *stmt_count);
- break;
- default:
- sqlite3_column_int(stmt, *stmt_count);
- break;
- }
- *stmt_count = *stmt_count+1;
+ }
+ return CALENDAR_ERROR_NONE;
}
-static void __cal_db_attendee_get_projection_stmt(sqlite3_stmt *stmt,
- const unsigned int *projection, const int projection_count,
- calendar_record_h record)
-{
- int i=0;
- int stmt_count = 0;
-
- for(i=0;i<projection_count;i++)
- {
- __cal_db_attendee_get_property_stmt(stmt,projection[i],&stmt_count,record);
- }
-}
#include "cal_db.h"
-int _cal_db_attendee_get_records(int event_id, GList **out_list);
-int _cal_db_attendee_convert_gtoh(GList *glist, int id, calendar_list_h *hlist);
+int _cal_db_attendee_get_records(int event_id, cal_list_s *list);
int _cal_db_attendee_delete_with_id(int event_id);
+int _cal_db_attendee_insert_records(cal_list_s *list_s, int event_id);
#endif //__CALENDAR_SVC_DB_ATTENDEE_H__
--- /dev/null
+/*
+ * Calendar Service
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <stdlib.h>
+
+#include "calendar_db.h"
+#include "cal_internal.h"
+#include "cal_typedef.h"
+#include "cal_view.h"
+#include "cal_record.h"
+
+#include "cal_db.h"
+#include "cal_db_util.h"
+#include "cal_db_query.h"
+#include "cal_db_calendar.h"
+
+#ifdef CAL_IPC_SERVER
+int calendar_db_delete_account(int account_id)
+{
+ CAL_FN_CALL;
+ int ret = CALENDAR_ERROR_NONE;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+ GList *calendar_list = NULL;
+
+ snprintf(query, sizeof(query), "SELECT id FROM %s where account_id = %d and deleted = 0",
+ CAL_TABLE_CALENDAR, account_id);
+
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt)
+ {
+ ERR("_cal_db_util_query_prepare() Failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ {
+ int id = 0;
+ id = sqlite3_column_int(stmt, 0);
+ calendar_list = g_list_append(calendar_list, GINT_TO_POINTER(id));
+ }
+
+ sqlite3_finalize(stmt);
+ if(calendar_list)
+ CAL_DBG("calendar cnt=%d",g_list_length(calendar_list) );
+
+ ret = _cal_db_util_begin_trans();
+ if (CALENDAR_ERROR_NONE != ret)
+ {
+ g_list_free(calendar_list);
+ ERR("db failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ GList* cursor = calendar_list;
+ while(cursor)
+ {
+ int id = GPOINTER_TO_INT(cursor->data);
+
+ ret = calendar_db_delete_record(_calendar_book._uri, id);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("calendar_id(%d) delete fail~ ",id);
+ }
+ cursor = g_list_next(cursor);
+ }
+
+ g_list_free(calendar_list);
+ _cal_db_util_end_trans(true);
+ return CALENDAR_ERROR_NONE;
+}
+#endif
--- /dev/null
+/*
+ * Calendar Service
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#ifndef __CALENDAR_SVC_DB_CALENDAR_H__
+#define __CALENDAR_SVC_DB_CALENDAR_H__
+
+#ifdef CAL_IPC_SERVER
+int calendar_db_delete_account(int account_id);
+#endif
+
+#endif // __CALENDAR_SVC_DB_CALENDAR_H__
--- /dev/null
+/*
+ * Calendar Service
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdlib.h>
+
+#include "cal_internal.h"
+#include "cal_typedef.h"
+#include "cal_view.h"
+#include "cal_record.h"
+
+#include "cal_time.h"
+#include "cal_access_control.h"
+
+#include "cal_db.h"
+#include "cal_db_util.h"
+#include "cal_db_query.h"
+#include "cal_db_rrule.h"
+#include "cal_db_query.h"
+#include "cal_db_alarm.h"
+#include "cal_db_instance.h"
+#include "cal_db_attendee.h"
+#include "cal_db_extended.h"
+#include "cal_db_event.h"
+
+enum {
+ CAL_RECURRENCE_ID_RANGE_NONE,
+ CAL_RECURRENCE_ID_RANGE_THISANDFUTURE,
+ CAL_RECURRENCE_ID_RANGE_THISANDPRIOR,
+ CAL_RECURRENCE_ID_RANGE_MAX,
+};
+
+#define DEBUG_DATETIME(x) DBG("%04d-%02d-%02dT%02d:%02d:%02d",\
+ x->time.date.year,\
+ x->time.date.month,\
+ x->time.date.mday,\
+ x->time.date.hour,\
+ x->time.date.minute,\
+ x->time.date.second)
+
+int _cal_db_event_update_original_event_version(int original_event_id, int version)
+{
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ cal_db_util_error_e dbret = CAL_DB_OK;
+
+ DBG("original_event(%d) changed_ver updated", original_event_id);
+ if (original_event_id > 0) {
+ snprintf(query, sizeof(query), "UPDATE %s SET "
+ "changed_ver = %d, has_exception = 1 WHERE id = %d ",
+ CAL_TABLE_SCHEDULE, version, original_event_id);
+
+ dbret = _cal_db_util_query_exec(query);
+ if (CAL_DB_DONE != dbret) {
+ ERR("_cal_db_util_query_exec() Failed");
+ switch (dbret) {
+ case CAL_DB_ERROR_NO_SPACE:
+ return CALENDAR_ERROR_FILE_NO_SPACE;
+ default:
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int _cal_db_event_check_value_validation(cal_event_s *event)
+{
+ long long int slli = 0;
+ long long int elli = 0;
+
+ retv_if(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER);
+
+ if (event->start.type != event->end.type) {
+ ERR("start type(%d) is not same as end type(%d)", event->start.type, event->end.type);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ switch (event->start.type) {
+ case CALENDAR_TIME_UTIME:
+ if (event->start.time.utime > event->end.time.utime) {
+ ERR("normal start(%lld) > end(%lld)",
+ event->start.time.utime, event->end.time.utime);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ break;
+
+ case CALENDAR_TIME_LOCALTIME:
+ // check invalid value
+ if (event->start.time.date.month < 1 || event->start.time.date.month > 12) {
+ ERR("check start month(input:%d)", event->start.time.date.month);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ else if (event->start.time.date.mday < 1 || event->start.time.date.mday > 31) {
+ ERR("check start mday(input:%d)", event->start.time.date.mday);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ else if (event->end.time.date.month < 1 || event->end.time.date.month > 12) {
+ ERR("check end month(input:%d)", event->end.time.date.month);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ else if (event->end.time.date.mday < 1 || event->end.time.date.mday > 31) {
+ ERR("check end mday(input:%d)", event->end.time.date.mday);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ } else { // handle hour, minute, second
+ if (event->start.time.date.hour < 0 || event->start.time.date.hour > 24) event->start.time.date.hour = 0;
+ if (event->start.time.date.minute < 0 || event->start.time.date.minute > 60) event->start.time.date.minute = 0;
+ if (event->start.time.date.second < 0 || event->start.time.date.second > 60) event->start.time.date.second = 0;
+ if (event->end.time.date.hour < 0 || event->end.time.date.hour > 24) event->end.time.date.hour = 0;
+ if (event->end.time.date.minute < 0 || event->end.time.date.minute > 60) event->end.time.date.minute = 0;
+ if (event->end.time.date.second < 0 || event->end.time.date.second > 60) event->end.time.date.second = 0;
+ }
+
+ // check start > end; convert long long int.
+ slli = _cal_time_convert_itol(NULL,
+ event->start.time.date.year, event->start.time.date.month, event->start.time.date.mday,
+ event->start.time.date.hour, event->start.time.date.minute, event->start.time.date.second);
+ elli = _cal_time_convert_itol(NULL,
+ event->end.time.date.year, event->end.time.date.month, event->end.time.date.mday,
+ event->end.time.date.hour, event->end.time.date.minute, event->end.time.date.second);
+
+ if (slli - elli > 1) { // 1 is to ignore milliseconds
+ ERR("allday start(%lld) > end(%lld)", slli, elli);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+GList* _cal_db_event_get_list_with_uid(char *uid, int parent_id)
+{
+ retvm_if (NULL == uid || '\0' == *uid, NULL, "Invalid parameter: uid is NULL");
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+
+ snprintf(query, sizeof(query), "SELECT id FROM %s "
+ "WHERE original_event_id=-1 AND uid LIKE '%s' AND id!=%d",
+ CAL_TABLE_SCHEDULE, uid, parent_id);
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt) {
+ ERR("_cal_db_util_query_prepare() is failed");
+ return NULL;
+ }
+ GList *l = NULL;
+ while (CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
+ int id = sqlite3_column_int(stmt, 0);
+ l = g_list_append(l, GINT_TO_POINTER(id));
+ }
+ sqlite3_finalize(stmt);
+ return l;
+}
+
+void _cal_db_event_update_child_origina_event_id(int child_id, int parent_id)
+{
+ ENTER();
+
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ snprintf(query, sizeof(query), "UPDATE %s SET original_event_id=%d WHERE id=%d",
+ CAL_TABLE_SCHEDULE, parent_id, child_id);
+ cal_db_util_error_e dbret = CAL_DB_OK;
+ dbret = _cal_db_util_query_exec(query);
+ if (CAL_DB_DONE != dbret) {
+ ERR("_cal_db_util_query_exec() Failed(%d)", dbret);
+ }
+}
+
+char* _cal_db_event_get_recurrence_id_from_exception(int child_id)
+{
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+ snprintf(query, sizeof(query), "SELECT recurrence_id FROM %s WHERE id=%d",
+ CAL_TABLE_SCHEDULE, child_id);
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt) {
+ ERR("_cal_db_util_query_prepare() is failed");
+ }
+
+ char *recurrence_id = NULL;
+ if (CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
+ recurrence_id = SAFE_STRDUP(sqlite3_column_text(stmt, 0));
+ }
+ sqlite3_finalize(stmt);
+ return recurrence_id;
+}
+static void __get_tzid_and_range(char *p, char **out_tzid, int *out_range)
+{
+ retm_if (NULL == p || '\0' == *p, "Invalid parameter: p is NULL");
+ retm_if (NULL == out_tzid, "Invalid parameter: tzid is NULL");
+ retm_if (NULL == out_range, "Invalid parameter: range is NULL");
+
+ char **s = NULL;
+ s = g_strsplit(p, ";", -1);
+ retm_if (NULL == s, "g_strsplit() is failed");
+
+ int count = g_strv_length(s);
+ int i;
+ char *tzid = NULL;
+ int range = CAL_RECURRENCE_ID_RANGE_NONE;
+ for (i = 0; i < count; i++) {
+ if (NULL == s[i] || '\0' == *s[i]) continue;
+
+ if (!strncmp(s[i], "TZID=", strlen("TZID="))) {
+ tzid = strdup(s[i] + strlen("TZID="));
+ DBG("tzid [%s]", tzid);
+ } else if (!strncmp(s[i], "RANGE=", strlen("RANGE="))) {
+ char *param = s[i] + strlen("RANGE=");
+ if (!strncmp(param, "THISANDFUTURE", strlen("THISANDFUTURE")))
+ range = CAL_RECURRENCE_ID_RANGE_THISANDFUTURE;
+ else if (!strncmp(param, "THISANDPRIOR", strlen("THISANDPRIOR")))
+ range = CAL_RECURRENCE_ID_RANGE_THISANDPRIOR;
+ else
+ ERR("Invalid param[%s]", s[i]);
+ } else {
+ ERR("Invalid param[%s]", s[i]);
+ }
+ }
+ *out_tzid = tzid;
+ *out_range = range;
+ g_strfreev(s);
+}
+static void _cal_db_event_apply_recurrence_id_child(int child_id, cal_event_s *event, calendar_time_s until, bool is_prior)
+{
+ // update rrule
+ int ret = 0;
+ calendar_record_h record = NULL;
+ ret = _cal_db_get_record(_calendar_event._uri, child_id, &record);
+ retm_if (CALENDAR_ERROR_NONE != ret, "_cal_db_get_record() is failed(%d)", ret);
+
+ if (true == is_prior) {
+ _cal_record_set_caltime(record, _calendar_event.start_time, event->start);
+ _cal_record_set_caltime(record, _calendar_event.end_time, event->end);
+ switch (event->start.type)
+ {
+ case CALENDAR_TIME_UTIME:
+ DBG("dtstart(%lld) dtend(%lld)", event->start.time.utime, event->end.time.utime);
+ break;
+ case CALENDAR_TIME_LOCALTIME:
+ DBG("dtstart(%04d-%02d-%02dT%02d:%02d:%02d) dtend(%04d-%02d-%02dT%02d:%02d:%02d)",
+ event->start.time.date.year, event->start.time.date.month, event->start.time.date.mday,
+ event->start.time.date.hour, event->start.time.date.minute, event->start.time.date.second,
+ event->end.time.date.year, event->end.time.date.month, event->end.time.date.mday,
+ event->end.time.date.hour, event->end.time.date.minute, event->end.time.date.second);
+ break;
+ }
+ }
+
+ // rrule
+ _cal_record_set_int(record, _calendar_event.freq, event->freq);
+ _cal_record_set_int(record, _calendar_event.interval, event->interval);
+ _cal_record_set_int(record, _calendar_event.wkst, event->wkst);
+ if (event->byyearday && *event->byyearday)
+ _cal_record_set_str(record, _calendar_event.byyearday, event->byyearday);
+ if (event->byweekno && *event->byweekno)
+ _cal_record_set_str(record, _calendar_event.byweekno, event->byweekno);
+ if (event->bymonth && *event->bymonth)
+ _cal_record_set_str(record, _calendar_event.bymonth, event->bymonth);
+ if (event->bymonthday && *event->bymonthday)
+ _cal_record_set_str(record, _calendar_event.bymonthday, event->bymonthday);
+ if (event->byday && *event->byday)
+ _cal_record_set_str(record, _calendar_event.byday, event->byday);
+ if (event->bysetpos && *event->bysetpos)
+ _cal_record_set_str(record, _calendar_event.bysetpos, event->bysetpos);
+
+ // until
+ _cal_record_set_int(record, _calendar_event.range_type, CALENDAR_RANGE_UNTIL);
+ _cal_record_set_caltime(record, _calendar_event.until_time, until);
+
+ // reset
+ _cal_record_set_str(record, _calendar_event.uid, "");
+ _cal_record_set_int(record, _calendar_event.original_event_id, -1);
+
+
+ calendar_db_update_record(record);
+ calendar_record_destroy(record, true);
+}
+static void __get_next_instance_caltime(int parent_id, calendar_time_s *caltime, calendar_time_s *dtstart, calendar_time_s *dtend)
+{
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+
+ switch (caltime->type)
+ {
+ case CALENDAR_TIME_UTIME:
+ snprintf(query, sizeof(query), "SELECT dtstart_utime, dtend_utime FROM %s WHERE event_id=%d AND dtstart_utime>%lld "
+ "ORDER BY dtstart_utime ASC LIMIT 1",
+ CAL_TABLE_NORMAL_INSTANCE, parent_id, caltime->time.utime);
+ stmt = _cal_db_util_query_prepare(query);
+ retm_if (NULL == stmt, "_cal_db_util_query_prepare() is failed");
+
+ while (CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
+ dtstart->type = CALENDAR_TIME_UTIME;
+ dtstart->time.utime = sqlite3_column_int64(stmt, 0);
+ dtend->type = CALENDAR_TIME_UTIME;
+ dtend->time.utime = sqlite3_column_int64(stmt, 0);
+ break;
+ }
+ break;
+ case CALENDAR_TIME_LOCALTIME:
+ snprintf(query, sizeof(query), "SELECT dtstart_datetime, dtend_datetime FROM %s "
+ "WHERE event_id=%d AND dtstart_datetime>'%04d-%02d-%02dT%02d:%02d:%02d' "
+ "ORDER BY dtstart_datetime ASC LIMIT 1",
+ CAL_TABLE_ALLDAY_INSTANCE, parent_id,
+ caltime->time.date.year, caltime->time.date.month, caltime->time.date.mday,
+ caltime->time.date.hour, caltime->time.date.minute, caltime->time.date.second);
+ stmt = _cal_db_util_query_prepare(query);
+ retm_if (NULL == stmt, "_cal_db_util_query_prepare() is failed");
+
+ if (CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
+ char *temp = NULL;
+ dtstart->type = CALENDAR_TIME_LOCALTIME;
+ temp = sqlite3_column_text(stmt, 0);
+ if (temp && *temp) {
+ sscanf(temp, CAL_FORMAT_LOCAL_DATETIME,
+ &(dtstart->time.date.year), &(dtstart->time.date.month), &(dtstart->time.date.mday),
+ &(dtstart->time.date.hour), &(dtstart->time.date.minute), &(dtstart->time.date.second));
+ }
+ dtend->type = CALENDAR_TIME_LOCALTIME;
+ temp = sqlite3_column_text(stmt, 1);
+ if (temp && *temp) {
+ sscanf(temp, CAL_FORMAT_LOCAL_DATETIME,
+ &(dtend->time.date.year), &(dtend->time.date.month), &(dtend->time.date.mday),
+ &(dtend->time.date.hour), &(dtend->time.date.minute), &(dtend->time.date.second));
+ }
+ }
+ break;
+ }
+ sqlite3_finalize(stmt);
+}
+static void __get_last_instance_caltime(int parent_id, int type, calendar_time_s *dtstart)
+{
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+
+ switch (type)
+ {
+ case CALENDAR_TIME_UTIME:
+ snprintf(query, sizeof(query), "SELECT dtstart_utime FROM %s WHERE event_id=%d "
+ "ORDER BY dtstart_utime DESC LIMIT 1",
+ CAL_TABLE_NORMAL_INSTANCE, parent_id);
+ stmt = _cal_db_util_query_prepare(query);
+ retm_if (NULL == stmt, "_cal_db_util_query_prepare() is failed");
+ while (CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
+ dtstart->type = CALENDAR_TIME_UTIME;
+ dtstart->time.utime = sqlite3_column_int64(stmt, 0);
+ break;
+ }
+ break;
+ case CALENDAR_TIME_LOCALTIME:
+ snprintf(query, sizeof(query), "SELECT dtstart_datetime FROM %s WHERE event_id=%d "
+ "ORDER BY dtstart_datetime DESC LIMIT 1",
+ CAL_TABLE_ALLDAY_INSTANCE, parent_id);
+ stmt = _cal_db_util_query_prepare(query);
+ retm_if (NULL == stmt, "_cal_db_util_query_prepare() is failed");
+
+ if (CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
+ char *temp = NULL;
+ dtstart->type = CALENDAR_TIME_LOCALTIME;
+ temp = sqlite3_column_text(stmt, 0);
+ if (temp && *temp) {
+ sscanf(temp, CAL_FORMAT_LOCAL_DATETIME,
+ &(dtstart->time.date.year), &(dtstart->time.date.month), &(dtstart->time.date.mday),
+ &(dtstart->time.date.hour), &(dtstart->time.date.minute), &(dtstart->time.date.second));
+ } else {
+ ERR("datetime is NULL");
+ }
+ }
+ break;
+ }
+ sqlite3_finalize(stmt);
+}
+static void __del_recurence_id_instance(calendar_time_s *rectime, int parent_id)
+{
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ switch (rectime->type)
+ {
+ case CALENDAR_TIME_UTIME:
+ snprintf(query, sizeof(query), "DELETE FROM %s WHERE dtstart_utime=%lld AND event_id=%d",
+ CAL_TABLE_NORMAL_INSTANCE, rectime->time.utime, parent_id);
+ break;
+ case CALENDAR_TIME_LOCALTIME:
+ snprintf(query, sizeof(query), "DELETE FROM %s WHERE dtstart_datetime='%04d-%02d-%02dT%02d:%02d:%02d' AND event_id=%d",
+ CAL_TABLE_ALLDAY_INSTANCE, rectime->time.date.year, rectime->time.date.month, rectime->time.date.mday,
+ rectime->time.date.hour, rectime->time.date.minute, rectime->time.date.second, parent_id);
+ break;
+ }
+ cal_db_util_error_e dbret = CAL_DB_OK;
+ dbret = _cal_db_util_query_exec(query);
+ if (dbret != CAL_DB_OK) {
+ ERR("query[ %s ]", query);
+ ERR("_cal_db_util_query_exec() is failed(%d)", dbret);
+ }
+ // debug
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
+ switch (rectime->type)
+ {
+ case CALENDAR_TIME_UTIME:
+ _cal_time_get_datetime(rectime->time.utime, &y, &m, &d, &h, &n, &s);
+ DBG("[DELETED] %04d-%02d-%02dT%02d:%02d:%02d (utime)", y, m, d, h, n, s);
+ break;
+ case CALENDAR_TIME_LOCALTIME:
+ DBG("[DELETED] %04d-%02d-%02dT%02d:%02d:%02d (local)",
+ rectime->time.date.year, rectime->time.date.month, rectime->time.date.mday,
+ rectime->time.date.hour, rectime->time.date.minute, rectime->time.date.second);
+ break;
+ }
+}
+
+static void __set_original_event_id_in_child(int child_id, int parent_id)
+{
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ snprintf(query, sizeof(query), "UPDATE %s SET original_event_id=%d WHERE id=%d",
+ CAL_TABLE_SCHEDULE, parent_id, child_id);
+ cal_db_util_error_e dbret = CAL_DB_OK;
+ dbret = _cal_db_util_query_exec(query);
+ if (dbret != CAL_DB_OK) {
+ ERR("_cal_db_util_query_exec() is failed(%d)", dbret);
+ }
+}
+
+/*
+ * RECURRENCE-ID;VALUE=DATE:19960401
+ * RECURRENCE-ID;RANGE=THISANDFUTURE:19960120T120000Z
+ * RECURRENCE-ID;RANGE=THISANDPRIOR:19980401T133000Z
+ * RECURRENCE-ID;TZID=Asia/Seoul:20150106T090000
+ */
+void _cal_db_event_apply_recurrence_id(int parent_id, cal_event_s *event, char *recurrence_id, int child_id)
+{
+ ENTER();
+
+ retm_if (NULL == recurrence_id || '\0' == *recurrence_id, "Invalid parameter: recurrence_id is NULL");
+
+ char **t = NULL;
+ t = g_strsplit(recurrence_id, ":", -1);
+ retm_if (NULL == t, "g_strsplit() is failed");
+
+ if ('\0' == *t[0]) { // no param
+ g_strfreev(t);
+ return;
+ }
+ int count = g_strv_length(t);
+ int len_param = strlen(t[count -1]);
+ *(recurrence_id + strlen(recurrence_id) - len_param -1) = '\0';
+ g_strfreev(t);
+
+ char *datetime = recurrence_id + strlen(recurrence_id) +1;
+ int len_datetime = strlen(datetime);
+ DBG("datetime[%s]", datetime);
+
+ char *tzid = NULL;
+ int range = CAL_RECURRENCE_ID_RANGE_NONE;
+ __get_tzid_and_range(recurrence_id, &tzid, &range);
+
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
+ char dtstart_datetime[32] = {0};
+ long long int dtstart_utime = 0;
+ calendar_time_s rectime = {0};
+ switch (len_datetime)
+ {
+ case 8:
+ sscanf(datetime, "%04d%02d%02d", &y, &m, &d);
+ snprintf(dtstart_datetime, sizeof(dtstart_datetime), CAL_FORMAT_LOCAL_DATETIME, y, m, d, 0, 0, 0);
+ rectime.type = CALENDAR_TIME_LOCALTIME;
+ rectime.time.date.year = y;
+ rectime.time.date.month = m;
+ rectime.time.date.mday = d;
+ rectime.time.date.hour = 0;
+ rectime.time.date.minute = 0;
+ rectime.time.date.second = 0;
+ break;
+ case 15:
+ sscanf(datetime, "%04d%02d%02dT%02d%02d%02d", &y, &m, &d, &h, &n, &s);
+ if (tzid && *tzid) {
+ dtstart_utime = _cal_time_convert_itol(tzid, y, m, d, h, n, s);
+ rectime.type = CALENDAR_TIME_UTIME;
+ rectime.time.utime = dtstart_utime;
+ } else {
+ snprintf(dtstart_datetime, sizeof(dtstart_datetime), CAL_FORMAT_LOCAL_DATETIME, y, m, d, h, n, s);
+ rectime.type = CALENDAR_TIME_LOCALTIME;
+ rectime.time.date.year = y;
+ rectime.time.date.month = m;
+ rectime.time.date.mday = d;
+ rectime.time.date.hour = h;
+ rectime.time.date.minute = n;
+ rectime.time.date.second = s;
+ }
+ break;
+ case 16:
+ sscanf(datetime, "%04d%02d%02dT%02d%02d%02dZ", &y, &m, &d, &h, &n, &s);
+ dtstart_utime = _cal_time_convert_itol(tzid, y, m, d, h, n, s);
+ rectime.type = CALENDAR_TIME_UTIME;
+ rectime.time.utime = dtstart_utime;
+ break;
+ }
+ free(tzid);
+
+ calendar_time_s until = {0};
+ calendar_time_s dtstart = {0};
+ calendar_time_s dtend = {0};
+ calendar_record_h record = (calendar_record_h)event;
+ switch (range)
+ {
+ case CAL_RECURRENCE_ID_RANGE_THISANDFUTURE:
+ DBG("update child");
+ switch (event->range_type)
+ {
+ case CALENDAR_RANGE_UNTIL:
+ case CALENDAR_RANGE_NONE:
+ until = event->start;
+ break;
+ case CALENDAR_RANGE_COUNT:
+ __get_last_instance_caltime(parent_id, rectime.type, &until);
+ break;
+ }
+ _cal_db_event_apply_recurrence_id_child(child_id, event, until, false); //
+
+ DBG("update parent");
+ until = rectime;
+ _cal_time_modify_caltime(&until, -1);
+ _cal_record_set_int(record, _calendar_event.range_type, CALENDAR_RANGE_UNTIL);
+ _cal_record_set_caltime(record, _calendar_event.until_time, until);
+ _cal_record_set_str(record, _calendar_event.recurrence_id, "");
+ _cal_record_set_str(record, _calendar_event.uid, "");
+ calendar_db_update_record(record);
+ break;
+ case CAL_RECURRENCE_ID_RANGE_THISANDPRIOR:
+ DBG("update child");
+ until = rectime;
+ _cal_db_event_apply_recurrence_id_child(child_id, event, until, true);
+
+ DBG("update parent");
+ __get_next_instance_caltime(parent_id, &until, &dtstart, &dtend);
+ _cal_record_set_caltime(record, _calendar_event.start_time, dtstart);
+ _cal_record_set_caltime(record, _calendar_event.end_time, dtend);
+ switch (event->range_type)
+ {
+ case CALENDAR_RANGE_UNTIL:
+ case CALENDAR_RANGE_NONE:
+ break;
+ case CALENDAR_RANGE_COUNT:
+ __get_last_instance_caltime(parent_id, rectime.type, &until);
+ _cal_record_set_int(record, _calendar_event.range_type, CALENDAR_RANGE_UNTIL);
+ _cal_record_set_caltime(record, _calendar_event.until_time, until);
+ DBG(CAL_FORMAT_LOCAL_DATETIME,
+ until.time.date.year, until.time.date.month, until.time.date.mday,
+ until.time.date.hour, until.time.date.minute, until.time.date.second);
+ break;
+ }
+ _cal_record_set_str(record, _calendar_event.recurrence_id, "");
+ calendar_db_update_record(record);
+ break;
+ default:
+ __del_recurence_id_instance(&rectime, parent_id);
+ __set_original_event_id_in_child(child_id, parent_id);
+ break;
+ }
+}
+static int __get_parent_id_with_uid(char *uid, int child_id)
+{
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+ int parent_id = -1;
+ snprintf(query, sizeof(query), "SELECT id FROM %s WHERE original_event_id=-1 AND id!=%d AND uid='%s'",
+ CAL_TABLE_SCHEDULE, child_id, uid);
+ stmt = _cal_db_util_query_prepare(query);
+ retvm_if (NULL == stmt, -1, "_cal_db_util_query_prepare() is failed");
+ if (CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
+ parent_id = sqlite3_column_int64(stmt, 0);
+ }
+ sqlite3_finalize(stmt);
+ DBG("found parent_id(%d)", parent_id);
+ return parent_id;
+}
+
+int _cal_db_event_insert_record(calendar_record_h record, int original_event_id, int *id)
+{
+ int ret = -1;
+ int event_id = -1;
+ int index;
+ int input_ver;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ char dtstart_datetime[32] = {0};
+ char dtend_datetime[32] = {0};
+ sqlite3_stmt *stmt = NULL;
+ cal_event_s* event = (cal_event_s*)(record);
+ cal_rrule_s *rrule = NULL;
+ cal_db_util_error_e dbret = CAL_DB_OK;
+ int tmp = 0;
+ int calendar_book_id = 0;
+ calendar_record_h record_calendar = NULL;
+ int has_alarm = 0;
+ int timezone_id = 0;
+
+ retv_if(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER);
+
+ ret = _cal_db_event_check_value_validation(event);
+ retvm_if(CALENDAR_ERROR_NONE != ret, ret, "_cal_db_event_check_value_validation() failed");
+
+ // access control
+ if (_cal_access_control_have_write_permission(event->calendar_id) == false) {
+ ERR("_cal_access_control_have_write_permission() failed");
+ return CALENDAR_ERROR_PERMISSION_DENIED;
+ }
+
+ ret = calendar_record_get_int(record, _calendar_event.calendar_book_id, &calendar_book_id);
+ DBG("calendar_book_id(%d)", calendar_book_id);
+
+ ret = _cal_db_get_record(_calendar_book._uri, calendar_book_id, &record_calendar);
+ retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_INVALID_PARAMETER, "calendar_book_id is invalid");
+
+ calendar_record_destroy(record_calendar, true);
+
+ has_alarm = _cal_db_alarm_has_alarm(event->alarm_list);
+ _cal_time_get_timezone_from_table(event->start_tzid, NULL, &timezone_id);
+ input_ver = _cal_db_util_get_next_ver();
+ int is_allday = 0;
+ if (CALENDAR_TIME_LOCALTIME == event->start.type
+ && (0 == event->start.time.date.hour)
+ && (0 == event->start.time.date.minute)
+ && (0 == event->start.time.date.second)
+ && (0 == event->end.time.date.hour)
+ && (0 == event->end.time.date.minute)
+ && (0 == event->end.time.date.second)) {
+ is_allday = 1;
+ }
+
+ snprintf(query, sizeof(query), "INSERT INTO %s ( "
+ "type, "
+ "created_ver, changed_ver, "
+ "summary, description, location, categories, exdate, "
+ "task_status, priority, "
+ "timezone, "
+ "contact_id, busy_status, sensitivity, uid, "
+ "organizer_name, organizer_email, meeting_status, "
+ "calendar_id, "
+ "original_event_id, "
+ "latitude, longitude, "
+ "email_id, "
+ "created_time, completed_time, progress, "
+ "dtstart_type, dtstart_utime, dtstart_datetime, dtstart_tzid, "
+ "dtend_type, dtend_utime, dtend_datetime, dtend_tzid, "
+ "last_mod, rrule_id, "
+ "recurrence_id, rdate, has_attendee, "
+ "has_alarm, system_type, updated, "
+ "sync_data1, sync_data2, sync_data3, sync_data4,"
+ "has_exception, has_extended, freq, is_allday "
+ ") VALUES ( "
+ "%d, "
+ "%d, %d, "
+ "?, ?, ?, ?, ?, "
+ "%d, %d, "
+ "%d, "
+ "%d, %d, %d, ?, "
+ "?, ?, %d, "
+ "%d, "
+ "%d, "
+ "%lf, %lf, "
+ "%d, "
+ "strftime('%%s', 'now'), %lld, %d, "
+ "%d, %lld, ?, ?, "
+ "%d, %lld, ?, ?, "
+ "strftime('%%s', 'now'), %d, "
+ "?, ?, %d, %d, %d, %ld, "
+ "?, ?, ?, ?, "
+ "%d, %d, %d, %d) ",
+ CAL_TABLE_SCHEDULE,
+ CAL_SCH_TYPE_EVENT, /*event->cal_type,*/
+ input_ver, input_ver,
+ event->event_status, event->priority,
+ event->timezone ? event->timezone : timezone_id,
+ event->contact_id, event->busy_status, event->sensitivity,
+ event->meeting_status,
+ event->calendar_id,
+ original_event_id,
+ event->latitude, event->longitude,
+ event->email_id,
+ (long long int)0, 0, //event->completed_time, event->progress,
+ event->start.type, event->start.type == CALENDAR_TIME_UTIME ? event->start.time.utime : 0,
+ event->end.type, event->end.type == CALENDAR_TIME_UTIME ? event->end.time.utime : 0,
+ event->freq > 0 ? 1 : 0,
+ (0 < event->attendee_list->count) ? 1 : 0,
+ has_alarm,
+ event->system_type,
+ event->updated,
+ (0 < event->exception_list->count) ? 1 : 0,
+ (0 < event->extended_list->count) ? 1 : 0,
+ event->freq, is_allday);
+
+ stmt = _cal_db_util_query_prepare(query);
+ retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED,
+ "_cal_db_util_query_prepare() Failed");
+
+ index = 1;
+
+ if (event->summary)
+ _cal_db_util_stmt_bind_text(stmt, index, event->summary);
+ index++;
+
+ if (event->description)
+ _cal_db_util_stmt_bind_text(stmt, index, event->description);
+ index++;
+
+ if (event->location)
+ _cal_db_util_stmt_bind_text(stmt, index, event->location);
+ index++;
+
+ if (event->categories)
+ _cal_db_util_stmt_bind_text(stmt, index, event->categories);
+ index++;
+
+ if (event->exdate)
+ _cal_db_util_stmt_bind_text(stmt, index, event->exdate);
+ index++;
+
+ if (event->uid)
+ _cal_db_util_stmt_bind_text(stmt, index, event->uid);
+ index++;
+
+ if (event->organizer_name)
+ _cal_db_util_stmt_bind_text(stmt, index, event->organizer_name);
+ index++;
+
+ if (event->organizer_email)
+ _cal_db_util_stmt_bind_text(stmt, index, event->organizer_email);
+ index++;
+
+ if (CALENDAR_TIME_LOCALTIME == event->start.type) {
+ snprintf(dtstart_datetime, sizeof(dtstart_datetime), CAL_FORMAT_LOCAL_DATETIME,
+ event->start.time.date.year,
+ event->start.time.date.month,
+ event->start.time.date.mday,
+ event->start.time.date.hour,
+ event->start.time.date.minute,
+ event->start.time.date.second);
+ _cal_db_util_stmt_bind_text(stmt, index, dtstart_datetime);
+ }
+ index++;
+
+ if (event->start_tzid)
+ _cal_db_util_stmt_bind_text(stmt, index, event->start_tzid);
+ index++;
+
+ if (CALENDAR_TIME_LOCALTIME == event->end.type) {
+ snprintf(dtend_datetime, sizeof(dtend_datetime), CAL_FORMAT_LOCAL_DATETIME,
+ event->end.time.date.year,
+ event->end.time.date.month,
+ event->end.time.date.mday,
+ event->end.time.date.hour,
+ event->end.time.date.minute,
+ event->end.time.date.second);
+ _cal_db_util_stmt_bind_text(stmt, index, dtend_datetime);
+ }
+ index++;
+
+ if (event->end_tzid)
+ _cal_db_util_stmt_bind_text(stmt, index, event->end_tzid);
+ index++;
+
+ if (event->recurrence_id)
+ _cal_db_util_stmt_bind_text(stmt, index, event->recurrence_id);
+ index++;
+
+ if (event->rdate)
+ _cal_db_util_stmt_bind_text(stmt, index, event->rdate);
+ index++;
+
+ if (event->sync_data1)
+ _cal_db_util_stmt_bind_text(stmt, index, event->sync_data1);
+ index++;
+
+ if (event->sync_data2)
+ _cal_db_util_stmt_bind_text(stmt, index, event->sync_data2);
+ index++;
+
+ if (event->sync_data3)
+ _cal_db_util_stmt_bind_text(stmt, index, event->sync_data3);
+ index++;
+
+ if (event->sync_data4)
+ _cal_db_util_stmt_bind_text(stmt, index, event->sync_data4);
+ index++;
+
+ dbret = _cal_db_util_stmt_step(stmt);
+ if (CAL_DB_DONE != dbret) {
+ sqlite3_finalize(stmt);
+ ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
+ switch (dbret) {
+ case CAL_DB_ERROR_NO_SPACE:
+ return CALENDAR_ERROR_FILE_NO_SPACE;
+ default:
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ event_id = _cal_db_util_last_insert_id();
+ sqlite3_finalize(stmt);
+
+ // update parent event changed ver in case this event is exception mod
+ // which is original_event_id > 0
+ _cal_db_event_update_original_event_version(original_event_id, input_ver);
+
+ calendar_record_get_int(record, _calendar_event.id, &tmp);
+ _cal_record_set_int(record, _calendar_event.id, event_id);
+ if (id) {
+ *id = event_id;
+ }
+
+// _cal_db_rrule_set_default(record);
+ _cal_db_rrule_get_rrule_from_event(record, &rrule);
+ if (rrule) {
+ _cal_db_rrule_insert_record(event_id, rrule);
+ CAL_FREE(rrule);
+ }
+ if (original_event_id > 0) {
+ _cal_record_set_int(record, _calendar_event.original_event_id, original_event_id);
+ }
+ _cal_db_instance_publish_record(record);
+
+ while (event->uid && *event->uid) {
+ if (NULL == event->recurrence_id || '\0' == *event->recurrence_id) {
+ DBG("this is parent");
+ // parent exception event is inserted in case child exception existed already.
+ // find child exceptions and link(one exception) or devide(this and future/prior)
+
+ GList *list = NULL;
+ list = _cal_db_event_get_list_with_uid(event->uid, event_id);
+ if (NULL == list)
+ break;
+ GList *l = g_list_first(list);
+ if (l) {
+ int child_id = GPOINTER_TO_INT(l->data);
+ // update children original_event_id
+ _cal_db_event_update_child_origina_event_id(child_id, event_id);
+ char *recurrence_id = NULL;
+ recurrence_id = _cal_db_event_get_recurrence_id_from_exception(child_id);
+ if (NULL == recurrence_id || '\0' == *recurrence_id) {
+ if (recurrence_id) free(recurrence_id);
+ l = g_list_next(l);
+ continue;
+ }
+ // remove parent instance
+ _cal_db_event_apply_recurrence_id(event_id, event, recurrence_id, child_id);
+ free(recurrence_id);
+ l = g_list_next(l);
+ }
+ g_list_free(list);
+ } else {
+ DBG("this is child");
+ // get parent with uid and update original_event_id
+ int parent_id = 0;
+ parent_id = __get_parent_id_with_uid(event->uid, event_id);
+ if (parent_id < 0) {
+ ERR("__get_parent_id_with_uid() is failed");
+ break;
+ }
+ calendar_record_h parent = NULL;
+ calendar_db_get_record(_calendar_event._uri, parent_id, &parent);
+ _cal_db_event_apply_recurrence_id(parent_id, (cal_event_s *)parent, event->recurrence_id, event_id);
+ calendar_record_destroy(parent, true);
+ }
+ break;
+ }
+
+ if (event->alarm_list->count) {
+ DBG("insert alarm");
+ ret = _cal_db_alarm_insert_records(event->alarm_list, event_id);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_db_alarm_insert_records() Failed(%d)", ret);
+ }
+ else {
+ DBG("No alarm");
+ }
+
+ if (0 < event->attendee_list->count) {
+ DBG("insert attendee");
+ ret = _cal_db_attendee_insert_records(event->attendee_list, event_id);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_db_attendee_insert_records() Failed(%d)", ret);
+ }
+ else {
+ DBG("No attendee");
+ }
+
+ if (original_event_id <= 0 && 0 < event->exception_list->count) {
+ DBG("insert exception");
+ ret = _cal_db_event_insert_records(event->exception_list, event_id);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_db_event_insert_records() Failed(%d)", ret);
+ }
+ else {
+ DBG("No exception");
+ }
+
+ if (0 < event->extended_list->count) {
+ DBG("insert extended");
+ ret = _cal_db_extended_insert_records(event->extended_list, event_id, CALENDAR_RECORD_TYPE_EVENT);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_db_extended_insert_records() Failed(%d)", ret);
+ }
+ else {
+ DBG("No extended");
+ }
+
+ _cal_db_util_notify(CAL_NOTI_TYPE_EVENT);
+
+ _cal_record_set_int(record, _calendar_event.id, tmp);
+
+ return CALENDAR_ERROR_NONE;
+
+}
+
+int _cal_db_event_insert_records(cal_list_s *list_s, int original_event_id)
+{
+ int ret;
+ int count = 0;
+ calendar_record_h record = NULL;
+ calendar_list_h list = (calendar_list_h)list_s;
+
+ retv_if(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER);
+
+ calendar_list_get_count(list, &count);
+ if (0 == count)
+ return CALENDAR_ERROR_NONE;
+
+ calendar_list_first(list);
+ while (CALENDAR_ERROR_NONE == calendar_list_get_current_record_p(list, &record)) {
+ ret = _cal_db_event_insert_record(record, original_event_id, NULL);
+ retvm_if(CALENDAR_ERROR_NONE != ret, ret, "_cal_db_extended_insert_record() Failed(%d)", ret);
+ calendar_list_next(list);
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+
--- /dev/null
+/*
+ * Calendar Service
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __CALENDAR_SVC_DB_EVENT_H__
+#define __CALENDAR_SVC_DB_EVENT_H__
+
+int _cal_db_event_update_original_event_version(int original_event_id, int version);
+int _cal_db_event_check_value_validation(cal_event_s *event);
+int _cal_db_event_insert_record(calendar_record_h record, int original_event_id, int *id);
+int _cal_db_event_insert_records(cal_list_s *list_s, int original_event_id);
+GList *_cal_db_event_get_list_with_uid(char *uid, int parent_id);
+void _cal_db_event_update_child_origina_event_id(int child_id, int parent_id);
+char *_cal_db_event_get_recurrence_id_from_exception(int child_id);
+void _cal_db_event_apply_recurrence_id(int parent_id, cal_event_s *event, char *recurrence_id, int child_id);
+
+#endif // __CALENDAR_SVC_DB_EVENT_H__
#include "cal_typedef.h"
#include "cal_view.h"
#include "cal_record.h"
+#include "cal_list.h"
#include "cal_db.h"
#include "cal_db_util.h"
#include "cal_db_query.h"
#include "cal_db_extended.h"
-int _cal_db_extended_get_records(int record_id, calendar_record_type_e record_type, GList **out_list)
+int _cal_db_extended_get_records(int record_id, calendar_record_type_e record_type, cal_list_s *list)
{
- int ret;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
- GList *list = NULL;
-
- retvm_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid parameter: GList is NULL");
-
- snprintf(query, sizeof(query),
- "SELECT * FROM %s "
- "WHERE record_id = %d AND "
- "record_type = %d",
- CAL_TABLE_EXTENDED,
- record_id,
- record_type);
-
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
-
- int count = 0;
- const unsigned char *temp;
- calendar_record_h record = NULL;
- cal_extended_s *extended = NULL;
-
- while (CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- ret = calendar_record_create(_calendar_extended_property._uri, &record);
- if (CALENDAR_ERROR_NONE != ret)
- {
- sqlite3_finalize(stmt);
- return ret;
- }
-
- count = 0;
- extended = (cal_extended_s *)(record);
-
- extended->id = sqlite3_column_int(stmt, count++);
- extended->record_id = sqlite3_column_int(stmt, count++);
- extended->record_type = sqlite3_column_int(stmt, count++);
- temp = sqlite3_column_text(stmt, count++);
- extended->key = SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- extended->value = SAFE_STRDUP(temp);
-
- list = g_list_append(list, record);
- }
- sqlite3_finalize(stmt);
-
- *out_list = list;
- return CALENDAR_ERROR_NONE;
-}
+ int ret;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+
+ retvm_if(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: GList is NULL");
+
+ snprintf(query, sizeof(query),
+ "SELECT * FROM %s "
+ "WHERE record_id = %d AND "
+ "record_type = %d",
+ CAL_TABLE_EXTENDED,
+ record_id,
+ record_type);
+
+ stmt = _cal_db_util_query_prepare(query);
+ retvm_if(NULL == stmt,CALENDAR_ERROR_DB_FAILED, "_cal_db_util_query_prepare() failed");
+
+ int count = 0;
+ const unsigned char *temp;
+ calendar_record_h record = NULL;
+ cal_extended_s *extended = NULL;
+
+ while (CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
+ ret = calendar_record_create(_calendar_extended_property._uri, &record);
+ if (CALENDAR_ERROR_NONE != ret) {
+ sqlite3_finalize(stmt);
+ _cal_list_clear(list);
+ return ret;
+ }
-int _cal_db_extended_convert_gtoh(GList *glist, int record_id, calendar_record_type_e record_type, calendar_list_h *hlist)
-{
- int ret;
- GList *g = NULL;
- calendar_list_h h = NULL;
- calendar_record_h extended = NULL;
-
- if (glist == NULL)
- {
- DBG("No attendee");
- return CALENDAR_ERROR_NO_DATA;
- }
- ret = calendar_list_create(&h);
-
- g = g_list_first(glist);
- while (g)
- {
- extended = (calendar_record_h)g->data;
- if (extended)
- {
- ret = _cal_record_set_int(extended,_calendar_extended_property.record_id,record_id);
- ret = _cal_record_set_int(extended,_calendar_extended_property.record_type,record_type);
- ret = calendar_list_add(h, extended);
- }
- g = g_list_next(g);
- }
-
- *hlist = h;
- return CALENDAR_ERROR_NONE;
+ count = 0;
+ extended = (cal_extended_s *)(record);
+
+ extended->id = sqlite3_column_int(stmt, count++);
+ extended->record_id = sqlite3_column_int(stmt, count++);
+ extended->record_type = sqlite3_column_int(stmt, count++);
+ temp = sqlite3_column_text(stmt, count++);
+ extended->key = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ extended->value = SAFE_STRDUP(temp);
+
+ calendar_list_add((calendar_list_h)list, record);
+ }
+ sqlite3_finalize(stmt);
+ return CALENDAR_ERROR_NONE;
}
int _cal_db_extended_delete_with_id(int record_id, calendar_record_type_e record_type)
{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- cal_db_util_error_e dbret = CAL_DB_OK;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ cal_db_util_error_e dbret = CAL_DB_OK;
- snprintf(query, sizeof(query), "DELETE FROM %s WHERE record_id=%d AND record_type=%d",
- CAL_TABLE_EXTENDED, record_id, record_type);
+ snprintf(query, sizeof(query), "DELETE FROM %s WHERE record_id=%d AND record_type=%d",
+ CAL_TABLE_EXTENDED, record_id, record_type);
+
+ dbret = _cal_db_util_query_exec(query);
+ if (dbret != CAL_DB_OK) {
+ ERR("_cal_db_util_query_exec() failed (%d)", dbret);
+ switch (dbret)
+ {
+ case CAL_DB_ERROR_NO_SPACE:
+ return CALENDAR_ERROR_FILE_NO_SPACE;
+ default:
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ return CALENDAR_ERROR_NONE;
+}
- dbret = _cal_db_util_query_exec(query);
- if (dbret != CAL_DB_OK) {
- ERR("_cal_db_util_query_exec() failed (%d)", dbret);
+int _cal_db_extended_insert_record(calendar_record_h record, int record_id, calendar_record_type_e record_type, int *id)
+{
+ int index;
+ sqlite3_stmt *stmt;
+ char query[CAL_DB_SQL_MAX_LEN];
+ cal_extended_s* extended = (cal_extended_s*)(record);
+ cal_db_util_error_e dbret;
+
+ retv_if(NULL == extended, CALENDAR_ERROR_INVALID_PARAMETER);
+ retvm_if(record_id <= 0, CALENDAR_ERROR_INVALID_PARAMETER, "record_id(%d)", record_id);
+
+ snprintf(query, sizeof(query), "INSERT INTO %s(record_id, "
+ "record_type ,key ,value) "
+ "VALUES(%d,%d,?,?)",
+ CAL_TABLE_EXTENDED,
+ record_id,
+ record_type);
+
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt)
+ {
+ ERR("_cal_db_util_query_prepare() Failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ if (extended->key)
+ _cal_db_util_stmt_bind_text(stmt, 1, extended->key);
+
+ if (extended->value)
+ _cal_db_util_stmt_bind_text(stmt, 2, extended->value);
+
+ dbret = _cal_db_util_stmt_step(stmt);
+ if (CAL_DB_DONE != dbret)
+ {
+ sqlite3_finalize(stmt);
+ ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
+ }
+ index = _cal_db_util_last_insert_id();
+ sqlite3_finalize(stmt);
+
+ //_cal_record_set_int(record, _calendar_extended.id,index);
+ if (id) {
+ *id = index;
+ }
+
+ if (record_type == CALENDAR_RECORD_TYPE_EVENT || record_type == CALENDAR_RECORD_TYPE_TODO)
+ {
+ snprintf(query, sizeof(query), "UPDATE %s SET "
+ "has_extended = 1 "
+ "WHERE id = %d;",
+ CAL_TABLE_SCHEDULE,
+ record_id);
+ dbret = _cal_db_util_query_exec(query);
+ if(CAL_DB_OK != dbret)
+ {
+ ERR("_cal_db_util_query_exec() Failed(%d)", dbret);
+ switch (dbret)
+ {
+ case CAL_DB_ERROR_NO_SPACE:
+ return CALENDAR_ERROR_FILE_NO_SPACE;
+ default:
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ }
+ return CALENDAR_ERROR_NONE;
+}
- return CALENDAR_ERROR_NONE;
+int _cal_db_extended_insert_records(cal_list_s *list_s, int record_id, calendar_record_type_e record_type)
+{
+ int ret;
+ int count = 0;
+ calendar_record_h record = NULL;
+ calendar_list_h list = (calendar_list_h)list_s;
+
+ retv_if(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER);
+
+ calendar_list_get_count(list, &count);
+ if (0 == count)
+ return CALENDAR_ERROR_NONE;
+
+ calendar_list_first(list);
+ while (CALENDAR_ERROR_NONE == calendar_list_get_current_record_p(list, &record)) {
+ ret = _cal_db_extended_insert_record(record, record_id, record_type, NULL);
+ retvm_if(CALENDAR_ERROR_NONE != ret, ret, "_cal_db_extended_insert_record() Failed(%d)", ret);
+ calendar_list_next(list);
+ }
+ return CALENDAR_ERROR_NONE;
}
+
#ifndef __CALENDAR_SVC_DB_EXTENDED_H__
#define __CALENDAR_SVC_DB_EXTENDED_H__
-int _cal_db_extended_get_records(int record_id, calendar_record_type_e record_type, GList **out_list);
-int _cal_db_extended_convert_gtoh(GList *glist, int record_id, calendar_record_type_e record_type, calendar_list_h *hlist);
+int _cal_db_extended_get_records(int record_id, calendar_record_type_e record_type, cal_list_s *list);
int _cal_db_extended_delete_with_id(int record_id, calendar_record_type_e record_type);
+int _cal_db_extended_insert_record(calendar_record_h record, int record_id, calendar_record_type_e record_type, int *id);
+int _cal_db_extended_insert_records(cal_list_s *list_s, int record_id, calendar_record_type_e record_type);
#endif //__CALENDAR_SVC_DB_EXTENDED_H__
#include <sys/types.h>
#include "calendar_db.h"
-#include "calendar_types2.h"
+#include "calendar_types.h"
#include "cal_internal.h"
#include "cal_typedef.h"
#include "cal_db_util.h"
#include "cal_db.h"
+#include "cal_db_instance_helper.h"
#define ms2sec(ms) (long long int)(ms / 1000.0)
#define sec2ms(s) (s * 1000.0)
+#define lli2p(x) ((gpointer)((time_t)x))
+
+#define COLOR_RED "\033[0;31m"
+#define COLOR_GREEN "\033[0;32m"
+#define COLOR_END "\033[0;m"
/* input order
- UCAL_MONTH + UCAL_DAY_OF_MONTH
- UCAL_MONTH + UCAL_WEEK_OF_MONTH + UCAL_DAY_OF_WEEK
- UCAL_MONTH + UCAL_DAY_OF_WEEK_IN_MONTH + UCAL_DAY_OF_WEEK
- UCAL_DAY_OF_YEAR
- UCAL_DAY_OF_WEEK + UCAL_WEEK_OF_YEAR
-*/
+ * UCAL_MONTH + UCAL_DAY_OF_MONTH
+ * UCAL_MONTH + UCAL_WEEK_OF_MONTH + UCAL_DAY_OF_WEEK
+ * UCAL_MONTH + UCAL_DAY_OF_WEEK_IN_MONTH + UCAL_DAY_OF_WEEK
+ * UCAL_DAY_OF_YEAR
+ * UCAL_DAY_OF_WEEK + UCAL_WEEK_OF_YEAR
+ */
struct day {
int uday;
const char *str;
};
-#define CAL_ENDLESS_LIMIT_YEAR 2038
+#define CAL_LUNAR_CALENDAR_BASE_YEAR 2637
+#define CAL_ENDLESS_LIMIT_YEAR 2036
#define CAL_ENDLESS_LIMIT_MONTH 12
#define CAL_ENDLESS_LIMIT_MDAY 31
+#define CAL_ENDLESS_LIMIT_UTIME 2114380800 // 2037/01/01 00:00:00 GMT
+#define CAL_ENDLESS_LIMIT_FULL_DAY (365 * 50)
-static struct day wdays[] = {
- [CALENDAR_SUNDAY] = {UCAL_SUNDAY, "SU"},
- [CALENDAR_MONDAY] = {UCAL_MONDAY, "MO"},
- [CALENDAR_TUESDAY] = {UCAL_TUESDAY, "TU"},
- [CALENDAR_WEDNESDAY] = {UCAL_WEDNESDAY, "WE"},
- [CALENDAR_THURSDAY] = {UCAL_THURSDAY, "TH"},
- [CALENDAR_FRIDAY] = {UCAL_FRIDAY, "FR"},
- [CALENDAR_SATURDAY] = {UCAL_SATURDAY, "SA"},
-};
-
-static void __cal_db_instance_print_ucal(UCalendar *ucal)
+static void __print_ucal(int calendar_system_type, UCalendar *ucal, const char *tzid, int wkst)
{
- long long int lli;
UErrorCode ec = U_ZERO_ERROR;
+ if (NULL == ucal) return;
- if (ucal)
+ UCalendar *s_ucal = NULL;
+
+ switch (calendar_system_type)
{
- lli = ms2sec(ucal_getMillis(ucal, &ec));
- DBG("(%d)", lli);
+ case CALENDAR_SYSTEM_EAST_ASIAN_LUNISOLAR:
+ s_ucal = _cal_time_get_ucal(tzid, wkst);
+ ucal_setMillis(s_ucal, ucal_getMillis(ucal, &ec), &ec);
+ break;
+
+ default: // CALENDAR_SYSTEM_NONE: CALENDAR_SYSTEM_GREGORIAN:
+ s_ucal = ucal;
+ break;
+ }
+ DBG(COLOR_GREEN"[INSERTED] instance %04d-%02d-%02d %02d:%02d:%02d"COLOR_END,
+ ucal_get(s_ucal, UCAL_YEAR, &ec),
+ ucal_get(s_ucal, UCAL_MONTH, &ec) + 1,
+ ucal_get(s_ucal, UCAL_DATE, &ec),
+ ucal_get(s_ucal, UCAL_HOUR_OF_DAY, &ec),
+ ucal_get(s_ucal, UCAL_MINUTE, &ec),
+ ucal_get(s_ucal, UCAL_SECOND, &ec));
+
+ if (CALENDAR_SYSTEM_EAST_ASIAN_LUNISOLAR == calendar_system_type) {
+ ucal_close(s_ucal);
}
}
-static int __cal_db_instance_work_normal_setpos(int event_id, long long int lli_s, long long int lli_e, char **t)
+static void __get_allday_date(cal_event_s *event, UCalendar *ucal, int *y, int *m, int *d, int *h, int *n, int *s)
{
- int i, j;
- int ret;
- int count = 0;
- int ids[366] = {0};
- char str_option[CAL_DB_SQL_MAX_LEN] = {0};
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- char str_fraction[64] = {0};
- cal_db_util_error_e dbret = CAL_DB_OK;
+ UErrorCode ec = U_ZERO_ERROR;
+ if (NULL == ucal) return;
- j = -1;
- for (i = 0; t[i];i++)
- {
- snprintf(query, sizeof(query), "SELECT rowid FROM %s "
- "WHERE event_id = %d "
- "AND dtstart_utime >= %lld AND dtend_utime < %lld "
- "ORDER BY dtstart_utime "
- "LIMIT %d, 1 ",
- CAL_TABLE_NORMAL_INSTANCE,
- event_id,
- lli_s, lli_e,
- atoi(t[i]) - 1);
- ret = _cal_db_util_query_get_first_int_result(query, NULL, &count);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("_cal_db_util_query_get_first_int_result() failed");
- return ret;
- }
- if (count <= 0)
- {
- DBG("%s", query);
- DBG("no result");
- continue;
- }
- else
- {
- j++;
- ids[j] = count;
- DBG("append result");
- }
- DBG("[%lld] ~ [%lld] setpos id(%d)", lli_s, lli_e, ids[j]);
- }
+ UCalendar *s_ucal = NULL;
- while (j >= 0)
+ switch (event->system_type)
{
- snprintf(str_fraction, sizeof(str_fraction), "AND rowid != %d ", ids[j]);
- DBG("fra:%s", str_fraction);
- strcat(str_option, str_fraction);
- DBG("opt:%s", str_option);
- j--;
+ case CALENDAR_SYSTEM_EAST_ASIAN_LUNISOLAR:
+ s_ucal = _cal_time_get_ucal(event->start_tzid, event->wkst);
+ ucal_setMillis(s_ucal, ucal_getMillis(ucal, &ec), &ec);
+ break;
+
+ default:
+ s_ucal = ucal;
+ break;
}
- DBG("str_option[%s]", str_option);
- snprintf(query, sizeof(query), "DELETE FROM %s "
- "WHERE event_id = %d "
- "AND dtstart_utime>= %lld AND dtend_utime < %lld "
- "%s",
- CAL_TABLE_NORMAL_INSTANCE,
- event_id,
- lli_s, lli_e,
- str_option);
- dbret = _cal_db_util_query_exec(query);
- if (CAL_DB_OK != dbret)
- {
- DBG("query[%s]", query);
- ERR("_cal_db_util_query_exec() Failed(%d)", dbret);
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
+ if (y)
+ *y = ucal_get(s_ucal, UCAL_YEAR, &ec);
+ if (m)
+ *m = ucal_get(s_ucal, UCAL_MONTH, &ec) + 1;
+ if (d)
+ *d = ucal_get(s_ucal, UCAL_DATE, &ec);
+ if (h)
+ *h = ucal_get(s_ucal, UCAL_HOUR_OF_DAY, &ec);
+ if (n)
+ *n = ucal_get(s_ucal, UCAL_MINUTE, &ec);
+ if (s)
+ *s = ucal_get(s_ucal, UCAL_SECOND, &ec);
+
+ if (CALENDAR_SYSTEM_EAST_ASIAN_LUNISOLAR == event->system_type) {
+ ucal_close(s_ucal);
}
-
- return CALENDAR_ERROR_NONE;
}
-static int __cal_db_instance_work_allday_setpos(int event_id, char *str_s, char *str_e, char **t)
+static int __cal_db_instance_parse_byint(char *byint, int *by, int *len)
{
- int i, j;
- int ret;
- cal_db_util_error_e dbret = CAL_DB_OK;
- int count = 0;
- int ids[366] = {0};
- char str_option[CAL_DB_SQL_MAX_LEN] = {0};
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- char str_fraction[64] = {0};
+ if (NULL == byint || '\0' == *byint)
+ return CALENDAR_ERROR_NONE;
- j = -1;
- for (i = 0; t[i];i++)
- {
- snprintf(query, sizeof(query), "SELECT rowid FROM %s "
- "WHERE event_id = %d "
- "AND dtstart_datetime >= %s AND dtend_datetime < %s "
- "ORDER BY dtstart_datetime "
- "LIMIT %d, 1 ",
- CAL_TABLE_ALLDAY_INSTANCE,
- event_id,
- str_s, str_e,
- atoi(t[i]) - 1);
- ret = _cal_db_util_query_get_first_int_result(query, NULL, &count);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("_cal_db_util_query_get_first_int_result() failed");
- return ret;
- }
- if (count <= 0)
- {
- DBG("%s", query);
- DBG("no result");
- continue;
- }
- else
- {
- j++;
- ids[j] = count;
- DBG("append result");
- }
- DBG("[%s] ~ [%s] setpos id(%d)", str_s, str_e, ids[j]);
- }
+ char **t = NULL;
+ t = g_strsplit_set(byint, " ,", -1);
+ retvm_if(NULL == t, CALENDAR_ERROR_OUT_OF_MEMORY, "g_strsplit_set() is failed");
- while (j >= 0)
- {
- snprintf(str_fraction, sizeof(str_fraction), "AND rowid != %d ", ids[j]);
- DBG("fra:%s", str_fraction);
- strcat(str_option, str_fraction);
- DBG("opt:%s", str_option);
- j--;
- }
- DBG("str_option[%s]", str_option);
- snprintf(query, sizeof(query), "DELETE FROM %s "
- "WHERE event_id = %d "
- "AND dtstart_datetime >= %s AND dtend_datetime < %s "
- "%s",
- CAL_TABLE_ALLDAY_INSTANCE,
- event_id,
- str_s, str_e,
- str_option);
- dbret = _cal_db_util_query_exec(query);
- if (CAL_DB_OK != dbret)
+ int length = g_strv_length(t);
+ int i;
+ int index = 0;
+ for (i = 0 ; i < length; i++)
{
- DBG("query[%s]", query);
- ERR("_cal_db_util_query_exec() Failed(%d)", dbret);
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
+ if (NULL == t[i] || 0 == strlen(t[i])) continue;
+ by[index] = atoi(t[i]);
+ index++;
}
-
+ g_strfreev(t);
+ if (len) *len = index;
return CALENDAR_ERROR_NONE;
}
-static int __cal_db_instance_apply_setpos(int event_id, calendar_time_s *st, cal_event_s *event, int freq)
+static int __cal_db_instance_parse_bystr(char *bystr, char **by, int *len)
{
- int ret;
- int count;
- int index;
- int y, m, d;
- int y1, m1, d1;
- long long int lli_s = 0, lli_e = 0;
- char **t;
- const char *dl = ",";
- char str_t[32] = {0};
- char str_s[32] = {0};
- char str_e[32] = {0};
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- UCalendar *ucal;
- UErrorCode ec = U_ZERO_ERROR;
+ retvm_if (NULL == bystr || '\0' == *bystr, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: byint is NULL");
- t = g_strsplit(event->bysetpos, dl, -1);
- if (!t)
- {
- ERR("g_strsplit failed");
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
+ char **t = NULL;
+ t = g_strsplit_set(bystr, " ,", -1);
+ retvm_if(NULL == t, CALENDAR_ERROR_OUT_OF_MEMORY, "g_strsplit_set() is failed");
- switch (st->type)
+ int length = g_strv_length(t);
+ int i;
+ int index = 0;
+ for (i = 0 ; i < length; i++)
{
- case CALENDAR_TIME_UTIME:
- DBG("(%lld)", st->time.utime);
- snprintf(query, sizeof(query), "SELECT count(*) FROM %s "
- "WHERE event_id = %d "
- "AND dtstart_utime >= %lld",
- CAL_TABLE_NORMAL_INSTANCE,
- event_id,
- st->time.utime);
- ret = _cal_db_util_query_get_first_int_result(query, NULL, &count);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("_cal_db_util_query_get_first_int_result() failed");
- g_strfreev(t);
- return ret;
- }
- DBG("count(%d)", count);
- index = 0;
-
- while (count > 0)
- {
- ucal = _cal_time_get_ucal(event->start_tzid, event->wkst);
- ucal_setMillis(ucal, sec2ms(st->time.utime), &ec);
- switch (freq)
- {
- case CALENDAR_RECURRENCE_YEARLY:
- ucal_add(ucal, UCAL_YEAR, index, &ec);
- ucal_set(ucal, UCAL_MONTH, 1);
- ucal_set(ucal, UCAL_DATE, 1);
- lli_s = ms2sec(ucal_getMillis(ucal, &ec));
-
- ucal_add(ucal, UCAL_YEAR, 1, &ec);
- lli_e = ms2sec(ucal_getMillis(ucal, &ec));
- break;
-
- case CALENDAR_RECURRENCE_MONTHLY:
- ucal_add(ucal, UCAL_MONTH, index, &ec);
- ucal_set(ucal, UCAL_DATE, 1);
- lli_s = ms2sec(ucal_getMillis(ucal, &ec));
-
- ucal_add(ucal, UCAL_MONTH, 1, &ec);
- lli_e = ms2sec(ucal_getMillis(ucal, &ec));
- break;
-
- case CALENDAR_RECURRENCE_WEEKLY:
- ucal_add(ucal, UCAL_DATE, (7 * index), &ec);
- ucal_set(ucal, UCAL_DAY_OF_WEEK, 1);
- lli_s = ms2sec(ucal_getMillis(ucal, &ec));
+ if (NULL == t[i] || 0 == strlen(t[i])) continue;
+ by[index] = strdup(t[i]);
+ index++;
+ }
+ g_strfreev(t);
+ if (len) *len = index;
+ return CALENDAR_ERROR_NONE;
+}
- ucal_add(ucal, UCAL_DATE, 7, &ec);
- lli_e = ms2sec(ucal_getMillis(ucal, &ec));
- break;
+static void __set_time_to_ucal(int calendar_system_type, UCalendar *ucal, calendar_time_s *t)
+{
+ retm_if(NULL == ucal, "Invalid parameter: ucal is NULL");
+ retm_if(NULL == t, "Invalid parameter: calendar_time_s is NULL");
- default:
- break;
- }
- ucal_close(ucal);
+ UErrorCode ec = U_ZERO_ERROR;
- DBG("%lld %lld", lli_s, lli_e);
- __cal_db_instance_work_normal_setpos(event_id, lli_s, lli_e, t);
- snprintf(query, sizeof(query), "SELECT count(*) FROM %s "
- "WHERE event_id = %d "
- "AND dtstart_utime >= %lld",
- CAL_TABLE_NORMAL_INSTANCE,
- event_id,
- lli_e);
- ret = _cal_db_util_query_get_first_int_result(query, NULL, &count);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("_cal_db_util_query_get_first_int_result() failed");
- g_strfreev(t);
- return ret;
- }
- DBG("setpos left count(%d) from [%lld]", count, lli_e);
- index++;
- }
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
+ struct tm tm = {0};
+ time_t tt = 0;
+ switch (t->type)
+ {
+ case CALENDAR_TIME_UTIME:
+ ucal_setMillis(ucal, sec2ms(t->time.utime), &ec);
break;
case CALENDAR_TIME_LOCALTIME:
- y = st->time.date.year;
- m = st->time.date.month;
- d = st->time.date.mday;
- DBG("%d/%d/%d", y, m, d);
- snprintf(str_t, sizeof(str_t), "%04d%02d%02d", y, m, d);
- snprintf(query, sizeof(query), "SELECT count(*) FROM %s "
- "WHERE event_id = %d "
- "AND dtstart_datetime >= %s",
- CAL_TABLE_ALLDAY_INSTANCE,
- event_id,
- str_t);
- ret = _cal_db_util_query_get_first_int_result(query, NULL, &count);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("_cal_db_util_query_get_first_int_result() failed");
- g_strfreev(t);
- return ret;
- }
- DBG("count(%d)", count);
- index = 0;
-
- while (count > 0)
+ switch (calendar_system_type)
{
- // _cal_db_instance_get_next_period(event, str_s, str_e, index);
- switch (freq)
- {
- case CALENDAR_RECURRENCE_YEARLY:
- snprintf(str_s, sizeof(str_s), "%04d%02d%02d", y + index, 1, 1);
- snprintf(str_e, sizeof(str_e), "%04d%02d%02d", y + index + 1, 1, 1);
- break;
-
- case CALENDAR_RECURRENCE_MONTHLY:
- snprintf(str_s, sizeof(str_s), "%04d%02d%02d",
- y + ((m + index) / 13),
- (m + index) % 13 == 0 ? 1 : (m + index) % 13,
- 1);
- snprintf(str_e, sizeof(str_e), "%04d%02d%02d",
- y + ((m + index + 1) / 13),
- (m + index + 1) % 13 == 0 ? 1 : (m + index + 1) % 13,
- 1);
- break;
-
- case CALENDAR_RECURRENCE_WEEKLY:
- ucal = _cal_time_get_ucal(event->start_tzid, event->wkst);
- ucal_setDate(ucal, y, m - 1, d + (7 * index), &ec);
- y1 = ucal_get(ucal, UCAL_YEAR, &ec);
- m1 = ucal_get(ucal, UCAL_MONTH, &ec) + 1;
- d1 = ucal_get(ucal, UCAL_DATE, &ec);
- DBG("start(%d/%d/%d", y1, m1, d1);
- ucal_set(ucal, UCAL_DAY_OF_WEEK, 1);
- y1 = ucal_get(ucal, UCAL_YEAR, &ec);
- m1 = ucal_get(ucal, UCAL_MONTH, &ec) + 1;
- d1 = ucal_get(ucal, UCAL_DATE, &ec);
- snprintf(str_s, sizeof(str_s), "%04d%02d%02d",
- y1, m1, d1);
- DBG("start(%d/%d/%d", y1, m1, d1);
-
- ucal_add(ucal, UCAL_DATE, 7, &ec);
- y1 = ucal_get(ucal, UCAL_YEAR, &ec);
- m1 = ucal_get(ucal, UCAL_MONTH, &ec) + 1;
- d1 = ucal_get(ucal, UCAL_DATE, &ec);
- snprintf(str_e, sizeof(str_e), "%04d%02d%02d",
- y1, m1, d1);
- DBG("end(%d/%d/%d", y1, m1, d1);
- ucal_close(ucal);
- break;
-
- case CALENDAR_RECURRENCE_DAILY:
- DBG("Not support setpos in daily");
- break;
-
- default:
- break;
- }
-
- __cal_db_instance_work_allday_setpos(event_id, str_s, str_e, t);
+ case CALENDAR_SYSTEM_EAST_ASIAN_LUNISOLAR:
+ tm.tm_year = t->time.date.year - 1900;
+ tm.tm_mon = t->time.date.month -1;
+ tm.tm_mday = t->time.date.mday;
+ tm.tm_hour = t->time.date.hour;
+ tm.tm_min = t->time.date.minute;
+ tm.tm_sec = t->time.date.second;
+ ucal_setMillis(ucal, sec2ms(timegm(&tm)), &ec);
+
+ y = ucal_get(ucal, UCAL_EXTENDED_YEAR, &ec) - CAL_LUNAR_CALENDAR_BASE_YEAR;
+ m = ucal_get(ucal, UCAL_MONTH, &ec) + 1;
+ d = ucal_get(ucal, UCAL_DATE, &ec);
+ h = ucal_get(ucal, UCAL_HOUR_OF_DAY, &ec);
+ n = ucal_get(ucal, UCAL_MINUTE, &ec);
+ s = ucal_get(ucal, UCAL_SECOND, &ec);
+ ucal_setDateTime(ucal, y, m - 1, d, h, n, s, &ec);
+ ucal_set(ucal, UCAL_EXTENDED_YEAR, y + CAL_LUNAR_CALENDAR_BASE_YEAR);
+ break;
- snprintf(query, sizeof(query), "SELECT count(*) FROM %s "
- "WHERE event_id = %d "
- "AND dtstart_datetime >= %s",
- CAL_TABLE_ALLDAY_INSTANCE,
- event_id,
- str_e);
-// DBG("%s", query);
- ret = _cal_db_util_query_get_first_int_result(query, NULL, &count);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("_cal_db_util_query_get_first_int_result() failed");
- g_strfreev(t);
- return ret;
- }
- DBG("setpos left count(%d) from [%s]", count, str_e);
- index++;
+ default:
+ ucal_setDateTime(ucal, t->time.date.year,
+ t->time.date.month -1,
+ t->time.date.mday,
+ t->time.date.hour,
+ t->time.date.minute,
+ t->time.date.second, &ec);
+ break;
}
break;
-
- default:
- break;
}
- g_strfreev(t);
- return CALENDAR_ERROR_NONE;
}
-static int __cal_db_instance_update_exdate_del(int id, char *exdate)
+static int __get_exdate_list(UCalendar *ucal, cal_event_s *event, GList **l, int *count)
{
- int dbret;
- int i, j;
- int y, mon, d, h, min, s;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- const char *dl = ",";
- char **t = NULL;
- char *p = NULL;
+ retvm_if (NULL == ucal, CALENDAR_ERROR_INVALID_PARAMETER, "ucal is NULL");
+ retvm_if (NULL == event, CALENDAR_ERROR_INVALID_PARAMETER, "event is NULL");
- if (exdate == NULL)
- {
- DBG("Nothing to update exdate del");
+ if (event->exdate == NULL || '\0' == *(event->exdate)) {
return CALENDAR_ERROR_NONE;
}
- DBG("exdate [%s]", exdate);
- t = g_strsplit(exdate, dl, -1);
- if (!t)
- {
- ERR("g_strsplit failed");
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
+ char **t = NULL;
+ t = g_strsplit_set(event->exdate, " ,", -1);
+ retvm_if (NULL == t, CALENDAR_ERROR_OUT_OF_MEMORY, "g_strsplit_set() is failed");;
- for (i = 0; t[i]; i++)
- {
- p = t[i];
- // remove space
- j = 0;
- while (p[j] == ' ')
- {
- j++;
- }
- p = t[i] + j;
- DBG("exdate[%s]", p);
+ DBG("[%s]", event->exdate);
+ int len = 0;
+ len = g_strv_length(t);
+ DBG("exdate len (%d)", len);
- if (strlen(p) > strlen("YYYYMMDD"))
- {
- DBG("NORMAL instance");
- sscanf(p, "%04d%02d%02dT%02d%02d%02dZ",
- &y, &mon, &d, &h, &min, &s);
- snprintf(query, sizeof(query),
- "DELETE FROM %s "
- "WHERE event_id = %d AND dtstart_utime = %lld ",
- CAL_TABLE_NORMAL_INSTANCE,
- id, _cal_time_convert_itol(NULL, y, mon, d, h, min, s));
- DBG("(%lld)", _cal_time_convert_itol(NULL, y, mon, d, h, min, s));
+ int i;
+ for (i = 0; i < len; i++) {
+ char *p = t[i];
+ if (NULL == p) {
+ continue;
}
- else
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
+ long long int lli = 0;
+ UCalendar *ucal2 = NULL;
+ UErrorCode ec = U_ZERO_ERROR;
+ switch (strlen(p))
{
+ case 8:
DBG("ALLDAY instance");
- snprintf(query, sizeof(query),
- "DELETE FROM %s "
- "WHERE event_id = %d AND dtstart_datetime = %s ",
- CAL_TABLE_ALLDAY_INSTANCE,
- id, p);
+ sscanf(p, "%04d%02d%02d", &y, &m, &d);
+ ucal2 = ucal_clone(ucal, &ec);
+ ucal_setDateTime(ucal2, y, m - 1, d, 0, 0, 0, &ec);
+ lli = ms2sec(ucal_getMillis(ucal2, &ec));
+ ucal_close(ucal2);
+ break;
+
+ case 15:
+ DBG("ALLDAY instance");
+ sscanf(p, "%04d%02d%02dT%02d%02d%02d", &y, &m, &d, &h, &n, &s);
+
+ ucal2 = ucal_clone(ucal, &ec);
+ ucal_setDateTime(ucal2, y, m - 1, d, h, n, s, &ec);
+ lli = ms2sec(ucal_getMillis(ucal2, &ec));
+ ucal_close(ucal2);
+ break;
+
+ case 16:
+ DBG("NORMAL instance");
+ sscanf(p, "%04d%02d%02dT%02d%02d%02dZ", &y, &m, &d, &h, &n, &s);
+ lli = _cal_time_convert_itol(NULL, y, m, d, h, n, s);
+ break;
}
- dbret = _cal_db_util_query_exec(query);
- if (dbret != CAL_DB_OK) {
- ERR("_cal_db_util_query_exec() failed (%d)", dbret);
- g_strfreev(t);
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
+ DBG("%lld", lli);
+ *l = g_list_append(*l, lli2p(lli));
}
+ if (count) *count = len;
+ DBG("exdate len(%d)", len);
g_strfreev(t);
+
return CALENDAR_ERROR_NONE;
}
{
int dbret;
int i, j;
- int y, mon, d, h, min, s;
- const char *dl = ",";
char **t = NULL;
char *p = NULL;
char query[CAL_DB_SQL_MAX_LEN] = {0};
}
DBG("recurrence_id[%s]", recurrence_id);
- t = g_strsplit(recurrence_id, dl, -1);
- if (!t)
- {
- ERR("g_strsplit failed");
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
+ t = g_strsplit_set(recurrence_id, " ,", -1);
+ retvm_if (NULL == t, CALENDAR_ERROR_OUT_OF_MEMORY, "g_strsplit_set() is failed");;
for (i = 0; t[i]; i++)
{
p = t[i];
// remove space
j = 0;
- while (p[j] == ' ')
- {
- j++;
- }
+ while (p[j] == ' ') j++;
+
p = t[i] + j;
DBG("%d[%s]", i + 1, p);
- if (strlen(p) > strlen("YYYYMMDD"))
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
+ char buf[32] = {0};
+ switch (strlen(p))
{
+ case 8:
+ DBG("ALLDAY instance");
+ sscanf(p, "%04d%02d%02d", &y, &m, &d);
+ snprintf(buf, sizeof(buf), "%04d-%02d-%02dT%02d:%02d:%02d", y, m, d, 0, 0, 0);
+ snprintf(query, sizeof(query),
+ "DELETE FROM %s "
+ "WHERE event_id = %d AND dtstart_datetime = '%s' ",
+ CAL_TABLE_ALLDAY_INSTANCE,
+ original_event_id, buf);
+ break;
+
+ case 15:
+ DBG("ALLDAY instance");
+ sscanf(p, "%04d%02d%02dT%02d%02d%02d", &y, &m, &d, &h, &n, &s);
+ snprintf(buf, sizeof(buf), "%04d-%02d-%02dT%02d:%02d:%02d", y, m, d, h, n, s);
+ snprintf(query, sizeof(query),
+ "DELETE FROM %s "
+ "WHERE event_id = %d AND dtstart_datetime = '%s' ",
+ CAL_TABLE_ALLDAY_INSTANCE,
+ original_event_id, buf);
+ break;
+
+ case 16:
DBG("NORMAL instance");
sscanf(p, "%04d%02d%02dT%02d%02d%02dZ",
- &y, &mon, &d, &h, &min, &s);
+ &y, &m, &d, &h, &n, &s);
snprintf(query, sizeof(query),
"DELETE FROM %s "
"WHERE event_id = %d AND dtstart_utime = %lld ",
CAL_TABLE_NORMAL_INSTANCE,
- original_event_id, _cal_time_convert_itol(NULL, y, mon, d, h, min, s));
- DBG("(%lld)", _cal_time_convert_itol(NULL, y, mon, d, h, min, s));
+ original_event_id, _cal_time_convert_itol(NULL, y, m, d, h, n, s));
+ DBG("(%lld)", _cal_time_convert_itol(NULL, y, m, d, h, n, s));
+ break;
}
- else
- {
- DBG("ALLDAY instance");
- snprintf(query, sizeof(query),
- "DELETE FROM %s "
- "WHERE event_id = %d AND dtstart_datetime = %s ",
- CAL_TABLE_ALLDAY_INSTANCE,
- original_event_id, p);
+
+ if (strlen(p) == strlen("YYYYMMDDTHHMMSSZ")) {
+ } else {
}
dbret = _cal_db_util_query_exec(query);
if (dbret != CAL_DB_OK) {
+ ERR("[%s]", query);
ERR("_cal_db_util_query_exec() failed (%d)", dbret);
g_strfreev(t);
switch (dbret)
static int __cal_db_instance_del_inundant(int event_id, calendar_time_s *st, cal_event_s *event)
{
- cal_db_util_error_e dbret = CAL_DB_OK;
+ cal_db_util_error_e dbret = CAL_DB_OK;
int cnt;
char query[CAL_DB_SQL_MAX_LEN];
return CALENDAR_ERROR_NONE;
}
-static void __cal_db_instance_print_caltime(calendar_time_s *caltime)
+/*
+ * bit |7 |6 |5 |4 |3 |2 |1 |0 |
+ * value |0 |SA |FR |TH |WE |TU |MO |SU|
+ *
+ * UCAL_XXX = bit position + 1
+ * UCAL_SUNDAY = 1
+ * UCAL_MONDAY = 2...
+ */
+static int __convert_week_to_bits(const char *byday, int *byday_len)
{
- if (caltime) {
- switch (caltime->type) {
- case CALENDAR_TIME_UTIME:
- DBG("utime(%lld)", caltime->time.utime);
- break;
-
- case CALENDAR_TIME_LOCALTIME:
- DBG("datetime(%04d/%02d/%02d)",
- caltime->time.date.year, caltime->time.date.month, caltime->time.date.mday);
- break;
+ retvm_if(NULL == byday, -1, "Invalid parameter:byday is NULL");
+ const char *week_text[7] = {"SU", "MO", "TU", "WE", "TH", "FR", "SA"};
+ int week = 0;
+ int i;
+ int len = 0;
+ for (i = 0; i < 7; i++)
+ {
+ if (strstr(byday, week_text[i]))
+ {
+ week |= (0x01 << i);
+ len++;
}
}
+ if (byday_len) *byday_len = len;
+ return week;
}
static int __cal_db_instance_get_duration(UCalendar *ucal, calendar_time_s *st, calendar_time_s *et, long long int *duration)
{
+ retvm_if(NULL == ucal, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter:ucal is NULL");
+ retvm_if(NULL == st || NULL == et, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: st or et is NULL");
+
long long int _duration = -1;
UErrorCode ec = U_ZERO_ERROR;
UDate ud;
- if (NULL == ucal)
- {
- ERR("Invalid parameter: ucal is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- if (NULL == st || NULL == et)
- {
- ERR("Invalid parameter: calendar_time_s is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
switch (st->type) {
case CALENDAR_TIME_UTIME:
if (st->time.utime > et->time.utime)
break;
case CALENDAR_TIME_LOCALTIME:
- ucal_setDateTime(ucal, et->time.date.year, et->time.date.month -1, et->time.date.mday, 0, 0, 0, &ec);
+ ucal_setDateTime(ucal, et->time.date.year, et->time.date.month -1, et->time.date.mday,
+ et->time.date.hour, et->time.date.minute, et->time.date.second, &ec);
ud = ucal_getMillis(ucal, &ec);
- ucal_setDateTime(ucal, st->time.date.year, st->time.date.month -1, st->time.date.mday, 0, 0, 0, &ec);
+ ucal_setDateTime(ucal, st->time.date.year, st->time.date.month -1, st->time.date.mday,
+ st->time.date.hour, st->time.date.minute, st->time.date.second, &ec);
- _duration = ucal_getFieldDifference(ucal, ud, UCAL_DATE, &ec);
+ _duration = ucal_getFieldDifference(ucal, ud, UCAL_SECOND, &ec);
if (U_FAILURE(ec))
{
ERR("ucal_getFieldDifference failed (%s)", u_errorName(ec));
return CALENDAR_ERROR_NONE;
}
-static int __cal_db_instance_parse_byday(const char *byday, int *nth, int *wday)
+static int __cal_db_instance_insert_record(UCalendar *ucal, long long int duration, cal_event_s *event)//int type, int event_id)
{
- int _nth = 0;
- int _wday = 0;
- char buf[3] = {0};
-
- if (NULL == byday || strlen(byday) == 0)
+ int ret;
+ UErrorCode ec = U_ZERO_ERROR;
+ long long int lli_s = 0;
+ long long int lli_e = 0;
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
+ char buf_s[256] = {0};
+ char buf_e[256] = {0};
+
+ retvm_if (NULL == ucal, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: ucal is NULL");
+
+ switch (event->start.type)
{
- ERR("Invalid parameter: byday is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
+ case CALENDAR_TIME_UTIME:
+ lli_s = ms2sec(ucal_getMillis(ucal, &ec));
+ lli_e = lli_s + duration;
+ ret = _cal_db_instance_helper_insert_utime_instance(event->index, lli_s, lli_e);
+ retvm_if (CALENDAR_ERROR_NONE != ret, ret, "_cal_db_instance_normal_insert_record() failed(%d)", ret);
+ break;
- if (!sscanf(byday, "%d", &_nth)) {
- DBG("no digit in front of byday, so set 1 as default");
- if (sscanf(byday, "%s", buf) != 1) {
- ERR("Failed to get byday[%s]", byday);
- return -1;
- }
- _nth = 1;
- } else {
- if (sscanf(byday, "%d%s", &_nth, buf) != 2) {
- ERR("Failed to get byday[%s]", byday);
- return -1;
- }
- }
- buf[2] = '\0';
+ case CALENDAR_TIME_LOCALTIME:
+ __get_allday_date(event, ucal, &y, &m, &d, &h, &n, &s);
+ snprintf(buf_s, sizeof(buf_s), CAL_FORMAT_LOCAL_DATETIME, y, m, d, h, n, s);
- // CALENDAR_SUNDAY
- for (_wday = CALENDAR_SUNDAY; _wday <= CALENDAR_SATURDAY; _wday++) {
- if (!strncmp(wdays[_wday].str, buf, 2)) {
- DBG("inserted nth(%d) wday[%s]", _nth, wdays[_wday].str);
- break;
+ if (duration > 0) {
+ UCalendar *ucal2 = NULL;
+ ucal2 = ucal_clone(ucal, &ec);
+ ucal_add(ucal2, UCAL_SECOND, duration, &ec);
+ __get_allday_date(event, ucal2, &y, &m, &d, &h, &n, &s);
+ ucal_close(ucal2);
}
+ snprintf(buf_e, sizeof(buf_e), CAL_FORMAT_LOCAL_DATETIME, y, m, d, h, n, s);
+ ret = _cal_db_instance_helper_insert_localtime_instance(event->index, buf_s, buf_e);
+ retvm_if (CALENDAR_ERROR_NONE != ret, ret, "_cal_db_instance_allday_insert_record() failed(%d)", ret);
+ break;
}
+ __print_ucal(event->system_type, ucal, NULL, 1);
+ return CALENDAR_ERROR_NONE;
+}
- if (nth) *nth = _nth > 4 ? -1 : _nth;
- if (wday) *wday = _wday;
+static int __convert_wday_to_int(const char *wday)
+{
+ retvm_if(NULL == wday, 0, "Invalid paramter: wday is NULL");
- return CALENDAR_ERROR_NONE;
+ const char *week_text[7] = {"SU", "MO", "TU", "WE", "TH", "FR", "SA"};
+ int i;
+ for (i = 0; i < 7; i++)
+ {
+ if (strstr(wday, week_text[i])) {
+ return i + 1;
+ }
+ }
+ return 0;
}
-static void __cal_db_instance_set_ucal_start(UCalendar *ucal, calendar_time_s *st)
+static int __get_until_from_range(cal_event_s *event, calendar_time_s *until)
{
- UErrorCode ec = U_ZERO_ERROR;
+ retvm_if(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: event is NULL");
+ retvm_if(NULL == until, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: until is NULL");
- if (ucal)
+ long long int range = 0;
+ switch (event->range_type)
{
- switch (st->type)
+ case CALENDAR_RANGE_COUNT:
+ DBG("range count");
+ break;
+
+ case CALENDAR_RANGE_UNTIL:
+ DBG("range until");
+ until->type = event->until.type;
+ switch (until->type)
{
case CALENDAR_TIME_UTIME:
- ucal_setMillis(ucal, sec2ms(st->time.utime), &ec);
+ range = _cal_time_convert_itol(NULL, CAL_ENDLESS_LIMIT_YEAR,
+ CAL_ENDLESS_LIMIT_MONTH, CAL_ENDLESS_LIMIT_MDAY,
+ 0, 0, 0);
+ if (event->until.time.utime > range)
+ {
+ DBG("until time(%lld) > max, so set max(%lld)", event->until.time.utime, range);
+ until->time.utime = range;
+ }
+ else
+ {
+ until->time.utime = event->until.time.utime;
+ }
break;
case CALENDAR_TIME_LOCALTIME:
- ucal_setDate(ucal, st->time.date.year,
- st->time.date.month -1, st->time.date.mday, &ec);
+ until->time.date.year = event->until.time.date.year > CAL_ENDLESS_LIMIT_YEAR ?
+ CAL_ENDLESS_LIMIT_YEAR : event->until.time.date.year;
+ until->time.date.month = event->until.time.date.month;
+ until->time.date.mday = event->until.time.date.mday;
+ until->time.date.hour = event->until.time.date.hour;
+ until->time.date.minute = event->until.time.date.minute;
+ until->time.date.second = event->until.time.date.second;
+ break;
+ }
+ break;
+
+ case CALENDAR_RANGE_NONE:
+ DBG("range none");
+ until->type = event->until.type;
+ switch (until->type)
+ {
+ case CALENDAR_TIME_UTIME:
+ until->time.utime = _cal_time_convert_itol(event->start_tzid,
+ CAL_ENDLESS_LIMIT_YEAR,
+ CAL_ENDLESS_LIMIT_MONTH,
+ CAL_ENDLESS_LIMIT_MDAY,
+ 0, 0, 0);
+ break;
+ case CALENDAR_TIME_LOCALTIME:
+ until->time.date.year = CAL_ENDLESS_LIMIT_YEAR;
+ until->time.date.month = CAL_ENDLESS_LIMIT_MONTH;
+ until->time.date.mday = CAL_ENDLESS_LIMIT_MDAY;
+ until->time.date.hour = 0;
+ until->time.date.minute = 0;
+ until->time.date.second = 0;
break;
}
+ break;
}
+ return CALENDAR_ERROR_NONE;
}
-static void __cal_db_instance_set_wday(UCalendar *ucal, int nth, int wday)
+/*
+ * Return true when index meets bysetpos value.
+ * ig. when bysetpos=2 and 3, index 1 returns false(skip), index 2 and 3 returns true(selected).
+ */
+static bool __check_bysetpos(int index, int *bysetpos, int bysetpos_len, int dates_len)
{
- if (ucal)
- {
- ucal_set(ucal, UCAL_DAY_OF_WEEK, wday);
- ucal_set(ucal, UCAL_DAY_OF_WEEK_IN_MONTH, nth);
+ if (0 == bysetpos_len) return false;
+
+ int i;
+ for (i = 0; i < bysetpos_len; i++) {
+ if (bysetpos[i] > 0) {
+ if (bysetpos[i] == (index + 1)) {
+ return true;
+ }
+ } else {
+ if ((index - dates_len) == bysetpos[i]) {
+ return true;
+ }
+ }
}
+ return false;
}
-static int __cal_db_instance_insert_record(UCalendar *ucal, long long int duration, int type, int event_id)
+static bool __check_before_dtstart(long long int current_utime, long long int dtstart_utime)
{
- int ret;
- long long int lli;
- UErrorCode ec = U_ZERO_ERROR;
- calendar_record_h record = NULL;
- calendar_time_s st = {0};
- calendar_time_s et = {0};
- UCalendar *ucal2 = NULL;
-
- if (NULL == ucal)
- {
- ERR("Invalid parameter: ucal is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
+ if (current_utime < dtstart_utime) {
+ DBG("get time(%lld) is earlier than start(%lld), so skip", current_utime, dtstart_utime);
+ return true;
}
+ return false;
+}
- switch (type)
- {
- case CALENDAR_TIME_UTIME:
- lli = ms2sec(ucal_getMillis(ucal, &ec));
-
- st.type = type;
- st.time.utime = lli;
- DBG("insert normal (%lld)%04d-%02d-%02d %02d:%02d:00",
- st.time.utime,
- ucal_get(ucal, UCAL_YEAR, &ec),
- ucal_get(ucal, UCAL_MONTH, &ec) +1,
- ucal_get(ucal, UCAL_DATE, &ec),
- ucal_get(ucal, UCAL_HOUR_OF_DAY, &ec),
- ucal_get(ucal, UCAL_MINUTE, &ec));
- et.type = type;
- et.time.utime = lli + duration;
-
- ret = calendar_record_create(_calendar_instance_normal._uri, &record);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_create() failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- _cal_record_set_int(record, _calendar_instance_normal.event_id, event_id);
- ret = _cal_record_set_caltime(record, _calendar_instance_normal.start_time, st);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("_cal_record_set_caltime() failed");
- return ret;
- }
- ret = _cal_record_set_caltime(record, _calendar_instance_normal.end_time, et);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("_cal_record_set_caltime() failed");
- return ret;
- }
- break;
-
- case CALENDAR_TIME_LOCALTIME:
- st.type = type;
- st.time.date.year = ucal_get(ucal, UCAL_YEAR, &ec);
- st.time.date.month = ucal_get(ucal, UCAL_MONTH, &ec) +1;
- st.time.date.mday = ucal_get(ucal, UCAL_DATE, &ec);
- DBG("insert allday %04d-%02d-%02d",
- st.time.date.year, st.time.date.month, st.time.date.mday);
- et.type = type;
- if (duration > 0)
- {
- ucal2 = ucal_clone(ucal, &ec);
- ucal_add(ucal2, UCAL_DATE, duration, &ec);
- et.time.date.year = ucal_get(ucal2, UCAL_YEAR, &ec);
- et.time.date.month = ucal_get(ucal2, UCAL_MONTH, &ec) +1;
- et.time.date.mday = ucal_get(ucal2, UCAL_DATE, &ec);
- ucal_close(ucal2);
- }
- else
- {
- et.time.date.year = st.time.date.year;
- et.time.date.month = st.time.date.month;
- et.time.date.mday = st.time.date.mday;
- }
-
- ret = calendar_record_create(_calendar_instance_allday._uri, &record);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_record_create() failed");
- return ret;
- }
- ret = _cal_record_set_int(record, _calendar_instance_allday.event_id, event_id);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("_cal_record_set_int() failed");
- return ret;
- }
- ret = _cal_record_set_caltime(record, _calendar_instance_allday.start_time, st);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("_cal_record_set_caltime() failed");
- return ret;
- }
- ret = _cal_record_set_caltime(record, _calendar_instance_allday.end_time, et);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("_cal_record_set_caltime() failed");
- return ret;
+static bool __check_exdate_to_skip(long long int get_lli, int exdate_len, GList **l)
+{
+ int i = 0;
+ for (i = 0; i < exdate_len; i++) {
+ long long int exdate_lli = (long long int)g_list_nth_data(*l, i);
+ if (exdate_lli == get_lli) {
+ DBG("found exdate(%lld)", get_lli);
+ *l = g_list_remove(*l, lli2p(get_lli));
+ return true;
}
- break;
- }
- ret = calendar_db_insert_record(record, NULL);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("calendar_db_insert_record() failed");
- return ret;
}
- calendar_record_destroy(record, true);
-
- return CALENDAR_ERROR_NONE;
+ return false;
}
-static int __cal_db_instance_has_next(UCalendar *ucal, calendar_time_s *until)
+static bool __check_to_stop_loop(long long int current_utime, long long int *last_utime, int loop)
{
- int has_next = 0;
- long long int lli = 0;
- long long int lli2 = 0;
- UErrorCode ec = U_ZERO_ERROR;
- UCalendar *ucal2 = NULL;
-
- if (NULL == ucal)
- {
- ERR("Invalid parameter: ucal is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (NULL == until)
- {
- ERR("Invalid parameter: until is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
+ if ((*last_utime == current_utime) || (CAL_ENDLESS_LIMIT_FULL_DAY == loop)) {
+ DBG("current utime is same as last utime(%lld), so stoppted", current_utime);
+ return true;
}
+ *last_utime = current_utime;
+ return false;
+}
+
+static bool __check_out_of_range(long long int current_utime, cal_event_s *event, long long int until_utime, int *count)
+{
+ retvm_if(NULL == event, true, "Invalid parameter: event is NULL");
- switch (until->type)
+ // check range
+ switch (event->range_type)
{
- case CALENDAR_TIME_UTIME:
- lli = ms2sec(ucal_getMillis(ucal, &ec));
- has_next = (lli > until->time.utime) ? 0 : 1;
- if (has_next == 0)
- {
- DBG("No next:get(%lld) until(%lld)", lli, until->time.utime);
+ case CALENDAR_RANGE_UNTIL:
+ case CALENDAR_RANGE_NONE:
+ if (current_utime > until_utime) {
+ DBG("(%lld) (%lld)", current_utime, until_utime);
+ return true;
}
break;
- case CALENDAR_TIME_LOCALTIME:
- lli = ms2sec(ucal_getMillis(ucal, &ec));
-
- ucal2 = ucal_clone(ucal, &ec);
- ucal_setDateTime(ucal2, until->time.date.year, until->time.date.month -1,
- until->time.date.mday, 0, 0, 0, &ec);
- lli2 = ms2sec(ucal_getMillis(ucal2, &ec));
- ucal_close(ucal2);
+ case CALENDAR_RANGE_COUNT:
+ (*count)++;
+ if (*count > event->count) {
+ DBG("(%d) (%d)", *count, event->count);
+ return true;
+ }
- has_next = (lli > lli2) ? 0 : 1;
- if (has_next == 0)
- {
- DBG("No next:get(%lld) until(%lld)", lli, lli2);
+ if (current_utime > CAL_ENDLESS_LIMIT_UTIME) { // event count is remained, it should not go over LIMIT
+ DBG("stopped because dtstart(%lld) > LIMIT UTIME(%lld)", current_utime, (long long int)CAL_ENDLESS_LIMIT_UTIME);
+ return true;
}
break;
}
-
-
- return has_next;
+ return false;
}
-static int __cal_db_instance_publish_with_wday(UCalendar *ucal, cal_event_s *event, long long int duration, int field, calendar_time_s *until)
+static bool __check_daily_bymonth_to_skip(UCalendar *ucal, int *bymonth, int bymonth_len, int *log_value)
{
- int ret = CALENDAR_ERROR_NONE;
- int i, j;
- int count = 0;
- int length = 0;
- char **t = NULL;
- const char *d = ",";
- UDate ud1, ud2;
- UErrorCode ec = U_ZERO_ERROR;
+ if (0 == bymonth_len) return false;
- if (event->byday && strlen(event->byday) > 0)
- {
- // range: MO, TU, WE, TH, FR, SA, SU ex> 3TH, -1MO
- t = g_strsplit(event->byday, d, -1);
- if (!t) {
- ERR("g_strsplit failed");
- g_strfreev(t);
- return CALENDAR_ERROR_OUT_OF_MEMORY;
+ UErrorCode ec = U_ZERO_ERROR;
+ int month = ucal_get(ucal, UCAL_MONTH, &ec) + 1;
+ int i;
+ for (i = 0; i < bymonth_len; i++) {
+ if (month == bymonth[i]) {
+ return false;
}
- length = g_strv_length(t);
}
- else
- {
- int nth = 0, wday = 0;
- int nth2;
- char buf[8] = {0};
- UCalendar *ucal2 = NULL;
-
- ucal2 = ucal_clone(ucal, &ec);
+ if (*log_value != month) {
+ DBG("Get month(%d) Not in bymonth", month);
+ *log_value = month;
+ }
+ return true;
+}
- switch (event->start.type)
- {
- case CALENDAR_TIME_UTIME:
- ucal_setMillis(ucal, sec2ms(event->start.time.utime), &ec);
- break;
+static int __get_dates_in_month(UCalendar *ucal, int week_bits, int bymonth, int *dates_len)
+{
+ retvm_if(NULL == ucal, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: ucal is NULL");
- case CALENDAR_TIME_LOCALTIME:
- ucal_setDate(ucal2, event->start.time.date.year,
- event->start.time.date.month -1, event->start.time.date.mday, &ec);
- break;
- }
+ UErrorCode ec = U_ZERO_ERROR;
+ int len = 0;
- wday = ucal_get(ucal, UCAL_DAY_OF_WEEK, &ec);
- wday = wday < UCAL_SUNDAY ? UCAL_SUNDAY : wday;
+ int i;
+ for (i = 0; i < 7; i++) {
+ if (0 == (week_bits & (0x01 << i))) continue;
+ int wday_int = i + 1;
+
+ ucal_set(ucal, UCAL_MONTH, bymonth - 1);
+ ucal_set(ucal, UCAL_DAY_OF_WEEK, wday_int);
+ ucal_set(ucal, UCAL_DAY_OF_WEEK_IN_MONTH, 1);
+ int weekno_start = ucal_get(ucal, UCAL_WEEK_OF_YEAR, &ec);
+
+ ucal_set(ucal, UCAL_MONTH, bymonth - 1);
+ ucal_set(ucal, UCAL_DAY_OF_WEEK, wday_int);
+ ucal_set(ucal, UCAL_DAY_OF_WEEK_IN_MONTH, -1);
+ int weekno_end = ucal_get(ucal, UCAL_WEEK_OF_YEAR, &ec);
+ if (1 == weekno_end) {
+ ucal_set(ucal, UCAL_MONTH, bymonth - 1);
+ ucal_set(ucal, UCAL_DAY_OF_WEEK, wday_int);
+ ucal_set(ucal, UCAL_DAY_OF_WEEK_IN_MONTH, -1);
+ ucal_add(ucal, UCAL_DATE, -7, &ec);
+ weekno_end = ucal_get(ucal, UCAL_WEEK_OF_YEAR, &ec) + 1;
+ }
+ int weekno_gap = weekno_end - weekno_start + 1;
+
+ len += weekno_gap;
+ }
+ if (dates_len) *dates_len = len;
+ return CALENDAR_ERROR_NONE;
+}
- nth = ucal_get(ucal2, UCAL_DAY_OF_WEEK_IN_MONTH, &ec);
- ucal_add(ucal, UCAL_DATE, 7, &ec);
- nth2 = ucal_get(ucal2, UCAL_DAY_OF_WEEK_IN_MONTH, &ec);
- nth = (nth2 == 1) ? -1 : nth;
+static int __cal_db_instance_publish_yearly_yday(UCalendar *ucal, cal_event_s *event, long long int duration)
+{
+ retvm_if(NULL == ucal, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: ucal is NULL");
+ retvm_if(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: event is NULL");
+ retvm_if(NULL == event->byyearday || '\0' == event->byyearday[0],
+ CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: no byyearday");
- ucal_close(ucal2);
+ UErrorCode ec = U_ZERO_ERROR;
+ calendar_time_s until = {0};
+ __get_until_from_range(event, &until);
+ __set_time_to_ucal(event->system_type, ucal, &until); // set until before dtstart_utime
+ long long int until_utime = ms2sec(ucal_getMillis(ucal, &ec));
- snprintf(buf, sizeof(buf), "%d%s", nth, wdays[wday].str);
- t = g_strsplit(buf, d, -1);
- if (!t) {
- ERR("g_strsplit failed");
- g_strfreev(t);
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- DBG("No byday, so set wday(%s)", t[0]);
+ int byyearday[1024] = {0};
+ int byyearday_len = 0;
+ __cal_db_instance_parse_byint(event->byyearday, byyearday, &byyearday_len);
+ DBG("byyearday len(%d)", byyearday_len);
- length = 1;
- }
- DBG("length(%d)", length);
+ int bysetpos[1024] = {0};
+ int bysetpos_len = 0;
+ __cal_db_instance_parse_byint(event->bysetpos, bysetpos, &bysetpos_len);
+ DBG("bysetpos len(%d)", bysetpos_len);
- if (event->count)
- {
- count = event->count;
+ GList *l = NULL;
+ int exdate_len = 0;
+ __get_exdate_list(ucal, event, &l, &exdate_len);
- if (event->bysetpos)
- {
- int share, remind;
- int length2;
- char **t2 = NULL;
-
- t2 = g_strsplit(event->bysetpos, ",", -1);
- length2 = g_strv_length(t2);
- g_strfreev(t2);
-
- share = length / length2;
- remind = length % length2;
- count = count * share + (remind ? length : 0);
- }
- else
+ int loop = 0;
+ int count = 0;
+ bool is_exit = false;
+ long long int last_utime = 0;
+ long long int current_utime = 0;
+ while (false == is_exit)
+ {
+ calendar_time_s *st = &event->start;
+ __set_time_to_ucal(event->system_type, ucal, st);
+ long long int dtstart_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ ucal_add(ucal, UCAL_YEAR, event->interval * loop, &ec);
+
+ int i;
+ for (i = 0; i < byyearday_len; i++)
{
- count = count / length + ((count % length == 0) ? 0 : 1);
+ ucal_set(ucal, UCAL_DAY_OF_YEAR, byyearday[i]);
+ if (false == __check_bysetpos(i, bysetpos, bysetpos_len, byyearday_len)) {
+ continue;
+ }
+ current_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ if (true == __check_before_dtstart(current_utime, dtstart_utime)) {
+ continue;
+ }
+ if (true == __check_exdate_to_skip(current_utime, exdate_len, &l)) {
+ count++;
+ continue;
+ }
+ is_exit = __check_out_of_range(current_utime, event, until_utime, &count);
+ if (true == is_exit) break;
+ __cal_db_instance_insert_record(ucal, duration, event);
}
- DBG("bycount(%d) count(%d)", event->count, count);
+ if (true == is_exit) break;
+ current_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ is_exit = __check_to_stop_loop(current_utime, &last_utime, loop);
+ loop++;
}
+ if (l) g_list_free(l);
+ return CALENDAR_ERROR_NONE;
+}
- ud1 = ucal_getMillis(ucal, &ec);
- int week = ucal_get(ucal, field, &ec);
+/*
+ * weekno is different num+day
+ * weekno=10, byday=SU, is not always same as 10SU
+ * in 2014, Mar 2nd != Mar 9th
+ */
+static int __cal_db_instance_publish_yearly_weekno(UCalendar *ucal, cal_event_s *event, long long int duration)
+{
+ retvm_if(NULL == ucal, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: ucal is NULL");
+ retvm_if(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: event is NULL");
+ retvm_if(NULL == event->byweekno || '\0' == event->byweekno[0],
+ CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: no byweekno");
- for (i = 0; i < length; i++)
- {
- // set nth, wday
- int nth = 0, wday = 0;
- ret = __cal_db_instance_parse_byday(t[i], &nth, &wday);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("__cal_db_instance_parse_byday() failed");
- g_strfreev(t);
- return ret;
- }
- ucal_setMillis(ucal, ud1, &ec);
- switch (field)
- {
- case UCAL_WEEK_OF_YEAR:
- DBG("UCAL_WEEK_OF_YEAR");
- ucal_set(ucal, UCAL_DAY_OF_WEEK, wday);
- ucal_set(ucal, field, week);
- DBG("Set wday week(%d) wday(%d)",week, wday);
- break;
- default:
- __cal_db_instance_set_wday(ucal, nth, wday);
- DBG("Set wday nth(%d) wday(%d)", nth, wday);
- break;
- }
+ UErrorCode ec = U_ZERO_ERROR;
+ calendar_time_s until = {0};
+ __get_until_from_range(event, &until);
+ __set_time_to_ucal(event->system_type, ucal, &until); // set until before dtstart_utime
+ long long int until_utime = ms2sec(ucal_getMillis(ucal, &ec));
+
+ // get byday
+ int week_bits = 0;
+ int byday_len = 0;
+ // if nowday in weekly
+ if (NULL == event->byday || '\0' == event->byday[0]) {
+ calendar_time_s *st = &event->start;
+ __set_time_to_ucal(event->system_type, ucal, st);
+ int dtstart_wday = ucal_get(ucal, UCAL_DAY_OF_WEEK, &ec);
+ week_bits |= (0x01 << (dtstart_wday - 1));
+ byday_len = 1;
- // check whether set ucal goes past or not
- ud1 = ucal_getMillis(ucal, &ec);
+ } else {
+ week_bits = __convert_week_to_bits(event->byday, &byday_len);
+ }
+ DBG("byday_len (%d) week integer(0x%x)", byday_len, week_bits);
- UCalendar *ucal2 = NULL;
- ucal2 = ucal_clone(ucal, &ec);
- __cal_db_instance_set_ucal_start(ucal2, &event->start);
- ud2 = ucal_getMillis(ucal2, &ec);
- ucal_close(ucal2);
+ int byweekno[1024] = {0};
+ int byweekno_len = 0;
+ __cal_db_instance_parse_byint(event->byweekno, byweekno, &byweekno_len);
+ DBG("byweekno len(%d)", byweekno_len);
- if (ms2sec(ud2) > ms2sec(ud1))
- {
- DBG("Invalid first time: start(%lld) get(%lld)", ms2sec(ud2), ms2sec(ud1));
- switch (field)
- {
- case UCAL_WEEK_OF_YEAR:
- ucal_add(ucal, field, event->interval, &ec);
- break;
+ int bysetpos[1024] = {0};
+ int bysetpos_len = 0;
+ __cal_db_instance_parse_byint(event->bysetpos, bysetpos, &bysetpos_len);
+ DBG("bysetpos len(%d)", bysetpos_len);
- default:
- ucal_add(ucal, field, event->interval, &ec);
- __cal_db_instance_set_wday(ucal, nth, wday);
- break;
- }
- }
+ GList *l = NULL;
+ int exdate_len = 0;
+ __get_exdate_list(ucal, event, &l, &exdate_len);
- DBG("range type(%d) interval(%d)", event->range_type, event->interval);
- switch (event->range_type)
+ int loop = 0;
+ int count = 0;
+ bool is_exit = false;
+ long long int last_utime = 0;
+ long long int current_utime = 0;
+ while (false == is_exit)
+ {
+ calendar_time_s *st = &event->start;
+ __set_time_to_ucal(event->system_type, ucal, st);
+ long long int dtstart_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ ucal_add(ucal, UCAL_YEAR, (event->interval * loop), &ec);
+ long long int start_point = sec2ms(ucal_getMillis(ucal, &ec));
+
+ /* extra_weekno : week-number converting value from iCalendar (RFC2445) to ICU:
+ * - iCalendar W1 : first week containing at least 4 days of the year
+ * (W0 when contains less than 4 days of the year)
+ * - ICU W1 : week of 1,Jan
+ */
+ int extra_weekno = 0;
+ ucal_set(ucal, UCAL_MONTH, 0);
+ ucal_set(ucal, UCAL_DATE, 1);
+ int wkst = ucal_getAttribute(ucal, UCAL_FIRST_DAY_OF_WEEK);
+ int first_wday = ucal_get(ucal, UCAL_DAY_OF_WEEK, &ec);
+ extra_weekno = ((first_wday+7-wkst)%7) > 3 ? 1 : 0;
+
+ ucal_setMillis(ucal, ms2sec(start_point), &ec); // set start point
+
+ int i;
+ for (i = 0 ; i < byweekno_len; i++)
{
- case CALENDAR_RANGE_COUNT:
- for (j = 0; j < count; j++)
- {
- __cal_db_instance_insert_record(ucal, duration, event->start.type, event->index);
- ucal_add(ucal, field, event->interval, &ec);
- switch (field)
- {
- case UCAL_WEEK_OF_YEAR:
- break;
- default:
- __cal_db_instance_set_wday(ucal, nth, wday);
- break;
- }
- }
- break;
-
- case CALENDAR_RANGE_UNTIL:
- case CALENDAR_RANGE_NONE:
- while (__cal_db_instance_has_next(ucal, until))
+ int j;
+ int week_count = 0;
+ for (j = 0; j < 7; j++)
{
- __cal_db_instance_insert_record(ucal, duration, event->start.type, event->index);
- ucal_add(ucal, field, event->interval, &ec);
- switch (field)
- {
- case UCAL_WEEK_OF_YEAR:
- break;
- default:
- __cal_db_instance_set_wday(ucal, nth, wday);
- break;
+ if (week_bits & (0x01 << j)) {
+ week_count++;
+ ucal_set(ucal, UCAL_WEEK_OF_YEAR, byweekno[i] + extra_weekno);
+ ucal_set(ucal, UCAL_DAY_OF_WEEK, j + 1);
+ if (false == __check_bysetpos(i + week_count - 1, bysetpos, bysetpos_len, byweekno_len + byday_len - 1)) {
+ continue;
+ }
+ current_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ if (true == __check_before_dtstart(current_utime, dtstart_utime)) {
+ continue;
+ }
+ if (true == __check_exdate_to_skip(current_utime, exdate_len, &l)) {
+ count++;
+ continue;
+ }
+ is_exit = __check_out_of_range(current_utime, event, until_utime, &count);
+ if (true == is_exit) break;
+ __cal_db_instance_insert_record(ucal, duration, event);
}
}
- break;
+ if (true == is_exit) break;
}
+ if (true == is_exit) break;
+ current_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ is_exit = __check_to_stop_loop(current_utime, &last_utime, loop);
+ loop++;
}
- g_strfreev(t);
-
+ if (l) g_list_free(l);
return CALENDAR_ERROR_NONE;
}
-static int __cal_db_instance_publish_with_mday(UCalendar *ucal, cal_event_s *event, long long int duration, int field, calendar_time_s *until)
+static int __cal_db_instance_publish_yearly_wday(UCalendar *ucal, cal_event_s *event, long long int duration)
{
- int i;
- int count = 0;
- int length = 0;
- int get_mday;
- char **t = NULL;
- const char *d = ",";
- UDate ud1, ud2;
+ retvm_if(NULL == ucal, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: ucal is NULL");
+ retvm_if(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: event is NULL");
+
UErrorCode ec = U_ZERO_ERROR;
+ calendar_time_s until = {0};
+ __get_until_from_range(event, &until);
+ __set_time_to_ucal(event->system_type, ucal, &until); // set until before dtstart_utime
+ long long int until_utime = ms2sec(ucal_getMillis(ucal, &ec));
+
+ // get bymonth into array
+ int bymonth[12] = {0};
+ int bymonth_len = 0;
+ bool has_bymonth = true;
+ __cal_db_instance_parse_byint(event->bymonth, bymonth, &bymonth_len);
+ if (0 == bymonth_len) {
+ has_bymonth = false;
+ calendar_time_s *st = &event->start;
+ __set_time_to_ucal(event->system_type, ucal, st);
+ int month = ucal_get(ucal, UCAL_MONTH, &ec) + 1;
+ bymonth[0] = month;
+ bymonth_len = 1;
+ }
- if (event->bymonthday && strlen(event->bymonthday) > 0)
- {
- // range: 1, 2, ... , 31 ex> 1, 5, 7
- t = g_strsplit(event->bymonthday, d, -1);
- if (!t) {
- ERR("g_strsplit failed");
- g_strfreev(t);
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- length = g_strv_length(t);
- DBG("has bymonthday");
+ // get bymonthday into array
+ int bymonthday[1024] = {0};
+ int bymonthday_len = 0;
+ __cal_db_instance_parse_byint(event->bymonthday, bymonthday, &bymonthday_len);
+ DBG("bymonthday_len(%d)", bymonthday_len);
- }
- else
- {
- int mday = 0;
- char buf[8] = {0};
- switch (event->start.type)
- {
- case CALENDAR_TIME_UTIME:
- _cal_time_ltoi(event->start_tzid, event->start.time.utime, NULL, NULL, &mday);
- snprintf(buf, sizeof(buf), "%d", mday);
- break;
+ char **t = NULL;
+ int byday_len = 0;
- case CALENDAR_TIME_LOCALTIME:
- snprintf(buf, sizeof(buf), "%d", event->start.time.date.mday);
- break;
- }
- t = g_strsplit(buf, d, -1);
- if (!t) {
- ERR("g_strsplit failed");
- g_strfreev(t);
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- DBG("No bymonthday, so set mday(%s)", t[0]);
+ // if nowday in weekly
+ if (NULL == event->byday || '\0' == event->byday[0]) {
+ const char *week_text[7] = {"SU", "MO", "TU", "WE", "TH", "FR", "SA"};
- length = 1;
- }
+ calendar_time_s *st = &event->start;
+ __set_time_to_ucal(event->system_type, ucal, st);
+ int nth = ucal_get(ucal, UCAL_DAY_OF_WEEK_IN_MONTH, &ec);
+ int dtstart_wday = ucal_get(ucal, UCAL_DAY_OF_WEEK, &ec);
+ char buf[32] = {0};
+ snprintf(buf, sizeof(buf), "%d%s", nth, week_text[dtstart_wday -1]);
+ DBG("set byday[%s]", buf);
- if (event->count)
- {
- count = event->count;
+ t = g_strsplit_set(buf, " ,", -1);
+ byday_len = 1;
- if (event->bysetpos)
- {
- int share, remind;
- int length2;
- char **t2 = NULL;
-
- t2 = g_strsplit(event->bysetpos, ",", -1);
- length2 = g_strv_length(t2);
- g_strfreev(t2);
-
- share = length / length2;
- remind = length % length2;
- count = count * share + (remind ? length : 0);
- DBG("share(%d) remind(%d)", share, remind);
- }
- else
- {
- count = count / length + ((count % length == 0) ? 0 : 1);
- }
- DBG("count(%d)", count);
+ } else {
+ t = g_strsplit_set(event->byday, " ,", -1);
+ byday_len = g_strv_length(t);
}
+ DBG("[%s] byday_len(%d)", event->byday, byday_len);
- ud1 = ucal_getMillis(ucal, &ec);
+ int bysetpos[1024] = {0};
+ int bysetpos_len = 0;
+ __cal_db_instance_parse_byint(event->bysetpos, bysetpos, &bysetpos_len);
+ DBG("bysetpos len(%d)", bysetpos_len);
- for (i = 0; i < length; i++)
- {
- int mday = atoi(t[i]);
- DBG("mday is set(%d)", mday);
- mday = mday < 1 ? mday +1 : mday; // In ICU, last day is 0 not -1.
+ GList *l = NULL;
+ int exdate_len = 0;
+ __get_exdate_list(ucal, event, &l, &exdate_len);
+ DBG("exdate_len(%d)", exdate_len);
- ucal_setMillis(ucal, ud1, &ec);
- ucal_set(ucal, UCAL_DATE, mday);
+ int loop = 0;
+ int count = 0;
+ bool is_exit = false;
+ long long int last_utime = 0;
+ long long int current_utime = 0;
+ while (false == is_exit)
+ {
+ calendar_time_s *st = &event->start;
+ __set_time_to_ucal(event->system_type, ucal, st);
+ long long int dtstart_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ ucal_add(ucal, UCAL_YEAR, event->interval * loop, &ec);
+ ucal_setMillis(ucal, ucal_getMillis(ucal, &ec), &ec); // set start point
+
+ int i, j, k;
+ for (i = 0; i < bymonth_len; i++) {
+
+ if (strlen(t[0]) > 2) { // -3SU, +2SA
+ for (j = 0; j < byday_len; j++) {
+ if (0 == strlen(t[j])) continue;
+ // get nth, wday
+ int nth = 0;
+ char wday[32] = {0};
+
+ sscanf(t[j], "%d%s", &nth, wday); // -3SU, +2SA
+ DBG("nth(%d) wday[%s]", nth, wday);
+ int wday_int = __convert_wday_to_int(wday);
+
+ // set nth, wday
+ if (nth > 0) {
+ ucal_set(ucal, UCAL_DAY_OF_WEEK, wday_int);
+ ucal_set(ucal, UCAL_DAY_OF_WEEK_IN_MONTH, 1);
+ ucal_set(ucal, UCAL_MONTH, false == has_bymonth ? 0 : (bymonth[i] - 1));
+ ucal_add(ucal, UCAL_WEEK_OF_YEAR, nth - 1, &ec);
+
+ } else {
+ ucal_set(ucal, UCAL_DAY_OF_WEEK, wday_int);
+ ucal_set(ucal, UCAL_MONTH, false == has_bymonth ? 0 : bymonth[i] - 1);
+ ucal_set(ucal, UCAL_DAY_OF_WEEK_IN_MONTH, nth);
+ }
+ if (false == __check_bysetpos(j, bysetpos, bysetpos_len, bymonth_len + byday_len - 1)) {
+ continue;
+ }
+ current_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ if (true == __check_before_dtstart(current_utime, dtstart_utime)) {
+ continue;
+ }
+ if (true == __check_exdate_to_skip(current_utime, exdate_len, &l)) {
+ count++;
+ continue;
+ }
+ is_exit = __check_out_of_range(current_utime, event, until_utime, &count);
+ if (true == is_exit) break;
+ __cal_db_instance_insert_record(ucal, duration, event);
+ }
- // check whether set ucal goes past or not
- ud1 = ucal_getMillis(ucal, &ec);
+ } else { // SU, SA: no week num: means all week:1TH,2TH,3TH.., so needs another byevent->system_typex
+ int week_bits = 0;
+ // if nowday in weekly
+ if (NULL == event->byday || '\0' == event->byday[0]) {
+ calendar_time_s *st = &event->start;
+ __set_time_to_ucal(event->system_type, ucal, st);
+ int dtstart_wday = ucal_get(ucal, UCAL_DAY_OF_WEEK, &ec);
+ week_bits |= (0x01 << (dtstart_wday - 1));
+
+ } else {
+ week_bits = __convert_week_to_bits(event->byday, NULL);
+ }
+ DBG("week integer(0x%x)", week_bits);
+
+ if (bymonthday_len) { // bymonthday
+ for (j = 0; j < bymonthday_len; j++) {
+ ucal_set(ucal, UCAL_MONTH, bymonth[i] - 1);
+ ucal_set(ucal, UCAL_DAY_OF_MONTH, bymonthday[j]);
+ bool is_match_wday = false;
+ int w = ucal_get(ucal, UCAL_DAY_OF_WEEK, &ec);
+ for (k = 0; k < 7; k++) { // check if this is one of wday
+ if (week_bits & (0x01 << k)) {
+ if ((k + 1) == w) {
+ is_match_wday = true;
+ break;
+ }
+ }
+ }
+ if (false == is_match_wday) {
+ DBG("get wday(%d) != want wday(%d)", w, k + 1);
+ continue;
+ }
+ if (false == __check_bysetpos(j, bysetpos, bysetpos_len, bymonthday_len)) {
+ continue;
+ }
+ current_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ if (true == __check_before_dtstart(current_utime, dtstart_utime)) {
+ continue;
+ }
+ if (true == __check_exdate_to_skip(current_utime, exdate_len, &l)) {
+ count++;
+ continue;
+ }
+ is_exit = __check_out_of_range(current_utime, event, until_utime, &count);
+ if (true == is_exit) break;
+ __cal_db_instance_insert_record(ucal, duration, event);
+ }
- UCalendar *ucal2 = NULL;
- ucal2 = ucal_clone(ucal, &ec);
- __cal_db_instance_set_ucal_start(ucal2, &event->start);
- ud2 = ucal_getMillis(ucal2, &ec);
- ucal_close(ucal2);
+ } else {
+ int year = ucal_get(ucal, UCAL_YEAR, &ec);
- if (ms2sec(ud2) > ms2sec(ud1))
- {
- DBG("Invalid first time(%lld) > (%lld), so added interval",
- ms2sec(ud2), ms2sec(ud1));
- ucal_add(ucal, field, event->interval, &ec);
- }
+ ucal_set(ucal, UCAL_MONTH, bymonth[i] - 1);
+ ucal_set(ucal, UCAL_DATE, 1);
+ int byday_start = ucal_get(ucal, UCAL_DAY_OF_WEEK, &ec);
- int j = 0, k = 0;
- DBG("range type(%d)", event->range_type);
- switch (event->range_type)
- {
- case CALENDAR_RANGE_COUNT:
- if (count == 1)
- {
- __cal_db_instance_insert_record(ucal, duration, event->start.type, event->index);
- break;
- }
+ int dates_len = 0;
+ __get_dates_in_month(ucal, week_bits, bymonth[i], &dates_len);
+ DBG("dates_len (%d)", dates_len);
- for (j = 0; j < count; j++)
- {
- __cal_db_instance_insert_record(ucal, duration, event->start.type, event->index);
- ucal_add(ucal, field, event->interval, &ec);
- if (event->freq != CALENDAR_RECURRENCE_DAILY)
- {
- if (mday > 0)
- {
- while ((get_mday = ucal_get(ucal, UCAL_DATE, &ec)) != mday)
- {
- k++;
- DBG("Skip this date, we got mday(%d) no match with mday(%d)", get_mday, mday);
- ucal_setMillis(ucal, ud1, &ec);
- ucal_set(ucal, UCAL_DATE, mday);
- ucal_add(ucal, field, event->interval * (j + k), &ec);
- if ((ucal_get(ucal, UCAL_YEAR, &ec) > CAL_ENDLESS_LIMIT_YEAR) || (k > 50))
- {
- ERR("Out of range");
- j = count;
- break;
- }
- }
- }
- else
- {
- ucal_add(ucal, field, event->interval, &ec);
- ucal_set(ucal, UCAL_DATE, mday);
- }
- }
- }
- break;
+ int index = -1;
+ for (j = 0; j < 6; j++) { // check weekno in month: max 6
+ for (k = 0; k < 7; k++) {
+ if (0 == (week_bits & (0x01 << ((byday_start -1 +k)%7)))) continue;
+ index++;
- case CALENDAR_RANGE_UNTIL:
- case CALENDAR_RANGE_NONE:
- j = 0;
- while (__cal_db_instance_has_next(ucal, until))
- {
- __cal_db_instance_insert_record(ucal, duration, event->start.type, event->index);
- ucal_add(ucal, field, event->interval, &ec);
- if (event->freq != CALENDAR_RECURRENCE_DAILY)
- {
- if (mday > 0)
- {
- while ((get_mday = ucal_get(ucal, UCAL_DATE, &ec)) != mday)
- {
- k++;
- DBG("Skip this date, we got mday(%d) no match with mday(%d)", get_mday, mday);
- ucal_setMillis(ucal, ud1, &ec);
- ucal_set(ucal, UCAL_DATE, mday);
- ucal_add(ucal, field, event->interval * (j + k), &ec);
- if ((ucal_get(ucal, UCAL_YEAR, &ec) > CAL_ENDLESS_LIMIT_YEAR) || (k > 50))
- {
- ERR("Out of range");
- j = count;
- break;
+ int wday_int = (byday_start -1 +k) %7 + 1;
+ ucal_set(ucal, UCAL_WEEK_OF_MONTH, (j + 1) + (byday_start -1 +k) / 7);
+ if (year != ucal_get(ucal, UCAL_YEAR, &ec)) ucal_set(ucal, UCAL_YEAR, year); // year is changed from 12/30
+ ucal_set(ucal, UCAL_MONTH, bymonth[i] - 1);
+ ucal_set(ucal, UCAL_DAY_OF_WEEK, wday_int);
+
+ int get_month = ucal_get(ucal, UCAL_MONTH, &ec) + 1;
+ if (bymonth[i] != get_month) { j = 6; break; }
+
+ if (false == __check_bysetpos(index, bysetpos, bysetpos_len, dates_len)) {
+ continue;
+ }
+ current_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ if (true == __check_before_dtstart(current_utime, dtstart_utime)) {
+ continue;
+ }
+ if (true == __check_exdate_to_skip(current_utime, exdate_len, &l)) {
+ count++;
+ continue;
}
+ is_exit = __check_out_of_range(current_utime, event, until_utime, &count);
+ if (true == is_exit) break;
+ __cal_db_instance_insert_record(ucal, duration, event);
}
- }
- else
- {
- ucal_add(ucal, field, event->interval, &ec);
- ucal_set(ucal, UCAL_DATE, mday);
+ if (true == is_exit) break;
}
}
- j++;
}
- break;
+ if (true == is_exit) break;
}
+ if (true == is_exit) break;
+ current_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ is_exit = __check_to_stop_loop(current_utime, &last_utime, loop);
+ loop++;
}
g_strfreev(t);
-
+ if (l) g_list_free(l);
return CALENDAR_ERROR_NONE;
}
-static int __cal_db_instance_publish_with_weekno(UCalendar *ucal, cal_event_s *event, long long int duration, int field, calendar_time_s *until)
+static int __cal_db_instance_publish_yearly_mday(UCalendar *ucal, cal_event_s *event, long long int duration)
{
- int i, j;
- int count = 0;
- int length = 0;
- char **t = NULL;
- const char *d = ",";
- UDate ud1, ud2;
- UErrorCode ec = U_ZERO_ERROR;
+ retvm_if(NULL == ucal, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: ucal is NULL");
+ retvm_if(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: event is NULL");
- if (event->byweekno && strlen(event->byweekno) > 0)
- {
- // range: -366, -1, 1, 366 ex> 3,200
- t = g_strsplit(event->byweekno, d, -1);
- if (!t) {
- ERR("g_strsplit failed");
- g_strfreev(t);
- return CALENDAR_ERROR_OUT_OF_MEMORY;
+ UErrorCode ec = U_ZERO_ERROR;
+ calendar_time_s until = {0};
+ __get_until_from_range(event, &until);
+ __set_time_to_ucal(event->system_type, ucal, &until); // set until before dtstart_utime
+ long long int until_utime = ms2sec(ucal_getMillis(ucal, &ec));
+
+ // get bymonth into array
+ int bymonth[12] = {0};
+ int bymonth_len = 0;
+ __cal_db_instance_parse_byint(event->bymonth, bymonth, &bymonth_len);
+ if (0 == bymonth_len) {
+ calendar_time_s *st = &event->start;
+ __set_time_to_ucal(event->system_type, ucal, st);
+ int month = ucal_get(ucal, UCAL_MONTH, &ec) + 1;
+ bymonth[0] = month;
+ bymonth_len = 1;
+ }
+ DBG("bymonth_len(%d)", bymonth_len);
+
+ // get bymonthday into array
+ int bymonthday[1024] = {0};
+ int bymonthday_len = 0;
+ __cal_db_instance_parse_byint(event->bymonthday, bymonthday, &bymonthday_len);
+ if (0 == bymonthday_len) {
+ calendar_time_s *st = &event->start;
+ __set_time_to_ucal(event->system_type, ucal, st);
+ int dtstart_mday = ucal_get(ucal, UCAL_DATE, &ec);
+ bymonthday[0] = dtstart_mday;
+ bymonthday_len = 1;
+ }
+ DBG("bymonthday len(%d)", bymonthday_len);
+
+ int bysetpos[1024] = {0};
+ int bysetpos_len = 0;
+ __cal_db_instance_parse_byint(event->bysetpos, bysetpos, &bysetpos_len);
+ DBG("bysetpos len(%d)", bysetpos_len);
+
+ GList *l = NULL;
+ int exdate_len = 0;
+ __get_exdate_list(ucal, event, &l, &exdate_len);
+
+ int loop = 0;
+ int count = 0;
+ bool is_exit = false;
+ long long int last_utime = 0;
+ long long int current_utime = 0;
+ while (false == is_exit)
+ {
+ calendar_time_s *st = &event->start;
+ __set_time_to_ucal(event->system_type, ucal, st);
+ long long int dtstart_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ ucal_add(ucal, UCAL_YEAR, event->interval *loop, &ec);
+ ucal_setMillis(ucal, ucal_getMillis(ucal, &ec), &ec); // set start point
+
+ int i, j;
+ for (j = 0; j < bymonth_len; j++) {
+ for (i = 0 ; i < bymonthday_len; i++) {
+ if (bymonthday[i] > 0) {
+ ucal_set(ucal, UCAL_MONTH, bymonth[j] - 1);
+ ucal_set(ucal, UCAL_DATE, bymonthday[i]);
+ int get_mday = ucal_get(ucal, UCAL_DATE, &ec);
+ if (get_mday != bymonthday[i]) {
+ DBG("bymonthday(%d) but get (%d) from icu", bymonthday[i], get_mday);
+ continue;
+ }
+ } else if (bymonthday[i] < 0) {
+ // goto end of the month
+ ucal_set(ucal, UCAL_MONTH, bymonth[j] - 1);
+ ucal_set(ucal, UCAL_DATE, 1);
+ ucal_add(ucal, UCAL_MONTH, 1, &ec);
+ ucal_add(ucal, UCAL_DAY_OF_YEAR, bymonthday[i], &ec);
+
+ } else { // 0 is invalid
+ DBG("Invalid bymonthday(%d)", bymonthday[i]);
+ continue;
+ }
+ if (false == __check_bysetpos(i, bysetpos, bysetpos_len, bymonthday_len)) {
+ continue;
+ }
+ current_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ if (true == __check_before_dtstart(current_utime, dtstart_utime)) {
+ continue;
+ }
+ if (true == __check_exdate_to_skip(current_utime, exdate_len, &l)) {
+ count++;
+ continue;
+ }
+ is_exit = __check_out_of_range(current_utime, event, until_utime, &count);
+ if (true == is_exit) break;
+ __cal_db_instance_insert_record(ucal, duration, event);
+ }
}
- length = g_strv_length(t);
- DBG("has bymonthday");
-
+ if (true == is_exit) break;
+ current_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ is_exit = __check_to_stop_loop(current_utime, &last_utime, loop);
+ loop++;
}
+ if (l) g_list_free(l);
+ return CALENDAR_ERROR_NONE;
+}
- if (event->count)
+static int __cal_db_instance_publish_record_yearly(UCalendar *ucal, cal_event_s *event, long long int duration)
+{
+ if (NULL == ucal)
{
- count = event->count;
-
- if (event->bysetpos)
- {
- int share, remind;
- int length2;
- char **t2 = NULL;
-
- t2 = g_strsplit(event->bysetpos, ",", -1);
- length2 = g_strv_length(t2);
- g_strfreev(t2);
-
- share = length / length2;
- remind = length % length2;
- count = count * share + (remind ? length : 0);
- DBG("share(%d) remind(%d)", share, remind);
- }
- else
- {
- count = count / length + ((count % length == 0) ? 0 : 1);
- DBG("length(%d)", length);
- }
- DBG("bycount(%d) count(%d)", event->count, count);
+ ERR("Invalid parameter: ucal is NULL");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
}
-
- int wday;
- wday = ucal_get(ucal, UCAL_DAY_OF_WEEK, &ec);
- ud1 = ucal_getMillis(ucal, &ec);
-
- for (i = 0; i < length; i++)
+ if (NULL == event)
{
- int weekno = atoi(t[i]);
-
- ucal_setMillis(ucal, ud1, &ec);
- ucal_set(ucal, UCAL_WEEK_OF_YEAR, weekno);
- DBG("weekno is set(%d)", weekno);
-
- // check whether set ucal goes past or not
- ud1 = ucal_getMillis(ucal, &ec);
+ ERR("Invalid parameter: event is NULL");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- UCalendar *ucal2 = NULL;
- ucal2 = ucal_clone(ucal, &ec);
- __cal_db_instance_set_ucal_start(ucal2, &event->start);
- ud2 = ucal_getMillis(ucal2, &ec);
- ucal_close(ucal2);
+ if (event->byyearday && strlen(event->byyearday) > 0) {
+ __cal_db_instance_publish_yearly_yday(ucal, event, duration);
- if (ms2sec(ud2) > ms2sec(ud1))
- {
- DBG("Invalid first time: start(%lld) get(%lld)", ms2sec(ud2), ms2sec(ud1));
- ucal_add(ucal, field, 1, &ec);
- }
+ } else if (event->byweekno && strlen(event->byweekno) > 0) {
+ __cal_db_instance_publish_yearly_weekno(ucal, event, duration);
- DBG("range type(%d) interval(%d)", event->range_type, event->interval);
- switch (event->range_type)
- {
- case CALENDAR_RANGE_COUNT:
- for (j = 0; j < count; j++)
- {
- __cal_db_instance_insert_record(ucal, duration, event->start.type, event->index);
- ucal_add(ucal, field, event->interval, &ec);
- }
- break;
+ } else {
+ if (event->byday && *event->byday) {
+ __cal_db_instance_publish_yearly_wday(ucal, event, duration);
- case CALENDAR_RANGE_UNTIL:
- case CALENDAR_RANGE_NONE:
- while (__cal_db_instance_has_next(ucal, until))
- {
- __cal_db_instance_insert_record(ucal, duration, event->start.type, event->index);
- ucal_add(ucal, field, event->interval, &ec);
- }
- break;
+ } else {
+ __cal_db_instance_publish_yearly_mday(ucal, event, duration);
}
}
- g_strfreev(t);
-
return CALENDAR_ERROR_NONE;
}
-
-static int __cal_db_instance_publish_with_yday(UCalendar *ucal, cal_event_s *event, long long int duration, int field, calendar_time_s *until)
+static int __cal_db_instance_publish_monthly_wday(UCalendar *ucal, cal_event_s *event, long long int duration)
{
- int i, j;
- int count = 0;
- int length = 0;
- char **t = NULL;
- const char *d = ",";
- UDate ud1, ud2;
+ retvm_if(NULL == ucal, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: ucal is NULL");
+ retvm_if(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: event is NULL");
+
UErrorCode ec = U_ZERO_ERROR;
+ calendar_time_s until = {0};
+ __get_until_from_range(event, &until);
+ __set_time_to_ucal(event->system_type, ucal, &until); // set until before dtstart_utime
+ long long int until_utime = ms2sec(ucal_getMillis(ucal, &ec));
- if (event->byyearday && strlen(event->byyearday) > 0)
- {
- // range: -366, -1, 1, 366 ex> 3,200
- t = g_strsplit(event->byyearday, d, -1);
- if (!t) {
- ERR("g_strsplit failed");
- g_strfreev(t);
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
- length = g_strv_length(t);
- DBG("has bymonthday");
+ // get bymonthday into array
+ int bymonthday[1024] = {0};
+ int bymonthday_len = 0;
+ __cal_db_instance_parse_byint(event->bymonthday, bymonthday, &bymonthday_len);
- }
+ char **t = NULL;
+ int byday_len = 0;
- if (event->count)
- {
- count = event->count;
+ // if nowday in weekly
+ if (NULL == event->byday || '\0' == event->byday[0]) {
+ const char *week_text[7] = {"SU", "MO", "TU", "WE", "TH", "FR", "SA"};
- if (event->bysetpos)
- {
- int share, remind;
- int length2;
- char **t2 = NULL;
-
- t2 = g_strsplit(event->bysetpos, ",", -1);
- length2 = g_strv_length(t2);
- g_strfreev(t2);
-
- share = length / length2;
- remind = length % length2;
- count = count * share + (remind ? length : 0);
- DBG("share(%d) remind(%d)", share, remind);
- }
- else
- {
- count = count / length + ((count % length == 0) ? 0 : 1);
- DBG("length(%d)", length);
- }
- DBG("bycount(%d) count(%d)", event->count, count);
+ calendar_time_s *st = &event->start;
+ __set_time_to_ucal(event->system_type, ucal, st);
+ int week_nth = ucal_get(ucal, UCAL_DAY_OF_WEEK_IN_MONTH, &ec);
+ int dtstart_wday = ucal_get(ucal, UCAL_DAY_OF_WEEK, &ec);
+ char buf[32] = {0};
+ snprintf(buf, sizeof(buf), "%d%s", week_nth, week_text[dtstart_wday -1]);
+ DBG("set byday[%s]", buf);
+
+ t = g_strsplit_set(buf, " ,", -1);
+ byday_len = 1;
+
+ } else {
+ t = g_strsplit_set(event->byday, " ,", -1);
+ byday_len = g_strv_length(t);
}
+ DBG("[%s] byday_len(%d)", event->byday, byday_len);
- ud1 = ucal_getMillis(ucal, &ec);
+ int bysetpos[1024] = {0};
+ int bysetpos_len = 0;
+ __cal_db_instance_parse_byint(event->bysetpos, bysetpos, &bysetpos_len);
+ DBG("bysetpos len(%d)", bysetpos_len);
- for (i = 0; i < length; i++)
- {
- int yday = atoi(t[i]);
+ GList *l = NULL;
+ int exdate_len = 0;
+ __get_exdate_list(ucal, event, &l, &exdate_len);
+ DBG("exdate_len(%d)", exdate_len);
+
+ int loop = 0;
+ int count = 0;
+ bool is_exit = false;
+ long long int last_utime = 0;
+ long long int current_utime = 0;
+ while (false == is_exit)
+ {
+ calendar_time_s *st = &event->start;
+ __set_time_to_ucal(event->system_type, ucal, st);
+ long long int dtstart_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ ucal_add(ucal, UCAL_MONTH, event->interval * loop, &ec);
+ ucal_setMillis(ucal, ucal_getMillis(ucal, &ec), &ec); // set start point
+
+ int i, j, k;
+ if (strlen(t[0]) > 2) { // -3SU, +2SA
+ for (i = 0; i < byday_len; i++) {
+ if (0 == strlen(t[i])) continue;
+ // get nth, wday
+ int nth = 0;
+ char wday[32] = {0};
+
+ sscanf(t[i], "%d%s", &nth, wday); // -3SU, +2SA
+ DBG("nth(%d) wday[%s]", nth, wday);
+ int wday_int = __convert_wday_to_int(wday);
+
+ // set nth, wday
+ if (nth > 0) {
+ if (nth > 4) {
+ ucal_set(ucal, UCAL_DAY_OF_WEEK, wday_int);
+ ucal_set(ucal, UCAL_DAY_OF_WEEK_IN_MONTH, -1);
+
+ } else {
+ ucal_set(ucal, UCAL_DAY_OF_WEEK, wday_int);
+ ucal_set(ucal, UCAL_DAY_OF_WEEK_IN_MONTH, 1);
+ ucal_add(ucal, UCAL_WEEK_OF_YEAR, nth - 1, &ec);
+ }
+ } else {
+ ucal_set(ucal, UCAL_DAY_OF_WEEK, wday_int);
+ ucal_set(ucal, UCAL_DAY_OF_WEEK_IN_MONTH, nth);
+ }
+ if (false == __check_bysetpos(i, bysetpos, bysetpos_len, byday_len)) {
+ continue;
+ }
+ current_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ if (true == __check_before_dtstart(current_utime, dtstart_utime)) {
+ continue;
+ }
+ if (true == __check_exdate_to_skip(current_utime, exdate_len, &l)) {
+ count++;
+ continue;
+ }
+ is_exit = __check_out_of_range(current_utime, event, until_utime, &count);
+ if (true == is_exit) break;
+ __cal_db_instance_insert_record(ucal, duration, event);
+ }
- ucal_setMillis(ucal, ud1, &ec);
- ucal_set(ucal, UCAL_DAY_OF_YEAR, yday);
- DBG("yday is set(%d)", yday);
+ } else { // SU, SA: no week num: means all week:1TH,2TH,3TH.., so needs another byevent->system_typex
+ int week_bits = 0;
+ // if nowday in weekly
+ if (NULL == event->byday || '\0' == event->byday[0]) {
+ calendar_time_s *st = &event->start;
+ __set_time_to_ucal(event->system_type, ucal, st);
+ int dtstart_wday = ucal_get(ucal, UCAL_DAY_OF_WEEK, &ec);
+ week_bits |= (0x01 << (dtstart_wday - 1));
- // check whether set ucal goes past or not
- ud1 = ucal_getMillis(ucal, &ec);
+ } else {
+ week_bits = __convert_week_to_bits(event->byday, NULL);
+ }
+ DBG("week integer(0x%x)", week_bits);
+
+ if (bymonthday_len) { // bymonthday
+ for (j = 0; j < bymonthday_len; j++) {
+ ucal_set(ucal, UCAL_DATE, bymonthday[j]);
+ bool is_match_wday = false;
+ int w = ucal_get(ucal, UCAL_DAY_OF_WEEK, &ec);
+ for (k = 0; k < 7; k++) { // check if this is one of wday
+ if (week_bits & (0x01 << k)) {
+ if ((k + 1) == w) {
+ is_match_wday = true;
+ break;
+ }
+ }
+ }
+ if (false == is_match_wday) {
+ DBG("get wday(%d) != want wday(%d)", w, k + 1);
+ continue;
+ }
+ if (false == __check_bysetpos(j, bysetpos, bysetpos_len, bymonthday_len)) {
+ continue;
+ }
+ current_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ if (true == __check_before_dtstart(current_utime, dtstart_utime)) {
+ continue;
+ }
+ if (true == __check_exdate_to_skip(current_utime, exdate_len, &l)) {
+ count++;
+ continue;
+ }
+ is_exit = __check_out_of_range(current_utime, event, until_utime, &count);
+ if (true == is_exit) break;
+ __cal_db_instance_insert_record(ucal, duration, event);
+ }
- UCalendar *ucal2 = NULL;
- ucal2 = ucal_clone(ucal, &ec);
- __cal_db_instance_set_ucal_start(ucal2, &event->start);
- ud2 = ucal_getMillis(ucal2, &ec);
- ucal_close(ucal2);
+ } else {
+ int year = ucal_get(ucal, UCAL_YEAR, &ec);
+ int month = ucal_get(ucal, UCAL_MONTH, &ec) + 1;
- if (ms2sec(ud2) > ms2sec(ud1))
- {
- DBG("Invalid first time: start(%lld) get(%lld)", ms2sec(ud2), ms2sec(ud1));
- ucal_add(ucal, field, 1, &ec);
- }
+ ucal_set(ucal, UCAL_MONTH, month - 1);
+ ucal_set(ucal, UCAL_DATE, 1);
+ int byday_start = ucal_get(ucal, UCAL_DAY_OF_WEEK, &ec);
+
+ int dates_len = 0;
+ __get_dates_in_month(ucal, week_bits, month, &dates_len);
+ DBG("month(%d) dates_len (%d)", month, dates_len);
+
+ int index = -1;
+ for (j = 0; j < 6; j++) { // check weekno in month: max 6
+ for (k = 0; k < 7; k++) {
+ if (0 == (week_bits & (0x01 << ((byday_start -1 +k)%7)))) continue;
+ index++;
- DBG("range type(%d) interval(%d)", event->range_type, event->interval);
- switch (event->range_type)
- {
- case CALENDAR_RANGE_COUNT:
- for (j = 0; j < count; j++)
- {
- __cal_db_instance_insert_record(ucal, duration, event->start.type, event->index);
- ucal_add(ucal, field, event->interval, &ec);
- }
- break;
+ int wday_int = (byday_start -1 +k) %7 + 1;
+ ucal_set(ucal, UCAL_WEEK_OF_MONTH, (j + 1) + (byday_start -1 +k) / 7);
+ if (year != ucal_get(ucal, UCAL_YEAR, &ec)) ucal_set(ucal, UCAL_YEAR, year);
+ ucal_set(ucal, UCAL_MONTH, month - 1);
+ ucal_set(ucal, UCAL_DAY_OF_WEEK, wday_int);
- case CALENDAR_RANGE_UNTIL:
- case CALENDAR_RANGE_NONE:
- while (__cal_db_instance_has_next(ucal, until))
- {
- __cal_db_instance_insert_record(ucal, duration, event->start.type, event->index);
- ucal_add(ucal, field, event->interval, &ec);
+ int get_month = ucal_get(ucal, UCAL_MONTH, &ec) + 1;
+ if (month != get_month) { j = 6; break; }
+
+ if (false == __check_bysetpos(index, bysetpos, bysetpos_len, dates_len)) {
+ continue;
+ }
+ current_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ if (true == __check_before_dtstart(current_utime, dtstart_utime)) {
+ continue;
+ }
+ if (true == __check_exdate_to_skip(current_utime, exdate_len, &l)) {
+ count++;
+ continue;
+ }
+ is_exit = __check_out_of_range(current_utime, event, until_utime, &count);
+ if (true == is_exit) break;
+ __cal_db_instance_insert_record(ucal, duration, event);
+ }
+ if (true == is_exit) break;
+ }
}
- break;
}
+ if (true == is_exit) break;
+ current_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ is_exit = __check_to_stop_loop(current_utime, &last_utime, loop);
+ loop++;
}
g_strfreev(t);
-
+ if (l) g_list_free(l);
return CALENDAR_ERROR_NONE;
}
-static int __cal_db_instance_publish_record_yearly(UCalendar *ucal, cal_event_s *event, long long int duration, calendar_time_s *until)
+static int __cal_db_instance_publish_monthly_mday(UCalendar *ucal, cal_event_s *event, long long int duration)
{
- int i;
- char **t = NULL;
- const char *d = ",";
-
- if (NULL == ucal)
- {
- ERR("Invalid parameter: ucal is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (NULL == event)
- {
- ERR("Invalid parameter: event is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- __cal_db_instance_set_ucal_start(ucal, &event->start);
- __cal_db_instance_print_ucal(ucal);
-
- if (event->bymonth && strlen(event->bymonth) > 0)
- {
- // range: 1 ~ 12 ex> 1, 2, 4
- t = g_strsplit(event->bymonth, d, -1);
- if (!t) {
- ERR("g_strsplit failed");
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
+ retvm_if(NULL == ucal, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: ucal is NULL");
+ retvm_if(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: event is NULL");
- for (i = 0; t[i]; i++)
- {
- int month = atoi(t[i]);
- ucal_set(ucal, UCAL_MONTH, month -1);
+ UErrorCode ec = U_ZERO_ERROR;
+ calendar_time_s until = {0};
+ __get_until_from_range(event, &until);
+ __set_time_to_ucal(event->system_type, ucal, &until); // set until before dtstart_utime
+ long long int until_utime = ms2sec(ucal_getMillis(ucal, &ec));
+
+ // get bymonthday into array
+ int bymonthday[1024] = {0};
+ int bymonthday_len = 0;
+ __cal_db_instance_parse_byint(event->bymonthday, bymonthday, &bymonthday_len);
+ if (0 == bymonthday_len) {
+ calendar_time_s *st = &event->start;
+ __set_time_to_ucal(event->system_type, ucal, st);
+ int dtstart_mday = ucal_get(ucal, UCAL_DATE, &ec);
+ bymonthday[0] = dtstart_mday;
+ bymonthday_len = 1;
+ }
+ DBG("bymonthday_len(%d) [%s]", bymonthday_len, event->bymonthday);
+
+ int bysetpos[1024] = {0};
+ int bysetpos_len = 0;
+ __cal_db_instance_parse_byint(event->bysetpos, bysetpos, &bysetpos_len);
+ DBG("bysetpos_len(%d)", bysetpos_len);
+
+ GList *l = NULL;
+ int exdate_len = 0;
+ __get_exdate_list(ucal, event, &l, &exdate_len);
+ DBG("exdate_len(%d)", bysetpos_len);
+
+ int loop = 0;
+ int count = 0;
+ bool is_exit = false;
+ long long int last_utime = 0;
+ long long int current_utime = 0;
+ while (false == is_exit)
+ {
+ calendar_time_s *st = &event->start;
+ __set_time_to_ucal(event->system_type, ucal, st);
+ long long int dtstart_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ ucal_add(ucal, UCAL_MONTH, event->interval * loop, &ec);
+ ucal_setMillis(ucal, ucal_getMillis(ucal, &ec), &ec); // set start point
+
+ int i;
+ for (i = 0 ; i < bymonthday_len; i++) {
+ if (bymonthday[i] > 0) {
+ ucal_set(ucal, UCAL_MONTH, ucal_get(ucal, UCAL_MONTH, &ec));
+ ucal_set(ucal, UCAL_DATE, bymonthday[i]);
+ int get_mday = ucal_get(ucal, UCAL_DATE, &ec);
+ if (get_mday != bymonthday[i]) {
+ DBG("bymonthday(%d) but get (%d) from icu", bymonthday[i], get_mday);
+ continue;
+ }
+ } else if (bymonthday[i] < 0) {
+ // goto end of the month
+ ucal_set(ucal, UCAL_DATE, 1);
+ ucal_add(ucal, UCAL_MONTH, 1, &ec);
+ ucal_add(ucal, UCAL_DAY_OF_YEAR, bymonthday[i], &ec);
- if (event->byday && strlen(event->byday) > 0)
- {
- __cal_db_instance_publish_with_wday(ucal, event, duration, UCAL_YEAR, until);
+ } else { // 0 is invalid
+ DBG("Invalid bymonthday(%d)", bymonthday[i]);
+ continue;
}
- else if (event->bymonthday && strlen(event->bymonthday) > 0)
- {
- __cal_db_instance_publish_with_mday(ucal, event, duration, UCAL_YEAR, until);
+ if (false == __check_bysetpos(i, bysetpos, bysetpos_len, bymonthday_len)) {
+ continue;
}
- else
- {
- ERR("Not completed");
+ current_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ if (true == __check_before_dtstart(current_utime, dtstart_utime)) {
+ continue;
+ }
+ if (true == __check_exdate_to_skip(current_utime, exdate_len, &l)) {
+ count++;
+ continue;
}
+ is_exit = __check_out_of_range(current_utime, event, until_utime, &count);
+ if (true == is_exit) break;
+ __cal_db_instance_insert_record(ucal, duration, event);
}
- g_strfreev(t);
- }
- else if (event->byyearday && strlen(event->byyearday) > 0)
- {
- __cal_db_instance_publish_with_yday(ucal, event, duration, UCAL_YEAR, until);
-
+ if (true == is_exit) break;
+ current_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ is_exit = __check_to_stop_loop(current_utime, &last_utime, loop);
+ loop++;
}
- else if (event->byweekno && strlen(event->byweekno) > 0)
- {
- __cal_db_instance_publish_with_weekno(ucal, event, duration, UCAL_YEAR, until);
-
- // range: 1 ~ 53 or -53 ~ -1 ex> 1, 4
- t = g_strsplit(event->byweekno, d, -1);
- if (!t) {
- ERR("g_strsplit failed");
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
-
- for (i = 0; t[i]; i++)
- {
+ if (l) g_list_free(l);
+ return CALENDAR_ERROR_NONE;
+}
- }
+static int __cal_db_instance_publish_record_monthly(UCalendar *ucal, cal_event_s *event, long long int duration)
+{
+ retvm_if(NULL == ucal, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter:ucal is NULL");
+ retvm_if(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: event is NULL");
- g_strfreev(t);
- }
- else
- {
- UErrorCode ec = U_ZERO_ERROR;
- int month = ucal_get(ucal, UCAL_MONTH, &ec) + 1;
- DBG("No bymonth, so set start time month(%d)", month);
+ if (event->byday && strlen(event->byday) > 0) {
+ __cal_db_instance_publish_monthly_wday(ucal, event, duration);
- if (event->byday && strlen(event->byday) > 0)
- {
- __cal_db_instance_publish_with_wday(ucal, event, duration, UCAL_YEAR, until);
- }
- else
- {
- __cal_db_instance_publish_with_mday(ucal, event, duration, UCAL_YEAR, until);
- }
+ } else {
+ __cal_db_instance_publish_monthly_mday(ucal, event, duration);
}
-
return CALENDAR_ERROR_NONE;
}
-static int __cal_db_instance_publish_record_monthly(UCalendar *ucal, cal_event_s *event, long long int duration, calendar_time_s *until)
+static int __cal_db_instance_publish_weekly_wday(UCalendar *ucal, cal_event_s *event, long long int duration)
{
- if (NULL == ucal)
- {
- ERR("Invalid parameter: ucal is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (NULL == event)
- {
- ERR("Invalid parameter: event is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
+ retvm_if(NULL == ucal, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: ucal is NULL");
+ retvm_if(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: event is NULL");
- __cal_db_instance_set_ucal_start(ucal, &event->start);
- __cal_db_instance_print_ucal(ucal);
+ UErrorCode ec = U_ZERO_ERROR;
+ calendar_time_s until = {0};
+ __get_until_from_range(event, &until);
+ __set_time_to_ucal(event->system_type, ucal, &until); // set until before dtstart_utime
+ long long int until_utime = ms2sec(ucal_getMillis(ucal, &ec));
+
+ int week_bits = 0;
+ int byday_len = 0;
+ // if nowday in weekly
+ if (NULL == event->byday || '\0' == event->byday[0]) {
+ calendar_time_s *st = &event->start;
+ __set_time_to_ucal(event->system_type, ucal, st);
+ int dtstart_wday = ucal_get(ucal, UCAL_DAY_OF_WEEK, &ec);
+ week_bits |= (0x01 << (dtstart_wday - 1));
- if (event->byday && strlen(event->byday) > 0)
- {
- __cal_db_instance_publish_with_wday(ucal, event, duration, UCAL_MONTH, until);
- }
- else
- {
- // bymonthday or none
- __cal_db_instance_publish_with_mday(ucal, event, duration, UCAL_MONTH, until);
+ } else {
+ week_bits = __convert_week_to_bits(event->byday, &byday_len);
}
+ DBG("week integer(0x%x)", week_bits);
+
+ int bysetpos[1024] = {0};
+ int bysetpos_len = 0;
+ __cal_db_instance_parse_byint(event->bysetpos, bysetpos, &bysetpos_len);
+ DBG("bysetpos len(%d)", bysetpos_len);
+
+ GList *l = NULL;
+ int exdate_len = 0;
+ __get_exdate_list(ucal, event, &l, &exdate_len);
+
+ int byday_start = ucal_getAttribute(ucal, UCAL_FIRST_DAY_OF_WEEK);
+ DBG("get first day of week(%d)", byday_start);
+
+ int loop = 0;
+ int count = 0;
+ bool is_exit = false;
+ long long int last_utime = 0;
+ long long int current_utime = 0;
+ while (false == is_exit)
+ {
+ calendar_time_s *st = &event->start;
+ __set_time_to_ucal(event->system_type, ucal, st);
+ long long int dtstart_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ ucal_add(ucal, UCAL_WEEK_OF_YEAR, event->interval *loop, &ec);
+ ucal_setMillis(ucal, ucal_getMillis(ucal, &ec), &ec); // set start point
+
+ int i;
+ int index = -1;
+ for (i = 0; i < 7; i++) {
+ if (0 == (week_bits & (0x01 << ((byday_start -1 +i)%7)))) continue;
+ index++;
+
+ int wday_int = (byday_start -1 +i) %7 + 1;
+ ucal_set(ucal, UCAL_DAY_OF_WEEK, wday_int);
+ if (false == __check_bysetpos(index, bysetpos, bysetpos_len, byday_len)) {
+ continue;
+ }
+ current_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ if (true == __check_before_dtstart(current_utime, dtstart_utime)) {
+ continue;
+ }
+ if (true == __check_exdate_to_skip(current_utime, exdate_len, &l)) {
+ count++;
+ continue;
+ }
+ is_exit = __check_out_of_range(current_utime, event, until_utime, &count);
+ if (true == is_exit) break;
+ __cal_db_instance_insert_record(ucal, duration, event);
+ }
+ if (true == is_exit) break;
+ current_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ is_exit = __check_to_stop_loop(current_utime, &last_utime, loop);
+ loop++;
+ }
+ if (l) g_list_free(l);
return CALENDAR_ERROR_NONE;
}
-static int __cal_db_instance_publish_record_weekly(UCalendar *ucal, cal_event_s *event, long long int duration, calendar_time_s *until)
+static int __cal_db_instance_publish_record_weekly(UCalendar *ucal, cal_event_s *event, long long int duration)
{
- if (NULL == ucal)
- {
- ERR("Invalid parameter: ucal is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (NULL == event)
- {
- ERR("Invalid parameter: event is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- __cal_db_instance_set_ucal_start(ucal, &event->start);
- __cal_db_instance_publish_with_wday(ucal, event, duration, UCAL_WEEK_OF_YEAR, until);
+ retvm_if(NULL == ucal, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter:ucal is NULL");
+ retvm_if(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: event is NULL");
+ __cal_db_instance_publish_weekly_wday(ucal, event, duration);
return CALENDAR_ERROR_NONE;
}
-static int __cal_db_instance_publish_record_daily(UCalendar *ucal, cal_event_s *event, long long int duration, calendar_time_s *until)
+static int __cal_db_instance_publish_daily_mday(UCalendar *ucal, cal_event_s *event, long long int duration)
{
- if (NULL == ucal)
- {
- ERR("Invalid parameter: ucal is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (NULL == event)
- {
- ERR("Invalid parameter: event is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
+ retvm_if(NULL == ucal, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: ucal is NULL");
+ retvm_if(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: event is NULL");
- __cal_db_instance_set_ucal_start(ucal, &event->start);
- __cal_db_instance_print_ucal(ucal);
+ UErrorCode ec = U_ZERO_ERROR;
+ calendar_time_s until = {0};
+ __get_until_from_range(event, &until);
+ __set_time_to_ucal(event->system_type, ucal, &until); // set until before dtstart_utime
+ long long int until_utime = ms2sec(ucal_getMillis(ucal, &ec));
- __cal_db_instance_publish_with_mday(ucal, event, duration, UCAL_DATE, until);
+ // get bymonth into array
+ int bymonth[12] = {0};
+ int bymonth_len = 0;
+ __cal_db_instance_parse_byint(event->bymonth, bymonth, &bymonth_len);
- return CALENDAR_ERROR_NONE;
-}
+ GList *l = NULL;
+ int exdate_len = 0;
+ __get_exdate_list(ucal, event, &l, &exdate_len);
-static int __cal_db_instance_publish_record_once(UCalendar *ucal, cal_event_s *event, long long int duration, calendar_time_s *until)
-{
- if (NULL == ucal)
- {
- ERR("Invalid parameter: ucal is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (NULL == event)
+ calendar_time_s *st = &event->start;
+ __set_time_to_ucal(event->system_type, ucal, st);
+ long long int dtstart_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ DBG("(%lld)", ms2sec(ucal_getMillis(ucal, &ec)));
+
+ int loop = 0;
+ int count = 0;
+ bool is_exit = false;
+ long long int last_utime = 0;
+ long long int current_utime = 0;
+ int log_value = 0;
+ while (false == is_exit)
{
- ERR("Invalid parameter: event is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
+ if (loop) ucal_add(ucal, UCAL_DAY_OF_YEAR, event->interval, &ec);
+
+ if (true == __check_daily_bymonth_to_skip(ucal, bymonth, bymonth_len, &log_value)) {
+ if (0 == loop) loop = 1;
+ continue;
+ }
+ current_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ if (true == __check_before_dtstart(current_utime, dtstart_utime)) {
+ if (0 == loop) loop = 1;
+ continue;
+ }
+ if (true == __check_exdate_to_skip(current_utime, exdate_len, &l)) {
+ if (0 == loop) loop = 1;
+ count++;
+ continue;
+ }
+ is_exit = __check_out_of_range(current_utime, event, until_utime, &count);
+ if (true == is_exit) break;
+ __cal_db_instance_insert_record(ucal, duration, event);
+
+ current_utime = ms2sec(ucal_getMillis(ucal, &ec));
+ is_exit = __check_to_stop_loop(current_utime, &last_utime, loop);
+ loop++;
}
+ if (l) g_list_free(l);
+ return CALENDAR_ERROR_NONE;
+}
- __cal_db_instance_set_ucal_start(ucal, &event->start);
- __cal_db_instance_print_ucal(ucal);
+static int __cal_db_instance_publish_record_daily(UCalendar *ucal, cal_event_s *event, long long int duration)
+{
+ retvm_if(NULL == ucal, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter:ucal is NULL");
+ retvm_if(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: event is NULL");
- event->interval = 1;
- event->count = 1;
- event->range_type = CALENDAR_RANGE_COUNT;
+ __cal_db_instance_publish_daily_mday(ucal, event, duration);
+ return CALENDAR_ERROR_NONE;
+}
- // start:for exception record which has original_event_id, mod freq 0
+static int __cal_db_instance_publish_record_once(UCalendar *ucal, cal_event_s *event, long long int duration)
+{
+ retvm_if(NULL == ucal, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter:ucal is NULL");
+ retvm_if(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: event is NULL");
- __cal_db_instance_publish_with_mday(ucal, event, duration, UCAL_DATE, until);
+ calendar_time_s *st = &event->start;
+ __set_time_to_ucal(event->system_type, ucal, st);
+ __cal_db_instance_insert_record(ucal, duration, event);//event->start.type, event->index);
return CALENDAR_ERROR_NONE;
}
static int __cal_db_instance_publish_record_details(UCalendar *ucal, cal_event_s *event)
{
- if (NULL == ucal)
- {
- ERR("Invalid parameter: ucal is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (NULL == event)
- {
- ERR("Invalid parameter: event is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
+ retvm_if(NULL == ucal, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter:ucal is NULL");
+ retvm_if(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: event is NULL");
long long int duration = -1;
- int exception_freq; // for exception
- long long int range = 0;
- calendar_time_s until = {0};
+ int exception_freq = 0; // for exception
__cal_db_instance_get_duration(ucal, &event->start, &event->end, &duration);
+ warn_if (duration < 0, "Invalid duration (%lld)", duration);
if (event->original_event_id > 0)
{
event->interval = 1;
}
- switch (event->range_type)
- {
- case CALENDAR_RANGE_COUNT:
- DBG("range count");
- break;
-
- case CALENDAR_RANGE_UNTIL:
- DBG("range until");
- until.type = event->until_type;
- switch (until.type)
- {
- case CALENDAR_TIME_UTIME:
- range = _cal_time_convert_itol(NULL, CAL_ENDLESS_LIMIT_YEAR,
- CAL_ENDLESS_LIMIT_MONTH, CAL_ENDLESS_LIMIT_MDAY,
- 0, 0, 0);
- if (event->until_utime > range)
- {
- DBG("until time(%lld) > max, so set max(%lld)", event->until_utime, range);
- until.time.utime = range;
- }
- else
- {
- until.time.utime = event->until_utime;
- }
- break;
-
- case CALENDAR_TIME_LOCALTIME:
- until.time.date.year = event->until_year;
- until.time.date.month = event->until_month;
- until.time.date.mday = event->until_mday;
- break;
- }
- break;
-
- case CALENDAR_RANGE_NONE:
- DBG("range none");
- until.type = event->until_type;
- switch (until.type)
- {
- case CALENDAR_TIME_UTIME:
- until.time.utime = _cal_time_convert_itol(event->start_tzid,
- CAL_ENDLESS_LIMIT_YEAR,
- CAL_ENDLESS_LIMIT_MONTH,
- CAL_ENDLESS_LIMIT_MDAY,
- 0, 0, 0);
- break;
- case CALENDAR_TIME_LOCALTIME:
- until.time.date.year = CAL_ENDLESS_LIMIT_YEAR;
- until.time.date.month = CAL_ENDLESS_LIMIT_MONTH;
- until.time.date.mday = CAL_ENDLESS_LIMIT_MDAY;
- break;
- }
- break;
- }
-
switch (event->freq)
{
case CALENDAR_RECURRENCE_YEARLY:
- __cal_db_instance_publish_record_yearly(ucal, event, duration, &until);
+ __cal_db_instance_publish_record_yearly(ucal, event, duration);
break;
case CALENDAR_RECURRENCE_MONTHLY:
- __cal_db_instance_publish_record_monthly(ucal, event, duration, &until);
+ __cal_db_instance_publish_record_monthly(ucal, event, duration);
break;
case CALENDAR_RECURRENCE_WEEKLY:
- __cal_db_instance_publish_record_weekly(ucal, event, duration, &until);
+ __cal_db_instance_publish_record_weekly(ucal, event, duration);
break;
case CALENDAR_RECURRENCE_DAILY:
- __cal_db_instance_publish_record_daily(ucal, event, duration, &until);
+ __cal_db_instance_publish_record_daily(ucal, event, duration);
break;
case CALENDAR_RECURRENCE_NONE:
default:
- __cal_db_instance_publish_record_once(ucal, event, duration, &until);
+ __cal_db_instance_publish_record_once(ucal, event, duration);
break;
-
- }
-
- if (event->bysetpos)
- {
- __cal_db_instance_apply_setpos(event->index, &event->start, event, event->freq);
}
if (event->original_event_id > 0)
return CALENDAR_ERROR_NONE;
}
-int _cal_db_instance_publish_record(calendar_record_h record)
+int _cal_db_instance_update_exdate_del(int id, char *exdate)
{
- cal_event_s *event;
+ int dbret;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ char **t = NULL;
+ char *p = NULL;
- if (NULL == record)
+ if (exdate == NULL || strlen(exdate) == 0)
{
- ERR("Invalid argument: record is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
+ DBG("Nothing to update exdate del");
+ return CALENDAR_ERROR_NONE;
}
- event = (cal_event_s *)(record);
+ DBG("exdate[%s]", exdate);
+ t = g_strsplit_set(exdate, " ,", -1);
+ if (!t)
+ {
+ ERR("g_strsplit_set failed");
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
- DBG("Start");
- __cal_db_instance_print_caltime(&event->start);
- DBG("End");
- __cal_db_instance_print_caltime(&event->end);
+ int i;
+ for (i = 0; t[i]; i++) {
+ if (NULL == t[i] || '\0' == *t[i]) continue;
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
- UCalendar *ucal = NULL;
- switch (event->start.type)
- {
- case CALENDAR_TIME_UTIME:
- ucal = _cal_time_get_ucal(event->start_tzid, event->wkst);
- break;
+ p = t[i];
+ DBG("exdate[%s]", p);
+ int len = strlen(p);
+ switch (len)
+ {
+ case 8: // 20141212
+ DBG("ALLDAY instance");
+ sscanf(p, "%04d%02d%02d", &y, &m, &d);
+ snprintf(query, sizeof(query), "DELETE FROM %s "
+ "WHERE event_id = %d AND dtstart_datetime = '%04d-%02d-%02dT%02d:%02d:%02d' ",
+ CAL_TABLE_ALLDAY_INSTANCE, id, y, m, d, h, n, s);
+ break;
- case CALENDAR_TIME_LOCALTIME:
- ucal = _cal_time_get_ucal(NULL, event->wkst);
- break;
+ case 15: // 20141212T000000
+ sscanf(p, "%04d%02d%02dT%02d%02d%02d", &y, &m, &d, &h, &n, &s);
+ snprintf(query, sizeof(query), "DELETE FROM %s "
+ "WHERE event_id = %d AND dtstart_datetime = '%04d-%02d-%02dT%02d:%02d:%02d' ",
+ CAL_TABLE_ALLDAY_INSTANCE, id, y, m, d, h, n, s);
+ DBG("localtime instance");
+ break;
+
+ case 16: // 20141212T000000Z
+ sscanf(p, "%04d%02d%02dT%02d%02d%02dZ", &y, &m, &d, &h, &n, &s);
+ snprintf(query, sizeof(query), "DELETE FROM %s "
+ "WHERE event_id = %d AND dtstart_utime = %lld ",
+ CAL_TABLE_NORMAL_INSTANCE, id, _cal_time_convert_itol(NULL, y, m, d, h, n, s));
+ DBG("normal instance (%lld)", _cal_time_convert_itol(NULL, y, m, d, h, n, s));
+ break;
+ }
+
+ dbret = _cal_db_util_query_exec(query);
+ if (dbret != CAL_DB_OK) {
+ ERR("[%s]", query);
+ ERR("_cal_db_util_query_exec() failed (%d)", dbret);
+ g_strfreev(t);
+ switch (dbret)
+ {
+ case CAL_DB_ERROR_NO_SPACE:
+ return CALENDAR_ERROR_FILE_NO_SPACE;
+ default:
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
}
+ g_strfreev(t);
+ return CALENDAR_ERROR_NONE;
+}
+
+int _cal_db_instance_publish_record(calendar_record_h record)
+{
+ retvm_if(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid argument: record is NULL");
+
+ cal_event_s *event = NULL;
+ event = (cal_event_s *)(record);
+
+ UCalendar *ucal = _cal_time_open_ucal(event->system_type,
+ event->start.type == CALENDAR_TIME_UTIME ? event->start_tzid : NULL,
+ event->wkst);
__cal_db_instance_publish_record_details(ucal, event);
__cal_db_instance_del_inundant(event->index, &event->start, event);
- __cal_db_instance_update_exdate_del(event->index, event->exdate);
__cal_db_instance_update_exdate_mod(event->original_event_id, event->recurrence_id);
ucal_close(ucal);
return CALENDAR_ERROR_NONE;
}
-int _cal_db_instance_discard_record(calendar_record_h record)
+int _cal_db_instance_discard_record(int index)
{
char query[CAL_DB_SQL_MAX_LEN] = {0};
- cal_db_util_error_e dbret = CAL_DB_OK;
- cal_event_s *event;
-
- event = (cal_event_s *)(record);
- if (event == NULL) {
- ERR("Invalid argument: cal_event_s is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
+ cal_db_util_error_e dbret = CAL_DB_OK;
DBG("delete normal");
snprintf(query, sizeof(query), "DELETE FROM %s WHERE event_id = %d ",
- CAL_TABLE_NORMAL_INSTANCE, event->index);
+ CAL_TABLE_NORMAL_INSTANCE, index);
dbret = _cal_db_util_query_exec(query);
if (CAL_DB_OK != dbret)
DBG("delete allday");
snprintf(query, sizeof(query), "DELETE FROM %s WHERE event_id = %d ",
- CAL_TABLE_ALLDAY_INSTANCE, event->index);
+ CAL_TABLE_ALLDAY_INSTANCE, index);
dbret = _cal_db_util_query_exec(query);
if (CAL_DB_OK != dbret)
return CALENDAR_ERROR_DB_FAILED;
}
}
-
return CALENDAR_ERROR_NONE;
}
#define __CALENDAR_SVC_DB_INSTANCE_H__
int _cal_db_instance_publish_record(calendar_record_h record);
-int _cal_db_instance_discard_record(calendar_record_h record);;
+int _cal_db_instance_discard_record(int index);
int _cal_db_instance_get_now(long long int *current);
+int _cal_db_instance_update_exdate_del(int id, char *exdate);
#endif // __CALENDAR_SVC_DB_INSTANCE_H__
--- /dev/null
+/*
+ * Calendar Service
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "cal_typedef.h"
+#include "cal_db.h"
+#include "cal_db_util.h"
+#include "cal_internal.h"
+#include "calendar_errors.h"
+#include "cal_db_instance_helper.h"
+
+int _cal_db_instance_normal_insert_record(cal_instance_normal_s *normal, int* id)
+{
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ retvm_if(NULL == normal, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid argument: cal_instance_normal_s is NULL");
+
+ snprintf(query, sizeof(query),
+ "INSERT INTO %s ("
+ "event_id, "
+ "dtstart_utime, dtend_utime"
+ ") VALUES ( "
+ "%d, "
+ "%lld, %lld) ",
+ CAL_TABLE_NORMAL_INSTANCE,
+ normal->event_id,
+ normal->start.time.utime, normal->end.time.utime);
+
+ cal_db_util_error_e dbret = CAL_DB_OK;
+ dbret = _cal_db_util_query_exec(query);
+ if (dbret != CAL_DB_OK) {
+ ERR("_cal_db_util_query_exec() failed (%d)", dbret);
+ switch (dbret) {
+ case CAL_DB_ERROR_NO_SPACE:
+ return CALENDAR_ERROR_FILE_NO_SPACE;
+ default:
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ if (id) *id = _cal_db_util_last_insert_id();
+
+ return CALENDAR_ERROR_NONE;
+}
+
+int _cal_db_instance_allday_insert_record(cal_instance_allday_s *allday, int* id)
+{
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ retvm_if(NULL == allday, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid argument: cal_instance_allday_s is NULL");
+
+ snprintf(query, sizeof(query),
+ "INSERT INTO %s ("
+ "event_id, "
+ "dtstart_datetime, dtend_datetime"
+ ") VALUES ( "
+ "%d, "
+ "'%04d-%02d-%02dT%02d:%02d:%02d', '%04d-%02d-%02dT%02d:%02d:%02d') ",
+ CAL_TABLE_ALLDAY_INSTANCE,
+ allday->event_id,
+ allday->start.time.date.year, allday->start.time.date.month, allday->start.time.date.mday,
+ allday->start.time.date.hour, allday->start.time.date.minute, allday->start.time.date.second,
+ allday->end.time.date.year, allday->end.time.date.month, allday->end.time.date.mday,
+ allday->end.time.date.hour, allday->end.time.date.minute, allday->end.time.date.second);
+
+ cal_db_util_error_e dbret = CAL_DB_OK;
+ dbret = _cal_db_util_query_exec(query);
+ if (dbret != CAL_DB_OK) {
+ ERR("_cal_db_util_query_exec() failed (%d)", dbret);
+ switch (dbret) {
+ case CAL_DB_ERROR_NO_SPACE:
+ return CALENDAR_ERROR_FILE_NO_SPACE;
+ default:
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ if (id) *id = _cal_db_util_last_insert_id();
+
+ return CALENDAR_ERROR_NONE;
+}
+
+int _cal_db_instance_helper_insert_utime_instance(int event_id, long long int s, long long int e)
+{
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ snprintf(query, sizeof(query), "INSERT INTO %s (event_id, dtstart_utime, dtend_utime) "
+ "VALUES ( %d, %lld, %lld) ", CAL_TABLE_NORMAL_INSTANCE, event_id, s, e);
+
+ cal_db_util_error_e dbret = CAL_DB_OK;
+ dbret = _cal_db_util_query_exec(query);
+ if (dbret != CAL_DB_OK) {
+ ERR("_cal_db_util_query_exec() failed (%d)", dbret);
+ switch (dbret) {
+ case CAL_DB_ERROR_NO_SPACE:
+ return CALENDAR_ERROR_FILE_NO_SPACE;
+ default:
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int _cal_db_instance_helper_insert_localtime_instance(int event_id, const char *s, const char *e)
+{
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ snprintf(query, sizeof(query), "INSERT INTO %s (event_id, dtstart_datetime, dtend_datetime) "
+ "VALUES ( %d, '%s', '%s') ", CAL_TABLE_ALLDAY_INSTANCE, event_id, s, e);
+
+ cal_db_util_error_e dbret = CAL_DB_OK;
+ dbret = _cal_db_util_query_exec(query);
+ if (dbret != CAL_DB_OK) {
+ ERR("_cal_db_util_query_exec() failed (%d)", dbret);
+ switch (dbret) {
+ case CAL_DB_ERROR_NO_SPACE:
+ return CALENDAR_ERROR_FILE_NO_SPACE;
+ default:
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
--- /dev/null
+/*
+ * Calendar Service
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __CALENDAR_SVC_DB_INSTANCE_HELPER_H__
+#define __CALENDAR_SVC_DB_INSTANCE_HELPER_H__
+
+int _cal_db_instance_normal_insert_record(cal_instance_normal_s *normal, int* id);
+int _cal_db_instance_allday_insert_record(cal_instance_allday_s *normal, int* id);
+
+#endif // __CALENDAR_SVC_DB_INSTANCE_HELPER_H__
--- /dev/null
+/*
+ * Calendar Service
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdlib.h>
+#ifdef CAL_NATIVE
+#include <alarm.h>
+#endif
+
+#include "calendar_db.h"
+
+#include "cal_internal.h"
+#include "cal_typedef.h"
+#include "cal_view.h"
+#include "cal_time.h"
+#include "cal_record.h"
+
+#include "cal_db_util.h"
+#include "cal_db.h"
+#include "cal_db_query.h"
+#include "cal_db_instance.h"
+#include "cal_db_alarm.h"
+
+//static int __cal_db_alarm_get_record(int id, calendar_record_h* out_record);
+static int __cal_db_alarm_get_all_records(int offset, int limit, calendar_list_h* out_list);
+static int __cal_db_alarm_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* out_list);
+static int __cal_db_alarm_get_count(int *out_count);
+static int __cal_db_alarm_get_count_with_query(calendar_query_h query, int *out_count);
+
+cal_db_plugin_cb_s _cal_db_alarm_plugin_cb = {
+ .is_query_only = false,
+ .insert_record=NULL,
+ .get_record=NULL, //__cal_db_alarm_get_record,
+ .update_record=NULL,
+ .delete_record=NULL,
+ .get_all_records=__cal_db_alarm_get_all_records,
+ .get_records_with_query=__cal_db_alarm_get_records_with_query,
+ .insert_records=NULL,
+ .update_records=NULL,
+ .delete_records=NULL,
+ .get_count=__cal_db_alarm_get_count,
+ .get_count_with_query=__cal_db_alarm_get_count_with_query,
+ .replace_record=NULL,
+ .replace_records=NULL
+};
+
+static void __cal_db_alarm_get_stmt(sqlite3_stmt *stmt,calendar_record_h record)
+{
+ cal_alarm_s *alarm = NULL;
+ int index;
+ const unsigned char *temp;
+
+ alarm = (cal_alarm_s*)(record);
+
+ index = 0;
+ alarm->id = sqlite3_column_int(stmt, index++);
+ alarm->parent_id = sqlite3_column_int(stmt, index++);
+ alarm->remind_tick = sqlite3_column_int(stmt, index++);
+ alarm->remind_tick_unit = sqlite3_column_int(stmt, index++);
+
+ temp = sqlite3_column_text(stmt, index++);
+ alarm->alarm_description = SAFE_STRDUP(temp);
+
+ alarm->alarm.type = sqlite3_column_int(stmt, index++);
+
+ temp = sqlite3_column_text(stmt, index++);
+ alarm->alarm_summary = SAFE_STRDUP(temp);
+
+ alarm->alarm_action = sqlite3_column_int(stmt, index++);
+
+ temp = sqlite3_column_text(stmt, index++);
+ alarm->alarm_attach = SAFE_STRDUP(temp);
+
+ if (alarm->alarm.type == CALENDAR_TIME_UTIME)
+ {
+ alarm->alarm.time.utime = sqlite3_column_int64(stmt,index++);
+ index++; // datetime
+ }
+ else
+ {
+ index++; // utime
+ temp = sqlite3_column_text(stmt, index++);
+ if (temp) {
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
+ switch (strlen((const char *)temp))
+ {
+ case 8:
+ sscanf((const char *)temp, "%04d%02d%02d", &y, &m, &d);
+ alarm->alarm.time.date.year = y;
+ alarm->alarm.time.date.month = m;
+ alarm->alarm.time.date.mday = d;
+ break;
+
+ case 15:
+ sscanf((const char *)temp, "%04d%02d%02dT%02d%02d%02d", &y, &m, &d, &h, &n, &s);
+ alarm->alarm.time.date.year = y;
+ alarm->alarm.time.date.month = m;
+ alarm->alarm.time.date.mday = d;
+ alarm->alarm.time.date.hour = h;
+ alarm->alarm.time.date.minute = n;
+ alarm->alarm.time.date.second = s;
+ break;
+ }
+ }
+ }
+}
+
+static int __cal_db_alarm_get_all_records(int offset, int limit, calendar_list_h* out_list )
+{
+ int ret = CALENDAR_ERROR_NONE;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ char offsetquery[CAL_DB_SQL_MAX_LEN] = {0};
+ char limitquery[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+
+ retvm_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ ret = calendar_list_create(out_list);
+
+ retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ if (offset > 0) {
+ snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
+ }
+ if (limit > 0) {
+ snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
+ }
+ snprintf(query, sizeof(query),
+ "SELECT rowid, "
+ "event_id, "
+ "remind_tick,"
+ "remind_tick_unit, "
+ "alarm_description, "
+ "alarm_type, "
+ "alarm_summary, "
+ "alarm_action, "
+ "alarm_attach, "
+ "alarm_utime, "
+ "alarm_datetime "
+ "FROM %s %s %s ",
+ CAL_TABLE_ALARM,limitquery,offsetquery);
+
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt) {
+ ERR("_cal_db_util_query_prepare() Failed");
+ calendar_list_destroy(*out_list, true);
+ *out_list = NULL;
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
+ calendar_record_h record = NULL;
+ // stmt -> record
+ ret = calendar_record_create(_calendar_alarm._uri,&record);
+ if( ret != CALENDAR_ERROR_NONE ) {
+ calendar_list_destroy(*out_list, true);
+ *out_list = NULL;
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+ __cal_db_alarm_get_stmt(stmt,record);
+
+ ret = calendar_list_add(*out_list,record);
+ if( ret != CALENDAR_ERROR_NONE ) {
+ calendar_list_destroy(*out_list, true);
+ *out_list = NULL;
+ calendar_record_destroy(record, true);
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+ }
+ sqlite3_finalize(stmt);
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static void __cal_db_alarm_get_property_stmt(sqlite3_stmt *stmt,
+ unsigned int property, int *stmt_count, calendar_record_h record)
+{
+ cal_alarm_s *alarm = NULL;
+ const unsigned char *temp;
+
+ alarm = (cal_alarm_s*)(record);
+
+ switch(property) {
+ case CAL_PROPERTY_ALARM_TICK:
+ alarm->remind_tick = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_ALARM_TICK_UNIT:
+ alarm->remind_tick_unit = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_ALARM_DESCRIPTION:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ alarm->alarm_description = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_ALARM_PARENT_ID:
+ alarm->parent_id = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_ALARM_SUMMARY:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ alarm->alarm_summary = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_ALARM_ACTION:
+ alarm->alarm_action = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_ALARM_ATTACH:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ alarm->alarm_attach = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_ALARM_ALARM:
+ alarm->alarm.type = sqlite3_column_int(stmt, *stmt_count);
+ if (alarm->alarm.type == CALENDAR_TIME_UTIME) {
+ *stmt_count = *stmt_count+1;
+ alarm->alarm.time.utime = sqlite3_column_int64(stmt, *stmt_count);
+ *stmt_count = *stmt_count+1; // datetime
+
+ } else {
+ *stmt_count = *stmt_count+1; // utime
+ *stmt_count = *stmt_count+1;
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ if (temp) {
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
+ switch (strlen((const char *)temp))
+ {
+ case 8:
+ sscanf((const char *)temp, "%04d%02d%02d", &y, &m, &d);
+ alarm->alarm.time.date.year = y;
+ alarm->alarm.time.date.month = m;
+ alarm->alarm.time.date.mday = d;
+ break;
+
+ case 15:
+ sscanf((const char *)temp, "%04d%02d%02dT%02d%02d%02d", &y, &m, &d, &h, &n, &s);
+ alarm->alarm.time.date.year = y;
+ alarm->alarm.time.date.month = m;
+ alarm->alarm.time.date.mday = d;
+ alarm->alarm.time.date.hour = h;
+ alarm->alarm.time.date.minute = n;
+ alarm->alarm.time.date.second = s;
+ break;
+ }
+ }
+ }
+ break;
+ default:
+ sqlite3_column_int(stmt, *stmt_count);
+ break;
+ }
+
+ *stmt_count = *stmt_count+1;
+}
+
+static void __cal_db_alarm_get_projection_stmt(sqlite3_stmt *stmt,
+ const unsigned int *projection, const int projection_count,
+ calendar_record_h record)
+{
+ int i=0;
+ int stmt_count = 0;
+
+ for(i=0;i<projection_count;i++)
+ __cal_db_alarm_get_property_stmt(stmt,projection[i],&stmt_count,record);
+}
+
+static int __cal_db_alarm_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* out_list )
+{
+ cal_query_s *que = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ char *condition = NULL;
+ char *projection = NULL;
+ char *order = NULL;
+ GSList *bind_text = NULL, *cursor = NULL;
+ char *query_str = NULL;
+ sqlite3_stmt *stmt = NULL;
+ int i = 0;
+ char *table_name;
+
+ que = (cal_query_s *)query;
+
+ if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_ALARM)) {
+ table_name = SAFE_STRDUP(CAL_TABLE_ALARM);
+ }
+ else {
+ ERR("uri(%s) not support get records with query",que->view_uri);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ //table_name = SAFE_STRDUP(CAL_TABLE_NORMAL_INSTANCE);
+ }
+
+ // make filter
+ if (que->filter) {
+ ret = _cal_db_query_create_condition(query, &condition, &bind_text);
+ if (ret != CALENDAR_ERROR_NONE) {
+ CAL_FREE(table_name);
+ ERR("filter create fail");
+ return ret;
+ }
+ }
+
+ // make projection
+ ret = _cal_db_query_create_projection(query, &projection);
+
+ // query - projection
+ if (projection) {
+ _cal_db_append_string(&query_str, "SELECT");
+ _cal_db_append_string(&query_str, projection);
+ _cal_db_append_string(&query_str, "FROM");
+ _cal_db_append_string(&query_str, table_name);
+ CAL_FREE(projection);
+ }
+ else {
+ _cal_db_append_string(&query_str,
+ "SELECT rowid, "
+ "event_id, "
+ "remind_tick,"
+ "remind_tick_unit, "
+ "alarm_description, "
+ "alarm_type, "
+ "alarm_summary, "
+ "alarm_action, "
+ "alarm_attach, "
+ "alarm_utime, "
+ "alarm_datetime "
+ "FROM ");
+ _cal_db_append_string(&query_str, table_name);
+ }
+ CAL_FREE(table_name);
+
+ // query - condition
+ if (condition) {
+ _cal_db_append_string(&query_str, "WHERE");
+ _cal_db_append_string(&query_str, condition);
+ CAL_FREE(condition);
+ }
+
+ // ORDER
+ ret = _cal_db_query_create_order(query, condition, &order);
+ if (order) {
+ _cal_db_append_string(&query_str, order);
+ CAL_FREE(order);
+ }
+
+ char buf[32] = {0};
+ if (0 < limit) {
+ snprintf(buf, sizeof(buf), "LIMIT %d", limit);
+ _cal_db_append_string(&query_str, buf);
+ if (0 < offset) {
+ snprintf(buf, sizeof(buf), "OFFSET %d", offset);
+ _cal_db_append_string(&query_str, buf);
+ }
+ }
+
+ // query
+ stmt = _cal_db_util_query_prepare(query_str);
+ if (NULL == stmt) {
+ if (bind_text) {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ ERR("_cal_db_util_query_prepare() Failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ CAL_DBG("%s",query_str);
+
+ // bind text
+ if (bind_text) {
+ for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++) {
+ _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
+ }
+ }
+
+ ret = calendar_list_create(out_list);
+ if (ret != CALENDAR_ERROR_NONE) {
+ if (bind_text) {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ ERR("calendar_list_create() Failed");
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
+ calendar_record_h record;
+ // stmt -> record
+ ret = calendar_record_create(_calendar_alarm._uri,&record);
+ if( ret != CALENDAR_ERROR_NONE ) {
+ calendar_list_destroy(*out_list, true);
+ *out_list = NULL;
+
+ if (bind_text) {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+ if (que->projection_count > 0) {
+ _cal_record_set_projection(record,
+ que->projection, que->projection_count, que->property_count);
+
+ __cal_db_alarm_get_projection_stmt(stmt,
+ que->projection, que->projection_count,
+ record);
+ }
+ else {
+ __cal_db_alarm_get_stmt(stmt,record);
+ }
+
+ ret = calendar_list_add(*out_list,record);
+ if( ret != CALENDAR_ERROR_NONE ) {
+ calendar_list_destroy(*out_list, true);
+ *out_list = NULL;
+ calendar_record_destroy(record, true);
+
+ if (bind_text) {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+ }
+
+ if (bind_text) {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+
+ sqlite3_finalize(stmt);
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_db_alarm_get_count(int *out_count)
+{
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ int count = 0;
+ int ret;
+
+ retvm_if(NULL == out_count, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ snprintf(query, sizeof(query), "SELECT count(*) FROM %s ", CAL_TABLE_ALARM);
+
+ ret = _cal_db_util_query_get_first_int_result(query, NULL, &count);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("_cal_db_util_query_get_first_int_result() failed");
+ return ret;
+ }
+ CAL_DBG("%s=%d",query,count);
+
+ *out_count = count;
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_db_alarm_get_count_with_query(calendar_query_h query, int *out_count)
+{
+ cal_query_s *que = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ char *condition = NULL;
+ char *table_name;
+ int count = 0;
+ GSList *bind_text = NULL;
+
+ que = (cal_query_s *)query;
+
+ if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_ALARM)) {
+ table_name = SAFE_STRDUP(CAL_TABLE_ALARM);
+ }
+ else {
+ ERR("uri(%s) not support get records with query",que->view_uri);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ // make filter
+ if (que->filter) {
+ ret = _cal_db_query_create_condition(query, &condition, &bind_text);
+ if (ret != CALENDAR_ERROR_NONE) {
+ CAL_FREE(table_name);
+ ERR("filter create fail");
+ return ret;
+ }
+ }
+
+ char *query_str = NULL;
+ // query - select from
+ _cal_db_append_string(&query_str, "SELECT count(*) FROM");
+ _cal_db_append_string(&query_str, table_name);
+ CAL_FREE(table_name);
+
+ // query - condition
+ if (condition) {
+ _cal_db_append_string(&query_str, "WHERE");
+ _cal_db_append_string(&query_str, condition);
+ CAL_FREE(condition);
+ }
+
+ // query
+ ret = _cal_db_util_query_get_first_int_result(query_str, bind_text, &count);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("_cal_db_util_query_get_first_int_result() failed");
+ if (bind_text) {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ return ret;
+ }
+ CAL_DBG("%s=%d",query_str,count);
+
+ *out_count = count;
+
+ if (bind_text) {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ return CALENDAR_ERROR_NONE;
+}
+
--- /dev/null
+/*
+ * Calendar Service
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdlib.h>
+
+#include "cal_internal.h"
+#include "cal_typedef.h"
+#include "cal_view.h"
+#include "cal_record.h"
+
+#include "cal_db_util.h"
+#include "cal_db_query.h"
+#include "cal_db_attendee.h"
+
+static int __cal_db_attendee_get_all_records(int offset, int limit, calendar_list_h* out_list);
+static int __cal_db_attendee_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* out_list);
+static int __cal_db_attendee_get_count(int *out_count);
+static int __cal_db_attendee_get_count_with_query(calendar_query_h query, int *out_count);
+// static int __cal_db_attendee_get_record(int id, calendar_record_h* out_record)
+
+cal_db_plugin_cb_s _cal_db_attendee_plugin_cb = {
+ .is_query_only = false,
+ .insert_record=NULL,
+ .get_record=NULL, // __cal_db_attendee_get_record
+ .update_record=NULL,
+ .delete_record=NULL,
+ .get_all_records=__cal_db_attendee_get_all_records,
+ .get_records_with_query=__cal_db_attendee_get_records_with_query,
+ .insert_records=NULL,
+ .update_records=NULL,
+ .delete_records=NULL,
+ .get_count=__cal_db_attendee_get_count,
+ .get_count_with_query=__cal_db_attendee_get_count_with_query,
+ .replace_record=NULL,
+ .replace_records=NULL
+};
+
+static void __cal_db_attendee_get_stmt(sqlite3_stmt *stmt,calendar_record_h record)
+{
+ cal_attendee_s *attendee = NULL;
+ int index;
+ const unsigned char *temp;
+
+ attendee = (cal_attendee_s*)(record);
+ index = 0;
+
+ attendee->id = sqlite3_column_int(stmt, index++);
+ attendee->parent_id = sqlite3_column_int(stmt, index++);
+
+ temp = sqlite3_column_text(stmt, index++);
+ attendee->attendee_name = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, index++);
+ attendee->attendee_email = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, index++);
+ attendee->attendee_number = SAFE_STRDUP(temp);
+
+ attendee->attendee_status = sqlite3_column_int(stmt, index++);
+ attendee->attendee_ct_index = sqlite3_column_int(stmt, index++);
+ attendee->attendee_role = sqlite3_column_int(stmt, index++);
+ attendee->attendee_rsvp = sqlite3_column_int(stmt, index++);
+
+ temp = sqlite3_column_text(stmt, index++);
+ attendee->attendee_group = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, index++);
+ attendee->attendee_delegator_uri = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, index++);
+ attendee->attendee_uid = SAFE_STRDUP(temp);
+
+ attendee->attendee_cutype = sqlite3_column_int(stmt, index++);
+
+ temp = sqlite3_column_text(stmt, index++);
+ attendee->attendee_delegatee_uri = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, index++);
+ attendee->attendee_member = SAFE_STRDUP(temp);
+}
+
+static int __cal_db_attendee_get_all_records(int offset, int limit, calendar_list_h* out_list)
+{
+ int ret;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ char offsetquery[CAL_DB_SQL_MAX_LEN] = {0};
+ char limitquery[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+
+ retvm_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Invalid parameter: calendar_list_h is NULL");
+ ret = calendar_list_create(out_list);
+ retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_DB_FAILED,
+ "calendar_list_create() failed");
+
+ if (limit > 0) {
+ snprintf(limitquery, sizeof(limitquery), "LIMIT %d ", limit);
+ }
+ if (offset > 0) {
+ snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d ", offset);
+ }
+ snprintf(query, sizeof(query),
+ "SELECT rowid, "
+ "event_id, "
+ "attendee_name, "
+ "attendee_email, "
+ "attendee_number, "
+ "attendee_status, "
+ "attendee_ct_index, "
+ "attendee_role, "
+ "attendee_rsvp, "
+ "attendee_group, "
+ "attendee_delegator_uri, "
+ "attendee_uid, "
+ "attendee_cutype, "
+ "attendee_delegatee_uri, "
+ "attendee_member "
+ "FROM %s %s %s",
+ CAL_TABLE_ATTENDEE, limitquery, offsetquery);
+
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt) {
+ ERR("_cal_db_util_query_prepare() failed");
+ calendar_list_destroy(*out_list, true);
+ *out_list = NULL;
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ calendar_record_h record = NULL;
+
+ while (CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
+ ret = calendar_record_create(_calendar_attendee._uri, &record);
+ if (CALENDAR_ERROR_NONE != ret) {
+ calendar_list_destroy(*out_list, true);
+ *out_list = NULL;
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+ //
+ __cal_db_attendee_get_stmt(stmt,record);
+
+ ret = calendar_list_add(*out_list, record);
+ if (CALENDAR_ERROR_NONE != ret) {
+ calendar_list_destroy(*out_list, true);
+ *out_list = NULL;
+ calendar_record_destroy(record, true);
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+ }
+ sqlite3_finalize(stmt);
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static void __cal_db_attendee_get_property_stmt(sqlite3_stmt *stmt,
+ unsigned int property, int *stmt_count, calendar_record_h record)
+{
+ cal_attendee_s *attendee = NULL;
+ const unsigned char *temp;
+
+ attendee = (cal_attendee_s*)(record);
+
+ switch(property) {
+ case CAL_PROPERTY_ATTENDEE_NUMBER:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ attendee->attendee_number = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_ATTENDEE_CUTYPE:
+ attendee->attendee_cutype = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_ATTENDEE_CT_INDEX:
+ attendee->attendee_ct_index = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_ATTENDEE_UID:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ attendee->attendee_uid = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_ATTENDEE_GROUP:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ attendee->attendee_group = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_ATTENDEE_EMAIL:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ attendee->attendee_email = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_ATTENDEE_ROLE:
+ attendee->attendee_role = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_ATTENDEE_STATUS:
+ attendee->attendee_status = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_ATTENDEE_RSVP:
+ attendee->attendee_rsvp = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_ATTENDEE_DELEGATEE_URI:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ attendee->attendee_delegatee_uri = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_ATTENDEE_DELEGATOR_URI:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ attendee->attendee_delegator_uri = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_ATTENDEE_NAME:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ attendee->attendee_name = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_ATTENDEE_MEMBER:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ attendee->attendee_member = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_ATTENDEE_PARENT_ID:
+ attendee->parent_id = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ default:
+ sqlite3_column_int(stmt, *stmt_count);
+ break;
+ }
+ *stmt_count = *stmt_count+1;
+}
+
+static void __cal_db_attendee_get_projection_stmt(sqlite3_stmt *stmt,
+ const unsigned int *projection, const int projection_count,
+ calendar_record_h record)
+{
+ int i=0;
+ int stmt_count = 0;
+
+ for(i=0;i<projection_count;i++)
+ __cal_db_attendee_get_property_stmt(stmt,projection[i],&stmt_count,record);
+}
+
+static int __cal_db_attendee_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* out_list)
+{
+ cal_query_s *que = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ char *condition = NULL;
+ char *projection = NULL;
+ char *order = NULL;
+ GSList *bind_text = NULL, *cursor = NULL;
+ char *query_str = NULL;
+ sqlite3_stmt *stmt = NULL;
+ int i = 0;
+ char *table_name;
+
+ que = (cal_query_s *)query;
+
+ if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_ATTENDEE)) {
+ table_name = SAFE_STRDUP(CAL_TABLE_ATTENDEE);
+ }
+ else {
+ ERR("uri(%s) not support get records with query",que->view_uri);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ //table_name = SAFE_STRDUP(CAL_TABLE_NORMAL_INSTANCE);
+ }
+
+ // make filter
+ if (que->filter) {
+ ret = _cal_db_query_create_condition(query, &condition, &bind_text);
+ if (ret != CALENDAR_ERROR_NONE) {
+ CAL_FREE(table_name);
+ ERR("filter create fail");
+ return ret;
+ }
+ }
+
+ // make projection
+ ret = _cal_db_query_create_projection(query, &projection);
+
+ // query - projection
+ if (projection) {
+ _cal_db_append_string(&query_str, "SELECT");
+ _cal_db_append_string(&query_str, projection);
+ _cal_db_append_string(&query_str, "FROM");
+ _cal_db_append_string(&query_str, table_name);
+ CAL_FREE(projection);
+ }
+ else {
+ _cal_db_append_string(&query_str,
+ "SELECT rowid, "
+ "event_id, "
+ "attendee_name, "
+ "attendee_email, "
+ "attendee_number, "
+ "attendee_status, "
+ "attendee_ct_index, "
+ "attendee_role, "
+ "attendee_rsvp, "
+ "attendee_group, "
+ "attendee_delegator_uri, "
+ "attendee_uid, "
+ "attendee_cutype, "
+ "attendee_delegatee_uri, "
+ "attendee_member "
+ " FROM");
+ _cal_db_append_string(&query_str, table_name);
+ }
+ CAL_FREE(table_name);
+
+ // query - condition
+ if (condition) {
+ _cal_db_append_string(&query_str, "WHERE");
+ _cal_db_append_string(&query_str, condition);
+ CAL_FREE(condition);
+ }
+
+ // ORDER
+ ret = _cal_db_query_create_order(query, condition, &order);
+ if (order) {
+ _cal_db_append_string(&query_str, order);
+ CAL_FREE(order);
+ }
+
+ char buf[32] = {0};
+ if (0 < limit) {
+ snprintf(buf, sizeof(buf), "LIMIT %d", limit);
+ _cal_db_append_string(&query_str, buf);
+ if (0 < offset) {
+ snprintf(buf, sizeof(buf), "OFFSET %d", offset);
+ _cal_db_append_string(&query_str, buf);
+ }
+ }
+
+ // query
+ stmt = _cal_db_util_query_prepare(query_str);
+ if (NULL == stmt) {
+ if (bind_text) {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ ERR("_cal_db_util_query_prepare() Failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ CAL_DBG("%s",query_str);
+
+ // bind text
+ if (bind_text) {
+ for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
+ _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
+ }
+
+ //
+ ret = calendar_list_create(out_list);
+ if (ret != CALENDAR_ERROR_NONE) {
+ if (bind_text) {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ ERR("calendar_list_create() Failed");
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
+ calendar_record_h record;
+ // stmt -> record
+ ret = calendar_record_create(_calendar_attendee._uri,&record);
+ if( ret != CALENDAR_ERROR_NONE ) {
+ calendar_list_destroy(*out_list, true);
+ *out_list = NULL;
+
+ if (bind_text) {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+ if (que->projection_count > 0) {
+ _cal_record_set_projection(record,
+ que->projection, que->projection_count, que->property_count);
+
+ __cal_db_attendee_get_projection_stmt(stmt,
+ que->projection, que->projection_count,
+ record);
+ }
+ else {
+ __cal_db_attendee_get_stmt(stmt,record);
+ }
+
+ ret = calendar_list_add(*out_list,record);
+ if( ret != CALENDAR_ERROR_NONE ) {
+ calendar_list_destroy(*out_list, true);
+ *out_list = NULL;
+ calendar_record_destroy(record, true);
+
+ if (bind_text) {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+ }
+
+ if (bind_text) {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ sqlite3_finalize(stmt);
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_db_attendee_get_count(int *out_count)
+{
+ int ret;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ int count = 0;
+
+ retvm_if(NULL == out_count, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ snprintf(query, sizeof(query), "SELECT count(*) FROM %s ", CAL_TABLE_ATTENDEE);
+
+ ret = _cal_db_util_query_get_first_int_result(query, NULL, &count);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("_cal_db_util_query_get_first_int_result() failed");
+ return ret;
+ }
+ CAL_DBG("%s=%d",query,count);
+
+ *out_count = count;
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_db_attendee_get_count_with_query(calendar_query_h query, int *out_count)
+{
+ cal_query_s *que = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ char *condition = NULL;
+ char *query_str = NULL;
+ char *table_name;
+ int count = 0;
+ GSList *bind_text = NULL;
+
+ que = (cal_query_s *)query;
+
+ if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_ATTENDEE)) {
+ table_name = SAFE_STRDUP(CAL_TABLE_ATTENDEE);
+ }
+ else {
+ ERR("uri(%s) not support get records with query",que->view_uri);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ // make filter
+ if (que->filter) {
+ ret = _cal_db_query_create_condition(query, &condition, &bind_text);
+ if (ret != CALENDAR_ERROR_NONE) {
+ CAL_FREE(table_name);
+ ERR("filter create fail");
+ return ret;
+ }
+ }
+
+ // query - select from
+ _cal_db_append_string(&query_str, "SELECT count(*) FROM");
+ _cal_db_append_string(&query_str, table_name);
+ CAL_FREE(table_name);
+
+ CAL_FREE(table_name);
+
+ // query - condition
+ if (condition) {
+ _cal_db_append_string(&query_str, "WHERE");
+ _cal_db_append_string(&query_str, condition);
+ CAL_FREE(condition);
+ }
+
+ // query
+ ret = _cal_db_util_query_get_first_int_result(query_str, bind_text, &count);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("_cal_db_util_query_get_first_int_result() failed");
+ if (bind_text) {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ return ret;
+ }
+ CAL_DBG("%s=%d",query_str,count);
+
+ *out_count = count;
+
+ if (bind_text) {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ return CALENDAR_ERROR_NONE;
+}
+
#include "cal_db.h"
#include "cal_db_util.h"
#include "cal_db_query.h"
+#include "cal_access_control.h"
#ifdef CAL_IPC_SERVER
#include "cal_server_calendar_delete.h"
#endif
+#include "cal_access_control.h"
/*
* db plugin function
*/
static void __cal_db_calendar_get_stmt(sqlite3_stmt *stmt,calendar_record_h record);
static void __cal_db_calendar_get_property_stmt(sqlite3_stmt *stmt,
- unsigned int property, int stmt_count, calendar_record_h record);
+ unsigned int property, int stmt_count, calendar_record_h record);
static void __cal_db_calendar_get_projection_stmt(sqlite3_stmt *stmt,
- const unsigned int *projection, const int projection_count,
- calendar_record_h record);
+ const unsigned int *projection, const int projection_count,
+ calendar_record_h record);
static int __cal_db_calendar_update_projection(calendar_record_h record);
cal_db_plugin_cb_s _cal_db_calendar_plugin_cb = {
.insert_records=__cal_db_calendar_insert_records,
.update_records=__cal_db_calendar_update_records,
.delete_records=__cal_db_calendar_delete_records,
- .get_count=__cal_db_calendar_get_count,
- .get_count_with_query=__cal_db_calendar_get_count_with_query,
- .replace_record = __cal_db_calendar_replace_record,
- .replace_records = __cal_db_calendar_replace_records
+ .get_count=__cal_db_calendar_get_count,
+ .get_count_with_query=__cal_db_calendar_get_count_with_query,
+ .replace_record = __cal_db_calendar_replace_record,
+ .replace_records = __cal_db_calendar_replace_records
};
+static bool __cal_db_calendar_check_value_validation(cal_calendar_s* calendar)
+{
+ retvm_if (NULL == calendar, CALENDAR_ERROR_INVALID_PARAMETER, "calendar is NULL");
+
+ switch (calendar->store_type) {
+ case CALENDAR_BOOK_TYPE_NONE:
+ case CALENDAR_BOOK_TYPE_EVENT:
+ case CALENDAR_BOOK_TYPE_TODO:
+ return true;
+
+ default:
+ ERR("store type is invalid(%d)", calendar->store_type);
+ return false;
+ }
+ return true;
+}
+
static int __cal_db_calendar_insert_record( calendar_record_h record, int* id )
{
char query[CAL_DB_SQL_MAX_LEN];
sqlite3_stmt *stmt;
cal_calendar_s* calendar = (cal_calendar_s*)(record);
cal_db_util_error_e dbret = CAL_DB_OK;
+ char *client_label = NULL;
// !! error check
retv_if(NULL == calendar, CALENDAR_ERROR_INVALID_PARAMETER);
+ if (false == __cal_db_calendar_check_value_validation(calendar)) {
+ ERR("_cal_db_calendar_check_value_validation() is failed");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ client_label = _cal_access_control_get_label();
+
sprintf(query,"INSERT INTO %s(uid,updated,name,description,"
"color,location,"
"visibility,"
"sync_event,"
- "account_id,store_type,sync_data1,sync_data2,sync_data3,sync_data4) "
+ "account_id,store_type,sync_data1,sync_data2,sync_data3,sync_data4,"
+ "mode, owner_label) "
"VALUES( ?, %ld, ?, ?, ?, ?, %d, %d, %d, %d"
- ", ?, ?, ?, ?)",
+ ", ?, ?, ?, ?"
+ ", %d, ?)",
CAL_TABLE_CALENDAR,
//calendar->uid,
calendar->updated,
calendar->visibility,
calendar->sync_event,
calendar->account_id,
- calendar->store_type);
+ calendar->store_type,
+ calendar->mode);
stmt = _cal_db_util_query_prepare(query);
- retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "_cal_db_util_query_prepare() Failed");
+ if (NULL == stmt) {
+ ERR("_cal_db_util_query_prepare() Failed");
+ CAL_FREE(client_label);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
if (calendar->uid)
_cal_db_util_stmt_bind_text(stmt, 1, calendar->uid);
if (calendar->sync_data4)
_cal_db_util_stmt_bind_text(stmt, 9, calendar->sync_data4 );
+ if (client_label)
+ _cal_db_util_stmt_bind_text(stmt, 10, client_label );
+
dbret = _cal_db_util_stmt_step(stmt);
if (CAL_DB_DONE != dbret) {
sqlite3_finalize(stmt);
ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
+ CAL_FREE(client_label);
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
index = _cal_db_util_last_insert_id();
sqlite3_finalize(stmt);
+ CAL_FREE(client_label);
+ // access control
+ _cal_access_control_reset();
//_cal_record_set_int(record, _calendar_book.id,index);
if (id)
{
- *id = index;
+ *id = index;
}
_cal_db_util_notify(CAL_NOTI_TYPE_CALENDAR);
static int __cal_db_calendar_get_record( int id, calendar_record_h* out_record )
{
- cal_calendar_s *calendar=NULL;
char query[CAL_DB_SQL_MAX_LEN];
sqlite3_stmt *stmt = NULL;
cal_db_util_error_e dbret = CAL_DB_OK;
int ret = 0;
- ret = calendar_record_create( _calendar_book._uri ,out_record);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("record create fail");
- return CALENDAR_ERROR_OUT_OF_MEMORY;
+ ret = calendar_record_create(_calendar_book._uri ,out_record);
+ if (ret != CALENDAR_ERROR_NONE) {
+ ERR("record create fail");
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
}
- calendar = (cal_calendar_s*)(*out_record);
-
snprintf(query, sizeof(query), "SELECT * FROM %s WHERE id=%d "
- "AND (deleted = 0)",
+ "AND (deleted = 0)",
CAL_TABLE_CALENDAR, id);
stmt = _cal_db_util_query_prepare(query);
retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "_cal_db_util_query_prepare() Failed");
if (dbret != CAL_DB_ROW) {
ERR("Failed to step stmt(%d)", dbret);
sqlite3_finalize(stmt);
- switch (dbret)
- {
+ switch (dbret) {
case CAL_DB_ERROR_NO_SPACE:
return CALENDAR_ERROR_FILE_NO_SPACE;
default:
retv_if(NULL == calendar, CALENDAR_ERROR_INVALID_PARAMETER);
- if (calendar->common.properties_flags != NULL)
- {
- return __cal_db_calendar_update_projection(record);
+ if (false == __cal_db_calendar_check_value_validation(calendar)) {
+ ERR("_cal_db_calendar_check_value_validation() is failed");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (calendar->common.properties_flags != NULL) {
+ return __cal_db_calendar_update_projection(record);
}
snprintf(query, sizeof(query), "UPDATE %s SET "
"sync_event = %d,"
"account_id = %d,"
"store_type = %d, "
- "sync_data1 = ?, "
- "sync_data2 = ?, "
- "sync_data3 = ?, "
- "sync_data4 = ? "
+ "sync_data1 = ?, "
+ "sync_data2 = ?, "
+ "sync_data3 = ?, "
+ "sync_data4 = ?,"
+ "mode = %d "
"WHERE id = %d",
- CAL_TABLE_CALENDAR,
- calendar->updated,
- calendar->visibility,
- calendar->sync_event,
- calendar->account_id,
- calendar->store_type,
- calendar->index);
+ CAL_TABLE_CALENDAR,
+ calendar->updated,
+ calendar->visibility,
+ calendar->sync_event,
+ calendar->account_id,
+ calendar->store_type,
+ calendar->mode,
+ calendar->index);
stmt = _cal_db_util_query_prepare(query);
retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "_cal_db_util_query_prepare() Failed");
_cal_db_util_stmt_bind_text(stmt, 4, calendar->location);
// sync_data1~4
- if (calendar->sync_data1)
- _cal_db_util_stmt_bind_text(stmt, 5, calendar->sync_data1);
- if (calendar->sync_data2)
- _cal_db_util_stmt_bind_text(stmt, 6, calendar->sync_data2);
- if (calendar->sync_data3)
- _cal_db_util_stmt_bind_text(stmt, 7, calendar->sync_data3);
- if (calendar->sync_data4)
- _cal_db_util_stmt_bind_text(stmt, 8, calendar->sync_data4);
-
- dbret = _cal_db_util_stmt_step(stmt);
+ if (calendar->sync_data1)
+ _cal_db_util_stmt_bind_text(stmt, 5, calendar->sync_data1);
+ if (calendar->sync_data2)
+ _cal_db_util_stmt_bind_text(stmt, 6, calendar->sync_data2);
+ if (calendar->sync_data3)
+ _cal_db_util_stmt_bind_text(stmt, 7, calendar->sync_data3);
+ if (calendar->sync_data4)
+ _cal_db_util_stmt_bind_text(stmt, 8, calendar->sync_data4);
+
+ dbret = _cal_db_util_stmt_step(stmt);
if (CAL_DB_DONE != dbret) {
sqlite3_finalize(stmt);
ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
- switch (dbret)
- {
+ switch (dbret) {
case CAL_DB_ERROR_NO_SPACE:
return CALENDAR_ERROR_FILE_NO_SPACE;
default:
static int __cal_db_calendar_delete_record( int id )
{
+ int ret = CALENDAR_ERROR_NONE;
char query[CAL_DB_SQL_MAX_LEN] = {0};
cal_db_util_error_e dbret = CAL_DB_OK;
+ int calendar_book_id = -1;
+
+ snprintf(query, sizeof(query), "SELECT id FROM %s WHERE id = %d",
+ CAL_TABLE_CALENDAR, id);
+ ret = _cal_db_util_query_get_first_int_result(query, NULL, &calendar_book_id);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("_cal_db_util_query_get_first_int_result(%d) failed", ret);
+ return ret;
+ }
#ifdef CAL_IPC_SERVER
- int ret;
int count = 0;
int count2 = 0;
// get instance count
- snprintf(query, sizeof(query), "select count(*) from %s",
- CAL_TABLE_NORMAL_INSTANCE);
+ snprintf(query, sizeof(query), "select count(*) from %s",
+ CAL_TABLE_NORMAL_INSTANCE);
ret = _cal_db_util_query_get_first_int_result(query, NULL, &count);
if (CALENDAR_ERROR_NONE != ret)
{
return ret;
}
- snprintf(query, sizeof(query), "select count(*) from %s",
- CAL_TABLE_ALLDAY_INSTANCE);
- ret = _cal_db_util_query_get_first_int_result(query,NULL, &count2);
+ snprintf(query, sizeof(query), "select count(*) from %s",
+ CAL_TABLE_ALLDAY_INSTANCE);
+ ret = _cal_db_util_query_get_first_int_result(query,NULL, &count2);
if (CALENDAR_ERROR_NONE != ret)
{
ERR("_cal_db_util_query_get_first_int_result() failed");
count += count2;
- if( count > 1000 )
- {
- snprintf(query, sizeof(query), "UPDATE %s SET deleted = 1 WHERE id = %d",
- CAL_TABLE_CALENDAR, id);
- dbret = _cal_db_util_query_exec(query);
- if (CAL_DB_OK != dbret)
- {
- ERR("_cal_db_util_query_exec() Failed(%d)", dbret);
+ if( count > 1000 )
+ {
+ snprintf(query, sizeof(query), "UPDATE %s SET deleted = 1 WHERE id = %d",
+ CAL_TABLE_CALENDAR, id);
+ dbret = _cal_db_util_query_exec(query);
+ if (CAL_DB_OK != dbret)
+ {
+ ERR("_cal_db_util_query_exec() Failed(%d)", dbret);
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
- _cal_server_calendar_delete_start();
- }
- else
- {
+ }
+ _cal_server_calendar_delete_start();
+ }
+ else
+ {
#endif
- snprintf(query, sizeof(query), "DELETE FROM %s WHERE id = %d",
- CAL_TABLE_CALENDAR, id);
- dbret = _cal_db_util_query_exec(query);
- if (CAL_DB_OK != dbret)
- {
- ERR("_cal_db_util_query_exec() Failed(%d)", dbret);
+ snprintf(query, sizeof(query), "DELETE FROM %s WHERE id = %d",
+ CAL_TABLE_CALENDAR, id);
+ dbret = _cal_db_util_query_exec(query);
+ if (CAL_DB_OK != dbret)
+ {
+ ERR("_cal_db_util_query_exec() Failed(%d)", dbret);
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
+ }
- snprintf(query, sizeof(query), "DELETE FROM %s WHERE calendar_id = %d",
- CAL_TABLE_SCHEDULE, id);
- dbret = _cal_db_util_query_exec(query);
- if (CAL_DB_OK != dbret) {
- ERR("_cal_db_util_query_exec() Failed(%d)", dbret);
+ snprintf(query, sizeof(query), "DELETE FROM %s WHERE calendar_id = %d",
+ CAL_TABLE_SCHEDULE, id);
+ dbret = _cal_db_util_query_exec(query);
+ if (CAL_DB_OK != dbret) {
+ ERR("_cal_db_util_query_exec() Failed(%d)", dbret);
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
+ }
#ifdef CAL_IPC_SERVER
- }
+ }
#endif
-
snprintf(query, sizeof(query), "DELETE FROM %s WHERE calendar_id = %d",
CAL_TABLE_DELETED, id);
dbret = _cal_db_util_query_exec(query);
}
}
+ // access control
+ _cal_access_control_reset();
+
_cal_db_util_notify(CAL_NOTI_TYPE_CALENDAR);
return CALENDAR_ERROR_NONE;
}
static int __cal_db_calendar_replace_record(calendar_record_h record, int id)
{
- //int rc = -1;
char query[CAL_DB_SQL_MAX_LEN] = {0};
sqlite3_stmt *stmt = NULL;
cal_calendar_s* calendar = (cal_calendar_s*)(record);
cal_db_util_error_e dbret = CAL_DB_OK;
retv_if(NULL == calendar, CALENDAR_ERROR_INVALID_PARAMETER);
+
+ if (false == __cal_db_calendar_check_value_validation(calendar)) {
+ ERR("_cal_db_calendar_check_value_validation() is failed");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
calendar->index = id;
- if (calendar->common.properties_flags != NULL)
- {
- return __cal_db_calendar_update_projection(record);
+ if (calendar->common.properties_flags != NULL) {
+ return __cal_db_calendar_update_projection(record);
}
snprintf(query, sizeof(query), "UPDATE %s SET "
"sync_event = %d,"
"account_id = %d,"
"store_type = %d, "
- "sync_data1 = ?, "
- "sync_data2 = ?, "
- "sync_data3 = ?, "
- "sync_data4 = ? "
+ "sync_data1 = ?, "
+ "sync_data2 = ?, "
+ "sync_data3 = ?, "
+ "sync_data4 = ?, "
+ "mode = %d "
"WHERE id = %d",
- CAL_TABLE_CALENDAR,
- calendar->updated,
- calendar->visibility,
- calendar->sync_event,
- calendar->account_id,
- calendar->store_type,
- id);
+ CAL_TABLE_CALENDAR,
+ calendar->updated,
+ calendar->visibility,
+ calendar->sync_event,
+ calendar->account_id,
+ calendar->store_type,
+ calendar->mode,
+ id);
stmt = _cal_db_util_query_prepare(query);
retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "_cal_db_util_query_prepare() Failed");
_cal_db_util_stmt_bind_text(stmt, 4, calendar->location);
// sync_data1~4
- if (calendar->sync_data1)
- _cal_db_util_stmt_bind_text(stmt, 5, calendar->sync_data1);
- if (calendar->sync_data2)
- _cal_db_util_stmt_bind_text(stmt, 6, calendar->sync_data2);
- if (calendar->sync_data3)
- _cal_db_util_stmt_bind_text(stmt, 7, calendar->sync_data3);
- if (calendar->sync_data4)
- _cal_db_util_stmt_bind_text(stmt, 8, calendar->sync_data4);
-
- dbret = _cal_db_util_stmt_step(stmt);
+ if (calendar->sync_data1)
+ _cal_db_util_stmt_bind_text(stmt, 5, calendar->sync_data1);
+ if (calendar->sync_data2)
+ _cal_db_util_stmt_bind_text(stmt, 6, calendar->sync_data2);
+ if (calendar->sync_data3)
+ _cal_db_util_stmt_bind_text(stmt, 7, calendar->sync_data3);
+ if (calendar->sync_data4)
+ _cal_db_util_stmt_bind_text(stmt, 8, calendar->sync_data4);
+
+ dbret = _cal_db_util_stmt_step(stmt);
if (CAL_DB_DONE != dbret) {
sqlite3_finalize(stmt);
ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
- switch (dbret)
- {
+ switch (dbret) {
case CAL_DB_ERROR_NO_SPACE:
return CALENDAR_ERROR_FILE_NO_SPACE;
default:
static int __cal_db_calendar_get_all_records( int offset, int limit, calendar_list_h* out_list )
{
- int ret = CALENDAR_ERROR_NONE;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- char offsetquery[CAL_DB_SQL_MAX_LEN] = {0};
- char limitquery[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
-
- retvm_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- ret = calendar_list_create(out_list);
-
- retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- if (offset > 0)
- {
- snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
- }
- if (limit > 0)
- {
- snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
- }
- snprintf(query, sizeof(query), "SELECT * FROM %s %s %s where deleted = 0",
- CAL_TABLE_CALENDAR,limitquery,offsetquery);
-
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() Failed");
- calendar_list_destroy(*out_list, true);
+ int ret = CALENDAR_ERROR_NONE;
+ char offsetquery[CAL_DB_SQL_MAX_LEN] = {0};
+ char limitquery[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+
+ retvm_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ ret = calendar_list_create(out_list);
+ retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ if (offset > 0) {
+ snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
+ }
+ if (limit > 0) {
+ snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
+ }
+
+ char *query_str = NULL;
+ _cal_db_append_string(&query_str, "SELECT * FROM");
+ _cal_db_append_string(&query_str, CAL_TABLE_CALENDAR);
+ _cal_db_append_string(&query_str, "WHERE deleted = 0");
+ _cal_db_append_string(&query_str, limitquery);
+ _cal_db_append_string(&query_str, offsetquery);
+
+ stmt = _cal_db_util_query_prepare(query_str);
+ if (NULL == stmt) {
+ ERR("_cal_db_util_query_prepare() Failed");
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- return CALENDAR_ERROR_DB_FAILED;
- }
-
- while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- calendar_record_h record;
- // stmt -> record
- ret = calendar_record_create(_calendar_book._uri,&record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
+ CAL_FREE(query_str);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
+ calendar_record_h record;
+ // stmt -> record
+ ret = calendar_record_create(_calendar_book._uri,&record);
+ if( ret != CALENDAR_ERROR_NONE ) {
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- sqlite3_finalize(stmt);
- return ret;
- }
- __cal_db_calendar_get_stmt(stmt,record);
-
- ret = calendar_list_add(*out_list,record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ __cal_db_calendar_get_stmt(stmt,record);
+
+ ret = calendar_list_add(*out_list,record);
+ if( ret != CALENDAR_ERROR_NONE ) {
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- calendar_record_destroy(record, true);
- sqlite3_finalize(stmt);
- return ret;
- }
- }
+ calendar_record_destroy(record, true);
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ }
- sqlite3_finalize(stmt);
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
return CALENDAR_ERROR_NONE;
}
static int __cal_db_calendar_get_records_with_query( calendar_query_h query, int offset, int limit, calendar_list_h* out_list )
{
- cal_query_s *que = NULL;
- int i = 0;
- int ret = CALENDAR_ERROR_NONE;
- char *condition = NULL;
- char *projection = NULL;
- char *order = NULL;
- GSList *bind_text = NULL, *cursor = NULL;
- char strquery[CAL_DB_SQL_MAX_LEN] = {0};
- int len;
- sqlite3_stmt *stmt = NULL;
-
- que = (cal_query_s *)query;
-
- // make filter
- if (que->filter)
- {
- ret = _cal_db_query_create_condition(query,
- &condition, &bind_text);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("filter create fail");
- return ret;
- }
- }
-
- // make projection
- ret = _cal_db_query_create_projection(query, &projection);
-
- // query - projection
- if (projection)
- {
- len = snprintf(strquery, sizeof(strquery), "SELECT %s FROM %s", projection, CAL_TABLE_CALENDAR);
- }
- else
- {
- len = snprintf(strquery, sizeof(strquery), "SELECT * FROM %s", CAL_TABLE_CALENDAR);
- }
-
- // query - condition
- if (condition)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " WHERE (%s) AND (deleted = 0)", condition);
- }
-
- // ORDER
- ret = _cal_db_query_create_order(query, &order);
- if (order)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " %s", order);
- }
-
- if (0 < limit)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " LIMIT %d", limit);
- if (0 < offset)
- len += snprintf(strquery+len, sizeof(strquery)-len, " OFFSET %d", offset);
- }
-
- // query
- stmt = _cal_db_util_query_prepare(strquery);
- if (NULL == stmt)
- {
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- CAL_DBG("%s",strquery);
-
- // bind text
- if (bind_text)
- {
- len = g_slist_length(bind_text);
- for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
- {
- _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
- }
- }
-
- //
- ret = calendar_list_create(out_list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- ERR("calendar_list_create() Failed");
- sqlite3_finalize(stmt);
- return ret;
- }
-
- while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- calendar_record_h record;
- // stmt -> record
- ret = calendar_record_create(_calendar_book._uri,&record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
+ cal_query_s *que = NULL;
+ int i = 0;
+ int ret = CALENDAR_ERROR_NONE;
+ char *condition = NULL;
+ GSList *bind_text = NULL, *cursor = NULL;
+ sqlite3_stmt *stmt = NULL;
+
+ que = (cal_query_s *)query;
+
+ // make filter
+ if (que->filter) {
+ ret = _cal_db_query_create_condition(query, &condition, &bind_text);
+ if (ret != CALENDAR_ERROR_NONE) {
+ ERR("filter create fail");
+ return ret;
+ }
+ }
+
+ // make projection
+ char *projection = NULL;
+ ret = _cal_db_query_create_projection(query, &projection);
+
+ char *query_str = NULL;
+ // query - projection
+ if (projection) {
+ _cal_db_append_string(&query_str, "SELECT");
+ _cal_db_append_string(&query_str, projection);
+ _cal_db_append_string(&query_str, "FROM");
+ _cal_db_append_string(&query_str, CAL_TABLE_CALENDAR);
+ CAL_FREE(projection);
+ }
+ else {
+ _cal_db_append_string(&query_str, "SELECT * FROM");
+ _cal_db_append_string(&query_str, CAL_TABLE_CALENDAR);
+ }
+
+ // query - condition
+ if (condition) {
+ _cal_db_append_string(&query_str, "WHERE (");
+ _cal_db_append_string(&query_str, condition);
+ _cal_db_append_string(&query_str, ") AND (deleted = 0)");
+ }
+
+ // ORDER
+ char *order = NULL;
+ ret = _cal_db_query_create_order(query, condition, &order);
+ if (order) {
+ _cal_db_append_string(&query_str, order);
+ CAL_FREE(order);
+ }
+ CAL_FREE(condition);
+
+ // limit, offset
+ char buf[32] = {0};
+ if (limit > 0) {
+ snprintf(buf, sizeof(buf), "LIMIT %d", limit);
+ _cal_db_append_string(&query_str, buf);
+
+ if (offset > 0) {
+ snprintf(buf, sizeof(buf), "OFFSET %d", offset);
+ _cal_db_append_string(&query_str, buf);
+ }
+ }
+
+ // query
+ stmt = _cal_db_util_query_prepare(query_str);
+ if (NULL == stmt) {
+ if (bind_text) {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ ERR("_cal_db_util_query_prepare() Failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ CAL_DBG("%s",query_str);
+
+ // bind text
+ if (bind_text) {
+ g_slist_length(bind_text);
+ for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
+ _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
+ }
+
+ ret = calendar_list_create(out_list);
+ if (ret != CALENDAR_ERROR_NONE) {
+ if (bind_text) {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ ERR("calendar_list_create() Failed");
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
+ calendar_record_h record;
+ // stmt -> record
+ ret = calendar_record_create(_calendar_book._uri,&record);
+ if( ret != CALENDAR_ERROR_NONE ) {
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
- return ret;
- }
- if (que->projection_count > 0)
- {
+ if (bind_text) {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+
+ if (que->projection_count > 0) {
_cal_record_set_projection(record,
que->projection, que->projection_count, que->property_count);
- __cal_db_calendar_get_projection_stmt(stmt,
+ __cal_db_calendar_get_projection_stmt(stmt,
que->projection, que->projection_count,
- record);
- }
- else
- {
- __cal_db_calendar_get_stmt(stmt,record);
- }
-
- ret = calendar_list_add(*out_list,record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
+ record);
+ }
+ else {
+ __cal_db_calendar_get_stmt(stmt,record);
+ }
+
+ ret = calendar_list_add(*out_list,record);
+ if( ret != CALENDAR_ERROR_NONE ) {
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- calendar_record_destroy(record, true);
-
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
- return ret;
- }
- }
-
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
+ calendar_record_destroy(record, true);
+
+ if (bind_text) {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ }
+
+ if (bind_text) {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
return CALENDAR_ERROR_NONE;
}
static int __cal_db_calendar_insert_records(const calendar_list_h list, int** ids)
{
- calendar_record_h record;
- int ret = 0;
- int count = 0;
- int i=0;
- int *id = NULL;
-
- ret = calendar_list_get_count(list, &count);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("list get error");
- return ret;
- }
-
- id = calloc(1, sizeof(int)*count);
-
- retvm_if(NULL == id, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc fail");
-
- ret = calendar_list_first(list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("list first error");
- CAL_FREE(id);
- return ret;
- }
- do
- {
- if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
- {
- if( __cal_db_calendar_insert_record(record, &id[i]) != CALENDAR_ERROR_NONE)
- {
- ERR("db insert error");
- CAL_FREE(id);
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- i++;
- } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
-
- if(ids)
- {
- *ids = id;
- }
- else
- {
- CAL_FREE(id);
- }
+ calendar_record_h record;
+ int ret = 0;
+ int count = 0;
+ int i=0;
+ int *id = NULL;
+
+ ret = calendar_list_get_count(list, &count);
+ if (ret != CALENDAR_ERROR_NONE) {
+ ERR("list get error");
+ return ret;
+ }
+
+ id = calloc(1, sizeof(int)*count);
+
+ retvm_if(NULL == id, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc fail");
+
+ ret = calendar_list_first(list);
+ if (ret != CALENDAR_ERROR_NONE) {
+ ERR("list first error");
+ CAL_FREE(id);
+ return ret;
+ }
+
+ do {
+ if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE) {
+ if( __cal_db_calendar_insert_record(record, &id[i]) != CALENDAR_ERROR_NONE) {
+ ERR("db insert error");
+ CAL_FREE(id);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ i++;
+ } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+
+ if(ids) {
+ *ids = id;
+ }
+ else {
+ CAL_FREE(id);
+ }
return CALENDAR_ERROR_NONE;
}
static int __cal_db_calendar_update_records(const calendar_list_h list)
{
- calendar_record_h record;
- int ret = 0;
-
- ret = calendar_list_first(list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("list first error");
- return ret;
- }
- do
- {
- if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
- {
- if( __cal_db_calendar_update_record(record) != CALENDAR_ERROR_NONE)
- {
- ERR("db insert error");
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
-
- return CALENDAR_ERROR_NONE;
+ calendar_record_h record;
+ int ret = 0;
+
+ ret = calendar_list_first(list);
+ if (ret != CALENDAR_ERROR_NONE) {
+ ERR("list first error");
+ return ret;
+ }
+
+ do {
+ if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE) {
+ if( __cal_db_calendar_update_record(record) != CALENDAR_ERROR_NONE) {
+ ERR("db insert error");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_calendar_delete_records(int ids[], int count)
{
- int i=0;
- for(i=0;i<count;i++)
- {
- if (__cal_db_calendar_delete_record(ids[i]) != CALENDAR_ERROR_NONE)
- {
- ERR("delete failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
+ int i=0;
+
+ for(i=0;i<count;i++) {
+ if (__cal_db_calendar_delete_record(ids[i]) != CALENDAR_ERROR_NONE) {
+ ERR("delete failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+
return CALENDAR_ERROR_NONE;
}
static int __cal_db_calendar_replace_records(const calendar_list_h list, int ids[], int count)
{
- calendar_record_h record;
+ calendar_record_h record;
int i = 0;
- int ret = 0;
+ int ret = 0;
- if (NULL == list)
- {
+ if (NULL == list) {
ERR("Invalid argument: list is NULL");
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- ret = calendar_list_first(list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("list first error");
- return ret;
- }
-
- for (i = 0; i < count; i++)
- {
- if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
- {
- if( __cal_db_calendar_replace_record(record, ids[i]) != CALENDAR_ERROR_NONE)
- {
- ERR("db insert error");
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- if (CALENDAR_ERROR_NO_DATA != calendar_list_next(list))
- {
+ ret = calendar_list_first(list);
+ if (ret != CALENDAR_ERROR_NONE) {
+ ERR("list first error");
+ return ret;
+ }
+
+ for (i = 0; i < count; i++) {
+ if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE) {
+ if( __cal_db_calendar_replace_record(record, ids[i]) != CALENDAR_ERROR_NONE) {
+ ERR("db insert error");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ if (CALENDAR_ERROR_NO_DATA != calendar_list_next(list)) {
break;
}
- }
+ }
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_calendar_get_count(int *out_count)
{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- int count = 0;
- int ret;
-
- retvm_if(NULL == out_count, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == out_count, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- snprintf(query, sizeof(query), "SELECT count(*) FROM %s where deleted = 0", CAL_TABLE_CALENDAR);
+ char *query_str = NULL;
+ _cal_db_append_string(&query_str, "SELECT count(*) FROM");
+ _cal_db_append_string(&query_str, CAL_TABLE_CALENDAR);
+ _cal_db_append_string(&query_str, "WHERE deleted = 0");
- ret = _cal_db_util_query_get_first_int_result(query, NULL, &count);
- if (CALENDAR_ERROR_NONE != ret)
- {
+ int ret = 0;
+ int count = 0;
+ ret = _cal_db_util_query_get_first_int_result(query_str, NULL, &count);
+ if (CALENDAR_ERROR_NONE != ret) {
ERR("_cal_db_util_query_get_first_int_result() failed");
+ CAL_FREE(query_str);
return ret;
}
- CAL_DBG("%s=%d",query,count);
+ CAL_DBG("count(%d) str[%s]", count, query_str);
+ CAL_FREE(query_str);
- *out_count = count;
- return CALENDAR_ERROR_NONE;
+ *out_count = count;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_calendar_get_count_with_query(calendar_query_h query, int *out_count)
{
- cal_query_s *que = NULL;
- int ret = CALENDAR_ERROR_NONE;
- char *condition = NULL;
- char strquery[CAL_DB_SQL_MAX_LEN] = {0};
- int len;
- char *table_name;
- int count = 0;
- GSList *bind_text = NULL;
-
- que = (cal_query_s *)query;
-
- if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_CALENDAR))
- {
- table_name = SAFE_STRDUP(CAL_TABLE_CALENDAR);
- }
- else
- {
- ERR("uri(%s) not support get records with query",que->view_uri);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- // make filter
- if (que->filter)
- {
- ret = _cal_db_query_create_condition(query, &condition, &bind_text);
- if (ret != CALENDAR_ERROR_NONE)
- {
- CAL_FREE(table_name);
- ERR("filter create fail");
- return ret;
- }
- }
-
- // query - select from
-
- len = snprintf(strquery, sizeof(strquery), "SELECT count(*) FROM %s", table_name);
-
- CAL_FREE(table_name);
-
- // query - condition
- if (condition)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " WHERE (%s) AND (deleted = 0)", condition);
- }
-
- // query
- ret = _cal_db_util_query_get_first_int_result(strquery, bind_text, &count);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("_cal_db_util_query_get_first_int_result() failed");
- if (bind_text)
- {
- g_slist_free(bind_text);
+ cal_query_s *que = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ char *condition = NULL;
+ char *table_name;
+ int count = 0;
+ GSList *bind_text = NULL;
+
+ que = (cal_query_s *)query;
+
+ if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_CALENDAR)) {
+ table_name = SAFE_STRDUP(CAL_TABLE_CALENDAR);
+ }
+ else {
+ ERR("uri(%s) not support get records with query",que->view_uri);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ // make filter
+ if (que->filter) {
+ ret = _cal_db_query_create_condition(query, &condition, &bind_text);
+ if (ret != CALENDAR_ERROR_NONE) {
+ CAL_FREE(table_name);
+ ERR("filter create fail");
+ return ret;
}
+ }
+
+ char *query_str = NULL;
+ // query - select from
+ _cal_db_append_string(&query_str, "SELECT count(*) FROM");
+ _cal_db_append_string(&query_str, table_name);
+ CAL_FREE(table_name);
+
+ // query - condition
+ if (condition) {
+ _cal_db_append_string(&query_str, "WHERE (");
+ _cal_db_append_string(&query_str, condition);
+ _cal_db_append_string(&query_str, ") AND (deleted = 0)");
CAL_FREE(condition);
+ }
+
+ // query
+ ret = _cal_db_util_query_get_first_int_result(query_str, bind_text, &count);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("_cal_db_util_query_get_first_int_result() failed");
+ if (bind_text) {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
return ret;
}
- CAL_DBG("%s=%d",strquery,count);
+ CAL_DBG("count(%d) str[%s]", count, query_str);
- if (out_count) *out_count = count;
+ if (out_count)
+ *out_count = count;
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- return CALENDAR_ERROR_NONE;
+ if (bind_text) {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ return CALENDAR_ERROR_NONE;
}
static void __cal_db_calendar_get_stmt(sqlite3_stmt *stmt,calendar_record_h record)
{
- cal_calendar_s* calendar = (cal_calendar_s*)(record);
- int count = 0;
- const unsigned char *temp;
+ cal_calendar_s* calendar = (cal_calendar_s*)(record);
+ int count = 0;
+ const unsigned char *temp;
+
+ calendar->index = sqlite3_column_int(stmt, count++);
- calendar->index = sqlite3_column_int(stmt, count++);
+ temp = sqlite3_column_text(stmt, count++);
+ calendar->uid = SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- calendar->uid = SAFE_STRDUP(temp);
+ calendar->updated = sqlite3_column_int(stmt, count++);
- calendar->updated = sqlite3_column_int(stmt, count++);
+ temp = sqlite3_column_text(stmt, count++);
+ calendar->name = SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- calendar->name = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ calendar->description = SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- calendar->description = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ calendar->color = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ calendar->location = SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- calendar->color = SAFE_STRDUP(temp);
+ calendar->visibility = sqlite3_column_int(stmt, count++);
+ calendar->sync_event = sqlite3_column_int(stmt, count++);
+ calendar->is_deleted = sqlite3_column_int(stmt, count++);
+ calendar->account_id = sqlite3_column_int(stmt, count++);
+ calendar->store_type = sqlite3_column_int(stmt, count++);
- temp = sqlite3_column_text(stmt, count++);
- calendar->location = SAFE_STRDUP(temp);
+ //sync_data1~4
+ temp = sqlite3_column_text(stmt, count++);
+ calendar->sync_data1 = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ calendar->sync_data2 = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ calendar->sync_data3 = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ calendar->sync_data4 = SAFE_STRDUP(temp);
- calendar->visibility = sqlite3_column_int(stmt, count++);
- calendar->sync_event = sqlite3_column_int(stmt, count++);
- calendar->is_deleted = sqlite3_column_int(stmt, count++);
- calendar->account_id = sqlite3_column_int(stmt, count++);
- calendar->store_type = sqlite3_column_int(stmt, count++);
+ //deleted
+ sqlite3_column_int(stmt, count++);
- //sync_data1~4
- temp = sqlite3_column_text(stmt, count++);
- calendar->sync_data1 = SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- calendar->sync_data2 = SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- calendar->sync_data3 = SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- calendar->sync_data4 = SAFE_STRDUP(temp);
+ // mode
+ calendar->mode = sqlite3_column_int(stmt, count++);
- //deleted
- sqlite3_column_int(stmt, count++);
+ // owner_label
+ sqlite3_column_text(stmt, count++);
}
static void __cal_db_calendar_get_property_stmt(sqlite3_stmt *stmt,
- unsigned int property, int stmt_count, calendar_record_h record)
+ unsigned int property, int stmt_count, calendar_record_h record)
{
- cal_calendar_s* calendar = (cal_calendar_s*)(record);
- const unsigned char *temp;
-
- switch(property)
- {
- case CAL_PROPERTY_CALENDAR_ID:
- calendar->index = sqlite3_column_int(stmt, stmt_count);
- break;
- case CAL_PROPERTY_CALENDAR_UID:
- temp = sqlite3_column_text(stmt, stmt_count);
- calendar->uid = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_CALENDAR_NAME:
- temp = sqlite3_column_text(stmt, stmt_count);
- calendar->name = SAFE_STRDUP(temp);
- CAL_DBG("calendar->name=%s",calendar->name);
- break;
- case CAL_PROPERTY_CALENDAR_DESCRIPTION:
- temp = sqlite3_column_text(stmt, stmt_count);
- calendar->description = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_CALENDAR_COLOR:
- temp = sqlite3_column_text(stmt, stmt_count);
- calendar->color = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_CALENDAR_LOCATION:
- temp = sqlite3_column_text(stmt, stmt_count);
- calendar->location = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_CALENDAR_VISIBILITY:
- calendar->visibility = sqlite3_column_int(stmt, stmt_count);
- break;
- case CAL_PROPERTY_CALENDAR_SYNC_EVENT:
- calendar->sync_event = sqlite3_column_int(stmt, stmt_count);
- break;
- case CAL_PROPERTY_CALENDAR_IS_DELETED:
- calendar->is_deleted = sqlite3_column_int(stmt, stmt_count);
- break;
- case CAL_PROPERTY_CALENDAR_ACCOUNT_ID:
- calendar->account_id = sqlite3_column_int(stmt, stmt_count);
- break;
- case CAL_PROPERTY_CALENDAR_STORE_TYPE:
- calendar->store_type = sqlite3_column_int(stmt, stmt_count);
- break;
- case CAL_PROPERTY_CALENDAR_SYNC_DATA1:
- temp = sqlite3_column_text(stmt, stmt_count);
- calendar->sync_data1 = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_CALENDAR_SYNC_DATA2:
- temp = sqlite3_column_text(stmt, stmt_count);
- calendar->sync_data1 = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_CALENDAR_SYNC_DATA3:
- temp = sqlite3_column_text(stmt, stmt_count);
- calendar->sync_data1 = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_CALENDAR_SYNC_DATA4:
- temp = sqlite3_column_text(stmt, stmt_count);
- calendar->sync_data1 = SAFE_STRDUP(temp);
- break;
- default:
- sqlite3_column_int(stmt, stmt_count);
- break;
- }
-
- return;
+ cal_calendar_s* calendar = (cal_calendar_s*)(record);
+ const unsigned char *temp;
+
+ switch(property) {
+ case CAL_PROPERTY_CALENDAR_ID:
+ calendar->index = sqlite3_column_int(stmt, stmt_count);
+ break;
+ case CAL_PROPERTY_CALENDAR_UID:
+ temp = sqlite3_column_text(stmt, stmt_count);
+ calendar->uid = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_CALENDAR_NAME:
+ temp = sqlite3_column_text(stmt, stmt_count);
+ calendar->name = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_CALENDAR_DESCRIPTION:
+ temp = sqlite3_column_text(stmt, stmt_count);
+ calendar->description = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_CALENDAR_COLOR:
+ temp = sqlite3_column_text(stmt, stmt_count);
+ calendar->color = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_CALENDAR_LOCATION:
+ temp = sqlite3_column_text(stmt, stmt_count);
+ calendar->location = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_CALENDAR_VISIBILITY:
+ calendar->visibility = sqlite3_column_int(stmt, stmt_count);
+ break;
+ case CAL_PROPERTY_CALENDAR_SYNC_EVENT:
+ calendar->sync_event = sqlite3_column_int(stmt, stmt_count);
+ break;
+ case CAL_PROPERTY_CALENDAR_ACCOUNT_ID:
+ calendar->account_id = sqlite3_column_int(stmt, stmt_count);
+ break;
+ case CAL_PROPERTY_CALENDAR_STORE_TYPE:
+ calendar->store_type = sqlite3_column_int(stmt, stmt_count);
+ break;
+ case CAL_PROPERTY_CALENDAR_SYNC_DATA1:
+ temp = sqlite3_column_text(stmt, stmt_count);
+ calendar->sync_data1 = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_CALENDAR_SYNC_DATA2:
+ temp = sqlite3_column_text(stmt, stmt_count);
+ calendar->sync_data1 = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_CALENDAR_SYNC_DATA3:
+ temp = sqlite3_column_text(stmt, stmt_count);
+ calendar->sync_data1 = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_CALENDAR_SYNC_DATA4:
+ temp = sqlite3_column_text(stmt, stmt_count);
+ calendar->sync_data1 = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_CALENDAR_MODE:
+ calendar->mode = sqlite3_column_int(stmt, stmt_count);
+ break;
+ default:
+ break;
+ }
+
+ return;
}
static void __cal_db_calendar_get_projection_stmt(sqlite3_stmt *stmt,
- const unsigned int *projection, const int projection_count,
- calendar_record_h record)
+ const unsigned int *projection, const int projection_count,
+ calendar_record_h record)
{
- int i=0;
+ int i=0;
- for(i=0;i<projection_count;i++)
- {
- __cal_db_calendar_get_property_stmt(stmt,projection[i],i,record);
- }
+ for(i=0;i<projection_count;i++)
+ __cal_db_calendar_get_property_stmt(stmt,projection[i],i,record);
}
static int __cal_db_calendar_update_projection(calendar_record_h record)
{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
- cal_calendar_s* calendar = (cal_calendar_s*)(record);
- cal_db_util_error_e dbret = CAL_DB_OK;
- int ret = CALENDAR_ERROR_NONE;
- char* set = NULL;
- GSList *bind_text = NULL;
- int len;
- GSList *cursor = NULL;
-
- ret = _cal_db_query_create_projection_update_set(record,&set,&bind_text);
- retv_if(CALENDAR_ERROR_NONE != ret, ret);
-
- snprintf(query, sizeof(query), "UPDATE %s SET %s "
- "WHERE id = %d",
- CAL_TABLE_CALENDAR,set,
- calendar->index);
-
- stmt = _cal_db_util_query_prepare(query);
- retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "_cal_db_util_query_prepare() Failed");
-
- // bind
- if (bind_text)
- {
- int i = 0;
- len = g_slist_length(bind_text);
- for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
- {
- _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
- }
- }
-
- dbret = _cal_db_util_stmt_step(stmt);
- if (CAL_DB_DONE != dbret) {
- sqlite3_finalize(stmt);
- ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
-
- CAL_FREE(set);
- if(bind_text)
- {
- for (cursor=bind_text; cursor;cursor=cursor->next)
- {
- CAL_FREE(cursor->data);
- }
- g_slist_free(bind_text);
- }
- switch (dbret)
- {
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+ cal_calendar_s* calendar = (cal_calendar_s*)(record);
+ cal_db_util_error_e dbret = CAL_DB_OK;
+ int ret = CALENDAR_ERROR_NONE;
+ char* set = NULL;
+ GSList *bind_text = NULL;
+ GSList *cursor = NULL;
+
+ ret = _cal_db_query_create_projection_update_set(record,&set,&bind_text);
+ retv_if(CALENDAR_ERROR_NONE != ret, ret);
+
+ snprintf(query, sizeof(query), "UPDATE %s SET %s "
+ "WHERE id = %d",
+ CAL_TABLE_CALENDAR,set,
+ calendar->index);
+
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt) {
+ ERR("_cal_db_util_query_prepare() Failed");
+ CAL_FREE(set);
+ if(bind_text) {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ // bind
+ if (bind_text) {
+ int i = 0;
+ for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
+ _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
+ }
+
+ dbret = _cal_db_util_stmt_step(stmt);
+ if (CAL_DB_DONE != dbret) {
+ sqlite3_finalize(stmt);
+ ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
+
+ CAL_FREE(set);
+ if(bind_text) {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+
+ switch (dbret) {
case CAL_DB_ERROR_NO_SPACE:
return CALENDAR_ERROR_FILE_NO_SPACE;
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
+ }
- sqlite3_finalize(stmt);
+ sqlite3_finalize(stmt);
- _cal_db_util_notify(CAL_NOTI_TYPE_CALENDAR);
+ _cal_db_util_notify(CAL_NOTI_TYPE_CALENDAR);
- CAL_FREE(set);
- if(bind_text)
- {
- for (cursor=bind_text; cursor;cursor=cursor->next)
- {
- CAL_FREE(cursor->data);
- }
- g_slist_free(bind_text);
- }
+ CAL_FREE(set);
+ if(bind_text) {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
#include <stdlib.h>
#include "calendar_db.h"
-
#include "cal_internal.h"
#include "cal_typedef.h"
#include "cal_view.h"
#include "cal_time.h"
#include "cal_record.h"
+#include "cal_list.h"
#include "cal_db_util.h"
#include "cal_db.h"
#include "cal_db_instance.h"
#include "cal_db_attendee.h"
#include "cal_db_extended.h"
+#include "cal_db_event.h"
+#include "cal_access_control.h"
static int __cal_db_event_insert_record(calendar_record_h record, int* id);
static int __cal_db_event_get_record(int id, calendar_record_h* out_record);
/*
* static function
*/
-static void __cal_db_event_get_stmt(sqlite3_stmt *stmt,bool is_view_table,calendar_record_h record);
+static void __cal_db_event_get_stmt(sqlite3_stmt *stmt,bool is_view_table,calendar_record_h record,
+ int *exception, int *extended);
static void __cal_db_event_get_property_stmt(sqlite3_stmt *stmt,
- unsigned int property, int *stmt_count, calendar_record_h record);
+ unsigned int property, int *stmt_count, calendar_record_h record);
static void __cal_db_event_get_projection_stmt(sqlite3_stmt *stmt,
- const unsigned int *projection, const int projection_count,
- calendar_record_h record);
-static int __cal_db_event_update_dirty(calendar_record_h record);
+ const unsigned int *projection, const int projection_count,
+ calendar_record_h record);
+static int __cal_db_event_update_dirty(calendar_record_h record, int is_dirty_in_time);
/* // under construction
-bool __cal_db_event_check_changed_rrule(record);
-*/
-static int __cal_db_event_exception_get_records(int original_id, GList **out_list);
-static int __cal_db_event_exception_convert_gtoh(GList *glist, int original_id, int calendar_id, calendar_list_h *hlist);
+ bool __cal_db_event_check_changed_rrule(record);
+ */
+static int __cal_db_event_exception_get_records(int original_id, cal_list_s *list);
static int __cal_db_event_exception_delete_with_id(int original_id);
+static int __cal_db_event_exception_get_ids(int original_id, GList **out_list);
+static int __cal_db_event_exception_update(cal_list_s *exception_list_s, int original_id, int calendar_id, int is_dirty_in_time, time_t time_diff, int old_type, int new_type);
+static int __cal_db_event_get_deleted_data(int id, int* calendar_book_id, int* created_ver, int* original_event_id, char** recurrence_id);
+static int __cal_db_event_exdate_insert_normal(int event_id, const char* original_exdate, const char* exdate, int **exception_id, int *exception_len);
+static bool __cal_db_event_check_calendar_book_type(calendar_record_h record);
+
+static void __check_list(calendar_list_h l)
+{
+ DBG("---------------------");
+ calendar_list_first(l);
+ int count = 0;
+ calendar_list_get_count(l, &count);
+ DBG("count(%d)", count);
+
+ int i;
+ for (i = 0; i < count; i++) {
+ calendar_record_h event = NULL;
+ calendar_list_get_current_record_p(l, &event);
+ int id = 0;
+ calendar_record_get_int(event, _calendar_event.id, &id);
+ int book_id = 0;
+ calendar_record_get_int(event, _calendar_event.calendar_book_id, &book_id);
+ char *summary = NULL;
+ calendar_record_get_str_p(event, _calendar_event.summary, &summary);
+ int freq = 0;
+ calendar_record_get_int(event, _calendar_event.freq, &freq);
+
+ DBG("id(%d) book_id(%d) summary[%s] freq(%d)", id, book_id, summary, freq);
+ calendar_list_next(l);
+ }
+}
cal_db_plugin_cb_s _cal_db_event_plugin_cb = {
.is_query_only = false,
.insert_records = __cal_db_event_insert_records,
.update_records = __cal_db_event_update_records,
.delete_records = __cal_db_event_delete_records,
- .get_count = __cal_db_event_get_count,
- .get_count_with_query = __cal_db_event_get_count_with_query,
- .replace_record = __cal_db_event_replace_record,
- .replace_records = __cal_db_event_replace_records
+ .get_count = __cal_db_event_get_count,
+ .get_count_with_query = __cal_db_event_get_count_with_query,
+ .replace_record = __cal_db_event_replace_record,
+ .replace_records = __cal_db_event_replace_records
};
-static int __cal_db_event_check_value_validation(cal_event_s *event)
+static int __cal_db_event_insert_record(calendar_record_h record, int* id)
{
- long long int slli = 0;
- long long int elli = 0;
+ retv_if(NULL == record, CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(false == __cal_db_event_check_calendar_book_type(record), CALENDAR_ERROR_INVALID_PARAMETER);
+ cal_event_s *event = (cal_event_s *)record;
+ return _cal_db_event_insert_record(record, event->original_event_id, id);
+}
- retv_if(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER);
+enum {
+ DIRTY_INIT = -1,
+ DIRTY_IN_OTHER = 0,
+ DIRTY_IN_TIME,
+};
+
+static int __cal_db_event_get_record(int id, calendar_record_h* out_record)
+{
+ char query[CAL_DB_SQL_MAX_LEN];
+ int ret = 0;
+ sqlite3_stmt *stmt = NULL;
+ cal_event_s *event = NULL;
+ cal_rrule_s *rrule = NULL;
+ cal_db_util_error_e dbret = CAL_DB_OK;
+ int exception = 0, extended = 0;
+ calendar_record_h record_calendar;
+ calendar_book_sync_event_type_e sync_event_type = CALENDAR_BOOK_SYNC_EVENT_FOR_ME;
- if (event->start.type != event->end.type)
+ ret = calendar_record_create( _calendar_event._uri ,out_record);
+ if (ret != CALENDAR_ERROR_NONE)
{
- ERR("start type(%d) is not same as end type(%d)", event->start.type, event->end.type);
- return CALENDAR_ERROR_INVALID_PARAMETER;
+ ERR("calendar_record_create(%d)", ret);
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+
+ event = (cal_event_s*)(*out_record);
+
+ snprintf(query, sizeof(query),
+ "SELECT "CAL_QUERY_SCHEDULE_A_ALL" FROM %s AS A "
+ "WHERE id = %d AND (type = %d OR type = %d) AND calendar_id IN "
+ "(select id from %s where deleted = 0)",
+ CAL_TABLE_SCHEDULE,
+ id, CALENDAR_BOOK_TYPE_EVENT, CALENDAR_BOOK_TYPE_NONE,
+ CAL_TABLE_CALENDAR);
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt)
+ {
+ SEC_ERR("query[%s]", query);
+ ERR("_cal_db_util_query_prepare() Failed");
+ calendar_record_destroy(*out_record, true);
+ *out_record = NULL;
+ return CALENDAR_ERROR_DB_FAILED;
}
- switch (event->start.type)
+ dbret = _cal_db_util_stmt_step(stmt);
+ if (dbret != CAL_DB_ROW)
{
- case CALENDAR_TIME_UTIME:
- if (event->start.time.utime > event->end.time.utime)
+ SEC_ERR("query[%s]", query);
+ ERR("Failed to step stmt(%d)", dbret);
+ sqlite3_finalize(stmt);
+ calendar_record_destroy(*out_record, true);
+ *out_record = NULL;
+ switch (dbret)
{
- ERR("normal start(%lld) > end(%lld)",
- event->start.time.utime, event->end.time.utime);
- return CALENDAR_ERROR_INVALID_PARAMETER;
+ case CAL_DB_DONE:
+ ERR("Failed to find record(id:%d, ret:%d)", id, dbret);
+ return CALENDAR_ERROR_DB_RECORD_NOT_FOUND;
+ case CAL_DB_ERROR_NO_SPACE:
+ return CALENDAR_ERROR_FILE_NO_SPACE;
+ default:
+ return CALENDAR_ERROR_DB_FAILED;
}
- break;
+ }
- case CALENDAR_TIME_LOCALTIME:
- // check invalid value
- if (event->start.time.date.month < 1 || event->start.time.date.month > 12)
- {
- ERR("check start month(input:%d)", event->start.time.date.month);
- return CALENDAR_ERROR_INVALID_PARAMETER;
+ __cal_db_event_get_stmt(stmt, false, *out_record, &exception, &extended);
+ sqlite3_finalize(stmt);
+ stmt = NULL;
+
+ //check
+ ret = _cal_db_get_record(_calendar_book._uri, event->calendar_id, &record_calendar);
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ ret = calendar_record_get_int(record_calendar,
+ _calendar_book.sync_event, (int *)&sync_event_type);
+ calendar_record_destroy(record_calendar, true);
+ }
+ if (event->is_deleted == 1
+ && sync_event_type != CALENDAR_BOOK_SYNC_EVENT_FOR_EVERY_AND_REMAIN
+ )
+ {
+ calendar_record_destroy(*out_record, true);
+ *out_record = NULL;
+ return CALENDAR_ERROR_DB_RECORD_NOT_FOUND;
+ }
+
+ if (_cal_db_rrule_get_rrule(event->index, &rrule) == CALENDAR_ERROR_NONE )
+ {
+ _cal_db_rrule_set_rrule_to_event(rrule, *out_record);
+ CAL_FREE(rrule);
+ }
+
+ if (event->has_alarm == 1)
+ _cal_db_alarm_get_records(event->index, event->alarm_list);
+
+ if (event->has_attendee == 1)
+ _cal_db_attendee_get_records(event->index, event->attendee_list);
+
+ if (exception == 1)
+ __cal_db_event_exception_get_records(event->index, event->exception_list);
+
+ if (extended == 1)
+ _cal_db_extended_get_records(event->index, CALENDAR_RECORD_TYPE_EVENT, event->extended_list);
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __is_dirty_in_time(calendar_record_h record)
+{
+ cal_record_s *rec = (cal_record_s *)record;
+ retvm_if (NULL == record, false, "Invalid parameter: record id NULL");
+ retvm_if (NULL == rec->view_uri, false, "Invalid parameter: view_uri is NULL");
+
+ int count = 0;
+ const cal_property_info_s *info = _cal_view_get_property_info(rec->view_uri, &count);
+ retvm_if (NULL == info, false, "_cal_view_get_property_info() is failed");
+
+ int i;
+ int is_dirty_in_time = DIRTY_IN_OTHER;
+ for (i = 0; i < count; i++) {
+ if (false == _cal_record_check_property_flag(record, info[i].property_id , CAL_PROPERTY_FLAG_DIRTY)) {
+ continue;
}
- else if (event->start.time.date.mday < 1 || event->start.time.date.mday > 31)
- {
- ERR("check start mday(input:%d)", event->start.time.date.mday);
- return CALENDAR_ERROR_INVALID_PARAMETER;
+ switch (info[i].property_id) {
+ case CAL_PROPERTY_EVENT_START:
+ case CAL_PROPERTY_EVENT_END:
+ case CAL_PROPERTY_EVENT_START_TZID:
+ case CAL_PROPERTY_EVENT_END_TZID:
+ case CAL_PROPERTY_EVENT_FREQ:
+ case CAL_PROPERTY_EVENT_RANGE_TYPE:
+ case CAL_PROPERTY_EVENT_UNTIL:
+ case CAL_PROPERTY_EVENT_COUNT:
+ case CAL_PROPERTY_EVENT_INTERVAL:
+ case CAL_PROPERTY_EVENT_BYSECOND:
+ case CAL_PROPERTY_EVENT_BYMINUTE:
+ case CAL_PROPERTY_EVENT_BYHOUR:
+ case CAL_PROPERTY_EVENT_BYDAY:
+ case CAL_PROPERTY_EVENT_BYMONTHDAY:
+ case CAL_PROPERTY_EVENT_BYYEARDAY:
+ case CAL_PROPERTY_EVENT_BYWEEKNO:
+ case CAL_PROPERTY_EVENT_BYMONTH:
+ case CAL_PROPERTY_EVENT_BYSETPOS:
+ case CAL_PROPERTY_EVENT_WKST:
+
+ is_dirty_in_time = DIRTY_IN_TIME;
+ break;
}
- else if (event->end.time.date.month < 1 || event->end.time.date.month > 12)
+ if (DIRTY_IN_OTHER != is_dirty_in_time) break;
+ }
+ DBG("%sirty in time", DIRTY_IN_OTHER == is_dirty_in_time ? "Not d" : "D");
+ return is_dirty_in_time;
+}
+
+time_t __get_time_diff(char *old_tzid, calendar_time_s *old, char *new_tzid, calendar_time_s *new)
+{
+ retvm_if (NULL == old, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: old time is NULL");
+ retvm_if (NULL == new, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: new time is NULL");
+
+ time_t diff = 0;
+ switch (old->type)
+ {
+ case CALENDAR_TIME_UTIME:
+ switch (new->type)
{
- ERR("check end month(input:%d)", event->end.time.date.month);
- return CALENDAR_ERROR_INVALID_PARAMETER;
+ case CALENDAR_TIME_UTIME:
+ DBG("%lld - %lld", old->time.utime, new->time.utime);
+ diff = old->time.utime - new->time.utime;
+ break;
+ case CALENDAR_TIME_LOCALTIME:
+ DBG("type is changed(%d) -> (%d)", old->type, new->type);
+ diff = old->time.utime - _cal_time_convert_itol(new_tzid,
+ new->time.date.year, new->time.date.month, new->time.date.mday,
+ new->time.date.hour, new->time.date.minute, new->time.date.second);
+ break;
}
- else if (event->end.time.date.mday < 1 || event->end.time.date.mday > 31)
+ break;
+ case CALENDAR_TIME_LOCALTIME:
+ switch (new->type)
{
- ERR("check end mday(input:%d)", event->end.time.date.mday);
- return CALENDAR_ERROR_INVALID_PARAMETER;
+ case CALENDAR_TIME_UTIME:
+ DBG("type is changed(%d) -> (%d)", old->type, new->type);
+ diff = _cal_time_convert_itol(old_tzid,
+ old->time.date.year, old->time.date.month, old->time.date.mday,
+ old->time.date.hour, old->time.date.minute, old->time.date.second) - new->time.utime;
+ break;
+ case CALENDAR_TIME_LOCALTIME:
+ diff = _cal_time_convert_itol(old_tzid,
+ old->time.date.year, old->time.date.month, old->time.date.mday,
+ old->time.date.hour, old->time.date.minute, old->time.date.second)
+ - _cal_time_convert_itol(new_tzid, new->time.date.year, new->time.date.month, new->time.date.mday,
+ new->time.date.hour, new->time.date.minute, new->time.date.second);
+ break;
}
+ break;
+ }
+ DBG("-------------time diff(%ld)", diff);
+ return diff;
+}
+
+static int __get_time_shifted_field(char *old_field, int old_type, int new_type, time_t time_diff, char **new_field)
+{
+ if (NULL == old_field || '\0' == *old_field) {
+ return CALENDAR_ERROR_NONE;
+ }
+
+ gchar **t = NULL;
+ t = g_strsplit_set(old_field, " ,", -1);
+ retvm_if (NULL == t, CALENDAR_ERROR_DB_FAILED, "g_strsplit_set() is failed");
+
+ int len_t = g_strv_length(t);
+
+ int len_field = strlen(old_field);
+ char *new= NULL;
+ new= calloc(len_field + (len_t * 8) + 1, sizeof(char)); // add (len_t * 8) for YYYYMMDD -> YYYYMMDDTHHMMSSZ
+ if (NULL == new) {
+ ERR("calloc() is failed");
+ g_strfreev(t);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ struct tm tm = {0};
+ time_t tt = 0;
- // check start > end; convert long long int.
- slli = _cal_time_convert_itol(NULL, event->start.time.date.year,
- event->start.time.date.month, event->start.time.date.mday, 0, 0, 0);
- elli = _cal_time_convert_itol(NULL, event->end.time.date.year,
- event->end.time.date.month, event->end.time.date.mday, 0, 0, 0);
+ int i;
+ for (i = 0; i < len_t; i++) {
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
+ switch (old_type)
+ {
+ case CALENDAR_TIME_UTIME:
+ sscanf(t[i], "%04d%02d%02dT%02d%02d%02dZ", &y, &m, &d, &h, &n, &s);
+ break;
+
+ case CALENDAR_TIME_LOCALTIME:
+ switch (strlen(t[i]))
+ {
+ case 8: // YYYYMMDD
+ sscanf(t[i], "%04d%02d%02d", &y, &m, &d);
+ break;
+
+ case 15: //YYYYMMDDTHHMMSS
+ sscanf(t[i], "%04d%02d%02dT%02d%02d%02d", &y, &m, &d, &h, &n, &s);
+ break;
+ }
+ break;
+ } // ct.type end switch
+
+ tm.tm_year = y - 1900;
+ tm.tm_mon = m - 1;
+ tm.tm_mday = d;
+ tm.tm_hour = h;
+ tm.tm_min = n;
+ tm.tm_sec = s;
- if (slli - elli > 1) // 1 is to ignore milliseconds
+ char buf[32] = {0};
+ switch (new_type)
{
- ERR("allday start(%lld) > end(%lld)", slli, elli);
- return CALENDAR_ERROR_INVALID_PARAMETER;
+ case CALENDAR_TIME_UTIME:
+ switch (strlen(t[i])) // check original type
+ {
+ case 8: // YYYYMMDD
+ case 15: //YYYYMMDDTHHMMSS
+ tt = timelocal(&tm) - time_diff;
+ gmtime_r(&tt, &tm);
+ snprintf(buf, sizeof(buf), "%s%04d%02d%02dT%02d%02d%02dZ",
+ i == 0 ? "" : ",", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
+ tm.tm_hour, tm.tm_min, tm.tm_sec);
+ break;
+
+ case 16: //YYYYMMDDTHHMMSSZ
+ tt = timegm(&tm) - time_diff;
+ gmtime_r(&tt, &tm);
+ snprintf(buf, sizeof(buf), "%s%04d%02d%02dT%02d%02d%02dZ",
+ i == 0 ? "" : ",", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
+ tm.tm_hour, tm.tm_min, tm.tm_sec);
+ break;
+ }
+
+ break;
+
+ case CALENDAR_TIME_LOCALTIME:
+ switch (strlen(t[i]))
+ {
+ case 8: // YYYYMMDD
+ tt = timegm(&tm) - time_diff;
+ gmtime_r(&tt, &tm);
+ snprintf(buf, sizeof(buf), "%s%04d%02d%02d",
+ i == 0 ? "" : ",", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
+ break;
+
+ case 15: //YYYYMMDDTHHMMSS
+ tt = timegm(&tm) - time_diff;
+ gmtime_r(&tt, &tm);
+ snprintf(buf, sizeof(buf), "%s%04d%02d%02dT%02d%02d%02d",
+ i == 0 ? "" : ",", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
+ tm.tm_hour, tm.tm_min, tm.tm_sec);
+ break;
+
+ case 16: //YYYYMMDDTHHMMSSZ
+ tt = timegm(&tm) - time_diff;
+ localtime_r(&tt, &tm);
+ snprintf(buf, sizeof(buf), "%s%04d%02d%02dT%02d%02d%02d",
+ i == 0 ? "" : ",", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
+ tm.tm_hour, tm.tm_min, tm.tm_sec);
+ break;
+ }
+ break;
}
- break;
+ strcat(new, buf);
}
+ g_strfreev(t);
+ if (new_field)
+ *new_field = new;
+ else
+ free(new);
return CALENDAR_ERROR_NONE;
}
-static int __cal_db_event_update_original_event_version(int original_event_id, int version)
+static int __update_exdate(cal_event_s *rec, time_t time_diff)
{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- cal_db_util_error_e dbret = CAL_DB_OK;
+ retvm_if (NULL == rec, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: rec is NULL");
+ if (NULL == rec->exdate || '\0' == *rec->exdate)
+ return CALENDAR_ERROR_NONE;
+ if (0 == time_diff)
+ return CALENDAR_ERROR_NONE;
- DBG("original_event(%d) changed_ver updated", original_event_id);
- if (original_event_id > 0)
- {
- snprintf(query, sizeof(query), "UPDATE %s SET "
- "changed_ver = %d WHERE id = %d ",
- CAL_TABLE_SCHEDULE, version, original_event_id);
+ int ret;
+ calendar_record_h db_record = NULL;
+ ret = calendar_db_get_record(_calendar_event._uri, rec->index, &db_record);
+ retvm_if(ret != CALENDAR_ERROR_NONE, ret, "calendar_db_get_record fail(%d)", ret);
- dbret = _cal_db_util_query_exec(query);
- if(CAL_DB_DONE != dbret)
- {
- ERR("_cal_db_util_query_exec() Failed");
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
+ // get time diff
+ char *db_tzid = NULL;
+ calendar_record_get_str_p(db_record, _calendar_event.start_tzid, &db_tzid);
+ calendar_time_s ct = {0};
+ calendar_record_get_caltime(db_record, _calendar_event.start_time, &ct);
+
+ char *new_exdate = NULL;
+ __get_time_shifted_field(rec->exdate, ct.type, rec->start.type, time_diff, &new_exdate);
+ free(rec->exdate);
+ rec->exdate = new_exdate;
+ DBG("new exdate[%s]", new_exdate);
+
+ calendar_record_destroy(db_record, true);
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __update_recurrence_id(calendar_record_h exception, int old_type, int new_type, time_t time_diff)
+{
+ ENTER();
+
+ cal_event_s *rec = (cal_event_s *)exception;
+ retvm_if (NULL == rec, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: rec is NULL");
+ if (NULL == rec->recurrence_id) {
+ DBG("No recurrence_id");
+ return CALENDAR_ERROR_NONE;
}
+
+ char *new_recurrence_id = NULL;
+ __get_time_shifted_field(rec->recurrence_id, rec->start.type, new_type, time_diff, &new_recurrence_id);
+ free(rec->recurrence_id);
+ rec->recurrence_id = new_recurrence_id;
+ DBG("new recurrence_id[%s]", new_recurrence_id);
+
return CALENDAR_ERROR_NONE;
}
-static int __cal_db_event_insert_record(calendar_record_h record, int* id)
+static int __update_record(calendar_record_h record, int is_dirty_in_time)
{
- int ret = -1;
- int event_id = -1;
- int index;
- int input_ver;
+ int ret;
char query[CAL_DB_SQL_MAX_LEN] = {0};
char dtstart_datetime[32] = {0};
char dtend_datetime[32] = {0};
cal_event_s* event = (cal_event_s*)(record);
cal_rrule_s *rrule = NULL;
cal_db_util_error_e dbret = CAL_DB_OK;
- int tmp = 0;
- int calendar_book_id = 0;
- calendar_record_h record_calendar = NULL;
int has_alarm = 0;
int timezone_id = 0;
+ int input_ver = 0;
retv_if(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(false == __cal_db_event_check_calendar_book_type(record), CALENDAR_ERROR_INVALID_PARAMETER);
- ret = __cal_db_event_check_value_validation(event);
+
+ ret = _cal_db_event_check_value_validation(event);
if (CALENDAR_ERROR_NONE != ret)
{
- ERR("__cal_db_event_check_value_validation() failed");
+ ERR("_cal_db_event_check_value_validation() failed");
return ret;
}
- ret = calendar_record_get_int(record, _calendar_event.calendar_book_id, &calendar_book_id);
- DBG("calendar_book_id(%d)", calendar_book_id);
+ // access control
+ if (_cal_access_control_have_write_permission(event->calendar_id) == false)
+ {
+ ERR("_cal_access_control_have_write_permission() failed");
+ return CALENDAR_ERROR_PERMISSION_DENIED;
+ }
- ret = calendar_db_get_record(_calendar_book._uri, calendar_book_id, &record_calendar);
- retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_INVALID_PARAMETER, "calendar_book_id is invalid");
+ if (event->common.properties_flags != NULL)
+ {
+ if (DIRTY_INIT == is_dirty_in_time) {
+ is_dirty_in_time = __is_dirty_in_time(record);
+ }
+ return __cal_db_event_update_dirty(record, is_dirty_in_time);
+ }
+ int time_diff = 0;
+ calendar_time_s ct = {0};
+ if (DIRTY_IN_TIME == is_dirty_in_time) {
+ calendar_record_h old_record = NULL;
+ ret = calendar_db_get_record(_calendar_event._uri, event->index, &old_record);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("calendar_db_get_record fail(%d)", ret);
+ return ret;
+ }
- calendar_record_destroy(record_calendar, true);
+ // get time diff
+ char *old_tzid = NULL;
+ calendar_record_get_str_p(old_record, _calendar_event.start_tzid, &old_tzid);
+ calendar_record_get_caltime(old_record, _calendar_event.start_time, &ct);
+ time_diff = __get_time_diff(old_tzid, &ct, event->start_tzid, &event->start);
+ calendar_record_destroy(old_record, true);
+ }
- has_alarm = _cal_db_alarm_has_alarm(event->alarm_list);
+ has_alarm = _cal_db_alarm_has_alarm(event->alarm_list);
_cal_time_get_timezone_from_table(event->start_tzid, NULL, &timezone_id);
input_ver = _cal_db_util_get_next_ver();
- ret = snprintf(query, sizeof(query),
- "INSERT INTO %s ("
- "type, "
- "created_ver, changed_ver, "
- "summary, description, location, categories, exdate, "
- "task_status, priority, "
- "timezone, "
- "contact_id, busy_status, sensitivity, uid, "
- "organizer_name, organizer_email, meeting_status, "
- "calendar_id, "
- "original_event_id, "
- "latitude, longitude, "
- "email_id, availability, "
- "created_time, completed_time, progress, "
- "dtstart_type, dtstart_utime, dtstart_datetime, dtstart_tzid, "
- "dtend_type, dtend_utime, dtend_datetime, dtend_tzid, "
- "last_mod, rrule_id, "
- "recurrence_id, rdate, has_attendee, "
- "has_alarm, system_type, updated, "
- "sync_data1, sync_data2, sync_data3, sync_data4 "
- ") VALUES ( "
- "%d, "
- "%d, %d, "
- "?, ?, ?, ?, ?, "
- "%d, %d, "
- "%d, "
- "%d, %d, %d, ?, "
- "?, ?, %d, "
- "%d, "
- "%d, "
- "%lf, %lf, "
- "%d, %d, "
- "strftime('%%s', 'now'), %lld, %d, "
- "%d, %lld, ?, ?, "
- "%d, %lld, ?, ?, "
- "strftime('%%s', 'now'), %d "
- ", ?, ?, %d, %d, %d, %ld"
- ", ?, ?, ?, ?"
- ") ",
- CAL_TABLE_SCHEDULE,
- CAL_SCH_TYPE_EVENT, /*event->cal_type,*/
- input_ver, input_ver,
- event->event_status, event->priority,
- event->timezone ? event->timezone : timezone_id,
- event->contact_id, event->busy_status, event->sensitivity,
- event->meeting_status,
- event->calendar_id,
- event->original_event_id,
- event->latitude, event->longitude,
- event->email_id, 0,//event->availability,
- (long long int)0, 0, //event->completed_time, event->progress,
- event->start.type, event->start.type == CALENDAR_TIME_UTIME ? event->start.time.utime : 0,
- event->end.type, event->end.type == CALENDAR_TIME_UTIME ? event->end.time.utime : 0,
- event->freq > 0 ? 1 : 0,
- event->attendee_list ? 1 : 0,
- has_alarm,
- event->system_type,
- event->updated);
+ int is_allday = 0;
+ if (CALENDAR_TIME_LOCALTIME == event->start.type
+ && (0 == event->start.time.date.hour)
+ && (0 == event->start.time.date.minute)
+ && (0 == event->start.time.date.second)
+ && (0 == event->end.time.date.hour)
+ && (0 == event->end.time.date.minute)
+ && (0 == event->end.time.date.second)) {
+ is_allday = 1;
+ }
+ snprintf(query, sizeof(query), "UPDATE %s SET "
+ "changed_ver = %d,"
+ "type = %d,"
+ "summary = ?,"
+ "description = ?,"
+ "location = ?,"
+ "categories = ?,"
+ "exdate = ?,"
+ "task_status = %d,"
+ "priority = %d,"
+ "timezone = %d, "
+ "contact_id = %d, "
+ "busy_status = %d, "
+ "sensitivity = %d, "
+ "uid = ?, "
+ "organizer_name = ?, "
+ "organizer_email = ?, "
+ "meeting_status = %d, "
+ "calendar_id = %d, "
+ "original_event_id = %d,"
+ "latitude = %lf,"
+ "longitude = %lf,"
+ "email_id = %d,"
+ "completed_time = %lld,"
+ "progress = %d, "
+ "dtstart_type = %d, "
+ "dtstart_utime = %lld, "
+ "dtstart_datetime = ?, "
+ "dtstart_tzid = ?, "
+ "dtend_type = %d, "
+ "dtend_utime = %lld, "
+ "dtend_datetime = ?, "
+ "dtend_tzid = ?, "
+ "last_mod = strftime('%%s', 'now'), "
+ "rrule_id = %d, "
+ "recurrence_id = ?, "
+ "rdate = ?, "
+ "has_attendee = %d, "
+ "has_alarm = %d, "
+ "system_type = %d, "
+ "updated = %ld, "
+ "sync_data1 = ?, "
+ "sync_data2 = ?, "
+ "sync_data3 = ?, "
+ "sync_data4 = ?,"
+ "has_exception = %d, "
+ "has_extended = %d, "
+ "freq = %d, "
+ "is_allday = %d "
+ "WHERE id = %d;",
+ CAL_TABLE_SCHEDULE,
+ input_ver,
+ CAL_SCH_TYPE_EVENT,/*event->cal_type,*/
+ event->event_status,
+ event->priority,
+ event->timezone ? event->timezone : timezone_id,
+ event->contact_id,
+ event->busy_status,
+ event->sensitivity,
+ event->meeting_status,
+ event->calendar_id,
+ event->original_event_id,
+ event->latitude,
+ event->longitude,
+ event->email_id,
+ (long long int)0,//event->completed_time,
+ 0,//event->progress,
+ event->start.type,
+ event->start.type == CALENDAR_TIME_UTIME ? event->start.time.utime : 0,
+ event->end.type,
+ event->end.type == CALENDAR_TIME_UTIME ? event->end.time.utime : 0,
+ event->freq > 0 ? 1 : 0,
+ (event->attendee_list && 0 < event->attendee_list->count)? 1: 0,
+ has_alarm,
+ event->system_type,
+ event->updated,
+ (event->exception_list && 0 < event->exception_list->count)? 1 : 0,
+ (event->extended_list && 0 < event->extended_list->count)? 1 : 0,
+ event->freq,
+ is_allday,
+ event->index);
stmt = _cal_db_util_query_prepare(query);
- retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED,
- "_cal_db_util_query_prepare() Failed");
+ retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "_cal_db_util_query_prepare() Failed");
- index = 1;
+ int index = 1;
if (event->summary)
_cal_db_util_stmt_bind_text(stmt, index, event->summary);
_cal_db_util_stmt_bind_text(stmt, index, event->categories);
index++;
- if (event->exdate)
+ if (event->exdate) {
+ if (DIRTY_IN_TIME == is_dirty_in_time) {
+ __update_exdate(event, time_diff);
+ }
_cal_db_util_stmt_bind_text(stmt, index, event->exdate);
+ }
index++;
if (event->uid)
if (CALENDAR_TIME_LOCALTIME == event->start.type)
{
- snprintf(dtstart_datetime, sizeof(dtstart_datetime), "%04d%02d%02d",
+ snprintf(dtstart_datetime, sizeof(dtstart_datetime), CAL_FORMAT_LOCAL_DATETIME,
event->start.time.date.year,
event->start.time.date.month,
- event->start.time.date.mday);
+ event->start.time.date.mday,
+ event->start.time.date.hour,
+ event->start.time.date.minute,
+ event->start.time.date.second);
_cal_db_util_stmt_bind_text(stmt, index, dtstart_datetime);
}
index++;
if (CALENDAR_TIME_LOCALTIME == event->end.type)
{
- snprintf(dtend_datetime, sizeof(dtend_datetime), "%04d%02d%02d",
+ snprintf(dtend_datetime, sizeof(dtend_datetime), CAL_FORMAT_LOCAL_DATETIME,
event->end.time.date.year,
event->end.time.date.month,
- event->end.time.date.mday);
+ event->end.time.date.mday,
+ event->end.time.date.hour,
+ event->end.time.date.minute,
+ event->end.time.date.second);
_cal_db_util_stmt_bind_text(stmt, index, dtend_datetime);
}
index++;
_cal_db_util_stmt_bind_text(stmt, index, event->end_tzid);
index++;
- if (event->recurrence_id)
- _cal_db_util_stmt_bind_text(stmt, index, event->recurrence_id);
+ if (event->recurrence_id)
+ _cal_db_util_stmt_bind_text(stmt, index, event->recurrence_id);
index++;
-
- if (event->rdate)
- _cal_db_util_stmt_bind_text(stmt, index, event->rdate);
+ if (event->rdate)
+ _cal_db_util_stmt_bind_text(stmt, index, event->rdate);
index++;
-
- if (event->sync_data1)
- _cal_db_util_stmt_bind_text(stmt, index, event->sync_data1);
+ if (event->sync_data1)
+ _cal_db_util_stmt_bind_text(stmt, index, event->sync_data1);
index++;
-
- if (event->sync_data2)
- _cal_db_util_stmt_bind_text(stmt, index, event->sync_data2);
+ if (event->sync_data2)
+ _cal_db_util_stmt_bind_text(stmt, index, event->sync_data2);
index++;
-
- if (event->sync_data3)
- _cal_db_util_stmt_bind_text(stmt, index, event->sync_data3);
+ if (event->sync_data3)
+ _cal_db_util_stmt_bind_text(stmt, index, event->sync_data3);
index++;
-
- if (event->sync_data4)
- _cal_db_util_stmt_bind_text(stmt, index, event->sync_data4);
+ if (event->sync_data4)
+ _cal_db_util_stmt_bind_text(stmt, index, event->sync_data4);
index++;
- dbret = _cal_db_util_stmt_step(stmt);
- if (CAL_DB_DONE != dbret)
- {
+ dbret = _cal_db_util_stmt_step(stmt);
+ if (CAL_DB_DONE != dbret) {
sqlite3_finalize(stmt);
- ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
+ ERR("sqlite3_step() Failed(%d)", dbret);
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
return CALENDAR_ERROR_DB_FAILED;
}
}
- event_id = _cal_db_util_last_insert_id();
sqlite3_finalize(stmt);
// update parent event changed ver in case this event is exception mod
// which is original_event_id > 0
- __cal_db_event_update_original_event_version(event->original_event_id, input_ver);
+ _cal_db_event_update_original_event_version(event->original_event_id, input_ver);
- calendar_record_get_int(record, _calendar_event.id, &tmp);
- _cal_record_set_int(record, _calendar_event.id, event_id);
- if (id)
- {
- *id = event_id;
- }
-
- _cal_db_rrule_set_default(record);
+// _cal_db_rrule_set_default(record);
_cal_db_rrule_get_rrule_from_event(record, &rrule);
- if (rrule)
- {
- _cal_db_rrule_insert_record(event_id, rrule);
- CAL_FREE(rrule);
- }
- _cal_db_instance_publish_record(record);
+ _cal_db_rrule_update_record(event->index, rrule); // if rrule turns none, update 0.
+ CAL_FREE(rrule);
- calendar_list_h list;
- if (event->alarm_list)
- {
- list = NULL;
- DBG("insert alarm");
- ret = _cal_db_alarm_convert_gtoh(event->alarm_list, event_id, &list);
- ret = calendar_db_insert_records(list, NULL, NULL);
- ret = calendar_list_destroy(list, false);
- }
- else
- {
- DBG("No alarm");
- }
+ if (DIRTY_IN_TIME == is_dirty_in_time) {
+ _cal_db_instance_discard_record(event->index);
+ _cal_db_instance_publish_record(record);
- if (event->attendee_list)
- {
- list = NULL;
- DBG("insert attendee");
- ret = _cal_db_attendee_convert_gtoh(event->attendee_list, event_id, &list);
- ret = calendar_db_insert_records(list, NULL, NULL);
- ret = calendar_list_destroy(list, false);
- }
- else
- {
- DBG("No attendee");
+ } else {
+ // check exdate
+ _cal_db_instance_update_exdate_del(event->index, event->exdate);
}
- if (event->original_event_id < 0)
- {
- if (event->exception_list)
- {
- DBG("insert exception");
- list = NULL;
- ret = __cal_db_event_exception_convert_gtoh(event->exception_list, event_id, event->calendar_id, &list);
- ret = calendar_db_insert_records(list, NULL, NULL);
- ret = calendar_list_destroy(list, false);
- }
- else
- {
- DBG("No exception");
+ while ((event->uid && *event->uid) && (NULL == event->recurrence_id || '\0' == *event->recurrence_id )) {
+ // check if exception mod has. recurrence_id
+ GList *list = NULL;
+ list = _cal_db_event_get_list_with_uid(event->uid, event->index);
+ if (NULL == list)
+ break;
+ GList *l = g_list_first(list);
+ if (l) {
+ int child_id = GPOINTER_TO_INT(l->data);
+ // update children original_event_id
+ _cal_db_event_update_child_origina_event_id(child_id, event->index);
+ char *recurrence_id = NULL;
+ recurrence_id = _cal_db_event_get_recurrence_id_from_exception(child_id);
+ if (recurrence_id) {
+ // remove parent instance
+ _cal_db_event_apply_recurrence_id(event->index, event, recurrence_id, child_id);
+ free(recurrence_id);
+ }
+ l = g_list_next(l);
}
+ g_list_free(list);
+ break;
}
- if (event->extended_list)
- {
- DBG("insert extended");
- list = NULL;
- ret = _cal_db_extended_convert_gtoh(event->extended_list, event_id, CALENDAR_RECORD_TYPE_EVENT, &list);
- ret = calendar_db_insert_records(list, NULL, NULL);
- ret = calendar_list_destroy(list, false);
- }
- else
- {
- DBG("No extended");
- }
-
- _cal_db_util_notify(CAL_NOTI_TYPE_EVENT);
-
- _cal_record_set_int(record, _calendar_event.id, tmp);
-
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_db_event_get_record(int id, calendar_record_h* out_record)
-{
- char query[CAL_DB_SQL_MAX_LEN];
- int ret = 0;
- sqlite3_stmt *stmt = NULL;
- cal_event_s *event = NULL;
- cal_rrule_s *rrule = NULL;
- GList *alarm_list, *attendee_list;
- GList *exception_list = NULL, *extended_list = NULL;
- cal_db_util_error_e dbret = CAL_DB_OK;
+ _cal_db_alarm_delete_with_id(event->index);
+ _cal_db_attendee_delete_with_id(event->index);
+ _cal_db_extended_delete_with_id(event->index, CALENDAR_RECORD_TYPE_EVENT);
- ret = calendar_record_create( _calendar_event._uri ,out_record);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_record_create(%d)", ret);
- return CALENDAR_ERROR_OUT_OF_MEMORY;
+ if (event->alarm_list && 0 < event->alarm_list->count) {
+ ret = _cal_db_alarm_insert_records(event->alarm_list, event->index);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_db_alarm_insert_records() failed(%x)", ret);
}
- event = (cal_event_s*)(*out_record);
-
- snprintf(query, sizeof(query),
- "SELECT * FROM %s "
- "WHERE id = %d AND type = %d AND calendar_id IN "
- "(select id from %s where deleted = 0)",
- CAL_TABLE_SCHEDULE,
- id, CALENDAR_BOOK_TYPE_EVENT,
- CAL_TABLE_CALENDAR);
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("query[%s]", query);
- ERR("_cal_db_util_query_prepare() Failed");
- calendar_record_destroy(*out_record, true);
- *out_record = NULL;
- return CALENDAR_ERROR_DB_FAILED;
+ if (event->attendee_list && 0 < event->attendee_list->count) {
+ ret = _cal_db_attendee_insert_records(event->attendee_list, event->index);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_db_attendee_insert_records() failed(%x)", ret);
}
- dbret = _cal_db_util_stmt_step(stmt);
- if (dbret != CAL_DB_ROW)
- {
- ERR("query[%s]", query);
- ERR("Failed to step stmt(%d)", dbret);
- sqlite3_finalize(stmt);
- calendar_record_destroy(*out_record, true);
- *out_record = NULL;
- switch (dbret)
- {
- case CAL_DB_DONE:
- ERR("Failed to find record(id:%d, ret:%d)", id, dbret);
- return CALENDAR_ERROR_DB_RECORD_NOT_FOUND;
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
+ if (event->exception_list && 0 < event->exception_list->count) {
+ ret = __cal_db_event_exception_update(event->exception_list, event->index, event->calendar_id, is_dirty_in_time, time_diff, ct.type, event->start.type);
+ warn_if(CALENDAR_ERROR_NONE != ret, "__cal_db_event_exception_update() Failed(%d)", ret);
}
- __cal_db_event_get_stmt(stmt,false,*out_record);
- sqlite3_finalize(stmt);
- stmt = NULL;
-
- if (_cal_db_rrule_get_rrule(event->index, &rrule) == CALENDAR_ERROR_NONE )
- {
- _cal_db_rrule_set_rrule_to_event(rrule, *out_record);
- CAL_FREE(rrule);
+ if (event->extended_list && 0 < event->extended_list->count) {
+ ret = _cal_db_extended_insert_records(event->extended_list, event->index, CALENDAR_RECORD_TYPE_EVENT);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_db_extended_insert_records() Failed(%d)", ret);
}
- _cal_db_alarm_get_records(event->index, &alarm_list);
- event->alarm_list = alarm_list;
-
- _cal_db_attendee_get_records(event->index, &attendee_list);
- event->attendee_list = attendee_list;
-
- __cal_db_event_exception_get_records(event->index, &exception_list);
- event->exception_list = exception_list;
-
- _cal_db_extended_get_records(event->index, CALENDAR_RECORD_TYPE_EVENT, &extended_list);
- event->extended_list = extended_list;
-
- event->has_alarm = 0;
- if (event->alarm_list)
- {
- if (g_list_length(event->alarm_list) != 0)
- {
- event->has_alarm = 1;
- }
- }
- event->has_attendee = 0;
- if (event->attendee_list)
- {
- if (g_list_length(event->attendee_list) != 0)
- {
- event->has_attendee = 1;
- }
- }
+ _cal_db_util_notify(CAL_NOTI_TYPE_EVENT);
return CALENDAR_ERROR_NONE;
}
static int __cal_db_event_update_record(calendar_record_h record)
{
- int ret;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- char dtstart_datetime[32] = {0};
- char dtend_datetime[32] = {0};
- sqlite3_stmt *stmt = NULL;
- cal_event_s* event = (cal_event_s*)(record);
- cal_rrule_s *rrule = NULL;
- cal_db_util_error_e dbret = CAL_DB_OK;
- int has_alarm = 0;
- int timezone_id = 0;
- int input_ver = 0;
-
- retv_if(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER);
-
- ret = __cal_db_event_check_value_validation(event);
- if (CALENDAR_ERROR_NONE != ret)
- {
- ERR("__cal_db_event_check_value_validation() failed");
- return ret;
- }
-
- if (event->common.properties_flags != NULL)
- {
- return __cal_db_event_update_dirty(record);
- }
- has_alarm = _cal_db_alarm_has_alarm(event->alarm_list);
- _cal_time_get_timezone_from_table(event->start_tzid, NULL, &timezone_id);
- input_ver = _cal_db_util_get_next_ver();
- snprintf(query, sizeof(query), "UPDATE %s SET "
- "changed_ver = %d,"
- "type = %d,"
- "summary = ?,"
- "description = ?,"
- "location = ?,"
- "categories = ?,"
- "exdate = ?,"
- "task_status = %d,"
- "priority = %d,"
- "timezone = %d, "
- "contact_id = %d, "
- "busy_status = %d, "
- "sensitivity = %d, "
- "uid = ?, "
- "organizer_name = ?, "
- "organizer_email = ?, "
- "meeting_status = %d, "
- "calendar_id = %d, "
- "original_event_id = %d,"
- "latitude = %lf,"
- "longitude = %lf,"
- "email_id = %d,"
- "availability = %d,"
- "completed_time = %lld,"
- "progress = %d, "
- "dtstart_type = %d, "
- "dtstart_utime = %lld, "
- "dtstart_datetime = ?, "
- "dtstart_tzid = ?, "
- "dtend_type = %d, "
- "dtend_utime = %lld, "
- "dtend_datetime = ?, "
- "dtend_tzid = ?, "
- "last_mod = strftime('%%s', 'now'), "
- "rrule_id = %d, "
- "recurrence_id = ?, "
- "rdate = ?, "
- "has_attendee = %d, "
- "has_alarm = %d, "
- "system_type = %d, "
- "updated = %ld, "
- "sync_data1 = ?, "
- "sync_data2 = ?, "
- "sync_data3 = ?, "
- "sync_data4 = ? "
- "WHERE id = %d;",
- CAL_TABLE_SCHEDULE,
- input_ver,
- CAL_SCH_TYPE_EVENT,/*event->cal_type,*/
- event->event_status,
- event->priority,
- event->timezone ? event->timezone : timezone_id,
- event->contact_id,
- event->busy_status,
- event->sensitivity,
- event->meeting_status,
- event->calendar_id,
- event->original_event_id,
- event->latitude,
- event->longitude,
- event->email_id,
- 0,//event->availability,
- (long long int)0,//event->completed_time,
- 0,//event->progress,
- event->start.type,
- event->start.type == CALENDAR_TIME_UTIME ? event->start.time.utime : 0,
- event->end.type,
- event->end.type == CALENDAR_TIME_UTIME ? event->end.time.utime : 0,
- event->freq > 0 ? 1 : 0,
- event->attendee_list ? 1: 0,
- has_alarm,
- event->system_type,
- event->updated,
- event->index);
-
- stmt = _cal_db_util_query_prepare(query);
- retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "_cal_db_util_query_prepare() Failed");
-
- int index = 1;
-
- if (event->summary)
- _cal_db_util_stmt_bind_text(stmt, index, event->summary);
- index++;
-
- if (event->description)
- _cal_db_util_stmt_bind_text(stmt, index, event->description);
- index++;
-
- if (event->location)
- _cal_db_util_stmt_bind_text(stmt, index, event->location);
- index++;
-
- if (event->categories)
- _cal_db_util_stmt_bind_text(stmt, index, event->categories);
- index++;
-
- if (event->exdate)
- _cal_db_util_stmt_bind_text(stmt, index, event->exdate);
- index++;
-
- if (event->uid)
- _cal_db_util_stmt_bind_text(stmt, index, event->uid);
- index++;
-
- if (event->organizer_name)
- _cal_db_util_stmt_bind_text(stmt, index, event->organizer_name);
- index++;
-
- if (event->organizer_email)
- _cal_db_util_stmt_bind_text(stmt, index, event->organizer_email);
- index++;
-
- if (CALENDAR_TIME_LOCALTIME == event->start.type)
- {
- snprintf(dtstart_datetime, sizeof(dtstart_datetime), "%04d%02d%02d",
- event->start.time.date.year,
- event->start.time.date.month,
- event->start.time.date.mday);
- _cal_db_util_stmt_bind_text(stmt, index, dtstart_datetime);
- }
- index++;
-
- if (event->start_tzid)
- _cal_db_util_stmt_bind_text(stmt, index, event->start_tzid);
- index++;
-
- if (CALENDAR_TIME_LOCALTIME == event->end.type)
- {
- snprintf(dtend_datetime, sizeof(dtend_datetime), "%04d%02d%02d",
- event->end.time.date.year,
- event->end.time.date.month,
- event->end.time.date.mday);
- _cal_db_util_stmt_bind_text(stmt, index, dtend_datetime);
- }
- index++;
-
- if (event->end_tzid)
- _cal_db_util_stmt_bind_text(stmt, index, event->end_tzid);
- index++;
-
- if (event->recurrence_id)
- _cal_db_util_stmt_bind_text(stmt, index, event->recurrence_id);
- index++;
- if (event->rdate)
- _cal_db_util_stmt_bind_text(stmt, index, event->rdate);
- index++;
- if (event->sync_data1)
- _cal_db_util_stmt_bind_text(stmt, index, event->sync_data1);
- index++;
- if (event->sync_data2)
- _cal_db_util_stmt_bind_text(stmt, index, event->sync_data2);
- index++;
- if (event->sync_data3)
- _cal_db_util_stmt_bind_text(stmt, index, event->sync_data3);
- index++;
- if (event->sync_data4)
- _cal_db_util_stmt_bind_text(stmt, index, event->sync_data4);
- index++;
-
- dbret = _cal_db_util_stmt_step(stmt);
- if (CAL_DB_DONE != dbret) {
- sqlite3_finalize(stmt);
- ERR("sqlite3_step() Failed(%d)", dbret);
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- sqlite3_finalize(stmt);
-
- // update parent event changed ver in case this event is exception mod
- // which is original_event_id > 0
- __cal_db_event_update_original_event_version(event->original_event_id, input_ver);
-
- _cal_db_rrule_get_rrule_from_event(record, &rrule);
- _cal_db_rrule_update_record(event->index, rrule); // if rrule turns none, update 0.
- CAL_FREE(rrule);
-
- ret = _cal_db_instance_discard_record(record);
- retvm_if(ret != CALENDAR_ERROR_NONE, CALENDAR_ERROR_DB_FAILED,
- "_cal_db_instance_discard_record() Failed(%d)", ret);
-
- _cal_db_instance_publish_record(record);
-
- _cal_db_alarm_delete_with_id(event->index);
- _cal_db_attendee_delete_with_id(event->index);
- __cal_db_event_exception_delete_with_id(event->index);
- _cal_db_extended_delete_with_id(event->index, CALENDAR_RECORD_TYPE_EVENT);
-
- calendar_list_h list;
-
- list = NULL;
- ret = _cal_db_alarm_convert_gtoh(event->alarm_list,event->index, &list);
- if (ret == CALENDAR_ERROR_NONE)
- {
- calendar_db_insert_records(list, NULL, NULL);
- calendar_list_destroy(list, false);
- }
-
- list = NULL;
- ret = _cal_db_attendee_convert_gtoh(event->attendee_list,event->index, &list);
- if (ret == CALENDAR_ERROR_NONE)
- {
- calendar_db_insert_records(list, NULL, NULL);
- calendar_list_destroy(list, false);
- }
-
- if (event->exception_list)
- {
- DBG("insert exception");
- list = NULL;
- ret = __cal_db_event_exception_convert_gtoh(event->exception_list, event->index, event->calendar_id, &list);
- if (ret == CALENDAR_ERROR_NONE)
- {
- calendar_db_insert_records(list, NULL, NULL);
- calendar_list_destroy(list, false);
- }
- }
-
- if (event->extended_list)
- {
- DBG("insert extended");
- list = NULL;
- ret = _cal_db_extended_convert_gtoh(event->extended_list, event->index, CALENDAR_RECORD_TYPE_EVENT, &list);
- if (ret == CALENDAR_ERROR_NONE)
- {
- calendar_db_insert_records(list, NULL, NULL);
- calendar_list_destroy(list, false);
- }
- }
-
- _cal_db_util_notify(CAL_NOTI_TYPE_EVENT);
-
- return CALENDAR_ERROR_NONE;
+ return __update_record(record, DIRTY_INIT);
}
-static int __cal_db_event_add_exdate(calendar_record_h record)
+static int __cal_db_event_add_exdate(int original_event_id, char* recurrence_id)
{
char query[CAL_DB_SQL_MAX_LEN];
sqlite3_stmt *stmt = NULL;
cal_db_util_error_e dbret = CAL_DB_OK;
- cal_event_s *event = (cal_event_s *)record;
- if (NULL == event)
- {
- ERR("Invalid parameter: event is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- if (event->original_event_id < 0)
+
+ if (original_event_id < 0)
{
return CALENDAR_ERROR_NONE;
}
DBG("This is exception mod event");
- if (NULL == event->recurrence_id)
+ if (NULL == recurrence_id)
{
ERR("This event should have recurrence_id");
return CALENDAR_ERROR_NONE;
}
- DBG("Exdate parent(id:%d) and recurrence_id[%s]", event->original_event_id, event->recurrence_id);
+ DBG("Exdate parent(id:%d) and recurrence_id[%s]", original_event_id, recurrence_id);
// get exdate from original event.
snprintf(query, sizeof(query), "SELECT exdate FROM %s WHERE id = %d ",
- CAL_TABLE_SCHEDULE, event->original_event_id);
+ CAL_TABLE_SCHEDULE, original_event_id);
stmt = _cal_db_util_query_prepare(query);
if (NULL == stmt)
{
- ERR("query[%s]", query);
+ SEC_ERR("query[%s]", query);
ERR("_cal_db_util_query_prepare() Failed");
return CALENDAR_ERROR_DB_FAILED;
}
// add recurrence id to end of the exdate of original event.
- const unsigned char *temp = NULL;
+ const unsigned char *temp = NULL;
int len = 0;
char *exdate = NULL;
if (CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
{
temp = sqlite3_column_text(stmt, 0);
- if (NULL == temp || strlen(temp) < 1)
+ if (NULL == temp || strlen((char *)temp) < 1)
{
- exdate = strdup(event->recurrence_id);
+ exdate = strdup(recurrence_id);
DBG("append first exdate[%s]", exdate);
}
else
{
- if (strstr((char *)temp, event->recurrence_id))
+ if (strstr((char *)temp, recurrence_id))
{
DBG("warn: recurrence id already is registered to exdate");
sqlite3_finalize(stmt);
return CALENDAR_ERROR_NONE;
}
- len = strlen((const char *)temp) + strlen(event->recurrence_id) + 2;
+ len = strlen((const char *)temp) + strlen(recurrence_id) + 2;
exdate = calloc(len, sizeof(char));
if (NULL == exdate)
{
sqlite3_finalize(stmt);
return CALENDAR_ERROR_DB_FAILED;
}
- snprintf(exdate, len, "%s,%s", temp, event->recurrence_id);
- DBG("append [%s] to aleady has exdate [%s]", temp, event->recurrence_id);
+ snprintf(exdate, len, "%s,%s", temp, recurrence_id);
+ DBG("append [%s] to aleady has exdate [%s]", temp, recurrence_id);
}
}
else
{
- DBG("Failed to get exdate: event_id(%d)", event->original_event_id);
+ DBG("Failed to get exdate: event_id(%d)", original_event_id);
}
sqlite3_finalize(stmt);
stmt = NULL;
// update exdate
DBG("update to recurrence id to exdate[%s]", exdate);
- snprintf(query, sizeof(query), "UPDATE %s SET exdate = ? WHERE id = %d ",
- CAL_TABLE_SCHEDULE, event->original_event_id);
+ int input_ver = _cal_db_util_get_next_ver();
+ snprintf(query, sizeof(query), "UPDATE %s SET exdate = ?, changed_ver=%d WHERE id = %d ",
+ CAL_TABLE_SCHEDULE, input_ver, original_event_id);
stmt = _cal_db_util_query_prepare(query);
if (NULL == stmt)
{
- DBG("query[%s]", query);
+ SEC_ERR("query[%s]", query);
ERR("_cal_db_util_query_prepare() failed");
if (exdate) free(exdate);
return CALENDAR_ERROR_DB_FAILED;
int index = 1;
_cal_db_util_stmt_bind_text(stmt, index, exdate);
- dbret = _cal_db_util_stmt_step(stmt);
+ dbret = _cal_db_util_stmt_step(stmt);
sqlite3_finalize(stmt);
if (CAL_DB_DONE != dbret) {
ERR("sqlite3_step() Failed(%d)", dbret);
static int __cal_db_event_delete_record(int id)
{
- int ret;
+ int ret = CALENDAR_ERROR_NONE;
cal_db_util_error_e dbret = CAL_DB_OK;
int calendar_book_id;
- int account_id;
char query[CAL_DB_SQL_MAX_LEN] = {0};
- calendar_record_h record_event;
- calendar_record_h record_calendar;
+ int created_ver = 0;
+ int original_event_id = 0;
+ char *recurrence_id = NULL;
+ calendar_book_sync_event_type_e sync_event_type = CALENDAR_BOOK_SYNC_EVENT_FOR_ME;
- DBG("delete record(id:%d", id);
+ DBG("delete record(id:%d)", id);
retvm_if(id < 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid argument: id < 0");
- ret = calendar_db_get_record(_calendar_event._uri, id, &record_event);
+ // get calendar_id, created_ver, original_event_id, recurrence_id
+ ret = __cal_db_event_get_deleted_data(id, &calendar_book_id, &created_ver, &original_event_id, &recurrence_id);
if (CALENDAR_ERROR_NONE != ret)
{
- DBG("calendar_db_get_record() failed");
- return CALENDAR_ERROR_DB_RECORD_NOT_FOUND;
+ DBG("__cal_db_event_get_deleted_data() failed");
+ return ret;
}
- ret = calendar_record_get_int(record_event,
- _calendar_event.calendar_book_id, &calendar_book_id);
- DBG("calendar_book_id(%d)", calendar_book_id);
-
- ret = calendar_db_get_record(_calendar_book._uri,
- calendar_book_id, &record_calendar);
- ret = calendar_record_get_int(record_calendar,
- _calendar_book.account_id, &account_id);
- DBG("account_id(%d)", account_id);
-
- if (account_id == LOCAL_ACCOUNT_ID) {
- DBG("insert deleted table");
- snprintf(query, sizeof(query),
- "INSERT INTO %s ( "
- "schedule_id, schedule_type, "
- "calendar_id, deleted_ver "
- ") VALUES ( "
- "%d, %d, "
- "%d, %d ) ",
- CAL_TABLE_DELETED,
- id, CAL_RECORD_TYPE_EVENT,
- calendar_book_id, _cal_db_util_get_next_ver());
- DBG("query[%s]", query);
-
- dbret = _cal_db_util_query_exec(query);
- if(CAL_DB_OK != dbret)
- {
- ERR("_cal_db_util_query_exec() Failed");
- calendar_record_destroy(record_event, true);
- calendar_record_destroy(record_calendar, true);
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- DBG("delete event");
- snprintf(query, sizeof(query), "DELETE FROM %s WHERE id = %d ",
- CAL_TABLE_SCHEDULE, id);
+ //access control
+ if (_cal_access_control_have_write_permission(calendar_book_id) == false)
+ {
+ ERR("fail");
+ CAL_FREE(recurrence_id);
+ return CALENDAR_ERROR_PERMISSION_DENIED;
+ }
- dbret = _cal_db_util_query_exec(query);
- if(CAL_DB_OK != dbret)
- {
- DBG("query[%s]", query);
- ERR("_cal_db_util_query_exec() Failed");
- calendar_record_destroy(record_event, true);
- calendar_record_destroy(record_calendar, true);
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
+ if (original_event_id > 0)
+ {
+ // start:add record to exdate if this record is exception mod.
+ __cal_db_event_add_exdate(original_event_id, recurrence_id);
+ }
+ CAL_FREE(recurrence_id);
- DBG("attendee, alarm and rrule is deleted by trigger");
+ snprintf(query, sizeof(query), "SELECT sync_event FROM %s WHERE id = %d ",
+ CAL_TABLE_CALENDAR, calendar_book_id);
+ ret = _cal_db_util_query_get_first_int_result(query, NULL, (int *)&sync_event_type);
+ if (CALENDAR_ERROR_NONE != ret)
+ {
+ ERR("_cal_db_util_query_get_first_int_result() failed");
+ return ret;
+ }
+ DBG("sync_event_type(%d)", sync_event_type);
- } else {
+ if (sync_event_type == CALENDAR_BOOK_SYNC_EVENT_FOR_EVERY_AND_REMAIN)
+ {
DBG("set is_delete");
snprintf(query, sizeof(query),
"UPDATE %s "
{
DBG("query[%s]", query);
ERR("_cal_db_util_query_exec() failed (%d)", dbret);
- calendar_record_destroy(record_event, true);
- calendar_record_destroy(record_calendar, true);
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
}
DBG("attendee, alarm and rrule will be deleted by trigger after sync clean");
- }
- ret = _cal_db_instance_discard_record(record_event);
- retvm_if(ret != CALENDAR_ERROR_NONE, CALENDAR_ERROR_DB_FAILED,
- "_cal_db_instance_discard_record() Failed(%d)", ret);
+ } else
+ {
+ _cal_db_util_get_next_ver();
+
+ DBG("delete event");
+ snprintf(query, sizeof(query), "DELETE FROM %s WHERE id = %d ",
+ CAL_TABLE_SCHEDULE, id);
- // start:add record to exdate if this record is exception mod.
- __cal_db_event_add_exdate(record_event);
+ dbret = _cal_db_util_query_exec(query);
+ if(CAL_DB_OK != dbret)
+ {
+ DBG("query[%s]", query);
+ ERR("_cal_db_util_query_exec() Failed");
+ switch (dbret)
+ {
+ case CAL_DB_ERROR_NO_SPACE:
+ return CALENDAR_ERROR_FILE_NO_SPACE;
+ default:
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
- ret = calendar_record_destroy(record_event, true);
- ret = calendar_record_destroy(record_calendar, true);
+ DBG("attendee, alarm and rrule is deleted by trigger");
+ }
+ _cal_db_instance_discard_record(id);
_cal_db_util_notify(CAL_NOTI_TYPE_EVENT);
return CALENDAR_ERROR_NONE;
static int __cal_db_event_get_all_records(int offset, int limit, calendar_list_h* out_list)
{
- int ret = CALENDAR_ERROR_NONE;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- char offsetquery[CAL_DB_SQL_MAX_LEN] = {0};
- char limitquery[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
-
- retvm_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- ret = calendar_list_create(out_list);
- retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- if (offset > 0)
- {
- snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
- }
- if (limit > 0)
- {
- snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
- }
- snprintf(query, sizeof(query), "SELECT * FROM %s %s %s", CAL_VIEW_TABLE_EVENT,limitquery,offsetquery);
-
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() Failed");
- calendar_list_destroy(*out_list, true);
+ int ret = CALENDAR_ERROR_NONE;
+ char offsetquery[CAL_DB_SQL_MAX_LEN] = {0};
+ char limitquery[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+
+ retvm_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ ret = calendar_list_create(out_list);
+ retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ if (offset > 0)
+ {
+ snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
+ }
+ if (limit > 0)
+ {
+ snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
+ }
+
+ char *query_str = NULL;
+ _cal_db_append_string(&query_str, "SELECT * FROM");
+ _cal_db_append_string(&query_str, CAL_VIEW_TABLE_EVENT);
+ _cal_db_append_string(&query_str, limitquery);
+ _cal_db_append_string(&query_str, offsetquery);
+
+ stmt = _cal_db_util_query_prepare(query_str);
+ if (NULL == stmt)
+ {
+ ERR("_cal_db_util_query_prepare() Failed");
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- return CALENDAR_ERROR_DB_FAILED;
- }
-
- while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- calendar_record_h record;
- // stmt -> record
- ret = calendar_record_create(_calendar_event._uri,&record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
+ CAL_FREE(query_str);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ {
+ calendar_record_h record;
+ int exception=0, extended=0;
+ // stmt -> record
+ ret = calendar_record_create(_calendar_event._uri,&record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- sqlite3_finalize(stmt);
- return ret;
- }
- __cal_db_event_get_stmt(stmt, true, record);
-
- // child
- int has_attendee = 0, has_alarm = 0;
- int record_id = 0;
- cal_event_s* pevent = (cal_event_s*) record;
- calendar_record_get_int(record, _calendar_event.id, &record_id);
- if(calendar_record_get_int(record, _calendar_event.has_attendee,&has_attendee) == CALENDAR_ERROR_NONE)
- {
- if( has_attendee == 1)
- {
- _cal_db_attendee_get_records(record_id, &pevent->attendee_list);
- }
- }
- if(calendar_record_get_int(record, _calendar_event.has_alarm,&has_alarm) == CALENDAR_ERROR_NONE)
- {
- if( has_alarm == 1)
- {
- _cal_db_alarm_get_records(record_id, &pevent->alarm_list);
- }
- }
-
- __cal_db_event_exception_get_records(record_id, &pevent->exception_list);
- _cal_db_extended_get_records(record_id, CALENDAR_RECORD_TYPE_EVENT, &pevent->extended_list);
-
- ret = calendar_list_add(*out_list,record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ __cal_db_event_get_stmt(stmt, true, record, &exception, &extended);
+
+ // child
+ int has_attendee = 0, has_alarm = 0;
+ int record_id = 0;
+ cal_event_s* pevent = (cal_event_s*) record;
+ calendar_record_get_int(record, _calendar_event.id, &record_id);
+ if(calendar_record_get_int(record, _calendar_event.has_attendee,&has_attendee) == CALENDAR_ERROR_NONE)
+ {
+ if( has_attendee == 1)
+ {
+ _cal_db_attendee_get_records(record_id, pevent->attendee_list);
+ }
+ }
+ if(calendar_record_get_int(record, _calendar_event.has_alarm,&has_alarm) == CALENDAR_ERROR_NONE)
+ {
+ if( has_alarm == 1)
+ {
+ _cal_db_alarm_get_records(record_id, pevent->alarm_list);
+ }
+ }
+
+ if (exception == 1)
+ __cal_db_event_exception_get_records(record_id, pevent->exception_list);
+ if (extended == 1)
+ _cal_db_extended_get_records(record_id, CALENDAR_RECORD_TYPE_EVENT, pevent->extended_list);
+
+ ret = calendar_list_add(*out_list,record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- calendar_record_destroy(record, true);
- sqlite3_finalize(stmt);
- return ret;
- }
- }
-
- sqlite3_finalize(stmt);
- return CALENDAR_ERROR_NONE;
+ calendar_record_destroy(record, true);
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ }
+
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_event_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* out_list)
{
- cal_query_s *que = NULL;
+ cal_query_s *que = NULL;
calendar_list_h list = NULL;
- int ret = CALENDAR_ERROR_NONE;
- char *condition = NULL;
- char *projection = NULL;
- char *order = NULL;
- GSList *bind_text = NULL, *cursor = NULL;
- char strquery[CAL_DB_SQL_MAX_LEN] = {0};
- int len;
- sqlite3_stmt *stmt = NULL;
- int i = 0;
- char *table_name;
+ int ret = CALENDAR_ERROR_NONE;
+ char *condition = NULL;
+ char *projection = NULL;
+ GSList *bind_text = NULL, *cursor = NULL;
+ sqlite3_stmt *stmt = NULL;
+ int i = 0;
+ char *table_name;
if (NULL == query || NULL == out_list)
{
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- que = (cal_query_s *)query;
-
- if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_EVENT))
- {
- table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT);
- }
- else if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR))
- {
- table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT_CALENDAR);
- }
- else if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR_ATTENDEE))
- {
- table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT_CALENDAR_ATTENDEE);
- }
- else
- {
- ERR("uri(%s) not support get records with query",que->view_uri);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- //table_name = SAFE_STRDUP(CAL_TABLE_NORMAL_INSTANCE);
- }
-
- // make filter
- if (que->filter)
- {
- ret = _cal_db_query_create_condition(query,
- &condition, &bind_text);
- if (ret != CALENDAR_ERROR_NONE)
- {
- CAL_FREE(table_name);
- ERR("filter create fail");
- return ret;
- }
- }
-
- // make projection
- ret = _cal_db_query_create_projection(query, &projection);
-
- // query - projection
- if (projection)
- {
- len = snprintf(strquery, sizeof(strquery), "SELECT %s FROM %s", projection, table_name);
- }
- else
- {
- len = snprintf(strquery, sizeof(strquery), "SELECT * FROM %s", table_name);
- }
- CAL_FREE(table_name);
-
- // query - condition
- if (condition)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " WHERE %s", condition);
- }
-
- // ORDER
- ret = _cal_db_query_create_order(query, &order);
- if (order)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " %s", order);
- }
-
- if (0 < limit)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " LIMIT %d", limit);
- if (0 < offset)
- len += snprintf(strquery+len, sizeof(strquery)-len, " OFFSET %d", offset);
- }
-
- // query
- stmt = _cal_db_util_query_prepare(strquery);
- if (NULL == stmt)
- {
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- CAL_DBG("%s",strquery);
-
- // bind text
- if (bind_text)
- {
- len = g_slist_length(bind_text);
- for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
- {
- _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
- }
- }
-
- //
- ret = calendar_list_create(&list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- ERR("calendar_list_create() Failed");
- sqlite3_finalize(stmt);
- return ret;
- }
-
- while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- calendar_record_h record;
- // stmt -> record
- ret = calendar_record_create(_calendar_event._uri,&record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(list, true);
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
- return ret;
- }
- if (que->projection_count > 0)
- {
+ que = (cal_query_s *)query;
+
+ if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_EVENT))
+ {
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT);
+ }
+ else if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR))
+ {
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT_CALENDAR);
+ }
+ else if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR_ATTENDEE))
+ {
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT_CALENDAR_ATTENDEE);
+ }
+ else
+ {
+ ERR("uri(%s) not support get records with query",que->view_uri);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ //table_name = SAFE_STRDUP(CAL_TABLE_NORMAL_INSTANCE);
+ }
+
+ // make filter
+ if (que->filter)
+ {
+ ret = _cal_db_query_create_condition(query, &condition, &bind_text);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ CAL_FREE(table_name);
+ ERR("filter create fail");
+ return ret;
+ }
+ }
+
+ // make projection
+ ret = _cal_db_query_create_projection(query, &projection);
+
+ char *query_str = NULL;
+ // query - projection
+ if (projection)
+ {
+ _cal_db_append_string(&query_str, "SELECT");
+ _cal_db_append_string(&query_str, projection);
+ _cal_db_append_string(&query_str, "FROM");
+ _cal_db_append_string(&query_str, table_name);
+ CAL_FREE(projection);
+ }
+ else
+ {
+ _cal_db_append_string(&query_str, "SELECT * FROM");
+ _cal_db_append_string(&query_str, table_name);
+ }
+ CAL_FREE(table_name);
+
+ // query - condition
+ if (condition)
+ {
+ _cal_db_append_string(&query_str, "WHERE (");
+ _cal_db_append_string(&query_str, condition);
+ _cal_db_append_string(&query_str, ")");
+ }
+
+ // ORDER
+ char *order = NULL;
+ ret = _cal_db_query_create_order(query, condition, &order);
+ if (order)
+ {
+ _cal_db_append_string(&query_str, order);
+ CAL_FREE(order);
+ }
+ CAL_FREE(condition);
+
+ // limit, offset
+ char buf[32] = {0};
+ if (limit > 0)
+ {
+ snprintf(buf, sizeof(buf), "LIMIT %d", limit);
+ _cal_db_append_string(&query_str, buf);
+
+ if (offset > 0)
+ {
+ snprintf(buf, sizeof(buf), "OFFSET %d", offset);
+ _cal_db_append_string(&query_str, buf);
+ }
+ }
+ CAL_DBG("%s",query_str);
+
+ // query
+ stmt = _cal_db_util_query_prepare(query_str);
+ if (NULL == stmt)
+ {
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ ERR("_cal_db_util_query_prepare() Failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ // bind text
+ if (bind_text)
+ {
+ for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
+ {
+ _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
+ }
+ }
+
+ //
+ ret = calendar_list_create(&list);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ ERR("calendar_list_create() Failed");
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ {
+ calendar_record_h record;
+ int exception = 1, extended = 1;
+ int attendee = 1, alarm = 1;
+
+ // stmt -> record
+ ret = calendar_record_create(_calendar_event._uri,&record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(list, true);
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ if (que->projection_count > 0)
+ {
_cal_record_set_projection(record,
que->projection, que->projection_count, que->property_count);
- __cal_db_event_get_projection_stmt(stmt,
+ __cal_db_event_get_projection_stmt(stmt,
que->projection, que->projection_count,
- record);
- }
- else
- {
- __cal_db_event_get_stmt(stmt,true,record);
- }
-
- // child
- if (_cal_db_query_find_projection_property(query,CAL_PROPERTY_EVENT_CALENDAR_ALARM) == true)
- {
- cal_event_s* pevent = (cal_event_s*) record;
- _cal_db_alarm_get_records(pevent->index, &pevent->alarm_list);
- }
- if (_cal_db_query_find_projection_property(query,CAL_PROPERTY_EVENT_CALENDAR_ATTENDEE) == true)
- {
- cal_event_s* pevent = (cal_event_s*) record;
- _cal_db_attendee_get_records(pevent->index, &pevent->attendee_list);
- }
- if (_cal_db_query_find_projection_property(query,CAL_PROPERTY_EVENT_EXCEPTION) == true)
- {
- cal_event_s* pevent = (cal_event_s*) record;
- __cal_db_event_exception_get_records(pevent->index, &pevent->exception_list);
- }
- if (_cal_db_query_find_projection_property(query,CAL_PROPERTY_EVENT_EXTENDED) == true)
- {
- cal_event_s* pevent = (cal_event_s*) record;
- _cal_db_extended_get_records(pevent->index, CALENDAR_RECORD_TYPE_EVENT, &pevent->extended_list);
- }
-
- ret = calendar_list_add(list,record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(list, true);
- calendar_record_destroy(record, true);
-
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
- return ret;
- }
- }
-
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
-
- sqlite3_finalize(stmt);
+ record);
+ }
+ else
+ {
+ cal_event_s *event = NULL;
+ __cal_db_event_get_stmt(stmt,true,record, &exception, &extended);
+ event = (cal_event_s*)(record);
+ if (event)
+ {
+ attendee = event->has_attendee;
+ alarm = event->has_alarm;
+ }
+ }
+
+ // child
+ if (_cal_db_query_find_projection_property(query,CAL_PROPERTY_EVENT_CALENDAR_ALARM) == true && alarm == 1)
+ {
+ cal_event_s* pevent = (cal_event_s*) record;
+ _cal_db_alarm_get_records(pevent->index, pevent->alarm_list);
+ }
+ if (_cal_db_query_find_projection_property(query,CAL_PROPERTY_EVENT_CALENDAR_ATTENDEE) == true && attendee == 1)
+ {
+ cal_event_s* pevent = (cal_event_s*) record;
+ _cal_db_attendee_get_records(pevent->index, pevent->attendee_list);
+ }
+ if (_cal_db_query_find_projection_property(query,CAL_PROPERTY_EVENT_EXCEPTION) == true && exception ==1)
+ {
+ cal_event_s* pevent = (cal_event_s*) record;
+ __cal_db_event_exception_get_records(pevent->index, pevent->exception_list);
+ }
+ if (_cal_db_query_find_projection_property(query,CAL_PROPERTY_EVENT_EXTENDED) == true && extended ==1)
+ {
+ cal_event_s* pevent = (cal_event_s*) record;
+ _cal_db_extended_get_records(pevent->index, CALENDAR_RECORD_TYPE_EVENT, pevent->extended_list);
+ }
+
+ ret = calendar_list_add(list,record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ ERR("calendar_list_add() is failed(%d)", ret);
+ calendar_list_destroy(list, true);
+ calendar_record_destroy(record, true);
+
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ }
+
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
*out_list = list;
+ __check_list(list);
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_event_insert_records(const calendar_list_h list, int** ids)
{
- calendar_record_h record;
- int ret = 0;
- int count = 0;
- int i=0;
- int *id = NULL;
-
- ret = calendar_list_get_count(list, &count);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("list get error");
- return ret;
- }
-
- id = calloc(1, sizeof(int)*count);
-
- retvm_if(NULL == id, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc fail");
-
- ret = calendar_list_first(list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("list first error");
- CAL_FREE(id);
- return ret;
- }
- do
- {
- if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
- {
- if( __cal_db_event_insert_record(record, &id[i]) != CALENDAR_ERROR_NONE)
- {
- ERR("db insert error");
- CAL_FREE(id);
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- i++;
- } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
-
- if(ids)
- {
- *ids = id;
- }
- else
- {
- CAL_FREE(id);
- }
-
- return CALENDAR_ERROR_NONE;
+ calendar_record_h record;
+ int ret = 0;
+ int count = 0;
+ int i=0;
+ int *id = NULL;
+
+ ret = calendar_list_get_count(list, &count);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("list get error");
+ return ret;
+ }
+
+ id = calloc(1, sizeof(int)*count);
+
+ retvm_if(NULL == id, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc fail");
+
+ ret = calendar_list_first(list);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("list first error");
+ CAL_FREE(id);
+ return ret;
+ }
+ do
+ {
+ if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
+ {
+ if( __cal_db_event_insert_record(record, &id[i]) != CALENDAR_ERROR_NONE)
+ {
+ ERR("db insert error");
+ CAL_FREE(id);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ i++;
+ } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+
+ if(ids)
+ {
+ *ids = id;
+ }
+ else
+ {
+ CAL_FREE(id);
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_event_update_records(const calendar_list_h list)
{
- calendar_record_h record;
- int ret = 0;
-
- ret = calendar_list_first(list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("list first error");
- return ret;
- }
- do
- {
- if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
- {
- if( __cal_db_event_update_record(record) != CALENDAR_ERROR_NONE)
- {
- ERR("db insert error");
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
-
- return CALENDAR_ERROR_NONE;
+ calendar_record_h record;
+ int ret = 0;
+
+ ret = calendar_list_first(list);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("list first error");
+ return ret;
+ }
+ do
+ {
+ if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
+ {
+ if( __cal_db_event_update_record(record) != CALENDAR_ERROR_NONE)
+ {
+ ERR("db insert error");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_event_delete_records(int ids[], int count)
{
- int i=0;
- for(i=0;i<count;i++)
- {
- if (__cal_db_event_delete_record(ids[i]) != CALENDAR_ERROR_NONE)
- {
- ERR("delete failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- return CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
+ int i = 0;
+
+ for(i = 0; i < count; i++)
+ {
+ ret = __cal_db_event_delete_record(ids[i]);
+ if (CALENDAR_ERROR_NONE != ret)
+ {
+ ERR("delete failed");
+ return ret;
+ }
+ }
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_event_get_count(int *out_count)
{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- int count = 0;
- int ret;
+ retvm_if(NULL == out_count, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ char *query_str = NULL;
+ _cal_db_append_string(&query_str, "SELECT count(*) FROM");
+ _cal_db_append_string(&query_str, CAL_VIEW_TABLE_EVENT);
+
+ int ret = 0;
+ int count = 0;
+ ret = _cal_db_util_query_get_first_int_result(query_str, NULL, &count);
+ if (CALENDAR_ERROR_NONE != ret)
+ {
+ ERR("_cal_db_util_query_get_first_int_result() failed");
+ CAL_FREE(query_str);
+ return ret;
+ }
+ CAL_DBG("count(%d) str[%s]", count, query_str);
+ CAL_FREE(query_str);
+
+ *out_count = count;
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_db_event_get_count_with_query(calendar_query_h query, int *out_count)
+{
+ cal_query_s *que = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ char *condition = NULL;
+ char *table_name;
+ int count = 0;
+ GSList *bind_text = NULL;
+
+ que = (cal_query_s *)query;
+
+ if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_EVENT))
+ {
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT);
+ }
+ else if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR))
+ {
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT_CALENDAR);
+ }
+ else if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR_ATTENDEE))
+ {
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT_CALENDAR_ATTENDEE);
+ }
+ else
+ {
+ ERR("uri(%s) not support get records with query",que->view_uri);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ //table_name = SAFE_STRDUP(CAL_TABLE_NORMAL_INSTANCE);
+ }
- retvm_if(NULL == out_count, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ // make filter
+ if (que->filter)
+ {
+ ret = _cal_db_query_create_condition(query, &condition, &bind_text);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ CAL_FREE(table_name);
+ ERR("filter create fail");
+ return ret;
+ }
+ }
- snprintf(query, sizeof(query), "SELECT count(*) FROM %s ", CAL_VIEW_TABLE_EVENT);
+ char *query_str = NULL;
+ // query - select from
+ _cal_db_append_string(&query_str, "SELECT count(*) FROM");
+ _cal_db_append_string(&query_str, table_name);
+ CAL_FREE(table_name);
- ret = _cal_db_util_query_get_first_int_result(query, NULL, &count);
- if (CALENDAR_ERROR_NONE != ret)
+ // query - condition
+ if (condition)
{
- ERR("_cal_db_util_query_get_first_int_result() failed");
- return ret;
+ _cal_db_append_string(&query_str, "WHERE (");
+ _cal_db_append_string(&query_str, condition);
+ _cal_db_append_string(&query_str, ")");
+ CAL_FREE(condition);
}
- CAL_DBG("%s=%d",query,count);
- *out_count = count;
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_db_event_get_count_with_query(calendar_query_h query, int *out_count)
-{
- cal_query_s *que = NULL;
- int ret = CALENDAR_ERROR_NONE;
- char *condition = NULL;
- char strquery[CAL_DB_SQL_MAX_LEN] = {0};
- int len;
- char *table_name;
- int count = 0;
- GSList *bind_text = NULL;
-
- que = (cal_query_s *)query;
-
- if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_EVENT))
- {
- table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT);
- }
- else if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR))
- {
- table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT_CALENDAR);
- }
- else if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR_ATTENDEE))
- {
- table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT_CALENDAR_ATTENDEE);
- }
- else
- {
- ERR("uri(%s) not support get records with query",que->view_uri);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- //table_name = SAFE_STRDUP(CAL_TABLE_NORMAL_INSTANCE);
- }
-
- // make filter
- if (que->filter)
- {
- ret = _cal_db_query_create_condition(query, &condition, &bind_text);
- if (ret != CALENDAR_ERROR_NONE)
- {
- CAL_FREE(table_name);
- ERR("filter create fail");
- return ret;
- }
- }
-
- // query - select from
-
- len = snprintf(strquery, sizeof(strquery), "SELECT count(*) FROM %s", table_name);
- CAL_FREE(table_name);
-
- // query - condition
- if (condition)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " WHERE %s", condition);
- }
-
- // query
- ret = _cal_db_util_query_get_first_int_result(strquery, bind_text, &count);
+ // query
+ ret = _cal_db_util_query_get_first_int_result(query_str, bind_text, &count);
if (CALENDAR_ERROR_NONE != ret)
{
ERR("_cal_db_util_query_get_first_int_result() failed");
if (bind_text)
{
- g_slist_free(bind_text);
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
}
- CAL_FREE(condition);
+ CAL_FREE(query_str);
return ret;
}
- CAL_DBG("%s=%d",strquery,count);
+ CAL_DBG("count(%d) str[%s]", count, query_str);
- *out_count = count;
+ if (out_count) *out_count = count;
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- return CALENDAR_ERROR_NONE;
+ CAL_FREE(query_str);
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_event_replace_record(calendar_record_h record, int id)
retv_if(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER);
event->index = id;
- if (event->common.properties_flags != NULL)
- {
- return __cal_db_event_update_dirty(record);
- }
- has_alarm = _cal_db_alarm_has_alarm(event->alarm_list);
+ // access control
+ if (_cal_access_control_have_write_permission(event->calendar_id) == false)
+ {
+ ERR("_cal_access_control_have_write_permission() failed");
+ return CALENDAR_ERROR_PERMISSION_DENIED;
+ }
+ if (event->common.properties_flags != NULL)
+ {
+ return __cal_db_event_update_dirty(record, -1);
+ }
+ has_alarm = _cal_db_alarm_has_alarm(event->alarm_list);
_cal_time_get_timezone_from_table(event->start_tzid, NULL, &timezone_id);
input_ver = _cal_db_util_get_next_ver();
+ int is_allday = 0;
+ if (CALENDAR_TIME_LOCALTIME == event->start.type
+ && (0 == event->start.time.date.hour)
+ && (0 == event->start.time.date.minute)
+ && (0 == event->start.time.date.second)
+ && (0 == event->end.time.date.hour)
+ && (0 == event->end.time.date.minute)
+ && (0 == event->end.time.date.second)) {
+ is_allday = 1;
+ }
+
snprintf(query, sizeof(query), "UPDATE %s SET "
"changed_ver = %d,"
"type = %d,"
"latitude = %lf,"
"longitude = %lf,"
"email_id = %d,"
- "availability = %d,"
"completed_time = %lld,"
"progress = %d, "
"dtstart_type = %d, "
"dtend_tzid = ?, "
"last_mod = strftime('%%s', 'now'), "
"rrule_id = %d, "
- "recurrence_id = ?, "
- "rdate = ?, "
- "has_attendee = %d, "
- "has_alarm = %d, "
- "system_type = %d, "
- "updated = %ld, "
- "sync_data1 = ?, "
- "sync_data2 = ?, "
- "sync_data3 = ?, "
- "sync_data4 = ? "
+ "recurrence_id = ?, "
+ "rdate = ?, "
+ "has_attendee = %d, "
+ "has_alarm = %d, "
+ "system_type = %d, "
+ "updated = %ld, "
+ "sync_data1 = ?, "
+ "sync_data2 = ?, "
+ "sync_data3 = ?, "
+ "sync_data4 = ?, "
+ "freq = %d, "
+ "is_allday = %d "
"WHERE id = %d ",
CAL_TABLE_SCHEDULE,
input_ver,
event->latitude,
event->longitude,
event->email_id,
- 0,//event->availability,
(long long int)0,//event->completed_time,
0,//event->progress,
event->start.type,
event->end.type,
event->end.type == CALENDAR_TIME_UTIME ? event->end.time.utime : 0,
event->freq > 0 ? 1 : 0,
- event->attendee_list ? 1 : 0,
+ (event->attendee_list && 0 < event->attendee_list->count) ? 1 : 0,
has_alarm,
event->system_type,
event->updated,
+ event->freq,
+ is_allday,
id);
stmt = _cal_db_util_query_prepare(query);
_cal_db_util_stmt_bind_text(stmt, index, event->uid);
index++;
- if (event->organizer_name)
- _cal_db_util_stmt_bind_text(stmt, index, event->organizer_name);
- index++;
+ if (event->organizer_name)
+ _cal_db_util_stmt_bind_text(stmt, index, event->organizer_name);
+ index++;
+
+ if (event->organizer_email)
+ _cal_db_util_stmt_bind_text(stmt, index, event->organizer_email);
+ index++;
+
+ if (CALENDAR_TIME_LOCALTIME == event->start.type)
+ {
+ snprintf(dtstart_datetime, sizeof(dtstart_datetime), CAL_FORMAT_LOCAL_DATETIME,
+ event->start.time.date.year,
+ event->start.time.date.month,
+ event->start.time.date.mday,
+ event->start.time.date.hour,
+ event->start.time.date.minute,
+ event->start.time.date.second);
+ _cal_db_util_stmt_bind_text(stmt, index, dtstart_datetime);
+ }
+ index++;
+
+ if (event->start_tzid)
+ _cal_db_util_stmt_bind_text(stmt, index, event->start_tzid);
+ index++;
+
+ if (CALENDAR_TIME_LOCALTIME == event->end.type)
+ {
+ snprintf(dtend_datetime, sizeof(dtend_datetime), CAL_FORMAT_LOCAL_DATETIME,
+ event->end.time.date.year,
+ event->end.time.date.month,
+ event->end.time.date.mday,
+ event->end.time.date.hour,
+ event->end.time.date.minute,
+ event->end.time.date.second);
+ _cal_db_util_stmt_bind_text(stmt, index, dtend_datetime);
+ }
+ index++;
+
+ if (event->end_tzid)
+ _cal_db_util_stmt_bind_text(stmt, index, event->end_tzid);
+ index++;
+
+ if (event->recurrence_id)
+ _cal_db_util_stmt_bind_text(stmt, index, event->recurrence_id);
+ index++;
+ if (event->rdate)
+ _cal_db_util_stmt_bind_text(stmt, index, event->rdate);
+ index++;
+ if (event->sync_data1)
+ _cal_db_util_stmt_bind_text(stmt, index, event->sync_data1);
+ index++;
+ if (event->sync_data2)
+ _cal_db_util_stmt_bind_text(stmt, index, event->sync_data2);
+ index++;
+ if (event->sync_data3)
+ _cal_db_util_stmt_bind_text(stmt, index, event->sync_data3);
+ index++;
+ if (event->sync_data4)
+ _cal_db_util_stmt_bind_text(stmt, index, event->sync_data4);
+ index++;
+
+ dbret = _cal_db_util_stmt_step(stmt);
+ if (CAL_DB_DONE != dbret) {
+ sqlite3_finalize(stmt);
+ ERR("sqlite3_step() Failed(%d)", dbret);
+ switch (dbret)
+ {
+ case CAL_DB_ERROR_NO_SPACE:
+ return CALENDAR_ERROR_FILE_NO_SPACE;
+ default:
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ sqlite3_finalize(stmt);
+
+ // update parent event changed ver in case this event is exception mod
+ // which is original_event_id > 0
+ _cal_db_event_update_original_event_version(event->original_event_id, input_ver);
+
+// _cal_db_rrule_set_default(record);
+ _cal_db_rrule_get_rrule_from_event(record, &rrule);
+ _cal_db_rrule_update_record(id, rrule);
+ CAL_FREE(rrule);
+
+ _cal_db_instance_discard_record(id);
+ _cal_db_instance_publish_record(record);
+
+ _cal_db_alarm_delete_with_id(id);
+ _cal_db_attendee_delete_with_id(id);
+ __cal_db_event_exception_delete_with_id(id);
+ _cal_db_extended_delete_with_id(id, CALENDAR_RECORD_TYPE_EVENT);
+
+ if (event->alarm_list && 0 < event->alarm_list->count) {
+ ret = _cal_db_alarm_insert_records(event->alarm_list, event->index);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_db_alarm_insert_records() failed(%x)", ret);
+ }
+
+ if (event->attendee_list && 0 < event->attendee_list->count) {
+ ret = _cal_db_attendee_insert_records(event->attendee_list, event->index);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_db_attendee_insert_records() failed(%x)", ret);
+ }
+
+ if (event->exception_list && 0 < event->exception_list->count) {
+ ret = _cal_db_event_insert_records(event->exception_list, id);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_db_event_insert_records() failed(%x)", ret);
+ }
+
+ if (event->extended_list && 0 < event->extended_list->count) {
+ ret = _cal_db_extended_insert_records(event->extended_list, id, CALENDAR_RECORD_TYPE_EVENT);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_db_extended_insert_records() Failed(%d)", ret);
+ }
+
+ _cal_db_util_notify(CAL_NOTI_TYPE_EVENT);
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_db_event_replace_records(const calendar_list_h list, int ids[], int count)
+{
+ calendar_record_h record;
+ int i = 0;
+ int ret = 0;
+
+ if (NULL == list)
+ {
+ ERR("Invalid argument: list is NULL");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = calendar_list_first(list);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("list first error");
+ return ret;
+ }
+
+ for (i = 0; i < count; i++)
+ {
+ if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
+ {
+ if( __cal_db_event_replace_record(record, ids[i]) != CALENDAR_ERROR_NONE)
+ {
+ ERR("db insert error");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ if (CALENDAR_ERROR_NO_DATA != calendar_list_next(list))
+ {
+ break;
+ }
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static void __cal_db_event_get_stmt(sqlite3_stmt *stmt,bool is_view_table,calendar_record_h record,
+ int *exception, int *extended)
+{
+ cal_event_s *event = NULL;
+ const unsigned char *temp;
+ int count = 0;
+
+ event = (cal_event_s*)(record);
+
+ event->index = sqlite3_column_int(stmt, count++);
+ sqlite3_column_int(stmt, count++);//event->cal_type = 1;/*sqlite3_column_int(stmt, count++);*/
+
+ temp = sqlite3_column_text(stmt, count++);
+ event->summary = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ event->description = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ event->location = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ event->categories = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ event->exdate = SAFE_STRDUP(temp);
+
+ event->event_status = sqlite3_column_int(stmt, count++);
+ event->priority = sqlite3_column_int(stmt, count++);
+ event->timezone = sqlite3_column_int(stmt, count++);
+ event->contact_id = sqlite3_column_int(stmt, count++);
+ event->busy_status = sqlite3_column_int(stmt, count++);
+ event->sensitivity = sqlite3_column_int(stmt, count++);
+
+ temp = sqlite3_column_text(stmt, count++);
+ event->uid = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ event->organizer_name = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ event->organizer_email = SAFE_STRDUP(temp);
+
+ event->meeting_status = sqlite3_column_int(stmt, count++);
+ event->calendar_id = sqlite3_column_int(stmt, count++);
+ event->original_event_id = sqlite3_column_int(stmt, count++);
+ event->latitude = sqlite3_column_double(stmt,count++);
+ event->longitude = sqlite3_column_double(stmt,count++);
+ event->email_id = sqlite3_column_int(stmt, count++);
+ event->created_time = sqlite3_column_int64(stmt, count++);
+
+ count++; // completed_time
+ count++; // progress
+ count++; // changed_ver
+ count++; // created_ver
+
+ event->is_deleted = sqlite3_column_int(stmt,count++);
+ event->start.type = sqlite3_column_int(stmt,count++);
+
+ if (event->start.type == CALENDAR_TIME_UTIME)
+ {
+ event->start.time.utime = sqlite3_column_int64(stmt,count++);
+ count++; // dtstart_datetime
+ }
+ else
+ {
+ count++; // dtstart_utime
+ temp = sqlite3_column_text(stmt, count++);
+ if (temp) {
+ sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME, &(event->start.time.date.year),
+ &(event->start.time.date.month), &(event->start.time.date.mday),
+ &(event->start.time.date.hour), &(event->start.time.date.minute),
+ &(event->start.time.date.second));
+ }
+ }
+
+ temp = sqlite3_column_text(stmt, count++);
+ event->start_tzid = SAFE_STRDUP(temp);
+
+ event->end.type = sqlite3_column_int(stmt, count++);
+ if (event->end.type == CALENDAR_TIME_UTIME)
+ {
+ event->end.time.utime = sqlite3_column_int64(stmt,count++);
+ count++; // dtend_datetime
+ }
+ else
+ {
+ count++; // dtend_utime
+ temp = sqlite3_column_text(stmt, count++);
+ if (temp) {
+ sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME, &(event->end.time.date.year),
+ &(event->end.time.date.month), &(event->end.time.date.mday),
+ &(event->end.time.date.hour), &(event->end.time.date.minute),
+ &(event->end.time.date.second));
+ }
+ }
+ temp = sqlite3_column_text(stmt, count++);
+ event->end_tzid = SAFE_STRDUP(temp);
+
+ event->last_mod = sqlite3_column_int64(stmt,count++);
+ sqlite3_column_int(stmt,count++);//event->rrule_id = sqlite3_column_int(stmt,count++);
+
+ temp = sqlite3_column_text(stmt, count++);
+ event->recurrence_id = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ event->rdate = SAFE_STRDUP(temp);
+ event->has_attendee = sqlite3_column_int(stmt,count++);
+ event->has_alarm = sqlite3_column_int(stmt,count++);
+ event->system_type = sqlite3_column_int(stmt,count++);
+ event->updated = sqlite3_column_int(stmt,count++);
+ temp = sqlite3_column_text(stmt, count++);
+ event->sync_data1 = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ event->sync_data2 = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ event->sync_data3 = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ event->sync_data4 = SAFE_STRDUP(temp);
+
+ //has_exception
+ if (exception != NULL)
+ *exception = sqlite3_column_int(stmt,count++);
+
+ //has_extended
+ if (extended != NULL)
+ *extended = sqlite3_column_int(stmt,count++);
+
+ event->freq = sqlite3_column_int(stmt, count++);
+ event->is_allday = sqlite3_column_int(stmt, count++);
+
+ if (is_view_table == true) {
+ if (event->freq <= 0) {
+ //event->rrule_id = 0;
+ //sqlite3_finalize(stmt);
+ //return CALENDAR_ERROR_NONE;
+ return ;
+ }
+
+ //event->rrule_id = 1;
+ event->range_type = sqlite3_column_int(stmt, count++);
+ event->until.type = sqlite3_column_int(stmt, count++);
+
+ switch (event->until.type)
+ {
+ case CALENDAR_TIME_UTIME:
+ event->until.time.utime = sqlite3_column_int64(stmt, count++);
+ count++; // datetime
+ break;
+
+ case CALENDAR_TIME_LOCALTIME:
+ count++; // utime
+ temp = sqlite3_column_text(stmt, count++);
+ if (temp) {
+ sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME, &(event->until.time.date.year),
+ &(event->until.time.date.month), &(event->until.time.date.mday),
+ &(event->until.time.date.hour), &(event->until.time.date.minute),
+ &(event->until.time.date.second));
+ }
+ break;
+ }
+
+ event->count = sqlite3_column_int(stmt, count++);
+ event->interval = sqlite3_column_int(stmt, count++);
+
+ temp = sqlite3_column_text(stmt, count++);
+ event->bysecond = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ event->byminute = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ event->byhour = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ event->byday= SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ event->bymonthday= SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ event->byyearday= SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ event->byweekno= SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ event->bymonth= SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ event->bysetpos = SAFE_STRDUP(temp);
+
+ event->wkst = sqlite3_column_int(stmt, count++);
+
+ sqlite3_column_int(stmt, count++); //calendar deleted
+ }
+
+}
+
+static void __cal_db_event_get_property_stmt(sqlite3_stmt *stmt,
+ unsigned int property, int *stmt_count, calendar_record_h record)
+{
+ cal_event_s *event = NULL;
+ const unsigned char *temp;
+
+ event = (cal_event_s*)(record);
+
+ switch(property)
+ {
+ case CAL_PROPERTY_EVENT_ID:
+ event->index = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_EVENT_CALENDAR_ID:
+ event->calendar_id = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_EVENT_SUMMARY:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ event->summary = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EVENT_DESCRIPTION:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ event->description = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EVENT_LOCATION:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ event->location = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EVENT_CATEGORIES:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ event->categories = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EVENT_EXDATE:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ event->exdate = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EVENT_EVENT_STATUS:
+ event->event_status = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_EVENT_PRIORITY:
+ event->priority = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_EVENT_TIMEZONE:
+ event->timezone = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_EVENT_CONTACT_ID:
+ event->contact_id = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_EVENT_BUSY_STATUS:
+ event->busy_status = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_EVENT_SENSITIVITY:
+ event->sensitivity = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_EVENT_UID:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ event->uid = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EVENT_ORGANIZER_NAME:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ event->organizer_name = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EVENT_ORGANIZER_EMAIL:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ event->organizer_email = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EVENT_MEETING_STATUS:
+ event->meeting_status = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_EVENT_ORIGINAL_EVENT_ID:
+ event->original_event_id = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_EVENT_LATITUDE:
+ event->latitude = sqlite3_column_double(stmt,*stmt_count);
+ break;
+ case CAL_PROPERTY_EVENT_LONGITUDE:
+ event->longitude = sqlite3_column_double(stmt,*stmt_count);
+ break;
+ case CAL_PROPERTY_EVENT_EMAIL_ID:
+ event->email_id = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_EVENT_CREATED_TIME:
+ event->created_time = sqlite3_column_int64(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_EVENT_LAST_MODIFIED_TIME:
+ event->last_mod = sqlite3_column_int64(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_EVENT_IS_DELETED:
+ event->is_deleted = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_EVENT_FREQ:
+ event->freq = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_EVENT_RANGE_TYPE:
+ event->range_type = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_EVENT_UNTIL:
+ //!!
+ break;
+ case CAL_PROPERTY_EVENT_COUNT:
+ event->count = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_EVENT_INTERVAL:
+ event->interval = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_EVENT_BYSECOND:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ event->bysecond = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EVENT_BYMINUTE:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ event->byminute = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EVENT_BYHOUR:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ event->byhour = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EVENT_BYDAY:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ event->byday = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EVENT_BYMONTHDAY:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ event->bymonthday = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EVENT_BYYEARDAY:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ event->byyearday = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EVENT_BYWEEKNO:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ event->byweekno = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EVENT_BYMONTH:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ event->bymonth = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EVENT_BYSETPOS:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ event->bysetpos = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EVENT_WKST:
+ event->wkst = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_EVENT_RECURRENCE_ID:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ event->recurrence_id = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EVENT_RDATE:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ event->rdate = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EVENT_HAS_ATTENDEE:
+ event->has_attendee = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_EVENT_HAS_ALARM:
+ event->has_alarm = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_EVENT_SYNC_DATA1:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ event->sync_data1 = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EVENT_SYNC_DATA2:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ event->sync_data2 = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EVENT_SYNC_DATA3:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ event->sync_data3 = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EVENT_SYNC_DATA4:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ event->sync_data4 = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EVENT_START:
+ event->start.type = sqlite3_column_int(stmt,*stmt_count);
+ if (event->start.type == CALENDAR_TIME_UTIME)
+ {
+ *stmt_count = *stmt_count+1;
+ event->start.time.utime = sqlite3_column_int64(stmt,*stmt_count);
+ *stmt_count = *stmt_count+1; // dtstart_datetime
+ }
+ else
+ {
+ *stmt_count = *stmt_count+1;
+ *stmt_count = *stmt_count+1;
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ if (temp) {
+ sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME, &(event->start.time.date.year),
+ &(event->start.time.date.month), &(event->start.time.date.mday),
+ &(event->start.time.date.hour), &(event->start.time.date.minute),
+ &(event->start.time.date.second));
+ }
+ }
+ break;
+ case CAL_PROPERTY_EVENT_START_TZID:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ event->start_tzid = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EVENT_END:
+ //!!
+ event->end.type = sqlite3_column_int(stmt, *stmt_count);
+ if (event->end.type == CALENDAR_TIME_UTIME)
+ {
+ *stmt_count = *stmt_count+1;
+ event->end.time.utime = sqlite3_column_int64(stmt,*stmt_count);
+ *stmt_count = *stmt_count+1; // dtstart_datetime
+ }
+ else
+ {
+ *stmt_count = *stmt_count+1; // dtend_utime
+ *stmt_count = *stmt_count+1;
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ if (temp) {
+ sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME, &(event->end.time.date.year),
+ &(event->end.time.date.month), &(event->end.time.date.mday),
+ &(event->end.time.date.hour), &(event->end.time.date.minute),
+ &(event->end.time.date.second));
+ }
+ }
+ break;
+ case CAL_PROPERTY_EVENT_END_TZID:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ event->end_tzid = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EVENT_CALENDAR_SYSTEM_TYPE:
+ event->system_type = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ default:
+ sqlite3_column_int(stmt, *stmt_count);
+ break;
+ }
+
+ *stmt_count = *stmt_count+1;
+}
- if (event->organizer_email)
- _cal_db_util_stmt_bind_text(stmt, index, event->organizer_email);
- index++;
+static void __cal_db_event_get_projection_stmt(sqlite3_stmt *stmt,
+ const unsigned int *projection, const int projection_count,
+ calendar_record_h record)
+{
+ int i=0;
+ int stmt_count = 0;
- if (CALENDAR_TIME_LOCALTIME == event->start.type)
+ for(i=0;i<projection_count;i++)
{
- snprintf(dtstart_datetime, sizeof(dtstart_datetime), "%04d%02d%02d",
- event->start.time.date.year,
- event->start.time.date.month,
- event->start.time.date.mday);
- _cal_db_util_stmt_bind_text(stmt, index, dtstart_datetime);
+ __cal_db_event_get_property_stmt(stmt,projection[i],&stmt_count,record);
}
- index++;
+}
- if (event->start_tzid)
- _cal_db_util_stmt_bind_text(stmt, index, event->start_tzid);
- index++;
+static bool __cal_db_event_check_calendar_book_type(calendar_record_h record)
+{
+ int store_type = 0;
+ cal_event_s *event = (cal_event_s *)record;
+ char query[CAL_DB_SQL_MAX_LEN];
+ sqlite3_stmt *stmt = NULL;
- if (CALENDAR_TIME_LOCALTIME == event->end.type)
+ snprintf(query, sizeof(query), "SELECT store_type "
+ "FROM %s WHERE id = %d ",
+ CAL_TABLE_CALENDAR, event->calendar_id);
+
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt)
{
- snprintf(dtend_datetime, sizeof(dtend_datetime), "%04d%02d%02d",
- event->end.time.date.year,
- event->end.time.date.month,
- event->end.time.date.mday);
- _cal_db_util_stmt_bind_text(stmt, index, dtend_datetime);
+ ERR("query[%s]", query);
+ ERR("_cal_db_util_query_prepare() Failed");
+ return false;
}
- index++;
-
- if (event->end_tzid)
- _cal_db_util_stmt_bind_text(stmt, index, event->end_tzid);
- index++;
- if (event->recurrence_id)
- _cal_db_util_stmt_bind_text(stmt, index, event->recurrence_id);
- index++;
- if (event->rdate)
- _cal_db_util_stmt_bind_text(stmt, index, event->rdate);
- index++;
- if (event->sync_data1)
- _cal_db_util_stmt_bind_text(stmt, index, event->sync_data1);
- index++;
- if (event->sync_data2)
- _cal_db_util_stmt_bind_text(stmt, index, event->sync_data2);
- index++;
- if (event->sync_data3)
- _cal_db_util_stmt_bind_text(stmt, index, event->sync_data3);
- index++;
- if (event->sync_data4)
- _cal_db_util_stmt_bind_text(stmt, index, event->sync_data4);
- index++;
-
- dbret = _cal_db_util_stmt_step(stmt);
- if (CAL_DB_DONE != dbret) {
+ if (CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
+ store_type = sqlite3_column_int(stmt, 0);
+ }
+ else {
sqlite3_finalize(stmt);
- ERR("sqlite3_step() Failed(%d)", dbret);
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
+ stmt = NULL;
+ DBG("Failed to get calendar: calendar_id(%d)", event->calendar_id);
+ return false;
}
sqlite3_finalize(stmt);
- // update parent event changed ver in case this event is exception mod
- // which is original_event_id > 0
- __cal_db_event_update_original_event_version(event->original_event_id, input_ver);
-
- _cal_db_rrule_get_rrule_from_event(record, &rrule);
- _cal_db_rrule_update_record(id, rrule);
- CAL_FREE(rrule);
+ bool ret = false;
+ switch (store_type) {
+ case CALENDAR_BOOK_TYPE_NONE:
+ case CALENDAR_BOOK_TYPE_EVENT:
+ ret = true;
+ break;
+ case CALENDAR_BOOK_TYPE_TODO:
+ default:
+ ret = false;
+ break;
+ }
+ return ret;
+}
- ret = _cal_db_instance_discard_record(record);
- retvm_if(ret != CALENDAR_ERROR_NONE, CALENDAR_ERROR_DB_FAILED,
- "_cal_db_instance_discard_record() Failed(%d)", ret);
+static int __cal_db_event_delete_exception(int *exception_ids, int exception_len)
+{
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ cal_db_util_error_e dbret = CAL_DB_OK;
- _cal_db_instance_publish_record(record);
+ int i;
+ for (i = 0; i < exception_len; i++) {
+ snprintf(query, sizeof(query), "DELETE FROM %s WHERE id=%d ",
+ CAL_TABLE_SCHEDULE, exception_ids[i]);
- _cal_db_alarm_delete_with_id(id);
- _cal_db_attendee_delete_with_id(id);
- __cal_db_event_exception_delete_with_id(id);
- _cal_db_extended_delete_with_id(id, CALENDAR_RECORD_TYPE_EVENT);
+ dbret = _cal_db_util_query_exec(query);
+ if (dbret != CAL_DB_OK) {
+ ERR("_cal_db_util_query_exec() failed (%d)", dbret);
+ switch (dbret)
+ {
+ case CAL_DB_ERROR_NO_SPACE:
+ return CALENDAR_ERROR_FILE_NO_SPACE;
+ default:
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ }
+ return CALENDAR_ERROR_NONE;
+}
- calendar_list_h list;
+static int __cal_db_event_update_dirty(calendar_record_h record, int is_dirty_in_time)
+{
+ int event_id = 0;
+ int ret = CALENDAR_ERROR_NONE;
+ calendar_record_h original_record = NULL;
- list = NULL;
- ret = _cal_db_alarm_convert_gtoh(event->alarm_list, id, &list);
- if (ret == CALENDAR_ERROR_NONE)
- {
- calendar_db_insert_records(list, NULL, NULL);
- calendar_list_destroy(list, false);
- }
-
- list = NULL;
- ret = _cal_db_attendee_convert_gtoh(event->attendee_list, id, &list);
- if (ret == CALENDAR_ERROR_NONE)
- {
- calendar_db_insert_records(list, NULL, NULL);
- calendar_list_destroy(list, false);
- }
-
- if (event->exception_list)
- {
- DBG("insert exception");
- list = NULL;
- ret = __cal_db_event_exception_convert_gtoh(event->exception_list, id, event->calendar_id, &list);
- if (ret == CALENDAR_ERROR_NONE)
- {
- calendar_db_insert_records(list, NULL, NULL);
- calendar_list_destroy(list, false);
- }
- }
-
- if (event->extended_list)
- {
- DBG("insert extended");
- list = NULL;
- ret = _cal_db_extended_convert_gtoh(event->extended_list, id, CALENDAR_RECORD_TYPE_EVENT, &list);
- if (ret == CALENDAR_ERROR_NONE)
- {
- calendar_db_insert_records(list, NULL, NULL);
- calendar_list_destroy(list, false);
- }
- }
+ ret = calendar_record_get_int(record,_calendar_event.id, &event_id);
+ retv_if(CALENDAR_ERROR_NONE != ret, ret);
- _cal_db_util_notify(CAL_NOTI_TYPE_EVENT);
+ CAL_DBG("id=%d",event_id);
- return CALENDAR_ERROR_NONE;
-}
+ ret = __cal_db_event_get_record(event_id, &original_record);
+ retvm_if (CALENDAR_ERROR_NONE != ret, ret, "__cal_db_event_get_record() is failed(%d)", ret);
-static int __cal_db_event_replace_records(const calendar_list_h list, int ids[], int count)
-{
- calendar_record_h record;
- int i = 0;
- int ret = 0;
+ cal_record_s *_record = NULL;
+ const cal_property_info_s* property_info = NULL;
+ int property_info_count = 0;
+ int i=0;
- if (NULL == list)
- {
- ERR("Invalid argument: list is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
+ _record = (cal_record_s *)record;
- ret = calendar_list_first(list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("list first error");
- return ret;
- }
+ property_info = _cal_view_get_property_info(_record->view_uri, &property_info_count);
- for (i = 0; i < count; i++)
+ for(i=0;i<property_info_count;i++)
{
- if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
- {
- if( __cal_db_event_replace_record(record, ids[i]) != CALENDAR_ERROR_NONE)
- {
- ERR("db insert error");
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- if (CALENDAR_ERROR_NO_DATA != calendar_list_next(list))
+ if (false == _cal_record_check_property_flag(record, property_info[i].property_id , CAL_PROPERTY_FLAG_DIRTY))
{
- break;
+ continue;
}
- }
- return CALENDAR_ERROR_NONE;
-}
+ //CAL_DBG("%d",property_info[i].property_id);
+ if (property_info[i].property_id == CAL_PROPERTY_EVENT_EXDATE)
+ {
+ int calendar_id = 0;
+ int account_id = 0;
+ calendar_book_sync_event_type_e sync_event_type = CALENDAR_BOOK_SYNC_EVENT_FOR_ME;
+
+ char *record_exdate = NULL;
+ ret = calendar_record_get_str_p(record,property_info[i]. property_id, &record_exdate);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ ret = calendar_record_get_int(original_record, CAL_PROPERTY_EVENT_CALENDAR_ID, &calendar_id);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+
+ calendar_record_h record_calendar = NULL;
+ ret = _cal_db_get_record(_calendar_book._uri, calendar_id, &record_calendar);
+ ret |= calendar_record_get_int(record_calendar, _calendar_book.account_id, &account_id);
+ ret |= calendar_record_get_int(record_calendar, _calendar_book.sync_event, (int *)&sync_event_type);
+ DBG("calendar_id(%d), account_id(%d), sync_event(%d)", calendar_id, account_id, sync_event_type);
+ calendar_record_destroy(record_calendar, true);
-static void __cal_db_event_get_stmt(sqlite3_stmt *stmt,bool is_view_table,calendar_record_h record)
-{
- cal_event_s *event = NULL;
- const unsigned char *temp;
- int count = 0;
- char *dtstart_datetime;
- char *dtend_datetime;
- char buf[8] = {0};
-
- event = (cal_event_s*)(record);
-
- event->index = sqlite3_column_int(stmt, count++);
- sqlite3_column_int(stmt, count++);//event->account_id = sqlite3_column_int(stmt, count++);
- sqlite3_column_int(stmt, count++);//event->cal_type = 1;/*sqlite3_column_int(stmt, count++);*/
-
- temp = sqlite3_column_text(stmt, count++);
- event->summary = SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- event->description = SAFE_STRDUP(temp);
-
- temp = sqlite3_column_text(stmt, count++);
- event->location = SAFE_STRDUP(temp);
-
- temp = sqlite3_column_text(stmt, count++);
- event->categories = SAFE_STRDUP(temp);
-
- temp = sqlite3_column_text(stmt, count++);
- event->exdate = SAFE_STRDUP(temp);
-
- event->event_status = sqlite3_column_int(stmt, count++);
- event->priority = sqlite3_column_int(stmt, count++);
- event->timezone = sqlite3_column_int(stmt, count++);
- event->contact_id = sqlite3_column_int(stmt, count++);
- event->busy_status = sqlite3_column_int(stmt, count++);
- event->sensitivity = sqlite3_column_int(stmt, count++);
-
- temp = sqlite3_column_text(stmt, count++);
- event->uid = SAFE_STRDUP(temp);
-
- temp = sqlite3_column_text(stmt, count++);
- event->organizer_name = SAFE_STRDUP(temp);
-
- temp = sqlite3_column_text(stmt, count++);
- event->organizer_email = SAFE_STRDUP(temp);
-
- event->meeting_status = sqlite3_column_int(stmt, count++);
-
- event->calendar_id = sqlite3_column_int(stmt, count++);
-
- event->original_event_id = sqlite3_column_int(stmt, count++);
-
- event->latitude = sqlite3_column_double(stmt,count++);
- event->longitude = sqlite3_column_double(stmt,count++);
- event->email_id = sqlite3_column_int(stmt, count++);
- sqlite3_column_int(stmt, count++);//event->availability = sqlite3_column_int(stmt, count++);
-
- event->created_time = sqlite3_column_int64(stmt, count++);
-
- sqlite3_column_int64(stmt, count++);//event->completed_time = sqlite3_column_int64(stmt, count++);
-
- sqlite3_column_int(stmt, count++);//event->progress = sqlite3_column_int(stmt,count++);
-
- sqlite3_column_int(stmt,count++);
- sqlite3_column_int(stmt,count++);
- event->is_deleted = sqlite3_column_int(stmt,count++);
-
- event->start.type = sqlite3_column_int(stmt,count++);
-
- if (event->start.type == CALENDAR_TIME_UTIME)
- {
- event->start.time.utime = sqlite3_column_int64(stmt,count++);
- sqlite3_column_text(stmt, count++); //dtstart_datetime
- }
- else
- {
- sqlite3_column_int64(stmt,count++); //event->start.time.utime = sqlite3_column_int64(stmt,count++);
- temp = sqlite3_column_text(stmt, count++);
- if (temp) {
- dtstart_datetime = SAFE_STRDUP(temp);
- snprintf(buf, strlen("YYYY") + 1, "%s", &dtstart_datetime[0]);
- event->start.time.date.year = atoi(buf);
- snprintf(buf, strlen("MM") + 1, "%s", &dtstart_datetime[4]);
- event->start.time.date.month = atoi(buf);
- snprintf(buf, strlen("DD") + 1, "%s", &dtstart_datetime[6]);
- event->start.time.date.mday = atoi(buf);
- if (dtstart_datetime) free(dtstart_datetime);
- }
- }
-
- temp = sqlite3_column_text(stmt, count++);
- event->start_tzid = SAFE_STRDUP(temp);
- event->end.type = sqlite3_column_int(stmt, count++);
- if (event->end.type == CALENDAR_TIME_UTIME)
- {
- event->end.time.utime = sqlite3_column_int64(stmt,count++);
- sqlite3_column_text(stmt, count++);
- }
- else
- {
- sqlite3_column_int64(stmt, count++);//event->end.time.utime = sqlite3_column_int64(stmt, count++);
- temp = sqlite3_column_text(stmt, count++);
- if (temp) {
- dtend_datetime = SAFE_STRDUP(temp);
- snprintf(buf, strlen("YYYY") + 1, "%s", &dtend_datetime[0]);
- event->end.time.date.year = atoi(buf);
- snprintf(buf, strlen("MM") + 1, "%s", &dtend_datetime[4]);
- event->end.time.date.month = atoi(buf);
- snprintf(buf, strlen("DD") + 1, "%s", &dtend_datetime[6]);
- event->end.time.date.mday = atoi(buf);
- if (dtend_datetime) free(dtend_datetime);
- }
- }
- temp = sqlite3_column_text(stmt, count++);
- event->end_tzid = SAFE_STRDUP(temp);
-
- event->last_mod = sqlite3_column_int64(stmt,count++);
- sqlite3_column_int(stmt,count++);//event->rrule_id = sqlite3_column_int(stmt,count++);
-
- temp = sqlite3_column_text(stmt, count++);
- event->recurrence_id = SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- event->rdate = SAFE_STRDUP(temp);
- event->has_attendee = sqlite3_column_int(stmt,count++);
- event->has_alarm = sqlite3_column_int(stmt,count++);
- event->system_type = sqlite3_column_int(stmt,count++);
- event->updated = sqlite3_column_int(stmt,count++);
- temp = sqlite3_column_text(stmt, count++);
- event->sync_data1 = SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- event->sync_data2 = SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- event->sync_data3 = SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- event->sync_data4 = SAFE_STRDUP(temp);
-
- if (is_view_table == true)
- {
- event->freq = sqlite3_column_int(stmt, count++);
-
- if (event->freq <= 0) {
- //event->rrule_id = 0;
- //sqlite3_finalize(stmt);
- //return CALENDAR_ERROR_NONE;
- return ;
- }
-
- //event->rrule_id = 1;
- event->range_type = sqlite3_column_int(stmt, count++);
- event->until_type = sqlite3_column_int(stmt, count++);
- event->until_utime = sqlite3_column_int64(stmt, count++);
-
- temp = sqlite3_column_text(stmt, count++);
- if (CALENDAR_TIME_LOCALTIME == event->until_type)
+ char *original_exdate = NULL;
+ ret = calendar_record_get_str_p(original_record,property_info[i].property_id,&original_exdate);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ if (sync_event_type == CALENDAR_BOOK_SYNC_EVENT_FOR_EVERY_AND_REMAIN)
+ {
+ ret = __cal_db_event_exdate_insert_normal(event_id, original_exdate, record_exdate, NULL, NULL);
+ warn_if (ret != CALENDAR_ERROR_NONE, "%s->%s",original_exdate,record_exdate);
+
+ } else {
+ int *exception_ids = NULL;
+ int exception_len = 0;
+ ret = __cal_db_event_exdate_insert_normal(event_id, original_exdate, record_exdate, &exception_ids, &exception_len);
+ warn_if (ret != CALENDAR_ERROR_NONE, "%s->%s",original_exdate,record_exdate);
+ ret = __cal_db_event_delete_exception(exception_ids, exception_len);
+ warn_if (ret != CALENDAR_ERROR_NONE, "__cal_db_event_delete_record() is failed");
+ free(exception_ids);
+ }
+ ret = _cal_record_set_str(original_record, property_info[i].property_id, record_exdate);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_INT) == true)
+ {
+ int tmp=0;
+ ret = calendar_record_get_int(record,property_info[i].property_id,&tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ ret = _cal_record_set_int(original_record, property_info[i].property_id, tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_STR) == true)
{
- sscanf((const char *)temp, "%04d%02d%02d",
- &event->until_year, &event->until_month, &event->until_mday);
+ char *tmp=NULL;
+ ret = calendar_record_get_str_p(record,property_info[i].property_id,&tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ ret = _cal_record_set_str(original_record, property_info[i].property_id, tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
}
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
+ {
+ double tmp=0;
+ ret = calendar_record_get_double(record,property_info[i].property_id,&tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ ret = _cal_record_set_double(original_record, property_info[i].property_id, tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_LLI) == true)
+ {
+ long long int tmp=0;
+ ret = calendar_record_get_lli(record,property_info[i].property_id,&tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ ret = _cal_record_set_lli(original_record, property_info[i].property_id, tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
+ {
+ calendar_time_s tmp = {0,};
+ ret = calendar_record_get_caltime(record,property_info[i].property_id,&tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ ret = _cal_record_set_caltime(original_record, property_info[i].property_id, tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ }
+ }
+ // child replace
+ cal_event_s *tmp = (cal_event_s *)original_record;
+ cal_event_s *tmp_src = (cal_event_s *)record;
+
+ if (tmp->alarm_list)
+ calendar_list_destroy((calendar_list_h)tmp->alarm_list, true);
+ _cal_list_clone((calendar_list_h)tmp_src->alarm_list, (calendar_list_h *)&tmp->alarm_list);
- event->count = sqlite3_column_int(stmt, count++);
- event->interval = sqlite3_column_int(stmt, count++);
+ if (tmp->attendee_list)
+ calendar_list_destroy((calendar_list_h)tmp->attendee_list, true);
+ _cal_list_clone((calendar_list_h)tmp_src->attendee_list, (calendar_list_h *)&tmp->attendee_list);
- temp = sqlite3_column_text(stmt, count++);
- event->bysecond = SAFE_STRDUP(temp);
+ if (tmp->exception_list)
+ calendar_list_destroy((calendar_list_h)tmp->exception_list, true);
+ _cal_list_clone((calendar_list_h)tmp_src->exception_list, (calendar_list_h *)&tmp->exception_list);
+
+ if (tmp->extended_list)
+ calendar_list_destroy((calendar_list_h)tmp->extended_list, true);
+ _cal_list_clone((calendar_list_h)tmp_src->extended_list, (calendar_list_h *)&tmp->extended_list);
+
+ CAL_RECORD_RESET_COMMON((cal_record_s*)original_record);
+ ret = __update_record(original_record, is_dirty_in_time);
+ calendar_record_destroy(original_record, true);
+
+ return ret;
+}
+
+static int __cal_db_event_exception_get_records(int original_id, cal_list_s *list)
+{
+ int ret;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
- temp = sqlite3_column_text(stmt, count++);
- event->byminute = SAFE_STRDUP(temp);
+ retvm_if(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Invalid parameter: list is NULL");
- temp = sqlite3_column_text(stmt, count++);
- event->byhour = SAFE_STRDUP(temp);
+ snprintf(query, sizeof(query),
+ "SELECT "CAL_QUERY_SCHEDULE_A_ALL" FROM %s AS A "
+ "WHERE original_event_id = %d AND is_deleted = 0 ",
+ CAL_TABLE_SCHEDULE,
+ original_id);
- temp = sqlite3_column_text(stmt, count++);
- event->byday= SAFE_STRDUP(temp);
+ stmt = _cal_db_util_query_prepare(query);
+ retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "_cal_db_util_query_prepare() failed");
- temp = sqlite3_column_text(stmt, count++);
- event->bymonthday= SAFE_STRDUP(temp);
+ calendar_record_h record = NULL;
- temp = sqlite3_column_text(stmt, count++);
- event->byyearday= SAFE_STRDUP(temp);
+ while (_cal_db_util_stmt_step(stmt) == CAL_DB_ROW) {
+ int exception = 0, extended = 0;
+ ret = calendar_record_create(_calendar_event._uri, &record);
+ if (CALENDAR_ERROR_NONE != ret) {
+ sqlite3_finalize(stmt);
+ _cal_list_clear(list);
+ return ret;
+ }
- temp = sqlite3_column_text(stmt, count++);
- event->byweekno= SAFE_STRDUP(temp);
+ __cal_db_event_get_stmt(stmt, false, record, &exception, &extended);
- temp = sqlite3_column_text(stmt, count++);
- event->bymonth= SAFE_STRDUP(temp);
+ cal_rrule_s *rrule = NULL;
+ cal_event_s *event = (cal_event_s *)record;
+ if (_cal_db_rrule_get_rrule(event->index, &rrule) == CALENDAR_ERROR_NONE )
+ {
+ _cal_db_rrule_set_rrule_to_event(rrule, record);
+ CAL_FREE(rrule);
+ }
- temp = sqlite3_column_text(stmt, count++);
- event->bysetpos = SAFE_STRDUP(temp);
+ if (event->has_alarm == 1)
+ _cal_db_alarm_get_records(event->index, event->alarm_list);
- event->wkst = sqlite3_column_int(stmt, count++);
+ if (event->has_attendee == 1)
+ _cal_db_attendee_get_records(event->index, event->attendee_list);
- sqlite3_column_int(stmt, count++); //calendar deleted
- }
+ if (exception == 1)
+ __cal_db_event_exception_get_records(event->index, event->exception_list);
-}
+ if (extended == 1)
+ _cal_db_extended_get_records(event->index, CALENDAR_RECORD_TYPE_EVENT, event->extended_list);
-static void __cal_db_event_get_property_stmt(sqlite3_stmt *stmt,
- unsigned int property, int *stmt_count, calendar_record_h record)
-{
- cal_event_s *event = NULL;
- const unsigned char *temp;
- char *dtstart_datetime;
- char *dtend_datetime;
- char buf[8] = {0};
-
- event = (cal_event_s*)(record);
-
- switch(property)
- {
- case CAL_PROPERTY_EVENT_ID:
- event->index = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_EVENT_CALENDAR_ID:
- event->calendar_id = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_EVENT_SUMMARY:
- temp = sqlite3_column_text(stmt, *stmt_count);
- event->summary = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EVENT_DESCRIPTION:
- temp = sqlite3_column_text(stmt, *stmt_count);
- event->description = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EVENT_LOCATION:
- temp = sqlite3_column_text(stmt, *stmt_count);
- event->location = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EVENT_CATEGORIES:
- temp = sqlite3_column_text(stmt, *stmt_count);
- event->categories = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EVENT_EXDATE:
- temp = sqlite3_column_text(stmt, *stmt_count);
- event->exdate = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EVENT_EVENT_STATUS:
- event->event_status = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_EVENT_PRIORITY:
- event->priority = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_EVENT_TIMEZONE:
- event->timezone = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_EVENT_CONTACT_ID:
- event->contact_id = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_EVENT_BUSY_STATUS:
- event->busy_status = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_EVENT_SENSITIVITY:
- event->sensitivity = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_EVENT_UID:
- temp = sqlite3_column_text(stmt, *stmt_count);
- event->uid = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EVENT_ORGANIZER_NAME:
- temp = sqlite3_column_text(stmt, *stmt_count);
- event->organizer_name = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EVENT_ORGANIZER_EMAIL:
- temp = sqlite3_column_text(stmt, *stmt_count);
- event->organizer_email = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EVENT_MEETING_STATUS:
- event->meeting_status = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_EVENT_ORIGINAL_EVENT_ID:
- event->original_event_id = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_EVENT_LATITUDE:
- event->latitude = sqlite3_column_double(stmt,*stmt_count);
- break;
- case CAL_PROPERTY_EVENT_LONGITUDE:
- event->longitude = sqlite3_column_double(stmt,*stmt_count);
- break;
- case CAL_PROPERTY_EVENT_EMAIL_ID:
- event->email_id = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_EVENT_CREATED_TIME:
- event->created_time = sqlite3_column_int64(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_EVENT_LAST_MODIFIED_TIME:
- event->last_mod = sqlite3_column_int64(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_EVENT_IS_DELETED:
- event->is_deleted = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_EVENT_FREQ:
- event->freq = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_EVENT_RANGE_TYPE:
- event->range_type = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_EVENT_UNTIL:
- //!!
- break;
- case CAL_PROPERTY_EVENT_COUNT:
- event->count = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_EVENT_INTERVAL:
- event->interval = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_EVENT_BYSECOND:
- temp = sqlite3_column_text(stmt, *stmt_count);
- event->bysecond = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EVENT_BYMINUTE:
- temp = sqlite3_column_text(stmt, *stmt_count);
- event->byminute = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EVENT_BYHOUR:
- temp = sqlite3_column_text(stmt, *stmt_count);
- event->byhour = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EVENT_BYDAY:
- temp = sqlite3_column_text(stmt, *stmt_count);
- event->byday = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EVENT_BYMONTHDAY:
- temp = sqlite3_column_text(stmt, *stmt_count);
- event->bymonthday = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EVENT_BYYEARDAY:
- temp = sqlite3_column_text(stmt, *stmt_count);
- event->byyearday = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EVENT_BYWEEKNO:
- temp = sqlite3_column_text(stmt, *stmt_count);
- event->byweekno = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EVENT_BYMONTH:
- temp = sqlite3_column_text(stmt, *stmt_count);
- event->bymonth = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EVENT_BYSETPOS:
- temp = sqlite3_column_text(stmt, *stmt_count);
- event->bysetpos = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EVENT_WKST:
- event->wkst = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_EVENT_RECURRENCE_ID:
- temp = sqlite3_column_text(stmt, *stmt_count);
- event->recurrence_id = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EVENT_RDATE:
- temp = sqlite3_column_text(stmt, *stmt_count);
- event->rdate = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EVENT_HAS_ATTENDEE:
- event->has_attendee = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_EVENT_HAS_ALARM:
- event->has_alarm = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_EVENT_SYNC_DATA1:
- temp = sqlite3_column_text(stmt, *stmt_count);
- event->sync_data1 = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EVENT_SYNC_DATA2:
- temp = sqlite3_column_text(stmt, *stmt_count);
- event->sync_data2 = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EVENT_SYNC_DATA3:
- temp = sqlite3_column_text(stmt, *stmt_count);
- event->sync_data3 = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EVENT_SYNC_DATA4:
- temp = sqlite3_column_text(stmt, *stmt_count);
- event->sync_data4 = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EVENT_START:
- //!!
- event->start.type = sqlite3_column_int(stmt,*stmt_count);
- if (event->start.type == CALENDAR_TIME_UTIME)
- {
- *stmt_count = *stmt_count+1;
- event->start.time.utime = sqlite3_column_int64(stmt,*stmt_count);
- *stmt_count = *stmt_count+1;
- sqlite3_column_text(stmt, *stmt_count); //dtstart_datetime
- }
- else
- {
- *stmt_count = *stmt_count+1;
- sqlite3_column_int64(stmt,*stmt_count); //event->start.time.utime = sqlite3_column_int64(stmt,count++);
- *stmt_count = *stmt_count+1;
- temp = sqlite3_column_text(stmt, *stmt_count);
- if (temp) {
- dtstart_datetime = SAFE_STRDUP(temp);
- snprintf(buf, strlen("YYYY") + 1, "%s", &dtstart_datetime[0]);
- event->start.time.date.year = atoi(buf);
- snprintf(buf, strlen("MM") + 1, "%s", &dtstart_datetime[4]);
- event->start.time.date.month = atoi(buf);
- snprintf(buf, strlen("DD") + 1, "%s", &dtstart_datetime[6]);
- event->start.time.date.mday = atoi(buf);
- if (dtstart_datetime) free(dtstart_datetime);
- }
- }
- break;
- case CAL_PROPERTY_EVENT_START_TZID:
- temp = sqlite3_column_text(stmt, *stmt_count);
- event->start_tzid = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EVENT_END:
- //!!
- event->end.type = sqlite3_column_int(stmt, *stmt_count);
- if (event->end.type == CALENDAR_TIME_UTIME)
- {
- *stmt_count = *stmt_count+1;
- event->end.time.utime = sqlite3_column_int64(stmt,*stmt_count);
- *stmt_count = *stmt_count+1;
- sqlite3_column_text(stmt, *stmt_count);
- }
- else
- {
- *stmt_count = *stmt_count+1;
- sqlite3_column_int64(stmt, *stmt_count);//event->end.time.utime = sqlite3_column_int64(stmt, count++);
- *stmt_count = *stmt_count+1;
- temp = sqlite3_column_text(stmt, *stmt_count);
- if (temp) {
- dtend_datetime = SAFE_STRDUP(temp);
- snprintf(buf, strlen("YYYY") + 1, "%s", &dtend_datetime[0]);
- event->end.time.date.year = atoi(buf);
- snprintf(buf, strlen("MM") + 1, "%s", &dtend_datetime[4]);
- event->end.time.date.month = atoi(buf);
- snprintf(buf, strlen("DD") + 1, "%s", &dtend_datetime[6]);
- event->end.time.date.mday = atoi(buf);
- if (dtend_datetime) free(dtend_datetime);
- }
- }
- break;
- case CAL_PROPERTY_EVENT_END_TZID:
- temp = sqlite3_column_text(stmt, *stmt_count);
- event->end_tzid = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EVENT_CALENDAR_SYSTEM_TYPE:
- event->system_type = sqlite3_column_int(stmt, *stmt_count);
- break;
- default:
- sqlite3_column_int(stmt, *stmt_count);
- break;
- }
-
- *stmt_count = *stmt_count+1;
-}
+ event->has_alarm = 0;
+ if (event->alarm_list && 0 < event->alarm_list->count)
+ event->has_alarm = 1;
-static void __cal_db_event_get_projection_stmt(sqlite3_stmt *stmt,
- const unsigned int *projection, const int projection_count,
- calendar_record_h record)
-{
- int i=0;
- int stmt_count = 0;
+ event->has_attendee = 0;
+ if (event->attendee_list && 0 < event->attendee_list->count)
+ event->has_attendee = 1;
- for(i=0;i<projection_count;i++)
- {
- __cal_db_event_get_property_stmt(stmt,projection[i],&stmt_count,record);
- }
+ calendar_list_add((calendar_list_h)list, record);
+ }
+ sqlite3_finalize(stmt);
+ return CALENDAR_ERROR_NONE;
}
-static int __cal_db_event_update_dirty(calendar_record_h record)
+static int __cal_db_event_exception_delete_with_id(int original_id)
{
- int event_id = 0;
- int ret = CALENDAR_ERROR_NONE;
- calendar_record_h original_record = NULL;
-
- ret = calendar_record_get_int(record,_calendar_event.id, &event_id);
- retv_if(CALENDAR_ERROR_NONE != ret, ret);
-
- CAL_DBG("id=%d",event_id);
-
- ret = __cal_db_event_get_record(event_id, &original_record);
-
- if (ret == CALENDAR_ERROR_NONE)
- {
- cal_record_s *_record = NULL;
- const cal_property_info_s* property_info = NULL;
- int property_info_count = 0;
- int i=0;
-
- _record = (cal_record_s *)record;
-
- property_info = _cal_view_get_property_info(_record->view_uri, &property_info_count);
-
- for(i=0;i<property_info_count;i++)
- {
- if ( true == _cal_record_check_property_flag(record, property_info[i].property_id , CAL_PROPERTY_FLAG_DIRTY))
- {
- //CAL_DBG("%d",property_info[i].property_id);
- if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_INT) == true)
- {
- int tmp=0;
- ret = calendar_record_get_int(record,property_info[i].property_id,&tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- ret = _cal_record_set_int(original_record, property_info[i].property_id, tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_STR) == true)
- {
- char *tmp=NULL;
- ret = calendar_record_get_str_p(record,property_info[i].property_id,&tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- ret = _cal_record_set_str(original_record, property_info[i].property_id, tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
- {
- double tmp=0;
- ret = calendar_record_get_double(record,property_info[i].property_id,&tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- ret = _cal_record_set_double(original_record, property_info[i].property_id, tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_LLI) == true)
- {
- long long int tmp=0;
- ret = calendar_record_get_lli(record,property_info[i].property_id,&tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- ret = _cal_record_set_lli(original_record, property_info[i].property_id, tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
- {
- calendar_time_s tmp = {0,};
- ret = calendar_record_get_caltime(record,property_info[i].property_id,&tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- ret = _cal_record_set_caltime(original_record, property_info[i].property_id, tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- }
- }
- }
-
- // child replace
- cal_event_s *tmp = (cal_event_s *)original_record;
- cal_event_s *tmp_src = (cal_event_s *)record;
- if ( tmp->alarm_list )
- {
- GList *alarm_list = g_list_first(tmp->alarm_list);
- calendar_record_h alarm_child_record = NULL;
- while (alarm_list)
- {
- alarm_child_record = (calendar_record_h)alarm_list->data;
- if (alarm_child_record == NULL)
- {
- alarm_list = g_list_next(alarm_list);
- continue;
- }
-
- calendar_record_destroy(alarm_child_record, true);
-
- alarm_list = g_list_next(alarm_list);
- }
- g_list_free(tmp->alarm_list);
- }
- tmp->alarm_list = tmp_src->alarm_list;
-
- if( tmp->attendee_list )
- {
- GList * attendee_list = g_list_first(tmp->attendee_list);
- calendar_record_h attendee = NULL;
-
- while (attendee_list)
- {
- attendee = (calendar_record_h)attendee_list->data;
- if (attendee == NULL)
- {
- attendee_list = g_list_next(attendee_list);
- continue;
- }
-
- calendar_record_destroy(attendee, true);
-
- attendee_list = g_list_next(attendee_list);
- }
- g_list_free(tmp->attendee_list);
- }
- tmp->attendee_list = tmp_src->attendee_list;
- if( tmp->exception_list )
- {
- GList * exception_list = g_list_first(tmp->exception_list);
- calendar_record_h exception = NULL;
-
- while (exception_list)
- {
- exception = (calendar_record_h)exception_list->data;
- if (exception == NULL)
- {
- exception_list = g_list_next(exception_list);
- continue;
- }
-
- calendar_record_destroy(exception, true);
-
- exception_list = g_list_next(exception_list);
- }
- g_list_free(tmp->exception_list);
- }
- tmp->exception_list = tmp_src->exception_list;
- if( tmp->extended_list )
- {
- GList * extended_list = g_list_first(tmp->extended_list);
- calendar_record_h extended = NULL;
-
- while (extended_list)
- {
- extended = (calendar_record_h)extended_list->data;
- if (extended == NULL)
- {
- extended_list = g_list_next(extended_list);
- continue;
- }
-
- calendar_record_destroy(extended, true);
-
- extended_list = g_list_next(extended_list);
- }
- g_list_free(tmp->extended_list);
- }
- tmp->extended_list = tmp_src->extended_list;
- }
- else
- {
- CAL_DBG("get_record fail");
- return ret;
- }
-
- CAL_RECORD_RESET_COMMON((cal_record_s*)original_record);
- ret = __cal_db_event_update_record(original_record);
-
- calendar_record_destroy(original_record,false);
-
- return ret;
-}
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ cal_db_util_error_e dbret = CAL_DB_OK;
-#if 0 // // under construction
-static int __cal_db_event_update_dirty(calendar_record_h record)
-{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
- cal_event_s* event = (cal_event_s*)(record);
- cal_db_util_error_e dbret = CAL_DB_OK;
- int ret = CALENDAR_ERROR_NONE;
- char* set = NULL;
- GSList *bind_text = NULL;
- unsigned int properties[36];
- int properties_count = 36;
- bool bchangerrule = __cal_db_event_check_changed_rrule(record);
- bool bchangetime = __cal_db_event_check_changed_time(record);
-
- if (bchangerrule == true && bchangetime == false)
- {
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- /*
- else if (bchangetime == true)
- {
- // rrule table check !
- }
- */
-
- properties[0] = CAL_PROPERTY_EVENT_CALENDAR_ID;
- properties[1] = CAL_PROPERTY_EVENT_SUMMARY;
- properties[2] = CAL_PROPERTY_EVENT_DESCRIPTION;
- properties[3] = CAL_PROPERTY_EVENT_LOCATION;
- properties[4] = CAL_PROPERTY_EVENT_CATEGORIES;
- properties[5] = CAL_PROPERTY_EVENT_EXDATE;
- properties[6] = CAL_PROPERTY_EVENT_EVENT_STATUS;
- properties[7] = CAL_PROPERTY_EVENT_PRIORITY;
- properties[8] = CAL_PROPERTY_EVENT_TIMEZONE;
- properties[9] = CAL_PROPERTY_EVENT_CONTACT_ID;
- properties[10] = CAL_PROPERTY_EVENT_BUSY_STATUS;
- properties[11] = CAL_PROPERTY_EVENT_SENSITIVITY;
- properties[12] = CAL_PROPERTY_EVENT_UID;
- properties[13] = CAL_PROPERTY_EVENT_ORGANIZER_NAME;
- properties[14] = CAL_PROPERTY_EVENT_ORGANIZER_EMAIL;
- properties[15] = CAL_PROPERTY_EVENT_MEETING_STATUS;
- properties[16] = CAL_PROPERTY_EVENT_ORIGINAL_EVENT_ID;
- properties[17] = CAL_PROPERTY_EVENT_LATITUDE;
- properties[18] = CAL_PROPERTY_EVENT_LONGITUDE;
- properties[19] = CAL_PROPERTY_EVENT_EMAIL_ID;
- properties[20] = CAL_PROPERTY_EVENT_CREATED_TIME;
- properties[21] = CAL_PROPERTY_EVENT_LAST_MODIFIED_TIME;
- properties[22] = CAL_PROPERTY_EVENT_IS_DELETED;
- properties[23] = CAL_PROPERTY_EVENT_RECURRENCE_ID;
- properties[24] = CAL_PROPERTY_EVENT_RDATE;
- properties[25] = CAL_PROPERTY_EVENT_HAS_ATTENDEE;
- properties[26] = CAL_PROPERTY_EVENT_HAS_ALARM;
- properties[27] = CAL_PROPERTY_EVENT_SYNC_DATA1;
- properties[28] = CAL_PROPERTY_EVENT_SYNC_DATA2;
- properties[29] = CAL_PROPERTY_EVENT_SYNC_DATA3;
- properties[30] = CAL_PROPERTY_EVENT_SYNC_DATA4;
- properties[31] = CAL_PROPERTY_EVENT_START;
- properties[32] = CAL_PROPERTY_EVENT_END;
- properties[33] = CAL_PROPERTY_EVENT_CALENDAR_SYSTEM_TYPE;
- properties[34] = CAL_PROPERTY_EVENT_START_TZID;
- properties[35] = CAL_PROPERTY_EVENT_END_TZID;
-
- ret = _cal_db_query_create_projection_update_set_with_property(record,properties,properties_count,
- &set,&bind_text);
- retv_if(CALENDAR_ERROR_NONE != ret, ret);
-
- if (set && strlen(str) > 0)
- {
- snprintf(query, sizeof(query), "UPDATE %s SET "
- "changed_ver = %d, "
- "%s"
- "WHERE id = %d",
- CAL_TABLE_SCHEDULE,
- _cal_db_util_get_next_ver(),
- set,
- event->index);
- }
- else
- {
- snprintf(query, sizeof(query), "UPDATE %s SET "
- "changed_ver = %d"
- "WHERE id = %d",
- CAL_TABLE_SCHEDULE,
- _cal_db_util_get_next_ver(),
- event->index);
- }
-
- stmt = _cal_db_util_query_prepare(query);
- retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "_cal_db_util_query_prepare() Failed");
-
- // bind
- if (bind_text)
- {
- int len;
- GSList *cursor = NULL;
- int i = 0;
- len = g_slist_length(bind_text);
- for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
- {
- _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
- }
- }
-
- dbret = _cal_db_util_stmt_step(stmt);
- if (CAL_DB_DONE != dbret) {
- sqlite3_finalize(stmt);
- ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
-
- CAL_FREE(set);
- if(bind_text)
- {
- for (cursor=bind_text; cursor;cursor=cursor->next)
- {
- CAL_FREE(cursor->data);
- }
- g_slist_free(bind_text);
- }
+ DBG("delete exception mod with original event id(%d)", original_id);
+ snprintf(query, sizeof(query), "DELETE FROM %s WHERE original_event_id=%d ",
+ CAL_TABLE_SCHEDULE, original_id);
+
+ dbret = _cal_db_util_query_exec(query);
+ if (dbret != CAL_DB_OK) {
+ ERR("_cal_db_util_query_exec() failed (%d)", dbret);
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
+ }
- sqlite3_finalize(stmt);
+ return CALENDAR_ERROR_NONE;
+}
- // rrule update
- if (bchangerrule == true)
- {
- cal_rrule_s *rrule = NULL;
+static int __cal_db_event_exception_get_ids(int original_id, GList **out_list)
+{
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+ GList *list = NULL;
- _cal_db_rrule_get_rrule_from_event(record, &rrule);
- _cal_db_rrule_update_record(event->index, rrule);
- CAL_FREE(rrule);
+ retvm_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Invalid parameter: GList is NULL");
- ret = _cal_db_instance_discard_record(record);
- retvm_if(ret != CALENDAR_ERROR_NONE, CALENDAR_ERROR_DB_FAILED,
- "_cal_db_instance_discard_record() Failed(%d)", ret);
+ snprintf(query, sizeof(query),
+ "SELECT id FROM %s "
+ "WHERE original_event_id = %d AND is_deleted = 0 ",
+ CAL_TABLE_SCHEDULE,
+ original_id);
- _cal_db_instance_publish_record(record);
- }
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt)
+ {
+ ERR("_cal_db_util_query_prepare() failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
- // child update 의 경우는 get_with_query 구현 이후 고려
+ while (_cal_db_util_stmt_step(stmt) == CAL_DB_ROW)
+ {
+ int id = 0;
+ id = sqlite3_column_int(stmt, 0);
+ list = g_list_append(list, GINT_TO_POINTER(id));
- _cal_db_util_notify(CAL_NOTI_TYPE_EVENT);
+ }
+ sqlite3_finalize(stmt);
- CAL_FREE(set);
- if(bind_text)
- {
- for (cursor=bind_text; cursor;cursor=cursor->next)
- {
- CAL_FREE(cursor->data);
- }
- g_slist_free(bind_text);
- }
- return CALENDAR_ERROR_NONE;
+ *out_list = list;
+ return CALENDAR_ERROR_NONE;
}
-bool __cal_db_event_check_changed_rrule(calendar_record_h record)
+static int __cal_db_event_exception_update(cal_list_s *exception_list_s, int original_id, int calendar_id, int is_dirty_in_time, time_t time_diff, int old_type, int new_type)
{
- unsigned int properties[15];
- int properties_count = 15;
- int i=0;
-
- properties[0] = CAL_PROPERTY_EVENT_FREQ;
- properties[1] = CAL_PROPERTY_EVENT_RANGE_TYPE;
- properties[2] = CAL_PROPERTY_EVENT_UNTIL;
- properties[3] = CAL_PROPERTY_EVENT_COUNT;
- properties[4] = CAL_PROPERTY_EVENT_INTERVAL;
- properties[5] = CAL_PROPERTY_EVENT_BYSECOND;
- properties[6] = CAL_PROPERTY_EVENT_BYMINUTE;
- properties[7] = CAL_PROPERTY_EVENT_BYHOUR;
- properties[8] = CAL_PROPERTY_EVENT_BYDAY;
- properties[9] = CAL_PROPERTY_EVENT_BYMONTHDAY;
- properties[10] = CAL_PROPERTY_EVENT_BYYEARDAY;
- properties[11] = CAL_PROPERTY_EVENT_BYWEEKNO;
- properties[12] = CAL_PROPERTY_EVENT_BYMONTH;
- properties[13] = CAL_PROPERTY_EVENT_BYSETPOS;
- properties[14] = CAL_PROPERTY_EVENT_WKST;
-
- for(i=0;i<properties_count;i++)
- {
- if (false == _cal_record_check_property_flag(record, properties[i], CAL_PROPERTY_FLAG_PROJECTION))
- return false;
- }
- return true;
-}
+ int count = 0;
+ int ret = CALENDAR_ERROR_NONE;
+ calendar_record_h exception = NULL;
+ calendar_list_h exception_list = (calendar_list_h)exception_list_s;
+ GList *id_list = NULL;
+
+ __cal_db_event_exception_get_ids(original_id, &id_list);
+
+ if (exception_list) {
+ calendar_list_get_count(exception_list, &count);
+ calendar_list_first(exception_list);
+ while (CALENDAR_ERROR_NONE == calendar_list_get_current_record_p(exception_list, &exception)) {
+ int exception_id = 0;
+ ret = calendar_record_get_int(exception,_calendar_event.id, &exception_id);
+ DBG("exception(%d)", exception_id);
+ if (exception_id > 0 && exception_id != original_id) { // update
+ bool bchanged = false;
+ cal_record_s *_record = NULL;
+ const cal_property_info_s* property_info = NULL;
+ int property_info_count = 0;
+
+ _record = (cal_record_s *)exception;
+
+ property_info = _cal_view_get_property_info(_record->view_uri, &property_info_count);
+
+ // check updated
+ int i;
+ for (i = 0; i < property_info_count; i++) {
+ if ( true == _cal_record_check_property_flag(exception, property_info[i].property_id , CAL_PROPERTY_FLAG_DIRTY)) {
+ bchanged = true;
+ break;
+ }
+ }
+
+ if (bchanged == true || DIRTY_IN_TIME == is_dirty_in_time) {
+ // update
+ __update_recurrence_id(exception, old_type, new_type, time_diff);
+ ret = __cal_db_event_update_record(exception);
+ _cal_db_instance_discard_record(exception_id);
+ _cal_db_instance_publish_record(exception);
+
+ } else {
+ _cal_db_instance_discard_record(exception_id);
+ _cal_db_instance_publish_record(exception);
+ DBG("exception don't changed. exception_id=[%d]",exception_id);
+ }
+
+ if (id_list)
+ id_list = g_list_remove(id_list, GINT_TO_POINTER(exception_id) );
+
+ } else { // insert
+ ret = _cal_record_set_int(exception,_calendar_event.calendar_book_id, calendar_id);
+ if (ret != CALENDAR_ERROR_NONE) {
+ ERR("set fail");
+ if (id_list)
+ g_list_free(id_list);
+ return ret;
+ }
+ ret = _cal_db_event_insert_record(exception, original_id, NULL);
+ if (ret != CALENDAR_ERROR_NONE) {
+ ERR("set fail");
+ if (id_list)
+ g_list_free(id_list);
+ return ret;
+ }
+ }
+ calendar_list_next(exception_list);
+ }
+ }
-bool __cal_db_event_check_changed_time(calendar_record_h record)
-{
- unsigned int properties[2];
- int properties_count = 2;
- int i=0;
-
- properties[0] = CAL_PROPERTY_EVENT_START;
- properties[1] = CAL_PROPERTY_EVENT_END;
-
- for(i=0;i<properties_count;i++)
- {
- if (false == _cal_record_check_property_flag(record, properties[i], CAL_PROPERTY_FLAG_PROJECTION))
- return false;
- }
- return true;
+ if (id_list) {
+ GList * tmp_list = g_list_first(id_list);
+ while(tmp_list) {
+ int tmp = GPOINTER_TO_INT(tmp_list->data);
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ cal_db_util_error_e dbret = CAL_DB_OK;
+
+ snprintf(query, sizeof(query), "DELETE FROM %s WHERE id=%d ", CAL_TABLE_SCHEDULE, tmp);
+
+ dbret = _cal_db_util_query_exec(query);
+ if (dbret != CAL_DB_OK) {
+ ERR("_cal_db_util_query_exec() failed (%d)", dbret);
+ }
+ tmp_list = g_list_next(tmp_list);
+ }
+ g_list_free(id_list);
+ }
+ return CALENDAR_ERROR_NONE;
}
-#endif
-static int __cal_db_event_exception_get_records(int original_id, GList **out_list)
+static int __cal_db_event_get_deleted_data(int id, int* calendar_book_id, int* created_ver,
+ int* original_event_id, char** recurrence_id)
{
- int ret;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
- GList *list = NULL;
-
- retvm_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid parameter: GList is NULL");
-
- snprintf(query, sizeof(query),
- "SELECT * FROM %s "
- "WHERE original_event_id = %d AND is_deleted = 0 ",
- CAL_TABLE_SCHEDULE,
- original_id);
-
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
-
- calendar_record_h record = NULL;
-
- while (_cal_db_util_stmt_step(stmt) == CAL_DB_ROW)
- {
- ret = calendar_record_create(_calendar_event._uri, &record);
- if (CALENDAR_ERROR_NONE != ret)
- {
- sqlite3_finalize(stmt);
- return ret;
- }
-
- __cal_db_event_get_stmt(stmt, false, record);
+ char query[CAL_DB_SQL_MAX_LEN];
+ sqlite3_stmt *stmt = NULL;
- cal_event_s *event = (cal_event_s *)record;
- if (NULL == record)
- {
- sqlite3_finalize(stmt);
- return ret;
- }
+ snprintf(query, sizeof(query), "SELECT calendar_id, created_ver, "
+ "original_event_id, recurrence_id "
+ "FROM %s WHERE id = %d ",
+ CAL_TABLE_SCHEDULE, id);
- cal_rrule_s *rrule = NULL;
- if (_cal_db_rrule_get_rrule(event->index, &rrule) == CALENDAR_ERROR_NONE )
- {
- _cal_db_rrule_set_rrule_to_event(rrule, record);
- CAL_FREE(rrule);
- }
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt)
+ {
+ ERR("query[%s]", query);
+ ERR("_cal_db_util_query_prepare() Failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ const unsigned char *tmp;
+ if (CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ {
+ *calendar_book_id = sqlite3_column_int(stmt, 0);
+ *created_ver = sqlite3_column_int(stmt, 1);
+ *original_event_id = sqlite3_column_int(stmt, 2);
+ tmp = sqlite3_column_text(stmt, 3);
+ *recurrence_id = SAFE_STRDUP(tmp);
+ }
+ else
+ {
+ sqlite3_finalize(stmt);
+ stmt = NULL;
+ DBG("Failed to get deleted_data: event_id(%d)", id);
+ return CALENDAR_ERROR_DB_RECORD_NOT_FOUND;
+ }
- GList *l = NULL;
- _cal_db_alarm_get_records(event->index, &l);
- if (l) event->alarm_list = l;
+ sqlite3_finalize(stmt);
+ stmt = NULL;
+ return CALENDAR_ERROR_NONE;
+}
- l = NULL;
- _cal_db_attendee_get_records(event->index, &l);
- if (l) event->attendee_list = l;
+static int __cal_db_event_exdate_insert_normal(int event_id, const char* original_exdate, const char* exdate, int **exception_ids, int *exception_len)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ gchar **patterns1 = NULL;
+ gchar **patterns2 = NULL;
+ int len1 = 0, len2 = 0, i = 0, j = 0;
- l = NULL;
- __cal_db_event_exception_get_records(event->index, &l);
- if (l) event->exception_list = l;
+ int input_ver = _cal_db_util_get_next_ver();
+ if (exdate != NULL && strlen(exdate) > 0)
+ {
+ patterns1 = g_strsplit_set(exdate, " ,", -1);
+ len1 = g_strv_length(patterns1);
+ }
+ if (original_exdate != NULL && strlen(original_exdate) > 0)
+ {
+ patterns2 = g_strsplit_set(original_exdate, " ,", -1);
+ len2 = g_strv_length(patterns2);
+ }
- l = NULL;
- _cal_db_extended_get_records(event->index, CALENDAR_RECORD_TYPE_EVENT, &l);
- if (l) event->extended_list = l;
+ int *ids = calloc(len1, sizeof(int));
+ retvm_if (NULL == ids, CALENDAR_ERROR_DB_FAILED, "calloc() is failed");
- event->has_alarm = 0;
- if (event->alarm_list)
+ int exception_count = 0;
+ for(i = 0; i < len1; i++)
+ {
+ bool bFind = false;
+ cal_db_util_error_e dbret = CAL_DB_OK;
+ for(j = 0; j < len2; j++)
{
- if (g_list_length(event->alarm_list) != 0)
+ if (g_strcmp0(patterns1[i], patterns2[j]) == 0)
{
- event->has_alarm = 1;
+ bFind = true;
+ break;
}
}
- event->has_attendee = 0;
- if (event->attendee_list)
+ if (bFind == false)
{
- if (g_list_length(event->attendee_list) != 0)
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ long long int start_utime = 0;
+ char datetime[16] = {0};
+ if (strlen(patterns1[i]) > strlen("YYYYMMDD"))
{
- event->has_attendee = 1;
- }
- }
-
- list = g_list_append(list, record);
- }
- sqlite3_finalize(stmt);
-
- *out_list = list;
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_db_event_exception_convert_gtoh(GList *glist, int original_id, int calendar_id, calendar_list_h *hlist)
-{
- int ret;
- GList *g = NULL;
- calendar_list_h h = NULL;
- calendar_record_h exception = NULL;
-
- if (glist == NULL)
- {
- DBG("No attendee");
- return CALENDAR_ERROR_NO_DATA;
- }
- ret = calendar_list_create(&h);
-
- g = g_list_first(glist);
- while (g)
- {
- exception = (calendar_record_h)g->data;
- if (exception)
- {
- ret = _cal_record_set_int(exception,_calendar_event.original_event_id, original_id);
- ret = _cal_record_set_int(exception,_calendar_event.calendar_book_id, calendar_id);
- ret = calendar_list_add(h, exception);
-
- }
- g = g_list_next(g);
- }
-
- *hlist = h;
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_db_event_exception_delete_with_id(int original_id)
-{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- cal_db_util_error_e dbret = CAL_DB_OK;
+ //DBG("NORMAL instance");
+ int y, mon, d, h, min, s;
+ sscanf(patterns1[i], "%04d%02d%02dT%02d%02d%02dZ",
+ &y, &mon, &d, &h, &min, &s);
+ start_utime = _cal_time_convert_itol(NULL, y, mon, d, h, min, s);
- DBG("delete exception mod with original event id(%d)", original_id);
- snprintf(query, sizeof(query), "DELETE FROM %s WHERE original_event_id=%d ",
- CAL_TABLE_SCHEDULE, original_id);
+ //DBG("(%lld)", start_utime);
+ }
+ else
+ {
+ //DBG("ALLDAY instance");
+ snprintf(datetime, sizeof(datetime),
+ "%s", patterns1[i]);
- dbret = _cal_db_util_query_exec(query);
- if (dbret != CAL_DB_OK) {
- ERR("_cal_db_util_query_exec() failed (%d)", dbret);
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
+ }
+ // insert DB
+ snprintf(query, sizeof(query),
+ "INSERT INTO %s ("
+ "type, "
+ "created_ver, changed_ver, "
+ "calendar_id, "
+ "original_event_id, "
+ "recurrence_id, "
+ "is_deleted, "
+ "dtstart_type, "
+ "dtstart_utime, "
+ "dtstart_datetime, "
+ "dtstart_tzid, "
+ "dtend_type, "
+ "dtend_utime, "
+ "dtend_datetime, "
+ "dtend_tzid"
+ ") SELECT %d,"
+ "created_ver, %d, "
+ "calendar_id, "
+ "%d, "
+ "'%s', "
+ "1, "
+ "dtstart_type, "
+ "%lld, "
+ "'%s', "
+ "dtstart_tzid, "
+ "dtend_type, "
+ "%lld+(dtend_utime-dtstart_utime), "
+ "'%s', "
+ "dtend_tzid "
+ "FROM %s "
+ "WHERE id = %d; ",
+ CAL_TABLE_SCHEDULE, // INSERT INTO
+ CAL_SCH_TYPE_EVENT, // type
+ input_ver, // ver
+ event_id, // original_event_id
+ patterns1[i],
+ start_utime,
+ datetime,
+ start_utime,
+ datetime,
+ CAL_TABLE_SCHEDULE,
+ event_id
+ );
+ dbret = _cal_db_util_query_exec(query);
+ if (dbret != CAL_DB_OK)
+ {
+ DBG("query[%s]", query);
+ ERR("_cal_db_util_query_exec() failed (%d)", dbret);
+ }
+ int event_id = _cal_db_util_last_insert_id();
+ DBG("last id(%d)", event_id);
+ ids[exception_count] = event_id;
+ exception_count++;
}
- }
+ }
+ if (exception_ids) {
+ *exception_ids = ids;
+ } else {
+ free(ids);
+ }
+ if (exception_len) *exception_len = exception_count;
- return CALENDAR_ERROR_NONE;
+ g_strfreev(patterns1);
+ g_strfreev(patterns2);
+ return ret;
}
#include "cal_db_util.h"
#include "cal_db.h"
#include "cal_db_query.h"
+#include "cal_db_extended.h"
static int __cal_db_extended_insert_record( calendar_record_h record, int* id );
static int __cal_db_extended_get_record( int id, calendar_record_h* out_record );
*/
static void __cal_db_extended_get_stmt(sqlite3_stmt *stmt,calendar_record_h record);
static void __cal_db_extended_get_property_stmt(sqlite3_stmt *stmt,
- unsigned int property, int stmt_count, calendar_record_h record);
+ unsigned int property, int stmt_count, calendar_record_h record);
static void __cal_db_extended_get_projection_stmt(sqlite3_stmt *stmt,
- const unsigned int *projection, const int projection_count,
- calendar_record_h record);
+ const unsigned int *projection, const int projection_count,
+ calendar_record_h record);
static void __cal_db_extended_get_stmt(sqlite3_stmt *stmt,calendar_record_h record);
static int __cal_db_extended_update_projection(calendar_record_h record);
cal_db_plugin_cb_s _cal_db_extended_plugin_cb = {
- .is_query_only=false,
- .insert_record=__cal_db_extended_insert_record,
- .get_record=__cal_db_extended_get_record,
- .update_record=__cal_db_extended_update_record,
- .delete_record=__cal_db_extended_delete_record,
- .get_all_records=__cal_db_extended_get_all_records,
- .get_records_with_query=__cal_db_extended_get_records_with_query,
- .insert_records=__cal_db_extended_insert_records,
- .update_records=__cal_db_extended_update_records,
- .delete_records=__cal_db_extended_delete_records,
- .get_count=__cal_db_extended_get_count,
- .get_count_with_query=__cal_db_extended_get_count_with_query,
- .replace_record = __cal_db_extended_replace_record,
- .replace_records = __cal_db_extended_replace_records
+ .is_query_only=false,
+ .insert_record=__cal_db_extended_insert_record,
+ .get_record=__cal_db_extended_get_record,
+ .update_record=__cal_db_extended_update_record,
+ .delete_record=__cal_db_extended_delete_record,
+ .get_all_records=__cal_db_extended_get_all_records,
+ .get_records_with_query=__cal_db_extended_get_records_with_query,
+ .insert_records=__cal_db_extended_insert_records,
+ .update_records=__cal_db_extended_update_records,
+ .delete_records=__cal_db_extended_delete_records,
+ .get_count=__cal_db_extended_get_count,
+ .get_count_with_query=__cal_db_extended_get_count_with_query,
+ .replace_record = __cal_db_extended_replace_record,
+ .replace_records = __cal_db_extended_replace_records
};
static int __cal_db_extended_insert_record( calendar_record_h record, int* id )
{
- int index;
- sqlite3_stmt *stmt;
- char query[CAL_DB_SQL_MAX_LEN];
- cal_extended_s* extended = (cal_extended_s*)(record);
- cal_db_util_error_e dbret;
-
- retv_if(NULL == extended, CALENDAR_ERROR_INVALID_PARAMETER);
-
- sprintf(query,"INSERT INTO %s(record_id, "
- "record_type ,key ,value) "
- "VALUES(%d,%d,?,?)",
- CAL_TABLE_EXTENDED,
- extended->record_id,
- extended->record_type);
+ cal_extended_s* extended = (cal_extended_s*)(record);
+ retv_if(NULL == extended, CALENDAR_ERROR_INVALID_PARAMETER);
+ retvm_if(extended->record_id <= 0, CALENDAR_ERROR_INVALID_PARAMETER, "record_id(%d)", extended->record_id);
+ return _cal_db_extended_insert_record(record, extended->record_id, extended->record_type, id);
+}
- stmt = _cal_db_util_query_prepare(query);
- retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "_cal_db_util_query_prepare() Failed");
+static int __cal_db_extended_get_record( int id, calendar_record_h* out_record )
+{
+ char query[CAL_DB_SQL_MAX_LEN];
+ sqlite3_stmt *stmt = NULL;
+ cal_db_util_error_e dbret = CAL_DB_OK;
+ int ret = 0;
- if (extended->key)
- _cal_db_util_stmt_bind_text(stmt, 1, extended->key);
+ ret = calendar_record_create( _calendar_extended_property._uri ,out_record);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("record create fail");
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
- if (extended->value)
- _cal_db_util_stmt_bind_text(stmt, 2, extended->value);
+ snprintf(query, sizeof(query), "SELECT * FROM %s WHERE id=%d",
+ CAL_TABLE_EXTENDED, id);
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt)
+ {
+ ERR("_cal_db_util_query_prepare() Failed");
+ calendar_record_destroy(*out_record, true);
+ *out_record = NULL;
+ return CALENDAR_ERROR_DB_FAILED;
+ }
- dbret = _cal_db_util_stmt_step(stmt);
- if (CAL_DB_DONE != dbret)
+ dbret = _cal_db_util_stmt_step(stmt);
+ if (CAL_DB_ROW != dbret)
{
- sqlite3_finalize(stmt);
- ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
+ ERR("_cal_db_util_stmt_step() failed(%d)", dbret);
+ sqlite3_finalize(stmt);
+ calendar_record_destroy(*out_record, true);
+ *out_record = NULL;
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
- index = _cal_db_util_last_insert_id();
- sqlite3_finalize(stmt);
+ }
- //_cal_record_set_int(record, _calendar_extended.id,index);
- if (id)
- {
- *id = index;
- }
+ __cal_db_extended_get_stmt(stmt,*out_record);
- return CALENDAR_ERROR_NONE;
+ sqlite3_finalize(stmt);
+ stmt = NULL;
+
+ return CALENDAR_ERROR_NONE;
}
-static int __cal_db_extended_get_record( int id, calendar_record_h* out_record )
+static int __cal_db_extended_update_record( calendar_record_h record )
{
- cal_extended_s *extended=NULL;
- char query[CAL_DB_SQL_MAX_LEN];
- sqlite3_stmt *stmt = NULL;
- cal_db_util_error_e dbret = CAL_DB_OK;
- int ret = 0;
-
- ret = calendar_record_create( _calendar_extended_property._uri ,out_record);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("record create fail");
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
-
- extended = (cal_extended_s*)(*out_record);
-
- snprintf(query, sizeof(query), "SELECT * FROM %s WHERE id=%d",
- CAL_TABLE_EXTENDED, id);
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() Failed");
- calendar_record_destroy(*out_record, true);
- *out_record = NULL;
- return CALENDAR_ERROR_DB_FAILED;
- }
-
- dbret = _cal_db_util_stmt_step(stmt);
- if (CAL_DB_ROW != dbret)
- {
- ERR("_cal_db_util_stmt_step() failed(%d)", dbret);
- sqlite3_finalize(stmt);
- calendar_record_destroy(*out_record, true);
- *out_record = NULL;
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+ cal_extended_s* extended_info = (cal_extended_s*)(record);
+ cal_db_util_error_e dbret = CAL_DB_OK;
- __cal_db_extended_get_stmt(stmt,*out_record);
+ retv_if(NULL == extended_info, CALENDAR_ERROR_INVALID_PARAMETER);
- sqlite3_finalize(stmt);
- stmt = NULL;
-
- return CALENDAR_ERROR_NONE;
-}
+ if (extended_info->common.properties_flags != NULL)
+ {
+ return __cal_db_extended_update_projection(record);
+ }
-static int __cal_db_extended_update_record( calendar_record_h record )
-{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
- cal_extended_s* extended_info = (cal_extended_s*)(record);
- cal_db_util_error_e dbret = CAL_DB_OK;
-
- retv_if(NULL == extended_info, CALENDAR_ERROR_INVALID_PARAMETER);
-
- if (extended_info->common.properties_flags != NULL)
- {
- return __cal_db_extended_update_projection(record);
- }
-
- sprintf(query, "UPDATE %s SET "
- "record_id=%d,"
- "record_type=%d,"
- "key=?,"
- "value=? "
- "WHERE id = %d",
- CAL_TABLE_EXTENDED,
- extended_info->record_id,
- extended_info->record_type,
- extended_info->id);
-
- stmt = _cal_db_util_query_prepare(query);
- retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "cal_q_cal_db_util_query_prepareuery_prepare() Failed");
-
- if (extended_info->key)
- _cal_db_util_stmt_bind_text(stmt, 1, extended_info->key);
-
- if (extended_info->value)
- _cal_db_util_stmt_bind_text(stmt, 2, extended_info->value);
-
- dbret = _cal_db_util_stmt_step(stmt);
- sqlite3_finalize(stmt);
- if (CAL_DB_DONE != dbret)
- {
- ERR("cal_stmt_step() Failed(%d)", dbret);
+ snprintf(query, sizeof(query), "UPDATE %s SET "
+ "record_id=%d,"
+ "record_type=%d,"
+ "key=?,"
+ "value=? "
+ "WHERE id = %d",
+ CAL_TABLE_EXTENDED,
+ extended_info->record_id,
+ extended_info->record_type,
+ extended_info->id);
+
+ stmt = _cal_db_util_query_prepare(query);
+ retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "cal_q_cal_db_util_query_prepareuery_prepare() Failed");
+
+ if (extended_info->key)
+ _cal_db_util_stmt_bind_text(stmt, 1, extended_info->key);
+
+ if (extended_info->value)
+ _cal_db_util_stmt_bind_text(stmt, 2, extended_info->value);
+
+ dbret = _cal_db_util_stmt_step(stmt);
+ sqlite3_finalize(stmt);
+ if (CAL_DB_DONE != dbret)
+ {
+ ERR("cal_stmt_step() Failed(%d)", dbret);
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
+ }
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_extended_delete_record( int id )
{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- cal_db_util_error_e dbret = CAL_DB_OK;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ cal_db_util_error_e dbret = CAL_DB_OK;
- snprintf(query, sizeof(query), "DELETE FROM %s WHERE id = %d",
- CAL_TABLE_EXTENDED, id);
- dbret = _cal_db_util_query_exec(query);
- if(CAL_DB_OK != dbret)
+ snprintf(query, sizeof(query), "DELETE FROM %s WHERE id = %d",
+ CAL_TABLE_EXTENDED, id);
+ dbret = _cal_db_util_query_exec(query);
+ if(CAL_DB_OK != dbret)
{
- ERR("_cal_db_util_query_exec() Failed(%d)", dbret);
+ ERR("_cal_db_util_query_exec() Failed(%d)", dbret);
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
-
- return CALENDAR_ERROR_NONE;
+ }
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_extended_replace_record(calendar_record_h record, int id)
{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
- cal_extended_s* extended_info = (cal_extended_s*)(record);
- cal_db_util_error_e dbret = CAL_DB_OK;
-
- retv_if(NULL == extended_info, CALENDAR_ERROR_INVALID_PARAMETER);
- extended_info->id = id;
-
- if (extended_info->common.properties_flags != NULL)
- {
- return __cal_db_extended_update_projection(record);
- }
-
- sprintf(query, "UPDATE %s SET "
- "record_id=%d,"
- "record_type=%d,"
- "key=?,"
- "value=? "
- "WHERE id = %d",
- CAL_TABLE_EXTENDED,
- extended_info->record_id,
- extended_info->record_type,
- id);
-
- stmt = _cal_db_util_query_prepare(query);
- retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "cal_q_cal_db_util_query_prepareuery_prepare() Failed");
-
- if (extended_info->key)
- _cal_db_util_stmt_bind_text(stmt, 1, extended_info->key);
-
- if (extended_info->value)
- _cal_db_util_stmt_bind_text(stmt, 2, extended_info->value);
-
- dbret = _cal_db_util_stmt_step(stmt);
- sqlite3_finalize(stmt);
- if (CAL_DB_DONE != dbret)
- {
- ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+ cal_extended_s* extended_info = (cal_extended_s*)(record);
+ cal_db_util_error_e dbret = CAL_DB_OK;
+
+ retv_if(NULL == extended_info, CALENDAR_ERROR_INVALID_PARAMETER);
+ extended_info->id = id;
+
+ if (extended_info->common.properties_flags != NULL)
+ {
+ return __cal_db_extended_update_projection(record);
+ }
+
+ snprintf(query, sizeof(query), "UPDATE %s SET "
+ "record_id=%d,"
+ "record_type=%d,"
+ "key=?,"
+ "value=? "
+ "WHERE id = %d",
+ CAL_TABLE_EXTENDED,
+ extended_info->record_id,
+ extended_info->record_type,
+ id);
+
+ stmt = _cal_db_util_query_prepare(query);
+ retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "cal_q_cal_db_util_query_prepareuery_prepare() Failed");
+
+ if (extended_info->key)
+ _cal_db_util_stmt_bind_text(stmt, 1, extended_info->key);
+
+ if (extended_info->value)
+ _cal_db_util_stmt_bind_text(stmt, 2, extended_info->value);
+
+ dbret = _cal_db_util_stmt_step(stmt);
+ sqlite3_finalize(stmt);
+ if (CAL_DB_DONE != dbret)
+ {
+ ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
+ }
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_extended_get_all_records( int offset, int limit, calendar_list_h* out_list )
{
- int ret = CALENDAR_ERROR_NONE;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- char offsetquery[CAL_DB_SQL_MAX_LEN] = {0};
- char limitquery[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
-
- retvm_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- ret = calendar_list_create(out_list);
-
- retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- if (offset > 0)
- {
- snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
- }
- if (limit > 0)
- {
- snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
- }
- snprintf(query, sizeof(query), "SELECT * FROM %s %s %s", CAL_TABLE_EXTENDED,limitquery,offsetquery);
-
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() Failed");
- calendar_list_destroy(*out_list, true);
- *out_list = NULL;
- return CALENDAR_ERROR_DB_FAILED;
- }
-
- while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- calendar_record_h record;
- // stmt -> record
- ret = calendar_record_create(_calendar_extended_property._uri,&record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
- *out_list = NULL;
- sqlite3_finalize(stmt);
- return ret;
- }
- __cal_db_extended_get_stmt(stmt,record);
-
- ret = calendar_list_add(*out_list,record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
- *out_list = NULL;
- calendar_record_destroy(record, true);
- sqlite3_finalize(stmt);
- return ret;
- }
- }
-
- sqlite3_finalize(stmt);
- return CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ char offsetquery[CAL_DB_SQL_MAX_LEN] = {0};
+ char limitquery[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+
+ retvm_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ ret = calendar_list_create(out_list);
+
+ retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ if (offset > 0)
+ {
+ snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
+ }
+ if (limit > 0)
+ {
+ snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
+ }
+ snprintf(query, sizeof(query), "SELECT * FROM %s %s %s", CAL_TABLE_EXTENDED,limitquery,offsetquery);
+
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt)
+ {
+ ERR("_cal_db_util_query_prepare() Failed");
+ calendar_list_destroy(*out_list, true);
+ *out_list = NULL;
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ {
+ calendar_record_h record;
+ // stmt -> record
+ ret = calendar_record_create(_calendar_extended_property._uri,&record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
+ *out_list = NULL;
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+ __cal_db_extended_get_stmt(stmt,record);
+
+ ret = calendar_list_add(*out_list,record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
+ *out_list = NULL;
+ calendar_record_destroy(record, true);
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+ }
+
+ sqlite3_finalize(stmt);
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_extended_get_records_with_query( calendar_query_h query, int offset, int limit, calendar_list_h* out_list )
{
- cal_query_s *que = NULL;
- int ret = CALENDAR_ERROR_NONE;
- char *condition = NULL;
- char *projection = NULL;
- char *order = NULL;
- GSList *bind_text = NULL, *cursor = NULL;
- char strquery[CAL_DB_SQL_MAX_LEN] = {0};
- int len;
- sqlite3_stmt *stmt = NULL;
- int i = 0;
-
- que = (cal_query_s *)query;
-
- // make filter
- if (que->filter)
- {
- ret = _cal_db_query_create_condition(query,
- &condition, &bind_text);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("filter create fail");
- return ret;
- }
- }
-
- // make projection
- ret = _cal_db_query_create_projection(query, &projection);
-
- // query - projection
- if (projection)
- {
- len = snprintf(strquery, sizeof(strquery), "SELECT %s FROM %s", projection, CAL_TABLE_EXTENDED);
- }
- else
- {
- len = snprintf(strquery, sizeof(strquery), "SELECT * FROM %s", CAL_TABLE_EXTENDED);
- }
-
- // query - condition
- if (condition)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " WHERE %s", condition);
- }
-
- // ORDER
- ret = _cal_db_query_create_order(query, &order);
- if (order)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " %s", order);
- }
-
- if (0 < limit)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " LIMIT %d", limit);
- if (0 < offset)
- len += snprintf(strquery+len, sizeof(strquery)-len, " OFFSET %d", offset);
- }
-
- // query
- stmt = _cal_db_util_query_prepare(strquery);
- if (NULL == stmt)
- {
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- CAL_DBG("%s",strquery);
-
- // bind text
- if (bind_text)
- {
- len = g_slist_length(bind_text);
- for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
- {
- _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
- }
- }
-
- //
- ret = calendar_list_create(out_list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- ERR("calendar_list_create() Failed");
- sqlite3_finalize(stmt);
- return ret;
- }
-
- while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- calendar_record_h record;
- // stmt -> record
- ret = calendar_record_create(_calendar_extended_property._uri,&record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
- *out_list = NULL;
-
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
- return ret;
- }
- if (que->projection_count > 0)
- {
- _cal_record_set_projection(record,
- que->projection, que->projection_count, que->property_count);
-
- __cal_db_extended_get_projection_stmt(stmt,
- que->projection, que->projection_count,
- record);
- }
- else
- {
- __cal_db_extended_get_stmt(stmt,record);
- }
-
- ret = calendar_list_add(*out_list,record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
- *out_list = NULL;
- calendar_record_destroy(record, true);
-
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
- return ret;
- }
- }
-
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
-
- return CALENDAR_ERROR_NONE;
+ cal_query_s *que = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ char *condition = NULL;
+ char *projection = NULL;
+ char *order = NULL;
+ GSList *bind_text = NULL, *cursor = NULL;
+ char *query_str = NULL;
+ sqlite3_stmt *stmt = NULL;
+ int i = 0;
+
+ que = (cal_query_s *)query;
+
+ // make filter
+ if (que->filter)
+ {
+ ret = _cal_db_query_create_condition(query, &condition, &bind_text);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("filter create fail");
+ return ret;
+ }
+ }
+
+ // make projection
+ ret = _cal_db_query_create_projection(query, &projection);
+
+ // query - projection
+ if (projection)
+ {
+ _cal_db_append_string(&query_str, "SELECT");
+ _cal_db_append_string(&query_str, projection);
+ _cal_db_append_string(&query_str, "FROM");
+ _cal_db_append_string(&query_str, CAL_TABLE_EXTENDED);
+ CAL_FREE(projection);
+ }
+ else
+ {
+ _cal_db_append_string(&query_str, "SELECT * FROM");
+ _cal_db_append_string(&query_str, CAL_TABLE_EXTENDED);
+ }
+
+ // query - condition
+ if (condition)
+ {
+ _cal_db_append_string(&query_str, "WHERE");
+ _cal_db_append_string(&query_str, condition);
+ CAL_FREE(condition);
+ }
+
+ // ORDER
+ ret = _cal_db_query_create_order(query, condition, &order);
+ if (order)
+ {
+ _cal_db_append_string(&query_str, order);
+ CAL_FREE(order);
+ }
+
+ char buf[32] = {0};
+ if (0 < limit)
+ {
+ snprintf(buf, sizeof(buf), "LIMIT %d", limit);
+ _cal_db_append_string(&query_str, buf);
+ if (0 < offset)
+ {
+ snprintf(buf, sizeof(buf), "OFFSET %d", offset);
+ _cal_db_append_string(&query_str, buf);
+ }
+ }
+
+ // query
+ stmt = _cal_db_util_query_prepare(query_str);
+ if (NULL == stmt)
+ {
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ ERR("_cal_db_util_query_prepare() Failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ CAL_DBG("%s",query_str);
+
+ // bind text
+ if (bind_text)
+ {
+ for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
+ {
+ _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
+ }
+ }
+
+ //
+ ret = calendar_list_create(out_list);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ ERR("calendar_list_create() Failed");
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ {
+ calendar_record_h record;
+ // stmt -> record
+ ret = calendar_record_create(_calendar_extended_property._uri,&record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
+ *out_list = NULL;
+
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+ if (que->projection_count > 0)
+ {
+ _cal_record_set_projection(record,
+ que->projection, que->projection_count, que->property_count);
+
+ __cal_db_extended_get_projection_stmt(stmt,
+ que->projection, que->projection_count,
+ record);
+ }
+ else
+ {
+ __cal_db_extended_get_stmt(stmt,record);
+ }
+
+ ret = calendar_list_add(*out_list,record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
+ *out_list = NULL;
+ calendar_record_destroy(record, true);
+
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+ }
+
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ sqlite3_finalize(stmt);
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_extended_insert_records(const calendar_list_h list, int** ids)
{
- calendar_record_h record;
- int ret = 0;
- int count = 0;
- int i=0;
- int *id = NULL;
-
- ret = calendar_list_get_count(list, &count);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("list get error");
- return ret;
- }
-
- id = calloc(1, sizeof(int)*count);
-
- retvm_if(NULL == id, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc fail");
-
- ret = calendar_list_first(list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("list first error");
- CAL_FREE(id);
- return ret;
- }
- do
- {
- if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
- {
- if( __cal_db_extended_insert_record(record, &id[i]) != CALENDAR_ERROR_NONE)
- {
- ERR("db insert error");
- CAL_FREE(id);
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- i++;
- } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
-
- if(ids)
- {
- *ids = id;
- }
- else
- {
- CAL_FREE(id);
- }
-
- return CALENDAR_ERROR_NONE;
+ calendar_record_h record;
+ int ret = 0;
+ int count = 0;
+ int i=0;
+ int *id = NULL;
+
+ ret = calendar_list_get_count(list, &count);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("list get error");
+ return ret;
+ }
+
+ id = calloc(1, sizeof(int)*count);
+
+ retvm_if(NULL == id, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc fail");
+
+ ret = calendar_list_first(list);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("list first error");
+ CAL_FREE(id);
+ return ret;
+ }
+ do
+ {
+ if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
+ {
+ if( __cal_db_extended_insert_record(record, &id[i]) != CALENDAR_ERROR_NONE)
+ {
+ ERR("db insert error");
+ CAL_FREE(id);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ i++;
+ } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+
+ if(ids)
+ {
+ *ids = id;
+ }
+ else
+ {
+ CAL_FREE(id);
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_extended_update_records(const calendar_list_h list)
{
- calendar_record_h record;
- int ret = 0;
-
- ret = calendar_list_first(list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("list first error");
- return ret;
- }
- do
- {
- if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
- {
- if( __cal_db_extended_update_record(record) != CALENDAR_ERROR_NONE)
- {
- ERR("db insert error");
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
-
- return CALENDAR_ERROR_NONE;
+ calendar_record_h record;
+ int ret = 0;
+
+ ret = calendar_list_first(list);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("list first error");
+ return ret;
+ }
+ do
+ {
+ if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
+ {
+ if( __cal_db_extended_update_record(record) != CALENDAR_ERROR_NONE)
+ {
+ ERR("db insert error");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_extended_delete_records(int ids[], int count)
{
- int i=0;
- for(i=0;i<count;i++)
- {
- if (__cal_db_extended_delete_record(ids[i]) != CALENDAR_ERROR_NONE)
- {
- ERR("delete failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- return CALENDAR_ERROR_NONE;
+ int i=0;
+ for(i=0;i<count;i++)
+ {
+ if (__cal_db_extended_delete_record(ids[i]) != CALENDAR_ERROR_NONE)
+ {
+ ERR("delete failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_extended_replace_records(const calendar_list_h list, int ids[], int count)
{
- calendar_record_h record;
- int i;
- int ret = 0;
-
- if (NULL == list)
- {
- ERR("Invalid argument: list is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- ret = calendar_list_first(list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("list first error");
- return ret;
- }
-
- for (i = 0; i < count; i++)
- {
- if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
- {
- if( __cal_db_extended_replace_record(record, ids[i]) != CALENDAR_ERROR_NONE)
- {
- ERR("db insert error");
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- if (CALENDAR_ERROR_NO_DATA != calendar_list_next(list))
- {
- break;
- }
- }
-
- return CALENDAR_ERROR_NONE;
+ calendar_record_h record;
+ int i;
+ int ret = 0;
+
+ if (NULL == list)
+ {
+ ERR("Invalid argument: list is NULL");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = calendar_list_first(list);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("list first error");
+ return ret;
+ }
+
+ for (i = 0; i < count; i++)
+ {
+ if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
+ {
+ if( __cal_db_extended_replace_record(record, ids[i]) != CALENDAR_ERROR_NONE)
+ {
+ ERR("db insert error");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ if (CALENDAR_ERROR_NO_DATA != calendar_list_next(list))
+ {
+ break;
+ }
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_extended_get_count(int *out_count)
{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- int count = 0;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ int count = 0;
int ret;
- retvm_if(NULL == out_count, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == out_count, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- snprintf(query, sizeof(query), "SELECT count(*) FROM %s ", CAL_TABLE_EXTENDED);
+ snprintf(query, sizeof(query), "SELECT count(*) FROM %s ", CAL_TABLE_EXTENDED);
- ret = _cal_db_util_query_get_first_int_result(query, NULL, &count);
+ ret = _cal_db_util_query_get_first_int_result(query, NULL, &count);
if (CALENDAR_ERROR_NONE != ret)
{
ERR("_cal_db_util_query_get_first_int_result() failed");
return ret;
}
- CAL_DBG("%s=%d",query,count);
+ CAL_DBG("%s=%d",query,count);
- *out_count = count;
- return CALENDAR_ERROR_NONE;
+ *out_count = count;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_extended_get_count_with_query(calendar_query_h query, int *out_count)
{
- cal_query_s *que = NULL;
- int ret = CALENDAR_ERROR_NONE;
- char *condition = NULL;
- char strquery[CAL_DB_SQL_MAX_LEN] = {0};
- int len;
- char *table_name;
- int count = 0;
- GSList *bind_text = NULL;
-
- que = (cal_query_s *)query;
-
- if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_EXTENDED))
- {
- table_name = SAFE_STRDUP(CAL_TABLE_EXTENDED);
- }
- else
- {
- ERR("uri(%s) not support get records with query",que->view_uri);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- // make filter
- if (que->filter)
- {
- ret = _cal_db_query_create_condition(query, &condition, &bind_text);
- if (ret != CALENDAR_ERROR_NONE)
- {
- CAL_FREE(table_name);
- ERR("filter create fail");
- return ret;
- }
- }
-
- // query - select from
-
- len = snprintf(strquery, sizeof(strquery), "SELECT count(*) FROM %s", table_name);
- CAL_FREE(table_name);
-
- // query - condition
- if (condition)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " WHERE %s", condition);
- }
-
- // query
- ret = _cal_db_util_query_get_first_int_result(strquery, NULL, &count);
+ cal_query_s *que = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ char *condition = NULL;
+ char *query_str = NULL;
+ char *table_name;
+ int count = 0;
+ GSList *bind_text = NULL;
+
+ que = (cal_query_s *)query;
+
+ if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_EXTENDED))
+ {
+ table_name = SAFE_STRDUP(CAL_TABLE_EXTENDED);
+ }
+ else
+ {
+ ERR("uri(%s) not support get records with query",que->view_uri);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ // make filter
+ if (que->filter)
+ {
+ ret = _cal_db_query_create_condition(query, &condition, &bind_text);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ CAL_FREE(table_name);
+ ERR("filter create fail");
+ return ret;
+ }
+ }
+
+ // query - select from
+ _cal_db_append_string(&query_str, "SELECT count(*) FROM");
+ _cal_db_append_string(&query_str, table_name);
+ CAL_FREE(table_name);
+
+ // query - condition
+ if (condition)
+ {
+ _cal_db_append_string(&query_str, "WHERE");
+ _cal_db_append_string(&query_str, condition);
+ CAL_FREE(condition);
+ }
+
+ // query
+ ret = _cal_db_util_query_get_first_int_result(query_str, NULL, &count);
if (CALENDAR_ERROR_NONE != ret)
{
ERR("_cal_db_util_query_get_first_int_result() failed");
if (bind_text)
{
- g_slist_free(bind_text);
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
}
- CAL_FREE(condition);
+ CAL_FREE(query_str);
return ret;
}
- CAL_DBG("%s=%d",strquery,count);
+ CAL_DBG("%s=%d",query_str,count);
- *out_count = count;
+ *out_count = count;
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- return CALENDAR_ERROR_NONE;
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ return CALENDAR_ERROR_NONE;
}
static void __cal_db_extended_get_stmt(sqlite3_stmt *stmt,calendar_record_h record)
{
- cal_extended_s* extended = (cal_extended_s*)(record);
- int count = 0;
- const unsigned char *temp;
+ cal_extended_s* extended = (cal_extended_s*)(record);
+ int count = 0;
+ const unsigned char *temp;
- extended->id = sqlite3_column_int(stmt, count++);
- extended->record_id = sqlite3_column_int(stmt, count++);
- extended->record_type = sqlite3_column_int(stmt, count++);
+ extended->id = sqlite3_column_int(stmt, count++);
+ extended->record_id = sqlite3_column_int(stmt, count++);
+ extended->record_type = sqlite3_column_int(stmt, count++);
- temp = sqlite3_column_text(stmt, count++);
- extended->key = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ extended->key = SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- extended->value = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ extended->value = SAFE_STRDUP(temp);
}
static void __cal_db_extended_get_property_stmt(sqlite3_stmt *stmt,
- unsigned int property, int stmt_count, calendar_record_h record)
+ unsigned int property, int stmt_count, calendar_record_h record)
{
- cal_extended_s* extended = (cal_extended_s*)(record);
- const unsigned char *temp;
-
- switch(property)
- {
- case CAL_PROPERTY_EXTENDED_ID:
- extended->id = sqlite3_column_int(stmt, stmt_count);
- break;
- case CAL_PROPERTY_EXTENDED_RECORD_ID:
- extended->record_id = sqlite3_column_int(stmt, stmt_count);
- break;
- case CAL_PROPERTY_EXTENDED_RECORD_TYPE:
- extended->record_type = sqlite3_column_int(stmt, stmt_count);
- break;
- case CAL_PROPERTY_EXTENDED_KEY:
- temp = sqlite3_column_text(stmt, stmt_count);
- extended->key = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_EXTENDED_VALUE:
- temp = sqlite3_column_text(stmt, stmt_count);
- extended->value = SAFE_STRDUP(temp);
- break;
- default:
- sqlite3_column_int(stmt, stmt_count);
- break;
- }
-
- return;
+ cal_extended_s* extended = (cal_extended_s*)(record);
+ const unsigned char *temp;
+
+ switch(property)
+ {
+ case CAL_PROPERTY_EXTENDED_ID:
+ extended->id = sqlite3_column_int(stmt, stmt_count);
+ break;
+ case CAL_PROPERTY_EXTENDED_RECORD_ID:
+ extended->record_id = sqlite3_column_int(stmt, stmt_count);
+ break;
+ case CAL_PROPERTY_EXTENDED_RECORD_TYPE:
+ extended->record_type = sqlite3_column_int(stmt, stmt_count);
+ break;
+ case CAL_PROPERTY_EXTENDED_KEY:
+ temp = sqlite3_column_text(stmt, stmt_count);
+ extended->key = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_EXTENDED_VALUE:
+ temp = sqlite3_column_text(stmt, stmt_count);
+ extended->value = SAFE_STRDUP(temp);
+ break;
+ default:
+ sqlite3_column_int(stmt, stmt_count);
+ break;
+ }
+
+ return;
}
static void __cal_db_extended_get_projection_stmt(sqlite3_stmt *stmt,
- const unsigned int *projection, const int projection_count,
- calendar_record_h record)
+ const unsigned int *projection, const int projection_count,
+ calendar_record_h record)
{
- int i=0;
+ int i=0;
- for(i=0;i<projection_count;i++)
- {
- __cal_db_extended_get_property_stmt(stmt,projection[i],i,record);
- }
+ for(i=0;i<projection_count;i++)
+ {
+ __cal_db_extended_get_property_stmt(stmt,projection[i],i,record);
+ }
}
static int __cal_db_extended_update_projection(calendar_record_h record)
{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
- cal_extended_s* extended = (cal_extended_s*)(record);
- cal_db_util_error_e dbret = CAL_DB_OK;
- int ret = CALENDAR_ERROR_NONE;
- char* set = NULL;
- GSList *bind_text = NULL;
- int len;
- GSList *cursor = NULL;
-
- ret = _cal_db_query_create_projection_update_set(record,&set,&bind_text);
- retv_if(CALENDAR_ERROR_NONE != ret, ret);
-
- snprintf(query, sizeof(query), "UPDATE %s SET %s "
- "WHERE id = %d",
- CAL_TABLE_EXTENDED,set,
- extended->id);
-
- stmt = _cal_db_util_query_prepare(query);
- retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "_cal_db_util_query_prepare() Failed");
-
- // bind
- if (bind_text)
- {
- int i = 0;
- len = g_slist_length(bind_text);
- for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
- {
- _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
- }
- }
-
- dbret = _cal_db_util_stmt_step(stmt);
- if (CAL_DB_DONE != dbret)
- {
- sqlite3_finalize(stmt);
- ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
-
- CAL_FREE(set);
- if(bind_text)
- {
- for (cursor=bind_text; cursor;cursor=cursor->next)
- {
- CAL_FREE(cursor->data);
- }
- g_slist_free(bind_text);
- }
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+ cal_extended_s* extended = (cal_extended_s*)(record);
+ cal_db_util_error_e dbret = CAL_DB_OK;
+ int ret = CALENDAR_ERROR_NONE;
+ char* set = NULL;
+ GSList *bind_text = NULL;
+ GSList *cursor = NULL;
+
+ ret = _cal_db_query_create_projection_update_set(record,&set,&bind_text);
+ retv_if(CALENDAR_ERROR_NONE != ret, ret);
+
+ snprintf(query, sizeof(query), "UPDATE %s SET %s "
+ "WHERE id = %d",
+ CAL_TABLE_EXTENDED,set,
+ extended->id);
+
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt) {
+ ERR("_cal_db_util_query_prepare() Failed");
+ CAL_FREE(set);
+ if(bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ // bind
+ if (bind_text)
+ {
+ int i = 0;
+ for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
+ {
+ _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
+ }
+ }
+
+ dbret = _cal_db_util_stmt_step(stmt);
+ if (CAL_DB_DONE != dbret)
+ {
+ sqlite3_finalize(stmt);
+ ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
+
+ CAL_FREE(set);
+ if(bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
+ }
- sqlite3_finalize(stmt);
+ sqlite3_finalize(stmt);
- CAL_FREE(set);
- if(bind_text)
- {
- for (cursor=bind_text; cursor;cursor=cursor->next)
- {
- CAL_FREE(cursor->data);
- }
- g_slist_free(bind_text);
- }
+ CAL_FREE(set);
+ if(bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
#include "cal_db_util.h"
#include "cal_db.h"
#include "cal_db_query.h"
+#include "cal_access_control.h"
-static int __cal_db_instance_allday_insert_record(calendar_record_h record, int* id);
//static int __cal_db_instance_allday_get_record(int id, calendar_record_h* out_record);
//static int __cal_db_instance_allday_update_record(calendar_record_h record);
static int __cal_db_instance_allday_delete_record(int id);
*/
static void __cal_db_instance_allday_get_stmt(sqlite3_stmt *stmt,calendar_record_h record);
static void __cal_db_instance_allday_get_property_stmt(sqlite3_stmt *stmt,
- unsigned int property, int *stmt_count, calendar_record_h record);
+ unsigned int property, int *stmt_count, calendar_record_h record);
static void __cal_db_instance_allday_get_projection_stmt(sqlite3_stmt *stmt,
- const unsigned int *projection, const int projection_count,
- calendar_record_h record);
+ const unsigned int *projection, const int projection_count,
+ calendar_record_h record);
cal_db_plugin_cb_s _cal_db_instance_allday_plugin_cb = {
.is_query_only = false,
- .insert_record=__cal_db_instance_allday_insert_record,
+ .insert_record=NULL,
.get_record=NULL,
.update_record=NULL,
.delete_record=__cal_db_instance_allday_delete_record,
.insert_records=NULL,
.update_records=NULL,
.delete_records=NULL,
- .get_count=__cal_db_instance_allday_get_count,
- .get_count_with_query=__cal_db_instance_allday_get_count_with_query,
- .replace_record=NULL,
- .replace_records=NULL
+ .get_count=__cal_db_instance_allday_get_count,
+ .get_count_with_query=__cal_db_instance_allday_get_count_with_query,
+ .replace_record=NULL,
+ .replace_records=NULL
};
-static int __cal_db_instance_allday_insert_record(calendar_record_h record, int* id)
-{
- int index = -1;
- char query[CAL_DB_SQL_MAX_LEN];
- sqlite3_stmt *stmt;
- cal_instance_allday_s *allday = NULL;
- cal_db_util_error_e dbret = CAL_DB_OK;
-
- allday = (cal_instance_allday_s *)(record);
- retvm_if(NULL == allday, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid argument: cal_instance_allday_s is NULL");
-
- snprintf(query, sizeof(query),
- "INSERT INTO %s ("
- "event_id, "
- "dtstart_datetime, dtend_datetime"
- ") VALUES ( "
- "%d, "
- "%04d%02d%02d, %04d%02d%02d) ",
- CAL_TABLE_ALLDAY_INSTANCE,
- allday->event_id,
- allday->dtstart_year, allday->dtstart_month, allday->dtstart_mday,
- allday->dtend_year, allday->dtend_month, allday->dtend_mday);
-
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- DBG("query[%s]", query);
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
-
- dbret = _cal_db_util_stmt_step(stmt);
- if (CAL_DB_DONE != dbret)
- {
- ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
- sqlite3_finalize(stmt);
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
-
- index = _cal_db_util_last_insert_id();
- sqlite3_finalize(stmt);
-
- //calendar_record_set_int(record, _calendar_instance_allday.id, index);
- if (id)
- {
- *id = index;
- }
-
- return CALENDAR_ERROR_NONE;
-}
-
static int __cal_db_instance_allday_delete_record(int id)
{
char query[CAL_DB_SQL_MAX_LEN] = {0};
- cal_db_util_error_e dbret = CAL_DB_OK;
+ cal_db_util_error_e dbret = CAL_DB_OK;
retvm_if(id < 0, CALENDAR_ERROR_INVALID_PARAMETER,
"Invalid argument: id(%d) < 0", id);
return CALENDAR_ERROR_DB_FAILED;
}
}
-
return CALENDAR_ERROR_NONE;
}
static int __cal_db_instance_allday_get_all_records(int offset, int limit, calendar_list_h* out_list)
{
- int ret = CALENDAR_ERROR_NONE;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- char offsetquery[CAL_DB_SQL_MAX_LEN] = {0};
- char limitquery[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
-
- retvm_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- ret = calendar_list_create(out_list);
- retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- if (offset > 0)
- {
- snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
- }
- if (limit > 0)
- {
- snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
- }
- snprintf(query, sizeof(query),
- "SELECT * FROM %s %s %s",
- CAL_TABLE_ALLDAY_INSTANCE, limitquery, offsetquery);
-
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() Failed");
- calendar_list_destroy(*out_list, true);
+ int ret = CALENDAR_ERROR_NONE;
+ char offsetquery[CAL_DB_SQL_MAX_LEN] = {0};
+ char limitquery[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+
+ retvm_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ ret = calendar_list_create(out_list);
+ retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ if (offset > 0)
+ {
+ snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
+ }
+ if (limit > 0)
+ {
+ snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
+ }
+
+ char *query_str = NULL;
+ _cal_db_append_string(&query_str, "SELECT * FROM");
+ _cal_db_append_string(&query_str, CAL_VIEW_TABLE_ALLDAY_INSTANCE);
+ _cal_db_append_string(&query_str, limitquery);
+ _cal_db_append_string(&query_str, offsetquery);
+
+ stmt = _cal_db_util_query_prepare(query_str);
+ if (NULL == stmt)
+ {
+ ERR("_cal_db_util_query_prepare() Failed");
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- return CALENDAR_ERROR_DB_FAILED;
- }
-
- while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- calendar_record_h record;
- // stmt -> record
- ret = calendar_record_create(_calendar_instance_allday._uri,&record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
+ CAL_FREE(query_str);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ {
+ calendar_record_h record;
+ // stmt -> record
+ ret = calendar_record_create(_calendar_instance_localtime_calendar_book._uri,&record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- sqlite3_finalize(stmt);
- return ret;
- }
- __cal_db_instance_allday_get_stmt(stmt,record);
-
- ret = calendar_list_add(*out_list,record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+
+ __cal_db_instance_allday_get_stmt(stmt, record);
+
+ ret = calendar_list_add(*out_list, record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- calendar_record_destroy(record, true);
- sqlite3_finalize(stmt);
- return ret;
- }
- }
- sqlite3_finalize(stmt);
+ calendar_record_destroy(record, true);
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ }
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
return CALENDAR_ERROR_NONE;
}
static int __cal_db_instance_allday_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* out_list)
{
- cal_query_s *que = NULL;
- int ret = CALENDAR_ERROR_NONE;
- char *condition = NULL;
- char *projection = NULL;
- char *order = NULL;
- GSList *bind_text = NULL, *cursor = NULL;
- char strquery[CAL_DB_SQL_MAX_LEN] = {0};
- int len;
- sqlite3_stmt *stmt = NULL;
- int i = 0;
- char *table_name;
-
- que = (cal_query_s *)query;
-
- if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_ALLDAY_CALENDAR))
- {
- table_name = SAFE_STRDUP(CAL_VIEW_TABLE_ALLDAY_INSTANCE);
- }
- else
- {
- ERR("uri(%s) not support get records with query",que->view_uri);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- //table_name = SAFE_STRDUP(CAL_TABLE_ALLDAY_INSTANCE);
- }
-
- // make filter
- if (que->filter)
- {
- ret = _cal_db_query_create_condition(query,
- &condition, &bind_text);
- if (ret != CALENDAR_ERROR_NONE)
- {
- CAL_FREE(table_name);
- ERR("filter create fail");
- return ret;
- }
- }
-
- // make projection
- ret = _cal_db_query_create_projection(query, &projection);
-
- // query - projection
- if (projection)
- {
- len = snprintf(strquery, sizeof(strquery), "SELECT %s FROM %s", projection, table_name);
- }
- else
- {
- len = snprintf(strquery, sizeof(strquery), "SELECT * FROM %s", table_name);
- }
-
- CAL_FREE(table_name);
-
- // query - condition
- if (condition)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " WHERE %s", condition);
- }
-
- // ORDER
- ret = _cal_db_query_create_order(query, &order);
- if (order)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " %s", order);
- }
-
- if (0 < limit)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " LIMIT %d", limit);
- if (0 < offset)
- len += snprintf(strquery+len, sizeof(strquery)-len, " OFFSET %d", offset);
- }
-
- // query
- stmt = _cal_db_util_query_prepare(strquery);
- if (NULL == stmt)
- {
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- CAL_DBG("%s",strquery);
-
- // bind text
- if (bind_text)
- {
- len = g_slist_length(bind_text);
- for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
- {
- _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
- }
- }
-
- //
- ret = calendar_list_create(out_list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- ERR("calendar_list_create() Failed");
- sqlite3_finalize(stmt);
- return ret;
- }
-
- while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- calendar_record_h record;
- // stmt -> record
- ret = calendar_record_create(que->view_uri,&record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
+ cal_query_s *que = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ char *condition = NULL;
+ char *projection = NULL;
+ GSList *bind_text = NULL, *cursor = NULL;
+ sqlite3_stmt *stmt = NULL;
+ int i = 0;
+ char *table_name;
+
+ que = (cal_query_s *)query;
+
+ if (0 == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_LOCALTIME_CALENDAR))
+ {
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_ALLDAY_INSTANCE);
+ }
+ else if (0 == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_LOCALTIME_CALENDAR_EXTENDED) )
+ {
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_ALLDAY_INSTANCE_EXTENDED);
+ }
+ else
+ {
+ ERR("uri(%s) not support get records with query",que->view_uri);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ //table_name = SAFE_STRDUP(CAL_TABLE_ALLDAY_INSTANCE);
+ }
+
+ // make filter
+ if (que->filter)
+ {
+ ret = _cal_db_query_create_condition(query, &condition, &bind_text);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ CAL_FREE(table_name);
+ ERR("filter create fail");
+ return ret;
+ }
+ }
+
+ // make projection
+ ret = _cal_db_query_create_projection(query, &projection);
+
+ char *query_str = NULL;
+ // query - projection
+ if (projection)
+ {
+ _cal_db_append_string(&query_str, "SELECT");
+ _cal_db_append_string(&query_str, projection);
+ _cal_db_append_string(&query_str, "FROM");
+ _cal_db_append_string(&query_str, table_name);
+ CAL_FREE(projection);
+ }
+ else
+ {
+ _cal_db_append_string(&query_str, "SELECT * FROM");
+ _cal_db_append_string(&query_str, table_name);
+ }
+ CAL_FREE(table_name);
+
+ // query - condition
+ if (condition)
+ {
+ _cal_db_append_string(&query_str, "WHERE (");
+ _cal_db_append_string(&query_str, condition);
+ _cal_db_append_string(&query_str, ")");
+ }
+
+ // ORDER
+ char *order = NULL;
+ ret = _cal_db_query_create_order(query, condition, &order);
+ if (order)
+ {
+ _cal_db_append_string(&query_str, order);
+ CAL_FREE(order);
+ }
+ CAL_FREE(condition);
+
+ // limit, offset
+ char buf[32] = {0};
+ if (limit > 0)
+ {
+ snprintf(buf, sizeof(buf), "LIMIT %d", limit);
+ _cal_db_append_string(&query_str, buf);
+
+ if (offset > 0)
+ {
+ snprintf(buf, sizeof(buf), "OFFSET %d", offset);
+ _cal_db_append_string(&query_str, buf);
+ }
+ }
+
+ // query
+ stmt = _cal_db_util_query_prepare(query_str);
+ if (NULL == stmt)
+ {
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ ERR("_cal_db_util_query_prepare() Failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ CAL_DBG("%s",query_str);
+
+ // bind text
+ if (bind_text)
+ {
+ g_slist_length(bind_text);
+ for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
+ {
+ _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
+ }
+ }
+
+ //
+ ret = calendar_list_create(out_list);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ ERR("calendar_list_create() Failed");
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ {
+ calendar_record_h record;
+ // stmt -> record
+ ret = calendar_record_create(que->view_uri,&record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
- return ret;
- }
- if (que->projection_count > 0)
- {
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ if (que->projection_count > 0)
+ {
_cal_record_set_projection(record,
que->projection, que->projection_count, que->property_count);
- __cal_db_instance_allday_get_projection_stmt(stmt,
+ __cal_db_instance_allday_get_projection_stmt(stmt,
que->projection, que->projection_count,
- record);
- }
- else
- {
- __cal_db_instance_allday_get_stmt(stmt,record);
- }
-
- ret = calendar_list_add(*out_list,record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
+ record);
+ }
+ else
+ {
+ __cal_db_instance_allday_get_stmt(stmt,record);
+ }
+
+ ret = calendar_list_add(*out_list,record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- calendar_record_destroy(record, true);
-
- if (bind_text)
- {
- for (cursor=bind_text;cursor;cursor=cursor->next)
- {
- CAL_FREE(cursor->data);
- }
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
- return ret;
- }
- }
-
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
-
- sqlite3_finalize(stmt);
-
- return CALENDAR_ERROR_NONE;
+ calendar_record_destroy(record, true);
+
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ }
+
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_instance_allday_get_count(int *out_count)
{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- int count = 0;
- int ret;
-
- retvm_if(NULL == out_count, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == out_count, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- snprintf(query, sizeof(query), "SELECT count(*) FROM %s ", CAL_TABLE_ALLDAY_INSTANCE);
+ char *query_str = NULL;
+ _cal_db_append_string(&query_str, "SELECT count(*) FROM");
+ _cal_db_append_string(&query_str, CAL_TABLE_ALLDAY_INSTANCE);
- ret = _cal_db_util_query_get_first_int_result(query, NULL, &count);
+ int ret = 0;
+ int count = 0;
+ ret = _cal_db_util_query_get_first_int_result(query_str, NULL, &count);
if (CALENDAR_ERROR_NONE != ret)
{
ERR("_cal_db_util_query_get_first_int_result() failed");
+ CAL_FREE(query_str);
return ret;
}
- CAL_DBG("%s=%d",query,count);
+ CAL_DBG("count(%d) str[%s]", count, query_str);
+ CAL_FREE(query_str);
- *out_count = count;
- return CALENDAR_ERROR_NONE;
+ *out_count = count;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_instance_allday_get_count_with_query(calendar_query_h query, int *out_count)
{
- cal_query_s *que = NULL;
- int ret = CALENDAR_ERROR_NONE;
- char *condition = NULL;
- char strquery[CAL_DB_SQL_MAX_LEN] = {0};
- int len;
- char *table_name;
- int count = 0;
- GSList *bind_text = NULL;
-
- que = (cal_query_s *)query;
-
- if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_ALLDAY_CALENDAR))
- {
- table_name = SAFE_STRDUP(CAL_VIEW_TABLE_ALLDAY_INSTANCE);
- }
- else
- {
- ERR("uri(%s) not support get records with query",que->view_uri);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- //table_name = SAFE_STRDUP(CAL_TABLE_ALLDAY_INSTANCE);
- }
-
- // make filter
- if (que->filter)
- {
- ret = _cal_db_query_create_condition(query, &condition, &bind_text);
- if (ret != CALENDAR_ERROR_NONE)
- {
- CAL_FREE(table_name);
- ERR("filter create fail");
- return ret;
- }
- }
-
- // query - select from
-
- len = snprintf(strquery, sizeof(strquery), "SELECT count(*) FROM %s", table_name);
-
- CAL_FREE(table_name);
-
- // query - condition
- if (condition)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " WHERE %s", condition);
- }
-
- // query
- ret = _cal_db_util_query_get_first_int_result(strquery, bind_text, &count);
+ cal_query_s *que = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ char *condition = NULL;
+ char *table_name;
+ int count = 0;
+ GSList *bind_text = NULL;
+
+ que = (cal_query_s *)query;
+
+ if (0 == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_LOCALTIME_CALENDAR))
+ {
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_ALLDAY_INSTANCE);
+ }
+ else if (0 == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_LOCALTIME_CALENDAR_EXTENDED) )
+ {
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_ALLDAY_INSTANCE_EXTENDED);
+ }
+ else
+ {
+ ERR("uri(%s) not support get records with query",que->view_uri);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ //table_name = SAFE_STRDUP(CAL_TABLE_ALLDAY_INSTANCE);
+ }
+
+ // make filter
+ if (que->filter)
+ {
+ ret = _cal_db_query_create_condition(query, &condition, &bind_text);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ CAL_FREE(table_name);
+ ERR("filter create fail");
+ return ret;
+ }
+ }
+
+ char *query_str = NULL;
+ // query - select from
+ _cal_db_append_string(&query_str, "SELECT count(*) FROM");
+ _cal_db_append_string(&query_str, table_name);
+ CAL_FREE(table_name);
+
+ // query - condition
+ if (condition)
+ {
+ _cal_db_append_string(&query_str, "WHERE (");
+ _cal_db_append_string(&query_str, condition);
+ _cal_db_append_string(&query_str, ")");
+ CAL_FREE(condition);
+ }
+
+ // query
+ ret = _cal_db_util_query_get_first_int_result(query_str, bind_text, &count);
if (CALENDAR_ERROR_NONE != ret)
{
ERR("_cal_db_util_query_get_first_int_result() failed");
if (bind_text)
{
- g_slist_free(bind_text);
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
}
- CAL_FREE(condition);
+ CAL_FREE(query_str);
return ret;
}
- CAL_DBG("%s=%d",strquery,count);
+ CAL_DBG("count(%d) str[%s]", count, query_str);
- if (out_count) *out_count = count;
+ if (out_count) *out_count = count;
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- return CALENDAR_ERROR_NONE;
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ return CALENDAR_ERROR_NONE;
}
static void __cal_db_instance_allday_get_stmt(sqlite3_stmt *stmt,calendar_record_h record)
{
- cal_instance_allday_s* instance = (cal_instance_allday_s*)(record);
- const unsigned char *temp;
- char *dtstart_datetime;
- char *dtend_datetime;
- char buf[8] = {0};
- int count = 0;
-
- instance->event_id = sqlite3_column_int(stmt, count++);
- instance->dtstart_type = sqlite3_column_int(stmt, count++);
- sqlite3_column_int64(stmt, count++);//instance->dtstart_utime = sqlite3_column_int64(stmt, count++);
- temp = sqlite3_column_text(stmt, count++);
- if (temp) {
- dtstart_datetime = SAFE_STRDUP(temp);
- snprintf(buf, strlen("YYYY") + 1, "%s", &dtstart_datetime[0]);
- instance->dtstart_year = atoi(buf);
- snprintf(buf, strlen("MM") + 1, "%s", &dtstart_datetime[4]);
- instance->dtstart_month = atoi(buf);
- snprintf(buf, strlen("DD") + 1, "%s", &dtstart_datetime[6]);
- instance->dtstart_mday = atoi(buf);
- if (dtstart_datetime)
- free(dtstart_datetime);
- }
-
- instance->dtend_type = sqlite3_column_int(stmt, count++);
- sqlite3_column_int64(stmt, count++);//instance->dtend_utime = sqlite3_column_int64(stmt, count++);
- temp = sqlite3_column_text(stmt, count++);
- if (temp) {
- dtend_datetime = SAFE_STRDUP(temp);
- snprintf(buf, strlen("YYYY") + 1, "%s", &dtend_datetime[0]);
- instance->dtend_year = atoi(buf);
- snprintf(buf, strlen("MM") + 1, "%s", &dtend_datetime[4]);
- instance->dtend_month = atoi(buf);
- snprintf(buf, strlen("DD") + 1, "%s", &dtend_datetime[6]);
- instance->dtend_mday = atoi(buf);
- if (dtend_datetime)
- free(dtend_datetime);
- }
-
- temp = sqlite3_column_text(stmt, count++);
- instance->summary = SAFE_STRDUP(temp);
-
- temp = sqlite3_column_text(stmt, count++);
- instance->description = SAFE_STRDUP(temp);
-
- temp = sqlite3_column_text(stmt, count++);
- instance->location = SAFE_STRDUP(temp);
-
- instance->busy_status = sqlite3_column_int(stmt, count++);
-
- instance->event_status = sqlite3_column_int(stmt, count++);
-
- instance->priority = sqlite3_column_int(stmt, count++);
-
- instance->sensitivity = sqlite3_column_int(stmt, count++);
-
- instance->has_rrule = sqlite3_column_int(stmt, count++);
- if (instance->has_rrule > 0)
- {
- instance->has_rrule = 1;
- }
-
- instance->latitude = sqlite3_column_double(stmt,count++);
- instance->longitude = sqlite3_column_double(stmt,count++);
- instance->has_alarm = sqlite3_column_int(stmt,count++);
- instance->original_event_id = sqlite3_column_int(stmt, count++);
- instance->calendar_id = sqlite3_column_int(stmt, count++);
- instance->last_mod = sqlite3_column_int64(stmt, count++);
-
- return;
+ cal_instance_allday_s* instance = (cal_instance_allday_s*)(record);
+ const unsigned char *temp;
+ int count = 0;
+
+ instance->event_id = sqlite3_column_int(stmt, count++);
+ instance->start.type = sqlite3_column_int(stmt, count++);
+ count++; // utime
+ temp = sqlite3_column_text(stmt, count++);
+ if (temp) {
+ sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME, &(instance->start.time.date.year),
+ &(instance->start.time.date.month), &(instance->start.time.date.mday),
+ &(instance->start.time.date.hour), &(instance->start.time.date.minute),
+ &(instance->start.time.date.second));
+ DBG(CAL_FORMAT_LOCAL_DATETIME, instance->start.time.date.year, instance->start.time.date.month, instance->start.time.date.mday,
+ instance->start.time.date.hour, instance->start.time.date.minute, instance->start.time.date.second);
+ }
+
+ instance->end.type = sqlite3_column_int(stmt, count++);
+ count++; // utime
+ temp = sqlite3_column_text(stmt, count++);
+ if (temp) {
+ sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME, &(instance->end.time.date.year),
+ &(instance->end.time.date.month), &(instance->end.time.date.mday),
+ &(instance->end.time.date.hour), &(instance->end.time.date.minute),
+ &(instance->end.time.date.second));
+ DBG(CAL_FORMAT_LOCAL_DATETIME, instance->end.time.date.year, instance->end.time.date.month, instance->end.time.date.mday,
+ instance->end.time.date.hour, instance->end.time.date.minute, instance->end.time.date.second);
+ }
+
+ temp = sqlite3_column_text(stmt, count++);
+ instance->summary = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ instance->description = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ instance->location = SAFE_STRDUP(temp);
+
+ instance->busy_status = sqlite3_column_int(stmt, count++);
+
+ instance->event_status = sqlite3_column_int(stmt, count++);
+
+ instance->priority = sqlite3_column_int(stmt, count++);
+
+ instance->sensitivity = sqlite3_column_int(stmt, count++);
+
+ instance->has_rrule = sqlite3_column_int(stmt, count++);
+ if (instance->has_rrule > 0)
+ {
+ instance->has_rrule = 1;
+ }
+
+ instance->latitude = sqlite3_column_double(stmt,count++);
+ instance->longitude = sqlite3_column_double(stmt,count++);
+ instance->has_alarm = sqlite3_column_int(stmt,count++);
+ instance->original_event_id = sqlite3_column_int(stmt, count++);
+ instance->calendar_id = sqlite3_column_int(stmt, count++);
+ instance->last_mod = sqlite3_column_int64(stmt, count++);
+
+ temp = sqlite3_column_text(stmt, count++);
+ instance->sync_data1 = SAFE_STRDUP(temp);
+
+ instance->is_allday = sqlite3_column_int(stmt, count++);
+
+ return;
}
static void __cal_db_instance_allday_get_property_stmt(sqlite3_stmt *stmt,
- unsigned int property, int *stmt_count, calendar_record_h record)
+ unsigned int property, int *stmt_count, calendar_record_h record)
{
- cal_instance_allday_s* instance = (cal_instance_allday_s*)(record);
- const unsigned char *temp;
- char *dtstart_datetime;
- char *dtend_datetime;
- char buf[8] = {0};
-
- switch(property)
- {
- case CAL_PROPERTY_INSTANCE_ALLDAY_START:
- sqlite3_column_int(stmt,*stmt_count);
- *stmt_count = *stmt_count+1;
- sqlite3_column_int64(stmt,*stmt_count);
- *stmt_count = *stmt_count+1;
- instance->dtstart_type = CALENDAR_TIME_LOCALTIME;//sqlite3_column_int(stmt, *stmt_count);
- temp = sqlite3_column_text(stmt, *stmt_count);
- if (temp) {
- dtstart_datetime = SAFE_STRDUP(temp);
- snprintf(buf, strlen("YYYY") + 1, "%s", &dtstart_datetime[0]);
- instance->dtstart_year = atoi(buf);
- snprintf(buf, strlen("MM") + 1, "%s", &dtstart_datetime[4]);
- instance->dtstart_month = atoi(buf);
- snprintf(buf, strlen("DD") + 1, "%s", &dtstart_datetime[6]);
- instance->dtstart_mday = atoi(buf);
- if (dtstart_datetime)
- free(dtstart_datetime);
- }
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_END:
- sqlite3_column_int(stmt,*stmt_count);
- *stmt_count = *stmt_count+1;
- sqlite3_column_int64(stmt,*stmt_count);
- *stmt_count = *stmt_count+1;
- instance->dtend_type = CALENDAR_TIME_LOCALTIME; //sqlite3_column_int(stmt, *stmt_count);
- temp = sqlite3_column_text(stmt, *stmt_count);
- if (temp) {
- dtend_datetime = SAFE_STRDUP(temp);
- snprintf(buf, strlen("YYYY") + 1, "%s", &dtend_datetime[0]);
- instance->dtend_year = atoi(buf);
- snprintf(buf, strlen("MM") + 1, "%s", &dtend_datetime[4]);
- instance->dtend_month = atoi(buf);
- snprintf(buf, strlen("DD") + 1, "%s", &dtend_datetime[6]);
- instance->dtend_mday = atoi(buf);
- if (dtend_datetime)
- free(dtend_datetime);
- }
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_SUMMARY:
- temp = sqlite3_column_text(stmt, *stmt_count);
- instance->summary = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_LOCATION:
- temp = sqlite3_column_text(stmt, *stmt_count);
- instance->location = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_CALENDAR_ID:
- instance->calendar_id = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_DESCRIPTION:
- temp = sqlite3_column_text(stmt, *stmt_count);
- instance->description = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_BUSY_STATUS:
- instance->busy_status = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_STATUS:
- instance->event_status = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_PRIORITY:
- instance->priority = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_SENSITIVITY:
- instance->sensitivity = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_HAS_RRULE:
- instance->has_rrule = sqlite3_column_int(stmt, *stmt_count);
- if (instance->has_rrule > 0)
- {
- instance->has_rrule = 1;
- }
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_LATITUDE:
- instance->latitude = sqlite3_column_double(stmt,*stmt_count);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_LONGITUDE:
- instance->longitude = sqlite3_column_double(stmt,*stmt_count);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_ID:
- instance->event_id = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_HAS_ALARM:
- instance->has_alarm = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_ORIGINAL_EVENT_ID:
- instance->original_event_id = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_INSTANCE_ALLDAY_LAST_MODIFIED_TIME:
- instance->last_mod = sqlite3_column_int64(stmt, *stmt_count);
- break;
- default:
- sqlite3_column_int(stmt, *stmt_count);
- break;
- }
-
- *stmt_count = *stmt_count+1;
-
- return;
+ cal_instance_allday_s* instance = (cal_instance_allday_s*)(record);
+ const unsigned char *temp;
+
+ switch(property)
+ {
+ case CAL_PROPERTY_INSTANCE_ALLDAY_START:
+ instance->start.type = CALENDAR_TIME_LOCALTIME;
+ *stmt_count = *stmt_count+1; // utime
+ *stmt_count = *stmt_count+1;
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ if (temp) {
+ sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME, &(instance->start.time.date.year),
+ &(instance->start.time.date.month), &(instance->start.time.date.mday),
+ &(instance->start.time.date.hour), &(instance->start.time.date.minute),
+ &(instance->start.time.date.second));
+ }
+ break;
+
+ case CAL_PROPERTY_INSTANCE_ALLDAY_END:
+ instance->end.type = CALENDAR_TIME_LOCALTIME;
+ *stmt_count = *stmt_count+1; // utime
+ *stmt_count = *stmt_count+1;
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ if (temp) {
+ sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME, &(instance->end.time.date.year),
+ &(instance->end.time.date.month), &(instance->end.time.date.mday),
+ &(instance->end.time.date.hour), &(instance->end.time.date.minute),
+ &(instance->end.time.date.second));
+ }
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_SUMMARY:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->summary = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_LOCATION:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->location = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_CALENDAR_ID:
+ instance->calendar_id = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_DESCRIPTION:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->description = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_BUSY_STATUS:
+ instance->busy_status = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_STATUS:
+ instance->event_status = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_PRIORITY:
+ instance->priority = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_SENSITIVITY:
+ instance->sensitivity = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_HAS_RRULE:
+ instance->has_rrule = sqlite3_column_int(stmt, *stmt_count);
+ if (instance->has_rrule > 0)
+ {
+ instance->has_rrule = 1;
+ }
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_LATITUDE:
+ instance->latitude = sqlite3_column_double(stmt,*stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_LONGITUDE:
+ instance->longitude = sqlite3_column_double(stmt,*stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EVENT_ID:
+ instance->event_id = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_HAS_ALARM:
+ instance->has_alarm = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_ORIGINAL_EVENT_ID:
+ instance->original_event_id = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_LAST_MODIFIED_TIME:
+ instance->last_mod = sqlite3_column_int64(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_SYNC_DATA1:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->sync_data1 = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_IS_ALLDAY:
+ instance->is_allday = sqlite3_column_int64(stmt, *stmt_count);
+ break;
+
+ default:
+ sqlite3_column_int(stmt, *stmt_count);
+ break;
+ }
+
+ *stmt_count = *stmt_count+1;
+
+ return;
}
static void __cal_db_instance_allday_get_projection_stmt(sqlite3_stmt *stmt,
- const unsigned int *projection, const int projection_count,
- calendar_record_h record)
+ const unsigned int *projection, const int projection_count,
+ calendar_record_h record)
{
- int i=0;
- int stmt_count = 0;
+ int i=0;
+ int stmt_count = 0;
- for(i=0;i<projection_count;i++)
- {
- __cal_db_instance_allday_get_property_stmt(stmt,projection[i],&stmt_count,record);
- }
+ for(i=0;i<projection_count;i++)
+ {
+ __cal_db_instance_allday_get_property_stmt(stmt,projection[i],&stmt_count,record);
+ }
}
--- /dev/null
+/*
+ * Calendar Service
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdlib.h>
+
+#include "cal_internal.h"
+#include "cal_typedef.h"
+#include "cal_view.h"
+#include "cal_record.h"
+
+#include "cal_db_util.h"
+#include "cal_db.h"
+#include "cal_db_query.h"
+#include "cal_access_control.h"
+
+static int __cal_db_instance_allday_extended_get_all_records(int offset, int limit, calendar_list_h* out_list);
+static int __cal_db_instance_allday_extended_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* out_list);
+static int __cal_db_instance_allday_extended_get_count(int *out_count);
+static int __cal_db_instance_allday_extended_get_count_with_query(calendar_query_h query, int *out_count);
+
+/*
+ * static function
+ */
+static void __cal_db_instance_allday_extended_get_stmt(sqlite3_stmt *stmt,calendar_record_h record);
+static void __cal_db_instance_allday_extended_get_property_stmt(sqlite3_stmt *stmt,
+ unsigned int property, int *stmt_count, calendar_record_h record);
+static void __cal_db_instance_allday_extended_get_projection_stmt(sqlite3_stmt *stmt,
+ const unsigned int *projection, const int projection_count,
+ calendar_record_h record);
+
+cal_db_plugin_cb_s _cal_db_instance_allday_extended_plugin_cb = {
+ .is_query_only = false,
+ .insert_record= NULL,
+ .get_record= NULL,
+ .update_record=NULL,
+ .delete_record=NULL,
+ .get_all_records=__cal_db_instance_allday_extended_get_all_records,
+ .get_records_with_query=__cal_db_instance_allday_extended_get_records_with_query,
+ .insert_records=NULL,
+ .update_records=NULL,
+ .delete_records=NULL,
+ .get_count=__cal_db_instance_allday_extended_get_count,
+ .get_count_with_query=__cal_db_instance_allday_extended_get_count_with_query,
+ .replace_record=NULL,
+ .replace_records=NULL
+};
+
+static int __cal_db_instance_allday_extended_get_all_records(int offset, int limit, calendar_list_h* out_list)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ char offsetquery[CAL_DB_SQL_MAX_LEN] = {0};
+ char limitquery[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+
+ retvm_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ ret = calendar_list_create(out_list);
+ retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ if (offset > 0)
+ {
+ snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
+ }
+ if (limit > 0)
+ {
+ snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
+ }
+
+ char *query_str = NULL;
+ _cal_db_append_string(&query_str, "SELECT * FROM");
+ _cal_db_append_string(&query_str, CAL_VIEW_TABLE_ALLDAY_INSTANCE_EXTENDED);
+ _cal_db_append_string(&query_str, limitquery);
+ _cal_db_append_string(&query_str, offsetquery);
+
+ stmt = _cal_db_util_query_prepare(query_str);
+ if (NULL == stmt)
+ {
+ ERR("_cal_db_util_query_prepare() Failed");
+ calendar_list_destroy(*out_list, true);
+ *out_list = NULL;
+ CAL_FREE(query_str);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ {
+ calendar_record_h record;
+ // stmt -> record
+ ret = calendar_record_create(_calendar_instance_localtime_calendar_book_extended._uri,&record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
+ *out_list = NULL;
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ __cal_db_instance_allday_extended_get_stmt(stmt,record);
+
+ ret = calendar_list_add(*out_list,record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
+ *out_list = NULL;
+ calendar_record_destroy(record, true);
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ }
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_db_instance_allday_extended_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* out_list)
+{
+ cal_query_s *que = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ char *condition = NULL;
+ char *projection = NULL;
+ GSList *bind_text = NULL, *cursor = NULL;
+ sqlite3_stmt *stmt = NULL;
+ int i = 0;
+ char *table_name;
+
+ que = (cal_query_s *)query;
+
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_ALLDAY_INSTANCE_EXTENDED);
+
+ // make filter
+ if (que->filter)
+ {
+ ret = _cal_db_query_create_condition(query, &condition, &bind_text);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ CAL_FREE(table_name);
+ ERR("filter create fail");
+ return ret;
+ }
+ }
+
+ // make projection
+ ret = _cal_db_query_create_projection(query, &projection);
+
+ char *query_str = NULL;
+ // query - projection
+ if (projection)
+ {
+ _cal_db_append_string(&query_str, "SELECT");
+ _cal_db_append_string(&query_str, projection);
+ _cal_db_append_string(&query_str, "FROM");
+ _cal_db_append_string(&query_str, table_name);
+ CAL_FREE(projection);
+ }
+ else
+ {
+ _cal_db_append_string(&query_str, "SELECT * FROM");
+ _cal_db_append_string(&query_str, table_name);
+ }
+ CAL_FREE(table_name);
+
+ // query - condition
+ if (condition)
+ {
+ _cal_db_append_string(&query_str, "WHERE (");
+ _cal_db_append_string(&query_str, condition);
+ _cal_db_append_string(&query_str, ")");
+ }
+
+ // ORDER
+ char *order = NULL;
+ ret = _cal_db_query_create_order(query, condition, &order);
+ if (order)
+ {
+ _cal_db_append_string(&query_str, order);
+ CAL_FREE(order);
+ }
+ CAL_FREE(condition);
+
+ // limit, offset
+ char buf[32] = {0};
+ if (limit > 0)
+ {
+ snprintf(buf, sizeof(buf), "LIMIT %d", limit);
+ _cal_db_append_string(&query_str, buf);
+
+ if (offset > 0)
+ {
+ snprintf(buf, sizeof(buf), "OFFSET %d", offset);
+ _cal_db_append_string(&query_str, buf);
+ }
+ }
+
+ // query
+ stmt = _cal_db_util_query_prepare(query_str);
+ if (NULL == stmt)
+ {
+ CAL_DBG("%s",query_str);
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ ERR("_cal_db_util_query_prepare() Failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ // bind text
+ if (bind_text)
+ {
+ g_slist_length(bind_text);
+ for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
+ {
+ _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
+ }
+ }
+
+ //
+ ret = calendar_list_create(out_list);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ ERR("calendar_list_create() Failed");
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ {
+ calendar_record_h record;
+ // stmt -> record
+ ret = calendar_record_create(que->view_uri,&record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
+ *out_list = NULL;
+
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ if (que->projection_count > 0)
+ {
+ _cal_record_set_projection(record,
+ que->projection, que->projection_count, que->property_count);
+
+ __cal_db_instance_allday_extended_get_projection_stmt(stmt,
+ que->projection, que->projection_count,
+ record);
+ }
+ else
+ {
+ __cal_db_instance_allday_extended_get_stmt(stmt,record);
+ }
+
+ ret = calendar_list_add(*out_list,record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
+ *out_list = NULL;
+ calendar_record_destroy(record, true);
+
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ }
+
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_db_instance_allday_extended_get_count(int *out_count)
+{
+ retvm_if(NULL == out_count, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ char *query_str = NULL;
+ _cal_db_append_string(&query_str, "SELECT count(*) FROM");
+ _cal_db_append_string(&query_str, CAL_VIEW_TABLE_ALLDAY_INSTANCE_EXTENDED);
+
+ int ret = 0;
+ int count = 0;
+ ret = _cal_db_util_query_get_first_int_result(query_str, NULL, &count);
+ if (CALENDAR_ERROR_NONE != ret)
+ {
+ ERR("_cal_db_util_query_get_first_int_result() failed");
+ CAL_FREE(query_str);
+ return ret;
+ }
+ CAL_DBG("count(%d) str[%s]", count, query_str);
+ CAL_FREE(query_str);
+
+ *out_count = count;
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_db_instance_allday_extended_get_count_with_query(calendar_query_h query, int *out_count)
+{
+ cal_query_s *que = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ char *condition = NULL;
+ char *table_name;
+ int count = 0;
+ GSList *bind_text = NULL;
+
+ que = (cal_query_s *)query;
+
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_ALLDAY_INSTANCE_EXTENDED);
+
+ // make filter
+ if (que->filter)
+ {
+ ret = _cal_db_query_create_condition(query, &condition, &bind_text);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ CAL_FREE(table_name);
+ ERR("filter create fail");
+ return ret;
+ }
+ }
+
+ char *query_str = NULL;
+ // query - select from
+ _cal_db_append_string(&query_str, "SELECT count(*) FROM");
+ _cal_db_append_string(&query_str, table_name);
+ CAL_FREE(table_name);
+
+ // query - condition
+ if (condition)
+ {
+ _cal_db_append_string(&query_str, "WHERE (");
+ _cal_db_append_string(&query_str, condition);
+ _cal_db_append_string(&query_str, ")");
+ CAL_FREE(condition);
+ }
+
+ // query
+ ret = _cal_db_util_query_get_first_int_result(query_str, bind_text, &count);
+ if (CALENDAR_ERROR_NONE != ret)
+ {
+ ERR("_cal_db_util_query_get_first_int_result() failed");
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ return ret;
+ }
+ CAL_DBG("count(%d) str[%s]", count, query_str);
+
+ if (out_count) *out_count = count;
+
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ return CALENDAR_ERROR_NONE;
+}
+
+static void __cal_db_instance_allday_extended_get_stmt(sqlite3_stmt *stmt,calendar_record_h record)
+{
+ cal_instance_allday_extended_s* instance = (cal_instance_allday_extended_s*)(record);
+ const unsigned char *temp;
+ int count = 0;
+
+ instance->event_id = sqlite3_column_int(stmt, count++);
+ instance->start.type = sqlite3_column_int(stmt, count++);
+ count++; // utime
+ temp = sqlite3_column_text(stmt, count++);
+ if (temp) {
+ sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME, &(instance->start.time.date.year),
+ &(instance->start.time.date.month), &(instance->start.time.date.mday),
+ &(instance->start.time.date.hour), &(instance->start.time.date.minute),
+ &(instance->start.time.date.second));
+ }
+
+ instance->end.type = sqlite3_column_int(stmt, count++);
+ count++; // utime
+ temp = sqlite3_column_text(stmt, count++);
+ if (temp) {
+ sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME, &(instance->end.time.date.year),
+ &(instance->end.time.date.month), &(instance->end.time.date.mday),
+ &(instance->end.time.date.hour), &(instance->end.time.date.minute),
+ &(instance->end.time.date.second));
+ }
+
+ temp = sqlite3_column_text(stmt, count++);
+ instance->summary = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ instance->description = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ instance->location = SAFE_STRDUP(temp);
+
+ instance->busy_status = sqlite3_column_int(stmt, count++);
+
+ instance->event_status = sqlite3_column_int(stmt, count++);
+
+ instance->priority = sqlite3_column_int(stmt, count++);
+
+ instance->sensitivity = sqlite3_column_int(stmt, count++);
+
+ instance->has_rrule = sqlite3_column_int(stmt, count++);
+ if (instance->has_rrule > 0)
+ {
+ instance->has_rrule = 1;
+ }
+
+ instance->latitude = sqlite3_column_double(stmt,count++);
+ instance->longitude = sqlite3_column_double(stmt,count++);
+ instance->has_alarm = sqlite3_column_int(stmt,count++);
+ instance->original_event_id = sqlite3_column_int(stmt, count++);
+ instance->calendar_id = sqlite3_column_int(stmt, count++);
+
+ instance->last_mod = sqlite3_column_int64(stmt, count++);
+
+ temp = sqlite3_column_text(stmt, count++);
+ instance->sync_data1 = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ instance->organizer_name = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ instance->categories= SAFE_STRDUP(temp);
+
+ instance->has_attendee= sqlite3_column_int(stmt, count++);
+
+ temp = sqlite3_column_text(stmt, count++);
+ instance->sync_data2 = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ instance->sync_data3 = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ instance->sync_data4 = SAFE_STRDUP(temp);
+
+ instance->is_allday = sqlite3_column_int(stmt, count++);
+
+ return;
+}
+
+static void __cal_db_instance_allday_extended_get_property_stmt(sqlite3_stmt *stmt,
+ unsigned int property, int *stmt_count, calendar_record_h record)
+{
+ cal_instance_allday_extended_s* instance = (cal_instance_allday_extended_s*)(record);
+ const unsigned char *temp;
+
+ switch(property)
+ {
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_START:
+ instance->start.type = CALENDAR_TIME_LOCALTIME;
+ *stmt_count = *stmt_count+1; // utime
+ *stmt_count = *stmt_count+1;
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ if (temp) {
+ sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME, &(instance->start.time.date.year),
+ &(instance->start.time.date.month), &(instance->start.time.date.mday),
+ &(instance->start.time.date.hour), &(instance->start.time.date.minute),
+ &(instance->start.time.date.second));
+ }
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_END:
+ instance->end.type = CALENDAR_TIME_LOCALTIME;
+ *stmt_count = *stmt_count+1; // utime
+ *stmt_count = *stmt_count+1;
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ if (temp) {
+ sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME, &(instance->end.time.date.year),
+ &(instance->end.time.date.month), &(instance->end.time.date.mday),
+ &(instance->end.time.date.hour), &(instance->end.time.date.minute),
+ &(instance->end.time.date.second));
+ }
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SUMMARY:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->summary = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_LOCATION:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->location = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_CALENDAR_ID:
+ instance->calendar_id = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_DESCRIPTION:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->description = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_BUSY_STATUS:
+ instance->busy_status = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_EVENT_STATUS:
+ instance->event_status = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_PRIORITY:
+ instance->priority = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SENSITIVITY:
+ instance->sensitivity = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_HAS_RRULE:
+ instance->has_rrule = sqlite3_column_int(stmt, *stmt_count);
+ if (instance->has_rrule > 0)
+ {
+ instance->has_rrule = 1;
+ }
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_LATITUDE:
+ instance->latitude = sqlite3_column_double(stmt,*stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_LONGITUDE:
+ instance->longitude = sqlite3_column_double(stmt,*stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_EVENT_ID:
+ instance->event_id = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_HAS_ALARM:
+ instance->has_alarm = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_ORIGINAL_EVENT_ID:
+ instance->original_event_id = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_LAST_MODIFIED_TIME:
+ instance->last_mod = sqlite3_column_int64(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA1:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->sync_data1 = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_ORGANIZER_NAME:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->organizer_name= SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_CATEGORIES:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->categories= SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_HAS_ATTENDEE:
+ instance->has_attendee= sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA2:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->sync_data2= SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA3:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->sync_data3 = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_SYNC_DATA4:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->sync_data4= SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_IS_ALLDAY:
+ instance->is_allday = sqlite3_column_int(stmt, *stmt_count);
+ break;
+
+ default:
+ sqlite3_column_int(stmt, *stmt_count);
+ break;
+ }
+
+ *stmt_count = *stmt_count+1;
+
+ return;
+}
+
+static void __cal_db_instance_allday_extended_get_projection_stmt(sqlite3_stmt *stmt,
+ const unsigned int *projection, const int projection_count,
+ calendar_record_h record)
+{
+ int i=0;
+ int stmt_count = 0;
+
+ for(i=0;i<projection_count;i++)
+ {
+ __cal_db_instance_allday_extended_get_property_stmt(stmt,projection[i],&stmt_count,record);
+ }
+}
#include "cal_db_util.h"
#include "cal_db.h"
#include "cal_db_query.h"
+#include "cal_access_control.h"
-static int __cal_db_instance_normal_insert_record(calendar_record_h record, int* id);
//static int __cal_db_instance_normal_get_record(int id, calendar_record_h* out_record);
//static int __cal_db_instance_normal_update_record(calendar_record_h record);
static int __cal_db_instance_normal_delete_record(int id);
*/
static void __cal_db_instance_normal_get_stmt(sqlite3_stmt *stmt,calendar_record_h record);
static void __cal_db_instance_normal_get_property_stmt(sqlite3_stmt *stmt,
- unsigned int property, int *stmt_count, calendar_record_h record);
+ unsigned int property, int *stmt_count, calendar_record_h record);
static void __cal_db_instance_normal_get_projection_stmt(sqlite3_stmt *stmt,
- const unsigned int *projection, const int projection_count,
- calendar_record_h record);
+ const unsigned int *projection, const int projection_count,
+ calendar_record_h record);
cal_db_plugin_cb_s _cal_db_instance_normal_plugin_cb = {
.is_query_only = false,
- .insert_record=__cal_db_instance_normal_insert_record,
+ .insert_record=NULL,
.get_record=NULL,
.update_record=NULL,
.delete_record=__cal_db_instance_normal_delete_record,
.insert_records=NULL,
.update_records=NULL,
.delete_records=NULL,
- .get_count=__cal_db_instance_normal_get_count,
- .get_count_with_query=__cal_db_instance_normal_get_count_with_query,
- .replace_record=NULL,
- .replace_records=NULL
+ .get_count=__cal_db_instance_normal_get_count,
+ .get_count_with_query=__cal_db_instance_normal_get_count_with_query,
+ .replace_record=NULL,
+ .replace_records=NULL
};
-static int __cal_db_instance_normal_insert_record(calendar_record_h record, int* id)
-{
- int index = -1;
- char query[CAL_DB_SQL_MAX_LEN];
- sqlite3_stmt *stmt;
- cal_instance_normal_s *normal = NULL;
- cal_db_util_error_e dbret = CAL_DB_OK;
-
- normal = (cal_instance_normal_s *)(record);
- retvm_if(NULL == normal, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid argument: cal_instance_normal_s is NULL");
-
- snprintf(query, sizeof(query),
- "INSERT INTO %s ("
- "event_id, "
- "dtstart_utime, dtend_utime"
- ") VALUES ( "
- "%d, "
- "%lld, %lld) ",
- CAL_TABLE_NORMAL_INSTANCE,
- normal->event_id,
- normal->dtstart_utime, normal->dtend_utime);
-
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- DBG("query[%s]", query);
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
-
- dbret = _cal_db_util_stmt_step(stmt);
- if (CAL_DB_DONE != dbret)
- {
- ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
- sqlite3_finalize(stmt);
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
-
- index = _cal_db_util_last_insert_id();
- sqlite3_finalize(stmt);
-
- //calendar_record_set_int(record, _calendar_instance_normal.id, index);
- if (id)
- {
- *id = index;
- }
-
- return CALENDAR_ERROR_NONE;
-}
-
static int __cal_db_instance_normal_delete_record(int id)
{
- cal_db_util_error_e dbret = CAL_DB_OK;
+ cal_db_util_error_e dbret = CAL_DB_OK;
char query[CAL_DB_SQL_MAX_LEN] = {0};
retvm_if(id < 0, CALENDAR_ERROR_INVALID_PARAMETER,
return CALENDAR_ERROR_DB_FAILED;
}
}
-
return CALENDAR_ERROR_NONE;
}
static int __cal_db_instance_normal_get_all_records(int offset, int limit, calendar_list_h* out_list)
{
- int ret = CALENDAR_ERROR_NONE;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- char offsetquery[CAL_DB_SQL_MAX_LEN] = {0};
- char limitquery[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
-
- retvm_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- ret = calendar_list_create(out_list);
- retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- if (offset > 0)
- {
- snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
- }
- if (limit > 0)
- {
- snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
- }
- snprintf(query, sizeof(query),
- "SELECT * FROM %s %s %s",
- CAL_TABLE_NORMAL_INSTANCE, limitquery, offsetquery);
-
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() Failed");
- calendar_list_destroy(*out_list, true);
+ int ret = CALENDAR_ERROR_NONE;
+ char offsetquery[CAL_DB_SQL_MAX_LEN] = {0};
+ char limitquery[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+
+ retvm_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ ret = calendar_list_create(out_list);
+ retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ if (offset > 0)
+ {
+ snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
+ }
+ if (limit > 0)
+ {
+ snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
+ }
+
+ char *query_str = NULL;
+ _cal_db_append_string(&query_str, "SELECT * FROM");
+ _cal_db_append_string(&query_str, CAL_VIEW_TABLE_NORMAL_INSTANCE);
+ _cal_db_append_string(&query_str, limitquery);
+ _cal_db_append_string(&query_str, offsetquery);
+
+ stmt = _cal_db_util_query_prepare(query_str);
+ if (NULL == stmt)
+ {
+ SEC_ERR("[%s]", query_str);
+ ERR("_cal_db_util_query_prepare() Failed");
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- return CALENDAR_ERROR_DB_FAILED;
- }
-
- while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- calendar_record_h record;
- // stmt -> record
- ret = calendar_record_create(_calendar_instance_normal._uri,&record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
+ CAL_FREE(query_str);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ {
+ calendar_record_h record;
+ // stmt -> record
+ ret = calendar_record_create(_calendar_instance_utime_calendar_book._uri,&record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- sqlite3_finalize(stmt);
- return ret;
- }
- __cal_db_instance_normal_get_stmt(stmt,record);
-
- ret = calendar_list_add(*out_list,record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ __cal_db_instance_normal_get_stmt(stmt, record);
+
+ ret = calendar_list_add(*out_list, record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- calendar_record_destroy(record, true);
- sqlite3_finalize(stmt);
- return ret;
- }
- }
- sqlite3_finalize(stmt);
+ calendar_record_destroy(record, true);
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ }
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
return CALENDAR_ERROR_NONE;
}
static int __cal_db_instance_normal_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* out_list)
{
- cal_query_s *que = NULL;
- int ret = CALENDAR_ERROR_NONE;
- char *condition = NULL;
- char *projection = NULL;
- char *order = NULL;
- GSList *bind_text = NULL, *cursor = NULL;
- char strquery[CAL_DB_SQL_MAX_LEN] = {0};
- int len;
- sqlite3_stmt *stmt = NULL;
- int i = 0;
- char *table_name;
-
- que = (cal_query_s *)query;
-
- if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_NORMAL_CALENDAR))
- {
- table_name = SAFE_STRDUP(CAL_VIEW_TABLE_NORMAL_INSTANCE);
- }
- else
- {
- ERR("uri(%s) not support get records with query",que->view_uri);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- //table_name = SAFE_STRDUP(CAL_TABLE_NORMAL_INSTANCE);
- }
-
- // make filter
- if (que->filter)
- {
- ret = _cal_db_query_create_condition(query,
- &condition, &bind_text);
- if (ret != CALENDAR_ERROR_NONE)
- {
- CAL_FREE(table_name);
- ERR("filter create fail");
- return ret;
- }
- }
-
- // make projection
- ret = _cal_db_query_create_projection(query, &projection);
-
- // query - projection
- if (projection)
- {
- len = snprintf(strquery, sizeof(strquery), "SELECT %s FROM %s", projection, table_name);
- }
- else
- {
- len = snprintf(strquery, sizeof(strquery), "SELECT * FROM %s", table_name);
- }
- CAL_FREE(table_name);
-
- // query - condition
- if (condition)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " WHERE %s", condition);
- }
-
- // ORDER
- ret = _cal_db_query_create_order(query, &order);
- if (order)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " %s", order);
- }
-
- if (0 < limit)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " LIMIT %d", limit);
- if (0 < offset)
- len += snprintf(strquery+len, sizeof(strquery)-len, " OFFSET %d", offset);
- }
-
- // query
- stmt = _cal_db_util_query_prepare(strquery);
- if (NULL == stmt)
- {
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- CAL_DBG("%s",strquery);
-
- // bind text
- if (bind_text)
- {
- len = g_slist_length(bind_text);
- for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
- {
- _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
- }
- }
-
- //
- ret = calendar_list_create(out_list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- ERR("calendar_list_create() Failed");
- sqlite3_finalize(stmt);
- return ret;
- }
-
- while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- calendar_record_h record;
- // stmt -> record
- ret = calendar_record_create(que->view_uri,&record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
+ cal_query_s *que = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ char *condition = NULL;
+ char *projection = NULL;
+ GSList *bind_text = NULL, *cursor = NULL;
+ sqlite3_stmt *stmt = NULL;
+ int i = 0;
+ char *table_name;
+
+ que = (cal_query_s *)query;
+
+ if (0 == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_UTIME_CALENDAR))
+ {
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_NORMAL_INSTANCE);
+ }
+ else if (0 == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_UTIME_CALENDAR_EXTENDED))
+ {
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_NORMAL_INSTANCE_EXTENDED);
+ }
+ else
+ {
+ ERR("uri(%s) not support get records with query",que->view_uri);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ //table_name = SAFE_STRDUP(CAL_TABLE_NORMAL_INSTANCE);
+ }
+
+ // make filter
+ if (que->filter)
+ {
+ ret = _cal_db_query_create_condition(query, &condition, &bind_text);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ CAL_FREE(table_name);
+ ERR("filter create fail");
+ return ret;
+ }
+ }
+
+ // make projection
+ ret = _cal_db_query_create_projection(query, &projection);
+
+ char *query_str = NULL;
+ // query - projection
+ if (projection)
+ {
+ _cal_db_append_string(&query_str, "SELECT");
+ _cal_db_append_string(&query_str, projection);
+ _cal_db_append_string(&query_str, "FROM");
+ _cal_db_append_string(&query_str, table_name);
+ CAL_FREE(projection);
+ }
+ else
+ {
+ _cal_db_append_string(&query_str, "SELECT * FROM");
+ _cal_db_append_string(&query_str, table_name);
+ }
+ CAL_FREE(table_name);
+
+ // query - condition
+ if (condition)
+ {
+ _cal_db_append_string(&query_str, "WHERE (");
+ _cal_db_append_string(&query_str, condition);
+ _cal_db_append_string(&query_str, ")");
+ }
+
+ // ORDER
+ char *order = NULL;
+ ret = _cal_db_query_create_order(query, condition, &order);
+ if (order)
+ {
+ _cal_db_append_string(&query_str, order);
+ CAL_FREE(order);
+ }
+ CAL_FREE(condition);
+
+ // limit, offset
+ char buf[32] = {0};
+ if (limit > 0)
+ {
+ snprintf(buf, sizeof(buf), "LIMIT %d", limit);
+ _cal_db_append_string(&query_str, buf);
+
+ if (offset > 0)
+ {
+ snprintf(buf, sizeof(buf), "OFFSET %d", offset);
+ _cal_db_append_string(&query_str, buf);
+ }
+ }
+
+ // query
+ stmt = _cal_db_util_query_prepare(query_str);
+ if (NULL == stmt)
+ {
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ ERR("_cal_db_util_query_prepare() Failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ CAL_DBG("%s",query_str);
+
+ // bind text
+ if (bind_text)
+ {
+ g_slist_length(bind_text);
+ for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
+ {
+ _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
+ }
+ }
+
+ //
+ ret = calendar_list_create(out_list);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ ERR("calendar_list_create() Failed");
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ {
+ calendar_record_h record;
+ // stmt -> record
+ ret = calendar_record_create(que->view_uri,&record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
- return ret;
- }
- if (que->projection_count > 0)
- {
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+ if (que->projection_count > 0)
+ {
_cal_record_set_projection(record,
que->projection, que->projection_count, que->property_count);
- __cal_db_instance_normal_get_projection_stmt(stmt,
+ __cal_db_instance_normal_get_projection_stmt(stmt,
que->projection, que->projection_count,
- record);
- }
- else
- {
- __cal_db_instance_normal_get_stmt(stmt,record);
- }
-
- ret = calendar_list_add(*out_list,record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
+ record);
+ }
+ else
+ {
+ __cal_db_instance_normal_get_stmt(stmt,record);
+ }
+
+ ret = calendar_list_add(*out_list,record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- calendar_record_destroy(record, true);
-
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
- return ret;
- }
- }
-
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
-
- return CALENDAR_ERROR_NONE;
+ calendar_record_destroy(record, true);
+
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ }
+
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_instance_normal_get_count(int *out_count)
{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- int count = 0;
- int ret;
-
- retvm_if(NULL == out_count, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == out_count, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- snprintf(query, sizeof(query), "SELECT count(*) FROM %s ", CAL_TABLE_NORMAL_INSTANCE);
+ char *query_str = NULL;
+ _cal_db_append_string(&query_str, "SELECT count(*) FROM");
+ _cal_db_append_string(&query_str, CAL_TABLE_NORMAL_INSTANCE);
- ret = _cal_db_util_query_get_first_int_result(query, NULL, &count);
+ int ret = 0;
+ int count = 0;
+ ret = _cal_db_util_query_get_first_int_result(query_str, NULL, &count);
if (CALENDAR_ERROR_NONE != ret)
{
ERR("_cal_db_util_query_get_first_int_result() failed");
+ CAL_FREE(query_str);
return ret;
}
- CAL_DBG("%s=%d",query,count);
+ CAL_DBG("count(%d) str[%s]", count, query_str);
+ CAL_FREE(query_str);
- *out_count = count;
- return CALENDAR_ERROR_NONE;
+ *out_count = count;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_instance_normal_get_count_with_query(calendar_query_h query, int *out_count)
{
- cal_query_s *que = NULL;
- int ret = CALENDAR_ERROR_NONE;
- char *condition = NULL;
- char strquery[CAL_DB_SQL_MAX_LEN] = {0};
- int len;
- char *table_name;
- int count = 0;
- GSList *bind_text = NULL;
-
- que = (cal_query_s *)query;
-
- if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_NORMAL_CALENDAR))
- {
- table_name = SAFE_STRDUP(CAL_VIEW_TABLE_NORMAL_INSTANCE);
- }
- else
- {
- ERR("uri(%s) not support get records with query",que->view_uri);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- //table_name = SAFE_STRDUP(CAL_TABLE_NORMAL_INSTANCE);
- }
-
- // make filter
- if (que->filter)
- {
- ret = _cal_db_query_create_condition(query, &condition, &bind_text);
- if (ret != CALENDAR_ERROR_NONE)
- {
- CAL_FREE(table_name);
- ERR("filter create fail");
- return ret;
- }
- }
-
- // query - select from
-
- len = snprintf(strquery, sizeof(strquery), "SELECT count(*) FROM %s", table_name);
- CAL_FREE(table_name);
-
- // query - condition
- if (condition)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " WHERE %s", condition);
- }
-
- // query
- ret = _cal_db_util_query_get_first_int_result(strquery, bind_text, &count);
+ cal_query_s *que = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ char *condition = NULL;
+ char *table_name;
+ int count = 0;
+ GSList *bind_text = NULL;
+
+ que = (cal_query_s *)query;
+
+ if (0 == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_UTIME_CALENDAR))
+ {
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_NORMAL_INSTANCE);
+ }
+ else if (0 == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_UTIME_CALENDAR_EXTENDED))
+ {
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_NORMAL_INSTANCE_EXTENDED);
+ }
+ else
+ {
+ ERR("uri(%s) not support get records with query",que->view_uri);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ //table_name = SAFE_STRDUP(CAL_TABLE_NORMAL_INSTANCE);
+ }
+
+ // make filter
+ if (que->filter)
+ {
+ ret = _cal_db_query_create_condition(query, &condition, &bind_text);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ CAL_FREE(table_name);
+ ERR("filter create fail");
+ return ret;
+ }
+ }
+
+ char *query_str = NULL;
+ // query - select from
+ _cal_db_append_string(&query_str, "SELECT count(*) FROM");
+ _cal_db_append_string(&query_str, table_name);
+ CAL_FREE(table_name);
+
+ // query - condition
+ if (condition)
+ {
+ _cal_db_append_string(&query_str, "WHERE (");
+ _cal_db_append_string(&query_str, condition);
+ _cal_db_append_string(&query_str, ")");
+ CAL_FREE(condition);
+ }
+
+ // query
+ ret = _cal_db_util_query_get_first_int_result(query_str, bind_text, &count);
if (CALENDAR_ERROR_NONE != ret)
{
ERR("_cal_db_util_query_get_first_int_result() failed");
if (bind_text)
{
- g_slist_free(bind_text);
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
}
- CAL_FREE(condition);
+
+ CAL_FREE(query_str);
return ret;
}
- CAL_DBG("%s=%d",strquery,count);
+ CAL_DBG("count(%d) str[%s]", count, query_str);
- if (out_count) *out_count = count;
+ if (out_count) *out_count = count;
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- return CALENDAR_ERROR_NONE;
+ CAL_FREE(query_str);
+ return CALENDAR_ERROR_NONE;
}
-static void __cal_db_instance_normal_get_stmt(sqlite3_stmt *stmt,calendar_record_h record)
+static void __cal_db_instance_normal_get_stmt(sqlite3_stmt *stmt, calendar_record_h record)
{
- cal_instance_normal_s* instance = (cal_instance_normal_s*)(record);
- const unsigned char *temp;
- int count = 0;
+ cal_instance_normal_s* instance = (cal_instance_normal_s*)(record);
+ const unsigned char *temp;
+ int count = 0;
- instance->event_id = sqlite3_column_int(stmt, count++);
- instance->dtstart_type = sqlite3_column_int(stmt, count++);
- instance->dtstart_utime = sqlite3_column_int64(stmt, count++);
- sqlite3_column_text(stmt, count++); //datetime
- instance->dtend_type = sqlite3_column_int(stmt, count++);
- instance->dtend_utime = sqlite3_column_int64(stmt, count++);
- sqlite3_column_text(stmt, count++); //datetime
+ instance->event_id = sqlite3_column_int(stmt, count++);
+ instance->start.type = sqlite3_column_int(stmt, count++);
+ instance->start.time.utime = sqlite3_column_int64(stmt, count++);
+ count++; // datetime
+ instance->end.type = sqlite3_column_int(stmt, count++);
+ instance->end.time.utime = sqlite3_column_int64(stmt, count++);
+ count++; //datetime
- temp = sqlite3_column_text(stmt, count++);
- instance->summary = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ instance->summary = SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- instance->description = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ instance->description = SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- instance->location = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ instance->location = SAFE_STRDUP(temp);
- instance->busy_status = sqlite3_column_int(stmt, count++);
+ instance->busy_status = sqlite3_column_int(stmt, count++);
- instance->event_status = sqlite3_column_int(stmt, count++);
+ instance->event_status = sqlite3_column_int(stmt, count++);
- instance->priority = sqlite3_column_int(stmt, count++);
+ instance->priority = sqlite3_column_int(stmt, count++);
- instance->sensitivity = sqlite3_column_int(stmt, count++);
+ instance->sensitivity = sqlite3_column_int(stmt, count++);
+
+ instance->has_rrule = sqlite3_column_int(stmt, count++);
+ if (instance->has_rrule > 0)
+ {
+ instance->has_rrule = 1;
+ }
- instance->has_rrule = sqlite3_column_int(stmt, count++);
- if (instance->has_rrule > 0)
- {
- instance->has_rrule = 1;
- }
+ instance->latitude = sqlite3_column_double(stmt,count++);
+ instance->longitude = sqlite3_column_double(stmt,count++);
+ instance->has_alarm = sqlite3_column_int(stmt,count++);
+ instance->original_event_id = sqlite3_column_int(stmt, count++);
+ instance->calendar_id = sqlite3_column_int(stmt, count++);
+ instance->last_mod = sqlite3_column_int64(stmt, count++);
- instance->latitude = sqlite3_column_double(stmt,count++);
- instance->longitude = sqlite3_column_double(stmt,count++);
- instance->has_alarm = sqlite3_column_int(stmt,count++);
- instance->original_event_id = sqlite3_column_int(stmt, count++);
- instance->calendar_id = sqlite3_column_int(stmt, count++);
- instance->last_mod = sqlite3_column_int64(stmt, count++);
+ temp = sqlite3_column_text(stmt, count++);
+ instance->sync_data1 = SAFE_STRDUP(temp);
- return;
+ return;
}
static void __cal_db_instance_normal_get_property_stmt(sqlite3_stmt *stmt,
- unsigned int property, int *stmt_count, calendar_record_h record)
+ unsigned int property, int *stmt_count, calendar_record_h record)
{
- cal_instance_normal_s* instance = (cal_instance_normal_s*)(record);
- const unsigned char *temp;
-
- switch(property)
- {
- case CAL_PROPERTY_INSTANCE_NORMAL_START:
- sqlite3_column_int(stmt,*stmt_count);
- *stmt_count = *stmt_count+1;
- instance->dtstart_type = CALENDAR_TIME_UTIME;//sqlite3_column_int(stmt, *stmt_count);
- instance->dtstart_utime = sqlite3_column_int64(stmt, *stmt_count);
- *stmt_count = *stmt_count+1;
- sqlite3_column_text(stmt, *stmt_count); // dtstart_datetime
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_END:
- sqlite3_column_int(stmt,*stmt_count);
- *stmt_count = *stmt_count+1;
- instance->dtend_type = CALENDAR_TIME_UTIME;//sqlite3_column_int(stmt, *stmt_count);
- instance->dtend_utime = sqlite3_column_int64(stmt, *stmt_count);
- *stmt_count = *stmt_count+1;
- sqlite3_column_text(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_SUMMARY:
- temp = sqlite3_column_text(stmt, *stmt_count);
- instance->summary = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_LOCATION:
- temp = sqlite3_column_text(stmt, *stmt_count);
- instance->location = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_CALENDAR_ID:
- instance->calendar_id = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_DESCRIPTION:
- temp = sqlite3_column_text(stmt, *stmt_count);
- instance->description = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_BUSY_STATUS:
- instance->busy_status = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_EVENT_STATUS:
- instance->event_status = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_PRIORITY:
- instance->priority = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_SENSITIVITY:
- instance->sensitivity = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_HAS_RRULE:
- instance->has_rrule = sqlite3_column_int(stmt, *stmt_count);
- if (instance->has_rrule > 0)
- {
- instance->has_rrule = 1;
- }
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_LATITUDE:
- instance->latitude = sqlite3_column_double(stmt,*stmt_count);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_LONGITUDE:
- instance->longitude = sqlite3_column_double(stmt,*stmt_count);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_EVENT_ID:
- instance->event_id = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_HAS_ALARM:
- instance->has_alarm = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_ORIGINAL_EVENT_ID:
- instance->original_event_id = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_INSTANCE_NORMAL_LAST_MODIFIED_TIME:
- instance->last_mod = sqlite3_column_int64(stmt, *stmt_count);
- break;
- default:
- sqlite3_column_int(stmt, *stmt_count);
- break;
- }
-
- *stmt_count = *stmt_count+1;
-
- return;
+ cal_instance_normal_s* instance = (cal_instance_normal_s*)(record);
+ const unsigned char *temp;
+
+ switch(property)
+ {
+ case CAL_PROPERTY_INSTANCE_NORMAL_START:
+ instance->start.type = CALENDAR_TIME_UTIME;
+ *stmt_count = *stmt_count+1;
+ instance->start.time.utime = sqlite3_column_int64(stmt, *stmt_count);
+ *stmt_count = *stmt_count+1; // datetime
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_END:
+ instance->end.type = CALENDAR_TIME_UTIME;
+ sqlite3_column_int(stmt,*stmt_count);
+ *stmt_count = *stmt_count+1;
+ instance->end.time.utime = sqlite3_column_int64(stmt, *stmt_count);
+ *stmt_count = *stmt_count+1; // datetime
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_SUMMARY:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->summary = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_LOCATION:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->location = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_CALENDAR_ID:
+ instance->calendar_id = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_DESCRIPTION:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->description = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_BUSY_STATUS:
+ instance->busy_status = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EVENT_STATUS:
+ instance->event_status = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_PRIORITY:
+ instance->priority = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_SENSITIVITY:
+ instance->sensitivity = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_HAS_RRULE:
+ instance->has_rrule = sqlite3_column_int(stmt, *stmt_count);
+ if (instance->has_rrule > 0)
+ {
+ instance->has_rrule = 1;
+ }
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_LATITUDE:
+ instance->latitude = sqlite3_column_double(stmt,*stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_LONGITUDE:
+ instance->longitude = sqlite3_column_double(stmt,*stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EVENT_ID:
+ instance->event_id = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_HAS_ALARM:
+ instance->has_alarm = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_ORIGINAL_EVENT_ID:
+ instance->original_event_id = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_LAST_MODIFIED_TIME:
+ instance->last_mod = sqlite3_column_int64(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_SYNC_DATA1:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->sync_data1 = SAFE_STRDUP(temp);
+ break;
+ default:
+ sqlite3_column_int(stmt, *stmt_count);
+ break;
+ }
+
+ *stmt_count = *stmt_count+1;
+
+ return;
}
static void __cal_db_instance_normal_get_projection_stmt(sqlite3_stmt *stmt,
- const unsigned int *projection, const int projection_count,
- calendar_record_h record)
+ const unsigned int *projection, const int projection_count,
+ calendar_record_h record)
{
- int i=0;
- int stmt_count = 0;
+ int i=0;
+ int stmt_count = 0;
- for(i=0;i<projection_count;i++)
- {
- __cal_db_instance_normal_get_property_stmt(stmt,projection[i],&stmt_count,record);
- }
+ for(i=0;i<projection_count;i++)
+ {
+ __cal_db_instance_normal_get_property_stmt(stmt,projection[i],&stmt_count,record);
+ }
}
--- /dev/null
+/*
+ * Calendar Service
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdlib.h>
+
+#include "cal_internal.h"
+#include "cal_typedef.h"
+#include "cal_view.h"
+#include "cal_record.h"
+
+#include "cal_db_util.h"
+#include "cal_db.h"
+#include "cal_db_query.h"
+#include "cal_access_control.h"
+
+static int __cal_db_instance_normal_extended_get_all_records(int offset, int limit, calendar_list_h* out_list);
+static int __cal_db_instance_normal_extended_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* out_list);
+static int __cal_db_instance_normal_extended_get_count(int *out_count);
+static int __cal_db_instance_normal_extended_get_count_with_query(calendar_query_h query, int *out_count);
+/*
+ * static function
+ */
+static void __cal_db_instance_normal_extended_get_stmt(sqlite3_stmt *stmt,calendar_record_h record);
+static void __cal_db_instance_normal_extended_get_property_stmt(sqlite3_stmt *stmt,
+ unsigned int property, int *stmt_count, calendar_record_h record);
+static void __cal_db_instance_normal_extended_get_projection_stmt(sqlite3_stmt *stmt,
+ const unsigned int *projection, const int projection_count,
+ calendar_record_h record);
+
+cal_db_plugin_cb_s _cal_db_instance_normal_extended_plugin_cb = {
+ .is_query_only = false,
+ .insert_record=NULL,
+ .get_record=NULL,
+ .update_record=NULL,
+ .delete_record=NULL,
+ .get_all_records=__cal_db_instance_normal_extended_get_all_records,
+ .get_records_with_query=__cal_db_instance_normal_extended_get_records_with_query,
+ .insert_records=NULL,
+ .update_records=NULL,
+ .delete_records=NULL,
+ .get_count=__cal_db_instance_normal_extended_get_count,
+ .get_count_with_query=__cal_db_instance_normal_extended_get_count_with_query,
+ .replace_record=NULL,
+ .replace_records=NULL
+};
+
+static int __cal_db_instance_normal_extended_get_all_records(int offset, int limit, calendar_list_h* out_list)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ char offsetquery[CAL_DB_SQL_MAX_LEN] = {0};
+ char limitquery[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+
+ retvm_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ ret = calendar_list_create(out_list);
+ retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ if (offset > 0)
+ {
+ snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
+ }
+ if (limit > 0)
+ {
+ snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
+ }
+
+ char *query_str = NULL;
+ _cal_db_append_string(&query_str, "SELECT * FROM");
+ _cal_db_append_string(&query_str, CAL_VIEW_TABLE_NORMAL_INSTANCE_EXTENDED);
+ _cal_db_append_string(&query_str, limitquery);
+ _cal_db_append_string(&query_str, offsetquery);
+
+ stmt = _cal_db_util_query_prepare(query_str);
+ if (NULL == stmt)
+ {
+ ERR("_cal_db_util_query_prepare() Failed");
+ calendar_list_destroy(*out_list, true);
+ *out_list = NULL;
+ CAL_FREE(query_str);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ {
+ calendar_record_h record;
+ // stmt -> record
+ ret = calendar_record_create(_calendar_instance_utime_calendar_book_extended._uri,&record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
+ *out_list = NULL;
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ __cal_db_instance_normal_extended_get_stmt(stmt,record);
+
+ ret = calendar_list_add(*out_list,record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
+ *out_list = NULL;
+ calendar_record_destroy(record, true);
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ }
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_db_instance_normal_extended_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* out_list)
+{
+ cal_query_s *que = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ char *condition = NULL;
+ char *projection = NULL;
+ GSList *bind_text = NULL, *cursor = NULL;
+ sqlite3_stmt *stmt = NULL;
+ int i = 0;
+ char *table_name;
+
+ que = (cal_query_s *)query;
+
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_NORMAL_INSTANCE_EXTENDED);
+
+ // make filter
+ if (que->filter)
+ {
+ ret = _cal_db_query_create_condition(query, &condition, &bind_text);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ CAL_FREE(table_name);
+ ERR("filter create fail");
+ return ret;
+ }
+ }
+
+ // make projection
+ ret = _cal_db_query_create_projection(query, &projection);
+
+ char *query_str = NULL;
+ // query - projection
+ if (projection)
+ {
+ _cal_db_append_string(&query_str, "SELECT");
+ _cal_db_append_string(&query_str, projection);
+ _cal_db_append_string(&query_str, "FROM");
+ _cal_db_append_string(&query_str, table_name);
+ CAL_FREE(projection);
+ }
+ else
+ {
+ _cal_db_append_string(&query_str, "SELECT * FROM");
+ _cal_db_append_string(&query_str, table_name);
+ }
+ CAL_FREE(table_name);
+
+ // query - condition
+ if (condition)
+ {
+ _cal_db_append_string(&query_str, "WHERE (");
+ _cal_db_append_string(&query_str, condition);
+ _cal_db_append_string(&query_str, ")");
+ }
+
+ // ORDER
+ char *order = NULL;
+ ret = _cal_db_query_create_order(query, condition, &order);
+ if (order)
+ {
+ _cal_db_append_string(&query_str, order);
+ CAL_FREE(order);
+ }
+ CAL_FREE(condition);
+
+ // limit, offset
+ char buf[32] = {0};
+ if (limit > 0)
+ {
+ snprintf(buf, sizeof(buf), "LIMIT %d", limit);
+ _cal_db_append_string(&query_str, buf);
+
+ if (offset > 0)
+ {
+ snprintf(buf, sizeof(buf), "OFFSET %d", offset);
+ _cal_db_append_string(&query_str, buf);
+ }
+ }
+
+ // query
+ stmt = _cal_db_util_query_prepare(query_str);
+ if (NULL == stmt)
+ {
+ CAL_DBG("%s",query_str);
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ ERR("_cal_db_util_query_prepare() Failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ // bind text
+ if (bind_text)
+ {
+ g_slist_length(bind_text);
+ for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
+ {
+ _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
+ }
+ }
+
+ //
+ ret = calendar_list_create(out_list);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ ERR("calendar_list_create() Failed");
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ {
+ calendar_record_h record;
+ // stmt -> record
+ ret = calendar_record_create(que->view_uri,&record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
+ *out_list = NULL;
+
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+
+ if (que->projection_count > 0)
+ {
+ _cal_record_set_projection(record,
+ que->projection, que->projection_count, que->property_count);
+
+ __cal_db_instance_normal_extended_get_projection_stmt(stmt,
+ que->projection, que->projection_count, record);
+ }
+ else
+ {
+ __cal_db_instance_normal_extended_get_stmt(stmt,record);
+ }
+
+ ret = calendar_list_add(*out_list,record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
+ *out_list = NULL;
+ calendar_record_destroy(record, true);
+
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ }
+
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_db_instance_normal_extended_get_count(int *out_count)
+{
+ retvm_if(NULL == out_count, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ char *query_str = NULL;
+ _cal_db_append_string(&query_str, "SELECT count(*) FROM");
+ _cal_db_append_string(&query_str, CAL_VIEW_TABLE_NORMAL_INSTANCE_EXTENDED);
+
+ int ret = 0;
+ int count = 0;
+ ret = _cal_db_util_query_get_first_int_result(query_str, NULL, &count);
+ if (CALENDAR_ERROR_NONE != ret)
+ {
+ ERR("_cal_db_util_query_get_first_int_result() failed");
+ CAL_FREE(query_str);
+ return ret;
+ }
+ CAL_DBG("count(%d) str[%s]", count, query_str);
+ CAL_FREE(query_str);
+
+ *out_count = count;
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_db_instance_normal_extended_get_count_with_query(calendar_query_h query, int *out_count)
+{
+ cal_query_s *que = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ char *condition = NULL;
+ char *table_name;
+ int count = 0;
+ GSList *bind_text = NULL;
+
+ que = (cal_query_s *)query;
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_NORMAL_INSTANCE_EXTENDED);
+
+ // make filter
+ if (que->filter)
+ {
+ ret = _cal_db_query_create_condition(query, &condition, &bind_text);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ CAL_FREE(table_name);
+ ERR("filter create fail");
+ return ret;
+ }
+ }
+
+ char *query_str = NULL;
+ // query - select from
+ _cal_db_append_string(&query_str, "SELECT count(*) FROM");
+ _cal_db_append_string(&query_str, table_name);
+ CAL_FREE(table_name);
+
+ // query - condition
+ if (condition)
+ {
+ _cal_db_append_string(&query_str, "WHERE (");
+ _cal_db_append_string(&query_str, condition);
+ _cal_db_append_string(&query_str, ")");
+ CAL_FREE(condition);
+ }
+
+ // query
+ ret = _cal_db_util_query_get_first_int_result(query_str, bind_text, &count);
+ if (CALENDAR_ERROR_NONE != ret)
+ {
+ ERR("_cal_db_util_query_get_first_int_result() failed");
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+
+ CAL_FREE(query_str);
+ return ret;
+ }
+ CAL_DBG("count(%d) str[%s]", count, query_str);
+
+ if (out_count) *out_count = count;
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+
+ CAL_FREE(query_str);
+ return CALENDAR_ERROR_NONE;
+}
+
+static void __cal_db_instance_normal_extended_get_stmt(sqlite3_stmt *stmt,calendar_record_h record)
+{
+ cal_instance_normal_extended_s* instance = (cal_instance_normal_extended_s*)(record);
+ const unsigned char *temp;
+ int count = 0;
+
+ instance->event_id = sqlite3_column_int(stmt, count++);
+ instance->start.type = sqlite3_column_int(stmt, count++);
+ instance->start.time.utime = sqlite3_column_int64(stmt, count++);
+ count++; // datetime
+ instance->end.type = sqlite3_column_int(stmt, count++);
+ instance->end.time.utime = sqlite3_column_int64(stmt, count++);
+ count++; // datetime
+
+ temp = sqlite3_column_text(stmt, count++);
+ instance->summary = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ instance->description = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ instance->location = SAFE_STRDUP(temp);
+
+ instance->busy_status = sqlite3_column_int(stmt, count++);
+
+ instance->event_status = sqlite3_column_int(stmt, count++);
+
+ instance->priority = sqlite3_column_int(stmt, count++);
+
+ instance->sensitivity = sqlite3_column_int(stmt, count++);
+
+ instance->has_rrule = sqlite3_column_int(stmt, count++);
+ if (instance->has_rrule > 0)
+ {
+ instance->has_rrule = 1;
+ }
+
+ instance->latitude = sqlite3_column_double(stmt,count++);
+ instance->longitude = sqlite3_column_double(stmt,count++);
+ instance->has_alarm = sqlite3_column_int(stmt,count++);
+ instance->original_event_id = sqlite3_column_int(stmt, count++);
+ instance->calendar_id = sqlite3_column_int(stmt, count++);
+ instance->last_mod = sqlite3_column_int64(stmt, count++);
+
+ temp = sqlite3_column_text(stmt, count++);
+ instance->sync_data1 = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ instance->organizer_name = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ instance->categories= SAFE_STRDUP(temp);
+
+ instance->has_attendee= sqlite3_column_int(stmt, count++);
+
+ temp = sqlite3_column_text(stmt, count++);
+ instance->sync_data2 = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ instance->sync_data3 = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ instance->sync_data4 = SAFE_STRDUP(temp);
+
+ return;
+}
+
+static void __cal_db_instance_normal_extended_get_property_stmt(sqlite3_stmt *stmt,
+ unsigned int property, int *stmt_count, calendar_record_h record)
+{
+ cal_instance_normal_extended_s* instance = (cal_instance_normal_extended_s*)(record);
+ const unsigned char *temp;
+
+ switch(property)
+ {
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_START:
+ instance->start.type = CALENDAR_TIME_UTIME;
+ *stmt_count = *stmt_count+1;
+ instance->start.time.utime = sqlite3_column_int64(stmt, *stmt_count);
+ *stmt_count = *stmt_count+1;
+ *stmt_count = *stmt_count+1;
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_END:
+ instance->end.type = CALENDAR_TIME_UTIME;
+ *stmt_count = *stmt_count+1;
+ instance->end.time.utime = sqlite3_column_int64(stmt, *stmt_count);
+ *stmt_count = *stmt_count+1;
+ *stmt_count = *stmt_count+1;
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SUMMARY:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->summary = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LOCATION:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->location = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_CALENDAR_ID:
+ instance->calendar_id = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_DESCRIPTION:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->description = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_BUSY_STATUS:
+ instance->busy_status = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_EVENT_STATUS:
+ instance->event_status = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_PRIORITY:
+ instance->priority = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SENSITIVITY:
+ instance->sensitivity = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_HAS_RRULE:
+ instance->has_rrule = sqlite3_column_int(stmt, *stmt_count);
+ if (instance->has_rrule > 0)
+ {
+ instance->has_rrule = 1;
+ }
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LATITUDE:
+ instance->latitude = sqlite3_column_double(stmt,*stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LONGITUDE:
+ instance->longitude = sqlite3_column_double(stmt,*stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_EVENT_ID:
+ instance->event_id = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_HAS_ALARM:
+ instance->has_alarm = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_ORIGINAL_EVENT_ID:
+ instance->original_event_id = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_LAST_MODIFIED_TIME:
+ instance->last_mod = sqlite3_column_int64(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA1:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->sync_data1 = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_ORGANIZER_NAME:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->organizer_name= SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_CATEGORIES:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->categories= SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_HAS_ATTENDEE:
+ instance->has_attendee= sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA2:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->sync_data2= SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA3:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->sync_data3 = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_SYNC_DATA4:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ instance->sync_data4= SAFE_STRDUP(temp);
+ break;
+ default:
+ sqlite3_column_int(stmt, *stmt_count);
+ break;
+ }
+
+ *stmt_count = *stmt_count+1;
+
+ return;
+}
+
+static void __cal_db_instance_normal_extended_get_projection_stmt(sqlite3_stmt *stmt,
+ const unsigned int *projection, const int projection_count,
+ calendar_record_h record)
+{
+ int i=0;
+ int stmt_count = 0;
+
+ for(i=0;i<projection_count;i++)
+ {
+ __cal_db_instance_normal_extended_get_property_stmt(stmt,projection[i],&stmt_count,record);
+ }
+}
#include "cal_db.h"
#include "cal_db_util.h"
#include "cal_db_query.h"
+#include "cal_access_control.h"
/*
* db plugin function
* static function
*/
static void __cal_db_search_get_stmt(sqlite3_stmt *stmt,calendar_query_h query,
- calendar_record_h record);
+ calendar_record_h record);
static void __cal_db_search_get_property_stmt(sqlite3_stmt *stmt,
- unsigned int property, int *stmt_count, calendar_record_h record);
+ unsigned int property, int *stmt_count, calendar_record_h record);
static void __cal_db_search_get_projection_stmt(sqlite3_stmt *stmt,
- const unsigned int *projection, const int projection_count,
- calendar_record_h record);
+ const unsigned int *projection, const int projection_count,
+ calendar_record_h record);
static int __cal_db_search_make_projection(calendar_query_h query, char **projection);
cal_db_plugin_cb_s _cal_db_search_plugin_cb = {
- .is_query_only=true,
- .insert_record=NULL,
- .get_record=NULL,
- .update_record=NULL,
- .delete_record=NULL,
- .get_all_records=NULL,
- .get_records_with_query=__cal_db_search_get_records_with_query,
- .insert_records=NULL,
- .update_records=NULL,
- .delete_records=NULL,
- .get_count=NULL,
- .get_count_with_query=__cal_db_search_get_count_with_query,
- .replace_record=NULL,
- .replace_records=NULL
+ .is_query_only=true,
+ .insert_record=NULL,
+ .get_record=NULL,
+ .update_record=NULL,
+ .delete_record=NULL,
+ .get_all_records=NULL,
+ .get_records_with_query=__cal_db_search_get_records_with_query,
+ .insert_records=NULL,
+ .update_records=NULL,
+ .delete_records=NULL,
+ .get_count=NULL,
+ .get_count_with_query=__cal_db_search_get_count_with_query,
+ .replace_record=NULL,
+ .replace_records=NULL
};
static int __cal_db_search_get_records_with_query( calendar_query_h query, int offset, int limit, calendar_list_h* out_list )
{
- cal_query_s *que = NULL;
- int ret = CALENDAR_ERROR_NONE;
- char *condition = NULL;
- char *projection = NULL;
- char *order = NULL;
- GSList *bind_text = NULL, *cursor = NULL;
- char strquery[CAL_DB_SQL_MAX_LEN] = {0};
- int len;
- sqlite3_stmt *stmt = NULL;
- int i = 0;
- char *table_name;
-
- que = (cal_query_s *)query;
-
- // make filter
- if (que->filter)
- {
- ret = _cal_db_query_create_condition(query,
- &condition, &bind_text);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("filter create fail");
- return ret;
- }
- }
-
- // make projection
- if (que->projection_count > 0)
- {
- ret = _cal_db_query_create_projection(query, &projection);
- }
- else
- {
- __cal_db_search_make_projection(query, &projection);
- }
-
- // query - projection
- if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR))
- {
- table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT_CALENDAR);
- }
- else if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_TODO_CALENDAR))
- {
- table_name = SAFE_STRDUP(CAL_VIEW_TABLE_TODO_CALENDAR);
- }
- else if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR_ATTENDEE))
- {
- table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT_CALENDAR_ATTENDEE);
- }
- else if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_NORMAL_CALENDAR))
- {
- table_name = SAFE_STRDUP(CAL_VIEW_TABLE_NORMAL_INSTANCE);
- }
- else if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_ALLDAY_CALENDAR))
- {
- table_name = SAFE_STRDUP(CAL_VIEW_TABLE_ALLDAY_INSTANCE);
- }
- else
- {
- ERR("uri(%s) not support get records with query",que->view_uri);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- if (que->distinct == true)
- {
- len = snprintf(strquery, sizeof(strquery), "SELECT DISTINCT %s FROM %s", projection, table_name);
- }
- else
- {
- len = snprintf(strquery, sizeof(strquery), "SELECT %s FROM %s", projection, table_name);
- }
-
- CAL_FREE(table_name);
-
- // query - condition
- if (condition)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " WHERE %s", condition);
- }
-
- // ORDER
- ret = _cal_db_query_create_order(query, &order);
- if (order)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " %s", order);
- }
-
- if (0 < limit)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " LIMIT %d", limit);
- if (0 < offset)
- len += snprintf(strquery+len, sizeof(strquery)-len, " OFFSET %d", offset);
- }
-
- // query
- stmt = _cal_db_util_query_prepare(strquery);
- if (NULL == stmt)
- {
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- CAL_DBG("%s",strquery);
-
- // bind text
- if (bind_text)
- {
- len = g_slist_length(bind_text);
- for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
- {
- _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
- }
- }
-
- //
- ret = calendar_list_create(out_list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- ERR("calendar_list_create() Failed");
- sqlite3_finalize(stmt);
- return ret;
- }
-
- while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- calendar_record_h record;
- // stmt -> record
- ret = calendar_record_create(que->view_uri,&record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
+ cal_query_s *que = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ char *condition = NULL;
+ char *projection = NULL;
+ GSList *bind_text = NULL, *cursor = NULL;
+ sqlite3_stmt *stmt = NULL;
+ int i = 0;
+ char *table_name = NULL;
+
+ que = (cal_query_s *)query;
+
+ // make filter
+ if (que->filter)
+ {
+ ret = _cal_db_query_create_condition(query,
+ &condition, &bind_text);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("filter create fail");
+ return ret;
+ }
+ }
+
+ // make projection
+ if (que->projection_count > 0)
+ {
+ ret = _cal_db_query_create_projection(query, &projection);
+ }
+ else
+ {
+ __cal_db_search_make_projection(query, &projection);
+ }
+
+ char *query_str = NULL;
+ if (que->distinct == true)
+ {
+ _cal_db_append_string(&query_str, "SELECT DISTINCT");
+ _cal_db_append_string(&query_str, projection);
+ _cal_db_append_string(&query_str, "FROM");
+ _cal_db_append_string(&query_str, table_name);
+ }
+ else
+ {
+ _cal_db_append_string(&query_str, "SELECT");
+ _cal_db_append_string(&query_str, projection);
+ _cal_db_append_string(&query_str, "FROM");
+ _cal_db_append_string(&query_str, table_name);
+ }
+ CAL_FREE(projection);
+ CAL_FREE(table_name);
+
+ // query - condition
+ if (condition)
+ {
+ _cal_db_append_string(&query_str, "WHERE (");
+ _cal_db_append_string(&query_str, condition);
+ _cal_db_append_string(&query_str, ")");
+ }
+
+ // ORDER
+ char *order = NULL;
+ ret = _cal_db_query_create_order(query, condition, &order);
+ if (order)
+ {
+ _cal_db_append_string(&query_str, order);
+ CAL_FREE(order);
+ }
+ CAL_FREE(condition);
+
+ // limit, offset
+ char buf[32] = {0};
+ if (limit > 0)
+ {
+ snprintf(buf, sizeof(buf), "LIMIT %d", limit);
+ _cal_db_append_string(&query_str, buf);
+
+ if (offset > 0)
+ {
+ snprintf(buf, sizeof(buf), "OFFSET %d", offset);
+ _cal_db_append_string(&query_str, buf);
+ }
+ }
+
+ // query
+ stmt = _cal_db_util_query_prepare(query_str);
+ if (NULL == stmt)
+ {
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ ERR("_cal_db_util_query_prepare() Failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ CAL_DBG("%s",query_str);
+
+ // bind text
+ if (bind_text)
+ {
+ g_slist_length(bind_text);
+ for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
+ {
+ _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
+ }
+ }
+
+ //
+ ret = calendar_list_create(out_list);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ ERR("calendar_list_create() Failed");
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ {
+ calendar_record_h record;
+ // stmt -> record
+ ret = calendar_record_create(que->view_uri,&record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
- return ret;
- }
- if (que->projection_count > 0)
- {
- __cal_db_search_get_projection_stmt(stmt,que->projection,que->projection_count,
- record);
- }
- else
- {
- __cal_db_search_get_stmt(stmt, query,record);
- }
-
- ret = calendar_list_add(*out_list,record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ if (que->projection_count > 0)
+ {
+ __cal_db_search_get_projection_stmt(stmt,que->projection,que->projection_count,
+ record);
+ }
+ else
+ {
+ __cal_db_search_get_stmt(stmt, query,record);
+ }
+
+ ret = calendar_list_add(*out_list,record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- calendar_record_destroy(record, true);
-
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
- return ret;
- }
- }
-
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
-
- return CALENDAR_ERROR_NONE;
+ calendar_record_destroy(record, true);
+
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ }
+
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_search_get_count_with_query(calendar_query_h query, int *out_count)
{
- cal_query_s *que = NULL;
- int ret = CALENDAR_ERROR_NONE;
- char *condition = NULL;
- char *projection = NULL;
- char strquery[CAL_DB_SQL_MAX_LEN] = {0};
- int len;
- char *table_name;
- int count = 0;
- GSList *bind_text = NULL;
-
- que = (cal_query_s *)query;
-
- if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR))
- {
- table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT_CALENDAR);
- projection = SAFE_STRDUP("id");
- }
- else if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_TODO_CALENDAR))
- {
- table_name = SAFE_STRDUP(CAL_VIEW_TABLE_TODO_CALENDAR);
- projection = SAFE_STRDUP("id");
- }
- else if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR_ATTENDEE))
- {
- table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT_CALENDAR_ATTENDEE);
- projection = SAFE_STRDUP("id");
- }
- else if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_NORMAL_CALENDAR))
- {
- table_name = SAFE_STRDUP(CAL_VIEW_TABLE_NORMAL_INSTANCE);
- projection = SAFE_STRDUP("event_id");
- }
- else if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_ALLDAY_CALENDAR))
- {
- table_name = SAFE_STRDUP(CAL_VIEW_TABLE_ALLDAY_INSTANCE);
- projection = SAFE_STRDUP("event_id");
- }
- else
- {
- ERR("uri(%s) not support get records with query",que->view_uri);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- // make filter
- if (que->filter)
- {
- ret = _cal_db_query_create_condition(query, &condition, &bind_text);
- if (ret != CALENDAR_ERROR_NONE)
- {
- CAL_FREE(table_name);
- ERR("filter create fail");
- CAL_FREE(projection);
- return ret;
- }
- }
-
- // query - select from
-
- if (que->distinct == true)
- {
- len = snprintf(strquery, sizeof(strquery), "SELECT count(DISTINCT %s) FROM %s", projection, table_name);
-
- }
- else
- {
- len = snprintf(strquery, sizeof(strquery), "SELECT count(*) FROM %s", table_name);
- }
-
- CAL_FREE(table_name);
-
- // query - condition
- if (condition)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " WHERE %s", condition);
- }
-
- // query
- ret = _cal_db_util_query_get_first_int_result(strquery, bind_text, &count);
+ cal_query_s *que = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ char *condition = NULL;
+ char *projection = NULL;
+ char *table_name;
+ int count = 0;
+ GSList *bind_text = NULL;
+
+ que = (cal_query_s *)query;
+
+ if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR))
+ {
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT_CALENDAR);
+ projection = SAFE_STRDUP("id");
+ }
+ else if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_TODO_CALENDAR))
+ {
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_TODO_CALENDAR);
+ projection = SAFE_STRDUP("id");
+ }
+ else if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_EVENT_CALENDAR_ATTENDEE))
+ {
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_EVENT_CALENDAR_ATTENDEE);
+ projection = SAFE_STRDUP("id");
+ }
+ else if (0 == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_UTIME_CALENDAR))
+ {
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_NORMAL_INSTANCE);
+ projection = SAFE_STRDUP("event_id");
+ }
+ else if (0 == strcmp(que->view_uri, CALENDAR_VIEW_INSTANCE_LOCALTIME_CALENDAR))
+ {
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_ALLDAY_INSTANCE);
+ projection = SAFE_STRDUP("event_id");
+ }
+ else
+ {
+ ERR("uri(%s) not support get records with query",que->view_uri);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ // make filter
+ if (que->filter)
+ {
+ ret = _cal_db_query_create_condition(query, &condition, &bind_text);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ CAL_FREE(table_name);
+ ERR("filter create fail");
+ CAL_FREE(projection);
+ return ret;
+ }
+ }
+
+ char *query_str = NULL;
+
+ // query - select from
+ if (que->distinct == true)
+ {
+ _cal_db_append_string(&query_str, "SELECT count(DISTINCT");
+ _cal_db_append_string(&query_str, projection);
+ _cal_db_append_string(&query_str, ") FROM");
+ _cal_db_append_string(&query_str, table_name);
+ }
+ else
+ {
+ _cal_db_append_string(&query_str, "SELECT count(*) FROM");
+ _cal_db_append_string(&query_str, table_name);
+ }
+ CAL_FREE(projection);
+ CAL_FREE(table_name);
+
+ // query - condition
+ if (condition)
+ {
+ _cal_db_append_string(&query_str, "WHERE (");
+ _cal_db_append_string(&query_str, condition);
+ _cal_db_append_string(&query_str, ")");
+ CAL_FREE(condition);
+ }
+
+ // query
+ ret = _cal_db_util_query_get_first_int_result(query_str, bind_text, &count);
if (CALENDAR_ERROR_NONE != ret)
{
ERR("_cal_db_util_query_get_first_int_result() failed");
if (bind_text)
{
- g_slist_free(bind_text);
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
}
- CAL_FREE(condition);
- CAL_FREE(projection);
+
+ CAL_FREE(query_str);
return ret;
}
- CAL_DBG("%s=%d",strquery,count);
+ CAL_DBG("count(%d) str[%s]", count, query_str);
- *out_count = count;
+ if (out_count) *out_count = count;
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- return CALENDAR_ERROR_NONE;
+ CAL_FREE(query_str);
+ return CALENDAR_ERROR_NONE;
}
static void __cal_db_search_get_stmt(sqlite3_stmt *stmt,calendar_query_h query,
- calendar_record_h record)
+ calendar_record_h record)
{
- int i=0;
- int stmt_count = 0;
- cal_query_s *query_s = NULL;
- cal_property_info_s *properties = NULL;
+ int i=0;
+ int stmt_count = 0;
+ cal_query_s *query_s = NULL;
+ cal_property_info_s *properties = NULL;
- query_s = (cal_query_s *)query;
+ query_s = (cal_query_s *)query;
- for (i=0;i<query_s->property_count;i++)
- {
- properties = &(query_s->properties[i]);
+ for (i=0;i<query_s->property_count;i++)
+ {
+ properties = &(query_s->properties[i]);
- if ( CAL_PROPERTY_CHECK_FLAGS(properties->property_id, CAL_PROPERTY_FLAGS_FILTER) == true)
- {
- break;
- }
+ if ( CAL_PROPERTY_CHECK_FLAGS(properties->property_id, CAL_PROPERTY_FLAGS_FILTER) == true)
+ {
+ break;
+ }
- __cal_db_search_get_property_stmt(stmt, properties->property_id, &stmt_count,record);
- }
- return ;
+ __cal_db_search_get_property_stmt(stmt, properties->property_id, &stmt_count,record);
+ }
+ return ;
}
static void __cal_db_search_get_property_stmt(sqlite3_stmt *stmt,
- unsigned int property, int *stmt_count, calendar_record_h record)
+ unsigned int property, int *stmt_count, calendar_record_h record)
{
- cal_search_s *search = NULL;
- const unsigned char *temp;
- char *dtstart_datetime;
- char buf[8] = {0};
- int int_tmp = 0;
- double d_tmp = 0;
- long long int lli_tmp = 0;
-
- search = (cal_search_s*)(record);
-
- if (CAL_PROPERTY_CHECK_DATA_TYPE(property,CAL_PROPERTY_DATA_TYPE_INT) == true)
- {
- int_tmp = sqlite3_column_int(stmt, *stmt_count);
- _cal_record_set_int(record,property,int_tmp);
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(property,CAL_PROPERTY_DATA_TYPE_STR) == true)
- {
- temp = sqlite3_column_text(stmt, *stmt_count);
- _cal_record_set_str(record,property,(const char*)temp);
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(property,CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
- {
- d_tmp = sqlite3_column_double(stmt,*stmt_count);
- _cal_record_set_double(record,property,d_tmp);
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(property,CAL_PROPERTY_DATA_TYPE_LLI) == true)
- {
- lli_tmp = sqlite3_column_int64(stmt, *stmt_count);
- _cal_record_set_lli(record,property,lli_tmp);
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(property,CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
- {
- calendar_time_s caltime_tmp;
- caltime_tmp.type = sqlite3_column_int(stmt,*stmt_count);
- if (caltime_tmp.type == CALENDAR_TIME_UTIME)
- {
- *stmt_count = *stmt_count+1;
- caltime_tmp.time.utime = sqlite3_column_int64(stmt,*stmt_count);
- *stmt_count = *stmt_count+1;
- sqlite3_column_text(stmt, *stmt_count);
- }
- else
- {
- *stmt_count = *stmt_count+1;
- sqlite3_column_int64(stmt,*stmt_count); //event->start.time.utime = sqlite3_column_int64(stmt,count++);
- *stmt_count = *stmt_count+1;
- temp = sqlite3_column_text(stmt, *stmt_count);
- if (temp) {
- dtstart_datetime = SAFE_STRDUP(temp);
- snprintf(buf, strlen("YYYY") + 1, "%s", &dtstart_datetime[0]);
- caltime_tmp.time.date.year = atoi(buf);
- snprintf(buf, strlen("MM") + 1, "%s", &dtstart_datetime[4]);
- caltime_tmp.time.date.month = atoi(buf);
- snprintf(buf, strlen("DD") + 1, "%s", &dtstart_datetime[6]);
- caltime_tmp.time.date.mday = atoi(buf);
- if (dtstart_datetime) free(dtstart_datetime);
- }
- }
- _cal_record_set_caltime(record,property,caltime_tmp);
- }
- else
- {
- sqlite3_column_int(stmt, *stmt_count);
- }
-
- *stmt_count = *stmt_count+1;
+ int ret = 0;
+ const unsigned char *temp;
+ int int_tmp = 0;
+ double d_tmp = 0;
+ long long int lli_tmp = 0;
+
+ if (CAL_PROPERTY_CHECK_DATA_TYPE(property,CAL_PROPERTY_DATA_TYPE_INT) == true)
+ {
+ int_tmp = sqlite3_column_int(stmt, *stmt_count);
+ _cal_record_set_int(record,property,int_tmp);
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(property,CAL_PROPERTY_DATA_TYPE_STR) == true)
+ {
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ _cal_record_set_str(record,property,(const char*)temp);
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(property,CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
+ {
+ d_tmp = sqlite3_column_double(stmt,*stmt_count);
+ _cal_record_set_double(record,property,d_tmp);
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(property,CAL_PROPERTY_DATA_TYPE_LLI) == true)
+ {
+ lli_tmp = sqlite3_column_int64(stmt, *stmt_count);
+ _cal_record_set_lli(record,property,lli_tmp);
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(property,CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
+ {
+ calendar_time_s caltime_tmp;
+ caltime_tmp.type = sqlite3_column_int(stmt,*stmt_count);
+ switch (caltime_tmp.type)
+ {
+ case CALENDAR_TIME_UTIME:
+ *stmt_count = *stmt_count+1;
+ caltime_tmp.time.utime = sqlite3_column_int64(stmt,*stmt_count);
+ *stmt_count = *stmt_count+1; // datetime
+ break;
+
+ case CALENDAR_TIME_LOCALTIME:
+ *stmt_count = *stmt_count+1; // utime
+ *stmt_count = *stmt_count+1;
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ if (temp) {
+ sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME, &(caltime_tmp.time.date.year),
+ &(caltime_tmp.time.date.month), &(caltime_tmp.time.date.mday),
+ &(caltime_tmp.time.date.hour), &(caltime_tmp.time.date.minute),
+ &(caltime_tmp.time.date.second));
+ }
+ break;
+ }
+ ret = _cal_record_set_caltime(record,property,caltime_tmp);
+ warn_if (CALENDAR_ERROR_NONE != ret, "Failed to _cal_record_set_caltime()");
+ }
+ else
+ {
+ sqlite3_column_int(stmt, *stmt_count);
+ }
+
+ *stmt_count = *stmt_count+1;
}
static void __cal_db_search_get_projection_stmt(sqlite3_stmt *stmt,
- const unsigned int *projection, const int projection_count,
- calendar_record_h record)
+ const unsigned int *projection, const int projection_count,
+ calendar_record_h record)
{
- int i=0;
- int stmt_count = 0;
+ int i=0;
+ int stmt_count = 0;
- for(i=0;i<projection_count;i++)
- {
- __cal_db_search_get_property_stmt(stmt,projection[i],&stmt_count,record);
- }
+ for(i=0;i<projection_count;i++)
+ {
+ __cal_db_search_get_property_stmt(stmt,projection[i],&stmt_count,record);
+ }
}
static int __cal_db_search_make_projection(calendar_query_h query, char **projection)
{
- int i = 0;
- int len = 0;
- const char *field_name;
- char out_projection[CAL_DB_SQL_MAX_LEN] = {0};
- cal_query_s *query_s = NULL;
- cal_property_info_s *properties = NULL;
-
- retv_if(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER);
- query_s = (cal_query_s *)query;
-
- properties = &(query_s->properties[0]);
- field_name = properties->fields;
- if (field_name)
- len += snprintf(out_projection+len, sizeof(out_projection)-len, "%s", field_name);
-
- for (i=1;i<query_s->property_count;i++)
- {
- properties = &(query_s->properties[i]);
- field_name = properties->fields;
-
- if ( CAL_PROPERTY_CHECK_FLAGS(properties->property_id, CAL_PROPERTY_FLAGS_FILTER) == true)
- {
- break;
- }
-
- if (field_name)
- {
- len += snprintf(out_projection+len, sizeof(out_projection)-len, ", %s", field_name);
- }
- }
-
- *projection = strdup(out_projection);
-
- return CALENDAR_ERROR_NONE;
+ int i = 0;
+ int len = 0;
+ const char *field_name;
+ char out_projection[CAL_DB_SQL_MAX_LEN] = {0};
+ cal_query_s *query_s = NULL;
+ cal_property_info_s *properties = NULL;
+
+ retv_if(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER);
+ query_s = (cal_query_s *)query;
+
+ properties = &(query_s->properties[0]);
+ field_name = properties->fields;
+ if (field_name)
+ len += snprintf(out_projection+len, sizeof(out_projection)-len, "%s", field_name);
+
+ if (len >= sizeof(out_projection))
+ {
+ ERR("buf len max");
+ return CALENDAR_ERROR_SYSTEM;
+ }
+
+ for (i=1;i<query_s->property_count;i++)
+ {
+ properties = &(query_s->properties[i]);
+ field_name = properties->fields;
+
+ if ( CAL_PROPERTY_CHECK_FLAGS(properties->property_id, CAL_PROPERTY_FLAGS_FILTER) == true)
+ {
+ break;
+ }
+
+ if (field_name)
+ {
+ len += snprintf(out_projection+len, sizeof(out_projection)-len, ", %s", field_name);
+ if (len >= sizeof(out_projection))
+ {
+ ERR("buf len max");
+ return CALENDAR_ERROR_SYSTEM;
+ }
+ }
+ }
+
+ *projection = strdup(out_projection);
+
+ return CALENDAR_ERROR_NONE;
}
*/
static void __cal_db_timezone_get_stmt(sqlite3_stmt *stmt,calendar_record_h record);
static void __cal_db_timezone_get_property_stmt(sqlite3_stmt *stmt,
- unsigned int property, int stmt_count, calendar_record_h record);
+ unsigned int property, int stmt_count, calendar_record_h record);
static void __cal_db_timezone_get_projection_stmt(sqlite3_stmt *stmt,
- const unsigned int *projection, const int projection_count,
- calendar_record_h record);
+ const unsigned int *projection, const int projection_count,
+ calendar_record_h record);
static void __cal_db_timezone_get_stmt(sqlite3_stmt *stmt,calendar_record_h record);
static int __cal_db_timezone_update_projection(calendar_record_h record);
cal_db_plugin_cb_s _cal_db_timezone_plugin_cb = {
- .is_query_only=false,
- .insert_record=__cal_db_timezone_insert_record,
- .get_record=__cal_db_timezone_get_record,
- .update_record=__cal_db_timezone_update_record,
- .delete_record=__cal_db_timezone_delete_record,
- .get_all_records=__cal_db_timezone_get_all_records,
- .get_records_with_query=__cal_db_timezone_get_records_with_query,
- .insert_records=__cal_db_timezone_insert_records,
- .update_records=__cal_db_timezone_update_records,
- .delete_records=__cal_db_timezone_delete_records,
- .get_count=__cal_db_timezone_get_count,
- .get_count_with_query=__cal_db_timezone_get_count_with_query,
- .replace_record = __cal_db_timezone_replace_record,
- .replace_records = __cal_db_timezone_replace_records
+ .is_query_only=false,
+ .insert_record=__cal_db_timezone_insert_record,
+ .get_record=__cal_db_timezone_get_record,
+ .update_record=__cal_db_timezone_update_record,
+ .delete_record=__cal_db_timezone_delete_record,
+ .get_all_records=__cal_db_timezone_get_all_records,
+ .get_records_with_query=__cal_db_timezone_get_records_with_query,
+ .insert_records=__cal_db_timezone_insert_records,
+ .update_records=__cal_db_timezone_update_records,
+ .delete_records=__cal_db_timezone_delete_records,
+ .get_count=__cal_db_timezone_get_count,
+ .get_count_with_query=__cal_db_timezone_get_count_with_query,
+ .replace_record = __cal_db_timezone_replace_record,
+ .replace_records = __cal_db_timezone_replace_records
};
static int __cal_db_timezone_insert_record( calendar_record_h record, int* id )
{
- int ret = CALENDAR_ERROR_NONE;
- int index;
- int calendar_book_id = 0;
- char query[CAL_DB_SQL_MAX_LEN];
- sqlite3_stmt *stmt;
- cal_timezone_s* timezone = (cal_timezone_s*)(record);
- calendar_record_h record_calendar = NULL;
- cal_db_util_error_e dbret = CAL_DB_OK;
-
- retv_if(NULL == timezone, CALENDAR_ERROR_INVALID_PARAMETER);
-
- ret = calendar_record_get_int(record,
- _calendar_timezone.calendar_book_id, &calendar_book_id);
- DBG("calendar_book_id(%d)", calendar_book_id);
-
- ret = calendar_db_get_record(_calendar_book._uri,
- calendar_book_id, &record_calendar);
- retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_INVALID_PARAMETER, "calendar_book_id is invalid");
- calendar_record_destroy(record_calendar, true);
+ int ret = CALENDAR_ERROR_NONE;
+ int index;
+ int calendar_book_id = 0;
+ char query[CAL_DB_SQL_MAX_LEN];
+ sqlite3_stmt *stmt;
+ cal_timezone_s* timezone = (cal_timezone_s*)(record);
+ calendar_record_h record_calendar = NULL;
+ cal_db_util_error_e dbret = CAL_DB_OK;
+
+ retv_if(NULL == timezone, CALENDAR_ERROR_INVALID_PARAMETER);
+
+ ret = calendar_record_get_int(record,
+ _calendar_timezone.calendar_book_id, &calendar_book_id);
+ DBG("calendar_book_id(%d)", calendar_book_id);
+
+ ret = _cal_db_get_record(_calendar_book._uri,
+ calendar_book_id, &record_calendar);
+ retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_INVALID_PARAMETER, "calendar_book_id is invalid");
+ calendar_record_destroy(record_calendar, true);
// start >>>>> check if we already have
-/*
- if (timezone->standard_name == NULL || strlen(timezone->standard_name) == 0)
- {
+ /*
+ if (timezone->standard_name == NULL || strlen(timezone->standard_name) == 0)
+ {
ERR("No timezone starndard name");
return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-*/
+ }
+ */
if (timezone->standard_name)
{
snprintf(query, sizeof(query), "SELECT count(*), id FROM %s "
}
// if we don't have
- snprintf(query, sizeof(query), "INSERT INTO %s(tz_offset_from_gmt ,standard_name, "
- "std_start_month ,std_start_position_of_week ,std_start_day, "
- "std_start_hour ,standard_bias ,day_light_name ,day_light_start_month, "
- "day_light_start_position_of_week ,day_light_start_day, "
- "day_light_start_hour ,day_light_bias, calendar_id) "
- "VALUES(%d,?,%d,%d,%d,%d,%d,?,%d,%d,%d,%d,%d,%d)",
- CAL_TABLE_TIMEZONE,
- timezone->tz_offset_from_gmt,
- timezone->std_start_month,
- timezone->std_start_position_of_week,
- timezone->std_start_day,
- timezone->std_start_hour,
- timezone->standard_bias,
- timezone->day_light_start_month,
- timezone->day_light_start_position_of_week,
- timezone->day_light_start_day,
- timezone->day_light_start_hour,
- timezone->day_light_bias,
- timezone->calendar_id);
-
- stmt = _cal_db_util_query_prepare(query);
- retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "_cal_db_util_query_prepare() Failed");
-
- if (timezone->standard_name)
- _cal_db_util_stmt_bind_text(stmt, 1, timezone->standard_name);
-
- if (timezone->day_light_name)
- _cal_db_util_stmt_bind_text(stmt, 2, timezone->day_light_name);
-
- dbret = _cal_db_util_stmt_step(stmt);
- if (CAL_DB_DONE != dbret)
+ snprintf(query, sizeof(query), "INSERT INTO %s(tz_offset_from_gmt ,standard_name, "
+ "std_start_month ,std_start_position_of_week ,std_start_day, "
+ "std_start_hour ,standard_bias ,day_light_name ,day_light_start_month, "
+ "day_light_start_position_of_week ,day_light_start_day, "
+ "day_light_start_hour ,day_light_bias, calendar_id) "
+ "VALUES(%d,?,%d,%d,%d,%d,%d,?,%d,%d,%d,%d,%d,%d)",
+ CAL_TABLE_TIMEZONE,
+ timezone->tz_offset_from_gmt,
+ timezone->std_start_month,
+ timezone->std_start_position_of_week,
+ timezone->std_start_day,
+ timezone->std_start_hour,
+ timezone->standard_bias,
+ timezone->day_light_start_month,
+ timezone->day_light_start_position_of_week,
+ timezone->day_light_start_day,
+ timezone->day_light_start_hour,
+ timezone->day_light_bias,
+ timezone->calendar_id);
+
+ stmt = _cal_db_util_query_prepare(query);
+ retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "_cal_db_util_query_prepare() Failed");
+
+ if (timezone->standard_name)
+ _cal_db_util_stmt_bind_text(stmt, 1, timezone->standard_name);
+
+ if (timezone->day_light_name)
+ _cal_db_util_stmt_bind_text(stmt, 2, timezone->day_light_name);
+
+ dbret = _cal_db_util_stmt_step(stmt);
+ if (CAL_DB_DONE != dbret)
{
- sqlite3_finalize(stmt);
- ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
+ sqlite3_finalize(stmt);
+ ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
- index = _cal_db_util_last_insert_id();
- sqlite3_finalize(stmt);
+ }
+ index = _cal_db_util_last_insert_id();
+ sqlite3_finalize(stmt);
- //_cal_record_set_int(record, _calendar_timezone.id,index);
- if (id)
- {
- *id = index;
- }
+ //_cal_record_set_int(record, _calendar_timezone.id,index);
+ if (id)
+ {
+ *id = index;
+ }
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_timezone_get_record( int id, calendar_record_h* out_record )
{
- cal_timezone_s *timezone=NULL;
- char query[CAL_DB_SQL_MAX_LEN];
- sqlite3_stmt *stmt = NULL;
- cal_db_util_error_e dbret = CAL_DB_OK;
- int ret = 0;
-
- ret = calendar_record_create( _calendar_timezone._uri ,out_record);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("record create fail");
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
-
- timezone = (cal_timezone_s*)(*out_record);
-
- snprintf(query, sizeof(query), "SELECT * FROM %s WHERE id = %d AND "
- "calendar_id IN (select id from %s where deleted = 0)",
- CAL_TABLE_TIMEZONE, id,
- CAL_TABLE_CALENDAR);
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() Failed");
- calendar_record_destroy(*out_record, true);
+ char query[CAL_DB_SQL_MAX_LEN];
+ sqlite3_stmt *stmt = NULL;
+ cal_db_util_error_e dbret = CAL_DB_OK;
+ int ret = 0;
+
+ ret = calendar_record_create( _calendar_timezone._uri ,out_record);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("record create fail");
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+
+ snprintf(query, sizeof(query), "SELECT * FROM %s WHERE id = %d AND "
+ "calendar_id IN (select id from %s where deleted = 0)",
+ CAL_TABLE_TIMEZONE, id,
+ CAL_TABLE_CALENDAR);
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt)
+ {
+ ERR("_cal_db_util_query_prepare() Failed");
+ calendar_record_destroy(*out_record, true);
*out_record = NULL;
- return CALENDAR_ERROR_DB_FAILED;
- }
+ return CALENDAR_ERROR_DB_FAILED;
+ }
- dbret = _cal_db_util_stmt_step(stmt);
- if (CAL_DB_ROW != dbret)
+ dbret = _cal_db_util_stmt_step(stmt);
+ if (CAL_DB_ROW != dbret)
{
- ERR("_cal_db_util_stmt_step() failed(%d)", dbret);
- sqlite3_finalize(stmt);
- calendar_record_destroy(*out_record, true);
+ ERR("_cal_db_util_stmt_step() failed(%d)", dbret);
+ sqlite3_finalize(stmt);
+ calendar_record_destroy(*out_record, true);
*out_record = NULL;
switch (dbret)
{
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
+ }
- __cal_db_timezone_get_stmt(stmt,*out_record);
+ __cal_db_timezone_get_stmt(stmt,*out_record);
- sqlite3_finalize(stmt);
- stmt = NULL;
+ sqlite3_finalize(stmt);
+ stmt = NULL;
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_timezone_update_record( calendar_record_h record )
{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
- cal_timezone_s* timezone_info = (cal_timezone_s*)(record);
- cal_db_util_error_e dbret = CAL_DB_OK;
-
- retv_if(NULL == timezone_info, CALENDAR_ERROR_INVALID_PARAMETER);
-
- if (timezone_info->common.properties_flags != NULL)
- {
- return __cal_db_timezone_update_projection(record);
- }
-
- sprintf(query, "UPDATE %s SET "
- "tz_offset_from_gmt=%d,"
- "standard_name=?,"
- "std_start_month=%d,"
- "std_start_position_of_week=%d,"
- "std_start_day=%d,"
- "std_start_hour=%d,"
- "standard_bias=%d,"
- "day_light_name=?,"
- "day_light_start_month=%d,"
- "day_light_start_position_of_week=%d,"
- "day_light_start_day=%d,"
- "day_light_start_hour=%d,"
- "day_light_bias=%d, "
- "calendar_id=%d "
- "WHERE id = %d",
- CAL_TABLE_TIMEZONE,
- timezone_info->tz_offset_from_gmt,
- timezone_info->std_start_month,
- timezone_info->std_start_position_of_week,
- timezone_info->std_start_day,
- timezone_info->std_start_hour,
- timezone_info->standard_bias,
- timezone_info->day_light_start_month,
- timezone_info->day_light_start_position_of_week,
- timezone_info->day_light_start_day,
- timezone_info->day_light_start_hour,
- timezone_info->day_light_bias,
- timezone_info->calendar_id,
- timezone_info->index);
-
- stmt = _cal_db_util_query_prepare(query);
- retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "cal_q_cal_db_util_query_prepareuery_prepare() Failed");
-
- if (timezone_info->standard_name)
- _cal_db_util_stmt_bind_text(stmt, 1, timezone_info->standard_name);
-
- if (timezone_info->day_light_name)
- _cal_db_util_stmt_bind_text(stmt, 2, timezone_info->day_light_name);
-
- dbret = _cal_db_util_stmt_step(stmt);
- if (CAL_DB_DONE != dbret)
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+ cal_timezone_s* timezone_info = (cal_timezone_s*)(record);
+ cal_db_util_error_e dbret = CAL_DB_OK;
+
+ retv_if(NULL == timezone_info, CALENDAR_ERROR_INVALID_PARAMETER);
+
+ if (timezone_info->common.properties_flags != NULL)
{
- sqlite3_finalize(stmt);
- ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
+ return __cal_db_timezone_update_projection(record);
+ }
+
+ snprintf(query, sizeof(query), "UPDATE %s SET "
+ "tz_offset_from_gmt=%d,"
+ "standard_name=?,"
+ "std_start_month=%d,"
+ "std_start_position_of_week=%d,"
+ "std_start_day=%d,"
+ "std_start_hour=%d,"
+ "standard_bias=%d,"
+ "day_light_name=?,"
+ "day_light_start_month=%d,"
+ "day_light_start_position_of_week=%d,"
+ "day_light_start_day=%d,"
+ "day_light_start_hour=%d,"
+ "day_light_bias=%d, "
+ "calendar_id=%d "
+ "WHERE id = %d",
+ CAL_TABLE_TIMEZONE,
+ timezone_info->tz_offset_from_gmt,
+ timezone_info->std_start_month,
+ timezone_info->std_start_position_of_week,
+ timezone_info->std_start_day,
+ timezone_info->std_start_hour,
+ timezone_info->standard_bias,
+ timezone_info->day_light_start_month,
+ timezone_info->day_light_start_position_of_week,
+ timezone_info->day_light_start_day,
+ timezone_info->day_light_start_hour,
+ timezone_info->day_light_bias,
+ timezone_info->calendar_id,
+ timezone_info->index);
+
+ stmt = _cal_db_util_query_prepare(query);
+ retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "cal_q_cal_db_util_query_prepareuery_prepare() Failed");
+
+ if (timezone_info->standard_name)
+ _cal_db_util_stmt_bind_text(stmt, 1, timezone_info->standard_name);
+
+ if (timezone_info->day_light_name)
+ _cal_db_util_stmt_bind_text(stmt, 2, timezone_info->day_light_name);
+
+ dbret = _cal_db_util_stmt_step(stmt);
+ if (CAL_DB_DONE != dbret)
+ {
+ sqlite3_finalize(stmt);
+ ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
- sqlite3_finalize(stmt);
+ }
+ sqlite3_finalize(stmt);
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_timezone_delete_record( int id )
{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- cal_db_util_error_e dbret = CAL_DB_OK;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ cal_db_util_error_e dbret = CAL_DB_OK;
- snprintf(query, sizeof(query), "DELETE FROM %s WHERE id = %d",
- CAL_TABLE_TIMEZONE, id);
- dbret = _cal_db_util_query_exec(query);
+ snprintf(query, sizeof(query), "DELETE FROM %s WHERE id = %d",
+ CAL_TABLE_TIMEZONE, id);
+ dbret = _cal_db_util_query_exec(query);
if(CAL_DB_OK != dbret)
{
- ERR("_cal_db_util_query_exec() Failed(%d)", dbret);
+ ERR("_cal_db_util_query_exec() Failed(%d)", dbret);
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
-
- return CALENDAR_ERROR_NONE;
+ }
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_timezone_replace_record(calendar_record_h record, int id)
{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
- cal_timezone_s* timezone_info = (cal_timezone_s*)(record);
- cal_db_util_error_e dbret = CAL_DB_OK;
-
- retv_if(NULL == timezone_info, CALENDAR_ERROR_INVALID_PARAMETER);
- timezone_info->index = id;
-
- if (timezone_info->common.properties_flags != NULL)
- {
- return __cal_db_timezone_update_projection(record);
- }
-
- sprintf(query, "UPDATE %s SET "
- "tz_offset_from_gmt=%d,"
- "standard_name=?,"
- "std_start_month=%d,"
- "std_start_position_of_week=%d,"
- "std_start_day=%d,"
- "std_start_hour=%d,"
- "standard_bias=%d,"
- "day_light_name=?,"
- "day_light_start_month=%d,"
- "day_light_start_position_of_week=%d,"
- "day_light_start_day=%d,"
- "day_light_start_hour=%d,"
- "day_light_bias=%d, "
- "calendar_id=%d "
- "WHERE id = %d",
- CAL_TABLE_TIMEZONE,
- timezone_info->tz_offset_from_gmt,
- timezone_info->std_start_month,
- timezone_info->std_start_position_of_week,
- timezone_info->std_start_day,
- timezone_info->std_start_hour,
- timezone_info->standard_bias,
- timezone_info->day_light_start_month,
- timezone_info->day_light_start_position_of_week,
- timezone_info->day_light_start_day,
- timezone_info->day_light_start_hour,
- timezone_info->day_light_bias,
- timezone_info->calendar_id,
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+ cal_timezone_s* timezone_info = (cal_timezone_s*)(record);
+ cal_db_util_error_e dbret = CAL_DB_OK;
+
+ retv_if(NULL == timezone_info, CALENDAR_ERROR_INVALID_PARAMETER);
+ timezone_info->index = id;
+
+ if (timezone_info->common.properties_flags != NULL)
+ {
+ return __cal_db_timezone_update_projection(record);
+ }
+
+ snprintf(query, sizeof(query), "UPDATE %s SET "
+ "tz_offset_from_gmt=%d,"
+ "standard_name=?,"
+ "std_start_month=%d,"
+ "std_start_position_of_week=%d,"
+ "std_start_day=%d,"
+ "std_start_hour=%d,"
+ "standard_bias=%d,"
+ "day_light_name=?,"
+ "day_light_start_month=%d,"
+ "day_light_start_position_of_week=%d,"
+ "day_light_start_day=%d,"
+ "day_light_start_hour=%d,"
+ "day_light_bias=%d, "
+ "calendar_id=%d "
+ "WHERE id = %d",
+ CAL_TABLE_TIMEZONE,
+ timezone_info->tz_offset_from_gmt,
+ timezone_info->std_start_month,
+ timezone_info->std_start_position_of_week,
+ timezone_info->std_start_day,
+ timezone_info->std_start_hour,
+ timezone_info->standard_bias,
+ timezone_info->day_light_start_month,
+ timezone_info->day_light_start_position_of_week,
+ timezone_info->day_light_start_day,
+ timezone_info->day_light_start_hour,
+ timezone_info->day_light_bias,
+ timezone_info->calendar_id,
id);
- stmt = _cal_db_util_query_prepare(query);
- retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "cal_q_cal_db_util_query_prepareuery_prepare() Failed");
+ stmt = _cal_db_util_query_prepare(query);
+ retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "cal_q_cal_db_util_query_prepareuery_prepare() Failed");
- if (timezone_info->standard_name)
- _cal_db_util_stmt_bind_text(stmt, 1, timezone_info->standard_name);
+ if (timezone_info->standard_name)
+ _cal_db_util_stmt_bind_text(stmt, 1, timezone_info->standard_name);
- if (timezone_info->day_light_name)
- _cal_db_util_stmt_bind_text(stmt, 2, timezone_info->day_light_name);
+ if (timezone_info->day_light_name)
+ _cal_db_util_stmt_bind_text(stmt, 2, timezone_info->day_light_name);
- dbret = _cal_db_util_stmt_step(stmt);
- sqlite3_finalize(stmt);
- if (CAL_DB_DONE != dbret)
+ dbret = _cal_db_util_stmt_step(stmt);
+ sqlite3_finalize(stmt);
+ if (CAL_DB_DONE != dbret)
{
- ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
+ ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
+ }
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_timezone_get_all_records( int offset, int limit, calendar_list_h* out_list )
{
- int ret = CALENDAR_ERROR_NONE;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- char offsetquery[CAL_DB_SQL_MAX_LEN] = {0};
- char limitquery[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
-
- retvm_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- ret = calendar_list_create(out_list);
-
- retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- if (offset > 0)
- {
- snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
- }
- if (limit > 0)
- {
- snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
- }
- snprintf(query, sizeof(query), "SELECT * FROM %s where "
- "calendar_id IN (select id from %s where deleted = 0) "
- "%s %s",
- CAL_TABLE_TIMEZONE,
- CAL_TABLE_CALENDAR,
- limitquery,
- offsetquery);
-
- stmt = _cal_db_util_query_prepare(query);
-
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() Failed");
- calendar_list_destroy(*out_list, true);
+ int ret = CALENDAR_ERROR_NONE;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ char offsetquery[CAL_DB_SQL_MAX_LEN] = {0};
+ char limitquery[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+
+ retvm_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ ret = calendar_list_create(out_list);
+
+ retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ if (offset > 0)
+ {
+ snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
+ }
+ if (limit > 0)
+ {
+ snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
+ }
+ snprintf(query, sizeof(query), "SELECT * FROM %s where "
+ "calendar_id IN (select id from %s where deleted = 0) "
+ "%s %s",
+ CAL_TABLE_TIMEZONE,
+ CAL_TABLE_CALENDAR,
+ limitquery,
+ offsetquery);
+
+ stmt = _cal_db_util_query_prepare(query);
+
+ if (NULL == stmt)
+ {
+ ERR("_cal_db_util_query_prepare() Failed");
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- return CALENDAR_ERROR_DB_FAILED;
- }
-
- while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- calendar_record_h record;
- // stmt -> record
- ret = calendar_record_create(_calendar_timezone._uri,&record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ {
+ calendar_record_h record;
+ // stmt -> record
+ ret = calendar_record_create(_calendar_timezone._uri,&record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- sqlite3_finalize(stmt);
- return ret;
- }
- __cal_db_timezone_get_stmt(stmt,record);
-
- ret = calendar_list_add(*out_list,record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+ __cal_db_timezone_get_stmt(stmt,record);
+
+ ret = calendar_list_add(*out_list,record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- calendar_record_destroy(record, true);
- sqlite3_finalize(stmt);
- return ret;
- }
- }
-
- sqlite3_finalize(stmt);
- return CALENDAR_ERROR_NONE;
+ calendar_record_destroy(record, true);
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+ }
+
+ sqlite3_finalize(stmt);
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_timezone_get_records_with_query( calendar_query_h query, int offset, int limit, calendar_list_h* out_list )
{
- cal_query_s *que = NULL;
- int ret = CALENDAR_ERROR_NONE;
- char *condition = NULL;
- char *projection = NULL;
- char *order = NULL;
- GSList *bind_text = NULL, *cursor = NULL;
- char strquery[CAL_DB_SQL_MAX_LEN] = {0};
- int len;
- sqlite3_stmt *stmt = NULL;
- int i = 0;
-
- que = (cal_query_s *)query;
-
- // make filter
- if (que->filter)
- {
- ret = _cal_db_query_create_condition(query,
- &condition, &bind_text);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("filter create fail");
- return ret;
- }
- }
-
- // make projection
- ret = _cal_db_query_create_projection(query, &projection);
-
- // query - projection
- if (projection)
- {
- len = snprintf(strquery, sizeof(strquery), "SELECT %s FROM %s", projection, CAL_TABLE_TIMEZONE);
- }
- else
- {
- len = snprintf(strquery, sizeof(strquery), "SELECT * FROM %s", CAL_TABLE_TIMEZONE);
- }
-
- // query - condition
- if (condition)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " WHERE %s AND "
- "calendar_id IN (select id from %s where deleted = 0)",
- condition,
- CAL_TABLE_CALENDAR);
- }
- else
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " WHERE "
- "calendar_id IN (select id from %s where deleted = 0)",
- CAL_TABLE_CALENDAR);
- }
-
- // ORDER
- ret = _cal_db_query_create_order(query, &order);
- if (order)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " %s", order);
- }
-
- if (0 < limit)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " LIMIT %d", limit);
- if (0 < offset)
- len += snprintf(strquery+len, sizeof(strquery)-len, " OFFSET %d", offset);
- }
-
- // query
- stmt = _cal_db_util_query_prepare(strquery);
- if (NULL == stmt)
- {
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- CAL_DBG("%s",strquery);
-
- // bind text
- if (bind_text)
- {
- len = g_slist_length(bind_text);
- for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
- {
- _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
- }
- }
-
- //
- ret = calendar_list_create(out_list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- ERR("calendar_list_create() Failed");
- sqlite3_finalize(stmt);
- return ret;
- }
-
- while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- calendar_record_h record;
- // stmt -> record
- ret = calendar_record_create(_calendar_timezone._uri,&record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
+ cal_query_s *que = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ char *condition = NULL;
+ char *projection = NULL;
+ char *order = NULL;
+ GSList *bind_text = NULL, *cursor = NULL;
+ char *query_str = NULL;
+ sqlite3_stmt *stmt = NULL;
+ int i = 0;
+
+ que = (cal_query_s *)query;
+
+ // make filter
+ if (que->filter)
+ {
+ ret = _cal_db_query_create_condition(query, &condition, &bind_text);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("filter create fail");
+ return ret;
+ }
+ }
+
+ // make projection
+ ret = _cal_db_query_create_projection(query, &projection);
+
+ // query - projection
+ if (projection)
+ {
+ _cal_db_append_string(&query_str, "SELECT");
+ _cal_db_append_string(&query_str, projection);
+ _cal_db_append_string(&query_str, "FROM");
+ _cal_db_append_string(&query_str, CAL_TABLE_TIMEZONE);
+ CAL_FREE(projection);
+ }
+ else
+ {
+ _cal_db_append_string(&query_str, "SELECT * FROM");
+ _cal_db_append_string(&query_str, CAL_TABLE_TIMEZONE);
+ }
+
+ // query - condition
+ if (condition)
+ {
+ _cal_db_append_string(&query_str, "WHERE");
+ _cal_db_append_string(&query_str, condition);
+ CAL_FREE(condition);
+ _cal_db_append_string(&query_str, "AND calendar_id IN (select id from");
+ _cal_db_append_string(&query_str, CAL_TABLE_CALENDAR);
+ _cal_db_append_string(&query_str, "where deleted = 0)");
+ }
+ else
+ {
+ _cal_db_append_string(&query_str, "WHERE calendar_id IN (select id from");
+ _cal_db_append_string(&query_str, CAL_TABLE_CALENDAR);
+ _cal_db_append_string(&query_str, "where deleted = 0)");
+ }
+
+ // ORDER
+ ret = _cal_db_query_create_order(query, condition, &order);
+ if (order)
+ {
+ _cal_db_append_string(&query_str, order);
+ CAL_FREE(order);
+ }
+
+ char buf[32] = {0};
+ if (0 < limit)
+ {
+ snprintf(buf, sizeof(buf), "LIMIT %d", limit);
+ _cal_db_append_string(&query_str, buf);
+ if (0 < offset)
+ {
+ snprintf(buf, sizeof(buf), "OFFSET %d", offset);
+ _cal_db_append_string(&query_str, buf);
+ }
+ }
+
+ // query
+ stmt = _cal_db_util_query_prepare(query_str);
+ if (NULL == stmt)
+ {
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ ERR("_cal_db_util_query_prepare() Failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ // bind text
+ if (bind_text)
+ {
+ for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
+ {
+ _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
+ }
+ }
+
+ //
+ ret = calendar_list_create(out_list);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ ERR("calendar_list_create() Failed");
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ {
+ calendar_record_h record;
+ // stmt -> record
+ ret = calendar_record_create(_calendar_timezone._uri,&record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
- return ret;
- }
- if (que->projection_count > 0)
- {
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+ if (que->projection_count > 0)
+ {
_cal_record_set_projection(record,
que->projection, que->projection_count, que->property_count);
- __cal_db_timezone_get_projection_stmt(stmt,
+ __cal_db_timezone_get_projection_stmt(stmt,
que->projection, que->projection_count,
- record);
- }
- else
- {
- __cal_db_timezone_get_stmt(stmt,record);
- }
-
- ret = calendar_list_add(*out_list,record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
+ record);
+ }
+ else
+ {
+ __cal_db_timezone_get_stmt(stmt,record);
+ }
+
+ ret = calendar_list_add(*out_list,record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- calendar_record_destroy(record, true);
-
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
- return ret;
- }
- }
-
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
-
- return CALENDAR_ERROR_NONE;
+ calendar_record_destroy(record, true);
+
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+ }
+
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ sqlite3_finalize(stmt);
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_timezone_insert_records(const calendar_list_h list, int** ids)
{
- calendar_record_h record;
- int ret = 0;
- int count = 0;
- int i=0;
- int *id = NULL;
-
- ret = calendar_list_get_count(list, &count);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("list get error");
- return ret;
- }
-
- id = calloc(1, sizeof(int)*count);
-
- retvm_if(NULL == id, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc fail");
-
- ret = calendar_list_first(list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("list first error");
- CAL_FREE(id);
- return ret;
- }
- do
- {
- if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
- {
- if( __cal_db_timezone_insert_record(record, &id[i]) != CALENDAR_ERROR_NONE)
- {
- ERR("db insert error");
- CAL_FREE(id);
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- i++;
- } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
-
- if(ids)
- {
- *ids = id;
- }
- else
- {
- CAL_FREE(id);
- }
-
- return CALENDAR_ERROR_NONE;
+ calendar_record_h record;
+ int ret = 0;
+ int count = 0;
+ int i=0;
+ int *id = NULL;
+
+ ret = calendar_list_get_count(list, &count);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("list get error");
+ return ret;
+ }
+
+ id = calloc(1, sizeof(int)*count);
+
+ retvm_if(NULL == id, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc fail");
+
+ ret = calendar_list_first(list);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("list first error");
+ CAL_FREE(id);
+ return ret;
+ }
+ do
+ {
+ if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
+ {
+ if( __cal_db_timezone_insert_record(record, &id[i]) != CALENDAR_ERROR_NONE)
+ {
+ ERR("db insert error");
+ CAL_FREE(id);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ i++;
+ } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+
+ if(ids)
+ {
+ *ids = id;
+ }
+ else
+ {
+ CAL_FREE(id);
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_timezone_update_records(const calendar_list_h list)
{
- calendar_record_h record;
- int ret = 0;
-
- ret = calendar_list_first(list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("list first error");
- return ret;
- }
- do
- {
- if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
- {
- if( __cal_db_timezone_update_record(record) != CALENDAR_ERROR_NONE)
- {
- ERR("db insert error");
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
-
- return CALENDAR_ERROR_NONE;
+ calendar_record_h record;
+ int ret = 0;
+
+ ret = calendar_list_first(list);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("list first error");
+ return ret;
+ }
+ do
+ {
+ if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
+ {
+ if( __cal_db_timezone_update_record(record) != CALENDAR_ERROR_NONE)
+ {
+ ERR("db insert error");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_timezone_delete_records(int ids[], int count)
{
- int i=0;
- for(i=0;i<count;i++)
- {
- if (__cal_db_timezone_delete_record(ids[i]) != CALENDAR_ERROR_NONE)
- {
- ERR("delete failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- return CALENDAR_ERROR_NONE;
+ int i = 0;
+
+ for(i = 0; i < count; i++)
+ {
+ if (__cal_db_timezone_delete_record(ids[i]) != CALENDAR_ERROR_NONE)
+ {
+ ERR("delete failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_timezone_replace_records(const calendar_list_h list, int ids[], int count)
{
- calendar_record_h record;
+ calendar_record_h record;
int i;
- int ret = 0;
+ int ret = 0;
if (NULL == list)
{
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- ret = calendar_list_first(list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("list first error");
- return ret;
- }
+ ret = calendar_list_first(list);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("list first error");
+ return ret;
+ }
for (i = 0; i < count; i++)
- {
- if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
- {
- if( __cal_db_timezone_replace_record(record, ids[i]) != CALENDAR_ERROR_NONE)
- {
- ERR("db insert error");
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
+ {
+ if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
+ {
+ if( __cal_db_timezone_replace_record(record, ids[i]) != CALENDAR_ERROR_NONE)
+ {
+ ERR("db insert error");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
if (CALENDAR_ERROR_NO_DATA != calendar_list_next(list))
{
break;
}
- }
+ }
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_timezone_get_count(int *out_count)
{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- int count = 0;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ int count = 0;
int ret;
- retvm_if(NULL == out_count, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ retvm_if(NULL == out_count, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- snprintf(query, sizeof(query), "SELECT count(*) FROM %s where "
- "calendar_id IN (select id from %s where deleted = 0)",
- CAL_TABLE_TIMEZONE,
- CAL_TABLE_CALENDAR);
+ snprintf(query, sizeof(query), "SELECT count(*) FROM %s where "
+ "calendar_id IN (select id from %s where deleted = 0)",
+ CAL_TABLE_TIMEZONE,
+ CAL_TABLE_CALENDAR);
- ret = _cal_db_util_query_get_first_int_result(query, NULL, &count);
+ ret = _cal_db_util_query_get_first_int_result(query, NULL, &count);
if (CALENDAR_ERROR_NONE != ret)
{
ERR("_cal_db_util_query_get_first_int_result() failed");
return ret;
}
- CAL_DBG("%s=%d",query,count);
+ CAL_DBG("%s=%d",query,count);
- *out_count = count;
- return CALENDAR_ERROR_NONE;
+ *out_count = count;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_timezone_get_count_with_query(calendar_query_h query, int *out_count)
{
- cal_query_s *que = NULL;
- int ret = CALENDAR_ERROR_NONE;
- char *condition = NULL;
- char strquery[CAL_DB_SQL_MAX_LEN] = {0};
- int len;
- char *table_name;
- int count = 0;
- GSList *bind_text = NULL;
-
- que = (cal_query_s *)query;
-
- if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_TIMEZONE))
- {
- table_name = SAFE_STRDUP(CAL_TABLE_TIMEZONE);
- }
- else
- {
- ERR("uri(%s) not support get records with query",que->view_uri);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- // make filter
- if (que->filter)
- {
- ret = _cal_db_query_create_condition(query, &condition, &bind_text);
- if (ret != CALENDAR_ERROR_NONE)
- {
- CAL_FREE(table_name);
- ERR("filter create fail");
- return ret;
- }
- }
-
- // query - select from
-
- len = snprintf(strquery, sizeof(strquery), "SELECT count(*) FROM %s", table_name);
- CAL_FREE(table_name);
-
- // query - condition
- if (condition)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " WHERE %s AND "
- "calendar_id IN (select id from %s where deleted = 0)",
- condition,
- CAL_TABLE_CALENDAR);
- }
- else
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " WHERE "
- "calendar_id IN (select id from %s where deleted = 0)",
- CAL_TABLE_CALENDAR);
- }
-
- // query
- ret = _cal_db_util_query_get_first_int_result(strquery, bind_text, &count);
+ cal_query_s *que = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ char *condition = NULL;
+ char *query_str = NULL;
+ char *table_name;
+ int count = 0;
+ GSList *bind_text = NULL;
+
+ que = (cal_query_s *)query;
+
+ if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_TIMEZONE))
+ {
+ table_name = SAFE_STRDUP(CAL_TABLE_TIMEZONE);
+ }
+ else
+ {
+ ERR("uri(%s) not support get records with query",que->view_uri);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ // make filter
+ if (que->filter)
+ {
+ ret = _cal_db_query_create_condition(query, &condition, &bind_text);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ CAL_FREE(table_name);
+ ERR("filter create fail");
+ return ret;
+ }
+ }
+
+ // query - select from
+ _cal_db_append_string(&query_str, "SELECT count(*) FROM");
+ _cal_db_append_string(&query_str, table_name);
+ CAL_FREE(table_name);
+
+ // query - condition
+ if (condition)
+ {
+ _cal_db_append_string(&query_str, "WHERE");
+ _cal_db_append_string(&query_str, condition);
+ _cal_db_append_string(&query_str, "AND calendar_id IN (select id from");
+ _cal_db_append_string(&query_str, CAL_TABLE_CALENDAR);
+ _cal_db_append_string(&query_str, "where deleted = 0)");
+ CAL_FREE(condition);
+ }
+ else
+ {
+ _cal_db_append_string(&query_str, "WHERE calendar_id IN (select id from");
+ _cal_db_append_string(&query_str, CAL_TABLE_CALENDAR);
+ _cal_db_append_string(&query_str, "where deleted = 0)");
+ }
+
+ // query
+ ret = _cal_db_util_query_get_first_int_result(query_str, bind_text, &count);
if (CALENDAR_ERROR_NONE != ret)
{
ERR("_cal_db_util_query_get_first_int_result() failed");
if (bind_text)
{
- g_slist_free(bind_text);
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
}
- CAL_FREE(condition);
+ CAL_FREE(query_str);
return ret;
}
- CAL_DBG("%s=%d",strquery,count);
+ CAL_DBG("%s=%d",query_str,count);
- *out_count = count;
+ *out_count = count;
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- return CALENDAR_ERROR_NONE;
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ return CALENDAR_ERROR_NONE;
}
static void __cal_db_timezone_get_stmt(sqlite3_stmt *stmt,calendar_record_h record)
{
- cal_timezone_s* timezone = (cal_timezone_s*)(record);
- int count = 0;
- const unsigned char *temp;
+ cal_timezone_s* timezone = (cal_timezone_s*)(record);
+ int count = 0;
+ const unsigned char *temp;
- timezone->index = sqlite3_column_int(stmt, count++);
- timezone->tz_offset_from_gmt = sqlite3_column_int(stmt, count++);
+ timezone->index = sqlite3_column_int(stmt, count++);
+ timezone->tz_offset_from_gmt = sqlite3_column_int(stmt, count++);
- temp = sqlite3_column_text(stmt, count++);
- timezone->standard_name = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ timezone->standard_name = SAFE_STRDUP(temp);
- timezone->std_start_month = sqlite3_column_int(stmt, count++);
- timezone->std_start_position_of_week = sqlite3_column_int(stmt, count++);
- timezone->std_start_day = sqlite3_column_int(stmt, count++);
- timezone->std_start_hour = sqlite3_column_int(stmt, count++);
- timezone->standard_bias = sqlite3_column_int(stmt, count++);
+ timezone->std_start_month = sqlite3_column_int(stmt, count++);
+ timezone->std_start_position_of_week = sqlite3_column_int(stmt, count++);
+ timezone->std_start_day = sqlite3_column_int(stmt, count++);
+ timezone->std_start_hour = sqlite3_column_int(stmt, count++);
+ timezone->standard_bias = sqlite3_column_int(stmt, count++);
- temp = sqlite3_column_text(stmt, count++);
- timezone->day_light_name = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ timezone->day_light_name = SAFE_STRDUP(temp);
- timezone->day_light_start_month = sqlite3_column_int(stmt, count++);
- timezone->day_light_start_position_of_week = sqlite3_column_int(stmt, count++);
- timezone->day_light_start_day = sqlite3_column_int(stmt, count++);
- timezone->day_light_start_hour = sqlite3_column_int(stmt, count++);
- timezone->day_light_bias = sqlite3_column_int(stmt, count++);
+ timezone->day_light_start_month = sqlite3_column_int(stmt, count++);
+ timezone->day_light_start_position_of_week = sqlite3_column_int(stmt, count++);
+ timezone->day_light_start_day = sqlite3_column_int(stmt, count++);
+ timezone->day_light_start_hour = sqlite3_column_int(stmt, count++);
+ timezone->day_light_bias = sqlite3_column_int(stmt, count++);
- timezone->calendar_id = sqlite3_column_int(stmt, count++);
+ timezone->calendar_id = sqlite3_column_int(stmt, count++);
}
static void __cal_db_timezone_get_property_stmt(sqlite3_stmt *stmt,
- unsigned int property, int stmt_count, calendar_record_h record)
+ unsigned int property, int stmt_count, calendar_record_h record)
{
- cal_timezone_s* timezone = (cal_timezone_s*)(record);
- const unsigned char *temp;
-
- switch(property)
- {
- case CAL_PROPERTY_TIMEZONE_ID:
- timezone->index = sqlite3_column_int(stmt, stmt_count);
- break;
- case CAL_PROPERTY_TIMEZONE_TZ_OFFSET_FROM_GMT:
- timezone->tz_offset_from_gmt = sqlite3_column_int(stmt, stmt_count);
- break;
- case CAL_PROPERTY_TIMEZONE_STANDARD_NAME:
- temp = sqlite3_column_text(stmt, stmt_count);
- timezone->standard_name = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_TIMEZONE_STD_START_MONTH:
- timezone->std_start_month = sqlite3_column_int(stmt, stmt_count);
- break;
- case CAL_PROPERTY_TIMEZONE_STD_START_POSITION_OF_WEEK:
- timezone->std_start_position_of_week = sqlite3_column_int(stmt, stmt_count);
- break;
- case CAL_PROPERTY_TIMEZONE_STD_START_DAY:
- timezone->std_start_day = sqlite3_column_int(stmt, stmt_count);
- break;
- case CAL_PROPERTY_TIMEZONE_STD_START_HOUR:
- timezone->std_start_hour = sqlite3_column_int(stmt, stmt_count);
- break;
- case CAL_PROPERTY_TIMEZONE_STANDARD_BIAS:
- timezone->standard_bias = sqlite3_column_int(stmt, stmt_count);
- break;
- case CAL_PROPERTY_TIMEZONE_DAY_LIGHT_NAME:
- temp = sqlite3_column_text(stmt, stmt_count);
- timezone->day_light_name = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_TIMEZONE_DAY_LIGHT_START_MONTH:
- timezone->day_light_start_month = sqlite3_column_int(stmt, stmt_count);
- break;
- case CAL_PROPERTY_TIMEZONE_DAY_LIGHT_START_POSITION_OF_WEEK:
- timezone->day_light_start_position_of_week = sqlite3_column_int(stmt, stmt_count);
- break;
- case CAL_PROPERTY_TIMEZONE_DAY_LIGHT_START_DAY:
- timezone->day_light_start_day = sqlite3_column_int(stmt, stmt_count);
- break;
- case CAL_PROPERTY_TIMEZONE_DAY_LIGHT_START_HOUR:
- timezone->day_light_start_hour = sqlite3_column_int(stmt, stmt_count);
- break;
- case CAL_PROPERTY_TIMEZONE_DAY_LIGHT_BIAS:
- timezone->day_light_bias = sqlite3_column_int(stmt, stmt_count);
- break;
- case CAL_PROPERTY_TIMEZONE_CALENDAR_ID:
- timezone->calendar_id = sqlite3_column_int(stmt, stmt_count);
- break;
- default:
- sqlite3_column_int(stmt, stmt_count);
- break;
- }
-
- return;
+ cal_timezone_s* timezone = (cal_timezone_s*)(record);
+ const unsigned char *temp;
+
+ switch(property)
+ {
+ case CAL_PROPERTY_TIMEZONE_ID:
+ timezone->index = sqlite3_column_int(stmt, stmt_count);
+ break;
+ case CAL_PROPERTY_TIMEZONE_TZ_OFFSET_FROM_GMT:
+ timezone->tz_offset_from_gmt = sqlite3_column_int(stmt, stmt_count);
+ break;
+ case CAL_PROPERTY_TIMEZONE_STANDARD_NAME:
+ temp = sqlite3_column_text(stmt, stmt_count);
+ timezone->standard_name = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_TIMEZONE_STD_START_MONTH:
+ timezone->std_start_month = sqlite3_column_int(stmt, stmt_count);
+ break;
+ case CAL_PROPERTY_TIMEZONE_STD_START_POSITION_OF_WEEK:
+ timezone->std_start_position_of_week = sqlite3_column_int(stmt, stmt_count);
+ break;
+ case CAL_PROPERTY_TIMEZONE_STD_START_DAY:
+ timezone->std_start_day = sqlite3_column_int(stmt, stmt_count);
+ break;
+ case CAL_PROPERTY_TIMEZONE_STD_START_HOUR:
+ timezone->std_start_hour = sqlite3_column_int(stmt, stmt_count);
+ break;
+ case CAL_PROPERTY_TIMEZONE_STANDARD_BIAS:
+ timezone->standard_bias = sqlite3_column_int(stmt, stmt_count);
+ break;
+ case CAL_PROPERTY_TIMEZONE_DAY_LIGHT_NAME:
+ temp = sqlite3_column_text(stmt, stmt_count);
+ timezone->day_light_name = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_TIMEZONE_DAY_LIGHT_START_MONTH:
+ timezone->day_light_start_month = sqlite3_column_int(stmt, stmt_count);
+ break;
+ case CAL_PROPERTY_TIMEZONE_DAY_LIGHT_START_POSITION_OF_WEEK:
+ timezone->day_light_start_position_of_week = sqlite3_column_int(stmt, stmt_count);
+ break;
+ case CAL_PROPERTY_TIMEZONE_DAY_LIGHT_START_DAY:
+ timezone->day_light_start_day = sqlite3_column_int(stmt, stmt_count);
+ break;
+ case CAL_PROPERTY_TIMEZONE_DAY_LIGHT_START_HOUR:
+ timezone->day_light_start_hour = sqlite3_column_int(stmt, stmt_count);
+ break;
+ case CAL_PROPERTY_TIMEZONE_DAY_LIGHT_BIAS:
+ timezone->day_light_bias = sqlite3_column_int(stmt, stmt_count);
+ break;
+ case CAL_PROPERTY_TIMEZONE_CALENDAR_ID:
+ timezone->calendar_id = sqlite3_column_int(stmt, stmt_count);
+ break;
+ default:
+ sqlite3_column_int(stmt, stmt_count);
+ break;
+ }
+
+ return;
}
static void __cal_db_timezone_get_projection_stmt(sqlite3_stmt *stmt,
- const unsigned int *projection, const int projection_count,
- calendar_record_h record)
+ const unsigned int *projection, const int projection_count,
+ calendar_record_h record)
{
- int i=0;
+ int i=0;
- for(i=0;i<projection_count;i++)
- {
- __cal_db_timezone_get_property_stmt(stmt,projection[i],i,record);
- }
+ for(i=0;i<projection_count;i++)
+ {
+ __cal_db_timezone_get_property_stmt(stmt,projection[i],i,record);
+ }
}
static int __cal_db_timezone_update_projection(calendar_record_h record)
{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
- cal_timezone_s* timezone = (cal_timezone_s*)(record);
- cal_db_util_error_e dbret = CAL_DB_OK;
- int ret = CALENDAR_ERROR_NONE;
- char* set = NULL;
- GSList *bind_text = NULL;
- int len;
- GSList *cursor = NULL;
-
- ret = _cal_db_query_create_projection_update_set(record,&set,&bind_text);
- retv_if(CALENDAR_ERROR_NONE != ret, ret);
-
- snprintf(query, sizeof(query), "UPDATE %s SET %s "
- "WHERE id = %d",
- CAL_TABLE_TIMEZONE,set,
- timezone->index);
-
- CAL_DBG("%s",query);
- stmt = _cal_db_util_query_prepare(query);
- retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "_cal_db_util_query_prepare() Failed");
-
- // bind
- if (bind_text)
- {
- int i = 0;
- len = g_slist_length(bind_text);
- for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
- {
- _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
- }
- }
-
- dbret = _cal_db_util_stmt_step(stmt);
- if (CAL_DB_DONE != dbret)
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+ cal_timezone_s* timezone = (cal_timezone_s*)(record);
+ cal_db_util_error_e dbret = CAL_DB_OK;
+ int ret = CALENDAR_ERROR_NONE;
+ char* set = NULL;
+ GSList *bind_text = NULL;
+ GSList *cursor = NULL;
+
+ ret = _cal_db_query_create_projection_update_set(record,&set,&bind_text);
+ retv_if(CALENDAR_ERROR_NONE != ret, ret);
+
+ snprintf(query, sizeof(query), "UPDATE %s SET %s "
+ "WHERE id = %d",
+ CAL_TABLE_TIMEZONE,set,
+ timezone->index);
+
+ CAL_DBG("%s",query);
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt) {
+ ERR("_cal_db_util_query_prepare() Failed");
+ CAL_FREE(set);
+ if(bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ // bind
+ if (bind_text)
{
- sqlite3_finalize(stmt);
- ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
-
- CAL_FREE(set);
- if(bind_text)
- {
- for (cursor=bind_text; cursor;cursor=cursor->next)
- {
- CAL_FREE(cursor->data);
- }
- g_slist_free(bind_text);
- }
+ int i = 0;
+ for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
+ {
+ _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
+ }
+ }
+
+ dbret = _cal_db_util_stmt_step(stmt);
+ if (CAL_DB_DONE != dbret)
+ {
+ sqlite3_finalize(stmt);
+ ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
+
+ CAL_FREE(set);
+ if(bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
+ }
- sqlite3_finalize(stmt);
+ sqlite3_finalize(stmt);
- CAL_FREE(set);
- if(bind_text)
- {
- for (cursor=bind_text; cursor;cursor=cursor->next)
- {
- CAL_FREE(cursor->data);
- }
- g_slist_free(bind_text);
- }
+ CAL_FREE(set);
+ if(bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
#include <stdlib.h>
#include "calendar_db.h"
-
#include "cal_internal.h"
#include "cal_typedef.h"
#include "cal_view.h"
#include "cal_record.h"
+#include "cal_list.h"
#include "cal_db_util.h"
#include "cal_db.h"
#include "cal_db_alarm.h"
#include "cal_db_attendee.h"
#include "cal_db_extended.h"
+#include "cal_access_control.h"
static int __cal_db_todo_insert_record(calendar_record_h record, int* id);
static int __cal_db_todo_get_record(int id, calendar_record_h* out_record);
/*
* static function
*/
-static void __cal_db_todo_get_stmt(sqlite3_stmt *stmt,bool is_view_table,calendar_record_h record);
+static void __cal_db_todo_get_stmt(sqlite3_stmt *stmt,bool is_view_table,calendar_record_h record, int *extended);
static void __cal_db_todo_get_property_stmt(sqlite3_stmt *stmt,
- unsigned int property, int *stmt_count, calendar_record_h record);
+ unsigned int property, int *stmt_count, calendar_record_h record);
static void __cal_db_todo_get_projection_stmt(sqlite3_stmt *stmt,
- const unsigned int *projection, const int projection_count,
- calendar_record_h record);
+ const unsigned int *projection, const int projection_count,
+ calendar_record_h record);
static int __cal_db_todo_update_dirty(calendar_record_h record);
+static int __cal_db_todo_get_deleted_data(int id, int* calendar_book_id, int* created_ver);
+static bool __cal_db_todo_check_calendar_book_type(calendar_record_h record);
cal_db_plugin_cb_s _cal_db_todo_plugin_cb = {
- .is_query_only = false,
- .insert_record = __cal_db_todo_insert_record,
- .get_record = __cal_db_todo_get_record,
- .update_record = __cal_db_todo_update_record,
- .delete_record = __cal_db_todo_delete_record,
- .get_all_records = __cal_db_todo_get_all_records,
- .get_records_with_query = __cal_db_todo_get_records_with_query,
- .insert_records = __cal_db_todo_insert_records,
- .update_records = __cal_db_todo_update_records,
- .delete_records = __cal_db_todo_delete_records,
- .get_count=__cal_db_todo_get_count,
- .get_count_with_query=__cal_db_todo_get_count_with_query,
- .replace_record = __cal_db_todo_replace_record,
- .replace_records = __cal_db_todo_replace_records
+ .is_query_only = false,
+ .insert_record = __cal_db_todo_insert_record,
+ .get_record = __cal_db_todo_get_record,
+ .update_record = __cal_db_todo_update_record,
+ .delete_record = __cal_db_todo_delete_record,
+ .get_all_records = __cal_db_todo_get_all_records,
+ .get_records_with_query = __cal_db_todo_get_records_with_query,
+ .insert_records = __cal_db_todo_insert_records,
+ .update_records = __cal_db_todo_update_records,
+ .delete_records = __cal_db_todo_delete_records,
+ .get_count=__cal_db_todo_get_count,
+ .get_count_with_query=__cal_db_todo_get_count_with_query,
+ .replace_record = __cal_db_todo_replace_record,
+ .replace_records = __cal_db_todo_replace_records
};
static int __cal_db_todo_insert_record(calendar_record_h record, int* id)
{
- int ret = -1;
- int index = -1;
- int input_ver;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- char dtstart_datetime[32] = {0};
- char dtend_datetime[32] = {0};
- sqlite3_stmt *stmt = NULL;
- cal_todo_s* todo = (cal_todo_s*)(record);
+ int ret = -1;
+ int index = -1;
+ int input_ver;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ char dtstart_datetime[32] = {0};
+ char dtend_datetime[32] = {0};
+ sqlite3_stmt *stmt = NULL;
+ cal_todo_s* todo = (cal_todo_s*)(record);
cal_rrule_s *rrule = NULL;
- cal_db_util_error_e dbret = CAL_DB_OK;
- int tmp = 0;
- int calendar_book_id = 0;
- calendar_record_h record_calendar = NULL;
- int has_alarm = 0;
-
- retv_if(NULL == todo, CALENDAR_ERROR_INVALID_PARAMETER);
-
- ret = calendar_record_get_int(record,
- _calendar_todo.calendar_book_id, &calendar_book_id);
- DBG("calendar_book_id(%d)", calendar_book_id);
-
- ret = calendar_db_get_record(_calendar_book._uri,
- calendar_book_id, &record_calendar);
- retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_INVALID_PARAMETER, "calendar_book_id is invalid");
-
- calendar_record_destroy(record_calendar, true);
-
- has_alarm = _cal_db_alarm_has_alarm(todo->alarm_list);
- input_ver = _cal_db_util_get_next_ver();
- ret = snprintf(query, sizeof(query),
- "INSERT INTO %s ("
- "type, "
- "created_ver, changed_ver, "
- "summary, description, location, categories, "
- "task_status, priority, "
- "sensitivity, uid, "
- "calendar_id, "
- "latitude, longitude, "
- "created_time, completed_time, progress, "
- "dtstart_type, dtstart_utime, dtstart_datetime, dtstart_tzid, "
- "dtend_type, dtend_utime, dtend_datetime, dtend_tzid, "
- "last_mod, rrule_id, "
- "has_alarm, updated, "
- "sync_data1, sync_data2, sync_data3, sync_data4, "
- "organizer_name, organizer_email, has_attendee"
- ") VALUES ( "
- "%d, "
- "%d, %d, "
- "?, ?, ?, ?, "
- "%d, %d, "
- "%d, ?, "
- "%d, "
- "%lf, %lf, "
- "strftime('%%s', 'now'), %lld, %d, "
- "%d, %lld, ?, ?, "
- "%d, %lld, ?, ?, "
- "strftime('%%s', 'now'), %d "
- ", %d, %ld"
- ", ?, ?, ?, ?"
- ", ?, ?, %d"
- ") ",
- CAL_TABLE_SCHEDULE,
- CAL_SCH_TYPE_TODO, /*event->cal_type,*/
- input_ver, input_ver,
- todo->todo_status, todo->priority,
- todo->sensitivity,
- todo->calendar_id,
- todo->latitude, todo->longitude,
- todo->completed_time, todo->progress,
- todo->start.type, todo->start.type == CALENDAR_TIME_UTIME ? todo->start.time.utime : 0,
- todo->due.type, todo->due.type == CALENDAR_TIME_UTIME ? todo->due.time.utime : 0,
- todo->freq > 0 ? 1 : 0,
- has_alarm,
- todo->updated,
- todo->attendee_list ? 1 : 0);
-
- stmt = _cal_db_util_query_prepare(query);
- retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "_cal_db_util_query_prepare() Failed");
-
- int count = 1;
-
- if (todo->summary)
- _cal_db_util_stmt_bind_text(stmt, count, todo->summary);
- count++;
-
- if (todo->description)
- _cal_db_util_stmt_bind_text(stmt, count, todo->description);
- count++;
-
- if (todo->location)
- _cal_db_util_stmt_bind_text(stmt, count, todo->location);
- count++;
-
- if (todo->categories)
- _cal_db_util_stmt_bind_text(stmt, count, todo->categories);
- count++;
-
- if (todo->uid)
- _cal_db_util_stmt_bind_text(stmt, count, todo->uid);
- count++;
+ cal_db_util_error_e dbret = CAL_DB_OK;
+ int tmp = 0;
+ int calendar_book_id = 0;
+ calendar_record_h record_calendar = NULL;
+ int has_alarm = 0;
+
+ retv_if(NULL == todo, CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(false == __cal_db_todo_check_calendar_book_type(record), CALENDAR_ERROR_INVALID_PARAMETER);
+
+ // access control
+ if (_cal_access_control_have_write_permission(todo->calendar_id) == false)
+ {
+ ERR("_cal_access_control_have_write_permission() failed");
+ return CALENDAR_ERROR_PERMISSION_DENIED;
+ }
+
+ ret = calendar_record_get_int(record,
+ _calendar_todo.calendar_book_id, &calendar_book_id);
+ DBG("calendar_book_id(%d)", calendar_book_id);
+
+ ret = _cal_db_get_record(_calendar_book._uri,
+ calendar_book_id, &record_calendar);
+ retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_INVALID_PARAMETER, "calendar_book_id is invalid");
+
+ calendar_record_destroy(record_calendar, true);
+
+ has_alarm = _cal_db_alarm_has_alarm(todo->alarm_list);
+ input_ver = _cal_db_util_get_next_ver();
+ int is_allday = 0;
+ if (CALENDAR_TIME_LOCALTIME == todo->start.type
+ && (0 == todo->start.time.date.hour)
+ && (0 == todo->start.time.date.minute)
+ && (0 == todo->start.time.date.second)
+ && (0 == todo->due.time.date.hour)
+ && (0 == todo->due.time.date.minute)
+ && (0 == todo->due.time.date.second)) {
+ is_allday = 1;
+ }
+
+ ret = snprintf(query, sizeof(query),
+ "INSERT INTO %s ("
+ "type, "
+ "created_ver, changed_ver, "
+ "summary, description, location, categories, "
+ "task_status, priority, "
+ "sensitivity, uid, "
+ "calendar_id, "
+ "latitude, longitude, "
+ "created_time, completed_time, progress, "
+ "dtstart_type, dtstart_utime, dtstart_datetime, dtstart_tzid, "
+ "dtend_type, dtend_utime, dtend_datetime, dtend_tzid, "
+ "last_mod, rrule_id, "
+ "has_alarm, system_type, updated, "
+ "sync_data1, sync_data2, sync_data3, sync_data4, "
+ "organizer_name, organizer_email, "
+ "has_attendee, has_extended, "
+ "freq, is_allday "
+ ") VALUES ( "
+ "%d, "
+ "%d, %d, "
+ "?, ?, ?, ?, "
+ "%d, %d, "
+ "%d, ?, "
+ "%d, "
+ "%lf, %lf, "
+ "strftime('%%s', 'now'), %lld, %d, "
+ "%d, %lld, ?, ?, "
+ "%d, %lld, ?, ?, "
+ "strftime('%%s', 'now'), %d, "
+ "%d, %d, %ld, "
+ "?, ?, ?, ?, "
+ "?, ?, "
+ "%d, %d, "
+ "%d, %d) ",
+ CAL_TABLE_SCHEDULE,
+ CAL_SCH_TYPE_TODO, /*event->cal_type,*/
+ input_ver, input_ver,
+ todo->todo_status, todo->priority,
+ todo->sensitivity,
+ todo->calendar_id,
+ todo->latitude, todo->longitude,
+ todo->completed_time, todo->progress,
+ todo->start.type, todo->start.type == CALENDAR_TIME_UTIME ? todo->start.time.utime : 0,
+ todo->due.type, todo->due.type == CALENDAR_TIME_UTIME ? todo->due.time.utime : 0,
+ todo->freq > 0 ? 1 : 0,
+ has_alarm,
+ todo->system_type,
+ todo->updated,
+ (todo->attendee_list && 0 < todo->attendee_list->count) ? 1 : 0,
+ (todo->extended_list && 0 < todo->extended_list->count) ? 1 : 0,
+ todo->freq, is_allday);
+
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt)
+ {
+ ERR("_cal_db_util_query_prepare() Failed");
+ SEC_DBG("[%s]", query);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ int count = 1;
+
+ if (todo->summary)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->summary);
+ count++;
+
+ if (todo->description)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->description);
+ count++;
+
+ if (todo->location)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->location);
+ count++;
+
+ if (todo->categories)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->categories);
+ count++;
+
+ if (todo->uid)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->uid);
+ count++;
if (CALENDAR_TIME_LOCALTIME == todo->start.type)
{
- snprintf(dtstart_datetime, sizeof(dtstart_datetime), "%04d%02d%02d",
+ snprintf(dtstart_datetime, sizeof(dtstart_datetime), CAL_FORMAT_LOCAL_DATETIME,
todo->start.time.date.year,
todo->start.time.date.month,
- todo->start.time.date.mday);
+ todo->start.time.date.mday,
+ todo->start.time.date.hour,
+ todo->start.time.date.minute,
+ todo->start.time.date.second);
_cal_db_util_stmt_bind_text(stmt, count, dtstart_datetime);
}
- count++;
+ count++;
- if (todo->start_tzid)
- _cal_db_util_stmt_bind_text(stmt, count, todo->start_tzid);
- count++;
+ if (todo->start_tzid)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->start_tzid);
+ count++;
if (CALENDAR_TIME_LOCALTIME == todo->due.type)
{
- snprintf(dtend_datetime, sizeof(dtend_datetime), "%04d%02d%02d",
+ snprintf(dtend_datetime, sizeof(dtend_datetime), CAL_FORMAT_LOCAL_DATETIME,
todo->due.time.date.year,
todo->due.time.date.month,
- todo->due.time.date.mday);
+ todo->due.time.date.mday,
+ todo->due.time.date.hour,
+ todo->due.time.date.minute,
+ todo->due.time.date.second);
_cal_db_util_stmt_bind_text(stmt, count, dtend_datetime);
}
- count++;
-
- if (todo->due_tzid)
- _cal_db_util_stmt_bind_text(stmt, count, todo->due_tzid);
- count++;
-
- if (todo->sync_data1)
- _cal_db_util_stmt_bind_text(stmt, count, todo->sync_data1);
- count++;
- if (todo->sync_data2)
- _cal_db_util_stmt_bind_text(stmt, count, todo->sync_data2);
- count++;
- if (todo->sync_data3)
- _cal_db_util_stmt_bind_text(stmt, count, todo->sync_data3);
- count++;
- if (todo->sync_data4)
- _cal_db_util_stmt_bind_text(stmt, count, todo->sync_data4);
- count++;
- if (todo->organizer_name)
- _cal_db_util_stmt_bind_text(stmt, count, todo->organizer_name);
- count++;
- if (todo->organizer_email)
- _cal_db_util_stmt_bind_text(stmt, count, todo->organizer_email);
- count++;
-
- dbret = _cal_db_util_stmt_step(stmt);
- if (CAL_DB_DONE != dbret)
- {
- sqlite3_finalize(stmt);
- ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
+ count++;
+
+ if (todo->due_tzid)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->due_tzid);
+ count++;
+
+ if (todo->sync_data1)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->sync_data1);
+ count++;
+ if (todo->sync_data2)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->sync_data2);
+ count++;
+ if (todo->sync_data3)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->sync_data3);
+ count++;
+ if (todo->sync_data4)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->sync_data4);
+ count++;
+ if (todo->organizer_name)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->organizer_name);
+ count++;
+ if (todo->organizer_email)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->organizer_email);
+ count++;
+
+ dbret = _cal_db_util_stmt_step(stmt);
+ if (CAL_DB_DONE != dbret)
+ {
+ sqlite3_finalize(stmt);
+ ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
- index = _cal_db_util_last_insert_id();
- sqlite3_finalize(stmt);
+ }
+ index = _cal_db_util_last_insert_id();
+ sqlite3_finalize(stmt);
- calendar_record_get_int(record, _calendar_todo.id, &tmp);
- _cal_record_set_int(record, _calendar_todo.id, index);
- if (id)
- {
- *id = index;
- }
+ calendar_record_get_int(record, _calendar_todo.id, &tmp);
+ _cal_record_set_int(record, _calendar_todo.id, index);
+ if (id) {
+ *id = index;
+ }
_cal_db_rrule_get_rrule_from_todo(record, &rrule);
- _cal_db_rrule_insert_record(index, rrule);
-
- calendar_list_h list;
- if (todo->alarm_list)
- {
- list = NULL;
- DBG("insert alarm");
- ret = _cal_db_alarm_convert_gtoh(todo->alarm_list, index, &list);
- ret = calendar_db_insert_records(list, NULL, NULL);
- ret = calendar_list_destroy(list, false);
- }
- if (todo->attendee_list)
- {
- list = NULL;
- DBG("insert attendee");
- ret = _cal_db_attendee_convert_gtoh(todo->attendee_list, index, &list);
- ret = calendar_db_insert_records(list, NULL, NULL);
- ret = calendar_list_destroy(list, false);
- }
-
- if (todo->extended_list)
- {
- DBG("insert extended");
- list = NULL;
- ret = _cal_db_extended_convert_gtoh(todo->extended_list, index, CALENDAR_RECORD_TYPE_TODO, &list);
- ret = calendar_db_insert_records(list, NULL, NULL);
- ret = calendar_list_destroy(list, false);
- }
- else
- {
- DBG("No extended");
- }
+ _cal_db_rrule_insert_record(index, rrule);
+
+ if (todo->alarm_list && 0 < todo->alarm_list->count) {
+ ret = _cal_db_alarm_insert_records(todo->alarm_list, index);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_db_alarm_insert_records() failed(%x)", ret);
+ }
+
+ if (todo->attendee_list && 0 < todo->attendee_list->count) {
+ ret = _cal_db_attendee_insert_records(todo->attendee_list, index);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_db_attendee_insert_records() failed(%x)", ret);
+ }
+
+ if (todo->extended_list && 0 < todo->extended_list->count) {
+ DBG("insert extended");
+ ret = _cal_db_extended_insert_records(todo->extended_list, index, CALENDAR_RECORD_TYPE_TODO);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_db_extended_insert_records() Failed(%x)", ret);
+ }
+ else {
+ DBG("No extended");
+ }
CAL_FREE(rrule);
- _cal_db_util_notify(CAL_NOTI_TYPE_TODO);
+ _cal_db_util_notify(CAL_NOTI_TYPE_TODO);
- _cal_record_set_int(record, _calendar_todo.id, tmp);
+ _cal_record_set_int(record, _calendar_todo.id, tmp);
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_todo_get_record(int id, calendar_record_h* out_record)
{
- char query[CAL_DB_SQL_MAX_LEN];
- int rc = 0;
- cal_todo_s *todo = NULL;
+ char query[CAL_DB_SQL_MAX_LEN];
+ int rc = 0;
+ cal_todo_s *todo = NULL;
cal_rrule_s *rrule = NULL;
- sqlite3_stmt *stmt = NULL;
- cal_db_util_error_e dbret = CAL_DB_OK;
- GList *alarm_list = NULL;
- GList *attendee_list = NULL;
- GList *extended_list = NULL;
-
- rc = calendar_record_create( _calendar_todo._uri ,out_record);
- if (rc != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_record_create(%d)", rc);
- return CALENDAR_ERROR_OUT_OF_MEMORY;
- }
-
- todo = (cal_todo_s*)(*out_record);
-
- snprintf(query, sizeof(query), "SELECT * FROM %s "
- "WHERE id=%d AND type = %d AND calendar_id IN "
- "(select id from %s where deleted = 0)",
- CAL_TABLE_SCHEDULE,
- id, CALENDAR_BOOK_TYPE_TODO,
- CAL_TABLE_CALENDAR);
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() Failed");
- calendar_record_destroy(*out_record, true);
+ sqlite3_stmt *stmt = NULL;
+ cal_db_util_error_e dbret = CAL_DB_OK;
+ int extended = 0;
+ calendar_record_h record_calendar;
+ calendar_book_sync_event_type_e sync_event_type = CALENDAR_BOOK_SYNC_EVENT_FOR_ME;
+ int ret = 0;
+
+ rc = calendar_record_create( _calendar_todo._uri ,out_record);
+ if (rc != CALENDAR_ERROR_NONE)
+ {
+ ERR("calendar_record_create(%d)", rc);
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+
+ todo = (cal_todo_s*)(*out_record);
+
+ snprintf(query, sizeof(query), "SELECT "CAL_QUERY_SCHEDULE_A_ALL" FROM %s AS A "
+ "WHERE id=%d AND (type = %d OR type = %d) AND calendar_id IN "
+ "(select id from %s where deleted = 0)",
+ CAL_TABLE_SCHEDULE,
+ id, CALENDAR_BOOK_TYPE_TODO, CALENDAR_BOOK_TYPE_NONE,
+ CAL_TABLE_CALENDAR);
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt)
+ {
+ ERR("_cal_db_util_query_prepare() Failed");
+ calendar_record_destroy(*out_record, true);
*out_record = NULL;
- return CALENDAR_ERROR_DB_FAILED;
- }
+ return CALENDAR_ERROR_DB_FAILED;
+ }
- dbret = _cal_db_util_stmt_step(stmt);
+ dbret = _cal_db_util_stmt_step(stmt);
if (dbret != CAL_DB_ROW)
{
- ERR("Failed to step stmt(%d)", dbret);
+ ERR("Failed to step stmt(%d)[%s]", dbret, query);
sqlite3_finalize(stmt);
- calendar_record_destroy(*out_record, true);
+ calendar_record_destroy(*out_record, true);
*out_record = NULL;
switch (dbret)
{
}
}
- __cal_db_todo_get_stmt(stmt,false,*out_record);
- sqlite3_finalize(stmt);
- stmt = NULL;
-
- if (_cal_db_rrule_get_rrule(todo->index, &rrule) == CALENDAR_ERROR_NONE)
- {
- _cal_db_rrule_set_rrule_to_todo(rrule, *out_record);
- CAL_FREE(rrule);
- }
-
- _cal_db_alarm_get_records(todo->index, &alarm_list);
- todo->alarm_list = alarm_list;
-
- _cal_db_attendee_get_records(todo->index, &attendee_list);
- todo->attendee_list = attendee_list;
-
- _cal_db_extended_get_records(todo->index, CALENDAR_RECORD_TYPE_TODO, &extended_list);
- todo->extended_list = extended_list;
-
- todo->has_alarm = 0;
- if (todo->alarm_list)
- {
- if (g_list_length(todo->alarm_list) != 0)
- {
- todo->has_alarm = 1;
- }
- }
- todo->has_attendee = 0;
- if (todo->attendee_list)
- {
- if (g_list_length(todo->attendee_list) != 0)
- {
- todo->has_attendee = 1;
- }
- }
-
- return CALENDAR_ERROR_NONE;
+ __cal_db_todo_get_stmt(stmt,false,*out_record, &extended);
+ sqlite3_finalize(stmt);
+ stmt = NULL;
+
+ //check
+ ret = _cal_db_get_record(_calendar_book._uri,
+ todo->calendar_id, &record_calendar);
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ ret = calendar_record_get_int(record_calendar,
+ _calendar_book.sync_event, (int *)&sync_event_type);
+ calendar_record_destroy(record_calendar, true);
+ }
+ if (todo->is_deleted == 1
+ && sync_event_type != CALENDAR_BOOK_SYNC_EVENT_FOR_EVERY_AND_REMAIN
+ )
+ {
+ calendar_record_destroy(*out_record, true);
+ *out_record = NULL;
+ return CALENDAR_ERROR_DB_RECORD_NOT_FOUND;
+ }
+
+ if (_cal_db_rrule_get_rrule(todo->index, &rrule) == CALENDAR_ERROR_NONE)
+ {
+ _cal_db_rrule_set_rrule_to_todo(rrule, *out_record);
+ CAL_FREE(rrule);
+ }
+
+ if (todo->has_alarm == 1)
+ _cal_db_alarm_get_records(todo->index, todo->alarm_list);
+
+ if (todo->has_attendee == 1)
+ _cal_db_attendee_get_records(todo->index, todo->attendee_list);
+
+ if (extended == 1)
+ _cal_db_extended_get_records(todo->index, CALENDAR_RECORD_TYPE_TODO, todo->extended_list);
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_todo_update_record(calendar_record_h record)
{
- int ret = CALENDAR_ERROR_NONE;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- char dtstart_datetime[32] = {0};
- char dtend_datetime[32] = {0};
- sqlite3_stmt *stmt = NULL;
- cal_todo_s* todo = (cal_todo_s*)(record);
+ int ret = CALENDAR_ERROR_NONE;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ char dtstart_datetime[32] = {0};
+ char dtend_datetime[32] = {0};
+ sqlite3_stmt *stmt = NULL;
+ cal_todo_s* todo = (cal_todo_s*)(record);
cal_rrule_s *rrule = NULL;
- cal_db_util_error_e dbret = CAL_DB_OK;
- int has_alarm = 0;
-
- retv_if(NULL == todo, CALENDAR_ERROR_INVALID_PARAMETER);
-
- //if (CAL_SYNC_STATUS_UPDATED != todo->sync_status)
- // todo->sync_status = CAL_SYNC_STATUS_UPDATED;
- if (todo->common.properties_flags != NULL)
- {
- return __cal_db_todo_update_dirty(record);
- }
-
- has_alarm = _cal_db_alarm_has_alarm(todo->alarm_list);
- snprintf(query, sizeof(query), "UPDATE %s SET "
- "changed_ver = %d,"
- "type = %d,"
- "summary = ?,"
- "description = ?,"
- "location = ?,"
- "categories = ?,"
- "task_status = %d,"
- "priority = %d,"
- "sensitivity = %d, "
- "uid = ?, "
- "calendar_id = %d, "
- "latitude = %lf,"
- "longitude = %lf,"
- "completed_time = %lld,"
- "progress = %d, "
- "dtstart_type = %d, "
- "dtstart_utime = %lld, "
- "dtstart_datetime = ?, "
- "dtstart_tzid = ?, "
- "dtend_type = %d, "
- "dtend_utime = %lld, "
- "dtend_datetime = ?, "
- "dtend_tzid = ?, "
- "last_mod = strftime('%%s', 'now'), "
- "has_alarm = %d, "
- "updated = %ld, "
- "sync_data1 = ?, "
- "sync_data2 = ?, "
- "sync_data3 = ?, "
- "sync_data4 = ?, "
- "organizer_name = ?, "
- "organizer_email = ?, "
- "has_attendee = %d "
- "WHERE id = %d;",
- CAL_TABLE_SCHEDULE,
- _cal_db_util_get_next_ver(),
- CAL_SCH_TYPE_TODO,/*todo->cal_type,*/
- todo->todo_status,
- todo->priority,
- todo->sensitivity,
- todo->calendar_id,
- todo->latitude,
- todo->longitude,
- todo->completed_time,
- todo->progress,
- todo->start.type,
- todo->start.type == CALENDAR_TIME_UTIME ? todo->start.time.utime : 0,
- todo->due.type,
- todo->due.type == CALENDAR_TIME_UTIME ? todo->due.time.utime : 0,
- has_alarm,
- todo->updated,
- todo->attendee_list ? 1 : 0,
- todo->index);
-
- stmt = _cal_db_util_query_prepare(query);
- retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "_cal_db_util_query_prepare() Failed");
-
- int count = 1;
-
- if (todo->summary)
- _cal_db_util_stmt_bind_text(stmt, count, todo->summary);
- count++;
-
- if (todo->description)
- _cal_db_util_stmt_bind_text(stmt, count, todo->description);
- count++;
-
- if (todo->location)
- _cal_db_util_stmt_bind_text(stmt, count, todo->location);
- count++;
-
- if (todo->categories)
- _cal_db_util_stmt_bind_text(stmt, count, todo->categories);
- count++;
-
- if (todo->uid)
- _cal_db_util_stmt_bind_text(stmt, count, todo->uid);
- count++;
+ cal_db_util_error_e dbret = CAL_DB_OK;
+ int has_alarm = 0;
+
+ retv_if(NULL == todo, CALENDAR_ERROR_INVALID_PARAMETER);
+
+ // access control
+ if (_cal_access_control_have_write_permission(todo->calendar_id) == false)
+ {
+ ERR("_cal_access_control_have_write_permission() failed");
+ return CALENDAR_ERROR_PERMISSION_DENIED;
+ }
+
+ //if (CAL_SYNC_STATUS_UPDATED != todo->sync_status)
+ // todo->sync_status = CAL_SYNC_STATUS_UPDATED;
+ if (todo->common.properties_flags != NULL)
+ {
+ return __cal_db_todo_update_dirty(record);
+ }
+
+ has_alarm = _cal_db_alarm_has_alarm(todo->alarm_list);
+ int is_allday = 0;
+ if (CALENDAR_TIME_LOCALTIME == todo->start.type
+ && (0 == todo->start.time.date.hour)
+ && (0 == todo->start.time.date.minute)
+ && (0 == todo->start.time.date.second)
+ && (0 == todo->due.time.date.hour)
+ && (0 == todo->due.time.date.minute)
+ && (0 == todo->due.time.date.second)) {
+ is_allday = 1;
+ }
+
+ snprintf(query, sizeof(query), "UPDATE %s SET "
+ "changed_ver = %d,"
+ "type = %d,"
+ "summary = ?,"
+ "description = ?,"
+ "location = ?,"
+ "categories = ?,"
+ "task_status = %d,"
+ "priority = %d,"
+ "sensitivity = %d, "
+ "uid = ?, "
+ "calendar_id = %d, "
+ "latitude = %lf,"
+ "longitude = %lf,"
+ "completed_time = %lld,"
+ "progress = %d, "
+ "dtstart_type = %d, "
+ "dtstart_utime = %lld, "
+ "dtstart_datetime = ?, "
+ "dtstart_tzid = ?, "
+ "dtend_type = %d, "
+ "dtend_utime = %lld, "
+ "dtend_datetime = ?, "
+ "dtend_tzid = ?, "
+ "last_mod = strftime('%%s', 'now'), "
+ "has_alarm = %d, "
+ "system_type = %d, "
+ "updated = %ld, "
+ "sync_data1 = ?, "
+ "sync_data2 = ?, "
+ "sync_data3 = ?, "
+ "sync_data4 = ?, "
+ "organizer_name = ?, "
+ "organizer_email = ?, "
+ "has_attendee = %d,"
+ "has_extended = %d, "
+ "is_allday = %d "
+ "WHERE id = %d;",
+ CAL_TABLE_SCHEDULE,
+ _cal_db_util_get_next_ver(),
+ CAL_SCH_TYPE_TODO,/*todo->cal_type,*/
+ todo->todo_status,
+ todo->priority,
+ todo->sensitivity,
+ todo->calendar_id,
+ todo->latitude,
+ todo->longitude,
+ todo->completed_time,
+ todo->progress,
+ todo->start.type,
+ todo->start.type == CALENDAR_TIME_UTIME ? todo->start.time.utime : 0,
+ todo->due.type,
+ todo->due.type == CALENDAR_TIME_UTIME ? todo->due.time.utime : 0,
+ has_alarm,
+ todo->system_type,
+ todo->updated,
+ (todo->attendee_list && 0 < todo->attendee_list->count) ? 1 : 0,
+ (todo->extended_list && 0 < todo->extended_list->count) ? 1 : 0,
+ is_allday,
+ todo->index);
+
+ stmt = _cal_db_util_query_prepare(query);
+ retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "_cal_db_util_query_prepare() Failed");
+
+ int count = 1;
+
+ if (todo->summary)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->summary);
+ count++;
+
+ if (todo->description)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->description);
+ count++;
+
+ if (todo->location)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->location);
+ count++;
+
+ if (todo->categories)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->categories);
+ count++;
+
+ if (todo->uid)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->uid);
+ count++;
if (CALENDAR_TIME_LOCALTIME == todo->start.type)
{
- snprintf(dtstart_datetime, sizeof(dtstart_datetime), "%04d%02d%02d",
+ snprintf(dtstart_datetime, sizeof(dtstart_datetime), CAL_FORMAT_LOCAL_DATETIME,
todo->start.time.date.year,
todo->start.time.date.month,
- todo->start.time.date.mday);
+ todo->start.time.date.mday,
+ todo->start.time.date.hour,
+ todo->start.time.date.minute,
+ todo->start.time.date.second);
_cal_db_util_stmt_bind_text(stmt, count, dtstart_datetime);
}
- count++;
+ count++;
- if (todo->start_tzid)
- _cal_db_util_stmt_bind_text(stmt, count, todo->start_tzid);
- count++;
+ if (todo->start_tzid)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->start_tzid);
+ count++;
if (CALENDAR_TIME_LOCALTIME == todo->due.type)
{
- snprintf(dtend_datetime, sizeof(dtend_datetime), "%04d%02d%02d",
+ snprintf(dtend_datetime, sizeof(dtend_datetime), CAL_FORMAT_LOCAL_DATETIME,
todo->due.time.date.year,
todo->due.time.date.month,
- todo->due.time.date.mday);
+ todo->due.time.date.mday,
+ todo->due.time.date.hour,
+ todo->due.time.date.minute,
+ todo->due.time.date.second);
_cal_db_util_stmt_bind_text(stmt, count, dtend_datetime);
}
- count++;
-
- if (todo->due_tzid)
- _cal_db_util_stmt_bind_text(stmt, count, todo->due_tzid);
- count++;
-
- if (todo->sync_data1)
- _cal_db_util_stmt_bind_text(stmt, count, todo->sync_data1);
- count++;
- if (todo->sync_data2)
- _cal_db_util_stmt_bind_text(stmt, count, todo->sync_data2);
- count++;
- if (todo->sync_data3)
- _cal_db_util_stmt_bind_text(stmt, count, todo->sync_data3);
- count++;
- if (todo->sync_data4)
- _cal_db_util_stmt_bind_text(stmt, count, todo->sync_data4);
- count++;
- if (todo->organizer_name)
- _cal_db_util_stmt_bind_text(stmt, count, todo->organizer_name);
- count++;
- if (todo->organizer_email)
- _cal_db_util_stmt_bind_text(stmt, count, todo->organizer_email);
- count++;
-
- dbret = _cal_db_util_stmt_step(stmt);
- if (CAL_DB_DONE != dbret) {
- sqlite3_finalize(stmt);
- ERR("sqlite3_step() Failed(%d)", dbret);
+ count++;
+
+ if (todo->due_tzid)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->due_tzid);
+ count++;
+
+ if (todo->sync_data1)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->sync_data1);
+ count++;
+ if (todo->sync_data2)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->sync_data2);
+ count++;
+ if (todo->sync_data3)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->sync_data3);
+ count++;
+ if (todo->sync_data4)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->sync_data4);
+ count++;
+ if (todo->organizer_name)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->organizer_name);
+ count++;
+ if (todo->organizer_email)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->organizer_email);
+ count++;
+
+ dbret = _cal_db_util_stmt_step(stmt);
+ if (CAL_DB_DONE != dbret) {
+ sqlite3_finalize(stmt);
+ ERR("sqlite3_step() Failed(%d)", dbret);
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
- sqlite3_finalize(stmt);
+ }
+ sqlite3_finalize(stmt);
_cal_db_rrule_get_rrule_from_todo(record, &rrule);
_cal_db_rrule_update_record(todo->index, rrule);
CAL_FREE(rrule);
- //_cal_db_instance_publish_record(record);
-
- _cal_db_alarm_delete_with_id(todo->index);
- _cal_db_attendee_delete_with_id(todo->index);
- _cal_db_extended_delete_with_id(todo->index, CALENDAR_RECORD_TYPE_TODO);
-
- calendar_list_h list;
-
- list = NULL;
- ret = _cal_db_alarm_convert_gtoh(todo->alarm_list,todo->index, &list);
- if (ret == CALENDAR_ERROR_NONE)
- {
- calendar_db_insert_records(list, NULL, NULL);
- calendar_list_destroy(list, false);
- }
-
- list = NULL;
- ret = _cal_db_attendee_convert_gtoh(todo->attendee_list,todo->index, &list);
- if (ret == CALENDAR_ERROR_NONE)
- {
- calendar_db_insert_records(list, NULL, NULL);
- calendar_list_destroy(list, false);
- }
-
- if (todo->extended_list)
- {
- DBG("insert extended");
- list = NULL;
- ret = _cal_db_extended_convert_gtoh(todo->extended_list, todo->index, CALENDAR_RECORD_TYPE_TODO, &list);
- if (ret == CALENDAR_ERROR_NONE)
- {
- calendar_db_insert_records(list, NULL, NULL);
- calendar_list_destroy(list, false);
- }
- }
-
- _cal_db_util_notify(CAL_NOTI_TYPE_TODO);
-
- return CALENDAR_ERROR_NONE;
+ //_cal_db_instance_publish_record(record);
+
+ _cal_db_alarm_delete_with_id(todo->index);
+ _cal_db_attendee_delete_with_id(todo->index);
+ _cal_db_extended_delete_with_id(todo->index, CALENDAR_RECORD_TYPE_TODO);
+
+ if (todo->alarm_list && 0 < todo->alarm_list->count) {
+ ret = _cal_db_alarm_insert_records(todo->alarm_list, todo->index);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_db_alarm_insert_records() Failed(%d)", ret);
+ }
+
+ if (todo->attendee_list && 0 < todo->attendee_list->count) {
+ ret = _cal_db_attendee_insert_records(todo->attendee_list, todo->index);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_db_attendee_insert_records() Failed(%d)", ret);
+ }
+
+
+ if (todo->extended_list && 0 < todo->extended_list->count) {
+ DBG("insert extended");
+ ret = _cal_db_extended_insert_records(todo->extended_list, todo->index, CALENDAR_RECORD_TYPE_TODO);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_db_extended_insert_records() Failed(%d)", ret);
+ }
+
+ _cal_db_util_notify(CAL_NOTI_TYPE_TODO);
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_todo_delete_record(int id)
{
- int ret;
- cal_db_util_error_e dbret = CAL_DB_OK;
- int calendar_book_id;
- int account_id;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- calendar_record_h record_todo;
- calendar_record_h record_calendar;
+ int ret = CALENDAR_ERROR_NONE;
+ cal_db_util_error_e dbret = CAL_DB_OK;
+ int calendar_book_id;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ int created_ver = 0;
+ calendar_book_sync_event_type_e sync_event_type = CALENDAR_BOOK_SYNC_EVENT_FOR_ME;
- retvm_if(id < 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid argument: id < 0");
+ retvm_if(id < 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid argument: id < 0");
- ret = calendar_db_get_record(_calendar_todo._uri, id, &record_todo);
+ ret = __cal_db_todo_get_deleted_data(id, &calendar_book_id, &created_ver);
if (CALENDAR_ERROR_NONE != ret)
{
- DBG("calendar_db_get_record() failed");
- return CALENDAR_ERROR_DB_RECORD_NOT_FOUND;
+ DBG("__cal_db_event_get_deleted_data() failed");
+ return ret;
}
- ret = calendar_record_get_int(record_todo,
- _calendar_todo.calendar_book_id, &calendar_book_id);
- DBG("calendar_book_id(%d)", calendar_book_id);
-
- ret = calendar_db_get_record(_calendar_book._uri,
- calendar_book_id, &record_calendar);
- ret = calendar_record_get_int(record_calendar,
- _calendar_book.account_id, &account_id);
- DBG("account_id(%d)", account_id);
-
- if (account_id == LOCAL_ACCOUNT_ID) {
- DBG("insert deleted table");
- snprintf(query, sizeof(query),
- "INSERT INTO %s ( "
- "schedule_id, schedule_type, "
- "calendar_id, deleted_ver "
- ") VALUES ( "
- "%d, %d,"
- "%d, %d )",
- CAL_TABLE_DELETED,
- id, CAL_RECORD_TYPE_TODO,
- calendar_book_id, _cal_db_util_get_next_ver());
- DBG("query[%s]", query);
-
- dbret = _cal_db_util_query_exec(query);
- if (CAL_DB_OK != dbret)
- {
- ERR("_cal_db_util_query_exec() Failed");
- calendar_record_destroy(record_todo, true);
- calendar_record_destroy(record_calendar, true);
+
+ //access control
+ if (_cal_access_control_have_write_permission(calendar_book_id) == false)
+ {
+ ERR("fail");
+ return CALENDAR_ERROR_PERMISSION_DENIED;
+ }
+
+ snprintf(query, sizeof(query), "SELECT sync_event FROM %s WHERE id = %d ",
+ CAL_TABLE_CALENDAR, calendar_book_id);
+ ret = _cal_db_util_query_get_first_int_result(query, NULL, (int *)&sync_event_type);
+ if (CALENDAR_ERROR_NONE != ret)
+ {
+ ERR("_cal_db_util_query_get_first_int_result() failed");
+ return ret;
+ }
+ DBG("sync_event_type(%d)", sync_event_type);
+
+ if (sync_event_type == CALENDAR_BOOK_SYNC_EVENT_FOR_EVERY_AND_REMAIN)
+ {
+ DBG("set is_delete");
+ snprintf(query, sizeof(query),
+ "UPDATE %s "
+ "SET is_deleted = 1, "
+ "changed_ver = %d, "
+ "last_mod = strftime('%%s','now') "
+ "WHERE id = %d ",
+ CAL_TABLE_SCHEDULE,
+ _cal_db_util_get_next_ver(),
+ id);
+
+ dbret = _cal_db_util_query_exec(query);
+ if (dbret != CAL_DB_OK)
+ {
+ ERR("_cal_db_util_query_exec() failed (%d)", dbret);
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
+ }
+
+ DBG("attendee, alarm and rrule will be deleted by trigger after sync clean");
+ }
+ else
+ {
+ _cal_db_util_get_next_ver();
- DBG("delete event");
- snprintf(query, sizeof(query),
- "DELETE FROM %s "
- "WHERE id = %d ",
- CAL_TABLE_SCHEDULE,
- id);
- DBG("query[%s]", query);
+ DBG("delete event");
+ snprintf(query, sizeof(query),
+ "DELETE FROM %s "
+ "WHERE id = %d ",
+ CAL_TABLE_SCHEDULE,
+ id);
- dbret = _cal_db_util_query_exec(query);
+ dbret = _cal_db_util_query_exec(query);
if (CAL_DB_OK != dbret)
- {
- ERR("_cal_db_util_query_exec() Failed");
- calendar_record_destroy(record_todo, true);
- calendar_record_destroy(record_calendar, true);
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
-
- DBG("attendee, alarm and rrule is deleted by trigger");
-
- } else {
- DBG("set is_delete");
- snprintf(query, sizeof(query),
- "UPDATE %s "
- "SET is_deleted = 1, "
- "changed_ver = %d, "
- "last_mod = strftime('%%s','now') "
- "WHERE id = %d ",
- CAL_TABLE_SCHEDULE,
- _cal_db_util_get_next_ver(),
- id);
-
- dbret = _cal_db_util_query_exec(query);
- if (dbret != CAL_DB_OK)
{
- ERR("_cal_db_util_query_exec() failed (%d)", dbret);
+ DBG("query[%s]", query);
+ ERR("_cal_db_util_query_exec() Failed");
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
-
- DBG("attendee, alarm and rrule will be deleted by trigger after sync clean");
- }
-
- ret = calendar_record_destroy(record_todo, true);
- ret = calendar_record_destroy(record_calendar, true);
+ }
- _cal_db_util_notify(CAL_NOTI_TYPE_TODO);
+ DBG("attendee, alarm and rrule is deleted by trigger");
+ }
+ _cal_db_util_notify(CAL_NOTI_TYPE_TODO);
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_todo_replace_record(calendar_record_h record, int id)
{
- int ret = CALENDAR_ERROR_NONE;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- char dtstart_datetime[32] = {0};
- char dtend_datetime[32] = {0};
- sqlite3_stmt *stmt = NULL;
- cal_todo_s* todo = (cal_todo_s*)(record);
+ int ret = CALENDAR_ERROR_NONE;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ char dtstart_datetime[32] = {0};
+ char dtend_datetime[32] = {0};
+ sqlite3_stmt *stmt = NULL;
+ cal_todo_s* todo = (cal_todo_s*)(record);
cal_rrule_s *rrule = NULL;
- cal_db_util_error_e dbret = CAL_DB_OK;
- int has_alarm = 0;
-
- retv_if(NULL == todo, CALENDAR_ERROR_INVALID_PARAMETER);
- todo->index = id;
-
- //if (CAL_SYNC_STATUS_UPDATED != todo->sync_status)
- // todo->sync_status = CAL_SYNC_STATUS_UPDATED;
- if (todo->common.properties_flags != NULL)
- {
- return __cal_db_todo_update_dirty(record);
- }
-
- has_alarm = _cal_db_alarm_has_alarm(todo->alarm_list);
- snprintf(query, sizeof(query), "UPDATE %s SET "
- "changed_ver = %d,"
- "type = %d,"
- "summary = ?,"
- "description = ?,"
- "location = ?,"
- "categories = ?,"
- "task_status = %d,"
- "priority = %d,"
- "sensitivity = %d, "
- "uid = ?, "
- "calendar_id = %d, "
- "latitude = %lf,"
- "longitude = %lf,"
- "completed_time = %lld,"
- "progress = %d, "
- "dtstart_type = %d, "
- "dtstart_utime = %lld, "
- "dtstart_datetime = ?, "
- "dtstart_tzid = ?, "
- "dtend_type = %d, "
- "dtend_utime = %lld, "
- "dtend_datetime = ?, "
- "dtend_tzid = ?, "
- "last_mod = strftime('%%s', 'now'), "
- "has_alarm = %d, "
- "updated = %ld, "
- "sync_data1 = ?, "
- "sync_data2 = ?, "
- "sync_data3 = ?, "
- "sync_data4 = ?, "
- "organizer_name = ?, "
- "organizer_email = ?, "
- "has_attendee = %d "
- "WHERE id = %d;",
- CAL_TABLE_SCHEDULE,
- _cal_db_util_get_next_ver(),
- CAL_SCH_TYPE_TODO,/*todo->cal_type,*/
- todo->todo_status,
- todo->priority,
- todo->sensitivity,
- todo->calendar_id,
- todo->latitude,
- todo->longitude,
- todo->completed_time,
- todo->progress,
- todo->start.type,
- todo->start.type == CALENDAR_TIME_UTIME ? todo->start.time.utime : 0,
- todo->due.type,
- todo->due.type == CALENDAR_TIME_UTIME ? todo->due.time.utime : 0,
- has_alarm,
- todo->updated,
- todo->attendee_list ? 1 : 0,
- id);
-
- stmt = _cal_db_util_query_prepare(query);
- retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "_cal_db_util_query_prepare() Failed");
-
- int count = 1;
-
- if (todo->summary)
- _cal_db_util_stmt_bind_text(stmt, count, todo->summary);
- count++;
-
- if (todo->description)
- _cal_db_util_stmt_bind_text(stmt, count, todo->description);
- count++;
-
- if (todo->location)
- _cal_db_util_stmt_bind_text(stmt, count, todo->location);
- count++;
-
- if (todo->categories)
- _cal_db_util_stmt_bind_text(stmt, count, todo->categories);
- count++;
-
- if (todo->uid)
- _cal_db_util_stmt_bind_text(stmt, count, todo->uid);
- count++;
+ cal_db_util_error_e dbret = CAL_DB_OK;
+ int has_alarm = 0;
+
+ retv_if(NULL == todo, CALENDAR_ERROR_INVALID_PARAMETER);
+ todo->index = id;
+
+ // access control
+ if (_cal_access_control_have_write_permission(todo->calendar_id) == false)
+ {
+ ERR("_cal_access_control_have_write_permission() failed");
+ return CALENDAR_ERROR_PERMISSION_DENIED;
+ }
+
+ //if (CAL_SYNC_STATUS_UPDATED != todo->sync_status)
+ // todo->sync_status = CAL_SYNC_STATUS_UPDATED;
+ if (todo->common.properties_flags != NULL)
+ {
+ return __cal_db_todo_update_dirty(record);
+ }
+ int is_allday = 0;
+ if (CALENDAR_TIME_LOCALTIME == todo->start.type
+ && (0 == todo->start.time.date.hour)
+ && (0 == todo->start.time.date.minute)
+ && (0 == todo->start.time.date.second)
+ && (0 == todo->due.time.date.hour)
+ && (0 == todo->due.time.date.minute)
+ && (0 == todo->due.time.date.second)) {
+ is_allday = 1;
+ }
+
+ has_alarm = _cal_db_alarm_has_alarm(todo->alarm_list);
+ snprintf(query, sizeof(query), "UPDATE %s SET "
+ "changed_ver = %d,"
+ "type = %d,"
+ "summary = ?,"
+ "description = ?,"
+ "location = ?,"
+ "categories = ?,"
+ "task_status = %d,"
+ "priority = %d,"
+ "sensitivity = %d, "
+ "uid = ?, "
+ "calendar_id = %d, "
+ "latitude = %lf,"
+ "longitude = %lf,"
+ "completed_time = %lld,"
+ "progress = %d, "
+ "dtstart_type = %d, "
+ "dtstart_utime = %lld, "
+ "dtstart_datetime = ?, "
+ "dtstart_tzid = ?, "
+ "dtend_type = %d, "
+ "dtend_utime = %lld, "
+ "dtend_datetime = ?, "
+ "dtend_tzid = ?, "
+ "last_mod = strftime('%%s', 'now'), "
+ "has_alarm = %d, "
+ "system_type = %d, "
+ "updated = %ld, "
+ "sync_data1 = ?, "
+ "sync_data2 = ?, "
+ "sync_data3 = ?, "
+ "sync_data4 = ?, "
+ "organizer_name = ?, "
+ "organizer_email = ?, "
+ "has_attendee = %d,"
+ "has_extended = %d, "
+ "is_allday = %d "
+ "WHERE id = %d;",
+ CAL_TABLE_SCHEDULE,
+ _cal_db_util_get_next_ver(),
+ CAL_SCH_TYPE_TODO,/*todo->cal_type,*/
+ todo->todo_status,
+ todo->priority,
+ todo->sensitivity,
+ todo->calendar_id,
+ todo->latitude,
+ todo->longitude,
+ todo->completed_time,
+ todo->progress,
+ todo->start.type,
+ todo->start.type == CALENDAR_TIME_UTIME ? todo->start.time.utime : 0,
+ todo->due.type,
+ todo->due.type == CALENDAR_TIME_UTIME ? todo->due.time.utime : 0,
+ has_alarm,
+ todo->system_type,
+ todo->updated,
+ (todo->attendee_list && 0 < todo->attendee_list->count) ? 1 : 0,
+ (todo->extended_list && 0 < todo->extended_list->count) ? 1 : 0,
+ is_allday,
+ id);
+
+ stmt = _cal_db_util_query_prepare(query);
+ retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, "_cal_db_util_query_prepare() Failed");
+
+ int count = 1;
+
+ if (todo->summary)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->summary);
+ count++;
+
+ if (todo->description)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->description);
+ count++;
+
+ if (todo->location)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->location);
+ count++;
+
+ if (todo->categories)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->categories);
+ count++;
+
+ if (todo->uid)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->uid);
+ count++;
if (CALENDAR_TIME_LOCALTIME == todo->start.type)
{
- snprintf(dtstart_datetime, sizeof(dtstart_datetime), "%04d%02d%02d",
+ snprintf(dtstart_datetime, sizeof(dtstart_datetime), CAL_FORMAT_LOCAL_DATETIME,
todo->start.time.date.year,
todo->start.time.date.month,
- todo->start.time.date.mday);
+ todo->start.time.date.mday,
+ todo->start.time.date.hour,
+ todo->start.time.date.minute,
+ todo->start.time.date.second);
_cal_db_util_stmt_bind_text(stmt, count, dtstart_datetime);
}
- count++;
+ count++;
- if (todo->start_tzid)
- _cal_db_util_stmt_bind_text(stmt, count, todo->start_tzid);
- count++;
+ if (todo->start_tzid)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->start_tzid);
+ count++;
if (CALENDAR_TIME_LOCALTIME == todo->due.type)
{
- snprintf(dtend_datetime, sizeof(dtend_datetime), "%04d%02d%02d",
+ snprintf(dtend_datetime, sizeof(dtend_datetime), CAL_FORMAT_LOCAL_DATETIME,
todo->due.time.date.year,
todo->due.time.date.month,
- todo->due.time.date.mday);
+ todo->due.time.date.mday,
+ todo->due.time.date.hour,
+ todo->due.time.date.minute,
+ todo->due.time.date.second);
_cal_db_util_stmt_bind_text(stmt, count, dtend_datetime);
}
- count++;
-
- if (todo->due_tzid)
- _cal_db_util_stmt_bind_text(stmt, count, todo->due_tzid);
- count++;
-
- if (todo->sync_data1)
- _cal_db_util_stmt_bind_text(stmt, count, todo->sync_data1);
- count++;
- if (todo->sync_data2)
- _cal_db_util_stmt_bind_text(stmt, count, todo->sync_data2);
- count++;
- if (todo->sync_data3)
- _cal_db_util_stmt_bind_text(stmt, count, todo->sync_data3);
- count++;
- if (todo->sync_data4)
- _cal_db_util_stmt_bind_text(stmt, count, todo->sync_data4);
- count++;
- if (todo->organizer_name)
- _cal_db_util_stmt_bind_text(stmt, count, todo->organizer_name);
- count++;
- if (todo->organizer_email)
- _cal_db_util_stmt_bind_text(stmt, count, todo->organizer_email);
- count++;
-
- dbret = _cal_db_util_stmt_step(stmt);
- if (CAL_DB_DONE != dbret) {
- sqlite3_finalize(stmt);
- ERR("sqlite3_step() Failed(%d)", dbret);
+ count++;
+
+ if (todo->due_tzid)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->due_tzid);
+ count++;
+
+ if (todo->sync_data1)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->sync_data1);
+ count++;
+ if (todo->sync_data2)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->sync_data2);
+ count++;
+ if (todo->sync_data3)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->sync_data3);
+ count++;
+ if (todo->sync_data4)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->sync_data4);
+ count++;
+ if (todo->organizer_name)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->organizer_name);
+ count++;
+ if (todo->organizer_email)
+ _cal_db_util_stmt_bind_text(stmt, count, todo->organizer_email);
+ count++;
+
+ dbret = _cal_db_util_stmt_step(stmt);
+ if (CAL_DB_DONE != dbret) {
+ sqlite3_finalize(stmt);
+ ERR("sqlite3_step() Failed(%d)", dbret);
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
default:
return CALENDAR_ERROR_DB_FAILED;
}
- }
- sqlite3_finalize(stmt);
+ }
+ sqlite3_finalize(stmt);
_cal_db_rrule_get_rrule_from_todo(record, &rrule);
_cal_db_rrule_update_record(id, rrule);
CAL_FREE(rrule);
- //_cal_db_instance_publish_record(record);
-
- _cal_db_alarm_delete_with_id(id);
- _cal_db_attendee_delete_with_id(id);
- _cal_db_extended_delete_with_id(id, CALENDAR_RECORD_TYPE_TODO);
-
- calendar_list_h list;
-
- list = NULL;
- ret = _cal_db_alarm_convert_gtoh(todo->alarm_list, id, &list);
- if (ret == CALENDAR_ERROR_NONE)
- {
- calendar_db_insert_records(list, NULL, NULL);
- calendar_list_destroy(list, false);
- }
-
- list = NULL;
- ret = _cal_db_attendee_convert_gtoh(todo->attendee_list, id, &list);
- if (ret == CALENDAR_ERROR_NONE)
- {
- calendar_db_insert_records(list, NULL, NULL);
- calendar_list_destroy(list, false);
- }
-
- if (todo->extended_list)
- {
- DBG("insert extended");
- list = NULL;
- ret = _cal_db_extended_convert_gtoh(todo->extended_list, id, CALENDAR_RECORD_TYPE_TODO, &list);
- if (ret == CALENDAR_ERROR_NONE)
- {
- calendar_db_insert_records(list, NULL, NULL);
- calendar_list_destroy(list, false);
- }
- }
-
- _cal_db_util_notify(CAL_NOTI_TYPE_TODO);
-
- return CALENDAR_ERROR_NONE;
+ //_cal_db_instance_publish_record(record);
+
+ _cal_db_alarm_delete_with_id(id);
+ _cal_db_attendee_delete_with_id(id);
+ _cal_db_extended_delete_with_id(id, CALENDAR_RECORD_TYPE_TODO);
+
+ if (todo->alarm_list && 0 < todo->alarm_list->count) {
+ ret = _cal_db_alarm_insert_records(todo->alarm_list, id);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_db_alarm_insert_records() failed(%x)", ret);
+ }
+
+ if (todo->attendee_list && 0 < todo->attendee_list->count) {
+ ret = _cal_db_attendee_insert_records(todo->attendee_list, id);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_db_attendee_insert_records() failed(%x)", ret);
+ }
+
+ if (todo->extended_list && 0 < todo->extended_list->count) {
+ DBG("insert extended");
+ ret = _cal_db_extended_insert_records(todo->extended_list, id, CALENDAR_RECORD_TYPE_TODO);
+ warn_if(CALENDAR_ERROR_NONE != ret, "_cal_db_extended_insert_records() Failed(%d)", ret);
+ }
+
+ _cal_db_util_notify(CAL_NOTI_TYPE_TODO);
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_todo_get_all_records(int offset, int limit, calendar_list_h* out_list)
{
- int ret = CALENDAR_ERROR_NONE;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- char offsetquery[CAL_DB_SQL_MAX_LEN] = {0};
- char limitquery[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
-
- retvm_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- ret = calendar_list_create(out_list);
-
- retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- if (offset > 0)
- {
- snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
- }
- if (limit > 0)
- {
- snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
- }
- snprintf(query, sizeof(query), "SELECT * FROM %s %s %s", CAL_VIEW_TABLE_TODO,limitquery,offsetquery);
-
- stmt = _cal_db_util_query_prepare(query);
-
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() Failed");
- calendar_list_destroy(*out_list, true);
+ int ret = CALENDAR_ERROR_NONE;
+ char offsetquery[CAL_DB_SQL_MAX_LEN] = {0};
+ char limitquery[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+
+ retvm_if(NULL == out_list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ ret = calendar_list_create(out_list);
+ retvm_if(CALENDAR_ERROR_NONE != ret, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+ if (offset > 0)
+ {
+ snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
+ }
+ if (limit > 0)
+ {
+ snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
+ }
+
+ char *query_str = NULL;
+ _cal_db_append_string(&query_str, "SELECT * FROM");
+ _cal_db_append_string(&query_str, CAL_VIEW_TABLE_TODO);
+ _cal_db_append_string(&query_str, limitquery);
+ _cal_db_append_string(&query_str, offsetquery);
+
+ stmt = _cal_db_util_query_prepare(query_str);
+ if (NULL == stmt)
+ {
+ ERR("_cal_db_util_query_prepare() Failed");
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- return CALENDAR_ERROR_DB_FAILED;
- }
- retvm_if(NULL == stmt, CALENDAR_ERROR_DB_FAILED, );
-
- while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- calendar_record_h record;
- // stmt -> record
- ret = calendar_record_create(_calendar_todo._uri,&record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
+ CAL_FREE(query_str);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ {
+ calendar_record_h record;
+ int extended = 0;
+ // stmt -> record
+ ret = calendar_record_create(_calendar_todo._uri,&record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- sqlite3_finalize(stmt);
- return ret;
- }
- __cal_db_todo_get_stmt(stmt,true,record);
-
- // child
- int has_attendee = 0, has_alarm = 0;
- int record_id = 0;
- cal_todo_s* ptodo = (cal_todo_s*) record;
- calendar_record_get_int(record, _calendar_todo.id, &record_id);
- if(calendar_record_get_int(record, _calendar_todo.has_attendee,&has_attendee) == CALENDAR_ERROR_NONE)
- {
- if( has_attendee == 1)
- {
- _cal_db_attendee_get_records(record_id, &ptodo->attendee_list);
- }
- }
- if(calendar_record_get_int(record, _calendar_todo.has_alarm,&has_alarm) == CALENDAR_ERROR_NONE)
- {
- if( has_alarm == 1)
- {
- _cal_db_alarm_get_records(record_id, &ptodo->alarm_list);
- }
- }
-
- _cal_db_extended_get_records(record_id, CALENDAR_RECORD_TYPE_TODO, &ptodo->extended_list);
-
- ret = calendar_list_add(*out_list,record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ __cal_db_todo_get_stmt(stmt,true,record, &extended);
+
+ // child
+ int has_attendee = 0, has_alarm = 0;
+ int record_id = 0;
+ cal_todo_s* ptodo = (cal_todo_s*) record;
+ calendar_record_get_int(record, _calendar_todo.id, &record_id);
+ if(calendar_record_get_int(record, _calendar_todo.has_attendee,&has_attendee) == CALENDAR_ERROR_NONE)
+ {
+ if( has_attendee == 1)
+ {
+ _cal_db_attendee_get_records(record_id, ptodo->attendee_list);
+ }
+ }
+ if(calendar_record_get_int(record, _calendar_todo.has_alarm,&has_alarm) == CALENDAR_ERROR_NONE)
+ {
+ if( has_alarm == 1)
+ {
+ _cal_db_alarm_get_records(record_id, ptodo->alarm_list);
+ }
+ }
+
+ if (extended == 1)
+ _cal_db_extended_get_records(record_id, CALENDAR_RECORD_TYPE_TODO, ptodo->extended_list);
+
+ ret = calendar_list_add(*out_list,record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- calendar_record_destroy(record, true);
- sqlite3_finalize(stmt);
- return ret;
- }
- }
- sqlite3_finalize(stmt);
-
- return CALENDAR_ERROR_NONE;
+ calendar_record_destroy(record, true);
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ }
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_todo_get_records_with_query(calendar_query_h query, int offset, int limit, calendar_list_h* out_list)
{
- cal_query_s *que = NULL;
- int ret = CALENDAR_ERROR_NONE;
- char *condition = NULL;
- char *projection = NULL;
- char *order = NULL;
- GSList *bind_text = NULL, *cursor = NULL;
- char strquery[CAL_DB_SQL_MAX_LEN] = {0};
- int len;
- sqlite3_stmt *stmt = NULL;
- int i = 0;
- char *table_name;
-
- que = (cal_query_s *)query;
-
- if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_TODO))
- {
- table_name = SAFE_STRDUP(CAL_VIEW_TABLE_TODO);
- }
- else if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_TODO_CALENDAR))
- {
- table_name = SAFE_STRDUP(CAL_VIEW_TABLE_TODO_CALENDAR);
- }
- else
- {
- ERR("uri(%s) not support get records with query",que->view_uri);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- //table_name = SAFE_STRDUP(CAL_TABLE_NORMAL_INSTANCE);
- }
-
- // make filter
- if (que->filter)
- {
- ret = _cal_db_query_create_condition(query,
- &condition, &bind_text);
- if (ret != CALENDAR_ERROR_NONE)
- {
- CAL_FREE(table_name);
- ERR("filter create fail");
- return ret;
- }
- }
-
- // make projection
- ret = _cal_db_query_create_projection(query, &projection);
-
- // query - projection
- if (projection)
- {
- len = snprintf(strquery, sizeof(strquery), "SELECT %s FROM %s", projection, table_name);
- }
- else
- {
- len = snprintf(strquery, sizeof(strquery), "SELECT * FROM %s", table_name);
- }
- CAL_FREE(table_name);
-
- // query - condition
- if (condition)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " WHERE %s", condition);
- }
-
- // ORDER
- ret = _cal_db_query_create_order(query, &order);
- if (order)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " %s", order);
- }
-
- if (0 < limit)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " LIMIT %d", limit);
- if (0 < offset)
- len += snprintf(strquery+len, sizeof(strquery)-len, " OFFSET %d", offset);
- }
-
- // query
- stmt = _cal_db_util_query_prepare(strquery);
- if (NULL == stmt)
- {
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- CAL_DBG("%s",strquery);
-
- // bind text
- if (bind_text)
- {
- len = g_slist_length(bind_text);
- for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
- {
- _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
- }
- }
-
- //
- ret = calendar_list_create(out_list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- ERR("calendar_list_create() Failed");
- sqlite3_finalize(stmt);
- return ret;
- }
-
- while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- calendar_record_h record;
- // stmt -> record
- ret = calendar_record_create(_calendar_todo._uri,&record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
+ cal_query_s *que = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ char *condition = NULL;
+ char *projection = NULL;
+ GSList *bind_text = NULL, *cursor = NULL;
+ sqlite3_stmt *stmt = NULL;
+ int i = 0;
+ char *table_name;
+
+ que = (cal_query_s *)query;
+
+ if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_TODO))
+ {
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_TODO);
+ }
+ else if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_TODO_CALENDAR))
+ {
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_TODO_CALENDAR);
+ }
+ else
+ {
+ ERR("uri(%s) not support get records with query",que->view_uri);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ //table_name = SAFE_STRDUP(CAL_TABLE_NORMAL_INSTANCE);
+ }
+
+ // make filter
+ if (que->filter)
+ {
+ ret = _cal_db_query_create_condition(query, &condition, &bind_text);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ CAL_FREE(table_name);
+ ERR("filter create fail");
+ return ret;
+ }
+ }
+
+ // make projection
+ ret = _cal_db_query_create_projection(query, &projection);
+
+ char *query_str = NULL;
+
+ // query - projection
+ if (projection)
+ {
+ _cal_db_append_string(&query_str, "SELECT");
+ _cal_db_append_string(&query_str, projection);
+ _cal_db_append_string(&query_str, "FROM");
+ _cal_db_append_string(&query_str, table_name);
+ CAL_FREE(projection);
+ }
+ else
+ {
+ _cal_db_append_string(&query_str, "SELECT * FROM");
+ _cal_db_append_string(&query_str, table_name);
+ }
+ CAL_FREE(table_name);
+
+ // query - condition
+ if (condition)
+ {
+ _cal_db_append_string(&query_str, "WHERE (");
+ _cal_db_append_string(&query_str, condition);
+ _cal_db_append_string(&query_str, ")");
+ }
+
+ // ORDER
+ char *order = NULL;
+ ret = _cal_db_query_create_order(query, condition, &order);
+ if (order)
+ {
+ _cal_db_append_string(&query_str, order);
+ CAL_FREE(order);
+ }
+ CAL_FREE(condition);
+
+ // limit, offset
+ char buf[32] = {0};
+ if (limit > 0)
+ {
+ snprintf(buf, sizeof(buf), "LIMIT %d", limit);
+ _cal_db_append_string(&query_str, buf);
+
+ if (offset > 0)
+ {
+ snprintf(buf, sizeof(buf), "OFFSET %d", offset);
+ _cal_db_append_string(&query_str, buf);
+ }
+ }
+
+ // query
+ stmt = _cal_db_util_query_prepare(query_str);
+ if (NULL == stmt)
+ {
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ CAL_FREE(query_str);
+ ERR("_cal_db_util_query_prepare() Failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ CAL_DBG("%s",query_str);
+
+ // bind text
+ if (bind_text)
+ {
+ g_slist_length(bind_text);
+ for (cursor=bind_text, i=1; cursor;cursor=cursor->next, i++)
+ {
+ _cal_db_util_stmt_bind_text(stmt, i, cursor->data);
+ }
+ }
+
+ //
+ ret = calendar_list_create(out_list);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ ERR("calendar_list_create() Failed");
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ {
+ calendar_record_h record;
+ int extended = 1;
+ int attendee = 1, alarm = 1;
+ // stmt -> record
+ ret = calendar_record_create(_calendar_todo._uri,&record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
- return ret;
- }
- if (que->projection_count > 0)
- {
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ if (que->projection_count > 0)
+ {
_cal_record_set_projection(record,
que->projection, que->projection_count, que->property_count);
- __cal_db_todo_get_projection_stmt(stmt,
+ __cal_db_todo_get_projection_stmt(stmt,
que->projection, que->projection_count,
- record);
- }
- else
- {
- __cal_db_todo_get_stmt(stmt,true,record);
- }
-
- // child
- if (_cal_db_query_find_projection_property(query,CAL_PROPERTY_TODO_CALENDAR_ALARM) == true)
- {
- cal_todo_s* todo = (cal_todo_s*) record;
- _cal_db_alarm_get_records(todo->index, &todo->alarm_list);
- }
- if (_cal_db_query_find_projection_property(query,CAL_PROPERTY_TODO_CALENDAR_ATTENDEE) == true)
- {
- cal_todo_s* todo = (cal_todo_s*) record;
- _cal_db_attendee_get_records(todo->index, &todo->attendee_list);
- }
- if (_cal_db_query_find_projection_property(query,CAL_PROPERTY_TODO_EXTENDED) == true)
- {
- cal_todo_s* todo = (cal_todo_s*) record;
- _cal_db_extended_get_records(todo->index, CALENDAR_RECORD_TYPE_TODO, &todo->extended_list);
- }
-
- ret = calendar_list_add(*out_list,record);
- if( ret != CALENDAR_ERROR_NONE )
- {
- calendar_list_destroy(*out_list, true);
+ record);
+ }
+ else
+ {
+ cal_todo_s *todo = NULL;
+ __cal_db_todo_get_stmt(stmt,true,record, &extended);
+ todo = (cal_todo_s*)(record);
+ if (todo)
+ {
+ attendee = todo->has_attendee;
+ alarm = todo->has_alarm;
+ }
+ }
+
+ // child
+ if (_cal_db_query_find_projection_property(query,CAL_PROPERTY_TODO_CALENDAR_ALARM) == true && alarm ==1)
+ {
+ cal_todo_s* todo = (cal_todo_s*) record;
+ _cal_db_alarm_get_records(todo->index, todo->alarm_list);
+ }
+ if (_cal_db_query_find_projection_property(query,CAL_PROPERTY_TODO_CALENDAR_ATTENDEE) == true && attendee==1)
+ {
+ cal_todo_s* todo = (cal_todo_s*) record;
+ _cal_db_attendee_get_records(todo->index, todo->attendee_list);
+ }
+ if (_cal_db_query_find_projection_property(query,CAL_PROPERTY_TODO_EXTENDED) == true && extended == 1)
+ {
+ cal_todo_s* todo = (cal_todo_s*) record;
+ _cal_db_extended_get_records(todo->index, CALENDAR_RECORD_TYPE_TODO, todo->extended_list);
+ }
+
+ ret = calendar_list_add(*out_list,record);
+ if( ret != CALENDAR_ERROR_NONE )
+ {
+ calendar_list_destroy(*out_list, true);
*out_list = NULL;
- calendar_record_destroy(record, true);
-
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
- sqlite3_finalize(stmt);
- return ret;
- }
- }
-
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
-
- sqlite3_finalize(stmt);
-
- return CALENDAR_ERROR_NONE;
+ calendar_record_destroy(record, true);
+
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+ return ret;
+ }
+ }
+
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
+
+ sqlite3_finalize(stmt);
+ CAL_FREE(query_str);
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_todo_insert_records(const calendar_list_h list, int** ids)
{
- calendar_record_h record;
- int ret = 0;
- int count = 0;
- int i=0;
- int *id = NULL;
-
- ret = calendar_list_get_count(list, &count);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("list get error");
- return ret;
- }
-
- id = calloc(1, sizeof(int)*count);
-
- retvm_if(NULL == id, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc fail");
-
- ret = calendar_list_first(list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("list first error");
- CAL_FREE(id);
- return ret;
- }
- do
- {
- if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
- {
- if( __cal_db_todo_insert_record(record, &id[i]) != CALENDAR_ERROR_NONE)
- {
- ERR("db insert error");
- CAL_FREE(id);
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- i++;
- } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
-
- if(ids)
- {
- *ids = id;
- }
- else
- {
- CAL_FREE(id);
- }
-
- return CALENDAR_ERROR_NONE;
+ calendar_record_h record;
+ int ret = 0;
+ int count = 0;
+ int i=0;
+ int *id = NULL;
+
+ ret = calendar_list_get_count(list, &count);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("list get error");
+ return ret;
+ }
+
+ id = calloc(1, sizeof(int)*count);
+
+ retvm_if(NULL == id, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc fail");
+
+ ret = calendar_list_first(list);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("list first error");
+ CAL_FREE(id);
+ return ret;
+ }
+ do
+ {
+ if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
+ {
+ if( __cal_db_todo_insert_record(record, &id[i]) != CALENDAR_ERROR_NONE)
+ {
+ ERR("db insert error");
+ CAL_FREE(id);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ i++;
+ } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+
+ if(ids)
+ {
+ *ids = id;
+ }
+ else
+ {
+ CAL_FREE(id);
+ }
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_todo_update_records(const calendar_list_h list)
{
- calendar_record_h record;
- int ret = 0;
-
- ret = calendar_list_first(list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("list first error");
- return ret;
- }
- do
- {
- if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
- {
- if( __cal_db_todo_update_record(record) != CALENDAR_ERROR_NONE)
- {
- ERR("db insert error");
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
-
- return CALENDAR_ERROR_NONE;
+ calendar_record_h record;
+ int ret = 0;
+
+ ret = calendar_list_first(list);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("list first error");
+ return ret;
+ }
+ do
+ {
+ if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
+ {
+ if( __cal_db_todo_update_record(record) != CALENDAR_ERROR_NONE)
+ {
+ ERR("db insert error");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ } while(calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_todo_delete_records(int ids[], int count)
{
- int i=0;
- for(i=0;i<count;i++)
- {
- if (__cal_db_todo_delete_record(ids[i]) != CALENDAR_ERROR_NONE)
- {
- ERR("delete failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
- return CALENDAR_ERROR_NONE;
+ int i=0;
+ for(i=0;i<count;i++)
+ {
+ if (__cal_db_todo_delete_record(ids[i]) != CALENDAR_ERROR_NONE)
+ {
+ ERR("delete failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_todo_get_count(int *out_count)
{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- int count = 0;
- int ret;
+ retvm_if(NULL == out_count, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
- retvm_if(NULL == out_count, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter");
+ char *query_str = NULL;
+ _cal_db_append_string(&query_str, "SELECT count(*) FROM");
+ _cal_db_append_string(&query_str, CAL_VIEW_TABLE_TODO);
- snprintf(query, sizeof(query), "SELECT count(*) FROM %s ", CAL_VIEW_TABLE_TODO);
-
- ret = _cal_db_util_query_get_first_int_result(query, NULL, &count);
+ int ret = 0;
+ int count = 0;
+ ret = _cal_db_util_query_get_first_int_result(query_str, NULL, &count);
if (CALENDAR_ERROR_NONE != ret)
{
ERR("_cal_db_util_query_get_first_int_result() failed");
+ CAL_FREE(query_str);
return ret;
}
- CAL_DBG("%s=%d",query,count);
+ CAL_DBG("count(%d) str[%s]", count, query_str);
+ CAL_FREE(query_str);
- *out_count = count;
- return CALENDAR_ERROR_NONE;
+ *out_count = count;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_todo_replace_records(const calendar_list_h list, int ids[], int count)
{
- calendar_record_h record;
+ calendar_record_h record;
int i = 0;
- int ret = 0;
+ int ret = 0;
if (NULL == list)
{
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- ret = calendar_list_first(list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("list first error");
- return ret;
- }
+ ret = calendar_list_first(list);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("list first error");
+ return ret;
+ }
for (i = 0; i < count; i++)
{
- if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
- {
- if( __cal_db_todo_replace_record(record, ids[i]) != CALENDAR_ERROR_NONE)
- {
- ERR("db insert error");
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
+ if( calendar_list_get_current_record_p(list, &record) == CALENDAR_ERROR_NONE)
+ {
+ if( __cal_db_todo_replace_record(record, ids[i]) != CALENDAR_ERROR_NONE)
+ {
+ ERR("db insert error");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
if (CALENDAR_ERROR_NO_DATA != calendar_list_next(list))
{
break;
}
- }
+ }
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_todo_get_count_with_query(calendar_query_h query, int *out_count)
{
- cal_query_s *que = NULL;
- int ret = CALENDAR_ERROR_NONE;
- char *condition = NULL;
- char strquery[CAL_DB_SQL_MAX_LEN] = {0};
- int len;
- char *table_name;
- int count = 0;
- GSList *bind_text = NULL;
-
- que = (cal_query_s *)query;
-
- if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_TODO))
- {
- table_name = SAFE_STRDUP(CAL_VIEW_TABLE_TODO);
- }
- else if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_TODO_CALENDAR))
- {
- table_name = SAFE_STRDUP(CAL_VIEW_TABLE_TODO_CALENDAR);
- }
- else
- {
- ERR("uri(%s) not support get records with query",que->view_uri);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- // make filter
- if (que->filter)
- {
- ret = _cal_db_query_create_condition(query, &condition, &bind_text);
- if (ret != CALENDAR_ERROR_NONE)
- {
- CAL_FREE(table_name);
- ERR("filter create fail");
- return ret;
- }
- }
-
- // query - select from
-
- len = snprintf(strquery, sizeof(strquery), "SELECT count(*) FROM %s", table_name);
- CAL_FREE(table_name);
-
- // query - condition
- if (condition)
- {
- len += snprintf(strquery+len, sizeof(strquery)-len, " WHERE %s", condition);
- }
-
- // query
- ret = _cal_db_util_query_get_first_int_result(strquery, bind_text, &count);
+ cal_query_s *que = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ char *condition = NULL;
+ char *table_name;
+ int count = 0;
+ GSList *bind_text = NULL;
+
+ que = (cal_query_s *)query;
+
+ if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_TODO))
+ {
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_TODO);
+ }
+ else if ( 0 == strcmp(que->view_uri, CALENDAR_VIEW_TODO_CALENDAR))
+ {
+ table_name = SAFE_STRDUP(CAL_VIEW_TABLE_TODO_CALENDAR);
+ }
+ else
+ {
+ ERR("uri(%s) not support get records with query",que->view_uri);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ // make filter
+ if (que->filter)
+ {
+ ret = _cal_db_query_create_condition(query, &condition, &bind_text);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ CAL_FREE(table_name);
+ ERR("filter create fail");
+ return ret;
+ }
+ }
+
+ char *query_str = NULL;
+ // query - select from
+ _cal_db_append_string(&query_str, "SELECT count(*) FROM");
+ _cal_db_append_string(&query_str, table_name);
+ CAL_FREE(table_name);
+
+ // query - condition
+ if (condition)
+ {
+ _cal_db_append_string(&query_str, "WHERE (");
+ _cal_db_append_string(&query_str, condition);
+ _cal_db_append_string(&query_str, ")");
+ CAL_FREE(condition);
+ }
+
+ // query
+ ret = _cal_db_util_query_get_first_int_result(query_str, bind_text, &count);
if (CALENDAR_ERROR_NONE != ret)
{
ERR("_cal_db_util_query_get_first_int_result() failed");
if (bind_text)
{
- g_slist_free(bind_text);
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
}
- CAL_FREE(condition);
+ CAL_FREE(query_str);
return ret;
}
- CAL_DBG("%s=%d",strquery,count);
+ CAL_DBG("count(%d) str[%s]", count, query_str);
- *out_count = count;
+ if (out_count) *out_count = count;
+ if (bind_text)
+ {
+ g_slist_free_full(bind_text, free);
+ bind_text = NULL;
+ }
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- return CALENDAR_ERROR_NONE;
+ CAL_FREE(query_str);
+ return CALENDAR_ERROR_NONE;
}
-static void __cal_db_todo_get_stmt(sqlite3_stmt *stmt,bool is_view_table,calendar_record_h record)
+static void __cal_db_todo_get_stmt(sqlite3_stmt *stmt,bool is_view_table,calendar_record_h record, int *extended)
{
- cal_todo_s *todo = NULL;
- const unsigned char *temp;
- int count = 0;
- char *dtstart_datetime;
- char *dtend_datetime;
- char buf[8] = {0};
-
- todo = (cal_todo_s*)(record);
-
- todo->index = sqlite3_column_int(stmt, count++);
- sqlite3_column_int(stmt, count++);//todo->account_id = sqlite3_column_int(stmt, count++);
- sqlite3_column_int(stmt, count++);//todo->cal_type = 1;/*sqlite3_column_int(stmt, count++);*/
-
- temp = sqlite3_column_text(stmt, count++);
- todo->summary = SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- todo->description = SAFE_STRDUP(temp);
-
- temp = sqlite3_column_text(stmt, count++);
- todo->location = SAFE_STRDUP(temp);
-
- temp = sqlite3_column_text(stmt, count++);
- todo->categories = SAFE_STRDUP(temp);
-
- sqlite3_column_text(stmt, count++);
- //todo->exdate = SAFE_STRDUP(temp);
-
- todo->todo_status = sqlite3_column_int(stmt, count++);
- todo->priority = sqlite3_column_int(stmt, count++);
- sqlite3_column_int(stmt, count++);//todo->timezone = sqlite3_column_int(stmt, count++);
- sqlite3_column_int(stmt, count++);//todo->contact_id = sqlite3_column_int(stmt, count++);
- sqlite3_column_int(stmt, count++);//todo->busy_status = sqlite3_column_int(stmt, count++);
- todo->sensitivity = sqlite3_column_int(stmt, count++);
-
- temp = sqlite3_column_text(stmt, count++);
- todo->uid = SAFE_STRDUP(temp);
-
- temp = sqlite3_column_text(stmt, count++);
- todo->organizer_name = SAFE_STRDUP(temp);
-
- temp = sqlite3_column_text(stmt, count++);
- todo->organizer_email = SAFE_STRDUP(temp);
-
- sqlite3_column_int(stmt, count++);//todo->meeting_status = sqlite3_column_int(stmt, count++);
-
- todo->calendar_id = sqlite3_column_int(stmt, count++);
-
- sqlite3_column_int(stmt, count++);//todo->original_todo_id = sqlite3_column_int(stmt, count++);
-
- todo->latitude = sqlite3_column_double(stmt,count++);
- todo->longitude = sqlite3_column_double(stmt,count++);
- sqlite3_column_int(stmt, count++);//todo->email_id = sqlite3_column_int(stmt, count++);
- sqlite3_column_int(stmt, count++);//todo->availability = sqlite3_column_int(stmt, count++);
-
- todo->created_time = sqlite3_column_int64(stmt, count++);
-
- todo->completed_time = sqlite3_column_int64(stmt, count++);
-
- todo->progress = sqlite3_column_int(stmt,count++);
-
- sqlite3_column_int(stmt,count++); //__version
- sqlite3_column_int(stmt,count++); //__version
- todo->is_deleted = sqlite3_column_int(stmt,count++);
-
- todo->start.type = sqlite3_column_int(stmt,count++);
-
- if (todo->start.type == CALENDAR_TIME_UTIME)
- {
- todo->start.time.utime = sqlite3_column_int64(stmt,count++);
- sqlite3_column_text(stmt, count++); // dtstart_datetime
- }
- else
- {
- sqlite3_column_int64(stmt,count++); //todo->start.time.utime = sqlite3_column_int64(stmt,count++);
- temp = sqlite3_column_text(stmt, count++);
- if (temp) {
- dtstart_datetime = SAFE_STRDUP(temp);
- snprintf(buf, strlen("YYYY") + 1, "%s", &dtstart_datetime[0]);
- todo->start.time.date.year = atoi(buf);
- snprintf(buf, strlen("MM") + 1, "%s", &dtstart_datetime[4]);
- todo->start.time.date.month = atoi(buf);
- snprintf(buf, strlen("DD") + 1, "%s", &dtstart_datetime[6]);
- todo->start.time.date.mday = atoi(buf);
- if (dtstart_datetime) free(dtstart_datetime);
- }
- }
-
- temp = sqlite3_column_text(stmt, count++);
- todo->start_tzid = SAFE_STRDUP(temp);
- todo->due.type = sqlite3_column_int(stmt, count++);
- if (todo->due.type == CALENDAR_TIME_UTIME)
- {
- todo->due.time.utime = sqlite3_column_int64(stmt,count++);
- sqlite3_column_text(stmt, count++); // dtdue_datetime
- }
- else
- {
- sqlite3_column_int64(stmt, count++);//todo->due.time.utime = sqlite3_column_int64(stmt, count++);
- temp = sqlite3_column_text(stmt, count++);
- if (temp) {
- dtend_datetime = SAFE_STRDUP(temp);
- snprintf(buf, strlen("YYYY") + 1, "%s", &dtend_datetime[0]);
- todo->due.time.date.year = atoi(buf);
- snprintf(buf, strlen("MM") + 1, "%s", &dtend_datetime[4]);
- todo->due.time.date.month = atoi(buf);
- snprintf(buf, strlen("DD") + 1, "%s", &dtend_datetime[6]);
- todo->due.time.date.mday = atoi(buf);
- if (dtend_datetime) free(dtend_datetime);
- }
- }
- temp = sqlite3_column_text(stmt, count++);
- todo->due_tzid = SAFE_STRDUP(temp);
-
- todo->last_mod = sqlite3_column_int64(stmt,count++);
- sqlite3_column_int(stmt,count++);//todo->rrule_id = sqlite3_column_int(stmt,count++);
-
- sqlite3_column_text(stmt, count++);
- //todo->recurrence_id = SAFE_STRDUP(temp);
- sqlite3_column_text(stmt, count++);
- //todo->rdate = SAFE_STRDUP(temp);
- todo->has_attendee = sqlite3_column_int(stmt,count++);
- todo->has_alarm = sqlite3_column_int(stmt,count++);
- sqlite3_column_int(stmt,count++); // system_type...
- todo->updated = sqlite3_column_int(stmt,count++);
- temp = sqlite3_column_text(stmt, count++);
- todo->sync_data1 = SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- todo->sync_data2 = SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- todo->sync_data3 = SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- todo->sync_data4 = SAFE_STRDUP(temp);
-
- if (is_view_table == true)
- {
- todo->freq = sqlite3_column_int(stmt, count++);
-
- if (todo->freq <= 0) {
- //todo->rrule_id = 0;
- //sqlite3_finalize(stmt);
- //return CALENDAR_ERROR_NONE;
- return ;
- }
-
- //todo->rrule_id = 1;
- todo->range_type = sqlite3_column_int(stmt, count++);
- todo->until_type = sqlite3_column_int(stmt, count++);
- todo->until_utime = sqlite3_column_int64(stmt, count++);
-
- temp = sqlite3_column_text(stmt, count++);
- if (CALENDAR_TIME_LOCALTIME == todo->until_type)
+ cal_todo_s *todo = NULL;
+ const unsigned char *temp;
+ int count = 0;
+
+ todo = (cal_todo_s*)(record);
+
+ todo->index = sqlite3_column_int(stmt, count++);
+ sqlite3_column_int(stmt, count++);//todo->cal_type = 1;/*sqlite3_column_int(stmt, count++);*/
+
+ temp = sqlite3_column_text(stmt, count++);
+ todo->summary = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ todo->description = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ todo->location = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ todo->categories = SAFE_STRDUP(temp);
+
+ sqlite3_column_text(stmt, count++);
+ //todo->exdate = SAFE_STRDUP(temp);
+
+ todo->todo_status = sqlite3_column_int(stmt, count++);
+ todo->priority = sqlite3_column_int(stmt, count++);
+ sqlite3_column_int(stmt, count++);//todo->timezone = sqlite3_column_int(stmt, count++);
+ sqlite3_column_int(stmt, count++);//todo->contact_id = sqlite3_column_int(stmt, count++);
+ sqlite3_column_int(stmt, count++);//todo->busy_status = sqlite3_column_int(stmt, count++);
+ todo->sensitivity = sqlite3_column_int(stmt, count++);
+
+ temp = sqlite3_column_text(stmt, count++);
+ todo->uid = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ todo->organizer_name = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ todo->organizer_email = SAFE_STRDUP(temp);
+
+ sqlite3_column_int(stmt, count++);//todo->meeting_status = sqlite3_column_int(stmt, count++);
+
+ todo->calendar_id = sqlite3_column_int(stmt, count++);
+
+ sqlite3_column_int(stmt, count++);//todo->original_todo_id = sqlite3_column_int(stmt, count++);
+
+ todo->latitude = sqlite3_column_double(stmt,count++);
+ todo->longitude = sqlite3_column_double(stmt,count++);
+ sqlite3_column_int(stmt, count++);//todo->email_id = sqlite3_column_int(stmt, count++);
+
+ todo->created_time = sqlite3_column_int64(stmt, count++);
+
+ todo->completed_time = sqlite3_column_int64(stmt, count++);
+
+ todo->progress = sqlite3_column_int(stmt,count++);
+
+ sqlite3_column_int(stmt,count++); //__version
+ sqlite3_column_int(stmt,count++); //__version
+ todo->is_deleted = sqlite3_column_int(stmt,count++);
+
+ todo->start.type = sqlite3_column_int(stmt,count++);
+
+ if (todo->start.type == CALENDAR_TIME_UTIME)
+ {
+ todo->start.time.utime = sqlite3_column_int64(stmt,count++);
+ count++; // dtstart_datetime
+ }
+ else
+ {
+ count++; // dtstart_utime
+ temp = sqlite3_column_text(stmt, count++);
+ if (temp) {
+ sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME, &(todo->start.time.date.year),
+ &(todo->start.time.date.month), &(todo->start.time.date.mday),
+ &(todo->start.time.date.hour), &(todo->start.time.date.minute),
+ &(todo->start.time.date.second));
+ }
+ }
+
+ temp = sqlite3_column_text(stmt, count++);
+ todo->start_tzid = SAFE_STRDUP(temp);
+ todo->due.type = sqlite3_column_int(stmt, count++);
+ if (todo->due.type == CALENDAR_TIME_UTIME)
+ {
+ todo->due.time.utime = sqlite3_column_int64(stmt,count++);
+ count++; // due_datetime
+ }
+ else
+ {
+ count++;
+ temp = sqlite3_column_text(stmt, count++);
+ if (temp) {
+ sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME, &(todo->due.time.date.year),
+ &(todo->due.time.date.month), &(todo->due.time.date.mday),
+ &(todo->due.time.date.hour), &(todo->due.time.date.minute),
+ &(todo->due.time.date.second));
+ }
+ }
+ temp = sqlite3_column_text(stmt, count++);
+ todo->due_tzid = SAFE_STRDUP(temp);
+
+ todo->last_mod = sqlite3_column_int64(stmt,count++);
+ sqlite3_column_int(stmt,count++);//todo->rrule_id = sqlite3_column_int(stmt,count++);
+
+ sqlite3_column_text(stmt, count++);
+ //todo->recurrence_id = SAFE_STRDUP(temp);
+ sqlite3_column_text(stmt, count++);
+ //todo->rdate = SAFE_STRDUP(temp);
+ todo->has_attendee = sqlite3_column_int(stmt,count++);
+ todo->has_alarm = sqlite3_column_int(stmt,count++);
+ todo->system_type = sqlite3_column_int(stmt,count++); // system_type...
+ todo->updated = sqlite3_column_int(stmt,count++);
+ temp = sqlite3_column_text(stmt, count++);
+ todo->sync_data1 = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ todo->sync_data2 = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ todo->sync_data3 = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ todo->sync_data4 = SAFE_STRDUP(temp);
+
+ //has_exception
+ sqlite3_column_int(stmt,count++);
+
+ //has_extended
+ if (extended != NULL)
+ *extended = sqlite3_column_int(stmt,count++);
+
+ todo->freq = sqlite3_column_int(stmt, count++);
+ todo->is_allday = sqlite3_column_int(stmt, count++);
+
+ if (is_view_table == true)
+ {
+ if (todo->freq <= 0) {
+ //todo->rrule_id = 0;
+ //sqlite3_finalize(stmt);
+ //return CALENDAR_ERROR_NONE;
+ return ;
+ }
+
+ //todo->rrule_id = 1;
+ todo->range_type = sqlite3_column_int(stmt, count++);
+ todo->until.type = sqlite3_column_int(stmt, count++);
+ todo->until.time.utime = sqlite3_column_int64(stmt, count++);
+
+ temp = sqlite3_column_text(stmt, count++);
+ if (CALENDAR_TIME_LOCALTIME == todo->until.type)
{
- sscanf((const char *)temp, "%04d%02d%02d",
- &todo->until_year, &todo->until_month, &todo->until_mday);
+ sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME,
+ &todo->until.time.date.year,
+ &todo->until.time.date.month,
+ &todo->until.time.date.mday,
+ &todo->until.time.date.hour,
+ &todo->until.time.date.minute,
+ &todo->until.time.date.second);
}
- todo->count = sqlite3_column_int(stmt, count++);
- todo->interval = sqlite3_column_int(stmt, count++);
+ todo->count = sqlite3_column_int(stmt, count++);
+ todo->interval = sqlite3_column_int(stmt, count++);
- temp = sqlite3_column_text(stmt, count++);
- todo->bysecond = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ todo->bysecond = SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- todo->byminute = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ todo->byminute = SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- todo->byhour = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ todo->byhour = SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- todo->byday= SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ todo->byday= SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- todo->bymonthday= SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ todo->bymonthday= SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- todo->byyearday= SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ todo->byyearday= SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- todo->byweekno= SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ todo->byweekno= SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- todo->bymonth= SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ todo->bymonth= SAFE_STRDUP(temp);
- temp = sqlite3_column_text(stmt, count++);
- todo->bysetpos = SAFE_STRDUP(temp);
+ temp = sqlite3_column_text(stmt, count++);
+ todo->bysetpos = SAFE_STRDUP(temp);
- todo->wkst = sqlite3_column_int(stmt, count++);
+ todo->wkst = sqlite3_column_int(stmt, count++);
- sqlite3_column_int(stmt, count++); //calendar deleted
- }
+ sqlite3_column_int(stmt, count++); //calendar deleted
+ }
}
static void __cal_db_todo_get_property_stmt(sqlite3_stmt *stmt,
- unsigned int property, int *stmt_count, calendar_record_h record)
+ unsigned int property, int *stmt_count, calendar_record_h record)
{
- cal_todo_s *todo = NULL;
- const unsigned char *temp;
- char *dtstart_datetime;
- char *dtend_datetime;
- char buf[8] = {0};
-
- todo = (cal_todo_s*)(record);
-
- switch(property)
- {
- case CAL_PROPERTY_TODO_ID:
- todo->index = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_TODO_CALENDAR_ID:
- todo->calendar_id = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_TODO_SUMMARY:
- temp = sqlite3_column_text(stmt, *stmt_count);
- todo->summary = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_TODO_DESCRIPTION:
- temp = sqlite3_column_text(stmt, *stmt_count);
- todo->description = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_TODO_LOCATION:
- temp = sqlite3_column_text(stmt, *stmt_count);
- todo->location = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_TODO_CATEGORIES:
- temp = sqlite3_column_text(stmt, *stmt_count);
- todo->categories = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_TODO_TODO_STATUS:
- todo->todo_status = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_TODO_PRIORITY:
- todo->priority = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_TODO_SENSITIVITY:
- todo->sensitivity = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_TODO_UID:
- temp = sqlite3_column_text(stmt, *stmt_count);
- todo->uid = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_TODO_LATITUDE:
- todo->latitude = sqlite3_column_double(stmt,*stmt_count);
- break;
- case CAL_PROPERTY_TODO_LONGITUDE:
- todo->longitude = sqlite3_column_double(stmt,*stmt_count);
- break;
- case CAL_PROPERTY_TODO_PROGRESS:
- todo->progress = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_TODO_COMPLETED_TIME:
- todo->completed_time = sqlite3_column_int64(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_TODO_CREATED_TIME:
- todo->created_time = sqlite3_column_int64(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_TODO_LAST_MODIFIED_TIME:
- todo->last_mod = sqlite3_column_int64(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_TODO_IS_DELETED:
- todo->is_deleted = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_TODO_FREQ:
- todo->freq = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_TODO_RANGE_TYPE:
- todo->range_type = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_TODO_UNTIL:
- //!!
- break;
- case CAL_PROPERTY_TODO_COUNT:
- todo->count = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_TODO_INTERVAL:
- todo->interval = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_TODO_BYSECOND:
- temp = sqlite3_column_text(stmt, *stmt_count);
- todo->bysecond = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_TODO_BYMINUTE:
- temp = sqlite3_column_text(stmt, *stmt_count);
- todo->byminute = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_TODO_BYHOUR:
- temp = sqlite3_column_text(stmt, *stmt_count);
- todo->byhour = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_TODO_BYDAY:
- temp = sqlite3_column_text(stmt, *stmt_count);
- todo->byday = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_TODO_BYMONTHDAY:
- temp = sqlite3_column_text(stmt, *stmt_count);
- todo->bymonthday = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_TODO_BYYEARDAY:
- temp = sqlite3_column_text(stmt, *stmt_count);
- todo->byyearday = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_TODO_BYWEEKNO:
- temp = sqlite3_column_text(stmt, *stmt_count);
- todo->byweekno = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_TODO_BYMONTH:
- temp = sqlite3_column_text(stmt, *stmt_count);
- todo->bymonth = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_TODO_BYSETPOS:
- temp = sqlite3_column_text(stmt, *stmt_count);
- todo->bysetpos = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_TODO_WKST:
- todo->wkst = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_TODO_HAS_ALARM:
- todo->has_alarm = sqlite3_column_int(stmt, *stmt_count);
- break;
- case CAL_PROPERTY_TODO_SYNC_DATA1:
- temp = sqlite3_column_text(stmt, *stmt_count);
- todo->sync_data1 = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_TODO_SYNC_DATA2:
- temp = sqlite3_column_text(stmt, *stmt_count);
- todo->sync_data2 = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_TODO_SYNC_DATA3:
- temp = sqlite3_column_text(stmt, *stmt_count);
- todo->sync_data3 = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_TODO_SYNC_DATA4:
- temp = sqlite3_column_text(stmt, *stmt_count);
- todo->sync_data4 = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_TODO_START:
- //!!
- todo->start.type = sqlite3_column_int(stmt,*stmt_count);
- if (todo->start.type == CALENDAR_TIME_UTIME)
- {
- *stmt_count = *stmt_count+1;
- todo->start.time.utime = sqlite3_column_int64(stmt,*stmt_count);
- *stmt_count = *stmt_count+1;
- sqlite3_column_text(stmt, *stmt_count);
- }
- else
- {
- *stmt_count = *stmt_count+1;
- sqlite3_column_int64(stmt,*stmt_count); //todo->start.time.utime = sqlite3_column_int64(stmt,count++);
- *stmt_count = *stmt_count+1;
- temp = sqlite3_column_text(stmt, *stmt_count);
- if (temp) {
- dtstart_datetime = SAFE_STRDUP(temp);
- snprintf(buf, strlen("YYYY") + 1, "%s", &dtstart_datetime[0]);
- todo->start.time.date.year = atoi(buf);
- snprintf(buf, strlen("MM") + 1, "%s", &dtstart_datetime[4]);
- todo->start.time.date.month = atoi(buf);
- snprintf(buf, strlen("DD") + 1, "%s", &dtstart_datetime[6]);
- todo->start.time.date.mday = atoi(buf);
- if (dtstart_datetime) free(dtstart_datetime);
- }
- }
- break;
- case CAL_PROPERTY_TODO_START_TZID:
- temp = sqlite3_column_text(stmt, *stmt_count);
- todo->start_tzid = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_TODO_DUE:
- //!!
- todo->due.type = sqlite3_column_int(stmt, *stmt_count);
- if (todo->due.type == CALENDAR_TIME_UTIME)
- {
- *stmt_count = *stmt_count+1;
- todo->due.time.utime = sqlite3_column_int64(stmt,*stmt_count);
- *stmt_count = *stmt_count+1;
- sqlite3_column_text(stmt, *stmt_count);
- }
- else
- {
- *stmt_count = *stmt_count+1;
- sqlite3_column_int64(stmt, *stmt_count);//todo->due.time.utime = sqlite3_column_int64(stmt, count++);
- *stmt_count = *stmt_count+1;
- temp = sqlite3_column_text(stmt, *stmt_count);
- if (temp) {
- dtend_datetime = SAFE_STRDUP(temp);
- snprintf(buf, strlen("YYYY") + 1, "%s", &dtend_datetime[0]);
- todo->due.time.date.year = atoi(buf);
- snprintf(buf, strlen("MM") + 1, "%s", &dtend_datetime[4]);
- todo->due.time.date.month = atoi(buf);
- snprintf(buf, strlen("DD") + 1, "%s", &dtend_datetime[6]);
- todo->due.time.date.mday = atoi(buf);
- if (dtend_datetime) free(dtend_datetime);
- }
- }
- break;
- case CAL_PROPERTY_TODO_DUE_TZID:
- temp = sqlite3_column_text(stmt, *stmt_count);
- todo->due_tzid = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_TODO_ORGANIZER_NAME:
- temp = sqlite3_column_text(stmt, *stmt_count);
- todo->organizer_name = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_TODO_ORGANIZER_EMAIL:
- temp = sqlite3_column_text(stmt, *stmt_count);
- todo->organizer_email = SAFE_STRDUP(temp);
- break;
- case CAL_PROPERTY_TODO_HAS_ATTENDEE:
- todo->has_attendee = sqlite3_column_int(stmt, *stmt_count);
- break;
- default:
- sqlite3_column_int(stmt, *stmt_count);
- break;
- }
-
- *stmt_count = *stmt_count+1;
+ cal_todo_s *todo = NULL;
+ const unsigned char *temp;
+
+ todo = (cal_todo_s*)(record);
+
+ switch(property)
+ {
+ case CAL_PROPERTY_TODO_ID:
+ todo->index = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_TODO_CALENDAR_ID:
+ todo->calendar_id = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_TODO_SUMMARY:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ todo->summary = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_TODO_DESCRIPTION:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ todo->description = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_TODO_LOCATION:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ todo->location = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_TODO_CATEGORIES:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ todo->categories = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_TODO_TODO_STATUS:
+ todo->todo_status = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_TODO_PRIORITY:
+ todo->priority = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_TODO_SENSITIVITY:
+ todo->sensitivity = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_TODO_UID:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ todo->uid = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_TODO_LATITUDE:
+ todo->latitude = sqlite3_column_double(stmt,*stmt_count);
+ break;
+ case CAL_PROPERTY_TODO_LONGITUDE:
+ todo->longitude = sqlite3_column_double(stmt,*stmt_count);
+ break;
+ case CAL_PROPERTY_TODO_PROGRESS:
+ todo->progress = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_TODO_COMPLETED_TIME:
+ todo->completed_time = sqlite3_column_int64(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_TODO_CREATED_TIME:
+ todo->created_time = sqlite3_column_int64(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_TODO_LAST_MODIFIED_TIME:
+ todo->last_mod = sqlite3_column_int64(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_TODO_IS_DELETED:
+ todo->is_deleted = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_TODO_FREQ:
+ todo->freq = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_TODO_RANGE_TYPE:
+ todo->range_type = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_TODO_UNTIL:
+ //!!
+ break;
+ case CAL_PROPERTY_TODO_COUNT:
+ todo->count = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_TODO_INTERVAL:
+ todo->interval = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_TODO_BYSECOND:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ todo->bysecond = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_TODO_BYMINUTE:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ todo->byminute = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_TODO_BYHOUR:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ todo->byhour = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_TODO_BYDAY:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ todo->byday = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_TODO_BYMONTHDAY:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ todo->bymonthday = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_TODO_BYYEARDAY:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ todo->byyearday = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_TODO_BYWEEKNO:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ todo->byweekno = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_TODO_BYMONTH:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ todo->bymonth = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_TODO_BYSETPOS:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ todo->bysetpos = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_TODO_WKST:
+ todo->wkst = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_TODO_HAS_ALARM:
+ todo->has_alarm = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ case CAL_PROPERTY_TODO_SYNC_DATA1:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ todo->sync_data1 = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_TODO_SYNC_DATA2:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ todo->sync_data2 = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_TODO_SYNC_DATA3:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ todo->sync_data3 = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_TODO_SYNC_DATA4:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ todo->sync_data4 = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_TODO_START:
+ //!!
+ todo->start.type = sqlite3_column_int(stmt,*stmt_count);
+ if (todo->start.type == CALENDAR_TIME_UTIME)
+ {
+ *stmt_count = *stmt_count+1;
+ todo->start.time.utime = sqlite3_column_int64(stmt,*stmt_count);
+ *stmt_count = *stmt_count+1; // dtstart_datetime
+ }
+ else
+ {
+ *stmt_count = *stmt_count+1; // dtstart_utime
+ *stmt_count = *stmt_count+1;
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ if (temp) {
+ sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME, &(todo->start.time.date.year),
+ &(todo->start.time.date.month), &(todo->start.time.date.mday),
+ &(todo->start.time.date.hour), &(todo->start.time.date.minute),
+ &(todo->start.time.date.second));
+ }
+ }
+ break;
+ case CAL_PROPERTY_TODO_START_TZID:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ todo->start_tzid = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_TODO_DUE:
+ //!!
+ todo->due.type = sqlite3_column_int(stmt, *stmt_count);
+ if (todo->due.type == CALENDAR_TIME_UTIME)
+ {
+ *stmt_count = *stmt_count+1;
+ todo->due.time.utime = sqlite3_column_int64(stmt,*stmt_count);
+ *stmt_count = *stmt_count+1; // due_datetime
+ }
+ else
+ {
+ *stmt_count = *stmt_count+1; // due_utime
+ *stmt_count = *stmt_count+1;
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ if (temp) {
+ sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME, &(todo->due.time.date.year),
+ &(todo->due.time.date.month), &(todo->due.time.date.mday),
+ &(todo->due.time.date.hour), &(todo->due.time.date.minute),
+ &(todo->due.time.date.second));
+ }
+ }
+ break;
+ case CAL_PROPERTY_TODO_DUE_TZID:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ todo->due_tzid = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_TODO_ORGANIZER_NAME:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ todo->organizer_name = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_TODO_ORGANIZER_EMAIL:
+ temp = sqlite3_column_text(stmt, *stmt_count);
+ todo->organizer_email = SAFE_STRDUP(temp);
+ break;
+ case CAL_PROPERTY_TODO_HAS_ATTENDEE:
+ todo->has_attendee = sqlite3_column_int(stmt, *stmt_count);
+ break;
+ default:
+ sqlite3_column_int(stmt, *stmt_count);
+ break;
+ }
+
+ *stmt_count = *stmt_count+1;
}
static void __cal_db_todo_get_projection_stmt(sqlite3_stmt *stmt,
- const unsigned int *projection, const int projection_count,
- calendar_record_h record)
+ const unsigned int *projection, const int projection_count,
+ calendar_record_h record)
+{
+ int i=0;
+ int stmt_count = 0;
+
+ for(i=0;i<projection_count;i++)
+ {
+ __cal_db_todo_get_property_stmt(stmt,projection[i],&stmt_count,record);
+ }
+}
+
+static bool __cal_db_todo_check_calendar_book_type(calendar_record_h record)
{
- int i=0;
- int stmt_count = 0;
+ int store_type = 0;
+ cal_todo_s *todo = (cal_todo_s *)record;
+ char query[CAL_DB_SQL_MAX_LEN];
+ sqlite3_stmt *stmt = NULL;
- for(i=0;i<projection_count;i++)
- {
- __cal_db_todo_get_property_stmt(stmt,projection[i],&stmt_count,record);
- }
+ snprintf(query, sizeof(query), "SELECT store_type "
+ "FROM %s WHERE id = %d ",
+ CAL_TABLE_CALENDAR, todo->calendar_id);
+
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt)
+ {
+ ERR("query[%s]", query);
+ ERR("_cal_db_util_query_prepare() Failed");
+ return false;
+ }
+
+ if (CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
+ store_type = sqlite3_column_int(stmt, 0);
+ }
+ else {
+ sqlite3_finalize(stmt);
+ stmt = NULL;
+ DBG("Failed to get calendar: calendar_id(%d)", todo->calendar_id);
+ return false;
+ }
+ sqlite3_finalize(stmt);
+
+ bool ret = false;
+ switch (store_type) {
+ case CALENDAR_BOOK_TYPE_NONE:
+ case CALENDAR_BOOK_TYPE_TODO:
+ ret = true;
+ break;
+ case CALENDAR_BOOK_TYPE_EVENT:
+ default:
+ ret = false;
+ break;
+ }
+ return ret;
}
+
static int __cal_db_todo_update_dirty(calendar_record_h record)
{
- int todo_id = 0;
- int ret = CALENDAR_ERROR_NONE;
- calendar_record_h original_record;
-
- ret = calendar_record_get_int(record,_calendar_todo.id, &todo_id);
- retv_if(CALENDAR_ERROR_NONE != ret, ret);
-
- CAL_DBG("id=%d",todo_id);
-
- ret = __cal_db_todo_get_record(todo_id, &original_record);
-
- if (ret == CALENDAR_ERROR_NONE)
- {
- cal_record_s *_record = NULL;
- const cal_property_info_s* property_info = NULL;
- int property_info_count = 0;
- int i=0;
-
- _record = (cal_record_s *)record;
-
- property_info = _cal_view_get_property_info(_record->view_uri, &property_info_count);
-
- for(i=0;i<property_info_count;i++)
- {
- if (true == _cal_record_check_property_flag(record, property_info[i].property_id , CAL_PROPERTY_FLAG_DIRTY))
- {
- if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_INT) == true)
- {
- int tmp=0;
- ret = calendar_record_get_int(record,property_info[i].property_id,&tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- ret = _cal_record_set_int(original_record, property_info[i].property_id, tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_STR) == true)
- {
- char *tmp=NULL;
- ret = calendar_record_get_str_p(record,property_info[i].property_id,&tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- ret = _cal_record_set_str(original_record, property_info[i].property_id, tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
- {
- double tmp=0;
- ret = calendar_record_get_double(record,property_info[i].property_id,&tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- ret = _cal_record_set_double(original_record, property_info[i].property_id, tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_LLI) == true)
- {
- long long int tmp=0;
- ret = calendar_record_get_lli(record,property_info[i].property_id,&tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- ret = _cal_record_set_lli(original_record, property_info[i].property_id, tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
- {
- calendar_time_s tmp = {0,};
- ret = calendar_record_get_caltime(record,property_info[i].property_id,&tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- ret = _cal_record_set_caltime(original_record, property_info[i].property_id, tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- }
- }
- }
-
- // child replace
- // alarm
- cal_todo_s *tmp = (cal_todo_s *)original_record;
- cal_todo_s *tmp_src = (cal_todo_s *)record;
- if ( tmp->alarm_list )
- {
- GList *alarm_list = g_list_first(tmp->alarm_list);
- calendar_record_h alarm_child_record = NULL;
- while (alarm_list)
- {
- alarm_child_record = (calendar_record_h)alarm_list->data;
- if (alarm_child_record == NULL)
- {
- alarm_list = g_list_next(alarm_list);
- continue;
- }
-
- calendar_record_destroy(alarm_child_record, true);
-
- alarm_list = g_list_next(alarm_list);
- }
- g_list_free(tmp->alarm_list);
- }
- tmp->alarm_list = tmp_src->alarm_list;
-
- if( tmp->attendee_list )
- {
- GList * attendee_list = g_list_first(tmp->attendee_list);
- calendar_record_h attendee = NULL;
-
- while (attendee_list)
- {
- attendee = (calendar_record_h)attendee_list->data;
- if (attendee == NULL)
- {
- attendee_list = g_list_next(attendee_list);
- continue;
- }
-
- calendar_record_destroy(attendee, true);
-
- attendee_list = g_list_next(attendee_list);
- }
- g_list_free(tmp->attendee_list);
- }
- tmp->attendee_list = tmp_src->attendee_list;
- if( tmp->extended_list )
- {
- GList * extended_list = g_list_first(tmp->extended_list);
- calendar_record_h extended = NULL;
-
- while (extended_list)
- {
- extended = (calendar_record_h)extended_list->data;
- if (extended == NULL)
- {
- extended_list = g_list_next(extended_list);
- continue;
- }
-
- calendar_record_destroy(extended, true);
-
- extended_list = g_list_next(extended_list);
- }
- g_list_free(tmp->extended_list);
- }
- tmp->extended_list = tmp_src->extended_list;
- }
- else
- {
- CAL_DBG("get_record fail");
- return ret;
- }
-
- CAL_RECORD_RESET_COMMON((cal_record_s*)original_record);
- ret = __cal_db_todo_update_record(original_record);
-
- calendar_record_destroy(original_record,false);
-
- return ret;
+ int todo_id = 0;
+ int ret = CALENDAR_ERROR_NONE;
+ calendar_record_h original_record;
+
+ ret = calendar_record_get_int(record,_calendar_todo.id, &todo_id);
+ retv_if(CALENDAR_ERROR_NONE != ret, ret);
+
+ CAL_DBG("id=%d",todo_id);
+
+ retv_if(false == __cal_db_todo_check_calendar_book_type(record), CALENDAR_ERROR_INVALID_PARAMETER);
+
+ ret = __cal_db_todo_get_record(todo_id, &original_record);
+
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ cal_record_s *_record = NULL;
+ const cal_property_info_s* property_info = NULL;
+ int property_info_count = 0;
+ int i=0;
+
+ _record = (cal_record_s *)record;
+
+ property_info = _cal_view_get_property_info(_record->view_uri, &property_info_count);
+
+ for(i=0;i<property_info_count;i++)
+ {
+ if (true == _cal_record_check_property_flag(record, property_info[i].property_id , CAL_PROPERTY_FLAG_DIRTY))
+ {
+ if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_INT) == true)
+ {
+ int tmp=0;
+ ret = calendar_record_get_int(record,property_info[i].property_id,&tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ ret = _cal_record_set_int(original_record, property_info[i].property_id, tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_STR) == true)
+ {
+ char *tmp=NULL;
+ ret = calendar_record_get_str_p(record,property_info[i].property_id,&tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ ret = _cal_record_set_str(original_record, property_info[i].property_id, tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
+ {
+ double tmp=0;
+ ret = calendar_record_get_double(record,property_info[i].property_id,&tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ ret = _cal_record_set_double(original_record, property_info[i].property_id, tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_LLI) == true)
+ {
+ long long int tmp=0;
+ ret = calendar_record_get_lli(record,property_info[i].property_id,&tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ ret = _cal_record_set_lli(original_record, property_info[i].property_id, tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
+ {
+ calendar_time_s tmp = {0,};
+ ret = calendar_record_get_caltime(record,property_info[i].property_id,&tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ ret = _cal_record_set_caltime(original_record, property_info[i].property_id, tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ }
+ }
+ }
+
+ // child replace
+ // alarm
+ cal_todo_s *tmp = (cal_todo_s *)original_record;
+ cal_todo_s *tmp_src = (cal_todo_s *)record;
+
+ _cal_list_clone((calendar_list_h)tmp_src->alarm_list, (calendar_list_h *)&tmp->alarm_list);
+ _cal_list_clone((calendar_list_h)tmp_src->attendee_list, (calendar_list_h *)&tmp->attendee_list);
+ _cal_list_clone((calendar_list_h)tmp_src->extended_list, (calendar_list_h *)&tmp->extended_list);
+
+ }
+ else
+ {
+ CAL_DBG("get_record fail");
+ return ret;
+ }
+
+ CAL_RECORD_RESET_COMMON((cal_record_s*)original_record);
+ ret = __cal_db_todo_update_record(original_record);
+
+ calendar_record_destroy(original_record, true);
+
+ return ret;
+}
+
+static int __cal_db_todo_get_deleted_data(int id, int* calendar_book_id, int* created_ver)
+{
+ char query[CAL_DB_SQL_MAX_LEN];
+ sqlite3_stmt *stmt = NULL;
+
+ snprintf(query, sizeof(query), "SELECT calendar_id, created_ver "
+ "FROM %s WHERE id = %d ",
+ CAL_TABLE_SCHEDULE, id);
+
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt)
+ {
+ ERR("query[%s]", query);
+ ERR("_cal_db_util_query_prepare() Failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ if (CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ {
+ *calendar_book_id = sqlite3_column_int(stmt, 0);
+ *created_ver = sqlite3_column_int(stmt, 1);
+ }
+ else
+ {
+ sqlite3_finalize(stmt);
+ stmt = NULL;
+ DBG("Failed to get deleted_data: event_id(%d)", id);
+ return CALENDAR_ERROR_DB_RECORD_NOT_FOUND;
+ }
+
+ sqlite3_finalize(stmt);
+ stmt = NULL;
+ return CALENDAR_ERROR_NONE;
}
#include "cal_db_query.h"
#define CAL_DB_CALTIME_FIELD_MAX 3
+#define CAL_DB_ESCAPE_CHAR '\\'
static const char* __cal_db_utime_field_name[] =
{
- "dtstart_utime",
- "dtend_utime",
- "until_utime"
+ "dtstart_utime",
+ "dtend_utime",
+ "until_utime"
};
static const char* __cal_db_datetime_field_name[] =
{
- "dtstart_datetime",
- "dtend_datetime",
- "until_datetime"
+ "dtstart_datetime",
+ "dtend_datetime",
+ "until_datetime"
};
static const char* __cal_db_timetype_field_name[] =
{
- "dtstart_type",
- "dtend_type",
- "until_type"
+ "dtstart_type",
+ "dtend_type",
+ "until_type"
};
static int __cal_db_query_create_composite_condition(cal_composite_filter_s *com_filter,
- char **condition, GSList **bind_text);
+ char **condition, GSList **bind_text);
static int __cal_db_query_create_attribute_condition(cal_composite_filter_s *com_filter,
- cal_attribute_filter_s *filter, char **condition, GSList **bind_text);
+ cal_attribute_filter_s *filter, char **condition, GSList **bind_text);
static int __cal_db_query_create_str_condition(cal_composite_filter_s *com_filter,
- cal_attribute_filter_s *filter, char **condition, GSList **bind_text);
+ cal_attribute_filter_s *filter, char **condition, GSList **bind_text);
static int __cal_db_query_create_int_condition(cal_composite_filter_s *com_filter,
- cal_attribute_filter_s *filter, char **condition );
+ cal_attribute_filter_s *filter, char **condition );
static int __cal_db_query_create_double_condition(cal_composite_filter_s *com_filter,
- cal_attribute_filter_s *filter, char **condition );
+ cal_attribute_filter_s *filter, char **condition );
static int __cal_db_query_create_lli_condition(cal_composite_filter_s *com_filter,
- cal_attribute_filter_s *filter, char **condition );
+ cal_attribute_filter_s *filter, char **condition );
static int __cal_db_query_create_caltime_condition(cal_composite_filter_s *com_filter,
- cal_attribute_filter_s *filter, char **condition );
+ cal_attribute_filter_s *filter, char **condition );
static const char * __cal_db_query_get_property_field_name(const cal_property_info_s *properties,
- int count, unsigned int property_id);
+ int count, unsigned int property_id);
static const char * __cal_db_query_get_utime_field_name(const char* src);
static const char * __cal_db_query_get_datetime_field_name(const char* src);
static const char * __cal_db_query_get_timetype_field_name(const char* src);
int _cal_db_query_create_condition(calendar_query_h query, char **condition, GSList **bind_text)
{
- cal_query_s *que = NULL;
- int ret = CALENDAR_ERROR_NONE;
+ cal_query_s *que = NULL;
+ int ret = CALENDAR_ERROR_NONE;
- retv_if(NULL == query || NULL == condition || NULL == bind_text, CALENDAR_ERROR_INVALID_PARAMETER);
+ retv_if(NULL == query || NULL == condition || NULL == bind_text, CALENDAR_ERROR_INVALID_PARAMETER);
- que = (cal_query_s *)query;
+ que = (cal_query_s *)query;
- ret = __cal_db_query_create_composite_condition(que->filter, condition, bind_text);
+ ret = __cal_db_query_create_composite_condition(que->filter, condition, bind_text);
- return ret;
+ return ret;
}
int _cal_db_query_create_projection(calendar_query_h query, char **projection)
{
- int i = 0;
- int len = 0;
- const char *field_name;
- char out_projection[CAL_DB_SQL_MAX_LEN] = {0};
- cal_query_s *query_s = NULL;
- cal_property_info_s *properties = NULL;
-
- retv_if(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER);
- query_s = (cal_query_s *)query;
-
- properties = query_s->properties;
-
- if (query_s->projection)
- {
- field_name = __cal_db_query_get_property_field_name(properties, query_s->property_count, query_s->projection[0]);
- if (field_name)
- len += snprintf(out_projection+len, sizeof(out_projection)-len, "%s", field_name);
-
- for (i=1;i<query_s->projection_count;i++)
- {
- field_name = __cal_db_query_get_property_field_name(properties, query_s->property_count, query_s->projection[i]);
- if (field_name)
- len += snprintf(out_projection+len, sizeof(out_projection)-len, ", %s", field_name);
- }
- }
- else
- {
-#if 0 // projection이 없을 경우 select *
- for (i=1;i<query_s->property_count;i++) {
- if (properties[i].fields)
- len += snprintf(out_projection+len, sizeof(out_projection)-len, ", %s", (char *)properties[i].fields);
- else
- len += snprintf(out_projection+len, sizeof(out_projection)-len, ", %s", ctsvc_get_display_column());
- }
-#endif
- len += snprintf(out_projection+len, sizeof(out_projection)-len, " * ");
- }
-
- *projection = strdup(out_projection);
-
- return CALENDAR_ERROR_NONE;
+ int i = 0;
+ const char *field_name;
+ char *out_projection = NULL;
+ cal_query_s *query_s = NULL;
+ cal_property_info_s *properties = NULL;
+
+ retv_if(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER);
+ query_s = (cal_query_s *)query;
+
+ properties = query_s->properties;
+
+ if (NULL == query_s->projection || '\0' == *(query_s->projection)) {
+ *projection = g_strdup("* ");
+ return CALENDAR_ERROR_NONE;
+ }
+
+ field_name = __cal_db_query_get_property_field_name(properties, query_s->property_count, query_s->projection[0]);
+ if (field_name)
+ _cal_db_append_string(&out_projection, (char*)field_name);
+
+ for (i=1;i<query_s->projection_count;i++)
+ {
+ field_name = __cal_db_query_get_property_field_name(properties, query_s->property_count, query_s->projection[i]);
+ if (field_name)
+ {
+ _cal_db_append_string(&out_projection, ",");
+ _cal_db_append_string(&out_projection, (char*)field_name);
+ }
+ }
+
+ *projection = out_projection;
+
+ return CALENDAR_ERROR_NONE;
}
-int _cal_db_query_create_order(calendar_query_h query, char **order)
+int _cal_db_query_create_order(calendar_query_h query, char *condition, char **order)
{
- int len = 0;
- const char *field_name;
- char out_order[CAL_DB_SQL_MAX_LEN] = {0};
- cal_query_s *query_s = NULL;
- cal_property_info_s *properties = NULL;
-
- retv_if(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER);
- query_s = (cal_query_s *)query;
- properties = query_s->properties;
-
- if (query_s->sort_property_id > 0)
- {
-
- field_name = __cal_db_query_get_property_field_name(properties, query_s->property_count, query_s->sort_property_id);
-
- if (CAL_PROPERTY_CHECK_DATA_TYPE(query_s->sort_property_id, CAL_PROPERTY_DATA_TYPE_CALTIME) == true && field_name)
- {
- const char *tmp = NULL;
-
- if (strcmp(query_s->view_uri, CALENDAR_VIEW_INSTANCE_ALLDAY) == 0 ||
- strcmp(query_s->view_uri, CALENDAR_VIEW_INSTANCE_ALLDAY_CALENDAR) == 0)
- {
- if(CAL_PROPERTY_INSTANCE_ALLDAY_START)
- {
- tmp = __cal_db_datetime_field_name[0];
- }
- else
- {
- tmp = __cal_db_datetime_field_name[1];
- }
- if (tmp != NULL)
- {
- field_name = tmp;
- }
- }
- else
- {
- tmp = __cal_db_query_get_utime_field_name(field_name);
- if (tmp == NULL)
- {
- tmp = __cal_db_query_get_datetime_field_name(field_name);
- }
- if (tmp != NULL)
- {
- field_name = tmp;
- }
- }
- }
-
- if (field_name)
- len += snprintf(out_order+len, sizeof(out_order)-len, "ORDER BY %s", field_name);
- }
- else
- {
- return CALENDAR_ERROR_NO_DATA;
- }
-
- if (field_name)
- {
- if (query_s->asc == false)
- {
- len += snprintf(out_order+len, sizeof(out_order)-len, " DESC");
- }
- #if 0 // is default
- else // (query_s->asc == true)
- {
- len += snprintf(out_order+len, sizeof(out_order)-len, " ASC");
- }
- #endif
- }
+ const char *field_name = NULL;
+ char out_order[CAL_DB_SQL_MAX_LEN] = {0};
+ cal_query_s *query_s = NULL;
+ cal_property_info_s *properties = NULL;
+
+ retv_if(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER);
+ query_s = (cal_query_s *)query;
+ properties = query_s->properties;
+
+ if (query_s->sort_property_id <= 0)
+ return CALENDAR_ERROR_NO_DATA;
+ field_name = __cal_db_query_get_property_field_name(properties, query_s->property_count, query_s->sort_property_id);
+ if (CAL_PROPERTY_CHECK_DATA_TYPE(query_s->sort_property_id, CAL_PROPERTY_DATA_TYPE_CALTIME) == true && field_name)
+ {
+ const char *p_utime = NULL;
+ const char *p_datetime = NULL;
+
+ p_utime = __cal_db_query_get_utime_field_name(field_name);
+ p_datetime = __cal_db_query_get_datetime_field_name(field_name);
+
+ if (!p_utime && !p_datetime)
+ {
+ if (condition)
+ {
+ p_utime = __cal_db_query_get_utime_field_name(condition);
+ p_datetime = __cal_db_query_get_datetime_field_name(condition);
+ }
+ else
+ {
+ DBG("No condition");
+ }
+ }
+
+ if (p_utime && p_datetime) {
+ cal_record_type_e type = _cal_view_get_type(query_s->view_uri);
+ switch (type)
+ {
+ case CAL_RECORD_TYPE_INSTANCE_NORMAL_EXTENDED:
+ case CAL_RECORD_TYPE_INSTANCE_NORMAL:
+ snprintf(out_order, sizeof(out_order), "ORDER BY %s %s ", p_utime, query_s->asc==false ? "DESC":"ASC");
+ break;
+ case CAL_RECORD_TYPE_INSTANCE_ALLDAY_EXTENDED:
+ case CAL_RECORD_TYPE_INSTANCE_ALLDAY:
+ snprintf(out_order, sizeof(out_order), "ORDER BY %s %s ", p_datetime, query_s->asc==false ? "DESC":"ASC");
+ break;
+ default:
+ snprintf(out_order, sizeof(out_order), "ORDER BY %s %s, %s %s ", p_utime, query_s->asc==false ? "DESC":"ASC", p_datetime, query_s->asc==false ? "DESC":"ASC");
+ break;
+ }
+ } else if (p_utime && !p_datetime) {
+ snprintf(out_order, sizeof(out_order), "ORDER BY %s %s ", p_utime, query_s->asc==false ? "DESC":"ASC");
+ } else if (!p_utime && p_datetime) {
+ snprintf(out_order, sizeof(out_order), "ORDER BY %s %s ", p_datetime, query_s->asc==false ? "DESC":"ASC");
+ } else {
+ DBG("No utime, datetime");
+ }
+ } else {
+ snprintf(out_order, sizeof(out_order), "ORDER BY %s %s ", field_name, query_s->asc==false ? "DESC":"ASC");
+ }
*order = strdup(out_order);
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
bool _cal_db_query_find_projection_property(calendar_query_h query, unsigned int property)
{
- int i = 0;
- cal_query_s *query_s = NULL;
- cal_property_info_s *properties = NULL;
-
- retv_if(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER);
- query_s = (cal_query_s *)query;
-
- properties = query_s->properties;
-
- if (query_s->projection)
- {
- for (i=0;i<query_s->projection_count;i++)
- {
- if (query_s->projection[i] == property)
- {
- return true;
- }
- }
- }
- else
- {
- // projection
- return true;
- }
-
- return false;
+ int i = 0;
+ cal_query_s *query_s = NULL;
+
+ retv_if(NULL == query, CALENDAR_ERROR_INVALID_PARAMETER);
+ query_s = (cal_query_s *)query;
+
+ if (NULL == query_s->projection || '\0' == *query_s->projection)
+ return true;
+
+ for (i = 0; i < query_s->projection_count; i++)
+ if (query_s->projection[i] == property)
+ return true;
+
+ return false;
}
int _cal_db_query_create_projection_update_set(calendar_record_h record, char **set, GSList **bind_text)
{
- cal_record_s *_record = NULL;
- int i = 0;
- const cal_property_info_s* property_info = NULL;
- int property_info_count = 0;
- char out_set[CAL_DB_SQL_MAX_LEN] = {0};
- int len = 0;
- const char *field_name;
- int ret = CALENDAR_ERROR_NONE;
-
- retv_if(record == NULL, -1);
-
- _record = (cal_record_s *)record;
-
- if (_record->properties_max_count == 0 || _record->properties_flags == NULL)
- {
- CAL_DBG("record don't have properties");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- // uri를 통해, property_info_s 가져옴
- property_info = _cal_view_get_property_info(_record->view_uri, &property_info_count);
-
- for(i=0;i<property_info_count;i++)
- {
- if (true == _cal_record_check_property_flag(record, property_info[i].property_id , CAL_PROPERTY_FLAG_DIRTY) )
- {
- field_name = property_info[i].fields;
-
- if (field_name == NULL)
- {
- continue;
- }
-
- if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_INT) == true)
- {
- int tmp=0;
- ret = calendar_record_get_int(record,property_info[i].property_id,&tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- if (strlen(out_set) != 0)
- {
- len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
- }
- len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%d",field_name,tmp);
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_STR) == true)
- {
- char *tmp=NULL;
- ret = calendar_record_get_str(record,property_info[i].property_id,&tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- if (strlen(out_set) != 0)
- {
- len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
- }
- len += snprintf(out_set+len, sizeof(out_set)-len, "%s=?",field_name);
- *bind_text = g_slist_append(*bind_text, tmp);
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
- {
- double tmp=0;
- ret = calendar_record_get_double(record,property_info[i].property_id,&tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- if (strlen(out_set) != 0)
- {
- len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
- }
- len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%lf",field_name,tmp);
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_LLI) == true)
- {
- long long int tmp=0;
- ret = calendar_record_get_lli(record,property_info[i].property_id,&tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- if (strlen(out_set) != 0)
- {
- len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
- }
- len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%lld",field_name,tmp);
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
- {
- /*
- * field_name
- * dtstart_type, dtstart_utime, dtstart_datetime
- * -> dtstart_type=%d, dtstart_utime=%lli, dtstart_datetime=?
- * dtend_type, dtend_utime, dtend_datetime
- * -> dtend_type=%d, dtend_utime=%lli, dtend_datetime=?
- * until_type, until_utime, until_datetime
- * -> until_type=%d, until_utime=%lli, until_datetime=?
- */
- calendar_time_s tmp = {0,};
- const char *timetype_field = NULL;
- const char *utime_field = NULL;
- const char *datetime_field = NULL;
- timetype_field = __cal_db_query_get_timetype_field_name(field_name);
- utime_field = __cal_db_query_get_utime_field_name(field_name);
- datetime_field = __cal_db_query_get_datetime_field_name(field_name);
- ret = calendar_record_get_caltime(record,property_info[i].property_id,&tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- if(tmp.type == CALENDAR_TIME_UTIME)
- {
- if (strlen(out_set) != 0)
- {
- len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
- }
- len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%d, %s=%lld",
- timetype_field, CALENDAR_TIME_UTIME, utime_field, tmp.time.utime);
- }
- else
- {
- char *bind_tmp = NULL;
- char bind_datetime[32] = {0};
- snprintf(bind_datetime, sizeof(bind_datetime), "%04d%02d%02d",
- tmp.time.date.year,
- tmp.time.date.month,
- tmp.time.date.mday);
-
- if (strlen(out_set) != 0)
- {
- len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
- }
- len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%d, %s=?",
+ cal_record_s *_record = NULL;
+ int i = 0;
+ const cal_property_info_s* property_info = NULL;
+ int property_info_count = 0;
+ char out_set[CAL_DB_SQL_MAX_LEN] = {0};
+ int len = 0;
+ const char *field_name;
+ int ret = CALENDAR_ERROR_NONE;
+
+ retv_if(record == NULL, -1);
+
+ _record = (cal_record_s *)record;
+
+ if (_record->properties_max_count == 0 || _record->properties_flags == NULL)
+ {
+ CAL_DBG("record don't have properties");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ // uri를 통해, property_info_s 가져옴
+ property_info = _cal_view_get_property_info(_record->view_uri, &property_info_count);
+
+ for(i=0;i<property_info_count;i++)
+ {
+ if (true == _cal_record_check_property_flag(record, property_info[i].property_id , CAL_PROPERTY_FLAG_DIRTY) )
+ {
+ field_name = property_info[i].fields;
+
+ if (field_name == NULL)
+ {
+ continue;
+ }
+
+ if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_INT) == true)
+ {
+ int tmp=0;
+ ret = calendar_record_get_int(record,property_info[i].property_id,&tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ if (strlen(out_set) != 0)
+ {
+ len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
+ }
+ len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%d",field_name,tmp);
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_STR) == true)
+ {
+ char *tmp=NULL;
+ ret = calendar_record_get_str(record,property_info[i].property_id,&tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ if (strlen(out_set) != 0)
+ {
+ len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
+ }
+ len += snprintf(out_set+len, sizeof(out_set)-len, "%s=?",field_name);
+ *bind_text = g_slist_append(*bind_text, tmp);
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
+ {
+ double tmp=0;
+ ret = calendar_record_get_double(record,property_info[i].property_id,&tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ if (strlen(out_set) != 0)
+ {
+ len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
+ }
+ len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%lf",field_name,tmp);
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_LLI) == true)
+ {
+ long long int tmp=0;
+ ret = calendar_record_get_lli(record,property_info[i].property_id,&tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ if (strlen(out_set) != 0)
+ {
+ len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
+ }
+ len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%lld",field_name,tmp);
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
+ {
+ /*
+ * field_name
+ * dtstart_type, dtstart_utime, dtstart_datetime
+ * -> dtstart_type=%d, dtstart_utime=%lli, dtstart_datetime=?
+ * dtend_type, dtend_utime, dtend_datetime
+ * -> dtend_type=%d, dtend_utime=%lli, dtend_datetime=?
+ * until_type, until_utime, until_datetime
+ * -> until_type=%d, until_utime=%lli, until_datetime=?
+ */
+ calendar_time_s tmp = {0,};
+ const char *timetype_field = NULL;
+ const char *utime_field = NULL;
+ const char *datetime_field = NULL;
+ timetype_field = __cal_db_query_get_timetype_field_name(field_name);
+ utime_field = __cal_db_query_get_utime_field_name(field_name);
+ datetime_field = __cal_db_query_get_datetime_field_name(field_name);
+ ret = calendar_record_get_caltime(record,property_info[i].property_id,&tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ if(tmp.type == CALENDAR_TIME_UTIME)
+ {
+ if (strlen(out_set) != 0)
+ {
+ len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
+ }
+ len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%d, %s=%lld",
+ timetype_field, CALENDAR_TIME_UTIME, utime_field, tmp.time.utime);
+ }
+ else
+ {
+ char *bind_tmp = NULL;
+ char bind_datetime[32] = {0};
+ snprintf(bind_datetime, sizeof(bind_datetime), CAL_FORMAT_LOCAL_DATETIME,
+ tmp.time.date.year,
+ tmp.time.date.month,
+ tmp.time.date.mday,
+ tmp.time.date.hour,
+ tmp.time.date.minute,
+ tmp.time.date.second);
+
+ if (strlen(out_set) != 0)
+ {
+ len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
+ }
+ len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%d, %s=?",
timetype_field, CALENDAR_TIME_LOCALTIME, datetime_field);
- bind_tmp= strdup(bind_datetime);
- *bind_text = g_slist_append(*bind_text, bind_tmp);
- }
- }
- }
- }
+ bind_tmp= strdup(bind_datetime);
+ *bind_text = g_slist_append(*bind_text, bind_tmp);
+ }
+ }
+ }
+ }
- *set = strdup(out_set);
- CAL_DBG("set=%s",*set);
+ *set = strdup(out_set);
+ CAL_DBG("set=%s",*set);
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
int _cal_db_query_create_projection_update_set_with_property(
- calendar_record_h record, unsigned int *properties, int properties_count,
- char **set, GSList **bind_text)
+ calendar_record_h record, unsigned int *properties, int properties_count,
+ char **set, GSList **bind_text)
{
- cal_record_s *_record = NULL;
- int i = 0;
- const cal_property_info_s* property_info = NULL;
- int property_info_count = 0;
- char out_set[CAL_DB_SQL_MAX_LEN] = {0};
- int len = 0;
- const char *field_name;
- int ret = CALENDAR_ERROR_NONE;
-
- retv_if(record == NULL, -1);
-
- _record = (cal_record_s *)record;
-
- if (_record->properties_max_count == 0 || _record->properties_flags == NULL)
- {
- return CALENDAR_ERROR_NONE;
- }
-
- // uri를 통해, property_info_s 가져옴
- property_info = _cal_view_get_property_info(_record->view_uri, &property_info_count);
-
- for(i=0;i<property_info_count;i++)
- {
- int j=0;
- bool flag = false;
- for(j=0;j<properties_count;j++)
- {
- if( property_info[i].property_id == properties[j] )
- {
- flag = true;
- break;
- }
- }
- if (true == flag &&
- ( true == _cal_record_check_property_flag(record, property_info[i].property_id , CAL_PROPERTY_FLAG_DIRTY)) )
- {
- field_name = property_info[i].fields;
-
- if (field_name == NULL)
- {
- continue;
- }
-
- if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_INT) == true)
- {
- int tmp=0;
- ret = calendar_record_get_int(record,property_info[i].property_id,&tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- if (strlen(out_set) != 0)
- {
- len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
- }
- len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%d",field_name,tmp);
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_STR) == true)
- {
- char *tmp=NULL;
- ret = calendar_record_get_str(record,property_info[i].property_id,&tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- if (strlen(out_set) != 0)
- {
- len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
- }
- len += snprintf(out_set+len, sizeof(out_set)-len, "%s=?",field_name);
- *bind_text = g_slist_append(*bind_text, tmp);
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
- {
- double tmp=0;
- ret = calendar_record_get_double(record,property_info[i].property_id,&tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- if (strlen(out_set) != 0)
- {
- len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
- }
- len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%lf",field_name,tmp);
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_LLI) == true)
- {
- long long int tmp=0;
- ret = calendar_record_get_lli(record,property_info[i].property_id,&tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- if (strlen(out_set) != 0)
- {
- len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
- }
- len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%lld",field_name,tmp);
- }
- else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
- {
- /*
- * field_name
- * dtstart_type, dtstart_utime, dtstart_datetime
- * -> dtstart_type=%d, dtstart_utime=%lli, dtstart_datetime=?
- * dtend_type, dtend_utime, dtend_datetime
- * -> dtend_type=%d, dtend_utime=%lli, dtend_datetime=?
- * until_type, until_utime, until_datetime
- * -> until_type=%d, until_utime=%lli, until_datetime=?
- */
- calendar_time_s tmp = {0,};
- const char *timetype_field = NULL;
- const char *utime_field = NULL;
- const char *datetime_field = NULL;
- timetype_field = __cal_db_query_get_timetype_field_name(field_name);
- utime_field = __cal_db_query_get_utime_field_name(field_name);
- datetime_field = __cal_db_query_get_datetime_field_name(field_name);
- ret = calendar_record_get_caltime(record,property_info[i].property_id,&tmp);
- if (ret != CALENDAR_ERROR_NONE)
- continue;
- if(tmp.type == CALENDAR_TIME_UTIME)
- {
- if (strlen(out_set) != 0)
- {
- len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
- }
- len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%d, %s=%lld",
- timetype_field,CALENDAR_TIME_UTIME,utime_field,tmp.time.utime);
- }
- else
- {
- char *bind_tmp = NULL;
- char bind_datetime[32] = {0};
- snprintf(bind_datetime, sizeof(bind_datetime), "%04d%02d%02d",
- tmp.time.date.year,
- tmp.time.date.month,
- tmp.time.date.mday);
-
- if (strlen(out_set) != 0)
- {
- len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
- }
- len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%d, %s=?",
+ cal_record_s *_record = NULL;
+ int i = 0;
+ const cal_property_info_s* property_info = NULL;
+ int property_info_count = 0;
+ char out_set[CAL_DB_SQL_MAX_LEN] = {0};
+ int len = 0;
+ const char *field_name;
+ int ret = CALENDAR_ERROR_NONE;
+
+ retv_if(record == NULL, -1);
+
+ _record = (cal_record_s *)record;
+
+ if (_record->properties_max_count == 0 || _record->properties_flags == NULL)
+ {
+ return CALENDAR_ERROR_NONE;
+ }
+
+ // uri를 통해, property_info_s 가져옴
+ property_info = _cal_view_get_property_info(_record->view_uri, &property_info_count);
+
+ for(i=0;i<property_info_count;i++)
+ {
+ int j=0;
+ bool flag = false;
+ for(j=0;j<properties_count;j++)
+ {
+ if( property_info[i].property_id == properties[j] )
+ {
+ flag = true;
+ break;
+ }
+ }
+ if (true == flag &&
+ ( true == _cal_record_check_property_flag(record, property_info[i].property_id , CAL_PROPERTY_FLAG_DIRTY)) )
+ {
+ field_name = property_info[i].fields;
+
+ if (field_name == NULL)
+ {
+ continue;
+ }
+
+ if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_INT) == true)
+ {
+ int tmp=0;
+ ret = calendar_record_get_int(record,property_info[i].property_id,&tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ if (strlen(out_set) != 0)
+ {
+ len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
+ }
+ len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%d",field_name,tmp);
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_STR) == true)
+ {
+ char *tmp=NULL;
+ ret = calendar_record_get_str(record,property_info[i].property_id,&tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ if (strlen(out_set) != 0)
+ {
+ len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
+ }
+ len += snprintf(out_set+len, sizeof(out_set)-len, "%s=?",field_name);
+ *bind_text = g_slist_append(*bind_text, tmp);
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_DOUBLE) == true)
+ {
+ double tmp=0;
+ ret = calendar_record_get_double(record,property_info[i].property_id,&tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ if (strlen(out_set) != 0)
+ {
+ len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
+ }
+ len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%lf",field_name,tmp);
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_LLI) == true)
+ {
+ long long int tmp=0;
+ ret = calendar_record_get_lli(record,property_info[i].property_id,&tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ if (strlen(out_set) != 0)
+ {
+ len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
+ }
+ len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%lld",field_name,tmp);
+ }
+ else if (CAL_PROPERTY_CHECK_DATA_TYPE(property_info[i].property_id,CAL_PROPERTY_DATA_TYPE_CALTIME) == true)
+ {
+ /*
+ * field_name
+ * dtstart_type, dtstart_utime, dtstart_datetime
+ * -> dtstart_type=%d, dtstart_utime=%lli, dtstart_datetime=?
+ * dtend_type, dtend_utime, dtend_datetime
+ * -> dtend_type=%d, dtend_utime=%lli, dtend_datetime=?
+ * until_type, until_utime, until_datetime
+ * -> until_type=%d, until_utime=%lli, until_datetime=?
+ */
+ calendar_time_s tmp = {0,};
+ const char *timetype_field = NULL;
+ const char *utime_field = NULL;
+ const char *datetime_field = NULL;
+ timetype_field = __cal_db_query_get_timetype_field_name(field_name);
+ utime_field = __cal_db_query_get_utime_field_name(field_name);
+ datetime_field = __cal_db_query_get_datetime_field_name(field_name);
+ ret = calendar_record_get_caltime(record,property_info[i].property_id,&tmp);
+ if (ret != CALENDAR_ERROR_NONE)
+ continue;
+ if(tmp.type == CALENDAR_TIME_UTIME)
+ {
+ if (strlen(out_set) != 0)
+ {
+ len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
+ }
+ len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%d, %s=%lld",
+ timetype_field,CALENDAR_TIME_UTIME,utime_field,tmp.time.utime);
+ }
+ else
+ {
+ char *bind_tmp = NULL;
+ char bind_datetime[32] = {0};
+ snprintf(bind_datetime, sizeof(bind_datetime), CAL_FORMAT_LOCAL_DATETIME,
+ tmp.time.date.year,
+ tmp.time.date.month,
+ tmp.time.date.mday,
+ tmp.time.date.hour,
+ tmp.time.date.minute,
+ tmp.time.date.second);
+
+ if (strlen(out_set) != 0)
+ {
+ len += snprintf(out_set+len, sizeof(out_set)-len, ", ");
+ }
+ len += snprintf(out_set+len, sizeof(out_set)-len, "%s=%d, %s=?",
timetype_field, CALENDAR_TIME_LOCALTIME, datetime_field);
- bind_tmp= strdup(bind_datetime);
- *bind_text = g_slist_append(*bind_text, bind_tmp);
- }
- }
- }
- }
+ bind_tmp= strdup(bind_datetime);
+ *bind_text = g_slist_append(*bind_text, bind_tmp);
+ }
+ }
+ }
+ }
- *set = strdup(out_set);
+ *set = strdup(out_set);
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_query_create_composite_condition(cal_composite_filter_s *com_filter, char **condition, GSList **bind_text)
{
- GSList *cursor_filter = NULL;
- GSList *cursor_ops = NULL;
- calendar_filter_operator_e op;
- int len = 0;
- char *cond = NULL, out_cond[CAL_DB_SQL_MAX_LEN] = {0,};
- GSList *binds = NULL, *binds2 = NULL;
- cal_filter_s *filter;
- int ret = CALENDAR_ERROR_NONE;
+ GSList *cursor_filter = NULL;
+ GSList *cursor_ops = NULL;
+ calendar_filter_operator_e op;
+ char *cond = NULL;
+ char *out_cond = NULL;
+ GSList *binds = NULL, *binds2 = NULL;
+ cal_filter_s *filter;
+ int ret = CALENDAR_ERROR_NONE;
if (com_filter == NULL || com_filter->filters == NULL)
{
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- filter = (cal_filter_s *)com_filter->filters->data;
- if(filter->filter_type == CAL_FILTER_COMPOSITE)
- {
- ret = __cal_db_query_create_composite_condition((cal_composite_filter_s*)filter, &cond, &binds);
- }
- else
- {
- ret = __cal_db_query_create_attribute_condition(com_filter, (cal_attribute_filter_s*)filter, &cond, &binds);
- }
-
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("__cal_db_query_create_attribute_condition fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- cursor_filter = com_filter->filters->next;
-
- len = 0;
- len = snprintf(out_cond, sizeof(out_cond), "(%s)", cond);
- CAL_FREE(cond);
-
- for(cursor_ops=com_filter->filter_ops; cursor_ops && cursor_filter;
- cursor_filter=cursor_filter->next, cursor_ops=cursor_ops->next)
- {
- filter = (cal_filter_s *)cursor_filter->data;
- if(filter->filter_type == CAL_FILTER_COMPOSITE)
- {
- ret = __cal_db_query_create_composite_condition((cal_composite_filter_s*)filter, &cond, &binds2);
- }
- else
- {
- ret = __cal_db_query_create_attribute_condition(com_filter, (cal_attribute_filter_s*)filter, &cond, &binds2);
- }
-
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("__cal_db_query_create_attribute_condition fail");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- op = (calendar_filter_operator_e)cursor_ops->data;
- if (op == CALENDAR_FILTER_OPERATOR_AND)
- len += snprintf(out_cond+len, sizeof(out_cond)-len, " AND (%s)", cond);
- else
- len += snprintf(out_cond+len, sizeof(out_cond)-len, " OR (%s)", cond);
-
- if(binds2)
- binds = g_slist_concat(binds, binds2);
- binds2 = NULL;
-
- CAL_FREE(cond);
- }
-
- *condition = strdup(out_cond);
- *bind_text = binds;
-
- return CALENDAR_ERROR_NONE;
+ filter = (cal_filter_s *)com_filter->filters->data;
+ if(filter->filter_type == CAL_FILTER_COMPOSITE)
+ {
+ ret = __cal_db_query_create_composite_condition((cal_composite_filter_s*)filter, &cond, &binds);
+ }
+ else
+ {
+ ret = __cal_db_query_create_attribute_condition(com_filter, (cal_attribute_filter_s*)filter, &cond, &binds);
+ }
+
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("__cal_db_query_create_attribute_condition fail");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ cursor_filter = com_filter->filters->next;
+
+ _cal_db_append_string(&out_cond, "(");
+ _cal_db_append_string(&out_cond, cond);
+ _cal_db_append_string(&out_cond, ")");
+
+ CAL_FREE(cond);
+
+ for(cursor_ops=com_filter->filter_ops; cursor_ops && cursor_filter;
+ cursor_filter=cursor_filter->next, cursor_ops=cursor_ops->next)
+ {
+ filter = (cal_filter_s *)cursor_filter->data;
+ if(filter->filter_type == CAL_FILTER_COMPOSITE)
+ {
+ ret = __cal_db_query_create_composite_condition((cal_composite_filter_s*)filter, &cond, &binds2);
+ }
+ else
+ {
+ ret = __cal_db_query_create_attribute_condition(com_filter, (cal_attribute_filter_s*)filter, &cond, &binds2);
+ }
+
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("__cal_db_query_create_attribute_condition fail");
+ CAL_FREE(out_cond);
+ if (binds)
+ {
+ g_slist_free_full(binds, free);
+ binds = NULL;
+ }
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ op = (calendar_filter_operator_e)cursor_ops->data;
+ if (op == CALENDAR_FILTER_OPERATOR_AND)
+ {
+ _cal_db_append_string(&out_cond, "AND (");
+ _cal_db_append_string(&out_cond, cond);
+ _cal_db_append_string(&out_cond, ")");
+ }
+ else
+ {
+ _cal_db_append_string(&out_cond, "OR (");
+ _cal_db_append_string(&out_cond, cond);
+ _cal_db_append_string(&out_cond, ")");
+ }
+
+ if(binds2)
+ binds = g_slist_concat(binds, binds2);
+ binds2 = NULL;
+
+ CAL_FREE(cond);
+ }
+
+ *condition = out_cond;
+ *bind_text = binds;
+
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_query_create_attribute_condition(cal_composite_filter_s *com_filter,
- cal_attribute_filter_s *filter, char **condition, GSList **bind_text)
+ cal_attribute_filter_s *filter, char **condition, GSList **bind_text)
{
- int ret;
- char *cond = NULL;
-
- retv_if(NULL == filter, CALENDAR_ERROR_INVALID_PARAMETER);
-
- switch (filter->filter_type)
- {
- case CAL_FILTER_INT:
- ret = __cal_db_query_create_int_condition(com_filter, filter, &cond);
- break;
- case CAL_FILTER_STR:
- ret = __cal_db_query_create_str_condition(com_filter, filter, &cond, bind_text);
- break;
- case CAL_FILTER_DOUBLE:
- ret = __cal_db_query_create_double_condition(com_filter, filter, &cond);
- break;
- case CAL_FILTER_LLI:
- ret = __cal_db_query_create_lli_condition(com_filter, filter, &cond);
- break;
- case CAL_FILTER_CALTIME:
- ret = __cal_db_query_create_caltime_condition(com_filter, filter, &cond);
- break;
- default :
- ERR("The filter type is not supported (%d)", filter->filter_type);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- if (CALENDAR_ERROR_NONE == ret)
- *condition = (cond);
-
- return ret;
+ int ret;
+ char *cond = NULL;
+
+ retv_if(NULL == filter, CALENDAR_ERROR_INVALID_PARAMETER);
+
+ switch (filter->filter_type)
+ {
+ case CAL_FILTER_INT:
+ ret = __cal_db_query_create_int_condition(com_filter, filter, &cond);
+ break;
+ case CAL_FILTER_STR:
+ ret = __cal_db_query_create_str_condition(com_filter, filter, &cond, bind_text);
+ break;
+ case CAL_FILTER_DOUBLE:
+ ret = __cal_db_query_create_double_condition(com_filter, filter, &cond);
+ break;
+ case CAL_FILTER_LLI:
+ ret = __cal_db_query_create_lli_condition(com_filter, filter, &cond);
+ break;
+ case CAL_FILTER_CALTIME:
+ ret = __cal_db_query_create_caltime_condition(com_filter, filter, &cond);
+ break;
+ default :
+ ERR("The filter type is not supported (%d)", filter->filter_type);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (CALENDAR_ERROR_NONE == ret)
+ *condition = (cond);
+
+ return ret;
}
static int __cal_db_query_create_int_condition(cal_composite_filter_s *com_filter,
- cal_attribute_filter_s *filter, char **condition )
+ cal_attribute_filter_s *filter, char **condition )
{
- const char *field_name;
- char out_cond[CAL_DB_SQL_MAX_LEN] = {0};
-
- field_name = __cal_db_query_get_property_field_name(com_filter->properties,
- com_filter->property_count, filter->property_id);
- retvm_if(NULL == field_name, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid parameter : property id(%d)", filter->property_id);
-
- switch(filter->match)
- {
- case CALENDAR_MATCH_EQUAL:
- snprintf(out_cond, sizeof(out_cond), "%s = %d", field_name, filter->value.i);
- break;
- case CALENDAR_MATCH_GREATER_THAN:
- snprintf(out_cond, sizeof(out_cond), "%s > %d", field_name, filter->value.i);
- break;
- case CALENDAR_MATCH_GREATER_THAN_OR_EQUAL:
- snprintf(out_cond, sizeof(out_cond), "%s >= %d", field_name, filter->value.i);
- break;
- case CALENDAR_MATCH_LESS_THAN:
- snprintf(out_cond, sizeof(out_cond), "%s < %d", field_name, filter->value.i);
- break;
- case CALENDAR_MATCH_LESS_THAN_OR_EQUAL:
- snprintf(out_cond, sizeof(out_cond), "%s <= %d", field_name, filter->value.i);
- break;
- case CALENDAR_MATCH_NONE:
- snprintf(out_cond, sizeof(out_cond), "%s IS NULL", field_name);
- break;
- case CALENDAR_MATCH_NOT_EQUAL:
- snprintf(out_cond, sizeof(out_cond), "%s <> %d", field_name, filter->value.i);
- break;
- default :
- ERR("Invalid parameter : int match rule(%d) is not supported", filter->match);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- *condition = strdup(out_cond);
- return CALENDAR_ERROR_NONE;
+ const char *field_name;
+ char out_cond[CAL_DB_SQL_MAX_LEN] = {0};
+
+ field_name = __cal_db_query_get_property_field_name(com_filter->properties,
+ com_filter->property_count, filter->property_id);
+ retvm_if(NULL == field_name, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Invalid parameter : property id(%d)", filter->property_id);
+
+ switch(filter->match)
+ {
+ case CALENDAR_MATCH_EQUAL:
+ snprintf(out_cond, sizeof(out_cond), "%s = %d", field_name, filter->value.i);
+ break;
+ case CALENDAR_MATCH_GREATER_THAN:
+ snprintf(out_cond, sizeof(out_cond), "%s > %d", field_name, filter->value.i);
+ break;
+ case CALENDAR_MATCH_GREATER_THAN_OR_EQUAL:
+ snprintf(out_cond, sizeof(out_cond), "%s >= %d", field_name, filter->value.i);
+ break;
+ case CALENDAR_MATCH_LESS_THAN:
+ snprintf(out_cond, sizeof(out_cond), "%s < %d", field_name, filter->value.i);
+ break;
+ case CALENDAR_MATCH_LESS_THAN_OR_EQUAL:
+ snprintf(out_cond, sizeof(out_cond), "%s <= %d", field_name, filter->value.i);
+ break;
+ case CALENDAR_MATCH_NONE:
+ snprintf(out_cond, sizeof(out_cond), "%s IS NULL", field_name);
+ break;
+ case CALENDAR_MATCH_NOT_EQUAL:
+ snprintf(out_cond, sizeof(out_cond), "%s <> %d", field_name, filter->value.i);
+ break;
+ default :
+ ERR("Invalid parameter : int match rule(%d) is not supported", filter->match);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ *condition = strdup(out_cond);
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_query_create_double_condition(cal_composite_filter_s *com_filter,
- cal_attribute_filter_s *filter, char **condition )
+ cal_attribute_filter_s *filter, char **condition )
{
- const char *field_name;
- char out_cond[CAL_DB_SQL_MAX_LEN] = {0};
-
- field_name = __cal_db_query_get_property_field_name(com_filter->properties,
- com_filter->property_count, filter->property_id);
- retvm_if(NULL == field_name, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid parameter : property id(%d)", filter->property_id);
-
- switch(filter->match)
- {
- case CALENDAR_MATCH_EQUAL:
- snprintf(out_cond, sizeof(out_cond), "%s = %lf", field_name, filter->value.d);
- break;
- case CALENDAR_MATCH_GREATER_THAN:
- snprintf(out_cond, sizeof(out_cond), "%s > %lf", field_name, filter->value.d);
- break;
- case CALENDAR_MATCH_GREATER_THAN_OR_EQUAL:
- snprintf(out_cond, sizeof(out_cond), "%s >= %lf", field_name, filter->value.d);
- break;
- case CALENDAR_MATCH_LESS_THAN:
- snprintf(out_cond, sizeof(out_cond), "%s < %lf", field_name, filter->value.d);
- break;
- case CALENDAR_MATCH_LESS_THAN_OR_EQUAL:
- snprintf(out_cond, sizeof(out_cond), "%s <= %lf", field_name, filter->value.d);
- break;
- case CALENDAR_MATCH_NONE:
- snprintf(out_cond, sizeof(out_cond), "%s IS NULL", field_name);
- break;
- case CALENDAR_MATCH_NOT_EQUAL:
- snprintf(out_cond, sizeof(out_cond), "%s <> %lf", field_name, filter->value.d);
- break;
- default :
- ERR("Invalid parameter : int match rule(%d) is not supported", filter->match);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- *condition = strdup(out_cond);
- return CALENDAR_ERROR_NONE;
+ const char *field_name;
+ char out_cond[CAL_DB_SQL_MAX_LEN] = {0};
+
+ field_name = __cal_db_query_get_property_field_name(com_filter->properties,
+ com_filter->property_count, filter->property_id);
+ retvm_if(NULL == field_name, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Invalid parameter : property id(%d)", filter->property_id);
+
+ switch(filter->match)
+ {
+ case CALENDAR_MATCH_EQUAL:
+ snprintf(out_cond, sizeof(out_cond), "%s = %lf", field_name, filter->value.d);
+ break;
+ case CALENDAR_MATCH_GREATER_THAN:
+ snprintf(out_cond, sizeof(out_cond), "%s > %lf", field_name, filter->value.d);
+ break;
+ case CALENDAR_MATCH_GREATER_THAN_OR_EQUAL:
+ snprintf(out_cond, sizeof(out_cond), "%s >= %lf", field_name, filter->value.d);
+ break;
+ case CALENDAR_MATCH_LESS_THAN:
+ snprintf(out_cond, sizeof(out_cond), "%s < %lf", field_name, filter->value.d);
+ break;
+ case CALENDAR_MATCH_LESS_THAN_OR_EQUAL:
+ snprintf(out_cond, sizeof(out_cond), "%s <= %lf", field_name, filter->value.d);
+ break;
+ case CALENDAR_MATCH_NONE:
+ snprintf(out_cond, sizeof(out_cond), "%s IS NULL", field_name);
+ break;
+ case CALENDAR_MATCH_NOT_EQUAL:
+ snprintf(out_cond, sizeof(out_cond), "%s <> %lf", field_name, filter->value.d);
+ break;
+ default :
+ ERR("Invalid parameter : int match rule(%d) is not supported", filter->match);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ *condition = strdup(out_cond);
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_query_create_lli_condition(cal_composite_filter_s *com_filter,
- cal_attribute_filter_s *filter, char **condition )
+ cal_attribute_filter_s *filter, char **condition )
{
- const char *field_name;
- char out_cond[CAL_DB_SQL_MAX_LEN] = {0};
-
- field_name = __cal_db_query_get_property_field_name(com_filter->properties,
- com_filter->property_count, filter->property_id);
- retvm_if(NULL == field_name, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid parameter : property id(%d)", filter->property_id);
-
- switch(filter->match)
- {
- case CALENDAR_MATCH_EQUAL:
- snprintf(out_cond, sizeof(out_cond), "%s = %lld", field_name, filter->value.lli);
- break;
- case CALENDAR_MATCH_GREATER_THAN:
- snprintf(out_cond, sizeof(out_cond), "%s > %lld", field_name, filter->value.lli);
- break;
- case CALENDAR_MATCH_GREATER_THAN_OR_EQUAL:
- snprintf(out_cond, sizeof(out_cond), "%s >= %lld", field_name, filter->value.lli);
- break;
- case CALENDAR_MATCH_LESS_THAN:
- snprintf(out_cond, sizeof(out_cond), "%s < %lld", field_name, filter->value.lli);
- break;
- case CALENDAR_MATCH_LESS_THAN_OR_EQUAL:
- snprintf(out_cond, sizeof(out_cond), "%s <= %lld", field_name, filter->value.lli);
- break;
- case CALENDAR_MATCH_NONE:
- snprintf(out_cond, sizeof(out_cond), "%s IS NULL", field_name);
- break;
- case CALENDAR_MATCH_NOT_EQUAL:
- snprintf(out_cond, sizeof(out_cond), "%s <> %lld", field_name, filter->value.lli);
- break;
- default :
- ERR("Invalid parameter : int match rule(%d) is not supported", filter->match);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- *condition = strdup(out_cond);
- return CALENDAR_ERROR_NONE;
+ const char *field_name;
+ char out_cond[CAL_DB_SQL_MAX_LEN] = {0};
+
+ field_name = __cal_db_query_get_property_field_name(com_filter->properties,
+ com_filter->property_count, filter->property_id);
+ retvm_if(NULL == field_name, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Invalid parameter : property id(%d)", filter->property_id);
+
+ switch(filter->match)
+ {
+ case CALENDAR_MATCH_EQUAL:
+ snprintf(out_cond, sizeof(out_cond), "%s = %lld", field_name, filter->value.lli);
+ break;
+ case CALENDAR_MATCH_GREATER_THAN:
+ snprintf(out_cond, sizeof(out_cond), "%s > %lld", field_name, filter->value.lli);
+ break;
+ case CALENDAR_MATCH_GREATER_THAN_OR_EQUAL:
+ snprintf(out_cond, sizeof(out_cond), "%s >= %lld", field_name, filter->value.lli);
+ break;
+ case CALENDAR_MATCH_LESS_THAN:
+ snprintf(out_cond, sizeof(out_cond), "%s < %lld", field_name, filter->value.lli);
+ break;
+ case CALENDAR_MATCH_LESS_THAN_OR_EQUAL:
+ snprintf(out_cond, sizeof(out_cond), "%s <= %lld", field_name, filter->value.lli);
+ break;
+ case CALENDAR_MATCH_NONE:
+ snprintf(out_cond, sizeof(out_cond), "%s IS NULL", field_name);
+ break;
+ case CALENDAR_MATCH_NOT_EQUAL:
+ snprintf(out_cond, sizeof(out_cond), "%s <> %lld", field_name, filter->value.lli);
+ break;
+ default :
+ ERR("Invalid parameter : int match rule(%d) is not supported", filter->match);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ *condition = strdup(out_cond);
+ return CALENDAR_ERROR_NONE;
}
static int __cal_db_query_create_caltime_condition(cal_composite_filter_s *com_filter,
- cal_attribute_filter_s *filter, char **condition )
+ cal_attribute_filter_s *filter, char **condition )
+{
+ const char *field_name;
+ char out_cond[CAL_DB_SQL_MAX_LEN] = {0};
+ const char *tmp = NULL;
+
+ field_name = __cal_db_query_get_property_field_name(com_filter->properties,
+ com_filter->property_count, filter->property_id);
+ retvm_if(NULL == field_name, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Invalid parameter : property id(%d)", filter->property_id);
+
+ if (filter->value.caltime.type == CALENDAR_TIME_UTIME )
+ {
+ tmp = __cal_db_query_get_utime_field_name(field_name);
+ if (tmp == NULL)
+ {
+ tmp = field_name;
+ }
+ switch(filter->match)
+ {
+ case CALENDAR_MATCH_EQUAL:
+ snprintf(out_cond, sizeof(out_cond), "%s = %lld", tmp, filter->value.caltime.time.utime);
+ break;
+ case CALENDAR_MATCH_GREATER_THAN:
+ snprintf(out_cond, sizeof(out_cond), "%s > %lld", tmp, filter->value.caltime.time.utime);
+ break;
+ case CALENDAR_MATCH_GREATER_THAN_OR_EQUAL:
+ snprintf(out_cond, sizeof(out_cond), "%s >= %lld", tmp, filter->value.caltime.time.utime);
+ break;
+ case CALENDAR_MATCH_LESS_THAN:
+ snprintf(out_cond, sizeof(out_cond), "%s < %lld", tmp, filter->value.caltime.time.utime);
+ break;
+ case CALENDAR_MATCH_LESS_THAN_OR_EQUAL:
+ snprintf(out_cond, sizeof(out_cond), "%s <= %lld", tmp, filter->value.caltime.time.utime);
+ break;
+ case CALENDAR_MATCH_NONE:
+ snprintf(out_cond, sizeof(out_cond), "%s IS NULL", tmp);
+ break;
+ case CALENDAR_MATCH_NOT_EQUAL:
+ snprintf(out_cond, sizeof(out_cond), "%s <> %lld", tmp, filter->value.caltime.time.utime);
+ break;
+ default :
+ ERR("Invalid parameter : int match rule(%d) is not supported", filter->match);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ else if (filter->value.caltime.type == CALENDAR_TIME_LOCALTIME )
+ {
+ char sdate[32] = {0};
+ snprintf(sdate, sizeof(sdate), CAL_FORMAT_LOCAL_DATETIME,
+ filter->value.caltime.time.date.year, filter->value.caltime.time.date.month, filter->value.caltime.time.date.mday,
+ filter->value.caltime.time.date.hour, filter->value.caltime.time.date.minute, filter->value.caltime.time.date.second);
+ tmp = __cal_db_query_get_datetime_field_name(field_name);
+ if (tmp == NULL)
+ {
+ tmp = field_name;
+ }
+ switch(filter->match)
+ {
+ case CALENDAR_MATCH_EQUAL:
+ snprintf(out_cond, sizeof(out_cond), "%s = '%s'", tmp, sdate);
+ break;
+ case CALENDAR_MATCH_GREATER_THAN:
+ snprintf(out_cond, sizeof(out_cond), "%s > '%s'", tmp, sdate);
+ break;
+ case CALENDAR_MATCH_GREATER_THAN_OR_EQUAL:
+ snprintf(out_cond, sizeof(out_cond), "%s >= '%s'", tmp, sdate);
+ break;
+ case CALENDAR_MATCH_LESS_THAN:
+ snprintf(out_cond, sizeof(out_cond), "%s < '%s'", tmp, sdate);
+ break;
+ case CALENDAR_MATCH_LESS_THAN_OR_EQUAL:
+ snprintf(out_cond, sizeof(out_cond), "%s <= '%s'", tmp, sdate);
+ break;
+ case CALENDAR_MATCH_NOT_EQUAL:
+ snprintf(out_cond, sizeof(out_cond), "%s <> '%s'", tmp, sdate);
+ break;
+ case CALENDAR_MATCH_NONE:
+ default :
+ ERR("Invalid parameter : int match rule(%d) is not supported", filter->match);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ }
+ else
+ {
+ ERR("Invalid parameter : property id(%d)", filter->property_id);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ cal_record_type_e record_type = _cal_view_get_type(com_filter->view_uri);
+ if (record_type != CAL_RECORD_TYPE_INSTANCE_NORMAL &&
+ record_type != CAL_RECORD_TYPE_INSTANCE_ALLDAY &&
+ record_type != CAL_RECORD_TYPE_INSTANCE_NORMAL_EXTENDED &&
+ record_type != CAL_RECORD_TYPE_INSTANCE_ALLDAY_EXTENDED)
+ {
+ int len = strlen(out_cond);
+ const char *type_field = __cal_db_query_get_timetype_field_name(field_name);
+ snprintf(out_cond + len, sizeof(out_cond) - len -1, " AND %s = %d ", type_field, filter->value.caltime.type);
+ }
+
+ *condition = strdup(out_cond);
+ return CALENDAR_ERROR_NONE;
+}
+
+static char * __cal_db_get_str_with_escape(char *str, int len, bool with_escape)
{
- const char *field_name;
- char out_cond[CAL_DB_SQL_MAX_LEN] = {0};
- const char *tmp = NULL;
-
- field_name = __cal_db_query_get_property_field_name(com_filter->properties,
- com_filter->property_count, filter->property_id);
- retvm_if(NULL == field_name, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid parameter : property id(%d)", filter->property_id);
-
- if (filter->value.caltime.type == CALENDAR_TIME_UTIME )
- {
- tmp = __cal_db_query_get_utime_field_name(field_name);
- if (tmp == NULL)
- {
- tmp = field_name;
- }
- switch(filter->match)
- {
- case CALENDAR_MATCH_EQUAL:
- snprintf(out_cond, sizeof(out_cond), "%s = %lld", tmp, filter->value.caltime.time.utime);
- break;
- case CALENDAR_MATCH_GREATER_THAN:
- snprintf(out_cond, sizeof(out_cond), "%s > %lld", tmp, filter->value.caltime.time.utime);
- break;
- case CALENDAR_MATCH_GREATER_THAN_OR_EQUAL:
- snprintf(out_cond, sizeof(out_cond), "%s >= %lld", tmp, filter->value.caltime.time.utime);
- break;
- case CALENDAR_MATCH_LESS_THAN:
- snprintf(out_cond, sizeof(out_cond), "%s < %lld", tmp, filter->value.caltime.time.utime);
- break;
- case CALENDAR_MATCH_LESS_THAN_OR_EQUAL:
- snprintf(out_cond, sizeof(out_cond), "%s <= %lld", tmp, filter->value.caltime.time.utime);
- break;
- case CALENDAR_MATCH_NONE:
- snprintf(out_cond, sizeof(out_cond), "%s IS NULL", tmp);
- break;
- case CALENDAR_MATCH_NOT_EQUAL:
- snprintf(out_cond, sizeof(out_cond), "%s <> %lld", tmp, filter->value.caltime.time.utime);
- break;
- default :
- ERR("Invalid parameter : int match rule(%d) is not supported", filter->match);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- else if (filter->value.caltime.type == CALENDAR_TIME_LOCALTIME )
- {
- char sdate[32] = {0};
- snprintf(sdate, sizeof(sdate), "%4d%02d%02d", filter->value.caltime.time.date.year
- , filter->value.caltime.time.date.month, filter->value.caltime.time.date.mday);
- tmp = __cal_db_query_get_datetime_field_name(field_name);
- if (tmp == NULL)
- {
- tmp = field_name;
- }
- switch(filter->match)
- {
- case CALENDAR_MATCH_EQUAL:
- snprintf(out_cond, sizeof(out_cond), "%s = %s", tmp, sdate);
- break;
- case CALENDAR_MATCH_GREATER_THAN:
- snprintf(out_cond, sizeof(out_cond), "%s > %s", tmp, sdate);
- break;
- case CALENDAR_MATCH_GREATER_THAN_OR_EQUAL:
- snprintf(out_cond, sizeof(out_cond), "%s >= %s", tmp, sdate);
- break;
- case CALENDAR_MATCH_LESS_THAN:
- snprintf(out_cond, sizeof(out_cond), "%s < %s", tmp, sdate);
- break;
- case CALENDAR_MATCH_LESS_THAN_OR_EQUAL:
- snprintf(out_cond, sizeof(out_cond), "%s <= %s", tmp, sdate);
- break;
- case CALENDAR_MATCH_NOT_EQUAL:
- snprintf(out_cond, sizeof(out_cond), "%s <> %s", tmp, sdate);
- break;
- case CALENDAR_MATCH_NONE:
- default :
- ERR("Invalid parameter : int match rule(%d) is not supported", filter->match);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
- ERR("Invalid parameter : property id(%d)", filter->property_id);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- *condition = strdup(out_cond);
- return CALENDAR_ERROR_NONE;
+ int i, j = 0;
+ char temp_str[len*2+1];
+
+ if (false == with_escape)
+ return strdup(str);
+
+ for(i=0;i<len;i++) {
+ if (str[i] == '\'' || str[i] == '_' || str[i] == '%' || str[i] == '\\') {
+ temp_str[j++] = CAL_DB_ESCAPE_CHAR;
+ }
+ temp_str[j++] = str[i];
+ }
+ temp_str[j] = '\0';
+
+ return strdup(temp_str);
}
static int __cal_db_query_create_str_condition(cal_composite_filter_s *com_filter,
- cal_attribute_filter_s *filter, char **condition, GSList **bind_text)
+ cal_attribute_filter_s *filter, char **condition, GSList **bind_text)
{
- const char *field_name;
- char out_cond[CAL_DB_SQL_MAX_LEN] = {0};
-
- field_name = __cal_db_query_get_property_field_name(com_filter->properties,
- com_filter->property_count, filter->property_id);
- retvm_if(NULL == field_name, CALENDAR_ERROR_INVALID_PARAMETER,
- "Invalid parameter : property id(%d)", filter->property_id);
-
- switch(filter->match)
- {
- case CALENDAR_MATCH_EXACTLY:
- snprintf(out_cond, sizeof(out_cond), "%s = ?", field_name);
- break;
- case CALENDAR_MATCH_FULLSTRING:
- snprintf(out_cond, sizeof(out_cond), "%s LIKE ?", field_name);
- break;
- case CALENDAR_MATCH_CONTAINS:
- snprintf(out_cond, sizeof(out_cond), "%s LIKE '%%' || ? || '%%'", field_name);
- break;
- case CALENDAR_MATCH_STARTSWITH:
- snprintf(out_cond, sizeof(out_cond), "%s LIKE ? || '%%'", field_name);
- break;
- case CALENDAR_MATCH_ENDSWITH:
- snprintf(out_cond, sizeof(out_cond), "%s LIKE '%%' || ?", field_name);
- break;
- case CALENDAR_MATCH_EXISTS:
- snprintf(out_cond, sizeof(out_cond), "%s IS NOT NULL", field_name);
- break;
- default :
- ERR("Invalid paramter : int match rule (%d) is not supported", filter->match);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- if (filter->value.s)
- {
- *bind_text = g_slist_append(*bind_text, filter->value.s);
- }
- *condition = strdup(out_cond);
- return CALENDAR_ERROR_NONE;
+ const char *field_name;
+ char out_cond[CAL_DB_SQL_MAX_LEN] = {0};
+ bool with_escape = true;
+
+ field_name = __cal_db_query_get_property_field_name(com_filter->properties,
+ com_filter->property_count, filter->property_id);
+ retvm_if(NULL == field_name, CALENDAR_ERROR_INVALID_PARAMETER,
+ "Invalid parameter : property id(%d)", filter->property_id);
+
+ switch(filter->match)
+ {
+ case CALENDAR_MATCH_EXACTLY:
+ snprintf(out_cond, sizeof(out_cond), "%s = ?", field_name);
+ with_escape = false;
+ break;
+ case CALENDAR_MATCH_FULLSTRING:
+ snprintf(out_cond, sizeof(out_cond), "%s LIKE ? ESCAPE '%c'", field_name, CAL_DB_ESCAPE_CHAR);
+ break;
+ case CALENDAR_MATCH_CONTAINS:
+ snprintf(out_cond, sizeof(out_cond), "%s LIKE ('%%' || ? || '%%') ESCAPE '%c'", field_name, CAL_DB_ESCAPE_CHAR);
+ break;
+ case CALENDAR_MATCH_STARTSWITH:
+ snprintf(out_cond, sizeof(out_cond), "%s LIKE ( ? || '%%') ESCAPE '%c'", field_name, CAL_DB_ESCAPE_CHAR);
+ break;
+ case CALENDAR_MATCH_ENDSWITH:
+ snprintf(out_cond, sizeof(out_cond), "%s LIKE ('%%' || ?) ESCAPE '%c'", field_name, CAL_DB_ESCAPE_CHAR);
+ break;
+ case CALENDAR_MATCH_EXISTS:
+ snprintf(out_cond, sizeof(out_cond), "%s IS NOT NULL", field_name);
+ break;
+ default :
+ ERR("Invalid paramter : int match rule (%d) is not supported", filter->match);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (filter->value.s)
+ {
+ *bind_text = g_slist_append(*bind_text,
+ __cal_db_get_str_with_escape(filter->value.s, strlen(filter->value.s), with_escape));
+ }
+ *condition = strdup(out_cond);
+ return CALENDAR_ERROR_NONE;
}
static const char * __cal_db_query_get_property_field_name(const cal_property_info_s *properties,
- int count, unsigned int property_id)
+ int count, unsigned int property_id)
{
- int i;
- for (i=0;i<count;i++)
- {
- cal_property_info_s *p = (cal_property_info_s*)&(properties[i]);
- if (property_id == p->property_id)
- {
- if (p->fields)
- return p->fields;
- else
- return NULL; //ctsvc_get_display_column();
- }
- }
- return NULL;
+ int i;
+ for (i=0;i<count;i++)
+ {
+ cal_property_info_s *p = (cal_property_info_s*)&(properties[i]);
+ if (property_id == p->property_id)
+ {
+ if (p->fields)
+ return p->fields;
+ else
+ return NULL; //ctsvc_get_display_column();
+ }
+ }
+ return NULL;
}
static const char * __cal_db_query_get_utime_field_name(const char* src)
{
- char *tmp1 = NULL;
- int i=0;
-
- for(i=0;i<CAL_DB_CALTIME_FIELD_MAX;i++)
- {
- tmp1 = strstr(src,__cal_db_utime_field_name[i]);
- if (tmp1 != NULL)
- {
- return __cal_db_utime_field_name[i];
- }
- }
-
- return NULL;
+ char *tmp1 = NULL;
+ int i=0;
+
+ for(i=0;i<CAL_DB_CALTIME_FIELD_MAX;i++)
+ {
+ tmp1 = strstr(src,__cal_db_utime_field_name[i]);
+ if (tmp1 != NULL)
+ {
+ return __cal_db_utime_field_name[i];
+ }
+ }
+
+ return NULL;
}
static const char * __cal_db_query_get_datetime_field_name(const char* src)
{
- char *tmp1 = NULL;
- int i=0;
-
- for(i=0;i<CAL_DB_CALTIME_FIELD_MAX;i++)
- {
- tmp1 = strstr(src,__cal_db_datetime_field_name[i]);
- if (tmp1 != NULL)
- {
- return __cal_db_datetime_field_name[i];
- }
- }
-
- return NULL;
+ char *tmp1 = NULL;
+ int i=0;
+
+ for(i=0;i<CAL_DB_CALTIME_FIELD_MAX;i++)
+ {
+ tmp1 = strstr(src,__cal_db_datetime_field_name[i]);
+ if (tmp1 != NULL)
+ {
+ return __cal_db_datetime_field_name[i];
+ }
+ }
+
+ return NULL;
}
static const char * __cal_db_query_get_timetype_field_name(const char* src)
{
- char *tmp1 = NULL;
- int i=0;
-
- for(i=0;i<CAL_DB_CALTIME_FIELD_MAX;i++)
- {
- tmp1 = strstr(src,__cal_db_timetype_field_name[i]);
- if (tmp1 != NULL)
- {
- return __cal_db_timetype_field_name[i];
- }
- }
-
- return NULL;
+ char *tmp1 = NULL;
+ int i=0;
+
+ for(i=0;i<CAL_DB_CALTIME_FIELD_MAX;i++)
+ {
+ tmp1 = strstr(src,__cal_db_timetype_field_name[i]);
+ if (tmp1 != NULL)
+ {
+ return __cal_db_timetype_field_name[i];
+ }
+ }
+
+ return NULL;
}
/*
* bind_text->date string is only pointer copy.
- if (bind_text)
- {
- g_slist_free(bind_text);
- }
- CAL_FREE(condition);
- CAL_FREE(projection);
+ if (bind_text) {
+ g_slist_free(bind_text);
+ }
+ CAL_FREE(condition);
+ CAL_FREE(projection);
*/
int _cal_db_query_create_condition(calendar_query_h query, char **condition, GSList **bind_text);
int _cal_db_query_create_projection(calendar_query_h query, char **projection);
-int _cal_db_query_create_order(calendar_query_h query, char **order);
+int _cal_db_query_create_order(calendar_query_h query, char *condition, char **order);
bool _cal_db_query_find_projection_property(calendar_query_h query, unsigned int property);
/*
* bind_text is strdup copy
* please check bind_text free
- CAL_FREE(set);
- if(bind_text)
- {
- for (cursor=bind_text; cursor;cursor=cursor->next)
- {
- CAL_FREE(cursor->data);
- }
- g_slist_free(bind_text);
- }
+ CAL_FREE(set);
+ if(bind_text) {
+ for (cursor=bind_text; cursor;cursor=cursor->next) {
+ CAL_FREE(cursor->data);
+ }
+ g_slist_free(bind_text);
+ }
*/
int _cal_db_query_create_projection_update_set(calendar_record_h record, char **set, GSList **bind_text);
int _cal_db_query_create_projection_update_set_with_property(
- calendar_record_h record, unsigned int *properties, int properties_count,
- char **set, GSList **bind_text);
+ calendar_record_h record, unsigned int *properties, int properties_count,
+ char **set, GSList **bind_text);
#endif // __CALENDAR_SVC_DB_QUERY_H__
event = (cal_event_s *)record;
- switch (event->freq)
- {
+ switch (event->freq) {
case CALENDAR_RECURRENCE_NONE:
break;
case CALENDAR_RECURRENCE_DAILY:
break;
case CALENDAR_RECURRENCE_WEEKLY:
- if (event->bymonthday || event->byday)
+ if (event->byday && strlen(event->byday) > 0)
+ {
break;
+ }
- event->byday = _cal_time_extract_by(event->start_tzid, event->wkst,
+ event->byday = _cal_time_extract_by(event->system_type, event->start_tzid, event->wkst,
&event->start, CAL_DAY_OF_WEEK);
DBG("Not enough field in weekly, so set byda[%s]", event->byday);
break;
case CALENDAR_RECURRENCE_MONTHLY:
- if (event->bymonthday || event->byday)
+ if (event->bymonthday && strlen(event->bymonthday) > 0) {
+ break;
+ }
+ else if (event->byday && strlen(event->byday) > 0) {
break;
+ }
- event->bymonthday = _cal_time_extract_by(event->start_tzid, event->wkst,
+ event->bymonthday = _cal_time_extract_by(event->system_type, event->start_tzid, event->wkst,
&event->start, CAL_DATE);
DBG("Not enough field in monthly, so set bymonthday[%s]", event->bymonthday);
break;
case CALENDAR_RECURRENCE_YEARLY:
- if (event->bymonth && (event->bymonthday || event->byday))
+ if (event->bymonth && strlen(event->bymonth) > 0) {
break;
- else if (event->byyearday || event->byweekno)
+ }
+ else if (event->byyearday && strlen(event->byyearday) > 0) {
break;
+ }
+ else if (event->byweekno && strlen(event->byweekno) > 0) {
+ break;
+ }
- event->bymonth = _cal_time_extract_by(event->start_tzid, event->wkst,
+ event->bymonth = _cal_time_extract_by(event->system_type, event->start_tzid, event->wkst,
&event->start, CAL_MONTH);
- event->bymonthday = _cal_time_extract_by(event->start_tzid, event->wkst,
+ event->bymonthday = _cal_time_extract_by(event->system_type, event->start_tzid, event->wkst,
&event->start, CAL_DATE);
DBG("Not enough field in yearly, so set bymonth[%s] bymonthday[%s]",
event->bymonth, event->bymonthday);
retm_if(event == NULL, "Invalid argument: rrule is NULL");
_event = (cal_event_s *)event;
- if (_event->freq == CALENDAR_RECURRENCE_NONE)
- {
+ if (_event->freq == CALENDAR_RECURRENCE_NONE) {
return;
}
_rrule->freq = _event->freq;
_rrule->range_type = _event->range_type;
- switch (_rrule->range_type)
- {
+ switch (_rrule->range_type) {
case CALENDAR_RANGE_UNTIL:
- _rrule->until_type = _event->until_type;
- switch (_rrule->until_type)
- {
- case CALENDAR_TIME_UTIME:
- _rrule->until_utime = _event->until_utime;
- break;
-
- case CALENDAR_TIME_LOCALTIME:
- _rrule->until_year = _event->until_year;
- _rrule->until_month = _event->until_month;
- _rrule->until_mday = _event->until_mday;
- break;
- }
+ _rrule->until = _event->until;
break;
-
case CALENDAR_RANGE_COUNT:
break;
case CALENDAR_RANGE_NONE:
_event->freq = rrule->freq;
_event->range_type = rrule->range_type;
- _event->until_type = rrule->until_type;
- _event->until_utime = rrule->until_utime;
- _event->until_year = rrule->until_year;
- _event->until_month = rrule->until_month;
- _event->until_mday = rrule->until_mday;
+ _event->until = rrule->until;
_event->count = rrule->count;
_event->interval = rrule->interval;
_event->bysecond = rrule->bysecond;
_todo->freq = rrule->freq;
_todo->range_type = rrule->range_type;
- _todo->until_type = rrule->until_type;
- _todo->until_utime = rrule->until_utime;
- _todo->until_year = rrule->until_year;
- _todo->until_month = rrule->until_month;
- _todo->until_mday = rrule->until_mday;
+ _todo->until = rrule->until;
_todo->count = rrule->count;
_todo->interval = rrule->interval;
_todo->bysecond = rrule->bysecond;
_rrule->freq = _todo->freq;
_rrule->range_type = _todo->range_type;
- _rrule->until_type = _todo->until_type;
- _rrule->until_utime = _todo->until_utime;
- _rrule->until_year = _todo->until_year;
- _rrule->until_month = _todo->until_month;
- _rrule->until_mday = _todo->until_mday;
+ _rrule->until = _todo->until;
_rrule->count = _todo->count;
_rrule->interval = _todo->interval;
_rrule->bysecond = _todo->bysecond;
char query[CAL_DB_SQL_MAX_LEN] = {0};
char until_datetime[32] = {0};
sqlite3_stmt *stmt = NULL;
- cal_db_util_error_e dbret = CAL_DB_OK;
+ cal_db_util_error_e dbret = CAL_DB_OK;
retvm_if(rrule == NULL, CALENDAR_ERROR_INVALID_PARAMETER,
"Invalid argument: rrule is NULL");
") ",
CAL_TABLE_RRULE,
id, rrule->freq, rrule->range_type,
- rrule->until_type, rrule->until_type == CALENDAR_TIME_UTIME ? rrule->until_utime : 0,
+ rrule->until.type, rrule->until.time.utime,
rrule->count, rrule->interval,
rrule->wkst);
- DBG("[%s]", query);
stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
+ if (NULL == stmt) {
DBG("query[%s]", query);
ERR("_cal_db_util_query_prepare() Failed");
return CALENDAR_ERROR_DB_FAILED;
index = 1;
- if (CALENDAR_TIME_LOCALTIME == rrule->until_type)
- {
- snprintf(until_datetime, sizeof(until_datetime), "%04d%02d%02d",
- rrule->until_year, rrule->until_month, rrule->until_mday);
+ if (CALENDAR_TIME_LOCALTIME == rrule->until.type) {
+ snprintf(until_datetime, sizeof(until_datetime), CAL_FORMAT_LOCAL_DATETIME,
+ rrule->until.time.date.year,
+ rrule->until.time.date.month,
+ rrule->until.time.date.mday,
+ rrule->until.time.date.hour,
+ rrule->until.time.date.minute,
+ rrule->until.time.date.second);
_cal_db_util_stmt_bind_text(stmt, index, until_datetime);
}
index++;
dbret = _cal_db_util_stmt_step(stmt);
sqlite3_finalize(stmt);
- if (CAL_DB_OK != dbret)
- {
+ if (CAL_DB_OK != dbret) {
ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
- switch (dbret)
- {
+ switch (dbret) {
case CAL_DB_ERROR_NO_SPACE:
return CALENDAR_ERROR_FILE_NO_SPACE;
default:
const unsigned char *temp;
cal_db_util_error_e dbret = CAL_DB_OK;
- _rrule = calloc(1, sizeof(cal_rrule_s));
- retvm_if(_rrule == NULL, CALENDAR_ERROR_OUT_OF_MEMORY,
- "Failed to calloc");
-
snprintf(query, sizeof(query),
- "SELECT * FROM %s "
- "WHERE event_id = %d ",
- CAL_TABLE_RRULE,
- id);
+ "SELECT id, event_id, freq, range_type, until_type, until_utime, "
+ "until_datetime, count, interval, bysecond, byminute, byhour, byday, "
+ "bymonthday, byyearday, byweekno, bymonth, bysetpos, wkst "
+ "FROM %s WHERE event_id = %d ",
+ CAL_TABLE_RRULE, id);
stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
+ if (NULL == stmt) {
ERR("_cal_db_util_query_prepare() Failed");
- CAL_FREE(_rrule);
return CALENDAR_ERROR_DB_FAILED;
}
dbret = _cal_db_util_stmt_step(stmt);
- if (dbret != CAL_DB_ROW) {
+ if (CAL_DB_DONE == dbret) {
+ DBG("No event: id(%d)", id);
+ sqlite3_finalize(stmt);
+ return CALENDAR_ERROR_DB_RECORD_NOT_FOUND;
+ }
+ else if (CAL_DB_ROW != dbret) {
+ ERR("query[%s]", query);
ERR("Failed to step stmt(%d)", dbret);
sqlite3_finalize(stmt);
- CAL_FREE(_rrule);
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
+ return CALENDAR_ERROR_DB_FAILED;
}
+ _rrule = calloc(1, sizeof(cal_rrule_s));
+ retvm_if(_rrule == NULL, CALENDAR_ERROR_OUT_OF_MEMORY,
+ "Failed to calloc");
+
index = 0;
sqlite3_column_int(stmt, index++); // id
sqlite3_column_int(stmt, index++); // event_id
//rrule->_rrule_id = 1;
_rrule->range_type = sqlite3_column_int(stmt, index++);
- _rrule->until_type = sqlite3_column_int(stmt, index++);
- _rrule->until_utime = sqlite3_column_int64(stmt, index++);
+ _rrule->until.type = sqlite3_column_int(stmt, index++);
+ _rrule->until.time.utime = sqlite3_column_int64(stmt, index++);
temp = sqlite3_column_text(stmt, index++);
- if (CALENDAR_TIME_LOCALTIME == _rrule->until_type)
- {
- sscanf((const char *)temp, "%04d%02d%02d",
- &_rrule->until_year, &_rrule->until_month, &_rrule->until_mday);
+ if (CALENDAR_TIME_LOCALTIME == _rrule->until.type) {
+ sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME,
+ &_rrule->until.time.date.year,
+ &_rrule->until.time.date.month,
+ &_rrule->until.time.date.mday,
+ &_rrule->until.time.date.hour,
+ &_rrule->until.time.date.minute,
+ &_rrule->until.time.date.second);
}
_rrule->count = sqlite3_column_int(stmt, index++);
CAL_TABLE_RRULE, id);
dbret = _cal_db_util_query_exec(query);
- if(CAL_DB_DONE != dbret)
- {
+ if(CAL_DB_DONE != dbret) {
ERR("_cal_db_util_query_exec() Failed");
switch (dbret)
{
static int __cal_db_rrule_has_record(int id, int *has_record)
{
- int ret;
- int count = 0;
+ int ret = CALENDAR_ERROR_NONE;
+ int count = 0;
char query[CAL_DB_SQL_MAX_LEN] = {0};
snprintf(query, sizeof(query),
CAL_TABLE_RRULE, id);
ret = _cal_db_util_query_get_first_int_result(query, NULL, &count);
- if (CALENDAR_ERROR_NONE != ret)
- {
+ if (CALENDAR_ERROR_NONE != ret) {
ERR("_cal_db_util_query_get_first_int_result() failed");
return ret;
}
CAL_TABLE_RRULE,
rrule->freq,
rrule->range_type,
- rrule->until_type,
- rrule->until_type == CALENDAR_TIME_UTIME ? rrule->until_utime : 0,
+ rrule->until.type,
+ rrule->until.time.utime,
rrule->count,
rrule->interval,
rrule->wkst,
id);
stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
+ if (NULL == stmt) {
DBG("query[%s]", query);
ERR("_cal_db_util_query_prepare() Failed");
return CALENDAR_ERROR_DB_FAILED;
}
int index = 1;
- if (CALENDAR_TIME_LOCALTIME == rrule->until_type)
- {
- snprintf(until_datetime, sizeof(until_datetime), "%04d%02d%02d",
- rrule->until_year, rrule->until_month, rrule->until_mday);
+ if (CALENDAR_TIME_LOCALTIME == rrule->until.type) {
+ snprintf(until_datetime, sizeof(until_datetime), CAL_FORMAT_LOCAL_DATETIME,
+ rrule->until.time.date.year,
+ rrule->until.time.date.month,
+ rrule->until.time.date.mday,
+ rrule->until.time.date.hour,
+ rrule->until.time.date.minute,
+ rrule->until.time.date.second);
_cal_db_util_stmt_bind_text(stmt, index, until_datetime);
}
index++;
sqlite3_finalize(stmt);
if (CAL_DB_DONE != dbret) {
ERR("sqlite3_step() Failed(%d)", dbret);
- switch (dbret)
- {
+ switch (dbret) {
case CAL_DB_ERROR_NO_SPACE:
return CALENDAR_ERROR_FILE_NO_SPACE;
default:
retvm_if(rrule == NULL, CALENDAR_ERROR_INVALID_PARAMETER,
"Invalid argument: rrule is NULL");
- if (rrule->freq == CALENDAR_RECURRENCE_NONE)
- {
+ if (rrule->freq == CALENDAR_RECURRENCE_NONE) {
}
- else
- {
+ else {
__cal_db_rrule_insert_record(id, rrule);
}
return CALENDAR_ERROR_NONE;
{
int has_record = 0;
- if (NULL == rrule || rrule->freq == CALENDAR_RECURRENCE_NONE)
- {
+ if (NULL == rrule || rrule->freq == CALENDAR_RECURRENCE_NONE) {
DBG("freq is NONE");
__cal_db_rrule_delete_record(id);
return CALENDAR_ERROR_NONE;
}
- else
- {
+ else {
__cal_db_rrule_has_record(id, &has_record);
- if (has_record)
- {
+ if (has_record) {
__cal_db_rrule_update_record(id, rrule);
}
- else
- {
+ else {
__cal_db_rrule_insert_record(id, rrule);
}
}
#include <fcntl.h>
#include <stdbool.h>
#include <db-util.h>
+#include <sys/time.h>
#include "cal_internal.h"
#include "cal_typedef.h"
static inline void __cal_db_util_cancel_changes(void)
{
- event_change = false;
- calendar_change = false;
- todo_change = false;
+ event_change = false;
+ calendar_change = false;
+ todo_change = false;
}
int _cal_db_util_notify(cal_noti_type_e type)
return sqlite3_last_insert_rowid(calendar_db_handle);
}
+#define __CAL_QUERY_RETRY_TIME 2
+
int _cal_db_util_query_get_first_int_result(const char *query, GSList *bind_text, int *result)
{
int ret;
int index;
char *text = NULL;
+ struct timeval from, now, diff;
+ bool retry = false;
sqlite3_stmt *stmt = NULL;
retvm_if(NULL == calendar_db_handle, CALENDAR_ERROR_DB_FAILED, "Database is not opended");
- ret = sqlite3_prepare_v2(calendar_db_handle, query, strlen(query), &stmt, NULL);
- retvm_if(SQLITE_OK != ret, CALENDAR_ERROR_DB_FAILED,
- "sqlite3_prepare_v2(%s) failed(%s).", query, sqlite3_errmsg(calendar_db_handle));
+ gettimeofday(&from, NULL);
+ do
+ {
+ ret = sqlite3_prepare_v2(calendar_db_handle, query, strlen(query), &stmt, NULL);
+ if (SQLITE_BUSY == ret || SQLITE_LOCKED == ret)
+ {
+ ERR("sqlite3_prepare_v2(%s) failed(%s).", query, sqlite3_errmsg(calendar_db_handle));
+ gettimeofday(&now, NULL);
+ timersub(&now, &from, &diff);
+ retry = (diff.tv_sec < __CAL_QUERY_RETRY_TIME) ? true : false;
+ if (retry)
+ {
+ usleep(50 * 1000); // 50ms
+ }
+ }
+ else
+ {
+ retry = false;
+ }
+ } while(retry);
+
+ if (SQLITE_OK != ret)
+ {
+ ERR("sqlite3_prepare_v2(%s) failed(%s).", query, sqlite3_errmsg(calendar_db_handle));
+ return CALENDAR_ERROR_DB_FAILED;
+ }
if (bind_text)
{
}
}
- ret = sqlite3_step(stmt);
- if (SQLITE_ROW != ret)
+ retry = false;
+ gettimeofday(&from, NULL);
+ do
{
- ERR("sqlite3_step() failed(%d, %s).", ret, sqlite3_errmsg(calendar_db_handle));
- sqlite3_finalize(stmt);
- if (SQLITE_DONE == ret)
- return CALENDAR_ERROR_DB_RECORD_NOT_FOUND;
- return CALENDAR_ERROR_DB_FAILED;
- }
+ ret = sqlite3_step(stmt);
+ if (SQLITE_ROW != ret)
+ {
+ if (SQLITE_DONE == ret)
+ {
+ sqlite3_finalize(stmt);
+ return CALENDAR_ERROR_DB_RECORD_NOT_FOUND;
+ }
+ else if (SQLITE_BUSY == ret || SQLITE_LOCKED == ret)
+ {
+ ERR("sqlite3_step fail(%d, %s)", ret, sqlite3_errmsg(calendar_db_handle));
+ gettimeofday(&now, NULL);
+ timersub(&now, &from, &diff);
+ retry = (diff.tv_sec < __CAL_QUERY_RETRY_TIME) ? true : false;
+ if (retry)
+ {
+ usleep(50 * 1000); // 50ms
+ }
+ }
+ else
+ {
+ ERR("sqlite3_step() failed(%d, %s).", ret, sqlite3_errmsg(calendar_db_handle));
+ retry = false;
+ }
+ }
+ else
+ if (result) *result = sqlite3_column_int(stmt, 0);
+ } while(retry);
- if (result) *result = sqlite3_column_int(stmt, 0);
sqlite3_finalize(stmt);
return CALENDAR_ERROR_NONE;
cal_db_util_error_e _cal_db_util_query_exec(char *query)
{
int ret;
- char *err_msg = NULL;
+ sqlite3_stmt *stmt = NULL;
retvm_if(NULL == calendar_db_handle, CALENDAR_ERROR_DB_FAILED, "Database is not opended");
- //CALS_DBG("query : %s", query);
-
- ret = sqlite3_exec(calendar_db_handle, query, NULL, NULL, &err_msg);
- if (SQLITE_OK != ret) {
- ERR("sqlite3_exec(%s) failed(%d, %s).", query, ret, err_msg);
- sqlite3_free(err_msg);
- switch (ret) {
- case SQLITE_BUSY:
- case SQLITE_LOCKED:
- return CAL_DB_ERROR_LOCKED;
- case SQLITE_IOERR:
- return CAL_DB_ERROR_IOERR;
- case SQLITE_FULL:
- return CAL_DB_ERROR_NO_SPACE;
- default:
- return CAL_DB_ERROR_FAIL;
- }
- }
- if (err_msg)
- {
- sqlite3_free(err_msg);
+
+ stmt = _cal_db_util_query_prepare(query);
+ retvm_if(NULL == stmt, CAL_DB_ERROR_FAIL, "_cal_db_util_query_prepare() Failed");
+
+ ret = _cal_db_util_stmt_step(stmt);
+
+ if (CAL_DB_DONE != ret) {
+ sqlite3_finalize(stmt);
+ ERR("_cal_db_util_stmt_step() Failed(%d)", ret);
+ SEC_ERR("[ %s ]", query);
+ return ret;
}
+ sqlite3_finalize(stmt);
return CAL_DB_OK;
}
sqlite3_stmt* _cal_db_util_query_prepare(char *query)
{
int ret = -1;
+ struct timeval from, now, diff;
+ bool retry = false;
sqlite3_stmt *stmt = NULL;
retvm_if(NULL == query, NULL, "Invalid query");
retvm_if(NULL == calendar_db_handle, NULL, "Database is not opended");
//CALS_DBG("prepare query : %s", query);
- ret = sqlite3_prepare_v2(calendar_db_handle, query, strlen(query), &stmt, NULL);
- retvm_if(SQLITE_OK != ret, NULL,
- "sqlite3_prepare_v2(%s) Failed(%s).", query, sqlite3_errmsg(calendar_db_handle));
+ gettimeofday(&from, NULL);
+ do
+ {
+ ret = sqlite3_prepare_v2(calendar_db_handle, query, strlen(query), &stmt, NULL);
+ if (SQLITE_BUSY == ret || SQLITE_LOCKED == ret)
+ {
+ gettimeofday(&now, NULL);
+ timersub(&now, &from, &diff);
+ retry = (diff.tv_sec < __CAL_QUERY_RETRY_TIME) ? true : false;
+ if (retry)
+ {
+ usleep(50 * 1000); // 50ms
+ }
+ }
+ else
+ {
+ retry = false;
+ }
+ } while(retry);
return stmt;
}
cal_db_util_error_e _cal_db_util_stmt_step(sqlite3_stmt *stmt)
{
int ret;
- ret = sqlite3_step(stmt);
- switch (ret) {
- case SQLITE_BUSY:
- case SQLITE_LOCKED:
- ret = CAL_DB_ERROR_LOCKED;
- break;
- case SQLITE_IOERR:
- ret = CAL_DB_ERROR_IOERR;
- break;
- case SQLITE_FULL:
- ret = CAL_DB_ERROR_NO_SPACE;
- break;
- case SQLITE_CONSTRAINT:
- ret = CAL_DB_ERROR_ALREADY_EXIST;
- break;
- case SQLITE_ROW:
- ret = CAL_DB_ROW;
- break;
- case SQLITE_DONE:
- ret = CAL_DB_DONE;
- break;
- default:
- ERR("sqlite3_step() Failed(%d)", ret);
- ret = CAL_DB_ERROR_FAIL;
- break;
- }
- return ret;
+ struct timeval from, now, diff;
+ bool retry = false;
+
+ gettimeofday(&from, NULL);
+ do
+ {
+ ret = sqlite3_step(stmt);
+ if (SQLITE_BUSY == ret || SQLITE_LOCKED == ret)
+ {
+ gettimeofday(&now, NULL);
+ timersub(&now, &from, &diff);
+ retry = (diff.tv_sec < __CAL_QUERY_RETRY_TIME) ? true : false;
+ if (retry)
+ {
+ usleep(50 * 1000); // 50ms
+ }
+ }
+ else
+ {
+ retry = false;
+ }
+ } while(retry);
+
+ switch (ret)
+ {
+ case SQLITE_BUSY:
+ case SQLITE_LOCKED:
+ ret = CAL_DB_ERROR_LOCKED;
+ break;
+ case SQLITE_IOERR:
+ ret = CAL_DB_ERROR_IOERR;
+ break;
+ case SQLITE_FULL:
+ ret = CAL_DB_ERROR_NO_SPACE;
+ break;
+ case SQLITE_CONSTRAINT:
+ ret = CAL_DB_ERROR_ALREADY_EXIST;
+ break;
+ case SQLITE_ROW:
+ ret = CAL_DB_ROW;
+ break;
+ case SQLITE_DONE:
+ ret = CAL_DB_DONE;
+ break;
+ default:
+ ERR("sqlite3_step() Failed(%d)", ret);
+ ret = CAL_DB_ERROR_FAIL;
+ break;
+ }
+ return ret;
}
#define CAL_COMMIT_TRY_MAX 500000
warn_if(CAL_DB_OK != ret, "cal_query_exec(version up) Failed(%d).", ret);
}
+ INFO("start commit");
progress = 100000;
ret = _cal_db_util_query_exec("COMMIT TRANSACTION");
// !! check error code
ret = _cal_db_util_query_exec("COMMIT TRANSACTION");
progress *= 2;
}
+ INFO("%s", (CAL_DB_OK == ret)?"commit": "rollback");
+
if (CAL_DB_OK != ret) {
int tmp_ret;
ERR("cal_query_exec() Failed(%d)", ret);
int _cal_db_util_get_transaction_ver(void)
{
- return transaction_ver;
+ return transaction_ver;
}
typedef enum
{
- CAL_DB_ERROR_FAIL = -1,
- CAL_DB_ERROR_LOCKED = -204, //SQLITE_BUSY, SQLITE_LOCKED
- CAL_DB_ERROR_IOERR = -10, //SQLITE_IOERR /* Some kind of disk I/O error occurred */
- CAL_DB_ERROR_NO_SPACE = -11, //SQLITE_FULL /* Insertion failed because database is full */
- CAL_DB_ERROR_ALREADY_EXIST = -7, //SQLITE_CONSTRAINT /* Abort due to constraint violation */
- CAL_DB_ROW = 1, //SQLITE_ROW CAL_TRUE /* sqlite3_step() has another row ready */
- CAL_DB_DONE = 0, //SQLITE_DONE CAL_SUCCESS /* sqlite3_step() has finished executing */
- CAL_DB_OK = 0, //SQLITE_OK /* Successful result */
+ CAL_DB_ERROR_FAIL = -1,
+ CAL_DB_ERROR_LOCKED = -204, //SQLITE_BUSY, SQLITE_LOCKED
+ CAL_DB_ERROR_IOERR = -10, //SQLITE_IOERR /* Some kind of disk I/O error occurred */
+ CAL_DB_ERROR_NO_SPACE = -11, //SQLITE_FULL /* Insertion failed because database is full */
+ CAL_DB_ERROR_ALREADY_EXIST = -7, //SQLITE_CONSTRAINT /* Abort due to constraint violation */
+ CAL_DB_ROW = 1, //SQLITE_ROW CAL_TRUE /* sqlite3_step() has another row ready */
+ CAL_DB_DONE = 0, //SQLITE_DONE CAL_SUCCESS /* sqlite3_step() has finished executing */
+ CAL_DB_OK = 0, //SQLITE_OK /* Successful result */
} cal_db_util_error_e;
int _cal_db_util_notify(cal_noti_type_e type);
cal_db_util_error_e _cal_db_util_stmt_step(sqlite3_stmt *stmt);
static inline int _cal_db_util_stmt_bind_text(sqlite3_stmt *stmt, int pos, const char *str) {
- return sqlite3_bind_text(stmt, pos, str, str ? strlen(str) : 0, SQLITE_STATIC);
+ return sqlite3_bind_text(stmt, pos, str, str ? strlen(str) : 0, SQLITE_STATIC);
}
int _cal_db_util_begin_trans(void);
#include "cal_view.h"
#include "cal_time.h"
#include "cal_record.h"
+#include "cal_access_control.h"
#include "cal_db_util.h"
#include "cal_db.h"
-API int calendar_reminder_add_receiver(const char *pkgname, const char *extra_data_key, const char *extra_data_value)
-{
- int index;
- int count = 0;
- cal_db_util_error_e dbret = CAL_DB_OK;
- char query[CAL_DB_SQL_MAX_LEN];
- sqlite3_stmt *stmt;
-
- if (pkgname == NULL || strlen(pkgname) == 0)
- {
- ERR("Invalid parameter");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- // check whether already registered
- snprintf(query, sizeof(query), "SELECT count(*) FROM %s WHERE pkgname = ? ",
- CAL_REMINDER_ALERT);
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- _cal_db_util_stmt_bind_text(stmt, 1, pkgname);
-
- dbret = _cal_db_util_stmt_step(stmt);
- if (CAL_DB_ROW == dbret)
- {
- index = 0;
- count = sqlite3_column_int(stmt, index++);
- }
- sqlite3_finalize(stmt);
-
- if (count > 0)
- {
- DBG("Already registered pkgname[%s]", pkgname);
- return CALENDAR_ERROR_NONE;
- }
-
- // register
- snprintf(query, sizeof(query),
- "INSERT INTO %s ( pkgname, key, value ) VALUES ( ?, ?, ? ) ",
- CAL_REMINDER_ALERT);
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- index = 1;
- _cal_db_util_stmt_bind_text(stmt, index++, pkgname);
- _cal_db_util_stmt_bind_text(stmt, index++, extra_data_key);
- _cal_db_util_stmt_bind_text(stmt, index++, extra_data_value);
- dbret = _cal_db_util_stmt_step(stmt);
- sqlite3_finalize(stmt);
-
- if (CAL_DB_DONE != dbret)
- {
- ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
-
- return CALENDAR_ERROR_NONE;
-}
-
-API int calendar_reminder_remove_receiver(const char *pkgname)
-{
- cal_db_util_error_e dbret = CAL_DB_OK;
- char query[CAL_DB_SQL_MAX_LEN];
- sqlite3_stmt *stmt;
-
- if (pkgname == NULL || strlen(pkgname) == 0)
- {
- ERR("Invalid parameter");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- snprintf(query, sizeof(query), "DELETE FROM %s WHERE pkgname = ? ",
- CAL_REMINDER_ALERT);
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- _cal_db_util_stmt_bind_text(stmt, 1, pkgname);
- dbret = _cal_db_util_stmt_step(stmt);
- sqlite3_finalize(stmt);
-
- if (CAL_DB_DONE != dbret)
- {
- ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
-
- return CALENDAR_ERROR_NONE;
-}
-
-API int calendar_reminder_activate_receiver(const char *pkgname)
-{
- cal_db_util_error_e dbret = CAL_DB_OK;
- char query[CAL_DB_SQL_MAX_LEN];
- sqlite3_stmt *stmt;
-
- if (pkgname == NULL || strlen(pkgname) == 0)
- {
- ERR("Invalid parameter");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- snprintf(query, sizeof(query), "UPDATE %s SET onoff = 1 WHERE pkgname = ? ",
- CAL_REMINDER_ALERT);
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- _cal_db_util_stmt_bind_text(stmt, 1, pkgname);
- dbret = _cal_db_util_stmt_step(stmt);
- sqlite3_finalize(stmt);
-
- if (CAL_DB_DONE != dbret)
-{
- ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
-
- return CALENDAR_ERROR_NONE;
-}
-
-API int calendar_reminder_deactivate_receiver(const char *pkgname)
-{
- cal_db_util_error_e dbret = CAL_DB_OK;
- char query[CAL_DB_SQL_MAX_LEN];
- sqlite3_stmt *stmt;
-
- if (pkgname == NULL || strlen(pkgname) == 0)
- {
- ERR("Invalid parameter");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- snprintf(query, sizeof(query), "UPDATE %s SET onoff = 0 WHERE pkgname = ? ",
- CAL_REMINDER_ALERT);
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- _cal_db_util_stmt_bind_text(stmt, 1, pkgname);
- dbret = _cal_db_util_stmt_step(stmt);
- sqlite3_finalize(stmt);
-
- if (CAL_DB_DONE != dbret)
- {
- ERR("_cal_db_util_stmt_step() Failed(%d)", dbret);
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
-
- return CALENDAR_ERROR_NONE;
-}
-
-API int calendar_reminder_has_receiver(const char *pkgname)
-{
- int index;
- int count = 0;
- cal_db_util_error_e ret = CAL_DB_OK;
- char query[CAL_DB_SQL_MAX_LEN];
- sqlite3_stmt *stmt;
-
- if (pkgname == NULL || strlen(pkgname) == 0)
- {
- ERR("Invalid parameter");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- snprintf(query, sizeof(query), "SELECT count(*) FROM %s WHERE pkgname = ? ",
- CAL_REMINDER_ALERT);
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- _cal_db_util_stmt_bind_text(stmt, 1, pkgname);
-
- ret = _cal_db_util_stmt_step(stmt);
- if (CAL_DB_ROW == ret) {
- index = 0;
- count = sqlite3_column_int(stmt, index++);
- }
- sqlite3_finalize(stmt);
-
- return count > 0 ? true : false;
-}
-
API int calendar_reminder_add_cb(calendar_reminder_cb callback, void *user_data)
{
ERR("This API[%s] is not valid in native library.", __func__);
--- /dev/null
+/*
+ * Calendar Service
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __CALENDAR_SVC_SERVICE_H__
+#define __CALENDAR_SVC_SERVICE_H__
+
+void _cal_calendar_internal_disconnect(void);
+
+#endif // __CALENDAR_SVC_SERVICE_H__
+++ /dev/null
-# Package Information for pkg-config
-
-prefix=@PREFIX@
-exec_prefix=@EXEC_PREFIX@
-libdir=@LIBDIR@
-includedir=@INCLUDEDIR@
-
-Name: @CALSVCNATIVE@
-Description: @CALSVCNATIVE@ library
-Version: @VERSION@
-Requires: glib-2.0 alarm-service db-util capi-base-common
-Libs: -L${libdir} -l@CALSVCNATIVE@
-Cflags: -I${includedir}
+++ /dev/null
-* Wed Jun 05 2013 Baptiste DURAND <baptiste.durand@eurogiciel.fr> accepted/tizen/20130604.123440@69ea7f5
-- Fix Error build of initdb
-- Revert "Fix install section of spec"
-
-* Tue Jun 04 2013 Xavier Roche <xavrock.os@gmail.com> accepted/tizen/20130523.195513@52e84ea
-- Fix hardcoded library path in CMakelists
-
-* Thu May 23 2013 Rusty Lynch <rusty.lynch@intel.com> submit/tizen/20130517.045114@007bfae
-- Fix install section of spec
+++ /dev/null
-<manifest>
- <request>
- <domain name="_"/>
- </request>
-</manifest>
Name: calendar-service
Summary: DB library for calendar
-Version: 0.1.15
+Version: 0.1.126
Release: 1
-Group: Social & Content/Calendar
+Group: System/Libraries
License: Apache 2.0
Source0: %{name}-%{version}.tar.gz
-Source1: calendar.service
-Source1001: calendar-service.manifest
+Source1: calendar-serviced.service
+Source2: calendar-serviced.socket
Requires(post): /sbin/ldconfig
Requires(post): /usr/bin/sqlite3, /bin/chown
+Requires(post): contacts-service2
Requires(postun): /sbin/ldconfig
+Requires: sys-assert
BuildRequires: cmake
BuildRequires: pkgconfig(db-util)
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(alarm-service)
BuildRequires: pkgconfig(icu-i18n)
-BuildRequires: pkgconfig(appsvc)
BuildRequires: pkgconfig(capi-base-common)
BuildRequires: pkgconfig(contacts-service2)
BuildRequires: pkgconfig(pims-ipc)
-BuildRequires: pkgconfig(bundle)
+BuildRequires: pkgconfig(security-server)
+BuildRequires: pkgconfig(capi-appfw-package-manager)
+BuildRequires: pkgconfig(accounts-svc)
+BuildRequires: pkgconfig(capi-appfw-application)
BuildRequires: pkgconfig(libtzplatform-config)
%description
%package devel
Summary: DB library for calendar
-Group: Social & Content/Calendar
+Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: pkgconfig(alarm-service)
%prep
%setup -q
-cp %{SOURCE1001} .
%build
-%cmake .
+export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
+export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
+
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+ -DMAJORVER=${MAJORVER} \
+ -DFULLVER=%{version}
make %{?jobs:-j%jobs}
%install
%make_install
-mkdir -p %{buildroot}/etc/rc.d/rc3.d/
-mkdir -p %{buildroot}/etc/rc.d/rc5.d/
-ln -s ../init.d/calendar-serviced.sh %{buildroot}/etc/rc.d/rc3.d/S85calendar-serviced
-ln -s ../init.d/calendar-serviced.sh %{buildroot}/etc/rc.d/rc5.d/S85calendar-serviced
+mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants
+install -m 0644 %SOURCE1 %{buildroot}%{_libdir}/systemd/system/calendar-serviced.service
+ln -s ../calendar-serviced.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/calendar-serviced.service
+
+mkdir -p %{buildroot}%{_libdir}/systemd/system/sockets.target.wants
+install -m 0644 %SOURCE2 %{buildroot}%{_libdir}/systemd/system/calendar-serviced.socket
+ln -s ../calendar-serviced.socket %{buildroot}%{_libdir}/systemd/system/sockets.target.wants/calendar-serviced.socket
-mkdir -p %{buildroot}%{_unitdir_user}/tizen-middleware.target.wants
-install %{SOURCE1} %{buildroot}%{_unitdir_user}/
-ln -s ../calendar.service %{buildroot}%{_unitdir_user}/tizen-middleware.target.wants/
+mkdir -p %{buildroot}/usr/share/license
+cp LICENSE.APLv2 %{buildroot}/usr/share/license/%{name}
%post
/sbin/ldconfig
%postun -p /sbin/ldconfig
%files
-%manifest %{name}.manifest
+%manifest calendar-service.manifest
%defattr(-,root,root,-)
-#%{_libdir}/libcalendar-service-native.so.*
%{_bindir}/calendar-serviced*
%{_libdir}/libcalendar-service2.so.*
-%attr(0755,root,root) /etc/rc.d/init.d/calendar-serviced.sh
-/etc/rc.d/rc3.d/S85calendar-serviced
-/etc/rc.d/rc5.d/S85calendar-serviced
-/usr/share/calendar-svc/dft-calendar
-%{_unitdir_user}/calendar.service
-%{_unitdir_user}/tizen-middleware.target.wants/calendar.service
+%config(noreplace) /opt/usr/dbspace/.calendar-svc.db*
+%{_libdir}/systemd/system/multi-user.target.wants/calendar-serviced.service
+%{_libdir}/systemd/system/calendar-serviced.service
+%{_libdir}/systemd/system/sockets.target.wants/calendar-serviced.socket
+%{_libdir}/systemd/system/calendar-serviced.socket
+/usr/share/license/%{name}
%files devel
-%manifest %{name}.manifest
%defattr(-,root,root,-)
-%{_includedir}/calendar-service/*.h
%{_includedir}/calendar-service2/*.h
%{_libdir}/*.so
-%{_libdir}/pkgconfig/calendar.pc
-#%{_libdir}/pkgconfig/calendar-service-native.pc
%{_libdir}/pkgconfig/calendar-service2.pc
--- /dev/null
+[Unit]
+Description=Calendar Service daemon
+After=tizen-runtime.target contacts-service.service
+Requires=tizen-runtime.target contacts-service.service
+
+[Service]
+Type=simple
+ExecStart=/usr/bin/calendar-serviced
+Restart=always
+RestartSec=1
+
+[Install]
+WantedBy=multi-user.target
--- /dev/null
+[Unit]
+Description=Calendar Service socket
+
+[Socket]
+ListenStream=/tmp/.cal_svc_ipc
+SmackLabelIPIn=calendar-service
+SmackLabelIPOut=calendar-service
+Service=calendar-serviced.service
+
+[Install]
+WantedBy=sockets.target
+++ /dev/null
-[Unit]
-Description=Calendar service
-
-[Service]
-Type=simple
-ExecStart=/usr/bin/calendar-serviced
-Restart=always
-RestartSec=2
-
-[Install]
-WantedBy=tizen-middleware.target
-
+++ /dev/null
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common)
-LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
-
-SET(TARGET calendar-svc-initdb)
-
-EXECUTE_PROCESS(COMMAND ./generator.sh WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
-
-#FILE(GLOB SRCS *.c)
-
-SET(INITDBFILE initdb.c)
-SET(TOOLLIB calendar-service2)
-
-pkg_check_modules(initdb_pkgs REQUIRED db-util dlog libtzplatform-config)
-
-UNSET(EXTRA_CFLAGS)
-FOREACH(flag ${initdb_pkgs_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-
-#ADD_EXECUTABLE(${TARGET} ${SRCS})
-ADD_EXECUTABLE(${TARGET} ${INITDBFILE})
-SET_TARGET_PROPERTIES(${TARGET} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS})
-TARGET_LINK_LIBRARIES(${TARGET} ${initdb_pkgs_LDFLAGS})
-
+++ /dev/null
-CC = gcc
-
-REQUIRED_PKG =
-CFLAGS = -g -Wall #-fprofile-arcs -ftest-coverage
-LDFLAGS =
-ifdef REQUIRED_PKG
- CFLAGS += `pkg-config --cflags $(REQUIRED_PKG)`
- LDFLAGS += `pkg-config --libs $(REQUIRED_PKG)`
-endif
-
-SRCS = $(wildcard *.c)
-OBJECTS = $(SRCS:.c=.o)
-TARGETS = $(OBJECTS:.o=)
-
-all: $(TARGETS)
-
-% : %.o
- $(CC) $(LDFLAGS) -o $@ $<
-
-clean:
- rm -rf $(OBJECTS) $(TARGETS)
-
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/native)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common/ipc)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/schema)
LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/server)
${CMAKE_SOURCE_DIR}/common/ipc/cal_ipc_marshal_calendar.c
${CMAKE_SOURCE_DIR}/common/ipc/cal_ipc_marshal_event.c
${CMAKE_SOURCE_DIR}/common/ipc/cal_ipc_marshal_instance_allday.c
+ ${CMAKE_SOURCE_DIR}/common/ipc/cal_ipc_marshal_instance_allday_extended.c
${CMAKE_SOURCE_DIR}/common/ipc/cal_ipc_marshal_instance_normal.c
+ ${CMAKE_SOURCE_DIR}/common/ipc/cal_ipc_marshal_instance_normal_extended.c
${CMAKE_SOURCE_DIR}/common/ipc/cal_ipc_marshal_search.c
${CMAKE_SOURCE_DIR}/common/ipc/cal_ipc_marshal_timezone.c
${CMAKE_SOURCE_DIR}/common/ipc/cal_ipc_marshal_todo.c
${CMAKE_SOURCE_DIR}/common/cal_record_updated_info.c
${CMAKE_SOURCE_DIR}/common/cal_record_instance_normal.c
${CMAKE_SOURCE_DIR}/common/cal_record_instance_allday.c
+ ${CMAKE_SOURCE_DIR}/common/cal_record_instance_normal_extended.c
+ ${CMAKE_SOURCE_DIR}/common/cal_record_instance_allday_extended.c
${CMAKE_SOURCE_DIR}/common/cal_record_extended.c
${CMAKE_SOURCE_DIR}/common/cal_view.c
${CMAKE_SOURCE_DIR}/common/cal_filter.c
${CMAKE_SOURCE_DIR}/common/cal_mutex.c
${CMAKE_SOURCE_DIR}/native/cal_db.c
${CMAKE_SOURCE_DIR}/native/cal_calendar.c
+ ${CMAKE_SOURCE_DIR}/native/cal_db_calendar.c
${CMAKE_SOURCE_DIR}/native/cal_db_util.c
${CMAKE_SOURCE_DIR}/native/cal_db_alarm.c
${CMAKE_SOURCE_DIR}/native/cal_db_attendee.c
${CMAKE_SOURCE_DIR}/native/cal_db_query.c
${CMAKE_SOURCE_DIR}/native/cal_db_plugin_calendar.c
${CMAKE_SOURCE_DIR}/native/cal_db_plugin_event.c
+ ${CMAKE_SOURCE_DIR}/native/cal_db_event.c
${CMAKE_SOURCE_DIR}/native/cal_db_plugin_search.c
+ ${CMAKE_SOURCE_DIR}/native/cal_db_plugin_attendee.c
+ ${CMAKE_SOURCE_DIR}/native/cal_db_plugin_alarm.c
${CMAKE_SOURCE_DIR}/native/cal_db_plugin_timezone.c
${CMAKE_SOURCE_DIR}/native/cal_db_plugin_instance_normal.c
+ ${CMAKE_SOURCE_DIR}/native/cal_db_plugin_instance_normal_extended.c
${CMAKE_SOURCE_DIR}/native/cal_db_plugin_instance_allday.c
+ ${CMAKE_SOURCE_DIR}/native/cal_db_plugin_instance_allday_extended.c
${CMAKE_SOURCE_DIR}/native/cal_db_plugin_todo.c
${CMAKE_SOURCE_DIR}/native/cal_db_plugin_extended.c
${CMAKE_SOURCE_DIR}/native/cal_db_extended.c
${CMAKE_SOURCE_DIR}/native/cal_reminder.c
+ ${CMAKE_SOURCE_DIR}/native/cal_access_control.c
+ ${CMAKE_SOURCE_DIR}/native/cal_db_instance_helper.c
cal_server_ipc.c
)
INCLUDE(FindPkgConfig)
-pkg_check_modules(calserver_pkgs REQUIRED pims-ipc db-util appsvc alarm-service capi-base-common icu-i18n alarm-service libtzplatform-config)
+pkg_check_modules(calserver_pkgs REQUIRED
+ dlog
+ pims-ipc
+ db-util
+ alarm-service
+ capi-base-common
+ icu-i18n
+ accounts-svc
+ capi-appfw-application
+ libtzplatform-config
+ )
FOREACH(flag ${calserver_pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -fPIE")
SET(calserver_pkgs_LDFLAGS "${pkgs_LDFLAGS} ${calserver_pkgs_LDFLAGS}")
ADD_DEFINITIONS("-DCAL_IPC_SERVER")
#cmake_policy(SET CMP0002 OLD)
ADD_EXECUTABLE(${DAEMON}
cal_server.c
+ cal_server_contacts.c
cal_server_alarm.c
cal_server_calendar_delete.c
cal_server_reminder.c
+ cal_server_schema.c
+ cal_server_update.c
)
SET_TARGET_PROPERTIES(${DAEMON} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS})
-TARGET_LINK_LIBRARIES(${DAEMON} ${calserver_pkgs_LDFLAGS} ${LIBNAME})
+TARGET_LINK_LIBRARIES(${DAEMON} ${calserver_pkgs_LDFLAGS} ${LIBNAME} -pie)
INSTALL(TARGETS ${DAEMON} DESTINATION bin)
-INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/calendar-serviced.sh DESTINATION /etc/rc.d/init.d)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <grp.h>
+#include <sys/types.h>
#include <unistd.h> //getuid
#include <pims-ipc.h>
#include <pims-ipc-svc.h>
#include <glib-object.h>
+#include <alarm.h>
+#include <contacts.h>
+#include <account.h>
-#include "calendar2.h"
+#include "calendar.h"
+#include "cal_internal.h" // DBG
#include "cal_ipc.h"
#include "cal_server_ipc.h"
#include "cal_typedef.h"
#include "cal_inotify.h"
#include "cal_db.h" // CAL_SECURITY_FILE_GROUP
-#include "cal_internal.h" // DBG
+#include "cal_server_contacts.h"
#include "cal_server_alarm.h"
#include "cal_server_calendar_delete.h"
+#include "cal_server_schema.h"
+#include "cal_server_update.h"
+#include "cal_access_control.h"
+#include "cal_db_calendar.h"
+#include "cal_time.h" // u_clean
//static GMainLoop *loop;
+static account_subscribe_h cal_account_h = NULL;
+#ifdef CAL_MEMORY_TEST
+GMainLoop* main_loop = NULL;
+#endif //#ifdef CAL_MEMORY_TEST
+
static int __server_main();
+static bool __cal_server_account_delete_cb(const char* event_type, int account_id, void* user_data);
+
+static gboolean __cal_server_timeout_cb(gpointer argv)
+{
+ int ret;
+ int *try_count = (int *)argv;
+ DBG("called count(%d)", *try_count);
+ if (*try_count > 2)
+ {
+ ERR("Tried 3 times but failed to contacts connect");
+ return false;
+ }
+
+ ret = contacts_connect();
+ if (CONTACTS_ERROR_NONE == ret)
+ {
+ DBG("contact connected");
+ }
+ else
+ {
+ ERR("Failed to connect (%d) times", *try_count + 1);
+ *try_count += 1;
+ return true;
+ }
+
+ ret = _cal_server_contacts();
+ return false;
+}
+
+static bool __cal_server_account_delete_cb(const char* event_type, int account_id, void* user_data)
+{
+ CAL_FN_CALL;
+
+ if (strcmp(event_type, ACCOUNT_NOTI_NAME_DELETE) == 0)
+ {
+ calendar_db_delete_account(account_id);
+ _cal_server_contacts_delete(account_id);
+ }
+ return true;
+}
+
+#ifdef CAL_MEMORY_TEST
+static gboolean __cal_server_ipc_destroy_idle(void* user_data)
+{
+ ERR();
+ g_main_loop_quit(main_loop);
+}
+
+void _cal_server_ipc_destroy(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
+{
+ ERR();
+ int ret = CALENDAR_ERROR_NONE;
+
+ // kill daemon destroy
+ g_timeout_add_seconds(1, &__cal_server_ipc_destroy_idle, NULL);
+
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
+ goto DATA_FREE;
+
+ERROR_RETURN:
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
+DATA_FREE:
+
+ return;
+}
+#endif //#ifdef CAL_MEMORY_TEST
static int __server_main(void)
{
int ret;
- g_type_init();
-
- pims_ipc_svc_init(CAL_IPC_SOCKET_PATH,CAL_SECURITY_FILE_GROUP,CAL_SECURITY_DEFAULT_PERMISSION);
-
- if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_CONNECT, _cal_server_ipc_connect, NULL) != 0)
- {
- ERR("pims_ipc_svc_register error");
- return -1;
- }
- if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DISCONNECT, _cal_server_ipc_disconnect, NULL) != 0)
- {
- ERR("pims_ipc_svc_register error");
- return -1;
- }
- if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_INSERT_RECORD, _cal_server_ipc_db_insert_record, NULL) != 0)
- {
- ERR("pims_ipc_svc_register error");
- return -1;
- }
- if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_GET_RECORD, _cal_server_ipc_db_get_record, NULL) != 0)
- {
- ERR("pims_ipc_svc_register error");
- return -1;
- }
- if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_UPDATE_RECORD, _cal_server_ipc_db_update_record, NULL) != 0)
- {
- ERR("pims_ipc_svc_register error");
- return -1;
- }
- if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_DELETE_RECORD, _cal_server_ipc_db_delete_record, NULL) != 0)
- {
- ERR("pims_ipc_svc_register error");
- return -1;
- }
- if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_GET_ALL_RECORDS, _cal_server_ipc_db_get_all_records, NULL) != 0)
- {
- ERR("pims_ipc_svc_register error");
- return -1;
- }
- if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_GET_RECORDS_WITH_QUERY, _cal_server_ipc_db_get_records_with_query, NULL) != 0)
- {
- ERR("pims_ipc_svc_register error");
- return -1;
- }
- if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_CLEAN_AFTER_SYNC, _cal_server_ipc_db_clean_after_sync, NULL) != 0)
- {
- ERR("pims_ipc_svc_register error");
- return -1;
- }
- if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_GET_COUNT, _cal_server_ipc_db_get_count, NULL) != 0)
- {
- ERR("pims_ipc_svc_register error");
- return -1;
- }
- if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_GET_COUNT_WITH_QUERY, _cal_server_ipc_db_get_count_with_query, NULL) != 0)
- {
- ERR("pims_ipc_svc_register error");
- return -1;
- }
- if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_INSERT_RECORDS, _cal_server_ipc_db_insert_records, NULL) != 0)
- {
- ERR("pims_ipc_svc_register error");
- return -1;
- }
- if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_UPDATE_RECORDS, _cal_server_ipc_db_update_records, NULL) != 0)
- {
- ERR("pims_ipc_svc_register error");
- return -1;
- }
- if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_DELETE_RECORDS, _cal_server_ipc_db_delete_records, NULL) != 0)
- {
- ERR("pims_ipc_svc_register error");
- return -1;
- }
- if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_CHANGES_BY_VERSION, _cal_server_ipc_db_get_changes_by_version, NULL) != 0)
- {
- ERR("pims_ipc_svc_register error");
- return -1;
- }
- if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_GET_CURRENT_VERSION, _cal_server_ipc_db_get_current_version, NULL) != 0)
- {
- ERR("pims_ipc_svc_register error");
- return -1;
- }
- if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_INSERT_VCALENDARS, _cal_server_ipc_db_insert_vcalendars, NULL) != 0)
- {
- ERR("pims_ipc_svc_register error");
- return -1;
- }
- if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_REPLACE_VCALENDARS, _cal_server_ipc_db_replace_vcalendars, NULL) != 0)
- {
- ERR("pims_ipc_svc_register error");
- return -1;
- }
- if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_REPLACE_RECORD, _cal_server_ipc_db_replace_record, NULL) != 0)
- {
- ERR("pims_ipc_svc_register error");
- return -1;
- }
- if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_REPLACE_RECORDS, _cal_server_ipc_db_replace_records, NULL) != 0)
- {
- ERR("pims_ipc_svc_register error");
- return -1;
- }
- if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_REGISTER_REMINDER, _cal_server_ipc_db_register_reminder, NULL) != 0)
- {
- ERR("pims_ipc_svc_register error");
- return -1;
- }
- if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_UNREGISTER_REMINDER, _cal_server_ipc_db_unregister_reminder, NULL) != 0)
- {
- ERR("pims_ipc_svc_register error");
- return -1;
- }
- if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_ACTIVATE_REMINDER, _cal_server_ipc_db_activate_reminder, NULL) != 0)
- {
- ERR("pims_ipc_svc_register error");
- return -1;
- }
- if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_DEACTIVATE_REMINDER, _cal_server_ipc_db_deactivate_reminder, NULL) != 0)
- {
- ERR("pims_ipc_svc_register error");
- return -1;
- }
- if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_HAS_REMINDER, _cal_server_ipc_db_has_reminder, NULL) != 0)
- {
- ERR("pims_ipc_svc_register error");
- return -1;
- }
+ int on_contact = 0;
+ int try_count = 0;
+ g_type_init();
+
+ pims_ipc_svc_init(CAL_IPC_SOCKET_PATH,CAL_SECURITY_FILE_GROUP, 0777);
+
+ if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_CONNECT, _cal_server_ipc_connect, NULL) != 0)
+ {
+ ERR("pims_ipc_svc_register error");
+ return -1;
+ }
+ if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DISCONNECT, _cal_server_ipc_disconnect, NULL) != 0)
+ {
+ ERR("pims_ipc_svc_register error");
+ return -1;
+ }
+ if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_CHECK_PERMISSION, _cal_server_ipc_check_permission, NULL) != 0) {
+ ERR("pims_ipc_svc_register error");
+ return -1;
+ }
+ if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_INSERT_RECORD, _cal_server_ipc_db_insert_record, NULL) != 0)
+ {
+ ERR("pims_ipc_svc_register error");
+ return -1;
+ }
+ if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_GET_RECORD, _cal_server_ipc_db_get_record, NULL) != 0)
+ {
+ ERR("pims_ipc_svc_register error");
+ return -1;
+ }
+ if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_UPDATE_RECORD, _cal_server_ipc_db_update_record, NULL) != 0)
+ {
+ ERR("pims_ipc_svc_register error");
+ return -1;
+ }
+ if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_DELETE_RECORD, _cal_server_ipc_db_delete_record, NULL) != 0)
+ {
+ ERR("pims_ipc_svc_register error");
+ return -1;
+ }
+ if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_GET_ALL_RECORDS, _cal_server_ipc_db_get_all_records, NULL) != 0)
+ {
+ ERR("pims_ipc_svc_register error");
+ return -1;
+ }
+ if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_GET_RECORDS_WITH_QUERY, _cal_server_ipc_db_get_records_with_query, NULL) != 0)
+ {
+ ERR("pims_ipc_svc_register error");
+ return -1;
+ }
+ if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_CLEAN_AFTER_SYNC, _cal_server_ipc_db_clean_after_sync, NULL) != 0)
+ {
+ ERR("pims_ipc_svc_register error");
+ return -1;
+ }
+ if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_GET_COUNT, _cal_server_ipc_db_get_count, NULL) != 0)
+ {
+ ERR("pims_ipc_svc_register error");
+ return -1;
+ }
+ if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_GET_COUNT_WITH_QUERY, _cal_server_ipc_db_get_count_with_query, NULL) != 0)
+ {
+ ERR("pims_ipc_svc_register error");
+ return -1;
+ }
+ if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_INSERT_RECORDS, _cal_server_ipc_db_insert_records, NULL) != 0)
+ {
+ ERR("pims_ipc_svc_register error");
+ return -1;
+ }
+ if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_UPDATE_RECORDS, _cal_server_ipc_db_update_records, NULL) != 0)
+ {
+ ERR("pims_ipc_svc_register error");
+ return -1;
+ }
+ if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_DELETE_RECORDS, _cal_server_ipc_db_delete_records, NULL) != 0)
+ {
+ ERR("pims_ipc_svc_register error");
+ return -1;
+ }
+ if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_CHANGES_BY_VERSION, _cal_server_ipc_db_get_changes_by_version, NULL) != 0)
+ {
+ ERR("pims_ipc_svc_register error");
+ return -1;
+ }
+ if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_GET_CURRENT_VERSION, _cal_server_ipc_db_get_current_version, NULL) != 0)
+ {
+ ERR("pims_ipc_svc_register error");
+ return -1;
+ }
+ if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_INSERT_VCALENDARS, _cal_server_ipc_db_insert_vcalendars, NULL) != 0)
+ {
+ ERR("pims_ipc_svc_register error");
+ return -1;
+ }
+ if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_REPLACE_VCALENDARS, _cal_server_ipc_db_replace_vcalendars, NULL) != 0)
+ {
+ ERR("pims_ipc_svc_register error");
+ return -1;
+ }
+ if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_REPLACE_RECORD, _cal_server_ipc_db_replace_record, NULL) != 0)
+ {
+ ERR("pims_ipc_svc_register error");
+ return -1;
+ }
+ if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_REPLACE_RECORDS, _cal_server_ipc_db_replace_records, NULL) != 0)
+ {
+ ERR("pims_ipc_svc_register error");
+ return -1;
+ }
+ if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DB_CHANGES_EXCEPTION, _cal_server_ipc_db_changes_exception, NULL) != 0)
+ {
+ ERR("pims_ipc_svc_register error");
+ return -1;
+ }
+#ifdef CAL_MEMORY_TEST
+ if (pims_ipc_svc_register(CAL_IPC_MODULE, CAL_IPC_SERVER_DESTROY, _cal_server_ipc_destroy, NULL) != 0)
+ {
+ ERR("pims_ipc_svc_register error");
+ return -1;
+ }
+#endif //#ifdef CAL_MEMORY_TEST
// for subscribe
- pims_ipc_svc_init_for_publish(CAL_IPC_SOCKET_PATH_FOR_SUBSCRIPTION, CAL_SECURITY_DEFAULT_PERMISSION, 0660);
+ pims_ipc_svc_init_for_publish(CAL_IPC_SOCKET_PATH_FOR_SUBSCRIPTION, CAL_SECURITY_FILE_GROUP, CAL_SECURITY_DEFAULT_PERMISSION);
- //loop = g_main_loop_new(NULL, FALSE);
+ //loop = g_main_loop_new(NULL, FALSE);
- //calendar_alarm_init();
+ //calendar_alarm_init();
+
+ ret = contacts_connect();
+ if (CONTACTS_ERROR_NONE != ret)
+ {
+ ERR("contacts_connect() failed");
+ g_timeout_add_seconds(30, __cal_server_timeout_cb, (gpointer)&try_count);
+ }
+ else
+ {
+ DBG("contacts connected");
+ on_contact = 1;
+ }
ret = calendar_connect();
if (CALENDAR_ERROR_NONE != ret)
return ret;
}
+ _cal_db_initialize_view_table();
+
+ if (on_contact)
+ {
+ ret = _cal_server_contacts();
+ if (CALENDAR_ERROR_NONE != ret)
+ {
+ contacts_disconnect();
+ ERR("_cal_server_contacts() failed");
+ return -1;
+ }
+
+ _cal_server_contacts_sync_start();
+ }
+
+ // access_control
+ _cal_access_control_set_client_info("calendar-service", NULL);
+
+ ret = account_subscribe_create(&cal_account_h);
+ if (ACCOUNT_ERROR_NONE == ret) {
+ ret = account_subscribe_notification(cal_account_h, __cal_server_account_delete_cb, NULL);
+ if (ACCOUNT_ERROR_NONE != ret) {
+ DBG("account_subscribe_notification Failed (%d)", ret);
+ }
+ }
+ else
+ DBG("account_subscribe_create Failed (%d)", ret);
+
_cal_inotify_initialize();
ret = _cal_server_alarm();
if (CALENDAR_ERROR_NONE != ret)
{
+ if (on_contact)
+ {
+ contacts_disconnect();
+ }
ERR("_cal_server_alarm() failed");
return -1;
}
_cal_server_calendar_delete_start();
- pims_ipc_svc_run_main_loop(NULL);
+#ifdef CAL_MEMORY_TEST
+ main_loop = g_main_loop_new(NULL, FALSE);
+
+ pims_ipc_svc_run_main_loop(main_loop);
+ ERR("exit");
+ g_main_loop_unref(main_loop);
+#else //#ifdef CAL_MEMORY_TEST
+ pims_ipc_svc_run_main_loop(NULL);
+#endif //#ifdef CAL_MEMORY_TEST
+
+ _cal_time_u_cleanup();
_cal_inotify_finalize();
calendar_disconnect();
+ contacts_disconnect();
+ on_contact = 0;
+
+ if (cal_account_h)
+ {
+ account_unsubscribe_notification(cal_account_h);
+ cal_account_h = NULL;
+ }
+
pims_ipc_svc_deinit_for_publish();
- pims_ipc_svc_deinit();
+ pims_ipc_svc_deinit();
+
+ _cal_access_control_unset_client_info();
+ alarmmgr_fini();
- return 0;
+ return 0;
}
int main(int argc, char *argv[])
{
- __server_main();
- return 0;
+ INFO(COLOR_GREEN"Server start"COLOR_END);
+
+ if (getuid() == 0)
+ { // root
+ gid_t glist[] = {CAL_SECURITY_FILE_GROUP};
+ if (setgroups(1, glist) < 0) // client and server should have same Groups
+ {
+ ERR("setgroups() failed");
+ }
+ }
+
+ _cal_server_schema_check();
+ _cal_server_update();
+
+ __server_main();
+ return 0;
}
#include <stdlib.h>
-#include <appsvc.h>
+#include <sys/time.h>
+#include <unistd.h>
+
#include <alarm.h>
#include <vconf.h>
+#include <app.h>
#include "cal_internal.h"
-#include "calendar2.h"
+#include "calendar.h"
#include "cal_time.h"
#include "cal_typedef.h"
#include "cal_inotify.h"
#include "cal_db_query.h"
#include "cal_server_reminder.h"
-static struct timeval stv; // check time
-static struct timeval etv; // check time
-
-static int __cal_server_alarm_unset_alerted_alarmmgr_id(int alarm_id);
-
-static int __cal_server_alarm_clear_all_cb(alarm_id_t alarm_id, void *data)
-{
- int ret;
+#define CAL_SEARCH_LOOP_MAX 4
- DBG("remove alarm id(%d)", alarm_id);
- __cal_server_alarm_unset_alerted_alarmmgr_id(alarm_id);
- ret = alarmmgr_remove_alarm(alarm_id);
- if (ret != ALARMMGR_RESULT_SUCCESS)
- {
- ERR("alarmmgr_remove_alarm() failed(ret:%d)", ret);
- return ret;
- }
- return CALENDAR_ERROR_NONE;
-}
+#define COLOR_CYAN "\033[0;36m"
+#define COLOR_END "\033[0;m"
-struct _normal_data_s
+struct _alarm_data_s
{
- int id;
- long long int alarm_utime;
- int tick;
+ int event_id;
+ long long int alert_utime; // to compare
int unit;
- int alarm_id;
- int record_type;
-};
-
-struct _allday_data_s
-{
- int id;
- int alarm_datetime;
int tick;
- int unit;
- int alarm_id;
- int record_type;
+ int type; // utime, local
+ long long int time;
+ int record; // todo, event
+ char datetime[32];
+ int system_type;
};
-static int __cal_server_alarm_get_next_list_normal_event(long long int from_utime, long long int to_utime, GList **list, int *count)
+// this api is necessary for repeat instance.
+static int __cal_server_alarm_unset_alerted_alarmmgr_id(int alarm_id)
{
- int index;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
-
- DBG("searching normal event (%lld) ~ (%lld)", from_utime, to_utime);
-
- snprintf(query, sizeof(query),
- "SELECT A.event_id, B.alarm_time, "
- "B.remind_tick, B.remind_tick_unit, B.alarm_id "
- "FROM %s as A, " // A is normal instance
- "%s as B ON A.event_id = B.event_id, " // B is alarm
- "%s as C ON B.event_id = C.id " // c is schedule
- "WHERE C.has_alarm == 1 AND C.type = %d "
- "AND B.remind_tick_unit = %d AND B.alarm_time = %lld "
- "UNION "
- "SELECT A.event_id, A.dtstart_utime - (B.remind_tick * B.remind_tick_unit), "
- "B.remind_tick, B.remind_tick_unit, B.alarm_id "
- "FROM %s as A, " // A is normal instance
- "%s as B ON A.event_id = B.event_id, " // B is alarm
- "%s as C ON B.event_id = C.id " // c is schedule
- "WHERE C.has_alarm = 1 AND C.type = %d "
- "AND B.remind_tick_unit > %d "
- "AND (A.dtstart_utime - (B.remind_tick * B.remind_tick_unit)) >= %lld "
- "AND (A.dtstart_utime - (B.remind_tick * B.remind_tick_unit)) < %lld "
- "ORDER BY (A.dtstart_utime - (B.remind_tick * B.remind_tick_unit))",
- CAL_TABLE_NORMAL_INSTANCE, CAL_TABLE_ALARM, CAL_TABLE_SCHEDULE,
- CALENDAR_BOOK_TYPE_EVENT,
- CALENDAR_ALARM_TIME_UNIT_SPECIFIC, from_utime,
- CAL_TABLE_NORMAL_INSTANCE, CAL_TABLE_ALARM, CAL_TABLE_SCHEDULE,
- CALENDAR_BOOK_TYPE_EVENT,
- CALENDAR_ALARM_TIME_UNIT_SPECIFIC,
- from_utime, to_utime);
+ int ret = CALENDAR_ERROR_NONE;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ cal_db_util_error_e dbret = CAL_DB_OK;
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
+ ret = _cal_db_util_begin_trans();
+ if (CALENDAR_ERROR_NONE != ret)
{
- DBG("query[%s]", query);
- ERR("_cal_db_util_query_prepare() Failed");
+ ERR("_cal_db_util_begin_trans() failed");
return CALENDAR_ERROR_DB_FAILED;
}
- *count = 0;
- while (CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- struct _normal_data_s *nd = calloc(1, sizeof(struct _normal_data_s));
-
- index = 0;
- nd->id = sqlite3_column_int(stmt, index++);
- nd->alarm_utime = sqlite3_column_int64(stmt, index++);
- nd->tick = sqlite3_column_int(stmt, index++);
- nd->unit = sqlite3_column_int(stmt, index++);
- nd->alarm_id = sqlite3_column_int(stmt, index++);
-
- *list = g_list_append(*list, nd);
- (*count)++;
- }
- sqlite3_finalize(stmt);
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_server_alarm_get_next_list_normal_todo(long long int from_utime, long long int to_utime, GList **list, int *count)
-{
- int index;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
-
- DBG("searching normal todo (%lld) ~ (%lld)", from_utime, to_utime);
-
- snprintf(query, sizeof(query),
- "SELECT B.id, A.alarm_time, "
- "A.remind_tick, A.remind_tick_unit, A.alarm_id "
- "FROM %s as A, " // A is alarm
- "%s as B ON A.event_id = B.id " // B is schedule
- "WHERE B.has_alarm == 1 AND B.type = %d "
- "AND A.remind_tick_unit = %d AND A.alarm_time = %lld "
- "UNION "
- "SELECT B.id, B.dtend_utime - (A.remind_tick * A.remind_tick_unit), "
- "A.remind_tick, A.remind_tick_unit, A.alarm_id "
- "FROM %s as A, " // A is alarm
- "%s as B ON A.event_id = B.id " // B is schedule
- "WHERE B.has_alarm = 1 AND B.type = %d "
- "AND A.remind_tick_unit > %d "
- "AND (B.dtend_utime - (A.remind_tick * A.remind_tick_unit)) >= %lld "
- "AND (B.dtend_utime - (A.remind_tick * A.remind_tick_unit)) < %lld "
- "ORDER BY (B.dtend_utime - (A.remind_tick * A.remind_tick_unit))",
- CAL_TABLE_ALARM, CAL_TABLE_SCHEDULE,
- CALENDAR_BOOK_TYPE_TODO,
- CALENDAR_ALARM_TIME_UNIT_SPECIFIC, from_utime,
- CAL_TABLE_ALARM, CAL_TABLE_SCHEDULE,
- CALENDAR_BOOK_TYPE_TODO,
- CALENDAR_ALARM_TIME_UNIT_SPECIFIC,
- from_utime, to_utime);
+ DBG("alarm_id(%d)", alarm_id);
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- DBG("query[%s]", query);
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
+ snprintf(query, sizeof(query), "UPDATE %s SET alarm_id = 0 WHERE alarm_id =%d ",
+ CAL_TABLE_ALARM, alarm_id);
- *count = 0;
- while (CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ dbret = _cal_db_util_query_exec(query);
+ if (CAL_DB_OK != dbret)
{
- struct _normal_data_s *nd = calloc(1, sizeof(struct _normal_data_s));
-
- index = 0;
- nd->id = sqlite3_column_int(stmt, index++);
- nd->alarm_utime = sqlite3_column_int64(stmt, index++);
- nd->tick = sqlite3_column_int(stmt, index++);
- nd->unit = sqlite3_column_int(stmt, index++);
- nd->alarm_id = sqlite3_column_int(stmt, index++);
-
- *list = g_list_append(*list, nd);
- (*count)++;
+ ERR("_cal_db_util_query_exec() Failed(%d)", dbret);
+ switch (dbret)
+ {
+ case CAL_DB_ERROR_NO_SPACE:
+ _cal_db_util_end_trans(false);
+ return CALENDAR_ERROR_FILE_NO_SPACE;
+ default:
+ _cal_db_util_end_trans(false);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
}
- sqlite3_finalize(stmt);
+ _cal_db_util_end_trans(true);
return CALENDAR_ERROR_NONE;
}
-static int __cal_server_alarm_get_next_list_allday_event(int from_datetime, int to_datetime, GList **list, int *count)
+static int __cal_server_alarm_clear_all_cb(alarm_id_t alarm_id, void *data)
{
- int index;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
-
- DBG("searching allday (%d) ~ (%d)", from_datetime, to_datetime);
-
- snprintf(query, sizeof(query),
- "SELECT A.event_id, B.alarm_time, "
- "B.remind_tick, B.remind_tick_unit, B.alarm_id "
- "FROM %s as A, " // A is allday instance
- "%s as B ON A.event_id = B.event_id, " // B is alarm
- "%s as C ON B.event_id = C.id " // C is schedule
- "WHERE C.has_alarm == 1 AND C.type = %d "
- "AND B.remind_tick_unit = %d AND B.alarm_time = %d "
- "UNION "
- "SELECT A.event_id, A.dtstart_datetime, "
- "B.remind_tick, B.remind_tick_unit, B.alarm_id "
- "FROM %s as A, " // A is allday instance
- "%s as B ON A.event_id = B.event_id, " // B is alarm
- "%s as C ON B.event_id = C.id " // C is schedule
- "WHERE C.has_alarm = 1 AND C.type = %d "
- "AND B.remind_tick_unit > %d "
- "AND A.dtstart_datetime - (B.remind_tick * B.remind_tick_unit)/86400 > %d "
- "AND A.dtstart_datetime - (B.remind_tick * B.remind_tick_unit)/86400 <= %d ",
- CAL_TABLE_ALLDAY_INSTANCE, CAL_TABLE_ALARM, CAL_TABLE_SCHEDULE,
- CALENDAR_BOOK_TYPE_EVENT,
- CALENDAR_ALARM_TIME_UNIT_SPECIFIC, from_datetime,
- CAL_TABLE_ALLDAY_INSTANCE, CAL_TABLE_ALARM, CAL_TABLE_SCHEDULE,
- CALENDAR_BOOK_TYPE_EVENT,
- CALENDAR_ALARM_TIME_UNIT_SPECIFIC,
- from_datetime, to_datetime);
-
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- DBG("query[%s]", query);
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
+ int ret;
- *count = 0;
- while (CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ DBG("remove alarm id(%d)", alarm_id);
+ __cal_server_alarm_unset_alerted_alarmmgr_id(alarm_id);
+ ret = alarmmgr_remove_alarm(alarm_id);
+ if (ret != ALARMMGR_RESULT_SUCCESS)
{
- struct _allday_data_s *ad = calloc(1, sizeof(struct _allday_data_s));
-
- index = 0;
- ad->id = sqlite3_column_int(stmt, index++);
- ad->alarm_datetime = sqlite3_column_int(stmt, index++);
- ad->tick = sqlite3_column_int(stmt, index++);
- ad->unit = sqlite3_column_int(stmt, index++);
- ad->alarm_id = sqlite3_column_int(stmt, index++);
-
- *list = g_list_append(*list, ad);
- (*count)++;
+ ERR("alarmmgr_remove_alarm() failed(ret:%d)", ret);
+ return ret;
}
- sqlite3_finalize(stmt);
return CALENDAR_ERROR_NONE;
}
-static int __cal_server_alarm_get_next_list_allday_todo(int from_datetime, int to_datetime, GList **list, int *count)
+static int __cal_server_alarm_update_alarm_id(int alarm_id, int event_id, int tick, int unit)
{
- int index;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
-
- DBG("searching allday todo(%d) ~ (%d)", from_datetime, to_datetime);
-
- snprintf(query, sizeof(query),
- "SELECT A.event_id, A.alarm_time, "
- "A.remind_tick, A.remind_tick_unit, A.alarm_id "
- "FROM %s as A, " // A is alarm
- "%s as B ON A.event_id = B.id " // B is schedule
- "WHERE B.has_alarm == 1 AND B.type = %d "
- "AND A.remind_tick_unit = %d AND A.alarm_time = %d "
- "UNION "
- "SELECT A.event_id, B.dtend_datetime, "
- "A.remind_tick, A.remind_tick_unit, A.alarm_id "
- "FROM %s as A, " // A is alarm
- "%s as B ON A.event_id = B.id " // B is schedule
- "WHERE B.has_alarm = 1 AND B.type = %d "
- "AND A.remind_tick_unit > %d "
- "AND B.dtend_datetime - (A.remind_tick * A.remind_tick_unit)/86400 > %d "
- "AND B.dtend_datetime - (A.remind_tick * A.remind_tick_unit)/86400 <= %d ",
- CAL_TABLE_ALARM, CAL_TABLE_SCHEDULE,
- CALENDAR_BOOK_TYPE_TODO,
- CALENDAR_ALARM_TIME_UNIT_SPECIFIC, from_datetime,
- CAL_TABLE_ALARM, CAL_TABLE_SCHEDULE,
- CALENDAR_BOOK_TYPE_TODO,
- CALENDAR_ALARM_TIME_UNIT_SPECIFIC,
- from_datetime, to_datetime);
+ int ret = CALENDAR_ERROR_NONE;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ cal_db_util_error_e dbret = CAL_DB_OK;
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
+ ret = _cal_db_util_begin_trans();
+ if (CALENDAR_ERROR_NONE != ret)
{
- DBG("query[%s]", query);
- ERR("_cal_db_util_query_prepare() Failed");
+ ERR("_cal_db_util_begin_trans() failed");
return CALENDAR_ERROR_DB_FAILED;
}
- *count = 0;
- while (CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- struct _allday_data_s *ad = calloc(1, sizeof(struct _allday_data_s));
-
- index = 0;
- ad->id = sqlite3_column_int(stmt, index++);
- ad->alarm_datetime = sqlite3_column_int(stmt, index++);
- ad->tick = sqlite3_column_int(stmt, index++);
- ad->unit = sqlite3_column_int(stmt, index++);
- ad->alarm_id = sqlite3_column_int(stmt, index++);
-
- *list = g_list_append(*list, ad);
- (*count)++;
- }
- sqlite3_finalize(stmt);
- return CALENDAR_ERROR_NONE;
-}
-
-static int __cal_server_alarm_update_alarm_id(int alarm_id, int event_id, int tick, int unit)
-{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- cal_db_util_error_e dbret = CAL_DB_OK;
-
DBG("Update alarm_id(%d) in alarm table", alarm_id);
snprintf(query, sizeof(query), "UPDATE %s SET "
- "alarm_id = %d "
- "WHERE event_id = %d AND remind_tick = %d AND remind_tick_unit = %d",
+ "alarm_id =%d "
+ "WHERE event_id =%d AND remind_tick =%d AND remind_tick_unit =%d",
CAL_TABLE_ALARM,
alarm_id,
event_id, tick, unit);
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
+ _cal_db_util_end_trans(false);
return CALENDAR_ERROR_FILE_NO_SPACE;
default:
+ _cal_db_util_end_trans(false);
return CALENDAR_ERROR_DB_FAILED;
}
}
-
+ _cal_db_util_end_trans(true);
return CALENDAR_ERROR_NONE;
}
-static GFunc __cal_server_alarm_print_list_normal(gpointer data, gpointer user_data)
+static long long int __cal_server_alarm_get_alert_utime(const char *field, int event_id, time_t current)
{
- struct _normal_data_s *normal = (struct _normal_data_s *)data;
- DBG("%02d:%lld", normal->id, normal->alarm_utime);
- return 0;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ snprintf(query, sizeof(query), "SELECT %s FROM %s "
+ "WHERE event_id=%d AND %s>%ld ORDER BY %s LIMIT 1",
+ field, CAL_TABLE_NORMAL_INSTANCE, event_id, field, current, field);
+
+ sqlite3_stmt *stmt = NULL;
+ stmt = _cal_db_util_query_prepare(query);
+
+ long long int utime = 0;
+ if (CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ utime = sqlite3_column_int(stmt, 0);
+
+ sqlite3_finalize(stmt);
+ return utime;
}
-static GFunc __cal_server_alarm_print_list_allday_todo(gpointer data, gpointer user_data)
+static int __cal_server_alarm_get_alert_localtime(const char *field, int event_id, time_t current)
{
- struct _allday_data_s *allday = (struct _allday_data_s *)data;
- DBG("%02d:%d", allday->id, allday->alarm_datetime);
- return 0;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ struct tm st = {0};
+ tzset();
+ localtime_r(¤t, &st);
+ time_t mod_current = timegm(&st);
+ snprintf(query, sizeof(query), "SELECT %s FROM %s "
+ "WHERE event_id=%d AND strftime('%%s', %s)>%ld ORDER BY %s LIMIT 1",
+ field, CAL_TABLE_ALLDAY_INSTANCE, event_id, field, mod_current, field);
+
+ sqlite3_stmt *stmt = NULL;
+ stmt = _cal_db_util_query_prepare(query);
+
+ const char *datetime = NULL;
+ if (CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ datetime = (const char *)sqlite3_column_text(stmt, 0);
+
+ if (NULL == datetime || '\0' == *datetime) {
+ ERR("Invalid datetime [%s]", datetime);
+ sqlite3_finalize(stmt);
+ return 0;
+ }
+
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
+ sscanf(datetime, CAL_FORMAT_LOCAL_DATETIME, &y, &m, &d, &h, &n, &s);
+ sqlite3_finalize(stmt);
+
+ st.tm_year = y - 1900;
+ st.tm_mon = m - 1;
+ st.tm_mday = d;
+ st.tm_hour = h;
+ st.tm_min = n;
+ st.tm_sec = s;
+
+ return (long long int)mktime(&st);
}
-static int __cal_server_alarm_get_list_with_alarmmgr_id(int alarm_id, GList **normal_list, GList **allday_list)
+/*
+ * to get aler time, time(NULL) is not accurate. 1 secs diff could be occured.
+ * so, searching DB is neccessary to find alert time.
+ */
+static int __cal_server_alarm_get_alert_time(int alarm_id, time_t *tt_alert)
{
- int index;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
- struct _normal_data_s *nd;
- struct _allday_data_s *ad;
-
- snprintf(query, sizeof(query),
- "SELECT A.type, A.dtstart_type, A.dtend_type, B.remind_tick, B.remind_tick_unit "
- "FROM %s as A, " // schedule
- "%s as B ON A.id = B.event_id " // alarm
- "WHERE B.alarm_id = %d",
- CAL_TABLE_SCHEDULE,
- CAL_TABLE_ALARM,
- alarm_id);
+ retvm_if(NULL == tt_alert, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: tt_alert is NULL");
+
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ snprintf(query, sizeof(query), "SELECT A.event_id, A.remind_tick_unit, A.remind_tick, "
+ "A.alarm_type, A.alarm_utime, A.alarm_datetime, B.system_type, "
+ "B.type, B.dtstart_type, B.dtend_type "
+ "FROM %s as A, %s as B ON A.event_id = B.id WHERE alarm_id =%d ",
+ CAL_TABLE_ALARM, CAL_TABLE_SCHEDULE, alarm_id);
+ sqlite3_stmt *stmt = NULL;
stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- DBG("query[%s]", query);
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
+ retvm_if (NULL == stmt, CALENDAR_ERROR_DB_FAILED, "_cal_db_util_query_prepare() Failed");
+ int event_id = 0;
+ int unit = 0;
+ int tick = 0;
int type = 0;
+ long long int utime = 0;
+ const char *datetime = NULL;
+ int system_type = 0;
+ int record_type = 0;
int dtstart_type = 0;
int dtend_type = 0;
- int tick = 0;
- int unit = 0;
- if (CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- index = 0;
+ struct tm st = {0};
+
+ if (CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
+ int index = 0;
+ event_id = sqlite3_column_int(stmt, index++);
+ unit = sqlite3_column_int(stmt, index++);
+ tick = sqlite3_column_int(stmt, index++);
type = sqlite3_column_int(stmt, index++);
+ utime = sqlite3_column_int64(stmt, index++);
+ datetime = (const char *)sqlite3_column_text(stmt, index++);
+ system_type = sqlite3_column_int(stmt, index++);
+ record_type = sqlite3_column_int(stmt, index++);
dtstart_type = sqlite3_column_int(stmt, index++);
dtend_type = sqlite3_column_int(stmt, index++);
- tick = sqlite3_column_int(stmt, index++);
- unit = sqlite3_column_int(stmt, index++);
}
- else
- {
- ERR("No record");
+
+ if (NULL == tt_alert) {
+ ERR("Invalid parameter: tt_alert is NULL");
+ sqlite3_finalize(stmt);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
}
- sqlite3_finalize(stmt);
- stmt = NULL;
- if ((type == CALENDAR_BOOK_TYPE_EVENT && dtstart_type == CALENDAR_TIME_UTIME)
- || (type == CALENDAR_BOOK_TYPE_TODO && dtend_type == CALENDAR_TIME_UTIME))
- {
- long long int now_utime;
- now_utime = _cal_time_get_now();
- now_utime -= now_utime % 60;
-
- snprintf(query, sizeof(query),
- "SELECT A.event_id, A.dtstart_utime, "
- "B.remind_tick, B.remind_tick_unit, "
- "C.type "
- "FROM %s as A, " // A is normal instance
- "%s as B ON A.event_id = B.event_id, " // B is alarm
- "%s as C ON B.event_id = C.id " // c is schedule
- "WHERE C.has_alarm == 1 AND C.type = %d "
- "AND B.remind_tick_unit = %d "
- "AND B.alarm_time = %lld "
- "UNION "
- "SELECT A.event_id, A.dtstart_utime, "
- "B.remind_tick, B.remind_tick_unit, "
- "C.type "
- "FROM %s as A, " // A is normal instance
- "%s as B ON A.event_id = B.event_id, " // B is alarm
- "%s as C ON B.event_id = C.id " // c is schedule
- "WHERE C.has_alarm = 1 AND C.type = %d "
- "AND B.remind_tick_unit > %d "
- "AND (A.dtstart_utime - (B.remind_tick * B.remind_tick_unit)) >= %lld "
- "AND (A.dtstart_utime - (B.remind_tick * B.remind_tick_unit)) < %lld "
- "UNION "
- "SELECT B.id, B.dtend_utime, "
- "A.remind_tick, A.remind_tick_unit, "
- "B.type "
- "FROM %s as A, " // A is alarm
- "%s as B ON A.event_id = B.id " // B is schedule
- "WHERE B.has_alarm == 1 AND B.type = %d "
- "AND A.remind_tick_unit = %d "
- "AND A.alarm_time = %lld "
- "UNION "
- "SELECT B.id, B.dtend_utime, "
- "A.remind_tick, A.remind_tick_unit, "
- "B.type "
- "FROM %s as A, " // A is alarm
- "%s as B ON A.event_id = B.id " // B is schedule
- "WHERE B.has_alarm = 1 AND B.type = %d "
- "AND A.remind_tick_unit > %d "
- "AND (B.dtend_utime - (A.remind_tick * A.remind_tick_unit)) >= %lld "
- "AND (B.dtend_utime - (A.remind_tick * A.remind_tick_unit)) < %lld ",
- CAL_TABLE_NORMAL_INSTANCE, CAL_TABLE_ALARM, CAL_TABLE_SCHEDULE,
- CALENDAR_BOOK_TYPE_EVENT,
- CALENDAR_ALARM_TIME_UNIT_SPECIFIC,
- now_utime,
- CAL_TABLE_NORMAL_INSTANCE, CAL_TABLE_ALARM, CAL_TABLE_SCHEDULE,
- CALENDAR_BOOK_TYPE_EVENT,
- CALENDAR_ALARM_TIME_UNIT_SPECIFIC,
- now_utime, now_utime + 60,
- CAL_TABLE_ALARM, CAL_TABLE_SCHEDULE,
- CALENDAR_BOOK_TYPE_TODO,
- CALENDAR_ALARM_TIME_UNIT_SPECIFIC,
- now_utime,
- CAL_TABLE_ALARM, CAL_TABLE_SCHEDULE,
- CALENDAR_BOOK_TYPE_TODO,
- CALENDAR_ALARM_TIME_UNIT_SPECIFIC,
- now_utime, now_utime + 60);
+ if (CALENDAR_ALARM_TIME_UNIT_SPECIFIC == unit) {
+ if (CALENDAR_TIME_UTIME == type) {
+ *tt_alert = utime;
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- DBG("query[%s]", query);
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
+ } else {
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
+ sscanf(datetime, CAL_FORMAT_LOCAL_DATETIME, &y, &m, &d, &h, &n, &s);
- while (CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- index = 0;
- nd = calloc(1, sizeof(struct _normal_data_s));
- nd->id = sqlite3_column_int(stmt, index++);
- nd->alarm_utime = sqlite3_column_int64(stmt, index++); // dtstart, dtend
- nd->tick = sqlite3_column_int(stmt, index++);
- nd->unit = sqlite3_column_int(stmt, index++);
- nd->record_type = sqlite3_column_int(stmt, index++); // event, todo
- *normal_list = g_list_append(*normal_list, nd);
- DBG("(%d)", nd->id);
+ st.tm_year = y - 1900;
+ st.tm_mon = m - 1;
+ st.tm_mday = d;
+ st.tm_hour = h;
+ st.tm_min = n;
+ st.tm_sec = s;
+ *tt_alert = (long long int)mktime(&st);
+ DBG("datetime[%s] to %02d:%02d:%02d (%lld)", datetime, h, n, s, *tt_alert);
}
+ sqlite3_finalize(stmt);
+ return CALENDAR_ERROR_NONE;
}
- else
- {
- int now_datetime;
- time_t now_timet = time(NULL);
- struct tm start_tm = {0};
- now_timet -= now_timet % 60;
- gmtime_r(&now_timet, &start_tm);
- now_datetime = (start_tm.tm_year + 1900) * 10000
- + (start_tm.tm_mon + 1) * 100
- + (start_tm.tm_mday);
-
- snprintf(query, sizeof(query),
- "SELECT A.event_id, A.dtstart_datetime, "
- "B.remind_tick, B.remind_tick_unit, "
- "C.type "
- "FROM %s as A, " // A is allday instance
- "%s as B ON A.event_id = B.event_id, " // B is alarm
- "%s as C ON B.event_id = C.id " // C is schedule
- "WHERE C.has_alarm == 1 AND C.type = %d "
- "AND B.remind_tick_unit = %d "
- "AND B.alarm_time = %d "
- "UNION "
- "SELECT A.event_id, A.dtstart_datetime, "
- "B.remind_tick, B.remind_tick_unit, "
- "C.type "
- "FROM %s as A, " // A is allday instance
- "%s as B ON A.event_id = B.event_id, " // B is alarm
- "%s as C ON B.event_id = C.id " // C is schedule
- "WHERE C.has_alarm = 1 AND C.type = %d "
- "AND B.remind_tick_unit > %d "
- "AND A.dtstart_datetime - (B.remind_tick * B.remind_tick_unit)/86400 = %d "
- "UNION "
- "SELECT A.event_id, B.dtend_datetime, "
- "A.remind_tick, A.remind_tick_unit, "
- "B.type "
- "FROM %s as A, " // A is alarm
- "%s as B ON A.event_id = B.id " // B is schedule
- "WHERE B.has_alarm == 1 AND B.type = %d "
- "AND A.remind_tick_unit = %d AND A.alarm_time = %d "
- "UNION "
- "SELECT A.event_id, B.dtend_datetime, "
- "A.remind_tick, A.remind_tick_unit, "
- "B.type "
- "FROM %s as A, " // A is alarm
- "%s as B ON A.event_id = B.id " // B is schedule
- "WHERE B.has_alarm = 1 AND B.type = %d "
- "AND A.remind_tick_unit > %d "
- "AND B.dtend_datetime - (A.remind_tick * A.remind_tick_unit)/86400 = %d ",
- CAL_TABLE_ALLDAY_INSTANCE, CAL_TABLE_ALARM, CAL_TABLE_SCHEDULE,
- CALENDAR_BOOK_TYPE_EVENT,
- CALENDAR_ALARM_TIME_UNIT_SPECIFIC,
- now_datetime,
- CAL_TABLE_ALLDAY_INSTANCE, CAL_TABLE_ALARM, CAL_TABLE_SCHEDULE,
- CALENDAR_BOOK_TYPE_EVENT,
- CALENDAR_ALARM_TIME_UNIT_SPECIFIC,
- now_datetime,
- CAL_TABLE_ALARM, CAL_TABLE_SCHEDULE,
- CALENDAR_BOOK_TYPE_TODO,
- CALENDAR_ALARM_TIME_UNIT_SPECIFIC,
- now_datetime,
- CAL_TABLE_ALARM, CAL_TABLE_SCHEDULE,
- CALENDAR_BOOK_TYPE_TODO,
- CALENDAR_ALARM_TIME_UNIT_SPECIFIC,
- now_datetime);
+ sqlite3_finalize(stmt);
+
+ // not specific
+
+ time_t current = time(NULL);
+ current += (tick * unit);
+ current -= 2; // in case time passed
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
+ switch (record_type)
+ {
+ case CALENDAR_BOOK_TYPE_EVENT:
+ switch (dtstart_type)
{
- DBG("query[%s]", query);
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
+ case CALENDAR_TIME_UTIME:
+ utime = __cal_server_alarm_get_alert_utime("dtstart_utime", event_id, current);
+ break;
+
+ case CALENDAR_TIME_LOCALTIME:
+ utime = __cal_server_alarm_get_alert_localtime("dtstart_datetime", event_id, current);
+ break;
}
+ break;
- const unsigned char *temp;
- while (CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ case CALENDAR_BOOK_TYPE_TODO:
+ switch (dtend_type)
{
- index = 0;
- ad = calloc(1, sizeof(struct _allday_data_s));
- ad->id = sqlite3_column_int(stmt, index++);
- temp = sqlite3_column_text(stmt, index++); // dtstart, dtend
- ad->alarm_datetime = atoi((const char *)temp);
- ad->tick = sqlite3_column_int(stmt, index++);
- ad->unit = sqlite3_column_int(stmt, index++);
- ad->record_type = sqlite3_column_int(stmt, index++);
- *allday_list = g_list_append(*allday_list, ad);
+ case CALENDAR_TIME_UTIME:
+ utime = __cal_server_alarm_get_alert_utime("dtend_utime", event_id, current);
+ break;
+
+ case CALENDAR_TIME_LOCALTIME:
+ utime = __cal_server_alarm_get_alert_localtime("dtend_datetime", event_id, current);
+ break;
}
+ break;
}
- sqlite3_finalize(stmt);
+ DBG("alert_time(%lld) = utime(%lld) - (tick(%d) * unit(%d))", *tt_alert, utime, datetime, tick, unit);
+
+ *tt_alert = utime - (tick * unit);
return CALENDAR_ERROR_NONE;
}
-// this api is necessary for repeat instance.
-static int __cal_server_alarm_unset_alerted_alarmmgr_id(int alarm_id)
+static void __cal_server_alarm_get_upcoming_specific_utime(time_t utime, bool get_all, GList **l) // case 1
{
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- cal_db_util_error_e dbret = CAL_DB_OK;
-
- DBG("alarm_id(%d)", alarm_id);
+ char query_specific_utime[CAL_DB_SQL_MAX_LEN] = {0};
+ snprintf(query_specific_utime, sizeof(query_specific_utime),
+ // alarm utime(normal event + todo)
+ "SELECT event_id, remind_tick_unit, remind_tick, alarm_type, alarm_utime, alarm_datetime "
+ "FROM %s "
+ "WHERE remind_tick_unit =%d AND alarm_type =%d AND alarm_utime %s %ld %s",
+ CAL_TABLE_ALARM,
+ CALENDAR_ALARM_TIME_UNIT_SPECIFIC, CALENDAR_TIME_UTIME,
+ true == get_all ? "=" : ">",
+ utime,
+ true == get_all ? "" : "ORDER BY alarm_utime ASC LIMIT 1");
+
+ sqlite3_stmt *stmt = NULL;
+ stmt = _cal_db_util_query_prepare(query_specific_utime);
+ if (NULL == stmt) {
+ ERR("_cal_db_util_query_prepare() Failed");
+ ERR("[%s]", query_specific_utime);
+ return;
+ }
- snprintf(query, sizeof(query),
- "UPDATE %s SET alarm_id = 0 WHERE alarm_id = %d ",
- CAL_TABLE_ALARM, alarm_id);
+ while (CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
+ struct _alarm_data_s *ad = calloc(1, sizeof(struct _alarm_data_s));
- dbret = _cal_db_util_query_exec(query);
- if (CAL_DB_OK != dbret)
- {
- ERR("_cal_db_util_query_exec() Failed(%d)", dbret);
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
+ int index = 0;
+ ad->event_id = sqlite3_column_int(stmt, index++);
+ ad->unit = sqlite3_column_int(stmt, index++);
+ ad->tick = sqlite3_column_int(stmt, index++);
+ ad->type = sqlite3_column_int(stmt, index++);
+ ad->time = (long long int)sqlite3_column_int64(stmt, index++);
+ snprintf(ad->datetime, sizeof(ad->datetime), "%s", (const char *)sqlite3_column_text(stmt, index++));
+ *l = g_list_append(*l, ad);
+ DBG("found id(%d) unit(%d) tick(%d) type(%d) time(%lld) [%s]",
+ ad->event_id, ad->unit, ad->tick, ad->type, ad->time, ad->datetime);
+ ad->alert_utime = ad->time;
+ if (false == get_all) break;
}
-
- return CALENDAR_ERROR_NONE;
+ sqlite3_finalize(stmt);
}
-static int __cal_server_alarm_alert_with_pkgname(const char *pkgname, char *id, char *time, char *tick, char *unit, char *type)
+static void __cal_server_alarm_get_upcoming_specific_localtime(const char *datetime, bool get_all, GList **l)
{
- int ret = CALENDAR_ERROR_NONE;
- int index;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- const char *key;
- const char *value;
- sqlite3_stmt *stmt = NULL;
- cal_db_util_error_e dbret = CAL_DB_OK;
-
- if (NULL == pkgname)
- {
- ERR("Invalid parameter: pkgname is NULL");
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- // get user key, value
- snprintf(query, sizeof(query), "SELECT key, value FROM %s WHERE pkgname = '%s' ",
- CAL_REMINDER_ALERT, pkgname);
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
-
- while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- index = 0;
- key = (const char *)sqlite3_column_text(stmt, index++);
- value = (const char *)sqlite3_column_text(stmt, index++);
+ char query_specific_localtime[CAL_DB_SQL_MAX_LEN] = {0};
+ snprintf(query_specific_localtime, sizeof(query_specific_localtime),
+ "SELECT event_id, remind_tick_unit, remind_tick, "
+ "alarm_type, alarm_utime, alarm_datetime "
+ "FROM %s "
+ "WHERE remind_tick_unit=%d AND alarm_type=%d AND alarm_datetime %s '%s' %s",
+ CAL_TABLE_ALARM,
+ CALENDAR_ALARM_TIME_UNIT_SPECIFIC, CALENDAR_TIME_LOCALTIME,
+ true == get_all ? "=" : ">",
+ datetime,
+ true == get_all ? "" : "ORDER BY alarm_datetime ASC LIMIT 1");
+
+ sqlite3_stmt *stmt = NULL;
+ stmt = _cal_db_util_query_prepare(query_specific_localtime);
+ if (NULL == stmt) {
+ ERR("_cal_db_util_query_prepare() Failed");
+ ERR("[%s]", query_specific_localtime);
+ return;
}
- // run appsvc
- DBG("[%s][%s][%s][%s]", id, time, tick, unit);
-
- bundle *b;
- b = bundle_create();
- appsvc_set_pkgname(b, pkgname);
- appsvc_set_operation(b, APPSVC_OPERATION_DEFAULT);
- if (key && value) appsvc_add_data(b, key, value);
- appsvc_add_data(b, "id", id);
- appsvc_add_data(b, "time", time);
- appsvc_add_data(b, "tick", tick);
- appsvc_add_data(b, "unit", unit);
- appsvc_add_data(b, "type", type);
- ret = appsvc_run_service(b, 0, NULL, NULL);
- bundle_free(b);
+ while (CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
+ struct _alarm_data_s *ad = calloc(1, sizeof(struct _alarm_data_s));
+ int index = 0;
+ ad->event_id = sqlite3_column_int(stmt, index++);
+ ad->unit = sqlite3_column_int(stmt, index++);
+ ad->tick = sqlite3_column_int(stmt, index++);
+ ad->type = sqlite3_column_int(stmt, index++);
+ ad->time = (long long int)sqlite3_column_int64(stmt, index++);
+ snprintf(ad->datetime, sizeof(ad->datetime), "%s", (const char *)sqlite3_column_text(stmt, index++));
+ *l = g_list_append(*l, ad);
+ DBG("found id(%d) unit(%d) tick(%d) type(%d) time(%lld) [%s]",
+ ad->event_id, ad->unit, ad->tick, ad->type, ad->time, ad->datetime);
+
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
+ sscanf(ad->datetime, CAL_FORMAT_LOCAL_DATETIME, &y, &m, &d, &h, &n, &s);
+
+ struct tm st = {0};
+ st.tm_year = y - 1900;
+ st.tm_mon = m -1;
+ st.tm_mday = d;
+ st.tm_hour = h;
+ st.tm_min = n;
+ st.tm_sec = s;
+ ad->alert_utime = (long long int)mktime(&st);
+ if (false == get_all) break;
+ }
sqlite3_finalize(stmt);
+}
- // if no app, delete from the table
- if (APPSVC_RET_ELAUNCH == ret)
- {
- DBG("Deleted no responce pkg[%s]", pkgname);
- snprintf(query, sizeof(query), "DELETE FROM %s WHERE pkgname = '%s' ",
- CAL_REMINDER_ALERT, pkgname);
- dbret = _cal_db_util_query_exec(query);
- if (CAL_DB_OK != dbret)
- {
- ERR("_cal_db_util_query_exec() failed(ret:%d)", ret);
- switch (dbret)
- {
- case CAL_DB_ERROR_NO_SPACE:
- return CALENDAR_ERROR_FILE_NO_SPACE;
- default:
- return CALENDAR_ERROR_DB_FAILED;
- }
- }
+static void __cal_server_alarm_get_upcoming_nonspecific_event_utime(time_t utime, bool get_all, GList **l)
+{
+ char query_nonspecific_event_utime[CAL_DB_SQL_MAX_LEN] = {0};
+ snprintf(query_nonspecific_event_utime, sizeof(query_nonspecific_event_utime),
+ // A:alarm B:normal instance
+ "SELECT A.event_id, A.remind_tick_unit, A.remind_tick, A.alarm_type, B.dtstart_utime, A.alarm_datetime "
+ "FROM %s as A, %s as B ON A.event_id = B.event_id "
+ "WHERE A.remind_tick_unit >%d AND (B.dtstart_utime - (A.remind_tick_unit * A.remind_tick)) %s %ld %s",
+ CAL_TABLE_ALARM, CAL_TABLE_NORMAL_INSTANCE,
+ CALENDAR_ALARM_TIME_UNIT_SPECIFIC,
+ true == get_all ? "=" : ">",
+ utime,
+ true == get_all ? "" : "ORDER BY (B.dtstart_utime - (A.remind_tick_unit * A.remind_tick)) LIMIT 1");
+ sqlite3_stmt *stmt = NULL;
+ stmt = _cal_db_util_query_prepare(query_nonspecific_event_utime);
+ if (NULL == stmt) {
+ ERR("_cal_db_util_query_prepare() Failed");
+ ERR("[%s]", query_nonspecific_event_utime);
+ return;
}
- return CALENDAR_ERROR_NONE;
-}
-static int __cal_server_alarm_alert(char *id, char *time, char *tick, char *unit, char *type)
-{
- int index;
- char query[CAL_DB_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
-
- snprintf(query, sizeof(query), "SELECT pkgname FROM %s WHERE onoff = 1 ",
- CAL_REMINDER_ALERT);
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
-
- while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- index = 0;
- const char *pkgname = (const char *)sqlite3_column_text(stmt, index++);
- DBG("pkgname[%s]", pkgname);
- __cal_server_alarm_alert_with_pkgname(pkgname, id, time, tick, unit, type);
+ while (CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
+ struct _alarm_data_s *ad = calloc(1, sizeof(struct _alarm_data_s));
+
+ int index = 0;
+ ad->event_id = sqlite3_column_int(stmt, index++);
+ ad->unit = sqlite3_column_int(stmt, index++);
+ ad->tick = sqlite3_column_int(stmt, index++);
+ ad->type = sqlite3_column_int(stmt, index++);
+ ad->time = (long long int)sqlite3_column_int64(stmt, index++);
+ snprintf(ad->datetime, sizeof(ad->datetime), "%s", (const char *)sqlite3_column_text(stmt, index++));
+ *l = g_list_append(*l, ad);
+ DBG("found id(%d) unit(%d) tick(%d) type(%d) time(%lld) [%s]",
+ ad->event_id, ad->unit, ad->tick, ad->type, ad->time, ad->datetime);
+
+ ad->alert_utime = ad->time - (ad->tick * ad->unit);
+ if (false == get_all) break;
}
sqlite3_finalize(stmt);
-
- return CALENDAR_ERROR_NONE;
}
-static int __cal_server_alarm_noti_with_appsvc(int alarm_id, GList *normal_list, GList *allday_list)
+static void __cal_server_alarm_get_upcoming_nonspecific_event_localtime(const char *datetime, bool get_all, GList **l)
{
- char buf_id[128] = {0};
- char buf_time[128] = {0};
- char buf_tick[128] = {0};
- char buf_unit[128] = {0};
- char buf_type[128] = {0};
- GList *l = NULL;
-
- l = g_list_first(normal_list);
- if (NULL == l) DBG("normal list is NULL");
- while (l)
- {
- struct _normal_data_s *nd = (struct _normal_data_s *)l->data;
- snprintf(buf_id, sizeof(buf_id), "%d", nd->id);
- snprintf(buf_time, sizeof(buf_time), "%lld", nd->alarm_utime);
- snprintf(buf_tick, sizeof(buf_tick), "%d", nd->tick);
- snprintf(buf_unit, sizeof(buf_unit), "%d", nd->unit);
- snprintf(buf_type, sizeof(buf_type), "%d", nd->record_type);
-
- __cal_server_alarm_alert(buf_id, buf_time, buf_tick, buf_unit, buf_type);
- l = g_list_next(l);
+ char query_nonspecific_event_localtime[CAL_DB_SQL_MAX_LEN] = {0};
+ snprintf(query_nonspecific_event_localtime, sizeof(query_nonspecific_event_localtime),
+ // A:alarm B:allday
+ "SELECT A.event_id, A.remind_tick_unit, A.remind_tick, A.alarm_type, A.alarm_utime, B.dtstart_datetime "
+ "FROM %s as A, %s as B ON A.event_id = B.event_id "
+ "WHERE A.remind_tick_unit >%d AND "
+ "(strftime('%%s', B.dtstart_datetime) - (A.remind_tick_unit * A.remind_tick) - strftime('%%s', '%s') %s 0) %s",
+ CAL_TABLE_ALARM, CAL_TABLE_ALLDAY_INSTANCE,
+ CALENDAR_ALARM_TIME_UNIT_SPECIFIC,
+ datetime,
+ true == get_all ? "=" : ">",
+ true == get_all ? "" : "ORDER BY (strftime('%s', B.dtstart_datetime) - (A.remind_tick_unit * A.remind_tick)) LIMIT 1 ");
+ sqlite3_stmt *stmt = NULL;
+ stmt = _cal_db_util_query_prepare(query_nonspecific_event_localtime);
+ if (NULL == stmt) {
+ ERR("_cal_db_util_query_prepare() Failed");
+ ERR("[%s]", query_nonspecific_event_localtime);
+ return;
}
- l = NULL;
- l = g_list_first(allday_list);
- if (NULL == l) DBG("allday list is NULL");
- while (l)
- {
- struct _allday_data_s *ad = (struct _allday_data_s *)l->data;
- snprintf(buf_id, sizeof(buf_id), "%d", ad->id);
- snprintf(buf_time, sizeof(buf_time), "%d", ad->alarm_datetime);
- snprintf(buf_tick, sizeof(buf_tick), "%d", ad->tick);
- snprintf(buf_unit, sizeof(buf_unit), "%d", ad->unit);
- snprintf(buf_type, sizeof(buf_type), "%d", ad->record_type);
+ while (CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
+ struct _alarm_data_s *ad = calloc(1, sizeof(struct _alarm_data_s));
- __cal_server_alarm_alert(buf_id, buf_time, buf_tick, buf_unit, buf_type);
- l = g_list_next(l);
+ int index = 0;
+ ad->event_id = sqlite3_column_int(stmt, index++);
+ ad->unit = sqlite3_column_int(stmt, index++);
+ ad->tick = sqlite3_column_int(stmt, index++);
+ ad->type = sqlite3_column_int(stmt, index++);
+ ad->time = (long long int)sqlite3_column_int64(stmt, index++);
+ snprintf(ad->datetime, sizeof(ad->datetime), "%s", (const char *)sqlite3_column_text(stmt, index++));
+ *l = g_list_append(*l, ad);
+ DBG("found id(%d) unit(%d) tick(%d) type(%d) time(%lld) [%s]",
+ ad->event_id, ad->unit, ad->tick, ad->type, ad->time, ad->datetime);
+
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
+ sscanf(ad->datetime, CAL_FORMAT_LOCAL_DATETIME, &y, &m, &d, &h, &n, &s);
+
+ struct tm st = {0};
+ st.tm_year = y - 1900;
+ st.tm_mon = m -1;
+ st.tm_mday = d;
+ st.tm_hour = h;
+ st.tm_min = n;
+ st.tm_sec = s;
+ ad->alert_utime = (long long int)mktime(&st) - (ad->tick * ad->unit);
+ if (false == get_all) break;
}
- return CALENDAR_ERROR_NONE;
+ sqlite3_finalize(stmt);
}
-static int __cal_server_alarm_register_next_normal(long long int now_utime, GList *normal_list)
+static void __cal_server_alarm_get_upcoming_nonspecific_todo_utime(time_t utime, bool get_all, GList **l)
{
- int ret;
- int alarm_id;
- struct _normal_data_s *nd;
+ char query_nonspecific_todo_utime[CAL_DB_SQL_MAX_LEN] = {0};
+ snprintf(query_nonspecific_todo_utime, sizeof(query_nonspecific_todo_utime),
+ // A:alarm B:todo(normal)
+ "SELECT A.event_id, A.remind_tick_unit, A.remind_tick, A.alarm_type, B.dtend_utime, A.alarm_datetime "
+ "FROM %s as A, %s as B ON A.event_id = B.id "
+ "WHERE A.remind_tick_unit >%d AND B.type =%d "
+ "AND (B.dtend_utime - (A.remind_tick_unit * A.remind_tick)) %s %ld %s",
+ CAL_TABLE_ALARM, CAL_TABLE_SCHEDULE,
+ CALENDAR_ALARM_TIME_UNIT_SPECIFIC, CALENDAR_BOOK_TYPE_TODO,
+ true == get_all ? "=" : ">",
+ utime,
+ true == get_all ? "" : "ORDER BY (B.dtend_utime - (A.remind_tick_unit * A.remind_tick)) LIMIT 1 ");
+
+ sqlite3_stmt *stmt = NULL;
+ stmt = _cal_db_util_query_prepare(query_nonspecific_todo_utime);
+ if (NULL == stmt) {
+ ERR("_cal_db_util_query_prepare() Failed");
+ ERR("[%s]", query_nonspecific_todo_utime);
+ return;
+ }
- GList *l = g_list_first(normal_list);
+ while (CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
+ struct _alarm_data_s *ad = calloc(1, sizeof(struct _alarm_data_s));
- // try to save the first record.
- // if alarm id exists, it means updated record is not earilier than already registerd one.
- nd = (struct _normal_data_s *)l->data;
- if (NULL == nd)
- {
- ERR("No data");
- return CALENDAR_ERROR_DB_FAILED;
+ int index = 0;
+ ad->event_id = sqlite3_column_int(stmt, index++);
+ ad->unit = sqlite3_column_int(stmt, index++);
+ ad->tick = sqlite3_column_int(stmt, index++);
+ ad->type = sqlite3_column_int(stmt, index++);
+ ad->time = (long long int)sqlite3_column_int64(stmt, index++);
+ snprintf(ad->datetime, sizeof(ad->datetime), "%s", (const char *)sqlite3_column_text(stmt, index++));
+ *l = g_list_append(*l, ad);
+ DBG("found id(%d) unit(%d) tick(%d) type(%d) time(%lld) [%s]",
+ ad->event_id, ad->unit, ad->tick, ad->type, ad->time, ad->datetime);
+
+ ad->alert_utime = ad->time - (ad->tick * ad->unit);
+ if (false == get_all) break;
}
+ sqlite3_finalize(stmt);
+}
- if (nd->alarm_id > 0)
- {
- DBG("Already registered this id");
- return CALENDAR_ERROR_NONE;
+static void __cal_server_alarm_get_upcoming_nonspecific_todo_localtime(const char *datetime, bool get_all, GList **l)
+{
+ char query_nonspecific_todo_localtime[CAL_DB_SQL_MAX_LEN] = {0};
+ snprintf(query_nonspecific_todo_localtime, sizeof(query_nonspecific_todo_localtime),
+ // A:alarm B:todo(allday)
+ "SELECT A.event_id, A.remind_tick_unit, A.remind_tick, A.alarm_type, A.alarm_utime, B.dtend_datetime "
+ "FROM %s as A, %s as B ON A.event_id = B.id "
+ "WHERE A.remind_tick_unit >%d AND B.type =%d "
+ "AND (strftime('%%s', B.dtend_datetime) - (A.remind_tick_unit * A.remind_tick) - strftime('%%s', '%s') %s 0) %s",
+ CAL_TABLE_ALARM, CAL_TABLE_SCHEDULE,
+ CALENDAR_ALARM_TIME_UNIT_SPECIFIC, CALENDAR_BOOK_TYPE_TODO,
+ datetime,
+ true == get_all ? "=" : ">",
+ true == get_all ? "" : "ORDER BY (strftime('%s', B.dtend_datetime) - (A.remind_tick_unit * A.remind_tick)) LIMIT 1 ");
+
+ sqlite3_stmt *stmt = NULL;
+ stmt = _cal_db_util_query_prepare(query_nonspecific_todo_localtime);
+ if (NULL == stmt) {
+ ERR("_cal_db_util_query_prepare() Failed");
+ ERR("[%s]", query_nonspecific_todo_localtime);
+ return;
}
- DBG("new is earilier than registered.");
+ while (CAL_DB_ROW == _cal_db_util_stmt_step(stmt)) {
+ struct _alarm_data_s *ad = calloc(1, sizeof(struct _alarm_data_s));
- // clear all alarm which set by mine.
- ret = alarmmgr_enum_alarm_ids(__cal_server_alarm_clear_all_cb, NULL);
- if (ret != ALARMMGR_RESULT_SUCCESS)
- {
- ERR("alarmmgr_enum_alarm_ids() failed");
- return ret;
+ int index = 0;
+ ad->event_id = sqlite3_column_int(stmt, index++);
+ ad->unit = sqlite3_column_int(stmt, index++);
+ ad->tick = sqlite3_column_int(stmt, index++);
+ ad->type = sqlite3_column_int(stmt, index++);
+ ad->time = (long long int)sqlite3_column_int64(stmt, index++);
+ snprintf(ad->datetime, sizeof(ad->datetime), "%s", (const char *)sqlite3_column_text(stmt, index++));
+ *l = g_list_append(*l, ad);
+ DBG("found id(%d) unit(%d) tick(%d) type(%d) time(%lld) [%s]",
+ ad->event_id, ad->unit, ad->tick, ad->type, ad->time, ad->datetime);
+
+ int y = 0, m = 0, d = 0;
+ int h = 0, n = 0, s = 0;
+ sscanf(ad->datetime, CAL_FORMAT_LOCAL_DATETIME, &y, &m, &d, &h, &n, &s);
+
+ struct tm st = {0};
+ st.tm_year = y - 1900;
+ st.tm_mon = m -1;
+ st.tm_mday = d;
+ st.tm_hour = h;
+ st.tm_min = n;
+ st.tm_sec = s;
+ ad->alert_utime = (long long int)mktime(&st) - (ad->tick * ad->unit);
+ if (false == get_all) break;
}
+ sqlite3_finalize(stmt);
+}
- // register new list
- long long int mod_alarm_utime; // del seconds
- mod_alarm_utime = nd->alarm_utime - (nd->alarm_utime % 60);
-// ret = alarmmgr_add_alarm(ALARM_TYPE_VOLATILE, (time_t)(mod_alarm_utime - now_utime), 0, NULL, &alarm_id);
+static int __cal_server_alarm_get_alert_list(time_t utime, GList **list)
+{
+ ENTER();
+ retvm_if (NULL == list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: list is NULL");
+
+ tzset();
+ struct tm st_local = {0};
+ localtime_r(&utime, &st_local);
+ char datetime[32] = {0};
+ snprintf(datetime, sizeof(datetime), CAL_FORMAT_LOCAL_DATETIME,
+ st_local.tm_year +1900, st_local.tm_mon + 1, st_local.tm_mday,
+ st_local.tm_hour, st_local.tm_min, st_local.tm_sec);
+ DBG("get alert to register with given time (%ld) datetime[%s]", utime, datetime);
-///////////////////////////////////////
- alarm_entry_t *alarm_info = NULL;
- alarm_info = alarmmgr_create_alarm();
- if (NULL == alarm_info)
- {
- ERR("Failed to create alarm");
- return CALENDAR_ERROR_DB_FAILED;
- }
- char *tzid = NULL;
- tzid = vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID);
-
- alarm_date_t alarm_date;
- _cal_time_utoi(mod_alarm_utime, tzid,
- &alarm_date.year, &alarm_date.month, &alarm_date.day,
- &alarm_date.hour, &alarm_date.min, &alarm_date.sec);
- DBG("tzid[%s] datetime(%04d/%02d/%02d %02d:%02d:%02d", tzid,
- alarm_date.year, alarm_date.month, alarm_date.day,
- alarm_date.hour, alarm_date.min, alarm_date.sec);
-
- alarmmgr_set_time(alarm_info, alarm_date);
- ret = alarmmgr_add_alarm_with_localtime(alarm_info, NULL, &alarm_id);
- if (tzid) free(tzid);
-///////////////////////////////////////
+ GList *l = NULL;
- if (ret < 0)
- {
- ERR("alarmmgr_add_alarm_appsvc failed (%d)", ret);
- return ret;
- }
- DBG("Get normal alarmmgr id (%d)", alarm_id);
- __cal_server_alarm_update_alarm_id(alarm_id, nd->id, nd->tick, nd->unit);
+ __cal_server_alarm_get_upcoming_specific_utime(utime, true, &l);
+ __cal_server_alarm_get_upcoming_nonspecific_event_utime(utime, true, &l);
+ __cal_server_alarm_get_upcoming_nonspecific_todo_utime(utime, true, &l);
+
+ __cal_server_alarm_get_upcoming_specific_localtime(datetime, true, &l);
+ __cal_server_alarm_get_upcoming_nonspecific_event_localtime(datetime, true, &l);
+ __cal_server_alarm_get_upcoming_nonspecific_todo_localtime(datetime, true, &l);
+
+ *list = l;
return CALENDAR_ERROR_NONE;
}
-static int __cal_server_alarm_register_next_allday(time_t now_timet, GList *allday_list)
+static gint __cal_server_alarm_sort_cb(gconstpointer a, gconstpointer b)
{
- int ret;
- int alarm_id;
- struct _allday_data_s *ad;
- time_t alarm_timet;
-
- GList *l = g_list_first(allday_list);
- alarm_id = 0;
- ad = (struct _allday_data_s *)l->data;
- if (NULL == ad)
- {
- ERR("No data");
- return CALENDAR_ERROR_DB_FAILED;
- }
+ struct _alarm_data_s *p1 = (struct _alarm_data_s *)a;
+ struct _alarm_data_s *p2 = (struct _alarm_data_s *)b;
+ DBG("%lld) > (%lld)",p1->alert_utime, p2->alert_utime);
- if (ad->alarm_id > 0)
- {
- DBG("Already registered this id");
- return CALENDAR_ERROR_NONE;
- }
+ return p1->alert_utime > p2->alert_utime ? 1 : -1;
+}
- DBG("new is earilier than registered.");
+static GFunc __cal_server_alarm_print_cb(gpointer data, gpointer user_data)
+{
+ struct _alarm_data_s *ad = (struct _alarm_data_s *)data;
+ DBG("id(%d) unit(%d) tick(%d) type(%d) time(%lld) datetime[%s]",
+ ad->event_id, ad->unit, ad->tick, ad->type, ad->time, ad->datetime);
+ return 0;
+}
+
+static int __cal_server_alarm_register(GList *alarm_list)
+{
+ ENTER();
+ retvm_if (NULL == alarm_list, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter: alarm list is NULL");
+
+ int ret = CALENDAR_ERROR_NONE;
+ GList *l = g_list_first(alarm_list);
+ struct _alarm_data_s *ad = (struct _alarm_data_s *)l->data;
+ retvm_if (NULL == ad, CALENDAR_ERROR_DB_FAILED, "No data");
// clear all alarm which set by mine.
ret = alarmmgr_enum_alarm_ids(__cal_server_alarm_clear_all_cb, NULL);
return ret;
}
- // register new list
-// ret = alarmmgr_add_alarm(ALARM_TYPE_VOLATILE, (time_t)(alarm_timet - (ad->tick * ad->unit) - now_timet), 0, NULL, &alarm_id);
-
-///////////////////////////////////////
+ time_t mod_time = (time_t)ad->alert_utime;
alarm_entry_t *alarm_info = NULL;
alarm_info = alarmmgr_create_alarm();
if (NULL == alarm_info)
ERR("Failed to create alarm");
return CALENDAR_ERROR_DB_FAILED;
}
- char *tzid = NULL;
- tzid = vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID);
-
- alarm_date_t alarm_date;
- _cal_time_utoi((long long int)(alarm_timet - (ad->tick * ad->unit)), tzid,
- &alarm_date.year, &alarm_date.month, &alarm_date.day,
- &alarm_date.hour, &alarm_date.min, &alarm_date.sec);
- alarmmgr_set_time(alarm_info, alarm_date);
- ret = alarmmgr_add_alarm_with_localtime(alarm_info, NULL, &alarm_id);
- if (tzid) free(tzid);
-///////////////////////////////////////
+ tzset();
+ struct tm st_alarm = {0};
+
+ switch (ad->system_type)
+ {
+ case CALENDAR_SYSTEM_EAST_ASIAN_LUNISOLAR:
+ gmtime_r(&mod_time, &st_alarm);
+ break;
+
+ default:
+ tzset();
+ localtime_r(&mod_time, &st_alarm);
+ break;
+ }
+
+ alarm_date_t date = {0};
+ date.year = st_alarm.tm_year + 1900;
+ date.month = st_alarm.tm_mon + 1;
+ date.day = st_alarm.tm_mday;
+ date.hour = st_alarm.tm_hour;
+ date.min = st_alarm.tm_min;
+ date.sec = st_alarm.tm_sec;
+ alarmmgr_set_time(alarm_info, date);
+ DBG(COLOR_CYAN" >>> registered record id (%d) at %04d/%02d/%02d %02d:%02d:%02d "COLOR_END" (utime(%lld), datetime[%s], tick(%d) unit(%d))",
+ ad->event_id, date.year, date.month, date.day, date.hour, date.min, date.sec,
+ ad->time, ad->datetime, ad->tick, ad->unit);
+ int alarm_id = 0;
+ ret = alarmmgr_add_alarm_with_localtime(alarm_info, NULL, &alarm_id);
if (ret < 0)
{
- ERR("alarmmgr_add_alarm_appsvc failed (%d)", ret);
+ ERR("alarmmgr_add_alarm_with_localtime failed (%d)", ret);
+ alarmmgr_free_alarm(alarm_info);
return ret;
}
- DBG("Get allday alarmmgr id (%d)", alarm_id);
- __cal_server_alarm_update_alarm_id(alarm_id, ad->id, ad->tick, ad->unit);
-
+ DBG("alarmmgr id (%d)", alarm_id);
+ __cal_server_alarm_update_alarm_id(alarm_id, ad->event_id, ad->tick, ad->unit);
+ alarmmgr_free_alarm(alarm_info);
return CALENDAR_ERROR_NONE;
}
-static gint __cal_server_alarm_normal_sort_cb(gconstpointer a, gconstpointer b)
-{
- struct _normal_data_s *p1 = (struct _normal_data_s *)a;
- struct _normal_data_s *p2 = (struct _normal_data_s *)b;
-
- return p1->alarm_utime - p2->alarm_utime > 0 ? 1 : -1;
-}
-
-static gint __cal_server_alarm_allday_sort_cb(gconstpointer a, gconstpointer b)
-{
- struct _allday_data_s *p1 = (struct _allday_data_s *)a;
- struct _allday_data_s *p2 = (struct _allday_data_s *)b;
-
- return p1->alarm_datetime - p2->alarm_datetime > 0 ? 1 : -1;
-}
-
-static int __cal_server_alarm_register_with_alarmmgr(long long int now_utime)
+static bool __app_matched_cb(app_control_h app_control, const char *package, void *user_data)
{
- GList *normal_list = NULL;
- GList *allday_list = NULL;
- int event_count;
- int todo_count;
- int loop_count;
+ retvm_if (NULL == user_data, true, "Invalid parameter: user_data is NULL");
+
+ int ret = 0;
+ char *mime = NULL;
+ ret = app_control_get_mime(app_control, &mime);
+ retvm_if(APP_CONTROL_ERROR_NONE != ret, true, "app_control_get_mime() is failed(%d)", ret);
+
+ const char *reminder_mime = "application/x-tizen.calendar.reminder";
+ if (strncmp(mime, reminder_mime, strlen(reminder_mime))) { // not same
+ DBG("get mime[%s] is not [%s]", mime, reminder_mime);
+ free(mime);
+ return true;
+ }
+ free(mime);
+
+ GList *alarm_list = (GList *)user_data;
+ int len = 0;
+ len = g_list_length(alarm_list);
+ if (0 == len) {
+ DBG("len is 0, no alarm list");
+ return true;
+ }
+
+ app_control_h b = NULL;
+ app_control_create(&b);
+ app_control_set_operation(b, APP_CONTROL_OPERATION_DEFAULT);
+ app_control_set_app_id(b, package);
+
+ // data
+ char **ids = NULL;
+ ids = calloc(len, sizeof(char *));
+ if (NULL == ids) {
+ ERR("calloc() is failed");
+ app_control_destroy(b);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ GList *l = g_list_first(alarm_list);
+ int i;
+ for (i = 0; i < len; i++) {
+ struct _alarm_data_s *ad = (struct _alarm_data_s *)l->data;
+ if (NULL == ad) {
+ ERR("No data");
+ l = g_list_next(l);
+ continue;
+ }
+ DBG("pkg[%s] time[%lld] tick[%d] unit[%d] record_type[%d]",
+ package, ad->time, ad->tick, ad->unit, ad->record);
+
+ char buf_event_id[128] = {0};
+ char buf_time[128] = {0};
+ char buf_tick[128] = {0};
+ char buf_unit[128] = {0};
+ char buf_record_type[128] = {0};
+ snprintf(buf_event_id, sizeof(buf_event_id), "%d", ad->event_id);
+ snprintf(buf_time, sizeof(buf_time), "%lld", ad->time);
+ snprintf(buf_tick, sizeof(buf_tick), "%d", ad->tick);
+ snprintf(buf_unit, sizeof(buf_unit), "%d", ad->unit);
+ snprintf(buf_record_type, sizeof(buf_record_type), "%d", ad->record);
- gettimeofday(&stv, NULL); // check time
+ char *p = NULL;
+ _cal_server_reminder_add_callback_data(&p, "id", buf_event_id);
+ _cal_server_reminder_add_callback_data(&p, "time", buf_time);
+ _cal_server_reminder_add_callback_data(&p, "tick", buf_tick);
+ _cal_server_reminder_add_callback_data(&p, "unit", buf_unit);
+ _cal_server_reminder_add_callback_data(&p, "type", buf_record_type);
- // for normal
- long long int from_utime, to_utime;
+ app_control_add_extra_data(b, buf_event_id, p); // key: id, value: id=4&time=123123&..
+ DBG("value[%s]", p);
+ free(p);
- event_count = 0;
- todo_count = 0;
- to_utime = now_utime - (now_utime % 60) + 60;
+ // append ids
+ ids[i] = strdup(buf_event_id);
- // searching 3months, next 6months, next 12months
- for (loop_count = 1; loop_count < 4; loop_count++)
- {
- from_utime = to_utime;
- to_utime = from_utime + (60 * 60 * 24 * 30 * 3 * loop_count);
- __cal_server_alarm_get_next_list_normal_event(from_utime, to_utime, &normal_list, &event_count);
- __cal_server_alarm_get_next_list_normal_todo(from_utime, to_utime, &normal_list, &todo_count);
- if (event_count + todo_count > 0)
- {
- break;
- }
+ l = g_list_next(l);
}
- DBG("event count(%d) todo count(%d)", event_count, todo_count);
-
- if (event_count + todo_count > 0)
- {
- normal_list = g_list_sort(normal_list, __cal_server_alarm_normal_sort_cb);
- DBG("after sorting");
- g_list_foreach(normal_list, (GFunc)__cal_server_alarm_print_list_normal, NULL);
- __cal_server_alarm_register_next_normal(now_utime, normal_list);
+ app_control_add_extra_data_array(b, "ids", (const char **)ids, len);
+ app_control_send_launch_request (b, NULL, NULL);
+ app_control_destroy(b);
+ // free ids
+ for (i = 0; i < len; i++) {
+ free(ids[i]);
+ ids[i] = NULL;
}
- if (normal_list)
- {
- g_list_free_full(normal_list, free);
- normal_list = NULL;
- }
-
- // for allday
- DBG("allday");
- time_t now_timet;
- time_t from_timet, to_timet;
- int from_datetime, to_datetime;
- struct tm datetime_tm;
- now_timet = (time_t)now_utime;
-
- event_count = 0;
- todo_count = 0;
- to_timet = now_timet;
-
- // searching 3months, next 6months, next 12months
- for (loop_count = 1; loop_count < 4; loop_count++)
- {
- from_timet = to_timet;
- gmtime_r(&from_timet, &datetime_tm);
- from_datetime = (1900 + datetime_tm.tm_year) * 10000 + (datetime_tm.tm_mon + 1) * 100 + datetime_tm.tm_mday;
+ free(ids);
- to_timet = from_timet + (60 * 60 * 24 * 30 * 3 * loop_count);
- gmtime_r(&to_timet, &datetime_tm);
- to_datetime = (1900 + datetime_tm.tm_year) * 10000 + (datetime_tm.tm_mon + 1) * 100 + datetime_tm.tm_mday;
+ return true;
+}
- __cal_server_alarm_get_next_list_allday_event(from_datetime, to_datetime, &allday_list, &event_count);
- __cal_server_alarm_get_next_list_allday_todo(from_datetime, to_datetime, &allday_list, &todo_count);
+static void __cal_server_alarm_noti_with_control(GList *alarm_list)
+{
+ retm_if(NULL == alarm_list, "No alarm list");
+
+ app_control_h app_control = NULL;
+ app_control_create(&app_control);
+ app_control_set_operation(app_control, APP_CONTROL_OPERATION_VIEW);
+ app_control_set_mime(app_control, "application/x-tizen.calendar.reminder");
+ app_control_foreach_app_matched(app_control, __app_matched_cb, alarm_list);
+ app_control_destroy(app_control);
+}
- if (event_count + todo_count > 0)
- {
- break;
+static void __cal_server_alarm_noti_with_callback(GList *alarm_list)
+{
+ retm_if(NULL == alarm_list, "No alarm list");
+
+ GList *l = g_list_first(alarm_list);
+ while (l) {
+ struct _alarm_data_s *ad = (struct _alarm_data_s *)l->data;
+ if (NULL == ad) {
+ ERR("No data");
+ l = g_list_next(l);
+ continue;
}
- }
- DBG("event count(%d) todo count(%d)", event_count, todo_count);
+ DBG("callback time[%lld] tick[%d] unit[%d] record_type[%d]",
+ ad->time, ad->tick, ad->unit, ad->record);
+
+ char buf_event_id[128] = {0};
+ char buf_time[128] = {0};
+ char buf_tick[128] = {0};
+ char buf_unit[128] = {0};
+ char buf_record_type[128] = {0};
+ snprintf(buf_event_id, sizeof(buf_event_id), "%d", ad->event_id);
+ snprintf(buf_time, sizeof(buf_time), "%lld", ad->time);
+ snprintf(buf_tick, sizeof(buf_tick), "%d", ad->tick);
+ snprintf(buf_unit, sizeof(buf_unit), "%d", ad->unit);
+ snprintf(buf_record_type, sizeof(buf_record_type), "%d", ad->record);
- if (event_count + todo_count > 0)
- {
- allday_list = g_list_sort(allday_list, __cal_server_alarm_allday_sort_cb);
- DBG("after sorting");
- g_list_foreach(allday_list, (GFunc)__cal_server_alarm_print_list_allday_todo, NULL);
- __cal_server_alarm_register_next_allday(now_timet, allday_list);
- }
- if (allday_list)
- {
- g_list_free_full(allday_list, free);
- allday_list = NULL;
- }
+ char *p = NULL;
+ _cal_server_reminder_add_callback_data(&p, "id", buf_event_id);
+ _cal_server_reminder_add_callback_data(&p, "time", buf_time);
+ _cal_server_reminder_add_callback_data(&p, "tick", buf_tick);
+ _cal_server_reminder_add_callback_data(&p, "unit", buf_unit);
+ _cal_server_reminder_add_callback_data(&p, "type", buf_record_type);
+ _cal_server_reminder_publish(p);
+ free(p);
- int diff;
- gettimeofday(&etv, NULL);
- diff = ((int)etv.tv_sec *1000 + (int)etv.tv_usec/1000)
- -((int)stv.tv_sec *1000 + (int)stv.tv_usec/1000);
- DBG("registering time diff %ld(%d.%d)",diff, diff/1000, diff%1000); // time check
- return 0;
+ l = g_list_next(l);
+ }
}
-static int __cal_server_alarm_callback(char *id, char *time, char *tick, char *unit, char *type)
+static int __cal_server_alarm_register_with_alarmmgr(time_t utime)
{
- _cal_server_reminder_add_callback_data("id", id);
- _cal_server_reminder_add_callback_data("time", time);
- _cal_server_reminder_add_callback_data("tick", tick);
- _cal_server_reminder_add_callback_data("unit", unit);
- _cal_server_reminder_add_callback_data("type", type);
-
- return CALENDAR_ERROR_NONE;
-}
+ tzset();
+ struct tm st_local = {0};
+ localtime_r(&utime, &st_local);
+ char datetime[32] = {0};
+ snprintf(datetime, sizeof(datetime), CAL_FORMAT_LOCAL_DATETIME,
+ st_local.tm_year +1900, st_local.tm_mon + 1, st_local.tm_mday,
+ st_local.tm_hour, st_local.tm_min, st_local.tm_sec);
+ DBG("search alarm to register with given time (%ld) datetime[%s]", utime, datetime);
-static int __cal_server_alarm_noti_callback(int alarm_id, GList *normal_list, GList *allday_list)
-{
- char buf_id[128] = {0};
- char buf_time[128] = {0};
- char buf_tick[128] = {0};
- char buf_unit[128] = {0};
- char buf_type[128] = {0};
GList *l = NULL;
- l = g_list_first(normal_list);
- if (NULL == l) DBG("normal list is NULL");
- while (l)
- {
- struct _normal_data_s *nd = (struct _normal_data_s *)l->data;
- snprintf(buf_id, sizeof(buf_id), "%d", nd->id);
- snprintf(buf_time, sizeof(buf_time), "%lld", nd->alarm_utime);
- snprintf(buf_tick, sizeof(buf_tick), "%d", nd->tick);
- snprintf(buf_unit, sizeof(buf_unit), "%d", nd->unit);
- snprintf(buf_type, sizeof(buf_type), "%d", nd->record_type);
-
- __cal_server_alarm_callback(buf_id, buf_time, buf_tick, buf_unit, buf_type);
- _cal_server_reminder_publish();
- l = g_list_next(l);
+ __cal_server_alarm_get_upcoming_specific_utime(utime, false, &l);
+ __cal_server_alarm_get_upcoming_nonspecific_event_utime(utime, false, &l);
+ __cal_server_alarm_get_upcoming_nonspecific_todo_utime(utime, false, &l);
+
+ __cal_server_alarm_get_upcoming_specific_localtime(datetime, false, &l);
+ __cal_server_alarm_get_upcoming_nonspecific_event_localtime(datetime, false, &l);
+ __cal_server_alarm_get_upcoming_nonspecific_todo_localtime(datetime, false, &l);
+
+ if (NULL == l) {
+ DBG("No alarm list");
+ return CALENDAR_ERROR_NONE;
}
- l = NULL;
- l = g_list_first(allday_list);
- if (NULL == l) DBG("allday list is NULL");
- while (l)
- {
- struct _allday_data_s *ad = (struct _allday_data_s *)l->data;
- snprintf(buf_id, sizeof(buf_id), "%d", ad->id);
- snprintf(buf_time, sizeof(buf_time), "%d", ad->alarm_datetime);
- snprintf(buf_tick, sizeof(buf_tick), "%d", ad->tick);
- snprintf(buf_unit, sizeof(buf_unit), "%d", ad->unit);
- snprintf(buf_type, sizeof(buf_type), "%d", ad->record_type);
+ l = g_list_sort(l, __cal_server_alarm_sort_cb);
+ g_list_foreach(l, (GFunc)__cal_server_alarm_print_cb, NULL);
+ __cal_server_alarm_register(l);
- __cal_server_alarm_callback(buf_id, buf_time, buf_tick, buf_unit, buf_type);
- _cal_server_reminder_publish();
+ // free list
+ l = g_list_first(l);
+ while(l) {
+ struct _alarm_data_s *ad = (struct _alarm_data_s *)l->data;
+ free(ad);
l = g_list_next(l);
}
- return 0;
+ g_list_free(l);
+ return CALENDAR_ERROR_NONE;
}
static int _alert_cb(alarm_id_t alarm_id, void *data)
{
- GList *normal_list = NULL;
- GList *allday_list = NULL;
+ ENTER();
+ GList *l = NULL;
- __cal_server_alarm_get_list_with_alarmmgr_id(alarm_id, &normal_list, &allday_list);
+ DBG("alarm_id (%ld)", alarm_id);
+ time_t tt_alert = 0;
+ __cal_server_alarm_get_alert_time(alarm_id, &tt_alert);
+ __cal_server_alarm_get_alert_list(tt_alert, &l);
__cal_server_alarm_unset_alerted_alarmmgr_id(alarm_id);
- __cal_server_alarm_noti_with_appsvc(alarm_id, normal_list, allday_list);
- __cal_server_alarm_noti_callback(alarm_id, normal_list, allday_list);
-
- if (normal_list)
- {
- g_list_free_full(normal_list, free);
- normal_list = NULL;
- }
- if (allday_list)
- {
- g_list_free_full(allday_list, free);
- allday_list = NULL;
- }
-
- __cal_server_alarm_register_with_alarmmgr(_cal_time_get_now());
+ __cal_server_alarm_noti_with_callback(l);
+ __cal_server_alarm_noti_with_control(l);
+ __cal_server_alarm_register_with_alarmmgr(tt_alert);
+ LEAVE();
return 0;
}
////////////////////////////////////////////////////////////////////
static void __cal_server_alarm_timechange_cb(keynode_t *node, void *data)
{
- time_t t;
+ ENTER();
+ int t = 0;
+ int ret;
+
if (node) {
t = vconf_keynode_get_int(node);
}
else
{
- vconf_get_int(VCONFKEY_SYSTEM_TIMECHANGE, (int *)&t);
+ ret = vconf_get_int(VCONFKEY_SYSTEM_TIMECHANGE, &t);
+ warn_if(0 < ret, "vconf_get_int() Failed");
}
- DBG("systme changed time(%ld)", t);
- __cal_server_alarm_register_with_alarmmgr((long long int)t);
+ if (t < 0)
+ {
+ __cal_server_alarm_register_with_alarmmgr(time(NULL));
+ }
+ else
+ {
+ DBG("system changed time(%ld)", t);
+ __cal_server_alarm_register_with_alarmmgr((time_t)t);
+ }
}
-int __cal_server_alarm_set_timechange(void)
+void __cal_server_alarm_set_timechange(void)
{
- int ret;
+ vconf_notify_key_changed(VCONFKEY_SYSTEM_TIME_CHANGED,
+ __cal_server_alarm_timechange_cb, NULL);
- ret = vconf_notify_key_changed(VCONFKEY_SYSTEM_TIMECHANGE,
+ vconf_notify_key_changed(VCONFKEY_TELEPHONY_NITZ_GMT,
+ __cal_server_alarm_timechange_cb, NULL);
+ vconf_notify_key_changed(VCONFKEY_TELEPHONY_NITZ_EVENT_GMT,
+ __cal_server_alarm_timechange_cb, NULL);
+ vconf_notify_key_changed(VCONFKEY_TELEPHONY_NITZ_ZONE,
__cal_server_alarm_timechange_cb, NULL);
- if (ret < 0)
- {
- ERR("vconf_ignore_key_changed() failed");
- return ret;
- }
- return CALENDAR_ERROR_NONE;
}
static void __changed_cb(const char* view_uri, void* data)
{
- __cal_server_alarm_register_with_alarmmgr(_cal_time_get_now());
+ ENTER();
+ __cal_server_alarm_register_with_alarmmgr(time(NULL));
}
static int __cal_server_alarm_set_inotify(calendar_db_changed_cb callback)
int _cal_server_alarm(void)
{
+ ENTER();
int ret;
__cal_server_alarm_set_timechange();
ret = alarmmgr_set_cb(_alert_cb, NULL);
retvm_if(ret < 0, ret, "alarmmgr_set_cb() failed");
- __cal_server_alarm_register_with_alarmmgr(_cal_time_get_now());
+ __cal_server_alarm_register_with_alarmmgr(time(NULL));
return CALENDAR_ERROR_NONE;
}
#include <glib.h>
#include <unistd.h> //sleep
-#include "calendar2.h"
+#include "calendar.h"
#include "cal_typedef.h"
#include "cal_internal.h"
#include "cal_server_calendar_delete.h"
typedef enum
{
- STEP_1, // create calendar_id_list
- STEP_2, // delete schedule_table <-- CAL_SERVER_CALENDAR_DELETE_COUNT
- // loop STEP_2
- STEP_3, // delete calendar_table
+ STEP_1, // create calendar_id_list
+ STEP_2, // delete schedule_table <-- CAL_SERVER_CALENDAR_DELETE_COUNT
+ // loop STEP_2
+ STEP_3, // delete calendar_table
} __calendar_delete_step_e;
typedef struct {
- GList *calendar_id_list;
- int current_calendar_id;
- __calendar_delete_step_e step;
+ GList *calendar_id_list;
+ int current_calendar_id;
+ __calendar_delete_step_e step;
} __calendar_delete_data_s;
GThread *__cal_server_calendar_delete_thread = NULL;
static bool __cal_server_calendar_delete_step(int ret, __calendar_delete_data_s* data)
{
- if (ret != CALENDAR_ERROR_NONE && ret != CALENDAR_ERROR_NO_DATA)
- {
- if(data->calendar_id_list)
- {
- g_list_free(data->calendar_id_list);
- }
- CAL_FREE(data);
- ERR("fail (%d)",ret);
-
- return false;
- }
- switch (data->step)
- {
- case STEP_1:
- if (ret == CALENDAR_ERROR_NO_DATA)
- {
- if(data->calendar_id_list)
- {
- g_list_free(data->calendar_id_list);
- }
- CAL_FREE(data);
- ERR("step_1 no_data");
-
- return false;
- }
- data->step = STEP_2;
- break;
- case STEP_2:
- if (ret == CALENDAR_ERROR_NO_DATA)
- {
- data->step = STEP_3;
- }
- break;
- case STEP_3:
- data->step = STEP_1;
- break;
- default:
- data->step = STEP_1;
- break;
- }
-
- // go next step
- return true;
+ if (ret != CALENDAR_ERROR_NONE && ret != CALENDAR_ERROR_NO_DATA)
+ {
+ if(data->calendar_id_list)
+ {
+ g_list_free(data->calendar_id_list);
+ }
+ CAL_FREE(data);
+ ERR("fail (%d)",ret);
+
+ return false;
+ }
+ switch (data->step)
+ {
+ case STEP_1:
+ if (ret == CALENDAR_ERROR_NO_DATA)
+ {
+ if(data->calendar_id_list)
+ {
+ g_list_free(data->calendar_id_list);
+ }
+ CAL_FREE(data);
+ ERR("step_1 no_data");
+
+ return false;
+ }
+ data->step = STEP_2;
+ break;
+ case STEP_2:
+ if (ret == CALENDAR_ERROR_NO_DATA)
+ {
+ data->step = STEP_3;
+ }
+ break;
+ case STEP_3:
+ data->step = STEP_1;
+ break;
+ default:
+ data->step = STEP_1;
+ break;
+ }
+
+ // go next step
+ return true;
}
static int __cal_server_calendar_delete_step1(__calendar_delete_data_s* data)
{
- char query[CAL_DB_SQL_MIN_LEN] = {0,};
- sqlite3_stmt *stmt = NULL;
- int count = 0;
-
- CAL_FN_CALL;
-
- if (data->calendar_id_list == NULL)
- {
- // get event_list
- snprintf(query, sizeof(query), "SELECT id FROM %s "
- "WHERE deleted = 1",
- CAL_TABLE_CALENDAR);
-
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- int id = 0;
- id = sqlite3_column_int(stmt, 0);
- data->calendar_id_list = g_list_append(data->calendar_id_list, GINT_TO_POINTER(id));
- }
- sqlite3_finalize(stmt);
- }
-
- count = g_list_length(data->calendar_id_list);
- if ( count <= 0)
- {
- return CALENDAR_ERROR_NO_DATA;
- }
-
- GList *cursor = g_list_first(data->calendar_id_list);
- if (cursor)
- {
- data->current_calendar_id = GPOINTER_TO_INT(cursor->data);
- data->calendar_id_list = g_list_remove(data->calendar_id_list, GINT_TO_POINTER(data->current_calendar_id));
-
- return CALENDAR_ERROR_NONE;
- }
- else
- {
- return CALENDAR_ERROR_NO_DATA;
- }
+ char query[CAL_DB_SQL_MIN_LEN] = {0,};
+ sqlite3_stmt *stmt = NULL;
+ int count = 0;
+
+ CAL_FN_CALL;
+
+ if (data->calendar_id_list == NULL)
+ {
+ // get event_list
+ snprintf(query, sizeof(query), "SELECT id FROM %s "
+ "WHERE deleted = 1",
+ CAL_TABLE_CALENDAR);
+
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt)
+ {
+ ERR("_cal_db_util_query_prepare() Failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ {
+ int id = 0;
+ id = sqlite3_column_int(stmt, 0);
+ data->calendar_id_list = g_list_append(data->calendar_id_list, GINT_TO_POINTER(id));
+ }
+ sqlite3_finalize(stmt);
+ }
+
+ count = g_list_length(data->calendar_id_list);
+ if ( count <= 0)
+ {
+ return CALENDAR_ERROR_NO_DATA;
+ }
+
+ GList *cursor = g_list_first(data->calendar_id_list);
+ if (cursor)
+ {
+ data->current_calendar_id = GPOINTER_TO_INT(cursor->data);
+ data->calendar_id_list = g_list_remove(data->calendar_id_list, GINT_TO_POINTER(data->current_calendar_id));
+
+ return CALENDAR_ERROR_NONE;
+ }
+ else
+ {
+ return CALENDAR_ERROR_NO_DATA;
+ }
}
static int __cal_server_calendar_delete_step2(__calendar_delete_data_s* data)
{
- int ret;
- char query[CAL_DB_SQL_MIN_LEN] = {0};
- cal_db_util_error_e dbret = CAL_DB_OK;
- GList *list = NULL;
- sqlite3_stmt *stmt = NULL;
- int count = 0;
-
- CAL_FN_CALL;
-
- // get event_list
- snprintf(query, sizeof(query), "SELECT id FROM %s "
- "WHERE calendar_id = %d LIMIT %d",
- CAL_TABLE_SCHEDULE,
- data->current_calendar_id, CAL_SERVER_CALENDAR_DELETE_COUNT);
-
- stmt = _cal_db_util_query_prepare(query);
- if (NULL == stmt)
- {
- ERR("_cal_db_util_query_prepare() Failed");
- return CALENDAR_ERROR_DB_FAILED;
- }
- while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
- {
- int id = 0;
- id = sqlite3_column_int(stmt, 0);
- list = g_list_append(list, GINT_TO_POINTER(id));
- }
-
- sqlite3_finalize(stmt);
- stmt = NULL;
-
- count = g_list_length(list);
- if ( count <= 0)
- {
- return CALENDAR_ERROR_NO_DATA;
- }
-
- ret = _cal_db_util_begin_trans();
- retvm_if( CALENDAR_ERROR_NONE != ret,CALENDAR_ERROR_DB_FAILED, "Db failed" );
-
- GList *cursor = g_list_first(list);
- while(cursor)
- {
- int id = GPOINTER_TO_INT(cursor->data);
- /* delete event table */
- snprintf(query, sizeof(query), "DELETE FROM %s "
- "WHERE id = %d",
- CAL_TABLE_SCHEDULE,
- id);
-
- dbret = _cal_db_util_query_exec(query);
- CAL_DBG("%s",query);
+ int ret = CALENDAR_ERROR_NONE;
+ char query[CAL_DB_SQL_MIN_LEN] = {0};
+ cal_db_util_error_e dbret = CAL_DB_OK;
+ GList *list = NULL;
+ sqlite3_stmt *stmt = NULL;
+ int count = 0;
+
+ CAL_FN_CALL;
+
+ ret = _cal_db_util_begin_trans();
+ if (CALENDAR_ERROR_NONE != ret)
+ {
+ ERR("_cal_db_util_begin_trans() failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ // get event_list
+ snprintf(query, sizeof(query), "SELECT id FROM %s "
+ "WHERE calendar_id = %d LIMIT %d",
+ CAL_TABLE_SCHEDULE,
+ data->current_calendar_id, CAL_SERVER_CALENDAR_DELETE_COUNT);
+
+ stmt = _cal_db_util_query_prepare(query);
+ if (NULL == stmt)
+ {
+ ERR("_cal_db_util_query_prepare() Failed");
+ _cal_db_util_end_trans(false);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ while(CAL_DB_ROW == _cal_db_util_stmt_step(stmt))
+ {
+ int id = 0;
+ id = sqlite3_column_int(stmt, 0);
+ list = g_list_append(list, GINT_TO_POINTER(id));
+ }
+
+ sqlite3_finalize(stmt);
+ stmt = NULL;
+
+ count = g_list_length(list);
+ if ( count <= 0)
+ {
+ _cal_db_util_end_trans(false);
+ return CALENDAR_ERROR_NO_DATA;
+ }
+
+ GList *cursor = g_list_first(list);
+ while(cursor)
+ {
+ int id = GPOINTER_TO_INT(cursor->data);
+ /* delete event table */
+ snprintf(query, sizeof(query), "DELETE FROM %s "
+ "WHERE id = %d",
+ CAL_TABLE_SCHEDULE,
+ id);
+
+ dbret = _cal_db_util_query_exec(query);
+ CAL_DBG("%s",query);
if (CAL_DB_OK != dbret)
- {
+ {
ERR("_cal_db_util_query_exec() failed (%d)", dbret);
- _cal_db_util_end_trans(false);
- g_list_free(list);
+ _cal_db_util_end_trans(false);
+ g_list_free(list);
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
+ _cal_db_util_end_trans(false);
return CALENDAR_ERROR_FILE_NO_SPACE;
default:
+ _cal_db_util_end_trans(false);
return CALENDAR_ERROR_DB_FAILED;
}
- }
- cursor = g_list_next(cursor);
- }
+ }
+ cursor = g_list_next(cursor);
+ }
- g_list_free(list);
+ g_list_free(list);
- _cal_db_util_end_trans(true);
+ _cal_db_util_end_trans(true);
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static int __cal_server_calendar_delete_step3(__calendar_delete_data_s* data)
{
- int ret;
- char query[CAL_DB_SQL_MIN_LEN] = {0};
- cal_db_util_error_e dbret = CAL_DB_OK;
-
- ret = _cal_db_util_begin_trans();
- retvm_if( CALENDAR_ERROR_NONE != ret,CALENDAR_ERROR_DB_FAILED, "Db failed" );
-
- CAL_FN_CALL;
-
- /* delete event table */
- snprintf(query, sizeof(query), "DELETE FROM %s "
- "WHERE id = %d",
- CAL_TABLE_CALENDAR,
- data->current_calendar_id);
-
- dbret = _cal_db_util_query_exec(query);
+ int ret = CALENDAR_ERROR_NONE;
+ char query[CAL_DB_SQL_MIN_LEN] = {0};
+ cal_db_util_error_e dbret = CAL_DB_OK;
+
+ ret = _cal_db_util_begin_trans();
+ if (CALENDAR_ERROR_NONE != ret)
+ {
+ ERR("_cal_db_util_begin_trans() failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ CAL_FN_CALL;
+
+ /* delete event table */
+ snprintf(query, sizeof(query), "DELETE FROM %s "
+ "WHERE id = %d",
+ CAL_TABLE_CALENDAR,
+ data->current_calendar_id);
+
+ dbret = _cal_db_util_query_exec(query);
if (CAL_DB_OK != dbret)
- {
+ {
ERR("_cal_db_util_query_exec() failed (%d)", dbret);
- _cal_db_util_end_trans(false);
+ _cal_db_util_end_trans(false);
switch (dbret)
{
case CAL_DB_ERROR_NO_SPACE:
+ _cal_db_util_end_trans(false);
return CALENDAR_ERROR_FILE_NO_SPACE;
default:
+ _cal_db_util_end_trans(false);
return CALENDAR_ERROR_DB_FAILED;
}
- }
+ }
- _cal_db_util_end_trans(true);
+ _cal_db_util_end_trans(true);
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
static bool __cal_server_calendar_run(__calendar_delete_data_s* data)
{
- int ret = CALENDAR_ERROR_NONE;
-
- CAL_FN_CALL;
-
- if(data == NULL)
- {
- ERR("data is NULL");
-
- return false;
- }
-
- switch (data->step)
- {
- case STEP_1:
- ret = __cal_server_calendar_delete_step1(data);
- break;
- case STEP_2:
- ret = __cal_server_calendar_delete_step2(data);
- break;
- case STEP_3:
- ret = __cal_server_calendar_delete_step3(data);
- break;
- default:
- ERR("invalid step");
- if(data->calendar_id_list)
- {
- g_list_free(data->calendar_id_list);
- }
- CAL_FREE(data);
-
- return false;
- }
-
- return __cal_server_calendar_delete_step(ret, data);
+ int ret = CALENDAR_ERROR_NONE;
+
+ CAL_FN_CALL;
+
+ if(data == NULL)
+ {
+ ERR("data is NULL");
+
+ return false;
+ }
+
+ switch (data->step)
+ {
+ case STEP_1:
+ ret = __cal_server_calendar_delete_step1(data);
+ break;
+ case STEP_2:
+ ret = __cal_server_calendar_delete_step2(data);
+ break;
+ case STEP_3:
+ ret = __cal_server_calendar_delete_step3(data);
+ break;
+ default:
+ ERR("invalid step");
+ if(data->calendar_id_list)
+ {
+ g_list_free(data->calendar_id_list);
+ }
+ CAL_FREE(data);
+
+ return false;
+ }
+
+ return __cal_server_calendar_delete_step(ret, data);
}
static gpointer __cal_server_calendar_main(gpointer user_data)
{
- __calendar_delete_data_s *callback_data = NULL;
- int ret = CALENDAR_ERROR_NONE;
- CAL_FN_CALL;
-
- while(1)
- {
- callback_data = calloc(1,sizeof(__calendar_delete_data_s));
-
- if (callback_data != NULL)
- {
- callback_data->step = STEP_1;
-
- // delete
- while(1)
- {
- ret = calendar_connect();
- if (CALENDAR_ERROR_NONE != ret)
- {
- break;
- }
- sleep(CAL_SERVER_CALENDAR_DELETE_STEP_TIME); // sleep 1 sec.
- if (__cal_server_calendar_run(callback_data) == false)
- {
- callback_data = NULL;
- CAL_DBG("end");
- break;
- }
- }
- calendar_disconnect();
- CAL_FREE(callback_data);
- }
- else
- {
- ERR("calloc fail");
- }
-
- g_mutex_lock(&__cal_server_calendar_delete_mutex);
- CAL_DBG("wait");
- g_cond_wait(&__cal_server_calendar_delete_cond, &__cal_server_calendar_delete_mutex);
- g_mutex_unlock(&__cal_server_calendar_delete_mutex);
- }
-
- return NULL;
+ __calendar_delete_data_s *callback_data = NULL;
+ int ret = CALENDAR_ERROR_NONE;
+ CAL_FN_CALL;
+
+ while(1)
+ {
+ callback_data = calloc(1,sizeof(__calendar_delete_data_s));
+
+ if (callback_data != NULL)
+ {
+ callback_data->step = STEP_1;
+
+ // delete
+ while(1)
+ {
+ ret = calendar_connect();
+ if (CALENDAR_ERROR_NONE != ret)
+ {
+ break;
+ }
+ sleep(CAL_SERVER_CALENDAR_DELETE_STEP_TIME); // sleep 1 sec.
+ if (__cal_server_calendar_run(callback_data) == false)
+ {
+ callback_data = NULL;
+ CAL_DBG("end");
+ break;
+ }
+ }
+ calendar_disconnect();
+ CAL_FREE(callback_data);
+ }
+ else
+ {
+ ERR("calloc fail");
+ }
+
+ g_mutex_lock(&__cal_server_calendar_delete_mutex);
+ CAL_DBG("wait");
+ g_cond_wait(&__cal_server_calendar_delete_cond, &__cal_server_calendar_delete_mutex);
+ g_mutex_unlock(&__cal_server_calendar_delete_mutex);
+ }
+
+ return NULL;
}
void _cal_server_calendar_delete_start(void)
{
- CAL_FN_CALL;
+ CAL_FN_CALL;
- if (__cal_server_calendar_delete_thread == NULL)
- {
- g_mutex_init(&__cal_server_calendar_delete_mutex);
- g_cond_init(&__cal_server_calendar_delete_cond);
- __cal_server_calendar_delete_thread = g_thread_new(CAL_SERVER_CALENDAR_DELETE_THREAD_NAME,__cal_server_calendar_main,NULL);
- }
+ if (__cal_server_calendar_delete_thread == NULL)
+ {
+ g_mutex_init(&__cal_server_calendar_delete_mutex);
+ g_cond_init(&__cal_server_calendar_delete_cond);
+ __cal_server_calendar_delete_thread = g_thread_new(CAL_SERVER_CALENDAR_DELETE_THREAD_NAME,__cal_server_calendar_main,NULL);
+ }
- // don't use mutex.
- g_cond_signal(&__cal_server_calendar_delete_cond);
+ // don't use mutex.
+ g_cond_signal(&__cal_server_calendar_delete_cond);
- return ;
+ return ;
}
--- /dev/null
+/*
+ * Calendar Service
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdlib.h>
+#include <sys/time.h> // check time
+#include <contacts.h>
+#include <unistd.h> // usleep
+
+#include "calendar.h"
+#include "cal_internal.h" // DBG
+#include "cal_typedef.h"
+#include "cal_db.h"
+#include "cal_db_util.h"
+#include "cal_time.h"
+#include "cal_server_contacts.h"
+#include "cal_access_control.h"
+
+#define CAL_SERVER_CONTACTS_SYNC_THREAD_NAME "cal_server_contacts_sync"
+
+static struct timeval stv; // check time
+static struct timeval etv; // check time
+
+GThread *__cal_server_contacts_sync_thread = NULL;
+GCond __cal_server_contacts_sync_cond;
+GMutex __cal_server_contacts_sync_mutex;
+
+static int __cal_server_contacts_get_contacts_db_version(int *version)
+{
+ int ver = 0;
+ int ret;
+ const char *query = "SELECT contacts_ver FROM "CAL_TABLE_VERSION;
+
+ DBG("query[%s]", query);
+ ret = _cal_db_util_query_get_first_int_result(query, NULL, &ver);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("_cal_db_util_query_get_first_int_result() failed");
+ return ret;
+ }
+
+ if (version) *version = ver;
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_server_contacts_set_contacts_db_version(int version)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ cal_db_util_error_e dbret = CAL_DB_OK;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+
+ ret = _cal_db_util_begin_trans();
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("_cal_db_util_begin_trans() failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ snprintf(query, sizeof(query), "UPDATE %s SET contacts_ver = %d",
+ CAL_TABLE_VERSION, version);
+ dbret = _cal_db_util_query_exec(query);
+ if (CAL_DB_OK != dbret) {
+ ERR("_cal_db_util_query_exec() failed (%d)", dbret);
+ switch (dbret) {
+ case CAL_DB_ERROR_NO_SPACE:
+ _cal_db_util_end_trans(false);
+ return CALENDAR_ERROR_FILE_NO_SPACE;
+ default:
+ _cal_db_util_end_trans(false);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ }
+ _cal_db_util_end_trans(true);
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_server_contacts_set_new_event(int id, char *label, int date, char *type, int account_id, calendar_record_h *out_event)
+{
+ int ret;
+ char buf[4] = {0};
+ calendar_record_h event = NULL;
+ calendar_time_s st = {0};
+ calendar_time_s et = {0};
+
+ *out_event = NULL;
+
+ DBG("date(%d)", date);
+ st.type = CALENDAR_TIME_LOCALTIME;
+ st.time.date.year = date / 10000;
+ st.time.date.month = (date % 10000) / 100;
+ st.time.date.mday = date % 100;
+ st.time.date.hour = 0;
+ st.time.date.minute = 0;
+ st.time.date.second = 0;
+
+ et.type = CALENDAR_TIME_LOCALTIME;
+ _cal_time_get_next_date(&st, &et);
+
+ snprintf(buf, sizeof(buf), "%d", st.time.date.mday);
+
+ ret = calendar_record_create(_calendar_event._uri, &event);
+ retvm_if(CALENDAR_ERROR_NONE != ret, ret, "calendar_record_create() failed");
+ ret = calendar_record_set_str(event, _calendar_event.summary, label);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("calendar_record_set_str() failed:summary");
+ calendar_record_destroy(event, true);
+ return ret;
+ }
+
+ ret = calendar_record_set_int(event, _calendar_event.calendar_book_id, DEFAULT_BIRTHDAY_CALENDAR_BOOK_ID);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("calendar_record_set_int() failed:calendar_book_id");
+ calendar_record_destroy(event, true);
+ return ret;
+ }
+ ret = calendar_record_set_caltime(event, _calendar_event.start_time, st);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("calendar_record_set_caltime() failed:start_time");
+ calendar_record_destroy(event, true);
+ return ret;
+ }
+ ret = calendar_record_set_caltime(event, _calendar_event.end_time, et);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("calendar_record_set_caltime() failed:end_time");
+ calendar_record_destroy(event, true);
+ return ret;
+ }
+ ret = calendar_record_set_int(event, _calendar_event.person_id, id);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("calendar_record_set_int() failed:person_id");
+ calendar_record_destroy(event, true);
+ return ret;
+ }
+ ret = calendar_record_set_str(event, _calendar_event.sync_data1, type);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("calendar_record_set_str() failed:sync_data1");
+ calendar_record_destroy(event, true);
+ return ret;
+ }
+ ret = calendar_record_set_int(event, _calendar_event.freq, CALENDAR_RECURRENCE_YEARLY);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("calendar_record_set_int() failed:freq");
+ calendar_record_destroy(event, true);
+ return ret;
+ }
+ ret = calendar_record_set_int(event, _calendar_event.interval, 1);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("calendar_record_set_int() failed:interval");
+ calendar_record_destroy(event, true);
+ return ret;
+ }
+ ret = calendar_record_set_str(event, _calendar_event.bymonthday, buf);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("calendar_record_set_str() failed:bymonthday");
+ calendar_record_destroy(event, true);
+ return ret;
+ }
+ ret = calendar_record_set_int(event, _calendar_event.range_type, CALENDAR_RANGE_NONE);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("calendar_record_set_int() failed:interval");
+ calendar_record_destroy(event, true);
+ return ret;
+ }
+
+ if (account_id > 0) {
+ snprintf(buf, sizeof(buf), "%d", account_id);
+ ret = calendar_record_set_str(event, _calendar_event.sync_data4, buf);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("calendar_record_set_str() failed:interval");
+ calendar_record_destroy(event, true);
+ return ret;
+ }
+ }
+
+ *out_event = event;
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_server_contacts_find_delete_event(int id, int **delete_ids, int *delete_count)
+{
+ int ret;
+ int event_id;
+ int count;
+ calendar_list_h list = NULL;
+ calendar_record_h event = NULL;
+ calendar_query_h query = NULL;
+ calendar_filter_h filter = NULL;
+
+ ret = calendar_query_create(_calendar_event._uri, &query);
+ retvm_if(CALENDAR_ERROR_NONE != ret, ret, "calendar_query_create() failed");
+ ret = calendar_filter_create(_calendar_event._uri, &filter);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("calendar_filter_create() failed");
+ calendar_query_destroy(query);
+ return ret;
+ }
+ ret = calendar_filter_add_int(filter, _calendar_event.person_id,
+ CALENDAR_MATCH_EQUAL, id);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("Failed to add _calendar_event.person_id");
+ calendar_filter_destroy(filter);
+ calendar_query_destroy(query);
+ return ret;
+ }
+ ret = calendar_query_set_filter(query, filter);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("calendar_query_set_filter() failed");
+ calendar_filter_destroy(filter);
+ calendar_query_destroy(query);
+ return ret;
+ }
+ ret = calendar_db_get_records_with_query(query, 0, 0, &list);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("calendar_db_get_records_with_query() failed");
+ calendar_list_destroy(list, true);
+ calendar_filter_destroy(filter);
+ calendar_query_destroy(query);
+ return ret;
+ }
+ ret = calendar_list_get_count(list, &count);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("calendar_list_get_count() failed");
+ calendar_list_destroy(list, true);
+ calendar_filter_destroy(filter);
+ calendar_query_destroy(query);
+ return ret;
+ }
+ DBG("event count(%d)\n", count);
+
+ calendar_list_first(list);
+ *delete_count = 0;
+ *delete_ids = (int*)calloc(count, sizeof(int));
+ do {
+ if (calendar_list_get_current_record_p(list, &event) == CALENDAR_ERROR_NONE) {
+ if (event == NULL) {
+ DBG("No event\n");
+ break;
+ }
+ calendar_record_get_int(event, _calendar_event.id, &event_id);
+ (*delete_ids)[*delete_count] = event_id;
+ (*delete_count)++;
+ DBG("delete event_id(%d)\n", event_id);
+ }
+ } while (calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+
+ calendar_list_destroy(list, true);
+ calendar_filter_destroy(filter);
+ calendar_query_destroy(query);
+
+ return CALENDAR_ERROR_NONE;
+}
+
+static int __cal_server_contacts_make_insert_event(int id, calendar_list_h *out_list)
+{
+ int ret;
+ int index;
+ int type;
+ int date;
+ int address_book_id = 0;
+ int account_id = 0;
+ contacts_record_h ctevent = NULL;
+ contacts_record_h address_book = NULL;
+ contacts_record_h contact = NULL;
+ calendar_record_h out_event = NULL;
+
+ contacts_db_get_record(_contacts_contact._uri, id, &contact);
+
+ ret = contacts_record_get_int(contact, _contacts_contact.address_book_id, &address_book_id);
+ if (ret != CONTACTS_ERROR_NONE) {
+ DBG("get fail");
+ }
+ else if (address_book_id > 0) { // default phone addressbook is 0
+ if (contacts_db_get_record(_contacts_address_book._uri, address_book_id, &address_book) != CONTACTS_ERROR_NONE) {
+ DBG("contacts_db_get_record(%d)", address_book_id);
+ }
+ else {
+ contacts_record_get_int(address_book, _contacts_address_book.account_id, &account_id);
+ DBG("account_id[%d]",account_id);
+ contacts_record_destroy(address_book, true);
+ }
+ }
+
+ index = 0;
+ while (CONTACTS_ERROR_NONE == contacts_record_get_child_record_at_p(contact,
+ _contacts_contact.event, index++, &ctevent)) {
+ ret = contacts_record_get_int(ctevent, _contacts_event.type, &type);
+ if (CONTACTS_ERROR_NONE != ret) {
+ ERR("Failed to get _contacts_event.type");
+ break;
+ }
+ ret = contacts_record_get_int(ctevent, _contacts_event.date, &date);
+ if (CONTACTS_ERROR_NONE != ret) {
+ ERR("Failed to get _contacts_event.date");
+ break;
+ }
+
+ bool is_proper_type = true;
+ char *caltype = NULL;
+ switch (type) {
+ case CONTACTS_EVENT_TYPE_BIRTH:
+ caltype = "birthday";
+ break;
+
+ case CONTACTS_EVENT_TYPE_ANNIVERSARY:
+ caltype = "anniversary";
+ break;
+
+ case CONTACTS_EVENT_TYPE_OTHER:
+ caltype = "other";
+ break;
+
+ case CONTACTS_EVENT_TYPE_CUSTOM:
+ ret = contacts_record_get_str_p(ctevent, _contacts_event.label, &caltype);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("Failed to get _contacts_event.label");
+ break;
+ }
+ break;
+
+ default:
+ DBG("Couldn't find type(%d)", type);
+ is_proper_type = false;
+ break;
+ }
+
+ if (false == is_proper_type)
+ continue;
+
+ char *display = NULL;
+ ret = contacts_record_get_str_p(contact, _contacts_contact.display_name, &display);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("Failed to get _contacts_contact.display_name");
+ break;
+ }
+ SEC_DBG("id(%d) display[%s] type(%d)", id, display, type);
+
+ __cal_server_contacts_set_new_event(id, display, date, caltype, account_id, &out_event);
+ calendar_list_add(*out_list, out_event);
+ }
+
+ contacts_record_destroy(contact, true);
+ contact = NULL;
+ return CALENDAR_ERROR_NONE;
+}
+
+static void __contacts_changed_cb(const char* view_uri, void *user_data)
+{
+ _cal_server_contacts_sync_start();
+}
+
+static void __cal_server_contacts_append_delete_ids(int **delete_ids, int *size, int *delete_count, int *del_ids, int dcount)
+{
+ if (*size < *delete_count + dcount) {
+ do {
+ (*size) = (*size) * 2;
+ } while(*size < *delete_count + dcount);
+ *delete_ids = realloc(*delete_ids, *size * sizeof(int));
+ }
+
+ int i=0;
+ for(;i<dcount;i++) {
+ (*delete_ids)[*delete_count] = del_ids[i];
+ (*delete_count)++;
+ }
+}
+
+#define BULK_MAX_COUNT 100
+#define SYNC_USLEEP 500
+
+static int __cal_server_contacts_sync()
+{
+ int ret;
+ int db_ver = -1;
+ int latest_ver = -1;
+ int status;
+ int id;
+ int count = 0;
+ contacts_list_h list = NULL;
+ contacts_record_h updated = NULL;
+
+ calendar_list_h insert_list = NULL;
+
+ gettimeofday(&stv, NULL); // check time
+
+ ret = __cal_server_contacts_get_contacts_db_version(&db_ver);
+ if (ret != CALENDAR_ERROR_NONE)
+ return false;
+
+ DBG("contacts db version(%d)", db_ver);
+
+ ret = contacts_db_get_changes_by_version(_contacts_contact_updated_info._uri,
+ -1, db_ver, &list, &latest_ver);
+ if (CONTACTS_ERROR_NONE != ret) {
+ ERR("contacts_db_get_changes_by_version() failed");
+ contacts_list_destroy(list, true);
+ return false;
+ }
+
+ if (list == NULL) {
+ DBG("list is NULL");
+ return false;
+ }
+ DBG("get changes and get the latest contacts version(%d)\n", latest_ver);
+
+ ret = contacts_list_get_count(list, &count);
+ DBG("contacts count(%d)", count);
+ if (count == 0) {
+ if (db_ver != latest_ver) {
+ __cal_server_contacts_set_contacts_db_version(latest_ver);
+ DBG("set latest ver(%d)", latest_ver);
+ }
+ return false;
+ }
+
+ int size = 100;
+ int *delete_ids = calloc(size, sizeof(int));
+ int delete_count = 0;
+
+ calendar_list_create(&insert_list);
+
+ while (CONTACTS_ERROR_NONE == ret) {
+ int *del_ids = NULL;
+ int dcount = 0;
+ contacts_list_get_current_record_p(list, &updated);
+ contacts_record_get_int(updated, _contacts_contact_updated_info.contact_id, &id);
+ contacts_record_get_int(updated, _contacts_contact_updated_info.type, &status);
+
+ switch (status) {
+ case CONTACTS_CHANGE_INSERTED:
+ __cal_server_contacts_make_insert_event(id, &insert_list);
+ break;
+
+ case CONTACTS_CHANGE_UPDATED:
+ __cal_server_contacts_find_delete_event(id, &del_ids, &dcount);
+ __cal_server_contacts_append_delete_ids(&delete_ids, &size, &delete_count, del_ids, dcount);
+ free(del_ids);
+ __cal_server_contacts_make_insert_event(id, &insert_list);
+ break;
+
+ case CONTACTS_CHANGE_DELETED:
+ __cal_server_contacts_find_delete_event(id, &del_ids, &dcount);
+ __cal_server_contacts_append_delete_ids(&delete_ids, &size, &delete_count, del_ids, dcount);
+ free(del_ids);
+ break;
+
+ default:
+ ERR("Not valid");
+ break;
+ }
+ ret = contacts_list_next(list);
+ }
+
+ // delete events
+ int index = 0;
+ int remain_count = delete_count;
+ while (remain_count > 0) {
+ int ids[BULK_MAX_COUNT] = {0};
+ int i;
+ for (i=0;i<BULK_MAX_COUNT && index<delete_count;i++) {
+ ids[i] = delete_ids[index];
+ remain_count--;
+ index++;
+ }
+ DBG("delete record : count(%d)", index);
+ calendar_db_delete_records(_calendar_event._uri, ids, i);
+ usleep(SYNC_USLEEP);
+ }
+ free(delete_ids);
+
+ // insert events
+ int insert_count = 0;
+ calendar_list_get_count(insert_list, &insert_count);
+ while (insert_count > BULK_MAX_COUNT) {
+ calendar_list_h temp = NULL;
+ calendar_list_create(&temp);
+ int i;
+ for (i=0;i<BULK_MAX_COUNT;i++) {
+ calendar_record_h temp_record = NULL;
+ calendar_list_first(insert_list);
+ calendar_list_get_current_record_p(insert_list, &temp_record);
+ calendar_list_remove(insert_list, temp_record);
+ calendar_list_add(temp, temp_record);
+ insert_count--;
+ }
+ calendar_db_insert_records(temp, NULL, NULL);
+ calendar_list_destroy(temp, true);
+ calendar_list_get_count(insert_list, &insert_count);
+ usleep(SYNC_USLEEP);
+ }
+ if (insert_count > 0) {
+ DBG("insert record : count(%d)", insert_count);
+ calendar_db_insert_records(insert_list, NULL, NULL);
+ usleep(SYNC_USLEEP);
+ }
+ calendar_list_destroy(insert_list, true);
+
+ contacts_list_destroy(list, true);
+ __cal_server_contacts_set_contacts_db_version(latest_ver);
+ DBG("set latest ver(%d)", latest_ver);
+
+ int diff;
+ gettimeofday(&etv, NULL);
+ diff = ((int)etv.tv_sec *1000 + (int)etv.tv_usec/1000)
+ -((int)stv.tv_sec *1000 + (int)stv.tv_usec/1000);
+ DBG(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); // time check
+ DBG("diff %ld(%d.%d)",diff, diff/1000, diff%1000); // time check
+
+ return true;
+}
+
+int _cal_server_contacts(void)
+{
+ int ret;
+
+ ret = contacts_db_add_changed_cb(_contacts_event._uri, __contacts_changed_cb, NULL);
+ retvm_if(CONTACTS_ERROR_NONE != ret, ret, "contacts_db_add_changed_cb() failed");
+
+ return CALENDAR_ERROR_NONE;
+}
+
+void _cal_server_contacts_delete(int account_id)
+{
+ int ret;
+ int event_id;
+ int count;
+ calendar_list_h list = NULL;
+ calendar_record_h event = NULL;
+ calendar_query_h query = NULL;
+ calendar_filter_h filter = NULL;
+ char buf[4];
+ int *record_id_array = NULL;
+ int i = 0;
+
+ snprintf(buf, sizeof(buf), "%d", account_id);
+
+ ret = calendar_query_create(_calendar_event._uri, &query);
+ retm_if(CALENDAR_ERROR_NONE != ret, "calendar_query_create() failed");
+ ret = calendar_filter_create(_calendar_event._uri, &filter);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("calendar_filter_create() failed");
+ calendar_query_destroy(query);
+ return ;
+ }
+ ret = calendar_filter_add_str(filter, _calendar_event.sync_data4,
+ CALENDAR_MATCH_EXACTLY, buf);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("Failed to add _calendar_event.person_id");
+ calendar_filter_destroy(filter);
+ calendar_query_destroy(query);
+ return ;
+ }
+ ret = calendar_filter_add_operator(filter, CALENDAR_FILTER_OPERATOR_AND);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("Failed to add _calendar_event.person_id");
+ calendar_filter_destroy(filter);
+ calendar_query_destroy(query);
+ return ;
+ }
+ ret = calendar_filter_add_int(filter, _calendar_event.calendar_book_id,
+ CALENDAR_MATCH_EQUAL,DEFAULT_BIRTHDAY_CALENDAR_BOOK_ID);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("Failed to add _calendar_event.person_id");
+ calendar_filter_destroy(filter);
+ calendar_query_destroy(query);
+ return ;
+ }
+ ret = calendar_query_set_filter(query, filter);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("calendar_query_set_filter() failed");
+ calendar_filter_destroy(filter);
+ calendar_query_destroy(query);
+ return ;
+ }
+ unsigned int projection = _calendar_event.id;
+ ret = calendar_query_set_projection(query, &projection ,1);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("calendar_query_set_projection() failed");
+ calendar_filter_destroy(filter);
+ calendar_query_destroy(query);
+ return ;
+ }
+
+ ret = calendar_db_get_records_with_query(query, 0, 0, &list);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("calendar_db_get_records_with_query() failed");
+ calendar_list_destroy(list, true);
+ calendar_filter_destroy(filter);
+ calendar_query_destroy(query);
+ return ;
+ }
+ ret = calendar_list_get_count(list, &count);
+ if (CALENDAR_ERROR_NONE != ret) {
+ ERR("calendar_list_get_count() failed");
+ calendar_list_destroy(list, true);
+ calendar_filter_destroy(filter);
+ calendar_query_destroy(query);
+ return ;
+ }
+ DBG("event count(%d)\n", count);
+
+ if (count > 0) {
+ record_id_array = (int *)malloc(count*sizeof(int));
+ calendar_list_first(list);
+ do {
+ if (calendar_list_get_current_record_p(list, &event) == CALENDAR_ERROR_NONE) {
+ if (event == NULL) {
+ DBG("No event\n");
+ break;
+ }
+ calendar_record_get_int(event, _calendar_event.id, &event_id);
+ DBG("delete event_id(%d)\n", event_id);
+ record_id_array[i] = event_id;
+ i++;
+ }
+ } while (calendar_list_next(list) != CALENDAR_ERROR_NO_DATA);
+
+ // delete
+ ret = calendar_db_delete_records(_calendar_event._uri, record_id_array, i);
+ if (ret != CALENDAR_ERROR_NONE)
+ DBG("calendar_db_delete_records fail");
+ free(record_id_array);
+ }
+ calendar_list_destroy(list, true);
+ calendar_filter_destroy(filter);
+ calendar_query_destroy(query);
+
+ return;
+}
+
+static gpointer __cal_server_contacts_sync_main(gpointer user_data)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ CAL_FN_CALL;
+
+ while(1) {
+ ret = calendar_connect();
+ if (CALENDAR_ERROR_NONE != ret)
+ break;
+ _cal_access_control_set_client_info("calendar-service", NULL);
+
+ while(1) {
+ if (__cal_server_contacts_sync() == false) {
+ CAL_DBG("end");
+ break;
+ }
+ }
+ _cal_access_control_unset_client_info();
+
+ calendar_disconnect();
+
+ g_mutex_lock(&__cal_server_contacts_sync_mutex);
+ CAL_DBG("wait");
+ g_cond_wait(&__cal_server_contacts_sync_cond, &__cal_server_contacts_sync_mutex);
+ g_mutex_unlock(&__cal_server_contacts_sync_mutex);
+ }
+
+ return NULL;
+}
+
+void _cal_server_contacts_sync_start(void)
+{
+ CAL_FN_CALL;
+
+ if (__cal_server_contacts_sync_thread == NULL) {
+ g_mutex_init(&__cal_server_contacts_sync_mutex);
+ g_cond_init(&__cal_server_contacts_sync_cond);
+ __cal_server_contacts_sync_thread = g_thread_new(CAL_SERVER_CONTACTS_SYNC_THREAD_NAME, __cal_server_contacts_sync_main,NULL);
+ }
+
+ // don't use mutex.
+ g_cond_signal(&__cal_server_contacts_sync_cond);
+
+ return;
+}
+
--- /dev/null
+/*
+ * Calendar Service
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __CAL_SERVER_CONTACTS_H__
+#define __CAL_SERVER_CONTACTS_H__
+
+int _cal_server_contacts(void);
+void _cal_server_contacts_delete(int account_id);
+void _cal_server_contacts_sync_start(void);
+
+#endif //__CAL_SERVER_CONTACTS_H__
*/
#include <stdlib.h>
+#include <malloc.h> // malloc_trim
+#include <security-server.h>
#include "calendar_service.h"
#include "calendar_db.h"
#include "calendar_query.h"
#include "calendar_vcalendar.h"
-#include "calendar_reminder.h"
#include "cal_typedef.h"
#include "cal_db.h"
#include "cal_ipc_marshal.h"
#include "cal_internal.h"
#include "cal_server_ipc.h"
+#include "cal_access_control.h"
void _cal_server_ipc_connect(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
{
- int ret = CALENDAR_ERROR_NONE;
-
- ret = calendar_connect();
-
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- return;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- return;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
- return;
+ int ret = CALENDAR_ERROR_NONE;
+ char *smack_label = NULL;
+ char *cookie = NULL;
+
+ if (indata)
+ {
+ int cookie_size = 0;
+ char *buf = NULL;
+ gsize buf_len;
+ // Access control : get cookie from indata
+ ret = _cal_ipc_unmarshal_int(indata, &cookie_size);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_int fail");
+ goto ERROR_RETURN;
+ }
+
+ if (cookie_size <= 0)
+ {
+ ERR("cookie size is %d", cookie_size);
+ ret = CALENDAR_ERROR_IPC;
+ goto ERROR_RETURN;
+ }
+
+ ret = _cal_ipc_unmarshal_char(indata, &buf);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_char fail");
+ goto ERROR_RETURN;
+ }
+ cookie = (char*)g_base64_decode((const gchar*)buf, &buf_len);
+ CAL_FREE(buf);
+ smack_label = security_server_get_smacklabel_cookie(cookie);
+ if (NULL == smack_label)
+ {
+ ERR("security_server_get_smacklabel_cookie fail");
+ ret = CALENDAR_ERROR_SYSTEM;
+ CAL_FREE(cookie);
+ goto ERROR_RETURN;
+ }
+ }
+ else
+ {
+ ERR("There is no indata fail");
+ ret = CALENDAR_ERROR_SYSTEM;
+ goto ERROR_RETURN;
+ }
+
+ ret = calendar_connect();
+ if (ret == CALENDAR_ERROR_NONE) {
+ _cal_access_control_set_client_info(smack_label, cookie);
+ }
+
+ERROR_RETURN:
+ if (outdata) {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata) {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ }
+ else {
+ ERR("outdata is NULL");
+ }
+
+DATA_FREE:
+ CAL_FREE(cookie);
+ CAL_FREE(smack_label);
+ return;
}
void _cal_server_ipc_disconnect(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
{
- int ret = CALENDAR_ERROR_NONE;
-
- ret = calendar_disconnect();
-
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- return;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- return;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
- return;
+ int ret = CALENDAR_ERROR_NONE;
+
+ ret = calendar_disconnect();
+
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ return;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ return;
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
+ return;
+}
+
+void _cal_server_ipc_check_permission(pims_ipc_h ipc, pims_ipc_data_h indata,
+ pims_ipc_data_h *outdata, void *userdata)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ int permission;
+ bool result;
+
+ if (NULL == indata) {
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ ERR("check permission fail.");
+ goto ERROR_RETURN;
+ }
+
+ ret = _cal_ipc_unmarshal_int(indata, &permission);
+ if (ret != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_unmarshal_int fail");
+ goto ERROR_RETURN;
+ }
+
+ result = _cal_access_control_have_permission(permission);
+
+ERROR_RETURN:
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata) {
+ ERR("pims_ipc_data_create fail");
+ return;
+ }
+
+ if (pims_ipc_data_put(*outdata, (void*)&ret, sizeof(int)) != 0) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail (return value)");
+ return;
+ }
+ if (ret == CALENDAR_ERROR_NONE) {
+ if (pims_ipc_data_put(*outdata, (void*)&result, sizeof(bool)) != 0) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ return;
+ }
+ }
}
-// calendar_db.h
void _cal_server_ipc_db_insert_record(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
{
- int ret = CALENDAR_ERROR_NONE;
- calendar_record_h record = NULL;
- int id = 0;
-
- if (indata)
- {
- ret = _cal_ipc_unmarshal_record(indata,&record);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_record fail");
- record = NULL;
- goto ERROR_RETURN;
- }
- }
- else
- {
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- ERR("_cal_server_ipc_db_insert_record fail");
- goto ERROR_RETURN;
- }
-
- ret = calendar_db_insert_record(record, &id);
-
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- if (ret == CALENDAR_ERROR_NONE)
- {
- int transaction_ver = _cal_db_util_get_transaction_ver();
- if (_cal_ipc_marshal_int(transaction_ver,*outdata) != CALENDAR_ERROR_NONE)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("_cal_ipc_marshal fail");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- goto ERROR_RETURN;
- }
- if (_cal_ipc_marshal_int(id,*outdata) != CALENDAR_ERROR_NONE)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("_cal_ipc_marshal fail");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- goto ERROR_RETURN;
- }
-/*
- ret = _cal_ipc_marshal_record_get_primary_id(record, &property_id, &id);
-
- if (ret == CALENDAR_ERROR_NONE)
- {
- if (pims_ipc_data_put(*outdata,(void*)&property_id,sizeof(unsigned int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- ERR("_cal_ipc_marshal fail");
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- goto ERROR_RETURN;
- }
- if (_cal_ipc_marshal_int(id,*outdata) != CALENDAR_ERROR_NONE)
- {
- pims_ipc_data_destroy(*outdata);
- ERR("_cal_ipc_marshal fail");
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- goto ERROR_RETURN;
- }
- }
- else
- {
- pims_ipc_data_destroy(*outdata);
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- goto ERROR_RETURN;
- }
-*/
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
- goto DATA_FREE;
+ int ret = CALENDAR_ERROR_NONE;
+ calendar_record_h record = NULL;
+ int id = 0;
+
+ if (indata)
+ {
+ ret = _cal_ipc_unmarshal_record(indata,&record);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_record fail");
+ record = NULL;
+ goto ERROR_RETURN;
+ }
+ }
+ else
+ {
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ ERR("_cal_server_ipc_db_insert_record fail");
+ goto ERROR_RETURN;
+ }
+
+ ret = calendar_db_insert_record(record, &id);
+
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ int transaction_ver = _cal_db_util_get_transaction_ver();
+ if (_cal_ipc_marshal_int(transaction_ver,*outdata) != CALENDAR_ERROR_NONE)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("_cal_ipc_marshal fail");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ goto ERROR_RETURN;
+ }
+ if (_cal_ipc_marshal_int(id,*outdata) != CALENDAR_ERROR_NONE)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("_cal_ipc_marshal fail");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ goto ERROR_RETURN;
+ }
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
+ goto DATA_FREE;
ERROR_RETURN:
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
DATA_FREE:
- if (record)
- {
- calendar_record_destroy(record,true);
- }
- return;
+ if (record)
+ {
+ calendar_record_destroy(record,true);
+ }
+ return;
}
void _cal_server_ipc_db_get_record(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
{
- int ret = CALENDAR_ERROR_NONE;
- char* view_uri = NULL;
- int id = 0;
- calendar_record_h record = NULL;
-
- if (indata)
- {
- ret = _cal_ipc_unmarshal_char(indata,&view_uri);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_char fail");
- goto ERROR_RETURN;
- }
- ret = _cal_ipc_unmarshal_int(indata,&id);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_int fail");
- goto ERROR_RETURN;
- }
- }
- else
- {
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- ERR("_cal_server_ipc_db_insert_record fail");
- goto ERROR_RETURN;
- }
-
- ret = calendar_db_get_record(view_uri,id,&record);
+ int ret = CALENDAR_ERROR_NONE;
+ char* view_uri = NULL;
+ int id = 0;
+ calendar_record_h record = NULL;
+
+ if (indata)
+ {
+ ret = _cal_ipc_unmarshal_char(indata,&view_uri);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_char fail");
+ goto ERROR_RETURN;
+ }
+ ret = _cal_ipc_unmarshal_int(indata,&id);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_int fail");
+ goto ERROR_RETURN;
+ }
+ }
+ else
+ {
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ ERR("_cal_server_ipc_db_insert_record fail");
+ goto ERROR_RETURN;
+ }
+
+ ret = calendar_db_get_record(view_uri,id,&record);
ERROR_RETURN:
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- if (_cal_ipc_marshal_record(record, *outdata) != CALENDAR_ERROR_NONE)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("_cal_ipc_marshal_record fail");
- goto DATA_FREE;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ if (ret == CALENDAR_ERROR_NONE) {
+ if (_cal_ipc_marshal_record(record, *outdata) != CALENDAR_ERROR_NONE) {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("_cal_ipc_marshal_record fail");
+ goto DATA_FREE;
+ }
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
DATA_FREE:
- if (record)
- {
- calendar_record_destroy(record,true);
- }
- CAL_FREE(view_uri);
- return;
+ if (record)
+ {
+ calendar_record_destroy(record,true);
+ }
+ CAL_FREE(view_uri);
+ return;
}
void _cal_server_ipc_db_update_record(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
{
- int ret = CALENDAR_ERROR_NONE;
- calendar_record_h record = NULL;
-
- if (indata)
- {
- ret = _cal_ipc_unmarshal_record(indata,&record);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_record fail");
- goto ERROR_RETURN;
- }
- }
- else
- {
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- ERR("_cal_server_ipc_db_insert_record fail");
- goto ERROR_RETURN;
- }
-
- ret = calendar_db_update_record(record);
+ int ret = CALENDAR_ERROR_NONE;
+ calendar_record_h record = NULL;
+
+ if (indata)
+ {
+ ret = _cal_ipc_unmarshal_record(indata,&record);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_record fail");
+ goto ERROR_RETURN;
+ }
+ }
+ else
+ {
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ ERR("_cal_server_ipc_db_insert_record fail");
+ goto ERROR_RETURN;
+ }
+
+ ret = calendar_db_update_record(record);
ERROR_RETURN:
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- if (ret == CALENDAR_ERROR_NONE)
- {
- int transaction_ver = _cal_db_util_get_transaction_ver();
- if (_cal_ipc_marshal_int(transaction_ver,*outdata) != CALENDAR_ERROR_NONE)
- {
- pims_ipc_data_destroy(*outdata);
- ERR("_cal_ipc_marshal fail");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- goto DATA_FREE;
- }
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ int transaction_ver = _cal_db_util_get_transaction_ver();
+ if (_cal_ipc_marshal_int(transaction_ver,*outdata) != CALENDAR_ERROR_NONE)
+ {
+ pims_ipc_data_destroy(*outdata);
+ ERR("_cal_ipc_marshal fail");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ goto DATA_FREE;
+ }
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
DATA_FREE:
- if (record)
- {
- calendar_record_destroy(record,true);
- }
- return;
+ if (record)
+ {
+ calendar_record_destroy(record,true);
+ }
+ return;
}
void _cal_server_ipc_db_delete_record(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
{
- int ret = CALENDAR_ERROR_NONE;
- char* view_uri = NULL;
- int id = 0;
-
- if (indata)
- {
- ret = _cal_ipc_unmarshal_char(indata,&view_uri);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_record fail");
- goto ERROR_RETURN;
- }
- ret = _cal_ipc_unmarshal_int(indata,&id);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_int fail");
- goto ERROR_RETURN;
- }
- }
- else
- {
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- ERR("_cal_server_ipc_db_insert_record fail");
- goto ERROR_RETURN;
- }
-
- ret = calendar_db_delete_record(view_uri,id);
+ int ret = CALENDAR_ERROR_NONE;
+ char* view_uri = NULL;
+ int id = 0;
+
+ if (indata)
+ {
+ ret = _cal_ipc_unmarshal_char(indata,&view_uri);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_record fail");
+ goto ERROR_RETURN;
+ }
+ ret = _cal_ipc_unmarshal_int(indata,&id);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_int fail");
+ goto ERROR_RETURN;
+ }
+ }
+ else
+ {
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ ERR("_cal_server_ipc_db_insert_record fail");
+ goto ERROR_RETURN;
+ }
+
+ ret = calendar_db_delete_record(view_uri,id);
ERROR_RETURN:
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- if (ret == CALENDAR_ERROR_NONE)
- {
- int transaction_ver = _cal_db_util_get_transaction_ver();
- if (_cal_ipc_marshal_int(transaction_ver,*outdata) != CALENDAR_ERROR_NONE)
- {
- pims_ipc_data_destroy(*outdata);
- ERR("_cal_ipc_marshal fail");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- goto DATA_FREE;
- }
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ int transaction_ver = _cal_db_util_get_transaction_ver();
+ if (_cal_ipc_marshal_int(transaction_ver,*outdata) != CALENDAR_ERROR_NONE)
+ {
+ pims_ipc_data_destroy(*outdata);
+ ERR("_cal_ipc_marshal fail");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ goto DATA_FREE;
+ }
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
DATA_FREE:
- CAL_FREE(view_uri);
- return;
+ CAL_FREE(view_uri);
+ return;
}
void _cal_server_ipc_db_get_all_records(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
{
- int ret = CALENDAR_ERROR_NONE;
- char* view_uri = NULL;
- int offset = 0;
- int limit = 0;
- calendar_list_h list = NULL;
-
- if (indata)
- {
- ret = _cal_ipc_unmarshal_char(indata,&view_uri);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_record fail");
- goto ERROR_RETURN;
- }
- ret = _cal_ipc_unmarshal_int(indata,&offset);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_int fail");
- goto ERROR_RETURN;
- }
- ret = _cal_ipc_unmarshal_int(indata,&limit);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_int fail");
- goto ERROR_RETURN;
- }
- }
- else
- {
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- ERR("_cal_server_ipc_db_insert_record fail");
- goto ERROR_RETURN;
- }
-
- ret = calendar_db_get_all_records(view_uri,offset,limit,&list);
-
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- ret = _cal_ipc_marshal_list(list,*outdata);
-
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_int fail");
- goto ERROR_RETURN;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
-
- goto DATA_FREE;
+ int ret = CALENDAR_ERROR_NONE;
+ char* view_uri = NULL;
+ int offset = 0;
+ int limit = 0;
+ calendar_list_h list = NULL;
+
+ if (indata)
+ {
+ ret = _cal_ipc_unmarshal_char(indata,&view_uri);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_record fail");
+ goto ERROR_RETURN;
+ }
+ ret = _cal_ipc_unmarshal_int(indata,&offset);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_int fail");
+ goto ERROR_RETURN;
+ }
+ ret = _cal_ipc_unmarshal_int(indata,&limit);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_int fail");
+ goto ERROR_RETURN;
+ }
+ }
+ else
+ {
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ ERR("_cal_server_ipc_db_insert_record fail");
+ goto ERROR_RETURN;
+ }
+
+ ret = calendar_db_get_all_records(view_uri,offset,limit,&list);
+
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_int fail");
+ goto DATA_FREE;
+ }
+ ret = _cal_ipc_marshal_list(list,*outdata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_int fail");
+ goto ERROR_RETURN;
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
+
+ goto DATA_FREE;
ERROR_RETURN:
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
DATA_FREE:
- if (list)
- {
- calendar_list_destroy(list,true);
- }
- CAL_FREE(view_uri);
- return;
+ if (list)
+ {
+ calendar_list_destroy(list,true);
+ }
+ CAL_FREE(view_uri);
+ return;
}
void _cal_server_ipc_db_get_records_with_query(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
{
- int ret = CALENDAR_ERROR_NONE;
- calendar_query_h query = NULL;
- int offset = 0;
- int limit = 0;
- calendar_list_h list = NULL;
-
- if (indata)
- {
- ret = _cal_ipc_unmarshal_query(indata,&query);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_record fail");
- goto ERROR_RETURN;
- }
- ret = _cal_ipc_unmarshal_int(indata,&offset);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_int fail");
- goto ERROR_RETURN;
- }
- ret = _cal_ipc_unmarshal_int(indata,&limit);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_int fail");
- goto ERROR_RETURN;
- }
- }
- else
- {
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- ERR("_cal_server_ipc_db_insert_record fail");
- goto ERROR_RETURN;
- }
-
- ret = calendar_db_get_records_with_query(query,offset,limit,&list);
-
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- ret = _cal_ipc_marshal_list(list,*outdata);
-
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_int fail");
- goto ERROR_RETURN;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
- goto DATA_FREE;
+ int ret = CALENDAR_ERROR_NONE;
+ calendar_query_h query = NULL;
+ int offset = 0;
+ int limit = 0;
+ calendar_list_h list = NULL;
+
+ if (indata)
+ {
+ ret = _cal_ipc_unmarshal_query(indata,&query);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_record fail");
+ goto ERROR_RETURN;
+ }
+ ret = _cal_ipc_unmarshal_int(indata,&offset);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_int fail");
+ goto ERROR_RETURN;
+ }
+ ret = _cal_ipc_unmarshal_int(indata,&limit);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_int fail");
+ goto ERROR_RETURN;
+ }
+ }
+ else
+ {
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ ERR("_cal_server_ipc_db_insert_record fail");
+ goto ERROR_RETURN;
+ }
+
+ ret = calendar_db_get_records_with_query(query,offset,limit,&list);
+
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_int fail");
+ goto DATA_FREE;
+ }
+ ret = _cal_ipc_marshal_list(list,*outdata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_int fail");
+ goto DATA_FREE;
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
+ goto DATA_FREE;
ERROR_RETURN:
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
DATA_FREE:
- if (list)
- {
- calendar_list_destroy(list,true);
- }
- if (query)
- {
- calendar_query_destroy(query);
- }
- return;
+ if (list)
+ {
+ calendar_list_destroy(list,true);
+ }
+ if (query)
+ {
+ calendar_query_destroy(query);
+ }
+ return;
}
void _cal_server_ipc_db_clean_after_sync(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
{
- int ret = CALENDAR_ERROR_NONE;
- int calendar_book_id = 0;
- int calendar_db_version = 0;
-
- if (indata)
- {
- ret = _cal_ipc_unmarshal_int(indata,&calendar_book_id);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_int fail");
- goto ERROR_RETURN;
- }
- ret = _cal_ipc_unmarshal_int(indata,&calendar_db_version);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_int fail");
- goto ERROR_RETURN;
- }
- }
- else
- {
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- ERR("_cal_server_ipc_db_insert_record fail");
- goto ERROR_RETURN;
- }
-
- ret = calendar_db_clean_after_sync(calendar_book_id, calendar_db_version);
+ int ret = CALENDAR_ERROR_NONE;
+ int calendar_book_id = 0;
+ int calendar_db_version = 0;
+
+ if (indata)
+ {
+ ret = _cal_ipc_unmarshal_int(indata,&calendar_book_id);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_int fail");
+ goto ERROR_RETURN;
+ }
+ ret = _cal_ipc_unmarshal_int(indata,&calendar_db_version);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_int fail");
+ goto ERROR_RETURN;
+ }
+ }
+ else
+ {
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ ERR("_cal_server_ipc_db_insert_record fail");
+ goto ERROR_RETURN;
+ }
+
+ ret = calendar_db_clean_after_sync(calendar_book_id, calendar_db_version);
ERROR_RETURN:
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- return;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- return;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
-
- return;
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ return;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ return;
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
+
+ return;
}
void _cal_server_ipc_db_get_count(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
{
- int ret = CALENDAR_ERROR_NONE;
- char* view_uri = NULL;
- int count = 0;
-
- if (indata)
- {
- ret = _cal_ipc_unmarshal_char(indata,&view_uri);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_record fail");
- goto ERROR_RETURN;
- }
- }
- else
- {
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- ERR("_cal_server_ipc_db_insert_record fail");
- goto ERROR_RETURN;
- }
-
- ret = calendar_db_get_count(view_uri,&count);
-
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- ret = _cal_ipc_marshal_int(count,*outdata);
-
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_int fail");
- goto ERROR_RETURN;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
- goto DATA_FREE;
+ int ret = CALENDAR_ERROR_NONE;
+ char* view_uri = NULL;
+ int count = 0;
+
+ if (indata)
+ {
+ ret = _cal_ipc_unmarshal_char(indata,&view_uri);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_record fail");
+ goto ERROR_RETURN;
+ }
+ }
+ else
+ {
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ ERR("_cal_server_ipc_db_insert_record fail");
+ goto ERROR_RETURN;
+ }
+
+ ret = calendar_db_get_count(view_uri,&count);
+
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ goto DATA_FREE;
+ }
+ ret = _cal_ipc_marshal_int(count,*outdata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_int fail");
+ goto ERROR_RETURN;
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
+ goto DATA_FREE;
ERROR_RETURN:
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
DATA_FREE:
- CAL_FREE(view_uri);
- return;
+ CAL_FREE(view_uri);
+ return;
}
void _cal_server_ipc_db_get_count_with_query(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
{
- int ret = CALENDAR_ERROR_NONE;
- calendar_query_h query = NULL;
- int count = 0;
-
- if (indata)
- {
- ret = _cal_ipc_unmarshal_query(indata,&query);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_record fail");
- goto ERROR_RETURN;
- }
- }
- else
- {
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- ERR("_cal_server_ipc_db_insert_record fail");
- goto ERROR_RETURN;
- }
-
- ret = calendar_db_get_count_with_query(query,&count);
-
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- ret = _cal_ipc_marshal_int(count,*outdata);
-
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_int fail");
- goto ERROR_RETURN;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
- goto DATA_FREE;
+ int ret = CALENDAR_ERROR_NONE;
+ calendar_query_h query = NULL;
+ int count = 0;
+
+ if (indata)
+ {
+ ret = _cal_ipc_unmarshal_query(indata,&query);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_record fail");
+ goto ERROR_RETURN;
+ }
+ }
+ else
+ {
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ ERR("_cal_server_ipc_db_insert_record fail");
+ goto ERROR_RETURN;
+ }
+
+ ret = calendar_db_get_count_with_query(query,&count);
+
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ if (CALENDAR_ERROR_NONE != ret) {
+ goto DATA_FREE;
+ }
+ ret = _cal_ipc_marshal_int(count,*outdata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_int fail");
+ goto ERROR_RETURN;
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
+ goto DATA_FREE;
ERROR_RETURN:
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
DATA_FREE:
- if (query)
- {
- calendar_query_destroy(query);
- }
- return;
+ if (query)
+ {
+ calendar_query_destroy(query);
+ }
+ return;
}
void _cal_server_ipc_db_insert_records(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
{
- int ret = CALENDAR_ERROR_NONE;
- calendar_list_h list = NULL;
- int id_count = 0;
- int *ids = NULL;
- int i=0;
-
- if (indata)
- {
- ret = _cal_ipc_unmarshal_list(indata,&list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_list fail");
- goto ERROR_RETURN;
- }
- }
- else
- {
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- ERR("_cal_server_ipc_db_insert_record fail");
- goto ERROR_RETURN;
- }
-
- ret = calendar_db_insert_records(list, &ids, &id_count);
-
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
-
- if(ret == CALENDAR_ERROR_NONE)
- {
- int transaction_ver = _cal_db_util_get_transaction_ver();
- if (_cal_ipc_marshal_int(transaction_ver,*outdata) != CALENDAR_ERROR_NONE)
- {
- pims_ipc_data_destroy(*outdata);
- ERR("_cal_ipc_marshal fail");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- goto ERROR_RETURN;
- }
- // marshal : id_count+[ids]*id_count
- // id_count
- if (pims_ipc_data_put(*outdata,(void*)&id_count,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- goto ERROR_RETURN;
- }
-
- for(i=0;i<id_count;i++)
- {
- // marshal ids
- if (pims_ipc_data_put(*outdata,(void*)&ids[i],sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- goto ERROR_RETURN;
- }
- }
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
- goto DATA_FREE;
+ int ret = CALENDAR_ERROR_NONE;
+ calendar_list_h list = NULL;
+ int id_count = 0;
+ int *ids = NULL;
+ int i=0;
+
+ if (indata)
+ {
+ ret = _cal_ipc_unmarshal_list(indata,&list);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_list fail");
+ goto ERROR_RETURN;
+ }
+ }
+ else
+ {
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ ERR("_cal_server_ipc_db_insert_record fail");
+ goto ERROR_RETURN;
+ }
+
+ ret = calendar_db_insert_records(list, &ids, &id_count);
+
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ if(ret == CALENDAR_ERROR_NONE)
+ {
+ int transaction_ver = _cal_db_util_get_transaction_ver();
+ if (_cal_ipc_marshal_int(transaction_ver,*outdata) != CALENDAR_ERROR_NONE)
+ {
+ pims_ipc_data_destroy(*outdata);
+ ERR("_cal_ipc_marshal fail");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ goto ERROR_RETURN;
+ }
+ // marshal : id_count+[ids]*id_count
+ // id_count
+ if (pims_ipc_data_put(*outdata,(void*)&id_count,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ goto ERROR_RETURN;
+ }
+
+ for(i=0;i<id_count;i++)
+ {
+ // marshal ids
+ if (pims_ipc_data_put(*outdata,(void*)&ids[i],sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ goto ERROR_RETURN;
+ }
+ }
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
+ goto DATA_FREE;
ERROR_RETURN:
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
DATA_FREE:
- if (list)
- {
- calendar_list_destroy(list,true);
- }
- CAL_FREE(ids);
- return;
+ if (list)
+ {
+ calendar_list_destroy(list,true);
+ }
+ CAL_FREE(ids);
+ return;
}
void _cal_server_ipc_db_update_records(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
{
- int ret = CALENDAR_ERROR_NONE;
- calendar_list_h list = NULL;
-
- if (indata)
- {
- ret = _cal_ipc_unmarshal_list(indata,&list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_list fail");
- goto ERROR_RETURN;
- }
- }
- else
- {
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- ERR("_cal_server_ipc_db_insert_record fail");
- goto ERROR_RETURN;
- }
-
- ret = calendar_db_update_records(list);
-
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- if (ret == CALENDAR_ERROR_NONE)
- {
- int transaction_ver = _cal_db_util_get_transaction_ver();
- if (_cal_ipc_marshal_int(transaction_ver,*outdata) != CALENDAR_ERROR_NONE)
- {
- pims_ipc_data_destroy(*outdata);
- ERR("_cal_ipc_marshal fail");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- goto DATA_FREE;
- }
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
- goto DATA_FREE;
+ int ret = CALENDAR_ERROR_NONE;
+ calendar_list_h list = NULL;
+
+ if (indata)
+ {
+ ret = _cal_ipc_unmarshal_list(indata,&list);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_list fail");
+ goto ERROR_RETURN;
+ }
+ }
+ else
+ {
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ ERR("_cal_server_ipc_db_insert_record fail");
+ goto ERROR_RETURN;
+ }
+
+ ret = calendar_db_update_records(list);
+
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ int transaction_ver = _cal_db_util_get_transaction_ver();
+ if (_cal_ipc_marshal_int(transaction_ver,*outdata) != CALENDAR_ERROR_NONE)
+ {
+ pims_ipc_data_destroy(*outdata);
+ ERR("_cal_ipc_marshal fail");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ goto DATA_FREE;
+ }
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
+ goto DATA_FREE;
ERROR_RETURN:
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
DATA_FREE:
- if (list)
- {
- calendar_list_destroy(list,true);
- }
- return;
+ if (list)
+ {
+ calendar_list_destroy(list,true);
+ }
+ return;
}
void _cal_server_ipc_db_delete_records(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
{
- int ret = CALENDAR_ERROR_NONE;
- int count = 0;
- int *ids = NULL;
- char *uri = NULL;
- int i = 0;
-
- if (indata)
- {
- ret = _cal_ipc_unmarshal_char(indata,&uri);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_char fail");
- goto ERROR_RETURN;
- }
- ret = _cal_ipc_unmarshal_int(indata,&count);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_int fail");
- goto ERROR_RETURN;
- }
- if (count <=0)
- {
- goto ERROR_RETURN;
- }
- ids = (int*)malloc(sizeof(int)*count);
- for(i=0;i<count;i++)
- {
- ret = _cal_ipc_unmarshal_int(indata,&ids[i]);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_int fail");
- goto ERROR_RETURN;
- }
- }
- }
- else
- {
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- ERR("_cal_server_ipc_db_insert_record fail");
- goto ERROR_RETURN;
- }
-
- ret = calendar_db_delete_records(uri,ids,count);
-
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- if (ret == CALENDAR_ERROR_NONE)
- {
- int transaction_ver = _cal_db_util_get_transaction_ver();
- if (_cal_ipc_marshal_int(transaction_ver,*outdata) != CALENDAR_ERROR_NONE)
- {
- pims_ipc_data_destroy(*outdata);
- ERR("_cal_ipc_marshal fail");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- goto DATA_FREE;
- }
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
- goto DATA_FREE;
+ int ret = CALENDAR_ERROR_NONE;
+ int count = 0;
+ int *ids = NULL;
+ char *uri = NULL;
+ int i = 0;
+
+ if (indata)
+ {
+ ret = _cal_ipc_unmarshal_char(indata,&uri);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_char fail");
+ goto ERROR_RETURN;
+ }
+ ret = _cal_ipc_unmarshal_int(indata,&count);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_int fail");
+ goto ERROR_RETURN;
+ }
+ if (count <=0)
+ {
+ goto ERROR_RETURN;
+ }
+ ids = (int*)malloc(sizeof(int)*count);
+ for(i=0;i<count;i++)
+ {
+ ret = _cal_ipc_unmarshal_int(indata,&ids[i]);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_int fail");
+ goto ERROR_RETURN;
+ }
+ }
+ }
+ else
+ {
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ ERR("_cal_server_ipc_db_insert_record fail");
+ goto ERROR_RETURN;
+ }
+
+ ret = calendar_db_delete_records(uri,ids,count);
+
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ int transaction_ver = _cal_db_util_get_transaction_ver();
+ if (_cal_ipc_marshal_int(transaction_ver,*outdata) != CALENDAR_ERROR_NONE)
+ {
+ pims_ipc_data_destroy(*outdata);
+ ERR("_cal_ipc_marshal fail");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ goto DATA_FREE;
+ }
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
+ goto DATA_FREE;
ERROR_RETURN:
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
DATA_FREE:
- CAL_FREE(uri);
- CAL_FREE(ids);
- return;
+ CAL_FREE(uri);
+ CAL_FREE(ids);
+ return;
}
void _cal_server_ipc_db_get_changes_by_version(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
{
- int ret = CALENDAR_ERROR_NONE;
- char* view_uri = NULL;
- int calendar_book_id = 0;
- int calendar_db_version = 0;
- calendar_list_h record_list = NULL;
- int current_calendar_db_version = 0;
-
- if (indata)
- {
- ret = _cal_ipc_unmarshal_char(indata,&view_uri);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_char fail");
- goto ERROR_RETURN;
- }
- ret = _cal_ipc_unmarshal_int(indata,&calendar_book_id);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_int fail");
- goto ERROR_RETURN;
- }
- ret = _cal_ipc_unmarshal_int(indata,&calendar_db_version);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_int fail");
- goto ERROR_RETURN;
- }
- }
- else
- {
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- ERR("_cal_server_ipc_db_insert_record fail");
- goto ERROR_RETURN;
- }
-
- ret = calendar_db_get_changes_by_version(view_uri,calendar_book_id,calendar_db_version,&record_list,¤t_calendar_db_version);
-
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- ret = _cal_ipc_marshal_list(record_list,*outdata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal_list fail");
- goto ERROR_RETURN;
- }
- ret = _cal_ipc_marshal_int(current_calendar_db_version,*outdata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_int fail");
- goto ERROR_RETURN;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
- goto DATA_FREE;
+ int ret = CALENDAR_ERROR_NONE;
+ char* view_uri = NULL;
+ int calendar_book_id = 0;
+ int calendar_db_version = 0;
+ calendar_list_h record_list = NULL;
+ int current_calendar_db_version = 0;
+
+ if (indata)
+ {
+ ret = _cal_ipc_unmarshal_char(indata,&view_uri);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_char fail");
+ goto ERROR_RETURN;
+ }
+ ret = _cal_ipc_unmarshal_int(indata,&calendar_book_id);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_int fail");
+ goto ERROR_RETURN;
+ }
+ ret = _cal_ipc_unmarshal_int(indata,&calendar_db_version);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_int fail");
+ goto ERROR_RETURN;
+ }
+ }
+ else
+ {
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ ERR("_cal_server_ipc_db_insert_record fail");
+ goto ERROR_RETURN;
+ }
+
+ ret = calendar_db_get_changes_by_version(view_uri,calendar_book_id,calendar_db_version,&record_list,¤t_calendar_db_version);
+
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ if (CALENDAR_ERROR_NONE != ret) {
+ goto DATA_FREE;
+ }
+ ret = _cal_ipc_marshal_list(record_list,*outdata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_marshal_list fail");
+ goto ERROR_RETURN;
+ }
+ ret = _cal_ipc_marshal_int(current_calendar_db_version,*outdata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_int fail");
+ goto ERROR_RETURN;
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
+ goto DATA_FREE;
ERROR_RETURN:
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
DATA_FREE:
- if (record_list)
- {
- calendar_list_destroy(record_list,true);
- }
- CAL_FREE(view_uri);
- return;
+ if (record_list)
+ {
+ calendar_list_destroy(record_list,true);
+ }
+ CAL_FREE(view_uri);
+ return;
}
void _cal_server_ipc_db_get_current_version(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
{
- int ret = CALENDAR_ERROR_NONE;
- int calendar_db_version = 0;
-
- ret = calendar_db_get_current_version(&calendar_db_version);
-
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- return;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- return;
- }
- ret = _cal_ipc_marshal_int(calendar_db_version,*outdata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_marshal_int fail");
- return;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
- return;
+ int ret = CALENDAR_ERROR_NONE;
+ int calendar_db_version = 0;
+
+ ret = calendar_db_get_current_version(&calendar_db_version);
+
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ return;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ return;
+ }
+ if (ret == CALENDAR_ERROR_NONE) {
+ ret = _cal_ipc_marshal_int(calendar_db_version,*outdata);
+ if (ret != CALENDAR_ERROR_NONE) {
+ ERR("_cal_ipc_marshal_int fail");
+ return;
+ }
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
+ return;
}
void _cal_server_ipc_db_insert_vcalendars(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
{
- int ret = CALENDAR_ERROR_NONE;
- char *stream = NULL;
- int count = 0;
- int *ids = NULL;
- int i = 0;
-
- if (indata)
- {
- ret = _cal_ipc_unmarshal_char(indata, &stream);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("unmarshal fail");
- goto ERROR_RETURN;
- }
- }
- else
- {
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- ERR("db_insert_vcalendars fail.");
- goto ERROR_RETURN;
- }
-
- ret = calendar_db_insert_vcalendars(stream, &ids, &count);
-
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_db_insert_vcalendars fail");
- goto ERROR_RETURN;
- }
-
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- // return
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- if (ret == CALENDAR_ERROR_NONE)
- {
- int transaction_ver = _cal_db_util_get_transaction_ver();
- if (_cal_ipc_marshal_int(transaction_ver,*outdata) != CALENDAR_ERROR_NONE)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("_cal_ipc_marshal fail");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- goto ERROR_RETURN;
- }
- }
- // count
- ret = _cal_ipc_marshal_int(count,*outdata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("_cal_ipc_marshal_list fail");
- goto ERROR_RETURN;
- }
- for(i=0;i<count;i++)
- {
- ret = _cal_ipc_marshal_int(ids[i],*outdata);
- if (ret != CALENDAR_ERROR_NONE)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("_cal_ipc_marshal_list fail");
- goto ERROR_RETURN;
- }
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
- goto DATA_FREE;
+ int ret = CALENDAR_ERROR_NONE;
+ char *stream = NULL;
+ int count = 0;
+ int *ids = NULL;
+ int i = 0;
+
+ if (indata)
+ {
+ ret = _cal_ipc_unmarshal_char(indata, &stream);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("unmarshal fail");
+ goto ERROR_RETURN;
+ }
+ }
+ else
+ {
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ ERR("db_insert_vcalendars fail.");
+ goto ERROR_RETURN;
+ }
+
+ ret = calendar_db_insert_vcalendars(stream, &ids, &count);
+
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("calendar_db_insert_vcalendars fail");
+ goto ERROR_RETURN;
+ }
+
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ // return
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ int transaction_ver = _cal_db_util_get_transaction_ver();
+ if (_cal_ipc_marshal_int(transaction_ver,*outdata) != CALENDAR_ERROR_NONE)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("_cal_ipc_marshal fail");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ goto ERROR_RETURN;
+ }
+ }
+ // count
+ ret = _cal_ipc_marshal_int(count,*outdata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("_cal_ipc_marshal_list fail");
+ goto ERROR_RETURN;
+ }
+ for(i=0;i<count;i++)
+ {
+ ret = _cal_ipc_marshal_int(ids[i],*outdata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("_cal_ipc_marshal_list fail");
+ goto ERROR_RETURN;
+ }
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
+ goto DATA_FREE;
ERROR_RETURN:
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
DATA_FREE:
- CAL_FREE(stream);
- CAL_FREE(ids);
- return;
+ CAL_FREE(stream);
+ CAL_FREE(ids);
+ return;
}
void _cal_server_ipc_db_replace_vcalendars(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
{
- int ret = CALENDAR_ERROR_NONE;
- char *stream = NULL;
- int count = 0;
- int *ids = NULL;
- int i = 0;
-
- if (indata)
- {
- ret = _cal_ipc_unmarshal_char(indata, &stream);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("unmarshal fail");
- goto ERROR_RETURN;
- }
- ret = _cal_ipc_unmarshal_int(indata, &count);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("unmarshal fail");
- goto ERROR_RETURN;
- }
- ids = (int*)malloc(sizeof(int)*count);
- if (ids == NULL)
- {
- ERR("malloc fail");
- goto ERROR_RETURN;
- }
- for(i=0;i<count;i++)
- {
- ret = _cal_ipc_unmarshal_int(indata, &ids[i]);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("unmarshal fail");
- goto ERROR_RETURN;
- }
- }
- }
- else
- {
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- ERR("db_replace_vcalendars fail.");
- goto ERROR_RETURN;
- }
-
- ret = calendar_db_replace_vcalendars(stream, ids, count);
-
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_db_insert_vcalendars fail");
- goto ERROR_RETURN;
- }
-
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- // return
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- if (ret == CALENDAR_ERROR_NONE)
- {
- int transaction_ver = _cal_db_util_get_transaction_ver();
- if (_cal_ipc_marshal_int(transaction_ver,*outdata) != CALENDAR_ERROR_NONE)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("_cal_ipc_marshal fail");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- goto DATA_FREE;
- }
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
- goto DATA_FREE;
+ int ret = CALENDAR_ERROR_NONE;
+ char *stream = NULL;
+ int count = 0;
+ int *ids = NULL;
+ int i = 0;
+
+ if (indata)
+ {
+ ret = _cal_ipc_unmarshal_char(indata, &stream);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("unmarshal fail");
+ goto ERROR_RETURN;
+ }
+ ret = _cal_ipc_unmarshal_int(indata, &count);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("unmarshal fail");
+ goto ERROR_RETURN;
+ }
+ ids = (int*)malloc(sizeof(int)*count);
+ if (ids == NULL)
+ {
+ ERR("malloc fail");
+ goto ERROR_RETURN;
+ }
+ for(i=0;i<count;i++)
+ {
+ ret = _cal_ipc_unmarshal_int(indata, &ids[i]);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("unmarshal fail");
+ goto ERROR_RETURN;
+ }
+ }
+ }
+ else
+ {
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ ERR("db_replace_vcalendars fail.");
+ goto ERROR_RETURN;
+ }
+
+ ret = calendar_db_replace_vcalendars(stream, ids, count);
+
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("calendar_db_insert_vcalendars fail");
+ goto ERROR_RETURN;
+ }
+
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ // return
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ int transaction_ver = _cal_db_util_get_transaction_ver();
+ if (_cal_ipc_marshal_int(transaction_ver,*outdata) != CALENDAR_ERROR_NONE)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("_cal_ipc_marshal fail");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ goto DATA_FREE;
+ }
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
+ goto DATA_FREE;
ERROR_RETURN:
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
DATA_FREE:
- CAL_FREE(stream);
- CAL_FREE(ids);
- return;
+ CAL_FREE(stream);
+ CAL_FREE(ids);
+ return;
}
void _cal_server_ipc_db_replace_record(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
{
- int ret = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
int id = 0;
- calendar_record_h record = NULL;
-
- if (indata)
- {
- ret = _cal_ipc_unmarshal_record(indata,&record);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_record fail");
- goto ERROR_RETURN;
- }
- ret = _cal_ipc_unmarshal_int(indata,&id);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_record fail");
- goto ERROR_RETURN;
- }
- }
-
- else
- {
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- ERR("_cal_server_ipc_db_insert_record fail");
- goto ERROR_RETURN;
- }
-
- ret = calendar_db_replace_record(record, id);
+ calendar_record_h record = NULL;
+
+ if (indata)
+ {
+ ret = _cal_ipc_unmarshal_record(indata,&record);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_record fail");
+ goto ERROR_RETURN;
+ }
+ ret = _cal_ipc_unmarshal_int(indata,&id);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_record fail");
+ goto ERROR_RETURN;
+ }
+ }
+
+ else
+ {
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ ERR("_cal_server_ipc_db_insert_record fail");
+ goto ERROR_RETURN;
+ }
+
+ ret = calendar_db_replace_record(record, id);
ERROR_RETURN:
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- if (ret == CALENDAR_ERROR_NONE)
- {
- int transaction_ver = _cal_db_util_get_transaction_ver();
- if (_cal_ipc_marshal_int(transaction_ver,*outdata) != CALENDAR_ERROR_NONE)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("_cal_ipc_marshal fail");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- goto DATA_FREE;
- }
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ int transaction_ver = _cal_db_util_get_transaction_ver();
+ if (_cal_ipc_marshal_int(transaction_ver,*outdata) != CALENDAR_ERROR_NONE)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("_cal_ipc_marshal fail");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ goto DATA_FREE;
+ }
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
DATA_FREE:
- if (record)
- {
- calendar_record_destroy(record,true);
- }
- return;
+ if (record)
+ {
+ calendar_record_destroy(record,true);
+ }
+ return;
}
void _cal_server_ipc_db_replace_records(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
{
- int ret = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
int i;
- int count = 0;
- int *ids = NULL;
- calendar_list_h list = NULL;
-
- if (indata)
- {
- ret = _cal_ipc_unmarshal_list(indata,&list);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_list fail");
- goto ERROR_RETURN;
- }
- ret = _cal_ipc_unmarshal_int(indata, &count);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_int fail");
- goto ERROR_RETURN;
- }
- if (count <= 0)
- {
- goto ERROR_RETURN;
- }
- ids = (int*)malloc(sizeof(int) * count);
- for(i = 0; i < count; i++)
- {
- ret = _cal_ipc_unmarshal_int(indata,&ids[i]);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("_cal_ipc_unmarshal_int fail");
- goto ERROR_RETURN;
- }
- }
- }
- else
- {
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- ERR("_cal_server_ipc_db_insert_record fail");
- goto ERROR_RETURN;
- }
-
- ret = calendar_db_replace_records(list, ids, count);
-
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- if (ret == CALENDAR_ERROR_NONE)
- {
- int transaction_ver = _cal_db_util_get_transaction_ver();
- if (_cal_ipc_marshal_int(transaction_ver,*outdata) != CALENDAR_ERROR_NONE)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("_cal_ipc_marshal fail");
- ret = CALENDAR_ERROR_OUT_OF_MEMORY;
- goto DATA_FREE;
- }
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
- goto DATA_FREE;
-
-ERROR_RETURN:
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- goto DATA_FREE;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- goto DATA_FREE;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
-DATA_FREE:
- CAL_FREE(ids);
- if (list)
- {
- calendar_list_destroy(list,true);
- }
- return;
-}
-
-void _cal_server_ipc_db_register_reminder(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
-{
- int ret = CALENDAR_ERROR_NONE;
- char *pkgname;
- char *extra_data_key;
- char *extra_data_value;
-
- if (indata)
- {
- ret = _cal_ipc_unmarshal_char(indata, &pkgname);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("unmarshal fail");
- goto ERROR_RETURN;
- }
- ret = _cal_ipc_unmarshal_char(indata, &extra_data_key);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("unmarshal fail");
- goto ERROR_RETURN;
- }
- ret = _cal_ipc_unmarshal_char(indata, &extra_data_value);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("unmarshal fail");
- goto ERROR_RETURN;
- }
- }
- else
- {
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- ERR("db_insert_vcalendars fail.");
- goto ERROR_RETURN;
- }
-
- ret = calendar_reminder_add_receiver(pkgname, extra_data_key, extra_data_value);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_reminder_add_receiver() fail");
- goto ERROR_RETURN;
- }
-
-ERROR_RETURN:
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- return;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- return;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
- return;
-}
-
-void _cal_server_ipc_db_unregister_reminder(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
-{
- int ret = CALENDAR_ERROR_NONE;
- char *pkgname;
+ int count = 0;
+ int *ids = NULL;
+ calendar_list_h list = NULL;
if (indata)
- {
- ret = _cal_ipc_unmarshal_char(indata, &pkgname);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("unmarshal fail");
- goto ERROR_RETURN;
- }
- }
- else
- {
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- ERR("db_insert_vcalendars fail.");
- goto ERROR_RETURN;
- }
-
- ret = calendar_reminder_remove_receiver(pkgname);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_reminder_remove_receiver() fail");
- goto ERROR_RETURN;
- }
+ {
+ ret = _cal_ipc_unmarshal_list(indata,&list);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_list fail");
+ goto ERROR_RETURN;
+ }
+ ret = _cal_ipc_unmarshal_int(indata, &count);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_int fail");
+ goto ERROR_RETURN;
+ }
+ if (count <= 0)
+ {
+ goto ERROR_RETURN;
+ }
+ ids = (int*)malloc(sizeof(int) * count);
+ for(i = 0; i < count; i++)
+ {
+ ret = _cal_ipc_unmarshal_int(indata,&ids[i]);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_int fail");
+ goto ERROR_RETURN;
+ }
+ }
+ }
+ else
+ {
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ ERR("_cal_server_ipc_db_insert_record fail");
+ goto ERROR_RETURN;
+ }
+
+ ret = calendar_db_replace_records(list, ids, count);
+
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ if (ret == CALENDAR_ERROR_NONE)
+ {
+ int transaction_ver = _cal_db_util_get_transaction_ver();
+ if (_cal_ipc_marshal_int(transaction_ver,*outdata) != CALENDAR_ERROR_NONE)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("_cal_ipc_marshal fail");
+ ret = CALENDAR_ERROR_OUT_OF_MEMORY;
+ goto DATA_FREE;
+ }
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
+ goto DATA_FREE;
ERROR_RETURN:
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- return;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- return;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
- return;
-}
-
-void _cal_server_ipc_db_activate_reminder(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
-{
- int ret = CALENDAR_ERROR_NONE;
- char *pkgname;
-
- if (indata)
- {
- ret = _cal_ipc_unmarshal_char(indata, &pkgname);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("unmarshal fail");
- goto ERROR_RETURN;
- }
- }
- else
- {
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- ERR("db_insert_vcalendars fail.");
- goto ERROR_RETURN;
- }
-
- ret = calendar_reminder_activate_receiver(pkgname);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_reminder_activate_receiver() fail");
- goto ERROR_RETURN;
- }
-
-ERROR_RETURN:
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- return;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- return;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
- return;
-}
-
-void _cal_server_ipc_db_deactivate_reminder(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
-{
- int ret = CALENDAR_ERROR_NONE;
- char *pkgname;
-
- if (indata)
- {
- ret = _cal_ipc_unmarshal_char(indata, &pkgname);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("unmarshal fail");
- goto ERROR_RETURN;
- }
- }
- else
- {
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- ERR("db_insert_vcalendars fail.");
- goto ERROR_RETURN;
- }
-
- ret = calendar_reminder_deactivate_receiver(pkgname);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_reminder_deactivate_pkgname() fail");
- goto ERROR_RETURN;
- }
-
-ERROR_RETURN:
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- return;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- return;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
- return;
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
+DATA_FREE:
+ CAL_FREE(ids);
+ if (list)
+ {
+ calendar_list_destroy(list,true);
+ }
+ return;
}
-void _cal_server_ipc_db_has_reminder(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
+void _cal_server_ipc_db_changes_exception(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata)
{
- int ret = CALENDAR_ERROR_NONE;
- char *pkgname;
+ int ret = CALENDAR_ERROR_NONE;
+ char* view_uri = NULL;
+ int original_event_id = 0;
+ int calendar_db_version = 0;
+ calendar_list_h record_list = NULL;
if (indata)
- {
- ret = _cal_ipc_unmarshal_char(indata, &pkgname);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("unmarshal fail");
- goto ERROR_RETURN;
- }
- }
- else
- {
- ret = CALENDAR_ERROR_INVALID_PARAMETER;
- ERR("db_insert_vcalendars fail.");
- goto ERROR_RETURN;
- }
-
- ret = calendar_reminder_has_receiver(pkgname);
- if (ret != CALENDAR_ERROR_NONE)
- {
- ERR("calendar_reminder_deactivate_pkgname() fail");
- goto ERROR_RETURN;
- }
+ {
+ ret = _cal_ipc_unmarshal_char(indata,&view_uri);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_char fail");
+ goto ERROR_RETURN;
+ }
+ ret = _cal_ipc_unmarshal_int(indata,&original_event_id);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_int fail");
+ goto ERROR_RETURN;
+ }
+ ret = _cal_ipc_unmarshal_int(indata,&calendar_db_version);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_unmarshal_int fail");
+ goto ERROR_RETURN;
+ }
+ }
+ else
+ {
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
+ ERR("_cal_server_ipc_db_insert_record fail");
+ goto ERROR_RETURN;
+ }
+
+ ret = calendar_db_get_changes_exception_by_version(view_uri,original_event_id,calendar_db_version,&record_list);
+
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ if (CALENDAR_ERROR_NONE != ret) {
+ goto DATA_FREE;
+ }
+ ret = _cal_ipc_marshal_list(record_list,*outdata);
+ if (ret != CALENDAR_ERROR_NONE)
+ {
+ ERR("_cal_ipc_marshal_list fail");
+ goto ERROR_RETURN;
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
+ goto DATA_FREE;
ERROR_RETURN:
- if (outdata)
- {
- *outdata = pims_ipc_data_create(0);
- if (!*outdata)
- {
- ERR("pims_ipc_data_create fail");
- return;
- }
- if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
- {
- pims_ipc_data_destroy(*outdata);
- *outdata = NULL;
- ERR("pims_ipc_data_put fail");
- return;
- }
- }
- else
- {
- ERR("outdata is NULL");
- }
- return;
+ if (outdata)
+ {
+ *outdata = pims_ipc_data_create(0);
+ if (!*outdata)
+ {
+ ERR("pims_ipc_data_create fail");
+ goto DATA_FREE;
+ }
+ if (pims_ipc_data_put(*outdata,(void*)&ret,sizeof(int)) != 0)
+ {
+ pims_ipc_data_destroy(*outdata);
+ *outdata = NULL;
+ ERR("pims_ipc_data_put fail");
+ goto DATA_FREE;
+ }
+ }
+ else
+ {
+ ERR("outdata is NULL");
+ }
+DATA_FREE:
+ if (record_list)
+ {
+ calendar_list_destroy(record_list,true);
+ }
+ CAL_FREE(view_uri);
+ return;
}
-
// calendar_service.h
void _cal_server_ipc_connect(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata);
void _cal_server_ipc_disconnect(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata);
+void _cal_server_ipc_check_permission(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata);
// calendar_db.h
void _cal_server_ipc_db_insert_record(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata);
void _cal_server_ipc_db_replace_vcalendars(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata);
void _cal_server_ipc_db_replace_record(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata);
void _cal_server_ipc_db_replace_records(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata);
-void _cal_server_ipc_db_register_reminder(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata);
-void _cal_server_ipc_db_unregister_reminder(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata);
-void _cal_server_ipc_db_activate_reminder(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata);
-void _cal_server_ipc_db_deactivate_reminder(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata);
-void _cal_server_ipc_db_has_reminder(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata);
-
+void _cal_server_ipc_db_changes_exception(pims_ipc_h ipc, pims_ipc_data_h indata, pims_ipc_data_h *outdata, void *userdata);
#endif /*__CAL_SERVER_IPC_H__*/
#include <stdlib.h>
#include <pims-ipc-svc.h>
-#include "calendar2.h"
+#include "calendar.h"
#include "cal_internal.h" // DBG
#include "cal_typedef.h"
#include "cal_db.h"
#define CAL_SUBSCRIBE_MAX_LEN 1024
-static __thread char *__data = NULL;
-static __thread int __len_data = 0;
-
-static gboolean __cal_server_reminder_publish_changes_with_data(unsigned char *data, int len)
+static gboolean __cal_server_reminder_publish_changes_with_data(char *data, int len)
{
pims_ipc_data_h indata = NULL;
if (NULL == data)
if (pims_ipc_data_put(indata, &len, sizeof(int)) != 0)
{
ERR("pims_ipc_data_put() failed");
+ pims_ipc_data_destroy(indata);
return false;
}
- if (pims_ipc_data_put(indata, data, len + 1) != 0)
+ if (pims_ipc_data_put(indata, data, strlen(data) + 1) != 0)
{
ERR("pims_ipc_data_put() failed");
+ pims_ipc_data_destroy(indata);
return false;
}
if (pims_ipc_svc_publish(CAL_IPC_MODULE_FOR_SUBSCRIPTION, (char *)CAL_NOTI_REMINDER_CAHNGED, indata) != 0)
{
ERR("pims_ipc_svc_publish() failed");
+ pims_ipc_data_destroy(indata);
return false;
}
pims_ipc_data_destroy(indata);
return true;
}
-void __cal_server_reminder_clear_changed_info(void)
+void _cal_server_reminder_publish(char *p)
{
- if (__data)
- {
- free(__data);
- __data = NULL;
- __len_data = 0;
- }
+ retm_if (NULL == p, "Invalid parameter: p is NULL");
+ __cal_server_reminder_publish_changes_with_data(p, strlen(p));
}
-void _cal_server_reminder_publish(void)
+int _cal_server_reminder_add_callback_data(char **p, char *key, char *value)
{
- if (__data)
- {
- __cal_server_reminder_publish_changes_with_data((unsigned char *)__data, __len_data);
- __cal_server_reminder_clear_changed_info();
- }
-}
-
-int _cal_server_reminder_add_callback_data(char *key, char *value)
-{
- int len_data = 0;
int len_key = 0;
int len_value = 0;
len_key = strlen(key);
len_value = strlen(value);
DBG("key[%s]value[%s]", key, value);
- if (NULL == __data)
+
+ if (NULL == *p)
{
- __len_data = len_key + len_value + 2;
- __data = calloc(__len_data, sizeof(char));
- if (NULL == __data)
- {
+ int len = len_key + len_value + 2;
+ *p = calloc(len, sizeof(char));
+ if (NULL == *p) {
ERR("calloc() failed");
return CALENDAR_ERROR_DB_FAILED;
}
- snprintf(__data, __len_data, "%s=%s", key, value);
- }
- else
- {
- char *p = NULL;
- len_data = strlen(__data);
+ snprintf(*p, len, "%s=%s", key, value);
- __len_data = len_data + len_key + len_value + 3;
- p = calloc(__len_data, sizeof(char));
- if (NULL == __data)
- {
+ } else {
+ int len = strlen(*p) + len_key + len_value + 3;
+ char *temp = calloc(len, sizeof(char));
+ if (NULL == temp) {
ERR("recalloc() failed");
return CALENDAR_ERROR_DB_FAILED;
}
- snprintf(p, __len_data, "%s&%s=%s", __data, key, value);
- free(__data);
- __data = p;
-
+ snprintf(temp, len, "%s&%s=%s", *p, key, value);
+ free(*p);
+ *p = temp;
}
-
- DBG("data[%s]len(%d)", __data, __len_data);
return CALENDAR_ERROR_NONE;
}
#ifndef __CAL_SERVER_REMINDER_H__
#define __CAL_SERVER_REMINDER_H__
-void _cal_server_reminder_publish(void);
-void _cal_server_reminder_add_callback_data(char *key, char *value);
+void _cal_server_reminder_publish(char *p);
+int _cal_server_reminder_add_callback_data(char **p, char *key, char *value);
#endif //__CAL_SERVER_REMINDER_H__
#include <string.h>
#include <sqlite3.h>
#include <db-util.h>
-#include "cal_typedef.h"
-#include "schema.h"
-#include <tzplatform_config.h>
+#include "cal_internal.h"
+#include "schema.h"
#define CALS_DB_NAME ".calendar-svc.db"
#define CALS_DB_JOURNAL_NAME ".calendar-svc.db-journal"
-#define CALS_DB_PATH tzplatform_mkpath(TZ_USER_DB, ".calendar-svc.db")
-#define CALS_DB_JOURNAL_PATH tzplatform_mkpath(TZ_USER_DB, ".calendar-svc.db-journal")
+#define CALS_DB_PATH "/opt/usr/dbspace/"CALS_DB_NAME
+#define CALS_DB_JOURNAL_PATH "/opt/usr/dbspace/"CALS_DB_JOURNAL_NAME
// For Security
-#define CALS_SECURITY_FILE_GROUP 6003
+#define CALS_SECURITY_FILE_GROUP 5000
#define CALS_SECURITY_DEFAULT_PERMISSION 0660
#define CALS_SECURITY_DIR_DEFAULT_PERMISSION 0770
-static inline int remake_db_file(char* db_path)
+static inline int __remake_db_file(char* db_path)
{
int ret, fd;
char *errmsg;
if(db_path == NULL)
{
- snprintf(db_file,sizeof(db_file),CALS_DB_PATH);
- snprintf(db_journal_file,sizeof(db_journal_file),CALS_DB_JOURNAL_PATH);
+ snprintf(db_file,sizeof(db_file),CALS_DB_PATH);
+ snprintf(db_journal_file,sizeof(db_journal_file),CALS_DB_JOURNAL_PATH);
}
else
{
- snprintf(db_file,sizeof(db_file),"%s%s",db_path, CALS_DB_NAME);
- snprintf(db_journal_file,sizeof(db_journal_file),"%s%s", db_path, CALS_DB_JOURNAL_NAME);
+ snprintf(db_file,sizeof(db_file),"%s%s",db_path, CALS_DB_NAME);
+ snprintf(db_journal_file,sizeof(db_journal_file),"%s%s", db_path, CALS_DB_JOURNAL_NAME);
}
ret = db_util_open(db_file, &db, 0);
if (SQLITE_OK != ret)
{
- printf("db_util_open() Failed(%d)\n", ret);
+ ERR("db_util_open() Failed(%d) ", ret);
return -1;
}
ret = sqlite3_exec(db, schema_query, NULL, 0, &errmsg);
if (SQLITE_OK != ret) {
- printf("remake calendar DB file is Failed : %s\n", errmsg);
+ ERR("remake calendar DB file is Failed : %s ", errmsg);
sqlite3_free(errmsg);
}
fd = open(db_file, O_CREAT | O_RDWR, 0660);
if (-1 == fd)
{
- printf("open Failed\n");
+ ERR("open Failed ");
return -1;
}
ret = fchown(fd, getuid(), CALS_SECURITY_FILE_GROUP);
if (-1 == ret)
{
- printf("Failed to fchown\n");
+ ERR("Failed to fchown ");
close(fd);
return -1;
}
if (-1 == fd)
{
- printf("open Failed\n");
+ ERR("open Failed ");
return -1;
}
ret = fchown(fd, getuid(), CALS_SECURITY_FILE_GROUP);
if (-1 == ret)
{
- printf("Failed to fchown\n");
+ ERR("Failed to fchown ");
close(fd);
return -1;
}
return 0;
}
-static inline int check_db_file(char* db_path)
+static inline int __check_db_file(char* db_path)
{
- int fd = -1;
-
- char db_file[256]={0,};
- if(db_path == NULL)
- {
- snprintf(db_file,sizeof(db_file),CALS_DB_PATH);
- }
- else
- {
- snprintf(db_file,sizeof(db_file),"%s%s",db_path, CALS_DB_NAME);
- }
-
- fd = open(db_file, O_RDONLY);
-
- if (-1 == fd)
- {
- printf("DB file(%s) is not exist\n", db_file);
- return -1;
- }
- printf("DB file(%s) \n", db_file);
- close(fd);
- return 0;
-}
+ int fd = -1;
+ char db_file[256]={0,};
+ if(db_path == NULL)
+ {
+ snprintf(db_file,sizeof(db_file),CALS_DB_PATH);
+ }
+ else
+ {
+ snprintf(db_file,sizeof(db_file),"%s%s",db_path, CALS_DB_NAME);
+ }
-static inline int check_schema(char* db_path)
-{
- if (check_db_file(db_path))
- remake_db_file(db_path);
-
+ fd = open(db_file, O_RDONLY);
+ if (fd < 0)
+ {
+ ERR("DB file(%s) is not exist(err:%d) ", db_file, fd);
+ return -1;
+ }
+ close(fd);
return 0;
}
-int main(int argc, char **argv)
+int _cal_server_schema_check(void)
{
- char *tmp = NULL;
- if(argc > 1)
- {
- tmp = argv[1];
- }
- return check_schema(tmp);
+ if (__check_db_file(NULL))
+ __remake_db_file(NULL);
+ return 0;
}
--- /dev/null
+/*
+ * Calendar Service
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __CAL_SERVER_SCHEMA_H__
+#define __CAL_SERVER_SCHEMA_H__
+
+int _cal_server_schema_check(void);
+
+#endif // __CAL_SERVER_SCHEMA_H__
--- /dev/null
+/*
+ * Calendar Service
+ *
+ * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <sqlite3.h>
+#include <db-util.h>
+#include <stdlib.h>
+
+#include "cal_internal.h"
+#include "cal_typedef.h"
+#include "cal_db.h"
+
+#define __USER_VERSION 105
+
+static int __cal_server_update_get_db_version(sqlite3 *db, int *version)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+
+ snprintf(query, sizeof(query), "PRAGMA user_version;");
+ ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
+ if (SQLITE_OK != ret)
+ {
+ ERR("sqlite3_prepare_v2() failed[%s]", sqlite3_errmsg(db));
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ ret = sqlite3_step(stmt);
+ if (SQLITE_ROW != ret)
+ {
+ ERR("sqlite3_step() failed[%s]", sqlite3_errmsg(db));
+ sqlite3_finalize(stmt);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ if (version) *version = (int)sqlite3_column_int(stmt, 0);
+ sqlite3_finalize(stmt);
+ return CALENDAR_ERROR_NONE;
+}
+
+int _cal_server_update(void)
+{
+ ENTER();
+
+ int ret = CALENDAR_ERROR_NONE;
+ int old_version = 0;
+ char *errmsg = NULL;
+ sqlite3 *__db;
+ char query[CAL_DB_SQL_MAX_LEN] = {0};
+
+ ret = db_util_open(CAL_DB_PATH, &__db, 0);
+ if (SQLITE_OK != ret)
+ {
+ ERR("db_util_open() failed");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ __cal_server_update_get_db_version(__db, &old_version);
+ DBG("old version(%d)", old_version);
+
+ if (old_version < 100)
+ {
+ /* ----------------------- start modified 2013/08/22
+ * added attendee_table(cutype, delegatee_uri, member), alarm_table(summary, action, attach).
+ */
+ ret = sqlite3_exec(__db, "DROP VIEW event_calendar_attendee_view", NULL, 0, &errmsg);
+ if (SQLITE_OK != ret)
+ {
+ ERR("sqlite3_exec() failed: DROP VIEW event_calendar_attendee_view(%d) [%s]", ret, errmsg);
+ sqlite3_free(errmsg);
+ }
+
+ ret = sqlite3_exec(__db, "ALTER TABLE attendee_table ADD COLUMN attendee_cutype INTEGER", NULL, 0, &errmsg);
+ if (SQLITE_OK != ret)
+ {
+ ERR("sqlite3_exec() failed: ALTER TABLE attendee_table ADD COLUMN attendee_cutype(%d) [%s]", ret, errmsg);
+ sqlite3_free(errmsg);
+ }
+ ret = sqlite3_exec(__db, "ALTER TABLE attendee_table ADD COLUMN attendee_delegatee_uri TEXT", NULL, 0, &errmsg);
+ if (SQLITE_OK != ret)
+ {
+ ERR("sqlite3_exec() failed: ALTER TABLE attendee_table ADD COLUMN attendee_delegatee_uri(%d) [%s]", ret, errmsg);
+ sqlite3_free(errmsg);
+ }
+ ret = sqlite3_exec(__db, "ALTER TABLE attendee_table ADD COLUMN attendee_member TEXT", NULL, 0, &errmsg);
+ if (SQLITE_OK != ret)
+ {
+ ERR("sqlite3_exec() failed: ALTER TABLE attendee_table ADD COLUMN attendee_member(%d) [%s]", ret, errmsg);
+ sqlite3_free(errmsg);
+ }
+
+ ret = sqlite3_exec(__db, "ALTER TABLE alarm_table ADD COLUMN alarm_summary TEXT", NULL, 0, &errmsg);
+ if (SQLITE_OK != ret)
+ {
+ ERR("sqlite3_exec() failed: ALTER TABLE alarm_table ADD COLUMN alarm_summary(%d) [%s]", ret, errmsg);
+ sqlite3_free(errmsg);
+ }
+ ret = sqlite3_exec(__db, "ALTER TABLE alarm_table ADD COLUMN alarm_action INTEGER", NULL, 0, &errmsg);
+ if (SQLITE_OK != ret)
+ {
+ ERR("sqlite3_exec() failed: ALTER TABLE alarm_table ADD COLUMN alarm_action(%d) [%s]", ret, errmsg);
+ sqlite3_free(errmsg);
+ }
+ ret = sqlite3_exec(__db, "ALTER TABLE alarm_table ADD COLUMN alarm_attach TEXT", NULL, 0, &errmsg);
+ if (SQLITE_OK != ret)
+ {
+ ERR("sqlite3_exec() failed: ALTER TABLE alarm_table ADD COLUMN alarm_attach(%d) [%s]", ret, errmsg);
+ sqlite3_free(errmsg);
+ }
+ old_version = 100;
+ /* ----------------------- end modified 2013/08/22
+ */
+ }
+ if (old_version == 100)
+ {
+ /* ----------------------- start modified 2013/09/22
+ * added schedule_table(freq) for view table parameter.
+ */
+ ret = sqlite3_exec(__db, "ALTER TABLE schedule_table ADD COLUMN freq INTEGER DEFAULT 0", NULL, 0, &errmsg);
+ if (SQLITE_OK != ret)
+ {
+ ERR("sqlite3_exec() failed: ALTER TABLE schedule_table ADD COLUMN freq(%d) [%s]", ret, errmsg);
+ sqlite3_free(errmsg);
+ }
+ old_version = 101;
+ /* ----------------------- end modified 2013/09/22
+ */
+ }
+ if (old_version == 101)
+ {
+ /* ----------------------- start modified 2014/07/02
+ * added trigger depeding on schedule_table
+ * added original_event_id in deleted_table to check exception event.
+ */
+
+ // rename trig -> trg
+ ret = sqlite3_exec(__db, "DROP TRIGGER trig_original_mod", NULL, 0, &errmsg);
+ if (SQLITE_OK != ret) {
+ ERR("DROP TRIGGER trig_original_mod failed(%d:%s)", ret, errmsg);
+ sqlite3_free(errmsg);
+ }
+ ret = sqlite3_exec(__db,
+ "CREATE TRIGGER trg_original_mod AFTER UPDATE OF is_deleted ON schedule_table "
+ " BEGIN "
+ " DELETE FROM normal_instance_table WHERE event_id = (SELECT rowid FROM schedule_table WHERE original_event_id = old.id);"
+ " DELETE FROM allday_instance_table WHERE event_id = (SELECT rowid FROM schedule_table WHERE original_event_id = old.id);"
+ " UPDATE schedule_table SET is_deleted = 1 WHERE original_event_id = old.id;"
+ " END;",
+ NULL, 0, &errmsg);
+ if (SQLITE_OK != ret) {
+ ERR("CREATE TRIGGER trg_original_mod failed(%d:%s)", ret, errmsg);
+ sqlite3_free(errmsg);
+ }
+
+ // rename trg_sch_del -> trg_schedule_del
+ ret = sqlite3_exec(__db, "DROP TRIGGER trg_sch_del", NULL, 0, &errmsg);
+ if (SQLITE_OK != ret) {
+ ERR("DROP TRIGGER trg_sch_del failed(%d:%s)", ret, errmsg);
+ sqlite3_free(errmsg);
+ }
+ ret = sqlite3_exec(__db,
+ "CREATE TRIGGER trg_schedule_del AFTER DELETE ON schedule_table "
+ "BEGIN "
+ " DELETE FROM rrule_table WHERE event_id = old.id;"
+ " DELETE FROM alarm_table WHERE event_id = old.id;"
+ " DELETE FROM schedule_table WHERE original_event_id = old.id;"
+ " DELETE FROM normal_instance_table WHERE event_id = old.id;"
+ " DELETE FROM allday_instance_table WHERE event_id = old.id;"
+ " DELETE FROM attendee_table WHERE event_id = old.id;"
+ " DELETE FROM extended_table WHERE record_id = old.id AND record_type = 2;"
+ " DELETE FROM extended_table WHERE record_id = old.id AND record_type = 3;"
+ "END;",
+ NULL, 0, &errmsg);
+ if (SQLITE_OK != ret) {
+ ERR("CREATE TRIGGER trg_schedule_del failed(%d:%s)", ret, errmsg);
+ sqlite3_free(errmsg);
+ }
+
+ // add trigger
+ ret = sqlite3_exec(__db,
+ "CREATE TRIGGER trg_schedule_del2 AFTER DELETE ON schedule_table "
+ " WHEN old.is_deleted = 0 AND old.calendar_id = (SELECT id FROM calendar_table WHERE id = old.calendar_id) "
+ " BEGIN "
+ " INSERT INTO deleted_table VALUES(old.id, old.type + 1, old.calendar_id, (SELECT ver FROM version_table) + 1, old.created_ver, old.original_event_id);"
+ " END;",
+ NULL, 0, &errmsg);
+ if (SQLITE_OK != ret) {
+ ERR("CREATE TRIGGER trg_schedule_del2 failed(%d:%s)", ret, errmsg);
+ sqlite3_free(errmsg);
+ }
+
+ // add trigger
+ ret = sqlite3_exec(__db,
+ "CREATE TRIGGER trg_schedule_del3 AFTER DELETE ON schedule_table "
+ " WHEN old.is_deleted = 1 AND old.calendar_id = (SELECT id FROM calendar_table WHERE id = old.calendar_id) "
+ " BEGIN "
+ " INSERT INTO deleted_table VALUES(old.id, old.type + 1, old.calendar_id, old.changed_ver, old.created_ver, old.original_event_id);"
+ " END;",
+ NULL, 0, &errmsg);
+ if (SQLITE_OK != ret) {
+ ERR("CREATE TRIGGER trg_schedule_del3 failed(%d:%s)", ret, errmsg);
+ sqlite3_free(errmsg);
+ }
+
+ // add field: original_event_id in deleted_table
+ ret = sqlite3_exec(__db, "ALTER TABLE deleted_table ADD COLUMN original_event_id INTEGER", NULL, 0, &errmsg);
+ if (SQLITE_OK != ret) {
+ ERR("ALTER TABLE deleted_table failed(%d:%s)", ret, errmsg);
+ sqlite3_free(errmsg);
+ }
+ /* ----------------------- end modified 2014/07/02
+ */
+ old_version = 102;
+ }
+ if (old_version == 102)
+ {
+ /* ----------------------- start modified 2014/10/24
+ * added field is_alldy on schedule_table
+ */
+
+ // add field: is_allday in deleted_table
+ ret = sqlite3_exec(__db, "ALTER TABLE schedule_table ADD COLUMN is_allday INTEGER DEFAULT 0", NULL, 0, &errmsg);
+ if (SQLITE_OK != ret) {
+ ERR("ALTER TABLE schedule_table failed(%d:%s)", ret, errmsg);
+ sqlite3_free(errmsg);
+ }
+ /* ----------------------- end modified 2014/10/24
+ */
+ old_version = 103;
+ }
+
+ if (old_version == 103)
+ {
+ ret = sqlite3_exec(__db, "DROP TABLE reminder_table", NULL, 0, &errmsg);
+ if (SQLITE_OK != ret) {
+ ERR("DROP TABLE reminder_table failed(%d:%s)", ret, errmsg);
+ sqlite3_free(errmsg);
+ }
+ old_version = 104;
+ }
+ if (old_version == 104)
+ {
+ ret = sqlite3_exec(__db, "ALTER TABLE alarm_table ADD COLUMN alarm_utime INTEGER", NULL, 0, &errmsg);
+ if (SQLITE_OK != ret) {
+ ERR("ALTER TABLE schedule_table failed(%d:%s)", ret, errmsg);
+ sqlite3_free(errmsg);
+ }
+ ret = sqlite3_exec(__db, "ALTER TABLE alarm_table ADD COLUMN alarm_datetime DATE", NULL, 0, &errmsg);
+ if (SQLITE_OK != ret) {
+ ERR("ALTER TABLE schedule_table failed(%d:%s)", ret, errmsg);
+ sqlite3_free(errmsg);
+ }
+ ret = sqlite3_exec(__db, "DROP VIEW allday_instance_view", NULL, 0, &errmsg);
+ if (SQLITE_OK != ret)
+ {
+ ERR("sqlite3_exec() failed: DROP VIEW allday_instance_view(%d) [%s]", ret, errmsg);
+ sqlite3_free(errmsg);
+ }
+ ret = sqlite3_exec(__db, "DROP VIEW allday_instance_view_extended", NULL, 0, &errmsg);
+ if (SQLITE_OK != ret)
+ {
+ ERR("sqlite3_exec() failed: DROP VIEW allday_instance_view_extended(%d) [%s]", ret, errmsg);
+ sqlite3_free(errmsg);
+ }
+ old_version = 105;
+ }
+
+ // update DB user_version
+ snprintf(query, sizeof(query), "PRAGMA user_version = %d", __USER_VERSION);
+ ret = sqlite3_exec(__db, query, NULL, 0, &errmsg);
+ if (SQLITE_OK != ret)
+ {
+ ERR("sqlite3_exec() failed(%d) [%s]", ret, errmsg);
+ sqlite3_free(errmsg);
+ }
+ db_util_close(__db);
+ __db = NULL;
+
+ LEAVE();
+ return CALENDAR_ERROR_NONE;
+}
+
+
*
*/
-long long int _convert_to_utime(char *date, char *time);
-int _convert_to_datetime(char *date, int *y, int *m, int *d);
+#ifndef __CAL_SERVER_UPDATE_H__
+#define __CAL_SERVER_UPDATE_H__
+
+int _cal_server_update(void);
+
+#endif //__CAL_SERVER_UPDATE_H__
+++ /dev/null
-#dlogutil -v threadtime -f /var/log/calendar-serviced.log -r 1000 -n 10 CALENDAR_SVC &
-
-/usr/bin/calendar-serviced &