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.
19 * @author Kisub Song (kisubs.song@samsung.com)
24 #ifndef _PLATFORM_CONTACT_ADDRESS_BOOK_H_
25 #define _PLATFORM_CONTACT_ADDRESS_BOOK_H_
27 #include <contacts-svc.h>
31 #include <Commons/Emitters.h>
32 #include <API/Contact/IAddressBook.h>
33 #include <API/Contact/IContact.h>
39 class AddressBook : public TizenApis::Api::Contact::IAddressBook
47 explicit AddressBook(TizenApis::Api::Contact::IAddressBook::AddressBookType type);
48 virtual ~AddressBook();
50 virtual std::string getId() const { return m_id; }
51 virtual void setId(const std::string &value) { m_id = value; }
52 virtual std::string getName() const { return m_name; }
53 virtual void setName(const std::string &value) { m_name = value; }
54 virtual bool getReadOnly() const { return m_readOnly; }
55 virtual void setReadOnly(const bool &value) { m_readOnly = value; }
57 virtual TizenApis::Api::Contact::ContactPtr get(const std::string &contactId);
58 virtual void add(const TizenApis::Api::Contact::ContactPtr &contact);
59 virtual void update(const TizenApis::Api::Contact::ContactPtr &contact);
60 virtual void remove(const std::string &id);
62 virtual long addChangeListener(const TizenApis::Api::Contact::EventAddressBookChangeListenerEmitterPtr &emitter);
63 virtual void removeChangeListener(const long watchId);
66 virtual void OnRequestReceived(const TizenApis::Api::Contact::EventAddressBookAddBatchPtr &event);
67 virtual void OnRequestReceived(const TizenApis::Api::Contact::EventAddressBookUpdateBatchPtr &event);
68 virtual void OnRequestReceived(const TizenApis::Api::Contact::EventAddressBookRemoveBatchPtr &event);
69 virtual void OnRequestReceived(const TizenApis::Api::Contact::EventAddressBookFindPtr &event);
74 void internalAddContact(const TizenApis::Api::Contact::ContactPtr &newContact);
75 void internalDeleteContactById(int id);
76 DPL::Mutex m_contactEditingMutex;
78 typedef WrtDeviceApis::Commons::Emitters<TizenApis::Api::Contact::EventAddressBookChangeListenerEmitter> AddressBookChangedEmitter;
79 AddressBookChangedEmitter m_addressBookEmitters;
80 DPL::Mutex m_addressBookEmittersMutex;
83 static void contactsSvcContactChangedCallback(void *data);
86 void contactsSvcContactChangedCallback();
93 #endif // _PLATFORM_CONTACT_ADDRESS_BOOK_H_