• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 CONTACT_COMMON_EVENT_H
17 #define CONTACT_COMMON_EVENT_H
18 
19 #include "common_event_manager.h"
20 #include "common_event_subscriber.h"
21 #include "hilog_wrapper.h"
22 
23 namespace OHOS {
24 namespace Contacts {
25 constexpr const char *CONTACT_EVENT = "com.ohos.contactsdataability";
26 constexpr const char *CALL_LOG_EVENT = "com.ohos.calllogability";
27 constexpr const char *VOICEMAIL_EVENT = "com.ohos.voicemailability";
28 constexpr int CONTACT_EVENT_CODE = 10000;
29 constexpr int CALL_LOG_EVENT_CODE = 20000;
30 constexpr int VOICEMAIL_EVENT_CODE = 30000;
31 
32 // action
33 constexpr int CONTACT_INSERT = 0;
34 constexpr int CONTACT_UPDATE = 1;
35 constexpr int CONTACT_DELETE = 2;
36 
37 class ContactsCommonEvent : public OHOS::EventFwk::CommonEventSubscriber {
38 public:
ContactsCommonEvent(const OHOS::EventFwk::CommonEventSubscribeInfo & subscriberInfo)39     explicit ContactsCommonEvent(const OHOS::EventFwk::CommonEventSubscribeInfo &subscriberInfo)
40         : CommonEventSubscriber(subscriberInfo)
41     {
42     }
43     ~ContactsCommonEvent() = default;
44     static std::shared_ptr<ContactsCommonEvent> subscriber;
45     void OnReceiveEvent(const OHOS::EventFwk::CommonEventData &data);
46     static bool PublishContactEvent(const OHOS::AAFwk::Want &want, int eventCode, const std::string &eventData);
47     static void UnregisterSubscriber(std::shared_ptr<OHOS::EventFwk::CommonEventSubscriber> subscriber);
48     static void RegisterSubscriber();
49     static void SendContactChange(int actionCode);
50     static void SendCallLogChange(int actionCode);
51     static void SendVoiceMailChange(int actionCode);
52 };
53 } // namespace Contacts
54 } // namespace OHOS
55 #endif // CONTACT_COMMON_EVENT_H
56