os/mm/mmlibs/mmfw/tsrc/mmvalidationsuite/mmvalidationsuiteapp/src/MVSSelectPluginsDialog.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Part of the MVS Application for TechView
sl@0
    15
//
sl@0
    16
sl@0
    17
#include "MVSSelectPluginsDialog.h"
sl@0
    18
#include "MVSApp.hrh"
sl@0
    19
#include <techview/eikmfne.h>
sl@0
    20
#include <coecntrl.h>
sl@0
    21
#include "MVSConstants.h"
sl@0
    22
sl@0
    23
#include <techview/eikhopbt.h>
sl@0
    24
sl@0
    25
sl@0
    26
sl@0
    27
void CMVSSelectPluginsDialog::SetupDialogLD(CDesCArrayFlat* aPluginArray,
sl@0
    28
		                     CDesCArrayFlat* aExtArray, CDesCArrayFlat* aCodecArray, 
sl@0
    29
                               CMVSAppUi* aAppUi)
sl@0
    30
	{
sl@0
    31
     
sl@0
    32
    CMVSSelectPluginsDialog* dialog = new (ELeave) CMVSSelectPluginsDialog(
sl@0
    33
                                                       aPluginArray, 
sl@0
    34
                                                       aExtArray, aCodecArray,
sl@0
    35
                                                       aAppUi);
sl@0
    36
     
sl@0
    37
    CleanupStack::PushL(dialog); 
sl@0
    38
    dialog->ConstructL(aCodecArray);
sl@0
    39
    CleanupStack::Pop(dialog);
sl@0
    40
    dialog->ExecuteLD(R_MVS_DIALOG_SELECTPLUGINS);
sl@0
    41
    }
sl@0
    42
sl@0
    43
sl@0
    44
sl@0
    45
void CMVSSelectPluginsDialog::ConstructL(CDesCArrayFlat* aCodecArray)
sl@0
    46
    {
sl@0
    47
    //Create new arrays
sl@0
    48
    iExtArray = new(ELeave) CDesCArrayFlat(8);
sl@0
    49
    iPluginArray = new(ELeave) CDesCArrayFlat(8);
sl@0
    50
	iCodecArray = new(ELeave) CDesCArrayFlat(8);
sl@0
    51
    iAppUi->GetExtensionListL(iExtArray,iMediaType);
sl@0
    52
    iAppUi->GetPluginListL(0,iExtArray,iPluginArray,iMediaType);
sl@0
    53
    for(TInt counter = 0; counter< aCodecArray->Count(); ++counter)
sl@0
    54
    	{
sl@0
    55
        iCodecArray->AppendL((*aCodecArray)[counter]);
sl@0
    56
        }
sl@0
    57
    }
sl@0
    58
sl@0
    59
sl@0
    60
void CMVSSelectPluginsDialog::PreLayoutDynInitL()
sl@0
    61
    {
sl@0
    62
    CEikChoiceList* myPluginArray = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectControllerPlugin));
sl@0
    63
    CEikChoiceList* myExt = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectFormat));
sl@0
    64
    if(iExtArray->Count()==0)
sl@0
    65
    	{
sl@0
    66
		User::InfoPrint(KNotsupported);    	
sl@0
    67
    	}
sl@0
    68
    else
sl@0
    69
    	{
sl@0
    70
    	if(myPluginArray)
sl@0
    71
			{
sl@0
    72
			myPluginArray->SetArrayL(iPluginArray);
sl@0
    73
    		myPluginArray->SetArrayExternalOwnership(ETrue);	
sl@0
    74
			myPluginArray->SetObserver(this);
sl@0
    75
			iPluginCtl =  myPluginArray; 
sl@0
    76
			}
sl@0
    77
    	if(myExt)
sl@0
    78
    		{
sl@0
    79
    		myExt->SetArrayL(iExtArray);
sl@0
    80
    		myExt->SetArrayExternalOwnership(ETrue);	
sl@0
    81
    		myExt->SetObserver(this); 
sl@0
    82
    		iExtCtl = myExt;
sl@0
    83
    		}	
sl@0
    84
    	}
sl@0
    85
    //Get a pointer to the Option Button List control
sl@0
    86
    CEikHorOptionButtonList* pRadioGroup = static_cast<CEikHorOptionButtonList*>(Control(EMVSCmdSelectMediaType));
sl@0
    87
    //set audio as the default button to be selected
sl@0
    88
    if(pRadioGroup)
sl@0
    89
    	{
sl@0
    90
    	pRadioGroup->SetButtonById(EMVSHorOptButtonAudio);
sl@0
    91
    	pRadioGroup->SetObserver(this);
sl@0
    92
    	}
sl@0
    93
    }
sl@0
    94
sl@0
    95
	
sl@0
    96
CMVSSelectPluginsDialog::CMVSSelectPluginsDialog(CDesCArrayFlat* aPluginArray,
sl@0
    97
		                      CDesCArrayFlat* aExtArray, CDesCArrayFlat* aCodecArray,  
sl@0
    98
                              CMVSAppUi* aAppUi)
sl@0
    99
: iPluginArray(aPluginArray), iExtArray(aExtArray), iCodecArray(aCodecArray), iAppUi(aAppUi)
sl@0
   100
    {     
sl@0
   101
    iPluginCtl = 0;
sl@0
   102
    iExtCtl = 0;
sl@0
   103
    iMediaType = 0;
sl@0
   104
    }
sl@0
   105
sl@0
   106
sl@0
   107
TBool CMVSSelectPluginsDialog::OkToExitL(TInt aButtonId)
sl@0
   108
	{
sl@0
   109
    TInt indx = 0;
sl@0
   110
    //button options are Next> and Cancel
sl@0
   111
    if(aButtonId == EMVSButtonNext)
sl@0
   112
    	{
sl@0
   113
        //Get a downcasted pointer to the controls
sl@0
   114
        CEikChoiceList* myPluginArray = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectControllerPlugin));
sl@0
   115
        CEikChoiceList* myExt = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectFormat));
sl@0
   116
		iExt.Zero(); //zero the buffer, and append the extension
sl@0
   117
        if(myPluginArray && myExt)
sl@0
   118
	        {
sl@0
   119
	        CDesCArray *pDescArr = myExt->DesCArray();
sl@0
   120
	        CDesCArray *pControllerArr = myPluginArray->DesCArray();
sl@0
   121
	        if(pDescArr->MdcaCount() > 0)
sl@0
   122
		    	{
sl@0
   123
		        indx = myExt->CurrentItem();
sl@0
   124
				iExt.Append((*iExtArray)[indx]);		  	          	
sl@0
   125
		        } 
sl@0
   126
		    indx = myPluginArray->CurrentItem();
sl@0
   127
			iAppUi->SelectedExtension(iExt);
sl@0
   128
		    iAppUi->SelectedPluginIdx(indx);
sl@0
   129
		    iAppUi->SelectedMedia(iMediaType);	
sl@0
   130
	        }
sl@0
   131
        }
sl@0
   132
    else if(aButtonId == EMVSButtonCancel)
sl@0
   133
    	{
sl@0
   134
    	//to indicate that a suitable controller has to be selected automatically
sl@0
   135
    	//by the system based on the file name entered by the user.
sl@0
   136
    	indx= KControllerNotSelected;
sl@0
   137
    	iAppUi->SelectedPluginIdx(indx);
sl@0
   138
    	}
sl@0
   139
    return ETrue; //return
sl@0
   140
    }
sl@0
   141
sl@0
   142
sl@0
   143
void CMVSSelectPluginsDialog::HandleControlEventL(CCoeControl *aControl, TCoeEvent aEventType)
sl@0
   144
	{
sl@0
   145
	CEikDialog::HandleControlEventL(aControl,aEventType);
sl@0
   146
	CEikChoiceList* myPluginArray = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectControllerPlugin));
sl@0
   147
	CEikChoiceList* myExt = static_cast<CEikChoiceList*>(Control(EMVSCmdSelectFormat));		
sl@0
   148
	if(myPluginArray && myExt)
sl@0
   149
		{
sl@0
   150
		TInt8 idx  = iExtCtl->CurrentItem();
sl@0
   151
		if(iExtCtl == aControl && aEventType == EEventStateChanged)
sl@0
   152
			{
sl@0
   153
			iPluginArray->Reset();
sl@0
   154
			TInt8 temp = iAppUi->GetPluginListL(idx,iExtArray,iPluginArray,iMediaType);
sl@0
   155
			TInt n = iPluginArray->Count();
sl@0
   156
			myPluginArray->SetArrayL(iPluginArray);
sl@0
   157
			myPluginArray->SetArrayExternalOwnership(ETrue);
sl@0
   158
			myPluginArray->SetCurrentItem(0);
sl@0
   159
			myPluginArray->DrawDeferred();
sl@0
   160
			return;
sl@0
   161
			}
sl@0
   162
		
sl@0
   163
		//Get a pointer to the Option Button List control
sl@0
   164
	    CEikHorOptionButtonList* pRadioGroup = 
sl@0
   165
	    	static_cast<CEikHorOptionButtonList*>(Control(EMVSCmdSelectMediaType)); 	
sl@0
   166
	    if(pRadioGroup == aControl && aEventType == EEventStateChanged)
sl@0
   167
	    	{
sl@0
   168
	     	TInt nButtonId = pRadioGroup->LabeledButtonId();
sl@0
   169
	     	if(nButtonId == EMVSHorOptButtonAudio) //if selected media - audio
sl@0
   170
	     		{
sl@0
   171
	     		iMediaType = 0;
sl@0
   172
	     		}
sl@0
   173
	     	else if(nButtonId == EMVSHorOptButtonVideo) //if selected media - video
sl@0
   174
	     		{
sl@0
   175
	     		iMediaType = 1;
sl@0
   176
	     		}
sl@0
   177
	       	iPluginArray->Reset();
sl@0
   178
	   		iExtArray->Reset();
sl@0
   179
	   		idx=0;  	
sl@0
   180
	      	iAppUi->GetExtensionListL(iExtArray,iMediaType);
sl@0
   181
	      	if(iExtArray->Count()==0)
sl@0
   182
	      		{
sl@0
   183
	      		User::InfoPrint(KNotsupported);
sl@0
   184
	      		}
sl@0
   185
	      	else
sl@0
   186
	      		{
sl@0
   187
	      		iAppUi->GetPluginListL(idx,iExtArray,iPluginArray,iMediaType);
sl@0
   188
	      		myPluginArray->SetArrayL(iPluginArray);
sl@0
   189
	     		myPluginArray->SetCurrentItem(0);
sl@0
   190
	     		myPluginArray->DrawDeferred();
sl@0
   191
	     		myExt->SetArrayL(iExtArray);
sl@0
   192
				myExt->SetArrayExternalOwnership(ETrue);
sl@0
   193
				myExt->SetCurrentItem(0);
sl@0
   194
				myExt->DrawDeferred();	
sl@0
   195
	      		}		
sl@0
   196
	      	}	
sl@0
   197
		}
sl@0
   198
	}
sl@0
   199
sl@0
   200
sl@0
   201
TKeyResponse CMVSSelectPluginsDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
sl@0
   202
	{
sl@0
   203
	//In this case iScanCode is used in preference to iCode, 
sl@0
   204
	//as using iCode in list selection doesn't seem to work well
sl@0
   205
	//with shortkeys,gives a panic
sl@0
   206
	if (aKeyEvent.iScanCode == EStdKeyEscape && aType == EEventKeyDown)
sl@0
   207
		{
sl@0
   208
		OkToExitL(EMVSButtonCancel);	
sl@0
   209
		}
sl@0
   210
	if(aKeyEvent.iScanCode == EStdKeyEnter && aType == EEventKeyDown)
sl@0
   211
		{
sl@0
   212
		OkToExitL(EMVSButtonNext);
sl@0
   213
		}
sl@0
   214
	return CEikDialog::OfferKeyEventL(aKeyEvent,aType);
sl@0
   215
	}
sl@0
   216
sl@0
   217
sl@0
   218
CMVSSelectPluginsDialog::~CMVSSelectPluginsDialog()
sl@0
   219
	{
sl@0
   220
	iPluginArray->Reset(); //reset the arrays
sl@0
   221
    iExtArray->Reset();
sl@0
   222
    iCodecArray->Reset();
sl@0
   223
    delete iExtArray; //and delete them both
sl@0
   224
    delete iPluginArray;
sl@0
   225
	delete iCodecArray;
sl@0
   226
	}