sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Part of the MVS Application for TechView sl@0: // sl@0: sl@0: #include "MVSSelectPluginsDialog.h" sl@0: #include "MVSApp.hrh" sl@0: #include sl@0: #include sl@0: #include "MVSConstants.h" sl@0: sl@0: #include sl@0: sl@0: sl@0: sl@0: void CMVSSelectPluginsDialog::SetupDialogLD(CDesCArrayFlat* aPluginArray, sl@0: CDesCArrayFlat* aExtArray, CDesCArrayFlat* aCodecArray, sl@0: CMVSAppUi* aAppUi) sl@0: { sl@0: sl@0: CMVSSelectPluginsDialog* dialog = new (ELeave) CMVSSelectPluginsDialog( sl@0: aPluginArray, sl@0: aExtArray, aCodecArray, sl@0: aAppUi); sl@0: sl@0: CleanupStack::PushL(dialog); sl@0: dialog->ConstructL(aCodecArray); sl@0: CleanupStack::Pop(dialog); sl@0: dialog->ExecuteLD(R_MVS_DIALOG_SELECTPLUGINS); sl@0: } sl@0: sl@0: sl@0: sl@0: void CMVSSelectPluginsDialog::ConstructL(CDesCArrayFlat* aCodecArray) sl@0: { sl@0: //Create new arrays sl@0: iExtArray = new(ELeave) CDesCArrayFlat(8); sl@0: iPluginArray = new(ELeave) CDesCArrayFlat(8); sl@0: iCodecArray = new(ELeave) CDesCArrayFlat(8); sl@0: iAppUi->GetExtensionListL(iExtArray,iMediaType); sl@0: iAppUi->GetPluginListL(0,iExtArray,iPluginArray,iMediaType); sl@0: for(TInt counter = 0; counter< aCodecArray->Count(); ++counter) sl@0: { sl@0: iCodecArray->AppendL((*aCodecArray)[counter]); sl@0: } sl@0: } sl@0: sl@0: sl@0: void CMVSSelectPluginsDialog::PreLayoutDynInitL() sl@0: { sl@0: CEikChoiceList* myPluginArray = static_cast(Control(EMVSCmdSelectControllerPlugin)); sl@0: CEikChoiceList* myExt = static_cast(Control(EMVSCmdSelectFormat)); sl@0: if(iExtArray->Count()==0) sl@0: { sl@0: User::InfoPrint(KNotsupported); sl@0: } sl@0: else sl@0: { sl@0: if(myPluginArray) sl@0: { sl@0: myPluginArray->SetArrayL(iPluginArray); sl@0: myPluginArray->SetArrayExternalOwnership(ETrue); sl@0: myPluginArray->SetObserver(this); sl@0: iPluginCtl = myPluginArray; sl@0: } sl@0: if(myExt) sl@0: { sl@0: myExt->SetArrayL(iExtArray); sl@0: myExt->SetArrayExternalOwnership(ETrue); sl@0: myExt->SetObserver(this); sl@0: iExtCtl = myExt; sl@0: } sl@0: } sl@0: //Get a pointer to the Option Button List control sl@0: CEikHorOptionButtonList* pRadioGroup = static_cast(Control(EMVSCmdSelectMediaType)); sl@0: //set audio as the default button to be selected sl@0: if(pRadioGroup) sl@0: { sl@0: pRadioGroup->SetButtonById(EMVSHorOptButtonAudio); sl@0: pRadioGroup->SetObserver(this); sl@0: } sl@0: } sl@0: sl@0: sl@0: CMVSSelectPluginsDialog::CMVSSelectPluginsDialog(CDesCArrayFlat* aPluginArray, sl@0: CDesCArrayFlat* aExtArray, CDesCArrayFlat* aCodecArray, sl@0: CMVSAppUi* aAppUi) sl@0: : iPluginArray(aPluginArray), iExtArray(aExtArray), iCodecArray(aCodecArray), iAppUi(aAppUi) sl@0: { sl@0: iPluginCtl = 0; sl@0: iExtCtl = 0; sl@0: iMediaType = 0; sl@0: } sl@0: sl@0: sl@0: TBool CMVSSelectPluginsDialog::OkToExitL(TInt aButtonId) sl@0: { sl@0: TInt indx = 0; sl@0: //button options are Next> and Cancel sl@0: if(aButtonId == EMVSButtonNext) sl@0: { sl@0: //Get a downcasted pointer to the controls sl@0: CEikChoiceList* myPluginArray = static_cast(Control(EMVSCmdSelectControllerPlugin)); sl@0: CEikChoiceList* myExt = static_cast(Control(EMVSCmdSelectFormat)); sl@0: iExt.Zero(); //zero the buffer, and append the extension sl@0: if(myPluginArray && myExt) sl@0: { sl@0: CDesCArray *pDescArr = myExt->DesCArray(); sl@0: CDesCArray *pControllerArr = myPluginArray->DesCArray(); sl@0: if(pDescArr->MdcaCount() > 0) sl@0: { sl@0: indx = myExt->CurrentItem(); sl@0: iExt.Append((*iExtArray)[indx]); sl@0: } sl@0: indx = myPluginArray->CurrentItem(); sl@0: iAppUi->SelectedExtension(iExt); sl@0: iAppUi->SelectedPluginIdx(indx); sl@0: iAppUi->SelectedMedia(iMediaType); sl@0: } sl@0: } sl@0: else if(aButtonId == EMVSButtonCancel) sl@0: { sl@0: //to indicate that a suitable controller has to be selected automatically sl@0: //by the system based on the file name entered by the user. sl@0: indx= KControllerNotSelected; sl@0: iAppUi->SelectedPluginIdx(indx); sl@0: } sl@0: return ETrue; //return sl@0: } sl@0: sl@0: sl@0: void CMVSSelectPluginsDialog::HandleControlEventL(CCoeControl *aControl, TCoeEvent aEventType) sl@0: { sl@0: CEikDialog::HandleControlEventL(aControl,aEventType); sl@0: CEikChoiceList* myPluginArray = static_cast(Control(EMVSCmdSelectControllerPlugin)); sl@0: CEikChoiceList* myExt = static_cast(Control(EMVSCmdSelectFormat)); sl@0: if(myPluginArray && myExt) sl@0: { sl@0: TInt8 idx = iExtCtl->CurrentItem(); sl@0: if(iExtCtl == aControl && aEventType == EEventStateChanged) sl@0: { sl@0: iPluginArray->Reset(); sl@0: TInt8 temp = iAppUi->GetPluginListL(idx,iExtArray,iPluginArray,iMediaType); sl@0: TInt n = iPluginArray->Count(); sl@0: myPluginArray->SetArrayL(iPluginArray); sl@0: myPluginArray->SetArrayExternalOwnership(ETrue); sl@0: myPluginArray->SetCurrentItem(0); sl@0: myPluginArray->DrawDeferred(); sl@0: return; sl@0: } sl@0: sl@0: //Get a pointer to the Option Button List control sl@0: CEikHorOptionButtonList* pRadioGroup = sl@0: static_cast(Control(EMVSCmdSelectMediaType)); sl@0: if(pRadioGroup == aControl && aEventType == EEventStateChanged) sl@0: { sl@0: TInt nButtonId = pRadioGroup->LabeledButtonId(); sl@0: if(nButtonId == EMVSHorOptButtonAudio) //if selected media - audio sl@0: { sl@0: iMediaType = 0; sl@0: } sl@0: else if(nButtonId == EMVSHorOptButtonVideo) //if selected media - video sl@0: { sl@0: iMediaType = 1; sl@0: } sl@0: iPluginArray->Reset(); sl@0: iExtArray->Reset(); sl@0: idx=0; sl@0: iAppUi->GetExtensionListL(iExtArray,iMediaType); sl@0: if(iExtArray->Count()==0) sl@0: { sl@0: User::InfoPrint(KNotsupported); sl@0: } sl@0: else sl@0: { sl@0: iAppUi->GetPluginListL(idx,iExtArray,iPluginArray,iMediaType); sl@0: myPluginArray->SetArrayL(iPluginArray); sl@0: myPluginArray->SetCurrentItem(0); sl@0: myPluginArray->DrawDeferred(); sl@0: myExt->SetArrayL(iExtArray); sl@0: myExt->SetArrayExternalOwnership(ETrue); sl@0: myExt->SetCurrentItem(0); sl@0: myExt->DrawDeferred(); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: sl@0: sl@0: TKeyResponse CMVSSelectPluginsDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) sl@0: { sl@0: //In this case iScanCode is used in preference to iCode, sl@0: //as using iCode in list selection doesn't seem to work well sl@0: //with shortkeys,gives a panic sl@0: if (aKeyEvent.iScanCode == EStdKeyEscape && aType == EEventKeyDown) sl@0: { sl@0: OkToExitL(EMVSButtonCancel); sl@0: } sl@0: if(aKeyEvent.iScanCode == EStdKeyEnter && aType == EEventKeyDown) sl@0: { sl@0: OkToExitL(EMVSButtonNext); sl@0: } sl@0: return CEikDialog::OfferKeyEventL(aKeyEvent,aType); sl@0: } sl@0: sl@0: sl@0: CMVSSelectPluginsDialog::~CMVSSelectPluginsDialog() sl@0: { sl@0: iPluginArray->Reset(); //reset the arrays sl@0: iExtArray->Reset(); sl@0: iCodecArray->Reset(); sl@0: delete iExtArray; //and delete them both sl@0: delete iPluginArray; sl@0: delete iCodecArray; sl@0: }