e03fd3311a6e01371b4720a3c96defae83aedbc1
[profile/ivi/wrt-plugins-tizen.git] / src / platform / Tizen / Calendar / CalendarFilter.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17
18 #ifndef _CALENDAR_FILTER_H_
19 #define _CALENDAR_FILTER_H_
20
21 #include <string>
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>
28
29 using namespace TizenApis::Api::Calendar;
30
31 namespace TizenApis {
32 namespace Platform {
33 namespace Calendar {
34
35 // List of attributes that can be used as the filter argument.
36 #define CALENDAR_FILTER_ATTRIBUTE_ID_UID "id.uid"
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_DURATION "duration"
43 #define CALENDAR_FILTER_ATTRIBUTE_LOCATION "location"
44 #define CALENDAR_FILTER_ATTRIBUTE_LATITUDE "geolocation.latitude"
45 #define CALENDAR_FILTER_ATTRIBUTE_LONGITUDE "geolocation.longitude"
46 #define CALENDAR_FILTER_ATTRIBUTE_ORGANIZER "organizer"
47 #define CALENDAR_FILTER_ATTRIBUTE_VISIBILITY "visibility"
48 #define CALENDAR_FILTER_ATTRIBUTE_STATUS "status"
49 #define CALENDAR_FILTER_ATTRIBUTE_PRIORITY "priority"
50 //#define CALENDAR_FILTER_ATTRIBUTE_ALARMS "alarms"
51 #define CALENDAR_FILTER_ATTRIBUTE_CATEGORIES "categories"
52 //#define CALENDAR_FILTER_ATTRIBUTE_ATTENDEES "attendees"
53 #define CALENDAR_FILTER_ATTRIBUTE_DUE_DATE "dueDate"
54 //#define CALENDAR_FILTER_ATTRIBUTE_COMPLETED_DATE "completedDate"
55 #define CALENDAR_FILTER_ATTRIBUTE_PROGRESS "progress"
56 //#define CALENDAR_FILTER_ATTRIBUTE_IS_DETACHED "isDetached"
57 #define CALENDAR_FILTER_ATTRIBUTE_END_DATE "endDate"
58 #define CALENDAR_FILTER_ATTRIBUTE_AVAILABILITY "availability"
59 //#define CALENDAR_FILTER_ATTRIBUTE_RECURRENCE_RULE "recurrenceRule"
60
61 class CalendarFilter: public TizenApis::Api::Tizen::IFilterVisitor
62 {
63 private:
64         std::string m_query;
65         static std::map<std::string, std::string> m_attributeMap;
66
67 public:
68         CalendarFilter();
69         virtual ~CalendarFilter();
70
71         virtual void visitPreComposite(TizenApis::Api::Tizen::FilterType& type, int depth);
72
73         virtual void visitInComposite(TizenApis::Api::Tizen::FilterType& type, int depth);
74
75         virtual void visitPostComposite(TizenApis::Api::Tizen::FilterType& type, int depth);
76
77         virtual void visitAttribute(std::string& attrName,
78                         TizenApis::Api::Tizen::AnyArrayPtr& matchValues,
79                         std::string& matchFlag,
80                         bool caseSensitive,
81                         int depth);
82
83         virtual void visitAttributeRange(std::string& attrName,
84                         TizenApis::Api::Tizen::AnyPtr& initialValue,
85                         TizenApis::Api::Tizen::AnyPtr& endValue,
86                         int depth);
87
88         std::string getResult() const;
89
90         bool executeQuery(std::string &query, CalendarEventListPtr calendarListPtr);
91
92         std::string makeQuerySortMode(TizenApis::Api::Tizen::SortModeArrayPtr attr);
93
94 private:
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();
98 };
99
100 typedef DPL::SharedPtr<CalendarFilter> CalendarFilterPtr;
101
102 }
103 }
104 }
105
106 #endif /* _CALENDAR_FILTER_H_ */