mirror of
https://github.com/chris2511/xca.git
synced 2026-09-14 11:06:19 +05:00
function to apply a time diff extracted to func.cpp
This commit is contained in:
parent
33f907b183
commit
ecf3c16e84
26
lib/func.cpp
26
lib/func.cpp
@ -51,7 +51,12 @@
|
||||
|
||||
|
||||
#include "func.h"
|
||||
#include "lib/asn1time.h"
|
||||
#include "widgets/validity.h"
|
||||
#include <qdir.h>
|
||||
#include <qlabel.h>
|
||||
#include <qlineedit.h>
|
||||
#include <qcombobox.h>
|
||||
#include <qmessagebox.h>
|
||||
|
||||
#ifdef WIN32
|
||||
@ -233,3 +238,24 @@ QString getBaseDir()
|
||||
#endif
|
||||
return baseDir;
|
||||
}
|
||||
|
||||
void applyTD(int number, int range, bool mnc, Validity *nb, Validity *na)
|
||||
{
|
||||
#define d_fac (60 * 60 * 24)
|
||||
int faktor[] = { 1, 30, 365 };
|
||||
int midnight = mnc? 1:0;
|
||||
|
||||
if (range>2 || range<0) range = 0;
|
||||
a1time a;
|
||||
time_t t;
|
||||
time(&t);
|
||||
int delta = faktor[range] * number ;
|
||||
t /= d_fac;
|
||||
if (delta + t > 24850){
|
||||
QMessageBox::warning(NULL, XCA_TITLE,
|
||||
"Time difference too big\nYou must set it manually." );
|
||||
return;
|
||||
}
|
||||
nb->setDate(a.now(), midnight);
|
||||
na->setDate(a.now(delta * d_fac), midnight* (-1));
|
||||
}
|
||||
|
||||
@ -54,8 +54,11 @@
|
||||
#include <qpixmap.h>
|
||||
#include "base.h"
|
||||
|
||||
class Validity;
|
||||
|
||||
QPixmap *loadImg(const char *name);
|
||||
QString getPrefix();
|
||||
QString getBaseDir();
|
||||
void applyTD(int number, int range, bool mnc, Validity *nb, Validity *na);
|
||||
|
||||
#endif
|
||||
|
||||
30
ui/About.ui
30
ui/About.ui
@ -11,13 +11,13 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>504</width>
|
||||
<height>349</height>
|
||||
<width>569</width>
|
||||
<height>392</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>caption</name>
|
||||
<string></string>
|
||||
<string>About_UI</string>
|
||||
</property>
|
||||
<vbox>
|
||||
<property stdset="1">
|
||||
@ -32,7 +32,7 @@
|
||||
<class>QLayoutWidget</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>Layout4</cstring>
|
||||
<cstring>Layout2</cstring>
|
||||
</property>
|
||||
<hbox>
|
||||
<property stdset="1">
|
||||
@ -94,22 +94,14 @@
|
||||
</property>
|
||||
</spacer>
|
||||
<widget>
|
||||
<class>QLabel</class>
|
||||
<class>QPushButton</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>TextLabel6</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>font</name>
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
<bold>1</bold>
|
||||
<underline>1</underline>
|
||||
</font>
|
||||
<cstring>PushButton1</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>text</name>
|
||||
<string>XCA</string>
|
||||
<string>Done</string>
|
||||
</property>
|
||||
</widget>
|
||||
<spacer>
|
||||
@ -173,4 +165,12 @@
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>PushButton1</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>About_UI</receiver>
|
||||
<slot>accept()</slot>
|
||||
</connection>
|
||||
</connections>
|
||||
</UI>
|
||||
|
||||
171
ui/CertExtend.ui
171
ui/CertExtend.ui
@ -11,13 +11,13 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>384</width>
|
||||
<height>304</height>
|
||||
<width>670</width>
|
||||
<height>329</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>caption</name>
|
||||
<string></string>
|
||||
<string>CertExtend_UI</string>
|
||||
</property>
|
||||
<vbox>
|
||||
<property stdset="1">
|
||||
@ -145,73 +145,165 @@
|
||||
</property>
|
||||
</spacer>
|
||||
<widget>
|
||||
<class>QGroupBox</class>
|
||||
<class>QLayoutWidget</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>GroupBox8</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>title</name>
|
||||
<string>Validity</string>
|
||||
<cstring>Layout24</cstring>
|
||||
</property>
|
||||
<hbox>
|
||||
<property stdset="1">
|
||||
<name>margin</name>
|
||||
<number>11</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>spacing</name>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<widget>
|
||||
<class>QLayoutWidget</class>
|
||||
<class>QGroupBox</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>Layout16</cstring>
|
||||
<cstring>GroupBox8</cstring>
|
||||
</property>
|
||||
<grid>
|
||||
<property stdset="1">
|
||||
<name>title</name>
|
||||
<string>Validity</string>
|
||||
</property>
|
||||
<hbox>
|
||||
<property stdset="1">
|
||||
<name>margin</name>
|
||||
<number>0</number>
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>spacing</name>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<widget row="0" column="0" >
|
||||
<class>QLabel</class>
|
||||
<widget>
|
||||
<class>QLayoutWidget</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>TextLabel1_2</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>text</name>
|
||||
<string>Not before</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget row="1" column="0" >
|
||||
<class>QLabel</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>TextLabel2_4</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>text</name>
|
||||
<string>Not after</string>
|
||||
<cstring>Layout16</cstring>
|
||||
</property>
|
||||
<grid>
|
||||
<property stdset="1">
|
||||
<name>margin</name>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>spacing</name>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<widget row="0" column="0" >
|
||||
<class>QLabel</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>TextLabel1_2</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>text</name>
|
||||
<string>Not before</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget row="1" column="0" >
|
||||
<class>QLabel</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>TextLabel2_4</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>text</name>
|
||||
<string>Not after</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget row="0" column="1" >
|
||||
<class>Validity</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>notBefore</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget row="1" column="1" >
|
||||
<class>Validity</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>notAfter</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
</hbox>
|
||||
</widget>
|
||||
<widget>
|
||||
<class>QGroupBox</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>GroupBox35</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>title</name>
|
||||
<string>Time Range</string>
|
||||
</property>
|
||||
<grid>
|
||||
<property stdset="1">
|
||||
<name>margin</name>
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>spacing</name>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<widget row="0" column="1" >
|
||||
<class>Validity</class>
|
||||
<class>QComboBox</class>
|
||||
<item>
|
||||
<property>
|
||||
<name>text</name>
|
||||
<string>Days</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property>
|
||||
<name>text</name>
|
||||
<string>Months</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property>
|
||||
<name>text</name>
|
||||
<string>Years</string>
|
||||
</property>
|
||||
</item>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>notBefore</cstring>
|
||||
<cstring>validRange</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget row="1" column="1" >
|
||||
<class>Validity</class>
|
||||
<class>QPushButton</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>notAfter</cstring>
|
||||
<cstring>applyTime</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>text</name>
|
||||
<string>Apply</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget row="1" column="0" >
|
||||
<class>QCheckBox</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>midnightCB</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>text</name>
|
||||
<string>Midnight</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget row="0" column="0" >
|
||||
<class>QLineEdit</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>validNumber</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
@ -345,5 +437,12 @@
|
||||
<receiver>CertExtend_UI</receiver>
|
||||
<slot>accept()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>applyTime</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>CertExtend_UI</receiver>
|
||||
<slot>applyTimeDiff()</slot>
|
||||
</connection>
|
||||
<slot access="public">applyTimeDiff()</slot>
|
||||
</connections>
|
||||
</UI>
|
||||
|
||||
127
ui/NewX509.ui
127
ui/NewX509.ui
@ -11,13 +11,13 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>523</width>
|
||||
<height>590</height>
|
||||
<width>620</width>
|
||||
<height>614</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>caption</name>
|
||||
<string>NewX509_UI</string>
|
||||
<string></string>
|
||||
</property>
|
||||
<widget>
|
||||
<class>QWidget</class>
|
||||
@ -1595,7 +1595,7 @@ It also copies the issuer and serial number from the issuer certificate. Normall
|
||||
<name>title</name>
|
||||
<string>Time Range</string>
|
||||
</property>
|
||||
<vbox>
|
||||
<grid>
|
||||
<property stdset="1">
|
||||
<name>margin</name>
|
||||
<number>11</number>
|
||||
@ -1604,74 +1604,65 @@ It also copies the issuer and serial number from the issuer certificate. Normall
|
||||
<name>spacing</name>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<widget>
|
||||
<class>QLayoutWidget</class>
|
||||
<widget row="0" column="1" >
|
||||
<class>QComboBox</class>
|
||||
<item>
|
||||
<property>
|
||||
<name>text</name>
|
||||
<string>Days</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property>
|
||||
<name>text</name>
|
||||
<string>Months</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property>
|
||||
<name>text</name>
|
||||
<string>Years</string>
|
||||
</property>
|
||||
</item>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>Layout18</cstring>
|
||||
<cstring>validRange</cstring>
|
||||
</property>
|
||||
<vbox>
|
||||
<property stdset="1">
|
||||
<name>margin</name>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>spacing</name>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<widget>
|
||||
<class>QLineEdit</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>validNumber</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget>
|
||||
<class>QComboBox</class>
|
||||
<item>
|
||||
<property>
|
||||
<name>text</name>
|
||||
<string>Days</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property>
|
||||
<name>text</name>
|
||||
<string>Months</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property>
|
||||
<name>text</name>
|
||||
<string>Years</string>
|
||||
</property>
|
||||
</item>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>validRange</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget>
|
||||
<class>QPushButton</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>applyTime</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>maximumSize</name>
|
||||
<size>
|
||||
<width>32767</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>text</name>
|
||||
<string>Apply</string>
|
||||
</property>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
</vbox>
|
||||
<widget row="1" column="1" >
|
||||
<class>QPushButton</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>applyTime</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>text</name>
|
||||
<string>Apply</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget row="1" column="0" >
|
||||
<class>QCheckBox</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>midnightCB</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>text</name>
|
||||
<string>Midnight</string>
|
||||
</property>
|
||||
<property>
|
||||
<name>toolTip</name>
|
||||
<string>Set the time to 00:00:00 and 23:59:59 respectively</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget row="0" column="0" >
|
||||
<class>QLineEdit</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>validNumber</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
</hbox>
|
||||
</widget>
|
||||
|
||||
@ -61,7 +61,7 @@
|
||||
#include <qtextview.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qinputdialog.h>
|
||||
#include "ui/CertExtend.h"
|
||||
#include "widgets/CertExtend.h"
|
||||
#include "widgets/ExportCert.h"
|
||||
#include "widgets/CertDetail.h"
|
||||
#include "widgets/KeyDetail.h"
|
||||
@ -256,11 +256,8 @@ void CertView::extendCert()
|
||||
a1int serial;
|
||||
emit init_database();
|
||||
try {
|
||||
CertExtend_UI *dlg = new CertExtend_UI(this, NULL, true);
|
||||
dlg->image->setPixmap(*MainWindow::certImg);
|
||||
dlg->notBefore->setDate(time.now());
|
||||
dlg->notAfter->setDate(time.now(60 * 60 * 24 * 356));
|
||||
|
||||
CertExtend *dlg = new CertExtend(this, NULL, true);
|
||||
|
||||
if (!dlg->exec()) {
|
||||
delete dlg;
|
||||
return;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user