[Contact] Refactoring API structures
[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" // 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"
61
62 class CalendarFilter: public TizenApis::Api::Tizen::IFilterVisitor
63 {
64 private:
65         std::string m_query;
66         static std::map<std::string, std::string> m_attributeMap;
67
68 public:
69         CalendarFilter();
70         virtual ~CalendarFilter();
71
72         virtual void visitPreComposite(TizenApis::Api::Tizen::FilterType& type, int depth);
73
74         virtual void visitInComposite(TizenApis::Api::Tizen::FilterType& type, int depth);
75
76         virtual void visitPostComposite(TizenApis::Api::Tizen::FilterType& type, int depth);
77
78         virtual void visitAttribute(std::string& attrName,
79                         TizenApis::Api::Tizen::MatchFlag& matchFlag,
80                         TizenApis::Api::Tizen::AnyPtr& matchValue,
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_ */