upnpframework/upnpcommonui/src/upnpcommonui.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 Common UI.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 // System
       
    21 #include <AknUtils.h>
       
    22 #include <featmgr.h>
       
    23 #include <bautils.h>
       
    24 #include <StringLoader.h>
       
    25 #include <aknnotewrappers.h>
       
    26 #include <pathinfo.h> //PathInfo
       
    27 
       
    28 // upnp stack api
       
    29 #include <upnpobject.h>
       
    30 
       
    31 // upnpframework / avcontroller api
       
    32 #include "upnpavcontroller.h"
       
    33 #include "upnpavrenderingsession.h"
       
    34 #include "upnpavdevice.h"
       
    35 #include "upnpmediaserversettings.h"
       
    36 
       
    37 // upnpframework / internal api's
       
    38 #include "upnpmusicadapter.h"
       
    39 
       
    40 // commonui internal
       
    41 #include "upnpcommonui.h"
       
    42 #include <upnpcommonui.rsg>
       
    43 #include "upnpexternaldevicedialog.h"
       
    44 #include "upnpbrowsedialog.h"
       
    45 #include "upnpvideoplayerdialog.h"
       
    46 #include "upnpadvfinddialog.h"
       
    47 #include "upnpselectiondialog.h"
       
    48 
       
    49 // debug stuff
       
    50 _LIT( KComponentLogfile, "commonui.txt");
       
    51 #include "upnplog.h"
       
    52 
       
    53 // CONSTANTS
       
    54 // Filename of rsc file
       
    55 _LIT( KUPnPCommonUiRscFile, "\\resource\\upnpcommonui.rsc" );
       
    56 
       
    57 // ============================ MEMBER FUNCTIONS ============================
       
    58 
       
    59 // --------------------------------------------------------------------------
       
    60 // CUPnPCommonUI::CUPnPCommonUI
       
    61 // --------------------------------------------------------------------------
       
    62 //
       
    63 CUPnPCommonUI::CUPnPCommonUI()
       
    64     {
       
    65     __LOG( "CUPnPCommonUI::CUPnPCommonUI" );
       
    66     iFeatureManagerInitialized = EFalse;
       
    67     }
       
    68 
       
    69 // --------------------------------------------------------------------------
       
    70 // CUPnPCommonUI::ConstructL()
       
    71 // Symbian 2nd phase constructor can leave.
       
    72 // --------------------------------------------------------------------------
       
    73 //
       
    74 void CUPnPCommonUI::ConstructL()
       
    75     {
       
    76     __LOG( "CUPnPCommonUI::ConstructL" );
       
    77 
       
    78     iCoeEnv = CEikonEnv::Static();
       
    79     RFs& fileSession = iCoeEnv->FsSession();
       
    80 
       
    81     // Load common ui resource file
       
    82     TFileName rscFileName( KUPnPCommonUiRscFile );
       
    83     TFileName dllName;
       
    84     Dll::FileName( dllName );
       
    85     TBuf<2> drive = dllName.Left( 2 ); // Drive letter followed by ':' 
       
    86     rscFileName.Insert( 0, drive );
       
    87     
       
    88     // Get the exact filename of the resource file
       
    89     BaflUtils::NearestLanguageFile( fileSession, rscFileName );
       
    90     // Check if the resource file exists or not
       
    91     if ( !BaflUtils::FileExists( fileSession, rscFileName ) )
       
    92         {
       
    93         User::Leave( KErrNotFound );
       
    94         }
       
    95     iResFileOffset = iCoeEnv->AddResourceFileL( rscFileName );
       
    96 
       
    97     FeatureManager::InitializeLibL();
       
    98     iFeatureManagerInitialized = ETrue;
       
    99 
       
   100     // Get AppUI pointer
       
   101     iAppUi = static_cast<CAknViewAppUi*>( iCoeEnv->EikAppUi() );
       
   102     }
       
   103 
       
   104 // --------------------------------------------------------------------------
       
   105 // CUPnPCommonUI::NewL()
       
   106 // Two-phased constructor.
       
   107 // --------------------------------------------------------------------------
       
   108 //
       
   109 EXPORT_C CUPnPCommonUI* CUPnPCommonUI::NewL()
       
   110     {
       
   111     __LOG( "CUPnPCommonUI::NewL" );
       
   112     
       
   113     CUPnPCommonUI* self = new ( ELeave) CUPnPCommonUI();
       
   114     CleanupStack::PushL( self );
       
   115 
       
   116     self->ConstructL();
       
   117     CleanupStack::Pop();
       
   118     return self;
       
   119     }
       
   120 
       
   121 // --------------------------------------------------------------------------
       
   122 // Destructor
       
   123 // --------------------------------------------------------------------------
       
   124 //
       
   125 EXPORT_C CUPnPCommonUI::~CUPnPCommonUI()
       
   126     {
       
   127     __LOG( "CUPnPCommonUI::~CUPnPCommonUI" );
       
   128 
       
   129     if ( iFeatureManagerInitialized )
       
   130         {
       
   131         FeatureManager::UnInitializeLib();
       
   132         }
       
   133    
       
   134     // Un-Load resource file
       
   135     if ( iResFileOffset )
       
   136         {
       
   137         iCoeEnv->DeleteResourceFile( iResFileOffset );
       
   138         iResFileOffset = 0;
       
   139         }
       
   140     }
       
   141 
       
   142 // --------------------------------------------------------------------------
       
   143 // CUPnPCommonUI::ExecuteDeviceDialogL
       
   144 // --------------------------------------------------------------------------
       
   145 //
       
   146 EXPORT_C TInt CUPnPCommonUI::ExecuteDeviceDialogL(
       
   147     MUPnPAVController& aAVControl )
       
   148     {
       
   149     __LOG( "CUPnPCommonUI::ExecuteDeviceDialogL" );
       
   150     
       
   151     TInt returnValue = KErrArgument;
       
   152 
       
   153     iExternalDeviceSelection = CUPnPExternalDeviceDialog::NewL(
       
   154         R_UPNPCOMMONUI_EXTERNAL_DEVICE_DIALOG_MENUBAR,
       
   155         aAVControl,
       
   156         *this );
       
   157 
       
   158     
       
   159     iExternalDeviceSelection->SetMopParent( iAppUi );
       
   160     returnValue = iExternalDeviceSelection->ExecuteLD(
       
   161         R_UPNPCOMMONUI_EXTERNAL_MEDIA_SELECT_DIALOG );
       
   162     iExternalDeviceSelection = NULL;
       
   163 
       
   164     return returnValue;
       
   165     }
       
   166 
       
   167 // --------------------------------------------------------------------------
       
   168 // CUPnPCommonUI::ExecuteBrowseDialogL
       
   169 // --------------------------------------------------------------------------
       
   170 //
       
   171 EXPORT_C TInt CUPnPCommonUI::ExecuteBrowseDialogL(
       
   172     MUPnPAVController& aAVControl,
       
   173     const CUpnpAVDevice& aDevice)
       
   174     {
       
   175     __LOG( "CUPnPCommonUI::ExecuteBrowseDialogL" );
       
   176 
       
   177 
       
   178     TInt returnValue = KErrArgument;
       
   179     
       
   180     TInt error = KErrNone; 
       
   181 
       
   182 
       
   183     iBrowseSelection = CUPnPBrowseDialog::NewL(
       
   184             R_UPNPCOMMONUI_BROWSE_DIALOG_MENUBAR, aAVControl, aDevice, *this );
       
   185 
       
   186     iBrowseSelection->SetMopParent( iAppUi );
       
   187     TRAP( error, returnValue =  iBrowseSelection->ExecuteLD( 
       
   188                                         R_UPNPCOMMONUI_BROWSE_DIALOG ) );
       
   189     iBrowseSelection = NULL;
       
   190 
       
   191     if( error != KErrNone )
       
   192         {
       
   193         returnValue = error;
       
   194         }
       
   195     return returnValue;
       
   196     }
       
   197 
       
   198 // --------------------------------------------------------------------------
       
   199 // CUPnPCommonUI::ExecuteVideoPlayerL
       
   200 // --------------------------------------------------------------------------
       
   201 //
       
   202 EXPORT_C TInt CUPnPCommonUI::ExecuteVideoPlayerL( 
       
   203     MUPnPAVRenderingSession& aRenderingSession,
       
   204     const CUpnpObject& aObject )
       
   205     {
       
   206     __LOG( "CUPnPCommonUI::ExecuteVideoPlayerL" );
       
   207 
       
   208     TInt returnValue = KErrArgument;
       
   209 
       
   210     iVideoPlayerDialog = CUPnPVideoPlayerDlg::NewL( 
       
   211               aRenderingSession, aObject, *this );
       
   212     iVideoPlayerDialog->SetMopParent( iAppUi );
       
   213     TRAPD( error, returnValue = iVideoPlayerDialog->ExecuteLD(
       
   214         R_UPNPCOMMONUI_VIDEO_PLAYER_DIALOG ) );
       
   215     iVideoPlayerDialog = NULL;
       
   216     
       
   217     if( error != KErrNone )
       
   218         {
       
   219         returnValue = error;
       
   220         }
       
   221         
       
   222     return returnValue;
       
   223     }
       
   224 
       
   225 // --------------------------------------------------------------------------
       
   226 // CUPnPCommonUI::ExecuteMusicPlayerL
       
   227 // --------------------------------------------------------------------------
       
   228 //
       
   229 EXPORT_C TInt CUPnPCommonUI::ExecuteMusicPlayerL( 
       
   230                                    MUPnPAVController& aAVControl,
       
   231                                    CUPnPPlayListFiller* aFiller,
       
   232                                    const CUpnpAVDevice* aTargetDevice )
       
   233     {
       
   234     TInt returnValue = KErrArgument;
       
   235 
       
   236     iMusicAdapter = CUPnPMusicAdapter::NewL( aAVControl ); 
       
   237     TInt error = KErrNone;   
       
   238     if( aTargetDevice )
       
   239         {
       
   240         //play in remote
       
   241         TRAP( error, returnValue = iMusicAdapter->ExecuteMusicInRemoteL( 
       
   242             iCoeEnv->EikAppUi(),
       
   243             aFiller,
       
   244             *aTargetDevice ) );
       
   245         }
       
   246     else 
       
   247         {
       
   248         //play in local
       
   249         TRAP( error, returnValue = iMusicAdapter->ExecuteMusicInLocalL(
       
   250              iCoeEnv->EikAppUi(),
       
   251              aFiller ) );
       
   252         }
       
   253     delete iMusicAdapter;
       
   254     iMusicAdapter = 0;
       
   255 
       
   256     if( error != KErrNone )
       
   257         {
       
   258         returnValue = error;
       
   259         }
       
   260     return returnValue;
       
   261     }
       
   262 
       
   263                   
       
   264 // --------------------------------------------------------------------------
       
   265 // CUPnPCommonUI::SelectDeviceL
       
   266 // Displays a UPnP device selection pop-up dialog.
       
   267 // --------------------------------------------------------------------------
       
   268 EXPORT_C TInt CUPnPCommonUI::SelectDeviceL( MUPnPAVController& aAVControl,
       
   269                                             CUpnpAVDevice& aDevice,
       
   270                                             TUPnPDeviceTypesToSearch aType,
       
   271                                             TUPnPDialogTitle aTitle )
       
   272     {
       
   273     __LOG( "CUPnPCommonUI::SelectDeviceL" );
       
   274 
       
   275 
       
   276     TInt returnValue = KErrGeneral;
       
   277 
       
   278     // Create the selection popup
       
   279     delete iDeviceSelection; iDeviceSelection = NULL;
       
   280     iDeviceSelection = CUPnPSelectionDialog::NewL( aAVControl );
       
   281     
       
   282     // Read the title string
       
   283     HBufC* title = NULL;
       
   284     if( aTitle == EUPnPCopyToTitle )
       
   285         {
       
   286         title = StringLoader::LoadLC( R_UPNPCOMMONUI_COPY_TO_TEXT );
       
   287         } 
       
   288     else if( aTitle == EUPnPMoveToTitle )
       
   289         {        
       
   290         title = StringLoader::LoadLC( R_UPNPCOMMONUI_MOVE_TO_TEXT );
       
   291         }
       
   292     else
       
   293         {
       
   294         if( aType == EUPnPSearchRenderingDevicesWithAudioCapability )
       
   295             {
       
   296             title = StringLoader::LoadLC( R_UPNPCOMMONUI_SELECT_PLAYER_TEXT );
       
   297             }
       
   298         else
       
   299             {
       
   300             title = StringLoader::LoadLC( R_UPNPCOMMONUI_SELECT_DEVICE_TEXT );
       
   301             }
       
   302         }
       
   303 
       
   304     if( aType == EUPnPSearchAllDevices ||
       
   305         aType == EUPnPSearchAllServerDevices ||
       
   306         aType == EUPnPSearchServerDevicesWithCopyCapability ||
       
   307         aType == EUPnPSearchServerDevicesWithSearchCapability ||
       
   308         aType == EUPnPSearchAllRenderingDevices ||
       
   309         aType == EUPnPSearchRenderingDevicesWithImageCapability ||
       
   310         aType == EUPnPSearchRenderingDevicesWithVideoCapability ||
       
   311         aType == EUPnPSearchRenderingDevicesWithImageAndVideoCapability ||
       
   312         aType == EUPnPSearchRenderingDevicesWithAudioCapability )
       
   313         {
       
   314         iDeviceSelection->CreatePopupL( *title, aType );
       
   315         returnValue = iDeviceSelection->StartPopupL( aDevice );
       
   316         }
       
   317     else
       
   318         {
       
   319         CleanupStack::PopAndDestroy( title ); 
       
   320         title = NULL;
       
   321         return KErrNotSupported;
       
   322         }
       
   323     
       
   324      // Clean up
       
   325     CleanupStack::PopAndDestroy( title ); 
       
   326     title = NULL;
       
   327     delete iDeviceSelection; iDeviceSelection = NULL;
       
   328 
       
   329     __LOG1( "CUPnPCommonUI::SelectDeviceL: %d", returnValue );
       
   330     return returnValue;
       
   331     }
       
   332 
       
   333 // --------------------------------------------------------------------------
       
   334 // CUPnPCommonUI::DisplayConnectionErrorNote()
       
   335 // Displays error note R_UPNP_ERROR_CON_TEXT
       
   336 // --------------------------------------------------------------------------
       
   337 //
       
   338 EXPORT_C void CUPnPCommonUI::DisplayConnectionErrorNoteL()
       
   339     {
       
   340     HBufC* errorText = StringLoader::LoadLC( R_UPNPCOMMONUI_ERROR_CON_TEXT );
       
   341     CAknErrorNote* errorNote = new ( ELeave ) CAknErrorNote( ETrue );
       
   342     errorNote->ExecuteLD( *errorText );
       
   343     CleanupStack::PopAndDestroy( errorText );
       
   344     }
       
   345 
       
   346 // --------------------------------------------------------------------------
       
   347 // CUPnPCommonUI::DisplayConnectionLostCopyErrorNoteL()
       
   348 // Displays error note R_UPNPCOMMONUI_CONN_LOST_COPY_ERROR_TEXT
       
   349 // --------------------------------------------------------------------------
       
   350 //
       
   351 EXPORT_C void CUPnPCommonUI::DisplayConnectionLostCopyErrorNoteL()
       
   352     {
       
   353     __LOG( "CUPnPCommonUI::DisplayConnectionLostCopyErrorNoteL" );
       
   354     HBufC* errorText = StringLoader::LoadLC( 
       
   355                            R_UPNPCOMMONUI_CONN_LOST_COPY_ERROR_TEXT );
       
   356     CAknErrorNote* errorNote = new ( ELeave ) CAknErrorNote( ETrue );
       
   357     errorNote->ExecuteLD( *errorText );
       
   358     CleanupStack::PopAndDestroy( errorText );
       
   359     }
       
   360 
       
   361 // --------------------------------------------------------------------------
       
   362 // CUPnPCommonUI::ExecuteAdvFindDialogL()
       
   363 // --------------------------------------------------------------------------
       
   364 //
       
   365 TInt CUPnPCommonUI::ExecuteAdvFindDialogL(
       
   366                                 MUPnPAVController& aAVControl,
       
   367                                 MUPnPAVBrowsingSession& aBrowsingSession)
       
   368 
       
   369     {
       
   370     __LOG( "CUPnPCommonUI::ExecuteAdvFindDialogL" );
       
   371     
       
   372     
       
   373     TInt returnValue = KErrArgument;
       
   374     TInt error = KErrNone;
       
   375 
       
   376     iAdvFindDialog = CUPnPAdvancedFindDialog::NewL(
       
   377                             R_UPNPCOMMONUI_ADVANCED_FIND_MAIN_DIALOG,
       
   378                             aAVControl,
       
   379                             aBrowsingSession,
       
   380                             *this );
       
   381 
       
   382     iAdvFindDialog->SetMopParent( iAppUi );
       
   383 
       
   384     TRAP( error, returnValue = iAdvFindDialog->ExecuteLD(
       
   385                             R_UPNPCOMMONUI_ADVANCED_FIND_MAIN_DIALOG ) );
       
   386     
       
   387     iAdvFindDialog = NULL;
       
   388     
       
   389     if( KErrNone != error )
       
   390         {
       
   391         returnValue = error;
       
   392         }
       
   393     
       
   394     return returnValue;
       
   395     }
       
   396 
       
   397 // --------------------------------------------------------------------------
       
   398 // CUPnPCommonUI::DismissDialogL()
       
   399 // called only when the media server disconnected or WLAN connection is lost
       
   400 // to close the dialogs which are running on the top of the mother class
       
   401 // --------------------------------------------------------------------------
       
   402 //
       
   403 EXPORT_C void CUPnPCommonUI::DismissDialogL( TInt aError )
       
   404     {
       
   405     if( iDeviceSelection && KErrSessionClosed == aError )
       
   406         {
       
   407         iDeviceSelection->DismissItself( aError );
       
   408         }
       
   409     
       
   410     if( iVideoPlayerDialog )
       
   411         {
       
   412         iVideoPlayerDialog->DismissItselfL( aError ); 
       
   413         iVideoPlayerDialog = NULL;
       
   414         }
       
   415         
       
   416     if( iMusicAdapter )
       
   417         {
       
   418         iMusicAdapter->Dismiss( aError );
       
   419         //iMusicAdapter = NULL;
       
   420         }
       
   421     }
       
   422 
       
   423 // --------------------------------------------------------------------------
       
   424 // CUPnPCommonUI::DisplayErrorTextL
       
   425 // 
       
   426 // --------------------------------------------------------------------------
       
   427 void CUPnPCommonUI::DisplayErrorTextL( TInt aResource )
       
   428     {
       
   429     CAknErrorNote* errorNote = new( ELeave )CAknErrorNote();
       
   430     errorNote->ExecuteLD( *StringLoader::LoadLC( aResource ) );
       
   431     CleanupStack::PopAndDestroy();  
       
   432     }
       
   433 
       
   434 // --------------------------------------------------------------------------
       
   435 // CUPnPCommonUI::DisplayErrorTextL
       
   436 // --------------------------------------------------------------------------
       
   437 // 
       
   438 void CUPnPCommonUI::DisplayErrorTextL( TInt aResource, const TDesC& aInfo )
       
   439     {
       
   440     HBufC* errorText = StringLoader::LoadLC( aResource, aInfo );
       
   441     CAknErrorNote* errorNote = new ( ELeave ) CAknErrorNote( ETrue );
       
   442     errorNote->ExecuteLD( *errorText );
       
   443     CleanupStack::PopAndDestroy( errorText );
       
   444     }
       
   445 
       
   446 // --------------------------------------------------------------------------
       
   447 // CUPnPBrowseDialog::DisplayErrorNote
       
   448 // --------------------------------------------------------------------------
       
   449 //    
       
   450 void CUPnPCommonUI::DisplayErrorTextL( TInt aResource,
       
   451                                        TInt aMaxNumberOfResultsShown )
       
   452     {    
       
   453     HBufC* errorText = StringLoader::LoadLC( aResource, 
       
   454                                              aMaxNumberOfResultsShown );
       
   455     CAknErrorNote* errorNote = new ( ELeave ) CAknErrorNote( ETrue );
       
   456     errorNote->ExecuteLD( *errorText );
       
   457     CleanupStack::PopAndDestroy( errorText );
       
   458     }
       
   459 
       
   460 // --------------------------------------------------------------------------
       
   461 // CUPnPBrowseDialog::DisplayInfoTextL
       
   462 // --------------------------------------------------------------------------
       
   463 //      
       
   464 void CUPnPCommonUI::DisplayInfoTextL( TInt aResource,
       
   465                                       TInt aNumberOfCopy )
       
   466     {
       
   467     CAknInformationNote* errorNote = 
       
   468                                 new( ELeave )CAknInformationNote( ETrue );
       
   469     errorNote->ExecuteLD( *StringLoader::LoadLC( aResource, 
       
   470                                                  aNumberOfCopy ) );
       
   471     CleanupStack::PopAndDestroy(); 
       
   472     }
       
   473     
       
   474 // --------------------------------------------------------------------------
       
   475 // CUPnPBrowseDialog::DisplayInfoTextL
       
   476 // --------------------------------------------------------------------------
       
   477 //      
       
   478 void CUPnPCommonUI::DisplayInfoTextL( TInt aResource )
       
   479     {
       
   480     CAknInformationNote* errorNote = 
       
   481                                 new( ELeave )CAknInformationNote( );
       
   482     errorNote->ExecuteLD( *StringLoader::LoadLC( aResource ) );
       
   483     CleanupStack::PopAndDestroy(); 
       
   484     }    
       
   485     
       
   486 // --------------------------------------------------------------------------
       
   487 // CUPnPBrowseDialog::PresenceOfDialog
       
   488 // --------------------------------------------------------------------------
       
   489 //  
       
   490 TBool CUPnPCommonUI::PresenceOfDialog()
       
   491     {
       
   492     if( iBrowseSelection || iAdvFindDialog || iDeviceSelection )
       
   493         {
       
   494         return ETrue;
       
   495         }
       
   496     return EFalse;
       
   497     }
       
   498 
       
   499 // --------------------------------------------------------------------------
       
   500 // CUPnPCommonUI::GetUpnpAction()
       
   501 // --------------------------------------------------------------------------
       
   502 //
       
   503 void CUPnPCommonUI::GetUpnpAction( TUPnPAction aAction )
       
   504     {
       
   505     iAction = aAction;
       
   506     }
       
   507 
       
   508 // --------------------------------------------------------------------------
       
   509 // CUPnPBrowseDialog::HandleCommonErrorL
       
   510 // --------------------------------------------------------------------------
       
   511 //      
       
   512 void CUPnPCommonUI::HandleCommonErrorL( TInt aError,
       
   513                                         TInt aCopyIndex  )
       
   514     {
       
   515     
       
   516     //specified errors for every action should be handled first
       
   517     // common erros last
       
   518     __LOG1( "CUPnPCommonUI::HandleCommonErrorL: %d", aError );
       
   519     
       
   520     if( KErrNone <= aError && ( iAction == CUPnPCommonUI::EUPnPNone ||
       
   521         iAction != CUPnPCommonUI::EUPnPCopy ) )
       
   522         {
       
   523         iAction = EUPnPNone;
       
   524         return;
       
   525         }
       
   526     switch( aError )
       
   527         {
       
   528         case KErrCancel:
       
   529             {
       
   530             break;
       
   531             }
       
   532         case KErrServerBusy:
       
   533             {
       
   534             DisplayErrorTextL( R_UPNPCOMMONUI_GENERAL_FAILURE_ERROR_TEXT );
       
   535             break; 
       
   536             }
       
   537         case KErrNoMemory:
       
   538             {
       
   539             DisplayErrorTextL( R_UPNPCOMMONUI_NOMEMORY_TEXT );
       
   540             break;
       
   541             }
       
   542         case KErrDiskFull:
       
   543             {
       
   544             HBufC* copyLocation = HBufC::NewLC( KMaxFileName );
       
   545             TPtr copyLocationPtr( copyLocation->Des() );
       
   546             GetCopyLocationL( copyLocationPtr );
       
   547             TPtr driveName = copyLocationPtr.LeftTPtr( 2 );
       
   548             DisplayErrorTextL( R_UPNPCOMMONUI_DEVICE_MEMORY_LOW, driveName );
       
   549             CleanupStack::PopAndDestroy( copyLocation );
       
   550             break;
       
   551             }
       
   552         case KErrSessionClosed:
       
   553         case KErrDisconnected:
       
   554             {
       
   555             if( iAction == CUPnPCommonUI::EUPnPCopy )
       
   556                 {
       
   557                 //Connection lost, some files may not be copied
       
   558                 DisplayErrorTextL( R_UPNPCOMMONUI_CONN_LOST_COPY_ERROR_TEXT );
       
   559                 }
       
   560             else if( KErrSessionClosed == aError &&
       
   561                      iAction != CUPnPCommonUI::EUPnPCopy )
       
   562                 {
       
   563                 //connection failed
       
   564                 DisplayErrorTextL( R_UPNPCOMMONUI_ERROR_CON_TEXT );
       
   565                 }
       
   566             delete iBrowseSelection;
       
   567             iBrowseSelection = NULL;
       
   568             break;
       
   569             }
       
   570         case KErrNotSupported:
       
   571             {
       
   572             //Selected device does not support this operation
       
   573             DisplayErrorTextL( R_UPNPCOMMONUI_NOT_SUPPORTED_ERROR_TEXT );
       
   574             break;
       
   575             }
       
   576         default:
       
   577             {
       
   578             if( iAction != EUPnPNone )
       
   579                 {
       
   580                 if( iAction == EUPnPCopy )  
       
   581                     {
       
   582                     if( KErrNone == aError )
       
   583                         {
       
   584                         if( aCopyIndex == 1) //copying single item OK
       
   585                             {
       
   586                             DisplayInfoTextL( 
       
   587                                     R_UPNPCOMMONUI_INFO_COPY_ONE_TEXT );
       
   588                             }
       
   589                         else if( aCopyIndex > 1 ) //copying multi items OK
       
   590                             {
       
   591                             DisplayInfoTextL( 
       
   592                                     R_UPNPCOMMONUI_INFO_COPY_MANY_TEXT, 
       
   593                                     aCopyIndex );
       
   594                             }
       
   595                         else
       
   596                             {
       
   597                             //
       
   598                             }    
       
   599                         }
       
   600                     else
       
   601                         {
       
   602                         if( KErrNotFound == aError )
       
   603                             {
       
   604                             if( aCopyIndex ) //copying a container
       
   605                                 {
       
   606                                 //"Container does not contain any items."
       
   607                                 DisplayErrorTextL( 
       
   608                                 R_UPNPCOMMONUI_NO_ITEMS_TO_PLAY_TEXT );
       
   609                                 }
       
   610                             else
       
   611                                 {
       
   612                                 //copy failed
       
   613                                 DisplayErrorTextL( 
       
   614                                 R_UPNPCOMMONUI_GENERAL_FAILURE_ERROR_TEXT );
       
   615                                 }
       
   616                             }
       
   617                          else //if copying, unkown error
       
   618                             {
       
   619                             //copy failed
       
   620                             DisplayErrorTextL( 
       
   621                                 R_UPNPCOMMONUI_GENERAL_FAILURE_ERROR_TEXT );
       
   622                             }   
       
   623                         }
       
   624                     }
       
   625                 else if( iAction == EUPnPShow )
       
   626                     {
       
   627                     if( KErrNone != aError )
       
   628                         {
       
   629                         //Playback failed on the remote device for 
       
   630                         //unknown error. Try again
       
   631                         DisplayErrorTextL( 
       
   632                         R_UPNPCOMMONUI_RENDERING_FAILED_UNKNOWN_ERROR_TEXT );
       
   633                         }
       
   634                     }
       
   635                 else
       
   636                     {
       
   637                     if( KErrNone != aError )
       
   638                         {
       
   639                         //Selected device refused the operation
       
   640                         DisplayErrorTextL( 
       
   641                             R_UPNPCOMMONUI_GENERAL_FAILURE_ERROR_TEXT );
       
   642                         }
       
   643                     }
       
   644                 }//if( iAction != EUPnPNone )
       
   645            
       
   646             break;        
       
   647             }//default:
       
   648             
       
   649         } // switch( aError )
       
   650         
       
   651         iAction = EUPnPNone;
       
   652     }
       
   653 
       
   654 // --------------------------------------------------------------------------
       
   655 // CUPnPCommonUI::GetCopyLocationL
       
   656 // --------------------------------------------------------------------------
       
   657 //
       
   658 void CUPnPCommonUI::GetCopyLocationL( TDes& aLocation ) const
       
   659     {
       
   660     // Get instance of Server Settings object
       
   661     CUpnpMediaServerSettings* settings = CUpnpMediaServerSettings::NewL();
       
   662     CleanupStack::PushL( settings );
       
   663 
       
   664     // Get the location setting from ServerSettings
       
   665     settings->Get( UpnpMediaServerSettings::EUploadDirectory, aLocation );
       
   666         
       
   667     CleanupStack::PopAndDestroy( settings );    
       
   668     }
       
   669 // End of File