|
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.h" |
|
18 #include "afstorageclient_p.h" |
|
19 |
|
20 // ----------------------------------------------------------------------------- |
|
21 /** |
|
22 * Constructor |
|
23 */ |
|
24 AfStorageClient::AfStorageClient(QObject *obj) |
|
25 : |
|
26 QObject(obj), |
|
27 d_ptr(0) |
|
28 { |
|
29 d_ptr = new AfStorageClientPrivate(*this); |
|
30 } |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 /** |
|
34 * Destructor |
|
35 */ |
|
36 AfStorageClient::~AfStorageClient() |
|
37 { |
|
38 delete d_ptr; |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 /** |
|
43 * Establish connection with activity server |
|
44 * @return 0 on succees, error code otherwise |
|
45 */ |
|
46 int AfStorageClient::connect() |
|
47 { |
|
48 return d_ptr->connect(); |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 /** |
|
53 * Interface implementation. |
|
54 * @see int MAfAsyncRequestObserver::asyncRequestCompleated(int, int, const QString&) |
|
55 */ |
|
56 void AfStorageClient::asyncRequestCompleated(int result, |
|
57 int requestType, |
|
58 const QString& data) |
|
59 { |
|
60 switch (requestType) { |
|
61 case WaitActivity: |
|
62 if (KErrCancel != result) { |
|
63 waitActivity(); |
|
64 } |
|
65 if (KErrNone == result) { |
|
66 emit activityRequested(data); |
|
67 } |
|
68 |
|
69 break; |
|
70 } |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 /** |
|
75 * Interface implementation. |
|
76 * @see int MAfAsyncRequestObserver::asyncRequestCompleated(int, int, QPixmap&, void*) |
|
77 */ |
|
78 void AfStorageClient::asyncRequestCompleated(int result, |
|
79 int requestType, |
|
80 const QPixmap& pixmap, |
|
81 void* userData) |
|
82 { |
|
83 switch (requestType) { |
|
84 case GetThumbnail: |
|
85 emit thumbnailRequested(0 == result ? pixmap : QPixmap(), |
|
86 userData); |
|
87 break; |
|
88 } |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 /** |
|
93 * Interface implementation. |
|
94 * @see int MAfAsyncRequestObserver::asyncRequestCompleated(int, int) |
|
95 */ |
|
96 void AfStorageClient::asyncRequestCompleated(int result,int requestType) |
|
97 { |
|
98 switch(requestType) { |
|
99 case NotifyChange: |
|
100 if (KErrCancel != result) { |
|
101 notifyDataChange(); |
|
102 } |
|
103 if (KErrNone == result) { |
|
104 emit dataChanged(); |
|
105 } |
|
106 break; |
|
107 } |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 /** |
|
112 * Function add new activity |
|
113 * @param entry - activity entry data structure |
|
114 * @param imageSource - source for activity thumbnail |
|
115 * @return 0 on success, error code otherwise |
|
116 */ |
|
117 int AfStorageClient::addActivity(const AfStorageEntry &entry, const QPixmap &imageSource) |
|
118 { |
|
119 return d_ptr->addActivity(entry, imageSource); |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 /** |
|
124 * Function update existing activity |
|
125 * @param entry - activity entry data structure |
|
126 * @param imageSource - source for activity thumbnail |
|
127 * @return 0 on success, error code otherwise |
|
128 */ |
|
129 int AfStorageClient::updateActivity(const AfStorageEntry &entry, |
|
130 const QPixmap &imageSource) |
|
131 { |
|
132 return d_ptr->updateActivity(entry, imageSource); |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 /** |
|
137 * Function remove existing activity |
|
138 * @param entry - activity entry template |
|
139 * @return 0 on success, error code otherwise |
|
140 */ |
|
141 int AfStorageClient::removeActivity(const AfStorageEntry &entry) |
|
142 { |
|
143 return d_ptr->removeActivity(entry); |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 /** |
|
148 * Function remove existing activities for application |
|
149 * @param entry - activity entry template |
|
150 * @return 0 on success, error code otherwise |
|
151 */ |
|
152 int AfStorageClient::removeApplicationActivities(const AfStorageEntry &entry) |
|
153 { |
|
154 return d_ptr->removeApplicationActivities(entry); |
|
155 } |
|
156 |
|
157 // ----------------------------------------------------------------------------- |
|
158 /** |
|
159 * Function retreive public data for all activities |
|
160 * @param dst - list of results |
|
161 * @return 0 on success, error code otherwise |
|
162 */ |
|
163 int AfStorageClient::activities(QList<AfStorageEntry> &dst) |
|
164 { |
|
165 return d_ptr->activities(dst); |
|
166 } |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 /** |
|
170 * Function retreive public data for all application activities |
|
171 * @param dst - list of results |
|
172 * @param entry - activity template |
|
173 * @return 0 on success, error code otherwise |
|
174 */ |
|
175 int AfStorageClient::applicationActivities(QList<AfStorageEntry> &dst, |
|
176 const AfStorageEntry &entry) |
|
177 { |
|
178 return d_ptr->applicationActivities(dst, entry); |
|
179 } |
|
180 |
|
181 // ----------------------------------------------------------------------------- |
|
182 /** |
|
183 * Function retreive all data for requested activity |
|
184 * @param dst - activity entry |
|
185 * @param entry - activity template |
|
186 * @return 0 on success, error code otherwise |
|
187 */ |
|
188 int AfStorageClient::activityData(AfStorageEntry &dst, const AfStorageEntry &entry) |
|
189 { |
|
190 return d_ptr->activityData(dst, entry); |
|
191 } |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 /** |
|
195 * Function subscribe application for notyfication about requested activity changes |
|
196 * @return 0 on success, error code otherwise |
|
197 */ |
|
198 int AfStorageClient::waitActivity() |
|
199 { |
|
200 return d_ptr->waitActivity(); |
|
201 } |
|
202 |
|
203 // ----------------------------------------------------------------------------- |
|
204 /** |
|
205 * Function request activity change |
|
206 * @param entry - activity template |
|
207 * @return 0 on success, error code otherwise |
|
208 */ |
|
209 int AfStorageClient::launchActivity(const AfStorageEntry &entry) |
|
210 { |
|
211 return d_ptr->launchActivity(entry); |
|
212 } |
|
213 |
|
214 // ----------------------------------------------------------------------------- |
|
215 int AfStorageClient::getThumbnail(QSize size, QString imagePath, void* userDdata) |
|
216 { |
|
217 return d_ptr->getThumbnail(size, imagePath, userDdata); |
|
218 } |
|
219 |
|
220 // ----------------------------------------------------------------------------- |
|
221 /** |
|
222 * Function subscribe launcher for data model changes |
|
223 * @return 0 on success, error code otherwise |
|
224 */ |
|
225 int AfStorageClient::notifyDataChange() |
|
226 { |
|
227 return d_ptr->notifyDataChange(); |
|
228 } |