- Timestamp:
- Sep 13, 2016, 2:45:48 PM (8 years ago)
- Branches:
- master, pruebas
- Children:
- 439da38
- Parents:
- 61947bf
- Location:
- sources
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sources/mainwindow.cpp
r61947bf r7eb08ea 75 75 #include "bookmarkdialog.h" 76 76 #include "database.h" 77 #include "Form.h" 78 79 80 81 //********************************* POPPLER 82 83 #include <stdio.h> 84 #include <stdlib.h> 85 #include <stddef.h> 86 #include <string.h> 87 #include <time.h> 88 89 //#include "config.h" 90 91 #include <poppler-config.h> 92 93 #include "Object.h" 94 #include "Array.h" 95 #include "Page.h" 96 #include "PDFDoc.h" 97 #include "PDFDocFactory.h" 98 #include "Error.h" 99 #include "GlobalParams.h" 100 #include "SignatureInfo.h" 101 102 103 /*const char * getReadableSigState(SignatureValidationStatus sig_vs) 104 { 105 switch(sig_vs) { 106 case SIGNATURE_VALID: 107 return "Signature is Valid."; 108 109 case SIGNATURE_INVALID: 110 return "Signature is Invalid."; 111 112 case SIGNATURE_DIGEST_MISMATCH: 113 return "Digest Mismatch."; 114 115 case SIGNATURE_DECODING_ERROR: 116 return "Document isn't signed or corrupted data."; 117 118 case SIGNATURE_NOT_VERIFIED: 119 return "Signature has not yet been verified."; 120 121 default: 122 return "Unknown Validation Failure."; 123 } 124 } 125 126 const char * getReadableCertState(CertificateValidationStatus cert_vs) 127 { 128 switch(cert_vs) { 129 case CERTIFICATE_TRUSTED: 130 return "Certificate is Trusted."; 131 132 case CERTIFICATE_UNTRUSTED_ISSUER: 133 return "Certificate issuer isn't Trusted."; 134 135 case CERTIFICATE_UNKNOWN_ISSUER: 136 return "Certificate issuer is unknown."; 137 138 case CERTIFICATE_REVOKED: 139 return "Certificate has been Revoked."; 140 141 case CERTIFICATE_EXPIRED: 142 return "Certificate has Expired"; 143 144 case CERTIFICATE_NOT_VERIFIED: 145 return "Certificate has not yet been verified."; 146 147 default: 148 return "Unknown issue with Certificate or corrupted data."; 149 } 150 } 151 152 char *getReadableTime(time_t unix_time) 153 { 154 char * time_str = (char *) gmalloc(64); 155 strftime(time_str, 64, "%b %d %Y %H:%M:%S", localtime(&unix_time)); 156 return time_str; 157 }*/ 158 159 //static GBool printVersion = gFalse; 160 //static GBool printHelp = gFalse; 161 //static GBool dontVerifyCert = gFalse; 162 163 //static const ArgDesc argDesc[] = { 164 // {"-nocert", argFlag, &dontVerifyCert, 0, 165 // "don't perform certificate validation"}, 166 167 // {"-v", argFlag, &printVersion, 0, 168 // "print copyright and version info"}, 169 // {"-h", argFlag, &printHelp, 0, 170 // "print usage information"}, 171 // {"-help", argFlag, &printHelp, 0, 172 // "print usage information"}, 173 // {"-?", argFlag, &printHelp, 0, 174 // "print usage information"}, 175 // {NULL} 176 //}; 177 178 179 //********************************* POPPLER 77 180 78 181 namespace … … 300 403 QMenu* MainWindow::createPopupMenu() 301 404 { 405 qDebug("createPopupMenu()"); 302 406 QMenu* menu = new QMenu(); 303 407 … … 310 414 menu->addAction(m_thumbnailsDock->toggleViewAction()); 311 415 menu->addAction(m_bookmarksDock->toggleViewAction()); 416 menu->addAction(m_detailsSignatureDock->toggleViewAction()); 312 417 313 418 return menu; … … 328 433 } 329 434 } 435 330 436 331 437 bool MainWindow::open(const QString& filePath, int page, const QRectF& highlight, bool quiet) … … 505 611 m_printAction->setEnabled(hasCurrent); 506 612 m_verify_signature->setEnabled(hasCurrent); 613 //m_detailsSignatureDock->setEnabled(hasCurrent); 507 614 508 615 m_previousPageAction->setEnabled(hasCurrent); … … 569 676 if(hasCurrent) 570 677 { 678 qDebug("if(hasCurrent)"); 571 679 m_saveCopyAction->setEnabled(currentTab()->canSave()); 572 680 m_saveAsAction->setEnabled(currentTab()->canSave()); … … 581 689 m_propertiesView->setModel(currentTab()->propertiesModel()); 582 690 m_bookmarksView->setModel(bookmarkModelForCurrentTab()); 691 m_detailsSignatureView->setModel(view_table_verify_signature()); 692 583 693 584 694 m_thumbnailsView->setScene(currentTab()->thumbnailsScene()); … … 2089 2199 { 2090 2200 qDebug("Entro a on_detailsSignatureView_sectionCountChanged()"); 2091 2092 if(m_detailsSignatureView->horizontalHeader()->count() > 0) 2093 { 2094 #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) 2095 2096 m_detailsSignatureView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); 2097 2098 #else 2099 2100 m_detailsSignatureView->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); 2101 2102 #endif // QT_VERSION 2103 } 2104 2105 if(m_detailsSignatureView->horizontalHeader()->count() > 1) 2106 { 2107 #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) 2108 2109 m_detailsSignatureView->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch); 2110 2111 #else 2112 2113 m_detailsSignatureView->horizontalHeader()->setResizeMode(1, QHeaderView::Stretch); 2114 2115 #endif // QT_VERSION 2116 } 2117 2118 m_detailsSignatureView->horizontalHeader()->setVisible(false); 2119 2120 2121 if(m_detailsSignatureView->verticalHeader()->count() > 0) 2122 { 2123 #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) 2124 2125 m_detailsSignatureView->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); 2126 2127 #else 2128 2129 m_detailsSignatureView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); 2130 2131 #endif // QT_VERSION 2132 } 2133 qDebug("Antes de salir"); 2134 m_detailsSignatureView->verticalHeader()->setVisible(false); 2135 m_detailsSignatureView->show(); 2136 qDebug("saliendo"); 2137 } 2138 2139 void MainWindow::on_properties_sectionCountChanged() 2140 { 2141 if(m_propertiesView->horizontalHeader()->count() > 0) 2142 { 2143 #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) 2144 2145 m_propertiesView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); 2146 2147 #else 2148 2149 m_propertiesView->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); 2150 2151 #endif // QT_VERSION 2152 } 2153 2154 if(m_propertiesView->horizontalHeader()->count() > 1) 2155 { 2156 #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) 2157 2158 m_propertiesView->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch); 2159 2160 #else 2161 2162 m_propertiesView->horizontalHeader()->setResizeMode(1, QHeaderView::Stretch); 2163 2164 #endif // QT_VERSION 2165 } 2166 2167 m_propertiesView->horizontalHeader()->setVisible(false); 2168 2169 2170 if(m_propertiesView->verticalHeader()->count() > 0) 2171 { 2172 #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) 2173 2174 m_propertiesView->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); 2175 2176 #else 2177 2178 m_propertiesView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); 2179 2180 #endif // QT_VERSION 2181 } 2182 2183 m_propertiesView->verticalHeader()->setVisible(false); 2184 } 2201 } 2202 2185 2203 2186 2204 void MainWindow::on_thumbnails_dockLocationChanged(Qt::DockWidgetArea area) 2187 2205 { 2206 qDebug("on_thumbnails_dockLocationChanged"); 2188 2207 for(int index = 0, count = m_tabWidget->count(); index < count; ++index) 2189 2208 { … … 2194 2213 void MainWindow::on_thumbnails_verticalScrollBar_valueChanged(int value) 2195 2214 { 2215 qDebug("on_thumbnails_verticalScrollBar_valueChanged"); 2196 2216 Q_UNUSED(value); 2197 2217 … … 2212 2232 void MainWindow::on_bookmarks_sectionCountChanged() 2213 2233 { 2234 qDebug("on_bookmarks_sectionCountChanged"); 2214 2235 if(m_bookmarksView->horizontalHeader()->count() > 0) 2215 2236 { … … 2271 2292 void MainWindow::on_bookmarks_contextMenuRequested(const QPoint& pos) 2272 2293 { 2294 qDebug("on_bookmarks_contextMenuRequested"); 2273 2295 QMenu menu; 2274 2296 … … 3146 3168 { 3147 3169 // outline 3148 3170 qDebug("createDocks()"); 3149 3171 m_outlineDock = createDock(tr("&Outline"), QLatin1String("outlineDock"), QKeySequence(Qt::Key_F6)); 3150 3172 … … 3178 3200 m_propertiesDock->setWidget(m_propertiesView); 3179 3201 3180 // verify signature 3202 //______________________________________________________________ 3203 // verify signature 3181 3204 m_detailsSignatureDock = createDock(tr("&Verify-Signature"), QLatin1String("verifySignature-Dock"), QKeySequence(Qt::Key_F12)); 3182 3205 //m_detailsSignatureDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); 3206 //QStringList itens; 3207 //m_detailsSignatureView = new QListWidget(m_detailsSignatureDock); 3183 3208 m_detailsSignatureView = new QTableView(this); 3184 3209 m_detailsSignatureView->setAlternatingRowColors(true); … … 3187 3212 m_detailsSignatureView->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); 3188 3213 3189 connect(m_detailsSignatureView->horizontalHeader(), SIGNAL(sectionCountChanged(int,int)), SLOT(on_detailsSignatureView_sectionCountChanged())); 3214 //prueba->addItems(QStringList() << verify_signature().toStdString()); 3215 // QStringList itens; 3216 // itens << "Cargar archivo PDF para verificar la firma "; 3217 //// for(int i = 0; i<1; i++) { 3218 3219 //// itens << "Cargar archivo PDF para verificar la firma " + QString::number(i); 3220 //// } 3221 // m_detailsSignatureView->addItems(itens); 3222 3223 // m_detailsSignatureDock->setWidget(m_detailsSignatureView); 3224 3225 3226 connect(m_detailsSignatureView->horizontalHeader(), SIGNAL(sectionCountChanged(int,int)), SLOT(on_detailsSignatureView_sectionCountChanged())); 3227 //connect(m_detailsSignatureView, SIGNAL(valueChanged(int)), SLOT(on_detailsSignatureView_sectionCountChanged())); 3190 3228 3191 3229 m_detailsSignatureDock->setWidget(m_detailsSignatureView); 3230 //______________________________________________________________ 3192 3231 3193 3232 // thumbnails … … 3289 3328 3290 3329 QMenu* docksMenu = m_viewMenu->addMenu(tr("&Docks")); 3291 docksMenu->addActions(QList< QAction* >() << m_outlineDock->toggleViewAction() << m_propertiesDock->toggleViewAction() << m_thumbnailsDock->toggleViewAction() << m_bookmarksDock->toggleViewAction() );3330 docksMenu->addActions(QList< QAction* >() << m_outlineDock->toggleViewAction() << m_propertiesDock->toggleViewAction() << m_thumbnailsDock->toggleViewAction() << m_bookmarksDock->toggleViewAction() << m_detailsSignatureDock->toggleViewAction()); 3292 3331 3293 3332 if(s_settings->mainWindow().extendedSearchDock()) … … 3511 3550 } 3512 3551 3513 3514 3515 3552 void MainWindowAdaptor::closeTab() 3516 3553 { … … 3530 3567 } 3531 3568 3569 // agregando funciones para la verificación de la firma electrónica 3570 3571 const char * getReadableSigState(SignatureValidationStatus sig_vs) 3572 { 3573 switch(sig_vs) { 3574 case SIGNATURE_VALID: 3575 //return "Signature is Valid."; 3576 return "Firma válida."; 3577 3578 case SIGNATURE_INVALID: 3579 //return "Signature is Invalid."; 3580 return "Firma inválida."; 3581 3582 case SIGNATURE_DIGEST_MISMATCH: 3583 //return "Digest Mismatch."; 3584 return "Digest Mismatch."; 3585 3586 case SIGNATURE_DECODING_ERROR: 3587 //return "Document isn't signed or corrupted data."; 3588 return "El documento no está firmado o datos dañados."; 3589 3590 case SIGNATURE_NOT_VERIFIED: 3591 //return "Signature has not yet been verified."; 3592 return "Firma todavía no se ha verificado."; 3593 3594 default: 3595 //return "Unknown Validation Failure."; 3596 return "Desconocido fallo de validación."; 3597 } 3598 } 3599 3600 const char * getReadableCertState(CertificateValidationStatus cert_vs) 3601 { 3602 switch(cert_vs) { 3603 case CERTIFICATE_TRUSTED: 3604 //return "Certificate is Trusted."; 3605 return "Certificado es de confianza"; 3606 3607 case CERTIFICATE_UNTRUSTED_ISSUER: 3608 //return "Certificate issuer isn't Trusted."; 3609 return "Emisor del certificado no es de confianza"; 3610 3611 case CERTIFICATE_UNKNOWN_ISSUER: 3612 //return "Certificate issuer is unknown."; 3613 return "Emisor de certificado es desconocido"; 3614 3615 case CERTIFICATE_REVOKED: 3616 //return "Certificate has been Revoked."; 3617 return "Certificado ha sido revocado."; 3618 3619 case CERTIFICATE_EXPIRED: 3620 //return "Certificate has Expired"; 3621 return "Certificado ha caducado"; 3622 3623 case CERTIFICATE_NOT_VERIFIED: 3624 //return "Certificate has not yet been verified."; 3625 return "Certificado aún no ha sido verificado."; 3626 3627 default: 3628 //return "Unknown issue with Certificate or corrupted data."; 3629 return "Problema desconocido con el certificado o datos dañados."; 3630 } 3631 } 3632 3633 char *getReadableTime(time_t unix_time) 3634 { 3635 char * time_str = (char *) gmalloc(64); 3636 strftime(time_str, 64, "%b %d %Y %H:%M:%S", localtime(&unix_time)); 3637 return time_str; 3638 } 3639 3640 static GBool printVersion = gFalse; 3641 static GBool printHelp = gFalse; 3642 static GBool dontVerifyCert = gFalse; 3643 3644 //static const ArgDesc argDesc[] = { 3645 // {"-nocert", argFlag, &dontVerifyCert, 0, 3646 // "don't perform certificate validation"}, 3647 3648 // {"-v", argFlag, &printVersion, 0, 3649 // "print copyright and version info"}, 3650 // {"-h", argFlag, &printHelp, 0, 3651 // "print usage information"}, 3652 // {"-help", argFlag, &printHelp, 0, 3653 // "print usage information"}, 3654 // {"-?", argFlag, &printHelp, 0, 3655 // "print usage information"}, 3656 // {NULL} 3657 //}; 3658 3659 //fin de agregar funciones para la verificación de firma electrónica 3660 3661 //QString MainWindow::verify_signature() { 3662 //QStringList MainWindow::verify_signature() { 3663 3664 QStandardItemModel *MainWindow::view_table_verify_signature() { 3665 3666 qDebug("view_table_verify_signature"); 3667 //m_tableVerifySign = new QTableView(); 3668 3669 char *time_str = NULL; 3670 PDFDoc *doc = NULL; 3671 unsigned int sigCount; 3672 GooString * fileName = NULL; 3673 SignatureInfo *sig_info = NULL; 3674 std::vector<FormWidgetSignature*> sig_widgets; 3675 globalParams = new GlobalParams(); 3676 3677 int exitCode = 99; 3678 // GBool ok; 3679 3680 QString newfile = currentTab()->fileInfo().absoluteFilePath(); 3681 3682 qDebug("***fileName signatures: |%s|",newfile.toUtf8().data()); 3683 fileName = new GooString(newfile.toUtf8().data()); // le paso el path del documento PDF para abrirlo 3684 3685 // open PDF file 3686 doc = PDFDocFactory().createPDFDoc(*fileName, NULL, NULL); //abre el documento 3687 if (!doc->isOk()) { 3688 exitCode = 1; 3689 qDebug(".......error"); 3690 } 3691 3692 sig_widgets = doc->getSignatureWidgets(); 3693 sigCount = sig_widgets.size(); 3694 3695 if( sigCount >= 1 ) { //El documento tiene firma electronica 3696 int numColumns = 2; 3697 int numRows = sigCount*5; 3698 QStandardItemModel* model = new QStandardItemModel(numRows, numColumns); 3699 QString rowtype, rowvalue; 3700 int countRow = 0; 3701 3702 for (unsigned int i = 0; i < sigCount; i++) { 3703 sig_info = sig_widgets.at(i)->validateSignature(!dontVerifyCert, false); 3704 3705 //**Sección para llenar la tabla 3706 rowtype = trUtf8("Firma número %1").arg(i+1); 3707 QStandardItem* item = new QStandardItem(rowtype); 3708 model->setItem(countRow, 0, item); 3709 countRow ++; 3710 rowtype = trUtf8(" - Nombre común "); 3711 item = new QStandardItem(rowtype); 3712 model->setItem(countRow, 0, item); 3713 rowvalue = sig_info->getSignerName(); 3714 item = new QStandardItem(rowvalue); 3715 model->setItem(countRow, 1, item); 3716 countRow ++; 3717 rowtype = trUtf8(" - Hora de la firma "); 3718 item = item = new QStandardItem(rowtype); 3719 model->setItem(countRow, 0, item); 3720 rowvalue = getReadableTime(sig_info->getSigningTime()); 3721 item = new QStandardItem(rowvalue); 3722 model->setItem(countRow, 1, item); 3723 countRow ++; 3724 rowtype = trUtf8(" - Validación de la firma "); 3725 item = item = new QStandardItem(rowtype); 3726 model->setItem(countRow, 0, item); 3727 rowvalue = trUtf8(getReadableSigState(sig_info->getSignatureValStatus())); 3728 item = new QStandardItem(rowvalue); 3729 model->setItem(countRow, 1, item); 3730 countRow ++; 3731 rowtype = trUtf8(" - Validación del certificado "); 3732 item = item = new QStandardItem(rowtype); 3733 model->setItem(countRow, 0, item); 3734 rowvalue = getReadableCertState(sig_info->getCertificateValStatus()); 3735 item = new QStandardItem(rowvalue); 3736 model->setItem(countRow, 1, item); 3737 countRow ++; 3738 } 3739 return model; 3740 } 3741 3742 else { //El documento no tiene firma 3743 QStandardItemModel* model = new QStandardItemModel(1,1); 3744 QString rowtype = trUtf8("El documento no posee firma electrónica"); 3745 QStandardItem* item = new QStandardItem(rowtype); 3746 model->setItem(0, 0, item); 3747 return model; 3748 } 3749 } 3750 3751 QStandardItemModel *MainWindow::verify_signature() { 3752 qDebug("verify_signature"); 3753 m_tableVerifySign = new QTableView(); 3754 3755 3756 char *time_str = NULL; 3757 PDFDoc *doc = NULL; 3758 unsigned int sigCount; 3759 GooString * fileName = NULL; 3760 SignatureInfo *sig_info = NULL; 3761 std::vector<FormWidgetSignature*> sig_widgets; 3762 globalParams = new GlobalParams(); 3763 3764 int exitCode = 99; 3765 // GBool ok; 3766 3767 QString newfile = currentTab()->fileInfo().absoluteFilePath(); 3768 3769 qDebug("***fileName signatures: |%s|",newfile.toUtf8().data()); 3770 fileName = new GooString(newfile.toUtf8().data()); // le paso el path del documento PDF para abrirlo 3771 3772 // open PDF file 3773 doc = PDFDocFactory().createPDFDoc(*fileName, NULL, NULL); //abre el documento 3774 //qDebug(".......1"); 3775 if (!doc->isOk()) { 3776 exitCode = 1; 3777 qDebug(".......error"); 3778 //return "Error"; 3779 //goto end; 3780 } 3781 3782 //qDebug(".......3"); 3783 sig_widgets = doc->getSignatureWidgets(); 3784 sigCount = sig_widgets.size(); 3785 int numColumns = 2; 3786 int numRows = sigCount*5; 3787 3788 QStandardItemModel* model = new QStandardItemModel(numRows, numColumns); 3789 3790 QStringList itens; 3791 //QStandardItem* item; 3792 QString rowtype, rowvalue; 3793 int countRow = 0; 3794 QString newmessage = trUtf8("Número de firmas: %1 ").arg(sigCount); 3795 newmessage += "\n \n"; 3796 for (unsigned int i = 0; i < sigCount; i++) { 3797 sig_info = sig_widgets.at(i)->validateSignature(!dontVerifyCert, false); 3798 //qDebug("Firma %d ", i+1); 3799 newmessage += trUtf8("Firma número %1").arg(i+1); 3800 newmessage += "\n"; 3801 //qDebug(sig_info->getSignerName()); 3802 newmessage += trUtf8(" - Nombre común: %1 \n").arg(sig_info->getSignerName()); 3803 newmessage += trUtf8(" - Hora de la firma: %1f \n").arg(time_str = getReadableTime(sig_info->getSigningTime())); 3804 newmessage += trUtf8(" - Validación de la firma: %1 \n").arg(getReadableSigState(sig_info->getSignatureValStatus())); 3805 newmessage += trUtf8(" - Validación del certificado: %1").arg(getReadableCertState(sig_info->getCertificateValStatus())); 3806 newmessage += " \n"; 3807 itens << trUtf8("Firma número %1").arg(i+1) + trUtf8(" - Nombre común: %1 \n").arg(sig_info->getSignerName()) + trUtf8(" - Hora de la firma: %1f \n").arg(time_str = getReadableTime(sig_info->getSigningTime())) + trUtf8(" - Validación de la firma: %1 \n").arg(getReadableSigState(sig_info->getSignatureValStatus())) + trUtf8(" - Validación del certificado: %1").arg(getReadableCertState(sig_info->getCertificateValStatus())); 3808 3809 //**Sección para llenar la tabla 3810 3811 rowtype = "Firma " + QString::number(i + 1); 3812 QStandardItem* item = new QStandardItem(rowtype); 3813 model->setItem(countRow, 0, item); 3814 countRow ++; 3815 rowtype = trUtf8(" - Nombre común "); 3816 item = new QStandardItem(rowtype); 3817 model->setItem(countRow, 0, item); 3818 rowvalue = sig_info->getSignerName(); 3819 item = new QStandardItem(rowvalue); 3820 model->setItem(countRow, 1, item); 3821 countRow ++; 3822 rowtype = trUtf8(" - Hora de la firma "); 3823 item = item = new QStandardItem(rowtype); 3824 model->setItem(countRow, 0, item); 3825 rowvalue = getReadableTime(sig_info->getSigningTime()); 3826 item = new QStandardItem(rowvalue); 3827 model->setItem(countRow, 1, item); 3828 countRow ++; 3829 rowtype = trUtf8(" - Validación de la firma "); 3830 item = item = new QStandardItem(rowtype); 3831 model->setItem(countRow, 0, item); 3832 rowvalue = trUtf8(getReadableSigState(sig_info->getSignatureValStatus())); 3833 item = new QStandardItem(rowvalue); 3834 model->setItem(countRow, 1, item); 3835 countRow ++; 3836 rowtype = trUtf8(" - Validación del certificado "); 3837 item = item = new QStandardItem(rowtype); 3838 model->setItem(countRow, 0, item); 3839 rowvalue = getReadableCertState(sig_info->getCertificateValStatus()); 3840 item = new QStandardItem(rowvalue); 3841 model->setItem(countRow, 1, item); 3842 countRow ++; 3843 } 3844 //return newmessage; 3845 qDebug()<<itens; 3846 qDebug("Saliendo**************************************************************************************************************"); 3847 //m_tableVerifySign->setModel(model); 3848 //return itens; 3849 return model; 3850 } 3851 3532 3852 void MainWindow::on_verify_signature() { 3533 3853 3534 3535 3854 qDebug("Entro a on_verify_signature()"); 3855 verify_signature(); 3856 char *time_str = NULL; 3857 PDFDoc *doc = NULL; 3858 unsigned int sigCount; 3859 GooString * fileName = NULL; 3860 SignatureInfo *sig_info = NULL; 3861 std::vector<FormWidgetSignature*> sig_widgets; 3862 globalParams = new GlobalParams(); 3863 3864 int exitCode = 99; 3865 // GBool ok; 3866 3867 QString newfile = currentTab()->fileInfo().absoluteFilePath(); 3868 3869 qDebug("***fileName signatures: |%s|",newfile.toUtf8().data()); 3870 fileName = new GooString(newfile.toUtf8().data()); // le paso el path del documento PDF para abrirlo 3871 3872 // open PDF file 3873 doc = PDFDocFactory().createPDFDoc(*fileName, NULL, NULL); //abre el documento 3874 //qDebug(".......1"); 3875 if (!doc->isOk()) { 3876 exitCode = 1; 3877 qDebug(".......error"); 3878 return; 3879 //goto end; 3880 } 3881 3882 qDebug(".......3"); 3883 sig_widgets = doc->getSignatureWidgets(); 3884 sigCount = sig_widgets.size(); 3885 3886 3887 QString newmessage = trUtf8("Número de firmas: %1 ").arg(sigCount); 3888 newmessage += "\n \n"; 3889 //qDebug("fileName number of signatures: %d", sigCount); 3890 //qDebug("****************************"); 3891 //qDebug(fileName->getCString()); 3892 3893 //*********************** 3894 // if (sigCount >= 1) { 3895 // //newmessage =+ trUtf8("Digital Signature Info of: %s\n").arg(fileName->getCString()); 3896 // //qDebug(fileName->getCString()); //path del archivo que se abrio 3897 // qDebug("El archivo contiene firma electrónica"); 3898 // //printf("Digital Signature Info of: %s\n", fileName->getCString()); 3899 // } else { 3900 // //newmessage =+ trUtf8("File '%s' does not contain any signatures\n").arg(fileName->getCString()); 3901 // qDebug("El archivo no contiene firma electrónica"); 3902 // //printf("File '%s' does not contain any signatures\n", fileName->getCString()); 3903 // exitCode = 2; 3904 // return; 3905 // //goto end; 3906 // } 3907 3908 for (unsigned int i = 0; i < sigCount; i++) { 3909 sig_info = sig_widgets.at(i)->validateSignature(!dontVerifyCert, false); 3910 qDebug("Firma %d ", i+1); 3911 //printf("Signature #%u:\n", i+1); 3912 newmessage += trUtf8("Firma número %1").arg(i+1); 3913 newmessage += "\n"; 3914 //qDebug("entro al for: %d", i); 3915 //qDebug(i+1); 3916 //printf(" - Signer Certificate Common Name: %s\n", sig_info->getSignerName()); 3917 qDebug(sig_info->getSignerName()); 3918 newmessage += trUtf8(" - Nombre común: %1 \n").arg(sig_info->getSignerName()); 3919 //newmessage += " \n"; 3920 //printf(" - Signing Time: %s\n", time_str = getReadableTime(sig_info->getSigningTime())); 3921 newmessage += trUtf8(" - Hora de la firma: %1f \n").arg(time_str = getReadableTime(sig_info->getSigningTime())); 3922 //newmessage += " \n"; 3923 //newmessage =+ trUtf8(" - Signing Time: %s\n").arg(getReadableTime(sig_info->getSigningTime())); 3924 //printf(" - Signature Validation: %s\n", getReadableSigState(sig_info->getSignatureValStatus())); 3925 newmessage += trUtf8(" - Validación de la firma: %1 \n").arg(trUtf8(getReadableSigState(sig_info->getSignatureValStatus()))); 3926 3927 //newmessage =+ trUtf8(" - Signature Validation: %s\n").arg(getReadableSigState(sig_info->getSignatureValStatus())); 3928 //gfree(time_str); 3929 //if (sig_info->getSignatureValStatus() != SIGNATURE_VALID || dontVerifyCert) { 3930 //continue; 3931 //} 3932 //printf(" - Certificate Validation: %s\n", getReadableCertState(sig_info->getCertificateValStatus())); 3933 newmessage += trUtf8(" - Validación del certificado: %1").arg(getReadableCertState(sig_info->getCertificateValStatus())); 3934 newmessage += " \n"; 3935 } 3936 3937 //*********************** 3938 3536 3939 3537 3940 QString my_msg; … … 3540 3943 QMessageBox my_msg_Box; 3541 3944 int cont = 1; 3542 if( cont == 0) {3945 if(sigCount == 0) { 3543 3946 my_msg_Box.setText("El documento no esta firmado"); 3544 3947 my_msg_Box.exec(); … … 3546 3949 else { 3547 3950 my_msg_Box.setText("El documento esta firmado electronicamente"); 3548 my_msg_Box.setDetailedText( my_msg);3951 my_msg_Box.setDetailedText(newmessage); 3549 3952 my_msg_Box.exec(); 3550 3953 } -
sources/mainwindow.h
re0e368b r7eb08ea 33 33 34 34 #include <QDBusAbstractAdaptor> 35 #include <QListWidget> 36 #include <QStandardItemModel> 35 37 36 38 #endif // WITH_DBUS … … 89 91 90 92 protected slots: 93 91 94 void on_tabWidget_currentChanged(int index); 92 95 void on_tabWidget_tabCloseRequested(int index); … … 239 242 240 243 void on_properties_sectionCountChanged(); 244 void on_detailsSignatureView_sectionCountChanged(); 241 245 242 246 void on_thumbnails_dockLocationChanged(Qt::DockWidgetArea area); … … 252 256 253 257 void on_saveDatabase_timeout(); 258 254 259 void on_verify_signature(); 260 //QString verify_signature(); 261 //QStringList verify_signature(); 262 QStandardItemModel* verify_signature(); 263 QStandardItemModel* view_table_verify_signature(); 255 264 256 265 protected: … … 424 433 425 434 QDockWidget* m_propertiesDock; 435 QDockWidget* m_detailsSignatureDock; 426 436 QTableView* m_propertiesView; 437 QTableView* m_detailsSignatureView; 438 //QListWidget* m_detailsSignatureView; 439 QTableView* m_tableVerifySign; 427 440 428 441 QDockWidget* m_thumbnailsDock; … … 437 450 438 451 QDockWidget* createDock(const QString& text, const QString& objectName, const QKeySequence& toggleViewShortcut); 452 QListWidget* prueba; 453 439 454 440 455 void createSearchDock();
Note: See TracChangeset
for help on using the changeset viewer.