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 FRAMEWORKS_SERVICES_CLOUD_SYNC_NOTIFY_HANDLE_INCLUDE_CLOUDE_SYNC_OBSERVER_H 17 #define FRAMEWORKS_SERVICES_CLOUD_SYNC_NOTIFY_HANDLE_INCLUDE_CLOUDE_SYNC_OBSERVER_H 18 19 #include <mutex> 20 #include <string> 21 22 #include <timer.h> 23 24 #include "datashare_helper.h" 25 #include "medialibrary_async_worker.h" 26 #include "userfile_manager_types.h" 27 28 namespace OHOS { 29 namespace Media { 30 31 struct CloudSyncNotifyInfo { 32 std::list<Uri> uris; 33 DataShare::DataShareObserver::ChangeType type; 34 }; 35 36 class CloudSyncObserver : public DataShare::DataShareObserver { 37 public: 38 CloudSyncObserver(); 39 ~CloudSyncObserver() = default; 40 41 void OnChange(const ChangeInfo &changeInfo) override; 42 void HandleIndex(); 43 44 /* delayed trigger */ 45 OHOS::Utils::Timer timer_; 46 uint32_t timerId_ = 0; 47 bool isPending_ = false; 48 std::mutex syncMutex_; 49 }; 50 51 class CloudSyncNotifyData : public AsyncTaskData { 52 public: CloudSyncNotifyData(const CloudSyncNotifyInfo & info)53 CloudSyncNotifyData(const CloudSyncNotifyInfo &info):notifyInfo_(info) {}; 54 virtual ~CloudSyncNotifyData() override = default; 55 CloudSyncNotifyInfo notifyInfo_; 56 }; 57 } // namespace Media 58 } // namespace OHOS 59 60 #endif //FRAMEWORKS_SERVICES_CLOUD_SYNC_NOTIFY_HANDLE_INCLUDE_CLOUDE_SYNC_OBSERVER_H 61