1 /* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef SMS_PERSIST_HELPER_H 17 #define SMS_PERSIST_HELPER_H 18 19 #include "singleton.h" 20 21 #include "datashare_helper.h" 22 #include "datashare_predicates.h" 23 24 #include "sms_receive_indexer.h" 25 #include "sms_mms_data.h" 26 27 namespace OHOS { 28 namespace Telephony { 29 class SmsPersistHelper { 30 DECLARE_DELAYED_SINGLETON(SmsPersistHelper) 31 public: 32 bool Insert(DataShare::DataShareValuesBucket &values, uint16_t &dataBaseId); 33 bool Insert(std::string tableUri, DataShare::DataShareValuesBucket &values); 34 bool Query(DataShare::DataSharePredicates &predicates, std::vector<SmsReceiveIndexer> &indexers); 35 bool Delete(DataShare::DataSharePredicates &predicates); 36 bool Update(DataShare::DataSharePredicates &predicates, DataShare::DataShareValuesBucket &values); 37 bool QueryBlockPhoneNumber(const std::string &phoneNum); 38 bool QueryParamBoolean(const std::string key, bool defValue); 39 bool QueryMaxGroupId(DataShare::DataSharePredicates &predicates, uint16_t &maxGroupId); 40 bool QuerySession(DataShare::DataSharePredicates &predicates, uint16_t &sessionId, uint16_t &messageCount); 41 42 inline static const std::string SMS_CAPABLE_KEY = "sms_config_capable"; 43 inline static const std::string SMS_ENCODING_KEY = "sms_config_force_7bit_encoding"; 44 inline static const std::string SMS_CAPABLE_PARAM_KEY = "const.telephony.sms.capable"; 45 inline static const std::string SMS_ENCODING_PARAM_KEY = "persist.sys.sms.config.7bitforce"; 46 47 private: 48 const std::string SMS_URI = "datashare:///com.ohos.smsmmsability"; 49 const std::string SMS_SUBSECTION = "datashare:///com.ohos.smsmmsability/sms_mms/sms_subsection"; 50 const std::string SMS_MMS_INFO = "datashare:///com.ohos.smsmmsability/sms_mms/sms_mms_info"; 51 const std::string SMS_SESSION = "datashare:///com.ohos.smsmmsability/sms_mms/session"; 52 const std::string CONTACT_URI = "datashare:///com.ohos.contactsdataability"; 53 const std::string CONTACT_BLOCK = 54 "datashare:///com.ohos.contactsdataability/contacts/contact_blocklist"; 55 56 std::shared_ptr<DataShare::DataShareHelper> CreateDataShareHelper(const std::string &uri); 57 void ResultSetConvertToIndexer( 58 SmsReceiveIndexer &info, const std::shared_ptr<DataShare::DataShareResultSet> &resultSet); 59 void ConvertIntToIndexer( 60 SmsReceiveIndexer &info, const std::shared_ptr<DataShare::DataShareResultSet> &resultSet); 61 void ConvertStringToIndexer( 62 SmsReceiveIndexer &info, const std::shared_ptr<DataShare::DataShareResultSet> &resultSet); 63 }; 64 } // namespace Telephony 65 } // namespace OHOS 66 #endif 67