2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include "FolderQueryGenerator.h"
19 #include "FolderFilterValidatorFactory.h"
20 #include "ConversationFilterValidatorFactory.h"
21 #include "IMessagingTypes.h"
23 #include <Commons/Exception.h>
24 #include <email-types.h>
28 using namespace DeviceAPI::Tizen;
33 const std::string FolderQueryGenerator::STRING_MATCH_EXACTLY = "EXACTLY";
34 const std::string FolderQueryGenerator::STRING_MATCH_CONTAINS = "CONTAINS";
35 const std::string FolderQueryGenerator::STRING_MATCH_STARTSWITH = "STARTSWITH";
36 const std::string FolderQueryGenerator::STRING_MATCH_ENDSWITH = "ENDSWITH";
37 const std::string FolderQueryGenerator::STRING_MATCH_EXISTS = "EXISTS";
39 const int FolderQueryGenerator::ACCOUNT_ID_NOT_INITIALIZED = -1;
41 FolderQueryGenerator::FolderQueryGenerator():m_messageType(ACCOUNT_ID_NOT_INITIALIZED) {
44 FolderQueryGenerator::~FolderQueryGenerator() {
48 void FolderQueryGenerator::visitPreComposite(DeviceAPI::Tizen::FilterType& type, int depth){
52 void FolderQueryGenerator::visitInComposite(DeviceAPI::Tizen::FilterType& type, int depth){
55 if(type != INTERSECTION_FILTER){
56 LoggerE("[ERROR] >>> invalid Filter type:" << type);
57 ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "invalid Fiilter Type");
62 void FolderQueryGenerator::visitPostComposite(DeviceAPI::Tizen::FilterType& type, int depth){
66 bool FolderQueryGenerator::getMatchExactlyClause(std::string& attrName, DeviceAPI::Tizen::AnyPtr& value)
68 std::string retClause;
69 std::string valueString = value->toString();
72 if(attrName.compare(FolderFilterValidatorFactory::ATTRIBUTE_ACCOUNTID)==0){
73 m_accountId = atoi(value->toString().c_str());
75 }else if(attrName.compare(FolderFilterValidatorFactory::ATTRIBUTE_FOLDERPATH)==0){
76 m_folderPathProcessing = TRUE;
77 m_folderpath = value->toString();
85 bool FolderQueryGenerator::getMatchExistClause(std::string& attrName)
87 std::string retClause;
90 if(attrName.compare(FolderFilterValidatorFactory::ATTRIBUTE_ACCOUNTID)==0){
102 std::string FolderQueryGenerator::getMatchStartsWithClause(std::string& attrName, DeviceAPI::Tizen::AnyPtr& value){
103 std::string retClause;
104 LoggerD("<<< NOT IMPLEMENTED YET");
108 std::string FolderQueryGenerator::getMatchEndsWithClause(std::string& attrName, DeviceAPI::Tizen::AnyPtr& value){
109 std::string retClause;
110 LoggerD("<<< NOT IMPLEMENTED YET");
114 std::string FolderQueryGenerator::getMatchContainsClause(std::string& attrName, DeviceAPI::Tizen::AnyPtr& value){
115 std::string retClause;
116 LoggerD("<<< NOT IMPLEMENTED YET");
120 void FolderQueryGenerator::visitAttribute(std::string& attrName, DeviceAPI::Tizen::MatchFlag& matchFlag,
121 DeviceAPI::Tizen::AnyPtr& matchValue, int depth){
122 LoggerD("<<< attrName:[" << attrName << "], matchFlag:[" << matchFlag << "]");
124 if(matchValue == NULL)
127 LoggerD("matchValue:" << matchValue->toString());
129 visitAttributeEach(attrName, matchFlag, matchValue, depth);
134 void FolderQueryGenerator::visitAttributeEach(std::string& attrName, DeviceAPI::Tizen::MatchFlag& matchFlag, DeviceAPI::Tizen::AnyPtr& value, int depth){
135 LoggerD("<<< attrName:[" << attrName << "], value:[" << value->toString() << "]");
137 if(matchFlag == DeviceAPI::Tizen::MATCH_EXACTLY){
138 LoggerD("STRING_MATCH_EXACTLY");
139 getMatchExactlyClause(attrName, value);
140 }else if(matchFlag == DeviceAPI::Tizen::MATCH_CONTAINS){
141 LoggerD("STRING_MATCH_CONTAINS");
142 getMatchContainsClause(attrName, value);
143 }else if(matchFlag== DeviceAPI::Tizen::MATCH_STARTSWITH){
144 LoggerD("STRING_MATCH_STARTSWITH");
145 getMatchStartsWithClause(attrName, value);
146 }else if(matchFlag == DeviceAPI::Tizen::MATCH_ENDSWITH){
147 LoggerD("STRING_MATCH_ENDSWITH");
148 getMatchEndsWithClause(attrName, value);
149 }else if(matchFlag == DeviceAPI::Tizen::MATCH_EXISTS){
150 LoggerD("STRING_MATCH_EXISTS");
151 getMatchExistClause(attrName);
153 LoggerD("[ERROR]invalid match flag[" << matchFlag << "]");
154 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid match flag:[" << matchFlag << "]");
159 void FolderQueryGenerator::visitAttributeRange(std::string& attrName, DeviceAPI::Tizen::AnyPtr& initialValue, DeviceAPI::Tizen::AnyPtr& endValue, int depth) {
160 LoggerD("<<< NOT IMPLEMENTED YET");
163 int FolderQueryGenerator::getAccountId()
168 std::string FolderQueryGenerator::getFolderPath()
173 bool FolderQueryGenerator::isFolderPathExist()
175 LoggerE("m_folderPathProcessing : " << m_folderPathProcessing);
176 return m_folderPathProcessing;
179 void FolderQueryGenerator::reset(){
180 m_folderPathProcessing = FALSE;
182 m_folderpath.clear();