|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Implementation for the CDosExtensionBase class |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "dosextensionbase.h" |
|
21 #include "dosclientserver.h" |
|
22 #include "dosserver.h" |
|
23 #include "dos_debug.h" |
|
24 #include <e32svr.h> |
|
25 |
|
26 // |
|
27 // --------------------------------------------------------- |
|
28 // CDosExtensionBase::ExecuteMessageL |
|
29 // --------------------------------------------------------- |
|
30 // |
|
31 |
|
32 EXPORT_C TInt CDosExtensionBase::ExecuteMessageL(const RMessage2& aMessage) |
|
33 { |
|
34 |
|
35 API_TRACE_( "[DOSSERVER] CDosExtensionBase::ExecuteMessageL(...)" ); |
|
36 __ASSERT_DEBUG(aMessage.Function() == ECallFunction, |
|
37 PanicClient(aMessage,EPanicIllegalFunction)); |
|
38 |
|
39 TInt retVal(KErrNone); |
|
40 TBool parameterModifiedByDSY(EFalse); |
|
41 |
|
42 // Get data from RMessage |
|
43 TExtensionParPckg extPars; |
|
44 aMessage.ReadL(0, extPars); |
|
45 |
|
46 TInt dataLength(extPars().iParLength); |
|
47 if (dataLength >= 0) |
|
48 { |
|
49 HBufC8* dataBuffer = HBufC8::NewMaxLC( dataLength ); |
|
50 TPtr8 dataPtr = dataBuffer->Des(); |
|
51 aMessage.ReadL( 1, dataPtr ); |
|
52 |
|
53 // Check autocomplete flag |
|
54 TUint autoCompl(aMessage.Int2()); |
|
55 if (autoCompl == KAutoComplete) |
|
56 { |
|
57 COM_TRACE_4( "[DOSSERVER] MDosExtensionBaseDSY::CallFunctionL(0x%x,0x%x,0x%x,0x%x)" |
|
58 ,extPars().iFunc |
|
59 ,dataPtr.Ptr() |
|
60 ,dataPtr.Length() |
|
61 ,autoCompl ); |
|
62 |
|
63 retVal = CallFunctionL(extPars().iFunc, const_cast<TUint8*>(dataPtr.Ptr()), dataPtr.Length(), parameterModifiedByDSY); |
|
64 |
|
65 if((retVal == KErrNone) && parameterModifiedByDSY) |
|
66 { |
|
67 // Write over client's parameters |
|
68 retVal = aMessage.Write(1, dataPtr); |
|
69 } |
|
70 } |
|
71 else |
|
72 { |
|
73 COM_TRACE_3( "[DOSSERVER] MDosExtensionBaseDSY::CallFunctionAndCompleteL(0x%x,0x%x,0x%x)" |
|
74 ,extPars().iFunc |
|
75 ,dataPtr.Ptr() |
|
76 ,dataPtr.Length() ); |
|
77 |
|
78 CallFunctionAndCompleteL(extPars().iFunc, const_cast<TUint8*>(dataPtr.Ptr()), dataPtr.Length(), aMessage); |
|
79 } |
|
80 |
|
81 CleanupStack::PopAndDestroy(); // dataBuffer |
|
82 } |
|
83 else |
|
84 { |
|
85 // Client passed negative parameter length |
|
86 retVal = KErrGeneral; |
|
87 } |
|
88 |
|
89 return retVal; |
|
90 } |
|
91 |
|
92 // |
|
93 // --------------------------------------------------------- |
|
94 // CDosExtensionBase::CompleteRequest |
|
95 // --------------------------------------------------------- |
|
96 // |
|
97 |
|
98 EXPORT_C void CDosExtensionBase::CompleteRequest(const RMessage2& aMessage, TInt aError, TAny* aPar, TInt aParLength, TBool aParameterModified) const |
|
99 { |
|
100 // Write over client's parameters |
|
101 if ((aError == KErrNone) && aParameterModified) |
|
102 { |
|
103 TPtrC8 ptr(static_cast<TUint8*>(aPar), aParLength); |
|
104 aError = aMessage.Write(1, ptr); |
|
105 } |
|
106 |
|
107 RequestComplete(aMessage, aError); |
|
108 } |
|
109 |