File: distname.cpp

package info (click to toggle)
xca 2.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,328 kB
  • sloc: cpp: 30,584; sh: 341; xml: 74; makefile: 56; python: 34
file content (90 lines) | stat: -rw-r--r-- 2,190 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/* vi: set sw=4 ts=4:
 *
 * Copyright (C) 2001 - 2010 Christian Hohnstaedt.
 *
 * All rights reserved.
 */

#include "distname.h"

#include <QLabel>
#include <QPushButton>
#include <QLineEdit>
#include "lib/x509name.h"
#include "lib/db_x509super.h"
#include "lib/base.h"
#include "clicklabel.h"
#include "OidResolver.h"
#include "MainWindow.h"

DistName::DistName(QWidget* parent)
    : QWidget(parent)
{
	DistNameLayout = new QGridLayout();
	DistNameLayout->setAlignment(Qt::AlignTop);
	DistNameLayout->setSpacing(6);
	DistNameLayout->setContentsMargins(11, 11, 11, 11);

	QGridLayout *g = new QGridLayout();
	g->setAlignment(Qt::AlignTop);
	g->setSpacing(6);
	g->setContentsMargins(11, 11, 11, 11);

	QVBoxLayout *v = new QVBoxLayout(this);
	v->setSpacing(6);
	v->setContentsMargins(11, 11, 11, 11);
	v->addLayout(DistNameLayout);
	v->addStretch();
	v->addLayout(g);

	rfc2253 = new QLineEdit(this);
	rfc2253->setReadOnly(true);
	g->addWidget(new QLabel(QString("RFC 2253:"), this), 0, 0);
	g->addWidget(rfc2253, 0, 1);

	namehash = new QLineEdit(this);
	namehash->setReadOnly(true);
	g->addWidget(new QLabel(QString("Hash:"), this), 1, 0);
	g->addWidget(namehash, 1, 1);
}

void DistName::setX509name(const x509name &n)
{
	DoubleClickLabel *l1;
	QLabel *l2;
	QStringList sl;
	for (int i=0; i<n.entryCount(); i++) {
		QString toolt, label, trans;
		int nid = n.nid(i);
		trans = dn_translations[nid];
		sl = n.entryList(i);
		if (Settings["translate_dn"] && !trans.isEmpty()) {
			label = trans;
			toolt = sl[1];
		} else {
			toolt = trans;
			label = sl[1];
		}
		l1 = new DoubleClickLabel(this);
		l2 = new CopyLabel(this);
		l1->setTextFormat(Qt::PlainText);
		l1->setText(label);
		l1->setClickText(sl[1]);
		if (l1->text().isEmpty())
			l1->setText(sl[0]);
		l2->setText(sl[2]);

		l1->setToolTip(QString("[%1] %2").arg(sl[0]).arg(toolt));
		l2->setToolTip(sl[3]);

		connect(l1, SIGNAL(doubleClicked(QString)),
			MainWindow::getResolver(), SLOT(searchOid(QString)));

		DistNameLayout->addWidget(l1, i, 0);
		DistNameLayout->addWidget(l2, i, 1);
	}
	rfc2253->setText(n.oneLine(XN_FLAG_RFC2253));
	rfc2253->setCursorPosition(0);
	namehash->setText(n.hash());
	updateGeometry();
}