qtcontactsmobility/tests/auto/qcontactasync/maliciousplugin/maliciousplugin.cpp
changeset 25 76a2435edfd4
parent 24 0ba2181d7c28
child 27 de1630741fbe
equal deleted inserted replaced
24:0ba2181d7c28 25:76a2435edfd4
    61 void MaliciousAsyncManagerEngine::deref()
    61 void MaliciousAsyncManagerEngine::deref()
    62 {
    62 {
    63     // does this leak?
    63     // does this leak?
    64 }
    64 }
    65 
    65 
    66 QString MaliciousAsyncManagerEngine::synthesizeDisplayLabel(const QContact& contact, QContactManager::Error& error) const
    66 QString MaliciousAsyncManagerEngine::synthesizedDisplayLabel(const QContact& contact, QContactManager::Error& error) const
    67 {
    67 {
    68     Q_UNUSED(contact);
    68     Q_UNUSED(contact);
    69     error = QContactManager::NotSupportedError;
    69     error = QContactManager::NotSupportedError;
    70     return QString();
    70     return QString();
    71 }
    71 }
    75     return QString(makename(MALICIOUSPLUGINNAME));
    75     return QString(makename(MALICIOUSPLUGINNAME));
    76 }
    76 }
    77 
    77 
    78 bool MaliciousAsyncManagerEngine::startRequest(QContactAbstractRequest* req)
    78 bool MaliciousAsyncManagerEngine::startRequest(QContactAbstractRequest* req)
    79 {
    79 {
    80     QContactManager::Error errorResult = QContactManager::NoError;
    80     // maliciously attempt to update the request with every result type
       
    81     updateRequestState(req, QContactAbstractRequest::ActiveState);
       
    82     // XXX TODO: call the request-type specific update functions
       
    83 /*
       
    84     //QContactManager::Error errorResult = QContactManager::NoError;
    81     QList<QContactManager::Error> errorsResult;
    85     QList<QContactManager::Error> errorsResult;
    82     QList<QContactLocalId> idResult;
    86     QList<QContactLocalId> idResult;
    83     QList<QContact> contactResult;
    87     QList<QContact> contactResult;
    84     QList<QContactDetailDefinition> defResult;
    88     QList<QContactDetailDefinition> defResult;
    85     QMap<QString, QContactDetailDefinition> defMapResult;
    89     QMap<QString, QContactDetailDefinition> defMapResult;
    86     QList<QContactRelationship> relResult;
    90     QList<QContactRelationship> relResult;
    87 
    91 
    88     // maliciously attempt to update the request with every result type
    92     updateContactLocalIdFetchRequest(req, idResult, errorResult, errorsResult, QContactAbstractRequest::ActiveState, false);
    89     updateRequestStatus(req, errorResult, errorsResult, QContactAbstractRequest::Active, false);
    93     updateContactFetchRequest(req, contactResult, errorResult, errorsResult, QContactAbstractRequest::ActiveState, false);
    90     updateRequest(req, idResult, errorResult, errorsResult, QContactAbstractRequest::Active, false);
    94     updateDefinitionSaveRequest(req, defResult, errorResult, errorsResult, QContactAbstractRequest::ActiveState);
    91     updateRequest(req, contactResult, errorResult, errorsResult, QContactAbstractRequest::Active, false);
    95     updateDefinitionFetchRequest(req, defMapResult, errorResult, errorsResult, QContactAbstractRequest::ActiveState, false);
    92     updateRequest(req, defResult, errorResult, errorsResult, QContactAbstractRequest::Active);
    96     updateRequest(req, relResult, errorResult, errorsResult, QContactAbstractRequest::ActiveState, false);
    93     updateRequest(req, defMapResult, errorResult, errorsResult, QContactAbstractRequest::Active, false);
    97 */
    94     updateRequest(req, relResult, errorResult, errorsResult, QContactAbstractRequest::Active, false);
       
    95 
       
    96     QContactManagerEngine::startRequest(req);
    98     QContactManagerEngine::startRequest(req);
    97     return true;
    99     return true;
    98 }
   100 }
    99 
   101 
   100 bool MaliciousAsyncManagerEngine::cancelRequest(QContactAbstractRequest *req)
   102 bool MaliciousAsyncManagerEngine::cancelRequest(QContactAbstractRequest *req)
   101 {
   103 {
   102     QContactManager::Error errorResult = QContactManager::NoError;
   104     updateRequestState(req, QContactAbstractRequest::CanceledState);
   103     QList<QContactManager::Error> errorsResult;
       
   104     updateRequestStatus(req, errorResult, errorsResult, QContactAbstractRequest::Cancelled, false);
       
   105     QContactManagerEngine::cancelRequest(req);
   105     QContactManagerEngine::cancelRequest(req);
   106     return true;
   106     return true;
   107 }
   107 }
   108 
   108 
   109 
   109