1 /* vi: set sw=4 ts=4: 2 * 3 * Copyright (C) 2014 Christian Hohnstaedt. 4 * 5 * All rights reserved. 6 */ 7 8 #ifndef __EXPORTDIALOG_H 9 #define __EXPORTDIALOG_H 10 11 #include "ui_ExportDialog.h" 12 #include "lib/pki_base.h" 13 14 class QPixmap; 15 16 class exportType { 17 public: 18 enum etype { Separator, PEM, PEM_chain, PEM_unrevoked, PEM_all, 19 DER, PKCS7, PKCS7_chain, PKCS7_unrevoked, PKCS7_all, 20 PKCS12, PKCS12_chain, PEM_cert_key, PEM_cert_pk8, 21 PEM_key, PEM_private, PEM_private_encrypt, DER_private, 22 DER_key, PKCS8, PKCS8_encrypt, SSH2_public, 23 PEM_selected, PKCS7_selected, Index, vcalendar, vcalendar_ca, 24 PVK_private, PVK_encrypt, SSH2_private, ETYPE_max }; 25 enum etype type; 26 QString desc; 27 QString extension; exportType(enum etype t,QString e,QString d)28 exportType(enum etype t, QString e, QString d) { 29 type = t; extension = e; desc = d; 30 } exportType()31 exportType() { type = Separator; } isPEM()32 bool isPEM() const { 33 switch (type) { 34 case PEM: 35 case PEM_chain: 36 case PEM_unrevoked: 37 case PEM_all: 38 case PEM_cert_key: 39 case PEM_cert_pk8: 40 case PEM_key: 41 case PEM_private: 42 case PEM_private_encrypt: 43 case PEM_selected: 44 case SSH2_private: 45 return true; 46 default: 47 return false; 48 } 49 } 50 }; 51 Q_DECLARE_METATYPE(exportType); 52 53 class ExportDialog: public QDialog, public Ui::ExportDialog 54 { 55 Q_OBJECT 56 57 protected: 58 QString filter; 59 QVector<QString> help; 60 61 public: 62 ExportDialog(QWidget *w, const QString &title, const QString &filt, 63 pki_base *pki, const QPixmap &img, QList<exportType> types, 64 const QString &help_ctx = QString()); 65 static bool mayWriteFile(const QString &fname); 66 enum exportType::etype type(); 67 68 public slots: 69 void on_fileBut_clicked(); 70 void on_exportFormat_activated(int); 71 void on_exportFormat_highlighted(int index); 72 void accept(); 73 }; 74 75 #endif 76