Help me write program work with protocol FTP and authentication by login password using QnetworkAccessManager. I implement connect to server and get directory listing, but i dont undestend how implement authentication. I read article http://doc.qt.nokia.com/qq/32/qq32-webkit-protocols.html.
My source in attach https://rapidshare.com/files/457472584/zip.zip.
Qt 4.7 Windows Xp Linux
I'm doing something similar and need to solve the very same problem:
What I do is:
- create the QNetworkAccessManager object, and connect the signal authenticationRequired
m_ftpManagerPtr = new QNetworkAccessManager(this);
Q_ASSERT(m_ftpManagerPtr);
connect ( m_ftpManagerPtr,
SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
this,
SLOT(onAuthenticationRequestSlot(QNetworkReply*,QAuthenticator*)) );
Inside the slot function I simply populate the user name and password fields/variable:
void QacFtpClient::onAuthenticationRequestSlot(QNetworkReply *aReply,
QAuthenticator *aAuthenticator)
{
qDebug() << Q_FUNC_INFO;
aAuthenticator->setUser(m_ftpUser);
aAuthenticator->setPassword(m_ftpPasswd);
}
And that's it... it automagically works ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With