void
PluginBootstrapper::onUploadCompleted( int status )
{
    QString savePath = lastfm::dir::runtimeData().filePath( lastfm::ws::Username + "_" + m_pluginId + "_bootstrap.xml" );
    QString zipPath = savePath + ".gz";

    if( status == Bootstrap_Ok  )
    {
        QMessageBoxBuilder( 0 )
                .setIcon( QMessageBox::Information )
                .setTitle( tr("Media Library Import Complete") )
                .setText( tr( "Last.fm has submitted your listening history to the server.\n"
                              "Your profile will be updated with the new tracks in a few minutes.") );
    }
    else if( status == Bootstrap_Denied )
    {
        QMessageBoxBuilder( 0 )
            .setIcon( QMessageBox::Warning )
            .setTitle( tr("Library Import Failed") )
            .setText( tr( "Sorry, Last.fm was unable to import your listening history. "
                          "This is probably because you've already scrobbled too many tracks. "
                          "Listening history can only be imported to brand new profiles.") );

        QFile::remove( savePath );
        QFile::remove( zipPath );
    }
}
Esempio n. 2
0
void
LoginProcess::showError() const
{
    switch ( m_lastError.enumValue() )
    {
        case lastfm::ws::AuthenticationFailed:
            // COPYTODO
            QMessageBoxBuilder( 0 )
                    .setIcon( QMessageBox::Critical )
                    .setTitle( tr("Login Failed") )
                    .setText( tr("Sorry, we don't recognise that username, or you typed the password wrongly.") )
                    .exec();
            break;

        default:
            // COPYTODO
            QMessageBoxBuilder( 0 )
                    .setIcon( QMessageBox::Critical )
                    .setTitle( tr("Last.fm Unavailable") )
                    .setText( tr("There was a problem communicating with the Last.fm services. Please try again later.") )
                    .exec();
            break;

        case lastfm::ws::TryAgainLater:
        case lastfm::ws::UnknownError:
            switch ( m_lastNetworkError )
            {
                case QNetworkReply::ProxyConnectionClosedError:
                case QNetworkReply::ProxyConnectionRefusedError:
                case QNetworkReply::ProxyNotFoundError:
                case QNetworkReply::ProxyTimeoutError:
                case QNetworkReply::ProxyAuthenticationRequiredError: //TODO we are meant to prompt!
                case QNetworkReply::UnknownProxyError:
                case QNetworkReply::UnknownNetworkError:
                    break;
                default:
                    return;
            }

            // TODO proxy prompting?
            // COPYTODO
            QMessageBoxBuilder( 0 )
                    .setIcon( QMessageBox::Critical )
                    .setTitle( tr("Cannot connect to Last.fm") )
                    .setText( tr("Last.fm cannot be reached. Please check your firewall or proxy settings.") )
                    .exec();

#ifdef WIN32
            // show Internet Settings Control Panel
            HMODULE h = LoadLibraryA( "InetCpl.cpl" );
            if (!h) break;
            BOOL (WINAPI *cpl)(HWND) = (BOOL (WINAPI *)(HWND)) GetProcAddress( h, "LaunchConnectionDialog" );
            if (cpl) cpl( qApp->activeWindow()->winId() );
            FreeLibrary( h );
#endif
            break;
    }
}
Esempio n. 3
0
void
LoginProcess::handleError( const lastfm::XmlQuery& lfm )
{
    qWarning() << lfm.parseError().message() << lfm.parseError().enumValue();

    if ( lfm.parseError().enumValue() == lastfm::ws::MalformedResponse )
    {
        // ask for proxy settings
        unicorn::ProxyDialog proxy;
        proxy.exec();
    }
    else
    {
        QString errorText;

        if ( lfm.parseError().enumValue() == lastfm::ws::UnknownError )
            errorText = tr( "There was a network error: %1" ).arg( QString::number( static_cast<QNetworkReply*>( sender() )->error() ) );
        else if ( lfm.parseError().enumValue() == lastfm::ws::TokenNotAuthorised )
            errorText = tr( "You have not authorised this application" );
        else
            errorText = lfm.parseError().message().trimmed() + ": " + QString::number( lfm.parseError().enumValue() );

        QMessageBoxBuilder( 0 )
                .setIcon( QMessageBox::Critical )
                .setTitle( tr("Authentication Error") )
                .setText( errorText )
                .exec();
    }
}
void
GeneralSettingsWidget::saveSettings()
{
    qDebug() << "has unsaved changes?" << hasUnsavedChanges();
    if ( hasUnsavedChanges() )
    {
        int currIndex = ui->languages->currentIndex();
        QString currLanguage = ui->languages->itemData( currIndex ).toString();

        if ( unicorn::AppSettings().value( "language", "" ) != currLanguage )
        {
            unicorn::AppSettings().setValue( "language", currLanguage );
            QMessageBoxBuilder( 0 )
                .setIcon( QMessageBox::Information )
                .setTitle( tr( "Restart needed" ) )
                .setText( tr( "You need to restart the application for the language change to take effect." ) )
                .exec();
        }

        unicorn::Settings().setValue( SETTING_SHOW_AS, ui->showAs->isChecked() );
        aApp->showAs( ui->showAs->isChecked() );

        // setting is for the 'Client' aplication for compatibility with old media player plugins
        unicorn::AppSettings( "Client" ).setValue( SETTING_LAUNCH_ITUNES, ui->launch->isChecked() );

        //
        unicorn::Settings().setValue( SETTING_NOTIFICATIONS, ui->notifications->isChecked() );
        unicorn::Settings().setValue( SETTING_LAST_RADIO, ui->lastRadio->isChecked() );
        unicorn::Settings().setValue( SETTING_SEND_CRASH_REPORTS, ui->sendCrashReports->isChecked() );
        unicorn::Settings().setValue( SETTING_CHECK_UPDATES, ui->updates->isChecked() );

        onSettingsSaved();
    }
}
void
IpodSettingsWidget::saveSettings()
{
    if ( hasUnsavedChanges() )
    {
        // save settings
        qDebug() << "Saving settings...";

        unicorn::AppSettings().setAlwaysAsk( ui->alwaysAsk->isChecked() );

        // we need to restart iTunes for this setting to take affect
        bool currentlyEnabled = unicorn::OldeAppSettings().deviceScrobblingEnabled();

#ifndef Q_WS_X11
        if ( currentlyEnabled != ui->deviceScrobblingEnabled->isChecked() )
        {
#ifdef Q_OS_WIN
            QList<unicorn::IPluginInfo*> plugins;
            unicorn::ITunesPluginInfo* iTunesPluginInfo = new unicorn::ITunesPluginInfo;
            plugins << iTunesPluginInfo;
            unicorn::CloseAppsDialog* closeApps = new unicorn::CloseAppsDialog( plugins, this );
            closeApps->setOwnsPlugins( true );
#else
            unicorn::CloseAppsDialog* closeApps = new unicorn::CloseAppsDialog( this );
#endif
            if ( closeApps->result() != QDialog::Accepted )
                closeApps->exec();
            else
                closeApps->deleteLater();

            if ( closeApps->result() == QDialog::Accepted )
            {
                unicorn::OldeAppSettings().setDeviceScrobblingEnabled( ui->deviceScrobblingEnabled->isChecked() );
            }
            else
            {
                ui->deviceScrobblingEnabled->setChecked( currentlyEnabled );

                // The user didn't close their media players
                QMessageBoxBuilder( this ).setTitle( tr( "Setting not changed" ) )
                        .setIcon( QMessageBox::Warning )
                        .setText( tr( "You did not close iTunes for this setting to change" ) )
                        .setButtons( QMessageBox::Ok )
                        .exec();
            }
        }
#endif

        onSettingsSaved();
    }
}
Esempio n. 6
0
void
SendLogsDialog::onError()
{
    QMessageBoxBuilder( this )
        .setIcon( QMessageBox::Information )
        .setTitle( tr("Couldn't send logs") )
        .setText( tr("Please try again later.") )
        .exec();

    ui.spinner->movie()->stop();
    ui.spinner->hide();
    ui.buttonBox->setEnabled( true );
    ui.moreInfoTextEdit->setEnabled( true );
}
Esempio n. 7
0
void
SendLogsDialog::onSuccess()
{
    ui.spinner->movie()->stop();
    ui.spinner->hide();

    QMessageBoxBuilder( this )
        .setIcon( QMessageBox::Information )
        .setTitle( tr("Logs sent") )
        .setText( tr( "Thank you, we will get back to you as soon as possible.") )
        .exec();

    ui.moreInfoTextEdit->clear();
    ui.buttonBox->setEnabled( true );
    ui.moreInfoTextEdit->setEnabled( true );
    QDialog::accept();
}
void
GeneralSettingsWidget::saveSettings()
{
    qDebug() << "has unsaved changes?" << hasUnsavedChanges();
    if ( hasUnsavedChanges() )
    {
        int currIndex = ui->languages->currentIndex();
        QString currLanguage = ui->languages->itemData( currIndex ).toString();

        if ( unicorn::AppSettings().value( "language", "" ) != currLanguage )
        {
            if ( currLanguage == ""  )
                QLocale::setDefault( QLocale::system() );
            else
                QLocale::setDefault( QLocale( currLanguage ) );

            unicorn::AppSettings().setValue( "language", currLanguage );
//            QMessageBoxBuilder( 0 )
//                .setIcon( QMessageBox::Information )
//                .setTitle( tr( "Restart needed" ) )
//                .setText( tr( "You need to restart the application for the language change to take effect." ) )
//                .exec();
        }

        // setting is for the 'Client' aplication for compatibility with old media player plugins
        unicorn::AppSettings( APP_LAUNCH ).setValue( SETTING_LAUNCH_ITUNES, ui->launch->isChecked() );

        unicorn::Settings().setValue( SETTING_NOTIFICATIONS, ui->notifications->isChecked() );
        unicorn::Settings().setValue( SETTING_LAST_RADIO, ui->lastRadio->isChecked() );
        unicorn::Settings().setValue( SETTING_SEND_CRASH_REPORTS, ui->sendCrashReports->isChecked() );
        unicorn::Settings().setValue( SETTING_CHECK_UPDATES, ui->updates->isChecked() );

#ifdef Q_OS_MAC
        int showWhereIndex = unicorn::Settings().value( SETTING_SHOW_WHERE, -1 ).toInt();
        bool showAs = ui->showWhere->currentIndex() != 1;

        unicorn::Settings().setValue( SETTING_SHOW_WHERE, ui->showWhere->currentIndex() );
        unicorn::Settings().setValue( SETTING_SHOW_AS, showAs );

        aApp->showAs( showAs );
        aApp->hideDockIcon( ui->showWhere->currentIndex() == 2 );

        if ( ( showWhereIndex != 2 && ui->showWhere->currentIndex() == 2 )
             || (showWhereIndex == 2 && ui->showWhere->currentIndex() != 2) )
        {
            int button = QMessageBoxBuilder( 0 )
                                .setIcon( QMessageBox::Question )
                                .setTitle( tr( "Restart now?" ) )
                                .setText( tr( "Would you like to restart now for the dock setting to take effect?" ) )
                                .setButtons( QMessageBox::Yes | QMessageBox::No )
                                .exec();

            if ( button == QMessageBox::Yes )
                aApp->restart();
        }
#else
        unicorn::Settings().setValue( SETTING_SHOW_AS, ui->showAs->isChecked() );
        aApp->showAs( ui->showAs->isChecked() );
#endif

        onSettingsSaved();
    }
}
void
GeneralSettingsWidget::saveSettings()
{
    qDebug() << "has unsaved changes?" << hasUnsavedChanges();
    if ( hasUnsavedChanges() )
    {
        bool restartNeeded = false;

        int currIndex = ui->languages->currentIndex();
        QString currLanguage = ui->languages->itemData( currIndex ).toString();

        if ( unicorn::AppSettings().value( "language", "" ) != currLanguage )
        {
            if ( currLanguage == ""  )
                QLocale::setDefault( QLocale::system() );
            else
                QLocale::setDefault( QLocale( currLanguage ) );

            unicorn::AppSettings().setValue( "language", currLanguage );

#ifdef Q_OS_MAC
            aApp->translate();
#endif

            restartNeeded = true;
        }

        // setting is for the 'Client' aplication for compatibility with old media player plugins
        unicorn::OldeAppSettings().setLaunchWithMediaPlayers( ui->launch->isChecked() );

        unicorn::Settings().setNotifications( ui->notifications->isChecked() );
        unicorn::Settings().setSendCrashReports( ui->sendCrashReports->isChecked() );
        unicorn::Settings().setCheckForUpdates( ui->updates->isChecked() );
        unicorn::Settings().setBetaUpdates( ui->beta->isChecked() );

        aApp->setBetaUpdates( ui->beta->isChecked() );

#ifdef Q_OS_MAC
        /// media keys
        unicorn::Settings().setValue( "mediaKeys", ui->mediaKeys->isChecked() );
        aApp->setMediaKeysEnabled( ui->mediaKeys->isChecked() );

        /// dock hiding
        bool showDockOld = unicorn::Settings().showDock();
        unicorn::Settings().setShowDock( ui->showDock->isChecked() );

        if ( showDockOld != ui->showDock->isChecked() )
        {
            // the setting has changed
            aApp->showDockIcon( ui->showDock->isChecked() );

            // Hiding the dock icon while the app is running is not supported on Snow Leopard
            if ( QSysInfo::MacintoshVersion <= QSysInfo::MV_10_6 && !ui->showDock->isChecked() )
                restartNeeded = true;
        }
#endif

        unicorn::Settings().setShowAS( ui->showAs->isChecked() );
        aApp->showAs( ui->showAs->isChecked() );

        onSettingsSaved();

        if ( restartNeeded )
        {
            int button = QMessageBoxBuilder( this )
                            .setIcon( QMessageBox::Question )
                            .setTitle( tr( "Restart now?" ) )
                            .setText( tr( "An application restart is required for the change to take effect. Would you like to restart now?" ) )
                            .setButtons( QMessageBox::Yes | QMessageBox::No )
                            .exec();

            if ( button == QMessageBox::Yes )
                aApp->restart();
        }
    }
}
Esempio n. 10
0
bool
unicorn::IPluginInfo::doInstall()
{
    bool success = false;

    QList<IPluginInfo*> plugins;
    plugins << this;

    CloseAppsDialog* closeApps = new CloseAppsDialog( plugins, 0 );

    if ( closeApps->result() != QDialog::Accepted )
        closeApps->exec();
    else
        closeApps->deleteLater();

    if ( closeApps->result() == QDialog::Accepted )
    {
        QString installer = QString( "\"%1\"" ).arg( QCoreApplication::applicationDirPath() + "/plugins/" + pluginInstaller() );
        qDebug() << installer;
        QProcess* installerProcess = new QProcess( this );
        QStringList args;
        if ( !m_verbose )
            args << "/SILENT";
        installerProcess->start( installer, args );
        success = installerProcess->waitForFinished( -1 );

        if ( m_verbose )
        {
            if ( !success )
            {
                // Tell the user that
                QMessageBoxBuilder( 0 ).setTitle( tr( "Plugin install error" ) )
                        .setIcon( QMessageBox::Information )
                        .setText( tr( "<p>There was an error updating your plugin.</p>"
                                      "<p>Please try again later.</p>" ) )
                        .setButtons( QMessageBox::Ok )
                        .exec();
            }
            else
            {
                // The user didn't closed their media players
                QMessageBoxBuilder( 0 ).setTitle( tr( "Plugin installed!" ) )
                        .setIcon( QMessageBox::Information )
                        .setText( tr( "<p>The %1 plugin has been installed.</p>"
                                      "<p>You're now ready to scrobble with %1.</p>" ).arg( name() ) )
                        .setButtons( QMessageBox::Ok )
                        .exec();
            }
        }
    }
    else
    {
        // The user didn't close their media players
        QMessageBoxBuilder( 0 ).setTitle( tr( "The %1 plugin hasn't been installed" ).arg( name() ) )
                .setIcon( QMessageBox::Warning )
                .setText( tr( "You didn't close %1 so its plugin hasn't been installed." ).arg( name() ) )
                .setButtons( QMessageBox::Ok )
                .exec();
    }

    return success;
}
Esempio n. 11
0
void
LoginDialog::onAuthenticated( WsReply* reply )
{
	switch (reply->error())
    {
        case Ws::NoError:
        {
            try
            {
                WsDomElement session = reply->lfm()["session"];
                
                // replace username; because eg. perhaps the user typed their
                // username with the wrong camel case
                QString username = session.optional( "name" ).text();
                if (username.size())
                    m_username = username;
                
                m_sessionKey = session["key"].nonEmptyText();
                m_subscriber = session["subscriber"].text() != "0";
                accept();
				
			#ifdef Q_WS_MAC
				ui.text->setText( "<b>Authentication successful" );
			#endif
                break;
            }
            catch (std::runtime_error& e)
            {
                qWarning() << e.what();
            }
			
            // FALL THROUGH!
        }
			
        case Ws::AuthenticationFailed:
            // COPYTODO
            QMessageBoxBuilder( this )
					.setIcon( QMessageBox::Critical )
					.setTitle( tr("Login Failed") )
					.setText( tr("Sorry, we don't recognise that username, or you typed the password wrongly.") )
					.exec();
            break;
			
        default:
            // COPYTODO
            QMessageBoxBuilder( this )
					.setIcon( QMessageBox::Critical )
					.setTitle( tr("Last.fm Unavailable") )
					.setText( tr("There was a problem communicating with the Last.fm services. Please try again later.") )
					.exec();
            break;
			
        case Ws::UrProxyIsFuckedLol:
        case Ws::UrLocalNetworkIsFuckedLol:
            // TODO proxy prompting?
            // COPYTODO
            QMessageBoxBuilder( this )
					.setIcon( QMessageBox::Critical )
					.setTitle( tr("Cannot connect to Last.fm") )
					.setText( tr("Last.fm cannot be reached. Please check your firewall or proxy settings.") )
					.exec();
        #ifdef WIN32
            // show Internet Settings Control Panel
            HMODULE h = LoadLibraryA( "InetCpl.cpl" );
            if (!h) break;
			BOOL (WINAPI *cpl)(HWND) = (BOOL (WINAPI *)(HWND)) GetProcAddress( h, "LaunchConnectionDialog" );
            if (cpl) cpl( winId() );
            FreeLibrary( h );
        #endif
            break;
    }
    
    
#ifdef Q_WS_MAC
	ui.transient->hide();
#else
    // do last, otherwise it looks weird
    ui.retranslateUi( this ); //resets Window title
    ok()->setEnabled( true );
    ui.spinner->hide();
#endif
}