| 17 | #include <QMenu> |
| 18 | |
| 19 | void KeyTreeView::fillContextMenu(QMenu *menu, QMenu *subExport, |
| 20 | const QModelIndex &index, QModelIndexList indexes) |
| 21 | { |
| 22 | bool multi = indexes.size() > 1; |
| 23 | |
| 24 | pki_key *key = db_base::fromIndex<pki_key>(index); |
| 25 | if (indexes.size() == 0 || !key) |
| 26 | return; |
| 27 | |
| 28 | if (!multi && key && key->isPrivKey() && !key->isToken()) { |
| 29 | switch (key->getOwnPass()) { |
| 30 | case pki_key::ptCommon: |
| 31 | menu->addAction(tr("Change password"), this, |
| 32 | SLOT(setOwnPass())); |
| 33 | break; |
| 34 | case pki_key::ptPrivate: |
| 35 | menu->addAction(tr("Reset password"), this, |
| 36 | SLOT(resetOwnPass())); |
| 37 | break; |
| 38 | default: |
| 39 | break; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | if (!pkcs11::libraries.loaded() || multi) |
| 44 | return; |
| 45 | |
| 46 | if (key->isToken()) { |
| 47 | menu->addAction(tr("Change PIN"), this, |
| 48 | SLOT(changePin())); |
| 49 | menu->addAction(tr("Init PIN with SO PIN (PUK)"), this, |
| 50 | SLOT(initPin())); |
| 51 | menu->addAction(tr("Change SO PIN (PUK)"), this, |
| 52 | SLOT(changeSoPin())); |
| 53 | } else if (subExport) { |
| 54 | subExport->addAction(tr("Security token"), |
| 55 | this, SLOT(toToken())); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | void KeyTreeView::setOwnPass() |
| 60 | { |
nothing calls this directly
no test coverage detected