profilesapplication/Profiles/ProfileApp/SettingsViewSrc/CProfileFileListSettingItem.cpp
changeset 0 ca436256272f
child 2 627793106ff9
equal deleted inserted replaced
-1:000000000000 0:ca436256272f
       
     1 /*
       
     2 * Copyright (c) 2002-2006 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:  Setting item class for tone selection.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // CLASS HEADER
       
    21 #include "CProfileFileListSettingItem.h"
       
    22 
       
    23 // INTERNAL INCLUDES
       
    24 #include <coemain.h>
       
    25 
       
    26 #include <profile.hrh> // From Profile Engine
       
    27 #include <StringLoader.h>
       
    28 #include <centralrepository.h>
       
    29 #include <profileengineinternalcrkeys.h>
       
    30 #include <ProfileSettingsView.rsg>
       
    31 #include <data_caging_path_literals.hrh>
       
    32 #include <CLFContentListing.hrh>	// For TCLFMediaType::ECLFMediaTypeVideo
       
    33 
       
    34 // for mediafilelist
       
    35 #include <mediafilelist.h>
       
    36 #include <profileinternal.hrh>
       
    37 #include <DRMHelper.h>
       
    38 
       
    39 
       
    40 // EXTERNAL INCLUDES
       
    41 #include "ProfilePanics.h"
       
    42 #include "ProfileSettingsView.hrh"
       
    43 
       
    44 namespace
       
    45 	{
       
    46 // CONSTANTS
       
    47 	_LIT( KIgnoredExtension, ".RNG" );
       
    48 	_LIT( KProfileSilentTone, "Z:No_Sound.wav" );
       
    49 
       
    50 	_LIT( KProfileAudioMpeg, "audio/mpegurl" );
       
    51 	_LIT( KProfileAudioRAPlugin, "audio/x-pn-realaudio-plugin" );
       
    52 #ifndef __WMA
       
    53 	_LIT( KProfileAudioWMA, "audio/x-ms-wma" );
       
    54 #endif
       
    55 	}
       
    56 
       
    57 // ============================ MEMBER FUNCTIONS ===============================
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CProfileFileListSettingItem::CProfileFileListSettingItem
       
    61 // C++ constructor can NOT contain any code, that might leave.
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 CProfileFileListSettingItem::CProfileFileListSettingItem(
       
    65     TInt aIdentifier,
       
    66     TDes& aToneFileName,
       
    67     const TInt& aRingingType,
       
    68     const TInt& aRingingVolume,
       
    69     const TBool& aVibratingAlert,
       
    70     TInt& a3DEffect,
       
    71     TInt& a3DEcho,
       
    72     CCoeEnv* aCoeEnv )
       
    73     :   CAknSettingItem( aIdentifier ),
       
    74         iExternalToneFileName( aToneFileName ),
       
    75         iRingingType( aRingingType ),
       
    76         iRingingVolume( aRingingVolume ),
       
    77         iVibratingAlert( aVibratingAlert ),
       
    78         i3DEffect( a3DEffect ),
       
    79         i3DEcho( a3DEcho ),
       
    80         iCoeEnv( aCoeEnv )
       
    81     {
       
    82     }
       
    83 
       
    84 // Destructor
       
    85 CProfileFileListSettingItem::~CProfileFileListSettingItem()
       
    86     {
       
    87     delete iTitle;
       
    88     delete iNoSoundFileName;
       
    89     delete iNoSoundText;
       
    90     delete iInternalToneFileName;
       
    91     }
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // CProfileFileListSettingItem::CompleteConstructionL
       
    95 // -----------------------------------------------------------------------------
       
    96 //
       
    97 void CProfileFileListSettingItem::CompleteConstructionL()
       
    98     {
       
    99     iNoSoundText =
       
   100 		StringLoader::LoadL( R_PROFILE_TEXT_NONE );
       
   101 
       
   102 	TFileName fileName;
       
   103 	TParse* fp = new(ELeave) TParse();
       
   104 	fp->Set(KProfileSilentTone, &KDC_RESOURCE_FILES_DIR, NULL);
       
   105 	fileName.Copy( fp->FullName() );
       
   106 	delete fp;
       
   107 	iNoSoundFileName = fileName.AllocL();
       
   108     iTitle =
       
   109         StringLoader::LoadL( R_PROFILE_TEXT_SELECT_TONE );
       
   110 
       
   111 	iInternalToneFileName = new( ELeave ) TFileName();
       
   112     }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CProfileFileListSettingItem::StoreL
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 void CProfileFileListSettingItem::StoreL()
       
   119     {
       
   120     if( iInternalToneFileName->Length() == 0 )
       
   121         {
       
   122         iInternalToneFileName->Copy( iNoSoundFileName->Des() );
       
   123         }
       
   124     iExternalToneFileName.Copy( *iInternalToneFileName );
       
   125     }
       
   126 
       
   127 // -----------------------------------------------------------------------------
       
   128 // CProfileFileListSettingItem::LoadL
       
   129 // -----------------------------------------------------------------------------
       
   130 //
       
   131 void CProfileFileListSettingItem::LoadL()
       
   132     {
       
   133     iInternalToneFileName->Copy( iExternalToneFileName );
       
   134     
       
   135     if( iInternalToneFileName->Length() == 0 )
       
   136         {
       
   137         iInternalToneFileName->Copy( iNoSoundFileName->Des() );
       
   138         }
       
   139     }
       
   140 
       
   141 
       
   142 // -----------------------------------------------------------------------------
       
   143 // CProfileFileListSettingItem::EditItemL
       
   144 // -----------------------------------------------------------------------------
       
   145 //
       
   146 void CProfileFileListSettingItem::EditItemL( TBool /*aCalledFromMenu*/ )
       
   147     {
       
   148     TInt ringingType( iRingingType );
       
   149     TInt id( Identifier() );
       
   150     if( ( id == EProfileSettingMessageAlertToneId ) ||
       
   151         ( id == EProfileSettingEmailAlertToneId ) )
       
   152         {
       
   153         // Message alert tone is always played EProfileRingingTypeRingingOnce
       
   154         // Exceptions are Silent and Beeb Once
       
   155          if( ( ringingType == EProfileRingingTypeRinging ) ||
       
   156             ( ringingType == EProfileRingingTypeAscending ) )
       
   157             {
       
   158             ringingType = EProfileRingingTypeRingingOnce;
       
   159             }
       
   160         }
       
   161 
       
   162     TFileName fileName;
       
   163     TInt nullItem = KErrNotFound;    
       
   164         
       
   165     CMediaFileList* list = CMediaFileList::NewL();
       
   166     CleanupStack::PushL( list );
       
   167 
       
   168     list->SetAttrL( CMediaFileList::EAttrTitle, *iTitle );
       
   169     list->SetAttrL( CMediaFileList::EAttrVolume, iRingingVolume );
       
   170     list->SetAttrL( CMediaFileList::EAttrVibra, iVibratingAlert );
       
   171     list->SetAttrL( CMediaFileList::EAttrRingingType, ringingType );
       
   172     list->SetAttrL( CMediaFileList::EAttrExcludeMimeType, KProfileAudioMpeg );
       
   173     list->SetAttrL( CMediaFileList::EAttrExcludeMimeType, KProfileAudioRAPlugin );
       
   174 #ifndef __WMA
       
   175     list->SetAttrL( CMediaFileList::EAttrExcludeMimeType, KProfileAudioWMA );
       
   176 #endif
       
   177   
       
   178     list->SetAttrL( CMediaFileList::EAttrAutomatedType, CDRMHelper::EAutomatedTypeRingingTone );
       
   179 
       
   180     if( id == EProfileSettingPTTRingingToneId )
       
   181         {
       
   182         // PTT does not allow videos
       
   183         list->SetAttrL( CMediaFileList::EAttrExcludeFolder, CMediaFileList::EMediaFileTypeVideo );
       
   184         }
       
   185 
       
   186     if( id == EProfileSettingMessageAlertToneId )
       
   187         {
       
   188         list->SetAttrL( CMediaFileList::EAttrAutomatedType, CDRMHelper::EAutomatedTypeMessageAlert );
       
   189         }
       
   190     else if( id == EProfileSettingEmailAlertToneId )
       
   191         {
       
   192         list->SetAttrL( CMediaFileList::EAttrAutomatedType, CDRMHelper::EAutomatedTypeEmailAlert );
       
   193         }
       
   194        
       
   195     // Size limit for voice call tone files
       
   196     if ( id == EProfileSettingRingingToneId      ||
       
   197          id == EProfileSettingRingingToneLine1Id ||
       
   198          id == EProfileSettingRingingToneLine2Id )
       
   199         {
       
   200         TInt sizeLimitKB = 0;
       
   201         CRepository* cenrep = CRepository::NewL( KCRUidProfileEngine );
       
   202         CleanupStack::PushL( cenrep );
       
   203         User::LeaveIfError( cenrep->Get( KProEngRingingToneMaxSize, sizeLimitKB ) );
       
   204         CleanupStack::PopAndDestroy(); // cenrep
       
   205 
       
   206         list->SetAttrL( CMediaFileList::EAttrFileSize, sizeLimitKB );
       
   207         
       
   208 
       
   209         }
       
   210 
       
   211     list->SetAttrL( CMediaFileList::EAttr3DEffect, i3DEffect );
       
   212     list->SetAttrL( CMediaFileList::EAttr3DEcho, i3DEcho );
       
   213 
       
   214     list->SetNullItemL( *iNoSoundText, *iNoSoundFileName,
       
   215                         CMediaFileList::EMediaFileTypeAudio,
       
   216                         CMediaFileList::ENullItemIconOff );
       
   217         
       
   218     TInt ret = list->ShowMediaFileListL( iInternalToneFileName, &nullItem, NULL, NULL );
       
   219      
       
   220     CleanupStack::PopAndDestroy( list );
       
   221 
       
   222     if( ret )
       
   223         {
       
   224         // Setting Oked.
       
   225         UpdateListBoxTextL();
       
   226         }
       
   227     }
       
   228 
       
   229 
       
   230 
       
   231 
       
   232 // -----------------------------------------------------------------------------
       
   233 // CProfileFileListSettingItem::SettingTextL
       
   234 // -----------------------------------------------------------------------------
       
   235 //
       
   236 const TDesC& CProfileFileListSettingItem::SettingTextL()
       
   237     {
       
   238     if( iInternalToneFileName->Length() > 0 )
       
   239         {
       
   240         // FLD has returned a filename
       
   241         if( iInternalToneFileName->CompareF( *iNoSoundFileName ) == 0 )
       
   242             {
       
   243             // Filename is "No_Sound", return localized text "None"
       
   244             iSettingText.Set( *iNoSoundText );
       
   245             }
       
   246         else
       
   247             {
       
   248             // Filename is something else
       
   249             TParsePtrC parse( *iInternalToneFileName );
       
   250             if( parse.Ext().CompareF( KIgnoredExtension ) == 0 )
       
   251                 {
       
   252                 iSettingText.Set( parse.Name() );
       
   253                 }
       
   254             else
       
   255                 {
       
   256                 iSettingText.Set( parse.NameAndExt() );
       
   257                 }
       
   258             }
       
   259         }
       
   260     else
       
   261         {
       
   262         // Filename is an empty descriptor, return localised text "None"
       
   263         iSettingText.Set( *iNoSoundText );
       
   264         }
       
   265     return iSettingText;
       
   266     }
       
   267 
       
   268 // End Of File