1 /* 2 * Copyright (c) 2021-2022 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 VOICEMAIL_DATABASE_H 17 #define VOICEMAIL_DATABASE_H 18 19 #include "datashare_predicates.h" 20 #include "rdb_errno.h" 21 #include "rdb_helper.h" 22 #include "rdb_open_callback.h" 23 #include "rdb_predicates.h" 24 #include "rdb_store.h" 25 #include "result_set.h" 26 #include "value_object.h" 27 28 #include "common.h" 29 #include "contacts_columns.h" 30 #include "hilog_wrapper.h" 31 32 namespace OHOS { 33 namespace Contacts { 34 class VoiceMailDataBase { 35 public: 36 static std::shared_ptr<VoiceMailDataBase> GetInstance(); 37 static std::shared_ptr<OHOS::NativeRdb::RdbStore> store_; 38 int64_t InsertVoiceMail(std::string tableName, OHOS::NativeRdb::ValuesBucket insertValues); 39 int UpdateVoiceMail(OHOS::NativeRdb::ValuesBucket values, OHOS::NativeRdb::RdbPredicates &rdbPredicates); 40 int DeleteVoiceMail(OHOS::NativeRdb::RdbPredicates &rdbPredicates); 41 std::shared_ptr<OHOS::NativeRdb::ResultSet> Query( 42 OHOS::NativeRdb::RdbPredicates &rdbPredicates, const std::vector<std::string> columns); 43 int BeginTransaction(); 44 int Commit(); 45 int RollBack(); 46 47 private: 48 VoiceMailDataBase(); 49 VoiceMailDataBase(const VoiceMailDataBase &); 50 const VoiceMailDataBase &operator=(const VoiceMailDataBase &); 51 static std::shared_ptr<VoiceMailDataBase> voiceMailDataBase_; 52 }; 53 } // namespace Contacts 54 } // namespace OHOS 55 #endif // VOICEMAIL_DATABASE_H 56