2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 #ifndef _CALENDAR_FILTER_H_
20 #define _CALENDAR_FILTER_H_
25 #include <dpl/shared_ptr.h>
26 #include <IFilterVisitor.h>
28 #include "CalendarEvent.h"
29 #include <calendar2.h>
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"
60 class CalendarFilter: public DeviceAPI::Tizen::IFilterVisitor
63 CalendarEvent::CalendarType m_type;
64 calendar_query_h m_query;
65 calendar_filter_h m_filter;
66 calendar_list_h m_recordList;
68 std::vector<calendar_filter_h> m_compositeFilters;
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;
82 bool m_enableInstanceSearch;
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;
91 virtual ~CalendarFilter();
93 virtual void visitPreComposite(DeviceAPI::Tizen::FilterType& type, int depth);
95 virtual void visitInComposite(DeviceAPI::Tizen::FilterType& type, int depth);
97 virtual void visitPostComposite(DeviceAPI::Tizen::FilterType& type, int depth);
99 virtual void visitAttribute(std::string& attrName,
100 DeviceAPI::Tizen::MatchFlag& matchFlag,
101 DeviceAPI::Tizen::AnyPtr& matchValue,
104 virtual void visitAttributeRange(std::string& attrName,
105 DeviceAPI::Tizen::AnyPtr& initialValue,
106 DeviceAPI::Tizen::AnyPtr& endValue,
109 void setType(CalendarEvent::CalendarType type);
111 void setCalendarId(int calendarId, bool isFilterSet);
113 void setSortMode(DeviceAPI::Tizen::SortModeArrayPtr attr);
117 int getResultRecordCount() const;
119 calendar_list_h getResultRecordList() const;
121 int getNormalInstanceResultRecordCount() const;
123 calendar_list_h getNormalInstanceResultRecordList() const;
125 int getAlldayInstanceResultRecordCount() const;
127 calendar_list_h getAlldayInstanceResultRecordList() const;
130 int convertStringToIntValue(const std::string attrName, const std::string valueString);
132 long long int getTimeTFromTZDateAny(DeviceAPI::Tizen::AnyPtr &any) const;
135 typedef DPL::SharedPtr<CalendarFilter> CalendarFilterPtr;
140 #endif /* _CALENDAR_FILTER_H_ */