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 "afsession.h"
|
|
18 |
#include "aftask.h"
|
|
19 |
#include "afcmd.h"
|
|
20 |
|
|
21 |
#include "afstorageasynctask.h"
|
|
22 |
#include "afstoragesynctask.h"
|
|
23 |
#include "afobservertask.h"
|
|
24 |
#include "afbroadcasttask.h"
|
|
25 |
#include "afdataprovidertask.h"
|
|
26 |
#include "afthumbnailtask.h"
|
|
27 |
|
|
28 |
_LIT(KTaskAlreadyExists, "Activity task exists");
|
|
29 |
|
|
30 |
// -----------------------------------------------------------------------------
|
|
31 |
/**
|
|
32 |
* Constructor for performing 1st stage construction
|
|
33 |
* @param fileSession - initialized file system session
|
|
34 |
* @param taskStorage - global observers storage
|
|
35 |
* @param storage - data storage
|
|
36 |
*/
|
|
37 |
|
|
38 |
CAfSession::CAfSession(RFs& fileSession,
|
|
39 |
MAfTaskStorage& taskStorage,
|
|
40 |
CAfStorage& storage)
|
|
41 |
:
|
|
42 |
mFileSession(fileSession),
|
|
43 |
mTasksStorage(taskStorage),
|
|
44 |
mStorage(storage)
|
|
45 |
{
|
|
46 |
// No implementation required
|
|
47 |
}
|
|
48 |
|
|
49 |
// -----------------------------------------------------------------------------
|
|
50 |
/**
|
|
51 |
* Destructor.
|
|
52 |
*/
|
|
53 |
CAfSession::~CAfSession()
|
|
54 |
{
|
|
55 |
RemoveNotValidTasks(this);
|
|
56 |
mTasksStorage.RemoveNotValidTasks(this);
|
|
57 |
}
|
|
58 |
|
|
59 |
// -----------------------------------------------------------------------------
|
|
60 |
/**
|
|
61 |
* Two-phased constructor.
|
|
62 |
* @param fileSession - initialized file system session
|
|
63 |
* @param taskStorage - global observers storage
|
|
64 |
* @param storage - data storage
|
|
65 |
*/
|
|
66 |
CAfSession* CAfSession::NewL(RFs& fileSession,
|
|
67 |
MAfTaskStorage& taskStorage,
|
|
68 |
CAfStorage& storage)
|
|
69 |
{
|
|
70 |
CAfSession* self = new (ELeave) CAfSession(fileSession,
|
|
71 |
taskStorage,
|
|
72 |
storage);
|
|
73 |
CleanupStack::PushL(self);
|
|
74 |
self->ConstructL();
|
|
75 |
CleanupStack::Pop(self);
|
|
76 |
return self;
|
|
77 |
}
|
|
78 |
|
|
79 |
// -----------------------------------------------------------------------------
|
|
80 |
/**
|
|
81 |
* EPOC default constructor for performing 2nd stage construction
|
|
82 |
*/
|
|
83 |
void CAfSession::ConstructL()
|
|
84 |
{
|
|
85 |
}
|
|
86 |
|
|
87 |
// -----------------------------------------------------------------------------
|
|
88 |
/**
|
|
89 |
* Implements interface
|
|
90 |
* @see void CSession2::ServiceL(const RMessage2&)
|
|
91 |
*/
|
|
92 |
void CAfSession::ServiceL(const RMessage2& message)
|
|
93 |
{
|
|
94 |
switch (message.Function()) {
|
107
|
95 |
case SaveActivity:
|
99
|
96 |
case RemoveActivity:
|
|
97 |
case RemoveApplicationActivities:
|
112
|
98 |
{
|
|
99 |
mStorage.InterruptCleanup();
|
99
|
100 |
AfStorageSyncTask::ExecuteL(mTasksStorage, mStorage, message);
|
112
|
101 |
mStorage.RequestCleanup();
|
99
|
102 |
break;
|
112
|
103 |
}
|
99
|
104 |
|
|
105 |
case ApplicationActivity:
|
|
106 |
case Activities:
|
|
107 |
case ApplicationActivities:
|
112
|
108 |
{
|
|
109 |
TBool cleanupInterrupted = mStorage.InterruptCleanup();
|
99
|
110 |
CAfStorageAsyncTask::ExecuteLD(*this, mStorage, message);
|
112
|
111 |
if (cleanupInterrupted) mStorage.RequestCleanup();
|
99
|
112 |
break;
|
112
|
113 |
}
|
99
|
114 |
|
|
115 |
case WaitActivity:
|
|
116 |
case NotifyChange:
|
|
117 |
CAfObserverTask::ExecuteLD(mTasksStorage, *this, message);
|
|
118 |
break;
|
|
119 |
|
|
120 |
case GetThumbnail:
|
|
121 |
CAfThumbnailTask::ExecuteLD(*this, message);
|
|
122 |
break;
|
|
123 |
|
|
124 |
case LaunchActivity:
|
|
125 |
case CancelWait:
|
|
126 |
case CancelNotify:
|
|
127 |
AfBroadcastTask::ExecuteL(mTasksStorage, message);
|
|
128 |
break;
|
|
129 |
|
|
130 |
case GetData:
|
|
131 |
AfDataProviderTask::ExecuteL(*this,message);
|
|
132 |
break;
|
|
133 |
|
|
134 |
default:
|
|
135 |
message.Complete(CServer2::EBadMessageNumber);
|
|
136 |
break;
|
|
137 |
}
|
|
138 |
}
|
|
139 |
|
|
140 |
// -----------------------------------------------------------------------------
|
|
141 |
/**
|
|
142 |
* Interface implementation
|
|
143 |
* @see MAfTaskStorage::PushL(CAfTask *)
|
|
144 |
*/
|
|
145 |
void CAfSession::PushL(CAfTask * task)
|
|
146 |
{
|
|
147 |
(KErrNotFound == mRunningTasks.Find(task)) ?
|
|
148 |
mRunningTasks.AppendL(task) :
|
|
149 |
User::Panic(KTaskAlreadyExists, KErrAlreadyExists);
|
|
150 |
}
|
|
151 |
|
|
152 |
// -----------------------------------------------------------------------------
|
|
153 |
/**
|
|
154 |
* Interface implementation
|
|
155 |
* @see MAfTaskStorage::Pop(CAfTask *)
|
|
156 |
*/
|
|
157 |
void CAfSession::Pop(CAfTask *task)
|
|
158 |
{
|
|
159 |
const TInt offset(mRunningTasks.Find(task));
|
|
160 |
if (KErrNotFound != offset) {
|
|
161 |
mRunningTasks.Remove(offset);
|
|
162 |
}
|
|
163 |
}
|
|
164 |
|
|
165 |
// -----------------------------------------------------------------------------
|
|
166 |
/**
|
|
167 |
* Interface implementation
|
|
168 |
* @see MAfTaskStorage::StorageData()
|
|
169 |
*/
|
|
170 |
const RPointerArray<CAfTask>& CAfSession::StorageData() const
|
|
171 |
{
|
|
172 |
return mRunningTasks;
|
|
173 |
}
|
|
174 |
|
|
175 |
// -----------------------------------------------------------------------------
|
|
176 |
/**
|
|
177 |
* Removes not valid task
|
|
178 |
*/
|
|
179 |
void CAfSession::RemoveNotValidTasks(const CSession2* session)
|
|
180 |
{
|
|
181 |
if (session == this) {
|
|
182 |
mRunningTasks.ResetAndDestroy();
|
|
183 |
}
|
|
184 |
}
|