• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 #ifndef WALLPAPER_SERVICES_WALLPAPER_COMMON_EVENT_H
16 #define WALLPAPER_SERVICES_WALLPAPER_COMMON_EVENT_H
17 
18 #include <string>
19 #include "common_event_subscriber.h"
20 #include "common_event_support.h"
21 #include "common_event_manager.h"
22 
23 namespace OHOS {
24 namespace WallpaperMgrService {
25 using CommonEventSubscriber = OHOS::EventFwk::CommonEventSubscriber;
26 using CommonEventData = OHOS::EventFwk::CommonEventData;
27 using CommonEventSubscribeInfo = OHOS::EventFwk::CommonEventSubscribeInfo;
28 static const std::string WALLPAPER_LOCK_SETTING_SUCCESS_EVENT = "com.ohos.wallpaperlocksettingsuccess";
29 static const std::string WALLPAPER_SYSTEM_SETTING_SUCCESS_EVENT = "com.ohos.wallpapersystemsettingsuccess";
30 static const int WALLPAPER_LOCK_SETTING_SUCCESS_CODE = 11000;
31 static const int WALLPAPER_SYSTEM_SETTING_SUCCESS_CODE = 21000;
32 
33 class WallpaperCommonEvent : public OHOS::EventFwk::CommonEventSubscriber {
34 public:
WallpaperCommonEvent(const OHOS::EventFwk::CommonEventSubscribeInfo & subscriberInfo)35     WallpaperCommonEvent(const OHOS::EventFwk::CommonEventSubscribeInfo &subscriberInfo)
36         : CommonEventSubscriber(subscriberInfo)
37     {}
38     ~WallpaperCommonEvent() = default;
39     static std::shared_ptr<WallpaperCommonEvent> subscriber;
40     void OnReceiveEvent(const OHOS::EventFwk::CommonEventData &data) override;
41     static bool PublishEvent(const OHOS::AAFwk::Want &want, int eventCode, const std::string &eventData);
42     static void UnregisterSubscriber(std::shared_ptr<OHOS::EventFwk::CommonEventSubscriber> subscriber);
43     static bool RegisterSubscriber();
44     static void SendWallpaperLockSettingMessage();
45     static void SendWallpaperSystemSettingMessage();
46 private:
47     std::function<void(const EventFwk::CommonEventData &)> callback_;
48 };
49 }
50 }
51 
52 #endif