void
TwitterConfigWidget::startPostGotTomahawkStatus()
{
    m_postGTtype = ui->twitterTweetComboBox->currentText();
    
    if ( m_postGTtype != "Global Tweet" && ( ui->twitterUserTweetLineEdit->text().isEmpty() || ui->twitterUserTweetLineEdit->text() == "@" ) )
    {
        QMessageBox::critical( this, tr("Tweetin' Error"), tr("You must enter a user name for this type of tweet.") );
        return;
    }
    
    qDebug() << "Posting Got Tomahawk status";
    TomahawkSettings* s = TomahawkSettings::instance();
    if ( s->twitterOAuthToken().isEmpty() || s->twitterOAuthTokenSecret().isEmpty() || s->twitterScreenName().isEmpty() )
    {
        QMessageBox::critical( this, tr("Tweetin' Error"), tr("Your saved credentials could not be loaded.\nYou may wish to try re-authenticating.") );
        emit twitterAuthed( false );
        return;
    }
    TomahawkOAuthTwitter *twitAuth = new TomahawkOAuthTwitter( this );
    twitAuth->setNetworkAccessManager( TomahawkUtils::nam() );
    twitAuth->setOAuthToken( s->twitterOAuthToken().toLatin1() );
    twitAuth->setOAuthTokenSecret( s->twitterOAuthTokenSecret().toLatin1() );
    QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( twitAuth, this );
    connect( credVerifier, SIGNAL( parsedUser(const QTweetUser &) ), SLOT( postGotTomahawkStatusAuthVerifyReply(const QTweetUser &) ) );
    credVerifier->verify();
}
void
TwitterConfigWidget::authenticateVerifyReply( const QTweetUser &user )
{
    qDebug() << Q_FUNC_INFO;
    if ( user.id() == 0 )
    {
        QMessageBox::critical( this, tr("Tweetin' Error"), tr("The credentials could not be verified.\nYou may wish to try re-authenticating.") );
        emit twitterAuthed( false );
        return;
    }

    TomahawkSettings* s = TomahawkSettings::instance();
    s->setTwitterScreenName( user.screenName() );
    s->setTwitterCachedFriendsSinceId( 0 );
    s->setTwitterCachedMentionsSinceId( 0 );
    
    ui->twitterStatusLabel->setText( tr( "Status: Credentials saved for %1" ).arg( s->twitterScreenName() ) );
    ui->twitterAuthenticateButton->setText( tr( "De-authenticate" ) );
    ui->twitterInstructionsInfoLabel->setVisible( true );
    ui->twitterGlobalTweetLabel->setVisible( true );
    ui->twitterTweetGotTomahawkButton->setVisible( true );
    ui->twitterUserTweetLineEdit->setVisible( true );
    ui->twitterTweetComboBox->setVisible( true );

    m_plugin->connectPlugin( false );
    
    emit twitterAuthed( true );
}
TwitterConfigWidget::TwitterConfigWidget(SipPlugin* plugin, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::TwitterConfigWidget),
    m_plugin(plugin)
{
    ui->setupUi(this);

    connect(ui->twitterAuthenticateButton, SIGNAL(pressed()),
            this,   SLOT(authenticateTwitter()));
    connect(ui->twitterTweetGotTomahawkButton, SIGNAL(pressed()),
            this,   SLOT(startPostGotTomahawkStatus()));


    TomahawkSettings* s = TomahawkSettings::instance();
    if ( s->twitterOAuthToken().isEmpty() || s->twitterOAuthTokenSecret().isEmpty() )
    {
        ui->twitterStatusLabel->setText("Status: No saved credentials");
        ui->twitterAuthenticateButton->setText( "Authenticate" );
        ui->twitterInstructionsBox->setVisible( false );
    }
    else
    {
        ui->twitterStatusLabel->setText("Status: Credentials saved");
        ui->twitterAuthenticateButton->setText( "Re-authenticate" );
        ui->twitterInstructionsBox->setVisible( true );
    }

}
Exemple #4
0
PlaylistUpdaterInterface*
PlaylistUpdaterInterface::loadForPlaylist( const playlist_ptr& pl )
{
    TomahawkSettings* s = TomahawkSettings::instance();
    const QString key = QString( "playlistupdaters/%1" ).arg( pl->guid() );
    if ( s->contains( QString( "%1/type" ).arg( key ) ) )
    {
        // Ok, we have one we can try to load
        const QString type = s->value( QString( "%1/type" ).arg( key ) ).toString();
        PlaylistUpdaterInterface* updater = 0;
        if ( type == "xspf" )
            updater = new XspfUpdater( pl );

        // You forgot to register your new updater type with the factory above. 00ps.
        if ( !updater )
        {
            Q_ASSERT( false );
            return 0;
        }
        updater->setAutoUpdate( s->value( QString( "%1/autoupdate" ).arg( key ) ).toBool() );
        updater->setInterval( s->value( QString( "%1/interval" ).arg( key ) ).toInt() );
        updater->loadFromSettings( key );

        return updater;
    }

    return 0;
}
Exemple #5
0
void
TomahawkWindow::addPeerManually()
{
    TomahawkSettings* s = TomahawkSettings::instance();
    bool ok;
    QString addr = QInputDialog::getText( this, tr( "Connect To Peer" ),
                                                tr( "Enter peer address:" ), QLineEdit::Normal,
                                                s->value( "connip" ).toString(), &ok ); // FIXME
    if ( !ok )
        return;

    s->setValue( "connip", addr );
    QString ports = QInputDialog::getText( this, tr( "Connect To Peer" ),
                                                 tr( "Enter peer port:" ), QLineEdit::Normal,
                                                 s->value( "connport", "50210" ).toString(), &ok );
    if ( !ok )
        return;

    s->setValue( "connport", ports );
    int port = ports.toInt();
    QString key = QInputDialog::getText( this, tr( "Connect To Peer" ),
                                               tr( "Enter peer key:" ), QLineEdit::Normal,
                                               "whitelist", &ok );
    if ( !ok )
        return;

    qDebug() << "Attempting to connect to" << addr;
    Servent::instance()->connectToPeer( addr, port, key );
}
Exemple #6
0
void
TomahawkWindow::saveSettings()
{
    TomahawkSettings* s = TomahawkSettings::instance();
    s->setMainWindowGeometry( saveGeometry() );
    s->setMainWindowState( saveState() );
    s->setMainWindowSplitterState( ui->splitter->saveState() );
}
void
PlaylistUpdaterInterface::save()
{
    TomahawkSettings* s = TomahawkSettings::instance();
    const QString key = QString( "playlistupdaters/%1" ).arg( m_playlist->guid() );
    if ( !s->contains( QString( "%1/type" ).arg( key ) ) )
    {
        s->setValue( QString( "%1/type" ).arg( key ), type() );
    }
    saveToSettings( key );
}
Exemple #8
0
void
HostDialog::saveSettings()
{
    TomahawkSettings* s = TomahawkSettings::instance();

    s->setAutoDetectExternalIp( ui->autoDetectIpCheckBox->isChecked() );
    s->setExternalHostname( ui->staticHostName->text() );
    s->setExternalPort( ui->staticPort->value() );

    s->sync();
}
void
PlaylistUpdaterInterface::remove()
{
    if ( m_playlist.isNull() )
        return;

    TomahawkSettings* s = TomahawkSettings::instance();
    const QString key = QString( "playlistupdaters/%1" ).arg( m_playlist->guid() );
    removeFromSettings( key );
    s->remove( QString( "%1/type" ).arg( key ) );

    deleteLater();
}
Exemple #10
0
TrackView::~TrackView()
{
    tDebug() << Q_FUNC_INFO << ( m_guid.isEmpty() ? QString( "with empty guid" ) : QString( "with guid %1" ).arg( m_guid ) );

    if ( !m_guid.isEmpty() && proxyModel()->playlistInterface() )
    {
        tDebug() << Q_FUNC_INFO << "Storing shuffle & random mode settings for guid" << m_guid;

        TomahawkSettings* s = TomahawkSettings::instance();
        s->setShuffleState( m_guid, proxyModel()->playlistInterface()->shuffled() );
        s->setRepeatMode( m_guid, proxyModel()->playlistInterface()->repeatMode() );
    }
}
Exemple #11
0
void
PlaylistUpdaterInterface::doSave()
{
    TomahawkSettings* s = TomahawkSettings::instance();
    const QString key = QString( "playlistupdaters/%1" ).arg( m_playlist->guid() );
    if ( !s->contains( QString( "%1/type" ).arg( key ) ) )
    {
        s->setValue( QString( "%1/type" ).arg( key ), type() );
        s->setValue( QString( "%1/autoupdate" ).arg( key ), m_autoUpdate );
        s->setValue( QString( "%1/interval" ).arg( key ), m_timer->interval() );
        saveToSettings( key );
    }
}
Exemple #12
0
void
Account::removeFromConfig()
{
    TomahawkSettings* s = TomahawkSettings::instance();
    s->beginGroup( "accounts/" + m_accountId );
    s->remove( "accountfriendlyname" );
    s->remove( "enabled" );
    s->remove( "credentials" );
    s->remove( "configuration" );
    s->remove( "acl" );
    s->remove( "types" );
    s->endGroup();
    s->remove( "accounts/" + m_accountId );
}
Exemple #13
0
HostDialog::HostDialog( QWidget* parent )
    : QDialog( parent )
    , ui( new Ui::HostDialog )
{
    ui->setupUi( this );

    TomahawkSettings* s = TomahawkSettings::instance();

    connect( ui->autoDetectIpCheckBox, SIGNAL( toggled( bool ) ),
             SLOT( toggleAutoDetectIp( bool ) ) );

    ui->staticHostName->setText( s->externalHostname() );
    ui->staticPort->setValue( s->externalPort() );
    ui->autoDetectIpCheckBox->setChecked( s->autoDetectExternalIp() );
}
Exemple #14
0
void
ViewManager::loadCurrentPlaylistSettings()
{
    TomahawkSettings* s = TomahawkSettings::instance();
    Tomahawk::playlist_ptr pl = playlistForInterface( currentPlaylistInterface() );
    if ( !pl.isNull() ) {
        currentPlaylistInterface()->setShuffled( s->shuffleState( pl->guid() ));
        currentPlaylistInterface()->setRepeatMode( s->repeatMode( pl->guid() ));
    } else {
        Tomahawk::dynplaylist_ptr dynPl = dynamicPlaylistForInterface( currentPlaylistInterface() );
        if ( !dynPl.isNull() ) {
            currentPlaylistInterface()->setShuffled( s->shuffleState( dynPl->guid() ));
        }
    }
}
void
TwitterConfigWidget::authenticateTwitter()
{
    qDebug() << Q_FUNC_INFO;
    TomahawkOAuthTwitter *twitAuth = new TomahawkOAuthTwitter( this );
    twitAuth->setNetworkAccessManager( TomahawkUtils::nam() );
    twitAuth->authorizePin();
    
    TomahawkSettings* s = TomahawkSettings::instance();
    s->setTwitterOAuthToken( twitAuth->oauthToken() );
    s->setTwitterOAuthTokenSecret( twitAuth->oauthTokenSecret() );
    
    QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( twitAuth, this );
    connect( credVerifier, SIGNAL( parsedUser( const QTweetUser & ) ), SLOT( authenticateVerifyReply( const QTweetUser & ) ) );
    connect( credVerifier, SIGNAL( error( QTweetNetBase::ErrorCode, QString ) ), SLOT( authenticateVerifyError( QTweetNetBase::ErrorCode, QString ) ) );
    credVerifier->verify();
}
TwitterConfigWidget::TwitterConfigWidget( SipPlugin* plugin, QWidget *parent ) :
    QWidget( parent ),
    ui( new Ui::TwitterConfigWidget ),
    m_plugin( plugin )
{
    ui->setupUi( this );

    connect( ui->twitterAuthenticateButton, SIGNAL( pressed() ),
            this, SLOT( authDeauthTwitter() ) );
    connect( ui->twitterTweetGotTomahawkButton, SIGNAL( pressed() ),
            this, SLOT( startPostGotTomahawkStatus() ) );
    connect( ui->twitterTweetComboBox, SIGNAL( currentIndexChanged( int ) ),
            this, SLOT( tweetComboBoxIndexChanged( int ) ) );

    ui->twitterTweetComboBox->setCurrentIndex( 0 );
    ui->twitterUserTweetLineEdit->setReadOnly( true );
    ui->twitterUserTweetLineEdit->setEnabled( false );
    
    TomahawkSettings* s = TomahawkSettings::instance();
    if ( s->twitterOAuthToken().isEmpty() || s->twitterOAuthTokenSecret().isEmpty() || s->twitterScreenName().isEmpty() )
    {
        ui->twitterStatusLabel->setText( tr( "Status: No saved credentials" ) );
        ui->twitterAuthenticateButton->setText( tr( "Authenticate" ) );
        ui->twitterInstructionsInfoLabel->setVisible( false );
        ui->twitterGlobalTweetLabel->setVisible( false );
        ui->twitterTweetGotTomahawkButton->setVisible( false );
        ui->twitterUserTweetLineEdit->setVisible( false );
        ui->twitterTweetComboBox->setVisible( false );
        
        emit twitterAuthed( false );
    }
    else
    {
        ui->twitterStatusLabel->setText( tr( "Status: Credentials saved for %1" ).arg( s->twitterScreenName() ) );
        ui->twitterAuthenticateButton->setText( tr( "De-authenticate" ) );
        ui->twitterInstructionsInfoLabel->setVisible( true );
        ui->twitterGlobalTweetLabel->setVisible( true );
        ui->twitterTweetGotTomahawkButton->setVisible( true );
        ui->twitterUserTweetLineEdit->setVisible( true );
        ui->twitterTweetComboBox->setVisible( true );

        emit twitterAuthed( true );
    }

}
Exemple #17
0
void
Account::loadFromConfig( const QString& accountId )
{
    m_accountId = accountId;
    TomahawkSettings* s = TomahawkSettings::instance();
    s->beginGroup( "accounts/" + m_accountId );
    m_accountFriendlyName = s->value( "accountfriendlyname", QString() ).toString();
    m_enabled = s->value( "enabled", false ).toBool();
    m_credentials = s->value( "credentials", QVariantHash() ).toHash();
    m_configuration = s->value( "configuration", QVariantHash() ).toHash();
    m_acl = s->value( "acl", QVariantMap() ).toMap();
    m_types = s->value( "types", QStringList() ).toStringList();
    s->endGroup();
}
Exemple #18
0
void
TomahawkWindow::loadSettings()
{
    TomahawkSettings* s = TomahawkSettings::instance();

    // Workaround for broken window geometry restoring on Qt Cocoa when setUnifiedTitleAndToolBarOnMac is true.
    // See http://bugreports.qt.nokia.com/browse/QTBUG-3116 and
    // http://lists.qt.nokia.com/pipermail/qt-interest/2009-August/011491.html
    // for the 'fix'
#ifdef QT_MAC_USE_COCOA
     bool workaround = !isVisible();
     if ( workaround )
     {
       // make "invisible"
       setWindowOpacity( 0 );
       // let Qt update its frameStruts
       show();
     }
#endif

    if ( !s->mainWindowGeometry().isEmpty() )
        restoreGeometry( s->mainWindowGeometry() );
    if ( !s->mainWindowState().isEmpty() )
        restoreState( s->mainWindowState() );
    if ( !s->mainWindowSplitterState().isEmpty() )
        ui->splitter->restoreState( s->mainWindowSplitterState() );

#ifdef QT_MAC_USE_COCOA
     if ( workaround )
     {
       // Make it visible again
       setWindowOpacity( 1 );
     }
#endif
}
void
TwitterConfigWidget::startPostGotTomahawkStatus()
{
    qDebug() << "Posting Got Tomahawk status";
    TomahawkSettings* s = TomahawkSettings::instance();
    if ( s->twitterOAuthToken().isEmpty() || s->twitterOAuthTokenSecret().isEmpty() )
    {
        QMessageBox::critical( 0, QString("Tweetin' Error"), QString("Your saved credentials could not be loaded.\nYou may wish to try re-authenticating.") );
        return;
    }
    TomahawkOAuthTwitter *twitAuth = new TomahawkOAuthTwitter( this );
    twitAuth->setNetworkAccessManager( TomahawkUtils::nam() );
    twitAuth->setOAuthToken( s->twitterOAuthToken().toLatin1() );
    twitAuth->setOAuthTokenSecret( s->twitterOAuthTokenSecret().toLatin1() );
    QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( twitAuth, this );
    connect( credVerifier, SIGNAL( parsedUser(const QTweetUser &) ), SLOT( postGotTomahawkStatusAuthVerifyReply(const QTweetUser &) ) );
    credVerifier->verify();
}
void
TwitterConfigWidget::postGotTomahawkStatusAuthVerifyReply( const QTweetUser &user )
{
    if ( user.id() == 0 )
    {
        QMessageBox::critical( this, tr("Tweetin' Error"), tr("Your saved credentials could not be verified.\nYou may wish to try re-authenticating.") );
        emit twitterAuthed( false );
        return;
    }
    TomahawkSettings* s = TomahawkSettings::instance();
    s->setTwitterScreenName( user.screenName() );
    TomahawkOAuthTwitter *twitAuth = new TomahawkOAuthTwitter( this );
    twitAuth->setNetworkAccessManager( TomahawkUtils::nam() );
    twitAuth->setOAuthToken( s->twitterOAuthToken().toLatin1() );
    twitAuth->setOAuthTokenSecret( s->twitterOAuthTokenSecret().toLatin1() );
    if ( m_postGTtype != "Direct Message" )
    {
        QTweetStatusUpdate *statUpdate = new QTweetStatusUpdate( twitAuth, this );
        connect( statUpdate, SIGNAL( postedStatus(const QTweetStatus &) ), SLOT( postGotTomahawkStatusUpdateReply(const QTweetStatus &) ) );
        connect( statUpdate, SIGNAL( error(QTweetNetBase::ErrorCode, const QString&) ), SLOT( postGotTomahawkStatusUpdateError(QTweetNetBase::ErrorCode, const QString &) ) );
        QString uuid = QUuid::createUuid();
        QString message = QString( "Got Tomahawk? {" ) + Database::instance()->dbid() + QString( "} (" ) + uuid.mid( 1, 8 ) + QString( ")" ) + QString( " http://gettomahawk.com" );
        if ( m_postGTtype == "@Mention" )
        {
            QString user = ui->twitterUserTweetLineEdit->text();
            if ( user.startsWith( "@" ) )
                user.remove( 0, 1 );
            message = QString( "@" ) + user + QString( " " ) + message;
        }
        statUpdate->post( message );
    }
    else
    {
        QTweetDirectMessageNew *statUpdate = new QTweetDirectMessageNew( twitAuth, this );
        connect( statUpdate, SIGNAL( parsedDirectMessage(const QTweetDMStatus &)), SLOT( postGotTomahawkDirectMessageReply(const QTweetDMStatus &) ) );
        connect( statUpdate, SIGNAL( error(QTweetNetBase::ErrorCode, const QString&) ), SLOT( postGotTomahawkStatusUpdateError(QTweetNetBase::ErrorCode, const QString &) ) );
        QString uuid = QUuid::createUuid();
        QString message = QString( "Got Tomahawk? {" ) + Database::instance()->dbid() + QString( "} (" ) + uuid.mid( 1, 8 ) + QString( ")" ) + QString( " http://gettomahawk.com" );
        QString user = ui->twitterUserTweetLineEdit->text();
        if ( user.startsWith( "@" ) )
            user.remove( 0, 1 );
        statUpdate->post( user, message );
    }
}
void
TwitterConfigWidget::deauthenticateTwitter()
{
    qDebug() << Q_FUNC_INFO;
    TomahawkSettings* s = TomahawkSettings::instance();
    s->setTwitterOAuthToken( QString() );
    s->setTwitterOAuthTokenSecret( QString() );
    s->setTwitterScreenName( QString() );
    
    ui->twitterStatusLabel->setText(tr("Status: No saved credentials"));
    ui->twitterAuthenticateButton->setText( tr( "Authenticate" ) );
    ui->twitterInstructionsInfoLabel->setVisible( false );
    ui->twitterGlobalTweetLabel->setVisible( false );
    ui->twitterTweetGotTomahawkButton->setVisible( false );
    ui->twitterUserTweetLineEdit->setVisible( false );
    ui->twitterTweetComboBox->setVisible( false );
    
    emit twitterAuthed( false );
}
void
TwitterConfigWidget::postGotTomahawkStatusAuthVerifyReply( const QTweetUser &user )
{
    if ( user.id() == 0 )
    {
        QMessageBox::critical( 0, QString("Tweetin' Error"), QString("Your saved credentials could not be verified.\nYou may wish to try re-authenticating.") );
        return;
    }
    TomahawkSettings* s = TomahawkSettings::instance();
    s->setTwitterScreenName( user.screenName() );
    TomahawkOAuthTwitter *twitAuth = new TomahawkOAuthTwitter( this );
    twitAuth->setNetworkAccessManager( TomahawkUtils::nam() );
    twitAuth->setOAuthToken( s->twitterOAuthToken().toLatin1() );
    twitAuth->setOAuthTokenSecret( s->twitterOAuthTokenSecret().toLatin1() );
    QTweetStatusUpdate *statUpdate = new QTweetStatusUpdate( twitAuth, this );
    connect( statUpdate, SIGNAL( postedStatus(const QTweetStatus &) ), SLOT( postGotTomahawkStatusUpdateReply(const QTweetStatus &) ) );
    connect( statUpdate, SIGNAL( error(QTweetNetBase::ErrorCode, const QString&) ), SLOT( postGotTomahawkStatusUpdateError(QTweetNetBase::ErrorCode, const QString &) ) );
    QString uuid = QUuid::createUuid();
    statUpdate->post( QString( "Got Tomahawk? {" ) + Database::instance()->dbid() + QString( "} (" ) + uuid.mid( 1, 8 ) + QString( ")" ) );
}
void
TwitterConfigWidget::authenticateTwitter()
{
    qDebug() << Q_FUNC_INFO;
    TomahawkOAuthTwitter *twitAuth = new TomahawkOAuthTwitter( this );
    twitAuth->setNetworkAccessManager( TomahawkUtils::nam() );
    twitAuth->authorizePin();
    if ( !twitAuth->oauthToken().isEmpty() && !twitAuth->oauthTokenSecret().isEmpty() )
    {
        TomahawkSettings* s = TomahawkSettings::instance();
        s->setTwitterOAuthToken( twitAuth->oauthToken() );
        s->setTwitterOAuthTokenSecret( twitAuth->oauthTokenSecret() );
        ui->twitterStatusLabel->setText("Status: Credentials saved");
        ui->twitterAuthenticateButton->setText( "Re-authenticate" );
        ui->twitterInstructionsBox->setVisible( true );
        TomahawkSettings::instance()->setTwitterCachedFriendsSinceId( 0 );
        TomahawkSettings::instance()->setTwitterCachedMentionsSinceId( 0 );
        m_plugin->connectPlugin( false );

    }
    else
    {
        TomahawkSettings* s = TomahawkSettings::instance();
        s->setTwitterOAuthToken( QString() );
        s->setTwitterOAuthTokenSecret( QString() );
        ui->twitterStatusLabel->setText("Status: No saved credentials");
        ui->twitterAuthenticateButton->setText( "Authenticate" );
        ui->twitterInstructionsBox->setVisible( false );
        QMessageBox::critical( 0, QString("Tweetin' Error"), QString("There was an error validating your authentication") );
    }
}
Exemple #24
0
void
TrackView::setGuid( const QString& newguid )
{
    if ( newguid == m_guid )
        return;

    if ( !newguid.isEmpty() )
    {
        tDebug() << Q_FUNC_INFO << "Setting guid on header" << newguid << "for a view with" << m_proxyModel->columnCount() << "columns";

        m_guid = newguid;
        m_header->setGuid( guid() );

        if ( !m_guid.isEmpty() && proxyModel()->playlistInterface() )
        {
            tDebug() << Q_FUNC_INFO << "Restoring shuffle & random mode settings for guid" << m_guid;

            TomahawkSettings* s = TomahawkSettings::instance();
            proxyModel()->playlistInterface()->setShuffled( s->shuffleState( m_guid ) );
            proxyModel()->playlistInterface()->setRepeatMode( s->repeatMode( m_guid ) );
        }
    }
}
PlaylistUpdaterInterface*
PlaylistUpdaterInterface::loadForPlaylist( const playlist_ptr& pl )
{
    TomahawkSettings* s = TomahawkSettings::instance();
    const QString key = QString( "playlistupdaters/%1" ).arg( pl->guid() );
    if ( s->contains( QString( "%1/type" ).arg( key ) ) )
    {
        // Ok, we have one we can try to load
        const QString type = s->value( QString( "%1/type" ).arg( key ) ).toString();
        PlaylistUpdaterInterface* updater = 0;

        if ( !s_factories.contains( type ) )
        {
            Q_ASSERT( false );
            // You forgot to register your new updater type with the factory....
            return 0;
        }

        updater = s_factories[ type ]->create( pl, key );
        return updater;
    }

    return 0;
}
Exemple #26
0
void
ProxyDialog::saveSettings()
{
    qDebug() << Q_FUNC_INFO;

    //First set settings
    TomahawkSettings* s = TomahawkSettings::instance();
    s->setProxyHost( ui->hostLineEdit->text() );

    int port = ui->portSpinBox->value();
    s->setProxyPort( port );
    s->setProxyNoProxyHosts( ui->noHostLineEdit->text() );
    s->setProxyUsername( ui->userLineEdit->text() );
    s->setProxyPassword( ui->passwordLineEdit->text() );
    s->setProxyDns( ui->checkBoxUseProxyForDns->checkState() == Qt::Checked );
    s->sync();
}
Exemple #27
0
ProxyDialog::ProxyDialog( QWidget *parent )
    : QDialog( parent )
    , ui( new Ui::ProxyDialog )
{
    ui->setupUi( this );

    // ugly, I know, but...
    TomahawkSettings* s = TomahawkSettings::instance();

    ui->hostLineEdit->setText( s->proxyHost() );
    ui->portSpinBox->setValue( s->proxyPort() );
    ui->userLineEdit->setText( s->proxyUsername() );
    ui->passwordLineEdit->setText( s->proxyPassword() );
    ui->checkBoxUseProxyForDns->setChecked( s->proxyDns() );
    ui->noHostLineEdit->setText( s->proxyNoProxyHosts() );
}
Exemple #28
0
void
TomahawkApp::init()
{
    if ( arguments().contains( "--help" ) || arguments().contains( "-h" ) )
    {
        printHelp();
        ::exit( 0 );
    }

    qDebug() << "TomahawkApp thread:" << thread();
    Logger::setupLogfile();
    qsrand( QTime( 0, 0, 0 ).secsTo( QTime::currentTime() ) );

    tLog() << "Starting Tomahawk...";

#ifdef ENABLE_HEADLESS
    m_headless = true;
#else
    m_mainwindow = 0;
    m_headless = arguments().contains( "--headless" );
    setWindowIcon( QIcon( RESPATH "icons/tomahawk-icon-128x128.png" ) );
    setQuitOnLastWindowClosed( false );

    QFont f = APP->font();
    f.setPixelSize( HeaderLabel::defaultFontSize() );
    QFontMetrics fm( f );
    TomahawkUtils::setHeaderHeight( fm.height() + 8 );
#endif

    TomahawkSettings* s = TomahawkSettings::instance();

    tDebug( LOGINFO ) << "Setting NAM.";
    // Cause the creation of the nam, but don't need to address it directly, so prevent warning
    Q_UNUSED( TomahawkUtils::nam() );

    m_audioEngine = QWeakPointer<AudioEngine>( new AudioEngine );
    m_scanManager = QWeakPointer<ScanManager>( new ScanManager( this ) );

    // init pipeline and resolver factories
    new Pipeline();

#ifndef ENABLE_HEADLESS
    Pipeline::instance()->addExternalResolverFactory( boost::bind( &QtScriptResolver::factory, _1 ) );
    Pipeline::instance()->addExternalResolverFactory( boost::bind( &ScriptResolver::factory, _1 ) );

    new ActionCollection( this );
    connect( ActionCollection::instance()->getAction( "quit" ), SIGNAL( triggered() ), SLOT( quit() ), Qt::UniqueConnection );
#endif

    m_servent = QWeakPointer<Servent>( new Servent( this ) );
    connect( m_servent.data(), SIGNAL( ready() ), SLOT( initSIP() ) );

    tDebug() << "Init Database.";
    initDatabase();

    QByteArray magic = QByteArray::fromBase64( enApiSecret );
    QByteArray wand = QByteArray::fromBase64( QCoreApplication::applicationName().toLatin1() );
    int length = magic.length(), n2 = wand.length();
    for ( int i=0; i<length; i++ ) magic[i] = magic[i] ^ wand[i%n2];
    Echonest::Config::instance()->setAPIKey( magic );

#ifndef ENABLE_HEADLESS
    tDebug() << "Init Echonest Factory.";
    GeneratorFactory::registerFactory( "echonest", new EchonestFactory );
#endif
    tDebug() << "Init Database Factory.";
    GeneratorFactory::registerFactory( "database", new DatabaseFactory );

    // Register shortcut handler for this platform
#ifdef Q_WS_MAC
    m_shortcutHandler = QWeakPointer<Tomahawk::ShortcutHandler>( new MacShortcutHandler( this ) );
    Tomahawk::setShortcutHandler( static_cast<MacShortcutHandler*>( m_shortcutHandler.data() ) );

    Tomahawk::setApplicationHandler( this );
    increaseMaxFileDescriptors();
#endif

    // Connect up shortcuts
    if ( !m_shortcutHandler.isNull() )
    {
        connect( m_shortcutHandler.data(), SIGNAL( playPause() ), m_audioEngine.data(), SLOT( playPause() ) );
        connect( m_shortcutHandler.data(), SIGNAL( pause() ), m_audioEngine.data(), SLOT( pause() ) );
        connect( m_shortcutHandler.data(), SIGNAL( stop() ), m_audioEngine.data(), SLOT( stop() ) );
        connect( m_shortcutHandler.data(), SIGNAL( previous() ), m_audioEngine.data(), SLOT( previous() ) );
        connect( m_shortcutHandler.data(), SIGNAL( next() ), m_audioEngine.data(), SLOT( next() ) );
        connect( m_shortcutHandler.data(), SIGNAL( volumeUp() ), m_audioEngine.data(), SLOT( raiseVolume() ) );
        connect( m_shortcutHandler.data(), SIGNAL( volumeDown() ), m_audioEngine.data(), SLOT( lowerVolume() ) );
        connect( m_shortcutHandler.data(), SIGNAL( mute() ), m_audioEngine.data(), SLOT( mute() ) );
    }

    tDebug() << "Init InfoSystem.";
    m_infoSystem = QWeakPointer<Tomahawk::InfoSystem::InfoSystem>( Tomahawk::InfoSystem::InfoSystem::instance() );

    tDebug() << "Init AccountManager.";
    m_accountManager = QWeakPointer< Tomahawk::Accounts::AccountManager >( new Tomahawk::Accounts::AccountManager( this ) );

    Tomahawk::Accounts::LastFmAccountFactory* lastfmFactory = new Tomahawk::Accounts::LastFmAccountFactory();
    m_accountManager.data()->addAccountFactory( lastfmFactory );

    Tomahawk::Accounts::SpotifyAccountFactory* spotifyFactory = new Tomahawk::Accounts::SpotifyAccountFactory;
    m_accountManager.data()->addAccountFactory( spotifyFactory );
    m_accountManager.data()->registerAccountFactoryForFilesystem( spotifyFactory );

    Tomahawk::Accounts::AccountManager::instance()->loadFromConfig();

    Echonest::Config::instance()->setNetworkAccessManager( TomahawkUtils::nam() );
#ifndef ENABLE_HEADLESS
    EchonestGenerator::setupCatalogs();

    if ( !m_headless )
    {
        tDebug() << "Init MainWindow.";
        m_mainwindow = new TomahawkWindow();
        m_mainwindow->setWindowTitle( "Tomahawk" );
        m_mainwindow->setObjectName( "TH_Main_Window" );
        if ( !arguments().contains( "--hide" ) )
        {
            m_mainwindow->show();
        }
    }
#endif

    tDebug() << "Init Local Collection.";
    initLocalCollection();
    tDebug() << "Init Pipeline.";
    initPipeline();

#ifndef ENABLE_HEADLESS
    // load remote list of resolvers able to be installed
    AtticaManager::instance();
#endif

    if ( arguments().contains( "--http" ) || TomahawkSettings::instance()->value( "network/http", true ).toBool() )
    {
        initHTTP();
    }
    connect( TomahawkSettings::instance(), SIGNAL( changed() ), SLOT( initHTTP() ) );

#ifndef ENABLE_HEADLESS
    if ( !s->hasScannerPaths() )
    {
        m_mainwindow->showSettingsDialog();
    }
#endif

#ifdef LIBLASTFM_FOUND
    tDebug() << "Init Scrobbler.";
    m_scrobbler = new Scrobbler( this );
#endif

    if ( arguments().contains( "--filescan" ) )
    {
        m_scanManager.data()->runScan( true );
    }

    // Set up echonest catalog synchronizer
    Tomahawk::EchonestCatalogSynchronizer::instance();

#ifndef ENABLE_HEADLESS
    // Make sure to init GAM in the gui thread
    GlobalActionManager::instance();

    // check if our spotify playlist api server is up and running, and enable spotify playlist drops if so
    QNetworkReply* r = TomahawkUtils::nam()->get( QNetworkRequest( QUrl( SPOTIFY_PLAYLIST_API_URL "/pong" ) ) );
    connect( r, SIGNAL( finished() ), this, SLOT( spotifyApiCheckFinished() ) );
#endif

#ifdef Q_WS_MAC
    // Make sure to do this after main window is inited
    Tomahawk::enableFullscreen();
#endif
}
Exemple #29
0
SettingsDialog::SettingsDialog(QObject *parent )
    : QObject( parent )
    , m_accountsWidgetUi( new Ui_Settings_Accounts )
    , m_accountsWidget( new QWidget )
    , m_collectionWidgetUi( new Ui_Settings_Collection )
    , m_collectionWidget( new QWidget )
    , m_advancedWidgetUi( new Ui_Settings_Advanced )
    , m_advancedWidget( new QWidget )
    , m_downloadsWidgetUi( new Ui_Settings_Downloads )
    , m_downloadsWidget( new QWidget )
    , m_staticHostSettings( 0 )
    , m_proxySettings( 0 )
    , m_restartRequired( false )
    , m_accountModel( 0 )
    , m_sipSpinner( 0 )
{
    m_accountsWidget->setFont( TomahawkUtils::systemFont() );
    m_collectionWidget->setFont( TomahawkUtils::systemFont() );
    m_advancedWidget->setFont( TomahawkUtils::systemFont() );
    m_downloadsWidget->setFont( TomahawkUtils::systemFont() );

    m_accountsWidgetUi->setupUi( m_accountsWidget );
    m_collectionWidgetUi->setupUi( m_collectionWidget );
    m_advancedWidgetUi->setupUi( m_advancedWidget );
    m_downloadsWidgetUi->setupUi( m_downloadsWidget );

    m_accountsWidgetUi->accountsFilterCombo->setFocusPolicy( Qt::NoFocus );
    m_dialog = new QToolbarTabDialog;




    TomahawkSettings* s = TomahawkSettings::instance();
    
// CHANGED
    m_advancedWidgetUi->checkBoxExitOnClose->setChecked( s->exitOnClose());


    m_advancedWidgetUi->checkBoxReporter->setChecked( s->crashReporterEnabled() );
    m_advancedWidgetUi->checkBoxHttp->setChecked( s->httpEnabled() );
    m_advancedWidgetUi->checkBoxListenApi->setChecked( s->httpBindAll() );
    m_advancedWidgetUi->checkBoxSongChangeNotifications->setChecked( s->songChangeNotificationEnabled() );

    //Network settings
    Tomahawk::Network::ExternalAddress::Mode mode = TomahawkSettings::instance()->externalAddressMode();
    if ( mode == Tomahawk::Network::ExternalAddress::Lan )
        m_advancedWidgetUi->lanOnlyRadioButton->setChecked( true );
    else if ( mode == Tomahawk::Network::ExternalAddress::Static )
        m_advancedWidgetUi->staticIpRadioButton->setChecked( true );
    else
        m_advancedWidgetUi->upnpRadioButton->setChecked( true );

    m_advancedWidgetUi->staticHostSettingsButton->setEnabled( m_advancedWidgetUi->staticIpRadioButton->isChecked() );

    bool useProxy = TomahawkSettings::instance()->proxyType() == QNetworkProxy::Socks5Proxy;
    m_advancedWidgetUi->enableProxyCheckBox->setChecked( useProxy );
    m_advancedWidgetUi->proxyButton->setEnabled( useProxy );

    m_advancedWidgetUi->aclEntryClearButton->setEnabled( TomahawkSettings::instance()->aclEntries().size() > 0 );
    connect( m_advancedWidgetUi->aclEntryClearButton, SIGNAL( clicked( bool ) ), this, SLOT( aclEntryClearButtonClicked() ) );

#ifdef Q_OS_MAC
    // Avoid resize handles on sheets on osx
    m_proxySettings.setSizeGripEnabled( true );
    QSizeGrip* p = m_proxySettings.findChild< QSizeGrip* >();
    p->setFixedSize( 0, 0 );
    m_staticHostSettings.setSizeGripEnabled( true );
    p = m_staticHostSettings.findChild< QSizeGrip* >();
    p->setFixedSize( 0, 0 );
#endif

    m_accountsWidgetUi->installFromFileBtn->setText( tr( "Install Plug-In..." ) );

    // Accounts
    AccountDelegate* accountDelegate = new AccountDelegate( this );
    m_accountsWidgetUi->accountsView->setItemDelegate( accountDelegate );
    m_accountsWidgetUi->accountsView->setContextMenuPolicy( Qt::CustomContextMenu );
    m_accountsWidgetUi->accountsView->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
    m_accountsWidgetUi->accountsView->setMouseTracking( true );

    connect( accountDelegate, SIGNAL( openConfig( Tomahawk::Accounts::Account* ) ), SLOT( openAccountConfig( Tomahawk::Accounts::Account* ) ) );
    connect( accountDelegate, SIGNAL( openConfig( Tomahawk::Accounts::AccountFactory* ) ), SLOT( openAccountFactoryConfig( Tomahawk::Accounts::AccountFactory* ) ) );
    connect( accountDelegate, SIGNAL( update( QModelIndex ) ), m_accountsWidgetUi->accountsView, SLOT( update( QModelIndex ) ) );

    m_accountModel = new AccountModel( this );
    m_accountProxy = new AccountModelFilterProxy( m_accountModel );
    m_accountProxy->setSourceModel( m_accountModel );

    connect( m_accountProxy, SIGNAL( startInstalling( QPersistentModelIndex ) ), accountDelegate, SLOT( startInstalling(QPersistentModelIndex) ) );
    connect( m_accountProxy, SIGNAL( doneInstalling( QPersistentModelIndex ) ), accountDelegate, SLOT( doneInstalling(QPersistentModelIndex) ) );
    connect( m_accountProxy, SIGNAL( errorInstalling( QPersistentModelIndex ) ), accountDelegate, SLOT( errorInstalling(QPersistentModelIndex) ) );
    connect( m_accountProxy, SIGNAL( scrollTo( QModelIndex ) ), SLOT( scrollTo( QModelIndex ) ) );

    m_accountsWidgetUi->accountsView->setModel( m_accountProxy );

    connect( m_accountsWidgetUi->installFromFileBtn, SIGNAL( clicked( bool ) ), SLOT( installFromFile() ) );
    connect( m_accountModel, SIGNAL( createAccount( Tomahawk::Accounts::AccountFactory* ) ), SLOT( createAccountFromFactory( Tomahawk::Accounts::AccountFactory* ) ) );

    m_accountsWidgetUi->accountsFilterCombo->addItem( tr( "All" ), Accounts::NoType );
    m_accountsWidgetUi->accountsFilterCombo->addItem( accountTypeToString( SipType ), SipType );
    m_accountsWidgetUi->accountsFilterCombo->addItem( accountTypeToString( ResolverType ), ResolverType );
    m_accountsWidgetUi->accountsFilterCombo->addItem( accountTypeToString( StatusPushType ), StatusPushType );

    connect( m_accountsWidgetUi->accountsFilterCombo, SIGNAL( activated( int ) ), SLOT( accountsFilterChanged( int ) ) );

    if ( !Servent::instance()->isReady() )
    {
        m_sipSpinner = new AnimatedSpinner( m_accountsWidgetUi->accountsView );
        m_sipSpinner->fadeIn();

        connect( Servent::instance(), SIGNAL( ready() ), SLOT( serventReady() ) );
    }

    // ADVANCED
    m_advancedWidgetUi->proxyButton->setVisible( true );

    m_collectionWidgetUi->checkBoxWatchForChanges->setChecked( s->watchForChanges() );
    m_collectionWidgetUi->scannerTimeSpinBox->setValue( s->scannerTime() );
    m_collectionWidgetUi->enableEchonestCatalog->setChecked( s->enableEchonestCatalogs() );

    connect( m_collectionWidgetUi->checkBoxWatchForChanges, SIGNAL( clicked( bool ) ), SLOT( updateScanOptionsView() ) );

    if ( m_collectionWidgetUi->checkBoxWatchForChanges->isChecked() )
    {
        m_collectionWidgetUi->scanTimeLabel->show();
        m_collectionWidgetUi->scannerTimeSpinBox->show();
    }
    else
    {
        m_collectionWidgetUi->scanTimeLabel->hide();
        m_collectionWidgetUi->scannerTimeSpinBox->hide();
    }

/*    foreach ( const QString& dir, TomahawkSettings::instance()->scannerPaths() )
    {
        m_collectionWidgetUi->dirTree->checkPath( dir, Qt::Checked );
    }*/
    m_collectionWidgetUi->pathListWidget->addItems( TomahawkSettings::instance()->scannerPaths() );

    const int buttonSize = TomahawkUtils::defaultFontHeight() * 2.5;
    m_collectionWidgetUi->addLibraryPathButton->setFixedSize( buttonSize, buttonSize );
    m_collectionWidgetUi->removeLibraryPathButton->setFixedSize( m_collectionWidgetUi->addLibraryPathButton->size() );

    connect( m_collectionWidgetUi->addLibraryPathButton, SIGNAL( clicked() ), SLOT( addLibraryPath() ) );
    connect( m_collectionWidgetUi->removeLibraryPathButton, SIGNAL( clicked() ), SLOT( removeLibraryPath() ) );

    int buttonsWidth = qMax( m_advancedWidgetUi->proxyButton->sizeHint().width(),
                             m_advancedWidgetUi->aclEntryClearButton->sizeHint().width() );
    m_advancedWidgetUi->proxyButton->setFixedWidth( buttonsWidth );
    m_advancedWidgetUi->aclEntryClearButton->setFixedWidth( buttonsWidth );

    m_downloadsWidgetUi->downloadsFolder->setText( TomahawkSettings::instance()->downloadsPath() );
    connect( m_downloadsWidgetUi->pickFolderButton, SIGNAL( clicked() ), SLOT( pickDownloadsPath() ) );

    m_downloadsFormats.insert( "MP3", tr( "MP3" ) );
    m_downloadsFormats.insert( "FLAC", tr( "FLAC" ) );
    m_downloadsFormats.insert( "M4A", tr( "M4A" ) );
    m_downloadsFormats.insert( "MP4", tr( "MP4" ) );
    foreach ( const QString& format, m_downloadsFormats.values() )
    {
        m_downloadsWidgetUi->preferredFormatComboBox->addItem( format );
    }
    int i = m_downloadsWidgetUi->preferredFormatComboBox->findText( m_downloadsFormats.value( TomahawkSettings::instance()->downloadsPreferredFormat() ) );
    if ( i < 0 )
        i = m_downloadsWidgetUi->preferredFormatComboBox->findText( "MP3" );
    m_downloadsWidgetUi->preferredFormatComboBox->setCurrentIndex( i );

#ifndef Q_OS_MAC
    m_advancedWidget->setMinimumSize( m_advancedWidget->sizeHint() );
    m_accountsWidget->setMinimumWidth( 500 );
#else
    m_accountsWidget->setContentsMargins( 6, 6, 6, 6 );
    m_accountsWidgetUi->horizontalLayout->setContentsMargins( 0, 0, 0, 0 );
    m_accountsWidgetUi->installFromFileBtn->setContentsMargins( 0, 0, 0, 0 );
    m_accountsWidget->setMinimumSize( 550, 400 );
    m_accountsWidgetUi->accountsView->setAttribute( Qt::WA_MacShowFocusRect, false );

    m_collectionWidget->setContentsMargins( 6, 6, 6, 6 );
    m_collectionWidget->setMinimumHeight( m_collectionWidgetUi->verticalLayout->sizeHint().height() + 20 );
    m_collectionWidgetUi->pathListWidget->setAttribute( Qt::WA_MacShowFocusRect, false );

    m_advancedWidget->setContentsMargins( 6, 6, 6, 6 );
    m_advancedWidget->setMinimumHeight( m_advancedWidgetUi->verticalLayout->sizeHint().height() );
#endif

    // NOW PLAYING
// #ifdef Q_OS_MAC
//     ui->checkBoxEnableAdium->setChecked( s->nowPlayingEnabled() );
// #else
//     ui->checkBoxEnableAdium->hide();
// #endif

    m_dialog->addTab( m_accountsWidget, TomahawkUtils::defaultPixmap( TomahawkUtils::AccountSettings ),
                      tr( "Plug-Ins" ), tr( "Configure the accounts and services used by Tomahawk "
                                             "to search and retrieve music, find your friends and "
                                             "update your status." ) );

    m_dialog->addTab( m_collectionWidget, TomahawkUtils::defaultPixmap( TomahawkUtils::MusicSettings ),
                      tr( "Collection" ), tr( "Manage how Tomahawk finds music on your computer." ) );

    m_dialog->addTab( m_advancedWidget, TomahawkUtils::defaultPixmap( TomahawkUtils::AdvancedSettings ),
                      tr( "Advanced" ), tr( "Configure Tomahawk's advanced settings, including "
                                            "network connectivity settings, browser interaction "
                                            "and more." ) );

    m_dialog->addTab( m_downloadsWidget, TomahawkUtils::defaultPixmap( TomahawkUtils::DownloadsSettings ),
                      tr( "Downloads" ), tr( "Configure Tomahawk's integrated download manager." ) );

    m_dialog->setCurrentIndex( 0 );

    connect( m_advancedWidgetUi->staticHostSettingsButton, SIGNAL( clicked() ), SLOT( showStaticHostSettings() ) );
    connect( m_advancedWidgetUi->proxyButton,  SIGNAL( clicked() ), SLOT( showProxySettings() ) );
    connect( m_advancedWidgetUi->lanOnlyRadioButton, SIGNAL( toggled( bool ) ), SLOT( requiresRestart() ) );
    connect( m_advancedWidgetUi->staticIpRadioButton, SIGNAL( toggled( bool ) ), SLOT( requiresRestart() ) );
    connect( m_advancedWidgetUi->upnpRadioButton, SIGNAL( toggled( bool ) ), SLOT( requiresRestart() ) );
    connect( m_advancedWidgetUi->lanOnlyRadioButton, SIGNAL( toggled( bool ) ), SLOT( toggleRemoteMode() ) );
    connect( m_advancedWidgetUi->staticIpRadioButton, SIGNAL( toggled( bool ) ), SLOT( toggleRemoteMode() ) );
    connect( m_advancedWidgetUi->upnpRadioButton, SIGNAL( toggled( bool ) ), SLOT( toggleRemoteMode() ) );
    connect( m_advancedWidgetUi->enableProxyCheckBox, SIGNAL( toggled( bool ) ), SLOT( toggleProxyEnabled() ) );
    connect( m_advancedWidgetUi->enableProxyCheckBox, SIGNAL( toggled( bool ) ), SLOT( requiresRestart() ) );

    connect( m_dialog, SIGNAL( accepted() ), SLOT( saveSettings() ) );
    connect( m_dialog, SIGNAL( rejected() ), SLOT( onRejected() ) );
}
Exemple #30
0
void
SettingsDialog::saveSettings()
{
    qDebug() << Q_FUNC_INFO;

    TomahawkSettings* s = TomahawkSettings::instance();

    s->setCrashReporterEnabled( m_advancedWidgetUi->checkBoxReporter->checkState() == Qt::Checked );

    // CHANGED
    s->setExitOnClose( m_advancedWidgetUi->checkBoxExitOnClose->checkState() == Qt::Checked );

    s->setHttpEnabled( m_advancedWidgetUi->checkBoxHttp->checkState() == Qt::Checked );
    s->setHttpBindAll( m_advancedWidgetUi->checkBoxListenApi->checkState() == Qt::Checked );
    s->setSongChangeNotificationEnabled( m_advancedWidgetUi->checkBoxSongChangeNotifications->checkState() == Qt::Checked );
    s->setProxyType( m_advancedWidgetUi->enableProxyCheckBox->isChecked() ? QNetworkProxy::Socks5Proxy : QNetworkProxy::NoProxy );
    s->setExternalAddressMode( m_advancedWidgetUi->upnpRadioButton->isChecked() ? Tomahawk::Network::ExternalAddress::Upnp : ( m_advancedWidgetUi->lanOnlyRadioButton->isChecked() ? Tomahawk::Network::ExternalAddress::Lan : Tomahawk::Network::ExternalAddress::Static ) );

    QStringList libraryPaths;
    for ( int i = 0; i < m_collectionWidgetUi->pathListWidget->count(); i++ )
    {
        libraryPaths << m_collectionWidgetUi->pathListWidget->item( i )->text();
    }
    s->setScannerPaths( libraryPaths );
//    s->setScannerPaths( m_collectionWidgetUi->dirTree->getCheckedPaths() );
    s->setWatchForChanges( m_collectionWidgetUi->checkBoxWatchForChanges->isChecked() );
    s->setScannerTime( m_collectionWidgetUi->scannerTimeSpinBox->value() );
    s->setEnableEchonestCatalogs( m_collectionWidgetUi->enableEchonestCatalog->isChecked() );
    s->setDownloadsPath( m_downloadsWidgetUi->downloadsFolder->text() );
    s->setDownloadsPreferredFormat( m_downloadsFormats.key( m_downloadsWidgetUi->preferredFormatComboBox->currentText() ) );

//         s->setNowPlayingEnabled( ui->checkBoxEnableAdium->isChecked() );

    s->applyChanges();
    s->sync();

    if ( m_restartRequired )
        QMessageBox::information( 0, tr( "Information" ), tr( "Some changed settings will not take effect until Tomahawk is restarted" ) );

//    m_collectionWidgetUi->dirTree->cleanup();

    Tomahawk::Utils::NetworkProxyFactory* proxyFactory = Tomahawk::Utils::proxyFactory();
    if ( !m_advancedWidgetUi->enableProxyCheckBox->isChecked() )
    {
        tDebug() << Q_FUNC_INFO << "Got NoProxy selected";
        proxyFactory->setProxy( QNetworkProxy::NoProxy, s->proxyDns() );
    }
    else
    {
        tDebug() << Q_FUNC_INFO << "Got Socks5Proxy selected";
        proxyFactory->setProxy( QNetworkProxy( QNetworkProxy::Socks5Proxy, s->proxyHost(), s->proxyPort(), s->proxyUsername(), s->proxyPassword() ), s->proxyDns() );
        if ( !s->proxyNoProxyHosts().isEmpty() )
        {
            tDebug() << Q_FUNC_INFO << "noproxy hosts:" << s->proxyNoProxyHosts();
            tDebug() << Q_FUNC_INFO << "split noproxy line edit is " << s->proxyNoProxyHosts().split( ' ', QString::SkipEmptyParts );
            proxyFactory->setNoProxyHosts( s->proxyNoProxyHosts().split( ' ', QString::SkipEmptyParts ) );
        }
    }

    emit finished( true );
}