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