summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYeongil Jang <yg0577.jang@samsung.com>2012-09-21 00:19:43 +0900
committerYeongil Jang <yg0577.jang@samsung.com>2012-09-21 00:19:43 +0900
commit6d5a5230487644957ac52c689af2395c3267338a (patch)
tree2b233f37b8629da2893cf09ce5dd0262e337c1e9 /src
parenta51a532adbad8e61d9917d43a98a73a5dea67a83 (diff)
downloadcalendar-master.tar.gz
calendar-master.tar.bz2
calendar-master.zip
Diffstat (limited to 'src')
-rwxr-xr-xsrc/calendar.c3955
-rwxr-xr-xsrc/calendar_private.c355
2 files changed, 2912 insertions, 1398 deletions
diff --git a/src/calendar.c b/src/calendar.c
index c91ec63..d27d007 100755
--- a/src/calendar.c
+++ b/src/calendar.c
@@ -11,20 +11,22 @@
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
*/
-
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <stdint.h>
#include <time.h>
-#include <calendar.h>
-#include <calendar_private.h>
-
-#include <calendar-svc-provider.h>
#include <dlog.h>
#include <contacts.h>
+#include <calendar-svc-provider.h>
+
+#include "calendar_private.h"
+#include "calendar_types.h"
+#include "calendar.h"
#ifdef LOG_TAG
#undef LOG_TAG
@@ -33,142 +35,189 @@
#define LOG_TAG "TIZEN_N_CALENDAR"
#define LOG_MODE (1)
+#ifndef CALS_TODO_NO_DUE_DATE
+#define CALS_TODO_NO_DUE_DATE INT64_MAX
+#endif
+
+
/*
* Public Implementation
*/
int calendar_connect(void)
{
- int ret_val = calendar_svc_connect();
-
- if (ret_val == CAL_SUCCESS) {
- return CALENDAR_ERROR_NONE;
- } else {
- LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+ if (calendar_svc_connect() != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
return CALENDAR_ERROR_DB_FAILED;
}
+ return CALENDAR_ERROR_NONE;
}
int calendar_disconnect(void)
{
- int ret_val = calendar_svc_close();
+ if (calendar_svc_close() != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ return CALENDAR_ERROR_NONE;
+}
- if (ret_val == CAL_SUCCESS) {
- return CALENDAR_ERROR_NONE;
- } else {
- LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+int calendar_begin_transaction(void)
+{
+ if (calendar_svc_begin_trans()!= CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
return CALENDAR_ERROR_DB_FAILED;
}
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_rollback_transaction(void)
+{
+ if (calendar_svc_end_trans(false)!= CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_commit_transaction(void)
+{
+ if (calendar_svc_end_trans(true)!= CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_book_delete_from_db(int calendar_db_id)
+{
+ int ret;
+
+ ret = calendar_svc_delete(CAL_STRUCT_CALENDAR, calendar_db_id);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_delete_all_by_account(int account_db_id)
+{
+ int ret;
+
+ ret = calendar_svc_delete(CAL_STRUCT_SCHEDULE, account_db_id);
+
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ return CALENDAR_ERROR_NONE;
}
int calendar_event_insert_to_db(calendar_event_h event, int calendar_db_id, int *event_id)
-{
+{
CALENDAR_NULL_ARG_CHECK(event);
CALENDAR_NULL_ARG_CHECK(event_id);
-
- int ret_val = CALENDAR_ERROR_NONE;
- int account_db_id = _calendar_get_account_db_id(calendar_db_id);
- CONTACTS_INVALID_ARG_CHECK(account_db_id == -2);
+ int ret;
+ int account_db_id;
+ cal_struct *cs;
- calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_INT_CALENDAR_ID, calendar_db_id);
- calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_INT_ACCOUNT_ID, account_db_id);
+ account_db_id = _calendar_get_account_db_id(calendar_db_id);
+ CALENDAR_INVALID_ARG_CHECK(account_db_id == -2);
- ret_val = -1;
- ret_val = calendar_svc_insert((cal_struct*)((calendar_event_s*)event)->event_legacy);
- if (ret_val < 0) {
- LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if (cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_CALENDAR_ID, calendar_db_id);
+ calendar_svc_struct_set_int(cs, CAL_VALUE_INT_ACCOUNT_ID, account_db_id);
+
+ ret = calendar_svc_insert(cs);
+ if (ret < 0) {
+ LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
return CALENDAR_ERROR_DB_FAILED;
}
- *event_id = ret_val;
- return CALENDAR_ERROR_NONE;
+ *event_id = ret;
+ return CALENDAR_ERROR_NONE;
}
int calendar_event_delete_from_db(int event_id)
-{
- CONTACTS_INVALID_ARG_CHECK(event_id <= 0);
-
- int ret_val = CALENDAR_ERROR_NONE;
-
- ret_val = calendar_svc_delete(CAL_STRUCT_SCHEDULE, event_id);
-
- if (ret_val == CAL_SUCCESS) {
- ret_val = CALENDAR_ERROR_NONE;
- }
- else {
- LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
- ret_val = CALENDAR_ERROR_DB_FAILED;
- }
+{
+ CALENDAR_INVALID_ARG_CHECK(event_id <= 0);
+
+ int ret;
- return ret_val;
+ ret = calendar_svc_delete(CAL_STRUCT_SCHEDULE, event_id);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ return CALENDAR_ERROR_NONE;
}
int calendar_event_update_to_db(calendar_event_h event)
-{
+{
CALENDAR_NULL_ARG_CHECK(event);
- int ret_val = CALENDAR_ERROR_NONE;
+ int ret;
+ cal_struct *cs;
- if((cal_struct*)((calendar_event_s*)event)->event_legacy == NULL) {
- LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- int event_id = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_TABLE_INT_INDEX);
- if(event_id <= 0) {
- LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- }
-
- cal_struct* cal = NULL;
- if(calendar_svc_get(CAL_STRUCT_SCHEDULE, event_id, NULL, &cal) == CAL_SUCCESS) { // referenced (SVACE)
- if( ((calendar_schedule_s*)((calendar_event_legacy_s*)cal)->user_data)->is_deleted == true ) { // referenced (SVACE)
- if(cal != NULL) { // referenced (SVACE)
- calendar_svc_struct_free(&cal);
- }
- LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
- return CALENDAR_ERROR_INVALID_PARAMETER;
- } else {
- if(cal != NULL) { // referenced (SVACE)
- calendar_svc_struct_free(&cal);
- }
- }
- } else {
- if(cal != NULL) { // referenced (SVACE)
- calendar_svc_struct_free(&cal);
- }
- LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
-
- ret_val = calendar_svc_update((cal_struct*)((calendar_event_s*)event)->event_legacy);
- if (ret_val != CAL_SUCCESS) {
- LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+ ret = calendar_svc_update(cs);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
return CALENDAR_ERROR_DB_FAILED;
}
-
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
int calendar_event_get_from_db(int event_id, calendar_event_h *event)
{
CALENDAR_NULL_ARG_CHECK(event);
- *event = malloc(sizeof(calendar_event_s));
- if (*event == NULL) {
- LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY);
+
+ int ret;
+ calendar_event_s *ce;
+
+ ce = calloc(1, sizeof(calendar_event_s));
+ if (ce == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY);
return CALENDAR_ERROR_OUT_OF_MEMORY;
}
- memset(*event, 0, sizeof(calendar_event_s));
- if(calendar_svc_get(CAL_STRUCT_SCHEDULE, event_id, NULL, (cal_struct**)&(*(calendar_event_s**)event)->event_legacy) != CAL_SUCCESS) {
+ LOGD("event_id = %d", event_id);
+
+ ret = calendar_svc_get(CAL_STRUCT_SCHEDULE, event_id, NULL,
+ (cal_struct **)&(ce->event_legacy));
+ if(ret != CAL_SUCCESS) {
free(*event);
*event = NULL;
-
- LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+ LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
return CALENDAR_ERROR_DB_FAILED;
}
+ *event = (calendar_event_h)ce;
return CALENDAR_ERROR_NONE;
}
@@ -177,129 +226,988 @@ int calendar_event_get_db_id(calendar_event_h event, int *db_id)
CALENDAR_NULL_ARG_CHECK(event);
CALENDAR_NULL_ARG_CHECK(db_id);
- *db_id = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)event)->event_legacy, (char*)CAL_VALUE_INT_INDEX);
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ *db_id = calendar_svc_struct_get_int(cs, CAL_VALUE_INT_INDEX);
if(*db_id < 0)
*db_id = 0;
return CALENDAR_ERROR_NONE;
}
-int calendar_event_get_calendar_db_id(calendar_event_h event, int *calendar_db_id)
+int calendar_event_get_calendar_book_db_id(calendar_event_h event, int *calendar_book_db_id)
{
CALENDAR_NULL_ARG_CHECK(event);
- CALENDAR_NULL_ARG_CHECK(calendar_db_id);
+ CALENDAR_NULL_ARG_CHECK(calendar_book_db_id);
- *calendar_db_id = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)event)->event_legacy,
- (char*)CAL_VALUE_INT_CALENDAR_ID);
- if(*calendar_db_id < 0)
- *calendar_db_id = 0;
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ *calendar_book_db_id = calendar_svc_struct_get_int(cs, CAL_VALUE_INT_CALENDAR_ID);
+ if(*calendar_book_db_id < 0)
+ *calendar_book_db_id = 0;
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_get_status(calendar_event_h event, calendar_event_status_e *status)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+ CALENDAR_NULL_ARG_CHECK(status);
+
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ *status = calendar_svc_struct_get_int(cs, CAL_VALUE_INT_MEETING_STATUS);
+ if (*status < 0) {
+ *status = 0;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_set_status(calendar_event_h event, calendar_event_status_e status)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+
+ int ret;
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = calendar_svc_struct_set_int(cs, CAL_VALUE_INT_MEETING_STATUS, status);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_get_priority(calendar_event_h event, calendar_event_priority_e *priority)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+ CALENDAR_NULL_ARG_CHECK(priority);
+
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ *priority = calendar_svc_struct_get_int(cs, CAL_VALUE_INT_PRIORITY);
+
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_set_priority(calendar_event_h event, calendar_event_priority_e priority)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+
+ int ret;
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = calendar_svc_struct_set_int(cs, CAL_VALUE_INT_PRIORITY, priority);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_get_busy_status(calendar_event_h event, calendar_event_busy_status_e *busy_status)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+ CALENDAR_NULL_ARG_CHECK(busy_status);
+
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ *busy_status = calendar_svc_struct_get_int(cs, CAL_VALUE_INT_BUSY_STATUS);
+
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_set_busy_status(calendar_event_h event, calendar_event_busy_status_e busy_status)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+
+ int ret;
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = calendar_svc_struct_set_int(cs, CAL_VALUE_INT_BUSY_STATUS, busy_status);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
return CALENDAR_ERROR_NONE;
}
-int calendar_event_get_total_count_from_db(int *count)
-{
+// TOREM
+int calendar_event_get_total_count_from_db(int calendar_book_db_id, int *count)
+{
CALENDAR_NULL_ARG_CHECK(count);
-
- *count = calendar_svc_get_count(0, 0, (char*)CAL_STRUCT_SCHEDULE);
- if(*count == CAL_ERR_FAIL)
- {
+
+ int cnt;
+ int account_db_id;
+
+ account_db_id = _calendar_get_account_db_id(calendar_book_db_id);
+ CALENDAR_INVALID_ARG_CHECK(account_db_id == -2);
+ cnt = calendar_svc_get_count(account_db_id, calendar_book_db_id, CAL_STRUCT_SCHEDULE);
+ if(cnt == CAL_ERR_FAIL) {
*count = 0;
- LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+ LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ *count = cnt;
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_get_reminder_sound_file_path(calendar_event_h event, char **sound_file_path)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+ CALENDAR_NULL_ARG_CHECK(sound_file_path);
+
+ cal_struct *cs;
+ GList *alarm_list;
+ int ret;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ ret = calendar_svc_struct_get_list(cs, CAL_VALUE_LST_ALARM, &alarm_list);
+ if (ret < CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (!alarm_list || !alarm_list->data) {
+ *sound_file_path = NULL;
+ return CALENDAR_ERROR_NONE;
+ }
+
+ *sound_file_path = _calendar_safe_strdup(
+ calendar_svc_value_get_str(alarm_list->data, CAL_VALUE_TXT_ALARMS_TONE));
+
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_set_reminder_sound_file_path(calendar_event_h event, const char *sound_file_path)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+
+ int ret;
+ cal_struct *cs;
+ GList *alarm_list = NULL;
+ cal_value *value;
+ GList* list = NULL;
+ int svc_reminder_interval_type;
+ int reminder_interval;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ ret = calendar_svc_struct_get_list(cs, CAL_VALUE_LST_ALARM, &alarm_list);
+ if (ret < CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ if (alarm_list) {
+ if (!alarm_list->data) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ value = (cal_value *)alarm_list->data;
+ svc_reminder_interval_type = calendar_svc_value_get_int(value,
+ CAL_VALUE_INT_ALARMS_TICK_UNIT);
+ reminder_interval = calendar_svc_value_get_int(value,
+ CAL_VALUE_INT_ALARMS_TICK);
+ calendar_svc_struct_free(&value);
+ alarm_list = NULL;
+ }
+
+ value = calendar_svc_value_new(CAL_VALUE_LST_ALARM);
+ if (value == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ ret = calendar_svc_value_set_int(value,
+ CAL_VALUE_INT_ALARMS_TICK_UNIT, svc_reminder_interval_type);
+ if (ret != CAL_SUCCESS) {
+ calendar_svc_value_free(&value);
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = calendar_svc_value_set_int(value, CAL_VALUE_INT_ALARMS_TICK, reminder_interval);
+ if (ret != CAL_SUCCESS) {
+ calendar_svc_value_free(&value);
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = calendar_svc_value_set_str(value, CAL_VALUE_TXT_ALARMS_TONE, sound_file_path);
+ if (ret != CAL_SUCCESS) {
+ calendar_svc_value_free(&value);
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ calendar_svc_struct_store_list(cs, CAL_VALUE_LST_ALARM, NULL);
+ list = g_list_append(list, value);
+ ret = calendar_svc_struct_store_list(cs, CAL_VALUE_LST_ALARM, list);
+ if (ret != CAL_SUCCESS) {
+ calendar_svc_value_free(&value);
+ g_list_free(list);
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_get_recurrence_byday(calendar_event_h event, char **byday)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+ CALENDAR_NULL_ARG_CHECK(byday);
+
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ *byday = _calendar_safe_strdup(
+ calendar_svc_struct_get_str(cs, CALS_VALUE_TXT_RRULE_BYDAY));
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_set_recurrence_byday(calendar_event_h event, const char* byday)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+
+ int ret;
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYDAY, byday);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_get_recurrence_bysetpos(calendar_event_h event, char **bysetpos)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+ CALENDAR_NULL_ARG_CHECK(bysetpos);
+
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ *bysetpos = _calendar_safe_strdup(
+ calendar_svc_struct_get_str(cs, CALS_VALUE_TXT_RRULE_BYSETPOS));
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_set_recurrence_bysetpos(calendar_event_h event, const char* bysetpos)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+
+ int ret;
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYSETPOS, bysetpos);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_get_recurrence_bymonthday(calendar_event_h event, char **bymonthday)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+ CALENDAR_NULL_ARG_CHECK(bymonthday);
+
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ *bymonthday = _calendar_safe_strdup(
+ calendar_svc_struct_get_str(cs, CALS_VALUE_TXT_RRULE_BYMONTHDAY));
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_set_recurrence_bymonthday(calendar_event_h event, const char* bymonthday)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+
+ int ret;
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYMONTHDAY, bymonthday);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_get_recurrence_bymonth(calendar_event_h event, char **bymonth)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+ CALENDAR_NULL_ARG_CHECK(bymonth);
+
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ *bymonth = _calendar_safe_strdup(
+ calendar_svc_struct_get_str(cs, CALS_VALUE_TXT_RRULE_BYMONTH));
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_set_recurrence_bymonth(calendar_event_h event, const char* bymonth)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+
+ int ret;
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = calendar_svc_struct_set_str(cs, CALS_VALUE_TXT_RRULE_BYMONTH, bymonth);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_get_recurrence_week_start(calendar_event_h event, calendar_week_flag_e *week_start)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+ CALENDAR_NULL_ARG_CHECK(week_start);
+
+ int wkst;
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ wkst = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_RRULE_WKST);
+ switch (wkst) {
+ case CALS_SUNDAY:
+ *week_start = CALENDAR_WEEK_FLAG_SUN;
+ break;
+ case CALS_MONDAY:
+ *week_start = CALENDAR_WEEK_FLAG_MON;
+ break;
+ case CALS_TUESDAY:
+ *week_start = CALENDAR_WEEK_FLAG_TUE;
+ break;
+ case CALS_WEDNESDAY:
+ *week_start = CALENDAR_WEEK_FLAG_WED;
+ break;
+ case CALS_THURSDAY:
+ *week_start = CALENDAR_WEEK_FLAG_THU;
+ break;
+ case CALS_FRIDAY:
+ *week_start = CALENDAR_WEEK_FLAG_FRI;
+ break;
+ case CALS_SATURDAY:
+ *week_start = CALENDAR_WEEK_FLAG_SAT;
+ break;
+ default:
+ *week_start = CALENDAR_WEEK_FLAG_SUN;
+ break;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_set_recurrence_week_start(calendar_event_h event, calendar_week_flag_e week_start)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+
+ int ret = CALENDAR_ERROR_NONE;
+ int wkst;
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ switch (week_start) {
+ case CALENDAR_WEEK_FLAG_SUN:
+ wkst = CALS_SUNDAY;
+ break;
+ case CALENDAR_WEEK_FLAG_MON:
+ wkst = CALS_MONDAY;
+ break;
+ case CALENDAR_WEEK_FLAG_TUE:
+ wkst = CALS_TUESDAY;
+ break;
+ case CALENDAR_WEEK_FLAG_WED:
+ wkst = CALS_WEDNESDAY;
+ break;
+ case CALENDAR_WEEK_FLAG_THU:
+ wkst = CALS_THURSDAY;
+ break;
+ case CALENDAR_WEEK_FLAG_FRI:
+ wkst = CALS_FRIDAY;
+ break;
+ case CALENDAR_WEEK_FLAG_SAT:
+ wkst = CALS_SATURDAY;
+ break;
+ default:
+ wkst = CALS_SUNDAY;
+ break;
+ }
+ ret = calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_WKST, wkst);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_delete_recurrence_instance_from_db(int event_db_id, long long int start_time)
+{
+ int ret;
+
+ if (event_db_id < 0) {
+ LOGE("Invalid argument: event_db_id is NULL");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = calendar_svc_event_delete_normal_instance(event_db_id, start_time);
+ if (ret != CAL_SUCCESS) {
+ LOGE("Failed to delete normal instance");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_delete_recurrence_all_day_instance_from_db(int event_db_id, int year, int month, int day)
+{
+ int ret;
+
+ if (event_db_id < 0) {
+ LOGE("Invalid argument: event_db_id is NULL");
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = calendar_svc_event_delete_allday_instance(event_db_id, year, month, day);
+ if (ret != CAL_SUCCESS) {
+ LOGE("Failed to delete normal instance");
return CALENDAR_ERROR_DB_FAILED;
}
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_get_recurrence_exdate(calendar_event_h event, char** exdate)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+ CALENDAR_NULL_ARG_CHECK(exdate);
+
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if (cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ *exdate = _calendar_safe_strdup(
+ calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_EXDATE));
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_get_uid(calendar_event_h event, char **uid)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+ CALENDAR_NULL_ARG_CHECK(uid);
+
+ char *_uid;
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ _uid = _calendar_safe_strdup(
+ calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_UID));
+ if (_uid == NULL || strlen(_uid) < 1) {
+ *uid = NULL;
+
+ } else {
+ *uid = _uid;
+
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_set_uid(calendar_event_h event, const char *uid)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+
+ int ret;
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_UID, uid);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_get_recurrence_interval(calendar_event_h event, int *recurrence_interval)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+ CALENDAR_NULL_ARG_CHECK(recurrence_interval);
+
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ *recurrence_interval = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_RRULE_INTERVAL);
+
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_set_recurrence_interval(calendar_event_h event, int recurrence_interval)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+
+ int ret;
+ cal_struct *cs;
- return CALENDAR_ERROR_NONE;
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_INTERVAL, recurrence_interval);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_get_recurrence_count(calendar_event_h event, int *recurrence_count)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+ CALENDAR_NULL_ARG_CHECK(recurrence_count);
+
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ *recurrence_count = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_RRULE_COUNT);
+
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_set_recurrence_count(calendar_event_h event, int recurrence_count)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+
+ int ret;
+ int type;
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ type = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_DTSTART_TYPE);
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_UNTIL_TYPE, type);
+
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_RANGE_TYPE, CALS_RANGE_COUNT);
+ ret = calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_COUNT, recurrence_count);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_attendee_get_status(calendar_attendee_h attendee, calendar_attendee_status_e *status)
+{
+ CALENDAR_NULL_ARG_CHECK(attendee);
+ CALENDAR_NULL_ARG_CHECK(status);
+
+ *status = calendar_svc_value_get_int(
+ (cal_value*)attendee,
+ CAL_VALUE_INT_ATTENDEE_DETAIL_STATUS);
+ if(*status < 0 || *status > CALENDAR_ATTENDEE_STATUS_MAX) {
+ *status = -1;
+ return CALENDAR_ERROR_NO_DATA;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_attendee_set_status(calendar_attendee_h attendee, calendar_attendee_status_e status)
+{
+ CALENDAR_NULL_ARG_CHECK(attendee);
+
+ int ret;
+
+ ret = calendar_svc_value_set_int(
+ (cal_value*)attendee,
+ CAL_VALUE_INT_ATTENDEE_DETAIL_STATUS, status);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_attendee_get_role(calendar_attendee_h attendee, calendar_attendee_role_e *role)
+{
+ CALENDAR_NULL_ARG_CHECK(attendee);
+ CALENDAR_NULL_ARG_CHECK(role);
+
+ *role = calendar_svc_value_get_int(
+ (cal_value*)attendee,
+ CAL_VALUE_INT_ATTENDEE_ROLE);
+ if(*role < 0 || *role > CALENDAR_ATTENDEE_ROLE_MAX) {
+ *role = -1;
+ return CALENDAR_ERROR_NO_DATA;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_attendee_set_role(calendar_attendee_h attendee, calendar_attendee_role_e role)
+{
+ CALENDAR_NULL_ARG_CHECK(attendee);
+
+ int ret;
+
+ ret = calendar_svc_value_set_int(
+ (cal_value*)attendee,
+ CAL_VALUE_INT_ATTENDEE_ROLE, role);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
}
int calendar_event_create (calendar_event_h *event)
-{
+{
CALENDAR_NULL_ARG_CHECK(event);
- *event = malloc(sizeof(calendar_event_s));
+ *event = calloc(1, sizeof(calendar_event_s));
if (*event == NULL) {
- LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY);
+ LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY);
return CALENDAR_ERROR_OUT_OF_MEMORY;
}
- (*(calendar_event_s**)event)->event_legacy = (calendar_event_legacy_s*)calendar_svc_struct_new(CAL_STRUCT_SCHEDULE);
+ (*(calendar_event_s**)event)->event_legacy = (calendar_event_legacy_s*)calendar_svc_struct_new(CAL_STRUCT_SCHEDULE);
if ((*(calendar_event_s**)event)->event_legacy == NULL) {
free(*event);
*event = NULL;
- LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY);
+ LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY);
return CALENDAR_ERROR_OUT_OF_MEMORY;
}
- calendar_svc_struct_set_int((cal_struct*)(*(calendar_event_s**)event)->event_legacy, CAL_VALUE_INT_TIMEZONE, 100); // set default timezone
-
+
return CALENDAR_ERROR_NONE;
}
-
+
int calendar_event_destroy(calendar_event_h event)
-{
- int ret_val = CALENDAR_ERROR_NONE;
+{
CALENDAR_NULL_ARG_CHECK(event);
- ret_val = calendar_svc_struct_free((cal_struct **)&((calendar_event_s*)event)->event_legacy);
-
- if (ret_val != CAL_SUCCESS) {
- LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
- ret_val = CALENDAR_ERROR_INVALID_PARAMETER;
- } else {
- free(event);
- ret_val = CALENDAR_ERROR_NONE;
+ int ret;
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
}
- return ret_val;
+ ret = calendar_svc_struct_free(&cs);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY);
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+
+ free(event);
+ return CALENDAR_ERROR_NONE;
}
int calendar_event_get_subject(calendar_event_h event, char **subject)
-{
+{
CALENDAR_NULL_ARG_CHECK(event);
CALENDAR_NULL_ARG_CHECK(subject);
- *subject = NULL;
- *subject = _calendar_safe_strdup(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_TXT_SUMMARY));
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- return CALENDAR_ERROR_NONE;
+ *subject = _calendar_safe_strdup(
+ calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_SUMMARY));
+
+ return CALENDAR_ERROR_NONE;
}
int calendar_event_set_subject(calendar_event_h event,const char *subject)
-{
- int ret_val = CALENDAR_ERROR_NONE;
+{
CALENDAR_NULL_ARG_CHECK(event);
- ret_val = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_TXT_SUMMARY, subject);
+ int ret;
+ cal_struct *cs;
- if (ret_val != CAL_SUCCESS) {
- LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
+ ret = calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_SUMMARY, subject);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_get_categories(calendar_event_h event, char **categories)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+ CALENDAR_NULL_ARG_CHECK(categories);
+
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ *categories = _calendar_safe_strdup(
+ calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_CATEGORIES));
+
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_set_categories(calendar_event_h event,const char *categories)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+
+ int ret;
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_CATEGORIES, categories);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
return CALENDAR_ERROR_NONE;
}
int calendar_event_get_description(calendar_event_h event,char **description)
-{
+{
CALENDAR_NULL_ARG_CHECK(event);
CALENDAR_NULL_ARG_CHECK(description);
- *description = NULL;
- *description = _calendar_safe_strdup(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_TXT_DESCRIPTION));
+ cal_struct *cs;
- return CALENDAR_ERROR_NONE;
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ *description = _calendar_safe_strdup(
+ calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_DESCRIPTION));
+
+ return CALENDAR_ERROR_NONE;
}
int calendar_event_set_description(calendar_event_h event, const char *description)
-{
- int ret_val = CALENDAR_ERROR_NONE;
-
+{
CALENDAR_NULL_ARG_CHECK(event);
- ret_val = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_TXT_DESCRIPTION, description);
+ int ret;
+ cal_struct *cs;
- if (ret_val != CAL_SUCCESS) {
- LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
+ ret = calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_DESCRIPTION, description);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
return CALENDAR_ERROR_NONE;
}
@@ -308,56 +1216,174 @@ int calendar_event_get_is_all_day_event(calendar_event_h event, bool *is_all_day
CALENDAR_NULL_ARG_CHECK(event);
CALENDAR_NULL_ARG_CHECK(is_all_day_event);
- *is_all_day_event = (bool)calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)event)->event_legacy,
- CAL_VALUE_INT_ALL_DAY_EVENT);
+ cal_struct *cs;
+ bool all_day;
+ int type;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ type = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_DTSTART_TYPE);
+
+ if (type == CALS_TIME_LOCALTIME)
+ all_day = true;
+ else
+ all_day = false;
+
+ *is_all_day_event = all_day;
return CALENDAR_ERROR_NONE;
}
-int calendar_event_set_is_all_day_event(calendar_event_h event, bool is_all_day_event)
-{
- int ret_val = CALENDAR_ERROR_NONE;
-
+int calendar_event_set_all_day_event(calendar_event_h event,
+ int start_year, int start_month, int start_day,
+ int end_year, int end_month, int end_day)
+{
CALENDAR_NULL_ARG_CHECK(event);
- ret_val = calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)event)->event_legacy,
- CAL_VALUE_INT_ALL_DAY_EVENT, is_all_day_event);
- if (ret_val != CAL_SUCCESS) {
- LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ int ret;
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTSTART_TYPE, CALS_TIME_LOCALTIME);
+ ret |= calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTSTART_YEAR, start_year);
+ ret |= calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTSTART_MONTH, start_month);
+ ret |= calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTSTART_MDAY, start_day);
+ ret |= calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTEND_TYPE, CALS_TIME_LOCALTIME);
+ ret |= calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTEND_YEAR, end_year);
+ ret |= calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTEND_MONTH, end_month);
+ ret |= calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTEND_MDAY, end_day);
+
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_get_all_day_event(calendar_event_h event,
+ int *start_year, int *start_month, int *start_day,
+ int *end_year, int *end_month, int *end_day)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+ CALENDAR_NULL_ARG_CHECK(start_year);
+ CALENDAR_NULL_ARG_CHECK(start_month);
+ CALENDAR_NULL_ARG_CHECK(start_day);
+ CALENDAR_NULL_ARG_CHECK(end_year);
+ CALENDAR_NULL_ARG_CHECK(end_month);
+ CALENDAR_NULL_ARG_CHECK(end_day);
+
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
+ *start_year = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_DTSTART_YEAR);
+ *start_month = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_DTSTART_MONTH);
+ *start_day = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_DTSTART_MDAY);
+ *end_year = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_DTEND_YEAR);
+ *end_month = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_DTEND_MONTH);
+ *end_day = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_DTEND_MDAY);
+
return CALENDAR_ERROR_NONE;
- }
+}
int calendar_event_get_location(calendar_event_h event, char **location)
-{
+{
CALENDAR_NULL_ARG_CHECK(event);
CALENDAR_NULL_ARG_CHECK(location);
- *location = NULL;
- *location = _calendar_safe_strdup(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)event)->event_legacy,
- CAL_VALUE_TXT_LOCATION));
-
- return CALENDAR_ERROR_NONE;
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ *location = _calendar_safe_strdup(
+ calendar_svc_struct_get_str(cs, CAL_VALUE_TXT_LOCATION) );
+
+ return CALENDAR_ERROR_NONE;
}
int calendar_event_set_location(calendar_event_h event, const char *location)
-{
- int ret_val = CALENDAR_ERROR_NONE;
-
+{
CALENDAR_NULL_ARG_CHECK(event);
+ CALENDAR_NULL_ARG_CHECK(location);
- ret_val = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)event)->event_legacy,
- CAL_VALUE_TXT_LOCATION, location);
-
- if (ret_val != CAL_SUCCESS)
- {
- LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ int ret;
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- return CALENDAR_ERROR_NONE;
+ ret = calendar_svc_struct_set_str(cs, CAL_VALUE_TXT_LOCATION, location);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+
+int _get_svc_reminder_interval_type(calendar_reminder_interval_type_e reminder_interval_type)
+{
+ switch (reminder_interval_type) {
+ case CALENDAR_REMINDER_NONE:
+ return CAL_SCH_TIME_UNIT_OFF;
+ case CALENDAR_REMINDER_TIME_UNIT_MINUTE:
+ return CAL_SCH_TIME_UNIT_MIN;
+ case CALENDAR_REMINDER_TIME_UNIT_HOUR:
+ return CAL_SCH_TIME_UNIT_HOUR;
+ case CALENDAR_REMINDER_TIME_UNIT_DAY:
+ return CAL_SCH_TIME_UNIT_DAY;
+ case CALENDAR_REMINDER_TIME_UNIT_WEEK:
+ return CAL_SCH_TIME_UNIT_WEEK;
+ case CALENDAR_REMINDER_TIME_UNIT_MONTH:
+ return CAL_SCH_TIME_UNIT_MONTH;
+ }
+ return CAL_SCH_TIME_UNIT_OFF;
+}
+
+calendar_reminder_interval_type_e _set_svc_reminder_interval_type(int svc_reminder_interval_type)
+{
+ switch (svc_reminder_interval_type) {
+ case CAL_SCH_TIME_UNIT_OFF:
+ return CALENDAR_REMINDER_NONE;
+ case CAL_SCH_TIME_UNIT_MIN:
+ return CALENDAR_REMINDER_TIME_UNIT_MINUTE;
+ case CAL_SCH_TIME_UNIT_HOUR:
+ return CALENDAR_REMINDER_TIME_UNIT_HOUR;
+ case CAL_SCH_TIME_UNIT_DAY:
+ return CALENDAR_REMINDER_TIME_UNIT_DAY;
+ case CAL_SCH_TIME_UNIT_WEEK:
+ return CALENDAR_REMINDER_TIME_UNIT_WEEK;
+ case CAL_SCH_TIME_UNIT_MONTH:
+ return CALENDAR_REMINDER_TIME_UNIT_MONTH;
+ }
+ return CALENDAR_REMINDER_NONE;
}
int calendar_event_get_reminder(calendar_event_h event,calendar_reminder_interval_type_e *reminder_interval_type, int *reminder_interval)
@@ -366,21 +1392,29 @@ int calendar_event_get_reminder(calendar_event_h event,calendar_reminder_interva
CALENDAR_NULL_ARG_CHECK(reminder_interval_type);
CALENDAR_NULL_ARG_CHECK(reminder_interval);
- GList* list = NULL;
- if(calendar_svc_struct_get_list((cal_struct*)((calendar_event_s*)event)->event_legacy,
- CAL_VALUE_LST_ALARM, &list) != CAL_SUCCESS) {
- LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ GList *alarm_list;
+ int r;
+ int svc_reminder_interval_type;
+
+ r = calendar_svc_struct_get_list((cal_struct*)((calendar_event_s*)event)->event_legacy,
+ CAL_VALUE_LST_ALARM, &alarm_list);
+ if (r < CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- if (g_list_length(list) == 0) {
- LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
- return CALENDAR_ERROR_INVALID_PARAMETER;
+ if (!alarm_list || !alarm_list->data) {
+ *reminder_interval_type = CALENDAR_REMINDER_NONE;
+ *reminder_interval = 0;
+ return CALENDAR_ERROR_NONE;
}
- cal_value *value = (cal_value *)list->data;
- *reminder_interval_type = calendar_svc_value_get_int(value, CAL_VALUE_INT_ALARMS_TICK_UNIT);
- *reminder_interval = calendar_svc_value_get_int(value, CAL_VALUE_INT_ALARMS_TICK);
+ svc_reminder_interval_type = calendar_svc_value_get_int(alarm_list->data,
+ CAL_VALUE_INT_ALARMS_TICK_UNIT);
+ *reminder_interval_type = _set_svc_reminder_interval_type(svc_reminder_interval_type);
+ *reminder_interval = calendar_svc_value_get_int(alarm_list->data,
+ CAL_VALUE_INT_ALARMS_TICK);
return CALENDAR_ERROR_NONE;
}
@@ -389,31 +1423,56 @@ int calendar_event_set_reminder(calendar_event_h event,calendar_reminder_interva
{
CALENDAR_NULL_ARG_CHECK(event);
- cal_value *value = calendar_svc_value_new(CAL_VALUE_LST_ALARM);
- if(calendar_svc_value_set_int(value, CAL_VALUE_INT_ALARMS_TICK_UNIT, reminder_interval_type) != CAL_SUCCESS) {
+ int ret;
+ int svc_reminder_interval_type;
+ cal_struct *cs;
+ cal_value *value;
+ GList* list = NULL;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ value = calendar_svc_value_new(CAL_VALUE_LST_ALARM);
+ if (value == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ svc_reminder_interval_type = _get_svc_reminder_interval_type(reminder_interval_type);
+
+ ret = calendar_svc_value_set_int(value,
+ CAL_VALUE_INT_ALARMS_TICK_UNIT, svc_reminder_interval_type);
+ if (ret != CAL_SUCCESS) {
calendar_svc_value_free(&value);
- LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- if(calendar_svc_value_set_int(value, CAL_VALUE_INT_ALARMS_TICK, reminder_interval) != CAL_SUCCESS) {
+ ret = calendar_svc_value_set_int(value, CAL_VALUE_INT_ALARMS_TICK, reminder_interval);
+ if (ret != CAL_SUCCESS) {
calendar_svc_value_free(&value);
- LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- GList* list = NULL;
- calendar_svc_struct_store_list((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_LST_ALARM, NULL);
+ calendar_svc_struct_store_list(cs, CAL_VALUE_LST_ALARM, NULL);
list = g_list_append(list, value);
- if(calendar_svc_struct_store_list((cal_struct*)((calendar_event_s*)event)->event_legacy,
- CAL_VALUE_LST_ALARM, list) != CAL_SUCCESS) {
+ ret = calendar_svc_struct_store_list(cs, CAL_VALUE_LST_ALARM, list);
+ if (ret != CAL_SUCCESS) {
calendar_svc_value_free(&value);
g_list_free(list);
- LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
-
return CALENDAR_ERROR_NONE;
}
@@ -422,382 +1481,268 @@ int calendar_event_get_recurrence_frequency(calendar_event_h event,calendar_recu
CALENDAR_NULL_ARG_CHECK(event);
CALENDAR_NULL_ARG_CHECK(recurrence_frequency);
- *recurrence_frequency = (calendar_recurrence_frequency_e)calendar_svc_struct_get_int(
- (cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_INT_REPEAT_TERM);
+ int freq;
+ cal_struct *cs;
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ freq = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_RRULE_FREQ);
+ switch (freq) {
+ case CALS_FREQ_ONCE:
+ *recurrence_frequency = CALENDAR_RECURRENCE_NONE;
+ break;
+ case CALS_FREQ_YEARLY:
+ *recurrence_frequency = CALENDAR_RECURRENCE_YEARLY;
+ break;
+ case CALS_FREQ_MONTHLY:
+ *recurrence_frequency = CALENDAR_RECURRENCE_MONTHLY;
+ break;
+ case CALS_FREQ_WEEKLY:
+ *recurrence_frequency = CALENDAR_RECURRENCE_WEEKLY;
+ break;
+ case CALS_FREQ_DAILY:
+ *recurrence_frequency = CALENDAR_RECURRENCE_DAILY;
+ break;
+ }
return CALENDAR_ERROR_NONE;
}
int calendar_event_set_recurrence_frequency(calendar_event_h event,calendar_recurrence_frequency_e recurrence_frequency)
{
- int ret_val = CALENDAR_ERROR_NONE;
-
CALENDAR_NULL_ARG_CHECK(event);
- calendar_event_legacy_s* event_legacy = ((calendar_event_s*)event)->event_legacy;
- ret_val = calendar_svc_struct_set_int((cal_struct*)event_legacy, CAL_VALUE_INT_REPEAT_TERM, recurrence_frequency);
- switch(recurrence_frequency)
- {
+ int ret;
+ int freq = CALS_FREQ_ONCE;
+ cal_struct *cs;
+
+ switch (recurrence_frequency) {
+ case CALENDAR_RECURRENCE_NONE:
+ freq = CALS_FREQ_ONCE;
+ break;
case CALENDAR_RECURRENCE_DAILY:
- ret_val = calendar_svc_struct_set_int((cal_struct*)event_legacy, CAL_VALUE_INT_REPEAT_INTERVAL, 1);
+ freq = CALS_FREQ_DAILY;
break;
case CALENDAR_RECURRENCE_WEEKLY:
- ret_val = calendar_svc_struct_set_int((cal_struct*)event_legacy, CAL_VALUE_INT_REPEAT_INTERVAL, 1);
- break;
-// case CALENDAR_RECURRENCE_WEEKDAY:
-// ret_val = calendar_svc_struct_set_int((cal_struct*)event_legacy, CAL_VALUE_INT_REPEAT_INTERVAL, 1);
-// break;
- case CALENDAR_RECURRENCE_NONE:
- ret_val = calendar_svc_struct_set_int((cal_struct*)event_legacy, CAL_VALUE_INT_REPEAT_INTERVAL, 1);
+ freq = CALS_FREQ_WEEKLY;
break;
case CALENDAR_RECURRENCE_MONTHLY:
+ freq = CALS_FREQ_MONTHLY;
+ break;
case CALENDAR_RECURRENCE_YEARLY:
-// case CALENDAR_RECURRENCE_MONTHLY_ON_DAY:
- ret_val = calendar_svc_struct_set_int((cal_struct*)event_legacy, CAL_VALUE_INT_REPEAT_INTERVAL, 1);
+ freq = CALS_FREQ_YEARLY;
+ break;
+ default:
+ freq = CALS_FREQ_ONCE;
break;
}
- if (ret_val != CAL_SUCCESS)
- {
- LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_FREQ, freq);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
return CALENDAR_ERROR_NONE;
}
-int calendar_event_get_recurrence_week_flag(calendar_event_h event, int *week_flag)
+int calendar_event_get_recurrence_until_date(calendar_event_h event, long long int *recurrence_until_date)
{
CALENDAR_NULL_ARG_CHECK(event);
- CALENDAR_NULL_ARG_CHECK(week_flag);
-
- char* week_flag_string = calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_TXT_WEEK_FLAG);
-
- if(week_flag_string == NULL) {
- *week_flag = 0;
- return CALENDAR_ERROR_NONE;
- }
-
- *week_flag = CALENDAR_WEEK_FLAG_NONE;
- if(week_flag_string[0] == '1')
- *week_flag = *week_flag | CALENDAR_WEEK_FLAG_SUN;
- if(week_flag_string[1] == '1')
- *week_flag = *week_flag | CALENDAR_WEEK_FLAG_MON;
- if(week_flag_string[2] == '1')
- *week_flag = *week_flag | CALENDAR_WEEK_FLAG_TUE;
- if(week_flag_string[3] == '1')
- *week_flag = *week_flag | CALENDAR_WEEK_FLAG_WED;
- if(week_flag_string[4] == '1')
- *week_flag = *week_flag | CALENDAR_WEEK_FLAG_THU;
- if(week_flag_string[5] == '1')
- *week_flag = *week_flag | CALENDAR_WEEK_FLAG_FRI;
- if(week_flag_string[6] == '1')
- *week_flag = *week_flag | CALENDAR_WEEK_FLAG_SAT;
-
- return CALENDAR_ERROR_NONE;
-}
-
-int calendar_event_set_recurrence_week_flag(calendar_event_h event, int week_flag)
-{
- CALENDAR_NULL_ARG_CHECK(event);
-
- char week_flag_string[8]; // never overflows
- if(week_flag & CALENDAR_WEEK_FLAG_SUN) week_flag_string[0] = '1';
- else week_flag_string[0] = '0';
- if(week_flag & CALENDAR_WEEK_FLAG_MON) week_flag_string[1] = '1';
- else week_flag_string[1] = '0';
- if(week_flag & CALENDAR_WEEK_FLAG_TUE) week_flag_string[2] = '1';
- else week_flag_string[2] = '0';
- if(week_flag & CALENDAR_WEEK_FLAG_WED) week_flag_string[3] = '1';
- else week_flag_string[3] = '0';
- if(week_flag & CALENDAR_WEEK_FLAG_THU) week_flag_string[4] = '1';
- else week_flag_string[4] = '0';
- if(week_flag & CALENDAR_WEEK_FLAG_FRI) week_flag_string[5] = '1';
- else week_flag_string[5] = '0';
- if(week_flag & CALENDAR_WEEK_FLAG_SAT) week_flag_string[6] = '1';
- else week_flag_string[6] = '0';
- week_flag_string[7] = 0x00;
-
- calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_TXT_WEEK_FLAG, week_flag_string); //days in which recurrence should be activated
-
- return CALENDAR_ERROR_NONE;
-}
-
-
-int calendar_event_get_recurrence_until_date(calendar_event_h event, struct tm *recurrence_until_date)
-{
- time_t time;
- struct tm *tmp_date = NULL;
-
- CALENDAR_NULL_ARG_CHECK(event);
CALENDAR_NULL_ARG_CHECK(recurrence_until_date);
- time = calendar_svc_struct_get_time((cal_struct*)((calendar_event_s*)event)->event_legacy,
- CAL_VALUE_GMT_REPEAT_END_DATE, CAL_TZ_FLAG_LOCAL);
-
- if(time == 0) {
- LOGE("[%s] CALENDAR_ERROR_NO_DATA(0x%08x)", __FUNCTION__, CALENDAR_ERROR_NO_DATA);
- return CALENDAR_ERROR_NO_DATA;
- }
-
- tmp_date = localtime(&time);
-
- if (tmp_date == NULL) {
- return CALENDAR_ERROR_NO_DATA;
- }
-
- *recurrence_until_date = *tmp_date;
-
- return CALENDAR_ERROR_NONE;
-}
-
-int calendar_event_set_recurrence_until_date(calendar_event_h event, struct tm recurrence_until_date)
-{
- int ret_val = CALENDAR_ERROR_NONE;
+ long long int lli;
+ cal_struct *cs;
- CALENDAR_NULL_ARG_CHECK(event);
-
- ret_val = calendar_svc_struct_set_time((cal_struct*)((calendar_event_s*)event)->event_legacy,
- CAL_VALUE_GMT_REPEAT_END_DATE, CAL_TZ_FLAG_LOCAL, mktime(&recurrence_until_date));
-
- if (ret_val != CAL_SUCCESS) {
- LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
- return CALENDAR_ERROR_INVALID_PARAMETER;
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
}
- return CALENDAR_ERROR_NONE;
-}
-
-int calendar_event_add_recurrence_exception_date(calendar_event_h event, int year, int month, int day)
-{
- CALENDAR_NULL_ARG_CHECK(event);
-
- int ret_val = CALENDAR_ERROR_NONE;
- GList* exception_list = NULL;
- struct tm date = {0};
- date.tm_year = year - 1900;
- date.tm_mon = month - 1;
- date.tm_mday = day;
-
- cal_value *value = calendar_svc_value_new(CAL_VALUE_LST_EXCEPTION_DATE);
- if(value == NULL) {
- LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY);
- return CALENDAR_ERROR_OUT_OF_MEMORY;
+ lli = calendar_svc_struct_get_lli(cs, CALS_VALUE_LLI_RRULE_UNTIL_UTIME);
+ if (lli == CALS_TODO_NO_DUE_DATE) {
+ return CALENDAR_ERROR_NO_DATA;
}
- calendar_svc_value_set_tm(value, CAL_VALUE_GMT_EXCEPTION_DATE_TIME, CAL_TZ_FLAG_LOCAL, &date);
-
- //get attendee list firstly
- calendar_svc_struct_get_list((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_LST_EXCEPTION_DATE, &exception_list);
- exception_list = g_list_append(exception_list, value);
- ret_val = calendar_svc_struct_store_list((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_LST_EXCEPTION_DATE, exception_list);
-
- return CALENDAR_ERROR_NONE;
+
+ *recurrence_until_date = lli;
+ return CALENDAR_ERROR_NONE;
}
-int calendar_event_get_recurrence_exception_iterator(calendar_event_h event, calendar_recurrence_exception_iterator_h *iterator)
+int calendar_event_set_recurrence_until_date(calendar_event_h event, long long int recurrence_until_date)
{
- CALENDAR_NULL_ARG_CHECK(event);
- CALENDAR_NULL_ARG_CHECK(iterator);
-
- GList* exception_list = NULL;
- //get attendee list first
- calendar_svc_struct_get_list((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_LST_EXCEPTION_DATE, &exception_list);
- *iterator = (calendar_recurrence_exception_iterator_h)exception_list;
+ CALENDAR_NULL_ARG_CHECK(event);
- return CALENDAR_ERROR_NONE;
-}
+ int ret = CALENDAR_ERROR_NONE;
+ cal_struct *cs;
-bool calendar_recurrence_exception_has_next(calendar_recurrence_exception_iterator_h iterator)
-{
- CALENDAR_NULL_ARG_CHECK(iterator);
- if(iterator == NULL) {
- return false;
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
}
- GList* glist = (GList*)iterator;
- cal_value* value = (cal_value*)glist->data;
- if(value == NULL) {
- return false;
- }
- glist = _calendar_glist_next_until_not_deleted(glist);
- if(glist == NULL) {
- return false;
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_RANGE_TYPE, CALS_RANGE_UNTIL);
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_UNTIL_TYPE, CALS_TIME_UTIME);
+ ret = calendar_svc_struct_set_lli(cs,
+ CALS_VALUE_LLI_RRULE_UNTIL_UTIME, recurrence_until_date);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
}
-
- return true;
+ return CALENDAR_ERROR_NONE;
}
-int calendar_recurrence_exception_next(calendar_recurrence_exception_iterator_h *iterator, int* year, int* month, int* day)
+int calendar_event_get_start_time(calendar_event_h event, long long int *start_time)
{
- CALENDAR_NULL_ARG_CHECK(iterator);
- CALENDAR_NULL_ARG_CHECK(year);
- CALENDAR_NULL_ARG_CHECK(month);
- CALENDAR_NULL_ARG_CHECK(day);
-
- cal_value *value = NULL;
- *year = 0;
- *month = 0;
- *day = 0;
- GList* glist = (GList*)*iterator;
- glist = _calendar_glist_next_until_not_deleted(glist);
- if(glist != NULL)
- {
- value = glist->data;
- struct tm *date = calendar_svc_value_get_tm(value, CAL_VALUE_GMT_EXCEPTION_DATE_TIME, CAL_TZ_FLAG_LOCAL);
- *year = date->tm_year + 1900;
- *month = date->tm_mon + 1;
- *day = date->tm_mday;
- glist = g_list_next(glist);
- *iterator = (calendar_recurrence_exception_iterator_h)glist;
- return CALENDAR_ERROR_NONE;
- }
- *iterator = NULL;
- return CALENDAR_ERROR_ITERATOR_END;
-}
-
-int calendar_event_get_start_time(calendar_event_h event, struct tm *start_time)
-{
- time_t time;
- struct tm *tmp_date = NULL;
CALENDAR_NULL_ARG_CHECK(event);
CALENDAR_NULL_ARG_CHECK(start_time);
- time = calendar_svc_struct_get_time((cal_struct*)((calendar_event_s*)event)->event_legacy,
- CAL_VALUE_GMT_START_DATE_TIME, CAL_TZ_FLAG_LOCAL);
-
- if(time == 0) {
- LOGE("[%s] CALENDAR_ERROR_NO_DATA(0x%08x)", __FUNCTION__, CALENDAR_ERROR_NO_DATA);
- return CALENDAR_ERROR_NO_DATA;
- }
-
- tmp_date = localtime(&time);
-
- if (tmp_date == NULL) {
- LOGE("[%s] CALENDAR_ERROR_NO_DATA(0x%08x)", __FUNCTION__, CALENDAR_ERROR_NO_DATA);
- return CALENDAR_ERROR_NO_DATA;
- }
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- *start_time = *tmp_date;
+ *start_time = calendar_svc_struct_get_lli(cs, CALS_VALUE_LLI_DTSTART_UTIME);
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
-int calendar_event_set_start_time(calendar_event_h event, struct tm start_time)
-{
- int ret_val = CALENDAR_ERROR_NONE;
-
+int calendar_event_set_start_time(calendar_event_h event, long long int start_time)
+{
CALENDAR_NULL_ARG_CHECK(event);
- ret_val = calendar_svc_struct_set_time((cal_struct*)((calendar_event_s*)event)->event_legacy,
- CAL_VALUE_GMT_START_DATE_TIME, CAL_TZ_FLAG_LOCAL, mktime(&start_time));
+ int ret;
+ cal_struct *cs;
- if (ret_val != CAL_SUCCESS)
- {
- LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
- return CALENDAR_ERROR_INVALID_PARAMETER;
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
}
- return CALENDAR_ERROR_NONE;
-}
+ ret = calendar_svc_struct_set_int(cs, CALS_VALUE_INT_DTSTART_TYPE, CALS_TIME_UTIME);
+ ret = calendar_svc_struct_set_lli(cs,
+ CALS_VALUE_LLI_DTSTART_UTIME, start_time);
-int calendar_event_get_end_time(calendar_event_h event, struct tm *end_time)
-{
- time_t time;
- struct tm *tmp_date = NULL;
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+int calendar_event_get_end_time(calendar_event_h event, long long int *end_time)
+{
CALENDAR_NULL_ARG_CHECK(event);
CALENDAR_NULL_ARG_CHECK(end_time);
- time = calendar_svc_struct_get_time((cal_struct*)((calendar_event_s*)event)->event_legacy,
- CAL_VALUE_GMT_END_DATE_TIME, CAL_TZ_FLAG_LOCAL);
+ cal_struct *cs;
- if(time == 0) {
- LOGE("[%s] CALENDAR_ERROR_NO_DATA(0x%08x)", __FUNCTION__, CALENDAR_ERROR_NO_DATA);
- return CALENDAR_ERROR_NO_DATA;
- }
-
- tmp_date = localtime(&time);
-
- if (tmp_date == NULL) {
- LOGE("[%s] CALENDAR_ERROR_NO_DATA(0x%08x)", __FUNCTION__, CALENDAR_ERROR_NO_DATA);
- return CALENDAR_ERROR_NO_DATA;
- }
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
- *end_time = *tmp_date;
+ *end_time = calendar_svc_struct_get_lli(cs, CALS_VALUE_LLI_DTEND_UTIME);
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
-int calendar_event_set_end_time(calendar_event_h event, struct tm end_time)
-{
- int ret_val = CALENDAR_ERROR_NONE;
+int calendar_event_set_end_time(calendar_event_h event, long long int end_time)
+{
CALENDAR_NULL_ARG_CHECK(event);
- ret_val = calendar_svc_struct_set_time((cal_struct*)((calendar_event_s*)event)->event_legacy,
- CAL_VALUE_GMT_END_DATE_TIME, CAL_TZ_FLAG_LOCAL, mktime(&end_time));
-
- if (ret_val != CAL_SUCCESS)
- {
- LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ int ret;
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- return CALENDAR_ERROR_NONE;
+ ret = calendar_svc_struct_set_lli(cs, CALS_VALUE_LLI_DTEND_UTIME, end_time);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
}
int calendar_attendee_get_name(calendar_attendee_h attendee, char **name)
-{
+{
CALENDAR_NULL_ARG_CHECK(attendee);
CALENDAR_NULL_ARG_CHECK(name);
- *name = NULL;
*name = _calendar_safe_strdup(calendar_svc_value_get_str((cal_value*)attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME));
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
int calendar_attendee_set_name(calendar_attendee_h attendee, const char *name)
-{
- int ret_val = CALENDAR_ERROR_NONE;
+{
+ int ret = CALENDAR_ERROR_NONE;
CALENDAR_NULL_ARG_CHECK(attendee);
- ret_val = calendar_svc_value_set_str((cal_value*)attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME, name);
-
- if (ret_val != CAL_SUCCESS)
- {
- LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ ret = calendar_svc_value_set_str((cal_value*)attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME, name);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
-
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
int calendar_attendee_get_email(calendar_attendee_h attendee, char **email)
-{
+{
CALENDAR_NULL_ARG_CHECK(attendee);
CALENDAR_NULL_ARG_CHECK(email);
- *email = NULL;
- *email = _calendar_safe_strdup(calendar_svc_value_get_str((cal_value*)attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_EMAIL));
-
- return CALENDAR_ERROR_NONE;
+ *email = _calendar_safe_strdup(
+ calendar_svc_value_get_str((cal_value*)attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_EMAIL));
+
+ return CALENDAR_ERROR_NONE;
}
int calendar_attendee_set_email(calendar_attendee_h attendee, const char *email)
-{
- int ret_val = CALENDAR_ERROR_NONE;
+{
+ int ret = CALENDAR_ERROR_NONE;
CALENDAR_NULL_ARG_CHECK(attendee);
CALENDAR_NULL_ARG_CHECK(email);
- ret_val = calendar_svc_value_set_str((cal_value*)attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_EMAIL, email);
-
- if (ret_val != CAL_SUCCESS)
- {
- LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ ret = calendar_svc_value_set_str((cal_value*)attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_EMAIL, email);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
-
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
int calendar_attendee_get_phone_number(calendar_attendee_h attendee, char **phone_number)
@@ -805,27 +1750,26 @@ int calendar_attendee_get_phone_number(calendar_attendee_h attendee, char **phon
CALENDAR_NULL_ARG_CHECK(attendee);
CALENDAR_NULL_ARG_CHECK(phone_number);
- *phone_number = NULL;
*phone_number = _calendar_safe_strdup(calendar_svc_value_get_str((cal_value*)attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_NUMBER));
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
int calendar_attendee_set_phone_number(calendar_attendee_h attendee, const char *phone_number)
{
- int ret_val = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
CALENDAR_NULL_ARG_CHECK(attendee);
CALENDAR_NULL_ARG_CHECK(phone_number);
- ret_val = calendar_svc_value_set_str((cal_value*)attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_NUMBER, phone_number);
-
- if (ret_val != CAL_SUCCESS)
+ ret = calendar_svc_value_set_str((cal_value*)attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_NUMBER, phone_number);
+
+ if (ret != CAL_SUCCESS)
{
LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
int calendar_attendee_get_contact_db_id(calendar_attendee_h attendee, int *contact_db_id)
@@ -837,64 +1781,73 @@ int calendar_attendee_get_contact_db_id(calendar_attendee_h attendee, int *conta
*contact_db_id = calendar_svc_value_get_int((cal_value*)attendee, CAL_VALUE_INT_ATTENDEE_DETAIL_CT_INDEX);
if(*contact_db_id <= 0)
*contact_db_id = -1;
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
int calendar_attendee_set_contact_db_id(calendar_attendee_h attendee, int contact_db_id)
{
- int ret_val = CALENDAR_ERROR_NONE;
CALENDAR_NULL_ARG_CHECK(attendee);
-
- ret_val = calendar_svc_value_set_int((cal_value*)attendee, CAL_VALUE_INT_ATTENDEE_DETAIL_CT_INDEX, contact_db_id);
- if (ret_val != CAL_SUCCESS)
+
+ int ret;
+
+ ret = calendar_svc_value_set_int((cal_value*)attendee, CAL_VALUE_INT_ATTENDEE_DETAIL_CT_INDEX, contact_db_id);
+ if (ret != CAL_SUCCESS)
{
- LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
-
+
int calendar_event_add_attendee(calendar_event_h event, calendar_attendee_h* attendee)
{
- int ret_val = CALENDAR_ERROR_NONE;
- GList* attendee_list = NULL;
-
CALENDAR_NULL_ARG_CHECK(event);
CALENDAR_NULL_ARG_CHECK(attendee);
- *attendee = (calendar_attendee_h)calendar_svc_value_new(CAL_VALUE_LST_ATTENDEE_LIST);
+ int ret = CALENDAR_ERROR_NONE;
+ GList* attendee_list = NULL;
+ cal_struct *cs;
- if (*attendee == NULL)
- {
- LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY);
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ *attendee = (calendar_attendee_h)calendar_svc_value_new(CAL_VALUE_LST_ATTENDEE_LIST);
+ if (*attendee == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY);
return CALENDAR_ERROR_OUT_OF_MEMORY;
}
//get attendee list first
- calendar_svc_struct_get_list((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_LST_ATTENDEE_LIST, &attendee_list);
+ calendar_svc_struct_get_list(cs, CAL_VALUE_LST_ATTENDEE_LIST, &attendee_list);
attendee_list = g_list_append(attendee_list, *attendee);
- ret_val = calendar_svc_struct_store_list((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_LST_ATTENDEE_LIST, attendee_list);
-
- return CALENDAR_ERROR_NONE;
+ ret = calendar_svc_struct_store_list(cs, CAL_VALUE_LST_ATTENDEE_LIST, attendee_list);
+
+ return CALENDAR_ERROR_NONE;
}
int calendar_event_add_attendee_with_contact(calendar_event_h event, int contact_db_id, calendar_attendee_h* attendee)
{
- int ret_val = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
contact_h contact = NULL;
if(contact_get_from_db(contact_db_id, &contact) != CONTACTS_ERROR_NONE) {
LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- if((ret_val = calendar_event_add_attendee(event, attendee)) != CALENDAR_ERROR_NONE)
+ if((ret = calendar_event_add_attendee(event, attendee)) != CALENDAR_ERROR_NONE)
{
LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY);
return CALENDAR_ERROR_OUT_OF_MEMORY;
}
calendar_attendee_set_contact_db_id(*attendee, contact_db_id);
-
+
contact_name_h name = NULL;
if(contact_get_name(contact, &name) == CONTACTS_ERROR_NONE) {
char *first_name = NULL;
@@ -927,20 +1880,20 @@ int calendar_event_add_attendee_with_contact(calendar_event_h event, int contact
_calendar_safe_free(number_string);
}
}
-
+
contact_destroy(contact);
-
- return CALENDAR_ERROR_NONE;
+
+ return CALENDAR_ERROR_NONE;
}
int calendar_event_remove_attendee(calendar_event_h event, calendar_attendee_h attendee)
-{
+{
CALENDAR_NULL_ARG_CHECK(event);
CALENDAR_NULL_ARG_CHECK(attendee);
- calendar_svc_value_set_int((cal_value*)attendee, CAL_VALUE_INT_DETAIL_DELETE, 1);
-
- return CALENDAR_ERROR_NONE;
+ calendar_svc_value_set_int((cal_value*)attendee, CAL_VALUE_INT_DETAIL_DELETE, 1);
+
+ return CALENDAR_ERROR_NONE;
}
int calendar_event_get_attendee_iterator(calendar_event_h event, calendar_attendee_iterator_h *iterator)
@@ -953,11 +1906,11 @@ int calendar_event_get_attendee_iterator(calendar_event_h event, calendar_attend
//get attendee list first
calendar_svc_struct_get_list((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_LST_ATTENDEE_LIST, &attendee_list);
*iterator = (calendar_attendee_iterator_h)attendee_list;
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
bool calendar_attendee_iterator_has_next(calendar_attendee_iterator_h iterator)
-{
+{
if(iterator == NULL) {
return false;
}
@@ -976,7 +1929,7 @@ bool calendar_attendee_iterator_has_next(calendar_attendee_iterator_h iterator)
}
int calendar_attendee_iterator_next(calendar_attendee_iterator_h *iterator, calendar_attendee_h *attendee)
-{
+{
CALENDAR_NULL_ARG_CHECK(iterator);
CALENDAR_NULL_ARG_CHECK(attendee);
@@ -988,137 +1941,324 @@ int calendar_attendee_iterator_next(calendar_attendee_iterator_h *iterator, cale
*attendee = (calendar_attendee_h)(glist)->data;
glist = g_list_next(glist);
*iterator = (calendar_attendee_iterator_h)glist;
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
*iterator = NULL;
return CALENDAR_ERROR_ITERATOR_END;
}
-//Provide iterator instead of event
-int calendar_foreach_event_from_db(calendar_foreach_query_event_cb callback, void *user_data)
-{
- CALENDAR_NULL_ARG_CHECK(callback);
- return _calendar_event_foreach(callback, ALL_ACCOUNT_ID, ALL_CALENDAR_ID, user_data);
+int calendar_event_free_event_array(calendar_event_h *event_array)
+{
+ int i;
+ CALENDAR_NULL_ARG_CHECK(event_array);
+
+ for (i = 0; event_array[i]; i++) {
+ calendar_event_destroy(event_array[i]);
+ }
+ free(event_array);
+ return CALENDAR_ERROR_NONE;
}
-int calendar_query_event_by_calendar(calendar_foreach_query_event_cb callback, int calendar_db_id, void *user_data)
+int calendar_event_free_modified_event_array(pcalendar_modified_event_s *modified_event_array)
{
- CALENDAR_NULL_ARG_CHECK(callback);
- CONTACTS_INVALID_ARG_CHECK(calendar_db_id < 1);
- int account_db_id = _calendar_get_account_db_id(calendar_db_id);
- CONTACTS_INVALID_ARG_CHECK(account_db_id == -2);
-
- return _calendar_event_foreach(callback, account_db_id, calendar_db_id, user_data);
+ CALENDAR_NULL_ARG_CHECK(modified_event_array);
+
+ int i = 0;
+ pcalendar_modified_event_s *p;
+
+ p = modified_event_array;
+
+ if (p) {
+ while (p[i]) {
+ free(p[i]);
+ i++;
+ }
+ free(p);
+ }
+
+ return CALENDAR_ERROR_NONE;
}
-int calendar_query_event_by_subject(calendar_foreach_query_event_cb callback, int calendar_db_id, const char *subject_to_find, void* user_data)
+void __free_event_data(gpointer data, gpointer user_data)
{
- CALENDAR_NULL_ARG_CHECK(callback);
- CALENDAR_NULL_ARG_CHECK(subject_to_find);
- return _calendar_event_query(callback, calendar_db_id, CAL_VALUE_TXT_SUMMARY, subject_to_find, user_data);
+ if (data) {
+ calendar_event_h *event = (calendar_event_h *)data;
+ if (event) free(event);
+ }
}
-int calendar_query_event_by_description(calendar_foreach_query_event_cb callback, int calendar_db_id, const char *description_to_find, void* user_data)
+static calendar_error_e _get_h_array_from_legacy_iter(const char fn[],
+ cal_iter* iter, calendar_event_h **event_h_array, int *length)
{
- CALENDAR_NULL_ARG_CHECK(callback);
- CALENDAR_NULL_ARG_CHECK(description_to_find);
- return _calendar_event_query(callback, calendar_db_id, CAL_VALUE_TXT_DESCRIPTION, description_to_find, user_data);
+ int i;
+ int is_error = 0;
+ cal_struct *cs = NULL;
+ calendar_event_s *ce;
+ GList *cursor;
+ GList *l = NULL;
+
+ if (iter == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)",
+ fn, CALENDAR_ERROR_DB_FAILED);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ while (calendar_svc_iter_next(iter) == CAL_SUCCESS)
+ {
+ if(calendar_svc_iter_get_info(iter, &cs) != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)",
+ fn, CALENDAR_ERROR_OUT_OF_MEMORY);
+ is_error = 1;
+ break;
+ }
+
+ ce = calloc(1, sizeof(calendar_event_s));
+ if (ce == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)",
+ fn, CALENDAR_ERROR_OUT_OF_MEMORY);
+ is_error = 1;
+ }
+
+ ce->event_legacy = (calendar_event_legacy_s *)cs;
+ l = g_list_append(l, ce);
+ cs = NULL;
+ }
+ calendar_svc_iter_remove(&iter);
+
+ if (is_error) {
+ g_list_foreach(l, __free_event_data, NULL);
+ g_list_free(l);
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+
+ /* malloc array and fill data */
+ *length = g_list_length(l);
+
+ /* plus 1 to fill null pointer*/
+ calendar_event_h *p = calloc(*length + 1, sizeof(calendar_event_h));
+ if (p == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)",
+ fn,CALENDAR_ERROR_OUT_OF_MEMORY);
+ g_list_foreach(l, __free_event_data, NULL);
+ g_list_free(l);
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+
+ cursor = l;
+ for (i = 0; cursor; i++) {
+ p[i] = (calendar_event_h)cursor->data;
+ cursor = g_list_next(cursor);
+ }
+ g_list_free(l);
+
+ /* fill NULL pointer to indicate end of array */
+ p[i] = NULL;
+ *event_h_array = p;
+
+ return CALENDAR_ERROR_NONE;
}
-int calendar_query_event_by_location(calendar_foreach_query_event_cb callback, int calendar_db_id, const char *location_to_find, void* user_data)
+static calendar_error_e _get_count_from_legacy_iter(const char fn[],
+ cal_iter* iter, int *count)
{
- CALENDAR_NULL_ARG_CHECK(callback);
- CALENDAR_NULL_ARG_CHECK(location_to_find);
- return _calendar_event_query(callback, calendar_db_id, CAL_VALUE_TXT_LOCATION, location_to_find, user_data);
+ int is_error = 0;
+ cal_struct *cs = NULL;
+ calendar_event_s *ce;
+ GList *l = NULL;
+
+ if (iter == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)",
+ fn, CALENDAR_ERROR_DB_FAILED);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ while (calendar_svc_iter_next(iter) == CAL_SUCCESS)
+ {
+ if(calendar_svc_iter_get_info(iter, &cs) != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)",
+ fn, CALENDAR_ERROR_OUT_OF_MEMORY);
+ is_error = 1;
+ break;
+ }
+
+ ce = calloc(1, sizeof(calendar_event_s));
+ if (ce == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)",
+ fn, CALENDAR_ERROR_OUT_OF_MEMORY);
+ is_error = 1;
+ }
+
+ ce->event_legacy = (calendar_event_legacy_s *)cs;
+ l = g_list_append(l, ce);
+ cs = NULL;
+ }
+ calendar_svc_iter_remove(&iter);
+
+ if (is_error) {
+ g_list_foreach(l, __free_event_data, NULL);
+ g_list_free(l);
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+
+ *count = g_list_length(l);
+
+ g_list_free(l);
+
+ return CALENDAR_ERROR_NONE;
}
-int calendar_query_event_by_period(calendar_foreach_query_event_cb callback, int calendar_db_id, struct tm start_time, struct tm end_time, void* user_data)
+int calendar_event_search_event_by_calendar_book(int calendar_book_db_id, calendar_event_h **event_array, int *length)
{
- CALENDAR_NULL_ARG_CHECK(callback);
- int ret_val = 0;
- cal_iter* iter = NULL;
- bool callback_return = true;
-
- int account_id = _calendar_get_account_db_id(calendar_db_id);
- CONTACTS_INVALID_ARG_CHECK(account_id == -2);
-
- //fetch from DB
- ret_val = calendar_svc_get_event_list_by_tm_period (account_id, calendar_db_id, &start_time, &end_time, &iter);
+ CALENDAR_NULL_ARG_CHECK(event_array);
+ CALENDAR_NULL_ARG_CHECK(length);
- if (ret_val != CAL_SUCCESS) {
- LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
- return CALENDAR_ERROR_DB_FAILED;
+ int ret;
+ cal_iter *iter = NULL;
+
+ ret = calendar_svc_get_all(0, calendar_book_db_id, CAL_STRUCT_SCHEDULE, &iter);
+ if (CAL_SUCCESS != ret) {
+ LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+ return CALENDAR_ERROR_DB_FAILED;
}
-
- if (iter == NULL) {
- LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
- return CALENDAR_ERROR_DB_FAILED;
- } else {
- while (calendar_svc_iter_next(iter) == CAL_SUCCESS)
- {
- calendar_event_s cal_event_from_db = {0,};
- if(calendar_svc_iter_get_info(iter, (cal_struct**)&cal_event_from_db.event_legacy) != CAL_SUCCESS) {
- calendar_svc_iter_remove(&iter);
- return CALENDAR_ERROR_NONE; // consider this as no data
- }
-
- if(cal_event_from_db.event_legacy == NULL) {
- calendar_svc_iter_remove(&iter);
- break;
- }
-
- //execute callback
- callback_return = callback((calendar_event_h)&cal_event_from_db, user_data);
- calendar_svc_struct_free((cal_struct**)&cal_event_from_db.event_legacy);
- if(callback_return == false) {
- break;
- }
- }
- calendar_svc_iter_remove(&iter);
+ if ((ret = _get_h_array_from_legacy_iter(__FUNCTION__, iter, event_array, length))
+ != CALENDAR_ERROR_NONE)
+ return ret;
- return CALENDAR_ERROR_NONE;
- }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_search_extend_instance_by_period(int calendar_book_db_id,
+ long long int period_start_time, long long int period_end_time,
+ calendar_event_h **event_array, int *length)
+{
+ CALENDAR_NULL_ARG_CHECK(event_array);
+ CALENDAR_NULL_ARG_CHECK(length);
+
+ cal_iter *iter = NULL;
+ int ret = calendar_svc_event_get_normal_list_by_period(calendar_book_db_id,
+ CALS_LIST_PERIOD_NORMAL_OSP,
+ period_start_time, period_end_time, &iter);
+ if (CAL_SUCCESS != ret) {
+ LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ if ((ret = _get_h_array_from_legacy_iter(__FUNCTION__, iter, event_array, length))
+ != CALENDAR_ERROR_NONE)
+ return ret;
return CALENDAR_ERROR_NONE;
}
-int calendar_set_db_changed_cb(calendar_db_changed_cb callback, void* user_data)
+int calendar_event_search_all_day_extend_instance_by_period(int calendar_book_db_id,
+ int period_start_year, int period_start_month, int period_start_day,
+ int period_end_year, int period_end_month, int period_end_day,
+ calendar_event_h **event_array, int *length)
{
+ CALENDAR_NULL_ARG_CHECK(event_array);
+ CALENDAR_NULL_ARG_CHECK(length);
+
+ cal_iter *iter = NULL;
+ int ret = calendar_svc_event_get_allday_list_by_period(calendar_book_db_id, CALS_LIST_PERIOD_ALLDAY_OSP,
+ period_start_year, period_start_month, period_start_day,
+ period_end_year, period_end_month, period_end_day, &iter);
+ if (CAL_SUCCESS != ret) {
+ LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ if ((ret = _get_h_array_from_legacy_iter(__FUNCTION__, iter, event_array, length))
+ != CALENDAR_ERROR_NONE)
+ return ret;
+
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_add_db_changed_cb(calendar_db_changed_cb callback, calendar_db_changed_cb_type_e type, void* user_data)
+{
+ int ret;
CALENDAR_NULL_ARG_CHECK(callback);
- if(calendar_svc_subscribe_change(callback, user_data) == CAL_SUCCESS) {
+
+ switch(type) {
+ case CALENDAR_DB_CHANGED_CB_TYPE_CALENDAR_BOOK:
+ ret = calendar_svc_subscribe_db_change(CAL_STRUCT_CALENDAR, callback, user_data);
+ break;
+ case CALENDAR_DB_CHANGED_CB_TYPE_EVENT:
+ ret = calendar_svc_subscribe_db_change(CAL_STRUCT_SCHEDULE, callback, user_data);
+ break;
+ case CALENDAR_DB_CHANGED_CB_TYPE_TODO:
+ ret = calendar_svc_subscribe_db_change(CAL_STRUCT_TODO, callback, user_data);
+ break;
+ default:
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ break;
+ }
+
+ if(ret == CAL_SUCCESS) {
return CALENDAR_ERROR_NONE;
}
- LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
-int calendar_unset_db_changed_cb(calendar_db_changed_cb callback)
+int calendar_remove_db_changed_cb(calendar_db_changed_cb callback, calendar_db_changed_cb_type_e type)
{
+ int ret;
CALENDAR_NULL_ARG_CHECK(callback);
- if(calendar_svc_unsubscribe_change(callback) == CAL_SUCCESS) {
+
+ switch(type) {
+ case CALENDAR_DB_CHANGED_CB_TYPE_CALENDAR_BOOK:
+ ret = calendar_svc_unsubscribe_db_change(CAL_STRUCT_CALENDAR, callback);
+ break;
+ case CALENDAR_DB_CHANGED_CB_TYPE_EVENT:
+ ret = calendar_svc_unsubscribe_db_change(CAL_STRUCT_SCHEDULE, callback);
+ break;
+ case CALENDAR_DB_CHANGED_CB_TYPE_TODO:
+ ret = calendar_svc_unsubscribe_db_change(CAL_STRUCT_TODO, callback);
+ break;
+ default:
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ break;
+ }
+
+ if(ret == CAL_SUCCESS) {
return CALENDAR_ERROR_NONE;
}
- LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
-int calendar_event_get_last_modified_time(calendar_event_h event, struct tm *reviedtime)
+int calendar_get_db_version(int* calendar_db_version)
{
- struct tm *tmp_date = NULL;
+ CALENDAR_NULL_ARG_CHECK(calendar_db_version);
- CALENDAR_NULL_ARG_CHECK(event);
- CALENDAR_NULL_ARG_CHECK(reviedtime);
+ if (calendar_svc_begin_trans() != CAL_SUCCESS) {
+ LOGE("%s] CALENDAR_ERROR_NO_DATA(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+ *calendar_db_version = calendar_svc_end_trans(true);
+ return CALENDAR_ERROR_NONE;
+}
- tmp_date = calendar_svc_struct_get_tm((cal_struct*)((calendar_event_s*)event)->event_legacy,
- CAL_VALUE_GMT_LAST_MODIFIED_TIME, CAL_TZ_FLAG_LOCAL);
-
- if (tmp_date == NULL) {
- LOGE("[%s] CALENDAR_ERROR_NO_DATA(0x%08x)", __FUNCTION__, CALENDAR_ERROR_NO_DATA);
- return CALENDAR_ERROR_NO_DATA;
- }
+int calendar_event_get_last_modified_time(calendar_event_h event, long long int *modified_time)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+ CALENDAR_NULL_ARG_CHECK(modified_time);
- *reviedtime = *tmp_date;
+ *modified_time = calendar_svc_struct_get_lli((cal_struct*)((calendar_event_s*)event)->event_legacy,
+ CALS_VALUE_LLI_LASTMOD);
return CALENDAR_ERROR_NONE;
}
@@ -1128,7 +2268,7 @@ int calendar_event_get_visibility(calendar_event_h event, calendar_visibility_e
CALENDAR_NULL_ARG_CHECK(event);
CALENDAR_NULL_ARG_CHECK(visibility);
- *visibility = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)event)->event_legacy,
+ *visibility = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)event)->event_legacy,
CAL_VALUE_INT_SENSITIVITY);
return CALENDAR_ERROR_NONE;
@@ -1136,13 +2276,13 @@ int calendar_event_get_visibility(calendar_event_h event, calendar_visibility_e
int calendar_event_set_visibility(calendar_event_h event, calendar_visibility_e visibility)
{
- int ret_val = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
CALENDAR_NULL_ARG_CHECK(event);
- ret_val = calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)event)->event_legacy,
+ ret = calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)event)->event_legacy,
CAL_VALUE_INT_SENSITIVITY, visibility);
- if (ret_val != CAL_SUCCESS)
+ if (ret != CAL_SUCCESS)
{
LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
@@ -1151,54 +2291,95 @@ int calendar_event_set_visibility(calendar_event_h event, calendar_visibility_e
return CALENDAR_ERROR_NONE;
}
-int calendar_query_event_by_time_last_modified(calendar_foreach_query_event_cb callback, int calendar_db_id, struct tm time, void *user_data)
+int calendar_event_search_event_by_version(int calendar_book_db_id, int calendar_db_version,
+ pcalendar_modified_event_s **modified_event_array, int *length)
{
- CALENDAR_NULL_ARG_CHECK(callback);
- int ret_val = 0;
- cal_iter* iter = NULL;
- bool callback_return = true;
-
- int account_id = _calendar_get_account_db_id(calendar_db_id);
- CONTACTS_INVALID_ARG_CHECK(account_id == -2);
+ CALENDAR_NULL_ARG_CHECK(modified_event_array);
+ CALENDAR_NULL_ARG_CHECK(length);
- //fetch from DB
- time_t timestamp = mktime(&time);
- ret_val = calendar_svc_get_updated_event_list (account_id, timestamp, &iter);
+ int i, ret;
+ int is_error = 0;
+ GList *l = NULL;
+ GList *cursor;
+ cal_iter *iter = NULL;
+ cal_struct *cs = NULL;
+ calendar_modified_event_s *cme;
+ pcalendar_modified_event_s *p;
+ *length = 0;
- if (ret_val != CAL_SUCCESS) {
- LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+ ret = calendar_svc_event_get_changes(calendar_book_db_id, calendar_db_version, &iter);
+ if (CAL_SUCCESS != ret) {
+ LOGE("[%s] CALLENDAR_ERROR_DB_FAILED(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
return CALENDAR_ERROR_DB_FAILED;
}
-
- if (iter == NULL) {
- LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
- return CALENDAR_ERROR_DB_FAILED;
- } else {
- while (calendar_svc_iter_next(iter) == CAL_SUCCESS)
- {
- calendar_event_s cal_event_from_db = {0,};
- if(calendar_svc_iter_get_info(iter, (cal_struct**)&cal_event_from_db.event_legacy) != CAL_SUCCESS) {
- calendar_svc_iter_remove(&iter);
- return CALENDAR_ERROR_NONE; // consider this as no data
- }
-
- if(cal_event_from_db.event_legacy == NULL) {
- calendar_svc_iter_remove(&iter);
- break;
- }
-
- //execute callback
- callback_return = callback((calendar_event_h)&cal_event_from_db, user_data);
- calendar_svc_struct_free((cal_struct**)&cal_event_from_db.event_legacy);
- if(callback_return == false) {
- break;
- }
- }
- calendar_svc_iter_remove(&iter);
- return CALENDAR_ERROR_NONE;
- }
+ /* get event_db_id and append to glist */
+ while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
+ if(calendar_svc_iter_get_info(iter, &cs) != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY);
+ is_error = 1;
+ break;
+ }
+ cme = calloc(1, sizeof(calendar_modified_event_s));
+ if (cme == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY);
+ is_error = 1;
+ break;
+ }
+
+ cme->modified_status = calendar_svc_struct_get_int(cs, CALS_STRUCT_UPDATED_INT_TYPE);
+ cme->event_db_id = calendar_svc_struct_get_int(cs, CALS_STRUCT_UPDATED_INT_ID);
+ cme->calendar_db_version = calendar_svc_struct_get_int(cs,
+ CALS_STRUCT_UPDATED_INT_VERSION);
+ cme->calendar_book_db_id = calendar_svc_struct_get_int(cs,
+ CALS_STRUCT_UPDATED_INT_CALENDAR_ID);
+
+ l = g_list_append(l, cme);
+ calendar_svc_struct_free(&cs);
+ }
+ calendar_svc_iter_remove(&iter);
+
+ if (is_error) {
+ LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY);
+ g_list_free_full(l, free);
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+
+ /* if there is no data */
+ if (l == NULL) {
+ *length = 0;
+ return CALENDAR_ERROR_NONE;
+ }
+
+ /* malloc array and fill data */
+ *length = g_list_length(l);
+
+ /* plus 1 to fill null pointer*/
+ p = calloc(*length + 1, sizeof(pcalendar_modified_event_s));
+ if (p == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)",
+ __FUNCTION__,CALENDAR_ERROR_OUT_OF_MEMORY);
+ g_list_free_full(l, free);
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+
+ cursor = l;
+ for (i = 0; cursor; i++) {
+ p[i] = (calendar_modified_event_s*)(cursor->data);
+ cursor = g_list_next(cursor);
+ }
+ /* free list after allocation */
+ g_list_free(l);
+
+ /* fill NULL pointer to indicate end of array */
+ p[i] = NULL;
+
+ *modified_event_array = p;
return CALENDAR_ERROR_NONE;
}
@@ -1207,24 +2388,21 @@ int calendar_event_get_timezone(calendar_event_h event, char** timezone_name)
CALENDAR_NULL_ARG_CHECK(event);
CALENDAR_NULL_ARG_CHECK(timezone_name);
-// *timezone_offset = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)event)->event_legacy,
-// CAL_VALUE_INT_TIMEZONE);
- *timezone_name = _calendar_safe_strdup(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)event)->event_legacy,
- CAL_VALUE_TXT_TZ_NAME));
+ *timezone_name = _calendar_safe_strdup(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)event)->event_legacy,
+ CALS_VALUE_TXT_DTSTART_TZID));
return CALENDAR_ERROR_NONE;
}
int calendar_event_set_timezone(calendar_event_h event, const char* timezone_name)
{
- int ret_val = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
CALENDAR_NULL_ARG_CHECK(event);
CALENDAR_NULL_ARG_CHECK(timezone_name);
- ret_val = calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_INT_TIMEZONE, 0);
- ret_val = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)event)->event_legacy, CAL_VALUE_TXT_TZ_NAME, timezone_name);
- if (ret_val != CAL_SUCCESS)
+ ret = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)event)->event_legacy, CALS_VALUE_TXT_DTSTART_TZID, timezone_name);
+ if (ret != CAL_SUCCESS)
{
LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
@@ -1233,393 +2411,96 @@ int calendar_event_set_timezone(calendar_event_h event, const char* timezone_nam
return CALENDAR_ERROR_NONE;
}
-typedef struct _calendar_time_zone_st _calendar_time_zone_s;
-struct _calendar_time_zone_st
-{
- char* city;
- char* country;
- char* gmt;
- char* tz_path;
-};
-const _calendar_time_zone_s _calendar_time_zone_array[] =
-{
- {"Abidjan", "Ivory Coast", "GMT+0", "Africa/Abidjan"},
- {"Abu Dhabi", "United Arab Emirates", "GMT+4", "Asia/Dubai"},
- {"Accra", "Ghana", "GMT-10", "Africa/Accra"},
- {"Addis Ababa", "Ethiopia", "GMT+3", "Africa/Addis_Ababa"},
- {"Adelaide", "Australia", "GMT+9:30", "Australia/Adelaide"},
- {"Alaska", "United States of America", "GMT-9", "America/Nome"},
- {"Algiers", "Algeria", "GMT+1", "Africa/Algiers"},
- {"Almaty", "Kazakhstan", "GMT+6", "Asia/Almaty"},
- {"Ambon", "Indonesia", "GMT+1", "Asia/Jayapura"},
- {"Amman", "Jordan", "GMT+2", "Asia/Amman"},
- {"Amsterdam", "Netherlands", "GMT+1", "Europe/Amsterdam"},
- {"Anadyr", "Russia ", "GMT+12", "Asia/Anadyr"},
- {"Anchorage", "United States of America", "GMT-9", "America/Anchorage"},
- {"Ankara", "Turkey", "GMT+2", "Asia/Istanbul"},
- {"Antananarivo", "Madagascar", "GMT+3", "Indian/Antananarivo"},
- {"Ashgabat", "Turkmenistan", "GMT+5", "Asia/Ashgabat"},
- {"Asmera", "Eritrea", "GMT+3", "Africa/Asmara"/* not in zone.tab */ },
- {"Astana", "Kazakhstan", "GMT+6", "Asia/Almaty"/* not in zone.tab */ },
- {"Asuncion", "Paraguay", "GMT-4", "America/Asuncion"},
- {"Athens", "Greece", "GMT+2", "Europe/Athens"},
- {"Auckland", "New Zealand", "GMT+12", "Pacific/Auckland"},
- {"Austin", "United States of America", "GMT-6", "CST6CDT"},
- {"Azores", "Portugal", "GMT-1", "Atlantic/Azores"},
- {"Baghdad", "Iraq", "GMT+3", "Asia/Baghdad"},
- {"Baku", "Azerbaijan", "GMT+4", "Asia/Baku"},
- {"Baltimore", "United States of America", "GMT-5", "EST5EDT"},
- {"Bamako", "Mali", "GMT+0", "Africa/Bamako"},
- {"Bangkok", "Thailand", "GMT+7", "Asia/Bangkok"},
- {"Bangui", "Central African Republic", "GMT+1", "Africa/Bangui"},
- {"Barcelona", "Spain", "GMT+2", "Europe/Madrid"},
- {"Bari", "Italy", "GMT+1", "Europe/Rome"},
- {"Basse-Terre", "Guadeloupe", "GMT-4", "America/Guadeloupe"},
- {"Beijing", "China", "GMT+8", "Asia/Shanghai"},
- {"Beirut", "Lebanon", "GMT+2", "Asia/Beirut"},
- {"Belgrade", "Serbia", "GMT+1", "Europe/Belgrade"},
- {"Belize City", "Belize", "GMT-6", "America/Belize"},
- {"Berlin", "Germany", "GMT+1", "Europe/Berlin"},
- {"Bern", "Switzerland", "GMT+1", "Europe/Zurich"},
- {"Bishkek", "Kyrgyzstan", "GMT+6", "Asia/Bishkek"},
- {"Bissau", "Guinea Bissau", "GMT+0", "Africa/Bissau"},
- {"Bogota", "Colombia", "GMT-5", "America/Bogota"},
- {"Bologna", "Italy", "GMT+1", "Europe/Rome"},
- {"Boston", "United States of America", "GMT-5", "EST5EDT"},
- {"Brasilia", "Brazil", "GMT-3", "America/Sao_Paulo"},
- {"Bratislava", "Slovakia", "GMT+2", "Europe/Bratislava"},
- {"Bridgetown", "Barbados", "GMT-4", "America/Barbados"},
- {"Brisbane", "Australia", "GMT+10", "Australia/Brisbane"},
- {"Brussels", "Belgium", "GMT+1", "Europe/Brussels"},
- {"Bucharest", "Romania", "GMT+3", "Europe/Bucharest"},
- {"Budapest", "Hungary", "GMT+1", "Europe/Budapest"},
- {"Buenos Aires", "Argentina", "GMT-3", "America/Argentina/Buenos_Aires"},
- {"Cairo", "Egypt", "GMT+2", "Africa/Cairo"},
- {"Calgary", "Canada", "GMT-7", "MST7MDT"},
- {"Canary Islands", "Spain", "GMT+0", "Atlantic/Canary"},
- {"Canberra", "Australia", "GMT+10", "Australia/Canberra"},
- {"Canton", "China", "GMT+8", "Asia/Shanghai"},
- {"Cape Town", "Republic of South Africa", "GMT+2", "Africa/Johannesburg"},
- {"Caracas", "Venezuela", "GMT-4:30", "America/Caracas"},
- {"Cardiff", "Wales", "GMT+0", "Europe/London"},
- {"Casablanca", "Morocco", "GMT+0", "Africa/Casablanca"},
- {"Catanzaro", "Italy", "GMT+1", "Europe/Rome"},
- {"Cayenne", "French Guiana", "GMT-3", "America/Cayenne"},
- {"Charlotte", "United States of America", "GMT-5", "EST5EDT"},
- {"Charlotte Amalie", "United States Virgin Islands ", "GMT-5:30", "America/St_Thomas"},
- {"Chelyabinsk", "Russia ", "GMT+5", "Asia/Yekaterinburg"},
- {"Chennai", "India", "GMT+5:30", "Asia/Kolkata"},
- {"Chicago", "United States of America", "GMT-6", "America/Chicago"},
- {"Chisinau", "Moldova", "GMT+2", "Europe/Chisinau"},
- {"Chita", "Russia", "GMT+9", "Asia/Yakutsk"},
- {"Cleveland", "United States of America", "GMT-5", "EST5EDT"},
- {"Colombo", "Sri Lanka", "GMT+5:30", "Asia/Colombo"},
- {"Columbus", "United States of America", "GMT-5", "EST5EDT"},
- {"Conakry", "Guinea", "GMT+1", "Africa/Conakry"},
- {"Copenhagen", "Denmark", "GMT+1", "Europe/Copenhagen"},
- {"Cork", "Ireland", "GMT+0", "Europe/Dublin"},
- {"Crotone", "Italy", "GMT+1", "Europe/Rome"},
- {"Dakar", "Senegal", "GMT+0", "Africa/Dakar"},
- {"Dallas", "United States of America", "GMT-6", "CST6CDT"},
- {"Damascus", "Syria", "GMT+2", "Asia/Damascus"},
- {"Dar es Salaam", "Tanzania", "GMT+3", "Africa/Dar_es_Salaam"},
- {"Darwin", "Australia", "GMT+9:30", "Australia/Darwin"},
- {"Delhi", "India", "GMT+5:30", "Asia/Kolkata"},
- {"Denpasar", "Indonesia", "GMT+8", "Asia/Makassar"},
- {"Denver", "United States of America", "GMT-7", "America/Denver"},
- {"Detroit", "United States of America", "GMT-5", "America/Detroit"},
- {"Dhaka", "Bangladesh", "GMT+6", "Asia/Dhaka"},
- {"Diego Garcia", "United Kingdom", "GMT+5", "Indian/Chagos"/* not in zone.tab */ },
- {"Djibouti", "Djibouti", "GMT+3", "Africa/Djibouti"},
- {"Doha", "Qatar", "GMT+3", "Asia/Qatar"},
- {"Douala", "Cameroon", "GMT+1", "Africa/Douala"},
- {"Dubai", "United Arab Emirates", "GMT+4", "Asia/Dubai"},
- {"Dublin", "Ireland", "GMT+0", "Europe/Dublin"},
- {"Dushanbe", "Tajikistan", "GMT+5", "Asia/Dushanbe"},
- {"Easter Island", "Chile", "GMT-6", "Pacific/Easter"},
- {"Edinburgh", "Scotland", "GMT+0", "Europe/London"},
- {"El Paso", "United States of America", "GMT-7", "MST7MDT"},
- {"Florence", "Italy", "GMT+1", "Europe/Rome"},
- {"Fort-de-France", "Martinique", "GMT-4", "America/Martinique"},
- {"Freetown", "Sierra Leone", "GMT+0", "Africa/Freetown"},
- {"Gaborone", "Botswana", "GMT+2", "Africa/Gaborone"},
- {"Galapagos Islands", "Ecuador", "GMT-7", "Pacific/Galapagos"},
- {"Geneva", "Switzerland", "GMT+1", "Europe/Paris"},
- {"Genoa", "Italy", "GMT+1", "Europe/Rome"},
- {"Georgetown", "Guyana", "GMT-4", "America/Guyana"},
- {"Grytviken", "South Georgia", "GMT-2", "Atlantic/South_Georgia"},
- {"Guam", "United States of America", "GMT+10", "Pacific/Guam"},
- {"Guatemala City", "Guatemala", "GMT-6", "America/Guatemala"},
- {"Gustavia", "Saint Barthelemy", "GMT-4", "America/Antigua"},
- {"Halifax", "Canada", "GMT-4", "America/Halifax"},
- {"Hamburg", "Germany", "GMT+1", "Europe/Berlin"},
- {"Hanoi", "Vietnam", "GMT+7", "Asia/Ho_Chi_Minh"},
- {"Harare", "Zimbabwe", "GMT+2", "Africa/Harare"},
- {"Havana", "Cuba", "GMT-5", "America/Havana"},
- {"Hawaii", "United States of America", "GMT-10", "Pacific/Honolulu"},
- {"Helsinki", "Finland", "GMT+2", "Europe/Helsinki"},
- {"Hobart", "Australia", "GMT+10", "Australia/Hobart"},
- {"Hong Kong", "China", "GMT+8", "Asia/Hong_Kong"},
- {"Honolulu", "United States of America", "GMT-10", "Pacific/Honolulu"},
- {"Houston", "United States of America", "GMT-6", "CST6CDT"},
- {"Hovd", "Mongolia", "GMT+8", "Asia/Hovd"},
- {"Indianapolis", "United States of America", "GMT-5", "America/Indiana/Indianapolis"},
- {"Irkutsk", "Russia ", "GMT+8", "Asia/Irkutsk"},
- {"Islamabad", "Pakistan", "GMT+5", "Asia/Karachi"},
- {"Istanbul", "Turkey", "GMT+2", "Europe/Istanbul"},
- {"Izhevsk", "Russia ", "GMT+4", "Europe/Moscow"},
- {"Jakarta", "Indonesia", "GMT+7", "Asia/Jakarta"},
- {"Jeddah", "Saudi Arabia", "GMT+3", "Asia/Riyadh"},
- {"Jerusalem", "Israel", "GMT+2", "Asia/Jerusalem"},
- {"Johannesburg", "South Africa", "GMT+2", "Africa/Johannesburg"},
- {"Kabul", "Afghanistan", "GMT+4:30", "Asia/Kabul"},
- {"Kaliningrad", "Russia", "GMT+2", "Europe/Kaliningrad"},
- {"Kamchatka", "Russia ", "GMT+12", "Asia/Kamchatka"},
- {"Kampala", "Uganda", "GMT+3", "Africa/Kampala"},
- {"Karachi", "Pakistan", "GMT+5", "Asia/Karachi"},
- {"Kathmandu", "Nepal", "GMT+5:45", "Asia/Kathmandu"},
- {"Khabarovsk", "Russia ", "GMT+10", "Asia/Vladivostok"},
- {"Kharkiv", "Ukraine", "GMT+2", "Europe/Kiev"},
- {"Khartoum", "Sudan", "GMT+3", "Africa/Khartoum"},
- {"Kiev", "Ukraine", "GMT+2", "Europe/Kiev"},
- {"Kingston", "Canada", "GMT-5", "America/Toronto"}, /* not in zone.tab */
- {"Kingston", "Jamaica", "GMT-5", "America/Jamaica"},
- {"Kinshasa", "Democratic Republic of the Congo", "GMT+1", "Africa/Kinshasa"},
- {"Kolkata", "India", "GMT+5:30", "Asia/Kolkata"},
- {"Krasnoyarsk", "Russia ", "GMT+7", "Asia/Krasnoyarsk"},
- {"Kuala Lumpur", "Malaysia", "GMT+8", "Asia/Kuala_Lumpur"},
- {"Kuwait", "Kuwait", "GMT+3", "Asia/Kuwait"},
- {"Kyiv", "Ukraine", "GMT+2", "Europe/Kiev"/* not in zone.tab */ },
- {"Los Angeles", "United States of America", "GMT-7", "America/Los_Angeles"},
- {"La Paz", "Bolivia", "GMT-4", "America/La_Paz"},
- {"Lagos", "Nigeria", "GMT+1", "Africa/Lagos"},
- {"Las Vegas", "United States of America", "GMT-8", "PST8PDT"},
- {"Lima", "Peru", "GMT-5", "America/Lima"},
- {"Lisbon", "Portugal", "GMT+0", "Europe/Lisbon"},
- {"Ljubljana", "Slovakia", "GMT+1", "Europe/Ljubljana"},
- {"London", "United Kingdom", "GMT+0", "Europe/London"},
- {"Longhua", "China", "GMT+8", "Asia/Shanghai"},
- {"Louisville", "United States of America", "GMT-5", "America/Kentucky/Louisville"},
- {"Luanda", "Angola", "GMT+1", "Africa/Luanda"},
- {"Lubumbashi", "Democratic Republic of the Congo", "GMT+2", "Africa/Lubumbashi"},
- {"Lusaka", "Zambia", "GMT+2", "Africa/Lusaka"},
- {"Luxembourg", "Luxembourg", "GMT+1", "Europe/Luxembourg"},
- {"Lviv", "Ukraine", "GMT+2", "Europe/Kiev"},
- {"Macau", "China", "GMT+8", "Asia/Macau"},
- {"Madrid", "Spain", "GMT+2", "Europe/Madrid"},
- {"Magadan", "Russia ", "GMT+11", "Asia/Magadan"},
- {"Malabo", "Equaorial Guinea", "GMT+1", "Africa/Malabo"},
- {"Male", "Maldives", "GMT+5", "Indian/Maldives"},
- {"Managua", "Nicaragua", "GMT-6", "America/Managua"},
- {"Manama", "Bahrain", "GMT+3", "Asia/Bahrain"},
- {"Manila", "Philippines", "GMT+8", "Asia/Manila"},
- {"Maputo", "Mozambique", "GMT+2", "Africa/Maputo"},
- {"Marigot", "Saint Martin", "GMT-4", "America/Marigot"},
- {"Mazatlan", "Mexico", "GMT-7", "America/Mazatlan"},
- {"Mecca", "Saudi Arabia", "GMT+3", "Asia/Riyadh"},
- {"Melbourne", "Australia", "GMT+10", "Australia/Melbourne"},
- {"Memphis", "United States of America", "GMT-6", "CST6CDT"},
- {"Messina", "Italy", "GMT+1", "Europe/Rome"},
- {"Mexico City", "Mexico", "GMT-6", "America/Mexico_City"},
- {"Miami", "United States of America", "GMT-5", "EST5EDT"},
- {"Mid-Atlantic", "United States of America", "GMT-2", "America/New_York"/* not in zone.tab */ },
- {"Midway Atoll", "United States of America", "GMT-11", "Pacific/Midway"},
- {"Milan", "Italy", "GMT+1", "Europe/Rome"},
- {"Milwaukee", "United States of America", "GMT-6", "CST6CDT"},
- {"Minsk", "Belarus", "GMT+2", "Europe/Minsk"},
- {"Mogadishu", "Somalia", "GMT+2", "Africa/Mogadishu"},
- {"Monrovia", "Liberia", "GMT+0", "Africa/Monrovia"},
- {"Montevideo", "Uruguay", "GMT-3", "America/Montevideo"},
- {"Montreal", "Canada", "GMT-5", "America/Montreal"},
- {"Moscow", "Russia ", "GMT+3", "Europe/Moscow"},
- {"Mumbai", "India", "GMT+5:30", "Asia/Kolkata"},
- {"Munich", "Germany", "GMT+1", "Europe/Berlin"},
- {"Muscat", "Oman", "GMT+4", "Asia/Muscat"},
- {"Nairobi", "Kenya", "GMT+3", "Africa/Nairobi"},
- {"Naples", "Italy", "GMT+1", "Europe/Rome"},
- {"Naters", "Switzerland", "GMT+1", "Europe/Zurich"},
- {"Ndjamena", "Chad", "GMT+1", "Africa/Ndjamena"},
- {"New Delhi", "India", "GMT+5:30", "Asia/Kolkata"/* not in zone.tab */ },
- {"New York", "United States of America", "GMT-4", "America/New_York"},
- {"Newfoundland", "Canada", "GMT-3:30", "America/St_Johns"},
- {"Niamey", "Niger", "GMT+1", "Africa/Niamey"},
- {"Nouakchott", "Mauritania", "GMT+1", "Africa/Nouakchott"},
- {"Noumea", "New Caledonia", "GMT+11", "Pacific/Noumea"},
- {"Novokuznetsk", "Russia", "GMT+7", "Asia/Novokuznetsk"},
- {"Novosibirsk", "Russia", "GMT+6", "Asia/Novosibirsk"},
- {"Nuku'alofa", "Tonga", "GMT+13", "Pacific/Tongatapu"},
- {"Nuuk", "Greenland", "GMT-3", "America/Godthab"},
- {"Omsk", "Russia", "GMT+6", "Asia/Omsk"},
- {"Osaka", "Japan", "GMT+9", "Asia/Tokyo"},
- {"Ottawa", "Canada", "GMT-5", "EST5EDT"},
- {"Ouagadougou", "Burkina Faso", "GMT+0", "Africa/Ouagadougou"},
- {"Pago Pago", "Independent State of Samoa", "GMT-11", "Pacific/Pago_Pago"},
- {"Palermo", "Italy", "GMT+1", "Europe/Rome"},
- {"Panama City", "Panama", "GMT-6", "America/Panama"},
- {"Paramaribo", "Surinam", "GMT-3", "America/Paramaribo"},
- {"Paris", "France", "GMT+1", "Europe/Paris"},
- {"Perm", "Russia", "GMT+5", "Asia/Yekaterinburg"},
- {"Perth", "Australia", "GMT+8", "Australia/Perth"},
- {"Petropavlovsk-Kamchatskiy", "Russia ", "GMT+12", "Asia/Kamchatka"},
- {"Philadelphia", "United States of America", "GMT-5", "EST5EDT"},
- {"Phnom Penh ", "Cambodia", "GMT-5", "Asia/Phnom_Penh"},
- {"Phoenix", "United States of America", "GMT-7", "America/Phoenix"},
- {"Podgorica", "Montenegro", "GMT+1", "Europe/Podgorica"},
- {"Ponta Delgada", "Portugal", "GMT-1", "Atlantic/Azores"},
- {"Port Louis", "Mauritius", "GMT+4", "Indian/Mauritius"},
- {"Port-au-Prince", "Haiti", "GMT-5", "America/Port-au-Prince"},
- {"Portland", "United States of America", "GMT-8", "PST8PDT"},
- {"Prague", "Czech Republic", "GMT+1", "Europe/Prague"},
- {"Pyongyang", "North Korea", "GMT+9", "Asia/Pyongyang"},
- {"Quito", "Ecuador", "GMT-5", "America/Guayaquil"},
- {"Rabat", "Morocco", "GMT+0", "Africa/Casablanca"},
- {"Rangoon", "Burma", "GMT+6:30", "Asia/Rangoon"},
- {"Recife", "Brazil", "GMT-3", "America/Recife"},
- {"Regina", "Canada", "GMT-6", "America/Regina"},
- {"Reykjavik", "Iceland", "GMT+0", "Atlantic/Reykjavik"},
- {"Riga", "Latvia", "GMT+2", "Europe/Riga"},
- {"Rio de Janeiro", "Brazil", "GMT-2", "America/Sao_Paulo"},
- {"Riyadh", "Saudi Arabia", "GMT+3", "Asia/Riyadh"},
- {"Rome", "Italy", "GMT+1", "Europe/Rome"},
- {"Saint-Denis", "Reunion Island", "GMT+4", "Indian/Reunion"},
- {"Samara", "Russia ", "GMT+4", "Europe/Samara"},
- {"San Antonio", "United States of America", "GMT-6", "CST6CDT"},
- {"San Diego", "United States of America", "GMT-8", "PST8PDT"},
- {"San Francisco", "United States of America", "GMT-8", "America/Los_Angeles"},
- {"San Jose", "United States of America", "GMT-8", "PST8PDT"},
- {"San Jose", "Costa Rica", "GMT-6", "America/Costa_Rica"},
- {"San Juan", "Puerto Rico", "GMT-4", "America/Puerto_Rico"},
- {"San Marino", "Italy", "GMT+1", "Europe/San_Marino"},
- {"San Salvador", "El Salvador", "GMT-6", "America/El_Salvador"},
- {"Sanaa", "Yemen", "GMT+3", "Asia/Aden"/* not in zone.tab */ },
- {"Santiago", "Chile", "GMT-4", "America/Santiago"},
- {"Santo Domingo", "Dominican Republic", "GMT-4", "America/Santo_Domingo"},
- {"Sao Paulo", "Brazil", "GMT-2", "America/Sao_Paulo"},
- {"Seattle", "United States of America", "GMT-8", "PST8PDT"},
- {"Seoul", "Republic of Korea", "GMT+9", "Asia/Seoul"},
- {"Shanghai", "China", "GMT+8", "Asia/Shanghai"},
- {"Shenzhen", "China", "GMT+8", "Asia/Shanghai"},
- {"Singapore", "Republic of Singapore", "GMT+8", "Asia/Singapore"},
- {"Skopje", "Macedonia", "GMT+1", "Europe/Skopje"},
- {"Sofia ", "Bulgaria", "GMT+3", "Europe/Sofia"},
- {"St. John's", "Antigua and Barbuda", "GMT-4", "America/Antigua"},
- {"St. John's", "Canada", "GMT-3:30", "America/St_Johns"},
- {"St. Petersburg", "Russia", "GMT+3", "Europe/Moscow"},
- {"Stockholm", "Sweden", "GMT+2", "Europe/Stockholm"},
- {"Suva", "Fiji", "GMT+12", "Pacific/Fiji"},
- {"Sydney", "Australia", "GMT+11", "Australia/Sydney"},
- {"Tahiti", "French Polynesia", "GMT-10", "Pacific/Tahiti"},
- {"Taipei", "Taiwan", "GMT+8", "Asia/Taipei"},
- {"Tallinn", "Estonia", "GMT+2", "Europe/Tallinn"},
- {"Tarawa", "Kiribati", "GMT+12", "Pacific/Tarawa"},
- {"Tashkent", "Uzbekistan", "GMT+5", "Asia/Tashkent"},
- {"Tbilisi", "Georgia", "GMT+4", "Asia/Tbilisi"},
- {"Tegucigalpa", "Honduras", "GMT-6", "America/Tegucigalpa"},
- {"Tehran", "Iran", "GMT+3:30", "Asia/Tehran"},
- {"Thanh Pho Ho Chi Minh", "Vietnam", "GMT+7", "Asia/Ho_Chi_Minh"},
- {"The Settlement", "British Virgin Islands ", "GMT-4", "America/Tortola"},
- {"Tientsin", "China", "GMT+8", "Asia/Shanghai"/* not in zone.tab */ },
- {"Tijuana", "Mexico", "GMT-5", "America/Tijuana"},
- {"Tokyo", "Japan", "GMT+9", "Asia/Tokyo"},
- {"Toronto", "Canada", "GMT-4", "America/Toronto"},
- {"Trehet", "France", "GMT+1", "Europe/Paris"/* not in zone.tab */ },
- {"Tripoli", "Libya", "GMT+2", "Africa/Tripoli"},
- {"Tunis", "Tunisia", "GMT+2", "Africa/Tunis"},
- {"Turin", "Italy", "GMT+1", "Europe/Rome"},
- {"Ufa", "Bashkiriya", "GMT+5", "Asia/Yekaterinburg"},
- {"Ulan Bator", "Mongolia", "GMT+8", "Asia/Ulan_Bator"},
- {"Vaduz", "Liechtenstein", "GMT+1", "Europe/Vaduz"},
- {"Valletta", "Malta", "GMT+1", "Europe/Malta"},
- {"Vancouver", "Canada", "GMT-8", "America/Vancouver"},
- {"Verona", "Italy", "GMT+1", "Europe/Rome"},
- {"Victoria", "Seychelles", "GMT+4", "Australia/Melbourne"},
- {"Vienna", "Austria", "GMT+1", "Europe/Vienna"},
- {"Vilnius", "Lithuania", "GMT+3", "Europe/Vilnius"},
- {"Vladivostok", "Russia ", "GMT+10", "Asia/Vladivostok"},
- {"Volgograd", "Russia ", "GMT+4", "Europe/Volgograd"},
- {"Warsaw", "Poland", "GMT+2", "Europe/Warsaw"},
- {"Washington, D.C.", "United States of America", "GMT-5", "EST5EDT"},
- {"Wellington", "New Zealand", "GMT+12", "Pacific/Auckland"},
- {"Winnipeg", "Canada", "GMT-5", "America/Winnipeg"},
- {"Yakutsk", "Russia ", "GMT+9", "Asia/Yakutsk"},
- {"Yamoussoukro", "Ivory Coast", "GMT+0", "Africa/Abidjan"},
- {"Yaounde", "Cameroon", "GMT+1", "Africa/Douala"/* not in zone.tab */ },
- {"Yekaterinburg", "Russia ", "GMT+5", "Asia/Yekaterinburg"},
- {"Yerevan", "Armenia", "GMT+5", "Asia/Yerevan"},
- {"Yuzhno-Sakhalinsk", "Russia ", "GMT+11", "Asia/Sakhalin"},
- {"Zagreb", "Croatia", "GMT+1", "Europe/Zagreb"},
- {"Zurich", "Switzerland", "GMT+1", "Europe/Zurich"},
- {NULL, NULL, NULL, NULL}
-};
-
-#define _calendar_timezone_dumpfile_path "/opt/share/zoneinfo/"
-
-int calendar_foreach_timezone(calendar_foreach_timezone_cb callback, void* user_data)
+int calendar_event_get_event_array_from_vcalendar(const char *vcalendar_stream, calendar_event_h **event_array, int *length)
{
- CALENDAR_NULL_ARG_CHECK(callback);
-
- int i = 0;
- char temp_filepath[256]; // normal char definition
- while(_calendar_time_zone_array[i].city != NULL)
- {
- calendar_foreach_timezone_s timezone;
- timezone.timezone_name = _calendar_safe_strdup(_calendar_time_zone_array[i].tz_path);
- timezone.city_name = _calendar_safe_strdup(_calendar_time_zone_array[i].city);
- timezone.country_name = _calendar_safe_strdup(_calendar_time_zone_array[i].country);
- timezone.time_offset = _calendar_safe_strdup(_calendar_time_zone_array[i].gmt);
- // all structure members has proper string value.
- snprintf(temp_filepath, sizeof(temp_filepath), "%s%s",
- _calendar_timezone_dumpfile_path, _calendar_time_zone_array[i].tz_path); // proper snprintf
- timezone.timezone_detail_filepath = _calendar_safe_strdup(temp_filepath);
-
- bool callback_return = callback(&timezone, user_data);
-
- _calendar_safe_free(timezone.timezone_name);
- _calendar_safe_free(timezone.city_name);
- _calendar_safe_free(timezone.country_name);
- _calendar_safe_free(timezone.time_offset);
- _calendar_safe_free(timezone.timezone_detail_filepath);
-
- if(callback_return == false)
- break;
-
- i++;
+ CALENDAR_NULL_ARG_CHECK(event_array);
+ CALENDAR_NULL_ARG_CHECK(vcalendar_stream);
+
+ int i, ret;
+ GList *schedules = NULL;
+ GList *cursor;
+ calendar_event_s *ces;
+ calendar_event_h *ceh;
+
+ ret = calendar_svc_read_schedules(vcalendar_stream, &schedules);
+ if (CAL_SUCCESS != ret) {
+ LOGE("[%s] CALENDAR_ERROR_READ_SCHEDULES(errno:%d)\n",
+ __FUNCTION__, ret);
+ return CALENDAR_ERROR_DB_FAILED;
}
- return CALENDAR_ERROR_NONE;
-}
+ if (schedules == NULL) {
+ LOGW("[%s] CALENDAR_ERROR_NO_SCHEDULES", __FUNCTION__);
+ *event_array = NULL;
+ *length = 0;
+ return CALENDAR_ERROR_NONE;
+ }
-int calendar_event_get_from_vcalendar(const char *vcalendar_stream, calendar_event_h *event)
-{
- CALENDAR_NULL_ARG_CHECK(event);
- CALENDAR_NULL_ARG_CHECK(vcalendar_stream);
- *event = malloc(sizeof(calendar_event_s));
- if (*event == NULL) {
- LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY);
+ *length = g_list_length(schedules);
+
+ ceh = calloc(*length + 1, sizeof(calendar_event_h));
+ if (ceh == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY);
+ g_list_free(schedules);
return CALENDAR_ERROR_OUT_OF_MEMORY;
}
- memset(*event, 0, sizeof(calendar_event_s));
- if(calendar_svc_util_convert_vcs_to_event(vcalendar_stream, 0, (cal_struct**)&(*(calendar_event_s**)event)->event_legacy) != CAL_SUCCESS) {
- free(*event);
- *event = NULL;
+ /* allocate list to array */
+ cursor = schedules;
+ for (i = 0; cursor; i++) {
+ ces = calloc(1, sizeof(calendar_event_s));
+ if (ces == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY);
+ break;
+ }
- LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
- return CALENDAR_ERROR_INVALID_PARAMETER;
+ ceh[i] = (calendar_event_h)ces;
+ ces->event_legacy = (calendar_event_legacy_s *)cursor->data;
+ cursor = g_list_next(cursor);
}
+ g_list_free(schedules);
+
+ ceh[i] = NULL;
+
+ *event_array = ceh;
return CALENDAR_ERROR_NONE;
}
-int calendar_event_get_vcalendar_from_event(calendar_event_h event, char **vcalendar_stream)
+int calendar_event_get_vcalendar_from_db(int *event_db_id_array, int length, char **vcalendar_stream)
{
- CALENDAR_NULL_ARG_CHECK(event);
+ CALENDAR_NULL_ARG_CHECK(event_db_id_array);
CALENDAR_NULL_ARG_CHECK(vcalendar_stream);
- if(calendar_svc_util_convert_event_to_vcs((cal_struct*)((calendar_event_s*)event)->event_legacy,
- vcalendar_stream, NULL) != CAL_SUCCESS) {
- LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
- return CALENDAR_ERROR_INVALID_PARAMETER;
+ int i, ret;
+ GList *schedules = NULL;
+ cal_struct *cs = NULL;
+
+ if (length < 1) {
+ LOGD("[%s] EVENT_DB_LENGTH is 0", __FUNCTION__);
+ return CALENDAR_ERROR_NONE;
+ }
+
+ for (i = 0; i < length; i++) {
+ ret = calendar_svc_get(CAL_STRUCT_SCHEDULE, event_db_id_array[i], NULL, &cs);
+ if (CAL_SUCCESS != ret) {
+ LOGE("[%s] CALENDAR_ERROR_GET_EVENT(errno:%d)", __FUNCTION__, ret);
+ break;
+ }
+ if (cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_GET_EVENT", __FUNCTION__);
+ break;
+ }
+ schedules = g_list_append(schedules, cs);
}
+
+ ret = calendar_svc_write_schedules(schedules, vcalendar_stream);
+ if (CAL_SUCCESS != ret) {
+ LOGE("[%s] CALENDAR_ERROR_WRITE_SCHEDDULES", __FUNCTION__);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
return CALENDAR_ERROR_NONE;
}
@@ -1642,28 +2523,27 @@ int calendar_todo_create(calendar_todo_h *todo)
LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY);
return CALENDAR_ERROR_OUT_OF_MEMORY;
}
- calendar_svc_struct_set_int((cal_struct*)(*(calendar_event_s**)todo)->event_legacy, CAL_VALUE_INT_TIMEZONE, 100); // set default timezone
return CALENDAR_ERROR_NONE;
}
int calendar_todo_destroy(calendar_todo_h todo)
{
- int ret_val = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
CALENDAR_NULL_ARG_CHECK(todo);
- ret_val = calendar_svc_struct_free((cal_struct **)&((calendar_event_s*)todo)->event_legacy);
-
- if (ret_val != CAL_SUCCESS)
+ ret = calendar_svc_struct_free((cal_struct **)&((calendar_event_s*)todo)->event_legacy);
+
+ if (ret != CAL_SUCCESS)
{
LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
- ret_val = CALENDAR_ERROR_INVALID_PARAMETER;
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
} else {
free(todo);
- ret_val = CALENDAR_ERROR_NONE;
+ ret = CALENDAR_ERROR_NONE;
}
- return ret_val;
+ return ret;
}
int calendar_todo_get_db_id(calendar_todo_h todo, int *db_id)
@@ -1678,12 +2558,12 @@ int calendar_todo_get_db_id(calendar_todo_h todo, int *db_id)
return CALENDAR_ERROR_NONE;
}
-int calendar_todo_get_calendar_db_id(calendar_todo_h todo, int *calendar_db_id)
+int calendar_todo_get_calendar_book_db_id(calendar_todo_h todo, int *calendar_db_id)
{
CALENDAR_NULL_ARG_CHECK(todo);
CALENDAR_NULL_ARG_CHECK(calendar_db_id);
- *calendar_db_id = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)todo)->event_legacy,
+ *calendar_db_id = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)todo)->event_legacy,
(char*)CAL_VALUE_INT_CALENDAR_ID);
if(*calendar_db_id < 0)
*calendar_db_id = 0;
@@ -1695,21 +2575,21 @@ int calendar_todo_insert_to_db(calendar_todo_h todo, int calendar_db_id, int *to
CALENDAR_NULL_ARG_CHECK(todo);
CALENDAR_NULL_ARG_CHECK(todo_id);
- int ret_val = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
int account_db_id = _calendar_get_account_db_id(calendar_db_id);
- CONTACTS_INVALID_ARG_CHECK(account_db_id == -2);
+ CALENDAR_INVALID_ARG_CHECK(account_db_id == -2);
calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_INT_CALENDAR_ID, calendar_db_id);
calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_INT_ACCOUNT_ID, account_db_id);
-
- ret_val = calendar_svc_insert((cal_struct*)((calendar_event_s*)todo)->event_legacy);
- if (ret_val < 0)
+
+ ret = calendar_svc_insert((cal_struct*)((calendar_event_s*)todo)->event_legacy);
+ if (ret < 0)
{
LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
return CALENDAR_ERROR_DB_FAILED;
}
- *todo_id = ret_val;
+ *todo_id = ret;
return CALENDAR_ERROR_NONE;
}
@@ -1719,25 +2599,25 @@ int calendar_todo_delete_from_db(int todo_id)
LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
-
- int ret_val = CALENDAR_ERROR_NONE;
-
- ret_val = calendar_svc_delete(CAL_STRUCT_TODO, todo_id);
-
- if (ret_val == CAL_SUCCESS) {
- ret_val = CALENDAR_ERROR_NONE;
- }
- else {
+
+ int ret = CALENDAR_ERROR_NONE;
+
+ ret = calendar_svc_delete(CAL_STRUCT_TODO, todo_id);
+
+ if (ret == CAL_SUCCESS) {
+ ret = CALENDAR_ERROR_NONE;
+ }
+ else {
LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
- ret_val = CALENDAR_ERROR_DB_FAILED;
- }
+ ret = CALENDAR_ERROR_DB_FAILED;
+ }
- return ret_val;
+ return ret;
}
int calendar_todo_update_to_db(calendar_todo_h todo)
{
- int ret_val = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
CALENDAR_NULL_ARG_CHECK(todo);
if((cal_struct*)((calendar_event_s*)todo)->event_legacy == NULL) {
@@ -1745,9 +2625,9 @@ int calendar_todo_update_to_db(calendar_todo_h todo)
return CALENDAR_ERROR_NO_DATA;
}
- ret_val = calendar_svc_update((cal_struct*)((calendar_event_s*)todo)->event_legacy);
+ ret = calendar_svc_update((cal_struct*)((calendar_event_s*)todo)->event_legacy);
- if (ret_val != CAL_SUCCESS) {
+ if (ret != CAL_SUCCESS) {
LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
return CALENDAR_ERROR_DB_FAILED;
}
@@ -1780,7 +2660,7 @@ int calendar_todo_get_priority(calendar_todo_h todo, calendar_todo_priority_e *p
CALENDAR_NULL_ARG_CHECK(todo);
CALENDAR_NULL_ARG_CHECK(priority);
- *priority = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)todo)->event_legacy,
+ *priority = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)todo)->event_legacy,
CAL_VALUE_INT_PRIORITY);
return CALENDAR_ERROR_NONE;
@@ -1788,13 +2668,13 @@ int calendar_todo_get_priority(calendar_todo_h todo, calendar_todo_priority_e *p
int calendar_todo_set_priority(calendar_todo_h todo, calendar_todo_priority_e priority)
{
- int ret_val = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
CALENDAR_NULL_ARG_CHECK(todo);
- ret_val = calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)todo)->event_legacy,
+ ret = calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)todo)->event_legacy,
CAL_VALUE_INT_PRIORITY, priority);
- if (ret_val != CAL_SUCCESS) {
+ if (ret != CAL_SUCCESS) {
LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
@@ -1807,58 +2687,21 @@ int calendar_todo_get_status(calendar_todo_h todo, calendar_todo_status_e *statu
CALENDAR_NULL_ARG_CHECK(todo);
CALENDAR_NULL_ARG_CHECK(status);
- int legacy_status = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)todo)->event_legacy,
+ *status = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)todo)->event_legacy,
CAL_VALUE_INT_TASK_STATUS);
- switch(legacy_status) {
- case CALS_TODO_STATUS_NEEDS_ACTION:
- *status = CALENDAR_TODO_STATUS_NEEDS_ACTION;
- break;
- case CALS_TODO_STATUS_COMPLETED:
- *status = CALENDAR_TODO_STATUS_COMPLETED;
- break;
- case CALS_TODO_STATUS_IN_PROCESS:
- *status = CALENDAR_TODO_STATUS_IN_PROCESS;
- break;
- case CALS_TODO_STATUS_CANCELLED:
- *status = CALENDAR_TODO_STATUS_CANCELED;
- break;
- default:
- *status = CALENDAR_TODO_STATUS_NONE;
- break;
- }
-
return CALENDAR_ERROR_NONE;
}
int calendar_todo_set_status(calendar_todo_h todo, calendar_todo_status_e status)
{
- int ret_val = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
CALENDAR_NULL_ARG_CHECK(todo);
- int legacy_status = CALS_STATUS_NONE;
- switch(status) {
- case CALENDAR_TODO_STATUS_NEEDS_ACTION:
- legacy_status = CALS_TODO_STATUS_NEEDS_ACTION;
- break;
- case CALENDAR_TODO_STATUS_COMPLETED:
- legacy_status = CALS_TODO_STATUS_COMPLETED;
- break;
- case CALENDAR_TODO_STATUS_IN_PROCESS:
- legacy_status = CALS_TODO_STATUS_IN_PROCESS;
- break;
- case CALENDAR_TODO_STATUS_CANCELED:
- legacy_status = CALS_TODO_STATUS_CANCELLED;
- break;
- default:
- legacy_status = CALENDAR_TODO_STATUS_NONE;
- break;
- }
-
- ret_val = calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)todo)->event_legacy,
- CAL_VALUE_INT_TASK_STATUS, legacy_status);
- if (ret_val != CAL_SUCCESS) {
+ ret = calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)todo)->event_legacy,
+ CAL_VALUE_INT_TASK_STATUS, status);
+ if (ret != CAL_SUCCESS) {
LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
@@ -1871,7 +2714,7 @@ int calendar_todo_get_visibility(calendar_todo_h todo, calendar_visibility_e *vi
CALENDAR_NULL_ARG_CHECK(todo);
CALENDAR_NULL_ARG_CHECK(visibility);
- *visibility = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)todo)->event_legacy,
+ *visibility = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)todo)->event_legacy,
CAL_VALUE_INT_SENSITIVITY);
return CALENDAR_ERROR_NONE;
@@ -1879,13 +2722,13 @@ int calendar_todo_get_visibility(calendar_todo_h todo, calendar_visibility_e *vi
int calendar_todo_set_visibility(calendar_todo_h todo, calendar_visibility_e visibility)
{
- int ret_val = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
CALENDAR_NULL_ARG_CHECK(todo);
- ret_val = calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)todo)->event_legacy,
+ ret = calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)todo)->event_legacy,
CAL_VALUE_INT_SENSITIVITY, visibility);
- if (ret_val != CAL_SUCCESS) {
+ if (ret != CAL_SUCCESS) {
LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
@@ -1901,17 +2744,43 @@ int calendar_todo_get_subject(calendar_todo_h todo, char **subject)
*subject = NULL;
*subject = _calendar_safe_strdup(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_TXT_SUMMARY));
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
int calendar_todo_set_subject(calendar_todo_h todo, const char *subject)
{
- int ret_val = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
+ CALENDAR_NULL_ARG_CHECK(todo);
+
+ ret = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_TXT_SUMMARY, subject);
+
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_todo_get_categories(calendar_todo_h todo, char **categories)
+{
CALENDAR_NULL_ARG_CHECK(todo);
+ CALENDAR_NULL_ARG_CHECK(categories);
- ret_val = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_TXT_SUMMARY, subject);
+ *categories = NULL;
+ *categories = _calendar_safe_strdup(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_TXT_CATEGORIES));
- if (ret_val != CAL_SUCCESS) {
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_todo_set_categories(calendar_todo_h todo, const char *categories)
+{
+ int ret = CALENDAR_ERROR_NONE;
+ CALENDAR_NULL_ARG_CHECK(todo);
+
+ ret = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_TXT_CATEGORIES, categories);
+
+ if (ret != CAL_SUCCESS) {
LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
@@ -1924,21 +2793,24 @@ int calendar_todo_get_description(calendar_todo_h todo, char **description)
CALENDAR_NULL_ARG_CHECK(todo);
CALENDAR_NULL_ARG_CHECK(description);
- *description = NULL;
- *description = _calendar_safe_strdup(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_TXT_DESCRIPTION));
+ *description = _calendar_safe_strdup(
+ calendar_svc_struct_get_str(
+ (cal_struct*)((calendar_event_s*)todo)->event_legacy,
+ CAL_VALUE_TXT_DESCRIPTION)
+ );
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
int calendar_todo_set_description(calendar_todo_h todo, const char *description)
{
- int ret_val = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
CALENDAR_NULL_ARG_CHECK(todo);
- ret_val = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_TXT_DESCRIPTION, description);
+ ret = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_TXT_DESCRIPTION, description);
- if (ret_val != CAL_SUCCESS) {
+ if (ret != CAL_SUCCESS) {
LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
@@ -1947,164 +2819,371 @@ int calendar_todo_set_description(calendar_todo_h todo, const char *description)
}
int calendar_todo_get_location(calendar_todo_h todo, char **location)
-{
+{
CALENDAR_NULL_ARG_CHECK(todo);
CALENDAR_NULL_ARG_CHECK(location);
- *location = NULL;
- *location = _calendar_safe_strdup(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)todo)->event_legacy,
- CAL_VALUE_TXT_LOCATION));
-
- return CALENDAR_ERROR_NONE;
+ *location = _calendar_safe_strdup(
+ calendar_svc_struct_get_str(
+ (cal_struct*)((calendar_event_s*)todo)->event_legacy,
+ CAL_VALUE_TXT_LOCATION)
+ );
+
+ return CALENDAR_ERROR_NONE;
}
int calendar_todo_set_location(calendar_todo_h todo, const char *location)
-{
- int ret_val = CALENDAR_ERROR_NONE;
+{
+ int ret = CALENDAR_ERROR_NONE;
CALENDAR_NULL_ARG_CHECK(todo);
- ret_val = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)todo)->event_legacy,
+ ret = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)todo)->event_legacy,
CAL_VALUE_TXT_LOCATION, location);
-
- if (ret_val != CAL_SUCCESS) {
+
+ if (ret != CAL_SUCCESS) {
LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
- return CALENDAR_ERROR_NONE;
+ return CALENDAR_ERROR_NONE;
}
-int calendar_todo_get_last_modified_time(calendar_todo_h todo, struct tm *reviedtime)
+int calendar_todo_get_last_modified_time(calendar_todo_h todo, long long int *modified_time)
{
- struct tm *tmp_date = NULL;
-
CALENDAR_NULL_ARG_CHECK(todo);
- CALENDAR_NULL_ARG_CHECK(reviedtime);
-
- tmp_date = calendar_svc_struct_get_tm((cal_struct*)((calendar_event_s*)todo)->event_legacy,
- CAL_VALUE_GMT_LAST_MODIFIED_TIME, CAL_TZ_FLAG_LOCAL);
-
- if (tmp_date == NULL) {
- LOGE("[%s] CALENDAR_ERROR_NO_DATA(0x%08x)", __FUNCTION__, CALENDAR_ERROR_NO_DATA);
- return CALENDAR_ERROR_NO_DATA;
- }
+ CALENDAR_NULL_ARG_CHECK(modified_time);
- *reviedtime = *tmp_date;
+ *modified_time = calendar_svc_struct_get_lli((cal_struct*)((calendar_event_s*)todo)->event_legacy,
+ CALS_VALUE_LLI_LASTMOD);
return CALENDAR_ERROR_NONE;
}
-
+
int calendar_todo_get_timezone(calendar_todo_h todo, char** timezone_name)
{
CALENDAR_NULL_ARG_CHECK(todo);
CALENDAR_NULL_ARG_CHECK(timezone_name);
-// *timezone_offset = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)event)->event_legacy,
-// CAL_VALUE_INT_TIMEZONE);
- *timezone_name = _calendar_safe_strdup(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)todo)->event_legacy,
- CAL_VALUE_TXT_TZ_NAME));
+ *timezone_name = _calendar_safe_strdup(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)todo)->event_legacy,
+ CALS_VALUE_TXT_DTSTART_TZID));
return CALENDAR_ERROR_NONE;
}
-
+
int calendar_todo_set_timezone(calendar_todo_h todo, const char* timezone_name)
{
- int ret_val = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
CALENDAR_NULL_ARG_CHECK(todo);
CALENDAR_NULL_ARG_CHECK(timezone_name);
- ret_val = calendar_svc_struct_set_int((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_INT_TIMEZONE, 0);
- ret_val = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_TXT_TZ_NAME, timezone_name);
- if (ret_val != CAL_SUCCESS) {
+ ret = calendar_svc_struct_set_str((cal_struct*)((calendar_event_s*)todo)->event_legacy, CALS_VALUE_TXT_DTSTART_TZID, timezone_name);
+ if (ret != CAL_SUCCESS) {
LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
return CALENDAR_ERROR_NONE;
}
-
-int calendar_todo_get_start_time(calendar_todo_h todo, struct tm *start_time)
+
+int calendar_todo_get_start_time(calendar_todo_h todo, long long int *start_time)
{
CALENDAR_NULL_ARG_CHECK(todo);
CALENDAR_NULL_ARG_CHECK(start_time);
-
- if(calendar_svc_struct_get_tm((cal_struct*)((calendar_event_s*)todo)->event_legacy,
- CAL_VALUE_GMT_START_DATE_TIME, CAL_TZ_FLAG_LOCAL) == NULL) {
- LOGE("[%s] CALENDAR_ERROR_NO_DATA(0x%08x)", __FUNCTION__, CALENDAR_ERROR_NO_DATA);
+
+ cal_struct *cs;
+ long long int lli;
+
+ cs = (cal_struct*)((calendar_event_s*)todo)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ lli = calendar_svc_struct_get_lli(cs, CALS_VALUE_LLI_DTSTART_UTIME);
+ if (lli == CALS_TODO_NO_DUE_DATE) {
return CALENDAR_ERROR_NO_DATA;
}
- memcpy(start_time, calendar_svc_struct_get_tm((cal_struct*)((calendar_event_s*)todo)->event_legacy,
- CAL_VALUE_GMT_START_DATE_TIME, CAL_TZ_FLAG_LOCAL), sizeof(struct tm)); // proper memcpy
-
+ *start_time = lli;
return CALENDAR_ERROR_NONE;
}
-int calendar_todo_set_start_time(calendar_todo_h todo, struct tm start_time)
+int calendar_todo_set_start_time(calendar_todo_h todo, long long int start_time)
{
- int ret_val = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
CALENDAR_NULL_ARG_CHECK(todo);
- ret_val = calendar_svc_struct_set_tm((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_GMT_START_DATE_TIME,
- CAL_TZ_FLAG_LOCAL, &start_time);
- if(ret_val != CAL_SUCCESS) {
+ ret = calendar_svc_struct_set_lli((cal_struct*)((calendar_event_s*)todo)->event_legacy, CALS_VALUE_LLI_DTSTART_UTIME,
+ start_time);
+ if(ret != CAL_SUCCESS) {
LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
-
+
return CALENDAR_ERROR_NONE;
}
-int calendar_todo_get_due_time(calendar_todo_h todo, struct tm *due_time)
+int calendar_todo_get_due_time(calendar_todo_h todo, long long int *due_time)
{
CALENDAR_NULL_ARG_CHECK(todo);
CALENDAR_NULL_ARG_CHECK(due_time);
-
- if(calendar_svc_struct_get_tm((cal_struct*)((calendar_event_s*)todo)->event_legacy,
- CAL_VALUE_GMT_END_DATE_TIME, CAL_TZ_FLAG_LOCAL) == NULL) {
- LOGE("[%s] CALENDAR_ERROR_NO_DATA(0x%08x)", __FUNCTION__, CALENDAR_ERROR_NO_DATA);
+
+ cal_struct *cs;
+ long long int lli;
+
+ cs = (cal_struct*)((calendar_event_s*)todo)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ lli = calendar_svc_struct_get_lli(cs, CALS_VALUE_LLI_DTEND_UTIME);
+ if (lli == CALS_TODO_NO_DUE_DATE) {
return CALENDAR_ERROR_NO_DATA;
}
- memcpy(due_time, calendar_svc_struct_get_tm((cal_struct*)((calendar_event_s*)todo)->event_legacy,
- CAL_VALUE_GMT_END_DATE_TIME, CAL_TZ_FLAG_LOCAL), sizeof(struct tm)); // proper memcpy
-
+ *due_time = lli;
return CALENDAR_ERROR_NONE;
}
-int calendar_todo_set_due_time(calendar_todo_h todo, struct tm due_time)
+int calendar_todo_set_due_time(calendar_todo_h todo, long long int due_time)
{
- int ret_val = CALENDAR_ERROR_NONE;
+ int ret = CALENDAR_ERROR_NONE;
CALENDAR_NULL_ARG_CHECK(todo);
- ret_val = calendar_svc_struct_set_tm((cal_struct*)((calendar_event_s*)todo)->event_legacy, CAL_VALUE_GMT_END_DATE_TIME,
- CAL_TZ_FLAG_LOCAL, &due_time);
- if(ret_val != CAL_SUCCESS) {
+ ret = calendar_svc_struct_set_lli((cal_struct*)((calendar_event_s*)todo)->event_legacy, CALS_VALUE_LLI_DTEND_UTIME,
+ due_time);
+ if(ret != CAL_SUCCESS) {
LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
return CALENDAR_ERROR_INVALID_PARAMETER;
}
-
+
return CALENDAR_ERROR_NONE;
}
-int calendar_foreach_todo_from_db(calendar_foreach_query_todo_cb callback, void *user_data)
+int calendar_todo_get_total_count_from_db(int calendar_book_db_id, int todo_priority, int todo_status, int *count)
{
- CALENDAR_NULL_ARG_CHECK(callback);
+ CALENDAR_NULL_ARG_CHECK(count);
+
+ int ret;
+ cal_iter *iter = NULL;
+ *count = 0;
+
+ ret = calendar_svc_todo_get_iter(calendar_book_db_id,
+ todo_priority, todo_status, CALS_TODO_LIST_ORDER_END_DATE, &iter);
+
+ if (CAL_SUCCESS != ret) {
+ LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ if ((ret = _get_count_from_legacy_iter(__FUNCTION__, iter, count))
+ != CALENDAR_ERROR_NONE)
+ return ret;
- return _calendar_todo_foreach(callback, ALL_ACCOUNT_ID, ALL_CALENDAR_ID, user_data);
+ return CALENDAR_ERROR_NONE;
}
-int calendar_query_todo_by_calendar(calendar_foreach_query_todo_cb callback, int calendar_db_id, void *user_data)
+
+int calendar_todo_get_total_count_by_duedate_range(int calendar_book_db_id, // TODO
+ long long int start_duedate_range, long long int end_duedate_range,
+ int todo_priority, int todo_status, int *count)
{
- CALENDAR_NULL_ARG_CHECK(callback);
- CONTACTS_INVALID_ARG_CHECK(calendar_db_id < 1);
- int account_db_id = _calendar_get_account_db_id(calendar_db_id);
- CONTACTS_INVALID_ARG_CHECK(account_db_id == -2);
-
- return _calendar_todo_foreach(callback, account_db_id, calendar_db_id, user_data);
+ CALENDAR_NULL_ARG_CHECK(count);
+
+ int ret;
+
+ ret = calendar_svc_todo_get_count_by_period(calendar_book_db_id,
+ start_duedate_range, end_duedate_range,
+ todo_priority, todo_status, count);
+ if (ret != CAL_SUCCESS) {
+ LOGE("Failed to get count by period");
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ if (*count < 1) {
+ LOGD("No data");
+// return CALENDAR_ERROR_NO_DATA; check s1-7153
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_todo_free_todo_array(calendar_todo_h *todo_array)
+{
+ int i;
+ CALENDAR_NULL_ARG_CHECK(todo_array);
+
+ for (i = 0; todo_array[i]; i++) {
+ calendar_svc_struct_free(((cal_struct**)&((calendar_event_s*)(todo_array[i]))->event_legacy));
+ }
+ free(todo_array);
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_todo_free_modified_todo_array(pcalendar_modified_todo_s *modified_todo_array)
+{
+ CALENDAR_NULL_ARG_CHECK(modified_todo_array);
+
+ int i = 0;
+ pcalendar_modified_todo_s *p;
+
+ p = modified_todo_array;
+
+ if (p) {
+ while (p[i]) {
+ free(p[i]);
+ i++;
+ }
+ free(p);
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_todo_search_todo_by_calendar_book(int calendar_book_db_id,
+ int todo_priority, int todo_status, calendar_todo_h **todo_array, int *length)
+{
+ CALENDAR_NULL_ARG_CHECK(todo_array);
+ CALENDAR_NULL_ARG_CHECK(length);
+
+ int ret;
+ cal_iter *iter = NULL;
+ *todo_array = NULL;
+ *length = 0;
+
+ ret = calendar_svc_todo_get_iter(calendar_book_db_id,
+ todo_priority, todo_status, CALS_TODO_LIST_ORDER_END_DATE, &iter);
+
+ if (CAL_SUCCESS != ret) {
+ LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ if ((ret = _get_h_array_from_legacy_iter(__FUNCTION__, iter, todo_array, length))
+ != CALENDAR_ERROR_NONE)
+ return ret;
+
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_todo_search_todo_by_duedate_range(int calendar_book_db_id,
+ long long int start_duedate_range, long long int end_duedate_range,
+ int todo_priority, int todo_status, calendar_todo_h **todo_array, int *length)
+{
+ CALENDAR_NULL_ARG_CHECK(todo_array);
+ CALENDAR_NULL_ARG_CHECK(length);
+
+ int ret;
+ cal_iter *iter = NULL;
+ *todo_array = NULL;
+ *length = 0;
+
+ ret = calendar_svc_todo_get_list_by_period(calendar_book_db_id,
+ start_duedate_range, end_duedate_range,
+ todo_priority, todo_status, &iter);
+
+ if (CAL_SUCCESS != ret) {
+ LOGE("[%s] CALLENDAR_ERROR_DB_FAILED(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ if ((ret = _get_h_array_from_legacy_iter(__FUNCTION__, iter, todo_array, length))
+ != CALENDAR_ERROR_NONE)
+ return ret;
+
+ return CALENDAR_ERROR_NONE;
}
-int calendar_get_from_db(int calendar_db_id, calendar_h *calendar)
+int calendar_todo_search_todo_by_version(int calendar_book_db_id, int calendar_db_version,
+ pcalendar_modified_todo_s **modified_todo_array, int *length)
{
- CONTACTS_INVALID_ARG_CHECK(calendar_db_id < 1);
+ CALENDAR_NULL_ARG_CHECK(modified_todo_array);
+ CALENDAR_NULL_ARG_CHECK(length);
+
+ int i, ret;
+ int is_error = 0;
+ GList *l = NULL;
+ GList *cursor;
+ cal_iter *iter = NULL;
+ cal_struct *cs = NULL;
+ calendar_modified_todo_s *cmt;
+ pcalendar_modified_todo_s *p;
+ *length = 0;
+
+ ret = calendar_svc_todo_get_changes(calendar_book_db_id, calendar_db_version, &iter);
+ if (CAL_SUCCESS != ret) {
+ LOGE("[%s] CALLENDAR_ERROR_DB_FAILED(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ /* get event_db_id and append to glist */
+ while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
+ if(calendar_svc_iter_get_info(iter, &cs) != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY);
+ is_error = 1;
+ break;
+ }
+
+ cmt = calloc(1, sizeof(calendar_modified_todo_s));
+ if (cmt == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY);
+ is_error = 1;
+ break;
+ }
+
+ cmt->modified_status = calendar_svc_struct_get_int(cs, CALS_STRUCT_UPDATED_INT_TYPE);
+ cmt->todo_db_id = calendar_svc_struct_get_int(cs, CALS_STRUCT_UPDATED_INT_ID);
+ cmt->calendar_db_version = calendar_svc_struct_get_int(cs,
+ CALS_STRUCT_UPDATED_INT_VERSION);
+ cmt->calendar_book_db_id = calendar_svc_struct_get_int(cs,
+ CALS_STRUCT_UPDATED_INT_CALENDAR_ID);
+
+ l = g_list_append(l, cmt);
+ calendar_svc_struct_free(&cs);
+ }
+ calendar_svc_iter_remove(&iter);
+
+ if (is_error) {
+ LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY);
+ g_list_free_full(l, free);
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+
+ /* malloc array and fill data */
+ *length = g_list_length(l);
+
+ /* plus 1 to set end of array as checking id -1 */
+ p = calloc(*length + 1, sizeof(pcalendar_modified_todo_s));
+ if (p == NULL) {
+ g_list_free_full(l, free);
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+
+ cursor = l;
+ for (i = 0; cursor; i++) {
+ p[i] = (pcalendar_modified_todo_s)(cursor->data);
+ cursor = g_list_next(cursor);
+ }
+ /* free list after allocation */
+ g_list_free(l);
+
+ /* fill NULL pointer to indicate end of array */
+ p[i] = NULL;
+
+ *modified_todo_array = p;
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_book_get_from_db(int calendar_db_id, calendar_book_h *calendar)
+{
+ CALENDAR_INVALID_ARG_CHECK(calendar_db_id < 1);
CALENDAR_NULL_ARG_CHECK(calendar);
*calendar = malloc(sizeof(calendar_event_s));
@@ -2124,25 +3203,98 @@ int calendar_get_from_db(int calendar_db_id, calendar_h *calendar)
return CALENDAR_ERROR_NONE;
}
-int calendar_destroy(calendar_h calendar)
+int calendar_book_create(calendar_book_h *calendar)
+{
+ CALENDAR_NULL_ARG_CHECK(calendar);
+
+ *calendar = malloc(sizeof(calendar_event_s));
+ if (*calendar == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CALENDAR_ERROR_OUT_OF_MEMORY);
+ return CALENDAR_ERROR_OUT_OF_MEMORY;
+ }
+
+ memset(*calendar, 0, sizeof(calendar_event_s));
+ (*(calendar_event_s**)calendar)->event_legacy = (calendar_event_legacy_s*)(calendar_svc_struct_new(CAL_STRUCT_CALENDAR));
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_book_insert_to_db(calendar_book_h calendar, int *calendar_db_id)
+{
+ CALENDAR_NULL_ARG_CHECK(calendar);
+ int index = -1;
+
+ index = calendar_svc_insert(
+ (cal_struct*)((calendar_event_s*)calendar)->event_legacy
+ );
+ *calendar_db_id = index;
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_book_update_to_db(calendar_book_h calendar)
+{
+ CALENDAR_NULL_ARG_CHECK(calendar);
+
+ int ret = CALENDAR_ERROR_NONE;
+
+ if((cal_struct*)((calendar_event_s*)calendar)->event_legacy == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = calendar_svc_update(
+ (cal_struct*)((calendar_event_s*)calendar)->event_legacy
+ );
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+// TOREM
+int calendar_book_set_is_default(calendar_book_h calendar, bool is_default)
{
CALENDAR_NULL_ARG_CHECK(calendar);
- int ret_val = CALENDAR_ERROR_NONE;
+/*
+ is_default = calendar_svc_struct_get_int(
+ (cal_struct*)((calendar_event_s*)calendar)->event_legacy,
+ CAL_TABLE_INT_VISIBILITY);
+*/
+
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_book_set_is_visible(calendar_book_h calendar, bool is_visible)
+{
+ CALENDAR_NULL_ARG_CHECK(calendar);
+
+ is_visible = calendar_svc_struct_get_int(
+ (cal_struct*)((calendar_event_s*)calendar)->event_legacy,
+ CAL_TABLE_INT_VISIBILITY);
- ret_val = calendar_svc_struct_free((cal_struct **)&((calendar_event_s*)calendar)->event_legacy);
-
- if (ret_val != CAL_SUCCESS) {
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_book_destroy(calendar_book_h calendar)
+{
+ CALENDAR_NULL_ARG_CHECK(calendar);
+ int ret = CALENDAR_ERROR_NONE;
+
+ ret = calendar_svc_struct_free((cal_struct **)&((calendar_event_s*)calendar)->event_legacy);
+
+ if (ret != CAL_SUCCESS) {
LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
- ret_val = CALENDAR_ERROR_INVALID_PARAMETER;
+ ret = CALENDAR_ERROR_INVALID_PARAMETER;
} else {
free(calendar);
- ret_val = CALENDAR_ERROR_NONE;
+ ret = CALENDAR_ERROR_NONE;
}
- return ret_val;
+ return ret;
}
-int calendar_get_db_id(calendar_h calendar, int *calendar_db_id)
+int calendar_book_get_db_id(calendar_book_h calendar, int *calendar_db_id)
{
CALENDAR_NULL_ARG_CHECK(calendar);
CALENDAR_NULL_ARG_CHECK(calendar_db_id);
@@ -2153,7 +3305,7 @@ int calendar_get_db_id(calendar_h calendar, int *calendar_db_id)
return CALENDAR_ERROR_NONE;
}
-int calendar_get_is_default(calendar_h calendar, bool *is_default)
+int calendar_book_get_is_default(calendar_book_h calendar, bool *is_default)
{
CALENDAR_NULL_ARG_CHECK(calendar);
CALENDAR_NULL_ARG_CHECK(is_default);
@@ -2167,18 +3319,40 @@ int calendar_get_is_default(calendar_h calendar, bool *is_default)
return CALENDAR_ERROR_NONE;
}
-int calendar_get_name(calendar_h calendar, char **calendar_name)
+int calendar_book_get_name(calendar_book_h calendar, char **calendar_name)
{
CALENDAR_NULL_ARG_CHECK(calendar);
CALENDAR_NULL_ARG_CHECK(calendar_name);
*calendar_name = NULL;
- *calendar_name = _calendar_safe_strdup(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)calendar)->event_legacy, CAL_TABLE_TXT_NAME));
+ *calendar_name = _calendar_safe_strdup(
+ calendar_svc_struct_get_str(
+ (cal_struct*)((calendar_event_s*)calendar)->event_legacy,
+ CAL_TABLE_TXT_NAME));
return CALENDAR_ERROR_NONE;
}
-int calendar_get_is_visibile(calendar_h calendar, bool *is_visible)
+int calendar_book_set_name(calendar_book_h calendar, const char *calnedar_name)
+{
+ int ret = CALENDAR_ERROR_NONE;
+
+ CALENDAR_NULL_ARG_CHECK(calendar);
+
+ ret = calendar_svc_struct_set_str(
+ (cal_struct*)((calendar_event_s*)calendar)->event_legacy,
+ CAL_TABLE_TXT_NAME, calnedar_name);
+
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_book_get_is_visible(calendar_book_h calendar, bool *is_visible)
{
CALENDAR_NULL_ARG_CHECK(calendar);
CALENDAR_NULL_ARG_CHECK(is_visible);
@@ -2188,87 +3362,362 @@ int calendar_get_is_visibile(calendar_h calendar, bool *is_visible)
return CALENDAR_ERROR_NONE;
}
-int calendar_get_color(calendar_h calendar, unsigned char *red, unsigned char *green, unsigned char *blue)
+int calendar_book_set_color(calendar_book_h calendar_book, unsigned char red, unsigned char green, unsigned char blue)
+{
+ CALENDAR_NULL_ARG_CHECK(calendar_book);
+
+ int ret;
+ char buf[32] = {0, };
+
+ snprintf(buf, sizeof(buf), "%d.%d.%d.%d", (int)red, (int)green, (int)blue, 0);
+ ret = calendar_svc_struct_set_str(
+ (cal_struct*)((calendar_event_s*)calendar_book)->event_legacy,
+ CAL_TABLE_TXT_COLOR, buf);
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_book_unset_color(calendar_book_h calendar_book)
+{
+ CALENDAR_NULL_ARG_CHECK(calendar_book);
+
+ int ret;
+ ret = calendar_svc_struct_set_str(
+ (cal_struct*)((calendar_event_s*)calendar_book)->event_legacy,
+ CAL_TABLE_TXT_COLOR, "");
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_book_get_color(calendar_book_h calendar, unsigned char *red, unsigned char *green, unsigned char *blue)
{
CALENDAR_NULL_ARG_CHECK(calendar);
CALENDAR_NULL_ARG_CHECK(red);
CALENDAR_NULL_ARG_CHECK(green);
CALENDAR_NULL_ARG_CHECK(blue);
- _calendar_parse_color(calendar_svc_struct_get_str((cal_struct*)((calendar_event_s*)calendar)->event_legacy, CAL_TABLE_TXT_COLOR),
- red, green, blue);
+ char *color = NULL;
+
+ color = calendar_svc_struct_get_str(
+ (cal_struct*)((calendar_event_s*)calendar)->event_legacy, CAL_TABLE_TXT_COLOR);
+ if (color == NULL || strlen(color) < 1) {
+ *red = *green = *blue = 0;
+ return CALENDAR_ERROR_NO_DATA;
+ }
+
+ _calendar_parse_color(color, red, green, blue);
return CALENDAR_ERROR_NONE;
}
-int calendar_get_account_db_id(calendar_h calendar, int *account_db_id)
+int calendar_book_get_account_db_id(calendar_book_h calendar, int *account_db_id)
{
CALENDAR_NULL_ARG_CHECK(calendar);
CALENDAR_NULL_ARG_CHECK(account_db_id);
- *account_db_id = calendar_svc_struct_get_int((cal_struct*)((calendar_event_s*)calendar)->event_legacy, CAL_TABLE_INT_ACCOUNT_ID) == 1 ? true : false;
+ *account_db_id = calendar_svc_struct_get_int(
+ (cal_struct*)((calendar_event_s*)calendar)->event_legacy,
+ CAL_TABLE_INT_ACCOUNT_ID) == 1 ? true : false;
return CALENDAR_ERROR_NONE;
}
-int calendar_foreach_calendar_from_db(calendar_foreach_query_calendar_cb callback, void *user_data)
+int calendar_book_set_account_db_id(calendar_book_h calendar, int account_db_id)
{
- CALENDAR_NULL_ARG_CHECK(callback);
+ int ret = CALENDAR_ERROR_NONE;
+
+ CALENDAR_NULL_ARG_CHECK(calendar);
+ ret = calendar_svc_struct_set_int(
+ (cal_struct*)((calendar_event_s*)calendar)->event_legacy,
+ CAL_TABLE_INT_ACCOUNT_ID, account_db_id);
+ if (ret != CAL_SUCCESS)
+ {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_book_get_type(calendar_book_h calendar, int *calendar_type)
+{
+ CALENDAR_NULL_ARG_CHECK(calendar);
+ CALENDAR_NULL_ARG_CHECK(calendar_type);
+
+ *calendar_type = calendar_svc_struct_get_int(
+ (cal_struct*)((calendar_event_s*)calendar)->event_legacy,
+ CAL_TABLE_INT_STORE_TYPE);
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_book_set_type(calendar_book_h calendar, int calendar_type)
+{
+ int ret = CALENDAR_ERROR_NONE;
+
+ CALENDAR_NULL_ARG_CHECK(calendar);
+ ret = calendar_svc_struct_set_int(
+ (cal_struct*)((calendar_event_s*)calendar)->event_legacy,
+ CAL_TABLE_INT_STORE_TYPE, calendar_type);
+ if (ret != CAL_SUCCESS)
+ {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_book_free_calendar_book_array(calendar_book_h *calendar_book_array) // TODO
+{
+ int i;
+ calendar_book_h c;
+
+ CALENDAR_NULL_ARG_CHECK(calendar_book_array);
+
+ c = calendar_book_array[0];
+ for (i = 0; c ; c = calendar_book_array[++i] )
+ calendar_book_destroy(c);
+ free(calendar_book_array);
+
+ return CALENDAR_ERROR_NONE;
+}
+
+//int calendar_foreach_calendar_book_from_db(calendar_foreach_query_calendar_book_cb callback, void *user_data)
+//{
+// CALENDAR_NULL_ARG_CHECK(callback);
+//
+// int ret = CALENDAR_ERROR_NONE;
+// cal_iter* iter = NULL;
+// bool callback_return = true;
+//
+// //fetch from DB
+// ret = calendar_svc_get_all(ALL_ACCOUNT_ID, ALL_CALENDAR_ID, CAL_STRUCT_CALENDAR, &iter);
+//
+// if (ret != CAL_SUCCESS) {
+// LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+// return CALENDAR_ERROR_DB_FAILED;
+// }
+//
+// if (iter == NULL) {
+// LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+// return CALENDAR_ERROR_DB_FAILED;
+// } else {
+// while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
+// cal_struct *calendar_struct = NULL;
+// if(calendar_svc_iter_get_info(iter, &calendar_struct) != CAL_SUCCESS) {
+// calendar_svc_iter_remove(&iter);
+// return CALENDAR_ERROR_NONE; // consider this as no data
+// }
+//
+// if(calendar_struct == NULL) {
+// calendar_svc_iter_remove(&iter);
+// return CALENDAR_ERROR_NONE; // consider this as no data
+// }
+//
+// calendar_query_calendar_book_s query_data;
+//
+// query_data.calendar_db_id = calendar_svc_struct_get_int(calendar_struct, CAL_TABLE_INT_INDEX);
+// query_data.calendar_name = _calendar_safe_strdup(calendar_svc_struct_get_str(calendar_struct, CAL_TABLE_TXT_NAME));
+// query_data.calendar_is_default = query_data.calendar_db_id == 1 ? true : false;
+// query_data.calendar_is_visible = calendar_svc_struct_get_int(calendar_struct, CAL_TABLE_INT_VISIBILITY) == 1 ? true : false;
+// _calendar_parse_color(calendar_svc_struct_get_str(calendar_struct, CAL_TABLE_TXT_COLOR),
+// &query_data.calendar_color_red, &query_data.calendar_color_green, &query_data.calendar_color_blue);
+// query_data.account_db_id = calendar_svc_struct_get_int(calendar_struct, CAL_TABLE_INT_ACCOUNT_ID);
+//
+// //execute callback
+// callback_return = callback(&query_data, user_data);
+//
+// _calendar_safe_free(query_data.calendar_name);
+//
+// calendar_svc_struct_free(&calendar_struct);
+//
+// if(callback_return == false) {
+// break;
+// }
+// }
+// calendar_svc_iter_remove(&iter);
+//
+// return CALENDAR_ERROR_NONE;
+// }
+// return CALENDAR_ERROR_NONE;
+//}
+
+int calendar_book_get_all_calendar_book(calendar_book_h **calendar_book_array, int *length)
+{
+ CALENDAR_NULL_ARG_CHECK(calendar_book_array);
+ CALENDAR_NULL_ARG_CHECK(length);
+
+ int ret = CALENDAR_ERROR_NONE;
+ cal_iter* iter = NULL;
- int ret_val = CALENDAR_ERROR_NONE;
- cal_iter* iter = NULL;
- bool callback_return = true;
+ //fetch from DB
+ ret = calendar_svc_get_all(ALL_ACCOUNT_ID, ALL_CALENDAR_ID, CAL_STRUCT_CALENDAR, &iter);
+ if (CAL_SUCCESS != ret) {
+ LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
+
+ if ((ret = _get_h_array_from_legacy_iter(__FUNCTION__, iter, calendar_book_array, length))
+ != CALENDAR_ERROR_NONE)
+ return ret;
+
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_book_search_calendar_book_by_account(int account_db_id, calendar_book_h **calendar_book_array, int *length)
+{
+ CALENDAR_NULL_ARG_CHECK(calendar_book_array);
+ CALENDAR_NULL_ARG_CHECK(length);
+
+ int ret = CALENDAR_ERROR_NONE;
+ cal_iter* iter = NULL;
//fetch from DB
- ret_val = calendar_svc_get_all(ALL_ACCOUNT_ID, ALL_CALENDAR_ID, CAL_STRUCT_CALENDAR, &iter);
+ ret = calendar_svc_get_all(account_db_id, ALL_CALENDAR_ID, CAL_STRUCT_CALENDAR, &iter);
+ if (CAL_SUCCESS != ret) {
+ LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+ return CALENDAR_ERROR_DB_FAILED;
+ }
- if (ret_val != CAL_SUCCESS) {
- LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
- return CALENDAR_ERROR_DB_FAILED;
+ if ((ret = _get_h_array_from_legacy_iter(__FUNCTION__, iter, calendar_book_array, length))
+ != CALENDAR_ERROR_NONE)
+ return ret;
+
+ return CALENDAR_ERROR_NONE;
+
+}
+
+int calendar_event_get_is_recurrence(calendar_event_h event, bool *is_recurrence)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+ CALENDAR_NULL_ARG_CHECK(is_recurrence);
+
+ int is_recur;
+
+ is_recur = calendar_svc_struct_get_int(
+ (cal_struct*)((calendar_event_s*)event)->event_legacy,
+ CALS_VALUE_INT_RRULE_ID);
+ *is_recurrence = is_recur > 0 ? 1 : 0;
+
+ return CALENDAR_ERROR_NONE;
+
+}
+
+int calendar_event_get_all_day_recurrence_until_date(calendar_event_h event,
+ int *until_year, int *until_month, int *until_day)
+{
+ int y, m, d;
+
+ CALENDAR_NULL_ARG_CHECK(event);
+ CALENDAR_NULL_ARG_CHECK(until_year);
+ CALENDAR_NULL_ARG_CHECK(until_month);
+ CALENDAR_NULL_ARG_CHECK(until_day);
+
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
}
-
- if (iter == NULL) {
- LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
- return CALENDAR_ERROR_DB_FAILED;
- } else {
- while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
- cal_struct *calendar_struct = NULL;
- if(calendar_svc_iter_get_info(iter, &calendar_struct) != CAL_SUCCESS) {
- calendar_svc_iter_remove(&iter);
- return CALENDAR_ERROR_NONE; // consider this as no data
- }
-
- if(calendar_struct == NULL) {
- calendar_svc_iter_remove(&iter);
- return CALENDAR_ERROR_NONE; // consider this as no data
- }
+ y = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_RRULE_UNTIL_YEAR);
+ m = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_RRULE_UNTIL_MONTH);
+ d = calendar_svc_struct_get_int(cs, CALS_VALUE_INT_RRULE_UNTIL_MDAY);
- calendar_query_calendar_s query_data;
-
- query_data.calendar_db_id = calendar_svc_struct_get_int(calendar_struct, CAL_TABLE_INT_INDEX);
- query_data.calendar_name = _calendar_safe_strdup(calendar_svc_struct_get_str(calendar_struct, CAL_TABLE_TXT_NAME));
- query_data.calendar_is_default = query_data.calendar_db_id == 1 ? true : false;
- query_data.calendar_is_visible = calendar_svc_struct_get_int(calendar_struct, CAL_TABLE_INT_VISIBILITY) == 1 ? true : false;
- _calendar_parse_color(calendar_svc_struct_get_str(calendar_struct, CAL_TABLE_TXT_COLOR),
- &query_data.calendar_color_red, &query_data.calendar_color_green, &query_data.calendar_color_blue);
- query_data.account_db_id = calendar_svc_struct_get_int(calendar_struct, CAL_TABLE_INT_ACCOUNT_ID);
-
- //execute callback
- callback_return = callback(&query_data, user_data);
-
- _calendar_safe_free(query_data.calendar_name);
-
- calendar_svc_struct_free(&calendar_struct);
-
- if(callback_return == false) {
- break;
- }
- }
- calendar_svc_iter_remove(&iter);
-
- return CALENDAR_ERROR_NONE;
- }
- return CALENDAR_ERROR_NONE;
+ if (y == 0 && m == 0 && d == 0) {
+ return CALENDAR_ERROR_NO_DATA;
+ }
+ *until_year = y;
+ *until_month = m;
+ *until_day = d;
-
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_event_set_all_day_recurrence_until_date(calendar_event_h event,
+ int until_year, int until_month, int until_day)
+{
+ CALENDAR_NULL_ARG_CHECK(event);
+
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)event)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_RANGE_TYPE, CALS_RANGE_UNTIL);
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_UNTIL_TYPE, CALS_TIME_LOCALTIME);
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_UNTIL_YEAR, until_year);
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_UNTIL_MONTH, until_month);
+ calendar_svc_struct_set_int(cs, CALS_VALUE_INT_RRULE_UNTIL_MDAY, until_day);
+
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_todo_unset_start_time(calendar_todo_h todo)
+{
+ CALENDAR_NULL_ARG_CHECK(todo);
+
+ int ret;
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)todo)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = calendar_svc_struct_set_lli(cs,
+ CALS_VALUE_LLI_DTSTART_UTIME, CALS_TODO_NO_DUE_DATE);
+
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
+}
+
+int calendar_todo_unset_due_time(calendar_todo_h todo)
+{
+ CALENDAR_NULL_ARG_CHECK(todo);
+
+ int ret;
+ cal_struct *cs;
+
+ cs = (cal_struct*)((calendar_event_s*)todo)->event_legacy;
+ if(cs == NULL) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = calendar_svc_struct_set_lli(cs,
+ CALS_VALUE_LLI_DTEND_UTIME, CALS_TODO_NO_DUE_DATE);
+
+ if (ret != CAL_SUCCESS) {
+ LOGE("[%s] CALENDAR_ERROR_INVALID_PARAMETER(0x%08x)",
+ __FUNCTION__, CALENDAR_ERROR_INVALID_PARAMETER);
+ return CALENDAR_ERROR_INVALID_PARAMETER;
+ }
+ return CALENDAR_ERROR_NONE;
}
+
+
diff --git a/src/calendar_private.c b/src/calendar_private.c
index 239e2f2..d8ba7dc 100755
--- a/src/calendar_private.c
+++ b/src/calendar_private.c
@@ -11,18 +11,19 @@
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <calendar.h>
-#include <calendar_private.h>
#include <calendar-svc-provider.h>
#include <dlog.h>
+#include "calendar_private.h"
+#include "calendar.h"
+
#ifdef LOG_TAG
#undef LOG_TAG
#endif
@@ -35,7 +36,7 @@ GList* _calendar_glist_next_until_not_deleted(GList* list)
{
if(list == NULL)
return NULL;
-
+
GList* glist = list;
cal_value* value = glist->data;
if(value == NULL)
@@ -55,146 +56,210 @@ GList* _calendar_glist_next_until_not_deleted(GList* list)
return glist;
}
-int _calendar_event_foreach(calendar_foreach_query_event_cb callback, int account_db_id, int calendar_db_id, void* user_data)
-{
- int ret_val = CALENDAR_ERROR_NONE;
- cal_iter* iter = NULL;
- bool callback_return = true;
-
- //fetch from DB
- ret_val = calendar_svc_get_all(account_db_id, calendar_db_id, CAL_STRUCT_SCHEDULE, &iter);
-
- if (ret_val != CAL_SUCCESS) {
- LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
- return CALENDAR_ERROR_DB_FAILED;
- }
-
- if (iter == NULL) {
- LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
- return CALENDAR_ERROR_DB_FAILED;
- } else {
- while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
- calendar_event_s cal_event_from_db = {0,};
- if(calendar_svc_iter_get_info(iter, (cal_struct**)&cal_event_from_db.event_legacy) != CAL_SUCCESS) {
- calendar_svc_iter_remove(&iter);
- return CALENDAR_ERROR_NONE; // consider this as no data
- }
-
- if(cal_event_from_db.event_legacy == NULL) {
- calendar_svc_iter_remove(&iter);
- return CALENDAR_ERROR_NONE; // consider this as no data
- }
-
- //execute callback
- callback_return = callback((calendar_event_h)&cal_event_from_db, user_data);
-
- calendar_svc_struct_free((cal_struct**)&cal_event_from_db.event_legacy);
-
- if(callback_return == false) {
- break;
- }
- }
- calendar_svc_iter_remove(&iter);
-
- return CALENDAR_ERROR_NONE;
- }
- return CALENDAR_ERROR_NONE;
-}
-
-int _calendar_todo_foreach(calendar_foreach_query_todo_cb callback, int account_db_id, int calendar_db_id, void* user_data)
-{
- int ret_val = CALENDAR_ERROR_NONE;
- cal_iter* iter = NULL;
- bool callback_return = true;
-
- //fetch from DB
- ret_val = calendar_svc_get_all(account_db_id, calendar_db_id, CAL_STRUCT_TODO, &iter);
-
- if (ret_val != CAL_SUCCESS) {
- LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
- return CALENDAR_ERROR_DB_FAILED;
- }
-
- if (iter == NULL) {
- LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
- return CALENDAR_ERROR_DB_FAILED;
- } else {
- while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
- calendar_event_s cal_event_from_db = {0,};
- if(calendar_svc_iter_get_info(iter, (cal_struct**)&cal_event_from_db.event_legacy) != CAL_SUCCESS) {
- calendar_svc_iter_remove(&iter);
- return CALENDAR_ERROR_NONE; // consider this as no data
- }
-
- if(cal_event_from_db.event_legacy == NULL) {
- calendar_svc_iter_remove(&iter);
- return CALENDAR_ERROR_NONE; // consider this as no data
- }
-
- //execute callback
- callback_return = callback((calendar_todo_h)&cal_event_from_db, user_data);
-
- calendar_svc_struct_free((cal_struct**)&cal_event_from_db.event_legacy);
-
- if(callback_return == false) {
- break;
- }
- }
- calendar_svc_iter_remove(&iter);
-
- return CALENDAR_ERROR_NONE;
- }
- return CALENDAR_ERROR_NONE;
-}
-
-int _calendar_event_query(calendar_foreach_query_event_cb callback, int calendar_db_id, char* option, const char* string_to_find, void* user_data)
-{
- int ret_val = 0;
- cal_iter* iter = NULL;
- bool callback_return = true;
-
- int account_id = _calendar_get_account_db_id(calendar_db_id);
- CONTACTS_INVALID_ARG_CHECK(account_id == -2);
-
- //fetch from DB
- ret_val = calendar_svc_find_event_list(account_id, option, string_to_find, &iter);
-
- if (ret_val != CAL_SUCCESS) {
- LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
- return CALENDAR_ERROR_DB_FAILED;
- }
-
- if (iter == NULL) {
- LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
- return CALENDAR_ERROR_DB_FAILED;
- } else {
- while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
- calendar_event_s cal_event_from_db = {0,};
- if(calendar_svc_iter_get_info(iter, (cal_struct**)&cal_event_from_db.event_legacy) != CAL_SUCCESS) {
- calendar_svc_iter_remove(&iter);
- return CALENDAR_ERROR_NONE; // consider this as no data
- }
-
- if(cal_event_from_db.event_legacy == NULL) {
- calendar_svc_iter_remove(&iter);
- return CALENDAR_ERROR_NONE; // consider this as no data
- }
-
- //execute callback
- callback_return = callback((calendar_event_h)&cal_event_from_db, user_data);
-
- calendar_svc_struct_free((cal_struct**)&cal_event_from_db.event_legacy);
- if(callback_return == false) {
- break;
- }
- }
- calendar_svc_iter_remove(&iter);
-
- return CALENDAR_ERROR_NONE;
- }
-
- return CALENDAR_ERROR_NONE;
-}
+//int _calendar_event_foreach(calendar_foreach_query_event_cb callback, int account_db_id, int calendar_db_id, void* user_data)
+//{
+// int ret_val = CALENDAR_ERROR_NONE;
+// cal_iter* iter = NULL;
+// bool callback_return = true;
+//
+// //fetch from DB
+// ret_val = calendar_svc_get_all(account_db_id, calendar_db_id, CAL_STRUCT_SCHEDULE, &iter);
+//
+// if (ret_val != CAL_SUCCESS) {
+// LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+// return CALENDAR_ERROR_DB_FAILED;
+// }
+//
+// if (iter == NULL) {
+// LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+// return CALENDAR_ERROR_DB_FAILED;
+// } else {
+// while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
+// calendar_event_s cal_event_from_db = {0,};
+// if(calendar_svc_iter_get_info(iter, (cal_struct**)&cal_event_from_db.event_legacy) != CAL_SUCCESS) {
+// calendar_svc_iter_remove(&iter);
+// return CALENDAR_ERROR_NONE; // consider this as no data
+// }
+//
+// if(cal_event_from_db.event_legacy == NULL) {
+// calendar_svc_iter_remove(&iter);
+// return CALENDAR_ERROR_NONE; // consider this as no data
+// }
+//
+// //execute callback
+// callback_return = callback((calendar_event_h)&cal_event_from_db, user_data);
+//
+// calendar_svc_struct_free((cal_struct**)&cal_event_from_db.event_legacy);
+//
+// if(callback_return == false) {
+// break;
+// }
+// }
+// calendar_svc_iter_remove(&iter);
+//
+// return CALENDAR_ERROR_NONE;
+// }
+// return CALENDAR_ERROR_NONE;
+//}
+//
+//int _calendar_todo_foreach(calendar_foreach_query_todo_cb callback, int account_db_id, int calendar_db_id, void* user_data)
+//{
+// int ret_val = CALENDAR_ERROR_NONE;
+// cal_iter* iter = NULL;
+// bool callback_return = true;
+//
+// //fetch from DB
+// ret_val = calendar_svc_get_all(account_db_id, calendar_db_id, CAL_STRUCT_TODO, &iter);
+//
+// if (ret_val != CAL_SUCCESS) {
+// LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+// return CALENDAR_ERROR_DB_FAILED;
+// }
+//
+// if (iter == NULL) {
+// LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+// return CALENDAR_ERROR_DB_FAILED;
+// } else {
+// while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
+// calendar_event_s cal_event_from_db = {0,};
+// if(calendar_svc_iter_get_info(iter, (cal_struct**)&cal_event_from_db.event_legacy) != CAL_SUCCESS) {
+// calendar_svc_iter_remove(&iter);
+// return CALENDAR_ERROR_NONE; // consider this as no data
+// }
+//
+// if(cal_event_from_db.event_legacy == NULL) {
+// calendar_svc_iter_remove(&iter);
+// return CALENDAR_ERROR_NONE; // consider this as no data
+// }
+//
+// //execute callback
+// callback_return = callback((calendar_todo_h)&cal_event_from_db, user_data);
+//
+// calendar_svc_struct_free((cal_struct**)&cal_event_from_db.event_legacy);
+//
+// if(callback_return == false) {
+// break;
+// }
+// }
+// calendar_svc_iter_remove(&iter);
+//
+// return CALENDAR_ERROR_NONE;
+// }
+// return CALENDAR_ERROR_NONE;
+//}
+//
+//int _calendar_calendar_query(calendar_foreach_query_calendar_book_cb callback,
+// int account_db_id, int calendar_db_id,
+// const char* string_to_find, void* user_data)
+//{
+// int ret_val = 0;
+// cal_iter* iter = NULL;
+// bool callback_return = true;
+// int search_field;
+//
+// search_field = CALS_SEARCH_FIELD_NONE;
+// search_field |= CALS_SEARCH_FIELD_SUMMARY;
+// search_field |= CALS_SEARCH_FIELD_DESCRIPTION;
+// search_field |= CALS_SEARCH_FIELD_LOCATION;
+// search_field |= CALS_SEARCH_FIELD_ATTENDEE;
+//
+// ret_val = calendar_svc_event_search(search_field, string_to_find, &iter);
+//
+// if (ret_val != CAL_SUCCESS) {
+// LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+// return CALENDAR_ERROR_DB_FAILED;
+// }
+//
+// if (iter == NULL) {
+// LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+// return CALENDAR_ERROR_DB_FAILED;
+// } else {
+// while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
+// cal_struct *calendar_struct = NULL;
+// if(calendar_svc_iter_get_info(iter, &calendar_struct) != CAL_SUCCESS) {
+// calendar_svc_iter_remove(&iter);
+// return CALENDAR_ERROR_NONE; // consider this as no data
+// }
+//
+// if(calendar_struct == NULL) {
+// calendar_svc_iter_remove(&iter);
+// return CALENDAR_ERROR_NONE; // consider this as no data
+// }
+//
+// calendar_query_calendar_book_s query_data;
+//
+// query_data.calendar_db_id = calendar_svc_struct_get_int(calendar_struct, CAL_TABLE_INT_INDEX);
+// query_data.calendar_name = _calendar_safe_strdup(calendar_svc_struct_get_str(calendar_struct, CAL_TABLE_TXT_NAME));
+// query_data.calendar_is_default = query_data.calendar_db_id == 1 ? true : false;
+// query_data.calendar_is_visible = calendar_svc_struct_get_int(calendar_struct, CAL_TABLE_INT_VISIBILITY) == 1 ? true : false;
+// _calendar_parse_color(calendar_svc_struct_get_str(calendar_struct, CAL_TABLE_TXT_COLOR),
+// &query_data.calendar_color_red, &query_data.calendar_color_green, &query_data.calendar_color_blue);
+// query_data.account_db_id = calendar_svc_struct_get_int(calendar_struct, CAL_TABLE_INT_ACCOUNT_ID);
+//
+// //execute callback
+// callback_return = callback(&query_data, user_data);
+//
+// _calendar_safe_free(query_data.calendar_name);
+//
+// calendar_svc_struct_free(&calendar_struct);
+//
+// if(callback_return == false) {
+// break;
+// }
+// }
+// calendar_svc_iter_remove(&iter);
+//
+// return CALENDAR_ERROR_NONE;
+// }
+// return CALENDAR_ERROR_NONE;
+//}
+//
+//int _calendar_event_query(calendar_foreach_query_event_cb callback, int calendar_db_id, char* option, const char* string_to_find, void* user_data)
+//{
+// int ret_val = 0;
+// cal_iter* iter = NULL;
+// bool callback_return = true;
+//
+// int account_id = _calendar_get_account_db_id(calendar_db_id);
+// CALENDAR_INVALID_ARG_CHECK(account_id == -2);
+//
+// //fetch from DB
+// ret_val = calendar_svc_find_event_list(account_id, option, string_to_find, &iter);
+//
+// if (ret_val != CAL_SUCCESS) {
+// LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+// return CALENDAR_ERROR_DB_FAILED;
+// }
+//
+// if (iter == NULL) {
+// LOGE("[%s] CALENDAR_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CALENDAR_ERROR_DB_FAILED);
+// return CALENDAR_ERROR_DB_FAILED;
+// }
+//
+// while (calendar_svc_iter_next(iter) == CAL_SUCCESS) {
+// calendar_event_s cal_event_from_db = {0,};
+// if(calendar_svc_iter_get_info(iter, (cal_struct**)&cal_event_from_db.event_legacy) != CAL_SUCCESS) {
+// calendar_svc_iter_remove(&iter);
+// return CALENDAR_ERROR_NONE; // consider this as no data
+// }
+//
+// if(cal_event_from_db.event_legacy == NULL) {
+// calendar_svc_iter_remove(&iter);
+// return CALENDAR_ERROR_NONE; // consider this as no data
+// }
+//
+// //execute callback
+// callback_return = callback((calendar_event_h)&cal_event_from_db, user_data);
+//
+// calendar_svc_struct_free((cal_struct**)&cal_event_from_db.event_legacy);
+// if(callback_return == false) {
+// break;
+// }
+// }
+// calendar_svc_iter_remove(&iter);
+//
+// return CALENDAR_ERROR_NONE;
+//}
int _calendar_get_account_db_id(int calendar_db_id)
{
@@ -223,7 +288,7 @@ void _calendar_parse_color(char* color_string, unsigned char* red, unsigned char
*red = 0;
*green = 0;
*blue = 0;
-
+
if(color_string == NULL) {
return;
}