1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-11 00:24:12 +02:00

Check for a valid xmpp id in the config widget

This commit is contained in:
Dominik Schmidt
2013-01-23 20:56:01 +01:00
parent 4ebec06484
commit 643dda78dc
3 changed files with 39 additions and 4 deletions

View File

@@ -33,10 +33,11 @@ namespace Tomahawk
namespace Accounts namespace Accounts
{ {
XmppConfigWidget::XmppConfigWidget( XmppAccount* account, QWidget *parent ) : XmppConfigWidget::XmppConfigWidget( XmppAccount* account, QWidget *parent )
AccountConfigWidget( parent ), : AccountConfigWidget( parent )
m_ui( new Ui::XmppConfigWidget ), , m_ui( new Ui::XmppConfigWidget )
m_account( account ) , m_account( account )
, m_disableChecksForGoogle( false )
{ {
m_ui->setupUi( this ); m_ui->setupUi( this );
@@ -109,6 +110,35 @@ XmppConfigWidget::onCheckJidExists( QString jid )
} }
void
XmppConfigWidget::checkForErrors()
{
const QString username = m_ui->xmppUsername->text().trimmed();
const QStringList usernameParts = username.split( '@', QString::KeepEmptyParts );
QString errorMessage;
if( username.isEmpty() )
{
errorMessage.append( tr( "You forgot to enter your username!" ) );
}
//HACK: don't check for xmpp id being an "email address"
if( !m_disableChecksForGoogle )
{
if( usernameParts.count() != 2 || usernameParts.at( 0 ).isEmpty() || ( usernameParts.count() == 2 && usernameParts.at( 1 ).isEmpty() ) )
{
errorMessage.append( tr( "Your Xmpp Id should look like an email address" ) );
}
}
if( !errorMessage.isEmpty() )
{
errorMessage.append( tr( "\n\nExample:\nusername@jabber.org" ) );
m_errors.append( errorMessage );
}
}
} }
} }

View File

@@ -49,6 +49,8 @@ public:
void saveConfig(); void saveConfig();
virtual void checkForErrors();
signals: signals:
void dataError( bool exists ); void dataError( bool exists );
@@ -59,6 +61,8 @@ private:
Ui::XmppConfigWidget *m_ui; Ui::XmppConfigWidget *m_ui;
XmppAccount *m_account; XmppAccount *m_account;
bool m_disableChecksForGoogle;
friend class GoogleWrapper; // So google wrapper can modify the labels and text friend class GoogleWrapper; // So google wrapper can modify the labels and text
}; };

View File

@@ -85,6 +85,7 @@ GoogleWrapper::GoogleWrapper ( const QString& pluginID )
: XmppAccount ( pluginID ) : XmppAccount ( pluginID )
{ {
XmppConfigWidget* config = static_cast< XmppConfigWidget* >( m_configWidget.data() ); XmppConfigWidget* config = static_cast< XmppConfigWidget* >( m_configWidget.data() );
config->m_disableChecksForGoogle = true;
config->m_ui->headerLabel->setText( tr( "Configure this Google Account" ) ); config->m_ui->headerLabel->setText( tr( "Configure this Google Account" ) );
config->m_ui->emailLabel->setText( tr( "Google Address:" ) ); config->m_ui->emailLabel->setText( tr( "Google Address:" ) );
config->m_ui->xmppBlurb->setText( tr( "Enter your Google login to connect with your friends using Tomahawk!" ) ); config->m_ui->xmppBlurb->setText( tr( "Enter your Google login to connect with your friends using Tomahawk!" ) );