50
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "cntservices.h"
|
|
19 |
#include "cntglobal.h"
|
|
20 |
#include "cntdebug.h"
|
|
21 |
#include <cntabstractviewmanager.h>
|
53
|
22 |
#include "cntserviceviewmanager.h"
|
50
|
23 |
#include "cntimageutility.h"
|
|
24 |
#include "cntserviceviewparams.h"
|
53
|
25 |
#include <cntservicescontact.h>
|
50
|
26 |
|
|
27 |
#include <hbview.h>
|
|
28 |
#include <hblistview.h>
|
|
29 |
#include <qversitreader.h>
|
|
30 |
#include <qversitcontactimporter.h>
|
|
31 |
#include <qversitdocument.h>
|
|
32 |
#include <xqserviceprovider.h>
|
61
|
33 |
#include <cntabstractengine.h>
|
50
|
34 |
|
|
35 |
#include <QApplication>
|
|
36 |
#include <QPixmap>
|
|
37 |
#include <QFile>
|
|
38 |
#include <QUrl>
|
61
|
39 |
#include <QTextCodec>
|
|
40 |
|
|
41 |
const int Latin1CharSetMIB = 4;
|
50
|
42 |
|
|
43 |
CntServices::CntServices() :
|
|
44 |
mViewManager(NULL),
|
72
|
45 |
mCurrentProvider(NULL)
|
50
|
46 |
{
|
|
47 |
CNT_ENTRY
|
|
48 |
|
|
49 |
// Definition names supported in symbian back-end
|
|
50 |
m_definitionNames << QContactName::DefinitionName;
|
|
51 |
m_definitionNames << QContactNickname::DefinitionName;
|
|
52 |
m_definitionNames << QContactPhoneNumber::DefinitionName;
|
|
53 |
m_definitionNames << QContactEmailAddress::DefinitionName;
|
|
54 |
m_definitionNames << QContactAddress::DefinitionName;
|
|
55 |
m_definitionNames << QContactUrl::DefinitionName;
|
|
56 |
m_definitionNames << QContactBirthday::DefinitionName;
|
|
57 |
m_definitionNames << QContactOrganization::DefinitionName;
|
|
58 |
m_definitionNames << QContactSyncTarget::DefinitionName;
|
|
59 |
m_definitionNames << QContactNote::DefinitionName;
|
|
60 |
m_definitionNames << QContactFamily::DefinitionName;
|
|
61 |
m_definitionNames << QContactAvatar::DefinitionName;
|
|
62 |
m_definitionNames << QContactAnniversary::DefinitionName;
|
|
63 |
m_definitionNames << QContactGeoLocation::DefinitionName;
|
|
64 |
m_definitionNames << QContactGender::DefinitionName;
|
|
65 |
m_definitionNames << QContactOnlineAccount::DefinitionName;
|
|
66 |
|
|
67 |
CNT_EXIT
|
|
68 |
}
|
|
69 |
|
|
70 |
|
|
71 |
CntServices::~CntServices()
|
|
72 |
{
|
|
73 |
CNT_LOG
|
|
74 |
}
|
|
75 |
|
|
76 |
|
61
|
77 |
void CntServices::setEngine( CntAbstractEngine& aEngine )
|
|
78 |
{
|
|
79 |
CNT_LOG
|
|
80 |
mEngine = &aEngine;
|
|
81 |
mViewManager = &mEngine->viewManager();
|
|
82 |
CntServiceViewManager* srvMng = static_cast<CntServiceViewManager*>(mViewManager);
|
|
83 |
connect(srvMng, SIGNAL(applicationClosed()), this, SLOT(terminateService()));
|
|
84 |
}
|
50
|
85 |
|
|
86 |
void CntServices::singleFetch(
|
|
87 |
const QString &title, const QString &action,
|
|
88 |
CntAbstractServiceProvider& aServiceProvider )
|
|
89 |
{
|
|
90 |
CNT_ENTRY
|
|
91 |
mCurrentProvider = &aServiceProvider;
|
|
92 |
|
|
93 |
CntViewParameters params;
|
|
94 |
params.insert(EViewId, serviceContactFetchView);
|
|
95 |
params.insert(ESelectedAction, action);
|
|
96 |
params.insert(KCntServiceViewParamTitle, title);
|
|
97 |
// SINGLE fetch
|
|
98 |
params.insert(ESelectionMode, HbAbstractItemView::SingleSelection);
|
|
99 |
|
|
100 |
mViewManager->changeView(params);
|
|
101 |
CNT_EXIT
|
|
102 |
}
|
|
103 |
|
|
104 |
|
|
105 |
void CntServices::multiFetch(
|
|
106 |
const QString &title, const QString &action,
|
|
107 |
CntAbstractServiceProvider& aServiceProvider )
|
|
108 |
{
|
|
109 |
CNT_ENTRY
|
|
110 |
mCurrentProvider = &aServiceProvider;
|
|
111 |
|
|
112 |
CntViewParameters params;
|
|
113 |
params.insert(EViewId, serviceContactFetchView);
|
|
114 |
params.insert(ESelectedAction, action);
|
|
115 |
params.insert(KCntServiceViewParamTitle, title);
|
|
116 |
// MULTI fetch
|
|
117 |
params.insert(ESelectionMode, HbAbstractItemView::MultiSelection);
|
|
118 |
mViewManager->changeView(params);
|
|
119 |
CNT_EXIT
|
|
120 |
}
|
|
121 |
|
53
|
122 |
void CntServices::editCreateNew(const QString &definitionName, const QString &value,
|
|
123 |
CntAbstractServiceProvider& aServiceProvider, bool defaultForOnlineAccountIsImpp )
|
|
124 |
{
|
|
125 |
CNT_ENTRY
|
|
126 |
editCreateNew( definitionName, value, QString(), aServiceProvider, defaultForOnlineAccountIsImpp);
|
|
127 |
CNT_EXIT
|
|
128 |
}
|
50
|
129 |
|
53
|
130 |
void CntServices::editCreateNew(const QString &definitionName, const QString &value, const QString& subType,
|
|
131 |
CntAbstractServiceProvider& aServiceProvider, bool defaultForOnlineAccountIsImpp )
|
50
|
132 |
{
|
|
133 |
CNT_ENTRY
|
|
134 |
mCurrentProvider = &aServiceProvider;
|
|
135 |
|
|
136 |
QContact contact;
|
|
137 |
|
|
138 |
if (definitionName == QContactPhoneNumber::DefinitionName)
|
53
|
139 |
{
|
50
|
140 |
QContactPhoneNumber phoneNumber;
|
|
141 |
phoneNumber.setNumber(value);
|
53
|
142 |
if (!subType.isEmpty())
|
|
143 |
{
|
|
144 |
phoneNumber.setSubTypes(subType);
|
50
|
145 |
}
|
53
|
146 |
else
|
|
147 |
{
|
|
148 |
phoneNumber.setSubTypes(QContactPhoneNumber::SubTypeMobile); // Mobile is the default if subtype is not given.
|
|
149 |
}
|
|
150 |
contact.saveDetail(&phoneNumber);
|
|
151 |
}
|
50
|
152 |
else if (definitionName == QContactEmailAddress::DefinitionName)
|
53
|
153 |
{
|
50
|
154 |
QContactEmailAddress email;
|
|
155 |
email.setEmailAddress(value);
|
53
|
156 |
// Email addresses can't have subtypes.
|
50
|
157 |
contact.saveDetail(&email);
|
53
|
158 |
}
|
50
|
159 |
else if (definitionName == QContactOnlineAccount::DefinitionName)
|
53
|
160 |
{
|
50
|
161 |
QContactOnlineAccount account;
|
53
|
162 |
fillOnlineAccount( account, value, subType, defaultForOnlineAccountIsImpp);
|
50
|
163 |
contact.saveDetail(&account);
|
53
|
164 |
}
|
50
|
165 |
|
|
166 |
// Launch editor now
|
|
167 |
CntViewParameters params;
|
|
168 |
params.insert(EViewId, serviceEditView);
|
|
169 |
QVariant var;
|
|
170 |
var.setValue(contact);
|
|
171 |
params.insert(ESelectedContact, var);
|
|
172 |
mViewManager->changeView(params);
|
|
173 |
CNT_EXIT
|
|
174 |
}
|
|
175 |
|
|
176 |
|
61
|
177 |
void CntServices::editCreateNewFromVCard(const QString &fileName,
|
50
|
178 |
CntAbstractServiceProvider& aServiceProvider )
|
|
179 |
{
|
|
180 |
CNT_ENTRY
|
|
181 |
mCurrentProvider = &aServiceProvider;
|
|
182 |
|
|
183 |
CntImageUtility imageUtility;
|
|
184 |
QContact contact;
|
|
185 |
QVersitReader reader;
|
61
|
186 |
QFile inputFile(fileName);
|
|
187 |
if (!inputFile.open(QIODevice::ReadOnly))
|
50
|
188 |
return;
|
|
189 |
|
61
|
190 |
// Versit parser default codec is UTF-8
|
|
191 |
// Check if decoding text to unicode is possible, else use Latin-1 text codec
|
|
192 |
QByteArray ba = inputFile.readAll();
|
|
193 |
if(!ba.isEmpty())
|
|
194 |
{
|
|
195 |
QTextCodec *c = QTextCodec::codecForUtfText(ba);
|
|
196 |
// Text codec returned is Latin-1, set default to Latin-1
|
|
197 |
if(c->mibEnum()==Latin1CharSetMIB)
|
|
198 |
reader.setDefaultCodec(QTextCodec::codecForName("ISO 8859-1"));
|
|
199 |
}
|
|
200 |
inputFile.close();
|
|
201 |
|
|
202 |
QFile vCardFile(fileName);
|
|
203 |
if (!vCardFile.open(QIODevice::ReadOnly))
|
|
204 |
return;
|
|
205 |
reader.setDevice(&vCardFile);
|
50
|
206 |
reader.startReading();
|
|
207 |
reader.waitForFinished();
|
|
208 |
// Use the resulting document(s)...
|
|
209 |
QVersitContactImporter importer;
|
|
210 |
QList<QVersitDocument> versitDocuments = reader.results();
|
|
211 |
if(versitDocuments.count() > 0
|
|
212 |
&& importer.importDocuments(versitDocuments))
|
|
213 |
{
|
|
214 |
QList<QContact> contacts = importer.contacts();
|
|
215 |
if(contacts.count() > 0)
|
|
216 |
contact = contacts.first();
|
|
217 |
}
|
61
|
218 |
vCardFile.close();
|
50
|
219 |
|
66
|
220 |
// check if the contact is in db already.
|
|
221 |
updateLocalId( contact );
|
|
222 |
|
50
|
223 |
// Save thumbnail images
|
|
224 |
QList<QContactThumbnail> details = contact.details<QContactThumbnail>();
|
|
225 |
for (int i = 0;i < details.count();i++)
|
|
226 |
{
|
|
227 |
if (!details.at(i).thumbnail().isNull())
|
|
228 |
{
|
|
229 |
QString imagepath;
|
|
230 |
QPixmap pixmap = QPixmap::fromImage(details.at(i).thumbnail());
|
|
231 |
if(imageUtility.createImage(pixmap,imagepath))
|
|
232 |
{
|
|
233 |
// Update contact detail
|
|
234 |
QContactAvatar detail=details.at(i);
|
|
235 |
detail.setImageUrl(imagepath);
|
|
236 |
contact.saveDetail(&detail);
|
|
237 |
}
|
|
238 |
}
|
|
239 |
}
|
|
240 |
|
|
241 |
removeNotSupportedDetails(contact);
|
|
242 |
removeNotSupportedFields(contact);
|
|
243 |
|
|
244 |
// Launch editor now
|
|
245 |
CntViewParameters params;
|
|
246 |
params.insert(EViewId, serviceEditView);
|
|
247 |
QVariant var;
|
|
248 |
var.setValue(contact);
|
|
249 |
params.insert(ESelectedContact, var);
|
|
250 |
mViewManager->changeView(params);
|
|
251 |
CNT_EXIT
|
|
252 |
}
|
|
253 |
|
53
|
254 |
void CntServices::editUpdateExisting(const QString &definitionName, const QString &value,
|
|
255 |
CntAbstractServiceProvider& aServiceProvider, bool defaultForOnlineAccountIsImpp )
|
|
256 |
{
|
|
257 |
CNT_ENTRY
|
|
258 |
editUpdateExisting( definitionName, value, QString(), aServiceProvider, defaultForOnlineAccountIsImpp );
|
|
259 |
CNT_EXIT
|
|
260 |
}
|
50
|
261 |
|
53
|
262 |
void CntServices::editUpdateExisting(const QString &definitionName, const QString &value, const QString& subType,
|
|
263 |
CntAbstractServiceProvider& aServiceProvider, bool defaultForOnlineAccountIsImpp )
|
50
|
264 |
{
|
|
265 |
CNT_ENTRY
|
|
266 |
mCurrentProvider = &aServiceProvider;
|
|
267 |
|
|
268 |
QContactDetail detail;
|
|
269 |
|
|
270 |
if (definitionName == QContactPhoneNumber::DefinitionName)
|
|
271 |
{
|
|
272 |
QContactPhoneNumber phoneNumber;
|
|
273 |
phoneNumber.setNumber(value);
|
53
|
274 |
if (!subType.isEmpty())
|
|
275 |
{
|
|
276 |
phoneNumber.setSubTypes(subType);
|
|
277 |
}
|
|
278 |
else
|
|
279 |
{
|
|
280 |
phoneNumber.setSubTypes(QContactPhoneNumber::SubTypeMobile);
|
|
281 |
}
|
50
|
282 |
detail = phoneNumber;
|
|
283 |
}
|
|
284 |
else if (definitionName == QContactEmailAddress::DefinitionName)
|
|
285 |
{
|
|
286 |
QContactEmailAddress email;
|
|
287 |
email.setEmailAddress(value);
|
53
|
288 |
// Email addresses can't have subtypes.
|
50
|
289 |
detail = email;
|
|
290 |
}
|
|
291 |
else if (definitionName == QContactOnlineAccount::DefinitionName)
|
|
292 |
{
|
|
293 |
QContactOnlineAccount account;
|
53
|
294 |
fillOnlineAccount( account, value, subType, defaultForOnlineAccountIsImpp);
|
50
|
295 |
detail = account;
|
|
296 |
}
|
|
297 |
|
|
298 |
CntViewParameters params;
|
|
299 |
params.insert(EViewId, serviceContactSelectionView);
|
|
300 |
QVariant var;
|
|
301 |
var.setValue(detail);
|
|
302 |
params.insert(ESelectedDetail, var);
|
|
303 |
mViewManager->changeView(params);
|
|
304 |
CNT_EXIT
|
|
305 |
}
|
|
306 |
|
|
307 |
void CntServices::editExisting(int contactId,
|
|
308 |
CntAbstractServiceProvider& aServiceProvider)
|
|
309 |
{
|
|
310 |
CNT_ENTRY
|
|
311 |
mCurrentProvider = &aServiceProvider;
|
|
312 |
|
|
313 |
// Give parameters for launching editor.
|
|
314 |
CntViewParameters params;
|
|
315 |
params.insert(EViewId, serviceEditView);
|
|
316 |
|
54
|
317 |
QContact contact = contactManager()->contact(contactId);
|
50
|
318 |
QVariant varContact;
|
|
319 |
varContact.setValue(contact);
|
|
320 |
params.insert(ESelectedContact, varContact);
|
|
321 |
mViewManager->changeView(params);
|
|
322 |
CNT_EXIT
|
|
323 |
}
|
|
324 |
|
|
325 |
|
|
326 |
void CntServices::launchContactCard(int aContactId,
|
|
327 |
CntAbstractServiceProvider& aServiceProvider )
|
|
328 |
{
|
|
329 |
CNT_ENTRY
|
|
330 |
mCurrentProvider = &aServiceProvider;
|
|
331 |
|
54
|
332 |
QContact contact = contactManager()->contact(aContactId);
|
50
|
333 |
|
|
334 |
// Launch Contact Card view
|
|
335 |
CntViewParameters params;
|
|
336 |
params.insert(EViewId, serviceContactCardView);
|
|
337 |
QVariant var;
|
|
338 |
var.setValue(contact);
|
|
339 |
params.insert(ESelectedContact, var);
|
|
340 |
mViewManager->changeView( params );
|
|
341 |
CNT_EXIT
|
|
342 |
}
|
|
343 |
|
|
344 |
|
|
345 |
void CntServices::launchTemporaryContactCard(const QString &definitionName, const QString &value,
|
|
346 |
CntAbstractServiceProvider& aServiceProvider )
|
|
347 |
{
|
|
348 |
CNT_ENTRY
|
|
349 |
mCurrentProvider = &aServiceProvider;
|
|
350 |
|
|
351 |
QContact contact;
|
|
352 |
QContactDetail detail;
|
|
353 |
|
53
|
354 |
QContactName name;
|
|
355 |
name.setFirstName(hbTrId("txt_phob_list_unknown"));
|
|
356 |
contact.saveDetail(&name);
|
|
357 |
|
50
|
358 |
if (definitionName == QContactPhoneNumber::DefinitionName)
|
|
359 |
{
|
|
360 |
QContactPhoneNumber phoneNumber;
|
|
361 |
phoneNumber.setNumber(value);
|
|
362 |
phoneNumber.setSubTypes(QContactPhoneNumber::SubTypeMobile);
|
|
363 |
contact.saveDetail(&phoneNumber);
|
|
364 |
detail = phoneNumber;
|
|
365 |
}
|
|
366 |
else if (definitionName == QContactEmailAddress::DefinitionName)
|
|
367 |
{
|
|
368 |
QContactEmailAddress email;
|
|
369 |
email.setEmailAddress(value);
|
|
370 |
contact.saveDetail(&email);
|
|
371 |
detail = email;
|
|
372 |
}
|
|
373 |
else if (definitionName == QContactOnlineAccount::DefinitionName)
|
|
374 |
{
|
|
375 |
QContactOnlineAccount account;
|
|
376 |
account.setAccountUri(value);
|
|
377 |
account.setSubTypes(QContactOnlineAccount::SubTypeSipVoip);
|
|
378 |
contact.saveDetail(&account);
|
|
379 |
detail = account;
|
|
380 |
}
|
|
381 |
|
|
382 |
// Launch the view
|
|
383 |
CntViewParameters params;
|
|
384 |
params.insert(EViewId, serviceAssignContactCardView);
|
|
385 |
QVariant var;
|
|
386 |
var.setValue(contact);
|
|
387 |
params.insert(ESelectedContact, var);
|
|
388 |
QVariant varDetail;
|
|
389 |
varDetail.setValue(detail);
|
|
390 |
params.insert(ESelectedDetail, varDetail);
|
|
391 |
mViewManager->changeView(params);
|
|
392 |
CNT_EXIT
|
|
393 |
}
|
|
394 |
|
54
|
395 |
void CntServices::launchGroupMemberView(int aContactId,
|
|
396 |
CntAbstractServiceProvider& aServiceProvider )
|
|
397 |
{
|
|
398 |
CNT_ENTRY
|
|
399 |
mCurrentProvider = &aServiceProvider;
|
|
400 |
|
|
401 |
QContact contact = contactManager()->contact(aContactId);
|
|
402 |
|
|
403 |
// Launch Group member view
|
|
404 |
CntViewParameters params;
|
|
405 |
params.insert(EViewId, serviceGroupMemberView);
|
|
406 |
QVariant var;
|
|
407 |
var.setValue(contact);
|
|
408 |
params.insert(ESelectedGroupContact, var);
|
|
409 |
mViewManager->changeView( params );
|
|
410 |
CNT_EXIT
|
|
411 |
}
|
50
|
412 |
|
53
|
413 |
void CntServices::quitApp()
|
|
414 |
{
|
72
|
415 |
CNT_ENTRY
|
|
416 |
|
|
417 |
qApp->quit();
|
|
418 |
|
53
|
419 |
CNT_EXIT
|
|
420 |
}
|
|
421 |
|
50
|
422 |
void CntServices::removeNotSupportedDetails(QContact& contact)
|
|
423 |
{
|
|
424 |
CNT_ENTRY
|
|
425 |
// Check definition map, remove details not supported
|
|
426 |
for (int i=0; i < contact.details().count(); i++)
|
|
427 |
{
|
|
428 |
if (!m_definitionNames.contains(contact.details().at(i).definitionName()))
|
|
429 |
{
|
|
430 |
QContactDetail detail= contact.details().at(i);
|
|
431 |
contact.removeDetail(&detail);
|
|
432 |
}
|
|
433 |
}
|
|
434 |
CNT_EXIT
|
|
435 |
}
|
|
436 |
|
|
437 |
void CntServices::removeNotSupportedFields(QContact& contact)
|
|
438 |
{
|
|
439 |
CNT_ENTRY
|
|
440 |
QList<QContactDetail> removeList;
|
|
441 |
|
|
442 |
// Not all fields are supported in symbian back-end
|
|
443 |
// Remove not supported fields
|
|
444 |
for (int i=0; i < contact.details().count(); i++)
|
|
445 |
{
|
|
446 |
QContactDetail detail = contact.details().at(i);
|
|
447 |
if(detail.definitionName() == QContactAddress::DefinitionName)
|
|
448 |
{
|
|
449 |
QContactAddress addrDetail = static_cast<QContactAddress>(detail);
|
|
450 |
|
|
451 |
// Sub-types not supported
|
|
452 |
if(detail.removeValue(QContactAddress::FieldSubTypes))
|
|
453 |
contact.saveDetail(&detail);
|
|
454 |
}
|
|
455 |
else if(detail.definitionName() == QContactAnniversary::DefinitionName)
|
|
456 |
{
|
|
457 |
QContactAnniversary annivDetail = static_cast<QContactAnniversary>(detail);
|
|
458 |
|
|
459 |
// Sub-types not supported
|
|
460 |
if(detail.removeValue(QContactAnniversary::FieldSubType))
|
|
461 |
contact.saveDetail(&detail);
|
|
462 |
|
|
463 |
// Context not supported
|
|
464 |
if(detail.removeValue(QContactDetail::FieldContext))
|
|
465 |
contact.saveDetail(&detail);
|
|
466 |
}
|
|
467 |
else if(detail.definitionName() == QContactPhoneNumber::DefinitionName)
|
|
468 |
{
|
|
469 |
QContactPhoneNumber phoneDetail = static_cast<QContactPhoneNumber>(detail);
|
|
470 |
|
|
471 |
if(phoneDetail.subTypes().size() > 0 )
|
|
472 |
{
|
|
473 |
// Sub-types not supported
|
|
474 |
if(phoneDetail.subTypes().contains(QContactPhoneNumber::SubTypeVoice)
|
|
475 |
|| phoneDetail.subTypes().contains(QContactPhoneNumber::SubTypeMessagingCapable))
|
|
476 |
{
|
54
|
477 |
// Default to subtype mobile
|
|
478 |
QStringList l;
|
|
479 |
l << QLatin1String(QContactPhoneNumber::SubTypeMobile);
|
|
480 |
detail.setValue(QContactPhoneNumber::FieldSubTypes, l);
|
50
|
481 |
contact.saveDetail(&detail);
|
|
482 |
}
|
|
483 |
}
|
|
484 |
}
|
|
485 |
else if(detail.definitionName() == QContactUrl::DefinitionName)
|
|
486 |
{
|
|
487 |
QContactUrl urlDetail = static_cast<QContactUrl>(detail);
|
|
488 |
|
|
489 |
QString stype=QContactUrl::SubTypeHomePage;
|
|
490 |
if(urlDetail.subType().compare(stype) != 0)
|
|
491 |
{
|
|
492 |
detail.removeValue(QContactUrl::FieldSubType);
|
|
493 |
contact.saveDetail(&detail);
|
|
494 |
}
|
|
495 |
}
|
|
496 |
}
|
|
497 |
CNT_EXIT
|
|
498 |
}
|
|
499 |
|
53
|
500 |
void CntServices::fillOnlineAccount( QContactOnlineAccount& account, const QString& value,
|
|
501 |
const QString& subType, bool defaultForOnlineAccountIsImpp )
|
|
502 |
{
|
|
503 |
// The value should normally consist of two parts:
|
|
504 |
// <service provider>:<user ID>
|
|
505 |
// for eg. "serviceprovider:jack@serviceprovider.com"
|
|
506 |
QStringList accountDetails = value.split(":");
|
|
507 |
if (accountDetails.count() == 1)
|
|
508 |
{
|
|
509 |
// For some reason it only had one part, so we're assuming it's the user ID.
|
|
510 |
account.setAccountUri(accountDetails.at(0));
|
|
511 |
}
|
|
512 |
else if (accountDetails.count() >= 2)
|
|
513 |
{
|
|
514 |
account.setServiceProvider(accountDetails.at(0));
|
|
515 |
account.setAccountUri(accountDetails.at(1)); // the user ID
|
|
516 |
}
|
|
517 |
|
|
518 |
if (!subType.isEmpty())
|
|
519 |
{
|
|
520 |
account.setSubTypes(subType);
|
|
521 |
}
|
|
522 |
else
|
|
523 |
{
|
|
524 |
if (defaultForOnlineAccountIsImpp)
|
|
525 |
{
|
|
526 |
account.setSubTypes( QContactOnlineAccount::SubTypeImpp );
|
|
527 |
}
|
|
528 |
else
|
|
529 |
{
|
|
530 |
account.setSubTypes( QContactOnlineAccount::SubTypeSipVoip );
|
|
531 |
}
|
|
532 |
}
|
|
533 |
}
|
|
534 |
|
66
|
535 |
void CntServices::updateLocalId( QContact& aContact )
|
|
536 |
{
|
|
537 |
CNT_ENTRY
|
|
538 |
if ( aContact.localId() == 0 )
|
|
539 |
{
|
|
540 |
QContactGuid guid = aContact.detail<QContactGuid>();
|
|
541 |
QString guidString = guid.guid();
|
|
542 |
|
|
543 |
QContactDetailFilter filter;
|
|
544 |
filter.setDetailDefinitionName( QContactGuid::DefinitionName, QContactGuid::FieldGuid );
|
|
545 |
filter.setValue( guid.guid() );
|
|
546 |
|
|
547 |
QContactManager& cm = mEngine->contactManager( SYMBIAN_BACKEND );
|
|
548 |
QList<QContactLocalId> idList = cm.contactIds( filter, QList<QContactSortOrder>() );
|
|
549 |
int count = idList.count();
|
|
550 |
|
|
551 |
if ( !idList.isEmpty() )
|
|
552 |
{
|
|
553 |
QContactId id;
|
|
554 |
id.setLocalId( idList.first() );
|
|
555 |
id.setManagerUri( cm.managerUri() );
|
|
556 |
|
|
557 |
aContact.setId( id );
|
|
558 |
}
|
|
559 |
}
|
|
560 |
CNT_EXIT
|
|
561 |
}
|
50
|
562 |
// This method is inherited from CntAbstractServiceProvider
|
|
563 |
void CntServices::CompleteServiceAndCloseApp(const QVariant& retValue)
|
|
564 |
{
|
|
565 |
CNT_ENTRY
|
|
566 |
if ( mCurrentProvider )
|
54
|
567 |
{
|
50
|
568 |
mCurrentProvider->CompleteServiceAndCloseApp( retValue );
|
54
|
569 |
}
|
50
|
570 |
CNT_EXIT
|
|
571 |
}
|
|
572 |
|
61
|
573 |
// This method is inherited from CntAbstractServiceProvider
|
|
574 |
void CntServices::overrideReturnValue(const QVariant& retValue)
|
|
575 |
{
|
|
576 |
CNT_ENTRY
|
|
577 |
if ( mCurrentProvider )
|
|
578 |
{
|
|
579 |
mCurrentProvider->overrideReturnValue( retValue );
|
|
580 |
}
|
|
581 |
CNT_EXIT
|
|
582 |
}
|
|
583 |
|
|
584 |
// This method is inherited from CntAbstractServiceProvider
|
|
585 |
bool CntServices::allowSubViewsExit()
|
|
586 |
{
|
|
587 |
bool allow = true;
|
|
588 |
if ( mCurrentProvider )
|
|
589 |
{
|
|
590 |
allow = mCurrentProvider->allowSubViewsExit();
|
|
591 |
}
|
|
592 |
|
|
593 |
return allow;
|
|
594 |
}
|
|
595 |
|
53
|
596 |
void CntServices::terminateService()
|
50
|
597 |
{
|
|
598 |
CNT_ENTRY
|
53
|
599 |
if ( mCurrentProvider )
|
54
|
600 |
{
|
53
|
601 |
// Complete the service with KCntServicesTerminated return value
|
|
602 |
QVariant var(KCntServicesTerminated);
|
|
603 |
mCurrentProvider->CompleteServiceAndCloseApp( var );
|
54
|
604 |
}
|
50
|
605 |
CNT_EXIT
|
|
606 |
}
|
|
607 |
|
54
|
608 |
QContactManager* CntServices::contactManager()
|
|
609 |
{
|
61
|
610 |
if ( mEngine )
|
|
611 |
return &mEngine->contactManager(SYMBIAN_BACKEND);
|
54
|
612 |
return NULL;
|
|
613 |
}
|
|
614 |
|
50
|
615 |
Q_IMPLEMENT_USER_METATYPE(CntServicesContact)
|
|
616 |
Q_IMPLEMENT_USER_METATYPE_NO_OPERATORS(CntServicesContactList)
|
53
|
617 |
|