1 /*
2  * Copyright (C) 2022-2024 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 FRAMEWORKS_NATIVE_CAPI_COMMON_MEDIA_USERFILE_CLIENT_H
17 #define FRAMEWORKS_NATIVE_CAPI_COMMON_MEDIA_USERFILE_CLIENT_H
18 
19 #include "datashare_helper.h"
20 #include "uri.h"
21 
22 namespace OHOS {
23 namespace Media {
24 
25 class UserFileClient {
26 public:
UserFileClient()27     UserFileClient() {}
~UserFileClient()28     virtual ~UserFileClient() {}
29     static bool IsValid();
30 
31     static void Init();
32     static void Init(const sptr<IRemoteObject> &token, bool isSetHelper = false);
33     static std::shared_ptr<DataShare::DataShareResultSet> Query(Uri &uri,
34         const DataShare::DataSharePredicates &predicates, std::vector<std::string> &columns, int &errCode);
35     static int Insert(Uri &uri, const DataShare::DataShareValuesBucket &value);
36     static int InsertExt(Uri &uri, const DataShare::DataShareValuesBucket &value, std::string &result);
37     static int Delete(Uri &uri, const DataShare::DataSharePredicates &predicates);
38     static int OpenFile(Uri &uri, const std::string &mode);
39     static int Update(Uri &uri, const DataShare::DataSharePredicates &predicates,
40         const DataShare::DataShareValuesBucket &value);
41     static void Clear();
42 
43 private:
44     static inline std::shared_ptr<DataShare::DataShareHelper> sDataShareHelper_ = nullptr;
45 };
46 }
47 }
48 
49 #endif // FRAMEWORKS_NATIVE_CAPI_COMMON_MEDIA_USERFILE_CLIENT_H