Code

Finish registration stuff
authorishmal <ishmal@users.sourceforge.net>
Wed, 24 May 2006 05:08:32 +0000 (05:08 +0000)
committerishmal <ishmal@users.sourceforge.net>
Wed, 24 May 2006 05:08:32 +0000 (05:08 +0000)
src/pedro/pedrogui.cpp
src/pedro/pedrogui.h
src/pedro/pedroxmpp.cpp

index b50791e25aece3ccafd12331645c732718210b1e..d5df2f5d71fb716698f163f1628668d35da02092 100644 (file)
@@ -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();
         }
index bee20c2947f04124e7d95e6775a1f1533d4baf94..a600e6d5011f3ae8e890dac8d50f74c7b81b913d 100644 (file)
@@ -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;
index 7160a09bd59d4ff09ed131b26d393b88e510ce95..92fa2f9a1a79e923adfa968bd01dd667c08f9f18 100644 (file)
@@ -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 =
-      "<iq type='set' from='%s' to='%s' id='regpass%d'>"
+      "<iq type='set' id='regpass%d' from='%s' to='%s'>"
       "  <query xmlns='jabber:iq:register'>"
       "    <x xmlns='jabber:x:data' type='form'>"
       "      <field type='hidden' var='FORM_TYPE'>"
@@ -3442,7 +3442,7 @@ bool XmppClient::inBandRegistrationCancel()
     Parser parser;
 
     char *fmt =
-     "<iq type='set' from='%s' id='regcancel%d'>"
+     "<iq type='set' id='regcancel%d' from='%s'>"
           "<query xmlns='jabber:iq:register'><remove/></query>"
           "</iq>\n\n";  
     if (!write(fmt, msgId++, jid.c_str()))