X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fui%2Fdialog%2Fwhiteboard-connect.cpp;h=ae291c03d74aa09e9a17662a4448e42c2899285c;hb=ba885512446fff2803585a4aaec34e7742841f05;hp=173e9a79417558148f2c579702b1046118e7b852;hpb=6b15695578f07a3f72c4c9475c1a261a3021472a;p=inkscape.git
diff --git a/src/ui/dialog/whiteboard-connect.cpp b/src/ui/dialog/whiteboard-connect.cpp
index 173e9a794..ae291c03d 100644
--- a/src/ui/dialog/whiteboard-connect.cpp
+++ b/src/ui/dialog/whiteboard-connect.cpp
@@ -41,10 +41,12 @@ WhiteboardConnectDialog::create()
}
WhiteboardConnectDialogImpl::WhiteboardConnectDialogImpl() :
- _layout(4, 4, false), _usessl(_("_Use SSL"), true)
+ _layout(4, 4, false), _usessl(_("_Use SSL"), true), _register(_("_Register"), true)
{
this->setSessionManager();
this->_construct();
+ //this->set_resize_mode(Gtk::RESIZE_IMMEDIATE);
+ this->set_resizable(false);
this->get_vbox()->show_all_children();
}
@@ -52,12 +54,16 @@ WhiteboardConnectDialogImpl::~WhiteboardConnectDialogImpl()
{
}
+void WhiteboardConnectDialogImpl::present()
+{
+ Dialog::present();
+}
+
void
WhiteboardConnectDialogImpl::setSessionManager()
{
- this->_desktop = SP_ACTIVE_DESKTOP;
- this->_sm = SP_ACTIVE_DESKTOP->whiteboard_session_manager();
-
+ this->_desktop = this->getDesktop();
+ this->_sm = this->_desktop->whiteboard_session_manager();
}
void
@@ -76,19 +82,26 @@ WhiteboardConnectDialogImpl::_construct()
this->_labels[2].set_mnemonic_widget(this->_password);
this->_labels[3].set_mnemonic_widget(this->_port);
- this->_port.set_text("5222");
+ this->_server.set_text(prefs_get_string_attribute("whiteboard.server", "name"));
+ this->_port.set_text(prefs_get_string_attribute("whiteboard.server", "port"));
+ this->_username.set_text(prefs_get_string_attribute("whiteboard.server", "username"));
+ this->_usessl.set_active((prefs_get_int_attribute("whiteboard.server", "ssl", 0) == 1) ? true : false);
this->_layout.attach(this->_labels[0], 0, 1, 0, 1);
- this->_layout.attach(this->_labels[3], 2, 3, 0, 1);
this->_layout.attach(this->_labels[1], 0, 1, 1, 2);
this->_layout.attach(this->_labels[2], 0, 1, 2, 3);
+ this->_layout.attach(this->_labels[3], 2, 3, 0, 1);
this->_layout.attach(this->_server, 1, 2, 0, 1);
this->_layout.attach(this->_port, 3, 4, 0, 1);
this->_layout.attach(this->_username, 1, 4, 1, 2);
this->_layout.attach(this->_password, 1, 4, 2, 3);
- this->_layout.attach(this->_usessl, 1, 4, 3, 4);
+ this->_checkboxes.attach(this->_blank,0,1,0,1);
+ this->_checkboxes.attach(this->_blank,0,1,1,2);
+
+ this->_checkboxes.attach(this->_usessl, 1, 4, 0, 1);
+ this->_checkboxes.attach(this->_register, 1, 5, 1, 2);
this->_layout.set_col_spacings(1);
this->_layout.set_row_spacings(1);
@@ -99,22 +112,91 @@ WhiteboardConnectDialogImpl::_construct()
// Buttons
this->_ok.set_label(_("Connect"));
this->_cancel.set_label(_("Cancel"));
+
this->_ok.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &WhiteboardConnectDialogImpl::_respCallback), GTK_RESPONSE_OK));
this->_cancel.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &WhiteboardConnectDialogImpl::_respCallback), GTK_RESPONSE_CANCEL));
+
+ this->_register.signal_clicked().connect(sigc::mem_fun(*this, &WhiteboardConnectDialogImpl::_registerCallback));
this->_usessl.signal_clicked().connect(sigc::mem_fun(*this, &WhiteboardConnectDialogImpl::_useSSLClickedCallback));
this->_buttons.pack_start(this->_cancel, true, true, 0);
this->_buttons.pack_end(this->_ok, true, true, 0);
-
+
// Pack widgets into main vbox
- main->pack_start(this->_layout);
- main->pack_end(this->_buttons);
+ main->pack_start(this->_layout,Gtk::PACK_SHRINK);
+ main->pack_start(this->_checkboxes,Gtk::PACK_SHRINK);
+ main->pack_end(this->_buttons,Gtk::PACK_SHRINK);
+}
+
+
+void
+WhiteboardConnectDialogImpl::_registerCallback()
+{
+ if (this->_register.get_active())
+ {
+ Glib::ustring server, port;
+ bool usessl;
+
+ server = this->_server.get_text();
+ port = this->_port.get_text();
+ usessl = this->_usessl.get_active();
+
+ Glib::ustring msg = String::ucompose(_("Establishing connection to Jabber server %1"), server);
+ this->_desktop->messageStack()->flash(INFORMATION_MESSAGE, msg.data());
+
+ if(this->_sm->initializeConnection(server,port,usessl) == CONNECT_SUCCESS)
+ {
+
+ std::vector entries = this->_sm->getRegistrationInfo();
+
+ for(unsigned i = 0; i_layout.attach (*label, 0, 1, i+3, i+4, Gtk::FILL|Gtk::EXPAND|Gtk::SHRINK, (Gtk::AttachOptions)0,0,0);
+ this->_layout.attach (*entry, 1, 4, i+3, i+4, Gtk::FILL|Gtk::EXPAND|Gtk::SHRINK, (Gtk::AttachOptions)0,0,0);
+
+ this->registerlabels.push_back(label);
+ this->registerentries.push_back(entry);
+ }
+ }else{
+ Glib::ustring msg = String::ucompose(_("Failed to establish connection to Jabber server %1"), server);
+ this->_desktop->messageStack()->flash(WARNING_MESSAGE, msg.data());
+ this->_sm->connectionError(msg);
+ }
+
+ }else{
+
+ for(unsigned i = 0; i_layout.remove(*registerlabels[i]);
+ this->_layout.remove(*registerentries[i]);
+
+ delete registerlabels[i];
+ delete registerentries[i];
+ }
+
+ registerentries.erase(registerentries.begin(), registerentries.end());
+ registerlabels.erase(registerlabels.begin(), registerlabels.end());
+ }
+
+ this->get_vbox()->show_all_children();
+ //this->reshow_with_initial_size();
}
void
WhiteboardConnectDialogImpl::_respCallback(int resp)
{
- if (resp == GTK_RESPONSE_OK) {
+ if (resp == GTK_RESPONSE_OK)
+ {
Glib::ustring server, port, username, password;
bool usessl;
@@ -127,32 +209,73 @@ WhiteboardConnectDialogImpl::_respCallback(int resp)
Glib::ustring msg = String::ucompose(_("Establishing connection to Jabber server %1 as user %2"), server, username);
this->_desktop->messageStack()->flash(INFORMATION_MESSAGE, msg.data());
- switch (this->_sm->connectToServer(server, port, username, password, usessl)) {
- case FAILED_TO_CONNECT:
- msg = String::ucompose(_("Failed to establish connection to Jabber server %1"), server);
- this->_desktop->messageStack()->flash(WARNING_MESSAGE, msg.data());
- this->_sm->connectionError(msg);
- break;
- case INVALID_AUTH:
- msg = String::ucompose(_("Authentication failed on Jabber server %1 as %2"), server, username);
- this->_desktop->messageStack()->flash(WARNING_MESSAGE, msg.data());
- this->_sm->connectionError(msg);
- break;
- case SSL_INITIALIZATION_ERROR:
- msg = String::ucompose(_("SSL initialization failed when connecting to Jabber server %1"), server);
- this->_desktop->messageStack()->flash(WARNING_MESSAGE, msg.data());
- this->_sm->connectionError(msg);
- break;
-
- case CONNECT_SUCCESS:
- msg = String::ucompose(_("Connected to Jabber server %1 as %2"), server, username);
- this->_desktop->messageStack()->flash(INFORMATION_MESSAGE, msg.data());
-
- // Save preferences
- prefs_set_string_attribute(this->_prefs_path, "server", this->_server.get_text().c_str());
- break;
- default:
- break;
+ if (!this->_register.get_active())
+ {
+ switch (this->_sm->connectToServer(server, port, username, password, usessl)) {
+ case FAILED_TO_CONNECT:
+ msg = String::ucompose(_("Failed to establish connection to Jabber server %1"), server);
+ this->_desktop->messageStack()->flash(WARNING_MESSAGE, msg.data());
+ this->_sm->connectionError(msg);
+ break;
+ case INVALID_AUTH:
+ msg = String::ucompose(_("Authentication failed on Jabber server %1 as %2"), server, username);
+ this->_desktop->messageStack()->flash(WARNING_MESSAGE, msg.data());
+ this->_sm->connectionError(msg);
+ break;
+ case SSL_INITIALIZATION_ERROR:
+ msg = String::ucompose(_("SSL initialization failed when connecting to Jabber server %1"), server);
+ this->_desktop->messageStack()->flash(WARNING_MESSAGE, msg.data());
+ this->_sm->connectionError(msg);
+ break;
+
+ case CONNECT_SUCCESS:
+ msg = String::ucompose(_("Connected to Jabber server %1 as %2"), server, username);
+ this->_desktop->messageStack()->flash(INFORMATION_MESSAGE, msg.data());
+
+ // Save preferences
+ prefs_set_string_attribute(this->_prefs_path, "server", this->_server.get_text().c_str());
+ break;
+ default:
+ break;
+ }
+ }else{
+
+ std::vector key,val;
+
+ for(unsigned i = 0; i_sm->registerWithServer(username, password, key, val))
+ {
+ case FAILED_TO_CONNECT:
+ msg = String::ucompose(_("Failed to establish connection to Jabber server %1"), server);
+ this->_desktop->messageStack()->flash(WARNING_MESSAGE, msg.data());
+ this->_sm->connectionError(msg);
+ break;
+ case INVALID_AUTH:
+ msg = String::ucompose(_("Registration failed on Jabber server %1 as %2"), server, username);
+ this->_desktop->messageStack()->flash(WARNING_MESSAGE, msg.data());
+ this->_sm->connectionError(msg);
+ break;
+ case SSL_INITIALIZATION_ERROR:
+ msg = String::ucompose(_("SSL initialization failed when connecting to Jabber server %1"), server);
+ this->_desktop->messageStack()->flash(WARNING_MESSAGE, msg.data());
+ this->_sm->connectionError(msg);
+ break;
+
+ case CONNECT_SUCCESS:
+ msg = String::ucompose(_("Connected to Jabber server %1 as %2"), server, username);
+ this->_desktop->messageStack()->flash(INFORMATION_MESSAGE, msg.data());
+
+ // Save preferences
+ prefs_set_string_attribute(this->_prefs_path, "server", this->_server.get_text().c_str());
+ break;
+ default:
+ break;
+ }
}
}