void
ITunesPluginInstaller::install()
{
    qDebug() << "Found installed iTunes plugin?" << isPluginInstalled();

    QString installedVersion;
    QString shippedVersion;

    disableLegacyHelperApp();

    if ( isPluginInstalled() ) 
    {
        installedVersion = pListVersion( k_iTunesPluginDir + kPListFile );
        qDebug() << "Found installed iTunes plugin version:" << installedVersion;
    }
    else
        //TODO don't bootstrap if installation fails
        m_needsTwiddlyBootstrap = true;

    shippedVersion = pListVersion( k_shippedPluginDir + kPListFile );
    if ( shippedVersion.isEmpty() )
    {
        qDebug() << "Could not locate shipped iTunes plugin!";
    }
    else
    {
        qDebug() << "Found shipped iTunes plugin version:" << shippedVersion;

        if ( installedVersion != shippedVersion )
        {
            qDebug() << "Installing shipped iTunes plugin...";

            CloseAppsDialog* closeApps = new CloseAppsDialog();

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

            if ( !removeInstalledPlugin() )
            {
                qDebug() << "Removing installed plugin from" << k_iTunesPluginDir << "failed!";
            }
            else
            {
                qDebug() << "Successfully removed installed plugin.";

                if ( installPlugin() )
                {
                    qDebug() << "Successfully installed the plugin.";
                }
                else
                    qDebug() << "Installing the plugin failed!";
            }
        }
        else
            qDebug() << "Installed iTunes plugin is up-to-date.";
    }
}
void
IpodSettingsWidget::saveSettings()
{
    if ( hasUnsavedChanges() )
    {
        // save settings
        qDebug() << "Saving settings...";

        unicorn::AppSettings().setValue( SETTING_ALWAYS_ASK, ui->alwaysAsk->isChecked() );

        // we need to restart iTunes for this setting to take affect
        bool currentlyEnabled = unicorn::AppSettings( OLDE_PLUGIN_SETTINGS ).value( SETTING_OLDE_ITUNES_DEVICE_SCROBBLING_ENABLED, true ).toBool();

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

            if ( closeApps->result() == QDialog::Accepted )
            {
                unicorn::AppSettings( OLDE_PLUGIN_SETTINGS ).setValue( SETTING_OLDE_ITUNES_DEVICE_SCROBBLING_ENABLED, 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();
    }
}
Example #3
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;
}