2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file ContactsSvcChangeListenerManager.h
18 * @author Kisub Song (kisubs.song@samsung.com)
23 #ifndef TIZENAPIS_PLATFORM_CONTACT_CONTACT_LISTENER_MANAGER_H_
24 #define TIZENAPIS_PLATFORM_CONTACT_CONTACT_LISTENER_MANAGER_H_
29 #include <dpl/shared_ptr.h>
30 #include <dpl/singleton.h>
31 #include <Commons/EventReceiver.h>
32 #include <Commons/IEvent.h>
34 #include <API/Contact/IContact.h>
40 class IContactEventCallbacks
43 friend class ContactsSvcChangeListenerManager;
45 IContactEventCallbacks() {}
46 ~IContactEventCallbacks() {}
49 virtual void onContactEventAdded(TizenApis::Api::Contact::ContactArrayPtr &contacts) = 0;
50 virtual void onContactEventUpdated(TizenApis::Api::Contact::ContactArrayPtr &contacts) = 0;
51 virtual void onContactEventRemoved(TizenApis::Api::Contact::StringArrayPtr &contactIds) = 0;
54 class EventInvokeChangeListener :
55 public WrtDeviceApis::Commons::IEvent<EventInvokeChangeListener>
58 typedef DPL::SharedPtr<EventInvokeChangeListener> EventInvokeChangeListenerPtr;
60 class ContactsSvcChangeListenerManager :
61 public WrtDeviceApis::Commons::EventRequestReceiver< EventInvokeChangeListener >
64 ContactsSvcChangeListenerManager();
65 virtual ~ContactsSvcChangeListenerManager();
67 // Can throw InvalidArgumentException or PlatformException
68 void registerAppListChangedCallbacks(IContactEventCallbacks *callbacks, int addressBookId);
71 void unregisterAppListChangedCallbacks(IContactEventCallbacks *callbacks);
72 void unregisterAppListChangedCallbacks(int addressBookId);
74 long getWatchIdAndInc();
77 static void contactsSvcEventCallback(void *data);
78 void contactsSvcEventCallback();
79 virtual void OnRequestReceived(const EventInvokeChangeListenerPtr &event);
81 void registerContactSvcChangedCallbacks();
82 void unregisterContactSvcChangedCallbacks();
84 IContactEventCallbacks* getContactEventCallbacks(int id);
86 typedef std::map<int, IContactEventCallbacks *> ContactEventCallbacksMap;
87 ContactEventCallbacksMap m_callbacks;
89 bool m_callbackRegistered;
96 friend class DPL::Singleton<ContactsSvcChangeListenerManager>;
99 typedef DPL::Singleton<ContactsSvcChangeListenerManager> ContactsSvcChangeListenerManagerSingleton;
105 #endif // TIZENAPIS_PLATFORM_CONTACT_CONTACT_LISTENER_MANAGER_H_