65aa7c51ac8e2aab51c706efedf659b0d6596c2b
[framework/web/wrt-plugins-common.git] / src / modules / tizen / Task / TaskWrapper.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        TaskWrapper.h
18  * @author      Shi Hezhang (hezhang.shi@samsung.com)
19  * @author      Pan Rui (r.pan@samsung.com)
20  * @version     0.1
21  */
22
23 #ifndef WRTDEVICEAPIS_TASK_TASK_WRAPPER_H_
24 #define WRTDEVICEAPIS_TASK_TASK_WRAPPER_H_
25
26 #include <string>
27 #include <calendar-svc-provider.h>
28 #include <calendar-svc-errors.h>
29 #include <dpl/shared_ptr.h>
30 #include <Task/CalendarTask.h>
31 #include <Task/TaskFilter.h>
32
33 namespace WrtDeviceApis {
34 namespace Task {
35
36 const int PLATFORM_UNSUPPORTED_DATE_YEAR = 69;
37
38 class TaskWrapper
39 {
40   public:
41     TaskWrapper();
42     explicit TaskWrapper(const Api::CalendarTaskPtr &task);
43     virtual ~TaskWrapper();
44     cal_struct *convertAbstractTaskToPlatformTask();
45     Api::CalendarTaskPtr convertPlatformTaskToAbstractTask();
46     cal_struct *getPlatformTask() const;
47     Api::CalendarTaskPtr getAbstractTask() const;
48     void freePlatformTask();
49     void saveTask();
50     void loadTask(int id);
51     void deleteTask();
52     bool matchFilters(Api::TaskFilterPtr filter);
53
54   protected:
55     int getIDFromPlatformTask() const;
56     int getStatusFromPlatformTask() const;
57     int getPriorityFromPlatformTask() const;
58
59     void setDescriptionToPlatformTask();
60     void setSubjectToPlatformTask();
61     void setDueDateToPlatformTask();
62     void setStatusToPlatformTask();
63     void setPriorityToPlatformTask();
64     void setIDToPlatformTask();
65
66     void setDescriptionFromPlatformTask();
67     void setSubjectFromPlatformTask();
68     void setDueDateFromPlatformTask();
69     void setStatusFromPlatformTask();
70     void setPriorityFromPlatformTask();
71     void setIDFromPlatformTask();
72   private:
73     //temporaty solution to cover plafrorm bug
74     //int calendar_svc_struct_set_int(cal_struct* record, const char* field, int intval);
75
76     void displayAbstractTask();     //only for debugging
77     void displayPlatformTask();     //only for debugging
78
79     cal_struct             *m_platformTask;
80     Api::CalendarTaskPtr m_abstractTask;
81 };
82
83 typedef DPL::SharedPtr<TaskWrapper> TaskWrapperPtr;
84 }
85 }
86 #endif // WRTDEVICEAPIS_TASK_TASK_WRAPPER_H_