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"
|
|
18 |
#include "tsfswengine.h"
|
|
19 |
#include "tsfswmonitor.h"
|
|
20 |
#include "tsfswentry.h"
|
|
21 |
#include <s32strm.h>
|
|
22 |
#include <S32MEM.H>
|
|
23 |
// -----------------------------------------------------------------------------
|
|
24 |
//
|
|
25 |
// -----------------------------------------------------------------------------
|
|
26 |
//
|
|
27 |
CRunningAppStorage::CRunningAppStorage(MHsDataObserver& observer)
|
|
28 |
: mObserver(observer)
|
|
29 |
{
|
|
30 |
}
|
|
31 |
|
|
32 |
// -----------------------------------------------------------------------------
|
|
33 |
//
|
|
34 |
// -----------------------------------------------------------------------------
|
|
35 |
//
|
|
36 |
CRunningAppStorage::~CRunningAppStorage()
|
|
37 |
{
|
|
38 |
mData.Close();
|
|
39 |
delete mEngine;
|
|
40 |
delete mMonitor;
|
|
41 |
}
|
|
42 |
|
|
43 |
// -----------------------------------------------------------------------------
|
|
44 |
//
|
|
45 |
// -----------------------------------------------------------------------------
|
|
46 |
//
|
|
47 |
CRunningAppStorage* CRunningAppStorage::NewL(MHsDataObserver& observer)
|
|
48 |
{
|
|
49 |
CRunningAppStorage * self = new (ELeave)CRunningAppStorage(observer);
|
|
50 |
CleanupStack::PushL(self);
|
|
51 |
self->ConstructL();
|
|
52 |
CleanupStack::Pop(self);
|
|
53 |
return self;
|
|
54 |
}
|
|
55 |
|
|
56 |
// -----------------------------------------------------------------------------
|
|
57 |
//
|
|
58 |
// -----------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
void CRunningAppStorage::ConstructL()
|
|
61 |
{
|
|
62 |
mEngine = CTsFswEngine::NewL(*this) ;
|
|
63 |
mMonitor = CTsFswMonitor::NewL(*mEngine);
|
|
64 |
DataChangedL();
|
|
65 |
}
|
|
66 |
|
|
67 |
// -----------------------------------------------------------------------------
|
|
68 |
//
|
|
69 |
// -----------------------------------------------------------------------------
|
|
70 |
//
|
|
71 |
const TDesC8& CRunningAppStorage::Data() const
|
|
72 |
{
|
|
73 |
return mData;
|
|
74 |
}
|
|
75 |
|
|
76 |
// -----------------------------------------------------------------------------
|
|
77 |
//
|
|
78 |
// -----------------------------------------------------------------------------
|
|
79 |
//
|
|
80 |
void CRunningAppStorage::DataChanged()
|
|
81 |
{
|
|
82 |
TRAPD( err, DataChangedL() );
|
|
83 |
if ( err == KErrNone)
|
|
84 |
{
|
|
85 |
mObserver.DataChanged();
|
|
86 |
}
|
|
87 |
|
|
88 |
int a=8;
|
|
89 |
if( a==9)
|
|
90 |
{
|
|
91 |
CActiveScheduler::Stop();
|
|
92 |
}
|
|
93 |
}
|
|
94 |
void CRunningAppStorage::DataChangedL()
|
|
95 |
{
|
|
96 |
RTsFswArray taskList = mEngine->FswDataL();
|
|
97 |
CTsFswEntry* entry = CTsFswEntry::NewLC();
|
|
98 |
// Create a dynamic flat buffer to hold this object’s member data
|
|
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 |
entry->ExternalizeArrayL(stream, taskList);
|
|
106 |
CleanupStack::PopAndDestroy(&stream);
|
|
107 |
mData.Close();
|
|
108 |
mData.CreateL( buf->Size() );
|
|
109 |
buf->Read(0, mData, buf->Size());
|
|
110 |
|
|
111 |
|
|
112 |
CleanupStack::PopAndDestroy(buf);
|
|
113 |
CleanupStack::PopAndDestroy(entry);
|
|
114 |
|
|
115 |
}
|