|
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 CNTSYMBIANSIMENGINE_H |
|
43 #define CNTSYMBIANSIMENGINE_H |
|
44 |
|
45 // |
|
46 // W A R N I N G |
|
47 // ------------- |
|
48 // |
|
49 // This file is not part of the Qt API. It exists purely as an |
|
50 // implementation detail. This header file may change from version to |
|
51 // version without notice, or even be removed. |
|
52 // |
|
53 // We mean it. |
|
54 // |
|
55 #include "qtcontactsglobal.h" |
|
56 #include "qcontactmanagerengine.h" |
|
57 #include "qcontactmanagerenginefactory.h" |
|
58 #include <flogger.h> |
|
59 #include <f32file.h> |
|
60 |
|
61 //#define SYMBIANSIM_BACKEND_DEBUG |
|
62 |
|
63 namespace { |
|
64 #ifdef SYMBIANSIM_BACKEND_DEBUG |
|
65 void PbkPrintToLog( TRefByValue<const TDesC> aFormat, ... ) |
|
66 { |
|
67 _LIT( KLogDir, "Sim" ); |
|
68 _LIT( KLogName, "sim.log" ); |
|
69 |
|
70 VA_LIST args; |
|
71 VA_START( args, aFormat ); |
|
72 RFileLogger::WriteFormat(KLogDir, KLogName, EFileLoggingModeAppend, aFormat, args); |
|
73 VA_END( args ); |
|
74 } |
|
75 #else |
|
76 void PbkPrintToLog( TRefByValue<const TDesC> aFormat, ... ) { Q_UNUSED(aFormat); } |
|
77 #endif |
|
78 } // namespace |
|
79 |
|
80 QTM_USE_NAMESPACE |
|
81 |
|
82 #define CNT_SYMBIANSIM_MANAGER_NAME "symbiansim" |
|
83 |
|
84 Q_DEFINE_LATIN1_CONSTANT(KSimSyncTarget, "SIM"); |
|
85 Q_DEFINE_LATIN1_CONSTANT(KParameterKeySimStoreName, "store"); |
|
86 Q_DEFINE_LATIN1_CONSTANT(KParameterValueSimStoreNameAdn, "ADN"); |
|
87 Q_DEFINE_LATIN1_CONSTANT(KParameterValueSimStoreNameSdn, "SDN"); |
|
88 Q_DEFINE_LATIN1_CONSTANT(KParameterValueSimStoreNameFdn, "FDN"); |
|
89 |
|
90 class CntSimStore; |
|
91 class CntAbstractSimRequest; |
|
92 |
|
93 class CntSymbianSimEngineData : public QSharedData |
|
94 { |
|
95 public: |
|
96 CntSymbianSimEngineData(); |
|
97 ~CntSymbianSimEngineData(); |
|
98 |
|
99 CntSimStore *m_simStore; |
|
100 QMap<QContactAbstractRequest *, CntAbstractSimRequest *> m_asyncRequests; |
|
101 int m_phoneNumberMatchLen; |
|
102 }; |
|
103 |
|
104 class CntSymbianSimEngine : public QContactManagerEngine |
|
105 { |
|
106 Q_OBJECT |
|
107 |
|
108 public: |
|
109 CntSymbianSimEngine(const QMap<QString, QString>& parameters, QContactManager::Error* error); |
|
110 CntSymbianSimEngine(const CntSymbianSimEngine &other); |
|
111 ~CntSymbianSimEngine(); |
|
112 |
|
113 QString managerName() const; |
|
114 |
|
115 int managerVersion() const { return 1;} |
|
116 |
|
117 /* Defaulted functions - XXX check*/ |
|
118 QList<QVariant::Type> supportedDataTypes() const |
|
119 { |
|
120 return QContactManagerEngine::supportedDataTypes(); |
|
121 } |
|
122 |
|
123 /* Contacts - Accessors and Mutators */ |
|
124 QList<QContactLocalId> contactIds(const QContactFilter& filter, const QList<QContactSortOrder>& sortOrders, QContactManager::Error* error) const; |
|
125 QList<QContact> contacts(const QContactFilter& filter, const QList<QContactSortOrder>& sortOrders, const QContactFetchHint& fetchHint, QContactManager::Error* error) const; |
|
126 QContact contact(const QContactLocalId& contactId, const QContactFetchHint& fetchHint, QContactManager::Error* error) const; |
|
127 |
|
128 bool saveContacts(QList<QContact>* contacts, QMap<int, QContactManager::Error>* errorMap, QContactManager::Error* error); |
|
129 bool removeContacts(const QList<QContactLocalId>& contactIds, QMap<int, QContactManager::Error>* errorMap, QContactManager::Error* error); |
|
130 |
|
131 /* Synthesize the display label of a contact */ |
|
132 QString synthesizedDisplayLabel(const QContact& contact, QContactManager::Error* error) const; |
|
133 |
|
134 /* Definitions - Accessors and Mutators */ |
|
135 QMap<QString, QContactDetailDefinition> detailDefinitions(const QString& contactType, QContactManager::Error* error) const; |
|
136 |
|
137 /* Asynchronous Request Support */ |
|
138 void requestDestroyed(QContactAbstractRequest* req); |
|
139 bool startRequest(QContactAbstractRequest* req); |
|
140 bool cancelRequest(QContactAbstractRequest* req); |
|
141 bool waitForRequestFinished(QContactAbstractRequest* req, int msecs); |
|
142 |
|
143 /* Capabilities reporting */ |
|
144 bool hasFeature(QContactManager::ManagerFeature feature, const QString& contactType = QContactType::TypeContact) const; |
|
145 bool isFilterSupported(const QContactFilter& filter) const; |
|
146 QStringList supportedContactTypes() const; |
|
147 |
|
148 public: |
|
149 void updateDisplayLabel(QContact& contact) const; |
|
150 CntSimStore* simStore() { return d->m_simStore; } |
|
151 void setReadOnlyAccessConstraint(QContactDetail* detail) const; |
|
152 bool filter(const QContactFilter &filter, const QContact &contact); |
|
153 |
|
154 private: |
|
155 bool executeRequest(QContactAbstractRequest *req, QContactManager::Error* qtError) const; |
|
156 void getMatchLengthL(int &matchLength); |
|
157 |
|
158 private: |
|
159 QExplicitlySharedDataPointer<CntSymbianSimEngineData> d; |
|
160 }; |
|
161 |
|
162 class CntSymbianSimFactory : public QObject, public QContactManagerEngineFactory |
|
163 { |
|
164 Q_OBJECT |
|
165 Q_INTERFACES(QtMobility::QContactManagerEngineFactory) |
|
166 public: |
|
167 QContactManagerEngine* engine(const QMap<QString, QString>& parameters, QContactManager::Error* error); |
|
168 QString managerName() const; |
|
169 }; |
|
170 |
|
171 #endif //CNTSYMBIANSIMENGINE_H |