diff options
Diffstat (limited to 'src/contacts_event.c')
-rwxr-xr-x | src/contacts_event.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/contacts_event.c b/src/contacts_event.c index 7ca2228..6d791c3 100755 --- a/src/contacts_event.c +++ b/src/contacts_event.c @@ -44,6 +44,22 @@ int contact_birthday_create(contact_birthday_h* birthday) return CONTACTS_ERROR_NONE; } +int contact_anniversary_create(contact_anniversary_h* anniversary) +{ + CONTACTS_NULL_ARG_CHECK(anniversary); + + CTSvalue* ret = contacts_svc_value_new(CTS_VALUE_EVENT); + if(ret == NULL) { + LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY); + return CONTACTS_ERROR_OUT_OF_MEMORY; + } + contacts_svc_value_set_int(ret, CTS_EVENT_VAL_TYPE_INT, CTS_EVENT_TYPE_ANNIVERSARY); + *anniversary = (contact_anniversary_h)ret; + + return CONTACTS_ERROR_NONE; +} + + int contact_birthday_destroy(contact_birthday_h birthday) { CONTACTS_NULL_ARG_CHECK(birthday); @@ -56,6 +72,17 @@ int contact_birthday_destroy(contact_birthday_h birthday) return CONTACTS_ERROR_INVALID_PARAMETER; } +int contact_anniversary_destroy(contact_anniversary_h anniversary) +{ + CONTACTS_NULL_ARG_CHECK(anniversary); + + if(contacts_svc_value_free((CTSvalue*)anniversary) == CTS_SUCCESS) { + return CONTACTS_ERROR_NONE; + } + + LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER); + return CONTACTS_ERROR_INVALID_PARAMETER; +} int contact_birthday_get_date(contact_birthday_h birthday, int *year, int *month, int *day) { @@ -76,6 +103,26 @@ int contact_birthday_get_date(contact_birthday_h birthday, int *year, int *month return CONTACTS_ERROR_NONE; } +int contact_anniversary_get_date(contact_anniversary_h anniversary, int *year, int *month, int *day) +{ + CONTACTS_NULL_ARG_CHECK(anniversary); + CONTACTS_NULL_ARG_CHECK(year); + CONTACTS_NULL_ARG_CHECK(month); + CONTACTS_NULL_ARG_CHECK(day); + + CTSvalue * CTSevent = (CTSvalue *)anniversary; + int date = contacts_svc_value_get_int(CTSevent, CTS_EVENT_VAL_DATE_INT); + if(date == 0) { + *year = *month = *day = 0; + } else { + *year = date / 10000; + *month = date % 10000 / 100; + *day = date % 100; + } + return CONTACTS_ERROR_NONE; +} + + int contact_birthday_set_date(contact_birthday_h birthday, int year, int month, int day) { CONTACTS_NULL_ARG_CHECK(birthday); @@ -86,3 +133,12 @@ int contact_birthday_set_date(contact_birthday_h birthday, int year, int month, return CONTACTS_ERROR_NONE; } +int contact_anniversary_set_date(contact_anniversary_h anniversary, int year, int month, int day) +{ + CONTACTS_NULL_ARG_CHECK(anniversary); + + CTSvalue * CTSevent = (CTSvalue *)anniversary; + contacts_svc_value_set_int(CTSevent, CTS_EVENT_VAL_DATE_INT, year*10000 + month*100 + day); + + return CONTACTS_ERROR_NONE; +} |