24
|
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 |
|
|
19 |
#include <cdbcols.h>
|
|
20 |
#include <e32base.h>
|
|
21 |
#include <e32def.h>
|
|
22 |
|
|
23 |
// User Includes
|
|
24 |
#include "T_RMobileLineData.h"
|
|
25 |
|
|
26 |
_LIT( KLineName, "Line" );
|
|
27 |
_LIT( KCallName, "Call");
|
|
28 |
_LIT( KDefaultSection, "Default" );
|
|
29 |
_LIT( KMaxPhoneCalls, "MaxPhoneCalls");
|
|
30 |
|
|
31 |
_LIT(KMobilePhoneKey, "RMobilePhone");
|
|
32 |
|
|
33 |
/*@{*/
|
|
34 |
//LIT's for commands
|
|
35 |
_LIT(KCmdOpen, "Open");
|
|
36 |
_LIT(KCmdClose, "Close");
|
|
37 |
_LIT(KCmdNotifyIncomingCall, "NotifyIncomingCall");
|
|
38 |
/*}@*/
|
|
39 |
|
|
40 |
/**
|
|
41 |
* Two phase constructor
|
|
42 |
*
|
|
43 |
* @leave system wide error
|
|
44 |
*/
|
|
45 |
CT_RMobileLineData* CT_RMobileLineData::NewL()
|
|
46 |
{
|
|
47 |
CT_RMobileLineData* ret=new (ELeave) CT_RMobileLineData();
|
|
48 |
CleanupStack::PushL(ret);
|
|
49 |
ret->ConstructL();
|
|
50 |
CleanupStack::Pop(ret);
|
|
51 |
return ret;
|
|
52 |
}
|
|
53 |
|
|
54 |
|
|
55 |
/**
|
|
56 |
* Protected constructor. First phase construction
|
|
57 |
*/
|
|
58 |
CT_RMobileLineData::CT_RMobileLineData()
|
|
59 |
: iActiveCallback(NULL),
|
|
60 |
iMobileLine(NULL)
|
|
61 |
{
|
|
62 |
}
|
|
63 |
|
|
64 |
/**
|
|
65 |
* Second phase construction
|
|
66 |
*
|
|
67 |
* @internalComponent
|
|
68 |
*
|
|
69 |
* @return N/A
|
|
70 |
*
|
|
71 |
* @pre None
|
|
72 |
* @post None
|
|
73 |
*
|
|
74 |
* @leave system wide error
|
|
75 |
*/
|
|
76 |
void CT_RMobileLineData::ConstructL()
|
|
77 |
{
|
|
78 |
iMobileLine = new (ELeave) RMobileLine();
|
|
79 |
iActiveCallback = CActiveCallback::NewL(*this);
|
|
80 |
}
|
|
81 |
|
|
82 |
/**
|
|
83 |
* Third phase construction
|
|
84 |
*
|
|
85 |
* @internalComponent
|
|
86 |
*
|
|
87 |
* @return N/A
|
|
88 |
*
|
|
89 |
* @pre None
|
|
90 |
* @post None
|
|
91 |
*
|
|
92 |
* @leave system wide error
|
|
93 |
*/
|
|
94 |
|
|
95 |
void CT_RMobileLineData::InitialiseL()
|
|
96 |
{
|
|
97 |
CDataWrapperBase::InitialiseL();
|
|
98 |
GetIntFromConfig(KDefaultSection, KMaxPhoneCalls, iMaxPhoneCalls );
|
|
99 |
|
|
100 |
TName* callName = NULL;
|
|
101 |
for (TInt i = 0; i < iMaxPhoneCalls; ++i)
|
|
102 |
{
|
|
103 |
// Call names
|
|
104 |
callName = new (ELeave) TName();
|
|
105 |
CleanupStack::PushL(callName);
|
|
106 |
iCallNames.Append(*callName);
|
|
107 |
CleanupStack::Pop(callName);
|
|
108 |
}
|
|
109 |
}
|
|
110 |
/**
|
|
111 |
* Public destructor
|
|
112 |
*/
|
|
113 |
CT_RMobileLineData::~CT_RMobileLineData()
|
|
114 |
{
|
|
115 |
if(iMobileLine)
|
|
116 |
{
|
|
117 |
delete iMobileLine;
|
|
118 |
iMobileLine = NULL;
|
|
119 |
}
|
|
120 |
|
|
121 |
if(iActiveCallback)
|
|
122 |
{
|
|
123 |
delete iActiveCallback;
|
|
124 |
iActiveCallback=NULL;
|
|
125 |
}
|
|
126 |
// Empty arrays and also delete objects whose pointers are contained within
|
|
127 |
iCallNames.Reset();
|
|
128 |
}
|
|
129 |
|
|
130 |
/**
|
|
131 |
* Return a pointer to the object that the data wraps
|
|
132 |
*
|
|
133 |
* @return pointer to the object that the data wraps
|
|
134 |
*/
|
|
135 |
TAny* CT_RMobileLineData::GetObject()
|
|
136 |
{
|
|
137 |
return iMobileLine;
|
|
138 |
}
|
|
139 |
|
|
140 |
void CT_RMobileLineData::RunL(CActive* aActive, TInt aIndex)
|
|
141 |
{
|
|
142 |
DecOutstanding(); // One of the async calls has completed
|
|
143 |
TInt err = aActive->iStatus.Int();
|
|
144 |
if( err != KErrNone )
|
|
145 |
{
|
|
146 |
ERR_PRINTF2(_L("RunL Error %d"), err);
|
|
147 |
SetAsyncError( aIndex, err );
|
|
148 |
}
|
|
149 |
else
|
|
150 |
{
|
|
151 |
INFO_PRINTF1(_L("RunL completed successfully"));
|
|
152 |
}
|
|
153 |
}
|
|
154 |
|
|
155 |
TBool CT_RMobileLineData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
|
|
156 |
{
|
|
157 |
TBool ret = ETrue;
|
|
158 |
|
|
159 |
if ( aCommand==KCmdOpen )
|
|
160 |
{
|
|
161 |
DoCmdOpen(aSection);
|
|
162 |
}
|
|
163 |
else if ( aCommand==KCmdClose )
|
|
164 |
{
|
|
165 |
DoCmdClose();
|
|
166 |
}
|
|
167 |
else if ( aCommand==KCmdNotifyIncomingCall)
|
|
168 |
{
|
|
169 |
DoCmdNotifyIncomingCall(aSection, aAsyncErrorIndex);
|
|
170 |
}
|
|
171 |
else
|
|
172 |
{
|
|
173 |
ERR_PRINTF1(_L("Unknown command"));
|
|
174 |
ret = EFalse;
|
|
175 |
}
|
|
176 |
return ret;
|
|
177 |
}
|
|
178 |
|
|
179 |
void CT_RMobileLineData::DoCmdOpen(const TDesC& aSection)
|
|
180 |
{
|
|
181 |
INFO_PRINTF1(_L("*START*CT_RMobileLineData::OpenLine"));
|
|
182 |
TBool dataOk = ETrue;
|
|
183 |
TPtrC resultLineName;
|
|
184 |
if( !GetStringFromConfig(aSection, KLineName, resultLineName) )
|
|
185 |
{
|
|
186 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KLineName);
|
|
187 |
SetBlockResult(EFail);
|
|
188 |
dataOk = EFalse;
|
|
189 |
}
|
|
190 |
TPtrC mobilePhoneName;
|
|
191 |
if( !GetStringFromConfig(aSection, KMobilePhoneKey, mobilePhoneName) )
|
|
192 |
{
|
|
193 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KMobilePhoneKey);
|
|
194 |
SetBlockResult(EFail);
|
|
195 |
dataOk = EFalse;
|
|
196 |
}
|
|
197 |
if(dataOk)
|
|
198 |
{
|
|
199 |
RMobilePhone* mobilePhoneObject = static_cast<RMobilePhone*>(GetDataObjectL(mobilePhoneName));
|
|
200 |
INFO_PRINTF1(_L("Opening Line"));
|
|
201 |
TRAPD (error, iMobileLine->Open(*mobilePhoneObject, resultLineName) );
|
|
202 |
if(error != KErrNone)
|
|
203 |
{
|
|
204 |
ERR_PRINTF2(_L("Failed to open Line with error %d"), error);
|
|
205 |
SetError(error);
|
|
206 |
}
|
|
207 |
else
|
|
208 |
{
|
|
209 |
INFO_PRINTF1(_L("OpenLine succeeded"));
|
|
210 |
}
|
|
211 |
}
|
|
212 |
INFO_PRINTF1(_L("*END*CT_RMobileLineData::OpenLine"));
|
|
213 |
}
|
|
214 |
|
|
215 |
void CT_RMobileLineData::DoCmdClose()
|
|
216 |
{
|
|
217 |
INFO_PRINTF1(_L("*START*CT_RMobileLineData::CloseLine"));
|
|
218 |
iMobileLine->Close();
|
|
219 |
INFO_PRINTF1(_L("CloseLine succeeded"));
|
|
220 |
INFO_PRINTF1(_L("*END*CT_RMobileLineData::CloseLine"));
|
|
221 |
}
|
|
222 |
|
|
223 |
void CT_RMobileLineData::DoCmdNotifyIncomingCall(const TDesC& aSection, const TInt aAsyncErrorIndex)
|
|
224 |
{
|
|
225 |
INFO_PRINTF1(_L("*START*CT_VoiceCallDriverData::DoCmdNotifyIncomingCall"));
|
|
226 |
|
|
227 |
TInt callNameParameter;
|
|
228 |
if( !GetIntFromConfig(aSection, KCallName, callNameParameter ) )
|
|
229 |
{
|
|
230 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName);
|
|
231 |
SetBlockResult(EFail);
|
|
232 |
}
|
|
233 |
else
|
|
234 |
{
|
|
235 |
TName* CallName = NULL;
|
|
236 |
TRAPD(error, CallName = GetCallNameL(callNameParameter));
|
|
237 |
if(error != KErrNone)
|
|
238 |
{
|
|
239 |
ERR_PRINTF2(_L("Left while getting call name with error %d"), error);
|
|
240 |
SetError(error);
|
|
241 |
}
|
|
242 |
else
|
|
243 |
{
|
|
244 |
INFO_PRINTF1(_L("Start NotifyIncomingCall Asynchronous call."));
|
|
245 |
iMobileLine->NotifyIncomingCall(iActiveCallback->iStatus, *CallName);
|
|
246 |
iActiveCallback->Activate(aAsyncErrorIndex);
|
|
247 |
IncOutstanding();
|
|
248 |
}
|
|
249 |
}
|
|
250 |
INFO_PRINTF1(_L("*END*CT_VoiceCallDriverData::DoCmdNotifyIncomingCall"));
|
|
251 |
}
|
|
252 |
|
|
253 |
TName* CT_RMobileLineData::GetCallNameL(TInt aCall)
|
|
254 |
{
|
|
255 |
INFO_PRINTF1(_L("*START*CT_VoiceCallDriverData::GetCallNameL"));
|
|
256 |
|
|
257 |
INFO_PRINTF2(_L("Get TName: %d name"), aCall);
|
|
258 |
|
|
259 |
// Check that over/under flow does not occur
|
|
260 |
if (aCall < 0 || aCall >= iCallNames.Count())
|
|
261 |
{
|
|
262 |
ERR_PRINTF2(_L("There is no such name as (%d)"), aCall);
|
|
263 |
User::Leave(KErrArgument);
|
|
264 |
}
|
|
265 |
|
|
266 |
INFO_PRINTF1(_L("*END*CT_VoiceCallDriverData::GetCallNameL"));
|
|
267 |
return &iCallNames[aCall];
|
|
268 |
}
|
|
269 |
|