2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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 FScl_ContactDbMonitor.h
18 * @brief This is the header file for the _ContactDbMonitor class.
20 * This header file contains the declarations of the _ContactDbMonitor class.
23 #ifndef _FSCL_INTERNAL_CONTACT_DB_MONITOR_H_
24 #define _FSCL_INTERNAL_CONTACT_DB_MONITOR_H_
28 #include <unique_ptr.h>
30 #include <FBaseTypes.h>
31 #include <FBaseResult.h>
32 #include <FBaseObject.h>
34 namespace Tizen { namespace Base {
38 template<typename Type>
49 namespace Tizen { namespace Social
51 class _IContactDbChangeEventListener;
52 class _ContactDbChangeEvent;
55 * @class _ContactDbMonitor
56 * @brief This class handles the _ContactDbMonitor operations.
58 * @see _AddressbookImpl
61 class _ContactDbMonitor
62 : public Tizen::Base::Object
65 result AddListener(const _IContactDbChangeEventListener& listener);
67 result RemoveListener(const _IContactDbChangeEventListener& listener);
69 int GetAccountIdByAddressbookId(int addressbookId);
71 static _ContactDbMonitor* GetInstance(void);
74 _ContactDbMonitor(void);
76 virtual ~_ContactDbMonitor(void);
78 result Construct(void);
80 _ContactDbMonitor(const _ContactDbMonitor& rhs);
82 static void OnContactDbChanged(const char* viewUri, void* pUserData);
84 _ContactDbMonitor& operator =(const _ContactDbMonitor& rhs);
86 static void InitSingleton(void);
88 static void DestroySingleton(void);
90 result UpdateAddressbookList(void);
97 __Callback(const char* uri, contacts_db_changed_cb callback, void* pData);
98 result Register(void);
103 contacts_db_changed_cb __callback;
111 __List(contacts_list_h list)
116 contacts_list_h Release(void)
118 contacts_list_h list = __list;
129 contacts_list_destroy(__list, true);
133 contacts_list_h __list;
139 __Lock(Tizen::Base::Runtime::Mutex* pMutex)
142 result r = pMutex->Acquire();
143 SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
150 if (__pMutex != null)
152 result r = __pMutex->Release();
153 SysTryReturnVoidResult(NID_SCL, r == E_SUCCESS, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
158 Tizen::Base::Runtime::Mutex* __pMutex;
162 std::unique_ptr<_ContactDbChangeEvent> __pEvent;
163 std::unique_ptr<Tizen::Base::Runtime::Mutex> __pMutex;
164 std::unique_ptr<__Callback> __pContactChangeCallback;
165 std::unique_ptr<__Callback> __pGroupChangeCallback;
166 std::unique_ptr<__Callback> __pGroupRelationChagneCallback;
167 std::unique_ptr<__Callback> __pAddressbookChagneCallback;
168 contacts_list_h __pAddressbookList;
170 static _ContactDbMonitor* __pTheInstance;
171 friend struct std::default_delete< _ContactDbMonitor >;
172 }; // _ContactDbMonitor
176 #endif //_FSCL_INTERNAL_CONTACT_DB_MONITOR_H_