|
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: Implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "MCEConstants.h" |
|
21 #include "TCmdGetEventState.h" |
|
22 #include "CTcMCEContext.h" |
|
23 #include <MCEEvent.h> |
|
24 |
|
25 |
|
26 void TCmdGetEventState::ExecuteL() |
|
27 { |
|
28 // ---------- Setup -------------------------------------------------------- |
|
29 |
|
30 |
|
31 // ---------- Execution ---------------------------------------------------- |
|
32 |
|
33 // Get an item off the receive queue (waits until timeout if none is present) |
|
34 |
|
35 TInt timeout = ExtractIntegerL( KParamTimeout, KDefaultReceiveTimeout, |
|
36 EFalse ); |
|
37 |
|
38 CTcMCEReceived& item = iContext.ReceivedEventItemL( timeout ); |
|
39 |
|
40 if ( !item.Event() ) |
|
41 { |
|
42 User::Leave(KErrNotFound); // If first item doesn't contain an event |
|
43 } |
|
44 |
|
45 CMceEvent* expectedEvent = reinterpret_cast<CMceEvent*> |
|
46 (GetObjectForIdL(KEventId, ETrue)); |
|
47 |
|
48 /*if( item.Event() != expectedEvent ) |
|
49 { |
|
50 // If the first item's containing event is not the expected |
|
51 User::Leave(KErrNotFound); |
|
52 }*/ |
|
53 |
|
54 CMceEvent::TState eventState = item.Event()->State(); |
|
55 |
|
56 // ---------- Response creation -------------------------------------------- |
|
57 |
|
58 |
|
59 // Add Event |
|
60 AddIdResponseL( KEventId, *(item.Event()) ); |
|
61 |
|
62 // Add state |
|
63 |
|
64 AddIntegerResponseL( KResponseEventState, eventState ); |
|
65 AddTextualEventStateL( eventState ); |
|
66 |
|
67 // Add StatusCode |
|
68 AddIntegerResponseL(KResponseStatusCode, item.StatusCode()); |
|
69 |
|
70 // Add ReasonPhrase |
|
71 if (item.ReasonPhrase()) |
|
72 { |
|
73 if (item.ReasonPhrase()->Length() > 0) |
|
74 { |
|
75 AddTextResponseL(KResponseReasonPhrase, *(item.ReasonPhrase())); |
|
76 } |
|
77 } |
|
78 |
|
79 // Add Headers |
|
80 AddHeadersL( item.Headers() ); |
|
81 |
|
82 // Add ContentType |
|
83 if (item.ContentType()) |
|
84 { |
|
85 if (item.ContentType()->Length() > 0) |
|
86 { |
|
87 AddTextResponseL(KResponseContentType, *(item.ContentType())); |
|
88 } |
|
89 |
|
90 } |
|
91 |
|
92 // Add Body |
|
93 if (item.Body()) |
|
94 { |
|
95 if (item.Body()->Length() > 0) |
|
96 { |
|
97 AddTextResponseL(KResponseBody, *(item.Body())); |
|
98 } |
|
99 } |
|
100 |
|
101 // Add Error |
|
102 if ( item.Error() != KErrNone ) |
|
103 { |
|
104 AddIntegerResponseL( KResponseError, item.Error() ); |
|
105 } |
|
106 } |
|
107 |
|
108 TBool TCmdGetEventState::Match( const TTcIdentifier& aId ) |
|
109 { |
|
110 return TTcMceCommandBase::Match( aId, _L8("GetEventState") ); |
|
111 } |
|
112 |
|
113 TTcCommandBase* TCmdGetEventState::CreateL( MTcTestContext& aContext ) |
|
114 { |
|
115 return new( ELeave ) TCmdGetEventState( aContext ); |
|
116 } |