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.

-- 
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

Reply via email to