28 #include <HbMenu> |
28 #include <HbMenu> |
29 #include <HbAction> |
29 #include <HbAction> |
30 #include <cntservicescontact.h> |
30 #include <cntservicescontact.h> |
31 #include <qtcontacts.h> |
31 #include <qtcontacts.h> |
32 #include <XQServiceRequest.h> |
32 #include <XQServiceRequest.h> |
33 |
33 #include <xqaiwrequest.h> |
34 |
34 |
35 QTM_USE_NAMESPACE |
35 QTM_USE_NAMESPACE |
36 |
36 |
37 //consts |
37 //consts |
38 |
38 |
39 //regexp |
39 //regexp |
40 const QString NUMBER_PATTERN("(\\(|\\+|\\d)((?:\\d{2,})((?:[\\s-/.\\)\\()])*(?:(\\d+|\\))))*)|((\\*#)(?:\\d+(\\*|#)(?:\\d+#)?))"); |
40 const QString NUMBER_PATTERN("(\\(|\\+|\\d)((?:\\d{2,})((?:[\\s-/.\\)\\()])*(?:(\\d+|\\))))*)|((\\*#)(?:\\d+(\\*|#)(?:\\d+#)?))"); |
41 |
41 |
42 const QString EMAIL_PATTERN("[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?"); |
42 const QString EMAIL_PATTERN("[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?"); |
43 |
43 |
44 const QString URL_PATTERN("(((ht|f|rt)(tp|sp)(s?)\\:\\/\\/)|(www|wap)(?:\\.))(([-\\w]*[0-9a-zA-Z])+(:(0-9)*)*(\\/?)([a-zA-Z0-9\\-\\?\\,\'\\/\\\\+&%\\$#_=~]*)(\\.)([-\\w]*[0-9a-zA-Z])+(:(0-9)*)*(\\/?)([a-zA-Z0-9\\-\\?\\,\'\\/\\\\+&%\\$#_=~]*))+"); |
44 const QString URL_PATTERN("(((ht|f|rt)(tp|sp)(s?)\\:\\/\\/)|(www|wap)(?:\\.))(([-\\w]*[0-9a-zA-Z])+(:(0-9)*)*(\\/?)([a-zA-Z0-9\\-\\?\\,\'\\/\\\\+&%\\$#_=~]*)(\\.)([-\\w]*[0-9a-zA-Z])+(:(0-9)*)*(\\/?)([a-zA-Z0-9\\-\\?\\,\'\\/\\\\+&%\\$#_=~]*))+"); |
45 |
45 |
46 //rules |
46 //rules |
47 const QString NUMBER_RULE("NUMBER_RULE"); |
47 const QString NUMBER_RULE("NUMBER_RULE"); |
312 this, SLOT(onServiceRequestCompleted())); |
312 this, SLOT(onServiceRequestCompleted())); |
313 |
313 |
314 connect(serviceRequest, SIGNAL(requestError(int)), |
314 connect(serviceRequest, SIGNAL(requestError(int)), |
315 this, SLOT(onServiceRequestCompleted())); |
315 this, SLOT(onServiceRequestCompleted())); |
316 |
316 |
317 *serviceRequest << phoneNumber; |
317 *serviceRequest << phoneNumber; |
318 serviceRequest->send(); |
318 serviceRequest->send(); |
319 } |
319 } |
320 } |
320 } |
321 |
321 |
322 void UniViewerTextItem::sendMessage() |
322 void UniViewerTextItem::sendMessage() |
323 { |
323 { |
335 |
335 |
336 void UniViewerTextItem::createEmail() |
336 void UniViewerTextItem::createEmail() |
337 { |
337 { |
338 HbAction* action = qobject_cast<HbAction*>(sender()); |
338 HbAction* action = qobject_cast<HbAction*>(sender()); |
339 |
339 |
340 if(action) |
340 if ( action ) |
341 { |
341 { |
342 QString emailId = action->data().toString(); |
342 QString emailId = action->data().toString(); |
343 emailId.remove(EMAIL_RULE); |
343 emailId.remove(EMAIL_RULE); |
344 //invoke email editor service & pass emailId. |
344 |
|
345 // Launch email editor |
|
346 QString serviceName("com.nokia.services.commonemail"); |
|
347 QString interfaceName("imessage.send"); |
|
348 QString operation("send(QVariant)"); |
|
349 XQAiwRequest* request = mAppManager.create(serviceName, interfaceName, |
|
350 operation, true); |
|
351 if ( request == NULL ) |
|
352 { |
|
353 return; |
|
354 } |
|
355 |
|
356 // Fill args |
|
357 QStringList recipients; |
|
358 recipients.append(emailId); |
|
359 |
|
360 QMap<QString,QVariant> map; |
|
361 map.insert(QString("to"),recipients); |
|
362 |
|
363 QList<QVariant> args; |
|
364 args.append(map); |
|
365 |
|
366 // Result handlers |
|
367 connect (request, SIGNAL(requestOk(const QVariant&)), |
|
368 this, SLOT(handleOk(const QVariant&))); |
|
369 connect (request, SIGNAL(requestError(const QVariant&)), |
|
370 this, SLOT(handleError(const QVariant&))); |
|
371 |
|
372 request->setArguments(args); |
|
373 request->send(); |
|
374 delete request; |
345 } |
375 } |
346 } |
376 } |
347 |
377 |
348 void UniViewerTextItem::openLink() |
378 void UniViewerTextItem::openLink() |
349 { |
379 { |
431 args << data; |
461 args << data; |
432 } |
462 } |
433 } |
463 } |
434 |
464 |
435 //service stuff. |
465 //service stuff. |
436 QString serviceName("com.nokia.services.phonebookservices.Fetch"); |
466 QString serviceName("com.nokia.services.phonebookservices"); |
437 |
467 |
438 XQServiceRequest* serviceRequest = new XQServiceRequest(serviceName,operation,false); |
468 XQAiwRequest* request; |
439 |
469 request = mAppManager.create(serviceName, "Fetch", operation, true); // embedded |
440 connect(serviceRequest, SIGNAL(requestCompleted(QVariant)), |
470 if ( request == NULL ) |
441 this, SLOT(onServiceRequestCompleted())); |
471 { |
442 |
472 return; |
443 connect(serviceRequest, SIGNAL(requestError(int)), |
473 } |
444 this, SLOT(onServiceRequestCompleted())); |
474 |
445 |
475 // Result handlers |
446 serviceRequest->setArguments(args); |
476 connect (request, SIGNAL(requestOk(const QVariant&)), |
447 serviceRequest->send(); |
477 this, SLOT(handleOk(const QVariant&))); |
|
478 connect (request, SIGNAL(requestError(const QVariant&)), |
|
479 this, SLOT(handleError(const QVariant&))); |
|
480 |
|
481 request->setArguments(args); |
|
482 request->send(); |
|
483 delete request; |
448 } |
484 } |
449 } |
485 } |
450 |
486 |
451 |
487 |
452 void UniViewerTextItem::saveToContacts() |
488 void UniViewerTextItem::saveToContacts() |
477 QContactDetailFilter phoneFilter; |
513 QContactDetailFilter phoneFilter; |
478 phoneFilter.setDetailDefinitionName(fieldName, fieldType); |
514 phoneFilter.setDetailDefinitionName(fieldName, fieldType); |
479 phoneFilter.setValue(value); |
515 phoneFilter.setValue(value); |
480 phoneFilter.setMatchFlags(QContactFilter::MatchEndsWith); |
516 phoneFilter.setMatchFlags(QContactFilter::MatchEndsWith); |
481 |
517 |
482 QList<QContactLocalId> matchingContacts = phonebookManager.contacts(phoneFilter); |
518 QList<QContactSortOrder> sortOrder; |
|
519 QList<QContact> matchingContacts = phonebookManager.contacts( |
|
520 phoneFilter, |
|
521 sortOrder, |
|
522 QStringList()); |
483 |
523 |
484 if ( matchingContacts.count() > 0 ) |
524 if ( matchingContacts.count() > 0 ) |
485 { |
525 { |
486 contactId = matchingContacts.at(0); |
526 contactId = matchingContacts.at(0).localId();; |
487 } |
527 } |
488 |
528 |
489 return contactId; |
529 return contactId; |
490 } |
530 } |
491 |
531 |
526 |
566 |
527 cursor.clearSelection(); |
567 cursor.clearSelection(); |
528 } |
568 } |
529 } |
569 } |
530 } |
570 } |
|
571 |
|
572 //--------------------------------------------------------------- |
|
573 // UniViewerTextItem::handleOk |
|
574 // |
|
575 //--------------------------------------------------------------- |
|
576 void UniViewerTextItem::handleOk(const QVariant& result) |
|
577 { |
|
578 Q_UNUSED(result) |
|
579 } |
|
580 |
|
581 //--------------------------------------------------------------- |
|
582 // UniViewerTextItem::handleError |
|
583 // |
|
584 //--------------------------------------------------------------- |
|
585 void UniViewerTextItem::handleError(int errorCode, const QString& errorMessage) |
|
586 { |
|
587 Q_UNUSED(errorMessage) |
|
588 Q_UNUSED(errorCode) |
|
589 } |