09ac05d1ae0535a3fddc2d99c7b9c29bfa012299
[profile/ivi/wrt-plugins-tizen.git] / src / platform / API / Messaging / StorageChangesConversationGenerator.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  * StorageChangesConversationGenerator.h
18  *
19  *  Created on: 2011. 10. 28.
20  *      Author: sangtai
21  */
22
23 #ifndef STORAGECHANGESCONVERSATIONGENERATOR_H_
24 #define STORAGECHANGESCONVERSATIONGENERATOR_H_
25
26 #include <API/Filter/IFilterVisitor.h>
27 #include <API/Filter/SortMode.h>
28 #include <API/Messaging/IMessaging.h>
29
30 #include <map>
31
32 namespace TizenApis {
33         namespace Platform {
34                 namespace Messaging {
35
36
37 //              using namespace std;
38
39                 class StorageChangesConversationGenerator: public TizenApis::Api::Tizen::IFilterVisitor{
40                         public:
41
42                                 enum operandType
43                                 {
44                                         leftblank = 1,
45                                         rightblank = 2,
46                                         operandUnion = 3,
47                                         operandIntersection = 4
48                                 };
49                                 
50                                 StorageChangesConversationGenerator(Api::Messaging::IConversationPtr conv);
51                                 virtual ~StorageChangesConversationGenerator();
52
53                                 void visitPreComposite(Api::Tizen::FilterType& type, int depth);
54                                 void visitInComposite(Api::Tizen::FilterType& type, int depth);
55                                 void visitPostComposite(Api::Tizen::FilterType& type, int depth);
56                                 void visitAttribute(std::string& attrName,
57                                                 Api::Tizen::AnyArrayPtr& values, std::string& matchFlag, bool caseSensitive, int depth);
58
59                                 void visitAttributeRange(std::string& attrName, Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue, int depth);
60
61                                 bool getMatchFlagResult(Api::Tizen::AnyPtr& value, std::string& valueString, std::string& matchFlag);
62                                 bool getCompareResult();                                                        
63
64                         private:
65                                 bool getMatchExactlyClause(std::string& attrName, Api::Tizen::AnyPtr& value);
66                                 bool getMatchContainsClause(std::string& attrName, Api::Tizen::AnyPtr& value);
67                                 bool getMatchStartwithClause(std::string& attrName, Api::Tizen::AnyPtr& value);
68                                 bool getMatchEndwithClause(std::string& attrName, Api::Tizen::AnyPtr& value);                           
69                                 bool getBetweenRangeClause(struct tm initialValue, struct tm endValue);                         
70
71                                 void visitAttributeEach(std::string& attrName, Api::Tizen::AnyPtr& value, std::string& matchFlag, int depth);
72                                 int convertMessageType(std::string& stringType);
73                                 std::string convertBooleanStringToIntegerString(std::string& booleanString);
74
75                                 struct tm convertToTimeFormat(const std::string& timeString);                   
76                                 std::string createTimeString(std::string& timeString);
77                                 std::string createFolderType(std::string& value);
78                                 std::string createPriorityType(std::string& value);
79                                 std::string createDateTimeType(Api::Tizen::AnyPtr& value);
80
81                         private:
82                                 int m_messageType;
83
84                                 std::vector<std::string> typeVector;
85                                 std::map<std::string, std::string> attributeMap;
86
87                                 std::vector<bool> m_result;
88                                 std::vector<int> m_operand;                             
89
90 //                              unsigned int m_Id;
91                                 unsigned short int m_type;
92                                 time_t m_time;
93                                 unsigned long m_messageCount;
94                                 unsigned long m_unreadMessages;
95                                 std::string m_preview;
96                                 bool m_read;
97                                 std::string m_from;
98                                 std::string m_subject;
99                                 std::vector<std::string> m_to;
100                                 std::vector<std::string> m_cc;
101                                 std::vector<std::string> m_bcc;
102                                 unsigned int m_lastMessageId;
103
104                                 Api::Messaging::RecipientsPtr Recipents;
105                                 std::string m_currentType;
106
107                                 static const std::string STRING_MATCH_EXCACTLY;
108                                 static const std::string STRING_MATCH_CONTAINS;
109                                 static const std::string STRING_MATCH_STARTSWITH;
110                                 static const std::string STRING_MATCH_ENDSWITH;
111                                 static const std::string STRING_MATCH_CASESENSITIVE;
112
113                                 static const int MESSAGE_TYPE_NOT_INITIALIZED;
114
115                 };
116
117                 typedef DPL::SharedPtr<StorageChangesConversationGenerator> StorageChangesConversationGeneratorPtr;
118         }               // namespace Platform
119 } // namespace WrtPlugins
120 }
121 #endif /* MESSAGEQUERYGENERATOR_H_ */