X-Git-Url: http://git.maemo.org/git/?p=qtmeetings;a=blobdiff_plain;f=src%2FIO%2FCommunication%2FCommunication.cpp;h=5c3b9244f6466ccfe4b1063928250892eddc6d00;hp=82b847e084096b1518e04192f310d54887b0e2f7;hb=5810de08d3a5b5311ba1b4175fba51072aa0e754;hpb=9ee999fe4a7de48abc3b4f950699cd4564d16562 diff --git a/src/IO/Communication/Communication.cpp b/src/IO/Communication/Communication.cpp index 82b847e..5c3b924 100644 --- a/src/IO/Communication/Communication.cpp +++ b/src/IO/Communication/Communication.cpp @@ -9,7 +9,6 @@ Communication::Communication( const ConnectionSettings &aConnection ) : iConnectionSettings = new ConnectionSettings( aConnection ); iHttp = new QHttp( iConnectionSettings->serverUrl().toString(), QHttp::ConnectionModeHttps ); - iResponse = new QByteArray(); connect( iHttp, SIGNAL( readyRead( const QHttpResponseHeader& ) ), @@ -46,32 +45,42 @@ Communication::~Communication() { delete iConnectionSettings; delete iHttp; - delete iResponse; + QList responses = iResponses.values(); + while(!responses.isEmpty()) + delete responses.takeFirst(); } void Communication::processResponse( const QHttpResponseHeader& aHeader ) { if ( aHeader.statusCode() == 200 ) { - iResponse->append( iHttp->readAll() ); + if( iResponses.contains( iCurrentRequest ) ) + { + QByteArray* response = iResponses.value( iCurrentRequest, NULL ); + response->append( iHttp->readAll() ); + } } } void Communication::handleRequestStarted( int aRequestId ) { - if( aRequestId != 0 && iCurrentRequest != 0 && - aRequestId == iCurrentRequest ) + if( iResponses.contains( aRequestId ) ) { - emit requestStarted( iCurrentRequest ); + iCurrentRequest = aRequestId; + emit requestStarted( aRequestId ); } } void Communication::handleResults( int aId, bool /*aError*/ ) { - if( aId == iCurrentRequest ) + if( iCurrentRequest != 0 && aId == iCurrentRequest ) { + iAuthFailCount = 0; iCurrentRequest = 0; - emit requestFinished( aId, iHttp->error() ); + int err = (int)iHttp->error(); + if( iHttp->error() == QHttp::Aborted && iAuthFailCount > 1 ) + err = 11; + emit requestFinished( aId, err ); } } @@ -88,24 +97,34 @@ void Communication::handleAuthentication( const QString& /*aHost*/, quint16 /*aP int Communication::request( const QString &aCommand, const QByteArray &aContent ) { - //TODO: This is just temporarily here to implement multiple request support - if( iCurrentRequest ) + if( iAuthFailCount > 1 ) return 0; + QHttpRequestHeader header( QString( "POST" ), QString( "/ews/exchange.asmx" ) ); header.setValue( "Host", iConnectionSettings->serverUrl().toString() ); QString command = aCommand; header.setContentType( command ); - iAuthFailCount = 0; - iResponse->clear(); - iCurrentRequest = iHttp->request( header, aContent ); + int id = iHttp->request( header, aContent ); + if( iResponses.contains( id ) ) + { + QByteArray* response = iResponses.value( id, NULL ); + response->clear(); + } + else + { + iResponses.insert( id, new QByteArray() ); + } - return iCurrentRequest; + return id; } -const QByteArray& Communication::response( int /*aRequestId*/ ) +QByteArray* Communication::response( int aRequestId ) { - return *iResponse; + if( !iResponses.contains( aRequestId ) ) + return NULL; + QByteArray* response = iResponses.take( aRequestId ); + return response; } void Communication::handleReadProgress( int aDone, int aTotal )