Exemplo n.º 1
0
void
DiagnosticsDialog::onScrobbleIPodClicked()
{
#ifndef Q_WS_X11    
    if (m_twiddly) { qWarning() << "m_twiddly already running. Early out."; return; }
    
    QStringList args = (QStringList() 
                    << "--device" << "diagnostic" 
                    << "--vid" << "0000" 
                    << "--pid" << "0000" 
                    << "--serial" << "UNKNOWN");

    bool const isManual = ( ui.ipod_type->currentIndex() == 1 );
    if (isManual)
        args += "--manual";

    QString path = unicorn::CoreApplication::log( twiddly::applicationName() ).absoluteFilePath();
#ifndef NDEBUG
    path = path.remove( ".debug" ); //because we run the release twiddly always
#endif    

    // we seek to the end below, but then twiddly's logger pretruncates the file
    // which then means our seeked position is beyond the file's end, and we
    // thus don't show any log output
#ifdef WIN32
    Logger::truncate( (wchar_t*) path.utf16() );
#else
    QByteArray const cpath = QFile::encodeName( path );
    Logger::truncate( cpath.data() );
#endif

    m_ipod_log = new QFile( path );
    m_ipod_log->open( QIODevice::ReadOnly );
    m_ipod_log->seek( m_ipod_log->size() );
    ui.ipod_log->clear();    
    
    m_twiddly = new QProcess( this );
    connect( m_twiddly, SIGNAL(finished( int, QProcess::ExitStatus )), SLOT(onTwiddlyFinished( int, QProcess::ExitStatus )) );
    connect( m_twiddly, SIGNAL(error( QProcess::ProcessError )), SLOT(onTwiddlyError( QProcess::ProcessError )) );
    m_twiddly->start( twiddly::path(), args );
    
    m_ipod_log->setParent( m_twiddly );    
    
    QTimer* timer = new QTimer( m_twiddly );
    timer->setInterval( 10 );
    connect( timer, SIGNAL(timeout()), SLOT(poll()) );
    timer->start();
#endif
}
Exemplo n.º 2
0
DeviceScrobbler::DoTwiddlyResult
DeviceScrobbler::doTwiddle( bool manual )
{
#ifndef Q_WS_X11
    if ( unicorn::CloseAppsDialog::isITunesRunning() )
    {
        if ( isITunesPluginInstalled() )
        {
            if ( m_twiddly )
            {
                qWarning() << "m_twiddly already running. Early out.";
                return AlreadyRunning;
            }

            //"--device diagnostic --vid 0000 --pid 0000 --serial UNKNOWN

            QStringList args = (QStringList()
                         << "--device" << "background"
                         << "--vid" << "0000"
                         << "--pid" << "0000"
                         << "--serial" << "UNKNOWN");

            if ( manual )
                args += "--manual";

            m_twiddly = new QProcess( this );
            connect( m_twiddly, SIGNAL(finished( int, QProcess::ExitStatus )), SLOT(onTwiddlyFinished( int, QProcess::ExitStatus )) );
            connect( m_twiddly, SIGNAL(error( QProcess::ProcessError )), SLOT(onTwiddlyError( QProcess::ProcessError )) );
#ifdef Q_OS_WIN
            m_twiddly->start( QDir( QCoreApplication::applicationDirPath() ).absoluteFilePath( "iPodScrobbler.exe" ), args );
#else
            m_twiddly->start( QDir( QCoreApplication::applicationDirPath() ).absoluteFilePath( "../Helpers/iPodScrobbler" ), args );
#endif
            return Started;
        }
        else
            return ITunesPluginNotInstalled;
    }
#endif //  Q_WS_X11
    return ITunesNotRunning;
}