|
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 "TCmdGetReferId.h" |
|
22 #include "CTcMCEContext.h" |
|
23 |
|
24 #include <MCERefer.h> |
|
25 #include <MceInRefer.h> |
|
26 |
|
27 void TCmdGetReferId::ExecuteL() |
|
28 { |
|
29 // ---------- Setup -------------------------------------------------------- |
|
30 |
|
31 |
|
32 // ---------- Execution ---------------------------------------------------- |
|
33 |
|
34 // Get an item off the receive queue (waits until timeout if none is present) |
|
35 |
|
36 TInt timeout = ExtractIntegerL( KParamTimeout, KDefaultReceiveTimeout, |
|
37 EFalse ); |
|
38 |
|
39 CTcMCEReceived& item = iContext.ReceivedEventItemL( timeout ); |
|
40 |
|
41 if ( !item.InRefer() ) |
|
42 { |
|
43 User::Leave(KErrNotFound); // If first item doesn't contain an refer |
|
44 } |
|
45 |
|
46 const CMceInRefer& inRefer( *item.InRefer() ); |
|
47 |
|
48 // ---------- Response creation -------------------------------------------- |
|
49 |
|
50 // Add the refer ID |
|
51 AddIdResponseL( KReferId, inRefer ); |
|
52 |
|
53 // Add the session ID of the related session if it exists |
|
54 if ( inRefer.AssociatedSession() ) |
|
55 { |
|
56 AddIdResponseL( KSessionId, *( inRefer.AssociatedSession() ) ); |
|
57 } |
|
58 |
|
59 // Add referTo |
|
60 AddTextResponseL( KResponseReferTo, inRefer.ReferTo() ); |
|
61 |
|
62 // Add Headers |
|
63 AddHeadersL( item.Headers() ); |
|
64 |
|
65 // Add ContentType |
|
66 if (item.ContentType()) |
|
67 { |
|
68 if (item.ContentType()->Length() > 0) |
|
69 { |
|
70 AddTextResponseL(KResponseContentType, *(item.ContentType())); |
|
71 } |
|
72 } |
|
73 |
|
74 // Add Body |
|
75 if (item.Body()) |
|
76 { |
|
77 if (item.Body()->Length() > 0) |
|
78 { |
|
79 AddTextResponseL(KResponseBody, *(item.Body())); |
|
80 } |
|
81 } |
|
82 |
|
83 // Add refer state |
|
84 AddIntegerResponseL( KResponseReferState, inRefer.State() ); |
|
85 AddTextualReferStateL( inRefer.State() ); |
|
86 } |
|
87 |
|
88 TBool TCmdGetReferId::Match( const TTcIdentifier& aId ) |
|
89 { |
|
90 return TTcMceCommandBase::Match( aId, _L8("GetReferId") ); |
|
91 } |
|
92 |
|
93 TTcCommandBase* TCmdGetReferId::CreateL( MTcTestContext& aContext ) |
|
94 { |
|
95 return new( ELeave ) TCmdGetReferId( aContext ); |
|
96 } |