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