1 /*
2  * Copyright (c) 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 #include "cloud_file_kit.h"
17 #include "dfs_error.h"
18 
19 namespace OHOS::FileManagement::CloudFile {
20 using namespace std;
21 
GetInstance()22 CloudFileKit *CloudFileKit::GetInstance()
23 {
24     return instance_;
25 }
26 
RegisterCloudInstance(CloudFileKit * instance)27 bool CloudFileKit::RegisterCloudInstance(CloudFileKit *instance)
28 {
29     if (instance_ != nullptr) {
30         return false;
31     }
32     instance_ = instance;
33     return true;
34 }
35 
GetCloudUserInfo(const int32_t userId,CloudUserInfo & userInfo)36 int32_t CloudFileKit::GetCloudUserInfo(const int32_t userId, CloudUserInfo &userInfo)
37 {
38     userInfo.enableCloud = true;
39     return E_OK;
40 }
41 
GetRemainSpace(const int32_t userId)42 uint64_t CloudFileKit::GetRemainSpace(const int32_t userId)
43 {
44     return E_OK;
45 }
46 
GetAppSwitchStatus(const std::string & bundleName,const int32_t userId,bool & switchStatus)47 int32_t CloudFileKit::GetAppSwitchStatus(const std::string &bundleName, const int32_t userId, bool &switchStatus)
48 {
49     switchStatus = true;
50     return E_OK;
51 }
52 
ResolveNotificationEvent(const int32_t userId,const std::string & extraData,std::string & appBundleName,std::string & prepareTraceId)53 int32_t CloudFileKit::ResolveNotificationEvent(const int32_t userId,
54                                                const std::string &extraData,
55                                                std::string &appBundleName,
56                                                std::string &prepareTraceId)
57 {
58     appBundleName = "com.ohos.photos";
59     return E_OK;
60 }
61 
GetAppConfigParams(const int32_t userId,const std::string & bundleName,std::map<std::string,std::string> & param)62 int32_t CloudFileKit::GetAppConfigParams(const int32_t userId,
63                                          const std::string &bundleName,
64                                          std::map<std::string, std::string> &param)
65 {
66     param["validDays"] = "30";
67     param["dataAgingPolicy"] = "0";
68     return E_OK;
69 }
70 
CleanCloudUserInfo(const int32_t userId)71 int32_t CloudFileKit::CleanCloudUserInfo(const int32_t userId)
72 {
73     return E_OK;
74 }
75 
GetDataSyncManager()76 shared_ptr<DataSyncManager> CloudFileKit::GetDataSyncManager()
77 {
78     return std::make_shared<DataSyncManager>();
79 }
80 
OnUploadAsset(const int32_t userId,const std::string & request,std::string & result)81 int32_t CloudFileKit::OnUploadAsset(const int32_t userId, const std::string &request, std::string &result)
82 {
83     return E_OK;
84 }
85 
GetCloudAssetsDownloader(const int32_t userId,const std::string & bundleName)86 std::shared_ptr<CloudAssetsDownloader> CloudFileKit::GetCloudAssetsDownloader(const int32_t userId,
87                                                                               const std::string &bundleName)
88 {
89     return make_shared<CloudAssetsDownloader>(userId, bundleName);
90 }
91 
GetCloudDatabase(const int32_t userId,const std::string & bundleName)92 std::shared_ptr<CloudDatabase> CloudFileKit::GetCloudDatabase(const int32_t userId, const std::string &bundleName)
93 {
94     return make_shared<CloudDatabase>(userId, bundleName);
95 }
96 
GetCloudSyncHelper(const int32_t userId,const std::string & bundleName)97 std::shared_ptr<CloudSyncHelper> CloudFileKit::GetCloudSyncHelper(const int32_t userId, const std::string &bundleName)
98 {
99     return make_shared<CloudSyncHelper>(userId, bundleName);
100 }
101 } // namespace OHOS::FileManagement::CloudFile