Remove hardcoded path for multiuser support
[platform/core/system/sync-agent.git] / src / fw-plugins / common-public / vcalendar / include / vcalendar_string_util.h
1 /*
2  * sync-agent
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #ifndef IN_VCALENDAR_STRING_UTIL_H_
19 #define IN_VCALENDAR_STRING_UTIL_H_
20
21 #include <stdio.h>
22 #include <string.h>
23 #include <stdlib.h>
24 #include <glib/gprintf.h>
25
26 #include <calendar2.h>
27 #include <calendar_types2.h>
28 #include <unicode/ucal.h>
29 #include <unicode/ustring.h>
30 #include <unicode/ustdio.h>
31 #include <unicode/udat.h>
32 #include <sys/types.h>
33
34 #include "utility/sync_util.h"
35 #include "data-adapter/error.h"
36
37 #include <tzplatform_config.h>
38
39 typedef enum cal_date_type {
40         CALENDAR_DATE_TYPE_ONTIME = 0,
41         CALENDAR_DATE_TYPE_YEAR,
42         CALENDAR_DATE_TYPE_MONTH,
43         CALENDAR_DATE_TYPE_WEEK,
44         CALENDAR_DATE_TYPE_DAY,
45         CALENDAR_DATE_TYPE_HOUR,
46         CALENDAR_DATE_TYPE_MINUTE,
47         CALENDAR_DATE_TYPE_SECOND,
48 } calendar_date_type_e;
49
50 typedef enum cal_exdate_type {
51         CALENDAR_EXDATE_TYPE_NONE = 0,
52         CALENDAR_EXDATE_TYPE_DELETED,
53         CALENDAR_EXDATE_TYPE_UPDATED_PARENT,
54         CALENDAR_EXDATE_TYPE_UPDATED_CHILD,
55         CALENDAR_EXDATE_TYPE_MAX,
56 } calendar_exdate_type_e;
57
58 typedef struct sync_agent_calendar_exdate_s sync_agent_calendar_exdate_t;
59
60 struct sync_agent_calendar_exdate_s {
61         calendar_exdate_type_e exdate_type;
62         int exdate_count;
63         GList *exdate_list;
64 };
65
66 #define RRULE_KEYWORD                                   "\r\nRRULE:"
67 #define RRULE_KEYWORD_FREQ_DAILY                RRULE_KEYWORD"FREQ=DAILY"
68 #define RRULE_KEYWORD_FREQ_WEEKLY               RRULE_KEYWORD"FREQ=WEEKLY"
69 #define RRULE_KEYWORD_FREQ_MONTHLY              RRULE_KEYWORD"FREQ=MONTHLY"
70 #define RRULE_KEYWORD_FREQ_YEARLY               RRULE_KEYWORD"FREQ=YEARLY"
71
72 #define RRULE_KEYWORD_INTERVAL                  "INTERVAL="
73 #define RRULE_KEYWORD_BYDAY                             "BYDAY="
74 #define RRULE_KEYWORD_BYMONTH                   "BYMONTH="
75 #define RRULE_KEYWORD_BYMONTHDAY                "BYMONTHDAY="
76 #define RRULE_KEYWORD_UNTIL                             "UNTIL="
77 #define RRULE_KEYWORD_COUNT                             "COUNT="
78
79 #define MAX_RRULE_DATE_KEYWORD                  "20361231T"
80 #define WEEKDAY_RRULE_ORIGIN_KEYWORD    RRULE_KEYWORD"W0 "
81 #define WEEKDAY_RRULE_CONVERTED_KEYWORD RRULE_KEYWORD"W1 MO TU WE TH FR "
82
83 #define DTSTART_KEYWORD                                 "DTSTART:"
84 #define DTEND_KEYWORD                                   "DTEND:"
85 #define AALARM_KEYWORD                                  "AALARM:"
86 #define END_VEVENT_KEYWORD                              "END:VEVENT"
87 #define SUMMARY_KEYWORD                                 "SUMMARY:"
88 #define TIMEZONE_GMT                                    "Etc/GMT"
89 #define ALLDAY_PREFIX                                   "X-ALLDAY:"
90
91 #define EXTYPE_UID_KEYWORD                              "\r\nUID:"
92 #define EXTYPE_DELETE_KEYWORD                   "X-EXTYPE:1"
93 #define EXTYPE_UPDATE_KEYWORD                   "X-EXTYPE:2"
94 #define IMPORT_EXTYPE_DELETE_KEYWORD    "\r\nX-EXTYPE:1\r\nEXDATE:"
95 #define IMPORT_EXTYPE_UPDATE_KEYWORD    "\r\nX-EXTYPE:2\r\nEXDATE:"
96 #define EXDATE_KEYWORD                                  "\r\nEXDATE:"
97
98 #define CALENDAR_IMAGE_KEYWORD_SNOTE    "snote" // refer to Cal-svc.h (calendar\include)
99 #define CALENDAR_IMAGE_KEYWORD_PHOTO    "photo" // refer to Cal-svc.h (calendar\include)
100 #define IMAGE_KEYWORD_PREFIX_SNOTE              "X-SS-ATTACH-SNOTE;"
101 #define IMAGE_KEYWORD_PREFIX_PHOTO              "X-SS-ATTACH-IMAGE;"
102 #define IMAGE_KEYWORD_BEGIN_PATH                "PATH=3D"
103 #define IMAGE_KEYWORD_END_PATH                  "=3bDATE=3D\r\n"
104
105 #define INTERNAL_MEMORY_ORIGIN                  tzplatform_getenv(TZ_USER_CONTENT)
106 #define INTERNAL_MEMORY_CONVERTED               "Internal=3a"
107 #define EXTERNAL_MEMORY_ORIGIN                  tzplatform_mkpath(TZ_SYS_STORAGE,"sdcard")
108 #define EXTERNAL_MEMORY_CONVERTED               "External=3a"
109 #define SNOTE_MEMORY_ORIGIN                     tzplatform_mkpath(TZ_USER_APP,"com.samsung.smemo/data/")
110
111 #define EXDATE_LENGTH                                   16 // length of "20130211T000000Z"
112
113
114 char * get_value_by_token(const char *src, const char *token, const char *end_of_token);
115 char * replace_string(char *origin, const char *src, const char *dest);
116
117 calendar_list_h set_vcalendar_version(calendar_record_h cal_record);
118 void set_timezone(const char *origin, calendar_record_h cal_record);
119 void set_allday(const char *origin, calendar_record_h calendar_record, bool is_phone_to_kies);
120
121 char * remove_uid(char *origin);
122 char * insert_exdate_data(char *origin, sync_agent_calendar_exdate_t *exdate_struct, int index);
123 char * has_image_import(const char *origin);
124 char * has_image_export(calendar_record_h cal_record);
125 void get_exdate_data(calendar_record_h cal_record, sync_agent_calendar_exdate_t *exdate_struct);
126
127 char * replace_rrule_data(char *origin);
128 char * replace_image_data(char *origin, char *image_path);
129 void replace_deleted_exdate_data(const char *origin, calendar_record_h parent_record);
130 int replace_updated_exdate_data(const char *origin, calendar_record_h parent_record);
131
132 #endif                          /* IN_VCALENDAR_STRING_UTIL_H_ */