|
1 /* |
|
2 * Copyright (c) 2005-2009 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 #include "t_rmobileconferencecalldata.h" |
|
19 #include <e32property.h> |
|
20 |
|
21 |
|
22 _LIT( KNumOfCalls, "NumOfCalls" ); |
|
23 |
|
24 _LIT(KMobilePhoneKey, "RMobilePhone"); |
|
25 |
|
26 _LIT(KCmdClose, "Close"); |
|
27 _LIT(KCmdCreateConference, "CreateConference"); |
|
28 _LIT(KCmdEnumerateCalls, "EnumerateCalls"); |
|
29 _LIT(KCmdOpen, "Open"); |
|
30 |
|
31 /** |
|
32 * Two phase constructor |
|
33 * |
|
34 * @leave system wide error |
|
35 */ |
|
36 CT_RMobileConferenceCallData* CT_RMobileConferenceCallData::NewL() |
|
37 { |
|
38 CT_RMobileConferenceCallData* ret=new (ELeave) CT_RMobileConferenceCallData(); |
|
39 CleanupStack::PushL(ret); |
|
40 ret->ConstructL(); |
|
41 CleanupStack::Pop(ret); |
|
42 return ret; |
|
43 } |
|
44 |
|
45 |
|
46 /** |
|
47 * Protected constructor. First phase construction |
|
48 */ |
|
49 CT_RMobileConferenceCallData::CT_RMobileConferenceCallData() |
|
50 : iActiveCallback(NULL), |
|
51 iMobileConferenceCall(NULL) |
|
52 { |
|
53 } |
|
54 |
|
55 void CT_RMobileConferenceCallData::ConstructL() |
|
56 { |
|
57 iMobileConferenceCall = new (ELeave) RMobileConferenceCall(); |
|
58 iActiveCallback = CActiveCallback::NewL(*this); |
|
59 } |
|
60 |
|
61 /** |
|
62 * Public destructor |
|
63 */ |
|
64 CT_RMobileConferenceCallData::~CT_RMobileConferenceCallData() |
|
65 { |
|
66 delete iMobileConferenceCall; |
|
67 iMobileConferenceCall = NULL; |
|
68 delete iActiveCallback; |
|
69 iActiveCallback=NULL; |
|
70 } |
|
71 |
|
72 TAny* CT_RMobileConferenceCallData::GetObject() |
|
73 { |
|
74 return iMobileConferenceCall; |
|
75 } |
|
76 |
|
77 void CT_RMobileConferenceCallData::RunL(CActive* aActive, TInt aIndex) |
|
78 { |
|
79 DecOutstanding(); // One of the async calls has completed |
|
80 TInt err = aActive->iStatus.Int(); |
|
81 if( err != KErrNone ) |
|
82 { |
|
83 ERR_PRINTF2(_L("RunL Error %d"), err); |
|
84 SetAsyncError( aIndex, err ); |
|
85 } |
|
86 else |
|
87 { |
|
88 INFO_PRINTF1(_L("RunL completed successfully")); |
|
89 } |
|
90 } |
|
91 |
|
92 TBool CT_RMobileConferenceCallData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex) |
|
93 { |
|
94 TBool ret = ETrue; |
|
95 |
|
96 if ( aCommand==KCmdClose ) |
|
97 { |
|
98 DoCmdClose(); |
|
99 } |
|
100 else if ( aCommand==KCmdCreateConference) |
|
101 { |
|
102 DoCmdCreateConference(aAsyncErrorIndex); |
|
103 } |
|
104 else if ( aCommand==KCmdEnumerateCalls) |
|
105 { |
|
106 DoCmdEnumerateCalls(aSection); |
|
107 } |
|
108 else if ( aCommand==KCmdOpen) |
|
109 { |
|
110 DoCmdOpen(aSection); |
|
111 } |
|
112 else |
|
113 { |
|
114 ERR_PRINTF1(_L("Unknown command")); |
|
115 ret = EFalse; |
|
116 } |
|
117 |
|
118 return ret; |
|
119 } |
|
120 |
|
121 |
|
122 |
|
123 void CT_RMobileConferenceCallData::DoCmdClose() |
|
124 { |
|
125 INFO_PRINTF1(_L("*START*CT_VoiceCallDriverData::DoCmdCloseConferenceCall")); |
|
126 |
|
127 iMobileConferenceCall->Close(); |
|
128 |
|
129 INFO_PRINTF1(_L("*END*CT_VoiceCallDriverData::DoCmdCloseConferenceCall")); |
|
130 } |
|
131 |
|
132 |
|
133 void CT_RMobileConferenceCallData::DoCmdCreateConference(const TInt aAsyncErrorIndex) |
|
134 { |
|
135 INFO_PRINTF1(_L("*START*CT_VoiceCallDriverData::DoCmdCreateConferenceCall")); |
|
136 |
|
137 iMobileConferenceCall->CreateConference(iActiveCallback->iStatus); |
|
138 iActiveCallback->Activate(aAsyncErrorIndex); |
|
139 IncOutstanding(); |
|
140 |
|
141 INFO_PRINTF1(_L("*END*CT_VoiceCallDriverData::DoCmdCreateConferenceCall")); |
|
142 } |
|
143 |
|
144 |
|
145 void CT_RMobileConferenceCallData::DoCmdEnumerateCalls(const TTEFFunction& aSection) |
|
146 { |
|
147 INFO_PRINTF1(_L("*START*CT_VoiceCallDriverData::DoCmdEnumerateCallsOnConference")); |
|
148 |
|
149 TInt expectedCalls; |
|
150 TInt error(0); |
|
151 if( !GetIntFromConfig(aSection, KNumOfCalls, expectedCalls) ) |
|
152 { |
|
153 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KNumOfCalls); |
|
154 SetBlockResult(EFail); |
|
155 } |
|
156 else |
|
157 { |
|
158 INFO_PRINTF2(_L("Expecting conference call to contain [%d] calls"), expectedCalls); |
|
159 TInt calls(0); |
|
160 error = iMobileConferenceCall->EnumerateCalls(calls); |
|
161 if(error != KErrNone) |
|
162 { |
|
163 ERR_PRINTF2(_L("Failed to enumerate calls with error %d"), error); |
|
164 SetError(error); |
|
165 } |
|
166 else |
|
167 { |
|
168 INFO_PRINTF2(_L("Conference contained [%d] calls"), calls); |
|
169 if (expectedCalls != calls) |
|
170 { |
|
171 ERR_PRINTF3(_L("Obtained number of calls %d is different from expected number of calls %d"), calls, expectedCalls); |
|
172 SetBlockResult(EFail); |
|
173 } |
|
174 else |
|
175 { |
|
176 INFO_PRINTF1(_L("DoCmdEnumerateCallsOnConference succeeded")); |
|
177 } |
|
178 } |
|
179 } |
|
180 INFO_PRINTF1(_L("*END*CT_VoiceCallDriverData::DoCmdEnumerateCallsOnConference")); |
|
181 } |
|
182 |
|
183 void CT_RMobileConferenceCallData::DoCmdOpen(const TTEFFunction& aSection) |
|
184 { |
|
185 INFO_PRINTF1(_L("*START*CT_VoiceCallDriverData::DoCmdOpenConferenceCall")); |
|
186 |
|
187 TPtrC mobilePhoneName; |
|
188 TInt error(0); |
|
189 if( !GetStringFromConfig(aSection, KMobilePhoneKey, mobilePhoneName)) |
|
190 { |
|
191 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KMobilePhoneKey); |
|
192 SetBlockResult(EFail); |
|
193 } |
|
194 else |
|
195 { |
|
196 RMobilePhone* MobilePhoneObject = static_cast<RMobilePhone*>(GetDataObjectL(mobilePhoneName)); |
|
197 error = iMobileConferenceCall->Open(*MobilePhoneObject); |
|
198 if (error != KErrNone) |
|
199 { |
|
200 ERR_PRINTF2(_L("Conference call open failed [%d]"), error); |
|
201 SetError(error); |
|
202 } |
|
203 else |
|
204 { |
|
205 INFO_PRINTF1(_L("DoCmdOpenConferenceCall succeeded")); |
|
206 } |
|
207 } |
|
208 INFO_PRINTF1(_L("*END*CT_VoiceCallDriverData::DoCmdOpenConferenceCall")); |
|
209 } |
|
210 |
|
211 |