Update ooo320-m1
[ooovba.git] / connectivity / source / inc / adabas / BDriver.hxx
blob794c6122f6a65f928091f88784097e6a2bae61a9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: BDriver.hxx,v $
10 * $Revision: 1.13 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CONNECTIVITY_ADABAS_BDRIVER_HXX_
32 #define _CONNECTIVITY_ADABAS_BDRIVER_HXX_
34 #include <com/sun/star/sdbc/XDriver.hpp>
35 #include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
36 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
37 #include <com/sun/star/sdbcx/XCreateCatalog.hpp>
38 #include <com/sun/star/sdbcx/XDropCatalog.hpp>
40 #include <com/sun/star/lang/XEventListener.hpp>
42 //#include <unotools/tempfile.hxx>
43 #include <cppuhelper/implbase4.hxx>
44 #include "odbc/OFunctiondefs.hxx"
45 #include "odbc/ODriver.hxx"
47 namespace connectivity
49 namespace adabas
51 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ODriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception );
53 typedef ::cppu::ImplHelper4< ::com::sun::star::sdbcx::XCreateCatalog,
54 ::com::sun::star::sdbcx::XDataDefinitionSupplier,
55 ::com::sun::star::lang::XEventListener,
56 ::com::sun::star::sdbcx::XDropCatalog> ODriver_BASE2;
58 typedef odbc::ODBCDriver ODriver_BASE;
60 class ODriver : public ODriver_BASE,
61 public ODriver_BASE2
63 typedef struct DatabaseStruct
65 ::rtl::OUString sControlUser;
66 ::rtl::OUString sControlPassword;
67 ::rtl::OUString sSysUser;
68 ::rtl::OUString sSysPassword;
69 ::rtl::OUString sDomainPassword;
70 ::rtl::OUString sCacheSize;
71 ::rtl::OUString sBackupFile;
72 ::rtl::OUString sDataDevName;
73 ::rtl::OUString sSysDevSpace;
74 ::rtl::OUString sTransLogName;
75 ::rtl::OUString sDBName;
76 sal_Int32 nDataIncrement; // which size the database should grow
77 sal_Int32 nDataSize;
78 sal_Int32 nLogSize;
79 sal_Bool bShutDown;
80 sal_Bool bRestoreDatabase;
82 DatabaseStruct() : nDataIncrement(0),nDataSize(0),nLogSize(0),bShutDown(sal_False),bRestoreDatabase(sal_False){ }
83 } TDatabaseStruct;
85 DECLARE_STL_USTRINGACCESS_MAP(TDatabaseStruct,TDatabaseMap);
86 TDatabaseMap m_aDatabaseMap; // contains all adabas databases with their flag to shut down or not
88 // environment vars
89 ::rtl::OUString m_sDbWork;
90 ::rtl::OUString m_sDbConfig;
91 ::rtl::OUString m_sDbRoot;
92 ::rtl::OUString m_sDbWorkURL;
93 ::rtl::OUString m_sDbConfigURL;
94 ::rtl::OUString m_sDbRootURL;
95 ::rtl::OUString m_sDbRunDir;
96 ::rtl::OUString m_sDelimit;
98 void checkAndInsertNewDevSpace(const ::rtl::OUString& _rDBName,const TDatabaseStruct& _rDBInfo);
99 void checkAndRestart(const ::rtl::OUString& _rDBName,const TDatabaseStruct& _rDbInfo);
100 void X_CONS(const ::rtl::OUString& _DBNAME,const ::rtl::OString& _ACTION,const ::rtl::OUString& _FILENAME);
101 sal_Bool getDBName(const ::rtl::OUString& _rName,::rtl::OUString& _rDBName) const;
102 ::rtl::OUString getDatabaseInitFile( const TDatabaseStruct& _aInfo);
103 ::rtl::OUString generateInitFile() const;
104 void fillEnvironmentVariables();
105 void fillInfo(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info, TDatabaseStruct& _rDBInfo /*out*/);
106 void LoadBatch(const ::rtl::OUString& _rDBNAME,
107 const ::rtl::OUString& _rUSR,
108 const ::rtl::OUString& _rPWD,
109 const ::rtl::OUString& _rBatch);
110 void XUTIL(const ::rtl::OUString& _rParam,
111 const ::rtl::OUString& _DBNAME,
112 const ::rtl::OUString& _USRNAME,
113 const ::rtl::OUString& _USRPWD);
114 int X_STOP(const ::rtl::OUString& _DBNAME);
115 int X_START(const ::rtl::OUString& _DBNAME);
116 void createDb(const TDatabaseStruct& _aInfo);
117 void clearDatabase(const ::rtl::OUString& _rDBName);
118 int X_PARAM(const ::rtl::OUString& _DBNAME,
119 const ::rtl::OUString& _USR,
120 const ::rtl::OUString& _PWD,
121 const ::rtl::OUString& _CMD);
122 sal_Int32 CreateFiles(const TDatabaseStruct& _aInfo);
123 sal_Bool CreateFile(const ::rtl::OUString &_FileName,
124 sal_Int32 _nSize);
125 void PutParam(const ::rtl::OUString& rDBNAME,
126 const ::rtl::OUString& rWhat,
127 const ::rtl::OUString& rHow);
128 void createNeededDirs( const ::rtl::OUString& _rDBName);
129 sal_Bool isKernelVersion(const char* _pVersion);
130 sal_Bool isVersion( const ::rtl::OUString& _rDBName,
131 const char* _pVersion);
133 void convertOldVersion( const ::rtl::OUString& _rDBName,
134 const TDatabaseStruct& _rDbInfo);
136 void installSystemTables( const TDatabaseStruct& _aInfo);
138 protected:
139 virtual SQLHANDLE EnvironmentHandle(::rtl::OUString &_rPath);
140 virtual ~ODriver();
141 public:
142 explicit ODriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
144 // XInterface
145 static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException);
146 static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException);
147 private:
148 DECLARE_SERVICE_INFO();
150 virtual oslGenericFunction getOdbcFunction(sal_Int32 _nIndex) const;
151 // OComponentHelper
152 virtual void SAL_CALL disposing(void);
153 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
154 virtual void SAL_CALL acquire() throw();
155 virtual void SAL_CALL release() throw();
157 // XDriver
158 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connect( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
159 virtual sal_Bool SAL_CALL acceptsURL( const ::rtl::OUString& url ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
160 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
161 virtual sal_Int32 SAL_CALL getMajorVersion( ) throw(::com::sun::star::uno::RuntimeException);
162 virtual sal_Int32 SAL_CALL getMinorVersion( ) throw(::com::sun::star::uno::RuntimeException);
164 // XDataDefinitionSupplier
165 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByConnection( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& connection ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
166 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL getDataDefinitionByURL( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
168 // XCreateCatalog
169 virtual void SAL_CALL createCatalog( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
170 // XDropCatalog
171 virtual void SAL_CALL dropCatalog( const ::rtl::OUString& catalogName, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
172 // XEventListener
173 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
178 #endif //_CONNECTIVITY_ADABAS_BDRIVER_HXX_