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