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