Check valid record while vcalendar composing 77/155377/1 accepted/tizen/unified/20171016.064309 submit/tizen/20171013.052117
authorJeesun Kim <iamjs.kim@samsung.com>
Fri, 13 Oct 2017 05:15:42 +0000 (14:15 +0900)
committerJeesun Kim <iamjs.kim@samsung.com>
Fri, 13 Oct 2017 05:15:52 +0000 (14:15 +0900)
Change-Id: I36491f36c83b9d504f9bbc65a1764360a2599bb1

common/cal_vcalendar_make.c

index d174b93..632ba88 100644 (file)
@@ -2100,6 +2100,7 @@ static int __make_vcalendar(cal_make_s *b, calendar_list_h list)
        RETV_IF(NULL == b, CALENDAR_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == list, CALENDAR_ERROR_INVALID_PARAMETER);
 
+       bool valid_count = 0;
        int ret = CALENDAR_ERROR_NONE;
        calendar_record_h record = NULL;
 
@@ -2116,11 +2117,13 @@ static int __make_vcalendar(cal_make_s *b, calendar_list_h list)
                DBG("uri[%s]", uri);
 
                if (CAL_STRING_EQUAL == strcmp(uri, _calendar_event._uri)) {
+                       valid_count++;
                        b->type = CALENDAR_BOOK_TYPE_EVENT;
                        __devide_vcalendar_with_header(b, record);
                        _cal_vcalendar_make_schedule(b, record);
 
                } else if (CAL_STRING_EQUAL == strcmp(uri, _calendar_todo._uri)) {
+                       valid_count++;
                        b->type = CALENDAR_BOOK_TYPE_TODO;
                        __devide_vcalendar_with_header(b, record);
                        _cal_vcalendar_make_schedule(b, record);
@@ -2145,6 +2148,12 @@ static int __make_vcalendar(cal_make_s *b, calendar_list_h list)
                }
 
        } while (CALENDAR_ERROR_NO_DATA != calendar_list_next(list));
+
+       if (0 == valid_count) {
+               DBG("There is no valid records");
+               return CALENDAR_ERROR_INVALID_PARAMETER;
+       }
+
        __make_footer(b);
 
        return CALENDAR_ERROR_NONE;
@@ -2179,6 +2188,5 @@ int cal_vcalendar_make_vcalendar(cal_make_s *b, calendar_list_h list)
        b->version = version;
        DBG("make as version(%d)", version);
 
-       __make_vcalendar(b, list);
-       return CALENDAR_ERROR_NONE;
+       return __make_vcalendar(b, list);
 }