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 ContactListenerManager.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>
32 #include <API/Contact/IContact.h>
38 class IContactEventCallbacks
41 friend class ContactListenerManager;
43 IContactEventCallbacks() {}
44 ~IContactEventCallbacks() {}
47 virtual void onContactEventAdded(TizenApis::Api::Contact::ContactArrayPtr &contacts) = 0;
48 virtual void onContactEventUpdated(TizenApis::Api::Contact::ContactArrayPtr &contacts) = 0;
49 virtual void onContactEventRemoved(TizenApis::Api::Contact::StringArrayPtr &contactIds) = 0;
52 class ContactListenerManager
55 ContactListenerManager();
56 virtual ~ContactListenerManager();
58 // Can throw InvalidArgumentException or PlatformException
59 void registerAppListChangedCallbacks(IContactEventCallbacks *callbacks, int addressBookId);
62 void unregisterAppListChangedCallbacks(IContactEventCallbacks *callbacks);
63 void unregisterAppListChangedCallbacks(int addressBookId);
65 long getWatchIdAndInc();
68 static void contactsSvcEventCallback(void *data);
69 void contactsSvcEventCallback();
71 void registerContactSvcChangedCallbacks();
72 void unregisterContactSvcChangedCallbacks();
74 IContactEventCallbacks* getContactEventCallbacks(int id);
76 typedef std::map<int, IContactEventCallbacks *> ContactEventCallbacksMap;
77 ContactEventCallbacksMap m_callbacks;
79 bool m_callbackRegistered;
86 friend class DPL::Singleton<ContactListenerManager>;
89 typedef DPL::Singleton<ContactListenerManager> ContactListenerManagerSingleton;
95 #endif // TIZENAPIS_PLATFORM_CONTACT_CONTACT_LISTENER_MANAGER_H_