upnpsettings/upnpsharingui/src/upnpappfilesharinglist.cpp
changeset 0 7f85d04be362
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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:      File sharing list implementation for File sharing view
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 // INCLUDE FILES
       
    24 // system
       
    25 #include <aknlists.h>
       
    26 #include <aknPopup.h>
       
    27 #include <StringLoader.h>
       
    28 #include <upnpsharingui.rsg>
       
    29 #include <aknnotewrappers.h>
       
    30 #include <AknProgressDialog.h>
       
    31 #include <AknWaitDialog.h>
       
    32 
       
    33 // internal upnpfw interfaces
       
    34 #include "upnpsettingsengine.h"
       
    35 #include "upnpfilesharingengine.h"
       
    36 #include "cupnpappwizard.h"
       
    37 #include "upnpcontentserverclient.h" //TUpnpProgressInfo
       
    38 
       
    39 // this component
       
    40 #include "upnpsharingui.hrh"
       
    41 #include "upnpappfilesharinglist.h"
       
    42 
       
    43 _LIT( KComponentLogfile, "upnpsharingui.txt");
       
    44 #include "upnplog.h"
       
    45 
       
    46 // CONSTANTS
       
    47 _LIT( KCDrive,  "C" );
       
    48 
       
    49 // ============================ MEMBER FUNCTIONS ============================
       
    50 
       
    51 // --------------------------------------------------------------------------
       
    52 // CUPnPAppFileSharingList::CUPnPAppFileSharingList
       
    53 // C++ default constructor can NOT contain any code, that
       
    54 // might leave.
       
    55 // --------------------------------------------------------------------------
       
    56 //
       
    57 CUPnPAppFileSharingList::CUPnPAppFileSharingList()
       
    58     {
       
    59     __LOG("CUPnPAppFileSharingList::CUPnPAppFileSharingList");
       
    60     }
       
    61 
       
    62 
       
    63 // --------------------------------------------------------------------------
       
    64 // CUPnPAppFileSharingList::ConstructL
       
    65 // Symbian 2nd phase constructor can leave.
       
    66 // --------------------------------------------------------------------------
       
    67 //
       
    68 void CUPnPAppFileSharingList::ConstructL(
       
    69                                 CUPnPFileSharingEngine* aFileSharingEngine)
       
    70     {
       
    71     __LOG("CUPnPAppFileSharingList::ConstructL");
       
    72 
       
    73     iFileSharingEngine = aFileSharingEngine;
       
    74     User::LeaveIfNull( iFileSharingEngine );
       
    75     iVisibility = 0;
       
    76     if ( iFileSharingEngine->SharingStateL() )
       
    77         {
       
    78         iVisibility = 1;
       
    79         }
       
    80     }
       
    81 
       
    82 
       
    83 // --------------------------------------------------------------------------
       
    84 // CUPnPAppFileSharingList::NewL
       
    85 // Two-phased constructor.
       
    86 // --------------------------------------------------------------------------
       
    87 //
       
    88 CUPnPAppFileSharingList* CUPnPAppFileSharingList::NewL(
       
    89     CUPnPFileSharingEngine* aFileSharingEngine )
       
    90     {
       
    91     __LOG("CUPnPAppFileSharingList::NewL");
       
    92 
       
    93     CUPnPAppFileSharingList* self = new (ELeave) CUPnPAppFileSharingList( );
       
    94     CleanupStack::PushL(self);
       
    95     self->ConstructL( aFileSharingEngine );
       
    96     CleanupStack::Pop( self );
       
    97     return self;
       
    98     }
       
    99 
       
   100 // --------------------------------------------------------------------------
       
   101 // CUPnPAppFileSharingList::~CUPnPAppFileSharingList
       
   102 // Destructor
       
   103 // --------------------------------------------------------------------------
       
   104 //
       
   105 CUPnPAppFileSharingList::~CUPnPAppFileSharingList()
       
   106     {
       
   107     __LOG("CUPnPAppFileSharingList::~CUPnPAppFileSharingList");
       
   108     // This will kill the possible wait note
       
   109     iStartingSharing = EPhaseCompleted;
       
   110     delete iWizard;
       
   111     iWizard = NULL;
       
   112     }
       
   113 
       
   114 
       
   115 // --------------------------------------------------------------------------
       
   116 // CUPnPAppFileSharingList::CreateSettingItemL
       
   117 // Creates list items
       
   118 // --------------------------------------------------------------------------
       
   119 //
       
   120 CAknSettingItem* CUPnPAppFileSharingList::CreateSettingItemL(TInt aIdentifier)
       
   121     {
       
   122     __LOG("CUPnPAppFileSharingList::CreateSettingItemL");
       
   123 
       
   124     CAknSettingItem* settingItem = NULL;
       
   125     switch (aIdentifier)
       
   126         {
       
   127         case ESharingUiSettingItemVisibility:
       
   128             {
       
   129             settingItem =
       
   130                 new (ELeave) CAknBinaryPopupSettingItem(aIdentifier,
       
   131                                                         iVisibility);
       
   132             break;
       
   133             }
       
   134 
       
   135         case ESharingUiSettingItemVisual:
       
   136             {
       
   137             settingItem = new (ELeave) CAknTextSettingItem(aIdentifier,
       
   138                                                            iVisualAlbums);
       
   139             break;
       
   140             }
       
   141 
       
   142         case ESharingUiSettingItemMusic:
       
   143             {
       
   144             settingItem = new (ELeave) CAknTextSettingItem(aIdentifier,
       
   145                                                            iPlayLists);
       
   146             break;
       
   147             }
       
   148 
       
   149         default:
       
   150             {
       
   151             __LOG("CUPnPAppFileSharingList::CreateSettingItemL \
       
   152 Unknown setting item!");
       
   153             }
       
   154         }
       
   155 
       
   156     return settingItem;
       
   157     }
       
   158 
       
   159 // --------------------------------------------------------------------------
       
   160 // CUPnPAppFileSharingList::EditItemL
       
   161 // Called when setting list item is modified
       
   162 // --------------------------------------------------------------------------
       
   163 //
       
   164 void  CUPnPAppFileSharingList::EditItemL (TInt aIndex, 
       
   165                                           TBool /*aCalledFromMenu*/)
       
   166     {
       
   167     __LOG("CUPnPAppFileSharingList::EditItemL");
       
   168 
       
   169     LoadDataFromEngineL();
       
   170 
       
   171     switch ( aIndex )
       
   172         {
       
   173         case ESharingUiSettingItemVisibility:
       
   174             {
       
   175             if ( !iVisibility )
       
   176                 {
       
   177                 if ( iIapId != KErrNotFound )
       
   178                     {
       
   179                     ShowWaitNoteL();
       
   180                     }
       
   181                 else
       
   182                     {
       
   183                     iWizardRun = ETrue;
       
   184 
       
   185                     MUPnPFileSharingEngineObserver* observer = 
       
   186                                     iFileSharingEngine->Observer();
       
   187                     
       
   188                     delete iWizard;
       
   189                     iWizard = NULL;
       
   190                     iWizard = CUPnPAppWizard::NewL( 
       
   191                         KNullDesC, iFileSharingEngine );
       
   192                     iWizard->StartL();
       
   193 
       
   194 
       
   195                     iFileSharingEngine->SetObserver(observer);
       
   196                     iFileSharingEngine->RequestSharingProgressL();
       
   197 
       
   198                     LoadDataFromEngineL();
       
   199                     }
       
   200                 }
       
   201             else
       
   202                 {
       
   203                 ShowWaitNoteL();
       
   204                 }
       
   205             }
       
   206             break;
       
   207 
       
   208         default:
       
   209             {
       
   210             __LOG("CUPnPAppFileSharingList::EditItemL No such item!");
       
   211             }
       
   212         }
       
   213 
       
   214     //load settings to screen
       
   215     CAknSettingItemList::LoadSettingsL();
       
   216     }
       
   217 
       
   218 // --------------------------------------------------------------------------
       
   219 // CUPnPAppFileSharingList::LoadDataFromEngineL
       
   220 // Loads data from Central Repository to member variables
       
   221 // (other items were commented in a header).
       
   222 // --------------------------------------------------------------------------
       
   223 //
       
   224 void  CUPnPAppFileSharingList::LoadDataFromEngineL()
       
   225     {
       
   226     __LOG("CUPnPAppFileSharingList::LoadDataFromEngineL");
       
   227 
       
   228     CUPnPSettingsEngine* settingsEngine = CUPnPSettingsEngine::NewL();
       
   229     CleanupStack::PushL( settingsEngine );
       
   230 
       
   231     // Read file sharing state
       
   232     iVisibility = 0;
       
   233     if ( iFileSharingEngine->SharingStateL() )
       
   234         {
       
   235         iVisibility = 1;
       
   236         }
       
   237 
       
   238     // Read iap id
       
   239     settingsEngine->GetAccessPoint( iIapId );
       
   240 
       
   241     //load settings to screen
       
   242     CAknSettingItemList::LoadSettingsL ();
       
   243     CleanupStack::PopAndDestroy( settingsEngine );
       
   244     }
       
   245 
       
   246 // --------------------------------------------------------------------------
       
   247 // CUPnPAppFileSharingList::HandleSharingStatus
       
   248 // Function informs when file sharing was enabled or disabled
       
   249 // --------------------------------------------------------------------------
       
   250 //
       
   251 void CUPnPAppFileSharingList::HandleSharingStatus( 
       
   252         CUPnPFileSharingEngine& /*aEngine*/, 
       
   253         TInt aError, 
       
   254         TBool aPhase )
       
   255     {
       
   256     __LOG("CUPnPAppFileSharingList::HandleSharingStatus begin");
       
   257 
       
   258     if ( aPhase )
       
   259         {
       
   260         __LOG("start sharing");
       
   261 
       
   262         if ( aError )
       
   263             {
       
   264             // change state back to off
       
   265             iVisibility = EFalse;
       
   266 
       
   267             // If there domtree wasn't able to be written due to disk full
       
   268             // situation, send leave to kernel to inform user
       
   269             if( aError == KErrDiskFull ||
       
   270                 aError == KErrNoMemory ||
       
   271                 aError == KErrInUse )
       
   272                 {
       
   273                 // stop the wait note
       
   274                 iStartingSharing = EPhaseCompleted;
       
   275                 //show some critical errors using
       
   276                 //default symbian error notes
       
   277                 CActiveScheduler::Current()->Error( aError );
       
   278                 }
       
   279             else
       
   280                 {
       
   281                 // show error note
       
   282                 TRAP_IGNORE(
       
   283                     HBufC* errorNote = StringLoader::LoadLC(
       
   284                         R_SETTINGS_START_SHARING_ERROR_TEXT);
       
   285                     CAknErrorNote* note = new (ELeave) CAknErrorNote(ETrue);
       
   286                     note->ExecuteLD(*errorNote);
       
   287                     CleanupStack::PopAndDestroy() ); //errorNote
       
   288                 }
       
   289 
       
   290             }
       
   291         else
       
   292             {
       
   293             // change secondary text
       
   294             iVisibility = ETrue;
       
   295             }
       
   296         }
       
   297     else
       
   298         {
       
   299         __LOG("stop sharing");
       
   300 
       
   301         // If the media server lost, aError will be KErrGeneral or
       
   302         // KErrServerTerminated.
       
   303         // If there were other errors, stop sharing fails and visibility 
       
   304         // will remain true.
       
   305         if ( !aError || KErrGeneral == aError || 
       
   306                 KErrServerTerminated == aError )
       
   307             {
       
   308             iVisibility = EFalse;
       
   309             }
       
   310 
       
   311         // Note user not enough memory to change the phone state.
       
   312         if ( KErrDiskFull == aError ||
       
   313              KErrNoMemory == aError ||
       
   314              KErrInUse == aError )
       
   315             {
       
   316             __LOG1( "Not enough memory to change the \
       
   317                     phone state error:%d ", aError  );
       
   318            
       
   319             //There is nothing to do if leaves
       
   320             TRAP_IGNORE(
       
   321                 HBufC* errorNote = StringLoader::LoadLC(
       
   322                     R_SETTINGS_START_SHARING_PHONE_ERROR_TEXT, KCDrive );
       
   323                 CAknErrorNote* note = new( ELeave ) CAknErrorNote( ETrue );
       
   324                 note->ExecuteLD( *errorNote );
       
   325                 CleanupStack::PopAndDestroy( errorNote ) );
       
   326             }  
       
   327         
       
   328         TRAP_IGNORE(
       
   329             CAknSettingItemList::EditItemL(
       
   330                 ESharingUiSettingItemVisibility, EFalse ) );
       
   331         }
       
   332 
       
   333 
       
   334     iStartingSharing = EPhaseCompleted;
       
   335     // Update UI
       
   336     TRAP_IGNORE( CAknSettingItemList::LoadSettingsL() );
       
   337     DrawDeferred();
       
   338 
       
   339     __LOG("CUPnPAppFileSharingList::HandleSharingStatus end");
       
   340     }
       
   341 
       
   342 // --------------------------------------------------------------------------
       
   343 // CUPnPAppFileSharingList::HandleSharingConnectionLost
       
   344 // Callback to inform if connection has been lost
       
   345 // --------------------------------------------------------------------------
       
   346 //
       
   347 void CUPnPAppFileSharingList::HandleSharingConnectionLost( 
       
   348         CUPnPFileSharingEngine& /*aEngine*/ )
       
   349     {
       
   350     __LOG("CUPnPAppFileSharingList::HandleSharingConnectionLost begin");
       
   351 
       
   352     iVisibility = EFalse;
       
   353     TRAPD( err,
       
   354         CAknSettingItemList::EditItemL (
       
   355             ESharingUiSettingItemVisibility, EFalse);
       
   356         LoadSettingsL();
       
   357         );
       
   358     DrawDeferred();
       
   359     if ( err != KErrNone )
       
   360         {
       
   361         //show some critical errors using
       
   362         //default symbian error notes
       
   363         CActiveScheduler::Current()->Error( err );
       
   364         }
       
   365 
       
   366     __LOG("CUPnPAppFileSharingList::HandleSharingConnectionLost end");
       
   367     }
       
   368 
       
   369 // --------------------------------------------------------------------------
       
   370 // CUPnPAppFileSharingList::HandleResourceChange
       
   371 // From CAknDialog
       
   372 // --------------------------------------------------------------------------
       
   373 //
       
   374 void CUPnPAppFileSharingList::HandleResourceChange( TInt aType )
       
   375     {
       
   376     __LOG("CUPnPAppFileSharingList::HandleResourceChange");
       
   377 
       
   378     if ( aType == KEikDynamicLayoutVariantSwitch )
       
   379         {
       
   380         TRect mainPaneRect;
       
   381         AknLayoutUtils::LayoutMetricsRect(
       
   382             AknLayoutUtils::EMainPane, mainPaneRect );
       
   383 
       
   384         TAknLayoutRect layoutRect;
       
   385         layoutRect.LayoutRect(
       
   386             TRect( TPoint( 0, 0 ), mainPaneRect.Size() ),
       
   387             AKN_LAYOUT_WINDOW_list_gen_pane( 0 ) );
       
   388 
       
   389         ListBox()->SetRect( layoutRect.Rect() );
       
   390         }
       
   391 
       
   392     // Base call
       
   393     CAknSettingItemList::HandleResourceChange( aType );
       
   394     }
       
   395 
       
   396 
       
   397 // --------------------------------------------------------------------------
       
   398 // CUPnPAppFileSharingList::SetFilesharingTextsL
       
   399 // Update the secondary texts in the dialog
       
   400 // --------------------------------------------------------------------------
       
   401 //
       
   402 void CUPnPAppFileSharingList::SetFilesharingTextsL( 
       
   403     const RArray<TUpnpProgressInfo>& aProgressInfo )
       
   404     {
       
   405     __LOG( "[CUPnPAppFileSharingList]\t SetFilesharingTextsL begin" );
       
   406 
       
   407 
       
   408     for ( TInt i(0); i < aProgressInfo.Count(); i++ )
       
   409         {
       
   410         if ( aProgressInfo[ i ].iProgressKind == EImageAndVideo )
       
   411             {
       
   412             if ( aProgressInfo[ i ].iProgressType == 
       
   413                  TUpnpProgressInfo::EVisualStatus )
       
   414                 {
       
   415                 SetDefaultSecondaryTextsL( EImageAndVideo, 
       
   416                                            aProgressInfo[ i ].iProgress );
       
   417                 }
       
   418             else
       
   419                 {
       
   420                 SetProgressSecondaryTextsL( EImageAndVideo, 
       
   421                                             aProgressInfo[ i ].iProgress );
       
   422                 }
       
   423             }
       
   424         else
       
   425             {
       
   426             if ( aProgressInfo[ i ].iProgressType == 
       
   427                  TUpnpProgressInfo::EVisualStatus )
       
   428                 {
       
   429                 SetDefaultSecondaryTextsL( EPlaylist, 
       
   430                                            aProgressInfo[ i ].iProgress );
       
   431                 }
       
   432             else
       
   433                 {
       
   434                 SetProgressSecondaryTextsL( EPlaylist, 
       
   435                                             aProgressInfo[ i ].iProgress );
       
   436                 }
       
   437             }
       
   438         }
       
   439     if( ListBox() && ListBox()->BottomItemIndex() > 1 )
       
   440         {
       
   441         CAknSettingItemList::LoadSettingsL();
       
   442         DrawDeferred();
       
   443         }
       
   444     __LOG( "[CUPnPAppFileSharingList]\t SetFilesharingTextsL end" );
       
   445     }
       
   446 
       
   447 // --------------------------------------------------------------------------
       
   448 // CUPnPAppFileSharingList::SetDefaultSecondaryTextsL
       
   449 // Update the secondary texts in the dialog
       
   450 // --------------------------------------------------------------------------
       
   451 //
       
   452 void CUPnPAppFileSharingList::SetDefaultSecondaryTextsL( 
       
   453     const TInt& aMediaType, 
       
   454     const TInt& aState )
       
   455     {
       
   456     __LOG( "[CUPnPAppFileSharingList]\t \
       
   457 SetDefaultSecondaryTextsL begin" );
       
   458     HBufC* secondaryText = NULL;
       
   459     switch ( aMediaType )
       
   460         {
       
   461     case EImageAndVideo :
       
   462         {
       
   463         if ( aState == EShareAll)
       
   464             {
       
   465             secondaryText = StringLoader::LoadLC(
       
   466                 R_VISUAL_ALBUMS_SHARE_MANY_TEXT);
       
   467             }
       
   468 
       
   469         else if ( aState == EShareNone)
       
   470             {
       
   471             secondaryText = StringLoader::LoadLC(
       
   472                 R_VISUAL_ALBUMS_SHARE_NOTHING_TEXT);
       
   473             }
       
   474 
       
   475         else // there were shared files
       
   476             {
       
   477             secondaryText = StringLoader::LoadLC(
       
   478                 R_VISUAL_ALBUMS_SHARE_ONE_TEXT);
       
   479             }
       
   480 
       
   481         iVisualAlbums.Copy( *secondaryText );
       
   482         }
       
   483         break;
       
   484     case EPlaylist :
       
   485         {
       
   486         if ( aState == EShareAll)
       
   487             {
       
   488             secondaryText = StringLoader::LoadLC(R_MUSIC_SHARE_MANY_TEXT);
       
   489             }
       
   490 
       
   491         else if ( aState == EShareNone)
       
   492             {
       
   493             secondaryText = StringLoader::LoadLC(
       
   494                 R_MUSIC_SHARE_NOTHING_TEXT);
       
   495             }
       
   496 
       
   497         else // there were shared files
       
   498             {
       
   499             secondaryText = StringLoader::LoadLC(R_MUSIC_SHARE_ONE_TEXT);
       
   500 
       
   501             }
       
   502 
       
   503         iPlayLists.Copy( *secondaryText );
       
   504         }
       
   505         break;
       
   506     default:
       
   507         break;
       
   508         }
       
   509     CleanupStack::PopAndDestroy( secondaryText );
       
   510     __LOG( "[CUPnPAppFileSharingList]\t SetDefaultSecondaryTextsL end" );
       
   511     }
       
   512 
       
   513 // --------------------------------------------------------------------------
       
   514 // CUPnPAppFileSharingList::SetProgressSecondaryTextsL
       
   515 // Update the secondary texts in the dialog
       
   516 // --------------------------------------------------------------------------
       
   517 //
       
   518 void CUPnPAppFileSharingList::SetProgressSecondaryTextsL( 
       
   519     const TInt& aMediaType, 
       
   520     const TInt& aProgress )
       
   521     {
       
   522     __LOG( "[CUPnPAppFileSharingList]\t \
       
   523 SetProgressSecondaryTextsL begin" );
       
   524 
       
   525     HBufC* secondaryText = StringLoader::LoadLC(
       
   526             R_SHARINGUI_SECONDARY_IN_PROGRESS, aProgress );
       
   527 
       
   528     switch ( aMediaType )
       
   529         {
       
   530     case EImageAndVideo :
       
   531         {
       
   532         iVisualAlbums.Copy(*secondaryText);
       
   533         }
       
   534         break;
       
   535     case EPlaylist :
       
   536         {
       
   537         iPlayLists.Copy(*secondaryText);
       
   538         }
       
   539         break;
       
   540     default:
       
   541         break;
       
   542         }
       
   543     CleanupStack::PopAndDestroy( secondaryText );
       
   544     __LOG( "[CUPnPAppFileSharingList]\t SetProgressSecondaryTextsL end" );
       
   545     }
       
   546 
       
   547 // --------------------------------------------------------------------------
       
   548 // CUPnPAppFileSharingList::FocusChanged
       
   549 // From CAknDialog
       
   550 // --------------------------------------------------------------------------
       
   551 //
       
   552 void CUPnPAppFileSharingList::FocusChanged( 
       
   553     TDrawNow  /*aDrawNow*/ )
       
   554     {
       
   555     __LOG( "[CUPnPAppFileSharingList]\t \
       
   556 FocusChanged begin" );
       
   557     if ( iWizardRun )
       
   558         {
       
   559         TRAP_IGNORE( iFileSharingEngine->RequestSharingProgressL());
       
   560         iWizardRun = EFalse;
       
   561         }
       
   562 
       
   563     __LOG( "[CUPnPAppFileSharingList]\t FocusChanged end" );
       
   564     }
       
   565 
       
   566 // --------------------------------------------------------------------------
       
   567 // CUPnPAppFileSharingList::ShowWaitNoteL
       
   568 // Shows standard wait note
       
   569 // --------------------------------------------------------------------------
       
   570 //
       
   571 void CUPnPAppFileSharingList::ShowWaitNoteL()
       
   572     {
       
   573     __LOG("[CUPnPAppFileSharingList]\t CUPnPAppFileSharingList::\
       
   574 ShowWaitNoteL begin");
       
   575     TInt resId( R_SHARINGUI_STOPPING_FILE_SHARING_NOTE_DIALOG );
       
   576     if ( !iVisibility )
       
   577         {
       
   578         resId = R_SHARINGUI_STARTING_FILE_SHARING_NOTE_DIALOG;
       
   579         }
       
   580 
       
   581     iStartingSharing = EPhaseNotActive;
       
   582     CAknWaitNoteWrapper* waitNoteWrapper = CAknWaitNoteWrapper::NewL();
       
   583     CleanupStack::PushL(reinterpret_cast<CBase*>(waitNoteWrapper));
       
   584     waitNoteWrapper->ExecuteL(
       
   585         resId,      // TInt aResId,
       
   586         *this,            // MAknBackgroundProcess& aBackgroundProcess
       
   587         ETrue);
       
   588     CleanupStack::PopAndDestroy();
       
   589     __LOG("[CUPnPAppFileSharingList]\t CUPnPAppFileSharingList::\
       
   590 ShowWaitNoteL end");
       
   591     }
       
   592 
       
   593 // --------------------------------------------------------------------------
       
   594 // CUPnPAppFileSharingList::StepL
       
   595 // Step done during wait note
       
   596 // From MAknBackgroundProcess
       
   597 // --------------------------------------------------------------------------
       
   598 //
       
   599 void CUPnPAppFileSharingList::StepL(void)
       
   600     {
       
   601     if ( iStartingSharing == EPhaseNotActive )
       
   602         {
       
   603         iStartingSharing = EPhaseProcessing;
       
   604         }
       
   605     }
       
   606 
       
   607 
       
   608 // --------------------------------------------------------------------------
       
   609 // CUPnPAppFileSharingList::IsProcessDone
       
   610 // Returns ETrue if process finished
       
   611 // From MAknBackgroundProcess
       
   612 // --------------------------------------------------------------------------
       
   613 //
       
   614 TBool CUPnPAppFileSharingList::IsProcessDone(void) const
       
   615     {
       
   616     
       
   617     TBool ret(EFalse);
       
   618     if ( iStartingSharing == EPhaseNotActive )
       
   619         {
       
   620         if ( !iVisibility )
       
   621             {
       
   622             TRAPD( err, iFileSharingEngine->SetSharingStateL( ETrue ) );
       
   623             if( err != KErrNone )
       
   624                 {
       
   625                 return ETrue;
       
   626                 }
       
   627             }
       
   628         else
       
   629             {
       
   630             TRAPD( err, iFileSharingEngine->SetSharingStateL( EFalse ) );
       
   631             if( err != KErrNone )
       
   632                 {
       
   633                 return ETrue;
       
   634                 }
       
   635             }
       
   636         }
       
   637     else if ( iStartingSharing == EPhaseCompleted )
       
   638         {
       
   639         ret = ETrue;
       
   640         }
       
   641     else
       
   642         {
       
   643         __LOG("CUPnPAppFileSharingList::IsProcessDone: else branch");
       
   644         }
       
   645     return ret;
       
   646     }
       
   647 
       
   648 // --------------------------------------------------------------------------
       
   649 // CUPnPAppFileSharingList::UpdateVisibitySettingItemL
       
   650 // Update the visibity of item ,when the list is switched foregroud.
       
   651 // --------------------------------------------------------------------------
       
   652 //
       
   653 void CUPnPAppFileSharingList::UpdateVisibitySettingItemL()
       
   654     {
       
   655     CUPnPSettingsEngine* settingsEngine = CUPnPSettingsEngine::NewL();
       
   656     CleanupStack::PushL( settingsEngine );
       
   657 
       
   658     // Read file sharing state
       
   659     TInt Visibility = 0;
       
   660     if ( iFileSharingEngine->SharingStateL() )
       
   661          {
       
   662          Visibility = 1;
       
   663          }
       
   664     CleanupStack::PopAndDestroy( settingsEngine );
       
   665     
       
   666     if( Visibility != iVisibility )
       
   667         {
       
   668         iVisibility = Visibility;
       
   669         CAknSettingItemList::LoadSettingsL();
       
   670         DrawDeferred();
       
   671         }
       
   672     
       
   673     }
       
   674 //  End of File