diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | bcb704366cb5e333a626c18c308c7e0448a8e69f (patch) | |
tree | f0d6ab7d78ecdd9207cf46536376b44b91a1ca71 /kopete/protocols/jabber/ui/dlgjabberregister.cpp | |
download | tdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.tar.gz tdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kopete/protocols/jabber/ui/dlgjabberregister.cpp')
-rw-r--r-- | kopete/protocols/jabber/ui/dlgjabberregister.cpp | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/kopete/protocols/jabber/ui/dlgjabberregister.cpp b/kopete/protocols/jabber/ui/dlgjabberregister.cpp new file mode 100644 index 00000000..e16b5652 --- /dev/null +++ b/kopete/protocols/jabber/ui/dlgjabberregister.cpp @@ -0,0 +1,117 @@ + +/*************************************************************************** + dlgjabberregister.cpp - description + ------------------- + begin : Mon Dec 9 2002 + copyright : (C) 2002-2003 by Till Gerken <[email protected]> + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include <qpushbutton.h> + +#include <kmessagebox.h> +#include <klocale.h> + +#include "jabberaccount.h" +#include "jabberprotocol.h" +#include "jabberclient.h" +#include "dlgjabberregister.h" + +dlgJabberRegister::dlgJabberRegister (JabberAccount *account, const XMPP::Jid & jid, QWidget * parent, const char *name):dlgRegister (parent, name) +{ + m_account = account; + + XMPP::JT_Register * task = new XMPP::JT_Register(m_account->client()->rootTask ()); + + connect (task, SIGNAL (finished ()), this, SLOT (slotGotForm ())); + + task->getForm (jid); + task->go (true); + + translator = 0; + +} + +void dlgJabberRegister::slotGotForm () +{ + XMPP::JT_Register * task = (XMPP::JT_Register *) sender (); + + // remove the "wait" message + delete lblWait; + + if (!task->success ()) + { + KMessageBox::error (this, i18n ("Unable to retrieve registration form.\nReason: \"%1\"").arg (task->statusString (), 1), i18n ("Jabber Error")); + + deleteLater (); + + return; + } + + // translate the form and create it inside the box widget + translator = new JabberFormTranslator (task->form (), grpForm); + static_cast<QBoxLayout*>(grpForm->layout())->insertWidget(1, translator); + translator->show(); + resize(sizeHint()); + + // enable the send button + btnRegister->setEnabled (true); + + connect (btnRegister, SIGNAL (clicked ()), this, SLOT (slotSendForm ())); + +} + +void dlgJabberRegister::slotSendForm () +{ + if(!translator) + return; + XMPP::JT_Register * task = new XMPP::JT_Register (m_account->client()->rootTask ()); + + connect (task, SIGNAL (finished ()), this, SLOT (slotSentForm ())); + + task->setForm (translator->resultData ()); + task->go (true); + + btnRegister->setEnabled (false); + btnCancel->setEnabled (false); + +} + +void dlgJabberRegister::slotSentForm () +{ + XMPP::JT_Register * task = (XMPP::JT_Register *) sender (); + + if (task->success ()) + { + KMessageBox::information (this, i18n ("Registration sent successfully."), i18n ("Jabber Registration")); + + deleteLater (); + } + else + { + KMessageBox::error (this, + i18n ("The server denied the registration form.\nReason: \"%1\"").arg (task->statusString (), 1), i18n ("Jabber Registration")); + + btnRegister->setEnabled (true); + btnRegister->setEnabled (true); + } + +} + +dlgJabberRegister::~dlgJabberRegister () +{ + + delete translator; + +} + +#include "dlgjabberregister.moc" |