From e4ffbeb064894b61c85e09e1a369a13f9906ea2f Mon Sep 17 00:00:00 2001 From: Manjeet Dahiya Date: Fri, 8 Oct 2010 14:05:01 +0000 Subject: error handling --- examples/GuiClient/mainDialog.cpp | 35 +++++++++++++++++++++++++++++++++++ examples/GuiClient/mainDialog.h | 1 + 2 files changed, 36 insertions(+) (limited to 'examples/GuiClient') diff --git a/examples/GuiClient/mainDialog.cpp b/examples/GuiClient/mainDialog.cpp index fba4f250..640ab95f 100644 --- a/examples/GuiClient/mainDialog.cpp +++ b/examples/GuiClient/mainDialog.cpp @@ -79,6 +79,11 @@ mainDialog::mainDialog(QWidget *parent): QDialog(parent, Qt::Window), this, SLOT(rosterChanged(const QString&))); Q_ASSERT(check); + check = connect(&m_xmppClient, + SIGNAL(error(QXmppClient::Error)), + this, SLOT(errorClient(QXmppClient::Error))); + Q_ASSERT(check); + check = connect(&m_xmppClient, SIGNAL(presenceReceived(const QXmppPresence&)), this, SLOT(presenceReceived(const QXmppPresence&))); @@ -756,3 +761,33 @@ void mainDialog::action_removeContact(const QString& bareJid) remove.addItem(itemRemove); m_xmppClient.sendPacket(remove); } + +void mainDialog::errorClient(QXmppClient::Error error) +{ + ui->label_throbber->hide(); + + showSignInPage(); + + switch(error) + { + case QXmppClient::SocketError: + showLoginStatus("Socket error"); + break; + case QXmppClient::KeepAliveError: + showLoginStatus("Keep alive error"); + break; + case QXmppClient::XmppStreamError: + switch(m_xmppClient.xmppStreamError()) + { + case QXmppStanza::Error::NotAuthorized: + showLoginStatus("Invalid password"); + break; + default: + showLoginStatus("Stream error"); + break; + } + break; + default: + break; + } +} diff --git a/examples/GuiClient/mainDialog.h b/examples/GuiClient/mainDialog.h index 1e3252a0..c9ae6014 100644 --- a/examples/GuiClient/mainDialog.h +++ b/examples/GuiClient/mainDialog.h @@ -84,6 +84,7 @@ private slots: void userNameCompleter_activated(const QString&); void addAccountToCache(); void presenceReceived(const QXmppPresence&); + void errorClient(QXmppClient::Error); void action_addContact(); void action_removeContact(const QString& bareJid); -- cgit v1.2.3