You can make a message in your readCookies () slot:
void readCookies( QNetworkReply* reply ) { if ( ...error? ) { report error... return; } ... manager->post(request2,postData2); }
I will be called when the cookies are read and you can continue your message. Connect this to the second slot and so on. Managing multiple, possibly parallel, asynchronous operations, such as this can be a mistake, though, if you are managing many of them in the same object. I would suggest using the Command Pattern - here, which I described why I find it extremely useful in this context. A sequence of requests and asynchronous operations is encapsulated in a single object (in abbreviated form, with some pseudo-code):
class PostStuffOperation : public QObject { Q_OBJECT public: enum Error { NoError=0, Error=1, ... }; Error error() const;
To start the operation, do
PostStuffOperation op* = new PostStuffOperation( this ); ... pass data like server, port etc. to the operation connect( op, SIGNAL(finished()), this, SLOT(postOperationFinished()) ); op->start(); void postOperationFinished( PostStuffOperation* op ) { if ( op->error != PostStuffOperation::NoError ) {
It makes sense to have a common base class for such operations; see, for example, KDE KJob .
source share