From 97193b2a96803e2106d00450bd27c85e508253e5 Mon Sep 17 00:00:00 2001 From: me_laptop Date: Thu, 26 Jul 2012 10:54:30 +0000 Subject: handling connection errors in RegisterAccountDialog git-svn-id: svn://localhost/project_picapica/trunk@152 fb96df88-216d-11de-830c-f3023f12d8ac --- pica-client/dialogs/registeraccountdialog.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'pica-client/dialogs/registeraccountdialog.cpp') diff --git a/pica-client/dialogs/registeraccountdialog.cpp b/pica-client/dialogs/registeraccountdialog.cpp index 1ce1cdb..bc723f7 100644 --- a/pica-client/dialogs/registeraccountdialog.cpp +++ b/pica-client/dialogs/registeraccountdialog.cpp @@ -96,9 +96,10 @@ void RegisterAccountDialog::stageConnect(int retval,QProcess::ExitStatus) lbStatus->setText(tr("3) Connecting to server...")); - sock.connectToHost(registrar_hosts[(registrar_index++)%(sizeof(registrar_hosts)/sizeof(char*))], 2299); - connect(&sock, SIGNAL(connected()), this, SLOT(stageGetCert())); + connect(&sock, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(showError())); + + sock.connectToHost(registrar_hosts[(registrar_index++)%(sizeof(registrar_hosts)/sizeof(char*))], 2299); } void RegisterAccountDialog::stageGetCert() @@ -124,6 +125,8 @@ void RegisterAccountDialog::stageReadCert() if (cert_buf.contains("-----END CERTIFICATE-----") || cert_buf.contains("-----END X509 CERTIFICATE-----")) { + disconnect(&sock, SIGNAL(error(QAbstractSocket::SocketError)), 0, 0); + QFile cert(config_dir + QDir::separator() + "cert.pem"); cert.open(QIODevice::WriteOnly | QIODevice::Truncate); cert.write(cert_buf.data(),cert_buf.size()); @@ -147,3 +150,10 @@ QString RegisterAccountDialog::GetPkeyFilename() { return PkeyFilename_; } + +void RegisterAccountDialog::showError() +{ + QMessageBox mbx; + mbx.setText(sock.errorString()); + mbx.exec(); +} -- cgit v1.2.1