diff --git a/src/accounts/xmpp/XmppConfigWidget.cpp b/src/accounts/xmpp/XmppConfigWidget.cpp index 0df3cc9d2..a6001cc90 100644 --- a/src/accounts/xmpp/XmppConfigWidget.cpp +++ b/src/accounts/xmpp/XmppConfigWidget.cpp @@ -23,7 +23,9 @@ #include "accounts/AccountManager.h" +#include "accounts/ConfigStorage.h" #include "utils/Logger.h" +#include "utils/TomahawkUtilsGui.h" #include @@ -48,9 +50,41 @@ XmppConfigWidget::XmppConfigWidget( XmppAccount* account, QWidget *parent ) m_ui->xmppPublishTracksCheckbox->setChecked( account->configuration().contains( "publishtracks" ) ? account->configuration()[ "publishtracks" ].toBool() : true); m_ui->xmppEnforceSecureCheckbox->setChecked( account->configuration().contains( "enforcesecure" ) ? account->configuration()[ "enforcesecure" ].toBool() : false); m_ui->jidExistsLabel->hide(); + m_ui->xmppConfigFrame->hide(); connect( m_ui->xmppUsername, SIGNAL( textChanged( QString ) ), SLOT( onCheckJidExists( QString ) ) ); + + if ( m_account->configuration()[ "read-only" ].toBool() ) + { + m_ui->xmppUsername->setEnabled( false ); + m_ui->xmppPassword->setEnabled( false ); + m_ui->xmppServer->setEnabled( false ); + m_ui->xmppPort->setEnabled( false ); + m_ui->xmppEnforceSecureCheckbox->setEnabled( false ); + m_ui->xmppPublishTracksCheckbox->setEnabled( false ); + } + + ConfigStorage* cs = AccountManager::instance()->configStorageForAccount( m_account->accountId() ); + if ( cs->id() != "localconfigstorage" ) + { + m_ui->xmppBlurb->hide(); + m_ui->xmppConfigFrame->show(); + m_ui->xmppConfigLabel->setText( tr( "Account provided by %1." ) + .arg( cs->prettyName() ) ); + m_ui->xmppConfigIcon->setPixmap( cs->icon().scaled( TomahawkUtils::defaultIconSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation ) ); + m_ui->xmppConfigLaunchDialog->setIcon( TomahawkUtils::defaultPixmap( TomahawkUtils::Configure ) ); + connect( m_ui->xmppConfigLaunchDialog, SIGNAL( clicked() ), + this, SLOT( launchExternalConfigDialog() ) ); + } +} + + +void +XmppConfigWidget::launchExternalConfigDialog() +{ + ConfigStorage* cs = AccountManager::instance()->configStorageForAccount( m_account->accountId() ); + cs->execConfigDialog(); } diff --git a/src/accounts/xmpp/XmppConfigWidget.h b/src/accounts/xmpp/XmppConfigWidget.h index 447b5fafb..bfdaa5da8 100644 --- a/src/accounts/xmpp/XmppConfigWidget.h +++ b/src/accounts/xmpp/XmppConfigWidget.h @@ -56,6 +56,7 @@ signals: private slots: void onCheckJidExists( const QString& jid ); + void launchExternalConfigDialog(); private: Ui::XmppConfigWidget *m_ui; diff --git a/src/accounts/xmpp/XmppConfigWidget.ui b/src/accounts/xmpp/XmppConfigWidget.ui index 8e16eaced..96eacb053 100644 --- a/src/accounts/xmpp/XmppConfigWidget.ui +++ b/src/accounts/xmpp/XmppConfigWidget.ui @@ -1,15 +1,21 @@ XmppConfigWidget - + 0 0 451 - 335 + 337 + + + 451 + 0 + + Xmpp Configuration @@ -35,7 +41,7 @@ - :/xmpp-account/xmpp-icon.png + :/xmpp-account/xmpp-icon.png @@ -69,15 +75,18 @@ - + Qt::Horizontal + + QSizePolicy::Expanding + - 40 + 0 20 @@ -85,9 +94,18 @@ + + + 0 + 0 + + Enter your Xmpp login to connect with your friends using Tomahawk! + + false + @@ -95,9 +113,12 @@ Qt::Horizontal + + QSizePolicy::Expanding + - 40 + 0 20 @@ -105,6 +126,85 @@ + + + + + + + 0 + 0 + + + + + 200 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + 0 + + + + 5 + + + 2 + + + 2 + + + 2 + + + 2 + + + + + + + + + + + + + 0 + 0 + + + + + + + true + + + + + + + Configure + + + + + + + + + + + diff --git a/src/libtomahawk/accounts/ConfigStorage.cpp b/src/libtomahawk/accounts/ConfigStorage.cpp index 8ee9fee76..07dac2233 100644 --- a/src/libtomahawk/accounts/ConfigStorage.cpp +++ b/src/libtomahawk/accounts/ConfigStorage.cpp @@ -37,5 +37,26 @@ ConfigStorage::~ConfigStorage() } +QString +ConfigStorage::prettyName() const +{ + return QString(); +} + + +QPixmap +ConfigStorage::icon() const +{ + return QPixmap(); +} + + +bool +ConfigStorage::execConfigDialog() +{ + return false; +} + + } //ns } //ns diff --git a/src/libtomahawk/accounts/ConfigStorage.h b/src/libtomahawk/accounts/ConfigStorage.h index 9f3d9e6d7..7da7a82cd 100644 --- a/src/libtomahawk/accounts/ConfigStorage.h +++ b/src/libtomahawk/accounts/ConfigStorage.h @@ -41,6 +41,11 @@ public: virtual void init() = 0; virtual QString id() const = 0; + virtual QString prettyName() const; + + virtual QPixmap icon() const; + + virtual bool execConfigDialog(); virtual QStringList accountIds() const = 0; diff --git a/src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorage.cpp b/src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorage.cpp index 3a422a47c..87b9241b9 100644 --- a/src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorage.cpp +++ b/src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorage.cpp @@ -28,6 +28,7 @@ #include #include +#include #include @@ -60,6 +61,37 @@ Tomahawk::Accounts::TelepathyConfigStorage::id() const } +QString +Tomahawk::Accounts::TelepathyConfigStorage::prettyName() const +{ + return tr( "the KDE instant messaging framework" ); +} + + +QPixmap +Tomahawk::Accounts::TelepathyConfigStorage::icon() const +{ + return QPixmap( ":/telepathy/kde.png" ); +} + + +bool +Tomahawk::Accounts::TelepathyConfigStorage::execConfigDialog() +{ + QProcess kcm; + kcm.start( "kcmshell4 kcm_ktp_accounts" ); + if ( !kcm.waitForStarted() ) + return false; + + if ( !kcm.waitForFinished( 600000 ) ) + return false; + + //TODO: this should probably be async + + return true; +} + + void Tomahawk::Accounts::TelepathyConfigStorage::onTpAccountManagerReady( Tp::PendingOperation* op ) { @@ -172,7 +204,7 @@ Tomahawk::Accounts::TelepathyConfigStorage::load( const QString& accountId, Acco Tp::AccountPtr account = m_tpam->accountForObjectPath( accountIdToTelepathyPath( accountId ) ); - cfg.accountFriendlyName = account->normalizedName(); + cfg.accountFriendlyName = "Tp:" + account->normalizedName(); cfg.enabled = true; cfg.acl = QVariantMap(); @@ -206,6 +238,8 @@ Tomahawk::Accounts::TelepathyConfigStorage::load( const QString& accountId, Acco QVariant credentials = c->credentials( m_credentialsServiceName, account->uniqueIdentifier() ); if ( credentials.type() == QVariant::String ) cfg.credentials[ "password" ] = credentials.toString(); + + cfg.configuration[ "read-only" ] = true; } diff --git a/src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorage.h b/src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorage.h index a829ee7c3..d88d65176 100644 --- a/src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorage.h +++ b/src/libtomahawk/accounts/configstorage/telepathy/TelepathyConfigStorage.h @@ -45,6 +45,10 @@ public: void init(); QString id() const; + QString prettyName() const; + QPixmap icon() const; + + bool execConfigDialog(); QStringList accountIds() const; diff --git a/src/libtomahawk/accounts/configstorage/telepathy/kde.png b/src/libtomahawk/accounts/configstorage/telepathy/kde.png new file mode 100644 index 000000000..3efaaf808 Binary files /dev/null and b/src/libtomahawk/accounts/configstorage/telepathy/kde.png differ diff --git a/src/libtomahawk/accounts/configstorage/telepathy/resources.qrc b/src/libtomahawk/accounts/configstorage/telepathy/resources.qrc new file mode 100644 index 000000000..2dd0f273e --- /dev/null +++ b/src/libtomahawk/accounts/configstorage/telepathy/resources.qrc @@ -0,0 +1,5 @@ + + + kde.png + +