|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef QCONTACTABOOK_P_H |
|
43 #define QCONTACTABOOK_P_H |
|
44 |
|
45 #include <QObject> |
|
46 #include <QMutex> |
|
47 |
|
48 #include "qtcontacts.h" |
|
49 #include "qcontactmaemo5debug_p.h" |
|
50 |
|
51 #include <gdk-pixbuf/gdk-pixbuf.h> |
|
52 |
|
53 #include "osso-abook-workaround.h" |
|
54 #include "qcontactidshash.h" |
|
55 |
|
56 QTM_USE_NAMESPACE |
|
57 |
|
58 /* Data shared with contact changes/added/removed callbacks */ |
|
59 struct cbSharedData; |
|
60 /* Data shared with job callbacks */ |
|
61 struct jobSharedData; |
|
62 |
|
63 class QContactABook : public QObject |
|
64 { |
|
65 Q_OBJECT |
|
66 |
|
67 public: |
|
68 QContactABook(QObject* parent = 0); |
|
69 ~QContactABook(); |
|
70 |
|
71 QList<QContactLocalId> contactIds(const QContactFilter& filter, const QList<QContactSortOrder>& sortOrders, QContactManager::Error* error) const; |
|
72 //QList<QContactLocalId> contactIds(const QList<QContactSortOrder>& sortOrders, QContactManager::Error* error) const; |
|
73 QContact* getQContact(const QContactLocalId& contactId, QContactManager::Error* error) const; |
|
74 bool removeContact(const QContactLocalId& contactId, QContactManager::Error* error); |
|
75 bool saveContact(QContact* contact, QContactManager::Error* error); |
|
76 |
|
77 QContactLocalId selfContactId(QContactManager::Error* errors) const; |
|
78 |
|
79 Q_SIGNALS: |
|
80 void contactsAdded(const QList<QContactLocalId>& contactIds); |
|
81 void contactsChanged(const QList<QContactLocalId>& contactIds); |
|
82 void contactsRemoved(const QList<QContactLocalId>& contactIds); |
|
83 void jobSavingCompleted(); |
|
84 void jobRemovingCompleted(); |
|
85 |
|
86 public: |
|
87 /* Members used by callbacks */ |
|
88 void _contactsAdded(const QList<QContactLocalId>& contactIds ){ emit contactsAdded(contactIds); }; |
|
89 void _contactsRemoved(const QList<QContactLocalId>& contactIds ){ emit contactsRemoved(contactIds); }; |
|
90 void _contactsChanged(const QList<QContactLocalId>& contactIds ){ emit contactsChanged(contactIds); }; |
|
91 void _jobSavingCompleted(){ emit jobSavingCompleted(); }; |
|
92 void _jobRemovingCompleted(){ emit jobRemovingCompleted(); }; |
|
93 |
|
94 private: |
|
95 void initAddressBook(); |
|
96 void initLocalIdHash(); |
|
97 |
|
98 bool setDetailValues(const QVariantMap& data, QContactDetail* detail) const; |
|
99 |
|
100 OssoABookContact* getAContact(const QContactLocalId& contactId) const; |
|
101 |
|
102 /* Filtering */ |
|
103 bool contactActionsMatch(OssoABookContact *contact, QList<QContactActionDescriptor> descriptors) const; |
|
104 EBookQuery* convert(const QContactFilter& filter) const; |
|
105 |
|
106 /* Reading - eContact/abookContact to QContact methods */ |
|
107 QContact* convert(EContact *eContact) const; |
|
108 |
|
109 QContactId getContactId(EContact *eContact) const; |
|
110 QList<QContactAddress*> getAddressDetail(EContact *eContact) const; |
|
111 QContactName* getNameDetail(EContact *eContact) const; |
|
112 QContactNickname* getNicknameDetail(EContact *eContact) const; |
|
113 QList<QContactEmailAddress*> getEmailDetail(EContact *eContact) const; |
|
114 QContactAvatar* getAvatarDetail(EContact *eContact) const; |
|
115 QContactBirthday* getBirthdayDetail(EContact *eContact) const; |
|
116 QContactGender* getGenderDetail(EContact *eContact) const; |
|
117 QContactGuid* getGuidDetail(EContact *eContact) const; |
|
118 QContactNote* getNoteDetail(EContact *eContact) const; |
|
119 QList<QContactOnlineAccount*> getOnlineAccountDetail(EContact *eContact) const; |
|
120 QContactOrganization* getOrganizationDetail(EContact *eContact) const; |
|
121 QList<QContactPhoneNumber*> getPhoneDetail(EContact *eContact) const; |
|
122 QList<QContactPresence*> getPresenceDetail(EContact *eContact) const; |
|
123 QContactTimestamp* getTimestampDetail(EContact *eContact) const; |
|
124 QContactThumbnail* getThumbnailDetail(EContact *eContact) const; |
|
125 QContactUrl* getUrlDetail(EContact *eContact) const; |
|
126 |
|
127 /* Saving - QContact to abookContact */ |
|
128 OssoABookContact* convert(const QContact *contact) const; |
|
129 |
|
130 /* Save QDetails in OssoABookContact attributes */ |
|
131 void setAddressDetail(const OssoABookContact* aContact, const QContactAddress& detail) const; |
|
132 void setAvatarDetail(const OssoABookContact* aContact, const QContactAvatar& detail) const; |
|
133 void setBirthdayDetail(const OssoABookContact* aContact, const QContactBirthday& detail) const; |
|
134 void setEmailDetail(const OssoABookContact* aContact, const QContactEmailAddress& detail) const; |
|
135 void setGenderDetail(const OssoABookContact* aContact, const QContactGender& detail) const; |
|
136 void setNameDetail(const OssoABookContact* aContact, const QContactName& detail) const; |
|
137 void setNicknameDetail(const OssoABookContact* aContact, const QContactNickname& detail) const; |
|
138 void setNoteDetail(const OssoABookContact* aContact, const QContactNote& detail) const; |
|
139 void setOnlineAccountDetail(const OssoABookContact* aContact, const QContactOnlineAccount& detail) const; |
|
140 void setOrganizationDetail(const OssoABookContact* aContact, const QContactOrganization& detail) const; |
|
141 void setPhoneDetail(const OssoABookContact* aContact, const QContactPhoneNumber& detail) const; |
|
142 void setPresenceDetail(const OssoABookContact* aContact, const QContactPresence& detail) const; |
|
143 void setThumbnailDetail(const OssoABookContact* aContact, const QContactThumbnail& detail) const; |
|
144 void setUrlDetail(const OssoABookContact* aContact, const QContactUrl& detail) const; |
|
145 |
|
146 /* Internal Vars */ |
|
147 gulong m_contactAddedHandlerId; |
|
148 gulong m_contactChangedHandlerId; |
|
149 gulong m_contactRemovedHandlerId; |
|
150 |
|
151 OssoABookAggregator *m_abookAgregator; |
|
152 mutable QContactIDsHash m_localIds; //Converts QLocalId <=> eContactId |
|
153 |
|
154 QMutex m_saveContactMutex; |
|
155 QMutex m_delContactMutex; |
|
156 |
|
157 cbSharedData *m_cbSD; |
|
158 jobSharedData *m_deleteJobSD; |
|
159 jobSharedData *m_saveJobSD; |
|
160 }; |
|
161 |
|
162 #endif |