os/boardsupport/haitest/bspsvs/suite/bsp/mmc/src/T_MmcSDSessionData.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
/*
sl@0
     2
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description:
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
#include "T_MmcSDSessionData.h"
sl@0
    19
sl@0
    20
//MMCSD Commands index
sl@0
    21
/*@{*/
sl@0
    22
_LIT(KCmdConstructor,					"NewL");
sl@0
    23
_LIT(KCmdLoadDriver,					"LoadDriver");
sl@0
    24
_LIT(KCmdUnLoadDriver,					"UnLoadDriver");
sl@0
    25
_LIT(KCmdDriverOpen,					"DriverOpen");
sl@0
    26
_LIT(KCmdDestructor,					"~");
sl@0
    27
sl@0
    28
_LIT(KLDDName,							"LDD");
sl@0
    29
_LIT(KStackNumber,						"stacknumber");
sl@0
    30
/*@}*/
sl@0
    31
sl@0
    32
sl@0
    33
sl@0
    34
/**
sl@0
    35
 * Create a new Socket Driver Data wrapper
sl@0
    36
 *
sl@0
    37
 * @return					A Socket Driver Data wrapper
sl@0
    38
 *
sl@0
    39
 * @leave					System wide error
sl@0
    40
 */
sl@0
    41
CT_MmcSDSessionData* CT_MmcSDSessionData::NewL()
sl@0
    42
	{
sl@0
    43
	CT_MmcSDSessionData*	ret=new (ELeave) CT_MmcSDSessionData();
sl@0
    44
	CleanupStack::PushL(ret);
sl@0
    45
	ret->ConstructL();
sl@0
    46
	CleanupStack::Pop(ret);
sl@0
    47
	return ret;
sl@0
    48
	}
sl@0
    49
sl@0
    50
/**
sl@0
    51
 * Construction
sl@0
    52
 *
sl@0
    53
 * @return					N/A
sl@0
    54
 */
sl@0
    55
CT_MmcSDSessionData::CT_MmcSDSessionData()
sl@0
    56
:	CT_RBusLogicalChannelData()
sl@0
    57
,	iMmcSDController(NULL)
sl@0
    58
	{
sl@0
    59
	}
sl@0
    60
sl@0
    61
/**
sl@0
    62
 * Second phase construction
sl@0
    63
 *
sl@0
    64
 * @return					void
sl@0
    65
 *
sl@0
    66
 * @leave					System wide error
sl@0
    67
 */
sl@0
    68
void CT_MmcSDSessionData::ConstructL()
sl@0
    69
	{
sl@0
    70
	}
sl@0
    71
sl@0
    72
/**
sl@0
    73
 * Public destructor
sl@0
    74
 *
sl@0
    75
 * @return					N/A
sl@0
    76
 */
sl@0
    77
CT_MmcSDSessionData::~CT_MmcSDSessionData()
sl@0
    78
	{
sl@0
    79
	}
sl@0
    80
sl@0
    81
/**
sl@0
    82
 * Return a pointer to the object that the data wraps
sl@0
    83
 *
sl@0
    84
 * @return					pointer to the object that the data wraps
sl@0
    85
 */
sl@0
    86
TAny* CT_MmcSDSessionData::GetObject()
sl@0
    87
	{
sl@0
    88
	return iMmcSDController;
sl@0
    89
	}
sl@0
    90
sl@0
    91
/**
sl@0
    92
 * Return a pointer to the handle
sl@0
    93
 *
sl@0
    94
 * @return					pointer to the MMC/SD Controller
sl@0
    95
 */
sl@0
    96
RHandleBase* CT_MmcSDSessionData::GetHandleBase()
sl@0
    97
	{
sl@0
    98
	return iMmcSDController;
sl@0
    99
	}
sl@0
   100
sl@0
   101
/**
sl@0
   102
 * Return a pointer to the logical channel
sl@0
   103
 *
sl@0
   104
 * @return					pointer to the MMC/SD Controller
sl@0
   105
 */
sl@0
   106
RBusLogicalChannel* CT_MmcSDSessionData::GetBusLogicalChannel()
sl@0
   107
	{
sl@0
   108
	return iMmcSDController;
sl@0
   109
	}
sl@0
   110
sl@0
   111
/**
sl@0
   112
 * Close and clean
sl@0
   113
 *
sl@0
   114
 * @return					void
sl@0
   115
 */
sl@0
   116
void CT_MmcSDSessionData::DestroyData()
sl@0
   117
	{
sl@0
   118
	delete iMmcSDController;
sl@0
   119
	iMmcSDController=NULL;
sl@0
   120
	}
sl@0
   121
sl@0
   122
/**
sl@0
   123
 * Process a command read from the script file
sl@0
   124
 *
sl@0
   125
 * @param aCommand			The command to process
sl@0
   126
 * @param aSection			The section in the ini containing data for the command
sl@0
   127
 * @param aAsyncErrorIndex	Command index for async calls to return errors to
sl@0
   128
 *
sl@0
   129
 * @return					ETrue if the command is processed
sl@0
   130
 *
sl@0
   131
 * @leave					System wide error
sl@0
   132
 */
sl@0
   133
TBool CT_MmcSDSessionData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
sl@0
   134
	{
sl@0
   135
	TBool	ret=ETrue;
sl@0
   136
sl@0
   137
	if ( aCommand==KCmdConstructor )
sl@0
   138
		{
sl@0
   139
		DoCmdConstructor();
sl@0
   140
		}
sl@0
   141
	else if ( aCommand==KCmdLoadDriver )
sl@0
   142
		{
sl@0
   143
		DoCmdLoadDriver(aSection);
sl@0
   144
		}
sl@0
   145
	else if ( aCommand==KCmdDriverOpen )
sl@0
   146
		{
sl@0
   147
		DoCmdDriverOpen(aSection);
sl@0
   148
		}
sl@0
   149
	else if ( aCommand==KCmdUnLoadDriver )
sl@0
   150
		{
sl@0
   151
		DoCmdUnLoadDriver(aSection);
sl@0
   152
		}
sl@0
   153
	else if ( aCommand==KCmdDestructor )
sl@0
   154
		{
sl@0
   155
		DoCmdDestructor();
sl@0
   156
		}
sl@0
   157
	else
sl@0
   158
		{
sl@0
   159
		ret=CT_RBusLogicalChannelData::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
sl@0
   160
		}
sl@0
   161
	return ret;
sl@0
   162
	}
sl@0
   163
sl@0
   164
/**
sl@0
   165
 * Creates the RBusLogicalChannel derived interface
sl@0
   166
 *
sl@0
   167
 * @param aCommand			None
sl@0
   168
 *
sl@0
   169
 * @return					None
sl@0
   170
 */
sl@0
   171
void CT_MmcSDSessionData::DoCmdConstructor()
sl@0
   172
	{
sl@0
   173
	delete iMmcSDController;
sl@0
   174
	iMmcSDController=NULL;
sl@0
   175
	TRAPD(err, iMmcSDController=new (ELeave) RMMCSDTestControllerInterface());
sl@0
   176
	if ( err!=KErrNone )
sl@0
   177
		{
sl@0
   178
		ERR_PRINTF2(_L("RMMCSDTestControllerInterface Creation Error %d"), err);
sl@0
   179
		SetError(err);
sl@0
   180
		}
sl@0
   181
	}
sl@0
   182
sl@0
   183
/**
sl@0
   184
 * Loads the Device Driver
sl@0
   185
 *
sl@0
   186
 * @param aSection			The section in the ini containing data for the command
sl@0
   187
 *
sl@0
   188
 * @return					void
sl@0
   189
 */
sl@0
   190
void CT_MmcSDSessionData::DoCmdLoadDriver(const TDesC& aSection)
sl@0
   191
	{
sl@0
   192
	TPtrC lddname;
sl@0
   193
	if(!GetStringFromConfig(aSection, KLDDName(), lddname))
sl@0
   194
		{
sl@0
   195
		ERR_PRINTF1(_L("Error in Reading Driver Name from INI file -Load"));
sl@0
   196
		SetBlockResult(EFail);
sl@0
   197
		}
sl@0
   198
	User::LoadLogicalDevice(lddname);
sl@0
   199
	}
sl@0
   200
sl@0
   201
/**
sl@0
   202
 * Unloads the Device Driver
sl@0
   203
 *
sl@0
   204
 * @param aSection			The section in the ini containing data for the command
sl@0
   205
 *
sl@0
   206
 * @return					void
sl@0
   207
 */
sl@0
   208
void CT_MmcSDSessionData::DoCmdUnLoadDriver(const TDesC& aSection)
sl@0
   209
	{
sl@0
   210
	TPtrC lddname;
sl@0
   211
	if(!GetStringFromConfig(aSection, KLDDName(), lddname))
sl@0
   212
		{
sl@0
   213
		ERR_PRINTF1(_L("Error in Reading Driver Name from INI file-UnLoad"));
sl@0
   214
		SetBlockResult(EFail);
sl@0
   215
		}
sl@0
   216
	User::FreeLogicalDevice(lddname);
sl@0
   217
	}
sl@0
   218
sl@0
   219
/**
sl@0
   220
 * Opens the Driver Call
sl@0
   221
 *
sl@0
   222
 * @param aSection			The section in the ini containing data for the command
sl@0
   223
 *
sl@0
   224
 * @return					void
sl@0
   225
 */
sl@0
   226
void CT_MmcSDSessionData::DoCmdDriverOpen(const TDesC& aSection)
sl@0
   227
	{
sl@0
   228
	TInt err;
sl@0
   229
	TInt stackNumber = 0;
sl@0
   230
	GetIntFromConfig(aSection, KStackNumber(), stackNumber);
sl@0
   231
	err=iMmcSDController->Open(stackNumber,iMmcSDController->VersionRequired());
sl@0
   232
	if ( err!=KErrNone )
sl@0
   233
		{
sl@0
   234
		ERR_PRINTF2(_L("Driver Open Call Failure %d"), err);
sl@0
   235
		SetError(err);
sl@0
   236
		}
sl@0
   237
	else
sl@0
   238
		{
sl@0
   239
		INFO_PRINTF2(_L("iMmcSDController = %x"), iMmcSDController);
sl@0
   240
		}
sl@0
   241
	}
sl@0
   242
sl@0
   243
/**
sl@0
   244
 * Destroys the objects
sl@0
   245
 *
sl@0
   246
 * @return					void
sl@0
   247
 */
sl@0
   248
void CT_MmcSDSessionData::DoCmdDestructor()
sl@0
   249
	{
sl@0
   250
	INFO_PRINTF1(_L("CT_MmcSDSessionData::DoCmdDestructor()"));
sl@0
   251
	DestroyData();
sl@0
   252
	}
sl@0
   253