KIO
ksslcertificatebox.cpp
Go to the documentation of this file.
00001 /* This file is part of the KDE project 00002 * 00003 * Copyright (C) 2007 Andreas Hartmetz <ahartmetz@gmail.com> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Library General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Library General Public License 00016 * along with this library; see the file COPYING.LIB. If not, write to 00017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 * Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #include "ksslcertificatebox.h" 00022 00023 #include "ui_certificateparty.h" 00024 00025 #include <QtNetwork/QSslCertificate> 00026 00027 class KSslCertificateBoxPrivate 00028 { 00029 public: 00030 Ui::CertificateParty ui; 00031 }; 00032 00033 00034 KSslCertificateBox::KSslCertificateBox(QWidget *parent) 00035 : QWidget(parent), 00036 d(new KSslCertificateBoxPrivate()) 00037 { 00038 d->ui.setupUi(this); 00039 // No fooling us with html tags 00040 Q_FOREACH(QLabel* label, qFindChildren<QLabel *>(this)) { 00041 label->setTextFormat(Qt::PlainText); 00042 } 00043 } 00044 00045 00046 KSslCertificateBox::~KSslCertificateBox() 00047 { 00048 delete d; 00049 } 00050 00051 00052 void KSslCertificateBox::setCertificate(const QSslCertificate &cert, CertificateParty party) 00053 { 00054 if (party == Subject) { 00055 d->ui.commonName->setText(cert.subjectInfo(QSslCertificate::CommonName)); 00056 d->ui.organization->setText(cert.subjectInfo(QSslCertificate::Organization)); 00057 d->ui.organizationalUnit 00058 ->setText(cert.subjectInfo(QSslCertificate::OrganizationalUnitName)); 00059 d->ui.country->setText(cert.subjectInfo(QSslCertificate::CountryName)); 00060 d->ui.state->setText(cert.subjectInfo(QSslCertificate::StateOrProvinceName)); 00061 d->ui.city->setText(cert.subjectInfo(QSslCertificate::LocalityName)); 00062 } else if (party == Issuer) { 00063 d->ui.commonName->setText(cert.issuerInfo(QSslCertificate::CommonName)); 00064 d->ui.organization->setText(cert.issuerInfo(QSslCertificate::Organization)); 00065 d->ui.organizationalUnit 00066 ->setText(cert.issuerInfo(QSslCertificate::OrganizationalUnitName)); 00067 d->ui.country->setText(cert.issuerInfo(QSslCertificate::CountryName)); 00068 d->ui.state->setText(cert.issuerInfo(QSslCertificate::StateOrProvinceName)); 00069 d->ui.city->setText(cert.issuerInfo(QSslCertificate::LocalityName)); 00070 } 00071 } 00072 00073 00074 void KSslCertificateBox::clear() 00075 { 00076 d->ui.commonName->clear(); 00077 d->ui.organization->clear(); 00078 d->ui.organizationalUnit->clear(); 00079 d->ui.country->clear(); 00080 d->ui.state->clear(); 00081 d->ui.city->clear(); 00082 } 00083 00084 00085 #include "ksslcertificatebox.moc"
KDE 4.7 API Reference