Update change log and spec for wrt-plugins-tizen_0.2.76
[profile/ivi/wrt-plugins-tizen.git] / src / platform / Tizen / Contact / ContactListenerManager.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 /*
17  * @file        ContactListenerManager.h
18  * @author      Kisub Song (kisubs.song@samsung.com)
19  * @version     0.1
20  * @brief       
21  */
22
23 #ifndef TIZENAPIS_PLATFORM_CONTACT_CONTACT_LISTENER_MANAGER_H_
24 #define TIZENAPIS_PLATFORM_CONTACT_CONTACT_LISTENER_MANAGER_H_
25
26 #include <string>
27 #include <map>
28 #include <set>
29 #include <dpl/shared_ptr.h>
30 #include <dpl/singleton.h>
31
32 #include <API/Contact/IContact.h>
33
34 namespace TizenApis {
35 namespace Platform {
36 namespace Contact {
37
38 class IContactEventCallbacks
39 {
40 public:
41     friend class ContactListenerManager;
42
43     IContactEventCallbacks() {}
44         ~IContactEventCallbacks() {}
45
46 protected:
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;
50 };
51
52 class ContactListenerManager
53 {
54 public:
55         ContactListenerManager();
56         virtual ~ContactListenerManager();
57
58         // Can throw InvalidArgumentException or PlatformException
59         void registerAppListChangedCallbacks(IContactEventCallbacks *callbacks, int addressBookId);
60
61         // No throws
62         void unregisterAppListChangedCallbacks(IContactEventCallbacks *callbacks);
63         void unregisterAppListChangedCallbacks(int addressBookId);
64
65         long getWatchIdAndInc();
66
67 private:
68         static void contactsSvcEventCallback(void *data);
69         void contactsSvcEventCallback();
70
71         void registerContactSvcChangedCallbacks();
72         void unregisterContactSvcChangedCallbacks();
73
74         IContactEventCallbacks* getContactEventCallbacks(int id);
75
76         typedef std::map<int, IContactEventCallbacks *> ContactEventCallbacksMap;
77         ContactEventCallbacksMap m_callbacks;
78
79         bool m_callbackRegistered;
80
81         int m_latestVersion;
82
83         long m_watchIdAcc;
84
85 public:
86         friend class DPL::Singleton<ContactListenerManager>;
87 };
88
89 typedef DPL::Singleton<ContactListenerManager> ContactListenerManagerSingleton;
90
91 } // Contact
92 } // Platform
93 } // TizenApis
94
95 #endif // TIZENAPIS_PLATFORM_CONTACT_CONTACT_LISTENER_MANAGER_H_