Update change log and spec for wrt-plugins-tizen_0.4.9
[platform/framework/web/wrt-plugins-tizen.git] / src / Calendar / CalendarFilter.h
1 //
2 // Tizen Web Device API
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
19 #ifndef _CALENDAR_FILTER_H_
20 #define _CALENDAR_FILTER_H_
21
22 #include <string>
23 #include <dpl/shared_ptr.h>
24 #include <IFilterVisitor.h>
25 #include <SortMode.h>
26 #include "CalendarEvent.h"
27 #include <calendar2.h>
28
29 namespace DeviceAPI {
30 namespace Calendar {
31
32 // List of attributes that can be used as the filter argument.
33 #define CALENDAR_FILTER_ATTRIBUTE_ID_UID "id.uid" // for event
34 #define CALENDAR_FILTER_ATTRIBUTE_ID "id" // for task
35 #define CALENDAR_FILTER_ATTRIBUTE_LAST_MODIFIED_DATE "lastModificationDate"
36 #define CALENDAR_FILTER_ATTRIBUTE_DESCRIPTION "description"
37 #define CALENDAR_FILTER_ATTRIBUTE_SUMMARY "summary"
38 #define CALENDAR_FILTER_ATTRIBUTE_IS_ALL_DAY "isAllDay"
39 #define CALENDAR_FILTER_ATTRIBUTE_START_DATE "startDate"
40 #define CALENDAR_FILTER_ATTRIBUTE_LOCATION "location"
41 #define CALENDAR_FILTER_ATTRIBUTE_LATITUDE "geolocation.latitude"
42 #define CALENDAR_FILTER_ATTRIBUTE_LONGITUDE "geolocation.longitude"
43 #define CALENDAR_FILTER_ATTRIBUTE_ORGANIZER "organizer"
44 #define CALENDAR_FILTER_ATTRIBUTE_VISIBILITY "visibility"
45 #define CALENDAR_FILTER_ATTRIBUTE_STATUS "status"
46 #define CALENDAR_FILTER_ATTRIBUTE_PRIORITY "priority"
47 #define CALENDAR_FILTER_ATTRIBUTE_ALARMS "alarms"
48 #define CALENDAR_FILTER_ATTRIBUTE_CATEGORIES "categories"
49 #define CALENDAR_FILTER_ATTRIBUTE_ATTENDEES "attendees"
50 #define CALENDAR_FILTER_ATTRIBUTE_DUE_DATE "dueDate"
51 #define CALENDAR_FILTER_ATTRIBUTE_COMPLETED_DATE "completedDate"
52 #define CALENDAR_FILTER_ATTRIBUTE_PROGRESS "progress"
53 #define CALENDAR_FILTER_ATTRIBUTE_IS_DETACHED "isDetached"
54 #define CALENDAR_FILTER_ATTRIBUTE_END_DATE "endDate"
55 #define CALENDAR_FILTER_ATTRIBUTE_AVAILABILITY "availability"
56 #define CALENDAR_FILTER_ATTRIBUTE_RECURRENCE_RULE "recurrenceRule"
57
58 class CalendarFilter: public DeviceAPI::Tizen::IFilterVisitor
59 {
60 private:
61     CalendarEvent::CalendarType m_type;
62         calendar_query_h m_query;
63         calendar_filter_h m_filter;
64     calendar_list_h m_recordList;
65     int m_recordCount;
66         // Corner case handling for recurring event range filter.
67     calendar_list_h m_normalInstanceRecordList;
68     int m_normalInstanceRecordCount;
69     calendar_list_h m_alldayInstanceRecordList;
70     int m_alldayInstanceRecordCount;
71
72         static std::map<std::string, unsigned int> m_eventAttributeMap;
73         static std::map<std::string, unsigned int> m_taskAttributeMap;
74
75 public:
76         CalendarFilter();
77         virtual ~CalendarFilter();
78
79         virtual void visitPreComposite(DeviceAPI::Tizen::FilterType& type, int depth);
80
81         virtual void visitInComposite(DeviceAPI::Tizen::FilterType& type, int depth);
82
83         virtual void visitPostComposite(DeviceAPI::Tizen::FilterType& type, int depth);
84
85         virtual void visitAttribute(std::string& attrName,
86                         DeviceAPI::Tizen::MatchFlag& matchFlag,
87                         DeviceAPI::Tizen::AnyPtr& matchValue,
88                         int depth);
89
90         virtual void visitAttributeRange(std::string& attrName,
91                         DeviceAPI::Tizen::AnyPtr& initialValue,
92                         DeviceAPI::Tizen::AnyPtr& endValue,
93                         int depth);
94
95     void setType(CalendarEvent::CalendarType type);
96
97     void setCalendarId(int calendarId, bool isFilterSet);
98
99         void setSortMode(DeviceAPI::Tizen::SortModeArrayPtr attr);
100
101         void executeQuery();
102
103     int getResultRecordCount() const;
104
105         calendar_list_h getResultRecordList() const;
106
107         int getNormalInstanceResultRecordCount() const;
108
109         calendar_list_h getNormalInstanceResultRecordList() const;
110
111         int getAlldayInstanceResultRecordCount() const;
112
113         calendar_list_h getAlldayInstanceResultRecordList() const;
114
115 private:
116         int convertStringToIntValue(const std::string attrName, const std::string valueString);
117 };
118
119 typedef DPL::SharedPtr<CalendarFilter> CalendarFilterPtr;
120
121 }
122 }
123
124 #endif /* _CALENDAR_FILTER_H_ */