Beta merge 2
[profile/ivi/wrt-plugins-tizen.git] / src / platform / Tizen / Messaging / FolderQueryGenerator.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  * FolderQueryGenerator.h
18  *
19  *  Created on: 2011. 10. 28.
20  *      Author: sangtai
21  */
22
23 #ifndef FOLDERQUERYGENERATOR_H_
24 #define FOLDERQUERYGENERATOR_H_
25
26 #include <API/Filter/IFilterVisitor.h>
27 #include <API/Filter/SortMode.h>
28
29 #include <map>
30
31 namespace TizenApis {
32 namespace Platform {
33 namespace Messaging {
34
35 class FolderQueryGenerator: public TizenApis::Api::Tizen::IFilterVisitor {
36
37 public:
38         enum QueryGeneratorMode {
39                 MODE_EMAIL, MODE_SMS_MMS
40         };
41
42 protected:
43         std::map<std::string, std::string> attributeMap;
44
45 private:
46         QueryGeneratorMode m_mode;
47         std::string m_query;
48         std::vector<std::string> m_queryVector;
49
50         int m_messageType;
51
52         std::vector<std::string> typeVector;
53
54         std::string m_currentType;
55
56         bool m_folderPathProcessing;
57
58         int m_accountId;
59         std::string m_folderpath;
60
61         static const std::string STRING_MATCH_EXACTLY;
62         static const std::string STRING_MATCH_CONTAINS;
63         static const std::string STRING_MATCH_STARTSWITH;
64         static const std::string STRING_MATCH_ENDSWITH;
65         static const std::string STRING_MATCH_CASESENSITIVE;
66
67         static const int ACCOUNT_ID_NOT_INITIALIZED;
68
69 public:
70         FolderQueryGenerator();
71         virtual ~FolderQueryGenerator();
72
73         void visitPreComposite(Api::Tizen::FilterType& type, int depth);
74         void visitInComposite(Api::Tizen::FilterType& type, int depth);
75         void visitPostComposite(Api::Tizen::FilterType& type, int depth);
76         void visitAttribute(std::string& attrName, Api::Tizen::MatchFlag& matchFlag,
77                         Api::Tizen::AnyArrayPtr& values, int depth);
78         void visitAttributeRange(std::string& attrName,
79                         Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue,
80                         int depth);
81         void visitID(Api::Tizen::AnyArrayPtr &value, int depth);
82
83         int getAccountId();
84         std::string getFolderPath();
85         bool isFolderPathExist();
86         void reset();
87
88 protected:
89         virtual bool getMatchExactlyClause(std::string& attrName,
90                         Api::Tizen::AnyPtr& value);
91         void visitAttributeEach(std::string& attrName,
92                         Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyPtr& value,
93                         int depth);
94
95 private:
96         std::string getMatchStartsWithClause(std::string& attrName,
97                         Api::Tizen::AnyPtr& value);
98         std::string getMatchEndsWithClause(std::string& attrName,
99                         Api::Tizen::AnyPtr& value);
100         std::string getMatchContainsClause(std::string& attrName,
101                         Api::Tizen::AnyPtr& value);
102
103 };
104
105 typedef DPL::SharedPtr<FolderQueryGenerator> FolderQueryGeneratorPtr;
106 } // namespace Platform
107 } // namespace WrtPlugins
108 }
109 #endif