os/mm/mmlibs/mmfw/tsrc/mmvalidationsuite/mmvalidationsuiteapp/src/MVSSelectPluginsDialog.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmvalidationsuite/mmvalidationsuiteapp/src/MVSSelectPluginsDialog.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,226 @@
     1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// Part of the MVS Application for TechView
    1.18 +//
    1.19 +
    1.20 +#include "MVSSelectPluginsDialog.h"
    1.21 +#include "MVSApp.hrh"
    1.22 +#include <techview/eikmfne.h>
    1.23 +#include <coecntrl.h>
    1.24 +#include "MVSConstants.h"
    1.25 +
    1.26 +#include <techview/eikhopbt.h>
    1.27 +
    1.28 +
    1.29 +
    1.30 +void CMVSSelectPluginsDialog::SetupDialogLD(CDesCArrayFlat* aPluginArray,
    1.31 +		                     CDesCArrayFlat* aExtArray, CDesCArrayFlat* aCodecArray, 
    1.32 +                               CMVSAppUi* aAppUi)
    1.33 +	{
    1.34 +     
    1.35 +    CMVSSelectPluginsDialog* dialog = new (ELeave) CMVSSelectPluginsDialog(
    1.36 +                                                       aPluginArray, 
    1.37 +                                                       aExtArray, aCodecArray,
    1.38 +                                                       aAppUi);
    1.39 +     
    1.40 +    CleanupStack::PushL(dialog); 
    1.41 +    dialog->ConstructL(aCodecArray);
    1.42 +    CleanupStack::Pop(dialog);
    1.43 +    dialog->ExecuteLD(R_MVS_DIALOG_SELECTPLUGINS);
    1.44 +    }
    1.45 +
    1.46 +
    1.47 +
    1.48 +void CMVSSelectPluginsDialog::ConstructL(CDesCArrayFlat* aCodecArray)
    1.49 +    {
    1.50 +    //Create new arrays
    1.51 +    iExtArray = new(ELeave) CDesCArrayFlat(8);
    1.52 +    iPluginArray = new(ELeave) CDesCArrayFlat(8);
    1.53 +	iCodecArray = new(ELeave) CDesCArrayFlat(8);
    1.54 +    iAppUi->GetExtensionListL(iExtArray,iMediaType);
    1.55 +    iAppUi->GetPluginListL(0,iExtArray,iPluginArray,iMediaType);
    1.56 +    for(TInt counter = 0; counter< aCodecArray->Count(); ++counter)
    1.57 +    	{
    1.58 +        iCodecArray->AppendL((*aCodecArray)[counter]);
    1.59 +        }
    1.60 +    }
    1.61 +
    1.62 +
    1.63 +void CMVSSelectPluginsDialog::PreLayoutDynInitL()
    1.64 +    {
    1.65 +    CEikChoiceList* myPluginArray = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectControllerPlugin));
    1.66 +    CEikChoiceList* myExt = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectFormat));
    1.67 +    if(iExtArray->Count()==0)
    1.68 +    	{
    1.69 +		User::InfoPrint(KNotsupported);    	
    1.70 +    	}
    1.71 +    else
    1.72 +    	{
    1.73 +    	if(myPluginArray)
    1.74 +			{
    1.75 +			myPluginArray->SetArrayL(iPluginArray);
    1.76 +    		myPluginArray->SetArrayExternalOwnership(ETrue);	
    1.77 +			myPluginArray->SetObserver(this);
    1.78 +			iPluginCtl =  myPluginArray; 
    1.79 +			}
    1.80 +    	if(myExt)
    1.81 +    		{
    1.82 +    		myExt->SetArrayL(iExtArray);
    1.83 +    		myExt->SetArrayExternalOwnership(ETrue);	
    1.84 +    		myExt->SetObserver(this); 
    1.85 +    		iExtCtl = myExt;
    1.86 +    		}	
    1.87 +    	}
    1.88 +    //Get a pointer to the Option Button List control
    1.89 +    CEikHorOptionButtonList* pRadioGroup = static_cast<CEikHorOptionButtonList*>(Control(EMVSCmdSelectMediaType));
    1.90 +    //set audio as the default button to be selected
    1.91 +    if(pRadioGroup)
    1.92 +    	{
    1.93 +    	pRadioGroup->SetButtonById(EMVSHorOptButtonAudio);
    1.94 +    	pRadioGroup->SetObserver(this);
    1.95 +    	}
    1.96 +    }
    1.97 +
    1.98 +	
    1.99 +CMVSSelectPluginsDialog::CMVSSelectPluginsDialog(CDesCArrayFlat* aPluginArray,
   1.100 +		                      CDesCArrayFlat* aExtArray, CDesCArrayFlat* aCodecArray,  
   1.101 +                              CMVSAppUi* aAppUi)
   1.102 +: iPluginArray(aPluginArray), iExtArray(aExtArray), iCodecArray(aCodecArray), iAppUi(aAppUi)
   1.103 +    {     
   1.104 +    iPluginCtl = 0;
   1.105 +    iExtCtl = 0;
   1.106 +    iMediaType = 0;
   1.107 +    }
   1.108 +
   1.109 +
   1.110 +TBool CMVSSelectPluginsDialog::OkToExitL(TInt aButtonId)
   1.111 +	{
   1.112 +    TInt indx = 0;
   1.113 +    //button options are Next> and Cancel
   1.114 +    if(aButtonId == EMVSButtonNext)
   1.115 +    	{
   1.116 +        //Get a downcasted pointer to the controls
   1.117 +        CEikChoiceList* myPluginArray = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectControllerPlugin));
   1.118 +        CEikChoiceList* myExt = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectFormat));
   1.119 +		iExt.Zero(); //zero the buffer, and append the extension
   1.120 +        if(myPluginArray && myExt)
   1.121 +	        {
   1.122 +	        CDesCArray *pDescArr = myExt->DesCArray();
   1.123 +	        CDesCArray *pControllerArr = myPluginArray->DesCArray();
   1.124 +	        if(pDescArr->MdcaCount() > 0)
   1.125 +		    	{
   1.126 +		        indx = myExt->CurrentItem();
   1.127 +				iExt.Append((*iExtArray)[indx]);		  	          	
   1.128 +		        } 
   1.129 +		    indx = myPluginArray->CurrentItem();
   1.130 +			iAppUi->SelectedExtension(iExt);
   1.131 +		    iAppUi->SelectedPluginIdx(indx);
   1.132 +		    iAppUi->SelectedMedia(iMediaType);	
   1.133 +	        }
   1.134 +        }
   1.135 +    else if(aButtonId == EMVSButtonCancel)
   1.136 +    	{
   1.137 +    	//to indicate that a suitable controller has to be selected automatically
   1.138 +    	//by the system based on the file name entered by the user.
   1.139 +    	indx= KControllerNotSelected;
   1.140 +    	iAppUi->SelectedPluginIdx(indx);
   1.141 +    	}
   1.142 +    return ETrue; //return
   1.143 +    }
   1.144 +
   1.145 +
   1.146 +void CMVSSelectPluginsDialog::HandleControlEventL(CCoeControl *aControl, TCoeEvent aEventType)
   1.147 +	{
   1.148 +	CEikDialog::HandleControlEventL(aControl,aEventType);
   1.149 +	CEikChoiceList* myPluginArray = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectControllerPlugin));
   1.150 +	CEikChoiceList* myExt = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectFormat));		
   1.151 +	if(myPluginArray && myExt)
   1.152 +		{
   1.153 +		TInt8 idx  = iExtCtl->CurrentItem();
   1.154 +		if(iExtCtl == aControl && aEventType == EEventStateChanged)
   1.155 +			{
   1.156 +			iPluginArray->Reset();
   1.157 +			TInt8 temp = iAppUi->GetPluginListL(idx,iExtArray,iPluginArray,iMediaType);
   1.158 +			TInt n = iPluginArray->Count();
   1.159 +			myPluginArray->SetArrayL(iPluginArray);
   1.160 +			myPluginArray->SetArrayExternalOwnership(ETrue);
   1.161 +			myPluginArray->SetCurrentItem(0);
   1.162 +			myPluginArray->DrawDeferred();
   1.163 +			return;
   1.164 +			}
   1.165 +		
   1.166 +		//Get a pointer to the Option Button List control
   1.167 +	    CEikHorOptionButtonList* pRadioGroup = 
   1.168 +	    	static_cast<CEikHorOptionButtonList*>(Control(EMVSCmdSelectMediaType)); 	
   1.169 +	    if(pRadioGroup == aControl && aEventType == EEventStateChanged)
   1.170 +	    	{
   1.171 +	     	TInt nButtonId = pRadioGroup->LabeledButtonId();
   1.172 +	     	if(nButtonId == EMVSHorOptButtonAudio) //if selected media - audio
   1.173 +	     		{
   1.174 +	     		iMediaType = 0;
   1.175 +	     		}
   1.176 +	     	else if(nButtonId == EMVSHorOptButtonVideo) //if selected media - video
   1.177 +	     		{
   1.178 +	     		iMediaType = 1;
   1.179 +	     		}
   1.180 +	       	iPluginArray->Reset();
   1.181 +	   		iExtArray->Reset();
   1.182 +	   		idx=0;  	
   1.183 +	      	iAppUi->GetExtensionListL(iExtArray,iMediaType);
   1.184 +	      	if(iExtArray->Count()==0)
   1.185 +	      		{
   1.186 +	      		User::InfoPrint(KNotsupported);
   1.187 +	      		}
   1.188 +	      	else
   1.189 +	      		{
   1.190 +	      		iAppUi->GetPluginListL(idx,iExtArray,iPluginArray,iMediaType);
   1.191 +	      		myPluginArray->SetArrayL(iPluginArray);
   1.192 +	     		myPluginArray->SetCurrentItem(0);
   1.193 +	     		myPluginArray->DrawDeferred();
   1.194 +	     		myExt->SetArrayL(iExtArray);
   1.195 +				myExt->SetArrayExternalOwnership(ETrue);
   1.196 +				myExt->SetCurrentItem(0);
   1.197 +				myExt->DrawDeferred();	
   1.198 +	      		}		
   1.199 +	      	}	
   1.200 +		}
   1.201 +	}
   1.202 +
   1.203 +
   1.204 +TKeyResponse CMVSSelectPluginsDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
   1.205 +	{
   1.206 +	//In this case iScanCode is used in preference to iCode, 
   1.207 +	//as using iCode in list selection doesn't seem to work well
   1.208 +	//with shortkeys,gives a panic
   1.209 +	if (aKeyEvent.iScanCode == EStdKeyEscape && aType == EEventKeyDown)
   1.210 +		{
   1.211 +		OkToExitL(EMVSButtonCancel);	
   1.212 +		}
   1.213 +	if(aKeyEvent.iScanCode == EStdKeyEnter && aType == EEventKeyDown)
   1.214 +		{
   1.215 +		OkToExitL(EMVSButtonNext);
   1.216 +		}
   1.217 +	return CEikDialog::OfferKeyEventL(aKeyEvent,aType);
   1.218 +	}
   1.219 +
   1.220 +
   1.221 +CMVSSelectPluginsDialog::~CMVSSelectPluginsDialog()
   1.222 +	{
   1.223 +	iPluginArray->Reset(); //reset the arrays
   1.224 +    iExtArray->Reset();
   1.225 +    iCodecArray->Reset();
   1.226 +    delete iExtArray; //and delete them both
   1.227 +    delete iPluginArray;
   1.228 +	delete iCodecArray;
   1.229 +	}