94
|
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"
|
98
|
18 |
#include "tsfswdatalist.h"
|
94
|
19 |
#include "tsfswentry.h"
|
|
20 |
#include <s32strm.h>
|
96
|
21 |
#include <s32mem.h>
|
94
|
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 |
//
|
98
|
45 |
CRunningAppStorage* CRunningAppStorage::NewL(MHsDataObserver& observer,
|
|
46 |
MTsResourceManager& resources,
|
|
47 |
MTsWindowGroupsMonitor &wsMonitor)
|
94
|
48 |
{
|
|
49 |
CRunningAppStorage * self = new (ELeave)CRunningAppStorage(observer);
|
|
50 |
CleanupStack::PushL(self);
|
98
|
51 |
self->ConstructL(resources, wsMonitor);
|
94
|
52 |
CleanupStack::Pop(self);
|
|
53 |
return self;
|
|
54 |
}
|
|
55 |
|
|
56 |
// -----------------------------------------------------------------------------
|
|
57 |
//
|
|
58 |
// -----------------------------------------------------------------------------
|
|
59 |
//
|
98
|
60 |
void CRunningAppStorage::ConstructL(MTsResourceManager& resources,
|
|
61 |
MTsWindowGroupsMonitor &wsMonitor)
|
94
|
62 |
{
|
98
|
63 |
mEngine = CTsFswDataList::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);
|
94
|
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 |
}
|
96
|
93 |
|
|
94 |
// -----------------------------------------------------------------------------
|
|
95 |
//
|
|
96 |
// -----------------------------------------------------------------------------
|
|
97 |
//
|
94
|
98 |
void CRunningAppStorage::DataChangedL()
|
|
99 |
{
|
|
100 |
RTsFswArray taskList = mEngine->FswDataL();
|
|
101 |
CTsFswEntry* entry = CTsFswEntry::NewLC();
|
|
102 |
// Create a dynamic flat buffer to hold this object’s member data
|
|
103 |
|
|
104 |
const TInt KExpandSize = 256; // "Granularity" of dynamic buffer
|
|
105 |
CBufFlat* buf = CBufFlat::NewL(KExpandSize);
|
|
106 |
CleanupStack::PushL(buf);
|
|
107 |
RBufWriteStream stream(*buf);
|
|
108 |
CleanupClosePushL(stream);
|
|
109 |
entry->ExternalizeArrayL(stream, taskList);
|
|
110 |
CleanupStack::PopAndDestroy(&stream);
|
|
111 |
mData.Close();
|
|
112 |
mData.CreateL( buf->Size() );
|
|
113 |
buf->Read(0, mData, buf->Size());
|
|
114 |
|
|
115 |
|
|
116 |
CleanupStack::PopAndDestroy(buf);
|
96
|
117 |
CleanupStack::PopAndDestroy(entry);
|
94
|
118 |
}
|
96
|
119 |
|
|
120 |
// -----------------------------------------------------------------------------
|
|
121 |
//
|
|
122 |
// -----------------------------------------------------------------------------
|
|
123 |
//
|
|
124 |
void CRunningAppStorage::UpdateL(TInt key, const CFbsBitmap& data, TInt /*param*/, TInt priority)
|
|
125 |
{
|
|
126 |
UpdatePriority newpriority = static_cast<UpdatePriority>(priority);
|
|
127 |
mEngine->SetScreenshotL(&data, newpriority, key);
|
|
128 |
}
|
|
129 |
|
|
130 |
// -----------------------------------------------------------------------------
|
|
131 |
//
|
|
132 |
// -----------------------------------------------------------------------------
|
|
133 |
//
|
|
134 |
void CRunningAppStorage::RemoveL(TInt key, TInt /*param*/)
|
|
135 |
{
|
|
136 |
mEngine->RemoveScreenshotL(key);
|
|
137 |
}
|