// // Tizen Web Device API // Copyright (c) 2012 Samsung Electronics Co., Ltd. // // Licensed under the Apache License, Version 2.0 (the License); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // #ifndef FOLDERQUERYGENERATOR_H_ #define FOLDERQUERYGENERATOR_H_ #include #include #include namespace DeviceAPI { namespace Messaging { class FolderQueryGenerator: public DeviceAPI::Tizen::IFilterVisitor { public: enum QueryGeneratorMode { MODE_EMAIL, MODE_SMS_MMS }; protected: std::map attributeMap; private: QueryGeneratorMode m_mode; std::string m_query; std::vector m_queryVector; int m_messageType; std::vector typeVector; std::string m_currentType; bool m_folderPathProcessing; int m_accountId; std::string m_folderpath; static const std::string STRING_MATCH_EXACTLY; static const std::string STRING_MATCH_CONTAINS; static const std::string STRING_MATCH_STARTSWITH; static const std::string STRING_MATCH_ENDSWITH; static const std::string STRING_MATCH_EXISTS; static const int ACCOUNT_ID_NOT_INITIALIZED; public: FolderQueryGenerator(); virtual ~FolderQueryGenerator(); void visitPreComposite(DeviceAPI::Tizen::FilterType& type, int depth); void visitInComposite(DeviceAPI::Tizen::FilterType& type, int depth); void visitPostComposite(DeviceAPI::Tizen::FilterType& type, int depth); void visitAttribute(std::string& attrName, DeviceAPI::Tizen::MatchFlag& matchFlag, DeviceAPI::Tizen::AnyPtr& matchValue, int depth); void visitAttributeRange(std::string& attrName, DeviceAPI::Tizen::AnyPtr& initialValue, DeviceAPI::Tizen::AnyPtr& endValue, int depth); int getAccountId(); std::string getFolderPath(); bool isFolderPathExist(); void reset(); protected: virtual bool getMatchExactlyClause(std::string& attrName, DeviceAPI::Tizen::AnyPtr& value); virtual bool getMatchExistClause(std::string& attrName); void visitAttributeEach(std::string& attrName, DeviceAPI::Tizen::MatchFlag& matchFlag, DeviceAPI::Tizen::AnyPtr& value, int depth); private: std::string getMatchStartsWithClause(std::string& attrName, DeviceAPI::Tizen::AnyPtr& value); std::string getMatchEndsWithClause(std::string& attrName, DeviceAPI::Tizen::AnyPtr& value); std::string getMatchContainsClause(std::string& attrName, DeviceAPI::Tizen::AnyPtr& value); }; typedef DPL::SharedPtr FolderQueryGeneratorPtr; } } #endif