1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AdabasNewDb.cxx,v $
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 adabasui_ADABAS_CREATEDB_HXX
32 #include "AdabasNewDb.hxx"
34 #ifndef adabasui_ADABASNEWDB_HRC
35 #include "AdabasNewDb.hrc"
38 #ifndef _VOS_PROCESS_HXX_
39 #include <vos/process.hxx>
41 #ifndef _OSL_PROCESS_H_
42 #include <osl/process.h>
44 #ifndef _MSGBOX_HXX //autogen
45 #include <vcl/msgbox.hxx>
47 #ifndef _PASSWD_HXX //autogen
48 #include <sfx2/passwd.hxx>
51 #include <tools/urlobj.hxx>
54 #include <tools/stream.hxx>
57 #include <tools/bigint.hxx>
59 #ifndef _TOOLS_DEBUG_HXX
60 #include <tools/debug.hxx>
62 #ifndef _EXTENSIONS_COMPONENT_MODULE_HXX_
63 #include "Acomponentmodule.hxx"
65 #ifndef _UNOTOOLS_TEMPFILE_HXX
66 #include <unotools/tempfile.hxx>
68 #ifndef _ADABASUI_RESOURCE_HRC_
69 #include "adabasui_resource.hrc"
71 #ifndef _UCBHELPER_CONTENT_HXX
72 #include <ucbhelper/content.hxx>
74 #ifndef _SV_WAITOBJ_HXX
75 #include <vcl/waitobj.hxx>
77 #ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
78 #include <svtools/pathoptions.hxx>
80 #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
81 #include <toolkit/unohlp.hxx>
83 #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
84 #include <com/sun/star/beans/PropertyValue.hpp>
86 #ifndef _COMPHELPER_EXTRACT_HXX_
87 #include <comphelper/extract.hxx>
89 #ifndef _UNOTOOLS_TEMPFILE_HXX
90 #include <unotools/tempfile.hxx>
92 #ifndef _UNOTOOLS_LOCALFILEHELPER_HXX
93 #include <unotools/localfilehelper.hxx>
95 #ifndef _COM_SUN_STAR_SDBC_SQLEXCEPTION_HPP_
96 #include <com/sun/star/sdbc/SQLException.hpp>
98 #ifndef _UNOTOOLS_UCBHELPER_HXX
99 #include <unotools/ucbhelper.hxx>
101 #ifndef _CONNECTIVITY_DBTOOLS_HXX_
102 #include <connectivity/dbtools.hxx>
104 #ifndef _DBHELPER_DBEXCEPTION_HXX_
105 #include <connectivity/dbexception.hxx>
107 #include "adabasuistrings.hrc"
109 #include <osl/thread.hxx>
111 #ifndef _OSL_FILE_HXX_
112 #include <osl/file.hxx>
116 using namespace adabasui
;
117 using namespace ucbhelper
;
120 using namespace ::com::sun::star::uno
;
121 using namespace ::com::sun::star::beans
;
122 using namespace ::com::sun::star::sdbcx
;
123 using namespace ::com::sun::star::sdbc
;
124 using namespace ::com::sun::star::ucb
;
125 using namespace ::com::sun::star::lang
;
128 class ODatabaseCreator
: public ::osl::Thread
130 Link m_aTerminateHandler
;
131 Sequence
< PropertyValue
> m_aValues
;
132 Reference
<XCreateCatalog
> m_xCreateCatalog
;
133 Reference
< XMultiServiceFactory
> m_xORB
;
134 Window
* m_pErrorWindow
;
136 ODatabaseCreator(const Reference
<XCreateCatalog
>& _rxCreateCatalog
137 ,Window
* _pErrorWindow
138 ,const Reference
< XMultiServiceFactory
>& _xORB
139 ,const Sequence
< PropertyValue
>& _rValues
)
140 : m_aValues(_rValues
)
141 , m_xCreateCatalog(_rxCreateCatalog
)
143 , m_pErrorWindow(_pErrorWindow
)
146 void setTerminateHandler(const Link
& _aTerminateHandler
) { m_aTerminateHandler
= _aTerminateHandler
; }
150 /// Working method which should be overridden.
151 virtual void SAL_CALL
run();
152 virtual void SAL_CALL
onTerminated();
155 void SAL_CALL
ODatabaseCreator::run()
159 m_xCreateCatalog
->createCatalog(m_aValues
);
161 catch(SQLException
& e
)
163 ::dbtools::showError(::dbtools::SQLExceptionInfo(e
),VCLUnoHelper::GetInterface(m_pErrorWindow
),m_xORB
);
168 // showError(::dbtools::SQLExceptionInfo(e),this,);
171 void SAL_CALL
ODatabaseCreator::onTerminated()
173 if ( m_aTerminateHandler
.IsSet() )
174 m_aTerminateHandler
.Call(NULL
);
177 DBG_NAME( OAdabasNewDbDlg
)
178 //========================================================================
179 OAdabasNewDbDlg::OAdabasNewDbDlg( Window
* pParent
,
180 const Reference
<XCreateCatalog
>& _rxCreateCatalog
,
181 const Reference
< XMultiServiceFactory
>& _rxORB
,
183 :ModalDialog( pParent
, ModuleRes( DLG_ADABAS_NEWDB
))
184 ,m_FT_DATABASENAME( this, ModuleRes( FT_DATABASENAME
) )
185 ,m_ET_DATABASENAME( this, ModuleRes( ET_DATABASENAME
) )
186 ,m_FL_USER( this, ModuleRes( FL_USER
) )
187 ,m_FT_SYSUSR( this, ModuleRes( FT_SYSUSR
) )
188 ,m_FT_CONUSR( this, ModuleRes( FT_CONUSR
) )
189 ,m_FT_DOMAIN_USR( this, ModuleRes( FT_DOMAIN_USR
) )
190 ,m_ET_SYSUSR( this, ModuleRes( ET_SYSUSR
) )
191 ,m_PB_SYSPWD( this, ModuleRes( PB_SYSPWD
) )
192 ,m_ET_CONUSR( this, ModuleRes( ET_CONUSR
) )
193 ,m_PB_CONPWD( this, ModuleRes( PB_CONPWD
) )
194 ,m_ET_DOMAIN_USR( this, ModuleRes( ET_DOMAIN_USR
) )
195 ,m_PB_DOMAINPWD( this, ModuleRes( PB_DOMAINPWD
) )
196 ,m_BMP_CON( this, ModuleRes( BMP_CON
) )
197 ,m_BMP_SYS( this, ModuleRes( BMP_SYS
) )
198 ,m_BMP_DOMAIN( this, ModuleRes( BMP_DOMAIN
) )
199 ,m_FT_RESTORE( this, ModuleRes( FT_RESTORE
) )
200 ,m_ET_RESTORE( this, ModuleRes( ET_RESTORE
) )
201 ,m_PB_RESTORE( this, ModuleRes( PB_RESTORE
) )
202 ,m_FL_DBSETTINGS( this, ModuleRes( FL_DBSETTINGS
) )
203 ,m_FT_SYSDEVSPACE( this, ModuleRes( FT_SYSDEVSPACE
) )
204 ,m_FT_TRANSACTIONLOG( this, ModuleRes( FT_TRANSACTIONLOG
) )
205 ,m_FT_DATADEVSPACE( this, ModuleRes( FT_DATADEVSPACE
) )
206 ,m_ET_SYSDEVSPACE( this, ModuleRes( ET_SYSDEVSPACE
) )
207 ,m_PB_SYSDEVSPACE( this, ModuleRes( PB_SYSDEVSPACE
) )
208 ,m_ET_TRANSACTIONLOG( this, ModuleRes( ET_TRANSACTIONLOG
) )
209 ,m_PB_TRANSACTIONLOG( this, ModuleRes( PB_TRANSACTIONLOG
) )
210 ,m_ET_DATADEVSPACE( this, ModuleRes( ET_DATADEVSPACE
) )
211 ,m_PB_DATADEVSPACE( this, ModuleRes( PB_DATADEVSPACE
) )
212 ,m_FT_TRANSACTIONLOG_SIZE( this, ModuleRes( FT_TRANSACTIONLOG_SIZE
) )
213 ,m_NF_TRANSACTIONLOG_SIZE( this, ModuleRes( NF_TRANSACTIONLOG_SIZE
) )
214 ,m_FT_DATADEVSPACE_SIZE( this, ModuleRes( FT_DATADEVSPACE_SIZE
) )
215 ,m_NF_DATADEVSPACE_SIZE( this, ModuleRes( NF_DATADEVSPACE_SIZE
) )
216 ,m_FT_CACHE_SIZE( this, ModuleRes( FT_CACHE_SIZE
) )
217 ,m_NF_CACHE_SIZE( this, ModuleRes( NF_CACHE_SIZE
) )
218 ,m_FL_END( this, ModuleRes( FL_END
) )
219 ,m_PB_OK( this, ModuleRes( PB_OK
) )
220 ,m_PB_CANCEL( this, ModuleRes( PB_CANCEL
) )
221 ,m_xCreateCatalog(_rxCreateCatalog
)
223 ,m_bRestore(_bRestore
)
226 DBG_CTOR( OAdabasNewDbDlg
, NULL
);
230 m_FL_DBSETTINGS
.SetPosPixel(m_FL_DBSETTINGS
.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT
));
231 m_FT_SYSDEVSPACE
.SetPosPixel(m_FT_SYSDEVSPACE
.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT
));
232 m_FT_TRANSACTIONLOG
.SetPosPixel(m_FT_TRANSACTIONLOG
.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT
));
233 m_FT_DATADEVSPACE
.SetPosPixel(m_FT_DATADEVSPACE
.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT
));
234 m_ET_SYSDEVSPACE
.SetPosPixel(m_ET_SYSDEVSPACE
.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT
));
235 m_PB_SYSDEVSPACE
.SetPosPixel(m_PB_SYSDEVSPACE
.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT
));
236 m_ET_TRANSACTIONLOG
.SetPosPixel(m_ET_TRANSACTIONLOG
.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT
));
237 m_PB_TRANSACTIONLOG
.SetPosPixel(m_PB_TRANSACTIONLOG
.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT
));
238 m_ET_DATADEVSPACE
.SetPosPixel(m_ET_DATADEVSPACE
.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT
));
239 m_PB_DATADEVSPACE
.SetPosPixel(m_PB_DATADEVSPACE
.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT
));
240 m_FT_TRANSACTIONLOG_SIZE
.SetPosPixel(m_FT_TRANSACTIONLOG_SIZE
.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT
));
241 m_NF_TRANSACTIONLOG_SIZE
.SetPosPixel(m_NF_TRANSACTIONLOG_SIZE
.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT
));
242 m_FT_DATADEVSPACE_SIZE
.SetPosPixel(m_FT_DATADEVSPACE_SIZE
.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT
));
243 m_NF_DATADEVSPACE_SIZE
.SetPosPixel(m_NF_DATADEVSPACE_SIZE
.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT
));
244 m_FT_CACHE_SIZE
.SetPosPixel(m_FT_CACHE_SIZE
.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT
));
245 m_NF_CACHE_SIZE
.SetPosPixel(m_NF_CACHE_SIZE
.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT
));
246 m_PB_OK
.SetPosPixel(m_PB_OK
.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT
));
247 m_PB_CANCEL
.SetPosPixel(m_PB_CANCEL
.GetPosPixel()-LogicToPixel( Point(0,14), MAP_APPFONT
));
249 Size
aSize(GetSizePixel().Width(),GetSizePixel().Height()-LogicToPixel( Size(0,14), MAP_APPFONT
).Height());
253 m_FT_DOMAIN_USR
.Hide();
254 m_FL_USER
.SetText(ModuleRes(STR_BACKUPFILE_LOAD
));
256 m_PB_DOMAINPWD
.Hide();
258 m_ET_DOMAIN_USR
.Hide();
260 m_ET_SYSUSR
.SetText(String::CreateFromAscii("DUMMY"));
263 m_ET_RESTORE
.SetModifyHdl( LINK(this,OAdabasNewDbDlg
,LoseFocusHdl
));
264 m_ET_RESTORE
.SetLoseFocusHdl( LINK(this,OAdabasNewDbDlg
,LoseFocusHdl
));
265 m_ET_RESTORE
.SetMaxTextLen(40);
273 m_ET_SYSUSR
.SetModifyHdl( LINK(this,OAdabasNewDbDlg
,LoseFocusHdl
));
274 m_ET_CONUSR
.SetModifyHdl( LINK(this,OAdabasNewDbDlg
,LoseFocusHdl
));
275 m_ET_DOMAIN_USR
.Enable(FALSE
);
277 // m_ET_SYSUSR.setUpperCase();
278 // m_ET_CONUSR.setUpperCase();
282 m_ET_SYSDEVSPACE
.SetLoseFocusHdl( LINK(this,OAdabasNewDbDlg
,LoseFocusHdl
));
283 m_ET_TRANSACTIONLOG
.SetLoseFocusHdl( LINK(this,OAdabasNewDbDlg
,LoseFocusHdl
));
284 m_ET_DATADEVSPACE
.SetLoseFocusHdl( LINK(this,OAdabasNewDbDlg
,LoseFocusHdl
));
286 m_ET_SYSDEVSPACE
.SetMaxTextLen(40);
287 m_ET_TRANSACTIONLOG
.SetMaxTextLen(40);
288 m_ET_DATADEVSPACE
.SetMaxTextLen(40);
290 m_NF_TRANSACTIONLOG_SIZE
.SetModifyHdl( LINK(this,OAdabasNewDbDlg
,LoseFocusHdl
));
291 m_NF_DATADEVSPACE_SIZE
.SetModifyHdl( LINK(this,OAdabasNewDbDlg
,LoseFocusHdl
));
292 m_NF_CACHE_SIZE
.SetModifyHdl( LINK(this,OAdabasNewDbDlg
,LoseFocusHdl
));
294 m_NF_TRANSACTIONLOG_SIZE
.SetMin(10);
295 m_NF_DATADEVSPACE_SIZE
.SetMin(10);
296 m_NF_CACHE_SIZE
.SetMin(4);
298 m_NF_TRANSACTIONLOG_SIZE
.SetMax(LONG_MAX
);
299 m_NF_DATADEVSPACE_SIZE
.SetMax(LONG_MAX
);
300 m_NF_CACHE_SIZE
.SetMax(LONG_MAX
);
302 m_NF_TRANSACTIONLOG_SIZE
.SetValue(20);
303 m_NF_DATADEVSPACE_SIZE
.SetValue(20);
304 m_NF_CACHE_SIZE
.SetValue(4);
306 m_NF_TRANSACTIONLOG_SIZE
.SetDecimalDigits(0);
307 m_NF_DATADEVSPACE_SIZE
.SetDecimalDigits(0);
308 m_NF_CACHE_SIZE
.SetDecimalDigits(0);
310 m_ET_DATABASENAME
.SetMaxTextLen( 8 ); //98292
312 m_PB_CONPWD
.SetClickHdl( LINK(this,OAdabasNewDbDlg
,PwdClickHdl
));
313 m_PB_SYSPWD
.SetClickHdl( LINK(this,OAdabasNewDbDlg
,PwdClickHdl
));
314 m_PB_DOMAINPWD
.SetClickHdl( LINK(this,OAdabasNewDbDlg
,PwdClickHdl
));
316 m_PB_RESTORE
.SetClickHdl( LINK(this,OAdabasNewDbDlg
,LoadButtonClickHdl
));
318 m_PB_SYSDEVSPACE
.SetClickHdl( LINK(this,OAdabasNewDbDlg
,ButtonClickHdl
));
319 m_PB_TRANSACTIONLOG
.SetClickHdl( LINK(this,OAdabasNewDbDlg
,ButtonClickHdl
));
320 m_PB_DATADEVSPACE
.SetClickHdl( LINK(this,OAdabasNewDbDlg
,ButtonClickHdl
));
322 m_BMP_CON
.SetImage( ModuleRes(UNCHECK_RED
) );
323 m_BMP_SYS
.SetImage( ModuleRes(UNCHECK_RED
) );
324 m_BMP_DOMAIN
.SetImage( ModuleRes(UNCHECK_RED
) );
326 static String
s_sRoot(RTL_CONSTASCII_USTRINGPARAM("DBROOT"));
327 static String
s_sConfig(RTL_CONSTASCII_USTRINGPARAM("DBCONFIG"));
328 static String
s_sWork(RTL_CONSTASCII_USTRINGPARAM("DBWORK"));
330 sal_Bool bError
= fillEnvironmentVariable(s_sWork
,m_sDbWork
);
331 if ( bError
|| !m_sDbWork
.Len() )
332 bError
= fillEnvironmentVariable(s_sRoot
,m_sDbWork
);
334 bError
= fillEnvironmentVariable(s_sConfig
,m_sDbConfig
);
335 if ( bError
|| !m_sDbConfig
.Len() )
336 bError
= fillEnvironmentVariable(s_sRoot
,m_sDbConfig
);
338 if ( m_sDbConfig
.Len() && m_sDbWork
.Len() )
340 m_sDbConfig
.AppendAscii("/");
341 m_sDbWork
.AppendAscii("/");
343 String sDefaultName
,sExt
;
344 sDefaultName
.AssignAscii("MYDB");
345 String sConfig
= m_sDbConfig
;
346 sConfig
.AppendAscii("config");
347 TempFile
aDefaultDatabase(sDefaultName
,&sExt
,&sConfig
);
348 aDefaultDatabase
.EnableKillingFile();
349 INetURLObject
aURL(aDefaultDatabase
.GetURL());
351 m_ET_DATABASENAME
.SetText(aURL
.GetName());
352 m_DBName
= m_ET_DATABASENAME
.GetText();
354 // create temp names for my files
355 // here we need only a name the creation is done by the driver
356 // so we delete the files after we get a valid name
357 // with this we avoiding to mention anything when the user presses cancel
360 sal_Bool bValid
= sal_True
;
362 aSysExt
.AssignAscii(".sys");
363 ::utl::TempFile
aTmpFile(m_ET_DATABASENAME
.GetText(),&aSysExt
,&m_sDbWork
);
364 aTmpFile
.EnableKillingFile();
365 bValid
= aTmpFile
.IsValid();
367 LocalFileHelper::ConvertURLToPhysicalName(aTmpFile
.GetURL(),m_SYSDEV_File
);
370 aSysExt
.AssignAscii(".trs");
371 ::utl::TempFile
aTmpFile(m_ET_DATABASENAME
.GetText(),&aSysExt
,&m_sDbWork
);
372 aTmpFile
.EnableKillingFile();
373 bValid
= !bValid
|| aTmpFile
.IsValid();
374 if(aTmpFile
.IsValid())
375 LocalFileHelper::ConvertURLToPhysicalName(aTmpFile
.GetURL(),m_TRANSDEV_File
);
378 aSysExt
.AssignAscii(".dat");
379 ::utl::TempFile
aTmpFile(m_ET_DATABASENAME
.GetText(),&aSysExt
,&m_sDbWork
);
380 aTmpFile
.EnableKillingFile();
381 bValid
= !bValid
|| aTmpFile
.IsValid();
382 if(aTmpFile
.IsValid())
383 LocalFileHelper::ConvertURLToPhysicalName(aTmpFile
.GetURL(),m_DATADEV_File
);
385 if(!bValid
) // we found a file which isn't valid so we report an error message
386 PostUserEvent(LINK(this, OAdabasNewDbDlg
, OnNoAccessRights
));
390 if(m_SYSDEV_File
.Len() < 41 && m_TRANSDEV_File
.Len() < 41 && m_DATADEV_File
.Len() < 41)
392 m_ET_SYSDEVSPACE
.SetText(m_SYSDEV_File
);
393 m_ET_TRANSACTIONLOG
.SetText(m_TRANSDEV_File
);
394 m_ET_DATADEVSPACE
.SetText(m_DATADEV_File
);
398 m_SYSDEV_File
= m_TRANSDEV_File
= m_DATADEV_File
= String();
399 PostUserEvent(LINK(this, OAdabasNewDbDlg
, OnNoDefaultPath
));
402 m_ET_CONUSR
.SetText(String::CreateFromAscii("CONTROL"));
404 m_PB_OK
.SetClickHdl(LINK(this,OAdabasNewDbDlg
,ImplOKHdl
));
405 m_PB_OK
.Enable(FALSE
);
407 m_ET_DATABASENAME
.SetModifyHdl( LINK(this,OAdabasNewDbDlg
,LoseFocusHdl
));
410 // -----------------------------------------------------------------------
411 OAdabasNewDbDlg::~OAdabasNewDbDlg()
413 DBG_DTOR( OAdabasNewDbDlg
, NULL
);
415 //------------------------------------------------------------------
416 IMPL_LINK(OAdabasNewDbDlg
, OnError
, void*, /*_pArg*/)
418 String
sErrorMsg(ModuleRes(STR_ERROR_IN_ADABAS_INSTALLATION
));
419 ErrorBox(this, WB_OK
, sErrorMsg
).Execute();
420 EndDialog(RET_CANCEL
);
423 //------------------------------------------------------------------
424 IMPL_LINK(OAdabasNewDbDlg
, OnNoDefaultPath
, void*, /*_pArg*/)
426 String
sErrorMsg(ModuleRes(STR_ADABAS_NO_DEFAULTNAME
));
427 ErrorBox(this, WB_OK
, sErrorMsg
).Execute();
430 //------------------------------------------------------------------
431 IMPL_LINK(OAdabasNewDbDlg
, OnNoAccessRights
, void*, /*_pArg*/)
433 String
sErrorMsg(ModuleRes(STR_ADABAS_NO_ACCESSRIGHTS
));
434 ErrorBox(this, WB_OK
, sErrorMsg
).Execute();
438 // -----------------------------------------------------------------------
439 IMPL_LINK( OAdabasNewDbDlg
, ImplOKHdl
, OKButton
*, /*EMPTYARG*/ )
441 m_SYSDEV_File
= m_ET_SYSDEVSPACE
.GetText();
442 m_TRANSDEV_File
= m_ET_TRANSACTIONLOG
.GetText();
443 m_DATADEV_File
= m_ET_DATADEVSPACE
.GetText();
445 m_Backup_File
= m_ET_RESTORE
.GetText();
449 aURL
.SetSmartProtocol(INET_PROT_FILE
);
450 aURL
.SetURL(m_Backup_File
);
451 Content
aContent(aURL
.GetURLNoPass(),Reference
<XCommandEnvironment
>());
454 if(!aContent
.isDocument())
456 String aString1
= String(ModuleRes(STR_ADABAS_NO_BACKUP_FILE
));
457 String aString2
= String(ModuleRes(STR_STAT_WARNING
));
458 SQLException
aSql(aString1
,NULL
,aString2
,1000,Any());
465 String aString1
= String(ModuleRes(STR_ADABAS_NO_BACKUP_FILE
));
466 String aString2
= String(ModuleRes(STR_STAT_WARNING
));
467 SQLException
aSql(aString1
,NULL
,aString2
,1000,Any());
470 if(m_Backup_File
.Len() > 40)
472 InfoBox
aInfo(this,ModuleRes(INFO_STR_MAX_FILE_LENGTH
));
473 String
aMsg(aInfo
.GetMessText());
474 aMsg
.SearchAndReplace(String::CreateFromAscii("\'#\'"),String::CreateFromAscii("40"));
475 aInfo
.SetMessText(aMsg
);
480 else if(m_SYSDEV_File
.Len() > 40 || m_TRANSDEV_File
.Len() > 40 || m_DATADEV_File
.Len() > 40)
482 InfoBox
aInfo(this,ModuleRes(INFO_STR_MAX_FILE_LENGTH
));
483 String
aMsg(aInfo
.GetMessText());
484 aMsg
.SearchAndReplace(String::CreateFromAscii("\'#\'"),String::CreateFromAscii("40"));
485 aInfo
.SetMessText(aMsg
);
496 bOk
= LocalFileHelper::ConvertPhysicalNameToURL(m_DATADEV_File
,sTemp
);
497 m_DATADEV_File
= sTemp
;
499 bOk
= LocalFileHelper::ConvertPhysicalNameToURL(m_SYSDEV_File
,sTemp
);
500 m_SYSDEV_File
= sTemp
;
502 bOk
= LocalFileHelper::ConvertPhysicalNameToURL(m_TRANSDEV_File
,sTemp
);
503 m_TRANSDEV_File
= sTemp
;
505 String aErrorMessage
= String(ModuleRes(STR_DEVSPACE_NO_FILE
));
506 if(!m_SYSDEV_File
.Len())
507 aErrorMessage
.SearchAndReplace(String::CreateFromAscii("$name$"),String::CreateFromAscii("SYSDEVSPACE"));
508 else if(!m_TRANSDEV_File
.Len())
509 aErrorMessage
.SearchAndReplace(String::CreateFromAscii("$name$"),String::CreateFromAscii("TRANSACTIONLOG"));
510 else if(!m_DATADEV_File
.Len())
511 aErrorMessage
.SearchAndReplace(String::CreateFromAscii("$name$"),String::CreateFromAscii("DATDEVSPACE"));
512 else if(m_ET_SYSUSR
.GetText() == m_ET_CONUSR
.GetText())
513 aErrorMessage
= String(ModuleRes(STR_NO_SAME_USER
));
520 ErrorBox(this, WB_OK
, aErrorMessage
).Execute();
525 Sequence
< PropertyValue
> aCreateArgs(m_bRestore
? 14 : 12);
526 aCreateArgs
[nPos
].Name
= PROPERTY_CONTROL_USER
;
527 aCreateArgs
[nPos
++].Value
<<= ::rtl::OUString(m_ET_CONUSR
.GetText().ToUpperAscii());
528 aCreateArgs
[nPos
].Name
= PROPERTY_CONTROL_PASSWORD
;
529 aCreateArgs
[nPos
++].Value
<<= ::rtl::OUString(m_ConPwd
);
530 aCreateArgs
[nPos
].Name
= PROPERTY_USER
;
531 aCreateArgs
[nPos
++].Value
<<= ::rtl::OUString(m_ET_SYSUSR
.GetText().ToUpperAscii());
532 aCreateArgs
[nPos
].Name
= PROPERTY_PASSWORD
;
533 aCreateArgs
[nPos
++].Value
<<= ::rtl::OUString(m_SysPwd
);
534 aCreateArgs
[nPos
].Name
= PROPERTY_DOMAINPASSWORD
;
535 aCreateArgs
[nPos
++].Value
<<= ::rtl::OUString(m_DomainPwd
);
536 aCreateArgs
[nPos
].Name
= PROPERTY_CACHESIZE
;
537 aCreateArgs
[nPos
++].Value
<<= ::rtl::OUString::valueOf(sal_Int32(m_NF_CACHE_SIZE
.GetValue()*256));
538 aCreateArgs
[nPos
].Name
= PROPERTY_DATABASENAME
;
539 aCreateArgs
[nPos
++].Value
<<= ::rtl::OUString(m_ET_DATABASENAME
.GetText().ToUpperAscii());
540 aCreateArgs
[nPos
].Name
= PROPERTY_DATADEVSPACE
;
541 aCreateArgs
[nPos
++].Value
<<= ::rtl::OUString(m_DATADEV_File
);
542 aCreateArgs
[nPos
].Name
= PROPERTY_SYSDEVSPACE
;
543 aCreateArgs
[nPos
++].Value
<<= ::rtl::OUString(m_SYSDEV_File
);
544 aCreateArgs
[nPos
].Name
= PROPERTY_TRANSACTION_LOG
;
545 aCreateArgs
[nPos
++].Value
<<= ::rtl::OUString(m_TRANSDEV_File
);
546 aCreateArgs
[nPos
].Name
= PROPERTY_DATADEVSIZE
;
547 aCreateArgs
[nPos
++].Value
<<= sal_Int32(m_NF_DATADEVSPACE_SIZE
.GetValue()*256);
548 aCreateArgs
[nPos
].Name
= PROPERTY_LOGDEVSIZE
;
549 aCreateArgs
[nPos
++].Value
<<= sal_Int32(m_NF_TRANSACTIONLOG_SIZE
.GetValue()*256);
553 aCreateArgs
[nPos
].Name
= PROPERTY_RESTOREDATABASE
;
554 aCreateArgs
[nPos
++].Value
<<= ::cppu::bool2any(sal_True
);
555 aCreateArgs
[nPos
].Name
= PROPERTY_BACKUPNAME
;
556 aCreateArgs
[nPos
++].Value
<<= ::rtl::OUString(m_Backup_File
);
561 m_aCreatorWait
= ::std::auto_ptr
<WaitObject
>(new WaitObject(this));
562 m_aCreatorThread
= ::std::auto_ptr
<ODatabaseCreator
>(new ODatabaseCreator(m_xCreateCatalog
,this,m_xORB
,aCreateArgs
));
563 m_aCreatorThread
->setTerminateHandler(LINK(this,OAdabasNewDbDlg
,TerminateHdl
));
564 m_aCreatorThread
->create();
568 //-------------------------------------------------------------------------
569 IMPL_LINK( OAdabasNewDbDlg
, TerminateHdl
, void*, /*NOTUSABLE*/ )
574 //------------------------------------------------------------------------
575 IMPL_LINK( OAdabasNewDbDlg
, LoseFocusHdl
, Edit
*, pEdit
)
577 if(&m_ET_SYSDEVSPACE
== pEdit
)
578 m_SYSDEV_File
= pEdit
->GetText();
579 else if(&m_ET_TRANSACTIONLOG
== pEdit
)
580 m_TRANSDEV_File
= pEdit
->GetText();
581 else if(&m_ET_DATADEVSPACE
== pEdit
)
582 m_DATADEV_File
= pEdit
->GetText();
583 else if(&m_ET_RESTORE
== pEdit
)
584 m_Backup_File
= pEdit
->GetText();
585 else if(&m_ET_DATABASENAME
== pEdit
)
586 {// check if the new dbname already exists
587 String sNewDbName
= pEdit
->GetText();
588 String sConfig
= m_sDbConfig
;
589 sConfig
.AppendAscii("config/");
590 sConfig
+= sNewDbName
;
591 if(UCBContentHelper::IsDocument(sConfig
))
593 String sErrorMessage
= String(ModuleRes(STR_ADABAS_DB_EXISTS
));
594 ErrorBox(this, WB_OK
, sErrorMessage
).Execute();
597 else if ( m_DBName
.SearchAscii(" ") != STRING_NOTFOUND
)
599 String sErrorMessage
= String(ModuleRes(STR_ADABAS_DB_EXISTS
));
600 ErrorBox(this, WB_OK
, sErrorMessage
).Execute();
601 m_DBName
= m_DBName
.GetToken(0,' ');
604 m_DBName
= sNewDbName
;
610 //------------------------------------------------------------------------
611 IMPL_LINK( OAdabasNewDbDlg
, LoadButtonClickHdl
, Button
*, /*pButton*/ )
613 ::sfx2::FileDialogHelper
aLoad(WB_3DLOOK
| WB_STDMODAL
| WB_OPEN
);
614 if(!m_Backup_File
.Len())
615 aLoad
.SetDisplayDirectory(SvtPathOptions().GetWorkPath());
617 aLoad
.SetDisplayDirectory(m_Backup_File
);
620 INetURLObject
aUrl(aLoad
.GetPath());
621 m_Backup_File
= aUrl
.PathToFileName();
622 if(m_Backup_File
.Len() > 40)
624 InfoBox
aInfo(this,ModuleRes(INFO_STR_MAX_FILE_LENGTH
));
625 String
aMsg(aInfo
.GetMessText());
626 aMsg
.SearchAndReplace(String::CreateFromAscii("\'#\'"),String::CreateFromAscii("40"));
627 aInfo
.SetMessText(aMsg
);
629 m_ET_RESTORE
.SetText(m_Backup_File
);
634 //------------------------------------------------------------------------
635 IMPL_LINK( OAdabasNewDbDlg
, ButtonClickHdl
, Button
*, pButton
)
637 WinBits
nBits(WB_3DLOOK
|WB_STDMODAL
|WB_SAVEAS
);
638 ::sfx2::FileDialogHelper
aFileDlg( static_cast<sal_uInt32
>(nBits
) ); // new FileDialog( this, nBits );
641 if(pButton
== &m_PB_SYSDEVSPACE
)
642 aPath
= m_SYSDEV_File
;
643 else if(pButton
== &m_PB_TRANSACTIONLOG
)
644 aPath
= m_TRANSDEV_File
;
645 else if(pButton
== &m_PB_DATADEVSPACE
)
646 aPath
= m_DATADEV_File
;
649 ::utl::LocalFileHelper::ConvertPhysicalNameToURL(aPath
,sUrl
);
650 aFileDlg
.SetDisplayDirectory(sUrl
);
654 if (aFileDlg
.Execute() == ERRCODE_NONE
)
656 INetURLObject
aUrl(aFileDlg
.GetPath());
657 if(pButton
== &m_PB_SYSDEVSPACE
)
659 m_SYSDEV_File
= aUrl
.PathToFileName();
660 if(m_SYSDEV_File
.Len() > 40)
662 InfoBox
aInfo(this,ModuleRes(INFO_STR_MAX_FILE_LENGTH
));
663 String
aMsg(aInfo
.GetMessText());
664 aMsg
.SearchAndReplace(String::CreateFromAscii("\'#\'"),String::CreateFromAscii("40"));
665 aInfo
.SetMessText(aMsg
);
669 m_ET_SYSDEVSPACE
.SetText(aUrl
.PathToFileName());
671 else if(pButton
== &m_PB_TRANSACTIONLOG
)
673 m_TRANSDEV_File
= aUrl
.PathToFileName();
674 if(m_TRANSDEV_File
.Len() > 40)
676 InfoBox
aInfo(this,ModuleRes(INFO_STR_MAX_FILE_LENGTH
));
677 String
aMsg(aInfo
.GetMessText());
678 aMsg
.SearchAndReplace(String::CreateFromAscii("\'#\'"),String::CreateFromAscii("40"));
679 aInfo
.SetMessText(aMsg
);
683 m_ET_TRANSACTIONLOG
.SetText(aUrl
.PathToFileName());
685 else if(pButton
== &m_PB_DATADEVSPACE
)
687 m_DATADEV_File
= aUrl
.PathToFileName();
688 if(m_DATADEV_File
.Len() > 40)
690 InfoBox
aInfo(this,ModuleRes(INFO_STR_MAX_FILE_LENGTH
));
691 String
aMsg(aInfo
.GetMessText());
692 aMsg
.SearchAndReplace(String::CreateFromAscii("\'#\'"),String::CreateFromAscii("40"));
693 aInfo
.SetMessText(aMsg
);
697 m_ET_DATADEVSPACE
.SetText(aUrl
.PathToFileName());
704 //------------------------------------------------------------------------
705 IMPL_LINK( OAdabasNewDbDlg
, PwdClickHdl
, Button
*, pButton
)
707 SfxPasswordDialog
aDlg(this);
708 aDlg
.ShowExtras(SHOWEXTRAS_CONFIRM
);
711 String sPwd
= aDlg
.GetPassword().ToUpperAscii();
712 // no space in password allowed
713 if ( sPwd
.GetTokenCount(' ') == 1 )
715 if(pButton
== &m_PB_CONPWD
)
720 else if(pButton
== &m_PB_SYSPWD
)
723 if(!m_DomainPwd
.Len())
726 m_DomainPwd
= m_SysPwd
;
735 else if(pButton
== &m_PB_DOMAINPWD
)
743 String
sErrorMsg(ModuleRes(STR_ADABAS_PASSWORD_ILLEGAL
));
744 ErrorBox(this, WB_OK
, sErrorMsg
).Execute();
750 //------------------------------------------------------------------------
751 void OAdabasNewDbDlg::CheckBitmaps()
754 if(m_ConPwd
.Len() && m_ET_CONUSR
.GetText().Len())
755 i
++,m_BMP_CON
.SetImage(ModuleRes(((m_nSetBitmap
& 2) == 2) ? DEFAULT_BLUE
: CHECK_GREEN
));
757 m_BMP_CON
.SetImage(ModuleRes(UNCHECK_RED
));
761 if(m_SysPwd
.Len() && m_ET_SYSUSR
.GetText().Len())
762 i
++,m_BMP_SYS
.SetImage(ModuleRes(CHECK_GREEN
));
764 m_BMP_SYS
.SetImage(ModuleRes(UNCHECK_RED
));
766 if(m_DomainPwd
.Len() )
767 i
++,m_BMP_DOMAIN
.SetImage(ModuleRes(((m_nSetBitmap
& 1) == 1) ? DEFAULT_BLUE
: CHECK_GREEN
));
769 m_BMP_DOMAIN
.SetImage(ModuleRes(UNCHECK_RED
));
771 else if(m_Backup_File
.Len())
774 if(m_ET_SYSDEVSPACE
.GetText().Len() && m_ET_TRANSACTIONLOG
.GetText().Len() && m_ET_DATADEVSPACE
.GetText().Len() &&
775 m_ET_SYSDEVSPACE
.GetText() != m_ET_TRANSACTIONLOG
.GetText() && m_ET_SYSDEVSPACE
.GetText() != m_ET_DATADEVSPACE
.GetText() &&
776 m_ET_DATADEVSPACE
.GetText() != m_ET_TRANSACTIONLOG
.GetText())
782 m_PB_OK
.Enable(i
== 5);
784 // -----------------------------------------------------------------------------
785 sal_Bool
OAdabasNewDbDlg::fillEnvironmentVariable(const ::rtl::OUString
& _sVariableName
,String
& _rsValue
)
787 rtl_uString
* pDbVar
= NULL
;
788 sal_Bool bError
= sal_False
;
789 if(osl_getEnvironment(_sVariableName
.pData
,&pDbVar
) == osl_Process_E_None
&& pDbVar
)
793 LocalFileHelper::ConvertPhysicalNameToURL(_rsValue
,sTemp
);
795 rtl_uString_release(pDbVar
);
799 osl::FileBase::RC rc
= osl::Directory::createPath(_rsValue
);
800 if(rc
!= osl::FileBase::E_None
&& rc
!= osl::FileBase::E_EXIST
)
803 PostUserEvent(LINK(this, OAdabasNewDbDlg
, OnError
));
808 // -----------------------------------------------------------------------------