Update contrib.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
20 #include "d_mmcsdif.h"
21 #include "LddAsyncRequest.h"
24 * DLddAsyncRequest constructor
26 * @param TInt aFunctionId - functionId
27 * @param TRequestStatus* aStatus for signalling upon completion
28 * @param MAsyncRequestObserver& aObserver - observer recieves notification upon completion
34 DLddAsyncRequest::DLddAsyncRequest(TInt aFunctionId, TRequestStatus* aStatus, MAsyncRequestObserver& aObserver)
35 : iFunctionId(aFunctionId)
37 , iObserver(aObserver)
49 DLddAsyncRequest::~DLddAsyncRequest()
54 * Get the error code for this request
57 * @return TInt the error code
61 TInt DLddAsyncRequest::Error()
67 * Get the function Id for this request
69 * @return TInt the function Id
73 TInt DLddAsyncRequest::FunctionId()
79 * Get the status of this request
82 * @return TRequestStatus status of the request
86 TRequestStatus* DLddAsyncRequest::Status()
92 ///////////////////////////////////////////////////////////////////////
93 //////////////////// DMmcSessionAsyncRequest //////////////////////////
94 ///////////////////////////////////////////////////////////////////////
97 * DMmcSessionAsyncRequest Constructor
99 * @param TInt aFunctionId - functionId
100 * @param TRequestStatus* aStatus for signalling upon completion
101 * @param MAsyncRequestObserver& aObserver - observer recieves notification upon completion
102 * @param TDynamicDfcQue* aDfcQ - pointer to dfc queue,
103 * @param DMMCStack& aStack stack upon which this request will operate
104 * @param TMMCard& aCard multimedia card upon which this request will operate
111 DMmcSessionAsyncRequest::DMmcSessionAsyncRequest(TInt aFunctionId, TRequestStatus* aStatus,
112 MAsyncRequestObserver& aObserver, TDynamicDfcQue* aDfcQ, DMMCStack& aStack, TMMCard& aCard)
113 : DLddAsyncRequest(aFunctionId, aStatus, aObserver)
115 , iSessionEndCallBack(DMmcSessionAsyncRequest::SessionEndCallBack, this)
116 , iSessionEndDfc(DMmcSessionAsyncRequest::SessionEndDfc, this, 1)
117 , iClientDesPtr(NULL)
123 aStack.BufferInfo(iBuf, bufLen, minorBufLen);
125 iSession = aStack.AllocSession(iSessionEndCallBack);
126 iSession->SetStack(&aStack);
127 iSession->SetCard(&aCard);
129 iSessionEndDfc.SetDfcQ(aDfcQ);
141 DMmcSessionAsyncRequest::~DMmcSessionAsyncRequest()
147 void DMmcSessionAsyncRequest::Reset()
149 MMCSDLOG("iSessionEndDfc.Cancel() called");
150 iSessionEndDfc.Cancel();
155 * Gets the async requests DMMCSession
157 * @return reference to the DMMCSession
161 DMMCSession& DMmcSessionAsyncRequest::Session()
167 * The session end callback (static)- called when and engaged session completes
169 * @param TAny* in this case this will be a pointer to the DMmcSessionAsyncRequest
175 void DMmcSessionAsyncRequest::SessionEndCallBack(TAny *aPtr)
177 ((DMmcSessionAsyncRequest*)aPtr)->SessionEndCallBack();
182 * Utility function called from static overload SessionEndCallBack(TAny*)
188 void DMmcSessionAsyncRequest::SessionEndCallBack()
190 MMCSDLOG("DMmcSessionAsyncRequest::SessionEndCallBack called");
191 iError = iSession->EpocErrorCode();
193 if (NKern::CurrentContext()==NKern::EInterrupt)
195 iSessionEndDfc.Add();
199 // Signal request complete using DFC
200 if (!iSessionEndDfc.Queued())
202 iSessionEndDfc.Enque();
209 * Session deferred function call (static)
211 * @param TAny* in this case this will be a pointer to the DMmcSessionAsyncRequest
217 void DMmcSessionAsyncRequest::SessionEndDfc(TAny *aPtr)
219 ((DMmcSessionAsyncRequest*) aPtr)->SessionEndDfc();
224 * Utility function called from static overload SessionEndDfc(TAny*)
230 void DMmcSessionAsyncRequest::SessionEndDfc()
232 MMCSDLOG2("DLddAsyncRequest::SessionEndDfc called err(%d)", iError);
233 iObserver.Notify(*this);
234 MMCSDLOG("DLddAsyncRequest::SessionEndDfc finished");
240 * DBusEventRequest constructor
242 * @param TInt aFunctionId - Function ID
243 * @param TRequestStatus* aStatus - Request Status
244 * @param MAsyncRequestObserver& aObserver - Asynchronous Request observer interface
245 * @param TInt aUnit - Socket ID
251 DBusEventRequest::DBusEventRequest(TInt aFunctionId, TRequestStatus* aStatus, MAsyncRequestObserver& aObserver, TInt aUnit,
252 TDynamicDfcQue* aDfcQ, DMMCStack& aStack, TMMCard& aCard)
253 : DMmcSessionAsyncRequest(aFunctionId, aStatus, aObserver, aDfcQ, aStack, aCard)
254 , iBusEventCallBack(DBusEventRequest::BusEventCallBack, this)
256 iBusEventCallBack.SetSocket(aUnit);
257 iBusEventCallBack.Add();
267 DBusEventRequest::~DBusEventRequest()
269 iBusEventCallBack.Remove();
273 * Callback when request has completed
275 * @param TAny* aPtr - Pointer to the bus event request
276 * @param TInt aReason - Completion error code
277 * @param TAny* a1 - Given parameter
278 * @param TAny* a2 - Given parameter
284 void DBusEventRequest::BusEventCallBack(TAny* aPtr, TInt aReason, TAny* a1, TAny* a2)
286 ((DBusEventRequest*)aPtr)->BusEventCallBack(aReason, a1, a2);
290 * Callback when request has completed
292 * @param TInt aReason - Completion error code
293 * @param TAny* a1 - Given parameter
294 * @param TAny* a2 - Given parameter
300 void DBusEventRequest::BusEventCallBack(TInt aReason, TAny* a1, TAny* a2)
303 MMCSDLOG("DBusEventRequest::BusEventCallBack called");
305 iBusState = (TPBusState)((TInt) a1);
306 iBusError = (TInt) a2;
307 MMCSDLOG4("DBusEventRequest::BusEventCallBack iBusState(%d) iBusError(%d) iError(%d)", iBusState, iBusError, iError);
308 iObserver.Notify(*this);
309 MMCSDLOG("DBusEventRequest::BusEventCallBack finished");