Ejemplo n.º 1
0
	QList<QCA::PGPKey> CryptoManager::GetPublicKeys () const
	{
		QList<QCA::PGPKey> result;

		QCA::KeyStore store { "qca-gnupg", KeyStoreMgr_.get () };

		for (const auto& entry : store.entryList ())
		{
			const auto& key = entry.pgpPublicKey ();
			if (!key.isNull ())
				result << key;
		}

		return result;
	}
Ejemplo n.º 2
0
	QList<QCA::PGPKey> CryptoManager::GetPrivateKeys () const
	{
		QList<QCA::PGPKey> result;

		QCA::KeyStore store ("qca-gnupg", KeyStoreMgr_.get ());

		Q_FOREACH (const QCA::KeyStoreEntry& entry, store.entryList ())
		{
			const QCA::PGPKey& key = entry.pgpSecretKey ();
			if (!key.isNull ())
				result << key;
		}

		return result;
	}
Ejemplo n.º 3
0
	void ks_updated()
	{
		QCA::KeyStore *ks = (QCA::KeyStore *)sender();
		KeyStoreItem *store_item = itemFromStore(ks);
		Q_ASSERT(store_item);

		QList<QCA::KeyStoreEntry> newEntries = ks->entryList();

#ifdef ONLY_SHOW_KEYBUNDLE
		// ignore entries that are not keybundles
		for(int n = 0; n < newEntries.count(); ++n)
		{
			if(newEntries[n].type() != QCA::KeyStoreEntry::TypeKeyBundle)
			{
				newEntries.removeAt(n);
				--n; // adjust position
			}
		}
#endif

		// update the store item itself
		store_item->setStore(ks->name(), ks->type());

		// handle removed child entries
		for(int n = 0; n < store_item->rowCount(); ++n)
		{
			KeyStoreItem *i = (KeyStoreItem *)store_item->child(n);

			// is the existing entry in the new list?
			bool found = false;
			foreach(const QCA::KeyStoreEntry &ne, newEntries)
			{
				if(ne.id() == i->keyStoreEntry.id())
				{
					found = true;
					break;
				}
			}

			// if not, remove it
			if(!found)
			{
				store_item->removeRow(n);
				--n; // adjust position
			}
		}

		// handle added/updated child entries
		for(int n = 0; n < newEntries.count(); ++n)
		{
			const QCA::KeyStoreEntry &ne = newEntries[n];

			// was this entry in the original list?
			KeyStoreItem *entry_item = 0;
			for(int k = 0; k < store_item->rowCount(); ++k)
			{
				KeyStoreItem *i = (KeyStoreItem *)store_item->child(k);
				if(i->keyStoreEntry.id() == ne.id())
				{
					entry_item = i;
					break;
				}
			}

			// if not, add it
			if(!entry_item)
			{
				entry_item = new KeyStoreItem(KeyStoreItem::Entry, &shared);
				entry_item->keyStoreEntry = ne;
				entry_item->setEntry(newEntries[n].name(), newEntries[n].type(), newEntries[n].isAvailable(), n);
				store_item->appendRow(entry_item);
			}
			// if so, update it
			else
			{
				entry_item->keyStoreEntry = ne;
				entry_item->setEntry(newEntries[n].name(), newEntries[n].type(), newEntries[n].isAvailable(), n);
			}
		}

		store_item->sortChildren(0);
	}