On 09 Mar 2014, at 19:32, Olivier Goffart <oliv...@woboq.com> wrote:
> On Sunday 09 March 2014 15:10:02 Kurt Pattyn wrote: >> Currently, QNAM stalls when authentication is required (also see: >> https://bugreports.qt-project.org/browse/QTBUG-16251). Also, the connection >> between the authenticationRequired signal and the slot must be a direct >> connection. This is problematic when an application wants to show a login >> dialogbox for instance. >> >> I propose to change this implementation by using a delegate authenticator >> instead. > ... >> What are your opinions on this? > > 1) Your suggested change would be binary incompatible. You would need to > pick > another class name than QAuthenticator > > 2) Your change does not seem to fix the problem at all. You get a "blocking" > virtual function instead of a "blocking" signal. > > > Here is my suggested API change: adding QNetworkReply::pause and > QNetworkReply::resumeAuthentication, to be used as this. > > > QObject::connect(qnam, &QNetworkManager::authenticationRequired, > [](QNetworkReply * reply, QAuthenticator * authenticator) { > reply->pause(); // New slot: when we return this function it won't continue > auto dialog = new MyPasswordDialog(); > dialog->open(); > QObject::connect(dialog, &MyPasswordDialog::done, reply, [=]{ > authenticator->setUser(dialog->user); > authenticator->setPassword(dialog->password); > reply->resumeAuthentication(authenticator); //new slot; > }); > }); > > > Alternative: adding those function to the QAuthenticator itself. I think it does solve the problem if QNAM would be changed like this: if (networkRequest->hasAuthenticator()) connect(networkRequest->authenticator(), &QAuthenticator::authenticated, this, &QNAM::goToNextStep); ... if (authenticationNeeded) if (networkRequest->hasAuthenticator()) QMetaMethod::invoke(“authenticate" , networkRequest, ..., QueuedConnection); else //authentication failed else goToNextStep(); ... Q_SLOTS: void goToNextStep() { ... } The handling of incoming data would basically be split in two parts. When authentication is needed, a queued metacall is invoked which makes it asynchronous. > > -- > Olivier > > Woboq - Qt services and support - http://woboq.com - http://code.woboq.org >
_______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development