1 /* |
|
2 * Copyright (c) 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 #include "afdataprovidertask.h" |
|
18 #include "activitycmd.h" |
|
19 |
|
20 // ----------------------------------------------------------------------------- |
|
21 /** |
|
22 * Handle data request. Deliver data stored in other task. |
|
23 * @param storage - data tasks storage |
|
24 * @param msg - request message |
|
25 */ |
|
26 void AfDataProviderTask::ExecuteL(MAfTaskStorage& storage, |
|
27 const RMessage2& msg) |
|
28 { |
|
29 TPckgBuf<void*> requestId; |
|
30 CAfTask* taskPtr(0); |
|
31 msg.Read(KRequestIdOffset, requestId); |
|
32 |
|
33 for (TInt iter(0);iter <storage.StorageData().Count();++iter) { |
|
34 taskPtr = storage.StorageData()[iter]; |
|
35 if (taskPtr == requestId()) {//compare requested task address with storage objects |
|
36 ProvideDataL(msg, *taskPtr); |
|
37 storage.Pop(taskPtr); |
|
38 delete taskPtr; |
|
39 return; |
|
40 } |
|
41 } |
|
42 User::Leave(KErrNotFound); |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 /** |
|
47 * Write response data to request message |
|
48 * @param msg - destination message |
|
49 * @param src - data source |
|
50 */ |
|
51 void AfDataProviderTask::ProvideDataL(const RMessage2& msg, |
|
52 const CAfTask& src) |
|
53 { |
|
54 if (EFalse ==msg.IsNull()) { |
|
55 msg.WriteL(KResponseDataOffset, src.Data()); |
|
56 msg.Complete(KErrNone); |
|
57 } |
|
58 } |
|