Beta merge 2
[profile/ivi/wrt-plugins-tizen.git] / src / platform / API / Messaging / StorageChangesMessageGenerator.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  * StorageChangesMessageGenerator.h
18  *
19  *  Created on: 2011. 10. 28.
20  *      Author: sangtai
21  */
22
23 #ifndef STORAGECHANGESMESSAGEGENERATOR_H_
24 #define STORAGECHANGESMESSAGEGENERATOR_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 StorageChangesMessageGenerator: 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                                 StorageChangesMessageGenerator(Api::Messaging::IMessagePtr msg);
51                                 virtual ~StorageChangesMessageGenerator();
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::MatchFlag& matchFlag, Api::Tizen::AnyArrayPtr& values, int depth);
58                                 void visitAttributeRange(std::string& attrName, Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue, int depth);
59                                 bool getMatchFlagResult(Api::Tizen::AnyPtr& value, std::string& valueString, Api::Tizen::MatchFlag& matchFlag);
60                                 bool getCompareResult();                                                        
61                                 int getMessageType(){
62                                         return m_messageType;
63                                 };
64
65                         private:
66                                 std::string convertToEmfAttrName(std::string attrName);
67                                 bool getMatchExactlyClause(std::string& attrName, Api::Tizen::AnyPtr& value);
68                                 bool getMatchContainsClause(std::string& attrName, Api::Tizen::AnyPtr& value);
69                                 bool getMatchStartwithClause(std::string& attrName, Api::Tizen::AnyPtr& value);
70                                 bool getMatchEndwithClause(std::string& attrName, Api::Tizen::AnyPtr& value);                           
71                                 bool getBetweenRangeClause(struct tm initialValue, struct tm endValue);                         
72
73                                 void visitAttributeEach(std::string& attrName, Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyPtr& value, int depth);
74                                 int convertMessageType(std::string& stringType);
75                                 int convertFolderType(std::string& stringType);                         
76
77                                 struct tm convertToTimeFormat(const std::string& timeString);                   
78                                 std::string createTimeString(std::string& timeString);
79                                 std::string createFolderType(std::string& value);
80                                 std::string createPriorityType(std::string& value);
81                                 std::string createDateTimeType(Api::Tizen::AnyPtr& value);
82                                 void initAttributeMap();
83
84
85                         private:
86                                 int m_messageType;
87
88                                 std::vector<std::string> typeVector;
89                                 std::map<std::string, std::string> attributeMap;
90
91                                 std::vector<bool> m_result;
92                                 std::vector<int> m_operand;                             
93
94 //                              std::string m_id;
95                                 Api::Messaging::MessageType m_type;
96                                 Api::Messaging::FolderType m_folder;
97                                 struct tm m_dateTime;
98                                 std::string m_from;
99                                 std::vector<std::string> m_to;
100                                 std::vector<std::string> m_cc;
101                                 std::vector<std::string> m_bcc;
102                                 std::string m_body;
103                                 bool m_isRead;
104                                 Api::Messaging::MessagePriority::Priority m_priority;
105                                 std::string m_subject;
106
107                                 Api::Messaging::RecipientsPtr Recipents;
108                                 std::string m_currentType;
109
110                                 static const int MESSAGE_TYPE_NOT_INITIALIZED;
111
112                 };
113
114                 typedef DPL::SharedPtr<StorageChangesMessageGenerator> StorageChangesMessageGeneratorPtr;
115         }               // namespace Platform
116 } // namespace WrtPlugins
117 }
118 #endif /* MESSAGEQUERYGENERATOR_H_ */