changes for WIN32 to use the installation-dir registry-key

and the %USERPROFILE% for databasedir
This commit is contained in:
chris2511 2003-05-14 18:03:34 +00:00
parent 1739747e7b
commit 0bf5d0e8d8
9 changed files with 189 additions and 161 deletions

View File

@ -238,7 +238,7 @@
<name>text</name>
<string>DER is a binary format of the Certificate
PEM is a base64 encoded Certificate
PKCS#7 is an official Certificate exchange format</string>
PKCS#7 is an official Certificate exchange format
PKCS#12 is an encrypted official Key-Certificate exchange format</string>
</property>
<property stdset="1">

View File

@ -73,10 +73,22 @@ MainWindow::MainWindow(QWidget *parent, const char *name )
temps = NULL;
dbenv = NULL;
global_tid = NULL;
#ifdef WIN32
baseDir = "";
char buf[255] = "";
DWORD ret_val;
ret_val = ExpandEnvironmentStrings("%USERPROFILE%", buf, 255);
baseDir = buf;
if (ret_val == 0) baseDir = "C:";
if (ret_val > 255) {
QMessageBox::warning(this,tr(XCA_TITLE), "Your %USERPROFILE% is too long");
qFatal( "Couldnt create: " + baseDir );
}
#else
baseDir = QDir::homeDirPath();
#endif
baseDir += QDir::separator();
baseDir += BASE_DIR;
@ -85,8 +97,7 @@ MainWindow::MainWindow(QWidget *parent, const char *name )
if (!d.mkdir(baseDir))
qFatal( "Couldnt create: " + baseDir );
}
#endif
#ifdef qt3
connect( keyList, SIGNAL(itemRenamed(QListViewItem *, int, const QString &)),
@ -286,6 +297,9 @@ void MainWindow::initPass()
PASS_INFO p;
string passHash = settings->getString("pwhash");
if (passHash == "") {
#ifdef WIN32
QMessageBox::warning(this,tr(XCA_TITLE), tr("WARNING: If you have updated your 'xca' application you have to copy your 'xca.db' from 'C:\\PROGAM FILES\\XCA\\' to 'C:\\DOCUMENTS AND SETTINGS\\xca\\ ( %USERPROFILE% )"));
#endif
string title=tr("New Password").latin1();
string description=tr("Please enter a password, that will be used to encrypt your private keys in the database-file").latin1();
p.title = &title;
@ -463,12 +477,12 @@ void MainWindow::newPath(QString str)
bool MainWindow::mkDir(QString dir)
{
#ifdef WIN32
int ret = mkdir(dir.latin1());
// in direct.h declare _CRTIMP int __cdecl mkdir(const char *);
#else
#ifdef WIN32
int ret = mkdir(dir.latin1());
// in direct.h declare _CRTIMP int __cdecl mkdir(const char *);
#else
int ret = mkdir(dir.latin1(), S_IRUSR | S_IWUSR | S_IXUSR);
#endif
#endif
if (ret) {
QString desc = " (";
desc += strerror(ret);
@ -478,6 +492,6 @@ bool MainWindow::mkDir(QString dir)
return false;
}
return true;
}

View File

@ -104,8 +104,10 @@
#include "lib/db_crl.h"
#include <sys/types.h>
#include <sys/stat.h>
#ifdef WIN32
#include <direct.h> // to define mkdir function
#include <WINDOWS.H> // to define mkdir function
#else
#include <unistd.h>
#endif
@ -119,7 +121,8 @@
class MainWindow: public MainWindow_UI
{
Q_OBJECT
Q_OBJECT
protected:
void addStr(string &str, const char *add);
void init_images();

View File

@ -6,5 +6,5 @@
#define DBEX(x)
#define CERR(x)
#define PREFIX ""
#define XCA_TITLE "X Certifikate and Key management"

View File

@ -51,7 +51,6 @@
#include "db_base.h"
db_base::db_base(DbEnv *dbe, string DBfile, string DB, DbTxn *global_tid)
{
dbenv = dbe;
@ -443,14 +442,31 @@ pki_base *db_base::findPKI(pki_base *refpki)
QPixmap *db_base::loadImg(const char *name )
{
QString path ="";
#ifdef WIN32
path = ".";
#else
path = PREFIX ;
#endif
path += QDir::separator();
return new QPixmap(path + name);
unsigned char PREFIX[100];
LONG lRc;
HKEY hKey;
lRc=RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\xca",0,KEY_READ, &hKey);
if(lRc!= ERROR_SUCCESS){
// No key error
QMessageBox::warning(NULL,tr(XCA_TITLE), "Registry Key: 'HKEY_LOCAL_MACHINE->Software->xca' not found");
PREFIX[0] = '\0';
}
else {
ULONG dwLength = 100;
lRc=RegQueryValueEx(hKey,"Install_Dir",NULL,NULL, PREFIX, &dwLength);
if(lRc!= ERROR_SUCCESS){
// No key error
QMessageBox::warning(NULL,tr(XCA_TITLE), "Registry Key: 'HKEY_LOCAL_MACHINE->Software->xca->Install_Dir' not found");
PREFIX[0] = '\0';
}
}
lRc=RegCloseKey(hKey);
#endif
QString path = (char *)PREFIX;
path += QDir::separator();
return new QPixmap(path + name);
}
void db_base::updateViewPKI(pki_base *pki)

View File

@ -49,6 +49,7 @@
*/
#include <qglobal.h>
#ifdef HAVE_CONFIG_H
#include "../config.h"
@ -68,7 +69,9 @@
#else // HAVE_CONFIG_H
#define WIN32 1
#include <db_cxx.h>
#include <db_cxx.h>
#include <WINDOWS.H>
#endif // HAVE_CONFIG_H
#include <qlistview.h>

10
xca.dsp
View File

@ -65,7 +65,7 @@ LINK32=link.exe
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD CPP /nologo /MD /W3 /Gm /Zi /Od /I "$(QTDIR)\include" /I "$(QTDIR)\mkspecs\win32-msvc" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "UNICODE" /D "QT_DLL" /D "QT_THREAD_SUPPORT" /FD /GZ -Zm200 /c
# ADD CPP /nologo /MD /W3 /Gm /GX /Zi /Od /I "$(QTDIR)\include" /I "$(QTDIR)\mkspecs\win32-msvc" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "QT_DLL" /D "QT_THREAD_SUPPORT" /FD /D /GZ -Zm200 "UNICODE" /c
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x407
# ADD RSC /l 0x409 /d "_DEBUG"
@ -208,6 +208,14 @@ InputPath=.\lib\db_crl.h
!ELSEIF "$(CFG)" == "xca - Win32 Debug"
# Begin Custom Build
InputPath=.\lib\db_crl.h
"lib\moc_db_crl.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
$(QTDIR)\bin\moc lib\db_crl.h -o lib\moc_db_crl.cpp
# End Custom Build
!ENDIF
# End Source File

58
xca.dsw
View File

@ -1,29 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELÖSCHT WERDEN!
###############################################################################
Project: "xca"=.\xca.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELÖSCHT WERDEN!
###############################################################################
Project: "xca"=".\xca.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

204
xca.nsi
View File

@ -1,110 +1,94 @@
; xca.nsi
;
; This is the .nsi script for creating the nullsoft windows installer
; The name of the installer
Name "X CA"
Caption "X Certification Authority"
; The licenseagreement
LicenseText "You must accept the following BSD like license to continue."
LicenseData COPYRIGHT
; The file to write
OutFile "xca.exe"
; The default installation directory
InstallDir $PROGRAMFILES\xca
; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
InstallDirRegKey HKLM SOFTWARE\xca "Install_Dir"
; The text to prompt the user to enter a directory
ComponentText "This will install the X Certification Authority (c) 2002 by Christian@Hohnstaedt.de"
; The text to prompt the user to enter a directory
DirText "Choose a directory to install in to:"
; The stuff to install
Section "xca (required)"
; Set output path to the installation directory.
SetOutPath $INSTDIR
; Put file there
File "Release\xca.exe"
File "img\bigcert.png"
File "img\bigcsr.png"
File "img\bigkey.png"
File "img\bigtemp.png"
File "img\halfkey.png"
File "img\invalidcert.png"
File "img\invalidcertkey.png"
File "img\key.png"
File "img\req.png"
File "img\reqkey.png"
File "img\template.png"
File "img\validcert.png"
File "img\validcertkey.png"
File "c:\devel\db-4.0.14\build_win32\Release\libdb40.dll"
File "c:\devel\openssl-0.9.6g\out32dll\Release\SSLeay32.dll"
File "c:\devel\openssl-0.9.6g\out32dll\Release\libeay32.dll"
File "e:\win\qt2\bin\msvcrt.dll"
File "c:\windows\system\msvcp60.dll"
File "e:\win\qt2\bin\qt-mt230nc.dll"
; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\xca "Install_Dir" "$INSTDIR"
; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\xca" "DisplayName" "X CA (remove only)"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\xca" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteUninstaller "uninstall.exe"
SectionEnd
; optional section
Section "Start Menu Shortcuts"
CreateDirectory "$SMPROGRAMS\xca"
CreateShortCut "$SMPROGRAMS\xca\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
CreateShortCut "$SMPROGRAMS\xca\xca xca.lnk" "$INSTDIR\xca.exe" "" "$INSTDIR\xca.exe" 0
SectionEnd
; uninstall stuff
UninstallText "This will uninstall xca. Hit next to continue."
; special uninstall section.
Section "Uninstall"
; remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\xca"
DeleteRegKey HKLM SOFTWARE\xca
; remove files
Delete $INSTDIR\xca.exe
; MUST REMOVE UNINSTALLER, too
Delete $INSTDIR\uninstall.exe
; remove shortcuts, if any.
Delete "$SMPROGRAMS\xca\*.*"
; remove directories used.
RMDir "$SMPROGRAMS\xca"
;RMDir "$INSTDIR" NO, we keep the databasefiles xca.db
Delete "$INSTDIR\xca\*.png"
Delete "$INSTDIR\xca\*.dll"
Delete "$INSTDIR\bigcert.png"
Delete "$INSTDIR\bigcsr.png"
Delete "$INSTDIR\bigkey.png"
Delete "$INSTDIR\bigtemp.png"
Delete "$INSTDIR\halfkey.png"
Delete "$INSTDIR\invalidcert.png"
Delete "$INSTDIR\invalidcertkey.png"
Delete "$INSTDIR\key.png"
Delete "$INSTDIR\req.png"
Delete "$INSTDIR\reqkey.png"
Delete "$INSTDIR\template.png"
Delete "$INSTDIR\validcert.png"
Delete "$INSTDIR\validcertkey.png"
Delete "$INSTDIR\libdb40.dll"
Delete "$INSTDIR\SSLeay32.dll"
Delete "$INSTDIR\libeay32.dll"
Delete "$INSTDIR\msvcrt.dll"
Delete "$INSTDIR\msvcp60.dll"
Delete "$INSTDIR\qt-mt230nc.dll"
SectionEnd
; eof
; xca.nsi
;
; This is the .nsi script for creating the nullsoft windows installer
; The name of the installer
Name "X CA"
Caption "X Certification Authority"
; The licenseagreement
LicenseText "You must accept the following BSD like license to continue."
LicenseData COPYRIGHT
; The file to write
OutFile "xca.exe"
; The default installation directory
InstallDir $PROGRAMFILES\xca
; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
InstallDirRegKey HKLM SOFTWARE\xca "Install_Dir"
; The text to prompt the user to enter a directory
ComponentText "This will install the X Certification Authority (c) 2002 by Christian@Hohnstaedt.de"
; The text to prompt the user to enter a directory
DirText "Choose a directory to install in to:"
; The stuff to install
Section "xca (required)"
; Set output path to the installation directory.
SetOutPath $INSTDIR
; Put file there
File "Release\xca.exe"
File "img\bigcert.png"
File "img\bigcrl.png"
File "img\bigcsr.png"
File "img\bigkey.png"
File "img\bigtemp.png"
File "img\halfkey.png"
File "img\invalidcert.png"
File "img\invalidcertkey.png"
File "img\key.png"
File "img\key.ico"
File "img\key.xpm"
File "img\netscape.png"
File "img\req.png"
File "img\reqkey.png"
File "img\revoked.png"
File "img\template.png"
File "img\validcert.png"
File "img\validcertkey.png"
File "Release\libdb41.dll"
File "Release\SSLeay32.dll"
File "Release\libeay32.dll"
File "Release\msvcrt.dll"
File "Release\msvcp60.dll"
File "Release\qt-mt230nc.dll"
; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\xca "Install_Dir" "$INSTDIR"
; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\xca" "DisplayName" "X CA (remove only)"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\xca" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteUninstaller "uninstall.exe"
SectionEnd
; optional section
Section "Start Menu Shortcuts"
CreateDirectory "$SMPROGRAMS\xca"
CreateShortCut "$SMPROGRAMS\xca\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
CreateShortCut "$SMPROGRAMS\xca\xca.lnk" "$INSTDIR\xca.exe" "" "$INSTDIR\xca.exe" 0
SectionEnd
; uninstall stuff
UninstallText "This will uninstall xca. Hit next to continue."
; special uninstall section.
Section "Uninstall"
; remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\xca"
DeleteRegKey HKLM SOFTWARE\xca
; remove files
Delete $INSTDIR\xca.exe
; MUST REMOVE UNINSTALLER, too
Delete $INSTDIR\uninstall.exe
; remove shortcuts, if any.
Delete "$SMPROGRAMS\xca\*.*"
; remove directories used.
RMDir "$SMPROGRAMS\xca"
RMDir "$INSTDIR"
SectionEnd
; eof