From 37a58ab9c80bb78e09de1cc61c12df026da5dbbd Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 25 Jul 2002 09:43:57 +0000 Subject: [PATCH] signals and slots introduced to db certs and requests do notice fading and arising keys --- lib/Makefile.in | 6 +++++- lib/db_base.cpp | 1 - lib/db_base.h | 7 +++++-- lib/db_key.cpp | 12 ++++++++++++ lib/db_key.h | 6 ++++++ lib/db_x509.cpp | 12 ++++++++++++ lib/db_x509.h | 4 ++++ lib/db_x509req.cpp | 15 +++++++++++++++ lib/db_x509req.h | 4 ++++ lib/pki_x509.cpp | 1 - 10 files changed, 63 insertions(+), 5 deletions(-) diff --git a/lib/Makefile.in b/lib/Makefile.in index efee0879..62094012 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -7,12 +7,13 @@ TARGET=xca-$(VERSION) GCC=@CXX@ CPPFLAGS=@CPPFLAGS@ -Wall -g +MOC=@MOC@ ############################################## PKIOBJS=pki_base.o pki_key.o pki_x509req.o pki_x509.o pki_pkcs12.o -DBOBJS=db_base.o db_key.o db_x509req.o db_x509.o +DBOBJS=db_base.o db_key.o db_x509req.o db_x509.o db_key_MOC.o db_x509req_MOC.o db_x509_MOC.o all: libpki.a libxcadb.a @@ -23,6 +24,9 @@ libpki.a: $(PKIOBJS) libxcadb.a: $(DBOBJS) ar rcs libxcadb.a $(DBOBJS) +%_MOC.cpp: %.h + $(MOC) $< -o $@ + %.o: %.cpp %.h $(GCC) $(CPPFLAGS) -c $(INC) -DVER=\"$(VERSION)\" -DPREFIX=\"@prefix@/share/xca\" $< diff --git a/lib/db_base.cpp b/lib/db_base.cpp index 7671a1d0..d7c75629 100644 --- a/lib/db_base.cpp +++ b/lib/db_base.cpp @@ -290,4 +290,3 @@ QPixmap *db_base::loadImg(const char *name ) return new QPixmap(path + name); } - diff --git a/lib/db_base.h b/lib/db_base.h index be0cf591..32c05efc 100644 --- a/lib/db_base.h +++ b/lib/db_base.h @@ -15,7 +15,7 @@ #define DB_BASE_H -class db_base +class db_base: public QObject { protected: @@ -28,7 +28,7 @@ class db_base db_base(DbEnv *dbe, string DBfile, string db); virtual ~db_base(); virtual pki_base *newPKI(){ - cerr<<"VIRTUAL CALLED: newPKI\n"; return NULL;} + CERR<<"VIRTUAL CALLED: newPKI\n"; return NULL;} virtual bool updateView(); bool insertPKI(pki_base *pki); bool deletePKI(pki_base *pki); @@ -37,6 +37,9 @@ class db_base pki_base *getSelectedPKI(); pki_base *findPKI(pki_base *refpki); virtual void loadContainer(); + /* preprocess should be implemented once to speed up updateView() + * i.e search for signers and keys */ + virtual void preprocess() {return;} virtual void remFromCont(pki_base *pki); Dbc *getCursor(); bool freeCursor(Dbc *cursor); diff --git a/lib/db_key.cpp b/lib/db_key.cpp index 02e58c24..be3e2369 100644 --- a/lib/db_key.cpp +++ b/lib/db_key.cpp @@ -50,3 +50,15 @@ QStringList db_key::getPrivateDesc() return x; } +void db_key::remFromCont(pki_base *pki) +{ + container.remove(pki); + emit delKey((pki_key *)pki); +} + +bool db_key::insertPKI(pki_base *pki) +{ + db_base::insertPKI(pki); + emit newKey((pki_key *)pki); + return true; +} diff --git a/lib/db_key.h b/lib/db_key.h index 846a897b..be854d74 100644 --- a/lib/db_key.h +++ b/lib/db_key.h @@ -8,11 +8,17 @@ class db_key: public db_base { + Q_OBJECT public: db_key(DbEnv *dbe, string DBfile, QListView *l); pki_base *newPKI(); QStringList getPrivateDesc(); bool updateView(); + bool insertPKI(pki_base *pki); + void remFromCont(pki_base *pki); + signals: + void delKey(pki_key *delkey); + void newKey(pki_key *newkey); }; #endif diff --git a/lib/db_x509.cpp b/lib/db_x509.cpp index 20cd8590..5deeef0f 100644 --- a/lib/db_x509.cpp +++ b/lib/db_x509.cpp @@ -8,6 +8,8 @@ db_x509::db_x509(DbEnv *dbe, string DBfile, QListView *l, db_key *keyl) listView = l; loadContainer(); updateView(); + connect(keyl, SIGNAL(delKey(pki_key *)), this, SLOT(delKey(pki_key *))); + connect(keyl, SIGNAL(newKey(pki_key *)), this, SLOT(newKey(pki_key *))); } pki_base *db_x509::newPKI(){ @@ -122,4 +124,14 @@ pki_key *db_x509::findKey(pki_x509* cert) return key; } +void db_x509::delKey(pki_key *delkey) +{ + updateView(); +} + + +void db_x509::newKey(pki_key *newkey) +{ + updateView(); +} diff --git a/lib/db_x509.h b/lib/db_x509.h index 43ff2448..2d81f9d4 100644 --- a/lib/db_x509.h +++ b/lib/db_x509.h @@ -9,6 +9,7 @@ class db_x509: public db_base { + Q_OBJECT protected: db_key *keylist; public: @@ -19,6 +20,9 @@ class db_x509: public db_base void remFromCont(pki_base *pki); QStringList getPrivateDesc(); pki_key * findKey(pki_x509 *cert); + public slots: + void delKey(pki_key *delkey); + void newKey(pki_key *newKey); }; #endif diff --git a/lib/db_x509req.cpp b/lib/db_x509req.cpp index 1c073172..f27147f8 100644 --- a/lib/db_x509req.cpp +++ b/lib/db_x509req.cpp @@ -8,6 +8,8 @@ db_x509req::db_x509req(DbEnv *dbe, string DBfile, QListView *l, db_key *keyl) keylist = keyl; loadContainer(); updateView(); + connect(keyl, SIGNAL(delKey(pki_key *)), this, SLOT(delKey(pki_key *))); + connect(keyl, SIGNAL(newKey(pki_key *)), this, SLOT(newKey(pki_key *))); } pki_base *db_x509req::newPKI(){ @@ -47,3 +49,16 @@ bool db_x509req::updateView() } return true; } + + +void db_x509req::delKey(pki_key *delkey) +{ + updateView(); +} + + +void db_x509req::newKey(pki_key *newkey) +{ + updateView(); +} + diff --git a/lib/db_x509req.h b/lib/db_x509req.h index 756e39d6..82d51f91 100644 --- a/lib/db_x509req.h +++ b/lib/db_x509req.h @@ -8,6 +8,7 @@ class db_x509req: public db_base { + Q_OBJECT protected: db_key *keylist; public: @@ -15,6 +16,9 @@ class db_x509req: public db_base pki_base *newPKI(); QStringList getDesc(); bool updateView(); + public slots: + void delKey(pki_key *delkey); + void newKey(pki_key *newKey); }; #endif diff --git a/lib/pki_x509.cpp b/lib/pki_x509.cpp index 3876d3c4..7a5dd901 100644 --- a/lib/pki_x509.cpp +++ b/lib/pki_x509.cpp @@ -237,7 +237,6 @@ string pki_x509::fingerprint(EVP_MD *digest) return fp; } - int pki_x509::checkDate() { time_t tnow = time(NULL);