9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: Offers message creation and sending services. |
14 * Description: Offers file share services. |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 // SYSTEM INCLUDES |
19 #include "shareuiprivate.h" |
|
20 #include <QVariant> |
19 #include <QVariant> |
21 #include <QDir> |
20 #include <QDir> |
22 #include <HbPushButton> |
21 #include <QRegExp> |
23 #include <HbListWidget> |
22 #include <QFile> |
24 #include <HbMainWindow> |
23 #include <QStringList> |
|
24 #include <QGraphicsLinearLayout> |
|
25 |
|
26 #include <HbAction> |
|
27 #include <HbDialog> |
|
28 #include <HbLabel> |
|
29 #include <HbListView> |
|
30 #include <HbListViewItem> |
25 #include <HbNotificationDialog> |
31 #include <HbNotificationDialog> |
|
32 #include <HbIconItem> |
|
33 #include <HbTextItem> |
|
34 |
26 #include <xqserviceglobal.h> |
35 #include <xqserviceglobal.h> |
27 |
36 #include <xqaiwrequest.h> |
28 //Localized Constants |
37 #include <xqaiwinterfacedescriptor.h> |
29 #define LOC_SEND_SELECTED_ITEM hbTrId("txt_messaging_title_send_selected_item") |
38 |
30 #define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel") |
39 // USER INCLUDES |
31 |
40 #include "shareuiprivate.h" |
|
41 |
|
42 // Localized Constants |
|
43 //#define LOC_SEND_SELECTED_ITEM hbTrId("txt_shareui_send_selected_item") |
|
44 //#define LOC_BUTTON_CANCEL hbTrId("txt_shareui_button_cancel") |
|
45 //#define LOC_NO_SERVICES hbTrId("txt_shareui_no_services") |
|
46 //#define LOC_NO_FILES hbTrId("txt_shareui_no_files") |
|
47 //#define LOC_SERVICE_ERROR hbTrId("txt_shareui_service_error") |
|
48 //#define LOC_PROTECTED_CONTENT hbTrId("txt_shareui_protected_content") |
|
49 |
|
50 #define LOC_SEND_SELECTED_ITEM hbTrId("Send selected item") |
|
51 #define LOC_BUTTON_CANCEL hbTrId("Cancel") |
|
52 #define LOC_NO_SERVICES hbTrId("No services found.") |
|
53 #define LOC_NO_FILES hbTrId("No files found.") |
|
54 #define LOC_SERVICE_ERROR hbTrId("Service error.") |
|
55 #define LOC_PROTECTED_CONTENT hbTrId("Protected content.") |
|
56 |
|
57 /** |
|
58 * Constructor. |
|
59 */ |
32 ShareUiPrivate::ShareUiPrivate() |
60 ShareUiPrivate::ShareUiPrivate() |
33 { |
61 { |
34 |
62 mContentItemModel = 0; |
|
63 mContentListView = 0; |
|
64 mSharePopup = 0; |
35 } |
65 } |
36 |
66 |
37 /** |
67 /** |
38 * Destructor. |
68 * Destructor. |
39 */ |
69 */ |
40 ShareUiPrivate::~ShareUiPrivate() |
70 ShareUiPrivate::~ShareUiPrivate() |
41 { |
71 { |
42 if(mContentItemModel) |
72 reset(); |
|
73 } |
|
74 |
|
75 /** |
|
76 * Clear the internal data structures |
|
77 */ |
|
78 void ShareUiPrivate::reset() |
|
79 { |
|
80 mFileList.clear(); |
|
81 |
|
82 mIndexActionMap.clear(); // TODO Is there MEM leak. |
|
83 mAiwRequestList.clear(); // TODO Is there MEM leak. |
|
84 |
|
85 if ( mContentItemModel ) |
43 { |
86 { |
44 delete mContentItemModel; |
87 delete mContentItemModel; |
45 } |
88 mContentItemModel = 0; |
46 if(mContentListView) |
89 } |
|
90 |
|
91 if ( mContentListView ) |
47 { |
92 { |
48 delete mContentListView; |
93 delete mContentListView; |
49 } |
94 mContentListView = 0; |
50 if(mSharePopup) |
95 } |
|
96 |
|
97 if ( mSharePopup ) |
51 { |
98 { |
52 delete mSharePopup; |
99 delete mSharePopup; |
53 } |
100 mSharePopup = 0; |
54 mIndexActionMap.clear(); |
101 } |
55 mAiwRequestList.clear(); |
102 } |
56 mFileList.clear(); |
103 |
57 } |
104 /** |
58 |
105 * Initialize and start the dialog |
59 /** |
|
60 * initialize and start the dialog |
|
61 * |
106 * |
62 * @param fileList list of tokens that would allow file manipulation |
107 * @param fileList list of tokens that would allow file manipulation. |
63 * @return bool error false if dialog initialization failed, true otherwise. |
108 * @return bool error false if dialog initialization failed, true otherwise. |
64 * |
109 * |
65 */ |
110 */ |
66 bool ShareUiPrivate::init(QStringList& fileList, bool embedded) |
111 bool ShareUiPrivate::init(QStringList& fileList, bool embedded) |
67 { |
112 { |
68 bool retval = false; |
113 reset(); |
69 mFileList.clear(); |
114 |
70 |
115 // No input files |
71 if(fileList.count()) |
116 if ( fileList.count() == 0 ) |
72 { |
117 { |
73 for(int i = 0; i < fileList.count(); i++) |
118 showNote(LOC_NO_FILES); |
|
119 return true; |
|
120 } |
|
121 |
|
122 #ifdef __SHAREUI_MIME_HANDLING__ |
|
123 // Get the file attributes (MIME and forward lock) |
|
124 QStringList mimeTypeList; |
|
125 QStringList forwardStatusList; |
|
126 getFileAttributes(fileList, mimeTypeList, forwardStatusList); |
|
127 |
|
128 // Ignore protected files |
|
129 QStringList filteredFileList; |
|
130 QStringList filteredMimeList; |
|
131 for ( int i = 0; i < forwardStatusList.count(); i++ ) |
|
132 { |
|
133 if ( forwardStatusList[i].toInt() ) |
74 { |
134 { |
75 mFileList.append(QDir::toNativeSeparators(fileList[i])); |
135 filteredFileList << fileList[i]; |
|
136 filteredMimeList << mimeTypeList[i]; |
|
137 } |
|
138 } |
|
139 filteredMimeList.removeDuplicates(); |
|
140 |
|
141 // Some protected content |
|
142 if ( fileList.count() != filteredFileList.count() ) |
|
143 { |
|
144 showNote(LOC_PROTECTED_CONTENT); |
|
145 } |
|
146 |
|
147 // Only protected content |
|
148 if ( filteredFileList.count() == 0 ) |
|
149 { |
|
150 showNote(LOC_NO_FILES); |
|
151 return true; |
|
152 } |
|
153 #endif |
|
154 |
|
155 #ifdef __SHAREUI_MIME_HANDLING__ |
|
156 for ( int i = 0; i < filteredFileList.count(); i++ ) |
|
157 { |
|
158 mFileList.append(QDir::toNativeSeparators(filteredFileList[i])); |
|
159 } |
|
160 #else |
|
161 for ( int i = 0; i < fileList.count(); i++ ) |
|
162 { |
|
163 mFileList.append(QDir::toNativeSeparators(fileList[i])); |
|
164 } |
|
165 #endif |
|
166 |
|
167 QList<XQAiwInterfaceDescriptor> serviceDescriptorList = |
|
168 mAppManager.list(SERVICE_INTERFACE, SHARE_OP); |
|
169 if ( serviceDescriptorList.size() > 0 ) |
|
170 { |
|
171 initializeUi(); |
|
172 |
|
173 for ( int i = 0; i < serviceDescriptorList.count() ; i++ ) |
|
174 { |
|
175 #ifdef __SHAREUI_MIME_HANDLING__ |
|
176 // Filter services based on content type |
|
177 QString allowedTypes = serviceDescriptorList[i].customProperty |
|
178 (QString("allowed_mime_types")); |
|
179 QString blockedTypes = serviceDescriptorList[i].customProperty |
|
180 (QString("blocked_mime_types")); |
|
181 |
|
182 // Check against MIME filters |
|
183 if ( ! isContentAllowed( filteredMimeList, allowedTypes ) ) |
|
184 continue; |
|
185 |
|
186 if ( isContentBlocked( filteredMimeList, blockedTypes ) ) |
|
187 continue; |
|
188 #endif |
|
189 HbAction* action = fetchServiceAction(serviceDescriptorList[i]); |
|
190 QString iconName = serviceDescriptorList[i].customProperty |
|
191 (QString("aiw_action_icon")); |
|
192 if ( action ) |
|
193 { |
|
194 updateShareUiDialogList(action, iconName); |
|
195 } |
76 } |
196 } |
77 |
197 |
78 mIsEmbedded = embedded; |
198 if ( mContentItemModel->rowCount() == 0 ) |
79 |
|
80 initializeUi(); |
|
81 |
|
82 QList<XQAiwInterfaceDescriptor> serviceDescriptorList; |
|
83 mIndexActionMap.clear(); |
|
84 mAiwRequestList.clear(); |
|
85 if(fetchServiceDescriptors(serviceDescriptorList)) |
|
86 { |
199 { |
87 |
200 showNote(LOC_NO_SERVICES); |
88 HbAction* action; |
201 return true; |
89 |
202 } |
90 for(int i = 0; i < serviceDescriptorList.count() ; i++) |
203 |
91 { |
204 mSharePopup->exec(); |
92 |
205 } |
93 if((action = fetchServiceAction(serviceDescriptorList[i])) != NULL) |
206 else |
94 { |
207 { |
95 updateShareUiDialogList(action); |
208 showNote(LOC_NO_SERVICES); |
96 } |
209 } |
97 } |
210 |
98 retval = true; |
211 return true; |
99 } |
212 } |
100 else |
213 |
101 { |
214 /** |
102 updateShareUiDialogList(NULL); |
215 * Creates the view for the share ui. |
103 } |
|
104 |
|
105 enableUi(); |
|
106 } |
|
107 return retval; |
|
108 } |
|
109 |
|
110 /** |
|
111 * Creates the view for the sendui dialog. |
|
112 * |
|
113 * @return bool true if initialization was successful, false otherwise. |
|
114 */ |
216 */ |
115 |
|
116 void ShareUiPrivate::initializeUi() |
217 void ShareUiPrivate::initializeUi() |
117 { |
218 { |
|
219 // Dialog |
118 mSharePopup = new HbDialog(); |
220 mSharePopup = new HbDialog(); |
119 mSharePopup->setHeadingWidget(new HbLabel(LOC_SEND_SELECTED_ITEM)); |
221 |
|
222 HbTextItem* heading = new HbTextItem(LOC_SEND_SELECTED_ITEM, mSharePopup); |
|
223 heading->setAlignment(Qt::AlignCenter); |
|
224 mSharePopup->setHeadingWidget(heading); |
120 mSharePopup->setTimeout(HbDialog::NoTimeout); |
225 mSharePopup->setTimeout(HbDialog::NoTimeout); |
|
226 mSharePopup->setFrameType(HbDialog::Strong); |
|
227 mSharePopup->setPrimaryAction(new HbAction(LOC_BUTTON_CANCEL, mSharePopup)); |
|
228 |
|
229 // Content widget |
121 mContentListView = new HbListView(mSharePopup); |
230 mContentListView = new HbListView(mSharePopup); |
122 |
231 ShareListItem *prototype = new ShareListItem(mSharePopup); |
123 mContentItemModel = new QStandardItemModel(mSharePopup); |
232 mContentListView->setItemPrototype(prototype); |
124 mContentListView->setModel(mContentItemModel); |
233 |
|
234 mContentItemModel = new QStandardItemModel(mSharePopup); |
|
235 mContentListView->setModel(mContentItemModel); |
|
236 mContentListView->setUniformItemSizes(true); |
125 mSharePopup->setContentWidget(mContentListView); |
237 mSharePopup->setContentWidget(mContentListView); |
126 mSharePopup->setFrameType(HbDialog::Strong); |
238 connect(mContentListView, SIGNAL(activated(QModelIndex)), |
127 mSharePopup->setPrimaryAction(new HbAction(LOC_BUTTON_CANCEL)); |
239 this, SLOT(itemActivated(QModelIndex))); |
128 |
240 } |
129 connect(mContentListView, SIGNAL(activated(QModelIndex)),this,SLOT(itemActivated(QModelIndex))); |
|
130 |
|
131 } |
|
132 |
|
133 /** |
|
134 * fetchServiceDescriptors |
|
135 * |
|
136 * Fetches the service descriptors using the Application Manager api. |
|
137 * This function is in progress and will change. |
|
138 * |
|
139 * @return error boolean true if successfully fetched. |
|
140 */ |
|
141 |
|
142 bool ShareUiPrivate::fetchServiceDescriptors(QList<XQAiwInterfaceDescriptor>& serviceDescriptorList) |
|
143 { |
|
144 bool retval = false; |
|
145 |
|
146 serviceDescriptorList = mAppManager.list(SERVICE_INTERFACE, SHARE_OP); |
|
147 |
|
148 if(serviceDescriptorList.size() > 0) |
|
149 { |
|
150 retval = true; |
|
151 } |
|
152 return retval; |
|
153 } |
|
154 |
|
155 |
241 |
156 /** |
242 /** |
157 * fetchServiceAction fetches the action associated with a specified interface descriptor. |
243 * fetchServiceAction fetches the action associated with a specified interface descriptor. |
158 * This is used after the fetchServiceDescriptors is called, and |
244 * This is used after the fetchServiceDescriptors is called, and |
159 * |
245 */ |
160 * @param serviceDescriptor ServiceDescriptor fetched using fetchServiceDescriptors |
246 HbAction* ShareUiPrivate::fetchServiceAction |
161 * @return error boolean true if successfully fetched. |
247 (XQAiwInterfaceDescriptor interfaceDescriptor) |
162 */ |
248 { |
163 |
249 XQAiwRequest* request = mAppManager.create(interfaceDescriptor, |
164 HbAction* ShareUiPrivate::fetchServiceAction(XQAiwInterfaceDescriptor interfaceDescriptor) |
250 SHARE_OP, mIsEmbedded); |
165 { |
|
166 |
|
167 XQAiwRequest* request = mAppManager.create(interfaceDescriptor,SHARE_OP,mIsEmbedded); |
|
168 mAiwRequestList.append(request); |
251 mAiwRequestList.append(request); |
|
252 |
169 HbAction* action = convertAction(request->createAction()); |
253 HbAction* action = convertAction(request->createAction()); |
170 if(action) |
254 if ( action ) |
171 { |
255 { |
172 connect(request, SIGNAL(triggered()), this, SLOT(onTriggered())); |
256 connect(request, SIGNAL(triggered()), this, SLOT(onTriggered())); |
173 connect(request, SIGNAL(requestOk(const QVariant&)), this, SLOT(handleOk(const QVariant&))); |
257 connect(request, SIGNAL(requestOk(const QVariant&)), this, |
174 connect(request, SIGNAL(requestError(int,const QString&)), this, SLOT(handleError(int,const QString&))); |
258 SLOT(handleOk(const QVariant&))); |
|
259 connect(request, SIGNAL(requestError(int,const QString&)), this, |
|
260 SLOT(handleError(int,const QString&))); |
175 } |
261 } |
176 return action; |
262 return action; |
177 } |
263 } |
178 |
264 |
179 |
265 |
180 /** |
266 /** |
181 * Update the SendUi Dialog (and associated list items) once the required |
267 * Update the SendUi Dialog (and associated list items) once the required |
182 * information has been fetched. |
268 * information has been fetched. |
183 * |
269 */ |
184 * @params action HbAction* The action that must be associated with the entry at that point in the list. |
270 void ShareUiPrivate::updateShareUiDialogList(HbAction* action, QString iconName) |
185 */ |
271 { |
186 |
272 QStandardItem* item = new QStandardItem(); |
187 |
273 item->setData(action->text(), ProviderNameRole); |
188 bool ShareUiPrivate::updateShareUiDialogList(HbAction* action) |
274 item->setData(iconName, ProviderIconRole); |
189 { |
275 mContentItemModel->appendRow(item); |
190 |
276 QModelIndex index = item->index(); |
191 bool retval = false; |
277 mIndexActionMap[index] = action; |
192 QStandardItem* item = NULL; |
278 } |
193 if(action != NULL) |
279 |
194 { |
280 /** |
195 item = new QStandardItem(action->icon().qicon(),action->text()); |
281 * Slot for handling send service selection on the UI. |
196 mContentItemModel->appendRow(item); |
282 */ |
197 QModelIndex index = item->index(); |
|
198 mIndexActionMap[index] = action; |
|
199 retval = true; |
|
200 } |
|
201 else |
|
202 { |
|
203 item = new QStandardItem(QString("No Services Found")); |
|
204 mContentItemModel->appendRow(item); |
|
205 } |
|
206 return retval; |
|
207 |
|
208 } |
|
209 |
|
210 |
|
211 /** |
|
212 * |
|
213 * Enable the UI and show it on the screen. |
|
214 * |
|
215 * |
|
216 */ |
|
217 |
|
218 void ShareUiPrivate::enableUi() |
|
219 { |
|
220 mSharePopup->exec(); |
|
221 } |
|
222 |
|
223 /** |
|
224 * Slot for handling send service selection on the UI |
|
225 * |
|
226 */ |
|
227 |
|
228 |
|
229 void ShareUiPrivate::onTriggered(void) |
283 void ShareUiPrivate::onTriggered(void) |
230 { |
284 { |
231 |
|
232 XQAiwRequest* request = 0; |
285 XQAiwRequest* request = 0; |
233 request = qobject_cast<XQAiwRequest*>(sender()); |
286 request = qobject_cast<XQAiwRequest*>(sender()); |
234 if(request) |
287 if(request) |
235 { |
288 { |
236 request->setArguments(mFileList); |
289 QList<QVariant> args; |
|
290 QVariant fileList(mFileList); |
|
291 args << fileList; |
|
292 request->setArguments(args); |
237 } |
293 } |
238 } |
294 } |
239 |
295 |
240 /** |
296 /** |
241 * Slot for handling valid returns from the framework. |
297 * Slot for handling valid returns from the framework. |
242 * |
298 */ |
243 * @param result const QVariant& |
|
244 */ |
|
245 |
|
246 void ShareUiPrivate::handleOk(const QVariant& result) |
299 void ShareUiPrivate::handleOk(const QVariant& result) |
247 { |
300 { |
248 Q_UNUSED(result) |
301 Q_UNUSED(result) |
249 } |
302 } |
250 |
303 |
251 /** |
304 /** |
252 * Slot for handling errors. Error ids are provided as |
305 * Slot for handling errors from the framework. |
253 * 32-bit integers. These are |
|
254 * |
|
255 * @param errorCode qint32 |
|
256 * |
|
257 * |
|
258 */ |
306 */ |
259 void ShareUiPrivate::handleError(int errorCode, const QString& errorMessage) |
307 void ShareUiPrivate::handleError(int errorCode, const QString& errorMessage) |
260 { |
308 { |
|
309 Q_UNUSED(errorCode) |
261 Q_UNUSED(errorMessage) |
310 Q_UNUSED(errorMessage) |
262 QString errText("IPC Error: "); |
311 |
263 HbNotificationDialog* dlg = new HbNotificationDialog(); |
312 showNote(LOC_SERVICE_ERROR); |
264 dlg->setFocusPolicy(Qt::NoFocus); |
313 } |
265 dlg->setAttribute(Qt::WA_DeleteOnClose, true); |
|
266 |
|
267 |
|
268 switch(errorCode) |
|
269 { |
|
270 case XQService::EConnectionError: |
|
271 errText.append(QString("EConnectionError: ")); |
|
272 break; |
|
273 case XQService::EConnectionClosed: |
|
274 errText.append(QString("EConnectionClosed: ")); |
|
275 break; |
|
276 case XQService::EServerNotFound: |
|
277 errText.append(QString("EServerNotFound: ")); |
|
278 break; |
|
279 case XQService::EIPCError: |
|
280 errText.append(QString("EIPCError: ")); |
|
281 break; |
|
282 case XQService::EUnknownError: |
|
283 errText.append(QString("EUnknownError: ")); |
|
284 break; |
|
285 case XQService::ERequestPending: |
|
286 errText.append(QString("ERequestPending: ")); |
|
287 break; |
|
288 } |
|
289 errText.append(errorMessage); |
|
290 dlg->setText(errText); |
|
291 dlg->show(); |
|
292 } |
|
293 |
|
294 |
|
295 |
314 |
296 /** |
315 /** |
297 * When a list box item is pressed, this slot should be invoked. The action |
316 * When a list box item is pressed, this slot should be invoked. The action |
298 * corresponding to the clicked list item should be invoked with the stored lis |
317 * corresponding to the clicked list item should be invoked with the stored lis |
299 * of files. |
318 * of files. |
300 * |
319 * |
301 * @param index QModelIndex |
320 * @param index QModelIndex |
302 * |
|
303 */ |
321 */ |
304 |
322 |
305 void ShareUiPrivate::itemActivated(QModelIndex index) |
323 void ShareUiPrivate::itemActivated(QModelIndex index) |
306 { |
324 { |
307 |
|
308 HbAction* action = mIndexActionMap[index]; |
325 HbAction* action = mIndexActionMap[index]; |
309 |
326 |
310 if(action) |
327 if ( action ) |
311 { |
328 { |
312 action->setEnabled(true); |
329 action->setEnabled(true); |
313 action->activate(HbAction::Trigger); |
330 action->activate(HbAction::Trigger); |
314 } |
331 } |
315 mSharePopup->close(); |
332 mSharePopup->close(); |
316 |
|
317 } |
333 } |
318 |
334 |
319 |
335 |
320 /** |
336 /** |
321 * Convert a qaction to hbaction. |
337 * Convert a qaction to hbaction. |
322 * |
338 * |
323 * @param action QAction* |
339 * @param action QAction* |
324 * @return HbAction* |
340 * @return HbAction* |
325 */ |
341 */ |
326 |
|
327 HbAction* ShareUiPrivate::convertAction(QAction *action) |
342 HbAction* ShareUiPrivate::convertAction(QAction *action) |
328 { |
343 { |
329 HbAction *actionHb = 0; |
344 HbAction *actionHb = 0; |
330 if (action) |
345 if (action) |
331 { |
346 { |
342 action->setParent(actionHb); |
357 action->setParent(actionHb); |
343 } |
358 } |
344 |
359 |
345 return actionHb; |
360 return actionHb; |
346 } |
361 } |
|
362 |
|
363 #ifdef __SHAREUI_MIME_HANDLING__ |
|
364 /** |
|
365 * Checks if the specified content type is allowed as per the |
|
366 * specified MIME pattern strings |
|
367 */ |
|
368 bool ShareUiPrivate::isContentAllowed( QStringList mimeType, |
|
369 QString mimePattern ) |
|
370 { |
|
371 if ( mimePattern.trimmed().length() == 0 ) |
|
372 return true; |
|
373 |
|
374 QStringList patterns = mimePattern.split(","); |
|
375 |
|
376 for ( QStringList::Iterator it = mimeType.begin(); |
|
377 it != mimeType.end(); ++it ) |
|
378 { |
|
379 bool match = false; |
|
380 for ( QStringList::Iterator it1 = patterns.begin(); |
|
381 it1 != patterns.end(); ++it1 ) |
|
382 { |
|
383 QString pattern = (*it1).trimmed(); |
|
384 QRegExp rx(pattern, Qt::CaseInsensitive, QRegExp::Wildcard); |
|
385 // Not case sensitive, wild cards allowed |
|
386 if ( rx.exactMatch( *it ) ) |
|
387 { |
|
388 match = true; |
|
389 break; |
|
390 } |
|
391 } |
|
392 |
|
393 if ( ! match ) |
|
394 { |
|
395 return false; |
|
396 } |
|
397 } |
|
398 |
|
399 return true; |
|
400 } |
|
401 |
|
402 /** |
|
403 * Checks if the specified content type is allowed as per the |
|
404 * specified MIME pattern strings |
|
405 */ |
|
406 bool ShareUiPrivate::isContentBlocked( QStringList mimeType, |
|
407 QString mimePattern ) |
|
408 { |
|
409 if ( mimePattern.trimmed().length() == 0 ) |
|
410 return false; |
|
411 |
|
412 QStringList patterns = mimePattern.split(","); |
|
413 |
|
414 for ( QStringList::Iterator it = mimeType.begin(); |
|
415 it != mimeType.end(); ++it ) |
|
416 { |
|
417 bool match = false; |
|
418 for ( QStringList::Iterator it1 = patterns.begin(); |
|
419 it1 != patterns.end(); ++it1 ) |
|
420 { |
|
421 QString pattern = (*it1).trimmed(); |
|
422 QRegExp rx(pattern, Qt::CaseInsensitive, QRegExp::Wildcard); |
|
423 // Not case sensitive, wild cards allowed |
|
424 if ( rx.exactMatch( *it ) ) |
|
425 { |
|
426 match = true; |
|
427 break; |
|
428 } |
|
429 } |
|
430 |
|
431 if ( match ) |
|
432 { |
|
433 return true; |
|
434 } |
|
435 } |
|
436 |
|
437 return false; |
|
438 } |
|
439 |
|
440 /** |
|
441 * Get the file MIME types and forward status |
|
442 */ |
|
443 void ShareUiPrivate::getFileAttributes |
|
444 (QStringList& fileList, QStringList& mimeTypeList, QStringList& forwardStatusList) |
|
445 { |
|
446 // Attributes to read |
|
447 QList<int> attrNames; |
|
448 attrNames.append(XQApplicationManager::MimeType); |
|
449 attrNames.append(XQApplicationManager::IsForwardable); |
|
450 |
|
451 for ( QStringList::Iterator it = fileList.begin(); |
|
452 it != fileList.end(); ++it ) |
|
453 { |
|
454 QFile file(*it); |
|
455 QVariantList attrValues; |
|
456 bool ok = mAppManager.getDrmAttributes(file, attrNames, attrValues); |
|
457 if ( !ok ) |
|
458 { |
|
459 mimeTypeList << QString(); |
|
460 forwardStatusList << QString("1"); // Forward ok. |
|
461 continue; |
|
462 } |
|
463 |
|
464 int i = 0; |
|
465 foreach (QVariant v, attrValues) |
|
466 { |
|
467 if ( attrNames[i] == XQApplicationManager::MimeType ) |
|
468 mimeTypeList << v.toString(); |
|
469 if ( attrNames[i] == XQApplicationManager::IsForwardable ) |
|
470 forwardStatusList << v.toString(); |
|
471 i++; |
|
472 } |
|
473 } |
|
474 } |
|
475 #endif |
|
476 |
|
477 /** |
|
478 * Show notes |
|
479 */ |
|
480 void ShareUiPrivate::showNote(QString text) |
|
481 { |
|
482 HbNotificationDialog* dlg = new HbNotificationDialog(); |
|
483 dlg->setFocusPolicy(Qt::NoFocus); |
|
484 dlg->setAttribute(Qt::WA_DeleteOnClose, true); |
|
485 dlg->setText(text); |
|
486 dlg->show(); |
|
487 } |
|
488 |
|
489 /** |
|
490 * List item prototype constructor. |
|
491 */ |
|
492 ShareListItem::ShareListItem(QGraphicsItem* parent) : |
|
493 HbListViewItem(parent), |
|
494 mProviderName(NULL), |
|
495 mProviderIcon(NULL) |
|
496 { |
|
497 } |
|
498 |
|
499 /** |
|
500 * @see HbListViewItem |
|
501 */ |
|
502 HbAbstractViewItem* ShareListItem::createItem() |
|
503 { |
|
504 return new ShareListItem(*this); |
|
505 } |
|
506 |
|
507 /** |
|
508 * @see HbListViewItem |
|
509 */ |
|
510 void ShareListItem::updateChildItems() |
|
511 { |
|
512 QGraphicsLinearLayout *layout = |
|
513 new QGraphicsLinearLayout(Qt::Horizontal, this); |
|
514 |
|
515 if (!mProviderIcon) |
|
516 { |
|
517 QVariant iconName = modelIndex().data(ProviderIconRole); |
|
518 mProviderIcon = new HbIconItem(HbIcon(iconName.toString()), this); |
|
519 } |
|
520 |
|
521 if (!mProviderName) |
|
522 { |
|
523 QVariant name = modelIndex().data(ProviderNameRole); |
|
524 mProviderName = new HbTextItem(name.toString(), this); |
|
525 } |
|
526 |
|
527 layout->addItem(mProviderIcon); |
|
528 layout->addItem(mProviderName); |
|
529 |
|
530 HbListViewItem::updateChildItems(); |
|
531 } |
|
532 |
|
533 // End of file |
|
534 |