os/mm/mmlibs/mmfw/tsrc/mmvalidationsuite/mmvalidationsuiteapp/src/MVSSelectPluginsDialog.cpp
Update contrib.
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Part of the MVS Application for TechView
17 #include "MVSSelectPluginsDialog.h"
19 #include <techview/eikmfne.h>
21 #include "MVSConstants.h"
23 #include <techview/eikhopbt.h>
27 void CMVSSelectPluginsDialog::SetupDialogLD(CDesCArrayFlat* aPluginArray,
28 CDesCArrayFlat* aExtArray, CDesCArrayFlat* aCodecArray,
32 CMVSSelectPluginsDialog* dialog = new (ELeave) CMVSSelectPluginsDialog(
34 aExtArray, aCodecArray,
37 CleanupStack::PushL(dialog);
38 dialog->ConstructL(aCodecArray);
39 CleanupStack::Pop(dialog);
40 dialog->ExecuteLD(R_MVS_DIALOG_SELECTPLUGINS);
45 void CMVSSelectPluginsDialog::ConstructL(CDesCArrayFlat* aCodecArray)
48 iExtArray = new(ELeave) CDesCArrayFlat(8);
49 iPluginArray = new(ELeave) CDesCArrayFlat(8);
50 iCodecArray = new(ELeave) CDesCArrayFlat(8);
51 iAppUi->GetExtensionListL(iExtArray,iMediaType);
52 iAppUi->GetPluginListL(0,iExtArray,iPluginArray,iMediaType);
53 for(TInt counter = 0; counter< aCodecArray->Count(); ++counter)
55 iCodecArray->AppendL((*aCodecArray)[counter]);
60 void CMVSSelectPluginsDialog::PreLayoutDynInitL()
62 CEikChoiceList* myPluginArray = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectControllerPlugin));
63 CEikChoiceList* myExt = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectFormat));
64 if(iExtArray->Count()==0)
66 User::InfoPrint(KNotsupported);
72 myPluginArray->SetArrayL(iPluginArray);
73 myPluginArray->SetArrayExternalOwnership(ETrue);
74 myPluginArray->SetObserver(this);
75 iPluginCtl = myPluginArray;
79 myExt->SetArrayL(iExtArray);
80 myExt->SetArrayExternalOwnership(ETrue);
81 myExt->SetObserver(this);
85 //Get a pointer to the Option Button List control
86 CEikHorOptionButtonList* pRadioGroup = static_cast<CEikHorOptionButtonList*>(Control(EMVSCmdSelectMediaType));
87 //set audio as the default button to be selected
90 pRadioGroup->SetButtonById(EMVSHorOptButtonAudio);
91 pRadioGroup->SetObserver(this);
96 CMVSSelectPluginsDialog::CMVSSelectPluginsDialog(CDesCArrayFlat* aPluginArray,
97 CDesCArrayFlat* aExtArray, CDesCArrayFlat* aCodecArray,
99 : iPluginArray(aPluginArray), iExtArray(aExtArray), iCodecArray(aCodecArray), iAppUi(aAppUi)
107 TBool CMVSSelectPluginsDialog::OkToExitL(TInt aButtonId)
110 //button options are Next> and Cancel
111 if(aButtonId == EMVSButtonNext)
113 //Get a downcasted pointer to the controls
114 CEikChoiceList* myPluginArray = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectControllerPlugin));
115 CEikChoiceList* myExt = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectFormat));
116 iExt.Zero(); //zero the buffer, and append the extension
117 if(myPluginArray && myExt)
119 CDesCArray *pDescArr = myExt->DesCArray();
120 CDesCArray *pControllerArr = myPluginArray->DesCArray();
121 if(pDescArr->MdcaCount() > 0)
123 indx = myExt->CurrentItem();
124 iExt.Append((*iExtArray)[indx]);
126 indx = myPluginArray->CurrentItem();
127 iAppUi->SelectedExtension(iExt);
128 iAppUi->SelectedPluginIdx(indx);
129 iAppUi->SelectedMedia(iMediaType);
132 else if(aButtonId == EMVSButtonCancel)
134 //to indicate that a suitable controller has to be selected automatically
135 //by the system based on the file name entered by the user.
136 indx= KControllerNotSelected;
137 iAppUi->SelectedPluginIdx(indx);
139 return ETrue; //return
143 void CMVSSelectPluginsDialog::HandleControlEventL(CCoeControl *aControl, TCoeEvent aEventType)
145 CEikDialog::HandleControlEventL(aControl,aEventType);
146 CEikChoiceList* myPluginArray = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectControllerPlugin));
147 CEikChoiceList* myExt = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectFormat));
148 if(myPluginArray && myExt)
150 TInt8 idx = iExtCtl->CurrentItem();
151 if(iExtCtl == aControl && aEventType == EEventStateChanged)
153 iPluginArray->Reset();
154 TInt8 temp = iAppUi->GetPluginListL(idx,iExtArray,iPluginArray,iMediaType);
155 TInt n = iPluginArray->Count();
156 myPluginArray->SetArrayL(iPluginArray);
157 myPluginArray->SetArrayExternalOwnership(ETrue);
158 myPluginArray->SetCurrentItem(0);
159 myPluginArray->DrawDeferred();
163 //Get a pointer to the Option Button List control
164 CEikHorOptionButtonList* pRadioGroup =
165 static_cast<CEikHorOptionButtonList*>(Control(EMVSCmdSelectMediaType));
166 if(pRadioGroup == aControl && aEventType == EEventStateChanged)
168 TInt nButtonId = pRadioGroup->LabeledButtonId();
169 if(nButtonId == EMVSHorOptButtonAudio) //if selected media - audio
173 else if(nButtonId == EMVSHorOptButtonVideo) //if selected media - video
177 iPluginArray->Reset();
180 iAppUi->GetExtensionListL(iExtArray,iMediaType);
181 if(iExtArray->Count()==0)
183 User::InfoPrint(KNotsupported);
187 iAppUi->GetPluginListL(idx,iExtArray,iPluginArray,iMediaType);
188 myPluginArray->SetArrayL(iPluginArray);
189 myPluginArray->SetCurrentItem(0);
190 myPluginArray->DrawDeferred();
191 myExt->SetArrayL(iExtArray);
192 myExt->SetArrayExternalOwnership(ETrue);
193 myExt->SetCurrentItem(0);
194 myExt->DrawDeferred();
201 TKeyResponse CMVSSelectPluginsDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
203 //In this case iScanCode is used in preference to iCode,
204 //as using iCode in list selection doesn't seem to work well
205 //with shortkeys,gives a panic
206 if (aKeyEvent.iScanCode == EStdKeyEscape && aType == EEventKeyDown)
208 OkToExitL(EMVSButtonCancel);
210 if(aKeyEvent.iScanCode == EStdKeyEnter && aType == EEventKeyDown)
212 OkToExitL(EMVSButtonNext);
214 return CEikDialog::OfferKeyEventL(aKeyEvent,aType);
218 CMVSSelectPluginsDialog::~CMVSSelectPluginsDialog()
220 iPluginArray->Reset(); //reset the arrays
222 iCodecArray->Reset();
223 delete iExtArray; //and delete them both