2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FScl_ContactDbMonitor.h
19 * @brief This is the header file for the _ContactDbMonitor class.
21 * This header file contains the declarations of the _ContactDbMonitor class.
24 #ifndef _FSCL_INTERNAL_CONTACT_DB_MONITOR_H_
25 #define _FSCL_INTERNAL_CONTACT_DB_MONITOR_H_
29 #include <unique_ptr.h>
31 #include <FBaseTypes.h>
32 #include <FBaseResult.h>
33 #include <FBaseObject.h>
35 namespace Tizen { namespace Base {
39 template<typename Type>
50 namespace Tizen { namespace Social
52 class _IContactDbChangeEventListener;
53 class _ContactDbChangeEvent;
56 * @class _ContactDbMonitor
57 * @brief This class handles the _ContactDbMonitor operations.
59 * @see _AddressbookImpl
62 class _ContactDbMonitor
63 : public Tizen::Base::Object
66 result AddListener(const _IContactDbChangeEventListener& listener);
68 result RemoveListener(const _IContactDbChangeEventListener& listener);
70 int GetAccountIdByAddressbookId(int addressbookId);
72 static _ContactDbMonitor* GetInstance(void);
75 _ContactDbMonitor(void);
77 virtual ~_ContactDbMonitor(void);
79 result Construct(void);
81 _ContactDbMonitor(const _ContactDbMonitor& rhs);
83 static void OnContactDbChanged(const char* viewUri, void* pUserData);
85 _ContactDbMonitor& operator =(const _ContactDbMonitor& rhs);
87 static void InitSingleton(void);
89 static void DestroySingleton(void);
91 result UpdateAddressbookList(void);
98 __Callback(const char* uri, contacts_db_changed_cb callback, void* pData);
99 result Register(void);
104 contacts_db_changed_cb __callback;
112 __List(contacts_list_h list)
117 contacts_list_h Release(void)
119 contacts_list_h list = __list;
130 contacts_list_destroy(__list, true);
134 contacts_list_h __list;
140 __Lock(Tizen::Base::Runtime::Mutex* pMutex)
143 result r = pMutex->Acquire();
144 SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
151 if (__pMutex != null)
153 result r = __pMutex->Release();
154 SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
159 Tizen::Base::Runtime::Mutex* __pMutex;
163 std::unique_ptr<_ContactDbChangeEvent> __pEvent;
164 std::unique_ptr<Tizen::Base::Runtime::Mutex> __pMutex;
165 std::unique_ptr<__Callback> __pContactChangeCallback;
166 std::unique_ptr<__Callback> __pGroupChangeCallback;
167 std::unique_ptr<__Callback> __pGroupRelationChagneCallback;
168 std::unique_ptr<__Callback> __pAddressbookChagneCallback;
169 contacts_list_h __pAddressbookList;
171 static _ContactDbMonitor* __pTheInstance;
172 friend struct std::default_delete< _ContactDbMonitor >;
173 }; // _ContactDbMonitor
177 #endif //_FSCL_INTERNAL_CONTACT_DB_MONITOR_H_