• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.10.2 API Reference
  • KDE Home
  • Contact Us
 

KIO

  • kio
  • kssl
  • kcm
displaycertdialog.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE project
2  Copyright (C) 2010 Andreas Hartmetz <ahartmetz@gmail.com>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #include "displaycertdialog_p.h"
21 #include <kpushbutton.h>
22 #include <kstandardguiitem.h>
23 
24 
25 DisplayCertDialog::DisplayCertDialog(QWidget *parent)
26  : KDialog(parent),
27  m_index(0)
28 {
29  m_ui.setupUi(mainWidget());
30  setButtons(KDialog::Ok | KDialog::User1 | KDialog::User2);
31  QPair<KGuiItem, KGuiItem> bAndF = KStandardGuiItem::backAndForward();
32  setButtonGuiItem(KDialog::User2, bAndF.first);
33  setButtonGuiItem(KDialog::User1, bAndF.second);
34  connect(button(KDialog::User2), SIGNAL(clicked()), SLOT(previousClicked()));
35  connect(button(KDialog::User1), SIGNAL(clicked()), SLOT(nextClicked()));
36 }
37 
38 void DisplayCertDialog::setCertificates(const QList<QSslCertificate> &certs)
39 {
40  Q_ASSERT(!certs.isEmpty());
41  m_certs = certs;
42  m_index = 0;
43  showCertificate(0);
44  button(KDialog::User2)->setEnabled(certs.size() > 1);
45  button(KDialog::User1)->setEnabled(certs.size() > 1);
46 }
47 
48 void DisplayCertDialog::showCertificate(int index)
49 {
50  const QSslCertificate &cert = m_certs.at(index);
51  m_ui.subjectCertBox->setCertificate(cert, KSslCertificateBox::Subject);
52  m_ui.issuerCertBox->setCertificate(cert, KSslCertificateBox::Issuer);
53 
54  QString vp = i18nc("%1 is the effective date of the certificate, %2 is the expiry date", "%1 to %2",
55  KGlobal::locale()->formatDateTime(cert.effectiveDate()),
56  KGlobal::locale()->formatDateTime(cert.expiryDate()));
57  m_ui.validityPeriod->setText(vp);
58 
59  m_ui.serialNumber->setText(cert.serialNumber());
60  m_ui.md5Digest->setText(cert.digest().toHex());
61  m_ui.sha1Digest->setText(cert.digest(QCryptographicHash::Sha1).toHex());
62 }
63 
64 //private slot
65 void DisplayCertDialog::nextClicked()
66 {
67  if (m_index == m_certs.size() - 1) {
68  m_index = 0;
69  } else {
70  m_index++;
71  }
72  showCertificate(m_index);
73 }
74 
75 //private slot
76 void DisplayCertDialog::previousClicked()
77 {
78  if (m_index == 0) {
79  m_index = m_certs.size() - 1;
80  } else {
81  m_index--;
82  }
83  showCertificate(m_index);
84 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Apr 20 2013 06:03:08 by doxygen 1.8.3.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.10.2 API Reference

Skip menu "kdelibs-4.10.2 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal