/*:VRX Main
*/
/* Samba Setup and Configuration Center (SSCC)
Copyright (C) 2007-2017 Herwig Bauernfeind for bww bitwise works GmbH.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
/* Main
*/
Main:
/* Process the arguments.
Get the parent window.
*/
parse source . calledAs .
parent = ""
argCount = arg()
argOff = 0
if( calledAs \= "COMMAND" )then do
if argCount >= 1 then do
parent = arg(1)
argCount = argCount - 1
argOff = 1
end
end; else do
call VROptions 'ImplicitNames'
call VROptions 'NoEchoQuit'
end
InitArgs.0 = argCount
if( argCount > 0 )then do i = 1 to argCount
InitArgs.i = arg( i + argOff )
end
drop calledAs argCount argOff
/* Load the windows
*/
call VRInit
parse source . . spec
_VREPrimaryWindowPath = ,
VRParseFileName( spec, "dpn" ) || ".VRW"
_VREPrimaryWindow = ,
VRLoad( parent, _VREPrimaryWindowPath )
drop parent spec
if( _VREPrimaryWindow == "" )then do
call VRMessage "", "Cannot load window:" VRError(), ,
"Error!"
_VREReturnValue = 32000
signal _VRELeaveMain
end
/* Process events
*/
call Init
signal on halt
do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
_VREEvent = VREvent()
interpret _VREEvent
end
_VREHalt:
_VREReturnValue = Fini()
call VRDestroy _VREPrimaryWindow
_VRELeaveMain:
call VRFini
exit _VREReturnValue
VRLoadSecondary:
__vrlsWait = abbrev( 'WAIT', translate(arg(2)), 1 )
if __vrlsWait then do
call VRFlush
end
__vrlsHWnd = VRLoad( VRWindow(), VRWindowPath(), arg(1) )
if __vrlsHWnd = '' then signal __vrlsDone
if __vrlsWait \= 1 then signal __vrlsDone
call VRSet __vrlsHWnd, 'WindowMode', 'Modal'
__vrlsTmp = __vrlsWindows.0
if( DataType(__vrlsTmp) \= 'NUM' ) then do
__vrlsTmp = 1
end
else do
__vrlsTmp = __vrlsTmp + 1
end
__vrlsWindows.__vrlsTmp = VRWindow( __vrlsHWnd )
__vrlsWindows.0 = __vrlsTmp
do while( VRIsValidObject( VRWindow() ) = 1 )
__vrlsEvent = VREvent()
interpret __vrlsEvent
end
__vrlsTmp = __vrlsWindows.0
__vrlsWindows.0 = __vrlsTmp - 1
call VRWindow __vrlsWindows.__vrlsTmp
__vrlsHWnd = ''
__vrlsDone:
return __vrlsHWnd
/*:VRX __VXREXX____APPENDS__
*/
__VXREXX____APPENDS__:
/*
#append ..\shared\swat.vrs
#append ..\shared\nlv.vrs
#append ..\shared\inittempdir.vrs
#append ..\shared\sambainit.vrs
#append ..\shared\masterpasswd.vrs
*/
return
/*:VRX _ActiveGroup
*/
_ActiveGroup:
ActiveGroup = translate(arg(1))
ActiveGroupObj = VRGet("GB_"ActiveGroup, "Self")
ok = VRset(ActiveGroupObj, "Visible", 1)
return
/*:VRX _bs2fs
*/
_bs2fs: procedure
string = arg(1)
return translate(string,'/','\')
/*:VRX _CfgPageSetupSize
*/
_CfgPageSetupSize:
if arg(1) = "GB_Global"
then ok = VRset(arg(1), "Top", 0)
else ok = VRset(arg(1), "Top", Fwidth)
ok = VRset(arg(1), "Left",VRGet("GB_SmbConfTree","Width") + 60)
if arg(1) = "GB_Global"
then ok = VRset(arg(1), "Height",VRGet("GB_SmbConfTree","height")+FWidth)
else ok = VRset(arg(1), "Height",VRGet("GB_SmbConfTree","height"))
ok = VRset(arg(1), "Width", VRGet("Main", "Width") - VRGet("GB_SmbConfTree","width") - 60- FWidth*2-24*2)
return
/*:VRX _ChooseDir
*/
_ChooseDir:
Invoked = VRInfo("Object")
InitDir = VRGet("EF_"||substr(VRGet(Invoked, "name"),5),"Value")
if pos('\\',InitDir) > 0 then do
Msg.Text = NLVGetMessage(63,InitDir)
Msg.Type = "E"
call _ShowMsg
return
end
VarPos = pos('%', InitDir)
if VarPos > 0 then do
VarChar = substr(InitDir,VarPos,2)
InitDir = left(InitDir,VarPos-1)
say VarChar
end
NewPath = _dirDialog('Choose path for 'VRGet("DT_Shares","Caption"),_fs2bs(InitDir))
if NewPath = "" then return
if VarPos > 0 then NewPath = NewPath'\'VarChar
ok = VRset("EF_"||substr(VRGet(Invoked, "name"),5),"value",NewPath)
return
/*:VRX _CreateVocObject
*/
_CreateVocObject:
IF options.!debug == 1 THEN say "_CreateVocObject() started"
If VRIsValidObject(VocObjType"_"upVoc ) then Success = 1
else do
/* Creative descriptive text */
Objs = Objs + 1
Voc.V = translate(left(Voc.V,1))||substr(Voc.V,2)
CreatedObjs.Objs = VRCreate(ActiveGroupObj, "DescriptiveText", "Name", "DT_"upVoc, 'Caption', Voc.V, "Top", ObjYPos+50 , "Left", 120+72, "Visible", 1, "AutoSize", 1)
select
when pos("\\",Val.V) > 0 then nop
when pos(" dir",Voc.V) > 0 then ok = VRSet(CreatedObjs.Objs, "Forecolor", "Black")
when pos("file",Voc.V) > 0 then ok = VRSet(CreatedObjs.Objs, "Forecolor", "Black")
when pos("path",Voc.V) > 0 then ok = VRSet(CreatedObjs.Objs, "Forecolor", "Black")
otherwise nop /* do not beautify */
end
DT_Handle = CreatedObjs.Objs
/* The CB or EF */
Objs = Objs + 1
select
when VocObjType = "CB" then do
CreatedObjs.Objs = VRCreate(ActiveGroupObj, "Checkbox", "Name", VocObjType"_"upVoc, "Top", ObjYPos+30, "AutoSize", 1)
ok = VRSet(VocObjType"_"upVoc, "Click", "call _ShareObject_Changed")
end
otherwise do
CreatedObjs.Objs = VRCreate(ActiveGroupObj, "EntryField", "Name", VocObjType"_"upVoc, "Top", ObjYPos , "Width", 2800, "Height", "253")
ok = VRSet(VocObjType"_"upVoc, "Change", "call _ShareObject_Changed")
end
end
Success = (CreatedObjs.OBjs <> "")
if Success then do /* SUccess */
ok = VRSet(VocObjType"_"upVoc, "Left", max(1500, 120*2+VRGet(DT_handle,"Width")))
if VocObjType = "EF" & upCurSection ="GLOBAL" then do
OWidth = 2800-max(0,VRGet(VocObjType"_"upVoc, "Left")-1500)
if datatype(Val.V) = "NUM" then OWidth = length(Val.V)*90+200
else OWidth = length(Val.V)*90+440
if Val.V = "" then OWidth = 1500
ok = VRSet(VocObjType"_"upVoc, "Width", OWidth)
if (pos("_DIRECTORY",upVoc) > 0 | pos("_PATH",upVoc) > 0) & pos("MODE",upVoc) = 0 & pos("MASK",upVoc) = 0 then do
Objs = Objs + 1
CreatedObjs.Objs = VRCreate(ActiveGroupObj, "ImagePushButton", "Name", "IPB_"upVoc, "Top", ObjYPos+30, "AutoSize", 0 , "PicturePath", "#2;#3", "Left", VRGet(VocObjType"_"upVoc,"Left")+VRGet(VocObjType"_"upVoc,"Width")+72)
ok = VRSet("IPB_"upVoc, "Click", "call _ChooseDir")
ok = VRSet("IPB_"upVoc,"Width" ,VRMethod( "Screen", "PixelsToTwips", 20 ))
ok = VRSet("IPB_"upVoc,"Height",VRMethod( "Screen", "PixelsToTwips", 20 ))
end
end
/* ok = VRSet(VocObjType"_"upVoc, "BackColor", "Red") */
ok = VRSet(VocObjType"_"upVoc, "Visible", 1)
CreatedObjs.0 = Objs
ObjYPos= ObjYPos + ObjDelta
end
else do
say "Failed to Create "||VocObjType"_"upVoc||' in 'ActiveGroupObj
end
end
IF options.!debug == 1 THEN say ' Object: "'VocObjType'_'upVoc'" Value: "'Val.V'" Handle:"'CreatedObjs.Objs'"'
IF options.!debug == 1 THEN say "_CreateVocObject() done"
return Success
/*:VRX _DebugLog
*/
_DebugLog:
IF options.!debug <> 1 THEN return
debugline = strip(arg(1))
if pos("started", debugline) > 0 |,
pos("aborted", debugline) > 0 |,
pos("done", debugline) > 0
then say time()' 'debugline
else say ' 'debugline
return
/*:VRX _dirdialog
*/
_DirDialog: procedure
Title = arg(1)
InitDir = arg(2)
RC = RxFuncQuery("DRCtrlPickDirectory")
if RC = 0 then do /* use DrCtrl if available */
MyDir=DRCtrlPickDirectory(InitDir, Title)
end
else do
MyDir = VRFileDialog(VRWindow,Title, 'o', InitDir||'\dummy')
if MyDir <> '' then MyDir = strip(filespec('D',MyDir)||Filespec('P',MyDir),'T','\')
end
return MyDir
/*:VRX _FindIBMLANPath
*/
_FindIBMLANPath:
say '_FindIBMLANPath() started.'
ibmlanini = SysBootDrive()'\IBMLAN\IBMLAN.INI'
ibmlaniniexists = VRFileExists(ibmlanini)
say ' Does "'ibmlanini'" exist? 'ibmlaniniexists' (1=Yes, 0=No)'
lsshareini = SysBootDrive()'\IBMLAN\LSSHARE.INI'
lsshareiniexists = VRFileExists(lsshareini)
say ' Does "'lsshareini'" exist? 'lsshareiniexists' (1=Yes, 0=No)'
say '_FindIBMLANPath() done.'
return
/*:VRX _fs2bs
*/
_fs2bs: procedure
string = arg(1)
return translate(string,'\','/')
/*:VRX _GroupCreate
*/
_GroupCreate:
/* Create kLIBC group file */
ok = SysFileDelete(samba.!group)
call lineout samba.!group, '# Created by SSCC ver. 'word(VRGet("Main","Hinttext"),2)
call lineout samba.!group, '# syntax:'
call lineout samba.!group, '# groupname:password:GID:user[,user,...,]'
call lineout samba.!group, 'admin:*:512:root,'
call lineout samba.!group, 'users:*:513:'
call lineout samba.!group, 'guests:*:514:'
call lineout samba.!group, 'machines:*:515:'
call lineout samba.!group, 'dc:*:516:'
call lineout samba.!group, 'certadmin:*:517:'
call lineout samba.!group, 'schemeadmin:*:518:'
call lineout samba.!group, 'entadmin:*:519:'
call lineout samba.!group, 'poladmin:*:520:'
ok = stream(samba.!group,'c','close')
return
/*:VRX _GUIInit
*/
_GUIInit:
if datatype(Top) = 'NUM' then do
ok = VRset("Main","Top",Top)
ok = VRset("Main","Left",Left)
ok = VRset("Main","Width",Width)
ok = VRset("Main","Height",Height)
end
else ok = VRset("Main","Width", 9250)
settings.!curfcolor = VRGetIni('PM_Default_Colors', 'ActiveTitleText', 'User', 'NoClose')
settings.!curbcolor = VRGetIni('PM_Default_Colors', 'ActiveTitleTextBgnd', 'User')
ok = VRSet("DT_SmbConfTree","BACKCOLOR", settings.!curbcolor )
ok = VRSet("DT_SmbConfTree","FORECOLOR", settings.!curfcolor )
ok = VRSet("EF_Binaries_Version","value",samba.!version)
ok = VRSet("EF_Binaries_Path","value",samba.!bin)
ok = VRSet("EF_Scripts_Path","value",samba.!tools)
ok = VRSet("EF_UnixRoot_Path","value",UnixRoot)
ok = VRSet("EF_ETC_Path","value",ETC)
ok = VRSet("CN_SmbConf","Caption", smbconf)
ok = VRSet("IPB_ChooseDir","Width" ,VRMethod( "Screen", "PixelsToTwips", 20 ))
ok = VRSet("IPB_ChooseDir","Height",VRMethod( "Screen", "PixelsToTwips", 20 ))
ok = VRSet("IPB_NewItem","Width" ,VRMethod( "Screen", "PixelsToTwips", 20 ))
ok = VRSet("IPB_NewItem","Height",VRMethod( "Screen", "PixelsToTwips", 20 ))
ok = VRSet("Menu_File_Import_IBMPeer", "Enabled", lsshareiniexists * ibmlaniniexists )
ok = VRSet("Menu_Options_MiniIcons","Checked", \advanced.!bigicons)
ok = VRset("CN_smbconf","MiniIcons", \advanced.!bigicons)
if _ChkTempFreeSpace() < 262144 then do
Msg.Type = "W"
Msg.Text = NLVGetMessage(116, TempDir)
call _ShowMsg
end
ok = VRSet("Menu_File_PrintCap","Enabled", \IsCupsPrintcap)
if \IsCupsPrintcap then call _PrintCapCreate
stst = NLVGetMessage(15)
parse var stst startst '/' stopst
if _SambaRunning() then do
ok = VRSet("PB_StartStop", "BackColor", "Red")
ok = VRSet("PB_StartStop", "Caption", stopst)
end
else do
ok = VRSet("PB_StartStop", "BackColor", "Green")
ok = VRSet("PB_StartStop", "Caption", startst)
end
if SmbConfExists then call _SmbConfLoad
else ok = VRSet("TM_Installer","Enabled", 1)
return
/*:VRX _GUIInitNLV
*/
_GUIInitNLV:
say '_GUIInitNLV started'
settings.!helpfile = 0
CALL NLVSetup
CALL NLVSetText 'Main', 'Caption', 1
Msg.Title = VRGet("Main", "Caption")
CALL NLVSetText 'PB_Reload', 'Caption', 11
CALL NLVSetText 'PB_Reload', 'Hinttext', 111
CALL NLVSetText 'PB_Save', 'Caption', 12
CALL NLVSetText 'PB_Save', 'Hinttext', 112
CALL NLVSetText 'PB_StartStop', 'Caption', 15
CALL NLVSetText 'PB_StartStop', 'Hinttext', 113
CALL NLVSetText 'PB_Undo', 'Caption', 9
CALL NLVSetText 'PB_Undo', 'Hinttext', 109
CALL NLVSetText 'PB_Cancel', 'Caption', 10
CALL NLVSetText 'PB_Cancel', 'Hinttext', 110
CALL NLVSetText 'PB_Help', 'Caption', 4
CALL NLVSetText 'PB_Help', 'Hinttext', 104
CALL NLVSetText 'PB_Add_Voc_OK', 'Caption', 2
CALL NLVSetText 'PB_Add_Voc_OK', 'Hinttext', 102
CALL NLVSetText 'PB_Add_Voc_Cancel','Caption', 3
CALL NLVSetText 'PB_Add_Voc_Cancel','Hinttext', 103
CALL NLVSetText 'Menu_File', 'Caption', 21
CALL NLVSetText 'Menu_Options', 'Caption', 22
CALL NLVSetText 'Menu_Help', 'Caption', 23
CALL NLVSetText 'Menu_File_Import_IBMPeer', 'Caption', 24
CALL NLVSetText 'Menu_File_Reset', 'Caption', 25
CALL NLVSetText 'Menu_File_Debug', 'Caption', 26
CALL NLVSetText 'Menu_File_ImportHosts', 'Caption', 36
CALL NLVSetText 'Menu_File_PrintCap', 'Caption', 37
CALL NLVSetText 'Menu_File_SmbUpdate', 'Caption', 44
CALL NLVSetText 'Menu_File_YumInstall', 'Caption', 99
CALL NLVSetText 'Menu_File_Exit', 'Caption', 27
CALL NLVSetText 'Menu_Options_SimpleMode', 'Caption', 28
CALL NLVSetText 'Menu_Options_ExportMode', 'Caption', 29
CALL NLVSetText 'Menu_Options_MiniIcons', 'Caption', 74
CALL NLVSetText 'Menu_Help_smbconf', 'Caption', 30
CALL NLVSetText 'Menu_Help_About', 'Caption', 31
CALL NLVSetText 'Menu_Action', 'Caption', 32
CALL NLVSetText 'Menu_Action_AddHomes', 'Caption', 33
CALL NLVSetText 'Menu_Action_AddNetlogon', 'Caption', 34
CALL NLVSetText 'Menu_Action_AddProfiles', 'Caption', 35
CALL NLVSetText 'Menu_Action_AddProfiles', 'Caption', 35
CALL NLVSetText 'Menu_Action_EraseTransient','Caption', 47
CALL NLVSetText 'Menu_ShareContext_AddPrinter', 'Caption', 40
CALL NLVSetText 'Menu_ShareContext_Add', 'Caption', 41
CALL NLVSetText 'Menu_ShareContext_RemovePrinter','Caption', 42
CALL NLVSetText 'Menu_ShareContext_Remove', 'Caption', 43
CALL NLVSetText 'Menu_ShareContext_RenamePrinter','Caption', 48
CALL NLVSetText 'Menu_ShareContext_Rename', 'Caption', 49
CALL NLVSetText 'DT_Help', 'Caption', 80
CALL NLVSetText 'DT_Heading', 'Caption', 81
CALL NLVSetText 'DT_Binaries_Version', 'Caption', 82
CALL NLVSetText 'DT_Binaries_Path', 'Caption', 83
CALL NLVSetText 'DT_Scripts_Path', 'Caption', 84
/* CALL NLVSetText 'DT_SmbConfTree', 'Caption', 73 */
say NLVGetMessage(73)
ok = VRSet("DT_SmbConfTree","Caption", NLVGetMessage(73))
Drive = NLVGetMessage(38)
say '_GUIInitNLV done'
return
/*:VRX _INIRead
*/
_INIRead:
IF options.!debug == 1 THEN say '_INIRead() started'
OurINI = strip(VRParseFileName(VRget("Application","Program"),'DP')'\SSCC.INI',,'\')
ok = SysFileTree(OurINI, INIFound.,'FO')
if INIFound.0 = 1 then OurINI = VRParseFileName(INIFound.1,'DPNE')
say 'OurINI ='OurINI
Top = VRGetIni( "Pos", "Top", OurINI , 'NoClose')
Left = VRGetIni( "Pos", "Left", OurINI , 'NoClose')
Width = VRGetIni( "Pos", "Width", OurINI , 'NoClose')
Height= VRGetIni( "Pos", "Height", OurINI , 'NoClose')
options.!debug = VRGetIni( "Options", "Debug", OurINI, 'NoClose')
if options.!debug = "" then options.!debug = 0
ok = VRSet("Menu_File_Debug","Checked",options.!Debug)
if options.!Debug then ok = VRREdirectStdIO("ON")
else ok = VRREdirectStdIO("OFF")
options.!builddir = VRGetIni( "Options", "BuildDir", OurINI, 'NoClose')
if options.!builddir = "" then options.!builddir = ""
advanced.!bigicons = VRGetIni( "Options", "BigIcons", OurINI)
if advanced.!bigicons = "" then advanced.!bigicons = 1
/* Initialize several variables */
indent = '09'x
ManageDaemons = 1
/* these were formerly defined in smb.conf */
CreatedObjs.0 = 0
ChangeList = ""
ValueChanged = 0
CurSection = ""
CreatedObjs.0 = 0
ActiveGroup = "Global"
InstallMode = 0 /* Normally 0 for configure mode, /Install switch overrides this */
UseTDBSam = 0 /* only for installermode */
CreatePDC = 0 /* only for installermode */
FWidth = 32
IF options.!debug == 1 THEN say '_INIRead() done'
return
/*:VRX _INIWrite
*/
_INIWrite:
ok = VRSetIni( "Pos", "Top", VRGet("Main","Top"), OurINI, 'NoClose')
ok = VRSetIni( "Pos", "Left", VRGet("Main","Left"), OurINI, 'NoClose')
ok = VRSetIni( "Pos", "Width", VRGet("Main","Width"), OurINI, 'NoClose')
ok = VRSetIni( "Pos", "Height", VRGet("Main","Height"), OurINI, 'NoClose')
ok = VRSetIni( "Options", "BuildDir", options.!builddir, OurINI, 'NoClose')
ok = VRSetIni( "Options", "Debug", options.!debug, OurINI, 'NoClose')
ok = VRSetIni( "Options", "BigIcons", \VRGet("Menu_Options_MiniIcons","Checked"),OurINI)
return
/*:VRX _InstallerMode
*/
_InstallerMode:
ok = VRSet("Main", "Visible", 1)
window = VRLoadSecondary( "Installer", "W" )
ok = VRSet("Main", "Visible", 1)
return
/*:VRX _LMHostsImport
*/
_LMHostsImport:
hosts = ETC'\hosts'
lmhosts = ETC'\samba\lmhosts'
ok = SysFileDelete(lmhosts)
call lineout lmhosts,'# Created by SSCC ver. 'word(VRGet("Main","Hinttext"),2)' on 'date()' at 'time()
call lineout lmhosts,'# Syntax:'
call lineout lmhosts,'# IP-address NetBIOS-name'
do until lines(hosts) = 0
hostsline = linein(hosts)
parse var hostsline IP FQDN Alias
parse var FQDN hostname'.'domain
if IP <> '127.0.0.1' then do
say left(IP, 25)||hostname
call lineout lmhosts, left(IP, 25)||hostname
end
end
ok = stream(hosts,'c','close')
ok = stream(lmhosts,'c','close')
Msg.Text = NLVGetMessage(50, lmhosts)
msg.Type = 'I'
call _ShowMsg
return
/*:VRX _LoadOtherFuncs
*/
_LoadOtherFuncs:
if options.!Debug = 1
then ok = VRREdirectStdIO("ON")
else ok = VRREdirectStdIO("OFF")
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
call rxfuncadd 'IniLoadFuncs', 'REXXINI', 'IniLoadFuncs'
call IniLoadFuncs
call RxFuncAdd 'PRLoadFuncs', 'PR1UTIL', 'PRLoadFuncs'
call PRLoadFuncs
/* Deal with DRCtrlxxx */
RC = RxFuncQuery("DRCtrlPickDirectory")
if RC = 1 then do /* DRCtrlXXX not already registered */
/* Load DRCtrl functions */
ok = RxFuncAdd('DRCtrlLoadFuncs', 'drctl017', 'DRCtrlLoadFuncs')
if ok = 0 then CALL DRCtrlLoadFuncs
end
return
/*:VRX _MsgYesNo
*/
_MsgYesNo:
IF options.!debug == 1 THEN say '_MsgYesNo() started'
IF options.!debug == 1 THEN say ' Msgbox:"'Msg.Text'"'
buttons.0 = 2
buttons.1 = NLVGetMessage('6')
buttons.2 = NLVGetMessage('7')
default = 2
buttons.default = buttons.2
esc = 2
buttons.esc = buttons.2
RC = VRMessage( VRWindow(), Msg.Text, Msg.Title,"Q","buttons.",default, esc )
IF options.!debug == 1 THEN say ' Answer: 'RC' ( 1 = Yes, 2 = No)'
IF options.!debug == 1 THEN say '_MsgYesNo() done'
return RC
/*:VRX _MyIniEnum
*/
_MyIniEnum: procedure expose sections. Voc. Val. options.
call _debugLog "_MyIniEnum() started."
CurSection = arg(1)
do I = 1 to sections.0
say I':'sections.I
if sections.I = Cursection then leave
end
if I <= sections.0 then do
say 'sections.'I'.0='sections.I.0
Voc.0 = sections.I.0
Val.0 = sections.I.0
do J = 1 to Voc.0
parse var sections.I.J Voc.J'='Val.J
Voc.J = strip(Voc.J)
Val.J = strip(Val.J)
end
end
call _debugLog "_MyIniEnum() done."
return
/*:VRX _MyIniEnumSections
*/
_MyIniEnumSections: procedure expose sections. options.
call _DebugLog '_MyIniEnumSections() started'
smbconf = arg(1)
sections. = ""
I = 0
J = 0
do until lines(smbconf) = 0
smbconfline = strip(translate(linein(smbconf),' ','09'x))
select
when left(smbconfline,1) =' ' then nop /* empty line */
when left(smbconfline,1) =';' then nop /* Comment */
when left(smbconfline,1) ='#' then nop /* Comment */
when left(smbconfline,1) ='[' then do /* Section */
sections.I.0 = J
I = I + 1
J = 0
parse var smbconfline '['CurSection']'
sections.I = CurSection
say ' 'CurSection
end
otherwise do /* Option */
parse var smbconfline option'='value
J = J + 1
sections.I.J = smbconfline
option = translate(strip(option),'_!?',' :$')
value = strip(value)
OptStr = CurSection'.'option'="'Value'"'
/* say OptStr */
end
end
end
sections.0 = I
sections.I.0 = J
ok = stream(smbconf,'c','close')
call _DebugLog '_MyIniEnumSections() done.'
return
/*:VRX _NLVSetup
*/
_NLVSetup:
call NLVSetup
RETURN
/*:VRX _ParseCommandLine
*/
_ParseCommandLine:
IF options.!debug == 1 THEN SAY "_ParseCommandLine() started"
CmdLine = VRGet("Application","Commandline")
IF options.!debug == 1 THEN SAY ' original commandline ="'CmdLine'"'
upCmdLine = translate(CmdLine)
InstPos = pos('/INSTALL',upCmdLine)
if InstPos > 0 then do
IF options.!debug == 1 THEN SAY " /install switch detected"
InstallMode = 1
end
IF options.!debug == 1 THEN SAY "_ParseCommandLine() done"
return
/*:VRX _PrintCapCreate
*/
_PrintCapCreate:
ok = SysFileDelete(samba.!printcap)
ok = SysIni('SYSTEM', 'PM_SPOOLER_QUEUE_DESCR', 'ALL:','printers.')
call lineout samba.!printcap, '# Created by SSCC ver. 'word(VRGet("Main","Hinttext"),2)' on 'date()' at 'time()
call lineout samba.!printcap, '# syntax:'
call lineout samba.!printcap, '# Printerqueue|printername'
do I = 1 to printers.0
queue = printers.I
name = strip(strip(SysIni('SYSTEM', 'PM_SPOOLER_QUEUE_DESCR', printers.I),'T','00'x),,';')
call lineout samba.!printcap, queue'|'name
end
ok = stream(samba.!printcap,'c','close')
return
/*:VRX _SambaCheckComponents
*/
_SambaCheckComponents:
IF options.!debug == 1 THEN say '_SambaCheckComponents() started'
/* set deprecated variables */
smbconf = samba.!smbconf
printcap = samba.!printcap
/* detect presence of several components and act accordingly */
SmbConfExists = VRFileExists(samba.!smbconf)
IF options.!debug == 1 THEN say ' Does "'smbconf'" exist? 'SmbConfExists' (1=Yes, 0=No)'
IsCupsPrintcap = 0
if VRFileExists(samba.!printcap) then do
printcapline = translate(linein(samba.!printcap))
if pos("CUPS",printcapline) > 0 then IsCupsPrintcap = 1
ok = stream(samba.!printcap,'c','close')
end
IF options.!debug == 1 THEN say ' Is printcap from CUPS? 'IsCupsPrintcap' (1=Yes, 0=No)'
if \VRFileExists(samba.!smbcmd) then do
Msg.Title = NLVGetMessage('1')
Msg.Type = "E"
Msg.Text = NLVGetMessage(53, samba.!smbcmd)' - 'NLVGetMessage(55)
call _ShowMsg
ManageDaemons = 0
end
IF options.!debug == 1 THEN say ' Is "'samba.!smbcmd'" present, able to manage daemons = 'ManageDaemons' (1=Yes, 0=No)'
if \VRFileExists(samba.!testparmexe) then do
Msg.Title = NLVGetMessage('1')
Msg.Text = NLVGetMessage(53,samba.!testparmexe)' - 'NLVGetMessage(54)
Msg.Type = "E"
call _ShowMsg
call Quit
end
IF options.!debug == 1 THEN say ' Is "'samba.!testparmexe'" present, continuing.'
if \VRFileExists(samba.!smbpasswdexe) then do
Msg.Title = NLVGetMessage('1')
Msg.Text = NLVGetMessage(53,samba.!smbpasswdexe)' - 'NLVGetMessage(54)
Msg.Type = "E"
call _ShowMsg
call Quit
end
IF options.!debug == 1 THEN say ' Is "'samba.!smbpasswdexe'" is present, continuing.'
if SmbConfExists then do
call _SmbConfBackup
if InstallMode then do
window = VRLoadSecondary( "RemoveConfig", "W" )
end
end
if \VRFileExists(swatusers) & swatauth = 1 & InstallMode = 0 then do
Msg.Text = NLVGetMessage(115, swatusers)
Msg.Type = "W"
call _ShowMsg
end
IF options.!debug == 1 THEN say ' Does "'samba.!smbconf'" still exist? 'SmbConfExists' (1=Yes, 0=No)'
IF options.!debug == 1 THEN say ' Running in InstallMode = 'InstallMode' (1=Yes, 0=No)'
IF options.!debug == 1 THEN say '_SambaCheckComponents() done'
return
/* Msg.Text = NLVGetMessage(56, samba.!smbconf)
Msg.Type = "Q"
ok = _MsgYesNo()
if ok = 1 then do
ok = SysFileDelete(samba.!smbconf)
SmbConfExists = 0
Msg.Text = "Also reinitialize backend?" /* NLVGetMessage(56, samba.!smbconf) */
Msg.Type = "Q"
ok = _MsgYesNo()
if ok = 1 then do
ok = SysFileTree(ETC"\samba\*.?db",xdb.,'FOS')
do I = 1 to xdb.0
ok = SysFileDelete(xdb.I)
if ok <> 0 then do
Msg.Text = "Error "ok" deleting "xdb.I"!"
Msg.Type = "W"
call _ShowMsg
end
end
end
end
else InstallMode = 0
*/
/*:VRX _SambaGroupMapInst
*/
_SambaGroupMapInst:
IF options.!debug == 1 THEN SAY "_SambaGroupMapInst() started"
/* These group mappings are obligatory */
IF options.!debug == 1 THEN SAY " Mapping Required domain groups"
address cmd samba.!netexe' groupmap add rid=512 ntgroup="Domain Admins" unixgroup="admin" type=domain comment="Domain Administrators"'
address cmd samba.!netexe' groupmap add rid=513 ntgroup="Domain Users" unixgroup="users" type=domain comment="Domain Users"'
address cmd samba.!netexe' groupmap add rid=514 ntgroup="Domain Guests" unixgroup="guests" type=domain comment="Domain Guests"'
/* These group mappings are optional */
IF options.!debug == 1 THEN SAY " Mapping Optional domain groups"
address cmd samba.!netexe' groupmap add rid=515 ntgroup="Domain Computers" unixgroup="machines" type=domain comment="Domain Computers"'
address cmd samba.!netexe' groupmap add rid=516 ntgroup="Domain Controllers" unixgroup="dc" type=domain comment="Domain Controllers"'
address cmd samba.!netexe' groupmap add rid=517 ntgroup="Domain Certificate Admins" unixgroup="certadmin" type=domain comment="Domain Certificate Administrators"'
address cmd samba.!netexe' groupmap add rid=518 ntgroup="Domain Schema Admins" unixgroup="schemeadmin" type=domain comment="Domain Schema Administrators"'
address cmd samba.!netexe' groupmap add rid=519 ntgroup="Domain Enterprise Admins" unixgroup="entadmin" type=domain comment="Domain Enterprise Administrators"'
address cmd samba.!netexe' groupmap add rid=520 ntgroup="Domain Policy Admins" unixgroup="poladmin" type=domain comment="Domain Policy Administrators"'
/* The following ones are unsupported at the moment - use at your own risk */
/*
IF options.!debug == 1 THEN SAY say " Mapping Builtin groups"
address cmd samba.!netexe' groupmap add rid=544 ntgroup="Builtin Admins" unixgroup="ntadmin" type=builtin
address cmd samba.!netexe' groupmap add rid=545 ntgroup="Builtin Users" unixgroup="ntusers" type=builtin
address cmd samba.!netexe' groupmap add rid=546 ntgroup="Builtin Guests" unixgroup="ntguests" type=builtin
address cmd samba.!netexe' groupmap add rid=547 ntgroup="Builtin Power Users" unixgroup="" type=builtin
address cmd samba.!netexe' groupmap add rid=548 ntgroup="Builtin Account Operators" unixgroup="" type=builtin
address cmd samba.!netexe' groupmap add rid=549 ntgroup="Builtin System Operators" unixgroup="operator" type=builtin
address cmd samba.!netexe' groupmap add rid=550 ntgroup="Builtin Print Operators" unixgroup="lp" type=builtin
address cmd samba.!netexe' groupmap add rid=551 ntgroup="Builtin Backup Operators" unixgroup="backup" type=builtin
address cmd samba.!netexe' groupmap add rid=552 ntgroup="Builtin Replicator" unixgroup="" type=builtin
address cmd samba.!netexe' groupmap add rid=553 ntgroup="Builtin RAS Servers" unixgroup="" type=builtin
*/
IF options.!debug == 1 THEN SAY "_SambaGroupMapInst() done"
return
/*:VRX _SambaGuestCreate
*/
_SambaGuestCreate:
IF options.!debug == 1 THEN say "_SambaGuestCreate() started"
IF options.!debug == 1 THEN say ' 'samba.!smbpasswdexe' -a guest -n'
samba.!smbpasswdexe' -a guest -n -D 0 2>'samba.!error' 1>'samba.!message
if rc = 0 then call _SambaShowMsg
else call _SambaShowError
IF options.!debug == 1 THEN say "_SambaGuestCreate() done"
return
/*:VRX _SambaRootPWCheck
*/
_SambaRootPWCheck:
call _debugLog "_SambaRootPWCheck() started "
if VRGet("EF_RootPassword","Value") ="" then do
Msg.type = "E"
Msg.Text = NLVGetMessage(57, "root")
call _ShowMsg
call _debugLog "_SambaRootPWCheck() done, RC = 0 "
return 0
end
if VRGet("EF_RootPassword_repeat","Value") ="" then do
Msg.type = "E"
Msg.Text = NLVGetMessage(58,"root")
call _ShowMsg
call _debugLog "_SambaRootPWCheck() done, RC = 0 "
return 0
end
if VRGet("EF_RootPassword","Value") <> VRGet("EF_RootPassword_repeat","Value") then do
Msg.type = "E"
Msg.Text = NLVGetMessage(59, "root")
call _ShowMsg
call _debugLog "_SambaRootPWCheck() done, RC = 0 "
return 0
end
call _debugLog "_SambaRootPWCheck() done, RC = 1 "
return 1
/*:VRX _SambaRootPWSet
*/
_SambaRootPWSet:
call _DebugLog "_SambaRootPWSet() started"
/* Write root password to a temp file */
pwdfile = TempDir'newpwd'
call lineout pwdfile, VRGet("EF_RootPassword","value")
call lineout pwdfile, VRGet("EF_RootPassword","value")
ok = stream(pwdfile,"c","close")
/* update Master.passwd and (s)pwd.db */
call _MasterPasswdRead
nx = _MasterPasswdFindUser("root")
call rxFuncAdd "Crypt", "RxCrypt", "RxCrypt"
itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
salt = ""
do i = 1 to 8
salt = salt || substr( itoa64, random( 0, 63 ) + 1, 1 )
end
password.nx = Crypt(VRGet("EF_RootPassword","Value"), salt )
/* we need this otherwise _MasterPasswdWrite does not work */
settings.!FixErrors = 1
call _MasterPasswdWrite
call _PasswordDbRewrite
/* Create the root account */
IF options.!debug == 1 THEN say ' 'samba.!smbpasswdexe' -a root -s <'pwdfile
samba.!smbpasswdexe' -a root -s -D 0 <'pwdfile' 2>'samba.!error' 1>'samba.!message
if rc = 0 then call _SambaShowMsg
else call _SambaShowError
/* Remove the temp password file */
ok = SysFileDelete(pwdfile)
/* Deal with swat */
/* We could use rxcrypt.dll however htpasswd.exe (at least in theory) is more flexible regarding encryption */
if swatauth then do
/* we always remove the old swat */
say ' 'samba.!htpasswdexe' -D "'swatusers'" root'
address cmd samba.!htpasswdexe' -D "'swatusers'" root' /* ' 2>'samba.!error' 1>'samba.!msg
if rc <> 0 then call _SambaShowError; else call _SambaShowMsg */
if VRFileExists(swatusers) then cFlag = ""; else cFlag="c"
say ' 'samba.!htpasswdexe' -b'cFLag' "'swatusers'" root **********'
address cmd samba.!htpasswdexe' -b'cFlag' "'swatusers'" root 'VRGet("EF_RootPassword","value") /* ' 2>'samba.!error' 1>'samba.!msg
if rc <> 0 then call _SambaShowError
else call _SambaShowMsg */
end
call _DebugLog THEN say "_SambaRootPWSet() done"
return
/*:VRX _SambaShowError
*/
_SambaShowError: procedure expose samba. settings. options.
I = 0
do while lines(samba.!error) <> 0
I = I + 1
smberr.I = linein(samba.!error)
say I':err:'smberr.I
end
ok = stream(Samba.!error,"c","close")
ok = SysFileDelete(Samba.!error)
smberr.0 = I
/* we did not get any error text */
if smberr.0 = 0 then return
Buttons.1 = "OK"
Buttons.0 = 1
id = VRMessageStem( VRWindow(), "smberr.", VRGet("Main", "Caption") , "Error", "Buttons.", buttons.1, buttons.1 )
return
/*:VRX _SambaShowMsg
*/
_SambaShowMsg: procedure expose samba. settings. options.
I = 0
do while lines(samba.!message) <> 0
I = I + 1
smbmsg.I = linein(samba.!message)
say I':msg:'smbmsg.I
end
ok = stream(Samba.!message,"c","close")
ok = SysFileDelete(Samba.!message)
smbmsg.0 = I
/* we did not get any message */
if smbmsg.0 = 0 then return
Buttons.1 = "OK"
Buttons.0 = 1
id = VRMessageStem( VRWindow(), "smbmsg.", VRGet("Main", "Caption") , "I", "Buttons.", buttons.1, buttons.1 )
return
/*:VRX _SambaUserCreate
*/
_SambaUserCreate:
OS2User = value("USER",,"OS2ENVIRONMENT")
if translate(OS2User) <> "root" & translate(OS2User) <> "guest" then do
Msg.Text = NLVGetMessage(75, OS2User)
Msg.Type = "I"
call _ShowMsg
end
return
/*:VRX _SambaVersion
*/
_SambaVersion:
say "_SambaVersion() started"
address cmd samba.!smbd' -V >'samba.!msg
samba.!version = linein(samba.!msg)
say " Samba "samba.!version
ok = stream(samba.!msg,"c","close")
say "_SambaVersion() done"
return
/*:VRX _SaveChanges
*/
_SaveChanges:
say '_SaveChanges() started for ['CurSection']'
do I = 1 to words(ChangeList)
ChangeObj = word(ChangeList,I)
say "Changed object: "ChangeObj
parse var ChangeObj ChangeObjType '_' ChangeVoc
ChangeVoc = translate(ChangeVoc, ' ', '_')
say "Changed voc: "ChangeVoc
VocIdx = VRGet(ChangeObj,'Userdata')
if ChangeObjType = "EF" then do
NewVal = VRGet(ChangeObj, 'Value')
parse var sections.CurSIdx.VocIdx OldVoc'='OldVal
OldVoc = strip(oldVoc)
sections.CurSIdx.VocIdx = OldVoc' = 'NewVal
if VRGet(ChangeObj, 'Value') <> "" then do
select
when pos("\\", VRGet(ChangeObj, 'Value')) > 0 then ok = IniSet(ChangeVoc, VRGet(ChangeObj, 'Value'), CurSection, samba.!smbconf)
when pos(" dir", ChangeVoc) > 0 then ok = IniSet(ChangeVoc, _bs2fs(VRGet(ChangeObj, 'Value')), CurSection, samba.!smbconf)
when pos("file", ChangeVoc) > 0 then ok = IniSet(ChangeVoc, _bs2fs(VRGet(ChangeObj, 'Value')), CurSection, samba.!smbconf)
when pos("path", ChangeVoc) > 0 then ok = IniSet(ChangeVoc, _bs2fs(VRGet(ChangeObj, 'Value')), CurSection, samba.!smbconf)
/* when pos("command",ChangeVoc) > 0 then ok = IniSet(ChangeVoc, _bs2fs(VRGet(ChangeObj, 'Value')), CurSection, samba.!smbconf) */
/* when pos("script", ChangeVoc) > 0 then ok = IniSet(ChangeVoc, _bs2fs(VRGet(ChangeObj, 'Value')), CurSection, samba.!smbconf) */
otherwise ok = IniSet(ChangeVoc, VRGet(ChangeObj, 'Value'), CurSection, samba.!smbconf)
end
say "INISet ok = "ok
end
else do
ok = IniDel( ChangeVoc, CurSection, samba.!smbconf )
say "INIDel ok = "ok
if ok = "" then ok = 0
end
end
if ChangeObjType = "CB" then do
If VRGet(ChangeObj, 'Set') then BoolVal = "Yes"; else BoolVal = "No"
parse var sections.CurSIdx.VocIdx OldVoc'='OldVal
OldVoc = strip(oldVoc)
sections.CurSIdx.VocIdx = OldVoc' = 'BoolVal
ok = IniSet(ChangeVoc, BoolVal, CurSection, samba.!smbconf)
say "INISet ok = "ok" (Bool)"
end
end
if ok = 0 then do
Msg.Type = "I"
Msg.Text = NLVGetMessage(51)
end
else do
Msg.Type = "E"
Msg.Text = NLVGetMessage(52)
end
call _ShowMsg
call TM_Value_Trigger
say '_SaveChanges() done'
return
/*:VRX _ShareObject_Changed
*/
_ShareObject_Changed:
say "_ShareObject_Changed() started"
ValueChanged = 1
if pos(VRGet(VRInfo("OBject"),"Name"), ChangeList) = 0 then Changelist = ChangeList' 'VRGet(VRInfo("OBject"),"Name")
ok = VRSet("PB_Save", "Enabled", 1)
say " ValueChanged = "ValueChanged
say Changelist
say "_ShareObject_Changed() done"
return
/*:VRX _SharesReset
*/
_SharesReset:
call _debuglog '_SharesReset() started'
ok = VRset("EF_path", "Value","")
ok = VRFlush( , "EF_path" )
ok = VRset("CB_Browseable", "Set", 1)
ok = VRFlush( , "CB_Browseable" )
ok = VRset("CB_Read_Only", "Set", 0)
ok = VRFlush( , "CB_Read_Only")
ok = VRset("CB_Guest_OK", "Set", 0)
ok = VRFlush( , "CB_Guest_OK" )
do I = 1 to CreatedObjs.0
ok = VRDestroy(CreatedObjs.I)
end
call _debuglog '_SharesReset() done'
return
/*:VRX _ShowMsg
*/
_ShowMsg:
Buttons.1 = "OK"
Buttons.0 = 1
id = VRMessage( VRWindow(), Msg.Text, Msg.Title, Msg.Type, "Buttons.", buttons.1, buttons.1 )
return
/*:VRX _Smb35Init
*/
_Smb35Init:
IF options.!debug == 1 THEN say '_Smb35Init() started'
say '1 -> 'samba.!smbpasswdexe' -a dummyuser -n -D 10'
address cmd samba.!smbpasswdexe' -a dummyuser -n -D 10'
say '2 -> 'samba.!smbpasswdexe' -x dummyuser -D 10'
address cmd samba.!smbpasswdexe' -x dummyuser -D 10'
say '3 -> 'samba.!pdbeditexe' --policies-reset -d=3'
address cmd samba.!pdbeditexe' --policies-reset -d=3'
say 'X -> ----------------------'
IF options.!debug == 1 THEN say '_Smb35Init() done'
return
/*:VRX _SmbConfBackup
*/
_SmbConfBackup:
ok = VRCopyFile( SmbConf, SmbConf"-backup" )
return
/*:VRX _SmbConfCommitChanges
*/
_SmbConfCommitChanges:
IF options.!debug == 1 THEN say '_SmbConfCommitChanges() started'
src = TempDir'smb.conf'
if stream(src,'c','query size') = 0 then do
ok = VRCopyFile(smbconf,src)
end
trg = smbconf
ok = SysFileDelete(smbconf)
call lineout trg, '# Samba config file created using SSCC ver. 'word(VRGet("Main","Hinttext"),2)
call lineout trg, '# from 'value("USER",,'OS2ENVIRONMENT')'@'value("HOSTNAME",,'OS2ENVIRONMENT')
call lineout trg, '# Date: 'date()' 'time()
lct = 0
do until lines(src) = 0
smbline = linein(src)
if pos("idmap uid",smbline) > 0 then iterate
if pos("idmap gid",smbline) > 0 then iterate
if pos("idmap config",smbline) > 0 then iterate
if pos("winbind separator",smbline) > 0 then iterate
if pos("copy ",smbline) > 0 then iterate
call lineout trg, smbline
lct = lct + 1
if pos("log file",smbline) > 0 then do
call lineout trg, '09'x||'log level = 'VRGet("EF_LOG_LEVEL","value")
lct = lct + 1
end
end
say "Lines saved "lct
ok = stream(trg,'c','close')
ok = stream(src,'c','close')
ok = SysFileDelete(src)
IF options.!debug == 1 THEN say '_SmbConfCommitChanges() done'
return
/*:VRX _SmbConfCreateDefault
*/
_SmbConfCreateDefault:
call _debuglog "_SmbConfCreateDefault() started"
ok = SysFileDelete(smbconf)
/* Create a basic smb.conf */
call _SmbConfDefault_Global
call _SmbConfDefault_Scripts
if CreatePDC then do
call _SmbConfDefault_NetLogon
call _SmbConfDefault_Profiles
end
call _SmbConfDefault_Homes
call _SmbConfDefault_SharePrinters
call _SmbConfDefault_ShareDrives
ok = stream(smbconf,'c','close')
call _debuglog "_SmbConfCreateDefault() done"
return
/*:VRX _SmbConfCreateDefault_OldInstall
*/
_SmbConfCreateDefault_OldInstall:
DriveList = SysDriveMap('C:','Local')
ok = SysIni('SYSTEM', 'PM_SPOOLER_QUEUE_DESCR', 'ALL:','printers.')
ok = VRSet("EF_NetBIOS_Name","Value", Value("HOSTNAME",,"OS2ENVIRONMENT"))
DrivesOH.0 = 0
do I = 1 to words(DriveList)
CurDrive = word(DriveList,I)
Filesys = SysFilesystemType(Curdrive)
DriveInfo=SysDriveInfo(CurDrive)
parse var DriveInfo DrvLet CurFree CurSize CurLabel
curlabel = strip(Curlabel)
CurFree = word(Driveinfo,2)
CurSize = word(Driveinfo,3)
if Curlabel = "" then Curlabel = '?'
if datatype(CurSize) = 'NUM' then do
CurSize = CurSize/(1024*1024)
CurFree = CurFree/(1024*1024)
CurSize = format(CurSize,,0)'MB'
CurFree = format(CurFree,,0)'MB'
end
else do
CurSize = '?'
CurFree = '?'
end
/* DrivesOH.I = VRCreate( "GB_Drives", "CheckBox", "Name", "CB_"left(CurDrive,1), "Top", 120, "Left", 1325+(I-1)*420, "Visible", 1, "Caption", CurDrive, "AutoSize", 1, "set", 1, "Userdata", FileSys, "HintText", CurDrive' ('Curlabel', 'FileSys') size: 'CurSize', free: 'CurFree) */
Shares.!drives.I = VRMethod( "CN_smbconf", "AddRecord", smbconf.!dirs,,left(CurDrive,1) ,"#4")
if FileSys = '' | FileSys = 'CDFS' then do
/* ok = VRSet(DrivesOH.I, "ForeColor", "Red") */
end
/* if CurDrive = SysBootDrive() then ok = VRSet(DrivesOH.I, "Set", 0)
if CurDrive = translate(left(samba.!bin,2)) then ok = VRSet(DrivesOH.I, "Set", 0) */
end
DrivesOH.0 = I-1
PrintersOH.0 = 0
Colum = 1325
dx = 0
do I = 1 to printers.0
queue = printers.I
name = strip(strip(SysIni('SYSTEM', 'PM_SPOOLER_QUEUE_DESCR', printers.I),'T','00'x),,';')
/* PrintersOH.I = VRCreate( "GB_printers", "CheckBox", "Name", "CB_"queue, "Top", 120+(I-1-dx)*250, "Left", Colum, "Visible", 1, "Caption", Name, "AutoSize", 1, "set", 1, "UserData", Queue) */
Shares.!printers.I = VRMethod( "CN_smbconf", "AddRecord", smbconf.!printers,,queue,"#6")
if I = 6 then do
Colum = 4000
dx = 6
end
end
PrintersOH.0 = I-1
return
/*:VRX _SmbConfDefault_Global
*/
_SmbConfDefault_Global:
call _debuglog "_SmbConfDefault_Global() started"
Migrate = (arg(1) = 1)
if \Migrate then do /* when migrating these 4 lines are there already */
call lineout smbconf, '# Samba config file created using SSCC ver. 'word(VRGet("Main","Hinttext"),2)
call lineout smbconf, '# from 'value("USER",,'OS2ENVIRONMENT')'@'value("HOSTNAME",,'OS2ENVIRONMENT')
call lineout smbconf, '# Date: 'date()' 'time()
section = '[global]'
call lineout smbconf, section
if workgroup = '' then workgroup = 'WORKGROUP' /* make sure we have no empty default, set to Windows default */
call lineout smbconf, Indent||'workgroup = 'workgroup
call lineout smbconf, Indent||'netbios name = 'value('HOSTNAME',,'OS2ENVIRONMENT')
call lineout smbconf, Indent||'server string = %h Samba Server for OS/2 based systems'
call lineout smbconf, Indent||'comment = Samba Server for OS/2 based systems'
end
if SysQueryProcessCodePage() = "850" then do
call lineout smbconf, Indent||'dos charset = IBM-850'
call lineout smbconf, Indent||'display charset = IBM-850'
call lineout smbconf, Indent||'unix charset = IBM-850'
end
else do
call lineout smbconf, Indent||'dos charset = IBM-850'
call lineout smbconf, Indent||'display charset = SYSTEM'
call lineout smbconf, Indent||'unix charset = SYSTEM'
end
CurCP = SysQueryProcessCodePage()
if CurCP <> "850" then do
Msg.Text = NLVGetMessage(117)
Msg.Type = "W"
call _ShowMsg
end
if UseTDBsam = 1 then do
call lineout smbconf, Indent||'passdb backend = tdbsam'
end
call lineout smbconf, Indent||'log level = 2'
call lineout smbconf, Indent||'log file = '||ETC||'\samba\log\log.smbd.%U.%M'
call lineout smbconf, Indent||'null passwords = Yes'
call lineout smbconf, Indent||'guest account = guest'
call lineout smbconf, Indent||'security = user'
call lineout smbconf, Indent||'load printers = No'
call lineout smbconf, Indent||'time server = Yes'
call lineout smbconf, Indent||'lock directory = '||ETC||'\samba\lock'
/* This EA makes the testparm warning about browsing go away.
Note: The EA is NOT marked critical as it should be,
neverthelesse this fix works */
ok = SysPutEA(ETC||'\samba\lock',"MODE", "FEFF0400ED410000"x)
call lineout smbconf, Indent||'ea support = Yes'
call lineout smbconf, Indent||'store dos attributes = Yes'
call lineout smbconf, Indent||'lm announce = Yes'
call lineout smbconf, Indent||'wins support = Yes'
call lineout smbconf, '#'Indent||'Enable next line to overcome Ticket #282'
call lineout smbconf, '#'Indent||'nmbd bind explicit broadcast = No'
call lineout smbconf, Indent||'wide links = No'
ok = SysFileTree(samba.!printcap,exist.,'FO')
if exist.0 = 1 then do
call lineout smbconf, Indent||'printcap name = 'samba.!printcap
end
samba.!smbusermap = ETC||'\samba\private\smbusermap'
call lineout smbconf, Indent||'username map = 'samba.!smbusermap
if \VRFileExists(samba.!smbusermap) then call _SmbUserMapCreate
if CreatePDC then do
call lineout smbconf, Indent||'local master = Yes'
call lineout smbconf, Indent||'preferred master = Yes'
call lineout smbconf, Indent||'domain master = Yes'
call lineout smbconf, Indent||'os level = 65'
call lineout smbconf, ';'Indent||'domain groups ='
call lineout smbconf, ';'Indent||'domain admin group = '
call lineout smbconf, Indent||'domain admin users = root'
call lineout smbconf, Indent||'domain logons = Yes'
call lineout smbconf, Indent||'logon home = \\%L\Profiles\%U'
call lineout smbconf, Indent||'logon path = \\%L\Profiles\%U'
call lineout smbconf, Indent||'logon drive = z:'
call lineout smbconf, Indent||'logon script = %U.cmd'
end
else do
call lineout smbconf, Indent||'create mask = 0777'
end
ok = stream(smbconf, 'c','close')
call _debuglog "_SmbConfDefault_Global() done"
return
/*:VRX _SmbConfDefault_Homes
*/
_SmbConfDefault_Homes:
/* Create Homes section */
call lineout smbconf, '[HOMES]'
call lineout smbconf, Indent||"comment = Home directory"
smbhome = ETC'\samba\homes'
Home = strip(value('Home',,'OS2ENVIRONMENT'),'T','\')
if Home <> '' then do
User = value('USER',,'OS2ENVIRONMENT')
if User <> '' then do
if translate(User) = translate(Filespec('N',Home)) | translate(Filespec('N',Home)) = "DEFAULT" then smbHome = strip(filespec('D',Home)||filespec('P',Home),'T','\')
end
end
ok = SysMkDir(smbhome)
call lineout smbconf, Indent||"path = "_bs2fs(smbhome)'/%u'
call lineout smbconf, Indent||"read only = No"
call lineout smbconf, Indent||"browseable = No"
call lineout smbconf, Indent
ok = stream(smbconf, 'c','close')
return
/*:VRX _SmbConfDefault_Netlogon
*/
_SmbConfDefault_Netlogon:
/* Create Netlogon section */
call lineout smbconf, '[NETLOGON]'
call lineout smbconf, Indent||"comment = Netlogon service"
smbnetlogon = samba.!bin'\netlogon'
ok = SysMkDir(smbnetlogon)
call lineout smbconf, Indent||"path = "_bs2fs(smbnetlogon)
call lineout smbconf, Indent||"read only = Yes"
call lineout smbconf, Indent||"browseable = Yes"
call lineout smbconf, Indent||"share modes = No"
call lineout smbconf, Indent
ok = stream(smbconf, 'c','close')
return
/*:VRX _SmbConfDefault_Profiles
*/
_SmbConfDefault_Profiles:
/* Create profiles section */
call lineout smbconf, '[profiles]'
call lineout smbconf, Indent||"comment = profiles"
smbprofiles = samba.!bin'\profiles'
ok = SysMkDir(smbprofiles)
call lineout smbconf, Indent||"path = "_bs2fs(smbprofiles)
call lineout smbconf, Indent||"profile acls = Yes"
call lineout smbconf, Indent||"read only = No"
call lineout smbconf, Indent||"browseable = Yes"
call lineout smbconf, Indent||"create mask = 0777"
call lineout smbconf, Indent||"directory mask = 0777"
call lineout smbconf, Indent
ok = stream(smbconf, 'c','close')
return
/*:VRX _SmbConfDefault_Scripts
*/
_SmbConfDefault_Scripts:
smbtools = samba.!bin
/* user scripts */
call lineout smbconf, '#'||Indent||'user scripts'
call lineout smbconf, Indent||'add user script = '||smbtools||'\usermod.cmd -a "%u"'
call lineout smbconf, Indent||'delete user script = '||smbtools||'\usermod.cmd -x "%u"'
call lineout smbconf, Indent||'rename user script = '||smbtools||'\usermod.cmd -r "%uold" "%unew"'
call lineout smbconf, Indent||'add machine script = '||smbtools||'\usermod.cmd -a "%u"'
call lineout smbconf, Indent||'set primary group script = '||smbtools||'\usermod.cmd -p "%u" "%g"'
/* group scripts */
call lineout smbconf, '#'||Indent||'group scripts'
call lineout smbconf, Indent||'add group script = '||smbtools||'\groupmod.cmd -a "%g"'
call lineout smbconf, Indent||'delete group script = '||smbtools||'\groupmod.cmd -x "%g"'
call lineout smbconf, Indent||'add user to group script = '||smbtools||'\groupmod.cmd -j "%g" "%u"'
call lineout smbconf, Indent||'delete user from group script = '||smbtools||'\groupmod.cmd -l "%g" "%u"'
/* share scripts */
call lineout smbconf, '#'||Indent||'share scripts'
call lineout smbconf, Indent||'add share command = '||smbtools||'\addshare.cmd'
call lineout smbconf, Indent||'change share command = '||smbtools||'\changeshare.cmd'
call lineout smbconf, Indent||'delete share command = '||smbtools||'\delshare.cmd'
/* other scripts */
call lineout smbconf, '#'||Indent||'other scripts'
call lineout smbconf, Indent||'enumports command = '||smbtools||'\enumports.cmd'
call lineout smbconf, Indent
call lineout smbconf
ok = stream(smbconf, 'c','close')
return
/*:VRX _SmbConfDefault_ShareDrives
*/
_SmbConfDefault_ShareDrives:
call _debugLog "_SmbConfDefault_ShareDrives() started."
DriveList = SysDriveMap('C:','Local')
do I = 1 to words(DriveList)
CurDrive = word(DriveList,I)
say " CurDrive="Curdrive
Filesys = SysFilesystemType(Curdrive)
DriveInfo=SysDriveInfo(CurDrive)
parse var DriveInfo DrvLet CurFree CurSize CurLabel
if FileSys = '' | FileSys = 'CDFS' then do
read_write = 'read only = Yes'
end
else do
read_write = 'read only = No'
end
if FileSys = '' then FileSys = 'CDFS'
section = '['left(curdrive,1)']'
comment = 'comment = 'Drive' 'CurDrive' ('FileSys')'
path = 'path = 'Curdrive'/'
guest_ok = 'guest ok = Yes'
hide_files = 'hide files = /*. SF/root/'
call lineout smbconf, section
call lineout smbconf, Indent||comment
call lineout smbconf, Indent||path
call lineout smbconf, Indent||read_write
call lineout smbconf, Indent||guest_ok
call lineout smbconf, Indent||hide_files
call lineout smbconf, Indent
end
ok = stream(smbconf, 'c','close')
call _debugLog "_SmbConfDefault_ShareDrives() done."
return
/* browsable = 'browsable = Yes'
printable = 'printable = No'
public = 'public = Yes'
call lineout smbconf, Indent||browsable
call lineout smbconf, Indent||printable
call lineout smbconf, Indent||public */
/*:VRX _SmbConfDefault_SharePrinters
*/
_SmbConfDefault_SharePrinters:
ok = SysIni('SYSTEM', 'PM_SPOOLER_QUEUE_DESCR', 'ALL:','printers.')
do I = 1 to printers.0
queue = printers.I
name = strip(strip(SysIni('SYSTEM', 'PM_SPOOLER_QUEUE_DESCR', printers.I),'T','00'x),,';')
/* call lineout samba.!printcap, queue'|'name */
section = '['queue']'
path = 'path = 'ETC'\samba\spool\'queue
ok = SysMkDir(ETC'\samba\spool\'queue)
comment = 'comment = 'name
create_mask = 'create mask = 0700'
guest_ok = 'guest ok = Yes'
printable = 'printable = Yes'
print_command = 'print command = 'samba.!bin'\smbprint.exe "%s" "%p" "%J" "%c" "%z"'
printer_name = 'printer name = 'queue
call lineout smbconf, section
call lineout smbconf, Indent||comment
call lineout smbconf, Indent||path
call lineout smbconf, Indent||create_mask
call lineout smbconf, Indent||printable
call lineout smbconf, Indent||print_command
call lineout smbconf, Indent||printer_name
call lineout smbconf, Indent||guest_ok
call lineout smbconf, Indent
end
ok = stream(smbconf, 'c','close')
ok = stream(samba.!printcap,'c','close')
return
/* browsable = 'browsable = Yes'
call lineout smbconf, Indent||browsable */
/*:VRX _SmbConfLoad
*/
_SmbConfLoad:
call _debuglog '_SmbConfLoad() started'
call _debuglog 'Loading "'samba.!smbconf'" ('stream(samba.!smbconf,'c','query size')' bytes)'
/* ok = IniEnumSections(sections., samba.!smbconf) */
section. = ""
sections.0 = 0
call _MyIniEnumSections(samba.!smbconf)
special = 'global printers netlogon print$ homes profiles'
Specialstatus.0 = sections.0
PrintStatus.0 = sections.0
sectionhandles.0 = sections.0
recordhandle.0 = sections.0
do I = 1 to sections.0
IF options.!debug == 1 THEN say ' ['sections.I'] section loaded'
if wordpos(translate(sections.I),translate(special)) > 0 Then SpecialStatus.I = 1
Else SpecialStatus.I = 0
PrintRes = IniGet("Printable", sections.I, samba.!smbconf)
if Translate(PrintRes) = "YES" | Translate(PrintRes) = "TRUE" then PrintStatus.I = 1
else PrintStatus.I = 0
IF options.!debug == 1 THEN say ' ['sections.I'] status (special:'SpecialStatus.I', print:'Printstatus.I')'
if Printstatus.I = 1 & SpecialStatus.I = 0 then do /* printer share */
recordhandle.I = VRMethod( "CN_smbconf", "AddRecord", smbconf.!printers,,sections.I,"#65:PMWP.DLL")
ok = VRMethod("CN_smbconf","SetRecordAttr",recordhandle.I,"ReadOnly", 1)
IF options.!debug == 1 THEN say ' ['sections.I'] added to shared printer tree'
end
if Printstatus.I = 0 & SpecialStatus.I = 0 then do /* directory share */
recordhandle.I = VRMethod( "CN_smbconf", "AddRecord", smbconf.!dirs,, sections.I,"#64:PMWP.DLL")
ok = VRMethod("CN_smbconf","SetRecordAttr",recordhandle.I,"ReadOnly", 1)
IF options.!debug == 1 THEN say ' ['sections.I'] added to shared folder tree'
end
if translate(sections.I) = 'PROFILES' then do
recordhandle.I = smbconf.!profiles
ok = VRMethod("CN_smbconf","SetRecordAttr",recordhandle.I,"Visible", 1)
end
if translate(sections.I) = 'NETLOGON' then do
recordhandle.I = smbconf.!netlogon
ok = VRMethod("CN_smbconf","SetRecordAttr",recordhandle.I,"Visible", 1)
end
if translate(sections.I) = 'HOMES' then do
recordhandle.I = smbconf.!homes
ok = VRMethod("CN_smbconf","SetRecordAttr",recordhandle.I,"Visible", 1)
end
if translate(sections.I) = 'GLOBAL' then recordhandle.I = smbconf.!global
end
ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!root, "Collapsed", 0 )
call _debuglog '_SmbConfLoad() done'
return
/* if VRGet("DT_AlreadySmbConf","Visible") then do
smbline = strip(translate(linein(smbconf),' ','09'x))
do while translate(left(smbline,8)) <> "[GLOBAL]"
smbline = strip(translate(linein(smbconf),' ','09'x))
end
do until left(smbline,1) = '['
smbline = strip(translate(linein(smbconf),' ','09'x))
parse var smbline voc '=' val
voc = strip(voc)
val = strip(val)
if translate(voc) = "WORKGROUP" then do
ok = VRset("EF_WorkGroup", "Value", val)
ok = VRSet("EF_WorkGroup", "BackColor", "(255,255,180)")
end
if translate(voc) = "NETBIOS NAME" then do
ok = VRset("EF_NetBIOS_Name", "Value", val)
ok = VRSet("EF_NetBIOS_Name", "BackColor", "(255,255,180)")
end
if translate(voc) = "SERVER STRING" then do
ok = VRset("EF_Server_String", "Value", val)
ok = VRSet("EF_server_string", "BackColor", "(255,255,180)")
end
end
ok = stream(smbconf, 'c','close')
end */
/*:VRX _SmbConfMigratePeer
*/
_SmbConfMigratePeer:
Ok = SysFileDelete(smbconf)
/* Migrate Peer To Samba */
/* IBMLAN.INI part */
ibmlanline = strip(translate(linein(ibmlanini),' ',Indent))
do while translate(left(ibmlanline,11)) <> "[REQUESTER]"
ibmlanline = strip(translate(linein(ibmlanini),' ',Indent))
end
call lineout smbconf, '[global]'
do until left(ibmlanline,1) = '['
ibmlanline = strip(translate(linein(ibmlanini),' ',Indent))
parse var ibmlanline voc '=' val
voc = strip(voc)
val = strip(val)
if translate(voc) = "DOMAIN" then do
call lineout smbconf, Indent||'workgroup = 'val
end
if translate(voc) = "COMPUTERNAME" then do
call lineout smbconf, Indent||'netbios name = 'val
end
end
do while translate(left(ibmlanline,6)) <> '[PEER]'
ibmlanline = strip(translate(linein(ibmlanini),' ',Indent))
end
do until left(ibmlanline,1) = '[' | lines(ibmlanini) = 0
ibmlanline = strip(translate(linein(ibmlanini),' ',Indent))
parse var ibmlanline voc '=' val
voc = strip(voc)
val = strip(val)
if translate(voc) = "SRVCOMMENT" then do
call lineout smbconf, Indent||'server string = 'val
call lineout smbconf, Indent||'comment = 'val
end
end
call _SmbConfDefault_Global 1 /* 1 = migration mode */
call _SmbConfDefault_Scripts
if CreatePDC then do
call _SmbConfDefault_NetLogon
call _SmbConfDefault_Profiles
end
call _SmbConfDefault_Homes
/* LSSHARE.INI part */
ok = SysINI(lsshareini,"ALL:","Shares." )
SharePath.0 = shares.0
Comment.0 = shares.0
Type.0 = shares.0
ok = VRMethod( "Application", "ListPrinters", "printer." )
do I = 1 to shares.0
call lineout smbconf, '['Shares.I']'
sharepath.I = SysINI(lsshareini, shares.I, 'Path')
Type.I = c2d(left(SysINI(lsshareini, shares.I, 'Type'),1))
if Type.I = '1' then do /* We migrate a printer */
do J = 1 to printer.0
parse var printer.J PrinterName';'PrinterQueue';'PrinterDriver
if PrinterQueue = Sharepath.I then leave
end
call lineout smbconf, Indent||'path = '_bs2fs(ETC'\samba\spool\'printerqueue)
ok = SysMkDir(ETC'\samba\spool\'printerqueue)
call lineout smbconf, Indent||'comment = 'Printername
call lineout smbconf, Indent||'create mask = 0700'
call lineout smbconf, Indent||'printer name = 'printerqueue
call lineout smbconf, Indent||'printing = os2'
call lineout smbconf, Indent||'printable = Yes'
call lineout smbconf, Indent||'print command = 'samba.!bin'\smbprint.exe "%s" "%p" "%J" "%c" "%z"'
call lineout smbconf, Indent||'browseable = Yes'
call lineout smbconf, Indent||'guest ok = Yes'
call lineout smbconf, Indent||'read only = No'
end
else do /* we migrate a folder */
Comment.I = SysINI(lsshareini, shares.I, 'Remark')
call lineout smbconf, Indent||'comment = 'Comment.I
call lineout smbconf, Indent||'path = 'translate(Sharepath.I,'/','\')
call lineout smbconf, Indent||'read only = No'
call lineout smbconf, Indent||'browseable = Yes'
call lineout smbconf, Indent||'hide files = /*. SF/root/'
end
call lineout smbconf, " "
end
ok = stream(smbconf,'c','close')
return
/*:VRX _SmbConfRestore
*/
_SmbConfRestore:
ok = VRCopyFile( SmbConf"-backup", SmbConf)
return
/*:VRX _SmbConfShareRemove
*/
_SmbConfShareRemove:
Aborted = 0
ok = VRMethod( "CN_smbconf", "GetRecordList", "Selected", "SelectedHandle." )
if Selectedhandle.0 = 0 then return
Msg.Title = NLVGetMessage(67)
do I = 1 to sections.0
if recordhandle.I = SelectedHandle.1 then do
if recordhandle.I = smbconf.!homes | recordhandle.I = smbconf.!global then do
Msg.Text = NLVGetMessage(61, Sections.I)
Msg.Type = 'E'
call _ShowMsg
Aborted = 1
return
end
Msg.Text = NLVGetMessage(62, Sections.I)
Msg.Type = "Q"
ok = _MsgYesNo()
if ok = 2 then return
NewSmbConf = TempDir'smb.conf'
ok = SysFileDelete(NewSmbConf)
smbline = strip(linein(smbconf))
do while left(translate(smbline),length(sections.I)+2) <> translate('['sections.I']')
call lineout NewSmbConf, smbline
smbline = strip(linein(smbconf))
end
smbline = strip(linein(smbconf))
do while left(translate(smbline),1) <> '[' & lines(smbconf) <> 0
smbline = strip(linein(smbconf))
end
do until lines(smbconf) = 0
call lineout NewSmbConf, smbline
smbline = strip(linein(smbconf))
end
call lineout NewSmbConf, smbline
ok = stream(smbconf, 'c', 'close')
ok = stream(Newsmbconf, 'c', 'close')
ok = VRCopyFile( NewSmbConf, smbconf )
end
end
call _SmbConfTreeReset
if _SambaRunning() then do
Msg.Text = NLVGetMessage(69)
Msg.Type = 'I'
call _ShowMsg
end
return
/*:VRX _SmbConfShareRename
*/
_SmbConfShareRename:
Aborted = 0
ok = VRMethod( "CN_smbconf", "GetRecordList", "Selected", "SelectedHandle." )
if Selectedhandle.0 = 0 then return
do I = 1 to sections.0
if recordhandle.I = SelectedHandle.1 then do
if recordhandle.I = smbconf.!homes | recordhandle.I = smbconf.!global then do
Msg.Text = NLVGetMessage(66, Sections.I)
Msg.Type = 'E'
call _ShowMsg
Aborted = 1
return
end
Buttons.1 = NLVGetMessage(2)
Buttons.2 = NLVGetMessage(3)
Buttons.0 = 2
NewShareName = Sections.I
id = VRPrompt( VRWindow(), NLVGetMessage(66), "NewShareName", NLVGetMessage(68), "Buttons.", buttons.1, buttons.2 )
if ID = 2 | NewShareName = "" then return
NewSmbConf = TempDir'smb.conf'
ok = SysFileDelete(NewSmbConf)
smbline = strip(linein(smbconf))
do while left(translate(smbline),length(sections.I)+2) <> translate('['sections.I']')
call lineout NewSmbConf, smbline
smbline = strip(linein(smbconf))
end
call lineout NewSmbConf, '['NewShareName']'
smbline = strip(linein(smbconf))
do until lines(smbconf) = 0
call lineout NewSmbConf, smbline
smbline = strip(linein(smbconf))
end
call lineout NewSmbConf, smbline
ok = stream(smbconf, 'c', 'close')
ok = stream(Newsmbconf, 'c', 'close')
ok = VRCopyFile( NewSmbConf, smbconf )
end
end
call _SmbConfTreeReset
if _SambaRunning() then do
Msg.Text = NLVGetMessage(69)
Msg.Type = 'I'
call _ShowMsg
end
return
/*:VRX _SmbConfTreeInit
*/
_SmbConfTreeInit:
IF options.!debug == 1 THEN say '_SmbConfTreeInit() started.'
call _CfgPageSetupSize "GB_Help"
call _CfgPageSetupSize "GB_Global"
call _CfgPageSetupSize "GB_Shares"
IF options.!debug == 1 THEN say ' Page setup done.'
ok = VRMethod("CN_smbconf", "RemoveRecord", "ALL")
smbconf.!root = VRMethod( "CN_smbconf", "AddRecord",,, "smb.conf","#33:PMWP.DLL")
smbconf.!global = VRMethod( "CN_smbconf", "AddRecord", smbconf.!root,, "Global","#33:PMWP.DLL")
smbconf.!homes = VRMethod( "CN_smbconf", "AddRecord", smbconf.!root,, "Homes","#33:PMWP.DLL")
smbconf.!netlogon = VRMethod( "CN_smbconf", "AddRecord", smbconf.!root,, "Netlogon","#33:PMWP.DLL")
smbconf.!profiles = VRMethod( "CN_smbconf", "AddRecord", smbconf.!root,, "Profiles","#33:PMWP.DLL")
smbconf.!printers = VRMethod( "CN_smbconf", "AddRecord", smbconf.!root,, NLVGetMessage(45),"#93:PMWP.DLL")
smbconf.!dirs = VRMethod( "CN_smbconf", "AddRecord", smbconf.!root,, NLVGetMessage(46),"#27:PMWP.DLL")
IF options.!debug == 1 THEN say ' smb.conf sections created.'
ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!netlogon, "Visible", 0 , "ReadOnly", 1)
ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!profiles, "Visible", 0 , "ReadOnly", 1)
ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!homes, "Visible", 0 , "ReadOnly", 1)
ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!root, "Collapsed",1, "ReadOnly", 1 )
ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!global, "ReadOnly", 1)
ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!printers, "ReadOnly", 1)
ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!dirs, "ReadOnly", 1)
IF options.!debug == 1 THEN say ' visibility set.'
IF options.!debug == 1 THEN say '_SmbConfTreeInit() done.'
return
/*:VRX _SmbConfTreeReset
*/
_SmbConfTreeReset:
call _debuglog '_SmbConfTreeReset() started'
call _SharesReset
ok = VRMethod( "CN_SmbConf", "RemoveRecord", smbconf.!root )
call _SmbConfTreeInit
call _GUIInit
call _debuglog '_SmbConfTreeReset() done'
return
/*:VRX _SmbUserMapCreate
*/
_SmbUserMapCreate:
call lineout samba.!smbusermap, '# Created by SSCC version 'word(VRGet("Main","Hinttext"),2)' on 'date()' at 'time()
call lineout samba.!smbusermap, '# syntax:'
call lineout samba.!smbusermap, '# Samba username = Windows username'
call lineout samba.!smbusermap, 'root = Administrator'
ok = stream(samba.!smbusermap,'c','close')
return
/*:VRX About_Close
*/
About_Close:
call About_Fini
return
/*:VRX About_Create
*/
About_Create:
call About_Init
ok = VRSet("About","Caption", NLVGetMessage(31))
ok = VRSet("PB_AboutOK","Caption", NLVGetMessage(2))
SambaTeam.0 = 9
SambaTeam.1 = 'Silvan Scherrer'
SambaTeam.2 = 'Herwig Bauernfeind'
SambaTeam.3 = 'Vitali Pelenyov'
SambaTeam.4 = 'Paul Smedley'
SambaTeam.5 = 'Yuri Dario'
SambaTeam.6 = 'Alex Taylor'
SambaTeam.7 = 'Nikolay Kolosov'
SambaTeam.8 = 'All the Samba people'
SambaTeam.9 = 'All the netlabs people'
ok = VRSet("About","Font", VRGet("GB_Help2","Font"))
ok = VRMethod("LB_SambaTeam","AddStringList", "SambaTeam." )
ok = VRSet("DT_SambaTeam","Caption", NLVGetMessage(72))
ok = VRSet("MLE_Version","Value", NLVGetMessage(1)||'0D0A'x||VRGet("Main", "Hinttext")||'0D0A'x||'0D0A'x||SambaVer)
return
/*:VRX About_Fini
*/
About_Fini:
window = VRInfo( "Window" )
call VRDestroy window
drop window
return
/*:VRX About_Init
*/
About_Init:
window = VRInfo( "Object" )
if( \VRIsChildOf( window, "Notebook" ) ) then do
call VRMethod window, "CenterWindow"
call VRSet window, "Visible", 1
call VRMethod window, "Activate"
end
drop window
return
/*:VRX CB_Browseable_Click
*/
CB_Browseable_Click:
call _ShareObject_Changed
return
/*:VRX CB_EA_Support_Click
*/
CB_EA_Support_Click:
call _ShareObject_Changed
return
/*:VRX CB_Guest_OK_Click
*/
CB_Guest_OK_Click:
call _ShareObject_Changed
return
/*:VRX CB_LM_Announce_Click
*/
CB_LM_Announce_Click:
call _ShareObject_Changed
return
/*:VRX CB_NoRoot_Click
*/
CB_NoRoot_Click:
if VRGet("CB_NoRoot","set") then do
ok = VRset("EF_RootPassword","BackColor","PaleGray")
ok = VRset("EF_RootPassword_Repeat","BackColor","PaleGray")
ok = VRset("EF_RootPassword","Enabled", 0)
ok = VRset("EF_RootPassword_Repeat","Enabled", 0)
end
else do
ok = VRset("EF_RootPassword","BackColor","")
ok = VRset("EF_RootPassword_Repeat","BackColor","")
ok = VRset("EF_RootPassword","Enabled", 1)
ok = VRset("EF_RootPassword_Repeat","Enabled", 1)
end
return
/*:VRX CB_Null_passwords_Click
*/
CB_Null_passwords_Click:
call _ShareObject_Changed
return
/*:VRX CB_Read_Only_Click
*/
CB_Read_Only_Click:
call _ShareObject_Changed
return
/*:VRX CB_RemoveSmbConf_Click
*/
CB_RemoveSmbConf_Click:
ok = VRSet("CB_RemoveBackend", "Enabled", VRGet("CB_RemoveSmbConf","set"))
if VRGet("CB_RemoveBackend", "Enabled") = 0 then ok = VRSet("CB_RemoveBackend", "Set", 0)
return
/*:VRX CB_Store_DOS_attributes_Click
*/
CB_Store_DOS_attributes_Click:
call _ShareObject_Changed
return
/*:VRX CB_Time_Server_Click
*/
CB_Time_Server_Click:
call _ShareObject_Changed
return
/*:VRX CB_WINS_Support_Click
*/
CB_WINS_Support_Click:
call _ShareObject_Changed
return
/*:VRX CN_smbconf_Click
*/
CN_smbconf_Click:
IF options.!debug == 1 THEN SAY 'CN_smbconf_Click() started'
IF options.!debug == 1 THEN SAY ' Using 'smbconf' ('stream(smbconf,'c','query size')' bytes)'
if ValueChanged then do
if CurSection <> "" then do
Msg.Title = NLVGetMessage('1')
Msg.Text = NLVGetMessage(60, CurSection)
ok = _MsgYesNo()
if ok = 1 then call _SaveChanges
CurSection = ""
end
end
Ok = VRset("Main", "Painting", 0)
ok = VRSet("Main", 'Pointer', 'WAIT' )
ok = VRset("GB_Help", "Visible", 0)
ok = VRset("GB_Global", "Visible", 0)
ok = VRset("GB_Shares", "Visible", 0)
ok = VRMethod( "CN_smbconf", "GetRecordList", "Selected", "Prophandle." )
if PropHandle.0 = 0 then do
IF options.!debug == 1 THEN SAY 'CN_smbconf_Click() aborted, no handle'
Ok = VRset("Main", "Painting", 1)
ok = VRSet("Main", 'Pointer', '' )
return
end
ParentHandle = VRMethod("CN_smbconf","GetRecordAttr", Prophandle.1,"Parent")
if Prophandle.1 = smbconf.!root then ok = VRset("GB_Help", "Visible", 1)
if Prophandle.1 = smbconf.!global | Parenthandle = smbconf.!global then call _ActiveGroup "Global"
if Prophandle.1 = smbconf.!homes | Parenthandle = smbconf.!homes then call _ActiveGroup "Shares"
if Prophandle.1 = smbconf.!netlogon | Parenthandle = smbconf.!netlogon then call _ActiveGroup "Shares"
if Prophandle.1 = smbconf.!profiles | Parenthandle = smbconf.!profiles then call _ActiveGroup "Shares"
if Prophandle.1 = smbconf.!dirs then call _ActiveGroup "Help"
if Prophandle.1 = smbconf.!printers then call _ActiveGroup "Help"
if Parenthandle = smbconf.!dirs then call _ActiveGroup "Shares"
if Parenthandle = smbconf.!printers then call _ActiveGroup "Shares"
call _SharesReset
Ok = VRset("Main", "Painting", 1)
ok = VRSet("Main", 'Pointer', '' )
ok = VRSet("TM_Value", "Enabled", 1)
if Prophandle.1 = smbconf.!root | Prophandle.1 = smbconf.!dirs | Prophandle.1 = smbconf.!printers then do
IF options.!debug == 1 THEN SAY 'CN_smbconf_Click() aborted, got parent handle'
Ok = VRset("Main", "Painting", 1)
ok = VRSet("Main", 'Pointer', '' )
return
end
IF options.!debug == 1 THEN SAY ' Got child handle, start populating now'
ObjYPos = 1280+361+72-120
ObjXPos = 1325+72
ObjDelta= 380
CreatedObjs.0 = 0
Objs = 0
Page = 1 /* for global */
do I = 1 to sections.0
if Prophandle.1 <> recordhandle.I then iterate
Ok = VRset("Main", "Painting", 0)
ok = VRSet("Main", 'Pointer', 'WAIT' )
CurSection = sections.I
CurSIdx = I
upCurSection = translate(CurSection)
IF options.!debug == 1 THEN SAY ' Section ['sections.I']'
if upCurSection = 'GLOBAL' then do
ObjYPos = 1605+-120+361+361+361+361+361+361
ObjXPos = 1325
ObjDelta = 320
if Page = 1 then do
if \VRIsValidObject("GB_"ActiveGroup"_1") then do
ActiveGroupObj = VRCreate("GB_Global", "Window", "Name", "GL_GLOBAL_"Page, "Height", 1500, "Width", 1500, "Visible", 0, "Font", "9.WarpSans")
IF options.!debug == 1 THEN say ' Neues Fenster VRCreate = 'ok
ok = VRLoad( "GB_Global", VRWindowPath(), "GL_GLOBAL_"Page )
IF options.!debug == 1 THEN say ' VRLoad = 'ok
ok = VRMethod("GB_Global", "InsertPage", "GL_GLOBAL_"Page, "+"Page)
IF options.!debug == 1 THEN say ' InsertPage = 'ok
/* ok = VRset("Main", "Painting", 1)
ok = VRSet("Main", 'Pointer', '' )
Msg.Text = NLVGetMessage(114)
Msg.Type = "I"
call _ShowMsg
return */
end
ActiveGroupObj = VRGet("GB_"ActiveGroup"_1", "Self")
end
end
else do
if \VRIsValidObject("GB_"ActiveGroup) then do
ok = VRset("Main", "Painting", 1)
ok = VRSet("Main", 'Pointer', '' )
Msg.Text = NLVGetMessage(114)
Msg.Type = "I"
call _ShowMsg
return
end
ActiveGroupObj = "GB_"ActiveGroup
ok = VRSet("DT_"ActiveGroup,"Caption",sections.I)
end
say "CurSection="CurSection
say "smbconf="smbconf
/* ok = IniEnum("Voc", hdl) */ /* Old command: Fill the Voc stem with vocabulary */
call _MyIniEnum(CurSection)
if upCurSection <> 'GLOBAL' then do
ok = VRSet("CB_Read_Only", "set", 1)
end
do V = 1 to Voc.0 /* loop for every vocabulary */
ValueChanged = 0
ChangeList = ""
/* get value for this vocabulary */
Val.V = IniGet(Voc.V, CurSection, samba.!smbconf) /* this is currently done by _MyIniEnum (which is probably not good) */
select
when pos("\\",Val.V) > 0 then nop
when pos(" dir",Voc.V) > 0 then Val.V = _fs2bs(Val.V)
when pos("file",Voc.V) > 0 then Val.V = _fs2bs(Val.V)
when pos("path",Voc.V) > 0 then Val.V = _fs2bs(Val.V)
when pos("username map",Voc.V) > 0 then Val.V = _fs2bs(Val.V)
otherwise nop /* do not beautify */
end
IF options.!debug == 1 THEN say ' Process: "'Voc.V'" = "'Val.V'"'
/* Proper format to ease checking and object creation */
upVal = translate(Val.V)
upVoc = translate(translate(Voc.V,'_',' '))
if upVal = 'YES'| upVal = 'NO'
then VocObjType = 'CB'
else VocObjType = 'EF'
/* Non configurable items */
if upVoc = "PRINTABLE" then iterate
if pos('SCRIPT', upVoc) > 0 then iterate
if pos('COMMAND', upVoc) > 0 then iterate
if upVoc = "COMMENT" then do
CurPage = Page
CurActiveGroupObj = ActiveGroupObj
if Page <> 1 then ActiveGroupObj = VRGet("GB_"ActiveGroup"_1", "Self")
OldObjYPos = ObjYPos
if upCurSection = "GLOBAL" then ObjYPos = 860-120
else ObjYPos = 860+361+72
if _CreateVocObject() then do
ok = VRSet(VocObjType"_"upVoc, 'Value', Val.V)
ok = VRFlush( , VocObjType"_"upVoc )
end
ActiveGroupObj = CurActiveGroupObj
Page = CurPage
ObjYPos = OldObjYPos
end
else do /* Normalfall */
if _CreateVocObject() then do
if upVal = "YES" | upVal = "NO" then do
ok = VRset(VocObjType"_"upVoc,"Set", (upVal="YES"))
ok = VRFlush( , VocObjType"_"upVoc )
end
else do
ok = VRSet(VocObjType"_"upVoc, 'Value', Val.V)
ok = VRFlush( , VocObjType"_"upVoc )
if translate(VocObjType"_"upVoc) = VocObjType"_PRINTER_NAME" then do
ok = VRSet(VocObjType"_"upVoc, 'ReadOnly', 1)
ok = VRSet(VocObjType"_"upVoc, 'BackColor', 'PaleGray')
end
end
end
nop
end
ok = VRSet(VocObjType"_"upVoc, 'Userdata', V)
if upCurSection = 'GLOBAL' then do
if upVoc = "WINBIND_SEPARATOR" then do /* Workaround for Samba Ticket #57 */
ok = VRset("DT_WINBIND_SEPARATOR","Visible","0")
ok = VRset("EF_WINBIND_SEPARATOR","Value","|")
ok = VRFlush( , "EF_WINBIND_SEPARATOR" )
ok = VRset("EF_WINBIND_SEPARATOR","Visible",0)
ObjYPos = ObjYPos - ObjDelta
end
if ObjYPos > VRGet("GB_Global","Height") - 1200 then do
/* Ok = VRset("Main", "Painting", 1)
ok = VRSet("Main", 'Pointer', '' )*/
Page = Page + 1
if Page = 2 then do
Ok = VRset("Main", "Painting", 1)
Ok = VRset("Main", "Painting", 0)
ok = VRSet("Main", 'Pointer', 'Wait' )
end
if \VRIsValidOBject("GL_GLOBAL_"Page) then do
ActiveGroupObj = VRCreate("GB_Global", "Window", "Name", "GL_GLOBAL_"Page, "Height", 1500, "Width", 1500, "Visible", 0, "Font", "9.WarpSans")
IF options.!debug == 1 THEN say ' Neues Fenster VRCreate = 'ok
ok = VRLoad( "GB_Global", VRWindowPath(), "GL_GLOBAL_"Page )
IF options.!debug == 1 THEN say ' VRLoad = 'ok
ok = VRMethod("GB_Global", "InsertPage", "GL_GLOBAL_"Page, "+"Page)
IF options.!debug == 1 THEN say ' InsertPage = 'ok
end
else do
ActiveGroupObj = VRGet("GL_GLOBAL_"Page, "Self")
end
ObjYPos = 0
IF options.!debug == 1 THEN say " Page ="page
/* Ok = VRset("Main", "Painting", 0) */
end
end
end
end
if upCurSection = "GLOBAL" then do
if VRGet("EF_Netbios_name","Value") = "" then do
ok = VRset("EF_NETBIOS_NAME","Value",Value("HOSTNAME",,"OS2ENVIRONMENT"))
ok = VRFlush( , "EF_NETBIOS_NAME" )
end
if VRGet("EF_WorkGroup","Value") = "" then do
ok = VRset("EF_WorkGroup","Value","WORKGROUP")
ok = VRFlush( , "EF_WorkGroup" )
end
end
Ok = VRset("Main", "Painting", 1)
ok = VRSet("Main", 'Pointer', '' )
IF options.!debug == 1 THEN SAY 'CN_smbconf_Click() done'
return
/*:VRX CN_smbconf_ContextMenu
*/
CN_smbconf_ContextMenu:
ok = VRMethod( "CN_smbconf", "GetRecordList", "Selected", "Prophandle." )
if PropHandle.0 = 0 then return
ParentHandle = VRMethod("CN_smbconf","GetRecordAttr", Prophandle.1,"Parent")
ok = VRset("Menu_ShareContext_AddPrinter", "Visible", 0)
ok = VRset("Menu_ShareContext_RenamePrinter", "Visible", 0)
ok = VRset("Menu_ShareContext_RemovePrinter", "Visible", 0)
ok = VRset("Menu_ShareContext_Add", "Visible", 0)
ok = VRset("Menu_ShareContext_Rename", "Visible", 0)
ok = VRset("Menu_ShareContext_Remove", "Visible", 0)
if Prophandle.1 = smbconf.!root then ok = VRset("GB_Help", "Visible", 1)
if Prophandle.1 = smbconf.!global | Parenthandle = smbconf.!global then return
if Prophandle.1 = smbconf.!homes | Parenthandle = smbconf.!homes then return
if Prophandle.1 = smbconf.!dirs then do
ok = VRset("Menu_ShareContext_Add", "Visible", 1)
end
if Parenthandle = smbconf.!dirs then do
ok = VRset("Menu_ShareContext_Add", "Visible", 1)
ok = VRset("Menu_ShareContext_Rename", "Visible", 1)
ok = VRset("Menu_ShareContext_Remove", "Visible", 1)
end
if Prophandle.1 = smbconf.!printers then do
ok = VRset("Menu_ShareContext_AddPrinter", "Visible", 1)
end
if Parenthandle = smbconf.!printers then do
ok = VRset("Menu_ShareContext_AddPrinter", "Visible", 1)
ok = VRset("Menu_ShareContext_RenamePrinter", "Visible", 1)
ok = VRset("Menu_ShareContext_RemovePrinter", "Visible", 1)
end
ok = VRMethod( "Menu_ShareContext", "Popup", , , "", "" )
return
/*:VRX EF_display_charset_Change
*/
EF_display_charset_Change:
call _ShareObject_Changed
return
/*:VRX EF_dos_charset_Change
*/
EF_dos_charset_Change:
call _ShareObject_Changed
return
/*:VRX EF_Log_file_Change
*/
EF_Log_file_Change:
call _ShareObject_Changed
return
/*:VRX EF_LOG_LEVEL_Change
*/
EF_LOG_LEVEL_Change:
call _ShareObject_Changed
return
/*:VRX EF_NetBIOS_Name_Change
*/
EF_NetBIOS_Name_Change:
call _ShareObject_Changed
return
/*:VRX EF_path_Change
*/
EF_path_Change:
call _ShareObject_Changed
return
/*:VRX EF_RootPassword_Change
*/
EF_RootPassword_Change:
if length(VRGet("EF_RootPassword","Value")) < 5 then do
ok = VRSet("EF_RootPassword","ForeColor", "Red")
end
else ok = VRSet("EF_RootPassword","ForeColor", "")
return
/*:VRX EF_SECURITY_Change
*/
EF_SECURITY_Change:
call _ShareObject_Changed
return
/*:VRX EF_Server_String_Change
*/
EF_Server_String_Change:
call _ShareObject_Changed
return
/*:VRX EF_Unix_charset_Change
*/
EF_Unix_charset_Change:
call _ShareObject_Changed
return
/*:VRX EF_Workgroup_Change
*/
EF_Workgroup_Change:
call _ShareObject_Changed
return
/*:VRX Fini
*/
Fini:
window = VRWindow()
call VRSet window, "Visible", 0
drop window
return 0
/*:VRX GB_Global_1_Close
*/
GB_Global_1_Close:
call GB_Global_1_Fini
return
/*:VRX GB_Global_1_Create
*/
GB_Global_1_Create:
call GB_Global_1_Init
SysCP = SysQueryProcessCodePage()
ok = VRMethod( "EF_unix_charset", "AddString", "IBM-"SysCP, 2)
ok = VRMethod( "EF_display_charset", "AddString", "IBM-"SysCP, 2)
if pos("IBM-"SysCP, VRGet( "EF_dos_charset","InitialList")) = 0 then do
ok = VRMethod( "EF_dos_charset", "AddString", "IBM-"SysCP, 2)
end
return
/*:VRX GB_Global_1_Fini
*/
GB_Global_1_Fini:
window = VRInfo( "Window" )
call VRDestroy window
drop window
return
/*:VRX GB_Global_1_Init
*/
GB_Global_1_Init:
window = VRInfo( "Object" )
if( \VRIsChildOf( window, "Notebook" ) ) then do
call VRMethod window, "CenterWindow"
call VRSet window, "Visible", 1
call VRMethod window, "Activate"
end
drop window
return
/*:VRX Halt
*/
Halt:
signal _VREHalt
return
/*:VRX Init
*/
Init:
window = VRWindow()
call VRMethod window, "CenterWindow"
call VRSet window, "Visible", 1
call VRMethod window, "Activate"
drop window
return
/*:VRX Installer_Close
*/
Installer_Close:
Msg.Text = NLVGetMessage(114)
Msg.Type = "I"
call _ShowMsg
ok = SysSetObjectData("","PARAMETERS=/config;")
say "SysSetObjectData ok="ok
call Installer_Fini
return
/*:VRX Installer_Create
*/
Installer_Create:
call Installer_Init
CALL NLVSetText 'Installer', 'Caption', 90
CALL NLVSetText 'DT_RootPasswordDescription', 'Caption', 91
CALL NLVSetText 'DT_RootPassword', 'Caption', 92
CALL NLVSetText 'DT_RootPassword_repeat', 'Caption', 93
CALL NLVSetText 'CB_NoRoot', 'Caption', 94
CALL NLVSetText 'DT_Backend', 'Caption', 95
CALL NLVSetText 'DT_ServerType', 'Caption', 96
CALL NLVSetText 'PB_Install_Default', 'Caption', 97
CALL NLVSetText 'PB_Install_Migration', 'Caption', 98
ok = VRSet("PB_Install_Migration", "Enabled", lsshareiniexists * ibmlaniniexists )
ok = VRSet("TM_Installer","Enabled", 0)
if stream(samba.!group,'c','query exists') = "" | stream(samba.!group,'c','query size') < 120 then do
call _GroupCreate
end
if stream(samba.!masterpasswd,'c','query exists') = "" | stream(samba.!group,'c','query size') < 230 then do
call _MasterPasswdCreate
call _PasswordDBRewrite
ok = VRSet("CB_NoRoot","Enabled", 0)
end
if stream(samba.!pwddb,'c','query exists') = "" | stream(samba.!spwddb,'c','query exists') = "" then do
call _PasswordDBRewrite
ok = VRSet("CB_NoRoot","Enabled", 0)
end
if \VRFileExists(ETC'\samba\private\secrets.tdb') then do
ok = VRSet("CB_NoRoot","Enabled", 0)
end
UseTDBsam = 1
CreatePDC = 0
return
/*:VRX Installer_Fini
*/
Installer_Fini:
window = VRInfo( "Window" )
call VRDestroy window
drop window
return
/*:VRX Installer_Init
*/
Installer_Init:
window = VRInfo( "Object" )
if( \VRIsChildOf( window, "Notebook" ) ) then do
call VRMethod window, "CenterWindow"
call VRSet window, "Visible", 1
call VRMethod window, "Activate"
end
drop window
return
/*:VRX IPB_ChooseDir_Click
*/
IPB_ChooseDir_Click:
InitDir = VRGet("EF_Path","Value")
VarPos = pos('%', InitDir)
if VarPos > 0 then do
VarChar = substr(InitDir,VarPos,2)
InitDir = left(InitDir,VarPos-1)
say VarChar
end
NewPath = _dirDialog('Choose path for 'VRGet("DT_Shares","Caption"),_fs2bs(InitDir))
if NewPath = "" then return
if VarPos > 0 then NewPath = NewPath'\'VarChar
ok = VRset("EF_Path","value",NewPath)
return
/*:VRX IPB_NewItem_Click
*/
IPB_NewItem_Click:
smbconfopt = samba.!tools'\smbconf.opt'
say smbconfopt
do until lines(smbconfopt) = 0
smbconfline = linein(smbconfopt)
say smbconfline
I = I + 1
opt.I = smbconfline
end
opt.0 = I
ok = stream(smbconfopt,'c','close')
ok = VRMethod("DDCB_Add_Voc","Reset")
ok = VRMethod("DDCB_Add_Voc","AddStringList", opt.)
ok = VRSet("DDCB_Add_Voc","Top",ObjYPos-380)
ok = VRSet("EF_Add_Voc","Top",ObjYPos-380)
ok = VRSet("PB_Add_Voc_OK","Top",ObjYPos)
ok = VRSet("PB_Add_Voc_Cancel","Top",ObjYPos)
ok = VRSet("DDCB_ADD_Voc","Visible",1)
ok = VRSet("EF_ADD_Voc","Visible",1)
ok = VRSet("PB_Add_Voc_OK","Visible",1)
ok = VRSet("PB_add_Voc_Cancel","Visible",1)
return
/*:VRX Main_Close
*/
Main_Close:
call Quit
return
/*:VRX Main_Create
*/
Main_Create:
ok = VRREdirectStdIO("OFF")
options.!debug = 0
call _LoadOtherFuncs
call _INIRead
call _ParseCommandLine
call _InitTempDir
call _SambaInit
call _SambaExtendSearchPath
call _GUIInitNLV
call _FindHtpasswd
call Main_Resize
call _SambaCheckComponents
call _SambaVersion
call _FindIBMLANPath
call _SmbConfTreeInit /* creates the records for default sections */
/* Installation mode is triggered by a timer activated in GUIInit, when no smb.conf exists */
call _GUIInit
return
/*:VRX Main_Resize
*/
Main_Resize:
IF options.!debug == 1 THEN SAY "Main_Resize() started"
Ok = VRset("Main", "Painting", 0)
ok = VRSet("GB_SmbConfTree","Top", FWidth)
ok = VRSet("GB_SmbConfTree","Left", FWidth-24)
ok = VRSet("GB_SmbConfTree","Height", VRGet("Main", "Height") -1400)
ok = VRset("GB_SmbConfTree3","Top", FWidth)
ok = VRset("GB_SmbConfTree3","Left", FWidth)
ok = VRset("GB_SmbConfTree3","Height", 245 )
ok = VRset("GB_SmbConfTree3","Width", VRGet("GB_SmbConfTree","Width") -(FWidth*2))
ok = VRset("DT_SmbConfTree","Top", 8)
ok = VRset("DT_SmbConfTree","Left", 8)
ok = VRset("DT_SmbConfTree","Height", 213)
ok = VRset("DT_SmbConfTree","Width", VRGet("GB_SmbConfTree3","Width") - 24)
ok = VRset("GB_SmbConfTree2","Left", FWidth)
ok = VRset("GB_SmbConfTree2","Top", 245 + FWidth*2)
ok = VRset("GB_SmbConfTree2","Width", VRGet("GB_SmbConfTree","Width")-FWidth*2)
ok = VRset("GB_SmbConfTree2","Height", VRGet("GB_SmbConfTree","Height")-FWidth*3-245)
ok = VRset("CN_SmbConf", "Top", FWidth)
ok = VRset("CN_SmbConf", "Left", FWidth)
ok = VRset("CN_SmbConf", "Width", VRGet("GB_SmbConfTree2","Width") -(FWidth*2))
ok = VRset("CN_SmbConf", "Height", VRGet("GB_SmbConfTree2","Height")-(FWidth*2))
ok = VRset("GB_Help", "Top", FWidth)
ok = VRset("GB_Help", "Left", VRGet("GB_SmbConfTree","Width") + 60)
ok = VRSet("GB_Help", "Height", VRGet("GB_SmbConfTree","Height"))
ok = VRSet("GB_Help", "Width", VRGet("Main", "Width") - VRGet("GB_SmbConfTree","width") - 60- FWidth*2-24*2)
ok = VRset("GB_Help3","Top", FWidth)
ok = VRset("GB_Help3","Left", FWidth)
ok = VRset("GB_Help3","Height", 245 )
ok = VRset("GB_Help3","Width", VRGet("GB_Help","Width") -(FWidth*2))
ok = VRset("GB_Help2","Left", FWidth)
ok = VRset("GB_Help2","Top", 245 + FWidth*2)
ok = VRset("GB_Help2","Width", VRGet("GB_Help","Width")-FWidth*2)
ok = VRset("GB_Help2","Height", VRGet("GB_Help","Height")-FWidth*3-245)
ok = VRset("DT_Help","Top", 8)
ok = VRset("DT_Help","Left", 8)
ok = VRset("DT_Help","Height", 213)
ok = VRset("DT_Help","Width", VRGet("GB_Help3","Width") - 24)
ok = VRset("GB_Shares", "Top", FWidth)
ok = VRset("GB_Shares", "Left", VRGet("GB_SmbConfTree","Width") + 60)
ok = VRSet("GB_Shares", "Height", VRGet("GB_SmbConfTree","Height"))
ok = VRSet("GB_Shares", "Width", VRGet("Main", "Width") - VRGet("GB_SmbConfTree","width") - 60- FWidth*2-24*2)
ok = VRset("GB_Shares3","Top", FWidth)
ok = VRset("GB_Shares3","Left", FWidth)
ok = VRset("GB_Shares3","Height", 245 )
ok = VRset("GB_Shares3","Width", VRGet("GB_Shares","Width") -(FWidth*2))
ok = VRset("GB_Shares2","Left", FWidth)
ok = VRset("GB_Shares2","Top", 245 + FWidth*2)
ok = VRset("GB_Shares2","Width", VRGet("GB_Shares","Width")-FWidth*2)
ok = VRset("GB_Shares2","Height", VRGet("GB_Shares","Height")-FWidth*3-245)
ok = VRset("DT_Shares", "Top", 8)
ok = VRset("DT_Shares", "Left", 8)
ok = VRset("DT_Shares", "Height", 213)
ok = VRset("DT_Shares", "Width", VRGet("GB_Shares3","Width") - 24)
ok = VRSet("GB_Global", "Height", VRGet("GB_SmbConfTree","Height"))
ok = VRSet("GB_Global", "Width", VRGet("GB_Shares", "Width"))
MButton.bTop = VRGet("GB_SmbConfTree","height")+FWidth*2
MButton.bLeft = VRGet("GB_Shares","Left")
MButton.bWidth = VRGet("PB_Save","Width")
if MButton.bTop < 1300 & MButton.bLeft < 1300 then do
MButton.bTop = 4802
MButton.bLeft = 3758
MButton.bWidth = 1241
FWidth = 32
end
ok = VRSet("PB_Reload", "Top", MButton.bTop)
ok = VRSet("PB_Reload", "Left", VRGet("GB_SmbConfTree","Left"))
ok = VRSet("PB_Reload", "Width", MButton.bWidth)
ok = VRSet("PB_StartStop","Top", MButton.bTop)
ok = VRSet("PB_StartStop","Left", VRGet("GB_SmbConfTree","Width")-MButton.bWidth-FWidth)
ok = VRSet("PB_StartStop","Width", MButton.bWidth)
ok = VRSet("PB_Save", "Top", MButton.bTop)
ok = VRSet("PB_Save", "Left", MButton.bLeft)
ok = VRSet("PB_Reload", "Width", MButton.bWidth)
ok = VRSet("PB_Undo", "Top", MButton.bTop)
ok = VRSet("PB_Undo", "Left", MButton.bLeft+2*FWidth+MButton.bWidth*1)
ok = VRSet("PB_Undo", "Width", MButton.bWidth)
ok = VRSet("PB_Help", "Top", MButton.bTop)
ok = VRSet("PB_Help", "Left", MButton.bLeft+6*FWidth+MButton.bWidth*2)
ok = VRSet("PB_Help", "Width", MButton.bWidth)
ok = VRSet("PB_Cancel", "Top", MButton.bTop)
ok = VRSet("PB_Cancel", "Left", VRGet("Main","Width")-MButton.bWidth-FWidth*4)
ok = VRSet("PB_Cancel", "Width", MButton.bWidth)
drop MButton.b
Top = VRGet("Main","Top")
Left = VRGet("Main","Left")
Width = VRGet("Main","Width")
Height = VRGet("Main","Height")
if ActiveGroup = "Global" then do
end
IF options.!debug == 1 THEN SAY " Window size = "VRGet("Main","Width")', 'VRGet("Main","Height")
/* check and empty event queue, trash spurious resize events */
EventString = ''
TrashedResize = 0
do until EventString = 'nop'
EventString = VREvent('N')
say ' Event: "'EventString'" ('TrashedResize')'
if EventString <> 'nop' then do
if EventString = 'CALL Main_Resize' then TrashedResize = TrashedResize + 1
else interpret eventString
end
end
if TrashedResize >= 2 then CALL Main_Resize
IF options.!debug == 1 THEN SAY " Window size = "VRGet("Main","Width")', 'VRGet("Main","Height")
Ok = VRset("Main", "Painting", 1)
IF options.!debug == 1 THEN SAY "Main_Resize() done"
return
/*:VRX Menu_Action_AddHomes_Click
*/
Menu_Action_AddHomes_Click:
call _SmbConfDefault_Homes
call _SmbConfTreeInit
call _SmbConfLoad
return
/*:VRX Menu_Action_AddNetLogon_Click
*/
Menu_Action_AddNetLogon_Click:
call _SmbConfDefault_Netlogon
call _SmbConfTreeInit
call _SmbConfLoad
return
/*:VRX Menu_Action_AddProfiles_Click
*/
Menu_Action_AddProfiles_Click:
call _SmbConfDefault_Profiles
call _SmbConfTreeInit
call _SmbConfLoad
return
/*:VRX Menu_Action_EraseTransient_Click
*/
Menu_Action_EraseTransient_Click:
if _SambaRunning() then do
Msg.Text = NLVGetMessage(70)
Msg.Type = "E"
ok = _ShowMsg()
return
end
ok = VRMethod("CN_smbconf","SetRecordAttr", smbconf.!global, "Selected", 1)
call CN_smbconf_Click
if VRIsValidObject( "EF_LOCK_DIRECTORY" ) then do
LockDir = VRGet("EF_Lock_Directory","Value")
Msg.Text = NLVGetMessage(71)
Msg.Type = "Q"
ok = _MsgYesNo()
if ok <> 1 then return
ok = SysFileDelete(LockDir"\gencache.tdb")
ok = SysFileDelete(LockDir"\brlock.tdb")
ok = SysFileDelete(LockDir"\unexpected.tdb")
ok = SysFileDelete(LockDir"\connections.tdb")
ok = SysFileDelete(LockDir"\locking.tdb")
ok = SysFileDelete(LockDir"\messages.tdb")
end
return
/*:VRX Menu_File_Debug_Click
*/
Menu_File_Debug_Click:
options.!debug = VRGet("Menu_File_debug","Checked")
/* The following 2 lines are unnecessary for a checkbox ! */
ok = VRSet("Menu_File_debug","Checked",\options.!debug)
options.!debug = \options.!debug
if options.!debug
then ok = VRRedirectStdIO("On")
else ok = VRRedirectStdIO("OFF")
return
/*:VRX Menu_File_Exit_Click
*/
Menu_File_Exit_Click:
call Quit
return
/*:VRX Menu_File_Import_IBMPeer_Click
*/
Menu_File_Import_IBMPeer_Click:
call _SmbConfMigratePeer
ok = SysFileTree(smbconf,exist.,'FO')
SmbConfExists = exist.0
call _SmbConfTreeReset
return
/*:VRX Menu_File_ImportHosts_Click
*/
Menu_File_ImportHosts_Click:
if VRFileExists(ETC'\samba\lmhosts') then do
Msg.Text = NLVGetMessage(56, ETC'\samba\lmhosts')
Msg.Type = 'Q'
if _MsgYesNo() = 1 then do
call _LMHostsImport
end
end
else call _LMHostsImport
return
/*:VRX Menu_File_PrintCap_Click
*/
Menu_File_PrintCap_Click:
call _PrintcapCreate
Msg.Text = NLVGetMessage(50, samba.!printcap)
msg.Type = 'I'
call _ShowMsg
return
/*:VRX Menu_File_reset_Click
*/
Menu_File_reset_Click:
say "Menu_File_reset_Click() started"
workgroup = "WORKGROUP"
call _SmbConfCreateDefault
ok = SysFileTree(smbconf,exist.,'FO')
SmbConfExists = exist.0
call _SmbConfTreeReset
say "Menu_File_reset_Click() done"
return
/*:VRX Menu_File_SmbUpdate_Click
*/
Menu_File_SmbUpdate_Click:
BuildFile = VRFileDialog( VRWindow(), NLVGetMessage(64), "Open", options.!builddir"\samba-*zip", , , )
if BuildFile = '' then return
options.!builddir = VRParseFilename(buildfile,'DP')
address CMD samba.!smbcmd' stop'
OldDir = Directory(Strip(samba.!bin,'T','\'))
ok = VRRedirectStdIO('ON')
address cmd 'unzip.exe -oCj 'BuildFile' *.exe *.dll'
say 'unzip RC = 'RC
if RC <> 0 then address cmd 'PAUSE'
IF options.!debug <> 1 THEN ok = VRRedirectStdIO('OFF')
ok = directory(OldDir)
call _SambaVersion
ok = VRSet("EF_Binaries_Version","value",samba.!version)
address CMD samba.!smbcmd' start'
return
/*:VRX Menu_File_YumInstall_Click
*/
Menu_File_YumInstall_Click:
address cmd 'yum install --assumeyes libc libcx libgcc1 cups-libs popt-libs gettext-libs zlib readline'
return
/*:VRX Menu_Help_About_Click
*/
Menu_Help_About_Click:
say ' 'samba.!smbd' -V --debuglevel=0 2>'samba.!error' 1>'smboutput
address cmd samba.!smbd' -V --debuglevel=0 2>'samba.!error' 1>'smboutput
SambaVer = "Samba "||strip(linein(smboutput))
ok = stream(smboutput,'c','close')
window = VRLoadSecondary( "About", "W" )
return
/*:VRX Menu_Options_ExportMode_Click
*/
Menu_Options_ExportMode_Click:
say 'ExpertMode_Click started'
ok = VRSet("Main", 'Pointer', 'WAIT' )
log_level = IniGet('log level', 'global', samba.!smbconf)
if datatype(log_level) <> "NUM" then log_level = 2
say samba.!testparmexe' -v -s -d='log_level' 1>'TempDir'smb.conf 2>'TempDir'sscc.testparm'
address cmd samba.!testparmexe' -v -s -d='log_level' 1>'TempDir'smb.conf 2>'TempDir'sscc.testparm'
say 'VRCopyFile('TempDir'smb.conf, 'smbconf' )'
say " smb.conf GrӇe: "stream(smbconf,'c','QUERY SIZE')
ok = VRCopyFile( TempDir'smb.conf', smbconf )
say " smb.conf GrӇe: "stream(smbconf,'c','QUERY SIZE')
say 'Copy ok ='ok' (1 = success, 0 = failure)'
call _SmbConfTreeReset
call Main_Resize
ok = VRSet("Main", 'Pointer', '' )
say 'ExpertMode_Click done'
return
/*:VRX Menu_Options_MiniIcons_Click
*/
Menu_Options_MiniIcons_Click:
advanced.!bigicons = \advanced.!bigicons
ok = VRset("CN_SMBCONF", "MiniIcons", \advanced.!bigicons)
ok = VRset("Menu_Options_MiniIcons", "Checked", \advanced.!bigicons)
return
/*:VRX Menu_Options_SimpleMode_Click
*/
Menu_Options_SimpleMode_Click:
call _debuglog 'Menu_SimpleMode_Click() started'
ok = VRSet("Main", 'Pointer', 'WAIT' )
/* Workaround for testparm bugs */
say 'VRCopyFile('smbconf', 'TempDir'smb.conf )'
ok = VRCopyFile( smbconf, TempDir'smb.conf')
call _SmbConfCommitChanges
log_level = IniGet('log level', 'global', samba.!smbconf)
if datatype(log_level) <> "NUM" then log_level = 2
say samba.!testparmexe' -s -d='log_level' 1>'TempDir'smb.conf 2>'TempDir'sscc.testparm'
address cmd samba.!testparmexe' -s -d='log_level' 1>'TempDir'smb.conf 2>'TempDir'sscc.testparm'
NewSize = stream(TempDir"smb.conf",'c','QUERY SIZE')
say " "TempDir"smb.conf GrӇe: "NewSize
if NewSize = 0 then 'pause'
say " smb.conf GrӇe: "stream(smbconf,'c','QUERY SIZE')
say 'VRCopyFile('TempDir'smb.conf, 'smbconf' )'
ok = VRCopyFile( TempDir'smb.conf' , smbconf )
say " smb.conf GrӇe: "stream(smbconf,'c','QUERY SIZE')
say 'Copy ok ='ok' (1 = success, 0 = failure)'
call _SmbConfTreeReset
if datatype(Page) = "NUM" then do
do I = Page to 3 by -1
ok = VRMethod( "GB_Global", "DeletePage", I )
ok = VRDestroy("GL_GLOBAL_"I)
end
end
Page = 2
call Main_resize
ok = VRSet("Main", 'Pointer', '<>default' )
call _debuglog 'Menu_SimpleMode_Click() done'
return
/*:VRX Menu_ShareContext_Add_Click
*/
Menu_ShareContext_Add_Click:
NewShareDir = _dirDialog()
if NewShareDir = "" then return
NewShareName = filespec("N",NewShareDir)
Buttons.1 = "OK"
Buttons.2 = "Abort"
Buttons.0 = 2
id = VRPrompt( VRWindow(), "Enter name for new share", "NewShareName", "Add new Samba share", "Buttons.", buttons.1, buttons.2 )
if ID = 2 | NewShareName = "" then return
NewShareHandle = VRMethod( "CN_smbconf", "AddRecord", smbconf.!dirs,, NewShareName,"#4")
call lineout smbconf, '['NewShareName']'
call lineout smbconf, Indent||'path = '_bs2fs(NewShareDir)
call lineout smbconf, Indent||'comment = 'NewShareName' directory'
call lineout smbconf, Indent||'browseable = Yes'
call lineout smbconf, Indent||'read only = Yes'
call lineout smbconf, Indent||'hide files = /*.?SF/'
call lineout smbconf
call _SmbConfTreeReset
Msg.Text = NLVGetMessage(69)
Msg.Type = 'I'
call _ShowMsg
ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!dirs, "Collapsed", 0 )
ok = VRMethod("CN_smbconf","SetRecordAttr",NewShareHandle, "Selected", 1 )
return
/*:VRX Menu_ShareContext_AddPrinter_Click
*/
Menu_ShareContext_AddPrinter_Click:
AbortPrinter = 1
window = VRLoadSecondary( "PrinterSelection", "W" )
if AbortPrinter then return
parse var SharePrinter PrinterName';'PrinterQueue';'PrinterDriver
NewShareHandle = VRMethod( "CN_smbconf", "AddRecord", smbconf.!printers,, PrinterQueue,"#4")
call lineout smbconf, '['PrinterQueue']'
call lineout smbconf, Indent||'path = '_bs2fs(ETC'\samba\spool\'printerqueue)
ok = SysMkDir(ETC'\samba\spool\'printerqueue)
call lineout smbconf, Indent||'comment = 'Printername
call lineout smbconf, Indent||'create mask = 0700'
call lineout smbconf, Indent||'printer name = 'printerqueue
call lineout smbconf, Indent||'printing = os2'
call lineout smbconf, Indent||'printable = Yes'
call lineout smbconf, Indent||'print command = 'samba.!bin'\smbprint.exe "%s" "%p" "%J" "%c" "%z"'
call lineout smbconf, Indent||'browseable = Yes'
call lineout smbconf, Indent||'guest ok = Yes'
call lineout smbconf, Indent||'read only = No'
call lineout smbconf
call _SmbConfTreeReset
Msg.Text = NLVGetMessage(69)
Msg.Type = 'I'
call _ShowMsg
ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!printers, "Collapsed", 0 )
ok = VRMethod("CN_smbconf","SetRecordAttr",NewShareHandle, "Selected", 1 )
return
/*:VRX Menu_ShareContext_Remove_Click
*/
Menu_ShareContext_Remove_Click:
call _SmbConfShareRemove
if \Aborted then ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!dirs, "Collapsed", 0 )
return
/*:VRX Menu_ShareContext_RemovePrinter_Click
*/
Menu_ShareContext_RemovePrinter_Click:
call _SmbConfShareRemove
if \Aborted then ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!printers, "Collapsed", 0 )
return
/*:VRX Menu_ShareContext_Rename_Click
*/
Menu_ShareContext_Rename_Click:
call _SmbConfShareRename
if \Aborted then ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!dirs, "Collapsed", 0 )
return
/*:VRX Menu_ShareContext_RenamePrinter_Click
*/
Menu_ShareContext_RenamePrinter_Click:
call _SmbConfShareRename
if \Aborted then ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!printers, "Collapsed", 0 )
return
/*:VRX PB_1_Click
*/
PB_1_Click:
ok = VRREdirectStdIO("ON")
Buttons.1 = NLVGetMessage(2)
Buttons.2 = NLVGetMessage(3)
Buttons.0 = 2
command = 'd:\samba\smbpasswd.exe'
id = VRPrompt( VRWindow(), "Console", "command", "Console", "Buttons.", buttons.1, buttons.2 )
if id = 2 then return
say command
address cmd command
/* samba.!netexe' rpc 'command' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg */
/* if RC <> 0 then call _SambaShowError; else call _SambaShowMsg */
return
/*:VRX PB_AboutOK_Click
*/
PB_AboutOK_Click:
call About_Close
return
/*:VRX PB_Add_Voc_Cancel_Click
*/
PB_Add_Voc_Cancel_Click:
drop opt.
ok = VRSet("DDCB_Add_Voc","Value","")
ok = VRSet("EF_Add_Voc", "Value","")
ok = VRSet("DDCB_ADD_Voc","Visible",0)
ok = VRSet("EF_ADD_Voc","Visible",0)
ok = VRSet("PB_Add_Voc_OK","Visible",0)
ok = VRSet("PB_add_Voc_Cancel","Visible",0)
return
/*:VRX PB_Add_Voc_OK_Click
*/
PB_Add_Voc_OK_Click:
NewVoc = VRGet("DDCB_Add_Voc","Value")
NewValue=VRGet("EF_Add_Voc", "Value")
call IniSet NewVoc, NewValue, CurSection, samba.!smbconf
drop opt.
ok = VRSet("DDCB_Add_Voc","Value","")
ok = VRSet("EF_Add_Voc", "Value","")
ok = VRSet("DDCB_ADD_Voc","Visible",0)
ok = VRSet("EF_ADD_Voc","Visible",0)
ok = VRSet("PB_Add_Voc_OK","Visible",0)
ok = VRSet("PB_add_Voc_Cancel","Visible",0)
call Menu_Options_SimpleMode_Click
return
/*:VRX PB_Cancel_Click
*/
PB_Cancel_Click:
IF options.!debug == 1 THEN say 'PB_Cancel_Click() started'
if VRGet("PB_Save","Enabled") then call PB_Save_Click
call Quit
IF options.!debug == 1 THEN say 'PB_Cancel_Click() done'
return
/*:VRX PB_Help_Click
*/
PB_Help_Click:
return
/*:VRX PB_Install_Default_Click
*/
PB_Install_Default_Click:
if VRGet("EF_Workgroup_Initial","Value") = "" then return
if \VRGet("CB_NoRoot","Set") then do
if \_SambaRootPWCheck() then return
end
workgroup = VRGet("EF_WORKGROUP","Value")
call _SmbConfCreateDefault
/* call _Smb35Init */
ok = SysFileTree(smbconf,exist.,'FO')
SmbConfExists = exist.0
call _SmbConfBackup
call _SmbConfTreeReset
if \VRGet("CB_NoRoot","Set") then do
call _SambaRootPWSet
end
call _SambaGuestCreate
call _SambaUserCreate
ok = VRSet("Main", 'Pointer', 'WAIT' )
call _SambaGroupMapInst
ok = VRSet("Main", 'Pointer', '' )
/* call Menu_File_ImportHosts_Click */
call Installer_Close
return
/*:VRX PB_Install_Migration_Click
*/
PB_Install_Migration_Click:
if VRGet("EF_Workgroup_Initial","Value") = "" then return
if \VRGet("CB_NoRoot","Set") then do
if \_SambaRootPWCheck() then return
end
call _SmbConfMigratePeer
ok = SysFileTree(smbconf,exist.,'FO')
SmbConfExists = exist.0
call _SmbConfBackup
call _SmbConfTreeReset
if \VRGet("CB_NoRoot","Set") then do
call _SambaRootPWSet
end
call _SambaGuestCreate
call _SambaUserCreate
ok = VRSet("Main", 'Pointer', 'WAIT' )
call _SambaGroupMapInst
ok = VRSet("Main", 'Pointer', '' )
/* call Menu_File_ImportHosts_Click */
call Installer_Close
return
/*:VRX PB_Printer_Abort_Click
*/
PB_Printer_Abort_Click:
call PrinterSelection_Close
return
/*:VRX PB_Printer_OK_Click
*/
PB_Printer_OK_Click:
SharePrinter = RawPrinter(VRGet("LB_Printers","SelectedString"))
AbortPrinter = 0
say SharePrinter
call PrinterSelection_Close
return
RawPrinter:
do I = 1 to printer.0 until PurePrinter(printer.I) = arg(1)
end
return printer.I
/*:VRX PB_Reload_Click
*/
PB_Reload_Click:
call PB_Save_Click
call beep 960, 1
address CMD samba.!smbcmd' reload'
return
/*:VRX PB_RemoveContinue_Click
*/
PB_RemoveContinue_Click:
if VRGet("CB_RemoveSmbConf","set") then do
ok = SysFileDelete(samba.!smbconf)
SmbConfExists = 0
Installmode = 1
end
else Installmode = 0
if VRGet("CB_RemoveBackend","set") then do
ok = SysFileTree(ETC"\samba\*.?db",xdb.,'FOS')
do I = 1 to xdb.0
ok = SysFileDelete(xdb.I)
if ok <> 0 then do
Msg.Text = "Error "ok" deleting "xdb.I"!"
Msg.Type = "W"
call _ShowMsg
end
end
end
if VRGet("CB_RemoveLMHosts","set") then do
call _LMHostsImport
end
if VRGet("CB_YumInstall","set") then do
call Menu_File_YumInstall_Click
end
call RemoveConfig_Close
return
/*:VRX PB_Save_Click
*/
PB_Save_Click:
IF options.!debug == 1 THEN say 'PB_Save_Click() started'
if ValueChanged then do
if CurSection <> "" then do
call _SaveChanges
ok = VRSet("PB_Save", "Enabled", 0)
call CN_smbconf_Click
end
end
IF options.!debug == 1 THEN say 'PB_Save_Click() done'
return
/*:VRX PB_StartStop_Click
*/
PB_StartStop_Click:
call PB_Save_Click
call beep 960, 1
if _SambaRunning() then do
address CMD samba.!smbcmd' stop'
ok = VRSet("PB_StartStop", "BackColor", "Green")
ok = VRSet("PB_StartStop", "Caption", startst)
end
else do
address CMD samba.!smbcmd' start'
ok = VRSet("PB_StartStop", "BackColor", "Red")
ok = VRSet("PB_StartStop", "Caption", stopst)
end
return
/*:VRX PB_Undo_Click
*/
PB_Undo_Click:
call _SmbConfRestore
SmbConfExists = 1
call _SmbConfTreeReset
return
/*:VRX PrinterSelection_Close
*/
PrinterSelection_Close:
call PrinterSelection_Fini
return
/*:VRX PrinterSelection_Create
*/
PrinterSelection_Create:
call PrinterSelection_Init
ok = VRMethod( "Application", "ListPrinters", "printer." )
CALL NLVSetText 'Printerselection', 'Caption', 40
CALL NLVSetText 'PB_Printer_OK', 'Caption', 2
CALL NLVSetText 'PB_Printer_Abort', 'Caption', 3
do I = 1 to printer.0
ok = VRMethod("LB_Printers","AddString",PurePrinter(printer.I))
if PurePrinter(printer.!default) = PurePrinter(printer.I) then ok = VRSet("LB_Printers","Selected",I)
end
return
/*:VRX PrinterSelection_Fini
*/
PrinterSelection_Fini:
window = VRInfo( "Window" )
call VRDestroy window
drop window
return
/*:VRX PrinterSelection_Init
*/
PrinterSelection_Init:
window = VRInfo( "Object" )
if( \VRIsChildOf( window, "Notebook" ) ) then do
call VRMethod window, "CenterWindow"
call VRSet window, "Visible", 1
call VRMethod window, "Activate"
end
drop window
return
/*:VRX PurePrinter
*/
PurePrinter:
return substr(arg(1),1,pos(';',arg(1))-1)
/*:VRX Quit
*/
Quit:
IF options.!debug == 1 THEN say "Quit() start"
if VRGet("Main","WindowState") = "Maximized"|,
VRGet("Main","WindowState") = "Minimized" then ok = VRMethod("Main", "Restore")
if samba.!testparmexe <> "" & Installmode = 0 then do
if datatype("log_level") <> "NUM" then log_level = VRGet("EF_LOG_LEVEL","Value")
call lineout "D:\testlog", "das erste log_level = '"log_level"'"
call lineout "D:\testlog", "pos check "pos(log_level,'012345678910')
if pos(log_level,'012345678910') = 0 then log_level = 2
call lineout "D:\testlog", "Das zweite log_level = '"log_level"'"
say samba.!testparmexe' -s -d='log_level' 1>'TempDir'smb.conf 2>'TempDir'sscc.testparm'
address cmd samba.!testparmexe' -s -d='log_level' 1>'TempDir'smb.conf 2>'TempDir'sscc.testparm'
call _SmbConfCommitChanges
end
call _INIWrite
call _SambaFinish
ok = SysFileDelete(TempDir'sscc.testparm')
ok = SysFileDelete(smboutput)
IF options.!debug == 1 THEN say "Quit() done"
/* ok = VRRedirectStdio('OFF') */
window = VRWindow()
call VRSet window, "Shutdown", 1
drop window
return
/*:VRX RB_PDC_Click
*/
RB_PDC_Click:
CreatePDC = VRGet("RB_PDC","Set")
return
/*:VRX RB_smbpasswd_Click
*/
RB_smbpasswd_Click:
UseTDBsam = 0
return
/*:VRX RB_Standalone_Click
*/
RB_Standalone_Click:
CreatePDC = \VRGet("RB_Standalone","Set")
return
/*:VRX RB_tdbsam_Click
*/
RB_tdbsam_Click:
UseTDBsam = 1
return
/*:VRX RemoveConfig_Close
*/
RemoveConfig_Close:
ok = SysSetObjectData("","PARAMETERS=/config;")
say "SysSetObjectData ok="ok
call RemoveConfig_Fini
return
/*:VRX RemoveConfig_Create
*/
RemoveConfig_Create:
call RemoveConfig_Init
CALL NLVSetText 'RemoveConfig', 'Caption', 90
CALL NLVSetText 'PB_RemoveContinue', 'Caption', 14
ok = VRset("CB_RemoveSmbConf","Caption", NLVGetMessage(56, 'smb.conf'))
ok = VRset("CB_RemoveBackend","Caption", NLVGetMessage(56, 'Backend'))
ok = VRset("CB_RemoveLMHosts","Caption", NLVGetMessage(56, 'lmhosts'))
ok = VRset("CB_YumInstall","Caption", NLVGetMessage(99))
/* Check if ?db backend files exist */
ok = SysFileTree(ETC"\samba\*.?db",xdb.,'FOS')
if xdb.0 = 0 then ok = VRset("CB_RemoveBackend","Enabled", 0)
/* Check if LMHOsts exists */
ok = VRset("CB_RemoveLMHosts","Enabled", VRFileExists(ETC'\samba\lmhosts'))
return
/*:VRX RemoveConfig_Fini
*/
RemoveConfig_Fini:
window = VRInfo( "Window" )
call VRDestroy window
drop window
return
/*:VRX RemoveConfig_Init
*/
RemoveConfig_Init:
window = VRInfo( "Object" )
if( \VRIsChildOf( window, "Notebook" ) ) then do
call VRMethod window, "CenterWindow"
call VRSet window, "Visible", 1
call VRMethod window, "Activate"
end
drop window
return
/*:VRX TM_Installer_Trigger
*/
TM_Installer_Trigger:
call _InstallerMode
return
/*:VRX TM_Value_Trigger
*/
TM_Value_Trigger:
say "TM_Value_Trigger started"
ValueChanged = 0
ok = VRSet("PB_Save", "Enabled", 0)
ChangeList = ""
ok = VRSet("TM_Value", "Enabled", 0)
say "TM_Value_Trigger done"
return