messagingappbase/smartmessaging/ringbc/src/RingingToneBioControl.cpp
changeset 79 2981cb3aa489
equal deleted inserted replaced
25:84d9eb65b26f 79:2981cb3aa489
       
     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:   BIO control for Ringing Tones.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 
       
    22 #include "RingingToneBioControl.h"      // for CRingingToneBioControl
       
    23 #include "RingBCToneConverter.h"             // for CComNSMConverter
       
    24 #include "RingBC.hrh"
       
    25 #include "RingBCLog.h"
       
    26 
       
    27 #include <biocmtm.h>                    // for CBIOClientMtm
       
    28 #include <coeutils.h>                   // for ConeUtils
       
    29 #include <msgbiocontrolObserver.h>      // for MMsgBioControlObserver
       
    30 #include <StringLoader.h>               // for StringLoader
       
    31 #include <AknsUtils.h>
       
    32 #include <RingBC.rsg>                   // for resouce identifiers
       
    33 #include <ringbc.mbg>                   // for icons indexes
       
    34 #include <ProfileEngineSDKCRKeys.h>
       
    35 #include <MsgBioUtils.h>                // for MsgBioUtils
       
    36 #include <eikrted.h>                    // for CEikRichTextEditor
       
    37 #include <txtrich.h>                    // for CRichText
       
    38 #include <aknnotewrappers.h>            // for CAknInformationNote
       
    39 #include <Profile.hrh>                  // for EProfileRingingTypeSilent
       
    40 #include <bldvariant.hrh>
       
    41 #include <pathinfo.h>
       
    42 #include <featmgr.h>					// Feature manager
       
    43 #include <csxhelp/smart.hlp.hrh>
       
    44 #include <data_caging_path_literals.hrh>
       
    45 #include <applayout.cdl.h>				// LAF
       
    46 #include <aknlayoutscalable_apps.cdl.h>
       
    47 #include <mmsvattachmentmanager.h>
       
    48 
       
    49 #include <msgaudiocontrol.h>	//AudioControl
       
    50 #include <MsgEditorCommon.h>	//MsgEditorCommons utilities
       
    51 
       
    52 // CONSTANTS
       
    53 
       
    54 _LIT(KRingingToneFileExtension,".rng");
       
    55 _LIT(KResourceName, "ringbc.rsc" );
       
    56 _LIT(KRingBCMbmFileName, "ringbc.mif");
       
    57 
       
    58 // LOCAL CONSTANTS AND MACROS
       
    59 const TInt KComponentCountZero = 0;
       
    60 const TInt KNoOverWriteOrRecurse = 0;
       
    61 const TInt KLengthOfTitleRow = 100;
       
    62 const TInt KTextNameQueryMaxLength = 50;
       
    63 
       
    64 
       
    65 const TInt KRichEditor              = 1;
       
    66 const TInt KAudioControl            = 0;
       
    67 
       
    68 const TInt KRingVolumeZero = 0;
       
    69 
       
    70 const TInt KShowNoNotes = 0;
       
    71 const TInt KShowNotes = 1;
       
    72 
       
    73 const TInt KFrameExpansion = 10;
       
    74 const TInt KMaxVolumeLevel = 10;
       
    75 
       
    76 // MODULE DATA STRUCTURES
       
    77 
       
    78 enum TOptionListLocation
       
    79     {
       
    80     EFirstMenuItem  = 0,
       
    81     ESecondMenuItem
       
    82     };
       
    83 
       
    84 // ================= MEMBER FUNCTIONS =======================
       
    85 
       
    86 // Two-phased constructor.
       
    87 EXPORT_C CMsgBioControl* CRingingToneBioControl::NewL(
       
    88             MMsgBioControlObserver& aObserver,
       
    89             CMsvSession* aSession,
       
    90             TMsvId aId,
       
    91             TMsgBioMode aEditorOrViewerMode,
       
    92             const RFile* aFile)
       
    93     {
       
    94     CRingingToneBioControl* self =
       
    95     	new( ELeave ) CRingingToneBioControl(
       
    96     		aObserver,
       
    97             aSession, aId, aEditorOrViewerMode,
       
    98             aFile);
       
    99 
       
   100     CleanupStack::PushL( self );
       
   101     self->ConstructL();
       
   102     CleanupStack::Pop(self); // self
       
   103 
       
   104     return self;
       
   105 
       
   106     }
       
   107 
       
   108 // Destructor
       
   109 CRingingToneBioControl::~CRingingToneBioControl()
       
   110     {
       
   111     FeatureManager::UnInitializeLib();
       
   112     
       
   113     // During Opening state CActiveScheduler was started and incase if it is not stopped, so to handle that case.
       
   114     if( iPlayerState == EMsgAsyncControlStateOpening ) 
       
   115        {
       
   116        //Check for player state, if it is opening then this state may come if user press RED key at the same time
       
   117        //Player state was opening so to go ahead with playing by stopping 
       
   118        //the active scheduler that was started in OpenFileL -function
       
   119        CActiveScheduler::Stop();
       
   120        }
       
   121     // Need to delete the same here if user move to next message / press Red key 
       
   122 	// or opening new message from universal indicator pane to avoid leak
       
   123     if ( iStopCba ) 
       
   124         {
       
   125         delete iStopCba;
       
   126         }
       
   127 
       
   128     delete iRichEditor;
       
   129     delete iAudioControl;    
       
   130     delete iToneTitle;        
       
   131     }
       
   132 
       
   133 // C++ default constructor.
       
   134 CRingingToneBioControl::CRingingToneBioControl(
       
   135         MMsgBioControlObserver& aObserver,
       
   136         CMsvSession* aSession,
       
   137         TMsvId aId,
       
   138         TMsgBioMode aEditorOrViewerMode,
       
   139         const RFile* aFile):
       
   140         CMsgBioControl(aObserver,
       
   141             aSession,
       
   142             aId,
       
   143             aEditorOrViewerMode,
       
   144             aFile)
       
   145     {
       
   146     }
       
   147 
       
   148 // Symbian OS default constructor can leave.
       
   149 void CRingingToneBioControl::ConstructL()
       
   150     {
       
   151     if( IsEditor() )   //Editor mode is not supported
       
   152         {
       
   153         User::Leave( KErrNotSupported );
       
   154         }
       
   155 
       
   156 	FeatureManager::InitializeLibL();
       
   157 
       
   158     LoadStandardBioResourceL();
       
   159     LoadResourceL( KResourceName );
       
   160 
       
   161     // checks if the message is valid
       
   162     CheckMsgValidityL();
       
   163     TakeTitleL();
       
   164 
       
   165     }
       
   166 
       
   167 // ----------------------------------------------------------------------------
       
   168 // CRingingToneBioControl::CheckMsgValidityL
       
   169 // ----------------------------------------------------------------------------
       
   170 //
       
   171 void CRingingToneBioControl::CheckMsgValidityL()
       
   172     {
       
   173     RFile file;
       
   174 
       
   175     CMsvEntry* entry = this->MsvSession(). GetEntryL(iId);
       
   176     CleanupStack::PushL( entry );
       
   177 
       
   178     CMsvStore* store = entry->ReadStoreL();
       
   179 	CleanupStack::PushL(store);
       
   180 
       
   181 	MMsvAttachmentManager& manager = store->AttachmentManagerL();
       
   182 	file = manager.GetAttachmentFileL(0);
       
   183 
       
   184     CleanupClosePushL(file);
       
   185 
       
   186     TInt size;
       
   187     User::LeaveIfError(file.Size(size));
       
   188     if (!size)
       
   189         {
       
   190         //the empty ringing tone is considered a corrupted message
       
   191         User::Leave(KErrMsgBioMessageNotValid);
       
   192         }
       
   193 	
       
   194 	HBufC8* dataBuf = HBufC8::NewLC(size);
       
   195     TPtr8 data(dataBuf->Des());
       
   196     User::LeaveIfError(file.Read(data, size));
       
   197 
       
   198     CRingBCNSMConverter* conv = CRingBCNSMConverter::NewL();
       
   199     CleanupStack::PushL( conv );
       
   200     TBool res = conv->IsRingToneMimeTypeL(data);
       
   201 
       
   202     if (!res)
       
   203         {
       
   204         User::Leave(KErrMsgBioMessageNotValid);
       
   205         }
       
   206         
       
   207     CleanupStack::PopAndDestroy(5,entry); // entry,conv,store,file,dataBuf
       
   208     }
       
   209 
       
   210 
       
   211 // ----------------------------------------------------------------------------
       
   212 // CRingingToneBioControl::ProcessCommandL
       
   213 // ----------------------------------------------------------------------------
       
   214 //
       
   215 void CRingingToneBioControl::ProcessCommandL( TInt aCommandId )
       
   216     {
       
   217     if ( aCommandId == ESoftkeyStop )
       
   218 		{
       
   219 		StopPlayback();
       
   220         }
       
   221     }
       
   222 
       
   223 // ----------------------------------------------------------------------------
       
   224 // CRingingToneBioControl::SetAndGetSizeL
       
   225 // ----------------------------------------------------------------------------
       
   226 //
       
   227 void CRingingToneBioControl::SetAndGetSizeL( TSize& aSize )
       
   228     {
       
   229 	//the heightadjustment calculates the height for the header elements and 
       
   230 	//the space between components
       
   231    	TInt heightAdjustment = (MsgEditorCommons::MsgBaseLineDelta()*2)+
       
   232    							MsgEditorCommons::MsgBaseLineOffset();
       
   233    	
       
   234    	aSize.iHeight -= heightAdjustment;
       
   235    	SetSizeWithoutNotification( aSize  );
       
   236     }
       
   237 
       
   238 // ----------------------------------------------------------------------------
       
   239 // CRingingToneBioControl::SetMenuCommandSetL
       
   240 // ----------------------------------------------------------------------------
       
   241 //
       
   242 void CRingingToneBioControl::SetMenuCommandSetL( CEikMenuPane& aMenuPane )
       
   243     {
       
   244     // if playing, do not show context sensitive menu.
       
   245     if ( iPlayerState != EMsgAsyncControlStatePlaying )
       
   246         {
       
   247 		//removing the playback option from options menu, single click will do the playing
       
   248         //AddMenuItemL(aMenuPane, R_SM_PLAYBACK, ERingtPlayback, EFirstMenuItem);
       
   249         AddMenuItemL(aMenuPane,
       
   250         	R_SM_ADD_COMPOSER, ERingtAddComposer, ESecondMenuItem);
       
   251         }
       
   252 	}
       
   253 
       
   254 // ----------------------------------------------------------------------------
       
   255 // CRingingToneBioControl::CurrentLineRect
       
   256 // ----------------------------------------------------------------------------
       
   257 //
       
   258 TRect CRingingToneBioControl::CurrentLineRect() const
       
   259     {
       
   260     return iAudioControl->CurrentLineRect();
       
   261     }
       
   262 
       
   263 // ----------------------------------------------------------------------------
       
   264 // CRingingToneBioControl::IsFocusChangePossible
       
   265 // ----------------------------------------------------------------------------
       
   266 //
       
   267 TBool CRingingToneBioControl::IsFocusChangePossible(
       
   268         TMsgFocusDirection aDirection ) const
       
   269     {
       
   270     return iAudioControl->IsFocusChangePossible( aDirection );
       
   271 	}
       
   272 
       
   273 // ----------------------------------------------------------------------------
       
   274 // CRingingToneBioControl::HeaderTextL
       
   275 // ----------------------------------------------------------------------------
       
   276 //
       
   277 HBufC* CRingingToneBioControl::HeaderTextL() const
       
   278     {
       
   279     return iCoeEnv->AllocReadResourceL( R_SM_TITLE_RINGING_TONE );
       
   280     }
       
   281 
       
   282 // ----------------------------------------------------------------------------
       
   283 // CRingingToneBioControl::HandleBioCommandL
       
   284 // ----------------------------------------------------------------------------
       
   285 //
       
   286 TBool CRingingToneBioControl::HandleBioCommandL(TInt aCommand)
       
   287     {
       
   288     aCommand -= iBioControlObserver.FirstFreeCommand();
       
   289     TBool retValue(EFalse);
       
   290     switch ( aCommand )
       
   291         {
       
   292         case ERingtPlayback:
       
   293             PlaybackL();
       
   294             retValue = ETrue;
       
   295             break;
       
   296         case ERingtAddComposer:
       
   297             TrySaveToneL();
       
   298             retValue = ETrue;
       
   299             break;
       
   300         default:
       
   301             retValue = EFalse;
       
   302             break;
       
   303         }
       
   304 	return retValue;
       
   305     }
       
   306 
       
   307 // ----------------------------------------------------------------------------
       
   308 // CRingingToneLogoBioControl::OptionMenuPermissionsL
       
   309 // ----------------------------------------------------------------------------
       
   310 //
       
   311 TUint32 CRingingToneBioControl::OptionMenuPermissionsL() const
       
   312     {
       
   313     if ( iPlayerState != EMsgAsyncControlStatePlaying )
       
   314         {
       
   315         return EMsgBioDelete
       
   316         | EMsgBioMessInfo
       
   317         | EMsgBioMove
       
   318         | EMsgBioHelp
       
   319         | EMsgBioExit;
       
   320         }
       
   321     else 
       
   322         {
       
   323         // do not show context sensitive menu.
       
   324         return 0;
       
   325         }
       
   326     }
       
   327 
       
   328 
       
   329 
       
   330 // ----------------------------------------------------------------------------
       
   331 // CRingingToneBioControl::OfferKeyEventL
       
   332 // ----------------------------------------------------------------------------
       
   333 //
       
   334 TKeyResponse CRingingToneBioControl::OfferKeyEventL(
       
   335         const TKeyEvent& /*aKeyEvent*/,
       
   336         TEventCode /*aType*/ )
       
   337     {
       
   338     return EKeyWasConsumed;
       
   339     }
       
   340 
       
   341 // ----------------------------------------------------------------------------
       
   342 // CRingingToneBioControl::GetHelpContext
       
   343 // ----------------------------------------------------------------------------
       
   344 //
       
   345 void CRingingToneBioControl::GetHelpContext(
       
   346 	TCoeHelpContext& aHelpContext) const
       
   347 	{
       
   348 	if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   349 		{
       
   350 		const TUid KUidSmart = {0x101F4CDA};
       
   351 
       
   352 		aHelpContext.iContext = KSMART_HLP_RINGVIEWER();
       
   353 		aHelpContext.iMajor = KUidSmart;
       
   354 		}
       
   355 	}
       
   356 
       
   357 // ----------------------------------------------------------------------------
       
   358 // CRingingToneBioControl::CountComponentControls
       
   359 // ----------------------------------------------------------------------------
       
   360 //
       
   361 TInt CRingingToneBioControl::CountComponentControls() const
       
   362     {
       
   363     TInt componentCount( KComponentCountZero );
       
   364     if ( iAudioControl )
       
   365         {
       
   366         componentCount++;
       
   367         }
       
   368 	if ( iRichEditor )        
       
   369 		{
       
   370 		componentCount++;
       
   371 		}
       
   372     return componentCount;
       
   373     }
       
   374 
       
   375 // ----------------------------------------------------------------------------
       
   376 // CRingingToneBioControl::ComponentControl
       
   377 // ----------------------------------------------------------------------------
       
   378 //
       
   379 CCoeControl* CRingingToneBioControl::ComponentControl( TInt aIndex ) const
       
   380     {
       
   381     if ( aIndex == KRichEditor )
       
   382     	{
       
   383     	return iRichEditor;
       
   384     	}
       
   385     if ( aIndex == KAudioControl )
       
   386         {
       
   387         return iAudioControl;
       
   388         }
       
   389     else
       
   390     	{
       
   391     	return NULL;
       
   392     	}
       
   393 	}
       
   394 
       
   395 // ----------------------------------------------------------------------------
       
   396 // CRingingToneBioControl::HandleResourceChange
       
   397 // ----------------------------------------------------------------------------
       
   398 //
       
   399 void CRingingToneBioControl::HandleResourceChange( TInt aType )
       
   400     {
       
   401     if(aType == KEikDynamicLayoutVariantSwitch)
       
   402     	{
       
   403         TRAP_IGNORE(
       
   404        		CorrectFormatToRichEditorL();
       
   405         	iRichEditor->SetTextL( iToneTitle );
       
   406         	FillBitmapMaskL();
       
   407         	);
       
   408         }
       
   409     iAudioControl->HandleResourceChange( aType );
       
   410     }
       
   411 
       
   412 // ----------------------------------------------------------------------------
       
   413 // CRingingToneBioControl::SizeChanged
       
   414 // ----------------------------------------------------------------------------
       
   415 //
       
   416 void CRingingToneBioControl::SizeChanged()
       
   417     {
       
   418     TRect rect = Rect();
       
   419     TRect bitmapRect;
       
   420     TAknWindowComponentLayout layout =
       
   421 	   	AknLayoutScalable_Apps::mce_image_pane_g5();
       
   422     TAknLayoutRect LayoutRect;
       
   423 	LayoutRect.LayoutRect( rect, layout.LayoutLine() );
       
   424 	bitmapRect = LayoutRect.Rect();
       
   425 	TInt formattedHeight = iRichEditor->TextLayout()->FormattedHeightInPixels();
       
   426 	bitmapRect.Move(0,formattedHeight);
       
   427 
       
   428 	//the rectangle is grown to so that focused frame is visible
       
   429 	bitmapRect.Grow( KFrameExpansion, KFrameExpansion );
       
   430 	
       
   431 	// rect for richtext is positioned on the top of audio control
       
   432 	rect.iBr.iY = bitmapRect.iTl.iY;
       
   433 	iRichEditor->SetRect( rect );
       
   434     iAudioControl->SetRect( bitmapRect );
       
   435     }
       
   436 
       
   437 // ----------------------------------------------------------------------------
       
   438 // CRingingToneBioControl::FocusChanged
       
   439 // ----------------------------------------------------------------------------
       
   440 //
       
   441 void CRingingToneBioControl::FocusChanged( TDrawNow aDrawNow )
       
   442     {
       
   443 	iAudioControl->SetFocus(IsFocused());
       
   444 	iRichEditor->FocusChanged(aDrawNow);
       
   445     }
       
   446 
       
   447 // ----------------------------------------------------------------------------
       
   448 // CRingingToneBioControl::SetContainerWindowL
       
   449 // ----------------------------------------------------------------------------
       
   450 //
       
   451 void CRingingToneBioControl::SetContainerWindowL(
       
   452 	const CCoeControl& aContainer )
       
   453     {
       
   454     CCoeControl::SetContainerWindowL( aContainer );
       
   455 
       
   456     //The reason for creating the audio control here is that the construction
       
   457     //requires a parent with a window. So it cannot be done in ConstructL()
       
   458     iAudioControl = CMsgAudioControl::NewL( *reinterpret_cast<CMsgEditorView*>(this), this, EMdaPriorityNormal, EMdaPriorityPreferenceQuality );
       
   459 	FillBitmapMaskL();
       
   460 
       
   461     CreateRichEditorL();
       
   462     }
       
   463 
       
   464 // ----------------------------------------------------------------------------
       
   465 // CRingingToneBioControl ::Draw()
       
   466 // ----------------------------------------------------------------------------
       
   467 //
       
   468 void CRingingToneBioControl::Draw(const TRect& /*aRect*/) const
       
   469     {
       
   470     }
       
   471 
       
   472 // ----------------------------------------------------------------------------
       
   473 // CRingingToneBioControl ::CorrectFormatToRichEditorL()
       
   474 // ----------------------------------------------------------------------------
       
   475 //
       
   476 void CRingingToneBioControl::CorrectFormatToRichEditorL()
       
   477     {
       
   478     CRichText* rich = iRichEditor->RichText();
       
   479     TInt pos(rich->DocumentLength());
       
   480 
       
   481     // font correction.
       
   482     TCharFormat format;
       
   483     TCharFormatMask mask;
       
   484 
       
   485 	TAknTextLineLayout editorLayout = AppLayout::Smart_Messages_Line_2( 0 );
       
   486 	const CFont* editorFont = AknLayoutUtils::FontFromId( editorLayout.FontId() );
       
   487 	format.iFontSpec = editorFont->FontSpecInTwips();
       
   488 
       
   489     TRgb textColor;
       
   490     if ( AknsUtils::GetCachedColor(
       
   491 	    AknsUtils::SkinInstance(),
       
   492         textColor,
       
   493         KAknsIIDQsnTextColors,
       
   494         EAknsCIQsnTextColorsCG6 ) != KErrNone )
       
   495 	    {
       
   496 	    textColor = AKN_LAF_COLOR_STATIC( 215 );
       
   497 	    }
       
   498 
       
   499     format.iFontPresentation.iTextColor = textColor;
       
   500 
       
   501     mask.ClearAll();
       
   502     mask.SetAttrib( EAttColor );
       
   503     mask.SetAttrib(EAttFontStrokeWeight);
       
   504     mask.SetAttrib(EAttFontHeight);
       
   505     mask.SetAttrib(EAttFontTypeface);
       
   506 
       
   507     rich->SetInsertCharFormatL(format, mask, pos);
       
   508 
       
   509     // this is needed to set ringing tone title centered.
       
   510     CParaFormat* paraFormat = CParaFormat::NewLC();
       
   511     TParaFormatMask paraMask;
       
   512 
       
   513     paraFormat->Reset();
       
   514     paraFormat->iHorizontalAlignment = CParaFormat::ECenterAlign;
       
   515     paraFormat->iVerticalAlignment = CParaFormat::ECenterAlign;
       
   516 
       
   517     paraMask.SetAttrib(EAttAlignment);
       
   518     paraMask.SetAttrib(EAttFontHeight);
       
   519     paraMask.SetAttrib(EAttColor);
       
   520 
       
   521     rich->ApplyParaFormatL(paraFormat, paraMask, 0, pos);
       
   522 
       
   523     CleanupStack::PopAndDestroy(paraFormat);
       
   524     }
       
   525 
       
   526 void CRingingToneBioControl::OpenFileL()
       
   527 	{
       
   528 	RFile file;
       
   529 
       
   530 	CMsvEntry* entry = this->MsvSession(). GetEntryL(iId);
       
   531 	CleanupStack::PushL( entry );
       
   532 
       
   533 	CMsvStore* store = entry->ReadStoreL();
       
   534 	CleanupStack::PushL(store);
       
   535 
       
   536 	MMsvAttachmentManager& manager = store->AttachmentManagerL();
       
   537 	file = manager.GetAttachmentFileL(0);
       
   538 	CleanupClosePushL(file);
       
   539 
       
   540 	//asynchronous loading of file
       
   541 	//the audio control takes a copy of the file
       
   542 	iAudioControl->LoadL(file);
       
   543 
       
   544 	//wait for the opening of file to complete
       
   545 	//in MsgMediaControlStateChanged
       
   546     CActiveScheduler::Start();
       
   547 
       
   548 	CleanupStack::PopAndDestroy(3, entry);
       
   549 	}
       
   550 
       
   551 // ----------------------------------------------------------------------------
       
   552 // CRingingToneBioControl::PlaybackL
       
   553 // ----------------------------------------------------------------------------
       
   554 //
       
   555 void CRingingToneBioControl::PlaybackL()
       
   556     {
       
   557     if( iPlayerState != EMsgAsyncControlStateOpening ||
       
   558 		iPlayerState != EMsgAsyncControlStateAboutToPlay ||
       
   559 		iPlayerState != EMsgAsyncControlStatePlaying ||
       
   560 		iPlayerState != EMsgAsyncControlStateBuffering )
       
   561     	{
       
   562     	
       
   563     	OpenFileL();
       
   564     	
       
   565     	//any other state than EMsgAsyncControlStateReady
       
   566     	//constitutes a failed opening of media file
       
   567     	if(iPlayerState == EMsgAsyncControlStateReady)
       
   568     		{
       
   569     		GetAndSetRingingToneVolumeL();
       
   570 		    iAudioControl->PlayL();
       
   571 
       
   572 		    iStopCba = CEikButtonGroupContainer::NewL (
       
   573 		    CEikButtonGroupContainer::ECba, CEikButtonGroupContainer::EHorizontal,
       
   574 		        this, R_RINGCONTROL_SOFTKEYS_STOP );
       
   575 
       
   576 		    const TSize screenSize = CCoeEnv::Static()->ScreenDevice()->SizeInPixels();
       
   577 		    iStopCba->SetBoundingRect( TRect( screenSize ) );
       
   578     		}
       
   579     	}
       
   580     }
       
   581 
       
   582 void CRingingToneBioControl::StopPlayback()
       
   583 	{
       
   584 	iAudioControl->Stop();
       
   585 	
       
   586 	//after playback the file must be closed so that moving the ring tone
       
   587 	//message to another folder is possible 
       
   588 	iAudioControl->Close();
       
   589 	}
       
   590 
       
   591 // ----------------------------------------------------------------------------
       
   592 // CRingingToneBioControl::GetAndSetRingingToneVolumeL
       
   593 // ----------------------------------------------------------------------------
       
   594 //
       
   595 void CRingingToneBioControl::GetAndSetRingingToneVolumeL()
       
   596     {
       
   597     TInt ringingVol;
       
   598     TInt ringingType;
       
   599     TInt aMaxVolume;
       
   600 	aMaxVolume = iAudioControl->MaxVolume();
       
   601 	CRepository* repository = CRepository::NewLC( KCRUidProfileEngine );
       
   602 
       
   603 	User::LeaveIfError( repository->Get( KProEngActiveRingingVolume, ringingVol ));
       
   604 	User::LeaveIfError(	repository->Get( KProEngActiveRingingType, ringingType ));
       
   605 
       
   606 	CleanupStack::PopAndDestroy(repository); //repository
       
   607 
       
   608 	//Some emulator versions crash in volume setting
       
   609 #ifndef __WINS__
       
   610     if (ringingType == EProfileRingingTypeSilent)
       
   611         {
       
   612         RDebug::Print(_L("Profile: Ring type silent"));
       
   613         iAudioControl->SetVolume(KRingVolumeZero);
       
   614         }
       
   615     else
       
   616         {
       
   617         TInt result( aMaxVolume * ringingVol / KMaxVolumeLevel ); 
       
   618         RDebug::Print(_L("Ringing volume : %d"), ringingVol);
       
   619         iAudioControl->SetVolume(result);
       
   620         }
       
   621 #endif
       
   622     }
       
   623 
       
   624 
       
   625 
       
   626 // ----------------------------------------------------------------------------
       
   627 // CRingingToneBioControl::CreateRichEditorL
       
   628 // ----------------------------------------------------------------------------
       
   629 //
       
   630 void CRingingToneBioControl::CreateRichEditorL()
       
   631     {
       
   632     iRichEditor = new( ELeave ) CEikRichTextEditor(TGulBorder::ENone);
       
   633 
       
   634     TInt edwinFlags =
       
   635     	CEikEdwin::ENoHorizScrolling |
       
   636     	CEikEdwin::ENoAutoSelection |
       
   637         CEikEdwin::EWidthInPixels |
       
   638         CEikEdwin::EReadOnly |
       
   639         CEikEdwin::EEdwinAlternativeWrapping;
       
   640 
       
   641     iRichEditor->ConstructL(this,2 , 0, edwinFlags);
       
   642 
       
   643     iRichEditor->SetMaximumHeightInLines(2);
       
   644 
       
   645     // corrects font and alignment to centered.
       
   646     CorrectFormatToRichEditorL();
       
   647 
       
   648     iRichEditor->SetTextL( iToneTitle );    
       
   649     }
       
   650 
       
   651 // ----------------------------------------------------------------------------
       
   652 // CRingingToneBioControl::FillBitmapMaskL
       
   653 // ----------------------------------------------------------------------------
       
   654 //
       
   655 void CRingingToneBioControl::FillBitmapMaskL()
       
   656     {
       
   657     
       
   658     TParse *fp = new(ELeave) TParse();
       
   659 	fp->Set( KRingBCMbmFileName, &KDC_APP_BITMAP_DIR, NULL );
       
   660 	CleanupStack::PushL( fp );
       
   661     
       
   662     iAudioControl->LoadIconL(  fp->FullName(),
       
   663                                 KAknsIIDQgnPropOtaTone,
       
   664                                 EMbmRingbcQgn_prop_ota_tone,
       
   665                                 EMbmRingbcQgn_prop_ota_tone_mask);
       
   666     
       
   667     CleanupStack::PopAndDestroy(fp);
       
   668                                     
       
   669     TAknWindowComponentLayout layout =
       
   670         		AknLayoutScalable_Apps::mce_image_pane_g5();
       
   671     TAknLayoutRect LayoutRect;
       
   672 	LayoutRect.LayoutRect( Rect(), layout.LayoutLine() );
       
   673 	TRect bitmapRect;
       
   674 	bitmapRect = LayoutRect.Rect();                                
       
   675 	iAudioControl->SetIconSizeL(bitmapRect.Size());
       
   676 	iAudioControl->SetIconVisible(ETrue);
       
   677     }
       
   678 
       
   679 
       
   680 // ----------------------------------------------------------------------------
       
   681 // CRingingToneBioControl::AddSongTitleToArrayL
       
   682 // ----------------------------------------------------------------------------
       
   683 //
       
   684 void CRingingToneBioControl::AddSongTitleToArrayL(CDesCArray& aItemArray) const
       
   685     {
       
   686     //Add titlerow to array
       
   687     HBufC* dataRow = HBufC::NewLC(KLengthOfTitleRow);
       
   688     TPtr rowPtr = dataRow->Des();
       
   689     HBufC* baseString = StringLoader::LoadLC( R_BASE_STRING );
       
   690 
       
   691     TInt maxLength(KLengthOfTitleRow - baseString->Length());
       
   692 
       
   693     HBufC* tempName = HBufC::NewLC(KMaxFileName);
       
   694 
       
   695     TPtr tempTPtr = tempName->Des();
       
   696     tempTPtr.Copy(iToneTitle->Des());
       
   697 
       
   698     if (iToneTitle->Length() > maxLength)
       
   699         {
       
   700         tempTPtr = iToneTitle->Des().Left(maxLength);
       
   701         }
       
   702 
       
   703     rowPtr.Format(*baseString, tempName);
       
   704     CleanupStack::PopAndDestroy( 2, baseString );  //tempName, baseString
       
   705     aItemArray.AppendL( rowPtr );
       
   706     CleanupStack::PopAndDestroy(dataRow);  //dataRow
       
   707     }
       
   708 
       
   709 // ----------------------------------------------------------------------------
       
   710 // CRingingToneBioControl ::IsOnlyDots
       
   711 // ----------------------------------------------------------------------------
       
   712 //
       
   713 TBool CRingingToneBioControl::IsOnlyDots(TDes& aTitle)
       
   714     {
       
   715     const TChar KSingleDot = '.';
       
   716 	_LIT(KDoubleDots,"..");
       
   717 
       
   718     if(aTitle.Length()==1)
       
   719         {
       
   720 
       
   721         if( aTitle.Locate(KSingleDot) != KErrNotFound )
       
   722             {
       
   723             return ETrue;
       
   724             }
       
   725         }
       
   726 
       
   727     else if(aTitle.Length()==2)
       
   728         {
       
   729 
       
   730         if( aTitle.Find(KDoubleDots) != KErrNotFound )
       
   731             {
       
   732             return ETrue;
       
   733             }
       
   734         }
       
   735 
       
   736     return EFalse;
       
   737     }
       
   738 
       
   739 // ----------------------------------------------------------------------------
       
   740 // CRingingToneBioControl::IsValidL
       
   741 // ----------------------------------------------------------------------------
       
   742 //
       
   743 TBool CRingingToneBioControl::IsValidL(TDes& aTitle, TBool aNotes)
       
   744     {
       
   745     RFs fileServer;
       
   746     User::LeaveIfError( fileServer.Connect() );
       
   747 
       
   748     //If name includes solely single dot or double dot, this note should be
       
   749     //showed (Folders spec)
       
   750     if( IsOnlyDots(aTitle) )
       
   751         {
       
   752 
       
   753         fileServer.Close();
       
   754         if(aNotes)
       
   755             {
       
   756             InformationNoteL(R_FLDR_BAD_FILE_NAME);
       
   757             }
       
   758         return EFalse;
       
   759 
       
   760         }
       
   761 
       
   762     //only because of IsValidName does not check backslash, but file
       
   763     //is not valid with it.
       
   764     if( aTitle.Locate('\\') != KErrNotFound )
       
   765         {
       
   766 
       
   767         fileServer.Close();
       
   768         if(aNotes)
       
   769             {
       
   770             InformationNoteL(R_FLDR_ILLEGAL_CHARACTERS);
       
   771             }
       
   772         return EFalse;
       
   773 
       
   774         }
       
   775     if( aTitle.Locate('\n') != KErrNotFound )
       
   776         {
       
   777         fileServer.Close();
       
   778         if(aNotes)
       
   779             {
       
   780             InformationNoteL(R_FLDR_ILLEGAL_CHARACTERS);
       
   781             }
       
   782         return EFalse;
       
   783         }
       
   784 
       
   785     // check is there any special chars between 00h to 1Fh
       
   786     for (TInt i=0; i<32; i++)
       
   787         {
       
   788         if (aTitle.Locate(i) !=KErrNotFound )
       
   789             {
       
   790             fileServer.Close();
       
   791             if(aNotes)
       
   792                 {
       
   793                 InformationNoteL(R_FLDR_ILLEGAL_CHARACTERS);
       
   794                 }
       
   795             return EFalse;
       
   796 
       
   797             }
       
   798 
       
   799         }
       
   800 
       
   801     //Checking if filename is valid for saving purpose
       
   802     if( !fileServer.IsValidName(aTitle) )
       
   803         {
       
   804 
       
   805         fileServer.Close();
       
   806         if(aNotes)
       
   807             {
       
   808             InformationNoteL(R_FLDR_ILLEGAL_CHARACTERS);
       
   809             }
       
   810         return EFalse;
       
   811 
       
   812         }
       
   813 
       
   814     fileServer.Close();
       
   815     return ETrue; //File name is valid
       
   816 
       
   817     }
       
   818 
       
   819 // ----------------------------------------------------------------------------
       
   820 // CRingingToneBioControl::InformationNoteL
       
   821 // ----------------------------------------------------------------------------
       
   822 //
       
   823 void CRingingToneBioControl::InformationNoteL(TInt aStringResource)
       
   824     {
       
   825     HBufC* buf = StringLoader::LoadLC(aStringResource);
       
   826 
       
   827     CAknInformationNote* note = new (ELeave) CAknInformationNote(ETrue);
       
   828     note->ExecuteLD(*buf);
       
   829 
       
   830     CleanupStack::PopAndDestroy(buf); //buf
       
   831     }
       
   832 
       
   833 
       
   834 // ----------------------------------------------------------------------------
       
   835 // CRingingToneBioControl::ExistsL
       
   836 // ----------------------------------------------------------------------------
       
   837 //
       
   838 TBool CRingingToneBioControl::ExistsL(TDes& aTitle)
       
   839     {
       
   840     HBufC* path = CreatePathForSavingLC(aTitle);
       
   841 
       
   842     if ( ConeUtils::FileExists(*path) )
       
   843         {
       
   844         CleanupStack::PopAndDestroy(path); //path;
       
   845 
       
   846         return ETrue;
       
   847         }
       
   848 
       
   849     CleanupStack::PopAndDestroy(path); //path;
       
   850     return EFalse;
       
   851     }
       
   852 
       
   853 // ----------------------------------------------------------------------------
       
   854 // CRingingToneBioControl::AskNameL
       
   855 // ----------------------------------------------------------------------------
       
   856 //
       
   857 TBool CRingingToneBioControl::AskNameL(TDes& aTitle)
       
   858     {
       
   859     IncrementFileNameL( aTitle );
       
   860 
       
   861     if (!NameQueryL(aTitle))
       
   862         {
       
   863         return EFalse;
       
   864         }
       
   865 
       
   866     return ETrue;
       
   867     }
       
   868 
       
   869 // ----------------------------------------------------------------------------
       
   870 // CRingingToneBioControl::AskNameAndValidNameL
       
   871 // ----------------------------------------------------------------------------
       
   872 //
       
   873 TBool CRingingToneBioControl::AskAndValidNameL(TDes& aTitle)
       
   874     {
       
   875     do
       
   876         {
       
   877         if(!AskNameL(aTitle))
       
   878             {
       
   879             return EFalse;
       
   880             }
       
   881 
       
   882         } while (!IsValidL(aTitle,KShowNotes)) ;
       
   883 
       
   884     return ETrue;
       
   885     }
       
   886 
       
   887 
       
   888 // ----------------------------------------------------------------------------
       
   889 // CRingingToneBioControl::TrySaveToneL
       
   890 // ----------------------------------------------------------------------------
       
   891 //
       
   892 void CRingingToneBioControl::TrySaveToneL()
       
   893     {
       
   894     HBufC* saveTitle = HBufC::NewLC(KMaxFileName);
       
   895     TPtr saveTitlePtr(saveTitle->Des());
       
   896 
       
   897     saveTitlePtr.Copy(*iToneTitle); //initialize saveTitle
       
   898 
       
   899     TBool okSave = ETrue; //No cancel pressed
       
   900 
       
   901     //First case is special, cause if message have wrong kind of title,
       
   902     //there will be default name in data query and no rename query.
       
   903     if( !IsValidL(saveTitlePtr,KShowNoNotes) )
       
   904         {
       
   905         SetDefaultNameL(saveTitlePtr);
       
   906 
       
   907         okSave = AskAndValidNameL(saveTitlePtr);
       
   908         }
       
   909 
       
   910     //Have to check if title already exists. If not, then save. But if
       
   911     //it exists already, should ask if rename (rename query) and then ask
       
   912     //for new name until user press cancel or give valid name. After that
       
   913     //we should check if that already exists...
       
   914     if(okSave)
       
   915         {
       
   916         while (ExistsL(saveTitlePtr))
       
   917             {
       
   918             if (!RenameQueryL(saveTitlePtr))
       
   919                 {
       
   920                 okSave = EFalse;
       
   921                 break;
       
   922                 }
       
   923 
       
   924             if(!AskAndValidNameL(saveTitlePtr))
       
   925                 {
       
   926                 okSave = EFalse;
       
   927                 break;
       
   928                 }
       
   929             };
       
   930         }
       
   931 
       
   932     //User did not press cancel in any place and it is saving time.
       
   933     if(okSave)
       
   934         {
       
   935         SaveToneL(saveTitlePtr);
       
   936         MsgBioUtils::ConfirmationNoteL(R_SM_NOTE_TONE_COPIED);
       
   937         }
       
   938 
       
   939     CleanupStack::PopAndDestroy(saveTitle); //saveTitle
       
   940     }
       
   941 
       
   942 // ----------------------------------------------------------------------------
       
   943 // CRingingToneBioControl::CreatePathForSavingLC
       
   944 // ----------------------------------------------------------------------------
       
   945 //
       
   946 HBufC* CRingingToneBioControl::CreatePathForSavingLC(const TDesC& aName)
       
   947     {
       
   948     HBufC* targetPathAndName = TargetPathLC();
       
   949 
       
   950     TPtr targetPathAndNamePtr = targetPathAndName->Des();
       
   951 
       
   952     targetPathAndNamePtr.Append(aName);
       
   953     targetPathAndNamePtr.Append(KRingingToneFileExtension);
       
   954 
       
   955     return targetPathAndName;
       
   956     }
       
   957 
       
   958 // ----------------------------------------------------------------------------
       
   959 // CRingingToneBioControl::RenameQueryL
       
   960 // ----------------------------------------------------------------------------
       
   961 //
       
   962 TBool CRingingToneBioControl::RenameQueryL(TDes& aTitle)
       
   963     {
       
   964     if ( !MsgBioUtils::ConfirmationQueryOkCancelL(
       
   965     	*StringLoader::LoadLC( R_FLDR_RENAME_QUERY, aTitle ) ) )
       
   966         {
       
   967 
       
   968         CleanupStack::PopAndDestroy(); //StringLoader;
       
   969         return EFalse;
       
   970 
       
   971         }
       
   972     CleanupStack::PopAndDestroy(); //StringLoader;
       
   973 
       
   974     return ETrue;
       
   975     }
       
   976 
       
   977 // ----------------------------------------------------------------------------
       
   978 // CRingingToneBioControl::SaveToneL
       
   979 // ----------------------------------------------------------------------------
       
   980 //
       
   981 TBool CRingingToneBioControl::SaveToneL(TDes& aTitle)
       
   982     {
       
   983     CFileMan* files = CFileMan::NewL(CCoeEnv::Static()->FsSession());
       
   984     CleanupStack::PushL( files );
       
   985 
       
   986     HBufC* targetPathAndName = CreatePathForSavingLC(aTitle);
       
   987 
       
   988     CMsvEntry* entry = this->MsvSession(). GetEntryL(iId);
       
   989     CleanupStack::PushL( entry );
       
   990 
       
   991     CMsvStore* store = entry->ReadStoreL();
       
   992 	CleanupStack::PushL(store);
       
   993 
       
   994 	MMsvAttachmentManager& manager = store->AttachmentManagerL();
       
   995 
       
   996 	RFile ringFile;
       
   997 	ringFile = manager.GetAttachmentFileL(0);
       
   998 
       
   999     CleanupStack::PopAndDestroy(2, entry);
       
  1000     CleanupClosePushL(ringFile);
       
  1001 
       
  1002     TInt err = files->Copy(
       
  1003     	ringFile, *targetPathAndName, KNoOverWriteOrRecurse );
       
  1004     User::LeaveIfError(err);
       
  1005 
       
  1006     CleanupStack::PopAndDestroy(3, files); //targetPathAndName, ringFile, files
       
  1007     return ETrue;
       
  1008     }
       
  1009 
       
  1010 // ----------------------------------------------------------------------------
       
  1011 // CRingingToneBioControl::SetDefaultNameL
       
  1012 // ----------------------------------------------------------------------------
       
  1013 //
       
  1014 void CRingingToneBioControl::SetDefaultNameL(TDes& aName)
       
  1015     {
       
  1016     aName.Copy(*StringLoader::LoadLC( R_SM_TONE_NAME ));
       
  1017     CleanupStack::PopAndDestroy(); //stringloader
       
  1018     }
       
  1019 
       
  1020 // ----------------------------------------------------------------------------
       
  1021 // CRingingToneBioControl::NameQueryL
       
  1022 // ----------------------------------------------------------------------------
       
  1023 //
       
  1024 TBool CRingingToneBioControl::NameQueryL(TDes& aName)
       
  1025     {
       
  1026     if (aName.Length() > KTextNameQueryMaxLength)
       
  1027         {
       
  1028         User::Leave(KErrOverflow);
       
  1029         }
       
  1030 
       
  1031     CAknTextQueryDialog* queryDlg = new ( ELeave )
       
  1032                                      CAknTextQueryDialog( aName );
       
  1033     return queryDlg->ExecuteLD( R_SM_QUERY_RINGING_TONE );
       
  1034     }
       
  1035 
       
  1036 // ----------------------------------------------------------------------------
       
  1037 // CRingingToneBioControl::TakeTitleL
       
  1038 // ----------------------------------------------------------------------------
       
  1039 //
       
  1040 void CRingingToneBioControl::TakeTitleL()
       
  1041     {
       
  1042     //Read stream from file
       
  1043 
       
  1044     RFile ringFile;
       
  1045 
       
  1046     CMsvEntry* entry = this->MsvSession(). GetEntryL(iId);
       
  1047     CleanupStack::PushL( entry );
       
  1048 
       
  1049     CMsvStore* store = entry->ReadStoreL();
       
  1050 	CleanupStack::PushL(store);
       
  1051 
       
  1052 	MMsvAttachmentManager& manager = store->AttachmentManagerL();
       
  1053 	ringFile = manager.GetAttachmentFileL(0);
       
  1054 
       
  1055     CleanupStack::PopAndDestroy(2,entry);    //entry, store
       
  1056     CleanupClosePushL(ringFile);
       
  1057 
       
  1058 
       
  1059     TInt filelen;
       
  1060     User::LeaveIfError(ringFile.Size(filelen));
       
  1061 
       
  1062     HBufC8* filedata8 = HBufC8::NewMaxLC(filelen);
       
  1063     TPtr8 dataPtr8 = filedata8->Des();
       
  1064     User::LeaveIfError(ringFile.Read(dataPtr8,filelen));
       
  1065 
       
  1066     CleanupStack::Pop( filedata8 ); // pop the filedata temporarily
       
  1067     CleanupStack::PopAndDestroy(); // close and destory ringFile
       
  1068     CleanupStack::PushL( filedata8 ); // put the filedata back
       
  1069 
       
  1070     CRingBCNSMConverter* conv = CRingBCNSMConverter::NewL();
       
  1071     CleanupStack::PushL( conv );
       
  1072 
       
  1073 	if ( iToneTitle )
       
  1074 		{
       
  1075 		delete iToneTitle;
       
  1076 		iToneTitle = NULL;
       
  1077 		}
       
  1078 	iToneTitle = conv->TitleLC(dataPtr8); //The ownership changes here
       
  1079 
       
  1080     CleanupStack::Pop(iToneTitle);
       
  1081     CleanupStack::PopAndDestroy(2, filedata8);  //conv, filedata8
       
  1082 
       
  1083     // checks if there is no name for ringing tone
       
  1084     if (iToneTitle->Length() == 0)
       
  1085         {
       
  1086         delete iToneTitle;
       
  1087         iToneTitle = NULL;
       
  1088 
       
  1089         // sets default name
       
  1090         iToneTitle = StringLoader::LoadL( R_SM_TONE_NAME );
       
  1091 
       
  1092         // check that default name is not too long.
       
  1093         if (iToneTitle->Length() > KMaxFileName )
       
  1094             {
       
  1095 
       
  1096             HBufC* tempName = HBufC::NewLC(KMaxFileName);
       
  1097             TPtr tempTPtr = tempName->Des();
       
  1098 
       
  1099             tempTPtr.Copy(iToneTitle->Des().Left(KMaxFileName));
       
  1100 
       
  1101             CleanupStack::Pop(tempName);
       
  1102 
       
  1103 	        delete iToneTitle;
       
  1104             iToneTitle = tempName;
       
  1105             }
       
  1106         }
       
  1107     }
       
  1108 // ----------------------------------------------------------------------------
       
  1109 // CRingingToneBioControl::IncrementFileName
       
  1110 // ----------------------------------------------------------------------------
       
  1111 //
       
  1112 void CRingingToneBioControl::IncrementFileNameL(TDes& aFileName)
       
  1113     {
       
  1114     HBufC* path = CreatePathForSavingLC(aFileName);
       
  1115 
       
  1116     while (ConeUtils::FileExists(*path))
       
  1117         {
       
  1118 
       
  1119         MsgBioUtils::IncrementNameL(aFileName,KMaxFileName);
       
  1120 
       
  1121         CleanupStack::PopAndDestroy(path);  //path
       
  1122         path = CreatePathForSavingLC(aFileName);
       
  1123 
       
  1124         }
       
  1125 
       
  1126     CleanupStack::PopAndDestroy(path); //path;
       
  1127     }
       
  1128 
       
  1129 
       
  1130 // ----------------------------------------------------------------------------
       
  1131 // CRingingToneBioControl ::TargetPathLC
       
  1132 // ----------------------------------------------------------------------------
       
  1133 //
       
  1134 HBufC* CRingingToneBioControl::TargetPathLC()
       
  1135     {
       
  1136 	TFileName path = PathInfo::PhoneMemoryRootPath();
       
  1137 	path.Append( PathInfo::SimpleSoundsPath() );
       
  1138     ConeUtils::EnsurePathExistsL(path);
       
  1139     HBufC* savePath = HBufC::NewLC(KMaxPath + KMaxFileName);
       
  1140 	TPtr ptr = savePath->Des();
       
  1141 	ptr = path;
       
  1142 	return savePath;
       
  1143     }
       
  1144 
       
  1145 // ----------------------------------------------------------------------------
       
  1146 // CRingingToneBioControl ::VirtualHeight
       
  1147 // ----------------------------------------------------------------------------
       
  1148 //
       
  1149 TInt CRingingToneBioControl::VirtualHeight()
       
  1150 	{
       
  1151     return 0;
       
  1152 	}
       
  1153 
       
  1154 // ----------------------------------------------------------------------------
       
  1155 // CRingingToneBioControl ::VirtualVisibleTop
       
  1156 // ----------------------------------------------------------------------------
       
  1157 //
       
  1158 TInt CRingingToneBioControl::VirtualVisibleTop()
       
  1159 	{
       
  1160     return 0;
       
  1161 	}
       
  1162 
       
  1163 void CRingingToneBioControl::MsgAsyncControlStateChanged( CMsgBaseControl& /*aControl*/,
       
  1164                                               TMsgAsyncControlState aNewState,
       
  1165                                               TMsgAsyncControlState aOldState )
       
  1166     {
       
  1167     iPlayerState = aNewState;
       
  1168     
       
  1169     if(aOldState == EMsgAsyncControlStateOpening)
       
  1170 		{
       
  1171 		//last state was opening so we go ahead with playing by stopping 
       
  1172 		//the active scheduler that was started in OpenFileL -function
       
  1173 		CActiveScheduler::Stop();
       
  1174 		}
       
  1175     
       
  1176     switch( aNewState )
       
  1177     	{
       
  1178 			//intentional fallthrough    			
       
  1179 			case EMsgAsyncControlStateIdle:
       
  1180     		case EMsgAsyncControlStateStopped:
       
  1181     		case EMsgAsyncControlStateCorrupt:
       
  1182     		case EMsgAsyncControlStateNoRights:
       
  1183     			{
       
  1184     			//the Stop CBA has to be removed here because
       
  1185     			//playing could be stopped when the tune has finished or
       
  1186     			//the tune is corrupt
       
  1187     			delete iStopCba;
       
  1188     			iStopCba = NULL;
       
  1189     			break;
       
  1190     			}
       
  1191     	}
       
  1192     }
       
  1193 
       
  1194 
       
  1195 #ifdef RD_SCALABLE_UI_V2    
       
  1196 void CRingingToneBioControl::HandlePointerEventL( const TPointerEvent& aPointerEvent )
       
  1197     {
       
  1198 
       
  1199 
       
  1200     if ( AknLayoutUtils::PenEnabled() )
       
  1201         {
       
  1202         switch ( aPointerEvent.iType )
       
  1203             {
       
  1204             case TPointerEvent::EButton1Down:
       
  1205             	{
       
  1206             	//nothing to do here
       
  1207             	}
       
  1208             break;
       
  1209             case TPointerEvent::EButton1Up:
       
  1210                 {
       
  1211 				TBool hitted = iAudioControl->HitRegionContains( aPointerEvent.iPosition, *this );
       
  1212                 if( hitted )
       
  1213                     {
       
  1214                         if ( iPlayerState != EMsgAsyncControlStatePlaying )
       
  1215                             {
       
  1216                             //playback is triggered when focused control is touched with stylus
       
  1217                             iAudioControl->SetFocus(EFalse);
       
  1218                             PlaybackL();
       
  1219                             }
       
  1220                         else if ( iPlayerState == EMsgAsyncControlStatePlaying )
       
  1221                             {
       
  1222                             //stylus hit to audio control when playback is in 
       
  1223                             //progress stops the playing 
       
  1224                             StopPlayback();
       
  1225                             }
       
  1226                     }
       
  1227             	}
       
  1228               break;
       
  1229             default:
       
  1230                 break;
       
  1231             }
       
  1232         }
       
  1233     }
       
  1234 #else   
       
  1235 void CRingingToneBioControl::HandlePointerEventL( const TPointerEvent& /*aPointerEvent*/ )
       
  1236     {
       
  1237     //no op
       
  1238     }
       
  1239 #endif // RD_SCALABLE_UI_V2    
       
  1240 
       
  1241 void CRingingToneBioControl::MsgAsyncControlResourceChanged( CMsgBaseControl& /*aControl*/,
       
  1242 											 				 TInt /*aType*/ )
       
  1243 	{
       
  1244 	//no op
       
  1245 	}
       
  1246 //  End of File