os/mm/mmlibs/mmfw/tsrc/mmvalidationsuite/mmvalidationsuiteapp/src/MVSSelectPluginsDialog.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // Part of the MVS Application for TechView
    15 //
    16 
    17 #include "MVSSelectPluginsDialog.h"
    18 #include "MVSApp.hrh"
    19 #include <techview/eikmfne.h>
    20 #include <coecntrl.h>
    21 #include "MVSConstants.h"
    22 
    23 #include <techview/eikhopbt.h>
    24 
    25 
    26 
    27 void CMVSSelectPluginsDialog::SetupDialogLD(CDesCArrayFlat* aPluginArray,
    28 		                     CDesCArrayFlat* aExtArray, CDesCArrayFlat* aCodecArray, 
    29                                CMVSAppUi* aAppUi)
    30 	{
    31      
    32     CMVSSelectPluginsDialog* dialog = new (ELeave) CMVSSelectPluginsDialog(
    33                                                        aPluginArray, 
    34                                                        aExtArray, aCodecArray,
    35                                                        aAppUi);
    36      
    37     CleanupStack::PushL(dialog); 
    38     dialog->ConstructL(aCodecArray);
    39     CleanupStack::Pop(dialog);
    40     dialog->ExecuteLD(R_MVS_DIALOG_SELECTPLUGINS);
    41     }
    42 
    43 
    44 
    45 void CMVSSelectPluginsDialog::ConstructL(CDesCArrayFlat* aCodecArray)
    46     {
    47     //Create new arrays
    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)
    54     	{
    55         iCodecArray->AppendL((*aCodecArray)[counter]);
    56         }
    57     }
    58 
    59 
    60 void CMVSSelectPluginsDialog::PreLayoutDynInitL()
    61     {
    62     CEikChoiceList* myPluginArray = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectControllerPlugin));
    63     CEikChoiceList* myExt = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectFormat));
    64     if(iExtArray->Count()==0)
    65     	{
    66 		User::InfoPrint(KNotsupported);    	
    67     	}
    68     else
    69     	{
    70     	if(myPluginArray)
    71 			{
    72 			myPluginArray->SetArrayL(iPluginArray);
    73     		myPluginArray->SetArrayExternalOwnership(ETrue);	
    74 			myPluginArray->SetObserver(this);
    75 			iPluginCtl =  myPluginArray; 
    76 			}
    77     	if(myExt)
    78     		{
    79     		myExt->SetArrayL(iExtArray);
    80     		myExt->SetArrayExternalOwnership(ETrue);	
    81     		myExt->SetObserver(this); 
    82     		iExtCtl = myExt;
    83     		}	
    84     	}
    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
    88     if(pRadioGroup)
    89     	{
    90     	pRadioGroup->SetButtonById(EMVSHorOptButtonAudio);
    91     	pRadioGroup->SetObserver(this);
    92     	}
    93     }
    94 
    95 	
    96 CMVSSelectPluginsDialog::CMVSSelectPluginsDialog(CDesCArrayFlat* aPluginArray,
    97 		                      CDesCArrayFlat* aExtArray, CDesCArrayFlat* aCodecArray,  
    98                               CMVSAppUi* aAppUi)
    99 : iPluginArray(aPluginArray), iExtArray(aExtArray), iCodecArray(aCodecArray), iAppUi(aAppUi)
   100     {     
   101     iPluginCtl = 0;
   102     iExtCtl = 0;
   103     iMediaType = 0;
   104     }
   105 
   106 
   107 TBool CMVSSelectPluginsDialog::OkToExitL(TInt aButtonId)
   108 	{
   109     TInt indx = 0;
   110     //button options are Next> and Cancel
   111     if(aButtonId == EMVSButtonNext)
   112     	{
   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)
   118 	        {
   119 	        CDesCArray *pDescArr = myExt->DesCArray();
   120 	        CDesCArray *pControllerArr = myPluginArray->DesCArray();
   121 	        if(pDescArr->MdcaCount() > 0)
   122 		    	{
   123 		        indx = myExt->CurrentItem();
   124 				iExt.Append((*iExtArray)[indx]);		  	          	
   125 		        } 
   126 		    indx = myPluginArray->CurrentItem();
   127 			iAppUi->SelectedExtension(iExt);
   128 		    iAppUi->SelectedPluginIdx(indx);
   129 		    iAppUi->SelectedMedia(iMediaType);	
   130 	        }
   131         }
   132     else if(aButtonId == EMVSButtonCancel)
   133     	{
   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);
   138     	}
   139     return ETrue; //return
   140     }
   141 
   142 
   143 void CMVSSelectPluginsDialog::HandleControlEventL(CCoeControl *aControl, TCoeEvent aEventType)
   144 	{
   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)
   149 		{
   150 		TInt8 idx  = iExtCtl->CurrentItem();
   151 		if(iExtCtl == aControl && aEventType == EEventStateChanged)
   152 			{
   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();
   160 			return;
   161 			}
   162 		
   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)
   167 	    	{
   168 	     	TInt nButtonId = pRadioGroup->LabeledButtonId();
   169 	     	if(nButtonId == EMVSHorOptButtonAudio) //if selected media - audio
   170 	     		{
   171 	     		iMediaType = 0;
   172 	     		}
   173 	     	else if(nButtonId == EMVSHorOptButtonVideo) //if selected media - video
   174 	     		{
   175 	     		iMediaType = 1;
   176 	     		}
   177 	       	iPluginArray->Reset();
   178 	   		iExtArray->Reset();
   179 	   		idx=0;  	
   180 	      	iAppUi->GetExtensionListL(iExtArray,iMediaType);
   181 	      	if(iExtArray->Count()==0)
   182 	      		{
   183 	      		User::InfoPrint(KNotsupported);
   184 	      		}
   185 	      	else
   186 	      		{
   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();	
   195 	      		}		
   196 	      	}	
   197 		}
   198 	}
   199 
   200 
   201 TKeyResponse CMVSSelectPluginsDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
   202 	{
   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)
   207 		{
   208 		OkToExitL(EMVSButtonCancel);	
   209 		}
   210 	if(aKeyEvent.iScanCode == EStdKeyEnter && aType == EEventKeyDown)
   211 		{
   212 		OkToExitL(EMVSButtonNext);
   213 		}
   214 	return CEikDialog::OfferKeyEventL(aKeyEvent,aType);
   215 	}
   216 
   217 
   218 CMVSSelectPluginsDialog::~CMVSSelectPluginsDialog()
   219 	{
   220 	iPluginArray->Reset(); //reset the arrays
   221     iExtArray->Reset();
   222     iCodecArray->Reset();
   223     delete iExtArray; //and delete them both
   224     delete iPluginArray;
   225 	delete iCodecArray;
   226 	}