2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef _CALENDAR_FILTER_H_
19 #define _CALENDAR_FILTER_H_
22 #include <dpl/shared_ptr.h>
23 #include <API/Filter/IFilterVisitor.h>
24 #include <API/Filter/SortMode.h>
25 #include "API/Calendar/CalendarEvent.h"
26 #include "CalendarQuery.h"
27 #include <calendar-svc-provider.h>
29 using namespace TizenApis::Api::Calendar;
35 // List of attributes that can be used as the filter argument.
36 #define CALENDAR_FILTER_ATTRIBUTE_ID_UID "id.uid" // for event
37 #define CALENDAR_FILTER_ATTRIBUTE_ID "id" // for task
38 #define CALENDAR_FILTER_ATTRIBUTE_LAST_MODIFIED_DATE "lastModificationDate"
39 #define CALENDAR_FILTER_ATTRIBUTE_DESCRIPTION "description"
40 #define CALENDAR_FILTER_ATTRIBUTE_SUMMARY "summary"
41 #define CALENDAR_FILTER_ATTRIBUTE_IS_ALL_DAY "isAllDay"
42 #define CALENDAR_FILTER_ATTRIBUTE_START_DATE "startDate"
43 //#define CALENDAR_FILTER_ATTRIBUTE_DURATION "duration"
44 #define CALENDAR_FILTER_ATTRIBUTE_LOCATION "location"
45 #define CALENDAR_FILTER_ATTRIBUTE_LATITUDE "geolocation.latitude"
46 #define CALENDAR_FILTER_ATTRIBUTE_LONGITUDE "geolocation.longitude"
47 #define CALENDAR_FILTER_ATTRIBUTE_ORGANIZER "organizer"
48 #define CALENDAR_FILTER_ATTRIBUTE_VISIBILITY "visibility"
49 #define CALENDAR_FILTER_ATTRIBUTE_STATUS "status"
50 #define CALENDAR_FILTER_ATTRIBUTE_PRIORITY "priority"
51 //#define CALENDAR_FILTER_ATTRIBUTE_ALARMS "alarms"
52 #define CALENDAR_FILTER_ATTRIBUTE_CATEGORIES "categories"
53 //#define CALENDAR_FILTER_ATTRIBUTE_ATTENDEES "attendees"
54 #define CALENDAR_FILTER_ATTRIBUTE_DUE_DATE "dueDate"
55 #define CALENDAR_FILTER_ATTRIBUTE_COMPLETED_DATE "completedDate"
56 #define CALENDAR_FILTER_ATTRIBUTE_PROGRESS "progress"
57 #define CALENDAR_FILTER_ATTRIBUTE_IS_DETACHED "isDetached"
58 #define CALENDAR_FILTER_ATTRIBUTE_END_DATE "endDate"
59 #define CALENDAR_FILTER_ATTRIBUTE_AVAILABILITY "availability"
60 #define CALENDAR_FILTER_ATTRIBUTE_RECURRENCE_RULE "recurrenceRule"
62 class CalendarFilter: public TizenApis::Api::Tizen::IFilterVisitor
66 static std::map<std::string, std::string> m_attributeMap;
70 virtual ~CalendarFilter();
72 virtual void visitPreComposite(TizenApis::Api::Tizen::FilterType& type, int depth);
74 virtual void visitInComposite(TizenApis::Api::Tizen::FilterType& type, int depth);
76 virtual void visitPostComposite(TizenApis::Api::Tizen::FilterType& type, int depth);
78 virtual void visitAttribute(std::string& attrName,
79 TizenApis::Api::Tizen::MatchFlag& matchFlag,
80 TizenApis::Api::Tizen::AnyPtr& matchValue,
83 virtual void visitAttributeRange(std::string& attrName,
84 TizenApis::Api::Tizen::AnyPtr& initialValue,
85 TizenApis::Api::Tizen::AnyPtr& endValue,
88 std::string getResult() const;
90 bool executeQuery(std::string &query, CalendarEventListPtr calendarListPtr);
92 std::string makeQuerySortMode(TizenApis::Api::Tizen::SortModeArrayPtr attr);
95 bool convertToCalendar(calendar_query_s *query_log, CalendarEventListPtr calendarListPtr);
96 std::string convertStringToValue(const std::string attrName, const std::string valueString);
97 std::string concatenateFilterAttributes();
100 typedef DPL::SharedPtr<CalendarFilter> CalendarFilterPtr;
106 #endif /* _CALENDAR_FILTER_H_ */