messagingapp/msgui/conversationview/src/msgcontactcardwidget.cpp
changeset 27 e4592d119491
parent 25 84d9eb65b26f
child 47 5b14749788d7
equal deleted inserted replaced
25:84d9eb65b26f 27:e4592d119491
    20 // SYSTEM INCLUDES
    20 // SYSTEM INCLUDES
    21 #include <HbStyle>
    21 #include <HbStyle>
    22 #include <HbIconItem>
    22 #include <HbIconItem>
    23 #include <HbTextItem>
    23 #include <HbTextItem>
    24 #include <HbFrameDrawer>
    24 #include <HbFrameDrawer>
    25 #include <HbGesture>
    25 //#include <HbGesture>
    26 #include <HbGestureSceneFilter>
    26 //#include <HbGestureSceneFilter>
    27 #include <HbWidgetFeedback>
    27 #include <HbWidgetFeedback>
    28 #include <HbFrameItem>
    28 #include <HbFrameItem>
    29 #include <qmobilityglobal.h>
       
    30 #include <qcontactphonenumber.h>
    29 #include <qcontactphonenumber.h>
    31 #include <qcontactfilter.h>
    30 #include <qcontactavatar.h>
    32 #include <qcontactmanager.h>
       
    33 #include <qcontactdetailfilter.h>
       
    34 #include <xqaiwrequest.h>
    31 #include <xqaiwrequest.h>
    35 #include <xqappmgr.h>
    32 #include <xqappmgr.h>
    36 #include <XQServiceRequest.h>
    33 #include <XQServiceRequest.h>
    37 #include <cntservicescontact.h>
    34 #include <cntservicescontact.h>
    38 #include <QGraphicsSceneMouseEvent>
    35 #include <QGraphicsSceneMouseEvent>
    39 #include <HbMenu>
    36 #include <HbMenu>
    40 #include <HbMainWindow>
    37 #include <HbMainWindow>
       
    38 #include <thumbnailmanager_qt.h>
    41 
    39 
    42 #include <ccsdefs.h>
    40 #include <ccsdefs.h>
    43 
    41 
    44 // USER INCLUDES
    42 // USER INCLUDES
    45 #include "conversationsenginedefines.h"
    43 #include "conversationsenginedefines.h"
    46 #include "debugtraces.h"
    44 #include "debugtraces.h"
    47 #include "conversationsengine.h"
    45 #include "conversationsengine.h"
    48 #include "convergedmessage.h"
    46 #include "convergedmessage.h"
    49 
    47 #include "msgcontacthandler.h"
    50 QTM_USE_NAMESPACE
       
    51 
    48 
    52 // LOCAL CONSTANTS
    49 // LOCAL CONSTANTS
    53 const QString DEFAULT_AVATAR_ICON("qtg_large_avatar");
    50 const QString DEFAULT_AVATAR_ICON("qtg_large_avatar");
    54 const QString BT_ICON("qtg_large_bluetooth");
    51 const QString BT_ICON("qtg_large_bluetooth");
    55 const QString BACKGROUND_FRAME_NORMAL("qtg_fr_groupbox");
    52 const QString BACKGROUND_FRAME_NORMAL("qtg_fr_groupbox");
    56 const QString GROUPBOX_BG_FRAME_PRESSED("qtg_fr_groupbox_pressed");
    53 const QString GROUPBOX_BG_FRAME_PRESSED("qtg_fr_groupbox_pressed");
    57 
    54 
    58 const QString PLUGINPATH("conversationviewplugin.dll");
       
    59 
    55 
    60 // LOCALIZATION CONSTANTS
    56 // LOCALIZATION CONSTANTS
    61 #define LOC_RECEIVED_FILES hbTrId("txt_messaging_title_received_files")
    57 #define LOC_RECEIVED_FILES hbTrId("txt_messaging_title_received_files")
    62 #define LOC_MENU_CONTACT_INFO hbTrId("txt_messaging_menu_open_contact_info")
    58 #define LOC_MENU_CONTACT_INFO hbTrId("txt_messaging_menu_open_contact_info")
    63 #define LOC_COMMON_MENU_CALL hbTrId("txt_common_menu_call_verb")
    59 #define LOC_COMMON_MENU_CALL hbTrId("txt_common_menu_call_verb")
    64 #define LOC_SAVETO_CONTACTS hbTrId("txt_messaging_menu_save_to_contacts")
    60 #define LOC_SAVETO_CONTACTS hbTrId("txt_messaging_menu_save_to_contacts")
    65 
    61 
       
    62 // LOCAL FUNCTIONS
       
    63 
    66 //---------------------------------------------------------------
    64 //---------------------------------------------------------------
    67 // MsgContactCardWidget::MsgContactCardWidget
    65 // MsgContactCardWidget::MsgContactCardWidget
    68 // @see header
    66 // @see header
    69 //---------------------------------------------------------------
    67 //---------------------------------------------------------------
    70 MsgContactCardWidget::MsgContactCardWidget(QGraphicsItem *parent) :
    68 MsgContactCardWidget::MsgContactCardWidget(QGraphicsItem *parent) :
    71 HbWidget(parent), 
    69     HbWidget(parent), mMenuShown(false), mAvatarIconItem(NULL), mPresenceIconItem(NULL),
    72 mMenuShown(false),
    70         mAddressTextItem(NULL),mThumbnailManager(NULL)
    73 mAvatarIconItem(NULL),
    71 {
    74 mPresenceIconItem(NULL),
    72     init();
    75 mAddressTextItem(NULL),
       
    76 mGestureFilter(NULL)
       
    77 
       
    78 {
       
    79     int baseId = style()->registerPlugin(PLUGINPATH);
       
    80     QDEBUG_WRITE_FORMAT("MsgContactCardWidget BASE ID --->", baseId);
       
    81     setPluginBaseId(baseId);
       
    82 
       
    83     init();  
       
    84     setBackGround(BACKGROUND_FRAME_NORMAL);
    73     setBackGround(BACKGROUND_FRAME_NORMAL);
    85     connectSignals(true);
    74     connectSignals(true);
    86     
    75 
    87     connect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(initGesture()));   
    76     connect(this->mainWindow(), SIGNAL(viewReady()), this, SLOT(initGesture()));
    88 }
    77 }
    89 
    78 
    90 //---------------------------------------------------------------
    79 //---------------------------------------------------------------
    91 // MsgContactCardWidget::~MsgContactCardWidget
    80 // MsgContactCardWidget::~MsgContactCardWidget
    92 // @see header
    81 // @see header
    93 //---------------------------------------------------------------
    82 //---------------------------------------------------------------
    94 MsgContactCardWidget::~MsgContactCardWidget()
    83 MsgContactCardWidget::~MsgContactCardWidget()
    95 {
    84 {
    96     style()->unregisterPlugin(PLUGINPATH);
    85   /*  if (mGestureFilter) {
    97     
       
    98     if(mGestureFilter)
       
    99         {
       
   100         removeSceneEventFilter(mGestureFilter);
    86         removeSceneEventFilter(mGestureFilter);
   101         }
    87     }*/
   102 }
    88 }
   103 
    89 
   104 //---------------------------------------------------------------
    90 //---------------------------------------------------------------
   105 // MsgContactCardWidget::init
    91 // MsgContactCardWidget::init
   106 // @see header
    92 // @see header
   114     HbStyle::setItemName(mPresenceIconItem, "presence");
   100     HbStyle::setItemName(mPresenceIconItem, "presence");
   115 
   101 
   116     mAddressTextItem = new HbTextItem(this);
   102     mAddressTextItem = new HbTextItem(this);
   117     HbStyle::setItemName(mAddressTextItem, "addressText");
   103     HbStyle::setItemName(mAddressTextItem, "addressText");
   118 
   104 
       
   105     mThumbnailManager = new ThumbnailManager(this);
       
   106     mThumbnailManager->setMode(ThumbnailManager::Default);
       
   107     mThumbnailManager->setQualityPreference(ThumbnailManager::OptimizeForQuality);
       
   108     mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailLarge);
       
   109 
       
   110     connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void*, int, int)), this,
       
   111         SLOT(thumbnailReady(QPixmap, void*, int, int)));
   119 }
   112 }
   120 
   113 
   121 //---------------------------------------------------------------
   114 //---------------------------------------------------------------
   122 // MsgContactCardWidget::setAvatar
   115 // MsgContactCardWidget::setAvatar
   123 // @see header
   116 // @see header
   185         //Set the Contact Name/Number
   178         //Set the Contact Name/Number
   186         qint64 convId;
   179         qint64 convId;
   187         QString displayName;
   180         QString displayName;
   188         QString contactAddress;
   181         QString contactAddress;
   189         convId = ConversationsEngine::instance()->getCurrentConversationId();
   182         convId = ConversationsEngine::instance()->getCurrentConversationId();
   190         ConversationsEngine::instance()->getContactDetails(convId, displayName,
   183         ConversationsEngine::instance()->getContactDetails(convId, displayName, contactAddress);
   191             contactAddress);
   184 
   192         
       
   193         mContactNumber = contactAddress;
   185         mContactNumber = contactAddress;
   194         QString contactName;
   186         QString contactName;
   195         if (displayName.isEmpty()) {
   187         if (displayName.isEmpty()) {
   196             contactName.append(contactAddress);
   188             contactName.append(contactAddress);
   197         }
   189         }
   198         else {
   190         else {
   199             contactName.append(displayName);
   191             contactName.append(displayName);
   200         }
   192         }
       
   193 
       
   194         setAddress(contactName);
       
   195 
       
   196         // Set Avatar
       
   197         QList<QContact> contactList = 
       
   198                 MsgContactHandler::findContactList(mContactNumber);
   201         
   199         
   202         setAddress(contactName);
   200         if (!contactList.isEmpty()) {
   203 
   201             QList<QContactAvatar> avatarDetails = 
   204         // Set Avatar
   202                     contactList.at(0).details<QContactAvatar> ();
   205         HbIcon avatar;
   203             
   206         QByteArray avatarByteArray = index.data(Avatar).toByteArray();
   204             if (!avatarDetails.isEmpty()) {
   207         if (avatarByteArray.isEmpty()) {
   205                 mThumbnailManager->getThumbnail(
   208             avatar = HbIcon(DEFAULT_AVATAR_ICON);
   206                         avatarDetails.at(0).imageUrl().toString());
   209         }
   207             }
   210         else {
   208         }
   211             QPixmap pixmap;
   209 
   212             pixmap.loadFromData(avatarByteArray);
   210         // Set default avatar till actual is set.
   213             avatar = HbIcon(QIcon(pixmap));
   211         setAvatar(HbIcon(DEFAULT_AVATAR_ICON));
   214         }
       
   215         setAvatar(avatar);
       
   216     }
   212     }
   217 }
   213 }
   218 
   214 
   219 //---------------------------------------------------------------
   215 //---------------------------------------------------------------
   220 // MsgContactCardWidget::clearContent
   216 // MsgContactCardWidget::clearContent
   231 // @see header file
   227 // @see header file
   232 //---------------------------------------------------------------
   228 //---------------------------------------------------------------
   233 void MsgContactCardWidget::initGesture()
   229 void MsgContactCardWidget::initGesture()
   234 {
   230 {
   235     // Create gesture filter
   231     // Create gesture filter
   236     QGraphicsScene* sc = this->scene();
   232   /*  QGraphicsScene* sc = this->scene();
   237     mGestureFilter = new HbGestureSceneFilter( Qt::LeftButton, this );
   233     mGestureFilter = new HbGestureSceneFilter(Qt::LeftButton, this);
   238     
   234 
   239     // Add gestures for longpress
   235     // Add gestures for longpress
   240     HbGesture* gestureLongpressed = new HbGesture( HbGesture::longpress,5 );
   236     HbGesture* gestureLongpressed = new HbGesture(HbGesture::longpress, 5);
   241     
   237 
   242     mGestureFilter->addGesture( gestureLongpressed );
   238     mGestureFilter->addGesture(gestureLongpressed);
   243     
   239 
   244     connect( gestureLongpressed, SIGNAL(longPress(QPointF)),
   240     connect(gestureLongpressed, SIGNAL(longPress(QPointF)), this, SLOT(handleLongPress(QPointF)));
   245              this, SLOT(handleLongPress(QPointF)));
       
   246 
   241 
   247     //install gesture filter.
   242     //install gesture filter.
   248     this->installSceneEventFilter(mGestureFilter);
   243     this->installSceneEventFilter(mGestureFilter);
   249     
   244 
   250     disconnect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(initGesture()));   
   245     disconnect(this->mainWindow(), SIGNAL(viewReady()), this, SLOT(initGesture()));*/
   251 }
   246 }
   252 
   247 
   253 //---------------------------------------------------------------
   248 //---------------------------------------------------------------
   254 // MsgContactCardWidget::mousePressEvent
   249 // MsgContactCardWidget::mousePressEvent
   255 // @see header file
   250 // @see header file
   256 //---------------------------------------------------------------
   251 //---------------------------------------------------------------
   257 void MsgContactCardWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
   252 void MsgContactCardWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
   258 {    
   253 {
   259     mMenuShown = false;
   254     mMenuShown = false;
   260     
   255 
   261     HbWidgetFeedback::triggered(this, Hb::InstantPressed);
   256     HbWidgetFeedback::triggered(this, Hb::InstantPressed);
   262     
   257 
   263     setBackGround(GROUPBOX_BG_FRAME_PRESSED);
   258     setBackGround(GROUPBOX_BG_FRAME_PRESSED);
   264     
   259 
   265     event->accept();
   260     event->accept();
   266 }
   261 }
   267 
   262 
   268 
       
   269 //---------------------------------------------------------------
   263 //---------------------------------------------------------------
   270 // MsgContactCardWidget::mouseReleaseEvent
   264 // MsgContactCardWidget::mouseReleaseEvent
   271 // @see header file
   265 // @see header file
   272 //---------------------------------------------------------------
   266 //---------------------------------------------------------------
   273 void MsgContactCardWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
   267 void MsgContactCardWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
   274 {
   268 {
   275     setBackGround(BACKGROUND_FRAME_NORMAL);
   269     setBackGround(BACKGROUND_FRAME_NORMAL);
   276     
   270 
   277     if(this->rect().contains(event->pos())&& !mMenuShown)
   271     if (this->rect().contains(event->pos()) && !mMenuShown) {
   278         {
       
   279         HbWidgetFeedback::triggered(this, Hb::InstantClicked);
   272         HbWidgetFeedback::triggered(this, Hb::InstantClicked);
   280 		emit clicked();
   273         emit clicked();
   281         }
   274     }
   282     
   275 
   283     event->accept();    
   276     event->accept();
   284 }
   277 }
   285 
   278 
   286 //---------------------------------------------------------------
   279 //---------------------------------------------------------------
   287 // MsgContactCardWidget::setBackGround
   280 // MsgContactCardWidget::setBackGround
   288 // @see header file
   281 // @see header file
   289 //---------------------------------------------------------------
   282 //---------------------------------------------------------------
   290 void MsgContactCardWidget::setBackGround(const QString& bg)
   283 void MsgContactCardWidget::setBackGround(const QString& bg)
   291     {
   284 {
   292     HbFrameItem* backGround = new HbFrameItem(this);
   285     HbFrameItem* backGround = new HbFrameItem(this);
   293     backGround->frameDrawer().setFrameGraphicsName(bg);
   286     backGround->frameDrawer().setFrameGraphicsName(bg);
   294     backGround->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
   287     backGround->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
   295     this->setBackgroundItem(backGround); 
   288     this->setBackgroundItem(backGround);
   296     this->repolish();
   289     this->repolish();
   297     }
   290 }
   298 
   291 
   299 //---------------------------------------------------------------
   292 //---------------------------------------------------------------
   300 // MsgContactCardWidget::handleLongPress
   293 // MsgContactCardWidget::handleLongPress
   301 // @see header file
   294 // @see header file
   302 //---------------------------------------------------------------
   295 //---------------------------------------------------------------
   303 void MsgContactCardWidget::handleLongPress(QPointF position)
   296 void MsgContactCardWidget::handleLongPress(QPointF position)
   304 {
   297 {
   305     if(KBluetoothMsgsConversationId 
   298     if (KBluetoothMsgsConversationId != ConversationsEngine::instance()->getCurrentConversationId()) {
   306         != ConversationsEngine::instance()->getCurrentConversationId())    
       
   307         {
       
   308         HbMenu* contextMenu = new HbMenu();
   299         HbMenu* contextMenu = new HbMenu();
   309         contextMenu->setDismissPolicy(HbPopup::TapAnywhere);
   300         contextMenu->setDismissPolicy(HbPopup::TapAnywhere);
   310         contextMenu->setAttribute(Qt::WA_DeleteOnClose, true);
   301         contextMenu->setAttribute(Qt::WA_DeleteOnClose, true);
   311         contextMenu->setPreferredPos(position);
   302         contextMenu->setPreferredPos(position);
   312         
   303 
   313         contextMenu->addAction(LOC_MENU_CONTACT_INFO,this, SLOT(openContactInfo()));    
   304         contextMenu->addAction(LOC_MENU_CONTACT_INFO, this, SLOT(openContactInfo()));
   314         contextMenu->addAction(LOC_COMMON_MENU_CALL, this, SLOT(call()));
   305         contextMenu->addAction(LOC_COMMON_MENU_CALL, this, SLOT(call()));
   315         
   306 
   316         //If contact doesn't exist in phonebook then add another menu item "Save to Contacts"
   307         //If contact doesn't exist in phonebook then add another menu item "Save to Contacts"
   317         int contactId = resolveContactId(mContactNumber);
   308         int contactId = resolveContactId(mContactNumber);
   318         if(contactId < 0)
   309         if (contactId < 0) {
   319         {
       
   320             contextMenu->addAction(LOC_SAVETO_CONTACTS, this, SLOT(addToContacts()));
   310             contextMenu->addAction(LOC_SAVETO_CONTACTS, this, SLOT(addToContacts()));
   321         }
   311         }
   322         
   312 
   323         contextMenu->show();
   313         contextMenu->show();
   324         
   314 
   325         mMenuShown = true;
   315         mMenuShown = true;
   326         }
   316     }
   327 }
   317 }
   328 
   318 
   329 //---------------------------------------------------------------
   319 //---------------------------------------------------------------
   330 // MsgContactCardWidget::overrideFeedback
   320 // MsgContactCardWidget::overrideFeedback
   331 // @see header file
   321 // @see header file
   332 //---------------------------------------------------------------
   322 //---------------------------------------------------------------
   333 HbFeedback::InstantEffect MsgContactCardWidget::overrideFeedback(Hb::InstantInteraction interaction) const
   323 /*HbFeedback::InstantEffect MsgContactCardWidget::overrideFeedback(Hb::InstantInteraction interaction) const
   334         {
   324 {
   335         switch(interaction)
   325     switch (interaction) {
   336             {
   326     case Hb::InstantPressed:
   337             case Hb::InstantPressed:
   327     case Hb::InstantClicked:
   338             case Hb::InstantClicked:
   328         return HbFeedback::Basic;   
   339                 return HbFeedback::Basic;
   329     default:
   340             default:
   330         return HbFeedback::None;
   341                 return HbFeedback::NoOverride;
   331     }
   342             }
   332 }*/
   343         }
   333 
   344 		
       
   345 //---------------------------------------------------------------
   334 //---------------------------------------------------------------
   346 // MsgContactCardWidget::openContactInfo
   335 // MsgContactCardWidget::openContactInfo
   347 // @see header
   336 // @see header
   348 //---------------------------------------------------------------
   337 //---------------------------------------------------------------
   349 void MsgContactCardWidget::openContactInfo()
   338 void MsgContactCardWidget::openContactInfo()
   350 {
   339 {
   351     QString operation;
   340     QString operation;
   352     QList<QVariant> args;
   341     QList<QVariant> args;
   353     if(KBluetoothMsgsConversationId 
   342     if (KBluetoothMsgsConversationId != ConversationsEngine::instance()->getCurrentConversationId()) {
   354             != ConversationsEngine::instance()->getCurrentConversationId())
   343         int contactId = resolveContactId(mContactNumber);
   355     {
   344         if (contactId > 0) {
   356         int contactId = resolveContactId(mContactNumber);                
       
   357         if(contactId > 0)
       
   358         {
       
   359             //open existing contact card
   345             //open existing contact card
   360             operation = QString("open(int)");
   346             operation = QString("open(int)");
   361             args << contactId;
   347             args << contactId;
   362         }
   348         }
   363         else
   349         else {
   364         {
       
   365             //populate data and open unknown contact template
   350             //populate data and open unknown contact template
   366             operation = QString("editCreateNew(QString,QString)");
   351             operation = QString("editCreateNew(QString,QString)");
   367             QString type = QContactPhoneNumber::DefinitionName;
   352             QString type = QContactPhoneNumber::DefinitionName;
   368     
   353 
   369             args << type;
   354             args << type;
   370             args << mAddress;
   355             args << mAddress;
   371         }
   356         }
   372         //service stuff.
   357         //service stuff.
   373         QString serviceName("com.nokia.services.phonebookservices");
   358         QString serviceName("com.nokia.services.phonebookservices");
   374      
   359 
   375         XQAiwRequest* request;
   360         XQAiwRequest* request;
   376         XQApplicationManager appManager;
   361         XQApplicationManager appManager;
   377         request = appManager.create(serviceName, "Fetch", operation, true); // embedded
   362         request = appManager.create(serviceName, "Fetch", operation, true); // embedded
   378         if ( request == NULL )
   363         if (request == NULL) {
   379         {
   364             return;
   380         	return;       
   365         }
   381         }
   366 
   382         
       
   383         // Result handlers
   367         // Result handlers
   384         connect (request, SIGNAL(requestOk(const QVariant&)), this, SLOT(handleOk(const QVariant&)));
   368         connect(request, SIGNAL(requestOk(const QVariant&)), this, SLOT(handleOk(const QVariant&)));
   385         connect (request, SIGNAL(requestError(const QVariant&)), this, SLOT(handleError(const QVariant&)));
   369         connect(request, SIGNAL(requestError(const QVariant&)), this,
   386         
   370             SLOT(handleError(const QVariant&)));
       
   371 
   387         request->setArguments(args);
   372         request->setArguments(args);
   388         request->send();
   373         request->send();
   389         delete request;
   374         delete request;
   390     }
   375     }
   391 }
   376 }
   394 // MsgContactCardWidget::resolveContactId
   379 // MsgContactCardWidget::resolveContactId
   395 // @see header
   380 // @see header
   396 //---------------------------------------------------------------
   381 //---------------------------------------------------------------
   397 int MsgContactCardWidget::resolveContactId(const QString& value)
   382 int MsgContactCardWidget::resolveContactId(const QString& value)
   398 {
   383 {
   399     int contactId = -1;
   384     QString displayLabel;
   400     
   385     
   401     QContactManager phonebookManager("symbian");
   386     return MsgContactHandler::resolveContactDisplayName(
   402     
   387             value, 
   403     QContactDetailFilter phoneFilter;
   388             displayLabel,
   404     phoneFilter.setDetailDefinitionName(QContactPhoneNumber::DefinitionName,
   389             0);    
   405                                         QContactPhoneNumber::FieldNumber);
       
   406     phoneFilter.setValue(value);
       
   407     phoneFilter.setMatchFlags(QContactFilter::MatchEndsWith);
       
   408 
       
   409     QList<QContactSortOrder> sortOrder;
       
   410     QList<QContact> matchingContacts = phonebookManager.contacts(
       
   411             phoneFilter,
       
   412             sortOrder,
       
   413             QStringList());
       
   414 
       
   415     if ( matchingContacts.count() > 0 ) 
       
   416         {       
       
   417         contactId = matchingContacts.at(0).localId();   
       
   418         }
       
   419     
       
   420     return contactId;
       
   421 }
   390 }
   422 
   391 
   423 //---------------------------------------------------------------
   392 //---------------------------------------------------------------
   424 // MsgContactCardWidget::call
   393 // MsgContactCardWidget::call
   425 // @see header
   394 // @see header
   427 void MsgContactCardWidget::call()
   396 void MsgContactCardWidget::call()
   428 {
   397 {
   429     //Launch dialer service     
   398     //Launch dialer service     
   430     QString serviceName("com.nokia.services.telephony");
   399     QString serviceName("com.nokia.services.telephony");
   431     QString operation("dial(QString)");
   400     QString operation("dial(QString)");
   432     
   401 
   433     XQServiceRequest* serviceRequest = new XQServiceRequest(serviceName,operation,false);
   402     XQServiceRequest* serviceRequest = new XQServiceRequest(serviceName, operation, false);
   434     
   403 
   435     connect(serviceRequest, SIGNAL(requestCompleted(QVariant)),
   404     connect(serviceRequest, SIGNAL(requestCompleted(QVariant)), this,
   436             this, SLOT(onServiceRequestCompleted()));
   405         SLOT(onServiceRequestCompleted()));
   437     
   406 
   438     connect(serviceRequest, SIGNAL(requestError(int)),
   407     connect(serviceRequest, SIGNAL(requestError(int)), this, SLOT(onServiceRequestCompleted()));
   439             this, SLOT(onServiceRequestCompleted()));
   408 
   440     
       
   441     *serviceRequest << mContactNumber;
   409     *serviceRequest << mContactNumber;
   442     serviceRequest->send();
   410     serviceRequest->send();
   443 }
   411 }
   444 
   412 
   445 //---------------------------------------------------------------
   413 //---------------------------------------------------------------
   455 // @see header
   423 // @see header
   456 //---------------------------------------------------------------
   424 //---------------------------------------------------------------
   457 void MsgContactCardWidget::handleOk(const QVariant& result)
   425 void MsgContactCardWidget::handleOk(const QVariant& result)
   458 {
   426 {
   459     Q_UNUSED(result)
   427     Q_UNUSED(result)
   460     
   428 
   461     QContactManager phonebookManager("symbian");
   429     QList<QContact> matchingContacts = 
       
   430             MsgContactHandler::findContactList(mContactNumber);
       
   431 
       
   432     if (!matchingContacts.isEmpty()) {
       
   433         setAddress(matchingContacts.at(0).displayLabel());
   462         
   434         
   463     QContactDetailFilter phoneFilter;
   435         QList<QContactAvatar> avatarDetails = 
   464     phoneFilter.setDetailDefinitionName(QContactPhoneNumber::DefinitionName, 
   436                 matchingContacts.at(0).details<QContactAvatar> ();
   465                                             QContactPhoneNumber::FieldNumber);
   437         
   466     phoneFilter.setValue(mContactNumber);
   438         if (!avatarDetails.isEmpty()) {
   467     phoneFilter.setMatchFlags(QContactFilter::MatchEndsWith);
   439             mThumbnailManager->getThumbnail(
   468 
   440                     avatarDetails.at(0).imageUrl().toString());
   469     QList<QContactSortOrder> sortOrder;
   441         }
   470     QList<QContact> matchingContacts = phonebookManager.contacts(phoneFilter,
       
   471                                        sortOrder, QStringList());
       
   472     
       
   473     if(matchingContacts.count())
       
   474     {
       
   475         setAddress(matchingContacts.at(0).displayLabel());
       
   476     }
   442     }
   477 }
   443 }
   478 
   444 
   479 //---------------------------------------------------------------
   445 //---------------------------------------------------------------
   480 // MsgContactCardWidget::handleError
   446 // MsgContactCardWidget::handleError
   481 // @see header
   447 // @see header
   482 //---------------------------------------------------------------
   448 //---------------------------------------------------------------
   483 void MsgContactCardWidget::handleError(int errorCode, const QString& errorMessage)
   449 void MsgContactCardWidget::handleError(int errorCode, const QString& errorMessage)
   484     {
   450 {
   485     Q_UNUSED(errorMessage)
   451     Q_UNUSED(errorMessage)
   486     Q_UNUSED(errorCode)
   452     Q_UNUSED(errorCode)
   487     }
   453 }
   488 	
   454 
   489 //---------------------------------------------------------------
   455 //---------------------------------------------------------------
   490 // MsgContactCardWidget::onServiceRequestCompleted
   456 // MsgContactCardWidget::onServiceRequestCompleted
   491 // @see header
   457 // @see header
   492 //---------------------------------------------------------------
   458 //---------------------------------------------------------------
   493 void MsgContactCardWidget::onServiceRequestCompleted()
   459 void MsgContactCardWidget::onServiceRequestCompleted()
   494 {
   460 {
   495     //service request is now complete. delete it.
   461     //service request is now complete. delete it.
   496     XQServiceRequest* request = qobject_cast<XQServiceRequest*>(sender());
   462     XQServiceRequest* request = qobject_cast<XQServiceRequest*> (sender());
   497     if(request)
   463     if (request) {
   498     {
       
   499         delete request;
   464         delete request;
   500     }
   465     }
   501 }
   466 }
   502 
   467 
   503 //---------------------------------------------------------------
   468 //---------------------------------------------------------------
       
   469 // MsgContactCardWidget::thumbnailReady
       
   470 // @see header
       
   471 //---------------------------------------------------------------
       
   472 void MsgContactCardWidget::thumbnailReady(const QPixmap& pixmap, void *data, int id, int error)
       
   473 {
       
   474     Q_UNUSED(data)
       
   475     Q_UNUSED(id)
       
   476 
       
   477     if (!error) {
       
   478         QIcon icon(pixmap);
       
   479         setAvatar(HbIcon(icon));
       
   480     }
       
   481     else {
       
   482         setAvatar(HbIcon(DEFAULT_AVATAR_ICON));
       
   483     }
       
   484 }
       
   485 //---------------------------------------------------------------
   504 // MsgContactCardWidget::connectSignals
   486 // MsgContactCardWidget::connectSignals
   505 // @see header
   487 // @see header
   506 //---------------------------------------------------------------
   488 //---------------------------------------------------------------
   507 void MsgContactCardWidget::connectSignals(bool yes)
   489 void MsgContactCardWidget::connectSignals(bool yes)
   508 {
   490 {
   509     if(yes)
   491     if (yes) {
   510     {
   492         connect(this, SIGNAL(clicked()), this, SLOT(openContactInfo()));
   511         connect(this,SIGNAL(clicked()),this,SLOT(openContactInfo()));
   493     }
   512     }
   494     else {
   513     else
   495         disconnect(this, SIGNAL(clicked()), this, SLOT(openContactInfo()));
   514     {
       
   515         disconnect(this,SIGNAL(clicked()),this,SLOT(openContactInfo()));
       
   516     }
   496     }
   517 }
   497 }
   518 // EOF
   498 // EOF