24
|
1 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
#include "cphonebookendispatcher.h"
|
|
17 |
|
|
18 |
#include <ctsy/ltsy/mltsydispatchphonebookeninterface.h>
|
|
19 |
#include <ctsy/pluginapi/mmmessagemanagercallback.h>
|
|
20 |
#include <ctsy/serviceapi/mmtsy_ipcdefs.h>
|
|
21 |
|
|
22 |
|
|
23 |
#include <ctsy/ltsy/ltsylogger.h>
|
|
24 |
#include "ctsydispatcherpanic.h"
|
|
25 |
#include "tdispatcherholder.h"
|
|
26 |
|
|
27 |
CPhonebookEnDispatcher::CPhonebookEnDispatcher(
|
|
28 |
MLtsyDispatchFactoryV1& aLtsyFactory,
|
|
29 |
MmMessageManagerCallback& aMessageManagerCallback,
|
|
30 |
CRequestQueueOneShot& aRequestAsyncOneShot)
|
|
31 |
: iLtsyFactoryV1(aLtsyFactory),
|
|
32 |
iMessageManagerCallback(aMessageManagerCallback),
|
|
33 |
iRequestAsyncOneShot(aRequestAsyncOneShot)
|
|
34 |
{
|
|
35 |
} // CPhonebookEnDispatcher::CPhonebookEnDispatcher
|
|
36 |
|
|
37 |
|
|
38 |
CPhonebookEnDispatcher::~CPhonebookEnDispatcher()
|
|
39 |
{
|
|
40 |
if (iEnEntriesArray)
|
|
41 |
{
|
|
42 |
iEnEntriesArray->ResetAndDestroy();
|
|
43 |
}
|
|
44 |
delete iEnEntriesArray;
|
|
45 |
} // CPhonebookEnDispatcher::~CPhonebookEnDispatcher
|
|
46 |
|
|
47 |
|
|
48 |
CPhonebookEnDispatcher* CPhonebookEnDispatcher::NewLC(
|
|
49 |
MLtsyDispatchFactoryV1& aLtsyFactory,
|
|
50 |
MmMessageManagerCallback& aMessageManagerCallback,
|
|
51 |
CRequestQueueOneShot& aRequestAsyncOneShot)
|
|
52 |
{
|
|
53 |
TSYLOGENTRYEXIT;
|
|
54 |
CPhonebookEnDispatcher* self =
|
|
55 |
new (ELeave) CPhonebookEnDispatcher(aLtsyFactory, aMessageManagerCallback, aRequestAsyncOneShot);
|
|
56 |
CleanupStack::PushL(self);
|
|
57 |
self->ConstructL();
|
|
58 |
return self;
|
|
59 |
} // CPhonebookEnDispatcher::NewLC
|
|
60 |
|
|
61 |
|
|
62 |
CPhonebookEnDispatcher* CPhonebookEnDispatcher::NewL(
|
|
63 |
MLtsyDispatchFactoryV1& aLtsyFactory,
|
|
64 |
MmMessageManagerCallback& aMessageManagerCallback,
|
|
65 |
CRequestQueueOneShot& aRequestAsyncOneShot)
|
|
66 |
{
|
|
67 |
TSYLOGENTRYEXIT;
|
|
68 |
CPhonebookEnDispatcher* self =
|
|
69 |
CPhonebookEnDispatcher::NewLC(aLtsyFactory, aMessageManagerCallback, aRequestAsyncOneShot);
|
|
70 |
CleanupStack::Pop (self);
|
|
71 |
return self;
|
|
72 |
} // CPhonebookEnDispatcher::NewL
|
|
73 |
|
|
74 |
|
|
75 |
void CPhonebookEnDispatcher::ConstructL()
|
|
76 |
/**
|
|
77 |
* Second phase constructor.
|
|
78 |
*/
|
|
79 |
{
|
|
80 |
TSYLOGENTRYEXIT;
|
|
81 |
|
|
82 |
// Get the Licensee LTSY interfaces related to PhonebookEn functionality
|
|
83 |
// from the factory
|
|
84 |
|
|
85 |
iEnEntriesArray = new (ELeave) CArrayPtrFlat<TENStoreResponse> (1);
|
|
86 |
|
|
87 |
if(iLtsyFactoryV1.IsDispatchInterfaceSupported(KDispatchPhonebookEnFuncUnitId, MLtsyDispatchPhonebookEnStoreGetInfo::KLtsyDispatchPhonebookEnStoreGetInfoApiId))
|
|
88 |
{
|
|
89 |
TAny* storeGetInfoInterface = NULL;
|
|
90 |
iLtsyFactoryV1.GetDispatchHandler(
|
|
91 |
MLtsyDispatchPhonebookEnStoreGetInfo::KLtsyDispatchPhonebookEnStoreGetInfoApiId,
|
|
92 |
storeGetInfoInterface);
|
|
93 |
iLtsyDispatchPhonebookEnStoreGetInfo =
|
|
94 |
static_cast<MLtsyDispatchPhonebookEnStoreGetInfo*>(storeGetInfoInterface);
|
|
95 |
__ASSERT_DEBUG(iLtsyDispatchPhonebookEnStoreGetInfo, CtsyDispatcherPanic(EInvalidNullPtr));
|
|
96 |
}
|
|
97 |
|
|
98 |
if(iLtsyFactoryV1.IsDispatchInterfaceSupported(KDispatchPhonebookEnFuncUnitId, MLtsyDispatchPhonebookEnStoreReadAll::KLtsyDispatchPhonebookEnStoreReadAllApiId))
|
|
99 |
{
|
|
100 |
TAny* storeReadAllInterface = NULL;
|
|
101 |
iLtsyFactoryV1.GetDispatchHandler(
|
|
102 |
MLtsyDispatchPhonebookEnStoreReadAll::KLtsyDispatchPhonebookEnStoreReadAllApiId,
|
|
103 |
storeReadAllInterface);
|
|
104 |
iLtsyDispatchPhonebookEnStoreReadAll =
|
|
105 |
static_cast<MLtsyDispatchPhonebookEnStoreReadAll*>(storeReadAllInterface);
|
|
106 |
__ASSERT_DEBUG(iLtsyDispatchPhonebookEnStoreReadAll, CtsyDispatcherPanic(EInvalidNullPtr));
|
|
107 |
}
|
|
108 |
|
|
109 |
if(iLtsyFactoryV1.IsDispatchInterfaceSupported(KDispatchPhonebookEnFuncUnitId, MLtsyDispatchPhonebookEnStoreReadEntry::KLtsyDispatchPhonebookEnStoreReadEntryApiId))
|
|
110 |
{
|
|
111 |
TAny* storeReadEntryInterface = NULL;
|
|
112 |
iLtsyFactoryV1.GetDispatchHandler(
|
|
113 |
MLtsyDispatchPhonebookEnStoreReadEntry::KLtsyDispatchPhonebookEnStoreReadEntryApiId,
|
|
114 |
storeReadEntryInterface);
|
|
115 |
iLtsyDispatchPhonebookEnStoreReadEntry =
|
|
116 |
static_cast<MLtsyDispatchPhonebookEnStoreReadEntry*>(storeReadEntryInterface);
|
|
117 |
__ASSERT_DEBUG(iLtsyDispatchPhonebookEnStoreReadEntry, CtsyDispatcherPanic(EInvalidNullPtr));
|
|
118 |
}
|
|
119 |
|
|
120 |
} // CPhonebookEnDispatcher::ConstructL
|
|
121 |
|
|
122 |
void CPhonebookEnDispatcher::SetDispatcherHolder(TDispatcherHolder& aDispatcherHolder)
|
|
123 |
/**
|
|
124 |
* Set the dispatcher holder.
|
|
125 |
*
|
|
126 |
* @param aDispatcherHolder Reference to dispatcher holder.
|
|
127 |
*/
|
|
128 |
{
|
|
129 |
TSYLOGENTRYEXIT;
|
|
130 |
|
|
131 |
iDispatcherHolder = &aDispatcherHolder;
|
|
132 |
} // CPhonebookEnDispatcher::SetDispatcherHolder
|
|
133 |
|
|
134 |
|
|
135 |
void CPhonebookEnDispatcher::FillEnStoreResponseListL(TInt aIndex, const TDesC& aNumber)
|
|
136 |
/*
|
|
137 |
* Append a TENStoreResponse entry to the iEnEntriesArray.
|
|
138 |
*
|
|
139 |
* @param aIndex The index of the entry.
|
|
140 |
* @param aNumber The number of the entry.
|
|
141 |
*
|
|
142 |
*/
|
|
143 |
{
|
|
144 |
TENStoreResponse* tempENStoreResponse = new (ELeave) TENStoreResponse();
|
|
145 |
CleanupStack::PushL(tempENStoreResponse);
|
|
146 |
|
|
147 |
tempENStoreResponse->iECCNumber.Copy(aNumber);
|
|
148 |
tempENStoreResponse->iLocation = aIndex;
|
|
149 |
iEnEntriesArray->AppendL(tempENStoreResponse); //iEnEntriesArray has taken the ownership of the object
|
|
150 |
|
|
151 |
CleanupStack::Pop(tempENStoreResponse);
|
|
152 |
}
|
|
153 |
|
|
154 |
TInt CPhonebookEnDispatcher::DispatchStoreGetInfoL()
|
|
155 |
/**
|
|
156 |
* Pass request on to Licensee LTSY.
|
|
157 |
*
|
|
158 |
* @return Returns error code returned by the Licensee LTSY or KErrNotSupported if
|
|
159 |
* the Licensee LTSY does not support this request.
|
|
160 |
*/
|
|
161 |
{
|
|
162 |
TSYLOGENTRYEXIT;
|
|
163 |
TInt ret = KErrNotSupported;
|
|
164 |
|
|
165 |
// Call Handle... method in Licensee LTSY
|
|
166 |
if (iLtsyDispatchPhonebookEnStoreGetInfo)
|
|
167 |
{
|
|
168 |
ret = iLtsyDispatchPhonebookEnStoreGetInfo->HandleStoreGetInfoReqL();
|
|
169 |
}
|
|
170 |
|
|
171 |
return TSYLOGSETEXITERR(ret);
|
|
172 |
} // CPhonebookEnDispatcher::DispatchStoreGetInfoL
|
|
173 |
|
|
174 |
TInt CPhonebookEnDispatcher::DispatchStoreReadAllL()
|
|
175 |
/**
|
|
176 |
* Unpack data related to EMmTsyENStoreReadAllPhase1IPC
|
|
177 |
* and pass request on to Licensee LTSY.
|
|
178 |
*
|
|
179 |
* @return Returns error code returned by the Licensee LTSY or KErrNotSupported if
|
|
180 |
* the Licensee LTSY does not support this request.
|
|
181 |
*/
|
|
182 |
{
|
|
183 |
TSYLOGENTRYEXIT;
|
|
184 |
TInt ret = KErrNotSupported;
|
|
185 |
|
|
186 |
if (iLtsyDispatchPhonebookEnStoreReadAll)
|
|
187 |
{
|
|
188 |
ret = iLtsyDispatchPhonebookEnStoreReadAll->HandleStoreReadAllReqL();
|
|
189 |
}
|
|
190 |
|
|
191 |
return TSYLOGSETEXITERR(ret);
|
|
192 |
} // CPhonebookEnDispatcher::DispatchStoreReadAllL
|
|
193 |
|
|
194 |
TInt CPhonebookEnDispatcher::DispatchStoreReadEntryL(const CMmDataPackage* aDataPackage)
|
|
195 |
/**
|
|
196 |
* Unpack data related to EMmTsyENStoreReadIPC
|
|
197 |
* and pass request on to Licensee LTSY.
|
|
198 |
*
|
|
199 |
* @return Returns error code returned by the Licensee LTSY or KErrNotSupported if
|
|
200 |
* the Licensee LTSY does not support this request.
|
|
201 |
*/
|
|
202 |
{
|
|
203 |
TSYLOGENTRYEXIT;
|
|
204 |
TInt ret = KErrNotSupported;
|
|
205 |
|
|
206 |
__ASSERT_DEBUG(aDataPackage, CtsyDispatcherPanic(EInvalidNullPtr));
|
|
207 |
|
|
208 |
// Call Handle... method in Licensee LTSY
|
|
209 |
TInt index = 0;
|
|
210 |
aDataPackage->UnPackData(index);
|
|
211 |
|
|
212 |
if (iLtsyDispatchPhonebookEnStoreReadEntry)
|
|
213 |
{
|
|
214 |
ret = iLtsyDispatchPhonebookEnStoreReadEntry->HandleStoreReadEntryReqL(index);
|
|
215 |
}
|
|
216 |
|
|
217 |
return TSYLOGSETEXITERR(ret);
|
|
218 |
} // CPhonebookEnDispatcher::DispatchStoreReadEntryL
|
|
219 |
|
|
220 |
|
|
221 |
//
|
|
222 |
// Callback handlers follow
|
|
223 |
//
|
|
224 |
|
|
225 |
|
|
226 |
|
|
227 |
void CPhonebookEnDispatcher::CallbackStoreGetInfo(TInt aError, TInt aUsedEntries)
|
|
228 |
/**
|
|
229 |
* Callback function to be used by the request to complete CCtsyDispatcherCallback::CallbackPhonebookEnStoreGetInfoComp()
|
|
230 |
*
|
|
231 |
* @param aError The error code to be returned to the CTSY Dispatcher.
|
|
232 |
* @param aUsedEntries The number of used entries in the EN storage.
|
|
233 |
*
|
|
234 |
* @see RMobileENStore::GetInfo()
|
|
235 |
*/
|
|
236 |
{
|
|
237 |
TSYLOGENTRYEXITARGS(_L8("aError=%d, aUsedEntries=%d"), aError, aUsedEntries);
|
|
238 |
|
|
239 |
// Pack the data to return to the Common TSY
|
|
240 |
CMmDataPackage dataPackage;
|
|
241 |
dataPackage.PackData(&aUsedEntries);
|
|
242 |
|
|
243 |
iMessageManagerCallback.Complete(EMmTsyENStoreGetInfoIPC, &dataPackage, aError);
|
|
244 |
|
|
245 |
} // CPhonebookEnDispatcher::CallbackStoreGetInfo
|
|
246 |
|
|
247 |
void CPhonebookEnDispatcher::CallbackStoreReadAll(TInt aError, TInt aIndex, const TDesC& aNumber, TBool aMoreToCome)
|
|
248 |
/**
|
|
249 |
* Callback function to be used by the request to complete CCtsyDispatcherCallback::CallbackPhonebookEnStoreReadAllComp()
|
|
250 |
*
|
|
251 |
* @param aError KErrNone on success, or another error code indicating the error otherwise.
|
|
252 |
* @param aIndex The index of the entry.
|
|
253 |
* @param aNumber The number stored in the EN entry. The length of this should not be more than 6.
|
|
254 |
* @param aMoreToCome ETrue if there are more entries to be read, EFalse otherwise.
|
|
255 |
*
|
|
256 |
* @see CRetrieveMobilePhoneENList::Start()
|
|
257 |
*/
|
|
258 |
{
|
|
259 |
TSYLOGENTRYEXITARGS(_L8("aError=%d, aIndex=%d, aMoreToCome=%d"), aError, aIndex, aMoreToCome);
|
|
260 |
|
|
261 |
TInt errorCode = aError;
|
|
262 |
CMmDataPackage dataPackage;
|
|
263 |
|
|
264 |
if (errorCode == KErrNone)
|
|
265 |
{
|
|
266 |
if ( aIndex < 0 || aIndex > KMaxTotalEntries )
|
|
267 |
{
|
|
268 |
errorCode = KErrCorrupt;
|
|
269 |
}
|
|
270 |
else
|
|
271 |
{
|
|
272 |
TRAP(errorCode, FillEnStoreResponseListL(aIndex, aNumber));
|
|
273 |
if (errorCode == KErrNone)
|
|
274 |
{
|
|
275 |
dataPackage.PackData(&iEnEntriesArray);
|
|
276 |
}
|
|
277 |
}
|
|
278 |
}
|
|
279 |
|
|
280 |
if (!aMoreToCome || errorCode != KErrNone)
|
|
281 |
{
|
|
282 |
iMessageManagerCallback.Complete(EMmTsyENStoreReadAllPhase1IPC, &dataPackage, errorCode);
|
|
283 |
iEnEntriesArray->ResetAndDestroy();
|
|
284 |
}
|
|
285 |
|
|
286 |
} // CPhonebookEnDispatcher::CallbackStoreReadAll
|
|
287 |
|
|
288 |
void CPhonebookEnDispatcher::CallbackStoreReadEntry(TInt aError, TInt aIndex, const TDesC& aNumber)
|
|
289 |
/**
|
|
290 |
* Callback function to be used by the request to complete CCtsyDispatcherCallback::CallbackPhonebookEnStoreReadEntryComp()
|
|
291 |
*
|
|
292 |
* @param aError KErrNone on success, or another error code indicating the error otherwise.
|
|
293 |
* @param aIndex The index of the entry.
|
|
294 |
* @param aNumber The number stored in the EN entry. The length of this should not be more than 6.
|
|
295 |
*
|
|
296 |
* @see RMobileENStore::Read()
|
|
297 |
*/
|
|
298 |
{
|
|
299 |
TSYLOGENTRYEXITARGS(_L8("aError=%d, aIndex=%d"), aError, aIndex);
|
|
300 |
|
|
301 |
TENStoreResponse storeResponse;
|
|
302 |
storeResponse.iLocation = aIndex;
|
|
303 |
storeResponse.iECCNumber.Copy(aNumber);
|
|
304 |
|
|
305 |
CMmDataPackage dataPackage;
|
|
306 |
dataPackage.PackData(&storeResponse);
|
|
307 |
|
|
308 |
if(aIndex >= KMaxTotalEntries)
|
|
309 |
{
|
|
310 |
iMessageManagerCallback.Complete(EMmTsyENStoreReadIPC, &dataPackage, KErrCorrupt);
|
|
311 |
}
|
|
312 |
else
|
|
313 |
{
|
|
314 |
iMessageManagerCallback.Complete(EMmTsyENStoreReadIPC, &dataPackage, aError);
|
|
315 |
}
|
|
316 |
} // CPhonebookEnDispatcher::CallbackStoreReadEntry
|
|
317 |
|
|
318 |
void CPhonebookEnDispatcher::CallbackSync(CRequestQueueOneShot::TIpcDataPackage& aIpcDataPackage)
|
|
319 |
/**
|
|
320 |
* Part of the MDispatcherCallback interface. Used to complete requests handled
|
|
321 |
* synchronously by the Licensee LTSY asynchronously back to the Common TSY.
|
|
322 |
*
|
|
323 |
* @param aIpcDataPackage Package encapsulating the request.
|
|
324 |
*
|
|
325 |
* @see MDispatcherCallback::CallbackSync
|
|
326 |
*/
|
|
327 |
{
|
|
328 |
TSYLOGENTRYEXIT;
|
|
329 |
|
|
330 |
switch (aIpcDataPackage.iIpc)
|
|
331 |
{
|
|
332 |
|
|
333 |
default:
|
|
334 |
LOG(_L8("WARNING: CPhonebookEnDispatcher::CallbackSync unhandled IPC=%d"), aIpcDataPackage.iIpc);
|
|
335 |
__ASSERT_DEBUG(NULL, CtsyDispatcherPanic(EUnhandledCtsyIpc));
|
|
336 |
break;
|
|
337 |
} // switch (aIpcDataPackage.iIpc)
|
|
338 |
|
|
339 |
} // CPhonebookEnDispatcher::CallbackSync
|
|
340 |
|
|
341 |
|
|
342 |
|