|
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 "TCmdSendRejectSession.h" |
|
22 #include "CTcMCEContext.h" |
|
23 #include <MceInSession.h> |
|
24 |
|
25 |
|
26 void TCmdSendRejectSession::ExecuteL() |
|
27 { |
|
28 // ---------- Setup -------------------------------------------------------- |
|
29 |
|
30 // Get session |
|
31 CMceInSession* session = reinterpret_cast<CMceInSession*> |
|
32 (GetObjectForIdL(KSessionId, ETrue)); |
|
33 |
|
34 // ---------- Execution -------------------------------- |
|
35 |
|
36 // Get reasonphrase |
|
37 TPtrC8 reason = ExtractTextL(KParamReasonPhrase, EFalse); |
|
38 |
|
39 // Get statuscode |
|
40 TInt status = ExtractIntegerL(KParamStatusCode, 0, EFalse); |
|
41 |
|
42 // Get Headers |
|
43 CDesC8Array* headers = ExtractHeadersL( EFalse ); |
|
44 CleanupStack::PushL(headers); |
|
45 |
|
46 // Get ContentType |
|
47 HBufC8* contentType = HBufCParameterL(ExtractTextL(KParamContentType, |
|
48 EFalse)); |
|
49 CleanupStack::PushL(contentType); |
|
50 // Get Content |
|
51 HBufC8* body = HBufCParameterL(ExtractTextL(KParamBody, EFalse)); |
|
52 CleanupStack::PushL( body ); |
|
53 |
|
54 // Reject |
|
55 if( reason == KNullDesC8 && status == 0 && !headers && |
|
56 (body && body->Length()==0) && (contentType && contentType->Length()==0)) |
|
57 { |
|
58 CleanupStack::PopAndDestroy( body ); body = NULL; |
|
59 CleanupStack::PopAndDestroy( contentType ); contentType = NULL; |
|
60 CleanupStack::PopAndDestroy( headers ); headers = NULL; |
|
61 session->RejectL(); |
|
62 } |
|
63 else |
|
64 { |
|
65 session->RejectL( reason, status, headers, contentType, body ); |
|
66 CleanupStack::Pop( body ); |
|
67 CleanupStack::Pop( contentType ); |
|
68 CleanupStack::Pop(headers); |
|
69 |
|
70 } |
|
71 |
|
72 CMceSession::TState state = session->State(); |
|
73 |
|
74 // ---------- Response creation ----------------------- |
|
75 |
|
76 AddIdResponseL( KSessionId, *session ); |
|
77 |
|
78 // Add Session state |
|
79 AddIntegerResponseL( KResponseState, state ); |
|
80 AddTextualSessionStateL( state ); |
|
81 |
|
82 } |
|
83 |
|
84 TBool TCmdSendRejectSession::Match( const TTcIdentifier& aId ) |
|
85 { |
|
86 return TTcMceCommandBase::Match( aId, _L8("SendRejectSession") ); |
|
87 } |
|
88 |
|
89 TTcCommandBase* TCmdSendRejectSession::CreateL( MTcTestContext& aContext ) |
|
90 { |
|
91 return new( ELeave ) TCmdSendRejectSession( aContext ); |
|
92 } |