[misc] modified priority from vcalendar
authorJeesun Kim <iamjs.kim@samsung.com>
Mon, 1 Apr 2013 10:09:38 +0000 (19:09 +0900)
committerJeesun Kim <iamjs.kim@samsung.com>
Mon, 1 Apr 2013 10:09:38 +0000 (19:09 +0900)
common/cal_vcalendar_make.c
common/cal_vcalendar_parse.c
include/calendar_types2.h

index 7945f9f..96443cb 100644 (file)
@@ -325,8 +325,26 @@ int __cal_vcalendar_make_organizer(cal_make_s *b, char *cn, char *address)
 
 static inline int __cal_vcalendar_make_priority(cal_make_s *b, int v)
 {
+       int prio = 0;
        char tmp[2];
-       snprintf(tmp, sizeof(tmp), "%d", v);
+
+       switch (v)
+       {
+       case CALENDAR_EVENT_PRIORITY_HIGH:
+               prio = 3;       // one out of 1 ~ 4.
+               break;
+       case CALENDAR_EVENT_PRIORITY_NORMAL:
+               prio = 5;
+               break;
+       case CALENDAR_EVENT_PRIORITY_LOW:
+               prio = 7; // one out of 6 ~ 9.
+               break;
+       default:
+               prio = 0; // means none.
+               break;
+       }
+
+       snprintf(tmp, sizeof(tmp), "%d", prio);
        __cal_vcalendar_make_printf(b, "PRIORITY:", tmp);
        return CALENDAR_ERROR_NONE;
 }
index 04466fc..aba1aeb 100644 (file)
@@ -1011,6 +1011,7 @@ static int __cal_vcalendar_parse_location(int type, calendar_list_h list, calend
 static int __cal_vcalendar_parse_priority(int type, calendar_list_h list, calendar_record_h record, char *prop, char *cont)
 {
        int ret;
+       int prio = 0;
        char *p = (char *)cont;
 
        p++;
@@ -1019,13 +1020,36 @@ static int __cal_vcalendar_parse_priority(int type, calendar_list_h list, calend
                return -1;
        }
 
+       switch (atoi(p))
+       {
+       case 1:
+       case 2:
+       case 3:
+       case 4:
+               prio = CALENDAR_TODO_PRIORITY_HIGH;
+               break;
+       case 5:
+               prio = CALENDAR_TODO_PRIORITY_NORMAL;
+               break;
+       case 6:
+       case 7:
+       case 8:
+       case 9:
+               prio = CALENDAR_TODO_PRIORITY_LOW;
+               break;
+       default:
+               prio = CALENDAR_TODO_PRIORITY_NONE;
+               break;
+       }
+
        switch (type)
        {
        case CALENDAR_BOOK_TYPE_EVENT:
-               ret = _cal_record_set_int(record, _calendar_event.priority, atoi(p));
+
+               ret = _cal_record_set_int(record, _calendar_event.priority, prio);
                break;
        case CALENDAR_BOOK_TYPE_TODO:
-               ret = _cal_record_set_int(record, _calendar_todo.priority, atoi(p));
+               ret = _cal_record_set_int(record, _calendar_todo.priority, prio);
                break;
        }
        return CALENDAR_ERROR_NONE;
index 975db0a..6b9ecd9 100644 (file)
@@ -317,9 +317,10 @@ typedef enum
  */
 typedef enum
 {
-    CALENDAR_EVENT_PRIORITY_LOW          = 0,  /**< Low priority */
-    CALENDAR_EVENT_PRIORITY_NORMAL,                            /**< Normal priority */
-    CALENDAR_EVENT_PRIORITY_HIGH                               /**< High priority */
+       CALENDAR_EVENT_PRIORITY_NONE            = 0x01, /**< Priority none */
+    CALENDAR_EVENT_PRIORITY_LOW         = 0x08,        /**< Low priority */
+    CALENDAR_EVENT_PRIORITY_NORMAL             = 0x04, /**< Normal priority */
+    CALENDAR_EVENT_PRIORITY_HIGH               = 0x02, /**< High priority */
 } calendar_event_priority_e;
 
 /**