• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 INTERFACES_KITS_JS_MEDIALIBRARY_INCLUDE_USER_FILE_CLIENT_H
17 #define INTERFACES_KITS_JS_MEDIALIBRARY_INCLUDE_USER_FILE_CLIENT_H
18 
19 #include "datashare_helper.h"
20 #include "datashare_predicates.h"
21 #include "napi_base_context.h"
22 #include "napi_error.h"
23 #include "napi/native_api.h"
24 #include "napi/native_node_api.h"
25 #include "napi_remote_object.h"
26 #include "uri.h"
27 
28 namespace OHOS {
29 namespace Media {
30 class UserFileClient {
31 public:
UserFileClient()32     UserFileClient() {}
~UserFileClient()33     virtual ~UserFileClient() {}
34     static bool IsValid();
35     static void Init(napi_env env, napi_callback_info info);
36     static std::shared_ptr<DataShare::DataShareResultSet> Query(Uri &uri,
37         const DataShare::DataSharePredicates &predicates, std::vector<std::string> &columns);
38     static int Insert(Uri &uri, const DataShare::DataShareValuesBucket &value);
39     static int Delete(Uri &uri, const DataShare::DataSharePredicates &predicates);
40     static void NotifyChange(const Uri &uri);
41     static void RegisterObserver(const Uri &uri, const sptr<AAFwk::IDataAbilityObserver> &dataObserver);
42     static void UnregisterObserver(const Uri &uri, const sptr<AAFwk::IDataAbilityObserver> &dataObserver);
43     static int OpenFile(Uri &uri, const std::string &mode);
44     static int Update(Uri &uri, const DataShare::DataSharePredicates &predicates,
45         const DataShare::DataShareValuesBucket &value);
46 private:
47     static inline std::shared_ptr<DataShare::DataShareHelper> sDataShareHelper_ = nullptr;
48     static std::shared_ptr<DataShare::DataShareHelper> GetDataShareHelper(napi_env env, napi_callback_info info);
49 };
50 }
51 }
52 
53 #endif // INTERFACES_KITS_JS_MEDIALIBRARY_INCLUDE_USER_FILE_CLIENT_H