2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @file CalendarTask.cpp
18 * @author Shi Hezhang (hezhang.shi@samsung.com)
19 * @author Pan Rui (r.pan@samsung.com)
23 #include "CalendarTask.h"
24 #include <dpl/log/log.h>
27 const int UNDEFINED_TASK_ID = -1;
30 namespace WrtDeviceApis {
34 CalendarTask::CalendarTask() :
35 m_id(UNDEFINED_TASK_ID),
36 m_taskId(UNDEFINED_TASK_ID),
37 m_dueDate(UNDEFINED_TASK_TIME_T_VALUE),
38 m_status(UNDEFINED_STATUS),
39 m_priority(UNDEFINED_PRIORITY),
40 m_descriptionIsSet(false),
45 CalendarTask::~CalendarTask()
49 bool CalendarTask::getIdIsSet() const
51 return m_id != UNDEFINED_TASK_ID;
54 bool CalendarTask::getTaskIdIsSet() const
56 return m_taskId != UNDEFINED_TASK_ID;
59 bool CalendarTask::getDescriptionIsSet() const
61 return m_descriptionIsSet;
64 bool CalendarTask::getSubjectIsSet() const
66 return m_subjectIsSet;
69 bool CalendarTask::getDueDateIsSet() const
71 return m_dueDate >= 0;
74 bool CalendarTask::getStatusIsSet() const
76 return m_status != UNDEFINED_STATUS;
79 bool CalendarTask::getPriorityIsSet() const
81 return m_priority != UNDEFINED_PRIORITY;
84 int CalendarTask::getTaskId() const
89 void CalendarTask::setTaskId(int value)
94 int CalendarTask::getId() const
99 void CalendarTask::setId(int value)
104 std::string CalendarTask::getDescription() const
106 return m_description;
109 void CalendarTask::setDescription(const std::string &value)
111 m_descriptionIsSet = true;
112 m_description = value;
115 std::string CalendarTask::getSubject() const
120 void CalendarTask::setSubject(const std::string &value)
122 m_subjectIsSet = true;
126 time_t CalendarTask::getDueDate() const
128 return m_dueDate > 0 ? m_dueDate : 0;
131 void CalendarTask::setDueDate(time_t value)
136 CalendarTask::TaskStatus CalendarTask::getStatus() const
138 return m_status == UNDEFINED_STATUS ? STATUS_NEEDS_ACTION : m_status;
141 void CalendarTask::setStatus(TaskStatus value)
146 CalendarTask::TaskPriority CalendarTask::getPriority() const
148 return m_priority == UNDEFINED_PRIORITY ? LOW_PRIORITY : m_priority;
151 void CalendarTask::setPriority(TaskPriority value)
156 void CalendarTask::display() const
158 LogDebug("m_id " << m_id);
159 LogDebug("m_calendarId " << m_taskId);
160 LogDebug("m_description " << m_description);
161 LogDebug("m_subject " << m_subject);
162 LogDebug("m_dueDate " << m_dueDate);
163 LogDebug("m_status " << m_status);
164 LogDebug("m_priority " << m_priority);
167 bool CalendarTask::validate() const
169 if (m_dueDate == -1) {
170 LogError("Incorrect due time value detected");
173 if (m_status == CalendarTask::INVALID_STATUS) {
174 LogError("Incorrect status value detected");
177 if (m_priority == CalendarTask::INVALID_PRIORITY) {
178 LogError("Incorrect priority value detected");