--- a/messagingapp/msgui/conversationview/src/msgcontactcardwidget.cpp Tue Oct 05 13:58:47 2010 +0530
+++ b/messagingapp/msgui/conversationview/src/msgcontactcardwidget.cpp Tue Oct 19 11:30:16 2010 +0530
@@ -27,6 +27,7 @@
#include <qcontactphonenumber.h>
#include <qcontactavatar.h>
#include <xqaiwrequest.h>
+#include <xqaiwdecl.h>
#include <xqappmgr.h>
#include <xqservicerequest.h>
#include <cntservicescontact.h>
@@ -57,7 +58,6 @@
#define LOC_RECEIVED_FILES hbTrId("txt_messaging_title_received_files")
#define LOC_MENU_CONTACT_INFO hbTrId("txt_messaging_menu_contact_info")
#define LOC_COMMON_MENU_CALL hbTrId("txt_common_menu_call_verb")
-#define LOC_SAVETO_CONTACTS hbTrId("txt_messaging_menu_save_to_contacts")
// LOCAL FUNCTIONS
@@ -87,7 +87,6 @@
void MsgContactCardWidget::init()
{
this->setProperty("state", "normal");
- this->grabGesture(Qt::TapGesture);
HbFrameItem *frameItem = new HbFrameItem(BG_FRAME_NORMAL, HbFrameDrawer::NinePieces, this);
this->setBackgroundItem(frameItem);
@@ -230,13 +229,12 @@
if (KBluetoothMsgsConversationId == convId) {
setAddress(LOC_RECEIVED_FILES);
setAvatar(HbIcon(BT_ICON));
+ this->ungrabGesture(Qt::TapGesture);
}
else {
//Set the Contact Name/Number
- qint64 convId;
QString displayName;
QString contactAddress;
- convId = ConversationsEngine::instance()->getCurrentConversationId();
ConversationsEngine::instance()->getContactDetails(convId, displayName, contactAddress);
mContactNumber = contactAddress;
@@ -263,6 +261,8 @@
// Set default avatar till actual is set.
setAvatar(HbIcon(DEFAULT_AVATAR_ICON));
+
+ this->grabGesture(Qt::TapGesture);
}
}
@@ -357,24 +357,15 @@
//---------------------------------------------------------------
void MsgContactCardWidget::handleLongTap(const QPointF &position)
{
- if (KBluetoothMsgsConversationId != ConversationsEngine::instance()->getCurrentConversationId()) {
- HbMenu* contextMenu = new HbMenu();
- contextMenu->setDismissPolicy(HbPopup::TapAnywhere);
- contextMenu->setAttribute(Qt::WA_DeleteOnClose, true);
- contextMenu->setPreferredPos(position);
+ HbMenu* contextMenu = new HbMenu();
+ contextMenu->setDismissPolicy(HbPopup::TapAnywhere);
+ contextMenu->setAttribute(Qt::WA_DeleteOnClose, true);
+ contextMenu->setPreferredPos(position);
- //If contact doesn't exist in phonebook then add another menu item "Save to Contacts"
- int contactId = resolveContactId(mContactNumber);
- if (contactId < 0) {
- contextMenu->addAction(LOC_SAVETO_CONTACTS, this, SLOT(addToContacts()));
- }
- else{
- contextMenu->addAction(LOC_MENU_CONTACT_INFO, this, SLOT(openContactInfo()));
- }
- contextMenu->addAction(LOC_COMMON_MENU_CALL, this, SLOT(call()));
+ contextMenu->addAction(LOC_MENU_CONTACT_INFO, this, SLOT(openContactInfo()));
+ contextMenu->addAction(LOC_COMMON_MENU_CALL, this, SLOT(call()));
- contextMenu->show();
- }
+ contextMenu->show();
}
//---------------------------------------------------------------
@@ -383,19 +374,11 @@
//---------------------------------------------------------------
void MsgContactCardWidget::handleShortTap(const QPointF &position)
{
+ Q_UNUSED(position)
+
this->ungrabGesture(Qt::TapGesture);
- int contactId = resolveContactId(mContactNumber);
- if(contactId > 0)
- {
- //resolved contact open contact card.
- openContactInfo();
- }
- else
- {
- //unresolved contact show longpress options menu.
- handleLongTap(position);
- }
+ openContactInfo();
//fire timer to regrab gesture after some delay.
QTimer::singleShot(300,this,SLOT(regrabGesture()));
@@ -407,46 +390,39 @@
//---------------------------------------------------------------
void MsgContactCardWidget::openContactInfo()
{
- //service stuff.
- QString service("phonebookservices");
- QString interface;
- QString operation;
QList<QVariant> args;
- if (KBluetoothMsgsConversationId != ConversationsEngine::instance()->getCurrentConversationId()) {
- int contactId = resolveContactId(mContactNumber);
- if (contactId > 0) {
- //open existing contact card
- interface = QString("com.nokia.symbian.IContactsView");
- operation = QString("openContactCard(int)");
- args << contactId;
- }
- else {
- //populate data and open unknown contact template
- interface = QString("com.nokia.symbian.IContactsEdit");
- operation = QString("editCreateNew(QString,QString)");
- QString type = QContactPhoneNumber::DefinitionName;
- args << type;
- args << mAddress;
- }
- XQAiwRequest* request;
- XQApplicationManager appManager;
- request = appManager.create(service, interface, operation, true); // embedded
- if (request == NULL) {
- return;
- }
+ XQAiwRequest* request = NULL;
+ XQApplicationManager appManager;
- // Result handlers
- connect(request, SIGNAL(requestOk(const QVariant&)), this, SLOT(handleOk(const QVariant&)));
- connect(request, SIGNAL(requestError(const QVariant&)), this,
- SLOT(handleError(const QVariant&)));
+ int contactId = resolveContactId(mContactNumber);
+ if (contactId > 0) {
+ // open existing contact card
+ request = appManager.create(XQI_CONTACTS_VIEW, XQOP_CONTACTS_VIEW_CONTACT_CARD, true); // Embedded
+ args << contactId;
+ }
+ else {
+ // open temp contact card
+ request = appManager.create(XQI_CONTACTS_VIEW,
+ XQOP_CONTACTS_VIEW_TEMP_CONTACT_CARD_WITH_DETAIL, true); // Embedded
+ args << QContactPhoneNumber::DefinitionName; // Type
+ args << mAddress; // Actual data
+ }
- //disbale subscritption for the CV events
- ConversationsEngine::instance()->disableRegisterationForCVEvents();
+ if (request == NULL) {
+ return;
+ }
- request->setArguments(args);
- request->send();
- delete request;
- }
+ // Result handlers
+ connect(request, SIGNAL(requestOk(const QVariant&)), this, SLOT(handleOk(const QVariant&)));
+ connect(request, SIGNAL(requestError(const QVariant&)), this,
+ SLOT(handleError(const QVariant&)));
+
+ //disbale subscritption for the CV events
+ ConversationsEngine::instance()->disableRegisterationForCVEvents();
+
+ request->setArguments(args);
+ request->send();
+ delete request;
}
//---------------------------------------------------------------
@@ -483,15 +459,6 @@
}
//---------------------------------------------------------------
-// MsgContactCardWidget::addToContacts
-// @see header
-//---------------------------------------------------------------
-void MsgContactCardWidget::addToContacts()
-{
- openContactInfo();
-}
-
-//---------------------------------------------------------------
// MsgContactCardWidget::handleOk
// @see header
//---------------------------------------------------------------