2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * FolderQueryGenerator.cpp
19 * Created on: 2011. 10. 28.
23 #include "FolderQueryGenerator.h"
24 #include "API/Messaging/FolderFilterValidatorFactory.h"
25 #include "API/Messaging/ConversationFilterValidatorFactory.h"
27 #include <API/Messaging/IMessagingTypes.h>
28 #include <API/Messaging/log.h>
29 #include <Commons/Exception.h>
31 #include <email-types.h>
33 #include <dpl/log/log.h>
36 using namespace TizenApis::Api::Tizen;
43 const std::string FolderQueryGenerator::STRING_MATCH_EXACTLY = "EXACTLY";
44 const std::string FolderQueryGenerator::STRING_MATCH_CONTAINS = "CONTAINS";
45 const std::string FolderQueryGenerator::STRING_MATCH_STARTSWITH = "STARTSWITH";
46 const std::string FolderQueryGenerator::STRING_MATCH_ENDSWITH = "ENDSWITH";
47 // const std::string FolderQueryGenerator::STRING_MATCH_CASESENSITIVE = "CASESENSITIVE";
49 const int FolderQueryGenerator::ACCOUNT_ID_NOT_INITIALIZED = -1;
51 FolderQueryGenerator::FolderQueryGenerator():m_messageType(ACCOUNT_ID_NOT_INITIALIZED) {
54 FolderQueryGenerator::~FolderQueryGenerator() {
58 void FolderQueryGenerator::visitPreComposite(Api::Tizen::FilterType& type, int depth){
62 void FolderQueryGenerator::visitInComposite(Api::Tizen::FilterType& type, int depth){
65 if(type != INTERSECTION_FILTER){
66 LogError("[ERROR] >>> invalid Filter type:" << type);
67 ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "invalid Fiilter Type");
72 void FolderQueryGenerator::visitPostComposite(Api::Tizen::FilterType& type, int depth){
76 bool FolderQueryGenerator::getMatchExactlyClause(std::string& attrName, Api::Tizen::AnyPtr& value)
78 std::string retClause;
79 std::string valueString = value->toString();
82 if(attrName.compare(FolderFilterValidatorFactory::ATTRIBUTE_ACCOUNTID)==0){
83 m_accountId = atoi(value->toString().c_str());
85 }else if(attrName.compare(FolderFilterValidatorFactory::ATTRIBUTE_FOLDERPATH)==0){
86 m_folderPathProcessing = TRUE;
87 m_folderpath = value->toString();
95 std::string FolderQueryGenerator::getMatchStartsWithClause(std::string& attrName, TizenApis::Api::Tizen::AnyPtr& value){
96 std::string retClause;
97 LogDebug("<<< NOT IMPLEMENTED YET");
101 std::string FolderQueryGenerator::getMatchEndsWithClause(std::string& attrName, TizenApis::Api::Tizen::AnyPtr& value){
102 std::string retClause;
103 LogDebug("<<< NOT IMPLEMENTED YET");
107 std::string FolderQueryGenerator::getMatchContainsClause(std::string& attrName, TizenApis::Api::Tizen::AnyPtr& value){
108 std::string retClause;
109 LogDebug("<<< NOT IMPLEMENTED YET");
113 void FolderQueryGenerator::visitAttribute(std::string& attrName, Api::Tizen::MatchFlag& matchFlag,
114 Api::Tizen::AnyPtr& matchValue, int depth){
115 LogDebug("<<< attrName:[" << attrName << "], matchFlag:[" << matchFlag << "]");
117 if(matchValue == NULL)
120 LogDebug("matchValue:" << matchValue->toString());
122 visitAttributeEach(attrName, matchFlag, matchValue, depth);
127 void FolderQueryGenerator::visitAttributeEach(std::string& attrName, Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyPtr& value, int depth){
128 LogDebug("<<< attrName:[" << attrName << "], value:[" << value->toString() << "]");
130 if(matchFlag == Api::Tizen::MATCH_EXACTLY){
131 LogDebug("STRING_MATCH_EXACTLY");
132 getMatchExactlyClause(attrName, value);
133 }else if(matchFlag == Api::Tizen::MATCH_CONTAINS){
134 LogDebug("STRING_MATCH_CONTAINS");
135 getMatchContainsClause(attrName, value);
136 }else if(matchFlag== Api::Tizen::MATCH_STARTSWITH){
137 LogDebug("STRING_MATCH_STARTSWITH");
138 getMatchStartsWithClause(attrName, value);
139 }else if(matchFlag == Api::Tizen::MATCH_ENDSWITH){
140 LogDebug("STRING_MATCH_ENDSWITH");
141 getMatchEndsWithClause(attrName, value);
143 LogDebug("[ERROR]invalid match flag[" << matchFlag << "]");
144 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid match flag:[" << matchFlag << "]");
149 void FolderQueryGenerator::visitAttributeRange(std::string& attrName, Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue, int depth) {
150 LogDebug("<<< NOT IMPLEMENTED YET");
153 //TODO implement visitID
154 void FolderQueryGenerator::visitID(Api::Tizen::AnyArrayPtr &value, int depth) {
155 LogDebug("<<< NOT IMPLEMENTED YET");
158 int FolderQueryGenerator::getAccountId()
163 std::string FolderQueryGenerator::getFolderPath()
168 bool FolderQueryGenerator::isFolderPathExist()
170 LogError("m_folderPathProcessing : " << m_folderPathProcessing);
171 return m_folderPathProcessing;
174 void FolderQueryGenerator::reset(){
175 m_folderPathProcessing = FALSE;
177 m_folderpath.clear();
182 } //namespace Platform
183 } //namespace WrtPlugins