Commit 1b16f421 authored by Pali Rohár's avatar Pali Rohár
Browse files

Add support for disable overriding jabber host & port when registring new jabber account

This is needed for all modern jabber servers, so override option is disabled by default
After this patch registring new jabber accounts should work again

BUG: 314641
parent 3d333844
<ui version="4.0" >
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DlgJabberRegisterAccount</class>
<widget class="QWidget" name="DlgJabberRegisterAccount" >
<property name="geometry" >
<widget class="QWidget" name="DlgJabberRegisterAccount">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
......@@ -9,147 +10,153 @@
<height>350</height>
</rect>
</property>
<property name="minimumSize" >
<property name="minimumSize">
<size>
<width>300</width>
<height>350</height>
</size>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string>Register Account - Jabber</string>
</property>
<layout class="QGridLayout" >
<property name="leftMargin" >
<layout class="QGridLayout">
<property name="margin">
<number>11</number>
</property>
<property name="topMargin" >
<number>11</number>
</property>
<property name="rightMargin" >
<number>11</number>
</property>
<property name="bottomMargin" >
<number>11</number>
</property>
<property name="horizontalSpacing" >
<property name="spacing">
<number>6</number>
</property>
<property name="verticalSpacing" >
<number>6</number>
</property>
<item row="1" column="1" >
<widget class="QLabel" name="lblJID" >
<property name="text" >
<string>Desired Jabber &amp;ID:</string>
<item row="0" column="2">
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="buddy" >
<cstring>leJID</cstring>
<property name="margin">
<number>0</number>
</property>
</widget>
<item>
<widget class="QLineEdit" name="leJID">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="KPushButton" name="btnChooseServer">
<property name="text">
<string>C&amp;hoose...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="pixPasswordVerify" >
<property name="minimumSize" >
<size>
<width>16</width>
<height>16</height>
</size>
<item row="8" column="2">
<widget class="KIntSpinBox" name="sbPort">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize" >
<size>
<width>32767</width>
<height>32767</height>
</size>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
<item row="0" column="2" >
<layout class="QHBoxLayout" >
<property name="spacing" >
<item row="9" column="0" colspan="3">
<layout class="QVBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="leServer" >
<property name="text" >
<widget class="QLabel" name="lblJIDInformation">
<property name="minimumSize">
<size>
<width>0</width>
<height>100</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="KPushButton" name="btnChooseServer" >
<property name="text" >
<string>C&amp;hoose...</string>
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>16</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="lblStatusMessage">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="1" >
<widget class="QLabel" name="lblPassword" >
<property name="text" >
<string>Pass&amp;word:</string>
<item row="0" column="1">
<widget class="QLabel" name="lblJID">
<property name="text">
<string>Desired Jabber &amp;ID:</string>
</property>
<property name="buddy" >
<cstring>lePassword</cstring>
<property name="buddy">
<cstring>leJID</cstring>
</property>
</widget>
</item>
<item row="4" column="2" >
<widget class="KIntSpinBox" name="sbPort" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="2" column="1">
<widget class="QLabel" name="lblPassword">
<property name="text">
<string>Pass&amp;word:</string>
</property>
<property name="maximum" >
<number>65535</number>
<property name="buddy">
<cstring>lePassword</cstring>
</property>
</widget>
</item>
<item row="5" column="1" colspan="2" >
<widget class="QCheckBox" name="cbUseSSL" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Check this box to enable legacy SSL encrypted communication with the server. This is needed only for old servers.</string>
</property>
<property name="whatsThis" >
<string>Check this box to enable legacy SSL encrypted communication with the server. This is needed only for old servers.</string>
</property>
<property name="text" >
<string>Use legacy SSL encr&amp;yption</string>
</property>
<property name="checked" >
<bool>false</bool>
<item row="2" column="2">
<widget class="KLineEdit" name="lePassword">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="pixJID" >
<property name="minimumSize" >
<item row="2" column="0">
<widget class="QLabel" name="pixPassword">
<property name="minimumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="maximumSize" >
<property name="maximumSize">
<size>
<width>32767</width>
<height>32767</height>
......@@ -157,45 +164,28 @@
</property>
</widget>
</item>
<item row="4" column="1" >
<widget class="QLabel" name="lblPort" >
<property name="text" >
<string>&amp;Port:</string>
</property>
<property name="buddy" >
<cstring>sbPort</cstring>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QLabel" name="lblPasswordVerify" >
<property name="enabled" >
<item row="3" column="1">
<widget class="QLabel" name="lblPasswordVerify">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text" >
<property name="text">
<string>&amp;Repeat password:</string>
</property>
<property name="buddy" >
<property name="buddy">
<cstring>lePasswordVerify</cstring>
</property>
</widget>
</item>
<item row="2" column="2" >
<widget class="KLineEdit" name="lePassword" >
<property name="echoMode" >
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="pixServer" >
<property name="minimumSize" >
<item row="3" column="0">
<widget class="QLabel" name="pixPasswordVerify">
<property name="minimumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="maximumSize" >
<property name="maximumSize">
<size>
<width>32767</width>
<height>32767</height>
......@@ -203,25 +193,48 @@
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLabel" name="lblServer" >
<property name="text" >
<string>Jabber &amp;server:</string>
<item row="3" column="2">
<widget class="KLineEdit" name="lePasswordVerify">
<property name="enabled">
<bool>true</bool>
</property>
<property name="buddy" >
<cstring>leServer</cstring>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QLineEdit" name="leServer">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLabel" name="lblPort">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Port:</string>
</property>
<property name="buddy">
<cstring>sbPort</cstring>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="pixPassword" >
<property name="minimumSize" >
<item row="0" column="0">
<widget class="QLabel" name="pixJID">
<property name="minimumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="maximumSize" >
<property name="maximumSize">
<size>
<width>32767</width>
<height>32767</height>
......@@ -229,95 +242,57 @@
</property>
</widget>
</item>
<item row="3" column="2" >
<widget class="KLineEdit" name="lePasswordVerify" >
<property name="enabled" >
<bool>true</bool>
<item row="7" column="1">
<widget class="QLabel" name="lblServer">
<property name="enabled">
<bool>false</bool>
</property>
<property name="echoMode" >
<enum>QLineEdit::Password</enum>
<property name="text">
<string>&amp;Server:</string>
</property>
</widget>
</item>
<item row="1" column="2" >
<widget class="QLineEdit" name="leJID" >
<property name="text" >
<string/>
<property name="buddy">
<cstring>leServer</cstring>
</property>
</widget>
</item>
<item row="6" column="0" colspan="3" >
<layout class="QVBoxLayout" >
<property name="spacing" >
<number>6</number>
<item row="5" column="1" colspan="2">
<widget class="QCheckBox" name="cbUseSSL">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="leftMargin" >
<number>0</number>
<property name="toolTip">
<string>Check this box to enable legacy SSL encrypted communication with the server. This is needed only for old servers.</string>
</property>
<property name="topMargin" >
<number>0</number>
<property name="whatsThis">
<string>Check this box to enable legacy SSL encrypted communication with the server. This is needed only for old servers.</string>
</property>
<property name="rightMargin" >
<number>0</number>
<property name="text">
<string>Use legacy SSL encr&amp;yption</string>
</property>
<property name="bottomMargin" >
<number>0</number>
<property name="checked">
<bool>false</bool>
</property>
<item>
<widget class="QLabel" name="lblJIDInformation" >
<property name="minimumSize" >
<size>
<width>0</width>
<height>100</height>
</size>
</property>
<property name="text" >
<string/>
</property>
<property name="alignment" >
<set>Qt::AlignVCenter</set>
</property>
<property name="wordWrap" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>16</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="lblStatusMessage" >
<property name="text" >
<string/>
</property>
<property name="alignment" >
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="6" column="1" colspan="2">
<widget class="QCheckBox" name="cbOverrideHost">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Override default server information</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KIntSpinBox</class>
<extends>QSpinBox</extends>
<header>knuminput.h</header>
</customwidget>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
......@@ -328,11 +303,15 @@
<extends>QPushButton</extends>
<header>kpushbutton.h</header>
</customwidget>
<customwidget>
<class>KIntSpinBox</class>
<extends>QSpinBox</extends>
<header>knuminput.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>leServer</tabstop>
<tabstop>btnChooseServer</tabstop>
<tabstop>leJID</tabstop>
<tabstop>btnChooseServer</tabstop>
<tabstop>lePassword</tabstop>
<tabstop>lePasswordVerify</tabstop>
</tabstops>
......
......@@ -82,14 +82,17 @@ JabberRegisterAccount::JabberRegisterAccount ( JabberEditAccountWidget *parent )
mSuccess = false;
// get all settings from the main dialog
mMainWidget->leServer->setText ( parent->mServer->text () );
mMainWidget->leJID->setText ( parent->mID->text () );
mMainWidget->lePassword->setText ( parent->mPass->password () );
mMainWidget->lePassword->setPasswordMode ( true );
// mMainWidget->lePasswordVerify->setText ( parent->mPass->password () ); //BUG 114631
mMainWidget->lePasswordVerify->setPasswordMode ( true );
mMainWidget->sbPort->setValue ( parent->mPort->value () );
mMainWidget->cbUseSSL->setChecked ( parent->cbUseSSL->isChecked () );
mMainWidget->cbOverrideHost->setChecked ( parent->cbCustomServer->isChecked () );
mMainWidget->leServer->setText ( parent->mServer->text () );
mMainWidget->sbPort->setValue ( parent->mPort->value () );
slotOverrideHostToggled();
connect ( this, SIGNAL (okClicked()), this, SLOT(slotOk()) );
connect ( this, SIGNAL (cancelClicked()), this, SLOT (slotDeleteDialog()) );
......@@ -97,6 +100,7 @@ JabberRegisterAccount::JabberRegisterAccount ( JabberEditAccountWidget *parent )
connect ( mMainWidget->leServer, SIGNAL (textChanged(QString)), this, SLOT (slotJIDInformation()) );
connect ( mMainWidget->leJID, SIGNAL (textChanged(QString)), this, SLOT (slotJIDInformation()) );
connect ( mMainWidget->cbUseSSL, SIGNAL (toggled(bool)), this, SLOT (slotSSLToggled()) );
connect ( mMainWidget->cbOverrideHost, SIGNAL (toggled(bool)), this, SLOT (slotOverrideHostToggled()) );
connect ( mMainWidget->leServer, SIGNAL (textChanged(QString)), this, SLOT (validateData()) );
connect ( mMainWidget->leJID, SIGNAL (textChanged(QString)), this, SLOT (validateData()) );
......@@ -135,20 +139,15 @@ void JabberRegisterAccount::validateData ()
bool valid = true;
bool passwordHighlight = false;
if ( mMainWidget->leServer->text().isEmpty () )
if ( mMainWidget->cbOverrideHost->isChecked () && mMainWidget->leServer->text().isEmpty () )
{
mMainWidget->lblStatusMessage->setText ( i18n ( "Please enter a server name, or click Choose." ) );
mMainWidget->pixServer->setPixmap ( hintPixmap );
mMainWidget->lblStatusMessage->setText ( i18n ( "Please enter a server name." ) );
valid = false;
}
else
{
mMainWidget->pixServer->setText ( "" );
}
if ( valid && !jidRegExp.exactMatch ( mMainWidget->leJID->text() ) )
{
mMainWidget->lblStatusMessage->setText ( i18n ( "Please enter a valid Jabber ID." ) );
mMainWidget->lblStatusMessage->setText ( i18n ( "Please enter a valid Jabber ID or click Choose." ) );
mMainWidget->pixJID->setPixmap ( hintPixmap );
valid = false;
}
......@@ -198,7 +197,7 @@ void JabberRegisterAccount::slotJIDInformation ()
if ( !mMainWidget->leServer->text().isEmpty () &&
( !jidRegExp.exactMatch ( mMainWidget->leJID->text () ) ||
( mMainWidget->leJID->text().section ( '@', 1 ) != mMainWidget->leServer->text () ) ) )
( mMainWidget->cbOverrideHost->isChecked () && mMainWidget->leJID->text().section ( '@', 1 ) != mMainWidget->leServer->text () ) ) )
{
mMainWidget->lblJIDInformation->setText ( i18n ( "Unless you know what you are doing, your JID should be of the form "
"\"username@server.com\". In your case for example \"username@%1\"." ,
......@@ -231,6 +230,19 @@ void JabberRegisterAccount::slotSSLToggled ()
}
void JabberRegisterAccount::slotOverrideHostToggled()
{
bool overrideHost = mMainWidget->cbOverrideHost->isChecked ();
mMainWidget->leServer->setEnabled ( overrideHost );
mMainWidget->sbPort->setEnabled ( overrideHost );
mMainWidget->lblServer->setEnabled ( overrideHost );
mMainWidget->lblPort->setEnabled ( overrideHost );
slotJIDInformation();
validateData();
}
void JabberRegisterAccount::slotChooseServer ()
{
......@@ -260,13 +272,18 @@ void JabberRegisterAccount::slotOk ()
// cancel any previous attempt
jabberClient->disconnect ();
// FIXME: we need to use the old protocol for now
jabberClient->setUseXMPP09 ( true );
jabberClient->setUseSSL ( mMainWidget->cbUseSSL->isChecked () );
// FIXME: check this when using the new protocol
jabberClient->setOverrideHost ( true, mMainWidget->leServer->text (), mMainWidget->sbPort->value () );
if ( mMainWidget->cbOverrideHost->isChecked () )
{
jabberClient->setUseXMPP09 ( true );
jabberClient->setOverrideHost ( true, mMainWidget->leServer->text (), mMainWidget->sbPort->value () );