MCPcopy Create free account
hub / github.com/IJHack/QtPass / writeGpgIdFile

Method writeGpgIdFile

src/imitatepass.cpp:256–278  ·  view source on GitHub ↗

* @brief Writes the selected users' GPG key IDs to a .gpg-id file. * @details Opens the specified file for writing, stores the key ID of each * enabled user on a separate line, and warns if none of the selected users has * a secret key available. * * @param QString &gpgIdFile - Path to the .gpg-id file to be written. * @param QList &users - List of users to evaluate and write to th

Source from the content-addressed store, hash-verified

254 *
255 */
256void ImitatePass::writeGpgIdFile(const QString &gpgIdFile,
257 const QList<UserInfo> &users) {
258 QFile gpgId(gpgIdFile);
259 if (!gpgId.open(QIODevice::WriteOnly | QIODevice::Text)) {
260 emit critical(tr("Cannot update"),
261 tr("Failed to open .gpg-id for writing."));
262 return;
263 }
264 bool secret_selected = false;
265 for (const UserInfo &user : users) {
266 if (user.enabled) {
267 gpgId.write((user.key_id + "\n").toUtf8());
268 secret_selected |= user.have_secret;
269 }
270 }
271 gpgId.close();
272 if (!secret_selected) {
273 emit critical(
274 tr("Check selected users!"),
275 tr("None of the selected keys have a secret key available.\n"
276 "You will not be able to decrypt any newly added passwords!"));
277 }
278}
279
280/**
281 * @brief Signs a GPG ID file and verifies its signature.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected