diff --git a/lib/func.cpp b/lib/func.cpp index 61cdfc9f..fe7bc362 100644 --- a/lib/func.cpp +++ b/lib/func.cpp @@ -51,7 +51,12 @@ #include "func.h" +#include "lib/asn1time.h" +#include "widgets/validity.h" #include +#include +#include +#include #include #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)); +} diff --git a/lib/func.h b/lib/func.h index e155e81a..1e613519 100644 --- a/lib/func.h +++ b/lib/func.h @@ -54,8 +54,11 @@ #include #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 diff --git a/ui/About.ui b/ui/About.ui index 7975363e..eabea857 100644 --- a/ui/About.ui +++ b/ui/About.ui @@ -11,13 +11,13 @@ 0 0 - 504 - 349 + 569 + 392 caption - + About_UI @@ -32,7 +32,7 @@ QLayoutWidget name - Layout4 + Layout2 @@ -94,22 +94,14 @@ - QLabel + QPushButton name - TextLabel6 - - - font - - 14 - 1 - 1 - + PushButton1 text - XCA + Done @@ -173,4 +165,12 @@ + + + PushButton1 + clicked() + About_UI + accept() + + diff --git a/ui/CertExtend.ui b/ui/CertExtend.ui index a3d7810f..6b68b37e 100644 --- a/ui/CertExtend.ui +++ b/ui/CertExtend.ui @@ -11,13 +11,13 @@ 0 0 - 384 - 304 + 670 + 329 caption - + CertExtend_UI @@ -145,73 +145,165 @@ - QGroupBox + QLayoutWidget name - GroupBox8 - - - title - Validity + Layout24 margin - 11 + 0 spacing 6 - QLayoutWidget + QGroupBox name - Layout16 + GroupBox8 - + + title + Validity + + margin - 0 + 11 spacing 6 - - QLabel + + QLayoutWidget name - TextLabel1_2 - - - text - Not before - - - - QLabel - - name - TextLabel2_4 - - - text - Not after + Layout16 + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + TextLabel1_2 + + + text + Not before + + + + QLabel + + name + TextLabel2_4 + + + text + Not after + + + + Validity + + name + notBefore + + + + Validity + + name + notAfter + + + + + + + QGroupBox + + name + GroupBox35 + + + title + Time Range + + + + margin + 11 + + + spacing + 6 + - Validity + QComboBox + + + text + Days + + + + + text + Months + + + + + text + Years + + name - notBefore + validRange - Validity + QPushButton name - notAfter + applyTime + + + text + Apply + + + + QCheckBox + + name + midnightCB + + + text + Midnight + + + + QLineEdit + + name + validNumber @@ -345,5 +437,12 @@ CertExtend_UI accept() + + applyTime + clicked() + CertExtend_UI + applyTimeDiff() + + applyTimeDiff() diff --git a/ui/NewX509.ui b/ui/NewX509.ui index 00db780d..66ce4ff1 100644 --- a/ui/NewX509.ui +++ b/ui/NewX509.ui @@ -11,13 +11,13 @@ 0 0 - 523 - 590 + 620 + 614 caption - NewX509_UI + QWidget @@ -1595,7 +1595,7 @@ It also copies the issuer and serial number from the issuer certificate. Normall title Time Range - + margin 11 @@ -1604,74 +1604,65 @@ It also copies the issuer and serial number from the issuer certificate. Normall spacing 6 - - QLayoutWidget + + QComboBox + + + text + Days + + + + + text + Months + + + + + text + Years + + name - Layout18 + validRange - - - margin - 0 - - - spacing - 6 - - - QLineEdit - - name - validNumber - - - - QComboBox - - - text - Days - - - - - text - Months - - - - - text - Years - - - - name - validRange - - - - QPushButton - - name - applyTime - - - maximumSize - - 32767 - 25 - - - - text - Apply - - - - + + QPushButton + + name + applyTime + + + text + Apply + + + + QCheckBox + + name + midnightCB + + + text + Midnight + + + toolTip + Set the time to 00:00:00 and 23:59:59 respectively + + + + QLineEdit + + name + validNumber + + + diff --git a/view/CertView.cpp b/view/CertView.cpp index c89db79c..23d5c91b 100644 --- a/view/CertView.cpp +++ b/view/CertView.cpp @@ -61,7 +61,7 @@ #include #include #include -#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;