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 
16 #ifndef NITZ_SUBSCRIBER_H
17 #define NITZ_SUBSCRIBER_H
18 
19 #include <common_event_publish_info.h>
20 #include <map>
21 #include <string>
22 #include <vector>
23 
24 #include "common_event.h"
25 #include "common_event_data.h"
26 #include "common_event_manager.h"
27 #include "common_event_support.h"
28 
29 namespace OHOS {
30 namespace MiscServices {
31 using namespace OHOS::EventFwk;
32 class NITZSubscriber : public CommonEventSubscriber {
33 public:
34     explicit NITZSubscriber(const CommonEventSubscribeInfo &subscriberInfo);
35     ~NITZSubscriber() = default;
36     virtual void OnReceiveEvent(const CommonEventData &data);
37 
38 private:
39     enum NITZBroadcastEventType {
40         UNKNOWN_BROADCAST_EVENT = 0,
41         NITZ_TIME_CHANGED_BROADCAST_EVENT,
42         NITZ_TIMEZONE_CHANGED_BROADCAST_EVENT
43     };
44     using broadcastSubscriberFunc = std::function<void(const CommonEventData &data)>;
45 
46     void NITZTimeChangeBroadcast(const CommonEventData &data);
47     void NITZTimezoneChangeBroadcast(const CommonEventData &data);
48     std::map<uint32_t, broadcastSubscriberFunc> memberFuncMap_;
49 };
50 } // namespace MiscServices
51 } // namespace OHOS
52 #endif // NITZ_SUBSCRIBER_H