xref: /trunk/main/connectivity/source/inc/adabas/BDriver.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
1*caf5cd79SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*caf5cd79SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*caf5cd79SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*caf5cd79SAndrew Rist  * distributed with this work for additional information
6*caf5cd79SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*caf5cd79SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*caf5cd79SAndrew Rist  * "License"); you may not use this file except in compliance
9*caf5cd79SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*caf5cd79SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*caf5cd79SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*caf5cd79SAndrew Rist  * software distributed under the License is distributed on an
15*caf5cd79SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*caf5cd79SAndrew Rist  * KIND, either express or implied.  See the License for the
17*caf5cd79SAndrew Rist  * specific language governing permissions and limitations
18*caf5cd79SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*caf5cd79SAndrew Rist  *************************************************************/
21*caf5cd79SAndrew Rist 
22*caf5cd79SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _CONNECTIVITY_ADABAS_BDRIVER_HXX_
25cdf0e10cSrcweir #define _CONNECTIVITY_ADABAS_BDRIVER_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/sdbc/XDriver.hpp>
28cdf0e10cSrcweir #include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
29cdf0e10cSrcweir #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
30cdf0e10cSrcweir #include <com/sun/star/sdbcx/XCreateCatalog.hpp>
31cdf0e10cSrcweir #include <com/sun/star/sdbcx/XDropCatalog.hpp>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <com/sun/star/lang/XEventListener.hpp>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir //#include <unotools/tempfile.hxx>
36cdf0e10cSrcweir #include <cppuhelper/implbase4.hxx>
37cdf0e10cSrcweir #include "odbc/OFunctiondefs.hxx"
38cdf0e10cSrcweir #include "odbc/ODriver.hxx"
39cdf0e10cSrcweir 
40cdf0e10cSrcweir namespace connectivity
41cdf0e10cSrcweir {
42cdf0e10cSrcweir     namespace adabas
43cdf0e10cSrcweir     {
44cdf0e10cSrcweir         ::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 );
45cdf0e10cSrcweir 
46cdf0e10cSrcweir         typedef ::cppu::ImplHelper4<    ::com::sun::star::sdbcx::XCreateCatalog,
47cdf0e10cSrcweir                                         ::com::sun::star::sdbcx::XDataDefinitionSupplier,
48cdf0e10cSrcweir                                         ::com::sun::star::lang::XEventListener,
49cdf0e10cSrcweir                                         ::com::sun::star::sdbcx::XDropCatalog> ODriver_BASE2;
50cdf0e10cSrcweir 
51cdf0e10cSrcweir         typedef odbc::ODBCDriver ODriver_BASE;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir         class ODriver : public ODriver_BASE,
54cdf0e10cSrcweir                         public ODriver_BASE2
55cdf0e10cSrcweir         {
56cdf0e10cSrcweir             typedef struct DatabaseStruct
57cdf0e10cSrcweir             {
58cdf0e10cSrcweir                 ::rtl::OUString sControlUser;
59cdf0e10cSrcweir                 ::rtl::OUString sControlPassword;
60cdf0e10cSrcweir                 ::rtl::OUString sSysUser;
61cdf0e10cSrcweir                 ::rtl::OUString sSysPassword;
62cdf0e10cSrcweir                 ::rtl::OUString sDomainPassword;
63cdf0e10cSrcweir                 ::rtl::OUString sCacheSize;
64cdf0e10cSrcweir                 ::rtl::OUString sBackupFile;
65cdf0e10cSrcweir                 ::rtl::OUString sDataDevName;
66cdf0e10cSrcweir                 ::rtl::OUString sSysDevSpace;
67cdf0e10cSrcweir                 ::rtl::OUString sTransLogName;
68cdf0e10cSrcweir                 ::rtl::OUString sDBName;
69cdf0e10cSrcweir                 sal_Int32       nDataIncrement;     // which size the database should grow
70cdf0e10cSrcweir                 sal_Int32       nDataSize;
71cdf0e10cSrcweir                 sal_Int32       nLogSize;
72cdf0e10cSrcweir                 sal_Bool        bShutDown;
73cdf0e10cSrcweir                 sal_Bool        bRestoreDatabase;
74cdf0e10cSrcweir 
DatabaseStructconnectivity::adabas::ODriver::DatabaseStruct75cdf0e10cSrcweir                 DatabaseStruct() : nDataIncrement(0),nDataSize(0),nLogSize(0),bShutDown(sal_False),bRestoreDatabase(sal_False){ }
76cdf0e10cSrcweir             } TDatabaseStruct;
77cdf0e10cSrcweir 
78cdf0e10cSrcweir             DECLARE_STL_USTRINGACCESS_MAP(TDatabaseStruct,TDatabaseMap);
79cdf0e10cSrcweir             TDatabaseMap    m_aDatabaseMap; // contains all adabas databases with their flag to shut down or not
80cdf0e10cSrcweir 
81cdf0e10cSrcweir             // environment vars
82cdf0e10cSrcweir             ::rtl::OUString m_sDbWork;
83cdf0e10cSrcweir             ::rtl::OUString m_sDbConfig;
84cdf0e10cSrcweir             ::rtl::OUString m_sDbRoot;
85cdf0e10cSrcweir             ::rtl::OUString m_sDbWorkURL;
86cdf0e10cSrcweir             ::rtl::OUString m_sDbConfigURL;
87cdf0e10cSrcweir             ::rtl::OUString m_sDbRootURL;
88cdf0e10cSrcweir             ::rtl::OUString m_sDbRunDir;
89cdf0e10cSrcweir             ::rtl::OUString m_sDelimit;
90cdf0e10cSrcweir 
91cdf0e10cSrcweir             void checkAndInsertNewDevSpace(const ::rtl::OUString& _rDBName,const TDatabaseStruct& _rDBInfo);
92cdf0e10cSrcweir             void checkAndRestart(const ::rtl::OUString& _rDBName,const TDatabaseStruct& _rDbInfo);
93cdf0e10cSrcweir             void X_CONS(const ::rtl::OUString& _DBNAME,const ::rtl::OString& _ACTION,const ::rtl::OUString& _FILENAME);
94cdf0e10cSrcweir             sal_Bool getDBName(const ::rtl::OUString& _rName,::rtl::OUString& _rDBName) const;
95cdf0e10cSrcweir             ::rtl::OUString getDatabaseInitFile(  const TDatabaseStruct& _aInfo);
96cdf0e10cSrcweir             ::rtl::OUString generateInitFile()  const;
97cdf0e10cSrcweir             void fillEnvironmentVariables();
98cdf0e10cSrcweir             void fillInfo(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info, TDatabaseStruct& _rDBInfo /*out*/);
99cdf0e10cSrcweir             void LoadBatch(const ::rtl::OUString& _rDBNAME,
100cdf0e10cSrcweir                         const ::rtl::OUString& _rUSR,
101cdf0e10cSrcweir                         const ::rtl::OUString& _rPWD,
102cdf0e10cSrcweir                         const ::rtl::OUString& _rBatch);
103cdf0e10cSrcweir             void XUTIL(const ::rtl::OUString& _rParam,
104cdf0e10cSrcweir                     const ::rtl::OUString& _DBNAME,
105cdf0e10cSrcweir                     const ::rtl::OUString& _USRNAME,
106cdf0e10cSrcweir                     const ::rtl::OUString& _USRPWD);
107cdf0e10cSrcweir             int X_STOP(const ::rtl::OUString& _DBNAME);
108cdf0e10cSrcweir             int X_START(const ::rtl::OUString& _DBNAME);
109cdf0e10cSrcweir             void createDb(const TDatabaseStruct& _aInfo);
110cdf0e10cSrcweir             void clearDatabase(const ::rtl::OUString& _rDBName);
111cdf0e10cSrcweir             int X_PARAM(const ::rtl::OUString& _DBNAME,
112cdf0e10cSrcweir                         const ::rtl::OUString& _USR,
113cdf0e10cSrcweir                         const ::rtl::OUString& _PWD,
114cdf0e10cSrcweir                         const ::rtl::OUString& _CMD);
115cdf0e10cSrcweir             sal_Int32 CreateFiles(const TDatabaseStruct& _aInfo);
116cdf0e10cSrcweir             sal_Bool CreateFile(const ::rtl::OUString &_FileName,
117cdf0e10cSrcweir                                 sal_Int32 _nSize);
118cdf0e10cSrcweir             void PutParam(const ::rtl::OUString& rDBNAME,
119cdf0e10cSrcweir                         const ::rtl::OUString& rWhat,
120cdf0e10cSrcweir                         const ::rtl::OUString& rHow);
121cdf0e10cSrcweir             void createNeededDirs(      const ::rtl::OUString& _rDBName);
122cdf0e10cSrcweir             sal_Bool isKernelVersion(const char* _pVersion);
123cdf0e10cSrcweir             sal_Bool isVersion(     const ::rtl::OUString& _rDBName,
124cdf0e10cSrcweir                                     const char* _pVersion);
125cdf0e10cSrcweir 
126cdf0e10cSrcweir             void convertOldVersion(     const ::rtl::OUString& _rDBName,
127cdf0e10cSrcweir                                         const TDatabaseStruct& _rDbInfo);
128cdf0e10cSrcweir 
129cdf0e10cSrcweir             void installSystemTables(   const TDatabaseStruct& _aInfo);
130cdf0e10cSrcweir 
131cdf0e10cSrcweir         protected:
132cdf0e10cSrcweir             virtual SQLHANDLE EnvironmentHandle(::rtl::OUString &_rPath);
133cdf0e10cSrcweir             virtual ~ODriver();
134cdf0e10cSrcweir         public:
135cdf0e10cSrcweir             explicit ODriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
136cdf0e10cSrcweir 
137cdf0e10cSrcweir             // XInterface
138cdf0e10cSrcweir             static ::rtl::OUString getImplementationName_Static(  ) throw(::com::sun::star::uno::RuntimeException);
139cdf0e10cSrcweir             static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(  ) throw (::com::sun::star::uno::RuntimeException);
140cdf0e10cSrcweir         private:
141cdf0e10cSrcweir             DECLARE_SERVICE_INFO();
142cdf0e10cSrcweir 
143cdf0e10cSrcweir             virtual oslGenericFunction getOdbcFunction(sal_Int32 _nIndex)  const;
144cdf0e10cSrcweir             // OComponentHelper
145cdf0e10cSrcweir             virtual void SAL_CALL disposing(void);
146cdf0e10cSrcweir             virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
147cdf0e10cSrcweir             virtual void SAL_CALL acquire() throw();
148cdf0e10cSrcweir             virtual void SAL_CALL release() throw();
149cdf0e10cSrcweir 
150cdf0e10cSrcweir             // XDriver
151cdf0e10cSrcweir             ::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);
152cdf0e10cSrcweir             virtual sal_Bool SAL_CALL acceptsURL( const ::rtl::OUString& url ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
153cdf0e10cSrcweir             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);
154cdf0e10cSrcweir             virtual sal_Int32 SAL_CALL getMajorVersion(  ) throw(::com::sun::star::uno::RuntimeException);
155cdf0e10cSrcweir             virtual sal_Int32 SAL_CALL getMinorVersion(  ) throw(::com::sun::star::uno::RuntimeException);
156cdf0e10cSrcweir 
157cdf0e10cSrcweir             // XDataDefinitionSupplier
158cdf0e10cSrcweir             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);
159cdf0e10cSrcweir             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);
160cdf0e10cSrcweir 
161cdf0e10cSrcweir             // XCreateCatalog
162cdf0e10cSrcweir             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);
163cdf0e10cSrcweir             // XDropCatalog
164cdf0e10cSrcweir             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);
165cdf0e10cSrcweir             // XEventListener
166cdf0e10cSrcweir             virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
167cdf0e10cSrcweir         };
168cdf0e10cSrcweir     }
169cdf0e10cSrcweir 
170cdf0e10cSrcweir }
171cdf0e10cSrcweir #endif //_CONNECTIVITY_ADABAS_BDRIVER_HXX_
172