contactwidgethsplugin/contactwidgeths/src/commlauncherwidget.cpp
changeset 81 640d30f4fb64
parent 66 554fe4dbbb59
equal deleted inserted replaced
77:c18f9fa7f42e 81:640d30f4fb64
    41 
    41 
    42 const QString appearEffectName = "appear";
    42 const QString appearEffectName = "appear";
    43 
    43 
    44 const int commLauncherMargin = 120;  // heights of titlebar & comm.launcher 
    44 const int commLauncherMargin = 120;  // heights of titlebar & comm.launcher 
    45 
    45 
    46 // TODO: THESE STRINGS ARE IN W32 SDK. THESE DEFINITIONS CAN BE REMOVED
       
    47 // WHEN EVERYBODY ARE USING IT OR LATER VERSION
       
    48 #ifndef XQOP_CONTACTS_VIEW_CONTACT_CARD
       
    49 #define XQOP_CONTACTS_VIEW_CONTACT_CARD QLatin1String("openContactCard(int)")
       
    50 #endif
       
    51 #ifndef XQI_CONTACTS_VIEW
       
    52 #define XQI_CONTACTS_VIEW QLatin1String("com.nokia.symbian.IContactsView")
       
    53 #endif
       
    54 
       
    55 
    46 
    56 /*!
    47 /*!
    57   \class CommLauncherWidget
    48   \class CommLauncherWidget
    58 */
    49 */
    59 
    50 
    63 CommLauncherWidget::CommLauncherWidget(QGraphicsItem *parent) :
    54 CommLauncherWidget::CommLauncherWidget(QGraphicsItem *parent) :
    64  HbPopup(parent),
    55  HbPopup(parent),
    65  mContact(0),
    56  mContact(0),
    66  mButtonCount(0),
    57  mButtonCount(0),
    67  mRequest(NULL),
    58  mRequest(NULL),
       
    59  mCommLauncherAction(0),
    68  mCallButton(0),
    60  mCallButton(0),
    69  mSendMsgButton(0),
    61  mSendMsgButton(0),
    70  mEmailButton(0),
    62  mEmailButton(0),
    71  mPhonebookButton(0),
    63  mPhonebookButton(0),
    72  mApplicationManager(0),
    64  mApplicationManager(0),
    73  mCommLauncherAction(0),
       
    74  mPendingRequest(false)
    65  mPendingRequest(false)
    75 {    
    66 {    
    76     
    67     
    77     HbStyleLoader::registerFilePath(":/commlauncherbuttons.css");
    68     HbStyleLoader::registerFilePath(":/commlauncherbuttons.css");
    78     // effect triggers
    69     // effect triggers
   401             messageNumber = static_cast<QContactPhoneNumber>(detail);
   392             messageNumber = static_cast<QContactPhoneNumber>(detail);
   402         } else {
   393         } else {
   403             //if preferred is not set select the first number
   394             //if preferred is not set select the first number
   404             messageNumber = mContact->detail<QContactPhoneNumber>();
   395             messageNumber = mContact->detail<QContactPhoneNumber>();
   405         }
   396         }
   406         // invoke action
   397 
   407         if(mCommLauncherAction)
   398         if (messageNumber.isEmpty()) {
   408         	delete mCommLauncherAction;
   399         	qDebug() << "contact have not phone number, why am I here?";
   409         mCommLauncherAction = QContactAction::action(messageActionDescriptors.at(0));
   400         } else {
   410         mCleanupHandler.add(mCommLauncherAction);
   401         	if (mRequest) {
   411         
   402         		delete mRequest;
   412         if (!messageNumber.isEmpty()) {
   403         	}
   413             mCommLauncherAction->invokeAction(*mContact, messageNumber);
   404         	mRequest = mApplicationManager->create(XQI_MESSAGE_SEND,
   414             
   405 												   XQOP_MESSAGE_SEND_WITH_ID,
   415             qDebug() << "send to number " << messageNumber.number();
   406 												   false);
       
   407         	if (mRequest) {
       
   408         		QList<QVariant> anArguments;
       
   409         		anArguments.append(QVariant::fromValue(messageNumber.number()));
       
   410         		anArguments.append(QVariant(0)); // unused contactId
       
   411         		anArguments.append(QVariant::fromValue(
       
   412         				mContact->displayLabel()));
       
   413         		mRequest->setArguments(anArguments);
       
   414         		mRequest->setSynchronous(false);
       
   415         		bool aResult = mRequest->send();
       
   416         		if (!aResult) {
       
   417         			qDebug() << "request for message was not successful";
       
   418         		}
       
   419         	} else {
       
   420         		qDebug() << "request for message was not created.";
       
   421         	}
   416         }
   422         }
   417     } else {
   423     } else {
   418         qDebug() << "contact has no Actions, can't send a message";
   424         qDebug() << "contact has no Actions, can't send a message";
   419     }
   425     }
   420     
   426     
   549     // Launching the phonebook to main view
   555     // Launching the phonebook to main view
   550     mRequest = mApplicationManager->create("com.nokia.services.phonebookappservices",
   556     mRequest = mApplicationManager->create("com.nokia.services.phonebookappservices",
   551                                            "Launch", "launch()", false);
   557                                            "Launch", "launch()", false);
   552     mCleanupHandler.add(mRequest);
   558     mCleanupHandler.add(mRequest);
   553     if (mRequest) {
   559     if (mRequest) {
       
   560     	mRequest->setSynchronous(false);
   554         QVariant retValue(-1);
   561         QVariant retValue(-1);
   555 		bool result = mRequest->send(retValue);
   562 		bool result = mRequest->send(retValue);
   556 		if (!result) {
   563 		if (!result) {
   557         	qDebug() << "Sending request failed: " << mRequest->lastErrorMessage();
   564         	qDebug() << "Sending request failed: " << mRequest->lastErrorMessage();
   558         }
   565         }