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

KIO

displaycertdialog.cpp

Go to the documentation of this file.
00001 /*  This file is part of the KDE project
00002     Copyright (C) 2010 Andreas Hartmetz <ahartmetz@gmail.com>
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This program is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012     GNU General Public License for more details.
00013 
00014     You should have received a copy of the GNU General Public License
00015     along with this program; if not, write to the Free Software
00016     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017     02110-1301, USA.
00018 */
00019 
00020 #include "displaycertdialog_p.h"
00021 #include <kpushbutton.h>
00022 #include <kstandardguiitem.h>
00023 
00024 
00025 DisplayCertDialog::DisplayCertDialog(QWidget *parent)
00026  : KDialog(parent),
00027    m_index(0)
00028 {
00029     m_ui.setupUi(mainWidget());
00030     setButtons(KDialog::Ok | KDialog::User1 | KDialog::User2);
00031     QPair<KGuiItem, KGuiItem> bAndF = KStandardGuiItem::backAndForward();
00032     setButtonGuiItem(KDialog::User2, bAndF.first);
00033     setButtonGuiItem(KDialog::User1, bAndF.second);
00034     connect(button(KDialog::User2), SIGNAL(clicked()), SLOT(previousClicked()));
00035     connect(button(KDialog::User1), SIGNAL(clicked()), SLOT(nextClicked()));
00036 }
00037 
00038 void DisplayCertDialog::setCertificates(const QList<QSslCertificate> &certs)
00039 {
00040     Q_ASSERT(!certs.isEmpty());
00041     m_certs = certs;
00042     m_index = 0;
00043     showCertificate(0);
00044     button(KDialog::User2)->setEnabled(certs.size() > 1);
00045     button(KDialog::User1)->setEnabled(certs.size() > 1);
00046 }
00047 
00048 void DisplayCertDialog::showCertificate(int index)
00049 {
00050     const QSslCertificate &cert = m_certs.at(index);
00051     m_ui.subjectCertBox->setCertificate(cert, KSslCertificateBox::Subject);
00052     m_ui.issuerCertBox->setCertificate(cert, KSslCertificateBox::Issuer);
00053     
00054     QString vp = i18nc("%1 is the effective date of the certificate, %2 is the expiry date", "%1 to %2",
00055                        KGlobal::locale()->formatDateTime(cert.effectiveDate()),
00056                        KGlobal::locale()->formatDateTime(cert.expiryDate()));
00057     m_ui.validityPeriod->setText(vp);
00058 
00059     m_ui.serialNumber->setText(cert.serialNumber());
00060     m_ui.md5Digest->setText(cert.digest().toHex());
00061     m_ui.sha1Digest->setText(cert.digest(QCryptographicHash::Sha1).toHex());
00062 }
00063 
00064 //private slot
00065 void DisplayCertDialog::nextClicked()
00066 {
00067     if (m_index == m_certs.size() - 1) {
00068         m_index = 0;
00069     } else {
00070         m_index++;
00071     }
00072     showCertificate(m_index);
00073 }
00074 
00075 //private slot
00076 void DisplayCertDialog::previousClicked()
00077 {
00078     if (m_index == 0) {
00079         m_index = m_certs.size() - 1;
00080     } else {
00081         m_index--;
00082     }
00083     showCertificate(m_index);
00084 }

KIO

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • 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
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal