|
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 "activityobservertask.h" |
|
18 #include "activitycmd.h" |
|
19 |
|
20 // ----------------------------------------------------------------------------- |
|
21 // |
|
22 // ----------------------------------------------------------------------------- |
|
23 // |
|
24 CActivityObserverTask::CActivityObserverTask(MActivityTaskStorage& globalStorage, |
|
25 MActivityTaskStorage& localStorage, |
|
26 const RMessage2& msg) |
|
27 : |
|
28 mGlobalStorage(globalStorage), |
|
29 mLocalStorage(localStorage), |
|
30 mMsg(msg) |
|
31 { |
|
32 // No implementation required |
|
33 } |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CActivityObserverTask::~CActivityObserverTask() |
|
40 { |
|
41 mData.Close(); |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 void CActivityObserverTask::ExecuteLD(MActivityTaskStorage& globalStorage, |
|
49 MActivityTaskStorage& localStorage, |
|
50 const RMessage2& msg) |
|
51 { |
|
52 CActivityObserverTask *self = new(ELeave)CActivityObserverTask(globalStorage, |
|
53 localStorage, |
|
54 msg); |
|
55 CleanupStack::PushL(self); |
|
56 globalStorage.PushL(self); |
|
57 CleanupStack::Pop(self); |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 const TDesC8& CActivityObserverTask::Data() const |
|
65 { |
|
66 return mData; |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 void CActivityObserverTask::BroadcastReceivedL(const RMessage2& msg) |
|
74 { |
|
75 if (WaitActivity == mMsg.Function() && |
|
76 LaunchActivity == msg.Function()) { |
|
77 TPckgBuf<TInt> observerdId; |
|
78 mMsg.ReadL(KRequestAppIdOffset, observerdId); |
|
79 |
|
80 TPckgBuf<TInt> requestedId; |
|
81 msg.ReadL(KRequestAppIdOffset, requestedId); |
|
82 if (observerdId() == requestedId()) { |
|
83 if (msg.GetDesLength(KRequestActOffset) > mData.MaxLength()) { |
|
84 mData.ReAllocL(msg.GetDesLength(1)); |
|
85 } |
|
86 msg.ReadL(KRequestActOffset, mData, 0); |
|
87 WriteResponseL(); |
|
88 mLocalStorage.PushL(this); |
|
89 mGlobalStorage.Pop(this); |
|
90 mMsg.Complete(KErrNone); |
|
91 } |
|
92 } else if (WaitActivity == mMsg.Function() && |
|
93 CancelWait == msg.Function() && |
|
94 mMsg.Session() == msg.Session()) { |
|
95 mGlobalStorage.Pop(this); |
|
96 mMsg.Complete(KErrCancel); |
|
97 delete this; |
|
98 } |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 void CActivityObserverTask::WriteResponseL() |
|
106 { |
|
107 mMsg.WriteL(KResponseDataSizeOffset, TPckgBuf<TInt>(mData.Length()));//write data size |
|
108 mMsg.WriteL(KResponseIdOffset, TPckgBuf<CBase*>(this));//task identyfier |
|
109 } |