99
|
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 <s32mem.h>
|
|
18 |
|
|
19 |
#include "afstorageasynctask.h"
|
|
20 |
#include "afcmd.h"
|
|
21 |
|
|
22 |
// -----------------------------------------------------------------------------
|
|
23 |
/**
|
|
24 |
* Constructor for performing 1st stage construction
|
|
25 |
*/
|
|
26 |
CAfStorageAsyncTask::CAfStorageAsyncTask()
|
|
27 |
{
|
|
28 |
// No implementation required
|
|
29 |
}
|
|
30 |
|
|
31 |
// -----------------------------------------------------------------------------
|
|
32 |
/**
|
|
33 |
* Destructor.
|
|
34 |
*/
|
|
35 |
CAfStorageAsyncTask::~CAfStorageAsyncTask()
|
|
36 |
{
|
|
37 |
mExternalizedData.Close();
|
|
38 |
mInternalizedData.ResetAndDestroy();
|
|
39 |
}
|
|
40 |
|
|
41 |
// -----------------------------------------------------------------------------
|
|
42 |
/**
|
|
43 |
* Handle asynchronous data storage requests
|
|
44 |
* @param taskStorage - data tasks storage
|
|
45 |
* @param dataStorage - data storage
|
|
46 |
* @param msg - request message
|
|
47 |
*/
|
|
48 |
void CAfStorageAsyncTask::ExecuteLD(MAfTaskStorage& taskStorage,
|
|
49 |
CAfStorage& dataStorage,
|
|
50 |
const RMessage2& msg)
|
|
51 |
{
|
|
52 |
CAfStorageAsyncTask* self = new (ELeave) CAfStorageAsyncTask();
|
|
53 |
CleanupStack::PushL(self);
|
|
54 |
self->ExecuteL(dataStorage, msg);
|
|
55 |
taskStorage.PushL(self);
|
|
56 |
CleanupStack::Pop(self);
|
107
|
57 |
msg.Complete(KErrNone);
|
99
|
58 |
}
|
|
59 |
|
|
60 |
// -----------------------------------------------------------------------------
|
|
61 |
/**
|
|
62 |
* Interface implementation
|
|
63 |
* @see CActivityTask::Data()
|
|
64 |
*/
|
|
65 |
const TDesC8& CAfStorageAsyncTask::CAfStorageAsyncTask::Data() const
|
|
66 |
{
|
|
67 |
return mExternalizedData;
|
|
68 |
}
|
|
69 |
|
|
70 |
// -----------------------------------------------------------------------------
|
|
71 |
/**
|
|
72 |
* Interface implementation
|
|
73 |
* @see CActivityTask::BroadcastReceivedL(const RMessage2 &)
|
|
74 |
*/
|
119
|
75 |
void CAfStorageAsyncTask::BroadcastReceivedL(const RMessage2&, TBool)
|
99
|
76 |
{
|
|
77 |
// No implementation required
|
|
78 |
}
|
|
79 |
|
|
80 |
// -----------------------------------------------------------------------------
|
|
81 |
/**
|
|
82 |
* Handle asynchronous data storage requests
|
|
83 |
* @param dataStorage - data storage
|
|
84 |
* @param msg - request message
|
|
85 |
*/
|
|
86 |
void CAfStorageAsyncTask::ExecuteL(CAfStorage& dataStorage,
|
|
87 |
const RMessage2& msg)
|
|
88 |
{
|
|
89 |
switch (msg.Function()) {
|
|
90 |
case Activities:
|
|
91 |
AllActivitiesL(dataStorage, msg);
|
|
92 |
break;
|
|
93 |
case ApplicationActivities:
|
|
94 |
ApplicationActivitiesL(dataStorage, msg);
|
|
95 |
break;
|
|
96 |
case ApplicationActivity:
|
|
97 |
ApplicationActivityL(dataStorage, msg);
|
|
98 |
break;
|
|
99 |
};
|
|
100 |
}
|
|
101 |
|
|
102 |
// -----------------------------------------------------------------------------
|
|
103 |
/**
|
|
104 |
* Handle getting all activities request
|
|
105 |
* @param dataStorage - data storage
|
|
106 |
* @param msg - requested message
|
|
107 |
*/
|
|
108 |
void CAfStorageAsyncTask::AllActivitiesL(CAfStorage& dataStorage,
|
|
109 |
const RMessage2& msg)
|
|
110 |
{
|
116
|
111 |
dataStorage.AllActivitiesL(mInternalizedData, msg.Int3());
|
99
|
112 |
ExternalizeL();
|
|
113 |
WriteResponseL(msg);
|
|
114 |
}
|
|
115 |
|
|
116 |
// -----------------------------------------------------------------------------
|
|
117 |
/**
|
|
118 |
* Handle getting application activities request
|
|
119 |
* @param dataStorage - data storage
|
|
120 |
* @param msg - requested message
|
|
121 |
*/
|
|
122 |
void CAfStorageAsyncTask::ApplicationActivitiesL(CAfStorage& dataStorage,
|
|
123 |
const RMessage2& msg)
|
|
124 |
{
|
|
125 |
CAfEntry *entry = CAfEntry::NewLC(msg);
|
|
126 |
dataStorage.ActivitiesL(mInternalizedData, entry->ApplicationId());
|
|
127 |
CleanupStack::PopAndDestroy(entry);
|
|
128 |
ExternalizeL();
|
|
129 |
WriteResponseL(msg);
|
|
130 |
}
|
|
131 |
|
|
132 |
// -----------------------------------------------------------------------------
|
|
133 |
/**
|
|
134 |
* Handle getting application activity request
|
|
135 |
* @param dataStorage - data storage
|
|
136 |
* @param msg - requested message
|
|
137 |
*/
|
|
138 |
void CAfStorageAsyncTask::ApplicationActivityL(CAfStorage& dataStorage,
|
|
139 |
const RMessage2& msg)
|
|
140 |
{
|
|
141 |
CAfEntry *src(CAfEntry::NewLC(msg));
|
|
142 |
dataStorage.ActivityL(mInternalizedData, *src);
|
|
143 |
CleanupStack::PopAndDestroy(src);
|
|
144 |
ExternalizeL();
|
|
145 |
WriteResponseL(msg);
|
|
146 |
}
|
|
147 |
|
|
148 |
// -----------------------------------------------------------------------------
|
|
149 |
void CAfStorageAsyncTask::ExternalizeL()
|
|
150 |
{
|
|
151 |
mExternalizedData << mInternalizedData;
|
|
152 |
mInternalizedData.ResetAndDestroy();
|
|
153 |
}
|
|
154 |
|
|
155 |
// -----------------------------------------------------------------------------
|
|
156 |
/**
|
|
157 |
* Write response data into request message
|
|
158 |
* @param msg - destination message
|
|
159 |
*/
|
|
160 |
void CAfStorageAsyncTask::WriteResponseL(const RMessage2& msg)
|
|
161 |
{
|
107
|
162 |
msg.WriteL(1,
|
|
163 |
TPckgBuf<TInt>(mExternalizedData.Length()));//write data size
|
|
164 |
msg.WriteL(2,
|
|
165 |
TPckgBuf<CBase*>(this));//task identyfier
|
99
|
166 |
}
|
|
167 |
|
|
168 |
// -----------------------------------------------------------------------------
|
|
169 |
/**
|
|
170 |
* Returns ETrue if task is related with session argument
|
|
171 |
*/
|
|
172 |
|
|
173 |
TBool CAfStorageAsyncTask::IsSessionTask(const CSession2* /*session*/)
|
|
174 |
{
|
|
175 |
return EFalse;
|
|
176 |
}
|