|
1 /* |
|
2 * Copyright (c) 2005 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 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // MCE API |
|
22 |
|
23 #include <MCEManager.h> |
|
24 #include <MCEOutEvent.h> |
|
25 #include <Uri8.h> |
|
26 |
|
27 #include "MCETestUIEngineDefaultValues.h" |
|
28 #include "CMCETestUIQuestionDataQuery.h" |
|
29 #include "CMCETestUIEngine.h" |
|
30 #include "CMCETestUIEngineProfileContainer.h" |
|
31 #include "CMCETestUIEngineProfile.h" |
|
32 #include "CMCETestUIEngineOutEvent.h" |
|
33 #include "TMCETestUIEngineCmdSubscribeEvent.h" |
|
34 #include "TMCETestUIEngineCmdUpdateEvent.h" |
|
35 #include "TMCETestUIEngineCmdDeleteEvent.h" |
|
36 |
|
37 // ============================ MEMBER FUNCTIONS =============================== |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CMCETestUIEngineOutEvent::NewL() |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CMCETestUIEngineOutEvent* CMCETestUIEngineOutEvent::NewL( |
|
44 CMCETestUIEngine& aEngine, |
|
45 CMCETestUIEngineProfile& aProfile) |
|
46 { |
|
47 |
|
48 CMCETestUIEngineOutEvent* self = |
|
49 new (ELeave) CMCETestUIEngineOutEvent( aEngine, |
|
50 aProfile); |
|
51 CleanupStack::PushL( self ); |
|
52 self->ConstructL(); |
|
53 CleanupStack::Pop( self ); |
|
54 return self; |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CMCETestUIEngineOutEvent::CMCETestUIEngineOutEvent |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 CMCETestUIEngineOutEvent::CMCETestUIEngineOutEvent( |
|
62 CMCETestUIEngine& aEngine, |
|
63 CMCETestUIEngineProfile& aProfile ) |
|
64 : CMCETestUIEngineEvent( aEngine ), |
|
65 iProfile( &aProfile ), |
|
66 iId( 0 ) |
|
67 { |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CMCETestUIEngineOutEvent::ConstructL() |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 void CMCETestUIEngineOutEvent::ConstructL() |
|
75 { |
|
76 |
|
77 ///////////////////// |
|
78 // |
|
79 // TODO: After implementing wrappers for streams, sinks and sources |
|
80 // this function should be refactored to make use of them. That will |
|
81 // also simplify the function to some extent. |
|
82 // |
|
83 ////////////////////// |
|
84 |
|
85 |
|
86 BaseConstructL(); |
|
87 FillProfileRegistrar(); |
|
88 |
|
89 if(EventParamsL(iEventParams)) |
|
90 { |
|
91 // Solve recipient |
|
92 CMCETestUIQuestionDataQuery* question = |
|
93 CMCETestUIQuestionDataQuery::NewLC(); |
|
94 question->SetCaptionL( KUserQuestionInputRecipient ); |
|
95 question->SetDefaultValueL(iEventParams.iRecipentAddress ); |
|
96 question->SetAnswerL( iEventParams.iRecipentAddress ); |
|
97 TBufC8<100> recipient( question->Answer8() ); |
|
98 |
|
99 CleanupStack::PopAndDestroy( question ); |
|
100 //solve eventheader |
|
101 |
|
102 CMCETestUIQuestionDataQuery* questioneventheader = |
|
103 CMCETestUIQuestionDataQuery::NewLC(); |
|
104 questioneventheader->SetCaptionL( KUserQuestionInputEventHeader ); |
|
105 questioneventheader->SetDefaultValueL(iEventParams.iEventHeader ); |
|
106 questioneventheader->SetAnswerL( iEventParams.iEventHeader ); |
|
107 TBufC8<100> eventHeader( questioneventheader->Answer8() ); |
|
108 |
|
109 CleanupStack::PopAndDestroy( questioneventheader ); |
|
110 // solve originator |
|
111 |
|
112 if ( iEventParams.originator.Compare(KNone)) |
|
113 { |
|
114 HBufC8* orig8 = HBufC8::NewL(iEventParams.originator.Length()); |
|
115 TPtr8 ptr = orig8->Des(); |
|
116 ptr.Copy(iEventParams.originator); |
|
117 // Create OutEvent |
|
118 CMceOutEvent* outEvent = CMceOutEvent::NewL( |
|
119 iEngine.MCEManager(), |
|
120 iProfile->Profile(), |
|
121 recipient,eventHeader,iEventParams.refreshInterval,orig8 ); |
|
122 CleanupStack::PushL(outEvent); |
|
123 CleanupStack::Pop( outEvent ); |
|
124 iEvent = outEvent; |
|
125 iOutEvent = outEvent; |
|
126 } |
|
127 else |
|
128 { |
|
129 // Create OutEvent |
|
130 CMceOutEvent* outEvent = CMceOutEvent::NewL( |
|
131 iEngine.MCEManager(), |
|
132 iProfile->Profile(), |
|
133 recipient,eventHeader,iEventParams.refreshInterval ); |
|
134 CleanupStack::PushL(outEvent); |
|
135 CleanupStack::Pop( outEvent ); |
|
136 iEvent = outEvent; |
|
137 iOutEvent = outEvent; |
|
138 } |
|
139 // Get identity |
|
140 iId = iEngine.NextOutEventId(); |
|
141 } |
|
142 |
|
143 } |
|
144 // ----------------------------------------------------------------------------- |
|
145 // CMCETestUIEngineOutEvent::NewL() |
|
146 // ----------------------------------------------------------------------------- |
|
147 // |
|
148 CMCETestUIEngineOutEvent* CMCETestUIEngineOutEvent::NewL( |
|
149 CMCETestUIEngine& aEngine, |
|
150 CMceOutEvent* aOutEvent) |
|
151 { |
|
152 |
|
153 CMCETestUIEngineOutEvent* self = |
|
154 new (ELeave) CMCETestUIEngineOutEvent( aEngine, |
|
155 aOutEvent); |
|
156 CleanupStack::PushL( self ); |
|
157 self->ConstructL(aOutEvent); |
|
158 CleanupStack::Pop( self ); |
|
159 return self; |
|
160 } |
|
161 |
|
162 // ----------------------------------------------------------------------------- |
|
163 // CMCETestUIEngineOutEvent::CMCETestUIEngineOutEvent |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 CMCETestUIEngineOutEvent::CMCETestUIEngineOutEvent( |
|
167 CMCETestUIEngine& aEngine, |
|
168 CMceOutEvent* aOutEvent ) |
|
169 : CMCETestUIEngineEvent( aEngine ), |
|
170 iOutEvent( aOutEvent ), |
|
171 iId( 0 ) |
|
172 { |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // CMCETestUIEngineOutEvent::ConstructL() |
|
177 // ----------------------------------------------------------------------------- |
|
178 // |
|
179 void CMCETestUIEngineOutEvent::ConstructL(CMceOutEvent* /*aOutEvent*/) |
|
180 { |
|
181 |
|
182 ///////////////////// |
|
183 // |
|
184 // TODO: After implementing wrappers for streams, sinks and sources |
|
185 // this function should be refactored to make use of them. That will |
|
186 // also simplify the function to some extent. |
|
187 // |
|
188 ////////////////////// |
|
189 |
|
190 |
|
191 User::LeaveIfError( iOutEvent ? KErrNone : KErrArgument ); |
|
192 |
|
193 BaseConstructL(); |
|
194 iEvent = iOutEvent; |
|
195 |
|
196 // Get identity |
|
197 iId = iEngine.NextOutEventId(); |
|
198 |
|
199 } |
|
200 |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // CMCETestUIEngineOutEvent::~CMCETestUIEngineOutEvent |
|
204 // ----------------------------------------------------------------------------- |
|
205 // |
|
206 EXPORT_C CMCETestUIEngineOutEvent::~CMCETestUIEngineOutEvent() |
|
207 { |
|
208 delete iOutEvent; |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // CMCETestUIEngineOutEvent::GetCommands |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 const RPointerArray<TMCETestUIEngineCmdBase>& |
|
216 CMCETestUIEngineOutEvent::GetCommandsL() |
|
217 { |
|
218 iCommands.ResetAndDestroy(); |
|
219 |
|
220 // Get base class commands |
|
221 CMCETestUIEngineEvent::GetCommandsL(); |
|
222 |
|
223 // Get own commands |
|
224 TInt state = iOutEvent->State(); |
|
225 |
|
226 switch( state ) |
|
227 { |
|
228 case CMceEvent::EIdle: |
|
229 iCommands.Append( new (ELeave) TMCETestUIEngineCmdSubscribeEvent( |
|
230 iEngine, *this ) ); |
|
231 iCommands.Append( new (ELeave) |
|
232 TMCETestUIEngineCmdDeleteEvent( iEngine, *this ) ); |
|
233 break; |
|
234 case CMceEvent::EActive: |
|
235 iCommands.Append( new (ELeave) TMCETestUIEngineCmdUpdateEvent( |
|
236 iEngine, *this ) ); |
|
237 iCommands.Append( new (ELeave) |
|
238 TMCETestUIEngineCmdDeleteEvent( iEngine, *this ) ); |
|
239 break; |
|
240 case CMceEvent::EPending: |
|
241 iCommands.Append( new (ELeave) TMCETestUIEngineCmdSubscribeEvent( |
|
242 iEngine, *this ) ); |
|
243 iCommands.Append( new (ELeave) TMCETestUIEngineCmdUpdateEvent( |
|
244 iEngine, *this ) ); |
|
245 iCommands.Append( new (ELeave) |
|
246 TMCETestUIEngineCmdDeleteEvent( iEngine, *this ) ); |
|
247 break; |
|
248 default: |
|
249 break; |
|
250 } |
|
251 |
|
252 return iCommands; |
|
253 } |
|
254 |
|
255 // ----------------------------------------------------------------------------- |
|
256 // CMCETestUIEngineOutEvent::Id |
|
257 // ----------------------------------------------------------------------------- |
|
258 // |
|
259 EXPORT_C TInt CMCETestUIEngineOutEvent::Id() const |
|
260 { |
|
261 return iId; |
|
262 } |
|
263 |
|
264 // ----------------------------------------------------------------------------- |
|
265 // CMCETestUIEngineOutSession::OutSession |
|
266 // ----------------------------------------------------------------------------- |
|
267 // |
|
268 CMceOutEvent& CMCETestUIEngineOutEvent::OutEvent() |
|
269 { |
|
270 return *iOutEvent; |
|
271 } |
|
272 |
|
273 // ----------------------------------------------------------------------------- |
|
274 // CMCETestUIEngineOutEvent::EventParams |
|
275 // ----------------------------------------------------------------------------- |
|
276 // |
|
277 |
|
278 TBool CMCETestUIEngineOutEvent::EventParamsL(TEventParams &aEventParams) |
|
279 { |
|
280 return iEngine.EventParamsL( aEventParams); |
|
281 |
|
282 } |
|
283 |
|
284 // ----------------------------------------------------------------------------- |
|
285 // CMCETestUIEngineOutEvent::FillProfileRegistrar |
|
286 // ----------------------------------------------------------------------------- |
|
287 // |
|
288 |
|
289 void CMCETestUIEngineOutEvent::FillProfileRegistrar() |
|
290 { |
|
291 // trying to get profile registrar |
|
292 |
|
293 TUriParser8 parser; |
|
294 const TDesC8& aor = iProfile->Aor(); |
|
295 parser.Parse( aor ) ; |
|
296 CUri8* uri8 = CUri8::NewLC( parser ); |
|
297 const TDesC8& registrar = uri8->Uri().Extract( EUriHost ) ; |
|
298 |
|
299 HBufC*registrar16 = HBufC16::NewLC( KRecipent().Length() + registrar.Length() ); |
|
300 TPtr registrarPtr = registrar16->Des(); |
|
301 registrarPtr.Copy( registrar ); |
|
302 |
|
303 iEventParams.iRecipentAddress.Append(KRecipent) ; |
|
304 iEventParams.iRecipentAddress.Append(*registrar16) ; |
|
305 |
|
306 CleanupStack::PopAndDestroy( registrar16 ); |
|
307 registrar16 = NULL; |
|
308 |
|
309 CleanupStack::PopAndDestroy( uri8 ); |
|
310 uri8 = NULL; |
|
311 // profile registrar end ..... |
|
312 } |