phonebookengines/cntactions/src/cntaction.cpp
changeset 59 a642906a277a
parent 47 7cbcb2896f0e
child 65 ae724a111993
--- a/phonebookengines/cntactions/src/cntaction.cpp	Tue Jul 06 14:05:47 2010 +0300
+++ b/phonebookengines/cntactions/src/cntaction.cpp	Wed Aug 18 09:39:00 2010 +0300
@@ -116,10 +116,11 @@
 }
 
 
-bool CntAction::invokeAction(const QContact& contact, const QContactDetail& detail, const QVariantMap& /*parameters*/)
+bool CntAction::invokeAction(const QContact& contact, const QContactDetail& detail, const QVariantMap& data)
 {
 	m_contact = contact;
 	m_detail  = detail;
+	m_data = data;
 	
 	QTimer::singleShot(1, this, SLOT(performAction()));
 	m_state = QContactAction::ActiveState;
@@ -159,77 +160,60 @@
 //common code to perform a call, videocall and message action
 void CntAction::performNumberAction(const QString &interface, const QString &operation)
 {
-    XQApplicationManager appMng;
     QVariantList args;
     QVariant retValue;
     
     // TODO: Using XQApplicationManager is not working with calls
     // The factory method cannot create a request. Find out why
-    bool isCallAction = m_actionName == "call";
+    //bool isCallAction = (m_actionName == "call" || m_actionName == "videocall");
     XQServiceRequest snd(interface, operation, false);
 
-    delete m_request;
-    m_request = NULL;
-    m_request = appMng.create(interface, operation, false); // not embedded
-    if (!isCallAction) {
-        if (!m_request) {
-            emitResult(GeneralError, retValue);
-            return;
-        }
+    //QContactType == TypeGroup
+    if (QContactType::TypeGroup == m_contact.type()) {
+        QContactPhoneNumber conferenceCall = m_contact.detail<QContactPhoneNumber>();
+        args << conferenceCall.number() << m_contact.localId() << m_contact.displayLabel();
+        
+        // TODO remove once call action works
+        snd << conferenceCall.number() << m_contact.localId() << m_contact.displayLabel();
+        snd.send(retValue);
+        emitResult(snd.latestError(), retValue);
     }
-	
+    //QContactType == TypeContact
     //detail exist use it
-	if (m_detail.definitionName() == QContactPhoneNumber::DefinitionName)
-	{
+    else if (m_detail.definitionName() == QContactPhoneNumber::DefinitionName) {
 		const QContactPhoneNumber &phoneNumber = static_cast<const QContactPhoneNumber &>(m_detail);
 		
 		args << phoneNumber.number() << m_contact.localId() << m_contact.displayLabel();
 	    
-		// TODO remove once call action works
-		if (isCallAction) {
-            snd << phoneNumber.number() << m_contact.localId() << m_contact.displayLabel();
-            emitResult(snd.send(retValue), retValue);
-	    } else {
-	       m_request->setArguments(args);
-	       m_request->setSynchronous(true);
-           emitResult(m_request->send(retValue), retValue);
-	    }
+        snd << phoneNumber.number() << m_contact.localId() << m_contact.displayLabel();
+        snd.send(retValue);
+        emitResult(snd.latestError(), retValue);
 	}
-	
-	//if no detail, pick preferred
-	else if(m_detail.isEmpty())
+    //QContactType == TypeContact
+    //if no detail, pick preferred
+	else if (m_detail.isEmpty())
 	{
 		QContactDetail detail = m_contact.preferredDetail(m_actionName);
 		QContactPhoneNumber phoneNumber;
 	
 		//if preferred is empty pick first phonenumber
-		if(detail.isEmpty())
-		{
+		if (detail.isEmpty()) {
 			phoneNumber = m_contact.detail<QContactPhoneNumber>();
 		}
 		
 		//if not empty, cast detail to phonenumber
-		else
-		{
+		else {
 			phoneNumber = static_cast<QContactPhoneNumber>(detail);
 		}
 		
 		args << phoneNumber.number() << m_contact.localId() << m_contact.displayLabel();
 
-        // TODO remove once call action works
-        if (isCallAction) {
-            snd << phoneNumber.number() << m_contact.localId() << m_contact.displayLabel();
-            emitResult(snd.send(retValue), retValue);
-        } else {
-            m_request->setArguments(args);
-            m_request->setSynchronous(true);
-            emitResult(m_request->send(retValue), retValue);
-        }
+        snd << phoneNumber.number() << m_contact.localId() << m_contact.displayLabel();
+        snd.send(retValue);
+        emitResult(snd.latestError(), retValue);
 	}
-	
 	//else return an error
-	else
-	{
+	else {
 		emitResult(GeneralError, retValue);
 	}
 }
@@ -244,11 +228,11 @@
         m_result.insert("XQAiwRequest Error", m_request->lastError());
 	}
 	
-	if (errorCode == 0){
+	if (errorCode == 0) {
 		m_state = QContactAction::FinishedState;
 	}
 	
-	else{
+	else {
 		m_state = QContactAction::FinishedWithErrorState;
 	}