1414#include " item/itemstore.h"
1515#include " item/itemwidget.h"
1616#include " item/serialize.h"
17+ #include " gui/clipboardbrowsershared.h"
1718
1819#include < QCoreApplication>
1920#include < QInputDialog>
@@ -325,9 +326,9 @@ Encryption::EncryptionKey promptForEncryptionPasswordChange(QWidget *parent)
325326
326327bool reencryptTabs (
327328 const QStringList &tabNames,
328- ItemFactory *itemFactory ,
329+ ClipboardBrowserShared *sharedData ,
329330 const Encryption::EncryptionKey &oldKey,
330- Encryption::EncryptionKey &newKey,
331+ const Encryption::EncryptionKey &newKey,
331332 int maxItems,
332333 QWidget *parent)
333334{
@@ -342,13 +343,20 @@ bool reencryptTabs(
342343 progress.setMinimumDuration (500 ); // Show after 500ms if not done
343344 progress.setValue (0 );
344345
345- const Encryption::EncryptionKey newKeyBackup = newKey;
346+ // Skip plugins that do not support encryption
347+ ItemLoaderList skipLoaders;
348+ for (auto &loader : sharedData->itemFactory ->loaders ()) {
349+ if (loader->isEnabled () && !loader->supportsEncryption ()) {
350+ skipLoaders.append (loader);
351+ loader->setEnabled (false );
352+ }
353+ }
346354
347355 QStringList failedTabs;
356+
348357 for (int i = 0 ; i < tabNames.size (); ++i) {
349358 if (progress.wasCanceled ()) {
350359 log (" Tab re-encryption cancelled by user" , LogWarning);
351- failedTabs.append (QObject::tr (" (Cancelled by user)" ));
352360 break ;
353361 }
354362
@@ -369,14 +377,12 @@ bool reencryptTabs(
369377 ClipboardModel model;
370378
371379 // Set old encryption key temporarily and load items
372- newKey = oldKey;
373- ItemSaverPtr saver = loadItems (tabName, model, itemFactory, maxItems);
374- newKey = newKeyBackup ;
380+ sharedData-> encryptionKey = oldKey;
381+ ItemSaverPtr saver = loadItems (tabName, model, sharedData-> itemFactory , maxItems);
382+ sharedData-> encryptionKey = newKey ;
375383
376384 if (!saver) {
377- const QString error = QStringLiteral (" Failed to load tab: %1" ).arg (tabName);
378- log (error, LogError);
379- failedTabs.append (tabName);
385+ COPYQ_LOG (QStringLiteral (" Skipping encryption on unsupported tab: %1" ).arg (tabName));
380386 continue ;
381387 }
382388
@@ -387,15 +393,17 @@ bool reencryptTabs(
387393 COPYQ_LOG (QStringLiteral (" Loaded %1 items from tab: %2" ).arg (itemCount).arg (tabName));
388394
389395 if (!saveItems (tabName, model, saver)) {
390- const QString error = QStringLiteral (" Failed to save tab: %1" ).arg (tabName);
391- log (error, LogError);
396+ log (QStringLiteral (" Failed to re-encrypt tab: %1" ).arg (tabName), LogError);
392397 failedTabs.append (tabName);
393398 continue ;
394399 }
395400
396401 COPYQ_LOG (QStringLiteral (" Successfully re-encrypted tab: %1" ).arg (tabName));
397402 }
398403
404+ for (auto &loader : skipLoaders)
405+ loader->setEnabled (true );
406+
399407 progress.setValue (tabNames.size ());
400408
401409 if (!failedTabs.isEmpty ()) {
@@ -411,11 +419,7 @@ bool reencryptTabs(
411419 return false ;
412420 }
413421
414- log (QStringLiteral (" Successfully re-encrypted all %1 tabs" ).arg (tabNames.size ()), LogNote);
415-
416- if (!newKey.isValid ())
417- removePasswordFromKeychain ();
418-
422+ log (" Successfully re-encrypted tabs" );
419423 return true ;
420424}
421425
@@ -444,9 +448,9 @@ Encryption::EncryptionKey promptForEncryptionPasswordChange(QWidget *)
444448
445449bool reencryptTabs (
446450 const QStringList &,
447- ItemFactory *,
451+ ClipboardBrowserShared *,
452+ const Encryption::EncryptionKey &,
448453 const Encryption::EncryptionKey &,
449- Encryption::EncryptionKey &,
450454 int ,
451455 QWidget *)
452456{
0 commit comments