upnpsettings/appwizard/src/cupnpappwizard.cpp
branchIOP_Improvements
changeset 40 08b5eae9f9ff
parent 39 6369bfd1b60d
child 41 b4d83ea1d6e2
equal deleted inserted replaced
39:6369bfd1b60d 40:08b5eae9f9ff
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:      Implementation of setup Wizard
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include <AknUtils.h>
       
    25 #include <featmgr.h>
       
    26 #include <bautils.h>
       
    27 #include <StringLoader.h>
       
    28 #include <eikspmod.h>
       
    29 #include <eikclb.h>
       
    30 #include <aknview.h>
       
    31 #include <aknViewAppUi.h>
       
    32 #include <eikprogi.h>
       
    33 #include <aknmessagequerydialog.h>  //CAknMessageQueryDialog
       
    34 #include <aknlistquerydialog.h>     //CAknListQueryDialog
       
    35 #include <es_sock.h> //RSocketServ
       
    36 #include <commdb.h>
       
    37 #include <cdbcols.h>
       
    38 #include <WlanCdbCols.h>
       
    39 #include <wlanmgmtinterface.h>
       
    40 #include <aknnotewrappers.h> //CAknWaitDialog
       
    41 #include <AknWaitDialog.h>
       
    42 #include <cupnpappwizard.rsg>
       
    43 #include <commdb.h> // COMMS DB - for checking AP validity
       
    44 
       
    45 // upnp stack
       
    46 #include "upnpstring.h" //String::ToUnicodeL
       
    47 
       
    48 // ADO internal interfaces
       
    49 #include "upnpsettingsengine.h" //Friendly name, AP
       
    50 #include "upnpsettingsengine.hrh" //AP
       
    51 #include "cupnpmultiselectionui.h" //CUPnPMultiSelectionUi
       
    52 
       
    53 // this component
       
    54 #include "cupnpappwizard.h"
       
    55 
       
    56 // logging facility
       
    57 _LIT( KComponentLogfile, "upnpsetupwizard.txt");
       
    58 #include "upnplog.h"
       
    59 
       
    60 // CONSTANTS
       
    61 // Filename of rsc file
       
    62 _LIT( KUPnPSetupWizardRscFile, "\\resource\\cupnpappwizard.rsc" );
       
    63 
       
    64 // ============================ MEMBER FUNCTIONS ============================
       
    65 
       
    66 // --------------------------------------------------------------------------
       
    67 // CUPnPAppWizard::CUPnPAppWizard
       
    68 // --------------------------------------------------------------------------
       
    69 //
       
    70 CUPnPAppWizard::CUPnPAppWizard()
       
    71     {
       
    72     __LOG("CUPnPAppWizard::CUPnPAppWizard");
       
    73     iDialogDismissed = ETrue;
       
    74     iFeatureManagerInitialized = EFalse;
       
    75     }
       
    76 
       
    77 // --------------------------------------------------------------------------
       
    78 // CUPnPAppWizard::ConstructL()
       
    79 // Symbian 2nd phase constructor can leave.
       
    80 // --------------------------------------------------------------------------
       
    81 //
       
    82 void CUPnPAppWizard::ConstructL( const TDesC& aFirstStepText,
       
    83                                  CUPnPFileSharingEngine* aEng )
       
    84     {
       
    85     __LOG("CUPnPAppWizard::ConstructL begin");
       
    86 
       
    87     iShareImgAndVideoArray = new (ELeave) CArrayFixFlat<TInt>(3);
       
    88     iShareMusicArray = new (ELeave) CArrayFixFlat<TInt>(3);
       
    89     
       
    90     iCoeEnv = CEikonEnv::Static();
       
    91     RFs& fileSession = iCoeEnv->FsSession();
       
    92 
       
    93 
       
    94     // Load resource file
       
    95     TFileName rscFileName( KUPnPSetupWizardRscFile );
       
    96     TFileName dllName;
       
    97     Dll::FileName( dllName );
       
    98     TBuf<2> drive = dllName.Left( 2 ); // Drive letter followed by ':' 
       
    99     rscFileName.Insert( 0, drive );
       
   100     
       
   101     // Get the exact filename of the resource file
       
   102     BaflUtils::NearestLanguageFile( fileSession, rscFileName );
       
   103     // Check if the resource file exists or not
       
   104     if ( !BaflUtils::FileExists( fileSession, rscFileName ) )
       
   105         {
       
   106         User::Leave( KErrNotFound );
       
   107         }
       
   108     TInt err( KErrNone );
       
   109     TRAP( err, iResFileOffset = iCoeEnv->AddResourceFileL( rscFileName ) );
       
   110 
       
   111     FeatureManager::InitializeLibL();
       
   112     iFeatureManagerInitialized = ETrue;
       
   113 
       
   114     // Get AppUI pointer
       
   115     iAppUi = static_cast<CAknViewAppUi*>( iCoeEnv->EikAppUi() );
       
   116 
       
   117     iSetEng = CUPnPSettingsEngine::NewL();
       
   118     if ( aEng )
       
   119         {
       
   120         iFileEng = aEng;
       
   121         }
       
   122     else
       
   123         {
       
   124         User::Leave( KErrArgument);
       
   125         }
       
   126     iFileEng->SetObserver( this );
       
   127     iFirstStepText = aFirstStepText.AllocL();
       
   128 
       
   129     iSharingState = iFileEng->SharingStateL();
       
   130     iSelections = new (ELeave) CSelectionStorage( iSetEng, iFileEng );
       
   131     __LOG("CUPnPAppWizard::ConstructL end");
       
   132     }
       
   133 
       
   134 // --------------------------------------------------------------------------
       
   135 // CUPnPAppWizard::NewL()
       
   136 // Two-phased constructor.
       
   137 // --------------------------------------------------------------------------
       
   138 //
       
   139 EXPORT_C CUPnPAppWizard* CUPnPAppWizard::NewL( const TDesC& aFirstStepText,
       
   140                                                CUPnPFileSharingEngine* aEng )
       
   141     {
       
   142     __LOG("CUPnPAppWizard::NewL begin");
       
   143 
       
   144     CUPnPAppWizard* self = new ( ELeave) CUPnPAppWizard();
       
   145     CleanupStack::PushL( self );
       
   146 
       
   147     self->ConstructL( aFirstStepText, aEng );
       
   148 
       
   149     CleanupStack::Pop();
       
   150     __LOG("CUPnPAppWizard::NewL end");
       
   151     return self;
       
   152     }
       
   153 
       
   154 // --------------------------------------------------------------------------
       
   155 // Destructor
       
   156 // --------------------------------------------------------------------------
       
   157 //
       
   158 CUPnPAppWizard::~CUPnPAppWizard()
       
   159     {
       
   160     __LOG("CUPnPAppWizard::~CUPnPAppWizard begin");
       
   161 
       
   162     if ( iFeatureManagerInitialized )
       
   163         {
       
   164         FeatureManager::UnInitializeLib();
       
   165         }
       
   166 
       
   167     // Un-Load resource file
       
   168     if ( iResFileOffset )
       
   169         {
       
   170         CEikonEnv::Static()->DeleteResourceFile( iResFileOffset );
       
   171         iResFileOffset = 0;
       
   172         }
       
   173 
       
   174     delete iSetEng;
       
   175 
       
   176     delete iSelections;
       
   177     delete iIapNameArr;
       
   178     delete iFirstStepText;
       
   179 
       
   180     if ( iWait.IsStarted() )
       
   181         {
       
   182         if ( iWait.CanStopNow() )
       
   183             {
       
   184             iWait.AsyncStop();
       
   185             }
       
   186         else
       
   187             {
       
   188             __LOG("CUPnPAppWizard: \
       
   189 Error cant stop iWait");
       
   190             }
       
   191         }
       
   192 
       
   193     if ( iFileEng )
       
   194         {
       
   195         iFileEng->SetObserver( NULL );
       
   196         }
       
   197 
       
   198     delete iShareImgAndVideoArray;
       
   199     delete iShareMusicArray;
       
   200     
       
   201     __LOG("CUPnPAppWizard::~CUPnPAppWizard end");
       
   202     }
       
   203 
       
   204 // --------------------------------------------------------------------------
       
   205 // CUPnPAppWizard::StartL
       
   206 // The main loop of setup wizard
       
   207 // --------------------------------------------------------------------------
       
   208 //
       
   209 
       
   210 EXPORT_C TInt CUPnPAppWizard::StartL( )
       
   211     {
       
   212     __LOG("CUPnPAppWizard::StartL begin");
       
   213     TInt ret(KErrNone);
       
   214     do
       
   215         {
       
   216         switch ( iStep )
       
   217             {
       
   218         case EInfo1:
       
   219             {
       
   220             ret = ShowFirstStepL( R_UPNP_WIZARD_POPUP_DIALOG_1 );
       
   221             }
       
   222             break;
       
   223         case EInfo2:
       
   224             {
       
   225             ret = ShowInfoStepL( R_UPNP_WIZARD_POPUP_DIALOG_2 );
       
   226             }
       
   227             break;
       
   228         case EDeviceName:
       
   229             {
       
   230             ret = ShowTextStepL( R_UPNP_WIZARD_POPUP_DIALOG_3 );
       
   231             }
       
   232             break;
       
   233         case EInfo4:
       
   234             {
       
   235             ret = ShowInfoStepL( R_UPNP_WIZARD_POPUP_DIALOG_4 );
       
   236             }
       
   237             break;
       
   238         case EAccessPoint:
       
   239             {
       
   240             ret = ShowListStepL( R_UPNP_WIZARD_POPUP_DIALOG_5 );
       
   241             }
       
   242             break;
       
   243         case EInfo6:
       
   244             {
       
   245             ret = ShowInfoStepL( R_UPNP_WIZARD_POPUP_DIALOG_6 );
       
   246             }
       
   247             break;
       
   248         case EShareImages:
       
   249             {
       
   250             ret = ShowMultiselectionStepL( R_UPNP_WIZARD_HEAD_7_TEXT );
       
   251             }
       
   252             break;
       
   253         case EShareMusic:
       
   254             {
       
   255             ret = ShowMultiselectionStepL(R_UPNP_WIZARD_HEAD_8_TEXT );
       
   256             }
       
   257             break;
       
   258         case EInfo9:
       
   259             {
       
   260             if ( iSelections->HasSomethingToShare() )
       
   261                 {
       
   262                 ret = ShowInfoStepL( R_UPNP_WIZARD_POPUP_DIALOG_9A );
       
   263                 }
       
   264             else
       
   265                 {
       
   266 				iFileEng->SetObserver( this );
       
   267                 ret = ShowInfoStepL( R_UPNP_WIZARD_POPUP_DIALOG_9B );
       
   268                 }
       
   269             }
       
   270             break;
       
   271         case EStoreSettings:
       
   272             {
       
   273             iSelections->StoreSettingsL();
       
   274             if ( !iSharingState && iSelections->HasSomethingToShare() )
       
   275                 {
       
   276                 __LOG("CUPnPAppWizard::StartL: \
       
   277 Staring sharing..");
       
   278                 // need to wait for DialogDismissed()
       
   279                 iDialogDismissed = EFalse;
       
   280                 ShowWaitNoteL( R_UPNP_WIZARD_STARTING_FILE_SHARING_NOTE );
       
   281                 DisplayInfoL( R_UPNP_WIZARD_UPDATING_CONTENT_HEADER,
       
   282                               R_UPNP_WIZARD_UPDATING_CONTENT_NOTE_TEXT,
       
   283                               R_UPNP_WIZARD_INFO_QUERY );
       
   284                 }
       
   285             else if ( iSharingState && !iSelections->HasSomethingToShare() )
       
   286                 {
       
   287                 __LOG("CUPnPAppWizard::StartL: \
       
   288 Stopping sharing..");
       
   289                 iFileEng->SetSharingStateL( EFalse );
       
   290                 iWait.Start();
       
   291                 }
       
   292 
       
   293             // Stores also videofiles
       
   294             iSelections->ImageStoreSharedFilesL();
       
   295 
       
   296 
       
   297             }
       
   298             break;
       
   299         default :
       
   300             {
       
   301             __LOG("CUPnPAppWizard::StartL: default!");
       
   302             _LIT(KUser, "USER");
       
   303             User::Panic(KUser, 0);
       
   304             }
       
   305             break;
       
   306             }
       
   307         SetNextStep( ret );
       
   308         }
       
   309     while ( iStep != EFinished );
       
   310     __LOG("CUPnPAppWizard::StartL end");
       
   311     return ret;
       
   312     }
       
   313 
       
   314 // --------------------------------------------------------------------------
       
   315 // CUPnPAppWizard::ShowListStepL
       
   316 // Show the UI dialog with selection list
       
   317 // --------------------------------------------------------------------------
       
   318 //
       
   319 TInt CUPnPAppWizard::ShowListStepL( TInt aMain )
       
   320     {
       
   321     __LOG("CUPnPAppWizard::ShowListStepL begin");
       
   322     TInt returnValue(KErrNone);
       
   323     TInt currentSel(0);
       
   324     TInt selectedIap(1);
       
   325     TInt oldIap;
       
   326     iSelections->GetIapId( oldIap );
       
   327     TBool sharingCheck;
       
   328     RArray<TInt64> iapIdArr;
       
   329     TInt oldIapCount(0);
       
   330 
       
   331     if ( !iIapNameArr )
       
   332         {
       
   333         iIapNameArr = new (ELeave) CDesCArrayFlat(3);
       
   334         }
       
   335 
       
   336     do
       
   337         {
       
   338         sharingCheck = ETrue;// ok to exit
       
   339         currentSel = 0;
       
   340         iSelections->InitializeIapArraysL( iIapNameArr, iapIdArr );
       
   341         CUPnPSettingsEngine::GetWLANAccessPointsL( iIapNameArr, iapIdArr );
       
   342         
       
   343         // Set correct initial selection for ui
       
   344         if ( currentSel != KUPnPCreateNewInd )
       
   345             {
       
   346             iSelections->GetCurrentSelection( currentSel, iapIdArr );
       
   347             }
       
   348         else
       
   349             {
       
   350             // ..in case user has selected "Create new"
       
   351             if ( !iSharingState &&
       
   352                  returnValue &&
       
   353                  oldIapCount )
       
   354                 {
       
   355                 if ( oldIapCount != iapIdArr.Count() )
       
   356                     {
       
   357                     currentSel = iapIdArr.Count() - 1;
       
   358                     }
       
   359                 }
       
   360             }
       
   361         CAknListQueryDialog* dlg = new
       
   362             ( ELeave ) CAknListQueryDialog( &currentSel );
       
   363 
       
   364         if ( !dlg )
       
   365             {
       
   366             User::Leave( KErrNoMemory );
       
   367             }
       
   368         dlg->PrepareLC( aMain );
       
   369         
       
   370         HBufC* head = StringLoader::LoadLC( R_UPNP_WIZARD_HEAD_5_TEXT );
       
   371         dlg->SetHeaderTextL( *head );
       
   372         CleanupStack::PopAndDestroy( head );
       
   373     
       
   374         dlg->SetItemTextArray( iIapNameArr );
       
   375         dlg->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   376 
       
   377         CListBoxView* listBoxView = dlg->ListBox()->View();
       
   378         listBoxView->SetCurrentItemIndex( currentSel );
       
   379 
       
   380         returnValue = dlg->RunLD();
       
   381 
       
   382         TInt c( iapIdArr.Count() );
       
   383 
       
   384         if ( currentSel == KUPnPCreateNewInd )
       
   385             {
       
   386             /* call to Wlan creator API */
       
   387             
       
   388             __LOG("CUPnPAppWizard::ShowListStepL:\
       
   389 Create new IAP..");
       
   390             CUPnPSettingsEngine::CreateAccessPointL();
       
   391             oldIapCount = iapIdArr.Count();
       
   392             }
       
   393         else if ( currentSel-1 < c )
       
   394             {
       
   395             // set last iap as selected if user succesfully created new iap
       
   396             selectedIap = iapIdArr[ currentSel ];
       
   397             }
       
   398         if ( iSharingState &&
       
   399              ( selectedIap != oldIap ) &&
       
   400              returnValue )
       
   401             {
       
   402             // show info note if sharing is on and user pressed ok
       
   403             sharingCheck = EFalse;
       
   404             ShowInfoNoteL( R_UPNP_WIZARD_IAP_TURN_SHARING_OFF );
       
   405             }
       
   406         iapIdArr.Reset();
       
   407         iIapNameArr->Reset();
       
   408         }
       
   409     while ( currentSel == KUPnPCreateNewInd ||
       
   410             ! sharingCheck );
       
   411 
       
   412     iSelections->SetIapId( selectedIap, currentSel );
       
   413 
       
   414     iapIdArr.Reset();
       
   415     __LOG("CUPnPAppWizard::ShowListStepL end");
       
   416     return returnValue;
       
   417     }
       
   418 
       
   419 // ---------------------------------------------------------
       
   420 // CUPnPAppWizard::ShowTextStepL( TInt aMain )
       
   421 // Shows popup with text and header
       
   422 // ---------------------------------------------------------
       
   423 //
       
   424 TInt CUPnPAppWizard::ShowTextStepL( TInt aMain )
       
   425     {
       
   426     __LOG("CUPnPAppWizard::ShowTextStepL");
       
   427     TInt returnValue(KErrNone);
       
   428 
       
   429     TBuf<64> data;
       
   430     TBool sharingCheck( ETrue );
       
   431     iSelections->GetDeviceNameL( data );
       
   432     HBufC16* oldName16 = HBufC16::NewL( data.Size() );
       
   433     CleanupStack::PushL( oldName16 );
       
   434     *oldName16 = data;
       
   435 
       
   436     do
       
   437         {
       
   438         sharingCheck = ETrue;
       
   439         CAknTextQueryDialog* dlg = CAknTextQueryDialog::NewL( data );
       
   440 
       
   441         dlg->PrepareLC( aMain );
       
   442         
       
   443         HBufC* head = StringLoader::LoadLC( R_UPNP_WIZARD_HEAD_3_TEXT );
       
   444         dlg->SetPromptL( *head );
       
   445         CleanupStack::PopAndDestroy( head );    
       
   446     
       
   447         returnValue = dlg->RunLD();
       
   448 
       
   449         if ( iSharingState &&
       
   450              returnValue )
       
   451             {
       
   452             TInt compRes = oldName16->CompareF( data );
       
   453             if ( compRes )
       
   454                 {
       
   455                 // show info note if sharing is on
       
   456                 sharingCheck = EFalse;
       
   457                 ShowInfoNoteL( R_UPNP_WIZARD_IAP_TURN_SHARING_OFF );
       
   458                 data = *oldName16;
       
   459                 }
       
   460             }
       
   461         }
       
   462     while ( !sharingCheck );
       
   463     CleanupStack::PopAndDestroy( oldName16 );
       
   464     if ( returnValue )
       
   465         {
       
   466         iSelections->SetDeviceNameL( data );
       
   467         }
       
   468     return returnValue;
       
   469     }
       
   470 
       
   471 // --------------------------------------------------------------------------
       
   472 // CUPnPAppWizard::ShowInfoNoteL
       
   473 // Show the information note without buttons
       
   474 // --------------------------------------------------------------------------
       
   475 //
       
   476 void CUPnPAppWizard::ShowInfoNoteL( TInt aMain ) const
       
   477     {
       
   478     __LOG("CUPnPAppWizard::ShowInfoNoteL");
       
   479 
       
   480     CAknInformationNote* note = new (ELeave) CAknInformationNote(ETrue);
       
   481     HBufC* noteText = CCoeEnv::Static()->AllocReadResourceLC(
       
   482         aMain);
       
   483     note->ExecuteLD(*noteText);
       
   484     CleanupStack::PopAndDestroy(noteText);
       
   485     }
       
   486 
       
   487 // --------------------------------------------------------------------------
       
   488 // CUPnPAppWizard::ShowInfoStepL
       
   489 // Show the information note with OK BACK buttons
       
   490 // --------------------------------------------------------------------------
       
   491 //
       
   492 TInt CUPnPAppWizard::ShowInfoStepL( TInt aMain ) const
       
   493     {
       
   494     __LOG("CUPnPAppWizard::ShowInfoStepL");
       
   495     TInt returnValue(KErrNone);
       
   496     HBufC* messageText;
       
   497 
       
   498     CAknMessageQueryDialog* dlg = new (ELeave)
       
   499         CAknMessageQueryDialog( CAknQueryDialog::ENoTone );
       
   500 
       
   501     dlg->PrepareLC( aMain );
       
   502 
       
   503     switch( aMain )
       
   504         {
       
   505     case R_UPNP_WIZARD_POPUP_DIALOG_2:
       
   506         {
       
   507         HBufC* head = StringLoader::LoadLC( R_UPNP_WIZARD_HEAD_2_TEXT );
       
   508         dlg->SetHeaderTextL( *head );
       
   509         CleanupStack::PopAndDestroy( head );
       
   510         
       
   511         HBufC* body = StringLoader::LoadLC( R_UPNP_WIZARD_2_TEXT );
       
   512         dlg->SetMessageTextL( *body );
       
   513         CleanupStack::PopAndDestroy( body );
       
   514         
       
   515         break;
       
   516         }
       
   517     case R_UPNP_WIZARD_POPUP_DIALOG_5:
       
   518         {
       
   519         HBufC* head = StringLoader::LoadLC( R_UPNP_WIZARD_HEAD_5_TEXT );
       
   520         dlg->SetHeaderTextL( *head );
       
   521         CleanupStack::PopAndDestroy( head );
       
   522         break;
       
   523         }    
       
   524     case R_UPNP_WIZARD_POPUP_DIALOG_6:
       
   525         {
       
   526         HBufC* head = StringLoader::LoadLC( R_UPNP_WIZARD_HEAD_6_TEXT );
       
   527         dlg->SetHeaderTextL( *head );
       
   528         CleanupStack::PopAndDestroy( head );
       
   529     
       
   530         messageText = StringLoader::LoadLC( R_UPNP_WIZARD_6_2_TEXT );
       
   531         dlg->SetMessageTextL( messageText->Des() );
       
   532         CleanupStack::PopAndDestroy( );
       
   533         break;
       
   534         }
       
   535     case R_UPNP_WIZARD_POPUP_DIALOG_9A:
       
   536         {
       
   537         HBufC* head = StringLoader::LoadLC( R_UPNP_WIZARD_HEAD_9_TEXT );
       
   538         dlg->SetHeaderTextL( *head );
       
   539         CleanupStack::PopAndDestroy( head );
       
   540         
       
   541         messageText = StringLoader::LoadLC( R_UPNP_WIZARD_9A_TEXT );
       
   542         dlg->SetMessageTextL( messageText->Des() );
       
   543         CleanupStack::PopAndDestroy( );
       
   544         break;
       
   545         }
       
   546     case R_UPNP_WIZARD_POPUP_DIALOG_9B:
       
   547         {
       
   548         HBufC* head = StringLoader::LoadLC( R_UPNP_WIZARD_HEAD_9_TEXT );
       
   549         dlg->SetHeaderTextL( *head );
       
   550         CleanupStack::PopAndDestroy( head );
       
   551         
       
   552         messageText = StringLoader::LoadLC( R_UPNP_WIZARD_9B_TEXT );
       
   553         dlg->SetMessageTextL( messageText->Des() );
       
   554         CleanupStack::PopAndDestroy( );
       
   555         break;
       
   556         }
       
   557     default:
       
   558         break;
       
   559         }
       
   560 
       
   561     if ( iStep == EInfo4 )
       
   562         {
       
   563         HBufC* head = StringLoader::LoadLC( R_UPNP_WIZARD_HEAD_4_TEXT );
       
   564         dlg->SetHeaderTextL( *head );
       
   565         CleanupStack::PopAndDestroy( head );
       
   566         
       
   567         HBufC* itemText2 = StringLoader::LoadLC( R_UPNP_WIZARD_ALWAYS_ASK_TEXT );
       
   568         HBufC* itemText1 = StringLoader::LoadLC( R_UPNP_WIZARD_4_TEXT,
       
   569                                                  *itemText2 );
       
   570 
       
   571         dlg->SetMessageTextL( itemText1->Des() );
       
   572         CleanupStack::PopAndDestroy( 2 ); //itemText 1 & 2
       
   573         }
       
   574     returnValue = dlg->RunLD();
       
   575 
       
   576     return returnValue;
       
   577     }
       
   578 
       
   579 // --------------------------------------------------------------------------
       
   580 // CUPnPAppWizard::ShowFirstStepL
       
   581 // Show the first information note with OK BACK buttons and given text
       
   582 // --------------------------------------------------------------------------
       
   583 //
       
   584 TInt CUPnPAppWizard::ShowFirstStepL( TInt aMain ) const
       
   585     {
       
   586     __LOG("CUPnPAppWizard::ShowFirstStepL");
       
   587     TInt returnValue( KErrNone );
       
   588 
       
   589     CAknMessageQueryDialog* dlg = new (ELeave)
       
   590         CAknMessageQueryDialog( CAknQueryDialog::ENoTone );
       
   591 
       
   592     dlg->PrepareLC( aMain );
       
   593     HBufC* head = StringLoader::LoadLC( R_UPNP_WIZARD_HEAD_1_TEXT );
       
   594     dlg->SetHeaderTextL( *head );
       
   595     CleanupStack::PopAndDestroy( head );
       
   596     
       
   597     if ( iFirstStepText->Length() )
       
   598         {
       
   599         // if the text for first step is given use it insted of default
       
   600         __LOG( "Setting text" );
       
   601         dlg->SetMessageTextL( *iFirstStepText );
       
   602         }       
       
   603     else
       
   604         {
       
   605         __LOG( " StringLoader::LoadLC" );
       
   606         HBufC* body = StringLoader::LoadLC(R_UPNP_WIZARD_1_TEXT);
       
   607         __LOG( "SetMessageTextL" );
       
   608         dlg->SetMessageTextL( *body );
       
   609         __LOG( "PopAndDestroy" );
       
   610         CleanupStack::PopAndDestroy();
       
   611         }
       
   612     returnValue = dlg->RunLD();
       
   613 
       
   614     return returnValue;
       
   615     }
       
   616 
       
   617 // --------------------------------------------------------------------------
       
   618 // CUPnPAppWizard::ShowInfoStepL
       
   619 // Show the multiselection popup dialog for setting content to share
       
   620 // --------------------------------------------------------------------------
       
   621 //
       
   622 TInt CUPnPAppWizard::ShowMultiselectionStepL( TInt aText )
       
   623     {
       
   624     __LOG("CUPnPAppWizard::ShowMultiselectionStepL");
       
   625 
       
   626     TInt returnValue(KErrNone);
       
   627 
       
   628     THomeConnectMediaType mediaType( EImageAndVideo );
       
   629 
       
   630     CArrayFix<TInt>* resArr = new (ELeave) CArrayFixFlat<TInt>(5);
       
   631     CleanupStack::PushL( resArr );
       
   632 
       
   633     if ( iStep == EShareMusic )
       
   634         {
       
   635         mediaType = EPlaylist;
       
   636         }
       
   637     TInt visualSharingState;
       
   638     HBufC* head = StringLoader::LoadLC( aText );
       
   639     
       
   640     // no ownership transfers
       
   641     CUPnPMultiselectionUi* uiDlg = CUPnPMultiselectionUi::
       
   642         NewL(mediaType,
       
   643              iFileEng,
       
   644              visualSharingState,
       
   645              resArr,
       
   646              CUPnPMultiselectionUi::EPopup,
       
   647              head );
       
   648     CleanupStack::PushL( uiDlg );
       
   649 
       
   650     ModifyMarkedArrayL(ESetMarked,NULL,uiDlg);
       
   651     
       
   652     returnValue = uiDlg->ExecutePopupLD();
       
   653 
       
   654     CleanupStack::PopAndDestroy( uiDlg );
       
   655     
       
   656     CleanupStack::PopAndDestroy( head );    
       
   657 
       
   658     if ( returnValue )
       
   659         {
       
   660         ModifyMarkedArrayL(EResetArray);
       
   661         for( TInt i = 0 ; i < resArr->Count() ; ++i )
       
   662             {
       
   663             TInt tmp = resArr->At(i);
       
   664             ModifyMarkedArrayL(EAddToArray,tmp);
       
   665             }
       
   666         // Transfer ownership of all dynamic variables( resARr )
       
   667         iSelections->SetSharedContent( mediaType,
       
   668                                        resArr );
       
   669         iFileEng->SetSelectionIndexesL( mediaType, *resArr );
       
   670         }
       
   671 
       
   672     CleanupStack::PopAndDestroy( resArr );
       
   673     return returnValue;
       
   674     }
       
   675 
       
   676 // --------------------------------------------------------------------------
       
   677 // CUPnPAppWizard::ModifyMarkedArrayL
       
   678 // --------------------------------------------------------------------------
       
   679 //
       
   680 void CUPnPAppWizard::ModifyMarkedArrayL( TShareArrayState aArrayState 
       
   681                                        , TInt aValue 
       
   682                                        , CUPnPMultiselectionUi* aUiDlg )
       
   683     {
       
   684     CArrayFix<TInt>* array = NULL;
       
   685     if( iStep == EShareMusic )
       
   686         {
       
   687         array = iShareMusicArray;
       
   688         }
       
   689     else if( EShareImages == iStep )
       
   690         {
       
   691         array = iShareImgAndVideoArray;
       
   692         }
       
   693     if( array )
       
   694         {
       
   695         switch(aArrayState)
       
   696             {
       
   697             case ESetMarked:
       
   698                 {
       
   699                 if( aUiDlg )
       
   700                     {
       
   701                     aUiDlg->SetMarkedItemsL( *array );
       
   702                     }
       
   703                 break;
       
   704                 }
       
   705             case EResetArray:
       
   706                 {
       
   707                 array->Reset();
       
   708                 break;
       
   709                 }
       
   710             case EAddToArray:
       
   711                 {
       
   712                 array->AppendL(aValue);
       
   713                 break;
       
   714                 }
       
   715             default:
       
   716             	break;
       
   717             }
       
   718         }
       
   719     }
       
   720 
       
   721 // --------------------------------------------------------------------------
       
   722 // CUPnPAppWizard::SetNextStep
       
   723 // Calculates the next step in wizard
       
   724 // --------------------------------------------------------------------------
       
   725 //
       
   726 void CUPnPAppWizard::SetNextStep( const TInt& aSelection )
       
   727     {
       
   728     __LOG("CUPnPAppWizard::SetNextStep");
       
   729 
       
   730     switch ( iStep )
       
   731         {
       
   732     case EInfo1:
       
   733         {
       
   734         if ( aSelection )
       
   735             {
       
   736             iStep++;
       
   737             }
       
   738         else
       
   739             {
       
   740             iStep = EFinished;
       
   741             }
       
   742         }
       
   743         break;
       
   744     case EInfo2:
       
   745         // fall through
       
   746     case EDeviceName:
       
   747         // fall through
       
   748     case EInfo4:
       
   749         // fall through
       
   750     case EAccessPoint:
       
   751         // fall through
       
   752     case EInfo6:
       
   753         // fall through
       
   754     case EShareImages:
       
   755         // fall through
       
   756     case EShareMusic:
       
   757         // fall through
       
   758     case EInfo9:
       
   759         // fall through
       
   760     case EStoreSettings:
       
   761         {
       
   762         if ( aSelection )
       
   763             {
       
   764             iStep++;
       
   765             }
       
   766         else
       
   767             {
       
   768             iStep--;
       
   769             }
       
   770         }
       
   771         break;
       
   772     default :
       
   773         {
       
   774         __LOG("CUPnPAppWizard::SetNextStep: default!");
       
   775         _LIT(KUser, "USER");
       
   776         User::Panic(KUser, 0);
       
   777         }
       
   778         break;
       
   779         }
       
   780     }
       
   781 
       
   782 // --------------------------------------------------------------------------
       
   783 // CUPnPAppWizard::ShowErrorNoteL
       
   784 // Shows note with error message
       
   785 // --------------------------------------------------------------------------
       
   786 //
       
   787 void CUPnPAppWizard::ShowErrorNoteL( TInt aMain ) const
       
   788     {
       
   789     __LOG("CUPnPAppWizard::ShowErrorNoteL begin");
       
   790 
       
   791     // show error note
       
   792     HBufC* errorNote = StringLoader::LoadLC( aMain );
       
   793     CAknErrorNote* note = new (ELeave) CAknErrorNote(ETrue);
       
   794     note->ExecuteLD(*errorNote);
       
   795     CleanupStack::PopAndDestroy(); //errorNote
       
   796     __LOG("CUPnPAppWizard::ShowErrorNoteL end");
       
   797     }
       
   798 
       
   799 // --------------------------------------------------------------------------
       
   800 // CUPnPAppWizard::ShowWaitNoteL
       
   801 // Shows standard wait note
       
   802 // --------------------------------------------------------------------------
       
   803 //
       
   804 void CUPnPAppWizard::ShowWaitNoteL( TInt aMain )
       
   805     {
       
   806     __LOG("CUPnPAppWizard::ShowWaitNoteL begin");
       
   807 
       
   808     CAknWaitNoteWrapper* waitNoteWrapper = CAknWaitNoteWrapper::NewL();
       
   809     CleanupStack::PushL(reinterpret_cast<CBase*>(waitNoteWrapper));
       
   810     waitNoteWrapper->ExecuteL(
       
   811         aMain,      // TInt aResId,
       
   812         *this,            // MAknBackgroundProcess& aBackgroundProcess
       
   813         ETrue);
       
   814     CleanupStack::PopAndDestroy();
       
   815     __LOG("CUPnPAppWizard::ShowWaitNoteL end");
       
   816     }
       
   817 
       
   818 // --------------------------------------------------------------------------
       
   819 // CUPnPAppWizard::StepL
       
   820 // Step done during wait note
       
   821 // --------------------------------------------------------------------------
       
   822 //
       
   823 void CUPnPAppWizard::StepL(void)
       
   824     {
       
   825     if ( iStartingSharing == ENotActive )
       
   826         {
       
   827         iStartingSharing = EStartingSharing;
       
   828         }
       
   829 
       
   830     }
       
   831 
       
   832 
       
   833 // --------------------------------------------------------------------------
       
   834 // CUPnPAppWizard::IsProcessDone
       
   835 // Returns ETrue if process finished
       
   836 // --------------------------------------------------------------------------
       
   837 //
       
   838 TBool CUPnPAppWizard::IsProcessDone(void) const
       
   839     {
       
   840 
       
   841     TBool ret(EFalse);
       
   842     if ( iStartingSharing == ENotActive )
       
   843         {
       
   844         TRAPD( err, iFileEng->SetSharingStateL( ETrue ) );
       
   845         if( err != KErrNone )
       
   846             {
       
   847             return ETrue;
       
   848             }
       
   849         }
       
   850     else if ( iStartingSharing == ESharingStarted )
       
   851         {
       
   852         ret = ETrue;
       
   853         }
       
   854     else
       
   855         {
       
   856         __LOG( "CUPnPAppWizard::IsProcessDone: else branch");
       
   857         }
       
   858     return ret;
       
   859     }
       
   860 
       
   861 // --------------------------------------------------------------------------
       
   862 // CUPnPAppWizard::HandleSharingStatus
       
   863 // Function informs when file sharing was enabled or disabled
       
   864 // --------------------------------------------------------------------------
       
   865 //
       
   866 void CUPnPAppWizard::HandleSharingStatus( 
       
   867         CUPnPFileSharingEngine& /*aEngine*/, 
       
   868         TInt aError, 
       
   869         TBool aPhase )
       
   870     {
       
   871     __LOG("CUPnPAppWizard::HandleSharingStatus begin");
       
   872 
       
   873     if ( aPhase )
       
   874         {
       
   875         __LOG("CUPnPAppWizard::HandleSharingStatus:\
       
   876  activating sharing");
       
   877         iStartingSharing = ESharingStarted;
       
   878         if ( aError )
       
   879             {
       
   880             // If there domtree wasn't able to be written due to disk full
       
   881             // situation, send leave to kernel to inform user
       
   882             if( aError == KErrDiskFull ||
       
   883                 aError == KErrNoMemory ||
       
   884                 aError == KErrInUse )
       
   885                 {
       
   886                 //show some critical errors using
       
   887                 //default symbian error notes
       
   888                 CActiveScheduler::Current()->Error( aError );
       
   889                 }
       
   890             else
       
   891                 {
       
   892                 if ( !iDialogDismissed )
       
   893                     {
       
   894                     // must ensure that wait note is gone, see DialogDismissed
       
   895                     iWait.Start();
       
   896                     }
       
   897                 TRAP_IGNORE( 
       
   898                     ShowErrorNoteL( 
       
   899                         R_UPNP_WIZARD_START_SHARING_ERROR_TEXT ) );
       
   900                 }
       
   901             }
       
   902         if ( iWait.IsStarted() )
       
   903             {
       
   904             if ( iWait.CanStopNow() )
       
   905                 {
       
   906                 iWait.AsyncStop();
       
   907                 }
       
   908             else
       
   909                 {
       
   910                 __LOG("CUPnPAppWizard: \
       
   911 Error cant stop iWait");
       
   912                 }
       
   913             }
       
   914         }
       
   915     else
       
   916         {
       
   917         __LOG("CUPnPAppWizard::HandleSharingStatus:\
       
   918  deactivating sharing");
       
   919         // stop showing wait note
       
   920         if ( iWait.IsStarted() )
       
   921             {
       
   922             iWait.AsyncStop();
       
   923             }
       
   924         }
       
   925 
       
   926     __LOG("CUPnPAppWizard::HandleSharingStatus end");
       
   927     }
       
   928 
       
   929 // --------------------------------------------------------------------------
       
   930 // CUPnPAppWizard::HandleSharingConnectionLost
       
   931 // Callback to inform if connection has been lost
       
   932 // --------------------------------------------------------------------------
       
   933 //
       
   934 void CUPnPAppWizard::HandleSharingConnectionLost( 
       
   935     CUPnPFileSharingEngine& /*aEngine*/ )
       
   936     {
       
   937     __LOG( "[CUPnPAppWizard]\t CUPnPAppWizard::HandleSharingConnectionLost\
       
   938  begin" );
       
   939 
       
   940     iSharingState = EFalse;
       
   941 
       
   942     __LOG( "[CUPnPAppWizard]\t CUPnPAppWizard::HandleSharingConnectionLost\
       
   943  end" );
       
   944     }
       
   945 
       
   946 // --------------------------------------------------------------------------
       
   947 // CUPnPAppWizard::DialogDismissedL
       
   948 // Callback for dialog disappearing
       
   949 // --------------------------------------------------------------------------
       
   950 //
       
   951 void CUPnPAppWizard::DialogDismissedL( TInt /*aButtonId*/ )
       
   952     {
       
   953     __LOG( "[CUPnPAppWizard]\t DialogDismissedL begin" );
       
   954 
       
   955     iDialogDismissed = ETrue;
       
   956     if ( iWait.IsStarted())
       
   957         {
       
   958         iWait.AsyncStop();
       
   959         }
       
   960 
       
   961     __LOG( "[CUPnPAppWizard]\t DialogDismissedL end" );
       
   962     }
       
   963 
       
   964 // --------------------------------------------------------------------------
       
   965 // CUPnPAppWizard::DisplayInfoL()
       
   966 // Shows message query to user
       
   967 // --------------------------------------------------------------------------
       
   968 //
       
   969 void CUPnPAppWizard::DisplayInfoL(
       
   970     TInt aHeaderResourceId,
       
   971     TInt aMessageResourceId,
       
   972     TInt aDialogResourceId )
       
   973     {
       
   974     __LOG("CUPnPAppWizard::DisplayInfoL begin");
       
   975     HBufC* noteHeader = StringLoader::LoadL(
       
   976         aHeaderResourceId);
       
   977     CleanupStack::PushL(noteHeader);
       
   978     HBufC* noteMsg = StringLoader::LoadL(
       
   979         aMessageResourceId);
       
   980     CleanupStack::PushL(noteMsg);
       
   981 
       
   982     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL(*noteMsg);
       
   983 
       
   984 
       
   985     dlg->PrepareLC(aDialogResourceId);
       
   986     dlg->QueryHeading()->SetTextL(*noteHeader);
       
   987     dlg->RunLD();
       
   988 
       
   989 
       
   990     CleanupStack::PopAndDestroy(noteMsg);
       
   991     CleanupStack::PopAndDestroy(noteHeader);
       
   992     __LOG("CUPnPAppWizard::DisplayInfoL end");
       
   993     }
       
   994 
       
   995 
       
   996 // --------------------------------------------------------------------------
       
   997 // CUPnPAppWizard::CSelectionStorage functions
       
   998 //
       
   999 // --------------------------------------------------------------------------
       
  1000 //
       
  1001 
       
  1002 // --------------------------------------------------------------------------
       
  1003 // CSelectionStorage::CSelectionStorage
       
  1004 // Destructor
       
  1005 // --------------------------------------------------------------------------
       
  1006 //
       
  1007 CUPnPAppWizard::CSelectionStorage::~CSelectionStorage()
       
  1008     {
       
  1009     __LOG("[UPnPAppWizard]\tCSelectionStorage::~CSelectionStorage() begin");
       
  1010     delete iDeviceName;
       
  1011     delete iMusicSelectionArray;
       
  1012     delete iImageSelectionArray;
       
  1013     __LOG("CSelectionStorage::~CSelectionStorage() end");
       
  1014     }
       
  1015 
       
  1016 // --------------------------------------------------------------------------
       
  1017 // CSelectionStorage::CSelectionStorage
       
  1018 // Constructor
       
  1019 // --------------------------------------------------------------------------
       
  1020 //
       
  1021 CUPnPAppWizard::CSelectionStorage::CSelectionStorage(
       
  1022     CUPnPSettingsEngine* aSetEng,
       
  1023     CUPnPFileSharingEngine* aFileEng )
       
  1024     {
       
  1025     __LOG("CSelectionStorage::CSelectionStorage() begin");
       
  1026     iSetEng = aSetEng;
       
  1027     iFileEng = aFileEng;
       
  1028     __LOG("CSelectionStorage::CSelectionStorage() end");
       
  1029     }
       
  1030 
       
  1031 // --------------------------------------------------------------------------
       
  1032 // CSelectionStorage::SetDeviceNameL
       
  1033 // Function for setting the device name to local storage
       
  1034 // --------------------------------------------------------------------------
       
  1035 //
       
  1036 void CUPnPAppWizard::CSelectionStorage::SetDeviceNameL( TDes& aDeviceName )
       
  1037     {
       
  1038     __LOG("CSelectionStorage::SetDeviceNameL begin");
       
  1039     delete iDeviceName;
       
  1040     iDeviceName = NULL;
       
  1041     iDeviceName = HBufC::NewL(aDeviceName.Length());
       
  1042 
       
  1043     *iDeviceName = aDeviceName;
       
  1044     __LOG("CSelectionStorage::SetDeviceNameL end");
       
  1045     }
       
  1046 
       
  1047 // --------------------------------------------------------------------------
       
  1048 // CSelectionStorage::GetDeviceNameL
       
  1049 // Function for getting the device name from local storage or from cenrep
       
  1050 // --------------------------------------------------------------------------
       
  1051 //
       
  1052 TInt CUPnPAppWizard::CSelectionStorage::GetDeviceNameL( TDes& aDeviceName )
       
  1053     {
       
  1054     __LOG("CSelectionStorage::GetDeviceNameL begin");
       
  1055     TInt err(0);
       
  1056     if ( iDeviceName )
       
  1057         {
       
  1058         aDeviceName = iDeviceName->Des();
       
  1059         }
       
  1060     else
       
  1061         {
       
  1062         THostName data;
       
  1063         TBuf8<65> deviceName8;
       
  1064         err = iSetEng->GetLocalFriendlyName( deviceName8 );
       
  1065 
       
  1066         HBufC* deviceName16 = UpnpString::ToUnicodeL( deviceName8 );
       
  1067         CleanupStack::PushL( deviceName16 );
       
  1068         aDeviceName = deviceName16->Des();
       
  1069         CleanupStack::PopAndDestroy( deviceName16 );
       
  1070         }
       
  1071     __LOG("CSelectionStorage::GetDeviceNameL end");
       
  1072     return err;
       
  1073     }
       
  1074 
       
  1075 // --------------------------------------------------------------------------
       
  1076 // CSelectionStorage::GetIapId
       
  1077 // Function for getting the iapid from local storage or from cenrep
       
  1078 // --------------------------------------------------------------------------
       
  1079 //
       
  1080 TInt CUPnPAppWizard::CSelectionStorage::GetIapId( TInt& aIapId )
       
  1081     {
       
  1082     __LOG("CSelectionStorage::GetIapId begin");
       
  1083     TInt err( KErrNone );
       
  1084     if ( iIapId )
       
  1085         {
       
  1086         aIapId = iIapId;
       
  1087         }
       
  1088     else
       
  1089         {
       
  1090         err = iSetEng->GetAccessPoint( iIapId );
       
  1091         aIapId = iIapId;
       
  1092         }
       
  1093     __LOG("CSelectionStorage::GetIapId end");
       
  1094     return err;
       
  1095     }
       
  1096 
       
  1097 // --------------------------------------------------------------------------
       
  1098 // CSelectionStorage::SetIapId
       
  1099 // Function for setting the iapid to local storage
       
  1100 // --------------------------------------------------------------------------
       
  1101 //
       
  1102 void CUPnPAppWizard::CSelectionStorage::SetIapId( const TInt aIapId,
       
  1103                                                   const TInt aIndexForUi )
       
  1104     {
       
  1105     __LOG("CSelectionStorage::SetIapId begin");
       
  1106 
       
  1107     iIapId = aIapId;
       
  1108     iIndexForUi = aIndexForUi;
       
  1109 
       
  1110     __LOG("CSelectionStorage::SetIapId end");
       
  1111     }
       
  1112 
       
  1113 // --------------------------------------------------------------------------
       
  1114 // CSelectionStorage::StoreSettingsL
       
  1115 // Function for storing devicename and iapid to cenrep
       
  1116 // --------------------------------------------------------------------------
       
  1117 //
       
  1118 TInt CUPnPAppWizard::CSelectionStorage::StoreSettingsL()
       
  1119     {
       
  1120     __LOG("CSelectionStorage::StoreSettingsL begin");
       
  1121     TInt err(0);
       
  1122     if ( iDeviceName )
       
  1123         {
       
  1124         HBufC8* name8 = UpnpString::FromUnicodeL( iDeviceName->Des() );
       
  1125         CleanupStack::PushL( name8 );
       
  1126         err = iSetEng->SetLocalFriendlyName( name8->Des() );
       
  1127         CleanupStack::PopAndDestroy( name8 );
       
  1128         }
       
  1129     if ( iIapId >= EUPnPSettingsEngineIAPIdAlwaysAsk )
       
  1130         {
       
  1131         // Stores iap id.
       
  1132         iSetEng->SetAccessPoint( iIapId );
       
  1133         
       
  1134         // Stores iap selection type.
       
  1135         TInt iapForHomeNetworkUi( EUPnPSettingsEngineIAPItemUserDefined );
       
  1136         if ( iIapId == EUPnPSettingsEngineIAPIdAlwaysAsk )
       
  1137             {
       
  1138             iapForHomeNetworkUi = EUPnPSettingsEngineIAPItemAlwaysAsk;
       
  1139             }
       
  1140         iSetEng->SetAccessPointSetting( iapForHomeNetworkUi );
       
  1141         
       
  1142         // index for HN ui?
       
  1143         iSetEng->SetWapId( iIndexForUi+1 );
       
  1144         }
       
  1145 
       
  1146     __LOG("CSelectionStorage::StoreSettingsL end");
       
  1147     return err;
       
  1148     }
       
  1149 
       
  1150 // --------------------------------------------------------------------------
       
  1151 // CSelectionStorage::ImageStoreSharedFilesL
       
  1152 // Function for storing image and video
       
  1153 // --------------------------------------------------------------------------
       
  1154 //
       
  1155 TInt CUPnPAppWizard::CSelectionStorage::ImageStoreSharedFilesL( )
       
  1156     {
       
  1157     /* Save Images and Videos */
       
  1158     __LOG( "CSelectionStorage::Sharing image and video .." );
       
  1159     if ( iFileEng )
       
  1160         {
       
  1161         iFileEng->ShareMediaL( EImageAndVideo );
       
  1162         iFileEng->ShareMediaL( EPlaylist );
       
  1163         }   
       
  1164     __LOG( "CSelectionStorage::ImageStoreSharedFilesL end" );
       
  1165     return KErrNone;
       
  1166     }
       
  1167 
       
  1168 // --------------------------------------------------------------------------
       
  1169 // CSelectionStorage::InitializeIapArraysL
       
  1170 // Add default items to iap name array
       
  1171 // --------------------------------------------------------------------------
       
  1172 //
       
  1173 void CUPnPAppWizard::CSelectionStorage::InitializeIapArraysL(
       
  1174     CDesCArray* aIapNameArr,
       
  1175     RArray<TInt64>& aIapIdArr ) const
       
  1176     {
       
  1177     __LOG("[UPnPAppWizard]\tCSelectionStorage::InitializeIapArraysL begin");
       
  1178 
       
  1179     HBufC* itemText1 = StringLoader::LoadLC( R_UPNP_WIZARD_ALWAYS_ASK_TEXT );
       
  1180     HBufC* itemText2 = StringLoader::LoadLC( R_UPNP_WIZARD_CREATE_NEW_TEXT );
       
  1181 
       
  1182     aIapNameArr->AppendL( itemText1->Des() );
       
  1183     aIapIdArr.AppendL( EUPnPSettingsEngineIAPIdAlwaysAsk );
       
  1184     aIapNameArr->AppendL( itemText2->Des() );
       
  1185     aIapIdArr.AppendL( EUPnPSettingsEngineIAPIdCreateNew );
       
  1186 
       
  1187     //aIapNameArr does not own the items
       
  1188     CleanupStack::PopAndDestroy(2);
       
  1189 
       
  1190     __LOG("[UPnPAppWizard]\tCSelectionStorage::InitializeIapArraysL end");
       
  1191     }
       
  1192 
       
  1193 // -------------------------------------------------------------
       
  1194 // CSelectionStorage::SetSharedContent()
       
  1195 // Sets the users sharing selections to local storage
       
  1196 // -------------------------------------------------------------
       
  1197 //
       
  1198 void CUPnPAppWizard::CSelectionStorage::SetSharedContent(
       
  1199     THomeConnectMediaType aMedia,
       
  1200     CArrayFix<TInt>* aSelections )
       
  1201     {
       
  1202     __LOG("CSelectionStorage::SetSharedContent begin");
       
  1203 
       
  1204     if ( aMedia == EImageAndVideo )
       
  1205         {
       
  1206         // determine the users selections from UI
       
  1207         // if there is only one item selected and its value is not 0
       
  1208         // -> Share all is selected
       
  1209         if ( ! (aSelections->Count() == 1 && aSelections->At(0) == 0 ) )
       
  1210             {
       
  1211             iVisualImageSelection = ETrue;
       
  1212             }
       
  1213         }
       
  1214     else
       
  1215         {
       
  1216 
       
  1217         if ( ! (aSelections->Count() == 1 && aSelections->At(0) == 0 ) )
       
  1218             {
       
  1219             // no difference between EShareAll and EShareMany
       
  1220             iVisualMusicSelection = ETrue;
       
  1221             }
       
  1222 
       
  1223         }
       
  1224 
       
  1225     __LOG("CSelectionStorage::SetSharedContent end");
       
  1226     }
       
  1227 
       
  1228 
       
  1229 // -------------------------------------------------------------
       
  1230 // CSelectionStorage::SetSharedContent()
       
  1231 // Gets the users sharing selections from local storage
       
  1232 // -------------------------------------------------------------
       
  1233 //
       
  1234 void CUPnPAppWizard::CSelectionStorage::GetSelectionsL(
       
  1235     THomeConnectMediaType aMedia,
       
  1236     CArrayFix<TInt>* aSelections )
       
  1237     {
       
  1238     __LOG("CSelectionStorage::GetSelectionsL begin");
       
  1239 
       
  1240     if ( aMedia == EImageAndVideo )
       
  1241         {
       
  1242         if ( iImageSelectionArray )
       
  1243             {
       
  1244             for ( TInt i = 0; i < iImageSelectionArray->Count(); i++ )
       
  1245                 {
       
  1246                 TInt tmp = iImageSelectionArray->At( i );
       
  1247                 aSelections->AppendL( tmp );
       
  1248                 }
       
  1249             }
       
  1250         }
       
  1251     else
       
  1252         {
       
  1253         if ( iMusicSelectionArray )
       
  1254             {
       
  1255             for ( TInt i = 0; i < iMusicSelectionArray->Count(); i++ )
       
  1256                 {
       
  1257                 TInt tmp = iMusicSelectionArray->At( i );
       
  1258                 aSelections->AppendL( tmp );
       
  1259                 }
       
  1260             }
       
  1261         }
       
  1262     __LOG("CSelectionStorage::GetSelectionsL end");
       
  1263     }
       
  1264 
       
  1265 // -------------------------------------------------------------
       
  1266 // CSelectionStorage::HasSomethingToShare()
       
  1267 // Determines if the user has selected content to share
       
  1268 // -------------------------------------------------------------
       
  1269 //
       
  1270 TBool CUPnPAppWizard::CSelectionStorage::HasSomethingToShare() const
       
  1271     {
       
  1272     __LOG("CSelectionStorage::HasSomethingToShare begin");
       
  1273     TBool retVal( EFalse );
       
  1274     if ( iVisualImageSelection || iVisualMusicSelection )
       
  1275         {
       
  1276         retVal = ETrue;
       
  1277         }
       
  1278     __LOG("CSelectionStorage::HasSomethingToShare end");
       
  1279     return retVal;
       
  1280     }
       
  1281 
       
  1282 // --------------------------------------------------------------------------
       
  1283 // CSelectionStorage::GetCurrentSelection
       
  1284 // Gets the user selected iapid or iapid from cenrep
       
  1285 // --------------------------------------------------------------------------
       
  1286 //
       
  1287 void CUPnPAppWizard::CSelectionStorage::GetCurrentSelection(
       
  1288     TInt& aCurrentSelection, RArray<TInt64>& aIapIdArr )
       
  1289     {
       
  1290     __LOG("CSelectionStorage::GetCurrentSelection begin");
       
  1291     // Get the current selection
       
  1292     TInt userIapId( 0 );
       
  1293     GetIapId( userIapId );
       
  1294 
       
  1295     if ( userIapId < 1 ||
       
  1296          userIapId == aIapIdArr[ KUPnPAlwaysAskInd ] )
       
  1297         {
       
  1298         aCurrentSelection = 0;
       
  1299         }
       
  1300     else
       
  1301         {
       
  1302         aCurrentSelection = aIapIdArr.Find( userIapId );
       
  1303 
       
  1304         if ( aCurrentSelection <= KUPnPCreateNewInd )
       
  1305             {
       
  1306             /* Current iap is not in the list or it is Always Ask */
       
  1307             aCurrentSelection = 0;
       
  1308             }
       
  1309         }
       
  1310     __LOG("CSelectionStorage::GetCurrentSelection end");
       
  1311     }
       
  1312 
       
  1313 
       
  1314 // End of File