From 26969a3000a85c66c03cd6893d0510d6a9147038 Mon Sep 17 00:00:00 2001 From: ishmal Date: Wed, 24 May 2006 05:08:32 +0000 Subject: [PATCH] Finish registration stuff --- src/pedro/pedrogui.cpp | 97 +++++++++++++++++++++++++++++------------ src/pedro/pedrogui.h | 21 ++++++--- src/pedro/pedroxmpp.cpp | 4 +- 3 files changed, 86 insertions(+), 36 deletions(-) diff --git a/src/pedro/pedrogui.cpp b/src/pedro/pedrogui.cpp index b50791e25..d5df2f5d7 100644 --- a/src/pedro/pedrogui.cpp +++ b/src/pedro/pedrogui.cpp @@ -1210,11 +1210,11 @@ void PasswordDialog::okCallback() Glib::ustring pass = passField.get_text(); Glib::ustring newpass = newField.get_text(); Glib::ustring confpass = confField.get_text(); - if ((pass.size() < 6 || pass.size() > 12 ) || - (newpass.size() < 6 || newpass.size() > 12 ) || - (confpass.size() < 6 || confpass.size()> 12 )) + if ((pass.size() < 5 || pass.size() > 12 ) || + (newpass.size() < 5 || newpass.size() > 12 ) || + (confpass.size() < 5 || confpass.size()> 12 )) { - Gtk::MessageDialog dlg(*this, "Password must be 6 to 12 characters", + Gtk::MessageDialog dlg(*this, "Password must be 5 to 12 characters", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); dlg.run(); } @@ -1226,17 +1226,24 @@ void PasswordDialog::okCallback() } else { - response(Gtk::RESPONSE_OK); + //response(Gtk::RESPONSE_OK); hide(); } } void PasswordDialog::cancelCallback() { - response(Gtk::RESPONSE_CANCEL); + //response(Gtk::RESPONSE_CANCEL); hide(); } +void PasswordDialog::on_response(int response_id) +{ + if (response_id == Gtk::RESPONSE_OK) + okCallback(); + else + cancelCallback(); +} bool PasswordDialog::doSetup() { @@ -1293,7 +1300,7 @@ bool PasswordDialog::doSetup() table.attach(confField, 1, 2, 2, 3); add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); + add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); show_all_children(); @@ -1848,6 +1855,44 @@ bool PedroGui::groupChatPresence(const DOMString &groupJid, //################################ //# EVENTS //################################ + +/** + * + */ +void PedroGui::handleConnectEvent() +{ + status("##### CONNECTED"); + actionEnable("Connect", false); + actionEnable("Chat", true); + actionEnable("GroupChat", true); + actionEnable("Disconnect", true); + actionEnable("RegPass", true); + actionEnable("RegCancel", true); + DOMString title = "Pedro - "; + title.append(client.getJid()); + set_title(title); +} + + +/** + * + */ +void PedroGui::handleDisconnectEvent() +{ + status("##### DISCONNECTED"); + actionEnable("Connect", true); + actionEnable("Chat", false); + actionEnable("GroupChat", false); + actionEnable("Disconnect", false); + actionEnable("RegPass", false); + actionEnable("RegCancel", false); + DOMString title = "Pedro"; + set_title(title); + chatDeleteAll(); + groupChatDeleteAll(); +} + + /** * */ @@ -1871,31 +1916,12 @@ void PedroGui::doEvent(const XmppEvent &event) } case XmppEvent::EVENT_CONNECTED: { - status("##### CONNECTED"); - actionEnable("Connect", false); - actionEnable("Chat", true); - actionEnable("GroupChat", true); - actionEnable("Disconnect", true); - actionEnable("RegPass", true); - actionEnable("RegCancel", true); - DOMString title = "Pedro - "; - title.append(client.getJid()); - set_title(title); + handleConnectEvent(); break; } case XmppEvent::EVENT_DISCONNECTED: { - status("##### DISCONNECTED"); - actionEnable("Connect", true); - actionEnable("Chat", false); - actionEnable("GroupChat", false); - actionEnable("Disconnect", false); - actionEnable("RegPass", false); - actionEnable("RegCancel", false); - DOMString title = "Pedro"; - set_title(title); - chatDeleteAll(); - groupChatDeleteAll(); + handleDisconnectEvent(); break; } case XmppEvent::EVENT_MESSAGE: @@ -1958,6 +1984,19 @@ void PedroGui::doEvent(const XmppEvent &event) event.getTo().c_str(), event.getFrom().c_str()); break; } + case XmppEvent::EVENT_REGISTRATION_CHANGE_PASS: + { + status("##### PASSWORD CHANGED: %s at %s\n", + event.getTo().c_str(), event.getFrom().c_str()); + break; + } + case XmppEvent::EVENT_REGISTRATION_CANCEL: + { + //client.disconnect(); + status("##### REGISTERATION CANCELLED: %s at %s\n", + event.getTo().c_str(), event.getFrom().c_str()); + break; + } default: { printf("unknown event type: %d\n", typ); @@ -2146,7 +2185,7 @@ void PedroGui::regCancelCallback() Gtk::MessageDialog dlg(*this, "Do you want to cancel your registration on the server?", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO, true); int ret = dlg.run(); - if (ret == Gtk::RESPONSE_OK) + if (ret == Gtk::RESPONSE_YES) { client.inBandRegistrationCancel(); } diff --git a/src/pedro/pedrogui.h b/src/pedro/pedrogui.h index bee20c294..a600e6d50 100644 --- a/src/pedro/pedrogui.h +++ b/src/pedro/pedrogui.h @@ -428,6 +428,11 @@ public: DOMString getConfirm() { return confField.get_text(); } +protected: + + //Overloaded from Gtk::Dialog + virtual void on_response(int response_id); + private: void okCallback(); @@ -673,14 +678,20 @@ public: virtual ~PedroGui(); + //Let everyone share this + XmppClient client; + + virtual void error(const char *fmt, ...); virtual void status(const char *fmt, ...); - //Let everyone share this - XmppClient client; + void handleConnectEvent(); + + void handleDisconnectEvent(); + /** * */ @@ -689,7 +700,7 @@ public: /** * */ - bool PedroGui::checkEventQueue(); + bool checkEventQueue(); bool chatCreate(const DOMString &userJid); @@ -720,8 +731,6 @@ public: long size, const DOMString &hash); -private: - //# File menu void connectCallback(); @@ -744,6 +753,8 @@ private: //# Help menu void aboutCallback(); +private: + bool doSetup(); Gtk::VBox mainBox; diff --git a/src/pedro/pedroxmpp.cpp b/src/pedro/pedroxmpp.cpp index 7160a09bd..92fa2f9a1 100644 --- a/src/pedro/pedroxmpp.cpp +++ b/src/pedro/pedroxmpp.cpp @@ -3405,7 +3405,7 @@ bool XmppClient::inBandRegistrationChangePassword(const DOMString &newpassword) //# Let's try it form-style to allow the common old/new password thing char *fmt = - "" + "" " " " " " " @@ -3442,7 +3442,7 @@ bool XmppClient::inBandRegistrationCancel() Parser parser; char *fmt = - "" + "" "" "\n\n"; if (!write(fmt, msgId++, jid.c_str())) -- 2.30.2