1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 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 QTRACKERCONTACTFETCHREQUEST_H_ |
|
43 #define QTRACKERCONTACTFETCHREQUEST_H_ |
|
44 |
|
45 #include "qtrackercontactasyncrequest.h" |
|
46 |
|
47 #include <qmobilityglobal.h> |
|
48 #include <qcontactonlineaccount.h> |
|
49 #include <qcontactmanager.h> |
|
50 |
|
51 #include <QtTracker/Tracker> |
|
52 #include <QtTracker/QLive> |
|
53 |
|
54 QTM_BEGIN_NAMESPACE |
|
55 class QContactAbstractRequest; |
|
56 class QContactManagerEngine; |
|
57 QTM_END_NAMESPACE |
|
58 |
|
59 QTM_USE_NAMESPACE |
|
60 |
|
61 namespace IMAccount { |
|
62 enum IMResultColumn { |
|
63 URI = 0, |
|
64 ContactPresence, |
|
65 ContactMessage, |
|
66 ContactNickname, |
|
67 ContactDisplayname, |
|
68 ContactIMId, |
|
69 ContactAvatar |
|
70 }; |
|
71 }; |
|
72 |
|
73 namespace IMContact { |
|
74 enum IMResultColumn { |
|
75 URI, |
|
76 ContactId, |
|
77 ContactIMId, |
|
78 ContactPresence, |
|
79 ContactMessage, |
|
80 ContactNickname, |
|
81 AccountType, |
|
82 Capabilities, |
|
83 ServiceProvider |
|
84 }; |
|
85 }; |
|
86 |
|
87 /*! |
|
88 * Running QContactFetchRequest. Doing the async tracker query and when data is ready setting the |
|
89 * finished status of request. \sa QTrackerContactFetchRequest |
|
90 */ |
|
91 class QTrackerContactFetchRequest : public QObject, public QTrackerContactAsyncRequest |
|
92 { |
|
93 Q_OBJECT |
|
94 // Q_ENUMS(IMResultColumn) |
|
95 public: |
|
96 QTrackerContactFetchRequest(QContactAbstractRequest* req, QContactManagerEngine* parent); |
|
97 public slots: |
|
98 void contactsReady(); |
|
99 void phoneNumbersReady(); |
|
100 void emailAddressesReady(); |
|
101 void imAcountsReady(); |
|
102 |
|
103 protected slots: |
|
104 virtual void run(); |
|
105 virtual void emitFinished(QContactManager::Error error = QContactManager::NoError); |
|
106 |
|
107 protected: |
|
108 QContactManager::Error applyFilterToContact(SopranoLive::RDFVariable &variable, const QContactFilter &filter); |
|
109 QContactManager::Error applyDetailRangeFilterToContact(SopranoLive::RDFVariable &variable, const QContactFilter &filter); |
|
110 |
|
111 // contacts query |
|
112 SopranoLive::LiveNodes query; |
|
113 |
|
114 QList<SopranoLive::LiveNodes> queryPhoneNumbersNodes; // 2 - one for affiliations and another one for PersonContact |
|
115 int queryPhoneNumbersNodesPending; |
|
116 QList<SopranoLive::LiveNodes> queryEmailAddressNodes; // 2 - one for affiliations and another one for PersonContact |
|
117 int queryEmailAddressNodesPending; |
|
118 SopranoLive::LiveNodes queryIMAccountNodes; |
|
119 int queryIMAccountNodesPending; |
|
120 |
|
121 // result of the request - multiple queries updating it |
|
122 QList<QContact> result; |
|
123 |
|
124 private: |
|
125 bool isMeContact(const QContactFilter &filter); |
|
126 // fills received phone number from tracker to list of contacts to QContactPhoneMumber details |
|
127 // all the following methods update \sa result |
|
128 void processQueryPhoneNumbers(SopranoLive::LiveNodes queryPhoneNumbers, bool affiliationNumbers); |
|
129 void processQueryEmailAddresses(SopranoLive::LiveNodes queryEmailAddresses, bool affiliationEmails); |
|
130 void processQueryIMContacts(SopranoLive::LiveNodes queryIMContacts); |
|
131 void validateRequest(); |
|
132 void readFromQueryRowToContact(QContact &contact, int queryRow); |
|
133 void addContactToResultSet(QContact &contact); |
|
134 QContactOnlineAccount getOnlineAccountFromIMQuery(SopranoLive::LiveNodes imAccountQuery, int queryRow); |
|
135 QContactOnlineAccount getIMAccountFromIMQuery(SopranoLive::LiveNodes imAccountQuery, int queryRow) ; |
|
136 QContactOnlineAccount getIMContactFromIMQuery(SopranoLive::LiveNodes imAccountQuery, int queryRow); |
|
137 |
|
138 // access existing contacts in result list, contactid to index in \sa result lookup |
|
139 QHash<quint32, int> id2ContactLookup; |
|
140 }; |
|
141 |
|
142 #endif /* QTRACKERCONTACTFETCHREQUEST_H_ */ |
|