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 "daemon_eventhandler.h"
17
18#include "daemon.h"
19#include "utils_log.h"
20
21namespace OHOS {
22namespace Storage {
23namespace DistributedFile {
24
25DaemonEventHandler::DaemonEventHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner,
26                                       const std::shared_ptr<DaemonExecute> &daemonExecute)
27    : AppExecFwk::EventHandler(runner), daemonExecute_(daemonExecute)
28{
29    LOGI("daemon event handler create.");
30}
31
32DaemonEventHandler::~DaemonEventHandler()
33{
34    LOGI("daemon event handler delete.");
35}
36
37void DaemonEventHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
38{
39    if (event == nullptr) {
40        LOGE("event is nullptr.");
41        return;
42    }
43
44    std::shared_ptr<DaemonExecute> daemonExecute = daemonExecute_.lock();
45    if (daemonExecute == nullptr) {
46        LOGE("get DaemonExecute fail.");
47        return;
48    }
49    daemonExecute->ProcessEvent(event);
50}
51
52} // namespace DistributedFile
53} // namespace Storage
54} // namespace OHOS