|
1 /* |
|
2 * Copyright (c) 2010 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 |
|
18 #include "enginewrapper.h" |
|
19 #include "engine.h" |
|
20 #include "FBFileUtils.h" |
|
21 #include "notifications.h" |
|
22 #include "fbfileview.h" |
|
23 #include "searchview.h" |
|
24 #include "filebrowsersettings.h" |
|
25 #include "settingsview.h" |
|
26 |
|
27 #include <HbProgressDialog> |
|
28 |
|
29 #include <QString> |
|
30 #include <QFileInfo> |
|
31 #include <QModelIndex> |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 |
|
35 EngineWrapper::EngineWrapper() |
|
36 : mEngine(0), |
|
37 mFilesFound(), |
|
38 mSettings(0), |
|
39 mProgressDialog(0), |
|
40 mWaitDialog(0) |
|
41 { |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 |
|
46 EngineWrapper::~EngineWrapper() |
|
47 { |
|
48 if(mEngine != NULL) { |
|
49 TRAP_IGNORE(mEngine->DeActivateEngineL()); |
|
50 delete mEngine; |
|
51 } |
|
52 if (mProgressDialog) |
|
53 delete mProgressDialog; |
|
54 |
|
55 if (mWaitDialog) |
|
56 delete mWaitDialog; |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 |
|
61 bool EngineWrapper::init() |
|
62 { |
|
63 TRAPD(err, mEngine = CEngine::NewL(this)); |
|
64 if (err != KErrNone) { |
|
65 return false; |
|
66 } else { |
|
67 TRAP_IGNORE(mEngine->ActivateEngineL()); |
|
68 mSettings = FileBrowserSettings(&mEngine->Settings()); |
|
69 return true; |
|
70 } |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // Functions that are called from UI |
|
75 // --------------------------------------------------------------------------- |
|
76 bool EngineWrapper::searchFiles() |
|
77 { |
|
78 TRAPD(err, mEngine->SearchL() ); |
|
79 if(err != KErrNone) { |
|
80 return false; |
|
81 } |
|
82 else { |
|
83 return true; |
|
84 } |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 SearchAttributes EngineWrapper::getFileSearchAttributes() |
|
89 { |
|
90 TSearchAttributes tAttributes = mEngine->GetSearchAttributes(); |
|
91 SearchAttributes attributes; |
|
92 |
|
93 // Convert TSearchAttributes to SearchAttributes |
|
94 attributes.mSearchDir = QString((QChar*)tAttributes.iSearchDir.Ptr(),tAttributes.iSearchDir.Length()); |
|
95 attributes.mWildCards = QString((QChar*)tAttributes.iWildCards.Ptr(),tAttributes.iWildCards.Length()); |
|
96 attributes.mTextInFile = QString((QChar*)tAttributes.iTextInFile.Ptr(),tAttributes.iTextInFile.Length()); |
|
97 attributes.mMinSize = tAttributes.iMinSize; |
|
98 attributes.mMaxSize = tAttributes.iMaxSize; |
|
99 attributes.mRecurse = tAttributes.iRecurse; |
|
100 |
|
101 // TTime to QDate |
|
102 TBuf<20> timeString; |
|
103 _LIT(KDateString,"%D%M%Y%/0%1%/1%2%/2%3%/3"); |
|
104 TRAP_IGNORE( tAttributes.iMinDate.FormatL(timeString, KDateString) ); |
|
105 QString temp = QString::fromUtf16(timeString.Ptr(), timeString.Length()); |
|
106 temp.replace(QChar('/'), QChar('-')); |
|
107 attributes.mMinDate = QDate::fromString(temp, "dd-MM-yyyy"); |
|
108 |
|
109 |
|
110 TRAP_IGNORE( tAttributes.iMaxDate.FormatL(timeString, KDateString) ); |
|
111 temp = QString::fromUtf16(timeString.Ptr(), timeString.Length()); |
|
112 temp.replace(QChar('/'), QChar('-')); |
|
113 attributes.mMaxDate = QDate::fromString(temp, "dd-MM-yyyy"); |
|
114 |
|
115 return attributes; |
|
116 |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 int EngineWrapper::setFileSearchAttributes(SearchAttributes attributes) |
|
121 { |
|
122 TSearchAttributes tAttributes; |
|
123 // Convert SearchAttributes to TSearchAttributes |
|
124 |
|
125 //convert QString to TFilename: |
|
126 tAttributes.iSearchDir = TFileName(attributes.mSearchDir.utf16()); |
|
127 tAttributes.iWildCards = TFileName(attributes.mWildCards.utf16()); |
|
128 tAttributes.iTextInFile = TFileName(attributes.mTextInFile.utf16()); |
|
129 |
|
130 tAttributes.iMinSize = attributes.mMinSize; |
|
131 tAttributes.iMaxSize = attributes.mMaxSize; |
|
132 tAttributes.iRecurse = attributes.mRecurse; |
|
133 |
|
134 // QDate to TTime for both min- and max Date |
|
135 QString temp = attributes.mMinDate.toString("yyyy-MM-dd"); |
|
136 QStringList dateList = temp.split("-"); |
|
137 int month = dateList[1].toInt() - 1; |
|
138 int day = dateList[2].toInt() - 1; |
|
139 temp = dateList[0]; |
|
140 if (month == 0) { |
|
141 temp.append("00"); |
|
142 } |
|
143 else { |
|
144 temp.append(QString::number(month)); |
|
145 } |
|
146 if (day == 0) { |
|
147 temp.append("00"); |
|
148 } |
|
149 else { |
|
150 temp.append(QString::number(day)); |
|
151 } |
|
152 temp.append(":"); |
|
153 |
|
154 TBuf<24> dateString(temp.utf16()); |
|
155 tAttributes.iMinDate.Set(dateString); |
|
156 |
|
157 temp = attributes.mMaxDate.toString("yyyy-MM-dd"); |
|
158 dateList = temp.split("-"); |
|
159 month = dateList[1].toInt() - 1; |
|
160 day = dateList[2].toInt() - 1; |
|
161 temp = dateList[0]; |
|
162 if (month == 0) { |
|
163 temp.append("00"); |
|
164 } |
|
165 else { |
|
166 temp.append(QString::number(month)); |
|
167 } |
|
168 if (day == 0) { |
|
169 temp.append("00"); |
|
170 } |
|
171 else { |
|
172 temp.append(QString::number(day)); |
|
173 } |
|
174 temp.append(":"); |
|
175 dateString.Copy(temp.utf16()); |
|
176 tAttributes.iMaxDate.Set(dateString); |
|
177 |
|
178 mEngine->ChangeAttributes(tAttributes); |
|
179 return KErrNone; |
|
180 } |
|
181 |
|
182 |
|
183 // --------------------------------------------------------------------------- |
|
184 SearchResults EngineWrapper::getSearchResults() |
|
185 { |
|
186 TSearchResults tResults = mEngine->SearchResults(); |
|
187 SearchResults results; |
|
188 results.mNumberOfFoundFiles = tResults.iNumberOfFoundFiles; |
|
189 CFileEntryList* foundFilesResult = mEngine->FoundFiles(); |
|
190 if (!mFilesFound.isEmpty()) { |
|
191 mFilesFound.clear(); |
|
192 } |
|
193 // copy file names and convert them from TFileName format to QStringList items type |
|
194 for (int i = 0; i < foundFilesResult->Count(); i++) { |
|
195 mFilesFound.append( |
|
196 QString((QChar*)foundFilesResult->At(i).iFullName.Ptr(), |
|
197 foundFilesResult->At(i).iFullName.Length()) |
|
198 ); |
|
199 } |
|
200 results.mFoundFilesList = &mFilesFound; |
|
201 return results; |
|
202 } |
|
203 |
|
204 // --------------------------------------------------------------------------- |
|
205 |
|
206 void EngineWrapper::saveSettings(bool aNotifyModules) |
|
207 { |
|
208 return mEngine->SaveSettingsL(aNotifyModules);; |
|
209 } |
|
210 |
|
211 // --------------------------------------------------------------------------- |
|
212 |
|
213 bool EngineWrapper::isDriveListViewActive() |
|
214 { |
|
215 // TODO check return value |
|
216 if (mEngine->FileUtils() && mEngine->FileUtils()->IsDriveListViewActive()) { |
|
217 return true; |
|
218 } else { |
|
219 return false; |
|
220 } |
|
221 } |
|
222 |
|
223 bool EngineWrapper::isCurrentDriveReadOnly() |
|
224 { |
|
225 // TODO check return value |
|
226 if (mEngine->FileUtils() && mEngine->FileUtils()->IsCurrentDriveReadOnly()) { |
|
227 return true; |
|
228 } else { |
|
229 return false; |
|
230 } |
|
231 } |
|
232 |
|
233 bool EngineWrapper::isClipBoardListInUse() |
|
234 { |
|
235 if (mEngine->FileUtils() && mEngine->FileUtils()->ClipBoardList() && mEngine->FileUtils()->ClipBoardList()->Count() != 0) |
|
236 return true; |
|
237 else |
|
238 return false; |
|
239 } |
|
240 |
|
241 // --------------------------------------------------------------------------- |
|
242 void EngineWrapper::startExecutingCommands(const QString &aCommandsExecutionMessage) |
|
243 { |
|
244 TPtrC commandsExecutionMessage(reinterpret_cast<const TText*>(aCommandsExecutionMessage.constData())); |
|
245 TRAPD(err, mEngine->FileUtils()->StartExecutingCommandsL(commandsExecutionMessage) ); |
|
246 Q_UNUSED(err); //TODO |
|
247 } |
|
248 |
|
249 // --------------------------------------------------------------------------- |
|
250 |
|
251 void EngineWrapper::refreshView() |
|
252 { |
|
253 if (mEngine->FileUtils()) { |
|
254 TRAPD(err, mEngine->FileUtils()->RefreshViewL() ); |
|
255 Q_UNUSED(err); //TODO |
|
256 } |
|
257 } |
|
258 |
|
259 void EngineWrapper::moveUpOneLevel() |
|
260 { |
|
261 if (mEngine->FileUtils()) { |
|
262 TRAPD(err, mEngine->FileUtils()->MoveUpOneLevelL() ); |
|
263 Q_UNUSED(err); //TODO |
|
264 } |
|
265 } |
|
266 |
|
267 // --------------------------------------------------------------------------- |
|
268 |
|
269 void EngineWrapper::moveDownToDirectory(const QModelIndex& aIndex) |
|
270 { |
|
271 if (mEngine->FileUtils()) { |
|
272 TRAPD(err, mEngine->FileUtils()->MoveDownToDirectoryL(aIndex.row()) ); |
|
273 Q_UNUSED(err); //TODO |
|
274 } |
|
275 } |
|
276 |
|
277 // --------------------------------------------------------------------------- |
|
278 |
|
279 int EngineWrapper::clipboardCut(const QModelIndexList& aSelectionIndices) |
|
280 { |
|
281 TInt operations = 0; |
|
282 const CArrayFix<TInt> *selectionIndexes = convertSelectionList(aSelectionIndices); |
|
283 if (mEngine->FileUtils()) { |
|
284 TRAPD(err, operations = mEngine->FileUtils()->ClipboardCutL(selectionIndexes) ); |
|
285 Q_UNUSED(err); //TODO |
|
286 } |
|
287 delete selectionIndexes; |
|
288 return operations; |
|
289 } |
|
290 |
|
291 // --------------------------------------------------------------------------- |
|
292 int EngineWrapper::clipboardCopy(const QModelIndexList& aSelectionIndices) |
|
293 { |
|
294 TInt operations = 0; |
|
295 const CArrayFix<TInt> *selectionIndexes = convertSelectionList(aSelectionIndices); |
|
296 |
|
297 if (mEngine->FileUtils()) { |
|
298 TRAPD(err, operations = mEngine->FileUtils()->ClipboardCopyL(selectionIndexes)); |
|
299 Q_UNUSED(err); //TODO |
|
300 } |
|
301 delete selectionIndexes; |
|
302 return operations; |
|
303 } |
|
304 |
|
305 // --------------------------------------------------------------------------- |
|
306 |
|
307 void EngineWrapper::clipboardPaste(const OverwriteOptions &aOverwriteOptions) |
|
308 { |
|
309 TOverwriteOptions tOverwriteOptions = convertOverwriteOptions(aOverwriteOptions); |
|
310 if (mEngine->FileUtils()) { |
|
311 TRAPD(err, mEngine->FileUtils()->ClipboardPasteL(tOverwriteOptions)); |
|
312 Q_UNUSED(err); //TODO |
|
313 } |
|
314 } |
|
315 |
|
316 // --------------------------------------------------------------------------- |
|
317 |
|
318 void EngineWrapper::copyToFolder(const QString &aTargetDir, const OverwriteOptions &aOverwriteOptions, bool aMove) |
|
319 { |
|
320 TFileName targetDir = TFileName(aTargetDir.utf16()); |
|
321 TOverwriteOptions tOverwriteOptions = convertOverwriteOptions(aOverwriteOptions); |
|
322 |
|
323 |
|
324 TRAPD(err, mEngine->FileUtils()->CopyToFolderL(targetDir, tOverwriteOptions, aMove ? ETrue : EFalse) ); |
|
325 Q_UNUSED(err); //TODO |
|
326 } |
|
327 |
|
328 // --------------------------------------------------------------------------- |
|
329 |
|
330 void EngineWrapper::createNewFile(const QString &aNewFileName) |
|
331 { |
|
332 TFileName fileName = TFileName(aNewFileName.utf16()); |
|
333 TRAPD(err, mEngine->FileUtils()->NewFileL(fileName) ); |
|
334 Q_UNUSED(err); //TODO |
|
335 } |
|
336 |
|
337 // --------------------------------------------------------------------------- |
|
338 |
|
339 void EngineWrapper::createNewDirectory(const QString &aNewDirectoryName) |
|
340 { |
|
341 TFileName newDirectoryName = TFileName(aNewDirectoryName.utf16()); |
|
342 TRAPD(err, mEngine->FileUtils()->NewDirectoryL(newDirectoryName) ); |
|
343 Q_UNUSED(err); //TODO |
|
344 } |
|
345 |
|
346 // --------------------------------------------------------------------------- |
|
347 |
|
348 void EngineWrapper::deleteItems(const QModelIndexList& aSelectionIndices) |
|
349 { |
|
350 setCurrentSelection(aSelectionIndices); |
|
351 TRAPD(err, mEngine->FileUtils()->DeleteL() ); |
|
352 Q_UNUSED(err); //TODO |
|
353 } |
|
354 |
|
355 // --------------------------------------------------------------------------- |
|
356 bool EngineWrapper::selectionHasDirs() |
|
357 { |
|
358 return mEngine->FileUtils()->SelectionHasDirs(); |
|
359 } |
|
360 |
|
361 // --------------------------------------------------------------------------- |
|
362 |
|
363 void EngineWrapper::rename(const QModelIndex& aIndex, const QString aNewName) |
|
364 { |
|
365 if (mEngine->FileUtils()) { |
|
366 const TFileName newName = TFileName(aNewName.utf16()); |
|
367 TRAPD(err, mEngine->FileUtils()->RenameL(aIndex.row(), newName) ); |
|
368 Q_UNUSED(err); //TODO |
|
369 } |
|
370 } |
|
371 |
|
372 // --------------------------------------------------------------------------- |
|
373 |
|
374 void EngineWrapper::touch(bool aRecurse) |
|
375 { |
|
376 if (mEngine->FileUtils()) { |
|
377 TRAPD(err, mEngine->FileUtils()->TouchL(aRecurse) ); |
|
378 Q_UNUSED(err); //TODO |
|
379 } |
|
380 } |
|
381 |
|
382 // --------------------------------------------------------------------------- |
|
383 |
|
384 void EngineWrapper::properties(const QModelIndex &aCurrentItemIndex, QStringList &aPropertyList, QString &aTitleText) |
|
385 { |
|
386 if (mEngine->FileUtils()) { |
|
387 |
|
388 // create an array for the items |
|
389 CDesCArray* entryLines = new(ELeave) CDesCArrayFlat(16); |
|
390 // CleanupStack::PushL(entryLines); |
|
391 TFileName titleText; |
|
392 |
|
393 TRAPD(err, mEngine->FileUtils()->PropertiesL(aCurrentItemIndex.row(), entryLines, titleText)); |
|
394 Q_UNUSED(err); //TODO |
|
395 |
|
396 aTitleText = QString::fromUtf16(titleText.Ptr(), titleText.Length()); |
|
397 QString textItem; |
|
398 for (TInt i = 0; i < entryLines->Count(); ++i) { |
|
399 textItem = QString::fromUtf16((*entryLines)[i].Ptr(), (*entryLines)[i].Length()); |
|
400 aPropertyList.append(textItem); |
|
401 } |
|
402 // CleanupStack::PopAndDestroy(); //entryLines |
|
403 delete entryLines; |
|
404 } |
|
405 } |
|
406 // --------------------------------------------------------------------------- |
|
407 |
|
408 bool EngineWrapper::openAppArc(QString fileName) |
|
409 { |
|
410 |
|
411 //convert QString to TFilename: |
|
412 fileName.replace("/", "\\"); |
|
413 TFileName fileToOpen = TFileName(fileName.utf16()); |
|
414 |
|
415 TRAPD(err, mEngine->OpenWithApparcL(fileToOpen) ); |
|
416 if(err != KErrNone) { |
|
417 return false; |
|
418 } else { |
|
419 return true; |
|
420 } |
|
421 } |
|
422 |
|
423 // --------------------------------------------------------------------------- |
|
424 |
|
425 bool EngineWrapper::openDocHandler(QString fileName, bool embeddedVal) |
|
426 { |
|
427 //convert QString to TFilename: |
|
428 fileName.replace("/", "\\"); |
|
429 TFileName fileToOpen = TFileName(fileName.utf16()); |
|
430 |
|
431 TRAPD(err, mEngine->OpenWithDocHandlerL(fileToOpen, embeddedVal) ); |
|
432 if(err != KErrNone) { |
|
433 return false; |
|
434 } else { |
|
435 return true; |
|
436 } |
|
437 } |
|
438 |
|
439 // --------------------------------------------------------------------------- |
|
440 |
|
441 int EngineWrapper::itemCount() const |
|
442 { |
|
443 if (mEngine->FileUtils()->IsDriveListViewActive()) { |
|
444 return mEngine->FileUtils()->DriveEntries()->Count(); |
|
445 } else { |
|
446 return mEngine->FileUtils()->FileEntries()->Count(); |
|
447 } |
|
448 } |
|
449 |
|
450 // --------------------------------------------------------------------------- |
|
451 |
|
452 DriveEntry EngineWrapper::getDriveEntry(const QModelIndex& aIndex) const |
|
453 { |
|
454 TDriveEntry driveEntry; |
|
455 if (mEngine->FileUtils()->DriveEntries()->Count() > aIndex.row() && aIndex.row() >= 0) { |
|
456 driveEntry = mEngine->FileUtils()->DriveEntries()->At(aIndex.row()); |
|
457 } |
|
458 return DriveEntry(driveEntry); |
|
459 } |
|
460 |
|
461 // --------------------------------------------------------------------------- |
|
462 |
|
463 FileEntry EngineWrapper::getFileEntry(const QModelIndex& aIndex) const |
|
464 { |
|
465 TFileEntry fileEntry; |
|
466 if (mEngine->FileUtils()->FileEntries()->Count() > aIndex.row() && aIndex.row() >= 0) { |
|
467 fileEntry = mEngine->FileUtils()->FileEntries()->At(aIndex.row()); |
|
468 } |
|
469 return FileEntry(fileEntry); |
|
470 } |
|
471 |
|
472 // --------------------------------------------------------------------------- |
|
473 |
|
474 const CArrayFix<TInt> *EngineWrapper::convertSelectionList(const QModelIndexList &aSelectionIndices) |
|
475 { |
|
476 CArrayFixFlat<TInt>* selectionIndexes = 0; |
|
477 TRAPD(err, selectionIndexes = new(ELeave)CArrayFixFlat<TInt>(4)); |
|
478 if (err != KErrNone) { |
|
479 return 0; |
|
480 } |
|
481 |
|
482 for (int i=0; i< aSelectionIndices.count(); ++i) { |
|
483 TRAPD(err, selectionIndexes->AppendL(aSelectionIndices.at(i).row()) ); |
|
484 Q_UNUSED(err); //TODO |
|
485 } |
|
486 return selectionIndexes; |
|
487 } |
|
488 |
|
489 |
|
490 // --------------------------------------------------------------------------- |
|
491 |
|
492 void EngineWrapper::setCurrentSelection(const QModelIndexList &aSelectionIndices) |
|
493 { |
|
494 const CArrayFix<TInt> *selectionIndexes = convertSelectionList(aSelectionIndices); |
|
495 mEngine->FileUtils()->SetCurrentSelection(selectionIndexes); |
|
496 delete selectionIndexes; |
|
497 } |
|
498 |
|
499 // --------------------------------------------------------------------------- |
|
500 |
|
501 bool EngineWrapper::isDestinationEntriesExists(const QModelIndexList &aSelectionIndices, QString aTargetDir) |
|
502 { |
|
503 TFileName targetDir = TFileName(aTargetDir.utf16()); |
|
504 setCurrentSelection(aSelectionIndices); |
|
505 |
|
506 TBool someEntryExists = mEngine->FileUtils()->IsDestinationEntriesExists(targetDir); |
|
507 return someEntryExists; |
|
508 } |
|
509 |
|
510 // --------------------------------------------------------------------------- |
|
511 bool EngineWrapper::targetExists(const QModelIndex& aIndex, const QString aNewName) |
|
512 { |
|
513 const TFileName newName = TFileName(aNewName.utf16()); |
|
514 return mEngine->FileUtils()->TargetExists(aIndex.row(), newName); |
|
515 } |
|
516 |
|
517 // --------------------------------------------------------------------------- |
|
518 |
|
519 QString EngineWrapper::currentPath() const |
|
520 { |
|
521 return QString::fromUtf16(mEngine->FileUtils()->CurrentPath().Ptr(), |
|
522 mEngine->FileUtils()->CurrentPath().Length()); |
|
523 } |
|
524 |
|
525 TOverwriteOptions EngineWrapper::convertOverwriteOptions(const OverwriteOptions &aOverwriteOptions) |
|
526 { |
|
527 TOverwriteOptions tOverwriteOptions; |
|
528 tOverwriteOptions.iDoFileOperations = aOverwriteOptions.doFileOperations; |
|
529 tOverwriteOptions.iQueryIndex = aOverwriteOptions.queryIndex; |
|
530 tOverwriteOptions.iPostFix = TFileName(aOverwriteOptions.postFix.utf16()); |
|
531 tOverwriteOptions.iOverWriteFlags = aOverwriteOptions.overWriteFlags; |
|
532 return tOverwriteOptions; |
|
533 } |
|
534 |
|
535 bool EngineWrapper::hasDrivePassword(const QModelIndex &aIndex) |
|
536 { |
|
537 bool hasPassword = false; |
|
538 if (mEngine->FileUtils()->DriveEntries()->Count() > aIndex.row() && aIndex.row() >= 0) |
|
539 { |
|
540 TDriveEntry driveEntry = mEngine->FileUtils()->DriveEntries()->At(aIndex.row()); |
|
541 hasPassword = driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttHasPassword; |
|
542 } |
|
543 return hasPassword; |
|
544 } |
|
545 |
|
546 bool EngineWrapper::isDriveRemovable(const QModelIndex &aIndex) |
|
547 { |
|
548 bool isRemovable = false; |
|
549 if (mEngine->FileUtils()->DriveEntries()->Count() > aIndex.row() && aIndex.row() >= 0) |
|
550 { |
|
551 TDriveEntry driveEntry = mEngine->FileUtils()->DriveEntries()->At(aIndex.row()); |
|
552 isRemovable = driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttRemovable; |
|
553 } |
|
554 return isRemovable; |
|
555 } |
|
556 |
|
557 bool EngineWrapper::isDriveLocked(const QModelIndex &aIndex) |
|
558 { |
|
559 bool isRemovable = false; |
|
560 if (mEngine->FileUtils()->DriveEntries()->Count() > aIndex.row() && aIndex.row() >= 0) |
|
561 { |
|
562 TDriveEntry driveEntry = mEngine->FileUtils()->DriveEntries()->At(aIndex.row()); |
|
563 isRemovable = driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttLocked; |
|
564 } |
|
565 return isRemovable; |
|
566 } |
|
567 |
|
568 void EngineWrapper::GetDriveName(const QModelIndex &aIndex, QString &aDriveName) |
|
569 { |
|
570 TFileName driveName; |
|
571 mEngine->FileUtils()->GetDriveName(aIndex.row(), driveName); |
|
572 aDriveName = QString::fromUtf16(driveName.Ptr(), driveName.Length()); |
|
573 } |
|
574 |
|
575 |
|
576 void EngineWrapper::GetDriveVolumeLabel(const QModelIndex &aIndex, QString &aVolumeLabel) |
|
577 { |
|
578 TFileName volumeLabel; |
|
579 mEngine->FileUtils()->GetDriveName(aIndex.row(), volumeLabel); |
|
580 aVolumeLabel = QString::fromUtf16(volumeLabel.Ptr(), volumeLabel.Length()); |
|
581 } |
|
582 |
|
583 void EngineWrapper::DiskAdminSetDrivePassword(const QModelIndex &aIndex, |
|
584 const QString &aOldPassword, |
|
585 const QString &aNewPassword) |
|
586 { |
|
587 TFileName oldPassword = TFileName(aOldPassword.utf16()); |
|
588 TFileName newPassword = TFileName(aNewPassword.utf16()); |
|
589 TRAP_IGNORE(mEngine->FileUtils()->SetDrivePasswordL(aIndex.row(), oldPassword, newPassword)); |
|
590 } |
|
591 |
|
592 void EngineWrapper::DiskAdminUnlockDrive(const QModelIndex &aIndex, const QString &aOldPassword) |
|
593 { |
|
594 TFileName oldPassword = TFileName(aOldPassword.utf16()); |
|
595 TRAP_IGNORE(mEngine->FileUtils()->UnlockDriveL(aIndex.row(), oldPassword)); |
|
596 } |
|
597 |
|
598 void EngineWrapper::DiskAdminClearDrivePassword(const QModelIndex &aIndex, const QString &aOldPassword) |
|
599 { |
|
600 TFileName oldPassword = TFileName(aOldPassword.utf16()); |
|
601 TRAP_IGNORE(mEngine->FileUtils()->ClearDrivePasswordL(aIndex.row(), oldPassword)); |
|
602 } |
|
603 |
|
604 void EngineWrapper::DiskAdminEraseDrivePassword(const QModelIndex &aIndex) |
|
605 { |
|
606 TRAP_IGNORE(mEngine->FileUtils()->EraseDrivePasswordL(aIndex.row())); |
|
607 } |
|
608 |
|
609 void EngineWrapper::DiskAdminFormatDrive(const QModelIndex &aIndex, bool aQuickFormat) |
|
610 { |
|
611 TRAP_IGNORE(mEngine->FileUtils()->FormatDriveL(aIndex.row(), aQuickFormat)); |
|
612 } |
|
613 |
|
614 void EngineWrapper::DiskAdminQuickFormatDrive(const QModelIndex &aIndex, bool aQuickFormat) |
|
615 { |
|
616 TRAP_IGNORE(mEngine->FileUtils()->FormatDriveL(aIndex.row(), aQuickFormat)); |
|
617 } |
|
618 |
|
619 void EngineWrapper::DiskAdminCheckDisk(const QModelIndex &aIndex) |
|
620 { |
|
621 TRAP_IGNORE(mEngine->FileUtils()->CheckDiskL(aIndex.row())); |
|
622 } |
|
623 |
|
624 void EngineWrapper::DiskAdminScanDrive(const QModelIndex &aIndex) |
|
625 { |
|
626 TRAP_IGNORE(mEngine->FileUtils()->ScanDriveL(aIndex.row())); |
|
627 } |
|
628 |
|
629 void EngineWrapper::DiskAdminSetDriveName(const QModelIndex &aIndex, const QString &aDriveName) |
|
630 { |
|
631 TFileName driveName = TFileName(aDriveName.utf16()); |
|
632 TRAP_IGNORE(mEngine->FileUtils()->SetDriveNameL(aIndex.row(), driveName)); |
|
633 } |
|
634 |
|
635 void EngineWrapper::DiskAdminSetDriveVolumeLabel(const QModelIndex &aIndex, const QString &aVolumeLabel) |
|
636 { |
|
637 TFileName volumeLabel = TFileName(aVolumeLabel.utf16()); |
|
638 TRAP_IGNORE(mEngine->FileUtils()->SetDriveNameL(aIndex.row(), volumeLabel)); |
|
639 } |
|
640 |
|
641 void EngineWrapper::DiskAdminEjectDrive(const QModelIndex &aIndex) |
|
642 { |
|
643 TRAP_IGNORE(mEngine->FileUtils()->EjectDriveL(aIndex.row())); |
|
644 } |
|
645 |
|
646 void EngineWrapper::DiskAdminDismountDrive(const QModelIndex &aIndex) |
|
647 { |
|
648 TRAP_IGNORE(mEngine->FileUtils()->DismountFileSystemL(aIndex.row())); |
|
649 } |
|
650 |
|
651 void EngineWrapper::DiskAdminEraseMBR(const QModelIndex &aIndex) |
|
652 { |
|
653 TRAP_IGNORE(mEngine->FileUtils()->EraseMBRL(aIndex.row())); |
|
654 } |
|
655 |
|
656 void EngineWrapper::DiskAdminPartitionDrive(const QModelIndex &aIndex, bool aEraseMBR, int aAmountOfPartitions) |
|
657 { |
|
658 TRAP_IGNORE(mEngine->FileUtils()->PartitionDriveL(aIndex.row(), aEraseMBR, aAmountOfPartitions)); |
|
659 } |
|
660 |
|
661 void EngineWrapper::ToolsSetErrRd(bool aEnable) |
|
662 { |
|
663 TRAP_IGNORE(mEngine->FileUtils()->SetErrRdL(aEnable)); |
|
664 } |
|
665 |
|
666 bool EngineWrapper::ErrRdFileExists() |
|
667 { |
|
668 return mEngine->FileUtils()->FileExists(KErrRdPath); |
|
669 } |
|
670 |
|
671 void EngineWrapper::ToolsErrorSimulateLeave(int aLeaveCode) |
|
672 { |
|
673 mEngine->FileUtils()->SimulateLeaveL(aLeaveCode); |
|
674 } |
|
675 |
|
676 void EngineWrapper::ToolsErrorSimulatePanic(QString aPanicCategory, int aPanicCode) |
|
677 { |
|
678 TBuf<128> panicCategory; |
|
679 panicCategory.Copy(aPanicCategory.utf16()); |
|
680 mEngine->FileUtils()->SimulatePanicL(panicCategory, aPanicCode); |
|
681 } |
|
682 |
|
683 void EngineWrapper::ToolsErrorSimulateException(int aExceptionCode) |
|
684 { |
|
685 mEngine->FileUtils()->SimulateExceptionL(aExceptionCode); |
|
686 } |
|
687 |
|
688 quint32 EngineWrapper::getDebugMask() |
|
689 { |
|
690 return mEngine->FileUtils()->GetDebugMask(); |
|
691 } |
|
692 |
|
693 void EngineWrapper::toolsSetDebugMask(quint32 aDbgMask) |
|
694 { |
|
695 mEngine->FileUtils()->SetDebugMaskL(aDbgMask); |
|
696 } |
|
697 |
|
698 void EngineWrapper::toolsWriteAllFiles() |
|
699 { |
|
700 mEngine->FileUtils()->WriteAllFilesL(); |
|
701 } |
|
702 |
|
703 void EngineWrapper::showFileCheckSums(const QModelIndex &aIndex, TFileBrowserCmdFileChecksums checksumType) |
|
704 { |
|
705 mEngine->FileUtils()->ShowFileCheckSumsL(aIndex.row(), checksumType); |
|
706 } |
|
707 |
|
708 // --------------------------------------------------------------------------- |
|
709 // Functions that are called from engine |
|
710 // --------------------------------------------------------------------------- |
|
711 |
|
712 // --------------------------------------------------------------------------- |
|
713 |
|
714 void EngineWrapper::ShowErrorNote(const TDesC& aDescText, TBool aNoTimeout /*= EFalse*/) |
|
715 { |
|
716 QString qText = QString::fromUtf16(aDescText.Ptr(), aDescText.Length()); |
|
717 Notifications::showErrorNote(qText, aNoTimeout); |
|
718 } |
|
719 |
|
720 // --------------------------------------------------------------------------- |
|
721 |
|
722 void EngineWrapper::ShowInformationNote(const TDesC &aDescText, const TDesC &aDescTitle) |
|
723 { |
|
724 QString qText = QString::fromUtf16(aDescText.Ptr(), aDescText.Length()); |
|
725 QString qTitle = QString::fromUtf16(aDescTitle.Ptr(), aDescTitle.Length()); |
|
726 Notifications::showInformationNote(qText, qTitle); |
|
727 } |
|
728 |
|
729 // --------------------------------------------------------------------------- |
|
730 |
|
731 void EngineWrapper::ShowConfirmationNote(const TDesC& aDescText, TBool aNoTimeout /*= EFalse*/) |
|
732 { |
|
733 QString qText = QString::fromUtf16(aDescText.Ptr(), aDescText.Length()); |
|
734 Notifications::showConfirmationNote(qText, aNoTimeout); |
|
735 } |
|
736 |
|
737 void EngineWrapper::ShowProgressDialog(const TDesC& aDescText, TInt aMinimum, TInt aMaximum ) |
|
738 { |
|
739 const QString qText = QString::fromUtf16(aDescText.Ptr(), aDescText.Length()); |
|
740 if (!mProgressDialog) { |
|
741 mProgressDialog = new HbProgressDialog(HbProgressDialog::WaitDialog); |
|
742 QObject::connect(mProgressDialog, SIGNAL(cancelled()), this, SLOT(progressDialogCancelled())); |
|
743 } |
|
744 |
|
745 mProgressDialog->setText(qText); |
|
746 mProgressDialog->setMinimum(aMinimum); |
|
747 mProgressDialog->setMaximum(aMaximum); |
|
748 mEngine->FileUtils()->SetAllowProcessing(true); |
|
749 mProgressDialog->show(); |
|
750 } |
|
751 |
|
752 void EngineWrapper::CancelProgressDialog() |
|
753 { |
|
754 if (mProgressDialog) { |
|
755 QObject::disconnect(mProgressDialog, SIGNAL(cancelled()), this, SLOT(progressDialogCancelled())); |
|
756 mProgressDialog->cancel(); |
|
757 QObject::connect(mProgressDialog, SIGNAL(cancelled()), this, SLOT(progressDialogCancelled())); |
|
758 } |
|
759 } |
|
760 |
|
761 void EngineWrapper::SetProgressValue(TInt aValue) |
|
762 { |
|
763 if (mProgressDialog) |
|
764 mProgressDialog->setProgressValue(aValue); |
|
765 } |
|
766 |
|
767 void EngineWrapper::progressDialogCancelled() |
|
768 { |
|
769 mEngine->FileUtils()->DialogDismissedL(); |
|
770 } |
|
771 |
|
772 void EngineWrapper::ShowWaitDialog(const TDesC& aDescText) |
|
773 { |
|
774 const QString qText = QString::fromUtf16(aDescText.Ptr(), aDescText.Length()); |
|
775 if (!mWaitDialog) { |
|
776 mWaitDialog = new HbProgressDialog(HbProgressDialog::WaitDialog); |
|
777 QObject::connect(mWaitDialog, SIGNAL(cancelled()), this, SLOT(waitDialogCancelled())); |
|
778 } |
|
779 |
|
780 mWaitDialog->setText(qText); |
|
781 mEngine->FileUtils()->SetAllowProcessing(true); |
|
782 //mWaitDialog->setAttribute(Qt::WA_DeleteOnClose); |
|
783 mWaitDialog->show(); |
|
784 } |
|
785 |
|
786 void EngineWrapper::CancelWaitDialog() |
|
787 { |
|
788 if (mWaitDialog) |
|
789 mWaitDialog->cancel(); |
|
790 } |
|
791 |
|
792 void EngineWrapper::waitDialogCancelled() |
|
793 { |
|
794 mEngine->FileUtils()->SetAllowProcessing(false); |
|
795 } |
|
796 |
|
797 void EngineWrapper::ProcessEvents() |
|
798 { |
|
799 qApp->processEvents(); |
|
800 } |
|
801 |
|
802 TBool EngineWrapper::ShowConfirmationQuery(const TDesC& aDescText) |
|
803 { |
|
804 QString qText = QString::fromUtf16(aDescText.Ptr(), aDescText.Length()); |
|
805 return Notifications::showConfirmationQuery(qText); |
|
806 } |
|
807 |
|
808 // --------------------------------------------------------------------------- |