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_
23 #include <dpl/shared_ptr.h>
24 #include <IFilterVisitor.h>
26 #include "CalendarEvent.h"
27 #include <calendar2.h>
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"
58 class CalendarFilter: public DeviceAPI::Tizen::IFilterVisitor
61 CalendarEvent::CalendarType m_type;
62 calendar_query_h m_query;
63 calendar_filter_h m_filter;
64 calendar_list_h m_recordList;
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;
72 static std::map<std::string, unsigned int> m_eventAttributeMap;
73 static std::map<std::string, unsigned int> m_taskAttributeMap;
77 virtual ~CalendarFilter();
79 virtual void visitPreComposite(DeviceAPI::Tizen::FilterType& type, int depth);
81 virtual void visitInComposite(DeviceAPI::Tizen::FilterType& type, int depth);
83 virtual void visitPostComposite(DeviceAPI::Tizen::FilterType& type, int depth);
85 virtual void visitAttribute(std::string& attrName,
86 DeviceAPI::Tizen::MatchFlag& matchFlag,
87 DeviceAPI::Tizen::AnyPtr& matchValue,
90 virtual void visitAttributeRange(std::string& attrName,
91 DeviceAPI::Tizen::AnyPtr& initialValue,
92 DeviceAPI::Tizen::AnyPtr& endValue,
95 void setType(CalendarEvent::CalendarType type);
97 void setCalendarId(int calendarId, bool isFilterSet);
99 void setSortMode(DeviceAPI::Tizen::SortModeArrayPtr attr);
103 int getResultRecordCount() const;
105 calendar_list_h getResultRecordList() const;
107 int getNormalInstanceResultRecordCount() const;
109 calendar_list_h getNormalInstanceResultRecordList() const;
111 int getAlldayInstanceResultRecordCount() const;
113 calendar_list_h getAlldayInstanceResultRecordList() const;
116 int convertStringToIntValue(const std::string attrName, const std::string valueString);
119 typedef DPL::SharedPtr<CalendarFilter> CalendarFilterPtr;
124 #endif /* _CALENDAR_FILTER_H_ */