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 "tsrunningappstorage.h" |
|
18 #include "tsdatalist.h" |
|
19 #include "tsentry.h" |
|
20 #include <s32strm.h> |
|
21 #include <s32mem.h> |
|
22 // ----------------------------------------------------------------------------- |
|
23 // |
|
24 // ----------------------------------------------------------------------------- |
|
25 // |
|
26 CRunningAppStorage::CRunningAppStorage(MHsDataObserver& observer) |
|
27 : mObserver(observer) |
|
28 { |
|
29 } |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CRunningAppStorage::~CRunningAppStorage() |
|
36 { |
|
37 mData.Close(); |
|
38 delete mEngine; |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 CRunningAppStorage* CRunningAppStorage::NewL(MHsDataObserver& observer, |
|
46 MTsResourceManager& resources, |
|
47 MTsWindowGroupsMonitor &wsMonitor) |
|
48 { |
|
49 CRunningAppStorage * self = new (ELeave)CRunningAppStorage(observer); |
|
50 CleanupStack::PushL(self); |
|
51 self->ConstructL(resources, wsMonitor); |
|
52 CleanupStack::Pop(self); |
|
53 return self; |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 void CRunningAppStorage::ConstructL(MTsResourceManager& resources, |
|
61 MTsWindowGroupsMonitor &wsMonitor) |
|
62 { |
|
63 mEngine = CTsDataList::NewL(resources, wsMonitor, *this) ; |
|
64 RArray<RWsSession::TWindowGroupChainInfo> wgList; |
|
65 CleanupClosePushL(wgList); |
|
66 User::LeaveIfError(resources.WsSession().WindowGroupList(&wgList)); |
|
67 mEngine->HandleWindowGroupChanged(resources, wgList.Array()); |
|
68 CleanupStack::PopAndDestroy(&wgList); |
|
69 DataChangedL(); |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 const TDesC8& CRunningAppStorage::Data() const |
|
77 { |
|
78 return mData; |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 void CRunningAppStorage::DataChanged() |
|
86 { |
|
87 TRAPD( err, DataChangedL() ); |
|
88 if ( err == KErrNone) |
|
89 { |
|
90 mObserver.DataChanged(); |
|
91 } |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 void CRunningAppStorage::DataChangedL() |
|
99 { |
|
100 const TInt KExpandSize = 256; // "Granularity" of dynamic buffer |
|
101 CBufFlat* buf = CBufFlat::NewL(KExpandSize); |
|
102 CleanupStack::PushL(buf); |
|
103 RBufWriteStream stream(*buf); |
|
104 CleanupClosePushL(stream); |
|
105 CTsEntry::ExternalizeArrayL(stream, mEngine->Data()); |
|
106 CleanupStack::PopAndDestroy(&stream); |
|
107 mData.Close(); |
|
108 mData.CreateL( buf->Size() ); |
|
109 buf->Read(0, mData, buf->Size()); |
|
110 CleanupStack::PopAndDestroy(buf); |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 void CRunningAppStorage::UpdateL(TInt key, const CFbsBitmap& data, TInt param, TInt priority) |
|
118 { |
|
119 mEngine->UpdateL(key, data, param, priority); |
|
120 |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 void CRunningAppStorage::UpdateL(TInt key, const Visibility& data, TInt param) |
|
128 { |
|
129 mEngine->UpdateL(key, data, param); |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 void CRunningAppStorage::RemoveL(TInt key, TInt param) |
|
137 { |
|
138 mEngine->RemoveL(key, param); |
|
139 } |
|