Fix the boiler plate codes
[framework/osp/social.git] / src / inc / FScl_AddressbookManagerImpl.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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 * @file         FScl_AddressbookManagerImpl.h
18 * @brief        This is the header file for the _AddressbookManagerImpl class.
19 *
20 * This header file contains the declarations of the _AddressbookManagerImpl class.
21 */
22
23 #ifndef _FSCL_INTERNAL_ADDRESSBOOK_MANAGER_IMPL_H_
24 #define _FSCL_INTERNAL_ADDRESSBOOK_MANAGER_IMPL_H_
25
26 #include <unique_ptr.h>
27 #include <contacts.h>
28 #include <FBaseObject.h>
29 #include "FScl_IContactDbChangeEventListener.h"
30
31 namespace Tizen { namespace Base {
32 class String;
33
34 namespace Collection {
35 class IList;
36 template<class Type> class IListT;
37 template<class Type1, class Type2> class HashMapT;
38 }
39 }}
40
41 namespace Tizen { namespace Social
42 {
43 class Addressbook;
44 class AddressbookManager;
45 class UserProfile;
46 class Contact;
47 class Category;
48 class IRecordEventListener;
49 class IAddressbookEventListener;
50 class IAddressbookChangeEventListener;
51
52 /**
53  * @class       _AddressbookManagerImpl
54  * @brief       This class handles the _AddressbookManagerImpl operations.
55  * @since       2.0
56  *
57  */
58 class _AddressbookManagerImpl
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         _AddressbookManagerImpl(void);
69
70         /**
71          * This destructor overrides Tizen::Base::Object::~Object().
72          *
73          * @since       2.0
74          */
75         virtual ~_AddressbookManagerImpl(void);
76
77         result Construct(void);
78
79         result SetEventListener(IAddressbookEventListener* pListener);
80
81         result SetAddressbookChangeEventListener(IAddressbookChangeEventListener* pListener);
82
83         Addressbook* CreateAddressbookN(AccountId accountId, const Tizen::Base::String& name);
84
85         result DeleteAddressbook(AddressbookId addressbookId);
86
87         Tizen::Base::Collection::IList* GetAddressbooksByAccountN(AccountId accountId) const;
88
89         Tizen::Base::Collection::IList* GetAllAddressbooksN(void) const;
90
91         Addressbook* GetAddressbookN(AddressbookId addressbookId) const;
92
93         result AddContact(Contact& contact, AddressbookId addressbookId);
94
95         result AddCategory(Category& category, AddressbookId addressbookId);
96
97         result RemoveContact(RecordId contactId);
98
99         result RemoveCategory(RecordId categoryId);
100
101         result UpdateContact(const Contact& contact);
102
103         result UpdateCategory(const Category& category);
104
105         result RemovePerson(PersonId personId);
106
107         Tizen::Base::Collection::IList* GetAllPersonsN(void) const;
108
109         Tizen::Base::Collection::IList* GetPersonsByCategoryN(RecordId categoryId) const;
110
111         Tizen::Base::Collection::IList* GetFavoritePersonsN() const;
112
113         Tizen::Base::Collection::IList* SearchPersonsN(const Tizen::Base::String& keyword) const;
114
115         Tizen::Base::Collection::IList* SearchN(const AddressbookFilter& filter, 
116                         unsigned long propertyToSort, Tizen::Base::SortOrder sortOrder, int offset, int maxCount);
117
118         int GetMatchedItemCount(const AddressbookFilter& filter);
119
120         result SetPersonAsFavorite(PersonId personId, bool isFavorite = true);
121
122         result MergePersons(PersonId sourcePersonId, PersonId targetPersonId);
123
124         result UnlinkContact(PersonId personId, RecordId contactId, PersonId& newPersonId);
125
126         Tizen::Base::Collection::IList* GetAllContactsN(void) const;
127
128         Tizen::Base::Collection::IList* GetContactsByCategoryN(RecordId categoryId) const;
129
130         Tizen::Base::Collection::IList* GetContactsByPersonN(PersonId personId) const;
131
132         Tizen::Base::Collection::IListT<RecordId>* GetContactIdsByCategoryN(RecordId categoryId) const;
133
134         result AddMemberToCategory(RecordId categoryId, RecordId contactId);
135
136         result RemoveMemberFromCategory(RecordId categoryId, RecordId contactId);
137
138         Tizen::Base::Collection::IList* GetAllCategoriesN(void) const;
139
140         Tizen::Base::Collection::IList* GetCategoriesByContactN(RecordId contactId) const;
141
142         Tizen::Base::Collection::IList* GetCategoriesByPersonN(PersonId personId) const;
143
144         Tizen::Base::Collection::IList* GetContactsInN(const Category& category, int pageNo, int countPerPage) const;
145
146         Tizen::Base::Collection::IList* SearchContactsByEmailN(const Tizen::Base::String& email) const;
147
148         Tizen::Base::Collection::IList* SearchContactsByNameN(const Tizen::Base::String& name) const;
149
150         Tizen::Base::Collection::IList* SearchContactsByPhoneNumberN(const Tizen::Base::String& phoneNumber) const;
151
152         int GetCategoryCount(void) const;
153
154         int GetContactCount(void) const;
155
156         Contact* GetContactN(RecordId contactId) const;
157
158         Person* GetPersonN(PersonId personId) const;
159
160         Category* GetCategoryN(RecordId categoryId) const;
161
162         int GetLatestVersion(void) const;
163
164         Tizen::Base::Collection::IList* GetChangedContactsAfterN(int version, int& latestVersion) const;
165
166         Tizen::Base::Collection::IList* GetChangedCategoriesAfterN(int version, int& latestVersion) const;
167
168         virtual void OnContactChanged(void);
169
170         virtual void OnCategoryChanged(void);
171
172         virtual void OnRelationChanged(void);
173
174         Tizen::Base::Collection::IList* ParseContactsFromVcardN(const Tizen::Base::String& vcardPath);
175
176         result ExportPersonToVcard(const Person& person, const Tizen::Base::String& vcardPath);
177
178         result ExportPersonsToVcard(const Tizen::Base::Collection::IList& personList, const Tizen::Base::String& vcardPath);
179
180         result ExportContactToVcard(const Contact& contact, const Tizen::Base::String& vcardPath);
181
182         result ExportContactsToVcard(const Tizen::Base::Collection::IList& contactList, const Tizen::Base::String& vcardPath);
183
184         Tizen::Base::ByteBuffer* ExportContactToVcardStreamN(const Contact& contact);
185
186         Tizen::Base::ByteBuffer*  ExportContactsToVcardStreamN(const Tizen::Base::Collection::IList& contactList);
187
188         Tizen::Base::ByteBuffer*  ExportPersonToVcardStreamN(const Person& person);
189
190         Tizen::Base::ByteBuffer*  ExportPersonsToVcardStreamN(const Tizen::Base::Collection::IList& personList);
191
192         Tizen::Base::Collection::IList* ParseVcardStreamN(const Tizen::Base::ByteBuffer& vcardStream);
193
194         Tizen::Base::ByteBuffer* ExportUserProfileToVcardStreamN(const UserProfile& userProfile);
195
196         Tizen::Base::ByteBuffer* ExportUserProfilesToVcardStreamN(const Tizen::Base::Collection::IList& userProfileList);
197
198         result ExportUserProfileToVcard(const UserProfile& userProfile, const Tizen::Base::String& vcardPath);
199
200         result ExportUserProfilesToVcard(const Tizen::Base::Collection::IList& userProfileList, const Tizen::Base::String& vcardPath);
201
202         Tizen::Base::Collection::IList* GetAllUserProfilesN(void) const;
203
204         UserProfile* GetUserProfileN(AddressbookId addressbookId) const;
205
206         static bool OnEachContact(contacts_record_h recordHandle, void* pUserData);
207
208         static _AddressbookManagerImpl* GetInstance(AddressbookManager& addressbookManager);
209
210         static const _AddressbookManagerImpl* GetInstance(const AddressbookManager& addressbookManager);
211
212 private:
213         Tizen::Base::Collection::IListT<int>* SearchAddressbooksByAccountIdN(AccountId accountId) const;
214
215         Tizen::Base::Collection::IList* GetChangedGroupsAfterN(int version, int& latestVersion) const;
216
217         Tizen::Base::Collection::IList* GetChangedRelationsAfterN(int version, int& latestVersion) const;
218
219         _AddressbookManagerImpl& operator =(const _AddressbookManagerImpl& rhs);
220
221         _AddressbookManagerImpl(const _AddressbookManagerImpl& rhs);
222
223 private:
224         IAddressbookEventListener* __pIAddressbookEventListener;
225         IAddressbookChangeEventListener* __pIAddressbookChangeEventListener;
226         int __dbVersionForContact;
227         int __dbVersionForGroup;
228         int __dbVersionForRelation;
229         Tizen::Base::Collection::HashMapT<int, int>* __pIdMap;
230 };      // _AddressbookManagerImpl
231
232 }}  // Tizen::Social
233
234 #endif //_FSCL_INTERNAL_ADDRESSBOOK_MANAGER_IMPL_H_