24 #include "keyadaptor.h"
59 #include <akonadi/contact/contacteditor.h>
60 #include <akonadi/contact/contacteditordialog.h>
61 #include <akonadi/contact/contactsearchjob.h>
63 #include <KActionCollection>
65 #include <KFileDialog>
67 #include <KFindDialog>
69 #include <KInputDialog>
73 #include <KMessageBox>
75 #include <KMimeTypeTrader>
77 #include <KRecentFilesAction>
79 #include <KSelectAction>
82 #include <KStandardAction>
83 #include <KStandardDirs>
84 #include <KStandardShortcut>
86 #include <KStatusNotifierItem>
87 #include <KToggleAction>
89 #include <KToolInvocation>
90 #include <KUniqueApplication>
93 #include <QApplication>
95 #include <QDesktopWidget>
99 #include <QKeySequence>
102 #include <QMetaObject>
104 #include <QPrintDialog>
107 #include <QTextStream>
109 #include <QtDBus/QtDBus>
110 #include <kabc/addresseelist.h>
112 #include <kio/global.h>
113 #include <kjobtrackerinterface.h>
115 #include <solid/networking.h>
117 using namespace KgpgCore;
128 new KeyAdaptor(
this);
129 QDBusConnection::sessionBus().registerObject(QLatin1String(
"/KeyInterface" ),
this);
131 setAttribute(Qt::WA_DeleteOnClose,
false);
132 setWindowTitle(i18n(
"Key Management"));
134 KStandardAction::quit(
this, SLOT(quitApp()), actionCollection());
135 actionCollection()->addAction(KStandardAction::Preferences, QLatin1String(
"options_configure" ),
this, SLOT(
showOptions()));
137 openEditor = actionCollection()->addAction(QLatin1String(
"kgpg_editor"),
this, SLOT(
slotOpenEditor()));
138 openEditor->setIcon(KIcon( QLatin1String(
"accessories-text-editor" )));
139 openEditor->setText(i18n(
"&Open Editor"));
141 kserver = actionCollection()->addAction( QLatin1String(
"key_server"),
this, SLOT(
showKeyServer()));
142 kserver->setText( i18n(
"&Key Server Dialog") );
143 kserver->setIcon( KIcon( QLatin1String(
"network-server" )) );
145 goToDefaultKey = actionCollection()->addAction(QLatin1String(
"go_default_key"),
this, SLOT(slotGotoDefaultKey()));
146 goToDefaultKey->setIcon(KIcon( QLatin1String(
"go-home" )));
147 goToDefaultKey->setText(i18n(
"&Go to Default Key"));
148 goToDefaultKey->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Home));
151 s_kgpgEditor->setAttribute(Qt::WA_DeleteOnClose,
false);
158 installEventFilter(
this);
162 action = actionCollection()->addAction(QLatin1String(
"help_tipofday"),
this, SLOT(slotTip()));
163 action->setIcon( KIcon( QLatin1String(
"help-hint" )) );
164 action->setText( i18n(
"Tip of the &Day") );
166 action = actionCollection()->addAction(QLatin1String(
"gpg_man"),
this, SLOT(slotManpage()));
167 action->setText( i18n(
"View GnuPG Manual") );
168 action->setIcon( KIcon( QLatin1String(
"help-contents" )) );
170 action = actionCollection()->addAction(QLatin1String(
"key_refresh"),
this, SLOT(
refreshkey()));
171 action->setIcon(KIcon( QLatin1String(
"view-refresh" )));
172 action->setText(i18n(
"&Refresh List"));
173 action->setShortcuts(KStandardShortcut::reload());
175 longId = actionCollection()->add<KToggleAction>(QLatin1String(
"show_long_keyid"),
this, SLOT(slotShowLongId(
bool)));
176 longId->setText(i18n(
"Show &Long Key Id"));
179 QAction *infoKey = actionCollection()->addAction(QLatin1String(
"key_info"),
this, SLOT(keyproperties()));
180 infoKey->setIcon(KIcon( QLatin1String(
"document-properties-key" )));
181 infoKey->setText(i18n(
"K&ey Properties"));
183 QAction *openKeyUrl = actionCollection()->addAction(QLatin1String(
"key_url"),
this, SLOT(slotOpenKeyUrl()));
184 openKeyUrl->setIcon(KIcon(QLatin1String(
"applications-internet")));
185 openKeyUrl->setText(i18n(
"&Open Key URL"));
187 editKey = actionCollection()->addAction(QLatin1String(
"key_edit"),
this, SLOT(slotedit()));
188 editKey->setIcon(KIcon( QLatin1String(
"utilities-terminal" )));
189 editKey->setText(i18n(
"Edit Key in &Terminal"));
190 editKey->setShortcut(QKeySequence(Qt::ALT + Qt::Key_Return));
192 KAction *generateKey = actionCollection()->addAction(QLatin1String(
"key_gener"),
this, SLOT(
slotGenerateKey()));
193 generateKey->setIcon(KIcon( QLatin1String(
"key-generate-pair" )));
194 generateKey->setText(i18n(
"&Generate Key Pair..."));
195 generateKey->setShortcuts(KStandardShortcut::shortcut(KStandardShortcut::New));
197 exportPublicKey = actionCollection()->addAction(QLatin1String(
"key_export"),
this, SLOT(slotexport()));
198 exportPublicKey->setIcon(KIcon( QLatin1String(
"document-export-key" )));
199 exportPublicKey->setShortcuts(KStandardShortcut::shortcut(KStandardShortcut::Copy));
201 KAction *importKey = actionCollection()->addAction(QLatin1String(
"key_import"),
this, SLOT(slotPreImportKey()));
202 importKey->setIcon(KIcon( QLatin1String(
"document-import-key" )));
203 importKey->setText(i18n(
"&Import Key..."));
204 importKey->setShortcuts(KStandardShortcut::shortcut(KStandardShortcut::Paste));
206 m_sendEmail = actionCollection()->addAction(QLatin1String(
"send_mail"),
this, SLOT(slotSendEmail()));
207 m_sendEmail->setIcon(KIcon(QLatin1String(
"mail-send")));
208 m_sendEmail->setText(i18n(
"Send Ema&il"));
210 QAction *newContact = actionCollection()->addAction(QLatin1String(
"add_kab"),
this, SLOT(addToKAB()));
211 newContact->setIcon(KIcon( QLatin1String(
"contact-new" )));
212 newContact->setText(i18n(
"&Create New Contact in Address Book"));
214 createGroup = actionCollection()->addAction(QLatin1String(
"create_group"),
this, SLOT(createNewGroup()));
217 editCurrentGroup = actionCollection()->addAction(QLatin1String(
"edit_group"),
this, SLOT(editGroup()));
218 editCurrentGroup->setText(i18n(
"&Edit Group..."));
220 delGroup = actionCollection()->addAction(QLatin1String(
"delete_group"),
this, SLOT(deleteGroup()));
221 delGroup->setText(i18n(
"&Delete Group"));
222 delGroup->setIcon(KIcon( QLatin1String(
"edit-delete" )));
224 m_groupRename = actionCollection()->addAction(QLatin1String(
"rename_group"),
this, SLOT(renameGroup()));
225 m_groupRename->setText(i18n(
"&Rename Group"));
226 m_groupRename->setIcon(KIcon( QLatin1String(
"edit-rename" )));
227 m_groupRename->setShortcut(QKeySequence(Qt::Key_F2));
229 deleteKey = actionCollection()->addAction(QLatin1String(
"key_delete"),
this, SLOT(confirmdeletekey()));
230 deleteKey->setIcon(KIcon( QLatin1String(
"edit-delete" )));
231 deleteKey->setShortcut(QKeySequence(Qt::Key_Delete));
233 setDefaultKey = actionCollection()->addAction(QLatin1String(
"key_default"),
this, SLOT(slotSetDefKey()));
234 setDefaultKey->setText(i18n(
"Set as De&fault Key"));
236 QAction *addPhoto = actionCollection()->addAction(QLatin1String(
"add_photo"),
this, SLOT(slotAddPhoto()));
237 addPhoto->setText(i18n(
"&Add Photo..."));
239 QAction *addUid = actionCollection()->addAction(QLatin1String(
"add_uid"),
this, SLOT(slotAddUid()));
240 addUid->setText(i18n(
"&Add User Id..."));
242 QAction *exportSecretKey = actionCollection()->addAction(QLatin1String(
"key_sexport"),
this, SLOT(slotexportsec()));
243 exportSecretKey->setText(i18n(
"Export Secret Key..."));
245 QAction *deleteKeyPair = actionCollection()->addAction(QLatin1String(
"key_pdelete"),
this, SLOT(deleteseckey()));
246 deleteKeyPair->setText(i18n(
"Delete Key Pair"));
247 deleteKeyPair->setIcon(KIcon( QLatin1String(
"edit-delete" )));
249 m_revokeKey = actionCollection()->addAction(QLatin1String(
"key_revoke"),
this, SLOT(revokeWidget()));
250 m_revokeKey->setText(i18n(
"Revoke Key..."));
252 QAction *regeneratePublic = actionCollection()->addAction(QLatin1String(
"key_regener"),
this, SLOT(slotregenerate()));
253 regeneratePublic->setText(i18n(
"&Regenerate Public Key"));
255 delUid = actionCollection()->addAction(QLatin1String(
"del_uid"),
this, SLOT(slotDelUid()));
256 delUid->setIcon(KIcon( QLatin1String(
"edit-delete" )));
258 setPrimUid = actionCollection()->addAction(QLatin1String(
"prim_uid"),
this, SLOT(slotPrimUid()));
259 setPrimUid->setText(i18n(
"Set User Id as &Primary"));
261 QAction *openPhoto = actionCollection()->addAction(QLatin1String(
"key_photo"),
this, SLOT(slotShowPhoto()));
262 openPhoto->setIcon(KIcon( QLatin1String(
"image-x-generic" )));
263 openPhoto->setText(i18n(
"&Open Photo"));
265 QAction *deletePhoto = actionCollection()->addAction(QLatin1String(
"delete_photo"),
this, SLOT(slotDeletePhoto()));
266 deletePhoto->setIcon(KIcon( QLatin1String(
"edit-delete" )));
267 deletePhoto->setText(i18n(
"&Delete Photo"));
269 delSignKey = actionCollection()->addAction(QLatin1String(
"key_delsign"),
this, SLOT(delsignkey()));
270 delSignKey->setIcon(KIcon( QLatin1String(
"edit-delete" )));
271 delSignKey->setEnabled(
false);
273 importAllSignKeys = actionCollection()->addAction(QLatin1String(
"key_importallsign"),
this, SLOT(importallsignkey()));
274 importAllSignKeys->setIcon(KIcon( QLatin1String(
"document-import" )));
275 importAllSignKeys->setText(i18n(
"Import &Missing Signatures From Keyserver"));
277 refreshKey = actionCollection()->addAction(QLatin1String(
"key_server_refresh"),
this, SLOT(refreshKeyFromServer()));
278 refreshKey->setIcon(KIcon( QLatin1String(
"view-refresh" )));
280 signKey = actionCollection()->addAction(QLatin1String(
"key_sign"),
this, SLOT(signkey()));
281 signKey->setIcon(KIcon( QLatin1String(
"document-sign-key" )));
283 signUid = actionCollection()->addAction(QLatin1String(
"key_sign_uid"),
this, SLOT(signuid()));
284 signUid->setIcon(KIcon( QLatin1String(
"document-sign-key" )));
286 signMailUid = actionCollection()->addAction(QLatin1String(
"key_sign_mail_uid"),
this, SLOT(caff()));
287 signMailUid->setIcon(KIcon( QLatin1String(
"document-sign-key" )));
289 importSignatureKey = actionCollection()->addAction(QLatin1String(
"key_importsign"),
this, SLOT(preimportsignkey()));
290 importSignatureKey->setIcon(KIcon( QLatin1String(
"document-import-key" )));
292 sTrust = actionCollection()->add<KToggleAction>(QLatin1String(
"show_trust"),
this, SLOT(slotShowTrust()));
293 sTrust->setText(i18n(
"Trust"));
295 sSize = actionCollection()->add<KToggleAction>(QLatin1String(
"show_size"),
this, SLOT(slotShowSize()));
296 sSize->setText(i18n(
"Size"));
298 sCreat = actionCollection()->add<KToggleAction>(QLatin1String(
"show_creat"),
this, SLOT(slotShowCreation()));
299 sCreat->setText(i18n(
"Creation"));
301 sExpi = actionCollection()->add<KToggleAction>(QLatin1String(
"show_expi"),
this, SLOT(slotShowExpiration()));
302 sExpi->setText(i18n(
"Expiration"));
304 photoProps = actionCollection()->add<KSelectAction>(QLatin1String(
"photo_settings" ));
305 photoProps->setIcon(KIcon( QLatin1String(
"image-x-generic" )));
306 photoProps->setText(i18n(
"&Photo ID's"));
310 list.append(i18n(
"Disable"));
311 list.append(i18nc(
"small picture",
"Small"));
312 list.append(i18nc(
"medium picture",
"Medium"));
313 list.append(i18nc(
"large picture",
"Large"));
314 photoProps->setItems(list);
316 trustProps = actionCollection()->add<KSelectAction>(QLatin1String(
"trust_filter_settings" ));
317 trustProps->setText(i18n(
"Minimum &Trust"));
320 tlist.append(i18nc(
"no filter: show all keys",
"&None"));
321 tlist.append(i18nc(
"show only active keys",
"&Active"));
322 tlist.append(i18nc(
"show only keys with at least marginal trust",
"&Marginal"));
323 tlist.append(i18nc(
"show only keys with at least full trust",
"&Full"));
324 tlist.append(i18nc(
"show only ultimately trusted keys",
"&Ultimate"));
326 trustProps->setItems(tlist);
333 connect(iview, SIGNAL(doubleClicked(QModelIndex)),
this, SLOT(defaultAction(QModelIndex)));
334 connect(iview, SIGNAL(importDrop(KUrl::List)), SLOT(
slotImport(KUrl::List)));
335 iview->setSelectionMode(QAbstractItemView::ExtendedSelection);
336 setCentralWidget(iview);
338 iview->setAlternatingRowColors(
true);
339 iview->setSortingEnabled(
true);
340 connect(iview, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(slotMenu(QPoint)));
341 iview->setContextMenuPolicy(Qt::CustomContextMenu);
342 connect(iview->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT(checkList()));
344 connect (iview, SIGNAL(returnPressed()), SLOT(slotDefaultAction()));
346 hPublic = actionCollection()->add<KToggleAction>(QLatin1String(
"show_secret"), iproxy, SLOT(setOnlySecret(
bool)));
347 hPublic->setIcon(KIcon( QLatin1String(
"view-key-secret" )));
348 hPublic->setText(i18n(
"&Show Only Secret Keys"));
352 photoProps->setCurrentItem(psize);
353 slotSetPhotoSize(psize);
355 trustProps->setCurrentItem(psize);
356 slotSetTrustFilter(psize);
359 m_popuppub =
new KMenu(
this);
360 m_popuppub->addAction(exportPublicKey);
361 m_popuppub->addAction(m_sendEmail);
362 m_popuppub->addAction(signMailUid);
363 m_popuppub->addAction(signKey);
364 m_popuppub->addAction(signUid);
365 m_popuppub->addAction(deleteKey);
366 m_popuppub->addAction(infoKey);
367 m_popuppub->addAction(openKeyUrl);
368 m_popuppub->addAction(editKey);
369 m_popuppub->addAction(refreshKey);
370 m_popuppub->addAction(createGroup);
371 m_popuppub->addSeparator();
372 m_popuppub->addAction(importAllSignKeys);
374 m_popupsec =
new KMenu(
this);
375 m_popupsec->addAction(exportPublicKey);
376 m_popupsec->addAction(m_sendEmail);
377 m_popupsec->addAction(signKey);
378 m_popupsec->addAction(signUid);
379 m_popupsec->addAction(signMailUid);
380 m_popupsec->addAction(infoKey);
381 m_popupsec->addAction(openKeyUrl);
382 m_popupsec->addAction(editKey);
383 m_popupsec->addAction(refreshKey);
384 m_popupsec->addAction(setDefaultKey);
385 m_popupsec->addSeparator();
386 m_popupsec->addAction(importAllSignKeys);
387 m_popupsec->addSeparator();
388 m_popupsec->addAction(addPhoto);
389 m_popupsec->addAction(addUid);
390 m_popupsec->addAction(exportSecretKey);
391 m_popupsec->addAction(deleteKeyPair);
393 m_popupgroup =
new KMenu(
this);
394 m_popupgroup->addAction(editCurrentGroup);
395 m_popupgroup->addAction(m_groupRename);
396 m_popupgroup->addAction(delGroup);
397 m_popupgroup->addAction(refreshKey);
399 m_popupout =
new KMenu(
this);
400 m_popupout->addAction(importKey);
402 m_popupsig =
new KMenu();
403 m_popupsig->addAction(importSignatureKey);
404 m_popupsig->addAction(delSignKey);
406 m_popupphoto =
new KMenu(
this);
407 m_popupphoto->addAction(openPhoto);
408 m_popupphoto->addAction(signUid);
409 m_popupphoto->addAction(signMailUid);
410 m_popupphoto->addAction(deletePhoto);
412 m_popupuid =
new KMenu(
this);
413 m_popupuid->addAction(m_sendEmail);
414 m_popupuid->addAction(signMailUid);
415 m_popupuid->addAction(signUid);
416 m_popupuid->addAction(delUid);
417 m_popupuid->addAction(setPrimUid);
419 m_popuporphan =
new KMenu(
this);
420 m_popuporphan->addAction(regeneratePublic);
421 m_popuporphan->addAction(deleteKeyPair);
423 exportPublicKey->setEnabled(
false);
425 KConfigGroup cg = KConfigGroup(KGlobal::config().data(),
"KeyView");
428 connect(photoProps, SIGNAL(triggered(
int)),
this, SLOT(slotSetPhotoSize(
int)));
429 connect(trustProps, SIGNAL(triggered(
int)),
this, SLOT(slotSetTrustFilter(
int)));
431 QLabel *searchLabel =
new QLabel(i18n(
"Search:"),
this);
432 m_listviewsearch =
new KLineEdit(
this);
433 m_listviewsearch->setClearButtonShown(
true);
436 QHBoxLayout *searchLayout =
new QHBoxLayout(searchWidget);
437 searchLayout->setMargin(0);
438 searchLayout->addWidget(searchLabel);
439 searchLayout->addWidget(m_listviewsearch);
440 searchLayout->addStretch();
442 KAction *searchLineAction =
new KAction(i18nc(
"Name of the action that is a search line, shown for example in the toolbar configuration dialog",
443 "Search Line"),
this);
444 actionCollection()->addAction(QLatin1String(
"search_line" ), searchLineAction);
445 searchLineAction->setDefaultWidget(searchWidget);
447 action = actionCollection()->addAction(QLatin1String(
"search_focus"), m_listviewsearch, SLOT(setFocus()));
448 action->setText(i18nc(
"Name of the action that gives the focus to the search line",
"Focus Search Line"));
449 action->setShortcut(QKeySequence(Qt::Key_F6));
450 connect(m_listviewsearch, SIGNAL(textChanged(QString)), iproxy, SLOT(setFilterFixedString(QString)));
452 setActionDescriptions(1);
455 setupGUI(KXmlGuiWindow::Create | Save | ToolBar | StatusBar | Keys, QLatin1String(
"keysmanager.rc" ));
467 KStatusBar *statusbar = statusBar();
469 statusbar->changeItem(QString(), 0);
471 cg = KConfigGroup(KGlobal::config().data(),
"MainWindow");
472 setAutoSaveSettings(cg,
true);
473 applyMainWindowSettings(cg);
477 m_netnote = Solid::Networking::notifier();
478 connect(m_netnote, SIGNAL(shouldConnect()), SLOT(slotNetworkUp()));
479 connect(m_netnote, SIGNAL(shouldDisconnect()), SLOT(slotNetworkDown()));
481 toggleNetworkActions(Solid::Networking::status() == Solid::Networking::Unknown || Solid::Networking::status() == Solid::Networking::Connected);
482 importSignatureKey->setEnabled(
false);
484 stateChanged(
"empty_list");
486 QMetaObject::invokeMethod(
this,
"refreshkey", Qt::QueuedConnection);
496 KMessageBox::error(
this,
497 i18n(
"Another key generation operation is still in progress.\nPlease wait a moment until this operation is complete."),
498 i18n(
"Generating new key pair"));
503 if (kg->exec() == QDialog::Accepted) {
504 if (!kg->isExpertMode()) {
506 kg->comment(), kg->algo(), kg->size(), kg->days(), kg->expiration(),
510 connect(m_genkey, SIGNAL(result(
KJob*)), SLOT(slotGenerateKeyDone(
KJob*)));
512 KIO::getJobTracker()->registerJob(m_genkey);
514 QApplication::setOverrideCursor(Qt::BusyCursor);
516 KConfigGroup config(KGlobal::config(),
"General");
518 QString terminalApp(config.readPathEntry(
"TerminalApplication", QLatin1String(
"konsole" )));
520 args << QLatin1String(
"-e" )
522 << QLatin1String(
"--gen-key")
523 << QLatin1String(
"--expert");
525 QProcess *genKeyProc =
new QProcess(
this);
526 genKeyProc->start(terminalApp, args);
527 if (!genKeyProc->waitForStarted(-1)) {
528 KMessageBox::error(
this, i18n(
"Generating new key pair"),
529 i18n(
"Can not start \"konsole\" application for expert mode."));
531 genKeyProc->waitForFinished(-1);
549 connect(
this, SIGNAL(
fontChanged(QFont)), kgpgtxtedit, SLOT(slotSetFont(QFont)));
554 void KeysManager::changeMessage(
const QString &msg,
const bool keep)
556 int timeout = keep ? 0 : 10000;
558 statusBar()->showMessage(msg, timeout);
561 void KeysManager::updateStatusCounter()
566 void KeysManager::slotGenerateKeyDone(
KJob *job)
568 changeMessage(i18nc(
"Application ready for user input",
"Ready"));
569 QApplication::restoreOverrideCursor();
576 const QString infomessage(i18n(
"Generating new key pair"));
580 KMessageBox::error(
this, i18n(
"Bad passphrase. Cannot generate a new key pair."), infomessage);
583 KMessageBox::error(
this, i18n(
"Aborted by the user. Cannot generate a new key pair."), infomessage);
586 KMessageBox::error(
this, i18n(
"The email address is not valid. Cannot generate a new key pair."), infomessage);
589 KMessageBox::error(
this, i18n(
"The name is not accepted by gpg. Cannot generate a new key pair."), infomessage);
592 updateStatusCounter();
594 QPointer<KDialog> keyCreated =
new KDialog(
this);
595 keyCreated->setCaption(i18n(
"New Key Pair Created"));
596 keyCreated->setButtons(KDialog::Ok);
597 keyCreated->setDefaultButton(KDialog::Ok);
598 keyCreated->setModal(
true);
601 page->TLname->setText(QLatin1String(
"<b>" ) + genkey->getName() + QLatin1String(
"</b>" ));
603 const QString email(genkey->getEmail());
604 page->TLemail->setText(QLatin1String(
"<b>" ) + email + QLatin1String(
"</b>" ));
608 if (!gpgPath.isEmpty())
609 revurl = KUrl::fromPath(gpgPath).directory(KUrl::AppendTrailingSlash);
611 revurl = QDir::homePath() + QLatin1Char(
'/' );
613 if (!email.isEmpty())
614 page->kURLRequester1->setUrl(QString(revurl + email.section(QLatin1Char(
'@' ), 0, 0) + QLatin1String(
".revoke" )));
616 page->kURLRequester1->setUrl(QString(revurl + genkey->getName().section(QLatin1Char(
' '), 0, 0) + QLatin1String(
".revoke")));
618 const QString fingerprint(genkey->getFingerprint());
619 page->TLid->setText(QLatin1String(
"<b>" ) + fingerprint.right(8) + QLatin1String(
"</b>" ));
620 page->LEfinger->setText(fingerprint);
621 page->CBdefault->setChecked(
true);
623 keyCreated->setMainWidget(page);
626 if (keyCreated.isNull())
631 if (page->CBdefault->isChecked())
636 if (page->CBsave->isChecked() || page->CBprint->isChecked()) {
638 if (page->CBsave->isChecked())
639 revurl = page->kURLRequester1->url();
642 0, i18n(
"backup copy"));
644 connect(genRev, SIGNAL(done(
int)), SLOT(slotRevokeGenerated(
int)));
646 if (page->CBprint->isChecked())
647 connect(genRev, SIGNAL(revokeCertificate(QString)), SLOT(doPrint(QString)));
655 KMessageBox::detailedError(
this,
656 i18n(
"gpg process did not finish. Cannot generate a new key pair."),
657 genkey->gpgErrorMessage(), infomessage);
663 void KeysManager::slotShowTrust()
665 bool b = !sTrust->isChecked();
671 void KeysManager::slotShowExpiration()
673 bool b = !sExpi->isChecked();
679 void KeysManager::slotShowSize()
681 bool b = !sSize->isChecked();
687 void KeysManager::slotShowCreation()
689 bool b = !sCreat->isChecked();
695 void KeysManager::slotShowLongId(
bool b)
700 void KeysManager::slotSetTrustFilter(
int i)
704 Q_ASSERT((i >= 0) && (i < 5));
727 if ((e->type() == QEvent::Show) && (showTipOfDay)) {
728 KTipDialog::showTip(
this, QLatin1String(
"kgpg/tips"),
false);
729 showTipOfDay =
false;
735 void KeysManager::slotGotoDefaultKey()
740 void KeysManager::refreshKeyFromServer()
743 if (keysList.isEmpty())
748 foreach (
KGpgNode *item, keysList) {
758 keyIDS << item->
getId();
760 KMessageBox::sorry(
this, i18n(
"You can only refresh primary keys. Please check your selection."));
767 proxy = QLatin1String( qgetenv(
"http_proxy") );
770 connect(t, SIGNAL(done(
int)), SLOT(slotKeyRefreshDone(
int)));
771 QApplication::setOverrideCursor(QCursor(Qt::BusyCursor));
775 void KeysManager::slotKeyRefreshDone(
int result)
782 QApplication::restoreOverrideCursor();
786 const QStringList log(t->
getLog());
795 QApplication::restoreOverrideCursor();
796 (void)
new KgpgDetailedInfo(
this, message.join(QLatin1String(
"\n")), log.join(QLatin1String(
"<br/>")),
800 void KeysManager::slotDelUid()
806 connect(deluid, SIGNAL(done(
int)), SLOT(slotDelUidDone(
int)));
810 void KeysManager::slotDelUidDone(
int result)
813 Q_ASSERT(deluid != NULL);
815 sender()->deleteLater();
821 void KeysManager::slotPrimUid()
825 connect(puid, SIGNAL(done(
int)), SLOT(slotPrimUidDone(
int)));
830 void KeysManager::slotPrimUidDone(
int result)
832 const QString kid(qobject_cast<KGpgPrimaryUid *>(sender())->getKeyId());
834 sender()->deleteLater();
841 void KeysManager::slotregenerate()
848 << QLatin1String(
"--no-secmem-warning")
849 << QLatin1String(
"--export-secret-key")
851 p1->setOutputChannelMode(KProcess::OnlyStdoutChannel);
854 *p2 << QLatin1String(
"gpgsplit")
855 << QLatin1String(
"--no-split")
856 << QLatin1String(
"--secret-to-public");
857 p2->setOutputChannelMode(KProcess::OnlyStdoutChannel);
861 << QLatin1String(
"--import");
863 p1->setStandardOutputProcess(p2);
864 p2->setStandardOutputProcess(p3);
870 p1->waitForFinished();
871 p2->waitForFinished();
872 p3->waitForFinished();
881 void KeysManager::slotAddUid()
884 KMessageBox::error(
this, i18n(
"Another operation is still in progress.\nPlease wait a moment until this operation is complete."),
885 i18n(
"Add New User Id"));
889 addUidWidget =
new KDialog(
this );
890 addUidWidget->setCaption( i18n(
"Add New User Id") );
891 addUidWidget->setButtons( KDialog::Ok | KDialog::Cancel );
892 addUidWidget->setDefaultButton( KDialog::Ok );
893 addUidWidget->setModal(
true );
894 addUidWidget->enableButtonOk(
false);
895 AddUid *keyUid =
new AddUid(addUidWidget);
896 addUidWidget->setMainWidget(keyUid);
898 keyUid->setMinimumWidth(300);
900 connect(keyUid->kLineEdit1, SIGNAL(textChanged(QString)),
this, SLOT(slotAddUidEnable(QString)));
901 if (addUidWidget->exec() != QDialog::Accepted)
905 keyUid->kLineEdit2->text(), keyUid->kLineEdit3->text());
906 connect(m_adduid, SIGNAL(done(
int)), SLOT(slotAddUidFin(
int)));
910 void KeysManager::slotAddUidFin(
int res)
915 m_adduid->deleteLater();
919 void KeysManager::slotAddUidEnable(
const QString & name)
921 addUidWidget->enableButtonOk(name.length() > 4);
924 void KeysManager::slotAddPhoto()
926 QString mess = i18n(
"The image must be a JPEG file. Remember that the image is stored within your public key, so "
927 "if you use a very large picture, your key will become very large as well. The size should not exceed 6 KiB. "
928 "An image size of around 240x288 is a good size to use.");
930 if (KMessageBox::warningContinueCancel(0, mess) != KMessageBox::Continue)
933 QString imagepath = KFileDialog::getOpenFileName(KUrl(), QLatin1String(
"image/jpeg" ), 0);
934 if (imagepath.isEmpty())
938 connect(addphoto, SIGNAL(done(
int)), SLOT(slotAddPhotoFinished(
int)));
942 void KeysManager::slotAddPhotoFinished(
int res)
944 sender()->deleteLater();
952 void KeysManager::slotDeletePhoto()
958 QString mess = i18n(
"<qt>Are you sure you want to delete Photo id <b>%1</b><br/>from key <b>%2 <%3></b>?</qt>",
962 connect(deluid, SIGNAL(done(
int)), SLOT(slotDelPhotoFinished(
int)));
967 void KeysManager::slotDelPhotoFinished(
int res)
969 sender()->deleteLater();
979 void KeysManager::slotUpdatePhoto()
985 void KeysManager::slotSetPhotoSize(
int size)
1003 void KeysManager::addToKAB()
1009 Akonadi::ContactSearchJob *
const job =
new Akonadi::ContactSearchJob();
1011 job->setQuery(Akonadi::ContactSearchJob::Email, nd->
getEmail());
1012 connect(job, SIGNAL(result(
KJob*)),
this, SLOT(slotAddressbookSearchResult(
KJob*)));
1017 void KeysManager::slotAddressbookSearchResult(
KJob *job)
1019 KGpgNode *
const nd = m_addIds.value(job, 0);
1024 Akonadi::ContactSearchJob *searchJob = qobject_cast<Akonadi::ContactSearchJob*>(job);
1025 Q_ASSERT(searchJob);
1026 const KABC::Addressee::List addresseeList = searchJob->contacts();
1030 Akonadi::ContactEditorDialog *dlg;
1032 if (!addresseeList.isEmpty()) {
1033 dlg =
new Akonadi::ContactEditorDialog(Akonadi::ContactEditorDialog::EditMode,
this);
1034 dlg->setContact(searchJob->items().first());
1036 KABC::Addressee addressee;
1037 addressee.setNameFromString(nd->
getName());
1038 addressee.setEmails(QStringList(nd->
getEmail()));
1039 dlg =
new Akonadi::ContactEditorDialog(Akonadi::ContactEditorDialog::CreateMode,
this);
1040 dlg->editor()->setContactTemplate(addressee);
1043 connect(dlg, SIGNAL(finished()), dlg, SLOT(deleteLater()));
1047 void KeysManager::slotManpage()
1049 KToolInvocation::startServiceByDesktopName(QLatin1String(
"khelpcenter"),
1050 QLatin1String(
"man:/gpg"), 0, 0, 0, QByteArray(),
true);
1053 void KeysManager::slotTip()
1055 KTipDialog::showTip(
this, QLatin1String(
"kgpg/tips"),
true);
1060 QPointer<KeyServer> ks =
new KeyServer(
this, imodel);
1061 connect(ks, SIGNAL(importFinished(QStringList)), imodel, SLOT(
refreshKeys(QStringList)));
1068 void KeysManager::checkList()
1072 switch (exportList.count()) {
1074 stateChanged(
"empty_list");
1078 stateChanged(QLatin1String(
"group_selected" ));
1080 stateChanged(QLatin1String(
"single_selected" ));
1081 m_revokeKey->setEnabled(exportList.at(0)->getType() ==
ITYPE_PAIR);
1083 editKey->setEnabled(
false);
1084 m_sendEmail->setEnabled(!exportList[0]->getEmail().isEmpty());
1085 setDefaultKey->setEnabled(!imodel->
isDefaultKey(exportList[0]));
1089 stateChanged(QLatin1String(
"multi_selected" ));
1092 refreshKey->setEnabled(
false);
1094 switch (exportList.at(0)->getType()) {
1096 changeMessage(i18n(
"Public Key"));
1099 changeMessage(i18n(
"Sub Key"));
1102 changeMessage(i18n(
"Secret Key Pair"));
1105 changeMessage(i18n(
"Key Group"));
1108 changeMessage(i18n(
"Signature"));
1111 changeMessage(i18n(
"User ID"));
1114 changeMessage(i18n(
"Revocation Signature"));
1117 changeMessage(i18n(
"Photo ID"));
1120 changeMessage(i18n(
"Orphaned Secret Key"));
1125 changeMessage(i18n(
"Group member"));
1128 kDebug(2100) <<
"Oops, unmatched type value" << exportList.at(0)->getType();
1132 void KeysManager::quitApp()
1141 KConfigGroup cg = KConfigGroup(KGlobal::config().data(),
"KeyView");
1154 void KeysManager::readOptions()
1156 m_clipboardmode = QClipboard::Clipboard;
1158 m_clipboardmode = QClipboard::Selection;
1161 updateStatusCounter();
1175 if (KConfigDialog::showDialog(QLatin1String(
"settings" )))
1178 QPointer<kgpgOptions> optionsDialog =
new kgpgOptions(
this, imodel);
1179 connect(optionsDialog, SIGNAL(settingsUpdated()), SLOT(
readAllOptions()));
1180 connect(optionsDialog, SIGNAL(homeChanged()), imodel, SLOT(
refreshKeys()));
1181 connect(optionsDialog, SIGNAL(homeChanged()), imodel, SLOT(refreshGroups()));
1182 connect(optionsDialog, SIGNAL(refreshTrust(KgpgCore::KgpgKeyTrust,QColor)), imodel, SLOT(refreshTrust(KgpgCore::KgpgKeyTrust,QColor)));
1183 connect(optionsDialog, SIGNAL(changeFont(QFont)), SIGNAL(
fontChanged(QFont)));
1184 optionsDialog->exec();
1185 delete optionsDialog;
1196 void KeysManager::slotSetDefKey()
1216 const QString &newID(key->
getId());
1228 KeysManager::setActionDescriptions(
int cnt)
1230 signUid->setText(i18np(
"&Sign User ID ...",
"&Sign User IDs ...", cnt));
1231 signMailUid->setText(i18np(
"Sign and &Mail User ID ...",
"Sign and &Mail User IDs ...", cnt));
1232 exportPublicKey->setText(i18np(
"E&xport Public Key...",
"E&xport Public Keys...", cnt));
1233 refreshKey->setText(i18np(
"&Refresh Key From Keyserver",
"&Refresh Keys From Keyserver", cnt));
1234 createGroup->setText(i18np(
"&Create Group with Selected Key...",
"&Create Group with Selected Keys...", cnt));
1235 signKey->setText(i18np(
"&Sign Key...",
"&Sign Keys...", cnt));
1236 delUid->setText(i18np(
"&Delete User ID",
"&Delete User IDs", cnt));
1237 delSignKey->setText(i18np(
"Delete Sign&ature",
"Delete Sign&atures", cnt));
1238 importSignatureKey->setText(i18np(
"Import Key From Keyserver",
"Import Keys From Keyserver", cnt));
1239 deleteKey->setText(i18np(
"&Delete Key",
"&Delete Keys", cnt));
1243 KeysManager::slotMenu(
const QPoint &pos)
1245 QPoint globpos = iview->mapToGlobal(pos);
1249 bool unksig =
false;
1251 int cnt = ndlist.count();
1265 getMissingSigs(l, exnd);
1271 importAllSignKeys->setEnabled(unksig && m_online);
1274 signMailUid->setEnabled(signUid->isEnabled());
1275 setActionDescriptions(cnt);
1278 bool allunksig =
true;
1285 importSignatureKey->setEnabled(allunksig && m_online);
1286 delSignKey->setEnabled( (cnt == 1) );
1287 m_popupsig->exec(globpos);
1293 m_popupuid->exec(globpos);
1294 }
else if ((itype ==
ITYPE_UAT) && (cnt == 1)) {
1295 m_popupphoto->exec(globpos);
1296 }
else if ((itype ==
ITYPE_PAIR) && (cnt == 1)) {
1297 m_popupsec->exec(globpos);
1299 m_popuporphan->exec(globpos);
1301 delGroup->setEnabled( (cnt == 1) );
1302 editCurrentGroup->setEnabled( (cnt == 1) );
1303 m_groupRename->setEnabled( (cnt == 1) );
1304 m_popupgroup->exec(globpos);
1307 deleteKey->setEnabled(!(itype & ITYPE_GROUP));
1308 setDefaultKey->setEnabled( (cnt == 1) );
1309 m_popuppub->exec(globpos);
1311 setPrimUid->setEnabled(
false);
1312 delUid->setEnabled(
false);
1313 m_popupuid->exec(globpos);
1315 m_popupout->exec(globpos);
1319 void KeysManager::revokeWidget()
1324 connect(keyRevokeDialog, SIGNAL(finished(
int)), SLOT(slotRevokeDialogFinished(
int)));
1326 keyRevokeDialog->open();
1329 void KeysManager::slotRevokeDialogFinished(
int result)
1331 sender()->deleteLater();
1333 if (result != QDialog::Accepted)
1341 connect(genRev, SIGNAL(done(
int)), SLOT(slotRevokeGenerated(
int)));
1344 connect(genRev, SIGNAL(revokeCertificate(QString)), SLOT(doPrint(QString)));
1346 connect(genRev, SIGNAL(revokeCertificate(QString)), SLOT(slotImportRevokeTxt(QString)));
1351 void KeysManager::slotRevokeGenerated(
int result)
1355 genRev->deleteLater();
1362 KMessageBox::detailedSorry(
this, i18n(
"Creation of the revocation certificate failed..."), genRev->
getOutput());
1367 void KeysManager::slotImportRevokeTxt(
const QString &revokeText)
1374 void KeysManager::slotexportsec()
1377 const QString warn(i18n(
"<qt>Secret keys <b>should not</b> be saved in an unsafe place.<br/>"
1378 "If someone else can access this file, encryption with this key will be compromised.<br/>Continue key export?</qt>"));
1379 int result = KMessageBox::warningContinueCancel(
this, warn);
1380 if (result != KMessageBox::Continue)
1384 QString sname(nd->
getEmail().section(QLatin1Char(
'@' ), 0, 0).section(QLatin1Char(
'.' ), 0, 0));
1385 if (sname.isEmpty())
1386 sname = nd->
getName().section(QLatin1Char(
' ' ), 0, 0);
1387 sname.append(QLatin1String(
".asc" ));
1388 sname.prepend(QDir::homePath() + QLatin1Char(
'/' ));
1389 KUrl url(KFileDialog::getSaveUrl(sname, i18n(
"*.asc|*.asc Files" ),
this, i18n(
"Export PRIVATE KEY As")));
1391 if(!url.isEmpty()) {
1392 KGpgExport *exp =
new KGpgExport(
this, QStringList(nd->
getId()), url.path(), QStringList(QLatin1String(
"--armor" )),
true);
1394 connect(exp, SIGNAL(done(
int)), SLOT(slotExportSecFinished(
int)));
1400 void KeysManager::slotExportSecFinished(
int result)
1403 Q_ASSERT(exp != NULL);
1406 KMessageBox::information(
this,
1407 i18n(
"<qt>Your <b>private</b> key \"%1\" was successfully exported to<br/>%2.<br/><b>Do not</b> leave it in an insecure place.</qt>",
1410 KMessageBox::sorry(
this, i18n(
"Your secret key could not be exported.\nCheck the key."));
1414 void KeysManager::slotexport()
1420 if (ndlist.isEmpty())
1427 if (ndlist.count() == 1) {
1428 sname = ndlist.at(0)->getEmail().section(QLatin1Char(
'@' ), 0, 0).section(QLatin1Char(
'.' ), 0, 0);
1429 if (sname.isEmpty())
1430 sname = ndlist.at(0)->getName().section(QLatin1Char(
' '), 0, 0);
1432 sname = QLatin1String(
"keyring" );
1435 for (
int i = 0; i < ndlist.count(); ++i) {
1436 klist << ndlist.at(i)->getId();
1439 sname.append(QLatin1String(
".asc" ));
1440 sname.prepend(QDir::homePath() + QLatin1Char(
'/' ));
1443 serverList.replaceInStrings(QRegExp( QLatin1String(
" .*") ), QLatin1String(
"" ) );
1444 if (!serverList.isEmpty()) {
1445 QString defaultServer = serverList.takeFirst();
1447 serverList.prepend(defaultServer);
1450 QPointer<KeyExport> page =
new KeyExport(
this, serverList);
1452 page->newFilename->setUrl(sname);
1455 page->checkServer->setEnabled(
false);
1457 if (page->exec() == QDialog::Accepted) {
1461 if (page->checkAttrAll->isChecked()) {
1463 }
else if (page->checkAttrPhoto->isChecked()) {
1464 exportAttr = QLatin1String(
"no-export-attributes" );
1466 exportAttr = QLatin1String(
"export-minimal" );
1468 QStringList expopts;
1470 if (!exportAttr.isEmpty())
1471 expopts << QLatin1String(
"--export-options" ) << exportAttr;
1473 if (page->checkServer->isChecked()) {
1479 }
else if (page->checkFile->isChecked()) {
1480 const QString expname(page->newFilename->url().path().simplified());
1481 if (!expname.isEmpty()) {
1483 expopts.append(QLatin1String(
"--armor" ));
1487 connect(exp, SIGNAL(done(
int)), SLOT(slotExportFinished(
int)));
1494 if (page->checkClipboard->isChecked())
1495 connect(exp, SIGNAL(done(
int)), SLOT(slotProcessExportClip(
int)));
1497 connect(exp, SIGNAL(done(
int)), SLOT(slotProcessExportMail(
int)));
1506 void KeysManager::slotExportFinished(
int result)
1509 Q_ASSERT(exp != NULL);
1512 KMessageBox::information(
this,
1513 i18np(
"<qt>The public key was successfully exported to<br/>%2</qt>",
1514 "<qt>The %1 public keys were successfully exported to<br/>%2</qt>",
1517 KMessageBox::sorry(
this, i18n(
"Your public key could not be exported\nCheck the key."));
1523 void KeysManager::slotProcessExportMail(
int result)
1526 Q_ASSERT(exp != NULL);
1530 KToolInvocation::invokeMailer(QString(), QString(), QString(), QString(),QLatin1String( exp->
getOutputData() ));
1532 KMessageBox::sorry(
this, i18n(
"Your public key could not be exported\nCheck the key."));
1538 void KeysManager::slotProcessExportClip(
int result)
1541 Q_ASSERT(exp != NULL);
1544 kapp->clipboard()->setText(QLatin1String( exp->
getOutputData() ), m_clipboardmode);
1546 KMessageBox::sorry(
this, i18n(
"Your public key could not be exported\nCheck the key."));
1559 showProperties(key);
1562 void KeysManager::slotShowPhoto()
1564 KService::List list(KMimeTypeTrader::self()->query(QLatin1String(
"image/jpeg" )));
1565 if (list.isEmpty()) {
1566 KMessageBox::sorry(NULL, i18n(
"<qt>A viewer for JPEG images is not specified.<br/>Please check your installation.</qt>"),
1567 i18n(
"Show photo"));
1573 KService::Ptr ptr = list.first();
1577 << QLatin1String(
"--no-tty")
1578 << QLatin1String(
"--photo-viewer")
1579 << (ptr->desktopEntryName() + QLatin1String(
" %i" ))
1580 << QLatin1String(
"--edit-key")
1582 << QLatin1String(
"uid")
1584 << QLatin1String(
"showphoto")
1585 << QLatin1String(
"quit");
1589 void KeysManager::defaultAction(
const QModelIndex &index)
1596 void KeysManager::slotDefaultAction()
1601 void KeysManager::defaultAction(
KGpgNode *nd)
1633 KeysManager::showProperties(
KGpgNode *n)
1641 QPointer<KgpgKeyInfo> opts =
new KgpgKeyInfo(k, imodel,
this);
1652 void KeysManager::keyproperties()
1663 if (KMessageBox::questionYesNo(
this,
1664 i18n(
"<p>This key is an orphaned secret key (secret key without public key.) It is currently not usable.</p>"
1665 "<p>Would you like to regenerate the public key?</p>"),
1666 QString(), KGuiItem(i18n(
"Generate")), KGuiItem(i18n(
"Do Not Generate"))) == KMessageBox::Yes)
1670 case ITYPE_PUBLIC: {
1680 kDebug(2100) <<
"Oops, called with invalid item type" << cur->
getType();
1684 QPointer<KgpgKeyInfo> opts =
new KgpgKeyInfo(kn, imodel,
this);
1690 void KeysManager::deleteGroup()
1696 int result = KMessageBox::warningContinueCancel(
this, i18n(
"<qt>Are you sure you want to delete group <b>%1</b> ?</qt>",
1697 nd->
getName()), QString(), KGuiItem(i18n(
"Delete"), QLatin1String(
"edit-delete")));
1698 if (result != KMessageBox::Continue)
1704 updateStatusCounter();
1707 void KeysManager::renameGroup()
1709 if (iview->selectionModel()->selectedIndexes().isEmpty())
1712 QModelIndex selectedNodeIndex = iview->selectionModel()->selectedIndexes().first();
1714 iview->edit(selectedNodeIndex);
1717 void KeysManager::createNewGroup()
1719 QStringList badkeys;
1724 if (ndlist.isEmpty())
1727 KMessageBox::sorry(
this, i18n(
"<qt>You cannot create a group containing signatures, subkeys or other groups.</qt>"));
1742 badkeys += i18nc(
"<Name> (<Email>) ID: <KeyId>",
"%1 (%2) ID: %3",
1747 QString groupName(KInputDialog::getText(i18n(
"Create New Group"),
1748 i18nc(
"Enter the name of the group you are creating now",
"Enter new group name:"),
1749 QString(), 0,
this));
1750 if (groupName.isEmpty())
1752 if (!keysList.isEmpty()) {
1753 if (!badkeys.isEmpty())
1754 KMessageBox::informationList(
this, i18n(
"Following keys are not valid or not trusted and will not be added to the group:"), badkeys);
1757 updateStatusCounter();
1759 KMessageBox::sorry(
this,
1760 i18n(
"<qt>No valid or trusted key was selected. The group <b>%1</b> will not be created.</qt>",
1765 void KeysManager::editGroup()
1771 QPointer<KDialog> dialogGroupEdit =
new KDialog(
this );
1772 dialogGroupEdit->setCaption( i18n(
"Group Properties") );
1773 dialogGroupEdit->setButtons( KDialog::Ok | KDialog::Cancel );
1774 dialogGroupEdit->setDefaultButton( KDialog::Ok );
1775 dialogGroupEdit->setModal(
true );
1779 groupEdit *gEdit =
new groupEdit(dialogGroupEdit, &members, imodel);
1781 dialogGroupEdit->setMainWidget(gEdit);
1785 if (dialogGroupEdit->exec() == QDialog::Accepted)
1788 delete dialogGroupEdit;
1791 void KeysManager::signkey()
1794 if (!signList.isEmpty())
1799 if (tmplist.isEmpty())
1803 KMessageBox::sorry(
this, i18n(
"You can only sign primary keys. Please check your selection."));
1807 if (tmplist.count() == 1) {
1812 opt = i18n(
"<qt>You are about to sign key:<br /><br />%1<br />ID: %2<br />Fingerprint: <br /><b>%3</b>.<br /><br />"
1813 "You should check the key fingerprint by phoning or meeting the key owner to be sure that someone "
1814 "is not trying to intercept your communications.</qt>",
1817 opt = i18n(
"<qt>You are about to sign key:<br /><br />%1 (%2)<br />ID: %3<br />Fingerprint: <br /><b>%4</b>.<br /><br />"
1818 "You should check the key fingerprint by phoning or meeting the key owner to be sure that someone "
1819 "is not trying to intercept your communications.</qt>",
1822 if (KMessageBox::warningContinueCancel(
this, opt) != KMessageBox::Continue) {
1825 signList.append(nd);
1827 QStringList signKeyList;
1839 if (KMessageBox::Continue != KMessageBox::warningContinueCancelList(
this,
1840 i18n(
"<qt>You are about to sign the following keys in one pass.<br/><b>If you have not carefully checked all fingerprints,"
1841 " the security of your communications may be compromised.</b></qt>"),
1846 QPointer<KgpgSelectSecretKey> opts =
new KgpgSelectSecretKey(
this, imodel, signList.count());
1847 if (opts->exec() != QDialog::Accepted) {
1853 globalkeyID = QString(opts->getKeyID());
1854 const bool localsign = opts->isLocalSign();
1855 const int checklevel = opts->getSignTrust();
1856 bool isterminal = opts->isTerminalSign();
1860 const QString keyid(signList.at(0)->getId());
1862 signKeyOpenConsole(globalkeyID, keyid, checklevel, localsign);
1866 signLoop(localsign, checklevel);
1870 void KeysManager::signuid()
1873 if (!signList.isEmpty())
1878 if (tmplist.isEmpty())
1882 KMessageBox::sorry(
this, i18n(
"You can only sign user ids and photo ids. Please check your selection."));
1886 if (tmplist.count() == 1) {
1889 if (tp & ITYPE_PUBLIC)
1896 opt = i18n(
"<qt>You are about to sign user id:<br /><br />%1<br />ID: %2<br />Fingerprint: <br /><b>%3</b>.<br /><br />"
1897 "You should check the key fingerprint by phoning or meeting the key owner to be sure that someone "
1900 opt = i18n(
"<qt>You are about to sign user id:<br /><br />%1 (%2)<br />ID: %3<br />Fingerprint: <br /><b>%4</b>.<br /><br />"
1901 "You should check the key fingerprint by phoning or meeting the key owner to be sure that someone "
1904 if (KMessageBox::warningContinueCancel(
this, opt) != KMessageBox::Continue) {
1907 signList.append(nd);
1909 QStringList signKeyList;
1916 signKeyList += i18nc(
"Name: ID",
"%1: %2",
1919 signKeyList += i18nc(
"Name (Email): ID",
"%1 (%2): %3",
1925 if (KMessageBox::warningContinueCancelList(
this,
1926 i18n(
"<qt>You are about to sign the following user ids in one pass.<br/><b>If you have not carefully checked all fingerprints,"
1927 " the security of your communications may be compromised.</b></qt>"),
1928 signKeyList) != KMessageBox::Continue)
1932 QPointer<KgpgSelectSecretKey> opts =
new KgpgSelectSecretKey(
this, imodel, signList.count());
1933 if (opts->exec() != QDialog::Accepted) {
1939 globalkeyID = QString(opts->getKeyID());
1940 const bool localsign = opts->isLocalSign();
1941 const int checklevel = opts->getSignTrust();
1942 bool isterminal = opts->isTerminalSign();
1946 const QString keyid(signList.at(0)->getId());
1948 signKeyOpenConsole(globalkeyID, keyid, checklevel, localsign);
1952 signLoop(localsign, checklevel);
1956 void KeysManager::signLoop(
const bool localsign,
const int checklevel)
1958 Q_ASSERT(keyCount < signList.count());
1967 sta =
new KGpgSignUid(
this, globalkeyID, nd, localsign, cc);
1969 sta =
new KGpgSignKey(
this, globalkeyID, nd->toKeyNode(), localsign, cc);
1972 connect(sta, SIGNAL(done(
int)), SLOT(signatureResult(
int)));
1976 void KeysManager::signatureResult(
int success)
1986 const bool localsign = ta->
getLocal();
1989 sender()->deleteLater();
1993 if (refreshList.indexOf(nd) == -1)
1994 refreshList.append(nd);
1997 KMessageBox::sorry(
this, i18n(
"<qt>Bad passphrase, key <b>%1 (%2)</b> not signed.</qt>",
2001 KMessageBox::sorry(
this, i18n(
"<qt>The key <b>%1 (%2)</b> is already signed.</qt>",
2005 if (KMessageBox::questionYesNo(
this,
2006 i18n(
"<qt>Signing key <b>%1</b> with key <b>%2</b> failed.<br />"
2007 "Do you want to try signing the key in console mode?</qt>",
2008 nd->
getId(), signer)) == KMessageBox::Yes)
2009 signKeyOpenConsole(signer, nd->
getId(), checklevel, localsign);
2012 if (++keyCount == signList.count()) {
2015 refreshList.clear();
2017 signLoop(localsign, checklevel);
2021 void KeysManager::caff()
2026 if (tmplist.isEmpty())
2030 KMessageBox::sorry(
this, i18n(
"You can only sign user ids and photo ids. Please check your selection."));
2046 QPointer<KgpgSelectSecretKey> opts =
new KgpgSelectSecretKey(
this, imodel, slist.count(),
false,
false);
2047 if (opts->exec() != QDialog::Accepted) {
2052 KGpgCaff *ca =
new KGpgCaff(
this, slist, QStringList(opts->getKeyID()), opts->getSignTrust());
2055 connect(ca, SIGNAL(done()), SLOT(slotCaffDone()));
2056 connect(ca, SIGNAL(aborted()), SLOT(slotCaffDone()));
2061 void KeysManager::slotCaffDone()
2063 Q_ASSERT(qobject_cast<KGpgCaff *>(sender()) != NULL);
2065 sender()->deleteLater();
2068 void KeysManager::signKeyOpenConsole(
const QString &signer,
const QString &keyid,
const int checking,
const bool local)
2070 KConfigGroup config(KGlobal::config(),
"General");
2073 process << config.readPathEntry(
"TerminalApplication", QLatin1String(
"konsole"))
2074 << QLatin1String(
"-e")
2076 << QLatin1String(
"--no-secmem-warning")
2077 << QLatin1String(
"-u") << signer
2078 << QLatin1String(
"--default-cert-level")
2079 << QString(checking);
2082 process << QLatin1String(
"--sign-key" ) << keyid;
2084 process << QLatin1String(
"--lsign-key" ) << keyid;
2089 void KeysManager::getMissingSigs(QSet<QString> &missingKeys,
const KGpgExpandableNode *nd)
2097 missingKeys << ch->
getId();
2102 void KeysManager::importallsignkey()
2105 QSet<QString> missingKeys;
2110 foreach (
const KGpgNode *nd, sel) {
2117 missingKeys << sn->
getId();
2121 if (missingKeys.isEmpty()) {
2122 KMessageBox::information(
this,
2123 i18np(
"All signatures for this key are already in your keyring",
2124 "All signatures for this keys are already in your keyring", sel.count()));
2131 void KeysManager::preimportsignkey()
2136 if (exportList.empty())
2139 foreach (
const KGpgNode *nd, exportList)
2140 idlist << nd->
getId();
2147 return importRemoteKeys(keyIDs.simplified().split(QLatin1Char(
' ' )),
false);
2153 if (kservers.isEmpty())
2157 connect(proc, SIGNAL(done(
int)), SLOT(importRemoteFinished(
int)));
2164 void KeysManager::importRemoteFinished(
int result)
2167 Q_ASSERT(t != NULL);
2182 void KeysManager::delsignkey()
2195 uid = QLatin1Char(
'1' );
2196 parentKey = parent->
getId();
2200 uid = parent->
getId();
2208 const QString signID(nd->
getId());
2213 parentMail += QLatin1String(
" <" ) + parent->
getEmail() + QLatin1String(
">" );
2215 signMail += QLatin1String(
" <" ) + nd->
getEmail() + QLatin1String(
">" );
2217 if (parentKey == signID) {
2218 KMessageBox::sorry(
this, i18n(
"Edit key manually to delete a self-signature."));
2222 QString ask = i18n(
"<qt>Are you sure you want to delete signature<br /><b>%1</b><br />from user id <b>%2</b><br />of key: <b>%3</b>?</qt>",
2223 signMail, parentMail, parentKey);
2225 if (KMessageBox::questionYesNo(
this, ask, QString(), KStandardGuiItem::del(), KStandardGuiItem::cancel()) != KMessageBox::Yes)
2229 connect(delsig, SIGNAL(done(
int)), SLOT(delsignatureResult(
int)));
2233 void KeysManager::delsignatureResult(
int success)
2235 sender()->deleteLater();
2244 KMessageBox::sorry(
this, i18n(
"Requested operation was unsuccessful, please edit the key manually."));
2248 void KeysManager::slotSendEmail()
2250 QStringList maillist;
2256 maillist << QLatin1Char(
'"') + nd->
getName() + QLatin1String(
"\" <") + nd->
getEmail() + QLatin1Char(
'>');
2259 if (maillist.isEmpty())
2262 KToolInvocation::invokeMailer(maillist.join(QLatin1String(
", ")), QString());
2265 void KeysManager::slotedit()
2268 Q_ASSERT(nd != NULL);
2274 if ((m_delkey != NULL) && m_delkey->
keys().contains(nd->
toKeyNode()))
2278 KConfigGroup config(KGlobal::config(),
"General");
2279 *kp << config.readPathEntry(
"TerminalApplication", QLatin1String(
"konsole"))
2280 << QLatin1String(
"-e")
2282 << QLatin1String(
"--no-secmem-warning")
2283 << QLatin1String(
"--edit-key")
2285 << QLatin1String(
"help");
2287 editKey->setEnabled(
false);
2289 connect(kp, SIGNAL(finished(
int)), SLOT(slotEditDone(
int)));
2293 void KeysManager::slotEditDone(
int exitcode)
2299 editKey->setEnabled(
true);
2302 void KeysManager::doPrint(
const QString &txt)
2306 QPointer<QPrintDialog> printDialog =
new QPrintDialog(&prt,
this);
2307 if (printDialog->exec() == QDialog::Accepted) {
2308 QPainter painter(&prt);
2309 int width = painter.device()->width();
2310 int height = painter.device()->height();
2311 painter.drawText(0, 0, width, height, Qt::AlignLeft|Qt::AlignTop|Qt::TextDontClip, txt);
2318 QStringList groupNames;
2323 if (groupNames.isEmpty())
2326 const QString ask = i18np(
"<qt>The key you are deleting is a member of the following key group. Do you want to remove it from this group?</qt>",
2327 "<qt>The key you are deleting is a member of the following key groups. Do you want to remove it from these groups?</qt>",
2328 groupNames.count());
2330 if (KMessageBox::questionYesNoList(
this, ask, groupNames, i18n(
"Delete key")) != KMessageBox::Yes)
2333 bool groupDeleted =
false;
2340 if (deleteWholeGroup)
2341 deleteWholeGroup = (KMessageBox::questionYesNo(
this,
2342 i18n(
"You are removing the last key from key group %1.<br/>Do you want to delete the group, too?", group->
getName()),
2343 i18n(
"Delete key")) == KMessageBox::Yes);
2345 if (!deleteWholeGroup) {
2350 groupDeleted =
true;
2355 updateStatusCounter();
2359 void KeysManager::deleteseckey()
2362 Q_ASSERT(nd != NULL);
2365 int result = KMessageBox::warningContinueCancel(
this,
2366 i18n(
"<p>Delete <b>secret</b> key pair <b>%1</b>?</p>Deleting this key pair means you will never be able to decrypt files encrypted with this key again.",
2369 KGuiItem(i18n(
"Delete"), QLatin1String(
"edit-delete" )));
2370 if (result != KMessageBox::Continue)
2373 if (terminalkey == nd)
2375 if (m_delkey != NULL) {
2376 KMessageBox::error(
this,
2377 i18n(
"Another key delete operation is still in progress.\nPlease wait a moment until this operation is complete."),
2378 i18n(
"Delete key"));
2385 connect(m_delkey, SIGNAL(done(
int)), SLOT(secretKeyDeleted(
int)));
2389 void KeysManager::secretKeyDeleted(
int retcode)
2393 KMessageBox::information(
this, i18n(
"Key <b>%1</b> deleted.", delkey->
getBeautifiedFingerprint()), i18n(
"Delete key"));
2396 KMessageBox::error(
this, i18n(
"Deleting key <b>%1</b> failed.", delkey->
getBeautifiedFingerprint()), i18n(
"Delete key"));
2398 m_delkey->deleteLater();
2402 void KeysManager::confirmdeletekey()
2405 KMessageBox::error(
this,
2406 i18n(
"Another key delete operation is still in progress.\nPlease wait a moment until this operation is complete."),
2407 i18n(
"Delete key"));
2411 KgpgCore::KgpgItemType pt;
2414 if (ndlist.isEmpty())
2418 if ((!(pt & ~
ITYPE_PAIR)) && (ndlist.at(0) == terminalkey) && (ndlist.count() == 1)) {
2419 KMessageBox::error(
this,
2420 i18n(
"Can not delete key <b>%1</b> while it is edited in terminal.",
2423 }
else if (pt == ITYPE_GROUP) {
2426 }
else if (!(pt & ITYPE_GROUP) && (pt &
ITYPE_SECRET) && (ndlist.count() == 1)) {
2429 }
else if ((pt ==
ITYPE_UID) && (ndlist.count() == 1)) {
2435 KMessageBox::error(
this,
2436 i18n(
"You have selected items that are not keys. They can not be deleted with this menu entry."),
2437 i18n(
"Delete key"));
2441 QStringList keysToDelete;
2442 QStringList deleteIds;
2443 QStringList secList;
2452 }
else if (ki != terminalkey) {
2454 deleteIds << ki->
getId();
2459 if (secretKeyInside) {
2460 int result = KMessageBox::warningContinueCancel(
this,
2461 i18n(
"<qt>The following are secret key pairs:<br/><b>%1</b><br/>They will not be deleted.</qt>",
2462 secList.join( QLatin1String(
"<br />" ))));
2463 if (result != KMessageBox::Continue)
2467 if (keysToDelete.isEmpty())
2470 int result = KMessageBox::warningContinueCancelList(
this,
2471 i18np(
"<qt><b>Delete the following public key?</b></qt>",
2472 "<qt><b>Delete the following %1 public keys?</b></qt>",
2473 keysToDelete.count()), keysToDelete, QString(),
2474 KStandardGuiItem::del());
2475 if (result != KMessageBox::Continue)
2482 connect(m_delkey, SIGNAL(done(
int)), SLOT(slotDelKeyDone(
int)));
2486 void KeysManager::slotDelKeyDone(
int res)
2493 m_delkey->deleteLater();
2496 updateStatusCounter();
2499 void KeysManager::slotPreImportKey()
2501 QPointer<KDialog> dial =
new KDialog(
this);
2502 dial->setCaption(i18n(
"Key Import"));
2503 dial->setButtons(KDialog::Ok | KDialog::Cancel);
2504 dial->setDefaultButton(KDialog::Ok);
2505 dial->setModal(
true);
2507 SrcSelect *page =
new SrcSelect();
2508 dial->setMainWidget(page);
2509 page->newFilename->setWindowTitle(i18n(
"Open File"));
2510 page->newFilename->setMode(KFile::File);
2512 if (dial->exec() == QDialog::Accepted) {
2513 if (page->checkFile->isChecked()) {
2514 KUrl impname = page->newFilename->url();
2515 if (!impname.isEmpty())
2517 }
else if (page->checkServer->isChecked()) {
2518 const QString ids(page->keyIds->text().simplified());
2522 slotImport(kapp->clipboard()->text(m_clipboardmode));
2537 if (KMessageBox::questionYesNo(
this,
2538 i18n(
"<qt>The text in the clipboard does not look like a key, but like encrypted text.<br />Do you want to decrypt it first"
2539 " and then try importing it?</qt>"),
2540 i18n(
"Import from Clipboard")) != KMessageBox::Yes)
2558 void KeysManager::startImport(
KGpgImport *
import)
2560 changeMessage(i18n(
"Importing..."),
true);
2568 Q_ASSERT(
import != NULL);
2569 const QStringList rawmsgs(import->getMessages());
2572 KMessageBox::detailedSorry(
this, i18n(
"Key importing failed. Please see the detailed log for more information."),
2573 rawmsgs.join(QLatin1String(
"\n")) , i18n(
"Key Import"));
2576 QStringList keys(import->getImportedIds(0x1f));
2577 const bool needsRefresh = !keys.isEmpty();
2578 keys <<
import->getImportedIds(0);
2580 if (!keys.isEmpty()) {
2581 const QString msg(import->getImportMessage());
2582 const QStringList keynames(import->getImportedKeys());
2584 new KgpgDetailedInfo(
this, msg, rawmsgs.join(QLatin1String(
"\n")), keynames, i18n(
"Key Import"));
2588 changeMessage(i18nc(
"Application ready for user input",
"Ready"));
2590 changeMessage(i18nc(
"Application ready for user input",
"Ready"));
2593 import->deleteLater();
2599 updateStatusCounter();
2608 KeysManager::slotNetworkUp()
2610 toggleNetworkActions(
true);
2614 KeysManager::slotNetworkDown()
2616 toggleNetworkActions(
false);
2620 KeysManager::toggleNetworkActions(
bool online)
2623 kserver->setEnabled(online);
2624 importSignatureKey->setEnabled(online);
2625 importAllSignKeys->setEnabled(online);
2626 refreshKey->setEnabled(online);
2630 KeysManager::setupTrayIcon()
2632 bool newtray = (m_trayicon == NULL);
2635 m_trayicon =
new KStatusNotifierItem(
this);
2636 m_trayicon->setIconByName(QLatin1String(
"kgpg" ));
2637 m_trayicon->setToolTip(QLatin1String(
"kgpg" ), i18n(
"KGpg - encryption tool"), QString());
2645 m_trayicon->setAssociatedWidget(
this);
2649 m_trayicon->setCategory(KStatusNotifierItem::ApplicationStatus);
2654 KMenu *conf_menu = m_trayicon->contextMenu();
2656 QAction *KgpgOpenManager = actionCollection()->addAction(QLatin1String(
"kgpg_manager"),
this, SLOT(show()));
2657 KgpgOpenManager->setIcon(KIcon( QLatin1String(
"kgpg" )));
2658 KgpgOpenManager->setText(i18n(
"Ke&y Manager"));
2660 QAction *KgpgEncryptClipboard = actionCollection()->addAction(QLatin1String(
"clip_encrypt"),
this, SLOT(
clipEncrypt()));
2661 KgpgEncryptClipboard->setText(i18n(
"&Encrypt Clipboard"));
2663 QAction *KgpgDecryptClipboard = actionCollection()->addAction(QLatin1String(
"clip_decrypt"),
this, SLOT(
clipDecrypt()));
2664 KgpgDecryptClipboard->setText(i18n(
"&Decrypt Clipboard"));
2666 QAction *KgpgSignClipboard = actionCollection()->addAction(QLatin1String(
"clip_sign"),
this, SLOT(
clipSign()));
2667 KgpgSignClipboard->setText(i18n(
"&Sign/Verify Clipboard"));
2668 KgpgSignClipboard->setIcon(KIcon( QLatin1String(
"document-sign-key" )));
2670 QAction *KgpgPreferences = KStandardAction::preferences(
this, SLOT(
showOptions()), actionCollection());
2672 conf_menu->addAction( KgpgEncryptClipboard );
2673 conf_menu->addAction( KgpgDecryptClipboard );
2674 conf_menu->addAction( KgpgSignClipboard );
2675 conf_menu->addAction( KgpgOpenManager );
2676 conf_menu->addAction( openEditor );
2677 conf_menu->addAction( kserver );
2678 conf_menu->addSeparator();
2679 conf_menu->addAction( KgpgPreferences );
2685 if (m_trayicon == NULL)
2688 m_trayicon->showMessage(QString(), message, QLatin1String(
"kgpg" ));
2694 return goToDefaultKey->shortcut();
2700 const QString cliptext(kapp->clipboard()->text(m_clipboardmode));
2702 if (cliptext.isEmpty()) {
2703 Q_ASSERT(m_trayicon != NULL);
2704 m_trayicon->showMessage(QString(), i18n(
"Clipboard is empty."), QLatin1String(
"kgpg" ));
2708 QPointer<KgpgSelectPublicKeyDlg> dialog =
new KgpgSelectPublicKeyDlg(
this, imodel, goToDefaultKey->shortcut(),
true);
2709 if (dialog->exec() == KDialog::Accepted) {
2711 QStringList options;
2714 options = dialog->getCustomOptions().split(QLatin1Char(
' '), QString::SkipEmptyParts);
2716 if (dialog->getUntrusted())
2718 if (dialog->getHideId())
2722 options.append(QLatin1String(
"--pgp6" ));
2725 connect(enc, SIGNAL(done(
int)), SLOT(slotSetClip(
int)));
2727 m_trayicon->setStatus(KStatusNotifierItem::Active);
2735 KeysManager::slotSetClip(
int result)
2738 Q_ASSERT(enc != NULL);
2739 sender()->deleteLater();
2741 m_trayicon->setStatus(KStatusNotifierItem::Passive);
2746 kapp->clipboard()->setText(enc->
encryptedText().join(QLatin1String(
"\n")), m_clipboardmode);
2748 Q_ASSERT(m_trayicon != NULL);
2749 m_trayicon->showMessage(QString(), i18n(
"Text successfully encrypted."), QLatin1String(
"kgpg" ));
2753 KeysManager::slotOpenKeyUrl()
2763 case ITYPE_PUBLIC: {
2777 if (servers.isEmpty())
2780 QString url = servers.first();
2782 url.replace(QLatin1String(
"$$ID8$$"),
id.right(8).toUpper());
2783 url.replace(QLatin1String(
"$$ID16$$"),
id.toUpper());
2784 url.replace(QLatin1String(
"$$FPR$$"),
id.toUpper());
2785 url.replace(QLatin1String(
"$$id8$$"),
id.right(8).toLower());
2786 url.replace(QLatin1String(
"$$id16$$"),
id.toLower());
2787 url.replace(QLatin1String(
"$$fpr$$"),
id.toLower());
2789 new KRun(url,
this);
2795 const QString cliptext(kapp->clipboard()->text(m_clipboardmode).trimmed());
2797 if (cliptext.isEmpty()) {
2798 Q_ASSERT(m_trayicon != NULL);
2799 m_trayicon->showMessage(QString(), i18n(
"Clipboard is empty."), QLatin1String(
"kgpg" ));
2804 kgpgtxtedit->setAttribute(Qt::WA_DeleteOnClose);
2805 connect(
this, SIGNAL(
fontChanged(QFont)), kgpgtxtedit, SLOT(slotSetFont(QFont)));
2806 kgpgtxtedit->
m_editor->setPlainText(cliptext);
2808 kgpgtxtedit->show();
2814 QString cliptext = kapp->clipboard()->text(m_clipboardmode);
2815 if (cliptext.isEmpty()) {
2816 Q_ASSERT(m_trayicon != NULL);
2817 m_trayicon->showMessage(QString(), i18n(
"Clipboard is empty."), QLatin1String(
"kgpg" ));
2822 kgpgtxtedit->setAttribute(Qt::WA_DeleteOnClose);
2823 connect(kgpgtxtedit->
m_editor, SIGNAL(verifyFinished()), kgpgtxtedit, SLOT(closeWindow()));
2826 kgpgtxtedit->show();
2829 #include "keysmanager.moc"
static void setShowLongKeyId(bool v)
Set Show long key id in key manager.
KgpgTextEdit *const m_editor
KgpgKeyTrustFlag
trust levels of keys, uids and uats
static int leftClick()
Get Choose default left-click behavior.
static void setShowExpi(bool v)
Set Show the expiration value in key manager.
decrypt the given text or files
static bool showTipOfDay()
Get Show tip of the day.
static bool pgpCompatibility()
Get Enable PGP 6 compatibility.
there is a minimal level of trust
key pair as member of a key group
void selectNode(KGpgNode *nd)
int getResultCode() const
get the result of the transaction
void showKeyInfo(const QString &keyID)
helper class for key signing transactions
const QStringList & getKeyIds() const
return the key ids to export
virtual QString getName() const
static bool allowUntrustedGroupMembers()
Get Allow untrusted keys to become members of key groups.
KGpgExpandableNode * getParentKeyNode() const
Returns the parent node in the key hierarchy.
static QString defaultKey()
virtual const KGpgNode::List & getChildren() const
QList< KGpgKeyNode * > List
const QByteArray & getOutputData() const
return the data read from standard output
static QString gpgConfigPath()
Get The path of the gpg configuration file.
bool isDefaultKey(const KGpgNode *node) const
void slotSetKeyserver(const QString &server)
shows a dialog to select a public key for encryption
static bool showCreat()
Get Show the creation value in key manager.
output the data as printable ASCII as opposed to binary data
const QString & getOutputFile() const
return the output filename currently set
A GnuPG group of public keys.
export one or more keys from keyring
KGpgGroupNode * addGroup(const QString &name, const KGpgKeyNode::List &keys)
virtual QString getNameComment() const
bool eventFilter(QObject *, QEvent *e)
void removeFromGroups(KGpgKeyNode *nd)
virtual QString getId() const
void refreshKey(const QString &id)
add a new user id to a key pair
transaction class to change the primary user id of a key
void restoreLayout(KConfigGroup &cg)
static bool showSystray()
Get Show the systray icon.
static bool showLongKeyId()
Get Show long key id in key manager.
import one or more keys into the keyring
public key as member of a key group
KGpgNode * nodeForIndex(const QModelIndex &index) const
Wrap a GnuPG transaction in a job.
QList< KGpgNode * > selectedNodes(bool *psame=NULL, KgpgCore::KgpgItemType *pt=NULL) const
QString getImportMessage() const
get textual summary of the import events
carefulCheck getChecking(void) const
check if local signing is requested
QString getSigner(void) const
get key id which is used to sign
bool isUnknown() const
Check if the referenced key exists.
virtual QString getName() const
static void setPhotoProperties(int v)
Set photo properties.
static QString statusCountMessageString(const unsigned int keys, const unsigned int groups)
transaction class to sign a single user id of a key
QString getKeyId(void) const
return the key id of the current transaction
void setInputTransaction(KGpgTransaction *ta)
connect the standard input of this transaction to another process
static QStringList infoServers()
Get List of URLs that show details and analysis of the given key.
void start()
Start the operation.
KGpgNode * selectedNode() const
KGpgRefNode * toRefNode()
void setDefaultKeyNode(KGpgKeyNode *key)
virtual KGpgNode * getChild(const int index) const
Returns the child node at the given index.
void signVerifyText(const QString &message)
void setKeyModel(KGpgItemModel *)
void saveToggleOpts(void)
bool getLocal(void) const
check if local signing is requested
QString getKeyid() const
return the id of the key we are editing
A public key with or without corresponding secret key.
KRecentFilesAction * m_recentfiles
static QString getDetailedImportMessage(const QStringList &log, const KGpgItemModel *model=NULL)
get detailed summary of import
static void setShowSize(bool v)
Set Show the size value in key manager.
KGpgItemModel * getModel()
static bool isEncryptedText(const QString &text, int *startPos=NULL, int *endPos=NULL)
check if the given text contains an encoded message
virtual KgpgCore::KgpgItemType getType() const =0
Returns the item type of this object.
const QStringList & getLog() const
void refreshKeys(const QStringList &ids)
generate a revokation certificate
secret key as member of a key group
KGpgSignableNode * toSignableNode()
void slotSetDefaultKey(const QString &newID)
KgpgEditor * s_kgpgEditor
void setTrustFilter(const KgpgCore::KgpgKeyTrustFlag t)
set the minimum trust level to be shown
const QString & getFingerprint() const
static QString gpgBinaryPath()
Get The path of the gpg binary used by KGpg.
static void setDefaultKey(const QString &_defaultKey)
static int trustLevel()
Get Show only keys with at least that trust level in key manager.
void slotImport(const QString &text)
KGpgGroupMemberNode * toGroupMemberNode()
user id is alredy signed by given key
const KGpgTransaction * getTransaction() const
get the transaction this job is handling
static bool useProxy()
Get Use HTTP proxy when available.
virtual QString getId() const
virtual int getChildCount()
Return how many child nodes exist.
bool importRemoteKey(const QString &keyIDs)
void clipEncrypt()
When you click on "encrypt the clipboard" in the systray, this slot will open the dialog to choose a ...
void slotExport(const QStringList &keyIds)
QString statusCountMessage() const
void changeGroup(KGpgGroupNode *node, const KGpgNode::List &keys)
virtual KGpgGroupNode * getParentKeyNode() const
you can fully trust this key
static int photoProperties()
Get photo properties.
the element is a GnuPG key group
virtual KGpgKeyNode * getParentKeyNode() const
remove anything that shows which key ids this data is encrypted to, ignored for symmetric encryption ...
static bool useMouseSelection()
Get Use the mouse selection instead of the clipboard.
QList< KGpgSignableNode * > List
static bool showTrust()
Get Show the trust value in key manager.
static void setShowCreat(bool v)
Set Show the creation value in key manager.
void delNode(KGpgNode *node)
void setIdLength(const int length)
virtual KGpgKeyNode * getRefNode() const
Get the node of the primary key this node references to.
The abstract base class for all classes representing keyring data.
KGpgRootNode * getRootNode() const
static KgpgCore::KgpgItemType getType(const KgpgCore::KgpgKey *k)
static bool allowCustomEncryptionOptions()
Get Allow custom encryption options.
trust value undefined (i.e. you did not set a trust level)
QStringList encryptedText() const
get decryption result
const KGpgKeyNode * getKey(void) const
get the key node this transaction is using
the user aborted the transaction
KGpgKeyNode * findKey(const QString &keyId)
Find a key node with the given id.
internal value for use in filters
KGpgExpandableNode * toExpandableNode()
signature (to a key, uid or uat)
The abstract base class for all classes that may have child objects.
void saveLayout(KConfigGroup &cg) const
static KGpgSettings * self()
KGpgUatNode * toUatNode()
QString getDescription() const
bool importRemoteKeys(const QStringList &keyIDs, const bool dialog=true)
KGpgKeyNode * toKeyNode()
static QStringList keyServers()
Get Key servers used by KGpg.
static uint recentFiles()
Get The number of recently opened files shown in the editor menu.
static bool showExpi()
Get Show the expiration value in key manager.
void refreshKeys(const QStringList &ids=QStringList())
virtual QString getId() const
virtual QString getId() const
virtual bool wasExpanded() const
check if there are any child nodes present in memory
virtual QString getEmail() const
KGpgUidNode * toUidNode()
A member of a GnuPG group.
KGpgKeyNode::List keys() const
the keys that were requested to be removed
KeysManager(QWidget *parent=0)
user attribute to a key (i.e. photo id)
KGpgGroupNode * toGroupNode()
void resizeColumnsToContents()
void slotImportDone(int ret)
static bool showSecret()
Get Show only secret keys in key manager.
class for downloading new keys from keyserver
virtual QString getEmail() const
virtual KGpgNode * getChild(const int index) const
Returns the child node at the given index.
the given email address is invalid
static QStringList getServerList()
Returns the server list.
const QString & getOutput() const
returns the revokation certificate
the passphrase was not correct
virtual int getChildCount()
Return how many child nodes exist.
KGpgSignNode * toSignNode()
virtual QString getName() const
QList< KGpgGroupMemberNode * > getGroupRefs(void) const
returns a list of all group member nodes that reference this key
static QStringList getImportedIds(const QStringList &log, const int reason=-1)
get the full fingerprints of the imported keys
delete signatures from user ids
void showTrayMessage(const QString &message)
virtual KGpgKeyNode * getParentKeyNode() const
Process one GnuPG operation.
void deleteFromGroup(KGpgGroupNode *group, KGpgGroupMemberNode *member)
A user id of a public key or key pair.
void setPreviewSize(const int pixel)
static int isKey(const QString &text, const bool incomplete=false)
check if the given text contains a private or public key
void setDefaultKey(KGpgKeyNode *def)
A signature to another key object.
this key has highest possible level of trust (e.g. your own secret keys)
virtual bool hasChildren() const
Returns if this node has child nodes.
void remove()
Remove this group from the GnuPG config file.
QString getBeautifiedFingerprint() const
Print the full key fingerprint with spaces inserted.
QList< KGpgGroupNode * > getGroups(void) const
returns a list of all groups this key is member of
virtual KgpgCore::KgpgKeyTrust getTrust() const
KShortcut goDefaultShortcut() const
returns the shortcut to go to the default key in a key selection
static void setShowSecret(bool v)
Set Show only secret keys in key manager.
static bool showSize()
Get Show the size value in key manager.
encrypt the given text or files
transaction class to sign all user ids of a key
An object that may have KGpgSignNode children.
the owners name is not accepted by GnuPG
static void setTrustLevel(int v)
Set Show only keys with at least that trust level in key manager.
static void setShowTrust(bool v)
Set Show the trust value in key manager.
class for refreshing keys already in the keyring from keyserver
void slotSetExportAttribute(const QString &attr)
allow encryption with untrusted keys, ignored for symmetric encryption
subkey of a public or secret key