1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/boardsupport/haitest/bspsvs/suite/bsp/mmc/src/T_MmcSDSessionData.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,253 @@
1.4 +/*
1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +#include "T_MmcSDSessionData.h"
1.22 +
1.23 +//MMCSD Commands index
1.24 +/*@{*/
1.25 +_LIT(KCmdConstructor, "NewL");
1.26 +_LIT(KCmdLoadDriver, "LoadDriver");
1.27 +_LIT(KCmdUnLoadDriver, "UnLoadDriver");
1.28 +_LIT(KCmdDriverOpen, "DriverOpen");
1.29 +_LIT(KCmdDestructor, "~");
1.30 +
1.31 +_LIT(KLDDName, "LDD");
1.32 +_LIT(KStackNumber, "stacknumber");
1.33 +/*@}*/
1.34 +
1.35 +
1.36 +
1.37 +/**
1.38 + * Create a new Socket Driver Data wrapper
1.39 + *
1.40 + * @return A Socket Driver Data wrapper
1.41 + *
1.42 + * @leave System wide error
1.43 + */
1.44 +CT_MmcSDSessionData* CT_MmcSDSessionData::NewL()
1.45 + {
1.46 + CT_MmcSDSessionData* ret=new (ELeave) CT_MmcSDSessionData();
1.47 + CleanupStack::PushL(ret);
1.48 + ret->ConstructL();
1.49 + CleanupStack::Pop(ret);
1.50 + return ret;
1.51 + }
1.52 +
1.53 +/**
1.54 + * Construction
1.55 + *
1.56 + * @return N/A
1.57 + */
1.58 +CT_MmcSDSessionData::CT_MmcSDSessionData()
1.59 +: CT_RBusLogicalChannelData()
1.60 +, iMmcSDController(NULL)
1.61 + {
1.62 + }
1.63 +
1.64 +/**
1.65 + * Second phase construction
1.66 + *
1.67 + * @return void
1.68 + *
1.69 + * @leave System wide error
1.70 + */
1.71 +void CT_MmcSDSessionData::ConstructL()
1.72 + {
1.73 + }
1.74 +
1.75 +/**
1.76 + * Public destructor
1.77 + *
1.78 + * @return N/A
1.79 + */
1.80 +CT_MmcSDSessionData::~CT_MmcSDSessionData()
1.81 + {
1.82 + }
1.83 +
1.84 +/**
1.85 + * Return a pointer to the object that the data wraps
1.86 + *
1.87 + * @return pointer to the object that the data wraps
1.88 + */
1.89 +TAny* CT_MmcSDSessionData::GetObject()
1.90 + {
1.91 + return iMmcSDController;
1.92 + }
1.93 +
1.94 +/**
1.95 + * Return a pointer to the handle
1.96 + *
1.97 + * @return pointer to the MMC/SD Controller
1.98 + */
1.99 +RHandleBase* CT_MmcSDSessionData::GetHandleBase()
1.100 + {
1.101 + return iMmcSDController;
1.102 + }
1.103 +
1.104 +/**
1.105 + * Return a pointer to the logical channel
1.106 + *
1.107 + * @return pointer to the MMC/SD Controller
1.108 + */
1.109 +RBusLogicalChannel* CT_MmcSDSessionData::GetBusLogicalChannel()
1.110 + {
1.111 + return iMmcSDController;
1.112 + }
1.113 +
1.114 +/**
1.115 + * Close and clean
1.116 + *
1.117 + * @return void
1.118 + */
1.119 +void CT_MmcSDSessionData::DestroyData()
1.120 + {
1.121 + delete iMmcSDController;
1.122 + iMmcSDController=NULL;
1.123 + }
1.124 +
1.125 +/**
1.126 + * Process a command read from the script file
1.127 + *
1.128 + * @param aCommand The command to process
1.129 + * @param aSection The section in the ini containing data for the command
1.130 + * @param aAsyncErrorIndex Command index for async calls to return errors to
1.131 + *
1.132 + * @return ETrue if the command is processed
1.133 + *
1.134 + * @leave System wide error
1.135 + */
1.136 +TBool CT_MmcSDSessionData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
1.137 + {
1.138 + TBool ret=ETrue;
1.139 +
1.140 + if ( aCommand==KCmdConstructor )
1.141 + {
1.142 + DoCmdConstructor();
1.143 + }
1.144 + else if ( aCommand==KCmdLoadDriver )
1.145 + {
1.146 + DoCmdLoadDriver(aSection);
1.147 + }
1.148 + else if ( aCommand==KCmdDriverOpen )
1.149 + {
1.150 + DoCmdDriverOpen(aSection);
1.151 + }
1.152 + else if ( aCommand==KCmdUnLoadDriver )
1.153 + {
1.154 + DoCmdUnLoadDriver(aSection);
1.155 + }
1.156 + else if ( aCommand==KCmdDestructor )
1.157 + {
1.158 + DoCmdDestructor();
1.159 + }
1.160 + else
1.161 + {
1.162 + ret=CT_RBusLogicalChannelData::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
1.163 + }
1.164 + return ret;
1.165 + }
1.166 +
1.167 +/**
1.168 + * Creates the RBusLogicalChannel derived interface
1.169 + *
1.170 + * @param aCommand None
1.171 + *
1.172 + * @return None
1.173 + */
1.174 +void CT_MmcSDSessionData::DoCmdConstructor()
1.175 + {
1.176 + delete iMmcSDController;
1.177 + iMmcSDController=NULL;
1.178 + TRAPD(err, iMmcSDController=new (ELeave) RMMCSDTestControllerInterface());
1.179 + if ( err!=KErrNone )
1.180 + {
1.181 + ERR_PRINTF2(_L("RMMCSDTestControllerInterface Creation Error %d"), err);
1.182 + SetError(err);
1.183 + }
1.184 + }
1.185 +
1.186 +/**
1.187 + * Loads the Device Driver
1.188 + *
1.189 + * @param aSection The section in the ini containing data for the command
1.190 + *
1.191 + * @return void
1.192 + */
1.193 +void CT_MmcSDSessionData::DoCmdLoadDriver(const TDesC& aSection)
1.194 + {
1.195 + TPtrC lddname;
1.196 + if(!GetStringFromConfig(aSection, KLDDName(), lddname))
1.197 + {
1.198 + ERR_PRINTF1(_L("Error in Reading Driver Name from INI file -Load"));
1.199 + SetBlockResult(EFail);
1.200 + }
1.201 + User::LoadLogicalDevice(lddname);
1.202 + }
1.203 +
1.204 +/**
1.205 + * Unloads the Device Driver
1.206 + *
1.207 + * @param aSection The section in the ini containing data for the command
1.208 + *
1.209 + * @return void
1.210 + */
1.211 +void CT_MmcSDSessionData::DoCmdUnLoadDriver(const TDesC& aSection)
1.212 + {
1.213 + TPtrC lddname;
1.214 + if(!GetStringFromConfig(aSection, KLDDName(), lddname))
1.215 + {
1.216 + ERR_PRINTF1(_L("Error in Reading Driver Name from INI file-UnLoad"));
1.217 + SetBlockResult(EFail);
1.218 + }
1.219 + User::FreeLogicalDevice(lddname);
1.220 + }
1.221 +
1.222 +/**
1.223 + * Opens the Driver Call
1.224 + *
1.225 + * @param aSection The section in the ini containing data for the command
1.226 + *
1.227 + * @return void
1.228 + */
1.229 +void CT_MmcSDSessionData::DoCmdDriverOpen(const TDesC& aSection)
1.230 + {
1.231 + TInt err;
1.232 + TInt stackNumber = 0;
1.233 + GetIntFromConfig(aSection, KStackNumber(), stackNumber);
1.234 + err=iMmcSDController->Open(stackNumber,iMmcSDController->VersionRequired());
1.235 + if ( err!=KErrNone )
1.236 + {
1.237 + ERR_PRINTF2(_L("Driver Open Call Failure %d"), err);
1.238 + SetError(err);
1.239 + }
1.240 + else
1.241 + {
1.242 + INFO_PRINTF2(_L("iMmcSDController = %x"), iMmcSDController);
1.243 + }
1.244 + }
1.245 +
1.246 +/**
1.247 + * Destroys the objects
1.248 + *
1.249 + * @return void
1.250 + */
1.251 +void CT_MmcSDSessionData::DoCmdDestructor()
1.252 + {
1.253 + INFO_PRINTF1(_L("CT_MmcSDSessionData::DoCmdDestructor()"));
1.254 + DestroyData();
1.255 + }
1.256 +