db_base.h
上传用户:stc1860
上传日期:2007-01-12
资源大小:234k
文件大小:4k
源码类别:

CA认证

开发平台:

MultiPlatform

  1. /*
  2.  * Copyright (C) 2001 Christian Hohnstaedt.
  3.  *
  4.  *  All rights reserved.
  5.  *
  6.  *
  7.  *  Redistribution and use in source and binary forms, with or without 
  8.  *  modification, are permitted provided that the following conditions are met:
  9.  *
  10.  *  - Redistributions of source code must retain the above copyright notice,
  11.  *    this list of conditions and the following disclaimer.
  12.  *  - Redistributions in binary form must reproduce the above copyright notice,
  13.  *    this list of conditions and the following disclaimer in the documentation
  14.  *    and/or other materials provided with the distribution.
  15.  *  - Neither the name of the author nor the names of its contributors may be 
  16.  *    used to endorse or promote products derived from this software without
  17.  *    specific prior written permission.
  18.  *
  19.  *
  20.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  22.  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  23.  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  24.  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  25.  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  26.  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  27.  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  28.  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  29.  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  30.  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31.  *
  32.  *
  33.  * This program links to software with different licenses from:
  34.  *
  35.  * http://www.openssl.org which includes cryptographic software
  36.  *  written by Eric Young (eay@cryptsoft.com)"
  37.  *
  38.  * http://www.sleepycat.com
  39.  *
  40.  * http://www.trolltech.com
  41.  * 
  42.  *
  43.  *
  44.  * http://www.hohnstaedt.de/xca
  45.  * email: christian@hohnstaedt.de
  46.  *
  47.  * $Id: db_base.h,v 1.31 2003/01/06 19:35:50 chris Exp $
  48.  *
  49.  */                           
  50. #ifdef HAVE_CONFIG_H
  51. #include "../config.h"
  52. #ifdef HAVE_DB4_DB_CXX_H
  53. #include <db4/db_cxx.h>
  54. #elif HAVE_DB3_DB_CXX_H
  55. #include <db3/db_cxx.h>
  56. #elif HAVE_DB_DB_CXX_H
  57. #include <db/db_cxx.h>
  58. #else
  59. #include <db_cxx.h>
  60. #endif
  61. #ifdef HAVE_QACCESSIBLE_H
  62. #define qt3 1
  63. #endif
  64. #else  // HAVE_CONFIG_H
  65. #define WIN32 1
  66. #include <db_cxx.h>
  67. #endif  // HAVE_CONFIG_H
  68. #include <qlistview.h>
  69. #include <qlist.h>
  70. #include <qdir.h>
  71. #include <qmessagebox.h>
  72. #include <qpixmap.h>
  73. #include <qstringlist.h>
  74. #include "pki_base.h"
  75. #define BASE_DIR "xca"
  76. #ifndef DB_BASE_H
  77. #define DB_BASE_H
  78. class db_base: public QObject
  79. {
  80.     protected:
  81. Db *data;
  82. DbEnv *dbenv;
  83. QListView *listView;
  84. QList<pki_base> container;
  85. void _writePKI(pki_base *pki, bool overwrite, DbTxn *tid );
  86. void _removePKI(pki_base *pki, DbTxn *tid );
  87. void removeItem(string k, DbTxn *tid);
  88.     public:
  89. db_base(DbEnv *dbe, string DBfile, string db);
  90. virtual ~db_base();
  91. virtual pki_base *newPKI(){
  92. CERR("VIRTUAL CALLED: newPKI"); return NULL;}
  93. virtual bool updateView();
  94. virtual void updateViewPKI(pki_base *pki);
  95. virtual void insertPKI(pki_base *pki);
  96. virtual void deletePKI(pki_base *pki);
  97. virtual void updatePKI(pki_base *pki);
  98. virtual void renamePKI(pki_base *pki, string desc);
  99. pki_base *getSelectedPKI(void *item);
  100. pki_base *getSelectedPKI(string desc);
  101. pki_base *getSelectedPKI();
  102. pki_base *findPKI(pki_base *refpki);
  103. virtual void loadContainer();
  104. QStringList getDesc();
  105. /* preprocess should be implemented once to speed up updateView() 
  106.  * i.e search for signers and keys */
  107. virtual void preprocess() {return;}
  108. virtual void remFromCont(pki_base *pki);
  109. virtual void inToCont(pki_base *pki);
  110. void *getData(void* key, int length, int *dsize);
  111. void *getData(string key, int *dsize);
  112. string getString(string key);
  113. string getString(char *key);
  114. int getInt(string key);
  115. void putData(void *key, int keylen, void *dat, int datalen);
  116. void putString(string key, void *dat, int datalen);
  117. void putString(string key, string dat);
  118. void putString(char *key, string dat);
  119. void putInt(string key, int dat);
  120. QPixmap *loadImg(const char *name);
  121. void setSelected(pki_base *item);
  122. };
  123. #endif