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_AddressbookManagerImpl.h
18 * @brief This is the header file for the _AddressbookManagerImpl class.
20 * This header file contains the declarations of the _AddressbookManagerImpl class.
23 #ifndef _FSCL_INTERNAL_ADDRESSBOOK_MANAGER_IMPL_H_
24 #define _FSCL_INTERNAL_ADDRESSBOOK_MANAGER_IMPL_H_
26 #include <unique_ptr.h>
28 #include <FBaseObject.h>
29 #include "FScl_IContactDbChangeEventListener.h"
31 namespace Tizen { namespace Base {
34 namespace Collection {
36 template<class Type> class IListT;
37 template<class Type1, class Type2> class HashMapT;
41 namespace Tizen { namespace Social
44 class AddressbookManager;
48 class IRecordEventListener;
49 class IAddressbookEventListener;
50 class IAddressbookChangeEventListener;
53 * @class _AddressbookManagerImpl
54 * @brief This class handles the _AddressbookManagerImpl operations.
58 class _AddressbookManagerImpl
59 : public Tizen::Base::Object
60 , virtual public _IContactDbChangeEventListener
64 * This is default constructor for the class.
68 _AddressbookManagerImpl(void);
71 * This destructor overrides Tizen::Base::Object::~Object().
75 virtual ~_AddressbookManagerImpl(void);
77 result Construct(void);
79 result SetEventListener(IAddressbookEventListener* pListener);
81 result SetAddressbookChangeEventListener(IAddressbookChangeEventListener* pListener);
83 Addressbook* CreateAddressbookN(AccountId accountId, const Tizen::Base::String& name);
85 result DeleteAddressbook(AddressbookId addressbookId);
87 Tizen::Base::Collection::IList* GetAddressbooksByAccountN(AccountId accountId) const;
89 Tizen::Base::Collection::IList* GetAllAddressbooksN(void) const;
91 Addressbook* GetAddressbookN(AddressbookId addressbookId) const;
93 result AddContact(Contact& contact, AddressbookId addressbookId);
95 result AddCategory(Category& category, AddressbookId addressbookId);
97 result RemoveContact(RecordId contactId);
99 result RemoveCategory(RecordId categoryId);
101 result UpdateContact(const Contact& contact);
103 result UpdateCategory(const Category& category);
105 result RemovePerson(PersonId personId);
107 Tizen::Base::Collection::IList* GetAllPersonsN(void) const;
109 Tizen::Base::Collection::IList* GetPersonsByCategoryN(RecordId categoryId) const;
111 Tizen::Base::Collection::IList* GetFavoritePersonsN() const;
113 Tizen::Base::Collection::IList* SearchPersonsN(const Tizen::Base::String& keyword) const;
115 Tizen::Base::Collection::IList* SearchN(const AddressbookFilter& filter,
116 unsigned long propertyToSort, Tizen::Base::SortOrder sortOrder, int offset, int maxCount);
118 int GetMatchedItemCount(const AddressbookFilter& filter);
120 result SetPersonAsFavorite(PersonId personId, bool isFavorite = true);
122 result MergePersons(PersonId sourcePersonId, PersonId targetPersonId);
124 result UnlinkContact(PersonId personId, RecordId contactId, PersonId& newPersonId);
126 Tizen::Base::Collection::IList* GetAllContactsN(void) const;
128 Tizen::Base::Collection::IList* GetContactsByCategoryN(RecordId categoryId) const;
130 Tizen::Base::Collection::IList* GetContactsByPersonN(PersonId personId) const;
132 Tizen::Base::Collection::IListT<RecordId>* GetContactIdsByCategoryN(RecordId categoryId) const;
134 result AddMemberToCategory(RecordId categoryId, RecordId contactId);
136 result RemoveMemberFromCategory(RecordId categoryId, RecordId contactId);
138 Tizen::Base::Collection::IList* GetAllCategoriesN(void) const;
140 Tizen::Base::Collection::IList* GetCategoriesByContactN(RecordId contactId) const;
142 Tizen::Base::Collection::IList* GetCategoriesByPersonN(PersonId personId) const;
144 Tizen::Base::Collection::IList* GetContactsInN(const Category& category, int pageNo, int countPerPage) const;
146 Tizen::Base::Collection::IList* SearchContactsByEmailN(const Tizen::Base::String& email) const;
148 Tizen::Base::Collection::IList* SearchContactsByNameN(const Tizen::Base::String& name) const;
150 Tizen::Base::Collection::IList* SearchContactsByPhoneNumberN(const Tizen::Base::String& phoneNumber) const;
152 int GetCategoryCount(void) const;
154 int GetContactCount(void) const;
156 Contact* GetContactN(RecordId contactId) const;
158 Person* GetPersonN(PersonId personId) const;
160 Category* GetCategoryN(RecordId categoryId) const;
162 int GetLatestVersion(void) const;
164 Tizen::Base::Collection::IList* GetChangedContactsAfterN(int version, int& latestVersion) const;
166 Tizen::Base::Collection::IList* GetChangedCategoriesAfterN(int version, int& latestVersion) const;
168 virtual void OnContactChanged(void);
170 virtual void OnCategoryChanged(void);
172 virtual void OnRelationChanged(void);
174 Tizen::Base::Collection::IList* ParseContactsFromVcardN(const Tizen::Base::String& vcardPath);
176 result ExportPersonToVcard(const Person& person, const Tizen::Base::String& vcardPath);
178 result ExportPersonsToVcard(const Tizen::Base::Collection::IList& personList, const Tizen::Base::String& vcardPath);
180 result ExportContactToVcard(const Contact& contact, const Tizen::Base::String& vcardPath);
182 result ExportContactsToVcard(const Tizen::Base::Collection::IList& contactList, const Tizen::Base::String& vcardPath);
184 Tizen::Base::ByteBuffer* ExportContactToVcardStreamN(const Contact& contact);
186 Tizen::Base::ByteBuffer* ExportContactsToVcardStreamN(const Tizen::Base::Collection::IList& contactList);
188 Tizen::Base::ByteBuffer* ExportPersonToVcardStreamN(const Person& person);
190 Tizen::Base::ByteBuffer* ExportPersonsToVcardStreamN(const Tizen::Base::Collection::IList& personList);
192 Tizen::Base::Collection::IList* ParseVcardStreamN(const Tizen::Base::ByteBuffer& vcardStream);
194 Tizen::Base::ByteBuffer* ExportUserProfileToVcardStreamN(const UserProfile& userProfile);
196 Tizen::Base::ByteBuffer* ExportUserProfilesToVcardStreamN(const Tizen::Base::Collection::IList& userProfileList);
198 result ExportUserProfileToVcard(const UserProfile& userProfile, const Tizen::Base::String& vcardPath);
200 result ExportUserProfilesToVcard(const Tizen::Base::Collection::IList& userProfileList, const Tizen::Base::String& vcardPath);
202 Tizen::Base::Collection::IList* GetAllUserProfilesN(void) const;
204 UserProfile* GetUserProfileN(AddressbookId addressbookId) const;
206 static bool OnEachContact(contacts_record_h recordHandle, void* pUserData);
208 static _AddressbookManagerImpl* GetInstance(AddressbookManager& addressbookManager);
210 static const _AddressbookManagerImpl* GetInstance(const AddressbookManager& addressbookManager);
213 Tizen::Base::Collection::IListT<int>* SearchAddressbooksByAccountIdN(AccountId accountId) const;
215 Tizen::Base::Collection::IList* GetChangedGroupsAfterN(int version, int& latestVersion) const;
217 Tizen::Base::Collection::IList* GetChangedRelationsAfterN(int version, int& latestVersion) const;
219 _AddressbookManagerImpl& operator =(const _AddressbookManagerImpl& rhs);
221 _AddressbookManagerImpl(const _AddressbookManagerImpl& rhs);
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
234 #endif //_FSCL_INTERNAL_ADDRESSBOOK_MANAGER_IMPL_H_