Master to tizen_2.1
[framework/osp/social.git] / src / inc / FScl_AddressbookImpl.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17 /**
18 * @file         FScl_AddressbookImpl.h
19 * @brief        This is the header file for the _AddressbookImpl class.
20 *
21 * This header file contains the declarations of the _AddressbookImpl class.
22 */
23
24 #ifndef _FSCL_INTERNAL_ADDRESSBOOK_IMPL_H_
25 #define _FSCL_INTERNAL_ADDRESSBOOK_IMPL_H_
26
27 #include <unique_ptr.h>
28 #include <contacts.h>
29 #include <FBaseObject.h>
30 #include "FScl_IContactDbChangeEventListener.h"
31
32 namespace Tizen { namespace Base {
33 class String;
34
35 namespace Collection {
36 class IList;
37 template<class Type> class IListT;
38 }
39 }}
40
41 namespace Tizen { namespace Social
42 {
43 class Addressbook;
44 class Contact;
45 class Category;
46 class UserProfile;
47 class IRecordEventListener;
48 class IAddressbookEventListener;
49 class IAddressbookChangeEventListener;
50
51 /**
52  * @class       _AddressbookImpl
53  * @brief       This class handles the _AddressbookImpl operations.
54  * @since       2.0
55  * @see   Addressbook
56  *
57  */
58 class _AddressbookImpl
59         : public Tizen::Base::Object
60         , virtual public _IContactDbChangeEventListener
61 {
62 public:
63         /**
64          * This is default constructor for the class.
65          *
66          * @since       2.0
67          */
68         _AddressbookImpl(void);
69
70         /**
71          * This destructor overrides Tizen::Base::Object::~Object().
72          *
73          * @since       2.0
74          */
75         virtual ~_AddressbookImpl(void);
76
77         result Construct(void);
78
79         result SetRecordEventListener(IRecordEventListener* pListener);
80
81         result SetAddressbookEventListener(IAddressbookEventListener* pListener);
82
83         result SetAddressbookChangeEventListener(IAddressbookChangeEventListener* pListener);
84
85         void SetId(AddressbookId addressbookId);
86
87         void SetAccountId(AccountId accountId);
88
89         void SetName(const Tizen::Base::String& name);
90
91         AddressbookId GetId(void) const;
92
93         AccountId GetAccountId(void) const;
94
95         Tizen::Base::String GetName(void) const;
96
97         result AddContact(Contact& contact);
98
99         result AddCategory(Category& category);
100
101         result RemoveContact(RecordId contactId);
102
103         result RemoveContact(Contact& contact);
104
105         result RemoveCategory(RecordId categoryId);
106
107         result UpdateContact(const Contact& contact);
108
109         result UpdateCategory(const Category& category);
110
111         Tizen::Base::Collection::IList* GetAllContactsN(void) const;
112
113         Tizen::Base::Collection::IList* GetContactsByCategoryN(RecordId categoryId) const;
114
115         Tizen::Base::Collection::IListT<RecordId>* GetContactIdsByCategoryN(RecordId categoryId) const;
116
117         result AddMemberToCategory(RecordId categoryId, RecordId contactId);
118
119         result RemoveMemberFromCategory(RecordId categoryId, RecordId contactId);
120
121         Tizen::Base::Collection::IList* GetAllCategoriesN(void) const;
122
123         Tizen::Base::Collection::IList* GetCategoriesByContactN(RecordId contactId) const;
124
125         Tizen::Base::Collection::IList* GetContactsN(int pageNo, int countPerPage) const;
126
127         Tizen::Base::Collection::IList* GetContactsInN(const Category& category, int pageNo, int countPerPage) const;
128
129         Tizen::Base::Collection::IList* SearchContactsByEmailN(const Tizen::Base::String& email) const;
130
131         Tizen::Base::Collection::IList* SearchContactsByNameN(const Tizen::Base::String& name) const;
132
133         Tizen::Base::Collection::IList* SearchContactsByPhoneNumberN(const Tizen::Base::String& phoneNumber) const;
134
135         int GetCategoryCount(void) const;
136
137         int GetContactCount(void) const;
138
139         Contact* GetContactN(RecordId contactId) const;
140
141         Category* GetCategoryN(RecordId categoryId) const;
142
143         int GetLatestVersion(void) const;
144
145         Tizen::Base::Collection::IList* GetChangedContactsAfterN(int version, int& latestVersion) const;
146
147         Tizen::Base::Collection::IList* GetChangedCategoriesAfterN(int version, int& latestVersion) const;
148
149         Tizen::Base::Collection::IList* GetChangedContactInfoListN(int version, int& latestVersion) const;
150
151         Tizen::Base::Collection::IList* GetChangedCategoryInfoListN(int version, int& latestVersion) const;
152
153         result AddContacts(const Tizen::Base::Collection::IList& contactList, Tizen::Base::Collection::IListT<RecordId>* pContactIdList);
154
155         result UpdateContacts(const Tizen::Base::Collection::IList& contactList);
156
157         result RemoveContacts(const Tizen::Base::Collection::IListT<RecordId>& contactIdList);
158
159         result SetUserProfile(const UserProfile* pUserProfile);
160
161         UserProfile* GetUserProfileN(void) const;
162
163         bool IsUserProfileChangedAfter(int version) const;
164
165         result CopyMyProfileContents(contacts_record_h srcHandle, contacts_record_h dstHandle);
166
167         virtual void OnContactChanged(void);
168
169         virtual void OnCategoryChanged(void);
170
171         virtual void OnRelationChanged(void);
172
173         static _AddressbookImpl* GetInstance(Addressbook& addressbook);
174
175         static const _AddressbookImpl* GetInstance(const Addressbook& addressbook);
176
177 private:
178         /**
179          * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
180          *
181          * @since       2.0
182          */
183         _AddressbookImpl(const _AddressbookImpl& rhs);
184
185         Tizen::Base::Collection::IList* GetChangedGroupsAfterN(int, int&) const;
186
187         Tizen::Base::Collection::IList* GetChangedRelationsAfterN(int, int&) const;
188
189         /**
190          * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
191          *
192          * @since       2.0
193          */
194         _AddressbookImpl& operator =(const _AddressbookImpl& rhs);
195
196 private:
197         IRecordEventListener* __pIRecordEventListener;
198         IAddressbookEventListener* __pIAddressbookEventListener;
199         IAddressbookChangeEventListener* __pIAddressbookChangeEventListener;
200         int __dbVersionForContact;
201         int __dbVersionForGroup;
202         int __dbVersionForRelation;
203         AddressbookId __addressbookId;
204         AccountId __accountId;
205         Tizen::Base::String __name;
206 };      // _AddressbookImpl
207
208 }}  // Tizen::Social
209
210 #endif //_FSCL_INTERNAL_ADDRESSBOOK_IMPL_H_