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_CASESENSITIVE = "CASESENSITIVE";
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 std::string FolderQueryGenerator::getMatchStartsWithClause(std::string& attrName, DeviceAPI::Tizen::AnyPtr& value){
86 std::string retClause;
87 LoggerD("<<< NOT IMPLEMENTED YET");
91 std::string FolderQueryGenerator::getMatchEndsWithClause(std::string& attrName, DeviceAPI::Tizen::AnyPtr& value){
92 std::string retClause;
93 LoggerD("<<< NOT IMPLEMENTED YET");
97 std::string FolderQueryGenerator::getMatchContainsClause(std::string& attrName, DeviceAPI::Tizen::AnyPtr& value){
98 std::string retClause;
99 LoggerD("<<< NOT IMPLEMENTED YET");
103 void FolderQueryGenerator::visitAttribute(std::string& attrName, DeviceAPI::Tizen::MatchFlag& matchFlag,
104 DeviceAPI::Tizen::AnyPtr& matchValue, int depth){
105 LoggerD("<<< attrName:[" << attrName << "], matchFlag:[" << matchFlag << "]");
107 if(matchValue == NULL)
110 LoggerD("matchValue:" << matchValue->toString());
112 visitAttributeEach(attrName, matchFlag, matchValue, depth);
117 void FolderQueryGenerator::visitAttributeEach(std::string& attrName, DeviceAPI::Tizen::MatchFlag& matchFlag, DeviceAPI::Tizen::AnyPtr& value, int depth){
118 LoggerD("<<< attrName:[" << attrName << "], value:[" << value->toString() << "]");
120 if(matchFlag == DeviceAPI::Tizen::MATCH_EXACTLY){
121 LoggerD("STRING_MATCH_EXACTLY");
122 getMatchExactlyClause(attrName, value);
123 }else if(matchFlag == DeviceAPI::Tizen::MATCH_CONTAINS){
124 LoggerD("STRING_MATCH_CONTAINS");
125 getMatchContainsClause(attrName, value);
126 }else if(matchFlag== DeviceAPI::Tizen::MATCH_STARTSWITH){
127 LoggerD("STRING_MATCH_STARTSWITH");
128 getMatchStartsWithClause(attrName, value);
129 }else if(matchFlag == DeviceAPI::Tizen::MATCH_ENDSWITH){
130 LoggerD("STRING_MATCH_ENDSWITH");
131 getMatchEndsWithClause(attrName, value);
133 LoggerD("[ERROR]invalid match flag[" << matchFlag << "]");
134 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid match flag:[" << matchFlag << "]");
139 void FolderQueryGenerator::visitAttributeRange(std::string& attrName, DeviceAPI::Tizen::AnyPtr& initialValue, DeviceAPI::Tizen::AnyPtr& endValue, int depth) {
140 LoggerD("<<< NOT IMPLEMENTED YET");
143 int FolderQueryGenerator::getAccountId()
148 std::string FolderQueryGenerator::getFolderPath()
153 bool FolderQueryGenerator::isFolderPathExist()
155 LoggerE("m_folderPathProcessing : " << m_folderPathProcessing);
156 return m_folderPathProcessing;
159 void FolderQueryGenerator::reset(){
160 m_folderPathProcessing = FALSE;
162 m_folderpath.clear();