Update change log and spec for wrt-plugins-tizen_0.2.84
[framework/web/wrt-plugins-tizen.git] / src / platform / API / Calendar / CalendarEvent.cpp
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
18 #include <dpl/log/log.h>
19 #include <Commons/Exception.h>
20 #include "CalendarEvent.h"
21
22 namespace TizenApis {
23 namespace Api {
24 namespace Calendar {
25
26 CalendarEvent::CalendarEvent():
27     m_id(UNDEFINED_ITEM_ID),
28     m_parentId(UNDEFINED_PARENT_ID),
29     m_calendarId(UNDEFINED_CALENDAR_ID),
30     m_startTime(UNDEFINED_TIME),
31     m_endTime(UNDEFINED_TIME),
32     m_recurrence(new EventRecurrenceRule()),
33     m_status(UNDEFINED_STATUS),
34     m_alarms(new EventAlarmList()),
35     m_categories(new StringArray()),
36     m_isAllDay(false),
37     m_lastModifiedDate(UNDEFINED_TIME),
38     m_visibility(PUBLIC_VISIBILITY),
39     m_availability(BUSY_FB),
40     m_uid(UNDEFINED_ID),
41     m_recurrenceId(UNDEFINED_TIME),
42     m_attendees(new EventAttendeeList()),
43     m_isDetached(false),
44     m_attributesOfInterest(new AttributeList()),
45     m_latitude(UNDEFINED_GEO),
46     m_longitude(UNDEFINED_GEO),
47     m_timeZone(DEFAULT_TIMEZONE),
48     m_priority(LOW_PRIORITY),
49     m_createdDate(UNDEFINED_TIME),
50     m_completedDate(UNDEFINED_TIME),
51     m_progress(0),
52     m_calendarType(EVENT_TYPE)
53 {
54 }
55
56 CalendarEvent::CalendarEvent(const CalendarEvent &original)
57 {
58     LogDebug("Copy constructor called.");
59
60     m_id = original.getId();
61     m_parentId = original.getParentId();
62     m_calendarId = original.getCalendarId();
63     m_description = original.getDescription();
64     m_subject = original.getSubject();
65     m_startTime = original.getStartTime();
66     m_endTime = original.getEndTime();
67     m_location = original.getLocation();
68
69     EventRecurrenceRulePtr recurrenceRulePtr( new EventRecurrenceRule() );
70     m_recurrence = recurrenceRulePtr;
71     m_recurrence->setFrequency(original.getRecurrenceRule()->getFrequency());
72     m_recurrence->setInterval(original.getRecurrenceRule()->getInterval());
73     m_recurrence->setEndDate(original.getRecurrenceRule()->getEndDate());
74     m_recurrence->setOccurrenceCount(original.getRecurrenceRule()->getOccurrenceCount());
75     m_recurrence->setDaysOfTheMonth(original.getRecurrenceRule()->getDaysOfTheMonth());
76     m_recurrence->setDaysOfTheWeek(original.getRecurrenceRule()->getDaysOfTheWeek());
77     m_recurrence->setDaysOfTheYear(original.getRecurrenceRule()->getDaysOfTheYear());
78     m_recurrence->setWeeksOfTheYear(original.getRecurrenceRule()->getWeeksOfTheYear());
79     m_recurrence->setSetPosition(original.getRecurrenceRule()->getSetPosition());
80     m_recurrence->setExceptions(original.getRecurrenceRule()->getExceptions());
81     m_recurrence->setTimeZone(original.getRecurrenceRule()->getTimeZone());
82
83     m_status = original.getStatus();
84
85     LogDebug("Copying alarms...");
86     EventAlarmListPtr alarmsPtr( new EventAlarmList() );
87     m_alarms = alarmsPtr;
88     for( unsigned int i=0; i<original.getAlarms()->size(); i++) {
89         EventAlarmPtr alarmPtr( new EventAlarm() );
90         alarmPtr->setAbsoluteDate(original.getAlarms()->at(i)->getAbsoluteDate());
91         alarmPtr->setDuration(original.getAlarms()->at(i)->getDuration());
92         alarmPtr->setMethods(original.getAlarms()->at(i)->getMethods());
93         alarmPtr->setTimeZone(original.getAlarms()->at(i)->getTimeZone());
94         alarmPtr->setDescription(original.getAlarms()->at(i)->getDescription());
95         m_alarms->push_back(alarmPtr);
96     }
97
98     StringArrayPtr categoriesPtr( new StringArray() );
99     m_categories = categoriesPtr;
100     *m_categories = *(original.getCategories());
101
102     m_isAllDay = original.getIsAllDay();
103     m_organizer = original.getOrganizer();
104     m_lastModifiedDate = original.getLastModifiedDate();
105     m_visibility = original.getVisibility();
106     m_availability = original.getAvailability();
107     m_uid = original.getUId();
108     m_recurrenceId = original.getRecurrenceId();
109
110     LogDebug("Copying attendees...");
111     EventAttendeeListPtr attendeesPtr( new EventAttendeeList() );
112     m_attendees = attendeesPtr;
113     for( unsigned int i=0; i<original.getAttendees()->size(); i++) {
114         EventAttendeePtr attendeePtr( new EventAttendee() );
115         attendeePtr->setName(original.getAttendees()->at(i)->getName());
116         attendeePtr->setURI(original.getAttendees()->at(i)->getURI());
117         attendeePtr->setRole(original.getAttendees()->at(i)->getRole());
118         attendeePtr->setStatus(original.getAttendees()->at(i)->getStatus());
119         attendeePtr->setRSVP(original.getAttendees()->at(i)->getRSVP());
120         attendeePtr->setType(original.getAttendees()->at(i)->getType());
121         attendeePtr->setGroup(original.getAttendees()->at(i)->getGroup());
122         attendeePtr->setDelegatorURI(original.getAttendees()->at(i)->getDelegatorURI());
123         attendeePtr->setDelegateURI(original.getAttendees()->at(i)->getDelegateURI());
124         attendeePtr->setAddressBookId(original.getAttendees()->at(i)->getAddressBookId());
125         attendeePtr->setContactId(original.getAttendees()->at(i)->getContactId());
126         m_attendees->push_back(attendeePtr);
127     }
128
129     m_isDetached = original.getIsDetached();
130
131     AttributeListPtr attributesPtr( new AttributeList() );
132     m_attributesOfInterest = attributesPtr;
133     *m_attributesOfInterest = *(original.getAttributesOfInterest());
134
135     m_latitude = original.getLatitude();
136     m_longitude = original.getLongitude();
137
138     m_timeZone = original.getTimeZone();
139     m_priority = original.getPriority();
140     m_createdDate = original.getCreatedDate();
141     m_completedDate = original.getCompletedDate();
142     m_progress = original.getProgress();
143     m_calendarType = original.getCalendarType();
144
145     LogDebug("Copying done.");
146 }
147
148 CalendarEvent::~CalendarEvent()
149 {
150 }
151
152 int CalendarEvent::getId() const
153 {
154     return m_id;
155 }
156
157 void CalendarEvent::setId(int value)
158 {
159     m_id = value;
160
161     // Set the uid also.
162     std::stringstream ss;
163     ss<<value;
164     m_uid = ss.str();
165     LogDebug("m_id: "<<m_id<<", m_uid: "<<m_uid);
166 }
167
168 void CalendarEvent::resetId()
169 {
170     m_id = UNDEFINED_ITEM_ID;
171     m_uid = "";
172 }
173
174 bool CalendarEvent::getIdIsSet() const
175 {
176     return !(m_id==UNDEFINED_ITEM_ID);
177 }
178
179 int CalendarEvent::getParentId() const
180 {
181     return m_parentId;
182 }
183
184 void CalendarEvent::setParentId(int value)
185 {
186     m_parentId = value;
187 }
188
189 int CalendarEvent::getCalendarId() const
190 {
191     return m_calendarId;
192 }
193
194 void CalendarEvent::setCalendarId(int value)
195 {
196     m_calendarId = value;
197 }
198
199 std::string CalendarEvent::getDescription() const
200 {
201     return m_description;
202 }
203
204 void CalendarEvent::setDescription(const std::string &value)
205 {
206     m_description = value;
207 }
208
209 std::string CalendarEvent::getSubject() const
210 {
211     return m_subject;
212 }
213
214 void CalendarEvent::setSubject(const std::string &value)
215 {
216     m_subject = value;
217 }
218
219 long long int CalendarEvent::getStartTime() const
220 {
221     return m_startTime;
222 }
223
224 void CalendarEvent::setStartTime(long long int value)
225 {
226     m_startTime = value;
227 }
228
229 long long int CalendarEvent::getEndTime() const
230 {
231     return m_endTime;
232 }
233
234 void CalendarEvent::setEndTime(long long int value)
235 {
236     m_endTime = value;
237 }
238
239 std::string CalendarEvent::getLocation() const
240 {
241     return m_location;
242 }
243
244 void CalendarEvent::setLocation(const std::string &value)
245 {
246     m_location = value;
247 }
248
249 EventRecurrenceRulePtr CalendarEvent::getRecurrenceRule() const
250 {
251     return m_recurrence;
252 }
253
254 void CalendarEvent::setRecurrenceRule(EventRecurrenceRulePtr value)
255 {
256     m_recurrence = value;
257 }
258
259 CalendarEvent::EventStatus CalendarEvent::getStatus() const
260 {
261     return m_status == UNDEFINED_STATUS ? TENTATIVE_STATUS : m_status;
262 }
263
264 void CalendarEvent::setStatus(EventStatus value)
265 {
266     m_status = value;
267 }
268
269 EventAlarmListPtr CalendarEvent::getAlarms() const
270 {
271     return m_alarms;
272 }
273 void CalendarEvent::setAlarms(const EventAlarmListPtr value)
274 {
275     m_alarms = value;
276 }
277
278 StringArrayPtr CalendarEvent::getCategories() const
279 {
280     return m_categories;
281 }
282 void CalendarEvent::setCategories(const StringArrayPtr value)
283 {
284     m_categories = value;
285 }
286
287 void CalendarEvent::display() const
288 {
289     LogDebug("m_id " << m_id);
290     LogDebug("m_parentId " << m_parentId);
291     LogDebug("m_calendarId " << m_calendarId);
292     LogDebug("m_calendarType " << m_calendarType);
293     LogDebug("m_description " << m_description);
294     LogDebug("m_subject " << m_subject);
295
296     LogDebug("m_startTime " << m_startTime);
297
298     LogDebug("m_endTime " << m_endTime);
299     LogDebug("m_location " << m_location);
300     LogDebug("m_recurrence " << m_recurrence);
301     LogDebug("m_status " << m_status);
302     LogDebug("m_isAllDay " << m_isAllDay);
303     LogDebug("m_organizer " << m_organizer);
304     LogDebug("m_lastModifiedDate " << m_lastModifiedDate);
305     LogDebug("m_visibility " << m_visibility);
306     LogDebug("m_availability " << m_availability);
307
308     if(m_recurrence->getFrequency()!=EventRecurrenceRule::NO_RECURRENCE) {
309         LogDebug("recurrence frequency " << m_recurrence->getFrequency());
310         LogDebug("recurrence interval " << m_recurrence->getInterval());
311         LogDebug("recurrence recurrenceCount " << m_recurrence->getOccurrenceCount());
312         LogDebug("recurrence endDate " << m_recurrence->getEndDate());
313     }
314 }
315
316 bool CalendarEvent::validate() const
317 {
318     LogInfo("Nothing to validate.");
319     return true;
320 }
321
322 bool CalendarEvent::getIsAllDay() const
323 {
324     return m_isAllDay;
325 }
326
327 void CalendarEvent::setIsAllDay(bool value)
328 {
329     m_isAllDay = value;
330 }
331
332 std::string CalendarEvent::getOrganizer() const
333 {
334     return m_organizer;
335 }
336
337 void CalendarEvent::setOrganizer(const std::string &value)
338 {
339     m_organizer = value;
340 }
341
342 long long int CalendarEvent::getLastModifiedDate() const
343 {
344     return m_lastModifiedDate;
345 }
346
347 void CalendarEvent::setLastModifiedDate(long long int value)
348 {
349     m_lastModifiedDate = value;
350 }
351
352 CalendarEvent::EventVisibility CalendarEvent::getVisibility() const
353 {
354     return m_visibility == UNDEFINED_VISIBILITY ? PUBLIC_VISIBILITY : m_visibility;
355 }
356
357 void CalendarEvent::setVisibility(EventVisibility value)
358 {
359     m_visibility = value;
360 }
361
362 CalendarEvent::EventAvailability CalendarEvent::getAvailability() const
363 {
364     return m_availability == UNDEFINED_AVAILABILITY ? FREE_FB : m_availability;
365 }
366
367 void CalendarEvent::setAvailability(EventAvailability value)
368 {
369     m_availability = value;
370 }
371
372 std::string CalendarEvent::getUId() const
373 {
374     return m_uid;
375 }
376
377 void CalendarEvent::setUId(const std::string &value)
378 {
379     m_uid = value;
380 }
381
382 long long int CalendarEvent::getRecurrenceId() const
383 {
384     return m_recurrenceId;
385 }
386
387 void CalendarEvent::setRecurrenceId(long long int value)
388 {
389     m_recurrenceId = value;
390 }
391
392 EventAttendeeListPtr CalendarEvent::getAttendees() const
393 {
394     return m_attendees;
395 }
396
397 void CalendarEvent::setAttendees(const EventAttendeeListPtr value)
398 {
399     m_attendees = value;
400 }
401
402 bool CalendarEvent::getIsDetached() const
403 {
404     return m_isDetached;
405 }
406
407 void CalendarEvent::setIsDetached(bool value)
408 {
409     m_isDetached = value;
410 }
411
412 AttributeListPtr CalendarEvent::getAttributesOfInterest() const
413 {
414     return m_attributesOfInterest;
415 }
416
417 void CalendarEvent::setAttributesOfInterest(AttributeListPtr value)
418 {
419     m_attributesOfInterest = value;
420 }
421
422 double CalendarEvent::getLatitude() const
423 {
424     return m_latitude;
425 }
426
427 void CalendarEvent::setLatitude(double value)
428 {
429     m_latitude = value;
430 }
431
432 double CalendarEvent::getLongitude() const
433 {
434     return m_longitude;
435 }
436
437 void CalendarEvent::setLongitude(double value)
438 {
439     m_longitude = value;
440 }
441
442 std::string CalendarEvent::getTimeZone() const
443 {
444     return m_timeZone;
445 }
446
447 void CalendarEvent::setTimeZone(std::string value)
448 {
449     m_timeZone = value;
450 }
451
452 CalendarEvent::TaskPriority CalendarEvent::getPriority() const
453 {
454     return m_priority;
455 }
456
457 void CalendarEvent::setPriority(TaskPriority value)
458 {
459     m_priority = value;
460 }
461
462 long long int CalendarEvent::getCreatedDate() const
463 {
464     return m_createdDate;
465 }
466
467 void CalendarEvent::setCreatedDate(long long int value)
468 {
469     m_createdDate = value;
470 }
471
472 long long int CalendarEvent::getCompletedDate() const
473 {
474     return m_completedDate;
475 }
476
477 void CalendarEvent::setCompletedDate(long long int value)
478 {
479     m_completedDate = value;
480 }
481
482 int CalendarEvent::getProgress() const
483 {
484     return m_progress;
485 }
486
487 void CalendarEvent::setProgress(int value)
488 {
489     m_progress = value;
490 }
491
492 CalendarEvent::CalendarType CalendarEvent::getCalendarType() const
493 {
494     return m_calendarType;
495 }
496
497 void CalendarEvent::setCalendarType(CalendarType type)
498 {
499     m_calendarType = type;
500 }
501
502 }
503 }
504 }