108 void FmDriverListWidget::on_list_longPressed( HbAbstractViewItem *item, const QPointF &coords ) |
108 void FmDriverListWidget::on_list_longPressed( HbAbstractViewItem *item, const QPointF &coords ) |
109 { |
109 { |
110 HbMenu *contextMenu = new HbMenu(); |
110 HbMenu *contextMenu = new HbMenu(); |
111 |
111 |
112 mCurrentItem = item; |
112 mCurrentItem = item; |
113 QString diskName = mCurrentItem->modelIndex().data( Qt::DisplayRole ).toString(); |
113 QString diskName = mModel->driveName( mCurrentItem->modelIndex() ); |
114 |
114 |
115 quint32 state = FmUtils::getDriverState( diskName ); |
|
116 FmDriverInfo driverInfo = FmUtils::queryDriverInfo( diskName ); |
115 FmDriverInfo driverInfo = FmUtils::queryDriverInfo( diskName ); |
117 |
116 FmDriverInfo::DriveState state = driverInfo.driveState(); |
118 if( !( state & FmDriverInfo::EDriveNotPresent ) ) { |
117 |
|
118 if( !( state & FmDriverInfo::EDriveNotPresent ) && !( state & FmDriverInfo::EDriveLocked ) && |
|
119 !( state & FmDriverInfo::EDriveCorrupted ) ) { |
119 HbAction *viewAction = new HbAction(); |
120 HbAction *viewAction = new HbAction(); |
120 viewAction->setObjectName( "viewAction" ); |
121 viewAction->setObjectName( "viewAction" ); |
121 viewAction->setText( tr( "View details" ) ); |
122 viewAction->setText( hbTrId( "txt_fmgr_menu_view_details_memory" ) ); |
122 contextMenu->addAction( viewAction ); |
123 contextMenu->addAction( viewAction ); |
123 |
124 |
124 //state = 0x210; |
125 //state = 0x210; |
125 |
126 |
126 connect( viewAction, SIGNAL( triggered() ), |
127 connect( viewAction, SIGNAL( triggered() ), |
127 this, SLOT( on_viewAction_triggered() ) ); |
128 this, SLOT( on_viewAction_triggered() ) ); |
128 } |
129 } |
129 |
130 |
130 HbMenu *subMenu = new HbMenu( "Memory name" ); |
|
131 if( ( state & FmDriverInfo::EDriveRemovable ) && !( state & FmDriverInfo::EDriveMassStorage ) ){ |
131 if( ( state & FmDriverInfo::EDriveRemovable ) && !( state & FmDriverInfo::EDriveMassStorage ) ){ |
132 if ( driverInfo.volumeName().length() ){ |
132 if ( driverInfo.volumeName().length() ){ |
133 HbAction *renameAction = new HbAction(); |
133 HbAction *renameAction = new HbAction(); |
134 renameAction->setObjectName( "renameAction" ); |
134 renameAction->setObjectName( "renameAction" ); |
135 renameAction->setText( tr( "Rename" ) ); |
135 renameAction->setText( hbTrId( "txt_fmgr_menu_rename" ) ); |
136 subMenu->addAction( renameAction ); |
136 contextMenu->addAction( renameAction ); |
137 |
137 |
138 connect( renameAction, SIGNAL( triggered() ), |
138 connect( renameAction, SIGNAL( triggered() ), |
139 this, SLOT( on_renameAction_triggered() ) ); |
139 this, SLOT( on_renameAction_triggered() ) ); |
140 } |
140 } |
141 else{ |
141 else{ |
142 HbAction *nameAction = new HbAction(); |
142 HbAction *nameAction = new HbAction(); |
143 nameAction->setObjectName( "nameAction" ); |
143 nameAction->setObjectName( "nameAction" ); |
144 nameAction->setText( tr( "Name" ) ); |
144 nameAction->setText( hbTrId( "txt_fmgr_menu_name" ) ); |
145 subMenu->addAction( nameAction ); |
145 contextMenu->addAction( nameAction ); |
146 |
146 |
147 connect( nameAction, SIGNAL( triggered() ), |
147 connect( nameAction, SIGNAL( triggered() ), |
148 this, SLOT( on_nameAction_triggered() ) ); |
148 this, SLOT( on_nameAction_triggered() ) ); |
149 } |
149 } |
150 contextMenu->addMenu( subMenu ); |
150 |
151 |
|
152 subMenu = new HbMenu( "Memory password" ); |
|
153 if( state & FmDriverInfo::EDrivePasswordProtected ){ |
151 if( state & FmDriverInfo::EDrivePasswordProtected ){ |
154 HbAction *changePwdAction = new HbAction(); |
152 HbAction *changePwdAction = new HbAction(); |
155 changePwdAction->setObjectName( "changePwdAction" ); |
153 changePwdAction->setObjectName( "changePwdAction" ); |
156 changePwdAction->setText( tr( "Change Password" ) ); |
154 changePwdAction->setText( hbTrId( "txt_fmgr_menu_change_password" ) ); |
157 subMenu->addAction( changePwdAction ); |
155 contextMenu->addAction( changePwdAction ); |
158 |
156 |
159 HbAction *removePwdAction = new HbAction(); |
157 HbAction *removePwdAction = new HbAction(); |
160 removePwdAction->setObjectName( "removePwdAction" ); |
158 removePwdAction->setObjectName( "removePwdAction" ); |
161 removePwdAction->setText( tr( "Remove Password" ) ); |
159 removePwdAction->setText( hbTrId( "txt_fmgr_menu_remove_password" ) ); |
162 subMenu->addAction( removePwdAction ); |
160 contextMenu->addAction( removePwdAction ); |
163 |
161 |
164 connect( changePwdAction, SIGNAL( triggered() ), |
162 connect( changePwdAction, SIGNAL( triggered() ), |
165 this, SLOT( on_changePwdAction_triggered() ) ); |
163 this, SLOT( on_changePwdAction_triggered() ) ); |
166 connect( removePwdAction, SIGNAL( triggered() ), |
164 connect( removePwdAction, SIGNAL( triggered() ), |
167 this, SLOT( on_removePwdAction_triggered() ) ); |
165 this, SLOT( on_removePwdAction_triggered() ) ); |
168 } |
166 } |
169 else{ |
167 else{ |
170 HbAction *setPwdAction = new HbAction(); |
168 HbAction *setPwdAction = new HbAction(); |
171 setPwdAction->setObjectName( "setPwdAction" ); |
169 setPwdAction->setObjectName( "setPwdAction" ); |
172 setPwdAction->setText( tr( "Set Password" ) ); |
170 setPwdAction->setText( hbTrId( "txt_fmgr_menu_set_password" ) ); |
173 subMenu->addAction( setPwdAction ); |
171 contextMenu->addAction( setPwdAction ); |
174 |
172 |
175 connect( setPwdAction, SIGNAL( triggered() ), |
173 connect( setPwdAction, SIGNAL( triggered() ), |
176 this, SLOT( on_setPwdAction_triggered() ) ); |
174 this, SLOT( on_setPwdAction_triggered() ) ); |
177 } |
175 } |
178 contextMenu->addMenu( subMenu ); |
|
179 |
176 |
180 if( state & FmDriverInfo::EDriveEjectable ){ |
177 if( state & FmDriverInfo::EDriveEjectable ){ |
181 HbAction *ejectAction = new HbAction(); |
178 HbAction *ejectAction = new HbAction(); |
182 ejectAction->setObjectName( "ejectAction" ); |
179 ejectAction->setObjectName( "ejectAction" ); |
183 ejectAction->setText( tr( "Eject" ) ); |
180 ejectAction->setText( hbTrId( "txt_fmgr_menu_eject" ) ); |
184 contextMenu->addAction( ejectAction ); |
181 contextMenu->addAction( ejectAction ); |
185 |
182 |
186 connect( ejectAction, SIGNAL( triggered() ), |
183 connect( ejectAction, SIGNAL( triggered() ), |
187 this, SLOT( on_ejectAction_triggered() ) ); |
184 this, SLOT( on_ejectAction_triggered() ) ); |
188 } |
185 } |
189 } |
186 } |
190 #ifndef _DEBUG_ENABLE_FORMATMENU_ |
187 #ifndef _DEBUG_ENABLE_FORMATMENU_ |
191 if ( state & FmDriverInfo::EDriveRemovable ){ |
188 if ( ( state & FmDriverInfo::EDriveRemovable ) || ( state & FmDriverInfo::EDriveCorrupted ) |
192 if( state & FmDriverInfo::EDriveFormattable ){ |
189 || ( state & FmDriverInfo::EDriveLocked ) ){ |
|
190 if( !( state & FmDriverInfo::EDriveNotPresent ) ){ |
193 #endif |
191 #endif |
194 HbAction *formatAction = new HbAction(); |
192 HbAction *formatAction = new HbAction(); |
195 formatAction->setObjectName( "formatAction" ); |
193 formatAction->setObjectName( "formatAction" ); |
196 formatAction->setText( tr( "Format" ) ); |
194 formatAction->setText( hbTrId( "txt_fmgr_menu_format" ) ); |
197 contextMenu->addAction( formatAction ); |
195 contextMenu->addAction( formatAction ); |
198 |
196 |
199 connect( formatAction, SIGNAL( triggered() ), |
197 connect( formatAction, SIGNAL( triggered() ), |
200 this, SLOT( on_formatAction_triggered() ) ); |
198 this, SLOT( on_formatAction_triggered() ) ); |
201 #ifndef _DEBUG_ENABLE_FORMATMENU_ |
199 #ifndef _DEBUG_ENABLE_FORMATMENU_ |
216 contextMenu->exec( coords ); |
214 contextMenu->exec( coords ); |
217 } |
215 } |
218 |
216 |
219 void FmDriverListWidget::on_viewAction_triggered() |
217 void FmDriverListWidget::on_viewAction_triggered() |
220 { |
218 { |
221 QString diskName = mCurrentItem->modelIndex().data( Qt::DisplayRole ).toString(); |
219 QString diskName = mModel->driveName( mCurrentItem->modelIndex() ); |
222 mOperationService->asyncViewDriveDetails( diskName ); |
220 mOperationService->asyncViewDriveDetails( diskName ); |
223 } |
221 } |
224 |
222 |
225 void FmDriverListWidget::on_renameAction_triggered() |
223 void FmDriverListWidget::on_renameAction_triggered() |
226 { |
224 { |
227 QString diskName = mCurrentItem->modelIndex().data( Qt::DisplayRole ).toString(); |
225 QString diskName = mModel->driveName( mCurrentItem->modelIndex() ); |
228 |
226 |
229 quint32 state = FmUtils::getDriverState( diskName ); |
227 FmDriverInfo::DriveState state = FmUtils::queryDriverInfo( diskName ).driveState(); |
230 FmDriverInfo driverInfo = FmUtils::queryDriverInfo( diskName ); |
228 FmDriverInfo driverInfo = FmUtils::queryDriverInfo( diskName ); |
231 |
229 |
232 if ( state & FmDriverInfo::EDriveWriteProtected ){ |
230 if ( state & FmDriverInfo::EDriveWriteProtected ){ |
233 HbMessageBox::information( tr( "Unable to perform operation. Memory card is read only." ) ); |
231 HbMessageBox::information( hbTrId( "Unable to perform operation. Memory card is read only." ) ); |
234 return; |
232 return; |
235 } |
233 } |
236 |
234 |
237 QString title( tr( "Drive name ") ); |
235 QString title( tr( "Drive name ") ); |
238 QString volumeName = driverInfo.volumeName(); |
236 QString volumeName = driverInfo.volumeName(); |
239 |
237 |
240 if( FmDlgUtils::showTextQuery( title, volumeName ) ){ |
238 QString associatedDrives( FmUtils::getDriveLetterFromPath( diskName ) ); |
241 |
239 while( FmDlgUtils::showTextQuery( title, volumeName, false, FmMaxLengthofDriveName, associatedDrives ) ){ |
242 if ( FmUtils::renameDrive( diskName, volumeName ) == 0 ){ |
240 int err = FmUtils::renameDrive( diskName, volumeName ); |
243 HbMessageBox::information( tr( "The name has been changed!" ) ); |
241 if ( err == FmErrNone ){ |
244 mModel->refresh(); |
242 HbMessageBox::information( hbTrId( "The name has been changed!" ) ); |
245 } |
243 mModel->refresh(); |
246 else{ |
244 break; |
247 HbMessageBox::information( tr( "Error occurred, operation cancelled!" ) ); |
245 } else if( err == FmErrBadName ) { |
|
246 HbMessageBox::information( hbTrId( "Illegal characters! Use only letters and numbers." ) ); |
|
247 } else{ |
|
248 HbMessageBox::information( hbTrId( "Error occurred, operation cancelled!" ) ); |
|
249 break; |
248 } |
250 } |
249 } |
251 } |
250 } |
252 } |
251 |
253 |
252 void FmDriverListWidget::on_nameAction_triggered() |
254 void FmDriverListWidget::on_nameAction_triggered() |
253 { |
255 { |
254 on_renameAction_triggered(); |
256 on_renameAction_triggered(); |
255 } |
257 } |
256 |
258 |
257 void FmDriverListWidget::on_changePwdAction_triggered() |
259 void FmDriverListWidget::on_setPwdAction_triggered() |
258 { |
260 { |
259 QString title( tr( "Password: ") ); |
261 QString firstLabel( hbTrId( "New Password: ") ); |
260 QString firstLabel( tr( "New Password: ") ); |
262 QString secondLabel( hbTrId( "Confirm new Password: ") ); |
261 QString secondLabel( tr( "Confirm new Password: ") ); |
|
262 |
263 |
263 QString oldPwd; |
264 QString oldPwd; |
264 QString newPwd; |
265 QString newPwd; |
265 |
266 |
266 QString diskName = mCurrentItem->modelIndex().data( Qt::DisplayRole ).toString(); |
267 FmUtils::emptyPwd( oldPwd ); |
267 |
268 |
268 if( FmDlgUtils::showConfirmPasswordQuery( title, diskName, oldPwd ) ){ |
269 QString diskName = mModel->driveName( mCurrentItem->modelIndex() ); |
269 if( FmDlgUtils::showChangePasswordQuery( firstLabel, secondLabel, newPwd ) ){ |
270 |
270 if ( FmUtils::setDrivePwd( diskName, oldPwd, newPwd ) == 0 ){ |
271 QString associatedDrives( FmUtils::getDriveLetterFromPath( diskName ) ); |
271 HbMessageBox::information( tr( "The password has been changed!" ) ); |
272 if( FmDlgUtils::showMultiPasswordQuery( firstLabel, secondLabel, newPwd, associatedDrives ) ) { |
|
273 if ( FmUtils::setDrivePwd( diskName, oldPwd, newPwd ) == 0 ){ |
|
274 HbMessageBox::information( hbTrId( "The password has been set!" ) ); |
|
275 } |
|
276 else{ |
|
277 HbMessageBox::information( hbTrId( "Error occurred, operation cancelled!" ) ); |
|
278 } |
|
279 } |
|
280 } |
|
281 |
|
282 void FmDriverListWidget::on_changePwdAction_triggered() |
|
283 { |
|
284 QString title( hbTrId( "Password: ") ); |
|
285 QString firstLabel( hbTrId( "New Password: ") ); |
|
286 QString secondLabel( hbTrId( "Confirm new Password: ") ); |
|
287 |
|
288 QString oldPwd; |
|
289 QString newPwd; |
|
290 |
|
291 QString diskName = mModel->driveName( mCurrentItem->modelIndex() ); |
|
292 |
|
293 QString associatedDrives( FmUtils::getDriveLetterFromPath( diskName ) ); |
|
294 while( FmDlgUtils::showSinglePasswordQuery( title, oldPwd, associatedDrives ) ) { |
|
295 if ( FmUtils::checkDrivePwd( diskName, oldPwd ) == 0 ){ |
|
296 if( FmDlgUtils::showMultiPasswordQuery( firstLabel, secondLabel, newPwd ) ){ |
|
297 if ( FmUtils::setDrivePwd( diskName, oldPwd, newPwd ) == 0 ){ |
|
298 HbMessageBox::information( hbTrId( "The password has been changed!" ) ); |
|
299 } else { |
|
300 HbMessageBox::information( hbTrId( "Error occurred, operation cancelled!" ) ); |
|
301 } |
|
302 break; |
|
303 } else { |
|
304 //cancel muti password query |
|
305 break; |
272 } |
306 } |
273 else{ |
307 } else { |
274 HbMessageBox::information( tr( "Error occurred, operation cancelled!" ) ); |
308 HbMessageBox::information( hbTrId( "The password is incorrect, try again!" ) ); |
275 } |
309 } |
276 } |
310 |
277 } |
311 } |
278 } |
312 } |
279 |
313 |
280 void FmDriverListWidget::on_removePwdAction_triggered() |
314 void FmDriverListWidget::on_removePwdAction_triggered() |
281 { |
315 { |
282 QString title( tr( "Password: ") ); |
316 QString title( hbTrId( "Password: ") ); |
283 |
317 |
284 QString oldPwd; |
318 QString oldPwd; |
285 |
319 |
286 QString diskName = mCurrentItem->modelIndex().data( Qt::DisplayRole ).toString(); |
320 QString diskName = mModel->driveName( mCurrentItem->modelIndex() ); |
287 //QString password( tr( "a ") ); |
321 //QString password( tr( "a ") ); |
288 if( HbMessageBox::question( tr( "Do you want to remove the password? Memory card becomes unlocked." ) ) ){ |
322 if( HbMessageBox::question( tr( "Do you want to remove the password? Memory card becomes unlocked." ) ) ){ |
289 if( FmDlgUtils::showConfirmPasswordQuery( title, diskName, oldPwd ) ){ |
323 QString associatedDrives( FmUtils::getDriveLetterFromPath( diskName ) ); |
290 |
324 while( FmDlgUtils::showSinglePasswordQuery( title, oldPwd, associatedDrives ) ) { |
291 if ( FmUtils::removeDrivePwd( diskName, oldPwd ) == 0 ){ |
325 if ( FmUtils::checkDrivePwd( diskName, oldPwd ) == 0 ) { |
292 HbMessageBox::information( tr( "The password has been removed!" ) ); |
326 if ( FmUtils::removeDrivePwd( diskName, oldPwd ) == 0 ){ |
|
327 HbMessageBox::information( hbTrId( "The password has been removed!" ) ); |
|
328 } |
|
329 else{ |
|
330 HbMessageBox::information( hbTrId( "Error occurred, operation cancelled!" ) ); |
|
331 } |
|
332 break; |
293 } |
333 } |
294 else{ |
334 else { |
295 HbMessageBox::information( tr( "Error occurred, operation cancelled!" ) ); |
335 HbMessageBox::information( hbTrId( "The password is incorrect, try again!" ) ); |
296 } |
336 } |
|
337 |
297 } |
338 } |
298 } |
339 } |
299 } |
340 } |
300 |
341 |
301 void FmDriverListWidget::on_unLockedAction_triggered() |
342 void FmDriverListWidget::on_unLockedAction_triggered() |
302 { |
343 { |
303 QString title( tr( "Password: ") ); |
344 QString title( hbTrId( "Password: ") ); |
304 |
345 |
305 QString oldPwd; |
346 QString oldPwd; |
306 |
347 |
307 QString diskName = mCurrentItem->modelIndex().data( Qt::DisplayRole ).toString(); |
348 QString diskName = mModel->driveName( mCurrentItem->modelIndex() ); |
308 |
349 |
309 if( FmDlgUtils::showConfirmPasswordQuery( title, diskName, oldPwd ) ){ |
350 //Do not add associatedDrives as Locked MMC is not available Drive but only present Drive |
310 |
351 while( FmDlgUtils::showSinglePasswordQuery( title, oldPwd ) ) { |
311 if ( FmUtils::unlockDrive( diskName, oldPwd ) == 0 ){ |
352 int err = FmUtils::unlockDrive( diskName, oldPwd ); |
312 HbMessageBox::information( tr( "The memory is unlocked!" ) ); |
353 if( err == FmErrNone ) { |
313 } |
354 HbMessageBox::information( hbTrId( "The memory is unlocked!" ) ); |
314 else{ |
355 break; |
315 HbMessageBox::information( tr( "Error occurred, operation cancelled!" ) ); |
356 } else if ( err == FmErrAccessDenied ) { |
316 } |
357 HbMessageBox::information( hbTrId( "The password is incorrect, try again!" ) ); |
317 } |
358 } else if (err == FmErrAlreadyExists ) { |
318 } |
359 HbMessageBox::information( hbTrId( "The disk has already been unlocked!" ) ); |
319 |
360 break; |
320 void FmDriverListWidget::on_setPwdAction_triggered() |
361 } else if( err == FmErrNotSupported ) { |
321 { |
362 HbMessageBox::information( hbTrId( "The media does not support password locking!" ) ); |
322 QString firstLabel( tr( "New Password: ") ); |
363 break; |
323 QString secondLabel( tr( "Confirm new Password: ") ); |
364 } else { |
324 |
365 HbMessageBox::information( hbTrId( "Error occurred, operation cancelled!" ) ); |
325 QString oldPwd; |
366 break; |
326 QString newPwd; |
|
327 |
|
328 FmUtils::emptyPwd( oldPwd ); |
|
329 |
|
330 QString diskName = mCurrentItem->modelIndex().data( Qt::DisplayRole ).toString(); |
|
331 |
|
332 if( FmDlgUtils::showChangePasswordQuery( firstLabel, secondLabel, newPwd ) ){ |
|
333 if ( FmUtils::setDrivePwd( diskName, oldPwd, newPwd ) == 0 ){ |
|
334 HbMessageBox::information( tr( "The password has been set!" ) ); |
|
335 } |
|
336 else{ |
|
337 HbMessageBox::information( tr( "Error occurred, operation cancelled!" ) ); |
|
338 } |
367 } |
339 } |
368 } |
340 } |
369 } |
341 |
370 |
342 void FmDriverListWidget::on_formatAction_triggered() |
371 void FmDriverListWidget::on_formatAction_triggered() |
343 { |
372 { |
344 QString diskName = mCurrentItem->modelIndex().data( Qt::DisplayRole ).toString(); |
373 QString diskName = mModel->driveName( mCurrentItem->modelIndex() ); |
345 |
374 |
346 if( HbMessageBox::question( tr( "Format? Data will be deleted during formatting." ) ) ){ |
375 if( HbMessageBox::question( hbTrId( "Format? Data will be deleted during formatting." ) ) ){ |
347 if( FmErrNone != mOperationService->asyncFormat( diskName ) ) |
376 if( FmErrNone != mOperationService->asyncFormat( diskName ) ) |
348 HbMessageBox::information( tr( "Formatting failed." ) ); |
377 HbMessageBox::information( hbTrId( "Formatting failed." ) ); |
349 } |
378 } |
350 |
|
351 } |
379 } |
352 |
380 |
353 void FmDriverListWidget::on_ejectAction_triggered() |
381 void FmDriverListWidget::on_ejectAction_triggered() |
354 { |
382 { |
355 QString diskName = mCurrentItem->modelIndex().data( Qt::DisplayRole ).toString(); |
383 QString diskName = mModel->driveName( mCurrentItem->modelIndex() ); |
356 |
384 |
357 if( HbMessageBox::question( tr( "Eject memory card? Some applications will be closed." ) ) ){ |
385 if( HbMessageBox::question( hbTrId( "Eject memory card? Some applications will be closed." ) ) ){ |
358 if( !FmUtils::ejectDrive( diskName ) ){ |
386 FmUtils::ejectDrive( diskName ); |
359 HbMessageBox::information( tr( "Error occurred, operation cancelled!") ); |
|
360 } |
|
361 } |
387 } |
362 } |
388 } |
363 |
389 |
364 void FmDriverListWidget::on_directoryChanged( const QString &path ) |
390 void FmDriverListWidget::on_directoryChanged( const QString &path ) |
365 { |
391 { |