• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef OHOS_MEDIA_CLOUD_SYNC_CLOUD_MEDIA_DATA_HANDLER_H
17 #define OHOS_MEDIA_CLOUD_SYNC_CLOUD_MEDIA_DATA_HANDLER_H
18 
19 #include <map>
20 #include <vector>
21 
22 #include "cloud_check_data.h"
23 #include "cloud_meta_data.h"
24 #include "mdk_record.h"
25 #include "mdk_reference.h"
26 #include "mdk_database.h"
27 #include "i_cloud_media_data_handler.h"
28 
29 namespace OHOS::Media::CloudSync {
30 #define EXPORT __attribute__ ((visibility ("default")))
31 class EXPORT CloudMediaDataHandler : public ICloudMediaDataHandler {
32 private:  // data members
33     int32_t cloudType_;
34     int32_t userId_;
35     std::string tableName_;
36     std::string traceId_;
37 
38 private:  // data handlers
39     std::shared_ptr<ICloudMediaDataHandler> dataHandler_;
40 
41 public:  // constructor
42     CloudMediaDataHandler() = default;
43     CloudMediaDataHandler(const std::string &tableName, int32_t cloudType, int32_t userId);
44     virtual ~CloudMediaDataHandler() = default;
45 
46 public:  // getter & setter
47     int32_t GetCloudType() const;
48     void SetCloudType(int32_t cloudType);
49     std::string GetTableName() const;
50     void SetTableName(const std::string &tableName);
51     int32_t GetUserId() const;
52     void SetUserId(const int32_t &userId) override;
53     void SetTraceId(const std::string &traceId) override;
54     std::string GetTraceId() const override;
55 
56 public:
57     int32_t GetCheckRecords(const std::vector<std::string> &cloudIds,
58         std::unordered_map<std::string, CloudCheckData> &checkRecords) override;
59     int32_t GetCreatedRecords(std::vector<MDKRecord> &records, int32_t size) override;
60     int32_t GetMetaModifiedRecords(std::vector<MDKRecord> &records, int32_t size, int32_t dirtyType = 2) override;
61     int32_t GetFileModifiedRecords(std::vector<MDKRecord> &records, int32_t size) override;
62     int32_t GetDeletedRecords(std::vector<MDKRecord> &records, int32_t size) override;
63     int32_t GetCopyRecords(std::vector<MDKRecord> &records, int32_t size) override;
64     int32_t OnCreateRecords(const std::map<std::string, MDKRecordOperResult> &map, int32_t &failSize) override;
65     int32_t OnMdirtyRecords(const std::map<std::string, MDKRecordOperResult> &map, int32_t &failSize) override;
66     int32_t OnFdirtyRecords(const std::map<std::string, MDKRecordOperResult> &map, int32_t &failSize) override;
67     int32_t OnDeleteRecords(const std::map<std::string, MDKRecordOperResult> &map, int32_t &failSize) override;
68     int32_t OnCopyRecords(const std::map<std::string, MDKRecordOperResult> &map, int32_t &failSize) override;
69     int32_t OnFetchRecords(const std::vector<MDKRecord> &records, std::vector<CloudMetaData> &newData,
70         std::vector<CloudMetaData> &fdirtyData, std::vector<std::string> &failedRecords,
71         std::vector<int32_t> &stats) override;
72     int32_t OnDentryFileInsert(std::vector<MDKRecord> &records, std::vector<std::string> &failedRecords) override;
73     int32_t GetRetryRecords(std::vector<std::string> &records) override;
74     int32_t OnStartSync() override;
75     int32_t OnCompleteSync() override;
76     int32_t OnCompletePull() override;
77     int32_t OnCompletePush() override;
78     int32_t OnCompleteCheck() override;
79 };
80 }  // namespace OHOS::Media::CloudSync
81 #endif  // OHOS_MEDIA_CLOUD_SYNC_CLOUD_MEDIA_DATA_HANDLER_H