phonebookengines/cntactions/src/cntaction.cpp
changeset 53 e6aff7b69165
parent 50 77bc263e1626
child 61 d30183af6ca6
equal deleted inserted replaced
51:81c360d47083 53:e6aff7b69165
   163     QVariantList args;
   163     QVariantList args;
   164     QVariant retValue;
   164     QVariant retValue;
   165     
   165     
   166     // TODO: Using XQApplicationManager is not working with calls
   166     // TODO: Using XQApplicationManager is not working with calls
   167     // The factory method cannot create a request. Find out why
   167     // The factory method cannot create a request. Find out why
   168     bool isCallAction = (m_actionName == "call" || m_actionName == "videocall");
   168     //bool isCallAction = (m_actionName == "call" || m_actionName == "videocall");
   169     XQServiceRequest snd(interface, operation, false);
   169     XQServiceRequest snd(interface, operation, false);
   170 
   170 
   171     delete m_request;
       
   172     m_request = NULL;
       
   173     m_request = m_AppManager.create(interface, operation, false); // not embedded
       
   174     
       
   175     if (!isCallAction) {
       
   176         if (!m_request) {
       
   177             emitResult(GeneralError, retValue);
       
   178             return;
       
   179         }
       
   180     }
       
   181     
       
   182     //QContactType == TypeGroup
   171     //QContactType == TypeGroup
   183     if (QContactType::TypeGroup == m_contact.type()) {
   172     if (QContactType::TypeGroup == m_contact.type()) {
   184         QContactPhoneNumber conferenceCall = m_contact.detail<QContactPhoneNumber>();
   173         QContactPhoneNumber conferenceCall = m_contact.detail<QContactPhoneNumber>();
   185         args << conferenceCall.number() << m_contact.localId() << m_contact.displayLabel();
   174         args << conferenceCall.number() << m_contact.localId() << m_contact.displayLabel();
   186         
   175         
   194     else if (m_detail.definitionName() == QContactPhoneNumber::DefinitionName) {
   183     else if (m_detail.definitionName() == QContactPhoneNumber::DefinitionName) {
   195 		const QContactPhoneNumber &phoneNumber = static_cast<const QContactPhoneNumber &>(m_detail);
   184 		const QContactPhoneNumber &phoneNumber = static_cast<const QContactPhoneNumber &>(m_detail);
   196 		
   185 		
   197 		args << phoneNumber.number() << m_contact.localId() << m_contact.displayLabel();
   186 		args << phoneNumber.number() << m_contact.localId() << m_contact.displayLabel();
   198 	    
   187 	    
   199 		// TODO remove once call action works
   188         snd << phoneNumber.number() << m_contact.localId() << m_contact.displayLabel();
   200 		if (isCallAction) {
   189         snd.send(retValue);
   201             snd << phoneNumber.number() << m_contact.localId() << m_contact.displayLabel();
   190         emitResult(snd.latestError(), retValue);
   202             snd.send(retValue);
       
   203             emitResult(snd.latestError(), retValue);
       
   204 	    } 
       
   205 		else {
       
   206 	       m_request->setArguments(args);
       
   207 	       m_request->send(retValue);
       
   208            emitResult(m_request->lastError(), retValue);
       
   209 	    }
       
   210 	}
   191 	}
   211     //QContactType == TypeContact
   192     //QContactType == TypeContact
   212     //if no detail, pick preferred
   193     //if no detail, pick preferred
   213 	else if (m_detail.isEmpty())
   194 	else if (m_detail.isEmpty())
   214 	{
   195 	{
   225 			phoneNumber = static_cast<QContactPhoneNumber>(detail);
   206 			phoneNumber = static_cast<QContactPhoneNumber>(detail);
   226 		}
   207 		}
   227 		
   208 		
   228 		args << phoneNumber.number() << m_contact.localId() << m_contact.displayLabel();
   209 		args << phoneNumber.number() << m_contact.localId() << m_contact.displayLabel();
   229 
   210 
   230         // TODO remove once call action works
   211         snd << phoneNumber.number() << m_contact.localId() << m_contact.displayLabel();
   231         if (isCallAction) {
   212         snd.send(retValue);
   232             snd << phoneNumber.number() << m_contact.localId() << m_contact.displayLabel();
   213         emitResult(snd.latestError(), retValue);
   233             snd.send(retValue);
       
   234             emitResult(snd.latestError(), retValue);
       
   235         }
       
   236         else {
       
   237             m_request->setArguments(args);
       
   238             m_request->send(retValue);
       
   239             emitResult(m_request->lastError(), retValue);
       
   240         }
       
   241 	}
   214 	}
   242 	//else return an error
   215 	//else return an error
   243 	else {
   216 	else {
   244 		emitResult(GeneralError, retValue);
   217 		emitResult(GeneralError, retValue);
   245 	}
   218 	}