|
1 /* |
|
2 * Copyright (c) 2006 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: Concrete server message wrapper implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "ximpsrvmessageimp.h" |
|
21 #include <e32base.h> |
|
22 |
|
23 // ----------------------------------------------------------------------------- |
|
24 // CXIMPSrvMessageImp::NewOrNull() |
|
25 // ----------------------------------------------------------------------------- |
|
26 // |
|
27 CXIMPSrvMessageImp* CXIMPSrvMessageImp::NewOrNull( |
|
28 const RMessage2& aMessage, |
|
29 MXIMPSrvMessage*& aSelfPtr, |
|
30 CXIMPSrvMessageImp*& aSourcePtr ) |
|
31 { |
|
32 __ASSERT_ALWAYS( !aSelfPtr, |
|
33 User::Panic( NXIMPPrivPanic::KCategory, |
|
34 NXIMPPrivPanic::EMessageSelfPtrAlreadyOccupied ) ); |
|
35 if( !aSourcePtr ) |
|
36 { |
|
37 aSourcePtr = new CXIMPSrvMessageImp( aMessage, aSelfPtr ); // CSI: 62 # |
|
38 // Special non-leaving function |
|
39 } |
|
40 else |
|
41 { |
|
42 aSourcePtr->Init( aMessage, aSelfPtr ); |
|
43 } |
|
44 return aSourcePtr; |
|
45 } |
|
46 |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CXIMPSrvMessageImp::~CXIMPSrvMessageImp() |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CXIMPSrvMessageImp::~CXIMPSrvMessageImp() |
|
53 { |
|
54 //If assert below is triggered, it means |
|
55 //that owned message is not completed before |
|
56 //deleting the wrapper |
|
57 __ASSERT_ALWAYS( iMessage.IsNull(), |
|
58 User::Panic( NXIMPPrivPanic::KCategory, |
|
59 NXIMPPrivPanic::EMessageStillPendingOnDestruction ) ); |
|
60 |
|
61 if( iSelfPtr ) |
|
62 { |
|
63 iSelfPtr = NULL; |
|
64 } |
|
65 } |
|
66 |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CXIMPSrvMessageImp::CXIMPSrvMessageImp() |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CXIMPSrvMessageImp::CXIMPSrvMessageImp( const RMessage2& aMessage, |
|
73 MXIMPSrvMessage*& aSelfPtr ) |
|
74 : iMessage( aMessage ), |
|
75 iSelfPtr( &aSelfPtr ) |
|
76 { |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CXIMPSrvMessageImp::Init() |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 void CXIMPSrvMessageImp::Init( const RMessage2& aMessage, |
|
84 MXIMPSrvMessage*& aSelfPtr ) |
|
85 { |
|
86 iMessage = aMessage; |
|
87 iSelfPtr = &aSelfPtr; |
|
88 } |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // CXIMPSrvMessageImp::Complete() |
|
92 // ----------------------------------------------------------------------------- |
|
93 void CXIMPSrvMessageImp::Complete( TInt aReason ) |
|
94 { |
|
95 if( !iMessage.IsNull() ) |
|
96 { |
|
97 iMessage.Complete( aReason ); |
|
98 } |
|
99 } |
|
100 |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CXIMPSrvMessageImp::IsCompleted() |
|
104 // ----------------------------------------------------------------------------- |
|
105 TBool CXIMPSrvMessageImp::IsCompleted() const |
|
106 { |
|
107 return iMessage.IsNull(); |
|
108 } |
|
109 |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CXIMPSrvMessageImp::Function() |
|
113 // ----------------------------------------------------------------------------- |
|
114 TInt CXIMPSrvMessageImp::Function() const |
|
115 { |
|
116 return iMessage.Function(); |
|
117 } |
|
118 |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // CXIMPSrvMessageImp::Int() |
|
122 // ----------------------------------------------------------------------------- |
|
123 TInt CXIMPSrvMessageImp::Int( TParamIndex aIndex ) const |
|
124 { |
|
125 TInt value = 0; |
|
126 switch( aIndex ) |
|
127 { |
|
128 case Ep0: |
|
129 { |
|
130 value = iMessage.Int0(); |
|
131 break; |
|
132 } |
|
133 |
|
134 case Ep1: |
|
135 { |
|
136 value = iMessage.Int1(); |
|
137 break; |
|
138 } |
|
139 |
|
140 case Ep2: |
|
141 { |
|
142 value = iMessage.Int2(); |
|
143 break; |
|
144 } |
|
145 |
|
146 case Ep3: |
|
147 { |
|
148 value = iMessage.Int3(); |
|
149 break; |
|
150 } |
|
151 } |
|
152 |
|
153 return value; |
|
154 } |
|
155 |
|
156 |
|
157 // ----------------------------------------------------------------------------- |
|
158 // CXIMPSrvMessageImp::GetDesLengthL() |
|
159 // ----------------------------------------------------------------------------- |
|
160 TInt CXIMPSrvMessageImp::GetDesLengthL( TParamIndex aIndex ) const |
|
161 { |
|
162 return iMessage.GetDesLengthL( aIndex ); |
|
163 } |
|
164 |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // CXIMPSrvMessageImp::ReadL() |
|
168 // ----------------------------------------------------------------------------- |
|
169 void CXIMPSrvMessageImp::ReadL( TParamIndex aIndex, TDes8& aDes ) const |
|
170 { |
|
171 return iMessage.ReadL( aIndex, aDes ); |
|
172 } |
|
173 |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // CXIMPSrvMessageImp::WriteL() |
|
177 // ----------------------------------------------------------------------------- |
|
178 void CXIMPSrvMessageImp::WriteL( TParamIndex aIndex, const TDesC8& aDes ) const |
|
179 { |
|
180 return iMessage.WriteL( aIndex, aDes ); |
|
181 } |
|
182 |
|
183 |
|
184 // ----------------------------------------------------------------------------- |
|
185 // CXIMPSrvMessageImp::PanicClientAndLeaveL() |
|
186 // ----------------------------------------------------------------------------- |
|
187 void CXIMPSrvMessageImp::PanicClientAndLeaveL( NXIMPPanic::TReason aReason ) const |
|
188 { |
|
189 iMessage.Panic( NXIMPPanic::KCategory, aReason ); |
|
190 User::Leave( KErrCompletion ); |
|
191 } |
|
192 |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // CXIMPSrvMessageImp::PlaceOwnershipHere() |
|
196 // ----------------------------------------------------------------------------- |
|
197 void CXIMPSrvMessageImp::PlaceOwnershipHere( MXIMPSrvMessage*& aNewSelfPtr ) |
|
198 { |
|
199 __ASSERT_ALWAYS( !aNewSelfPtr, |
|
200 User::Panic( NXIMPPrivPanic::KCategory, |
|
201 NXIMPPrivPanic::EMessageSelfPtrAlreadyOccupied ) ); |
|
202 |
|
203 //remove ownership from old pointer |
|
204 (*iSelfPtr) = NULL; |
|
205 |
|
206 //Cache new owning pointer |
|
207 iSelfPtr = &aNewSelfPtr; |
|
208 |
|
209 //And setup new owning pointer to point self |
|
210 aNewSelfPtr = this; |
|
211 } |
|
212 |
|
213 |
|
214 // End of file |