Roshani's KDE & GSoC Blog

Week 4 Update: KeepSecret Import/Export Feature Completed

This week, the import/export feature for KeepSecret was completed and merged in !33.

The implementation went through several changes before reaching its final form. My initial approach was to use a KWalletManager-compatible XML format so that data could be exchanged directly between the two applications. To match KWalletManager's structure exactly, I referenced kwalleteditor.cpp from the KWalletManager repository and implemented support for elements such as , , , , and .

The final format now preserves all item information:

-Secrets are stored as Base64-encoded data and decoded directly from the raw byte array, avoiding UTF-8 conversions that could corrupt binary or non-UTF-8 secrets. -The contentType field is preserved, matching the Secret Service specification's combination of raw secret bytes and content type metadata. -Every attribute key and value is exported exactly as stored, without assuming any particular schema. -Exported files use a dedicated .keepsecret extension instead of a generic XML extension.

My first version queried libsecret directly during export. While functional, this wasn't consistent with how CollectionModel already manages data. Based on feedback, the final version loads secrets and attributes into the in-memory item list (m_items) when a wallet is opened secrets and attributes into the in-memory item list (m_items) when a wallet is opened, and the export process simply reads from that existing data. This keeps the implementation cleaner and aligned with the rest of the model.

There was also a small but important UI change. Initially, the Import and Export actions were placed in the application's global drawer. During review, Marco Martin noted that these operations belong to a specific wallet rather than the application as a whole. Following that feedback, the actions were moved to the wallet page itself and integrated into the ActionCollection system, alongside actions such as Lock and Delete Wallet. As a bonus, they automatically gain keyboard shortcut support through the existing shortcut infrastructure.

The next step is a follow-up merge request that adds support for importing the legacy KWalletManager XML format. This will make migration from KWallet to KeepSecret much smoother for existing users. The merge request!34 is open and under review.