235b4b4a147944e2b1091ae57868dd4f8047e4a9
[framework/web/wrt-plugins-common.git] / src / modules / API / Calendar / CalendarEvent.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /**
17  * @file        CalendarEvent.h
18  * @author      Lukasz Marek (l.marek@samsung.com)
19  * @version     0.1
20  */
21
22 #ifndef WRTDEVICEAPIS_CALENDAR_CALENDAR_EVENT_H_
23 #define WRTDEVICEAPIS_CALENDAR_CALENDAR_EVENT_H_
24
25 #include <ctime>
26 #include <string>
27 #include <vector>
28 #include <dpl/optional.h>
29 #include <dpl/shared_ptr.h>
30
31 namespace WrtDeviceApis {
32 namespace Calendar {
33 namespace Api {
34
35 typedef std::vector<std::string> CategoryList;
36 typedef DPL::SharedPtr<CategoryList> CategoryListPtr;
37
38 /* This object represents a single calendar event */
39 class CalendarEvent
40 {
41   public:
42
43     static const int UNDEFINED_CALENDAR_ID = -1;
44
45     typedef enum
46     {
47         NO_RECURRENCE,                  //The calendar entry occurs once
48         DAILY_RECURRENCE,               //The calendar entry occurs every day
49         WEEKLY_RECURRENCE,              //The calendar entry occurs every week e.g. every Monday
50         MONTHLY_RECURRENCE,             //The calendar entry occurs every month e.g. every 3rd day of month
51         YEARLY_RECURRENCE,              //The calendar entry occurs every year  e.g. every June 1st
52         WEEKDAY_RECURRENCE,             //The calendar entry occurs Mon-Fri every week
53         MONTHLY_ON_DAY_RECURRENCE,      //The calendar entry occurs on the same weekday or weekend every month, e.g., every second Tuesday each month.
54         INVALID_RECURRENCE = 10000,
55         UNDEFINED_RECURRENCE            /* should be used only to mark a fact filter is not set */
56     } EventRecurrence;
57
58     typedef enum
59     {
60         TENTATIVE_STATUS,
61         CONFIRMED_STATUS,
62         CANCELLED_STATUS,
63         INVALID_STATUS = 10000,
64         UNDEFINED_STATUS                /* should be used only to mark a fact filter is not set */
65     } EventStatus;
66
67     typedef enum
68     {
69         NO_ALARM,
70         SILENT_ALARM,
71         SOUND_ALARM,
72         INVALID_ALARM_TYPE = 10000,
73         UNDEFINED_ALARM_TYPE            /* should be used only to mark a fact filter is not set */
74     } EventAlarmType;
75
76     CalendarEvent();
77     virtual ~CalendarEvent();
78
79     int getId() const;
80     void setId(int value);
81     void resetId();
82
83     int getCalendarId() const;
84     void setCalendarId(int value);
85
86     std::string getDescription() const;
87     void setDescription(const std::string &value);
88
89     std::string getSubject() const;
90     void setSubject(const std::string &value);
91
92     time_t getStartTime() const;
93     void setStartTime(time_t value);
94
95     time_t getEndTime() const;
96     void setEndTime(time_t value);
97
98     std::string getLocation() const;
99     void setLocation(const std::string &value);
100
101     EventRecurrence getRecurrence() const;
102     void setRecurrence(EventRecurrence value);
103
104     EventStatus getStatus() const;
105     void setStatus(EventStatus value);
106
107     time_t getAlarmTime() const;
108     void setAlarmTime(time_t value);
109     void resetAlarmTime();
110
111     EventAlarmType getAlarmType() const;
112     void setAlarmType(EventAlarmType value);
113
114     CategoryListPtr getCategories() const;
115     void setCategories(const CategoryListPtr &value);
116
117     time_t getExpires() const;
118     void setExpires(time_t value);
119     void resetExpires();
120
121     int getInterval() const;
122     void setInterval(int value);
123
124     void display() const;
125     bool validate() const;
126
127     bool getIdIsSet() const;
128     bool getAlarmTimeIsSet() const;
129     bool getExpiresIsSet() const;
130
131   protected:
132     DPL::Optional<int> m_id;
133     int m_calendarId;
134     std::string m_description;
135     std::string m_subject;
136     std::time_t m_startTime;
137     std::time_t m_endTime;
138     std::string m_location;
139     EventRecurrence m_recurrence;
140     EventStatus m_status;
141     DPL::Optional<std::time_t> m_alarmTime;
142     EventAlarmType m_alarmType;
143     CategoryListPtr m_categories;
144     DPL::Optional<std::time_t> m_expires;
145     int m_interval;
146 };
147
148 typedef DPL::SharedPtr<CalendarEvent> CalendarEventPtr;
149
150 }
151 }
152 }
153
154 #endif // WRTDEVICEAPIS_CALENDAR_CALENDAR_EVENT_H_
155