|
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 QCONTACTMAEMO5BACKEND_P_H |
|
43 #define QCONTACTMAEMO5BACKEND_P_H |
|
44 |
|
45 #include "qcontactmanager.h" |
|
46 #include "qcontactmanager_p.h" |
|
47 |
|
48 #include <QMap> |
|
49 #include <QString> |
|
50 #include <QList> |
|
51 #include <QQueue> |
|
52 #include <QDebug> |
|
53 |
|
54 #include "qtcontacts.h" |
|
55 #include "qcontactabook_p.h" |
|
56 #include "qcontactchangeset.h" |
|
57 |
|
58 #define MAEMO5_ENGINE_VERSION 0.1 |
|
59 |
|
60 QTM_USE_NAMESPACE |
|
61 |
|
62 Q_DEFINE_LATIN1_CONSTANT(AddressFieldExtension, "X-Maemo5-Extension"); |
|
63 |
|
64 class Q_DECL_EXPORT ContactMaemo5Factory : public QObject, public QContactManagerEngineFactory |
|
65 { |
|
66 Q_OBJECT |
|
67 Q_INTERFACES(QtMobility::QContactManagerEngineFactory) |
|
68 public: |
|
69 QContactManagerEngine* engine(const QMap<QString, QString>& parameters, QContactManager::Error*); |
|
70 QString managerName() const; |
|
71 }; |
|
72 |
|
73 class QContactMaemo5EngineData : public QSharedData |
|
74 { |
|
75 public: |
|
76 QContactMaemo5EngineData() |
|
77 : QSharedData(), |
|
78 m_refCount(QAtomicInt(1)), |
|
79 m_abook(new QContactABook) |
|
80 { |
|
81 } |
|
82 |
|
83 QContactMaemo5EngineData(const QContactMaemo5EngineData& other) |
|
84 : QSharedData(other), |
|
85 m_refCount(QAtomicInt(1)), |
|
86 m_abook(other.m_abook) |
|
87 { |
|
88 } |
|
89 |
|
90 ~QContactMaemo5EngineData() |
|
91 { |
|
92 delete m_abook; |
|
93 } |
|
94 |
|
95 QAtomicInt m_refCount; |
|
96 QContactABook *m_abook; |
|
97 }; |
|
98 |
|
99 class QContactMaemo5Engine : public QContactManagerEngine |
|
100 { |
|
101 Q_OBJECT |
|
102 public: |
|
103 QContactMaemo5Engine(); |
|
104 QContactMaemo5Engine& operator=(const QContactMaemo5Engine& other); |
|
105 |
|
106 QString managerName() const; |
|
107 QString synthesizedDisplayLabel(const QContact& contact, QContactManager::Error* error) const; |
|
108 bool validateContact(const QContact&, QContactManager::Error* error) const; |
|
109 bool validateDefinition(const QContactDetailDefinition&, QContactManager::Error* error) const; |
|
110 QContact compatibleContact(const QContact& contact, QContactManager::Error* error) const; |
|
111 |
|
112 /* "Self" contact id (MyCard) */ |
|
113 QContactLocalId selfContactId(QContactManager::Error* errors) const; |
|
114 |
|
115 /* Filtering */ |
|
116 QList<QContactLocalId> contactIds(const QContactFilter& filter, const QList<QContactSortOrder>& sortOrders, QContactManager::Error* error) const; |
|
117 |
|
118 /* Contacts - Accessors and Mutators */ |
|
119 QContact contact(const QContactLocalId& contactId, const QContactFetchHint& fetchHint, QContactManager::Error* error) const; |
|
120 QList<QContact> contacts(const QContactFilter& filter, const QList<QContactSortOrder>& sortOrders, const QContactFetchHint& fetchHint, QContactManager::Error* error ) const; |
|
121 bool saveContact(QContact* contact, QContactManager::Error* error); |
|
122 bool removeContact(const QContactLocalId& contactId, QContactManager::Error* error); |
|
123 bool saveContacts(QList<QContact>*, QMap<int, QContactManager::Error>*, QContactManager::Error* error); // implemented in terms of the singular saveContact |
|
124 bool removeContacts(const QList<QContactLocalId>&, QMap<int, QContactManager::Error>*, QContactManager::Error* error); // implemented in terms of the singular removeContact |
|
125 |
|
126 /* Definitions - Accessors and Mutators */ |
|
127 QMap<QString, QContactDetailDefinition> detailDefinitions(const QString& contactType, QContactManager::Error* error) const; |
|
128 QContactDetailDefinition detailDefinition(const QString& definitionName, const QString& contactType, QContactManager::Error* error) const; // implemented in terms of the plural detailDefinitions |
|
129 |
|
130 /* Version Reporting */ |
|
131 int implementationVersion() const { return MAEMO5_ENGINE_VERSION; }; |
|
132 int managerVersion() const { return MAEMO5_ENGINE_VERSION; }; |
|
133 |
|
134 /* Capabilities reporting */ |
|
135 bool hasFeature(QContactManager::ManagerFeature feature, const QString& contactType) const; |
|
136 bool isFilterSupported(const QContactFilter& filter) const; |
|
137 QList<QVariant::Type> supportedDataTypes() const; |
|
138 QStringList supportedContactTypes() const {return (QStringList() << QContactType::TypeContact);} |
|
139 |
|
140 /* Asynchronous Request Support - synchronous versions until thread worker is stable */ |
|
141 void requestDestroyed(QContactAbstractRequest *req); |
|
142 bool startRequest(QContactAbstractRequest *req); |
|
143 bool cancelRequest(QContactAbstractRequest *req); |
|
144 bool waitForRequestProgress(QContactAbstractRequest* req, int msecs); |
|
145 bool waitForRequestFinished(QContactAbstractRequest* req, int msecs); |
|
146 |
|
147 private slots: |
|
148 void performAsynchronousOperation(); |
|
149 |
|
150 private: |
|
151 QQueue<QContactAbstractRequest*> m_asynchronousOperations; // async requests to be performed. |
|
152 QSharedDataPointer<QContactMaemo5EngineData> d; |
|
153 }; |
|
154 |
|
155 #endif |
|
156 |