25 #include <HbInstantFeedback> |
25 #include <HbInstantFeedback> |
26 #include <HbFrameItem> |
26 #include <HbFrameItem> |
27 #include <qcontactphonenumber.h> |
27 #include <qcontactphonenumber.h> |
28 #include <qcontactavatar.h> |
28 #include <qcontactavatar.h> |
29 #include <xqaiwrequest.h> |
29 #include <xqaiwrequest.h> |
|
30 #include <xqaiwdecl.h> |
30 #include <xqappmgr.h> |
31 #include <xqappmgr.h> |
31 #include <xqservicerequest.h> |
32 #include <xqservicerequest.h> |
32 #include <cntservicescontact.h> |
33 #include <cntservicescontact.h> |
33 #include <QGraphicsSceneMouseEvent> |
34 #include <QGraphicsSceneMouseEvent> |
34 #include <HbMenu> |
35 #include <HbMenu> |
55 |
56 |
56 // LOCALIZATION CONSTANTS |
57 // LOCALIZATION CONSTANTS |
57 #define LOC_RECEIVED_FILES hbTrId("txt_messaging_title_received_files") |
58 #define LOC_RECEIVED_FILES hbTrId("txt_messaging_title_received_files") |
58 #define LOC_MENU_CONTACT_INFO hbTrId("txt_messaging_menu_contact_info") |
59 #define LOC_MENU_CONTACT_INFO hbTrId("txt_messaging_menu_contact_info") |
59 #define LOC_COMMON_MENU_CALL hbTrId("txt_common_menu_call_verb") |
60 #define LOC_COMMON_MENU_CALL hbTrId("txt_common_menu_call_verb") |
60 #define LOC_SAVETO_CONTACTS hbTrId("txt_messaging_menu_save_to_contacts") |
|
61 |
61 |
62 // LOCAL FUNCTIONS |
62 // LOCAL FUNCTIONS |
63 |
63 |
64 //--------------------------------------------------------------- |
64 //--------------------------------------------------------------- |
65 // MsgContactCardWidget::MsgContactCardWidget |
65 // MsgContactCardWidget::MsgContactCardWidget |
85 // @see header |
85 // @see header |
86 //--------------------------------------------------------------- |
86 //--------------------------------------------------------------- |
87 void MsgContactCardWidget::init() |
87 void MsgContactCardWidget::init() |
88 { |
88 { |
89 this->setProperty("state", "normal"); |
89 this->setProperty("state", "normal"); |
90 this->grabGesture(Qt::TapGesture); |
|
91 |
90 |
92 HbFrameItem *frameItem = new HbFrameItem(BG_FRAME_NORMAL, HbFrameDrawer::NinePieces, this); |
91 HbFrameItem *frameItem = new HbFrameItem(BG_FRAME_NORMAL, HbFrameDrawer::NinePieces, this); |
93 this->setBackgroundItem(frameItem); |
92 this->setBackgroundItem(frameItem); |
94 |
93 |
95 mAvatarIconItem = new HbIconItem(this); |
94 mAvatarIconItem = new HbIconItem(this); |
228 qint64 convId = ConversationsEngine::instance()->getCurrentConversationId(); |
227 qint64 convId = ConversationsEngine::instance()->getCurrentConversationId(); |
229 |
228 |
230 if (KBluetoothMsgsConversationId == convId) { |
229 if (KBluetoothMsgsConversationId == convId) { |
231 setAddress(LOC_RECEIVED_FILES); |
230 setAddress(LOC_RECEIVED_FILES); |
232 setAvatar(HbIcon(BT_ICON)); |
231 setAvatar(HbIcon(BT_ICON)); |
|
232 this->ungrabGesture(Qt::TapGesture); |
233 } |
233 } |
234 else { |
234 else { |
235 //Set the Contact Name/Number |
235 //Set the Contact Name/Number |
236 qint64 convId; |
|
237 QString displayName; |
236 QString displayName; |
238 QString contactAddress; |
237 QString contactAddress; |
239 convId = ConversationsEngine::instance()->getCurrentConversationId(); |
|
240 ConversationsEngine::instance()->getContactDetails(convId, displayName, contactAddress); |
238 ConversationsEngine::instance()->getContactDetails(convId, displayName, contactAddress); |
241 |
239 |
242 mContactNumber = contactAddress; |
240 mContactNumber = contactAddress; |
243 QString contactName; |
241 QString contactName; |
244 if (displayName.isEmpty()) { |
242 if (displayName.isEmpty()) { |
355 // MsgContactCardWidget::handleLongTap |
355 // MsgContactCardWidget::handleLongTap |
356 // @see header file |
356 // @see header file |
357 //--------------------------------------------------------------- |
357 //--------------------------------------------------------------- |
358 void MsgContactCardWidget::handleLongTap(const QPointF &position) |
358 void MsgContactCardWidget::handleLongTap(const QPointF &position) |
359 { |
359 { |
360 if (KBluetoothMsgsConversationId != ConversationsEngine::instance()->getCurrentConversationId()) { |
360 HbMenu* contextMenu = new HbMenu(); |
361 HbMenu* contextMenu = new HbMenu(); |
361 contextMenu->setDismissPolicy(HbPopup::TapAnywhere); |
362 contextMenu->setDismissPolicy(HbPopup::TapAnywhere); |
362 contextMenu->setAttribute(Qt::WA_DeleteOnClose, true); |
363 contextMenu->setAttribute(Qt::WA_DeleteOnClose, true); |
363 contextMenu->setPreferredPos(position); |
364 contextMenu->setPreferredPos(position); |
364 |
365 |
365 contextMenu->addAction(LOC_MENU_CONTACT_INFO, this, SLOT(openContactInfo())); |
366 //If contact doesn't exist in phonebook then add another menu item "Save to Contacts" |
366 contextMenu->addAction(LOC_COMMON_MENU_CALL, this, SLOT(call())); |
367 int contactId = resolveContactId(mContactNumber); |
367 |
368 if (contactId < 0) { |
368 contextMenu->show(); |
369 contextMenu->addAction(LOC_SAVETO_CONTACTS, this, SLOT(addToContacts())); |
|
370 } |
|
371 else{ |
|
372 contextMenu->addAction(LOC_MENU_CONTACT_INFO, this, SLOT(openContactInfo())); |
|
373 } |
|
374 contextMenu->addAction(LOC_COMMON_MENU_CALL, this, SLOT(call())); |
|
375 |
|
376 contextMenu->show(); |
|
377 } |
|
378 } |
369 } |
379 |
370 |
380 //--------------------------------------------------------------- |
371 //--------------------------------------------------------------- |
381 // MsgContactCardWidget::handleShortTap |
372 // MsgContactCardWidget::handleShortTap |
382 // @see header |
373 // @see header |
383 //--------------------------------------------------------------- |
374 //--------------------------------------------------------------- |
384 void MsgContactCardWidget::handleShortTap(const QPointF &position) |
375 void MsgContactCardWidget::handleShortTap(const QPointF &position) |
385 { |
376 { |
|
377 Q_UNUSED(position) |
|
378 |
386 this->ungrabGesture(Qt::TapGesture); |
379 this->ungrabGesture(Qt::TapGesture); |
387 |
380 |
388 int contactId = resolveContactId(mContactNumber); |
381 openContactInfo(); |
389 if(contactId > 0) |
|
390 { |
|
391 //resolved contact open contact card. |
|
392 openContactInfo(); |
|
393 } |
|
394 else |
|
395 { |
|
396 //unresolved contact show longpress options menu. |
|
397 handleLongTap(position); |
|
398 } |
|
399 |
382 |
400 //fire timer to regrab gesture after some delay. |
383 //fire timer to regrab gesture after some delay. |
401 QTimer::singleShot(300,this,SLOT(regrabGesture())); |
384 QTimer::singleShot(300,this,SLOT(regrabGesture())); |
402 } |
385 } |
403 |
386 |
405 // MsgContactCardWidget::openContactInfo |
388 // MsgContactCardWidget::openContactInfo |
406 // @see header |
389 // @see header |
407 //--------------------------------------------------------------- |
390 //--------------------------------------------------------------- |
408 void MsgContactCardWidget::openContactInfo() |
391 void MsgContactCardWidget::openContactInfo() |
409 { |
392 { |
410 //service stuff. |
|
411 QString service("phonebookservices"); |
|
412 QString interface; |
|
413 QString operation; |
|
414 QList<QVariant> args; |
393 QList<QVariant> args; |
415 if (KBluetoothMsgsConversationId != ConversationsEngine::instance()->getCurrentConversationId()) { |
394 XQAiwRequest* request = NULL; |
416 int contactId = resolveContactId(mContactNumber); |
395 XQApplicationManager appManager; |
417 if (contactId > 0) { |
396 |
418 //open existing contact card |
397 int contactId = resolveContactId(mContactNumber); |
419 interface = QString("com.nokia.symbian.IContactsView"); |
398 if (contactId > 0) { |
420 operation = QString("openContactCard(int)"); |
399 // open existing contact card |
421 args << contactId; |
400 request = appManager.create(XQI_CONTACTS_VIEW, XQOP_CONTACTS_VIEW_CONTACT_CARD, true); // Embedded |
422 } |
401 args << contactId; |
423 else { |
402 } |
424 //populate data and open unknown contact template |
403 else { |
425 interface = QString("com.nokia.symbian.IContactsEdit"); |
404 // open temp contact card |
426 operation = QString("editCreateNew(QString,QString)"); |
405 request = appManager.create(XQI_CONTACTS_VIEW, |
427 QString type = QContactPhoneNumber::DefinitionName; |
406 XQOP_CONTACTS_VIEW_TEMP_CONTACT_CARD_WITH_DETAIL, true); // Embedded |
428 args << type; |
407 args << QContactPhoneNumber::DefinitionName; // Type |
429 args << mAddress; |
408 args << mAddress; // Actual data |
430 } |
409 } |
431 XQAiwRequest* request; |
410 |
432 XQApplicationManager appManager; |
411 if (request == NULL) { |
433 request = appManager.create(service, interface, operation, true); // embedded |
412 return; |
434 if (request == NULL) { |
413 } |
435 return; |
414 |
436 } |
415 // Result handlers |
437 |
416 connect(request, SIGNAL(requestOk(const QVariant&)), this, SLOT(handleOk(const QVariant&))); |
438 // Result handlers |
417 connect(request, SIGNAL(requestError(const QVariant&)), this, |
439 connect(request, SIGNAL(requestOk(const QVariant&)), this, SLOT(handleOk(const QVariant&))); |
418 SLOT(handleError(const QVariant&))); |
440 connect(request, SIGNAL(requestError(const QVariant&)), this, |
419 |
441 SLOT(handleError(const QVariant&))); |
420 //disbale subscritption for the CV events |
442 |
421 ConversationsEngine::instance()->disableRegisterationForCVEvents(); |
443 //disbale subscritption for the CV events |
422 |
444 ConversationsEngine::instance()->disableRegisterationForCVEvents(); |
423 request->setArguments(args); |
445 |
424 request->send(); |
446 request->setArguments(args); |
425 delete request; |
447 request->send(); |
|
448 delete request; |
|
449 } |
|
450 } |
426 } |
451 |
427 |
452 //--------------------------------------------------------------- |
428 //--------------------------------------------------------------- |
453 // MsgContactCardWidget::resolveContactId |
429 // MsgContactCardWidget::resolveContactId |
454 // @see header |
430 // @see header |
478 |
454 |
479 connect(serviceRequest, SIGNAL(requestError(int)), this, SLOT(onServiceRequestCompleted())); |
455 connect(serviceRequest, SIGNAL(requestError(int)), this, SLOT(onServiceRequestCompleted())); |
480 |
456 |
481 *serviceRequest << mContactNumber; |
457 *serviceRequest << mContactNumber; |
482 serviceRequest->send(); |
458 serviceRequest->send(); |
483 } |
|
484 |
|
485 //--------------------------------------------------------------- |
|
486 // MsgContactCardWidget::addToContacts |
|
487 // @see header |
|
488 //--------------------------------------------------------------- |
|
489 void MsgContactCardWidget::addToContacts() |
|
490 { |
|
491 openContactInfo(); |
|
492 } |
459 } |
493 |
460 |
494 //--------------------------------------------------------------- |
461 //--------------------------------------------------------------- |
495 // MsgContactCardWidget::handleOk |
462 // MsgContactCardWidget::handleOk |
496 // @see header |
463 // @see header |