projects
/
qtmeetings
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Multiple simultaneous request support to Communication
[qtmeetings]
/
src
/
IO
/
Communication
/
Communication.cpp
diff --git
a/src/IO/Communication/Communication.cpp
b/src/IO/Communication/Communication.cpp
index
82b847e
..
5c3b924
100644
(file)
--- 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 );
iConnectionSettings = new ConnectionSettings( aConnection );
iHttp = new QHttp( iConnectionSettings->serverUrl().toString(), QHttp::ConnectionModeHttps );
- iResponse = new QByteArray();
connect( iHttp,
SIGNAL( readyRead( const QHttpResponseHeader& ) ),
connect( iHttp,
SIGNAL( readyRead( const QHttpResponseHeader& ) ),
@@
-46,32
+45,42
@@
Communication::~Communication()
{
delete iConnectionSettings;
delete iHttp;
{
delete iConnectionSettings;
delete iHttp;
- delete iResponse;
+ QList<QByteArray*> responses = iResponses.values();
+ while(!responses.isEmpty())
+ delete responses.takeFirst();
}
void Communication::processResponse( const QHttpResponseHeader& aHeader )
{
if ( aHeader.statusCode() == 200 )
{
}
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 )
{
}
}
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*/ )
{
}
}
void Communication::handleResults( int aId, bool /*aError*/ )
{
- if( aId == iCurrentRequest )
+ if( iCurrentRequest != 0 && aId == iCurrentRequest )
{
{
+ iAuthFailCount = 0;
iCurrentRequest = 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 )
{
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;
return 0;
+
QHttpRequestHeader header( QString( "POST" ), QString( "/ews/exchange.asmx" ) );
header.setValue( "Host", iConnectionSettings->serverUrl().toString() );
QString command = aCommand;
header.setContentType( command );
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 )
}
void Communication::handleReadProgress( int aDone, int aTotal )