Update change log and spec for wrt-plugins-tizen_0.4.63
[framework/web/wrt-plugins-tizen.git] / src / Messaging / FolderQueryGenerator.h
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 #ifndef FOLDERQUERYGENERATOR_H_
19 #define FOLDERQUERYGENERATOR_H_
20
21 #include <IFilterVisitor.h>
22 #include <SortMode.h>
23
24 #include <map>
25
26 namespace DeviceAPI {
27 namespace Messaging {
28
29 class FolderQueryGenerator: public DeviceAPI::Tizen::IFilterVisitor {
30
31 public:
32         enum QueryGeneratorMode {
33                 MODE_EMAIL, MODE_SMS_MMS
34         };
35
36 protected:
37         std::map<std::string, std::string> attributeMap;
38
39 private:
40         QueryGeneratorMode m_mode;
41         std::string m_query;
42         std::vector<std::string> m_queryVector;
43
44         int m_messageType;
45
46         std::vector<std::string> typeVector;
47
48         std::string m_currentType;
49
50         bool m_folderPathProcessing;
51
52         int m_accountId;
53         std::string m_folderpath;
54
55         static const std::string STRING_MATCH_EXACTLY;
56         static const std::string STRING_MATCH_CONTAINS;
57         static const std::string STRING_MATCH_STARTSWITH;
58         static const std::string STRING_MATCH_ENDSWITH;
59         static const std::string STRING_MATCH_EXISTS;
60
61         static const int ACCOUNT_ID_NOT_INITIALIZED;
62
63 public:
64         FolderQueryGenerator();
65         virtual ~FolderQueryGenerator();
66
67         void visitPreComposite(DeviceAPI::Tizen::FilterType& type, int depth);
68         void visitInComposite(DeviceAPI::Tizen::FilterType& type, int depth);
69         void visitPostComposite(DeviceAPI::Tizen::FilterType& type, int depth);
70         void visitAttribute(std::string& attrName, DeviceAPI::Tizen::MatchFlag& matchFlag,
71                         DeviceAPI::Tizen::AnyPtr& matchValue, int depth);
72         void visitAttributeRange(std::string& attrName,
73                         DeviceAPI::Tizen::AnyPtr& initialValue, DeviceAPI::Tizen::AnyPtr& endValue,
74                         int depth);
75
76         int getAccountId();
77         std::string getFolderPath();
78         bool isFolderPathExist();
79         void reset();
80
81 protected:
82         virtual bool getMatchExactlyClause(std::string& attrName,
83                         DeviceAPI::Tizen::AnyPtr& value);
84         virtual bool getMatchExistClause(std::string& attrName);
85         void visitAttributeEach(std::string& attrName,
86                         DeviceAPI::Tizen::MatchFlag& matchFlag, DeviceAPI::Tizen::AnyPtr& value,
87                         int depth);
88
89 private:
90         std::string getMatchStartsWithClause(std::string& attrName,
91                         DeviceAPI::Tizen::AnyPtr& value);
92         std::string getMatchEndsWithClause(std::string& attrName,
93                         DeviceAPI::Tizen::AnyPtr& value);
94         std::string getMatchContainsClause(std::string& attrName,
95                         DeviceAPI::Tizen::AnyPtr& value);
96
97 };
98
99 typedef DPL::SharedPtr<FolderQueryGenerator> FolderQueryGeneratorPtr;
100 }
101 }
102 #endif