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_ABILITY_H 17 #define VOICEMAIL_ABILITY_H 18 19 #include "abs_shared_result_set.h" 20 #include "datashare_ext_ability.h" 21 #include "datashare_values_bucket.h" 22 #include "telephony_permission.h" 23 #include "voicemail_database.h" 24 #include "want.h" 25 26 namespace OHOS { 27 namespace AbilityRuntime { 28 class VoiceMailAbility : public DataShare::DataShareExtAbility { 29 public: 30 VoiceMailAbility(); 31 virtual ~VoiceMailAbility() override; 32 static VoiceMailAbility* Create(); 33 sptr<IRemoteObject> OnConnect(const AAFwk::Want &want) override; 34 virtual int Insert(const Uri &uri, const DataShare::DataShareValuesBucket &value) override; 35 virtual int BatchInsert(const Uri &uri, const std::vector<DataShare::DataShareValuesBucket> &values) override; 36 virtual void OnStart(const Want &want) override; 37 virtual int Update(const Uri &uri, const DataShare::DataSharePredicates &predicates, 38 const DataShare::DataShareValuesBucket &value) override; 39 virtual int Delete(const Uri &uri, const DataShare::DataSharePredicates &predicates) override; 40 virtual std::shared_ptr<DataShare::DataShareResultSet> Query(const Uri &uri, 41 const DataShare::DataSharePredicates &predicates, std::vector<std::string> &columns, 42 DataShare::DatashareBusinessError &businessError) override; 43 44 private: 45 static std::shared_ptr<Contacts::VoiceMailDataBase> voiceMailDataBase_; 46 static std::map<std::string, int> uriValueMap_; 47 int InsertExecute(const OHOS::Uri &uri, const OHOS::NativeRdb::ValuesBucket &value); 48 void DataBaseNotifyChange(int code, Uri uri); 49 bool IsBeginTransactionOK(int code, std::mutex &mutex); 50 bool IsCommitOK(int code, std::mutex &mutex); 51 int UriParse(Uri &uri); 52 }; 53 } // namespace AbilityRuntime 54 } // namespace OHOS 55 #endif // VOICEMAIL_ABILITY_H 56