FILE(GLOB SRCS src/*.c)
INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED glib-2.0 sqlite3 vconf dlog db-util alarm-service)
+pkg_check_modules(pkgs REQUIRED glib-2.0 sqlite3 vconf dlog db-util alarm-service icu-i18n appsvc)
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+libslp-calendar (0.1.13-36) unstable; urgency=low
+
+ * fixed: s1-6347.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-36
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Thu, 02 Aug 2012 22:22:13 +0900
+
+libslp-calendar (0.1.13-35) unstable; urgency=low
+
+ * fixed: s1-6577.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-35
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Wed, 01 Aug 2012 21:04:51 +0900
+
+libslp-calendar (0.1.13-34) unstable; urgency=low
+
+ * fixed: s1-6343.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-34
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Tue, 31 Jul 2012 20:01:00 +0900
+
+libslp-calendar (0.1.13-33) unstable; urgency=low
+
+ * added op code for location
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-33
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Tue, 31 Jul 2012 11:04:01 +0900
+
+libslp-calendar (0.1.13-32) unstable; urgency=low
+
+ * fixed s1-6157, 6184, 6213, 6499.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-32
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Mon, 30 Jul 2012 17:37:05 +0900
+
+libslp-calendar (0.1.13-31) unstable; urgency=low
+
+ * updated tag name.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-31
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Fri, 27 Jul 2012 10:27:17 +0900
+
+libslp-calendar (0.1.13-30) unstable; urgency=low
+
+ * fixed jira 6213.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-30
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Wed, 25 Jul 2012 13:09:20 +0900
+
+libslp-calendar (0.1.13-29) unstable; urgency=low
+
+ * modified jira issue. s1-6213.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-29
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Mon, 23 Jul 2012 17:44:42 +0900
+
+libslp-calendar (0.1.13-28) unstable; urgency=low
+
+ * added define before deprecated enum value.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-28
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Mon, 23 Jul 2012 13:32:18 +0900
+
+libslp-calendar (0.1.13-27) unstable; urgency=low
+
+ * updated changelog for obs.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-27
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Sat, 21 Jul 2012 10:40:l5 +0900
+
+libslp-calendar (0.1.13-26) unstable; urgency=low
+
+ * fixed todo condition query: time type was changed from long int to long long int.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-26
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Fri, 20 Jul 2012 15:31:09 +0900
+
+libslp-calendar (0.1.13-25) unstable; urgency=low
+
+ * updated changelog for obs.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-25
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Tue, 17 Jul 2012 17:44:14 +0900
+
+libslp-calendar (0.1.13-24) unstable; urgency=low
+
+ * fixed bug: stmt was not filled before step, added notify after deleting instance.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-24
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Mon, 16 Jul 2012 18:59:53 +0900
+
+libslp-calendar (0.1.13-23) unstable; urgency=low
+
+ * added api for get_todo_iter without period.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-23
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Mon, 16 Jul 2012 18:59:51 +0900
+
+libslp-calendar (0.1.13-22) unstable; urgency=low
+
+ * fixed updated deleted table in local calendar.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-22
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Tue, 10 Jul 2012 15:26:47 +0900
+
+libslp-calendar (0.1.13-21) unstable; urgency=low
+
+ * able to add db for past event, but not registered to alarmmgr.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-21
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Mon, 09 Jul 2012 17:45:22 +0900
+
+libslp-calendar (0.1.13-20) unstable; urgency=low
+
+ * fixed not showing repeat, alarm in db.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-20
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Thu, 05 Jul 2012 18:36:56 +0900
+
+libslp-calendar (0.1.13-19) unstable; urgency=low
+
+ * added type in instance struct.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-19
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Tue, 03 Jul 2012 15:26:31 +0900
+
+libslp-calendar (0.1.13-18) unstable; urgency=low
+
+ * updated until when once event.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-18
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Sun, 01 Jul 2012 21:40:19 +0900
+
+libslp-calendar (0.1.13-17) unstable; urgency=low
+
+ * 1. added instance table for allday and normal events. 2. added period search APIs 3. added test code.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-17
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Sun, 01 Jul 2012 16:31:43 +0900
+
+libslp-calendar (0.1.13-16) unstable; urgency=low
+
+ * clean deprecated code.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-16
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Wed, 20 Jun 2012 18:09:08 +0900
+
+libslp-calendar (0.1.13-15) unstable; urgency=low
+
+ * fixed bug: noty event.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-15
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Tue, 22 May 2012 16:39:46 +0900
+
+libslp-calendar (0.1.13-14) unstable; urgency=low
+
+ * fixed bug: change iter policy.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-14
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Fri, 18 May 2012 17:20:17 +0900
+
+libslp-calendar (0.1.13-13) unstable; urgency=low
+
+ * fixed bug: deleted sync.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-13
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Fri, 18 May 2012 14:50:38 +0900
+
+libslp-calendar (0.1.13-12) unstable; urgency=low
+
+ * fiex bug in get_changes.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-12
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Mon, 14 May 2012 17:18:56 +0900
+
+libslp-calendar (0.1.13-11) unstable; urgency=low
+
+ * fixed error query in get_changes.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-11
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Mon, 14 May 2012 15:28:57 +0900
+
+libslp-calendar (0.1.13-10) unstable; urgency=low
+
+ * fixed bug.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-10
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Thu, 10 May 2012 17:04:39 +0900
+
+libslp-calendar (0.1.13-9) unstable; urgency=low
+
+ * Add smartsearch API
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-9
+
+ -- Sunghyuk Lee <sunghyuk.lee@samsung.com> Thu, 10 May 2012 16:08:08 +0900
+
+libslp-calendar (0.1.13-8) unstable; urgency=low
+
+ * added is_deleted and event, todo changes..
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-8
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Tue, 08 May 2012 20:13:09 +0900
+
+libslp-calendar (0.1.13-7) unstable; urgency=low
+
+ * fixed duplicated sting.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-7
+
+ -- Sunghyuk Lee <sunghyuk.lee@samsung.com> Thu, 03 May 2012 16:46:34 +0900
+
+libslp-calendar (0.1.13-6) unstable; urgency=low
+
+ * modified import export vcs file apis.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-6
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Thu, 26 Apr 2012 21:43:50 +0900
+
+libslp-calendar (0.1.13-5) unstable; urgency=low
+
+ * Replace 1st paramter of calendar_svc_get_updated_schedules
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-5
+
+ -- Sunghyuk Lee <sunghyuk.lee@samsung.com> Thu, 26 Apr 2012 13:38:30 +0900
+
+libslp-calendar (0.1.13-4) unstable; urgency=low
+
+ * updated changelog and modified api name write schedules.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-4
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Wed, 25 Apr 2012 10:29:17 +0900
+
+libslp-calendar (0.1.13-3) unstable; urgency=low
+
+ * added quotied printable, rrule for vcal.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-3
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Mon, 23 Apr 2012 10:33:02 +0900
+
+libslp-calendar (0.1.13-2) unstable; urgency=low
+
+ * Change calendar_svc_end_trans parameter
+ * Fix timezone data getting bug
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-2
+
+ -- Sunghyuk Lee <sunghyuk.lee@samsung.com> Thu, 19 Apr 2012 20:14:15 +0900
+
+libslp-calendar (0.1.13-1) unstable; urgency=low
+
+ * Add calender versioning feature
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.13-1
+
+ -- Sunghyuk Lee <sunghyuk.lee@samsung.com> Mon, 16 Apr 2012 16:14:42 +0900
+
+libslp-calendar (0.1.12-23) unstable; urgency=low
+
+ * Set the repeat end date unless its until_type is date-time (N_SE 505)
+ * Fix a crash caused by timezone vconf
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.12-23
+
+ -- Sunghyuk Lee <sunghyuk.lee@samsung.com> Fri, 13 Apr 2012 09:24:22 +0900
+
+libslp-calendar (0.1.12-22) unstable; urgency=low
+
+ * Make the last modified time field read-only
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.12-22
+
+ -- Sunghyuk Lee <sunghyuk.lee@samsung.com> Thu, 05 Apr 2012 10:16:16 +0900
+
+libslp-calendar (0.1.12-21) unstable; urgency=low
+
+ * modified alarm description error (located wrong column)
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.12-21
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Mon, 02 Apr 2012 17:24:25 +0900
+
+libslp-calendar (0.1.12-20) unstable; urgency=low
+
+ * Add repeat until type
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.12-20
+
+ -- Sunghyuk Lee <sunghyuk.lee@samsung.com> Fri, 30 Mar 2012 18:47:39 +0900
+
+libslp-calendar (0.1.12-19) unstable; urgency=low
+
+ * modified todo and rrule crash.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.12-19
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Fri, 30 Mar 2012 10:05:05 +0900
+
+libslp-calendar (0.1.12-18) unstable; urgency=low
+
+ * Fix a bug on getting todo list and add order option
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.12-18
+
+ -- Sunghyuk Lee <sunghyuk.lee@samsung.com> Thu, 29 Mar 2012 13:53:17 +0900
+
+libslp-calendar (0.1.12-17) unstable; urgency=low
+
+ * modified icalendar decoding code.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.12-17
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Wed, 21 Mar 2012 10:00:00 +0900
+
libslp-calendar (0.1.12-16) unstable; urgency=low
- * release
- * Git: pkgs/l/libslp-calendar
+ * added calendar sensitivity enum values.
+ * Git: slp/pkgs/l/libslp-calendar
* Tag: libslp-calendar_0.1.12-16
- -- Jeesun Kim <iamjs.kim@samsung.com> Tue, 21 Feb 2012 10:00:00 +0900
\ No newline at end of file
+ -- Jeesun Kim <iamjs.kim@samsung.com> Tue, 21 Feb 2012 10:00:00 +0900
+
+libslp-calendar (0.1.12-15) unstable; urgency=low
+
+ * fiexed query for edit.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.12-15
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Fri, 17 Feb 2012 13:00:00 +0900
+
+libslp-calendar (0.1.12-14) unstable; urgency=low
+
+ * added alarm_description.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.12-14
+
+ -- Jeesun Kim <iamjs.kim@samsung.com> Fri, 10 Feb 2012 16:00:00 +0900
+
+libslp-calendar (0.1.12-13) unstable; urgency=low
+
+ * revise
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.12-13
+
+ -- Youngjae Shin <yj99.shin@samsung.com> Wed, 01 Feb 2012 10:16:13 +0900
+
+libslp-calendar (0.1.12-12) unstable; urgency=low
+
+ * change default calendar application pkg name
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.12-12
+
+ -- Youngjae Shin <yj99.shin@samsung.com> Thu, 26 Jan 2012 09:07:42 +0900
+
+libslp-calendar (0.1.12-11) unstable; urgency=low
+
+ * fix bug
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.12-11
+
+ -- Youngjae Shin <yj99.shin@samsung.com> Thu, 19 Jan 2012 11:33:45 +0900
+
+libslp-calendar (0.1.12-10) unstable; urgency=low
+
+ * revise noti
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.12-10
+
+ -- Youngjae Shin <yj99.shin@samsung.com> Mon, 16 Jan 2012 11:15:38 +0900
+
+libslp-calendar (0.1.12-9) unstable; urgency=low
+
+ * add type for calendar
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.12-9
+
+ -- Youngjae Shin <yj99.shin@samsung.com> Thu, 12 Jan 2012 17:04:34 +0900
+
+libslp-calendar (0.1.12-8) unstable; urgency=low
+
+ * clean up and change enum name
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.12-8
+
+ -- Youngjae Shin <yj99.shin@samsung.com> Fri, 06 Jan 2012 15:01:13 +0900
+
+libslp-calendar (0.1.12-7) unstable; urgency=low
+
+ * fix bug
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.12-7
+
+ -- Youngjae Shin <yj99.shin@samsung.com> Mon, 26 Dec 2011 18:44:07 +0900
+
+libslp-calendar (0.1.12-6) unstable; urgency=low
+
+ * fix bug
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.12-6
+
+ -- Youngjae Shin <yj99.shin@samsung.com> Thu, 22 Dec 2011 10:26:12 +0900
+
+libslp-calendar (0.1.12-5) unstable; urgency=low
+
+ * fix bugs
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.12-5
+
+ -- Youngjae Shin <yj99.shin@samsung.com> Wed, 14 Dec 2011 10:29:27 +0900
+
+libslp-calendar (0.1.12-4) unstable; urgency=low
+
+ * fix bugs
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.12-4
+
+ -- Youngjae Shin <yj99.shin@samsung.com> Thu, 08 Dec 2011 18:12:54 +0900
+
+libslp-calendar (0.1.12-3) unstable; urgency=low
+
+ * fix bugs
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.12-3
+
+ -- Youngjae Shin <yj99.shin@samsung.com> Thu, 08 Dec 2011 13:39:10 +0900
+
+libslp-calendar (0.1.12-2) unstable; urgency=low
+
+ * fix bugs
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.12-2
+
+ -- Youngjae Shin <yj99.shin@samsung.com> Thu, 08 Dec 2011 11:05:37 +0900
+
+libslp-calendar (0.1.12-1) unstable; urgency=low
+
+ * revise alarm(support multi alarms)
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.12-1
+
+ -- Youngjae Shin <yj99.shin@samsung.com> Mon, 05 Dec 2011 15:55:16 +0900
+
+libslp-calendar (0.1.11-4) unstable; urgency=low
+
+ * fix bug generated by "clean up"
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.11-4
+
+ -- Youngjae Shin <yj99.shin@samsung.com> Tue, 22 Nov 2011 13:45:44 +0900
+
+libslp-calendar (0.1.11-3) unstable; urgency=low
+
+ * add old files for immigration
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.11-3
+
+ -- Youngjae Shin <yj99.shin@samsung.com> Mon, 21 Nov 2011 14:50:38 +0900
+
+libslp-calendar (0.1.11-2) unstable; urgency=low
+
+ * fix bug generated by "clean up"
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.11-2
+
+ -- Youngjae Shin <yj99.shin@samsung.com> Mon, 21 Nov 2011 14:16:53 +0900
+
+libslp-calendar (0.1.11-1) unstable; urgency=low
+
+ * clean up
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.11-1
+
+ -- Youngjae Shin <yj99.shin@samsung.com> Sat, 19 Nov 2011 16:48:56 +0900
+
+libslp-calendar (0.1.10-35) unstable; urgency=low
+
+ * Fix bug : Update alarm info.
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-35
+
+ -- Taeho Kang <taeho84.kang@samsung.com> Tue, 15 Nov 2011 10:59:02 +0900
+
+libslp-calendar (0.1.10-34) unstable; urgency=low
+
+ * code cleanup and fix bug of using heynoti
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-34
+
+ -- Youngjae Shin <yj99.shin@samsung.com> Thu, 03 Nov 2011 20:46:44 +0900
+
+libslp-calendar (0.1.10-33) unstable; urgency=low
+
+ * Change lock timezone vconf
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-33
+
+ -- Taeho Kang <taeho84.kang@samsung.com> Sat, 30 Oct 2011 14:34:34 +0900
+
+libslp-calendar (0.1.10-32) unstable; urgency=low
+
+ * fixed multiple alarm problem
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-32
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Sat, 29 Oct 2011 14:34:34 +0900
+
+libslp-calendar (0.1.10-31) unstable; urgency=low
+
+ * add calendar multivalue list remove function
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-31
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Wed, 26 Oct 2011 15:25:05 +0900
+
+libslp-calendar (0.1.10-30) unstable; urgency=low
+
+ * add calendar multivalue list remove function
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-30
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Tue, 18 Oct 2011 13:09:51 +0900
+
+libslp-calendar (0.1.10-29) unstable; urgency=low
+
+ * noti type add for calendarbook update, basic test passed
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-29
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Sat, 08 Oct 2011 14:23:39 +0900
+
+libslp-calendar (0.1.10-28) unstable; urgency=low
+
+ * vcalendar convert error fixed, basic test passed
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-28
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Fri, 30 Sep 2011 17:39:41 +0900
+
+libslp-calendar (0.1.10-27) unstable; urgency=low
+
+ * all day event exception handling error fixed, basic test passed
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-27
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Wed, 21 Sep 2011 15:28:50 +0900
+
+libslp-calendar (0.1.10-26) unstable; urgency=low
+
+ * prevent error fixed, basic test passed
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-26
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Mon, 19 Sep 2011 20:24:46 +0900
+
+libslp-calendar (0.1.10-25) unstable; urgency=low
+
+ * default calendar error fixed in edit view
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-25
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Fri, 16 Sep 2011 10:16:22 +0900
+
+libslp-calendar (0.1.10-24) unstable; urgency=low
+
+ * pkg update
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-24
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Thu, 08 Sep 2011 12:02:00 +0900
+
+libslp-calendar (0.1.10-23) unstable; urgency=low
+
+ * monthly event count return, delete flag passed to ui
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-23
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Thu, 08 Sep 2011 11:01:30 +0900
+
+libslp-calendar (0.1.10-22) unstable; urgency=low
+
+ * recurrence exception operation error fixed, basic test passed
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-22
+
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Wed, 07 Sep 2011 19:14:56 +0900
+
+libslp-calendar (0.1.10-21) unstable; urgency=low
+
+ * add get delete flag value, basic test passed
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-21
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Wed, 07 Sep 2011 15:19:55 +0900
+
+libslp-calendar (0.1.10-20) unstable; urgency=low
+
+ * prevent error fixed, basic test passed
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-20
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Tue, 06 Sep 2011 09:04:32 +0900
+
+libslp-calendar (0.1.10-19) unstable; urgency=low
+
+ * all day event time setting error fixed, basic test passed
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-19
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Fri, 02 Sep 2011 16:02:08 +0900
+
+libslp-calendar (0.1.10-18) unstable; urgency=low
+
+ * delete error fixed(recurrence delete), TC passed, basic test passed
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-18
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Thu, 01 Sep 2011 18:00:32 +0900
+
+libslp-calendar (0.1.10-17) unstable; urgency=low
+
+ * delete error fixed(recurrence delete), TC passed, basic test passed
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-17
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Tue, 30 Aug 2011 16:58:05 +0900
+
+libslp-calendar (0.1.10-16) unstable; urgency=low
+
+ * release problem fixed(save error),vobject move to calendar-engine basic test passed
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-16
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Mon, 29 Aug 2011 14:01:22 +0900
+
+libslp-calendar (0.1.10-15) unstable; urgency=low
+
+ * change vcalendar encode type, basic test passed
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-15
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Wed, 24 Aug 2011 16:49:56 +0900
+
+libslp-calendar (0.1.10-14) unstable; urgency=low
+
+ * vcalendar length error fixed(release issue) , add protection code(MACRO) , TC passed, basic test passed
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-14
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Tue, 23 Aug 2011 14:06:33 +0900
+
+libslp-calendar (0.1.10-13) unstable; urgency=low
+
+ * dts error fixed, add location field for get_list
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-13
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Wed, 17 Aug 2011 19:42:52 +0900
+
+libslp-calendar (0.1.10-12) unstable; urgency=low
+
+ * remove duplicated delete not
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-12
+
+ -- Taeho Kang <taeho84.kang@samsung.com> Wed, 10 Aug 2011 22:00:38 +0900
+
+
+libslp-calendar (0.1.10-11) unstable; urgency=low
+
+ * remove dependency, pkg release
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-11
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Tue, 02 Aug 2011 16:04:16 +0900
+
+libslp-calendar (0.1.10-10) unstable; urgency=low
+
+ * add error check code
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-10
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Thu, 28 Jul 2011 18:05:21 +0900
+
+libslp-calendar (0.1.10-9) unstable; urgency=low
+
+ * prevent error fixed & api header rearrangement
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-9
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Tue, 26 Jul 2011 18:55:36 +0900
+
+libslp-calendar (0.1.10-8) unstable; urgency=low
+
+ * remove system()
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-8
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Wed, 20 Jul 2011 14:51:16 +0900
+
+libslp-calendar (0.1.10-7) unstable; urgency=low
+
+ * pkg update
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-7
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Mon, 18 Jul 2011 15:08:02 +0900
+
+libslp-calendar (0.1.10-6) unstable; urgency=low
+
+ * add exception handling for tz info search api
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-6
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Thu, 07 Jul 2011 11:33:11 +0900
+
+libslp-calendar (0.1.10-5) unstable; urgency=low
+
+ * add exception handling for tz info search api
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-5
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Thu, 07 Jul 2011 09:30:16 +0900
+
+libslp-calendar (0.1.10-4) unstable; urgency=low
+
+ * add tz info header
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-4
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Wed, 06 Jul 2011 18:55:50 +0900
+
+libslp-calendar (0.1.10-3) unstable; urgency=low
+
+ * pkg update(set tz info api error fixed)
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-3
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Wed, 06 Jul 2011 18:46:19 +0900
+
+libslp-calendar (0.1.10-2) unstable; urgency=low
+
+ * pkg update(sync b/s fixed)
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-2
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Wed, 06 Jul 2011 18:41:08 +0900
+
+libslp-calendar (0.1.10-1) unstable; urgency=low
+
+ * pkg update(Auto DST)
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.10-1
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Tue, 05 Jul 2011 15:15:08 +0900
+
+libslp-calendar (0.1.9-11) unstable; urgency=low
+
+ * Add calendar_id in get_list(), Add default calendar color in postinst
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.9-11
+
+ -- Taeho Kang <taeho84.kang@samsung.com> Fri, 24 Jun 2011 13:59:26 +0900
+
+libslp-calendar (0.1.9-10) unstable; urgency=low
+
+ * vobject, task convert error fixed
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.9-10
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Wed, 22 Jun 2011 16:43:11 +0900
+
+libslp-calendar (0.1.9-9) unstable; urgency=low
+
+ * Modify repeat end date error condition
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.9-9
+
+ -- Taeho Kang <taeho84.kang@samsung.com> Tue, 14 Jun 2011 17:02:59 +0900
+
+libslp-calendar (0.1.9-8) unstable; urgency=low
+
+ * Fix BS issue regarding meeting category
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.9-8
+
+ -- Taeho Kang <taeho84.kang@samsung.com> Thu, 02 Jun 2011 09:26:55 +0900
+
+libslp-calendar (0.1.9-7) unstable; urgency=low
+
+ * search text api modification
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.9-7
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Tue, 24 May 2011 11:38:51 +0900
+
+libslp-calendar (0.1.9-6) unstable; urgency=low
+
+ * alarm error fixed
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.9-6
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Tue, 17 May 2011 16:07:47 +0900
+
+libslp-calendar (0.1.9-5) unstable; urgency=low
+
+ * alarm error fixed
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.9-5
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Mon, 16 May 2011 10:22:45 +0900
+
+libslp-calendar (0.1.9-4) unstable; urgency=low
+
+ * vobject convert error fixed
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.9-4
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Thu, 12 May 2011 17:27:36 +0900
+
+libslp-calendar (0.1.9-3) unstable; urgency=low
+
+ * add list update api
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.9-3
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Wed, 11 May 2011 12:23:01 +0900
+
+libslp-calendar (0.1.9-2) unstable; urgency=low
+
+ * Fix recurrence counting bug
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.9-2
+
+ -- Taeho Kang <taeho84.kang@samsung.com> Mon, 02 May 2011 19:29:34 +0900
+
+libslp-calendar (0.1.9-1) unstable; urgency=low
+
+ * ui lockup issue fix
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.9-1
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Thu, 28 Apr 2011 18:43:44 +0900
+
+libslp-calendar (0.1.9-0) unstable; urgency=low
+
+ * voject-convert-error fixed
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.9-0
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Wed, 27 Apr 2011 18:49:49 +0900
+
+libslp-calendar (0.1.8-99) unstable; urgency=low
+
+ * month check error fixed
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-99
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Wed, 27 Apr 2011 14:10:32 +0900
+
+libslp-calendar (0.1.8-98) unstable; urgency=low
+
+ * Release 0.1.8-98
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-98
+
+ -- Taeho Kang <taeho84.kang@samsung.com> Wed, 27 Apr 2011 10:15:42 +0900
+
+libslp-calendar (0.1.8-97) unstable; urgency=low
+
+ * Release 0.1.8-97
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-97
+
+ -- Taeho Kang <taeho84.kang@samsung.com> Tue, 26 Apr 2011 14:44:56 +0900
+
+libslp-calendar (0.1.8-96) unstable; urgency=low
+
+ * Release 0.1.8-96
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-96
+
+ -- Taeho Kang <taeho84.kang@samsung.com> Mon, 25 Apr 2011 15:06:23 +0900
+
+libslp-calendar (0.1.8-95) unstable; urgency=low
+
+ * Release 0.1.8-95
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-95
+
+ -- Taeho Kang <taeho84.kang@samsung.com> Mon, 25 Apr 2011 14:48:51 +0900
+
+libslp-calendar (0.1.8-94) unstable; urgency=low
+
+ * Release 0.1.8-94
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-94
+
+ -- Taeho Kang <taeho84.kang@samsung.com> Mon, 25 Apr 2011 11:26:42 +0900
+
+libslp-calendar (0.1.8-93) unstable; urgency=low
+
+ * Release 0.1.8-93
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-93
+
+ -- Heungjae Jeong <hj98.jeong@samsung.com> Wed, 20 Apr 2011 20:09:05 +0900
+
+libslp-calendar (0.1.8-92) unstable; urgency=low
+
+ * Release 0.1.8-92
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-92
+
+ -- Taeho Kang <taeho84.kang@samsung.com> Wed, 20 Apr 2011 10:56:39 +0900
+
+libslp-calendar (0.1.8-91) unstable; urgency=low
+
+ * Release 0.1.8-91
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-91
+
+ -- Taeho Kang <taeho84.kang@samsung.com> Fri, 01 Apr 2011 08:52:50 +0900
+
+libslp-calendar (0.1.8-90) unstable; urgency=low
+
+ * Fix bug : alarm_init
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-90
+
+ -- Taeho Kang <taeho84.kang@samsung.com> Tue, 22 Mar 2011 13:58:37 +0900
+
+libslp-calendar (0.1.8-89) unstable; urgency=low
+
+ * Fix bug : alarm_init
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-89
+
+ -- Taeho Kang <taeho84.kang@samsung.com> Mon, 21 Mar 2011 17:19:09 +0900
+
+libslp-calendar (0.1.8-88) unstable; urgency=low
+
+ * Fix bug : alarm_init
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-88
+
+ -- Taeho Kang <taeho84.kang@samsung.com> Wed, 16 Mar 2011 16:59:05 +0900
+
+libslp-calendar (0.1.8-87) unstable; urgency=low
+
+ * Fix bug : alarm_init
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-87
+
+ -- Taeho Kang <taeho84.kang@samsung.com> Wed, 09 Mar 2011 14:49:36 +0900
+
+libslp-calendar (0.1.8-86) unstable; urgency=low
+
+ * timezone add
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-86
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Tue, 22 Feb 2011 12:52:22 +0900
+
+libslp-calendar (0.1.8-85) unstable; urgency=low
+
+ * prevent error fixed
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-85
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Wed, 16 Feb 2011 20:27:49 +0900
+
+libslp-calendar (0.1.8-84) unstable; urgency=low
+
+ * pkg update
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-84
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Wed, 16 Feb 2011 15:53:11 +0900
+
+libslp-calendar (0.1.8-83) unstable; urgency=low
+
+ * prevent error fixed, tz type add
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-83
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Tue, 15 Feb 2011 20:19:17 +0900
+
+libslp-calendar (0.1.8-82) unstable; urgency=low
+
+ * pc studio b/s error fix
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-82
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Wed, 02 Feb 2011 09:24:35 +0900
+
+libslp-calendar (0.1.8-81) unstable; urgency=low
+
+ * pkg update
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-81
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Thu, 27 Jan 2011 13:29:25 +0900
+
+libslp-calendar (0.1.8-80) unstable; urgency=low
+
+ * add account_id for calendar table
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-80
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Thu, 27 Jan 2011 13:23:26 +0900
+
+libslp-calendar (0.1.8-79) unstable; urgency=low
+
+ * add account_id for calendar table
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-79
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Thu, 27 Jan 2011 10:29:58 +0900
+
+libslp-calendar (0.1.8-78) unstable; urgency=low
+
+ * remove alarm fini api(active sync b/s issue fixed):
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-78
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Wed, 26 Jan 2011 14:55:30 +0900
+
+libslp-calendar (0.1.8-77) unstable; urgency=low
+
+ * setting b/s error fix - alarm fini api add
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-77
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Tue, 25 Jan 2011 18:13:26 +0900
+
+libslp-calendar (0.1.8-76) unstable; urgency=low
+
+ * tz name field added for timezone support
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-76
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Thu, 20 Jan 2011 20:13:28 +0900
+
+libslp-calendar (0.1.8-75) unstable; urgency=low
+
+ * priority field error fixed, max year value changed(2030->2037)
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-75
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Thu, 13 Jan 2011 11:50:39 +0900
+
+libslp-calendar (0.1.8-74) unstable; urgency=low
+
+ * alarm error fix
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-74
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Wed, 12 Jan 2011 11:00:50 +0900
+
+libslp-calendar (0.1.8-73) unstable; urgency=low
+
+ * TC make file modification
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-73
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Fri, 07 Jan 2011 11:31:23 +0900
+
+libslp-calendar (0.1.8-72) unstable; urgency=low
+
+ * delete account error fixed
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-72
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Thu, 06 Jan 2011 10:36:15 +0900
+
+libslp-calendar (0.1.8-71) unstable; urgency=low
+
+ * account id error fix
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-71
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Tue, 04 Jan 2011 14:50:31 +0900
+
+libslp-calendar (0.1.8-70) unstable; urgency=low
+
+ * alarm error fixed
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-70
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Wed, 29 Dec 2010 17:03:06 +0900
+
+libslp-calendar (0.1.8-69) unstable; urgency=low
+
+ * pkgs update
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-69
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Tue, 28 Dec 2010 16:09:41 +0900
+
+libslp-calendar (0.1.8-68) unstable; urgency=low
+
+ * fixed recurrence error
+ * Git: /slp/limo/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-68
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Tue, 28 Dec 2010 15:37:09 +0900
+
+libslp-calendar (0.1.8-67) unstable; urgency=low
+
+ * prepare limo contribution
+ * Git: /slp/limo/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-67
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Tue, 28 Dec 2010 15:22:15 +0900
+
+libslp-calendar (0.1.8-66) unstable; urgency=low
+
+ * prepare limo contribution
+ * Git: /slp/limo/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-66
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Mon, 27 Dec 2010 11:22:49 +0900
+
+libslp-calendar (0.1.8-65) unstable; urgency=low
+
+ * alarm enable
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-65
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Wed, 22 Dec 2010 14:39:24 +0900
+
+libslp-calendar (0.1.8-64) unstable; urgency=low
+
+ * fixed attendee's ct index return error
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-64
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Mon, 20 Dec 2010 21:28:49 +0900
+
+libslp-calendar (0.1.8-63) unstable; urgency=low
+
+ * vobject error fix, alarm type add
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-63
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Fri, 17 Dec 2010 18:18:42 +0900
+
+libslp-calendar (0.1.8-62) unstable; urgency=low
+
+ * postinst error fixed, default calendar added
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-62
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Wed, 15 Dec 2010 08:16:30 +0900
+
+libslp-calendar (0.1.8-61) unstable; urgency=low
+
+ * todo support
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-61
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Tue, 14 Dec 2010 10:03:15 +0900
+
+libslp-calendar (0.1.8-60) unstable; urgency=low
+
+ * pkg update
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-60
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Mon, 13 Dec 2010 11:14:11 +0900
+
+libslp-calendar (0.1.8-59) unstable; urgency=low
+
+ * pkg update
+ * Git: slp/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-59
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Thu, 09 Dec 2010 17:42:12 +0900
+
+libslp-calendar (0.1.8-58) unstable; urgency=low
+
+ * remove lucene dependency for limo
+ * Git: /slp/limo/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-58
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Thu, 09 Dec 2010 17:08:44 +0900
+
+libslp-calendar (0.1.8-57) unstable; urgency=low
+
+ * remove dependency for limo
+ * Git: /slp/limo/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-57
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Thu, 09 Dec 2010 16:53:23 +0900
+
+libslp-calendar (0.1.8-56) unstable; urgency=low
+
+ * pkg update for limo
+ * Git: /slp/limo/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-56
+
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Thu, 09 Dec 2010 16:42:02 +0900
+
+libslp-calendar (0.1.8-54) unstable; urgency=low
+
+ * pkg update
+ * Git: /slp/limo/pkgs/l/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-54
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Thu, 09 Dec 2010 14:34:03 +0900
+
+libslp-calendar (0.1.8-53) unstable; urgency=low
+
+ * removed vobject-service-dev in control
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-53
+
+ -- jeesun kim <iamjs.kim@samsung.com> Fri, 10 Dec 2010 17:07:25 +0900
+
+libslp-calendar (0.1.8-52) unstable; urgency=low
+
+ * pkg update
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-52
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Thu, 02 Dec 2010 18:11:32 +0900
+
+libslp-calendar (0.1.8-51) unstable; urgency=low
+
+ * multi calendar index add
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-51
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Thu, 25 Nov 2010 17:52:53 +0900
+
+libslp-calendar (0.1.8-50) unstable; urgency=low
+
+ * pkg update
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-50
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Tue, 23 Nov 2010 23:14:37 +0900
+
+libslp-calendar (0.1.8-49) unstable; urgency=low
+
+ * pkg update(dependency add-alarm)
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-49
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Tue, 23 Nov 2010 22:42:03 +0900
+
+libslp-calendar (0.1.8-48) unstable; urgency=low
+
+ * repeat_end_date bug fix, multi account bug fix
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-48
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Tue, 23 Nov 2010 10:55:48 +0900
+
+libslp-calendar (0.1.8-47) unstable; urgency=low
+
+ * doxygen update
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-47
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Fri, 12 Nov 2010 15:56:09 +0900
+
+libslp-calendar (0.1.8-46) unstable; urgency=low
+
+ * doxygen update
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-46
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Fri, 12 Nov 2010 15:22:05 +0900
+
+libslp-calendar (0.1.8-45) unstable; urgency=low
+
+ * sqlite3 add(dependency add)
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-45
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Thu, 11 Nov 2010 14:58:20 +0900
+
+libslp-calendar (0.1.8-44) unstable; urgency=low
+
+ * dependency removed
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-44
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Thu, 11 Nov 2010 11:53:10 +0900
+
+libslp-calendar (0.1.8-43) unstable; urgency=low
+
+ * recurrence module performance improvement, multi calendar/account implementation
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-43
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Wed, 10 Nov 2010 20:13:06 +0900
+
+libslp-calendar (0.1.8-42) unstable; urgency=low
+
+ * cq b/s issue fixed, log message modification
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-42
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Tue, 09 Nov 2010 14:52:54 +0900
+
+libslp-calendar (0.1.8-41) unstable; urgency=low
+
+ * convert time_t -> tm update(for week day)
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-41
+
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Tue, 09 Nov 2010 12:41:12 +0900
+
+libslp-calendar (0.1.8-40) unstable; urgency=low
+
+ * pkg update
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-40
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Mon, 08 Nov 2010 14:30:46 +0900
+
+libslp-calendar (0.1.8-39) unstable; urgency=low
+
+ * remove unused code
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-39
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Mon, 08 Nov 2010 14:17:56 +0900
+
+libslp-calendar (0.1.8-38) unstable; urgency=low
+
+ * old api remove
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-38
+
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Mon, 08 Nov 2010 11:33:57 +0900
+
+libslp-calendar (0.1.8-37) unstable; urgency=low
+
+ * add time convert api, fixed time convert error
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-37
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Fri, 05 Nov 2010 09:43:32 +0900
+
+libslp-calendar (0.1.8-36) unstable; urgency=low
+
+ * get updated list error fixed, add status for updated type
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-36
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Fri, 29 Oct 2010 11:40:17 +0900
+
+libslp-calendar (0.1.8-35) unstable; urgency=low
+
+ * attendee update error fix, location error fix
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-35
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Tue, 26 Oct 2010 13:45:57 +0900
+
+libslp-calendar (0.1.8-34) unstable; urgency=low
+
+ * sync status error fixed
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-34
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Tue, 26 Oct 2010 09:33:01 +0900
+
+libslp-calendar (0.1.8-33) unstable; urgency=low
+
+ * change param type , bool -> int
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-33
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Fri, 22 Oct 2010 11:09:01 +0900
+
+libslp-calendar (0.1.8-32) unstable; urgency=low
+
+ * package update, timezone api added
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-32
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Thu, 21 Oct 2010 14:22:07 +0900
+
+libslp-calendar (0.1.8-31) unstable; urgency=low
+
+ * 2days event error fixed, alarm field error fixed
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-31
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Wed, 20 Oct 2010 11:38:14 +0900
+
+libslp-calendar (0.1.8-30) unstable; urgency=low
+
+ * db owner change(script error fixed)
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-30
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Mon, 18 Oct 2010 14:26:14 +0900
+
+libslp-calendar (0.1.8-29) unstable; urgency=low
+
+ * recurrent util bug fixed
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-29
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Sat, 16 Oct 2010 08:26:01 +0900
+
+libslp-calendar (0.1.8-28) unstable; urgency=low
+
+ * recurrent util bug fixed
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-28
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Sat, 16 Oct 2010 08:16:58 +0900
+
+libslp-calendar (0.1.8-27) unstable; urgency=low
+ * calendar.pc file modification for compile error
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-27
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Fri, 15 Oct 2010 10:17:08 +0900
+
+libslp-calendar (0.1.8-26) unstable; urgency=low
+
+ * support new calendar api, remove old api
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-26
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Thu, 14 Oct 2010 14:08:17 +0900
+
+libslp-calendar (0.1.8-14) unstable; urgency=low
+
+ * support new calendar api, remove old api
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-14
+
+ -- heungjae jeong <hj98.jeong@samsung.com> Thu, 14 Oct 2010 14:03:40 +0900
+
+libslp-calendar (0.1.8-13) unstable; urgency=low
+
+ * added exception code in db.c
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-13
+
+ -- jeesun kim <iamjs.kim@samsung.com> Mon, 02 Aug 2010 17:46:23 +0900
+
+libslp-calendar (0.1.8-12) unstable; urgency=low
+
+ * added event_t for sg
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-12
+
+ -- jeesun kim <iamjs.kim@samsung.com> Fri, 30 Jul 2010 14:24:54 +0900
+
+libslp-calendar (0.1.8-11) unstable; urgency=low
+
+ * added new apis
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-11
+
+ -- jeesun kim <iamjs.kim@samsung.com> Fri, 30 Jul 2010 11:32:53 +0900
+
+libslp-calendar (0.1.8-10) unstable; urgency=low
+
+ * modified eventAddDeletedOccur
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-10
+
+ -- jeesun kim <iamjs.kim@samsung.com> Thu, 22 Jul 2010 10:09:24 +0900
+
+libslp-calendar (0.1.8-9) unstable; urgency=low
+
+ * added missing api(eventModLocation)
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-9
+
+ -- jeesun kim <iamjs.kim@samsung.com> Mon, 19 Jul 2010 17:54:50 +0900
+
+libslp-calendar (0.1.8-8) unstable; urgency=low
+
+ * added omitted api
+ * Git: /git/slp/pkgs/libslp-calendar
+ * Tag: libslp-calendar_0.1.8-8
+
+ -- jeesun kim <iamjs.kim@samsung.com> Fri, 16 Jul 2010 10:15:20 +0900
+
+libslp-calendar (0.1.8-7) unstable; urgency=low
+
+ * modified cmake to see internal header calenda.h
+ * Git: /git/slp2.0/slp2.0-pkgs/libslp-calendar-0
+ * Tag: libslp-calendar_0.1.8-7
+
+ -- jeesun kim <iamjs.kim@samsung.com> Wed, 14 Jul 2010 17:53:18 +0900
+
+libslp-calendar (0.1.8-6) unstable; urgency=low
+
+ * modified comment for doxygen
+ * Git: /git/slp2.0/slp2.0-pkgs/libslp-calendar-0
+ * Tag: libslp-calendar_0.1.8-6
+
+ -- jeesun kim <iamjs.kim@samsung.com> Wed, 14 Jul 2010 16:20:43 +0900
+
+libslp-calendar (0.1.8-5) unstable; urgency=low
+
+ * moved sglib to c file
+ * Git: /git/slp2.0/slp2.0-pkgs/libslp-calendar-0
+ * Tag: libslp-calendar_0.1.8-5
+
+ -- jeesun kim <iamjs.kim@samsung.com> Tue, 13 Jul 2010 13:40:23 +0900
+
+libslp-calendar (0.1.8-4) unstable; urgency=low
+
+ * delete sglib define from event header
+ * Git: /git/slp2.0/slp2.0-pkgs/libslp-calendar-0
+ * Tag: libslp-calendar_0.1.8-4
+
+ -- jeesun kim <iamjs.kim@samsung.com> Tue, 13 Jul 2010 11:01:05 +0900
+
+libslp-calendar (0.1.8-3) unstable; urgency=low
+
+ * modified "_"apis
+ * Git: /git/slp2.0/slp2.0-pkgs/libslp-calendar-0
+ * Tag: libslp-calendar_0.1.8-3
+
+ -- jeesun kim <iamjs.kim@samsung.com> Tue, 06 Jul 2010 08:39:54 +0900
+
+libslp-calendar (0.1.8-2) unstable; urgency=low
+
+ * modified _* api
+ * Git: /git/slp2.0/slp2.0-pkgs/libslp-calendar-0
+ * Tag: libslp-calendar_0.1.8-2
+
+ -- jeesun kim <iamjs.kim@samsung.com> Mon, 05 Jul 2010 20:20:37 +0900
+
+libslp-calendar (0.1.8-1) unstable; urgency=low
+
+ * modified dpkg option
+ * Git: /git/slp2.0/slp2.0-pkgs/libslp-calendar-0
+ * Tag: libslp-calendar_0.1.8-1
+
+ -- jeesun kim <iamjs.kim@samsung.com> Mon, 05 Jul 2010 17:09:57 +0900
+
+libslp-calendar (0.1.2-79) unstable; urgency=low
+
+ * removed warning
+ * Git: /git/slp2.0/slp2.0-pkgs/libslp-calendar-0
+ * Tag: libslp-calendar_0.1.2-79
+
+ -- jeesun kim <iamjs.kim@samsung.com> Thu, 24 Jun 2010 15:24:02 +0900
+
+libslp-calendar (0.1.2-78) unstable; urgency=low
+
+ * set hasUntill none 1 instead of zero
+ * Git: /git/slp2.0/slp2.0-pkgs/libslp-calendar-0
+ * Tag: libslp-calendar_0.1.2-78
+
+ -- Yongjun Wang <yj.wang@samsung.com> Thu, 17 Jun 2010 13:47:57 +0800
+
+libslp-calendar (0.1.2-77) unstable; urgency=low
+
+ * dac at journal file
+ * Git: /git/slp2.0/slp2.0-pkgs/libslp-calendar-0
+ * Tag: libslp-calendar_0.1.2-77
+
+ -- jeesun kim <iamjs.kim@samsung.com> Wed, 16 Jun 2010 10:04:10 +0900
+
+libslp-calendar (0.1.2-76) unstable; urgency=low
+
+ * modified VCal api
+ * Git: /git/slp2.0/slp2.0-pkgs/libslp-calendar-0
+ * Tag: libslp-calendar_0.1.2-76
+
+ -- jeesun kim <iamjs.kim@samsung.com> Mon, 31 May 2010 19:44:06 +0900
+
+libslp-calendar (0.1.2-75) unstable; urgency=low
+
+ * fix the bug that synced calendar events can't be showed in month view
+ * Git: /git/slp2.0/slp2.0-pkgs/libslp-calendar-0
+ * Tag: libslp-calendar_0.1.2-75
+
+ -- Yongjun Wang <yj.wang@samsung.com> Wed, 26 May 2010 15:42:43 +0800
+
+libslp-calendar (0.1.2-74) unstable; urgency=low
+
+ * fix the bug about calendar sync
+ * Git: /git/slp2.0/slp2.0-pkgs/libslp-calendar-0
+ * Tag: libslp-calendar_0.1.2-74
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Sun, 23 May 2010 10:34:46 +0900
+
+libslp-calendar (0.1.2-73) unstable; urgency=low
+
+ * fix the bug about calendar sync
+
+ -- Yongjun Wang <yj.wang@samsung.com> Fri, 21 May 2010 10:55:28 +0800
+
+libslp-calendar (0.1.2-72) unstable; urgency=low
+
+ * fix the bug about birthday event sync
+
+ -- Yongjun Wang <yj.wang@samsung.com> Fri, 21 May 2010 10:33:31 +0800
+
+libslp-calendar (0.1.2-71) unstable; urgency=low
+
+ * fix the bug of repeat end date
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Fri, 21 May 2010 09:56:56 +0800
+
+libslp-calendar (0.1.2-70) unstable; urgency=low
+
+ * fix the bug about unitll date
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Wed, 19 May 2010 10:54:58 +0800
+
+libslp-calendar (0.1.2-69) unstable; urgency=low
+
+ * fix bug about untill date
+ * Git: /git/slp2.0/slp2.0-pkgs/libslp-calendar-0
+ * Tag: libslp-calendar_0.1.2-69
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Thu, 13 May 2010 16:53:16 +0800
+
+libslp-calendar (0.1.2-68) unstable; urgency=low
+
+ * fix vcalendar bug
+ * Git: /git/slp2.0/slp2.0-pkgs/libslp-calendar-0
+ * Tag: libslp-calendar_0.1.2-68
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Wed, 12 May 2010 21:39:11 +0900
+
+libslp-calendar (0.1.2-67) unstable; urgency=low
+
+ * revise calendar recurrence API
+ * Git: /git/slp2.0/slp2.0-pkgs/libslp-calendar-0
+ * Tag: libslp-calendar_0.1.2-67
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Wed, 12 May 2010 08:32:52 +0900
+
+libslp-calendar (0.1.2-66) unstable; urgency=low
+
+ * revise calendar recurrence API
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Mon, 10 May 2010 17:46:46 +0800
+
+libslp-calendar (0.1.2-65) unstable; urgency=low
+
+ * fix the bug about vcalendar recurrence
+ * Git: /git/slp2.0/slp2.0-pkgs/libslp-calendar-0
+ * Tag: libslp-calendar_0.1.2-65
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Thu, 06 May 2010 09:36:12 +0900
+
+libslp-calendar (0.1.2-64) unstable; urgency=low
+
+ * fix the bug that list view cannot show all the events
+ * Git: /git/slp2.0/slp2.0-pkgs/libslp-calendar-0
+ * Tag: libslp-calendar_0.1.2-64
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Wed, 28 Apr 2010 20:01:11 +0900
+
+libslp-calendar (0.1.2-63) unstable; urgency=low
+
+ * update changelog
+ * Git: /git/slp2.0/slp2.0-pkgs/libslp-calendar-0
+ * Tag: libslp-calendar_0.1.2-63
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Tue, 27 Apr 2010 07:59:59 +0900
+
+libslp-calendar (0.1.2-62) unstable; urgency=low
+
+ * fix bug of vcalendar_convert_vfile_to_record API
+ * Git: /git/slp2.0/slp2.0-pkgs/libslp-calendar-0
+ * Tag: libslp-calendar_0.1.2-62
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Sat, 24 Apr 2010 10:16:45 +0900
+
+libslp-calendar (0.1.2-61) unstable; urgency=low
+
+ * vCalendar support X-FUNAMBOL-ALLDAY
+ * Git: /git/slp2.0/slp2.0-pkgs/libslp-calendar-0
+ * Tag: libslp-calendar_0.1.2-61
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Mon, 19 Apr 2010 14:50:09 +0800
+
+libslp-calendar (0.1.2-60) unstable; urgency=low
+
+ * support Deleteing Repeat events
+ * Git: /git/slp2.0/slp2.0-pkgs/libslp-calendar-0
+ * Tag: libslp-calendar_0.1.2-60
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Sun, 18 Apr 2010 09:46:30 +0900
+
+libslp-calendar (0.1.2-59) unstable; urgency=low
+
+ * support Deleteing Repeat events
+ * Git: /git/slp2.0/slp2.0-pkgs/libslp-calendar-0
+ * Tag: libslp-calendar-0_0.1.2-59
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Sun, 18 Apr 2010 09:29:35 +0900
+
+libslp-calendar (0.1.2-58) unstable; urgency=low
+
+ * support Deleteing Repeat events
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Tue, 13 Apr 2010 14:33:07 +0800
+
+libslp-calendar (0.1.2-57) unstable; urgency=low
+
+ * support RRULE for vCalendar 1.0
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Mon, 12 Apr 2010 15:50:14 +0800
+
+libslp-calendar (0.1.2-56) unstable; urgency=low
+
+ * fix vCalendar bugs when event type is anniversary
+ * Git: /git/slp2.0/slp2.0-pkgs/libslp-calendar-0
+ * Tag: libslp-calendar-0_0.1.2-56
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Tue, 06 Apr 2010 15:13:42 +0800
+
+libslp-calendar (0.1.2-55) unstable; urgency=low
+
+ * add get day list function
+ * Git: /git/slp2.0/slp2.0-pkgs/libslp-calendar-0
+ * Tag: libslp-calendar-0_0.1.2-55
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Mon, 05 Apr 2010 21:17:06 +0900
+
+libslp-calendar (0.1.2-54) unstable; urgency=low
+
+ * add monthly recurrence check
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Tue, 30 Mar 2010 18:02:53 +0900
+
+libslp-calendar (0.1.2-53) unstable; urgency=low
+
+ * fix recurrece API bugs
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Thu, 25 Mar 2010 10:16:14 +0800
+
+libslp-calendar (0.1.2-52) unstable; urgency=low
+
+ * exception handle for vcalendar attendee
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Wed, 24 Mar 2010 10:40:58 +0800
+
+libslp-calendar (0.1.2-51) unstable; urgency=low
+
+ * modify calendar_get_data_by_alarmId and eventModDescription
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Fri, 19 Mar 2010 19:37:12 +0900
+
+libslp-calendar (0.1.2-50) unstable; urgency=low
+
+ * add globalMeetingId field in exception event table
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Thu, 18 Mar 2010 13:54:16 +0900
+
+libslp-calendar (0.1.2-49) unstable; urgency=low
+
+ * reflect modified sync_db APIs
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Mon, 15 Mar 2010 19:48:16 +0900
+
+libslp-calendar (0.1.2-48) unstable; urgency=low
+
+ * modify value of event category in calendar-engine's header
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Thu, 11 Mar 2010 18:01:13 +0900
+
+libslp-calendar (0.1.2-47) unstable; urgency=low
+
+ * fix the bug of eventAddException and _s API
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Thu, 11 Mar 2010 10:57:12 +0900
+
+libslp-calendar (0.1.2-46) unstable; urgency=low
+
+ * add calendar_insert_data_for_test_by_category API
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Tue, 09 Mar 2010 17:22:05 +0900
+
+libslp-calendar (0.1.2-45) unstable; urgency=low
+
+ * add calendar_get_all_data_list_by_category API
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Tue, 09 Mar 2010 16:02:57 +0900
+
+libslp-calendar (0.1.2-44) unstable; urgency=low
+
+ * add exception handling before using strdup
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Mon, 08 Mar 2010 10:16:07 +0900
+
+libslp-calendar (0.1.2-43) unstable; urgency=low
+
+ * add some APIs for "change calendar"
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Wed, 03 Mar 2010 19:54:49 +0900
+
+libslp-calendar (0.1.2-42) unstable; urgency=low
+
+ * change vcalendar file path to "/opt/share"
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Thu, 25 Feb 2010 08:48:04 +0900
+
+libslp-calendar (0.1.2-41) unstable; urgency=low
+
+ * change vcalendar file path to /opt/share/vcs"
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Tue, 23 Feb 2010 15:14:12 +0800
+
+libslp-calendar (0.1.2-40) unstable; urgency=low
+
+ * fix the defects about vcalendar file name duplicated
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Mon, 22 Feb 2010 16:54:04 +0800
+
+libslp-calendar (0.1.2-39) unstable; urgency=low
+
+ * apply sync-db for interacting with syncml
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Mon, 22 Feb 2010 14:46:26 +0900
+
+libslp-calendar (0.1.2-38) unstable; urgency=low
+
+ * add new include directory for calendar-engine-include-dev
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Mon, 22 Feb 2010 11:19:31 +0900
+
+libslp-calendar (0.1.2-37) unstable; urgency=low
+
+ * generate initial DB file in /opt/dbspace
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Fri, 19 Feb 2010 09:21:35 +0900
+
+libslp-calendar (0.1.2-36) unstable; urgency=low
+
+ * add calendar_insert_data_for_test API for DB test in process
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Thu, 18 Feb 2010 17:36:19 +0900
+
+libslp-calendar (0.1.2-35) unstable; urgency=low
+
+ * add completionDate field in event structure for task
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Thu, 18 Feb 2010 09:07:34 +0900
+
+libslp-calendar (0.1.2-34) unstable; urgency=low
+
+ * fix the bug(eventSetIsAllDayEvent)
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Wed, 17 Feb 2010 09:31:40 +0900
+
+libslp-calendar (0.1.2-33) unstable; urgency=low
+
+ * add isComplete field in Event
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Tue, 09 Feb 2010 12:14:23 +0900
+
+libslp-calendar (0.1.2-32) unstable; urgency=low
+
+ * add calendar_get_data_counts_by_category API
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Mon, 08 Feb 2010 19:53:32 +0900
+
+libslp-calendar (0.1.2-31) unstable; urgency=low
+
+ * add dbg-package
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Sat, 06 Feb 2010 17:03:59 +0900
+
+libslp-calendar (0.1.2-30) unstable; urgency=low
+
+ * fix the bug(calendar_free_all_data API) and apply autoincrement to primary key
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Thu, 04 Feb 2010 22:26:55 +0900
+
+libslp-calendar (0.1.2-29) unstable; urgency=low
+
+ * remove dummy node in linked-list
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Wed, 03 Feb 2010 23:37:42 +0900
+
+libslp-calendar (0.1.2-28) unstable; urgency=low
+
+ * fix the bug(calendar_update_data API)
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Wed, 03 Feb 2010 18:11:30 +0900
+
+libslp-calendar (0.1.2-27) unstable; urgency=low
+
+ * fix the bug(calendar_update_data API)
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Wed, 03 Feb 2010 18:05:54 +0900
+
+libslp-calendar (0.1.2-26) unstable; urgency=low
+
+ * add alarm id field to event table for alarm ring
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Wed, 03 Feb 2010 15:47:23 +0900
+
+libslp-calendar (0.1.2-25) unstable; urgency=low
+
+ * modify eventAddxxx() APIs and calendar_free_data API
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Wed, 03 Feb 2010 14:29:53 +0900
+
+libslp-calendar (0.1.2-24) unstable; urgency=low
+
+ * fix the bug(calendar_insert_data API)
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Tue, 02 Feb 2010 20:43:42 +0900
+
+libslp-calendar (0.1.2-23) unstable; urgency=low
+
+ * fix the bug(eventSetTimeZone API)
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Sun, 31 Jan 2010 14:17:00 +0900
+
+libslp-calendar (0.1.2-22) unstable; urgency=low
+
+ * reupload pkg because of build machine's problem
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Fri, 29 Jan 2010 20:01:34 +0900
+
+libslp-calendar (0.1.2-21) unstable; urgency=low
+
+ * add eventRemoveAllxxx APIs
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Fri, 29 Jan 2010 14:47:42 +0900
+
+libslp-calendar (0.1.2-20) unstable; urgency=low
+
+ * add notification API using dbus
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Fri, 29 Jan 2010 10:03:06 +0900
+
+libslp-calendar (0.1.2-19) unstable; urgency=low
+
+ * modify enum AttendeeStatus
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Thu, 28 Jan 2010 14:16:38 +0900
+
+libslp-calendar (0.1.2-18) unstable; urgency=low
+
+ * add removing string API(eventRemovexxx())
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Thu, 28 Jan 2010 10:22:41 +0900
+
+libslp-calendar (0.1.2-17) unstable; urgency=low
+
+ * modify calendar event API
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Wed, 27 Jan 2010 20:30:56 +0900
+
+libslp-calendar (0.1.2-16) unstable; urgency=low
+
+ * modify data structure of RecurDateList and DeletedOccurList
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Wed, 27 Jan 2010 14:09:17 +0900
+
+libslp-calendar (0.1.2-15) unstable; urgency=low
+
+ * remove prefix "SLP"
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Wed, 27 Jan 2010 13:31:38 +0900
+
+libslp-calendar (0.1.2-14) unstable; urgency=low
+
+ * add SLP_calendar_get_range_data_list_by_time API
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Tue, 26 Jan 2010 17:49:45 +0900
+
+libslp-calendar (0.1.2-13) unstable; urgency=low
+
+ * reinsert old data structure
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Tue, 26 Jan 2010 10:29:54 +0900
+
+libslp-calendar (0.1.2-12) unstable; urgency=low
+
+ * add doxygen
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Mon, 25 Jan 2010 22:36:46 +0900
+
+libslp-calendar (0.1.2-11) unstable; urgency=low
+
+ * add eventSetAttendeeList API
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Mon, 25 Jan 2010 13:53:42 +0900
+
+libslp-calendar (0.1.2-10) unstable; urgency=low
+
+ * add vcalendar APIs
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Sat, 23 Jan 2010 21:05:09 +0800
+
+libslp-calendar (0.1.2-9) unstable; urgency=low
+
+ * modify data structure and API for interacting with SEVEN
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Fri, 22 Jan 2010 23:27:15 +0900
+
+libslp-calendar (0.1.2-8) unstable; urgency=low
+
+ * use libslp-db-util-dev
+
+ -- Sangjung Woo <sangjung.woo@samsung.com> Thu, 21 Jan 2010 09:09:25 +0900
+
+libslp-calendar (0.1.2-7) unstable; urgency=low
+
+ * change location of database(from /root to /opt/dbspace)
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Thu, 14 Jan 2010 09:06:31 +0900
+
+libslp-calendar (0.1.2-6) unstable; urgency=low
+
+ * modify for interaction with SEVEN
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Tue, 05 Jan 2010 14:58:53 +0900
+
+libslp-calendar (0.1.2-5) unstable; urgency=low
+
+ * fix the bug (H0100075687)
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Fri, 01 Jan 2010 13:39:38 +0900
+
+libslp-calendar (0.1.2-4) unstable; urgency=low
+
+ * remove SLP_alarm feature
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Thu, 24 Dec 2009 11:09:26 +0900
+
+libslp-calendar (0.1.2-3) unstable; urgency=low
+
+ * modify structure of source tree
+
+ -- Deokjin Kim <deokjin81.kim@samsung.com> Thu, 10 Dec 2009 17:35:35 +0900
+
+libslp-calendar (0.1.2-2) unstable; urgency=low
+
+ * fix
+
+ -- Jihoon Kim <jihoon48.kim@samsung.com> Fri, 20 Nov 2009 21:04:40 +0900
+
+libslp-calendar (0.1.2-1) unstable; urgency=low
+
+ * fix installing pkgconfi
+
+ -- Jihoon Kim <jihoon48.kim@samsung.com> Fri, 20 Nov 2009 20:47:46 +0900
+
+libslp-calendar (0.1.2) unstable; urgency=low
+
+ * change control file
+
+ -- Jihoon Kim <jihoon48.kim@samsung.com> Fri, 20 Nov 2009 19:50:13 +0900
+
+libx1-calendar (0.1.1) unstable; urgency=low
+
+ * rename X1 -> SLP
+
+ -- Jihoon Kim <jihoon48.kim@samsung.com> Fri, 20 Nov 2009 19:27:38 +0900
+
+libx1-calendar (0.1.0) unstable; urgency=low
+
+ * Initial Release.
+
+ -- Jihoon Kim <jihoon48.kim@samsung.com> Mon, 16 Nov 2009 15:40:49 +0900
Section: devel
Priority: extra
Maintainer: Youngjae Shin <yj99.shin@samsung.com> , Sunghyuk Lee <sunghyuk.lee@samsung.com>, Jeesun Kim <iamjs.kim@samsung.com>
-Build-Depends: debhelper (>= 5), libslp-db-util-dev, libsqlite3-dev, libglib2.0-dev, dlog-dev, libvconf-dev, libvconf-keys-dev, libalarm-dev
+Build-Depends: debhelper (>= 5), libslp-db-util-dev, libsqlite3-dev, libglib2.0-dev, dlog-dev, libvconf-dev, libvconf-keys-dev, libalarm-dev, libicu-dev, libappsvc-dev
Standards-Version: 3.7.2
Package: libslp-calendar-dev
if [ "$USER" = "root" ]
then
chown root:root /usr/lib/libcalendar-service.so.*
- chown :6003 /opt/data/calendar-svc/.CALENDAR_SVC_*
+ chown :6003 /opt/data/calendar-svc/.CALENDAR_SVC_*
chown :6003 /opt/dbspace/.calendar-svc.db
chown :6003 /opt/dbspace/.calendar-svc.db-journal
+ vconftool set -t int db/calendar/timezone_on_off 0 -g 6003
+ vconftool set -t string db/calendar/timezone_path "Asia/Seoul" -g 6003
fi
chmod 660 /opt/dbspace/.calendar-svc.db
#ifndef __CALENDAR_SVC_H__
#define __CALENDAR_SVC_H__
+#ifndef DEPRECATED
+#define DEPRECATED __attribute__ ((deprecated))
+#endif
+
+
/**
* @defgroup CALENDAR_SVC Calendar Service
*/
*/
#include <glib.h>
+#include <stdbool.h>
+#include <stdint.h>
#ifdef __cplusplus
extern "C" {
*/
/**
- * This enumeration defines schedule category.
- */
-typedef enum
-{
- CAL_SCH_NONE=0, /**< None type */
- CAL_SCH_APPOINTMENT, /**< appointment category */
- CAL_SCH_IMPORTANT, /**< important category */
- CAL_SCH_SPECIAL_OCCASION, /**< anniversary category */
- CAL_SCH_BIRTHDAY, /**< birthday category */
- CAL_SCH_HOLIDAY, /**< holiday category */
- CAL_SCH_PRIVATE, /**< private category */
- CAL_SCH_BUSSINESS, /**< bussiness category */
-} cal_sch_category_t;
-
-/**
* This enumeration date type, sun or lunar.
*/
typedef enum
* Ex. remindTick = 1, remindTickUnit = CAL_SCH_TIME_UNIT_MIN, Organizer alarms
* 1 minute before schedule starting time.
*/
-typedef enum
+typedef enum /* use with *60 */
{
CAL_SCH_TIME_UNIT_OFF = -1, /**< off */
- CAL_SCH_TIME_UNIT_MIN = 0, /**< Minute */
- CAL_SCH_TIME_UNIT_HOUR, /**< Hour */
- CAL_SCH_TIME_UNIT_DAY, /**< Day */
- CAL_SCH_TIME_UNIT_WEEK, /**< Week */
+ 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_t;
typedef enum
{
CALS_REPEAT_UNTIL_TYPE_NONE = 0, /**< Repeat endlessly */
- CALS_REPEAT_UNTIL_TYPE_DATETIME, /**< Repeat until the date-time which the CAL_VALUE_GMT_REPEAT_END_DATE indicates */
CALS_REPEAT_UNTIL_TYPE_COUNT, /**< Repeat number of times, which the CAL_VALUE_INT_REPEAT_OCCURRENCES indicates */
+ CALS_REPEAT_UNTIL_TYPE_DATETIME, /**< Repeat until the date-time which the CAL_VALUE_GMT_REPEAT_END_DATE indicates */
} cal_repeat_until_type_t;
/**
/**
+ * Deprecated.
+ */
+#define EVENT_ATTENDEE_PENDING_AT_STATUS EVENT_ATTENDEE_NEEDS_ACTION_AT_STATUS
+
+/**
* This enumeration defines event attendee's type .
*/
typedef enum
*/
typedef enum
{
- EVENT_PRIORITY_LOW =0,
+ EVENT_PRIORITY_LOW = 0,
EVENT_PRIORITY_NORMAL,
EVENT_PRIORITY_HIGH,
} cal_priority_type_t;
+enum {
+ CALS_TODO_PRIORITY_NONE = 0x01,
+ CALS_TODO_PRIORITY_HIGH = 0x02,
+ CALS_TODO_PRIORITY_MID = 0x04,
+ CALS_TODO_PRIORITY_LOW = 0x08,
+};
+
/**
* This enumeration defines status.
* (related with CAL_VALUE_INT_TASK_STATUS)
*/
+
+#define CALS_STATUS_NONE CALS_EVENT_STATUS_NONE
typedef enum
{
- CALS_STATUS_NONE =0,
- CALS_EVENT_STATUS_TENTATIVE,
- CALS_EVENT_STATUS_CONFIRMED,
- CALS_EVENT_STATUS_CANCELLED,
- CALS_TODO_STATUS_NEEDS_ACTION,
- CALS_TODO_STATUS_COMPLETED,
- CALS_TODO_STATUS_IN_PROCESS,
- CALS_TODO_STATUS_CANCELLED,
+ CALS_EVENT_STATUS_NONE = 0x0001,
+ CALS_EVENT_STATUS_TENTATIVE = 0x0002,
+ CALS_EVENT_STATUS_CONFIRMED = 0x0004,
+ CALS_EVENT_STATUS_CANCELLED = 0x0008,
+ CALS_TODO_STATUS_NONE = 0x0100,
+ CALS_TODO_STATUS_NEEDS_ACTION = 0x0200,
+ CALS_TODO_STATUS_IN_PROCESS = 0x0400,
+ CALS_TODO_STATUS_CANCELLED = 0x0800,
+ CALS_TODO_STATUS_COMPLETED = 0x1000,
} cals_status_t;
/**
} cals_calendar_store_type;
/**
+ * This enumeration defines todo list ordering type.
+ */
+typedef enum
+{
+ CALS_TODO_LIST_ORDER_END_DATE = 0,
+ CALS_TODO_LIST_ORDER_PRIORITY,
+ CALS_TODO_LIST_ORDER_STATUS,
+} cals_todo_list_order_t;
+
+/**
* This enumeration defines calendar sensitivity.
* (related with CAL_VALUE_INT_SENSITIVITY)
*/
CALS_SENSITIVITY_CONFIDENTIAL,
} cals_sensitivity_t;
+/**
+ * This enumeration defines updated type
+ * (related with CALS_STRUCT_UPDATED_INT_TYPE)
+ */
+enum cals_updated_type {
+ CALS_UPDATED_TYPE_INSERTED = 0x0,
+ CALS_UPDATED_TYPE_MODIFIED,
+ CALS_UPDATED_TYPE_DELETED,
+};
+
+/**
+ * Flags to specify what fields will be searched by search API
+ */
+enum SEARCHFIELD {
+ CALS_SEARCH_FIELD_NONE = 0,
+ CALS_SEARCH_FIELD_SUMMARY = 1<<0,
+ CALS_SEARCH_FIELD_DESCRIPTION = 1<<2,
+ CALS_SEARCH_FIELD_LOCATION = 1<<3,
+ CALS_SEARCH_FIELD_ATTENDEE = 1<<4,
+};
/**
* @}
* calendar_svc_struct_new's argument
*/
#define CAL_STRUCT_TYPE /**< CAL_STRUCT_TYPE */
-#define CAL_STRUCT_CALENDAR "calendar" /**< CAL_STRUCT_CALENDAR */
-#define CAL_STRUCT_SCHEDULE "schedule" /**< CAL_STRUCT_SCHEDULE */
-#define CAL_STRUCT_TODO "todo" /**< CAL_STRUCT_TASK */
+#define CAL_STRUCT_CALENDAR "calendar" /**< CAL_STRUCT_CALENDAR */
+#define CAL_STRUCT_SCHEDULE "schedule" /**< CAL_STRUCT_SCHEDULE */
+#define CAL_STRUCT_TODO "todo" /**< CAL_STRUCT_TASK */
#define CAL_STRUCT_TIMEZONE "timezone" /**< CAL_STRUCT_TIMEZONE */
+#define CAL_STRUCT_UPDATED "updated" /**< CAL_STRUCT_UPDATED */
+#define CALS_STRUCT_PERIOD_NORMAL_ONOFF "period_normal_onoff"
+#define CALS_STRUCT_PERIOD_ALLDAY_ONOFF "period_allday_onoff"
+#define CALS_STRUCT_PERIOD_NORMAL_BASIC "period_normal_basic"
+#define CALS_STRUCT_PERIOD_ALLDAY_BASIC "period_allday_basic"
+#define CALS_STRUCT_PERIOD_NORMAL_OSP "period_normal_osp"
+#define CALS_STRUCT_PERIOD_ALLDAY_OSP "period_allday_osp"
+#define CALS_STRUCT_PERIOD_NORMAL_LOCATION "period_normal_location"
+#define CALS_STRUCT_PERIOD_ALLDAY_LOCATION "period_allday_location"
+#define CALS_STRUCT_PERIOD_NORMAL_ALARM "period_normal_alarm"
// id for all data read
#define ALL_ACCOUNT_ID 0
#define LOCAL_ACCOUNT_ID -1
#define LOCAL_ALL_CALENDAR -1
+/* start deprecated */
#define DEFAULT_CALENDAR_ID 1
+/* end deprecated, replace DEFAULT_EVENT_CALENDAR_ID */
+
+#define DEFAULT_EVENT_CALENDAR_ID 1
+#define DEFAULT_TODO_CALENDAR_ID 2
+
+// added val 2012.07.30
+#define CALS_TODO_NO_DUE_DATE INT64_MAX
/**
* @}
* @addtogroup common
* @{
* brief
- * calendar_svc_value_xxx()'s argument
+ * calendar_svc_struct_xxx()'s argument
*/
#define CAL_TABLE_INT_INDEX "index"
#define CAL_TABLE_TXT_CALENDAR_ID "calendar_id"
* @addtogroup common
* @{
* brief
- * calendar_svc_value_xxx()'s argument
+ * calendar_svc_struct_xxx()'s argument
+ */
+#define CALS_STRUCT_UPDATED_INT_VERSION "version" /**< Version of schedule */
+#define CALS_STRUCT_UPDATED_INT_TYPE "updated_type" /**< Type of schedule update #cals_updated_type */
+#define CALS_STRUCT_UPDATED_INT_ID "updated_id" /**< id of updated schedule */
+/**
+ * @}
+ */
+
+
+
+/**
+ * @addtogroup common
+ * @{
+ * brief
+ * calendar_svc_struct_xxx()'s argument
*/
#define CAL_VALUE_INT_INDEX "id" /**< Record index */
#define CAL_VALUE_INT_ACCOUNT_ID "account_id" /**< account id */
#define CAL_VALUE_INT_TYPE "type" /**< Calendar component type */
-#define CAL_VALUE_INT_CATEGORY "category" /**< Category of schedule #cal_sch_category_t */
+#define CAL_VALUE_TXT_CATEGORIES "categories" /**< Category of schedule */
+#define CAL_VALUE_TXT_EXDATE "exdate" /**< Exdate */
#define CAL_VALUE_TXT_SUMMARY "summary" /**< Summary, appointment, task: subject, birthday:Name */
#define CAL_VALUE_TXT_DESCRIPTION "description" /**< Description,appointment, task: description, anniversary,holiday:occasion*/
#define CAL_VALUE_TXT_LOCATION "location" /**< Location */
-#define CAL_VALUE_INT_ALL_DAY_EVENT "all_day_event" /**< All day event flag */
-#define CAL_VALUE_GMT_START_DATE_TIME "start_date_time" /**< schedule:start time, anniv,holiday,birthday,memo,todo: date */
-#define CAL_VALUE_GMT_END_DATE_TIME "end_date_time" /**< end time */
-#define CAL_VALUE_INT_REPEAT_TERM "repeat_item" /**< Repeat term */
-#define CAL_VALUE_INT_REPEAT_INTERVAL "repeat_interval" /**< Interval of repeat term */
-#define CAL_VALUE_INT_REPEAT_UNTIL_TYPE "repeat_until_type" /**< Repeat until type */
-#define CAL_VALUE_INT_REPEAT_OCCURRENCES "repeat_occurrences" /**< occurrences of repeat */
-#define CAL_VALUE_GMT_REPEAT_END_DATE "repeat_end_date" /**< End date for repeat */
-#define CAL_VALUE_INT_SUN_MOON "sun_moon" /**< Using sun or lunar calendar */
-#define CAL_VALUE_INT_WEEK_START "week_start" /**< Start day of a week */
-#define CAL_VALUE_TXT_WEEK_FLAG "week_flag" /**< 1001000(sun,wed) Indicate which day is select in a week */
-#define CAL_VALUE_INT_DAY_DATE "day_date" /**< 0- for weekday(sun,mon,etc.), 1- for specific day(1,2.. Etc) */
-#define CAL_VALUE_GMT_LAST_MODIFIED_TIME "last_modified_time" /**< for PC Sync */
#define CAL_VALUE_INT_MISSED "missed" /**< Miss alarm flag */
#define CAL_VALUE_INT_TASK_STATUS "task_status" /**< current task status #cals_status_t */
#define CAL_VALUE_INT_PRIORITY "priority" /**< Priority */
#define CAL_VALUE_INT_CALENDAR_INDEX "calendar_index" /**< specific calendar id - will be remove */
#define CAL_VALUE_DBL_LATITUDE "latitude" /**< latitude */
#define CAL_VALUE_DBL_LONGITUDE "longitude" /**< longitude */
-#define CAL_VALUE_INT_IS_DELETED "is_deleted" /**< readonly */
-#define CAL_VALUE_TXT_TZ_NAME "tz_name" /**< tz file name */
-#define CAL_VALUE_TXT_TZ_CITY_NAME "tz_city_name" /**< tz city name */
#define CAL_VALUE_INT_EMAIL_ID "email_id" /**< email id */
#define CAL_VALUE_INT_AVAILABILITY "availability"
-#define CAL_VALUE_GMT_CREATED_DATE_TIME "created_date_time"
-#define CAL_VALUE_GMT_COMPLETED_DATE_TIME "completed_date_time"
+#define CAL_VALUE_LLI_CREATED_TIME "created_time"
+#define CAL_VALUE_LLI_COMPLETED_TIME "completed_time"
#define CAL_VALUE_INT_PROGRESS "progress"
+#define CAL_VALUE_INT_IS_DELETED "is_deleted"/**< In deleting action, this is set 1 and will be deleted after sync */
+
+#define CAL_VALUE_INT_CAL_TYPE "cal_type" /**< deprecated */
/**
* @}
* attendee cal_value's detail field
*/
#define CAL_VALUE_LST_ATTENDEE_LIST "attendee_list" /**< attendee's detail information set */
-#define CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME "attendee_name" /**< attendee_name */
+#define CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME "attendee_name" /**< attendee_name */
#define CAL_VALUE_TXT_ATTENDEE_DETAIL_EMAIL "attendee_email" /**< attendee_email */
#define CAL_VALUE_TXT_ATTENDEE_DETAIL_NUMBER "attendee_number" /**< attendee_email */
-#define CAL_VALUE_INT_ATTENDEE_DETAIL_STATUS "attendee_status" /**< #cal_event_attendee_status_type_t */
-#define CAL_VALUE_INT_ATTENDEE_DETAIL_TYPE "attendee_type" /**< #cal_event_attendee_type_t */
+#define CAL_VALUE_INT_ATTENDEE_DETAIL_STATUS "attendee_status" /**< #cal_event_attendee_status_type_t */
+#define CAL_VALUE_INT_ATTENDEE_DETAIL_TYPE "attendee_type" /**< #cal_event_attendee_type_t */
#define CAL_VALUE_INT_ATTENDEE_DETAIL_CT_INDEX "attendee_ct_index" /**< contact db index for reference */
#define CAL_VALUE_INT_ATTENDEE_ROLE "attendee_role" /**< #cal_event_attendee_role_type_t */
#define CAL_VALUE_INT_ATTENDEE_RSVP "attendee_rsvp"
* @}
*/
-/**
- * @addtogroup common
- * @{
- * brief
- * meeting category cal_value's detail field
- */
-#define CAL_VALUE_LST_MEETING_CATEGORY "meeting_category" /**< attendee's detail information set */
-#define CAL_VALUE_INT_MEETING_CATEGORY_DETAIL_ID "event_id" /**< attendee_name */
-#define CAL_VALUE_TXT_MEETING_CATEGORY_DETAIL_NAME "category_name" /**< attendee_email */
-
-/**
- * @}
- */
-
-
-/**
- * @addtogroup common
- * @{
- * brief
- * exception event date
- */
-#define CAL_VALUE_LST_EXCEPTION_DATE "exception_date" /**< exception's detail information set */
-#define CAL_VALUE_GMT_EXCEPTION_DATE_TIME "exception_date_time" /**< exception event's start date */
-#define CAL_VALUE_INT_EXCEPTION_DATE_ID "exception_event_id" /**< if occasion update case, it has valid id(not -1) */
-
-/**
- * @}
- */
-
-
-
-/**
- * @addtogroup common
- * @{
- * brief
- * exception event date
- */
#define CAL_VALUE_LST_ALARM "alarm" /**< exception's detail information set */
-#define CAL_VALUE_GMT_ALARMS_TIME "alarm_time" /**< alarm time */
-#define CAL_VALUE_INT_ALARMS_TICK "remind_tick" /**< Alarms before remindTick */
-#define CAL_VALUE_INT_ALARMS_TICK_UNIT "remind_tick_unit" /**< Remind tick unit */
-#define CAL_VALUE_TXT_ALARMS_TONE "alarm_tone" /**< Alert Sound File Name */
+#define CAL_VALUE_LLI_ALARMS_TIME "alarm_time" /**< alarm time */
+#define CAL_VALUE_INT_ALARMS_TICK "remind_tick" /**< Alarms before remindTick */
+#define CAL_VALUE_INT_ALARMS_TICK_UNIT "remind_tick_unit" /**< Remind tick unit */
+#define CAL_VALUE_TXT_ALARMS_TONE "alarm_tone" /**< Alert Sound File Name */
#define CAL_VALUE_TXT_ALARMS_DESCRIPTION "alarm_description" /**< Alert description */
-#define CAL_VALUE_INT_ALARMS_TYPE "alarm_type" /**< Alert type(see 'cal_alert_type_t') */
-#define CAL_VALUE_INT_ALARMS_ID "alarm_id" /**< Alarm id */
+#define CAL_VALUE_INT_ALARMS_TYPE "alarm_type" /**< Alert type(see 'cal_alert_type_t') */
+#define CAL_VALUE_INT_ALARMS_ID "alarm_id" /**< Alarm id */
/**
* @}
*/
-/**
- * @addtogroup common
- * @{
- * brief
- * api param
- */
-#define CAL_VALUE_CUSTOM /**< custom field value(MIME Type will be Support) */
-#define CAL_VALUE_ALL_FIELD "all_field_list" /**< event's all data field return */
-#define CAL_VALUE_MAIN_FILED "main_field_list" /**< event's major data field return(summay,description,status,etc..) */
-#define CAL_VALUE_LIST_FILED "list_field_list" /**< event's sub data field for list view(summary,start/end date/all day,repeat) */
-#define CAL_VALUE_MONTH_FILED "month_field_list" /**< event's sub data field for month view check */
-/**
- * @}
- */
-
-
/**
* @addtogroup common
int calendar_svc_begin_trans(void);
/**
- * @fn int calendar_svc_end_trans(void);
- * This function finish db transaction,it is coninient for user do many operaion once.
+ * @fn int calendar_svc_end_trans(bool is_success);
+ * This function finishes database transaction of calendar service.
+ * If it returns error, the transaction has been rollbacked.
+ * When transction is success, it returns the last contacts version.
*
* @ingroup service_management
- * @return This function returns CAL_SUCCESS or error code on failure.
+ * @param[in] is_success Commit changes if #true. Otherwise, no changes will be made on the database.
+ * @return CAL_SUCCESS or the last calendar version(when success) on success,
+ * Negative value(#cal_error) on error
* @exception None.
* @remarks None.
* @pre database connected and calendar_svc_begin_trans() is called.
//..do some operation to database
// end transaction
- calendar_svc_end_trans();
+ calendar_svc_end_trans(true);
//close database
calendar_svc_close();
* @endcode
* @see calendar_svc_begin_trans().
*/
-int calendar_svc_end_trans(void);
+int calendar_svc_end_trans(bool is_success);
/**
int calendar_svc_delete(const char *data_type,int index);
/**
- * @fn int calendar_svc_event_delete_by_period(int account_id,time_t start_time,time_t end_time);
- * This function delete records from database,it is convenient for user to delete records set once.
- *
- * @ingroup event_management
- * @return This function returns CAL_SUCCESS or error code on failure.
- * @param[in] account_id account db index
- * @param[in] start_time timestamp
- * @param[in] end_time timestamp
- * @return This function returns CAL_SUCCESS or error code on failure.
- * @exception None.
- * @remarks None.
- * @pre database connected
- * @post none
- * @code
- #include <calendar-svc-provider.h>
- void sample_code()
- {
- time_t start_time = time(NULL);
- time_t end_time = start_time + 10000;
-
- //connect to database
- calendar_svc_connect();
-
- //delete the records whose lase modified time is between start_time and end_time
- calendar_svc_event_delete_by_period(0,start_time,end_time);
-
- //close database
- calendar_svc_close();
- }
- * @endcode
- * @see detail_management module
- * @see
- */
-int calendar_svc_event_delete_by_period(int account_id,time_t start_time,time_t end_time);
-
-/**
* @fn int calendar_svc_delete_all(int account_id,const char *data_type);
* This function delete all records from database,it is convenient for user to delete all of records.
+ * local account deletes data immediately but the others set is_deleted parameter 1.
*
* @ingroup event_management
* @return This function returns CAL_SUCCESS or error code on failure.
* @endcode
* @see detail_management module
*/
-
int calendar_svc_delete_all(int account_id,const char *data_type);
/**
* @fn int calendar_svc_delete_account(int account_id);
* This function delete all records from database,it is convenient for user to delete all of records according to account.
+ * local account deletes data immediately but the others set is_deleted parameter 1.
*
* @ingroup event_management
* @return This function returns CAL_SUCCESS or error code on failure.
/**
- * @fn int calendar_svc_clean_after_sync(int account_id);
+ * @fn int calendar_svc_clean_after_sync(int calendar_id);
* This function clean deleted(marked) all records from database,which is used to remove data from database after sync operation.
*
* @ingroup event_management
* @return This function returns CAL_SUCCESS or error code on failure.
- * @param[in] account_id account db index
+ * @param[in] account_id calendar id
* @return This function returns CAL_SUCCESS or error code on failure.
* @exception None.
* @remarks None.
* @see detail_management module
*/
-int calendar_svc_clean_after_sync(int account_id);
+int calendar_svc_clean_after_sync(int calendar_id);
/**
* @fn int calendar_svc_get(const char *data_type,int index,const char *field_list, cal_struct **record);
*/
int calendar_svc_get_count(int account_id,int calendar_id,const char *data_type);
+int calendar_svc_calendar_get_count(int account_id);
+int calendar_svc_event_get_count(int calendar_id);
+int calendar_svc_todo_get_count(int calendar_id);
+
/**
* @fn int calendar_svc_get_all(int account_id,int calendar_id,const char *data_type, cal_iter **iter);
* This function get all records from database,it is convenient for user to get all of the reocrds once.
*/
int calendar_svc_get_all(int account_id,int calendar_id,const char *data_type, cal_iter **iter);
-
-/**
- * @fn int calendar_svc_get_list(int account_id,int calendar_id,const char *data_type,const char *field_type,int offset,int count, cal_iter **iter)
- * This function get all records from database,but, this api support data filter for performance.
- *
- * @ingroup event_management
- * @return This function returns CAL_SUCCESS or error code on failure.
- * @param[in] account_id account db index
- * @param[in] calendar_id calendar id(will be support phase 2)
- * @param[in] data_type data_type(CAL_STRUCT_CALENDAR or CAL_STRUCT_SCHEDULE)
- * @param[in] sub field type(CAL_VALUE_ALL_FIELD or CAL_VALUE_MAIN_FILED,CAL_VALUE_LIST_FILED,CAL_VALUE_MONTH_FILED)
- * @param[in] offset start item list index
- * @param[in] count return data count(limit count)
- * @param[out] iter calendar data
- * @return This function returns CAL_SUCCESS or error code on failure.
- * @exception None.
- * @remarks event should .
- * @pre database connected
- * @post call calendar_svc_iter_remove() when leave
- * @code
- #include <calendar-svc-provider.h>
- void sample_code()
- {
- cal_iter *iter = NULL;
-
- //connect to database
- calendar_svc_connect();
-
- //get all records
- calendar_svc_get_list(ALL_VISIBILITY_ACCOUNT,ALL_CALENDAR_ID,CAL_STRUCT_SCHEDULE,CAL_VALUE_LIST_FILED,0,10, &iter);
-
- //free
- calendar_svc_iter_remove(&iter);
-
- //close database
- calendar_svc_close();
- }
- * @endcode
- * @see detail_management module
- */
-int calendar_svc_get_list(int account_id,int calendar_id,const char *data_type,const char *field_type,int offset,int count, cal_iter **iter);
-
-
/**
- * @fn int calendar_svc_get_updated_event_list(int account_id,time_t timestamp, cal_iter **iter);
- * This function get update records from database by time statmp,it is convenient for user to decide which records need to sync.
+ * @fn int calendar_svc_event_get_changes(int calendar_id, int version, cal_iter **iter);
+ * This function provides the iterator to get all changes later than the version.
*
* @ingroup event_management
* @return This function returns CAL_SUCCESS or error code on failure.
- * @param[in] account_id account db index
- * @param[in] timestamp updated timestamp
+ * @param[in] calendar_id calendar ID
+ * @param[in] version version number
* @param[out] iter interation struct for list travel
* @return This function returns CAL_SUCCESS or error code on failure.
* @exception None.
* @post none
* @code
#include <calendar-svc-provider.h>
+ #include <stdio.h>
void sample_code()
{
- cal_iter *iter = NULL;
- time timestamp = time(NULL) - 10000;
-
- //connect to database
- calendar_svc_connect();
-
- //get events updated after timestamp
- calendar_svc_get_updated_event_list(0,timestamp, &iter);
-
- //free
- calendar_svc_iter_remove(&iter);
-
- //close database
- calendar_svc_close();
+ int ret;
+ cal_struct *cs;
+ cal_iter *it;
+ int id, type, ver;
+
+ calendar_svc_event_get_changes(1, 0, &it);
+
+ while (calendar_svc_iter_next(it) == CAL_SUCCESS) {
+ cs = NULL;
+ ret = calendar_svc_iter_get_info(it, &cs);
+ if (ret != CAL_SUCCESS) {
+ printf("calendar_svc_iter_get_info failed (%d)\n", ret);
+ return -1;
+ }
+ id = calendar_svc_struct_get_int(cs, CALS_STRUCT_UPDATED_INT_ID);
+ type = calendar_svc_struct_get_int(cs, CALS_STRUCT_UPDATED_INT_TYPE);
+ ver = calendar_svc_struct_get_int(cs, CALS_STRUCT_UPDATED_INT_VERSION);
+ printf("type = %d id = %d ver = %d\n", id, type, ver);
+ calendar_svc_struct_free(&cs);
+ }
+ calendar_svc_iter_remove(&it);
}
* @endcode
* @see detail_management module
*/
-int calendar_svc_get_updated_event_list(int account_id,time_t timestamp, cal_iter **iter);
-
+int calendar_svc_event_get_changes(int calendar_id, int version, cal_iter **iter);
/**
- * @fn int calendar_svc_get_event_list_by_period(int account_id,time_t start_time,time_t end_time,cal_iter **iter);
- * This function get update records from database by time statmp,it is convenient for user to get records according to time.
+ * @fn int calendar_svc_todo_get_changes(int calendar_id, int version, cal_iter **iter);
+ * This function provides the iterator to get all changes later than the version.
*
* @ingroup event_management
* @return This function returns CAL_SUCCESS or error code on failure.
- * @param[in] account_id account db index(0 for all event
- * @param[in] start_time timestamp
- * @param[in] end_time timestamp
+ * @param[in] calendar_id calendar ID
+ * @param[in] version version number
* @param[out] iter interation struct for list travel
* @return This function returns CAL_SUCCESS or error code on failure.
* @exception None.
* @post none
* @code
#include <calendar-svc-provider.h>
+ #include <stdio.h>
void sample_code()
{
- cal_iter *iter = NULL;
- time start_time = time(NULL);
- time end_time = start_time + 10000;
-
- //connect to database
- calendar_svc_connect();
-
- //get events
- calendar_svc_get_event_list_by_period(0,start_time,end_time,&iter);
-
- //free
- calendar_svc_iter_remove(&iter);
-
- //close database
- calendar_svc_close();
+ int ret;
+ cal_struct *cs;
+ cal_iter *it;
+ int id, type, ver;
+
+ calendar_svc_todo_get_changes(1, 0, &it);
+
+ while (calendar_svc_iter_next(it) == CAL_SUCCESS) {
+ cs = NULL;
+ ret = calendar_svc_iter_get_info(it, &cs);
+ if (ret != CAL_SUCCESS) {
+ printf("calendar_svc_iter_get_info failed (%d)\n", ret);
+ return -1;
+ }
+ id = calendar_svc_struct_get_int(cs, CALS_STRUCT_UPDATED_INT_ID);
+ type = calendar_svc_struct_get_int(cs, CALS_STRUCT_UPDATED_INT_TYPE);
+ ver = calendar_svc_struct_get_int(cs, CALS_STRUCT_UPDATED_INT_VERSION);
+ printf("type = %d id = %d ver = %d\n", id, type, ver);
+ calendar_svc_struct_free(&cs);
+ }
+ calendar_svc_iter_remove(&it);
}
* @endcode
* @see detail_management module
*/
-int calendar_svc_get_event_list_by_period(int account_id,
- time_t start_time,
- time_t end_time,
- cal_iter **iter);
-
-
-int calendar_svc_get_event_list_by_tm_period (int account_id,
- int calendar_id,
- struct tm* startdate,
- struct tm* enddate,
- cal_iter **iter);
-
+int calendar_svc_todo_get_changes(int calendar_id, int version, cal_iter **iter);
int calendar_svc_convert_id_to_uid(const char *data_type,int index,char **uid);
int calendar_svc_iter_remove(cal_iter **iter);
/**
- * @fn int calendar_svc_util_next_valid_event_tm ( cal_struct * event,struct tm* start_tm,struct tm* end_tm,struct tm* next_valid_start_tm,struct tm* next_valid_end_tm );
- * This function gets next valid event(it should be recurrence event) by period,user can get next valid event't time through calling it.
- *
- * @ingroup event_management
- * @param[in] event point of event struct
- * @param[in] start_time start point of valid time period
- * @param[in] end_time end point of valid time period
- * @param[out] next_valid_start_time next valid start time in period
- * @param[out] next_valid_end_time next valid end time in period
- * @return This function returns CAL_SUCCESS or error code on failure.
- * @remarks none
- * @pre the event must be recurrence event
- * @post none
- * @code
- #include <calendar_svc_provider.h>
- #include <time.h>
- void sample_code()
- {
- cal_struct* event = NULL;
- index = 1;
- time_t start_time = time(NULL);
- time_t end_time = start_time + 1000000;
- time_t next_valid_start_time = 0;
- time_t next_valid_end_time = 0;
- struct tm stm,etm;
- struct tm estm,eetm;
-
- localtime_r(&start_time,&stm);
- localtime_r(&end_time,&etm);
-
- //connect to database
- calendar_svc_connect();
-
- //get the record
- calendar_svc_get("schedule",NULL,index,&event);
-
- //get the next valid event time
- memset(&estm,0x00,sizeof(struct tm));
- memset(&eetm,0x00,sizeof(struct tm));
- while(calendar_svc_util_next_valid_event_tm(event,&stm,&etm,&estm,&eetm)==CAL_SUCCESS)
- {
- //using estm,eetm
- }
-
- //free the space
- calendar_svc_struct_free(&event);
-
- //close database
- calendar_svc_close();
-
- }
- * @endcode
- * @see none.
- */
-int calendar_svc_util_next_valid_event_tm ( cal_struct * event,
- struct tm* start_tm,
- struct tm* end_tm,
- struct tm* next_valid_start_tm,
- struct tm* next_valid_end_tm );
-
-
-/**
* @defgroup detail_management detail_management
* @ingroup CALENDAR_SVC
* @brief
/**
- * @fn struct tm* calendar_svc_struct_get_tm(cal_struct* record, const char* field, int timezone_flag);
- * This function gets time value of the calendar service value,it is convenient for user get the value needed without knowing the detail of the struct.
- *
- * @ingroup detail_management
- * @param[in] record Point to The calendar struct
- * @param[in] field The index of the integer value in calendar service value.
- * @param[in] timezone_flag #cal_timezone_flag time flag means 'time' value is local or gmt time(CAL_TZ_FLAG_GMT or CAL_TZ_FLAG_LOCAL)
- * @return Integer value, or 0 if no value is obtained
- * @remarks none
- * @pre cal_struct varibale is defined.
- * @post none
- * @code
- #include <calendar-svc-provider.h>
- #include <time.h>
- void sample_code()
- {
- time_t last_modified_time = 0;
- index = 1;
- cal_struct* event = NULL;
-
- //connect to database
- calendar_svc_connect();
-
- //get the record
- calendar_svc_get("schedule",index,NULL,&event);
-
- //get the time value
- last_modified_time = calendar_svc_struct_get_time(event,CAL_VALUE_GMT_LAST_MODIFIED_TIME,CAL_TZ_FLAG_GMT);
-
- //free space
- calendar_svc_free(&event);
-
- //close database
- calendar_svc_close();
- }
- * @endcode
- * @see calendar_svc_struct_set_time().
- */
-struct tm* calendar_svc_struct_get_tm(cal_struct* record, const char *field, int timezone_flag);
-
-
-
-/**
* @fn double calendar_svc_struct_get_double(cal_struct* record, const char* field);
* This function gets double value of the calendar service value,it is convenient for user get the value needed without knowing the detail of the struct.
*
/**
- * @fn int calendar_svc_struct_set_tm(cal_struct* record, const char* field,int timezone_flag, struct tm* time);
- * This function sets time value of the calendar service value,it is convenient for user set the value without knowing the detail of the struct.
+ * @fn int calendar_svc_struct_get_list(cal_struct* record, const char* field, GList** retlist);
+ * This function gets the point of glib double-linked list in the calendar service struct,it is convenient for user get the value without knowing the detail of the struct.
*
* @ingroup detail_management
- * @param[in] record Point to The calendar struct
- * @param[in] field The index of the integer value in calendar service value.
- * @param[in] timezone_flag #cal_timezone_flag time flag means 'time' value is local or gmt time(CAL_TZ_FLAG_GMT or CAL_TZ_FLAG_LOCAL)
- * @param[in] time time value in calendar service value.
- * @return Integer value, or 0 if no value is obtained
- * @remarks none.
+ * @param[in] record structure A calendar service struct
+ * @param[in] field The index of the glib singly-linked list in calendar service struct.
+ * @param[out] retlist the glib singly-linked list requested with field(should not be freed or removed)
+ * @return This function returns CAL_SUCCESS or error code on failure.
+ * @remarks if parent cal_struct is destroyed, retlist is not valid.
* @pre cal_struct variable is defined.
- * @post the corresponding value of cal_struct is set.
+ * @post none.
* @code
#include <calendar-svc-provider.h>
- #include <time.h>
void sample_code()
{
- time_t last_modified_time = time(NULL);
- index = 0;
+ GList* list = NULL;
+ index = 1;
cal_struct* event = NULL;
//connect to database
calendar_svc_connect();
- //create a cal_struct variable
- event = calendar_svc_struct_new("schedule");
+ //get the record
+ calendar_svc_get("schedule",index,NULL,&event);
- //set the time value
- calendar_svc_set_time(event,CAL_VALUE_GMT_LAST_MODIFIED_TIME,CAL_TZ_FLAG_GMT,last_modified_time);
-
- //insert the record
- index = calendar_svc_insert(event);
-
- //free the space
- calendar_svc_struct_free(&event);
-
- //close database
- calendar_svc_close();
- }
- * @endcode
- * @see calendar_svc_struct_get_time().
- */
-int calendar_svc_struct_set_tm(cal_struct* record, const char *field, int timezone_flag,struct tm* time);
-
-/**
- * @fn int calendar_svc_struct_get_list(cal_struct* record, const char* field, GList** retlist);
- * This function gets the point of glib double-linked list in the calendar service struct,it is convenient for user get the value without knowing the detail of the struct.
- *
- * @ingroup detail_management
- * @param[in] record structure A calendar service struct
- * @param[in] field The index of the glib singly-linked list in calendar service struct.
- * @param[out] retlist the glib singly-linked list requested with field(should not be freed or removed)
- * @return This function returns CAL_SUCCESS or error code on failure.
- * @remarks if parent cal_struct is destroyed, retlist is not valid.
- * @pre cal_struct variable is defined.
- * @post none.
- * @code
- #include <calendar-svc-provider.h>
- void sample_code()
- {
- GList* list = NULL;
- index = 1;
- cal_struct* event = NULL;
-
- //connect to database
- calendar_svc_connect();
-
- //get the record
- calendar_svc_get("schedule",index,NULL,&event);
-
- //get the list
- calendar_svc_struct_get_list(event,"attendee_list",&list);
+ //get the list
+ calendar_svc_struct_get_list(event,"attendee_list",&list);
//free the space
calendar_svc_struct_free(&event);
*/
int calendar_svc_value_set_int(cal_value* value, const char *field, int intval);
+int calendar_svc_value_set_lli (cal_value *value, const char *field, long long int llival);
+long long int calendar_svc_value_get_lli (cal_value *value, const char *field);
/**
* @fn int calendar_svc_value_set_str(cal_value* value, const char* field, const char *strval);
* This function sets string value to the calendar service value,it is convenient for user set value of cal_value varible.
int calendar_svc_value_set_str(cal_value* value, const char *field, const char *strval);
-
-/**
- * @fn int calendar_svc_value_set_time(cal_value* value, const char* field,int timezone_flag, time_t time);
- * This function sets time value of the calendar service value,it is convenient for user set value of cal_value varible.
- *
- * @ingroup detail_management
- * @param[in] value The calendar service value
- * @param[in] field The index of the integer value in calendar service value.
- * @param[in] timezone_flag #cal_timezone_flag time flag means 'time' value is local or gmt time(CAL_TZ_FLAG_GMT or CAL_TZ_FLAG_LOCAL)
- * @param[in] time timestamp value in calendar service value.
- * @return This function returns CAL_SUCCESS or error code on failure.
- * @remarks none.
- * @pre cal_value variable is defined.
- * @post none.
- * @code
- #include <calendar-svc-provider.h>
- void sample_code()
- {
- GList* list = NULL;
- index = 1;
- cal_value* event = NULL;
-
- //connect to database
- calendar_svc_connect();
-
- //create the event
- event = calendar_svc_value_new(CAL_VALUE_LST_EXCEPTION_DATE);
- calendar_svc_value_set_time(event,CAL_VALUE_GMT_EXCEPTION_DATE_TIME,CAL_TZ_FLAG_GMT,time(NULL));
-
- //set the list
- list = g_list_append(list,event);
- calendar_svc_struct_store_list(event,CAL_VALUE_LST_EXCEPTION_DATE,list);
-
- //free the space
- calendar_svc_value_free(&event);
-
- //close database
- calendar_svc_close();
- }
- * @endcode
- * @see calendar_svc_value_get_time().
- */
-int calendar_svc_value_set_tm (cal_value *value, const char *field,int timezone_flag, struct tm* time);
-
/**
* @fn int calendar_svc_value_get_int(cal_value* value, const char* field);
* This function gets Integer value of the calendar service value,it is convenient for user get value of cal_value varible.
#include <calendar-svc-provider.h>
void sample_code()
{
- int event_id = 0;
+ int type = 0;
cal_value* event = NULL;
//connect to database
calendar_svc_connect();
//create the event
- event = calendar_svc_value_new("meeting_category");
+ event = calendar_svc_value_new(CAL_VALUE_LST_ATTENDEE_LIST);
- //get the event_id value
- event_id = calendar_svc_value_get_int(event,"event_id");
+ //get the type value
+ type = calendar_svc_value_get_int(event,
+ CAL_VALUE_INT_ATTENDEE_DETAIL_TYPE);
//free the space
calendar_svc_value_free(&event);
#include <calendar-svc-provider.h>
void sample_code()
{
- char* category_name = "money";
+ char* name = "money";
cal_value* event = NULL;
//connect to database
calendar_svc_connect();
//create the event
- event = calendar_svc_value_new("meeting_category");
+ event = calendar_svc_value_new(CAL_VALUE_LST_ATTENDEE_LIST);
//get the event_id value
- category_name = calendar_svc_value_get_str(event,"category_name");
+ name = calendar_svc_value_get_str(event,
+ CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME);
//free the space
calendar_svc_value_free(&event);
*/
char *calendar_svc_value_get_str(cal_value* value, const char *field);
-
-
-/**
- * @fn time_t calendar_svc_value_get_time(cal_value* value, const char* field,int timezone_flag);
- * This function gets time value of the calendar service value,it is convenient for user get value of cal_value varible.
- *
- * @ingroup detail_management
- * @param[in] value The calendar service value
- * @param[in] field The index of the integer value in calendar service value.
- * @param[in] timezone_flag #cal_timezone_flag time flag means 'time' value is local or gmt time(CAL_TZ_FLAG_GMT or CAL_TZ_FLAG_LOCAL)
- * @return time time value in calendar service value.
- * @remarks none.
- * @pre cal_value variable is defined.
- * @post none.
- * @code
- #include <calendar-svc-provider.h>
- #include <time.t>
- void sample_code()
- {
- time_t exception_time = 0;
- index = 1;
- cal_value* event = NULL;
-
- //connect to database
- calendar_svc_connect();
-
- //create the event
- event = calendar_svc_value_new(CAL_VALUE_LST_EXCEPTION_DATE);
- exception_time = calendar_svc_value_get_time(event,CAL_VALUE_GMT_EXCEPTION_DATE_TIME,CAL_TZ_FLAG_GMT);
-
- //free the space
- calendar_svc_value_free(&event);
-
- //close database
- calendar_svc_close();
- }
- * @endcode
- * @see calendar_svc_value_set_time().
- */
-struct tm* calendar_svc_value_get_tm (cal_value *value, const char *field,int timezone_flag);
-
-
-
-/**
- * @defgroup utilities utilities
- * @ingroup CALENDAR_SVC
- * @brief
- * date/time, timzone utilities
- */
-
-/**
- * @fn int calendar_svc_util_convert_db_time (struct tm* fromTime,char* fromTz, struct tm *toTime, char *toTz);
- * This function gets local time by gmt0 time,it is convenient for user to convert time.
- */
-int calendar_svc_util_convert_db_time (struct tm* fromTime,char *fromTz, struct tm *toTime, char *toTz);
-
-
-/**
- * @fn int calendar_svc_util_gmt_to_local(time_t fromTime,time_t *toTime);
- * This function gets local time by gmt0 time,it is convenient for user to convert time.
- *
- * @ingroup utilities
- * @param[in] fromTime gmt0 time
- * @param[out] toTime local time
- * @return This function returns CAL_SUCCESS or error code on failure.
- * @remarks none
- * @pre none
- * @post none
- * @code
- #include <calendar_svc_provider.h>
- #include <time.h>
- void sample_code()
- {
- time_t fromTime = time(NULL);
- time_t toTime = 0;
-
- //connect to database
- calendar_svc_connect();
-
- //convert
- calendar_svc_util_gmt_to_local(fromTime,&toTime);
-
- //close to database
- calendar_svc_close();
- }
- * @endcode
- * @see calendar_svc_util_local_to_gmt().
- */
-int calendar_svc_util_gmt_to_local(time_t fromTime,time_t *toTime);
-
-/**
- * @fn int calendar_svc_util_local_to_gmt(time_t fromTime,time_t *toTime);
- * This function gets gmt0 time by local time,it is convenient for user to convert time.
- *
- * @ingroup utilities
- * @param[in] fromTime local time
- * @param[out] toTime gmt0 time
- * @return This function returns CAL_SUCCESS or error code on failure.
- * @remarks none
- * @pre none
- * @post none
- * @code
- #include <calendar_svc_provider.h>
- #include <time.h>
- void sample_code()
- {
- time_t fromTime = time(NULL);
- time_t toTime = 0;
-
- //connect to database
- calendar_svc_connect();
-
- //convert
- calendar_svc_util_local_to_gmt(fromTime,&toTime);
-
- //close to database
- calendar_svc_close();
- }
- * @endcode
- * @see calendar_svc_util_gmt_to_local().
- */
-int calendar_svc_util_local_to_gmt(time_t fromTime,time_t *toTime);
-
-
-/**
- * @fn int calendar_svc_util_save_vcs_by_index(const int index,char* full_file_path);
- * This function makes vcal file by record index,it is convenient for user to get vcal from the calendar record.
- *
- * @ingroup utilities
- * @param[in] index event's index for vcal converting
- * @param[out] full_file_path Points the file path.
- * @return This function returns CAL_SUCCESS or error code on failure.
- * @remarks none
- * @pre none
- * @post none
- * @code
- #include <calendar_svc_provider.h>
- #include <time.h>
- void sample_code()
- {
- char* full_file_path = "/opt/dbspace";
- int index = 1;
-
- //connect to database
- calendar_svc_connect();
-
- //convert
- calendar_svc_util_save_vcs_by_index(index,full_file_path);
-
- //close to database
- calendar_svc_close();
- }
- * @endcode
- * @see calendar_svc_util_register_vcs_file(),calendar_svc_util_convert_vcs_to_event().
- */
-int calendar_svc_util_save_vcs_by_index(const int index,char *full_file_path);
-
-/**
- * @fn int calendar_svc_util_register_vcs_file(const char * file_name);
- * This function registers vcal to calendar db,user can save vcal to database through calling it.
- *
- * @ingroup utilities
- * @param[in] file_name vcalendar's file name
- * @return This function returns cid or error code on failure.
- * @remarks none
- * @pre the vcalendar exists
- * @post none
- * @code
- #include <calendar_svc_provider.h>
- void sample_code()
- {
- char* full_name = "/opt/dbspace/vcalendar_test.vcs";
- int cal_id = 0;
-
- //connect to database
- calendar_svc_connect();
-
- //convert
- cal_id = calendar_svc_util_register_vcs_file(full_name);
-
- //close to database
- calendar_svc_close();
- }
- * @endcode
- * @see calendar_svc_util_save_vcs_by_index(),calendar_svc_util_convert_vcs_to_event().
- */
-int calendar_svc_util_register_vcs_file(const char * file_name);
-
-/**
- * @fn int calendar_svc_util_convert_vcs_to_event (const char *raw_data,int data_size,cal_struct **record);
- * This function converts data (raw_data(vcal format) to cal_struct(event)),it is convenient for user to convert.
- *
- * @ingroup utilities
- * @param[in] raw_data vcalendar event raw data
- * @param[in] data_size raw_data buf size
- * @param[out] record assigned record
- * @return This function returns CAL_SUCCESS or error code on failure.
- * @remarks none
- * @pre the vcalendar data is valid.
- * @post none
- * @code
- #include <calendar_svc_provider.h>
- void sample_code()
- {
- char raw_data[] = "";//raw data
-
- //connect to database
- calendar_svc_connect();
-
- cal_struct* event = NULL;
-
- //convert
- calendar_svc_util_convert_vcs_to_event (raw_data,strlen(raw_data),&event);
-
- calendar_svc_struct_free(&event);
-
- //close to database
- calendar_svc_close();
- }
- * @endcode
- * @see calendar_svc_util_convert_event_to_vcs().
- */
-int calendar_svc_util_convert_vcs_to_event (const char *raw_data,int data_size,cal_struct **record);
-
/**
* @fn int calendar_svc_util_convert_event_to_vcs (cal_struct *record,char **raw_data,int *data_size);
* This function converts data (cal_struct(event) to raw_data(vcal format)),it is convenient for user to convert.
calendar_svc_close();
}
* @endcode
- * @see calendar_svc_util_convert_vcs_to_event().
*/
-int calendar_svc_util_convert_event_to_vcs (cal_struct *record,char **raw_data,int *data_size);
+DEPRECATED int calendar_svc_util_convert_event_to_vcs (cal_struct *record,char **raw_data,int *data_size);
/**
- * @fn int calendar_svc_util_next_valid_event(cal_struct* event,time_t start_time,time_t end_time,time_t *next_valid_start_time,time_t *next_valid_end_time);
- * This function gets next valid event(it should be recurrence event) by period,user can get next valid event't time through calling it.
+ * @fn int calendar_svc_find_event_list(int account_id,const char* search_type,const void* search_value, cal_iter **iter);
+ * This function get records from database by search param,it is convenient for user to get records according to some condition.
*
- * @ingroup utilities
- * @param[in] event point of event struct
- * @param[in] start_time start point of valid time period
- * @param[in] end_time end point of valid time period
- * @param[out] next_valid_start_time next valid start time in period
- * @param[out] next_valid_end_time next valid end time in period
+ * @ingroup event_management
* @return This function returns CAL_SUCCESS or error code on failure.
- * @remarks none
- * @pre the event must be recurrence event
- * @deprecated this api will be deprecated.
+ * @param[in] account_id account db index
+ * @param[in] search_type event search type(eg. CAL_VALUE_SUMMARY or CAL_VALUE_DESCRIPTION,..)
+ * @param[in] search_value event search value(eg. "weekly report", etc.. ), it can be integer value(eg. 1 or 2.. etc)
+ * @param[out] iter interation struct for list travel
+ * @return This function returns CAL_SUCCESS or error code on failure.
+ * @exception None.
+ * @remarks None.
+ * @pre database connected
* @post none
* @code
- #include <calendar_svc_provider.h>
- #include <time.h>
+ #include <calendar-svc-provider.h>
void sample_code()
{
- cal_struct* event = NULL;
- index = 1;
- time_t start_time = time(NULL);
- time_t end_time = start_time + 1000000;
- time_t next_valid_start_time = 0;
- time_t next_valid_end_time = 0;
-
- //connect to database
- calendar_svc_connect();
-
- //get the record
- calendar_svc_get("schedule",NULL,index,&event);
+ cal_iter *iter = NULL;
- //get the next valid event time
- calendar_svc_util_next_valid_event(event,start_time,end_time,&next_valid_start_time,&next_valid_end_time);
+ //connect to database
+ calendar_svc_connect();
- //free the space
- calendar_svc_struct_free(&event);
+ //find event whose summary including string like "party"
+ calendar_svc_find_event_list(0,"summary","party", &iter);
- //close database
- calendar_svc_close();
+ //free
+ calendar_svc_iter_remove(&iter);
+ //close database
+ calendar_svc_close();
}
* @endcode
- * @see none.
+ * @see detail_management module
+ * @deprecated it will replacement calendar_svc_find_list
*/
-int calendar_svc_util_next_valid_event(cal_struct* event,time_t start_time,time_t end_time,
- time_t *next_valid_start_time,time_t *next_valid_end_time);
+int calendar_svc_find_event_list(int account_id,const char *search_type,const void* search_value, cal_iter **iter);
/**
- * @fn time_t calendar_svc_value_get_time(cal_value* value, const char* field,int timezone_flag);
- * This function gets time value of the calendar service value,it is convenient for user get value of cal_value varible.
+ * @fn int calendar_svc_event_search(int field, const char *keyword, cal_iter **iter);
+ * #calendar_svc_event_search searches events including the keyword in given fields.
*
- * @ingroup detail_management
- * @param[in] value The calendar service value
- * @param[in] field The index of the integer value in calendar service value.
- * @param[in] timezone_flag #cal_timezone_flag time flag means 'time' value is local or gmt time(CAL_TZ_FLAG_GMT or CAL_TZ_FLAG_LOCAL)
- * @return time time value in calendar service value.
- * @remarks none.
- * @pre cal_value variable is defined.
- * @deprecated this api will be deprecated.
- * @post none.
+ * @ingroup event_management
+ * @return This function returns CAL_SUCCESS or error code on failure.
+ * @param[in] field fields where the keyword is searched. #SEARCHFIELD
+ * @param[in] keyword keyword to be searched
+ * @param[out] iter interation struct for list travel
+ * @return This function returns CAL_SUCCESS or error code on failure.
+ * @exception None.
+ * @remarks None.
+ * @pre database connected
+ * @post none
* @code
- #include <calendar-svc-provider.h>
- #include <time.t>
- void sample_code()
- {
- time_t exception_time = 0;
- index = 1;
- cal_value* event = NULL;
+ #include <calendar-svc-provider.h>
+ void sample_code()
+ {
+ int ret;
+ cal_struct *cs;
+ cal_iter *it;
+ char *summary;
+ char *desc;
+ int id;
- //connect to database
- calendar_svc_connect();
+ calendar_svc_connect();
+ int search_field;
+
+ search_field = CALS_SEARCH_FIELD_NONE;
+ search_field |= CALS_SEARCH_FIELD_SUMMARY;
+ search_field |= CALS_SEARCH_FIELD_DESCRIPTION;
+ search_field |= CALS_SEARCH_FIELD_LOCATION;
+ search_field |= CALS_SEARCH_FIELD_ATTENDEE;
+
+ ret = calendar_svc_event_search(search_field, "Hello", &it);
+ if (ret < 0)
+ return -1;
+
+ while (calendar_svc_iter_next(it) == CAL_SUCCESS) {
+ cs = NULL;
+ ret = calendar_svc_iter_get_info(it, &cs);
+ if (ret != CAL_SUCCESS) {
+ printf("calendar_svc_iter_get_info failed (%d)\n", ret);
+ return -1;
+ }
- //create the event
- event = calendar_svc_value_new(CAL_VALUE_LST_EXCEPTION_DATE);
- exception_time = calendar_svc_value_get_time(event,CAL_VALUE_GMT_EXCEPTION_DATE_TIME,CAL_TZ_FLAG_GMT);
+ id = calendar_svc_struct_get_int(cs, CAL_VALUE_INT_INDEX);
+ summary = calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_SUMMARY);
+ desc = calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_DESCRIPTION);
+ printf("type = %d id = %s desc = %s\n", id, summary, desc);
+ calendar_svc_struct_free(&cs);
+ }
- //free the space
- calendar_svc_value_free(&event);
+ calendar_svc_iter_remove(&it);
- //close database
- calendar_svc_close();
- }
+ calendar_svc_close();
+
+ return 0;
+ }
* @endcode
- * @see calendar_svc_value_set_time().
+ * @see detail_management module
*/
-time_t calendar_svc_value_get_time(cal_value* value, const char *field,int timezone_flag);
+int calendar_svc_event_search(int field, const char *keyword, cal_iter **iter);
/**
- * @fn int calendar_svc_value_set_time(cal_value* value, const char* field,int timezone_flag, time_t time);
- * This function sets time value of the calendar service value,it is convenient for user set value of cal_value varible.
+ * @fn int calendar_svc_smartsearch_excl(const char *keyword, int offset, int limit, cal_iter **iter)
+ * Search events by keyword with database offset and limit option.
+ * This function is provided for Smartsearch application exclusively.
*
- * @ingroup detail_management
- * @param[in] value The calendar service value
- * @param[in] field The index of the integer value in calendar service value.
- * @param[in] timezone_flag #cal_timezone_flag time flag means 'time' value is local or gmt time(CAL_TZ_FLAG_GMT or CAL_TZ_FLAG_LOCAL)
- * @param[in] time timestamp value in calendar service value.
- * @return This function returns CAL_SUCCESS or error code on failure.
- * @remarks none.
- * @pre cal_value variable is defined.
- * @post none.
- * @deprecated this api will be deprecated.
- * @code
- #include <calendar-svc-provider.h>
- void sample_code()
- {
- GList* list = NULL;
- index = 1;
- cal_value* event = NULL;
-
- //connect to database
- calendar_svc_connect();
-
- //create the event
- event = calendar_svc_value_new(CAL_VALUE_LST_EXCEPTION_DATE);
- calendar_svc_value_set_time(event,CAL_VALUE_GMT_EXCEPTION_DATE_TIME,CAL_TZ_FLAG_GMT,time(NULL));
-
- //set the list
- list = g_list_append(list,event);
- calendar_svc_struct_store_list(event,CAL_VALUE_LST_EXCEPTION_DATE,list);
-
- //free the space
- calendar_svc_value_free(&event);
-
- //close database
- calendar_svc_close();
- }
- * @endcode
- * @see calendar_svc_value_get_time().
+ * @ingroup event_management
+ * @return CAL_SUCCESS or negative error code on failure.
+ * @param[in] field fields where the keyword is searched, #SEARCHFIELD
+ * @param[in] keyword keyword to be searched
+ * @param[in] offset offset to omit some searching results
+ * @param[in] limit limit of the number of results. If negative, no limit is applied.
+ * @param[out] iter interation struct for list travel
+ * @return This function returns CAL_SUCCESS or error code on failure.
+ * @exception None.
+ * @remarks None.
+ * @pre database connected
+ * @post none
+ * @see detail_management module
*/
-int calendar_svc_value_set_time(cal_value* value, const char *field,int timezone_flag, time_t time);
+int calendar_svc_smartsearch_excl(const char *keyword, int offset, int limit, cal_iter **iter);
/**
- * @fn int calendar_svc_struct_set_time(cal_struct* record, const char* field,int timezone_flag, time_t time);
- * This function sets time value of the calendar service value,it is convenient for user set the value without knowing the detail of the struct.
+ * @fn int calendar_svc_todo_search(int field, const char *keyword, cal_iter **iter);
+ * #calendar_svc_event_search searches TO-DOs including the keyword in given fields.
*
- * @ingroup detail_management
- * @param[in] record Point to The calendar struct
- * @param[in] field The index of the integer value in calendar service value.
- * @param[in] timezone_flag #cal_timezone_flag time flag means 'time' value is local or gmt time(CAL_TZ_FLAG_GMT or CAL_TZ_FLAG_LOCAL)
- * @param[in] time time value in calendar service value.
- * @return Integer value, or 0 if no value is obtained
- * @remarks none.
- * @pre cal_struct variable is defined.
- * @post the corresponding value of cal_struct is set.
- * @deprecated this api will be deprecated.
+ * @ingroup event_management
+ * @return This function returns CAL_SUCCESS or error code on failure.
+ * @param[in] field fields where the keyword is searched, #SEARCHFIELD
+ * @param[in] keyword keyword to be searched
+ * @param[out] iter interation struct for list travel
+ * @return This function returns CAL_SUCCESS or error code on failure.
+ * @exception None.
+ * @remarks None.
+ * @pre database connected
+ * @post none
* @code
- #include <calendar-svc-provider.h>
- #include <time.h>
- void sample_code()
- {
- time_t last_modified_time = time(NULL);
- index = 0;
- cal_struct* event = NULL;
-
- //connect to database
- calendar_svc_connect();
+ #include <calendar-svc-provider.h>
+ void sample_code()
+ {
+ int ret;
+ cal_struct *cs;
+ cal_iter *it;
+ char *summary;
+ char *desc;
+ int id;
- //create a cal_struct variable
- event = calendar_svc_struct_new("schedule");
+ calendar_svc_connect();
+ int search_field;
+
+ search_field = CALS_SEARCH_FIELD_NONE;
+ search_field |= CALS_SEARCH_FIELD_SUMMARY;
+ search_field |= CALS_SEARCH_FIELD_DESCRIPTION;
+ search_field |= CALS_SEARCH_FIELD_LOCATION;
+ search_field |= CALS_SEARCH_FIELD_ATTENDEE;
+
+ ret = calendar_svc_todo_search(search_field, "Hello", &it);
+ if (ret < 0)
+ return -1;
+
+ while (calendar_svc_iter_next(it) == CAL_SUCCESS) {
+ cs = NULL;
+ ret = calendar_svc_iter_get_info(it, &cs);
+ if (ret != CAL_SUCCESS) {
+ printf("calendar_svc_iter_get_info failed (%d)\n", ret);
+ return -1;
+ }
- //set the time value
- calendar_svc_set_time(event,CAL_VALUE_GMT_LAST_MODIFIED_TIME, CAL_TZ_FLAG_GMT, last_modified_time);
+ id = calendar_svc_struct_get_int(cs, CAL_VALUE_INT_INDEX);
+ summary = calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_SUMMARY);
+ desc = calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_DESCRIPTION);
+ printf("type = %d id = %s desc = %s\n", id, summary, desc);
+ calendar_svc_struct_free(&cs);
+ }
- //insert the record
- index = calendar_svc_insert(event);
+ calendar_svc_iter_remove(&it);
- //free the space
- calendar_svc_struct_free(&event);
+ calendar_svc_close();
- //close database
- calendar_svc_close();
- }
+ return 0;
+ }
* @endcode
- * @see calendar_svc_struct_set_tm().
+ * @see detail_management module
*/
-int calendar_svc_struct_set_time(cal_struct* record, const char *field,int timezone_flag, time_t time);
+int calendar_svc_todo_search(int field, const char *keyword, cal_iter **iter);
/**
- * @fn time_t calendar_svc_struct_get_time(cal_struct* record, const char* field, int timezone_flag);
- * This function gets time value of the calendar service value,it is convenient for user get the value needed without knowing the detail of the struct.
+ * @fn int calendar_svc_read_schedules(const char *stream, GList **schedules);
+ * This function reads schedules and provides schedule list.
*
- * @ingroup detail_management
- * @param[in] record Point to The calendar struct
- * @param[in] field The index of the integer value in calendar service value.
- * @param[in] timezone_flag #cal_timezone_flag time flag means 'time' value is local or gmt time(CAL_TZ_FLAG_GMT or CAL_TZ_FLAG_LOCAL)
- * @return Integer value, or 0 if no value is obtained
+ * @ingroup event management
+ * @param[in] stream vcalendar(ver1.0) icalendar(ver2.0) stream
+ * @param[out] schedules schedule list which data is cal_struct
+ * @return This function returns CAL_SUCCESS or error code on failure.
* @remarks none
- * @pre cal_struct varibale is defined.
+ * @pre none
* @post none
- * @deprecated this api will be deprecated.
* @code
- #include <calendar-svc-provider.h>
- #include <time.h>
- void sample_code()
- {
- time_t last_modified_time = 0;
- index = 1;
- cal_struct* event = NULL;
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <calendar-svc-provider.h>
- //connect to database
- calendar_svc_connect();
-
- //get the record
- calendar_svc_get("schedule",index,NULL,&event);
+ void sample_code()
+ {
+ int ret, len = 0;
+ char *vals;
+ char *stream = NULL;
+ char buf[1024];
+ time_t tt;
+ cal_struct *cs = NULL;
+ GList *l, *schedules = NULL;
+ buf_size = 1024;
+ FILE *file;
+
+ file = fopen(path, "r");
+ if (file == NULL) {
+ printf("failed to open\n");
+ return -1;
+ }
+ stream = malloc(1024);
+ 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);
+ printf("out of memory\n");
+ return NULL;
+ }
+ len += snprintf(stream + len, strlen(buf) +1, "%s", buf);
+ }
+ }
+ fclose(file);
- //get the time value
- last_modified_time = calendar_svc_struct_get_time(event,CAL_VALUE_GMT_LAST_MODIFIED_TIME);
+ ret = calendar_svc_read_schedules(stream, &schedules);
+ if (ret < 0) {
+ printf("Failed to read schedules(errno:%d)\n", ret);
+ return -1;
+ }
- //free space
- calendar_svc_free(&event);
+ if (schedules == NULL) {
+ printf("No schedules\n");
+ return -1;
+ }
- //close database
- calendar_svc_close();
- }
+ l = schedules;
+ while (l) {
+ cs = l->data;
+ if (cs == NULL) {
+ l = g_list_next(l);
+ continue;
+ }
+ vals = NULL;
+ vals = calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_SUMMARY);
+ printf("summary:%s\n", vals);
+
+ l = g_list_next(l);
+ }
+ if (stream) free(stream);
+ return 0;
+ }
* @endcode
- * @see calendar_svc_struct_get_tm().
+ * @see calendar_svc_write_schedules().
*/
-time_t calendar_svc_struct_get_time(cal_struct* record, const char *field, int timezone_flag);
+int calendar_svc_read_schedules(const char *stream, GList **schedules);
/**
- * @fn int calendar_svc_find_event_list(int account_id,const char* search_type,const void* search_value, cal_iter **iter);
- * This function get records from database by search param,it is convenient for user to get records according to some condition.
+ * @fn int calendar_svc_calendar_import(const char *path, int calendar_id);
+ * This function import vcalendar(ver 1.0), icalendar(ver 2.0) to calendar DB.
*
- * @ingroup event_management
- * @return This function returns CAL_SUCCESS or error code on failure.
- * @param[in] account_id account db index
- * @param[in] search_type event search type(eg. CAL_VALUE_SUMMARY or CAL_VALUE_DESCRIPTION,..)
- * @param[in] search_value event search value(eg. "weekly report", etc.. ), it can be integer value(eg. 1 or 2.. etc)
- * @param[out] iter interation struct for list travel
+ * @ingroup event management
+ * @param[in] path file path
+ * @param[out] calendar_id calendar id
* @return This function returns CAL_SUCCESS or error code on failure.
- * @exception None.
- * @remarks None.
- * @pre database connected
+ * @remarks none
+ * @pre none
* @post none
* @code
- #include <calendar-svc-provider.h>
- void sample_code()
- {
- cal_iter *iter = NULL;
-
- //connect to database
- calendar_svc_connect();
-
- //find event whose summary including string like "party"
- calendar_svc_find_event_list(0,"summary","party", &iter);
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <calendar-svc-provider.h>
- //free
- calendar_svc_iter_remove(&iter);
+ int sample_code())
+ {
+ int r;
+ int calendar_id = 1;
+ char *path = "/opt/media/test.ics";
- //close database
- calendar_svc_close();
- }
+ calendar_svc_connect();
+ ret = calendar_svc_calendar_import(path, calendar_id);
+ if (ret != CAL_SUCCESS) {
+ printf("Failed to import path(%s) to id(%d)\n", path, calendar_id);
+ return -1;
+ }
+ calendar_svc_close();
+ return 0;
+ }
* @endcode
- * @see detail_management module
- * @deprecated it will replacement calendar_svc_find_list
+ * @see calendar_svc_calendar_export().
*/
-int calendar_svc_find_event_list(int account_id,const char *search_type,const void* search_value, cal_iter **iter);
-
-int calendar_svc_find_recurring_event_list (int account_id, cal_iter **iter);
-
-int calendar_svc_find_event_list_by_filter(int account_id, int filter_count, const char *search_type[], const void *search_value[], cal_iter **iter);
+int calendar_svc_calendar_import(const char *path, int calendar_id);
/**
- * @fn int calendar_svc_find(int account_id,int calendar_id,const char *data_type,const char *search_type,const void *search_value, cal_iter **iter);
- * This function get records from database by search param,it is convenient for user to get records according to some condition.
+ * @fn int calendar_svc_write_schedules(GList *schedules, char **stream);
+ * This function writes schedules to stream.
*
- * @ingroup event_management
- * @return This function returns CAL_SUCCESS or error code on failure.
- * @param[in] account_id account db index
- * @param[in] calendar_id calendar db index
- * @param[in] data_type struct type(CAL_STRUCT_SCHEDULE,CAL_STRUCT_CALENDAR,CAL_STRUCT_TIMEZONE,..)
- * @param[in] search_type event search type(eg. CAL_VALUE_SUMMARY or CAL_VALUE_DESCRIPTION,..)
- * @param[in] search_value event search value(eg. "weekly report", etc.. ), it can be integer value(eg. 1 or 2.. etc)
- * @param[out] iter interation struct for list travel
+ * @ingroup event management
+ * @param[in] schedules schedule list which data is cal_struct
+ * @param[out] stream vcalendar(ver1.0) icalendar(ver2.0) stream
* @return This function returns CAL_SUCCESS or error code on failure.
- * @exception None.
- * @remarks None.
- * @pre database connected
+ * @remarks none
+ * @pre none
* @post none
* @code
- #include <calendar-svc-provider.h>
- void sample_code()
- {
- cal_iter *iter = NULL;
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <calendar-svc-provider.h>
- //connect to database
- calendar_svc_connect();
+ int main(int argc, char **argv)
+ {
+ int ret;
+ char *stream;
+ GList *schedules = NULL;
+ cal_struct *cs = NULL;
+
+ cs = calendar_svc_struct_new(CAL_STRUCT_CALENDAR);
+ if (cs == NULL) {
+ printf("Failed to calloc\n");
+ return-1;
+ }
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_SUMMARY, "title");
+ // set data in cs...
- //find event whose summary including string like "party"
- calendar_svc_find(LOCAL_ACCOUNT_ID,DEFAULT_CALENDAR_ID,CAL_STRUCT_SCHEDULE,"summary","party", &iter);
+ schedules = g_list_append(schedules, cs);
- //free
- calendar_svc_iter_remove(&iter);
+ ret = calendar_svc_write_schedules(schedules, &stream);
+ if (ret != CAL_SUCCESS) {
+ printf("Failed to read schedules(errno:%d)\n", ret);
+ return -1;
+ }
- //close database
- calendar_svc_close();
- }
+ if (stream == NULL) {
+ printf("stream is NULL\n");
+ return -1;
+ }
+
+ if (stream) free(stream);
+ return 0;
+ }
* @endcode
- * @see detail_management module
- * @deprecated it will replacement calendar_svc_find_list
+ * @see calendar_svc_read_schedules().
*/
-int calendar_svc_find(int account_id,int calendar_id,const char *data_type,const char *search_type,const void *search_value, cal_iter **iter);
-
+int calendar_svc_write_schedules(GList *schedules, char **stream);
/**
- * @fn int calendar_svc_search_list(int account_id,int calendar_id,const char *data_type,const char *search_type,const void *search_value,int offset,int count, cal_iter **iter);
- * This function get records from database by search param,it is convenient for user to get records according to some condition.
+ * @fn int calendar_svc_calendar_export(int calendar_id, const char *path);
+ * This function export calendar DB to file.
+ *
+ * @ingroup event management
+ * @param[in] calendar_id calendar id
+ * @param[out] path file path
+ * @return This function returns CAL_SUCCESS or error code on failure.
+ * @remarks none
+ * @pre none
+ * @post none
+ * @code
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <calendar-svc-provider.h>
- * @deprecated it will replacement calendar_svc_find_list
- **/
-int calendar_svc_search_list(int account_id,int calendar_id,const char *data_type,const char *search_type,const void *search_value,
- int offset,int count, cal_iter **iter);
+ int sample_code())
+ {
+ int r;
+ int calendar_id = 1;
+ char *path = "/opt/media/test.ics";
+ calendar_svc_connect();
+ r = calendar_svc_calendar_export(calendar_id, path);
+ if (r != CAL_SUCCESS) {
+ printf("Failed to export schedules\n");
+ return -1;
+ }
+ calendar_svc_close();
+ return 0;
+ }
+ * @endcode
+ * @see calendar_svc_calendar_import().
+ */
+int calendar_svc_calendar_export(int calendar_id, const char *path);
+
+#define CALS_VALUE_INT_DTSTART_TYPE "dtstart_type"
+#define CALS_VALUE_LLI_DTSTART_UTIME "dtstart_utime"
+#define CALS_VALUE_INT_DTSTART_YEAR "dtstart_year"
+#define CALS_VALUE_INT_DTSTART_MONTH "dtstart_month"
+#define CALS_VALUE_INT_DTSTART_MDAY "dtstart_mday"
+#define CALS_VALUE_TXT_DTSTART_TZID "dtstart_tzid"
+#define CALS_VALUE_INT_DTEND_TYPE "dtend_type"
+#define CALS_VALUE_LLI_DTEND_UTIME "dtend_utime"
+#define CALS_VALUE_INT_DTEND_YEAR "dtend_year"
+#define CALS_VALUE_INT_DTEND_MONTH "dtend_month"
+#define CALS_VALUE_INT_DTEND_MDAY "dtend_mday"
+#define CALS_VALUE_TXT_DTEND_TZID "dtend_tzid"
+#define CALS_VALUE_LLI_LASTMOD "last_mod"
+
+#define CALS_VALUE_INT_RRULE_FREQ "freq"
+#define CALS_VALUE_INT_RRULE_ID "rrule_id"
+#define CALS_VALUE_INT_RRULE_RANGE_TYPE "range_type" //endless, until, count
+#define CALS_VALUE_INT_RRULE_UNTIL_TYPE "until_type" //until by utc, until by local date
+#define CALS_VALUE_LLI_RRULE_UNTIL_UTIME "until_utime" //unix time
+#define CALS_VALUE_INT_RRULE_UNTIL_YEAR "until_year"
+#define CALS_VALUE_INT_RRULE_UNTIL_MONTH "until_month"
+#define CALS_VALUE_INT_RRULE_UNTIL_MDAY "until_mday"
+#define CALS_VALUE_INT_RRULE_COUNT "count"
+#define CALS_VALUE_INT_RRULE_INTERVAL "interval"
+#define CALS_VALUE_TXT_RRULE_BYSECOND "bysecond"
+#define CALS_VALUE_TXT_RRULE_BYMINUTE "byminute"
+#define CALS_VALUE_TXT_RRULE_BYHOUR "byhour"
+#define CALS_VALUE_TXT_RRULE_BYDAY "byday"
+#define CALS_VALUE_TXT_RRULE_BYMONTHDAY "bymonthday"
+#define CALS_VALUE_TXT_RRULE_BYYEARDAY "byyearday"
+#define CALS_VALUE_TXT_RRULE_BYWEEKNO "byweekno"
+#define CALS_VALUE_TXT_RRULE_BYMONTH "bymonth"
+#define CALS_VALUE_TXT_RRULE_BYSETPOS "bysetpos"
+#define CALS_VALUE_INT_RRULE_WKST "wkst"
+
+/* 0x00 ~0x06 used cal_struct_type */
+enum {
+ CALS_LIST_PERIOD_NORMAL_ONOFF = 0x07,
+ CALS_LIST_PERIOD_ALLDAY_ONOFF,
+ CALS_LIST_PERIOD_NORMAL_BASIC,
+ CALS_LIST_PERIOD_ALLDAY_BASIC,
+ CALS_LIST_PERIOD_NORMAL_OSP = 0x100,
+ CALS_LIST_PERIOD_ALLDAY_OSP,
+ CALS_LIST_PERIOD_NORMAL_LOCATION,
+ CALS_LIST_PERIOD_ALLDAY_LOCATION,
+ CALS_LIST_PERIOD_NORMAL_ALARM,
+ CALS_LIST_PERIOD_ALLDAY_ALARM,
+};
+
+#define CALS_LIST_PERIOD_NORMAL_ONOFF_INT_EVENTID CAL_VALUE_INT_INDEX
+#define CALS_LIST_PERIOD_NORMAL_ONOFF_INT_DTSTART_TYPE CALS_VALUE_INT_DTSTART_TYPE
+#define CALS_LIST_PERIOD_NORMAL_ONOFF_LLI_DTSTART_UTIME CALS_VALUE_LLI_DTSTART_UTIME
+#define CALS_LIST_PERIOD_NORMAL_ONOFF_INT_DTEND_TYPE CALS_VALUE_INT_DTEND_TYPE
+#define CALS_LIST_PERIOD_NORMAL_ONOFF_LLI_DTEND_UTIME CALS_VALUE_LLI_DTEND_UTIME
+
+#define CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_EVENTID CAL_VALUE_INT_INDEX
+#define CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTSTART_TYPE CALS_VALUE_INT_DTSTART_TYPE
+#define CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTSTART_YEAR CALS_VALUE_INT_DTSTART_YEAR
+#define CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTSTART_MONTH CALS_VALUE_INT_DTSTART_MONTH
+#define CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTSTART_MDAY CALS_VALUE_INT_DTSTART_MDAY
+#define CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTEND_TYPE CALS_VALUE_INT_DTEND_TYPE
+#define CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTEND_YEAR CALS_VALUE_INT_DTEND_YEAR
+#define CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTEND_MONTH CALS_VALUE_INT_DTEND_MONTH
+#define CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTEND_MDAY CALS_VALUE_INT_DTEND_MDAY
+
+#define CALS_LIST_PERIOD_NORMAL_BASIC_INT_EVENTID CAL_VALUE_INT_INDEX
+#define CALS_LIST_PERIOD_NORMAL_BASIC_INT_DTSTART_TYPE CALS_VALUE_INT_DTSTART_TYPE
+#define CALS_LIST_PERIOD_NORMAL_BASIC_LLI_DTSTART_UTIME CALS_VALUE_LLI_DTSTART_UTIME
+#define CALS_LIST_PERIOD_NORMAL_BASIC_INT_DTEND_TYPE CALS_VALUE_INT_DTEND_TYPE
+#define CALS_LIST_PERIOD_NORMAL_BASIC_LLI_DTEND_UTIME CALS_VALUE_LLI_DTEND_UTIME
+#define CALS_LIST_PERIOD_NORMAL_BASIC_TXT_SUMMARY CAL_VALUE_TXT_SUMMARY
+#define CALS_LIST_PERIOD_NORMAL_BASIC_TXT_LOCATION CAL_VALUE_TXT_LOCATION
+
+#define CALS_LIST_PERIOD_ALLDAY_BASIC_INT_EVENTID CAL_VALUE_INT_INDEX
+#define CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTSTART_TYPE CALS_VALUE_INT_DTSTART_TYPE
+#define CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTSTART_YEAR CALS_VALUE_INT_DTSTART_YEAR
+#define CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTSTART_MONTH CALS_VALUE_INT_DTSTART_MONTH
+#define CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTSTART_MDAY CALS_VALUE_INT_DTSTART_MDAY
+#define CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTEND_TYPE CALS_VALUE_INT_DTEND_TYPE
+#define CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTEND_YEAR CALS_VALUE_INT_DTEND_YEAR
+#define CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTEND_MONTH CALS_VALUE_INT_DTEND_MONTH
+#define CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTEND_MDAY CALS_VALUE_INT_DTEND_MDAY
+#define CALS_LIST_PERIOD_ALLDAY_BASIC_TXT_SUMMARY CAL_VALUE_TXT_SUMMARY
+#define CALS_LIST_PERIOD_ALLDAY_BASIC_TXT_LOCATION CAL_VALUE_TXT_LOCATION
+
+#define CALS_LIST_PERIOD_NORMAL_OSP_INT_EVENTID CAL_VALUE_INT_INDEX
+#define CALS_LIST_PERIOD_NORMAL_OSP_INT_DTSTART_TYPE CALS_VALUE_INT_DTSTART_TYPE
+#define CALS_LIST_PERIOD_NORMAL_OSP_LLI_DTSTART_UTIME CALS_VALUE_LLI_DTSTART_UTIME
+#define CALS_LIST_PERIOD_NORMAL_OSP_INT_DTEND_TYPE CALS_VALUE_INT_DTEND_TYPE
+#define CALS_LIST_PERIOD_NORMAL_OSP_LLI_DTEND_UTIME CALS_VALUE_LLI_DTEND_UTIME
+#define CALS_LIST_PERIOD_NORMAL_OSP_TXT_SUMMARY CAL_VALUE_TXT_SUMMARY
+#define CALS_LIST_PERIOD_NORMAL_OSP_TXT_LOCATION CAL_VALUE_TXT_LOCATION
+#define CALS_LIST_PERIOD_NORMAL_OSP_INT_CALENDAR_ID CAL_VALUE_INT_CALENDAR_ID
+#define CALS_LIST_PERIOD_NORMAL_OSP_TXT_DESCRIPTION CAL_VALUE_TXT_DESCRIPTION
+#define CALS_LIST_PERIOD_NORMAL_OSP_INT_BUSY_STATUS CAL_VALUE_INT_BUSY_STATUS
+#define CALS_LIST_PERIOD_NORMAL_OSP_INT_STATUS CAL_VALUE_INT_MEETING_STATUS
+#define CALS_LIST_PERIOD_NORMAL_OSP_INT_PRIORITY CAL_VALUE_INT_PRIORITY
+#define CALS_LIST_PERIOD_NORMAL_OSP_INT_VISIBILITY CAL_VALUE_INT_SENSITIVITY
+#define CALS_LIST_PERIOD_NORMAL_OSP_INT_IS_RECURRING CALS_VALUE_INT_RRULE_ID
+
+#define CALS_LIST_PERIOD_ALLDAY_OSP_INT_EVENTID CAL_VALUE_INT_INDEX
+#define CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTSTART_TYPE CALS_VALUE_INT_DTSTART_TYPE
+#define CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTSTART_YEAR CALS_VALUE_INT_DTSTART_YEAR
+#define CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTSTART_MONTH CALS_VALUE_INT_DTSTART_MONTH
+#define CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTSTART_MDAY CALS_VALUE_INT_DTSTART_MDAY
+#define CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTEND_TYPE CALS_VALUE_INT_DTEND_TYPE
+#define CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTEND_YEAR CALS_VALUE_INT_DTEND_YEAR
+#define CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTEND_MONTH CALS_VALUE_INT_DTEND_MONTH
+#define CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTEND_MDAY CALS_VALUE_INT_DTEND_MDAY
+#define CALS_LIST_PERIOD_ALLDAY_OSP_TXT_SUMMARY CAL_VALUE_TXT_SUMMARY
+#define CALS_LIST_PERIOD_ALLDAY_OSP_TXT_LOCATION CAL_VALUE_TXT_LOCATION
+#define CALS_LIST_PERIOD_ALLDAY_OSP_INT_CALENDAR_ID CAL_VALUE_INT_CALENDAR_ID
+#define CALS_LIST_PERIOD_ALLDAY_OSP_TXT_DESCRIPTION CAL_VALUE_TXT_DESCRIPTION
+#define CALS_LIST_PERIOD_ALLDAY_OSP_INT_BUSY_STATUS CAL_VALUE_INT_BUSY_STATUS
+#define CALS_LIST_PERIOD_ALLDAY_OSP_INT_STATUS CAL_VALUE_INT_MEETING_STATUS
+#define CALS_LIST_PERIOD_ALLDAY_OSP_INT_PRIORITY CAL_VALUE_INT_PRIORITY
+#define CALS_LIST_PERIOD_ALLDAY_OSP_INT_VISIBILITY CAL_VALUE_INT_SENSITIVITY
+#define CALS_LIST_PERIOD_ALLDAY_OSP_INT_IS_RECURRING CALS_VALUE_INT_RRULE_ID
+
+#define CALS_LIST_PERIOD_NORMAL_LOCATION_INT_EVENTID CAL_VALUE_INT_INDEX
+#define CALS_LIST_PERIOD_NORMAL_LOCATION_INT_DTSTART_TYPE CALS_VALUE_INT_DTSTART_TYPE
+#define CALS_LIST_PERIOD_NORMAL_LOCATION_LLI_DTSTART_UTIME CALS_VALUE_LLI_DTSTART_UTIME
+#define CALS_LIST_PERIOD_NORMAL_LOCATION_INT_DTEND_TYPE CALS_VALUE_INT_DTEND_TYPE
+#define CALS_LIST_PERIOD_NORMAL_LOCATION_LLI_DTEND_UTIME CALS_VALUE_LLI_DTEND_UTIME
+#define CALS_LIST_PERIOD_NORMAL_LOCATION_TXT_SUMMARY CAL_VALUE_TXT_SUMMARY
+#define CALS_LIST_PERIOD_NORMAL_LOCATION_TXT_LOCATION CAL_VALUE_TXT_LOCATION
+#define CALS_LIST_PERIOD_NORMAL_LOCATION_INT_CALENDAR_ID CAL_VALUE_INT_CALENDAR_ID
+#define CALS_LIST_PERIOD_NORMAL_LOCATION_TXT_DESCRIPTION CAL_VALUE_TXT_DESCRIPTION
+#define CALS_LIST_PERIOD_NORMAL_LOCATION_INT_BUSY_STATUS CAL_VALUE_INT_BUSY_STATUS
+#define CALS_LIST_PERIOD_NORMAL_LOCATION_INT_STATUS CAL_VALUE_INT_MEETING_STATUS
+#define CALS_LIST_PERIOD_NORMAL_LOCATION_INT_PRIORITY CAL_VALUE_INT_PRIORITY
+#define CALS_LIST_PERIOD_NORMAL_LOCATION_INT_VISIBILITY CAL_VALUE_INT_SENSITIVITY
+#define CALS_LIST_PERIOD_NORMAL_LOCATION_INT_IS_RECURRING CALS_VALUE_INT_RRULE_ID
+#define CALS_LIST_PERIOD_NORMAL_LOCATION_DBL_LATITUDE CAL_VALUE_DBL_LATITUDE
+#define CALS_LIST_PERIOD_NORMAL_LOCATION_DBL_LONGITUDE CAL_VALUE_DBL_LONGITUDE
+
+#define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_EVENTID CAL_VALUE_INT_INDEX
+#define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTSTART_TYPE CALS_VALUE_INT_DTSTART_TYPE
+#define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTSTART_YEAR CALS_VALUE_INT_DTSTART_YEAR
+#define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTSTART_MONTH CALS_VALUE_INT_DTSTART_MONTH
+#define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTSTART_MDAY CALS_VALUE_INT_DTSTART_MDAY
+#define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTEND_TYPE CALS_VALUE_INT_DTEND_TYPE
+#define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTEND_YEAR CALS_VALUE_INT_DTEND_YEAR
+#define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTEND_MONTH CALS_VALUE_INT_DTEND_MONTH
+#define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTEND_MDAY CALS_VALUE_INT_DTEND_MDAY
+#define CALS_LIST_PERIOD_ALLDAY_LOCATION_TXT_SUMMARY CAL_VALUE_TXT_SUMMARY
+#define CALS_LIST_PERIOD_ALLDAY_LOCATION_TXT_LOCATION CAL_VALUE_TXT_LOCATION
+#define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_CALENDAR_ID CAL_VALUE_INT_CALENDAR_ID
+#define CALS_LIST_PERIOD_ALLDAY_LOCATION_TXT_DESCRIPTION CAL_VALUE_TXT_DESCRIPTION
+#define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_BUSY_STATUS CAL_VALUE_INT_BUSY_STATUS
+#define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_STATUS CAL_VALUE_INT_MEETING_STATUS
+#define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_PRIORITY CAL_VALUE_INT_PRIORITY
+#define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_VISIBILITY CAL_VALUE_INT_SENSITIVITY
+#define CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_IS_RECURRING CALS_VALUE_INT_RRULE_ID
+#define CALS_LIST_PERIOD_ALLDAY_LOCATION_DBL_LATITUDE CAL_VALUE_DBL_LATITUDE
+#define CALS_LIST_PERIOD_ALLDAY_LOCATION_DBL_LONGITUDE CAL_VALUE_DBL_LONGITUDE
+
+#define CALS_LIST_PERIOD_NORMAL_ALARM_INT_EVENTID CAL_VALUE_INT_INDEX
+#define CALS_LIST_PERIOD_NORMAL_ALARM_INT_CALENDAR_ID CAL_VALUE_INT_CALENDAR_ID
+#define CALS_LIST_PERIOD_NORMAL_ALARM_INT_DTSTART_TYPE CALS_VALUE_INT_DTSTART_TYPE
+#define CALS_LIST_PERIOD_NORMAL_ALARM_LLI_DTSTART_UTIME CALS_VALUE_LLI_DTSTART_UTIME
+#define CALS_LIST_PERIOD_NORMAL_ALARM_INT_DTEND_TYPE CALS_VALUE_INT_DTEND_TYPE
+#define CALS_LIST_PERIOD_NORMAL_ALARM_LLI_DTEND_UTIME CALS_VALUE_LLI_DTEND_UTIME
+#define CALS_LIST_PERIOD_NORMAL_ALARM_LLI_ALARM_UTIME CAL_VALUE_LLI_ALARMS_TIME
+#define CALS_LIST_PERIOD_NORMAL_ALARM_INT_ALARM_ID CAL_VALUE_INT_ALARMS_ID
+
+enum cals_day {
+ CALS_SUNDAY,
+ CALS_MONDAY,
+ CALS_TUESDAY,
+ CALS_WEDNESDAY,
+ CALS_THURSDAY,
+ CALS_FRIDAY,
+ CALS_SATURDAY,
+ CALS_NODAY,
+};
+
+enum cals_freq {
+ CALS_FREQ_ONCE = 0x0,
+ CALS_FREQ_YEARLY,
+ CALS_FREQ_MONTHLY,
+ CALS_FREQ_WEEKLY,
+ CALS_FREQ_DAILY,
+ CALS_FREQ_HOURLY,
+ CALS_FREQ_MINUTELY,
+ CALS_FREQ_SECONDLY,
+};
+
+enum cals_time_type {
+ CALS_TIME_UTIME,
+ CALS_TIME_LOCALTIME,
+};
+
+enum cals_range {
+ CALS_RANGE_UNTIL,
+ CALS_RANGE_COUNT,
+ CALS_RANGE_NONE,
+};
+
+int calendar_svc_event_get_normal_list_by_period(int calendar_id, int op_code,
+ long long int start, long long int end, cal_iter **iter);
+
+int calendar_svc_event_get_allday_list_by_period(int calendar_id, int op_code,
+ int dtstart_year, int dtstart_mon, int dtstart_day,
+ int dtend_year, int dtend_mon, int dtend_day, cal_iter **iter);
+
+int calendar_svc_struct_set_lli(cal_struct *record, const char *field, long long int llival);
+
+long long int calendar_svc_struct_get_lli(cal_struct *record, const char *field);
+
+int calendar_svc_todo_get_list_by_period(int calendar_id,
+ long long int due_from, long long int dueto, int priority, int status, cal_iter **iter);
+int calendar_svc_todo_get_count_by_period(int calendar_id,
+ long long int due_from, long long int dueto, int priority, int status, int *count);
+int calendar_svc_event_delete_normal_instance(int event_id, long long int dtstart_utime);
+int calendar_svc_event_delete_allday_instance(int event_id, int dtstart_year, int dtstart_month, int dtstart_mday);
#ifdef __cplusplus
}
#endif
/**
* cal_struct is an opaque type, it must be used via accessor functions.
* @ingroup common
- * @see calendar_svc_find_event_list(), calendar_svc_get_updated_event_list()
+ * @see calendar_svc_find_event_list(), calendar_svc_event_get_changes()
* calendar_svc_get_event_by_period(), calendar_svc_iter_get_info(),
* calendar_svc_iter_next(), calendar_svc_iter_remove()
*/
cal_struct *event=NULL;
cal_value *attendee1=NULL,*attendee2=NULL;
GList *attendee_list=NULL;
- time_t cur_time = 0;
cal_iter *iter=NULL;
int ret = 0;
int index = 0;
+ int version = 0;
- cur_time = time(NULL);
calendar_svc_connect();
- calendar_svc_get_updated_event_list(0, cur_time,&iter);
+ calendar_svc_event_get_changes(0, version, &iter);
ret = calendar_svc_iter_next(iter);
while(CAL_SUCCESS == ret)
{
#define CALS_SECURITY_DIR_DEFAULT_PERMISSION 0770
#define CALS_TABLE_SCHEDULE "schedule_table"
-#define CALS_TABLE_ALARM "cal_alarm_table"
+#define CALS_TABLE_ALARM "alarm_table"
#define CALS_TABLE_CALENDAR "calendar_table"
-#define CALS_TABLE_RECURRENCY_LOG "recurrency_log_table"
#define CALS_TABLE_PARTICIPANT "cal_participant_table"
-#define CALS_TABLE_MEETING_CATEGORY "cal_meeting_category_table"
#define CALS_TABLE_TIMEZONE "timezone_table"
+#define CALS_TABLE_VERSION "version_table"
+#define CALS_TABLE_DELETED "deleted_table"
+#define CALS_TABLE_RRULE "rrule_table"
+#define CALS_TABLE_NORMAL_INSTANCE "normal_instance_table"
+#define CALS_TABLE_ALLDAY_INSTANCE "allday_instance_table"
#endif /* __CALENDAR_SVC_DB_INFO_H__ */
#define DLOG(prio, fmt, arg...) \
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 warn_if(expr, fmt, arg...) do { \
if (expr) { \
- ERR(fmt, ##arg); \
+ WARN(fmt, ##arg); \
} \
} while (0)
#define ret_if(expr) do { \
Name: libslp-calendar
Summary: DB library for calendar
-Version: 0.1.12
-Release: 29
+Version: 0.1.13
+Release: 36
Group: System/Libraries
License: Apache 2.0
Source0: %{name}-%{version}.tar.gz
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(alarm-service)
+BuildRequires: pkgconfig(icu-i18n)
+BuildRequires: pkgconfig(appsvc)
%description
DB library for calendar
chmod 660 /opt/dbspace/.calendar-svc.db-journal
chmod 660 /opt/data/calendar-svc/.CALENDAR_SVC_*
+vconftool set -t int db/calendar/timezone_on_off 0 -g 6003
+vconftool set -t string db/calendar/timezone_path "Asia/Seoul" -g 6003
+
%postun -p /sbin/ldconfig
id INTEGER PRIMARY KEY AUTOINCREMENT,
account_id INTEGER,
type INTEGER,
-category INTEGER,
summary TEXT,
description TEXT,
location TEXT,
-all_day_event INTEGER,
-start_date_time INTEGER,
-end_date_time INTEGER,
-repeat_item INTEGER,
-repeat_interval INTEGER,
-repeat_until_type INTEGER,
-repeat_occurrences INTEGER,
-repeat_end_date INTEGER,
-sun_moon INTEGER,
-week_start INTEGER,
-week_flag TEXT,
-day_date INTEGER,
-last_modified_time INTEGER,
+categories TEXT,
+exdate TEXT,
missed INTEGER,
task_status INTEGER,
priority INTEGER,
organizer_email TEXT,
meeting_status INTEGER,
gcal_id TEXT,
-deleted INTEGER,
updated TEXT,
location_type INTEGER,
location_summary TEXT,
original_event_id INTEGER,
latitude DOUBLE,
longitude DOUBLE,
-is_deleted INTEGER,
-tz_name TEXT,
-tz_city_name TEXT,
email_id INTEGER,
availability INTEGER,
-created_date_time INTEGER,
-completed_date_time INTEGER,
-progress INTEGER
+created_time INTEGER,
+completed_time INTEGER,
+progress INTEGER,
+changed_ver INTEGER,
+created_ver INTEGER,
+is_deleted INTEGER DEFAULT 0,
+dtstart_type INTEGER,
+dtstart_utime INTEGER,
+dtstart_datetime TEXT,
+dtstart_tzid TEXT,
+dtend_type INTEGER,
+dtend_utime INTEGER,
+dtend_datetime TEXT,
+dtend_tzid TEXT,
+last_mod INTEGER,
+rrule_id INTEGER DEFAULT 0
);
-CREATE INDEX sch_idx1 ON schedule_table(type, category);
+CREATE INDEX sch_idx1 ON schedule_table(type);
CREATE TRIGGER trg_sch_del AFTER DELETE ON schedule_table
BEGIN
- DELETE FROM cal_alarm_table WHERE event_id = old.id;
+ DELETE FROM alarm_table WHERE event_id = old.id;
END;
+CREATE TABLE rrule_table
+(
+id INTEGER PRIMARY KEY AUTOINCREMENT,
+event_id INTEGER,
+freq INTEGER DEFAULT 0,
+range_type INTEGER,
+until_type INTEGER,
+until_utime INTEGER,
+until_datetime TEXT,
+count INTEGER,
+interval INTEGER,
+bysecond TEXT,
+byminute TEXT,
+byhour TEXT,
+byday TEXT,
+bymonthday TEXT,
+byyearday TEXT,
+byweekno TEXT,
+bymonth TEXT,
+bysetpos TEXT,
+wkst INTEGER
+);
+
+CREATE TABLE normal_instance_table
+(
+event_id INTEGER,
+dtstart_utime INTEGER,
+dtend_utime INTEGER
+);
+
+CREATE TABLE allday_instance_table
+(
+event_id INTEGER,
+dtstart_datetime TEXT,
+dtend_datetime TEXT
+);
+
CREATE TABLE cal_participant_table
(
event_id INTEGER,
attendee_uid TEXT
);
-CREATE TABLE cal_meeting_category_table
-(
-event_id INTEGER,
-category_name TEXT
-);
-
-CREATE TABLE recurrency_log_table
-(
-uid TEXT,
-start_date_time INTEGER,
-end_date_time INTEGER,
-event_id INTEGER,
-exception_event_id INTEGER,
-updated INTEGER
-);
-
CREATE TABLE calendar_table
(
calendar_id TEXT,
day_light_bias INTEGER
);
-CREATE TABLE cal_alarm_table
+CREATE TABLE alarm_table
(
event_id INTEGER,
alarm_time INTEGER,
alarm_id INTEGER
);
-INSERT INTO calendar_table VALUES(0,0,0,0,'default calendar',0,0,'76.198.86.255',0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,-1,0,3);
+CREATE TABLE deleted_table
+(
+schedule_id INTEGER,
+schedule_type INTEGER,
+calendar_id INTEGER,
+deleted_ver INTEGER
+);
+CREATE INDEX deleted_schedule_ver_idx ON deleted_table(deleted_ver);
+
+CREATE TABLE version_table
+(
+ver INTEGER PRIMARY KEY
+);
+INSERT INTO version_table VALUES(0);
+
+INSERT INTO calendar_table VALUES(0,0,0,0,'Default event calendar',0,0,'224.167.79.255',0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,-1,0,3);
+INSERT INTO calendar_table VALUES(0,0,0,0,'Default todo calendar',0,0,'224.167.79.255',0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,-1,0,3);
#include <stdlib.h>
#include <errno.h>
#include <alarm.h>
+#include <appsvc.h>
#include "cals-internal.h"
#include "cals-typedef.h"
#include "cals-db-info.h"
#include "cals-sqlite.h"
-#include "cals-tz-utils.h"
#include "cals-utils.h"
#include "cals-alarm.h"
+#include "cals-time.h"
-#define PKG_CALENDAR_APP "org.tizen.efl-calendar"
+#define PKG_CALENDAR_APP "org.tizen.calendar"
int cals_alarm_remove(int type, int related_id)
{
return CAL_SUCCESS;
}
-static inline int _cals_alarm_add(const int event_id, cal_alarm_info_t *alarm_info)
+int _cals_alarm_add_to_db(const int event_id, cal_alarm_info_t *alarm_info)
{
- int rc = -1;
+ CALS_FN_CALL;
+ int r;
sqlite3_stmt *stmt = NULL;
- char sql_value[CALS_SQL_MAX_LEN] = {0};
- time_t conv_alarm_time;
-
- conv_alarm_time = cals_mktime(&alarm_info->alarm_time);
+ char query[CALS_SQL_MAX_LEN] = {0};
- sprintf(sql_value, "INSERT INTO %s(event_id,alarm_time,remind_tick,remind_tick_unit,alarm_tone,alarm_description,alarm_type,alarm_id) "
- "VALUES(%d,%ld,%d,%d,?,?,%d,%d)", CALS_TABLE_ALARM,
+ sprintf(query, "INSERT INTO %s ("
+ "event_id, "
+ "alarm_time, remind_tick, remind_tick_unit, alarm_tone, "
+ "alarm_description, alarm_type, alarm_id "
+ ") VALUES ( "
+ "%d, "
+ "%lld, %d, %d, ?, "
+ "?, %d, %d )",
+ CALS_TABLE_ALARM,
event_id,
- conv_alarm_time,
- alarm_info->remind_tick,
- alarm_info->remind_tick_unit,
- alarm_info->alarm_type,
- alarm_info->alarm_id);
+ alarm_info->alarm_time, alarm_info->remind_tick, alarm_info->remind_tick_unit,
+ alarm_info->alarm_type, alarm_info->alarm_id);
- stmt = cals_query_prepare(sql_value);
+ DBG("query(%s)\n", query);
+ stmt = cals_query_prepare(query);
retvm_if(NULL == stmt, CAL_ERR_DB_FAILED, "cals_query_prepare() Failed");
if (alarm_info->alarm_tone)
if (alarm_info->alarm_description)
cals_stmt_bind_text(stmt, 2, alarm_info->alarm_description);
- rc = cals_stmt_step(stmt);
- if (CAL_SUCCESS != rc) {
- sqlite3_finalize(stmt);
- ERR("cals_stmt_step() Failed(%d)", rc);
- return rc;
- }
-
+ r = cals_stmt_step(stmt);
sqlite3_finalize(stmt);
+ if (CAL_SUCCESS != r) {
+ ERR("cals_stmt_step() Failed(%d)", r);
+ return r;
+ }
+
return CAL_SUCCESS;
}
-int cals_alarm_add(int event_id, cal_alarm_info_t *alarm_info, struct tm *start_date_time)
+static long long int _cals_get_interval(cal_alarm_info_t *alarm_info, struct cals_time *start_time)
{
- CALS_FN_CALL;
- int ret = 0;
- alarm_id_t alarm_id;
- alarm_date_t alarm_date = {0};
- alarm_entry_t *aet = NULL;
- struct tm time;
- time_t base_tt, alarm_tt;
+ long long int iv, diff;
+ int sec;
+ struct cals_time at;
+
+ if (alarm_info->remind_tick_unit == CAL_SCH_TIME_UNIT_SPECIFIC) {
+ at.type = CALS_TIME_UTIME;
+ at.utime = alarm_info->alarm_time;
+ return cals_time_diff_with_now(&at);
+ }
- if(alarm_info->remind_tick_unit == CAL_SCH_TIME_UNIT_OFF)
- return CAL_INVALID_INDEX;
+ switch (alarm_info->remind_tick_unit) {
+ case CAL_SCH_TIME_UNIT_MIN:
+ sec = 60;
+ break;
+ case CAL_SCH_TIME_UNIT_HOUR:
+ sec = 3600;
+ break;
+ case CAL_SCH_TIME_UNIT_DAY:
+ sec = ONE_DAY_SECONDS;
+ break;
+ case CAL_SCH_TIME_UNIT_WEEK:
+ sec = ONE_WEEK_SECONDS;
+ break;
+ case CAL_SCH_TIME_UNIT_MONTH:
+ sec = ONE_MONTH_SECONDS;
+ break;
+ case CAL_SCH_TIME_UNIT_OFF:
+ default:
+ return 0;
+ }
- //update the alarm time
- aet = alarmmgr_create_alarm();
- retvm_if(NULL == aet, CAL_ERR_ALARMMGR_FAILED, "alarmmgr_create_alarm() Failed");
+ sec = sec * alarm_info->remind_tick;
+ if (start_time->type == CALS_TIME_UTIME) {
+ alarm_info->alarm_time = start_time->utime - sec;
- //calculate time
- if(alarm_info->remind_tick_unit == CAL_SCH_TIME_UNIT_SPECIFIC) {
- base_tt = cals_mktime(&alarm_info->alarm_time);
} else {
- int sec = 0;
-
- switch (alarm_info->remind_tick_unit) {
- case CAL_SCH_TIME_UNIT_MIN:
- sec = 60;
- break;
- case CAL_SCH_TIME_UNIT_HOUR:
- sec = 3600;
- break;
- case CAL_SCH_TIME_UNIT_DAY:
- sec = ONE_DAY_SECONDS;
- break;
- case CAL_SCH_TIME_UNIT_WEEK:
- sec = ONE_WEEK_SECONDS;
- break;
- case CAL_SCH_TIME_UNIT_MONTH:
- sec = ONE_MONTH_SECONDS;
- break;
- case CAL_SCH_TIME_UNIT_OFF:
- default:
- alarmmgr_free_alarm(aet);
- return CAL_INVALID_INDEX;
- }
+ alarm_info->alarm_time = cals_time_convert_to_lli(start_time) - sec;
+
+ }
+
+ diff = cals_time_diff_with_now(start_time);
+ iv = diff - (long long int)sec;
+ DBG("tick(%d) tick unit(%d) "
+ ",so sets (%lld) = diff(%lld) - sec(%lld)",
+ alarm_info->remind_tick, alarm_info->remind_tick_unit,
+ iv, diff, (long long int)sec);
+
+ return iv;
+}
- sec = sec * alarm_info->remind_tick;
+bundle *_get_appsvc(const char *pkg)
+{
+ int r;
+ bundle *b;
- base_tt = cals_mktime(start_date_time) - sec;
+ b = bundle_create();
+ if (!b) {
+ ERR("bundle_create failed");
+ return NULL;
}
- calendar_svc_util_gmt_to_local(base_tt,&alarm_tt);
- cals_tmtime_r(&alarm_tt,&time);
- TMDUMP(time);
-
- alarm_date.year = time.tm_year + 1900;
- alarm_date.month = time.tm_mon + 1;
- alarm_date.day = time.tm_mday;
- alarm_date.hour = time.tm_hour;
- alarm_date.min = time.tm_min;
- alarm_date.sec = time.tm_sec;
-
- ret = alarmmgr_set_time(aet, alarm_date);
- if (ret < 0) {
- alarmmgr_free_alarm(aet);
- ERR("alarmmgr_set_time() Failed(%d)", ret);
- return CAL_ERR_ALARMMGR_FAILED;
+ r = appsvc_set_pkgname(b, pkg);
+ appsvc_set_operation(b, APPSVC_OPERATION_DEFAULT);
+ if (r) {
+ bundle_free(b);
+ ERR("appsvc_set_pkgname failed (%d)", r);
+ return NULL;
}
- ret = alarmmgr_set_repeat_mode(aet, 0, 0);
- if (ret < 0) {
- alarmmgr_free_alarm(aet);
- ERR("alarmmgr_set_repeat_mode() Failed(%d)", ret);
- return CAL_ERR_ALARMMGR_FAILED;
+ return b;
+}
+
+int _cals_alarm_add_to_alarmmgr(struct cals_time *start_time, cal_alarm_info_t *alarm_info)
+{
+ int ret;
+ long long int iv;
+ bundle *b;
+ alarm_id_t alarm_id = 0;
+
+ iv = _cals_get_interval(alarm_info, start_time);
+ if (iv < 0) {
+ DBG("Tried to register past event, so passed registration");
+ return 0;
+
+ } else if (iv == 0) {
+ DBG("Set no alarm");
+ return 0;
}
- ret = alarmmgr_set_type(aet, ALARM_TYPE_DEFAULT);
- if (ret < 0) {
- alarmmgr_free_alarm(aet);
- ERR("alarmmgr_set_type() Failed(%d)", ret);
- return CAL_ERR_ALARMMGR_FAILED;
+ b = _get_appsvc(PKG_CALENDAR_APP);
+ if (!b) {
+ ERR("_get_appsvc failed");
+ return CAL_ERR_FAIL;
}
- ret = alarmmgr_add_alarm_with_localtime(aet, PKG_CALENDAR_APP, &alarm_id);
- if (ret < 0) {
- alarmmgr_free_alarm(aet);
- ERR("alarmmgr_add_alarm_with_localtime() Failed(%d)", ret);
+ ret = alarmmgr_add_alarm_appsvc(ALARM_TYPE_DEFAULT, (long int)iv, 0, b, &alarm_id);
+ bundle_free(b);
+
+ if (ret) {
+ ERR("alarmmgr_add_alarm_appsvc failed (%d)", ret);
return CAL_ERR_ALARMMGR_FAILED;
}
-
- alarmmgr_free_alarm(aet);
+ DBG("Set alarm id(%d)", alarm_id);
alarm_info->alarm_id = alarm_id;
- _cals_alarm_add(event_id, alarm_info);
+ return 0;
+}
+
+int cals_alarm_add(int event_id, cal_alarm_info_t *alarm_info, struct cals_time *start_time)
+{
+ CALS_FN_CALL;
+ int ret;
+
+ if(alarm_info->remind_tick_unit == CAL_SCH_TIME_UNIT_OFF)
+ return CAL_SUCCESS;
+
+ ret = _cals_alarm_add_to_alarmmgr(start_time, alarm_info);
+ if (ret) {
+ ERR("Failed to register alarm");
+ return CAL_ERR_FAIL;
+ }
+
+ ret = _cals_alarm_add_to_db(event_id, alarm_info);
+ if (ret) {
+ ERR("Failed to add alarm to db");
+ return CAL_ERR_FAIL;
+ }
return CAL_SUCCESS;
}
{
char query[CALS_SQL_MIN_LEN];
- sprintf(query, "SELECT event_id FROM cal_alarm_table WHERE alarm_id=%d", alarm_id);
+ sprintf(query, "SELECT event_id FROM %s WHERE alarm_id=%d", CALS_TABLE_ALARM, alarm_id);
return cals_query_get_first_int_result(query);
}
alarm_info->event_id = sqlite3_column_int(stmt, 0);
- long int temp = 0;
- temp = sqlite3_column_int(stmt, 1);
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime(&temp),&(alarm_info->alarm_time));
- alarm_info->remind_tick = sqlite3_column_int(stmt,2);
+ alarm_info->alarm_time = sqlite3_column_int64(stmt, 1);
+ alarm_info->remind_tick = sqlite3_column_int(stmt, 2);
alarm_info->remind_tick_unit = sqlite3_column_int(stmt, 3);
alarm_info->alarm_tone = SAFE_STRDUP(sqlite3_column_text(stmt, 4));
alarm_info->alarm_description = SAFE_STRDUP(sqlite3_column_text(stmt, 5));
return CAL_SUCCESS;
}
-
#ifndef __CALENDAR_SVC_ALARM_H__
#define __CALENDAR_SVC_ALARM_H__
+#include "cals-time.h"
enum {
CALS_ALARM_REMOVE_BY_EVENT_ID,
CALS_ALARM_REMOVE_ALL,
};
int cals_alarm_remove(int type, int related_id);
-int cals_alarm_add(int event_id, cal_alarm_info_t *alarm_info, struct tm *start_date_time);
+int cals_alarm_add(int event_id, cal_alarm_info_t *alarm_info, struct cals_time *start_time);
int cals_alarm_get_event_id(int alarm_id);
int cals_get_alarm_info(const int event_id, GList **alarm_list);
return CAL_SUCCESS;
}
-int cals_delete_calendar(int index)
+int cals_delete_calendar(int calendar_id)
{
int ret = 0;
- char query[CALS_SQL_MAX_LEN] = {0};
+ char query[CALS_SQL_MIN_LEN] = {0};
ret = cals_begin_trans();
retvm_if(CAL_SUCCESS != ret, ret, "cals_begin_trans() Failed(%d)", ret);
- sprintf(query,"DELETE FROM %s WHERE rowid = %d", CALS_TABLE_CALENDAR, index);
+ snprintf(query, sizeof(query), "DELETE FROM %s WHERE rowid = %d",
+ CALS_TABLE_CALENDAR, calendar_id);
ret = cals_query_exec(query);
if(CAL_SUCCESS != ret) {
ERR("cals_query_exec() Failed(%d)", ret);
return ret;
}
- time_t current_time = time(NULL);
-
- sprintf(query,"UPDATE %s SET is_deleted = 1, sync_status = %d, last_modified_time = %ld WHERE calendar_id = %d",
- CALS_TABLE_SCHEDULE, CAL_SYNC_STATUS_DELETED,(long int)current_time, index);
+ snprintf(query, sizeof(query), "DELETE FROM %s WHERE calendar_id = %d",
+ CALS_TABLE_SCHEDULE, calendar_id);
+ ret = cals_query_exec(query);
+ if (CAL_SUCCESS != ret) {
+ ERR("cals_query_exec() Failed(%d)", ret);
+ cals_end_trans(false);
+ return ret;
+ }
+ snprintf(query, sizeof(query), "DELETE FROM %s WHERE calendar_id = %d",
+ CALS_TABLE_DELETED, calendar_id);
ret = cals_query_exec(query);
if (CAL_SUCCESS != ret) {
ERR("cals_query_exec() Failed(%d)", ret);
cals_end_trans(false);
return ret;
}
- ret = cals_alarm_remove(CALS_ALARM_REMOVE_BY_CALENDAR_ID, index);
+
+ ret = cals_alarm_remove(CALS_ALARM_REMOVE_BY_CALENDAR_ID, calendar_id);
if (CAL_SUCCESS != ret) {
ERR("cals_alarm_remove() Failed(%d)", ret);
cals_end_trans(false);
#include "cals-db-info.h"
#include "cals-typedef.h"
#include "cals-utils.h"
-#include "cals-tz-utils.h"
#include "cals-ical.h"
-#include "cals-recurrence-utils.h"
#include "cals-alarm.h"
#include "cals-sqlite.h"
#include "cals-schedule.h"
* *
************************************************************************************************/
-bool cal_db_service_init_schedule_record(cal_sch_t *sch_record, int *error_code)
-{
- time_t t = time(NULL);
- tzset();
- struct tm *tm = NULL; //localtime(&t);
- struct tm ttm;
-
- tm = localtime_r(&t,&ttm);
-
- if(NULL == tm)
- {
- return false;
- }
- struct tm temp_date_time = {0};
- struct tm current_time = {0};
-
- retvm_if(NULL == error_code, false, "The error_code is NULL");
-
- if(NULL == sch_record) {
- ERR("The sch_record is NULL");
- *error_code = CAL_ERR_ARG_INVALID;
- return false;
- }
-
- memset(sch_record,0,sizeof(cal_sch_t));
-
- sch_record->index = CAL_INVALID_INDEX;
- sch_record->cal_type = CAL_EVENT_SCHEDULE_TYPE;
- sch_record->sch_category = CAL_SCH_APPOINTMENT;
- memset(&temp_date_time, 0 ,sizeof(struct tm));
- memset(&sch_record->start_date_time, 0 ,sizeof(struct tm));
- memset(&sch_record->end_date_time, 0 ,sizeof(struct tm));
- memset(&sch_record->repeat_end_date, 0 ,sizeof(struct tm));
- memset(&sch_record->alarm_time, 0 ,sizeof(struct tm));
- memcpy(¤t_time,tm,sizeof(struct tm));
- //CALS_DBG("!!!!!!!!!!!----------current hour is %d, minutes %d----------------",current_time.tm_hour,current_time.tm_min);
-
- memcpy(&sch_record->start_date_time,¤t_time,sizeof(struct tm));
- memcpy(&sch_record->alarm_time,¤t_time,sizeof(struct tm));
- memcpy(&sch_record->end_date_time,¤t_time,sizeof(struct tm));
- sch_record->start_date_time.tm_sec = 0;
- sch_record->alarm_time.tm_sec = 0;
- sch_record->end_date_time.tm_sec = 0;
- sch_record->end_date_time.tm_hour ++;
- if (sch_record->end_date_time.tm_hour > 23)
- {
- sch_record->end_date_time.tm_hour = 0;
- cal_db_service_get_tomorrow(&sch_record->end_date_time);
- }
-
- temp_date_time.tm_year = 137;
- temp_date_time.tm_mon = 11;
- temp_date_time.tm_mday = 31;
- memcpy(&sch_record->repeat_end_date,&temp_date_time,sizeof(struct tm));
-
- sch_record->remind_tick = CAL_INVALID_INDEX; //inintial
- sch_record->repeat_term = CAL_REPEAT_NONE;
- sch_record->day_date = 1;
- sch_record->calendar_type = CAL_PHONE_CALENDAR;
- return true;
-}
bool cal_db_service_free_participant(cal_participant_info_t* paritcipant_info, int *error_code)
{
return true;
}
-bool cal_db_service_free_category(cal_category_info_t* category_info, int *error_code)
-{
- if(NULL == category_info)
- {
- return true;
- }
- CAL_FREE(category_info->category_name);
- return true;
-}
-
-
bool cal_db_service_free_full_record(cal_sch_full_t *sch_full_record, int *error_code)
{
retex_if(error_code == NULL, ,"error_code is NULL.");
CAL_FREE(sch_full_record->summary);
CAL_FREE(sch_full_record->description);
CAL_FREE(sch_full_record->location);
- CAL_FREE(sch_full_record->week_flag);
+ CAL_FREE(sch_full_record->categories);
CAL_FREE(sch_full_record->uid);
CAL_FREE(sch_full_record->organizer_name);
CAL_FREE(sch_full_record->organizer_email);
CAL_FREE(sch_full_record->etag);
CAL_FREE(sch_full_record->edit_uri);
CAL_FREE(sch_full_record->gevent_id);
- CAL_FREE(sch_full_record->tz_name);
- CAL_FREE(sch_full_record->tz_city_name);
-
- if(sch_full_record->exception_date_list)
- {
- head = sch_full_record->exception_date_list;
- while (sch_full_record->exception_date_list)
- {
- value = sch_full_record->exception_date_list->data;
- if(value)
- {
- free(value->user_data);
- free(value);
- }
- sch_full_record->exception_date_list = sch_full_record->exception_date_list->next;
- }
- g_list_free(head);
- sch_full_record->exception_date_list = NULL;
- }
if (sch_full_record->attendee_list)
{
g_list_free(head);
sch_full_record->attendee_list = NULL;
}
-
- if (sch_full_record->meeting_category)
- {
- head = sch_full_record->meeting_category;
- while (sch_full_record->meeting_category)
- {
- value = sch_full_record->meeting_category->data;
- if(NULL != value)
- {
- if(NULL != value->user_data)
- {
- cal_db_service_free_category((cal_category_info_t*)value->user_data,error_code);
- CAL_FREE(value->user_data);
- }
- CAL_FREE(value);
- }
- sch_full_record->meeting_category = sch_full_record->meeting_category->next;
- }
- g_list_free(head);
- sch_full_record->meeting_category = NULL;
- }
-
- return true;
-
-CATCH:
-
- return false;
-}
-
-
-bool cal_db_service_free_sch_record(cal_sch_t *sch_record, int *error_code)
-{
- retex_if(error_code == NULL, ,"error_code is NULL.");
- retex_if(sch_record == NULL, *error_code = CAL_ERR_ARG_INVALID,"sch_record is NULL.");
-
- CAL_FREE(sch_record->summary);
- CAL_FREE(sch_record->description);
- CAL_FREE(sch_record->location);
- CAL_FREE(sch_record->week_flag);
-
return true;
CATCH:
* calendar event table add/edit APIs *
* *
************************************************************************************************/
-bool cal_db_service_get_meeting_category_info_by_index(const int event_id, GList** record_list, int *error_code)
-{
- int rc = -1;
- char sql_value[CALS_SQL_MAX_LEN] = {0};
- cal_category_info_t* category_info = NULL;
- sqlite3_stmt *stmt = NULL;
- cal_value *cvalue = NULL;
-
- retex_if(error_code == NULL, ,"cal_db_service_get_record_by_index: The error_code is NULL.");
-
- //check if db opened
- retex_if(NULL == calendar_db_handle, *error_code = CAL_ERR_DB_NOT_OPENED, "The calendar database hasn't been opened.");
-
- sprintf(sql_value, "select * from cal_meeting_category_table where event_id = %d;", event_id);
-
- rc = sqlite3_prepare_v2(calendar_db_handle, sql_value, strlen(sql_value), &stmt, NULL);
- retex_if(rc != SQLITE_OK, *error_code = CAL_ERR_DB_FAILED, "EDBStmtCreate error!!");
-
- rc = sqlite3_step(stmt);
- while(rc == SQLITE_ROW)
- {
- cvalue = (cal_value*)malloc(sizeof(cal_value));
- retex_if(NULL == cvalue,,"[ERROR]cal_db_service_get_participant_info_by_index:Failed to malloc!");
-
- cvalue->v_type = CAL_EVENT_CATEGORY;
- cvalue->user_data = category_info = (cal_category_info_t*)malloc(sizeof(cal_category_info_t));
- retex_if(category_info == NULL, *error_code = CAL_ERR_DB_FAILED, "cal_category_info_t malloc error!!");
-
- memset(category_info,0x00,sizeof(cal_category_info_t));
-
- category_info->event_id = sqlite3_column_int(stmt, 0);
-
- cal_db_get_text_from_stmt(stmt,&(category_info->category_name),1);
-
- *record_list = g_list_append(*record_list, (gpointer)cvalue);
-
- rc = sqlite3_step(stmt);
- retex_if(SQLITE_ROW != rc && SQLITE_OK != rc && SQLITE_DONE != rc,*error_code = CAL_ERR_DB_FAILED,"__cal_db_service_get_meeting_category_info_by_index:Failed to query.");
- }
-
- if(NULL != stmt)
- {
- sqlite3_finalize(stmt);
- stmt = NULL;
- }
-
- return true;
-
-CATCH:
-
- if(cvalue){
- CAL_FREE(cvalue->user_data);
- CAL_FREE(cvalue);
- }
-
- if (stmt)
- {
- sqlite3_finalize(stmt);
- stmt = NULL;
-
- }
-
- return false;
-}
-
-
int cal_service_add_participant_info(const int event_id, const cal_participant_info_t* current_record)
{
int ret = -1;
bool cal_db_service_get_participant_info_by_index(const int panticipant_index, GList** record_list, int *error_code)
{
- int rc = -1;
- char sql_value[CALS_SQL_MAX_LEN] = {0};
+ int rc = -1;
+ char sql_value[CALS_SQL_MAX_LEN] = {0};
cal_participant_info_t* participant_info = NULL;
sqlite3_stmt *stmt = NULL;
cal_value *cvalue = NULL;
return false;
}
-bool cal_db_service_get_record_full_field_by_index(const int index, cal_sch_full_t *returned_record, int *error_code)
+int __cal_service_delete_all_records(const int account_id, const cals_sch_type record_type)
{
- int rc = -1;
- char sql_value[CALS_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
-
- retex_if(error_code == NULL, ,"The error_code is NULL.\n");
- retex_if(returned_record == NULL, *error_code = CAL_ERR_ARG_INVALID,"The returned_record is NULL.\n");
-
- //check input parameter
- retex_if (!__check_record_index_valid(index),*error_code = CAL_ERR_ARG_INVALID,"The index is invalid." );
-
- //check if db opened
- retex_if(NULL == calendar_db_handle, *error_code = CAL_ERR_DB_NOT_OPENED, "The calendar database hasn't been opened.");
-
- sprintf(sql_value, "SELECT * FROM %s WHERE id = %d and is_deleted = 0;", CALS_TABLE_SCHEDULE, index);
-
- rc = sqlite3_prepare_v2(calendar_db_handle, sql_value, strlen(sql_value), &stmt, NULL);
- retex_if(rc != SQLITE_OK, *error_code = CAL_ERR_DB_FAILED, "Failed to get stmt!!");
-
- rc = sqlite3_step(stmt);
- retex_if(rc != SQLITE_ROW && rc != SQLITE_OK && rc != SQLITE_DONE, *error_code = CAL_ERR_DB_FAILED, "Failed to query!!");
-
- cals_stmt_get_full_schedule(stmt,returned_record,false);
-
- cal_db_service_get_participant_info_by_index(index, &(returned_record->attendee_list), error_code);
- cal_db_service_get_meeting_category_info_by_index(index, &(returned_record->meeting_category), error_code);
-
- if(NULL!= stmt)
- {
- sqlite3_finalize(stmt);
- stmt=NULL;
- }
-
- //calendar_svc_end_trans();
-
- return true;
-
-CATCH:
-
- if(NULL!= stmt)
- {
- sqlite3_finalize(stmt);
- stmt=NULL;
- }
+ int ret = 0;
+ char query_logging[CALS_SQL_MIN_LEN] = {0};
+ char query_delete[CALS_SQL_MIN_LEN] = {0};
- //calendar_svc_end_trans();
+ if (account_id == LOCAL_ACCOUNT_ID) {
+ snprintf(query_logging, sizeof(query_logging), "INSERT INTO %s "
+ "SELECT id, type, calendar_id, %d FROM %s "
+ "WHERE type = %d AND account_id = %d",
+ CALS_TABLE_DELETED,
+ cals_get_next_ver(), CALS_TABLE_SCHEDULE,
+ record_type, account_id);
- return false;
-}
+ snprintf(query_delete, sizeof(query_delete), "DELETE FROM %s "
+ "WHERE type = %d AND account_id = %d",
+ CALS_TABLE_SCHEDULE,
+ record_type, account_id);
-int __cal_service_delete_all_records(const int account_id, const cal_event_type_t record_type)
-{
- int ret = 0;
- char query[CALS_SQL_MAX_LEN] = {0};
+ } else {
+ snprintf(query_logging, sizeof(query_logging), "UPDATE %s "
+ "SET is_deleted = 1, last_modified_time = %ld, changed_ver = %d "
+ "WHERE type = %d AND accoutn_id = %d ",
+ CALS_TABLE_SCHEDULE,
+ time(NULL), cals_get_next_ver(),
+ record_type, account_id);
- time_t current_time = time(NULL);
- if(account_id)
- {
- switch (record_type)
- {
- case CAL_EVENT_NONE:
- sprintf(query, "UPDATE %s SET is_deleted = 1, sync_status = %d, last_modified_time = %ld WHERE account_id = %d",
- CALS_TABLE_SCHEDULE, CAL_SYNC_STATUS_DELETED,(long int)current_time,account_id);
- break;
- case CAL_EVENT_SCHEDULE_TYPE:
- sprintf(query, "UPDATE %s SET is_deleted = 1, sync_status = %d, last_modified_time = %ld WHERE (type = 1 and account_id = %d)",
- CALS_TABLE_SCHEDULE, CAL_SYNC_STATUS_DELETED,(long int)current_time,account_id);
- break;
- case CAL_EVENT_TODO_TYPE:
- sprintf(query, "UPDATE %s SET is_deleted = 1, sync_status = %d, last_modified_time = %ld WHERE (type = 2 and account_id = %d)",
- CALS_TABLE_SCHEDULE, CAL_SYNC_STATUS_DELETED,(long int)current_time,account_id);
- break;
- case CAL_EVENT_MEMO_TYPE:
- sprintf(query, "UPDATE %s SET is_deleted = 1, sync_status = %d, last_modified_time = %ld WHERE (type = 3 and locked_flag = 0 and account_id = %d)",
- CALS_TABLE_SCHEDULE, CAL_SYNC_STATUS_DELETED,(long int)current_time,account_id);
- break;
- default:
- ERR("Unknown type(%d)", record_type);
- return CAL_ERR_ARG_INVALID;
- }
- }
- else
- {
- switch (record_type)
- {
- case CAL_EVENT_NONE:
- sprintf(query, "UPDATE %s SET is_deleted = 1, sync_status = %d, last_modified_time = %ld",
- CALS_TABLE_SCHEDULE, CAL_SYNC_STATUS_DELETED,(long int)current_time);
- break;
- case CAL_EVENT_SCHEDULE_TYPE:
- sprintf(query, "UPDATE %s SET is_deleted = 1, sync_status = %d, last_modified_time = %ld WHERE type = 1",
- CALS_TABLE_SCHEDULE, CAL_SYNC_STATUS_DELETED,(long int)current_time);
- break;
- case CAL_EVENT_TODO_TYPE:
- sprintf(query, "UPDATE %s SET is_deleted = 1, sync_status = %d, last_modified_time = %ld WHERE type = 2",
- CALS_TABLE_SCHEDULE, CAL_SYNC_STATUS_DELETED,(long int)current_time);
- break;
- case CAL_EVENT_MEMO_TYPE:
- sprintf(query, "UPDATE %s SET is_deleted = 1, sync_status = %d, last_modified_time = %ld WHERE (type = 3 and locked_flag = 0)",
- CALS_TABLE_SCHEDULE, CAL_SYNC_STATUS_DELETED,(long int)current_time);
- break;
- default:
- ERR("Unknown type(%d)", record_type);
- return CAL_ERR_ARG_INVALID;
- }
}
ret = cals_begin_trans();
retvm_if(CAL_SUCCESS != ret, ret, "cals_begin_trans() Failed(%d)", ret);
- if (CAL_EVENT_NONE == record_type || CAL_EVENT_SCHEDULE_TYPE == record_type) {
+ if (CALS_SCH_TYPE_NONE == record_type || CALS_SCH_TYPE_EVENT == record_type) {
if (account_id)
cals_alarm_remove(CALS_ALARM_REMOVE_BY_ACC_ID, account_id);
else
cals_alarm_remove(CALS_ALARM_REMOVE_ALL, account_id);
}
- ret = cals_query_exec(query);
+ ret = cals_query_exec(query_logging);
if (CAL_SUCCESS != ret) {
cals_end_trans(false);
ERR("cals_query_exec() Failed(%d)", ret);
return ret;
}
+
+ ret = cals_query_exec(query_delete);
+ if (CAL_SUCCESS != ret) {
+ cals_end_trans(false);
+ ERR("cals_query_exec() Failed(%d)", ret);
+ return ret;
+ }
+
cals_end_trans(true);
- if(CAL_EVENT_SCHEDULE_TYPE == record_type)
+ if(CALS_SCH_TYPE_EVENT == record_type)
cals_notify(CALS_NOTI_TYPE_EVENT);
else
cals_notify(CALS_NOTI_TYPE_TODO);
}
-/************************************************************************************************
- * *
- * event exception table APIs *
- * *
- ************************************************************************************************/
-
-int cal_service_add_exception_info(int event_id, cal_exception_info_t *exception_info,
- const cal_sch_full_t *sch_record)
-{
- int ret;
- sqlite3_stmt *stmt = NULL;
- char sql_value[CALS_SQL_MIN_LEN];
- struct tm* recurrency_tm = &exception_info->exception_start_time;
- time_t start_time = cals_mktime(recurrency_tm);
-
- DBG("next_start_tm [%s\n", ctime(&start_time));
-
- sprintf(sql_value,"INSERT INTO %s(start_date_time,end_date_time,event_id,exception_event_id,updated) "
- "VALUES(%ld, %ld, %d, %d, ?)", CALS_TABLE_RECURRENCY_LOG,
- cals_mktime(recurrency_tm),
- cals_mktime(recurrency_tm),
- event_id,
- exception_info->event_id);
-
- stmt = cals_query_prepare(sql_value);
- retvm_if(NULL == stmt, CAL_ERR_DB_FAILED, "cals_query_prepare() Failed");
-
- ret = cals_stmt_step(stmt);
- if (CAL_SUCCESS != ret) {
- sqlite3_finalize(stmt);
- ERR("cals_stmt_step() Failed(%d)", ret);
- return ret;
- }
- sqlite3_finalize(stmt);
-
- return CAL_SUCCESS;
-}
-
-
int cals_insert_timezone(cal_timezone_t *timezone_info)
{
int ret;
return CAL_SUCCESS;
}
-
-/************************************************************************************************
- * *
- * Recurrence exception API for activesync. *
- * *
- ************************************************************************************************/
- bool
-cal_db_service_get_recurrency_exception(const int event_id, GList **exception_list, int *error_code)
-{
- int rc = -1;
- char sql_value[CALS_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
- cal_exception_info_t* exception_info = NULL;
- cal_value * cvalue = NULL;
- retex_if(error_code == NULL, ,"cal_db_service_get_recurrency_exception_for_acs: The error_code is NULL.\n");
- retex_if (!__check_record_index_valid(event_id),*error_code = CAL_ERR_ARG_INVALID, "The index is invalid." );
-
- sprintf(sql_value, "select start_date_time, exception_event_id from recurrency_log_table where event_id=%d;", event_id);
-
- rc = sqlite3_prepare_v2(calendar_db_handle, sql_value, strlen(sql_value), &stmt, NULL);
- retex_if(rc != SQLITE_OK, *error_code = CAL_ERR_DB_FAILED, "Failed to get stmt!!");
-
- rc = sqlite3_step(stmt);
- retex_if(rc == SQLITE_DONE, *error_code = CAL_ERR_DB_FAILED, "cal_db_service_get_recurrency_exception no result!!");
- retex_if(rc != SQLITE_ROW, *error_code = CAL_ERR_DB_FAILED, "Query error!!");
-
- while (rc == SQLITE_ROW)
- {
- cvalue = (cal_value*)malloc(sizeof(cal_value));
- retex_if(NULL == cvalue,,"Failed to malloc!\n");
-
- cvalue->v_type = CAL_EVENT_RECURRENCY;
-
- cvalue->user_data = exception_info = (cal_exception_info_t*)malloc(sizeof(cal_exception_info_t));
- retex_if(NULL == exception_info,,"Failed to malloc!\n");
-
- memset(exception_info, 0x00, sizeof(cal_exception_info_t));
-
- time_t temp_time = sqlite3_column_int(stmt, 0);
- //cal_db_service_copy_struct_tm((struct tm*)gmtime(&temp_time),&(exception_info->exception_start_time));
- gmtime_r(&temp_time,&(exception_info->exception_start_time));
-
- exception_info->event_id = sqlite3_column_int(stmt, 1);
- // exception_info->index = exception_event_id;
- /*
- if(exception_event_id != CAL_INVALID_INDEX)
- {
- sch_record = (cal_sch_full_t*)malloc(sizeof(cal_sch_full_t));
- cals_init_full_record(sch_record, error_code);
- cal_db_service_get_record_full_field_by_index(exception_event_id,"exception",sch_record, error_code);
- exception_info->exception_record = sch_record;
- INFO( "Exception record is here : %d !!\n", exception_event_id);
- }
- else*/
- {
- exception_info->exception_record = NULL;
- }
-
- *exception_list = g_list_append(*exception_list, (gpointer)cvalue);
-
- rc = sqlite3_step(stmt);
- if(rc == SQLITE_DONE)
- {
- break;
- }
- retex_if(rc != SQLITE_ROW, *error_code = CAL_ERR_DB_FAILED, "Query error!!");
-
-
- }
-
- CALS_DBG( "exception_info_length = %d\n", g_list_length(*exception_list));
-
- /*if(g_list_length(*exception_list)>0)
- {
- time_t temp_time = mktime(&(exception_info->exception_start_time));
- //DBG("exception_start_time [%s\n", ctime(&temp_time));
- }*/
-
-
- if(NULL!= stmt)
- {
- sqlite3_finalize(stmt);
- stmt = NULL;
- }
- return true;
-
-CATCH:
- if (cvalue)
- {
- CAL_FREE(cvalue->user_data);
- CAL_FREE(cvalue);
- }
- if(NULL!= stmt)
- {
- sqlite3_finalize(stmt);
- stmt = NULL;
- }
-
- return false;
-}
-
-
-int cal_db_service_get_month_event(int account_id, time_t startdate, time_t enddate,int is_repeat, sqlite3_stmt** stmt)
-{
-
- char condition[1024] = {0};
- char select_value[1024] = {0};
- char from_vlaue[1024] = {0};
- char sql_value[1024] = {0};
- time_t gm_startdate = 0;
- time_t gm_enddate =0;
-
- calendar_svc_util_local_to_gmt(startdate,&gm_startdate);
- calendar_svc_util_local_to_gmt(enddate,&gm_enddate);
-
- gm_startdate = gm_startdate - SECSPERDAY;
- gm_enddate = gm_enddate + SECSPERDAY;
-
- if(account_id == ALL_VISIBILITY_ACCOUNT)
- {
- sprintf(from_vlaue,"from schedule_table as st, calendar_table as ct "\
- "where st.calendar_id = ct.rowid and ct.visibility = 1 "\
- "and ");
- }
- else
- {
- sprintf(from_vlaue,"from schedule_table as st where st.account_id = %d and ",account_id);
- }
-
- if(is_repeat == FALSE)
- {
- sprintf(select_value,"select st.id, "\
- "st.all_day_event, "\
- "st.start_date_time, "\
- "st.end_date_time ");
-
- sprintf(condition, "st.type=%d and st.is_deleted = 0 "\
- "and (st.repeat_item = 0 and st.start_date_time <= %d and st.end_date_time >=%d) ",
- CAL_EVENT_SCHEDULE_TYPE,(int)gm_enddate,(int)gm_startdate);
- }
- else
- {
- sprintf(select_value,"select st.id, "\
- "st.all_day_event, "\
- "st.start_date_time, "\
- "st.end_date_time, "\
- "st.repeat_item, "\
- "st.repeat_interval, "\
- "st.repeat_until_type, "\
- "st.repeat_occurrences, "\
- "st.repeat_end_date, "\
- "st.week_start, "\
- "st.week_flag, "\
- "st.day_date, "\
- "st.timezone, "\
- "st.tz_name ");
-
- sprintf(condition, "st.type=%d and st.is_deleted = 0 "\
- "and (st.repeat_item>0 and st.repeat_end_date>=%d) ",
- CAL_EVENT_SCHEDULE_TYPE,(int)gm_startdate );
- }
-
- sprintf(sql_value,"%s %s %s",select_value,from_vlaue,condition);
-
- *stmt = cals_query_prepare(sql_value);
- retvm_if(NULL == *stmt, CAL_ERR_DB_FAILED, "cals_query_prepare() Failed");
-
- return CAL_SUCCESS;
-}
#include "cals-typedef.h"
/**
- * This function initialize schedule record.
- *
- * @return This function returns initialized record.
- * @param[out] sch_record Points the field information for schedule table' s record.
- * @param[out] error_code Points the error code.
- * @exception None.
- */
-bool cal_db_service_init_schedule_record(cal_sch_t *sch_record, int *error_code);
-
-/**
* This function free full schedule record.
*
* @return This function returns initialized record.
*/
bool cal_db_service_get_participant_info_by_index(const int panticipant_index, GList** record_list, int *error_code);
-bool cal_db_service_get_meeting_category_info_by_index(const int event_id, GList** record_list, int *error_code);
-
/**
* This function get record by index base on table type.
*
*/
int cal_service_add_participant_info(const int participant_id, const cal_participant_info_t* current_record);
-int cal_service_add_exception_info(int event_id, cal_exception_info_t *exception_info, const cal_sch_full_t *sch_record);
-
-int cal_db_service_get_month_event (int account_id, time_t startdate, time_t enddate,int is_repeat, sqlite3_stmt** stmt);
-
int cals_insert_timezone(cal_timezone_t *timezone_info);
int cals_update_timezone(cal_timezone_t *timezone_info);
-bool cal_db_service_get_recurrency_exception(const int event_id, GList **exception_list, int *error_code);
-
-int __cal_service_delete_all_records(const int account_id, const cal_event_type_t record_type);
+int __cal_service_delete_all_records(const int account_id, const cals_sch_type record_type);
/**
* @}
#include "cals-db.h"
#include "cals-alarm.h"
#include "cals-utils.h"
+#include "cals-schedule.h"
+#include "cals-time.h"
+
+
+int cals_event_init(cal_sch_full_t *sch_full_record)
+{
+ retvm_if(NULL == sch_full_record, CAL_ERR_ARG_INVALID , "sch_full_record is NULL");
+
+ memset(sch_full_record,0,sizeof(cal_sch_full_t));
+
+ sch_full_record->cal_type = CALS_SCH_TYPE_EVENT;
+ sch_full_record->meeting_status = CALS_EVENT_STATUS_NONE;
+ sch_full_record->calendar_id = DEFAULT_EVENT_CALENDAR_ID;
+
+ sch_full_record->index = CALS_INVALID_ID;
+ sch_full_record->timezone = -1;
+ sch_full_record->contact_id = CALS_INVALID_ID;
+ sch_full_record->calendar_type = CAL_PHONE_CALENDAR;
+ sch_full_record->attendee_list = NULL;
+ sch_full_record->busy_status = 2;
+ sch_full_record->summary = NULL;
+ sch_full_record->description = NULL;
+ sch_full_record->location= NULL;
+ sch_full_record->categories = NULL;
+ sch_full_record->exdate = NULL;
+ sch_full_record->organizer_email = NULL;
+ sch_full_record->organizer_name = NULL;
+ sch_full_record->uid= NULL;
+ sch_full_record->gcal_id = NULL;
+ sch_full_record->location_summary = NULL;
+ sch_full_record->etag = NULL;
+ sch_full_record->edit_uri = NULL;
+ sch_full_record->gevent_id = NULL;
+ sch_full_record->original_event_id = CALS_INVALID_ID;
+
+ sch_full_record->sync_status = CAL_SYNC_STATUS_NEW;
+ sch_full_record->account_id = -1;
+ sch_full_record->is_deleted = 0;
+ sch_full_record->latitude = 1000; // set default 1000 out of range(-180 ~ 180)
+ sch_full_record->longitude = 1000; // set default 1000 out of range(-180 ~ 180)
+ sch_full_record->freq = CALS_FREQ_ONCE;
+
+ return CAL_SUCCESS;
+}
static inline void cals_event_make_condition(int calendar_id,
- time_t start_time, time_t end_time, cal_sch_category_t category, int all_day, char *dest, int dest_size)
+ time_t start_time, time_t end_time, int all_day, char *dest, int dest_size)
{
int ret;
- ret = snprintf(dest, dest_size, "type = %d", CAL_EVENT_SCHEDULE_TYPE);
+ ret = snprintf(dest, dest_size, "type = %d", CALS_SCH_TYPE_EVENT);
if (calendar_id)
ret += snprintf(dest+ret, dest_size-ret, "AND calendar_id = %d", calendar_id);
if (0 < end_time)
ret += snprintf(dest+ret, dest_size-ret, "AND start_date_time <= %ld", end_time);
- if (0 < category)
- ret += snprintf(dest+ret, dest_size-ret, "AND category = %d", category);
-
if (0 <= all_day)
ret += snprintf(dest+ret, dest_size-ret, "AND all_day_event = %d", !!(all_day));
}
* @param[in] calendar_id calendar_id
* @param[in] start_time start time
* @param[in] end_time end time
- * @param[in] category #cal_sch_category_t
* @param[in] all_day TRUE(1 or positive)/FALSE(0)/IGNORE(-1 or negative)
* @return The count number on success, Negative value(#cal_error) on error
*/
+/*
API int calendar_svc_event_get_count(int calendar_id,
- time_t start_time, time_t end_time, cal_sch_category_t category, int all_day)
+ time_t start_time, time_t end_time, int all_day)
{
char query[CALS_SQL_MIN_LEN];
char cond[CALS_SQL_MIN_LEN];
- cals_event_make_condition(calendar_id, start_time, end_time, category, all_day,
+ cals_event_make_condition(calendar_id, start_time, end_time, all_day,
cond, sizeof(cond));
snprintf(query, sizeof(query), "SELECT COUNT(*) FROM %s WHERE is_deleted = 0 AND %s",
return cals_query_get_first_int_result(query);
}
-
+*/
API cal_iter* calendar_svc_event_get_list(int calendar_id,
- time_t start_time, time_t end_time, cal_sch_category_t category, int all_day)
+ time_t start_time, time_t end_time, int all_day)
{
cal_iter *iter;
sqlite3_stmt *stmt = NULL;
char query[CALS_SQL_MAX_LEN];
char cond[CALS_SQL_MIN_LEN];
- cals_event_make_condition(calendar_id, start_time, end_time, category, all_day,
+ cals_event_make_condition(calendar_id, start_time, end_time, all_day,
cond, sizeof(cond));
sprintf(query,"SELECT * FROM %s WHERE is_deleted = 0 AND %s ORDER BY start_date_time",
return CAL_SUCCESS;
}
-API int calendar_svc_event_delete_all(int calendar_id)
+API int calendar_svc_event_search(int fields, const char *keyword, cal_iter **iter)
{
int ret;
- char query[CALS_SQL_MAX_LEN] = {0};
- sprintf(query, "UPDATE %s SET is_deleted = 1, sync_status = %d, last_modified_time = %ld "
- "WHERE type = %d and calendar_id = %d",
- CALS_TABLE_SCHEDULE, CAL_SYNC_STATUS_DELETED, time(NULL),
- CAL_EVENT_SCHEDULE_TYPE, calendar_id);
+ ret = cals_sch_search(CALS_SCH_TYPE_EVENT, fields, keyword, iter);
+ retvm_if(ret < 0, ret, "cals_sch_search() failed(%d)", ret);
- ret = cals_begin_trans();
- retvm_if(CAL_SUCCESS != ret, ret, "cals_begin_trans() Failed(%d)", ret);
+ return CAL_SUCCESS;
+}
- ret = cals_alarm_remove(CALS_ALARM_REMOVE_BY_CALENDAR_ID, calendar_id);
- if (CAL_SUCCESS != ret) {
- cals_end_trans(false);
- ERR("cals_alarm_remove() Failed(%d)", ret);
+static inline int cals_event_get_changes(int calendar_id, int version, cal_iter *iter)
+{
+ char buf[64] = {0};
+ char query[CALS_SQL_MIN_LEN] = {0,};
+ sqlite3_stmt *stmt;
+ cals_updated *last;
+ cals_updated *result;
+
+ if (calendar_id > 0) {
+ snprintf(buf, sizeof(buf), "AND calendar_id = %d ", calendar_id);
+ } else {
+ memset(buf, 0x0, sizeof(buf));
+ }
+
+ snprintf(query, sizeof(query),
+ "SELECT id, changed_ver, created_ver, is_deleted FROM %s "
+ "WHERE changed_ver > %d AND original_event_id = %d AND type = %d %s "
+ "UNION "
+ "SELECT schedule_id, deleted_ver, -1, 1 FROM %s "
+ "WHERE deleted_ver > %d AND schedule_type = %d %s ",
+ CALS_TABLE_SCHEDULE,
+ version, CALS_INVALID_ID, CALS_SCH_TYPE_EVENT, buf,
+ CALS_TABLE_DELETED,
+ version, CALS_SCH_TYPE_EVENT, buf);
+
+ DBG("query(%s)", query);
+ stmt = cals_query_prepare(query);
+ retvm_if (NULL == stmt, CAL_ERR_DB_FAILED, "cals_query_prepare() failed.");
+
+ while (CAL_TRUE == cals_stmt_step(stmt)){
+ result = cals_updated_schedule_add_mempool();
+
+ result->id = sqlite3_column_int(stmt, 0);
+ result->ver = sqlite3_column_int(stmt, 1);
+ if (sqlite3_column_int(stmt, 3) == 1) {
+ result->type = CALS_UPDATED_TYPE_DELETED;
+ } else if (sqlite3_column_int(stmt, 2) == result->ver || version < sqlite3_column_int(stmt, 2)) {
+ result->type = CALS_UPDATED_TYPE_INSERTED;
+ } else {
+ result->type = CALS_UPDATED_TYPE_MODIFIED;
+ }
+
+ if (iter->info->head == NULL) {
+ iter->info->head = result;
+ } else {
+ last->next = result;
+ }
+ last = result;
+ }
+ iter->i_type = CAL_STRUCT_TYPE_UPDATED_LIST;
+
+ sqlite3_finalize(stmt);
+
+ return CAL_SUCCESS;
+}
+
+
+API int calendar_svc_event_get_changes(int calendar_id, int version, cal_iter **iter)
+{
+ int ret;
+ cal_iter *it;
+
+ retv_if (NULL == iter, CAL_ERR_ARG_NULL);
+ retvm_if (version < 0, CAL_ERR_ARG_INVALID, "Invalid argument");
+
+ it = calloc(1, sizeof(cal_iter));
+ retvm_if (NULL == it, CAL_ERR_OUT_OF_MEMORY, "calloc() failed");
+
+ it->info = calloc(1, sizeof(cals_updated_info));
+ if (!it->info) {
+ ERR("calloc() Failed");
+ free(it);
+ return CAL_ERR_OUT_OF_MEMORY;
+ }
+
+ ret = cals_event_get_changes(calendar_id, version, it);
+ if (ret) {
+ ERR("cals_get_updated_schedules() failed(%d)", ret);
+ free(it->info);
+ free(it);
return ret;
}
+ *iter = it;
+
+ return CAL_SUCCESS;
+}
+
+API int calendar_svc_event_get_normal_list_by_period(int calendar_id, int op_code,
+ long long int stime, long long int etime, cal_iter **iter)
+{
+ /* calendar_id: -1 means searching all calendar */
+ retv_if(iter == NULL, CAL_ERR_ARG_NULL);
+
+ char query[CALS_SQL_MIN_LEN] = {0};
+ char buf[64] = {0};
+ sqlite3_stmt *stmt = NULL;
+
+ if (calendar_id > 0) {
+ snprintf(buf, sizeof(buf), "AND B.calendar_id = %d", calendar_id);
+ } else {
+ memset(buf, 0x0, sizeof(buf));
+ }
+
+ *iter = calloc(1, sizeof(cal_iter));
+ retvm_if(NULL == *iter, CAL_ERR_OUT_OF_MEMORY, "Failed to calloc(%d)", errno);
+ (*iter)->is_patched = 0;
+
+ switch (op_code) {
+ case CALS_LIST_PERIOD_NORMAL_ONOFF:
+ (*iter)->i_type = CALS_STRUCT_TYPE_PERIOD_NORMAL_ONOFF;
+ snprintf(query, sizeof(query),
+ "SELECT A.event_id, "
+ "B.dtstart_type, A.dtstart_utime, "
+ "B.dtend_type, A.dtend_utime "
+ "FROM %s as A, %s as B, %s as C "
+ "ON A.event_id = B.id AND B.calendar_id = C.rowid "
+ "WHERE A.dtstart_utime <= %lld AND A.dtend_utime > %lld "
+ "AND B.type = %d AND B.is_deleted = 0 AND C.visibility = 1 %s "
+ "ORDER BY A.dtstart_utime ",
+ CALS_TABLE_NORMAL_INSTANCE, CALS_TABLE_SCHEDULE, CALS_TABLE_CALENDAR,
+ etime, stime,
+ CALS_SCH_TYPE_EVENT, buf);
+ break;
+
+ case CALS_LIST_PERIOD_NORMAL_BASIC:
+ (*iter)->i_type = CALS_STRUCT_TYPE_PERIOD_NORMAL_BASIC;
+ snprintf(query, sizeof(query),
+ "SELECT A.event_id, "
+ "B.dtstart_type, A.dtstart_utime, "
+ "B.dtend_type, A.dtend_utime, "
+ "B.summary, B.location "
+ "FROM %s as A, %s as B, %s as C "
+ "ON A.event_id = B.id AND B.calendar_id = C.rowid "
+ "WHERE A.dtstart_utime <= %lld AND A.dtend_utime > %lld "
+ "AND B.type = %d AND B.is_deleted = 0 AND C.visibility = 1 %s "
+ "ORDER BY A.dtstart_utime ",
+ CALS_TABLE_NORMAL_INSTANCE, CALS_TABLE_SCHEDULE, CALS_TABLE_CALENDAR,
+ etime, stime,
+ CALS_SCH_TYPE_EVENT, buf);
+ break;
+
+ case CALS_LIST_PERIOD_NORMAL_OSP:
+ (*iter)->i_type = CALS_STRUCT_TYPE_PERIOD_NORMAL_OSP;
+ snprintf(query, sizeof(query),
+ "SELECT A.event_id, B.calendar_id, "
+ "B.dtstart_type, A.dtstart_utime, "
+ "B.dtend_type, A.dtend_utime, "
+ "B.summary, B.description, B.location, B.busy_status, "
+ "B.meeting_status, B.priority, B.sensitivity, B.rrule_id "
+ "FROM %s as A, %s as B, %s as C "
+ "ON A.event_id = B.id AND B.calendar_id = C.rowid "
+ "WHERE A.dtstart_utime <= %lld AND A.dtend_utime > %lld "
+ "AND B.type = %d AND B.is_deleted = 0 AND C.visibility = 1 %s "
+ "ORDER BY A.dtstart_utime ",
+ CALS_TABLE_NORMAL_INSTANCE, CALS_TABLE_SCHEDULE, CALS_TABLE_CALENDAR,
+ etime, stime,
+ CALS_SCH_TYPE_EVENT, buf);
+ break;
+
+ case CALS_LIST_PERIOD_NORMAL_LOCATION:
+ (*iter)->i_type = CALS_STRUCT_TYPE_PERIOD_NORMAL_LOCATION;
+ snprintf(query, sizeof(query),
+ "SELECT A.event_id, B.calendar_id, "
+ "B.dtstart_type, A.dtstart_utime, "
+ "B.dtend_type, A.dtend_utime, "
+ "B.summary, B.description, B.location, B.busy_status, "
+ "B.meeting_status, B.priority, B.sensitivity, B.rrule_id, "
+ "B.latitude, B.longitude "
+ "FROM %s as A, %s as B, %s as C "
+ "ON A.event_id = B.id AND B.calendar_id = C.rowid "
+ "WHERE A.dtstart_utime <= %lld AND A.dtend_utime > %lld "
+ "AND B.type = %d AND B.is_deleted = 0 AND C.visibility = 1 %s "
+ "ORDER BY A.dtstart_utime ",
+ CALS_TABLE_NORMAL_INSTANCE, CALS_TABLE_SCHEDULE, CALS_TABLE_CALENDAR,
+ etime, stime,
+ CALS_SCH_TYPE_EVENT, buf);
+ break;
+
+ case CALS_LIST_PERIOD_NORMAL_ALARM:
+ (*iter)->i_type = CALS_STRUCT_TYPE_PERIOD_NORMAL_ALARM;
+ snprintf(query, sizeof(query),
+ "SELECT A.event_id, C.calendar_id, "
+ "C.dtstart_type, A.dtstart_utime, "
+ "C.dtend_type, A.dtend_utime, "
+ "(A.dtstart_utime - (B.remind_tick * B.remind_tick_unit * 60)), "
+ "B.alarm_id "
+ "FROM %s as A, %s as B, %s as C "
+ "ON A.event_id = B.event_id AND B.event_id = C.id "
+ "WHERE C.type = %d AND C.is_deleted = 0 "
+ "AND A.dtstart_utime - (B.remind_tick * B.remind_tick_unit * 60) >= %lld "
+ "AND A.dtstart_utime - (B.remind_tick * B.remind_tick_unit * 60) < %lld "
+ "%s "
+ "ORDER BY B.alarm_time ",
+ CALS_TABLE_NORMAL_INSTANCE, CALS_TABLE_ALARM, CALS_TABLE_SCHEDULE,
+ CALS_SCH_TYPE_EVENT,
+ stime, etime,
+ buf);
+ break;
+
+ }
+ DBG("query(%s)", query);
+ stmt = cals_query_prepare(query);
+ retvm_if(NULL == stmt, CAL_ERR_DB_FAILED, "Failed to query prepare");
+
+ (*iter)->stmt = stmt;
+ return CAL_SUCCESS;
+}
+
+API int calendar_svc_event_get_allday_list_by_period(int calendar_id, int op_code,
+ int dtstart_year, int dtstart_month, int dtstart_mday,
+ int dtend_year, int dtend_month, int dtend_mday, cal_iter **iter)
+{
+ /* calendar_id -1 means searching all calendar */
+ retv_if(iter == NULL, CAL_ERR_ARG_NULL);
+
+ sqlite3_stmt *stmt = NULL;
+ char query[CALS_SQL_MIN_LEN] = {0};
+ char buf[64] = {0};
+ char sdate[32] = {0};
+ char edate[32] = {0};
+
+ if (dtstart_year < 0 || dtstart_month < 0 || dtstart_mday < 0) {
+ ERR("Check start date(%d/%d/%d)", dtstart_year, dtstart_month, dtstart_mday);
+ return CAL_ERR_ARG_NULL;
+ }
+ if (dtend_year < 0 || dtend_month < 0 || dtend_mday < 0) {
+ ERR("Check end date(%d/%d/%d)", dtend_year, dtend_month, dtend_mday);
+ return CAL_ERR_ARG_NULL;
+ }
+
+ if (calendar_id > 0) {
+ snprintf(buf, sizeof(buf), "AND B.calendar_id = %d", calendar_id);
+ } else {
+ memset(buf, 0x0, sizeof(buf));
+ }
+
+ snprintf(sdate, sizeof(sdate), "%4d%02d%02d", dtstart_year, dtstart_month, dtstart_mday);
+ snprintf(edate, sizeof(edate), "%4d%02d%02d", dtend_year, dtend_month, dtend_mday);
+
+ *iter = calloc(1, sizeof(cal_iter));
+ retvm_if(NULL == *iter, CAL_ERR_OUT_OF_MEMORY, "Failed to calloc(%d)", errno);
+ (*iter)->is_patched = 0;
+
+ switch (op_code) {
+ case CALS_LIST_PERIOD_ALLDAY_ONOFF:
+ (*iter)->i_type = CALS_STRUCT_TYPE_PERIOD_ALLDAY_ONOFF;
+ snprintf(query, sizeof(query),
+ "SELECT A.event_id, "
+ "B.dtstart_type, A.dtstart_datetime, "
+ "B.dtend_type, A.dtend_datetime "
+ "FROM %s as A, %s as B, %s as C "
+ "ON A.event_id = B.id AND B.calendar_id = C.rowid "
+ "WHERE A.dtstart_datetime <= %s AND A.dtend_datetime >= %s "
+ "AND B.type = %d AND B.is_deleted = 0 AND C.visibility = 1 %s "
+ "ORDER BY A.dtstart_datetime ",
+ CALS_TABLE_ALLDAY_INSTANCE, CALS_TABLE_SCHEDULE, CALS_TABLE_CALENDAR,
+ edate, sdate,
+ CALS_SCH_TYPE_EVENT, buf);
+ break;
+
+ case CALS_LIST_PERIOD_ALLDAY_BASIC:
+ (*iter)->i_type = CALS_STRUCT_TYPE_PERIOD_ALLDAY_BASIC;
+ snprintf(query, sizeof(query),
+ "SELECT A.event_id, "
+ "B.dtstart_type, A.dtstart_datetime, "
+ "B.dtend_type, A.dtend_datetime, "
+ "B.summary, B.location "
+ "FROM %s as A, %s as B, %s as C "
+ "ON A.event_id = B.id AND B.calendar_id = C.rowid "
+ "WHERE A.dtstart_datetime <= %s AND A.dtend_datetime >= %s "
+ "AND B.type = %d AND B.is_deleted = 0 AND C.visibility = 1 %s "
+ "ORDER BY A.dtstart_datetime ",
+ CALS_TABLE_ALLDAY_INSTANCE, CALS_TABLE_SCHEDULE, CALS_TABLE_CALENDAR,
+ edate, sdate,
+ CALS_SCH_TYPE_EVENT, buf);
+ break;
+
+ case CALS_LIST_PERIOD_ALLDAY_OSP:
+ (*iter)->i_type = CALS_STRUCT_TYPE_PERIOD_ALLDAY_OSP;
+ snprintf(query, sizeof(query),
+ "SELECT A.event_id, B.calendar_id, "
+ "B.dtstart_type, A.dtstart_datetime, "
+ "B.dtend_type, A.dtend_datetime, "
+ "B.summary, B.description, B.location, B.busy_status, "
+ "B.meeting_status, B.priority, B.sensitivity, B.rrule_id "
+ "FROM %s as A, %s as B, %s as C "
+ "ON A.event_id = B.id AND B.calendar_id = C.rowid "
+ "WHERE A.dtstart_datetime <= %s AND A.dtend_datetime >= %s "
+ "AND B.type = %d AND B.is_deleted = 0 AND C.visibility = 1 %s "
+ "ORDER BY A.dtstart_datetime ",
+ CALS_TABLE_ALLDAY_INSTANCE, CALS_TABLE_SCHEDULE, CALS_TABLE_CALENDAR,
+ edate, sdate,
+ CALS_SCH_TYPE_EVENT, buf);
+ break;
+
+ case CALS_LIST_PERIOD_ALLDAY_LOCATION:
+ (*iter)->i_type = CALS_STRUCT_TYPE_PERIOD_ALLDAY_LOCATION;
+ snprintf(query, sizeof(query),
+ "SELECT A.event_id, B.calendar_id, "
+ "B.dtstart_type, A.dtstart_datetime, "
+ "B.dtend_type, A.dtend_datetime, "
+ "B.summary, B.description, B.location, B.busy_status, "
+ "B.meeting_status, B.priority, B.sensitivity, B.rrule_id, "
+ "B.latitude, B.longitude "
+ "FROM %s as A, %s as B, %s as C "
+ "ON A.event_id = B.id AND B.calendar_id = C.rowid "
+ "WHERE A.dtstart_datetime <= %s AND A.dtend_datetime >= %s "
+ "AND B.type = %d AND B.is_deleted = 0 AND C.visibility = 1 %s "
+ "ORDER BY A.dtstart_datetime ",
+ CALS_TABLE_ALLDAY_INSTANCE, CALS_TABLE_SCHEDULE, CALS_TABLE_CALENDAR,
+ edate, sdate,
+ CALS_SCH_TYPE_EVENT, buf);
+ break;
+/*
+ case CALS_LIST_PERIOD_ALLDAY_ALARM:
+ (*iter)->i_type = CALS_STRUCT_TYPE_PERIOD_ALLDAY_ALARM;
+ snprintf(query, sizeof(query),
+ "SELECT B.event_id, B.alarm_time, B.alarm_id "
+ "FROM %s as A, %s as B, %s as C "
+ "ON A.event_id = B.event_id "
+ "WHERE B.alarm_time >= %lld AND B.alarm_time < %lld "
+ "AND C.type = %d AND C.is_deleted = 0 "
+ "%s "
+ "ORDER BY B.alarm_time ",
+ CALS_TABLE_ALLDAY_INSTANCE, CALS_TABLE_ALARM, CALS_TABLE_SCHEDULE,
+ sdate, edate,
+ CALS_SCH_TYPE_EVENT,
+ buf);
+ break;
+*/
+ }
+
+ stmt = cals_query_prepare(query);
+ retvm_if(NULL == stmt, CAL_ERR_DB_FAILED, "Failed to query prepare");
+
+ (*iter)->stmt = stmt;
+ return CAL_SUCCESS;
+}
+
+/* delete instance from instance_table and update exdate from schedule_table */
+API int calendar_svc_event_delete_normal_instance(int event_id, long long int dtstart_utime)
+{
+ int ret, len, len_datetime;
+ char *exdate = NULL;
+ char *str_datetime = NULL;
+ char *p;
+ char query[CALS_SQL_MIN_LEN] = {0};
+ sqlite3_stmt *stmt;
+
+ len_datetime = strlen("YYYYMMDDTHHMMSSZ");
+
+ /* delete instance from normal_instance_table */
+ snprintf(query, sizeof(query), "DELETE FROM %s "
+ "WHERE event_id = %d AND dtstart_utime = %lld ",
+ CALS_TABLE_NORMAL_INSTANCE,
+ event_id, dtstart_utime);
+
ret = cals_query_exec(query);
+ retvm_if(ret != CAL_SUCCESS, ret, "Failed to delete instance(errno:%d)"
+ "[id:%d utime:%lld]", ret, event_id, dtstart_utime);
+
+ /* get exdate to append */
+ snprintf(query, sizeof(query), "SELECT %s FROM %s "
+ "WHERE id = %d ",
+ CAL_VALUE_TXT_EXDATE, CALS_TABLE_SCHEDULE,
+ event_id);
+
+ stmt = cals_query_prepare(query);
+ retvm_if (NULL == stmt, CAL_ERR_DB_FAILED, "cals_query_prepare() failed.");
+
+ ret = cals_stmt_step(stmt);
+ if (ret == CAL_TRUE) {
+ exdate = (char *)sqlite3_column_text(stmt, 0);
+ DBG("exdate(%s)", exdate);
+
+ } else if (ret != CAL_SUCCESS) {
+ ERR("Failed to step(errno:%d)", ret);
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+
+ /* check whether exdate does already exist */
+ if (exdate == NULL || strlen(exdate) == 0) {
+ p = calloc(len_datetime + 1, sizeof(char));
+ if (p == NULL) {
+ ERR("Failed to calloc");
+ sqlite3_finalize(stmt);
+ return CAL_ERR_OUT_OF_MEMORY;
+ }
+ str_datetime = cals_time_get_str_datetime(NULL, dtstart_utime);
+ snprintf(p, len_datetime + 1, "%s", str_datetime);
+ DBG("inserted exdate firstly(%s)", str_datetime);
+
+ } else {
+ DBG("append exdate");
+ len = strlen(exdate);
+ p = calloc(len + strlen(", ") + len_datetime + 1, sizeof(char));
+ if (p == NULL) {
+ ERR("Failed to calloc");
+ sqlite3_finalize(stmt);
+ return CAL_ERR_OUT_OF_MEMORY;
+ }
+ str_datetime = cals_time_get_str_datetime(NULL, dtstart_utime);
+ snprintf(p, len + 2 + len_datetime + 1, "%s, %s",
+ exdate, str_datetime);
+ }
+ if (str_datetime) free(str_datetime);
+ sqlite3_finalize(stmt);
+
+ /* updaet exdate from schedule table */
+ snprintf(query, sizeof(query), "UPDATE %s SET "
+ "exdate = ? "
+ "WHERE id = %d ",
+ CALS_TABLE_SCHEDULE,
+ event_id);
+
+ stmt = cals_query_prepare(query);
+ retvm_if (NULL == stmt, CAL_ERR_DB_FAILED, "Failed to prepare(errno:%d)", ret);
+
+ cals_stmt_bind_text(stmt, 1, p);
+
+ ret = cals_stmt_step(stmt);
if (CAL_SUCCESS != ret) {
- cals_end_trans(false);
- ERR("cals_query_exec() Failed(%d)", ret);
+ sqlite3_finalize(stmt);
+ ERR("sqlite3_step() Failed(%d)", ret);
return ret;
}
- cals_end_trans(true);
+ sqlite3_finalize(stmt);
- cals_notify(CALS_NOTI_TYPE_EVENT);
+ /* send noti */
+ ret = cals_notify(CALS_NOTI_TYPE_EVENT);
+ if (ret < 0) {
+ WARN("cals_notify failed (%d)", ret);
+ }
return CAL_SUCCESS;
}
-API cal_iter* calendar_svc_event_get_updated_list(int calendar_id, time_t timestamp)
+API int calendar_svc_event_delete_allday_instance(int event_id, int dtstart_year, int dtstart_month, int dtstart_mday)
{
- return cals_get_updated_list(CAL_EVENT_SCHEDULE_TYPE, calendar_id, timestamp);
+ int ret, len, len_datetime;
+ char *exdate = NULL;
+ char *p;
+ char query[CALS_SQL_MIN_LEN] = {0};
+ char buf[32] = {0};
+ sqlite3_stmt *stmt;
+
+ len_datetime = strlen("YYYYMMDDTHHMMSSZ");
+
+ /* delete instance from normal_instance_table */
+ snprintf(buf, sizeof(buf), "%04d%02d%02d", dtstart_year, dtstart_month, dtstart_mday);
+ DBG("allday(%s)\n", buf);
+ snprintf(query, sizeof(query), "DELETE FROM %s "
+ "WHERE event_id = %d AND dtstart_datetime = %s ",
+ CALS_TABLE_ALLDAY_INSTANCE,
+ event_id, buf);
+
+ ret = cals_query_exec(query);
+ retvm_if(ret != CAL_SUCCESS, ret, "Failed to delete instance(errno:%d)"
+ "[id:%d datetime:%s]", ret, event_id, buf);
+
+ /* get exdate to append */
+ snprintf(query, sizeof(query), "SELECT %s FROM %s "
+ "WHERE id = %d ",
+ CAL_VALUE_TXT_EXDATE, CALS_TABLE_SCHEDULE,
+ event_id);
+
+ stmt = cals_query_prepare(query);
+ retvm_if (NULL == stmt, CAL_ERR_DB_FAILED, "cals_query_prepare() failed.");
+
+ ret = cals_stmt_step(stmt);
+ if (ret == CAL_TRUE) {
+ exdate = (char *)sqlite3_column_text(stmt, 0);
+ DBG("exdate(%s)", exdate);
+
+ } else if (ret != CAL_SUCCESS) {
+ ERR("Failed to step(errno:%d)", ret);
+ sqlite3_finalize(stmt);
+ return ret;
+ }
+
+ /* check whether exdate does already exist */
+ if (exdate == NULL || strlen(exdate) == 0) {
+ p = calloc(len_datetime + 1, sizeof(char));
+ if (p == NULL) {
+ ERR("Failed to calloc");
+ sqlite3_finalize(stmt);
+ return CAL_ERR_OUT_OF_MEMORY;
+ }
+ snprintf(p, len_datetime + 1, "%s", buf);
+ DBG("inserted exdate firstly(%s)", buf);
+
+ } else {
+ DBG("append exdate");
+ len = strlen(exdate);
+ p = calloc(len + strlen(", ") + len_datetime + 1, sizeof(char));
+ if (p == NULL) {
+ ERR("Failed to calloc");
+ sqlite3_finalize(stmt);
+ return CAL_ERR_OUT_OF_MEMORY;
+ }
+ snprintf(p, len + 2 + len_datetime + 1, "%s, %s",
+ exdate, buf);
+ }
+ sqlite3_finalize(stmt);
+
+ /* updaet exdate from schedule table */
+ snprintf(query, sizeof(query), "UPDATE %s SET "
+ "exdate = ? "
+ "WHERE id = %d ",
+ CALS_TABLE_SCHEDULE,
+ event_id);
+
+ stmt = cals_query_prepare(query);
+ retvm_if (NULL == stmt, CAL_ERR_DB_FAILED, "Failed to prepare(errno:%d)", ret);
+
+ cals_stmt_bind_text(stmt, 1, p);
+
+ ret = cals_stmt_step(stmt);
+ if (CAL_SUCCESS != ret) {
+ sqlite3_finalize(stmt);
+ ERR("sqlite3_step() Failed(%d)", ret);
+ return ret;
+ }
+ sqlite3_finalize(stmt);
+
+ /* send noti */
+ ret = cals_notify(CALS_NOTI_TYPE_EVENT);
+ if (ret < 0) {
+ WARN("cals_notify failed (%d)", ret);
+ }
+
+ return CAL_SUCCESS;
}
+
+
+
+++ /dev/null
-/*
- * Calendar Service
- *
- * Copyright (c) 2000 - 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.
- *
- */
-#include <glib.h>
-#include <ctype.h>
-#include <assert.h>
-#include <time.h>
-
-#include "cals-typedef.h"
-#include "cals-ical.h"
-#include "cals-ical-codec.h"
-#include "cals-utils.h"
-#include "cals-db.h"
-#include "cals-internal.h"
-#include "cals-struct.h"
-
-
-#define VCALENDAR_HEADER "BEGIN:VCALENDAR"
-#define VNOTE_HEADER "BEGIN:VNOTE"
-
-#define MAX_BUFFER_SIZE 200
-
-
-/****************************************************************************************************/
-/* GLOBAL VARIABLE DECLARATION AND INITIALIZATION */
-/****************************************************************************************************/
-#define MAX_CAL_TYPE_NAME 50
-
-/* Type */
-const char *pszCalTypeList[] =
-{
- "AALARM",
- "ACTION",
- "ATTACH",
- "ATTENDEE",
- "BEGIN",
- "CALSCALE",
- "CATEGORIES",
- "CLASS",
- "COMMENT",
- "COMPLETED",
- "CONTACT",
- "CREATED",
- "DALARM",
- "DAYLIGHT",
- "DCREATED",
- "DESCRIPTION",
- "DTEND",
- "DTSTAMP",
- "DTSTART",
- "DUE",
- "DURATION",
- "END",
- "EXDATE",
- "EXRULE",
- "FREEBUSY",
- "GEO",
- "LAST-MODIFIED",
- "LOCATION",
- "MALARM",
- "METHOD",
- "ORGANIZER",
- "PALARM",
- "PERCENT-COMPLETE",
- "PRIORITY",
- "PRODID",
- "RDATE",
- "RECURRENCE-ID",
- "RELATED-TO",
- "REPEAT",
- "REQUEST-STATUS",
- "RESOURCES",
- "RNUM",
- "RRULE",
- "SEQUENCE",
- "STANDARD",
- "STATUS",
- "SUMMARY",
- "TRANSP",
- "TRIGGER",
- "TZ",
- "TZID",
- "TZNAME",
- "TZOFFSETFROM",
- "TZOFFSETTO",
- "TZURL",
- "URL",
- "UID",
- "VALARM",
- "VCALENDAR",
- "VERSION",
- "VEVENT",
- "VFREEBUSY",
- "VJOURNAL",
- "VTIMEZONE",
- "VTODO",
- "X-FUNAMBOL-ALLDAY"
-};
-
-/* Parameter */
-static const char *pszCalParamList[] =
-{
- "ALTREP",
- "CHARSET",
- "CN",
- "CONTEXT",
- "CUTYPE",
- "DELEGATED-FROM",
- "DELEGATED-TO",
- "DIR",
- "ENCODING",
- "EXPECT",
- "FBTYPE",
- "FMTYPE",
- "LANGUAGE",
- "MEMBER",
- "PARTSTAT",
- "RANGE",
- "RELATED",
- "RELTYPE",
- "ROLE",
- "RSVP",
- "SENT_BY",
- "STATUS",
- "TYPE",
- "TZID",
- "VALUE"
-};
-
-/* Cu type value */
-static const ValueObj pCalCutypeValList[] =
-{
- {"GROUP", 0x00000001},
- {"INDIVIDUAL", 0x00000002},
- {"RESOURCE", 0x00000004},
- {"ROOM", 0x00000008},
- {"UNKNOWN", 0x00000010}
-};
-
-/* Character set value */
-static const ValueObj pCalCharsetValList[] =
-{
- {"UTF-8", 0x00000001},
- {"UTF-16", 0x00000002}
-};
-
-/* Encoding value */
-static const ValueObj pCalEncValList[] =
-{
- {"B", 0x00000001},
- {"BASE64", 0x00000002},
- {"QUOTED-PRINTABLE", 0x00000004},
- {"7BIT", 0x00000008},
- {"8BIT", 0x00000010}
-};
-
-/* Fb type value */
-static const ValueObj pCalFbtypeValList[] =
-{
- {"BUSY", 0x00000001},
- {"BUSY_TENTATIVE", 0x00000002},
- {"BUSY_UNAVAILABLE", 0x00000004},
- {"FREE", 0x00000008}
-};
-
-/* Partstat value */
-static const ValueObj pCalPartstatValList[] =
-{
- {"ACCEPTED", 0x00000001},
- {"COMPLETED", 0x00000002},
- {"DELEGATED", 0x00000004},
- {"DECLINED", 0x00000008},
- {"IN_PROCESS", 0x00000010},
- {"NEED_ACTION", 0x00000020},
- {"TENTATIVE", 0x00000040}
-};
-
-/* Range value */
-static const ValueObj pCalRangeValList[] =
-{
- {"THISANDFUTURE", 0x00000001},
- {"THISANDPRIOR", 0x00000002}
-};
-
-/* Related value */
-static const ValueObj pCalRelatedValList[] =
-{
- {"END", 0x00000001},
- {"START", 0x00000002}
-};
-
-/* Rel type value */
-static const ValueObj pCalReltypeValList[] =
-{
- {"CHILD", 0x00000001},
- {"PARENT", 0x00000002},
- {"SIBLING", 0x00000004}
-};
-
-/* Value value */
-static const ValueObj pCalValValList[] =
-{
- {"BINARY", 0x00000001},
- {"BOOLEAN", 0x00000002},
- {"CAL-ADDRESS", 0x00000004},
- {"CID", 0x00000008},
- {"CONTENT-ID", 0x00000010},
- {"DATE", 0x00000020},
- {"DATE-TIME", 0x00000040},
- {"DURATION", 0x00000080},
- {"FLOAT", 0x00000100},
- {"INTEGER", 0x00000200},
- {"PERIOD", 0x00000400},
- {"PHONE-NUMBER", 0x00000800},
- {"RECUR", 0X00001000},
- {"TEXT", 0x00002000},
- {"TIME", 0x00004000},
- {"URI", 0x00008000},
- {"URL", 0x00010000},
- {"UTC-OFFSET", 0x00020000},
- {"VCALENDAR", 0x00040000},
- {"VEVENT", 0x00080000},
- {"VTODO", 0x00100000}
-};
-
-/* Type value */
-static const ValueObj pCalTypeValList[] =
-{
- {"AIFF", 0x00000001},
- {"BBS", 0x00000002},
- {"CAR", 0x00000004},
- {"CELL", 0x00000008},
- {"DOM", 0x00000010},
- {"FAX", 0x00000020},
- {"GIF", 0x00000040},
- {"HOME", 0x00000080},
- {"INTL", 0x00000100},
- {"INTERNET", 0x00000200},
- {"ISDN", 0x00000400},
- {"JPEG", 0x00000800},
- {"MODEM", 0x00001000},
- {"MSG", 0x00002000},
- {"PAGER", 0x00004000},
- {"PARCEL", 0x00008000},
- {"PCM", 0x00010000},
- {"PCS", 0x00020000},
- {"PNG", 0x00040000},
- {"POSTAL", 0x00080000},
- {"PREF", 0x00100000},
- {"VCARD", 0x00200000},
- {"VIDEO", 0x00400000},
- {"VOICE", 0x00800000},
- {"WAVE", 0x01000000},
- {"WBMP", 0x02000000},
- {"WORK", 0x04000000},
- {"X400", 0x08000000}
-};
-
-/* Expect value */
-static const ValueObj pCalExpectValList[] =
-{
- {"FYI", 0x00000001},
- {"IMMEDIATE", 0x00000002},
- {"REQUEST", 0x00000004},
- {"REQUIRE", 0x00000008}
-};
-
-/* Role value */
-static const ValueObj pCalRoleValList[] =
-{
- {"ATTENDEE", 0x00000001},
- {"CHAIR", 0x00000002},
- {"DELEGATE", 0x00000004},
- {"NON_PARTICIPANT", 0x00000008},
- {"OPT_PARTICIPANT", 0x00000010},
- {"ORGANIZER", 0x00000020},
- {"OWNER", 0x00000040},
- {"REQ_PARTICIPANT", 0x00000080}
-};
-
-/* RSVP value */
-static const ValueObj pCalRSVPValList[] =
-{
- {"false", 0x00000001},
- {"NO", 0x00000002},
- {"true", 0x00000004},
- {"YES", 0x00000008}
-};
-
-/* Status value */
-static const ValueObj pCalStatusValList[] =
-{
- {"ACCEPTED", 0x00000001},
- {"COMPLETED", 0x00000002},
- {"CONFIRMED", 0x00000004},
- {"DECLINED", 0x00000008},
- {"DELEGATED", 0x00000010},
- {"NEEDS ACTION", 0x00000020},
- {"SENT", 0x00000040},
- {"TENTATIVE", 0x00000080},
-};
-
-/****************************************************************************************************/
-/* FUNCTION DECLARATION */
-/****************************************************************************************************/
-static int __VCalGetName( char*, char**, int );
-static int __VCalGetValue( char*, const ValueObj*, int );
-static int __VCalGetTypeName( char*, int*, int *);
-static int __VCalGetParamName( char*, int*, int *);
-static char* __VCalGetParamValue( char*, int*, int *);
-static char* __VCalGetTypeValue( char*, int*, int*, int, VObject* );
-static char* __VCalParamEncode( VObject*, int *);
-
-
-/*
- * VIsVCalFile() verify VCalendar file.
- *
- * @param pVCalRaw Data which will be encoded
- * @return int result (TRUE or FALSE)
- */
-static int __VIsVCalFile(char *pVCalRaw)
-{
- char *pszVCalBegin = "BEGIN:VCALENDAR";
- char *pszVCalEnd = "END:VCALENDAR";
-
- /*for(i=0; i<15; i++)
- {
- if(*pszVCalBegin++ != *pVCalRaw++)
- return false;
- }*/
-
- DBG("raw data:%s",pVCalRaw);
- if( strstr(pVCalRaw, pszVCalBegin) == NULL)
- return false;
-
- if( strstr(pVCalRaw, pszVCalEnd) == NULL)
- return false;
- return true;
-}
-
-
-
-/*
- * vCalFindName() compares the string and VCal type, parameter name.
- *
- * @param string Name which will compare
- * @param list[] Name list of VCal type and param
- * @param size Number of total element of list
- * @return index The index in the list
- */
-static int __VCalGetName( char *szString, char** pszList, int size )
-{
- int high, low, i, diff;
-
- DBG( "__VCalGetName() enter..\n");
-
-
- for ( low = 0, high = size - 1; high >= low; diff < 0 ? ( low = i+1 ) : ( high = i-1 ) )
- {
- i = ( low + high ) / 2;
- diff = strcmp( pszList[i], szString );
- if ( diff == 0 ) /* success: found it */
- return i;
- }
- return UNKNOWN_NAME;
-}
-
-
-/*
- * vCalFindValue() compares the string and VCal type, parameter value.
- *
- * @param string Value which will compare
- * @param list[] Value list of VCal type and param
- * @param size Number of total element of list
- * @return index The index in the list
- */
-static int __VCalGetValue( char *szString, const ValueObj pList[], int size )
-{
- int high, low, i, diff;
- char* szTemp = szString;
- unsigned int k;
-
- DBG( "__VCalGetValue enter()..\n");
-
- for ( k = 0; k < strlen( szTemp ); k++ )
- {
- szTemp[k] = toupper( szTemp[k] );
- }
-
- for ( low = 0, high = size - 1; high >= low; diff < 0 ? ( low = i+1 ) : ( high = i-1 ) )
- {
- i = ( low + high ) / 2;
- diff = strcmp( pList[i].szName, szTemp );
- if ( diff == 0 ) /* success: found it */
- return pList[i].flag;
- }
- return UNKNOWN_NAME;
-}
-
-
-/*
- * vCalTypeName() fine the type name and returns the index number
- *
- * @param pVCalRaw The raw data
- * @param status Decoder status
- * @return res The index in type list
- */
-static int __VCalGetTypeName( char *pVCalRaw, int *pStatus, int *pDLen )
-{
- char name[MAX_CAL_TYPE_NAME];
- char c = VTYPE_TOKEN_SEMICOLON;
- int res=UNKNOWN_NAME;
- int i;
- int index = 0;
-
- DBG( "__VCalGetTypeName() enter \n");
-
- // while ( true )
- while ( pVCalRaw!= NULL )
- {
- c = *pVCalRaw;
-
- pVCalRaw++;
- ( *pDLen )++;
-
- if(index >= MAX_CAL_TYPE_NAME){
- DBG( "UNKNOWN_NAME!!(pVCalRaw(%s),%d)\n",pVCalRaw,index);
- res = UNKNOWN_NAME;
- if ( ( c == VTYPE_TOKEN_SEMICOLON ) || ( c == VTYPE_TOKEN_COLON ) )
- break;
- //return UNKNOWN_NAME;
- }
- else
- {
- if ( ( c == VTYPE_TOKEN_SEMICOLON ) || ( c == VTYPE_TOKEN_COLON ) )
- {
- name[index] = '\0';
- _VRLSpace( name );
- _VRTSpace( name );
- for ( i = 0; i < index; i++ )
- name[i] = toupper( name[i] );
-
- res = __VCalGetName( name, ( char** )pszCalTypeList, VCAL_TYPE_NUM );
- break;
- }
- else if ( ( c == '\r' ) || ( c == '\n' ) || ( _VIsSpace( c ) ) ) ;
- else
- name[index++] = c;
- }
- }
-
- if ( c == VTYPE_TOKEN_SEMICOLON )
- *pStatus = VCAL_PARAM_NAME_STATUS;
- else
- *pStatus = VCAL_TYPE_VALUE_STATUS;
-
- DBG( "###########- __VCalGetTypeName() end..\n");
-
- return res;
-}
-
-
-/*
- * vCalParamName() fine the param name and returns the index number
- *
- * @param pVCalRaw The raw data
- * @param status Decoder status
- * @return res The index in param list
- */
-static int __VCalGetParamName( char *pVCalRaw, int *pStatus, int *pDLen )
-{
- char name[50];
- char c;
- int res;
- int i;
- int index = 0;
- char* pTemp = pVCalRaw;
-
- DBG( "__VCalGetParamName() enter..\n");
-
- // while ( true )
- while ( pVCalRaw!= NULL )
- {
- c = *pVCalRaw;
- pVCalRaw++;
- ( *pDLen )++;
- if ( c == VTYPE_TOKEN_EQUAL )
- {
- name[index] = '\0';
- _VRLSpace( name );
- _VRTSpace( name );
- for ( i = 0; i < index; i++ )
- name[i] = toupper( name[i] );
-
- res = __VCalGetName( name, ( char** )pszCalParamList, VCAL_PARAM_NUM );
- *pStatus = VCAL_PARAM_VALUE_STATUS;
- return res;
- }
- else if ( c == VTYPE_TOKEN_COLON )
- {
- *pStatus = VCAL_PARAM_VALUE_STATUS;
- pVCalRaw = pTemp;
- (*pDLen) = 0;
- return UNKNOWN_NAME;
- }
- else if ( c == VTYPE_TOKEN_SEMICOLON )
- {
- *pStatus = VCAL_PARAM_NAME_STATUS;
- pVCalRaw = pTemp;
- ( *pDLen ) = 0;
- return UNKNOWN_NAME;
- }
- else if ( ( c == '\r' ) || ( c == '\n' ) || ( _VIsSpace( c ) ) ) ;
- else
- name[index++] = c;
- }
- return UNKNOWN_NAME;
-}
-
-
-/*
- * vCalParamValue() fine the param value and returns value.
- *
- * @param pVCalRaw The raw data
- * @param status Decoder status
- * @return buffer The result value
- */
-static char* __VCalGetParamValue( char *pVCalRaw, int *pStatus, int *pDLen )
-{
- char* pBuf = NULL;
- char c;
- int len = 0;
- char* pTemp = pVCalRaw;
- char buf[100];
- char delimiter;
-
- DBG( "__VCalGetParamValue() enter..\n");
-
- // while ( true )
- while ( pVCalRaw!= NULL )
- {
- c = *pVCalRaw;
- pVCalRaw++;
- ( *pDLen )++;
- if ( c == VTYPE_TOKEN_SEMICOLON )
- {
- buf[len] = '\0';
- if ( ( pBuf = ( char * )malloc( len+1 ) ) == NULL )
- {
- DBG( "__VCalGetParamValue():malloc Failed\n");
- return NULL;
- }
- // memcpy( pBuf, pTemp, len-1 );
- strcpy( pBuf, buf );
- *( pBuf + len ) = '\0';
- _VRLSpace( pBuf );
- _VRTSpace( pBuf );
- *pStatus = VCAL_PARAM_NAME_STATUS;
- return pBuf;
- }
- else if ( c == VTYPE_TOKEN_COLON )
- {
- buf[len] = '\0';
- if ( ( pBuf = ( char * )malloc( len+1 ) ) == NULL )
- {
- DBG( "__VCalGetParamValue():malloc Failed\n");
- return NULL;
- }
- // memcpy( pBuf, pTemp, len-1 );
- strcpy( pBuf, buf );
- *( pBuf + len ) = '\0';
- _VRLSpace( pBuf );
- _VRTSpace( pBuf );
- *pStatus = VCAL_TYPE_VALUE_STATUS;
- return pBuf;
- }
- else if ( c == VTYPE_TOKEN_COMMA )
- {
- buf[len] = '\0';
- if ( ( pBuf = ( char * )malloc( len+1 ) ) == NULL )
- {
- DBG( "__VCalGetParamValue():malloc Failed\n");
- return NULL;
- }
- // memcpy( pBuf, pTemp, len-1 );
- strcpy( pBuf, buf );
- *( pBuf + len ) = '\0';
- _VRLSpace( pBuf );
- _VRTSpace( pBuf );
- *pStatus = VCAL_PARAM_VALUE_STATUS;
- return pBuf;
- }
- else if ( c == VTYPE_TOKEN_QUOTE || c == VTYPE_TOKEN_DBLQUOTE )
- {
- delimiter = c;
- pTemp = pVCalRaw;
- // while ( true )
- while ( pVCalRaw != NULL )
- {
- c = *pVCalRaw;
- pVCalRaw++;
- ( *pDLen )++;
- len++;
- if ( c == delimiter )
- {
- buf[len] = '\0';
- if ( ( pBuf = ( char * )malloc( len+1 ) ) == NULL )
- {
- DBG( "__VCalGetParamValue():malloc Failed\n");
- return NULL;
- }
- // memcpy( pBuf, pTemp, len-1 );
- strcpy( pBuf, buf );
- *( pBuf + len ) = '\0';
- _VRLSpace( pBuf );
- _VRTSpace( pBuf );
- *pStatus = VCAL_PARAM_VALUE_STATUS;
- //while ( true )
- while ( pVCalRaw != NULL )
- {
- c = *pVCalRaw;
- pVCalRaw++;
- ( *pDLen )++;
- len++;
- if ( c == VTYPE_TOKEN_COLON ) break;
- }
- return pBuf;
- }
- buf[len++] = c;
- }
- }
- else
- buf[len++] = c;
- }
- return pBuf;
-}
-
-int _gbase64Decode( char *Dest, char *Src )
-{
- gsize len;
-
- guchar *buf = g_base64_decode(Src,&len);
- memcpy(Dest,buf,len);
- g_free(buf);
- DBG("_gbase64Decode before:\n%s \n",Src);
- DBG("_gbase64Decode after:\n%s \n",Dest);
- return len;
-}
-
-void _gbase64Encode( char *Dest, char *Src, int len )
-{
- gchar *buf = g_base64_encode((guchar *)Src, strlen(Src));
- strcpy(Dest,buf);
- DBG("_gbase64Decode before:\n%s \n",Src);
- DBG("_gbase64Decode after:\n%s \n",Dest);
- g_free(buf);
-}
-
-
-/*
- * vCalTypeValue() fine the type value and returns value.
- *
- * @param VCalRaw The raw data
- * @param status Decoder status
- * @return buffer The result value
- */
-static char* __VCalGetTypeValue( char *pVCalRaw, int *pStatus, int *pDLen, int enc, VObject* pType )
-{
- char* pBuf = NULL;
- char c, c1, c2;
- int len = 0;
- char* pTemp = pVCalRaw;
- char* pTmpBuf = NULL;
- int bufferCount;
- int num;
- bool bEscape = false;
-
- DBG( "__VCalGetTypeValue() enter..\n");
-
- // while ( true )
- while ( pVCalRaw!= NULL )
- {
- c = *pVCalRaw;
- pVCalRaw++;
- ( *pDLen )++;
- len++;
-
- if ( c == VTYPE_TOKEN_SEMICOLON && bEscape == false )
- {
- if ( ( pBuf = ( char * )malloc( len ) ) == NULL )
- {
- DBG( "__VCalGetTypeValue():malloc Failed\n");
- return NULL;
- }
- memcpy( pBuf, pTemp, len-1 );
- *( pBuf + len -1 ) = '\0';
- _VRLSpace( pBuf );
- _VRTSpace( pBuf );
- _VUnescape( pBuf );
- *pStatus = VCAL_TYPE_VALUE_STATUS;
- if ( enc & pCalEncValList[1].flag )
- {
- bufferCount = ( len * 6 / 8 ) + 2;
- if ( ( pTmpBuf = ( char * )malloc( bufferCount ) ) == NULL )
- {
- DBG( "__VCalGetTypeValue():malloc Failed\n");
- free(pBuf);
-
- return NULL;
- }
- memset( pTmpBuf, '\0', bufferCount );
-
- num = _gbase64Decode( pTmpBuf, pBuf );
-
- if ( pType != NULL )
- pType->numOfBiData = num;
- free( pBuf );
- return pTmpBuf;
- }
- if ( enc & pCalEncValList[2].flag )
- {
- int i = 0, j = 0;
-
- while ( pBuf[i] )
- {
- if ( pBuf[i] == '\n' || pBuf[i] == '\r' )
- {
- i++;
- if ( pBuf[i] == '\n' || pBuf[i] == '\r' )
- i++;
-
- if ( pBuf[j-1] == '=' ) j--;
- }
- else
- {
- pBuf[j++] = pBuf[i++];
- }
- }
- pBuf[j] = '\0';
-
- _VQPDecode( pBuf );
- _VRLSpace( pBuf );
- _VRTSpace( pBuf );
- }
- return pBuf;
- }
- else if ( c == VTYPE_TOKEN_SEMICOLON && bEscape == true )
- {
- bEscape = false;
- }
- else if ( c == '\\' )
- {
- bEscape = true;
- }
- else if ( bEscape == true && c != VTYPE_TOKEN_SEMICOLON )
- {
- bEscape = false;
- }
- else if ( ( c == '\r' ) || ( c == '\n' ) )
- {
- c2 = *( pVCalRaw-2 );
-
- if ( c2 == '=' && ( enc & pCalEncValList[2].flag ) )
- {
- c1 = *pVCalRaw;
- if ( ( c1 == '\r' ) || ( c1 == '\n' ) )
- {
- pVCalRaw += 1;
- ( *pDLen ) += 1; len++;
- }
- }
- else
- {
- if ( ( pBuf = ( char * )malloc( len ) ) == NULL )
- {
- DBG( "__VCalGetTypeValue():malloc Failed\n");
- return NULL;
- }
-
- memcpy( pBuf, pTemp, len-1 );
-
- *( pBuf + len -1 ) = '\0';
- _VRLSpace( pBuf );
- _VRTSpace( pBuf );
- _VUnescape( pBuf );
- *pStatus = VCAL_TYPE_NAME_STATUS;
-
- c1 = *( pVCalRaw );
- if ( ( c1 == '\r' ) || ( c1 == '\n' ) )
- {
- pVCalRaw += 1;
- ( *pDLen ) += 1;
- }
-
- if ( enc & pCalEncValList[1].flag )
- {
-
- bufferCount = ( len * 6 / 8 ) + 2;
- if ( ( pTmpBuf = ( char * )malloc( bufferCount ) ) == NULL )
- {
- DBG( "__VCalGetTypeValue():malloc Failed\n");
- free(pBuf);
- return NULL;
- }
- memset( pTmpBuf, '\0', bufferCount );
- len = _gbase64Decode( pTmpBuf, pBuf );
- if ( pType != NULL )
- pType->numOfBiData = len;
- free( pBuf );
- return pTmpBuf;
- }
- if ( enc & pCalEncValList[2].flag )
- {
- int i = 0, j = 0;
-
- while ( pBuf[i] )
- {
- if ( pBuf[i] == '\n' || pBuf[i] == '\r' )
- {
- i++;
- if ( pBuf[i] == '\n' || pBuf[i] == '\r' )
- i++;
-
- if ( pBuf[j-1] == '=' ) j--;
- }
- else
- {
- pBuf[j++] = pBuf[i++];
- }
- }
- pBuf[j] = '\0';
-
- _VQPDecode( pBuf );
- _VRLSpace( pBuf );
- _VRTSpace( pBuf );
- }
- return pBuf;
- }
-
- }
- else if(enc == 0 && c == 0) // VCAlENDAR type value µðÄÚµù½Ã memory overlap µÇ´Â Çö»ó ¹æÁöÇϱâ À§ÇÑ ÄÚµå.
- {
- if ( ( pBuf = ( char * )malloc( len ) ) == NULL )
- {
- DBG( "__VCalGetTypeValue():malloc Failed\n");
- return NULL;
- }
- memcpy( pBuf, pTemp, len-1 );
- *( pBuf + len -1 ) = '\0';
- _VQPDecode( pBuf );
- _VRLSpace( pBuf );
- _VRTSpace( pBuf );
- return pBuf;
- }
- }
- DBG( "__VCalGetTypeValue() end..\n");
-
- return pBuf;
-}
-
-
-/*
- * vcal_decode() decode the VCal data and returns vObject struct
- *
- * @param pVCalRaw The raw data
- * @return vObject The result value
- */
- VTree*
-vcal_decode( char *pVCalRaw )
-{
- char* szValue = NULL;
- char c;
- VParam* pTmpParam = NULL;
- VTree* pRes = NULL;
- VTree* pVCal = NULL;
- VObject* pTemp = NULL;
- VTree* pTmpTree = NULL;
- char* szCalBegin = NULL;
- char* szCalEnd = NULL;
- int type, param;
- int status = VCAL_TYPE_NAME_STATUS;
- int done = false;
- int valueCount = 0;
- int len;
- int dLen = 0;
- int param_status = false;
- int numberedParam = 0;
- int enc = 0;
- unsigned int i;
- int diff;
-
- DBG( "------------------------------------------enter vcal_decode()--------------------------\n");
-
- //SysRequireEx( pVCalRaw != NULL, NULL );
- retvm_if(NULL == pVCalRaw,NULL , "[ERROR]vcal_decode:Invalid parameter(pVCalRaw)!\n");
-
- _VManyCRLF2CRLF(pVCalRaw);
-
- if(__VIsVCalFile(pVCalRaw) == false) // verify Vcalendar file
- {
- DBG( "not vcalendar file\n");
- return NULL;
- }
-
- //len = _VUnfolding( pVCalRaw );
- len = _VUnfoldingNoSpec(pVCalRaw, VCALENDAR);
- len = _VManySpace2Space( pVCalRaw );
-
- if ( len < 10 )
- {
- DBG("length is too short!!\n");
- return NULL;
- }
-
- // while ( true )
- while ( pVCalRaw != NULL )
- {
-
- c = *pVCalRaw;
- if ( ( c == '\0' ) || done )
- break;
-
- switch ( status )
- {
- case VCAL_TYPE_NAME_STATUS:
- enc = 0;
- dLen = 0;
- numberedParam = 0;
- type = __VCalGetTypeName( pVCalRaw, &status, &dLen );
- pVCalRaw += dLen;
-
- switch ( type )
- {
- case VCAL_TYPE_BEGIN:
- DBG("VCAL_TYPE_BEGIN\n");
- dLen = 0;
- pVCal = ( VTree* )malloc( sizeof( VTree ) );
-
- if ( pVCal == NULL )
- {
- DBG( "vcal_decode():malloc Failed\n");
- return NULL;
- }
- pVCal->pTop = NULL;
- pVCal->pCur = NULL;
- pVCal->pNext = NULL;
-
- szCalBegin = __VCalGetTypeValue( pVCalRaw, &status, &dLen, 0, NULL );
-
- pVCalRaw += dLen;
-
- for ( i = 0; i < strlen( szCalBegin ); i++ )
- szCalBegin[i] = toupper( szCalBegin[i] );
-
- if ( ( diff = strcmp( "VCALENDAR", szCalBegin ) ) == 0 )
- {
- pVCal->treeType = VCALENDAR;
- pRes = pVCal;
- pTmpTree = pRes;
- }
- else if ( ( diff = strcmp( "VEVENT", szCalBegin ) ) == 0 )
- {
- pVCal->treeType = VEVENT;
- if(pTmpTree)
- pTmpTree->pNext = pVCal;
- pTmpTree = pVCal;
- }
- else if ( ( diff = strcmp( "VTODO", szCalBegin ) ) == 0 )
- {
- pVCal->treeType = VTODO;
- pTmpTree->pNext = pVCal;
- pTmpTree = pVCal;
- }
- else if ( ( diff = strcmp( "VFREEBUSH", szCalBegin ) ) == 0 )
- {
- pVCal->treeType = VFREEBUSY;
- pTmpTree->pNext = pVCal;
- pTmpTree = pVCal;
- }
- else if ( ( diff = strcmp( "VALARM", szCalBegin ) ) == 0 )
- {
- pVCal->treeType = VALARM;
- pTmpTree->pNext = pVCal;
- pTmpTree = pVCal;
- }
- else if ( ( diff = strcmp( "VTIMEZONE", szCalBegin ) ) == 0 )
- {
- pVCal->treeType = VTIMEZONE;
- pTmpTree->pNext = pVCal;
- pTmpTree = pVCal;
- }
- else if ( ( diff = strcmp( "VJOURNAL", szCalBegin ) ) == 0 )
- {
- pVCal->treeType = VJOURNAL;
- pTmpTree->pNext = pVCal;
- pTmpTree = pVCal;
- }
- else if ( ( diff = strcmp( "STANDARD", szCalBegin ) ) == 0 )
- {
- pVCal->treeType = STANDARD;
- pTmpTree->pNext = pVCal;
- pTmpTree = pVCal;
- }
- else if ( ( diff = strcmp( "DAYLIGHT", szCalBegin ) ) == 0 )
- {
- pVCal->treeType = DAYLIGHT;
- pTmpTree->pNext = pVCal;
- pTmpTree = pVCal;
- }
-
- free( szCalBegin );
- break;
- case VCAL_TYPE_END:
- dLen = 0;
- DBG("VCAL_TYPE_END\n");
- szCalEnd = __VCalGetTypeValue( pVCalRaw, &status, &dLen, 0, NULL );
-
- pVCalRaw += dLen;
-
- for ( i = 0; i < strlen( szCalEnd ); i++ )
- szCalEnd[i] = toupper(szCalEnd[i]);
-
- if ( ( diff = strcmp( "VCALENDAR", szCalEnd ) ) == 0 )
- done = true;
- free( szCalEnd );
-
- break;
- //case UNKNOWN_NAME:
- // DBG( "Unknown name!!\n");
- // break;
- default:
-
- if ( pTmpTree == NULL )
- {
- ERR( "vcal_decode():pTmpTree is NULL\n");
- vcal_free_vtree_memory(pVCal);
- return NULL;
-
- }
-
- if ( ( pTemp = ( VObject* )malloc( sizeof( VObject ) ) ) == NULL )
- {
- ERR( "vcal_decode():malloc Failed\n");
- vcal_free_vtree_memory(pVCal);
- return NULL;
- }
-
- memset( pTemp, 0, sizeof( VObject ) );
- pTemp->property = type;
-
- if ( pTmpTree->pTop == NULL )
- {
- pTmpTree->pTop = pTemp;
- pTmpTree->pCur = pTemp;
- }
- else
- {
-
- pTmpTree->pCur->pSibling = pTemp;
- pTmpTree->pCur = pTemp;
- }
-
- break;
- }
-
- numberedParam = 0;
- param_status = false;
- valueCount = 0;
- break;
- case VCAL_PARAM_NAME_STATUS:
- dLen = 0;
- param = __VCalGetParamName( pVCalRaw, &status, &dLen );
- pVCalRaw += dLen;
-
- if ( param_status != true )
- {
-
- if ( pTmpTree == NULL )
- {
- return pVCal;
- }
-
- if ( ( pTmpTree->pCur->pParam = ( VParam* )malloc( sizeof( VParam ) ) ) == NULL )
- {
- DBG( "vcal_decode():malloc Failed\n");
- //SysSetLastError( VDATA_ERROR_MEMALLOC_FAILED );
- return pVCal;
- }
- param_status = true;
- pTmpParam = pTmpTree->pCur->pParam;
- memset( pTmpParam, 0, sizeof( VParam ) );
- }
- else
- {
- if ( pTmpParam == NULL )
- {
- return pVCal;
- }
-
- if ( ( pTmpParam->pNext = ( VParam* )malloc( sizeof( VParam ) ) ) == NULL )
- {
- DBG( "vcal_decode():malloc Failed\n");
- //SysSetLastError( VDATA_ERROR_MEMALLOC_FAILED );
- return pVCal;
- }
- pTmpParam = pTmpParam->pNext;
- memset( pTmpParam, 0, sizeof( VParam ) );
- }
- pTmpParam->parameter = param;
-
- // poiema Go through to the next case statement.
-
- case VCAL_PARAM_VALUE_STATUS:
- dLen = 0;
- numberedParam = 0;
- if(pTmpParam == NULL)
- break;
- switch( pTmpParam->parameter )
- {
- case VCAL_PARAM_TYPE:
- szValue = __VCalGetParamValue( pVCalRaw, &status, &dLen );
- numberedParam |= __VCalGetValue( szValue, pCalTypeValList, VCAL_TYPE_PARAM_NUM );
- break;
- case VCAL_PARAM_VALUE:
- szValue = __VCalGetParamValue( pVCalRaw, &status, &dLen );
- numberedParam |= __VCalGetValue( szValue, pCalValValList, VCAL_VALUE_PARAM_NUM );
- break;
- case VCAL_PARAM_ENCODING:
- szValue = __VCalGetParamValue( pVCalRaw, &status, &dLen );
- numberedParam |= __VCalGetValue( szValue, pCalEncValList, VCAL_ENCODE_PARAM_NUM );
- enc = numberedParam;
- break;
- case VCAL_PARAM_ROLE:
- szValue = __VCalGetParamValue( pVCalRaw, &status, &dLen );
- numberedParam |= __VCalGetValue( szValue, pCalRoleValList, VCAL_ROLE_PARAM_NUM );
- break;
- case VCAL_PARAM_RSVP:
- szValue = __VCalGetParamValue( pVCalRaw, &status, &dLen );
- numberedParam |= __VCalGetValue( szValue, pCalRSVPValList, VCAL_RSVP_PARAM_NUM );
- break;
- case VCAL_PARAM_EXPECT:
- szValue = __VCalGetParamValue( pVCalRaw, &status, &dLen );
- numberedParam |= __VCalGetValue( szValue, pCalExpectValList, VCAL_EXPECT_PARAM_NUM );
- break;
- case VCAL_PARAM_STATUS:
- szValue = __VCalGetParamValue( pVCalRaw, &status, &dLen );
- numberedParam |= __VCalGetValue( szValue, pCalStatusValList, VCAL_STATUS_PARAM_NUM );
- break;
- case VCAL_PARAM_CUTYPE:
- szValue = __VCalGetParamValue( pVCalRaw, &status, &dLen );
- numberedParam |= __VCalGetValue( szValue, pCalCutypeValList, VCAL_CUTYPE_PARAM_NUM );
- break;
- case VCAL_PARAM_FBTYPE:
- szValue = __VCalGetParamValue( pVCalRaw, &status, &dLen );
- numberedParam |= __VCalGetValue( szValue, pCalFbtypeValList, VCAL_FBTYPE_PARAM_NUM );
- break;
- case VCAL_PARAM_PARTSTAT:
- szValue = __VCalGetParamValue( pVCalRaw, &status, &dLen );
- numberedParam |= __VCalGetValue( szValue, pCalPartstatValList, VCAL_PARTSTAT_PARAM_NUM );
- break;
- case VCAL_PARAM_RANGE:
- szValue = __VCalGetParamValue( pVCalRaw, &status, &dLen );
- numberedParam |= __VCalGetValue( szValue, pCalRangeValList, VCAL_RANGE_PARAM_NUM );
- break;
- case VCAL_PARAM_RELATED:
- szValue = __VCalGetParamValue( pVCalRaw, &status, &dLen );
- numberedParam |= __VCalGetValue( szValue, pCalRelatedValList, VCAL_RELATED_PARAM_NUM );
- break;
- case VCAL_PARAM_RELTYPE:
- szValue = __VCalGetParamValue( pVCalRaw, &status, &dLen );
- numberedParam |= __VCalGetValue( szValue, pCalReltypeValList, VCAL_RELTYPE_PARAM_NUM );
- break;
- case VCAL_PARAM_CHARSET:
- case VCAL_PARAM_CONTEXT:
- case VCAL_PARAM_LANGUAGE:
- case VCAL_PARAM_ALTREP:
- case VCAL_PARAM_CN:
- case VCAL_PARAM_DELEGATED_FROM:
- case VCAL_PARAM_DELEGATED_TO:
- case VCAL_PARAM_DIR:
- case VCAL_PARAM_FMTYPE:
- case VCAL_PARAM_MEMBER:
- case VCAL_PARAM_SENT_BY:
- case VCAL_PARAM_TZID:
- {
- char * pParamValue = __VCalGetParamValue( pVCalRaw, &status, &dLen );
- if (pParamValue != NULL)
- {
- free(pParamValue);
- pParamValue = NULL;
- }
- }
- break;
-
- default:
- szValue = __VCalGetParamValue( pVCalRaw, &status, &dLen );
- numberedParam = 0;
- numberedParam |= __VCalGetValue( szValue, pCalTypeValList, VCAL_TYPE_PARAM_NUM );
- if ( numberedParam != UNKNOWN_NAME )
- {
- pTmpParam->parameter = VCAL_PARAM_TYPE;
- break;
- }
- numberedParam = 0;
- numberedParam |= __VCalGetValue( szValue, pCalValValList, VCAL_VALUE_PARAM_NUM );
- if ( numberedParam != UNKNOWN_NAME )
- {
- pTmpParam->parameter = VCAL_PARAM_VALUE;
- break;
- }
- numberedParam = 0;
- numberedParam |= __VCalGetValue( szValue, pCalEncValList, VCAL_ENCODE_PARAM_NUM );
- if ( numberedParam != UNKNOWN_NAME )
- {
- pTmpParam->parameter = VCAL_PARAM_ENCODING;
- enc = numberedParam;
- break;
- }
- numberedParam = 0;
- numberedParam |= __VCalGetValue( szValue, pCalRoleValList, VCAL_ROLE_PARAM_NUM );
- if ( numberedParam != UNKNOWN_NAME )
- {
- pTmpParam->parameter = VCAL_PARAM_ROLE;
- break;
- }
- numberedParam = 0;
- numberedParam |= __VCalGetValue( szValue, pCalRSVPValList, VCAL_RSVP_PARAM_NUM );
- if ( numberedParam != UNKNOWN_NAME )
- {
- pTmpParam->parameter = VCAL_PARAM_RSVP;
- break;
- }
- numberedParam = 0;
- numberedParam |= __VCalGetValue( szValue, pCalExpectValList, VCAL_EXPECT_PARAM_NUM );
- if ( numberedParam != UNKNOWN_NAME )
- {
- pTmpParam->parameter = VCAL_PARAM_EXPECT;
- break;
- }
- numberedParam = 0;
- numberedParam |= __VCalGetValue( szValue, pCalStatusValList, VCAL_STATUS_PARAM_NUM );
- if ( numberedParam != UNKNOWN_NAME )
- {
- pTmpParam->parameter = VCAL_PARAM_STATUS;
- break;
- }
- numberedParam = 0;
- numberedParam |= __VCalGetValue( szValue, pCalCutypeValList, VCAL_CUTYPE_PARAM_NUM );
- if ( numberedParam != UNKNOWN_NAME )
- {
- pTmpParam->parameter = VCAL_PARAM_CUTYPE;
- break;
- }
- numberedParam = 0;
- numberedParam |= __VCalGetValue( szValue, pCalFbtypeValList, VCAL_FBTYPE_PARAM_NUM );
- if ( numberedParam != UNKNOWN_NAME )
- {
- pTmpParam->parameter = VCAL_PARAM_FBTYPE;
- break;
- }
- numberedParam = 0;
- numberedParam |= __VCalGetValue( szValue, pCalPartstatValList, VCAL_PARTSTAT_PARAM_NUM );
- if ( numberedParam != UNKNOWN_NAME )
- {
- pTmpParam->parameter = VCAL_PARAM_PARTSTAT;
- break;
- }
- numberedParam = 0;
- numberedParam |= __VCalGetValue( szValue, pCalRangeValList, VCAL_RANGE_PARAM_NUM );
- if ( numberedParam != UNKNOWN_NAME )
- {
- pTmpParam->parameter = VCAL_PARAM_RANGE;
- break;
- }
- numberedParam = 0;
- numberedParam |= __VCalGetValue( szValue, pCalRelatedValList, VCAL_RELATED_PARAM_NUM );
- if ( numberedParam != UNKNOWN_NAME )
- {
- pTmpParam->parameter = VCAL_PARAM_RELATED;
- break;
- }
- numberedParam = 0;
- numberedParam |= __VCalGetValue( szValue, pCalReltypeValList, VCAL_RELTYPE_PARAM_NUM );
- if ( numberedParam != UNKNOWN_NAME )
- {
- pTmpParam->parameter = VCAL_PARAM_RELTYPE;
- break;
- }
- numberedParam = 0;
-
- char * pTypeValue = __VCalGetTypeValue( pVCalRaw, &status, &dLen, 0, pVCal->pCur );
- if (pTypeValue != NULL)
- {
- free(pTypeValue);
- pTypeValue = NULL;
- }
-
- break;
- }
- pTmpParam->paramValue = numberedParam;
- if (szValue != NULL)
- {
- free(szValue);
- szValue = NULL;
- }
- pVCalRaw += dLen;
- break;
-
- case VCAL_TYPE_VALUE_STATUS:
- {
- dLen = 0;
- char *temp = NULL;
- temp = __VCalGetTypeValue( pVCalRaw, &status, &dLen, enc, pTmpTree->pCur );
-
- if(valueCount < VDATA_VALUE_COUNT_MAX) {
- pTmpTree->pCur->pszValue[valueCount] = temp;
- valueCount++;
- }
- else
- free(temp);
- }
-
-
- pTmpTree->pCur->valueCount = valueCount;
- pVCalRaw += dLen;
- break;
- }
- // pVCalRaw += dLen;
- // break;
- }
-
- if (!done )
- {
- DBG("@@@---- vcal_decode() lack VCLENDAR END and exit\n");
- vcal_free_vtree_memory(pVCal);
- return NULL;
-
- }
-
- DBG( "------------------------------------------exit vcal_decode()--------------------------\n");
-
- return pRes;
-}
-
-/*
- * vcal_free_vtree_memory() frees memory used for decoding.
- *
- * @param pTree VTree structure to be freed.
- * @return If succeeds, return true, else false.
- */
- bool
-vcal_free_vtree_memory( VTree* pTree )
-{
-
- VObject* pCurObj = NULL;
- VObject* pNextObj = NULL;
- VTree* pCurTree = NULL;
- VTree* pNextTree = NULL;
-
- DBG( "vcal_free_vtree_memory() entered.\n");
- //SysRequireEx( pTree != NULL, false );
- retvm_if(NULL == pTree,NULL , "[ERROR]vcal_free_vtree_memory:Invalid parameter(pTree)!\n");
-
- if ((pTree->treeType == VCALENDAR) ||
- ((pTree->treeType >= VEVENT) &&
- (pTree->treeType <= DAYLIGHT)))
- {
- //continue
- ;
- }
- else
- {
- return false;
- }
-
-
- pCurTree = pTree;
-
- while ( pCurTree )
- {
- pNextTree = pCurTree->pNext;
- pCurObj = pCurTree->pTop;
-
- while ( pCurObj )
- {
- int count;
- int i;
-
- pNextObj = pCurObj->pSibling;
-
- count = pCurObj->valueCount;
-
- for ( i = 0; i < count; i++ )
- {
- if ( pCurObj->pszValue[i] )
- {
- free( pCurObj->pszValue[i] );
- pCurObj->pszValue[i] = NULL;
- }
- }
-
-#ifdef VDATA_GROUPNAME_SUPPORTED
- if ( pCurObj->pszGroupName )
- {
- free( pCurObj->pszGroupName );
- pCurObj->pszGroupName = NULL;
- }
-#endif // VDATA_GROUPNAME_SUPPORTED
-
- if ( pCurObj->pParam )
- {
- VParam* pCurParam = NULL;
- VParam* pNextParam = NULL;
-
- pCurParam = pCurObj->pParam;
-
- while ( pCurParam )
- {
- pNextParam = pCurParam->pNext;
-
- free( pCurParam );
- pCurParam = NULL;
-
- pCurParam = pNextParam;
- }
- }
-
- free( pCurObj );
- pCurObj = NULL;
-
- pCurObj = pNextObj;
- }
-
- free( pCurTree );
- pCurTree = NULL;
-
- pCurTree = pNextTree;
- }
-
- DBG( "\n---------------------------exit vcal_free_vtree_memory--------- -------------\n");
-
- return true;
-}
-
-
-/*
- * vCaLTypeEncoder() compares the string and VCal type, parameter value.
- *
- * @param typeObj Data which will be encoded
- * @param type Name of the type
- * @return char * Encoded result
- */
-static char* __VCalTypeEncode( VObject* pTypeObj, const char *pType )
-{
- int len;
- char* pTemp = NULL;
- char* szTypeValue = NULL;
- int i;
- int enc = 0;
- char* pEncode = NULL;
- char* pRes = NULL;
- int total = 0;
- int biLen = 0;
- char* tempszTypeValue = NULL;
-
- DBG( "__VCalTypeEncode() enter..\n");
-
- len = strlen( pType );
- biLen = pTypeObj->numOfBiData;
-
- if ( ( szTypeValue = ( char * )malloc( total += ( len+1+10 ) ) ) == NULL ) {
- DBG( "VCalTypeEncode():malloc failed\n");
- return NULL;
- }
-
- memset( szTypeValue, '\0', ( len+1+10 ) );
- memcpy( szTypeValue, pType, len );
-
- pTemp = __VCalParamEncode( pTypeObj, &enc );
- if ( pTemp != NULL )
- {
- len = strlen( pTemp );
- tempszTypeValue = szTypeValue;
- if ( ( szTypeValue = ( char * )realloc( szTypeValue, ( total += len + 10 ) ) ) == NULL ){
- DBG( "__VCalTypeEncode():realloc failed\n");
- if (pTemp != NULL) {
- free(pTemp);
- pTemp = NULL;
- }
-
- if(tempszTypeValue) {
- free(tempszTypeValue);
- tempszTypeValue = NULL;
- }
- return NULL;
- }
- strcat( szTypeValue, pTemp );
- free( pTemp );
- }
-
- tempszTypeValue = szTypeValue;
- if ( ( szTypeValue = ( char * )realloc( szTypeValue, ( total += 2 + 10 ) ) ) == NULL ){
-
- DBG( "__VCalTypeEncode():realloc failed\n");
- if(tempszTypeValue) {
- free(tempszTypeValue);
- tempszTypeValue = NULL;
- }
- return NULL;
- }
- strcat( szTypeValue, ":\0" );
-
- len = 0;
- for ( i = 0; i < pTypeObj->valueCount; i++ ){
- if( (pTypeObj->pszValue[i]==NULL)) {
- free(szTypeValue);
- return NULL;
- }
-
- len += strlen( pTypeObj->pszValue[i] );
- }
-
- int buf_len = 0;
- char *buf = NULL;
- if ( !( pEncode = ( char * )calloc(1, (len+30)*2 + 31 )) ) {
- free( szTypeValue );
- DBG( "__VCalTypeEncode():malloc failed\n");
- return NULL;
- }
- for ( i = 0; i < pTypeObj->valueCount; i++ ) {
- int len_i = strlen(pTypeObj->pszValue[i]);
- if( buf_len < len_i ) {
- free(buf);
- buf_len = len_i;
- if( !(buf = (char*) calloc(1, buf_len*2 + 1 )) ) {
- free( szTypeValue );
- DBG( "__VCalTypeEncode():malloc failed\n");
- free( pEncode );
- return NULL;
- }
- } else {
- if(buf)
- bzero(buf, buf_len);
- }
-
- if(buf)
- {
- strncpy (buf, pTypeObj->pszValue[i], len_i);
- _VEscape( buf );
-
- if( i ) strcat( pEncode, ";");
- strcat( pEncode, buf );
- }
- }
- free( buf );
-
- strcat( pEncode, "\0\0" );
- // _VEscape( pEncode );
- len = strlen( pEncode );
-
- if ( enc & pCalEncValList[2].flag )
- {
-
- //if ( ( pRes = ( char * )malloc( len+40 ) ) == NULL )
- //if ( ( pRes = ( char * )malloc( len+40+10 ) ) == NULL )
- // Task description¿¡ enter°¡ µé¾î°¥ °æ¿ì memory ¸ðÀÚ¶÷. len * 4 + 30 -> len * 6 + 30À¸·Î º¯°æ 2004.3.12
- if ( ( pRes = ( char * )malloc( len*6+30 ) ) == NULL )
- {
- DBG( "__VCalTypeEncode():malloc failed\n");
-
- free( pEncode );
- free( szTypeValue );
-
- return NULL;
- }
- _VQPEncode( pRes, pEncode );
- free( pEncode );
- pEncode = NULL;
- }
- else if ( enc & pCalEncValList[1].flag )
- {
-
- //if ( ( pRes = ( char * )malloc( ( len * 8 / 6 ) + 4 ) ) == NULL )
- if ( ( pRes = ( char * )malloc( ( len * 8 / 6 ) + 4 + 10 ) ) == NULL )
- {
- DBG( "__VCalTypeEncode():malloc failed\n");
- free( pEncode );
- free( szTypeValue );
-
- return NULL;
- }
-
- //memset( pRes, '\0', ( ( len * 8 / 6 ) + 4 ) );
- memset( pRes, '\0', ( ( len * 8 / 6 ) + 4 + 10) );
- _gbase64Encode( pRes, pEncode, biLen );
-
- free( pEncode );
- pEncode = NULL;
- }
- else
- {
-
- //if ( ( pRes = ( char * )malloc( len+2 ) ) == NULL )
- if ( ( pRes = ( char * )malloc( len+2 + 10) ) == NULL )
- {
- DBG( "__VCalTypeEncode():malloc failed\n");
-
- free( pEncode );
- free( szTypeValue );
-
- return NULL;
- }
- //memset( pRes, '\0', ( len + 2 ) );
- memset( pRes, '\0', ( len + 2 + 10 ) );
- memcpy( pRes, pEncode, len );
- free( pEncode );
- pEncode = NULL;
- }
-
- strcat( pRes, "\r\n" ); //\n\0 -> \r\n ¼öÁ¤ ewpark 10.14th
-
- len = strlen( pRes );
- //if ( ( szTypeValue = ( char * )realloc( szTypeValue, ( total += ( len+3 ) ) ) ) == NULL )
- tempszTypeValue = szTypeValue;
- if ( ( szTypeValue = ( char * )malloc( ( total += ( len*4 +3 + 10 ) ) ) ) == NULL )
- {
- DBG( "__VCalTypeEncode():realloc failed\n");
- if (pEncode != NULL)
- {
- free( pEncode );
- pEncode = NULL;
- }
- if (pRes != NULL)
- {
- free( pRes );
- pRes = NULL;
- }
- if(tempszTypeValue)
- {
- free(tempszTypeValue);
- tempszTypeValue = NULL;
- }
-
- return NULL;
- }
-
- memset(szTypeValue,0x00,total);
- strncpy(szTypeValue,tempszTypeValue,total);
- strcat( szTypeValue, pRes );
- _VRLSpace( szTypeValue );
- _VRTSpace( szTypeValue );
-
- free(tempszTypeValue);
- free( pRes );
- if ( strlen( szTypeValue ) >= 75 )
- {
- if ( ( pEncode = ( char * )malloc( sizeof( char ) * ( strlen( szTypeValue )*4 + ( strlen( szTypeValue ) / 75 ) * 2 + 10 + 10 ) ) ) == NULL )
- {
- DBG( "__VCalTypeEncode():malloc failed\n");
- free( szTypeValue );
- return NULL;
- }
-
- _VFolding( pEncode, szTypeValue );
- free( szTypeValue );
-
- return pEncode;
- }
-
- DBG( "__VCalTypeEncode() end..\n");
-
- return szTypeValue;
-}
-
-
-/*
- * vcal_encode() compares the string and VCal type, parameter value.
- *
- * @param pVCalRaw Data which will be encoded
- * @return char * Encoded result
- */
- char*
-vcal_encode( VTree* pVCalRaw )
-{
- char* pCalRes = NULL;
- char* pTemp = NULL;
- int len;
- int total = 0;
- VTree* pTmpTree = NULL;
- VObject* pTmpObj = NULL;
-
- DBG( "vcal_encode() enter..\n");
- //SysRequireEx( pVCalRaw != NULL, NULL );
- if(pVCalRaw == NULL)
- return NULL;
-
- if ((pVCalRaw->treeType == VCALENDAR) ||
- ((pVCalRaw->treeType >= VEVENT) &&
- (pVCalRaw->treeType <= DAYLIGHT)))
- {
- //continue
- ;
- }
- else
- {
- return NULL;
- }
-
- if ( ( pCalRes = ( char * )malloc( total += 2 ) ) == NULL )
- {
- DBG( "vcal_encode():malloc failed\n");
- return NULL;
- }
- memset( pCalRes, '\0', 1);
-
- pTmpTree = pVCalRaw;
- pTmpObj = pTmpTree->pTop;
-
- /*
- if( (pTmpObj == NULL) || (pTmpObj->property < 0) || (pTmpObj->valueCount < 0) )
- {
- if(pTmpObj !=NULL)
- DBG( "pTmpObj = %d, pTmpObj->property = %d,pTmpObj->valueCount=%d \n",pTmpObj,pTmpObj->property,pTmpObj->valueCount);
- else
- DBG("pTmpObj is NULL");
- return NULL;
- }*/
-
- while ( true )
- {
- switch ( pTmpTree->treeType )
- {
- case VCALENDAR:
-
- // wyj add PRODID field,set PRODID length is 100
- if ( ( pCalRes = ( char * )realloc( pCalRes, ( total += 18 + 100+15) ) ) == NULL )
- {
-
- DBG( "vcal_encode():realloc failed\n");
- return NULL;
- }
- strcat( pCalRes, "BEGIN:VCALENDAR\r\n" );
- strcat( pCalRes, "PRODID:-//Tizen //Calendar //EN\r\n" );
-
- strcat( pCalRes, "VERSION:1.0\r\n" );
- break;
- case VEVENT:
- if ( ( pCalRes = ( char * )realloc( pCalRes, ( total += 15 ) ) ) == NULL )
- {
-
- DBG( "vcal_encode():realloc failed\n");
- return NULL;
- }
- strcat( pCalRes, "BEGIN:VEVENT\r\n" );
- break;
- case VTODO:
- if ( ( pCalRes = ( char * )realloc( pCalRes, ( total += 14 ) ) ) == NULL )
- {
-
- DBG( "vcal_encode():realloc failed\n");
- return NULL;
- }
- strcat( pCalRes, "BEGIN:VTODO\r\n" );
- break;
- case VJOURNAL:
- if ( ( pCalRes = ( char * )realloc( pCalRes, ( total += 17 ) ) ) == NULL )
- {
-
- DBG( "vcal_encode():realloc failed\n");
- return NULL;
- }
- strcat( pCalRes, "BEGIN:VJOURNAL\r\n" );
- break;
- case VFREEBUSY:
- if ( ( pCalRes = ( char * )realloc( pCalRes, ( total += 18 ) ) ) == NULL )
- {
-
- DBG( "vcal_encode():realloc failed\n");
- return NULL;
- }
- strcat( pCalRes, "BEGIN:VFREEBUSY\r\n" );
- break;
- case VTIMEZONE:
- if ( ( pCalRes = ( char * )realloc( pCalRes, ( total += 19 ) ) ) == NULL )
- {
-
- DBG( "vcal_encode():realloc failed\n");
- return NULL;
- }
- strcat( pCalRes, "BEGIN:VTIMEZONE\r\n" );
- break;
- case VALARM:
- if ( ( pCalRes = ( char * )realloc( pCalRes, ( total += 15 ) ) ) == NULL )
- {
-
- DBG( "vcal_encode():realloc failed\n");
- return NULL;
- }
- strcat( pCalRes, "BEGIN:VALARM\r\n" );
- break;
- case STANDARD:
- if ( ( pCalRes = ( char * )realloc( pCalRes, ( total += 17 ) ) ) == NULL )
- {
-
- DBG( "vcal_encode():realloc failed\n");
- return NULL;
- }
- strcat( pCalRes, "BEGIN:STANDARD\r\n" );
- break;
- case DAYLIGHT:
- if ( ( pCalRes = ( char * )realloc( pCalRes, ( total += 17 ) ) ) == NULL )
- {
-
- DBG( "vcal_encode():realloc failed\n");
- return NULL;
- }
- strcat( pCalRes, "BEGIN:DAYLIGHT\r\n" );
- break;
- }
-
- while ( true )
- {
- if ( pTmpObj != NULL )
- {
- if( pTmpObj->property <0 || pTmpObj->property >= VCAL_TYPE_NUM )
- {
- if(pCalRes)
- free(pCalRes);
- return NULL;
- }
- if ( ( pTemp = __VCalTypeEncode( pTmpObj, pszCalTypeList[pTmpObj->property] ) ) != NULL )
- {
- len = strlen( pTemp );
- if ( ( pCalRes = ( char *)realloc( pCalRes, ( total += ( len + 10 ) ) ) ) == NULL )
- {
- DBG( "vcal_encode():realloc failed\n");
- free( pTemp );
- pTemp = NULL;
- return NULL;
- }
- strcat( pCalRes, pTemp );
- free( pTemp );
- }
-
- if ( pTmpObj->pSibling != NULL )
- pTmpObj = pTmpObj->pSibling;
- else
- break;
- }
- else
- break;
- }
-
- switch ( pTmpTree->treeType )
- {
- /* case VCALENDAR:
- if ( ( pCalRes = ( char * )realloc( pCalRes, ( total += 15 ) ) ) == NULL )
- {
- DBG( "vcal_encode():realloc failed\n");
- return NULL;
- }
- memcpy( pCalRes, "END:VCALENDAR\r\n", 17 );
- break; */
- case VEVENT:
- if ( ( pCalRes = ( char * )realloc( pCalRes, ( total += 13 ) ) ) == NULL )
- {
-
- DBG( "vcal_encode():realloc failed\n");
- return NULL;
- }
- strcat( pCalRes, "END:VEVENT\r\n" );
- break;
- case VTODO:
- if ( ( pCalRes = ( char * )realloc( pCalRes, ( total += 12 ) ) ) == NULL )
- {
-
- DBG( "vcal_encode():realloc failed\n");
- return NULL;
- }
- strcat( pCalRes, "END:VTODO\r\n" );
- break;
- case VJOURNAL:
- if ( ( pCalRes = ( char * )realloc( pCalRes, ( total += 15 ) ) ) == NULL )
- {
-
- DBG( "vcal_encode():realloc failed\n");
- return NULL;
- }
- strcat( pCalRes, "END:VJOURNALO\r\n" );
- break;
- case VFREEBUSY:
- if ( ( pCalRes = ( char * )realloc( pCalRes, ( total += 16 ) ) ) == NULL )
- {
-
- DBG( "vcal_encode():realloc failed\n");
- return NULL;
- }
- strcat( pCalRes, "END:VFREEBUSY\r\n" );
- break;
- case VTIMEZONE:
- if ( ( pCalRes = ( char * )realloc( pCalRes, ( total += 16 ) ) ) == NULL )
- {
-
- DBG( "vcal_encode():realloc failed\n");
- return NULL;
- }
- strcat( pCalRes, "END:VTIMEZONE\r\n" );
- break;
- case VALARM:
- if ( ( pCalRes = ( char * )realloc( pCalRes, ( total += 13 ) ) ) == NULL )
- {
-
- DBG( "vcal_encode():realloc failed\n");
- return NULL;
- }
- strcat( pCalRes, "END:VALARM\r\n" );
- break;
- case STANDARD:
- if ( ( pCalRes = ( char * )realloc( pCalRes, ( total += 15 ) ) ) == NULL )
- {
-
- DBG( "vcal_encode():realloc failed\n");
- return NULL;
- }
- strcat( pCalRes, "END:STANDARD\r\n" );
- break;
- case DAYLIGHT:
- if ( ( pCalRes = ( char * )realloc( pCalRes, ( total += 15 ) ) ) == NULL )
- {
- DBG( "vcal_encode():realloc failed\n");
- return NULL;
- }
- strcat( pCalRes, "END:DAYLIGHT\r\n" );
- break;
- }
-
- if ( pTmpTree->pNext != NULL )
- pTmpTree = pTmpTree->pNext;
- else
- break;
- pTmpObj = pTmpTree->pTop;
- }
-
- if ( ( pCalRes = ( char * )realloc( pCalRes, ( total += 16 ) ) ) == NULL )
- {
-
- DBG( "vcal_encode():realloc failed\n");
- return NULL;
- }
- strcat( pCalRes, "END:VCALENDAR\r\n" ); //\n\0 -> \r\n ¼öÁ¤ ewpark 10.14th
-
- DBG( "vcal_encode() end..\n");
-
- return pCalRes;
-}
-
-
-
-/*
- * vCalParamEncoder() compares the string and VCal type, parameter value.
- *
- * @param typeObj Data which will be encoded
- * @param type Name of the type
- */
-static char* __VCalParamEncode( VObject* pTypeObj, int *pEnc )
-{
- char *szParam = NULL;
- VParam *pTemp = NULL;
- int i;
- const ValueObj *pList;
- bool bSupported;
- int sNum;
- int shift;
- int len = 0;
-
- DBG( "__VCalParamEncode() enter..\n");
- retvm_if(NULL == pTypeObj,NULL , "[ERROR]__VCalParamEncode:Invalid parameter(pTypeObj)!\n");
-
- pTemp = pTypeObj->pParam;
- if ( pTemp != NULL )
- {
- if ( ( szParam = ( char *)malloc( len += 2 ) ) == NULL )
- {
- DBG( "__VCalParamEncode():malloc failed\n");
- return NULL;
- }
- memcpy( szParam, "\0\0", 2 );
- }
-
- while ( pTemp != NULL )
- {
- bSupported = false;
-
- if ( ( szParam = ( char * )realloc( szParam, ( len += 15 ) ) ) == NULL )
- {
-
- DBG( "__VCalParamEncode():realloc failed\n");
- return NULL;
- }
-
- strcat( szParam, ";" );
- strcat( szParam, pszCalParamList[pTemp->parameter] );
- strcat( szParam, "=" );
-
- switch ( pTemp->parameter )
- {
- case VCAL_PARAM_ENCODING:
- *pEnc = pTemp->paramValue;
- shift = VCAL_ENCODE_PARAM_NUM;
- pList = pCalEncValList; bSupported = true;
- break;
- case VCAL_PARAM_CHARSET:
- shift = VCAL_CHARSET_PARAM_NUM;
- pList = pCalCharsetValList; bSupported = true;
- break;
- case VCAL_PARAM_TYPE:
- shift = VCAL_TYPE_PARAM_NUM;
- pList = pCalTypeValList; bSupported = true;
- break;
- case VCAL_PARAM_VALUE:
- shift = VCAL_VALUE_PARAM_NUM;
- pList = pCalValValList; bSupported = true;
- break;
- case VCAL_PARAM_EXPECT:
- shift = VCAL_EXPECT_PARAM_NUM;
- pList = pCalExpectValList; bSupported = true;
- break;
- case VCAL_PARAM_ROLE:
- shift = VCAL_ROLE_PARAM_NUM;
- pList = pCalRoleValList; bSupported = true;
- break;
- case VCAL_PARAM_RSVP:
- shift = VCAL_RSVP_PARAM_NUM;
- pList = pCalRSVPValList; bSupported = true;
- break;
- case VCAL_PARAM_STATUS:
- shift = VCAL_STATUS_PARAM_NUM;
- pList = pCalStatusValList; bSupported = true;
- break;
- case VCAL_PARAM_CUTYPE:
- shift = VCAL_CUTYPE_PARAM_NUM;
- pList = pCalCutypeValList; bSupported = true;
- break;
- case VCAL_PARAM_FBTYPE:
- shift = VCAL_FBTYPE_PARAM_NUM;
- pList = pCalFbtypeValList; bSupported = true;
- break;
- case VCAL_PARAM_PARTSTAT:
- shift = VCAL_PARTSTAT_PARAM_NUM;
- pList = pCalPartstatValList; bSupported = true;
- break;
- case VCAL_PARAM_RANGE:
- shift = VCAL_RANGE_PARAM_NUM;
- pList = pCalRangeValList; bSupported = true;
- break;
- case VCAL_PARAM_RELATED:
- shift = VCAL_RELATED_PARAM_NUM;
- pList = pCalRelatedValList; bSupported = true;
- break;
- case VCAL_PARAM_RELTYPE:
- shift = VCAL_RELTYPE_PARAM_NUM;
- pList = pCalReltypeValList; bSupported = true;
- break;
- default:
-
- if ( ( szParam = ( char *)realloc( szParam, 5 ) ) == NULL )
- {
- DBG( "__VCalParamEncode():realloc failed\n");
- return NULL;
- }
- strcat( szParam, "NONE" );
- break;
- }
-
- if ( bSupported == true )
- {
- for ( i = 0, sNum = 0x00000001; i < shift; i++ )
- {
- if ( pTemp->paramValue & sNum )
- {
- if ( ( szParam = ( char * )realloc( szParam,
- ( len += ( strlen( pList[i].szName ) + 2 ) ) ) ) == NULL )
- {
-
- DBG( "__VCalParamEncode():realloc failed\n");
- return NULL;
- }
- strcat( szParam, pList[i].szName );
- strcat( szParam, ", \0" );
- }
- sNum <<= 1;
- }
- }
-
- for ( i = strlen( szParam ); i > 0 ; i-- )
- {
- if ( szParam[i] == ' ' && szParam[i-1] == ',' )
- {
- szParam[i-1] = '\0';
- break;
- }
- }
-
- if ( pTemp->pNext != NULL )
- pTemp = pTemp->pNext;
- else
- break;
- }
-
- DBG( "\n ------end __VCalParamEncode ---------..\n");
-
- return szParam;
-}
-
-bool __cal_vcalendar_get_week_day_string(struct tm *start_time, char *s2)
-{
- char *date_string[7] = { "SU","MO","TU","WE","TH","FR","SA" };
-
- struct tm temp;
- time_t t = timegm(start_time);
- gmtime_r(&t, &temp);
-
- if(temp.tm_wday < 0 || temp.tm_wday > 6 )
- {
- return false;
- }
- else
- {
- snprintf(s2, 3, date_string[temp.tm_wday]);
- }
-
- return true;
-}
-
-// in calendar schedule and todo data structure, the remind_tick is always 1
- bool
-__cal_vcalendar_parse_reminder_time(const char * str, cal_sch_category_t category, struct tm * event_start_time, int * remind_tick, cal_sch_remind_tick_unit_t * remind_tick_unit)
-{
- assert(str != NULL);
-
- struct tm tm={0,};
- struct tm base_tm={0,};
-
- cal_vcalendar_convert_utc_str_to_tm(str, &tm);
- base_tm.tm_year = event_start_time->tm_year;
- base_tm.tm_mon = event_start_time->tm_mon;
- base_tm.tm_mday = event_start_time->tm_mday;
- if ((category == CAL_SCH_SPECIAL_OCCASION) || (category == CAL_SCH_BIRTHDAY))
- {
- base_tm.tm_min = tm.tm_min;
- base_tm.tm_hour = tm.tm_hour;
- }
- else
- {
- base_tm.tm_min = event_start_time->tm_min;
- base_tm.tm_hour = event_start_time->tm_hour;
- }
- base_tm.tm_sec = 0;
- tm.tm_sec = 0;
- time_t gap_time = timegm(&base_tm) - timegm(&tm);
-
- *remind_tick = 1;
-
- if (gap_time < 0)
- {
- gap_time = 0 - gap_time;
- *remind_tick_unit = CAL_SCH_TIME_UNIT_MIN;
- *remind_tick = 0;
- }
- else if ((gap_time >= 0) && (gap_time < 60*60))
- {
- *remind_tick_unit = CAL_SCH_TIME_UNIT_MIN;
- *remind_tick = gap_time/60;
- }
- else if ((gap_time >= 60*60) && (gap_time < 60*60*24))
- {
- *remind_tick_unit = CAL_SCH_TIME_UNIT_HOUR;
- *remind_tick = gap_time/(60*60);
-
- }
- else if ((gap_time >= 60*60*24) && (gap_time < 60*60*24*7))
- {
- *remind_tick_unit = CAL_SCH_TIME_UNIT_DAY;
- *remind_tick = gap_time/(60*60*24);
-
- }
- else if ((gap_time >= 60*60*24*7) && (gap_time < 60*60*24*30))
- {
- *remind_tick_unit = CAL_SCH_TIME_UNIT_WEEK;
- *remind_tick = gap_time/(60*60*24*7);
-
- }
- else if ((gap_time >= 60*60*24*30) && (gap_time < 60*60*24*365))
- {
- *remind_tick_unit = CAL_SCH_TIME_UNIT_MONTH;
- *remind_tick = gap_time/(60*60*24*30);
-
- }
-
- return true;
-}
-
-// string format: D1 20020305T235959Z
- bool
-__cal_vcalendar_parse_sch_repeat_rule(const char *szText, cal_repeat_term_t * repeat_term, int * repeatInterval, struct tm * repeat_end_date,int *repeat_count)
-{
- char szBuff[4];
- int startPos, strLen;
- int i, j;
- char c, c1, c2;
- char *date_pos = NULL;
-
- startPos = 1;
- j = 0;
-
- //check repeat term rule
- if ( szText[0] == 'D' )
- {
- *repeat_term = CAL_REPEAT_EVERY_DAY;
- startPos = 1;
- }
- else if ( szText[0] == 'W' )
- {
- *repeat_term = CAL_REPEAT_EVERY_WEEK;
- startPos = 1;
- }
- else if ( szText[0] == 'M' )
- {
- *repeat_term = CAL_REPEAT_EVERY_MONTH;
- if ( szText[1] == 'P' )
- {
- startPos = 2;
- }
- else if ( szText[1] == 'D' )
- {
- startPos = 2;
- }
- }
- else if ( szText[0] == 'Y' )
- {
- *repeat_term = CAL_REPEAT_EVERY_YEAR;
- if ( szText[1] == 'M' )
- {
- startPos = 2;
- }
- else if ( szText[1] == 'D' )
- {
- startPos = 2;
- }
- }
- //check repeat interval
- strLen = strlen(szText);
- for ( i = startPos ; i < strLen ; i++ )
- {
- if ( j < 4 )
- {
- if (szText[i] != ' ')
- {
- szBuff[j] = szText[i];
- j++;
- }
- else
- {
- break;
- }
- }
- else
- {
- return false;
- }
-
- }
-
- szBuff[j] = '\0';
- *repeatInterval = atol(szBuff);
-
- startPos = i + 1;
-
- date_pos = strchr(szText + startPos, 'T');
-
- if(date_pos == NULL)
- {
- date_pos = strchr(szText + startPos, '#');
- *repeat_count = atol(date_pos+1);
- }
- else
- {
- while(date_pos != NULL) {
- c1 = *(date_pos - 1);
- c2 = *(date_pos + 1);
-
- if(isdigit(c1) && isdigit(c2))
- {
- do
- {
- c=*(--date_pos);
- }while(c!=' ');
- date_pos = date_pos + 1; // Skip ' ';
- cal_vcalendar_convert_utc_str_to_tm(date_pos, repeat_end_date);
- break;
- }
- if(date_pos + 1 == NULL)
- {
- break;
- }
-
- date_pos = strchr(date_pos+1, 'T');
- }
- }
-
- return true;
-}
-
- bool
-__cal_vcalendar_parse_sch_repeat_rule_for_ical(VObject* object , cal_repeat_term_t * repeat_term, int * repeatInterval, struct tm * repeat_end_date)
-{
- int i = 0;
- int j = 0;
- int m = 0;
- int value_count = 0;
- char szBuff[4];
- int startPos = 0;
- int strLen = 0;
-
- if (strcmp(object->pszValue[0], "FREQ=DAILY") == 0)
- {
- *repeat_term = CAL_REPEAT_EVERY_DAY;
- }
- else if (strcmp(object->pszValue[0], "FREQ=WEEKLY") == 0)
- {
- *repeat_term = CAL_REPEAT_EVERY_WEEK;
- }
- else if (strcmp(object->pszValue[0], "FREQ=MONTHLY") == 0)
- {
- *repeat_term = CAL_REPEAT_EVERY_MONTH;
- }
- else if (strcmp(object->pszValue[0], "FREQ=YEARLY") == 0)
- {
- *repeat_term = CAL_REPEAT_EVERY_YEAR;
- }
- else
- {
- *repeat_term = CAL_REPEAT_NONE;
- }
-
- *repeatInterval = 1;
- value_count = object->valueCount;
- for (i = 1; i < value_count; i ++)
- {
- if (strstr(object->pszValue[i], "INTERVAL=") != NULL)
- {
- startPos = 9;
- //check repeat interval
- strLen = strlen(object->pszValue[i]);
- for ( m = startPos ; m < strLen ; m++ )
- {
- if ( j < 4 )
- {
- if (object->pszValue[i][m] != ' ')
- {
- szBuff[j] = object->pszValue[i][m];
- j++;
- }
- else
- {
- break;
- }
- }
- else
- {
- return false;
- }
-
- }
- szBuff[j] = '\0';
- *repeatInterval = atol(szBuff);
- }
- else if (strstr(object->pszValue[i], "UNTIL=") != NULL)
- {
- startPos = 6;
- if (object->pszValue[i] + startPos != NULL)
- {
- cal_vcalendar_convert_utc_str_to_tm(object->pszValue[i] + startPos, repeat_end_date);
- }
- }
- else
- {
- ;
- }
- }
-
- CALS_DBG( "\n-------------------__cal_vcalendar_parse_sch_repeat_rule_for_ical repeat item is %d, interval is %d --------------------\n",*repeat_term,*repeatInterval);
-
- return true;
-}
-
- struct tm *
-__cal_vcalendar_compute_pre_time(struct tm* start_tm,
- struct tm *alarm_tm, const int remind_tick, const cal_sch_remind_tick_unit_t unit,struct tm *ret_tm)
-{
- start_tm->tm_sec = 0;
- alarm_tm->tm_sec = 0;
- // time_t gap_time = cals_mktime(alarm_tm) - cals_mktime(start_tm);
- time_t timep = timegm(alarm_tm);
- time_t t = 0;
-
- // Fix for prevent - B.
- switch (unit )
- {
- case CAL_SCH_TIME_UNIT_MIN:
- t = timep - 60*remind_tick;
- break;
-
- case CAL_SCH_TIME_UNIT_HOUR:
- t = timep - 60*60*remind_tick;
- break;
-
- case CAL_SCH_TIME_UNIT_DAY:
- t = timep - 24*60*60*remind_tick;
- break;
- case CAL_SCH_TIME_UNIT_WEEK:
- t = timep - 7*24*60*60*remind_tick;
- break;
-
- case CAL_SCH_TIME_UNIT_MONTH:
- t = timep - 30*24*60*60*remind_tick;
- break;
-
- default:
- break;
-
- }
-
- return gmtime_r(&t,ret_tm);
-}
-
-
- bool
-__cal_vcalendar_sch_vtree_add_object(VTree *tree, const cal_sch_full_t *sch, vCalType obj_type)
-{
-#if 1
-
- VObject* object;
- int str_len = 0;
-
- assert((tree != NULL) && (sch != NULL));
-
- object = (VObject*)malloc(sizeof(VObject));
- if ( !object )
- {
- vcal_free_vtree_memory( tree );
- return false;
- }
-
- memset( object, 0, sizeof(VObject));
-
- switch(obj_type)
- {
- case VCAL_TYPE_CATEGORIES:
- {
- if(sch->cal_type == CAL_EVENT_TODO_TYPE)
- {
- break;
- }
-
- object->property = VCAL_TYPE_CATEGORIES;
-
- object->pszValue[0] = (char*)malloc(20);
- if ( !(object->pszValue[0]) )
- {
- vcal_free_vtree_memory( tree );
- CAL_FREE(object);
-
- return false;
- }
-
- memset(object->pszValue[0], 0, 20);
-
- switch (sch->sch_category)
- {
- case CAL_SCH_APPOINTMENT:
- strcpy( object->pszValue[0], "APPOINTMENT");
- break;
-
- case CAL_SCH_HOLIDAY:
- strcpy( object->pszValue[0], "HOLIDAY");
- break;
-
- case CAL_SCH_BUSSINESS:
- strcpy( object->pszValue[0], "BUSINESS");
- break;
-
- case CAL_SCH_SPECIAL_OCCASION:
- strcpy( object->pszValue[0], "SPECIAL OCCASION");
- break;
-
- case CAL_SCH_IMPORTANT:
- strcpy( object->pszValue[0], "IMPORTANT");
- break;
-
- case CAL_SCH_BIRTHDAY:
- strcpy( object->pszValue[0], "BIRTHDAY");
- break;
-
- default:
- strcpy( object->pszValue[0], "MISCELLANEOUS");
- break;
-
- }
- object->valueCount = 1;
- }
- break;
-
- case VCAL_TYPE_SUMMARY:
- {
- if (NULL != sch->summary && strlen(sch->summary) != 0)
- {
- object->property = VCAL_TYPE_SUMMARY;
- str_len = strlen(sch->summary);
- //str_len = (str_len>500)?500:str_len;
- CALS_DBG("-------------------__cal_vcalendar_sch_vtree_add_object /VCAL_TYPE_SUMMARY(%d) -------------",str_len);
- object->pParam = (VParam*)malloc(sizeof(VParam));
- if (!object->pParam)
- {
- vcal_free_vtree_memory( tree );
- CAL_FREE(object);
-
- return false;
- }
- memset(object->pParam, 0, sizeof(VParam));
-
- object->pParam->parameter = VCAL_PARAM_CHARSET;
- object->pParam->paramValue = 0x01 << VCAL_CHARSET_PARAM_UTF_8;
- object->pParam->pNext = NULL;
-
- object->pParam->pNext = (VParam*)malloc(sizeof(VParam));
- if (!object->pParam->pNext)
- {
- vcal_free_vtree_memory( tree );
- CAL_FREE(object);
-
- return false;
- }
- memset(object->pParam->pNext, 0, sizeof(VParam));
-
- object->pParam->pNext->parameter = VCAL_PARAM_ENCODING;
- object->pParam->pNext->paramValue = 0x01<<VCAL_ENC_PARAM_BASE64;
-
-
- object->pszValue[0] = (char*)malloc(str_len*2 + 1 );
- if ( !(object->pszValue[0]) )
- {
- vcal_free_vtree_memory( tree );
- CAL_FREE(object);
-
- return false;
- }
-
- if (NULL != sch->summary)
- {
- memset(object->pszValue[0], 0, str_len + 1);
- memcpy( object->pszValue[0], sch->summary, str_len);
- }
- CALS_DBG("sch->summary = %s,%s\n", sch->summary,object->pszValue[0]);
-
- object->valueCount = 1;
- }
- else
- {
- CAL_FREE(object);
-
- return true;
- }
- }
- break;
-
- case VCAL_TYPE_DESCRIPTION:
- {
- CALS_DBG("---__cal_vcalendar_sch_vtree_add_object /VCAL_TYPE_DESCRIPTION/ -------------\n");
-
- if (NULL != sch->description && strlen(sch->description) != 0)
- {
- object->property = VCAL_TYPE_DESCRIPTION;
- str_len = strlen(sch->description);
- //str_len = (str_len>500)?500:str_len;
-
- object->pParam = (VParam*)malloc(sizeof(VParam));
- if (!object->pParam)
- {
- vcal_free_vtree_memory( tree );
- CAL_FREE(object);
-
- return false;
- }
- memset(object->pParam, 0, sizeof(VParam));
-
- object->pParam->parameter = VCAL_PARAM_CHARSET;
- object->pParam->paramValue = 0x01 << VCAL_CHARSET_PARAM_UTF_8;
- object->pParam->pNext = NULL;
-
- object->pParam->pNext = (VParam*)malloc(sizeof(VParam));
- if (!object->pParam->pNext)
- {
- vcal_free_vtree_memory( tree );
- CAL_FREE(object);
-
- return false;
- }
- memset(object->pParam->pNext, 0, sizeof(VParam));
-
- object->pParam->pNext->parameter = VCAL_PARAM_ENCODING;
- object->pParam->pNext->paramValue = 0x01<<VCAL_ENC_PARAM_BASE64;
-
- object->pszValue[0] = (char*)malloc(str_len + 1 );
- if ( !(object->pszValue[0]) )
- {
- vcal_free_vtree_memory( tree );
- CAL_FREE(object);
-
- return false;
- }
-
- if (sch->description)
- {
- memset(object->pszValue[0], 0, str_len + 1);
- memcpy( object->pszValue[0], sch->description, str_len);
- }
- object->valueCount = 1;
-
- CALS_DBG("description = %s", object->pszValue[0]);
-
- }
- else
- {
- CAL_FREE(object);
-
- return true;
- }
-
- }
- break;
- case VCAL_TYPE_LOCATION:
- {
- CALS_DBG("-------------------__cal_vcalendar_sch_vtree_add_object /VCAL_TYPE_LOCATION -------------\n");
-
- if (NULL != sch->location && strlen(sch->location) != 0)
- {
- object->property = VCAL_TYPE_LOCATION;
- str_len = strlen(sch->location);
- object->pParam = (VParam*)malloc(sizeof(VParam));
- if (!object->pParam)
- {
- vcal_free_vtree_memory( tree );
- CAL_FREE(object);
-
- return false;
- }
- memset(object->pParam, 0, sizeof(VParam));
-
- object->pParam->parameter = VCAL_PARAM_CHARSET;
- object->pParam->paramValue = 0x01 << VCAL_CHARSET_PARAM_UTF_8;
- object->pParam->pNext = NULL;
-
- object->pParam->pNext = (VParam*)malloc(sizeof(VParam));
- if (!object->pParam->pNext)
- {
- vcal_free_vtree_memory( tree );
- CAL_FREE(object);
-
- return false;
- }
- memset(object->pParam->pNext, 0, sizeof(VParam));
-
- object->pParam->pNext->parameter = VCAL_PARAM_ENCODING;
- object->pParam->pNext->paramValue = 0x01;
-
- object->pszValue[0] = (char*)malloc(str_len + 1 );
- if ( !(object->pszValue[0]) )
- {
- vcal_free_vtree_memory( tree );
- CAL_FREE(object);
-
- return false;
- }
-
- if (sch->location)
- {
- memset(object->pszValue[0], 0, str_len + 1);
- memcpy( object->pszValue[0], sch->location, str_len);
- }
- object->valueCount = 1;
- }
- else
- {
- CAL_FREE(object);
-
- return true;
- }
-
- }
- break;
- case VCAL_TYPE_DTSTART:
- {
- CALS_DBG("-------------------__cal_vcalendar_sch_vtree_add_object /VCAL_TYPE_DTSTART -------------\n");
-
- object->property = VCAL_TYPE_DTSTART;
-
- object->pszValue[0] = (char*)malloc(VCALENDAR_TIME_STR_LEN + 1);
- if ( !(object->pszValue[0]) )
- {
- vcal_free_vtree_memory( tree );
- CAL_FREE(object);
-
- return false;
- }
-
- cal_vcalendar_convert_tm_to_vdata_str(&sch->start_date_time, object->pszValue[0]);
-
- object->valueCount = 1;
- }
- break;
-
- case VCAL_TYPE_DTEND:
- {
- CALS_DBG("-------------------__cal_vcalendar_sch_vtree_add_object /VCAL_TYPE_DTEND -------------\n");
-
- if(sch->cal_type == CAL_EVENT_TODO_TYPE)
- {
- break;
- }
-
- object->property = VCAL_TYPE_DTEND;
-
- object->pszValue[0] = (char*)malloc(VCALENDAR_TIME_STR_LEN + 1);
- if ( !(object->pszValue[0]) )
- {
- vcal_free_vtree_memory( tree );
- CAL_FREE(object);
-
- return false;
- }
-
- cal_vcalendar_convert_tm_to_vdata_str(&sch->end_date_time, object->pszValue[0]);
-
- object->valueCount = 1;
- }
- break;
-
- // in Calendar sch data structure, there is no due data field
- // end_date_time is assigned to due date
- case VCAL_TYPE_DUE:
- {
- CALS_DBG( "-------------------__cal_vcalendar_sch_vtree_add_object /VCAL_TYPE_DUE -------------\n");
-
- if(sch->cal_type != CAL_EVENT_TODO_TYPE)
- {
- break;
- }
-
- object->property = VCAL_TYPE_DUE;
-
- object->pszValue[0] = (char*)malloc(VCALENDAR_TIME_STR_LEN + 1);
- if ( !(object->pszValue[0]) )
- {
- vcal_free_vtree_memory( tree );
- CAL_FREE(object);
-
- return false;
- }
- cal_vcalendar_convert_tm_to_vdata_str(&sch->end_date_time, object->pszValue[0]);
-
- object->valueCount = 1;
- }
- break;
-
- case VCAL_TYPE_LAST_MODIFIED:
- {
- CALS_DBG( "-------------------__cal_vcalendar_sch_vtree_add_object /VCAL_TYPE_LAST_MODIFIED -------------\n");
-
- object->property = obj_type;
- object->pszValue[0] = (char*)malloc(VCALENDAR_TIME_STR_LEN + 1);
- if ( !(object->pszValue[0]) )
- {
- vcal_free_vtree_memory( tree );
- CAL_FREE(object);
-
- return false;
- }
-
- // get current time
- struct tm now;
-
- now.tm_year = 105;
- now.tm_mon = 2;
- now.tm_mday = 4;
- now.tm_hour = 10;
- now.tm_min = 12;
- now.tm_sec = 34;
-
- cal_vcalendar_convert_tm_to_vdata_str(&now, object->pszValue[0]);
-
- object->valueCount = 1;
- }
- break;
-
- case VCAL_TYPE_AALARM:
- {
- CALS_DBG( "\n-------------------__cal_vcalendar_sch_vtree_add_object /VCAL_TYPE_AALARM -------------\n");
-
- if (sch->alarm_list)
- {
- object->property = VCAL_TYPE_AALARM;
- cal_alarm_info_t *tmp_alarm = ((cal_value *)sch->alarm_list->data)->user_data;
- /*
- // set alarm type
- object->pParam = (VParam*)malloc(sizeof(VParam));
- if ( !object->pParam)
- {
- vcal_free_vtree_memory( tree );
- if (object != NULL)
- {
- CAL_FREE(object);
- object = NULL;
- }
- return false;
- }
- memset(object->pParam, 0, sizeof(VParam));
-
- object->pParam->parameter = VCAL_PARAM_TYPE;
-
- object->pParam->paramValue = 0x01 << VCAL_TYPE_PARAM_WAVE;
-
- // set alarm value
- object->pParam->pNext = (VParam*)malloc(sizeof(VParam));
- if ( !object->pParam->pNext)
- {
- vcal_free_vtree_memory( tree );
- if (object != NULL)
- {
- CAL_FREE(object);
- object = NULL;
- }
- return false;
- }
-
- memset(object->pParam->pNext, 0, sizeof(VParam));
-
- object->pParam->pNext->parameter = VCAL_PARAM_VALUE;
- object->pParam->pNext->paramValue = 0x01 << VCAL_VALUE_PARAM_URL;
- */
-
- object->pszValue[0] = (char*)malloc(VCALENDAR_TIME_STR_LEN + 1);
- if ( !(object->pszValue[0]) )
- {
- vcal_free_vtree_memory( tree );
- if (object != NULL)
- {
- free(object);
- object = NULL;
- }
- return false;
- }
- struct tm ttm;
-
- // TODO: handle alarms(this is one alarm)
- struct tm *tm = __cal_vcalendar_compute_pre_time((struct tm*)&sch->start_date_time,
- &tmp_alarm->alarm_time, tmp_alarm->remind_tick, tmp_alarm->remind_tick_unit, &ttm);
- cal_vcalendar_convert_tm_to_vdata_str(tm, object->pszValue[0]);
-
- // set audio reminder file
- /*
- object->pszValue[1] = (char*)malloc(FM_FILENAME_LEN_MAX + 1 );
- if (!(object->pszValue[1]))
- {
- vcal_free_vtree_memory( tree );
- if (object != NULL)
- {
- CAL_FREE(object);
- object = NULL;
- }
- return false;
- }*/
-
- //memset(object->pszValue[1], 0, FM_FILENAME_LEN_MAX + 1);
- //memcpy( object->pszValue[1], sch->alarm_tone, FM_FILENAME_LEN_MAX);
-
- object->valueCount = 1;
- }
- else
- {
- CAL_FREE(object);
-
- return true;
- }
- }
- break;
-
- case VCAL_TYPE_RRULE:
- {
- CALS_DBG( "\n-------------------__cal_vcalendar_sch_vtree_add_object /VCAL_TYPE_RRULE -------------\n");
-
- if (sch->repeat_term != CAL_REPEAT_NONE)
- {
- CALS_DBG(" ------------------------ begine to create RRULE-------------------------- ");
-
- object->property = VCAL_TYPE_RRULE;
-
- char repeat_end_date[VCALENDAR_TIME_STR_LEN + 1] = {0};
- char week_day_string[VCALENDAR_TIME_STR_LEN + 1] = {0};
- cal_vcalendar_convert_tm_to_vdata_str(&sch->repeat_end_date, repeat_end_date);
-
- CALS_DBG(" repeat_end_date = %s ", repeat_end_date);
-
- char str[100];
- memset(str, 0, 100);
-
- switch (sch->repeat_term)
- {
- case CAL_REPEAT_EVERY_DAY:
- sprintf(str, "D%d %s", sch->repeat_interval, repeat_end_date);
- break;
-
- case CAL_REPEAT_EVERY_WEEK:
- case CAL_REPEAT_EVERY_WEEKDAYS:
- __cal_vcalendar_get_week_day_string((struct tm*)&(sch->start_date_time), week_day_string);
- sprintf(str, "W%d %s %s", sch->repeat_interval, week_day_string, repeat_end_date);
- break;
-
- case CAL_REPEAT_EVERY_MONTH:
- case CAL_REPEAT_EVERY_MONTH_DAY:
- sprintf(str, "MD%d %s", sch->repeat_interval, repeat_end_date);
- break;
-
- case CAL_REPEAT_EVERY_YEAR:
- case CAL_REPEAT_EVERY_YEAR_DAY:
- sprintf(str, "YM%d %s", sch->repeat_interval, repeat_end_date);
- break;
-
- default:
- break;
- }
- object->valueCount = 1;
-
- object->pszValue[0] = (char*)malloc(strlen(str) + 1);
- if ( !(object->pszValue[0]) )
- {
- vcal_free_vtree_memory(tree);
- CAL_FREE(object);
-
- return false;
- }
- memset(object->pszValue[0], 0, (strlen(str) + 1));
- strcpy(object->pszValue[0], str);
-
- CALS_DBG("RRULE = %s", object->pszValue[0]);
-
- }
- else
- {
- CAL_FREE(object);
-
- return true;
- }
- }
- break;
-
- case VCAL_TYPE_PRIORITY:
- {
- CALS_DBG( "\n-------------------__cal_vcalendar_todo_vtree_add_object /VCAL_TYPE_PRIORITY -------------\n");
-
- object->property = VCAL_TYPE_PRIORITY;
-
- char str[3];
- memset(str, 0, 3);
-
- sprintf(str, "%d", sch->priority);
-
- object->pszValue[0] = (char*)malloc(3);
- if ( !(object->pszValue[0]) )
- {
- vcal_free_vtree_memory( tree );
- CAL_FREE(object);
-
- return false;
- }
-
- memset(object->pszValue[0], 0, 3);
- strcpy(object->pszValue[0], str);
-
- object->valueCount = 1;
- }
- break;
-
- case VCAL_TYPE_STATUS:
- {
- CALS_DBG( "\n-------------------__cal_vcalendar_todo_vtree_add_object /VCAL_TYPE_STATUS -------------\n");
-
- if(sch->cal_type != CAL_EVENT_TODO_TYPE)
- {
- break;
- }
-
- object->property = VCAL_TYPE_STATUS;
-
- object->pszValue[0] = (char*)malloc(20);
- if ( !(object->pszValue[0]) )
- {
- vcal_free_vtree_memory( tree );
- CAL_FREE(object);
-
- return false;
- }
-
- memset(object->pszValue[0], 0, 20);
-
- switch (sch->task_status)
- {
- case CALS_EVENT_STATUS_TENTATIVE:
- strcpy(object->pszValue[0], "TENTATIVE");
- break;
- case CALS_EVENT_STATUS_CONFIRMED:
- strcpy(object->pszValue[0], "CONFIRMED");
- break;
- case CALS_EVENT_STATUS_CANCELLED:
- strcpy(object->pszValue[0], "CANCELLED");
- break;
- case CALS_TODO_STATUS_NEEDS_ACTION:
- strcpy(object->pszValue[0], "NEEDS-ACTION");
- break;
- case CALS_TODO_STATUS_COMPLETED:
- strcpy(object->pszValue[0], "COMPLETED");
- break;
- case CALS_TODO_STATUS_IN_PROCESS:
- strcpy(object->pszValue[0], "IN-PROCESS");
- break;
- case CALS_TODO_STATUS_CANCELLED:
- strcpy(object->pszValue[0], "CANCELLED");
- break;
- default:
- strcpy(object->pszValue[0], "NEEDS-ACTION");
- break;
- }
-
- object->valueCount = 1;
- break;
- }
-
- default:
- break;
-
- }
-
- // if current is the header of the list
- if (tree->pTop == NULL)
- {
- CALS_DBG( "\n--------tree->pTop = object--------------\n");
- tree->pTop = object;
- }
- else
- {
- tree->pCur->pSibling = object;
- }
-
- // the object is the current object
- tree->pCur = object;
-
-#endif
- return true;
-}
-
-#if 0
- bool
-__cal_vnote_sch_vtree_add_object(VTree * tree, const cal_sch_full_t * sch, vCalType obj_type)
-{
- VObject* object;
-
- assert((tree != NULL) && (sch != NULL));
-
- object = (VObject*)malloc(sizeof(VObject));
- if ( !object )
- {
- VNoteFreeVTreeMemory( tree );
- return false;
- }
-
- memset( object, 0, sizeof(VObject));
-
- switch(obj_type)
- {
- case VNOTE_TYPE_BODY:
- {
- INFO("---__cal_vnote_sch_vtree_add_object /VNOTE_TYPE_BODY -------------\n");
-
-#if 1
- if (strlen(sch->description) != 0)
- {
- object->property = VNOTE_TYPE_BODY;
-
- object->pParam = (VParam*)malloc(sizeof(VParam));
- if ( !object->pParam)
- {
- VNoteFreeVTreeMemory( tree );
- if (object != NULL)
- {
- CAL_FREE(object);
- object = NULL;
- }
- return false;
- }
- memset(object->pParam, 0, sizeof(VParam));
- memcpy( object->pszValue[0], sch->summary, CAL_SCH_SUMMARY_LEN_MAX);
-
-
- // object->pParam->parameter = VNOTE_PARAM_ENCODING;
- // object->pParam->paramValue = 0x01 << VNOTE_ENC_PARAM_QUOTED_PRINTABLE;
-
- // object->pszValue[0] = (char*)malloc(CAL_SCH_DESCRIPTION_LEN_MAX + 1 );
- if ( !(object->pszValue[0]) )
- {
- VNoteFreeVTreeMemory( tree );
- CAL_FREE(object);
-
- return false;
- }
-
- // memset(object->pszValue[0], 0, CAL_SCH_DESCRIPTION_LEN_MAX + 1);
- memcpy( object->pszValue[0], sch->description, CAL_SCH_DESCRIPTION_LEN_MAX);
-
- object->valueCount = 1;
-
- }
- else
- {
- CAL_FREE(object);
-
- return true;
- }
-
-#else
-
- if (NULL != sch->description && strlen(sch->description) != 0)
- {
- object->property = VNOTE_TYPE_BODY;
-
- object->pszValue[0] = (char*)malloc(CAL_SCH_DESCRIPTION_LEN_MAX + 1 );
- if ( !(object->pszValue[0]) )
- {
- VNoteFreeVTreeMemory( tree );
- if (object != NULL)
- {
- CAL_FREE(object);
- object = NULL;
- }
- return false;
- }
-
- if (sch->description)
- {
- memset(object->pszValue[0], 0, CAL_SCH_DESCRIPTION_LEN_MAX + 1);
- memcpy( object->pszValue[0], sch->description, CAL_SCH_DESCRIPTION_LEN_MAX);
- }
- INFO("sch->description = %s\n", sch->description);
-
- object->valueCount = 1;
- }
- else
- {
- if (object != NULL)
- {
- CAL_FREE(object);
- object = NULL;
- }
- return true;
- }
-#endif
-
- }
- break;
-
- case VNOTE_TYPE_LAST_MODIFIED:
- {
- INFO("---__cal_vnote_sch_vtree_add_object /VNOTE_TYPE_LAST_MODIFIED -------------\n");
-
- object->property = VNOTE_TYPE_LAST_MODIFIED;
- object->pszValue[0] = (char*)malloc(VCALENDAR_TIME_STR_LEN + 1);
- if ( !(object->pszValue[0]) )
- {
- VNoteFreeVTreeMemory( tree );
- CAL_FREE(object);
-
- return false;
- }
-
- // get current time
- struct tm now;
-
- now.tm_year = 105;
- now.tm_mon = 2;
- now.tm_mday = 4;
- now.tm_hour = 10;
- now.tm_min = 12;
- now.tm_sec = 34;
-
- cal_vcalendar_convert_tm_to_vdata_str(&now, object->pszValue[0]);
-
- object->valueCount = 1;
- }
- break;
-
- default:
- break;
-
- }
-
- // if current is the header of the list
- if (tree->pTop == NULL)
- {
- INFO( "\n--------tree->pTop = object--------------\n");
- tree->pTop = object;
- }
- else
- {
- tree->pCur->pSibling = object;
- }
-
- // the object is the current object
- tree->pCur = object;
-
- INFO( "\n-------------------exit __cal_vnote_sch_vtree_add_object --------------------\n");
-
- return true;
-}
-
-#endif
-
-bool _cal_convert_sch_to_vcalendar(const cal_sch_full_t *sch_array,
- const int sch_count, char **vcal, cal_vCal_ver_t version)
-{
-#if 1
- int i;
- int j;
-
- VTree *cal_tree = NULL;
- VTree *tmp_tree = NULL;
-
- vCalType obj_type[] =
- {
- VCAL_TYPE_SUMMARY,
- VCAL_TYPE_DESCRIPTION,
- VCAL_TYPE_LOCATION,
- VCAL_TYPE_DTSTART,
- VCAL_TYPE_DTEND,
- VCAL_TYPE_LAST_MODIFIED,
- VCAL_TYPE_ATTACH,
- VCAL_TYPE_CATEGORIES,
- VCAL_TYPE_PRIORITY,
- VCAL_TYPE_STATUS,
- VCAL_TYPE_AALARM,
- VCAL_TYPE_RRULE,
- 0
- };
-
-
- assert((sch_array != NULL) && (vcal != NULL));
-
-
- cal_tree = (VTree*)malloc(sizeof(VTree));
- if ( !cal_tree )
- return false;
-
- memset( cal_tree, 0, sizeof(VTree));
-
- cal_tree->treeType = VCALENDAR;
- cal_tree->pTop = NULL;
- cal_tree->pCur = NULL;
- cal_tree->pNext = NULL;
-
- VTree *tree = cal_tree;
-
- for ( i = 0; i < sch_count; i++)
- {
- tmp_tree = (VTree*)malloc(sizeof(VTree));
- if ( !tmp_tree )
- {
- vcal_free_vtree_memory( cal_tree );
- return false;
- }
-
- memset( tmp_tree, 0, sizeof(VTree));
-
- if((sch_array + i)->cal_type == CAL_EVENT_TODO_TYPE){
- tmp_tree->treeType = VTODO;
- obj_type[4]=VCAL_TYPE_DUE;
- }
- else
- {
- tmp_tree->treeType = VEVENT;
- }
-
- tmp_tree->pTop = NULL;
- tmp_tree->pCur = NULL;
- tmp_tree->pNext = NULL;
-
- j=0;
- while (obj_type[j])
- {
- if ( !__cal_vcalendar_sch_vtree_add_object(tmp_tree, sch_array + i, obj_type[j]) )
- {
- vcal_free_vtree_memory(cal_tree);
- return false;
- }
- j++;
- }
-
- tree->pNext = tmp_tree;
- tree = tmp_tree;
-
- }
-
- tree->pNext = NULL;
-
- *vcal = vcal_encode( cal_tree );
- if ( *vcal == NULL )
- {
- ERR("vcal_encode Failed");
- vcal_free_vtree_memory( cal_tree );
- return false;
- }
-
- vcal_free_vtree_memory( cal_tree );
- CALS_DBG( "\n---------------------------exit _cal_convert_sch_to_vcalendar--------- -------------\n");
-#endif
- return true;
-}
-
- bool
-_cal_convert_vcalendar_to_cal_data(const char *vcal, cal_sch_full_t **sch_array, int *sch_count)
-{
- VTree* vCal = NULL;
- VTree* tmp_tree = NULL;
- VObject* object = NULL;
- int error_code = 0;
- bool start_date_exist = false;
- char* pszAlarmValue = NULL;
- bool is_ical = false;
-
- assert((vcal != NULL) && (sch_array != NULL));
-
- /* decode VCalendar */
- vCal = vcal_decode ( (char*)vcal );
- if ( vCal == NULL )
- {
- ERR( "vcal_decode() Failed");
- return false;
- }
-
- tmp_tree = vCal;
- int i = 0;
-
- *sch_array = malloc(sizeof(cal_sch_full_t));
- if(NULL == *sch_array)
- {
- ERR("malloc() Failed");
- return FALSE;
- }
-
- error_code = cals_init_full_record(*sch_array);
-
- while(tmp_tree != NULL )
- {
-
- char buff[MAX_BUFFER_SIZE];
- if (i > 0)
- {
- *sch_array = realloc(*sch_array, sizeof(cal_sch_full_t) * (i + 1));
- if(NULL == *sch_array)
- {
- ERR("realloc() Failed");
- return false;
- }
- error_code = cals_init_full_record(*sch_array + i);
- }
-
- memset(buff, 0, MAX_BUFFER_SIZE);
-
- if (tmp_tree->treeType == VTODO)
- {
- ((*sch_array) + i)->cal_type = CAL_EVENT_TODO_TYPE;
- }
- else if (tmp_tree->treeType == VEVENT)
- {
- ((*sch_array) + i)->cal_type = CAL_EVENT_SCHEDULE_TYPE;
- }
- /*
- else if ((tmp_tree->treeType == STANDARD) || (tmp_tree->treeType == DAYLIGHT))
- {
- object = tmp_tree->pTop;
- while (true)
- {
- if (object->property == VCAL_TYPE_TZOFFSETFROM)
- {
- ((*sch_array) + i)->timezone = __cal_vcalendar_get_timezone(object->pszValue[0], (char**)timezoneoffset, 33);
- }
-
- if ( object->pSibling != NULL )
- {
- object = object->pSibling;
- }
- else
- {
- break;
- }
- }
- tmp_tree = tmp_tree->pNext;
-
- continue;
- }*/
- else if (tmp_tree->treeType == VCALENDAR)
- {
- object = tmp_tree->pTop;
- while (true)
- {
- if (object->property == VCAL_TYPE_VERSION)
- {
- if (strcmp(object->pszValue[0], "2.0") == 0)
- {
- is_ical = true;
- }
- }
-
- if ( object->pSibling != NULL )
- {
- object = object->pSibling;
- }
- else
- {
- break;
- }
- }
- tmp_tree = tmp_tree->pNext;
-
- continue;
- }
- else
- {
- tmp_tree = tmp_tree->pNext;
- continue;
- }
-
- // initialize a sch
- ((*sch_array) + i)->start_date_time.tm_year = 71;
- ((*sch_array) + i)->start_date_time.tm_mon = 1;
- ((*sch_array) + i)->start_date_time.tm_mday = 1;
- ((*sch_array) + i)->start_date_time.tm_hour = 0;
- ((*sch_array) + i)->start_date_time.tm_min = 0;
- ((*sch_array) + i)->start_date_time.tm_sec = 0;
-
- ((*sch_array) + i)->end_date_time.tm_year = 71;
- ((*sch_array) + i)->end_date_time.tm_mon = 1;
- ((*sch_array) + i)->end_date_time.tm_mday = 1;
- ((*sch_array) + i)->end_date_time.tm_hour = 0;
- ((*sch_array) + i)->end_date_time.tm_min = 0;
- ((*sch_array) + i)->end_date_time.tm_sec = 0;
-
- ((*sch_array) + i)->repeat_end_date.tm_year = 137;
- ((*sch_array) + i)->repeat_end_date.tm_mon = 11;
- ((*sch_array) + i)->repeat_end_date.tm_mday = 31;
- ((*sch_array) + i)->repeat_end_date.tm_hour = 23;
- ((*sch_array) + i)->repeat_end_date.tm_min = 59;
- ((*sch_array) + i)->repeat_end_date.tm_sec = 59;
-
- (*sch_array + i)->sch_category = CAL_SCH_APPOINTMENT;
-
- object = tmp_tree->pTop;
-
- // read vcalendar and fill sch structure
- while (true)
- {
- CALS_DBG(" \nproperty=%d \n",object->property);
-
- switch (object->property)
- {
- case VCAL_TYPE_CATEGORIES:
-
- //(*sch_array + i)->cal_type = CAL_EVENT_SCHEDULE_TYPE;
-
- CALS_DBG("sch_category = %s", object->pszValue[0]);
-
- if (strcmp(object->pszValue[0], "APPOINTMENT") == 0)
- {
- (*sch_array + i)->sch_category = CAL_SCH_APPOINTMENT;
-
- }
- else if (strcmp(object->pszValue[0], "HOLIDAY") == 0)
- {
- (*sch_array + i)->sch_category = CAL_SCH_HOLIDAY;
-
- }
- else if (strcmp(object->pszValue[0], "BUSINESS") == 0)
- {
- (*sch_array + i)->sch_category = CAL_SCH_BUSSINESS;
-
- }
- else if (strcmp(object->pszValue[0], "SPECIAL OCCASION") == 0)
- {
- (*sch_array + i)->sch_category = CAL_SCH_SPECIAL_OCCASION;
-
- }
- else if (strcmp(object->pszValue[0], "IMPORTANT") == 0)
- {
- (*sch_array + i)->sch_category = CAL_SCH_IMPORTANT;
-
- }
- else if (strcmp(object->pszValue[0], "BIRTHDAY") == 0)
- {
- (*sch_array + i)->sch_category = CAL_SCH_BIRTHDAY;
-
- }
-
- else if (strcmp(object->pszValue[0], "MISCELLANEOUS") == 0)
- {
- (*sch_array + i)->sch_category = CAL_SCH_APPOINTMENT;
-
- }
- else
- {
- (*sch_array + i)->sch_category = CAL_SCH_APPOINTMENT;
-
- }
-
- break;
-
- case VCAL_TYPE_SUMMARY:
- (*sch_array + i)->summary = strdup(object->pszValue[0]);
- // memcpy((*sch_array + i)->summary, object->pszValue[0], CAL_SCH_SUMMARY_LEN_MAX);
- break;
- case VCAL_TYPE_DESCRIPTION:
- (*sch_array + i)->description = strdup(object->pszValue[0]);
- //memcpy( (*sch_array + i)->description, object->pszValue[0], CAL_SCH_DESCRIPTION_LEN_MAX);
- break;
- case VCAL_TYPE_LOCATION:
- (*sch_array + i)->location = strdup(object->pszValue[0]);
- // memcpy( (*sch_array + i)->location, object->pszValue[0], CAL_SCH_LOCATION_LEN_MAX);
- break;
-
- /* case VCAL_TYPE_ATTACH:
- memcpy( (*sch_array + i)->attach_path, object->pszValue[0], FM_FILENAME_LEN_MAX);
- break;*/
-
- case VCAL_TYPE_DTSTART:
- cal_vcalendar_convert_utc_str_to_tm(object->pszValue[0], &(*sch_array + i)->start_date_time);
- start_date_exist = true;
- break;
- case VCAL_TYPE_DTEND:
- cal_vcalendar_convert_utc_str_to_tm(object->pszValue[0], &(*sch_array + i)->end_date_time);
- break;
- case VCAL_TYPE_CREATED:
- cal_vcalendar_convert_utc_str_to_tm(object->pszValue[0], &(*sch_array + i)->created_date_time);
- break;
- case VCAL_TYPE_COMPLETED:
- cal_vcalendar_convert_utc_str_to_tm(object->pszValue[0], &(*sch_array + i)->completed_date_time);
- break;
- case VCAL_TYPE_DUE:
- cal_vcalendar_convert_utc_str_to_tm(object->pszValue[0], &(*sch_array + i)->end_date_time);
- break;
- case VCAL_TYPE_LAST_MODIFIED:
- cal_vcalendar_convert_utc_str_to_tm(object->pszValue[0], &(*sch_array + i)->last_modified_time);
-
- break;
- case VCAL_TYPE_RRULE:
- CALS_DBG( " \n---------------------VCAL_TYPE_RRULE is_ical is %d-------------------- \n",is_ical);
-
- // Calendar sch structure has no repeat interval field, discard it
- struct tm tm;
- tm.tm_year = 137;
- tm.tm_mon = 11;
- tm.tm_mday = 31;
- tm.tm_hour = 23;
- tm.tm_min = 59;
- tm.tm_sec = 59;
- int count = -1;
-
- if(is_ical)
- {
- __cal_vcalendar_parse_sch_repeat_rule_for_ical(object,&(*sch_array + i)->repeat_term, &(*sch_array + i)->repeat_interval, &tm);
- }
- else
- {
- __cal_vcalendar_parse_sch_repeat_rule( object->pszValue[0], &(*sch_array + i)->repeat_term, &(*sch_array + i)->repeat_interval, &tm,&count);
- }
-
- if(count != -1)
- {
- (*sch_array + i)->repeat_occurrences = count;
- }
-
- ((*sch_array + i)->repeat_end_date).tm_year = tm.tm_year;
- ((*sch_array + i)->repeat_end_date).tm_mon = tm.tm_mon;
- ((*sch_array + i)->repeat_end_date).tm_mday = tm.tm_mday;
- ((*sch_array + i)->repeat_end_date).tm_hour = ((*sch_array + i)->end_date_time).tm_hour;
- ((*sch_array + i)->repeat_end_date).tm_min = ((*sch_array + i)->end_date_time).tm_min;
- ((*sch_array + i)->repeat_end_date).tm_sec = ((*sch_array + i)->end_date_time).tm_sec;
-
- if (((*sch_array + i)->repeat_term == CAL_REPEAT_EVERY_WEEK) || ((*sch_array + i)->repeat_term == CAL_REPEAT_EVERY_WEEKDAYS))
- {
- (*sch_array + i)->week_flag = malloc(sizeof(char) * (DAY_OF_A_WEEK+1));
- memset((*sch_array + i)->week_flag,0x00,sizeof(char) * (DAY_OF_A_WEEK+1));
- cal_db_service_set_sch_weekflag(&((*sch_array + i)->start_date_time), (*sch_array + i)->week_flag);
- }
- CALS_DBG( " \n repeat_end_date->year = %d\n", ((*sch_array + i)->repeat_end_date).tm_year);
- CALS_DBG( " \n repeat_end_date->mon = %d\n", ((*sch_array + i)->repeat_end_date).tm_mon);
- CALS_DBG( " \n repeat_end_date->mday = %d\n", ((*sch_array + i)->repeat_end_date).tm_mday);
-
- break;
-
- // Note: Before decode AALARM, decode START_DATE_TIME first!
- case VCAL_TYPE_AALARM:
- CALS_DBG( " \n---------------------VCAL_TYPE_AALARM-------------------- \n");
- pszAlarmValue = object->pszValue[0];
- //__cal_vcalendar_parse_reminder_time(object->pszValue[0], &(*sch_array + i)->start_date_time, &(*sch_array + i)->remind_tick, &(*sch_array + i)->remind_tick_unit);
-
- /*if (object->pszValue[1] != NULL)
- {
- strncpy((*sch_array + i)->alarm_tone, object->pszValue[1], FM_FILENAME_LEN_MAX);
- }*/
- break;
-
- // sch data structure has no priority and status fields
- case VCAL_TYPE_PRIORITY:
- CALS_DBG( " \n---------------------VCAL_TYPE_PRIORITY-------------------- \n");
- if (object->pszValue[0] != NULL)
- {
-
- int prio = atoi(object->pszValue[0]);
- if ((prio < 3) && (prio >= 0))
- {
- (*sch_array + i)->priority = prio;
- }
- else
- {
- // INFO( " \n---------------------VCAL_TYPE_PRIORITY-HHHHHHHHH------------------- \n");
-
- (*sch_array + i)->priority = CAL_PRIORITY_HIGH;
- }
-
- }
-
- break;
-
- case VCAL_TYPE_STATUS:
- CALS_DBG( " \n---------------------VCAL_TYPE_STATUS-------------------- \n");
-
- if ( object->pszValue[0] != NULL)
- {
- if (CAL_EVENT_TODO_TYPE == (*sch_array + i)->cal_type) {
- if (strcmp(object->pszValue[0], "NEEDS-ACTION") == 0)
- (*sch_array + i)->task_status = CALS_TODO_STATUS_NEEDS_ACTION;
- else if (strcmp(object->pszValue[0], "COMPLETED") == 0)
- (*sch_array + i)->task_status = CALS_TODO_STATUS_COMPLETED;
- else if (strcmp(object->pszValue[0], "IN-PROCESS") == 0)
- (*sch_array + i)->task_status = CALS_TODO_STATUS_IN_PROCESS;
- else if (strcmp(object->pszValue[0], "CANCELLED") == 0)
- (*sch_array + i)->task_status = CALS_TODO_STATUS_CANCELLED;
- else
- (*sch_array + i)->task_status = CALS_STATUS_NONE;
- } else if (CAL_EVENT_SCHEDULE_TYPE == (*sch_array + i)->cal_type) {
- if (strcmp(object->pszValue[0], "TENTATIVE") == 0)
- (*sch_array + i)->task_status = CALS_EVENT_STATUS_TENTATIVE;
- else if (strcmp(object->pszValue[0], "CONFIRMED") == 0)
- (*sch_array + i)->task_status = CALS_EVENT_STATUS_CONFIRMED;
- else if (strcmp(object->pszValue[0], "CANCELLED") == 0)
- (*sch_array + i)->task_status = CALS_EVENT_STATUS_CANCELLED;
- else
- (*sch_array + i)->task_status = CALS_STATUS_NONE;
- }
- }
- break;
-
- default:
- break;
-
- }
-
- if ( object->pSibling != NULL )
- {
- object = object->pSibling;
- }
- else
- {
- break;
- }
- } /* while */
-
- if(false == start_date_exist)
- {
- memcpy(&(*sch_array + i)->start_date_time,&(*sch_array + i)->start_date_time,sizeof(struct tm));
- }
-
-
- if(((*sch_array + i)->start_date_time.tm_hour==0) && ((*sch_array + i)->start_date_time.tm_min==0) &&
- ((*sch_array + i)->start_date_time.tm_sec==0) && ((*sch_array + i)->end_date_time.tm_hour==0) &&
- ((*sch_array + i)->end_date_time.tm_min==0) && ((*sch_array + i)->end_date_time.tm_sec==0))
- {
- (*sch_array + i)->all_day_event = true;
- }
-
- if(pszAlarmValue && pszAlarmValue[0] != '\0')
- {
- cal_alarm_info_t *alarm;
- cal_value *val;
-
- val = calendar_svc_value_new(CAL_VALUE_LST_ALARM); // Alarm value create
-
- alarm = (cal_alarm_info_t *)val->user_data;
- __cal_vcalendar_parse_reminder_time(pszAlarmValue, (*sch_array + i)->sch_category,
- &(*sch_array + i)->start_date_time, &alarm->remind_tick, &alarm->remind_tick_unit);
- cal_vcalendar_convert_utc_str_to_tm(pszAlarmValue, &alarm->alarm_time);
-
- if (((*sch_array + i)->sch_category == CAL_SCH_SPECIAL_OCCASION) ||
- ((*sch_array + i)->sch_category == CAL_SCH_BIRTHDAY)) {
- alarm->alarm_time.tm_year = (*sch_array + i)->start_date_time.tm_year;
- alarm->alarm_time.tm_mon = (*sch_array + i)->start_date_time.tm_mon;
- alarm->alarm_time.tm_mday = (*sch_array + i)->start_date_time.tm_mday;
- } else {
- cal_db_service_copy_struct_tm(&((*sch_array + i)->start_date_time), &alarm->alarm_time);
- }
-
- (*sch_array + i)->alarm_list = g_list_append((*sch_array + i)->alarm_list, val);
-
- CALS_DBG( "remind_tick = %d", alarm->remind_tick);
- CALS_DBG( "remind_tick_unit = %d", alarm->remind_tick_unit);
- pszAlarmValue = NULL;
- }
-
- /* int len = strlen((*sch_array + i)->description);
-
- strncat((*sch_array + i)->description, buff, CAL_SCH_DESCRIPTION_LEN_MAX - len -10);*/
-
- tmp_tree = tmp_tree->pNext;
-
- i++;
- }
-
- *sch_count = i;
-
- /* Free VCalendar Tree */
- vcal_free_vtree_memory( vCal );
- return true;
-}
+++ /dev/null
-/*
- * Calendar Service
- *
- * Copyright (c) 2000 - 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 __CALENDAR_SVC_ICAL_CODEC_H__
-#define __CALENDAR_SVC_ICAL_CODEC_H__
-
-#define CR 0x0d
-#define LF 0x0a
-#define TAB 0x09
-#define WSP 0x20
-#define UNKNOWN_NAME 0x80000000
-
-#define VCALENDAR 0x02
-#define VNOTE 0x0b
-
-#define VEVENT 0x03
-#define VTODO 0x04
-#define VJOURNAL 0x05
-#define VFREEBUSY 0x06
-#define VTIMEZONE 0x07
-#define VALARM 0x08
-#define VMESSAGE 0x0c
-#define VBODY 0X0d
-#define STANDARD 0x09
-#define DAYLIGHT 0x0a
-
-#define VTYPE_TOKEN_SEMICOLON ';'
-#define VTYPE_TOKEN_COLON ':'
-#define VTYPE_TOKEN_EQUAL '='
-#define VTYPE_TOKEN_COMMA ','
-#define VTYPE_TOKEN_DOT '.'
-#define VTYPE_TOKEN_QUOTE '\''
-#define VTYPE_TOKEN_DBLQUOTE '"'
-
-#define VDATA_VALUE_COUNT_MAX 2000
-
-/****************************************************************************************************/
-/* ENUMERATION DECLARATION */
-/****************************************************************************************************/
-/* Property */
-typedef enum
-{
- VCAL_TYPE_AALARM,
- VCAL_TYPE_ACTION,
- VCAL_TYPE_ATTACH,
- VCAL_TYPE_ATTENDEE,
- VCAL_TYPE_BEGIN,
- VCAL_TYPE_CALSCALE,
- VCAL_TYPE_CATEGORIES,
- VCAL_TYPE_CLASS,
- VCAL_TYPE_COMMENT,
- VCAL_TYPE_COMPLETED,
- VCAL_TYPE_CONTACT,
- VCAL_TYPE_CREATED,
- VCAL_TYPE_DALARM,
- VCAL_TYPE_DAYLIGHT,
- VCAL_TYPE_DCREATED,
- VCAL_TYPE_DESCRIPTION,
- VCAL_TYPE_DTEND,
- VCAL_TYPE_DTSTAMP,
- VCAL_TYPE_DTSTART,
- VCAL_TYPE_DUE,
- VCAL_TYPE_DURATION,
- VCAL_TYPE_END,
- VCAL_TYPE_EXDATE,
- VCAL_TYPE_EXRULE,
- VCAL_TYPE_FREEBUSY,
- VCAL_TYPE_GEO,
- VCAL_TYPE_LAST_MODIFIED,
- VCAL_TYPE_LOCATION,
- VCAL_TYPE_MALARM,
- VCAL_TYPE_METHOD,
- VCAL_TYPE_ORGANIZER,
- VCAL_TYPE_PALARM,
- VCAL_TYPE_PERCENT_COMPLETE,
- VCAL_TYPE_PRIORITY,
- VCAL_TYPE_PRODID,
- VCAL_TYPE_RDATE,
- VCAL_TYPE_RECURRENCE_ID,
- VCAL_TYPE_RELATED_TO,
- VCAL_TYPE_REPEAT,
- VCAL_TYPE_REQUEST_STATUS,
- VCAL_TYPE_RESOURCES,
- VCAL_TYPE_RNUM,
- VCAL_TYPE_RRULE,
- VCAL_TYPE_SEQUENCE,
- VCAL_TYPE_STANDARD,
- VCAL_TYPE_STATUS,
- VCAL_TYPE_SUMMARY,
- VCAL_TYPE_TRANSP,
- VCAL_TYPE_TRIGGER,
- VCAL_TYPE_TZ,
- VCAL_TYPE_TZID,
- VCAL_TYPE_TZNAME,
- VCAL_TYPE_TZOFFSETFROM,
- VCAL_TYPE_TZOFFSETTO,
- VCAL_TYPE_TZURL,
- VCAL_TYPE_URL,
- VCAL_TYPE_UID,
- VCAL_TYPE_VALARM,
- VCAL_TYPE_VCALENDAR,
- VCAL_TYPE_VERSION,
- VCAL_TYPE_VEVENT,
- VCAL_TYPE_VFREEBUSY,
- VCAL_TYPE_VJOURNAL,
- VCAL_TYPE_VTIMEZONE,
- VCAL_TYPE_VTODO,
- VCAL_TYPE_ALLDAY
-}vCalType;
-
-#define VCAL_TYPE_NUM 66
-
-/* Parameter */
-typedef enum
-{
- VCAL_PARAM_ALTREP,
- VCAL_PARAM_CHARSET,
- VCAL_PARAM_CN,
- VCAL_PARAM_CONTEXT,
- VCAL_PARAM_CUTYPE,
- VCAL_PARAM_DELEGATED_FROM,
- VCAL_PARAM_DELEGATED_TO,
- VCAL_PARAM_DIR,
- VCAL_PARAM_ENCODING,
- VCAL_PARAM_EXPECT,
- VCAL_PARAM_FBTYPE,
- VCAL_PARAM_FMTYPE,
- VCAL_PARAM_LANGUAGE,
- VCAL_PARAM_MEMBER,
- VCAL_PARAM_PARTSTAT,
- VCAL_PARAM_RANGE,
- VCAL_PARAM_RELATED,
- VCAL_PARAM_RELTYPE,
- VCAL_PARAM_ROLE,
- VCAL_PARAM_RSVP,
- VCAL_PARAM_SENT_BY,
- VCAL_PARAM_STATUS,
- VCAL_PARAM_TYPE,
- VCAL_PARAM_TZID,
- VCAL_PARAM_VALUE
-}vCalendarParamName;
-
-#define VCAL_PARAM_NUM 25
-
-/* Cu type value */
-typedef enum
-{
- VCAL_CUTYPE_PARAM_GROUP,
- VCAL_CUTYPE_PARAM_INDIVIDUAL,
- VCAL_CUTYPE_PARAM_RESOURCE,
- VCAL_CUTYPE_PARAM_ROOM,
- VCAL_CUTYPE_PARAM_UNKNOWN
-} vCalCutypeVal;
-
-#define VCAL_CUTYPE_PARAM_NUM 5
-
-/* Parameter encoding value */
-typedef enum
-{
- VCAL_ENC_PARAM_B,
- VCAL_ENC_PARAM_BASE64,
- VCAL_ENC_PARAM_QUOTED_PRINTABLE,
- VCAL_ENC_PARAM_7BIT,
- VCAL_ENC_PARAM_8BIT
-}vCalEncVal;
-
-#define VCAL_ENCODE_PARAM_NUM 5
-
-/* Fb Type value */
-typedef enum
-{
- VCAL_FBTYPE_PARAM_BUSY,
- VCAL_FBTYPE_PARAM_BUSY_TENTATIVE,
- VCAL_FBTYPE_PARAM_BUSY_UNAVAILABLE,
- VCAL_FBTYPE_PARAM_FREE
-} vCalFbtypeVal;
-
-#define VCAL_FBTYPE_PARAM_NUM 4
-
-/* Partstat value */
-typedef enum
-{
- VCAL_PARTSTAT_PARAM_ACCEPTED,
- VCAL_PARTSTAT_PARAM_COMPLETED,
- VCAL_PARTSTAT_PARAM_DELEGATED,
- VCAL_PARTSTAT_PARAM_DECLINED,
- VCAL_PARTSTAT_PARAM_IN_PROCESS,
- VCAL_PARTSTAT_PARAM_NEED_ACTION,
- VCAL_PARTSTAT_PARAM_TENTATIVE
-} vCalPartstatVal;
-
-#define VCAL_PARTSTAT_PARAM_NUM 7
-
-/* Range value */
-typedef enum
-{
- VCAL_RANGE_PARAM_THISANDFUTURE,
- VCAL_RANGE_PARAM_THISANDPRIOR
-} vCalRangeVal;
-
-#define VCAL_RANGE_PARAM_NUM 2
-
-/* Related value */
-typedef enum
-{
- VCAL_RELATED_PARAM_END,
- VCAL_RELATED_PARAM_START
-} vCalRelatedVal;
-
-#define VCAL_RELATED_PARAM_NUM 2
-
-/* Rel type value */
-typedef enum
-{
- VCAL_RELTYPE_PARAM_CHILD,
- VCAL_RELTYPE_PARAM_PARENT,
- VCAL_RELTYPE_PARAM_SIBLING
-} vCalReltypeVal;
-
-#define VCAL_RELTYPE_PARAM_NUM 3
-
-/* Value value */
-typedef enum
-{
- VCAL_VALUE_PARAM_BINARY,
- VCAL_VALUE_PARAM_BOOLEAN,
- VCAL_VALUE_PARAM_CAL_ADDRESS,
- VCAL_VALUE_PARAM_CID,
- VCAL_VALUE_PARAM_CONTENT_ID,
- VCAL_VALUE_PARAM_DATE,
- VCAL_VALUE_PARAM_DATE_TIME,
- VCAL_VALUE_PARAM_DURATION,
- VCAL_VALUE_PARAM_FLOAT,
- VCAL_VALUE_PARAM_INTEGER,
- VCAL_VALUE_PARAM_PERIOD,
- VCAL_VALUE_PARAM_PHONE_NUMBER,
- VCAL_VALUE_PARAM_RECUR,
- VCAL_VALUE_PARAM_TEXT,
- VCAL_VALUE_PARAM_TIME,
- VCAL_VALUE_PARAM_URI,
- VCAL_VALUE_PARAM_URL,
- VCAL_VALUE_PARAM_UTC_OFFSET,
- VCAL_VALUE_PARAM_VCALENDAR,
- VCAL_VALUE_PARAM_VEVENT,
- VCAL_VALUE_PARAM_VTODO
-}vCalValVal;
-
-#define VCAL_VALUE_PARAM_NUM 21
-
-/* Parameter type value */
-typedef enum
-{
- VCAL_TYPE_PARAM_AIFF,
- VCAL_TYPE_PARAM_BBS,
- VCAL_TYPE_PARAM_CAR,
- VCAL_TYPE_PARAM_CELL,
- VCAL_TYPE_PARAM_DOM,
- VCAL_TYPE_PARAM_FAX,
- VCAL_TYPE_PARAM_GIF,
- VCAL_TYPE_PARAM_HOME,
- VCAL_TYPE_PARAM_INTL,
- VCAL_TYPE_PARAM_INTERNET,
- VCAL_TYPE_PARAM_ISDN,
- VCAL_TYPE_PARAM_JPEG,
- VCAL_TYPE_PARAM_MODEM,
- VCAL_TYPE_PARAM_MSG,
- VCAL_TYPE_PARAM_PAGER,
- VCAL_TYPE_PARAM_PARCEL,
- VCAL_TYPE_PARAM_PCM,
- VCAL_TYPE_PARAM_PCS,
- VCAL_TYPE_PARAM_PNG,
- VCAL_TYPE_PARAM_POSTAL,
- VCAL_TYPE_PARAM_PREF,
- VCAL_TYPE_PARAM_VCARD,
- VCAL_TYPE_PARAM_VIDEO,
- VCAL_TYPE_PARAM_VOICE,
- VCAL_TYPE_PARAM_WAVE,
- VCAL_TYPE_PARAM_WBMP,
- VCAL_TYPE_PARAM_WORK,
- VCAL_TYPE_PARAM_X400
-}vCalTypeVal;
-
-#define VCAL_TYPE_PARAM_NUM 28
-
-/* Parameter expect value */
-typedef enum
-{
- VCAL_EXPECT_PARAM_FYI,
- VCAL_EXPECT_PARAM_IMMEDIATE,
- VCAL_EXPECT_PARAM_REQUEST,
- VCAL_EXPECT_PARAM_REQUIRE
-}vCalExpectVal;
-
-#define VCAL_EXPECT_PARAM_NUM 4
-
-/* Parameter role value */
-typedef enum
-{
- VCAL_ROLE_PARAM_ATTENDEE,
- VCAL_ROLE_PARAM_CHAIR,
- VCAL_ROLE_PARAM_DELEGATE,
- VCAL_ROLE_PARAM_NON_PARTICIPANT,
- VCAL_ROLE_PARAM_OPT_PARTICIPANT,
- VCAL_ROLE_PARAM_ORGANIZER,
- VCAL_ROLE_PARAM_OWNER,
- VCAL_ROLE_PARAM_REQ_PARTICIPANT
-}vCalRoleVal;
-
-#define VCAL_ROLE_PARAM_NUM 8
-
-/* Parameter RSVP value */
-typedef enum
-{
- VCAL_RSVP_PARAM_FALSE,
- VCAL_RSVP_PARAM_NO,
- VCAL_RSVP_PARAM_TRUE,
- VCAL_RSVP_PARAM_YES
-}vCalRsvpVal;
-
-#define VCAL_RSVP_PARAM_NUM 4
-
-/* Parameter Charset value */
-typedef enum
-{
- VCAL_CHARSET_PARAM_UTF_8,
- VCAL_CHARSET_PARAM_UTF_16,
- VCAL_CHARSET_PARAM_SHIFT_JIS
-}vCalCharsetVal;
-
-#define VCAL_CHARSET_PARAM_NUM 2
-
-/* Parameter STATUS value */
-typedef enum
-{
- VCAL_STATUS_PARAM_ACCEPTED,
- VCAL_STATUS_PARAM_COMPLETED,
- VCAL_STATUS_PARAM_CONFIRMED,
- VCAL_STATUS_PARAM_DECLINED,
- VCAL_STATUS_PARAM_DELEGATED,
- VCAL_STATUS_PARAM_NEEDS_ACTION,
- VCAL_STATUS_PARAM_SENT,
- VCAL_STATUS_PARAM_TENTATIVE
-}vCalStatusVal;
-
-#define VCAL_STATUS_PARAM_NUM 8
-
-
-/* VCalendar encoder/decoder status */
-#define VCAL_TYPE_NAME_STATUS 1
-#define VCAL_PARAM_NAME_STATUS 2
-#define VCAL_TYPE_VALUE_STATUS 3
-#define VCAL_PARAM_VALUE_STATUS 4
-
-
-/****************************************************************************************************/
-/* GLOBAL STRUCTURE DECLARATION */
-/****************************************************************************************************/
-
-typedef struct _VParam VParam;
-typedef struct _VObject VObject;
-typedef struct _ValueObj ValueObj;
-typedef struct _VTree VTree;
-
-struct _VTree
-{
- int treeType;
- VObject* pTop;
- VObject* pCur;
- VTree* pNext;
-};
-
-struct _VParam
-{
- int parameter;
- int paramValue;
- VParam* pNext;
-};
-
-struct _VObject
-{
- int property;
- VParam* pParam;
- int valueCount;
- int numOfBiData;
- char* pszValue[VDATA_VALUE_COUNT_MAX];
- VObject* pSibling;
- VObject* pParent;
- VObject* pChild;
-
- char* pszGroupName; //VDATA_GROUPNAME_SUPPORTED
-};
-
-struct _ValueObj
-{
- char* szName;
- int flag;
-};
-
-
-#define FEATURE_SHIFT_JIS
-
-/****************************************************************************************************/
-/* FUNCTION DECLARATION */
-/****************************************************************************************************/
-int _VIsSpace( char );
-int _VRLSpace( char * );
-int _VRTSpace( char * );
-int _VUnescape( char *);
-int _VEscape(char*);
-int _VManySpace2Space( char * );
-int _VB64Decode( char *, char * );
-int _VB64Encode( char *, char *, int );
-int _VUnfolding( char * );
-void _VFolding( char *, char * );
-int _VQPDecode( char * );
-int _VQPEncode( char *, char * );
-
-void _VFoldingQP( char *result, char *contentline );
-void _VFoldingNoSpace( char *result, char *contentline );
-int _VManyCRLF2CRLF(char *pIn);
-int _VUnfoldingNoSpec( char *string, int vType );
-
-
-/**
-* @fn VTree* vcal_decode(char* pVCalRaw);
-* This function decodes a vCalendar raw buffer
-* @return This function returns a pointer to VTree.
-* @param[in] pVCalRaw Points to the vCalendar raw buffers.
-* @see vcal_encode
-*/
-
-VTree* vcal_decode(char *pVCalRaw);
-
-/**
-* @fn char* vcal_encode(VTree* pVTree);
-* This function encodes a vTree data to vCalendar buffer
-* @return This function returns a pointer to vCalendar buffer.
-* @param[in] pVTree Points to vTree data.
-* @see vcal_decode
-*/
-
-char *vcal_encode(VTree* pVTree);
-
-/**
-* @fn bool vcal_free_vtree_memory( VTree* pTree );
-* This function free vTree memory
-* @return This function returns true if success and false if failuer.
-* @param[in] pTree Points to a vTree data.
-* @see vcal_decode
-*/
-
-bool vcal_free_vtree_memory( VTree* pTree );
-
-bool _cal_convert_sch_to_vcalendar(const cal_sch_full_t *sch_array, const int sch_count, char** vcal, cal_vCal_ver_t version );
-
-bool _cal_convert_vcalendar_to_cal_data(const char *vcal, cal_sch_full_t **sch_array, int *sch_count);
-
-
-#endif /* __CALENDAR_SVC_ICAL_CODEC_H__ */
+++ /dev/null
-/*
- * Calendar Service
- *
- * Copyright (c) 2000 - 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.
- *
- */
-#include <glib.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "cals-typedef.h"
-#include "cals-ical-codec.h"
-
-#define VCARD_TYPE_NUM 34
-#define VCAL_TYPE_NUM 66
-#define VMSG_TYPE_NUM 12
-
-/* BASE64 TABLE */
-static const char Base64Table[65] = { 'A',
- 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
- 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
- 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e',
- 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
- 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y',
- 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8',
- '9', '+', '/', '='
-};
-
-/* Function Declaration */
-static int __VFindBase64( char );
-static int __VBase64Check( char * );
-static char __VHexaDecoder( char * );
-static void __VHexaEncoder( char * );
-static int __VIsPrintable( char );
-
-
-/**
- * vCardIsSpace() returns one if char is either a space, tab, or newline.
- *
- * @param s1 [in] pointer to first string.
- * @param s2 [in] pointer to second string.
- * @return 1 'in' is a space character.
- * @return 0 'in' is not a space.
- */
- int
-_VIsSpace( char in )
-{
- //DLOG( "_VIsSpace() enter..\n");
-
- if ( ( in == TAB ) || ( in == WSP ) )
- {
- return 1;
- }
- else
- {
- return 0;
- }
-}
-
-
-/*
- * vRemLeadSpace() removes leading space in string 'in'.
- *
- * @param in [inout] pointer to string.
- * @return 0 if success.
- */
- int
-_VRLSpace( char *in )
-{
- int i, j;
- short int done;
-
- //DLOG( "_VRLSpace() enter..\n");
-
- i = 0;
- done = 0;
-
- while ( !done && in[i] )
- {
- if ( _VIsSpace( in[i] ) )
- {
- i++;
- }
- else
- {
- done = 1;
- }
- }
-
- j = 0;
- while ( in[i] )
- {
- in[j++] = in[i++];
- }
-
- in[j] = '\0';
-
- return 0;
-}
-
-
-/*
- * vRemTermSpace() removes terminating space.
- *
- * @param in [inout] pointer to string.
- * @return 0 if success.
- */
- int
-_VRTSpace( char *in )
-{
- int i;
- short int done;
-
- //DLOG( "_VRTSpace() enter..\n");
-
- i = strlen(in) - 1;
- done = 0;
-
- while ( !done && !( i < 0 ) )
- {
- if ( _VIsSpace( in[i] ) )
- {
- in[i--] = '\0';
- }
- else
- {
- done = 1;
- }
- }
-
- return(0);
-}
-
-
-/*
- * VUnescape() unescapes escaped character.
- *
- * @param in [inout] pointer to string.
- * @return 0 if success.
- */
- int
-_VUnescape( char *in )
-{
- int i;
- int index;
- int len;
- char c1, c2;
-
- //DLOG( "_VUnescape() enter..\n");
-
- len = strlen(in);
-
- for ( i = 0, index = 0; i < len; i++ )
- {
- c1 = in[i];
-
- if ( c1 == '\\' )
- {
- c2 = in[i+1];
- if ( c2 == ';' ) continue;
- }
- in[index++] = c1;
- }
-
- in[index] = '\0';
-
- return(0);
-}
-
-/*
- * VEscape() escapes character.
- *
- * @param in [inout] pointer to string.
- * @return 0 if success.
- */
- int
-_VEscape( char *in )
-{
- int i;
- int index;
- int len;
- char *buf = NULL;
- char c;
-
- //DLOG( "_VEscape() enter..\n");
-
- len = strlen(in);
- buf = (char*) calloc(1, len*2+1);
-
- for ( i = 0, index = 0; i < len; i++ ){
- c = in[i];
- if ( c == ';' ) {
- buf[index++] = '\\';
- }
- buf[index++] = c;
- }
-
- strncpy( in, buf, len*2+1 );
- free(buf);
-
- return(0);
-}
-
-
-
-/*
- * vManySpace2Space() converts multiple spaces to single space in 'in'.
- *
- * @param in [inout] pointer to string.
- * @return int length of converted string.
- */
- int
-_VManySpace2Space( char *in )
-{
- int i, j;
- int spaced = 0;
-
- //DLOG( "_VManySpace2Space() enter..\n");
-
- j = 0;
- for ( i = 0; in[i]; i++ )
- {
- if ( _VIsSpace( in[i] ) )
- {
- if ( !spaced )
- {
- in[j] = WSP;
- spaced = 1;
- j++;
- }
- }
- else
- {
- spaced = 0;
- in[j] = in[i];
- j++;
- }
- }
-
-
- in[j] = '\0';
-
- return j;
-}
-
-
-/**
- * vFindBase64() returns the integer repesentation of the location in base64 table.
- *
- * @param in a character
- * @return int The base64 table location of input character
- */
-static int __VFindBase64( char in )
-{
- int i;
-
- //DLOG( "__VFindBase64() enter..\n");
-
- for ( i = 0; i < 65; i++ )
- {
- if ( Base64Table[i] == in )
- return i;
- }
- return -1;
-}
-
-
-
-/**
- * vBase64Check() returns the total length of input except non-base64 value.
- *
- * @param in char values which are base64 or non-base64
- * @return int the total length of input except non-base64
- */
-static int __VBase64Check( char *in )
-{
- int i = 0, j = 0;
- int base;
-
- //DLOG( "__VBase64Check() enter..\n");
-
- while ( in[i] )
- {
- base = __VFindBase64( in[i] );
- if ( base < 0 )
- {
- i++;
- }
- else
- {
- in[j] = in[i];
- j++; i++;
- }
- }
-
- in[j] = '\0';
-
- return j;
-}
-
-/**
- * vBase64Decoder() decodes the base64 encoded input.
- *
- * @param Src Base64 encoded input
- * @param Dest The destination buffer of decoded value
- * @return int The total length decoded value
- */
- int
-_VB64Decode( char *Dest, char *Src )
-{
- char* Encoded = Src;
- int i, j = 0;
- int res;
- char Base = 0;
- char DecodeTemp;
- char Debuffer[4] = {0x00, 0x00, 0x00, '\0'};
- int index = 0;
- int len;
-
- //DLOG( "_VB64Decode() enter..\n");
-
- len = __VBase64Check( Src );
-
- while ( *Encoded )
- {
- for ( i = 0; i < 3; i++ )
- Debuffer[i] = 0x00;
-
- for ( i = 0; i < 4; i++, Encoded++, j++ )
- {
- if(*Encoded == 0x00) break;
- if((res = __VFindBase64(*Encoded)) < 0) continue;
-
- Base = ( char )res;
- DecodeTemp = 0x00;
-
- if(Base == 64) {
- Encoded++;
- break;
- }
-
- switch ( i )
- {
- case 0:
- DecodeTemp = Base << 2;
- Debuffer[0] |= DecodeTemp;
- break;
- case 1:
- DecodeTemp = Base >> 4;
- Debuffer[0] |= DecodeTemp;
- DecodeTemp = Base << 4;
- Debuffer[1] |= DecodeTemp;
- break;
- case 2:
- DecodeTemp = Base >> 2;
- Debuffer[1] |= DecodeTemp;
- DecodeTemp = Base << 6;
- Debuffer[2] |= DecodeTemp;
- break;
- case 3:
- DecodeTemp = Base;
- Debuffer[2] |= DecodeTemp;
- break;
- }
- }
-
- if ( Base == 64 )
- {
- switch ( i )
- {
- case 0: break;
- case 1:
- case 2:
- Dest[index] = Debuffer[0];
- index++;
- break;
- case 3:
- Dest[index++] = Debuffer[0];
- Dest[index++] = Debuffer[1];
- break;
- }
- }
- else
- {
- Dest[index++] = Debuffer[0];
- Dest[index++] = Debuffer[1];
- Dest[index++] = Debuffer[2];
- }
- }
-
- return index;
-}
-
-
-/**
- * vBase64Encoder() encode the input to base64.
- *
- * @param Src non-base64 char input
- * @param Dest The destination buffer of encoded value
- * @return 0
- */
-int _VB64Encode( char *Dest, char *Src, int len )
-{
- char* Encoded = Dest;
- char* Decoded = Src;
- int i, j;
- int index;
- int res = 0;
- int base1 = 0, base2 = 0;
- char Enbuffer[4] = {0};
- char Debuffer[3] = {0};
- int length = 0;
-
- //DLOG( "_VB64Encode() enter..\n");
-
- for ( i = 0; i < len; i++ )
- {
- res = i%3;
-
- switch ( res )
- {
- case 0:
- Debuffer[0] = *Decoded;
- break;
- case 1:
- Debuffer[1] = *Decoded;
- break;
- case 2:
- Debuffer[2] = *Decoded;
- index = ( int )( ( Debuffer[0] & 0xFC ) >> 2 );
- Enbuffer[0] = Base64Table[index];
- base1 = ( int )( ( Debuffer[0] & 0x03 ) << 4 );
- base2 = ( int )( ( Debuffer[1] & 0xF0 ) >> 4 );
- index = ( int )( base1 | base2 );
- Enbuffer[1] = Base64Table[index];
- base1 = ( int )( ( Debuffer[1] & 0x0F ) << 2 );
- base2 = ( int )( ( Debuffer[2] & 0xC0 ) >> 6 );
- index = ( int )( base1 | base2 );
- Enbuffer[2] = Base64Table[index];
- index = ( int )( Debuffer[2] & 0x3F );
- Enbuffer[3] = Base64Table[index];
-
- Encoded[length++] = Enbuffer[0];
- Encoded[length++] = Enbuffer[1];
- Encoded[length++] = Enbuffer[2];
- Encoded[length++] = Enbuffer[3];
-
- for ( j = 0; j < 3; j++ )
- Debuffer[j] = 0x00;
-
- break;
- }
-
- Decoded++;
- }
-
- res = i % 3;
-
- switch ( res )
- {
- case 0:
- break;
- case 1:
- index = ( int )( ( Debuffer[0] & 0xFC ) >> 2 );
- Enbuffer[0] = Base64Table[index];
- base1 = ( int )( ( Debuffer[0] & 0x03 ) << 4 );
- base2 = ( int )( ( Debuffer[1] & 0xF0 ) >> 4 );
- index = ( int )( base1 | base2 );
- Enbuffer[1] = Base64Table[index];
- Enbuffer[2] = Base64Table[64];
- Enbuffer[3] = Base64Table[64];
-
- Encoded[length++] = Enbuffer[0];
- Encoded[length++] = Enbuffer[1];
- Encoded[length++] = Enbuffer[2];
- Encoded[length++] = Enbuffer[3];
-
- break;
- case 2:
- index = ( int )( ( Debuffer[0] & 0xFC ) >> 2 );
- Enbuffer[0] = Base64Table[index];
- base1 = ( int )( ( Debuffer[0] & 0x03 ) << 4 );
- base2 = ( int )( ( Debuffer[1] & 0xF0 ) >> 4 );
- index = ( int )( base1 | base2 );
- Enbuffer[1] = Base64Table[index];
- base1 = ( int )( ( Debuffer[1] & 0x0F ) << 2 );
- base2 = ( int )( ( Debuffer[2] & 0xC0 ) >> 6 );
- index = ( int )( base1 | base2 );
- Enbuffer[2] = Base64Table[index];
- Enbuffer[3] = Base64Table[64];
-
- Encoded[length++] = Enbuffer[0];
- Encoded[length++] = Enbuffer[1];
- Encoded[length++] = Enbuffer[2];
- Encoded[length++] = Enbuffer[3];
-
- break;
- }
-
- Encoded[length] = '\0';
-
- return 0;
-}
-
-
-/**
- * vUnfolding() unfold the folded line.
- *
- * @param string The folded line input
- * @return int Total length of unfolded output
- */
-int _VUnfolding( char *string )
-{
- unsigned int i, j;
- unsigned int len;
-
- //DLOG( "_VUnfolding() enter..\n");
-
- len = strlen( string );
-
- for ( i = 0, j = 0; i < len; i++, j++ )
- {
- string[j] = string[i];
-
- // 12.03.2004 Process garbage character at the end of vcard/vcal
- if ( _VIsSpace( string[i] ) && ( i < len-5 ) )
- {
- if ( string[i-1] == LF || string[i-1] == CR )
- {
- j -= 2; string[i-1] = 0;
- }
- if ( string[i-2] == LF || string[i-2] == CR )
- {
- j -= 1; string[i-2] = 0;
- }
- }
- }
-
- string[j] = '\0';
-
- return j;
-}
-
-
-int __VIsNewTypeforOrg( char *pCardRaw, int vType )
-{
- int count=0, i = 0, low=0, high=0, diff=0,vTypeNum;
- char strTypeName[50]={0};
- extern const char *pszCalTypeList[];
- //SysDebug(( MID_VDATA, "__VIsNewType() enter..\n"));
-
- while(1)
- {
- if(*pCardRaw == CR || *pCardRaw == LF)
- pCardRaw++;
- else
- {
- if(*pCardRaw == ';' || *pCardRaw == ':' || count >= 50)
- {
- break;
- }
- else
- strTypeName[count++] = *pCardRaw++;
- }
- }
-
- if(vType == VCALENDAR)
- vTypeNum = VCAL_TYPE_NUM;
- else
- return false;
-
- for ( low = 0, high = vTypeNum - 1; high >= low; diff < 0 ? ( low = i+1 ) : ( high = i-1 ) )
- {
- i = ( low + high ) / 2;
-
- if(vType == VCALENDAR)
- diff = strcmp( pszCalTypeList[i], strTypeName );
-
- if ( diff == 0 ) /* success: found it */
- return true;
- else if( !strncmp( strTypeName, "X-", 2 )) /* jpds-835 X-NEC-SUMMARY, X-NEC-FILENAME, X-NO, X-CLASS µî ƯÁ¤ Æù¿¡¼ Áö¿øÇÏ´Â TYPEÀÎ °æ¿ì¿¡ ´ëÇÑ Ã³¸® Ãß°¡ by sohn */
- return true;
- }
-
- //if(count <= 50) return TRUE;
-
- return false;
-
- //res = __VCardGetName( strTypeName, (char**)pszCardTypeList, VCARD_TYPE_NUM );
-}
-
-
-/**
- * vUnfolding() unfold the folded line.
- *
- * @param string The folded line input
- * @return int Total length of unfolded output
- */
- int
-_VUnfoldingNoSpec( char *string, int vType )
-{
- unsigned int i, j;
- unsigned int len;
-
- //SysDebug(( MID_VDATA, "_VUnfolding() enter..\n" ));
-
- len = strlen( string );
-
- for ( i = 0, j = 0; i < len; i++, j++ )
- {
- string[j] = string[i];
-
- if ( ( i < len-5 ) )
- {
- if ( string[i] == '=' )
- {
- if(string[i+1] == CR && string[i+2] == LF && string[i+3] =='=' ) // quoted printableÀÌ°í, ´ÙÀ½ÁÙ·Î stringÀÌ ¿¬°áµÇ´Â °æ¿ì
- {
- string[i] = 0;
- string[i+1] = 0;
- string[i+2] = 0;
- j -= 1;
- i += 2;
- }
- // else if(string[i+1] == CR || string[i+1] == LF) // CR À̳ª LF µÑÁß¿¡ ÇÑ°³¸¸ Á¸ÀçÇÏ´Â °æ¿ì
- else if(string[i+1] == CR && string[i+2] == LF && __VIsNewTypeforOrg(&string[i+3], vType) == false) //stringÀÌ ¿¬°áµÇ´Â °æ¿ì
- {
- string[i] = 0;
- string[i+1] = 0;
- string[i+2] = 0;
- j -= 1;
- i += 2;
- }
- }
- else if(string[i] ==WSP
- ||string[i]==TAB)
- {
- if(string[i-2] == CR && string[i-1] == LF)
- {
- string[i] = 0;
- string[i-1] = 0;
- string[i-2] = 0;
- j -= 3;
- }
- else if(string[i-1] == CR || string[i-1] == LF) // CR À̳ª LF µÑÁß¿¡ ÇÑ°³¸¸ Á¸ÀçÇÏ´Â °æ¿ì
- {
- string[i] = 0;
- string[i-1] = 0;
- j -= 2;
- }
- }
-
- }
- }
-
- string[j] = '\0';
-
- return j;
-}
-
-/**
- * vFolding() decodes the base64 encoded input.
- *
- * @param contentline Original line (unfolded)
- * @param Dest The destination buffer of folded result
- */
- void
-_VFolding( char *result, char *contentline )
-{
- int i = 0;
-
- //DLOG( "_VFolding() enter..\n");
-
- while ( *contentline )
- {
- if ( i == 75 )
- {
- i = 0;
- *result++ = '\r';
- *result++ = '\n';
- *result++ = ' ';
- }
-
- *result++ = *contentline++;
- i++;
- }
-
- *result++ = '\0';
-}
-
-
-/**
- * vFolding() decodes the base64 encoded input.
- *
- * @param contentline Original line (unfolded)
- * @param Dest The destination buffer of folded result
- */
- void
-_VFoldingQP( char *result, char *contentline )
-{
- int i = 0;
-
- //DLOG( "_VFolding() enter..\n");
-
- while ( *contentline )
- {
- if ( i == 74 )
- {
- i = 0;
- *result++= '=';
- *result++ = '\r';
- *result++ = '\n';
- }
-
- *result++ = *contentline++;
- i++;
- }
-
- *result++ = '\0';
-}
-
-
-/**
- * vFolding() decodes the base64 encoded input.
- *
- * @param contentline Original line (unfolded)
- * @param Dest The destination buffer of folded result
- */
- void
-_VFoldingNoSpace( char *result, char *contentline )
-{
- int i = 0;
-
- //DLOG( "_VFolding() enter..\n");
-
- while ( *contentline )
- {
- if ( i == 75 )
- {
- i = 0;
- *result++ = '\r';
- *result++ = '\n';
- }
-
- *result++ = *contentline++;
- i++;
- }
-
- *result++ = '\0';
-}
-
-
-/**
- * vQuotedPrintalbeDecoder() decodes the quoted-printable encoded input.
- *
- * @param Src Quoted-printable encoded input
- * @return int The total length decoded value
- */
- int
-_VQPDecode( char *src )
-{
- int i = 0, j = 0;
- char qp[2];
- char decodedNum;
-
- //DLOG( "_VQPDecode() enter..\n");
-
- while ( src[i] )
- {
- if ( src[i] == '=' )
- {
- if ( !( _VIsSpace( src[i + 1] ) || ( src[i + 1] == '\r' ) || ( src[i+1] == '\n' ) ) )
- {
- if ( src[i + 1] == '0' && ( src[i + 2] == 'D' || src[i +2] == 'd' ) && src[i + 3] == '='
- && src[i + 4] == '0' && ( src[i + 5] == 'A' || src[i + 5] == 'a' ) )
- {
- src[j] = '\n';
- j++;
- i += 6;
- }
- else
- {
- qp[0] = src[i + 1];
- qp[1] = src[i + 2];
- decodedNum = __VHexaDecoder( qp );
- src[j] = decodedNum;
- i += 3; j++;
- }
- }
- else
- {
- i += 3;
- }
- }
- else
- {
- src[j] = src[i];
- i++; j++;
- }
- }
-
- src[j] = '\0';
-
- j = _VManySpace2Space( src );
-
- return j;
-}
-
-
-
-/**
- * vQuotedPrintableEncoder() decodes the quoted-printalbe encoded input.
- *
- * @param Src Quoted-printable encoded input
- * @param Dest The destination buffer of decoded value
- * @return int The total length decoded value
- */
- int
-_VQPEncode( char *dest, char *src )
-{
- int i = 0, j = 0, k = 0;
- char encoded[2] = {0x0f, 0x0f};
-
- //DLOG( "_VQPEncode() enter..\n");
-
- while ( src[i] /*&& ( src[i] > 0 )*/ )
- {
- if ( k == 73 && _VIsSpace( src[i] ) )
- {
- if( src[i] == WSP )
- {
- dest[j++] = '='; dest[j++] = '2'; dest[j++] = '0';
- k += 3;
- }
- else if ( src[i] == TAB )
- {
- dest[j++] = '='; dest[j++] = '0'; dest[j++] = '9';
- k += 3;
- }
- }
- /* else if ( k == 76 )
- {
- dest[j++] = '='; dest[j++] = WSP;
- k = 0;
- } */
- else if ( !__VIsPrintable( src[i] ) )
- {
- dest[j++] = '=';
- encoded[0] &= (src[i] >> 4);
- encoded[1] &= (src[i]);
- __VHexaEncoder( encoded );
- dest[j++] = encoded[0]; encoded[0] = 0x0f;
- dest[j++] = encoded[1]; encoded[1] = 0x0f;
- k += 3;
- }
- else if ( src[i] == '\r' || src[i] == '\n' )
- {
- dest[j++] = '='; dest[j++] = '0'; dest[j++] = 'D'; k += 3;
- dest[j++] = '='; dest[j++] = '0'; dest[j++] = 'A'; k += 3;
- }
- else
- {
- dest[j++] = src[i]; k++;
- }
- i++;
- }
-
- dest[j] = '\0';
-
- return j;
-}
-
-
-/**
- * vIsPrintable() check whether the input is printable.
- *
- * @param in
- * @return true/false if input is printable :true else : false
- */
-static int __VIsPrintable( char in )
-{
- //DLOG( "__VIsPrintable() enter..\n");
-
- if ( in >= 33 && in <= 60 ) return true;
- else if ( in >= 62 && in <= 126 ) return true;
- else if ( in == WSP || in == TAB ) return true;
- else if ( in == '\r' || in == '\n' ) return true;
- else return false;
-}
-
-
-
-/**
- * vHexaDecoder() output the character value of inputed hexadecimal value.
- *
- * @param qp Hexadecimal input value
- * @return char Character representation of input hexadecimal value
- */
-static char __VHexaDecoder( char *qp )
-{
- int i;
- char decoded[2] = {0x00, 0x00};
- char res;
-
- //DLOG( "__VHexaDecoder() enter..\n");
-
- for ( i = 0; i < 2; i++ )
- {
- switch ( qp[i] )
- {
- case '0':
- decoded[i] = 0x00;
- break;
- case '1':
- decoded[i] = 0x01;
- break;
- case '2':
- decoded[i] = 0x02;
- break;
- case '3':
- decoded[i] = 0x03;
- break;
- case '4':
- decoded[i] = 0x04;
- break;
- case '5':
- decoded[i] = 0x05;
- break;
- case '6':
- decoded[i] = 0x06;
- break;
- case '7':
- decoded[i] = 0x07;
- break;
- case '8':
- decoded[i] = 0x08;
- break;
- case '9':
- decoded[i] = 0x09;
- break;
- case 'a':
- case 'A':
- decoded[i] = 0x0a;
- break;
- case 'b':
- case 'B':
- decoded[i] = 0x0b;
- break;
- case 'c':
- case 'C':
- decoded[i] = 0x0c;
- break;
- case 'd':
- case 'D':
- decoded[i] = 0x0d;
- break;
- case 'e':
- case 'E':
- decoded[i] = 0x0e;
- break;
- case 'f':
- case 'F':
- decoded[i] = 0x0f;
- break;
- }
- }
-
- res = ( char )( ( decoded[0] << 4 ) + decoded[1] );
-
- return res;
-}
-
-
-
-/**
- * vHexaEncoder() output the hexadecimal value of input character value.
- *
- * @return qp Character representation of input hexadecimal value
- */
-static void __VHexaEncoder( char *qp )
-{
- int i;
-
- //DLOG( "__VHexaEncoder() enter..\n");
-
- for ( i = 0; i < 2; i++ )
- {
- switch ( qp[i] )
- {
- case 0:
- qp[i] = '0';
- break;
- case 1:
- qp[i] = '1';
- break;
- case 2:
- qp[i] = '2';
- break;
- case 3:
- qp[i] = '3';
- break;
- case 4:
- qp[i] = '4';
- break;
- case 5:
- qp[i] = '5';
- break;
- case 6:
- qp[i] = '6';
- break;
- case 7:
- qp[i] = '7';
- break;
- case 8:
- qp[i] = '8';
- break;
- case 9:
- qp[i] = '9';
- break;
- case 10:
- qp[i] = 'A';
- break;
- case 11:
- qp[i] = 'B';
- break;
- case 12:
- qp[i] = 'C';
- break;
- case 13:
- qp[i] = 'D';
- break;
- case 14:
- qp[i] = 'E';
- break;
- case 15:
- qp[i] = 'F';
- break;
- }
- }
-
-}
-
-/**
- * _VIsCrLf() returns one if char is either a space, tab, or newline.
- *
- * @param s1 [in] pointer to first string.
- * @param s2 [in] pointer to second string.
- * @return 1 'in' is a space character.
- * @return 0 'in' is not a space.
- */
- int
-_VIsCrLf(char in)
-{
- //SysDebug(( MID_VDATA, "_VIsCrLf() enter..\n" ));
-
- if ( ( in == CR ) || ( in == LF ) )
- {
- return 1;
- }
- else
- {
- return 0;
- }
-}
-
-/*
- * vManySpace2Space() converts multiple spaces to single space in 'in'.
- *
- * @param in [inout] pointer to string.
- * @return int length of converted string.
- */
- int
-_VManyCRLF2CRLF(char *pIn)
-{
- int i, j;
- bool bCrLf = false, bFirstCrLf = true;
-
- //SysDebug(( MID_VDATA, "_VManySpace2Space() enter..\n" ));
-
- j = 0;
- for ( i = 0; pIn[i]; i++ )
- {
- if ( _VIsCrLf( pIn[i] ) && _VIsCrLf( pIn[i+1] ))
- {
- if( bFirstCrLf && !bCrLf)
- {
- bCrLf = 1;
- }
- else if( !bFirstCrLf )
- {
- if ( !bCrLf )
- {
- pIn[j] = CR;
- pIn[++j] = LF;
- bCrLf = true;
- j++;
- }
- }
- i++;
- }
- else
- {
- bCrLf = false;
- bFirstCrLf = false;
- pIn[j] = pIn[i];
- j++;
- }
- }
-
- pIn[j] = '\0';
-
- return j;
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
* limitations under the License.
*
*/
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+#include <glib.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <ctype.h>
+
#include "cals-typedef.h"
-#include "cals-ical-codec.h"
#include "cals-ical.h"
#include "cals-utils.h"
#include "cals-db.h"
#include "cals-internal.h"
#include "cals-schedule.h"
+#include "cals-struct.h"
+#include "cals-utils.h"
+#include "cals-time.h"
+
+#define ICALENAR_BUFFER_MAX (1024*1024)
+
+
+enum {
+ ENCODE_NONE = 0x0,
+ ENCODE_BASE64,
+ ENCODE_QUOTED_PRINTABLE,
+ ENCODE_MAX,
+};
+
+
+struct _comp_func {
+ char *prop;
+ char *(*func)(GList **list_sch, void *data);
+};
+
+struct _prop_func {
+ char *prop;
+ int (*func)(GList **list_sch, void *data);
+};
+
+struct _veve_func {
+ char *prop;
+ int (*func)(int ver, cal_sch_full_t *sch, void *data);
+};
+
+struct _vala_func {
+ char *prop;
+ int (*func)(cal_sch_full_t *sch, void *data);
+};
+
+struct _rrule_func {
+ char *prop;
+ int (*func)(cal_sch_full_t *sch, void *data);
+};
+
+
+struct _val_func {
+ char *prop;
+ int (*func)(int *val, void *data);
+};
+
+
+char *cals_func_vcalendar(GList **list_sch, void *data);
+char *cals_func_vevent(int ver, GList **list_sch, void *data);
+char *cals_func_vtodo(int ver, GList **list_sch, void *data);
+char *cals_func_valarm(cal_sch_full_t *sch, void *data);
+
+enum {
+ VCAL_PRODID = 0x0,
+ VCAL_VERSION,
+// VCAL_CALSCALE,
+// VCAL_METHOD,
+ VCAL_MAX,
+};
+
+int cals_func_prodid(GList **list_sch, void *data);
+int cals_func_version(GList **list_sch, void *data);
+
+struct _prop_func _vcal_list[VCAL_MAX] =
+{
+ {"PRODID", cals_func_prodid },
+ {"VERSION", cals_func_version }//,
+// {"CALSCALE", cals_func_calscale },
+// {"METHOD", cals_func_method }
+};
+
+int cals_func_dtstamp(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_dtstart(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_uid(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_class(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_created(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_description(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_geo(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_last_mod(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_location(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_organizer(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_priority(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_seq(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_status(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_summary(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_transp(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_url(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_recurid(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_rrule(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_dtend(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_duration(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_attach(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_attendee(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_categories(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_comment(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_contact(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_exdate(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_rstatus(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_related(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_resources(int ver, cal_sch_full_t *sch, void *data);
+int cals_func_rdate(int ver, cal_sch_full_t *sch, void *data);
+
+/* for vcalendar version 1.0 */
+int cals_ver1_func_rrule(cal_sch_full_t *sch, void *data);
+
+enum {
+ VEVE_DTSTAMP = 0x0,
+ VEVE_DTSTART,
+// VEVE_UID,
+// VEVE_CLASS,
+ VEVE_CREATED,
+ VEVE_DESCRIPTION,
+// VEVE_GEO,
+ VEVE_LAST_MOD,
+ VEVE_LOCATION,
+// VEVE_ORGANIZER,
+ VEVE_PRIORITY,
+// VEVE_SEQ,
+ VEVE_STATUS,
+ VEVE_SUMMARY,
+// VEVE_TRANSP,
+// VEVE_URL,
+// VEVE_RECURID,
+ VEVE_RRULE,
+ VEVE_DTEND,
+// VEVE_DURATION,
+// VEVE_ATTACH,
+// VEVE_ATTENDEE,
+ VEVE_CATEGORIES,
+// VEVE_COMMENT,
+// VEVE_CONTACT,
+// VEVE_EXDATE,
+// VEVE_RSTATUS,
+// VEVE_RELATED,
+// VEVE_RESOURCES,
+// VEVE_RDATE,
+ VEVE_MAX,
+};
+
+struct _veve_func _veve_list[VEVE_MAX] =
+{
+ { "DTSTAMP", cals_func_dtstamp },
+ { "DTSTART", cals_func_dtstart },
+// { "UID", cals_func_uid },
+// { "CLASS", cals_func_class },
+ { "CREATED", cals_func_created },
+ { "DESCRIPTION", cals_func_description },
+// { "GEO", cals_func_geo },
+ { "LAST-MOD", cals_func_last_mod },
+ { "LOCATION", cals_func_location },
+// { "ORGANIZER", cals_func_organizer },
+ { "PRIORITY", cals_func_priority },
+// { "SEQ", cals_func_seq },
+ { "STATUS", cals_func_status },
+ { "SUMMARY", cals_func_summary },
+// { "TRANSP", cals_func_transp },
+// { "URL", cals_func_url },
+// { "RECURID", cals_func_recurid },
+ { "RRULE", cals_func_rrule },
+ { "DTEND", cals_func_dtend },
+// { "DURATION", cals_func_duration },
+// { "ATTACH", cals_func_attach },
+// { "ATTENDEE", cals_func_attendee },
+ { "CATEGORIES", cals_func_categories }//,
+// { "COMMENT", cals_func_comment },
+// { "CONTACT", cals_func_contact },
+// { "EXDATE", cals_func_exdate },
+// { "RSTATUS", cals_func_rstatus },
+// { "RELATED", cals_func_related },
+// { "RESOURCES", cals_func_resources },
+// { "RDATE", cals_func_rdate }
+};
+
+int cals_func_action(cal_sch_full_t *sch, void *data);
+int cals_func_trigger(cal_sch_full_t *sch, void *data);
+int cals_func_repeat(cal_sch_full_t *sch, void *data);
+int cals_func_duration_alarm(cal_sch_full_t *sch, void *data);
+int cals_func_attach_alarm(cal_sch_full_t *sch, void *data);
+int cals_func_summary_alarm(cal_sch_full_t *sch, void *data);
+
+enum {
+ VALA_ACTION = 0x0,
+ VALA_TRIGGER,
+ VALA_REPEAT,
+ VALA_DURATION,
+ VALA_ATTACH,
+// VALA_DESCRIPTION,
+ VALA_SUMMARY,
+// VALA_ATTENDEE,
+ VALA_MAX,
+};
+
+struct _vala_func _vala_list[VALA_MAX] =
+{
+ { "ACTION", cals_func_action },
+ { "TRIGGER", cals_func_trigger },
+ { "REPEAT", cals_func_repeat },
+ { "DURATION", cals_func_duration_alarm },
+ { "ATTACH", cals_func_attach_alarm },
+// { "DESCRIPTION", cals_func_description },
+ { "SUMMARY", cals_func_summary_alarm },
+// { "ATTENDEE", cals_func_attendee },
+};
+
+int cals_func_freq(cal_sch_full_t *sch, void *data);
+int cals_func_until(cal_sch_full_t *sch, void *data);
+int cals_func_count(cal_sch_full_t *sch, void *data);
+int cals_func_interval(cal_sch_full_t *sch, void *data);
+int cals_func_bysecond(cal_sch_full_t *sch, void *data);
+int cals_func_byminute(cal_sch_full_t *sch, void *data);
+int cals_func_byhour(cal_sch_full_t *sch, void *data);
+int cals_func_byday(cal_sch_full_t *sch, void *data);
+int cals_func_bymonthday(cal_sch_full_t *sch, void *data);
+int cals_func_byyearday(cal_sch_full_t *sch, void *data);
+int cals_func_byweekno(cal_sch_full_t *sch, void *data);
+int cals_func_bymonth(cal_sch_full_t *sch, void *data);
+int cals_func_bysetpos(cal_sch_full_t *sch, void *data);
+int cals_func_wkst(cal_sch_full_t *sch, 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,
+};
+
+struct _rrule_func _rrule_list[RRULE_MAX] =
+{
+ { "FREQ=", cals_func_freq },
+ { "UNTIL=", cals_func_until },
+ { "COUNT=", cals_func_count },
+ { "INTERVAL=", cals_func_interval },
+ { "BYSECOND=", cals_func_bysecond },
+ { "BYMINUTE=", cals_func_byminute },
+ { "BYHOUR=", cals_func_byhour },
+ { "BYDAY=", cals_func_byday },
+ { "BYMONTHDAY=", cals_func_bymonthday },
+ { "BYYEARDAY=", cals_func_byyearday },
+ { "BYWEEKNO=", cals_func_byweekno },
+ { "BYMONTH=", cals_func_bymonth },
+ { "BYSETPOS=", cals_func_bysetpos },
+ { "WKST=", cals_func_wkst }
+};
+
+int cals_func_related_trig(cal_sch_full_t *sch, void *data);
+int cals_func_value(cal_sch_full_t *sch, void *data);
+
+enum {
+ TRIG_RELATED = 0x0,
+ TRIG_VALUE,
+ TRIG_MAX,
+};
+
+struct _vala_func _trig_list[TRIG_MAX] =
+{
+ { "RELATED=", cals_func_related_trig },
+ { "VALUE=", cals_func_value }
+};
+
+int cals_func_charset(int *val, void *data);
+int cals_func_encoding(int *val, void *data);
+
+
+enum {
+ TEXT_CHARSET = 0x0,
+ TEXT_ENCODING,
+ TEXT_MAX,
+};
+
+struct _val_func _optional_list[TEXT_MAX] =
+{
+ { "CHARSET=", cals_func_charset },
+ { "ENCODING=", cals_func_encoding },
+};
+
+char *cals_convert_sec_from_duration(char *p, int *dur_t, char *dur);
+
+//util //////////////////////////////////////////////////////////////////////
+
+
+char *cals_skip_empty_line(char *src)
+{
+ CALS_FN_CALL;
+ while (*src) {
+ if ('\n' != *src && '\r' != *src) {
+ break;
+ }
+ src++;
+ }
+ return src;
+}
+
+int cals_file_exist(const char *path)
+{
+ FILE *fp;
+
+ fp = fopen(path, "r");
+
+ if (fp == NULL) {
+ ERR("Failed to access path(%s)\n", path);
+ return -1;
+ }
+ fclose(fp);
+ return 0;
+}
+
+char *cals_check_word(char *src, const char *word)
+{
+ int start = 0;
+
+ src = cals_skip_empty_line(src);
+
+ while (*src) {
+ switch (*src) {
+ case ' ':
+ case ':':
+ case ';':
+ src++;
+ break;
+ default:
+ start = 1;
+ break;
+ }
+ if (start) break;
+ }
+
+ while (*src == *word) {
+ src++;
+ word++;
+
+ if ('\0' == *src || '\0' == *word)
+ break;
+ }
+
+ if ('\0' == *word)
+ return src;
+ else
+ return NULL;
+}
+
+char cals_2hexa_to_1char(char *p)
+{
+ int i;
+ char decoded[2] = {0x00, 0x00};
+
+ for (i = 0; i < 2; i++) {
+ switch (p[i]) {
+ case '0' ... '9':
+ decoded[i] = p[i] - '0';
+ break;
+ case 'a' ... 'f':
+ decoded[i] = p[i] - 'a' + 10;
+ break;
+ case 'A' ... 'F':
+ decoded[i] = p[i] - 'A' + 10;
+ break;
+ }
+ }
+
+ return (char)((decoded[0] << 4) + decoded[1]);
+}
+
+int cals_quoted_printable_decode(char *p, int *len)
+{
+ int i = 0, j = 0;
+ char ch;
+
+ while (p[i]) {
+ if (p[i] == '=') {
+ if (p[i+1] == 0x09 || p[i+1] == 0x20) {
+ i +=3;
+
+ } else if (p[i+1] == '\r' || p[i+1] == '\n') {
+ i +=3;
+
+ } else {
+ if (p[i+1] == '0' && tolower(p[i+2]) == 'd' &&
+ p[i+3] == '=' && p[i+4] == '0' && tolower(p[i+5]) == 'a') {
+ p[j] = '\n';
+ j++;
+ i += 6;
+ } else {
+ ch = cals_2hexa_to_1char(&p[i+1]);
+ p[j] = ch;
+ j++;
+ i += 3;
+ }
+ }
+ } else {
+ p[j] = p[i];
+ j++;
+ i++;
+ }
+ }
+ p[j] = '\0';
+ *len = i;
+ return 0;
+}
+
+////////////////////////////////////////////////////////////////////////
-#define VCALENDAR_HEADER "BEGIN:VCALENDAR"
-#define VNOTE_HEADER "BEGIN:VNOTE"
+cal_sch_full_t *cals_add_vcalendar(void)
+{
+ cal_sch_full_t *sch;
+
+ sch = calloc(1, sizeof(cal_sch_full_t));
+ if (sch == NULL) {
+ return NULL;
+ }
+ return sch;
+}
+
-bool cal_convert_cal_data_to_vdata_file(const cal_sch_full_t *sch_array,
- const int sch_count, const char *file_path, int *error_code)
+int cals_unfold_content(char *stream)
{
CALS_FN_CALL;
- bool is_success = false;
- char *vcal = NULL;
+ char *p;
+
+ retv_if(stream == NULL, CAL_ERR_ARG_NULL);
+
+ p = stream;
+ while (*stream) {
+ if ('\n' == *stream && ' ' == *(stream + 1)) {
+ stream += 2;
+ p--;
+ } else if ('\0' == *stream) {
+ CALS_DBG("break\n");
+ break;
+ }
+ *p = *stream;
+ p++;
+ stream++;
+
+ }
+ return 0;
+}
+
- cal_vCal_ver_t version = CAL_VCAL_VER_1_0;
+char *cals_read_line(char *stream, char **prop, char **cont)
+{
+ int i;
+ char *p, *q;
+ int out;
- retvm_if(NULL == error_code, false, "The error_code is NULL");
- if (NULL == sch_array || NULL == file_path) {
- ERR("Invalid ARG:sch_array(%p), file_path(%p)", sch_array, file_path);
- *error_code = CAL_ERR_ARG_INVALID;
- return false;
+ /* skip space */
+ p = stream;
+ q = p;
+ out = 0;
+ while (*p) {
+ switch (*p) {
+ case ' ':
+ break;
+ default:
+ out = 1;
+ break;
+ }
+ if (out == 1) {
+ break;
+ }
+ p++;
}
- // create a vcal file
- FILE* file = fopen(file_path, "w+");
- retex_if(file == NULL, *error_code = CAL_ERR_IO_ERR, "Failed to create file!");
+ i = 0;
+ out = 0;
+ q = p;
+ while (*p) {
+ switch (*p) {
+ case ';':
+ case ':':
+ out = 1;
+ break;
+ default:
+ i++;
+ break;
+ }
+ if (out == 1) {
+ i++;
+ break;
+ }
+ p++;
+ }
- // encode a sch data
- /*if (sch_array[0].cal_type == CAL_EVENT_MEMO_TYPE)
- {
- is_success = _cal_convert_note_to_vnote(sch_array, sch_count, &vcal, version);
- retex_if(is_success == true, *error_code = CAL_ERR_VOBJECT_FAILED, "_cal_convert_sch_to_vcalendar error!");
- }
- else*/
- {
- is_success = _cal_convert_sch_to_vcalendar(sch_array, sch_count, &vcal, version);
- retex_if(is_success != true, *error_code = CAL_ERR_VOBJECT_FAILED, "_cal_convert_sch_to_vcalendar error!");
+ if (0 < i) {
+ *prop = calloc(1, i);
+ snprintf(*prop, i, "%s", q);
+ } else {
+ *prop = NULL;
+ return NULL;
}
- retex_if(vcal == NULL, *error_code = CAL_ERR_VOBJECT_FAILED,"cal_convert_cal_data_to_vdata_file vcal is NULL!!");
+ i = 0;
+ out = 0;
+ q = p;
+
+ while (*p) {
+ switch (*p) {
+ case '\r':
+ if ('\n' == *(p + 1)) {
+ out = 1;
+ }
+ break;
+ case '\0':
+ break;
+ default:
+ i++;
+ break;
+ }
+ if (out == 1) {
+ i++;
+ break;
+ }
+ p++;
+ }
+ if (0 < i) {
+ *cont = calloc(1, i);
+ snprintf(*cont, i, "%s", q);
+ p += 2;
+ } else {
+ *cont = NULL;
+ return NULL;
+ }
- CALS_DBG( "\n%s\n", vcal );
+ DBG("%s][%s\n", *prop, *cont);
+ return p;
+}
- CALS_DBG("------------begint to write to file_path = %s--------------------\n", file_path);
+inline void cals_get_optional_parameter(char *p, int *encoding)
+{
+ int i;
- // write vcal string to file
- if (fputs( vcal, file) == EOF)
- {
- fclose( file );
+ for (i = 0; i < TEXT_MAX; i++) {
+ if (!strncmp(p, _optional_list[i].prop, strlen(_optional_list[i].prop))) {
+ int j = 0;
+ char buf[64] = {0, };
+ p += strlen(_optional_list[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';
+ }
- CAL_FREE(vcal);
+ p += j;
+ _optional_list[i].func(encoding, buf);
+ break;
+ } else {
- *error_code = CAL_ERR_IO_ERR;
- return false;
+ }
}
+}
+
+API int calendar_svc_read_schedules(const char *stream, GList **schedules)
+{
+ CALS_FN_CALL;
+ int ret = 0;
+ char *prop, *cont;
+ char *cursor;
+ GList *l = NULL;
+
+ cursor = (char *)stream;
+
+ retv_if(stream == NULL, CAL_ERR_ARG_INVALID);
+ cursor = cals_skip_empty_line(cursor);
+ retvm_if(cursor == NULL, CAL_ERR_FAIL, "Failed to skip empty line\n");
+ cals_unfold_content(cursor);
- CALS_DBG("------------success write to file_path = %s--------------------\n", file_path);
+ cursor = cals_read_line(cursor, &prop, &cont);
+ retvm_if(cursor == NULL, CAL_ERR_FAIL, "Failed to read line\n");
- // free buff
- free(vcal);
- fclose( file );
+ if (strncmp(prop, "BEGIN", strlen("BEGIN")) ||
+ strncmp(cont + 1, "VCALENDAR", strlen("VCALENDAR"))) {
+ ERR("Failed to find BEGIN:VCALDENDAR [%s][%s]", prop, cont);
+ free(prop);
+ free(cont);
+ return CAL_ERR_FAIL;
+ }
+ free(prop);
+ free(cont);
- return true;
+ cursor = cals_func_vcalendar(&l, cursor);
-CATCH:
- if (file != NULL)
- {
- fclose( file );
+ if (l == NULL) {
+ ERR("No schedules");
+ return CAL_ERR_NO_DATA;
}
- return false;
+
+ *schedules = l;
+ return ret;
}
-bool cal_convert_vdata_file_to_cal_data(const char *file_path,
- cal_sch_full_t **sch_array, int * sch_count, int *error_code)
+int cals_do_importing(int calendar_id, char *stream, void *data)
{
- char raw_data[VCALENDAR_DATA_LEN + 1];
- bool is_success = false;
+ int ret;
+ GList *list_sch = NULL;
+ GList *l;
+ cal_struct *cs;
+ cal_sch_full_t *sch;
+
+ ret = calendar_svc_read_schedules(stream, &list_sch);
+ retvm_if(ret < 0, ret, "Failed to parse(%d)", ret);
+
+ /* calendar id validation check */
- retvm_if(NULL == error_code, false, "The error_code is NULL");
+ /* insert schedules to db */
+ l = list_sch;
+ while (l) {
+ sch = (cal_sch_full_t *)((cal_struct *)l->data)->user_data;
+ if (sch) {
+ sch->calendar_id = calendar_id;
+ ret = cals_insert_schedule(sch);
+ }
+
+ l = g_list_next(l);
+ }
- if (NULL == file_path || NULL == sch_array || NULL == sch_count) {
- ERR("Invalid ARG:file_path(%p), sch_array(%p), sch_count(%p)",
- file_path, sch_array, sch_count);
- *error_code = CAL_ERR_ARG_INVALID;
- return false;
+ /* free schedules in memory */
+ l = list_sch;
+ while (l) {
+ cs = (cal_struct *)l->data;
+ if (cs == NULL) {
+ ERR("Not cal struct\n");
+ break;
+ }
+ calendar_svc_struct_free(&cs);
+ l = g_list_next(l);
}
+ g_list_free(list_sch);
- memset(raw_data, 0, VCALENDAR_DATA_LEN + 1);
+ return ret;
+}
- // write vcal to file
- FILE * file = fopen(file_path, "r");
- retex_if(file == NULL, *error_code = CAL_ERR_IO_ERR, "Failed to open file!");
+static const char* cals_get_stream_from_path(const char *path)
+{
+ FILE *file;
+ int buf_size, len;
+ char *stream;
+ char buf[1024];
- // Fix for prevent - B.
- fread(raw_data, 1, (VCALENDAR_DATA_LEN), file);
+ file = fopen(path, "r");
- fclose( file );
+ len = 0;
+ buf_size = ICALENAR_BUFFER_MAX;
+ stream = malloc(ICALENAR_BUFFER_MAX);
- if (strncmp(raw_data, VCALENDAR_HEADER, strlen(VCALENDAR_HEADER)) == 0)
- {
- // this is a vcalendar stream
- is_success = _cal_convert_vcalendar_to_cal_data(raw_data, sch_array, sch_count);
- retex_if(is_success == false, *error_code = CAL_ERR_VOBJECT_FAILED, "_cal_convert_vcalendar_to_cal_data error!");
+ 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);
+ ERR("out of memory\n");
+ return NULL;
+ }
+ len += snprintf(stream + len, strlen(buf) +1, "%s", buf);
+ }
}
- else
- {
- ERR( "\n-------------------------- header error --------- -------------\n");
- return false;
+ fclose(file);
+ return stream;
+}
+
+int calendar_svc_read_schedules_from_file(const char *path, GList **schedules)
+{
+ const char *stream;
+ int ret;
+
+ ret = cals_file_exist(path);
+ if (ret < 0) {
+ ERR("Failed to access path(%s)\n", path);
+ return -1;
+ }
+
+ stream = cals_get_stream_from_path(path);
+ retvm_if(stream == NULL, -1, "Failed to get stream from path(%s)", path);
+
+ ret = calendar_svc_read_schedules(stream, schedules);
+ if (ret < 0) {
+ ERR("Failed to parse ics\n");
+ if (stream) {
+ free((void *)stream);
+ }
+ return -1;
+ }
+
+ if (stream) {
+ free((void *)stream);
+ }
+ return 0;
+}
+
+int cals_import_schedules(const char *path, int calendar_id)
+{
+ FILE *file;
+ int buf_size, len;
+ char *stream;
+ char buf[1024];
+
+ file = fopen(path, "r");
+
+ 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 CAL_ERR_OUT_OF_MEMORY;
+ }
+ len += snprintf(stream + len, strlen(buf) +1, "%s", buf);
+ }
+
+ if (!strncmp(buf, "END:VCALENDAR", strlen("END:VCALENDAR"))){
+ DBG("end vcalendar");
+
+ if (cals_do_importing(calendar_id, stream, NULL)) {
+ if (stream) free(stream);
+ fclose(file);
+ return 0;
+ }
+ len = 0;
+ }
+ }
+ if (stream) free(stream);
+ fclose(file);
+ return CAL_SUCCESS;
+}
+
+API int calendar_svc_calendar_import(const char *path, int calendar_id)
+{
+ int ret;
+ retv_if(path == NULL, CAL_ERR_ARG_INVALID);
+
+ ret = cals_file_exist(path);
+ if (ret < 0) {
+ ERR("Failed to access (%s)\n", path);
+ return -1;
+ }
+
+ ret = cals_import_schedules(path, calendar_id);
+ return ret;
+}
+
+
+
+// func ////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////
+
+char *cals_func_vcalendar(GList **list_sch, void *data)
+{
+ CALS_FN_CALL;
+ int ver = -1;
+ char *prop, *cont;
+ char *cursor = (char *)data;
+ char *p = cursor;
+
+ /* do until meet BEGIN */
+ while ((cursor = cals_read_line(cursor, &prop, &cont))) {
+ if (!strncmp(prop, "BEGIN", strlen("BEGIN"))) {
+ if (prop) free(prop);
+ if (cont) free(cont);
+
+ break;
+
+ }
+
+ if (!strncmp(prop, "PRODID", strlen("PRODID"))) {
+ _vcal_list[VCAL_PRODID].func(list_sch, cont);
+
+ } else if (!strncmp(prop, "VERSION", strlen("VERSION"))) {
+ ver = _vcal_list[VCAL_VERSION].func(list_sch, cont);
+
+ } else {
+
+ }
+
+ if (prop) {
+ free(prop);
+ prop = NULL;
+ }
+ if (cont) {
+ free(cont);
+ cont = NULL;
+ }
+
+ p = cursor;
+ }
+
+ cursor = p;
+ while ((cursor = cals_read_line(cursor, &prop, &cont))) {
+ if (!strncmp(prop, "BEGIN", strlen("BEGIN"))) {
+
+ if (!strncmp(cont + 1, "VEVENT", strlen("VEVENT"))) {
+ cursor = cals_func_vevent(ver, list_sch, cursor);
+
+ } else if (!strncmp(cont + 1, "VTODO", strlen("VTODO"))) {
+ cursor = cals_func_vtodo(ver, list_sch, cursor);
+/*
+ } else if (!strncmp(cont + 1, "VFREEBUSY", strlen("VFREEBUSY"))) {
+ } else if (!strncmp(cont + 1, "VTIMEZONE", strlen("VTIMEZONE"))) {
+ } else if (!strncmp(cont + 1, "STANDARD", strlen("STANDARD"))) {
+ } else if (!strncmp(cont + 1, "DAYLIGHT", strlen("DAYLIGHT"))) {
+*/
+ } else {
+
+ }
+
+ } else if (!strncmp(prop, "END", strlen("END"))) {
+ if (prop) free(prop);
+ if (cont) free(cont);
+
+ break;
+
+ }
+
+ if (prop) {
+ free(prop);
+ prop = NULL;
+ }
+ if (cont) {
+ free(cont);
+ cont = NULL;
+ }
+ }
+
+ return cursor;
+}
+
+char *cals_func_vevent(int ver, GList **list_sch, void *data)
+{
+ CALS_FN_CALL;
+ int i;
+ char *prop, *cont;
+ char *cursor = (char *)data;
+ GList *l;
+ cal_struct *cs;
+ cal_sch_full_t *sch;
+
+ sch = calloc(1, sizeof(cal_sch_full_t));
+ retvm_if(sch == NULL, NULL, "Failed to alloc cal_sch_full_t");
+ cals_event_init(sch);
+
+ cs = calloc(1, sizeof(cal_struct));
+ retvm_if(cs == NULL, NULL, "Failed to alloc cal_struct");
+ cs->event_type = CAL_STRUCT_TYPE_SCHEDULE;
+ cs->user_data = sch;
+
+ *list_sch = g_list_append(*list_sch, cs);
+
+ /* do until meet BEGIN */
+ while ((cursor = cals_read_line(cursor, &prop, &cont))) {
+ if (!strncmp(prop, "BEGIN", strlen("BEGIN"))) {
+
+ if (!strncmp(cont + 1, "VALARM", strlen("VALARM"))) {
+ cursor = cals_func_valarm(sch, cursor);
+ } else {
+ break;
+ }
+
+ } else if (!strncmp(prop, "END", strlen("END"))) {
+ break;
+
+ } else {
+ for (i = 0; i < VEVE_MAX; i++) {
+ if (!strncmp(prop, _veve_list[i].prop, strlen(_veve_list[i].prop))) {
+ l = g_list_last(*list_sch);
+ _veve_list[i].func(ver, ((cal_struct *)(l->data))->user_data, cont);
+ break;
+ }
+ }
+ }
+
+ if (prop) free(prop);
+ prop = NULL;
+ if (cont) free(cont);
+ cont = NULL;
+
}
- return true;
-CATCH:
+ if (prop) free(prop);
+ if (cont) free(cont);
+ return cursor;
+}
+
+/*TODO: vtodo is same as vevent */
+char *cals_func_vtodo(int ver, GList **list_sch, void *data)
+{
+ int i;
+ char *prop, *cont;
+ char *cursor = (char *)data;
+ GList *l;
+ cal_struct *cs;
+ cal_sch_full_t *sch;
+
+ sch = calloc(1, sizeof(cal_sch_full_t));
+ retvm_if(sch == NULL, NULL, "Failed to alloc cal_sch_full_t");
+ cals_todo_init(sch);
+
+ cs = calloc(1, sizeof(cal_struct));
+ retvm_if(cs == NULL, NULL, "Failed to alloc cal_struct");
+ cs->event_type = CAL_STRUCT_TYPE_SCHEDULE;
+ cs->user_data = sch;
+
+ *list_sch = g_list_append(*list_sch, cs);
+
+ /* do until meet BEGIN */
+ while ((cursor = cals_read_line(cursor, &prop, &cont))) {
+ if (!strncmp(prop, "BEGIN", strlen("BEGIN"))) {
+
+ if (!strncmp(cont + 1, "VALARM", strlen("VALARM"))) {
+ cursor = cals_func_valarm(sch, cursor);
+ } else {
+ break;
+ }
+
+ } else if (!strncmp(prop, "END", strlen("END"))) {
+ break;
+
+ } else {
+ for (i = 0; i < VEVE_MAX; i++) {
+ if (!strncmp(prop, _veve_list[i].prop, strlen(_veve_list[i].prop))) {
+ l = g_list_last(*list_sch);
+ _veve_list[i].func(ver, ((cal_struct *)(l->data))->user_data, cont);
+ break;
+ }
+ }
+ }
+
+ if (prop) free(prop);
+ prop = NULL;
+ if (cont) free(cont);
+ cont = NULL;
+
+ }
- return false;
+ if (prop) free(prop);
+ if (cont) free(cont);
+ return cursor;
}
-int cal_vcalendar_register_vcs_file(const char * file_name)
+char *cals_func_valarm(cal_sch_full_t *sch, void *data)
{
- int ret, i = 0;
- bool is_success = false;
- cal_sch_full_t * sch_array = NULL;
- int sch_count = 0;
- int error_code = 0;
- int index = 0;
- is_success = cal_convert_vdata_file_to_cal_data( file_name, &sch_array, &sch_count, &error_code);
- retex_if(!is_success,,"[ERROR]Falied to convert to cal!\n");
+ int i;
+ char *prop, *cont;
+ char *cursor = (char *)data;
- // get data
- if ((sch_array != NULL) && (sch_count != 0))
- {
- CALS_DBG("\n-------------------------get a sch from vcalendar ---------------------------------\n");
+ cal_value *val;
+ val = calendar_svc_value_new(CAL_VALUE_LST_ALARM);
+ sch->alarm_list = g_list_append(sch->alarm_list, val);
- calendar_svc_connect();
+ while ((cursor = cals_read_line(cursor, &prop, &cont))) {
+ if (!strncmp(prop, "BEGIN", strlen("BEGIN"))) {
+ break;
- for ( i = 0; i < sch_count; i++)
- {
- CALS_DBG("\n--------------------------begin to store it in DB--------------------------------\n");
- if (sch_array[i].cal_type == CAL_EVENT_TODO_TYPE)
- ret = cals_insert_schedule(sch_array + i);
- else
- ret = cals_insert_schedule(sch_array + i);
- retvm_if(ret < CAL_SUCCESS, ret, "cals_insert_schedule() Failed(%d)", ret);
- index = ret;
+ } else if (!strncmp(prop, "END", strlen("END"))) {
+ break;
- CALS_DBG("\n--------------------------success store it in DB--------------------------------\n");
}
+ for (i = 0; i < VALA_MAX; i++) {
+ if (!strncmp(prop, _vala_list[i].prop, strlen(_vala_list[i].prop))) {
+ _vala_list[i].func(sch, cont);
+ break;
+ }
+ }
+ if (prop) {
+ free(prop);
+ prop = NULL;
+ }
+ if (cont) {
+ free(cont);
+ cont = NULL;
+ }
}
- if ( sch_array != NULL )
- {
- cal_db_service_free_full_record(sch_array,&error_code);
- CAL_FREE(sch_array);
+ if (prop) free(prop);
+ if (cont) free(cont);
+
+ return cursor;
+}
+
+
+/* vcalendar */////////////////////////////////////////////////
+
+int cals_func_prodid(GList **list_sch, void *data)
+{
+ return 0;
+}
+
+int cals_func_version(GList **list_sch, void *data)
+{
+ char *p = (char *)data;
+
+ p++;
+ if (!strncmp(p, "1.0", strlen("1.0"))) {
+ return 1;
+ } else if (!strncmp(p, "2.0", strlen("2.0"))) {
+ return 2;
+ } else {
+ return -1;
}
+ return 0;
+}
+
+/* vevnt */////////////////////////////////////////////////
+int cals_func_dtstamp(int ver, cal_sch_full_t *sch, void *data)
+{
+ return 0;
+}
+
+int cals_func_dtstart(int ver, cal_sch_full_t *sch, void *data)
+{
+ char *p = (char *)data;
+ int k = 0, j;
+ int y, mon, d, h, min, s;
+ char buf[64] = {0, };
+ char tmp[64] = {0, };
+
+ p++;
- CALS_DBG("-----------------exit-cal_vcalendar_register_vcs_file-------------------\n");
- calendar_svc_close();
- return index;
+ if (!strncmp(p, "TZID=", strlen("TZID="))) {
+ k = 0;
+ j = 0;
+ while (p[j] != ':' && p[j] != ';' && p[j] != '\n' && p[j] != '\0') {
+ buf[k] = p[j];
+ k++;
+ j++;
+ }
+ if (p[j] != '\0') {
+ buf[k] = '\0';
+ }
+ p += j;
+ p++;
+ sch->dtstart_tzid = strdup(buf);
+ } else {
+ sch->dtstart_tzid = strdup("Europe/London");
+ }
-CATCH:
+ if (!strncmp(p, "VALUE=", strlen("VALUE="))) {
+ k = 0;
+ j = strlen("VALUE=");
+ while (p[j] != ':' && p[j] != ';' && p[j] != '\n' && p[j] != '\0') {
+ buf[k] = p[j];
+ k++;
+ j++;
+ }
+ if (p[j] != '\0') {
+ buf[k] = '\0';
+ }
+ p += j;
+ p++;
+ }
- calendar_svc_close();
+ if (!strncmp(buf, "DATE", strlen("DATE"))){
+ snprintf(tmp, 5, "%s", p);
+ sch->dtstart_year = atoi(tmp);
+ snprintf(tmp, 3, "%s", p + 4);
+ sch->dtstart_month = atoi(tmp);
+ snprintf(tmp, 3, "%s", p + 6);
+ sch->dtstart_mday = atoi(tmp);
- if ( sch_array != NULL )
- {
- cal_db_service_free_full_record(sch_array,&error_code);
- CAL_FREE(sch_array);
+ } else {
+ snprintf(tmp, 5, "%s", p);
+ y = atoi(tmp);
+ snprintf(tmp, 3, "%s", p + 4);
+ mon = atoi(tmp);
+ snprintf(tmp, 3, "%s", p + 6);
+ d = atoi(tmp);
+ snprintf(tmp, 3, "%s", p + 9);
+ h = atoi(tmp);
+ snprintf(tmp, 3, "%s", p + 11);
+ min = atoi(tmp);
+ snprintf(tmp, 3, "%s", p + 13);
+ s = atoi(tmp);
+ sch->dtstart_utime = cals_time_date_to_utime(sch->dtstart_tzid,
+ y, mon, d, h, min, s);
}
+ return 0;
+}
+
+int cals_func_uid(int ver, cal_sch_full_t *sch, void *data)
+{
+ return 0;
+}
+
+int cals_func_class(int ver, cal_sch_full_t *sch, void *data)
+{
+ return 0;
+}
+
+int cals_func_created(int ver, cal_sch_full_t *sch, void *data)
+{
+ char *p = (char *)data;
- return -1;
+ p++;
+ sch->created_time = _datetime_to_utime(p);
+ return 0;
}
+int cals_func_description(int ver, cal_sch_full_t *sch, void *data)
+{
+ char *p = (char *)data;
+ int encoding = 0;
+ while (*p != '\n' && *p != '\r' && *p != '\0') {
+ if ( *p == ':') {
+ p++;
+ if (encoding == ENCODE_BASE64) {
+ gsize len;
+ sch->description = strdup((char *)g_base64_decode(p, &len));
+
+ } else if (encoding == ENCODE_QUOTED_PRINTABLE) {
+ if (ver == 1) {
+ int len;
+ cals_quoted_printable_decode(p, &len);
+ sch->description = strdup(p);
+ } else {
+ CALS_DBG("only ver1.0 supports quoted printable\n");
+ sch->summary = strdup(p);
+ }
+
+ } else {
+ sch->description = strdup(p);
+
+ }
+
+ } else if (*p == ';') {
+ p++;
+ cals_get_optional_parameter(p, &encoding);
+
+ } else {
+ p++;
+ }
+ }
+ return 0;
+}
+
+int cals_func_geo(int ver, cal_sch_full_t *sch, void *data)
+{
+ return 0;
+}
+
+int cals_func_last_mod(int ver, cal_sch_full_t *sch, void *data)
+{
+ char *p = (char *)data;
+
+ p++;
+ sch->last_mod = _datetime_to_utime(p);
+ return 0;
+}
+
+int cals_func_location(int ver, cal_sch_full_t *sch, void *data)
+{
+ char *p = (char *)data;
+ int encoding = 0;
+
+ while (*p != '\n' && *p != '\r' && *p != '\0') {
+ if ( *p == ':') {
+ p++;
+ if (encoding == ENCODE_BASE64) {
+ gsize len;
+ sch->location = strdup((char *)g_base64_decode(p, &len));
+
+ } else if (encoding == ENCODE_QUOTED_PRINTABLE) {
+ if (ver == 1) {
+ int len;
+ cals_quoted_printable_decode(p, &len);
+ sch->location = strdup(p);
+ } else {
+ CALS_DBG("only ver1.0 supports quoted printable\n");
+ sch->summary = strdup(p);
+ }
+
+ } else {
+ sch->location = strdup(p);
+
+ }
+
+ } else if (*p == ';') {
+ p++;
+ cals_get_optional_parameter(p, &encoding);
+
+ } else {
+ p++;
+ }
+ }
+ return 0;
+}
+
+int cals_func_organizer(int ver, cal_sch_full_t *sch, void *data)
+{
+ return 0;
+}
+
+int cals_func_priority(int ver, cal_sch_full_t *sch, void *data)
+{
+ char *p = (char *)data;
+
+ p++;
+ sch->priority = 0; /* default */
+ if (p[0] >= '0' && p[0] <= '9') {
+ sch->priority = atoi(p);
+ } else {
+ CALS_DBG("warning check range\n");
+ }
+ return 0;
+}
+
+int cals_func_seq(int ver, cal_sch_full_t *sch, void *data)
+{
+ return 0;
+}
+
+int cals_func_status(int ver, cal_sch_full_t *sch, void *data)
+{
+ char *p = (char *)data;
+
+ p++;
+ if (sch->cal_type == CALS_SCH_TYPE_TODO) {
+ if (!strncmp(p, "NEEDS-ACTION", strlen("NEEDS-ACTION"))) {
+ } else if (!strncmp(p, "COMPLETED", strlen("COMPLETED"))) {
+ sch->task_status = CALS_TODO_STATUS_NEEDS_ACTION;
+ } else if (!strncmp(p, "IN-PROCESS", strlen("IN-PROCESS"))) {
+ sch->task_status = CALS_TODO_STATUS_IN_PROCESS;
+ } else if (!strncmp(p, "CANCELLED", strlen("CANCELLED"))) {
+ sch->task_status = CALS_TODO_STATUS_CANCELLED;
+ } else {
+ sch->task_status = CALS_TODO_STATUS_NONE;
+ }
+ } else if (sch->cal_type == CALS_SCH_TYPE_EVENT ) {
+ if (!strncmp(p, "TENTATIVE", strlen("TENTATIVE"))) {
+ sch->task_status = CALS_EVENT_STATUS_TENTATIVE;
+ } else if (!strncmp(p, "CONFIRMED", strlen("CONFIRMED"))) {
+ sch->task_status = CALS_EVENT_STATUS_CONFIRMED;
+ } else if (!strncmp(p, "CANCELLED", strlen("CANCELLED"))) {
+ sch->task_status = CALS_EVENT_STATUS_CANCELLED;
+ } else {
+ sch->task_status = CALS_EVENT_STATUS_NONE;
+ }
+ }
+
+ return 0;
+}
+
+int cals_func_summary(int ver, cal_sch_full_t *sch, void *data)
+{
+ char *p = (char *)data;
+ int encoding = 0;
+
+ while (*p != '\n' && *p != '\r' && *p != '\0') {
+ if ( *p == ':') {
+ p++;
+ if (encoding == ENCODE_BASE64) {
+ gsize len;
+ sch->summary = strdup((char *)g_base64_decode(p, &len));
+
+ } else if (encoding == ENCODE_QUOTED_PRINTABLE) {
+ if (ver == 1) {
+ int len;
+ cals_quoted_printable_decode(p, &len);
+ sch->summary = strdup(p);
+ } else {
+ CALS_DBG("only ver1.0 supports quoted printable\n");
+ sch->summary = strdup(p);
+ }
+
+ } else {
+ sch->summary = strdup(p);
+ }
+ break;
+
+ } else if (*p == ';') {
+ p++;
+ cals_get_optional_parameter(p, &encoding);
+
+ } else {
+ p++;
+ }
+ }
+ DBG("ver(%d)summary(%s)\n", ver, sch->summary);
+
+ return 0;
+}
+
+int cals_func_transp(int ver, cal_sch_full_t *sch, void *data)
+{
+ return 0;
+}
+
+int cals_func_url(int ver, cal_sch_full_t *sch, void *data)
+{
+ return 0;
+}
+
+int cals_func_recurid(int ver, cal_sch_full_t *sch, void *data)
+{
+ return 0;
+}
+
+int cals_func_rrule(int ver, cal_sch_full_t *sch, void *data)
+{
+ int i = 0, k = 0;
+ char *p = (char *)data;
+
+ p++;
+ while (*p != '\n' && *p != '\r' && *p != '\0') {
+ if (*p == ':' || *p == ';' || k == 0) {
+ p += k;
+ k = 1;
+
+ switch (ver) {
+ case 1:
+ for (i = 0; i < RRULE_MAX; i++) {
+ if (!strncmp(p, _rrule_list[i].prop, strlen(_rrule_list[i].prop))) {
+ int j = 0;
+ char buf[64] = {0, };
+ p += strlen(_rrule_list[i].prop);
+ while (p[j] != ';' && p[j] != '\n' && p[j] != '\0') {
+ buf[j] = p[j];
+ j++;
+ }
+ if (p[j] != '\0') {
+ buf[j] = '\0';
+ }
+ p += j;
+ _rrule_list[i].func(sch, buf);
+ break;
+ }
+ }
+ break;
+
+ case 2:
+ /* Suppose vcalendar 1.0, if p == data */
+ if ((p - 1) == (char *)data) {
+ cals_ver1_func_rrule(sch, p);
+ }
+ break;
+ }
+ } else {
+ p++;
+ }
+ }
+
+ return 0;
+}
+
+int cals_func_dtend(int ver, cal_sch_full_t *sch, void *data)
+{
+ char *p = (char *)data;
+ int k = 0, j;
+ int y, mon, d, h, min, s;
+ char buf[64] = {0, };
+ char tmp[64] = {0, };
+
+ p++;
+
+ if (!strncmp(p, "TZID=", strlen("TZID="))) {
+ k = 0;
+ j = 0;
+ while (p[j] != ':' && p[j] != ';' && p[j] != '\n' && p[j] != '\0') {
+ buf[k] = p[j];
+ k++;
+ j++;
+ }
+ if (p[j] != '\0') {
+ buf[k] = '\0';
+ }
+ p += j;
+ p++;
+ sch->dtend_tzid = strdup(buf);
+ } else {
+ sch->dtend_tzid = strdup("Europe/London");
+ }
+
+ if (!strncmp(p, "VALUE=", strlen("VALUE="))) {
+ k = 0;
+ j = strlen("VALUE=");
+ while (p[j] != ':' && p[j] != ';' && p[j] != '\n' && p[j] != '\0') {
+ buf[k] = p[j];
+ k++;
+ j++;
+ }
+ if (p[j] != '\0') {
+ buf[k] = '\0';
+ }
+ p += j;
+ p++;
+ }
+
+ if (!strncmp(buf, "DATE", strlen("DATE"))){
+ snprintf(tmp, 5, "%s", p);
+ sch->dtend_year = atoi(tmp);
+ snprintf(tmp, 3, "%s", p + 4);
+ sch->dtend_month = atoi(tmp);
+ snprintf(tmp, 3, "%s", p + 6);
+ sch->dtend_mday = atoi(tmp);
+
+ } else {
+ snprintf(tmp, 5, "%s", p);
+ y = atoi(tmp);
+ snprintf(tmp, 3, "%s", p + 4);
+ mon = atoi(tmp);
+ snprintf(tmp, 3, "%s", p + 6);
+ d = atoi(tmp);
+ snprintf(tmp, 3, "%s", p + 9);
+ h = atoi(tmp);
+ snprintf(tmp, 3, "%s", p + 11);
+ min = atoi(tmp);
+ snprintf(tmp, 3, "%s", p + 13);
+ s = atoi(tmp);
+ sch->dtend_utime = cals_time_date_to_utime(sch->dtend_tzid,
+ y, mon, d, h, min, s);
+ }
+ return 0;
+}
+
+int cals_func_duration(int ver, cal_sch_full_t *sch, void *data)
+{
+ return 0;
+}
+
+int cals_func_attach(int ver, cal_sch_full_t *sch, void *data)
+{
+ return 0;
+}
+
+int cals_func_attendee(int ver, cal_sch_full_t *sch, void *data)
+{
+ return 0;
+}
+
+int cals_func_categories(int ver, cal_sch_full_t *sch, void *data)
+{
+ CALS_FN_CALL;
+ char *p = (char *)data;
+ int encoding = 0;
+
+ while (*p != '\n' && *p != '\r' && *p != '\0') {
+ if ( *p == ':') {
+ p++;
+ if (encoding == ENCODE_BASE64) {
+ gsize len;
+ sch->categories = strdup((char *)g_base64_decode(p, &len));
+
+ } else if (encoding == ENCODE_QUOTED_PRINTABLE) {
+ if (ver == 1) {
+ int len;
+ cals_quoted_printable_decode(p, &len);
+ sch->categories = strdup(p);
+ } else {
+ CALS_DBG("only ver1.0 supports quoted printable\n");
+ sch->categories = strdup(p);
+ }
+
+ } else {
+ sch->categories = strdup(p);
+ }
+ break;
+
+ } else if (*p == ';') {
+ p++;
+ cals_get_optional_parameter(p, &encoding);
+
+ } else {
+ p++;
+ }
+ }
+ DBG("ver(%d)categories(%s)\n", ver, sch->categories);
+
+ return 0;
+}
+
+int cals_func_comment(int ver, cal_sch_full_t *sch, void *data)
+{
+ return 0;
+}
+
+int cals_func_contact(int ver, cal_sch_full_t *sch, void *data)
+{
+ return 0;
+}
+
+int cals_func_exdate(int ver, cal_sch_full_t *sch, void *data)
+{
+ return 0;
+}
+/*
+int cals_func_status(int ver, cal_sch_full_t *sch, void *data)
+{
+ return 0;
+}
+*/
+int cals_func_related(int ver, cal_sch_full_t *sch, void *data)
+{
+ return 0;
+}
+
+int cals_func_resources(int ver, cal_sch_full_t *sch, void *data)
+{
+ return 0;
+}
+
+int cals_func_rdate(int ver, cal_sch_full_t *sch, void *data)
+{
+ return 0;
+}
+
+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"};
+
+/* for vcalendar version 1.0 */
+int cals_ver1_func_rrule(cal_sch_full_t *sch, void *data)
+{
+ char *p = (char *)data;
+ int i = 0, j = 0;
+ int column = 0, loop = 1;
+ int byint = -1; /* for by day:1 or by position:0 */
+ int y, mon, d, h, min, s;
+ char buf[64] = {0, };
+ char tmp[8] = {0, };
+
+ while(loop) {
+ /* parse sentence */
+ i = 0;
+ while(p[i] != '\n' && p[i] != '\0' && p[i] != ' ') {
+ buf[i] = p[i];
+ i++;
+ }
+ buf[i] = '\n';
+
+ /* exit when sentence ends */
+ if (p[i] == '\n' || p[i] == '\0') {
+ loop = 0;
+ }
+
+
+ if (column == 0) {
+ column++;
+
+ /* freq */
+ if (buf[0] == 'D') {
+ sch->freq = CALS_FREQ_DAILY;
+
+ } else if (buf[0] == 'W') {
+ sch->freq = CALS_FREQ_WEEKLY;
+
+ } else if (buf[0] == 'M') {
+ sch->freq = CALS_FREQ_MONTHLY;
+
+ } else if (buf[0] == 'Y') {
+ sch->freq = CALS_FREQ_YEARLY;
+
+ } else {
+ sch->freq = CALS_FREQ_ONCE;
+
+ }
+
+ /* interval */
+ if (buf[1] == 'P') {
+ byint = 0;
+ sch->interval = atoi(&buf[2]);
+
+ } else if (buf[1] == 'D') {
+ byint = 1;
+ sch->interval = atoi(&buf[2]);
+
+ } else {
+ sch->interval = atoi(&buf[1]);
+
+ }
+ DBG("interval(%d)\n", sch->interval);
+
+ } else {
+ if (buf[0] == '#') {
+ /* occurrences */
+ sch->count = atoi(&buf[1]);
+ DBG("occur(%d)\n", sch->count);
+
+ } else if (strlen(buf) < 3) {
+ /* get by-day: TODO:not supported byday*/
+ if (byint == 0) {
+
+ } else if (byint == 1) {
+
+ } else {
+
+ }
+
+ } else if (strlen(buf) >= strlen("YYYYMMDDTHHMMSS")) {
+ sch->until_type = CALS_TIME_UTIME;
+ snprintf(tmp, 5, "%s", buf);
+ y = atoi(tmp);
+ snprintf(tmp, 3, "%s", buf + 4);
+ mon = atoi(tmp);
+ snprintf(tmp, 3, "%s", buf + 6);
+ d = atoi(tmp);
+ snprintf(tmp, 3, "%s", buf + 9);
+ h = atoi(tmp);
+ snprintf(tmp, 3, "%s", buf + 11);
+ min = atoi(tmp);
+ snprintf(tmp, 3, "%s", buf + 13);
+ s = atoi(tmp);
+ sch->until_utime = cals_time_date_to_utime(sch->dtstart_tzid,
+ y, mon, d, h, min, s);
+ DBG("until(%s)\n", buf);
+
+ } else {
+ /* get repeat week day */
+ char buf_w[64] = {0};
+ for (j = 0; j < WEEKNAME2_MAX; j++) {
+ if(!strncmp(buf, weekname2[j], strlen(weekname2[j]))) {
+ if (strlen(buf_w) != 0) {
+ strcat(buf_w, ", ");
+ }
+ strcat(buf_w, weekname2[j]);
+ }
+ }
+ sch->byday = strdup(buf_w);
+ }
+ }
+
+ p += i;
+ p++;
+ }
+ return 0;
+}
+
+//alarm////////////////////////////////////////////////////////////
+int cals_func_action(cal_sch_full_t *sch, void *data)
+{
+ return 0;
+}
+
+char *cals_convert_sec_from_duration(char *p, int *dur_t, char *dur)
+{
+ char du = '0';
+ char buf[8] = {0, };
+ int i = 0, c, d = 1;
+ int t = 0;
+
+ CALS_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++;
+ break;
+
+ }
+ p++;
+ }
+ t *= d;
+ *dur_t = t;
+
+ if (dur) {
+ *dur = du;
+ }
+
+ return p;
+}
+
+int cals_func_trigger(cal_sch_full_t *sch, void *data)
+{
+ int i = 0, out = 0;
+ char *p = (char *)data;
+ long long int dtstart_utime;
+ int dur_t;
+ cal_value *val;
+ cal_alarm_info_t *alarm;
+ GList *l;
+
+ p++;
+ l = g_list_last(sch->alarm_list);
+ if (l == NULL) {
+ return -1;
+ }
+ val = (cal_value *)l->data;
+ alarm = (cal_alarm_info_t *)val->user_data;
+ dtstart_utime = sch->dtstart_utime;
+
+ while (*p != '\n' && *p != '\r' && *p != '\0') {
+
+ for (i = 0; i < TRIG_MAX; i++) {
+ if (!strncmp(p, _trig_list[i].prop, strlen(_trig_list[i].prop))) {
+ out = 1;
+ int j = 0;
+ char buf[64] = {0, };
+ p += strlen(_trig_list[i].prop);
+ while (p[j] != ';' && p[j] != '\n' && p[j] != '\0') {
+ buf[j] = p[j];
+ j++;
+ }
+ if (p[j] != '\0') {
+ buf[j] = '\0';
+ }
+
+ p += j;
+ _trig_list[i].func(sch, buf);
+ break;
+ }
+ }
+ if (out == 1) {
+ break;
+ }
+ p = cals_convert_sec_from_duration(p, &dur_t, NULL);
+ alarm->alarm_time = dtstart_utime + (long long int)dur_t;
+ break;
+ }
+ return 0;
+}
+
+int cals_func_repeat(cal_sch_full_t *sch, void *data)
+{
+ return 0;
+}
+
+int cals_func_duration_alarm(cal_sch_full_t *sch, void *data)
+{
+ char *p = (char *)data;
+ char dur;
+ int dur_t;
+ cal_value *val;
+ cal_alarm_info_t *alarm = NULL;
+ GList *l;
+
+ p++;
+ l = g_list_last(sch->alarm_list);
+ if (l) {
+ val = (cal_value *)l->data;
+ alarm = (cal_alarm_info_t *)val->user_data;
+
+ cals_convert_sec_from_duration(p, &dur_t, &dur);
+ switch (dur) {
+ case 'W':
+ alarm->remind_tick = dur_t/(7 *24 *60 *60);
+ alarm->remind_tick_unit = CAL_SCH_TIME_UNIT_WEEK;
+ break;
+ case 'D':
+ alarm->remind_tick = dur_t/(24 *60 *60);
+ alarm->remind_tick_unit = CAL_SCH_TIME_UNIT_DAY;
+ break;
+ case 'H':
+ alarm->remind_tick = dur_t/(60 *60);
+ alarm->remind_tick_unit = CAL_SCH_TIME_UNIT_HOUR;
+ break;
+ case 'M':
+ alarm->remind_tick = dur_t/(60);
+ alarm->remind_tick_unit = CAL_SCH_TIME_UNIT_MIN;
+ break;
+ default:
+ alarm->remind_tick = 1;
+ alarm->remind_tick_unit = 0;
+ break;
+ }
+ }
+ DBG("tick:%d\n", alarm->remind_tick);
+ DBG("unit:%c\n", dur);
+ return 0;
+}
+
+int cals_func_attach_alarm(cal_sch_full_t *sch, void *data)
+{
+ return 0;
+}
+
+int cals_func_summary_alarm(cal_sch_full_t *sch, void *data)
+{
+ char *p = (char *)data;
+ cal_value *val;
+ cal_alarm_info_t *alarm;
+ GList *l;
+
+ p++;
+ l = g_list_last(sch->alarm_list);
+ if (l) {
+ val = (cal_value *)l->data;
+ alarm = (cal_alarm_info_t *)val->user_data;
+
+ alarm->alarm_description = strdup(p);
+ }
+ return 0;
+}
+
+
+//rrule////////////////////////////////////////////////////////////
+int cals_func_freq(cal_sch_full_t *sch, void *data)
+{
+ char *p = (char *)data;
+
+ DBG("%s\n", (char *)data);
+ if (!strncmp(p, "YEARLY", strlen("YEARLY"))) {
+ sch->freq = CALS_FREQ_YEARLY;
+
+ } else if (!strncmp(p, "MONTHLY", strlen("MONTHLY"))) {
+ sch->freq = CALS_FREQ_MONTHLY;
+
+ } else if (!strncmp(p, "WEEKLY", strlen("WEEKLY"))) {
+ sch->freq = CALS_FREQ_WEEKLY;
+
+ } else if (!strncmp(p, "DAILY", strlen("DAILY"))) {
+ sch->freq = CALS_FREQ_DAILY;
+
+ } else if (!strncmp(p, "HOURLY", strlen("HOURLY"))) {
+ sch->freq = CALS_FREQ_ONCE;
+
+ } else if (!strncmp(p, "MINUTELY", strlen("MINUTELY"))) {
+ sch->freq = CALS_FREQ_ONCE;
+
+ } else if (!strncmp(p, "SECONDLY", strlen("SECONDLY"))) {
+ sch->freq = CALS_FREQ_ONCE;
+
+ } else {
+ sch->freq = CALS_FREQ_ONCE;
+
+ }
+ return 0;
+}
+
+int cals_func_until(cal_sch_full_t *sch, void *data)
+{
+ int y, mon, d, h, min, s;
+ char *p = (char *)data;
+ char buf[8] = {0};
+
+ /* until value type has the same value as the dtstart */
+ sch->range_type = CALS_RANGE_UNTIL;
+ if (sch->dtstart_utime) {
+ sch->until_type = CALS_TIME_UTIME;
+ snprintf(buf, 5, "%s", p);
+ y = atoi(buf);
+ snprintf(buf, 3, "%s", p + 4);
+ mon = atoi(buf);
+ snprintf(buf, 3, "%s", p + 6);
+ d = atoi(buf);
+ snprintf(buf, 3, "%s", p + 9);
+ h = atoi(buf);
+ snprintf(buf, 3, "%s", p + 11);
+ min = atoi(buf);
+ snprintf(buf, 3, "%s", p + 13);
+ s = atoi(buf);
+ sch->until_utime = cals_time_date_to_utime(sch->dtstart_tzid,
+ y, mon, d, h, min, s);
+
+ } else {
+ sch->until_type = CALS_TIME_LOCALTIME;
+ snprintf(buf, strlen("YYYY") + 1, "%s", p);
+ sch->until_year = atoi(buf);
+ snprintf(buf, strlen("MM") + 1, "%s", p + 4);
+ sch->until_month = atoi(buf);
+ snprintf(buf, strlen("DD") + 1, "%s", p + 6);
+ sch->until_mday = atoi(buf);
+
+ }
+ return 0;
+}
+
+int cals_func_count(cal_sch_full_t *sch, void *data)
+{
+ int c;
+ char *p = (char *)data;
+
+ DBG("%s\n", (char *)data);
+ sch->range_type = CALS_RANGE_COUNT;
+ c = atoi(p);
+ sch->count = c < 0 ? 0 : c;
+ return 0;
+}
+
+int cals_func_interval(cal_sch_full_t *sch, void *data)
+{
+ int c;
+ char *p = (char *)data;
+
+ DBG("%s\n", (char *)data);
+ c = atoi(p);
+ sch->interval = c < 0 ? 0 : c;
+ return 0;
+}
+
+int cals_func_bysecond(cal_sch_full_t *sch, void *data)
+{
+ CALS_DBG("%s\n", (char *)data);
+ char *p = (char *)data;
+ sch->bysecond = strdup(p);
+ return 0;
+}
+
+int cals_func_byminute(cal_sch_full_t *sch, void *data)
+{
+ CALS_DBG("%s\n", (char *)data);
+ char *p = (char *)data;
+ sch->byminute = strdup(p);
+ return 0;
+}
+
+int cals_func_byhour(cal_sch_full_t *sch, void *data)
+{
+ CALS_DBG("%s\n", (char *)data);
+ char *p = (char *)data;
+ sch->byhour = strdup(p);
+ return 0;
+}
+
+int cals_func_byday(cal_sch_full_t *sch, void *data)
+{
+ CALS_DBG("%s\n", (char *)data);
+ char *p = (char *)data;
+ sch->byday = strdup(p);
+ return 0;
+}
+
+int cals_func_bymonthday(cal_sch_full_t *sch, void *data)
+{
+ CALS_DBG("%s\n", (char *)data);
+ char *p = (char *)data;
+ sch->bymonthday = strdup(p);
+ return 0;
+}
+
+int cals_func_byyearday(cal_sch_full_t *sch, void *data)
+{
+ CALS_DBG("%s\n", (char *)data);
+ char *p = (char *)data;
+ sch->byyearday = strdup(p);
+ return 0;
+}
+
+int cals_func_byweekno(cal_sch_full_t *sch, void *data)
+{
+ CALS_DBG("%s\n", (char *)data);
+ char *p = (char *)data;
+ sch->byweekno = strdup(p);
+ return 0;
+}
+
+int cals_func_bymonth(cal_sch_full_t *sch, void *data)
+{
+ CALS_DBG("%s\n", (char *)data);
+ char *p = (char *)data;
+ sch->bymonth = strdup(p);
+ return 0;
+}
+
+int cals_func_bysetpos(cal_sch_full_t *sch, void *data)
+{
+ CALS_DBG("%s\n", (char *)data);
+ char *p = (char *)data;
+ sch->bysetpos = strdup(p);
+ return 0;
+}
+
+int cals_func_wkst(cal_sch_full_t *sch, void *data)
+{
+ CALS_DBG("%s\n", (char *)data);
+
+ char *p = (char *)data;
+
+ if (!strncmp(p, "SU", strlen("SU"))) {
+ sch->wkst = CALS_SUNDAY;
+
+ } else if (!strncmp(p, "MO", strlen("MO"))) {
+ sch->wkst = CALS_MONDAY;
+
+ } else if (!strncmp(p, "TU", strlen("TU"))) {
+ sch->wkst = CALS_TUESDAY;
+
+ } else if (!strncmp(p, "WE", strlen("WE"))) {
+ sch->wkst = CALS_WEDNESDAY;
+
+ } else if (!strncmp(p, "TH", strlen("TH"))) {
+ sch->wkst = CALS_THURSDAY;
+
+ } else if (!strncmp(p, "FR", strlen("FR"))) {
+ sch->wkst = CALS_FRIDAY;
+
+ } else if (!strncmp(p, "SA", strlen("SA"))) {
+ sch->wkst = CALS_SATURDAY;
+
+ }
+ return 0;
+}
+
+int cals_func_related_trig(cal_sch_full_t *sch, void *data)
+{
+ CALS_DBG("%s\n", (char *)data);
+ return 0;
+}
+
+int cals_func_value(cal_sch_full_t *sch, void *data)
+{
+ CALS_DBG("%s\n", (char *)data);
+ return 0;
+}
+
+int cals_func_charset(int *val, void *data)
+{
+ CALS_DBG("%s\n", (char *)data);
+ return 0;
+}
+
+int cals_func_encoding(int *val, void *data)
+{
+ char *p = (char *)data;
+ *val = 0;
+
+ if (!strncmp(p, "BASE64", strlen("BASE64"))) {
+ *val = ENCODE_BASE64;
+
+ } else if (!strncmp(p, "QUOTED-PRINTABLE", strlen("QUOTED-PRINTABLE"))){
+ *val = ENCODE_QUOTED_PRINTABLE;
+
+ }
+ return 0;
+}
+
+struct buf {
+ int size;
+ char *data;
+ char lbuf[76];
+};
+
+#define _strlen(s) (((s) && *(s)) ? strlen(s) : 0)
+
+static inline int _alloc(struct buf *b, int n)
+{
+ b->data = realloc(b->data, b->size + n);
+
+ retvm_if(!b->data, CAL_ERR_OUT_OF_MEMORY, "Out of memory error");
+ b->size += n;
+
+ return CAL_SUCCESS;
+}
+
+
+static struct buf *cal_svc_buf_new()
+{
+ struct buf *b;
+
+ b = calloc(1, sizeof(struct buf));
+ if (!b) {
+ return NULL;
+ }
+
+ b->data = malloc(sizeof(char));
+ if (!b->data) {
+ free(b);
+ return NULL;
+ }
+
+ *b->data = '\0';
+ b->size = 1;
+
+ return b;
+}
+
+
+static void cal_svc_buf_free(struct buf **b)
+{
+ if (!b || !*b)
+ return;
+
+ if ((*b)->data)
+ free((*b)->data);
+
+ free(*b);
+ b = NULL;
+}
+
+static inline int _flush(struct buf *b)
+{
+ int r;
+ r = _alloc(b, _strlen(b->lbuf) + 2);
+ retv_if(r < CAL_SUCCESS, r);
+
+ strncat(b->data, b->lbuf, b->size - _strlen(b->data) - 1);
+ strncat(b->data, "\r\n", b->size - _strlen(b->data) - 1);
+ *b->lbuf = '\0';
+ return CAL_SUCCESS;
+}
+
+static inline int _fold(struct buf *b)
+{
+ int r;
+ r = _alloc(b, _strlen(b->lbuf) + 3);
+ retv_if(r < CAL_SUCCESS, r);
+
+ strncat(b->data, b->lbuf, b->size - _strlen(b->data) - 1);
+ strncat(b->data, "\r\n ", b->size - _strlen(b->data) - 1);
+ *b->lbuf = '\0';
+ return CAL_SUCCESS;
+}
+
+static inline int _set_str(struct buf *b, const char *s)
+{
+ int remain_lbuf;
+ int remain_str;
+ int k;
+ int r;
+
+ remain_lbuf = sizeof(b->lbuf) - _strlen(b->lbuf);
+ remain_str = _strlen(s);
+
+ k = 0;
+ while ( remain_lbuf - 1 < remain_str) {
+ strncat(b->lbuf, s + k, remain_lbuf - 1);
+ k += remain_lbuf - 1;
+ remain_str -= remain_lbuf - 1;
+ r = _fold(b);
+ retv_if(r < CAL_SUCCESS, r);
+ remain_lbuf = sizeof(b->lbuf);
+ }
+
+ strncat(b->lbuf, s + k, remain_lbuf - 1);
+ return CAL_SUCCESS;
+}
+
+static inline int cal_svc_buf_flush(struct buf *b)
+{
+ return _flush(b);
+}
+
+static int cal_svc_buf_print(struct buf *b, const char *s1, const char *s2)
+{
+ int r;
+
+ if (s1) {
+ r = _set_str(b, s1);
+ retv_if(r < CAL_SUCCESS, r);
+ }
+
+ if (s2) {
+ r = _set_str(b, s2);
+ retv_if(r < CAL_SUCCESS, r);
+ }
+
+ return CAL_SUCCESS;
+}
+
+
+static int cal_svc_buf_printline(struct buf *b, const char *s1, const char *s2)
+{
+ int r;
+
+ if (s1) {
+ r = _set_str(b, s1);
+ retv_if(r < CAL_SUCCESS, r);
+ }
+
+ if (s2) {
+ r = _set_str(b, s2);
+ retv_if(r < CAL_SUCCESS, r);
+ }
+
+ return _flush(b);
+}
+
+
+static char *cal_svc_buf_get_data(struct buf *b)
+{
+ if (!b || !b->data)
+ return NULL;
+ return strdup(b->data);
+}
+
+static const char *vl_datetime(int y, int m, int d)
+{
+ static char buf[9];
+ snprintf(buf, sizeof(buf), "%04d%02d%02d", y, m, d);
+ return buf;
+}
+
+static const char *vl_dur(cal_sch_remind_tick_unit_t unit, int dur)
+{
+ static char buf[8];
+ int i = 0;
+ char d[5];
+
+ if (dur < 0) {
+ *buf = '-';
+ i++;
+ dur = -dur;
+ }
+
+ snprintf(d, sizeof(d), "%d", dur);
+
+ *(buf + i) = 'P';
+ i++;
+
+ switch (unit) {
+ case CAL_SCH_TIME_UNIT_WEEK:
+ snprintf(buf + i, sizeof(buf) - i, "%sW", d);
+ break;
+ case CAL_SCH_TIME_UNIT_DAY:
+ snprintf(buf + i, sizeof(buf) - i, "%sD", d);
+ break;
+ case CAL_SCH_TIME_UNIT_HOUR:
+ snprintf(buf + i, sizeof(buf) - i, "T%sH", d);
+ break;
+ case CAL_SCH_TIME_UNIT_MIN:
+ snprintf(buf + i, sizeof(buf) - i, "T%sM", d);
+ break;
+ default:
+ buf[0] = '\0';
+ }
+
+ return buf;
+}
+
+static inline int pr_dtstart_utime(struct buf *b, char *tzid, long long int lli)
+{
+ return cal_svc_buf_printline(b, "DTSTART:", cals_time_get_str_datetime(tzid, lli));
+}
+
+static inline int pr_dtstart_datetime(struct buf *b, int y, int m, int s)
+{
+ return cal_svc_buf_printline(b, "DTSTART:", vl_datetime(y, m, s));
+}
+
+static inline int pr_dtend_utime(struct buf *b, char *tzid, long long int lli)
+{
+ return cal_svc_buf_printline(b, "DTEND:", cals_time_get_str_datetime(tzid, lli));
+}
+
+static inline int pr_dtend_datetime(struct buf *b, int y, int m, int s)
+{
+ return cal_svc_buf_printline(b, "DTEND:", vl_datetime(y, m, s));
+}
+
+static inline int pr_created(struct buf *b, char *tzid, long long int t)
+{
+ return cal_svc_buf_printline(b, "CREATED:", cals_time_get_str_datetime(tzid, t));
+}
+
+
+static inline int pr_lastmod(struct buf *b, char *tzid, long long int lli)
+{
+ return cal_svc_buf_printline(b, "LAST-MODIFIED:", cals_time_get_str_datetime(tzid, lli));
+}
+
+/**
+ * Descriptive Component Properties
+ */
+
+static inline int pr_summary(struct buf *b, char *s)
+{
+ return cal_svc_buf_printline(b, "SUMMARY:", s);
+}
+
+static inline int pr_description(struct buf *b, char *s)
+{
+ return cal_svc_buf_printline(b, "DESCRIPTION:", s);
+}
+
+static inline int pr_location(struct buf *b, char *s)
+{
+ return cal_svc_buf_printline(b, "LOCATION:", s);
+}
+
+static inline int pr_priority(struct buf *b, int v)
+{
+ char tmp[2];
+ snprintf(tmp, sizeof(tmp), "%d", v);
+ return cal_svc_buf_printline(b, "PRIORITY:", tmp);
+}
+
+static inline int pr_class(struct buf *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;
+ }
+ return cal_svc_buf_printline(b, "CLASS:", c);
+}
+
+static inline int pr_transp(struct buf *b, int v)
+{
+ // TODO : Need to define enumeration of transp property
+ return cal_svc_buf_printline(b, "TRANSP:", v? "OPAQUE":"TRANSPARENT");
+}
+
+int pr_dtstamp(char *tzid, struct buf *b)
+{
+ return cal_svc_buf_printline(b, "DTSTAMP:", cals_time_get_str_datetime(tzid, cals_get_lli_now()));
+}
+
+static const char *_att_role[] = {
+ [EVENT_ATTENDEE_REQ_PARTICIPANT_ROLE] = "REQ-PARTICIPANT",
+ [EVENT_ATTENDEE_OPT_PARTICIPANT_ROLE] = "OPT-PARTICIPANT",
+ [EVENT_ATTENDEE_NON_PARTICIPANT_ROLE] = "NON-PARTICIPANT",
+ [EVENT_ATTENDEE_CHAIR_ROLE] = "CHAIR",
+};
+
+static const char *_att_st[] = {
+ [EVENT_ATTENDEE_NEEDS_ACTION_AT_STATUS] = "NEEDS-ACTION",
+ [EVENT_ATTENDEE_ACCEPTED_AT_STATUS] = "ACCEPTED",
+ [EVENT_ATTENDEE_DECLINED_AT_STATUS] = "DECLINED",
+ [EVENT_ATTENDEE_TENTATIVE_AT_STATUS] = "TENTATIVE",
+ [EVENT_ATTENDEE_DELEGATED_AT_STATUS] = "DELEGATED",
+ [EVENT_ATTENDEE_COMPLETED_AT_STATUS] = "COMPLETED",
+ [EVENT_ATTENDEE_IN_PROCESS_AT_STATUS] = "IN-PROCESS",
+};
+
+int pr_attendee(struct buf *b, cal_participant_info_t *att)
+{
+ int r;
+ if (!att->attendee_email)
+ return CAL_ERR_NO_DATA;
+
+ r = cal_svc_buf_print(b, "ATTENDEE", NULL);
+ retv_if(r < CAL_SUCCESS, r);
+
+ if (att->attendee_group && *att->attendee_group) {
+ r = cal_svc_buf_print(b, ";CUTYPE=", att->attendee_group);
+ retv_if(r < CAL_SUCCESS, r);
+ }
+
+ // TODO : NO 'member' member in cal_participant_info_t
+
+ r = cal_svc_buf_print(b, ";ROLE=", _att_role[att->attendee_role]);
+ retv_if(r < CAL_SUCCESS, r);
+
+ r = cal_svc_buf_print(b, ";PARTSTAT=", _att_st[att->attendee_status]);
+ retv_if(r < CAL_SUCCESS, r);
+
+ r = cal_svc_buf_print(b, ";RSVP=", att->attendee_rsvp?"TRUE":"FALSE");
+ retv_if(r < CAL_SUCCESS, r);
+
+ if (att->attendee_delegator_uri && *att->attendee_delegator_uri) {
+ r = cal_svc_buf_print(b, ";DELEGATED-TO=", att->attendee_delegator_uri);
+ retv_if(r < CAL_SUCCESS, r);
+ }
+
+ if (att->attendee_delegate_uri && *att->attendee_delegate_uri) {
+ r = cal_svc_buf_print(b, ";DELEGATED-FROM=", att->attendee_delegate_uri);
+ retv_if(r < CAL_SUCCESS, r);
+ }
+
+ // TODO : No 'sentby' member in cal_participant_info_t
+
+ if (att->attendee_name && *att->attendee_name) {
+ r = cal_svc_buf_print(b, ";CN=", att->attendee_name);
+ retv_if(r < CAL_SUCCESS, r);
+ }
+
+ return cal_svc_buf_printline(b, ":", att->attendee_email);
+}
+
+int pr_organizer(struct buf *b, char *cn, char *address)
+{
+ int r;
+
+ r = cal_svc_buf_print(b, "ORGANIZER", NULL);
+ retv_if(r < CAL_SUCCESS, r);
+ if (cn && *cn) {
+ r = cal_svc_buf_print(b, ";CN=", cn);
+ retv_if(r < CAL_SUCCESS, r);
+ }
+
+ return cal_svc_buf_printline(b, ":", address);
+}
+
+int pr_trigger(struct buf *b, cal_sch_remind_tick_unit_t unit, int dur, long long int t)
+{
+ retvm_if(unit == CAL_SCH_TIME_UNIT_OFF, CAL_ERR_NO_DATA, "tick unit is invalid");
+
+ if (unit == CAL_SCH_TIME_UNIT_SPECIFIC)
+ return cal_svc_buf_printline(b, "TRIGGER;VALUE=DATE-TIME:",cals_time_get_str_datetime(NULL, t));
+ else
+ return cal_svc_buf_printline(b, "TRIGGER:", vl_dur(unit, dur));
+}
+
+int pr_action(struct buf *b)
+{
+ return cal_svc_buf_printline(b, "ACTION:", "AUDIO");
+}
+
+
+int pr_audio(struct buf *b, cal_alarm_info_t *alm)
+{
+ int r;
+
+ r = pr_action(b);
+ retv_if(r < CAL_SUCCESS, r);
+
+ r = pr_trigger(b, alm->remind_tick_unit, alm->remind_tick, alm->alarm_time);
+ retv_if(r < CAL_SUCCESS, r);
+
+ // TODO : Support duration
+ // TODO : Support repeat (snooze)
+ return CAL_SUCCESS;
+}
+
+
+int cp_alarm(struct buf *b, cal_alarm_info_t *alm)
+{
+ int r;
+ // TODO : No action type is defined
+ r = cal_svc_buf_printline(b, "BEGIN:VALARM", NULL);
+ retv_if(r < CAL_SUCCESS, r);
+
+ r = pr_audio(b, alm);
+ retv_if(r < CAL_SUCCESS, r);
+
+ // TODO : Display
+ // TODO : Email
+ // TODO : Proc
+
+ return cal_svc_buf_printline(b, "END:VALARM", NULL);
+}
+
+int cp_schedule(struct buf *b, cal_sch_full_t *s)
+{
+ int r;
+ GList *l;
+ cal_participant_info_t *att;
+ cal_alarm_info_t *alm;
+
+ r = cal_svc_buf_printline(b, "BEGIN:VEVENT", NULL);
+ retv_if(r < CAL_SUCCESS, r);
+
+ r = pr_class(b, s->sensitivity);
+ retv_if(r < CAL_SUCCESS, r);
+
+ r = pr_transp(b, s->busy_status);
+ retv_if(r < CAL_SUCCESS, r);
+
+ r = pr_created(b, s->dtstart_tzid, s->created_time);
+ retv_if(r < CAL_SUCCESS, r);
+
+ if (s->description) {
+ r = pr_description(b, s->description);
+ retv_if(r < CAL_SUCCESS, r);
+ }
+
+ switch (s->dtstart_type) {
+ case CALS_TIME_UTIME:
+ r = pr_dtstart_utime(b, s->dtstart_tzid, s->dtstart_utime);
+ retv_if(r < CAL_SUCCESS, r);
+ break;
+
+ case CALS_TIME_LOCALTIME:
+ r = pr_dtstart_datetime(b, s->dtstart_year, s->dtstart_month, s->dtstart_mday);
+ retv_if(r < CAL_SUCCESS, r);
+ break;
+
+ }
+
+ // TODO : geo
+
+ r = pr_lastmod(b, s->dtstart_tzid, s->last_mod);
+ retv_if(r < CAL_SUCCESS, r);
+
+ if (s->location) {
+ r = pr_location(b, s->location);
+ retv_if(r < CAL_SUCCESS, r);
+ }
+ if (s->organizer_email) {
+ r = pr_organizer(b, s->organizer_name, s->organizer_email);
+ retv_if(r < CAL_SUCCESS, r);
+ }
+
+ r = pr_priority(b, s->priority);
+ retv_if(r < CAL_SUCCESS, r);
+
+ // TODO : seq
+
+ r = pr_dtstamp(s->dtstart_tzid, b);
+ retv_if(r < CAL_SUCCESS, r);
+
+ if (s->summary) {
+ r = pr_summary(b, s->summary);
+ retv_if(r < CAL_SUCCESS, r);
+ }
+
+ switch (s->dtend_type) {
+ case CALS_TIME_UTIME:
+ r = pr_dtend_utime(b, s->dtstart_tzid, s->dtend_utime);
+ retv_if(r < CAL_SUCCESS, r);
+ break;
+
+ case CALS_TIME_LOCALTIME:
+ r = pr_dtend_datetime(b, s->dtend_year, s->dtend_month, s->dtend_mday);
+ retv_if(r < CAL_SUCCESS, r);
+ break;
+
+ }
+
+ if (s->attendee_list) {
+ for (l = s->attendee_list; l; l = g_list_next(l)) {
+ if (!l->data || ((cal_value *)(l->data))->v_type != CAL_EVENT_PATICIPANT
+ || !((cal_value *)(l->data))->user_data) {
+ ERR("The attendee entry has no attendee data");
+ return CAL_ERR_NO_DATA;
+ }
+ att = ((cal_value *)(l->data))->user_data;
+ r = pr_attendee(b, att);
+ retv_if(r < CAL_SUCCESS, r);
+ }
+ }
+
+ if (s->alarm_list) {
+ for (l = s->alarm_list; l; l = g_list_next(l)) {
+ if (!l->data || ((cal_value *)(l->data))->v_type != CAL_EVENT_ALARM
+ || !((cal_value *)(l->data))->user_data) {
+ ERR("The alarm entry has no alarm data");
+ return CAL_ERR_NO_DATA;
+ }
+ alm = ((cal_value *)(l->data))->user_data;
+ r = cp_alarm(b, alm);
+ retv_if(r < CAL_SUCCESS, r);
+ }
+ }
+
+ return cal_svc_buf_printline(b, "END:VEVENT", NULL);
+}
+
+
+int cp_vcalendar(struct buf *b, GList *sch_l)
+{
+ int r;
+ cal_sch_full_t *s;
+ GList *l;
+
+ r = cal_svc_buf_printline(b, "BEGIN:VCALENDAR", NULL);
+ retv_if(r < CAL_SUCCESS, r);
+
+ r = cal_svc_buf_printline(b, "CALSCALE:GREGORIAN", NULL);
+ retv_if(r < CAL_SUCCESS, r);
+
+ r = cal_svc_buf_printline(b, "PRODID:-//Samsung Electronics//Calendar//EN", NULL);
+ retv_if(r < CAL_SUCCESS, r);
+
+ r = cal_svc_buf_printline(b, "VERSION:2.0", NULL);
+ retv_if(r < CAL_SUCCESS, r);
+
+ for (l = sch_l; l; l = g_list_next(l)) {
+ if (!l->data || !((cal_struct *)(l->data))->user_data) {
+ ERR("The schedule entry has no event data");
+ return CAL_ERR_NO_DATA;
+ }
+ s = (cal_sch_full_t *)((cal_struct *)(l->data))->user_data;
+ r = cp_schedule(b, s);
+ retv_if(r < CAL_SUCCESS, r);
+ }
+
+ return cal_svc_buf_printline(b, "END:VCALENDAR", NULL);
+}
+
+
+API int calendar_svc_write_schedules(GList *schedules, char **stream)
+{
+ int r;
+ struct buf *b;
+ char *ical;
+
+ retvm_if(!schedules || !stream, CAL_ERR_ARG_NULL, "Invalid parameter");
+
+ b = cal_svc_buf_new();
+ retvm_if(!b, CAL_ERR_OUT_OF_MEMORY, "Failed to create a buffer");
+
+ r = cp_vcalendar(b, schedules);
+
+ if (r < 0) {
+ cal_svc_buf_free(&b);
+ return r;
+ }
+
+ ical = cal_svc_buf_get_data(b);
+ cal_svc_buf_free(&b);
+
+ if (!ical) {
+ ERR("Failed to get ical data");
+ return CAL_ERR_OUT_OF_MEMORY;
+ }
+
+ if (!*ical) {
+ ERR("No ical data");
+ return CAL_ERR_NO_DATA;
+ }
+
+ *stream = ical;
+
+ return CAL_SUCCESS;
+}
+
+
+API int calendar_svc_calendar_export(int calendar_id, const char *path)
+{
+ int fd, r;
+ char *stream = NULL;
+ cal_iter *it;
+ cal_struct *cs;
+ GList *schedules = NULL;
+ GList *l;
+
+ if (calendar_id < 0 || path == NULL) {
+ ERR("Invalid argument: calendar id(%d) path(%s)", calendar_id, path);
+ return CAL_ERR_ARG_INVALID;
+ }
+
+ /* get schedules from DB */
+ r = calendar_svc_get_all(0, calendar_id, CAL_STRUCT_SCHEDULE, &it);
+ if (r != CAL_SUCCESS) {
+ ERR("Failed to get calendar(id:%d errno:%d)", calendar_id, r);
+ return CAL_ERR_FAIL;
+ }
+ while (calendar_svc_iter_next(it) == CAL_SUCCESS) {
+ r = calendar_svc_iter_get_info(it, &cs);
+ if (r != CAL_SUCCESS) {
+ ERR("Failed to get cal_struct");
+ break;
+ }
+
+ if (cs == NULL) {
+ ERR("cal_struct is NULL");
+ break;
+ }
+ schedules = g_list_append(schedules, cs);
+ }
+ calendar_svc_iter_remove(&it);
+ /* end getting schedules and close DB */
+
+ if (schedules == NULL) {
+ ERR("No schedules");
+ return CAL_ERR_FAIL;
+ }
+
+ /* get stream from schedules */
+ r = calendar_svc_write_schedules(schedules, &stream);
+
+ /* free schedules in memory */
+ l = schedules;
+ while (l) {
+ cs = (cal_struct *)l->data;
+ if (cs == NULL) {
+ ERR("Not cal struct");
+ break;
+ }
+ calendar_svc_struct_free(&cs);
+ l = g_list_next(l);
+ }
+ g_list_free(schedules);
+
+ if (r < 0) {
+ ERR("Failed to write schedules(errno:%d)", r);
+ return CAL_ERR_FAIL;
+ }
+
+ if (stream == NULL) {
+ ERR("stream is NULL");
+ return CAL_ERR_FAIL;
+ }
+
+ fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, 0660);
+ if (fd < 0) {
+ ERR("Failed to open path(%s)\n", path);
+ free(stream);
+ return CAL_ERR_IO_ERR;
+ }
+
+ r = write(fd, stream, strlen(stream));
+ free(stream);
+ close(fd);
+
+ if (r < 0) {
+ ERR("Failed to write stream(errno:%d)\n", r);
+ return CAL_ERR_IO_ERR;
+ }
+
+ return CAL_SUCCESS;
+}
//#include "org-engine-typedef.h"
/**
-* @fn bool cal_convert_cal_data_to_vdata_file( const cal_sch_full_t * sch_array, const int sch_count, const char * file_path, int * error_code);
-* This function convert a record to vcal file.
-*
-* @return This function returns true on success, or false on failure.
-* @param[in] sch_array Points the field information for schedule table' s record.
-* @param[in] sch_count Points the count of records.
-* @param[in] file_path Points the file path.
-* @param[out] error_code Points the error code.
-* @exception #CAL_ERR_VOBJECT_FAILED - Encode vcal error.
-* @exception #CAL_ERR_FILE_CREATE_ERROR - Create file error.
-* @exception #CAL_ERR_FILE_WRITINGNG_ERROR - Write file error.
-*/
-bool cal_convert_cal_data_to_vdata_file( const cal_sch_full_t * sch_array, const int sch_count, const char * file_path, int * error_code);
-
-/**
* @fn bool cal_convert_vdata_file_to_cal_data(const char * file_path, cal_sch_full_t ** sch_array, int * sch_count, int* error_code );
* This function convert a record to vcal file.
*
bool cal_convert_vdata_file_to_cal_data(const char * file_path, cal_sch_full_t ** sch_array, int * sch_count, int *error_code );
/**
-* @fn int cal_vcalendar_register_vcs_file(const char * file_name);
-* This function make vcal file by record index.
-*
-* @return This function returns true on success, or false on failure.
-* @param[in] file_name vcalendar's file name
-* @exception #CAL_ERR_FILE_OPEN_ERROR - Open file error.
-* @exception #CAL_ERR_VOBJECT_FAILED - Decode vcal error.
-* @exception #CAL_ERR_DB_NOT_OPENED - org db not opended.
-*/
-int cal_vcalendar_register_vcs_file(const char * file_name);
-
-/**
* @}
*/
#endif /* __CALENDAR_SVC_ICAL_H__ */
--- /dev/null
+#include <stdlib.h>
+#include <glib.h>
+#include <unicode/ucal.h>
+#include <unicode/ustring.h>
+#include <unicode/ustdio.h>
+#include <unicode/udat.h>
+#include <sys/types.h>
+#include "cals-typedef.h"
+#include "cals-internal.h"
+#include "cals-instance.h"
+#include "cals-sqlite.h"
+#include "cals-db-info.h"
+#include "cals-utils.h"
+
+#define ms2sec(ms) (long long int)(ms / 1000.0)
+#define sec2ms(s) (s * 1000.0)
+
+/* 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
+*/
+
+int _print_cal(UCalendar *cal)
+{
+ int y, m, d;
+ UErrorCode status = U_ZERO_ERROR;
+
+ y = ucal_get(cal, UCAL_YEAR, &status);
+ m = ucal_get(cal, UCAL_MONTH, &status) + 1;
+ d = ucal_get(cal, UCAL_DATE, &status);
+ DBG("PRINT CAL %04d/%02d/%02d", y, m, d);
+ return 0;
+}
+
+static int _get_max_count(cal_sch_full_t *);
+static int instance_insert_yearly(int event_id,
+ struct cals_time *st, int dr, cal_sch_full_t *sch);
+static int instance_insert_monthly(int event_id,
+ struct cals_time *st, int dr, cal_sch_full_t *sch);
+static int instance_insert_weekly(int event_id,
+ struct cals_time *st, int dr, cal_sch_full_t *sch);
+static int instance_insert_daily(int event_id,
+ struct cals_time *st, int dr, cal_sch_full_t *sch);
+static int instance_insert_once(int event_id,
+ struct cals_time *st, int dr, cal_sch_full_t *sch);
+
+struct inst_info {
+ int (*insert)(int, struct cals_time *, int duration, cal_sch_full_t *);
+ UCalendarDateFields f;
+ int max;
+};
+
+static struct inst_info inst_info[] = {
+ [CALS_FREQ_YEARLY] = {instance_insert_yearly, UCAL_YEAR, 100,},
+ [CALS_FREQ_MONTHLY] = {instance_insert_monthly, UCAL_MONTH, 120,},
+ [CALS_FREQ_WEEKLY] = {instance_insert_weekly, UCAL_WEEK_OF_YEAR, 520,},
+ [CALS_FREQ_DAILY] = {instance_insert_daily, UCAL_DATE, 3650,},
+ [CALS_FREQ_HOURLY] = {instance_insert_once, 0, 1,},
+ [CALS_FREQ_MINUTELY] = {instance_insert_once, 0, 1,},
+ [CALS_FREQ_SECONDLY] = {instance_insert_once, 0, 1,},
+ [CALS_FREQ_ONCE] = {instance_insert_once, 0, 1,},
+};
+
+struct day {
+ int uday;
+ const char *str;
+};
+
+enum cals_month {
+
+ CALS_JANUARY = 1,
+ CALS_FEBRUARY,
+ CALS_MARCH,
+ CALS_APRIL,
+ CALS_MAY,
+ CALS_JUNE,
+ CALS_JULY,
+ CALS_AUGUST,
+ CALS_SEPTEMBER,
+ CALS_OCTOBER,
+ CALS_NOVEMBER,
+ CALS_DECEMBER,
+ CALS_NOMONTH = 0x100,
+};
+
+static int months[] = {
+ [CALS_JANUARY] = UCAL_JANUARY,
+ [CALS_FEBRUARY] = UCAL_FEBRUARY,
+ [CALS_MARCH] = UCAL_MARCH,
+ [CALS_APRIL] = UCAL_APRIL,
+ [CALS_MAY] = UCAL_MAY,
+ [CALS_JUNE] = UCAL_JUNE,
+ [CALS_JULY] = UCAL_JULY,
+ [CALS_AUGUST] = UCAL_AUGUST,
+ [CALS_SEPTEMBER] = UCAL_SEPTEMBER,
+ [CALS_OCTOBER] = UCAL_OCTOBER,
+ [CALS_NOVEMBER] = UCAL_NOVEMBER,
+ [CALS_DECEMBER] = UCAL_DECEMBER,
+};
+
+static struct day days[] = {
+ [CALS_SUNDAY] = {UCAL_SUNDAY, "SU"},
+ [CALS_MONDAY] = {UCAL_MONDAY, "MO"},
+ [CALS_TUESDAY] = {UCAL_TUESDAY, "TU"},
+ [CALS_WEDNESDAY] = {UCAL_WEDNESDAY, "WE"},
+ [CALS_THURSDAY] = {UCAL_THURSDAY, "TH"},
+ [CALS_FRIDAY] = {UCAL_FRIDAY, "FR"},
+ [CALS_SATURDAY] = {UCAL_SATURDAY, "SA"},
+};
+
+static UCalendar *_ucal_get_cal(const char *tzid, int wkst)
+{
+ UCalendar *cal;
+ UErrorCode status = U_ZERO_ERROR;
+ UChar *_tzid;
+
+ _tzid = NULL;
+
+ if (tzid) {
+ _tzid = (UChar*)malloc(sizeof(UChar) * (strlen(tzid) +1));
+ if (_tzid)
+ u_uastrcpy(_tzid, tzid);
+ else
+ ERR("malloc failed");
+ }
+
+ cal = ucal_open(_tzid, u_strlen(_tzid), "en_US", UCAL_TRADITIONAL, &status);
+ if (_tzid)
+ free(_tzid);
+
+ if (U_FAILURE(status)) {
+ ERR("ucal_open failed (%s)", u_errorName(status));
+ return NULL;
+ }
+
+ if (wkst >= CALS_SUNDAY && wkst <= CALS_SATURDAY)
+ ucal_setAttribute(cal, UCAL_FIRST_DAY_OF_WEEK, days[wkst].uday);
+
+ return cal;
+}
+
+static void _ucal_set_time(UCalendar *cal, struct cals_time *t)
+{
+ UErrorCode status = U_ZERO_ERROR;
+
+ if (t->type == CALS_TIME_UTIME) {
+ ucal_setMillis(cal, sec2ms(t->utime), &status);
+ if (U_FAILURE(status)) {
+ ERR("ucal_setMillis failed (%s)", u_errorName(status));
+ return;
+ }
+ } else if (t->type == CALS_TIME_LOCALTIME) {
+ ucal_setDate(cal, t->year, months[t->month], t->mday, &status);
+ if (U_FAILURE(status)) {
+ ERR("ucal_setDate failed (%s)", u_errorName(status));
+ return;
+ }
+ } else
+ ERR("Invalid dtstart type. Current time is used in default");
+}
+
+static inline void _ucal_set_mday(UCalendar *cal, int mday)
+{
+ ucal_set(cal, UCAL_DATE, mday);
+}
+
+static inline void _ucal_set_month(UCalendar *cal, int month)
+{
+ if (month == CALS_NOMONTH)
+ return;
+ ucal_set(cal, UCAL_MONTH, months[month]);
+}
+
+static inline void _ucal_set_day(UCalendar *cal, int day)
+{
+ int woy; /* week of year */
+ int date, date_new; /* date */
+ UErrorCode status = U_ZERO_ERROR;
+
+ if (day == CALS_NODAY)
+ return;
+ woy = ucal_get(cal, UCAL_WEEK_OF_YEAR, &status);
+ date = ucal_get(cal, UCAL_DATE, &status);
+ ucal_set(cal, UCAL_DAY_OF_WEEK, days[day].uday);
+ ucal_set(cal, UCAL_WEEK_OF_YEAR, woy);
+ date_new = ucal_get(cal, UCAL_DATE, &status);
+ DBG("date old(%d) new(%d)", date, date_new);
+ if (date_new < date) {
+ ucal_add(cal, UCAL_DATE, 7, &status);
+ }
+}
+
+static inline void _ucal_set_week(UCalendar *cal, int week)
+{
+ if (!week)
+ return;
+ ucal_set(cal, UCAL_DAY_OF_WEEK_IN_MONTH, week);
+}
+
+static void _ucal_get_instance(UCalendar *cal,
+ struct cals_time *st, struct cals_time *result)
+{
+ UErrorCode status = U_ZERO_ERROR;
+
+ if (st->type == CALS_TIME_UTIME) {
+ result->type = CALS_TIME_UTIME;
+ result->utime = (long long int)(ms2sec(ucal_getMillis(cal, &status)));
+ return;
+ }
+
+ result->type = CALS_TIME_LOCALTIME;
+ result->year = ucal_get(cal, UCAL_YEAR, &status);
+ result->month = ucal_get(cal, UCAL_MONTH, &status) + 1;
+ result->mday = ucal_get(cal, UCAL_DATE, &status);
+ DBG("get instance %04d/%02d/%02d", result->year, result->month, result->mday);
+
+ return;
+}
+
+static inline int _is_after(struct cals_time *t1, struct cals_time *t2)
+{
+ if (t1->type == CALS_TIME_UTIME) {
+ if (t1->utime > t2->utime)
+ return 1;
+ else
+ return 0;
+ }
+
+ DBG("%d %d %d /%d %d %d", t1->year, t1->month, t1->mday,
+ t2->year, t2->month, t2->mday);
+ if (t1->year > t2->year) {
+ return 1;
+ } else if (t1->month > t2->month) {
+ return 1;
+ } else if (t1->mday > t2->mday) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+static inline void _set_until(struct cals_time *until, cal_sch_full_t *sch)
+{
+ until->type = sch->until_type;
+
+ if (sch->range_type == CALS_RANGE_UNTIL) {
+ if (sch->until_type == CALS_TIME_UTIME) {
+ DBG("until utime(%lld)", sch->until_utime);
+ until->utime = sch->until_utime;
+ } else {
+ DBG("until datetime(%04d/%02d/%02d",
+ sch->until_year, sch->until_month, sch->until_mday);
+ until->year = sch->until_year;
+ until->month = sch->until_month;
+ until->mday = sch->until_mday;
+ }
+ return;
+ }
+
+ until->utime = 253402300799;
+ until->year = 9999;
+ until->month = 12;
+ until->mday = 31;
+}
+
+int _ucal_del_inundant(int event_id, struct cals_time *st, cal_sch_full_t *sch)
+{
+ int r;
+ int cnt;
+ char query[CALS_SQL_MIN_LEN];
+
+ if (sch->range_type != CALS_RANGE_COUNT) {
+ return 0;
+ }
+
+ cnt = _get_max_count(sch);
+
+ if (st->type == CALS_TIME_UTIME) {
+ snprintf(query, sizeof(query), "DELETE FROM %s "
+ "WHERE event_id = %d "
+ "AND dtstart_utime > (SELECT dtstart_utime FROM %s "
+ "WHERE event_id = %d ORDER BY dtstart_utime LIMIT %d, 1) ",
+ CALS_TABLE_NORMAL_INSTANCE,
+ event_id,
+ CALS_TABLE_NORMAL_INSTANCE,
+ event_id, cnt -1);
+
+ } else if (st->type == CALS_TIME_LOCALTIME) {
+ snprintf(query, sizeof(query), "DELETE FROM %s "
+ "WHERE event_id = %d "
+ "AND dtstart_datetime > (SELECT dtstart_datetime FROM %s "
+ "WHERE event_id = %d ORDER BY dtstart_datetime LIMIT %d, 1) ",
+ CALS_TABLE_ALLDAY_INSTANCE,
+ event_id,
+ CALS_TABLE_ALLDAY_INSTANCE,
+ event_id, cnt -1);
+ }
+
+ r = cals_query_exec(query);
+ if (r) {
+ ERR("cals_query_prepare failed (%d)", r);
+ return -1;
+ }
+ DBG("query(%s)", query);
+ return 0;
+}
+
+static int _insert_instance(UCalendar *cal, int event_id,
+ struct cals_time *st, int dr, int day, int week, cal_sch_full_t *sch)
+{
+ int r;
+ int i;
+ int cnt;
+ int e_year;
+ int e_month;
+ int e_mday;
+
+ UCalendar *e_cal;
+ UErrorCode status = U_ZERO_ERROR;
+ struct cals_time in;
+ struct cals_time until;
+ char query[CALS_SQL_MIN_LEN];
+
+ r = CAL_SUCCESS;
+
+ memset(&until, 0, sizeof(struct cals_time));
+ memset(&in, 0, sizeof(struct cals_time));
+
+ cnt = _get_max_count(sch);
+ _set_until(&until, sch);
+
+ for (i = 0; i < cnt; i++) {
+ _ucal_set_day(cal, day);
+ _ucal_set_week(cal, week);
+
+ _ucal_get_instance(cal, st, &in);
+ if (sch->freq != CALS_FREQ_ONCE && _is_after(&in, &until)) {
+ DBG("exit in is_after");
+ break;
+ }
+
+ if (st->type == CALS_TIME_UTIME) {
+ snprintf(query, sizeof(query), "INSERT INTO %s "
+ "VALUES (%d, %lld, %lld)",
+ CALS_TABLE_NORMAL_INSTANCE,
+ event_id, in.utime, in.utime + dr);
+
+ } else if (st->type == CALS_TIME_LOCALTIME) {
+ if (dr > 0) {
+ e_cal = ucal_clone(cal, &status);
+ ucal_add(e_cal, UCAL_DATE, dr, &status);
+ e_year = ucal_get(e_cal, UCAL_YEAR, &status);
+ e_month = ucal_get(e_cal, UCAL_MONTH, &status) + 1;
+ e_mday = ucal_get(e_cal, UCAL_DATE, &status);
+ ucal_close(e_cal);
+ }
+ else {
+ e_year = in.year;
+ e_month = in.month;
+ e_mday = in.mday;
+ }
+
+ snprintf(query, sizeof(query), "INSERT INTO %s "
+ "VALUES (%d, %04d%02d%02d, %04d%02d%02d)",
+ CALS_TABLE_ALLDAY_INSTANCE, event_id,
+ in.year, in.month, in.mday,
+ e_year, e_month, e_mday);
+ } else {
+ ERR("Invalid dtstart time type");
+ return CAL_ERR_ARG_INVALID;
+ }
+
+ DBG("query(%s)", query);
+ r = cals_query_exec(query);
+ if (r) {
+ ERR("cals_query_prepare failed (%d)", r);
+ break;
+ }
+
+ ucal_add(cal, inst_info[sch->freq].f, sch->interval, &status);
+ }
+
+ return r;
+}
+
+static int _get_duration(struct cals_time *st, struct cals_time *et)
+{
+ UErrorCode status = U_ZERO_ERROR;
+ UCalendar *cal;
+ UDate ud;
+ int dr;
+ if (st->type == CALS_TIME_UTIME)
+ return et->utime - st->utime;
+
+ cal = _ucal_get_cal(et->tzid, -1);
+
+ _ucal_set_time(cal, et);
+
+ ud = ucal_getMillis(cal, &status);
+
+ _ucal_set_time(cal, st);
+
+ dr = ucal_getFieldDifference(cal, ud, UCAL_DATE, &status);
+ if (U_FAILURE(status)) {
+ ERR("ucal_getFieldDifference failed (%s)", u_errorName(status));
+ return 0;
+ }
+
+ ucal_close(cal);
+
+ return dr;
+}
+
+static inline int _get_month(const char *str)
+{
+ int month;
+
+ if (!str || !*str)
+ return -1;
+
+ month = atoi(str);
+ if (month < CALS_JANUARY || month > CALS_DECEMBER)
+ return -1;
+
+ return month;
+}
+
+static inline int _get_mday(const char *str)
+{
+ int mday;
+
+ if (!str || !*str)
+ return -1;
+
+ mday = atoi(str);
+ if (mday < 1 || mday > 31)
+ return -1;
+
+ return mday;
+}
+
+static int insert_bymday(int event_id,
+ struct cals_time *st, int dr, int month, cal_sch_full_t *sch)
+{
+ UCalendar *cal;
+ int r;
+ int i;
+ int mday;
+ char **t;
+ const char *d = ",";
+
+ t = g_strsplit(sch->bymonthday, d, -1);
+
+ if (!t) {
+ ERR("g_strsplit failed");
+ return CAL_ERR_OUT_OF_MEMORY;
+ }
+
+ for (i = 0; t[i]; ++i) {
+ mday = _get_mday(t[i]);
+ if (mday < 0) {
+ g_strfreev(t);
+ return CAL_ERR_ARG_INVALID;
+ }
+
+ cal = _ucal_get_cal(st->tzid, sch->wkst);
+ if (!cal)
+ return CAL_ERR_FAIL;
+ _ucal_set_time(cal, st);
+ _ucal_set_month(cal, month);
+ _ucal_set_mday(cal, mday);
+
+ r = _insert_instance(cal, event_id, st, dr, CALS_NODAY, 0, sch);
+ if (r) {
+ ERR("_insert_bymday failed (%d)", r);
+ g_strfreev(t);
+ return r;
+ }
+ }
+ _ucal_del_inundant(event_id, st, sch);
+
+ return CAL_SUCCESS;
+}
+
+static int insert_no_by(int event_id,
+ struct cals_time *st, int dr, cal_sch_full_t *sch)
+{
+ UCalendar *cal;
+
+ cal = _ucal_get_cal(st->tzid, sch->wkst);
+ if (!cal)
+ return CAL_ERR_FAIL;
+
+ _ucal_set_time(cal, st);
+
+ return _insert_instance(cal, event_id, st, dr, CALS_NODAY, 0, sch);
+}
+
+static inline int _get_day(const char *str, int *week, int *day)
+{
+ int i;
+ int d;
+ char buf[3];
+
+ if (!str || !*str)
+ return -1;
+
+ if (!sscanf(str, "%d", &d)) {
+ DBG("no week digit");
+ if (sscanf(str, "%s", buf) != 1) {
+ ERR("Failed to get day[%s]", str);
+ return -1;
+ }
+ d = 0;
+ } else {
+ if (sscanf(str, "%d%s", &d, buf) != 2) {
+ ERR("Failed to get day[%s]", str);
+ return -1;
+ }
+ }
+
+ *week = d;
+
+ buf[2] = '\0';
+ DBG("[%s] and sets week (%d)", buf, d);
+
+ for (i = 0; i < sizeof(days)/sizeof(struct day); i++) {
+ if (!strncmp(days[i].str, buf, 2)) {
+ DBG("inserted wday[%s]and set[%s]", days[i].str, buf);
+ *day = i;
+ break;
+ }
+ }
+
+ return 0;
+}
+
+static int insert_byday(int event_id,
+ struct cals_time *st, int dr, int month, cal_sch_full_t *sch)
+{
+ UCalendar *cal;
+ int r;
+ int i;
+ int day;
+ int week;
+ char **t;
+ const char *d = ",";
+
+ t = g_strsplit(sch->byday, d, -1);
+
+ if (!t) {
+ ERR("g_strsplit failed");
+ return CAL_ERR_OUT_OF_MEMORY;
+ }
+
+ day = 0;
+ week = 0;
+
+ for (i = 0; t[i]; ++i) {
+ r = _get_day(t[i], &week, &day);
+ if (r < 0) {
+ g_strfreev(t);
+ ERR("_get_day failed");
+ return CAL_ERR_ARG_INVALID;
+ }
+
+ cal = _ucal_get_cal(st->tzid, sch->wkst);
+ if (!cal)
+ return CAL_ERR_FAIL;
+ _ucal_set_time(cal, st);
+ _ucal_set_month(cal, month);
+
+ r = _insert_instance(cal, event_id, st, dr, day, week, sch);
+ if (r) {
+ ERR("_insert_bymday failed (%d)", r);
+ g_strfreev(t);
+ return r;
+ }
+ }
+
+ _ucal_del_inundant(event_id, st, sch);
+ g_strfreev(t);
+
+ return CAL_SUCCESS;
+}
+
+static int instance_insert_yearly(int event_id,
+ struct cals_time *st, int dr, cal_sch_full_t *sch)
+{
+ CALS_FN_CALL;
+ int month;
+
+ month = _get_month(sch->bymonth);
+ if (month < 0) {
+ ERR("_get_month failed");
+ return CAL_ERR_ARG_INVALID;
+ }
+
+ if (sch->bymonthday)
+ return insert_bymday(event_id, st, dr, month, sch);
+ else
+ return insert_byday(event_id, st, dr, month, sch);
+
+ return CAL_ERR_ARG_INVALID;
+}
+
+static int instance_insert_monthly(int event_id,
+ struct cals_time *st, int dr, cal_sch_full_t *sch)
+{
+ CALS_FN_CALL;
+ if (sch->bymonthday)
+ return insert_bymday(event_id, st, dr, CALS_NOMONTH, sch);
+ else if (sch->byday)
+ return insert_byday(event_id, st, dr, CALS_NOMONTH, sch);
+ return CAL_ERR_ARG_INVALID;
+}
+
+static int instance_insert_daily(int event_id,
+ struct cals_time *st, int dr, cal_sch_full_t *sch)
+{
+ CALS_FN_CALL;
+ return insert_no_by(event_id, st, dr, sch);
+}
+
+static int instance_insert_weekly(int event_id,
+ struct cals_time *st, int dr, cal_sch_full_t *sch)
+{
+ CALS_FN_CALL;
+ if (sch->byday)
+ return insert_byday(event_id, st, dr, CALS_NOMONTH, sch);
+ return CAL_ERR_ARG_INVALID;
+}
+
+static int instance_insert_once(int event_id,
+ struct cals_time *st, int dr, cal_sch_full_t *sch)
+{
+ CALS_FN_CALL;
+ return insert_no_by(event_id, st, dr, sch);
+}
+
+static int _get_max_count(cal_sch_full_t *sch)
+{
+ int cnt;
+
+ cnt = inst_info[sch->freq].max;
+
+ if (sch->range_type == CALS_RANGE_COUNT) {
+ if (sch->count < cnt)
+ cnt = sch->count;
+ }
+ return cnt;
+}
+
+int cals_instance_insert(int event_id, struct cals_time *st,
+ struct cals_time *et, cal_sch_full_t *sch)
+{
+ if (sch->cal_type != CALS_SCH_TYPE_EVENT) {
+ DBG("Check schedule type, you're handling with type(%d)", sch->cal_type);
+ return -1;
+ }
+ int dr = _get_duration(st, et);
+ return inst_info[sch->freq].insert(event_id, st, dr, sch);
+}
+
+int cals_instance_delete(int event_id, struct cals_time *st)
+{
+ int r, ret;
+ int type;
+ sqlite3_stmt *stmt;
+ char query[CALS_SQL_MIN_LEN];
+
+ /* get type for noty */
+ snprintf(query, sizeof(query), "SELECT type FROM %s WHERE id = %d ",
+ CALS_TABLE_SCHEDULE, event_id);
+ stmt = cals_query_prepare(query);
+ if (!stmt) {
+ ERR("cals_query_prepare failed");
+ return CAL_ERR_DB_FAILED;
+ }
+
+ r = cals_stmt_step(stmt);
+ if (r != CAL_SUCCESS) {
+ sqlite3_finalize(stmt);
+ ERR("cals_stmt_step failed (%d)", r);
+ return r;
+ }
+
+ type = sqlite3_column_int(stmt, 0);
+ sqlite3_finalize(stmt);
+
+ /* send noti */
+ ret = cals_notify(type == CALS_SCH_TYPE_EVENT ? CALS_NOTI_TYPE_EVENT : CALS_NOTI_TYPE_TODO);
+ if (ret < 0) {
+ WARN("cals_notify failed (%d)", ret);
+ }
+
+ /* delete instance from table */
+ if (st->type == CALS_TIME_UTIME) {
+ snprintf(query, sizeof(query), "DELETE FROM %s "
+ "WHERE event_id = %d AND dtstart_utime = %lld",
+ CALS_TABLE_NORMAL_INSTANCE, event_id, st->utime);
+
+ } else if (st->type == CALS_TIME_LOCALTIME) {
+ snprintf(query, sizeof(query), "DELETE FROM %s "
+ "WHERE event_id = %d AND %04d%02d%02d",
+ CALS_TABLE_ALLDAY_INSTANCE, event_id, st->year, st->month, st->mday);
+
+ } else {
+ ERR("Invalid start time type");
+ return CAL_ERR_ARG_INVALID;
+ }
+
+ r = cals_query_exec(query);
+ if (r)
+ ERR("cals_query_exec failed");
+
+ return r;
+}
+
--- /dev/null
+#include "cals-typedef.h"
+#include "cals-time.h"
+
+int cals_instance_insert(int event_id, struct cals_time *st, struct cals_time *et, cal_sch_full_t *sch);
+int cals_instance_delete(int event_id, struct cals_time *st);
+
#include "cals-db.h"
#include "cals-db-info.h"
#include "cals-ical.h"
-#include "cals-tz-utils.h"
-#include "cals-recurrence-utils.h"
-#include "cals-ical-codec.h"
#include "cals-alarm.h"
#include "cals-sqlite.h"
#include "cals-calendar.h"
{CAL_VALUE_INT_ACCOUNT_ID, VALUE_TYPE_INT},
{CAL_VALUE_TXT_SUMMARY, VALUE_TYPE_TEXT},
{CAL_VALUE_TXT_DESCRIPTION, VALUE_TYPE_TEXT},
- {CAL_VALUE_TXT_LOCATION, VALUE_TYPE_TEXT},
- {CAL_VALUE_INT_ALL_DAY_EVENT, VALUE_TYPE_INT},
- {CAL_VALUE_GMT_START_DATE_TIME, VALUE_TYPE_TIME},
- {CAL_VALUE_GMT_END_DATE_TIME, VALUE_TYPE_TIME},
- {CAL_VALUE_INT_REPEAT_TERM, VALUE_TYPE_INT},
- {CAL_VALUE_INT_REPEAT_INTERVAL, VALUE_TYPE_INT},
- {CAL_VALUE_INT_REPEAT_OCCURRENCES, VALUE_TYPE_INT},
- {CAL_VALUE_GMT_REPEAT_END_DATE, VALUE_TYPE_TIME},
- {CAL_VALUE_INT_SUN_MOON, VALUE_TYPE_INT},
- {CAL_VALUE_INT_WEEK_START, VALUE_TYPE_INT},
- {CAL_VALUE_TXT_WEEK_FLAG, VALUE_TYPE_TEXT},
- {CAL_VALUE_INT_DAY_DATE, VALUE_TYPE_INT},
- {CAL_VALUE_GMT_LAST_MODIFIED_TIME, VALUE_TYPE_TIME},
+ {CAL_VALUE_TXT_LOCATION, VALUE_TYPE_TEXT},
+ {CAL_VALUE_TXT_CATEGORIES, VALUE_TYPE_TEXT},
{CAL_VALUE_INT_MISSED, VALUE_TYPE_INT},
{CAL_VALUE_INT_TASK_STATUS, VALUE_TYPE_INT},
{CAL_VALUE_INT_PRIORITY, VALUE_TYPE_INT},
{CAL_VALUE_INT_CALENDAR_INDEX, VALUE_TYPE_INT},
{CAL_VALUE_DBL_LATITUDE, VALUE_TYPE_DOUBLE},
{CAL_VALUE_DBL_LONGITUDE, VALUE_TYPE_DOUBLE},
- {CAL_VALUE_TXT_TZ_NAME, VALUE_TYPE_TEXT},
- {CAL_VALUE_TXT_TZ_CITY_NAME, VALUE_TYPE_TEXT},
{CAL_VALUE_INT_EMAIL_ID, VALUE_TYPE_INT},
{CAL_VALUE_INT_AVAILABILITY, VALUE_TYPE_INT},
- {CAL_VALUE_TXT_MEETING_CATEGORY_DETAIL_NAME, VALUE_TYPE_TEXT},
- {CAL_VALUE_GMT_CREATED_DATE_TIME, VALUE_TYPE_TIME},
- {CAL_VALUE_GMT_COMPLETED_DATE_TIME, VALUE_TYPE_TIME},
{CAL_VALUE_INT_PROGRESS, VALUE_TYPE_INT},
{NULL, VALUE_TYPE_USER}
};
CALS_FN_CALL;
int ret = 0;
+ g_type_init(); // added for alarmmgr
+
if(db_ref_cnt <= 0)
{
ret = cals_db_open();
ret = cals_begin_trans();
retvm_if(CAL_SUCCESS != ret, ret, "cals_begin_trans() Failed(%d)", ret);
+ DBG("insert cal type(%d)", ((cal_sch_full_t*)event->user_data)->cal_type);
switch(event->event_type) {
case CAL_STRUCT_TYPE_SCHEDULE:
sch_temp = (cal_sch_full_t*)event->user_data;
- sch_temp->cal_type = CAL_EVENT_SCHEDULE_TYPE;
+ if (sch_temp->cal_type != CALS_SCH_TYPE_EVENT) {
+ ERR("Invalid type check (%d)", sch_temp->cal_type);
+ return CAL_ERR_FAIL;
+ }
+/*
+ if (sch_temp->calendar_id == DEFAULT_TODO_CALENDAR_ID) {
+ ERR("Error, tried to insert TODO calendar id.");
+ return CAL_ERR_FAIL;
+ }
+*/
ret = cals_insert_schedule(sch_temp);
if (ret < CAL_SUCCESS) {
break;
case CAL_STRUCT_TYPE_TODO:
sch_temp = (cal_sch_full_t*)event->user_data;
-
+ if (sch_temp->cal_type != CALS_SCH_TYPE_TODO) {
+ ERR("Invalid type check (%d)", sch_temp->cal_type);
+ return CAL_ERR_FAIL;
+ }
+/*
+ if (sch_temp->calendar_id == DEFAULT_EVENT_CALENDAR_ID) {
+ ERR("Error, tried to insert TODO calendar id.");
+ return CAL_ERR_FAIL;
+ }
+*/
ret = cals_insert_schedule(sch_temp);
if (ret < CAL_SUCCESS) {
cals_end_trans(false);
sch_record = (*record)->user_data;
if (field_list) {
- cals_rearrage_schedule_field(field_list, rearranged, sizeof(rearranged));
- sprintf(sql_value,"SELECT %s FROM %s WHERE id=%d",
- CALS_TABLE_SCHEDULE, rearranged, index);
- } else
- sprintf(sql_value,"SELECT * FROM %s WHERE id=%d;", CALS_TABLE_SCHEDULE, index);
+ cals_rearrange_schedule_field(field_list, rearranged, sizeof(rearranged));
+ snprintf(sql_value, sizeof(sql_value),
+ "SELECT %s FROM %s WHERE id = %d AND is_deleted = 0 ",
+ CALS_TABLE_SCHEDULE, rearranged, index);
+ } else {
+ snprintf(sql_value, sizeof(sql_value),
+ "SELECT * FROM %s WHERE id = %d AND is_deleted = 0 ",
+ CALS_TABLE_SCHEDULE, index);
+ }
+ DBG("query(%s)", sql_value);
stmt = cals_query_prepare(sql_value);
retex_if(NULL == stmt,,"cals_query_prepare() Failed");
rc = cals_stmt_step(stmt);
- retex_if(CAL_TRUE != rc,,"cals_stmt_step() Failed(%d)", rc);
+ if (rc != CAL_TRUE) {
+ ERR("Failed to step stmt(%d)", rc);
+ sqlite3_finalize(stmt);
+ if (malloc_inside && *record != NULL) {
+ calendar_svc_struct_free(record);
+ }
+ return CAL_ERR_FAIL;
+ }
if (field_list)
cals_stmt_get_filted_schedule(stmt, sch_record, field_list);
else
cals_stmt_get_full_schedule(stmt, sch_record, true);
+ sqlite3_finalize(stmt);
+ stmt = NULL;
+
+ if (sch_record->rrule_id > 0) {
+
+ snprintf(sql_value, sizeof(sql_value),
+ "SELECT * FROM %s WHERE event_id = %d ",
+ CALS_TABLE_RRULE, index);
+
+ DBG("has rrule_is query(%s)", sql_value);
+
+ stmt = cals_query_prepare(sql_value);
+ retex_if(NULL == stmt,,"cals_query_prepare() Failed");
+
+ rc = cals_stmt_step(stmt);
+ if (rc != CAL_TRUE) {
+ ERR("Failed to step stmt(%d)", rc);
+ sqlite3_finalize(stmt);
+ if (malloc_inside && *record != NULL) {
+ calendar_svc_struct_free(record);
+ }
+ return CAL_ERR_FAIL;
+ }
+
+ cals_stmt_fill_rrule(stmt, sch_record);
+ sqlite3_finalize(stmt);
+ stmt = NULL;
+ }
+
sch_record->index = index;
if (0 == strcmp(data_type,CAL_STRUCT_SCHEDULE)) {
cal_db_service_get_participant_info_by_index(index,&(sch_record->attendee_list),&error_code);
- cal_db_service_get_meeting_category_info_by_index(index,&(sch_record->meeting_category),&error_code);
- cal_db_service_get_recurrency_exception(index,&(sch_record->exception_date_list),&error_code);
cals_get_alarm_info(index, &(sch_record->alarm_list));
}
}
if (field_list) {
cals_rearrage_calendar_field(field_list, rearranged, sizeof(rearranged));
- sprintf(sql_value,"SELECT rowid,%s FROM %s WHERE rowid=%d",
+ snprintf(sql_value, sizeof(sql_value), "SELECT rowid %s FROM %s WHERE rowid=%d",
rearranged, CALS_TABLE_CALENDAR, index);
}
else
- sprintf(sql_value,"SELECT rowid,* FROM %s WHERE rowid=%d",
+ snprintf(sql_value, sizeof(sql_value), "SELECT rowid,* FROM %s WHERE rowid=%d",
CALS_TABLE_CALENDAR, index);
stmt = cals_query_prepare(sql_value);
retex_if(NULL == stmt,,"cals_query_prepare() Failed");
rc = cals_stmt_step(stmt);
- retex_if(CAL_TRUE != rc,,"cals_stmt_step() Failed(%d)", rc);
+ if (rc != CAL_TRUE) {
+ ERR("Failed to step stmt(%d)", rc);
+ sqlite3_finalize(stmt);
+ if (malloc_inside && *record != NULL) {
+ calendar_svc_struct_free(record);
+ }
+ return CAL_ERR_FAIL;
+ }
if (field_list)
cals_stmt_get_filted_calendar(stmt, calendar, field_list);
}
else*/
{
- sprintf(sql_value,"select rowid,* from timezone_table where rowid=%d;",index);
+ snprintf(sql_value, sizeof(sql_value), "select rowid,* from timezone_table where rowid=%d;",index);
}
stmt = cals_query_prepare(sql_value);
retex_if(NULL == stmt,,"cals_query_prepare() Failed");
rc = cals_stmt_step(stmt);
- retex_if(CAL_TRUE != rc,,"cals_stmt_step() Failed(%d)", rc);
+ if (rc != CAL_TRUE) {
+ ERR("Failed to step stmt(%d)", rc);
+ sqlite3_finalize(stmt);
+ if (malloc_inside && *record != NULL) {
+ calendar_svc_struct_free(record);
+ }
+ return CAL_ERR_FAIL;
+ }
/*if(NULL != field_list) - not support yet
{
if(0 == strcmp(data_type,CAL_STRUCT_SCHEDULE))
{
- sprintf(condition_value,"WHERE type=%d",CAL_EVENT_SCHEDULE_TYPE);
+ snprintf(condition_value, sizeof(condition_value), "WHERE type=%d",CALS_SCH_TYPE_EVENT);
if(account_id == ALL_VISIBILITY_ACCOUNT || calendar_id==ALL_VISIBILITY_ACCOUNT)
{
- sprintf(sql_value,"SELECT COUNT(*) FROM %s A, %s B %s "
- "AND A.calendar_id = B.rowid AND B.visibility = 1 AND "
- "A.is_deleted = 0 ORDER BY A.start_date_time",
+ snprintf(sql_value, sizeof(sql_value), "SELECT COUNT(*) "
+ "FROM %s A, %s B %s "
+ "AND A.calendar_id = B.rowid AND B.visibility = 1 AND A.is_deleted = 0 "
+ "ORDER BY A.dtstart_utime",
CALS_TABLE_SCHEDULE, CALS_TABLE_CALENDAR, condition_value);
}
else
{
if(account_id !=0)
{
- sprintf(condition_value,"%s AND account_id = %d",condition_value,account_id);
+ snprintf(condition_value, sizeof(condition_value), "%s AND account_id = %d",condition_value,account_id);
}
if(calendar_id != 0)
{
- sprintf(condition_value,"%s AND calendar_id = %d",condition_value,calendar_id);
+ snprintf(condition_value, sizeof(condition_value), "%s AND calendar_id = %d",condition_value,calendar_id);
}
- sprintf(sql_value,"SELECT COUNT(*) FROM %s %s AND is_deleted = 0 ORDER BY start_date_time",
- CALS_TABLE_SCHEDULE, condition_value);
+ snprintf(sql_value, sizeof(sql_value), "SELECT COUNT(*) FROM %s %s "
+ "AND is_deleted = 0 "
+ "ORDER BY dtstart_utime",
+ CALS_TABLE_SCHEDULE, condition_value);
}
}
else if(0 == strcmp(data_type,CAL_STRUCT_TODO))
{
- sprintf(condition_value,"WHERE type=%d",CAL_EVENT_TODO_TYPE);
+ snprintf(condition_value, sizeof(condition_value), "WHERE type=%d",CALS_SCH_TYPE_TODO);
if(account_id !=0)
{
- sprintf(condition_value,"%s AND account_id = %d ",condition_value,account_id);
+ snprintf(condition_value, sizeof(condition_value), "%s AND account_id = %d ",condition_value,account_id);
}
if(calendar_id != 0)
{
- sprintf(condition_value,"%s AND calendar_id = %d ",condition_value,calendar_id);
+ snprintf(condition_value, sizeof(condition_value), "%s AND calendar_id = %d ",condition_value,calendar_id);
}
- sprintf(sql_value,"SELECT COUNT(*) FROM %s %s AND is_deleted = 0",
- CALS_TABLE_SCHEDULE, condition_value);
+ snprintf(sql_value, sizeof(sql_value), "SELECT COUNT(*) FROM %s %s "
+ "AND is_deleted = 0 ",
+ CALS_TABLE_SCHEDULE, condition_value);
}
else if(0 == strcmp(data_type,CAL_STRUCT_CALENDAR))
if(account_id != 0)
{
- sprintf(condition_value, "WHERE account_id = %d ", account_id);
+ snprintf(condition_value, sizeof(condition_value), "WHERE account_id = %d ", account_id);
}
- sprintf(sql_value,"SELECT COUNT(*) FROM %s %s;", CALS_TABLE_CALENDAR, condition_value);
+ snprintf(sql_value, sizeof(sql_value), "SELECT COUNT(*) FROM %s %s;", CALS_TABLE_CALENDAR, condition_value);
}
else //not support yet
return count;
}
+/* get entry */
API int calendar_svc_get_all(int account_id, int calendar_id,const char *data_type, cal_iter **iter)
{
CALS_FN_CALL;
sqlite3_stmt *stmt = NULL;
char sql_value[CALS_SQL_MIN_LEN];
- retv_if(NULL == data_type, CAL_ERR_ARG_NULL);
- retv_if(NULL == iter, CAL_ERR_ARG_NULL);
- retvm_if(calendar_id < 0, CAL_ERR_ARG_INVALID, "calendar_id(%d) is Invalid", calendar_id);
+ retvm_if(NULL == data_type, CAL_ERR_ARG_NULL, "Invalid argument: data type is NULL");
+ retvm_if(NULL == iter, CAL_ERR_ARG_NULL, "Invalid argument: iter is not NULL");
if(0 == strcmp(data_type,CAL_STRUCT_SCHEDULE))
{
if (account_id == ALL_VISIBILITY_ACCOUNT || calendar_id==ALL_VISIBILITY_ACCOUNT)
{
- sprintf(sql_value,"SELECT A.* FROM %s A, %s B ON A.calendar_id = B.rowid "
- "WHERE type=%d AND B.visibility = 1 AND A.is_deleted = 0 "
- "ORDER BY A.start_date_time",
- CALS_TABLE_SCHEDULE, CALS_TABLE_CALENDAR, CAL_EVENT_SCHEDULE_TYPE);
+ snprintf(sql_value, sizeof(sql_value), "SELECT A.* "
+ "FROM %s A, %s B ON A.calendar_id = B.rowid "
+ "WHERE A.type=%d AND B.visibility = 1 AND A.is_deleted = 0 "
+ "ORDER BY id",
+ CALS_TABLE_SCHEDULE, CALS_TABLE_CALENDAR, CALS_SCH_TYPE_EVENT);
}
else
{
- if (calendar_id)
- sprintf(sql_value,"SELECT * FROM %s "
- "WHERE type=%d AND is_deleted = 0 AND calendar_id = %d "
- "ORDER BY start_date_time",
- CALS_TABLE_SCHEDULE, CAL_EVENT_SCHEDULE_TYPE, calendar_id);
+ if (calendar_id > 0)
+ snprintf(sql_value, sizeof(sql_value), "SELECT * FROM %s "
+ "WHERE type=%d AND calendar_id = %d AND is_deleted = 0 "
+ "ORDER BY id",
+ CALS_TABLE_SCHEDULE, CALS_SCH_TYPE_EVENT, calendar_id);
else if (account_id)
- sprintf(sql_value,"SELECT * FROM %s "
- "WHERE type=%d AND is_deleted = 0 AND account_id = %d "
- "ORDER BY start_date_time",
- CALS_TABLE_SCHEDULE, CAL_EVENT_SCHEDULE_TYPE, account_id);
+ snprintf(sql_value, sizeof(sql_value), "SELECT * FROM %s "
+ "WHERE type=%d AND account_id = %d AND is_deleted = 0 "
+ "ORDER BY id",
+ CALS_TABLE_SCHEDULE, CALS_SCH_TYPE_EVENT, account_id);
else
- sprintf(sql_value,"SELECT * FROM %s "
+ snprintf(sql_value, sizeof(sql_value), "SELECT * FROM %s "
"WHERE type=%d AND is_deleted = 0 "
- "ORDER BY start_date_time",
- CALS_TABLE_SCHEDULE, CAL_EVENT_SCHEDULE_TYPE);
+ "ORDER BY id",
+ CALS_TABLE_SCHEDULE, CALS_SCH_TYPE_EVENT);
}
type = CAL_STRUCT_TYPE_SCHEDULE;
}
else if(0 == strcmp(data_type,CAL_STRUCT_TODO))
{
- if (calendar_id)
- sprintf(sql_value,"SELECT * FROM %s WHERE type=%d AND is_deleted = 0 AND calendar_id = %d ",
- CALS_TABLE_SCHEDULE, CAL_EVENT_TODO_TYPE, calendar_id);
+ if (calendar_id > 0)
+ snprintf(sql_value, sizeof(sql_value), "SELECT * FROM %s "
+ "WHERE type=%d AND calendar_id = %d AND is_deleted = 0 ORDER BY id",
+ CALS_TABLE_SCHEDULE, CALS_SCH_TYPE_TODO, calendar_id);
else if (account_id)
- sprintf(sql_value,"SELECT * FROM %s WHERE type=%d AND is_deleted = 0 AND account_id = %d ",
- CALS_TABLE_SCHEDULE, CAL_EVENT_TODO_TYPE, account_id);
+ snprintf(sql_value, sizeof(sql_value), "SELECT * FROM %s "
+ "WHERE type=%d AND account_id = %d AND is_deleted = 0 ORDER BY id",
+ CALS_TABLE_SCHEDULE, CALS_SCH_TYPE_TODO, account_id);
else
- sprintf(sql_value,"SELECT * FROM %s WHERE type=%d AND is_deleted = 0 ",
- CALS_TABLE_SCHEDULE, CAL_EVENT_TODO_TYPE);
+ snprintf(sql_value, sizeof(sql_value), "SELECT * FROM %s "
+ "WHERE type=%d AND is_deleted = 0 ORDER BY id",
+ CALS_TABLE_SCHEDULE, CALS_SCH_TYPE_TODO);
type = CAL_STRUCT_TYPE_TODO;
}
else if(0 == strcmp(data_type,CAL_STRUCT_CALENDAR))
{
if (account_id)
- sprintf(sql_value,"SELECT rowid,* FROM %s WHERE account_id = %d", CALS_TABLE_CALENDAR, account_id);
+ snprintf(sql_value, sizeof(sql_value), "SELECT rowid,* FROM %s WHERE account_id = %d", CALS_TABLE_CALENDAR, account_id);
else
- sprintf(sql_value,"SELECT rowid,* FROM %s", CALS_TABLE_CALENDAR);
+ snprintf(sql_value, sizeof(sql_value), "SELECT rowid,* FROM %s", CALS_TABLE_CALENDAR);
type = CAL_STRUCT_TYPE_CALENDAR;
}
return CAL_ERR_ARG_INVALID;
}
+ DBG("query(%s)", sql_value);
stmt = cals_query_prepare(sql_value);
retvm_if(NULL == stmt, CAL_ERR_DB_FAILED, "cals_query_prepare() Failed");
return CAL_SUCCESS;
}
-
-API int calendar_svc_get_list(int account_id, int calendar_id,
- const char *data_type,const char *field_type, int offset,int count, cal_iter **iter)
-{
- CALS_FN_CALL;
- int type;
- sqlite3_stmt *stmt = NULL;
- char sql_value[CALS_SQL_MAX_LEN] = {0};
-
- retv_if(NULL == data_type, CAL_ERR_ARG_NULL);
- retv_if(NULL == iter, CAL_ERR_ARG_NULL);
- retvm_if(calendar_id < 0, CAL_ERR_ARG_INVALID, "calendar_id(%d) is Invalid", calendar_id);
-
- if(0 == strcmp(data_type,CAL_STRUCT_SCHEDULE))
- {
- if(account_id == ALL_VISIBILITY_ACCOUNT || calendar_id==ALL_VISIBILITY_ACCOUNT)
- {
- sprintf(sql_value,"SELECT A.id, A.summary, A.location, A.all_day_event,"
- "A.start_date_time,A.end_date_time,A.repeat_item,A.week_start,A.week_flag,A.calendar_id "
- "FROM %s A, %s B "
- "WHERE A.type=%d AND B.visibility = 1 AND A.calendar_id = B.rowid AND A.is_deleted = 0 "
- "ORDER BY A.start_date_time LIMIT %d, %d",
- CALS_TABLE_SCHEDULE, CALS_TABLE_CALENDAR, CAL_EVENT_SCHEDULE_TYPE, offset, count);
- }
- else
- {
- char cond[CALS_SQL_MIN_LEN];
- cond[0] = '\0';
-
- if (account_id)
- sprintf(cond,"type=%d AND account_id = %d AND",CAL_EVENT_SCHEDULE_TYPE,account_id);
-
- if (calendar_id)
- sprintf(cond,"type=%d AND calendar_id = %d AND",CAL_EVENT_SCHEDULE_TYPE,calendar_id);
-
- sprintf(sql_value,"SELECT id,summary,location,all_day_event,"
- "start_date_time,end_date_time,repeat_item,week_start,week_flag,calendar_id "
- "FROM %s WHERE %s is_deleted = 0 ORDER BY start_date_time LIMIT %d,%d;",
- CALS_TABLE_SCHEDULE, cond, offset, count);
- }
-
- type = CAL_STRUCT_TYPE_SCHEDULE_LIST;
- }
- else if (0 == strcmp(data_type,CAL_STRUCT_TODO)) {
- //cond_size = sprintf(condition_value,"WHERE A.type=%d AND",CAL_EVENT_TODO_TYPE);
- ERR("data_type(%s) is not supported", data_type);
- return CAL_ERR_ARG_INVALID;
- }
- else {
- //cond_size = sprintf(condition_value,"WHERE ");
- ERR("data_type(%s) is not supported", data_type);
- return CAL_ERR_ARG_INVALID;
- }
-
- stmt = cals_query_prepare(sql_value);
- retvm_if(NULL == stmt, CAL_ERR_DB_FAILED, "cals_query_prepare() Failed");
-
- *iter = calloc(1, sizeof(cal_iter));
- retvm_if(NULL == *iter, CAL_ERR_OUT_OF_MEMORY, "calloc() Failed(%d)", errno);
-
- (*iter)->stmt = stmt;
- (*iter)->i_type = type;
-
- return CAL_SUCCESS;
-}
-
-
-API int calendar_svc_search_list(int account_id,int calendar_id,const char *data_type,const char *search_type,const void *search_value,
- int offset,int count, cal_iter **iter)
-{
- CALS_FN_CALL;
- sqlite3_stmt *stmt = NULL;
- char sql_value[CALS_SQL_MAX_LEN] = {0};
- int rc = 0;
- char condition_value[CALS_SQL_MAX_LEN] = {0};
- char search_str[CALS_SQL_MAX_LEN] = {0};
- cal_value_type_t value_type = 0;
-
- retv_if(NULL == data_type, CAL_ERR_FAIL);
- retv_if(NULL == search_type, CAL_ERR_FAIL);
- retv_if(NULL == search_value, CAL_ERR_FAIL);
- retv_if(CALS_SQL_MIN_LEN < strlen(search_value), CAL_ERR_FAIL);
- retv_if(NULL == iter, CAL_ERR_FAIL);
- retv_if(calendar_id < 0, CAL_ERR_FAIL);
-
- *iter = calloc(1, sizeof(cal_iter));
- retvm_if(NULL == *iter, CAL_ERR_OUT_OF_MEMORY, "calloc() Failed(%d)", errno);
-
- value_type = __calendar_svc_get_type(CAL_STRUCT_TYPE_SCHEDULE, search_type);
-
- switch(value_type)
- {
- case VALUE_TYPE_TEXT:
-
- retex_if(search_value == NULL,,"search_value is NULL");
- cals_escape_like_pattern(search_value, search_str, sizeof(search_str));
- DBG("%s %s", search_value, search_str);
-
- if(ALL_VISIBILITY_ACCOUNT == account_id)
- {
- sprintf(condition_value,"where st.type=%d and upper(%s) like upper('%%%s%%') ESCAPE '\\'",CAL_EVENT_SCHEDULE_TYPE, search_type, search_str);
- }
- else if(0 != account_id)
- {
- sprintf(condition_value,"where st.type=%d and upper(%s) like upper('%%%s%%') ESCAPE '\\'and account_id = %d",CAL_EVENT_SCHEDULE_TYPE, search_type, search_str, account_id);
- }
- else
- {
- sprintf(condition_value,"where st.type=%d and upper(%s) like upper('%%%s%%') ESCAPE '\\'",CAL_EVENT_SCHEDULE_TYPE, search_type, search_str);
- }
- break;
- case VALUE_TYPE_INT:
- if(ALL_VISIBILITY_ACCOUNT == account_id)
- {
- sprintf(condition_value,"where st.type=%d and %s = %d ",CAL_EVENT_SCHEDULE_TYPE, search_type,(int)search_value);
- }
- else if(0 != account_id)
- {
- sprintf(condition_value,"where st.type=%d and %s = %d and account_id = %d",CAL_EVENT_SCHEDULE_TYPE, search_type, (int)search_value, account_id);
- }
- else
- {
- sprintf(condition_value,"where st.type=%d and %s = %d ",CAL_EVENT_SCHEDULE_TYPE, search_type, (int)search_value);
- }
- break;
-
- case VALUE_TYPE_TIME:
- case VALUE_TYPE_DOUBLE:
- case VALUE_TYPE_USER:
- retex_if(true,,"Can not find");
- default:
- break;
- }
-
- if(0 == strcmp(data_type,CAL_STRUCT_SCHEDULE))
- {
- if(account_id == ALL_VISIBILITY_ACCOUNT || calendar_id==ALL_VISIBILITY_ACCOUNT)
- {
- sprintf(sql_value,"select st.id,st.summary,st.location,st.all_day_event,st.start_date_time,st.end_date_time,st.repeat_item,st.week_start,st.week_flag,st.calendar_id "
- "from schedule_table as st, calendar_table as ct %s "
- "and ct.visibility = 1 and st.calendar_id = ct.rowid and "
- "st.is_deleted = 0 order by st.summary limit %d,%d ;",condition_value,offset,count);
- }
- else
- {
-
- sprintf(sql_value,"select st.id,st.summary,st.location,st.all_day_event,st.start_date_time,st.end_date_time,st.repeat_item,st.week_start,st.week_flag,st.calendar_id "\
- "from schedule_table as st %s and is_deleted = 0 order by st.summary limit %d,%d ;",condition_value,offset,count);
- }
-
- (*iter)->i_type = CAL_STRUCT_TYPE_SCHEDULE_LIST;
- }
-
- rc = sqlite3_prepare_v2(calendar_db_handle, sql_value, strlen(sql_value), &stmt, NULL);
- retex_if(rc != SQLITE_OK,,"[ERROR]calendar_svc_get_all:Failed to get stmt!(sql:%s)\n",sql_value);
-
- (*iter)->stmt = stmt;
-
-
- return CAL_SUCCESS;
-
-CATCH:
-
- if (iter && *iter != NULL)
- {
- CAL_FREE(*iter);
- }
-
- if (stmt != NULL)
- {
- sqlite3_finalize(stmt);
- stmt = NULL;
- }
-
- return CAL_ERR_FAIL;
-}
-
-
API int calendar_svc_update(cal_struct *record)
{
CALS_FN_CALL;
ret = cals_begin_trans();
retvm_if(CAL_SUCCESS != ret, ret, "cals_begin_trans() Failed(%d)", ret);
- if(0 == strcmp(data_type,CAL_STRUCT_SCHEDULE) || 0 == strcmp(data_type,CAL_STRUCT_TODO)) {
+ if(0 == strcmp(data_type, CAL_STRUCT_SCHEDULE) || 0 == strcmp(data_type, CAL_STRUCT_TODO)) {
ret = cals_delete_schedule(index);
if (ret) {
cals_end_trans(false);
ERR("cals_delete_schedule() Failed(%d)", ret);
return ret;
}
- } else if(0 == strcmp(data_type,CAL_STRUCT_CALENDAR)) {
- if(DEFAULT_CALENDAR_ID == index) {
+ } else if(0 == strcmp(data_type, CAL_STRUCT_CALENDAR)) {
+ if(DEFAULT_EVENT_CALENDAR_ID == index || (DEFAULT_TODO_CALENDAR_ID == index)) {
cals_end_trans(false);
return CAL_ERR_FAIL;
}
}
-static inline int cals_remove_alarms_by_period(int calendar_id, time_t start_time, time_t end_time)
-{
- int ret = 0;
- char query[CALS_SQL_MIN_LEN];
- sqlite3_stmt *stmt = NULL;
-
- if (calendar_id)
- sprintf(query, "SELECT id FROM %s WHERE start_date_time >= %ld AND start_date_time <= %ld AND calendar_id = %d",
- CALS_TABLE_SCHEDULE, start_time, end_time, calendar_id);
- else
- sprintf(query, "SELECT id FROM %s WHERE start_date_time >= %ld AND start_date_time <= %ld",
- CALS_TABLE_SCHEDULE, start_time, end_time);
-
- stmt = cals_query_prepare(query);
- retvm_if(NULL == stmt, CAL_ERR_DB_FAILED, "cals_query_prepare() Failed");
-
- ret = cals_stmt_step(stmt);
- if (ret < CAL_SUCCESS) {
- sqlite3_finalize(stmt);
- ERR("cals_stmt_step() Failed(%d)", ret);
- return ret;
- }
-
- while(CAL_TRUE == ret)
- {
- cals_alarm_remove(CALS_ALARM_REMOVE_BY_EVENT_ID, sqlite3_column_int(stmt,0));
- ret = cals_stmt_step(stmt);
- }
- sqlite3_finalize(stmt);
-
- return CAL_SUCCESS;
-}
-
-
-API int calendar_svc_event_delete_by_period(int calendar_id, time_t start_time, time_t end_time)
-{
- CALS_FN_CALL;
- char sql[CALS_SQL_MIN_LEN] = {0};
- int ret = 0;
-
- retvm_if(start_time < 0, CAL_ERR_ARG_INVALID, "start_time(%ld) Invalid", start_time);
- retvm_if(end_time < 0, CAL_ERR_ARG_INVALID, "end_time(%ld) Invalid", end_time);
-
- ret = cals_begin_trans();
- retvm_if(CAL_SUCCESS != ret, ret, "cals_begin_trans() Failed(%d)", ret);
-
- ret = cals_remove_alarms_by_period(calendar_id, start_time, end_time);
- if (CAL_SUCCESS != ret) {
- cals_end_trans(false);
- ERR("cals_remove_alarms_by_period() Failed(%d)", ret);
- return ret;
- }
-
- time_t current_time = time(NULL);
-
- if (calendar_id)
- sprintf(sql,"UPDATE %s SET is_deleted = 1,sync_status = %d,last_modified_time = %ld "
- "WHERE start_date_time >= %ld AND start_date_time <= %ld AND calendar_id = %d",
- CALS_TABLE_SCHEDULE, CAL_SYNC_STATUS_DELETED, current_time, start_time, end_time, calendar_id);
- else
- sprintf(sql,"UPDATE %s SET is_deleted = 1,sync_status = %d,last_modified_time = %ld "
- "WHERE start_date_time >= %ld AND start_date_time <= %ld",
- CALS_TABLE_SCHEDULE, CAL_SYNC_STATUS_DELETED, current_time, start_time, end_time);
-
- ret = cals_query_exec(sql);
- if (CAL_SUCCESS != ret) {
- cals_end_trans(false);
- ERR("cals_query_exec() Failed(%d)", ret);
- return ret;
- }
- cals_end_trans(true);
-
- cals_notify(CALS_NOTI_TYPE_EVENT);
-
- return CAL_SUCCESS;
-}
-
-
API int calendar_svc_delete_account (int account_id)
{
CALS_FN_CALL;
return CAL_SUCCESS;
}
-
-API int calendar_svc_clean_after_sync(int account_id)
+API int calendar_svc_clean_after_sync(int calendar_id)
{
- CALS_FN_CALL;
- int ret = 0;
- char sql[256] = {0};
+ int ret;
+ int id;
+ char query[CALS_SQL_MIN_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
- retvm_if(account_id < 0, CAL_ERR_ARG_INVALID, "account_id(%d) is Invalid", account_id);
+ retvm_if(calendar_id < 0, CAL_ERR_ARG_INVALID, "calendar_id(%d) is Invalid", calendar_id);
- if(account_id)
- sprintf(sql,"delete from %s where (is_deleted = 1 and account_id = %d);",
- CALS_TABLE_SCHEDULE, account_id);
- else
- sprintf(sql,"delete from %s where is_deleted = 1;", CALS_TABLE_SCHEDULE);
+ /* delete recur table */
+ /* get event id which id_delete = 1 */
+ snprintf(query, sizeof(query), "SELECT id FROM %s "
+ "WHERE is_delete = 1 AND calendar_id = %d",
+ CALS_TABLE_SCHEDULE,
+ calendar_id);
+ stmt = cals_query_prepare(query);
+ retvm_if(stmt == NULL, CAL_ERR_DB_FAILED, "Failed to query prepare");
- ret = cals_query_exec(sql);
- retvm_if(ret, ret, "cals_query_exec() Failed(%d)", ret);
+ /* delete all recur data */
+ while (sqlite3_step(stmt) == SQLITE_ROW) {
+ id = sqlite3_column_int(stmt, 0);
+ if (id < 0) {
+ ERR("FAiled to get rruel_id");
+ break;
+ }
+
+ snprintf(query, sizeof(query), "DELETE FROM %s WHERE rrule_id = %d",
+ CALS_TABLE_RRULE, id);
+ ret = cals_query_exec(query);
+ if (ret != CAL_SUCCESS) {
+ ERR("Failed to query exit");
+ break;
+ }
+ }
+ sqlite3_finalize(stmt);
+
+ /* delete event table */
+ snprintf(query, sizeof(query), "DELETE FROM %s "
+ "WHERE is_deleted = 1 AND calendar_id = %d",
+ CALS_TABLE_SCHEDULE,
+ calendar_id);
+
+ ret = cals_query_exec(query);
+ 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",
+ CALS_TABLE_DELETED,
+ calendar_id);
+
+ ret = cals_query_exec(query);
+ retvm_if(ret < 0, ret, "cals_query_exec() failed (%d)", ret);
return CAL_SUCCESS;
}
-
API int calendar_svc_delete_all(int account_id, const char *data_type)
{
int ret = 0;
if(data_type == NULL) //delete all data from db by account id
{
- ret = __cal_service_delete_all_records(account_id, CAL_EVENT_NONE);
+ ret = __cal_service_delete_all_records(account_id, CALS_SCH_TYPE_NONE);
retvm_if(CAL_SUCCESS != ret, ret, "__cal_service_delete_all_records() Failed(%d)", ret);
ret = cals_delete_calendars(account_id);
retvm_if(CAL_SUCCESS != ret, ret, "cals_delete_calendars() Failed(%d)", ret);
}
else if(0 == strcmp(data_type,CAL_STRUCT_SCHEDULE))
{
- ret = __cal_service_delete_all_records(account_id, CAL_EVENT_SCHEDULE_TYPE);
+ ret = __cal_service_delete_all_records(account_id, CALS_SCH_TYPE_EVENT);
retvm_if(CAL_SUCCESS != ret, ret, "__cal_service_delete_all_records() Failed(%d)", ret);
}
else if(0 == strcmp(data_type,CAL_STRUCT_TODO))
{
- ret = __cal_service_delete_all_records(account_id, CAL_EVENT_TODO_TYPE);
+ ret = __cal_service_delete_all_records(account_id, CALS_SCH_TYPE_TODO);
retvm_if(CAL_SUCCESS != ret, ret, "__cal_service_delete_all_records() Failed(%d)", ret);
}
else if(0 == strcmp(data_type,CAL_STRUCT_CALENDAR))
if(ALL_VISIBILITY_ACCOUNT == account_id)
{
- sprintf(sql_value,
- "SELECT * FROM %s WHERE %s like upper('%%%s%%') AND is_deleted = 0 ORDER BY start_date_time;",
+ snprintf(sql_value, sizeof(sql_value),
+ "SELECT * FROM %s "
+ "WHERE %s like upper('%%%s%%') AND is_deleted = 0 "
+ "ORDER BY dtstart_utime;",
CALS_TABLE_SCHEDULE, search_type, (char*)search_value);
}
else if(0 != account_id)
{
- sprintf(sql_value,
- "SELECT * FROM %s WHERE %s like upper('%%%s%%') AND is_deleted = 0 and account_id = %d ORDER BY start_date_time;",
+ snprintf(sql_value, sizeof(sql_value),
+ "SELECT * FROM %s "
+ "WHERE %s like upper('%%%s%%') AND account_id = %d AND is_deleted = 0 "
+ "ORDER BY dtstart_utime;",
CALS_TABLE_SCHEDULE, search_type, (char*)search_value, account_id);
}
else
{
- sprintf(sql_value,
- "SELECT * FROM %s WHERE %s like upper('%%%s%%') AND is_deleted = 0 ORDER BY start_date_time;",
+ snprintf(sql_value, sizeof(sql_value),
+ "SELECT * FROM %s "
+ "WHERE %s like upper('%%%s%%') AND is_deleted = 0 "
+ "ORDER BY dtstart_utime;",
CALS_TABLE_SCHEDULE, search_type, (char*)search_value);
}
break;
case VALUE_TYPE_INT:
if(ALL_VISIBILITY_ACCOUNT == account_id)
{
- sprintf(sql_value,
- "SELECT * FROM %s WHERE %s = %d AND is_deleted = 0 ORDER BY start_date_time;",
+ snprintf(sql_value, sizeof(sql_value),
+ "SELECT * FROM %s "
+ "WHERE %s = %d AND is_deleted = 0 "
+ "ORDER BY dtstart_utime;",
CALS_TABLE_SCHEDULE, search_type,(int)search_value);
}
else if(0 != account_id)
{
- sprintf(sql_value,
- "SELECT * FROM %s WHERE %s = %d AND is_deleted = 0 AND account_id = %d ORDER BY start_date_time;",
+ snprintf(sql_value, sizeof(sql_value),
+ "SELECT * FROM %s "
+ "WHERE %s = %d AND account_id = %d AND is_deleted = 0 "
+ "ORDER BY dtstart_utime;",
CALS_TABLE_SCHEDULE, search_type, (int)search_value, account_id);
}
else
{
- sprintf(sql_value,
- "SELECT * FROM %s WHERE %s = %d AND is_deleted = 0 ORDER BY start_date_time;",
+ snprintf(sql_value, sizeof(sql_value),
+ "SELECT * FROM %s "
+ "WHERE %s = %d AND is_deleted = 0 "
+ "ORDER BY dtstart_utime;",
CALS_TABLE_SCHEDULE, search_type, (int)search_value);
}
break;
case VALUE_TYPE_USER:
if (0 == strcmp(CAL_VALUE_INT_ALARMS_ID, search_type)) {
ret = cals_alarm_get_event_id((int)search_value);
- sprintf(sql_value,
- "SELECT * FROM %s WHERE id = %d AND is_deleted = 0 ORDER BY start_date_time",
+ snprintf(sql_value, sizeof(sql_value),
+ "SELECT * FROM %s "
+ "WHERE id = %d AND is_deleted = 0 "
+ "ORDER BY dtstart_utime",
CALS_TABLE_SCHEDULE, ret);
break;
}
return CAL_SUCCESS;
}
-
-API int calendar_svc_find_recurring_event_list(int account_id, cal_iter **iter)
+API int calendar_svc_convert_id_to_uid(const char *data_type,int index,char **uid)
{
- CALS_FN_CALL;
+ int rc = -1;
+ char sql_value[CALS_SQL_MAX_LEN] = {0};
sqlite3_stmt *stmt = NULL;
- char sql_value[512] = {0};
-
- retv_if(NULL == iter, CAL_ERR_ARG_NULL);
+ int return_value = CAL_SUCCESS;
- *iter = calloc(1, sizeof(cal_iter));
- retvm_if(NULL == *iter, CAL_ERR_OUT_OF_MEMORY, "calloc() Failed(%d)", errno);
+ retex_if(uid == NULL,return_value = CAL_ERR_ARG_NULL, "The calendar database hasn't been opened.");
- if(0 != account_id)
- snprintf(sql_value, sizeof(sql_value), "select * from %s where repeat_item > 0 and is_deleted = 0 and account_id = %d",
- CALS_TABLE_SCHEDULE, account_id);
- else
- snprintf(sql_value, sizeof(sql_value), "select * from %s where repeat_item > 0 and is_deleted = 0;",
- CALS_TABLE_SCHEDULE);
+ retex_if(NULL == calendar_db_handle, return_value = CAL_ERR_DB_NOT_OPENED, "The calendar database hasn't been opened.");
- stmt = cals_query_prepare(sql_value);
- if (NULL == stmt) {
- ERR("cals_query_prepare() Failed");
- free(*iter);
- return CAL_ERR_DB_FAILED;
+ // TODO: make query!!!!
+ if((0 == strcmp(data_type,CAL_STRUCT_SCHEDULE)) || (0 == strcmp(data_type,CAL_STRUCT_TODO)))
+ {
+ snprintf(sql_value, sizeof(sql_value), "select uid from schedule_table where id=%d;",index);
+ }
+ else if(0 == strcmp(data_type,CAL_STRUCT_CALENDAR))
+ {
+ snprintf(sql_value, sizeof(sql_value), "select uid from calendar_table where rowid=%d;",index);
}
- (*iter)->stmt = stmt;
- (*iter)->i_type = CAL_STRUCT_TYPE_SCHEDULE;
- return CAL_SUCCESS;
-}
-
-
-API int calendar_svc_find_event_list_by_filter(int account_id, int filter_count, const char *search_type[], const void *search_value[], cal_iter **iter)
-{
- CALS_FN_CALL;
-
- int i, j, cond_len = 0;
- int rc = 0;
- sqlite3_stmt *stmt = NULL;
- char sql_value[2560] = {0};
- char sql_condition_value[2048] = {0};
- char sql_temp[256] = {0};
- cal_value_type_t value_type = 0;
- bool category_table_used = false;
-
- retex_if(0 >= filter_count,,"Invalid parameter(filter_count).\n");
- retex_if(NULL == iter,,"Invalid parameter(iter).\n");
-
- if(*iter == NULL)
- {
- *iter = malloc(sizeof(cal_iter));
- retex_if(NULL == *iter,,"Failed to malloc!\n");
- }
- memset(*iter,0x00,sizeof(cal_iter));
-
- for (i=0; i<filter_count; i++)
- {
- value_type = __calendar_svc_get_type(CAL_STRUCT_TYPE_SCHEDULE, search_type[i]);
- memset(sql_temp, 0, sizeof(sql_temp));
- switch(value_type)
- {
- case VALUE_TYPE_TEXT:
- if(search_value[i] == NULL)
- {
- return CAL_ERR_ARG_NULL;
- }
- if(!strncmp(CAL_VALUE_TXT_MEETING_CATEGORY_DETAIL_NAME, search_type[i], 128))
- {
- snprintf(sql_temp, sizeof(sql_temp), "schedule_table.id = cal_meeting_category_table.event_id and cal_meeting_category_table.category_name like upper('%s') and ", (char*)search_value[i]);
- category_table_used = true;
- }
- else
- {
- snprintf(sql_temp, sizeof(sql_temp), "upper(%s) like upper('%s') and ", search_type[i], (char*)search_value[i]);
- }
- break;
- case VALUE_TYPE_INT:
- if(!strncmp(CAL_VALUE_INT_MEETING_STATUS, search_type[i], 128))
- {
- int len;
- char *status_string = (char*)search_value[i];
- int status_length = strlen(status_string);
- len = snprintf(sql_temp, sizeof(sql_temp), "(");
- CALS_DBG("status string: %s", status_string);
- for(j=0;j<status_length;j++)
- {
- len += snprintf(sql_temp+len, sizeof(sql_temp)-len, "%s = %c ", search_type[i], status_string[j]);
- if(status_length-1 > j)
- len += snprintf(sql_temp+len, sizeof(sql_temp)-len, "or ");
- }
- len += snprintf(sql_temp+len, sizeof(sql_temp)-len, ") and ");
- if(sizeof(sql_temp) <= len) {
- ERR("condition is too long");
- free(*iter);
- return CAL_ERR_ARG_INVALID;
- }
- }
- else
- {
- snprintf(sql_temp, sizeof(sql_temp), "%s = %d and", search_type[i], (int)search_value[i]);
- }
- break;
- case VALUE_TYPE_TIME:
- // Doesn't consider the recurrence.
- if(!strncmp(CAL_VALUE_GMT_START_DATE_TIME, search_type[i], 128)) // start time min value
- {
- snprintf(sql_temp, sizeof(sql_temp), "%s >= %d and ", search_type[i], (int)search_value[i]);
- }
- if(!strncmp(CAL_VALUE_GMT_END_DATE_TIME, search_type[i], 128)) // start time max value
- {
- snprintf(sql_temp, sizeof(sql_temp), "%s <= %d and ", CAL_VALUE_GMT_START_DATE_TIME, (int)search_value[i]);
- }
- break;
- case VALUE_TYPE_DOUBLE:
- case VALUE_TYPE_USER:
- retex_if(true,,"Can not find!\n");
- default:
- break;
- }
-
- cond_len += snprintf(sql_condition_value+cond_len, sizeof(sql_condition_value)-cond_len, "%s", sql_temp);
- if(sizeof(sql_condition_value) <= cond_len) {
- ERR("condition is too long");
- free(*iter);
- return CAL_ERR_ARG_INVALID;
- }
- }
- if(0 != account_id)
- {
- if(false==category_table_used)
- snprintf(sql_value, sizeof(sql_value), "select schedule_table.* from schedule_table where %s is_deleted = 0 and account_id = %d;", sql_condition_value, account_id);
- else
- snprintf(sql_value, sizeof(sql_value), "select schedule_table.* from schedule_table, cal_meeting_category_table where %s is_deleted = 0 and account_id = %d;", sql_condition_value, account_id);
- }
- else
- {
- if(false==category_table_used)
- snprintf(sql_value, sizeof(sql_value), "select schedule_table.* from schedule_table where %s is_deleted = 0;", sql_condition_value);
- else
- snprintf(sql_value, sizeof(sql_value), "select schedule_table.* from schedule_table, cal_meeting_category_table where %s is_deleted = 0;", sql_condition_value);
- }
-
- rc = sqlite3_prepare_v2(calendar_db_handle, sql_value, strlen(sql_value), &stmt, NULL);
- retex_if(rc != SQLITE_OK,,"[ERROR]calendar_svc_find_event_list_by_filter: Failed to get stmt!(%s)\n", sql_value);
-
- (*iter)->stmt = stmt;
- (*iter)->i_type = CAL_STRUCT_TYPE_SCHEDULE;
- return CAL_SUCCESS;
-CATCH:
- if (iter && *iter != NULL)
- {
- CAL_FREE(*iter);
- }
- if (stmt != NULL)
- {
- sqlite3_finalize(stmt);
- stmt = NULL;
- }
- return CAL_ERR_FAIL;
-}
-
-
-static inline int __calendar_svc_find_calendar_list(int account_id,int calendar_id,const char *search_type,const void *search_value, cal_iter **iter)
-{
- sqlite3_stmt *stmt = NULL;
- char sql_value[CALS_SQL_MIN_LEN] = {0};
- int rc = 0;
- cal_value_type_t value_type = 0;
-
- //retex_if(0 < account_id,,"[ERROR]calendar_svc_find_event_list:Invalid parameter(account_id)");
- retex_if(NULL == search_type ,," [ERROR]calendar_svc_find_event_list:Invalid parameter(search_type).\n");
- retex_if(NULL == iter,," [ERROR]calendar_svc_find_event_list:Invalid parameter(iter).\n");
-
- *iter = calloc(1, sizeof(cal_iter));
- retvm_if(NULL == *iter, CAL_ERR_OUT_OF_MEMORY, "calloc() Failed(%d)", errno);
-
- value_type = __calendar_svc_get_type(CAL_STRUCT_TYPE_CALENDAR,search_type);
-
- switch(value_type)
- {
- case VALUE_TYPE_TEXT:
- if(account_id)
- sprintf(sql_value,
- "select rowid,* from calendar_table where %s like '%%%s%%' and is_deleted = 0 and account_id = %d ORDER BY start_date_time;",
- search_type, (char*)search_value, account_id);
- else
- sprintf(sql_value,
- "select rowid,* from calendar_table where %s like '%%%s%%' and is_deleted = 0 ORDER BY start_date_time;",
- search_type, (char*)search_value);
- break;
- case VALUE_TYPE_INT:
- if(account_id)
- sprintf(sql_value,
- "select rowid,* from calendar_table where %s = %d and is_deleted = 0 and account_id = %d ORDER BY start_date_time;",
- search_type, (int)search_value, account_id);
- else
- sprintf(sql_value,
- "select rowid,* from calendar_table where %s = %d and is_deleted = 0 ORDER BY start_date_time;",
- search_type, (int)search_value);
- break;
- case VALUE_TYPE_TIME:
- case VALUE_TYPE_DOUBLE:
- case VALUE_TYPE_USER:
- default:
- retex_if(true,,"Can not find!\n");
- }
-
- rc = sqlite3_prepare_v2(calendar_db_handle, sql_value, strlen(sql_value), &stmt, NULL);
- retex_if(rc != SQLITE_OK,,"[ERROR]calendar_svc_find_event_list:Failed to get stmt!(%s)\n",sql_value);
-
- (*iter)->stmt = stmt;
- (*iter)->i_type = CAL_STRUCT_TYPE_SCHEDULE;
-
- return CAL_SUCCESS;
-
-CATCH:
-
- if (iter && *iter != NULL)
- {
- CAL_FREE(*iter);
- }
-
- if (stmt != NULL)
- {
- sqlite3_finalize(stmt);
- stmt = NULL;
- }
-
-
- return CAL_ERR_FAIL;
-
-}
-
-
-static inline int __calendar_svc_find_timezone_list(int account_id,int calendar_id,const char *search_type,const void *search_value, cal_iter **iter)
-{
- sqlite3_stmt *stmt = NULL;
- char sql_value[CALS_SQL_MIN_LEN] = {0};
- int rc = 0;
- cal_value_type_t value_type = 0;
-
- //retex_if(0 < account_id,,"[ERROR]calendar_svc_find_event_list:Invalid parameter(account_id)");
- retex_if(NULL == search_type ,,"Invalid parameter(search_type)");
- retex_if(NULL == iter,,"Invalid parameter(iter)");
-
- *iter = calloc(1, sizeof(cal_iter));
- retvm_if(NULL == *iter, CAL_ERR_OUT_OF_MEMORY, "calloc() Failed(%d)", errno);
-
- value_type = __calendar_svc_get_type(CAL_STRUCT_TYPE_TIMEZONE,search_type);
-
- switch(value_type)
- {
- case VALUE_TYPE_TEXT:
- if(0 != account_id)
- sprintf(sql_value,"select rowid,* from timezone_table where %s like '%%%s%%' and account_id = %d;", search_type, (char*)search_value, account_id);
- else
- sprintf(sql_value,"select rowid,* from timezone_table where %s like '%%%s%%' ;", search_type, (char*)search_value);
-
- break;
- case VALUE_TYPE_INT:
- if(0 != account_id)
- sprintf(sql_value,"select rowid,* from timezone_table where %s = %d and account_id = %d;", search_type, (int)search_value, account_id);
- else
- sprintf(sql_value,"select rowid,* from timezone_table where %s = %d ;", search_type, (int)search_value);
- break;
- case VALUE_TYPE_TIME:
- case VALUE_TYPE_DOUBLE:
- case VALUE_TYPE_USER:
- default:
- retex_if(true,,"Can not find!\n");
- }
-
- rc = sqlite3_prepare_v2(calendar_db_handle, sql_value, strlen(sql_value), &stmt, NULL);
- retex_if(rc != SQLITE_OK,,"ailed to get stmt!(%s)",sql_value);
-
- (*iter)->stmt = stmt;
- (*iter)->i_type = CAL_STRUCT_TYPE_TIMEZONE;
-
- return CAL_SUCCESS;
-
-CATCH:
-
- if (iter && *iter != NULL)
- {
- CAL_FREE(*iter);
- }
-
- if (stmt != NULL)
- {
- sqlite3_finalize(stmt);
- stmt = NULL;
- }
-
-
- return CAL_ERR_FAIL;
-
-}
-
-
-API int calendar_svc_find(int account_id,int calendar_id,const char *data_type,const char *search_type,const void *search_value, cal_iter **iter)
-{
- retv_if(NULL == data_type, CAL_ERR_ARG_NULL);
-
- if(0 == strcmp(data_type,CAL_STRUCT_SCHEDULE))
- {
- calendar_svc_find_event_list(account_id,search_type,search_value,iter);
- }
- else if(0 == strcmp(data_type,CAL_STRUCT_CALENDAR))
- {
- __calendar_svc_find_calendar_list(account_id, calendar_id, search_type, search_value, iter);
- }
- else if(0 == strcmp(data_type,CAL_STRUCT_TIMEZONE))
- {
- __calendar_svc_find_timezone_list(account_id, calendar_id, search_type, search_value, iter);
- }
- else {
- ERR("Unknown Type(%s)", data_type);
- return CAL_ERR_FAIL;
- }
-
- return CAL_SUCCESS;
-}
-
-
-API int calendar_svc_get_updated_event_list(int account_id, time_t timestamp, cal_iter **iter)
-{
- CALS_FN_CALL;
- sqlite3_stmt *stmt = NULL;
- char sql_value[CALS_SQL_MIN_LEN] = {0};
-
- cal_iter *iter_value = NULL;
-
- retv_if(NULL == iter, CAL_ERR_ARG_NULL);
- retvm_if(timestamp < 0, CAL_ERR_ARG_INVALID, "timestamp(%ld) is Invalid", timestamp);
-
- iter_value = calloc(1, sizeof(cal_iter));
- retvm_if(NULL == iter_value, CAL_ERR_OUT_OF_MEMORY, "calloc() Failed");
-
- if (account_id)
- sprintf(sql_value,"SELECT * FROM %s WHERE last_modified_time > %ld AND account_id = %d",
- CALS_TABLE_SCHEDULE, timestamp, account_id);
- else
- sprintf(sql_value,"SELECT * FROM %s WHERE last_modified_time > %ld",
- CALS_TABLE_SCHEDULE, timestamp);
-
- stmt = cals_query_prepare(sql_value);
- if (NULL == stmt) {
- ERR("cals_query_prepare() Failed");
- free(iter_value);
- return CAL_ERR_DB_FAILED;
- }
-
- iter_value->stmt = stmt;
- iter_value->i_type = CAL_STRUCT_TYPE_SCHEDULE;
- *iter = iter_value;
-
- return CAL_SUCCESS;
-}
-
-
-
-API int calendar_svc_get_month_event_list_by_period(int account_id,
- time_t startdate, time_t enddate, cal_iter **iter)
-{
- CALS_FN_CALL;
- sqlite3_stmt *stmt = NULL;
- char sql_value[CALS_SQL_MIN_LEN] = {0};
- time_t gm_startdate = 0;
- time_t gm_enddate =0;
-
- //retex_if(0 > account_id,,"[ERROR]calendar_svc_get_event_list_by_period:Invalid parameter(account_id)!\n");
- retv_if(NULL == iter, CAL_ERR_ARG_NULL);
- retv_if(startdate < 0, CAL_ERR_ARG_INVALID);
- retv_if(enddate < 0, CAL_ERR_ARG_INVALID);
-
- //switch((*iter)->i_type)
- //{
- // case CAL_STRUCT_TYPE_SCHEDULE:
- //calendar_svc_util_local_to_gmt(startdate,&gm_startdate);
- //calendar_svc_util_local_to_gmt(enddate,&gm_enddate);
- gm_startdate = startdate - SECSPERDAY;
- gm_enddate = enddate + SECSPERDAY;
-
- *iter = calloc(1, sizeof(cal_iter));
- retvm_if(NULL == *iter, CAL_ERR_OUT_OF_MEMORY,"calloc() Failed(%d)", errno);
-
- (*iter)->is_patched = FALSE;
-
- if(account_id == ALL_VISIBILITY_ACCOUNT) {
- sprintf(sql_value,"select schedule_table.* from schedule_table,calendar_table "\
- "where schedule_table.type=%d and schedule_table.is_deleted = 0 "\
- "and schedule_table.calendar_id = calendar_table.rowid and calendar_table.visibility = 1 "\
- "and ((schedule_table.repeat_item = 0 and schedule_table.start_date_time <= %d and schedule_table.end_date_time >=%d) "\
- "or (schedule_table.repeat_item<>0 and schedule_table.repeat_end_date>=%d)) limit 10;"
- ,CAL_EVENT_SCHEDULE_TYPE, (int)gm_enddate,(int)gm_startdate, (int)gm_startdate);
- } else {
- if(0 != account_id) {
- sprintf(sql_value,"select * from schedule_table where type=%d and is_deleted = 0 and account_id = %d and\
- ((repeat_item = 0 and start_date_time <= %d and end_date_time >=%d) \
- or (repeat_item<>0 and repeat_end_date>=%d));"
- ,CAL_EVENT_SCHEDULE_TYPE,account_id, (int)gm_enddate,(int)gm_startdate, (int)gm_startdate);
- } else {
- sprintf(sql_value,"select * from schedule_table where type=%d and is_deleted = 0 and\
- ((repeat_item = 0 and start_date_time <= %d and end_date_time >=%d) \
- or (repeat_item<>0 and repeat_end_date>=%d));"
- ,CAL_EVENT_SCHEDULE_TYPE, (int)gm_enddate,(int)gm_startdate, (int)gm_startdate);
- }
- }
- stmt = cals_query_prepare(sql_value);
- if (NULL == stmt) {
- ERR("cals_query_prepare() Failed");
- free(*iter);
- return CAL_ERR_DB_FAILED;
- }
-
- (*iter)->stmt = stmt;
- (*iter)->i_type = CAL_STRUCT_TYPE_SCHEDULE;
-
- return CAL_SUCCESS;
-}
-
-
-API int calendar_svc_get_event_list_by_period (int account_id, time_t startdate, time_t enddate, cal_iter **iter)
-{
- CALS_FN_CALL;
- sqlite3_stmt *stmt = NULL;
- char sql_value[CALS_SQL_MIN_LEN] = {0};
- int rc = 0;
- time_t gm_startdate = 0;
- time_t gm_enddate =0;
-
- //retex_if(0 > account_id,,"[ERROR]calendar_svc_get_event_list_by_period:Invalid parameter(account_id)!\n");
- retex_if(NULL == iter,,"[ERROR]calendar_svc_get_event_list_by_period:Invalid parameter(iter)!\n");
- retex_if(startdate < 0,,"[ERROR]calendar_svc_get_event_list_by_period:Invalid parameter(startdate)!\n");
- retex_if(enddate < 0,,"[ERROR]calendar_svc_get_event_list_by_period:Invalid parameter(enddate)!\n");
-
- //switch((*iter)->i_type)
- //{
- // case CAL_STRUCT_TYPE_SCHEDULE:
- gm_startdate = startdate - SECSPERDAY;
- gm_enddate = enddate + SECSPERDAY;
-
- *iter = calloc(1, sizeof(cal_iter));
- retvm_if(NULL == *iter, CAL_ERR_OUT_OF_MEMORY, "calloc() Failed(%d)", errno);
-
- (*iter)->is_patched = FALSE;
-
- if(account_id == ALL_VISIBILITY_ACCOUNT)
- {
- sprintf(sql_value,"select schedule_table.* from schedule_table,calendar_table "\
- "where schedule_table.type=%d and schedule_table.is_deleted = 0 "\
- "and schedule_table.calendar_id = calendar_table.rowid and calendar_table.visibility = 1 "\
- "and ((schedule_table.repeat_item = 0 and schedule_table.start_date_time <= %d and schedule_table.end_date_time >=%d) "\
- "or (schedule_table.repeat_item<>0 and schedule_table.repeat_end_date>=%d));"
- ,CAL_EVENT_SCHEDULE_TYPE, (int)gm_enddate,(int)gm_startdate, (int)gm_startdate);
- }
- else
- {
-
- if(0 != account_id)
- {
- sprintf(sql_value,"select * from schedule_table where type=%d and is_deleted = 0 and account_id = %d and\
- ((repeat_item = 0 and start_date_time <= %d and end_date_time >=%d) \
- or (repeat_item<>0 and repeat_end_date>=%d));"
- ,CAL_EVENT_SCHEDULE_TYPE,account_id, (int)gm_enddate,(int)gm_startdate, (int)gm_startdate);
- }
- else
- {
- sprintf(sql_value,"select * from schedule_table where type=%d and is_deleted = 0 and\
- ((repeat_item = 0 and start_date_time <= %d and end_date_time >=%d) \
- or (repeat_item<>0 and repeat_end_date>=%d));"
- ,CAL_EVENT_SCHEDULE_TYPE, (int)gm_enddate,(int)gm_startdate, (int)gm_startdate);
- }
-
- }
- rc = sqlite3_prepare_v2(calendar_db_handle, sql_value, strlen(sql_value), &stmt, NULL);
- retex_if(rc != SQLITE_OK,printf("errmsg is %s\n",sqlite3_errmsg(calendar_db_handle)),"[ERROR]calendar_svc_get_event_list_by_period:Failed to get stmt!\n");
-
-
- (*iter)->stmt = stmt;
- (*iter)->i_type = CAL_STRUCT_TYPE_SCHEDULE;
-
- return CAL_SUCCESS;
-
-CATCH:
-
- if (iter)
- {
- CAL_FREE(*iter);
- }
-
- if (stmt != NULL)
- {
- sqlite3_finalize(stmt);
- stmt = NULL;
- }
-
- return CAL_ERR_FAIL;
-}
-
-
-
-API int calendar_svc_get_event_list_by_tm_period (int account_id,int calendar_id, struct tm* startdate, struct tm* enddate, cal_iter **iter)
-{
- CALS_FN_CALL;
- sqlite3_stmt *stmt = NULL;
- char sql_value[CALS_SQL_MIN_LEN] = {0};
- int rc = 0;
-
- time_t gm_startdate = 0;
- time_t gm_enddate =0;
- time_t local_startdate = 0;
- time_t local_enddate =0;
- //retex_if(0 > account_id,,"[ERROR]calendar_svc_get_event_list_by_period:Invalid parameter(account_id)!\n");
- retex_if(NULL == iter,,"[ERROR]calendar_svc_get_event_list_by_period:Invalid parameter(iter)!\n");
- retex_if(startdate < 0,,"[ERROR]calendar_svc_get_event_list_by_period:Invalid parameter(startdate)!\n");
- retex_if(enddate < 0,,"[ERROR]calendar_svc_get_event_list_by_period:Invalid parameter(enddate)!\n");
-
- //switch((*iter)->i_type)
- //{
- // case CAL_STRUCT_TYPE_SCHEDULE:
- local_startdate = cals_mktime(startdate);
- local_enddate = cals_mktime(enddate);
-
- calendar_svc_util_local_to_gmt(local_startdate,&gm_startdate);
- calendar_svc_util_local_to_gmt(local_enddate,&gm_enddate);
-
- *iter = calloc(1, sizeof(cal_iter));
- retvm_if(NULL == *iter, CAL_ERR_OUT_OF_MEMORY, "calloc() Failed(%d)", errno);
- (*iter)->is_patched = FALSE;
-
- if(account_id == ALL_VISIBILITY_ACCOUNT)
- {
- sprintf(sql_value,"select schedule_table.* from schedule_table,calendar_table "\
- "where schedule_table.type=%d and schedule_table.is_deleted = 0 "\
- "and schedule_table.calendar_id = calendar_table.rowid and calendar_table.visibility = 1 "\
- "and ((schedule_table.repeat_item = 0 and schedule_table.start_date_time <= %d and schedule_table.end_date_time >=%d) "\
- "or (schedule_table.repeat_item<>0 and schedule_table.repeat_end_date>=%d));"
- ,CAL_EVENT_SCHEDULE_TYPE,(int)gm_enddate,(int)gm_startdate, (int)gm_startdate);
-
- DBG("%s",sql_value);
- }
- else
- {
-
- if(0 != calendar_id)
- {
- sprintf(sql_value,"select * from schedule_table where type=%d and is_deleted = 0 and calendar_id = %d and\
- ((repeat_item = 0 and start_date_time <= %d and end_date_time >=%d) \
- or (repeat_item<>0 and repeat_end_date>=%d));"
- ,CAL_EVENT_SCHEDULE_TYPE,calendar_id, (int)gm_enddate,(int)gm_startdate, (int)gm_startdate);
- }
- else if(0 != account_id)
- {
- sprintf(sql_value,"select * from schedule_table where type=%d and is_deleted = 0 and account_id = %d and\
- ((repeat_item = 0 and start_date_time <= %d and end_date_time >=%d) \
- or (repeat_item<>0 and repeat_end_date>=%d));"
- ,CAL_EVENT_SCHEDULE_TYPE,account_id, (int)gm_enddate,(int)gm_startdate, (int)gm_startdate);
- }
- else
- {
- sprintf(sql_value,"select * from schedule_table where type=%d and is_deleted = 0 and\
- ((repeat_item = 0 and start_date_time <= %d and end_date_time >=%d) \
- or (repeat_item<>0 and repeat_end_date>=%d));"
- ,CAL_EVENT_SCHEDULE_TYPE, (int)gm_enddate,(int)gm_startdate, (int)gm_startdate);
- }
- }
-
- rc = sqlite3_prepare_v2(calendar_db_handle, sql_value, strlen(sql_value), &stmt, NULL);
- retex_if(rc != SQLITE_OK,,"[ERROR]calendar_svc_get_event_list_by_period:Failed to get stmt!\n");
-
- (*iter)->stmt = stmt;
- (*iter)->i_type = CAL_STRUCT_TYPE_SCHEDULE;
-
- return CAL_SUCCESS;
-
-CATCH:
-
- if (iter)
- {
- CAL_FREE(*iter);
- }
-
- if (stmt != NULL)
- {
- sqlite3_finalize(stmt);
- stmt = NULL;
- }
-
- return CAL_ERR_FAIL;
-}
-
-
-API int calendar_svc_convert_id_to_uid(const char *data_type,int index,char **uid)
-{
- int rc = -1;
- char sql_value[CALS_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
- int return_value = CAL_SUCCESS;
-
- retex_if(uid == NULL,return_value = CAL_ERR_ARG_NULL, "The calendar database hasn't been opened.");
-
- retex_if(NULL == calendar_db_handle, return_value = CAL_ERR_DB_NOT_OPENED, "The calendar database hasn't been opened.");
-
- //sprintf(sql_value, "select * from cal_participant_table where event_id = %d;", panticipant_index);
- // TODO: make query!!!!
- if((0 == strcmp(data_type,CAL_STRUCT_SCHEDULE)) || (0 == strcmp(data_type,CAL_STRUCT_TODO)))
- {
- sprintf(sql_value,"select uid from schedule_table where id=%d;",index);
- }
- else if(0 == strcmp(data_type,CAL_STRUCT_CALENDAR))
- {
- sprintf(sql_value,"select uid from calendar_table where rowid=%d;",index);
- }
-
-
- rc = sqlite3_prepare_v2(calendar_db_handle, sql_value, strlen(sql_value), &stmt, NULL);
- retex_if(rc != SQLITE_OK, return_value = CAL_ERR_DB_FAILED, "Failed to get stmt!!");
-
- rc = sqlite3_step(stmt);
- retex_if(rc!= SQLITE_ROW && rc!= SQLITE_OK && rc!= SQLITE_DONE, return_value = CAL_ERR_DB_FAILED, "[ERROR]cal_db_service_get_participant_info_by_index:Query error !!");
-
- cal_db_get_text_from_stmt(stmt,uid,0);
-
- if (stmt != NULL)
- {
- sqlite3_finalize(stmt);
- stmt = NULL;
- }
-
- return CAL_SUCCESS;
-
-CATCH:
-
- if (stmt != NULL)
- {
- sqlite3_finalize(stmt);
- stmt = NULL;
- }
-
- return return_value;
-}
-
-int calendar_svc_convert_uid_to_id(const char *data_type,char *uid,int *index)
-{
- int rc = -1;
- char sql_value[CALS_SQL_MAX_LEN] = {0};
- sqlite3_stmt *stmt = NULL;
- int return_value = CAL_SUCCESS;
-
- retex_if(uid == NULL, return_value = CAL_ERR_ARG_NULL, "The calendar database hasn't been opened.");
-
- retex_if(NULL == calendar_db_handle, return_value = CAL_ERR_DB_NOT_OPENED, "The calendar database hasn't been opened.");
-
- //sprintf(sql_value, "select * from cal_participant_table where event_id = %d;", panticipant_index);
- // TODO: make query!!!!
- if((0 == strcmp(data_type,CAL_STRUCT_SCHEDULE)) || (0 == strcmp(data_type,CAL_STRUCT_TODO)))
- {
- sprintf(sql_value,"select id from schedule_table where uid=%s;",uid);
- }
- else if(0 == strcmp(data_type,CAL_STRUCT_CALENDAR))
- {
- sprintf(sql_value,"select rowid from calendar_table where uid=%s;",uid);
- }
-
-
- rc = sqlite3_prepare_v2(calendar_db_handle, sql_value, strlen(sql_value), &stmt, NULL);
- retex_if(rc != SQLITE_OK, return_value = CAL_ERR_DB_FAILED, "Failed to get stmt!!");
-
- rc = sqlite3_step(stmt);
- retex_if(rc!= SQLITE_ROW && rc!= SQLITE_OK && rc!= SQLITE_DONE, return_value = CAL_ERR_DB_FAILED, "[ERROR]cal_db_service_get_participant_info_by_index:Query error !!");
-
- *index = sqlite3_column_int(stmt,0);
-
- if (stmt != NULL)
- {
- sqlite3_finalize(stmt);
- stmt = NULL;
- }
-
- return CAL_SUCCESS;
-
-CATCH:
-
- if (stmt != NULL)
- {
- sqlite3_finalize(stmt);
- stmt = NULL;
- }
-
- return return_value;
-}
-
-
-API int calendar_svc_iter_get_info(cal_iter *iter, cal_struct **row_event)
-{
- cal_sch_full_t *sch_record = NULL;
- calendar_t *cal_record = NULL;
- cal_timezone_t *tz_record = NULL;
-
- retv_if(NULL == iter, CAL_ERR_ARG_NULL);
- retv_if(NULL == iter->stmt, CAL_ERR_ARG_INVALID);
- retv_if(NULL == row_event, CAL_ERR_ARG_NULL);
-
- if(iter->is_patched!=TRUE)
- {
- int ret = calendar_svc_iter_next(iter);
- if(ret == CAL_ERR_FINISH_ITER)
- return CAL_ERR_NO_DATA;
- else if(ret != CAL_SUCCESS)
- return ret;
- }
-
- int error_code = 0;
-
- switch(iter->i_type)
- {
- case CAL_STRUCT_TYPE_SCHEDULE_LIST:
- if (NULL == *row_event)
- {
- *row_event = calendar_svc_struct_new(CAL_STRUCT_SCHEDULE);
- retvm_if(NULL == *row_event, CAL_ERR_FAIL, "calendar_svc_struct_new(SCHEDULE) Failed");
- }
- sch_record = (*row_event)->user_data;
- retvm_if(NULL == sch_record, CAL_ERR_FAIL, "row_event is Invalid");
-
- cal_db_service_convert_stmt_to_list_field_record(iter->stmt,sch_record,true);
- break;
- case CAL_STRUCT_TYPE_SCHEDULE:
- if (NULL == *row_event)
- {
- *row_event = calendar_svc_struct_new(CAL_STRUCT_SCHEDULE);
- retvm_if(NULL == *row_event, CAL_ERR_FAIL, "calendar_svc_struct_new(SCHEDULE) Failed");
- }
- sch_record = (cal_sch_full_t*)(*row_event)->user_data;
- retvm_if(NULL == sch_record, CAL_ERR_FAIL, "row_event is Invalid");
-
- cals_stmt_get_full_schedule(iter->stmt,sch_record,true);
-
- cal_db_service_get_participant_info_by_index(sch_record->index,&(sch_record->attendee_list),&error_code);
- cal_db_service_get_meeting_category_info_by_index(sch_record->index,&(sch_record->meeting_category),&error_code);
- cal_db_service_get_recurrency_exception(sch_record->index,&(sch_record->exception_date_list),&error_code);
- cals_get_alarm_info(sch_record->index, &(sch_record->alarm_list));
-
- break;
- case CAL_STRUCT_TYPE_TODO:
- if (NULL == *row_event)
- {
- *row_event = calendar_svc_struct_new(CAL_STRUCT_TODO);
- retvm_if(NULL == *row_event, CAL_ERR_FAIL, "calendar_svc_struct_new(TODO) Failed");
- }
- sch_record = (cal_sch_full_t*)(*row_event)->user_data;
- retvm_if(NULL == sch_record, CAL_ERR_FAIL, "row_event is Invalid");
-
- cals_stmt_get_full_schedule(iter->stmt,sch_record,true);
-
- break;
-
- case CAL_STRUCT_TYPE_CALENDAR:
- if (NULL == *row_event)
- {
- *row_event = calendar_svc_struct_new(CAL_STRUCT_CALENDAR);
- retvm_if(NULL == *row_event, CAL_ERR_FAIL, "calendar_svc_struct_new(CALENDAR) Failed");
- }
- cal_record = (calendar_t*)(*row_event)->user_data;
- retvm_if(NULL == cal_record, CAL_ERR_FAIL, "row_event is Invalid");
-
- cals_stmt_get_calendar(iter->stmt,cal_record);
-
- break;
- case CAL_STRUCT_TYPE_TIMEZONE:
- if (NULL == *row_event)
- {
- *row_event = calendar_svc_struct_new(CAL_STRUCT_TIMEZONE);
- retvm_if(NULL == *row_event, CAL_ERR_FAIL, "calendar_svc_struct_new(TIMEZONE) Failed");
- }
- tz_record = (cal_timezone_t*)(*row_event)->user_data;
- retvm_if(NULL == tz_record, CAL_ERR_FAIL, "row_event is Invalid");
-
- cal_db_service_convert_stmt_to_tz_info(iter->stmt,tz_record);
- break;
- default:
- break;
- }
-
- return CAL_SUCCESS;
-}
-
-
-API int calendar_svc_iter_next(cal_iter *iter)
-{
- int ret = 0;
-
- retv_if(NULL == iter, CAL_ERR_ARG_NULL);
-
- if (iter->is_patched == FALSE)
- iter->is_patched = TRUE;
-
- ret = cals_stmt_step(iter->stmt);
- retvm_if(ret < CAL_SUCCESS, ret, "cals_stmt_step() Failed(%d)", ret);
-
- if (CAL_SUCCESS == ret)
- return CAL_ERR_FINISH_ITER;
-
- return CAL_SUCCESS;
-}
-
-API int calendar_svc_iter_remove(cal_iter **iter)
-{
- CALS_FN_CALL;
- retv_if(NULL == iter, CAL_ERR_ARG_NULL);
- retv_if(NULL == *iter, CAL_ERR_ARG_NULL);
-
- if ((*iter)->stmt)
- {
- sqlite3_finalize((*iter)->stmt);
- (*iter)->stmt = NULL;
- }
-
- free(*iter);
- *iter = NULL;
-
- return CAL_SUCCESS;
-}
-
-
-API int calendar_svc_util_next_valid_event(cal_struct *event, time_t start_time,
- time_t end_time, time_t *next_valid_start_time, time_t *next_valid_end_time)
-{
- CALS_FN_CALL;
- int ret = 0;
- cal_sch_full_t *temp_sch_full;
- static cal_date_param_t cal_date_param;
- struct tm start_tm, end_tm;
- struct tm event_start_tm = {0};
- struct tm event_end_tm = {0};
-
- retv_if(NULL == event, CAL_ERR_ARG_NULL);
- retv_if(NULL == event->user_data, CAL_ERR_ARG_INVALID);
- retv_if(NULL == next_valid_start_time, CAL_ERR_ARG_NULL);
- retv_if(NULL == next_valid_end_time, CAL_ERR_ARG_NULL);
-
- retvm_if(start_time < 0, CAL_ERR_ARG_INVALID, "start_time(%ld) is Invalid", start_time);
- retvm_if(end_time < 0, CAL_ERR_ARG_INVALID, "end_time(%ld) is Invalid", end_time);
-
- temp_sch_full = event->user_data;
-
- memcpy(&event_start_tm,cals_tmtime(&start_time),sizeof(struct tm));
- memcpy(&event_end_tm,cals_tmtime(&end_time),sizeof(struct tm));
-
- if((*next_valid_start_time == 0) && (*next_valid_end_time == 0))
- {
- cal_service_set_date_param(&cal_date_param, temp_sch_full);
- }
-
- ret = cal_db_service_get_next_valid_exception_time(temp_sch_full,
- &cal_date_param,cal_date_param.exception_date_list,&event_start_tm,&event_end_tm,&start_tm,&end_tm);
- retvm_if(ret, ret, "cal_db_service_get_next_valid_exception_time() Failed(%d)", ret);
-
- *next_valid_start_time = mktime(&start_tm);
- *next_valid_end_time = mktime(&end_tm);
-
- //ERR("%d-start_tm(%d/%d/%d %d)",temp_sch_full->index, start_tm.tm_year+1900,start_tm.tm_mon+1,start_tm.tm_mday,start_tm.tm_hour);
- //ERR("%d-end_tm(%d/%d/%d %d)",temp_sch_full->index,end_tm.tm_year+1900,end_tm.tm_mon+1,end_tm.tm_mday,end_tm.tm_hour);
-
- return CAL_SUCCESS;
-}
-
-
-API int calendar_svc_util_next_valid_event_tm(cal_struct *event, struct tm *start_tm,
- struct tm *end_tm, struct tm *next_valid_start_tm, struct tm *next_valid_end_tm)
-{
- int ret = 0;
- cal_sch_full_t *temp_sch_full;
- static cal_date_param_t cal_date_param;
-
- retv_if(NULL == event, CAL_ERR_ARG_NULL);
- retv_if(NULL == event->user_data, CAL_ERR_ARG_INVALID);
- retv_if(NULL == next_valid_start_tm, CAL_ERR_ARG_NULL);
- retv_if(NULL == next_valid_end_tm, CAL_ERR_ARG_NULL);
- retv_if(NULL == start_tm, CAL_ERR_ARG_NULL);
- retv_if(NULL == end_tm, CAL_ERR_ARG_NULL);
-
- temp_sch_full = (cal_sch_full_t *)event->user_data;
-
- if((next_valid_start_tm->tm_year == 0) && (next_valid_end_tm->tm_year == 0))
- {
- cal_service_set_date_param(&cal_date_param, temp_sch_full);
- }
-
- ret = cal_db_service_get_next_valid_exception_time(temp_sch_full,
- &cal_date_param,cal_date_param.exception_date_list,start_tm,end_tm,next_valid_start_tm,next_valid_end_tm);
- retvm_if(ret, ret, "cal_db_service_get_next_valid_exception_time() Failed(%d)", ret);
-
- CALS_DBG("%d-start_tm(%d/%d/%d %d)",temp_sch_full->index, next_valid_start_tm->tm_year+1900,next_valid_start_tm->tm_mon+1,next_valid_start_tm->tm_mday,next_valid_start_tm->tm_hour);
- CALS_DBG("%d-end_tm(%d/%d/%d %d)",temp_sch_full->index,next_valid_end_tm->tm_year+1900,next_valid_end_tm->tm_mon+1,next_valid_end_tm->tm_mday,next_valid_end_tm->tm_hour);
-
- return CAL_SUCCESS;
-}
-
-
-time_t calendar_svc_util_mk_localtime(struct tm* tmTime)
-{
- retvm_if(NULL == tmTime,0,"Invalid parameter(tmTime)!\n");
-
- if(cal_svc_tm_value.is_initialize == false){
- cal_svc_set_tz_base_info(tmTime->tm_year); //local time
- }
-
- return cals_mktime(tmTime)-cal_svc_tm_value.localtime_offset;
-}
-
-API int calendar_svc_util_gmt_to_local (time_t fromTime, time_t *toTime)
-{
- retex_if(toTime==NULL,,"[ERROR]calendar_svc_util_gmt_to_local:Invalid parameter(toTime)!\n");
- struct tm * cur_time = NULL;
- struct tm ttm;
- cur_time = gmtime_r(&fromTime,&ttm);
-
- retex_if(cur_time==NULL,,"[ERROR]calendar_svc_util_gmt_to_local:Invalid parameter(fromTime)!\n");
-
- if( (cal_svc_tm_value.is_initialize == false) ||
- ((cal_svc_tm_value.local_dst_offset !=0) &&
- (cal_svc_tm_value.start_local_dst_date_time.tm_year != cur_time->tm_year)) ){
- cal_svc_set_tz_base_info(cur_time->tm_year); //local time
- }
-
- if( (cal_svc_tm_value.local_dst_offset !=0) &&
- (__cal_service_compare_date(&cal_svc_tm_value.start_local_dst_date_time,cur_time) > 0) &&
- (__cal_service_compare_date(cur_time,&cal_svc_tm_value.start_local_std_date_time) > 0) )
- {
- *toTime = fromTime+cal_svc_tm_value.local_dst_offset;
- }
- else
- *toTime = fromTime+cal_svc_tm_value.localtime_offset;
-
-
- return CAL_SUCCESS;
-CATCH:
-
- return CAL_ERR_FAIL;
-
-}
-
-API int calendar_svc_util_local_to_gmt (time_t fromTime, time_t *toTime)
-{
- retex_if(toTime==NULL,,"[ERROR]calendar_svc_util_local_to_gmt:Invalid parameter(toTime)!\n");
- struct tm * cur_time = NULL;
- struct tm ttm;
- cur_time = gmtime_r(&fromTime,&ttm);
- retex_if(cur_time==NULL,,"[ERROR]calendar_svc_util_local_to_gmt:Invalid parameter(fromTime)!\n");
-
-
- if( (cal_svc_tm_value.is_initialize == false) ||
- ((cal_svc_tm_value.local_dst_offset !=0) &&
- (cal_svc_tm_value.start_local_dst_date_time.tm_year != cur_time->tm_year)) ){
- cal_svc_set_tz_base_info(cur_time->tm_year); //local time
- }
-
- if( (cal_svc_tm_value.local_dst_offset !=0) &&
- (__cal_service_compare_date(&cal_svc_tm_value.start_local_dst_date_time,cur_time) > 0) &&
- (__cal_service_compare_date(cur_time,&cal_svc_tm_value.start_local_std_date_time) > 0) )
- {
- *toTime = fromTime-cal_svc_tm_value.local_dst_offset;
- }
- else
- *toTime = fromTime-cal_svc_tm_value.localtime_offset;
-
- return CAL_SUCCESS;
-CATCH:
-
- return CAL_ERR_FAIL;
-}
-
-static int get_num(const char *num)
-{
- if(NULL == num)
- {
- return -1;
- }
-
- int temp = 0;
-
- if(isdigit(num[0]))
- {
- temp = num[0]-'0';
- }
-
- if(isdigit(num[1]))
- {
- temp *= 10;
- temp += num[1]-'0';
- }
-
- return temp;
-}
-
-static int get_week(const char *week)
-{
- if(NULL == week)
- {
- return -1;
- }
-
- switch(week[0])
- {
- case 'M':
- return 1;
-
- case 'T':
- if(week[1] == 'u')
- {
- return 2;
- }
- else if(week[1] == 'h')
- {
- return 4;
- }
- else
- {
- return -1;
- }
-
- case 'W':
- return 3;
-
- case 'F':
- return 5;
-
- case 'S':
- if(week[1] == 'a')
- {
- return 6;
- }
- else if(week[1] == 'u')
- {
- return 0;
- }
- else
- return -1;
- default:
- return -1;
-
- }
-
-}
-
-static int get_month(const char *mon)
-{
- if(NULL == mon)
- {
- return -1;
- }
-
- switch(mon[0])
- {
- case 'J':
- if(mon[1] == 'a')
- {
- return 0;
- }
- else if(mon[1] == 'u')
- {
- if(mon[2] == 'n')
- {
- return 5;
- }
- else
- {
- return 6;
- }
-
- }
- else
- {
- return -1;
- }
-
- case 'F':
- return 1;
-
- case 'M':
- if(mon[2] == 'r')
- {
- return 2;
- }
- else if(mon[2] == 'y')
- {
- return 4;
- }
- else
- {
- return -1;
- }
-
- case 'A':
- if(mon[1] == 'p')
- {
- return 3;
- }
- else if(mon[1] == 'g')
- {
- return 7;
- }
- else
- {
- return -1;
- }
-
- case 'S':
- return 8;
-
- case 'O':
- return 9;
-
- case 'N':
- return 10;
-
- case 'D':
- return 11;
-
- default:
- return -1;
-
- }
-
-}
-
-static int get_time(char *line, struct tm* time)
-{
- if(NULL == line || NULL == time)
- {
- return CAL_ERR_FAIL;
- }
-
- char *p = strstr(line," = ");
- if(NULL != p)
- {
- p += 3;
- int temp = get_week(p);
- if(temp >= 0)
- {
- time->tm_wday = temp;
- }
-
- p += 4;
- temp = get_month(p);
- if(temp >= 0)
- {
- time->tm_mon = temp;
- }
-
- p += 4;
- temp = get_num(p);
- if(temp >= 0)
- {
- time->tm_mday = temp;
- }
-
- p += 3;
- temp = get_num(p);
- if(temp >= 0)
- {
- time->tm_hour = temp;
- }
-
- p += 3;
- temp = get_num(p);
- if(temp >= 0)
- {
- time->tm_min = temp;
- }
-
- p += 3;
- temp = get_num(p);
- if(temp >= 0)
- {
- time->tm_sec = temp;
- }
-
- }
-
- return CAL_SUCCESS;
-}
-
-
-static int get_offset(char *line, int *offset)
-{
- if(NULL == line || NULL == time)
- {
- return CAL_ERR_FAIL;
- }
-
- char *p = strstr(line,"gmtoff=");
- if(NULL != p)
- {
- //ERR("%s",p);
- p=p+7;
- *offset = atoi(p);
- }
-
- return CAL_SUCCESS;
-}
-
-
-API int calendar_svc_get_tz_info(char *tz_file_name,int year, struct tm* dst_start, struct tm* dst_end,int *base_offset,int *dst_offset)
-{
- CALS_FN_CALL;
- char line[1024] = {0};
- char cmd[1024] = {0};
- char year_str[10]= {0};
- bool is_start_time = true;
- bool is_set_base_offset = false;
- static FILE* fd = NULL;
-
- retex_if(NULL == tz_file_name || NULL == dst_start || NULL == dst_end,,"Invalid parameter!\n");
-
- //start->tm_year = year - 1900;
- //end->tm_year = year - 1900;
-
- snprintf(year_str,sizeof(year_str),"%4d UTC",year);
+ rc = sqlite3_prepare_v2(calendar_db_handle, sql_value, strlen(sql_value), &stmt, NULL);
+ retex_if(rc != SQLITE_OK, return_value = CAL_ERR_DB_FAILED, "Failed to get stmt!!");
- snprintf(cmd,sizeof(cmd),"zdump %s -v -c %d,%d",tz_file_name,year-1,year+1);
+ rc = sqlite3_step(stmt);
+ retex_if(rc!= SQLITE_ROW && rc!= SQLITE_OK && rc!= SQLITE_DONE, return_value = CAL_ERR_DB_FAILED, "[ERROR]cal_db_service_get_participant_info_by_index:Query error !!");
- if(!(fd = popen(cmd, "r")))
- return CAL_ERR_FAIL;
+ cal_db_get_text_from_stmt(stmt,uid,0);
- while(NULL != fgets(line,sizeof(line)-1,fd))
+ if (stmt != NULL)
{
- if(NULL != strstr(line,"isdst=1") && NULL != strstr(line,year_str))
- {
- if(is_start_time)
- {
- is_start_time = false;
- get_time(line,dst_start);
- dst_start->tm_year = year-1900;
- //ERR("%s %d-%d-%d %d",line,dst_start->tm_year,dst_start->tm_mon,dst_start->tm_mday,dst_start->tm_hour);
- }
- else
- {
- get_time(line,dst_end);
- get_offset(line,dst_offset);
- dst_end->tm_year = year-1900;
- //ERR("%s %d-%d-%d %d",line,dst_start->tm_year,dst_start->tm_mon,dst_start->tm_mday,dst_start->tm_hour);
- }
-
- }
- else if(is_set_base_offset == false)
- {
- get_offset(line,base_offset);
- //is_set_base_offset = true;
- }
+ sqlite3_finalize(stmt);
+ stmt = NULL;
}
- pclose(fd);
- ERR("%s base:%d dst:%d",tz_file_name,*base_offset,*dst_offset);
-
return CAL_SUCCESS;
CATCH:
- return CAL_ERR_FAIL;
-}
-
-
-API int calendar_svc_util_convert_db_time (struct tm* fromTime,char *fromTz, struct tm *toTime, char *toTz)
-{
- struct tm start_dst_date_time;
- struct tm start_std_date_time;
- int tz_offset=0;
- int dst_offset=0;
- time_t base_tt;
- struct tm temp_tm;
-
- retex_if(fromTime==NULL,,"[ERROR]calendar_svc_util_local_to_gmt:Invalid parameter(enddate)!\n");
- retex_if(toTime==NULL,,"[ERROR]calendar_svc_util_local_to_gmt:Invalid parameter(enddate)!\n");
- retex_if(fromTz==NULL,,"[ERROR]calendar_svc_util_local_to_gmt:Invalid parameter(enddate)!\n");
- retex_if(toTz==NULL,,"[ERROR]calendar_svc_util_local_to_gmt:Invalid parameter(enddate)!\n");
-
-
- base_tt = cals_mktime(fromTime);
- if(base_tt < 0)
- return 0;
- calendar_svc_util_gmt_to_local(base_tt,&base_tt);
- cals_tmtime_r(&base_tt,&temp_tm);
-
- //ERR("temp_tm(%d/%d/%d %d)",temp_tm.tm_year+1900,temp_tm.tm_mon+1,temp_tm.tm_mday,temp_tm.tm_hour);
-
- if(strcmp(toTz,"GMT")!=0)
+ if (stmt != NULL)
{
- if(strcmp(toTz,cal_svc_tm_value.local_tz_name) == 0)
- {
- dst_offset = cal_svc_tm_value.local_dst_offset;
- tz_offset = cal_svc_tm_value.localtime_offset;
- memcpy(&start_dst_date_time,&cal_svc_tm_value.start_local_dst_date_time,sizeof(struct tm));
- memcpy(&start_std_date_time,&cal_svc_tm_value.start_local_std_date_time,sizeof(struct tm));
- }
- else if(strcmp(toTz,cal_svc_tm_value.temp_tz_name) == 0)
- {
- dst_offset = cal_svc_tm_value.temp_dst_offset;
- tz_offset = cal_svc_tm_value.temptime_offset;
- memcpy(&start_dst_date_time,&cal_svc_tm_value.start_temp_dst_date_time,sizeof(struct tm));
- memcpy(&start_std_date_time,&cal_svc_tm_value.start_temp_std_date_time,sizeof(struct tm));
- }
- else
- {
- calendar_svc_get_tz_info(toTz,fromTime->tm_year+1900,
- &start_dst_date_time,
- &start_std_date_time,
- &tz_offset,&dst_offset);
- }
-
- if( (dst_offset !=0) &&
- (__cal_service_compare_date(&start_dst_date_time,&temp_tm) > 0) &&
- (__cal_service_compare_date(&temp_tm,&start_std_date_time) > 0) )
- {
- base_tt = base_tt-dst_offset;
- }
- else
- base_tt = base_tt-tz_offset;
+ sqlite3_finalize(stmt);
+ stmt = NULL;
}
- cals_tmtime_r(&base_tt,toTime);
-
- //ERR("tzinfo(%s:(%d->%d) %d, %d)",toTz,cals_mktime(fromTime),base_tt,tz_offset,dst_offset);
- //ERR("fromTime(%d/%d/%d %d)",fromTime->tm_year+1900,fromTime->tm_mon+1,fromTime->tm_mday,fromTime->tm_hour);
- //ERR("toTime(%d/%d/%d %d)\n\n",toTime->tm_year+1900,toTime->tm_mon+1,toTime->tm_mday,toTime->tm_hour);
-
- return CAL_SUCCESS;
-CATCH:
-
- return CAL_ERR_FAIL;
+ return return_value;
}
-
-
-API int calendar_svc_util_save_vcs_by_index (const int index, char *full_file_path)
+int calendar_svc_convert_uid_to_id(const char *data_type,char *uid,int *index)
{
- cal_sch_full_t sch_record_fulle = {0};
- int sch_count = 1;
- int error_code = 0;
- bool is_success = false;
-
- retv_if(NULL == full_file_path, CAL_ERR_ARG_NULL);
-
- is_success = cal_db_service_get_record_full_field_by_index(index,&sch_record_fulle,&error_code);
- retvm_if(!is_success, error_code, "cal_db_service_get_record_full_field_by_index() Failed(%d)", error_code);
+ int rc = -1;
+ char sql_value[CALS_SQL_MAX_LEN] = {0};
+ sqlite3_stmt *stmt = NULL;
+ int return_value = CAL_SUCCESS;
- cal_convert_cal_data_to_vdata_file(&sch_record_fulle,sch_count,full_file_path,&error_code);
- cal_db_service_free_full_record(&sch_record_fulle,&error_code);
+ retex_if(uid == NULL, return_value = CAL_ERR_ARG_NULL, "The calendar database hasn't been opened.");
- return CAL_SUCCESS;
-}
+ retex_if(NULL == calendar_db_handle, return_value = CAL_ERR_DB_NOT_OPENED, "The calendar database hasn't been opened.");
-API int calendar_svc_util_register_vcs_file (const char *file_name)
-{
- retv_if(NULL == file_name, CAL_ERR_ARG_NULL);
+ // TODO: make query!!!!
+ if((0 == strcmp(data_type,CAL_STRUCT_SCHEDULE)) || (0 == strcmp(data_type,CAL_STRUCT_TODO)))
+ {
+ snprintf(sql_value, sizeof(sql_value), "select id from schedule_table where uid=%s;",uid);
+ }
+ else if(0 == strcmp(data_type,CAL_STRUCT_CALENDAR))
+ {
+ snprintf(sql_value, sizeof(sql_value), "select rowid from calendar_table where uid=%s;",uid);
+ }
- return cal_vcalendar_register_vcs_file(file_name);
-}
-API int calendar_svc_util_convert_vcs_to_event (const char *raw_data,int data_size,cal_struct **record)
-{
- CALS_FN_CALL;
- //cal_vcalendar_register_vcs_file(file_name);
- cal_sch_full_t *sch_array = NULL;
- int sch_count = 0;
- int error_code = 0;
+ rc = sqlite3_prepare_v2(calendar_db_handle, sql_value, strlen(sql_value), &stmt, NULL);
+ retex_if(rc != SQLITE_OK, return_value = CAL_ERR_DB_FAILED, "Failed to get stmt!!");
- retex_if(NULL == record,,"[ERROR]calendar_svc_util_convert_vcs_to_event:Invalid parameter!\n");
- retex_if(NULL == raw_data,,"[ERROR]calendar_svc_util_convert_vcs_to_event:Invalid parameter!\n");
+ rc = sqlite3_step(stmt);
+ retex_if(rc!= SQLITE_ROW && rc!= SQLITE_OK && rc!= SQLITE_DONE, return_value = CAL_ERR_DB_FAILED, "[ERROR]cal_db_service_get_participant_info_by_index:Query error !!");
- bool is_success= FALSE;
- is_success = _cal_convert_vcalendar_to_cal_data(raw_data,&sch_array, &sch_count);
+ *index = sqlite3_column_int(stmt,0);
- if(is_success)
+ if (stmt != NULL)
{
- *record = (cal_struct*)malloc(sizeof(cal_struct));
- retex_if(NULL == *record,,"Failed to malloc!\n");
-
- (*record)->user_data = sch_array;
- //(*record)->event_type = CAL_STRUCT_TYPE_SCHEDULE;
- //SURC d.zakutailo 2010-06-03: (*record)->event_type must be obtained from _cal_convert_vcalendar_to_cal_data function. Don't use any predefined types directly.
- if (sch_array->cal_type == CAL_EVENT_SCHEDULE_TYPE) {
- (*record)->event_type = CAL_STRUCT_TYPE_SCHEDULE;
- } else
- if (sch_array->cal_type == CAL_EVENT_TODO_TYPE) {
- (*record)->event_type = CAL_STRUCT_TYPE_TODO;
- } else
- (*record)->event_type = sch_array->cal_type;
- return CAL_SUCCESS;
+ sqlite3_finalize(stmt);
+ stmt = NULL;
}
+ return CAL_SUCCESS;
+
CATCH:
- if(NULL != sch_array)
+ if (stmt != NULL)
{
- cal_db_service_free_full_record(sch_array,&error_code);
- CAL_FREE(sch_array);
+ sqlite3_finalize(stmt);
+ stmt = NULL;
}
- return CAL_ERR_FAIL;
-}
-
-API int calendar_svc_util_convert_event_to_vcs (cal_struct *record,char **raw_data,int *data_size)
-{
- bool is_success= FALSE;
-
- retv_if(NULL == record, CAL_ERR_ARG_NULL);
- retv_if(NULL == raw_data, CAL_ERR_ARG_NULL);
-
- is_success = _cal_convert_sch_to_vcalendar((cal_sch_full_t*)(record->user_data), 1,raw_data, CAL_VCAL_VER_1_0);
- retvm_if(!is_success, CAL_ERR_FAIL, "_cal_convert_sch_to_vcalendar() Failed");
-
- return CAL_SUCCESS;
+ return return_value;
}
-/* will be removed */
-int calendar_svc_util_set_calendar_timezone(const char *tzname)
+static void cals_iter_get_info_change(cals_updated *cursor, cals_updated *result)
{
- /* char zoneinfo[256]={0,};
- char cmd[256]={0,};
- sprintf(zoneinfo,"/usr/share/zoneinfo/%s",tzname);
-
- //calendar_svc_get_time_by_tzinfo(zoneinfo);
- //calendar_svc_get_time_by_tzinfo("/usr/share/zoneinfo/calendar_localtime");
- //sprintf(cmd,"rm -f /usr/share/zoneinfo/calendar_localtime");
- unlink("/usr/share/zoneinfo/calendar_localtime");
- sprintf(cmd,"ln -s %s /usr/share/zoneinfo/calendar_localtime",zoneinfo);
- execve(cmd);*/
-
- return CAL_SUCCESS;
+ result->type = cursor->type;
+ result->id = cursor->id;
+ result->ver = cursor->ver;
+ return;
}
-/* hidden api */
-API int calendar_svc_get_month_event_list (int account_id, time_t startdate, time_t enddate,int is_repeat, cal_iter **iter)
-{
- CALS_FN_CALL;
- int ret;
- sqlite3_stmt *stmt = NULL;
-
- retv_if(NULL == iter, CAL_ERR_ARG_NULL);
-
- *iter = calloc(1, sizeof(cal_iter));
- retvm_if(NULL == *iter, CAL_ERR_OUT_OF_MEMORY, "calloc() Failed(%d)", errno);
-
- ret = cal_db_service_get_month_event(account_id, startdate, enddate, is_repeat, &stmt);
- if (CAL_SUCCESS != ret) {
- ERR("cal_db_service_get_month_event() Failed(%d)", ret);
- free(*iter);
- *iter = NULL;
- return ret;
- }
-
- (*iter)->is_patched = FALSE;
- (*iter)->stmt = stmt;
- (*iter)->i_type = CAL_STRUCT_TYPE_SCHEDULE;
-
- return CAL_SUCCESS;
-}
-
-API int calendar_svc_iter_get_month_info (cal_iter *iter, int is_repeat,cal_struct **row_event)
+API int calendar_svc_iter_get_info(cal_iter *iter, cal_struct **row_event)
{
- CALS_FN_CALL;
+ int cnt;
+ int rc = 0;
+ char *s_datetime;
+ char *e_datetime;
+ char buf[8] = {0};
+ char sql_value[CALS_SQL_MIN_LEN] = {0};
cal_sch_full_t *sch_record = NULL;
+ calendar_t *cal_record = NULL;
+ cal_timezone_t *tz_record = NULL;
+ cals_updated *cal_updated = NULL;
+ sqlite3_stmt *stmt = NULL;
retv_if(NULL == iter, CAL_ERR_ARG_NULL);
- retv_if(NULL == iter->stmt, CAL_ERR_ARG_NULL);
+ retv_if(NULL == iter->stmt && NULL == iter->info, CAL_ERR_ARG_INVALID);
retv_if(NULL == row_event, CAL_ERR_ARG_NULL);
if(iter->is_patched!=TRUE)
int error_code = 0;
- if(*row_event == NULL)
+ switch(iter->i_type)
{
- *row_event = calendar_svc_struct_new(CAL_STRUCT_SCHEDULE);
- retvm_if(NULL == *row_event, CAL_ERR_OUT_OF_MEMORY, "calendar_svc_struct_new() Failed");
+ case CAL_STRUCT_TYPE_SCHEDULE:
+ if (NULL == *row_event)
+ {
+ *row_event = calendar_svc_struct_new(CAL_STRUCT_SCHEDULE);
+ retvm_if(NULL == *row_event, CAL_ERR_FAIL, "calendar_svc_struct_new(SCHEDULE) Failed");
+ }
+ sch_record = (cal_sch_full_t*)(*row_event)->user_data;
+ retvm_if(NULL == sch_record, CAL_ERR_FAIL, "row_event is Invalid");
- (*row_event)->event_type = CAL_STRUCT_TYPE_SCHEDULE;
- }
- sch_record = (cal_sch_full_t*)(*row_event)->user_data;
- retv_if(NULL == sch_record, CAL_ERR_FAIL);
+ cals_stmt_get_full_schedule(iter->stmt,sch_record,true);
- cal_db_service_convert_stmt_to_month_field_record(iter->stmt,is_repeat,sch_record,true);
+ if (sch_record->rrule_id > 0) {
+ snprintf(sql_value, sizeof(sql_value),
+ "SELECT * FROM %s WHERE event_id = %d ",
+ CALS_TABLE_RRULE, sch_record->index);
- if(is_repeat)
- cal_db_service_get_recurrency_exception(sch_record->index,&(sch_record->exception_date_list),&error_code);
+ stmt = cals_query_prepare(sql_value);
+ retvm_if(NULL == stmt, CAL_ERR_FAIL, "cals_query_prepare() Failed");
+ rc = cals_stmt_step(stmt);
+ retvm_if(CAL_TRUE != rc, CAL_ERR_FAIL, "cals_stmt_step() Failed(%d)", rc);
- return CAL_SUCCESS;
-}
-static inline void __set_day_flag(struct tm*stm,struct tm*etm,struct tm*estm,struct tm*eetm,int *day_flag)
-{
+ cals_stmt_fill_rrule(stmt, sch_record);
+ sqlite3_finalize(stmt);
+ stmt = NULL;
+ }
- int start_day = 0;
- int end_day = 0;
- int i = 0;
+ cal_db_service_get_participant_info_by_index(sch_record->index,&(sch_record->attendee_list),&error_code);
+ cals_get_alarm_info(sch_record->index, &(sch_record->alarm_list));
+ break;
- //ERR("stm(%d/%d/%d %d)",stm->tm_year+1900,stm->tm_mon+1,stm->tm_mday,stm->tm_hour);
- //ERR("etm(%d/%d/%d %d)",etm->tm_year+1900,etm->tm_mon+1,etm->tm_mday,etm->tm_hour);
- //ERR("estm(%d/%d/%d %d)",estm->tm_year+1900,estm->tm_mon+1,estm->tm_mday,estm->tm_hour);
- //ERR("eetm(%d/%d/%d %d)",eetm->tm_year+1900,eetm->tm_mon+1,eetm->tm_mday,eetm->tm_hour);
+ case CAL_STRUCT_TYPE_TODO:
+ if (NULL == *row_event)
+ {
+ *row_event = calendar_svc_struct_new(CAL_STRUCT_TODO);
+ retvm_if(NULL == *row_event, CAL_ERR_FAIL, "calendar_svc_struct_new(TODO) Failed");
+ }
+ sch_record = (cal_sch_full_t*)(*row_event)->user_data;
+ retvm_if(NULL == sch_record, CAL_ERR_FAIL, "row_event is Invalid");
- int istm = 0;
- int ietm = 0;
- int iestm = 0;
- int ieetm = 0;
+ cals_stmt_get_full_schedule(iter->stmt,sch_record,true);
- istm = timegm(stm)/ONE_DAY_SECONDS;
- ietm = timegm(etm)/ONE_DAY_SECONDS;
- iestm = timegm(estm)/ONE_DAY_SECONDS;
- ieetm = timegm(eetm)/ONE_DAY_SECONDS;
+ if (sch_record->rrule_id > 0) {
+ snprintf(sql_value, sizeof(sql_value),
+ "SELECT * FROM %s WHERE event_id = %d ",
+ CALS_TABLE_RRULE, sch_record->index);
- if(ieetm<istm)
- return; //imposible
+ stmt = cals_query_prepare(sql_value);
+ retvm_if(NULL == stmt, CAL_ERR_FAIL, "cals_query_prepare() Failed");
- if(iestm>ietm)
- return;
+ rc = cals_stmt_step(stmt);
+ retvm_if(CAL_TRUE != rc, CAL_ERR_FAIL, "cals_stmt_step() Failed(%d)", rc);
- if(iestm<istm)
- start_day = 1;
- else
- start_day = ((iestm-istm)+1);
+ cals_stmt_fill_rrule(stmt, sch_record);
+ sqlite3_finalize(stmt);
+ stmt = NULL;
+ }
+ break;
- if(ieetm<ietm)
- end_day = ((ieetm-istm)+1);
- else
- end_day = ((ietm-istm)+1);
+ case CAL_STRUCT_TYPE_CALENDAR:
+ if (NULL == *row_event)
+ {
+ *row_event = calendar_svc_struct_new(CAL_STRUCT_CALENDAR);
+ retvm_if(NULL == *row_event, CAL_ERR_FAIL, "calendar_svc_struct_new(CALENDAR) Failed");
+ }
+ cal_record = (calendar_t*)(*row_event)->user_data;
+ retvm_if(NULL == cal_record, CAL_ERR_FAIL, "row_event is Invalid");
- //ERR("%d,%d,%d,%d (%d,%d)",istm,ietm,iestm,ieetm,start_day,end_day);
- for(i=start_day-1;i<end_day;i++)
- {
- day_flag[i]++;
- }
-}
+ cals_stmt_get_calendar(iter->stmt,cal_record);
+ break;
+ case CAL_STRUCT_TYPE_TIMEZONE:
+ if (NULL == *row_event)
+ {
+ *row_event = calendar_svc_struct_new(CAL_STRUCT_TIMEZONE);
+ retvm_if(NULL == *row_event, CAL_ERR_FAIL, "calendar_svc_struct_new(TIMEZONE) Failed");
+ }
+ tz_record = (cal_timezone_t*)(*row_event)->user_data;
+ retvm_if(NULL == tz_record, CAL_ERR_FAIL, "row_event is Invalid");
-API int calendar_svc_get_month_event_check (int account_id, time_t startdate, time_t enddate, int *day_flag)
-{
- cal_iter *it = NULL;
- cal_struct *cs = NULL;
- int rc = 0;
+ cal_db_service_convert_stmt_to_tz_info(iter->stmt,tz_record);
+ break;
- struct tm lstm;
- struct tm letm;
+ case CAL_STRUCT_TYPE_UPDATED_LIST:
+ if (NULL == *row_event)
+ {
+ *row_event = calendar_svc_struct_new(CAL_STRUCT_UPDATED);
+ retvm_if (NULL == *row_event, CAL_ERR_FAIL, "calendar_svc_struct_new(CAL_STRUCT_UPDATE) Failed");
+ }
+ cal_updated = (cals_updated *)(*row_event)->user_data;
+ retvm_if(NULL == cal_updated, CAL_ERR_FAIL, "row_event is Invalid");
- struct tm stm ;
- struct tm etm ;
+ cals_iter_get_info_change(iter->info->cursor, cal_updated);
+ break;
- struct tm* temp_tm = NULL;
- struct tm estm;
- struct tm eetm;
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_ONOFF:
+ if (NULL == *row_event) {
+ *row_event = calendar_svc_struct_new(CALS_STRUCT_PERIOD_NORMAL_ONOFF);
+ retvm_if(NULL == *row_event, CAL_ERR_FAIL,
+ "Failed to new CALS_STRUCT_PERIOD_NORMAL_ONOFF");
+ }
+ cals_struct_period_normal_onoff *nof;
+ nof = (cals_struct_period_normal_onoff *)(*row_event)->user_data;
+ retvm_if(NULL == nof, CAL_ERR_FAIL, "user_data is NULL");
+
+ cnt = 0;
+ nof->index = sqlite3_column_int(iter->stmt, cnt++);
+ nof->dtstart_type = sqlite3_column_int(iter->stmt, cnt++);
+ nof->dtstart_utime = sqlite3_column_int64(iter->stmt, cnt++);
+ nof->dtend_type = sqlite3_column_int(iter->stmt, cnt++);
+ nof->dtend_utime = sqlite3_column_int64(iter->stmt, cnt++);
+ break;
- CALS_FN_CALL;
+ case CALS_STRUCT_TYPE_PERIOD_ALLDAY_ONOFF:
+ s_datetime = NULL;
+ if (NULL == *row_event) {
+ *row_event = calendar_svc_struct_new(CALS_STRUCT_PERIOD_ALLDAY_ONOFF);
+ retvm_if(NULL == *row_event, CAL_ERR_FAIL,
+ "Failed to new CALS_STRUCT_TYPE_PERIOD_ALLDAY_ONOFF");
+ }
+ cals_struct_period_allday_onoff *aof;
+ aof = (cals_struct_period_allday_onoff *)(*row_event)->user_data;
+ retvm_if(NULL == aof, CAL_ERR_FAIL, "user_data is NULL");
+
+ cnt = 0;
+ aof->index = sqlite3_column_int(iter->stmt, cnt++);
+ aof->dtstart_type = sqlite3_column_int(iter->stmt, cnt++);
+ cal_db_get_text_from_stmt(iter->stmt,&(s_datetime),cnt++);
+ memset(buf, 0x0, sizeof(buf));
+ snprintf(buf, strlen("YYYY") + 1, "%s", &s_datetime[0]);
+ aof->dtstart_year = atoi(buf);
+ memset(buf, 0x0, sizeof(buf));
+ snprintf(buf, strlen("MM") + 1, "%s", &s_datetime[4]);
+ aof->dtstart_month = atoi(buf);
+ memset(buf, 0x0, sizeof(buf));
+ snprintf(buf, strlen("DD") + 1, "%s", &s_datetime[6]);
+ aof->dtstart_mday = atoi(buf);
+
+ aof->dtend_type = sqlite3_column_int(iter->stmt, cnt++);
+ cal_db_get_text_from_stmt(iter->stmt,&(s_datetime), cnt++);
+ memset(buf, 0x0, sizeof(buf));
+ snprintf(buf, strlen("YYYY") + 1, "%s", &s_datetime[0]);
+ aof->dtend_year = atoi(buf);
+ memset(buf, 0x0, sizeof(buf));
+ snprintf(buf, strlen("MM") + 1, "%s", &s_datetime[4]);
+ aof->dtend_month = atoi(buf);
+ memset(buf, 0x0, sizeof(buf));
+ snprintf(buf, strlen("DD") + 1, "%s", &s_datetime[6]);
+ aof->dtend_mday = atoi(buf);
+ break;
- //retex_if(0 > account_id,,"[ERROR]calendar_svc_get_event_list_by_period:Invalid parameter(account_id)!\n");
- retvm_if(startdate < 0, CAL_ERR_ARG_INVALID, "startdate(%d) is Invalid", startdate);
- retvm_if(enddate < 0, CAL_ERR_ARG_INVALID, "enddate(%d) is Invalid", enddate);
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_BASIC:
+ if (NULL == *row_event) {
+ *row_event = calendar_svc_struct_new(CALS_STRUCT_PERIOD_NORMAL_BASIC);
+ retvm_if(NULL == *row_event, CAL_ERR_FAIL,
+ "Failed to new CALS_STRUCT_TYPE_PERIOD_NORMAL_BASIC");
+ }
+ cals_struct_period_normal_basic *nb;
+ nb = (cals_struct_period_normal_basic *)(*row_event)->user_data;
+ retvm_if(NULL == nb, CAL_ERR_FAIL, "user_data is NULL");
+
+ cnt = 0;
+ nb->index = sqlite3_column_int(iter->stmt, 0);
+ nb->dtstart_type = sqlite3_column_int(iter->stmt, 1);
+ nb->dtstart_utime = sqlite3_column_int64(iter->stmt, 2);
+ nb->dtend_type = sqlite3_column_int(iter->stmt, 3);
+ nb->dtend_utime = sqlite3_column_int64(iter->stmt, 4);
+ cal_db_get_text_from_stmt(iter->stmt,&(nb->summary), 5);
+ cal_db_get_text_from_stmt(iter->stmt,&(nb->location), 6);
+ break;
- localtime_r(&startdate, &stm);
- localtime_r(&enddate, &etm);
+ case CALS_STRUCT_TYPE_PERIOD_ALLDAY_BASIC:
+ s_datetime = NULL;
+ e_datetime = NULL;
+ if (NULL == *row_event) {
+ *row_event = calendar_svc_struct_new(CALS_STRUCT_PERIOD_ALLDAY_BASIC);
+ retvm_if(NULL == *row_event, CAL_ERR_FAIL,
+ "Failed to new CALS_STRUCT_TYPE_PERIOD_ALLDAY_BASIC");
+ }
+ cals_struct_period_allday_basic *ab;
+ ab = (cals_struct_period_allday_basic *)(*row_event)->user_data;
+ retvm_if(NULL == ab, CAL_ERR_FAIL, "user_data is NULL");
+
+ cnt = 0;
+ ab->index = sqlite3_column_int(iter->stmt, cnt++);
+ ab->dtstart_type = sqlite3_column_int(iter->stmt, cnt++);
+ cal_db_get_text_from_stmt(iter->stmt,&(s_datetime), cnt++);
+ memset(buf, 0x0, sizeof(buf));
+ snprintf(buf, strlen("YYYY") + 1, "%s", &s_datetime[0]);
+ ab->dtstart_year = atoi(buf);
+ memset(buf, 0x0, sizeof(buf));
+ snprintf(buf, strlen("MM") + 1, "%s", &s_datetime[4]);
+ ab->dtstart_month = atoi(buf);
+ memset(buf, 0x0, sizeof(buf));
+ snprintf(buf, strlen("DD") + 1, "%s", &s_datetime[6]);
+ ab->dtstart_mday = atoi(buf);
+
+ ab->dtend_type = sqlite3_column_int(iter->stmt, cnt++);
+ cal_db_get_text_from_stmt(iter->stmt,&(e_datetime),cnt++);
+ memset(buf, 0x0, sizeof(buf));
+ snprintf(buf, strlen("YYYY") + 1, "%s", &e_datetime[0]);
+ ab->dtend_year = atoi(buf);
+ memset(buf, 0x0, sizeof(buf));
+ snprintf(buf, strlen("MM") + 1, "%s", &e_datetime[4]);
+ ab->dtend_month = atoi(buf);
+ memset(buf, 0x0, sizeof(buf));
+ snprintf(buf, strlen("DD") + 1, "%s", &e_datetime[6]);
+ ab->dtend_mday = atoi(buf);
+ cal_db_get_text_from_stmt(iter->stmt,&(ab->summary), cnt++);
+ cal_db_get_text_from_stmt(iter->stmt,&(ab->location), cnt++);
+ break;
- //localtime_r(&startdate,&stm);
- //localtime_r(&enddate,&etm);
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_OSP:
+ if (NULL == *row_event) {
+ *row_event = calendar_svc_struct_new(CALS_STRUCT_PERIOD_NORMAL_OSP);
+ retvm_if(NULL == *row_event, CAL_ERR_FAIL,
+ "Failed to new CALS_STRUCT_TYPE_PERIOD_NORMAL_OSP");
+ }
+ cals_struct_period_normal_osp *nosp;
+ nosp = (cals_struct_period_normal_osp *)(*row_event)->user_data;
+ retvm_if(NULL == nosp, CAL_ERR_FAIL, "user_data is NULL");
+
+ cnt = 0;
+ nosp->index = sqlite3_column_int(iter->stmt, cnt++);
+ nosp->calendar_id = sqlite3_column_int(iter->stmt, cnt++);
+ nosp->dtstart_type = sqlite3_column_int(iter->stmt, cnt++);
+ nosp->dtstart_utime = sqlite3_column_int64(iter->stmt, cnt++);
+ nosp->dtend_type = sqlite3_column_int(iter->stmt, cnt++);
+ nosp->dtend_utime = sqlite3_column_int64(iter->stmt, cnt++);
+ cal_db_get_text_from_stmt(iter->stmt,&(nosp->summary), cnt++);
+ cal_db_get_text_from_stmt(iter->stmt,&(nosp->description), cnt++);
+ cal_db_get_text_from_stmt(iter->stmt,&(nosp->location), cnt++);
+ nosp->busy_status= sqlite3_column_int(iter->stmt, cnt++);
+ nosp->meeting_status= sqlite3_column_int(iter->stmt, cnt++);
+ nosp->priority= sqlite3_column_int(iter->stmt, cnt++);
+ nosp->sensitivity= sqlite3_column_int(iter->stmt, cnt++);
+ nosp->rrule_id = sqlite3_column_int(iter->stmt, cnt++);
+ break;
- if(etm.tm_mon != stm.tm_mon)
- {
- enddate--;
- localtime_r(&enddate,&etm);
- //cals_tmtime_r(&enddate, &etm);
+ case CALS_STRUCT_TYPE_PERIOD_ALLDAY_OSP:
+ s_datetime = NULL;
+ e_datetime = NULL;
+ if (NULL == *row_event) {
+ *row_event = calendar_svc_struct_new(CALS_STRUCT_PERIOD_ALLDAY_OSP);
+ retvm_if(NULL == *row_event, CAL_ERR_FAIL,
+ "Failed to new CALS_STRUCT_TYPE_PERIOD_ALLDAY_OSP");
+ }
+ cals_struct_period_allday_osp *aosp;
+ aosp = (cals_struct_period_allday_osp *)(*row_event)->user_data;
+ retvm_if(NULL == aosp, CAL_ERR_FAIL, "user_data is NULL");
+
+ cnt = 0;
+ aosp->index = sqlite3_column_int(iter->stmt, cnt++);
+ aosp->calendar_id = sqlite3_column_int(iter->stmt, cnt++);
+ aosp->dtstart_type = sqlite3_column_int(iter->stmt, cnt++);
+ cal_db_get_text_from_stmt(iter->stmt,&(s_datetime),cnt++);
+ memset(buf, 0x0, sizeof(buf));
+ snprintf(buf, strlen("YYYY") + 1, "%s", &s_datetime[0]);
+ aosp->dtstart_year = atoi(buf);
+ memset(buf, 0x0, sizeof(buf));
+ snprintf(buf, strlen("MM") + 1, "%s", &s_datetime[4]);
+ aosp->dtstart_month = atoi(buf);
+ memset(buf, 0x0, sizeof(buf));
+ snprintf(buf, strlen("DD") + 1, "%s", &s_datetime[6]);
+ aosp->dtstart_mday = atoi(buf);
+
+ aosp->dtend_type = sqlite3_column_int(iter->stmt, cnt++);
+ cal_db_get_text_from_stmt(iter->stmt,&(e_datetime),cnt++);
+ memset(buf, 0x0, sizeof(buf));
+ snprintf(buf, strlen("YYYY") + 1, "%s", &e_datetime[0]);
+ aosp->dtend_year = atoi(buf);
+ memset(buf, 0x0, sizeof(buf));
+ snprintf(buf, strlen("MM") + 1, "%s", &e_datetime[4]);
+ aosp->dtend_month = atoi(buf);
+ memset(buf, 0x0, sizeof(buf));
+ snprintf(buf, strlen("DD") + 1, "%s", &e_datetime[6]);
+ aosp->dtend_mday = atoi(buf);
+ cal_db_get_text_from_stmt(iter->stmt,&(aosp->summary), cnt++);
+ cal_db_get_text_from_stmt(iter->stmt,&(aosp->description), cnt++);
+ cal_db_get_text_from_stmt(iter->stmt,&(aosp->location), cnt++);
+ aosp->busy_status= sqlite3_column_int(iter->stmt, cnt++);
+ aosp->meeting_status= sqlite3_column_int(iter->stmt, cnt++);
+ aosp->priority= sqlite3_column_int(iter->stmt, cnt++);
+ aosp->sensitivity= sqlite3_column_int(iter->stmt, cnt++);
+ aosp->rrule_id = sqlite3_column_int(iter->stmt, cnt++);
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_LOCATION:
+ if (NULL == *row_event) {
+ *row_event = calendar_svc_struct_new(CALS_STRUCT_PERIOD_NORMAL_LOCATION);
+ retvm_if(NULL == *row_event, CAL_ERR_FAIL,
+ "Failed to new CALS_STRUCT_TYPE_PERIOD_NORMAL_OSP");
+ }
+ cals_struct_period_normal_location *nosl;
+ nosl = (cals_struct_period_normal_location *)(*row_event)->user_data;
+ retvm_if(NULL == nosl, CAL_ERR_FAIL, "user_data is NULL");
+
+ cnt = 0;
+ nosl->index = sqlite3_column_int(iter->stmt, cnt++);
+ nosl->calendar_id = sqlite3_column_int(iter->stmt, cnt++);
+ nosl->dtstart_type = sqlite3_column_int(iter->stmt, cnt++);
+ nosl->dtstart_utime = sqlite3_column_int64(iter->stmt, cnt++);
+ nosl->dtend_type = sqlite3_column_int(iter->stmt, cnt++);
+ nosl->dtend_utime = sqlite3_column_int64(iter->stmt, cnt++);
+ cal_db_get_text_from_stmt(iter->stmt,&(nosl->summary), cnt++);
+ cal_db_get_text_from_stmt(iter->stmt,&(nosl->description), cnt++);
+ cal_db_get_text_from_stmt(iter->stmt,&(nosl->location), cnt++);
+ nosl->busy_status= sqlite3_column_int(iter->stmt, cnt++);
+ nosl->meeting_status= sqlite3_column_int(iter->stmt, cnt++);
+ nosl->priority= sqlite3_column_int(iter->stmt, cnt++);
+ nosl->sensitivity= sqlite3_column_int(iter->stmt, cnt++);
+ nosl->rrule_id = sqlite3_column_int(iter->stmt, cnt++);
+ nosl->latitude = sqlite3_column_double(iter->stmt, cnt++);
+ nosl->longitude = sqlite3_column_double(iter->stmt, cnt++);
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_ALLDAY_LOCATION:
+ s_datetime = NULL;
+ e_datetime = NULL;
+ if (NULL == *row_event) {
+ *row_event = calendar_svc_struct_new(CALS_STRUCT_PERIOD_ALLDAY_LOCATION);
+ retvm_if(NULL == *row_event, CAL_ERR_FAIL,
+ "Failed to new CALS_STRUCT_TYPE_PERIOD_ALLDAY_OSP");
+ }
+ cals_struct_period_allday_location *aosl;
+ aosl = (cals_struct_period_allday_location *)(*row_event)->user_data;
+ retvm_if(NULL == aosl, CAL_ERR_FAIL, "user_data is NULL");
+
+ cnt = 0;
+ aosl->index = sqlite3_column_int(iter->stmt, cnt++);
+ aosl->calendar_id = sqlite3_column_int(iter->stmt, cnt++);
+ aosl->dtstart_type = sqlite3_column_int(iter->stmt, cnt++);
+ cal_db_get_text_from_stmt(iter->stmt,&(s_datetime),cnt++);
+ memset(buf, 0x0, sizeof(buf));
+ snprintf(buf, strlen("YYYY") + 1, "%s", &s_datetime[0]);
+ aosl->dtstart_year = atoi(buf);
+ memset(buf, 0x0, sizeof(buf));
+ snprintf(buf, strlen("MM") + 1, "%s", &s_datetime[4]);
+ aosl->dtstart_month = atoi(buf);
+ memset(buf, 0x0, sizeof(buf));
+ snprintf(buf, strlen("DD") + 1, "%s", &s_datetime[6]);
+ aosl->dtstart_mday = atoi(buf);
+
+ aosl->dtend_type = sqlite3_column_int(iter->stmt, cnt++);
+ cal_db_get_text_from_stmt(iter->stmt,&(e_datetime),cnt++);
+ memset(buf, 0x0, sizeof(buf));
+ snprintf(buf, strlen("YYYY") + 1, "%s", &e_datetime[0]);
+ aosl->dtend_year = atoi(buf);
+ memset(buf, 0x0, sizeof(buf));
+ snprintf(buf, strlen("MM") + 1, "%s", &e_datetime[4]);
+ aosl->dtend_month = atoi(buf);
+ memset(buf, 0x0, sizeof(buf));
+ snprintf(buf, strlen("DD") + 1, "%s", &e_datetime[6]);
+ aosl->dtend_mday = atoi(buf);
+ cal_db_get_text_from_stmt(iter->stmt,&(aosl->summary), cnt++);
+ cal_db_get_text_from_stmt(iter->stmt,&(aosl->description), cnt++);
+ cal_db_get_text_from_stmt(iter->stmt,&(aosl->location), cnt++);
+ aosl->busy_status= sqlite3_column_int(iter->stmt, cnt++);
+ aosl->meeting_status= sqlite3_column_int(iter->stmt, cnt++);
+ aosl->priority= sqlite3_column_int(iter->stmt, cnt++);
+ aosl->sensitivity= sqlite3_column_int(iter->stmt, cnt++);
+ aosl->rrule_id = sqlite3_column_int(iter->stmt, cnt++);
+ aosl->latitude = sqlite3_column_double(iter->stmt, cnt++);
+ aosl->longitude = sqlite3_column_double(iter->stmt, cnt++);
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_ALARM:
+ if (NULL == *row_event) {
+ *row_event = calendar_svc_struct_new(CALS_STRUCT_PERIOD_NORMAL_ALARM);
+ retvm_if(NULL == *row_event, CAL_ERR_FAIL,
+ "Failed to new CALS_STRUCT_TYPE_PERIOD_NORMAL_ALARM");
+ }
+ cals_struct_period_normal_alarm *nosa;
+ nosa = (cals_struct_period_normal_alarm *)(*row_event)->user_data;
+ retvm_if(NULL == nosa, CAL_ERR_FAIL, "user_data is NULL");
+
+ cnt = 0;
+ nosa->index = sqlite3_column_int(iter->stmt, cnt++);
+ nosa->calendar_id = sqlite3_column_int(iter->stmt, cnt++);
+ nosa->dtstart_type = sqlite3_column_int(iter->stmt, cnt++);
+ nosa->dtstart_utime = sqlite3_column_int64(iter->stmt, cnt++);
+ nosa->dtend_type = sqlite3_column_int(iter->stmt, cnt++);
+ nosa->dtend_utime = sqlite3_column_int64(iter->stmt, cnt++);
+ nosa->alarm_utime = sqlite3_column_int64(iter->stmt, cnt++);
+ nosa->alarm_id = sqlite3_column_int(iter->stmt, cnt++);
+ break;
+
+ default:
+ break;
}
+ return CAL_SUCCESS;
+}
+
- //no repeat event
- calendar_svc_get_month_event_list(account_id, startdate, enddate,false,&it);
- while (calendar_svc_iter_next(it) == CAL_SUCCESS) {
- rc = calendar_svc_iter_get_month_info(it, false,&cs);
- if (rc != CAL_SUCCESS || cs == NULL)
- break;
+API int calendar_svc_iter_next(cal_iter *iter)
+{
+ int ret = 0;
- temp_tm = calendar_svc_struct_get_tm(cs, CAL_VALUE_GMT_START_DATE_TIME,CAL_TZ_FLAG_LOCAL);
- memcpy(&estm,temp_tm,sizeof(struct tm));
- temp_tm = calendar_svc_struct_get_tm(cs, CAL_VALUE_GMT_END_DATE_TIME,CAL_TZ_FLAG_LOCAL);
- memcpy(&eetm,temp_tm,sizeof(struct tm));
- __set_day_flag(&stm,&etm,&estm,&eetm,day_flag);
+ retv_if(NULL == iter, CAL_ERR_ARG_NULL);
- calendar_svc_struct_free(&cs);
- }
+ if (iter->is_patched == FALSE)
+ iter->is_patched = TRUE;
- calendar_svc_iter_remove(&it);
- it = NULL;
+ if (CAL_STRUCT_TYPE_UPDATED_LIST == iter->i_type) {
+ retv_if(NULL == iter->info, CAL_ERR_ARG_INVALID);
- //repeat event
- calendar_svc_get_month_event_list(account_id, startdate, enddate,true,&it);
+ if (NULL == iter->info->cursor)
+ iter->info->cursor = iter->info->head;
+ else
+ iter->info->cursor = iter->info->cursor->next;
- while (calendar_svc_iter_next(it) == CAL_SUCCESS) {
- rc = calendar_svc_iter_get_month_info(it,true, &cs);
- if (rc != CAL_SUCCESS || cs == NULL) {
- ERR("calendar_svc_iter_get_month_info return %d", rc);
- break;
+ if (NULL == iter->info->cursor || 0 == iter->info->cursor->id) {
+ iter->info->cursor = NULL;
+ cals_updated_schedule_free_mempool(iter->info->head);
+ iter->info->head = NULL;
+ return CAL_ERR_FINISH_ITER;
}
+ }
+ else {
+ ret = cals_stmt_step(iter->stmt);
+ retvm_if(ret < CAL_SUCCESS, ret, "cals_stmt_step() Failed(%d)", ret);
+
+ if (CAL_SUCCESS == ret)
+ return CAL_ERR_FINISH_ITER;
+ }
+
+ return CAL_SUCCESS;
+}
+
+API int calendar_svc_iter_remove(cal_iter **iter)
+{
+ CALS_FN_CALL;
+ retv_if(NULL == iter, CAL_ERR_ARG_NULL);
+ retv_if(NULL == *iter, CAL_ERR_ARG_NULL);
- memset(&lstm,0x00,sizeof(struct tm));
- memset(&letm,0x00,sizeof(struct tm));
+ if (CAL_STRUCT_TYPE_UPDATED_LIST == (*iter)->i_type) {
+ retv_if(NULL == (*iter)->info, CAL_ERR_ARG_INVALID);
+ if ((*iter)->info->head) {
+ cals_updated_schedule_free_mempool((*iter)->info->head);
+ }
+ free((*iter)->info);
- while (calendar_svc_util_next_valid_event_tm(cs,
- &stm, &etm, &lstm, &letm) == CAL_SUCCESS) {
- __set_day_flag(&stm,&etm,&lstm,&letm,day_flag);
+ } else {
+ if ((*iter)->stmt)
+ {
+ sqlite3_finalize((*iter)->stmt);
+ (*iter)->stmt = NULL;
}
- calendar_svc_struct_free(&cs);
}
- calendar_svc_iter_remove(&it);
+ free(*iter);
+ *iter = NULL;
return CAL_SUCCESS;
}
{
CALS_FN_CALL;
int ret;
+ int rc;
+ int error_code = 0;
+ char sql_value[CALS_SQL_MIN_LEN] = {0};
calendar_t *cal_record = NULL;
cal_sch_full_t *sch_record = NULL;
cal_timezone_t *tz_record = NULL;
- int error_code = 0;
+ sqlite3_stmt *stmt = NULL;
retv_if(iter == NULL, CAL_ERR_ARG_NULL);
retv_if(iter->stmt == NULL, CAL_ERR_ARG_INVALID);
cals_stmt_get_full_schedule(iter->stmt, sch_record, true);
+ if (sch_record->rrule_id > 0) {
+ snprintf(sql_value, sizeof(sql_value),
+ "SELECT * FROM %s WHERE event_id = %d ",
+ CALS_TABLE_RRULE, sch_record->index);
+
+ stmt = cals_query_prepare(sql_value);
+ retvm_if(NULL == stmt, CAL_ERR_FAIL, "cals_query_prepare() Failed");
+
+ rc = cals_stmt_step(stmt);
+ retvm_if(CAL_TRUE != rc, CAL_ERR_FAIL, "cals_stmt_step() Failed(%d)", rc);
+
+
+ cals_stmt_fill_rrule(stmt, sch_record);
+ sqlite3_finalize(stmt);
+ stmt = NULL;
+ }
+
cal_db_service_get_participant_info_by_index(sch_record->index,&(sch_record->attendee_list),&error_code);
- cal_db_service_get_meeting_category_info_by_index(sch_record->index,&(sch_record->meeting_category),&error_code);
- cal_db_service_get_recurrency_exception(sch_record->index,&(sch_record->exception_date_list),&error_code);
ret = cals_get_alarm_info(sch_record->index, &(sch_record->alarm_list));
retvm_if(CAL_SUCCESS != ret, ret, "cals_get_alarm_info() Failed(%d)", ret);
-
break;
+
case CAL_STRUCT_TYPE_TODO:
if(*row_event == NULL)
{
cals_stmt_get_full_schedule(iter->stmt, sch_record, true);
+ if (sch_record->rrule_id > 0) {
+ snprintf(sql_value, sizeof(sql_value),
+ "SELECT * FROM %s WHERE event_id = %d ",
+ CALS_TABLE_RRULE, sch_record->index);
+
+ stmt = cals_query_prepare(sql_value);
+ retvm_if(NULL == stmt, CAL_ERR_FAIL, "cals_query_prepare() Failed");
+
+ rc = cals_stmt_step(stmt);
+ retvm_if(CAL_TRUE != rc, CAL_ERR_FAIL, "cals_stmt_step() Failed(%d)", rc);
+
+ cals_stmt_fill_rrule(stmt, sch_record);
+ sqlite3_finalize(stmt);
+ stmt = NULL;
+ }
+
break;
case CAL_STRUCT_TYPE_CALENDAR:
+++ /dev/null
-/*
- * Calendar Service
- *
- * Copyright (c) 2000 - 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.
- *
- */
-#include <stdlib.h>
-#include <string.h>
-
-#include "cals-internal.h"
-#include "cals-typedef.h"
-#include "cals-recurrence-utils.h"
-#include "cals-utils.h"
-#include "cals-tz-utils.h"
-
-int calendar_svc_get_tz_info(char *tz_file_name,int year, struct tm* dst_start, struct tm* dst_end,int *base_offset,int *dst_offset);
-
-static const UINT8 month_table[12]={31,28,31,30,31,30,31,31,30,31,30,31};
-
-//this array is used to calculate the day numer of a month in a year
-static const UINT16 days_table[12] = {
- 0,
- 31,
- 31 + 28,
- 31 + 28 + 31,
- 31 + 28 + 31 + 30,
- 31 + 28 + 31 + 30 + 31,
- 31 + 28 + 31 + 30 + 31 + 30,
- 31 + 28 + 31 + 30 + 31 + 30 + 31,
- 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31,
- 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30,
- 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31,
- 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30,
-};
-
-//const static int _lpdays[] = { -1, 30, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
-//const static int _days[] = { -1, 30, 58, 89, 119, 150, 180, 211, 242, 272, 303, 333, 364 };
-
-
-#define is_leap_year_tm(y) (((y+1900)%4 == 0 && ((y+1900)%100 != 0 || (y+1900)%400 == 0))? 1 : 0)
-
-static UINT32 g_cal_cur_id = -1;
-//cal_date_param_t cal_date_param={0,};
-
-#ifndef SECOFONEDAY
-#define SECOFONEDAY 86400
-#endif
-
-extern cal_svc_tm_info_t cal_svc_tm_value;
-
-static CAL_GET_VALID_DATE_FUNC cal_service_get_valid_date_func[] =
-{
- cal_service_get_next_repeat_none_valid_date,
- cal_service_get_next_repeat_daily_valid_date,
- cal_service_get_next_repeat_weekly_valid_date,
- cal_service_get_next_repeat_monthly_valid_date,
- cal_service_get_next_repeat_yearly_valid_date,
- cal_service_get_next_repeat_weekly_valid_date,
- cal_service_get_next_repeat_monthly_valid_date,
- cal_service_get_next_repeat_yearly_valid_date,
-};
-
-
-/**
- * compare two days
- * return -1 : adate is later then bdate
- * 0 : adate is the same with bdate
- * 1 : adate is earlier then bdate
- */
-INT8 __cal_service_compare_date(const struct tm *first_date,const struct tm *second_date)
-{
- UINT32 int_date_one = 0 ,int_date_two = 0;
-
- retvm_if(NULL == first_date, false, "\n %s:argument is NULL",__FUNCTION__);
- retvm_if(NULL == second_date, false, "\n %s:argument is NULL",__FUNCTION__);
-
- int_date_one = (first_date->tm_year*10000)+(first_date->tm_mon*100)+first_date->tm_mday;
- int_date_two = (second_date->tm_year*10000)+(second_date->tm_mon*100)+second_date->tm_mday;
-
- if( int_date_one == int_date_two )
- {
- return 0;
- }
- else if( int_date_one > int_date_two )
- {
- return -1;
- }
-
- return 1;
-}
-
-
-static void __cal_service_get_day_after_num(struct tm *start_day,struct tm *after_day,int day)
-{
- time_t base_time = 0;
- retm_if(NULL == start_day, "\n %s:argument is NULL",__FUNCTION__);
- retm_if(NULL == after_day, "\n %s:argument is NULL",__FUNCTION__);
-
- base_time = cals_mktime(start_day);
- base_time = base_time + (day * SECOFONEDAY);
-
- memcpy(after_day,cals_tmtime(&base_time),sizeof(struct tm));
-}
-
-static void __cal_service_get_day_after_sec(struct tm *start_day,struct tm *after_day,int sec)
-{
- time_t base_time = 0;
- retm_if(NULL == start_day, "\n %s:argument is NULL",__FUNCTION__);
- retm_if(NULL == after_day, "\n %s:argument is NULL",__FUNCTION__);
-
- base_time = cals_mktime(start_day);
- base_time = base_time + (sec);
-
- memcpy(after_day,cals_tmtime(&base_time),sizeof(struct tm));
-}
-
-static int __cal_service_get_num_of_event_day(struct tm *start_date, struct tm *end_date)
-{
- struct tm start_buf={0,};
- struct tm end_buf={0,};
- retvm_if(NULL == start_date, false, "\n %s:argument is NULL",__FUNCTION__);
- retvm_if(NULL == end_date, false, "\n %s:argument is NULL",__FUNCTION__);
-
- //compare date only
- memcpy(&start_buf,start_date,sizeof(struct tm));
- memcpy(&end_buf,end_date,sizeof(struct tm));
-
- start_buf.tm_hour = 0;
- start_buf.tm_min = 0;
- start_buf.tm_sec = 0;
-
- end_buf.tm_hour = 0;
- end_buf.tm_min = 0;
- end_buf.tm_sec = 0;
-
-
- return ((cals_mktime(&end_buf) - cals_mktime(&start_buf)) /SECOFONEDAY);
-}
-/*
- void
- cal_service_get_day_after_num(cal_service_date_t *start_day,cal_service_date_t *after_day,int day)
- {
- __cal_service_get_day_after_num(start_day,after_day,day);
- }*/
-
-void cal_service_set_day_of_week(struct tm* tm)
-{
- int days = 0;
- int year = 0;
- int month = 0;
- retm_if(NULL == tm, "\n %s:argument is NULL",__FUNCTION__);
- days = tm->tm_mday;
- year = tm->tm_year+1900;
- month = tm->tm_mon;
-
- days=(year-1)+(year-1)/4-(year-1)/100+(year-1)/400 + days_table[month] + tm->tm_mday + ( (month>1) ? is_leap_year_tm(year) : 0 ) ;
- tm->tm_wday = days%7;
-}
-
-
-bool cal_is_used_dst_timezone(cal_sch_full_t *sch_record)
-{
-
- return false;
-}
-
-void cal_svc_set_tz_base_info(int year)
-{
- char *tz_name;
-
- tz_name = cals_tzutil_get_tz_path();
-
- if (!tz_name) {
- ERR("cals_tzutil_get_tz_path failed");
- return;
- }
-
- if(cal_svc_tm_value.is_initialize == FALSE || year != cal_svc_tm_value.start_local_dst_date_time.tm_year)
- {
- calendar_svc_get_tz_info(tz_name,year+1900,
- &cal_svc_tm_value.start_local_dst_date_time,
- &cal_svc_tm_value.start_local_std_date_time,
- &cal_svc_tm_value.localtime_offset,&cal_svc_tm_value.local_dst_offset);
-
- cal_svc_tm_value.is_initialize = true;
- strncpy(cal_svc_tm_value.local_tz_name,tz_name, sizeof(cal_svc_tm_value.local_tz_name));
- }
-
- free(tz_name);
-
- return;
-}
-
-bool cal_get_dst_info_time(cal_date_param_t *cal_date_param,const cal_sch_full_t *sch_record)
-{
- int dst_offset = 0;
-
- retvm_if(NULL == cal_date_param, false, "\n %s:argument is NULL",__FUNCTION__);
- retvm_if(NULL == sch_record, false, "\n %s:argument is NULL",__FUNCTION__);
-
- if(cal_svc_tm_value.is_initialize == false){
- time_t t = time(NULL);
- struct tm * cur_time = NULL;//localtime(&t);
- struct tm ttm;
-
- cur_time = localtime_r(&t,&ttm);
-
- if(cur_time)
- cal_svc_set_tz_base_info(cur_time->tm_year); //local time
- }
-
- if(sch_record->tz_name == NULL || sch_record->tz_name[0] == '\0')
- {
- strncpy(cal_svc_tm_value.temp_tz_name,"calendar_localtime", sizeof(cal_svc_tm_value.temp_tz_name));
- dst_offset = cal_svc_tm_value.temp_dst_offset = cal_svc_tm_value.local_dst_offset;
- cal_svc_tm_value.temptime_offset = cal_svc_tm_value.localtime_offset;
- memcpy(&cal_svc_tm_value.start_temp_dst_date_time,&cal_svc_tm_value.start_local_dst_date_time,sizeof(struct tm));
- memcpy(&cal_svc_tm_value.start_temp_std_date_time,&cal_svc_tm_value.start_local_std_date_time,sizeof(struct tm));
- }
- else
- {
-
- if( (strcmp(cal_svc_tm_value.temp_tz_name,sch_record->tz_name)==0) &&
- ((cal_svc_tm_value.temp_dst_offset ==0) ||
- ((cal_svc_tm_value.temp_dst_offset !=0) &&
- (cal_svc_tm_value.start_temp_dst_date_time.tm_year == cal_date_param->start_db_date_time.tm_year))))
- {
- cal_date_param->dbtime_offset = cal_svc_tm_value.temptime_offset;
- dst_offset = cal_date_param->db_dst_offset = cal_svc_tm_value.temp_dst_offset;
- memcpy(&cal_date_param->start_db_dst_date_time,&cal_svc_tm_value.start_temp_dst_date_time,sizeof(struct tm));
- memcpy(&cal_date_param->start_db_std_date_time,&cal_svc_tm_value.start_temp_std_date_time,sizeof(struct tm));
- }
- else {
- calendar_svc_get_tz_info(sch_record->tz_name,cal_date_param->start_db_date_time.tm_year+1900,
- &cal_date_param->start_db_dst_date_time,
- &cal_date_param->start_db_std_date_time,
- &cal_date_param->dbtime_offset,&cal_date_param->db_dst_offset);
-
- strncpy(cal_svc_tm_value.temp_tz_name,sch_record->tz_name,sizeof(cal_svc_tm_value.temp_tz_name));
- dst_offset = cal_svc_tm_value.temp_dst_offset = cal_date_param->db_dst_offset;
- cal_svc_tm_value.temptime_offset = cal_date_param->dbtime_offset;
- memcpy(&cal_svc_tm_value.start_temp_dst_date_time,&cal_date_param->start_db_dst_date_time,sizeof(struct tm));
- memcpy(&cal_svc_tm_value.start_temp_std_date_time,&cal_date_param->start_db_std_date_time,sizeof(struct tm));
- }
- }
-
- if(dst_offset == 0)
- return false;
- else
- return true;
-}
-
-
-void cal_set_time_by_dst_info(cal_date_param_t *cal_date_param,const cal_sch_full_t *sch_record,struct tm *next_start_tm,struct tm *next_end_tm)
-{
- retm_if(NULL == cal_date_param, "\n %s:argument is NULL",__FUNCTION__);
- retm_if(NULL == sch_record, "\n %s:argument is NULL",__FUNCTION__);
- retm_if(NULL == next_start_tm, "\n %s:argument is NULL",__FUNCTION__);
- retm_if(NULL == next_end_tm, "\n %s:argument is NULL",__FUNCTION__);
-
- if(cal_date_param->is_need_adjust_time_for_view == DB_STD_LOCAL_STD ||
- cal_date_param->is_need_adjust_time_for_view == DB_INDST_LOCAL_DST ||
- cal_date_param->is_need_adjust_time_for_view == DB_OUTDST_LOCAL_DST ||
- (sch_record->repeat_term == CAL_REPEAT_NONE) ||
- (sch_record->all_day_event == TRUE) )
- {
- cal_date_param->i_adjust_time_value = 0;
- memcpy(next_start_tm,&cal_date_param->start_local_date_time,sizeof(struct tm));
- memcpy(next_end_tm,&cal_date_param->end_local_date_time,sizeof(struct tm));
- return;
- }
-
- if(cal_date_param->is_need_adjust_time_for_view == DB_STD_LOCAL_DST)
- {
- cal_svc_set_tz_base_info(cal_date_param->start_local_date_time.tm_year);
-
- if( (__cal_service_compare_date(&cal_svc_tm_value.start_local_dst_date_time,&cal_date_param->start_local_date_time) > 0) &&
- (__cal_service_compare_date(&cal_date_param->start_local_date_time,&cal_svc_tm_value.start_local_std_date_time) > 0)
- )
- {
- /* if current local date is exist in DST Time period - adjust +1 hours */
- cal_date_param->i_adjust_time_value = 1;
- __cal_service_get_day_after_sec(&cal_date_param->start_local_date_time,next_start_tm,SECSPERHOUR*cal_date_param->i_adjust_time_value);
- __cal_service_get_day_after_sec(&cal_date_param->end_local_date_time,next_end_tm,SECSPERHOUR*cal_date_param->i_adjust_time_value);
-
- }
- else
- {
- /* if current local date is exist out DST Time period - do not need adjustment */
- memcpy(next_start_tm,&cal_date_param->start_local_date_time,sizeof(struct tm));
- memcpy(next_end_tm,&cal_date_param->end_local_date_time,sizeof(struct tm));
- }
-
- }
- else if(cal_date_param->is_need_adjust_time_for_view == DB_INDST_LOCAL_STD)
- {
- cal_get_dst_info_time(cal_date_param,sch_record);
-
- /* check startDstTimeDate < srcTimeDate < startStdTimeDate */
- if( (__cal_service_compare_date(&cal_date_param->start_db_dst_date_time,&cal_date_param->start_db_date_time) > 0) &&
- (__cal_service_compare_date(&cal_date_param->start_db_date_time,&cal_date_param->start_db_std_date_time) > 0)
- )
- {
- /* if current local date is exist in DST Time period - do not need adjustment*/
- memcpy(next_start_tm,&cal_date_param->start_local_date_time,sizeof(struct tm));
- memcpy(next_end_tm,&cal_date_param->end_local_date_time,sizeof(struct tm));
- }
- else
- {
- /* if current local date is exist out DST Time period - adjust +1 hours */
- cal_date_param->i_adjust_time_value = 1;
- __cal_service_get_day_after_sec(&cal_date_param->start_local_date_time,next_start_tm,SECSPERHOUR*cal_date_param->i_adjust_time_value);
- __cal_service_get_day_after_sec(&cal_date_param->end_local_date_time,next_end_tm,SECSPERHOUR*cal_date_param->i_adjust_time_value);
-
-
- }
-
- }
- else /* DB_OUTDST_LOCAL_STD */
- {
- cal_get_dst_info_time(cal_date_param,sch_record);
-
- /* check startDstTimeDate < srcTimeDate < startStdTimeDate */
- if( (__cal_service_compare_date(&cal_date_param->start_db_dst_date_time,&cal_date_param->start_db_date_time) > 0) &&
- (__cal_service_compare_date(&cal_date_param->start_db_date_time,&cal_date_param->start_db_std_date_time) > 0)
- )
- {
- /* if current local date is exist in DST Time period - adjust -1 hours */
- cal_date_param->i_adjust_time_value = -1;
- __cal_service_get_day_after_sec(&cal_date_param->start_local_date_time,next_start_tm,SECSPERHOUR*cal_date_param->i_adjust_time_value);
- __cal_service_get_day_after_sec(&cal_date_param->end_local_date_time,next_end_tm,SECSPERHOUR*cal_date_param->i_adjust_time_value);
-
-
- }
- else
- {
- /* if current local date is exist out DST Time period - do not need adjustment*/
- memcpy(next_start_tm,&cal_date_param->start_local_date_time,sizeof(struct tm));
- memcpy(next_end_tm,&cal_date_param->end_local_date_time,sizeof(struct tm));
- }
- }
-}
-
-void __cal_service_reset_exception_date_info(cal_date_param_t *cal_date_param )
-{
- GList *head;
- cal_value *value = NULL;
- if(cal_date_param->exception_date_list)
- {
- head = cal_date_param->exception_date_list;
- while (cal_date_param->exception_date_list)
- {
- value = cal_date_param->exception_date_list->data;
- if(NULL != value)
- {
- if(NULL != value->user_data)
- {
- CAL_FREE(value->user_data);
- }
- CAL_FREE(value);
- }
- cal_date_param->exception_date_list = cal_date_param->exception_date_list->next;
- }
- g_list_free(head);
- cal_date_param->exception_date_list = NULL;
- }
-}
-
-void __cal_service_set_exception_date_info(cal_date_param_t *cal_date_param,cal_sch_full_t *sch_record)
-{
- GList *head=NULL;
- GList *desc=NULL;
-
- cal_value *value = NULL;
- cal_value *desc_value = NULL;
- cal_exception_info_t* desc_exception = NULL;
- time_t exception_tt,temp_time;
-
- if(sch_record->exception_date_list)
- {
- head = sch_record->exception_date_list;
- while (head)
- {
- value = head->data;
- if(NULL != value)
- {
- if(value->user_data)
- {
- desc_value = (cal_value*)malloc(sizeof(cal_value));
- retm_if(NULL == desc_value,"[ERROR]__cal_service_set_exception_date_info:Failed to malloc!\n");
-
- desc_value->v_type = CAL_EVENT_RECURRENCY;
- desc_exception = desc_value->user_data = (cal_exception_info_t*)malloc(sizeof(cal_exception_info_t));
- retm_if(NULL == desc_exception,"[ERROR]__cal_service_set_exception_date_info:Failed to malloc!\n");
-
- exception_tt = cals_mktime(&(((cal_exception_info_t*)(value->user_data))->exception_start_time));
- temp_time = exception_tt + cal_svc_tm_value.temptime_offset; //db timezone
- cals_tmtime_r(&temp_time,&(desc_exception->exception_start_time));
- ERR("exception date(%d/%d/%d %d)",desc_exception->exception_start_time.tm_year+1900,desc_exception->exception_start_time.tm_mon+1,desc_exception->exception_start_time.tm_mday,desc_exception->exception_start_time.tm_hour);
-
- }
- }
- head = head->next;
- desc = g_list_append(desc,desc_value);
- }
- cal_date_param->exception_date_list = desc;
- }
-
-}
-
-void cal_service_set_date_param(cal_date_param_t *cal_date_param,cal_sch_full_t *sch_record)
-{
- time_t temp_time;
- time_t end_time = 0;
- time_t start_time = 0;
- time_t repeat_end_time = 0;
- retm_if(NULL == cal_date_param, "\n %s:argument is NULL",__FUNCTION__);
- retm_if(NULL == sch_record, "\n %s:argument is NULL",__FUNCTION__);
- //bool is_used_dst_db_timezone = false;
- //bool is_used_dst_local_timezone = false;
- extern cal_svc_tm_info_t cal_svc_tm_value;
-
- __cal_service_reset_exception_date_info(cal_date_param);
- memset(cal_date_param,0x00,sizeof(cal_date_param_t));
-
- memcpy(&(cal_date_param->start_db_date_time),&(sch_record->start_date_time),sizeof(struct tm));
- memcpy(&(cal_date_param->end_db_date_time),&(sch_record->end_date_time),sizeof(struct tm));
- memcpy(&(cal_date_param->start_local_date_time),&(sch_record->start_date_time),sizeof(struct tm));
- memcpy(&(cal_date_param->end_local_date_time),&(sch_record->end_date_time),sizeof(struct tm));
-
- memcpy(&(cal_date_param->repeat_end_date),&(sch_record->repeat_end_date),sizeof(struct tm));
-
- cal_get_dst_info_time(cal_date_param,sch_record);
-
- __cal_service_set_exception_date_info(cal_date_param,sch_record);
-
- if(sch_record->all_day_event == true)
- goto COMMON;
- cal_date_param->repeat_end_date.tm_hour = cal_date_param->start_db_date_time.tm_hour;
- cal_date_param->repeat_end_date.tm_min = cal_date_param->start_db_date_time.tm_min;
- cal_date_param->repeat_end_date.tm_sec = cal_date_param->start_db_date_time.tm_sec;
-
- start_time = cals_mktime(&(cal_date_param->start_db_date_time));
- end_time = cals_mktime(&(cal_date_param->end_db_date_time));
- repeat_end_time = cals_mktime(&(cal_date_param->repeat_end_date));
-
- temp_time = start_time + cal_svc_tm_value.temptime_offset;
- //calendar_svc_util_local_to_gmt(start_time, &temp_time);
- cals_tmtime_r(&temp_time,&(cal_date_param->start_db_date_time));
-
- temp_time = end_time + cal_svc_tm_value.temptime_offset;
- //calendar_svc_util_local_to_gmt(end_time, &temp_time);
- cals_tmtime_r(&temp_time,&(cal_date_param->end_db_date_time));
-
- temp_time = repeat_end_time + cal_svc_tm_value.temptime_offset;
- cals_tmtime_r(&temp_time,&(cal_date_param->repeat_end_date));
-
-
- start_time = cals_mktime(&(cal_date_param->start_local_date_time));
- end_time = cals_mktime(&(cal_date_param->end_local_date_time));
-
- //if(sch_record->repeat_term == CAL_REPEAT_NONE)
- calendar_svc_util_gmt_to_local(start_time, &temp_time);
- cals_tmtime_r(&temp_time,&(cal_date_param->start_local_date_time));
-
-
- calendar_svc_util_gmt_to_local(end_time, &temp_time);
- cals_tmtime_r(&temp_time,&(cal_date_param->end_local_date_time));
-
- if(cal_svc_tm_value.temp_dst_offset!=0)
- {
- /* check startDstTimeDate < srcTimeDate < startStdTimeDate */
- if( (__cal_service_compare_date(&cal_date_param->start_db_dst_date_time,&cal_date_param->start_db_date_time) > 0) &&
- (__cal_service_compare_date(&cal_date_param->start_db_date_time,&cal_date_param->start_db_std_date_time) > 0)
- ) /* dbtimezone is dst timezone */
- {
- if(cal_svc_tm_value.local_dst_offset!=0)
- {
- __cal_service_get_day_after_sec(&cal_date_param->start_local_date_time,&cal_date_param->start_local_date_time,SECSPERHOUR);
- __cal_service_get_day_after_sec(&cal_date_param->end_local_date_time,&cal_date_param->end_local_date_time,SECSPERHOUR);
- cal_date_param->is_need_adjust_time_for_view = DB_INDST_LOCAL_DST;
-
- }else
- {
- /* need adjust, after computation */
- cal_date_param->is_need_adjust_time_for_view = DB_INDST_LOCAL_STD;
- }
- }
- else /* dbtimezone is not dst timezone */
- {
- if(cal_svc_tm_value.local_dst_offset!=0)
- {
- /* nothing */
- cal_date_param->is_need_adjust_time_for_view = DB_OUTDST_LOCAL_DST;
- }
- else
- {
- /* need adjust, after computation */
- cal_date_param->is_need_adjust_time_for_view = DB_OUTDST_LOCAL_STD;
- }
- }
- }else
- {
- if(cal_svc_tm_value.local_dst_offset!=0)
- {
- /* need adjust, after computation */
- cal_date_param->is_need_adjust_time_for_view = DB_STD_LOCAL_DST;
- }else
- {
- /* nothing */
- cal_date_param->is_need_adjust_time_for_view = DB_STD_LOCAL_STD;
- }
- }
-
-COMMON:
-
- g_cal_cur_id = -2;
- if(cal_date_param->repeat_end_date.tm_year >137)
- {
- cal_date_param->repeat_end_date.tm_year = 137;
- }
-
- cal_date_param->prev_alarm_time.tm_year = 9999;
- cal_date_param->repeat_by_set_position = (cal_date_param->start_db_date_time.tm_mday - 1) /7 + 1;
-
-}
-
-
-
-/* API for calculate date return TRUE is valid DATE, FALSE is not valid date */
-BOOL cal_service_get_next_repeat_none_valid_date(const cal_sch_full_t *sch_record,
- cal_date_param_t *cal_date_param,struct tm *now_start_date,struct tm *now_end_date)
-{
- retvm_if(NULL == sch_record, false, "sch_record is NULL");
- retvm_if(NULL == cal_date_param, false, "cal_date_param is NULL");
- retvm_if(NULL == now_start_date, false, "now_start_date is NULL");
- retvm_if(NULL == now_end_date, false, "now_end_date is NULL");
-
- /* localend_date < nowStartDate || nowEndDate < localStartDate */
- memcpy(&cal_date_param->prev_alarm_time,&cal_date_param->start_local_date_time,sizeof(struct tm));
-
- /* never call this function with same id */
- if (g_cal_cur_id == sch_record->index)
- {
- return FALSE;
- }
-
- if ((__cal_service_compare_date(&(cal_date_param->end_local_date_time),now_start_date) > 0)
- || (__cal_service_compare_date(now_end_date,&(cal_date_param->start_local_date_time)) > 0) )
- {
- g_cal_cur_id = -1;
- return FALSE;
- }
-
- g_cal_cur_id = sch_record->index;
-
- return TRUE;
-}
-
-BOOL cal_service_get_next_repeat_daily_valid_date(const cal_sch_full_t *sch_record,
- cal_date_param_t *cal_date_param, struct tm *now_start_date, struct tm *now_end_date)
-{
- UINT32 count_day=0;
- retvm_if(NULL == sch_record, false, "sch_record is NULL");
- retvm_if(NULL == cal_date_param, false, "cal_date_param is NULL");
- retvm_if(NULL == now_start_date, false, "now_start_date is NULL");
- retvm_if(NULL == now_end_date, false, "now_end_date is NULL");
-
- if (sch_record->repeat_interval == 0)
- {
- return FALSE; /* invalid Data */
- }
-
- /* first function call & valid date check */
- if ( (g_cal_cur_id != sch_record->index) &&
- ( !( (__cal_service_compare_date(&(cal_date_param->end_local_date_time),now_start_date) > 0 )
- || (__cal_service_compare_date(&(cal_date_param->start_local_date_time),now_end_date) < 0 ) )
- ) )
- {
- g_cal_cur_id = sch_record->index;
- }
- else
- {
- //TODO: need improvement performance
-
- do
- {
- count_day = 0;
- count_day = count_day + sch_record->repeat_interval;
- __cal_service_get_day_after_num(&(cal_date_param->start_db_date_time),&(cal_date_param->start_db_date_time),count_day);
- __cal_service_get_day_after_num(&(cal_date_param->end_db_date_time),&(cal_date_param->end_db_date_time),count_day);
- __cal_service_get_day_after_num(&(cal_date_param->start_local_date_time),&(cal_date_param->start_local_date_time),count_day);
- __cal_service_get_day_after_num(&(cal_date_param->end_local_date_time),&(cal_date_param->end_local_date_time),count_day);
- }while( (__cal_service_compare_date(&(cal_date_param->end_local_date_time),now_start_date) > 0));
-
- g_cal_cur_id = sch_record->index;
- }
-
- //__cal_service_convert_tm_to_date(&(sch_record->repeat_end_date), &repeat_end_date);
- /*check again*/
- if ((__cal_service_compare_date(&(cal_date_param->repeat_end_date),&(cal_date_param->start_db_date_time)) > 0 )
- || (__cal_service_compare_date(&(cal_date_param->start_local_date_time),now_end_date) < 0 ))
- {
- g_cal_cur_id = -1;
- return FALSE;
- }
-
- return TRUE;
-}
-
-BOOL cal_service_get_next_repeat_weekly_valid_date(const cal_sch_full_t *sch_record,
- cal_date_param_t *cal_date_param, struct tm *now_start_date, struct tm *now_end_date)
-{
-
- UINT8 valid_week[7]={0,};
- UINT32 count_day=0;
- int week_count=0;
- int i = 0;
- static BOOL is_same_start_day_of_week =TRUE;
- static UINT8 start_day_of_week=0;
- BOOL is_first_valid_date = TRUE;
- BOOL is_set_week_flag = FALSE;
- retvm_if(NULL == sch_record, false, "\n %s:argument is NULL",__FUNCTION__);
- retvm_if(NULL == cal_date_param, false, "\n %s:argument is NULL",__FUNCTION__);
- retvm_if(NULL == now_start_date, false, "\n %s:argument is NULL",__FUNCTION__);
- retvm_if(NULL == now_end_date, false, "\n %s:argument is NULL",__FUNCTION__);
- if (sch_record->repeat_interval == 0)
- {
- return FALSE; /* invalid Data */
- }
-
- /* make valid week array */
- for (i=0;i<7;i++)
- {
- valid_week[i] = sch_record->week_flag[i]-'0';
- if(valid_week[i])
- {
- is_set_week_flag = TRUE;
- }
- }
-
- if(is_set_week_flag == FALSE){
- DBG("critical error!! , week flag should be setting ");
- return FALSE;
- }
-
-
- if (g_cal_cur_id != sch_record->index)
- {
- if (sch_record->week_start !=0)
- {
- UINT8 start_week;
-
- start_week = (UINT8)sch_record->week_start;
- is_first_valid_date = TRUE;
-
- for (i = 0; i < DAY_OF_A_WEEK; i++)
- {
- if(valid_week[i] == 1)
- {
- if((is_first_valid_date == TRUE) && (start_week == i))
- {
- is_same_start_day_of_week = TRUE;
- break;
- }
- else if(start_week == i)
- {
- start_day_of_week = start_week;
- is_same_start_day_of_week = FALSE;
- break;
- }
- is_first_valid_date = FALSE;
- }
- }
- }
- else
- {
- is_same_start_day_of_week = TRUE;
- }
- }
-
- if ( (g_cal_cur_id != sch_record->index) &&
-
- ( !( (__cal_service_compare_date(&(cal_date_param->end_local_date_time),now_start_date) > 0 )
- || (__cal_service_compare_date(&(cal_date_param->start_local_date_time),now_end_date) < 0 ) ) )
- )
- {
- g_cal_cur_id = sch_record->index;
- }
- else
- {
- do
- {
- int valid_term=1;
- count_day = 0;
-
- week_count = cal_date_param->start_db_date_time.tm_wday;
-
- // [2010.05.09. Brian] Dangerous statements.
- // if weekflag is '0000000', following statement would make process in infinite loop.
- while (valid_week[((week_count+valid_term) %7)] ==0 )
- {
- valid_term++;
- }
-
- count_day = count_day + valid_term;
-
- //pass interval week
- if (is_same_start_day_of_week == TRUE)
- {
- if( (week_count+valid_term) >=7 )
- count_day = count_day + ((sch_record->repeat_interval-1) * 7);
- }
- else
- {
- if (((week_count+valid_term)%7) == start_day_of_week)
- {
- count_day = count_day + ((sch_record->repeat_interval-1) * 7);
- }
- }
-
- __cal_service_get_day_after_num(&(cal_date_param->start_db_date_time),&(cal_date_param->start_db_date_time),count_day);
- __cal_service_get_day_after_num(&(cal_date_param->end_db_date_time),&(cal_date_param->end_db_date_time),count_day);
- __cal_service_get_day_after_num(&(cal_date_param->start_local_date_time),&(cal_date_param->start_local_date_time),count_day);
- __cal_service_get_day_after_num(&(cal_date_param->end_local_date_time),&(cal_date_param->end_local_date_time),count_day);
- }
- while( (__cal_service_compare_date(&(cal_date_param->end_local_date_time),now_start_date) > 0));
-
- g_cal_cur_id = sch_record->index;
- }
-
- //__cal_service_convert_tm_to_date(&(sch_record->repeat_end_date), &repeat_end_date);
- if( (__cal_service_compare_date(&(cal_date_param->repeat_end_date),&(cal_date_param->start_db_date_time)) > 0 )
- || (__cal_service_compare_date(&(cal_date_param->start_local_date_time),now_end_date) < 0 ) )
- {
- start_day_of_week = 0;
- is_same_start_day_of_week= TRUE;
- g_cal_cur_id = -1;
-
- return FALSE;
- }
-
- return TRUE;
-
-}
-
- BOOL
-cal_service_get_next_repeat_monthly_valid_date(const cal_sch_full_t *sch_record,cal_date_param_t *cal_date_param,struct tm *now_start_date,struct tm *now_end_date)
-{
- UINT32 count_day=0;
- int i = 0;
- retvm_if(NULL == sch_record, false, "sch_record is NULL");
- retvm_if(NULL == cal_date_param, false, "cal_date_param is NULL");
- retvm_if(NULL == now_start_date, false, "now_start_date is NULL");
- retvm_if(NULL == now_end_date, false, "now_end_date is NULL");
-
- if (sch_record->repeat_interval == 0)
- {
- return FALSE; /* invalid Data */
- }
-
- if (g_cal_cur_id != sch_record->index) /* SEC 060427 heungjae.jeong last day issue */
- {
- cal_date_param->day_for_last_day_event = sch_record->start_date_time.tm_mday;
- }
-
- if ((g_cal_cur_id != sch_record->index) &&
- ( !( (__cal_service_compare_date(&(cal_date_param->end_local_date_time),now_start_date) > 0 )
- || (__cal_service_compare_date(&(cal_date_param->start_local_date_time),now_end_date) < 0 ) ) )
- )
- {
- g_cal_cur_id = sch_record->index;
- }
- else
- {
- do
- {
- count_day = 0;
- if (sch_record->day_date ==1)
- {
- int temp=0;
-
- /* move next month */
- for (i = cal_date_param->start_db_date_time.tm_mon; i < (cal_date_param->start_db_date_time.tm_mon +
- sch_record->repeat_interval); i++)
- {
- temp = temp + month_table[(i)%12] +
- (((i%12)==1) ? is_leap_year_tm(cal_date_param->start_db_date_time.tm_year + ((i)/12)) : 0 ) ;
- }
-
- if(cal_date_param->day_for_last_day_event != 0)
- {
- if (cal_date_param->start_db_date_time.tm_mday >
- (month_table[(i)%12]+ ( ((i%12)==1) ? is_leap_year_tm(cal_date_param->start_db_date_time.tm_year + ((i)/12)) : 0 ) ) )
- {
- temp = temp - (cal_date_param->day_for_last_day_event-
- (month_table[(i)%12]+(((i%12)==1)?is_leap_year_tm(cal_date_param->start_db_date_time.tm_year+((i)/12)):0)) );
- }
- else
- {
- temp = temp + (cal_date_param->day_for_last_day_event-cal_date_param->start_db_date_time.tm_mday);
- }
- }
-
- count_day = count_day + temp;
-
- __cal_service_get_day_after_num(&(cal_date_param->start_db_date_time),&(cal_date_param->start_db_date_time),count_day);
- __cal_service_get_day_after_num(&(cal_date_param->end_db_date_time),&(cal_date_param->end_db_date_time),count_day);
- __cal_service_get_day_after_num(&(cal_date_param->start_local_date_time),&(cal_date_param->start_local_date_time),count_day);
- __cal_service_get_day_after_num(&(cal_date_param->end_local_date_time),&(cal_date_param->end_local_date_time),count_day);
-
- }
- else /* Relative date check */
- {
- int first_day_of_week=0;
- struct tm after_from_date;
-
- after_from_date = cal_date_param->start_db_date_time;
-
- after_from_date.tm_mon += sch_record->repeat_interval;
-
- if (after_from_date.tm_mon > 11)
- {
- after_from_date.tm_year += (after_from_date.tm_mon) / 12;
- after_from_date.tm_mon = (after_from_date.tm_mon) % 12;
- //after_from_date.tm_mon ++;
- }
-
- if (cal_date_param->repeat_by_set_position == 5)
- {
- int valid_day_of_week = 0;
- int k = 0;
-
- after_from_date.tm_mday = month_table[after_from_date.tm_mon]
- + ( (after_from_date.tm_mon==1) ? is_leap_year_tm(after_from_date.tm_year) : 0 ) ;
-
- cal_service_set_day_of_week(&after_from_date);
-
- while(sch_record->start_date_time.tm_wday != valid_day_of_week)
- {
- valid_day_of_week++;
- } /* j = recurrence_day_of_the_week 0..6 */
-
- k=0;
- while (((k+after_from_date.tm_wday)%7) != valid_day_of_week)
- {
- k++;
- }
-
- after_from_date.tm_mday = after_from_date.tm_mday - ((7-k)%7);
- after_from_date.tm_wday = (after_from_date.tm_wday + k) % 7;
- }
- else
- {
- int valid_day_of_week=0;
- int k=0;
-
- after_from_date.tm_mday = 1;
- cal_service_set_day_of_week(&after_from_date);
- first_day_of_week = after_from_date.tm_wday;
-
- while(sch_record->start_date_time.tm_wday != valid_day_of_week)
- {
- valid_day_of_week++;
- } /* j = recurrence_day_of_the_week 0..6 */
-
- k=0;
- while( ((k+first_day_of_week)%7) != valid_day_of_week)
- {
- k++;
- }
-
- after_from_date.tm_mday = 1 + k;
-
- after_from_date.tm_mday = after_from_date.tm_mday + (cal_date_param->repeat_by_set_position-1)*7;
- cal_service_set_day_of_week(&after_from_date);
- }
-
- count_day = __cal_service_get_num_of_event_day(&(cal_date_param->start_db_date_time),&after_from_date);
-
- __cal_service_get_day_after_num(&(cal_date_param->start_db_date_time),&(cal_date_param->start_db_date_time),count_day);
- __cal_service_get_day_after_num(&(cal_date_param->end_db_date_time),&(cal_date_param->end_db_date_time),count_day);
- __cal_service_get_day_after_num(&(cal_date_param->start_local_date_time),&(cal_date_param->start_local_date_time),count_day);
- __cal_service_get_day_after_num(&(cal_date_param->end_local_date_time),&(cal_date_param->end_local_date_time),count_day);
-
- }
- g_cal_cur_id = sch_record->index;
- if(count_day == 0) return FALSE;
- }
- while((__cal_service_compare_date(&(cal_date_param->end_local_date_time),now_start_date) > 0));
- }
-
- //__cal_service_convert_tm_to_date(&(sch_record->repeat_end_date), &repeat_end_date);
- if ((__cal_service_compare_date(&(cal_date_param->repeat_end_date),&(cal_date_param->start_db_date_time)) > 0 )
- || (__cal_service_compare_date(&(cal_date_param->start_local_date_time),now_end_date) < 0 ))
- {
- g_cal_cur_id = -1;
- return FALSE;
- }
-
- return TRUE;
-}
-
-BOOL cal_service_get_next_repeat_yearly_valid_date(const cal_sch_full_t *sch_record,
- cal_date_param_t *cal_date_param, struct tm *now_start_date, struct tm *now_end_date)
-{
- int i;
- UINT32 count_day=0;
-
- retvm_if(NULL == sch_record, FALSE, "sch_record is NULL");
- retvm_if(NULL == cal_date_param, FALSE, "cal_date_param is NULL");
- retvm_if(NULL == now_start_date, FALSE, "now_start_date is NULL");
- retvm_if(NULL == now_end_date, FALSE, "now_end_date is NULL");
- //__cal_service_convert_tm_to_date(&(sch_record->start_date_time), &sch_start_date);
- // repeat_by_set_position = (sch_start_date.tm_mday - 1) /7 + 1;
-
- if (sch_record->repeat_interval== 0)
- return FALSE; /* invalid Data */
-
- if ((g_cal_cur_id != sch_record->index) &&
- ( !( (__cal_service_compare_date(&(cal_date_param->end_local_date_time),now_start_date) > 0 )
- || (__cal_service_compare_date(&(cal_date_param->start_local_date_time),now_end_date) < 0 ) ) ))
- {
- g_cal_cur_id = sch_record->index;
- }
- else
- {
- do
- {
- count_day = 0;
-
- if (sch_record->day_date ==1)
- {
- int temp = 0;
-
- for (i = cal_date_param->start_db_date_time.tm_year; i < (cal_date_param->start_db_date_time.tm_year +
- sch_record->repeat_interval); i++)
- {
- temp = temp + 365;
-
- if(cal_date_param->start_db_date_time.tm_mon > 1)
- temp = temp + is_leap_year_tm(i+1);
- else
- temp = temp + is_leap_year_tm(i);
- }
-
- i = cal_date_param->start_db_date_time.tm_year;
- if (cal_date_param->start_db_date_time.tm_mon == 1)
- {
- // cal_date_param->day_for_last_day_event,i,is_leap_year_tm(i));
- if (cal_date_param->day_for_last_day_event != 0)
- {
- if (is_leap_year_tm(i+1))
- {
- temp = temp + 1;
- cal_date_param->day_for_last_day_event = 0;
- }
- /*if (cal_date_param->start_db_date_time.tm_mday > (month_table[1]+is_leap_year_tm(i)) )
- {
- temp = temp - 1;
- }
- else if (is_leap_year_tm(i))
- {
- temp = temp + 1;
- }*/
- }
- else if (cal_date_param->start_db_date_time.tm_mday == 29 )
- {
- temp = temp-1;
- cal_date_param->day_for_last_day_event = 29;
- // temp, cal_date_param->start_db_date_time.tm_mday,(month_table[1]+is_leap_year_tm(i)));
- }
- }
-
- count_day = count_day + temp;
- __cal_service_get_day_after_num(&(cal_date_param->start_db_date_time),&(cal_date_param->start_db_date_time),count_day);
- __cal_service_get_day_after_num(&(cal_date_param->end_db_date_time),&(cal_date_param->end_db_date_time),count_day);
- __cal_service_get_day_after_num(&(cal_date_param->start_local_date_time),&(cal_date_param->start_local_date_time),count_day);
- __cal_service_get_day_after_num(&(cal_date_param->end_local_date_time),&(cal_date_param->end_local_date_time),count_day);
-
- }
- else /* Relative date check */
- {
- int first_day_of_week=0;
- int temp = 0;
- struct tm after_from_date;
-
- after_from_date = cal_date_param->start_db_date_time;
-
- for (i=after_from_date.tm_year;i<(after_from_date.tm_year+sch_record->repeat_interval);i++)
- {
- temp = temp + 365;
-
- if(after_from_date.tm_mon > 1)
- temp = temp + is_leap_year_tm(i+1);
- else
- temp = temp + is_leap_year_tm(i);
- }
-
- count_day = count_day + temp;
-
- __cal_service_get_day_after_num(&after_from_date,&after_from_date,count_day);
-
- if (cal_date_param->repeat_by_set_position == 5)
- {
- int valid_day_of_week=0;
- int k=0;
-
- after_from_date.tm_mday = month_table[after_from_date.tm_mon]
- + ( (after_from_date.tm_mon==1) ? is_leap_year_tm(after_from_date.tm_year) : 0 ) ;
-
- cal_service_set_day_of_week(&after_from_date);
-
- while(sch_record->start_date_time.tm_wday != valid_day_of_week)
- valid_day_of_week++; /* j = recurrence_day_of_the_week 0..6 */
-
- k=0;
- while( ((k+after_from_date.tm_wday)%7) != valid_day_of_week)
- k++;
-
- after_from_date.tm_mday = after_from_date.tm_mday - ((7-k)%7);
- after_from_date.tm_wday = (after_from_date.tm_wday + k) % 7;
- }
- else
- {
- int valid_day_of_week=0;
- int k=0;
-
- after_from_date.tm_mday = 1;
- cal_service_set_day_of_week(&after_from_date);
- first_day_of_week = after_from_date.tm_wday;
-
- while(sch_record->start_date_time.tm_wday != valid_day_of_week)
- valid_day_of_week++; /* j = recurrence_day_of_the_week 0..6 */
-
- k=0;
- while( ((k+first_day_of_week)%7) != valid_day_of_week)
- k++;
-
- after_from_date.tm_mday = 1 + k;
-
- after_from_date.tm_mday = after_from_date.tm_mday + (cal_date_param->repeat_by_set_position-1)*7;
- cal_service_set_day_of_week(&after_from_date);
- }
-
- count_day = __cal_service_get_num_of_event_day(&(cal_date_param->start_db_date_time),&after_from_date);
- __cal_service_get_day_after_num(&(cal_date_param->start_db_date_time),&(cal_date_param->start_db_date_time),count_day);
- __cal_service_get_day_after_num(&(cal_date_param->end_db_date_time),&(cal_date_param->end_db_date_time),count_day);
- __cal_service_get_day_after_num(&(cal_date_param->start_local_date_time),&(cal_date_param->start_local_date_time),count_day);
- __cal_service_get_day_after_num(&(cal_date_param->end_local_date_time),&(cal_date_param->end_local_date_time),count_day);
-
- }
-
- g_cal_cur_id = sch_record->index;
- }
- while((__cal_service_compare_date(&(cal_date_param->end_local_date_time),now_start_date) > 0));
- }
-
- //__cal_service_convert_tm_to_date(&(sch_record->repeat_end_date), &repeat_end_date);
- if((__cal_service_compare_date(&(cal_date_param->repeat_end_date),&(cal_date_param->start_db_date_time)) > 0 )
- ||(__cal_service_compare_date(&(cal_date_param->start_local_date_time),now_end_date) < 0 ) )
- {
- g_cal_cur_id = -1;
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-
-int cal_db_service_get_next_valid_exception_time(const cal_sch_full_t *sch_record,
- cal_date_param_t *cal_date_param,GList *exception_date_list,
- struct tm* start_tm,struct tm* end_tm,
- struct tm* next_start_tm,struct tm* next_end_tm)
-{
- cal_exception_info_t *exception_info = NULL;
- cal_value *cvalue = NULL;
- GList *head = NULL;
- bool is_exception_date = false;
- bool is_valid_date = FALSE;
- time_t temp_time = 0;
-
- retv_if(NULL == sch_record, CAL_ERR_ARG_NULL);
- retv_if(NULL == start_tm, CAL_ERR_ARG_NULL);
- retv_if(NULL == end_tm, CAL_ERR_ARG_NULL);
- retv_if(NULL == next_start_tm, CAL_ERR_ARG_NULL);
- retv_if(NULL == next_end_tm, CAL_ERR_ARG_NULL);
-
- //g_cal_cur_id = -1;
- is_valid_date = false;
- while (cal_service_get_valid_date_func[sch_record->repeat_term](sch_record, cal_date_param,
- start_tm, end_tm) == TRUE )
- {
- is_exception_date = false;
- //check exception date
- if(exception_date_list)
- {
- // __cal_service_convert_datetime_to_tm(&cal_date_param.start_db_date_time,next_start_tm);
- memcpy(next_start_tm,&cal_date_param->start_db_date_time,sizeof(struct tm));
-
- //if exception date, calucate again
- temp_time = cals_mktime(next_start_tm);
- //DBG("next_start_tm [%s\n", ctime(&temp_time));
-
- //DBG("exception_date_list = %x\n",exception_date_list);
-
- head = exception_date_list;
-
- while(head != NULL)
- {
- cvalue = head->data;
- //DBG("cvalue = %x\n",cvalue);
- if(cvalue)
- {
- exception_info = cvalue->user_data;
- temp_time = cals_mktime(&(exception_info->exception_start_time));
- //DBG("exception_start_time [%s\n", ctime(&temp_time));
-
- //check exception date is same or not
- if( (next_start_tm->tm_year == exception_info->exception_start_time.tm_year) &&
- (next_start_tm->tm_mon == exception_info->exception_start_time.tm_mon ) &&
- (next_start_tm->tm_mday == exception_info->exception_start_time.tm_mday) )
- {
- is_exception_date = true;
- //DBG("is_exception_date = %d\n",is_exception_date);
- break;
- }
- }
- else
- {
- break;
- }
- head = head->next;
- }
-
- if(is_exception_date)
- {
- continue;
- }
-
- //printf("is_exception_date = %d",is_exception_date);
- cal_set_time_by_dst_info(cal_date_param,sch_record,next_start_tm,next_end_tm);
- is_valid_date = true;
- break;
- }
- else
- {
- cal_set_time_by_dst_info(cal_date_param,sch_record,next_start_tm,next_end_tm);
- is_valid_date = true;
- break;
- }
-
- }
-
- if(is_valid_date == true)
- {
- return CAL_SUCCESS;
- }
-
- return CAL_ERR_FAIL;
-}
+++ /dev/null
-/*
- * Calendar Service
- *
- * Copyright (c) 2000 - 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 _CALENDAR_SVC_RECURRENCE_UTILS_H_
-#define _CALENDAR_SVC_RECURRENCE_UTILS_H_
-
-#ifndef true
- #define true 1
- #define false 0
-#endif
-
-#ifndef TRUE
- #define TRUE 1
- #define FALSE 0
-#endif
-
-#ifndef BOOLEAN
- #define BOOLEAN int
-#endif
-
-#ifndef BOOL
- #define BOOL int
-#endif
-
-
-#ifndef __RECURRENCE_FEATURE__
- #define __RECURRENCE_FEATURE__
-
- #define CAL_SUPPORT_TIMEZONE
-#ifdef CAL_SUPPORT_TIMEZONE
- #define CAL_SUPPORT_AUTO_DST /* precondition: TIMEZONE should be supported */
-#endif
- //#define CAL_SUPPORT_EXCEPTION_DATE
-#endif
-
-#define UINT8 unsigned char
-#define UINT16 unsigned short
-#define UINT32 unsigned long
-
-#define INT8 signed char
-#define INT16 signed short
-#define INT32 signed long
-
-
-#define is_leap_year(y) (((y)%4 == 0 && ((y)%100 != 0 || (y)%400 == 0))? 1 : 0)
-
-typedef struct
-{
- UINT8 seconds; // 0 - 59
- UINT8 minutes; // 0 - 59
- UINT8 hours; // 0 - 23
-}
-cal_service_time_t;
-
-//cal_service_date_t : Structure for expressing a calendar date
-typedef struct
-{
- UINT8 wday; // 0-6, 0=Sunday, 6=Saturday
- UINT8 day; // 1 - 28, 29, 30, 31 depending on month and year
- UINT8 month; // 1 - 12
- UINT16 year; // Range of 32 years, starting with reference year
-}cal_service_date_t;
-
-//cal_service_time_date_t : Structure for expressing time and date as a single item.
-typedef struct
-{
- cal_service_time_t time; // Time
- cal_service_date_t date; // Date
-}
-cal_service_time_date_t;
-
-
-#ifdef CAL_SUPPORT_AUTO_DST
-typedef enum
-{
- DB_STD_LOCAL_STD, /* nothing */
- DB_STD_LOCAL_DST, /* need adjust, after computation */
- DB_INDST_LOCAL_STD, /* need adjust, after computation */
- DB_INDST_LOCAL_DST, /* all datetime +1 hour */
- DB_OUTDST_LOCAL_STD, /* need adjust, after computation */
- DB_OUTDST_LOCAL_DST /* nothing */
-
-} cal_dst_type_t;
-
-
-typedef struct
-{
- UINT16 tz_index;
- UINT8 std_start_month;
- UINT8 std_start_position_of_week;
- UINT8 std_start_day;
- UINT8 std_start_hour;
- UINT8 day_start_month;
- UINT8 day_start_position_of_week;
- UINT8 day_start_day;
- UINT8 day_start_hour;
-} cal_dst_info_t;
-#endif
-
-
-typedef struct
-{
- struct tm start_db_date_time;
- struct tm end_db_date_time;
- struct tm repeat_end_date;
- int dbtime_offset;
- int db_dst_offset;
-
- struct tm start_local_date_time;
- struct tm end_local_date_time;
-
- struct tm prev_alarm_time;
- UINT32 day_for_last_day_event;
-
- UINT32 db_time_zone_index;
- UINT32 local_time_zone_index;
-
- int repeat_by_set_position;
- GList* exception_date_list;
-
-#ifdef CAL_SUPPORT_AUTO_DST
- struct tm start_db_dst_date_time;
- struct tm start_db_std_date_time;
- struct tm start_local_dst_date_time;
- struct tm start_local_std_date_time;
- cal_dst_type_t is_need_adjust_time_for_view;
- INT32 i_adjust_time_value; /* 0,-1,+1 viewÇÏ´Â ½ÃÁ¡¿¡ DSTÀû¿ë ¿©ºÎ¿¡ ¸Â°Ô ½Ã°£ Á¶Á¤ÈÄ °ª ¼ÂÆà */
-#endif
-
-} cal_date_param_t;
-
-typedef BOOL (*CAL_GET_VALID_DATE_FUNC)(const cal_sch_full_t *,cal_date_param_t *,struct tm *,struct tm *);
-
-BOOL cal_service_get_next_repeat_none_valid_date(const cal_sch_full_t *sch_record,cal_date_param_t *cal_date_param,
- struct tm *now_start_date,struct tm *now_end_date);
-BOOL cal_service_get_next_repeat_daily_valid_date(const cal_sch_full_t *sch_record,cal_date_param_t *cal_date_param,
- struct tm *now_start_date,struct tm *now_end_date);
-BOOL cal_service_get_next_repeat_weekly_valid_date(const cal_sch_full_t *sch_record,cal_date_param_t *cal_date_param,
- struct tm *now_start_date,struct tm *now_end_date);
-BOOL cal_service_get_next_repeat_monthly_valid_date(const cal_sch_full_t *sch_record,cal_date_param_t *cal_date_param,
- struct tm *now_start_date,struct tm *now_end_date);
-BOOL cal_service_get_next_repeat_yearly_valid_date(const cal_sch_full_t *sch_record,cal_date_param_t *cal_date_param,
- struct tm *now_start_date,struct tm *now_end_date);
-void cal_service_set_date_param(cal_date_param_t *cal_date_param,cal_sch_full_t *sch_record);
-void cal_service_set_day_of_week(struct tm* date);
-
-void cal_svc_set_tz_base_info(int year);
-
-INT8 __cal_service_compare_date(const struct tm *first_date,const struct tm *second_date);
-
-int cal_db_service_get_next_valid_exception_time(const cal_sch_full_t *sch_record,
- cal_date_param_t *cal_date_param,GList *exception_date_list,
- struct tm* start_tm,struct tm* end_tm,
- struct tm* next_start_tm,struct tm* next_end_tm);
-
-
-#endif /* _CALENDAR_SVC_RECURRENCE_UTILS_H_ */
-
#include "cals-sqlite.h"
#include "cals-db-info.h"
#include "cals-db.h"
-#include "cals-tz-utils.h"
#include "cals-utils.h"
#include "cals-alarm.h"
#include "cals-schedule.h"
+#include "cals-instance.h"
+#include "cals-time.h"
-
-static void _cals_adjust_time(cal_sch_full_t *current_record,
- time_t *start, time_t *end, time_t *repeat_end)
-{
- TMDUMP(current_record->start_date_time);
-
- if ((current_record->all_day_event == true) &&
- ((current_record->start_date_time.tm_hour != 0) ||
- (current_record->start_date_time.tm_min !=0)) )
- {
- *start = cals_mktime(&(current_record->start_date_time));
- CALS_DBG("%d",*start);
- calendar_svc_util_gmt_to_local(*start, start);
- CALS_DBG("%d",*start);
- *end = cals_mktime(&(current_record->end_date_time));
-
- if(current_record->all_day_event == true &&
- current_record->end_date_time.tm_hour == 0 &&
- current_record->end_date_time.tm_min == 0)
- *end = *end - 1;
-
- CALS_DBG("%d",*end);
- calendar_svc_util_gmt_to_local(*end, end);
- CALS_DBG("%d",*end);
- *repeat_end = cals_mktime(&(current_record->repeat_end_date));
-
- calendar_svc_util_gmt_to_local(*repeat_end, repeat_end);
- }
- else
- {
- *start = cals_mktime(&(current_record->start_date_time));
- *end = cals_mktime(&(current_record->end_date_time));
- *repeat_end = cals_mktime(&(current_record->repeat_end_date));
- }
-
-}
+int _cals_clear_instances(int id);
static inline int _cals_insert_schedule(cal_sch_full_t *record)
{
int ret = -1;
char query[CALS_SQL_MAX_LEN] = {0};
+ char dtstart_datetime[32] = {0};
+ char dtend_datetime[32] = {0};
sqlite3_stmt *stmt = NULL;
- time_t conv_start_time;
- time_t conv_end_time;
- time_t conv_repeat_end_time;
- time_t conv_last_modified_time;
- time_t conv_created_date_time;
- time_t conv_completed_date_time;
- time_t t = time(NULL);
- tzset();
- struct tm * ptm = NULL;
- struct tm ttm;
retv_if(NULL == record, CAL_ERR_ARG_NULL);
- ptm = gmtime_r(&t,&ttm);
- retvm_if(NULL == ptm, CAL_ERR_TIME_FAILED, "gmtime_r() Failed(%d)", errno);
-
- memcpy(&record->last_modified_time, &ttm, sizeof(struct tm));
-
- conv_last_modified_time = cals_mktime(&(record->last_modified_time));
-
- _cals_adjust_time(record, &conv_start_time, &conv_end_time, &conv_repeat_end_time);
- conv_created_date_time = cals_mktime(&(record->created_date_time));
- conv_completed_date_time = cals_mktime(&(record->completed_date_time));
+ int input_ver = cals_get_next_ver();
ret = snprintf(query, sizeof(query),
- "INSERT INTO %s( "
- "account_id, type, category, "
- "summary, description, location, all_day_event, "
- "start_date_time, end_date_time, repeat_item, repeat_interval, "
- "repeat_until_type, repeat_occurrences, repeat_end_date, sun_moon, week_start, "
- "week_flag, day_date, last_modified_time, missed, "
+ "INSERT INTO %s ("
+ "account_id, type, "
+ "created_ver, changed_ver, "
+ "summary, description, location, categories, exdate, "
+ "missed, "
"task_status, priority, timezone, file_id, "
"contact_id, busy_status, sensitivity, uid, "
"calendar_type, organizer_name, organizer_email, meeting_status, "
- "gcal_id, deleted, updated, location_type, "
+ "gcal_id, updated, location_type, "
"location_summary, etag, calendar_id, sync_status, "
"edit_uri, gevent_id, dst, original_event_id, "
- "latitude, longitude, is_deleted, tz_name, "
- "tz_city_name, email_id, availability, "
- "created_date_time, completed_date_time, progress) "
- "VALUES( "
- "%d, %d, %d, "
- "?, ?, ?, %d, "
- "%ld, %ld, %d, %d, "
- "%d, %d, %ld, %d, %d, "
- "?, %d, %ld, %d, "
+ "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 "
+ ") VALUES ( "
+ "%d, %d, "
+ "%d, %d, "
+ "?, ?, ?, ?, ?, "
+ "%d, "
"%d, %d, %d, %d, "
"%d, %d, %d, ?, "
"%d, ?, ?, %d, "
- "?, %d, ?, %d, "
+ "?, ?, %d, "
"?, ?, %d, %d, "
"?, ?, %d, %d, "
- "%lf, %lf, %d, ?, "
- "?, %d, %d, "
- "%ld, %ld, %d)",
+ "%lf, %lf, "
+ "%d, %d, "
+ "strftime('%%s', 'now'), %lld, %d, "
+ "%d, %lld, ?, ?, "
+ "%d, %lld, ?, ?, "
+ "strftime('%%s', 'now'), %d ) ",
CALS_TABLE_SCHEDULE,
- record->account_id, record->cal_type, record->sch_category,
- record->all_day_event,
- conv_start_time, conv_end_time, record->repeat_term, record->repeat_interval,
- record->repeat_until_type, record->repeat_occurrences, conv_repeat_end_time, record->sun_moon, record->week_start,
- record->day_date, (long int)conv_last_modified_time, record->missed,
- record->task_status, record->priority, record->timezone, record->file_id,
+ record->account_id, record->cal_type,
+ input_ver, input_ver,
+ record->missed,
+ record->task_status, record->priority, record->timezone, record->file_id,
record->contact_id, record->busy_status, record->sensitivity,
record->calendar_type, record->meeting_status,
- record->deleted, record->location_type,
- record->calendar_id, record->sync_status,
+ record->location_type,
+ record->calendar_id, record->sync_status,
record->dst, record->original_event_id,
- record->latitude, record->longitude, record->is_deleted,
- record->email_id, record->availability,
- conv_created_date_time, conv_completed_date_time, record->progress);
+ record->latitude, record->longitude,
+ record->email_id, record->availability,
+ record->completed_time, record->progress,
+ record->dtstart_type, record->dtstart_utime,
+ record->dtend_type, record->dtend_utime,
+ record->rrule_id);
stmt = cals_query_prepare(query);
retvm_if(NULL == stmt, CAL_ERR_DB_FAILED, "cals_query_prepare() Failed");
cals_stmt_bind_text(stmt, count, record->location);
count++;
- if (record->week_flag)
- cals_stmt_bind_text(stmt, count, record->week_flag);
+ if (record->categories)
+ cals_stmt_bind_text(stmt, count, record->categories);
+ count++;
+
+ if (record->exdate)
+ cals_stmt_bind_text(stmt, count, record->exdate);
count++;
if (record->uid)
cals_stmt_bind_text(stmt, count, record->gevent_id);
count++;
- if (record->tz_name)
- cals_stmt_bind_text(stmt, count, record->tz_name);
+ snprintf(dtstart_datetime, sizeof(dtstart_datetime), "%04d%02d%02dT000000",
+ record->dtstart_year, record->dtstart_month, record->dtstart_mday);
+ cals_stmt_bind_text(stmt, count, dtstart_datetime);
+ count++;
+
+ if (record->dtstart_tzid)
+ cals_stmt_bind_text(stmt, count, record->dtstart_tzid);
+ count++;
+
+ snprintf(dtend_datetime, sizeof(dtend_datetime), "%04d%02d%02dT235959",
+ record->dtend_year, record->dtend_month, record->dtend_mday);
+ cals_stmt_bind_text(stmt, count, dtend_datetime);
count++;
- if (record->tz_city_name)
- cals_stmt_bind_text(stmt, count, record->tz_city_name);
+ if (record->dtend_tzid)
+ cals_stmt_bind_text(stmt, count, record->dtend_tzid);
count++;
ret = cals_stmt_step(stmt);
return cals_last_insert_id();
}
-int _cals_add_meeting_category_info(const int event_id, const cal_category_info_t *current_record)
+static inline int _cals_insert_rrule_id(int index, cal_sch_full_t *record)
{
- int ret;
- sqlite3_stmt *stmt;
- char sql_value[CALS_SQL_MAX_LEN];
-
- retv_if(NULL == current_record, CAL_ERR_ARG_NULL);
-
- sprintf(sql_value, "INSERT INTO %s(event_id, category_name) "
- "VALUES(%d, ?)", CALS_TABLE_MEETING_CATEGORY, event_id);
-
- stmt = cals_query_prepare(sql_value);
- retvm_if(NULL == stmt, CAL_ERR_DB_FAILED, "cals_query_prepare() Failed");
+ CALS_FN_CALL;
+ int ret = -1;
+ char query[CALS_SQL_MAX_LEN] = {0};
- cals_stmt_bind_text(stmt, 1, current_record->category_name);
+ retv_if(NULL == record, CAL_ERR_ARG_NULL);
- ret = cals_stmt_step(stmt);
- if (CAL_SUCCESS != ret) {
- sqlite3_finalize(stmt);
- ERR("sqlite3_step() Failed(%d)", ret);
+ ret = snprintf(query, sizeof(query),
+ "UPDATE %s SET "
+ "rrule_id = %d "
+ "WHERE id = %d ",
+ CALS_TABLE_SCHEDULE,
+ record->rrule_id,
+ index);
+DBG("query(%s)", query);
+ ret = cals_query_exec(query);
+ if (ret) {
+ ERR("cals_query_exec() failed (%d)", ret);
return ret;
}
- sqlite3_finalize(stmt);
-
return CAL_SUCCESS;
}
-static inline int _cals_check_date_validity(struct tm *day)
+static inline int _cals_insert_rrule(int index, cal_sch_full_t *record)
{
- int month_day_count = 0;
+ int ret;
+ int cnt;
+ char query[CALS_SQL_MAX_LEN] = {0};
+ char until_datetime[32] = {0};
+ sqlite3_stmt *stmt = NULL;
- retvm_if(NULL == day, CAL_FALSE, "day is NULL");
+ snprintf(query, sizeof(query),
+ "INSERT INTO %s ( "
+ "event_id, freq, range_type, "
+ "until_type, until_utime, until_datetime, "
+ "count, interval, "
+ "bysecond, byminute, byhour, byday, "
+ "bymonthday, byyearday, byweekno, bymonth, "
+ "bysetpos, wkst "
+ ") VALUES ( "
+ "%d, %d, %d, "
+ "%d, %lld, ?, "
+ "%d, %d, "
+ "?, ?, ?, ?, "
+ "?, ?, ?, ?, "
+ "?, %d "
+ ") ",
+ CALS_TABLE_RRULE,
+ index, record->freq, record->range_type,
+ record->until_type, record->until_utime,
+ record->count, record->interval,
+ record->wkst);
- month_day_count = cal_db_service_get_day_count_in_month(day->tm_year, day->tm_mon);
+ stmt = cals_query_prepare(query);
+ retvm_if(stmt == NULL, CAL_ERR_DB_FAILED, "Failed to query prepare");
- if ((day->tm_mday < 1) ||
- (day->tm_mday > month_day_count) ||
- (day->tm_mon < CAL_MONTH_CNT_MIN - 1 ) ||
- (day->tm_mon > CAL_MONTH_CNT_MAX - 1) ||
- (day->tm_year < CAL_YEAR_MIN - BENCHMARK_YEAR ) ||
- (day->tm_year > CAL_YEAR_MAX - BENCHMARK_YEAR))
- {
- day->tm_year = 137;
- day->tm_mon = 11;
- day->tm_mday = 31;
- return CAL_TRUE;
- }
- else
- {
- return CAL_TRUE;
- }
-}
+ cnt = 1;
+ snprintf(until_datetime, sizeof(until_datetime), "%04d%02d%02dT235959",
+ record->until_year, record->until_month, record->until_mday);
+ cals_stmt_bind_text(stmt, cnt, until_datetime);
+ cnt++;
-static inline int _cals_sch_check_validity(cal_sch_full_t *sch_record)
-{
- struct tm end_date_time = {0};
- struct tm start_date = {0};
- struct tm tmp_start_date_time = {0};
- struct tm tmp_end_date_time = {0};
+ if (record->bysecond)
+ cals_stmt_bind_text(stmt, cnt, record->bysecond);
+ cnt++;
- time_t temp_start_time_seconds = 0;
- time_t temp_end_time_seconds = 0;
- time_t temp_repeat_until_seconds = 0;
+ if (record->byminute)
+ cals_stmt_bind_text(stmt, cnt, record->byminute);
+ cnt++;
- if(sch_record->cal_type != CAL_EVENT_SCHEDULE_TYPE)
- return CAL_SUCCESS;
+ if (record->byhour)
+ cals_stmt_bind_text(stmt, cnt, record->byhour);
+ cnt++;
- if((sch_record->repeat_term != CAL_REPEAT_NONE) && ((
- (sch_record->repeat_occurrences) != 0 &&
- (sch_record->repeat_end_date.tm_year == BASE_TIME_YEAR)) || (sch_record->repeat_until_type == CALS_REPEAT_UNTIL_TYPE_NONE)))
- {
- cal_db_service_set_repeat_end_date(sch_record);
- }
+ if (record->byday)
+ cals_stmt_bind_text(stmt, cnt, record->byday);
+ cnt++;
- if (!_cals_check_date_validity(&sch_record->start_date_time))
- {
- //ERR("start_date_time is invalied: %s-%s-%s",sch_record->start_date_time.tm_year,
- //sch_record->start_date_time.tm_mon,
- //sch_record->start_date_time.tm_mday);
- return CAL_ERR_EVENT_START_DATE;
- }
+ if (record->bymonthday)
+ cals_stmt_bind_text(stmt, cnt, record->bymonthday);
+ cnt++;
- if (!_cals_check_date_validity(&sch_record->end_date_time))
- {
- //ERR("end_date_time is invalied: %s-%s-%s",sch_record->end_date_time.tm_year,
- // sch_record->end_date_time.tm_mon,
- // sch_record->end_date_time.tm_mday);
- return CAL_ERR_EVENT_END_DATE;
- }
-
-
- if (!_cals_check_date_validity(&sch_record->repeat_end_date))
- {
- //ERR("repeat_end_date is invalied: %s-%s-%s",sch_record->repeat_end_date.tm_year,
- // sch_record->repeat_end_date.tm_mon,
- // sch_record->repeat_end_date.tm_mday);
- return CAL_ERR_EVENT_REPEAT_END_DATE;
- }
+ if (record->byyearday)
+ cals_stmt_bind_text(stmt, cnt, record->byyearday);
+ cnt++;
- start_date.tm_year = sch_record->start_date_time.tm_year;
- start_date.tm_mon = sch_record->start_date_time.tm_mon;
- start_date.tm_mday = sch_record->start_date_time.tm_mday;
+ if (record->byweekno)
+ cals_stmt_bind_text(stmt, cnt, record->byweekno);
+ cnt++;
- memcpy( &tmp_start_date_time, &sch_record->start_date_time, sizeof(struct tm) );
- memcpy( &tmp_end_date_time, &sch_record->end_date_time, sizeof(struct tm) );
+ if (record->bymonth)
+ cals_stmt_bind_text(stmt, cnt, record->bymonth);
+ cnt++;
- temp_start_time_seconds = timegm(&tmp_start_date_time);
- temp_end_time_seconds = timegm(&tmp_end_date_time);
- temp_repeat_until_seconds = timegm(&sch_record->repeat_end_date);
+ if (record->bysetpos)
+ cals_stmt_bind_text(stmt, cnt, record->bysetpos);
+ cnt++;
- if( temp_start_time_seconds > temp_end_time_seconds )
- {
- return CAL_ERR_EVENT_DURATION;
+ ret = cals_stmt_step(stmt);
+ if (CAL_SUCCESS != ret) {
+ sqlite3_finalize(stmt);
+ ERR("sqlite3_step() Failed(%d)", ret);
+ return ret;
}
+ sqlite3_finalize(stmt);
- switch(sch_record->repeat_term)
- {
- case CAL_REPEAT_EVERY_DAY:
- if( temp_end_time_seconds - temp_start_time_seconds > (sch_record->repeat_interval*ONE_DAY_SECONDS))
- return CAL_ERR_EVENT_REPEAT_DURATION_TOO_SHORT;
- break;
- /* case CAL_REPEAT_EVERY_WEEKDAYS:
- if( temp_end_time_seconds - temp_start_time_seconds > (sch_record->repeat_interval*ONE_DAY_SECONDS))
- {
- *error_code = CAL_ERR_EVENT_REPEAT_DURATION_TOO_SHORT;
- return false;
- }
- break;
- case CAL_REPEAT_EVERY_WEEKENDS:
- if( temp_end_time_seconds - temp_start_time_seconds > (sch_record->repeat_interval*ONE_DAY_SECONDS))
- {
- *error_code = CAL_ERR_EVENT_REPEAT_DURATION_TOO_SHORT;
- return false;
- }
- break;*/
- case CAL_REPEAT_EVERY_WEEK:
- //if( temp_end_time_seconds - temp_start_time_seconds > (sch_record->repeat_interval*ONE_WEEK_SECONDS))
- //{
- // *error_code = CAL_ERR_EVENT_REPEAT_DURATION_TOO_SHORT;
- // return false;
- //}
- break;
- case CAL_REPEAT_EVERY_MONTH:
- if( temp_end_time_seconds - temp_start_time_seconds > (sch_record->repeat_interval*ONE_MONTH_SECONDS))
- return CAL_ERR_EVENT_REPEAT_DURATION_TOO_SHORT;
- break;
- case CAL_REPEAT_EVERY_YEAR:
- if( temp_end_time_seconds - temp_start_time_seconds > (sch_record->repeat_interval*ONE_YEAR_SECONDS))
- return CAL_ERR_EVENT_REPEAT_DURATION_TOO_SHORT;
- break;
- case CAL_REPEAT_NONE:
- default:
- break;
- }
-
- end_date_time.tm_year = sch_record->repeat_end_date.tm_year;
- end_date_time.tm_mon = sch_record->repeat_end_date.tm_mon;
- end_date_time.tm_mday = sch_record->repeat_end_date.tm_mday;
- end_date_time.tm_hour = sch_record->repeat_end_date.tm_hour;
- end_date_time.tm_min = sch_record->repeat_end_date.tm_min;
- end_date_time.tm_sec = 59;
-
- // If Repeat end date is earlier than end date
- if ( sch_record->repeat_term != CAL_REPEAT_NONE )
- {
- memcpy(&tmp_end_date_time, &sch_record->end_date_time, sizeof(struct tm));
- //if( timegm(&tmp_end_date_time) > timegm(&end_date_time) )
- //{
- // *error_code = CAL_ERR_REPEAT_DURATION;
- // return false;
- //}
- }
- return CAL_SUCCESS;
+ return cals_last_insert_id();
}
-
int cals_insert_schedule(cal_sch_full_t *sch_record)
{
int ret = 0;
int index = 0;
cal_value *cvalue = NULL;
bool is_success = false;
+ struct cals_time st;
+ struct cals_time et;
retvm_if(NULL == sch_record, CAL_ERR_ARG_INVALID, "sch_record is NULL");
- ret = _cals_sch_check_validity(sch_record);
- retvm_if(CAL_SUCCESS != ret, ret, "_cals_sch_check_validity() is Failed(%d)", ret);
-
- switch(sch_record->sch_category)
- {
- case CAL_SCH_NONE:
- retvm_if(CAL_EVENT_TODO_TYPE != sch_record->cal_type, CAL_ERR_ARG_INVALID,
- "Invalid type(category = %d, component type = %d)", sch_record->sch_category, sch_record->cal_type);
- break;
- case CAL_SCH_APPOINTMENT:
- retvm_if(CAL_EVENT_SCHEDULE_TYPE != sch_record->cal_type, CAL_ERR_ARG_INVALID,
- "Invalid type(category = %d, component type = %d)", sch_record->sch_category, sch_record->cal_type);
- break;
- case CAL_SCH_SPECIAL_OCCASION:
- retvm_if(CAL_EVENT_SCHEDULE_TYPE != sch_record->cal_type, CAL_ERR_ARG_INVALID,
- "Invalid type(category = %d, component type = %d)", sch_record->sch_category, sch_record->cal_type);
- sch_record->all_day_event = 1;
- break;
- case CAL_SCH_BIRTHDAY:
- retvm_if(CAL_EVENT_SCHEDULE_TYPE != sch_record->cal_type, CAL_ERR_ARG_INVALID,
- "Invalid type(category = %d, component type = %d)", sch_record->sch_category, sch_record->cal_type);
- sch_record->all_day_event = 1;
- break;
- case CAL_SCH_HOLIDAY:
- retvm_if(CAL_EVENT_SCHEDULE_TYPE != sch_record->cal_type, CAL_ERR_ARG_INVALID,
- "Invalid type(category = %d, component type = %d)", sch_record->sch_category, sch_record->cal_type);
- sch_record->all_day_event = 1;
- break;
- case CAL_SCH_IMPORTANT:
- case CAL_SCH_PRIVATE:
- case CAL_SCH_BUSSINESS:
- default:
- ERR("Invalid type(category = %d, component type = %d)", sch_record->sch_category, sch_record->cal_type);
- return CAL_ERR_ARG_INVALID;
- }
-
sch_record->missed = 0;
ret = cals_begin_trans();
}
index = ret;
+ if (sch_record->freq != CALS_FREQ_ONCE) {
+ ret = _cals_insert_rrule(index, sch_record);
+ if (ret < CAL_SUCCESS) {
+ ERR("Failed in _cals_insert_rrule(%d)\n", ret);
+ cals_end_trans(false);
+ return ret;
+ }
+ sch_record->rrule_id = ret;
+ DBG("added rrule_id(%d)", ret);
+ ret = _cals_insert_rrule_id(index, sch_record);
+ if (ret != CAL_SUCCESS) {
+ ERR("Failed in _cals_insert_rrule_id(%d)\n", ret);
+ }
+ DBG("ended add");
+ }
+
+ st.type = sch_record->dtstart_type;
+ if (st.type == CALS_TIME_UTIME)
+ st.utime = sch_record->dtstart_utime;
+ else {
+ st.year = sch_record->dtstart_year;
+ st.month = sch_record->dtstart_month;
+ st.mday = sch_record->dtstart_mday;
+ }
+
+ et.type = sch_record->dtend_type;
+ if (et.type == CALS_TIME_UTIME)
+ et.utime = sch_record->dtend_utime;
+ else {
+ et.year = sch_record->dtend_year;
+ et.month = sch_record->dtend_month;
+ et.mday = sch_record->dtend_mday;
+ }
+
+ cals_instance_insert(index, &st, &et, sch_record);
+
if (sch_record->attendee_list)
{
GList *list = g_list_first(sch_record->attendee_list);
}
}
- if (sch_record->meeting_category)
- {
- GList *list = g_list_first(sch_record->meeting_category);
- cal_category_info_t *category_info = NULL;
-
- while(list)
- {
- cvalue = list->data;
- if(cvalue)
- {
- category_info = cvalue->user_data;
- ret = _cals_add_meeting_category_info(index, category_info);
- warn_if(CAL_SUCCESS != ret, "_cals_add_meeting_category_info() Failed(%d)", ret);
- }
- list = g_list_next(list);
- }
- }
-
- if (sch_record->exception_date_list)
- {
- GList *list = g_list_first(sch_record->exception_date_list);
- cal_exception_info_t *exception_info = NULL;
-
- while(list)
- {
- cvalue = list->data;
- if(cvalue)
- {
- exception_info = cvalue->user_data;
- ret = cal_service_add_exception_info(index, exception_info, sch_record);
- warn_if(CAL_SUCCESS != ret, "cal_service_add_exception_info() Failed(%d)", ret);
- }
- list = g_list_next(list);
- }
- }
-
if (sch_record->alarm_list)
{
GList *list = sch_record->alarm_list;
if (cvalue)
{
alarm_info = cvalue->user_data;
- if(alarm_info->is_deleted==0)
+ if(alarm_info->is_deleted == 0)
{
- if (alarm_info->remind_tick != CAL_INVALID_INDEX)
+ if (alarm_info->remind_tick != CALS_INVALID_ID)
{
- ret = cals_alarm_add(index, alarm_info, &sch_record->start_date_time);
+ ret = cals_alarm_add(index, alarm_info, &st);
warn_if(CAL_SUCCESS != ret, "cals_alarm_add() Failed(%d)", ret);
}
}
cals_end_trans(true);
sch_record->index = index;
- if(sch_record->cal_type == CAL_EVENT_SCHEDULE_TYPE)
+ if(sch_record->cal_type == CALS_SCH_TYPE_EVENT)
is_success= cals_notify(CALS_NOTI_TYPE_EVENT);
else
is_success= cals_notify(CALS_NOTI_TYPE_TODO);
- warn_if(is_success != true, "cals_notify() Failed");
+ warn_if(is_success != CAL_SUCCESS, "cals_notify() Failed");
return index;
}
-
-static int _cals_delete_meeting_category_info(const int index)
-{
- int ret;
- char query[CALS_SQL_MIN_LEN];
-
- sprintf(query, "DELETE FROM %s WHERE event_id = %d;", CALS_TABLE_MEETING_CATEGORY, index);
-
- ret = cals_query_exec(query);
- retvm_if(CAL_SUCCESS != ret, ret, "cals_query_exec() Failed(%d)", ret);
-
- return CAL_SUCCESS;
-}
-
-
static int _cals_delete_participant_info(const int index)
{
int ret;
}
-static int _cals_delete_recurrency_log(const int event_id)
-{
- int ret;
- char query[CALS_SQL_MIN_LEN] = {0};
-
- sprintf(query, "DELETE FROM %s WHERE event_id = %d", CALS_TABLE_RECURRENCY_LOG, event_id);
-
- ret = cals_query_exec(query);
- retvm_if(CAL_SUCCESS != ret, ret, "cals_query_exec() Failed(%d)", ret);
-
- return CAL_SUCCESS;
-}
-
-
static inline int _cals_update_schedule(const int index, cal_sch_full_t *current_record)
{
int ret = -1;
- char sql_value[CALS_SQL_MAX_LEN] = {0};
+ char query[CALS_SQL_MAX_LEN] = {0};
+ char dtstart_datetime[32] = {0};
+ char dtend_datetime[32] = {0};
sqlite3_stmt *stmt = NULL;
- time_t conv_start_time;
- time_t conv_end_time;
- time_t conv_repeat_end_time;
- time_t conv_created_date_time;
- time_t conv_completed_date_time;
- time_t t = time(NULL);
- tzset();
- struct tm * ptm = NULL;
- struct tm ttm;
retv_if(NULL == current_record, CAL_ERR_ARG_NULL);
- ptm = gmtime_r(&t, &ttm);
- retvm_if(NULL == ptm, CAL_ERR_TIME_FAILED, "gmtime_r() Failed(%d)", errno);
- memcpy(¤t_record->last_modified_time, &ttm, sizeof(struct tm));
-
- _cals_adjust_time(current_record,&conv_start_time,&conv_end_time,&conv_repeat_end_time);
- conv_created_date_time = cals_mktime(&(current_record->created_date_time));
- conv_completed_date_time = cals_mktime(&(current_record->completed_date_time));
-
if (CAL_SYNC_STATUS_UPDATED != current_record->sync_status)
current_record->sync_status = CAL_SYNC_STATUS_UPDATED;
- snprintf(sql_value, sizeof(sql_value), "UPDATE %s set "
+ snprintf(query, sizeof(query), "UPDATE %s SET "
+ "changed_ver = %d,"
"type = %d,"
- "category = %d,"
"summary = ?,"
"description = ?,"
"location = ?,"
- "all_day_event = %d,"
- "start_date_time = %ld,"
- "end_date_time = %ld,"
- "repeat_item = %d,"
- "repeat_interval = %d,"
- "repeat_until_type = %d,"
- "repeat_occurrences = %d,"
- "repeat_end_date = %ld,"
- "sun_moon = %d,"
- "week_start = %d,"
- "week_flag = ?,"
- "day_date = %d,"
- "last_modified_time = %ld,"
+ "categories = ?,"
+ "exdate = ?,"
"missed = %d,"
"task_status = %d,"
"priority = %d,"
"organizer_email = ?, "
"meeting_status = %d, "
"gcal_id = ?, "
- "deleted = %d, "
"updated = ?, "
"location_type = %d, "
"location_summary = ?, "
"original_event_id = %d,"
"latitude = %lf,"
"longitude = %lf,"
- "is_deleted = %d,"
- "tz_name = ?,"
- "tz_city_name = ?,"
"email_id = %d,"
"availability = %d,"
- "created_date_time = %ld,"
- "completed_date_time = %ld,"
- "progress = %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')"
"WHERE id = %d;",
CALS_TABLE_SCHEDULE,
+ cals_get_next_ver(),
current_record->cal_type,
- current_record->sch_category,
- current_record->all_day_event,
- (long int)conv_start_time,
- (long int)conv_end_time,
- current_record->repeat_term,
- current_record->repeat_interval,
- current_record->repeat_until_type,
- current_record->repeat_occurrences,
- (long int)conv_repeat_end_time,
- current_record->sun_moon,
- current_record->week_start,
- current_record->day_date,
- (long int)cals_mktime(&(current_record->last_modified_time)),
current_record->missed,
current_record->task_status,
current_record->priority,
current_record->sensitivity,
current_record->calendar_type,
current_record->meeting_status,
- current_record->deleted,
current_record->location_type,
current_record->calendar_id,
current_record->sync_status,
current_record->original_event_id,
current_record->latitude,
current_record->longitude,
- current_record->is_deleted,
current_record->email_id,
current_record->availability,
- (long int)conv_created_date_time,
- (long int)conv_completed_date_time,
+ current_record->completed_time,
current_record->progress,
+ current_record->dtstart_type,
+ current_record->dtstart_utime,
+ current_record->dtend_type,
+ current_record->dtend_utime,
index);
- stmt = cals_query_prepare(sql_value);
+ stmt = cals_query_prepare(query);
retvm_if(NULL == stmt, CAL_ERR_DB_FAILED, "cals_query_prepare() Failed");
int count = 1;
cals_stmt_bind_text(stmt, count, current_record->location);
count++;
- if (current_record->week_flag)
- cals_stmt_bind_text(stmt, count, current_record->week_flag);
+ if (current_record->categories)
+ cals_stmt_bind_text(stmt, count, current_record->categories);
+ count++;
+
+ if (current_record->exdate)
+ cals_stmt_bind_text(stmt, count, current_record->exdate);
count++;
if (current_record->uid)
cals_stmt_bind_text(stmt, count, current_record->gevent_id);
count++;
- if (current_record->tz_name)
- cals_stmt_bind_text(stmt, count, current_record->tz_name);
+ snprintf(dtstart_datetime, sizeof(dtstart_datetime), "%04d%02d%02d",
+ current_record->dtstart_year,
+ current_record->dtstart_month,
+ current_record->dtstart_mday);
+ cals_stmt_bind_text(stmt, count, dtstart_datetime);
+ count++;
+
+ if (current_record->dtstart_tzid)
+ cals_stmt_bind_text(stmt, count, current_record->dtstart_tzid);
+ count++;
+
+ snprintf(dtend_datetime, sizeof(dtend_datetime), "%04d%02d%02d",
+ current_record->dtend_year,
+ current_record->dtend_month,
+ current_record->dtend_mday);
+ cals_stmt_bind_text(stmt, count, dtend_datetime);
count++;
- if (current_record->tz_city_name)
- cals_stmt_bind_text(stmt, count, current_record->tz_city_name);
+ if (current_record->dtend_tzid)
+ cals_stmt_bind_text(stmt, count, current_record->dtend_tzid);
count++;
ret = cals_stmt_step(stmt);
return CAL_SUCCESS;
}
+static inline int _cals_update_rrule(const int index, cal_sch_full_t *record)
+{
+ int ret;
+ int cnt;
+ char query[CALS_SQL_MAX_LEN] = {0};
+ char until_datetime[32] = {0};
+ sqlite3_stmt *stmt = NULL;
+
+ retv_if(record == NULL, CAL_ERR_ARG_NULL);
+
+ snprintf(query, sizeof(query), "UPDATE %s set "
+ "range_type = %d, "
+ "until_type = %d, "
+ "until_utime = %lld, "
+ "until_datetime = ?, "
+ "count = %d, "
+ "interval = %d, "
+ "bysecond = ?, "
+ "byminute = ?, "
+ "byhour = ?, "
+ "byday = ?, "
+ "bymonthday = ?, "
+ "byyearday = ?, "
+ "byweekno = ?, "
+ "bymonth = ?, "
+ "bysetpos = ?, "
+ "wkst = %d "
+ "WHERE event_id = %d",
+ CALS_TABLE_RRULE,
+ record->range_type,
+ record->until_type,
+ record->until_utime,
+ record->count,
+ record->interval,
+ record->wkst,
+ index);
+ stmt = cals_query_prepare(query);
+ retvm_if(stmt == NULL, CAL_ERR_DB_FAILED, "Failed query prepare");
+
+ cnt = 1;
+ snprintf(until_datetime, sizeof(until_datetime), "%04d%02d%02dT235959",
+ record->until_year, record->until_month, record->until_mday);
+ cals_stmt_bind_text(stmt, cnt, until_datetime);
+ cnt++;
+
+ if (record->bysecond)
+ cals_stmt_bind_text(stmt, cnt, record->bysecond);
+ cnt++;
+
+ if (record->byminute)
+ cals_stmt_bind_text(stmt, cnt, record->byminute);
+ cnt++;
+
+ if (record->byhour)
+ cals_stmt_bind_text(stmt, cnt, record->byhour);
+ cnt++;
+
+ if (record->byday)
+ cals_stmt_bind_text(stmt, cnt, record->byday);
+ cnt++;
+
+ if (record->bymonthday)
+ cals_stmt_bind_text(stmt, cnt, record->bymonthday);
+ cnt++;
+
+ if (record->byyearday)
+ cals_stmt_bind_text(stmt, cnt, record->byyearday);
+ cnt++;
+
+ if (record->byweekno)
+ cals_stmt_bind_text(stmt, cnt, record->byweekno);
+ cnt++;
+
+ if (record->bymonth)
+ cals_stmt_bind_text(stmt, cnt, record->bymonth);
+ cnt++;
+
+ if (record->bysetpos)
+ cals_stmt_bind_text(stmt, cnt, record->bysetpos);
+ cnt++;
+
+ ret = cals_stmt_step(stmt);
+ if (CAL_SUCCESS != ret) {
+ sqlite3_finalize(stmt);
+ ERR("sqlite3_step() Failed(%d)", ret);
+ return ret;
+ }
+ sqlite3_finalize(stmt);
+
+ return CAL_SUCCESS;
+}
+
+
int cals_update_schedule(const int index, cal_sch_full_t *sch_record)
{
bool is_success = false;
sch_record->missed = 0;
- ret = _cals_sch_check_validity(sch_record);
- retvm_if(CAL_SUCCESS != ret, ret, "_cals_sch_check_validity() is Failed(%d)", ret);
-
ret = _cals_update_schedule(index, sch_record);
retvm_if(CAL_SUCCESS != ret, ret, "_cals_update_schedule() Failed(%d)", ret);
+ ret = _cals_update_rrule(index, sch_record);
+ retvm_if(CAL_SUCCESS != ret, ret, "Failed in update rrule(%d)", ret);
+
_cals_delete_participant_info(index);
if (sch_record->attendee_list)
{
}
}
- _cals_delete_meeting_category_info(index);
- if (sch_record->meeting_category)
- {
- GList *list = g_list_first(sch_record->meeting_category);
- cal_category_info_t* category_info = NULL;
-
- while (list)
- {
- cvalue = (cal_value *)list->data;
- category_info = (cal_category_info_t*)cvalue->user_data;
- ret = _cals_add_meeting_category_info(index,category_info);
- warn_if(CAL_SUCCESS != ret, "_cals_add_meeting_category_info() Failed(%d)", ret);
- list = g_list_next(list);
- }
- }
-
- _cals_delete_recurrency_log(index);
- if (sch_record->exception_date_list)
- {
- GList *list = g_list_first(sch_record->exception_date_list);
- cal_exception_info_t* exception_info = NULL;
-
- while(list)
- {
- cvalue = (cal_value *)list->data;
- if(cvalue)
- {
- exception_info = (cal_exception_info_t*)cvalue->user_data;
- ret = cal_service_add_exception_info(index, exception_info, sch_record);
- warn_if(CAL_SUCCESS != ret, "cal_service_add_exception_info() Failed(%d)", ret);
- }
- list = g_list_next(list);
- }
- }
-
+ /* delete registered alarm */
cals_alarm_remove(CALS_ALARM_REMOVE_BY_EVENT_ID, index);
if (sch_record->alarm_list)
{
GList *list = sch_record->alarm_list;
cal_alarm_info_t *alarm_info = NULL;
+ struct cals_time dtstart;
while (list)
{
alarm_info = (cal_alarm_info_t*)cvalue->user_data;
if (alarm_info->is_deleted==0) {
- if (alarm_info->remind_tick != CAL_INVALID_INDEX) {
- ret = cals_alarm_add(index, alarm_info, &sch_record->start_date_time);
+ if (alarm_info->remind_tick != CALS_INVALID_ID) {
+ dtstart.type = sch_record->dtstart_type;
+ dtstart.utime = sch_record->dtstart_utime;
+ dtstart.year = sch_record->dtstart_year;
+ dtstart.month = sch_record->dtstart_month;
+ dtstart.mday = sch_record->dtstart_mday;
+ ret = cals_alarm_add(index, alarm_info, &dtstart);
warn_if(CAL_SUCCESS != ret, "cals_alarm_add() Failed(%d)", ret);
}
}
}
}
- if(sch_record->cal_type == CAL_EVENT_SCHEDULE_TYPE)
+ /* TODO: re register alarm */
+
+ /* clear instance */
+ ret = _cals_clear_instances(index);
+ if (ret) {
+ ERR("_cals_clear_instances failed (%d)", ret);
+ return ret;
+ }
+
+ /* insert instance */
+ struct cals_time st;
+ struct cals_time et;
+
+ st.type = sch_record->dtstart_type;
+ if (st.type == CALS_TIME_UTIME)
+ st.utime = sch_record->dtstart_utime;
+ else {
+ st.year = sch_record->dtstart_year;
+ st.month = sch_record->dtstart_month;
+ st.mday = sch_record->dtstart_mday;
+ }
+
+ et.type = sch_record->dtend_type;
+ if (et.type == CALS_TIME_UTIME)
+ et.utime = sch_record->dtend_utime;
+ else {
+ et.year = sch_record->dtend_year;
+ et.month = sch_record->dtend_month;
+ et.mday = sch_record->dtend_mday;
+ }
+
+ cals_instance_insert(index, &st, &et, sch_record);
+
+ /* set notify */
+ if(sch_record->cal_type == CALS_SCH_TYPE_EVENT)
is_success= cals_notify(CALS_NOTI_TYPE_EVENT);
else
is_success= cals_notify(CALS_NOTI_TYPE_TODO);
return CAL_SUCCESS;
}
+int _get_sch_basic_info(int id, int *cal_id, int *sch_type, int *acc_id)
+{
+ int r;
+ sqlite3_stmt *stmt;
+ char query[CALS_SQL_MAX_LEN];
+
+ snprintf(query, sizeof(query), "SELECT calendar_id, type, "
+ "account_id FROM %s WHERE id = %d",
+ CALS_TABLE_SCHEDULE, id);
+
+ stmt = cals_query_prepare(query);
+
+ if (!stmt) {
+ ERR("cals_query_prepare failed");
+ return CAL_ERR_DB_FAILED;
+ }
+
+ r = cals_stmt_step(stmt);
-static inline int _cals_update_recurrency_log(const int exception_event_id)
+ if (r < 0) {
+ sqlite3_finalize(stmt);
+ ERR("cals_stmt_step failed (%d)", r);
+ return r;
+ }
+
+ if (r == CAL_SUCCESS) {
+ ERR("cals_stmt_step return no data");
+ sqlite3_finalize(stmt);
+ return CAL_ERR_NO_DATA;
+ }
+
+ *cal_id = sqlite3_column_int(stmt, 0);
+ *sch_type = sqlite3_column_int(stmt, 1);
+ *acc_id = sqlite3_column_int(stmt, 2);
+
+ sqlite3_finalize(stmt);
+
+ return CAL_SUCCESS;
+}
+
+int _cals_update_deleted_table(int id)
{
- int ret;
- char query[CALS_SQL_MIN_LEN];
+ int r;
+ char query[CALS_SQL_MAX_LEN];
- sprintf(query, "UPDATE %s SET exception_event_id=-1 WHERE exception_event_id=%d",
- CALS_TABLE_RECURRENCY_LOG, exception_event_id);
+ snprintf(query, sizeof(query), "INSERT INTO %s "
+ "SELECT id, type, calendar_id, %d FROM %s "
+ "WHERE id = %d",
+ CALS_TABLE_DELETED,
+ cals_get_next_ver(), CALS_TABLE_SCHEDULE,
+ id);
- ret = cals_query_exec(query);
- retvm_if(CAL_SUCCESS != ret, ret, "cals_query_exec() Failed(%d)", ret);
+ r = cals_query_exec(query);
+ if (r) {
+ ERR("cals_query_exec() failed (%d)", r);
+ return r;
+ }
+ return CAL_SUCCESS;
+}
+
+int _cals_delete_schedule(int id)
+{
+ int r;
+ char query[CALS_SQL_MAX_LEN];
+
+ snprintf(query, sizeof(query), "DELETE FROM %s WHERE id = %d",
+ CALS_TABLE_SCHEDULE, id);
+ r = cals_query_exec(query);
+ if (r) {
+ ERR("cals_query_exec() failed (%d)", r);
+ return r;
+ }
return CAL_SUCCESS;
}
+int _cals_clear_instances(int id)
+{
+ int r;
+ char query[CALS_SQL_MAX_LEN];
+
+ snprintf(query, sizeof(query), "DELETE FROM %s WHERE event_id = %d ",
+ CALS_TABLE_NORMAL_INSTANCE, id);
-int cals_delete_schedule(const int index)
+ r = cals_query_exec(query);
+ if (r) {
+ ERR("cals_query_exec() failed (%d)", r);
+ return r;
+ }
+
+ snprintf(query, sizeof(query), "DELETE FROM %s WHERE event_id = %d ",
+ CALS_TABLE_ALLDAY_INSTANCE, id);
+
+ r = cals_query_exec(query);
+ if (r) {
+ ERR("cals_query_exec() failed (%d)", r);
+ return r;
+ }
+
+ return CAL_SUCCESS;
+}
+
+int _cals_delete_rrule(int id)
{
- bool is_success = false;
- sqlite3_stmt *stmt = NULL;
- int ret = 0;
- char sql_value[CALS_SQL_MAX_LEN] = {0};
- calendar_type_t type = CAL_PHONE_CALENDAR;
- int original_event_id = CAL_INVALID_INDEX;
- int repeat_item = 0;
- time_t current_time = time(NULL);
- int child_index = 0;
- int cal_type = 0;
-
- sprintf(sql_value, "SELECT calendar_type,original_event_id,repeat_item "
- "FROM %s WHERE id=%d AND is_deleted = 0", CALS_TABLE_SCHEDULE, index);
-
- stmt = cals_query_prepare(sql_value);
- retvm_if(NULL == stmt, CAL_ERR_DB_FAILED, "cals_query_prepare() Failed");
+ int r;
+ char query[CALS_SQL_MAX_LEN];
- ret = cals_stmt_step(stmt);
- if (CAL_TRUE == ret) {
- type = sqlite3_column_int(stmt, 0);
+ snprintf(query, sizeof(query), "DELETE FROM %s WHERE event_id = %d",
+ CALS_TABLE_RRULE, id);
- original_event_id = sqlite3_column_int(stmt, 1);
- repeat_item = sqlite3_column_int(stmt, 2);
- } else if (CAL_SUCCESS != ret) {
- sqlite3_finalize(stmt);
- ERR("cals_stmt_step() Failed(%d)", ret);
- return ret;
+ r = cals_query_exec(query);
+ if (r) {
+ ERR("cals_query_exec() failed (%d)", r);
+ return r;
}
- sqlite3_finalize(stmt);
- stmt = NULL;
- if(original_event_id != CAL_INVALID_INDEX) {
- _cals_update_recurrency_log(index);
- } else if(repeat_item != 0) {
- //select child list
- sprintf(sql_value, "SELECT id, type FROM %s WHERE original_event_id=%d AND is_deleted = 0",
- CALS_TABLE_SCHEDULE, index);
+ return CAL_SUCCESS;
+}
+
+int _cals_mark_delete_schedule(int id)
+{
+ int r;
+ char query[CALS_SQL_MAX_LEN];
- stmt = cals_query_prepare(sql_value);
- retvm_if(NULL == stmt, CAL_ERR_DB_FAILED, "cals_query_prepare() Failed");
+ snprintf(query, sizeof(query), "UPDATE %s "
+ "SET is_deleted = 1, changed_ver = %d, "
+ "last_mod = strftime('%%s','now') WHERE id = %d",
+ CALS_TABLE_SCHEDULE, cals_get_next_ver(), id);
- while (CAL_TRUE == cals_stmt_step(stmt))
- {
- child_index =sqlite3_column_int(stmt, 0);
- cal_type = sqlite3_column_int(stmt,1);
-
- memset(sql_value,'\0',CALS_SQL_MAX_LEN);
- sprintf(sql_value, "UPDATE %s SET is_deleted = 1,sync_status = %d,last_modified_time = %ld WHERE id = %d",
- CALS_TABLE_SCHEDULE, CAL_SYNC_STATUS_DELETED, (long int)current_time, child_index);
-
- ret = cals_query_exec(sql_value);
- if (CAL_SUCCESS != ret) {
- sqlite3_finalize(stmt);
- ERR("cals_query_exec() Failed(%d)", ret);
- return ret;
- }
+ r = cals_query_exec(query);
+ if (r) {
+ ERR("cals_query_exec() failed (%d)", r);
+ return r;
+ }
- ret = cals_alarm_remove(CALS_ALARM_REMOVE_BY_EVENT_ID, child_index);
- if (CAL_SUCCESS != ret) {
- sqlite3_finalize(stmt);
- ERR("cals_alarm_remove() Failed(%d)", ret);
- return ret;
- }
+ return CAL_SUCCESS;
+}
+
+int cals_delete_schedule(int id)
+{
+ int r;
+ int cal_id;
+ int sch_type;
+ int acc_id;
+
+ r = _get_sch_basic_info(id, &cal_id, &sch_type, &acc_id);
+ if (r) {
+ ERR("_get_sch_basic_info failed (%d)", r);
+ return r;
+ }
+
+ if (acc_id == LOCAL_ACCOUNT_ID) {
+ _cals_update_deleted_table(id);
+ if (r) {
+ ERR("_cals_update_deleted_table failed (%d)", r);
+ return r;
+ }
+ r = _cals_delete_schedule(id);
+ if (r) {
+ ERR("_cals_delete_schedule failed (%d)", r);
+ return r;
+ }
+ _cals_delete_participant_info(id);
+ if (r) {
+ ERR("_cals_delete_participant_info failed (%d)", r);
+ return r;
+ }
+ _cals_delete_rrule(id);
+ if (r) {
+ ERR("_cals_delete_rrule failed (%d)", r);
+ return r;
+ }
+ }
+ else {
+ r = _cals_mark_delete_schedule(id);
+ if (r) {
+ ERR("_cals_mark_delete_schedule failed (%d)", r);
+ return r;
}
- sqlite3_finalize(stmt);
}
- //delete original event
- sprintf(sql_value, "UPDATE %s SET is_deleted = 1,sync_status = %d,last_modified_time = %ld WHERE id = %d;",
- CALS_TABLE_SCHEDULE, CAL_SYNC_STATUS_DELETED,(long int)current_time, index);
-
- ret = cals_query_exec(sql_value);
- retvm_if(CAL_SUCCESS != ret, ret, "cals_query_exec() Failed(%d)", ret);
+ r = _cals_clear_instances(id);
+ if (r) {
+ ERR("_cals_clear_instances failed (%d)", r);
+ return r;
+ }
- ret = cals_alarm_remove(CALS_ALARM_REMOVE_BY_EVENT_ID, index);
- retvm_if(CAL_SUCCESS != ret, ret, "cals_alarm_remove() Failed(%d)", ret);
+ r = _cals_delete_rrule(id);
+ if (r) {
+ ERR("_cals_delete_rrule (%d)", r);
+ return r;
+ }
- _cals_delete_recurrency_log(index);
- _cals_delete_participant_info(index);
- _cals_delete_meeting_category_info(index);
+ r = cals_alarm_remove(CALS_ALARM_REMOVE_BY_EVENT_ID, id);
+ if (r) {
+ ERR("cals_alarm_remove() failed(%d)", r);
+ return r;
+ }
- if(cal_type == CAL_EVENT_SCHEDULE_TYPE)
- is_success= cals_notify(CALS_NOTI_TYPE_EVENT);
+ if(sch_type == CALS_SCH_TYPE_EVENT)
+ r = cals_notify(CALS_NOTI_TYPE_EVENT);
else
- is_success= cals_notify(CALS_NOTI_TYPE_TODO);
- warn_if(is_success != true, , "cals_notify() Failed");
+ r = cals_notify(CALS_NOTI_TYPE_TODO);
+
+ if (r)
+ WARN("cals_notify failed (%d)", r);
return CAL_SUCCESS;
}
-
-int cals_rearrage_schedule_field(const char *src, char *dest, int dest_size)
+int cals_rearrange_schedule_field(const char *src, char *dest, int dest_size)
{
int ret = 0;
if (strstr(src, CAL_VALUE_INT_INDEX))
if (strstr(src,CAL_VALUE_INT_TYPE))
ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_INT_TYPE);
- if (strstr(src,CAL_VALUE_INT_CATEGORY))
- ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_INT_CATEGORY);
-
if (strstr(src,CAL_VALUE_TXT_SUMMARY))
ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_TXT_SUMMARY);
if (strstr(src,CAL_VALUE_TXT_LOCATION))
ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_TXT_LOCATION);
- if(strstr(src,CAL_VALUE_INT_ALL_DAY_EVENT))
- ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_INT_ALL_DAY_EVENT);
-
- if(strstr(src,CAL_VALUE_GMT_START_DATE_TIME))
- ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_GMT_START_DATE_TIME);
-
- if(strstr(src, CAL_VALUE_GMT_END_DATE_TIME))
- ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_GMT_END_DATE_TIME);
-
- if(strstr(src, CAL_VALUE_INT_REPEAT_TERM))
- ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_INT_REPEAT_TERM);
-
- if(strstr(src, CAL_VALUE_INT_REPEAT_INTERVAL))
- ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_INT_REPEAT_INTERVAL);
-
- if(strstr(src, CAL_VALUE_INT_REPEAT_OCCURRENCES))
- ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_INT_REPEAT_OCCURRENCES);
-
- if(strstr(src,CAL_VALUE_GMT_REPEAT_END_DATE))
- ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_GMT_REPEAT_END_DATE);
-
- if(strstr(src,CAL_VALUE_INT_SUN_MOON))
- ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_INT_SUN_MOON);
-
- if(strstr(src,CAL_VALUE_INT_WEEK_START))
- ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_INT_WEEK_START);
-
- if(strstr(src,CAL_VALUE_TXT_WEEK_FLAG))
- ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_TXT_WEEK_FLAG);
-
- if(strstr(src,CAL_VALUE_INT_DAY_DATE))
- ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_INT_DAY_DATE);
-
- if(strstr(src,CAL_VALUE_GMT_LAST_MODIFIED_TIME))
- ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_GMT_LAST_MODIFIED_TIME);
+ if (strstr(src, CAL_VALUE_TXT_CATEGORIES))
+ ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_TXT_CATEGORIES);
if(strstr(src,CAL_VALUE_INT_MISSED))
ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_INT_MISSED);
if(strstr(src,CAL_VALUE_DBL_LONGITUDE))
ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_DBL_LONGITUDE);
- if(strstr(src,CAL_VALUE_INT_IS_DELETED))
- ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_INT_IS_DELETED);
-
- if(strstr(src,CAL_VALUE_TXT_TZ_NAME))
- ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_TXT_TZ_NAME);
-
- if(strstr(src,CAL_VALUE_TXT_TZ_CITY_NAME))
- ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_TXT_TZ_CITY_NAME);
-
if(strstr(src,CAL_VALUE_INT_EMAIL_ID))
ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_INT_EMAIL_ID);
if(strstr(src,CAL_VALUE_INT_AVAILABILITY))
ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_INT_AVAILABILITY);
- if(strstr(src,CAL_VALUE_GMT_CREATED_DATE_TIME))
- ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_GMT_CREATED_DATE_TIME);
+ if(strstr(src,CAL_VALUE_LLI_CREATED_TIME))
+ ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_LLI_CREATED_TIME);
- if(strstr(src,CAL_VALUE_GMT_COMPLETED_DATE_TIME))
- ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_GMT_COMPLETED_DATE_TIME);
+ if(strstr(src,CAL_VALUE_LLI_COMPLETED_TIME))
+ ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_LLI_COMPLETED_TIME);
if(strstr(src,CAL_VALUE_INT_PROGRESS))
ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_INT_PROGRESS);
+ if(strstr(src,CAL_VALUE_INT_IS_DELETED))
+ ret += snprintf(dest+ret, dest_size-ret, ",%s", CAL_VALUE_INT_IS_DELETED);
+
return CAL_SUCCESS;
}
cal_sch_full_t *sch_record, const char *select_field)
{
int count = 0;
- int ivalue = 0;
const unsigned char *temp;
const char *start, *result;
start = result;
}
- if((result = strstr(start,CAL_VALUE_INT_CATEGORY))) {
- sch_record->sch_category = sqlite3_column_int(stmt, count++);
- start = result;
- }
-
if((result = strstr(start,CAL_VALUE_TXT_SUMMARY))) {
temp = sqlite3_column_text(stmt, count++);
sch_record->summary = SAFE_STRDUP(temp);
start = result;
}
- if((result = strstr(start,CAL_VALUE_INT_ALL_DAY_EVENT))) {
- sch_record->all_day_event = sqlite3_column_int(stmt, count++);
- start = result;
- }
-
- if((result = strstr(start,CAL_VALUE_GMT_START_DATE_TIME))) {
- ivalue = sqlite3_column_int(stmt, count++);
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime((time_t*)&ivalue ),&(sch_record->start_date_time));
- start = result;
- }
-
- if((result = strstr(start, CAL_VALUE_GMT_END_DATE_TIME))) {
- ivalue = sqlite3_column_int(stmt, count++);
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime((time_t*)&ivalue),&(sch_record->end_date_time));
- start = result;
- }
-
- if((result = strstr(start, CAL_VALUE_INT_REPEAT_TERM))) {
- sch_record->repeat_term = sqlite3_column_int(stmt, count++);
- start = result;
- }
-
- if((result = strstr(start, CAL_VALUE_INT_REPEAT_INTERVAL))) {
- sch_record->repeat_interval = sqlite3_column_int(stmt, count++);
- start = result;
- }
-
- if((result = strstr(start, CAL_VALUE_INT_REPEAT_UNTIL_TYPE))) {
- sch_record->repeat_until_type = sqlite3_column_int(stmt, count++);
- start = result;
- }
-
- if((result = strstr(start, CAL_VALUE_INT_REPEAT_OCCURRENCES))) {
- sch_record->repeat_occurrences = sqlite3_column_int(stmt, count++);
- start = result;
- }
-
- if((result = strstr(start,CAL_VALUE_GMT_REPEAT_END_DATE))) {
- ivalue = sqlite3_column_int(stmt, count++);
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime((time_t*)&ivalue),&(sch_record->repeat_end_date));
- start = result;
- }
-
- if((result = strstr(start,CAL_VALUE_INT_SUN_MOON))) {
- sch_record->sun_moon = sqlite3_column_int(stmt, count++);
- start = result;
- }
-
- if((result = strstr(start,CAL_VALUE_INT_WEEK_START))) {
- sch_record->week_start = sqlite3_column_int(stmt, count++);
- start = result;
- }
-
- if((result = strstr(start,CAL_VALUE_TXT_WEEK_FLAG))) {
+ if((result = strstr(start, CAL_VALUE_TXT_CATEGORIES))) {
temp = sqlite3_column_text(stmt, count++);
- sch_record->week_flag = SAFE_STRDUP(temp);
- start = result;
- }
-
- if((result = strstr(start,CAL_VALUE_INT_DAY_DATE))) {
- sch_record->day_date = sqlite3_column_int(stmt, count++);
+ sch_record->categories = SAFE_STRDUP(temp);
start = result;
}
- if((result = strstr(start,CAL_VALUE_GMT_LAST_MODIFIED_TIME))) {
- ivalue = sqlite3_column_int(stmt, count++);
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime((time_t*)&ivalue),&(sch_record->last_modified_time));
+ if((result = strstr(start, CAL_VALUE_TXT_EXDATE))) {
+ temp = sqlite3_column_text(stmt, count++);
+ sch_record->exdate = SAFE_STRDUP(temp);
start = result;
}
-
if((result = strstr(start,CAL_VALUE_INT_MISSED))) {
sch_record->missed = sqlite3_column_int(stmt, count++);
start = result;
start = result;
}
- if((result = strstr(start,CAL_VALUE_INT_DELETED))) {
- sch_record->deleted = sqlite3_column_int(stmt, count++);
- start = result;
- }
-
if((result = strstr(start,CAL_VALUE_TXT_UPDATED))) {
temp = sqlite3_column_text(stmt, count++);
sch_record->updated = SAFE_STRDUP(temp);
start = result;
}
- if((result = strstr(start,CAL_VALUE_INT_IS_DELETED))) {
- sch_record->is_deleted = sqlite3_column_int(stmt, count++);
- start = result;
- }
-
- if((result = strstr(start,CAL_VALUE_TXT_TZ_NAME))) {
- temp = sqlite3_column_text(stmt, count++);
- sch_record->tz_name = SAFE_STRDUP(temp);
- start = result;
- }
-
- if((result = strstr(start,CAL_VALUE_TXT_TZ_CITY_NAME))) {
- temp = sqlite3_column_text(stmt, count++);
- sch_record->tz_city_name = SAFE_STRDUP(temp);
- start = result;
- }
-
if((result = strstr(start,CAL_VALUE_INT_EMAIL_ID))) {
sch_record->email_id = sqlite3_column_int(stmt, count++);
start = result;
start = result;
}
- if((result = strstr(start,CAL_VALUE_GMT_CREATED_DATE_TIME))) {
- ivalue = sqlite3_column_int(stmt, count++);
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime((time_t*)&ivalue ),&(sch_record->created_date_time));
+ if((result = strstr(start,CAL_VALUE_LLI_CREATED_TIME))) {
+ sch_record->created_time = sqlite3_column_int64(stmt, count++);
start = result;
}
- if((result = strstr(start,CAL_VALUE_GMT_COMPLETED_DATE_TIME))) {
- ivalue = sqlite3_column_int(stmt, count++);
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime((time_t*)&ivalue ),&(sch_record->completed_date_time));
+ if((result = strstr(start,CAL_VALUE_LLI_COMPLETED_TIME))) {
+ sch_record->completed_time = sqlite3_column_int64(stmt, count++);
start = result;
}
start = result;
}
+ if((result = strstr(start,CAL_VALUE_INT_IS_DELETED))) {
+ sch_record->is_deleted = sqlite3_column_int(stmt, count++);
+ start = result;
+ }
return CAL_SUCCESS;
}
void cals_stmt_get_full_schedule(sqlite3_stmt *stmt,cal_sch_full_t *sch_record, bool is_utc)
{
int count = 0;
- long int tmp_time = 0;
+ char *dtstart_datetime;
+ char *dtend_datetime;
+ char buf[8] = {0};
const unsigned char *temp;
sch_record->index = sqlite3_column_int(stmt, count++);
sch_record->account_id = sqlite3_column_int(stmt, count++);
sch_record->cal_type = sqlite3_column_int(stmt, count++);
- sch_record->sch_category = sqlite3_column_int(stmt, count++);
+
temp = sqlite3_column_text(stmt, count++);
sch_record->summary = SAFE_STRDUP(temp);
+
temp = sqlite3_column_text(stmt, count++);
sch_record->description = SAFE_STRDUP(temp);
+
temp = sqlite3_column_text(stmt, count++);
sch_record->location = SAFE_STRDUP(temp);
- sch_record->all_day_event = sqlite3_column_int(stmt, count++);
-
- tmp_time = sqlite3_column_int(stmt, count++);
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime(&tmp_time),&(sch_record->start_date_time));
-
- tmp_time = sqlite3_column_int(stmt, count++);
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime(&tmp_time),&(sch_record->end_date_time));
-
- sch_record->repeat_term = sqlite3_column_int(stmt, count++);
- sch_record->repeat_interval = sqlite3_column_int(stmt, count++);
- sch_record->repeat_until_type = sqlite3_column_int(stmt, count++);
- sch_record->repeat_occurrences = sqlite3_column_int(stmt, count++);
-
- tmp_time = sqlite3_column_int(stmt, count++);
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime(&tmp_time),&(sch_record->repeat_end_date));
-
- sch_record->sun_moon = sqlite3_column_int(stmt, count++);
- sch_record->week_start = sqlite3_column_int(stmt, count++);
temp = sqlite3_column_text(stmt, count++);
- sch_record->week_flag = SAFE_STRDUP(temp);
-
- sch_record->day_date = sqlite3_column_int(stmt, count++);
+ sch_record->categories = SAFE_STRDUP(temp);
- tmp_time = sqlite3_column_int(stmt, count++);
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime(&tmp_time), &(sch_record->last_modified_time));
+ temp = sqlite3_column_text(stmt, count++);
+ sch_record->exdate = SAFE_STRDUP(temp);
sch_record->missed = sqlite3_column_int(stmt, count++);
sch_record->task_status = sqlite3_column_int(stmt, count++);
temp = sqlite3_column_text(stmt, count++);
sch_record->gcal_id = SAFE_STRDUP(temp);
- sch_record->deleted = sqlite3_column_int(stmt, count++);
-
temp = sqlite3_column_text(stmt, count++);
sch_record->updated = SAFE_STRDUP(temp);
sch_record->latitude = sqlite3_column_double(stmt,count++);
sch_record->longitude = sqlite3_column_double(stmt,count++);
- sch_record->deleted = sqlite3_column_int(stmt, count++);
+ sch_record->email_id = sqlite3_column_int(stmt, count++);
+
+ sch_record->availability = sqlite3_column_int(stmt, count++);
+
+ sch_record->created_time = sqlite3_column_int64(stmt, count++);
+
+ sch_record->completed_time = sqlite3_column_int64(stmt, count++);
+
+ sch_record->progress = sqlite3_column_int(stmt,count++);
+
+
+ sqlite3_column_int(stmt,count++);
+ sqlite3_column_int(stmt,count++);
+ sch_record->is_deleted = sqlite3_column_int(stmt,count++);
+
+ sch_record->dtstart_type = sqlite3_column_int(stmt,count++);
+ sch_record->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]);
+ sch_record->dtstart_year = atoi(buf);
+ snprintf(buf, strlen("MM") + 1, "%s", &dtstart_datetime[4]);
+ sch_record->dtstart_month = atoi(buf);
+ snprintf(buf, strlen("DD") + 1, "%s", &dtstart_datetime[6]);
+ sch_record->dtstart_mday = atoi(buf);
+ if (dtstart_datetime) free(dtstart_datetime);
+ }
temp = sqlite3_column_text(stmt, count++);
- sch_record->tz_name = SAFE_STRDUP(temp);
+ sch_record->dtstart_tzid = SAFE_STRDUP(temp);
+ sch_record->dtend_type = sqlite3_column_int(stmt, count++);
+ sch_record->dtend_utime = sqlite3_column_int64(stmt, count++);
temp = sqlite3_column_text(stmt, count++);
- sch_record->tz_city_name = SAFE_STRDUP(temp);
+ if (temp) {
+ dtend_datetime = SAFE_STRDUP(temp);
+ snprintf(buf, strlen("YYYY") + 1, "%s", &dtend_datetime[0]);
+ sch_record->dtend_year = atoi(buf);
+ snprintf(buf, strlen("MM") + 1, "%s", &dtend_datetime[4]);
+ sch_record->dtend_month = atoi(buf);
+ snprintf(buf, strlen("DD") + 1, "%s", &dtend_datetime[6]);
+ sch_record->dtend_mday = atoi(buf);
+ if (dtend_datetime) free(dtend_datetime);
+ }
+ temp = sqlite3_column_text(stmt, count++);
+ sch_record->dtend_tzid = SAFE_STRDUP(temp);
- sch_record->email_id = sqlite3_column_int(stmt, count++);
+ sch_record->last_mod = sqlite3_column_int64(stmt,count++);
+ sch_record->rrule_id = sqlite3_column_int(stmt,count++);
+}
- sch_record->availability = sqlite3_column_int(stmt, count++);
+void cals_stmt_fill_rrule(sqlite3_stmt *stmt,cal_sch_full_t *sch_record)
+{
+ char *until_datetime;
+ char buf[8] = {0};
+ const unsigned char *temp;
+ int count = 0;
- tmp_time = sqlite3_column_int(stmt, count++);
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime(&tmp_time),&(sch_record->created_date_time));
+ sch_record->rrule_id = sqlite3_column_int(stmt,count++);
+ sqlite3_column_int(stmt,count++); // event_id
+ sch_record->freq = sqlite3_column_int(stmt,count++);
+ sch_record->range_type = sqlite3_column_int(stmt,count++);
+ sch_record->until_type = sqlite3_column_int(stmt,count++);
+ sch_record->until_utime = sqlite3_column_int64(stmt, count++);
- tmp_time = sqlite3_column_int(stmt, count++);
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime(&tmp_time),&(sch_record->completed_date_time));
+ temp = sqlite3_column_text(stmt, count++);
+ if (temp) {
+ until_datetime = SAFE_STRDUP(temp);
+ snprintf(buf, strlen("YYYY") + 1, "%s", &until_datetime[0]);
+ sch_record->until_year = atoi(buf);
+ snprintf(buf, strlen("MM") + 1, "%s", &until_datetime[4]);
+ sch_record->until_month = atoi(buf);
+ snprintf(buf, strlen("DD") + 1, "%s", &until_datetime[6]);
+ sch_record->until_mday = atoi(buf);
+ if (until_datetime) free(until_datetime);
+ }
- sch_record->progress = sqlite3_column_int(stmt,count++);
+ sch_record->count = sqlite3_column_int(stmt,count++);
+ sch_record->interval = sqlite3_column_int(stmt,count++);
+
+ temp = sqlite3_column_text(stmt, count++);
+ sch_record->bysecond = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ sch_record->byminute = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ sch_record->byhour = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ sch_record->byday = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ sch_record->bymonthday = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ sch_record->byyearday = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ sch_record->byweekno = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ sch_record->bymonth = SAFE_STRDUP(temp);
+
+ temp = sqlite3_column_text(stmt, count++);
+ sch_record->bysetpos = SAFE_STRDUP(temp);
+
+ sch_record->wkst = sqlite3_column_int(stmt,count++);
+}
+
+inline char *cals_strcat(char * const dest, const char *src, int bufsize)
+{
+ return strncat(dest, src, bufsize - strlen(dest) -1);
+}
+
+void _cals_sch_search_get_cond(int fields, char * const buf, int bufsize)
+{
+ int first;
+
+ first = 1;
+
+ if (fields & CALS_SEARCH_FIELD_SUMMARY) {
+ if (first)
+ first = 0;
+ else
+ cals_strcat(buf, "OR ", bufsize);
+ cals_strcat(buf, "A.summary LIKE ('%%' || :key || '%%') ", bufsize);
+ }
+
+ if (fields & CALS_SEARCH_FIELD_DESCRIPTION) {
+ if (first)
+ first = 0;
+ else
+ cals_strcat(buf, "OR ", bufsize);
+ cals_strcat(buf, "A.description LIKE ('%%' || :key || '%%') ", bufsize);
+ }
+
+ if (fields & CALS_SEARCH_FIELD_LOCATION) {
+ if (first)
+ first = 0;
+ else
+ cals_strcat(buf, "OR ", bufsize);
+ cals_strcat(buf, "A.location LIKE ('%%' || :key || '%%') ", bufsize);
+ }
+
+ if (fields & CALS_SEARCH_FIELD_ATTENDEE) {
+ if (first)
+ first = 0;
+ else
+ cals_strcat(buf, "OR ", bufsize);
+ cals_strcat(buf, "B.attendee_name LIKE ('%%' || :key || '%%') ", bufsize);
+ }
+
+ return;
+}
+
+int cals_sch_search(cals_sch_type sch_type, int fields, const char *keyword, cal_iter **iter)
+{
+ cal_iter *it;
+ sqlite3_stmt *stmt;
+ char query[CALS_SQL_MAX_LEN] = {0};
+ char cond[CALS_SQL_MIN_LEN] = {0};
+
+ _cals_sch_search_get_cond(fields, cond, sizeof(cond));
+ snprintf(query, sizeof(query), "SELECT A.* "
+ "FROM %s A LEFT JOIN %s B ON A.id = B.event_id "
+ "JOIN %s C ON A.calendar_id = C.ROWID "
+ "WHERE A.type = %d AND (%s) AND C.visibility = 1",
+ CALS_TABLE_SCHEDULE, CALS_TABLE_PARTICIPANT, CALS_TABLE_CALENDAR, sch_type, cond);
+ DBG("QUERY [%s]", query);
+
+ stmt = cals_query_prepare(query);
+ retvm_if (!stmt, CAL_ERR_DB_FAILED, "cals_query_prepare() failed");
+
+ sqlite3_bind_text(stmt, sqlite3_bind_parameter_index(stmt, ":key"), keyword, strlen(keyword), SQLITE_TRANSIENT);
+
+ it = calloc(1, sizeof(cal_iter));
+ if (!it) {
+ sqlite3_finalize(stmt);
+ ERR("calloc() failed(%d)", errno);
+ return CAL_ERR_OUT_OF_MEMORY;
+ }
+
+ it->i_type = CAL_STRUCT_TYPE_SCHEDULE;
+ it->stmt = stmt;
+ *iter = it;
+
+ return CAL_SUCCESS;
+}
+
+API int calendar_svc_smartsearch_excl(const char *keyword, int offset, int limit, cal_iter **iter)
+{
+ cal_iter *it;
+ sqlite3_stmt *stmt;
+ char query[CALS_SQL_MAX_LEN] = {0};
+ char buf[1024] = {0};
+
+ snprintf(query, sizeof(query), "SELECT A.* "
+ "FROM %s A LEFT JOIN %s B ON A.calendar_id = B.ROWID "
+ "WHERE A.summary LIKE ('%%' || :key || '%%') AND B.visibility = 1 LIMIT %d OFFSET %d",
+ CALS_TABLE_SCHEDULE, CALS_TABLE_CALENDAR, limit, offset);
+
+ stmt = cals_query_prepare(query);
+ retvm_if (!stmt, CAL_ERR_DB_FAILED, "cals_query_prepare() failed");
+
+ cals_escape_like_pattern(keyword, buf, sizeof(buf));
+ sqlite3_bind_text(stmt, sqlite3_bind_parameter_index(stmt, ":key"), buf, strlen(buf), SQLITE_TRANSIENT);
+
+ it = calloc(1, sizeof(cal_iter));
+ if (!it) {
+ sqlite3_finalize(stmt);
+ ERR("calloc() failed(%d)", errno);
+ return CAL_ERR_OUT_OF_MEMORY;
+ }
+
+ it->i_type = CAL_STRUCT_TYPE_SCHEDULE;
+ it->stmt = stmt;
+ *iter = it;
+
+ return CAL_SUCCESS;
}
int cals_insert_schedule(cal_sch_full_t *sch_record);
int cals_update_schedule(const int index, cal_sch_full_t *sch_record);
int cals_delete_schedule(const int index);
+int cals_sch_search(cals_sch_type sch_type, int fields, const char *keyword, cal_iter **iter);
-int cals_rearrage_schedule_field(const char *src, char *dest, int dest_size);
+int cals_rearrange_schedule_field(const char *src, char *dest, int dest_size);
int cals_stmt_get_filted_schedule(sqlite3_stmt *stmt,cal_sch_full_t *sch_record, const char *select_field);
void cals_stmt_get_full_schedule(sqlite3_stmt *stmt,cal_sch_full_t *sch_record, bool is_utc);
-
+void cals_stmt_fill_rrule(sqlite3_stmt *stmt,cal_sch_full_t *sch_record);
#endif /* __CALENDAR_SVC_SCHEDULE_H__ */
int ret = -1;
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);
return ret;
}
-
int cals_escape_like_pattern(const char *src, char * const dest, int dest_size)
{
int s_pos=0, d_pos=0;
#include "calendar-svc-provider.h"
#include "cals-internal.h"
#include "cals-typedef.h"
-#include "cals-tz-utils.h"
#include "cals-db.h"
#include "cals-utils.h"
-int cals_init_full_record(cal_sch_full_t *sch_full_record)
-{
- time_t t = time(NULL);
- tzset();
- struct tm * cur_time = NULL;//localtime(&t);
- struct tm ttm;
-
- cur_time = localtime_r(&t,&ttm);
- if(NULL == cur_time)
- {
- return CAL_ERR_FAIL;
- }
- struct tm temp_date_time = {0};
- struct tm current_time = {0};
-
- retvm_if(NULL == sch_full_record, CAL_ERR_ARG_INVALID , "sch_full_record is NULL");
-
- memset(sch_full_record,0,sizeof(cal_sch_full_t));
-
- sch_full_record->cal_type = CAL_EVENT_SCHEDULE_TYPE;
- sch_full_record->sch_category = CAL_SCH_APPOINTMENT;
- memset(&temp_date_time, 0 ,sizeof(struct tm));
- memset(&sch_full_record->start_date_time, 0 ,sizeof(struct tm));
- memset(&sch_full_record->end_date_time, 0 ,sizeof(struct tm));
- memset(&sch_full_record->repeat_end_date, 0 ,sizeof(struct tm));
- memset(&sch_full_record->last_modified_time, 0 ,sizeof(struct tm));
- memset(&sch_full_record->created_date_time, 0 ,sizeof(struct tm));
- memset(&sch_full_record->completed_date_time, 0 ,sizeof(struct tm));
- memcpy(¤t_time,cur_time,sizeof(struct tm));
-
- memcpy(&sch_full_record->start_date_time,¤t_time,sizeof(struct tm));
- memcpy(&sch_full_record->end_date_time,¤t_time,sizeof(struct tm));
- sch_full_record->start_date_time.tm_sec = 0;
- sch_full_record->end_date_time.tm_sec = 0;
- sch_full_record->end_date_time.tm_hour ++;
- if (sch_full_record->end_date_time.tm_hour > 23)
- {
- sch_full_record->end_date_time.tm_hour = 0;
- cal_db_service_get_tomorrow(&sch_full_record->end_date_time);
- }
-
- cal_db_service_get_next_month(&sch_full_record->repeat_end_date);
- temp_date_time.tm_year = TM_YEAR_MIN;
- temp_date_time.tm_mon = MONTH_MIN;
- temp_date_time.tm_mday = MONTH_DAY_MIN;
- memcpy(&sch_full_record->repeat_end_date,&temp_date_time,sizeof(struct tm));
- memcpy(&sch_full_record->last_modified_time,&temp_date_time,sizeof(struct tm));
- memcpy(&sch_full_record->created_date_time,&temp_date_time,sizeof(struct tm));
- memcpy(&sch_full_record->completed_date_time,&temp_date_time,sizeof(struct tm));
-
- sch_full_record->index = CAL_INVALID_INDEX;
- sch_full_record->repeat_term = CAL_REPEAT_NONE;
- sch_full_record->repeat_until_type = CALS_REPEAT_UNTIL_TYPE_NONE;
- sch_full_record->day_date = 1;
- sch_full_record->timezone = -1;
- sch_full_record->contact_id = CAL_INVALID_INDEX;
- sch_full_record->calendar_type = CAL_PHONE_CALENDAR;
- sch_full_record->calendar_id = CAL_INVALID_INDEX;
- sch_full_record->attendee_list = NULL;
- sch_full_record->meeting_category = NULL;
- sch_full_record->busy_status = 2;
- sch_full_record->summary = NULL;
- sch_full_record->description = NULL;
- sch_full_record->location= NULL;
- sch_full_record->organizer_email = NULL;
- sch_full_record->organizer_name = NULL;
- sch_full_record->uid= NULL;
- sch_full_record->gcal_id = NULL;
- sch_full_record->location_summary = NULL;
- sch_full_record->etag = NULL;
- sch_full_record->edit_uri = NULL;
- sch_full_record->gevent_id = NULL;
- sch_full_record->tz_name = NULL;
- sch_full_record->tz_city_name = NULL;
- sch_full_record->original_event_id = CAL_INVALID_INDEX;
-
- // TODO : To define default value.
- sch_full_record->sync_status = CAL_SYNC_STATUS_NEW;
- sch_full_record->timezone = CAL_TIME_ZONE_GMT_L11;
- sch_full_record->is_deleted = 0;
- sch_full_record->account_id = -1;
- sch_full_record->calendar_id = DEFAULT_CALENDAR_ID;
-
- return CAL_SUCCESS;
-}
-
static inline void cals_init_calendar_record(calendar_t *calendar)
{
calendar->index = -1;
user_data = (cal_sch_full_t*)malloc(sizeof(cal_sch_full_t));
retvm_if(NULL == user_data, NULL, "malloc(cal_sch_full_t:sch) Failed(%d)", errno);
- ret = cals_init_full_record(user_data);
+ ret = cals_event_init(user_data);
if(ret) {
free(user_data);
- ERR("cals_init_full_record() Failed(%d)", ret);
+ ERR("cals_event_init() Failed(%d)", ret);
return NULL;
}
+
} else if (0 == strcmp(event_type, CAL_STRUCT_TODO)) {
type = CAL_STRUCT_TYPE_TODO;
- user_data = (cal_sch_full_t*)malloc(sizeof(cal_sch_full_t));
- retvm_if(NULL == user_data, NULL, "malloc(cal_sch_full_t:todo) Failed(%d)", errno);
+ user_data = (cal_sch_full_t*)calloc(1, sizeof(cal_sch_full_t));
+ retvm_if(NULL == user_data, NULL, "calloc(cal_sch_full_t:todo) Failed(%d)", errno);
- ret = cals_init_full_record(user_data);
+ ret = cals_todo_init(user_data);
if(ret) {
free(user_data);
- ERR("cals_init_full_record() Failed(%d)", ret);
+ ERR("cals_todo_init() Failed(%d)", ret);
return NULL;
}
- ((cal_sch_full_t*)user_data)->cal_type = CAL_EVENT_TODO_TYPE;
- ((cal_sch_full_t*)user_data)->end_date_time.tm_year = 69;
- ((cal_sch_full_t*)user_data)->sch_category = CAL_SCH_NONE;
} else if (0 == strcmp(event_type, CAL_STRUCT_CALENDAR)) {
type = CAL_STRUCT_TYPE_CALENDAR;
user_data = (cal_timezone_t*)calloc(1, sizeof(cal_timezone_t));
retvm_if(NULL == user_data, NULL, "calloc(cal_timezone_t) Failed(%d)", errno);
+ } else if(0 == strcmp(event_type, CAL_STRUCT_UPDATED)) {
+ type = CAL_STRUCT_TYPE_UPDATED_LIST;
+
+ user_data = (cals_updated*)calloc(1, sizeof(cals_updated));
+ retvm_if(NULL == user_data, NULL, "calloc(cals_updated) Failed(%d)", errno);
+ } else if(0 == strcmp(event_type, CALS_STRUCT_PERIOD_NORMAL_ONOFF)) {
+ type = CALS_STRUCT_TYPE_PERIOD_NORMAL_ONOFF;;
+ user_data = (cals_struct_period_normal_onoff*)calloc(1,
+ sizeof(cals_struct_period_normal_onoff));
+ retvm_if(NULL == user_data, NULL,
+ "Failed to calloc PERIOD_NORMAL_ONOFF(%d)", errno);
+
+ } else if(0 == strcmp(event_type, CALS_STRUCT_PERIOD_ALLDAY_ONOFF)) {
+ type = CALS_STRUCT_TYPE_PERIOD_ALLDAY_ONOFF;;
+ user_data = (cals_struct_period_allday_onoff*)calloc(1,
+ sizeof(cals_struct_period_allday_onoff));
+ retvm_if(NULL == user_data, NULL,
+ "Failed to calloc PERIOD_ALLDAY_ONOFF(%d)", errno);
+
+ } else if(0 == strcmp(event_type, CALS_STRUCT_PERIOD_NORMAL_BASIC)) {
+ type = CALS_STRUCT_TYPE_PERIOD_NORMAL_BASIC;
+ user_data = (cals_struct_period_normal_basic*)calloc(1,
+ sizeof(cals_struct_period_normal_basic));
+ retvm_if(NULL == user_data, NULL,
+ "Failed to calloc CAL_STRUCT_PERIOD_NORMAL_BASIC(%d)", errno);
+
+ } else if(0 == strcmp(event_type, CALS_STRUCT_PERIOD_ALLDAY_BASIC)) {
+ type = CALS_STRUCT_TYPE_PERIOD_ALLDAY_BASIC;
+ user_data = (cals_struct_period_allday_basic*)calloc(1,
+ sizeof(cals_struct_period_allday_basic));
+ retvm_if(NULL == user_data, NULL,
+ "Failed to calloc CAL_STRUCT_PERIOD_ALLDAY_BASIC(%d)", errno);
+
+ } else if(0 == strcmp(event_type, CALS_STRUCT_PERIOD_NORMAL_OSP)) {
+ type = CALS_STRUCT_TYPE_PERIOD_NORMAL_OSP;
+ user_data = (cals_struct_period_normal_osp*)calloc(1,
+ sizeof(cals_struct_period_normal_osp));
+ retvm_if(NULL == user_data, NULL,
+ "Failed to calloc CAL_STRUCT_PERIOD_NORMAL_BASIC(%d)", errno);
+
+ } else if(0 == strcmp(event_type, CALS_STRUCT_PERIOD_ALLDAY_OSP)) {
+ type = CALS_STRUCT_TYPE_PERIOD_ALLDAY_OSP;
+ user_data = (cals_struct_period_allday_osp*)calloc(1,
+ sizeof(cals_struct_period_allday_osp));
+ retvm_if(NULL == user_data, NULL,
+ "Failed to calloc CAL_STRUCT_PERIOD_ALLDAY_BASIC(%d)", errno);
+
+ } else if(0 == strcmp(event_type, CALS_STRUCT_PERIOD_NORMAL_LOCATION)) {
+ type = CALS_STRUCT_TYPE_PERIOD_NORMAL_LOCATION;
+ user_data = (cals_struct_period_normal_location*)calloc(1,
+ sizeof(cals_struct_period_normal_location));
+ retvm_if(NULL == user_data, NULL,
+ "Failed to calloc CAL_STRUCT_PERIOD_NORMAL_LOCATION(%d)", errno);
+
+ } else if(0 == strcmp(event_type, CALS_STRUCT_PERIOD_ALLDAY_LOCATION)) {
+ type = CALS_STRUCT_TYPE_PERIOD_ALLDAY_LOCATION;
+ user_data = (cals_struct_period_allday_location*)calloc(1,
+ sizeof(cals_struct_period_allday_location));
+ retvm_if(NULL == user_data, NULL,
+ "Failed to calloc CAL_STRUCT_PERIOD_ALLDAY_BASIC(%d)", errno);
+
+ } else if(0 == strcmp(event_type, CALS_STRUCT_PERIOD_NORMAL_ALARM)) {
+ type = CALS_STRUCT_TYPE_PERIOD_NORMAL_ALARM;
+ user_data = (cals_struct_period_normal_alarm*)calloc(1,
+ sizeof(cals_struct_period_normal_alarm));
+ retvm_if(NULL == user_data, NULL,
+ "Failed to calloc CAL_STRUCT_PERIOD_NORMAL_ALARM(%d)", errno);
+
} else {
ERR("Unknown type(%s)", event_type);
return NULL;
cals_free_timezone_record((cal_timezone_t*)(*event)->user_data);
CAL_FREE(*event);
break;
+ case CAL_STRUCT_TYPE_UPDATED_LIST:
+ CAL_FREE((*event)->user_data);
+ CAL_FREE(*event);
+ break;
default:
ERR("Unknown type(%d)", (*event)->event_type);
break;
cal_sch_full_t * sch_rec = NULL;
calendar_t * cal_rec = NULL;
cal_timezone_t *tz_rec = NULL;
+ cals_struct_period_normal_basic *nbs = NULL;
+ cals_struct_period_allday_basic *abs = NULL;
+ cals_struct_period_normal_osp *nosp = NULL;
+ cals_struct_period_allday_osp *aosp = NULL;
+ cals_struct_period_normal_location *nosl = NULL;
+ cals_struct_period_allday_location *aosl = NULL;
switch(event->event_type)
{
{
return (sch_rec->location);
}
- else if(0 == strcmp(field,CAL_VALUE_TXT_WEEK_FLAG))
+ else if(0 == strcmp(field, CAL_VALUE_TXT_CATEGORIES))
+ {
+ return (sch_rec->categories);
+ }
+ else if(0 == strcmp(field, CAL_VALUE_TXT_EXDATE))
{
- return (sch_rec->week_flag);
+ return (sch_rec->exdate);
}
else if(0 == strcmp(field,CAL_VALUE_TXT_UID))
{
{
return (sch_rec->gevent_id);
}
- else if(0 == strcmp(field,CAL_VALUE_TXT_TZ_NAME))
- {
- return (sch_rec->tz_name);
- }
- else if(0 == strcmp(field,CAL_VALUE_TXT_TZ_CITY_NAME))
- {
- return (sch_rec->tz_city_name);
- }
+ else if(0 == strcmp(field, CALS_VALUE_TXT_DTSTART_TZID))
+ return (sch_rec->dtstart_tzid);
+ else if(0 == strcmp(field, CALS_VALUE_TXT_DTEND_TZID))
+ return (sch_rec->dtend_tzid);
+ else if(0 == strcmp(field, CALS_VALUE_TXT_RRULE_BYSECOND))
+ return (sch_rec->bysecond);
+ else if(0 == strcmp(field, CALS_VALUE_TXT_RRULE_BYMINUTE))
+ return (sch_rec->byminute);
+ else if(0 == strcmp(field, CALS_VALUE_TXT_RRULE_BYHOUR))
+ return (sch_rec->byhour);
+ else if(0 == strcmp(field, CALS_VALUE_TXT_RRULE_BYDAY))
+ return (sch_rec->byday);
+ else if(0 == strcmp(field, CALS_VALUE_TXT_RRULE_BYMONTHDAY))
+ return (sch_rec->bymonthday);
+ else if(0 == strcmp(field, CALS_VALUE_TXT_RRULE_BYYEARDAY))
+ return (sch_rec->byyearday);
+ else if(0 == strcmp(field, CALS_VALUE_TXT_RRULE_BYWEEKNO))
+ return (sch_rec->byweekno);
+ else if(0 == strcmp(field, CALS_VALUE_TXT_RRULE_BYMONTH))
+ return (sch_rec->bymonth);
+ else if(0 == strcmp(field, CALS_VALUE_TXT_RRULE_BYSETPOS))
+ return (sch_rec->bysetpos);
else
{
ERR("Can not find the field(%s)!", field);
ERR("Can not find the field!(%s)",field);
return NULL;
}
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_ONOFF:
+ ERR("No field in CALS_LIST_PERIOD_NORMAL_ONOFF");
+ return NULL;
+
+ case CALS_STRUCT_TYPE_PERIOD_ALLDAY_ONOFF:
+ ERR("No field in CALS_LIST_PERIOD_ALLDAY_ONOFF");
+ return NULL;
+
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_BASIC:
+ nbs = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_BASIC_TXT_SUMMARY))
+ return nbs->summary;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_BASIC_TXT_LOCATION))
+ return nbs->location;
+ else {
+ ERR("Can not find the field!(%s)",field);
+ return NULL;
+ }
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_ALLDAY_BASIC:
+ abs = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_BASIC_TXT_SUMMARY))
+ return abs->summary;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_BASIC_TXT_LOCATION))
+ return abs->location;
+ else {
+ ERR("Can not find the field!(%s)", field);
+ return NULL;
+ }
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_OSP:
+ nosp = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_TXT_SUMMARY))
+ return nosp->summary;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_TXT_LOCATION))
+ return nosp->location;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_TXT_DESCRIPTION))
+ return nosp->description;
+ else {
+ ERR("Can not find the field!(%s)", field);
+ return NULL;
+ }
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_ALLDAY_OSP:
+ aosp = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_TXT_SUMMARY))
+ return aosp->summary;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_TXT_LOCATION))
+ return aosp->location;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_TXT_DESCRIPTION))
+ return aosp->description;
+ else {
+ ERR("Can not find the field!(%s)", field);
+ return NULL;
+ }
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_LOCATION:
+ nosl = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_TXT_SUMMARY))
+ return nosl->summary;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_TXT_LOCATION))
+ return nosl->location;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_TXT_DESCRIPTION))
+ return nosl->description;
+ else {
+ ERR("Can not find the field!(%s)", field);
+ return NULL;
+ }
+ break;
+ case CALS_STRUCT_TYPE_PERIOD_ALLDAY_LOCATION:
+ aosl = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_TXT_SUMMARY))
+ return aosl->summary;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_TXT_LOCATION))
+ return aosl->location;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_TXT_DESCRIPTION))
+ return aosl->description;
+ else {
+ ERR("Can not find the field!(%s)", field);
+ return NULL;
+ }
break;
+
default:
ERR("Can not find the field!(%s)!", field);
return NULL;
API int calendar_svc_struct_get_int(cal_struct *event, const char *field)
{
cal_sch_full_t * sch_rec = NULL;
+ cals_updated *update = NULL;
calendar_t * cal_rec = NULL;
cal_timezone_t *tz_rec = NULL;
+ cals_struct_period_normal_onoff *nof = NULL;
+ cals_struct_period_allday_onoff *aof = NULL;
+ cals_struct_period_normal_basic *nbs = NULL;
+ cals_struct_period_allday_basic *abs = NULL;
+ cals_struct_period_normal_osp *nosp = NULL;
+ cals_struct_period_allday_osp *aosp = NULL;
+ cals_struct_period_normal_location *nosl = NULL;
+ cals_struct_period_allday_location *aosl = NULL;
+ cals_struct_period_normal_alarm *nosa = NULL;
retvm_if(NULL == event || NULL==event->user_data || NULL == field, 0,
"Invalid parameters(event(%p), field(%p))", event, field);
-
switch(event->event_type)
{
case CAL_STRUCT_TYPE_SCHEDULE:
{
return sch_rec->cal_type;
}
- else if(0 == strcmp(field, CAL_VALUE_INT_CATEGORY))
- {
- return sch_rec->sch_category;
- }
- else if(0 == strcmp(field,CAL_VALUE_INT_REPEAT_TERM))
- {
- return sch_rec->repeat_term;
- }
- else if(0 == strcmp(field,CAL_VALUE_INT_REPEAT_INTERVAL))
- {
- return sch_rec->repeat_interval;
- }
- else if(0 == strcmp(field,CAL_VALUE_INT_REPEAT_UNTIL_TYPE))
- {
- return sch_rec->repeat_until_type;
- }
- else if(0 == strcmp(field,CAL_VALUE_INT_REPEAT_OCCURRENCES))
- {
- return sch_rec->repeat_occurrences;
- }
- else if(0 == strcmp(field,CAL_VALUE_INT_DAY_DATE))
- {
- return sch_rec->day_date;
- }
else if(0 == strcmp(field,CAL_VALUE_INT_FILE_ID))
{
return sch_rec->file_id;
{
return sch_rec->original_event_id;
}
- else if(0 == strcmp(field,CAL_VALUE_INT_ALL_DAY_EVENT))
- {
- return sch_rec->all_day_event;
- }
else if(0 == strcmp(field,CAL_VALUE_INT_SYNC_STATUS))
{
return sch_rec->sync_status;
}
- else if(0 == strcmp(field,CAL_VALUE_INT_SUN_MOON))
- {
- return sch_rec->sun_moon;
- }
else if(0 == strcmp(field,CAL_VALUE_INT_PRIORITY))
{
return sch_rec->priority;
}
- else if(0 == strcmp(field,CAL_VALUE_INT_WEEK_START))
- {
- return sch_rec->week_start;
- }
else if(0 == strcmp(field,CAL_VALUE_INT_TASK_STATUS))
{
return sch_rec->task_status;
}
else if(0 == strcmp(field,CAL_VALUE_INT_DELETED))
{
- return sch_rec->deleted;
+ return 0;
}
else if(0 == strcmp(field,CAL_VALUE_INT_PROGRESS))
{
return sch_rec->progress;
}
+ else if(0 == strcmp(field, CALS_VALUE_INT_DTSTART_TYPE))
+ return sch_rec->dtstart_type;
+ else if(0 == strcmp(field, CALS_VALUE_INT_DTSTART_YEAR))
+ return sch_rec->dtstart_year;
+ else if(0 == strcmp(field, CALS_VALUE_INT_DTSTART_MONTH))
+ return sch_rec->dtstart_month;
+ else if(0 == strcmp(field, CALS_VALUE_INT_DTSTART_MDAY))
+ return sch_rec->dtstart_mday;
+ else if(0 == strcmp(field, CALS_VALUE_INT_DTEND_TYPE))
+ return sch_rec->dtend_type;
+ else if(0 == strcmp(field, CALS_VALUE_INT_DTEND_YEAR))
+ return sch_rec->dtend_year;
+ else if(0 == strcmp(field, CALS_VALUE_INT_DTEND_MONTH))
+ return sch_rec->dtend_month;
+ else if(0 == strcmp(field, CALS_VALUE_INT_DTEND_MDAY))
+ return sch_rec->dtend_mday;
+ else if(0 == strcmp(field, CALS_VALUE_INT_RRULE_FREQ))
+ return sch_rec->freq;
+ else if(0 == strcmp(field, CALS_VALUE_INT_RRULE_ID))
+ return sch_rec->rrule_id;
+ else if(0 == strcmp(field, CALS_VALUE_INT_RRULE_RANGE_TYPE))
+ return sch_rec->range_type;
+ else if(0 == strcmp(field, CALS_VALUE_INT_RRULE_UNTIL_TYPE))
+ return sch_rec->until_type;
+ else if(0 == strcmp(field, CALS_VALUE_INT_RRULE_UNTIL_YEAR))
+ return sch_rec->until_year;
+ else if(0 == strcmp(field, CALS_VALUE_INT_RRULE_UNTIL_MONTH))
+ return sch_rec->until_month;
+ else if(0 == strcmp(field, CALS_VALUE_INT_RRULE_UNTIL_MDAY))
+ return sch_rec->until_mday;
+ else if(0 == strcmp(field, CALS_VALUE_INT_RRULE_COUNT))
+ return sch_rec->count;
+ else if(0 == strcmp(field, CALS_VALUE_INT_RRULE_INTERVAL))
+ return sch_rec->interval;
+ else if(0 == strcmp(field, CALS_VALUE_INT_RRULE_WKST))
+ return sch_rec->wkst;
+ /* deprecated start >>>>>>>>>>>>>>>>>>>>>>>>>*/
+ else if(0 == strcmp(field, "index"))
+ {
+ return sch_rec->index;
+ }
+ else if(0 == strcmp(field, CAL_VALUE_INT_CAL_TYPE))
+ {
+ return sch_rec->cal_type;
+ }
else
{
ERR("Can not find the field(%s)",field);
}
break;
- default:
- break;
-
- }
-
- return 0;
-}
-
-API time_t calendar_svc_struct_get_time (cal_struct *event, const char *field, int timezone_flag)
-{
- time_t ret_time = 0;
- cal_sch_full_t * sch_rec = NULL;
-
- retv_if(NULL == event, CAL_ERR_ARG_NULL);
- retv_if(NULL == field, CAL_ERR_ARG_NULL);
- retv_if(NULL == event->user_data, CAL_ERR_ARG_INVALID);
-
- switch(event->event_type)
- {
- case CAL_STRUCT_TYPE_SCHEDULE:
- case CAL_STRUCT_TYPE_TODO:
- sch_rec = (cal_sch_full_t*)event->user_data;
- if(sch_rec==NULL)
- {
- return CAL_ERR_ARG_NULL;
- }
-
- if(0 == strcmp(field,CAL_VALUE_GMT_START_DATE_TIME))
- {
- ret_time = cals_mktime(&(sch_rec->start_date_time));
- }
- else if(0 == strcmp(field,CAL_VALUE_GMT_END_DATE_TIME))
- {
- ret_time = cals_mktime(&(sch_rec->end_date_time));
- }
- else if(0 == strcmp(field,CAL_VALUE_GMT_REPEAT_END_DATE))
- {
- ret_time = cals_mktime(&(sch_rec->repeat_end_date));
- }
- else if(0 == strcmp(field,CAL_VALUE_GMT_LAST_MODIFIED_TIME))
+ case CAL_STRUCT_TYPE_UPDATED_LIST:
+ update = event->user_data;
+ if(0 == strcmp(field, CALS_STRUCT_UPDATED_INT_TYPE))
{
- ret_time = cals_mktime(&(sch_rec->last_modified_time));
+ return update->type;
}
- else if(0 == strcmp(field,CAL_VALUE_GMT_CREATED_DATE_TIME))
+ else if(0 == strcmp(field, CALS_STRUCT_UPDATED_INT_ID))
{
- ret_time = cals_mktime(&(sch_rec->created_date_time));
+ return update->id;
}
- else if(0 == strcmp(field,CAL_VALUE_GMT_COMPLETED_DATE_TIME))
+ else if(0 == strcmp(field, CALS_STRUCT_UPDATED_INT_VERSION))
{
- ret_time = cals_mktime(&(sch_rec->completed_date_time));
+ return update->ver;
}
else
{
+ ERR("Can not find the field(%s)",field);
}
break;
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_ONOFF:
+ nof = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_ONOFF_INT_EVENTID))
+ return nof->index;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_ONOFF_INT_DTSTART_TYPE))
+ return nof->dtstart_type;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_ONOFF_INT_DTEND_TYPE))
+ return nof->dtstart_type;
+ else
+ ERR("Can't find field(%s)", field);
+
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_ALLDAY_ONOFF:
+ aof = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_EVENTID))
+ return aof->index;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTSTART_TYPE))
+ return nof->dtstart_type;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTSTART_YEAR))
+ return aof->dtstart_year;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTSTART_MONTH))
+ return aof->dtstart_month;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTSTART_MDAY))
+ return aof->dtstart_mday;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTEND_TYPE))
+ return nof->dtend_type;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTEND_YEAR))
+ return aof->dtend_year;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTEND_MONTH))
+ return aof->dtend_month;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTEND_MDAY))
+ return aof->dtend_mday;
+ else
+ ERR("Can't find field(%s)", field);
- case CAL_STRUCT_TYPE_CALENDAR:
- return 0;
- break;
-
- default:
- return 0;
break;
- }
-
- if(timezone_flag != CAL_TZ_FLAG_GMT && sch_rec->all_day_event==false)
- {
- time_t temp = 0;
- calendar_svc_util_gmt_to_local(ret_time,&temp);
- ret_time = temp;
- }
-
- return ret_time;
-}
-
-API struct tm* calendar_svc_struct_get_tm(cal_struct* record, const char *field, int timezone_flag)
-{
- struct tm* ret_tm = 0;
- cal_sch_full_t * sch_rec = NULL;
-
- retv_if(NULL == record, NULL);
- retv_if(NULL == field, NULL);
- retv_if(NULL == record->user_data, NULL);
-
- switch(record->event_type)
- {
- case CAL_STRUCT_TYPE_SCHEDULE:
- case CAL_STRUCT_TYPE_TODO:
- sch_rec = (cal_sch_full_t*)record->user_data;
- if(sch_rec==NULL)
- {
- return NULL;
- }
- if(0 == strcmp(field,CAL_VALUE_GMT_START_DATE_TIME))
- {
- ret_tm = &(sch_rec->start_date_time);
- }
- else if(0 == strcmp(field,CAL_VALUE_GMT_END_DATE_TIME))
- {
- ret_tm = &(sch_rec->end_date_time);
- }
- else if(0 == strcmp(field,CAL_VALUE_GMT_REPEAT_END_DATE))
- {
- ret_tm = &(sch_rec->repeat_end_date);
- }
- else if(0 == strcmp(field,CAL_VALUE_GMT_LAST_MODIFIED_TIME))
- {
- ret_tm = &(sch_rec->last_modified_time);
- }
- else if(0 == strcmp(field,CAL_VALUE_GMT_CREATED_DATE_TIME))
- {
- ret_tm = &(sch_rec->created_date_time);
- }
- else if(0 == strcmp(field,CAL_VALUE_GMT_COMPLETED_DATE_TIME))
- {
- ret_tm = &(sch_rec->completed_date_time);
- }
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_BASIC:
+ nbs = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_BASIC_INT_EVENTID))
+ return nbs->index;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_BASIC_INT_DTSTART_TYPE))
+ return nbs->dtstart_type;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_BASIC_INT_DTEND_TYPE))
+ return nbs->dtstart_type;
else
- {
- }
- break;
-
- case CAL_STRUCT_TYPE_CALENDAR:
- return NULL;
+ ERR("Can't find field(%s)", field);
+
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_ALLDAY_BASIC:
+ abs = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_EVENTID))
+ return abs->index;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTSTART_TYPE))
+ return abs->dtstart_type;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTSTART_YEAR))
+ return abs->dtstart_year;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTSTART_MONTH))
+ return abs->dtstart_month;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTSTART_MDAY))
+ return abs->dtstart_mday;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTEND_TYPE))
+ return abs->dtend_type;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTEND_YEAR))
+ return abs->dtend_year;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTEND_MONTH))
+ return abs->dtend_month;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTEND_MDAY))
+ return abs->dtend_mday;
+ else
+ ERR("Can't find field(%s)", field);
+
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_OSP:
+ nosp = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_INT_EVENTID))
+ return nosp->index;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_INT_DTSTART_TYPE))
+ return nosp->dtstart_type;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_INT_DTEND_TYPE))
+ return nosp->dtend_type;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_INT_CALENDAR_ID))
+ return nosp->calendar_id;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_INT_BUSY_STATUS))
+ return nosp->busy_status;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_INT_STATUS))
+ return nosp->meeting_status;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_INT_PRIORITY))
+ return nosp->priority;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_INT_VISIBILITY))
+ return nosp->sensitivity;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_INT_IS_RECURRING))
+ return nosp->rrule_id;
+ else
+ ERR("Can't find field(%s)", field);
+
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_ALLDAY_OSP:
+ aosp = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_EVENTID))
+ return aosp->index;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTSTART_TYPE))
+ return aosp->dtstart_type;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTSTART_YEAR))
+ return aosp->dtstart_year;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTSTART_MONTH))
+ return aosp->dtstart_month;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTSTART_MDAY))
+ return aosp->dtstart_mday;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTEND_TYPE))
+ return aosp->dtend_type;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTEND_YEAR))
+ return aosp->dtend_year;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTEND_MONTH))
+ return aosp->dtend_month;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTEND_MDAY))
+ return aosp->dtend_mday;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_CALENDAR_ID))
+ return aosp->calendar_id;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_BUSY_STATUS))
+ return aosp->busy_status;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_STATUS))
+ return aosp->meeting_status;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_PRIORITY))
+ return aosp->priority;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_VISIBILITY))
+ return aosp->sensitivity;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_IS_RECURRING))
+ return aosp->rrule_id;
+ else
+ ERR("Can't find field(%s)", field);
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_LOCATION:
+ nosl = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_INT_EVENTID))
+ return nosl->index;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_INT_DTSTART_TYPE))
+ return nosl->dtstart_type;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_INT_DTEND_TYPE))
+ return nosl->dtend_type;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_INT_CALENDAR_ID))
+ return nosl->calendar_id;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_INT_BUSY_STATUS))
+ return nosl->busy_status;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_INT_STATUS))
+ return nosl->meeting_status;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_INT_PRIORITY))
+ return nosl->priority;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_INT_VISIBILITY))
+ return nosl->sensitivity;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_INT_IS_RECURRING))
+ return nosl->rrule_id;
+ else
+ ERR("Can't find field(%s)", field);
+
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_ALLDAY_LOCATION:
+ aosl = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_EVENTID))
+ return aosl->index;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTSTART_TYPE))
+ return aosl->dtstart_type;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTSTART_YEAR))
+ return aosl->dtstart_year;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTSTART_MONTH))
+ return aosl->dtstart_month;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTSTART_MDAY))
+ return aosl->dtstart_mday;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTEND_TYPE))
+ return aosl->dtend_type;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTEND_YEAR))
+ return aosl->dtend_year;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTEND_MONTH))
+ return aosl->dtend_month;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTEND_MDAY))
+ return aosl->dtend_mday;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_CALENDAR_ID))
+ return aosl->calendar_id;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_BUSY_STATUS))
+ return aosl->busy_status;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_STATUS))
+ return aosl->meeting_status;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_PRIORITY))
+ return aosl->priority;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_VISIBILITY))
+ return aosl->sensitivity;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_IS_RECURRING))
+ return aosl->rrule_id;
+ else
+ ERR("Can't find field(%s)", field);
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_ALARM:
+ nosa = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_ALARM_INT_EVENTID))
+ return nosa->index;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_ALARM_INT_DTSTART_TYPE))
+ return nosa->dtstart_type;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_ALARM_INT_DTEND_TYPE))
+ return nosa->dtend_type;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_ALARM_INT_CALENDAR_ID))
+ return nosa->calendar_id;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_ALARM_INT_ALARM_ID))
+ return nosa->alarm_id;
+ else
+ ERR("Can't find field(%s)", field);
break;
default:
- return NULL;
break;
- }
-
-
- if(timezone_flag != CAL_TZ_FLAG_GMT && NULL != ret_tm && sch_rec->all_day_event==false)
- {
- time_t temp = 0;
- time_t input_tt = 0;
- input_tt = cals_mktime(ret_tm);
-
- calendar_svc_util_gmt_to_local(input_tt,&temp);
- input_tt = temp;
- return cals_tmtime(&input_tt);
}
- //TMDUMP(*ret_tm);
- return ret_tm;
+ return 0;
}
-
API int calendar_svc_struct_set_int (cal_struct *event, const char *field, int intval)
{
cal_sch_full_t * sch_rec = NULL;
calendar_t * cal_rec = NULL;
cal_timezone_t *tz_rec = NULL;
+ cals_struct_period_normal_onoff *nof = NULL;
+ cals_struct_period_allday_onoff *aof = NULL;
+ cals_struct_period_normal_basic *nbs = NULL;
+ cals_struct_period_allday_basic *abs = NULL;
+ cals_struct_period_normal_osp *nosp = NULL;
+ cals_struct_period_allday_osp *aosp = NULL;
+ cals_struct_period_normal_location *nosl = NULL;
+ cals_struct_period_allday_location *aosl = NULL;
+ cals_struct_period_normal_alarm *nosa = NULL;
retv_if(NULL == event, CAL_ERR_ARG_NULL);
retv_if(NULL == field, CAL_ERR_ARG_NULL);
{
sch_rec->account_id = intval;
}
- else if(0 == strcmp(field, CAL_VALUE_INT_CATEGORY))
- {
- sch_rec->sch_category = intval;
- }
- else if(0 == strcmp(field, CAL_VALUE_INT_ALL_DAY_EVENT))
- {
- sch_rec->all_day_event = !!(intval);
- }
- else if(0 == strcmp(field,CAL_VALUE_INT_REPEAT_TERM))
- {
- sch_rec->repeat_term = intval;
- }
- else if(0 == strcmp(field,CAL_VALUE_INT_REPEAT_INTERVAL))
- {
- sch_rec->repeat_interval = intval;
- }
- else if(0 == strcmp(field,CAL_VALUE_INT_REPEAT_UNTIL_TYPE))
- {
- sch_rec->repeat_until_type = intval;
- }
- else if(0 == strcmp(field,CAL_VALUE_INT_REPEAT_OCCURRENCES))
- {
- sch_rec->repeat_occurrences = intval;
- sch_rec->repeat_end_date.tm_year = BASE_TIME_YEAR;
- }
- else if(0 == strcmp(field,CAL_VALUE_INT_DAY_DATE))
- {
- sch_rec->day_date = intval;
- }
else if(0 == strcmp(field,CAL_VALUE_INT_FILE_ID))
{
sch_rec->file_id = intval;
{
sch_rec->dst = intval;
}
- else if(0 == strcmp(field,CAL_VALUE_INT_SUN_MOON))
- {
- sch_rec->sun_moon = intval;
- }
- else if(0 == strcmp(field,CAL_VALUE_INT_WEEK_START))
- {
- sch_rec->week_start = intval;
- }
else if(0 == strcmp(field, CAL_VALUE_INT_ORIGINAL_EVENT_ID))
{
sch_rec->original_event_id = intval;
{
sch_rec->progress = intval;
}
+ else if(0 == strcmp(field, CALS_VALUE_INT_DTSTART_TYPE))
+ sch_rec->dtstart_type = intval;
+ else if(0 == strcmp(field, CALS_VALUE_INT_DTSTART_YEAR))
+ sch_rec->dtstart_year = intval;
+ else if(0 == strcmp(field, CALS_VALUE_INT_DTSTART_MONTH))
+ sch_rec->dtstart_month = intval;
+ else if(0 == strcmp(field, CALS_VALUE_INT_DTSTART_MDAY))
+ sch_rec->dtstart_mday = intval;
+ else if(0 == strcmp(field, CALS_VALUE_INT_DTEND_TYPE))
+ sch_rec->dtend_type = intval;
+ else if(0 == strcmp(field, CALS_VALUE_INT_DTEND_YEAR))
+ sch_rec->dtend_year = intval;
+ else if(0 == strcmp(field, CALS_VALUE_INT_DTEND_MONTH))
+ sch_rec->dtend_month = intval;
+ else if(0 == strcmp(field, CALS_VALUE_INT_DTEND_MDAY))
+ sch_rec->dtend_mday = intval;
+ else if(0 == strcmp(field, CALS_VALUE_INT_RRULE_FREQ))
+ sch_rec->freq = intval;
+ else if(0 == strcmp(field, CALS_VALUE_INT_RRULE_RANGE_TYPE))
+ sch_rec->range_type = intval;
+ else if(0 == strcmp(field, CALS_VALUE_INT_RRULE_UNTIL_TYPE))
+ sch_rec->until_type = intval;
+ else if(0 == strcmp(field, CALS_VALUE_INT_RRULE_UNTIL_YEAR))
+ sch_rec->until_year = intval;
+ else if(0 == strcmp(field, CALS_VALUE_INT_RRULE_UNTIL_MONTH))
+ sch_rec->until_month = intval;
+ else if(0 == strcmp(field, CALS_VALUE_INT_RRULE_UNTIL_MDAY))
+ sch_rec->until_mday = intval;
+ else if(0 == strcmp(field, CALS_VALUE_INT_RRULE_COUNT))
+ sch_rec->count = intval;
+ else if(0 == strcmp(field, CALS_VALUE_INT_RRULE_INTERVAL))
+ sch_rec->interval = intval;
+ else if(0 == strcmp(field, CALS_VALUE_INT_RRULE_WKST))
+ sch_rec->wkst = intval;
+ /* deprecated start >>>>>>>>>>>>>>>>>>> */
+ else if(0 == strcmp(field,"index"))
+ {
+ sch_rec->index = intval;
+ }
+ /* <<<<<<<<<<<<<<<<<<<< deprecated end */
else
{
ERR("Invalid field(%d, %s)", event->event_type, field);
return CAL_ERR_ARG_INVALID;
}
break;
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_ONOFF:
+ nof = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_ONOFF_INT_EVENTID))
+ nof->index = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_ONOFF_INT_DTSTART_TYPE))
+ nof->dtstart_type = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_ONOFF_INT_DTEND_TYPE))
+ nof->dtend_type = intval;
+ else {
+ ERR("Invalid field(%d, %s)", event->event_type, field);
+ return CAL_ERR_ARG_INVALID;
+ }
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_ALLDAY_ONOFF:
+ aof = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_EVENTID))
+ aof->index = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTSTART_TYPE))
+ aof->dtstart_type = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTSTART_YEAR))
+ aof->dtstart_year = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTSTART_MONTH))
+ aof->dtstart_month = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTSTART_MDAY))
+ aof->dtstart_mday = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTEND_TYPE))
+ aof->dtend_type = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTEND_YEAR))
+ aof->dtend_year = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTEND_MONTH))
+ aof->dtend_month = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTEND_MDAY))
+ aof->dtend_mday = intval;
+ else {
+ ERR("Invalid field(%d, %s)", event->event_type, field);
+ return CAL_ERR_ARG_INVALID;
+ }
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_BASIC:
+ nbs = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_BASIC_INT_EVENTID))
+ nbs->index = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_BASIC_INT_DTSTART_TYPE))
+ nbs->dtstart_type = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_BASIC_INT_DTEND_TYPE))
+ nbs->dtend_type = intval;
+ else {
+ ERR("Invalid field(%d, %s)", event->event_type, field);
+ return CAL_ERR_ARG_INVALID;
+ }
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_ALLDAY_BASIC:
+ abs = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_EVENTID))
+ abs->index = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTSTART_TYPE))
+ abs->dtstart_type = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTSTART_YEAR))
+ abs->dtstart_year = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTSTART_MONTH))
+ abs->dtstart_month = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTSTART_MDAY))
+ abs->dtstart_mday = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTEND_TYPE))
+ abs->dtend_type = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTEND_YEAR))
+ abs->dtend_year = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTEND_MONTH))
+ abs->dtend_month = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTEND_MDAY))
+ abs->dtend_mday = intval;
+ else {
+ ERR("Invalid field(%d, %s)", event->event_type, field);
+ return CAL_ERR_ARG_INVALID;
+ }
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_OSP:
+ nosp = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_INT_EVENTID))
+ nosp->index = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_INT_DTSTART_TYPE))
+ nosp->dtstart_type = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_INT_DTEND_TYPE))
+ nosp->dtend_type = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_INT_CALENDAR_ID))
+ nosp->calendar_id = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_INT_BUSY_STATUS))
+ nosp->busy_status = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_INT_STATUS))
+ nosp->meeting_status = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_INT_PRIORITY))
+ nosp->priority = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_INT_VISIBILITY))
+ nosp->sensitivity = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_INT_IS_RECURRING))
+ nosp->rrule_id = intval;
+ else {
+ ERR("Invalid field(%d, %s)", event->event_type, field);
+ return CAL_ERR_ARG_INVALID;
+ }
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_ALLDAY_OSP:
+ aosp = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_EVENTID))
+ aosp->index = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTSTART_TYPE))
+ aosp->dtstart_type = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTSTART_YEAR))
+ aosp->dtstart_year = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTSTART_MONTH))
+ aosp->dtstart_month = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTSTART_MDAY))
+ aosp->dtstart_mday = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTEND_TYPE))
+ aosp->dtend_type = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTEND_YEAR))
+ aosp->dtend_year = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTEND_MONTH))
+ aosp->dtend_month = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTEND_MDAY))
+ aosp->dtend_mday = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_CALENDAR_ID))
+ aosp->calendar_id = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_BUSY_STATUS))
+ aosp->busy_status = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_STATUS))
+ aosp->meeting_status = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_PRIORITY))
+ aosp->priority = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_VISIBILITY))
+ aosp->sensitivity = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_INT_IS_RECURRING))
+ aosp->rrule_id = intval;
+ else {
+ ERR("Invalid field(%d, %s)", event->event_type, field);
+ return CAL_ERR_ARG_INVALID;
+ }
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_LOCATION:
+ nosl = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_INT_EVENTID))
+ nosl->index = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_INT_DTSTART_TYPE))
+ nosl->dtstart_type = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_INT_DTEND_TYPE))
+ nosl->dtend_type = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_INT_CALENDAR_ID))
+ nosl->calendar_id = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_INT_BUSY_STATUS))
+ nosl->busy_status = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_INT_STATUS))
+ nosl->meeting_status = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_INT_PRIORITY))
+ nosl->priority = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_INT_VISIBILITY))
+ nosl->sensitivity = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_INT_IS_RECURRING))
+ nosl->rrule_id = intval;
+ else {
+ ERR("Invalid field(%d, %s)", event->event_type, field);
+ return CAL_ERR_ARG_INVALID;
+ }
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_ALLDAY_LOCATION:
+ aosl = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_EVENTID))
+ aosl->index = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTSTART_TYPE))
+ aosl->dtstart_type = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTSTART_YEAR))
+ aosl->dtstart_year = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTSTART_MONTH))
+ aosl->dtstart_month = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTSTART_MDAY))
+ aosl->dtstart_mday = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTEND_TYPE))
+ aosl->dtend_type = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTEND_YEAR))
+ aosl->dtend_year = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTEND_MONTH))
+ aosl->dtend_month = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_DTEND_MDAY))
+ aosl->dtend_mday = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_CALENDAR_ID))
+ aosl->calendar_id = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_BUSY_STATUS))
+ aosl->busy_status = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_STATUS))
+ aosl->meeting_status = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_PRIORITY))
+ aosl->priority = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_VISIBILITY))
+ aosl->sensitivity = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_INT_IS_RECURRING))
+ aosl->rrule_id = intval;
+ else {
+ ERR("Invalid field(%d, %s)", event->event_type, field);
+ return CAL_ERR_ARG_INVALID;
+ }
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_ALARM:
+ nosa = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_ALARM_INT_EVENTID))
+ nosa->index = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_ALARM_INT_DTSTART_TYPE))
+ nosa->dtstart_type = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_ALARM_INT_DTEND_TYPE))
+ nosa->dtend_type = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_ALARM_INT_CALENDAR_ID))
+ nosa->calendar_id = intval;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_ALARM_INT_ALARM_ID))
+ nosa->alarm_id = intval;
+ else {
+ ERR("Invalid field(%d, %s)", event->event_type, field);
+ return CAL_ERR_ARG_INVALID;
+ }
+
default:
ERR("Invalid field(%d, %s)", event->event_type, field);
return CAL_ERR_ARG_INVALID;
cal_sch_full_t *sch_rec = NULL;
calendar_t *cal_rec = NULL;
cal_timezone_t *tz_rec = NULL;
- int str_len = strlen(strval)+1;
+ cals_struct_period_normal_basic *nbs = NULL;
+ cals_struct_period_allday_basic *abs = NULL;
+ cals_struct_period_normal_osp *nosp = NULL;
+ cals_struct_period_allday_osp *aosp = NULL;
+ cals_struct_period_normal_location *nosl = NULL;
+ cals_struct_period_allday_location *aosl = NULL;
+
+ retvm_if(strval == NULL, CAL_ERR_FAIL, "Invalid argument: value is NULL");
switch(event->event_type)
{
if(0 == strcmp(field,CAL_VALUE_TXT_SUMMARY))
{
CAL_FREE(sch_rec->summary);
-
- sch_rec->summary = (char*)malloc(str_len);
- retex_if(NULL == sch_rec->summary,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(sch_rec->summary,0x00,str_len);
-
- strcpy(sch_rec->summary,strval);
+ sch_rec->summary = strdup(strval);
}
else if(0 == strcmp(field,CAL_VALUE_TXT_DESCRIPTION))
{
CAL_FREE(sch_rec->description);
-
- sch_rec->description = (char*)malloc(str_len);
- retex_if(NULL == sch_rec->description,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(sch_rec->description,0x00,str_len);
-
- strcpy(sch_rec->description,strval);
+ sch_rec->description = strdup(strval);
}
else if(0 == strcmp(field, CAL_VALUE_TXT_LOCATION))
{
CAL_FREE(sch_rec->location);
-
-
- sch_rec->location = (char*)malloc(str_len);
- retex_if(NULL == sch_rec->location,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(sch_rec->location,0x00,str_len);
-
- strcpy(sch_rec->location,strval);
+ sch_rec->location = strdup(strval);
}
- else if(0 == strcmp(field,CAL_VALUE_TXT_WEEK_FLAG))
+ else if(0 == strcmp(field, CAL_VALUE_TXT_CATEGORIES))
{
- CAL_FREE(sch_rec->week_flag);
-
- sch_rec->week_flag = (char*)malloc(str_len);
- retex_if(NULL == sch_rec->week_flag,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(sch_rec->week_flag,0x00,str_len);
-
- strcpy(sch_rec->week_flag,strval);
+ CAL_FREE(sch_rec->categories);
+ sch_rec->categories = strdup(strval);
+ }
+ else if(0 == strcmp(field, CAL_VALUE_TXT_EXDATE))
+ {
+ CAL_FREE(sch_rec->exdate);
+ sch_rec->exdate = strdup(strval);
}
else if(0 == strcmp(field,CAL_VALUE_TXT_UID))
{
CAL_FREE(sch_rec->uid);
-
- sch_rec->uid = (char*)malloc(str_len);
- retex_if(NULL == sch_rec->uid,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(sch_rec->uid,0x00,str_len);
-
- strcpy(sch_rec->uid,strval);
+ sch_rec->uid = strdup(strval);
}
else if(0 == strcmp(field,CAL_VALUE_TXT_ORGANIZER_NAME))
{
CAL_FREE(sch_rec->organizer_name);
-
-
- sch_rec->organizer_name = (char*)malloc(str_len);
- retex_if(NULL == sch_rec->organizer_name,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(sch_rec->organizer_name,0x00,str_len);
-
- strcpy(sch_rec->organizer_name,strval);
+ sch_rec->organizer_name = strdup(strval);
}
else if(0 == strcmp(field,CAL_VALUE_TXT_ORGANIZER_EMAIL ))
{
CAL_FREE(sch_rec->organizer_email);
-
- sch_rec->organizer_email = (char*)malloc(str_len);
- retex_if(NULL == sch_rec->organizer_email,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(sch_rec->organizer_email,0x00,str_len);
-
- strcpy(sch_rec->organizer_email,strval);
+ sch_rec->organizer_email = strdup(strval);
}
else if(0 == strcmp(field,CAL_VALUE_TXT_GCAL_ID ))
{
CAL_FREE(sch_rec->gcal_id);
-
-
- sch_rec->gcal_id = (char*)malloc(str_len);
- retex_if(NULL == sch_rec->gcal_id,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(sch_rec->gcal_id,0x00,str_len);
-
- strcpy(sch_rec->gcal_id,strval);
+ sch_rec->gcal_id = strdup(strval);
}
else if(0 == strcmp(field,CAL_VALUE_TXT_UPDATED))
{
CAL_FREE(sch_rec->updated);
-
-
- sch_rec->updated = (char*)malloc(str_len);
- retex_if(NULL == sch_rec->updated,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(sch_rec->updated,0x00,str_len);
-
- strcpy(sch_rec->updated,strval);
+ sch_rec->updated = strdup(strval);
}
else if(0 == strcmp(field,CAL_VALUE_TXT_LOCATION_SUMMARY))
{
CAL_FREE(sch_rec->location_summary);
-
-
- sch_rec->location_summary = (char*)malloc(str_len);
- retex_if(NULL == sch_rec->location_summary,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(sch_rec->location_summary,0x00,str_len);
-
- strcpy(sch_rec->location_summary,strval);
+ sch_rec->location_summary = strdup(strval);
}
else if(0 == strcmp(field, CAL_VALUE_TXT_ETAG))
{
CAL_FREE(sch_rec->etag);
-
- sch_rec->etag = (char*)malloc(str_len);
- retex_if(NULL == sch_rec->etag,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(sch_rec->etag,0x00,str_len);
-
- strcpy(sch_rec->etag,strval);
+ sch_rec->etag = strdup(strval);
}
else if(0 == strcmp(field,CAL_VALUE_TXT_EDIT_URL))
{
CAL_FREE(sch_rec->edit_uri);
-
- sch_rec->edit_uri = (char*)malloc(str_len);
- retex_if(NULL == sch_rec->edit_uri,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(sch_rec->edit_uri,0x00,str_len);
-
- strcpy(sch_rec->edit_uri,strval);
+ sch_rec->edit_uri = strdup(strval);
}
else if(0 == strcmp(field,CAL_VALUE_TXT_GEDERID))
{
CAL_FREE(sch_rec->gevent_id);
-
- sch_rec->gevent_id = (char*)malloc(str_len);
- retex_if(NULL == sch_rec->gevent_id,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(sch_rec->gevent_id,0x00,str_len);
-
- strcpy(sch_rec->gevent_id,strval);
+ sch_rec->gevent_id = strdup(strval);
}
- else if(0 == strcmp(field,CAL_VALUE_TXT_TZ_NAME))
+ else if(0 == strcmp(field, CALS_VALUE_TXT_DTSTART_TZID))
{
- CAL_FREE(sch_rec->tz_name);
-
-
- sch_rec->tz_name = (char*)malloc(str_len);
- retex_if(NULL == sch_rec->tz_name,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(sch_rec->tz_name,0x00,str_len);
-
- strcpy(sch_rec->tz_name,strval);
+ CAL_FREE(sch_rec->dtstart_tzid);
+ sch_rec->dtstart_tzid = strdup(strval);
}
- else if(0 == strcmp(field,CAL_VALUE_TXT_TZ_CITY_NAME))
+ else if(0 == strcmp(field, CALS_VALUE_TXT_DTEND_TZID))
{
- CAL_FREE(sch_rec->tz_city_name);
-
-
- sch_rec->tz_city_name = (char*)malloc(str_len);
- retex_if(NULL == sch_rec->tz_city_name,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(sch_rec->tz_city_name,0x00,str_len);
-
- strcpy(sch_rec->tz_city_name,strval);
+ CAL_FREE(sch_rec->dtend_tzid);
+ sch_rec->dtend_tzid = strdup(strval);
+ }
+ else if(0 == strcmp(field, CALS_VALUE_TXT_RRULE_BYSECOND))
+ {
+ CAL_FREE(sch_rec->bysecond);
+ sch_rec->bysecond = strdup(strval);
+ }
+ else if(0 == strcmp(field, CALS_VALUE_TXT_RRULE_BYMINUTE))
+ {
+ CAL_FREE(sch_rec->byminute);
+ sch_rec->byminute = strdup(strval);
+ }
+ else if(0 == strcmp(field, CALS_VALUE_TXT_RRULE_BYHOUR))
+ {
+ CAL_FREE(sch_rec->byhour);
+ sch_rec->byhour = strdup(strval);
+ }
+ else if(0 == strcmp(field, CALS_VALUE_TXT_RRULE_BYDAY))
+ {
+ CAL_FREE(sch_rec->byday);
+ sch_rec->byday = strdup(strval);
+ }
+ else if(0 == strcmp(field, CALS_VALUE_TXT_RRULE_BYMONTHDAY))
+ {
+ CAL_FREE(sch_rec->bymonthday);
+ sch_rec->bymonthday = strdup(strval);
+ }
+ else if(0 == strcmp(field, CALS_VALUE_TXT_RRULE_BYYEARDAY))
+ {
+ CAL_FREE(sch_rec->byyearday);
+ sch_rec->byyearday = strdup(strval);
+ }
+ else if(0 == strcmp(field, CALS_VALUE_TXT_RRULE_BYWEEKNO))
+ {
+ CAL_FREE(sch_rec->byweekno);
+ sch_rec->byweekno = strdup(strval);
+ }
+ else if(0 == strcmp(field, CALS_VALUE_TXT_RRULE_BYMONTH))
+ {
+ CAL_FREE(sch_rec->bymonth);
+ sch_rec->bymonth = strdup(strval);
+ }
+ else if(0 == strcmp(field, CALS_VALUE_TXT_RRULE_BYSETPOS))
+ {
+ CAL_FREE(sch_rec->bysetpos);
+ sch_rec->bysetpos = strdup(strval);
}
else
{
if(0 == strcmp(field,CAL_TABLE_TXT_CALENDAR_ID))
{
CAL_FREE(cal_rec->calendar_id);
-
- cal_rec->calendar_id = (char*)malloc(str_len);
- retex_if(NULL == cal_rec->calendar_id,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(cal_rec->calendar_id,0x00,str_len);
-
- strcpy(cal_rec->calendar_id,strval);
+ cal_rec->calendar_id = strdup(strval);
}
else if(0 == strcmp(field,CAL_TABLE_TXT_UID))
{
CAL_FREE(cal_rec->uid);
-
-
- cal_rec->uid = (char*)malloc(str_len);
- retex_if(NULL == cal_rec->uid,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(cal_rec->uid,0x00,str_len);
-
- strcpy(cal_rec->uid,strval);
+ cal_rec->uid = strdup(strval);
}
else if(0 == strcmp(field,CAL_TABLE_TXT_LINK))
{
CAL_FREE(cal_rec->link);
-
-
- cal_rec->link = (char*)malloc(str_len);
- retex_if(NULL == cal_rec->link,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(cal_rec->link,0x00,str_len);
-
- strcpy(cal_rec->link,strval);
+ cal_rec->link = strdup(strval);
}
else if(0 == strcmp(field,CAL_TABLE_TXT_NAME))
{
CAL_FREE(cal_rec->name);
-
-
- cal_rec->name = (char*)malloc(str_len);
- retex_if(NULL == cal_rec->name,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(cal_rec->name,0x00,str_len);
-
- strcpy(cal_rec->name,strval);
+ cal_rec->name = strdup(strval);
}
else if(0 == strcmp(field,CAL_TABLE_TXT_DESCRIPTION))
{
CAL_FREE(cal_rec->description);
-
-
- cal_rec->description = (char*)malloc(str_len);
- retex_if(NULL == cal_rec->description,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(cal_rec->description,0x00,str_len);
-
- strcpy(cal_rec->description,strval);
+ cal_rec->description = strdup(strval);
}
else if(0 == strcmp(field,CAL_TABLE_TXT_AUTHOR))
{
CAL_FREE(cal_rec->author);
-
- cal_rec->author = (char*)malloc(str_len);
- retex_if(NULL == cal_rec->author,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(cal_rec->author,0x00,str_len);
-
- strcpy(cal_rec->author,strval);
+ cal_rec->author = strdup(strval);
}
else if(0 == strcmp(field,CAL_TABLE_TXT_COLOR))
{
CAL_FREE(cal_rec->color);
-
-
- cal_rec->color = (char*)malloc(str_len);
- retex_if(NULL == cal_rec->color,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(cal_rec->color,0x00,str_len);
-
- strcpy(cal_rec->color,strval);
+ cal_rec->color = strdup(strval);
}
else if(0 == strcmp(field,CAL_TABLE_TXT_LOCATION))
{
CAL_FREE(cal_rec->location);
-
- cal_rec->location = (char*)malloc(str_len);
- retex_if(NULL == cal_rec->location,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(cal_rec->location,0x00,str_len);
-
- strcpy(cal_rec->location,strval);
+ cal_rec->location = strdup(strval);
}
else if(0 == strcmp(field,CAL_TABLE_TXT_TIME_ZONE_LABEL))
{
CAL_FREE(cal_rec->timezone_label);
-
- cal_rec->timezone_label = (char*)malloc(str_len);
- retex_if(NULL == cal_rec->timezone_label,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(cal_rec->timezone_label,0x00,str_len);
-
- strcpy(cal_rec->timezone_label,strval);
+ cal_rec->timezone_label = strdup(strval);
}
else if(0 == strcmp(field,CAL_TABLE_TXT_USER_LOCATION))
{
CAL_FREE(cal_rec->user_location);
-
-
- cal_rec->user_location = (char*)malloc(str_len);
- retex_if(NULL == cal_rec->user_location,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(cal_rec->user_location,0x00,str_len);
-
- strcpy(cal_rec->user_location,strval);
+ cal_rec->user_location = strdup(strval);
}
else if(0 == strcmp(field,CAL_TABLE_TXT_WEATHER))
{
CAL_FREE(cal_rec->weather);
-
-
- cal_rec->weather = (char*)malloc(str_len);
- retex_if(NULL == cal_rec->weather,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(cal_rec->weather,0x00,str_len);
-
- strcpy(cal_rec->weather,strval);
+ cal_rec->weather = strdup(strval);
}
else
{
if(0 == strcmp(field,CAL_TZ_VALUE_TXT_STD_NAME))
{
CAL_FREE(tz_rec->standard_name);
-
-
- tz_rec->standard_name = (char*)malloc(str_len);
- retex_if(NULL == tz_rec->standard_name,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(tz_rec->standard_name,0x00,str_len);
-
- strcpy(tz_rec->standard_name,strval);
+ tz_rec->standard_name = strdup(strval);
}
else if(0 == strcmp(field,CAL_TZ_VALUE_TXT_DST_NAME))
{
CAL_FREE(tz_rec->day_light_name);
-
- tz_rec->day_light_name = (char*)malloc(str_len);
- retex_if(NULL == tz_rec->day_light_name,,"[ERROR]calendar_svc_struct_set_str:Failed to malloc!\n");
- memset(tz_rec->day_light_name,0x00,str_len);
-
- strcpy(tz_rec->day_light_name,strval);
+ tz_rec->day_light_name = strdup(strval);
}
break;
- default:
- ERR("Unknown event type(%d)", event->event_type);
- return CAL_ERR_ARG_INVALID;
- }
-
- return CAL_SUCCESS;
-
-CATCH:
-
- return CAL_ERR_FAIL;
-
-}
-
-API int calendar_svc_struct_set_time (cal_struct *event, const char *field,int timezone_flag, time_t time)
-{
- cal_sch_full_t *sch_rec = NULL;
-
- retv_if(NULL == event, CAL_ERR_ARG_NULL);
- retv_if(NULL == field, CAL_ERR_ARG_NULL);
-
- if(timezone_flag != CAL_TZ_FLAG_GMT)
- {
- time_t temp = 0;
- calendar_svc_util_local_to_gmt(time,&temp);
- time = temp;
- }
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_ONOFF:
+ ERR("No field in CALS_LIST_PERIOD_NORMAL_ONOFF");
+ break;
- switch(event->event_type)
- {
- case CAL_STRUCT_TYPE_SCHEDULE:
- case CAL_STRUCT_TYPE_TODO:
+ case CALS_STRUCT_TYPE_PERIOD_ALLDAY_ONOFF:
+ ERR("No field in CALS_LIST_PERIOD_ALLDAY_ONOFF");
+ break;
- sch_rec = (cal_sch_full_t*)event->user_data;
- if(sch_rec==NULL)
- {
- return CAL_ERR_ARG_NULL;
- }
- if(0 == strcmp(field,CAL_VALUE_GMT_START_DATE_TIME))
- {
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime(&time),&(sch_rec->start_date_time));
- }
- else if(0 == strcmp(field,CAL_VALUE_GMT_END_DATE_TIME))
- {
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime(&time),&(sch_rec->end_date_time));
- }
- else if(0 == strcmp(field,CAL_VALUE_GMT_REPEAT_END_DATE))
- {
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime(&time),&(sch_rec->repeat_end_date));
- }
- else if(0 == strcmp(field,CAL_VALUE_GMT_LAST_MODIFIED_TIME))
- {
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime(&time),&(sch_rec->last_modified_time));
- }
- else if(0 == strcmp(field,CAL_VALUE_GMT_CREATED_DATE_TIME))
- {
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime(&time),&(sch_rec->created_date_time));
- }
- else if(0 == strcmp(field,CAL_VALUE_GMT_COMPLETED_DATE_TIME))
- {
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime(&time),&(sch_rec->completed_date_time));
- }
- else
- {
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_BASIC:
+ nbs = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_BASIC_TXT_SUMMARY)) {
+ CAL_FREE(nbs->summary);
+ nbs->summary = strdup(strval);
+ } else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_BASIC_TXT_LOCATION)) {
+ CAL_FREE(nbs->location);
+ nbs->location = strdup(strval);
+ }else {
+ ERR("Can not find the field!(%s)",field);
}
-
break;
- case CAL_STRUCT_TYPE_CALENDAR:
-
+ case CALS_STRUCT_TYPE_PERIOD_ALLDAY_BASIC:
+ abs = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_BASIC_TXT_SUMMARY)) {
+ CAL_FREE(abs->summary);
+ abs->summary = strdup(strval);
+ } else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_BASIC_TXT_LOCATION)) {
+ CAL_FREE(abs->location);
+ abs->location = strdup(strval);
+ }else {
+ ERR("Can not find the field!(%s)",field);
+ }
break;
- default:
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_OSP:
+ nosp = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_TXT_SUMMARY)) {
+ CAL_FREE(nosp->summary);
+ nosp->summary = strdup(strval);
+ } else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_TXT_LOCATION)) {
+ CAL_FREE(nosp->location);
+ nosp->location = strdup(strval);
+ } else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_TXT_DESCRIPTION)) {
+ CAL_FREE(nosp->description);
+ nosp->description = strdup(strval);
+ }else {
+ ERR("Can not find the field!(%s)",field);
+ }
break;
- }
-
- return CAL_SUCCESS;
-}
-
-
-API int calendar_svc_struct_set_tm(cal_struct* record, const char *field, int timezone_flag,struct tm* time)
-{
- cal_sch_full_t * sch_rec = NULL;
- struct tm input_tm ={0};
-
- retv_if(NULL == record, CAL_ERR_ARG_NULL);
- retv_if(NULL == field, CAL_ERR_ARG_NULL);
-
- if(timezone_flag != CAL_TZ_FLAG_GMT)
- {
- time_t temp = 0;
- time_t input_tt = 0;
-
- input_tt = cals_mktime(time);
- calendar_svc_util_local_to_gmt(input_tt,&temp);
- input_tt = temp;
- cals_tmtime_r(&input_tt,&input_tm);
- }
- else
- memcpy(&input_tm,time,sizeof(struct tm));
-
- switch(record->event_type)
- {
- case CAL_STRUCT_TYPE_SCHEDULE:
- case CAL_STRUCT_TYPE_TODO:
- sch_rec = (cal_sch_full_t*)record->user_data;
- if(sch_rec==NULL)
- {
- return CAL_ERR_ARG_NULL;
- }
- if(0 == strcmp(field,CAL_VALUE_GMT_START_DATE_TIME))
- {
- cal_db_service_copy_struct_tm(&input_tm,&(sch_rec->start_date_time));
- TMDUMP(input_tm);
- }
- else if(0 == strcmp(field,CAL_VALUE_GMT_END_DATE_TIME))
- {
- cal_db_service_copy_struct_tm(&input_tm,&(sch_rec->end_date_time));
- TMDUMP(input_tm);
- }
- else if(0 == strcmp(field,CAL_VALUE_GMT_REPEAT_END_DATE))
- {
- cal_db_service_copy_struct_tm(&input_tm,&(sch_rec->repeat_end_date));
- }
- else if(0 == strcmp(field,CAL_VALUE_GMT_LAST_MODIFIED_TIME))
- {
- cal_db_service_copy_struct_tm(&input_tm,&(sch_rec->last_modified_time));
- }
- else if(0 == strcmp(field,CAL_VALUE_GMT_CREATED_DATE_TIME))
- {
- cal_db_service_copy_struct_tm(&input_tm,&(sch_rec->created_date_time));
- }
- else if(0 == strcmp(field,CAL_VALUE_GMT_COMPLETED_DATE_TIME))
- {
- cal_db_service_copy_struct_tm(&input_tm,&(sch_rec->completed_date_time));
- }
- else
- {
+ case CALS_STRUCT_TYPE_PERIOD_ALLDAY_OSP:
+ nosp = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_TXT_SUMMARY)) {
+ CAL_FREE(aosp->summary);
+ aosp->summary = strdup(strval);
+ } else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_TXT_LOCATION)) {
+ CAL_FREE(aosp->location);
+ aosp->location = strdup(strval);
+ } else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_OSP_TXT_DESCRIPTION)) {
+ CAL_FREE(aosp->description);
+ aosp->description = strdup(strval);
+ } else {
+ ERR("Can not find the field!(%s)", field);
+ }
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_LOCATION:
+ nosl = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_TXT_SUMMARY)) {
+ CAL_FREE(nosp->summary);
+ nosl->summary = strdup(strval);
+ } else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_TXT_LOCATION)) {
+ CAL_FREE(nosp->location);
+ nosl->location = strdup(strval);
+ } else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_TXT_DESCRIPTION)) {
+ CAL_FREE(nosp->description);
+ nosl->description = strdup(strval);
+ }else {
+ ERR("Can not find the field!(%s)",field);
}
-
break;
- case CAL_STRUCT_TYPE_CALENDAR:
-
+ case CALS_STRUCT_TYPE_PERIOD_ALLDAY_LOCATION:
+ nosl = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_TXT_SUMMARY)) {
+ CAL_FREE(aosp->summary);
+ aosl->summary = strdup(strval);
+ } else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_TXT_LOCATION)) {
+ CAL_FREE(aosp->location);
+ aosl->location = strdup(strval);
+ } else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_TXT_DESCRIPTION)) {
+ CAL_FREE(aosp->description);
+ aosl->description = strdup(strval);
+ } else {
+ ERR("Can not find the field!(%s)", field);
+ }
break;
default:
- break;
+ ERR("Unknown event type(%d)", event->event_type);
+ return CAL_ERR_ARG_INVALID;
}
return CAL_SUCCESS;
-}
+CATCH:
+
+ return CAL_ERR_FAIL;
+
+}
API double calendar_svc_struct_get_double(cal_struct* record, const char *field)
{
double ret_val = 0.0;
cal_sch_full_t *sch_rec = NULL;
+ cals_struct_period_normal_location *nosl = NULL;
+ cals_struct_period_allday_location *aosl = NULL;
retv_if(NULL == record, 0.0);
retv_if(NULL == field, 0.0);
else
ERR("Unknown field(%s)", field);
break;
+
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_LOCATION:
+ nosl = record->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_DBL_LATITUDE))
+ ret_val = nosl->latitude;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_DBL_LONGITUDE))
+ ret_val = nosl->longitude;
+ else
+ ERR("Unknown field(%s)", field);
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_ALLDAY_LOCATION:
+ aosl = record->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_DBL_LATITUDE))
+ ret_val = aosl->latitude;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_DBL_LONGITUDE))
+ ret_val = aosl->longitude;
+ else
+ ERR("Unknown field(%s)", field);
+ break;
+
default:
ERR("Unknown event type(%d)", record->event_type);
break;
API int calendar_svc_struct_set_double(cal_struct* record, const char *field,double value)
{
cal_sch_full_t * sch_rec = NULL;
+ cals_struct_period_normal_location *nosl = NULL;
+ cals_struct_period_allday_location *aosl = NULL;
retv_if(NULL == record, CAL_ERR_ARG_NULL);
retv_if(NULL == field, CAL_ERR_ARG_NULL);
return CAL_ERR_ARG_INVALID;
}
break;
+
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_LOCATION:
+ nosl = record->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_DBL_LATITUDE))
+ nosl->latitude = value;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_DBL_LONGITUDE))
+ nosl->longitude = value;
+ break;
+
+ case CALS_STRUCT_TYPE_PERIOD_ALLDAY_LOCATION:
+ aosl = record->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_DBL_LATITUDE))
+ aosl->latitude = value;
+ else if (!strcmp(field, CALS_LIST_PERIOD_ALLDAY_LOCATION_DBL_LONGITUDE))
+ aosl->longitude = value;
+ else
+ ERR("Unknown field(%s)", field);
+ break;
+
default:
ERR("Unknown event type(%d)", record->event_type);
return CAL_ERR_ARG_INVALID;
switch(event->event_type) {
case CAL_STRUCT_TYPE_SCHEDULE:
sch_rec = (cal_sch_full_t*)event->user_data;
- if(0 == strcmp(field, CAL_VALUE_LST_MEETING_CATEGORY))
- *retlist = sch_rec->meeting_category;
- else if(0 == strcmp(field,CAL_VALUE_LST_ATTENDEE_LIST))
+ if(0 == strcmp(field,CAL_VALUE_LST_ATTENDEE_LIST))
*retlist = sch_rec->attendee_list;
- else if(0 == strcmp(field, CAL_VALUE_LST_EXCEPTION_DATE))
- *retlist = sch_rec->exception_date_list;
else if(0 == strcmp(field, CAL_VALUE_LST_ALARM))
*retlist = sch_rec->alarm_list;
else {
}
break;
case CAL_STRUCT_TYPE_TODO:
+ sch_rec = (cal_sch_full_t*)event->user_data;
+ if(0 == strcmp(field,CAL_VALUE_LST_ATTENDEE_LIST))
+ *retlist = sch_rec->attendee_list;
+ else if(0 == strcmp(field, CAL_VALUE_LST_ALARM))
+ *retlist = sch_rec->alarm_list;
+ else {
+ ERR("Unknown field(%s)", field);
+ return CAL_ERR_ARG_INVALID;
+ }
+ break;
case CAL_STRUCT_TYPE_CALENDAR:
default:
ERR("Unknown event type(%d)", event->event_type);
switch(event->event_type) {
case CAL_STRUCT_TYPE_SCHEDULE:
sch_rec = (cal_sch_full_t*)event->user_data;
- if(0 == strcmp(field,CAL_VALUE_LST_MEETING_CATEGORY))
+
+ if(0 == strcmp(field,CAL_VALUE_LST_ATTENDEE_LIST))
{
if(list == NULL)
- _cals_struct_remove_list(field,sch_rec->meeting_category);
+ _cals_struct_remove_list(field,sch_rec->attendee_list);
- sch_rec->meeting_category = list;
+ sch_rec->attendee_list = list;
}
- else if(0 == strcmp(field,CAL_VALUE_LST_ATTENDEE_LIST))
+ else if(0 == strcmp(field,CAL_VALUE_LST_ALARM))
{
if(list == NULL)
- _cals_struct_remove_list(field,sch_rec->attendee_list);
+ _cals_struct_remove_list(field,sch_rec->alarm_list);
- sch_rec->attendee_list = list;
+ sch_rec->alarm_list = list;
+ } else {
+ ERR("%s is invalid field for event type schedule");
+ return CAL_ERR_ARG_INVALID;
}
- else if(0 == strcmp(field,CAL_VALUE_LST_EXCEPTION_DATE))
+ break;
+
+ case CAL_STRUCT_TYPE_TODO:
+ sch_rec = (cal_sch_full_t*)event->user_data;
+
+ if(0 == strcmp(field,CAL_VALUE_LST_ATTENDEE_LIST))
{
if(list == NULL)
- _cals_struct_remove_list(field,sch_rec->exception_date_list);
+ _cals_struct_remove_list(field,sch_rec->attendee_list);
- sch_rec->exception_date_list = list;
+ sch_rec->attendee_list = list;
}
else if(0 == strcmp(field,CAL_VALUE_LST_ALARM))
{
_cals_struct_remove_list(field,sch_rec->alarm_list);
sch_rec->alarm_list = list;
+ } else {
+ ERR("%s is invalid field for todo type schedule");
+ return CAL_ERR_ARG_INVALID;
}
break;
case CAL_STRUCT_TYPE_CALENDAR:
- case CAL_STRUCT_TYPE_TODO:
default:
- break;
+ ERR("Invalid schedule type(%d)", event->event_type);
+ return CAL_ERR_ARG_INVALID;
}
return CAL_SUCCESS;
memset(value,0x00,sizeof(cal_value));
- if(0 == strcmp(CAL_VALUE_LST_MEETING_CATEGORY,filed))
- {
- value->v_type = CAL_EVENT_CATEGORY;
- value->user_data = (cal_category_info_t*)malloc(sizeof(cal_category_info_t));
- retex_if(NULL == value->user_data,,"[ERROR]calendar_svc_value_new:Fail to malloc!\n");
-
- memset(value->user_data,0,sizeof(cal_category_info_t));
- }
- else if(0 == strcmp(CAL_VALUE_LST_ATTENDEE_LIST,filed))
+ if(0 == strcmp(CAL_VALUE_LST_ATTENDEE_LIST,filed))
{
value->v_type = CAL_EVENT_PATICIPANT;
value->user_data = (cal_participant_info_t*)malloc(sizeof(cal_participant_info_t));
memset(value->user_data,0,sizeof(cal_participant_info_t));
}
- else if(0 == strcmp(CAL_VALUE_LST_EXCEPTION_DATE,filed))
- {
- value->v_type = CAL_EVENT_RECURRENCY;
- value->user_data = (cal_exception_info_t*)malloc(sizeof(cal_exception_info_t));
- retex_if(NULL == value->user_data,,"[ERROR]calendar_svc_value_new:Fail to malloc!\n");
-
- memset(value->user_data,0,sizeof(cal_exception_info_t));
- }
else if(0 == strcmp(CAL_VALUE_LST_ALARM,filed))
{
value->v_type = CAL_EVENT_ALARM;
return CAL_SUCCESS;
}
-static int calendar_svc_free_category(cal_category_info_t* value)
-{
- CALS_FN_CALL;
- if(NULL == value)
- {
- return CAL_SUCCESS;
- }
-
- CAL_FREE(value->category_name);
- CAL_FREE(value);
-
-
- return CAL_SUCCESS;
-}
-
-static int calendar_svc_free_exception_info(cal_exception_info_t* value)
-{
- CALS_FN_CALL;
-
- int error_code = 0;
-
- if(NULL == value)
- {
- return CAL_SUCCESS;
- }
-
- if(NULL != value->exception_record)
- {
- cal_db_service_free_full_record(value->exception_record,&error_code);
- free(value->exception_record);
- }
-
- CAL_FREE(value);
-
-
- return CAL_SUCCESS;
-}
-
-
static int calendar_svc_free_alarm_info(cal_alarm_info_t* value)
{
CALS_FN_CALL;
return CAL_SUCCESS;
}
-
-
API int calendar_svc_value_free (cal_value **value)
{
CALS_FN_CALL;
switch((*value)->v_type)
{
- case CAL_EVENT_CATEGORY:
- calendar_svc_free_category((cal_category_info_t*)(*value)->user_data);
- break;
-
case CAL_EVENT_PATICIPANT:
calendar_svc_free_participant((cal_participant_info_t*)(*value)->user_data);
break;
- case CAL_EVENT_RECURRENCY:
- calendar_svc_free_exception_info((cal_exception_info_t*)(*value)->user_data);
- break;
case CAL_EVENT_ALARM:
calendar_svc_free_alarm_info((cal_alarm_info_t*)(*value)->user_data);
break;
+
default:
break;
}
API int calendar_svc_value_set_int (cal_value *value, const char *field, int intval)
{
- //CALS_FN_CALL();
- retex_if(NULL == value || NULL == value->user_data || NULL == field,,"[ERROR]calendar_svc_value_free:Invalid parameter!\n");
-
- cal_category_info_t *category = NULL;
cal_participant_info_t *participant = NULL;
- cal_exception_info_t *exception = NULL;
cal_alarm_info_t *alarm_info = NULL;
+ if (!value || !value->user_data || !field || !*field) {
+ ERR("Invalid parameter");
+ return CAL_ERR_ARG_INVALID;
+ }
switch(value->v_type)
{
- case CAL_EVENT_CATEGORY:
-
- category = (cal_category_info_t*)value->user_data;
-
- if(0 == strcmp(field,CAL_VALUE_INT_MEETING_CATEGORY_DETAIL_ID))
- {
- category->event_id = intval;
- }
- else
- {
- }
- break;
-
case CAL_EVENT_PATICIPANT:
participant = (cal_participant_info_t*)value->user_data;
}
else
{
- }
- break;
- case CAL_EVENT_RECURRENCY:
- exception = (cal_exception_info_t*)value->user_data;
- if(0 == strcmp(field,CAL_VALUE_INT_EXCEPTION_DATE_ID))
- {
- exception->event_id = intval;
+ ERR("Invalid field (%s)", field);
+ return CAL_ERR_ARG_INVALID;
}
break;
case CAL_EVENT_ALARM:
{
alarm_info->alarm_id = intval;
}
+ else
+ {
+ ERR("Invalid field (%s)", field);
+ return CAL_ERR_ARG_INVALID;
+ }
+ break;
default:
- break;
+ ERR("Invalid value type (%d)", value->v_type);
+ return CAL_ERR_ARG_INVALID;
}
return CAL_SUCCESS;
+}
-CATCH:
+API int calendar_svc_value_set_lli(cal_value *value, const char *field, long long int llival)
+{
+ cal_alarm_info_t *alarm_info;
- return CAL_ERR_FAIL;
+ if (!field || !*field)
+ return CAL_ERR_ARG_NULL;
+ switch(value->v_type)
+ {
+ case CAL_EVENT_ALARM:
+ alarm_info = (cal_alarm_info_t *)value->user_data;
+ if (!strcmp(field, CAL_VALUE_LLI_ALARMS_TIME))
+ alarm_info->alarm_time = llival;
+ else {
+ ERR("Invalid field (%s) in alarm value", field);
+ return CAL_ERR_ARG_INVALID;
+ }
+ break;
+ default:
+ ERR("Invalid value type (%d)", value->v_type);
+ return CAL_ERR_ARG_INVALID;
+ }
+
+ return CAL_SUCCESS;
+}
+
+API long long int calendar_svc_value_get_lli(cal_value *value, const char *field)
+{
+ cal_alarm_info_t *alarm_info;
+
+ switch(value->v_type)
+ {
+ case CAL_EVENT_ALARM:
+ alarm_info = (cal_alarm_info_t*)value->user_data;
+ if(!strcmp(field,CAL_VALUE_LLI_ALARMS_TIME))
+ return alarm_info->alarm_time;
+ else {
+ ERR("Invalid field (%s) in alarm value", field);
+ return CAL_ERR_ARG_INVALID;
+ }
+ break;
+ default:
+ ERR("Invalid value type (%d)", value->v_type);
+ return CAL_ERR_ARG_INVALID;
+ }
+ return CAL_SUCCESS;
}
API int calendar_svc_value_set_str (cal_value *value, const char *field, const char *strval)
{
- //CALS_FN_CALL();
retex_if(NULL == value || NULL == value->user_data || NULL == field || NULL == strval,,"[ERROR]calendar_svc_value_free:Invalid parameter!\n");
- cal_category_info_t* category = NULL;
cal_participant_info_t* participant = NULL;
cal_alarm_info_t *alarm_info = NULL;
switch(value->v_type)
{
- case CAL_EVENT_CATEGORY:
-
- category = (cal_category_info_t*)value->user_data;
-
- if(0 == strcmp(field,CAL_VALUE_TXT_MEETING_CATEGORY_DETAIL_NAME))
- {
- CAL_FREE(category->category_name);
-
- category->category_name = (char*)malloc(str_len);
- retex_if(NULL == category->category_name,,"[ERROR]calendar_svc_value_set_str:Failed to malloc!\n");
-
- memset(category->category_name ,0x00,str_len);
-
- strcpy(category->category_name,strval);
- }
- else
- {
- }
- break;
-
case CAL_EVENT_PATICIPANT:
participant = (cal_participant_info_t*)value->user_data;
API int calendar_svc_value_get_int (cal_value *value, const char *field)
{
- CALS_FN_CALL;
- retex_if(NULL == value || NULL == value->user_data || NULL == field,,"[ERROR]calendar_svc_value_free:Invalid parameter!\n");
-
- cal_category_info_t* category = NULL;
cal_participant_info_t* participant = NULL;
- cal_exception_info_t * exception = NULL;
cal_alarm_info_t* alarm_info = NULL;
- switch(value->v_type)
- {
- case CAL_EVENT_CATEGORY:
- category = (cal_category_info_t*)value->user_data;
-
- if(0 == strcmp(field,CAL_VALUE_INT_MEETING_CATEGORY_DETAIL_ID))
- {
- return(category->event_id);
- }
- else
- {
- }
- break;
+ if (!value || !value->user_data || !field || !*field) {
+ ERR("Invalid parameter");
+ return 0;
+ }
+ switch(value->v_type)
+ {
case CAL_EVENT_PATICIPANT:
participant = (cal_participant_info_t*)value->user_data;
{
}
break;
- case CAL_EVENT_RECURRENCY:
- exception = (cal_exception_info_t*)value->user_data;
- if(0 == strcmp(field,CAL_VALUE_INT_EXCEPTION_DATE_ID))
- {
- return exception->event_id;
- }
- break;
case CAL_EVENT_ALARM:
alarm_info = (cal_alarm_info_t*)value->user_data;
if(0 == strcmp(field,CAL_VALUE_INT_ALARMS_TICK))
break;
}
- return CAL_SUCCESS;
-
-CATCH:
-
- return CAL_ERR_FAIL;
-
+ return 0;
}
API char * calendar_svc_value_get_str (cal_value *value, const char *field)
{
CALS_FN_CALL;
- cal_category_info_t* category = NULL;
cal_participant_info_t* participant = NULL;
cal_alarm_info_t * alarm_info = NULL;
- retex_if(NULL == value || NULL == value->user_data || NULL == field,,"[ERROR]calendar_svc_value_free:Invalid parameter!\n");
+ if (!value || !value->user_data || !field || !*field) {
+ ERR("Invalid parameter");
+ return NULL;
+ }
switch(value->v_type)
{
- case CAL_EVENT_CATEGORY:
- category = (cal_category_info_t*)value->user_data;
-
- if(0 == strcmp(field,CAL_VALUE_TXT_MEETING_CATEGORY_DETAIL_NAME))
- {
- return category->category_name;
- }
- break;
-
case CAL_EVENT_PATICIPANT:
participant = (cal_participant_info_t*)value->user_data;
break;
}
-CATCH:
-
return NULL;
-
}
-
-API time_t calendar_svc_value_get_time (cal_value *value, const char *field,int timezone_flag)
+API long long int calendar_svc_struct_get_lli(cal_struct *event, const char *field)
{
- CALS_FN_CALL;
- time_t ret_time = 0;
+ cal_sch_full_t *sch_rec = NULL;
+ cals_struct_period_normal_onoff *nof = NULL;
+ cals_struct_period_normal_basic *nbs = NULL;
+ cals_struct_period_normal_osp *nosp = NULL;
+ cals_struct_period_normal_location *nosl = NULL;
+ cals_struct_period_normal_alarm *nosa = NULL;
- retv_if(NULL == value, CAL_ERR_ARG_NULL);
- retv_if(NULL == value->user_data, CAL_ERR_ARG_INVALID);
- retv_if(NULL == field, CAL_ERR_ARG_NULL);
+ retv_if(NULL == event || NULL == event->user_data, 0);
+ retv_if(NULL == field, 0);
- switch(value->v_type)
+ switch(event->event_type)
{
- case CAL_EVENT_RECURRENCY:
- if(0 == strcmp(field,CAL_VALUE_GMT_EXCEPTION_DATE_TIME))
- {
- cal_exception_info_t *exception_info = value->user_data;
- ret_time = cals_mktime(&(exception_info->exception_start_time));
- }
+ case CAL_STRUCT_TYPE_SCHEDULE:
+ case CAL_STRUCT_TYPE_TODO:
+ sch_rec = (cal_sch_full_t*)event->user_data;
+
+ if (0 == strcmp(field, CALS_VALUE_LLI_DTSTART_UTIME))
+ return sch_rec->dtstart_utime;
+ else if (0 == strcmp(field, CALS_VALUE_LLI_DTEND_UTIME))
+ return sch_rec->dtend_utime;
+ else if (0 == strcmp(field, CALS_VALUE_LLI_LASTMOD))
+ return sch_rec->last_mod;
+ else if (0 == strcmp(field, CALS_VALUE_LLI_RRULE_UNTIL_UTIME))
+ return sch_rec->until_utime;
+ else if(0 == strcmp(field,CAL_VALUE_LLI_CREATED_TIME))
+ return sch_rec->created_time;
+ else if(0 == strcmp(field,CAL_VALUE_LLI_COMPLETED_TIME))
+ return sch_rec->completed_time;
else
- {
- }
+ ERR("Can not find the field(%s)",field);
break;
- case CAL_EVENT_ALARM:
- if(0 == strcmp(field,CAL_VALUE_GMT_ALARMS_TIME))
- {
- cal_alarm_info_t *alarm_info = value->user_data;
- ret_time = cals_mktime(&(alarm_info->alarm_time));
- }
- else
- {
- }
+ case CAL_STRUCT_TYPE_CALENDAR:
break;
- default:
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_ONOFF:
+ nof = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_ONOFF_LLI_DTSTART_UTIME))
+ return nof->dtstart_utime;
+ else
+ ERR("Can't find field(%s)", field);
break;
- }
-
- if(timezone_flag != CAL_TZ_FLAG_GMT)
- {
- time_t temp = 0;
- calendar_svc_util_gmt_to_local(ret_time,&temp);
- ret_time = temp;
- }
- return ret_time;
-}
-
-API struct tm* calendar_svc_value_get_tm (cal_value *value, const char *field,int timezone_flag)
-{
- CALS_FN_CALL;
- struct tm* ret_tm = 0;
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_BASIC:
+ nbs = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_BASIC_LLI_DTSTART_UTIME))
+ return nbs->dtstart_utime;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_BASIC_LLI_DTEND_UTIME))
+ return nbs->dtend_utime;
+ else
+ ERR("Can't find field(%s)", field);
+ break;
- retv_if(NULL == value, NULL);
- retv_if(NULL == value->user_data, NULL);
- retv_if(NULL == field, NULL);
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_OSP:
+ nosp = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_LLI_DTSTART_UTIME))
+ return nosp->dtstart_utime;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_LLI_DTEND_UTIME))
+ return nosp->dtend_utime;
+ else
+ ERR("Can't find field(%s)", field);
+ break;
- switch(value->v_type)
- {
- case CAL_EVENT_RECURRENCY:
- if(0 == strcmp(field,CAL_VALUE_GMT_EXCEPTION_DATE_TIME))
- {
- cal_exception_info_t *exception_info = value->user_data;
- ret_tm = &(exception_info->exception_start_time);
- }
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_LOCATION:
+ nosl = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_LLI_DTSTART_UTIME))
+ return nosl->dtstart_utime;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_LLI_DTEND_UTIME))
+ return nosl->dtend_utime;
else
- {
- }
+ ERR("Can't find field(%s)", field);
break;
- case CAL_EVENT_ALARM:
- if(0 == strcmp(field,CAL_VALUE_GMT_ALARMS_TIME))
- {
- cal_alarm_info_t *alarm_info = value->user_data;
- ret_tm = &(alarm_info->alarm_time);
- }
+
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_ALARM:
+ nosa = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_ALARM_LLI_DTSTART_UTIME))
+ return nosa->dtstart_utime;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_ALARM_LLI_DTEND_UTIME))
+ return nosa->dtend_utime;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_ALARM_LLI_ALARM_UTIME))
+ return nosa->alarm_utime;
else
- {
- }
+ ERR("Can't find field(%s)", field);
break;
default:
break;
}
-
- if(timezone_flag != CAL_TZ_FLAG_GMT && NULL != ret_tm)
- {
- time_t temp = 0;
- time_t input_tt = 0;
-
- input_tt = cals_mktime(ret_tm);
-
- calendar_svc_util_gmt_to_local(input_tt,&temp);
- input_tt = temp;
- return cals_tmtime(&input_tt);
- }
-
- return ret_tm;
+ return 0;
}
-
-
-API int calendar_svc_value_set_time (cal_value *value, const char *field,int timezone_flag, time_t time)
+API int calendar_svc_struct_set_lli(cal_struct *event, const char *field, long long int value)
{
- CALS_FN_CALL;
+ cal_sch_full_t *sch_rec = NULL;
+ cals_struct_period_normal_onoff *nof = NULL;
+ cals_struct_period_normal_basic *nbs = NULL;
+ cals_struct_period_normal_osp *nosp = NULL;
+ cals_struct_period_normal_location *nosl = NULL;
+ cals_struct_period_normal_alarm *nosa = NULL;
- retv_if(NULL == value, CAL_ERR_ARG_NULL);
- retv_if(NULL == value->user_data, CAL_ERR_ARG_INVALID);
- retv_if(NULL == field, CAL_ERR_ARG_NULL);
+ retv_if(NULL == event || NULL == event->user_data, CAL_ERR_ARG_NULL);
- if(timezone_flag != CAL_TZ_FLAG_GMT)
+ switch(event->event_type)
{
- time_t temp = 0;
- calendar_svc_util_local_to_gmt(time,&temp);
- time = temp;
- }
+ case CAL_STRUCT_TYPE_SCHEDULE:
+ case CAL_STRUCT_TYPE_TODO:
- switch(value->v_type)
- {
- case CAL_EVENT_RECURRENCY:
- if(0 == strcmp(field,CAL_VALUE_GMT_EXCEPTION_DATE_TIME))
- {
- cal_exception_info_t *exception_info = value->user_data;
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime(&time),&(exception_info->exception_start_time));
+ sch_rec = (cal_sch_full_t*)event->user_data;
- return CAL_SUCCESS;
- }
+ if (0 == strcmp(field, CALS_VALUE_LLI_DTSTART_UTIME))
+ sch_rec->dtstart_utime = value;
+ else if (0 == strcmp(field, CALS_VALUE_LLI_DTEND_UTIME))
+ sch_rec->dtend_utime = value;
+ else if (0 == strcmp(field, CALS_VALUE_LLI_LASTMOD))
+ sch_rec->last_mod = value;
+ else if (0 == strcmp(field, CALS_VALUE_LLI_RRULE_UNTIL_UTIME))
+ sch_rec->until_utime = value;
+ else if(0 == strcmp(field,CAL_VALUE_LLI_CREATED_TIME))
+ sch_rec->created_time = value;
+ else if(0 == strcmp(field,CAL_VALUE_LLI_COMPLETED_TIME))
+ sch_rec->completed_time = value;
else
- {
-
- }
+ return CAL_ERR_ARG_INVALID;
break;
- case CAL_EVENT_ALARM:
- if(0 == strcmp(field,CAL_VALUE_GMT_ALARMS_TIME))
- {
- cal_alarm_info_t *alarm_info = value->user_data;
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime(&time),&(alarm_info->alarm_time));
- return CAL_SUCCESS;
- }
- else
- {
+ case CAL_STRUCT_TYPE_CALENDAR:
+ break;
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_ONOFF:
+ nof = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_ONOFF_LLI_DTSTART_UTIME))
+ nof->dtstart_utime = value;
+ else {
+ ERR("Can't find field(%s)", field);
+ return CAL_ERR_ARG_INVALID;
}
break;
- default:
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_BASIC:
+ nbs = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_BASIC_LLI_DTSTART_UTIME))
+ nbs->dtstart_utime = value;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_BASIC_LLI_DTEND_UTIME))
+ nbs->dtend_utime = value;
+ else {
+ ERR("Can't find field(%s)", field);
+ return CAL_ERR_ARG_INVALID;
+ }
break;
- }
-
- return CAL_SUCCESS;
-}
-
-
-API int calendar_svc_value_set_tm (cal_value *value, const char *field,int timezone_flag, struct tm* time)
-{
- CALS_FN_CALL;
- struct tm input_tm ={0};
-
- retv_if(NULL == value, CAL_ERR_ARG_NULL);
- retv_if(NULL == value->user_data, CAL_ERR_ARG_INVALID);
- retv_if(NULL == field, CAL_ERR_ARG_NULL);
-
- if(timezone_flag != CAL_TZ_FLAG_GMT)
- {
- time_t temp = 0;
- time_t input_tt = 0;
-
- input_tt = cals_mktime(time);
- calendar_svc_util_local_to_gmt(input_tt,&temp);
- input_tt = temp;
- cals_tmtime_r(&input_tt,&input_tm);
- }
- else
- memcpy(&input_tm,time,sizeof(struct tm));
-
-
- switch(value->v_type)
- {
- case CAL_EVENT_RECURRENCY:
- if(0 == strcmp(field,CAL_VALUE_GMT_EXCEPTION_DATE_TIME))
- {
- cal_exception_info_t *exception_info = value->user_data;
- //cal_db_service_copy_struct_tm((struct tm*)&input_tm,&(exception_info->exception_start_time));
- memcpy(&(exception_info->exception_start_time),&input_tm,sizeof(struct tm));
- DBG("%d-%d-%d",exception_info->exception_start_time.tm_year,exception_info->exception_start_time.tm_mon,exception_info->exception_start_time.tm_mday);
- return CAL_SUCCESS;
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_OSP:
+ nosp = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_LLI_DTSTART_UTIME))
+ nosp->dtstart_utime = value;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_OSP_LLI_DTEND_UTIME))
+ nosp->dtend_utime = value;
+ else {
+ ERR("Can't find field(%s)", field);
+ return CAL_ERR_ARG_INVALID;
}
- else
- {
+ break;
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_LOCATION:
+ nosl = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_LLI_DTSTART_UTIME))
+ nosl->dtstart_utime = value;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_LOCATION_LLI_DTEND_UTIME))
+ nosl->dtend_utime = value;
+ else {
+ ERR("Can't find field(%s)", field);
+ return CAL_ERR_ARG_INVALID;
}
break;
- case CAL_EVENT_ALARM:
- if(0 == strcmp(field,CAL_VALUE_GMT_ALARMS_TIME))
- {
- cal_alarm_info_t *alarm_info = value->user_data;
- //cal_db_service_copy_struct_tm((struct tm*)&input_tm,&(exception_info->exception_start_time));
- memcpy(&(alarm_info->alarm_time),&input_tm,sizeof(struct tm));
- DBG("%d-%d-%d",alarm_info->alarm_time.tm_year,alarm_info->alarm_time.tm_mon,alarm_info->alarm_time.tm_mday);
- return CAL_SUCCESS;
- }
- else
- {
+ case CALS_STRUCT_TYPE_PERIOD_NORMAL_ALARM:
+ nosa = event->user_data;
+ if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_ALARM_LLI_DTSTART_UTIME))
+ nosa->dtstart_utime = value;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_ALARM_LLI_DTEND_UTIME))
+ nosa->dtend_utime = value;
+ else if (!strcmp(field, CALS_LIST_PERIOD_NORMAL_ALARM_LLI_ALARM_UTIME))
+ nosa->alarm_utime = value;
+ else {
+ ERR("Can't find field(%s)", field);
+ return CAL_ERR_ARG_INVALID;
}
break;
return CAL_SUCCESS;
}
+
+
#ifndef _CALENDAR_SVC_STRUCT_INTERNAL_H_
#define _CALENDAR_SVC_STRUCT_INTERNAL_H_
-int cals_init_full_record(cal_sch_full_t *sch_full_record);
-
#endif // _CALENDAR_SVC_STRUCT_INTERNAL_H_
--- /dev/null
+#include <unicode/ucal.h>
+#include <unicode/ustring.h>
+#include <unicode/ustdio.h>
+#include <unicode/udat.h>
+#include <stdlib.h>
+#include "cals-time.h"
+#include "calendar-svc-provider.h"
+#include "cals-internal.h"
+
+#define ms2sec(ms) (long long int)(ms / 1000.0)
+#define sec2ms(s) (s * 1000.0)
+
+static UCalendar *_ucal_get_cal(const char *tzid)
+{
+ UCalendar *cal;
+ UErrorCode status = U_ZERO_ERROR;
+ UChar *_tzid;
+
+ _tzid = NULL;
+
+ if (tzid) {
+ _tzid = (UChar*)malloc(sizeof(UChar) * (strlen(tzid) +1));
+ if (_tzid)
+ u_uastrcpy(_tzid, tzid);
+ else
+ ERR("malloc failed");
+ }
+
+ cal = ucal_open(_tzid, u_strlen(_tzid), "en_US", UCAL_TRADITIONAL, &status);
+ if (_tzid)
+ free(_tzid);
+
+ if (U_FAILURE(status)) {
+ ERR("ucal_open failed (%s)", u_errorName(status));
+ return NULL;
+ }
+ return cal;
+}
+
+static void _ucal_set_time(UCalendar *cal, struct cals_time *t)
+{
+ UErrorCode status = U_ZERO_ERROR;
+
+ if (t->type == CALS_TIME_UTIME) {
+ ucal_setMillis(cal, sec2ms(t->utime), &status);
+ if (U_FAILURE(status)) {
+ ERR("ucal_setMillis failed (%s)", u_errorName(status));
+ return;
+ }
+ } else if (t->type == CALS_TIME_LOCALTIME) {
+ ucal_setDateTime(cal, t->year, t->month - 1, t->mday, 0, 0, 0, &status);
+ if (U_FAILURE(status)) {
+ ERR("ucal_setDate failed (%s)", u_errorName(status));
+ return;
+ }
+ } else
+ ERR("Invalid dtstart type. Current time is used in default");
+}
+
+long long int cals_time_diff(struct cals_time *st, struct cals_time *et)
+{
+ UErrorCode status = U_ZERO_ERROR;
+ UCalendar *cal;
+ UDate ud;
+ int dr;
+ if (st->type == CALS_TIME_UTIME)
+ return et->utime - st->utime;
+
+ cal = _ucal_get_cal(et->tzid);
+
+ _ucal_set_time(cal, et);
+
+ ud = ucal_getMillis(cal, &status);
+
+ _ucal_set_time(cal, st);
+
+ dr = ucal_getFieldDifference(cal, ud, UCAL_DATE, &status);
+ if (U_FAILURE(status)) {
+ ERR("ucal_getFieldDifference failed (%s)", u_errorName(status));
+ return 0;
+ }
+
+ ucal_close(cal);
+
+ return dr;
+}
+
+long long int cals_time_diff_with_now(struct cals_time *t)
+{
+ long long int now;
+ UErrorCode status = U_ZERO_ERROR;
+ UCalendar *cal;
+ UDate ud;
+
+ if (t->type == CALS_TIME_UTIME) {
+ DBG("alarm utime diff (%lld) - (%lld)", t->utime, ms2sec(ucal_getNow()));
+ return t->utime - ms2sec(ucal_getNow());
+ }
+
+ cal = _ucal_get_cal(t->tzid);
+ _ucal_set_time(cal, t);
+ ud = ucal_getMillis(cal, &status);
+ ucal_close(cal);
+ now = ms2sec(ucal_getNow());
+ DBG("alarm allday diff (%lld) - (%lld) ", ms2sec(ud), now);
+ return ms2sec(ud) - now ;
+}
+
+char *cals_time_get_str_datetime(char *tzid, long long int t)
+{
+ UErrorCode status = U_ZERO_ERROR;
+ UCalendar *cal;
+ int y, mon, d, h, m, s;
+ char buf[17] = {0};
+
+ if (tzid == NULL) {
+ tzid = CALS_TZID_0;
+ }
+ cal = _ucal_get_cal(tzid);
+
+ y = ucal_get(cal, UCAL_YEAR, &status);
+ mon = ucal_get(cal, UCAL_MONTH, &status) + 1;
+ d = ucal_get(cal, UCAL_DATE, &status);
+ h = ucal_get(cal, UCAL_HOUR, &status);
+ m = ucal_get(cal, UCAL_MINUTE, &status);
+ s = ucal_get(cal, UCAL_SECOND, &status);
+
+ snprintf(buf, sizeof(buf),
+ "%04d%02d%02dT%02d%02d%02dZ",
+ y, mon, d, h, m, s);
+ return strdup(buf);
+}
+
+long long int cals_time_convert_to_lli(struct cals_time *ct)
+{
+ long long int lli;
+ UCalendar *cal;
+ UErrorCode status = U_ZERO_ERROR;
+ UChar *_tzid;
+
+ _tzid = NULL;
+
+ if (ct->tzid) {
+ _tzid = (UChar*)malloc(sizeof(UChar) * (strlen(ct->tzid) +1));
+ if (_tzid)
+ u_uastrcpy(_tzid, ct->tzid);
+ else
+ ERR("malloc failed");
+ }
+DBG("tzid(%s)", ct->tzid);
+ cal = ucal_open(_tzid, u_strlen(_tzid), "en_US", UCAL_TRADITIONAL, &status);
+ if (_tzid)
+ free(_tzid);
+
+ if (U_FAILURE(status)) {
+ ERR("ucal_open failed (%s)", u_errorName(status));
+ return -1;
+ }
+
+ ucal_set(cal, UCAL_YEAR, ct->year);
+ ucal_set(cal, UCAL_MONTH, ct->month - 1);
+ ucal_set(cal, UCAL_DATE, ct->mday);
+ ucal_set(cal, UCAL_HOUR, 0);
+ ucal_set(cal, UCAL_MINUTE, 0);
+ ucal_set(cal, UCAL_SECOND, 0);
+
+ lli = (long long int)(ms2sec(ucal_getMillis(cal, &status)));
+
+ ucal_close(cal);
+ DBG("%04d/%02d/%02d %02d:%02d:%03d", ct->year, ct->month, ct->mday, 0, 0, 0);
+ DBG("%lld", lli);
+ return lli;
+}
+
+
+long long int cals_time_date_to_utime(const char *tzid,
+ int year, int month, int mday, int hour, int minute, int second)
+{
+ UCalendar *cal;
+ UErrorCode status = U_ZERO_ERROR;
+ UChar *_tzid;
+ long long int lli;
+
+ cal = _ucal_get_cal(tzid);
+
+ ucal_set(cal, UCAL_YEAR, year);
+ ucal_set(cal, UCAL_MONTH, month - 1);
+ ucal_set(cal, UCAL_DATE, mday);
+ ucal_set(cal, UCAL_HOUR, hour);
+ ucal_set(cal, UCAL_MINUTE, minute);
+ ucal_set(cal, UCAL_SECOND, second);
+
+ lli = ms2sec(ucal_getMillis(cal, &status));
+ if (U_FAILURE(status)) {
+ ERR("ucal_open failed (%s)", u_errorName(status));
+ ucal_close(cal);
+ return -1;
+ }
+ ucal_close(cal);
+ return lli;
+}
+
+long long int cals_get_lli_now(void)
+{
+ return ms2sec(ucal_getNow());
+}
--- /dev/null
+#ifndef __CALENDAR_SVC_TIME_H__
+#define __CALENDAR_SVC_TIME_H__
+
+struct cals_time {
+ int type;
+ long long int utime;
+ int year;
+ int month;
+ int mday;
+ char tzid[15];
+};
+
+long long int cals_time_diff(struct cals_time *st, struct cals_time *et);
+long long int cals_time_diff_with_now(struct cals_time *t);
+char *cals_time_get_str_datetime(char *tzid, long long int t);
+long long int cals_get_lli_now(void);
+
+#define CALS_TZID_0 "Europe/London"
+
+#endif
#include "cals-db-info.h"
#include "cals-db.h"
#include "cals-utils.h"
+#include "cals-schedule.h"
-static inline void cals_todo_make_condition(int calendar_id,
- time_t start_time, time_t end_time,
- int priority, cals_status_t status, char *dest, int dest_size)
+static const char *_todo_list_order[] = {
+ [CALS_TODO_LIST_ORDER_END_DATE] = "dtend_utime DESC",
+ [CALS_TODO_LIST_ORDER_PRIORITY] = "priority DESC, dtend_utime DESC",
+ [CALS_TODO_LIST_ORDER_STATUS] = "task_status ASC, dtend_utime DESC",
+};
+
+static inline const char *cals_todo_get_order(cals_todo_list_order_t order)
{
- int ret;
+ return _todo_list_order[order];
+}
+
+int cals_todo_init(cal_sch_full_t *sch_full_record)
+{
+ retvm_if(NULL == sch_full_record, CAL_ERR_ARG_INVALID , "sch_full_record is NULL");
+
+ memset(sch_full_record,0,sizeof(cal_sch_full_t));
+
+ sch_full_record->cal_type = CALS_SCH_TYPE_TODO;
+ sch_full_record->task_status = CALS_TODO_STATUS_NONE;
+ sch_full_record->calendar_id = DEFAULT_TODO_CALENDAR_ID;
+
+ sch_full_record->index = CALS_INVALID_ID;
+ sch_full_record->timezone = -1;
+ sch_full_record->contact_id = CALS_INVALID_ID;
+ sch_full_record->calendar_type = CAL_PHONE_CALENDAR;
+ sch_full_record->attendee_list = NULL;
+ sch_full_record->busy_status = 2;
+ sch_full_record->summary = NULL;
+ sch_full_record->description = NULL;
+ sch_full_record->location= NULL;
+ sch_full_record->categories = NULL;
+ sch_full_record->exdate = NULL;
+ sch_full_record->organizer_email = NULL;
+ sch_full_record->organizer_name = NULL;
+ sch_full_record->uid= NULL;
+ sch_full_record->gcal_id = NULL;
+ sch_full_record->location_summary = NULL;
+ sch_full_record->etag = NULL;
+ sch_full_record->edit_uri = NULL;
+ sch_full_record->gevent_id = NULL;
+ sch_full_record->original_event_id = CALS_INVALID_ID;
+
+ sch_full_record->sync_status = CAL_SYNC_STATUS_NEW;
+ sch_full_record->account_id = -1;
+ sch_full_record->is_deleted = 0;
+ sch_full_record->latitude = 1000; // set default 1000 out of range(-180 ~ 180)
+ sch_full_record->longitude = 1000; // set default 1000 out of range(-180 ~ 180)
+ sch_full_record->freq = CALS_FREQ_ONCE;
+
+ return CAL_SUCCESS;
+}
+
+
+static int __todo_get_query_priority(int priority, char *query, int len)
+{
+ switch (priority) {
+ case CALS_TODO_PRIORITY_NONE: // 0x01
+ snprintf(query, len, "AND priority = %d ", 0);
+ break;
+
+ case CALS_TODO_PRIORITY_HIGH: // 0x020
+ snprintf(query, len, "AND priority < %d ", CALS_TODO_PRIORITY_MID);
+ break;
+
+ case CALS_TODO_PRIORITY_MID: // 0x04
+ snprintf(query, len, "AND priority = %d ", CALS_TODO_PRIORITY_MID);
+ break;
+
+ case CALS_TODO_PRIORITY_LOW: // 0x08
+ snprintf(query, len, "AND priority > %d ", CALS_TODO_PRIORITY_MID);
+ break;
+
+ case 0x03: /* NONE | HIGH */
+ snprintf(query, len, "AND (priority = %d OR priority < %d) ", 0, CALS_TODO_PRIORITY_MID);
+ break;
+
+ case 0x05: /* NONE | MID */
+ snprintf(query, len, "AND (priority = %d OR priority = %d) ", 0, CALS_TODO_PRIORITY_MID);
+ break;
+
+ case 0x09: /* NONE | LOW */
+ snprintf(query, len, "AND (priority = %d OR priority > %d) ", 0, CALS_TODO_PRIORITY_MID);
+ break;
+
+ case 0x06: /* HIGH |MID */
+ snprintf(query, len, "AND priority > %d AND priority <= %d ", 0, CALS_TODO_PRIORITY_MID);
+ break;
+
+ case 0x0A: /* HIGH |LOW */
+ snprintf(query, len, "AND priority > %d AND priority != %d ", 0, CALS_TODO_PRIORITY_MID);
+ break;
+
+ case 0x0C: /* MID |LOW */
+ snprintf(query, len, "AND priority >= %d ", CALS_TODO_PRIORITY_MID);
+ break;
+
+ case 0x07: /* NONE | HIGH | MID */
+ snprintf(query, len, "AND priority <= %d ", CALS_TODO_PRIORITY_MID);
+ break;
+
+ case 0x0B: /* NONE | HIGH | LOW */
+ snprintf(query, len, "AND priority <> %d ", CALS_TODO_PRIORITY_MID);
+ break;
+
+ case 0x0D: /* NONE | MID | LOW */
+ snprintf(query, len, "AND priority >= %d ", CALS_TODO_PRIORITY_MID);
+ break;
+
+ case 0x0E: /* HIGH | MID |LOW */
+ snprintf(query, len, "AND priority > %d ", 0);
+ break;
- ret = snprintf(dest, dest_size, "type = %d", CAL_EVENT_TODO_TYPE);
+ case 0x0F: /* NONE | HIGH | MID | LOW */
+ memset(query, 0x0, len);
+ default:
+ break;
+ }
+ return 0;
+}
+
+static int __todo_get_query_status(int status, char *query, int len)
+{
+ int i, conj;
+ char buf[64] = {0};
- if (calendar_id)
- ret += snprintf(dest+ret, dest_size-ret, "AND calendar_id = %d", calendar_id);
+ if (status) {
+ if (status & 0xff) {
+ DBG("check status:%x", status);
+ return -1;
+ }
+ conj = 0;
+ snprintf(query, len, "%s", "AND ( ");
- if (0 < start_time)
- ret += snprintf(dest+ret, dest_size-ret, "AND start_date_time >= %ld", start_time);
+ for (i = 0; i < 5; i++) {
+ if (status & (1 << (i + 8))) {
+ if (conj) {
+ strcat(query, "OR ");
+ conj = 0;
+ }
- if (0 < end_time)
- ret += snprintf(dest+ret, dest_size-ret, "AND start_date_time <= %ld", end_time);
+ snprintf(buf, sizeof(buf), "task_status = %d ", (1 << (i + 8)));
+ strcat(query, buf);
+ conj = 1;
+ }
+ }
+ strcat(query, ") ");
- if (0 < priority)
- ret += snprintf(dest+ret, dest_size-ret, "AND priority = %d", priority);
+ } else {
+ memset(query, 0x0, len);
- if (0 < status)
- ret += snprintf(dest+ret, dest_size-ret, "AND task_status = %d", status);
+ }
+ return 0;
}
/**
* @param[in] status #cals_status_t
* @return The count number on success, Negative value(#cal_error) on error
*/
-API int calendar_svc_todo_get_count(int calendar_id, time_t start_time,
- time_t end_time, int priority, cals_status_t status)
+/*
+API int calendar_svc_todo_get_count(int calendar_id,
+ long long int dtstart_utime, long long int dtend_utime, int priority, cals_status_t status)
{
char query[CALS_SQL_MIN_LEN];
char cond[CALS_SQL_MIN_LEN];
- cals_todo_make_condition(calendar_id, start_time, end_time, priority, status, cond, sizeof(cond));
+ cals_todo_get_condition(calendar_id, start_time, end_time, priority, status, cond, sizeof(cond));
snprintf(query, sizeof(query), "SELECT COUNT(*) FROM %s WHERE is_deleted = 0 AND %s",
CALS_TABLE_SCHEDULE, cond);
return cals_query_get_first_int_result(query);
}
-
-
-API cal_iter* calendar_svc_todo_get_list(int calendar_id, time_t start_time,
- time_t end_time, int priority, cals_status_t status)
+*/
+API int calendar_svc_todo_get_list(int calendar_id, long long int dtend_from, long long int dtend_to,
+ int priority,cals_status_t status, cals_todo_list_order_t order, cal_iter **iter)
{
- cal_iter *iter;
+ cal_iter *it;
sqlite3_stmt *stmt = NULL;
+ char buf_calendar_id[256] = {0};
+ char buf_dtend_from[256] = {0};
+ char buf_dtend_to[256] = {0};
+ char buf_priority[256] = {0};
+ char buf_status[256] = {0};
char query[CALS_SQL_MAX_LEN];
- char cond[CALS_SQL_MIN_LEN];
- cals_todo_make_condition(calendar_id, start_time, end_time, priority, status, cond, sizeof(cond));
+ retv_if(NULL == iter, CAL_ERR_ARG_NULL);
+ retv_if(order < CALS_TODO_LIST_ORDER_END_DATE || order > CALS_TODO_LIST_ORDER_STATUS, CAL_ERR_ARG_INVALID);
- sprintf(query,"SELECT * FROM %s WHERE is_deleted = 0 AND %s ORDER BY start_date_time",
- CALS_TABLE_SCHEDULE, cond);
+ if (calendar_id > 0) {
+ snprintf(buf_calendar_id, sizeof(buf_calendar_id), "AND calendar_id = %d ", calendar_id);
+ } else {
+ memset(buf_calendar_id, 0x0, sizeof(buf_calendar_id));
+ }
+
+ if (dtend_from >= 0) {
+ snprintf(buf_dtend_from, sizeof(buf_dtend_from), "AND dtend_utime >= %lld ", dtend_from);
+ } else {
+ memset(buf_dtend_from, 0x0, sizeof(buf_dtend_from));
+ }
+
+ if (dtend_to >= 0) {
+ snprintf(buf_dtend_to, sizeof(buf_dtend_to), "AND dtend_utime <= %lld ", dtend_to);
+ } else {
+ memset(buf_dtend_to, 0x0, sizeof(buf_dtend_to));
+ }
+
+ __todo_get_query_priority(priority, buf_priority, sizeof(buf_priority));
+ __todo_get_query_status(status, buf_status, sizeof(buf_status));
+
+ snprintf(query, sizeof(query),
+ "SELECT * FROM %s "
+ "WHERE is_deleted = 0 AND type = %d "
+ "%s %s %s %s %s "
+ "ORDER BY %s",
+ CALS_TABLE_SCHEDULE,
+ CAL_STRUCT_TYPE_TODO,
+ buf_calendar_id, buf_dtend_from, buf_dtend_to, buf_priority, buf_status,
+ cals_todo_get_order(order));
stmt = cals_query_prepare(query);
- retvm_if(NULL == stmt, NULL,"cals_query_prepare() Failed");
+ retvm_if(NULL == stmt, CAL_ERR_DB_FAILED, "cals_query_prepare() Failed");
- iter = calloc(1, sizeof(cal_iter));
- if (NULL == iter) {
+ it = calloc(1, sizeof(cal_iter));
+ if (NULL == it) {
sqlite3_finalize(stmt);
ERR("calloc() Failed(%d)", errno);
- return NULL;
+ return CAL_ERR_OUT_OF_MEMORY;
}
- iter->i_type = CAL_STRUCT_TYPE_TODO;
- iter->stmt = stmt;
+ it->i_type = CAL_STRUCT_TYPE_TODO;
+ it->stmt = stmt;
+ *iter = it;
return CAL_SUCCESS;
}
-API int calendar_svc_todo_delete_all(int calendar_id)
+API int calendar_svc_todo_search(int fields, const char *keyword, cal_iter **iter)
{
int ret;
- char query[CALS_SQL_MAX_LEN] = {0};
- sprintf(query, "UPDATE %s SET is_deleted = 1, sync_status = %d, last_modified_time = %ld "
- "WHERE type = %d AND calendar_id = %d",
- CALS_TABLE_SCHEDULE, CAL_SYNC_STATUS_DELETED, time(NULL),
- CAL_EVENT_TODO_TYPE, calendar_id);
+ ret = cals_sch_search(CALS_SCH_TYPE_TODO, fields, keyword, iter);
+ retvm_if(ret < 0, ret, "cals_sch_search() failed(%d)", ret);
+
+ return CAL_SUCCESS;
+}
+
+static inline int cals_todo_get_changes(int calendar_id, int version, cal_iter *iter)
+{
+ char buf[64] = {0};
+ char query[CALS_SQL_MIN_LEN] = {0,};
+ sqlite3_stmt *stmt;
+ cals_updated *last;
+ cals_updated *result;
+
+ if (calendar_id > 0) {
+ snprintf(buf, sizeof(buf), "AND calendar_id = %d ", calendar_id);
+ } else {
+ memset(buf, 0x0, sizeof(buf));
+ }
+
+ snprintf(query, sizeof(query),
+ "SELECT id, changed_ver, created_ver, is_deleted FROM %s "
+ "WHERE changed_ver > %d AND original_event_id = %d AND type = %d %s "
+ "UNION "
+ "SELECT schedule_id, deleted_ver, -1, 1 FROM %s "
+ "WHERE deleted_ver > %d AND schedule_type = %d %s",
+ CALS_TABLE_SCHEDULE,
+ version, CALS_INVALID_ID, CALS_SCH_TYPE_TODO, buf,
+ CALS_TABLE_DELETED,
+ version, CALS_SCH_TYPE_TODO, buf);
+
+ DBG("query(%s)", query);
+ stmt = cals_query_prepare(query);
+ retvm_if (NULL == stmt, CAL_ERR_DB_FAILED, "cals_query_prepare() failed.");
+
+ while (CAL_TRUE == cals_stmt_step(stmt)){
+ result = cals_updated_schedule_add_mempool();
- ret = cals_begin_trans();
- retvm_if(CAL_SUCCESS != ret, ret, "cals_begin_trans() Failed(%d)", ret);
+ result->id = sqlite3_column_int(stmt, 0);
+ result->ver = sqlite3_column_int(stmt, 1);
+ if (sqlite3_column_int(stmt, 3) == 1)
+ result->type = CALS_UPDATED_TYPE_DELETED;
+ else if (sqlite3_column_int(stmt, 2) == result->ver || version < sqlite3_column_int(stmt, 2))
+ result->type = CALS_UPDATED_TYPE_INSERTED;
+ else
+ result->type = CALS_UPDATED_TYPE_MODIFIED;
- ret = cals_query_exec(query);
- if (CAL_SUCCESS != ret) {
- cals_end_trans(false);
- ERR("cals_query_exec() Failed(%d)", ret);
+ if (iter->info->head == NULL) {
+ iter->info->head = result;
+ } else {
+ last->next = result;
+ }
+ last = result;
+ }
+ iter->i_type = CAL_STRUCT_TYPE_UPDATED_LIST;
+
+ sqlite3_finalize(stmt);
+
+ return CAL_SUCCESS;
+}
+
+API int calendar_svc_todo_get_changes(int calendar_id, int version, cal_iter **iter)
+{
+ int ret;
+ cal_iter *it;
+
+ retv_if (NULL == iter, CAL_ERR_ARG_NULL);
+ retvm_if (version < 0, CAL_ERR_ARG_INVALID, "Invalid argument");
+
+ it = calloc(1, sizeof(cal_iter));
+ retvm_if (NULL == it, CAL_ERR_OUT_OF_MEMORY, "calloc() failed");
+
+ it->info = calloc(1, sizeof(cals_updated_info));
+ if (!it->info) {
+ ERR("calloc() Failed");
+ free(it);
+ return CAL_ERR_OUT_OF_MEMORY;
+ }
+
+ ret = cals_todo_get_changes(calendar_id, version, it);
+ if (ret) {
+ ERR("cals_todo_get_changes() failed(%d", ret);
+ free(it->info);
+ free(it);
return ret;
}
- cals_end_trans(true);
- cals_notify(CALS_NOTI_TYPE_TODO);
+ *iter = it;
+
+ return CAL_SUCCESS;
+}
+
+
+API int calendar_svc_todo_get_iter(int calendar_id, int priority, int status,
+ cals_todo_list_order_t order, cal_iter **iter)
+{
+ char query[CALS_SQL_MIN_LEN] = {0};
+ char buf_id[64] = {0};
+ char buf_prio[64] = {0};
+ char buf_stat[256] = {0};
+ cal_iter *it;
+ sqlite3_stmt *stmt = NULL;
+
+ it = calloc(1, sizeof(cal_iter));
+ retvm_if(NULL == it, CAL_ERR_OUT_OF_MEMORY, "Failed to calloc(%d)", errno);
+ it->is_patched = 0;
+
+ if (calendar_id > 0) {
+ snprintf(buf_id, sizeof(buf_id), "AND calendar_id = %d ", calendar_id);
+ } else {
+ memset(buf_id, 0x0, sizeof(buf_id));
+ }
+
+ /* priority */
+ __todo_get_query_priority(priority, buf_prio, sizeof(buf_prio));
+
+ /* status */
+ __todo_get_query_status(status, buf_stat, sizeof(buf_stat));
+ /* dtend means due */
+ it->i_type = CAL_STRUCT_TYPE_TODO;
+ snprintf(query, sizeof(query),
+ "SELECT * FROM %s "
+ "WHERE type = %d %s %s %s ",
+ CALS_TABLE_SCHEDULE,
+ CALS_SCH_TYPE_TODO, buf_id, buf_prio, buf_stat);
+DBG("%s\n", query);
+ stmt = cals_query_prepare(query);
+ retvm_if(NULL == stmt, CAL_ERR_DB_FAILED, "Failed to query prepare");
+
+ it->stmt = stmt;
+ *iter = it;
return CAL_SUCCESS;
}
-API cal_iter* calendar_svc_todo_get_updated_list(int calendar_id, time_t timestamp)
+API int calendar_svc_todo_get_list_by_period(int calendar_id,
+ long long int due_from, long long int dueto, int priority, int status, cal_iter **iter)
{
- return cals_get_updated_list(CAL_EVENT_TODO_TYPE, calendar_id, timestamp);
+ char query[CALS_SQL_MIN_LEN] = {0};
+ char buf_id[64] = {0};
+ char buf_prio[64] = {0};
+ char buf_stat[256] = {0};
+ cal_iter *it;
+ sqlite3_stmt *stmt = NULL;
+
+ it = calloc(1, sizeof(cal_iter));
+ retvm_if(NULL == it, CAL_ERR_OUT_OF_MEMORY, "Failed to calloc(%d)", errno);
+ it->is_patched = 0;
+
+ if (calendar_id > 0) {
+ snprintf(buf_id, sizeof(buf_id), "AND calendar_id = %d ", calendar_id);
+ } else {
+ memset(query, 0x0, sizeof(buf_id));
+ }
+
+ /* priority */
+ __todo_get_query_priority(priority, buf_prio, sizeof(buf_prio));
+
+ /* status */
+ __todo_get_query_status(status, buf_stat, sizeof(buf_stat));
+
+ /* dtend means due */
+ it->i_type = CAL_STRUCT_TYPE_TODO;
+ snprintf(query, sizeof(query),
+ "SELECT * FROM %s "
+ "WHERE dtend_utime >= %lld AND dtend_utime <= %lld "
+ "AND type = %d %s %s ",
+ CALS_TABLE_SCHEDULE,
+ due_from, dueto,
+ CALS_SCH_TYPE_TODO, buf_prio, buf_stat);
+DBG("%s\n", query);
+ stmt = cals_query_prepare(query);
+ retvm_if(NULL == stmt, CAL_ERR_DB_FAILED, "Failed to query prepare");
+
+ it->stmt = stmt;
+ *iter = it;
+ return CAL_SUCCESS;
+}
+
+API int calendar_svc_todo_get_count_by_period(int calendar_id,
+ long long int due_from, long long int dueto, int priority, int status, int *count)
+{
+ int ret, cnt = 0;
+ char query[CALS_SQL_MIN_LEN] = {0};
+ char buf_prio[64] = {0};
+ char buf_stat[256] = {0};
+
+ retvm_if(priority < 0, CAL_ERR_ARG_INVALID, "Invalid argument: priorit(%d)", priority);
+ retvm_if(status < 0, CAL_ERR_ARG_INVALID, "Invalid argument: status(%d)", priority);
+
+ DBG("priority(%d) status(%d)", priority, status);
+ sqlite3_stmt *stmt = NULL;
+
+ /* priority */
+ __todo_get_query_priority(priority, buf_prio, sizeof(buf_prio));
+
+ /* status */
+ __todo_get_query_status(status, buf_stat, sizeof(buf_stat));
+
+ snprintf(query, sizeof(query),
+ "SELECT count(*) FROM %s "
+ "WHERE dtend_utime >= %lld AND dtend_utime <= %lld "
+ "AND type = %d %s %s ",
+ CALS_TABLE_SCHEDULE,
+ due_from, dueto,
+ CALS_SCH_TYPE_TODO, buf_prio, buf_stat);
+
+DBG("%s\n", query);
+ stmt = cals_query_prepare(query);
+ retvm_if(NULL == stmt, CAL_ERR_DB_FAILED, "Failed to query prepare");
+
+ ret = cals_stmt_step(stmt);
+ if (CAL_TRUE == ret) {
+ cnt = sqlite3_column_int(stmt, 0);
+
+ } else if (CAL_SUCCESS != ret) {
+ sqlite3_finalize(stmt);
+ ERR("Failed to step(errno:%d)", ret);
+ return ret;
+ }
+ sqlite3_finalize(stmt);
+ *count = cnt;
+
+ return CAL_SUCCESS;
}
#include "calendar-svc-provider.h"
/* Definition */
-#define CAL_INVALID_INDEX (-1)
+#define CALS_INVALID_ID (-1)
#define CAL_SCH_SUMMARY_LEN_MAX 1024//256 /**< Summary string length of Schedule */
#define CAL_SCH_DESCRIPTION_LEN_MAX 4096 /**< Description string length of Schedule */
CAL_STRUCT_TYPE_TIMEZONE,
CAL_STRUCT_TYPE_SCHEDULE_LIST,
CAL_STRUCT_TYPE_TODO_LIST,
-}cal_struct_type;
+ CAL_STRUCT_TYPE_UPDATED_LIST,
+ CALS_STRUCT_TYPE_PERIOD_NORMAL_ONOFF,
+ CALS_STRUCT_TYPE_PERIOD_ALLDAY_ONOFF,
+ CALS_STRUCT_TYPE_PERIOD_NORMAL_BASIC,
+ CALS_STRUCT_TYPE_PERIOD_ALLDAY_BASIC,
+ CALS_STRUCT_TYPE_PERIOD_NORMAL_OSP,
+ CALS_STRUCT_TYPE_PERIOD_ALLDAY_OSP,
+ CALS_STRUCT_TYPE_PERIOD_NORMAL_LOCATION,
+ CALS_STRUCT_TYPE_PERIOD_ALLDAY_LOCATION,
+ CALS_STRUCT_TYPE_PERIOD_NORMAL_ALARM,
+ CALS_STRUCT_TYPE_PERIOD_ALLDAY_ALARM
+
+} cal_struct_type;
typedef enum
{
CAL_EVENT_PATICIPANT = 0, /**< CAL_STRUCT_PARTICIPANT */
- CAL_EVENT_CATEGORY, /**< CAL_STRUCT_CATEFORY */
CAL_EVENT_RECURRENCY, /**< CAL_STRUCT_RECURRENCY */
CAL_EVENT_DELETE, /**< CAL_STRUCT_DELETE */
CAL_EVENT_SYNC_STATUS, /**< CAL_STRUCT_SYNC_STATUS */
} cal_data_type_t;
-struct _cal_struct{
+
+#define CAL_STRUCT_UPDATED "updated" /**< CAL_STRUCT_UPDATED */
+
+typedef struct _updated {
+ int type;
+ int id;
+ int ver;
+ struct _updated *next;
+} cals_updated;
+
+typedef struct {
+ cals_updated *head;
+ cals_updated *cursor;
+} cals_updated_info;
+
+struct _cal_struct {
cal_struct_type event_type;
void* user_data;
};
-struct _cal_value{
+struct _cal_value {
cal_data_type_t v_type;
void* user_data;
};
-struct _cal_iter{
+struct _cal_iter {
int i_type;
sqlite3_stmt *stmt;
int is_patched;
+ cals_updated_info *info;
};
typedef struct
{
int localtime_offset;
int local_dst_offset;
- char local_tz_name[50];
+ char local_tz_id[50];
struct tm start_local_dst_date_time;
struct tm start_local_std_date_time;
int temptime_offset;
int temp_dst_offset;
- char temp_tz_name[50];
+ char temp_tz_id[50];
struct tm start_temp_dst_date_time;
struct tm start_temp_std_date_time;
typedef enum
{
- CALS_NOTI_TYPE_EVENT,
+ CALS_NOTI_TYPE_EVENT = 0x0,
CALS_NOTI_TYPE_TODO,
CALS_NOTI_TYPE_CALENDAR,
}cals_noti_type;
*/
typedef enum
{
- CAL_EVENT_NONE=0, /**< None type */
- CAL_EVENT_SCHEDULE_TYPE, /**< schedule event type */
- CAL_EVENT_TODO_TYPE, /**< task event type */
- CAL_EVENT_MEMO_TYPE, /**< memo event type */
- CAL_EVENT_MAX_TYPE, /**< max type */
-} cal_event_type_t;
+ CALS_SCH_TYPE_NONE=0, /**< None type */
+ CALS_SCH_TYPE_EVENT, /**< schedule event type */
+ CALS_SCH_TYPE_TODO, /**< task event type */
+ CALS_SCH_TYPE_MAX, /**< max type */
+} cals_sch_type;
/**
CAL_STARTING_DAY_MONDAY /**< starting day is monday */
} cal_starting_day_type_t;
-
-typedef enum
-{
- CAL_TIME_ZONE_GMT_L11,
- CAL_TIME_ZONE_GMT_L10,
- CAL_TIME_ZONE_GMT_L9,
- CAL_TIME_ZONE_GMT_L8,
- CAL_TIME_ZONE_GMT_L7,
- CAL_TIME_ZONE_GMT_L6,
- CAL_TIME_ZONE_GMT_L5,
- CAL_TIME_ZONE_GMT_L45,
- CAL_TIME_ZONE_GMT_L4,
- CAL_TIME_ZONE_GMT_L35,
- CAL_TIME_ZONE_GMT_L3,
- CAL_TIME_ZONE_GMT_L2,
- CAL_TIME_ZONE_GMT_L1,
- CAL_TIME_ZONE_GMT_0,
- CAL_TIME_ZONE_GMT_1,
- CAL_TIME_ZONE_GMT_2,
- CAL_TIME_ZONE_GMT_3,
- CAL_TIME_ZONE_GMT_35,
- CAL_TIME_ZONE_GMT_4,
- CAL_TIME_ZONE_GMT_45,
- CAL_TIME_ZONE_GMT_5,
- CAL_TIME_ZONE_GMT_55,
- CAL_TIME_ZONE_GMT_575,
- CAL_TIME_ZONE_GMT_6,
- CAL_TIME_ZONE_GMT_65,
- CAL_TIME_ZONE_GMT_7,
- CAL_TIME_ZONE_GMT_8,
- CAL_TIME_ZONE_GMT_9,
- CAL_TIME_ZONE_GMT_95,
- CAL_TIME_ZONE_GMT_10,
- CAL_TIME_ZONE_GMT_11,
- CAL_TIME_ZONE_GMT_12,
- CAL_TIME_ZONE_GMT_13,
-
- CAL_TIME_ZONE_COUNT_MAX
-}cal_time_zone_t;
-
-/**
- * This structure stores the information whether there is an event on specific month
- * event_info description.
- * 0 : none.
- * 1 : event start or one day's event.
- * 2 : event not start and not end date , if 3 more days event than, 12223
- * 3 : event end
- * 4 : repeated event's start & end date is duplicated.
- */
-typedef struct
-{
- int index; /**< index of event */
- cal_sch_category_t cal_type; /**< category type */
- int all_day_event; /***< this event is all day event or not */
- struct tm start_date_time[MAX_REPEAT_OF_A_WEEK];
- struct tm end_date_time[MAX_REPEAT_OF_A_WEEK];
- int repeat_event_count;
- //int event_info[ DAY_OF_A_WEEK ]; /**< event info in a month 0-none */
-}cal_weekly_event_info_t;
-
-/**
- * This structure stores the information whether there is an event on specific month.
- */
-typedef struct
-{
- int year; /**< Specifies a year */
- int month; /**< Specifies a month */
- bool exist[CAL_DAY_CNT_MAX]; /**< There can be an event or not on specific date */
-}cal_event_info_t; /* Event data info for calendar */
-
-/**
- * This structure stores the information whether there is an event on specific month.
- */
-typedef struct
-{
- int year; /**< Specifies a year */
- int month; /**< Specifies a month */
- int index; /**< index of event */
- int event_info[CAL_DAY_CNT_MAX]; /**< event info in a month 0-none, 1-has */
-}cal_monthly_event_info_t;
-
/**
* This structure defines schedule information.
*/
{
int index; /**< Record index */
int account_id; /**< Account_id */
- cal_event_type_t cal_type; /**< Calendar event type */
- cal_sch_category_t sch_category; /**< Category of schedule */
+ cals_sch_type cal_type; /**< Calendar event type */
char *summary; /**< Summary, appointment, task: subject, birthday:Name */
char *description; /**< Description,appointment, task: description, anniversary,holiday:occasion*/
char *location; /**< Location */
- GList *meeting_category; /**< collection of categories */
- bool all_day_event; /**< All day event flag */
- struct tm start_date_time; /**< schedule:start time, anniv,holiday,birthday,memo,todo: date */
- struct tm end_date_time; /**< end time */
+ char *categories;
+ char *exdate;
GList *alarm_list;
- cal_repeat_term_t repeat_term; /**< Repeat term */
- int repeat_interval; /**< Interval of repeat term */
- int repeat_until_type; /**< repeat until type */
- int repeat_occurrences; /**< occurrences of repeat */
- struct tm repeat_end_date; /**< End date for repeat */
- cal_date_type_t sun_moon; /**< Using sun or lunar calendar */
- cal_starting_day_type_t week_start; /**< Start day of a week */
- char *week_flag;//[DAY_OF_A_WEEK + 1]; /**< Indicate which day is select in a week */
- int day_date; /**< 0- for weekday(sun,mon,etc.), 1- for specific day(1,2.. Etc) */
- struct tm last_modified_time; /**< for PC Sync */
bool missed; /**< Miss alarm flag */
cals_status_t task_status; /**< current task status */
cal_priority_t priority; /**< Priority */
char *organizer_email; /**< ACS, G : Email of organizer */
calendar_type_t calendar_type; /**< ACS, G : Type(all,phone,google) of calendar */
char *gcal_id; /**< G : Server id of calendar */
- bool deleted; /**< G : Flag for deleted */
char *updated; /**< G : Updated time stamp */
int location_type; /**< G : Location type */
char *location_summary; /**< G : A simple string value that can be used as a representation of this location */
int original_event_id; /**< original event id for recurrency exception */
double latitude;
double longitude;
- char *tz_name;
- char *tz_city_name;
- int is_deleted;
int email_id;
int availability;
- struct tm created_date_time; /**< created time */
- struct tm completed_date_time; /**< completed time */
+ long long int created_time;
+ long long int completed_time;
int progress;
+ int is_deleted; /**< for sync */
+ int dtstart_type;
+ long long int dtstart_utime;
+ int dtstart_year;
+ int dtstart_month;
+ int dtstart_mday;
+ char *dtstart_tzid;
+ int dtend_type;
+ long long int dtend_utime;
+ int dtend_year;
+ int dtend_month;
+ int dtend_mday;
+ char *dtend_tzid;
+ int duration;
+ long long int last_mod;
+ 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;
+ int count;
+ int interval;
+ char *bysecond;
+ char *byminute;
+ char *byhour;
+ char *byday;
+ char *bymonthday;
+ char *byyearday;
+ char *byweekno;
+ char *bymonth;
+ char *bysetpos;
+ int wkst;
}cal_sch_full_t;
/**
- * This structure defines schedule information.
- */
-typedef struct
-{
- int index; /**< Record index */
- cal_event_type_t cal_type; /**< Calendar event type */
- cal_sch_category_t sch_category; /**< Category of schedule */
-
- char *summary; /**< Summary, appointment, task: subject, birthday:Name */
- char *description; /**< Description,appointment, task: description, anniversary,holiday:occasion*/
- char *location; /**< Location */
-
- bool all_day_event; /**< All day event flag */
- struct tm start_date_time; /**< schedule:start time, anniv,holiday,birthday,memo,todo: date */
- struct tm end_date_time; /**< end time */
- struct tm alarm_time; /**< alarm time */
- int remind_tick; /**< Alarms before remindTick */
- cal_sch_remind_tick_unit_t remind_tick_unit; /**< Remind tick unit */
- int alarm_id; /**< Alarm id */
-
- cal_repeat_term_t repeat_term; /**< Repeat term */
- int repeat_interval; /**< Interval of repeat term */
- int repeat_until_type; /**< Repeat until type */
- struct tm repeat_end_date; /**< End date for repeat */
- cal_date_type_t sun_moon; /**< Using sun or lunar calendar */
- cal_starting_day_type_t week_start; /**< Start day of a week */
- char *week_flag; /**< Indicate which day is select in a week */
- int day_date; /**< 0- for weekday(sun,mon,etc.), 1- for specific day(1,2.. Etc) */
- bool missed; /**< Miss alarm flag */
-
- int participant_id; /**<contact id for participant*/
- calendar_type_t calendar_type; /**<one type of calendar */
- cal_time_zone_t timezone; /**< timezone of task */
- int dst; /**< dst of event */
- int is_deleted;
-}cal_sch_t;
-
-/**
* This structure defines participant information of a meetting.
* ical: cutype, member, role, partstat, rsvp, delto, delfrom, sentby, cn, dir, language
*/
}cal_participant_info_t;
/**
- * This structure defines category information of a meetting.
- */
-typedef struct
-{
- int event_id;
- char *category_name;
-}cal_category_info_t;
-
-/**
- * This structure defines exception information of recurrence event.
- */
-typedef struct
-{
- cal_sch_full_t *exception_record;
- struct tm exception_start_time;
- int is_modified;
- int event_id;
-}cal_exception_info_t;
-
-/**
* This structure defines exception information of alarm.
*/
typedef struct
/* audio */
/* -- trigger */
- struct tm alarm_time;
+ long long int alarm_time;
int remind_tick;
cal_sch_remind_tick_unit_t remind_tick_unit;
/* --attach */
}cal_alarm_info_t;
-
-/**
- * This structure stores record and its repeat type.
- * repeat_type / include original data / include repeated data / repeated schedule or not
- * 1 o x o
- * 2 o o o
- * 3 x o o
- * 4 o x x (just one day event )
- * 5 o x x ( more than two days )
- */
-typedef struct
-{
- cal_sch_t record; /**< event record */
- cal_event_type_t repeat_type; /**< repeat type as above, 1-5 */
-}cal_period_record_t;
-
-/**
- * @enum cal_search_repeat_term_t
- * This enumeration defines Repeat term.
- */
-typedef enum
-{
- CAL_SEARCH_REPEAT_INVALID = -1, /**< Invalid Repeat */
- CAL_SEARCH_REPEAT_NONE = 0, /**< never Repeat */
- CAL_SEARCH_REPEAT_EVERY_DAY, /**< Repeats every day */
- CAL_SEARCH_REPEAT_EVERY_WEEK, /**< Repeats every week */
- CAL_SEARCH_REPEAT_EVERY_MONTH, /**< Repeats every month */
- CAL_SEARCH_REPEAT_EVERY_YEAR, /**< Repeats every year */
- CAL_SEARCH_REPEAT_EVERY_WEEKDAYS, /**< Repeats every weekdays *//* same with CAL_REPEAT_EVERY_WEEK, but week_flag="0111110", day_date=1, sun_moon=0, week_start=0 */
- CAL_SEARCH_REPEAT_EVERY_MONTH_DAY, /**< Repeats every month's week days *//* same with CAL_REPEAT_EVERY_MONTH, but week_flag="1000000"~"0000001", day_date=0, sun_moon=0, week_start=0 */
- CAL_SEARCH_REPEAT_EVERY_YEAR_DAY, /**< Repeats every year's month week days *//* same with CAL_REPEAT_EVERY_YEAR, but week_flag="1000000"~"0000001", day_date=0, sun_moon=0, week_start=0 */
-} cal_search_repeat_term_t;
-
-
-typedef struct
-{
- int index; /**< Record index */
- char summary[CAL_SCH_SUMMARY_LEN_MAX + 1]; /**< Summary, appointment, task: subject, birthday:Name */
- char description[CAL_SCH_DESCRIPTION_LEN_MAX + 1]; /**< Description,appointment, task: description, anniversary,holiday:occasion*/
- struct tm start_date_time; /**< schedule:start time, anniv,holiday,birthday,memo,todo: date */
- struct tm end_date_time; /**< end time */
- int alarmed; /**< Indicates whether an alarm is to be activated for the event */
- struct tm alarm_time; /**< alarm time */
- cal_search_repeat_term_t eventRecurrence; /**< Recurrent interval of this event. */
-}cal_record_search_field;
-
-
//This is the calendar schema
typedef struct
{
int day_light_bias;
} cal_timezone_t;
+typedef struct
+{
+ int index;
+ int dtstart_type;
+ long long int dtstart_utime;
+ int dtend_type;
+ long long int dtend_utime;
+} cals_struct_period_normal_onoff;
+
+typedef struct
+{
+ int index;
+ int dtstart_type;
+ int dtstart_year;
+ int dtstart_month;
+ int dtstart_mday;
+ int dtend_type;
+ int dtend_year;
+ int dtend_month;
+ int dtend_mday;
+} cals_struct_period_allday_onoff;
+
+typedef struct
+{
+ int index;
+ int dtstart_type;
+ long long int dtstart_utime;
+ int dtend_type;
+ long long int dtend_utime;
+ char *summary;
+ char *location;
+} cals_struct_period_normal_basic;
+
+typedef struct
+{
+ int index;
+ int dtstart_type;
+ int dtstart_year;
+ int dtstart_month;
+ int dtstart_mday;
+ int dtend_type;
+ int dtend_year;
+ int dtend_month;
+ int dtend_mday;
+ char *summary;
+ char *location;
+} cals_struct_period_allday_basic;
+
+typedef struct
+{
+ int index;
+ int calendar_id;
+ int dtstart_type;
+ long long int dtstart_utime;
+ int dtend_type;
+ long long int dtend_utime;
+ char *summary;
+ char *description;
+ char *location;
+ int busy_status;
+ int meeting_status;
+ int priority;
+ int sensitivity;
+ int rrule_id;
+} cals_struct_period_normal_osp;
+
+typedef struct
+{
+ int index;
+ 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;
+ char *summary;
+ char *description;
+ char *location;
+ int busy_status;
+ int meeting_status;
+ int priority;
+ int sensitivity;
+ int rrule_id;
+} cals_struct_period_allday_osp;
+
+typedef struct
+{
+ int index;
+ int calendar_id;
+ int dtstart_type;
+ long long int dtstart_utime;
+ int dtend_type;
+ long long int dtend_utime;
+ char *summary;
+ char *description;
+ char *location;
+ int busy_status;
+ int meeting_status;
+ int priority;
+ int sensitivity;
+ int rrule_id;
+ double latitude;
+ double longitude;
+} cals_struct_period_normal_location;
+
+typedef struct
+{
+ int index;
+ 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;
+ char *summary;
+ char *description;
+ char *location;
+ int busy_status;
+ int meeting_status;
+ int priority;
+ int sensitivity;
+ int rrule_id;
+ double latitude;
+ double longitude;
+} cals_struct_period_allday_location;
+
+typedef struct
+{
+ int index;
+ 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;
+}cals_struct_period_normal_alarm;
+
/**
* @}
*/
+++ /dev/null
-/*
- * Calendar Service
- *
- * Copyright (c) 2000 - 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.
- *
- */
-#include <time.h>
-#include <sys/types.h>
-#include <vconf.h>
-#include <stdlib.h>
-
-#include "cals-internal.h"
-#include "cals-tz-utils.h"
-
-struct tm cal_tm_value = {0};
-
-struct tm* cals_tmtime(time_t *sec)
-{
- struct tm* temp = gmtime_r(sec,&cal_tm_value);
-
- if(temp)
- return &cal_tm_value;
- else
- return NULL;
-}
-
-time_t cals_mktime(struct tm *date_time)
-{
- return timegm(date_time);
-}
-
-struct tm* cals_tmtime_r(time_t *ttTime, struct tm *tmTime)
-{
- struct tm* pTmTime = NULL;
- retvm_if(NULL == ttTime, NULL,"ttTime is NULL");
- retvm_if(NULL == tmTime, NULL,"tmTime is NULL");
-
- pTmTime = (struct tm*)cals_tmtime(ttTime);
- memcpy(tmTime,pTmTime,sizeof(struct tm));
- return pTmTime;
-}
-
-static bool _get_tz_path(const char *city, char **tz_path)
-{
- int left = 0;
- int right = sizeof(time_zone_array)/sizeof(Time_Zone) -1;
- int index = 0;
- int result = 0;
- int max_count = right;
-
-
- while(true)
- {
- index = ( left + right ) / 2;
-
- result = strcmp(time_zone_array[index].city, city);
-
- if(result == 0)
- {
- *tz_path = strdup(time_zone_array[index].tz_path);
- }
- else if(result < 0)
- left = index+1;
- else
- right = index-1;
-
- if(left <0 || left >max_count)
- goto error;
- if(right <0 || right >max_count)
- goto error;
- if(left > right)
- goto error;
-
- }
-
- if(*tz_path == NULL)
- return false;
- else
- return true;
-error:
- *tz_path = NULL;
- return false;
-}
-
-
-char *cals_tzutil_get_tz_path(void)
-{
- int lock_on;
- char *tz_path;
- char *city;
- bool ret;
-
- tz_path = NULL;
- lock_on = 0;
-
- vconf_get_int("db/calendar/timezone_on_off", &lock_on);
-
- if (lock_on) {
- tz_path = vconf_get_str("db/calendar/timezone_path");
- return tz_path;
- }
-
- city = vconf_get_str(VCONFKEY_SETAPPL_CITYNAME_INDEX_INT);
-
- if (!city)
- return NULL;
-
- ret = _get_tz_path(city, &tz_path);
- free(city);
-
- if (ret)
- return tz_path;
-
- return strdup("localtime");
-}
-
-
+++ /dev/null
-/*
- * Calendar Service
- *
- * Copyright (c) 2000 - 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 __CALENDAR_SVC_TZ_UTILS_H__
-#define __CALENDAR_SVC_TZ_UTILS_H__
-
-typedef struct _Time_Zone Time_Zone;
-struct _Time_Zone
-{
- char *city;
- char *country;
- char *gmt;
- char *tz_path;
-};
-
-static const Time_Zone time_zone_array[] =
-{
-{"Abidjan", "Ivory Coast", "GMT+0", "Africa/Abidjan"},
-{"Abu Dhabi", "United Arab Emirates", "GMT+4", "Asia/Dubai"},
-{"Accra", "Ghana", "GMT-10", "Africa/Accra"},
-{"Addis Ababa", "Ethiopia", "GMT+3", "Africa/Addis_Ababa"},
-{"Adelaide", "Australia", "GMT+9:30", "Australia/Adelaide"},
-{"Alaska", "United States of America", "GMT-9", "America/Nome"},
-{"Algiers", "Algeria", "GMT+1", "Africa/Algiers"},
-{"Almaty", "Kazakhstan", "GMT+6", "Asia/Almaty"},
-{"Ambon", "Indonesia", "GMT+1", "Asia/Jayapura"},
-{"Amman", "Jordan", "GMT+2", "Asia/Amman"},
-{"Amsterdam", "Netherlands", "GMT+1", "Europe/Amsterdam"},
-{"Anadyr", "Russia ", "GMT+12", "Asia/Anadyr"},
-{"Anchorage", "United States of America", "GMT-9", "America/Anchorage"},
-{"Ankara", "Turkey", "GMT+2", "Asia/Istanbul"},
-{"Antananarivo", "Madagascar", "GMT+3", "Indian/Antananarivo"},
-{"Ashgabat", "Turkmenistan", "GMT+5", "Asia/Ashgabat"},
-{"Asmera", "Eritrea", "GMT+3", "Africa/Asmara" /* not in zone.tab */ },
-{"Astana", "Kazakhstan", "GMT+6", "Asia/Almaty" /* not in zone.tab */ },
-{"Asuncion", "Paraguay", "GMT-4", "America/Asuncion"},
-{"Athens", "Greece", "GMT+2", "Europe/Athens"},
-{"Auckland", "New Zealand", "GMT+12", "Pacific/Auckland"},
-{"Austin", "United States of America", "GMT-6", "CST6CDT"},
-{"Azores", "Portugal", "GMT-1", "Atlantic/Azores"},
-{"Baghdad", "Iraq", "GMT+3", "Asia/Baghdad"},
-{"Baku", "Azerbaijan", "GMT+4", "Asia/Baku"},
-{"Baltimore", "United States of America", "GMT-5", "EST5EDT"},
-{"Bamako", "Mali", "GMT+0", "Africa/Bamako"},
-{"Bangkok", "Thailand", "GMT+7", "Asia/Bangkok"},
-{"Bangui", "Central African Republic", "GMT+1", "Africa/Bangui"},
-{"Barcelona", "Spain", "GMT+2", "Europe/Madrid"},
-{"Bari", "Italy", "GMT+1", "Europe/Rome"},
-{"Basse-Terre", "Guadeloupe", "GMT-4", "America/Guadeloupe"},
-{"Beijing", "China", "GMT+8", "Asia/Shanghai"},
-{"Beirut", "Lebanon", "GMT+2", "Asia/Beirut"},
-{"Belgrade", "Serbia", "GMT+1", "Europe/Belgrade"},
-{"Belize City", "Belize", "GMT-6", "America/Belize"},
-{"Berlin", "Germany", "GMT+1", "Europe/Berlin"},
-{"Bern", "Switzerland", "GMT+1", "Europe/Zurich"},
-{"Bishkek", "Kyrgyzstan", "GMT+6", "Asia/Bishkek"},
-{"Bissau", "Guinea Bissau", "GMT+0", "Africa/Bissau"},
-{"Bogota", "Colombia", "GMT-5", "America/Bogota"},
-{"Bologna", "Italy", "GMT+1", "Europe/Rome"},
-{"Boston", "United States of America", "GMT-5", "EST5EDT"},
-{"Brasilia", "Brazil", "GMT-3", "America/Sao_Paulo"},
-{"Bratislava", "Slovakia", "GMT+2", "Europe/Bratislava"},
-{"Bridgetown", "Barbados", "GMT-4", "America/Barbados"},
-{"Brisbane", "Australia", "GMT+10", "Australia/Brisbane"},
-{"Brussels", "Belgium", "GMT+1", "Europe/Brussels"},
-{"Bucharest", "Romania", "GMT+3", "Europe/Bucharest"},
-{"Budapest", "Hungary", "GMT+1", "Europe/Budapest"},
-{"Buenos Aires", "Argentina", "GMT-3", "America/Argentina/Buenos_Aires"},
-{"Cairo", "Egypt", "GMT+2", "Africa/Cairo"},
-{"Calgary", "Canada", "GMT-7", "MST7MDT"},
-{"Canary Islands", "Spain", "GMT+0", "Atlantic/Canary"},
-{"Canberra", "Australia", "GMT+10", "Australia/Canberra"},
-{"Canton", "China", "GMT+8", "Asia/Shanghai"},
-{"Cape Town", "Republic of South Africa", "GMT+2", "Africa/Johannesburg"},
-{"Caracas", "Venezuela", "GMT-4:30", "America/Caracas"},
-{"Cardiff", "Wales", "GMT+0", "Europe/London"},
-{"Casablanca", "Morocco", "GMT+0", "Africa/Casablanca"},
-{"Catanzaro", "Italy", "GMT+1", "Europe/Rome"},
-{"Cayenne", "French Guiana", "GMT-3", "America/Cayenne"},
-{"Charlotte", "United States of America", "GMT-5", "EST5EDT"},
-{"Charlotte Amalie", "United States Virgin Islands ", "GMT-5:30", "America/St_Thomas"},
-{"Chelyabinsk", "Russia ", "GMT+5", "Asia/Yekaterinburg"},
-{"Chennai", "India", "GMT+5:30", "Asia/Kolkata"},
-{"Chicago", "United States of America", "GMT-6", "America/Chicago"},
-{"Chisinau", "Moldova", "GMT+2", "Europe/Chisinau"},
-{"Chita", "Russia", "GMT+9", "Asia/Yakutsk"},
-{"Cleveland", "United States of America", "GMT-5", "EST5EDT"},
-{"Colombo", "Sri Lanka", "GMT+5:30", "Asia/Colombo"},
-{"Columbus", "United States of America", "GMT-5", "EST5EDT"},
-{"Conakry", "Guinea", "GMT+1", "Africa/Conakry"},
-{"Copenhagen", "Denmark", "GMT+1", "Europe/Copenhagen"},
-{"Cork", "Ireland", "GMT+0", "Europe/Dublin"},
-{"Crotone", "Italy", "GMT+1", "Europe/Rome"},
-{"Dakar", "Senegal", "GMT+0", "Africa/Dakar"},
-{"Dallas", "United States of America", "GMT-6", "CST6CDT"},
-{"Damascus", "Syria", "GMT+2", "Asia/Damascus"},
-{"Dar es Salaam", "Tanzania", "GMT+3", "Africa/Dar_es_Salaam"},
-{"Darwin", "Australia", "GMT+9:30", "Australia/Darwin"},
-{"Delhi", "India", "GMT+5:30", "Asia/Kolkata"},
-{"Denpasar", "Indonesia", "GMT+8", "Asia/Makassar"},
-{"Denver", "United States of America", "GMT-7", "America/Denver"},
-{"Detroit", "United States of America", "GMT-5", "America/Detroit"},
-{"Dhaka", "Bangladesh", "GMT+6", "Asia/Dhaka"},
-{"Diego Garcia", "United Kingdom", "GMT+5", "Indian/Chagos" /* not in zone.tab */ },
-{"Djibouti", "Djibouti", "GMT+3", "Africa/Djibouti"},
-{"Doha", "Qatar", "GMT+3", "Asia/Qatar"},
-{"Douala", "Cameroon", "GMT+1", "Africa/Douala"},
-{"Dubai", "United Arab Emirates", "GMT+4", "Asia/Dubai"},
-{"Dublin", "Ireland", "GMT+0", "Europe/Dublin"},
-{"Dushanbe", "Tajikistan", "GMT+5", "Asia/Dushanbe"},
-{"Easter Island", "Chile", "GMT-6", "Pacific/Easter"},
-{"Edinburgh", "Scotland", "GMT+0", "Europe/London"},
-{"El Paso", "United States of America", "GMT-7", "MST7MDT"},
-{"Florence", "Italy", "GMT+1", "Europe/Rome"},
-{"Fort-de-France", "Martinique", "GMT-4", "America/Martinique"},
-{"Freetown", "Sierra Leone", "GMT+0", "Africa/Freetown"},
-{"Gaborone", "Botswana", "GMT+2", "Africa/Gaborone"},
-{"Galapagos Islands", "Ecuador", "GMT-7", "Pacific/Galapagos"},
-{"Geneva", "Switzerland", "GMT+1", "Europe/Paris"},
-{"Genoa", "Italy", "GMT+1", "Europe/Rome"},
-{"Georgetown", "Guyana", "GMT-4", "America/Guyana"},
-{"Grytviken", "South Georgia", "GMT-2", "Atlantic/South_Georgia"},
-{"Guam", "United States of America", "GMT+10", "Pacific/Guam"},
-{"Guatemala City", "Guatemala", "GMT-6", "America/Guatemala"},
-{"Gustavia", "Saint Barthelemy", "GMT-4", "America/Antigua"},
-{"Halifax", "Canada", "GMT-4", "America/Halifax"},
-{"Hamburg", "Germany", "GMT+1", "Europe/Berlin"},
-{"Hanoi", "Vietnam", "GMT+7", "Asia/Ho_Chi_Minh"},
-{"Harare", "Zimbabwe", "GMT+2", "Africa/Harare"},
-{"Havana", "Cuba", "GMT-5", "America/Havana"},
-{"Hawaii", "United States of America", "GMT-10", "Pacific/Honolulu"},
-{"Helsinki", "Finland", "GMT+2", "Europe/Helsinki"},
-{"Hobart", "Australia", "GMT+10", "Australia/Hobart"},
-{"Hong Kong", "China", "GMT+8", "Asia/Hong_Kong"},
-{"Honolulu", "United States of America", "GMT-10", "Pacific/Honolulu"},
-{"Houston", "United States of America", "GMT-6", "CST6CDT"},
-{"Hovd", "Mongolia", "GMT+8", "Asia/Hovd"},
-{"Indianapolis", "United States of America", "GMT-5", "America/Indiana/Indianapolis"},
-{"Irkutsk", "Russia ", "GMT+8", "Asia/Irkutsk"},
-{"Islamabad", "Pakistan", "GMT+5", "Asia/Karachi"},
-{"Istanbul", "Turkey", "GMT+2", "Europe/Istanbul"},
-{"Izhevsk", "Russia ", "GMT+4", "Europe/Moscow"},
-{"Jakarta", "Indonesia", "GMT+7", "Asia/Jakarta"},
-{"Jeddah", "Saudi Arabia", "GMT+3", "Asia/Riyadh"},
-{"Jerusalem", "Israel", "GMT+2", "Asia/Jerusalem"},
-{"Johannesburg", "South Africa", "GMT+2", "Africa/Johannesburg"},
-{"Kabul", "Afghanistan", "GMT+4:30", "Asia/Kabul"},
-{"Kaliningrad", "Russia", "GMT+2", "Europe/Kaliningrad"},
-{"Kamchatka", "Russia ", "GMT+12", "Asia/Kamchatka"},
-{"Kampala", "Uganda", "GMT+3", "Africa/Kampala"},
-{"Karachi", "Pakistan", "GMT+5", "Asia/Karachi"},
-{"Kathmandu", "Nepal", "GMT+5:45", "Asia/Kathmandu"},
-{"Khabarovsk", "Russia ", "GMT+10", "Asia/Vladivostok"},
-{"Kharkiv", "Ukraine", "GMT+2", "Europe/Kiev"},
-{"Khartoum", "Sudan", "GMT+3", "Africa/Khartoum"},
-{"Kiev", "Ukraine", "GMT+2", "Europe/Kiev"},
-{"Kingston", "Canada", "GMT-5", "America/Toronto"}, /* not in zone.tab */
-{"Kingston", "Jamaica", "GMT-5", "America/Jamaica"},
-{"Kinshasa", "Democratic Republic of the Congo", "GMT+1", "Africa/Kinshasa"},
-{"Kolkata", "India", "GMT+5:30", "Asia/Kolkata"},
-{"Krasnoyarsk", "Russia ", "GMT+7", "Asia/Krasnoyarsk"},
-{"Kuala Lumpur", "Malaysia", "GMT+8", "Asia/Kuala_Lumpur"},
-{"Kuwait", "Kuwait", "GMT+3", "Asia/Kuwait"},
-{"Kyiv", "Ukraine", "GMT+2", "Europe/Kiev" /* not in zone.tab */ },
-{"Los Angeles", "United States of America", "GMT-7", "America/Los_Angeles"},
-{"La Paz", "Bolivia", "GMT-4", "America/La_Paz"},
-{"Lagos", "Nigeria", "GMT+1", "Africa/Lagos"},
-{"Las Vegas", "United States of America", "GMT-8", "PST8PDT"},
-{"Lima", "Peru", "GMT-5", "America/Lima"},
-{"Lisbon", "Portugal", "GMT+0", "Europe/Lisbon"},
-{"Ljubljana", "Slovakia", "GMT+1", "Europe/Ljubljana"},
-{"London", "United Kingdom", "GMT+0", "Europe/London"},
-{"Longhua", "China", "GMT+8", "Asia/Shanghai"},
-{"Louisville", "United States of America", "GMT-5", "America/Kentucky/Louisville"},
-{"Luanda", "Angola", "GMT+1", "Africa/Luanda"},
-{"Lubumbashi", "Democratic Republic of the Congo", "GMT+2", "Africa/Lubumbashi"},
-{"Lusaka", "Zambia", "GMT+2", "Africa/Lusaka"},
-{"Luxembourg", "Luxembourg", "GMT+1", "Europe/Luxembourg"},
-{"Lviv", "Ukraine", "GMT+2", "Europe/Kiev"},
-{"Macau", "China", "GMT+8", "Asia/Macau"},
-{"Madrid", "Spain", "GMT+2", "Europe/Madrid"},
-{"Magadan", "Russia ", "GMT+11", "Asia/Magadan"},
-{"Malabo", "Equaorial Guinea", "GMT+1", "Africa/Malabo"},
-{"Male", "Maldives", "GMT+5", "Indian/Maldives"},
-{"Managua", "Nicaragua", "GMT-6", "America/Managua"},
-{"Manama", "Bahrain", "GMT+3", "Asia/Bahrain"},
-{"Manila", "Philippines", "GMT+8", "Asia/Manila"},
-{"Maputo", "Mozambique", "GMT+2", "Africa/Maputo"},
-{"Marigot", "Saint Martin", "GMT-4", "America/Marigot"},
-{"Mazatlan", "Mexico", "GMT-7", "America/Mazatlan"},
-{"Mecca", "Saudi Arabia", "GMT+3", "Asia/Riyadh"},
-{"Melbourne", "Australia", "GMT+10", "Australia/Melbourne"},
-{"Memphis", "United States of America", "GMT-6", "CST6CDT"},
-{"Messina", "Italy", "GMT+1", "Europe/Rome"},
-{"Mexico City", "Mexico", "GMT-6", "America/Mexico_City"},
-{"Miami", "United States of America", "GMT-5", "EST5EDT"},
-{"Mid-Atlantic", "United States of America", "GMT-2", "America/New_York" /* not in zone.tab */ },
-{"Midway Atoll", "United States of America", "GMT-11", "Pacific/Midway"},
-{"Milan", "Italy", "GMT+1", "Europe/Rome"},
-{"Milwaukee", "United States of America", "GMT-6", "CST6CDT"},
-{"Minsk", "Belarus", "GMT+2", "Europe/Minsk"},
-{"Mogadishu", "Somalia", "GMT+2", "Africa/Mogadishu"},
-{"Monrovia", "Liberia", "GMT+0", "Africa/Monrovia"},
-{"Montevideo", "Uruguay", "GMT-3", "America/Montevideo"},
-{"Montreal", "Canada", "GMT-5", "America/Montreal"},
-{"Moscow", "Russia ", "GMT+3", "Europe/Moscow"},
-{"Mumbai", "India", "GMT+5:30", "Asia/Kolkata"},
-{"Munich", "Germany", "GMT+1", "Europe/Berlin"},
-{"Muscat", "Oman", "GMT+4", "Asia/Muscat"},
-{"Nairobi", "Kenya", "GMT+3", "Africa/Nairobi"},
-{"Naples", "Italy", "GMT+1", "Europe/Rome"},
-{"Naters", "Switzerland", "GMT+1", "Europe/Zurich"},
-{"Ndjamena", "Chad", "GMT+1", "Africa/Ndjamena"},
-{"New Delhi", "India", "GMT+5:30", "Asia/Kolkata" /* not in zone.tab */ },
-{"New York", "United States of America", "GMT-4", "America/New_York"},
-{"Newfoundland", "Canada", "GMT-3:30", "America/St_Johns"},
-{"Niamey", "Niger", "GMT+1", "Africa/Niamey"},
-{"Nouakchott", "Mauritania", "GMT+1", "Africa/Nouakchott"},
-{"Noumea", "New Caledonia", "GMT+11", "Pacific/Noumea"},
-{"Novokuznetsk", "Russia", "GMT+7", "Asia/Novokuznetsk"},
-{"Novosibirsk", "Russia", "GMT+6", "Asia/Novosibirsk"},
-{"Nuku'alofa", "Tonga", "GMT+13", "Pacific/Tongatapu"},
-{"Nuuk", "Greenland", "GMT-3", "America/Godthab"},
-{"Omsk", "Russia", "GMT+6", "Asia/Omsk"},
-{"Osaka", "Japan", "GMT+9", "Asia/Tokyo"},
-{"Ottawa", "Canada", "GMT-5", "EST5EDT"},
-{"Ouagadougou", "Burkina Faso", "GMT+0", "Africa/Ouagadougou"},
-{"Pago Pago", "Independent State of Samoa", "GMT-11", "Pacific/Pago_Pago"},
-{"Palermo", "Italy", "GMT+1", "Europe/Rome"},
-{"Panama City", "Panama", "GMT-6", "America/Panama"},
-{"Paramaribo", "Surinam", "GMT-3", "America/Paramaribo"},
-{"Paris", "France", "GMT+1", "Europe/Paris"},
-{"Perm", "Russia", "GMT+5", "Asia/Yekaterinburg"},
-{"Perth", "Australia", "GMT+8", "Australia/Perth"},
-{"Petropavlovsk-Kamchatskiy", "Russia ", "GMT+12", "Asia/Kamchatka"},
-{"Philadelphia", "United States of America", "GMT-5", "EST5EDT"},
-{"Phnom Penh ", "Cambodia", "GMT-5", "Asia/Phnom_Penh"},
-{"Phoenix", "United States of America", "GMT-7", "America/Phoenix"},
-{"Podgorica", "Montenegro", "GMT+1", "Europe/Podgorica"},
-{"Ponta Delgada", "Portugal", "GMT-1", "Atlantic/Azores"},
-{"Port Louis", "Mauritius", "GMT+4", "Indian/Mauritius"},
-{"Port-au-Prince", "Haiti", "GMT-5", "America/Port-au-Prince"},
-{"Portland", "United States of America", "GMT-8", "PST8PDT"},
-{"Prague", "Czech Republic", "GMT+1", "Europe/Prague"},
-{"Pyongyang", "North Korea", "GMT+9", "Asia/Pyongyang"},
-{"Quito", "Ecuador", "GMT-5", "America/Guayaquil"},
-{"Rabat", "Morocco", "GMT+0", "Africa/Casablanca"},
-{"Rangoon", "Burma", "GMT+6:30", "Asia/Rangoon"},
-{"Recife", "Brazil", "GMT-3", "America/Recife"},
-{"Regina", "Canada", "GMT-6", "America/Regina"},
-{"Reykjavik", "Iceland", "GMT+0", "Atlantic/Reykjavik"},
-{"Riga", "Latvia", "GMT+2", "Europe/Riga"},
-{"Rio de Janeiro", "Brazil", "GMT-2", "America/Sao_Paulo"},
-{"Riyadh", "Saudi Arabia", "GMT+3", "Asia/Riyadh"},
-{"Rome", "Italy", "GMT+1", "Europe/Rome"},
-{"Saint-Denis", "Reunion Island", "GMT+4", "Indian/Reunion"},
-{"Samara", "Russia ", "GMT+4", "Europe/Samara"},
-{"San Antonio", "United States of America", "GMT-6", "CST6CDT"},
-{"San Diego", "United States of America", "GMT-8", "PST8PDT"},
-{"San Francisco", "United States of America", "GMT-8", "America/Los_Angeles"},
-{"San Jose", "United States of America", "GMT-8", "PST8PDT"},
-{"San Jose", "Costa Rica", "GMT-6", "America/Costa_Rica"},
-{"San Juan", "Puerto Rico", "GMT-4", "America/Puerto_Rico"},
-{"San Marino", "Italy", "GMT+1", "Europe/San_Marino"},
-{"San Salvador", "El Salvador", "GMT-6", "America/El_Salvador"},
-{"Sanaa", "Yemen", "GMT+3", "Asia/Aden" /* not in zone.tab */ },
-{"Santiago", "Chile", "GMT-4", "America/Santiago"},
-{"Santo Domingo", "Dominican Republic", "GMT-4", "America/Santo_Domingo"},
-{"Sao Paulo", "Brazil", "GMT-2", "America/Sao_Paulo"},
-{"Seattle", "United States of America", "GMT-8", "PST8PDT"},
-{"Seoul", "Republic of Korea", "GMT+9", "Asia/Seoul"},
-{"Shanghai", "China", "GMT+8", "Asia/Shanghai"},
-{"Shenzhen", "China", "GMT+8", "Asia/Shanghai"},
-{"Singapore", "Republic of Singapore", "GMT+8", "Asia/Singapore"},
-{"Skopje", "Macedonia", "GMT+1", "Europe/Skopje"},
-{"Sofia ", "Bulgaria", "GMT+3", "Europe/Sofia"},
-{"St. John's", "Antigua and Barbuda", "GMT-4", "America/Antigua"},
-{"St. John's", "Canada", "GMT-3:30", "America/St_Johns"},
-{"St. Petersburg", "Russia", "GMT+3", "Europe/Moscow"},
-{"Stockholm", "Sweden", "GMT+2", "Europe/Stockholm"},
-{"Suva", "Fiji", "GMT+12", "Pacific/Fiji"},
-{"Sydney", "Australia", "GMT+11", "Australia/Sydney"},
-{"Tahiti", "French Polynesia", "GMT-10", "Pacific/Tahiti"},
-{"Taipei", "Taiwan", "GMT+8", "Asia/Taipei"},
-{"Tallinn", "Estonia", "GMT+2", "Europe/Tallinn"},
-{"Tarawa", "Kiribati", "GMT+12", "Pacific/Tarawa"},
-{"Tashkent", "Uzbekistan", "GMT+5", "Asia/Tashkent"},
-{"Tbilisi", "Georgia", "GMT+4", "Asia/Tbilisi"},
-{"Tegucigalpa", "Honduras", "GMT-6", "America/Tegucigalpa"},
-{"Tehran", "Iran", "GMT+3:30", "Asia/Tehran"},
-{"Thanh Pho Ho Chi Minh", "Vietnam", "GMT+7", "Asia/Ho_Chi_Minh"},
-{"The Settlement", "British Virgin Islands ", "GMT-4", "America/Tortola"},
-{"Tientsin", "China", "GMT+8", "Asia/Shanghai" /* not in zone.tab */ },
-{"Tijuana", "Mexico", "GMT-5", "America/Tijuana"},
-{"Tokyo", "Japan", "GMT+9", "Asia/Tokyo"},
-{"Toronto", "Canada", "GMT-4", "America/Toronto"},
-{"Trehet", "France", "GMT+1", "Europe/Paris" /* not in zone.tab */ },
-{"Tripoli", "Libya", "GMT+2", "Africa/Tripoli"},
-{"Tunis", "Tunisia", "GMT+2", "Africa/Tunis"},
-{"Turin", "Italy", "GMT+1", "Europe/Rome"},
-{"Ufa", "Bashkiriya", "GMT+5", "Asia/Yekaterinburg"},
-{"Ulan Bator", "Mongolia", "GMT+8", "Asia/Ulan_Bator"},
-{"Vaduz", "Liechtenstein", "GMT+1", "Europe/Vaduz"},
-{"Valletta", "Malta", "GMT+1", "Europe/Malta"},
-{"Vancouver", "Canada", "GMT-8", "America/Vancouver"},
-{"Verona", "Italy", "GMT+1", "Europe/Rome"},
-{"Victoria", "Seychelles", "GMT+4", "Australia/Melbourne"},
-{"Vienna", "Austria", "GMT+1", "Europe/Vienna"},
-{"Vilnius", "Lithuania", "GMT+3", "Europe/Vilnius"},
-{"Vladivostok", "Russia ", "GMT+10", "Asia/Vladivostok"},
-{"Volgograd", "Russia ", "GMT+4", "Europe/Volgograd"},
-{"Warsaw", "Poland", "GMT+2", "Europe/Warsaw"},
-{"Washington, D.C.", "United States of America", "GMT-5", "EST5EDT"},
-{"Wellington", "New Zealand", "GMT+12", "Pacific/Auckland"},
-{"Winnipeg", "Canada", "GMT-5", "America/Winnipeg"},
-{"Yakutsk", "Russia ", "GMT+9", "Asia/Yakutsk"},
-{"Yamoussoukro", "Ivory Coast", "GMT+0", "Africa/Abidjan"},
-{"Yaounde", "Cameroon", "GMT+1", "Africa/Douala" /* not in zone.tab */ },
-{"Yekaterinburg", "Russia ", "GMT+5", "Asia/Yekaterinburg"},
-{"Yerevan", "Armenia", "GMT+5", "Asia/Yerevan"},
-{"Yuzhno-Sakhalinsk", "Russia ", "GMT+11", "Asia/Sakhalin"},
-{"Zagreb", "Croatia", "GMT+1", "Europe/Zagreb"},
-{"Zurich", "Switzerland", "GMT+1", "Europe/Zurich"},
-{NULL, NULL, NULL, NULL}
-};
-
-static const Time_Zone tz_path_array[] =
-{
-{"Abidjan","Ivory Coast","GMT+0","Africa/Abidjan"},
-{"Yamoussoukro","Ivory Coast","GMT+0","Africa/Abidjan"},
-{"Accra","Ghana","GMT-10","Africa/Accra"},
-{"Addis Ababa","Ethiopia","GMT+3","Africa/Addis_Ababa"},
-{"Algiers","Algeria","GMT+1","Africa/Algiers"},
-{"Asmera","Eritrea","GMT+3","Africa/Asmara "},
-{"Bamako","Mali","GMT+0","Africa/Bamako"},
-{"Bangui","Central African Republic","GMT+1","Africa/Bangui"},
-{"Bissau","Guinea Bissau","GMT+0","Africa/Bissau"},
-{"Cairo","Egypt","GMT+2","Africa/Cairo"},
-{"Casablanca","Morocco","GMT+0","Africa/Casablanca"},
-{"Rabat","Morocco","GMT+0","Africa/Casablanca"},
-{"Conakry","Guinea","GMT+1","Africa/Conakry"},
-{"Dakar","Senegal","GMT+0","Africa/Dakar"},
-{"Dar es Salaam","Tanzania","GMT+3","Africa/Dar_es_Salaam"},
-{"Djibouti","Djibouti","GMT+3","Africa/Djibouti"},
-{"Douala","Cameroon","GMT+1","Africa/Douala"},
-{"Yaounde","Cameroon","GMT+1","Africa/Douala "},
-{"Freetown","Sierra Leone","GMT+0","Africa/Freetown"},
-{"Gaborone","Botswana","GMT+2","Africa/Gaborone"},
-{"Harare","Zimbabwe","GMT+2","Africa/Harare"},
-{"Cape Town","Republic of South Africa","GMT+2","Africa/Johannesburg"},
-{"Johannesburg","South Africa","GMT+2","Africa/Johannesburg"},
-{"Kampala","Uganda","GMT+3","Africa/Kampala"},
-{"Khartoum","Sudan","GMT+3","Africa/Khartoum"},
-{"Kinshasa","Democratic Republic of the Congo","GMT+1","Africa/Kinshasa"},
-{"Lagos","Nigeria","GMT+1","Africa/Lagos"},
-{"Luanda","Angola","GMT+1","Africa/Luanda"},
-{"Lubumbashi","Democratic Republic of the Congo","GMT+2","Africa/Lubumbashi"},
-{"Lusaka","Zambia","GMT+2","Africa/Lusaka"},
-{"Malabo","Equaorial Guinea","GMT+1","Africa/Malabo"},
-{"Maputo","Mozambique","GMT+2","Africa/Maputo"},
-{"Mogadishu","Somalia","GMT+2","Africa/Mogadishu"},
-{"Monrovia","Liberia","GMT+0","Africa/Monrovia"},
-{"Nairobi","Kenya","GMT+3","Africa/Nairobi"},
-{"Ndjamena","Chad","GMT+1","Africa/Ndjamena"},
-{"Niamey","Niger","GMT+1","Africa/Niamey"},
-{"Nouakchott","Mauritania","GMT+1","Africa/Nouakchott"},
-{"Ouagadougou","Burkina Faso","GMT+0","Africa/Ouagadougou"},
-{"Tripoli","Libya","GMT+2","Africa/Tripoli"},
-{"Tunis","Tunisia","GMT+2","Africa/Tunis"},
-{"Anchorage","United States of America","GMT-9","America/Anchorage"},
-{"Gustavia","Saint Barthelemy","GMT-4","America/Antigua"},
-{"St. John's","Antigua and Barbuda","GMT-4","America/Antigua"},
-{"Buenos Aires","Argentina","GMT-3","America/Argentina/Buenos_Aires"},
-{"Asuncion","Paraguay","GMT-4","America/Asuncion"},
-{"Bridgetown","Barbados","GMT-4","America/Barbados"},
-{"Belize City","Belize","GMT-6","America/Belize"},
-{"Bogota","Colombia","GMT-5","America/Bogota"},
-{"Caracas","Venezuela","GMT-4:30","America/Caracas"},
-{"Cayenne","French Guiana","GMT-3","America/Cayenne"},
-{"Chicago","United States of America","GMT-6","America/Chicago"},
-{"San Jose","Costa Rica","GMT-6","America/Costa_Rica"},
-{"Denver","United States of America","GMT-7","America/Denver"},
-{"Detroit","United States of America","GMT-5","America/Detroit"},
-{"San Salvador","El Salvador","GMT-6","America/El_Salvador"},
-{"Nuuk","Greenland","GMT-3","America/Godthab"},
-{"Basse-Terre","Guadeloupe","GMT-4","America/Guadeloupe"},
-{"Guatemala City","Guatemala","GMT-6","America/Guatemala"},
-{"Quito","Ecuador","GMT-5","America/Guayaquil"},
-{"Georgetown","Guyana","GMT-4","America/Guyana"},
-{"Halifax","Canada","GMT-4","America/Halifax"},
-{"Havana","Cuba","GMT-5","America/Havana"},
-{"Indianapolis","United States of America","GMT-5","America/Indiana/Indianapolis"},
-{"Kingston","Jamaica","GMT-5","America/Jamaica"},
-{"Louisville","United States of America","GMT-5","America/Kentucky/Louisville"},
-{"La Paz","Bolivia","GMT-4","America/La_Paz"},
-{"Lima","Peru","GMT-5","America/Lima"},
-{"Los Angeles","United States of America","GMT-7","America/Los_Angeles"},
-{"San Francisco","United States of America","GMT-8","America/Los_Angeles"},
-{"Managua","Nicaragua","GMT-6","America/Managua"},
-{"Marigot","Saint Martin","GMT-4","America/Marigot"},
-{"Fort-de-France","Martinique","GMT-4","America/Martinique"},
-{"Mazatlan","Mexico","GMT-7","America/Mazatlan"},
-{"Mexico City","Mexico","GMT-6","America/Mexico_City"},
-{"Montevideo","Uruguay","GMT-3","America/Montevideo"},
-{"Montreal","Canada","GMT-5","America/Montreal"},
-{"New York","United States of America","GMT-4","America/New_York"},
-{"Mid-Atlantic","United States of America","GMT-2","America/New_York "},
-{"Alaska","United States of America","GMT-9","America/Nome"},
-{"Panama City","Panama","GMT-6","America/Panama"},
-{"Paramaribo","Surinam","GMT-3","America/Paramaribo"},
-{"Phoenix","United States of America","GMT-7","America/Phoenix"},
-{"Port-au-Prince","Haiti","GMT-5","America/Port-au-Prince"},
-{"San Juan","Puerto Rico","GMT-4","America/Puerto_Rico"},
-{"Recife","Brazil","GMT-3","America/Recife"},
-{"Regina","Canada","GMT-6","America/Regina"},
-{"Santiago","Chile","GMT-4","America/Santiago"},
-{"Santo Domingo","Dominican Republic","GMT-4","America/Santo_Domingo"},
-{"Brasilia","Brazil","GMT-3","America/Sao_Paulo"},
-{"Rio de Janeiro","Brazil","GMT-2","America/Sao_Paulo"},
-{"Sao Paulo","Brazil","GMT-2","America/Sao_Paulo"},
-{"Newfoundland","Canada","GMT-3:30","America/St_Johns"},
-{"St. John's","Canada","GMT-3:30","America/St_Johns"},
-{"Charlotte Amalie","United States Virgin Islands ","GMT-5:30","America/St_Thomas"},
-{"Tegucigalpa","Honduras","GMT-6","America/Tegucigalpa"},
-{"Tijuana","Mexico","GMT-5","America/Tijuana"},
-{"Toronto","Canada","GMT-4","America/Toronto"},
-{"Kingston","Canada","GMT-5","America/Toronto "},
-{"The Settlement","British Virgin Islands ","GMT-4","America/Tortola"},
-{"Vancouver","Canada","GMT-8","America/Vancouver"},
-{"Winnipeg","Canada","GMT-5","America/Winnipeg"},
-{"Sanaa","Yemen","GMT+3","Asia/Aden "},
-{"Almaty","Kazakhstan","GMT+6","Asia/Almaty"},
-{"Astana","Kazakhstan","GMT+6","Asia/Almaty "},
-{"Amman","Jordan","GMT+2","Asia/Amman"},
-{"Anadyr","Russia","GMT+12","Asia/Anadyr"},
-{"Ashgabat","Turkmenistan","GMT+5","Asia/Ashgabat"},
-{"Baghdad","Iraq","GMT+3","Asia/Baghdad"},
-{"Manama","Bahrain","GMT+3","Asia/Bahrain"},
-{"Baku","Azerbaijan","GMT+4","Asia/Baku"},
-{"Bangkok","Thailand","GMT+7","Asia/Bangkok"},
-{"Beirut","Lebanon","GMT+2","Asia/Beirut"},
-{"Bishkek","Kyrgyzstan","GMT+6","Asia/Bishkek"},
-{"Colombo","Sri Lanka","GMT+5:30","Asia/Colombo"},
-{"Damascus","Syria","GMT+2","Asia/Damascus"},
-{"Dhaka","Bangladesh","GMT+6","Asia/Dhaka"},
-{"Abu Dhabi","United Arab Emirates","GMT+4","Asia/Dubai"},
-{"Dubai","United Arab Emirates","GMT+4","Asia/Dubai"},
-{"Dushanbe","Tajikistan","GMT+5","Asia/Dushanbe"},
-{"Hanoi","Vietnam","GMT+7","Asia/Ho_Chi_Minh"},
-{"Thanh Pho Ho Chi Minh","Vietnam","GMT+7","Asia/Ho_Chi_Minh"},
-{"Hong Kong","China","GMT+8","Asia/Hong_Kong"},
-{"Hovd","Mongolia","GMT+8","Asia/Hovd"},
-{"Irkutsk","Russia","GMT+8","Asia/Irkutsk"},
-{"Ankara","Turkey","GMT+2","Asia/Istanbul"},
-{"Jakarta","Indonesia","GMT+7","Asia/Jakarta"},
-{"Ambon","Indonesia","GMT+1","Asia/Jayapura"},
-{"Jerusalem","Israel","GMT+2","Asia/Jerusalem"},
-{"Kabul","Afghanistan","GMT+4:30","Asia/Kabul"},
-{"Kamchatka","Russia ","GMT+12","Asia/Kamchatka"},
-{"Petropavlovsk-Kamchatskiy","Russia ","GMT+12","Asia/Kamchatka"},
-{"Islamabad","Pakistan","GMT+5","Asia/Karachi"},
-{"Karachi","Pakistan","GMT+5","Asia/Karachi"},
-{"Kathmandu","Nepal","GMT+5:45","Asia/Kathmandu"},
-{"Chennai","India","GMT+5:30","Asia/Kolkata"},
-{"Delhi","India","GMT+5:30","Asia/Kolkata"},
-{"Kolkata","India","GMT+5:30","Asia/Kolkata"},
-{"Mumbai","India","GMT+5:30","Asia/Kolkata"},
-{"New Delhi","India","GMT+5:30","Asia/Kolkata "},
-{"Krasnoyarsk","Russia","GMT+7","Asia/Krasnoyarsk"},
-{"Kuala Lumpur","Malaysia","GMT+8","Asia/Kuala_Lumpur"},
-{"Kuwait","Kuwait","GMT+3","Asia/Kuwait"},
-{"Macau","China","GMT+8","Asia/Macau"},
-{"Magadan","Russia","GMT+11","Asia/Magadan"},
-{"Denpasar","Indonesia","GMT+8","Asia/Makassar"},
-{"Manila","Philippines","GMT+8","Asia/Manila"},
-{"Muscat","Oman","GMT+4","Asia/Muscat"},
-{"Novokuznetsk","Russia","GMT+7","Asia/Novokuznetsk"},
-{"Novosibirsk","Russia","GMT+6","Asia/Novosibirsk"},
-{"Omsk","Russia","GMT+6","Asia/Omsk"},
-{"Phnom Penh ","Cambodia","GMT-5","Asia/Phnom_Penh"},
-{"Pyongyang","North Korea","GMT+9","Asia/Pyongyang"},
-{"Doha","Qatar","GMT+3","Asia/Qatar"},
-{"Rangoon","Burma","GMT+6:30","Asia/Rangoon"},
-{"Jeddah","Saudi Arabia","GMT+3","Asia/Riyadh"},
-{"Mecca","Saudi Arabia","GMT+3","Asia/Riyadh"},
-{"Riyadh","Saudi Arabia","GMT+3","Asia/Riyadh"},
-{"Yuzhno-Sakhalinsk","Russia","GMT+11","Asia/Sakhalin"},
-{"Seoul","Republic of Korea","GMT+9","Asia/Seoul"},
-{"Beijing","China","GMT+8","Asia/Shanghai"},
-{"Canton","China","GMT+8","Asia/Shanghai"},
-{"Longhua","China","GMT+8","Asia/Shanghai"},
-{"Shanghai","China","GMT+8","Asia/Shanghai"},
-{"Shenzhen","China","GMT+8","Asia/Shanghai"},
-{"Tientsin","China","GMT+8","Asia/Shanghai "},
-{"Singapore","Republic of Singapore","GMT+8","Asia/Singapore"},
-{"Taipei","Taiwan","GMT+8","Asia/Taipei"},
-{"Tashkent","Uzbekistan","GMT+5","Asia/Tashkent"},
-{"Tbilisi","Georgia","GMT+4","Asia/Tbilisi"},
-{"Tehran","Iran","GMT+3:30","Asia/Tehran"},
-{"Osaka","Japan","GMT+9","Asia/Tokyo"},
-{"Tokyo","Japan","GMT+9","Asia/Tokyo"},
-{"Ulan Bator","Mongolia","GMT+8","Asia/Ulan_Bator"},
-{"Khabarovsk","Russia","GMT+10","Asia/Vladivostok"},
-{"Vladivostok","Russia","GMT+10","Asia/Vladivostok"},
-{"Chita","Russia","GMT+9","Asia/Yakutsk"},
-{"Yakutsk","Russia","GMT+9","Asia/Yakutsk"},
-{"Chelyabinsk","Russia","GMT+5","Asia/Yekaterinburg"},
-{"Perm","Russia","GMT+5","Asia/Yekaterinburg"},
-{"Ufa","Bashkiriya","GMT+5","Asia/Yekaterinburg"},
-{"Yekaterinburg","Russia","GMT+5","Asia/Yekaterinburg"},
-{"Yerevan","Armenia","GMT+5","Asia/Yerevan"},
-{"Azores","Portugal","GMT-1","Atlantic/Azores"},
-{"Ponta Delgada","Portugal","GMT-1","Atlantic/Azores"},
-{"Canary Islands","Spain","GMT+0","Atlantic/Canary"},
-{"Reykjavik","Iceland","GMT+0","Atlantic/Reykjavik"},
-{"Grytviken","South Georgia","GMT-2","Atlantic/South_Georgia"},
-{"Adelaide","Australia","GMT+9:30","Australia/Adelaide"},
-{"Brisbane","Australia","GMT+10","Australia/Brisbane"},
-{"Canberra","Australia","GMT+10","Australia/Canberra"},
-{"Darwin","Australia","GMT+9:30","Australia/Darwin"},
-{"Hobart","Australia","GMT+10","Australia/Hobart"},
-{"Melbourne","Australia","GMT+10","Australia/Melbourne"},
-{"Victoria","Seychelles","GMT+4","Australia/Melbourne"},
-{"Perth","Australia","GMT+8","Australia/Perth"},
-{"Sydney","Australia","GMT+11","Australia/Sydney"},
-{"Austin","United States of America","GMT-6","CST6CDT"},
-{"Dallas","United States of America","GMT-6","CST6CDT"},
-{"Houston","United States of America","GMT-6","CST6CDT"},
-{"Memphis","United States of America","GMT-6","CST6CDT"},
-{"Milwaukee","United States of America","GMT-6","CST6CDT"},
-{"San Antonio","United States of America","GMT-6","CST6CDT"},
-{"Baltimore","United States of America","GMT-5","EST5EDT"},
-{"Boston","United States of America","GMT-5","EST5EDT"},
-{"Charlotte","United States of America","GMT-5","EST5EDT"},
-{"Cleveland","United States of America","GMT-5","EST5EDT"},
-{"Columbus","United States of America","GMT-5","EST5EDT"},
-{"Miami","United States of America","GMT-5","EST5EDT"},
-{"Ottawa","Canada","GMT-5","EST5EDT"},
-{"Philadelphia","United States of America","GMT-5","EST5EDT"},
-{"Amsterdam","Netherlands","GMT+1","Europe/Amsterdam"},
-{"Athens","Greece","GMT+2","Europe/Athens"},
-{"Belgrade","Serbia","GMT+1","Europe/Belgrade"},
-{"Berlin","Germany","GMT+1","Europe/Berlin"},
-{"Hamburg","Germany","GMT+1","Europe/Berlin"},
-{"Munich","Germany","GMT+1","Europe/Berlin"},
-{"Bratislava","Slovakia","GMT+2","Europe/Bratislava"},
-{"Brussels","Belgium","GMT+1","Europe/Brussels"},
-{"Bucharest","Romania","GMT+3","Europe/Bucharest"},
-{"Budapest","Hungary","GMT+1","Europe/Budapest"},
-{"Chisinau","Moldova","GMT+2","Europe/Chisinau"},
-{"Copenhagen","Denmark","GMT+1","Europe/Copenhagen"},
-{"Cork","Ireland","GMT+0","Europe/Dublin"},
-{"Dublin","Ireland","GMT+0","Europe/Dublin"},
-{"Helsinki","Finland","GMT+2","Europe/Helsinki"},
-{"Istanbul","Turkey","GMT+2","Europe/Istanbul"},
-{"Kaliningrad","Russia","GMT+2","Europe/Kaliningrad"},
-{"Kharkiv","Ukraine","GMT+2","Europe/Kiev"},
-{"Kiev","Ukraine","GMT+2","Europe/Kiev"},
-{"Lviv","Ukraine","GMT+2","Europe/Kiev"},
-{"Kyiv","Ukraine","GMT+2","Europe/Kiev "},
-{"Lisbon","Portugal","GMT+0","Europe/Lisbon"},
-{"Ljubljana","Slovakia","GMT+1","Europe/Ljubljana"},
-{"Cardiff","Wales","GMT+0","Europe/London"},
-{"Edinburgh","Scotland","GMT+0","Europe/London"},
-{"London","United Kingdom","GMT+0","Europe/London"},
-{"Luxembourg","Luxembourg","GMT+1","Europe/Luxembourg"},
-{"Barcelona","Spain","GMT+2","Europe/Madrid"},
-{"Madrid","Spain","GMT+2","Europe/Madrid"},
-{"Valletta","Malta","GMT+1","Europe/Malta"},
-{"Minsk","Belarus","GMT+2","Europe/Minsk"},
-{"Izhevsk","Russia","GMT+4","Europe/Moscow"},
-{"Moscow","Russia","GMT+3","Europe/Moscow"},
-{"St. Petersburg","Russia","GMT+3","Europe/Moscow"},
-{"Geneva","Switzerland","GMT+1","Europe/Paris"},
-{"Paris","France","GMT+1","Europe/Paris"},
-{"Trehet","France","GMT+1","Europe/Paris "},
-{"Podgorica","Montenegro","GMT+1","Europe/Podgorica"},
-{"Prague","Czech Republic","GMT+1","Europe/Prague"},
-{"Riga","Latvia","GMT+2","Europe/Riga"},
-{"Bari","Italy","GMT+1","Europe/Rome"},
-{"Bologna","Italy","GMT+1","Europe/Rome"},
-{"Catanzaro","Italy","GMT+1","Europe/Rome"},
-{"Crotone","Italy","GMT+1","Europe/Rome"},
-{"Florence","Italy","GMT+1","Europe/Rome"},
-{"Genoa","Italy","GMT+1","Europe/Rome"},
-{"Messina","Italy","GMT+1","Europe/Rome"},
-{"Milan","Italy","GMT+1","Europe/Rome"},
-{"Naples","Italy","GMT+1","Europe/Rome"},
-{"Palermo","Italy","GMT+1","Europe/Rome"},
-{"Rome","Italy","GMT+1","Europe/Rome"},
-{"Turin","Italy","GMT+1","Europe/Rome"},
-{"Verona","Italy","GMT+1","Europe/Rome"},
-{"Samara","Russia","GMT+4","Europe/Samara"},
-{"San Marino","Italy","GMT+1","Europe/San_Marino"},
-{"Skopje","Macedonia","GMT+1","Europe/Skopje"},
-{"Sofia ","Bulgaria","GMT+3","Europe/Sofia"},
-{"Stockholm","Sweden","GMT+2","Europe/Stockholm"},
-{"Tallinn","Estonia","GMT+2","Europe/Tallinn"},
-{"Vaduz","Liechtenstein","GMT+1","Europe/Vaduz"},
-{"Vienna","Austria","GMT+1","Europe/Vienna"},
-{"Vilnius","Lithuania","GMT+3","Europe/Vilnius"},
-{"Volgograd","Russia","GMT+4","Europe/Volgograd"},
-{"Warsaw","Poland","GMT+2","Europe/Warsaw"},
-{"Zagreb","Croatia","GMT+1","Europe/Zagreb"},
-{"Bern","Switzerland","GMT+1","Europe/Zurich"},
-{"Naters","Switzerland","GMT+1","Europe/Zurich"},
-{"Zurich","Switzerland","GMT+1","Europe/Zurich"},
-{"Antananarivo","Madagascar","GMT+3","Indian/Antananarivo"},
-{"Diego Garcia","United Kingdom","GMT+5","Indian/Chagos "},
-{"Male","Maldives","GMT+5","Indian/Maldives"},
-{"Port Louis","Mauritius","GMT+4","Indian/Mauritius"},
-{"Saint-Denis","Reunion Island","GMT+4","Indian/Reunion"},
-{"Calgary","Canada","GMT-7","MST7MDT"},
-{"El Paso","United States of America","GMT-7","MST7MDT"},
-{"Auckland","New Zealand","GMT+12","Pacific/Auckland"},
-{"Wellington","New Zealand","GMT+12","Pacific/Auckland"},
-{"Easter Island","Chile","GMT-6","Pacific/Easter"},
-{"Suva","Fiji","GMT+12","Pacific/Fiji"},
-{"Galapagos Islands","Ecuador","GMT-7","Pacific/Galapagos"},
-{"Guam","United States of America","GMT+10","Pacific/Guam"},
-{"Hawaii","United States of America","GMT-10","Pacific/Honolulu"},
-{"Honolulu","United States of America","GMT-10","Pacific/Honolulu"},
-{"Midway Atoll","United States of America","GMT-11","Pacific/Midway"},
-{"Noumea","New Caledonia","GMT+11","Pacific/Noumea"},
-{"Pago Pago","Independent State of Samoa","GMT-11","Pacific/Pago_Pago"},
-{"Tahiti","French Polynesia","GMT-10","Pacific/Tahiti"},
-{"Tarawa","Kiribati","GMT+12","Pacific/Tarawa"},
-{"Nuku'alofa","Tonga","GMT+13","Pacific/Tongatapu"},
-{"Las Vegas","United States of America","GMT-8","PST8PDT"},
-{"Portland","United States of America","GMT-8","PST8PDT"},
-{"San Diego","United States of America","GMT-8","PST8PDT"},
-{"San Jose","United States of America","GMT-8","PST8PDT"},
-{"Seattle","United States of America","GMT-8","PST8PDT"},
-{"Washington, D.C.","United States of America","GMT-5","EST5EDT"},
-{NULL, NULL, NULL, NULL}
-};
-
-#ifndef SECSPERHOUR
-#define SECSPERHOUR 3600 //(SECSPERMIN * MINSPERHOUR)
-#endif /* !defined SECSPERHOUR */
-
-#ifndef SECSPERDAY
-#define SECSPERDAY 86400 //(SECSPERHOUR * HOURSPERDAY)
-#endif /* !defined SECSPERDAY */
-
-
-time_t cals_mktime(struct tm *date_time);
-struct tm *cals_tmtime(time_t *sec);
-struct tm* cals_tmtime_r(time_t *ttTime, struct tm *tmTime);
-char *cals_tzutil_get_tz_path(void);
-
-#endif /* __CALENDAR_SVC_TZ_UTILS_H__ */
*/
#include <unistd.h>
#include <fcntl.h>
+#include <stdbool.h>
#include "cals-typedef.h"
#include "cals-utils.h"
-#include "cals-recurrence-utils.h"
#include "cals-db.h"
#include "cals-db-info.h"
#include "cals-internal.h"
-#include "cals-tz-utils.h"
#include "cals-sqlite.h"
+#define CALS_MALLOC_DEFAULT_NUM 256 //4Kbytes
+
extern sqlite3* calendar_db_handle;
typedef enum
CAL_SCH_TERM_ERROR
} __cal_sch_term_status_t;
-static cal_month_tab g_month_day[] = { {1,31}, {2,28}, {3,31}, {4,30}, {5,31}, {6,30}, {7,31}, {8,31}, {9,30}, {10,31}, {11,30}, {12,31} };
-
static const char *CALS_NOTI_EVENT_CHANGED="/opt/data/calendar-svc/.CALENDAR_SVC_EVENT_CHANGED";
static const char *CALS_NOTI_TODO_CHANGED="/opt/data/calendar-svc/.CALENDAR_SVC_TODO_CHANGED";
static const char *CALS_NOTI_CALENDAR_CHANGED="/opt/data/calendar-svc/.CALENDAR_SVC_CALENDAR_CHANGED";
static int transaction_cnt = 0;
+static int transaction_ver = 0;
+static bool version_up = false;
static bool event_change=false;
static bool todo_change=false;
retvm_if(CAL_SUCCESS != ret, ret, "cals_query_exec() Failed(%d)", ret);
transaction_cnt = 0;
+ const char *query = "SELECT ver FROM "CALS_TABLE_VERSION;
+ transaction_ver = cals_query_get_first_int_result(query);
+ version_up = false;
}
transaction_cnt++;
CALS_DBG("transaction_cnt : %d", transaction_cnt);
{
int ret;
int progress = 0;
+ char query[CALS_SQL_MIN_LEN];
transaction_cnt--;
return CAL_SUCCESS;
}
+ if (version_up) {
+ transaction_ver++;
+ snprintf(query, sizeof(query), "UPDATE %s SET ver = %d",
+ CALS_TABLE_VERSION, transaction_ver);
+ ret = cals_query_exec(query);
+ warn_if(CAL_SUCCESS != ret, "cals_query_exec(version up) Failed(%d).", ret);
+ }
+
progress = 400000;
ret = cals_query_exec("COMMIT TRANSACTION");
while (CAL_ERR_DB_LOCK == ret && progress < CAL_COMMIT_TRY_MAX) {
if (todo_change) _cals_notify_todo_change();
if (calendar_change) _cals_notify_calendar_change();
- return CAL_SUCCESS;
+ return transaction_ver;
}
API int calendar_svc_begin_trans(void)
return cals_begin_trans();
}
-API int calendar_svc_end_trans()
-{
- CALS_FN_CALL;
- return cals_end_trans(true);
-}
-
-
-int cal_db_service_get_day_count_in_month(int input_year, int input_mon)
-{
- input_year = input_year + BENCHMARK_YEAR;
- input_mon = input_mon + 1;
-
- if ((input_year % 4) == 0) {
- if ((input_year % 100) == 0) {
- if ((input_year % 400) == 0)
- g_month_day[1].day = 29;
- else
- g_month_day[1].day = 28;
- } else {
- g_month_day[1].day = 29;
- }
- } else {
- g_month_day[1].day = 28;
- }
-
- return g_month_day[(input_mon - 1)].day;
-}
-
-static bool cal_get_day_count_in_month(int year, int month, int *count, int *error_code)
+API int calendar_svc_end_trans(bool is_success)
{
- assert((count != NULL) && (error_code != NULL));
-
- if(year < CAL_YEAR_MIN || CAL_YEAR_MAX < year) {
- ERR("year is invalid.");
- *error_code = CAL_ERR_ARG_INVALID;
- return false;
- }
-
- if(month < CAL_MONTH_CNT_MIN || CAL_MONTH_CNT_MAX < month) {
- ERR("month is invalid.");
- *error_code = CAL_ERR_ARG_INVALID;
- return false;
- }
-
- year = year - BENCHMARK_YEAR;
- month = month - 1;
-
- *count = cal_db_service_get_day_count_in_month(year, month);
- return true;
+ CALS_FN_CALL;
+ return cals_end_trans(is_success);
}
-void cal_db_service_set_repeat_end_date(cal_sch_full_t *sch_record)
+int cals_get_next_ver(void)
{
- int i = 0;
- struct tm start_tm={0};
- struct tm end_tm={0};
- struct tm next_valid_start_tm={0};
- struct tm next_valid_end_tm={0};
- cal_date_param_t cal_date_param;
- memset(&cal_date_param, 0x00, sizeof(cal_date_param_t));
+ const char *query;
- start_tm.tm_year = TM_YEAR_MIN;
- start_tm.tm_mon = MONTH_MIN;
- start_tm.tm_mday = MONTH_DAY_MIN;
-
- end_tm.tm_year = TM_YEAR_MAX;
- end_tm.tm_mon = MONTH_MAX;
- end_tm.tm_mday = MONTH_DAY_MAX;
-
- sch_record->repeat_end_date.tm_year = TM_YEAR_MAX-1;
- sch_record->repeat_end_date.tm_mon = MONTH_MAX;
- sch_record->repeat_end_date.tm_mday = MONTH_DAY_MAX;
-
- cal_service_set_date_param(&cal_date_param, sch_record);
-
- for(i = 0;i<sch_record->repeat_occurrences; i++)
- {
- cal_db_service_get_next_valid_exception_time(sch_record,
- &cal_date_param,NULL,&start_tm,&end_tm,&next_valid_start_tm,&next_valid_end_tm);
+ if (0 < transaction_cnt) {
+ version_up = true;
+ return transaction_ver + 1;
}
- memcpy(&sch_record->repeat_end_date, &next_valid_start_tm, sizeof(struct tm));
- ERR("sch_record->repeat_end_date:%d-%d-%d",sch_record->repeat_end_date.tm_year,sch_record->repeat_end_date.tm_mon,sch_record->repeat_end_date.tm_mday);
+ query = "SELECT ver FROM "CALS_TABLE_VERSION;
+ return (1 + cals_query_get_first_int_result(query));
}
-
bool cal_db_get_text_from_stmt(sqlite3_stmt *stmt,char** p_str_dst,int column)
{
char *str_temp = NULL;
return true;
}
-
-bool cal_db_service_convert_stmt_to_list_field_record(sqlite3_stmt *stmt,cal_sch_full_t *sch_record, bool is_utc)
-{
- assert(sch_record != NULL);
- int i = 0;
- long int temp = 0;
-
- sch_record->index = sqlite3_column_int(stmt, i++);
- cal_db_get_text_from_stmt(stmt,&(sch_record->summary),i++);
- cal_db_get_text_from_stmt(stmt,&(sch_record->location),i++);
-
- sch_record->all_day_event = sqlite3_column_int(stmt, i++);
-
- temp = sqlite3_column_int(stmt, i++);
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime(&temp),&(sch_record->start_date_time));
- temp = sqlite3_column_int(stmt, i++);
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime(&temp),&(sch_record->end_date_time));
-
- sch_record->repeat_term = sqlite3_column_int(stmt, i++);
-
- sch_record->week_start = sqlite3_column_int(stmt, i++);
- cal_db_get_text_from_stmt(stmt,&(sch_record->week_flag),i++);
-
- sch_record->calendar_id = sqlite3_column_int(stmt, i++);
-
- return true;
-
-}
-
-bool cal_db_service_convert_stmt_to_month_field_record(sqlite3_stmt *stmt,int is_repeat,cal_sch_full_t *sch_record, bool is_utc)
-{
- assert(sch_record != NULL);
- int i = 0;
- long int temp = 0;
-
- sch_record->index = sqlite3_column_int(stmt, i++);
- sch_record->all_day_event = sqlite3_column_int(stmt, i++);
-
- temp = sqlite3_column_int(stmt, i++);
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime(&temp),&(sch_record->start_date_time));
- temp = sqlite3_column_int(stmt, i++);
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime(&temp),&(sch_record->end_date_time));
-
- if(is_repeat)
- {
- sch_record->repeat_term = sqlite3_column_int(stmt, i++);
- sch_record->repeat_interval = sqlite3_column_int(stmt, i++);
- sch_record->repeat_until_type = sqlite3_column_int(stmt, i++);
- sch_record->repeat_occurrences = sqlite3_column_int(stmt, i++);
- temp = sqlite3_column_int(stmt, i++);
- cal_db_service_copy_struct_tm((struct tm*)cals_tmtime(&temp),&(sch_record->repeat_end_date));
- sch_record->week_start = sqlite3_column_int(stmt, i++);
- cal_db_get_text_from_stmt(stmt,&(sch_record->week_flag),i++);
- sch_record->day_date = sqlite3_column_int(stmt, i++);
- sch_record->timezone = sqlite3_column_int(stmt, i++);
- cal_db_get_text_from_stmt(stmt,&(sch_record->tz_name),i++);
- }
-
- return true;
-
-}
-
-
-#define MONTH_MAX 11
-
-// week day from 0--6
-#define MAX_WEEK_DAY 7
-
-#define MONTH_DAY_MAX 31
-#define MONTH_DAY_MIN 1
-
-#define MONTH_MIN 0
-
-#define TM_YEAR_MIN 0
-#define TM_YEAR_MAX 138
-#define TM_YEAR_OFFSET 1900
-
-#define TIME_HOUR_MAX_12 12
-#define TIME_HOUR_MAX_24 23
-
-#define TIME_ZONE_COUNT 28
-
-typedef enum
-{
- OEG_CALENDAR_ITEM_MEETING_CATEGORY = 0,
- OEG_CALENDAR_ITEM_ATTENDEE_LIST
-}OEG_CALENDAR_ITEM_TYPE;
-
-
- static bool
-__cal_db_service_get_next_month_first_day(struct tm* tm)
-{
- tm->tm_mon++;
- tm->tm_mday = MONTH_DAY_MIN;
-
- return TRUE;
-
-}
-
- static bool
-__cal_db_service_get_next_year_first_day(struct tm* tm)
+inline cals_updated* cals_updated_schedule_add_mempool(void)
{
- tm->tm_year++;
- tm->tm_mon = MONTH_MIN;
- tm->tm_mday = MONTH_DAY_MIN;
-
- return TRUE;
+ int i;
+ cals_updated *mempool;
+ mempool = calloc(CALS_MALLOC_DEFAULT_NUM, sizeof(cals_updated));
+ for (i=0;i<CALS_MALLOC_DEFAULT_NUM-1;i++)
+ mempool[i].next = &mempool[i+1];
+ return mempool;
}
- bool
-cal_db_service_get_tomorrow(struct tm* tm)
+inline int cals_updated_schedule_free_mempool(cals_updated *mempool)
{
- int day_count = 0;
- int error_code = 0;
-
- int year = tm->tm_year + TM_YEAR_OFFSET;
- int month = tm->tm_mon + 1;
+ cals_updated *memseg, *tmp;
- cal_get_day_count_in_month(year, month, &day_count, &error_code);
+ retv_if(NULL == mempool, CAL_ERR_ARG_NULL);
- if (tm->tm_mday < day_count)
- {
- tm->tm_mday++;
- }
- else
- {
- if ( tm->tm_mon < MONTH_MAX)
- {
- __cal_db_service_get_next_month_first_day(tm);
- }
- else
- {
- // to next year the first day
- __cal_db_service_get_next_year_first_day(tm);
- }
+ memseg = mempool;
+ while (memseg) {
+ tmp = memseg[CALS_MALLOC_DEFAULT_NUM-1].next;
+ free(memseg);
+ memseg = tmp;
}
- return TRUE;
-
-}
-
- bool
-cal_db_service_get_next_month(struct tm* tm)
-{
- if (tm->tm_mon == 11)
- {
- if (tm->tm_year == TM_YEAR_MAX-1)
- {
- tm->tm_mday = 31;
- }
- else
- {
- tm->tm_mon = 0;
- tm->tm_year ++;
- }
- }
- else
- {
- tm->tm_mon ++;
- }
-
- return true;
-}
-
-void cal_db_service_copy_struct_tm(const struct tm *tm_src, struct tm *tm_des)
-{
- ret_if(NULL == tm_src);
- ret_if(NULL == tm_des);
-
- tm_des->tm_sec = tm_src->tm_sec;
- tm_des->tm_min = tm_src->tm_min;
- tm_des->tm_hour = tm_src->tm_hour;
- tm_des->tm_mday = tm_src->tm_mday;
- tm_des->tm_wday = tm_src->tm_wday;
-
- tm_des->tm_mon = tm_src->tm_mon;
- tm_des->tm_year = tm_src->tm_year;
-
- tm_des->tm_yday = tm_src->tm_yday;
- tm_des->tm_isdst = tm_src->tm_isdst;
-}
-
-
-bool cal_db_service_get_current_time(struct tm * time_date)
-{
- assert(time_date != NULL);
-
- time_t t = time(NULL);
-
- tzset();
- localtime_r(&t,time_date);
-
- return TRUE;
-}
-
-
- void
-cal_db_service_set_sch_weekflag(struct tm* date_time, char *week_flag)
-{
- GDate cur_date={0,};
-
- g_date_set_dmy(&cur_date, (GDateDay) date_time->tm_mday, (GDateMonth) (
- date_time->tm_mon + 1), (GDateYear) (date_time->tm_year + TM_YEAR_OFFSET));
-
- date_time->tm_wday = g_date_get_weekday (&cur_date);
-
- switch (date_time->tm_wday)
- {
- case 7:
- memcpy(week_flag,"1000000",DAY_OF_A_WEEK);
- break;
- case 1:
- memcpy(week_flag,"0100000",DAY_OF_A_WEEK);
- break;
- case 2:
- memcpy(week_flag,"0010000",DAY_OF_A_WEEK);
- break;
- case 3:
- memcpy(week_flag,"0001000",DAY_OF_A_WEEK);
- break;
- case 4:
- memcpy(week_flag,"0000100",DAY_OF_A_WEEK);
- break;
- case 5:
- memcpy(week_flag,"0000010",DAY_OF_A_WEEK);
- break;
- case 6:
- memcpy(week_flag,"0000001",DAY_OF_A_WEEK);
- break;
- default:
-
- break;
- }
-
-}
-
-
-bool cal_vcalendar_convert_tm_to_vdata_str(const struct tm *tm, char *utc_str)
-{
-
- memset(utc_str, 0, 17);
-
- sprintf(utc_str, "%04ld%02d%02dT%02d%02d%02dZ",
- tm->tm_year + BENCHMARK_YEAR,
- tm->tm_mon +1,
- tm->tm_mday,
- tm->tm_hour,
- tm->tm_min,
- tm->tm_sec);
-
- return true;
-
+ return CAL_SUCCESS;
}
-void cal_vcalendar_convert_utc_str_to_tm(const char *szText, struct tm *tm)
-{
- assert((szText != NULL) && (tm != NULL));
-
- char szBuff[8];
-
- // struct tm tm;
- memset(tm, 0, sizeof(struct tm));
-
- // year, month, day
- memcpy(szBuff, &(szText[0]), 4);
- szBuff[4] = '\0';
- tm->tm_year = atol(szBuff) - BENCHMARK_YEAR;
- if ((tm->tm_year > (CAL_YEAR_MAX - BENCHMARK_YEAR)) || (tm->tm_year < (CAL_YEAR_MIN - BENCHMARK_YEAR)))
- {
- tm->tm_year = (CAL_YEAR_MAX - BENCHMARK_YEAR);
- }
-
- memcpy(szBuff, &(szText[4]), 2);
- szBuff[2] = '\0';
- tm->tm_mon = atol(szBuff)-1;
- if ((tm->tm_mon > 11) || (tm->tm_mon < 0))
- {
- tm->tm_mon = 11;
- }
-
- memcpy(szBuff, &(szText[6]), 2);
- szBuff[2] = '\0';
- tm->tm_mday = atol(szBuff);
- if ((tm->tm_mday > 31) || (tm->tm_mday < 1))
- {
- tm->tm_mday = 31;
- }
+char cal_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
- // hour, minute, second
- memcpy(szBuff, &(szText[9]), 2);
- szBuff[2] = '\0';
- tm->tm_hour = atol(szBuff);
- if ((tm->tm_hour > 23) || (tm->tm_hour < 0))
- {
- tm->tm_hour = 23;
- }
-
- memcpy(szBuff, &(szText[11]), 2);
- szBuff[2] = '\0';
- tm->tm_min = atol(szBuff);
- if ((tm->tm_min > 59) || (tm->tm_min < 0))
- {
- tm->tm_min = 59;
- }
- memcpy(szBuff, &(szText[13]), 2);
- szBuff[2] = '\0';
- tm->tm_sec = atol(szBuff);
- if ((tm->tm_sec > 59) || (tm->tm_sec < 0))
- {
- tm->tm_sec = 59;
- }
-
- CALS_DBG( "\n-------------------cal_vcalendar_convert_utc_str_to_tm year is %d, month is %d, day is %d, hour is %d, min is %d, sec is %d--------------------\n",
- tm->tm_year,tm->tm_mon,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec);
-}
-
- bool
-cal_util_convert_query_string(const char *src, char *dst)
+//long long int _get_utime(int y, int mon, int d, int h, int min, int s)
+long long int _date_to_utime(int y, int mon, int d, int h, int min, int s)
{
- int i = 0;
- int j = 0;
- int nSrc = 0;
-
- if (src == NULL || dst == NULL)
- {
- return FALSE;
- }
-
- nSrc = strlen(src);
-
- for(i = 0; i < nSrc; ++i)
- {
- if (src[i] == '\'')
- {
- dst[j++] = src[i];
- dst[j++] = src[i];
- }
- else if (src[i] == '%')
- {
- dst[j++] = src[i];
- dst[j++] = src[i];
- }
- else
- {
- dst[j++] = src[i];
+ int i;
+ long long int t;
+
+ t = y * 365;
+ t += ((int)y/4 - (int)y/100 + (int)y/400);
+ for (i = 0; i < mon-1; i++) {
+ t += cal_month[i];
+ }
+ if (i > 2 && (y % 4 == 0)) {
+ t += 1;
+ if ((y % 100 == 0) && (y % 400 != 0)) {
+ t -= 1;
}
}
- dst[j] = '\0';
-
- return TRUE;
+ t += d;
+ t *= (24 * 60 * 60);
+ t += (((h * 60) + min ) * 60 + s);
+ t -= D19700101;
+ return t;
}
-cal_iter* cals_get_updated_list(int type, int calendar_id, time_t timestamp)
+long long int _datetime_to_utime(char *datetime)
{
- cal_iter *iter;
- sqlite3_stmt *stmt;
- char query[CALS_SQL_MIN_LEN];
-
- retvm_if(timestamp < 0, NULL, "timestamp(%ld) is Invalid", timestamp);
+ int y, mon, d, h, min, s;
+ char tmp[8] = {0};
+ char *p;
+
+ if (datetime == NULL || strlen(datetime) == 0) {
+ ERR("Invalid argument");
+ return -1;
+ }
+
+ p = datetime;
+ snprintf(tmp, 5, "%s", p);
+ y = atoi(tmp);
+ snprintf(tmp, 3, "%s", p + 4);
+ mon = atoi(tmp);
+ snprintf(tmp, 3, "%s", p + 6);
+ d = atoi(tmp);
+
+ if (strlen(datetime) > 14) {
+ snprintf(tmp, 3, "%s", p + 9);
+ h = atoi(tmp);
+ snprintf(tmp, 3, "%s", p + 11);
+ min = atoi(tmp);
+ snprintf(tmp, 3, "%s", p + 13);
+ s = atoi(tmp);
- iter = calloc(1, sizeof(cal_iter));
- retvm_if(NULL == iter, NULL, "calloc() Failed");
-
- if (calendar_id)
- sprintf(query,"SELECT * FROM %s WHERE type = %d AND last_modified_time > %ld AND calendar_id = %d",
- CALS_TABLE_SCHEDULE, type, timestamp, calendar_id);
- else
- sprintf(query,"SELECT * FROM %s WHERE type = %d AND last_modified_time > %ld",
- CALS_TABLE_SCHEDULE, type, timestamp);
-
- stmt = cals_query_prepare(query);
- if (NULL == stmt) {
- free(iter);
- ERR("cals_query_prepare() Failed");
- return NULL;
+ } else {
+ h = min = s = 0;
}
- iter->stmt = stmt;
- if (CAL_EVENT_TODO_TYPE == type)
- iter->i_type = CAL_STRUCT_TYPE_TODO;
- else
- iter->i_type = CAL_STRUCT_TYPE_SCHEDULE;
-
- return iter;
+ return _date_to_utime(y, mon, d, h, min, s);
}
#include "db-util.h"
#include <glib.h>
+/* sec to 1970 1 1 0:0:0 */
+#define D19700101 62167219200
+
//SQL operation type. May be used for other usage.
typedef enum
{
CAL_SCH_FIELD_MISSED, /**< This is missed flag */
CAL_SCH_FIELD_CALENDAR_TYPE, /**< Calendar type */
CAL_SCH_FIELD_TIME_ZOON, /**< This is time zoon of calendar event */
- CAL_SCH_FIELD_DST, /**< This is dst of an event*/
+ CAL_SCH_FIELD_DST, /**< This is dst of an event*/
CAL_SCH_FIELD_CNT_MAX /**< This is count max */
} __cal_sch_field_t;
bool cal_db_get_blob_from_stmt(sqlite3_stmt * stmt,struct tm * p_tm,int column);
bool cal_db_service_convert_stmt_to_tz_info(sqlite3_stmt *stmt,cal_timezone_t * tz_info);
-
-int cal_db_service_get_day_count_in_month(int input_year, int input_mon);
-
-bool cal_db_service_get_current_time(struct tm * time_date);
-
-bool cal_db_service_get_tomorrow(struct tm* tm);
-
-bool cal_db_service_get_next_month(struct tm* tm);
-
-void cal_db_service_copy_struct_tm(const struct tm *tm_src, struct tm *tm_des);
-
-void cal_db_service_set_sch_weekflag(struct tm* date_time, char *week_flag);
-
-bool cal_vcalendar_convert_tm_to_vdata_str(const struct tm * tm, char * utc_str);
-
-void cal_vcalendar_convert_utc_str_to_tm(const char *szText, struct tm * tm);
-
bool cal_util_convert_query_string(const char *src, char *dst);
-void cal_db_service_set_repeat_end_date(cal_sch_full_t *sch_record);
-
-bool cal_db_service_convert_stmt_to_list_field_record(sqlite3_stmt *stmt,cal_sch_full_t *sch_record, bool is_utc);
-bool cal_db_service_convert_stmt_to_month_field_record(sqlite3_stmt *stmt,int is_repeat,cal_sch_full_t *sch_record, bool is_utc);
-
-cal_iter* cals_get_updated_list(int type, int calendar_id, time_t timestamp);
-
int cals_notify(cals_noti_type operation_type);
int cals_begin_trans(void);
int cals_end_trans(bool is_success);
+int cals_get_next_ver(void);
const char* cals_noti_get_file_path(int type);
+inline cals_updated* cals_updated_schedule_add_mempool(void);
+inline int cals_updated_schedule_free_mempool(cals_updated *mempool);
+long long int _date_to_utime(int y, int mon, int d, int h, int min, int s);
+long long int _datetime_to_utime(char *datetime);
#endif /* __CALENDAR_SVC_UTILS_H__ */
-CC = gcc
+C = gcc
REQUIRED_PKG = calendar-service
CFLAGS = -g -Wall
LDFLAGS += `pkg-config --libs $(REQUIRED_PKG)`
endif
-SRCS = calendar-test.c schedule-test.c
+SRCS = recur-add.c eve-add.c recur-add.c eve-see.c
TIMESRC = timetest.c
OBJECTS = $(SRCS:.c=.o)
TIMEOBJ = $(TIMESRC:.c=.o)
--- /dev/null
+
+#include <stdio.h>
+#include <time.h>
+#include <calendar-svc-provider.h>
+
+int main(int argc, char **argv)
+{
+ int ret;
+ time_t tt;
+ cal_struct *cs = NULL;
+
+ cs = calendar_svc_struct_new(CAL_STRUCT_SCHEDULE);
+ if (cs == NULL) {
+ printf("Failed to new calendar\n");
+ return -1;
+ }
+
+ tt = time(NULL);
+
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_ACCOUNT_ID, 1);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_TASK_STATUS, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_PRIORITY, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_FILE_ID, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_CONTACT_ID, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_BUSY_STATUS, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_SENSITIVITY, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_CALENDAR_TYPE, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_MEETING_STATUS, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_LOCATION_TYPE, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_CALENDAR_ID, 1);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_SYNC_STATUS, 1);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_DST, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_ORIGINAL_EVENT_ID, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_EMAIL_ID, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_AVAILABILITY, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_PROGRESS, 0);
+
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_CATEGORIES, "event categories");
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_SUMMARY, "event summary");
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_DESCRIPTION, "event description");
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_LOCATION, "event location");
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_UID, "event uid");
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_ORGANIZER_NAME, "event org name");
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_ORGANIZER_EMAIL, "event org email");
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_GCAL_ID, "event gcal id");
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_UPDATED, "event udpated");
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_LOCATION_SUMMARY, "event loc summary");
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_ETAG, "event etag");
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_EDIT_URL, "event url");
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_GEDERID, "event gederid");
+
+ calendar_svc_struct_set_double(cs, CAL_VALUE_DBL_LATITUDE, 0.1);
+ calendar_svc_struct_set_double(cs, CAL_VALUE_DBL_LONGITUDE, 0.2);
+
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTSTART_TYPE, CALS_TIME_LOCALTIME);
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTSTART_YEAR, 2012);
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTSTART_MONTH, 7);
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTSTART_MDAY, 1);
+ calendar_svc_struct_set_lli(cs, CALS_VALUE_LLI_DTSTART_UTIME, 1339833600);
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_DTSTART_TZID, "Europe/London");
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTEND_TYPE, CALS_TIME_UTIME);
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTEND_YEAR, 2012);
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTEND_MONTH, 7);
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTEND_MDAY, 1);
+ calendar_svc_struct_set_lli(cs, CALS_VALUE_LLI_DTEND_UTIME, 1339837200);
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_DTEND_TZID, "Europe/London");
+
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_MONTHLY);
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_RANGE_TYPE, CALS_RANGE_UNTIL);
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_UNTIL_TYPE, CALS_TIME_LOCALTIME);
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_UNTIL_YEAR, 2013);
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_UNTIL_MONTH, 5);
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_UNTIL_MDAY, 1);
+ calendar_svc_struct_set_lli(cs, CALS_VALUE_LLI_RRULE_UNTIL_UTIME, 1452483199);
+// calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_COUNT, 6);
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_INTERVAL, 2);
+// calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYSECOND, "bysecond");
+// calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYMINUTE, "byminute");
+// calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYHOUR, "byhour");
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYDAY, "3SA,3TU");
+// calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYDAY, "SA,TU");
+// calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYMONTHDAY, "4,27");
+// calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYYEARDAY, "byyearday");
+// calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYWEEKNO, "byweekno");
+// calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYMONTH, "7");
+// calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYSETPOS, "bysetpos");
+
+ calendar_svc_connect();
+ ret = calendar_svc_insert(cs);
+ calendar_svc_close();
+
+ calendar_svc_struct_free(&cs);
+ return ret;
+}
--- /dev/null
+
+#include <stdio.h>
+#include <time.h>
+#include <calendar-svc-provider.h>
+#include "utime.h"
+
+int main(int argc, char **argv)
+{
+ int ret;
+ time_t tt;
+ cal_struct *cs = NULL;
+
+ cs = calendar_svc_struct_new(CAL_STRUCT_SCHEDULE);
+ if (cs == NULL) {
+ printf("Failed to new calendar\n");
+ return -1;
+ }
+
+ tt = time(NULL);
+
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_ACCOUNT_ID, 1);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_TASK_STATUS, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_PRIORITY, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_FILE_ID, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_CONTACT_ID, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_BUSY_STATUS, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_SENSITIVITY, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_CALENDAR_TYPE, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_MEETING_STATUS, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_LOCATION_TYPE, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_CALENDAR_ID, 1);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_SYNC_STATUS, 1);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_DST, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_ORIGINAL_EVENT_ID, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_EMAIL_ID, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_AVAILABILITY, 0);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_PROGRESS, 0);
+
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_CATEGORIES, "event categories");
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_SUMMARY, "event summary");
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_DESCRIPTION, "event description");
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_LOCATION, "event location");
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_UID, "event uid");
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_ORGANIZER_NAME, "event org name");
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_ORGANIZER_EMAIL, "event org email");
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_GCAL_ID, "event gcal id");
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_UPDATED, "event udpated");
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_LOCATION_SUMMARY, "event loc summary");
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_ETAG, "event etag");
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_EDIT_URL, "event url");
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_GEDERID, "event gederid");
+
+ calendar_svc_struct_set_double(cs, CAL_VALUE_DBL_LATITUDE, 0.1);
+ calendar_svc_struct_set_double(cs, CAL_VALUE_DBL_LONGITUDE, 0.2);
+
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTSTART_TYPE, CALS_TIME_UTIME);
+ calendar_svc_struct_set_lli(cs, CALS_VALUE_LLI_DTSTART_UTIME, D20120701T000000);
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_DTSTART_TZID, "Europe/London");
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTEND_TYPE, CALS_TIME_UTIME);
+ calendar_svc_struct_set_lli(cs, CALS_VALUE_LLI_DTEND_UTIME, D20120901T000000);
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_DTEND_TZID, "Europe/London");
+
+/*
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTSTART_TYPE, CALS_TIME_LOCALTIME);
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_DTSTART_TZID, "Europe/London");
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTSTART_YEAR, 2012);
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTSTART_MONTH, 6);
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTSTART_MDAY, 1);
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTEND_TYPE, CALS_TIME_LOCALTIME);
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_DTEND_TZID, "Europe/London");
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTEND_YEAR, 2012);
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTEND_MONTH, 6);
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTEND_MDAY, 1);
+*/
+
+
+
+// calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_WEEKLY);
+// calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_RANGE_TYPE, CALS_RANGE_COUNT);
+// calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_UNTIL_TYPE, CALS_TIME_UTIME);
+// calendar_svc_struct_set_lli(cs, CALS_VALUE_LLI_RRULE_UNTIL_UTIME, 1452483199);
+// calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_UNTIL_YEAR, 2012);
+// calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_UNTIL_MONTH, 9);
+// calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_UNTIL_MDAY, 31);
+
+
+// calendar_svc_struct_set_lli(cs, CALS_VALUE_INT_RRULE_UNTIL_YEAR, "2012");
+// calendar_svc_struct_set_lli(cs, CALS_VALUE_INT_RRULE_UNTIL_MONTH, "8");
+// calendar_svc_struct_set_lli(cs, CALS_VALUE_INT_RRULE_UNTIL_MDAY, "12");
+// calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_COUNT, 6);
+// calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_INTERVAL, 2);
+// calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYSECOND, "bysecond");
+// calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYMINUTE, "byminute");
+// calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYHOUR, "byhour");
+// calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYDAY, "3SA,3TU");
+// calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYDAY, "SA,TU");
+// calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYMONTHDAY, "4,27");
+// calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYYEARDAY, "byyearday");
+// calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYWEEKNO, "byweekno");
+// calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYMONTH, "7");
+// calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYSETPOS, "bysetpos");
+
+ calendar_svc_connect();
+ ret = calendar_svc_insert(cs);
+
+ long long int get_lli;
+ get_lli = calendar_svc_struct_get_lli(cs, CALS_VALUE_LLI_DTSTART_UTIME);
+ printf("%lld\n", get_lli);
+
+
+ calendar_svc_close();
+
+ calendar_svc_struct_free(&cs);
+ return ret;
+}
--- /dev/null
+
+#include <stdio.h>
+#include <time.h>
+#include <calendar-svc-provider.h>
+
+int main(int argc, char **argv)
+{
+ int ret;
+ int index;
+
+ if (argc < 2) {
+ printf("needs 2 arguments\n");
+ return -1;
+ }
+
+ index = atoi(argv[1]);
+ if (index < 0) {
+ printf("Invalid index (%d)\n", index);
+ return -1;
+ }
+
+ calendar_svc_connect();
+ printf("id(%d)\n", index);
+ ret = calendar_svc_delete(CAL_STRUCT_SCHEDULE, index);
+ if (ret != CAL_SUCCESS) {
+ printf("Failed to delete\n");
+ return -1;
+ }
+ calendar_svc_close();
+ return 0;
+}
--- /dev/null
+
+#include <stdio.h>
+#include <time.h>
+#include <calendar-svc-provider.h>
+
+#define D20120601T000000 1338508800
+#define D20120931T100000 1349085600
+
+int _get_iter_period_normal_onoff(int calendar_id, long long int llis, long long int llie)
+{
+ int index;
+ int is_exist = 0;
+ long long int s;
+ cal_iter *iter;
+ cal_struct *cs;
+
+ calendar_svc_event_get_normal_list_by_period(calendar_id, CALS_LIST_PERIOD_NORMAL_ONOFF,
+ llis, llie, &iter);
+ while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
+ is_exist = 1;
+ cs = NULL;
+ calendar_svc_iter_get_info(iter, &cs);
+ index = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_NORMAL_ONOFF_INT_EVENTID);
+ s = calendar_svc_struct_get_lli(cs, CALS_LIST_PERIOD_NORMAL_ONOFF_LLI_DTSTART_UTIME);
+ printf("index(%d)dtstart utime:%lld\n", index, s);
+ }
+ calendar_svc_iter_remove(&iter);
+ return is_exist;
+}
+
+int _get_iter_period_allday_onoff(int calendar_id,
+ int sy, int sm, int sd, int ey, int em, int ed)
+{
+ int index;
+ int dtstart_year, dtstart_month, dtstart_mday;
+ int is_exist = 0;
+ cal_iter *iter;
+ cal_struct *cs;
+
+ calendar_svc_event_get_allday_list_by_period(calendar_id, CALS_LIST_PERIOD_ALLDAY_ONOFF,
+ sy, sm, sd, ey, em, ed, &iter);
+ while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
+ is_exist = 1;
+ cs = NULL;
+ calendar_svc_iter_get_info(iter, &cs);
+ index = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_EVENTID);
+ dtstart_year = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTSTART_YEAR);
+ dtstart_month = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTSTART_MONTH);
+ dtstart_mday = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTSTART_MDAY);
+
+ printf("index(%d)dtstart datetime(%04d/%02d/%02d)\n", index, dtstart_year, dtstart_month, dtstart_mday);
+ }
+ calendar_svc_iter_remove(&iter);
+ return is_exist;
+}
+
+int _get_iter_period_normal_basic(int calendar_id, long long int llis, long long int llie)
+{
+ int index;
+ int is_exist = 0;
+ char *sum, *loc;
+ long long int s, e;
+ cal_iter *iter;
+ cal_struct *cs;
+
+ calendar_svc_event_get_normal_list_by_period(calendar_id, CALS_LIST_PERIOD_NORMAL_BASIC,
+ llis, llie, &iter);
+ while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
+ is_exist = 1;
+ cs = NULL;
+ calendar_svc_iter_get_info(iter, &cs);
+ index = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_NORMAL_BASIC_INT_EVENTID);
+ s = calendar_svc_struct_get_lli(cs, CALS_LIST_PERIOD_NORMAL_BASIC_LLI_DTSTART_UTIME);
+ e = calendar_svc_struct_get_lli(cs, CALS_LIST_PERIOD_NORMAL_BASIC_LLI_DTEND_UTIME);
+ sum = calendar_svc_struct_get_str(cs, CALS_LIST_PERIOD_NORMAL_BASIC_TXT_SUMMARY);
+ loc = calendar_svc_struct_get_str(cs, CALS_LIST_PERIOD_NORMAL_BASIC_TXT_LOCATION);
+ printf("index(%d) s(%lld) e(%lld), sum(%s) loc(%s)\n", index, s, e, sum, loc);
+ }
+ calendar_svc_iter_remove(&iter);
+ return is_exist;
+}
+
+int _get_iter_period_allday_basic(int calendar_id,
+ int sy, int sm, int sd, int ey, int em, int ed)
+{
+ int index;
+ int dtstart_year, dtstart_month, dtstart_mday;
+ int dtend_year, dtend_month, dtend_mday;
+ int is_exist = 0;
+ char *sum, *loc;
+ cal_iter *iter;
+ cal_struct *cs;
+
+ calendar_svc_event_get_allday_list_by_period(calendar_id, CALS_LIST_PERIOD_ALLDAY_BASIC,
+ sy, sm, sd, ey, em, ed, &iter);
+ while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
+ is_exist = 1;
+ cs = NULL;
+ calendar_svc_iter_get_info(iter, &cs);
+ index = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_EVENTID);
+ dtstart_year = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTSTART_YEAR);
+ dtstart_month = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTSTART_MONTH);
+ dtstart_mday = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTSTART_MDAY);
+ dtend_year = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTEND_YEAR);
+ dtend_month = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTEND_MONTH);
+ dtend_mday = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTEND_MDAY);
+ sum = calendar_svc_struct_get_str(cs, CALS_LIST_PERIOD_ALLDAY_BASIC_TXT_SUMMARY);
+ loc = calendar_svc_struct_get_str(cs, CALS_LIST_PERIOD_ALLDAY_BASIC_TXT_LOCATION);
+
+ printf("index(%d) (%04d/%02d/%02d) - (%04d/%02d/%02d)sum(%s) loc(%s)\n",
+ index,
+ dtstart_year, dtstart_month, dtstart_mday,
+ dtend_year, dtend_month, dtend_mday,
+ sum, loc);
+ }
+ calendar_svc_iter_remove(&iter);
+ return is_exist;
+}
+
+
+
+int _get_iter_period_normal_osp(int calendar_id, long long int llis, long long int llie)
+{
+ int index, cal_id, busy, meeting, prio, sensi;
+ int is_exist = 0;
+ char *sum, *loc, *dsc;
+ long long int s, e;
+ cal_iter *iter;
+ cal_struct *cs;
+
+ calendar_svc_event_get_normal_list_by_period(calendar_id, CALS_LIST_PERIOD_NORMAL_OSP,
+ llis, llie, &iter);
+ while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
+ is_exist = 1;
+ cs = NULL;
+ calendar_svc_iter_get_info(iter, &cs);
+ index = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_NORMAL_OSP_INT_EVENTID);
+ cal_id = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_NORMAL_OSP_INT_CALENDAR_ID);
+ busy = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_NORMAL_OSP_INT_BUSY_STATUS);
+ meeting = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_NORMAL_OSP_INT_STATUS);
+ prio = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_NORMAL_OSP_INT_PRIORITY);
+ sensi = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_NORMAL_OSP_INT_VISIBILITY);
+ s = calendar_svc_struct_get_lli(cs, CALS_LIST_PERIOD_NORMAL_OSP_LLI_DTSTART_UTIME);
+ e = calendar_svc_struct_get_lli(cs, CALS_LIST_PERIOD_NORMAL_OSP_LLI_DTEND_UTIME);
+ sum = calendar_svc_struct_get_str(cs, CALS_LIST_PERIOD_NORMAL_OSP_TXT_SUMMARY);
+ loc = calendar_svc_struct_get_str(cs, CALS_LIST_PERIOD_NORMAL_OSP_TXT_LOCATION);
+ dsc = calendar_svc_struct_get_str(cs, CALS_LIST_PERIOD_NORMAL_OSP_TXT_DESCRIPTION);
+ printf("index(%d) s(%lld) e(%lld), sum(%s) loc(%s) "
+ "dsc(%s) cal_id(%d) busy(%d) meeting(%d) prio(%d) sensi(%d)\n",
+ index, s, e, sum, loc, dsc, cal_id, busy, meeting, prio, sensi);
+ }
+ calendar_svc_iter_remove(&iter);
+ return is_exist;
+}
+
+int _get_iter_period_allday_osp(int calendar_id,
+ int sy, int sm, int sd, int ey, int em, int ed)
+{
+ int index, cal_id, busy, meeting, prio, sensi;
+ int dtstart_year, dtstart_month, dtstart_mday;
+ int dtend_year, dtend_month, dtend_mday;
+ int is_exist = 0;
+ char *sum, *loc, *dsc;
+ cal_iter *iter;
+ cal_struct *cs;
+
+ calendar_svc_event_get_allday_list_by_period(calendar_id, CALS_LIST_PERIOD_ALLDAY_OSP,
+ sy, sm, sd, ey, em, ed, &iter);
+ while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
+ is_exist = 1;
+ cs = NULL;
+ calendar_svc_iter_get_info(iter, &cs);
+ index = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_OSP_INT_EVENTID);
+ dtstart_year = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTSTART_YEAR);
+ dtstart_month = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTSTART_MONTH);
+ dtstart_mday = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTSTART_MDAY);
+ dtend_year = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTEND_YEAR);
+ dtend_month = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTEND_MONTH);
+ dtend_mday = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTEND_MDAY);
+ sum = calendar_svc_struct_get_str(cs, CALS_LIST_PERIOD_ALLDAY_OSP_TXT_SUMMARY);
+ loc = calendar_svc_struct_get_str(cs, CALS_LIST_PERIOD_ALLDAY_OSP_TXT_LOCATION);
+ cal_id = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_OSP_INT_CALENDAR_ID);
+ busy = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_OSP_INT_BUSY_STATUS);
+ meeting = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_OSP_INT_STATUS);
+ prio = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_OSP_INT_PRIORITY);
+ sensi = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_OSP_INT_VISIBILITY);
+ dsc = calendar_svc_struct_get_str(cs, CALS_LIST_PERIOD_ALLDAY_OSP_TXT_DESCRIPTION);
+
+ printf("index(%d) (%04d/%02d/%02d) - (%04d/%02d/%02d)sum(%s) loc(%s) "
+ "dsc(%s) cal_id(%d) busy(%d) meeting(%d) prio(%d) sensi(%d)\n",
+ index,
+ dtstart_year, dtstart_month, dtstart_mday,
+ dtend_year, dtend_month, dtend_mday,
+ sum, loc,
+ dsc, cal_id, busy, meeting, prio, sensi);
+ }
+ calendar_svc_iter_remove(&iter);
+ return is_exist;
+}
+
+int main(int argc, char **argv)
+{
+ int index;
+ int is_exist;;
+ long long int lli;
+
+ calendar_svc_connect();
+
+ printf("======= CALS_LIST_PERIOD_NORMAL_ONOFF ======\n");
+ printf("\nall calendar(-1)\n");
+ is_exist = _get_iter_period_normal_onoff(-1, D20120601T000000, D20120931T100000);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("\ncalendar(1)\n");
+ is_exist = _get_iter_period_normal_onoff(1, D20120601T000000, D20120931T100000);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("\ncalendar(2)\n");
+ is_exist = _get_iter_period_normal_onoff(2, D20120601T000000, D20120931T100000);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("======= CALS_LIST_PERIOD_ALLDAY_ONOFF ======\n");
+ printf("\nall calendar(-1)\n");
+ is_exist = _get_iter_period_allday_onoff(-1, 2012, 6, 1, 2012, 9, 31);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("\ncalendar(1)\n");
+ is_exist = _get_iter_period_allday_onoff(1, 2012, 6, 1, 2012, 9, 31);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("\ncalendar(2)\n");
+ is_exist = _get_iter_period_allday_onoff(2, 2012, 6, 1, 2012, 9, 31);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("======= CALS_LIST_PERIOD_NORMAL_BASIC ======\n");
+ printf("\nall calendar(-1)\n");
+ is_exist = _get_iter_period_normal_basic(-1, D20120601T000000, D20120931T100000);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("\ncalendar(1)\n");
+ is_exist = _get_iter_period_normal_basic(1, D20120601T000000, D20120931T100000);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("\ncalendar(2)\n");
+ is_exist = _get_iter_period_normal_basic(2, D20120601T000000, D20120931T100000);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("======= CALS_LIST_PERIOD_ALLDAY_BASIC ======\n");
+ printf("\nall calendar(-1)\n");
+ is_exist = _get_iter_period_allday_basic(-1, 2012, 6, 1, 2012, 9, 31);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("\ncalendar(1)\n");
+ is_exist = _get_iter_period_allday_basic(1, 2012, 6, 1, 2012, 9, 31);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("\ncalendar(2)\n");
+ is_exist = _get_iter_period_allday_basic(2, 2012, 6, 1, 2012, 9, 31);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("======= CALS_LIST_PERIOD_NORMAL_OSP ======\n");
+ printf("\nall calendar(-1)\n");
+ is_exist = _get_iter_period_normal_osp(-1, D20120601T000000, D20120931T100000);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("\ncalendar(1)\n");
+ is_exist = _get_iter_period_normal_osp(1, D20120601T000000, D20120931T100000);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("\ncalendar(2)\n");
+ is_exist = _get_iter_period_normal_osp(2, D20120601T000000, D20120931T100000);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("======= CALS_LIST_PERIOD_ALLDAY_OSP ======\n");
+ printf("\nall calendar(-1)\n");
+ is_exist = _get_iter_period_allday_osp(-1, 2012, 6, 1, 2012, 9, 31);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("\ncalendar(1)\n");
+ is_exist = _get_iter_period_allday_osp(1, 2012, 6, 1, 2012, 9, 31);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("\ncalendar(2)\n");
+ is_exist = _get_iter_period_allday_osp(2, 2012, 6, 1, 2012, 9, 31);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ calendar_svc_close();
+
+
+ long long int ts;
+ int i, y, m, d, h, min, s;
+ char mon[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+ long long int th = 62167219200;
+
+ y = 1970;
+ m = 1;
+ d = 1;
+
+ ts = y*365;
+ printf("%lld\n", ts);
+ ts = ts + (int)y/4 - (int)y/100 + (int)y/400;
+ printf("%lld\n", ts);
+ for (i = 0; i < m-1; i++) {
+ ts += mon[i];
+ }
+ ts = ts + d;
+ printf("%lld\n", ts);
+ ts = ts * 24;
+ printf("%lld\n", ts);
+ ts = ts * 60;
+ printf("%lld\n", ts);
+ ts = ts * 60;
+ printf("bb:%lld\n", ts);
+ th = ts;
+
+
+ y = 2012;
+ m = 6;
+ d = 1;
+
+ ts = y*365;
+ printf("%lld\n", ts);
+ ts = ts + (int)y/4 - (int)y/100 + (int)y/400;
+ printf("%lld\n", ts);
+ for (i = 0; i < m-1; i++) {
+ ts += mon[i];
+ }
+ ts = ts + d;
+ printf("%lld\n", ts);
+ ts = ts * 24;
+ printf("%lld\n", ts);
+ ts = ts * 60;
+ printf("%lld\n", ts);
+ ts = ts * 60;
+ printf("%lld\n", ts);
+ ts = ts - 62167219200;
+ printf("aa%lld\n", ts);
+
+ ts = 1338508800;
+ ts = ts / 60;
+ printf("%lld\n", ts);
+ ts = ts / 60;
+ printf("%lld\n", ts);
+ ts = ts / 24;
+ printf("%lld\n", ts);
+
+ printf("%lld\n", ts / 365);
+ printf("%lld\n", ts % 365);
+
+ ts = ts - mon[m-1] - d;
+ printf("%lld\n", ts);
+ ts = ts - y/4 + y/100 - y/400;
+ printf("%lld\n", ts);
+
+
+
+ ts = 1338508800;
+ ts += 62167219200;
+ s = ts % 60;
+ ts /= 60;
+ min = ts % 60;
+ ts /= 60;
+ h = ts % 24;
+ ts /= 24;
+ y = (ts * 400) / (365 * 400 + 100 - 4 + 1);
+ ts = ts - (y * 365) - (y/4) + (y/100) - (y/400);
+ m = 0;
+ while (ts > mon[m]) {
+ ts -= mon[m];
+ m++;
+ }
+ m++;
+ d = ts;
+ printf("%04d/%02d/%02d %d:%d:%d\n", y, m, d, h, min, s);
+
+ return 0;
+}
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <calendar-svc-provider.h>
+#include "utime.h"
+
+int main(int argc, char **argv)
+{
+ int ret;
+ int idx;
+ int intv;
+ long long int get_lli;
+ cal_struct *cs = NULL;
+
+ if (argc < 2)
+ return -1;
+
+ idx = atoi(argv[1]);
+
+ calendar_svc_connect();
+
+ calendar_svc_get(CAL_STRUCT_SCHEDULE, idx, NULL, &cs);
+
+ get_lli = calendar_svc_struct_get_lli(cs, CALS_VALUE_LLI_DTSTART_UTIME);
+ printf("%lld\n", get_lli);
+ get_lli = calendar_svc_struct_get_lli(cs, CALS_VALUE_LLI_DTEND_UTIME);
+ printf("%lld\n", get_lli);
+
+
+ intv = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_RRULE_ID);
+ printf("id:%d\n", intv);
+ intv = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_RRULE_FREQ);
+ printf("freq:%d\n", intv);
+
+ calendar_svc_close();
+
+ calendar_svc_struct_free(&cs);
+ return ret;
+}
--- /dev/null
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <calendar-svc-provider.h>
+
+int main(int argc, char **argv)
+{
+ int r;
+ int calendar_id;
+ char *path;
+
+ calendar_id = atoi(argv[1]);
+ printf("calendar id(%d)\n", calendar_id);
+
+ path = argv[2];
+ printf("path(%s)\n", path);
+
+ calendar_svc_connect();
+
+ r = calendar_svc_calendar_export(calendar_id, path);
+ if (r != CAL_SUCCESS) {
+ printf("Failed to export schedules\n");
+ return -1;
+ }
+
+ calendar_svc_close();
+ return 0;
+}
--- /dev/null
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <calendar-svc-provider.h>
+
+/*
+ * argv[1]: path
+ * argv[2]: calendar_id
+ */
+int main(int argc, char **argv)
+{
+ int ret, calendar_id;
+ char *path;
+
+ if (argc < 3) {
+ printf("argument needs 3\n");
+ return -1;
+ }
+
+ if (argv[1] == NULL || argv[2] == NULL) {
+ printf("Invalid argument\n");
+ return -1;
+ }
+
+ path = argv[1];
+ calendar_id = atoi(argv[2]);
+
+ calendar_svc_connect();
+
+ ret = calendar_svc_calendar_import(path, calendar_id);
+ if (ret != CAL_SUCCESS) {
+ printf("Failed to import path(%s) to calendar id(%d)\n", path, calendar_id);
+ return -1;
+ }
+
+ calendar_svc_close();
+ return 0;
+}
--- /dev/null
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <time.h>
+#include <glib.h>
+#include <calendar-svc-provider.h>
+
+static char* _get_stream(const char *path)
+{
+ FILE *file;
+ int buf_size, len;
+ char *stream;
+ char buf[1024];
+
+ file = fopen(path, "r");
+
+ len = 0;
+ buf_size = 1024;
+ stream = malloc(1024);
+
+ 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);
+ printf("out of memory\n");
+ return NULL;
+ }
+ len += snprintf(stream + len, strlen(buf) +1, "%s", buf);
+ }
+ }
+ fclose(file);
+ return stream;
+}
+
+static int _do_import_with_newapi(char *stream)
+{
+ int ret;
+ char *vals;
+ char buf[256];
+ time_t tt;
+ cal_struct *cs = NULL;
+ cal_value *cv = NULL;
+ GList *ls, *schedules = NULL;
+ GList *lc, *categories = NULL;
+
+ if (stream == NULL) {
+ printf("Invalid argument: stream is NULL\n");
+ return -1;
+ }
+
+ ret = calendar_svc_read_schedules(stream, &schedules);
+ if (ret != CAL_SUCCESS) {
+ printf("Failed to read schedules(errno:%d)\n", ret);
+ return -1;
+ }
+
+ if (schedules == NULL) {
+ printf("No schedules\n");
+ return -1;
+ }
+
+ ls = schedules;
+ while (ls) {
+ cs = ls->data;
+ if (cs == NULL) {
+ ls = g_list_next(ls);
+ continue;
+ }
+ vals = NULL;
+ vals = calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_SUMMARY);
+ printf("summary:%s\n", vals);
+
+ vals = calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_CATEGORIES);
+ printf("categories:%s\n", vals);
+
+ tt = calendar_svc_struct_get_time(cs,
+ CAL_VALUE_GMT_START_DATE_TIME, CAL_TZ_FLAG_LOCAL);
+ ctime_r(&tt, buf);
+ printf("stime:%s", buf);
+
+ tt = calendar_svc_struct_get_time(cs,
+ CAL_VALUE_GMT_END_DATE_TIME, CAL_TZ_FLAG_LOCAL);
+ ctime_r(&tt, buf);
+ printf("etime:%s", buf);
+
+ vals = calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_DESCRIPTION);
+ if (vals) {
+ printf("desc(%s)\n", vals);
+ } else {
+ printf("No description\n");
+ }
+
+ ls = g_list_next(ls);
+ }
+ return 0;
+}
+
+/*
+ * argv[1]: file path
+ */
+int main(int argc, char **argv)
+{
+ int sel;
+ char *stream = NULL;
+ stream = _get_stream(argv[1]);
+
+ _do_import_with_newapi(stream);
+
+printf("%d\n", __LINE__);
+// if (stream) free(stream);
+
+ return 0;
+}
--- /dev/null
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <calendar-svc-provider.h>
+
+int main(int argc, char **argv)
+{
+ int ret;
+ char *stream;
+ GList *schedules = NULL;
+ cal_struct *cs = NULL;
+
+ cs = calendar_svc_struct_new(CAL_STRUCT_CALENDAR);
+ if (cs == NULL) {
+ printf("Failed to calloc\n");
+ return-1;
+ }
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_SUMMARY, "title");
+ /* set data in cs... */
+
+ schedules = g_list_append(schedules, cs);
+
+ ret = calendar_svc_write_schedules(schedules, &stream);
+ if (ret != CAL_SUCCESS) {
+ printf("Failed to read schedules(errno:%d)\n", ret);
+ return -1;
+ }
+
+ if (stream == NULL) {
+ printf("stream is NULL\n");
+ return -1;
+ }
+
+ return 0;
+}
--- /dev/null
+
+#include <stdio.h>
+#include <time.h>
+#include <calendar-svc-provider.h>
+#include "utime.h"
+
+int main(int argc, char **argv)
+{
+ int ret;
+ int index;
+
+ if (argc < 2) {
+ printf("needs 2 arguments\n");
+ return -1;
+ }
+
+ index = atoi(argv[1]);
+ if (index < 0) {
+ printf("Invalid index (%d)\n", index);
+ return -1;
+ }
+
+ calendar_svc_connect();
+// calendar_svc_event_delete_normal_instance(index, 1445299200);
+ calendar_svc_event_delete_allday_instance(index, 2013, 9, 22);
+ calendar_svc_close();
+ return 0;
+}
--- /dev/null
+
+#include <stdio.h>
+#include <time.h>
+#include <calendar-svc-provider.h>
+
+
+int main(int argc, char **argv)
+{
+ int index;
+ int ret;
+ int cal_id, acc_id;
+ char *sum;
+ cal_iter *iter;
+ cal_struct *cs;
+
+ calendar_svc_connect();
+
+ ret = calendar_svc_get_list(0, 0, CAL_STRUCT_SCHEDULE, NULL, 0, 10, &iter);
+ if (ret != CAL_SUCCESS) {
+ printf("Failed to get list\n");
+ return -1;
+ }
+ while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
+ cs = NULL;
+ ret = calendar_svc_iter_get_info(iter, &cs);
+ if (ret != CAL_SUCCESS) {
+ printf("Failed to get info\n");
+ break;
+ }
+ sum = calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_SUMMARY);
+ printf("summary(%s)\n", sum);
+ }
+ calendar_svc_iter_remove(&iter);
+ calendar_svc_close();
+
+ return 0;
+}
--- /dev/null
+
+#include <stdio.h>
+#include <time.h>
+#include <calendar-svc-provider.h>
+
+#define D20120601T000000 1338508800
+#define D20120931T100000 1349085600
+
+int _get_iter_period_normal_onoff(int calendar_id, long long int llis, long long int llie)
+{
+ int index;
+ int is_exist = 0;
+ long long int s;
+ cal_iter *iter;
+ cal_struct *cs;
+
+ calendar_svc_event_get_normal_list_by_period(calendar_id, CALS_LIST_PERIOD_NORMAL_ONOFF,
+ llis, llie, &iter);
+ while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
+ is_exist = 1;
+ cs = NULL;
+ calendar_svc_iter_get_info(iter, &cs);
+ index = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_NORMAL_ONOFF_INT_EVENTID);
+ s = calendar_svc_struct_get_lli(cs, CALS_LIST_PERIOD_NORMAL_ONOFF_LLI_DTSTART_UTIME);
+ printf("index(%d)dtstart utime:%lld\n", index, s);
+ }
+ return is_exist;
+}
+
+int _get_iter_period_allday_onoff(int calendar_id,
+ int sy, int sm, int sd, int ey, int em, int ed)
+{
+ int index;
+ int dtstart_year, dtstart_month, dtstart_mday;
+ int is_exist = 0;
+ cal_iter *iter;
+ cal_struct *cs;
+
+ calendar_svc_event_get_allday_list_by_period(calendar_id, CALS_LIST_PERIOD_ALLDAY_ONOFF,
+ sy, sm, sd, ey, em, ed, &iter);
+ while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
+ is_exist = 1;
+ cs = NULL;
+ calendar_svc_iter_get_info(iter, &cs);
+ index = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_EVENTID);
+ dtstart_year = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTSTART_YEAR);
+ dtstart_month = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTSTART_MONTH);
+ dtstart_mday = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_ONOFF_INT_DTSTART_MDAY);
+
+ printf("index(%d)dtstart datetime(%04d/%02d/%02d)\n", index, dtstart_year, dtstart_month, dtstart_mday);
+ }
+ return is_exist;
+}
+
+int _get_iter_period_normal_basic(int calendar_id, long long int llis, long long int llie)
+{
+ int index;
+ int is_exist = 0;
+ char *sum, *loc;
+ long long int s, e;
+ cal_iter *iter;
+ cal_struct *cs;
+
+ calendar_svc_event_get_normal_list_by_period(calendar_id, CALS_LIST_PERIOD_NORMAL_BASIC,
+ llis, llie, &iter);
+ while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
+ is_exist = 1;
+ cs = NULL;
+ calendar_svc_iter_get_info(iter, &cs);
+ index = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_NORMAL_BASIC_INT_EVENTID);
+ s = calendar_svc_struct_get_lli(cs, CALS_LIST_PERIOD_NORMAL_BASIC_LLI_DTSTART_UTIME);
+ e = calendar_svc_struct_get_lli(cs, CALS_LIST_PERIOD_NORMAL_BASIC_LLI_DTEND_UTIME);
+ sum = calendar_svc_struct_get_str(cs, CALS_LIST_PERIOD_NORMAL_BASIC_TXT_SUMMARY);
+ loc = calendar_svc_struct_get_str(cs, CALS_LIST_PERIOD_NORMAL_BASIC_TXT_LOCATION);
+ printf("index(%d) s(%lld) e(%lld), sum(%s) loc(%s)\n", index, s, e, sum, loc);
+ }
+ return is_exist;
+}
+
+int _get_iter_period_allday_basic(int calendar_id,
+ int sy, int sm, int sd, int ey, int em, int ed)
+{
+ int index;
+ int dtstart_year, dtstart_month, dtstart_mday;
+ int dtend_year, dtend_month, dtend_mday;
+ int is_exist = 0;
+ char *sum, *loc;
+ cal_iter *iter;
+ cal_struct *cs;
+
+ calendar_svc_event_get_allday_list_by_period(calendar_id, CALS_LIST_PERIOD_ALLDAY_BASIC,
+ sy, sm, sd, ey, em, ed, &iter);
+ while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
+ is_exist = 1;
+ cs = NULL;
+ calendar_svc_iter_get_info(iter, &cs);
+ index = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_EVENTID);
+ dtstart_year = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTSTART_YEAR);
+ dtstart_month = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTSTART_MONTH);
+ dtstart_mday = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTSTART_MDAY);
+ dtend_year = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTEND_YEAR);
+ dtend_month = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTEND_MONTH);
+ dtend_mday = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_BASIC_INT_DTEND_MDAY);
+ sum = calendar_svc_struct_get_str(cs, CALS_LIST_PERIOD_ALLDAY_BASIC_TXT_SUMMARY);
+ loc = calendar_svc_struct_get_str(cs, CALS_LIST_PERIOD_ALLDAY_BASIC_TXT_LOCATION);
+
+ printf("index(%d) (%04d/%02d/%02d) - (%04d/%02d/%02d)sum(%s) loc(%s)\n",
+ index,
+ dtstart_year, dtstart_month, dtstart_mday,
+ dtend_year, dtend_month, dtend_mday,
+ sum, loc);
+ }
+ return is_exist;
+}
+
+
+
+int _get_iter_period_normal_osp(int calendar_id, long long int llis, long long int llie)
+{
+ int index, cal_id, busy, meeting, prio, sensi;
+ int is_exist = 0;
+ char *sum, *loc, *dsc;
+ long long int s, e;
+ cal_iter *iter;
+ cal_struct *cs;
+
+ calendar_svc_event_get_normal_list_by_period(calendar_id, CALS_LIST_PERIOD_NORMAL_OSP,
+ llis, llie, &iter);
+ while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
+ is_exist = 1;
+ cs = NULL;
+ calendar_svc_iter_get_info(iter, &cs);
+ index = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_NORMAL_OSP_INT_EVENTID);
+ cal_id = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_NORMAL_OSP_INT_CALENDAR_ID);
+ busy = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_NORMAL_OSP_INT_BUSY_STATUS);
+ meeting = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_NORMAL_OSP_INT_STATUS);
+ prio = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_NORMAL_OSP_INT_PRIORITY);
+ sensi = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_NORMAL_OSP_INT_VISIBILITY);
+ s = calendar_svc_struct_get_lli(cs, CALS_LIST_PERIOD_NORMAL_OSP_LLI_DTSTART_UTIME);
+ e = calendar_svc_struct_get_lli(cs, CALS_LIST_PERIOD_NORMAL_OSP_LLI_DTEND_UTIME);
+ sum = calendar_svc_struct_get_str(cs, CALS_LIST_PERIOD_NORMAL_OSP_TXT_SUMMARY);
+ loc = calendar_svc_struct_get_str(cs, CALS_LIST_PERIOD_NORMAL_OSP_TXT_LOCATION);
+ dsc = calendar_svc_struct_get_str(cs, CALS_LIST_PERIOD_NORMAL_OSP_TXT_DESCRIPTION);
+ printf("index(%d) s(%lld) e(%lld), sum(%s) loc(%s) "
+ "dsc(%s) cal_id(%d) busy(%d) meeting(%d) prio(%d) sensi(%d)\n",
+ index, s, e, sum, loc, dsc, cal_id, busy, meeting, prio, sensi);
+ }
+ return is_exist;
+}
+
+int _get_iter_period_allday_osp(int calendar_id,
+ int sy, int sm, int sd, int ey, int em, int ed)
+{
+ int index, cal_id, busy, meeting, prio, sensi;
+ int dtstart_year, dtstart_month, dtstart_mday;
+ int dtend_year, dtend_month, dtend_mday;
+ int is_exist = 0;
+ char *sum, *loc, *dsc;
+ cal_iter *iter;
+ cal_struct *cs;
+
+ calendar_svc_event_get_allday_list_by_period(calendar_id, CALS_LIST_PERIOD_ALLDAY_OSP,
+ sy, sm, sd, ey, em, ed, &iter);
+ while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
+ is_exist = 1;
+ cs = NULL;
+ calendar_svc_iter_get_info(iter, &cs);
+ index = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_OSP_INT_EVENTID);
+ dtstart_year = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTSTART_YEAR);
+ dtstart_month = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTSTART_MONTH);
+ dtstart_mday = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTSTART_MDAY);
+ dtend_year = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTEND_YEAR);
+ dtend_month = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTEND_MONTH);
+ dtend_mday = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_OSP_INT_DTEND_MDAY);
+ sum = calendar_svc_struct_get_str(cs, CALS_LIST_PERIOD_ALLDAY_OSP_TXT_SUMMARY);
+ loc = calendar_svc_struct_get_str(cs, CALS_LIST_PERIOD_ALLDAY_OSP_TXT_LOCATION);
+ cal_id = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_OSP_INT_CALENDAR_ID);
+ busy = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_OSP_INT_BUSY_STATUS);
+ meeting = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_OSP_INT_STATUS);
+ prio = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_OSP_INT_PRIORITY);
+ sensi = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_ALLDAY_OSP_INT_VISIBILITY);
+ dsc = calendar_svc_struct_get_str(cs, CALS_LIST_PERIOD_ALLDAY_OSP_TXT_DESCRIPTION);
+
+ printf("index(%d) (%04d/%02d/%02d) - (%04d/%02d/%02d)sum(%s) loc(%s) "
+ "dsc(%s) cal_id(%d) busy(%d) meeting(%d) prio(%d) sensi(%d)\n",
+ index,
+ dtstart_year, dtstart_month, dtstart_mday,
+ dtend_year, dtend_month, dtend_mday,
+ sum, loc,
+ dsc, cal_id, busy, meeting, prio, sensi);
+ }
+ return is_exist;
+}
+
+int main(int argc, char **argv)
+{
+ int index;
+ int is_exist;;
+ long long int lli;
+ cal_iter *iter;
+ cal_struct *cs;
+
+ calendar_svc_connect();
+
+ printf("======= CALS_LIST_PERIOD_NORMAL_ONOFF ======\n");
+ printf("\nall calendar(-1)\n");
+ is_exist = _get_iter_period_normal_onoff(-1, D20120601T000000, D20120931T100000);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("\ncalendar(1)\n");
+ is_exist = _get_iter_period_normal_onoff(1, D20120601T000000, D20120931T100000);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("\ncalendar(2)\n");
+ is_exist = _get_iter_period_normal_onoff(2, D20120601T000000, D20120931T100000);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("======= CALS_LIST_PERIOD_ALLDAY_ONOFF ======\n");
+ printf("\nall calendar(-1)\n");
+ is_exist = _get_iter_period_allday_onoff(-1, 2012, 6, 1, 2012, 9, 31);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("\ncalendar(1)\n");
+ is_exist = _get_iter_period_allday_onoff(1, 2012, 6, 1, 2012, 9, 31);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("\ncalendar(2)\n");
+ is_exist = _get_iter_period_allday_onoff(2, 2012, 6, 1, 2012, 9, 31);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("======= CALS_LIST_PERIOD_NORMAL_BASIC ======\n");
+ printf("\nall calendar(-1)\n");
+ is_exist = _get_iter_period_normal_basic(-1, D20120601T000000, D20120931T100000);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("\ncalendar(1)\n");
+ is_exist = _get_iter_period_normal_basic(1, D20120601T000000, D20120931T100000);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("\ncalendar(2)\n");
+ is_exist = _get_iter_period_normal_basic(2, D20120601T000000, D20120931T100000);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("======= CALS_LIST_PERIOD_ALLDAY_BASIC ======\n");
+ printf("\nall calendar(-1)\n");
+ is_exist = _get_iter_period_allday_basic(-1, 2012, 6, 1, 2012, 9, 31);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("\ncalendar(1)\n");
+ is_exist = _get_iter_period_allday_basic(1, 2012, 6, 1, 2012, 9, 31);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("\ncalendar(2)\n");
+ is_exist = _get_iter_period_allday_basic(2, 2012, 6, 1, 2012, 9, 31);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("======= CALS_LIST_PERIOD_NORMAL_OSP ======\n");
+ printf("\nall calendar(-1)\n");
+ is_exist = _get_iter_period_normal_osp(-1, D20120601T000000, D20120931T100000);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("\ncalendar(1)\n");
+ is_exist = _get_iter_period_normal_osp(1, D20120601T000000, D20120931T100000);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("\ncalendar(2)\n");
+ is_exist = _get_iter_period_normal_osp(2, D20120601T000000, D20120931T100000);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("======= CALS_LIST_PERIOD_ALLDAY_OSP ======\n");
+ printf("\nall calendar(-1)\n");
+ is_exist = _get_iter_period_allday_osp(-1, 2012, 6, 1, 2012, 9, 31);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("\ncalendar(1)\n");
+ is_exist = _get_iter_period_allday_osp(1, 2012, 6, 1, 2012, 9, 31);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+ printf("\ncalendar(2)\n");
+ is_exist = _get_iter_period_allday_osp(2, 2012, 6, 1, 2012, 9, 31);
+ if (is_exist == 0) {
+ printf("no data exist\n");
+ }
+
+
+
+ long long int ts;
+ int i, y, m, d;
+ char mon[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+ long long int th = 62167219200;
+
+ y = 1970;
+ m = 1;
+ d = 1;
+
+ ts = y*365;
+ printf("%lld\n", ts);
+ ts = ts + (int)y/4 - (int)y/100 + (int)y/400;
+ printf("%lld\n", ts);
+ for (i = 0; i < m-1; i++) {
+ ts += mon[i];
+ }
+ ts = ts + d;
+ printf("%lld\n", ts);
+ ts = ts * 24;
+ printf("%lld\n", ts);
+ ts = ts * 60;
+ printf("%lld\n", ts);
+ ts = ts * 60;
+ printf("bb:%lld\n", ts);
+ th = ts;
+
+
+ y = 2012;
+ m = 6;
+ d = 1;
+
+ ts = y*365;
+ printf("%lld\n", ts);
+ ts = ts + (int)y/4 - (int)y/100 + (int)y/400;
+ printf("%lld\n", ts);
+ for (i = 0; i < m-1; i++) {
+ ts += mon[i];
+ }
+ ts = ts + d;
+ printf("%lld\n", ts);
+ ts = ts * 24;
+ printf("%lld\n", ts);
+ ts = ts * 60;
+ printf("%lld\n", ts);
+ ts = ts * 60;
+ printf("%lld\n", ts);
+ ts = ts - 62167219200;
+ printf("aa%lld\n", ts);
+
+ ts = 1338508800;
+ ts = ts / 60;
+ printf("%lld\n", ts);
+ ts = ts / 60;
+ printf("%lld\n", ts);
+ ts = ts / 24;
+ printf("%lld\n", ts);
+
+ printf("%lld\n", ts / 365);
+ printf("%lld\n", ts % 365);
+
+ ts = ts - mon[m-1] - d;
+ printf("%lld\n", ts);
+ ts = ts - y/4 + y/100 - y/400;
+ printf("%lld\n", ts);
+
+ calendar_svc_close();
+ return 0;
+}
--- /dev/null
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <time.h>
+#include <calendar-svc-provider.h>
+#include "utime.h"
+
+#define D19700101 62167219200
+char cal_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+
+long long int _mkutime(int y, int mon, int d, int h, int min, int s)
+{
+ int i;
+ long long int t;
+
+ t = y * 365;
+ t += ((int)y/4 - (int)y/100 + (int)y/400);
+ for (i = 0; i < mon-1; i++) {
+ t += cal_month[i];
+ }
+ if (i > 2 && (y % 4 == 0)) {
+ t += 1;
+ if ((y % 100 == 0) && (y % 400 != 0)) {
+ t -= 1;
+ }
+ }
+ t += d;
+ t *= (24 * 60 * 60);
+ t += (((h * 60) + min ) * 60 + s);
+ t -= D19700101;
+ return t;
+}
+
+char *_mkdatetime(long long int lli)
+{
+ int y, mon, d, h, min, s;
+ long long int t;
+ static char buf[17];
+
+ t = lli + D19700101;
+ s = t % 60;
+ t /= 60;
+ min = t % 60;
+ t /= 60;
+ h = t % 24;
+ t /= 24;
+ y = (t * 400) / (365 * 400 + 100 - 4 + 1);
+ t = t - (y * 365) - (y/4) + (y/100) - (y/400);
+ mon = 0;
+ while (t > cal_month[mon]) {
+ if (t == 29 && mon == 1 && y % 4 == 0) {
+ if (y % 100 == 0 && y % 400 != 0) {
+ break;
+ }
+ } else {
+ t -= cal_month[mon];
+ mon++;
+ }
+ }
+ mon++;
+ d = t;
+ snprintf(buf, sizeof(buf), "%04d/%02d/%02d %02d:%02d:%02dZ", y, mon, d, h, min, s);
+ return strdup(buf);
+}
+
+int main(int argc, char **argv)
+{
+ int ret;
+ int index = 0;
+ cal_struct *cs = NULL;
+
+ if (argc < 2) {
+ printf("needs 2 arguments\n");
+ return -1;
+ }
+
+ index = atoi(argv[1]);
+ if (index < 0) {
+ printf("Invalid index (%d)\n", index);
+ return -1;
+ }
+
+ cs = calendar_svc_struct_new(CAL_STRUCT_SCHEDULE);
+ if (cs == NULL) {
+ printf("Failed to new calendar\n");
+ return -1;
+ }
+
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_ACCOUNT_ID, -1);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_CALENDAR_ID, 1);
+
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_SUMMARY, "event summary");
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTSTART_TYPE, CALS_TIME_UTIME);
+ calendar_svc_struct_set_lli(cs, CALS_VALUE_LLI_DTSTART_UTIME, D20120701T000000);
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_DTSTART_TZID, "Europe/London");
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTEND_TYPE, CALS_TIME_UTIME);
+ calendar_svc_struct_set_lli(cs, CALS_VALUE_LLI_DTEND_UTIME, D20120701T060000);
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_DTEND_TZID, "Europe/London");
+
+
+ /* freq */
+
+ switch (index) {
+
+/* yearly */
+ case 0: // bad
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_YEARLY);
+ break;
+
+ case 1: // bad
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_YEARLY);
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYMONTH, "7");
+ break;
+
+ case 2: // bad
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_YEARLY);
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYWEEKNO, "5, 6");
+ break;
+
+ case 3: // bad
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_YEARLY);
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYYEARDAY, "5");
+ break;
+
+ case 4:
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_YEARLY);
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYMONTHDAY, "5");
+ break;
+
+/* monthly */
+ case 10: // bad
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_MONTHLY);
+ break;
+
+ case 11: // bad: not working bymonth
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_MONTHLY);
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYMONTH, "3, 7");
+ break;
+
+ case 12: // good
+ printf("every 11st, 25th in a month\n");
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_MONTHLY);
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYMONTHDAY, "11, 25");
+ break;
+
+ case 13: // good
+ printf("eveny 2nd Monday, 3rd Friday in a month\n");
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_MONTHLY);
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYDAY, "2MO,3FR");
+ break;
+
+ case 14: // bad
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_MONTHLY);
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYDAY, "2MO,3FR");
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYSETPOS, "2");
+ break;
+
+/* weekly */
+ case 20: // bad
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_WEEKLY);
+ break;
+
+ case 21: // bad
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_WEEKLY);
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYMONTH, "3, 7");
+ break;
+
+ case 22: // good
+ printf("every Saturday, Tuesday in a week\n");
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_WEEKLY);
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYDAY, "SA,TU");
+ break;
+
+ case 23: // bad
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_WEEKLY);
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYDAY, "SA,TU");
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYSETPOS, "2");
+ break;
+
+/* daily */
+ case 30: //good
+ printf("every day\n");
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_DAILY);
+ break;
+
+ case 31: // bad
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_DAILY);
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYMONTH, "3, 9");
+ break;
+
+ case 32: // bad
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_DAILY);
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYMONTHDAY, "10, 15");
+ break;
+
+ case 33: // bad
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_FREQ, CALS_FREQ_DAILY);
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYDAY, "SA");
+ break;
+
+ default:
+ break;
+
+ }
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_INTERVAL, 1);
+
+ /* until */
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_RANGE_TYPE, CALS_RANGE_COUNT);
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_COUNT, 4);
+// calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_UNTIL_TYPE, CALS_TIME_UTIME);
+// calendar_svc_struct_set_lli(cs, CALS_VALUE_LLI_RRULE_UNTIL_UTIME, D20150701T000000);
+
+ calendar_svc_connect();
+ ret = calendar_svc_insert(cs);
+ calendar_svc_struct_free(&cs);
+
+
+ int cnt = 0;
+ long long int dtstart_utime;
+ long long int from, to;
+ char *str;
+ cal_iter *iter = NULL;
+
+ from = _mkutime(2012, 1, 1, 0, 0, 0);
+ to = _mkutime(2012, 12, 31, 0, 0, 0);
+ calendar_svc_event_get_normal_list_by_period(1,
+ CALS_LIST_PERIOD_NORMAL_ONOFF, from, to, &iter);
+
+ while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
+ cs = NULL;
+ calendar_svc_iter_get_info(iter, &cs);
+ dtstart_utime = calendar_svc_struct_get_lli(cs,
+ CALS_LIST_PERIOD_NORMAL_ONOFF_LLI_DTSTART_UTIME);
+ str = _mkdatetime(dtstart_utime);
+ printf("%02d dtstart_utime(%s)\n", ++cnt, str);
+ if (str) free(str);
+ calendar_svc_struct_free(&cs);
+ }
+
+// calendar_svc_delete(CAL_STRUCT_SCHEDULE, ret);
+ calendar_svc_close();
+
+ return 0;
+}
#include "test-log.h"
-static inline int insert_test()
+#define ST_SUM "Weekly Meeting"
+#define ST_DESC "Review : Project status"
+#define ST_LOC "Meeting Room #1"
+#define ST_TZ "Asia/Seoul"
+#define ST_CTG "Business"
+#define ST_ATT1_NAME "David Lee"
+#define ST_ATT1_EMAIL "davidlee@gmail.com"
+#define ST_ATT2_NAME "Brian Kim"
+#define ST_ATT2_EMAIL "briankim@yahoo.com"
+
+static inline int insert()
{
+ TEST_FN_START;
+
int ret;
+
cal_struct *event = NULL;
cal_value *attendee1 = NULL, *attendee2 = NULL;
- cal_value *alarm_info1 = NULL, *alarm_info2 = NULL;
-
GList *attendee_list=NULL;
- GList *alarm_list = NULL;
time_t cur_time = time(NULL)+240;
event = calendar_svc_struct_new(CAL_STRUCT_SCHEDULE);
- calendar_svc_struct_set_str(event, CAL_VALUE_TXT_SUMMARY, "weekly meeting");
- calendar_svc_struct_set_str(event, CAL_VALUE_TXT_DESCRIPTION, "review : project status");
- calendar_svc_struct_set_str(event, CAL_VALUE_TXT_LOCATION, "meeting room #1");
- //calendar_svc_struct_set_int(event, CAL_VALUE_INT_SCH_CATEGORY, CAL_SCH_NONE);
- calendar_svc_struct_set_int(event, CAL_VALUE_INT_REPEAT_TERM,1);
- calendar_svc_struct_set_int(event, CAL_VALUE_INT_REPEAT_INTERVAL,3);
- calendar_svc_struct_set_time(event, CAL_VALUE_GMT_START_DATE_TIME,CAL_TZ_FLAG_GMT,cur_time);
- calendar_svc_struct_set_time(event, CAL_VALUE_GMT_END_DATE_TIME,CAL_TZ_FLAG_GMT,cur_time+(60*60));
- calendar_svc_struct_set_time(event, CAL_VALUE_GMT_REPEAT_END_DATE,CAL_TZ_FLAG_GMT,cur_time+(60*60*24*7));
-
- //location
- calendar_svc_struct_set_str(event,CAL_VALUE_TXT_LOCATION,"location field");
- calendar_svc_struct_set_str(event,CAL_VALUE_TXT_LOCATION_SUMMARY,"location field");
- calendar_svc_struct_set_str(event,CAL_VALUE_TXT_TZ_NAME,"Asia/Seoul");
- calendar_svc_struct_set_double(event,CAL_VALUE_DBL_LATITUDE,0.1);
- calendar_svc_struct_set_double(event,CAL_VALUE_DBL_LONGITUDE,0.2);
+ calendar_svc_struct_set_str(event, CAL_VALUE_TXT_SUMMARY, ST_SUM);
+ calendar_svc_struct_set_str(event, CAL_VALUE_TXT_DESCRIPTION, ST_DESC);
+ calendar_svc_struct_set_str(event, CAL_VALUE_TXT_LOCATION, ST_LOC);
+ calendar_svc_struct_set_int(event, CAL_VALUE_INT_REPEAT_TERM, 1);
+ calendar_svc_struct_set_int(event, CAL_VALUE_INT_REPEAT_INTERVAL, 3);
+ calendar_svc_struct_set_int(event, CAL_VALUE_INT_REPEAT_UNTIL_TYPE, CALS_REPEAT_UNTIL_TYPE_DATETIME);
+
+ calendar_svc_struct_set_time(event, CAL_VALUE_GMT_START_DATE_TIME, CAL_TZ_FLAG_GMT, cur_time);
+ calendar_svc_struct_set_time(event, CAL_VALUE_GMT_END_DATE_TIME, CAL_TZ_FLAG_GMT, cur_time+(60*60));
+ calendar_svc_struct_set_time(event, CAL_VALUE_GMT_REPEAT_END_DATE, CAL_TZ_FLAG_GMT, cur_time+(60*60*24*7));
+ calendar_svc_struct_set_str(event,CAL_VALUE_TXT_CATEGORIES, ST_CTG);
+ calendar_svc_struct_set_str(event,CAL_VALUE_TXT_TZ_NAME, ST_TZ);
+ calendar_svc_struct_set_double(event,CAL_VALUE_DBL_LATITUDE, 0.1);
+ calendar_svc_struct_set_double(event,CAL_VALUE_DBL_LONGITUDE, 0.2);
calendar_svc_struct_set_int(event, CAL_VALUE_INT_SYNC_STATUS,1);
attendee1 = calendar_svc_value_new(CAL_VALUE_LST_ATTENDEE_LIST);
if(attendee1) {
- calendar_svc_value_set_str(attendee1, CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME, "heungjae jeong");
- calendar_svc_value_set_str(attendee1, CAL_VALUE_TXT_ATTENDEE_DETAIL_EMAIL, "id@domain.com");
+ calendar_svc_value_set_str(attendee1, CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME, ST_ATT1_NAME);
+ calendar_svc_value_set_str(attendee1, CAL_VALUE_TXT_ATTENDEE_DETAIL_EMAIL, ST_ATT1_EMAIL);
calendar_svc_value_set_int(attendee1, CAL_VALUE_INT_ATTENDEE_DETAIL_STATUS, 1);
calendar_svc_value_set_int(attendee1, CAL_VALUE_INT_ATTENDEE_DETAIL_CT_INDEX, 1);
attendee_list = g_list_append(attendee_list, attendee1);
attendee2 = calendar_svc_value_new(CAL_VALUE_LST_ATTENDEE_LIST);
if(attendee2) {
- calendar_svc_value_set_str(attendee2, CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME, "boncheol gu");
- calendar_svc_value_set_str(attendee2, CAL_VALUE_TXT_ATTENDEE_DETAIL_EMAIL, "id@domain.com");
+ calendar_svc_value_set_str(attendee2, CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME, ST_ATT2_NAME);
+ calendar_svc_value_set_str(attendee2, CAL_VALUE_TXT_ATTENDEE_DETAIL_EMAIL, ST_ATT2_EMAIL);
calendar_svc_value_set_int(attendee2, CAL_VALUE_INT_ATTENDEE_DETAIL_STATUS, 0);
calendar_svc_value_set_int(attendee2, CAL_VALUE_INT_ATTENDEE_DETAIL_CT_INDEX, 2);
attendee_list = g_list_append(attendee_list, attendee2);
ret = calendar_svc_struct_store_list(event, CAL_VALUE_LST_ATTENDEE_LIST, attendee_list);
-
- alarm_info1 = calendar_svc_value_new(CAL_VALUE_LST_ALARM);
- if(alarm_info1) {
- calendar_svc_value_set_int(alarm_info1, CAL_VALUE_INT_ALARMS_TICK, 1);
- calendar_svc_value_set_int(alarm_info1, CAL_VALUE_INT_ALARMS_TICK_UNIT,CAL_SCH_TIME_UNIT_MIN);
- alarm_list = g_list_append(alarm_list, alarm_info1);
- }
-
- alarm_info2 = calendar_svc_value_new(CAL_VALUE_LST_ALARM);
- if(alarm_info2) {
- calendar_svc_value_set_int(alarm_info2, CAL_VALUE_INT_ALARMS_TICK, 2);
- calendar_svc_value_set_int(alarm_info2, CAL_VALUE_INT_ALARMS_TICK_UNIT, CAL_SCH_TIME_UNIT_MIN);
- }
- alarm_list = g_list_append(alarm_list, alarm_info2);
-
- ret = calendar_svc_struct_store_list(event, CAL_VALUE_LST_ALARM, alarm_list);
-
ret = calendar_svc_insert(event);
calendar_svc_struct_free(&event);
- if (ret < CAL_SUCCESS) {
- ERR("calendar_svc_insert() Failed(%d)", ret);
- return -1;
- } else {
- DBG("calendar_svc_insert() return %d", ret);
- return ret;
- }
+ return ret;
}
-static inline void get_event(int index)
+static inline void get(int index)
{
+ TEST_FN_START;
+
cal_struct *event = NULL;
int ct_value = 0;
int repeat_term = 0;
int interval = 0;
+ int until_type = -1;
time_t r_end_date_time = 0;
GList *attendee_list=NULL;
time_t cur_time = time(NULL)+240;
calendar_svc_get(CAL_STRUCT_SCHEDULE, index, NULL, &event);
repeat_term = calendar_svc_struct_get_int(event, CAL_VALUE_INT_REPEAT_TERM);
interval = calendar_svc_struct_get_int(event, CAL_VALUE_INT_REPEAT_INTERVAL);
+ until_type = calendar_svc_struct_get_int(event, CAL_VALUE_INT_REPEAT_UNTIL_TYPE);
r_end_date_time = calendar_svc_struct_get_time(event, CAL_VALUE_GMT_REPEAT_END_DATE,CAL_TZ_FLAG_LOCAL);
- //location
char *location = calendar_svc_struct_get_str(event,CAL_VALUE_TXT_LOCATION);
- char *location_summary = calendar_svc_struct_get_str(event,CAL_VALUE_TXT_LOCATION_SUMMARY);
- double latitude = calendar_svc_struct_get_double(event,CAL_VALUE_DBL_LATITUDE);
- double longitude = calendar_svc_struct_get_double(event,CAL_VALUE_DBL_LONGITUDE);
- int sync_status = calendar_svc_struct_get_int(event, CAL_VALUE_INT_SYNC_STATUS);
+ char *categories = calendar_svc_struct_get_str(event,CAL_VALUE_TXT_CATEGORIES);
char *tz_name = calendar_svc_struct_get_str(event,CAL_VALUE_TXT_TZ_NAME);
- DBG("tz_name:Asia/Seoul = %s",tz_name);
- DBG("location: %s,%s,%s, %lf, %lf, %d",location,location_summary,tz_name,latitude,longitude,sync_status);
- DBG("curtime:%ld, event repeat_term(%d,%d,%ld)",cur_time,repeat_term,interval,r_end_date_time);
+ DBG("%s = %s", ST_TZ, tz_name);
+ DBG("%s = %s", ST_LOC, location);
+ DBG("%s = %s", ST_CTG, categories);
attendee_list = NULL;
calendar_svc_struct_get_list(event,CAL_VALUE_LST_ATTENDEE_LIST,&attendee_list);
calendar_svc_struct_free(&event);
}
-int main(int argc, char **argv)
+int search()
+{
+ TEST_FN_START;
+ int ret;
+ cal_struct *cs;
+ cal_iter *it;
+ char *summary;
+ char *location;
+ char *desc;
+ int id;
+
+ calendar_svc_connect();
+ int search_field;
+
+ search_field = CALS_SEARCH_FIELD_NONE;
+ search_field |= CALS_SEARCH_FIELD_SUMMARY;
+ search_field |= CALS_SEARCH_FIELD_DESCRIPTION;
+ search_field |= CALS_SEARCH_FIELD_LOCATION;
+ search_field |= CALS_SEARCH_FIELD_ATTENDEE;
+
+ ret = calendar_svc_event_search(search_field, "Brian", &it);
+ if (ret < 0) {
+ ERR("calendar_svc_event_search failed(%d)", ret);
+ return ret;
+ }
+
+ while (calendar_svc_iter_next(it) == CAL_SUCCESS) {
+ cs = NULL;
+ ret = calendar_svc_iter_get_info(it, &cs);
+ if (ret < 0) {
+ ERR("calendar_svc_iter_get_info failed (%d)\n", ret);
+ return ret;
+ }
+
+ id = calendar_svc_struct_get_int(cs, CAL_VALUE_INT_INDEX);
+ summary = calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_SUMMARY);
+ desc = calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_DESCRIPTION);
+ location = calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_LOCATION);
+ DBG("\t%s = %s", ST_SUM, summary);
+ DBG("\t%s = %s", ST_DESC, desc);
+ DBG("\t%s = %s", ST_LOC, location);
+ calendar_svc_struct_free(&cs);
+ }
+
+ calendar_svc_iter_remove(&it);
+
+ calendar_svc_close();
+
+ return 0;
+}
+
+int smartsearch()
{
+ TEST_FN_START;
int ret;
+ cal_struct *cs;
+ cal_iter *it;
+ char *summary;
+ char *location;
+ char *desc;
+ int id;
+
+ calendar_svc_connect();
+
+ ret = calendar_svc_smartsearch_excl("weekly", -1, 10, &it);
+ if (ret < 0) {
+ ERR("calendar_svc_event_search failed(%d)", ret);
+ return ret;
+ }
+
+ while (calendar_svc_iter_next(it) == CAL_SUCCESS) {
+ cs = NULL;
+ ret = calendar_svc_iter_get_info(it, &cs);
+ if (ret < 0) {
+ ERR("calendar_svc_iter_get_info failed (%d)\n", ret);
+ return ret;
+ }
+
+ id = calendar_svc_struct_get_int(cs, CAL_VALUE_INT_INDEX);
+ summary = calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_SUMMARY);
+ desc = calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_DESCRIPTION);
+ location = calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_LOCATION);
+ DBG("ID = %d", id);
+ DBG("\t%s = %s", ST_SUM, summary);
+ DBG("\t%s = %s", ST_DESC, desc);
+ DBG("\t%s = %s", ST_LOC, location);
+ calendar_svc_struct_free(&cs);
+ }
+
+ calendar_svc_iter_remove(&it);
+
+ calendar_svc_close();
+
+ return 0;
+}
+
+
+int main(int argc, char **argv)
+{
+ int id;
calendar_svc_connect();
- ret = insert_test();
- if (0 < ret)
- get_event(ret);
+ id = insert();
+ if (id) {
+ get(id);
+ }
+ search();
+ smartsearch();
calendar_svc_close();
--- /dev/null
+#include <unistd.h>
+#include <string.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <glib.h>
+#define _GNU_SOURCE
+#include <time.h>
+
+#include <calendar-svc-provider.h>
+
+#define ICALENAR_BUFFER_MAX 1024*1024
+
+static const char* calendar_svc_get_stream_from_ics(const char *path)
+{
+ FILE *file;
+ int buf_size, len;
+ char *stream;
+ char buf[1024];
+
+ file = fopen(path, "r");
+
+ 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 {
+ free(stream);
+ fclose(file);
+ printf("out of memory\n");
+ return NULL;
+ }
+ len += snprintf(stream + len, strlen(buf) +1, "%s", buf);
+ }
+ }
+ fclose(file);
+ return stream;
+}
+
+
+
+int main(int argc, char **argv)
+{
+fprintf(stdout, "%s\n", __func__);
+ const char *stream;
+ GList *list_sch = NULL, *l;
+ int i = 0;
+
+ if (argc < 2) return -1;
+
+ fprintf(stdout, "file path:%s\n", argv[1]);
+ if (access(argv[1], F_OK) != 0) {
+ fprintf(stdout, "Failed to access (%s)\n", argv[1]);
+ return -1;
+ }
+
+ stream = calendar_svc_get_stream_from_ics(argv[1]);
+ calendar_svc_ics_to_sch(stream, &list_sch);
+
+ if (list_sch == NULL) {
+ fprintf(stdout, "No list\n");
+ return 0;
+ }
+
+
+ l = list_sch;
+ while (l) {
+ cal_struct *event;
+ char *str;
+ printf("%d\n", i++);
+/*
+ calendar_svc_get(CAL_STRUCT_SCHDULE, 1, NULL, &event);
+ str = calendar_svc_struct_get_str(l->data, CAL_VALUE_TXT_SUMMARY);
+ if (str) {
+ printf("summary(%s)\n", str);
+ }
+*/
+ l = g_list_next(l);
+ }
+
+// calendar_svc_struct_free(&event);
+
+ l = list_sch;
+ while (l = g_list_next(l)) {
+ if (l) {
+ fprintf(stdout, "exist\n");
+ }
+ }
+
+
+ if (stream) {
+ free(stream);
+ }
+ return 0;
+}
#define PRT(prio, fmt, arg...) \
do { fprintf((prio?stderr:stdout),fmt"\n", ##arg); } while (0)
#define INFO(fmt, arg...) PRT(0, fmt, ##arg)
-#define ERR(fmt, arg...) PRT(1,"\x1b[101;38m[ERROR]\x1b[0m%s :" fmt, __FUNCTION__, ##arg)
+#define ERR(fmt, arg...) PRT(1,"\x1b[101;38m[ERROR]\x1b[0m%s:%d" fmt, __FUNCTION__, __LINE__, ##arg)
#define DBG(fmt, arg...) \
do { \
- printf("\x1b[105;37m[%s]\x1b[0m" fmt"\n", __FUNCTION__, ##arg); \
+ printf(fmt"\n", ##arg); \
} while (0)
-#define TEST_FN_START DBG("[FUNC_START]")
+#define TEST_FN_START DBG("[START] \x1b[105;37m[%s]\x1b[0m", __FUNCTION__)
#endif /* __TEST_LOG_H__ */
--- /dev/null
+
+#include <stdio.h>
+#include <time.h>
+#include <calendar-svc-provider.h>
+#include "utime.h"
+
+int main(int argc, char **argv)
+{
+ int i;
+ int ret;
+ char buf[32] = {0};
+ cal_struct *cs = NULL;
+
+ calendar_svc_connect();
+
+ for (i = 0; i < 10; i++) {
+ printf("start insert priority:%d\n", i);
+ cs = calendar_svc_struct_new(CAL_STRUCT_TODO);
+ if (cs == NULL) {
+ printf("Failed to new calendar\n");
+ return -1;
+ }
+
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_ACCOUNT_ID, 1);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_TASK_STATUS, 1);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_CALENDAR_TYPE, 2);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_CALENDAR_ID, 1);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_PRIORITY, i);
+ snprintf(buf, sizeof(buf), "status:1 /priority:%d", i);
+ calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_SUMMARY, buf);
+
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTSTART_TYPE, CALS_TIME_UTIME);
+ calendar_svc_struct_set_lli(cs, CALS_VALUE_LLI_DTSTART_UTIME, D20120701T000000);
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_DTSTART_TZID, "Europe/London");
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTEND_TYPE, CALS_TIME_UTIME);
+ calendar_svc_struct_set_lli(cs, CALS_VALUE_LLI_DTEND_UTIME, D20120901T000000);
+ calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_DTEND_TZID, "Europe/London");
+
+ ret = calendar_svc_insert(cs);
+ calendar_svc_struct_free(&cs);
+ }
+ calendar_svc_close();
+
+ return 0;
+}
+
+
+
--- /dev/null
+
+#include <stdio.h>
+#include <time.h>
+#include <calendar-svc-provider.h>
+#include "utime.h"
+
+struct _pair {
+ int i;
+ char *s;
+};
+
+struct _pair is[8] = {
+ {CALS_TODO_PRIORITY_NONE, "CALS_TODO_PRIORITY_NONE"},
+ {CALS_TODO_PRIORITY_HIGH, "CALS_TODO_PRIORITY_HIGH"},
+ {CALS_TODO_PRIORITY_MID,"CALS_TODO_PRIORITY_MID"},
+ {CALS_TODO_PRIORITY_LOW,"CALS_TODO_PRIORITY_LOW"},
+ {CALS_TODO_PRIORITY_HIGH | CALS_TODO_PRIORITY_MID | CALS_TODO_PRIORITY_LOW, "CALS_TODO_PRIORITY_HIGH |MID | LOW"},
+ {CALS_TODO_PRIORITY_HIGH | CALS_TODO_PRIORITY_MID, "CALS_TODO_PRIORITY_HIGH | MID"},
+ {CALS_TODO_PRIORITY_HIGH | CALS_TODO_PRIORITY_LOW, "CALS_TODO_PRIORITY_HIGH | LOW"},
+ {CALS_TODO_PRIORITY_MID | CALS_TODO_PRIORITY_LOW, "CALS_TODO_PRIORITY_MID | LOW"}
+};
+
+
+int main(int argc, char **argv)
+{
+ int i, count;
+ int ret, is_exist;;
+ char *sum;
+ cal_iter *iter;
+ cal_struct *cs;
+
+ calendar_svc_connect();
+printf("%d\n", CALS_TODO_STATUS_NEEDS_ACTION | CALS_TODO_STATUS_COMPLETED | CALS_TODO_STATUS_IN_PROCESS | CALS_TODO_STATUS_CANCELLED);
+
+ for (i = 0; i < 8; i++) {
+ printf("start (priority:%d)%s\n", is[i].i, is[i].s);
+
+ calendar_svc_todo_get_count_by_period(1,
+// D20120601T000000, D20120931T100000, is[i].i, -1, &count);
+ 200, 400, is[i].i,
+ CALS_TODO_STATUS_NEEDS_ACTION | CALS_TODO_STATUS_COMPLETED |
+ CALS_TODO_STATUS_IN_PROCESS | CALS_TODO_STATUS_CANCELLED,
+ &count);
+ if (ret != CAL_SUCCESS) {
+ printf("Failed to get count\n");
+ return -1;
+ }
+ printf("count(%d)\n", count);
+
+
+
+ ret = calendar_svc_todo_get_list_by_period(1,
+// D20120601T000000, D20120931T100000, is[i].i, 0, &iter);
+ 200, 400, is[i].i,
+ CALS_TODO_STATUS_NEEDS_ACTION | CALS_TODO_STATUS_COMPLETED |
+ CALS_TODO_STATUS_IN_PROCESS | CALS_TODO_STATUS_CANCELLED,
+ &iter);
+ if (ret != CAL_SUCCESS) {
+ printf("Failed to get list\n");
+ break;
+ }
+ is_exist = 0;
+ while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
+ is_exist = 1;
+ cs = NULL;
+ calendar_svc_iter_get_info(iter, &cs);
+ sum = calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_SUMMARY);
+ printf("sum(%s)\n", sum);
+ }
+ if (is_exist == 0) {
+ printf("No date\n");
+ }
+ }
+ calendar_svc_close();
+ return 0;
+}
+
+
+
+
+
--- /dev/null
+
+#define D20120601T000000 1338508800
+#define D20120701T000000 1341100800
+#define D20120701T060000 1341122400
+#define D20120801T000000 1343779200
+#define D20120901T000000 1346457600
+#define D20120931T100000 1349085600
+#define D20150701T000000 1435708800
--- /dev/null
+#include <calendar-svc-provider.h>
+#include <stdio.h>
+
+int main(void)
+{
+ int ret;
+ cal_struct *cs;
+ cal_iter *it;
+ int id;
+ int type;
+ int ver;
+
+ calendar_svc_connect();
+
+ ret = calendar_svc_event_get_changes(1, 0, &it);
+ if (ret < 0)
+ return -1;
+
+ while (calendar_svc_iter_next(it) == CAL_SUCCESS) {
+ cs = NULL;
+ ret = calendar_svc_iter_get_info(it, &cs);
+ if (ret != CAL_SUCCESS) {
+ printf("calendar_svc_iter_get_info failed (%d)\n", ret);
+ return -1;
+ }
+
+ type = calendar_svc_struct_get_int(cs, CALS_STRUCT_UPDATED_INT_TYPE);
+ id = calendar_svc_struct_get_int(cs, CALS_STRUCT_UPDATED_INT_ID);
+ ver = calendar_svc_struct_get_int(cs, CALS_STRUCT_UPDATED_INT_VERSION);
+ printf("type = %d id = %d ver = %d\n", type, id, ver);
+ calendar_svc_struct_free(&cs);
+ }
+
+ calendar_svc_iter_remove(&it);
+
+ calendar_svc_close();
+
+ return 0;
+}
+
+