7314e00a2746cedd50a6b62dca3395d08210fdeb
[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,
40                                         MODE_SMS_MMS
41                                 };
42
43                         protected:
44                                 std::map<std::string, std::string> attributeMap;
45
46                         private:
47                                 QueryGeneratorMode m_mode;
48                                 std::string m_query;
49                                 std::vector<std::string> m_queryVector;
50
51                                 int m_messageType;
52
53                                 std::vector<std::string> typeVector;
54
55                                 std::string m_currentType;
56
57                                 bool m_folderPathProcessing;
58
59                                 int m_accountId;
60                                 std::string m_folderpath;
61
62                                 static const std::string STRING_MATCH_EXACTLY;
63                                 static const std::string STRING_MATCH_CONTAINS;
64                                 static const std::string STRING_MATCH_STARTSWITH;
65                                 static const std::string STRING_MATCH_ENDSWITH;
66                                 static const std::string STRING_MATCH_CASESENSITIVE;
67
68                                 static const int ACCOUNT_ID_NOT_INITIALIZED;
69
70                         public:
71                                 FolderQueryGenerator();
72                                 virtual ~FolderQueryGenerator();
73
74                                 void visitPreComposite(Api::Tizen::FilterType& type, int depth);
75                                 void visitInComposite(Api::Tizen::FilterType& type, int depth);
76                                 void visitPostComposite(Api::Tizen::FilterType& type, int depth);
77                                 void visitAttribute(std::string& attrName,      Api::Tizen::AnyArrayPtr& values, std::string& matchFlag, bool caseSensitive, int depth);
78                                 void visitAttributeRange(std::string& attrName, Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue, int depth);
79                                 void visitID(Api::Tizen::AnyArrayPtr &value, int depth);
80
81                                 int getAccountId();
82                                 std::string getFolderPath();    
83                                 bool isFolderPathExist();
84                                 void reset();                           
85
86                         protected:
87                                 virtual bool getMatchExactlyClause(std::string& attrName, Api::Tizen::AnyPtr& value);
88                                 void visitAttributeEach(std::string& attrName, Api::Tizen::AnyPtr& value, std::string& matchFlag, int depth);                           
89
90                         private:
91                                 std::string getMatchStartsWithClause(std::string& attrName, Api::Tizen::AnyPtr& value);
92                                 std::string getMatchEndsWithClause(std::string& attrName, Api::Tizen::AnyPtr& value);
93                                 std::string getMatchContainsClause(std::string& attrName, Api::Tizen::AnyPtr& value);
94
95                 };
96
97                 typedef DPL::SharedPtr<FolderQueryGenerator> FolderQueryGeneratorPtr;
98         }               // namespace Platform
99 } // namespace WrtPlugins
100 }
101 #endif