phonebookengines/cntactions/src/cntmessageaction.cpp
changeset 59 a642906a277a
parent 47 7cbcb2896f0e
child 66 554fe4dbbb59
equal deleted inserted replaced
47:7cbcb2896f0e 59:a642906a277a
    64     return supportedDetails;
    64     return supportedDetails;
    65 }
    65 }
    66 
    66 
    67 void CntMessageAction::performAction()
    67 void CntMessageAction::performAction()
    68 {
    68 {
    69     QString service("com.nokia.symbian.IMessageSend");
    69     QList<QVariant> data;
    70     QString type("send(QString,qint32,QString)");
    70     QVariant retValue;
    71     
    71     
    72     performNumberAction(service, type);
    72     delete m_request;
       
    73     m_request = NULL;
       
    74         
       
    75     //QContactType == TypeGroup
       
    76     if (QContactType::TypeGroup == m_contact.type()) {
       
    77         QString interface("com.nokia.symbian.IMessageSend");
       
    78         QString operation("send(QVariantMap,QString)");
       
    79         m_request = m_AppManager.create(interface, operation, false); // not embedded
       
    80         if (m_request==NULL) {
       
    81             emitResult(GeneralError, retValue);
       
    82             return;
       
    83         }
       
    84         
       
    85         QVariantMap recipientMap;
       
    86         QVariant value = m_data.value("message");
       
    87         if (value.canConvert<QVariantMap>()) {
       
    88             recipientMap = value.toMap();
       
    89         }
       
    90         if (!recipientMap.isEmpty()) {
       
    91             data.append(recipientMap); //recipients
       
    92             data.append(QString()); //body text
       
    93             
       
    94             m_request->setArguments(data);
       
    95             m_request->send(retValue);
       
    96             emitResult(m_request->lastError(), retValue);
       
    97         }
       
    98         else {
       
    99             emitResult(GeneralError, retValue);
       
   100         }
       
   101     }
       
   102     //QContactType == TypeContact
       
   103     //detail exist use it
       
   104     else if (m_detail.definitionName() == QContactPhoneNumber::DefinitionName) {
       
   105         QString interface("com.nokia.symbian.IMessageSend");
       
   106         QString operation("send(QString,qint32,QString)");
       
   107         m_request = m_AppManager.create(interface, operation, false); // not embedded
       
   108         if (m_request==NULL) {
       
   109             emitResult(GeneralError, retValue);
       
   110             return;
       
   111         }
       
   112         
       
   113         const QContactPhoneNumber &phoneNumber = static_cast<const QContactPhoneNumber &>(m_detail);
       
   114         data << phoneNumber.number() << m_contact.localId() << m_contact.displayLabel();
       
   115         
       
   116         m_request->setArguments(data);
       
   117         m_request->send(retValue);
       
   118         emitResult(m_request->lastError(), retValue);
       
   119     }
       
   120     else {
       
   121         emitResult(GeneralError, retValue);
       
   122     }
    73 }
   123 }
    74 
   124 
    75 
   125 
    76 
   126