xref: /AOO41X/main/dbaccess/source/ext/adabas/AdabasNewDb.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef adabasui_ADABAS_CREATEDB_HXX
29*cdf0e10cSrcweir #include "AdabasNewDb.hxx"
30*cdf0e10cSrcweir #endif
31*cdf0e10cSrcweir #ifndef adabasui_ADABASNEWDB_HRC
32*cdf0e10cSrcweir #include "AdabasNewDb.hrc"
33*cdf0e10cSrcweir #endif
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #ifndef _VOS_PROCESS_HXX_
36*cdf0e10cSrcweir #include <vos/process.hxx>
37*cdf0e10cSrcweir #endif
38*cdf0e10cSrcweir #ifndef _OSL_PROCESS_H_
39*cdf0e10cSrcweir #include <osl/process.h>
40*cdf0e10cSrcweir #endif
41*cdf0e10cSrcweir #ifndef _MSGBOX_HXX //autogen
42*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
43*cdf0e10cSrcweir #endif
44*cdf0e10cSrcweir #ifndef _PASSWD_HXX //autogen
45*cdf0e10cSrcweir #include <sfx2/passwd.hxx>
46*cdf0e10cSrcweir #endif
47*cdf0e10cSrcweir #ifndef _URLOBJ_HXX
48*cdf0e10cSrcweir #include <tools/urlobj.hxx>
49*cdf0e10cSrcweir #endif
50*cdf0e10cSrcweir #ifndef _STREAM_HXX
51*cdf0e10cSrcweir #include <tools/stream.hxx>
52*cdf0e10cSrcweir #endif
53*cdf0e10cSrcweir #ifndef _BIGINT_HXX
54*cdf0e10cSrcweir #include <tools/bigint.hxx>
55*cdf0e10cSrcweir #endif
56*cdf0e10cSrcweir #ifndef _TOOLS_DEBUG_HXX
57*cdf0e10cSrcweir #include <tools/debug.hxx>
58*cdf0e10cSrcweir #endif
59*cdf0e10cSrcweir #ifndef _EXTENSIONS_COMPONENT_MODULE_HXX_
60*cdf0e10cSrcweir #include "Acomponentmodule.hxx"
61*cdf0e10cSrcweir #endif
62*cdf0e10cSrcweir #ifndef _UNOTOOLS_TEMPFILE_HXX
63*cdf0e10cSrcweir #include <unotools/tempfile.hxx>
64*cdf0e10cSrcweir #endif
65*cdf0e10cSrcweir #ifndef _ADABASUI_RESOURCE_HRC_
66*cdf0e10cSrcweir #include "adabasui_resource.hrc"
67*cdf0e10cSrcweir #endif
68*cdf0e10cSrcweir #ifndef _UCBHELPER_CONTENT_HXX
69*cdf0e10cSrcweir #include <ucbhelper/content.hxx>
70*cdf0e10cSrcweir #endif
71*cdf0e10cSrcweir #ifndef _SV_WAITOBJ_HXX
72*cdf0e10cSrcweir #include <vcl/waitobj.hxx>
73*cdf0e10cSrcweir #endif
74*cdf0e10cSrcweir #ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
75*cdf0e10cSrcweir #include <unotools/pathoptions.hxx>
76*cdf0e10cSrcweir #endif
77*cdf0e10cSrcweir #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
78*cdf0e10cSrcweir #include <toolkit/unohlp.hxx>
79*cdf0e10cSrcweir #endif
80*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
81*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
82*cdf0e10cSrcweir #endif
83*cdf0e10cSrcweir #ifndef _COMPHELPER_EXTRACT_HXX_
84*cdf0e10cSrcweir #include <comphelper/extract.hxx>
85*cdf0e10cSrcweir #endif
86*cdf0e10cSrcweir #ifndef _UNOTOOLS_TEMPFILE_HXX
87*cdf0e10cSrcweir #include <unotools/tempfile.hxx>
88*cdf0e10cSrcweir #endif
89*cdf0e10cSrcweir #ifndef _UNOTOOLS_LOCALFILEHELPER_HXX
90*cdf0e10cSrcweir #include <unotools/localfilehelper.hxx>
91*cdf0e10cSrcweir #endif
92*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_SQLEXCEPTION_HPP_
93*cdf0e10cSrcweir #include <com/sun/star/sdbc/SQLException.hpp>
94*cdf0e10cSrcweir #endif
95*cdf0e10cSrcweir #ifndef _UNOTOOLS_UCBHELPER_HXX
96*cdf0e10cSrcweir #include <unotools/ucbhelper.hxx>
97*cdf0e10cSrcweir #endif
98*cdf0e10cSrcweir #ifndef _CONNECTIVITY_DBTOOLS_HXX_
99*cdf0e10cSrcweir #include <connectivity/dbtools.hxx>
100*cdf0e10cSrcweir #endif
101*cdf0e10cSrcweir #ifndef _DBHELPER_DBEXCEPTION_HXX_
102*cdf0e10cSrcweir #include <connectivity/dbexception.hxx>
103*cdf0e10cSrcweir #endif
104*cdf0e10cSrcweir #include "adabasuistrings.hrc"
105*cdf0e10cSrcweir #ifndef _THREAD_HXX_
106*cdf0e10cSrcweir #include <osl/thread.hxx>
107*cdf0e10cSrcweir #endif
108*cdf0e10cSrcweir #ifndef _OSL_FILE_HXX_
109*cdf0e10cSrcweir #include <osl/file.hxx>
110*cdf0e10cSrcweir #endif
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir using namespace adabasui;
114*cdf0e10cSrcweir using namespace ucbhelper;
115*cdf0e10cSrcweir using namespace utl;
116*cdf0e10cSrcweir using namespace vos;
117*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
118*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
119*cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx;
120*cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
121*cdf0e10cSrcweir using namespace ::com::sun::star::ucb;
122*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
123*cdf0e10cSrcweir namespace adabasui
124*cdf0e10cSrcweir {
125*cdf0e10cSrcweir 	class ODatabaseCreator : public ::osl::Thread
126*cdf0e10cSrcweir 	{
127*cdf0e10cSrcweir 		Link								m_aTerminateHandler;
128*cdf0e10cSrcweir 		Sequence< PropertyValue>			m_aValues;
129*cdf0e10cSrcweir 		Reference<XCreateCatalog>			m_xCreateCatalog;
130*cdf0e10cSrcweir 		Reference< XMultiServiceFactory >	m_xORB;
131*cdf0e10cSrcweir 		Window*								m_pErrorWindow;
132*cdf0e10cSrcweir 	public:
133*cdf0e10cSrcweir 		ODatabaseCreator(const Reference<XCreateCatalog>& _rxCreateCatalog
134*cdf0e10cSrcweir 						,Window* _pErrorWindow
135*cdf0e10cSrcweir 						,const Reference< XMultiServiceFactory >& _xORB
136*cdf0e10cSrcweir 						,const Sequence< PropertyValue>& _rValues)
137*cdf0e10cSrcweir             : m_aValues(_rValues)
138*cdf0e10cSrcweir 			, m_xCreateCatalog(_rxCreateCatalog)
139*cdf0e10cSrcweir 			, m_xORB(_xORB)
140*cdf0e10cSrcweir 			, m_pErrorWindow(_pErrorWindow)
141*cdf0e10cSrcweir 		{}
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 		void setTerminateHandler(const Link& _aTerminateHandler) { m_aTerminateHandler = _aTerminateHandler; }
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir 	protected:
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 		/// Working method which should be overridden.
148*cdf0e10cSrcweir 		virtual void SAL_CALL run();
149*cdf0e10cSrcweir 		virtual void SAL_CALL onTerminated();
150*cdf0e10cSrcweir 	};
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir 	void SAL_CALL ODatabaseCreator::run()
153*cdf0e10cSrcweir 	{
154*cdf0e10cSrcweir 		try
155*cdf0e10cSrcweir 		{
156*cdf0e10cSrcweir 			m_xCreateCatalog->createCatalog(m_aValues);
157*cdf0e10cSrcweir 		}
158*cdf0e10cSrcweir 		catch(SQLException& e)
159*cdf0e10cSrcweir 		{
160*cdf0e10cSrcweir 			::dbtools::showError(::dbtools::SQLExceptionInfo(e),VCLUnoHelper::GetInterface(m_pErrorWindow),m_xORB);
161*cdf0e10cSrcweir 		}
162*cdf0e10cSrcweir 		catch(Exception&)
163*cdf0e10cSrcweir 		{
164*cdf0e10cSrcweir 			OSL_ASSERT(0);
165*cdf0e10cSrcweir 			//	showError(::dbtools::SQLExceptionInfo(e),this,);
166*cdf0e10cSrcweir 		}
167*cdf0e10cSrcweir 	}
168*cdf0e10cSrcweir 	void SAL_CALL ODatabaseCreator::onTerminated()
169*cdf0e10cSrcweir 	{
170*cdf0e10cSrcweir 		if ( m_aTerminateHandler.IsSet() )
171*cdf0e10cSrcweir 			m_aTerminateHandler.Call(NULL);
172*cdf0e10cSrcweir 	}
173*cdf0e10cSrcweir }
174*cdf0e10cSrcweir DBG_NAME( OAdabasNewDbDlg )
175*cdf0e10cSrcweir //========================================================================
176*cdf0e10cSrcweir OAdabasNewDbDlg::OAdabasNewDbDlg( Window* pParent,
177*cdf0e10cSrcweir 								 const Reference<XCreateCatalog>& _rxCreateCatalog,
178*cdf0e10cSrcweir 								 const Reference< XMultiServiceFactory >&	_rxORB,
179*cdf0e10cSrcweir 								 sal_Bool _bRestore)
180*cdf0e10cSrcweir     :ModalDialog( pParent, ModuleRes( DLG_ADABAS_NEWDB ))
181*cdf0e10cSrcweir     ,m_FT_DATABASENAME(         this, ModuleRes( FT_DATABASENAME        ) )
182*cdf0e10cSrcweir     ,m_ET_DATABASENAME(         this, ModuleRes( ET_DATABASENAME        ) )
183*cdf0e10cSrcweir     ,m_FL_USER(                 this, ModuleRes( FL_USER                ) )
184*cdf0e10cSrcweir     ,m_FT_SYSUSR(               this, ModuleRes( FT_SYSUSR              ) )
185*cdf0e10cSrcweir     ,m_FT_CONUSR(               this, ModuleRes( FT_CONUSR              ) )
186*cdf0e10cSrcweir     ,m_FT_DOMAIN_USR(           this, ModuleRes( FT_DOMAIN_USR          ) )
187*cdf0e10cSrcweir     ,m_ET_SYSUSR(               this, ModuleRes( ET_SYSUSR              ) )
188*cdf0e10cSrcweir     ,m_PB_SYSPWD(               this, ModuleRes( PB_SYSPWD              ) )
189*cdf0e10cSrcweir     ,m_ET_CONUSR(               this, ModuleRes( ET_CONUSR              ) )
190*cdf0e10cSrcweir     ,m_PB_CONPWD(               this, ModuleRes( PB_CONPWD              ) )
191*cdf0e10cSrcweir     ,m_ET_DOMAIN_USR(           this, ModuleRes( ET_DOMAIN_USR          ) )
192*cdf0e10cSrcweir     ,m_PB_DOMAINPWD(            this, ModuleRes( PB_DOMAINPWD           ) )
193*cdf0e10cSrcweir     ,m_BMP_CON(                 this, ModuleRes( BMP_CON                ) )
194*cdf0e10cSrcweir     ,m_BMP_SYS(                 this, ModuleRes( BMP_SYS                ) )
195*cdf0e10cSrcweir     ,m_BMP_DOMAIN(              this, ModuleRes( BMP_DOMAIN             ) )
196*cdf0e10cSrcweir     ,m_FT_RESTORE(              this, ModuleRes( FT_RESTORE             ) )
197*cdf0e10cSrcweir     ,m_ET_RESTORE(              this, ModuleRes( ET_RESTORE             ) )
198*cdf0e10cSrcweir     ,m_PB_RESTORE(              this, ModuleRes( PB_RESTORE             ) )
199*cdf0e10cSrcweir     ,m_FL_DBSETTINGS(           this, ModuleRes( FL_DBSETTINGS          ) )
200*cdf0e10cSrcweir     ,m_FT_SYSDEVSPACE(          this, ModuleRes( FT_SYSDEVSPACE         ) )
201*cdf0e10cSrcweir     ,m_FT_TRANSACTIONLOG(       this, ModuleRes( FT_TRANSACTIONLOG      ) )
202*cdf0e10cSrcweir     ,m_FT_DATADEVSPACE(         this, ModuleRes( FT_DATADEVSPACE        ) )
203*cdf0e10cSrcweir     ,m_ET_SYSDEVSPACE(          this, ModuleRes( ET_SYSDEVSPACE         ) )
204*cdf0e10cSrcweir     ,m_PB_SYSDEVSPACE(          this, ModuleRes( PB_SYSDEVSPACE         ) )
205*cdf0e10cSrcweir     ,m_ET_TRANSACTIONLOG(       this, ModuleRes( ET_TRANSACTIONLOG      ) )
206*cdf0e10cSrcweir     ,m_PB_TRANSACTIONLOG(       this, ModuleRes( PB_TRANSACTIONLOG      ) )
207*cdf0e10cSrcweir     ,m_ET_DATADEVSPACE(         this, ModuleRes( ET_DATADEVSPACE        ) )
208*cdf0e10cSrcweir     ,m_PB_DATADEVSPACE(         this, ModuleRes( PB_DATADEVSPACE        ) )
209*cdf0e10cSrcweir     ,m_FT_TRANSACTIONLOG_SIZE(  this, ModuleRes( FT_TRANSACTIONLOG_SIZE ) )
210*cdf0e10cSrcweir     ,m_NF_TRANSACTIONLOG_SIZE(  this, ModuleRes( NF_TRANSACTIONLOG_SIZE ) )
211*cdf0e10cSrcweir     ,m_FT_DATADEVSPACE_SIZE(    this, ModuleRes( FT_DATADEVSPACE_SIZE   ) )
212*cdf0e10cSrcweir     ,m_NF_DATADEVSPACE_SIZE(    this, ModuleRes( NF_DATADEVSPACE_SIZE   ) )
213*cdf0e10cSrcweir     ,m_FT_CACHE_SIZE(           this, ModuleRes( FT_CACHE_SIZE          ) )
214*cdf0e10cSrcweir     ,m_NF_CACHE_SIZE(           this, ModuleRes( NF_CACHE_SIZE          ) )
215*cdf0e10cSrcweir     ,m_FL_END(                  this, ModuleRes( FL_END                 ) )
216*cdf0e10cSrcweir     ,m_PB_OK(                   this, ModuleRes( PB_OK                  ) )
217*cdf0e10cSrcweir     ,m_PB_CANCEL(               this, ModuleRes( PB_CANCEL              ) )
218*cdf0e10cSrcweir     ,m_xCreateCatalog(_rxCreateCatalog)
219*cdf0e10cSrcweir     ,m_xORB(_rxORB)
220*cdf0e10cSrcweir     ,m_bRestore(_bRestore)
221*cdf0e10cSrcweir     ,m_nSetBitmap(0)
222*cdf0e10cSrcweir {
223*cdf0e10cSrcweir 	DBG_CTOR( OAdabasNewDbDlg, NULL );
224*cdf0e10cSrcweir 	FreeResource();
225*cdf0e10cSrcweir 	if(m_bRestore)
226*cdf0e10cSrcweir 	{
227*cdf0e10cSrcweir         m_FL_DBSETTINGS.SetPosPixel(m_FL_DBSETTINGS.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
228*cdf0e10cSrcweir 		m_FT_SYSDEVSPACE.SetPosPixel(m_FT_SYSDEVSPACE.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
229*cdf0e10cSrcweir 		m_FT_TRANSACTIONLOG.SetPosPixel(m_FT_TRANSACTIONLOG.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
230*cdf0e10cSrcweir 		m_FT_DATADEVSPACE.SetPosPixel(m_FT_DATADEVSPACE.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
231*cdf0e10cSrcweir 		m_ET_SYSDEVSPACE.SetPosPixel(m_ET_SYSDEVSPACE.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
232*cdf0e10cSrcweir 		m_PB_SYSDEVSPACE.SetPosPixel(m_PB_SYSDEVSPACE.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
233*cdf0e10cSrcweir 		m_ET_TRANSACTIONLOG.SetPosPixel(m_ET_TRANSACTIONLOG.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
234*cdf0e10cSrcweir 		m_PB_TRANSACTIONLOG.SetPosPixel(m_PB_TRANSACTIONLOG.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
235*cdf0e10cSrcweir 		m_ET_DATADEVSPACE.SetPosPixel(m_ET_DATADEVSPACE.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
236*cdf0e10cSrcweir 		m_PB_DATADEVSPACE.SetPosPixel(m_PB_DATADEVSPACE.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
237*cdf0e10cSrcweir 		m_FT_TRANSACTIONLOG_SIZE.SetPosPixel(m_FT_TRANSACTIONLOG_SIZE.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
238*cdf0e10cSrcweir 		m_NF_TRANSACTIONLOG_SIZE.SetPosPixel(m_NF_TRANSACTIONLOG_SIZE.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
239*cdf0e10cSrcweir 		m_FT_DATADEVSPACE_SIZE.SetPosPixel(m_FT_DATADEVSPACE_SIZE.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
240*cdf0e10cSrcweir 		m_NF_DATADEVSPACE_SIZE.SetPosPixel(m_NF_DATADEVSPACE_SIZE.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
241*cdf0e10cSrcweir 		m_FT_CACHE_SIZE.SetPosPixel(m_FT_CACHE_SIZE.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
242*cdf0e10cSrcweir 		m_NF_CACHE_SIZE.SetPosPixel(m_NF_CACHE_SIZE.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
243*cdf0e10cSrcweir 		m_PB_OK.SetPosPixel(m_PB_OK.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
244*cdf0e10cSrcweir 		m_PB_CANCEL.SetPosPixel(m_PB_CANCEL.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT ));
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir 		Size aSize(GetSizePixel().Width(),GetSizePixel().Height()-LogicToPixel( Size(0,14), MAP_APPFONT ).Height());
247*cdf0e10cSrcweir 		SetSizePixel(aSize);
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir 		m_FT_SYSUSR.Hide();
250*cdf0e10cSrcweir 		m_FT_DOMAIN_USR.Hide();
251*cdf0e10cSrcweir         m_FL_USER.SetText(ModuleRes(STR_BACKUPFILE_LOAD));
252*cdf0e10cSrcweir 		m_PB_SYSPWD.Hide();
253*cdf0e10cSrcweir 		m_PB_DOMAINPWD.Hide();
254*cdf0e10cSrcweir 		m_ET_SYSUSR.Hide();
255*cdf0e10cSrcweir 		m_ET_DOMAIN_USR.Hide();
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir 		m_ET_SYSUSR.SetText(String::CreateFromAscii("DUMMY"));
258*cdf0e10cSrcweir 		m_BMP_SYS.Hide();
259*cdf0e10cSrcweir 		m_BMP_DOMAIN.Hide();
260*cdf0e10cSrcweir 		m_ET_RESTORE.SetModifyHdl(				LINK(this,OAdabasNewDbDlg,LoseFocusHdl));
261*cdf0e10cSrcweir 		m_ET_RESTORE.SetLoseFocusHdl(			LINK(this,OAdabasNewDbDlg,LoseFocusHdl));
262*cdf0e10cSrcweir 		m_ET_RESTORE.SetMaxTextLen(40);
263*cdf0e10cSrcweir 	}
264*cdf0e10cSrcweir 	else
265*cdf0e10cSrcweir 	{
266*cdf0e10cSrcweir 		m_FT_RESTORE.Hide();
267*cdf0e10cSrcweir 		m_ET_RESTORE.Hide();
268*cdf0e10cSrcweir 		m_PB_RESTORE.Hide();
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir 		m_ET_SYSUSR.SetModifyHdl(				LINK(this,OAdabasNewDbDlg,LoseFocusHdl));
271*cdf0e10cSrcweir 		m_ET_CONUSR.SetModifyHdl(				LINK(this,OAdabasNewDbDlg,LoseFocusHdl));
272*cdf0e10cSrcweir 		m_ET_DOMAIN_USR.Enable(sal_False);
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir 		//	m_ET_SYSUSR.setUpperCase();
275*cdf0e10cSrcweir 		//	m_ET_CONUSR.setUpperCase();
276*cdf0e10cSrcweir 	}
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir 	m_ET_SYSDEVSPACE.SetLoseFocusHdl(		LINK(this,OAdabasNewDbDlg,LoseFocusHdl));
280*cdf0e10cSrcweir 	m_ET_TRANSACTIONLOG.SetLoseFocusHdl(	LINK(this,OAdabasNewDbDlg,LoseFocusHdl));
281*cdf0e10cSrcweir 	m_ET_DATADEVSPACE.SetLoseFocusHdl(		LINK(this,OAdabasNewDbDlg,LoseFocusHdl));
282*cdf0e10cSrcweir 
283*cdf0e10cSrcweir 	m_ET_SYSDEVSPACE.SetMaxTextLen(40);
284*cdf0e10cSrcweir 	m_ET_TRANSACTIONLOG.SetMaxTextLen(40);
285*cdf0e10cSrcweir 	m_ET_DATADEVSPACE.SetMaxTextLen(40);
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir 	m_NF_TRANSACTIONLOG_SIZE.SetModifyHdl(	LINK(this,OAdabasNewDbDlg,LoseFocusHdl));
288*cdf0e10cSrcweir 	m_NF_DATADEVSPACE_SIZE.SetModifyHdl(	LINK(this,OAdabasNewDbDlg,LoseFocusHdl));
289*cdf0e10cSrcweir 	m_NF_CACHE_SIZE.SetModifyHdl(			LINK(this,OAdabasNewDbDlg,LoseFocusHdl));
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir 	m_NF_TRANSACTIONLOG_SIZE.SetMin(10);
292*cdf0e10cSrcweir 	m_NF_DATADEVSPACE_SIZE.SetMin(10);
293*cdf0e10cSrcweir 	m_NF_CACHE_SIZE.SetMin(4);
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir 	m_NF_TRANSACTIONLOG_SIZE.SetMax(LONG_MAX);
296*cdf0e10cSrcweir 	m_NF_DATADEVSPACE_SIZE.SetMax(LONG_MAX);
297*cdf0e10cSrcweir 	m_NF_CACHE_SIZE.SetMax(LONG_MAX);
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir 	m_NF_TRANSACTIONLOG_SIZE.SetValue(20);
300*cdf0e10cSrcweir 	m_NF_DATADEVSPACE_SIZE.SetValue(20);
301*cdf0e10cSrcweir 	m_NF_CACHE_SIZE.SetValue(4);
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir 	m_NF_TRANSACTIONLOG_SIZE.SetDecimalDigits(0);
304*cdf0e10cSrcweir 	m_NF_DATADEVSPACE_SIZE.SetDecimalDigits(0);
305*cdf0e10cSrcweir 	m_NF_CACHE_SIZE.SetDecimalDigits(0);
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir 	m_ET_DATABASENAME.SetMaxTextLen( 8 ); //98292
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir 	m_PB_CONPWD.SetClickHdl(			LINK(this,OAdabasNewDbDlg,PwdClickHdl));
310*cdf0e10cSrcweir 	m_PB_SYSPWD.SetClickHdl(			LINK(this,OAdabasNewDbDlg,PwdClickHdl));
311*cdf0e10cSrcweir 	m_PB_DOMAINPWD.SetClickHdl(			LINK(this,OAdabasNewDbDlg,PwdClickHdl));
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir 	m_PB_RESTORE.SetClickHdl(			LINK(this,OAdabasNewDbDlg,LoadButtonClickHdl));
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir 	m_PB_SYSDEVSPACE.SetClickHdl(		LINK(this,OAdabasNewDbDlg,ButtonClickHdl));
316*cdf0e10cSrcweir 	m_PB_TRANSACTIONLOG.SetClickHdl(	LINK(this,OAdabasNewDbDlg,ButtonClickHdl));
317*cdf0e10cSrcweir 	m_PB_DATADEVSPACE.SetClickHdl(		LINK(this,OAdabasNewDbDlg,ButtonClickHdl));
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir 	m_BMP_CON.SetImage(		ModuleRes(UNCHECK_RED) );
320*cdf0e10cSrcweir 	m_BMP_SYS.SetImage(		ModuleRes(UNCHECK_RED) );
321*cdf0e10cSrcweir 	m_BMP_DOMAIN.SetImage(	ModuleRes(UNCHECK_RED) );
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir 	static String s_sRoot(RTL_CONSTASCII_USTRINGPARAM("DBROOT"));
324*cdf0e10cSrcweir 	static String s_sConfig(RTL_CONSTASCII_USTRINGPARAM("DBCONFIG"));
325*cdf0e10cSrcweir 	static String s_sWork(RTL_CONSTASCII_USTRINGPARAM("DBWORK"));
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir 	sal_Bool bError = fillEnvironmentVariable(s_sWork,m_sDbWork);
328*cdf0e10cSrcweir 	if ( bError || !m_sDbWork.Len() )
329*cdf0e10cSrcweir 		bError = fillEnvironmentVariable(s_sRoot,m_sDbWork);
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir     bError = fillEnvironmentVariable(s_sConfig,m_sDbConfig);
332*cdf0e10cSrcweir 	if ( bError || !m_sDbConfig.Len() )
333*cdf0e10cSrcweir 		bError = fillEnvironmentVariable(s_sRoot,m_sDbConfig);
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir 	if ( m_sDbConfig.Len() && m_sDbWork.Len() )
336*cdf0e10cSrcweir 	{
337*cdf0e10cSrcweir 		m_sDbConfig.AppendAscii("/");
338*cdf0e10cSrcweir 		m_sDbWork.AppendAscii("/");
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir 		String sDefaultName,sExt;
341*cdf0e10cSrcweir 		sDefaultName.AssignAscii("MYDB");
342*cdf0e10cSrcweir 		String sConfig = m_sDbConfig;
343*cdf0e10cSrcweir 		sConfig.AppendAscii("config");
344*cdf0e10cSrcweir 		TempFile aDefaultDatabase(sDefaultName,&sExt,&sConfig);
345*cdf0e10cSrcweir 		aDefaultDatabase.EnableKillingFile();
346*cdf0e10cSrcweir 		INetURLObject aURL(aDefaultDatabase.GetURL());
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir 		m_ET_DATABASENAME.SetText(aURL.GetName());
349*cdf0e10cSrcweir 		m_DBName = m_ET_DATABASENAME.GetText();
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir 		// create temp names for my files
352*cdf0e10cSrcweir 		// here we need only a name the creation is done by the driver
353*cdf0e10cSrcweir 		// so we delete the files after we get a valid name
354*cdf0e10cSrcweir 		// with this we avoiding to mention anything when the user presses cancel
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir 		String aSysExt;
357*cdf0e10cSrcweir 		sal_Bool bValid = sal_True;
358*cdf0e10cSrcweir 		{
359*cdf0e10cSrcweir 			aSysExt.AssignAscii(".sys");
360*cdf0e10cSrcweir 			::utl::TempFile aTmpFile(m_ET_DATABASENAME.GetText(),&aSysExt,&m_sDbWork);
361*cdf0e10cSrcweir 			aTmpFile.EnableKillingFile();
362*cdf0e10cSrcweir 			bValid = aTmpFile.IsValid();
363*cdf0e10cSrcweir 			if(bValid)
364*cdf0e10cSrcweir 				LocalFileHelper::ConvertURLToPhysicalName(aTmpFile.GetURL(),m_SYSDEV_File);
365*cdf0e10cSrcweir 		}
366*cdf0e10cSrcweir 		{
367*cdf0e10cSrcweir 			aSysExt.AssignAscii(".trs");
368*cdf0e10cSrcweir 			::utl::TempFile aTmpFile(m_ET_DATABASENAME.GetText(),&aSysExt,&m_sDbWork);
369*cdf0e10cSrcweir 			aTmpFile.EnableKillingFile();
370*cdf0e10cSrcweir 			bValid = !bValid || aTmpFile.IsValid();
371*cdf0e10cSrcweir 			if(aTmpFile.IsValid())
372*cdf0e10cSrcweir 				LocalFileHelper::ConvertURLToPhysicalName(aTmpFile.GetURL(),m_TRANSDEV_File);
373*cdf0e10cSrcweir 		}
374*cdf0e10cSrcweir 		{
375*cdf0e10cSrcweir 			aSysExt.AssignAscii(".dat");
376*cdf0e10cSrcweir 			::utl::TempFile aTmpFile(m_ET_DATABASENAME.GetText(),&aSysExt,&m_sDbWork);
377*cdf0e10cSrcweir 			aTmpFile.EnableKillingFile();
378*cdf0e10cSrcweir 			bValid = !bValid || aTmpFile.IsValid();
379*cdf0e10cSrcweir 			if(aTmpFile.IsValid())
380*cdf0e10cSrcweir 				LocalFileHelper::ConvertURLToPhysicalName(aTmpFile.GetURL(),m_DATADEV_File);
381*cdf0e10cSrcweir 		}
382*cdf0e10cSrcweir 		if(!bValid) // we found a file which isn't valid so we report an error message
383*cdf0e10cSrcweir 			PostUserEvent(LINK(this, OAdabasNewDbDlg, OnNoAccessRights));
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir 	}
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir 	if(m_SYSDEV_File.Len() < 41 && m_TRANSDEV_File.Len() < 41 && m_DATADEV_File.Len() < 41)
388*cdf0e10cSrcweir 	{
389*cdf0e10cSrcweir 		m_ET_SYSDEVSPACE.SetText(m_SYSDEV_File );
390*cdf0e10cSrcweir 		m_ET_TRANSACTIONLOG.SetText(m_TRANSDEV_File);
391*cdf0e10cSrcweir 		m_ET_DATADEVSPACE.SetText(m_DATADEV_File);
392*cdf0e10cSrcweir 	}
393*cdf0e10cSrcweir 	else
394*cdf0e10cSrcweir 	{
395*cdf0e10cSrcweir 		m_SYSDEV_File = m_TRANSDEV_File = m_DATADEV_File = String();
396*cdf0e10cSrcweir 		PostUserEvent(LINK(this, OAdabasNewDbDlg, OnNoDefaultPath));
397*cdf0e10cSrcweir 	}
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir 	m_ET_CONUSR.SetText(String::CreateFromAscii("CONTROL"));
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir 	m_PB_OK.SetClickHdl(LINK(this,OAdabasNewDbDlg,ImplOKHdl));
402*cdf0e10cSrcweir 	m_PB_OK.Enable(sal_False);
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir 	m_ET_DATABASENAME.SetModifyHdl(	LINK(this,OAdabasNewDbDlg,LoseFocusHdl));
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir }
407*cdf0e10cSrcweir // -----------------------------------------------------------------------
408*cdf0e10cSrcweir OAdabasNewDbDlg::~OAdabasNewDbDlg()
409*cdf0e10cSrcweir {
410*cdf0e10cSrcweir 	DBG_DTOR( OAdabasNewDbDlg, NULL );
411*cdf0e10cSrcweir }
412*cdf0e10cSrcweir //------------------------------------------------------------------
413*cdf0e10cSrcweir IMPL_LINK(OAdabasNewDbDlg, OnError, void*, /*_pArg*/)
414*cdf0e10cSrcweir {
415*cdf0e10cSrcweir 	String sErrorMsg(ModuleRes(STR_ERROR_IN_ADABAS_INSTALLATION));
416*cdf0e10cSrcweir 	ErrorBox(this, WB_OK, sErrorMsg).Execute();
417*cdf0e10cSrcweir 	EndDialog(RET_CANCEL);
418*cdf0e10cSrcweir 	return 0L;
419*cdf0e10cSrcweir }
420*cdf0e10cSrcweir //------------------------------------------------------------------
421*cdf0e10cSrcweir IMPL_LINK(OAdabasNewDbDlg, OnNoDefaultPath, void*, /*_pArg*/)
422*cdf0e10cSrcweir {
423*cdf0e10cSrcweir 	String sErrorMsg(ModuleRes(STR_ADABAS_NO_DEFAULTNAME));
424*cdf0e10cSrcweir 	ErrorBox(this, WB_OK, sErrorMsg).Execute();
425*cdf0e10cSrcweir 	return 0L;
426*cdf0e10cSrcweir }
427*cdf0e10cSrcweir //------------------------------------------------------------------
428*cdf0e10cSrcweir IMPL_LINK(OAdabasNewDbDlg, OnNoAccessRights, void*, /*_pArg*/)
429*cdf0e10cSrcweir {
430*cdf0e10cSrcweir 	String sErrorMsg(ModuleRes(STR_ADABAS_NO_ACCESSRIGHTS));
431*cdf0e10cSrcweir 	ErrorBox(this, WB_OK, sErrorMsg).Execute();
432*cdf0e10cSrcweir 	return 0L;
433*cdf0e10cSrcweir }
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir // -----------------------------------------------------------------------
436*cdf0e10cSrcweir IMPL_LINK( OAdabasNewDbDlg, ImplOKHdl, OKButton*, /*EMPTYARG*/ )
437*cdf0e10cSrcweir {
438*cdf0e10cSrcweir 	m_SYSDEV_File 	= m_ET_SYSDEVSPACE.GetText();
439*cdf0e10cSrcweir 	m_TRANSDEV_File = m_ET_TRANSACTIONLOG.GetText();
440*cdf0e10cSrcweir 	m_DATADEV_File	= m_ET_DATADEVSPACE.GetText();
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir 	m_Backup_File	= m_ET_RESTORE.GetText();
443*cdf0e10cSrcweir 	if(m_bRestore)
444*cdf0e10cSrcweir 	{
445*cdf0e10cSrcweir 		INetURLObject aURL;
446*cdf0e10cSrcweir 		aURL.SetSmartProtocol(INET_PROT_FILE);
447*cdf0e10cSrcweir 		aURL.SetURL(m_Backup_File);
448*cdf0e10cSrcweir 		Content aContent(aURL.GetURLNoPass(),Reference<XCommandEnvironment>());
449*cdf0e10cSrcweir 		try
450*cdf0e10cSrcweir 		{
451*cdf0e10cSrcweir 			if(!aContent.isDocument())
452*cdf0e10cSrcweir 			{
453*cdf0e10cSrcweir 				String aString1 = String(ModuleRes(STR_ADABAS_NO_BACKUP_FILE));
454*cdf0e10cSrcweir 				String aString2 = String(ModuleRes(STR_STAT_WARNING));
455*cdf0e10cSrcweir 				SQLException aSql(aString1,NULL,aString2,1000,Any());
456*cdf0e10cSrcweir 				return 0;
457*cdf0e10cSrcweir 			}
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir 		}
460*cdf0e10cSrcweir 		catch(Exception&)
461*cdf0e10cSrcweir 		{
462*cdf0e10cSrcweir 			String aString1 = String(ModuleRes(STR_ADABAS_NO_BACKUP_FILE));
463*cdf0e10cSrcweir 			String aString2 = String(ModuleRes(STR_STAT_WARNING));
464*cdf0e10cSrcweir 			SQLException aSql(aString1,NULL,aString2,1000,Any());
465*cdf0e10cSrcweir 			throw aSql;
466*cdf0e10cSrcweir 		}
467*cdf0e10cSrcweir 		if(m_Backup_File.Len() > 40)
468*cdf0e10cSrcweir 		{
469*cdf0e10cSrcweir 			InfoBox aInfo(this,ModuleRes(INFO_STR_MAX_FILE_LENGTH));
470*cdf0e10cSrcweir 			String aMsg(aInfo.GetMessText());
471*cdf0e10cSrcweir 			aMsg.SearchAndReplace(String::CreateFromAscii("\'#\'"),String::CreateFromAscii("40"));
472*cdf0e10cSrcweir 			aInfo.SetMessText(aMsg);
473*cdf0e10cSrcweir 			aInfo.Execute();
474*cdf0e10cSrcweir 			return 0;
475*cdf0e10cSrcweir 		}
476*cdf0e10cSrcweir 	}
477*cdf0e10cSrcweir 	else if(m_SYSDEV_File.Len() > 40 || m_TRANSDEV_File.Len() > 40 || m_DATADEV_File.Len() > 40)
478*cdf0e10cSrcweir 	{
479*cdf0e10cSrcweir 		InfoBox aInfo(this,ModuleRes(INFO_STR_MAX_FILE_LENGTH));
480*cdf0e10cSrcweir 		String aMsg(aInfo.GetMessText());
481*cdf0e10cSrcweir 		aMsg.SearchAndReplace(String::CreateFromAscii("\'#\'"),String::CreateFromAscii("40"));
482*cdf0e10cSrcweir 		aInfo.SetMessText(aMsg);
483*cdf0e10cSrcweir 		aInfo.Execute();
484*cdf0e10cSrcweir 		return 0;
485*cdf0e10cSrcweir 	}
486*cdf0e10cSrcweir 
487*cdf0e10cSrcweir 
488*cdf0e10cSrcweir 	sal_Bool bOk = sal_False;
489*cdf0e10cSrcweir 
490*cdf0e10cSrcweir 	{
491*cdf0e10cSrcweir 		// we need url
492*cdf0e10cSrcweir 		String sTemp;
493*cdf0e10cSrcweir 		bOk = LocalFileHelper::ConvertPhysicalNameToURL(m_DATADEV_File,sTemp);
494*cdf0e10cSrcweir 		m_DATADEV_File = sTemp;
495*cdf0e10cSrcweir 		sTemp = String();
496*cdf0e10cSrcweir 		bOk = LocalFileHelper::ConvertPhysicalNameToURL(m_SYSDEV_File,sTemp);
497*cdf0e10cSrcweir 		m_SYSDEV_File = sTemp;
498*cdf0e10cSrcweir 		sTemp = String();
499*cdf0e10cSrcweir 		bOk = LocalFileHelper::ConvertPhysicalNameToURL(m_TRANSDEV_File,sTemp);
500*cdf0e10cSrcweir 		m_TRANSDEV_File = sTemp;
501*cdf0e10cSrcweir 	}
502*cdf0e10cSrcweir 	String aErrorMessage = String(ModuleRes(STR_DEVSPACE_NO_FILE));
503*cdf0e10cSrcweir 	if(!m_SYSDEV_File.Len())
504*cdf0e10cSrcweir 		aErrorMessage.SearchAndReplace(String::CreateFromAscii("$name$"),String::CreateFromAscii("SYSDEVSPACE"));
505*cdf0e10cSrcweir 	else if(!m_TRANSDEV_File.Len())
506*cdf0e10cSrcweir 		aErrorMessage.SearchAndReplace(String::CreateFromAscii("$name$"),String::CreateFromAscii("TRANSACTIONLOG"));
507*cdf0e10cSrcweir 	else if(!m_DATADEV_File.Len())
508*cdf0e10cSrcweir 		aErrorMessage.SearchAndReplace(String::CreateFromAscii("$name$"),String::CreateFromAscii("DATDEVSPACE"));
509*cdf0e10cSrcweir 	else if(m_ET_SYSUSR.GetText() == m_ET_CONUSR.GetText())
510*cdf0e10cSrcweir 		aErrorMessage = String(ModuleRes(STR_NO_SAME_USER));
511*cdf0e10cSrcweir 	else
512*cdf0e10cSrcweir 		bOk = sal_True;
513*cdf0e10cSrcweir 
514*cdf0e10cSrcweir 
515*cdf0e10cSrcweir 	if (!bOk)
516*cdf0e10cSrcweir 	{
517*cdf0e10cSrcweir 		ErrorBox(this, WB_OK, aErrorMessage).Execute();
518*cdf0e10cSrcweir 		return sal_False;
519*cdf0e10cSrcweir 	}
520*cdf0e10cSrcweir 
521*cdf0e10cSrcweir 	sal_Int32 nPos = 0;
522*cdf0e10cSrcweir 	Sequence< PropertyValue> aCreateArgs(m_bRestore ? 14 : 12);
523*cdf0e10cSrcweir 	aCreateArgs[nPos].Name		= PROPERTY_CONTROL_USER;
524*cdf0e10cSrcweir 	aCreateArgs[nPos++].Value  <<= ::rtl::OUString(m_ET_CONUSR.GetText().ToUpperAscii());
525*cdf0e10cSrcweir 	aCreateArgs[nPos].Name		= PROPERTY_CONTROL_PASSWORD;
526*cdf0e10cSrcweir 	aCreateArgs[nPos++].Value  <<= ::rtl::OUString(m_ConPwd);
527*cdf0e10cSrcweir 	aCreateArgs[nPos].Name		= PROPERTY_USER;
528*cdf0e10cSrcweir 	aCreateArgs[nPos++].Value  <<= ::rtl::OUString(m_ET_SYSUSR.GetText().ToUpperAscii());
529*cdf0e10cSrcweir 	aCreateArgs[nPos].Name		= PROPERTY_PASSWORD;
530*cdf0e10cSrcweir 	aCreateArgs[nPos++].Value  <<= ::rtl::OUString(m_SysPwd);
531*cdf0e10cSrcweir 	aCreateArgs[nPos].Name		= PROPERTY_DOMAINPASSWORD;
532*cdf0e10cSrcweir 	aCreateArgs[nPos++].Value  <<= ::rtl::OUString(m_DomainPwd);
533*cdf0e10cSrcweir 	aCreateArgs[nPos].Name		= PROPERTY_CACHESIZE;
534*cdf0e10cSrcweir 	aCreateArgs[nPos++].Value  <<= ::rtl::OUString::valueOf(sal_Int32(m_NF_CACHE_SIZE.GetValue()*256));
535*cdf0e10cSrcweir 	aCreateArgs[nPos].Name		= PROPERTY_DATABASENAME;
536*cdf0e10cSrcweir 	aCreateArgs[nPos++].Value  <<= ::rtl::OUString(m_ET_DATABASENAME.GetText().ToUpperAscii());
537*cdf0e10cSrcweir 	aCreateArgs[nPos].Name		= PROPERTY_DATADEVSPACE;
538*cdf0e10cSrcweir 	aCreateArgs[nPos++].Value  <<= ::rtl::OUString(m_DATADEV_File);
539*cdf0e10cSrcweir 	aCreateArgs[nPos].Name		= PROPERTY_SYSDEVSPACE;
540*cdf0e10cSrcweir 	aCreateArgs[nPos++].Value  <<= ::rtl::OUString(m_SYSDEV_File);
541*cdf0e10cSrcweir 	aCreateArgs[nPos].Name		= PROPERTY_TRANSACTION_LOG;
542*cdf0e10cSrcweir 	aCreateArgs[nPos++].Value  <<= ::rtl::OUString(m_TRANSDEV_File);
543*cdf0e10cSrcweir 	aCreateArgs[nPos].Name		= PROPERTY_DATADEVSIZE;
544*cdf0e10cSrcweir 	aCreateArgs[nPos++].Value  <<= sal_Int32(m_NF_DATADEVSPACE_SIZE.GetValue()*256);
545*cdf0e10cSrcweir 	aCreateArgs[nPos].Name		= PROPERTY_LOGDEVSIZE;
546*cdf0e10cSrcweir 	aCreateArgs[nPos++].Value  <<= 	sal_Int32(m_NF_TRANSACTIONLOG_SIZE.GetValue()*256);
547*cdf0e10cSrcweir 
548*cdf0e10cSrcweir 	if(m_bRestore)
549*cdf0e10cSrcweir 	{
550*cdf0e10cSrcweir 		aCreateArgs[nPos].Name		= PROPERTY_RESTOREDATABASE;
551*cdf0e10cSrcweir 		aCreateArgs[nPos++].Value  <<= ::cppu::bool2any(sal_True);
552*cdf0e10cSrcweir 		aCreateArgs[nPos].Name		= PROPERTY_BACKUPNAME;
553*cdf0e10cSrcweir 		aCreateArgs[nPos++].Value  <<= ::rtl::OUString(m_Backup_File);
554*cdf0e10cSrcweir 	}
555*cdf0e10cSrcweir 
556*cdf0e10cSrcweir 	Disable();
557*cdf0e10cSrcweir 
558*cdf0e10cSrcweir 	m_aCreatorWait = ::std::auto_ptr<WaitObject>(new WaitObject(this));
559*cdf0e10cSrcweir 	m_aCreatorThread = ::std::auto_ptr<ODatabaseCreator>(new ODatabaseCreator(m_xCreateCatalog,this,m_xORB,aCreateArgs));
560*cdf0e10cSrcweir 	m_aCreatorThread->setTerminateHandler(LINK(this,OAdabasNewDbDlg,TerminateHdl));
561*cdf0e10cSrcweir 	m_aCreatorThread->create();
562*cdf0e10cSrcweir 
563*cdf0e10cSrcweir 	return sal_True;
564*cdf0e10cSrcweir }
565*cdf0e10cSrcweir //-------------------------------------------------------------------------
566*cdf0e10cSrcweir IMPL_LINK( OAdabasNewDbDlg, TerminateHdl, void*, /*NOTUSABLE*/ )
567*cdf0e10cSrcweir {
568*cdf0e10cSrcweir 	EndDialog(RET_OK);
569*cdf0e10cSrcweir 	return 0;
570*cdf0e10cSrcweir }
571*cdf0e10cSrcweir //------------------------------------------------------------------------
572*cdf0e10cSrcweir IMPL_LINK( OAdabasNewDbDlg, LoseFocusHdl, Edit *, pEdit )
573*cdf0e10cSrcweir {
574*cdf0e10cSrcweir 	if(&m_ET_SYSDEVSPACE == pEdit)
575*cdf0e10cSrcweir 		m_SYSDEV_File = pEdit->GetText();
576*cdf0e10cSrcweir 	else if(&m_ET_TRANSACTIONLOG == pEdit)
577*cdf0e10cSrcweir 		m_TRANSDEV_File = pEdit->GetText();
578*cdf0e10cSrcweir 	else if(&m_ET_DATADEVSPACE == pEdit)
579*cdf0e10cSrcweir 		m_DATADEV_File = pEdit->GetText();
580*cdf0e10cSrcweir 	else if(&m_ET_RESTORE == pEdit)
581*cdf0e10cSrcweir 		m_Backup_File = pEdit->GetText();
582*cdf0e10cSrcweir 	else if(&m_ET_DATABASENAME == pEdit)
583*cdf0e10cSrcweir 	{// check if the new dbname already exists
584*cdf0e10cSrcweir 		String sNewDbName = pEdit->GetText();
585*cdf0e10cSrcweir 		String sConfig = m_sDbConfig;
586*cdf0e10cSrcweir 		sConfig.AppendAscii("config/");
587*cdf0e10cSrcweir 		sConfig += sNewDbName;
588*cdf0e10cSrcweir 		if(UCBContentHelper::IsDocument(sConfig))
589*cdf0e10cSrcweir 		{
590*cdf0e10cSrcweir 			String sErrorMessage = String(ModuleRes(STR_ADABAS_DB_EXISTS));
591*cdf0e10cSrcweir 			ErrorBox(this, WB_OK, sErrorMessage).Execute();
592*cdf0e10cSrcweir 			m_DBName.Erase();
593*cdf0e10cSrcweir 		}
594*cdf0e10cSrcweir 		else if ( m_DBName.SearchAscii(" ") != STRING_NOTFOUND )
595*cdf0e10cSrcweir 		{
596*cdf0e10cSrcweir 			String sErrorMessage = String(ModuleRes(STR_ADABAS_DB_EXISTS));
597*cdf0e10cSrcweir 			ErrorBox(this, WB_OK, sErrorMessage).Execute();
598*cdf0e10cSrcweir 			m_DBName = m_DBName.GetToken(0,' ');
599*cdf0e10cSrcweir 		}
600*cdf0e10cSrcweir 		else
601*cdf0e10cSrcweir 			m_DBName = sNewDbName;
602*cdf0e10cSrcweir 	}
603*cdf0e10cSrcweir 
604*cdf0e10cSrcweir 	CheckBitmaps();
605*cdf0e10cSrcweir 	return 0;
606*cdf0e10cSrcweir }
607*cdf0e10cSrcweir //------------------------------------------------------------------------
608*cdf0e10cSrcweir IMPL_LINK( OAdabasNewDbDlg, LoadButtonClickHdl, Button *, /*pButton*/ )
609*cdf0e10cSrcweir {
610*cdf0e10cSrcweir 	::sfx2::FileDialogHelper aLoad(WB_3DLOOK | WB_STDMODAL | WB_OPEN);
611*cdf0e10cSrcweir 	if(!m_Backup_File.Len())
612*cdf0e10cSrcweir 		aLoad.SetDisplayDirectory(SvtPathOptions().GetWorkPath());
613*cdf0e10cSrcweir 	else
614*cdf0e10cSrcweir 		aLoad.SetDisplayDirectory(m_Backup_File);
615*cdf0e10cSrcweir 	if (aLoad.Execute())
616*cdf0e10cSrcweir 	{
617*cdf0e10cSrcweir 		INetURLObject aUrl(aLoad.GetPath());
618*cdf0e10cSrcweir 		m_Backup_File = aUrl.PathToFileName();
619*cdf0e10cSrcweir 		if(m_Backup_File.Len() > 40)
620*cdf0e10cSrcweir 		{
621*cdf0e10cSrcweir 			InfoBox aInfo(this,ModuleRes(INFO_STR_MAX_FILE_LENGTH));
622*cdf0e10cSrcweir 			String aMsg(aInfo.GetMessText());
623*cdf0e10cSrcweir 			aMsg.SearchAndReplace(String::CreateFromAscii("\'#\'"),String::CreateFromAscii("40"));
624*cdf0e10cSrcweir 			aInfo.SetMessText(aMsg);
625*cdf0e10cSrcweir 		}
626*cdf0e10cSrcweir 		m_ET_RESTORE.SetText(m_Backup_File);
627*cdf0e10cSrcweir 	}
628*cdf0e10cSrcweir 	CheckBitmaps();
629*cdf0e10cSrcweir 	return 0;
630*cdf0e10cSrcweir }
631*cdf0e10cSrcweir //------------------------------------------------------------------------
632*cdf0e10cSrcweir IMPL_LINK( OAdabasNewDbDlg, ButtonClickHdl, Button *, pButton )
633*cdf0e10cSrcweir {
634*cdf0e10cSrcweir 	WinBits	nBits(WB_3DLOOK|WB_STDMODAL|WB_SAVEAS);
635*cdf0e10cSrcweir 	::sfx2::FileDialogHelper aFileDlg( static_cast<sal_uInt32>(nBits) ); //	new FileDialog( this, nBits );
636*cdf0e10cSrcweir 
637*cdf0e10cSrcweir 	String aPath;
638*cdf0e10cSrcweir 	if(pButton == &m_PB_SYSDEVSPACE)
639*cdf0e10cSrcweir 		aPath = m_SYSDEV_File;
640*cdf0e10cSrcweir 	else if(pButton == &m_PB_TRANSACTIONLOG)
641*cdf0e10cSrcweir 		aPath = m_TRANSDEV_File;
642*cdf0e10cSrcweir 	else if(pButton == &m_PB_DATADEVSPACE)
643*cdf0e10cSrcweir 		aPath = m_DATADEV_File;
644*cdf0e10cSrcweir 
645*cdf0e10cSrcweir 	String sUrl;
646*cdf0e10cSrcweir 	::utl::LocalFileHelper::ConvertPhysicalNameToURL(aPath,sUrl);
647*cdf0e10cSrcweir 	aFileDlg.SetDisplayDirectory(sUrl);
648*cdf0e10cSrcweir 
649*cdf0e10cSrcweir 
650*cdf0e10cSrcweir 
651*cdf0e10cSrcweir 	if (aFileDlg.Execute() == ERRCODE_NONE)
652*cdf0e10cSrcweir 	{
653*cdf0e10cSrcweir 		INetURLObject aUrl(aFileDlg.GetPath());
654*cdf0e10cSrcweir 		if(pButton == &m_PB_SYSDEVSPACE)
655*cdf0e10cSrcweir 		{
656*cdf0e10cSrcweir 			m_SYSDEV_File = aUrl.PathToFileName();
657*cdf0e10cSrcweir 			if(m_SYSDEV_File.Len() > 40)
658*cdf0e10cSrcweir 			{
659*cdf0e10cSrcweir 				InfoBox aInfo(this,ModuleRes(INFO_STR_MAX_FILE_LENGTH));
660*cdf0e10cSrcweir 				String aMsg(aInfo.GetMessText());
661*cdf0e10cSrcweir 				aMsg.SearchAndReplace(String::CreateFromAscii("\'#\'"),String::CreateFromAscii("40"));
662*cdf0e10cSrcweir 				aInfo.SetMessText(aMsg);
663*cdf0e10cSrcweir 				aInfo.Execute();
664*cdf0e10cSrcweir 				return 0;
665*cdf0e10cSrcweir 			}
666*cdf0e10cSrcweir 			m_ET_SYSDEVSPACE.SetText(aUrl.PathToFileName());
667*cdf0e10cSrcweir 		}
668*cdf0e10cSrcweir 		else if(pButton == &m_PB_TRANSACTIONLOG)
669*cdf0e10cSrcweir 		{
670*cdf0e10cSrcweir 			m_TRANSDEV_File = aUrl.PathToFileName();
671*cdf0e10cSrcweir 			if(m_TRANSDEV_File.Len() > 40)
672*cdf0e10cSrcweir 			{
673*cdf0e10cSrcweir 				InfoBox aInfo(this,ModuleRes(INFO_STR_MAX_FILE_LENGTH));
674*cdf0e10cSrcweir 				String aMsg(aInfo.GetMessText());
675*cdf0e10cSrcweir 				aMsg.SearchAndReplace(String::CreateFromAscii("\'#\'"),String::CreateFromAscii("40"));
676*cdf0e10cSrcweir 				aInfo.SetMessText(aMsg);
677*cdf0e10cSrcweir 				aInfo.Execute();
678*cdf0e10cSrcweir 				return 0;
679*cdf0e10cSrcweir 			}
680*cdf0e10cSrcweir 			m_ET_TRANSACTIONLOG.SetText(aUrl.PathToFileName());
681*cdf0e10cSrcweir 		}
682*cdf0e10cSrcweir 		else if(pButton == &m_PB_DATADEVSPACE)
683*cdf0e10cSrcweir 		{
684*cdf0e10cSrcweir 			m_DATADEV_File = aUrl.PathToFileName();
685*cdf0e10cSrcweir 			if(m_DATADEV_File.Len() > 40)
686*cdf0e10cSrcweir 			{
687*cdf0e10cSrcweir 				InfoBox aInfo(this,ModuleRes(INFO_STR_MAX_FILE_LENGTH));
688*cdf0e10cSrcweir 				String aMsg(aInfo.GetMessText());
689*cdf0e10cSrcweir 				aMsg.SearchAndReplace(String::CreateFromAscii("\'#\'"),String::CreateFromAscii("40"));
690*cdf0e10cSrcweir 				aInfo.SetMessText(aMsg);
691*cdf0e10cSrcweir 				aInfo.Execute();
692*cdf0e10cSrcweir 				return 0;
693*cdf0e10cSrcweir 			}
694*cdf0e10cSrcweir 			m_ET_DATADEVSPACE.SetText(aUrl.PathToFileName());
695*cdf0e10cSrcweir 		}
696*cdf0e10cSrcweir 	}
697*cdf0e10cSrcweir 
698*cdf0e10cSrcweir 	CheckBitmaps();
699*cdf0e10cSrcweir 	return 0;
700*cdf0e10cSrcweir }
701*cdf0e10cSrcweir //------------------------------------------------------------------------
702*cdf0e10cSrcweir IMPL_LINK( OAdabasNewDbDlg, PwdClickHdl, Button *, pButton )
703*cdf0e10cSrcweir {
704*cdf0e10cSrcweir 	SfxPasswordDialog aDlg(this);
705*cdf0e10cSrcweir 	aDlg.ShowExtras(SHOWEXTRAS_CONFIRM);
706*cdf0e10cSrcweir 	if(aDlg.Execute())
707*cdf0e10cSrcweir 	{
708*cdf0e10cSrcweir 		String sPwd = aDlg.GetPassword().ToUpperAscii();
709*cdf0e10cSrcweir 		// no space in password allowed
710*cdf0e10cSrcweir 		if ( sPwd.GetTokenCount(' ') == 1 )
711*cdf0e10cSrcweir 		{
712*cdf0e10cSrcweir 			if(pButton == &m_PB_CONPWD)
713*cdf0e10cSrcweir 			{
714*cdf0e10cSrcweir 				m_ConPwd = sPwd;
715*cdf0e10cSrcweir 				m_nSetBitmap &=~2;
716*cdf0e10cSrcweir 			}
717*cdf0e10cSrcweir 			else if(pButton == &m_PB_SYSPWD)
718*cdf0e10cSrcweir 			{
719*cdf0e10cSrcweir 				m_SysPwd = sPwd;
720*cdf0e10cSrcweir 				if(!m_DomainPwd.Len())
721*cdf0e10cSrcweir 				{
722*cdf0e10cSrcweir 					m_nSetBitmap = 1;
723*cdf0e10cSrcweir 					m_DomainPwd = m_SysPwd;
724*cdf0e10cSrcweir 				}
725*cdf0e10cSrcweir 				if(!m_ConPwd.Len())
726*cdf0e10cSrcweir 				{
727*cdf0e10cSrcweir 					m_nSetBitmap |= 2;
728*cdf0e10cSrcweir 					m_ConPwd = m_SysPwd;
729*cdf0e10cSrcweir 				}
730*cdf0e10cSrcweir 
731*cdf0e10cSrcweir 			}
732*cdf0e10cSrcweir 			else if(pButton == &m_PB_DOMAINPWD)
733*cdf0e10cSrcweir 			{
734*cdf0e10cSrcweir 				m_DomainPwd = sPwd;
735*cdf0e10cSrcweir 				m_nSetBitmap &=~1;
736*cdf0e10cSrcweir 			}
737*cdf0e10cSrcweir 		}
738*cdf0e10cSrcweir 		else
739*cdf0e10cSrcweir 		{
740*cdf0e10cSrcweir 			String sErrorMsg(ModuleRes(STR_ADABAS_PASSWORD_ILLEGAL));
741*cdf0e10cSrcweir 			ErrorBox(this, WB_OK, sErrorMsg).Execute();
742*cdf0e10cSrcweir 		}
743*cdf0e10cSrcweir 	}
744*cdf0e10cSrcweir 	CheckBitmaps();
745*cdf0e10cSrcweir 	return 0;
746*cdf0e10cSrcweir }
747*cdf0e10cSrcweir //------------------------------------------------------------------------
748*cdf0e10cSrcweir void OAdabasNewDbDlg::CheckBitmaps()
749*cdf0e10cSrcweir {
750*cdf0e10cSrcweir 	sal_Int16 i=0;
751*cdf0e10cSrcweir 	if(m_ConPwd.Len() && m_ET_CONUSR.GetText().Len())
752*cdf0e10cSrcweir 			i++,m_BMP_CON.SetImage(ModuleRes(((m_nSetBitmap & 2) == 2) ? DEFAULT_BLUE : CHECK_GREEN));
753*cdf0e10cSrcweir 	else
754*cdf0e10cSrcweir 		m_BMP_CON.SetImage(ModuleRes(UNCHECK_RED));
755*cdf0e10cSrcweir 
756*cdf0e10cSrcweir 	if(!m_bRestore)
757*cdf0e10cSrcweir 	{
758*cdf0e10cSrcweir 		if(m_SysPwd.Len() && m_ET_SYSUSR.GetText().Len())
759*cdf0e10cSrcweir 			i++,m_BMP_SYS.SetImage(ModuleRes(CHECK_GREEN));
760*cdf0e10cSrcweir 		else
761*cdf0e10cSrcweir 			m_BMP_SYS.SetImage(ModuleRes(UNCHECK_RED));
762*cdf0e10cSrcweir 
763*cdf0e10cSrcweir 		if(m_DomainPwd.Len() )
764*cdf0e10cSrcweir 			i++,m_BMP_DOMAIN.SetImage(ModuleRes(((m_nSetBitmap & 1) == 1) ? DEFAULT_BLUE : CHECK_GREEN));
765*cdf0e10cSrcweir 		else
766*cdf0e10cSrcweir 			m_BMP_DOMAIN.SetImage(ModuleRes(UNCHECK_RED));
767*cdf0e10cSrcweir 	}
768*cdf0e10cSrcweir 	else if(m_Backup_File.Len())
769*cdf0e10cSrcweir 		i+=2;
770*cdf0e10cSrcweir 
771*cdf0e10cSrcweir 	if(m_ET_SYSDEVSPACE.GetText().Len() && m_ET_TRANSACTIONLOG.GetText().Len() && m_ET_DATADEVSPACE.GetText().Len() &&
772*cdf0e10cSrcweir 		m_ET_SYSDEVSPACE.GetText() != m_ET_TRANSACTIONLOG.GetText() && m_ET_SYSDEVSPACE.GetText() != m_ET_DATADEVSPACE.GetText() &&
773*cdf0e10cSrcweir 		m_ET_DATADEVSPACE.GetText() != m_ET_TRANSACTIONLOG.GetText())
774*cdf0e10cSrcweir 		i++;
775*cdf0e10cSrcweir 
776*cdf0e10cSrcweir 	if(m_DBName.Len())
777*cdf0e10cSrcweir 		i++;
778*cdf0e10cSrcweir 
779*cdf0e10cSrcweir 	m_PB_OK.Enable(i == 5);
780*cdf0e10cSrcweir }
781*cdf0e10cSrcweir // -----------------------------------------------------------------------------
782*cdf0e10cSrcweir sal_Bool OAdabasNewDbDlg::fillEnvironmentVariable(const ::rtl::OUString& _sVariableName,String& _rsValue)
783*cdf0e10cSrcweir {
784*cdf0e10cSrcweir 	rtl_uString* pDbVar = NULL;
785*cdf0e10cSrcweir 	sal_Bool bError = sal_False;
786*cdf0e10cSrcweir 	if(osl_getEnvironment(_sVariableName.pData,&pDbVar) == osl_Process_E_None && pDbVar)
787*cdf0e10cSrcweir 	{
788*cdf0e10cSrcweir 		_rsValue = pDbVar;
789*cdf0e10cSrcweir 		String sTemp;
790*cdf0e10cSrcweir 		LocalFileHelper::ConvertPhysicalNameToURL(_rsValue,sTemp);
791*cdf0e10cSrcweir 		_rsValue = sTemp;
792*cdf0e10cSrcweir 		rtl_uString_release(pDbVar);
793*cdf0e10cSrcweir 		pDbVar = NULL;
794*cdf0e10cSrcweir 
795*cdf0e10cSrcweir 		// ensure dir exists
796*cdf0e10cSrcweir 		osl::FileBase::RC rc = osl::Directory::createPath(_rsValue);
797*cdf0e10cSrcweir 		if(rc != osl::FileBase::E_None && rc != osl::FileBase::E_EXIST)
798*cdf0e10cSrcweir 		{
799*cdf0e10cSrcweir 			bError = sal_True;
800*cdf0e10cSrcweir 			PostUserEvent(LINK(this, OAdabasNewDbDlg, OnError));
801*cdf0e10cSrcweir 		}
802*cdf0e10cSrcweir 	}
803*cdf0e10cSrcweir 	return bError;
804*cdf0e10cSrcweir }
805*cdf0e10cSrcweir // -----------------------------------------------------------------------------
806