107
|
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 "afstorageclient_p.h"
|
|
18 |
|
|
19 |
#include <fbs.h>
|
|
20 |
#include <s32mem.h>
|
|
21 |
|
|
22 |
#include "afasyncrequest_p.h"
|
|
23 |
#include "afstorageglobals.h"
|
|
24 |
#include "afentry.h"
|
|
25 |
|
|
26 |
// -----------------------------------------------------------------------------
|
|
27 |
/**
|
|
28 |
* Two-phase constructor. Create and initialize instance
|
|
29 |
* @return entry instance
|
|
30 |
*/
|
|
31 |
CAfStorageClientPrivate *CAfStorageClientPrivate::NewL(MAfAsyncRequestObserver &observer)
|
|
32 |
{
|
|
33 |
CAfStorageClientPrivate *self = CAfStorageClientPrivate::NewLC(observer);
|
|
34 |
CleanupStack::Pop(self);
|
|
35 |
return self;
|
|
36 |
}
|
|
37 |
|
|
38 |
// -----------------------------------------------------------------------------
|
|
39 |
/**
|
|
40 |
* Two-phase constructor. Create, initialize and push instance into cleanup stack
|
|
41 |
* @return entry instance
|
|
42 |
*/
|
|
43 |
CAfStorageClientPrivate *CAfStorageClientPrivate::NewLC(MAfAsyncRequestObserver &observer)
|
|
44 |
{
|
|
45 |
CAfStorageClientPrivate *self = new (ELeave) CAfStorageClientPrivate(observer);
|
|
46 |
CleanupStack::PushL(self);
|
|
47 |
self->ConstructL();
|
|
48 |
return self;
|
|
49 |
}
|
|
50 |
|
|
51 |
// -----------------------------------------------------------------------------
|
|
52 |
/**
|
|
53 |
* Destructor
|
|
54 |
*/
|
|
55 |
CAfStorageClientPrivate::~CAfStorageClientPrivate()
|
|
56 |
{
|
|
57 |
mImplementation.Close();
|
|
58 |
}
|
|
59 |
|
|
60 |
// -----------------------------------------------------------------------------
|
|
61 |
/**
|
|
62 |
* Constructor
|
|
63 |
*/
|
|
64 |
CAfStorageClientPrivate::CAfStorageClientPrivate(MAfAsyncRequestObserver &observer) : mImplementation(observer)
|
|
65 |
{
|
|
66 |
}
|
|
67 |
|
|
68 |
// -----------------------------------------------------------------------------
|
|
69 |
/**
|
|
70 |
* 2nd phase of construction
|
|
71 |
*/
|
|
72 |
void CAfStorageClientPrivate::ConstructL()
|
|
73 |
{
|
|
74 |
mImplementation.connectL();
|
|
75 |
}
|
|
76 |
|
|
77 |
// -----------------------------------------------------------------------------
|
|
78 |
/**
|
|
79 |
* Function implementation
|
|
80 |
* @see AfStorageClient::saveActivity(const CAfEntry &,const QPixmap&)
|
|
81 |
*/
|
|
82 |
int CAfStorageClientPrivate::saveActivity(const CAfEntry &entry, TInt imageHandle)
|
|
83 |
{
|
|
84 |
return execute(SaveActivity, entry, imageHandle);
|
|
85 |
}
|
|
86 |
|
|
87 |
// -----------------------------------------------------------------------------
|
|
88 |
/**
|
|
89 |
* Function implementation
|
|
90 |
* @see AfStorageClient::removeActivity(const CAfEntry &)
|
|
91 |
*/
|
|
92 |
int CAfStorageClientPrivate::removeActivity(const CAfEntry &entry)
|
|
93 |
{
|
|
94 |
return execute(RemoveActivity, entry, -1);
|
|
95 |
}
|
|
96 |
|
|
97 |
// -----------------------------------------------------------------------------
|
|
98 |
/**
|
|
99 |
* Function implementation
|
|
100 |
* @see AfStorageClient::removeApplicationActivities(const CAfEntry &)
|
|
101 |
*/
|
|
102 |
int CAfStorageClientPrivate::removeApplicationActivities(const CAfEntry &entry)
|
|
103 |
{
|
|
104 |
return execute(RemoveApplicationActivities, entry, -1);
|
|
105 |
}
|
|
106 |
|
|
107 |
// -----------------------------------------------------------------------------
|
|
108 |
/**
|
|
109 |
* Function implementation
|
|
110 |
* @see AfStorageClient::activities(RPointerArray<CAfEntry> &)
|
|
111 |
*/
|
116
|
112 |
int CAfStorageClientPrivate::activities(RPointerArray<CAfEntry> &results, TInt limit)
|
107
|
113 |
{
|
|
114 |
CAfEntry *entry = CAfEntry::NewL();
|
116
|
115 |
TInt result = execute(Activities, results, *entry, limit);
|
107
|
116 |
delete entry;
|
|
117 |
return result;
|
|
118 |
}
|
|
119 |
|
|
120 |
// -----------------------------------------------------------------------------
|
|
121 |
/**
|
|
122 |
* Function implementation
|
|
123 |
* @see AfStorageClient::applicationActivities(RPointerArray<CAfEntry> &, const CAfEntry &)
|
|
124 |
*/
|
|
125 |
int CAfStorageClientPrivate::applicationActivities(RPointerArray<CAfEntry> &results, const CAfEntry &templateEntry)
|
|
126 |
{
|
|
127 |
return execute(ApplicationActivities, results, templateEntry);
|
|
128 |
}
|
|
129 |
|
|
130 |
// -----------------------------------------------------------------------------
|
|
131 |
/**
|
|
132 |
* Function implementation
|
|
133 |
* @see AfStorageClient::activityData(CAfEntry &, const CAfEntry &)
|
|
134 |
*/
|
|
135 |
int CAfStorageClientPrivate::activityData(CAfEntry *&resultEntry, const CAfEntry &templateEntry)
|
|
136 |
{
|
|
137 |
RPointerArray<CAfEntry> results;
|
|
138 |
int errNo(execute(ApplicationActivity, results, templateEntry));
|
|
139 |
if (KErrNone == errNo && results.Count() > 0) {
|
|
140 |
resultEntry = results[0];
|
|
141 |
results.Remove(0);
|
|
142 |
}
|
|
143 |
results.ResetAndDestroy();
|
|
144 |
return errNo;
|
|
145 |
}
|
|
146 |
|
|
147 |
// -----------------------------------------------------------------------------
|
|
148 |
/**
|
|
149 |
* Function implementation
|
|
150 |
* @see AfStorageClient::waitActivity()
|
|
151 |
*/
|
|
152 |
int CAfStorageClientPrivate::waitActivity()
|
|
153 |
{
|
|
154 |
CAfEntry *entry = CAfEntry::NewL();
|
|
155 |
TInt result = execute(WaitActivity, *entry, -1);
|
|
156 |
delete entry;
|
|
157 |
return result;
|
|
158 |
}
|
|
159 |
|
|
160 |
// -----------------------------------------------------------------------------
|
|
161 |
/**
|
|
162 |
* Function implementation
|
119
|
163 |
* @see AfStorageClient::getThumbnail(const TDesC &imagePath, void *userData)
|
107
|
164 |
*/
|
119
|
165 |
int CAfStorageClientPrivate::getThumbnail(const TDesC &imagePath, void *userData)
|
107
|
166 |
{
|
119
|
167 |
TRAPD(errNo, mImplementation.getThumbnailL(imagePath, userData);)
|
107
|
168 |
return errNo;
|
|
169 |
}
|
|
170 |
|
|
171 |
// -----------------------------------------------------------------------------
|
|
172 |
/**
|
|
173 |
* Function implementation
|
|
174 |
* @see AfStorageClient::notifyDataChange()
|
|
175 |
*/
|
|
176 |
int CAfStorageClientPrivate::notifyDataChange()
|
|
177 |
{
|
|
178 |
CAfEntry *entry = CAfEntry::NewL();
|
|
179 |
TInt result = execute(NotifyChange, *entry, -1);
|
|
180 |
delete entry;
|
|
181 |
return result;
|
|
182 |
}
|
|
183 |
|
|
184 |
// -----------------------------------------------------------------------------
|
|
185 |
/**
|
|
186 |
* Function implementation
|
|
187 |
* @see AfStorageClient::launchActivity(const CAfEntry &)
|
|
188 |
*/
|
|
189 |
int CAfStorageClientPrivate::launchActivity(const CAfEntry &templateEntry)
|
|
190 |
{
|
|
191 |
return execute(LaunchActivity, templateEntry, -1);
|
|
192 |
}
|
|
193 |
|
|
194 |
// -----------------------------------------------------------------------------
|
|
195 |
/**
|
|
196 |
* Function execute activity framework functinality and return results
|
|
197 |
*/
|
|
198 |
int CAfStorageClientPrivate::execute(int function, const CAfEntry &sourceEntry, TInt imageHandle)
|
|
199 |
{
|
|
200 |
TRAPD(errNo,
|
|
201 |
switch (function) {
|
|
202 |
case SaveActivity:
|
|
203 |
case RemoveActivity:
|
|
204 |
case RemoveApplicationActivities:
|
|
205 |
case LaunchActivity:
|
|
206 |
mImplementation.executeL(function, sourceEntry, imageHandle);
|
|
207 |
break;
|
|
208 |
|
|
209 |
case WaitActivity:
|
|
210 |
case NotifyChange:
|
|
211 |
mImplementation.executeL(function);
|
|
212 |
break;
|
|
213 |
default:
|
|
214 |
User::Leave(KErrArgument);
|
|
215 |
}
|
|
216 |
)
|
|
217 |
return errNo;
|
|
218 |
}
|
|
219 |
|
|
220 |
// -----------------------------------------------------------------------------
|
|
221 |
/**
|
|
222 |
* Function execute activity framework functinality and return results
|
|
223 |
*/
|
116
|
224 |
int CAfStorageClientPrivate::execute(int function, RPointerArray<CAfEntry>& resultsList,const CAfEntry& templateEntry, int limit)
|
107
|
225 |
{
|
116
|
226 |
TRAPD(errNo, mImplementation.executeL(function, resultsList, templateEntry, limit);)
|
107
|
227 |
return errNo;
|
|
228 |
}
|