Update change log and spec for wrt-plugins-tizen_0.2.77
[profile/ivi/wrt-plugins-tizen.git] / src / platform / Tizen / Contact / AddressBook.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 /**
18  * @file        AddressBook.h
19  * @author      Kisub Song (kisubs.song@samsung.com)
20  * @version     0.1
21  * @brief
22  */
23
24 #ifndef _PLATFORM_CONTACT_ADDRESS_BOOK_H_
25 #define _PLATFORM_CONTACT_ADDRESS_BOOK_H_
26
27 #include <contacts-svc.h>
28
29 #include <string>
30 #include <vector>
31 #include <Commons/Emitters.h>
32 #include <API/Contact/IAddressBook.h>
33 #include <API/Contact/IContact.h>
34
35 #include "ContactsSvcChangeListenerManager.h"
36
37 namespace TizenApis {
38 namespace Platform {
39 namespace Contact {
40
41 class AddressBook : public TizenApis::Api::Contact::IAddressBook, public IContactEventCallbacks
42 {
43 private:
44         int             m_id;
45         std::string     m_name;
46         bool            m_readOnly;
47         int             m_accountId;
48
49 public:
50         explicit AddressBook();
51         virtual ~AddressBook();
52
53         virtual std::string getId() const;
54         virtual void        setId(const std::string &value);
55         void                setId(const int &value) { m_id = value; }
56         virtual std::string getName() const { return m_name; }
57         virtual void            setName(const std::string &value) { m_name = value; }
58         virtual bool        getReadOnly() const { return m_readOnly; }
59         virtual void        setReadOnly(const bool &value) { m_readOnly = value; }
60         virtual std::string getAccountId() const;
61         virtual void        setAccountId(const std::string &value);
62         void                setAccountId(const int &value) { m_accountId = value; }
63
64 protected:
65         virtual void OnRequestReceived(const TizenApis::Api::Contact::EventAddressBookGetPtr &event);
66         virtual void OnRequestReceived(const TizenApis::Api::Contact::EventAddressBookAddPtr &event);
67         virtual void OnRequestReceived(const TizenApis::Api::Contact::EventAddressBookAddBatchPtr &event);
68         virtual void OnRequestReceived(const TizenApis::Api::Contact::EventAddressBookUpdatePtr &event);
69         virtual void OnRequestReceived(const TizenApis::Api::Contact::EventAddressBookUpdateBatchPtr &event);
70         virtual void OnRequestReceived(const TizenApis::Api::Contact::EventAddressBookRemovePtr &event);
71         virtual void OnRequestReceived(const TizenApis::Api::Contact::EventAddressBookRemoveBatchPtr &event);
72         virtual void OnRequestReceived(const TizenApis::Api::Contact::EventAddressBookFindPtr &event);
73         virtual void OnRequestReceived(const TizenApis::Api::Contact::EventAddressBookGetCategoriesPtr &event);
74         virtual void OnRequestReceived(const TizenApis::Api::Contact::EventAddressBookAddChangeListenerPtr &event);
75         virtual void OnRequestReceived(const TizenApis::Api::Contact::EventAddressBookRemoveChangeListenerPtr &event);
76
77         virtual void onContactEventAdded(TizenApis::Api::Contact::ContactArrayPtr &contacts);
78         virtual void onContactEventUpdated(TizenApis::Api::Contact::ContactArrayPtr &contacts);
79         virtual void onContactEventRemoved(TizenApis::Api::Contact::StringArrayPtr &contactIds);
80
81 private:
82         //int m_latestVersion;
83
84         void internalAddContact(const TizenApis::Api::Contact::ContactPtr &newContact);
85         void internalDeleteContactById(int id);
86         DPL::Mutex      m_contactEditingMutex;
87
88         typedef WrtDeviceApis::Commons::Emitters<TizenApis::Api::Contact::EventAddressBookChangeListenerEmitter> AddressBookChangedEmitter;
89         AddressBookChangedEmitter       m_addressBookEmitters;
90         //DPL::Mutex    m_addressBookEmittersMutex;
91
92         typedef std::map<long, TizenApis::Api::Contact::EventAddressBookChangeListenerEmitter::IdType> WatchIdMap;
93         WatchIdMap m_watchIdMap;
94         //long m_watchIdAcc;
95 };
96
97 } // Contact
98 } // Platform
99 } // TizenApis
100
101 #endif // _PLATFORM_CONTACT_ADDRESS_BOOK_H_