* Git: pkgs/l/libslp-calendar
* Tag: libslp-calendar_0.1.12-16
- -- Taeho Kang <taeho84.kang@samsung.com> Tue, 28 Feb 2012 00:16:13 +0900
-
-libslp-calendar (0.1.12-15) unstable; urgency=low
-
- * release
- * Git: pkgs/l/libslp-calendar
- * Tag: libslp-calendar_0.1.12-15
-
- -- Youngjae Shin <yj99.shin@samsung.com> Wed, 01 Feb 2012 10:16:13 +0900
+ -- Jeesun Kim <iamjs.kim@samsung.com> Tue, 21 Feb 2012 10:00:00 +0900
\ No newline at end of file
CAL_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_repeat_term_t;
+/**
+ * This enumeration defines Repeat term.
+ */
+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 */
+} cal_repeat_until_type_t;
+
/**
* This enumeration defines sync status.
*/
CALS_CALENDAR_TYPE_TODO = 1<<1,
} cals_calendar_store_type;
+/**
+ * This enumeration defines calendar sensitivity.
+ * (related with CAL_VALUE_INT_SENSITIVITY)
+ */
+typedef enum
+{
+ CALS_SENSITIVITY_PUBLIC = 0x0,
+ CALS_SENSITIVITY_PRIVATE,
+ CALS_SENSITIVITY_CONFIDENTIAL,
+} cals_sensitivity_t;
+
+
/**
* @}
*/
* brief
* calendar_svc_value_xxx()'s argument
*/
-#define CAL_VALUE_INT_INDEX "id" /**< Record index */
+#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_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_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_TIMEZONE "timezone" /**< deprecated - timezone of task */
-#define CAL_VALUE_INT_FILE_ID "file_id" /**< file id for attach or alarm tone*/
-#define CAL_VALUE_INT_CONTACT_ID "contact_id" /**< contact id for birthday in contact list */
-#define CAL_VALUE_INT_BUSY_STATUS "busy_status" /**< ACS, G : Flag of busy or not */
-#define CAL_VALUE_INT_SENSITIVITY "sensitivity" /**< ACS, G : The sensitivity of the task item (normal, presonal, private, confidential). */
-#define CAL_VALUE_TXT_UID "uid" /**< ACS, G : Unique ID of the meeting item */
-#define CAL_VALUE_INT_CALENDAR_TYPE "calendar_type" /**< ACS, G : Type(all,phone,google) of calendar */
-#define CAL_VALUE_TXT_ORGANIZER_NAME "organizer_name" /**< ACS, G : Name of organizer(author) */
-#define CAL_VALUE_TXT_ORGANIZER_EMAIL "organizer_email" /**< ACS, G : Email of organizer */
-#define CAL_VALUE_INT_MEETING_STATUS "meeting_status" /**< ACS, G : The status of the meeting. */
-#define CAL_VALUE_TXT_GCAL_ID "gcal_id" /**< G : Server id of calendar */
-#define CAL_VALUE_INT_DELETED "deleted" /**< G : Flag for deleted */
-#define CAL_VALUE_TXT_UPDATED "updated" /**< G : Updated time stamp */
-#define CAL_VALUE_INT_LOCATION_TYPE "location_type" /**< G : Location type */
-#define CAL_VALUE_TXT_LOCATION_SUMMARY "location_summary" /**< G : A simple string value that can be used as a representation of this location */
-#define CAL_VALUE_TXT_ETAG "etag" /**< G : ETAG of this event */
-#define CAL_VALUE_INT_CALENDAR_ID "calendar_id" /**< G : id to map from calendar table */
-#define CAL_VALUE_INT_SYNC_STATUS "sync_status" /**< G : Indication for event entry whether added/ modified/ deleted */
-#define CAL_VALUE_TXT_EDIT_URL "edit_uri" /**< G : EditUri for google calendar */
-#define CAL_VALUE_TXT_GEDERID "gevent_id" /**< G : Server id of an event */
-#define CAL_VALUE_INT_DST "dst" /**< dst of event */
-#define CAL_VALUE_INT_ORIGINAL_EVENT_ID "original_event_id" /**< original event id for recurrency exception */
+#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_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_TIMEZONE "timezone" /**< deprecated - timezone of task */
+#define CAL_VALUE_INT_FILE_ID "file_id" /**< file id for attach or alarm tone*/
+#define CAL_VALUE_INT_CONTACT_ID "contact_id" /**< contact id for birthday in contact list */
+#define CAL_VALUE_INT_BUSY_STATUS "busy_status" /**< ACS, G : Flag of busy or not */
+#define CAL_VALUE_INT_SENSITIVITY "sensitivity" /**< iCal:CLASS #cals_sensitivity_t */
+#define CAL_VALUE_TXT_UID "uid" /**< ACS, G : Unique ID of the meeting item */
+#define CAL_VALUE_INT_CALENDAR_TYPE "calendar_type" /**< ACS, G : Type(all,phone,google) of calendar */
+#define CAL_VALUE_TXT_ORGANIZER_NAME "organizer_name" /**< ACS, G : Name of organizer(author) */
+#define CAL_VALUE_TXT_ORGANIZER_EMAIL "organizer_email" /**< ACS, G : Email of organizer */
+#define CAL_VALUE_INT_MEETING_STATUS "meeting_status" /**< ACS, G : The status of the meeting. */
+#define CAL_VALUE_TXT_GCAL_ID "gcal_id" /**< G : Server id of calendar */
+#define CAL_VALUE_INT_DELETED "deleted" /**< G : Flag for deleted */
+#define CAL_VALUE_TXT_UPDATED "updated" /**< G : Updated time stamp */
+#define CAL_VALUE_INT_LOCATION_TYPE "location_type" /**< G : Location type */
+#define CAL_VALUE_TXT_LOCATION_SUMMARY "location_summary" /**< G : A simple string value that can be used as a representation of this location */
+#define CAL_VALUE_TXT_ETAG "etag" /**< G : ETAG of this event */
+#define CAL_VALUE_INT_CALENDAR_ID "calendar_id" /**< G : id to map from calendar table */
+#define CAL_VALUE_INT_SYNC_STATUS "sync_status" /**< G : Indication for event entry whether added/ modified/ deleted */
+#define CAL_VALUE_TXT_EDIT_URL "edit_uri" /**< G : EditUri for google calendar */
+#define CAL_VALUE_TXT_GEDERID "gevent_id" /**< G : Server id of an event */
+#define CAL_VALUE_INT_DST "dst" /**< dst of event */
+#define CAL_VALUE_INT_ORIGINAL_EVENT_ID "original_event_id" /**< original event id for recurrency exception */
#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 */
*/
time_t calendar_svc_struct_get_time(cal_struct* record, const char *field, int timezone_flag);
-/**
- * @fn void calendar_svc_util_get_local_tz_info(char **lock_city_name,char **lock_tz_path,char** lock_tz_offset,char **local_city_name,char **local_tz_path,char **local_tz_offset);
- get timezone information by setting value
- * @deprecated it will be deprecated.
- */
-void calendar_svc_util_get_local_tz_info(char **lock_city_name,char **lock_tz_path,char** lock_tz_offset,
- char **local_city_name,char **local_tz_path,char **local_tz_offset);
-
/**
* @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.
}
#endif
+/**
+ * deprecated
+ */
typedef enum
{
- CAL_STATUS_FREE = 0, /**< deprecated */
- CAL_STATUS_TENTATIVE, /**< deprecated */
- CAL_STATUS_BUSY, /**< deprecated */
- CAL_STATUS_OUROFOFFICE, /**< deprecated */
- CAL_STATUS_CONFIRM, /**< deprecated */
- CAL_STATUS_DENIED, /**< deprecated */
+ CAL_STATUS_FREE = 0, /**< deprecated */
+ CAL_STATUS_TENTATIVE, /**< deprecated */
+ CAL_STATUS_BUSY, /**< deprecated */
+ CAL_STATUS_OUROFOFFICE, /**< deprecated */
+ CAL_STATUS_CONFIRM, /**< deprecated */
+ CAL_STATUS_DENIED, /**< deprecated */
} cal_status_type_t;
#endif /* __CALENDAR_SVC_H__ */
-Name: libslp-calendar
+Name: libslp-calendar
Summary: DB library for calendar
Version: 0.1.12
-Release: 1
+Release: 29
Group: System/Libraries
-License: Apache-2.0
+License: Apache 2.0
Source0: %{name}-%{version}.tar.gz
Requires(post): /sbin/ldconfig
+Requires(post): /usr/bin/sqlite3
Requires(postun): /sbin/ldconfig
BuildRequires: cmake
BuildRequires: pkgconfig(db-util)
-BuildRequires: pkgconfig(dbus-glib-1)
-BuildRequires: pkgconfig(gconf-2.0)
-BuildRequires: pkgconfig(gmodule-2.0)
-BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(sqlite3)
+BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(heynoti)
+BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(alarm-service)
-BuildRequires: pkgconfig(aul)
-Requires(post): /usr/bin/sqlite3
%description
DB library for calendar
Summary: DB library for calendar
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
+Requires: pkgconfig(alarm-service)
%description devel
DB library for calendar (developement files)
%post
/sbin/ldconfig
+mkdir -p /opt/dbspace
+if [ -f /opt/dbspace/.calendar-svc.db ]
+then
+ echo "calendar-svc.db exist"
+else
+ calendar-svc-initdb
+fi
-/usr/bin/calendar-svc-initdb
-
-chown root:root /usr/lib/libcalendar-service.so.*
-chown :6003 /opt/data/calendar-svc/.CALENDAR_SVC_*
chown :6003 /opt/dbspace/.calendar-svc.db
chown :6003 /opt/dbspace/.calendar-svc.db-journal
+chown :6003 /opt/data/calendar-svc/.CALENDAR_SVC_*
chmod 660 /opt/dbspace/.calendar-svc.db
chmod 660 /opt/dbspace/.calendar-svc.db-journal
chmod 660 /opt/data/calendar-svc/.CALENDAR_SVC_*
-
%postun -p /sbin/ldconfig
%files
-/usr/lib/lib*.so.*
-/usr/bin/calendar-svc-initdb
-/opt/data/calendar-svc/.*
+%defattr(-,root,root,-)
+%{_bindir}/calendar-svc-initdb
+%{_libdir}/libcalendar-service.so.*
+/opt/data/calendar-svc/.CALENDAR_SVC_CALENDAR_CHANGED
+/opt/data/calendar-svc/.CALENDAR_SVC_EVENT_CHANGED
+/opt/data/calendar-svc/.CALENDAR_SVC_TODO_CHANGED
%files devel
-/usr/lib/pkgconfig/*.pc
-/usr/include/calendar/*.h
-/usr/include/calendar-svc/*.h
-/usr/lib/lib*.so
+%defattr(-,root,root,-)
+%{_includedir}/calendar-svc/*.h
+%{_includedir}/calendar/*.h
+%{_libdir}/*.so
+%{_libdir}/pkgconfig/calendar.pc
+%{_libdir}/pkgconfig/calendar-service.pc
end_date_time INTEGER,
repeat_item INTEGER,
repeat_interval INTEGER,
+repeat_until_type INTEGER,
repeat_occurrences INTEGER,
repeat_end_date INTEGER,
sun_moon INTEGER,
#include "cals-utils.h"
#include "cals-alarm.h"
-#define PKG_CALENDAR_APP "org.tizen.calendar"
+#define PKG_CALENDAR_APP "org.tizen.efl-calendar"
int cals_alarm_remove(int type, int related_id)
{
retvm_if(NULL == stmt, CAL_ERR_DB_FAILED, "cals_query_prepare() Failed");
if (alarm_info->alarm_tone)
- cals_stmt_bind_text(stmt, 0, alarm_info->alarm_tone);
+ cals_stmt_bind_text(stmt, 1, alarm_info->alarm_tone);
if (alarm_info->alarm_description)
- cals_stmt_bind_text(stmt, 1, alarm_info->alarm_description);
+ cals_stmt_bind_text(stmt, 2, alarm_info->alarm_description);
rc = cals_stmt_step(stmt);
if (CAL_SUCCESS != rc) {
"st.end_date_time, "\
"st.repeat_item, "\
"st.repeat_interval, "\
+ "st.repeat_until_type, "\
"st.repeat_occurrences, "\
"st.repeat_end_date, "\
"st.week_start, "\
{
CALS_FN_CALL;
sqlite3_stmt *stmt = NULL;
- char sql_value[CALS_SQL_MIN_LEN] = {0};
+ char sql_value[CALS_SQL_MAX_LEN] = {0};
int rc = 0;
- char condition_value[1024] = {0};
+ char condition_value[CALS_SQL_MAX_LEN] = {0};
+ char search_str[CALS_SQL_MAX_LEN] = {0};
cal_value_type_t value_type = 0;
- retex_if(NULL == data_type,,"Invalid parameter.\n");
- retex_if(NULL == iter,,"Invalid parameter.\n");
- retex_if(0 > calendar_id,,"Invalid parameter.\n");
+
+ 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);
+ 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%%')",CAL_EVENT_SCHEDULE_TYPE, search_type, (char*)search_value);
+ 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%%') and account_id = %d",CAL_EVENT_SCHEDULE_TYPE, search_type, (char*)search_value, 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%%') ",CAL_EVENT_SCHEDULE_TYPE, search_type, (char*)search_value);
+ 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:
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);
+ "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);
+ "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;
if(ALL_VISIBILITY_ACCOUNT == account_id)
{
- sprintf(sql_value,"SELECT * FROM %s WHERE %s like upper('%%%s%%') AND is_deleted = 0;",
- CALS_TABLE_SCHEDULE, search_type, (char*)search_value);
+ sprintf(sql_value,
+ "SELECT * FROM %s WHERE %s like upper('%%%s%%') AND is_deleted = 0 ORDER BY start_date_time;",
+ 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;",
- CALS_TABLE_SCHEDULE, search_type, (char*)search_value, 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;",
+ 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;",
- CALS_TABLE_SCHEDULE, search_type, (char*)search_value);
+ sprintf(sql_value,
+ "SELECT * FROM %s WHERE %s like upper('%%%s%%') AND is_deleted = 0 ORDER BY start_date_time;",
+ 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;",
- CALS_TABLE_SCHEDULE, search_type,(int)search_value);
+ sprintf(sql_value,
+ "SELECT * FROM %s WHERE %s = %d AND is_deleted = 0 ORDER BY start_date_time;",
+ 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;",
- CALS_TABLE_SCHEDULE, search_type, (int)search_value, account_id);
+ sprintf(sql_value,
+ "SELECT * FROM %s WHERE %s = %d AND is_deleted = 0 AND account_id = %d ORDER BY start_date_time;",
+ CALS_TABLE_SCHEDULE, search_type, (int)search_value, account_id);
}
else
{
- sprintf(sql_value,"SELECT * FROM %s WHERE %s = %d AND is_deleted = 0;",
- CALS_TABLE_SCHEDULE, search_type, (int)search_value);
+ sprintf(sql_value,
+ "SELECT * FROM %s WHERE %s = %d AND is_deleted = 0 ORDER BY start_date_time;",
+ 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",
- CALS_TABLE_SCHEDULE, ret);
+ sprintf(sql_value,
+ "SELECT * FROM %s WHERE id = %d AND is_deleted = 0 ORDER BY start_date_time",
+ CALS_TABLE_SCHEDULE, ret);
break;
}
case VALUE_TYPE_TIME:
{
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;", search_type, (char*)search_value, 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;", search_type, (char*)search_value);
+ 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;", search_type, (int)search_value, 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;", search_type, (int)search_value);
+ 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:
return CAL_SUCCESS;
}
-bool cal_svc_util_get_timezone_info(char *city,char **tz_path,char**offset)
-{
- 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);
- *offset = strdup(time_zone_array[index].gmt);
- //DBG("%s,%s,%s,%s",*tz_path,*offset,time_zone_array[index].tz_path,time_zone_array[index].gmt);
- break;
- }
- 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;
- *offset = NULL;
- return false;
-}
-
-
-bool cal_svc_util_get_timezone_info_by_tz_path(char *tz_path,char **city_name,char**offset)
-{
- int left = 0;
- int right = sizeof(tz_path_array)/sizeof(Time_Zone) -1;
- int index = 0;
- int result = 0;
- int max_count = right;
-
-
- while(true)
- {
- index = ( left + right ) / 2;
-
- result = strcmp(tz_path_array[index].tz_path, tz_path);
-
- if(result == 0)
- {
- *city_name = strdup(tz_path_array[index].city);
- *offset = strdup(tz_path_array[index].gmt);
- //DBG("%s,%s,%s,%s",*tz_path,*offset,time_zone_array[index].tz_path,time_zone_array[index].gmt);
- break;
- }
- 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(*city_name == NULL)
- return false;
- else
- return true;
-error:
- *city_name = NULL;
- *offset = NULL;
- return false;
-}
-
-void calendar_svc_util_get_city_info(char *tz_path, char**city_name, char**tz_offset)
-{
- bool r = false;
- if(tz_path == NULL || city_name==NULL || tz_offset == NULL)
- return;
-
- r = cal_svc_util_get_timezone_info_by_tz_path(tz_path,city_name,tz_offset);
- if(r){
- ERR("%s,%s,%s",tz_path,*city_name,*tz_offset);
- }
-}
-
-
-API void calendar_svc_util_get_local_tz_info(char **lock_city_name,char **lock_tz_path,char** lock_tz_offset,
- char **local_city_name,char **local_tz_path,char **local_tz_offset)
-{
- int lock_on = 0;
- bool r = false;
- clock_t start_time=0,end_time = 0;
- start_time = CAL_PROFILE_GET_TIME();
-
- vconf_get_int("db/calendar/timezone_on_off",&lock_on);
-
- if(lock_on)
- {
- *lock_city_name = vconf_get_str("db/calendar/timezone");
- r = cal_svc_util_get_timezone_info(*lock_city_name,lock_tz_path,lock_tz_offset);
-
- if(r){
- ERR("%s,%s,%s",*lock_city_name,*lock_tz_path,*lock_tz_offset);
- }
- }
- else
- {
- *lock_city_name = NULL;
- *lock_tz_path = NULL;
- *lock_tz_offset = NULL;
- }
-
- if(*local_tz_path)
- {
- r = cal_svc_util_get_timezone_info_by_tz_path(*local_tz_path,local_city_name,local_tz_offset);
- }
- else
- {
- *local_city_name = vconf_get_str(VCONFKEY_SETAPPL_CITYNAME_INDEX_INT);
- cal_svc_util_get_timezone_info(*local_city_name,local_tz_path,local_tz_offset);
- }
-
- if(r){
- ERR("%s,%s,%s",*local_city_name,*local_tz_path,*local_tz_offset);
- }
-
- end_time = CAL_PROFILE_GET_TIME();
- CAL_PROFILE_PRINT(start_time,end_time);
-
-}
-
/* 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)
for(i=start_day-1;i<end_day;i++)
{
day_flag[i]++;
- //DBG("day_flag[%d]=%d\n",i,day_flag[i]);
}
}
while (calendar_svc_iter_next(it) == CAL_SUCCESS) {
rc = calendar_svc_iter_get_month_info(it,true, &cs);
- if (rc != CAL_SUCCESS || cs == NULL)
+ if (rc != CAL_SUCCESS || cs == NULL) {
+ ERR("calendar_svc_iter_get_month_info return %d", rc);
break;
+ }
memset(&lstm,0x00,sizeof(struct tm));
memset(&letm,0x00,sizeof(struct tm));
while (calendar_svc_util_next_valid_event_tm(cs,
&stm, &etm, &lstm, &letm) == CAL_SUCCESS) {
__set_day_flag(&stm,&etm,&lstm,&letm,day_flag);
-
}
calendar_svc_struct_free(&cs);
}
tm->tm_wday = days%7;
}
-/*
-/// just refer
-void __cal_service_convert_datetime_to_tm(struct tm *date,struct tm *tm)
-{
-tm->tm_year = date->date.tm_year-BENCHMARK_YEAR;
-tm->tm_mon = date->date.month-1;
-tm->tm_mday = date->date.tm_mday;
-tm->tm_wday = date->date.wday;
-tm->tm_hour = date->time.hours;
-tm->tm_min = date->time.minutes;
-tm->tm_sec = date->time.seconds;
-}
-
-void __cal_service_convert_tm_to_datetime(struct tm *tm,struct tm *date)
-{
-date->date.tm_year =tm->tm_year+BENCHMARK_YEAR;
-date->date.month = tm->tm_mon+1;
-date->date.tm_mday = tm->tm_mday;
-date->date.wday =tm->tm_wday;
-date->time.hours = tm->tm_hour;
-date->time.minutes = tm->tm_min;
-date->time.seconds = tm->tm_sec;
-}
-
-
-bool
-cal_db_service_adjust_time(struct tm* pDateTime, long adjustment)
-{
-time_t base_time = cals_mktime(pDateTime);
-
-base_time = base_time+adjustment;
-memcpy(pDateTime,cals_tmtime(&base_time),sizeof(struct tm));
-
-return true;
-}
-*/
-
bool cal_is_used_dst_timezone(cal_sch_full_t *sch_record)
{
void cal_svc_set_tz_base_info(int year)
{
- char *tz_name = NULL;
- char * lock_city_name= NULL;
- char * lock_tz_path= NULL;
- char * lock_tz_offset= NULL;
- char * local_city_name= NULL;
- char * local_tz_path= NULL;
- char * local_tz_offset= NULL;
-
- //temp(test code)
- //local_tz_path=strdup("Asia/Seoul");
-
- calendar_svc_util_get_local_tz_info(&lock_city_name,&lock_tz_path,&lock_tz_offset,&local_city_name,&local_tz_path,&local_tz_offset);
-
-
- if(lock_tz_path)
- tz_name = lock_tz_path;
- else if(local_tz_path)
- tz_name = local_tz_path;
- else
- tz_name = "localtime";
+ 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)
{
strncpy(cal_svc_tm_value.local_tz_name,tz_name, sizeof(cal_svc_tm_value.local_tz_name));
}
+ free(tz_name);
- CAL_FREE(lock_city_name);
- CAL_FREE(lock_tz_path);
- CAL_FREE(lock_tz_offset);
- CAL_FREE(local_city_name);
- CAL_FREE(local_tz_path);
- CAL_FREE(local_tz_offset);
+ return;
}
bool cal_get_dst_info_time(cal_date_param_t *cal_date_param,const cal_sch_full_t *sch_record)
"account_id, type, category, "
"summary, description, location, all_day_event, "
"start_date_time, end_date_time, repeat_item, repeat_interval, "
- "repeat_occurrences, repeat_end_date, sun_moon, week_start, "
+ "repeat_until_type, repeat_occurrences, repeat_end_date, sun_moon, week_start, "
"week_flag, day_date, last_modified_time, missed, "
"task_status, priority, timezone, file_id, "
"contact_id, busy_status, sensitivity, uid, "
"%d, %d, %d, "
"?, ?, ?, %d, "
"%ld, %ld, %d, %d, "
- "%d, %ld, %d, %d, "
+ "%d, %d, %ld, %d, %d, "
"?, %d, %ld, %d, "
"%d, %d, %d, %d, "
"%d, %d, %d, ?, "
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_occurrences, conv_repeat_end_time, record->sun_moon, record->week_start,
+ 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->contact_id, record->busy_status, record->sensitivity,
if(sch_record->cal_type != CAL_EVENT_SCHEDULE_TYPE)
return CAL_SUCCESS;
- if((sch_record->repeat_term != CAL_REPEAT_NONE) &&
+ 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_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);
}
"end_date_time = %ld,"
"repeat_item = %d,"
"repeat_interval = %d,"
+ "repeat_until_type = %d,"
"repeat_occurrences = %d,"
"repeat_end_date = %ld,"
"sun_moon = %d,"
(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,
sch_record->missed = 0;
- if((sch_record->repeat_occurrences) != 0 && (sch_record->repeat_end_date.tm_year == BASE_TIME_YEAR))
- {
- cal_db_service_set_repeat_end_date(sch_record);
- }
+ 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);
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;
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++);
}
return ret;
}
+
+
+int cals_escape_like_pattern(const char *src, char * const dest, int dest_size)
+{
+ int s_pos=0, d_pos=0;
+
+ if (NULL == src) {
+ ERR("The parameter(src) is NULL");
+ dest[d_pos] = '\0';
+ return 0;
+ }
+
+ while (src[s_pos] != 0) {
+ if (dest_size == d_pos - 1)
+ break;
+ if ('%' == src[s_pos] || '_' == src[s_pos]) {
+ dest[d_pos++] = '\\';
+ }
+ dest[d_pos++] = src[s_pos++];
+ }
+
+ dest[d_pos] = '\0';
+
+ return d_pos;
+}
+
+
return sqlite3_bind_text(stmt, pos, str, strlen(str), SQLITE_STATIC);
}
+int cals_escape_like_pattern(const char *src, char *dest, int dest_size);
+
#endif /* __CALENDAR_SVC_SQLITE_H__ */
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;
{
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;
{
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;
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_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 */
*/
#include <time.h>
#include <sys/types.h>
+#include <vconf.h>
+#include <stdlib.h>
#include "cals-internal.h"
#include "cals-tz-utils.h"
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");
+}
+
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__ */
{
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));