|
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 "TCmdCreateRefer.h" |
|
22 #include "CTcMCEContext.h" |
|
23 |
|
24 #include <MCEEvent.h> |
|
25 #include <MceOutRefer.h> |
|
26 #include <MCESession.h> |
|
27 #include <MceOutSession.h> |
|
28 |
|
29 |
|
30 void TCmdCreateRefer::ExecuteL() |
|
31 { |
|
32 // ---------- Setup -------------------------------------------------------- |
|
33 |
|
34 // Get profile |
|
35 CSIPProfile* profile = |
|
36 reinterpret_cast<CSIPProfile*>(GetObjectForIdL(KProfileObj, EFalse)); |
|
37 |
|
38 // Get session |
|
39 CMceSession* session = |
|
40 reinterpret_cast<CMceSession*>(GetObjectForIdL(KSessionId, EFalse)); |
|
41 |
|
42 // Get event |
|
43 CMceEvent* event = |
|
44 reinterpret_cast<CMceEvent*>(GetObjectForIdL(KEventId, EFalse)); |
|
45 |
|
46 // Get refer |
|
47 CMceRefer* refer = |
|
48 reinterpret_cast<CMceRefer*>(GetObjectForIdL(KReferId, EFalse)); |
|
49 |
|
50 // Get ReferTo |
|
51 TPtrC8 referTo = ExtractTextL(KParamReferTo, ETrue); |
|
52 //If suppressed=0 then it is NoSuppression, it will receive Notify by outEventRefer |
|
53 // outEventRefer returned by calling sendRefer |
|
54 TInt suppressed =0; |
|
55 CMceRefer::TType referType ; |
|
56 suppressed = ExtractIntegerL(KParamNotifyReceiver,0, EFalse); |
|
57 referType = CMceRefer::ENoSuppression; |
|
58 if ( suppressed==1) |
|
59 { |
|
60 referType = CMceRefer::ESuppressed; |
|
61 } |
|
62 if (suppressed==2) |
|
63 { |
|
64 referType = CMceRefer::EMultipleRefer; |
|
65 } |
|
66 |
|
67 // Get event, which is going to receive notifications. |
|
68 // If not present, notifications are suppressed |
|
69 //command out by Chuan, the following will be later removed due to API change |
|
70 /*CMceOutEvent* outEvent = NULL; |
|
71 TPtrC8 outEventName = ExtractTextL( KParamNotifyReceiverEventId, EFalse ); |
|
72 if ( outEventName != KNullDesC8 ) |
|
73 { |
|
74 outEvent = reinterpret_cast<CMceOutEvent*> |
|
75 (iContext.Registry().ObjectPtrL( outEventName )); |
|
76 } |
|
77 */ |
|
78 // ---------- Execution ---------------------------------------------------- |
|
79 |
|
80 CMceOutRefer* outRefer = NULL; |
|
81 |
|
82 if ( profile ) |
|
83 { |
|
84 TPtrC8 recipient = ExtractTextL( KParamRecipient, ETrue ); |
|
85 |
|
86 HBufC8* originator = HBufCParameterL(ExtractTextL( KParamOriginator, |
|
87 EFalse )); |
|
88 CleanupStack::PushL( originator ); |
|
89 |
|
90 outRefer = CMceOutRefer::NewL( iContext.MCEManager(), |
|
91 *profile, |
|
92 recipient, |
|
93 referTo, |
|
94 referType, |
|
95 originator ); |
|
96 |
|
97 CleanupStack::Pop( originator ); |
|
98 } |
|
99 else if ( session ) |
|
100 { |
|
101 outRefer = CMceOutRefer::NewL( *session, referTo, referType ); |
|
102 } |
|
103 else if ( event ) |
|
104 { |
|
105 outRefer = CMceOutRefer::NewL( *event, referTo, referType ); |
|
106 } |
|
107 else if ( refer ) |
|
108 { |
|
109 outRefer = CMceOutRefer::NewL( *refer, referTo, referType ); |
|
110 } |
|
111 else |
|
112 { |
|
113 User::Leave( KErrNotFound ); |
|
114 } |
|
115 |
|
116 // ---------- Response creation -------------------------------------------- |
|
117 |
|
118 |
|
119 AddIdResponseL( KReferId, outRefer ); |
|
120 |
|
121 // If outEvent exists, it is placed in object registry, so it can be added |
|
122 // as parameter. |
|
123 //Due to API's change, command out by Chuan and it might be removed later |
|
124 /*AddIntegerResponseL( KParamNotifyReceiverEventId, |
|
125 reinterpret_cast<TInt>(outEvent) );*/ |
|
126 |
|
127 } |
|
128 |
|
129 TBool TCmdCreateRefer::Match( const TTcIdentifier& aId ) |
|
130 { |
|
131 return TTcMceCommandBase::Match( aId, _L8("CreateRefer") ); |
|
132 } |
|
133 |
|
134 TTcCommandBase* TCmdCreateRefer::CreateL( MTcTestContext& aContext ) |
|
135 { |
|
136 return new( ELeave ) TCmdCreateRefer( aContext ); |
|
137 } |