~ubuntu-branches/ubuntu/lucid/lastfm/lucid

« back to all changes in this revision

Viewing changes to src/configwizard.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Devid Filoni
  • Date: 2008-07-14 16:46:20 UTC
  • mfrom: (1.1.7 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080714164620-67hoz9fs177wpgmr
Tags: 1:1.5.1.31879.dfsg-1ubuntu1
* Merge from Debian unstable (LP: #248100), remaining changes:
  - debian/rules: add dh_icons call
  + debian/control:
    - switch iceweasel to firefox in Recommends field
    - modify debhelper version to >= 5.0.51~
    - modify Maintainer to Ubuntu MOTU Developers

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include "WebService.h"
26
26
#include "LastMessageBox.h"
27
27
#include "container.h"
28
 
#include "Bootstrapper/iTunesBootstrapper.h"
29
 
#include "Bootstrapper/PluginBootstrapper.h"
 
28
 
 
29
#ifndef Q_WS_X11
 
30
    #include "Bootstrapper/iTunesBootstrapper.h"
 
31
    #include "Bootstrapper/PluginBootstrapper.h"
 
32
#endif
30
33
 
31
34
 
32
35
using namespace std;
39
42
******************************************************************************/
40
43
ConfigWizard::ConfigWizard( QWidget* parent, Mode mode,  QString uid )
41
44
        : BaseWizard( parent ),
42
 
          m_page8( NULL ),
43
45
          m_mode( mode ),
44
46
          m_bootstrapAllowed( false ),
45
47
          m_didBootstrap( false ),
134
136
    m_doneInfoPlugin =
135
137
        tr("The plugin(s) you selected have now been installed.");
136
138
 
137
 
    m_doneInfoMediaDeviceYes = 
138
 
        tr("Your iPod has now been connected to your Last.fm account");
139
 
    m_doneInfoMediaDeviceNo = 
140
 
        tr("Your iPod has not been connected to your Last.fm account");
141
 
 
142
139
    #ifdef Q_WS_MAC
143
140
        setTitle(tr("Set up Last.fm"));
144
141
    #else 
150
147
        case Login:
151
148
            m_pageOffset = 0;
152
149
          #ifdef WIN32
153
 
            setNumPages(10);
 
150
            setNumPages(11);
154
151
          #elif defined Q_WS_MAC
155
 
            setNumPages(6);
 
152
            setNumPages(7);
156
153
          #elif defined Q_WS_X11
157
154
            setNumPages(3);
158
155
          #endif
164
161
            #endif
165
162
            
166
163
            setTitle(tr("Set up Last.fm for your iPod"));
167
 
            m_pageOffset = 7;
168
 
            setNumPages( 3 );
 
164
            m_pageOffset = 9;
 
165
            setNumPages( 2 );
169
166
            break;            
170
167
 
171
168
        case Plugin:
242
239
            connect( &m_infoGetter, SIGNAL( progressMade( int, int ) ),
243
240
                     m_page4,       SLOT( setProgress( int, int ) ) );
244
241
            connect( &m_infoGetter, SIGNAL( statusChange( QString ) ),
 
242
            
245
243
                     m_page4,       SIGNAL( detailedInfoChanged( QString ) ) );
246
244
            m_page4->setInfo( m_detectInfo );
247
245
 
288
286
                                list[0].SetPlayerName( "iTunes" );
289
287
                                list[0].SetBootstrapType( "Client" );
290
288
                                
291
 
                        #else //Q_WS_MAC
 
289
                        #else //not Q_WS_MAC
292
290
                        
293
291
                    vector<CPluginInfo>& list = The::container().getPluginList();
294
292
            
295
293
                    if( list.empty() )
296
294
                        list = mAvailPlugins;
297
295
        
298
 
                        #endif //!Q_WS_MAC
 
296
                        #endif
299
297
 
300
298
            m_page7->populate( list );
301
299
 
303
301
        }
304
302
        break;
305
303
 
306
 
        case 7:
307
 
        {
308
 
            const QString& info = m_mediaDeviceQuestion;
309
 
            m_page8 = new WizardMediaDeviceAskPage(this, info);
310
 
            adjustSize();
311
 
 
312
 
            return m_page8;
313
 
        }
314
 
        break;
315
 
 
316
304
        case 8:
317
305
        {
 
306
            #ifndef Q_WS_X11
318
307
            // Create a bootstrapper progress page
319
 
 
320
308
            const QString& info = m_bootstrapInfo;
321
309
 
322
310
            m_page9 = new WizardBootstrapPage(this, info);
339
327
                         this,              SLOT  (onBootstrapDone( int ) ) );
340
328
            }
341
329
 
342
 
 
343
330
            return m_page9;
 
331
            #endif
344
332
        }
345
333
        break;
346
334
 
347
 
 
348
335
        case 9:
349
336
        {
 
337
            switch (m_mode)
 
338
            {
 
339
              #ifndef Q_WS_X11
 
340
                case MediaDevice:
 
341
                case Login:
 
342
                case Plugin:
 
343
                    if ( twiddlyBootstrapRequired() )
 
344
                        break;
 
345
              #endif
 
346
 
 
347
                // FALL THROUGH
 
348
 
 
349
                default:
 
350
                    // don't do the twiddly bootstrap
 
351
                    // returning 0 forces the basewizard to do nextButtonClicked()
 
352
                    m_pageOffset++;
 
353
                    setNumPages( numPages() - 1 );
 
354
                    return 0;
 
355
            }
 
356
 
 
357
            m_pageTwiddly = new WizardTwiddlyBootstrapPage( this );
 
358
            connect( m_pageTwiddly, SIGNAL(done()), SLOT(onTwiddlyBootstrapDone()) );
 
359
            enableNext( false );
 
360
            return m_pageTwiddly;
 
361
        }
 
362
        break;
 
363
 
 
364
        case 10:
 
365
        {
350
366
            QString info;
351
367
 
352
368
            if ( m_mode == Login )
361
377
            }
362
378
            else if ( m_mode == MediaDevice )
363
379
            {
364
 
                if ( m_page8 && m_page8->uiWidget.yesButton->isChecked() )
365
 
                    info = m_doneInfoMediaDeviceYes;
366
 
                else
367
 
                    info = m_doneInfoMediaDeviceNo;
 
380
                info = tr( "Last.fm is now ready for iPod scrobbling. Scrobbles should show up on your profile within 20 minutes of syncing your iPod with iTunes." );
368
381
            }
369
382
 
 
383
            #ifndef Q_WS_X11
370
384
            if ( m_didBootstrap )
371
385
            {
372
386
                info += "<p>"; // we may have already got a text from above
394
408
                            info += m_doneInfoPluginBootstrapExtra;
395
409
                        }
396
410
                        break;
 
411
 
 
412
                    case AbstractBootstrapper::Bootstrap_Denied:
 
413
                        info += tr( "It was not possible to import your listening history. "
 
414
                                    "Could it be that you've already imported it?" );
 
415
                        break;
 
416
 
 
417
                    default:
 
418
                        Q_ASSERT( !"unhandled" );
 
419
                        break;
 
420
 
397
421
                }
398
422
            }
 
423
            #endif
399
424
 
400
425
            m_page10 = new WizardInfoPage( this, info );
401
426
            enableBack(false);
413
438
******************************************************************************/
414
439
QString
415
440
ConfigWizard::headerForPage(
416
 
    int index)
 
441
    int index )
417
442
{
418
443
    index += m_pageOffset;
419
444
 
428
453
        case 6: return m_bootstrapHeader;     break;
429
454
        case 7: return m_mediaDeviceHeader;   break;
430
455
        case 8: return m_bootstrapHeader;     break;
431
 
        case 9: return m_doneHeader;          break;
 
456
        case 9: return tr("Preparing for iPod Scrobbling");
 
457
        case 10: return m_doneHeader;          break;
432
458
    }
433
459
 
434
460
    return "";
462
488
        case 1:
463
489
        {
464
490
            // Leaving login page, verify login details
465
 
            QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
 
491
            QApplication::setOverrideCursor( Qt::WaitCursor );
466
492
            m_page2->verify();
467
493
 
468
494
            //disable next / forward buttons during verification
513
539
 
514
540
            if ( m_page7 && m_page7->selectedPlugin() != NULL )
515
541
            {
516
 
 
517
542
                CPluginInfo* bootstrapPlugin = m_page7->selectedPlugin();
518
543
 
519
544
                if( !bootstrapPlugin )
522
547
                    return;
523
548
                }
524
549
 
 
550
                #ifndef Q_WS_X11
525
551
                switch( bootstrapPlugin->GetBootstrapType() )
526
552
                {
527
553
                case CPluginInfo::BOOTSTRAP_CLIENT:
545
571
                    Q_ASSERT( !"not possible" );
546
572
                }
547
573
 
548
 
 
549
574
                setNumPages( numPages() - 1 );
550
575
                m_pageOffset++;
551
576
 
558
583
                nextButtonClicked();
559
584
 
560
585
                m_bootstrapper->bootStrap();
561
 
               
 
586
 
562
587
                if( !dynamic_cast<AbstractFileBootstrapper*>( m_bootstrapper ) )
563
588
                {
564
589
                    onBootstrapDone( AbstractBootstrapper::Bootstrap_Ok );
565
590
                }
 
591
                #endif
566
592
 
567
593
                return;
568
594
            }
574
600
        }
575
601
        break;
576
602
 
577
 
        case 7:
578
 
        {
579
 
            // This is where the iPod connect wizard starts
580
 
            if ( m_page8 )
581
 
            {
582
 
                // If m_page8 exists, we have been asked the iPod question
583
 
                if ( m_page8->uiWidget.yesButton->isChecked() )
584
 
                {
585
 
                    The::settings().addMediaDevice( m_uid,
586
 
                                                    m_page8->uiWidget.userComboBox->itemText( m_page8->uiWidget.userComboBox->currentIndex() ) );
587
 
 
588
 
/*                  if ( !The::settings().bootstrap() )
589
 
                    {
590
 
                        BaseWizard::nextButtonClicked();
591
 
                        return;
592
 
                    }
593
 
                    else*/
594
 
                    {
595
 
                        setNumPages( numPages() - 1 );
596
 
                        m_pageOffset++;
597
 
                    }
598
 
                }
599
 
                else
600
 
                {
601
 
                    The::settings().addMediaDevice( m_uid, "<disabled>" );
602
 
                    setNumPages( numPages() - 1 );
603
 
                    m_pageOffset++;
604
 
                }
605
 
            }
606
 
        }
607
 
        break;
608
 
 
609
603
        case 8:
610
604
        {
611
 
            // Leaving the bootstrap progress screen
612
 
                       
 
605
            // next clicked on bootstrap progress page
613
606
        }
614
607
        break;
615
 
 
 
608
        
616
609
        case 9:
617
610
        {
 
611
            // next clicked on Twiddly Bootstrap page
 
612
        }
 
613
        break;
 
614
 
 
615
        case 10:
 
616
        {
618
617
            // Done page
619
618
        }
620
619
        break;
847
846
void
848
847
ConfigWizard::onBootstrapDone( int status )
849
848
{
 
849
    #ifndef Q_WS_X11
850
850
    bool pluginBootstrap = dynamic_cast<PluginBootstrapper*>( m_bootstrapper );
851
851
    if( pluginBootstrap )
852
852
    {
882
882
 
883
883
        BaseWizard::nextButtonClicked();
884
884
    }   // !pluginBootstrap
 
885
    #endif
885
886
}
886
887
 
887
888
 
888
889
int
889
890
ConfigWizard::exec()
890
891
{
 
892
    if (m_mode == MediaDevice && !twiddlyBootstrapRequired())
 
893
        return QDialog::Accepted;
 
894
        
891
895
    s_wizardRunning = true;
892
896
    activateWindow();
893
897
 
901
905
 
902
906
    return r;
903
907
}
 
908
 
 
909
 
 
910
void
 
911
ConfigWizard::onTwiddlyBootstrapDone()
 
912
{
 
913
    BaseWizard::nextButtonClicked();
 
914
    enableNext( true );
 
915
}
 
916
 
 
917
 
 
918
bool
 
919
ConfigWizard::twiddlyBootstrapRequired()
 
920
{
 
921
  #ifdef Q_OS_WIN
 
922
    // Check plugin version is new enough to bootstrap
 
923
    if ( The::settings().pluginVersion( "itw" ).split( '.' ).value( 0 ).toInt() < 3 )
 
924
        return false;
 
925
  #endif
 
926
    
 
927
    QProcess p;
 
928
    p.start( TWIDDLY_PATH, QStringList() << "--bootstrap-needed?" );
 
929
    
 
930
    if ( !p.waitForFinished() )
 
931
        // better to let the plugin manage the bootstrap if we can't be sure
 
932
        // it's needed, returning true could lead to misscrobbles
 
933
        return false;
 
934
 
 
935
    return p.exitCode();
 
936
}