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