From: ishmal Date: Sun, 28 May 2006 23:03:10 +0000 (+0000) Subject: Add code to generate and display an SSL-connection event with a padlock X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=eb064b0a45987edcaa468ed8e300efe8d0677a77;p=inkscape.git Add code to generate and display an SSL-connection event with a padlock --- diff --git a/src/pedro/pedrogui.cpp b/src/pedro/pedrogui.cpp index d5df2f5d7..eb02c3e56 100644 --- a/src/pedro/pedrogui.cpp +++ b/src/pedro/pedrogui.cpp @@ -1148,8 +1148,8 @@ bool ConnectDialog::doSetup() table.resize(6, 2); get_vbox()->pack_start(table); - parent.client.setHost("gristle.org"); - parent.client.setPort(5223); + parent.client.setHost("broadway.dynalias.com"); + parent.client.setPort(5222); parent.client.setUsername(""); parent.client.setPassword(""); parent.client.setResource("pedroXmpp"); @@ -1856,6 +1856,24 @@ bool PedroGui::groupChatPresence(const DOMString &groupJid, //# EVENTS //################################ +/** + * + */ +void PedroGui::padlockEnable() +{ + padlockIcon.set(Gtk::Stock::DIALOG_AUTHENTICATION, + Gtk::ICON_SIZE_MENU); +} + +/** + * + */ +void PedroGui::padlockDisable() +{ + padlockIcon.clear(); +} + + /** * */ @@ -1886,6 +1904,7 @@ void PedroGui::handleDisconnectEvent() actionEnable("Disconnect", false); actionEnable("RegPass", false); actionEnable("RegCancel", false); + padlockDisable(); DOMString title = "Pedro"; set_title(title); chatDeleteAll(); @@ -1912,6 +1931,12 @@ void PedroGui::doEvent(const XmppEvent &event) { //printf("##### ERROR: %s\n", event.getData().c_str()); error(event.getData().c_str()); + padlockDisable(); + break; + } + case XmppEvent::EVENT_SSL_STARTED: + { + padlockEnable(); break; } case XmppEvent::EVENT_CONNECTED: @@ -2105,6 +2130,8 @@ void PedroGui::connectCallback() } } + + void PedroGui::chatCallback() { ChatDialog dialog(*this); @@ -2116,6 +2143,8 @@ void PedroGui::chatCallback() } } + + void PedroGui::groupChatCallback() { GroupChatDialog dialog(*this); @@ -2135,16 +2164,19 @@ void PedroGui::groupChatCallback() client.groupChatJoin(groupJid, dialog.getNick(), dialog.getPass() ); } + void PedroGui::disconnectCallback() { client.disconnect(); } + void PedroGui::quitCallback() { Gtk::Main::quit(); } + void PedroGui::fontCallback() { Gtk::FontSelectionDialog dlg; @@ -2191,11 +2223,15 @@ void PedroGui::regCancelCallback() } } + + void PedroGui::sendFileCallback() { doSendFile(""); } + + void PedroGui::aboutCallback() { Gtk::AboutDialog dlg; @@ -2209,11 +2245,19 @@ void PedroGui::aboutCallback() dlg.run(); } + + void PedroGui::actionEnable(const DOMString &name, bool val) { - DOMString path = "/ui/MenuBar/MenuFile/"; + DOMString path = "/ui/MenuBar/"; path.append(name); Glib::RefPtr action = uiManager->get_action(path); + if (!action) + { + path = "/ui/MenuBar/MenuFile/"; + path.append(name); + action = uiManager->get_action(path); + } if (!action) { path = "/ui/MenuBar/MenuEdit/"; @@ -2244,9 +2288,11 @@ void PedroGui::actionEnable(const DOMString &name, bool val) } + + bool PedroGui::doSetup() { - set_title("Inkscape XMPP (Inkboard)"); + set_title("Pedro XMPP Client"); set_size_request(500, 300); add(mainBox); @@ -2340,7 +2386,12 @@ bool PedroGui::doSetup() uiManager->add_ui_from_string(ui_info); Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar"); - mainBox.pack_start(*pMenuBar, Gtk::PACK_SHRINK); + menuBarBox.pack_start(*pMenuBar, Gtk::PACK_SHRINK); + + padlockDisable(); + menuBarBox.pack_end(padlockIcon, Gtk::PACK_SHRINK); + + mainBox.pack_start(menuBarBox, Gtk::PACK_SHRINK); actionEnable("Connect", true); actionEnable("Chat", false); diff --git a/src/pedro/pedrogui.h b/src/pedro/pedrogui.h index a600e6d50..b4655bec1 100644 --- a/src/pedro/pedrogui.h +++ b/src/pedro/pedrogui.h @@ -759,6 +759,13 @@ private: Gtk::VBox mainBox; + Gtk::HBox menuBarBox; + + Gtk::Image padlockIcon; + void padlockEnable(); + void padlockDisable(); + + Pango::FontDescription fontDesc; Gdk::Color foregroundColor; Gdk::Color backgroundColor; diff --git a/src/pedro/pedroxmpp.cpp b/src/pedro/pedroxmpp.cpp index 92fa2f9a1..1f137850f 100644 --- a/src/pedro/pedroxmpp.cpp +++ b/src/pedro/pedroxmpp.cpp @@ -632,7 +632,7 @@ public: static void hash(unsigned char *dataIn, unsigned long len, unsigned char *digest); - static DOMString Md5::hashHex(unsigned char *dataIn, unsigned long len); + static DOMString hashHex(unsigned char *dataIn, unsigned long len); /** * Initialize the context (also zeroizes contents) @@ -3866,6 +3866,9 @@ bool XmppClient::saslAuthenticate() recbuf = readStanza(); status("RECV: '%s'\n", recbuf.c_str()); elem = parser.parse(recbuf); + + XmppEvent event(XmppEvent::EVENT_SSL_STARTED); + dispatchXmppEvent(event); } //register, if user requests @@ -3966,6 +3969,12 @@ bool XmppClient::createSession() return false; } + if (sock->getEnableSSL()) + { + XmppEvent event(XmppEvent::EVENT_SSL_STARTED); + dispatchXmppEvent(event); + } + char *fmt = "\n"; - if (!write(fmt, jid.c_str(), groupJid.c_str(), user.c_str(), xmlPresence.c_str())) + if (!write(fmt, jid.c_str(), groupJid.c_str(), + user.c_str(), xmlPresence.c_str())) return true; return true; } diff --git a/src/pedro/pedroxmpp.h b/src/pedro/pedroxmpp.h index d26b83b76..0e07013e6 100644 --- a/src/pedro/pedroxmpp.h +++ b/src/pedro/pedroxmpp.h @@ -132,6 +132,13 @@ public: */ static const int EVENT_DISCONNECTED = 11; + /** + * Client has begun speaking to the server in SSL. This is usually + * emitted just before EVENT_CONNECTED, since authorization has not + * yet taken place. + */ + static const int EVENT_SSL_STARTED = 12; + /** * Client has successfully registered a new account on a server. * The server is in getFrom(), the user in getTo() @@ -959,7 +966,7 @@ public: * */ virtual std::vector - XmppClient::groupChatGetUserList(const DOMString &groupJid); + groupChatGetUserList(const DOMString &groupJid); /** *