source: trunk/guitools/sscc/sscc.vrx @ 875

Last change on this file since 875 was 875, checked in by Herwig Bauernfeind, 6 years ago

GUITools: SSCC (Ticket #248), SMBMon (TDB Check page), EVFSGUI, shared library updates

File size: 111.7 KB
Line 
1/*:VRX         Main
2*/
3/*  Main
4*/
5Main:
6/*  Process the arguments.
7    Get the parent window.
8*/
9    parse source . calledAs .
10    parent = ""
11    argCount = arg()
12    argOff = 0
13    if( calledAs \= "COMMAND" )then do
14        if argCount >= 1 then do
15            parent = arg(1)
16            argCount = argCount - 1
17            argOff = 1
18        end
19    end; else do
20        call VROptions 'ImplicitNames'
21        call VROptions 'NoEchoQuit'
22    end
23    InitArgs.0 = argCount
24    if( argCount > 0 )then do i = 1 to argCount
25        InitArgs.i = arg( i + argOff )
26    end
27    drop calledAs argCount argOff
28
29/*  Load the windows
30*/
31    call VRInit
32    parse source . . spec
33    _VREPrimaryWindowPath = ,
34        VRParseFileName( spec, "dpn" ) || ".VRW"
35    _VREPrimaryWindow = ,
36        VRLoad( parent, _VREPrimaryWindowPath )
37    drop parent spec
38    if( _VREPrimaryWindow == "" )then do
39        call VRMessage "", "Cannot load window:" VRError(), ,
40            "Error!"
41        _VREReturnValue = 32000
42        signal _VRELeaveMain
43    end
44
45/*  Process events
46*/
47    call Init
48    signal on halt
49    do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
50        _VREEvent = VREvent()
51        interpret _VREEvent
52    end
53_VREHalt:
54    _VREReturnValue = Fini()
55    call VRDestroy _VREPrimaryWindow
56_VRELeaveMain:
57    call VRFini
58exit _VREReturnValue
59
60VRLoadSecondary:
61    __vrlsWait = abbrev( 'WAIT', translate(arg(2)), 1 )
62    if __vrlsWait then do
63        call VRFlush
64    end
65    __vrlsHWnd = VRLoad( VRWindow(), VRWindowPath(), arg(1) )
66    if __vrlsHWnd = '' then signal __vrlsDone
67    if __vrlsWait \= 1 then signal __vrlsDone
68    call VRSet __vrlsHWnd, 'WindowMode', 'Modal'
69    __vrlsTmp = __vrlsWindows.0
70    if( DataType(__vrlsTmp) \= 'NUM' ) then do
71        __vrlsTmp = 1
72    end
73    else do
74        __vrlsTmp = __vrlsTmp + 1
75    end
76    __vrlsWindows.__vrlsTmp = VRWindow( __vrlsHWnd )
77    __vrlsWindows.0 = __vrlsTmp
78    do while( VRIsValidObject( VRWindow() ) = 1 )
79        __vrlsEvent = VREvent()
80        interpret __vrlsEvent
81    end
82    __vrlsTmp = __vrlsWindows.0
83    __vrlsWindows.0 = __vrlsTmp - 1
84    call VRWindow __vrlsWindows.__vrlsTmp
85    __vrlsHWnd = ''
86__vrlsDone:
87return __vrlsHWnd
88
89/*:VRX         __VXREXX____APPENDS__
90*/
91__VXREXX____APPENDS__:
92/*
93#append U:\Develop\Samba\guitools-1.0\shared\inittempdir.vrs
94#append U:\Develop\Samba\guitools-1.0\shared\sambainit.vrs
95#append U:\Develop\Samba\guitools-2.0\shared\nlv.vrs
96#append U:\Develop\Samba\guitools-1.0\shared\swat.vrs
97*/
98return
99/*:VRX         _ActiveGroup
100*/
101_ActiveGroup:
102    ActiveGroup = translate(arg(1))
103    ActiveGroupObj = VRGet("GB_"ActiveGroup, "Self")
104    ok = VRset(ActiveGroupObj, "Visible", 1)
105return
106
107/*:VRX         _bs2fs
108*/
109_bs2fs: procedure
110    string = arg(1)
111return translate(string,'/','\')
112
113/*:VRX         _CfgPageSetupSize
114*/
115_CfgPageSetupSize:
116    if arg(1) = "GB_Global"
117        then ok = VRset(arg(1), "Top", 0)
118        else ok = VRset(arg(1), "Top", Fwidth)
119
120    ok = VRset(arg(1), "Left",VRGet("GB_SmbConfTree","Width") + 60)
121
122    if arg(1) = "GB_Global"
123        then ok = VRset(arg(1), "Height",VRGet("GB_SmbConfTree","height")+FWidth)
124        else ok = VRset(arg(1), "Height",VRGet("GB_SmbConfTree","height"))
125
126    ok = VRset(arg(1), "Width", VRGet("Main", "Width") - VRGet("GB_SmbConfTree","width") - 60- FWidth*2-24*2)
127return
128
129/*:VRX         _ChooseDir
130*/
131_ChooseDir:
132    Invoked = VRInfo("Object")
133    InitDir = VRGet("EF_"||substr(VRGet(Invoked, "name"),5),"Value")
134    if pos('\\',InitDir) > 0 then do
135        Msg.Text = NLVGetMessage(63,InitDir)
136        Msg.Type = "E"
137        call _ShowMsg
138        return
139    end
140    VarPos = pos('%', InitDir)
141    if VarPos > 0 then do
142        VarChar = substr(InitDir,VarPos,2)
143        InitDir = left(InitDir,VarPos-1)
144        say VarChar
145    end
146    NewPath = _dirDialog('Choose path for 'VRGet("DT_Shares","Caption"),_fs2bs(InitDir))
147    if NewPath = "" then return
148    if VarPos > 0 then NewPath = NewPath'\'VarChar
149    ok = VRset("EF_"||substr(VRGet(Invoked, "name"),5),"value",NewPath)
150return
151
152/*:VRX         _CreateVocObject
153*/
154_CreateVocObject:
155    IF options.!debug == 1 THEN say "_CreateVocObject() started"
156    If VRIsValidObject(VocObjType"_"upVoc ) then Success = 1
157    else do
158        /* Creative descriptive text */
159        Objs = Objs + 1
160        Voc.V = translate(left(Voc.V,1))||substr(Voc.V,2)
161        CreatedObjs.Objs = VRCreate(ActiveGroupObj, "DescriptiveText", "Name", "DT_"upVoc, 'Caption', Voc.V, "Top", ObjYPos+50 , "Left", 120+72, "Visible", 1, "AutoSize", 1)
162        select
163            when pos("\\",Val.V) > 0 then nop
164            when pos(" dir",Voc.V) > 0 then ok = VRSet(CreatedObjs.Objs, "Forecolor", "Black")
165            when pos("file",Voc.V) > 0 then ok = VRSet(CreatedObjs.Objs, "Forecolor", "Black")
166            when pos("path",Voc.V) > 0 then ok = VRSet(CreatedObjs.Objs, "Forecolor", "Black")
167            otherwise nop /* do not beautify */
168        end
169
170        DT_Handle = CreatedObjs.Objs
171        /* The CB or EF */
172        Objs = Objs + 1
173        select
174            when VocObjType = "CB" then do
175                CreatedObjs.Objs = VRCreate(ActiveGroupObj, "Checkbox",   "Name", VocObjType"_"upVoc, "Top", ObjYPos+30, "AutoSize", 1)
176                ok = VRSet(VocObjType"_"upVoc, "Click", "call _ShareObject_Changed")
177            end
178            otherwise do
179                CreatedObjs.Objs = VRCreate(ActiveGroupObj, "EntryField", "Name", VocObjType"_"upVoc, "Top", ObjYPos   , "Width", 2800, "Height", "253")
180                ok = VRSet(VocObjType"_"upVoc, "Change", "call _ShareObject_Changed")
181            end
182        end
183        Success = (CreatedObjs.OBjs <> "")
184        if Success then do /* SUccess */
185            ok = VRSet(VocObjType"_"upVoc, "Left", max(1500, 120*2+VRGet(DT_handle,"Width")))
186            if VocObjType = "EF" & upCurSection ="GLOBAL" then do
187                OWidth = 2800-max(0,VRGet(VocObjType"_"upVoc, "Left")-1500)
188                if datatype(Val.V) = "NUM" then OWidth = length(Val.V)*90+200
189                                           else OWidth = length(Val.V)*90+440
190                if Val.V = "" then OWidth = 1500
191                ok = VRSet(VocObjType"_"upVoc, "Width", OWidth)
192                if (pos("_DIRECTORY",upVoc) > 0 | pos("_PATH",upVoc) > 0) & pos("MODE",upVoc) = 0 & pos("MASK",upVoc) = 0 then do
193                    Objs = Objs + 1
194                    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)
195                    ok = VRSet("IPB_"upVoc, "Click", "call _ChooseDir")
196                    ok = VRSet("IPB_"upVoc,"Width" ,VRMethod( "Screen", "PixelsToTwips", 20 ))
197                    ok = VRSet("IPB_"upVoc,"Height",VRMethod( "Screen", "PixelsToTwips", 20 ))
198                end
199            end
200           
201         /* ok = VRSet(VocObjType"_"upVoc, "BackColor", "Red") */
202            ok = VRSet(VocObjType"_"upVoc, "Visible", 1)
203            CreatedObjs.0 = Objs
204            ObjYPos= ObjYPos + ObjDelta
205        end
206        else do
207            say "Failed to Create "||VocObjType"_"upVoc||' in 'ActiveGroupObj
208        end
209    end
210    IF options.!debug == 1 THEN say '  Object: "'VocObjType'_'upVoc'" Value: "'Val.V'" Handle:"'CreatedObjs.Objs'"'
211    IF options.!debug == 1 THEN say "_CreateVocObject() done"
212return Success
213/*:VRX         _dirdialog
214*/
215_DirDialog: procedure
216    Title   = arg(1)
217    InitDir = arg(2)
218    RC = RxFuncQuery("DRCtrlPickDirectory")
219    if RC = 0 then do /* use DrCtrl if available */
220        MyDir=DRCtrlPickDirectory(InitDir, Title)
221    end
222    else do
223        MyDir = VRFileDialog(VRWindow,Title, 'o', InitDir||'\dummy')
224        if MyDir <> '' then MyDir = strip(filespec('D',MyDir)||Filespec('P',MyDir),'T','\')
225    end
226return MyDir
227/*:VRX         _FindIBMLANPath
228*/
229_FindIBMLANPath:
230    say '_FindIBMLANPath() started.'
231    ibmlanini  = SysBootDrive()'\IBMLAN\IBMLAN.INI'
232    ibmlaniniexists = VRFileExists(ibmlanini)
233    say '  Does "'ibmlanini'" exist? 'ibmlaniniexists' (1=Yes, 0=No)'
234
235    lsshareini = SysBootDrive()'\IBMLAN\LSSHARE.INI'
236    lsshareiniexists = VRFileExists(lsshareini)
237    say '  Does "'lsshareini'" exist? 'lsshareiniexists' (1=Yes, 0=No)'
238    say '_FindIBMLANPath() done.'
239return
240
241/*:VRX         _fs2bs
242*/
243_fs2bs: procedure
244    string = arg(1)
245return translate(string,'\','/')
246
247/*:VRX         _GroupCreate
248*/
249_GroupCreate:
250    /* Create kLIBC group file */
251    ok = SysFileDelete(samba.!group)
252    call lineout samba.!group, '# Created by SSCC ver. 'word(VRGet("Main","Hinttext"),2)
253    call lineout samba.!group, '# syntax:'
254    call lineout samba.!group, '# groupname:password:GID:user[,user,...,]'
255    call lineout samba.!group, 'admin:*:512:root,'
256    call lineout samba.!group, 'users:*:513:'
257    call lineout samba.!group, 'guests:*:514:'
258    call lineout samba.!group, 'machines:*:515:'
259    call lineout samba.!group, 'dc:*:516:'
260    call lineout samba.!group, 'certadmin:*:517:'
261    call lineout samba.!group, 'schemeadmin:*:518:'
262    call lineout samba.!group, 'entadmin:*:519:'
263    call lineout samba.!group, 'poladmin:*:520:'
264    ok = stream(samba.!group,'c','close')
265return
266/*:VRX         _GUIInit
267*/
268_GUIInit:
269    if datatype(Top) = 'NUM' then do
270        ok = VRset("Main","Top",Top)
271        ok = VRset("Main","Left",Left)
272        ok = VRset("Main","Width",Width)
273        ok = VRset("Main","Height",Height)
274    end
275    else ok = VRset("Main","Width", 9250)
276
277    settings.!curfcolor = VRGetIni('PM_Default_Colors', 'ActiveTitleText', 'User', 'NoClose')
278    settings.!curbcolor = VRGetIni('PM_Default_Colors', 'ActiveTitleTextBgnd', 'User')
279
280    ok = VRSet("DT_SmbConfTree","BACKCOLOR", settings.!curbcolor )
281    ok = VRSet("DT_SmbConfTree","FORECOLOR", settings.!curfcolor )
282
283    ok = VRSet("EF_Binaries_Version","value",samba.!version)
284    ok = VRSet("EF_Binaries_Path","value",samba.!bin)
285    ok = VRSet("EF_Scripts_Path","value",samba.!tools)
286    ok = VRSet("EF_UnixRoot_Path","value",UnixRoot)
287    ok = VRSet("EF_ETC_Path","value",ETC)
288    ok = VRSet("CN_SmbConf","Caption", smbconf)
289    ok = VRSet("IPB_ChooseDir","Width" ,VRMethod( "Screen", "PixelsToTwips", 20 ))
290    ok = VRSet("IPB_ChooseDir","Height",VRMethod( "Screen", "PixelsToTwips", 20 ))
291    ok = VRSet("IPB_NewItem","Width" ,VRMethod( "Screen", "PixelsToTwips", 20 ))
292    ok = VRSet("IPB_NewItem","Height",VRMethod( "Screen", "PixelsToTwips", 20 ))
293
294    ok = VRSet("Menu_File_Import_IBMPeer", "Enabled", lsshareiniexists * ibmlaniniexists )
295
296    ok = VRSet("Menu_Options_MiniIcons","Checked", \advanced.!bigicons)
297    ok = VRset("CN_smbconf","MiniIcons", \advanced.!bigicons)
298
299    if _ChkTempFreeSpace() < 262144 then do
300        Msg.Type = "W"
301        Msg.Text = NLVGetMessage(116, TempDir)
302        call _ShowMsg
303    end
304
305    ok = VRSet("Menu_File_PrintCap","Enabled", \IsCupsPrintcap)
306    if \IsCupsPrintcap then call _PrintCapCreate
307
308    if SmbConfExists then call _SmbConfLoad
309                     else ok = VRSet("TM_Installer","Enabled", 1)
310return
311
312/*:VRX         _GUIInitNLV
313*/
314_GUIInitNLV:
315    say '_GUIInitNLV started'
316    CALL NLVSetup
317    CALL NLVSetText 'Main', 'Caption', 1
318    Msg.Title = VRGet("Main", "Caption")
319
320    CALL NLVSetText 'PB_Reload',        'Caption',   11
321    CALL NLVSetText 'PB_Reload',        'Hinttext', 111
322    CALL NLVSetText 'PB_Save',        'Caption',   12
323    CALL NLVSetText 'PB_Save',        'Hinttext', 112
324    CALL NLVSetText 'PB_Undo',          'Caption',    9
325    CALL NLVSetText 'PB_Undo',          'Hinttext', 109
326    CALL NLVSetText 'PB_Cancel',        'Caption',   10
327    CALL NLVSetText 'PB_Cancel',        'Hinttext', 110
328    CALL NLVSetText 'PB_Help',          'Caption',    4
329    CALL NLVSetText 'PB_Help',          'Hinttext', 104
330    CALL NLVSetText 'PB_Add_Voc_OK',    'Caption',    2
331    CALL NLVSetText 'PB_Add_Voc_OK',    'Hinttext', 102
332    CALL NLVSetText 'PB_Add_Voc_Cancel','Caption',    3
333    CALL NLVSetText 'PB_Add_Voc_Cancel','Hinttext', 103
334    CALL NLVSetText 'Menu_File',        'Caption',   21
335    CALL NLVSetText 'Menu_Options',     'Caption',   22
336    CALL NLVSetText 'Menu_Help',        'Caption',   23
337
338    CALL NLVSetText 'Menu_File_Import_IBMPeer', 'Caption',  24
339    CALL NLVSetText 'Menu_File_Reset',          'Caption',  25
340    CALL NLVSetText 'Menu_File_Debug',          'Caption',  26
341    CALL NLVSetText 'Menu_File_ImportHosts',    'Caption',  36
342    CALL NLVSetText 'Menu_File_PrintCap',       'Caption',  37
343    CALL NLVSetText 'Menu_File_SmbUpdate',      'Caption',  44
344    CALL NLVSetText 'Menu_File_Exit',           'Caption',  27
345
346    CALL NLVSetText 'Menu_Options_SimpleMode',   'Caption', 28
347    CALL NLVSetText 'Menu_Options_ExportMode',   'Caption', 29
348    CALL NLVSetText 'Menu_Options_MiniIcons',    'Caption', 74
349    CALL NLVSetText 'Menu_Help_smbconf',         'Caption', 30
350    CALL NLVSetText 'Menu_Help_About',           'Caption', 31
351    CALL NLVSetText 'Menu_Action',               'Caption', 32
352    CALL NLVSetText 'Menu_Action_AddHomes',      'Caption', 33
353    CALL NLVSetText 'Menu_Action_AddNetlogon',   'Caption', 34
354    CALL NLVSetText 'Menu_Action_AddProfiles',   'Caption', 35
355    CALL NLVSetText 'Menu_Action_AddProfiles',   'Caption', 35
356    CALL NLVSetText 'Menu_Action_EraseTransient','Caption', 47
357
358    CALL NLVSetText 'Menu_ShareContext_AddPrinter',   'Caption', 40
359    CALL NLVSetText 'Menu_ShareContext_Add',          'Caption', 41
360    CALL NLVSetText 'Menu_ShareContext_RemovePrinter','Caption', 42
361    CALL NLVSetText 'Menu_ShareContext_Remove',       'Caption', 43
362    CALL NLVSetText 'Menu_ShareContext_RenamePrinter','Caption', 48
363    CALL NLVSetText 'Menu_ShareContext_Rename',       'Caption', 49
364
365    CALL NLVSetText 'DT_Help',                        'Caption', 80
366    CALL NLVSetText 'DT_Heading',                     'Caption', 81
367    CALL NLVSetText 'DT_Binaries_Version',            'Caption', 82
368    CALL NLVSetText 'DT_Binaries_Path',               'Caption', 83
369    CALL NLVSetText 'DT_Scripts_Path',                'Caption', 84
370/*  CALL NLVSetText 'DT_SmbConfTree',                 'Caption', 73 */
371say NLVGetMessage(73)
372    ok = VRSet("DT_SmbConfTree","Caption", NLVGetMessage(73))
373    Drive = NLVGetMessage(38)
374    say '_GUIInitNLV done'
375return
376
377/*:VRX         _INIRead
378*/
379_INIRead:
380    IF options.!debug == 1 THEN say '_INIRead() started'
381    OurINI = strip(VRParseFileName(VRget("Application","Program"),'DP')'\SSCC.INI',,'\')
382    ok = SysFileTree(OurINI, INIFound.,'FO')
383    if INIFound.0 = 1 then OurINI = VRParseFileName(INIFound.1,'DPNE')
384    say 'OurINI  ='OurINI
385
386    Top   = VRGetIni( "Pos", "Top",    OurINI , 'NoClose')
387    Left  = VRGetIni( "Pos", "Left",   OurINI , 'NoClose')
388    Width = VRGetIni( "Pos", "Width",  OurINI , 'NoClose')
389    Height= VRGetIni( "Pos", "Height", OurINI , 'NoClose')
390
391    options.!debug = VRGetIni( "Options", "Debug", OurINI, 'NoClose')
392    if options.!debug = "" then options.!debug = 0
393
394    ok = VRSet("Menu_File_Debug","Checked",options.!Debug)
395    if options.!Debug then ok = VRREdirectStdIO("ON")
396                      else ok = VRREdirectStdIO("OFF")
397
398    options.!builddir = VRGetIni( "Options", "BuildDir", OurINI, 'NoClose')
399    if options.!builddir = "" then options.!builddir = ""
400
401    advanced.!bigicons = VRGetIni( "Options", "BigIcons", OurINI)
402    if advanced.!bigicons = "" then advanced.!bigicons = 1
403
404    /* Initialize several variables */
405    indent = '09'x
406    ManageDaemons = 1
407
408    /* these were formerly defined in smb.conf */
409    CreatedObjs.0 = 0
410    ChangeList    = ""
411    ValueChanged  = 0
412    CurSection    = ""
413    CreatedObjs.0 = 0
414    ActiveGroup   = "Global"
415
416    InstallMode = 0 /* Normally 0 for configure mode, /Install switch overrides this */
417    UseTDBSam = 0   /* only for installermode */
418    CreatePDC = 0   /* only for installermode */
419
420    FWidth = 32
421
422    IF options.!debug == 1 THEN say '_INIRead() done'
423return
424
425/*:VRX         _INIWrite
426*/
427_INIWrite:
428    ok = VRSetIni( "Pos",     "Top",      VRGet("Main","Top"),         OurINI, 'NoClose')
429    ok = VRSetIni( "Pos",     "Left",     VRGet("Main","Left"),        OurINI, 'NoClose')
430    ok = VRSetIni( "Pos",     "Width",    VRGet("Main","Width"),       OurINI, 'NoClose')   
431    ok = VRSetIni( "Pos",     "Height",   VRGet("Main","Height"),      OurINI, 'NoClose')
432    ok = VRSetIni( "Options", "BuildDir", options.!builddir,           OurINI, 'NoClose')
433    ok = VRSetIni( "Options", "Debug",    options.!debug,              OurINI, 'NoClose')
434    ok = VRSetIni( "Options", "BigIcons", \VRGet("Menu_Options_MiniIcons","Checked"),OurINI)
435return
436
437/*:VRX         _InstallerMode
438*/
439_InstallerMode:
440    ok = VRSet("Main", "Visible", 1)
441    window = VRLoadSecondary( "Installer", "W" )
442    ok = VRSet("Main", "Visible", 1)
443return
444
445/*:VRX         _LMHostsImport
446*/
447_LMHostsImport:
448    hosts = ETC'\hosts'
449    lmhosts = ETC'\samba\lmhosts'
450   
451    ok = SysFileDelete(lmhosts)
452
453    call lineout lmhosts,'# Created by SSCC ver. 'word(VRGet("Main","Hinttext"),2)' on 'date()' at 'time()
454    call lineout lmhosts,'# Syntax:'
455    call lineout lmhosts,'# IP-address NetBIOS-name'
456
457    do until lines(hosts) = 0
458        hostsline = linein(hosts)
459        parse var hostsline IP FQDN Alias
460        parse var FQDN hostname'.'domain
461        if IP <> '127.0.0.1' then do
462            say left(IP, 25)||hostname
463            call lineout lmhosts, left(IP, 25)||hostname
464        end
465    end
466
467    ok = stream(hosts,'c','close')
468    ok = stream(lmhosts,'c','close')
469    Msg.Text = NLVGetMessage(50, lmhosts)
470    msg.Type = 'I'
471    call _ShowMsg
472return
473
474/*:VRX         _LoadOtherFuncs
475*/
476_LoadOtherFuncs:
477    if options.!Debug = 1
478        then ok = VRREdirectStdIO("ON")
479        else ok = VRREdirectStdIO("OFF")
480
481    call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
482    call SysLoadFuncs
483
484    call rxfuncadd 'IniLoadFuncs', 'REXXINI', 'IniLoadFuncs'
485    call IniLoadFuncs
486
487    call RxFuncAdd 'PRLoadFuncs',  'PR1UTIL', 'PRLoadFuncs'
488    call PRLoadFuncs
489
490    /* Deal with DRCtrlxxx */
491    RC = RxFuncQuery("DRCtrlPickDirectory")
492    if RC = 1 then do /* DRCtrlXXX not already registered */
493        /* Load DRCtrl functions */
494        ok = RxFuncAdd('DRCtrlLoadFuncs', 'drctl017', 'DRCtrlLoadFuncs')
495        if ok = 0 then CALL DRCtrlLoadFuncs
496    end
497return
498
499/*:VRX         _MasterPasswdCreate
500*/
501_MasterPasswdCreate:
502    call lineout samba.!masterpasswd, '# Created by SSCC ver. 'word(VRGet("Main","Hinttext"),2)
503    call lineout samba.!masterpasswd, '# syntax:'
504    call lineout samba.!masterpasswd, '# username:passwd:UID:GID:login-class:chg pw x sec:deact x sec:GECOS:home:shell'
505    call lineout samba.!masterpasswd, 'root:*:0:513::0:0:root:/nonexistent:/usr/sbin/nologin'
506    call lineout samba.!masterpasswd, 'guest:*:65534:65534::0:0:guest:/nonexistent:/usr/sbin/nologin'
507    ok = stream(samba.!masterpasswd,'c','close')
508return
509
510/*:VRX         _MsgYesNo
511*/
512_MsgYesNo:
513    IF options.!debug == 1 THEN say '_MsgYesNo() started'   
514    IF options.!debug == 1 THEN say '  Msgbox:"'Msg.Text'"'
515    buttons.0 = 2
516    buttons.1 = NLVGetMessage('6')
517    buttons.2 = NLVGetMessage('7')
518    default = 2
519    buttons.default = buttons.2
520    esc = 2
521    buttons.esc = buttons.2
522    RC = VRMessage( VRWindow(), Msg.Text, Msg.Title,"Q","buttons.",default, esc )
523    IF options.!debug == 1 THEN say '  Answer: 'RC' ( 1 = Yes, 2 = No)'
524    IF options.!debug == 1 THEN say '_MsgYesNo() done'   
525return RC
526
527/*:VRX         _MyIniEnum
528*/
529_MyIniEnum: procedure expose sections. Voc. Val.
530    CurSection = arg(1)
531    do I = 1 to sections.0
532        say I':'sections.I
533        if sections.I = Cursection then leave
534    end
535    if I <= sections.0 then do
536        say 'sections.'I'.0='sections.I.0
537        Voc.0 = sections.I.0
538        Val.0 = sections.I.0
539        do J = 1 to Voc.0
540            parse var sections.I.J Voc.J'='Val.J
541            Voc.J = strip(Voc.J)
542            Val.J = strip(Val.J)
543        end
544    end
545return
546
547/*:VRX         _MyIniEnumSections
548*/
549_MyIniEnumSections: procedure expose sections.
550    say '_MyIniEnumSections() started'
551    smbconf = arg(1)
552    sections. = ""
553    I = 0
554    J = 0
555    do until lines(smbconf) = 0
556        smbconfline = strip(translate(linein(smbconf),' ','09'x))
557        select
558            when left(smbconfline,1) =' ' then nop /* empty line */
559            when left(smbconfline,1) =';' then nop /* Comment */
560            when left(smbconfline,1) ='#' then nop /* Comment */
561            when left(smbconfline,1) ='[' then do  /* Section */
562                sections.I.0 = J
563                I = I + 1
564                J = 0
565                parse var smbconfline '['CurSection']'
566                sections.I = CurSection
567                say '  'CurSection
568            end
569            otherwise do /* Option */
570                parse var smbconfline option'='value
571                J = J + 1
572                sections.I.J = smbconfline
573               option = translate(strip(option),'_!?',' :$')
574               value  = strip(value)
575               OptStr = CurSection'.'option'="'Value'"'
576               /* say OptStr */
577            end
578        end
579    end
580    sections.0 = I
581    sections.I.0 = J
582    ok = stream(smbconf,'c','close')
583    say '_MyIniEnumSections() done.'
584return
585
586/*:VRX         _NLVSetup
587*/
588_NLVSetup:
589    call NLVSetup
590RETURN
591/*:VRX         _ParseCommandLine
592*/
593_ParseCommandLine:
594    IF options.!debug == 1 THEN SAY "_ParseCommandLine() started"
595    CmdLine = VRGet("Application","Commandline")
596    IF options.!debug == 1 THEN SAY '  original commandline ="'CmdLine'"'
597    upCmdLine = translate(CmdLine)
598
599    InstPos = pos('/INSTALL',upCmdLine)
600
601    if InstPos > 0 then do
602        IF options.!debug == 1 THEN SAY "  /install switch detected"
603        InstallMode = 1
604    end
605    IF options.!debug == 1 THEN SAY "_ParseCommandLine() done"
606return
607
608/*:VRX         _PrintCapCreate
609*/
610_PrintCapCreate:
611    ok = SysFileDelete(samba.!printcap)
612    ok = SysIni('SYSTEM', 'PM_SPOOLER_QUEUE_DESCR', 'ALL:','printers.')
613    call lineout samba.!printcap, '# Created by SSCC ver. 'word(VRGet("Main","Hinttext"),2)' on 'date()' at 'time()
614    call lineout samba.!printcap, '# syntax:'
615    call lineout samba.!printcap, '# Printerqueue|printername'
616    do I = 1 to printers.0
617        queue = printers.I
618        name = strip(strip(SysIni('SYSTEM', 'PM_SPOOLER_QUEUE_DESCR', printers.I),'T','00'x),,';')
619        call lineout samba.!printcap, queue'|'name
620    end
621    ok = stream(samba.!printcap,'c','close')
622return
623
624/*:VRX         _SambaCheckComponents
625*/
626_SambaCheckComponents:
627    IF options.!debug == 1 THEN say '_SambaCheckComponents() started'
628
629    /* set deprecated variables */
630    smbconf = samba.!smbconf
631    printcap = samba.!printcap
632
633    /* detect presence of several components and act accordingly */
634    SmbConfExists = VRFileExists(samba.!smbconf)
635    IF options.!debug == 1 THEN say '  Does "'smbconf'" exist? 'SmbConfExists' (1=Yes, 0=No)'
636
637    IsCupsPrintcap = 0
638    if VRFileExists(samba.!printcap) then do
639        printcapline = translate(linein(samba.!printcap))
640        if pos("CUPS",printcapline) > 0 then IsCupsPrintcap = 1
641        ok = stream(samba.!printcap,'c','close')
642    end
643    IF options.!debug == 1 THEN say '  Is printcap from CUPS? 'IsCupsPrintcap' (1=Yes, 0=No)'
644
645    if \VRFileExists(samba.!smbcmd) then do
646        Msg.Title = NLVGetMessage('1')
647        Msg.Type = "E"
648        Msg.Text = NLVGetMessage(53, samba.!smbcmd)' - 'NLVGetMessage(55)
649        call _ShowMsg
650        ManageDaemons = 0
651    end
652    IF options.!debug == 1 THEN say '  Is "'samba.!smbcmd'" present, able to manage daemons = 'ManageDaemons' (1=Yes, 0=No)'
653
654    if \VRFileExists(samba.!testparmexe) then do   
655        Msg.Title = NLVGetMessage('1')
656        Msg.Text  = NLVGetMessage(53,samba.!testparmexe)' - 'NLVGetMessage(54)
657        Msg.Type  = "E"
658        call _ShowMsg
659        call Quit
660    end
661    IF options.!debug == 1 THEN say '  Is "'samba.!testparmexe'" present, continuing.'
662
663    if \VRFileExists(samba.!smbpasswdexe) then do   
664        Msg.Title = NLVGetMessage('1')
665        Msg.Text  = NLVGetMessage(53,samba.!smbpasswdexe)' - 'NLVGetMessage(54)
666        Msg.Type  = "E"
667        call _ShowMsg
668        call Quit
669    end
670    IF options.!debug == 1 THEN say '  Is "'samba.!smbpasswdexe'" is present, continuing.'
671
672    if SmbConfExists then do
673        call _SmbConfBackup
674        if InstallMode then do
675            window = VRLoadSecondary( "RemoveConfig", "W" )
676        end
677    end
678
679    if \VRFileExists(swatusers) & swatauth = 1 & InstallMode = 0 then do
680        Msg.Text = NLVGetMessage(115, swatusers)
681        Msg.Type = "W"
682        call _ShowMsg
683    end
684    IF options.!debug == 1 THEN say '  Does "'samba.!smbconf'" still exist? 'SmbConfExists' (1=Yes, 0=No)'
685    IF options.!debug == 1 THEN say '  Running in InstallMode = 'InstallMode' (1=Yes, 0=No)'
686
687    IF options.!debug == 1 THEN say '_SambaCheckComponents() done'
688return
689
690
691/*          Msg.Text = NLVGetMessage(56, samba.!smbconf)
692            Msg.Type = "Q"
693            ok = _MsgYesNo()
694            if ok = 1 then do
695                ok = SysFileDelete(samba.!smbconf)
696                SmbConfExists = 0
697                Msg.Text = "Also reinitialize backend?" /* NLVGetMessage(56, samba.!smbconf) */
698                Msg.Type = "Q"
699                ok = _MsgYesNo()
700                if ok = 1 then do
701                    ok = SysFileTree(ETC"\samba\*.?db",xdb.,'FOS')
702                    do I = 1 to xdb.0
703                        ok = SysFileDelete(xdb.I)
704                        if ok <> 0 then do
705                            Msg.Text = "Error "ok" deleting "xdb.I"!"
706                            Msg.Type = "W"
707                            call _ShowMsg
708                        end
709                    end
710                end
711            end
712            else InstallMode = 0
713 */
714/*:VRX         _SambaGroupMapInst
715*/
716_SambaGroupMapInst:
717    IF options.!debug == 1 THEN SAY "_SambaGroupMapInst() started"
718    /* These group mappings are obligatory */
719    IF options.!debug == 1 THEN SAY  "  Mapping Required domain groups"
720    address cmd samba.!netexe' groupmap add rid=512 ntgroup="Domain Admins"                unixgroup="admin"       type=domain   comment="Domain Administrators"'
721    address cmd samba.!netexe' groupmap add rid=513 ntgroup="Domain Users"                 unixgroup="users"       type=domain   comment="Domain Users"'
722    address cmd samba.!netexe' groupmap add rid=514 ntgroup="Domain Guests"                unixgroup="guests"      type=domain   comment="Domain Guests"'
723
724    /* These group mappings are optional */
725    IF options.!debug == 1 THEN SAY "  Mapping Optional domain groups"
726    address cmd samba.!netexe' groupmap add rid=515 ntgroup="Domain Computers"             unixgroup="machines"    type=domain   comment="Domain Computers"'
727    address cmd samba.!netexe' groupmap add rid=516 ntgroup="Domain Controllers"           unixgroup="dc"          type=domain   comment="Domain Controllers"'
728    address cmd samba.!netexe' groupmap add rid=517 ntgroup="Domain Certificate Admins"    unixgroup="certadmin"   type=domain   comment="Domain Certificate Administrators"'
729    address cmd samba.!netexe' groupmap add rid=518 ntgroup="Domain Schema Admins"         unixgroup="schemeadmin" type=domain   comment="Domain Schema Administrators"'     
730    address cmd samba.!netexe' groupmap add rid=519 ntgroup="Domain Enterprise Admins"     unixgroup="entadmin"    type=domain   comment="Domain Enterprise Administrators"' 
731    address cmd samba.!netexe' groupmap add rid=520 ntgroup="Domain Policy Admins"         unixgroup="poladmin"    type=domain   comment="Domain Policy Administrators"'     
732
733    /* The following ones are unsupported at the moment - use at your own risk */
734    /*
735    IF options.!debug == 1 THEN SAY say "  Mapping Builtin groups"
736    address cmd samba.!netexe' groupmap add rid=544 ntgroup="Builtin Admins"               unixgroup="ntadmin"   type=builtin
737    address cmd samba.!netexe' groupmap add rid=545 ntgroup="Builtin Users"                unixgroup="ntusers"   type=builtin
738    address cmd samba.!netexe' groupmap add rid=546 ntgroup="Builtin Guests"               unixgroup="ntguests"  type=builtin
739    address cmd samba.!netexe' groupmap add rid=547 ntgroup="Builtin Power Users"          unixgroup="" type=builtin
740    address cmd samba.!netexe' groupmap add rid=548 ntgroup="Builtin Account Operators"    unixgroup="" type=builtin
741    address cmd samba.!netexe' groupmap add rid=549 ntgroup="Builtin System Operators"     unixgroup="operator" type=builtin
742    address cmd samba.!netexe' groupmap add rid=550 ntgroup="Builtin Print Operators"      unixgroup="lp" type=builtin
743    address cmd samba.!netexe' groupmap add rid=551 ntgroup="Builtin Backup Operators"     unixgroup="backup" type=builtin
744    address cmd samba.!netexe' groupmap add rid=552 ntgroup="Builtin Replicator"           unixgroup="" type=builtin
745    address cmd samba.!netexe' groupmap add rid=553 ntgroup="Builtin RAS Servers"          unixgroup="" type=builtin
746    */
747    IF options.!debug == 1 THEN SAY "_SambaGroupMapInst() done"
748return
749
750/*:VRX         _SambaGuestCreate
751*/
752_SambaGuestCreate:
753    IF options.!debug == 1 THEN say "_SambaGuestCreate() started"
754    IF options.!debug == 1 THEN say '  'samba.!smbpasswdexe' -a guest -n'
755    samba.!smbpasswdexe' -a guest -n -D 0 2>'samba.!error' 1>'samba.!message
756
757    if rc = 0 then call _SambaShowMsg
758              else call _SambaShowError
759
760    IF options.!debug == 1 THEN say "_SambaGuestCreate() done"
761return
762
763/*:VRX         _SambaRootPWCheck
764*/
765_SambaRootPWCheck:
766    if VRGet("EF_RootPassword","Value") ="" then do
767        Msg.type  = "E"
768        Msg.Text  = NLVGetMessage(57, "root")
769        call _ShowMsg
770        return 0
771    end
772    if VRGet("EF_RootPassword_repeat","Value") ="" then do
773        Msg.type  = "E"
774        Msg.Text  = NLVGetMessage(58,"root")
775        call _ShowMsg
776        return 0
777    end
778
779    if VRGet("EF_RootPassword","Value") <> VRGet("EF_RootPassword_repeat","Value") then do
780        Msg.type  = "E"
781        Msg.Text  = NLVGetMessage(59, "root")
782        call _ShowMsg
783        return 0
784    end
785return 1
786
787/*:VRX         _SambaRootPWSet
788*/
789_SambaRootPWSet:
790    IF options.!debug == 1 THEN say "_SambaRootPWSet() started"
791
792    /* Write root password to a temp file */
793    pwdfile = TempDir'newpwd'
794    call lineout pwdfile, VRGet("EF_RootPassword","value")
795    call lineout pwdfile, VRGet("EF_RootPassword","value")
796    ok = stream(pwdfile,"c","close")
797
798    /* Create the root account */
799    IF options.!debug == 1 THEN say '  'samba.!smbpasswdexe' -a root -s <'pwdfile
800    samba.!smbpasswdexe' -a root -s -D 0 <'pwdfile' 2>'samba.!error' 1>'samba.!message
801
802    if rc = 0 then call _SambaShowMsg
803              else call _SambaShowError
804
805    /* Remove the temp password file */
806    ok = SysFileDelete(pwdfile)
807
808    /* Deal with swat */
809    /* FixMe: We do not need htpasswd.exe anymore as we use rxcrypt.dll */
810    if swatauth then do
811        /* we always remove the old swat */
812        say '  'samba.!htpasswdexe' -D "'swatusers'" root'
813        address cmd samba.!htpasswdexe' -D "'swatusers'" root' /* ' 2>'samba.!error' 1>'samba.!msg
814        if rc <> 0 then call _SambaShowError; else call _SambaShowMsg  */             
815
816        if VRFileExists(swatusers) then cFlag = ""; else cFlag="c"
817        say '  'samba.!htpasswdexe' -b'cFLag' "'swatusers'" root **********'
818        address cmd samba.!htpasswdexe' -b'cFlag' "'swatusers'" root 'VRGet("EF_RootPassword","value") /* ' 2>'samba.!error' 1>'samba.!msg
819        if rc <> 0 then call _SambaShowError
820        else call _SambaShowMsg */
821    end
822    IF options.!debug == 1 THEN say "_SambaRootPWSet() done"
823return
824
825/*:VRX         _SambaShowError
826*/
827_SambaShowError: procedure expose samba. settings. options.
828    I = 0
829    do while lines(samba.!error) <> 0
830        I = I + 1
831        smberr.I = linein(samba.!error)
832        say I':err:'smberr.I
833    end
834    ok = stream(Samba.!error,"c","close")
835    ok = SysFileDelete(Samba.!error)
836    smberr.0 = I
837    /* we did not get any error text */
838    if smberr.0 = 0 then return
839    Buttons.1 = "OK"
840    Buttons.0 = 1
841    id = VRMessageStem( VRWindow(), "smberr.", VRGet("Main", "Caption") , "Error", "Buttons.", buttons.1, buttons.1 )
842return
843
844/*:VRX         _SambaShowMsg
845*/
846_SambaShowMsg: procedure expose samba. settings. options.
847    I = 0
848    do while lines(samba.!message) <> 0
849        I = I + 1
850        smbmsg.I = linein(samba.!message)
851        say I':msg:'smbmsg.I
852    end
853    ok = stream(Samba.!message,"c","close")
854    ok = SysFileDelete(Samba.!message)
855    smbmsg.0 = I
856    /* we did not get any message */
857    if smbmsg.0 = 0 then return
858    Buttons.1 = "OK"
859    Buttons.0 = 1
860    id = VRMessageStem( VRWindow(), "smbmsg.", VRGet("Main", "Caption") , "I", "Buttons.", buttons.1, buttons.1 )
861return
862/*:VRX         _SambaUserCreate
863*/
864_SambaUserCreate:
865    eCSUser  = value("USER",,"OS2ENVIRONMENT")
866    HostName = value("HOSTNAME",,"OS2ENVIRONMENT")
867    if translate(eCSUser) = translate(Hostname) then do
868        Msg.Text = NLVGetMessage(118, eCSUser)
869        Msg.Type = "I"
870        call _ShowMsg
871    end
872    if translate(eCSUser) <> "root" & translate(eCSUser) <> "guest" then do
873        Msg.Text = NLVGetMessage(75, eCSUser)
874        Msg.Type = "I"
875        call _ShowMsg
876    end
877return
878
879/*:VRX         _SambaVersion
880*/
881_SambaVersion:
882    say "_SambaVersion() started"
883    address cmd samba.!smbd' -V >'samba.!msg
884    samba.!version = linein(samba.!msg)
885    say "  Samba "samba.!version
886    ok = stream(samba.!msg,"c","close")
887    say "_SambaVersion() done"
888return
889
890/*:VRX         _SaveChanges
891*/
892_SaveChanges:
893    say '_SaveChanges() started for ['CurSection']'
894
895    do I = 1 to words(ChangeList)
896        ChangeObj = word(ChangeList,I)
897        say "Changed object: "ChangeObj
898
899        parse var ChangeObj ChangeObjType '_' ChangeVoc
900
901        ChangeVoc = translate(ChangeVoc, ' ', '_')
902        say "Changed voc: "ChangeVoc
903        VocIdx = VRGet(ChangeObj,'Userdata')
904        if ChangeObjType = "EF" then do
905
906            NewVal = VRGet(ChangeObj, 'Value')
907            parse var sections.CurSIdx.VocIdx OldVoc'='OldVal
908            OldVoc = strip(oldVoc)
909            sections.CurSIdx.VocIdx = OldVoc' = 'NewVal
910
911            if VRGet(ChangeObj, 'Value') <> "" then do
912                select
913                    when pos("\\", VRGet(ChangeObj, 'Value')) > 0 then ok = IniSet(ChangeVoc, VRGet(ChangeObj, 'Value'), CurSection, samba.!smbconf)
914                    when pos(" dir",   ChangeVoc) > 0 then ok = IniSet(ChangeVoc, _bs2fs(VRGet(ChangeObj, 'Value')), CurSection, samba.!smbconf)
915                    when pos("file",   ChangeVoc) > 0 then ok = IniSet(ChangeVoc, _bs2fs(VRGet(ChangeObj, 'Value')), CurSection, samba.!smbconf)
916                    when pos("path",   ChangeVoc) > 0 then ok = IniSet(ChangeVoc, _bs2fs(VRGet(ChangeObj, 'Value')), CurSection, samba.!smbconf)
917/*                  when pos("command",ChangeVoc) > 0 then ok = IniSet(ChangeVoc, _bs2fs(VRGet(ChangeObj, 'Value')), CurSection, samba.!smbconf) */
918/*                  when pos("script", ChangeVoc) > 0 then ok = IniSet(ChangeVoc, _bs2fs(VRGet(ChangeObj, 'Value')), CurSection, samba.!smbconf) */
919                    otherwise ok = IniSet(ChangeVoc, VRGet(ChangeObj, 'Value'), CurSection, samba.!smbconf)
920                end
921                say "INISet ok = "ok
922            end
923            else do
924                ok = IniDel( ChangeVoc, CurSection, samba.!smbconf )
925                say "INIDel ok = "ok
926                if ok = "" then ok = 0
927            end
928        end
929        if ChangeObjType = "CB" then do
930            If VRGet(ChangeObj, 'Set') then BoolVal = "Yes"; else BoolVal = "No"
931
932            parse var sections.CurSIdx.VocIdx OldVoc'='OldVal
933            OldVoc = strip(oldVoc)
934            sections.CurSIdx.VocIdx = OldVoc' = 'BoolVal
935
936            ok = IniSet(ChangeVoc, BoolVal, CurSection, samba.!smbconf)
937            say "INISet ok = "ok" (Bool)"
938        end
939    end
940
941    if ok = 0 then do
942        Msg.Type = "I"
943        Msg.Text = NLVGetMessage(51)
944    end
945    else do
946        Msg.Type = "E"
947        Msg.Text = NLVGetMessage(52)
948    end
949    call _ShowMsg
950
951    call TM_Value_Trigger
952   
953    say '_SaveChanges() done'
954return
955/*:VRX         _ShareObject_Changed
956*/
957_ShareObject_Changed:
958    say "_ShareObject_Changed() started"
959    ValueChanged = 1
960    if pos(VRGet(VRInfo("OBject"),"Name"), ChangeList) = 0 then Changelist = ChangeList' 'VRGet(VRInfo("OBject"),"Name")
961    ok = VRSet("PB_Save", "Enabled", 1)
962    say "  ValueChanged = "ValueChanged
963    say Changelist
964    say "_ShareObject_Changed() done"
965return
966
967/*:VRX         _SharesReset
968*/
969_SharesReset:
970    say '_SharesReset started'
971    ok = VRset("EF_path", "Value","")
972    ok = VRFlush( , "EF_path" )
973    ok = VRset("CB_Browseable", "Set", 1)
974    ok = VRFlush( , "CB_Browseable" )
975    ok = VRset("CB_Read_Only",  "Set", 0)
976    ok = VRFlush( , "CB_Read_Only")
977    ok = VRset("CB_Guest_OK",   "Set", 0)
978    ok = VRFlush( , "CB_Guest_OK" )
979    do I = 1 to CreatedObjs.0
980        ok = VRDestroy(CreatedObjs.I)     
981    end
982    say '_SharesReset done'
983return
984
985/*:VRX         _ShowMsg
986*/
987_ShowMsg:
988    Buttons.1 = "OK"
989    Buttons.0 = 1
990    id = VRMessage( VRWindow(), Msg.Text, Msg.Title, Msg.Type, "Buttons.", buttons.1, buttons.1 )
991return
992
993/*:VRX         _Smb35Init
994*/
995_Smb35Init:
996    IF options.!debug == 1 THEN say '_Smb35Init() started'
997    say '1 -> 'samba.!smbpasswdexe' -a dummyuser -n -D 10'
998    address cmd samba.!smbpasswdexe' -a dummyuser -n -D 10'
999    say '2 -> 'samba.!smbpasswdexe' -x dummyuser -D 10'
1000    address cmd samba.!smbpasswdexe' -x dummyuser -D 10'
1001    say '3 -> 'samba.!pdbeditexe' --policies-reset -d=3'
1002    address cmd samba.!pdbeditexe' --policies-reset -d=3'
1003    say 'X -> ----------------------'
1004    IF options.!debug == 1 THEN say '_Smb35Init() done'
1005return
1006
1007/*:VRX         _SmbConfBackup
1008*/
1009_SmbConfBackup:
1010    ok = VRCopyFile( SmbConf, SmbConf"-backup" )
1011return
1012
1013/*:VRX         _SmbConfCommitChanges
1014*/
1015_SmbConfCommitChanges:
1016    IF options.!debug == 1 THEN say '_SmbConfCommitChanges() started'   
1017 
1018    src = TempDir'smb.conf'
1019    if stream(src,'c','query size') = 0 then do
1020        ok = VRCopyFile(smbconf,src)
1021    end
1022    trg = smbconf
1023    ok = SysFileDelete(smbconf)
1024    call lineout trg, '# Samba config file created using SSCC ver. 'word(VRGet("Main","Hinttext"),2)
1025    call lineout trg, '# from 'value("USER",,'OS2ENVIRONMENT')'@'value("HOSTNAME",,'OS2ENVIRONMENT')
1026    call lineout trg, '# Date: 'date()' 'time()
1027    lct = 0
1028    do until lines(src) = 0
1029        smbline = linein(src)
1030        if pos("idmap uid",smbline) > 0 then iterate
1031        if pos("idmap gid",smbline) > 0 then iterate
1032        if pos("idmap config",smbline) > 0 then iterate
1033        if pos("winbind separator",smbline) > 0 then iterate
1034        if pos("copy ",smbline) > 0 then iterate
1035        call lineout trg, smbline
1036        lct = lct + 1
1037    end
1038    say "Lines saved "lct
1039    ok = stream(trg,'c','close')
1040    ok = stream(src,'c','close')
1041    ok = SysFileDelete(src)
1042    IF options.!debug == 1 THEN say '_SmbConfCommitChanges() done'   
1043return
1044
1045/*:VRX         _SmbConfCreateDefault
1046*/
1047_SmbConfCreateDefault:
1048    ok = SysFileDelete(smbconf)
1049   
1050    /* Create a basic smb.conf */
1051    call _SmbConfDefault_Global   
1052    call _SmbConfDefault_Scripts
1053    if CreatePDC then do
1054        call _SmbConfDefault_NetLogon
1055        call _SmbConfDefault_Profiles
1056    end
1057    call _SmbConfDefault_Homes
1058    call _SmbConfDefault_SharePrinters
1059    call _SmbConfDefault_ShareDrives
1060    ok = stream(smbconf,'c','close')
1061return
1062
1063/*:VRX         _SmbConfCreateDefault_OldInstall
1064*/
1065_SmbConfCreateDefault_OldInstall:
1066    DriveList = SysDriveMap('C:','Local')
1067    ok = SysIni('SYSTEM', 'PM_SPOOLER_QUEUE_DESCR', 'ALL:','printers.')
1068    ok = VRSet("EF_NetBIOS_Name","Value", Value("HOSTNAME",,"OS2ENVIRONMENT"))
1069
1070    DrivesOH.0 = 0
1071    do I = 1 to words(DriveList)
1072        CurDrive = word(DriveList,I)
1073        Filesys = SysFilesystemType(Curdrive)
1074        DriveInfo=SysDriveInfo(CurDrive)
1075        parse var DriveInfo DrvLet CurFree CurSize CurLabel
1076        curlabel = strip(Curlabel)
1077        CurFree = word(Driveinfo,2)
1078        CurSize = word(Driveinfo,3)
1079        if Curlabel = "" then Curlabel = '?'
1080
1081        if datatype(CurSize) = 'NUM' then do       
1082            CurSize = CurSize/(1024*1024)
1083            CurFree = CurFree/(1024*1024)
1084
1085            CurSize = format(CurSize,,0)'MB'
1086            CurFree = format(CurFree,,0)'MB'
1087        end
1088        else do
1089            CurSize = '?'
1090            CurFree = '?'
1091        end
1092
1093/*      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)  */
1094        Shares.!drives.I = VRMethod( "CN_smbconf", "AddRecord", smbconf.!dirs,,left(CurDrive,1) ,"#4")
1095        if FileSys = '' | FileSys = 'CDFS' then do
1096/*          ok = VRSet(DrivesOH.I, "ForeColor", "Red") */
1097        end
1098/*      if CurDrive = SysBootDrive() then ok = VRSet(DrivesOH.I, "Set", 0)
1099        if CurDrive = translate(left(samba.!bin,2)) then ok = VRSet(DrivesOH.I, "Set", 0) */
1100    end
1101    DrivesOH.0 = I-1
1102
1103    PrintersOH.0 = 0
1104    Colum = 1325
1105    dx = 0
1106    do I = 1 to printers.0
1107        queue = printers.I
1108        name = strip(strip(SysIni('SYSTEM', 'PM_SPOOLER_QUEUE_DESCR', printers.I),'T','00'x),,';')
1109/*      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)     */
1110        Shares.!printers.I = VRMethod( "CN_smbconf", "AddRecord", smbconf.!printers,,queue,"#6")
1111        if I = 6 then do
1112            Colum = 4000
1113            dx = 6
1114        end
1115    end
1116    PrintersOH.0 = I-1
1117return
1118
1119/*:VRX         _SmbConfDefault_Global
1120*/
1121_SmbConfDefault_Global:
1122    Migrate = (arg(1) = 1)
1123    if \Migrate then do /* when migrating these 4 lines are there already */
1124        section       = '[global]'
1125        call lineout smbconf, section
1126        call lineout smbconf, Indent||'workgroup = 'VRGet("EF_Workgroup_Initial","value")
1127        call lineout smbconf, Indent||'netbios name = 'value('HOSTNAME',,'OS2ENVIRONMENT')
1128        call lineout smbconf, Indent||'server string = %h Samba Server for eCS (OS/2)'
1129        call lineout smbconf, Indent||'comment = Samba Server for eCS (OS/2)'
1130    end
1131
1132    call lineout smbconf, Indent||'dos charset = IBM-850'
1133    call lineout smbconf, Indent||'display charset = IBM-850'
1134    call lineout smbconf, Indent||'unix charset = IBM-850'
1135
1136    CurCP = SysQueryProcessCodePage()
1137    if CurCP <> "850" then do
1138        Msg.Text = NLVGetMessage(117)
1139        Msg.Type = "W"
1140        call _ShowMsg
1141    end
1142    if UseTDBsam = 1 then do
1143        call lineout smbconf, Indent||'passdb backend = tdbsam'
1144    end
1145    call lineout smbconf, Indent||'log level = 2'
1146    call lineout smbconf, Indent||'log file = '||ETC||'\samba\log\log.smbd.%U.%M'
1147    call lineout smbconf, Indent||'null passwords = Yes'
1148    call lineout smbconf, Indent||'guest account = guest'
1149    call lineout smbconf, Indent||'security = user'
1150    call lineout smbconf, Indent||'load printers = No'
1151    call lineout smbconf, Indent||'time server = Yes'
1152    call lineout smbconf, Indent||'lock directory = '||ETC||'\samba\lock'
1153    /* This EA makes the testparm warning about browsing go away.
1154       Note: The EA is NOT marked critical as it should be,
1155             neverthelesse this fix works */
1156    ok = SysPutEA(ETC||'\samba\lock',"MODE", "FEFF0400ED410000"x)
1157    call lineout smbconf, Indent||'ea support = Yes'
1158    call lineout smbconf, Indent||'store dos attributes = Yes'
1159    call lineout smbconf, Indent||'lm announce = Yes'
1160    call lineout smbconf, Indent||'wins support = Yes'
1161    call lineout smbconf, Indent||'wide links = No'
1162    ok = SysFileTree(samba.!printcap,exist.,'FO')
1163    if exist.0 = 1 then do
1164        call lineout smbconf, Indent||'printcap name = 'samba.!printcap
1165    end
1166    samba.!smbusermap = ETC||'\samba\private\smbusermap'
1167    call lineout smbconf, Indent||'username map = 'samba.!smbusermap
1168    if \VRFileExists(samba.!smbusermap) then call _SmbUserMapCreate
1169    if CreatePDC then do
1170        call lineout smbconf, Indent||'local master = Yes'
1171        call lineout smbconf, Indent||'preferred master = Yes'
1172        call lineout smbconf, Indent||'domain master = Yes'
1173        call lineout smbconf, Indent||'os level = 65'
1174        call lineout smbconf, ';'Indent||'domain groups ='
1175        call lineout smbconf, ';'Indent||'domain admin group = '
1176        call lineout smbconf, Indent||'domain admin users = root'
1177        call lineout smbconf, Indent||'domain logons = Yes'
1178        call lineout smbconf, Indent||'logon home = \\%L\Profiles\%U'
1179        call lineout smbconf, Indent||'logon path = \\%L\Profiles\%U'
1180        call lineout smbconf, Indent||'logon drive = z:'
1181        call lineout smbconf, Indent||'logon script = %U.cmd'
1182    end
1183    else do
1184        call lineout smbconf, Indent||'create mask = 0777'
1185    end
1186    ok = stream(smbconf, 'c','close') 
1187return
1188/*:VRX         _SmbConfDefault_Homes
1189*/
1190_SmbConfDefault_Homes:
1191    /* Create Homes section */
1192    call lineout smbconf, '[HOMES]'
1193    call lineout smbconf, Indent||"comment = Home directory"
1194    smbhome = samba.!bin'\homes'
1195    Home = strip(value('Home',,'OS2ENVIRONMENT'),'T','\')
1196    if Home <> '' then do
1197        User = value('USER',,'OS2ENVIRONMENT')
1198        if User <> '' then do
1199            if translate(User) = translate(Filespec('N',Home)) | translate(Filespec('N',Home)) = "DEFAULT"  then smbHome = strip(filespec('D',Home)||filespec('P',Home),'T','\')
1200        end
1201    end
1202    ok = SysMkDir(smbhome)
1203    call lineout smbconf, Indent||"path = "_bs2fs(smbhome)'/%u'
1204    call lineout smbconf, Indent||"read only = No"
1205    call lineout smbconf, Indent||"browseable = No"
1206    call lineout smbconf, Indent
1207    ok = stream(smbconf, 'c','close')
1208return
1209
1210/*:VRX         _SmbConfDefault_Netlogon
1211*/
1212_SmbConfDefault_Netlogon:
1213    /* Create Netlogon section */
1214    call lineout smbconf, '[NETLOGON]'
1215    call lineout smbconf, Indent||"comment = Netlogon service"
1216    smbnetlogon = samba.!bin'\netlogon'
1217    ok = SysMkDir(smbnetlogon)
1218    call lineout smbconf, Indent||"path = "_bs2fs(smbnetlogon)
1219    call lineout smbconf, Indent||"read only = Yes"
1220    call lineout smbconf, Indent||"browseable = Yes"
1221    call lineout smbconf, Indent||"share modes = No"
1222    call lineout smbconf, Indent
1223    ok = stream(smbconf, 'c','close')
1224return
1225
1226/*:VRX         _SmbConfDefault_Profiles
1227*/
1228_SmbConfDefault_Profiles:
1229    /* Create profiles section */
1230    call lineout smbconf, '[profiles]'
1231    call lineout smbconf, Indent||"comment = profiles"
1232    smbprofiles = samba.!bin'\profiles'
1233    ok = SysMkDir(smbprofiles)
1234    call lineout smbconf, Indent||"path = "_bs2fs(smbprofiles)
1235    call lineout smbconf, Indent||"profile acls = Yes"
1236    call lineout smbconf, Indent||"read only = No"
1237    call lineout smbconf, Indent||"browseable = Yes"
1238    call lineout smbconf, Indent||"create mask = 0777"
1239    call lineout smbconf, Indent||"directory mask = 0777"
1240    call lineout smbconf, Indent
1241    ok = stream(smbconf, 'c','close')
1242return
1243
1244/*:VRX         _SmbConfDefault_Scripts
1245*/
1246_SmbConfDefault_Scripts:
1247    smbtools = samba.!bin
1248
1249    /* user scripts */
1250    call lineout smbconf, ';'||Indent||'user scripts'
1251    call lineout smbconf, Indent||'add user script          = '||smbtools||'\usermod.cmd -a "%u"'
1252    call lineout smbconf, Indent||'delete user script       = '||smbtools||'\usermod.cmd -x "%u"'
1253    call lineout smbconf, Indent||'rename user script       = '||smbtools||'\usermod.cmd -r "%uold" "%unew"'
1254    call lineout smbconf, Indent||'add machine script       = '||smbtools||'\usermod.cmd -a "%u"'
1255    call lineout smbconf, Indent||'set primary group script = '||smbtools||'\usermod.cmd -p "%u" "%g"'
1256
1257    /* group scripts */
1258    call lineout smbconf, ';'||Indent||'group scripts'
1259    call lineout smbconf, Indent||'add group script              = '||smbtools||'\groupmod.cmd -a "%g"'
1260    call lineout smbconf, Indent||'delete group script           = '||smbtools||'\groupmod.cmd -x "%g"'
1261    call lineout smbconf, Indent||'add user to group script      = '||smbtools||'\groupmod.cmd -j "%g" "%u"'
1262    call lineout smbconf, Indent||'delete user from group script = '||smbtools||'\groupmod.cmd -l "%g" "%u"'
1263
1264    /* share scripts */
1265    call lineout smbconf, ';'||Indent||'share scripts'
1266    call lineout smbconf, Indent||'add share command = '||smbtools||'\addshare.cmd'
1267    call lineout smbconf, Indent||'change share command = '||smbtools||'\changeshare.cmd'
1268    call lineout smbconf, Indent||'delete share command = '||smbtools||'\delshare.cmd'
1269
1270    /* other scripts */
1271    call lineout smbconf, ';'||Indent||'other scripts'
1272    call lineout smbconf, Indent||'enumports command = '||smbtools||'\enumports.cmd'
1273    call lineout smbconf, Indent
1274    call lineout smbconf
1275    ok = stream(smbconf, 'c','close') 
1276return
1277
1278/*:VRX         _SmbConfDefault_ShareDrives
1279*/
1280_SmbConfDefault_ShareDrives:
1281    DriveList = SysDriveMap('C:','Local')
1282
1283    do I = 1 to words(DriveList)
1284        CurDrive = word(DriveList,I)
1285say CurDrive
1286        Filesys = SysFilesystemType(Curdrive)
1287        DriveInfo=SysDriveInfo(CurDrive)
1288        parse var DriveInfo DrvLet CurFree CurSize CurLabel
1289
1290        if FileSys = '' | FileSys = 'CDFS' then do
1291            read_write = 'read only = Yes'
1292        end
1293        else do
1294            read_write = 'read only = No'
1295        end
1296        if FileSys = '' then FileSys = 'CDFS'
1297   
1298        section    = '['left(curdrive,1)']'
1299        comment    = 'comment = 'Drive' 'CurDrive' ('FileSys')'
1300        path       = 'path = 'Curdrive'/'
1301        guest_ok = 'guest ok = Yes'
1302        hide_files = 'hide files = /*. SF/root/'
1303   
1304        call lineout smbconf, section
1305        call lineout smbconf, Indent||comment   
1306        call lineout smbconf, Indent||path     
1307        call lineout smbconf, Indent||read_write
1308        call lineout smbconf, Indent||guest_ok
1309        call lineout smbconf, Indent||hide_files
1310        call lineout smbconf, Indent   
1311    end
1312    ok = stream(smbconf, 'c','close') 
1313return
1314
1315/*      browsable  = 'browsable = Yes'
1316        printable  = 'printable = No'
1317        public     = 'public = Yes'
1318        call lineout smbconf, Indent||browsable
1319        call lineout smbconf, Indent||printable
1320        call lineout smbconf, Indent||public    */
1321/*:VRX         _SmbConfDefault_SharePrinters
1322*/
1323_SmbConfDefault_SharePrinters:
1324    ok = SysIni('SYSTEM', 'PM_SPOOLER_QUEUE_DESCR', 'ALL:','printers.')
1325
1326    do I = 1 to printers.0
1327        queue = printers.I
1328        name = strip(strip(SysIni('SYSTEM', 'PM_SPOOLER_QUEUE_DESCR', printers.I),'T','00'x),,';')
1329
1330/*      call lineout samba.!printcap, queue'|'name */
1331
1332        section       = '['queue']'
1333        path          = 'path = 'ETC'\samba\spool\'queue
1334        ok = SysMkDir(ETC'\samba\spool\'queue)
1335        comment       = 'comment = 'name
1336        create_mask   = 'create mask = 0700'
1337        guest_ok = 'guest ok = Yes'
1338       
1339        printable     = 'printable = Yes'
1340        print_command = 'print command = 'samba.!bin'\smbprint.exe "%s" "%p" "%J" "%c" "%z"'
1341        printer_name  = 'printer name = 'queue
1342
1343        call lineout smbconf, section
1344        call lineout smbconf, Indent||comment   
1345        call lineout smbconf, Indent||path     
1346        call lineout smbconf, Indent||create_mask
1347        call lineout smbconf, Indent||printable
1348        call lineout smbconf, Indent||print_command
1349        call lineout smbconf, Indent||printer_name
1350        call lineout smbconf, Indent||guest_ok
1351
1352        call lineout smbconf, Indent 
1353   
1354    end
1355    ok = stream(smbconf, 'c','close') 
1356    ok = stream(samba.!printcap,'c','close')
1357return
1358
1359/*  browsable     = 'browsable = Yes'
1360    call lineout smbconf, Indent||browsable */
1361/*:VRX         _SmbConfLoad
1362*/
1363_SmbConfLoad:
1364    IF options.!debug == 1 THEN say '_SmbConfLoad() started'
1365    IF options.!debug == 1 THEN say '  Loading "'samba.!smbconf'" ('stream(samba.!smbconf,'c','query size')' bytes)'
1366
1367/*  ok = IniEnumSections(sections., samba.!smbconf) */
1368
1369    section. = ""
1370    sections.0 = 0
1371    call _MyIniEnumSections(samba.!smbconf)
1372
1373    special = 'global printers netlogon print$ homes profiles'
1374    Specialstatus.0 = sections.0
1375    PrintStatus.0 = sections.0
1376    sectionhandles.0 = sections.0
1377    recordhandle.0 = sections.0
1378
1379    do I = 1 to sections.0
1380        IF options.!debug == 1 THEN say '  ['sections.I'] section loaded'
1381        if wordpos(translate(sections.I),translate(special)) > 0 Then SpecialStatus.I = 1
1382                                           Else SpecialStatus.I = 0
1383        PrintRes = IniGet("Printable", sections.I, samba.!smbconf)
1384        if Translate(PrintRes) = "YES" | Translate(PrintRes) = "TRUE" then PrintStatus.I = 1
1385                                                                      else PrintStatus.I = 0
1386
1387        IF options.!debug == 1 THEN say '  ['sections.I'] status (special:'SpecialStatus.I', print:'Printstatus.I')'
1388        if Printstatus.I = 1 & SpecialStatus.I = 0 then do /* printer share */
1389            recordhandle.I = VRMethod( "CN_smbconf", "AddRecord", smbconf.!printers,,sections.I,"#65:PMWP.DLL")
1390            ok = VRMethod("CN_smbconf","SetRecordAttr",recordhandle.I,"ReadOnly", 1)
1391            IF options.!debug == 1 THEN say '  ['sections.I'] added to shared printer tree'
1392        end
1393        if Printstatus.I = 0 & SpecialStatus.I = 0 then do /* directory share */
1394            recordhandle.I = VRMethod( "CN_smbconf", "AddRecord", smbconf.!dirs,,    sections.I,"#64:PMWP.DLL")
1395            ok = VRMethod("CN_smbconf","SetRecordAttr",recordhandle.I,"ReadOnly", 1)
1396            IF options.!debug == 1 THEN say '  ['sections.I'] added to shared folder tree'
1397        end
1398        if translate(sections.I) = 'PROFILES' then do
1399            recordhandle.I = smbconf.!profiles
1400            ok = VRMethod("CN_smbconf","SetRecordAttr",recordhandle.I,"Visible", 1)
1401        end
1402        if translate(sections.I) = 'NETLOGON' then do
1403            recordhandle.I = smbconf.!netlogon
1404            ok = VRMethod("CN_smbconf","SetRecordAttr",recordhandle.I,"Visible", 1)
1405        end
1406        if translate(sections.I) = 'HOMES' then do
1407            recordhandle.I = smbconf.!homes
1408            ok = VRMethod("CN_smbconf","SetRecordAttr",recordhandle.I,"Visible", 1)
1409        end
1410        if translate(sections.I) = 'GLOBAL' then recordhandle.I = smbconf.!global   
1411    end
1412    ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!root, "Collapsed", 0 )
1413    IF options.!debug == 1 THEN say '_SmbConfLoad() done'
1414return
1415
1416
1417/*    if VRGet("DT_AlreadySmbConf","Visible") then do
1418        smbline = strip(translate(linein(smbconf),' ','09'x))
1419
1420        do while translate(left(smbline,8)) <> "[GLOBAL]"
1421            smbline = strip(translate(linein(smbconf),' ','09'x))
1422        end
1423
1424        do until left(smbline,1) = '['
1425            smbline = strip(translate(linein(smbconf),' ','09'x))
1426            parse var smbline voc '=' val
1427            voc = strip(voc)
1428            val = strip(val)
1429            if translate(voc) = "WORKGROUP" then do
1430                ok = VRset("EF_WorkGroup", "Value", val)
1431                ok = VRSet("EF_WorkGroup", "BackColor", "(255,255,180)")
1432            end
1433            if translate(voc) = "NETBIOS NAME" then do
1434                ok = VRset("EF_NetBIOS_Name", "Value", val)
1435                ok = VRSet("EF_NetBIOS_Name", "BackColor", "(255,255,180)")
1436            end
1437            if translate(voc) = "SERVER STRING" then do
1438                ok = VRset("EF_Server_String", "Value", val)
1439                ok = VRSet("EF_server_string", "BackColor", "(255,255,180)")
1440            end
1441
1442        end
1443        ok = stream(smbconf, 'c','close')
1444    end */
1445
1446/*:VRX         _SmbConfMigratePeer
1447*/
1448_SmbConfMigratePeer:
1449    Ok = SysFileDelete(smbconf)
1450    /* Migrate Peer To Samba */
1451
1452    /* IBMLAN.INI part */
1453    ibmlanline = strip(translate(linein(ibmlanini),' ',Indent))
1454
1455    do while translate(left(ibmlanline,11)) <> "[REQUESTER]"
1456        ibmlanline = strip(translate(linein(ibmlanini),' ',Indent))
1457    end
1458
1459    call lineout smbconf, '[global]'
1460    do until left(ibmlanline,1) = '['
1461        ibmlanline = strip(translate(linein(ibmlanini),' ',Indent))
1462        parse var ibmlanline voc '=' val
1463        voc = strip(voc)
1464        val = strip(val)
1465        if translate(voc) = "DOMAIN" then do
1466            call lineout smbconf, Indent||'workgroup = 'val
1467        end
1468        if translate(voc) = "COMPUTERNAME" then do
1469            call lineout smbconf, Indent||'netbios name = 'val
1470        end
1471    end
1472    do while translate(left(ibmlanline,6)) <> '[PEER]'
1473        ibmlanline = strip(translate(linein(ibmlanini),' ',Indent))
1474    end
1475    do until left(ibmlanline,1) = '[' | lines(ibmlanini) = 0
1476        ibmlanline = strip(translate(linein(ibmlanini),' ',Indent))
1477        parse var ibmlanline voc '=' val
1478        voc = strip(voc)
1479        val = strip(val)
1480        if translate(voc) = "SRVCOMMENT" then do
1481            call lineout smbconf, Indent||'server string = 'val
1482            call lineout smbconf, Indent||'comment = 'val
1483        end
1484    end
1485    call _SmbConfDefault_Global 1 /* 1 = migration mode */
1486
1487    call _SmbConfDefault_Scripts
1488    if CreatePDC then do
1489        call _SmbConfDefault_NetLogon
1490        call _SmbConfDefault_Profiles
1491    end
1492    call _SmbConfDefault_Homes
1493
1494    /* LSSHARE.INI part */
1495
1496    ok = SysINI(lsshareini,"ALL:","Shares." )
1497    SharePath.0 = shares.0
1498    Comment.0 = shares.0
1499    Type.0 = shares.0
1500
1501    ok = VRMethod( "Application", "ListPrinters", "printer." )
1502
1503    do I = 1 to shares.0
1504        call lineout smbconf, '['Shares.I']'
1505        sharepath.I = SysINI(lsshareini, shares.I, 'Path')
1506        Type.I = c2d(left(SysINI(lsshareini, shares.I, 'Type'),1))
1507        if Type.I = '1' then do /* We migrate a printer */
1508            do J = 1 to printer.0
1509                parse var printer.J PrinterName';'PrinterQueue';'PrinterDriver
1510                if PrinterQueue = Sharepath.I then leave
1511            end
1512            call lineout smbconf, Indent||'path = '_bs2fs(ETC'\samba\spool\'printerqueue)
1513            ok = SysMkDir(ETC'\samba\spool\'printerqueue)
1514            call lineout smbconf, Indent||'comment = 'Printername
1515            call lineout smbconf, Indent||'create mask = 0700'
1516            call lineout smbconf, Indent||'printer name = 'printerqueue
1517            call lineout smbconf, Indent||'printing = os2'
1518            call lineout smbconf, Indent||'printable = Yes'
1519            call lineout smbconf, Indent||'print command = 'samba.!bin'\smbprint.exe "%s" "%p" "%J" "%c" "%z"'
1520            call lineout smbconf, Indent||'browseable = Yes'
1521            call lineout smbconf, Indent||'guest ok = Yes'
1522            call lineout smbconf, Indent||'read only = No'
1523        end
1524        else do /* we migrate a folder */
1525            Comment.I = SysINI(lsshareini, shares.I, 'Remark')
1526            call lineout smbconf, Indent||'comment = 'Comment.I
1527            call lineout smbconf, Indent||'path = 'translate(Sharepath.I,'/','\')
1528            call lineout smbconf, Indent||'read only = No'
1529            call lineout smbconf, Indent||'browseable = Yes'
1530            call lineout smbconf, Indent||'hide files = /*. SF/root/'
1531        end
1532        call lineout smbconf, " "
1533    end
1534    ok = stream(smbconf,'c','close')
1535return
1536
1537/*:VRX         _SmbConfRestore
1538*/
1539_SmbConfRestore:
1540    ok = VRCopyFile( SmbConf"-backup", SmbConf)
1541return
1542
1543/*:VRX         _SmbConfShareRemove
1544*/
1545_SmbConfShareRemove:
1546    Aborted = 0
1547    ok = VRMethod( "CN_smbconf", "GetRecordList", "Selected", "SelectedHandle." )
1548    if Selectedhandle.0 = 0 then return
1549    Msg.Title = NLVGetMessage(67)
1550    do I = 1 to sections.0
1551        if recordhandle.I = SelectedHandle.1 then do
1552            if recordhandle.I = smbconf.!homes | recordhandle.I = smbconf.!global then do
1553                Msg.Text = NLVGetMessage(61, Sections.I)
1554                Msg.Type = 'E'
1555                call _ShowMsg
1556                Aborted = 1
1557                return
1558            end
1559
1560            Msg.Text = NLVGetMessage(62, Sections.I)
1561            Msg.Type = "Q"
1562            ok = _MsgYesNo()
1563            if ok = 2 then return
1564
1565            NewSmbConf = TempDir'smb.conf'
1566            ok = SysFileDelete(NewSmbConf)
1567            smbline = strip(linein(smbconf))
1568            do while left(translate(smbline),length(sections.I)+2) <> translate('['sections.I']')
1569                call lineout NewSmbConf, smbline
1570                smbline = strip(linein(smbconf))
1571            end
1572            smbline = strip(linein(smbconf))
1573            do while left(translate(smbline),1) <> '[' & lines(smbconf) <> 0
1574                smbline = strip(linein(smbconf))
1575            end
1576            do until lines(smbconf) = 0
1577                call lineout NewSmbConf, smbline
1578                smbline = strip(linein(smbconf))
1579            end
1580            call lineout NewSmbConf, smbline
1581            ok = stream(smbconf, 'c', 'close')
1582            ok = stream(Newsmbconf, 'c', 'close')
1583            ok = VRCopyFile( NewSmbConf, smbconf )
1584        end
1585    end
1586    call _SmbConfTreeReset
1587
1588    if _SambaRunning() then do
1589        Msg.Text = NLVGetMessage(69)
1590        Msg.Type = 'I'
1591        call _ShowMsg
1592    end
1593return
1594
1595/*:VRX         _SmbConfShareRename
1596*/
1597_SmbConfShareRename:
1598    Aborted = 0
1599    ok = VRMethod( "CN_smbconf", "GetRecordList", "Selected", "SelectedHandle." )
1600    if Selectedhandle.0 = 0 then return
1601
1602    do I = 1 to sections.0
1603        if recordhandle.I = SelectedHandle.1 then do
1604            if recordhandle.I = smbconf.!homes | recordhandle.I = smbconf.!global then do
1605                Msg.Text = NLVGetMessage(66, Sections.I)
1606                Msg.Type = 'E'
1607                call _ShowMsg
1608                Aborted = 1
1609                return
1610            end
1611            Buttons.1 = NLVGetMessage(2)
1612            Buttons.2 = NLVGetMessage(3)
1613            Buttons.0 = 2
1614            NewShareName = Sections.I
1615            id = VRPrompt( VRWindow(), NLVGetMessage(66), "NewShareName", NLVGetMessage(68), "Buttons.", buttons.1, buttons.2 )
1616            if ID = 2 | NewShareName = "" then return
1617       
1618            NewSmbConf = TempDir'smb.conf'
1619            ok = SysFileDelete(NewSmbConf)
1620            smbline = strip(linein(smbconf))
1621            do while left(translate(smbline),length(sections.I)+2) <> translate('['sections.I']')
1622                call lineout NewSmbConf, smbline
1623                smbline = strip(linein(smbconf))
1624            end
1625            call lineout NewSmbConf, '['NewShareName']'
1626            smbline = strip(linein(smbconf))
1627            do until lines(smbconf) = 0
1628                call lineout NewSmbConf, smbline
1629                smbline = strip(linein(smbconf))
1630            end
1631            call lineout NewSmbConf, smbline
1632            ok = stream(smbconf, 'c', 'close')
1633            ok = stream(Newsmbconf, 'c', 'close')
1634            ok = VRCopyFile( NewSmbConf, smbconf )
1635        end
1636    end
1637    call _SmbConfTreeReset
1638
1639    if _SambaRunning() then do
1640        Msg.Text = NLVGetMessage(69)
1641        Msg.Type = 'I'
1642        call _ShowMsg
1643    end
1644return
1645
1646/*:VRX         _SmbConfTreeInit
1647*/
1648_SmbConfTreeInit:
1649    IF options.!debug == 1 THEN say '_SmbConfTreeInit() started.'
1650    call _CfgPageSetupSize "GB_Help"
1651    call _CfgPageSetupSize "GB_Global"
1652    call _CfgPageSetupSize "GB_Shares"
1653    IF options.!debug == 1 THEN say '  Page setup done.'
1654
1655    ok = VRMethod("CN_smbconf", "RemoveRecord", "ALL")
1656    smbconf.!root     = VRMethod( "CN_smbconf", "AddRecord",,, "smb.conf","#33:PMWP.DLL")
1657    smbconf.!global   = VRMethod( "CN_smbconf", "AddRecord", smbconf.!root,, "Global","#33:PMWP.DLL")
1658    smbconf.!homes    = VRMethod( "CN_smbconf", "AddRecord", smbconf.!root,, "Homes","#33:PMWP.DLL")
1659    smbconf.!netlogon = VRMethod( "CN_smbconf", "AddRecord", smbconf.!root,, "Netlogon","#33:PMWP.DLL")
1660    smbconf.!profiles = VRMethod( "CN_smbconf", "AddRecord", smbconf.!root,, "Profiles","#33:PMWP.DLL")
1661    smbconf.!printers = VRMethod( "CN_smbconf", "AddRecord", smbconf.!root,, NLVGetMessage(45),"#93:PMWP.DLL")
1662    smbconf.!dirs     = VRMethod( "CN_smbconf", "AddRecord", smbconf.!root,, NLVGetMessage(46),"#27:PMWP.DLL")
1663    IF options.!debug == 1 THEN say '  smb.conf sections created.'
1664
1665    ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!netlogon, "Visible", 0 , "ReadOnly", 1)
1666    ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!profiles, "Visible", 0 , "ReadOnly", 1)
1667    ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!homes,    "Visible", 0 , "ReadOnly", 1)
1668    ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!root,     "Collapsed",1, "ReadOnly", 1 )
1669    ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!global,   "ReadOnly", 1)
1670    ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!printers, "ReadOnly", 1)
1671    ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!dirs,     "ReadOnly", 1)
1672
1673    IF options.!debug == 1 THEN say '  visibility set.'
1674    IF options.!debug == 1 THEN say '_SmbConfTreeInit() done.'
1675return
1676
1677/*:VRX         _SmbConfTreeReset
1678*/
1679_SmbConfTreeReset:
1680    call _SharesReset
1681    ok = VRMethod( "CN_SmbConf", "RemoveRecord", smbconf.!root )
1682    call _SmbConfTreeInit
1683    call _GUIInit
1684return
1685
1686/*:VRX         _SmbUserMapCreate
1687*/
1688_SmbUserMapCreate:
1689    call lineout samba.!smbusermap, '# Created by SSCC version 'word(VRGet("Main","Hinttext"),2)' on 'date()' at 'time()
1690    call lineout samba.!smbusermap, '# syntax:'
1691    call lineout samba.!smbusermap, '# Samba username = Windows username'
1692    call lineout samba.!smbusermap, 'root = Administrator'
1693    ok = stream(samba.!smbusermap,'c','close')
1694return
1695
1696/*:VRX         About_Close
1697*/
1698About_Close:
1699    call About_Fini
1700return
1701
1702/*:VRX         About_Create
1703*/
1704About_Create:
1705    call About_Init
1706    ok = VRSet("About","Caption", NLVGetMessage(31))
1707    ok = VRSet("PB_AboutOK","Caption", NLVGetMessage(2))
1708    SambaTeam.0 = 9
1709    SambaTeam.1 = 'Silvan Scherrer'
1710    SambaTeam.2 = 'Herwig Bauernfeind'
1711    SambaTeam.3 = 'Vitali Pelenyov'
1712    SambaTeam.4 = 'Paul Smedley'
1713    SambaTeam.5 = 'Yuri Dario'
1714    SambaTeam.6 = 'Alex Taylor'
1715    SambaTeam.7 = 'Nikolay Kolosov'
1716    SambaTeam.8 = 'All the Samba people'
1717    SambaTeam.9 = 'All the netlabs people'
1718    ok = VRSet("About","Font", VRGet("GB_Help2","Font"))
1719    ok = VRMethod("LB_SambaTeam","AddStringList", "SambaTeam." )
1720    ok = VRSet("DT_SambaTeam","Caption", NLVGetMessage(72))
1721    ok = VRSet("MLE_Version","Value", NLVGetMessage(1)||'0D0A'x||VRGet("Main", "Hinttext")||'0D0A'x||'0D0A'x||SambaVer)
1722return
1723
1724/*:VRX         About_Fini
1725*/
1726About_Fini:
1727    window = VRInfo( "Window" )
1728    call VRDestroy window
1729    drop window
1730return
1731/*:VRX         About_Init
1732*/
1733About_Init:
1734    window = VRInfo( "Object" )
1735    if( \VRIsChildOf( window, "Notebook" ) ) then do
1736        call VRMethod window, "CenterWindow"
1737        call VRSet window, "Visible", 1
1738        call VRMethod window, "Activate"
1739    end
1740    drop window
1741return
1742
1743/*:VRX         CB_Browseable_Click
1744*/
1745CB_Browseable_Click:
1746    call _ShareObject_Changed
1747return
1748
1749/*:VRX         CB_EA_Support_Click
1750*/
1751CB_EA_Support_Click:
1752    call _ShareObject_Changed
1753return
1754
1755/*:VRX         CB_Guest_OK_Click
1756*/
1757CB_Guest_OK_Click:
1758    call _ShareObject_Changed
1759return
1760
1761/*:VRX         CB_LM_Announce_Click
1762*/
1763CB_LM_Announce_Click:
1764    call _ShareObject_Changed
1765return
1766
1767/*:VRX         CB_Null_passwords_Click
1768*/
1769CB_Null_passwords_Click:
1770    call _ShareObject_Changed
1771return
1772
1773/*:VRX         CB_Read_Only_Click
1774*/
1775CB_Read_Only_Click:
1776    call _ShareObject_Changed
1777return
1778
1779/*:VRX         CB_RemoveSmbConf_Click
1780*/
1781CB_RemoveSmbConf_Click:
1782    ok = VRSet("CB_RemoveBackend", "Enabled", VRGet("CB_RemoveSmbConf","set"))
1783    if VRGet("CB_RemoveBackend", "Enabled") = 0 then ok = VRSet("CB_RemoveBackend", "Set", 0)
1784return
1785
1786/*:VRX         CB_Store_DOS_attributes_Click
1787*/
1788CB_Store_DOS_attributes_Click:
1789    call _ShareObject_Changed
1790return
1791
1792/*:VRX         CB_Time_Server_Click
1793*/
1794CB_Time_Server_Click:
1795    call _ShareObject_Changed
1796return
1797
1798/*:VRX         CB_WINS_Support_Click
1799*/
1800CB_WINS_Support_Click:
1801    call _ShareObject_Changed
1802return
1803
1804/*:VRX         CN_smbconf_Click
1805*/
1806CN_smbconf_Click:
1807    IF options.!debug == 1 THEN SAY 'CN_smbconf_Click() started'
1808    IF options.!debug == 1 THEN SAY '  Using 'smbconf' ('stream(smbconf,'c','query size')' bytes)'
1809    if ValueChanged then do
1810        if CurSection <> "" then do
1811            Msg.Title = NLVGetMessage('1')
1812            Msg.Text  = NLVGetMessage(60, CurSection)
1813            ok = _MsgYesNo()
1814            if ok = 1 then call _SaveChanges
1815            CurSection = ""
1816        end
1817    end
1818
1819    Ok = VRset("Main", "Painting", 0)
1820    ok = VRset("GB_Help",      "Visible", 0)
1821    ok = VRset("GB_Global",    "Visible", 0)
1822    ok = VRset("GB_Shares",    "Visible", 0)
1823
1824    ok = VRMethod( "CN_smbconf", "GetRecordList", "Selected", "Prophandle." )
1825    if PropHandle.0 = 0 then do
1826        IF options.!debug == 1 THEN SAY 'CN_smbconf_Click() aborted, no handle'
1827        Ok = VRset("Main", "Painting", 1)
1828        return
1829    end
1830    ParentHandle = VRMethod("CN_smbconf","GetRecordAttr", Prophandle.1,"Parent")
1831
1832    if Prophandle.1 = smbconf.!root          then ok = VRset("GB_Help",      "Visible", 1)
1833    if Prophandle.1 = smbconf.!global   | Parenthandle = smbconf.!global   then call _ActiveGroup "Global"
1834    if Prophandle.1 = smbconf.!homes    | Parenthandle = smbconf.!homes    then call _ActiveGroup "Shares"
1835    if Prophandle.1 = smbconf.!netlogon | Parenthandle = smbconf.!netlogon then call _ActiveGroup "Shares"
1836    if Prophandle.1 = smbconf.!profiles | Parenthandle = smbconf.!profiles then call _ActiveGroup "Shares"
1837    if Prophandle.1 = smbconf.!dirs     then call _ActiveGroup "Help"
1838    if Prophandle.1 = smbconf.!printers then call _ActiveGroup "Help"
1839    if Parenthandle = smbconf.!dirs     then call _ActiveGroup "Shares"
1840    if Parenthandle = smbconf.!printers then call _ActiveGroup "Shares"
1841
1842    call _SharesReset
1843    Ok = VRset("Main", "Painting", 1)
1844
1845    ok = VRSet("TM_Value", "Enabled", 1)
1846    if Prophandle.1 = smbconf.!root | Prophandle.1 = smbconf.!dirs | Prophandle.1 = smbconf.!printers then do
1847        IF options.!debug == 1 THEN SAY 'CN_smbconf_Click() aborted, got parent handle'
1848        Ok = VRset("Main", "Painting", 1)
1849        return
1850    end
1851    IF options.!debug == 1 THEN SAY '  Got child handle, start populating now'
1852    ObjYPos = 1280+361+72-120
1853    ObjXPos = 1325+72
1854    ObjDelta= 380
1855    CreatedObjs.0 = 0
1856    Objs = 0
1857
1858    Page = 1 /* for global */
1859
1860    do I = 1 to sections.0
1861        if Prophandle.1 <> recordhandle.I then iterate
1862
1863        Ok = VRset("Main", "Painting", 0)
1864        CurSection = sections.I
1865        CurSIdx = I
1866        upCurSection = translate(CurSection)
1867        IF options.!debug == 1 THEN SAY '  Section ['sections.I']'
1868
1869        if upCurSection = 'GLOBAL' then do
1870            ObjYPos = 1605+-120+361+361+361+361+361+361
1871            ObjXPos = 1325
1872            ObjDelta = 320
1873            if Page = 1 then do
1874                if \VRIsValidObject("GB_"ActiveGroup"_1") then do
1875                        ActiveGroupObj = VRCreate("GB_Global", "Window", "Name", "GL_GLOBAL_"Page, "Height", 1500, "Width", 1500, "Visible", 0, "Font", "9.WarpSans")
1876                        IF options.!debug == 1 THEN say '  Neues Fenster VRCreate = 'ok
1877                        ok = VRLoad( "GB_Global", VRWindowPath(), "GL_GLOBAL_"Page )
1878                        IF options.!debug == 1 THEN say '  VRLoad = 'ok
1879                        ok = VRMethod("GB_Global", "InsertPage", "GL_GLOBAL_"Page, "+"Page)
1880                        IF options.!debug == 1 THEN  say '  InsertPage = 'ok
1881
1882/*                    ok = VRset("Main", "Painting", 1)
1883                    Msg.Text = NLVGetMessage(114)
1884                    Msg.Type = "I"
1885                    call _ShowMsg
1886                    return */
1887                end
1888                ActiveGroupObj = VRGet("GB_"ActiveGroup"_1", "Self")
1889            end
1890        end
1891        else do
1892            if \VRIsValidObject("GB_"ActiveGroup) then do
1893                ok = VRset("Main", "Painting", 1)
1894                Msg.Text = NLVGetMessage(114)
1895                Msg.Type = "I"
1896                call _ShowMsg
1897                return
1898            end
1899            ActiveGroupObj = "GB_"ActiveGroup
1900            ok = VRSet("DT_"ActiveGroup,"Caption",sections.I)
1901        end           
1902        say "CurSection="CurSection
1903        say "smbconf="smbconf
1904
1905     /* ok = IniEnum("Voc", hdl) */ /* Old command: Fill the Voc stem with vocabulary */
1906
1907        call _MyIniEnum(CurSection)
1908
1909        if upCurSection <> 'GLOBAL' then do
1910            ok = VRSet("CB_Read_Only", "set", 1)
1911        end
1912        do V = 1 to Voc.0  /* loop for every vocabulary */
1913            ValueChanged = 0
1914            ChangeList = ""
1915
1916         /* get value for this vocabulary */               
1917           Val.V = IniGet(Voc.V, CurSection, samba.!smbconf) /* this is currently done by _MyIniEnum (which is probably not good) */
1918            select
1919                when pos("\\",Val.V) > 0 then nop
1920                when pos(" dir",Voc.V) > 0 then Val.V = _fs2bs(Val.V)
1921                when pos("file",Voc.V) > 0 then Val.V = _fs2bs(Val.V)
1922                when pos("path",Voc.V) > 0 then Val.V = _fs2bs(Val.V)
1923                when pos("username map",Voc.V) > 0 then Val.V = _fs2bs(Val.V)
1924                otherwise nop /* do not beautify */
1925            end
1926
1927            IF options.!debug == 1 THEN say '  Process: "'Voc.V'" = "'Val.V'"'
1928
1929            /* Proper format to ease checking and object creation */
1930            upVal = translate(Val.V)
1931            upVoc = translate(translate(Voc.V,'_',' '))
1932
1933            if upVal = 'YES'| upVal = 'NO'
1934                then VocObjType = 'CB'
1935                else VocObjType = 'EF'
1936
1937            /* Non configurable items */
1938            if upVoc = "PRINTABLE" then iterate
1939            if pos('SCRIPT', upVoc)  > 0 then iterate
1940            if pos('COMMAND', upVoc)  > 0 then iterate
1941
1942            if upVoc = "COMMENT" then do
1943                CurPage = Page
1944                CurActiveGroupObj = ActiveGroupObj
1945                if Page <> 1 then ActiveGroupObj = VRGet("GB_"ActiveGroup"_1", "Self")
1946                OldObjYPos = ObjYPos
1947                if upCurSection = "GLOBAL" then ObjYPos = 860-120
1948                                           else ObjYPos = 860+361+72
1949                if _CreateVocObject() then do
1950                    ok = VRSet(VocObjType"_"upVoc, 'Value', Val.V)
1951                    ok = VRFlush( , VocObjType"_"upVoc )
1952                end
1953                ActiveGroupObj = CurActiveGroupObj
1954                Page = CurPage
1955                ObjYPos = OldObjYPos
1956            end
1957            else do /* Normalfall */
1958                if _CreateVocObject() then do
1959                    if upVal = "YES" | upVal = "NO" then do
1960                        ok = VRset(VocObjType"_"upVoc,"Set", (upVal="YES"))
1961                        ok = VRFlush( , VocObjType"_"upVoc )
1962                    end
1963                    else do
1964                        ok = VRSet(VocObjType"_"upVoc, 'Value', Val.V)
1965                        ok = VRFlush( , VocObjType"_"upVoc )
1966                        if translate(VocObjType"_"upVoc) = VocObjType"_PRINTER_NAME" then do
1967                            ok = VRSet(VocObjType"_"upVoc, 'ReadOnly', 1)
1968                            ok = VRSet(VocObjType"_"upVoc, 'BackColor', 'PaleGray')
1969                        end
1970                    end
1971                end   
1972                nop
1973            end
1974            ok = VRSet(VocObjType"_"upVoc, 'Userdata', V)
1975
1976            if upCurSection = 'GLOBAL' then do
1977                if upVoc = "WINBIND_SEPARATOR" then do /* Workaround for Samba Ticket #57 */
1978                    ok = VRset("DT_WINBIND_SEPARATOR","Visible","0")
1979                    ok = VRset("EF_WINBIND_SEPARATOR","Value","|")
1980                    ok = VRFlush( , "EF_WINBIND_SEPARATOR" )
1981                    ok = VRset("EF_WINBIND_SEPARATOR","Visible",0)
1982                    ObjYPos = ObjYPos - ObjDelta
1983                end
1984
1985                if ObjYPos > VRGet("GB_Global","Height") - 1200 then do
1986                    /* Ok = VRset("Main", "Painting", 1) */
1987                    Page = Page + 1
1988                    if Page = 2 then do
1989                        Ok = VRset("Main", "Painting", 1)
1990                        ok = VRSet("Main", 'Pointer', 'Wait' )
1991                        Ok = VRset("Main", "Painting", 0)
1992                    end
1993                    if \VRIsValidOBject("GL_GLOBAL_"Page) then do
1994                        ActiveGroupObj = VRCreate("GB_Global", "Window", "Name", "GL_GLOBAL_"Page, "Height", 1500, "Width", 1500, "Visible", 0, "Font", "9.WarpSans")
1995                        IF options.!debug == 1 THEN say '  Neues Fenster VRCreate = 'ok
1996                        ok = VRLoad( "GB_Global", VRWindowPath(), "GL_GLOBAL_"Page )
1997                        IF options.!debug == 1 THEN say '  VRLoad = 'ok
1998                        ok = VRMethod("GB_Global", "InsertPage", "GL_GLOBAL_"Page, "+"Page)
1999                        IF options.!debug == 1 THEN  say '  InsertPage = 'ok
2000                    end
2001                    else do
2002                        ActiveGroupObj = VRGet("GL_GLOBAL_"Page, "Self")
2003                    end
2004                    ObjYPos = 0
2005                    IF options.!debug == 1 THEN say "  Page ="page
2006                    /* Ok = VRset("Main", "Painting", 0) */
2007                end
2008            end
2009        end
2010    end     
2011    if upCurSection = "GLOBAL" then do
2012        if VRGet("EF_Netbios_name","Value") = "" then do
2013            ok = VRset("EF_NETBIOS_NAME","Value",Value("HOSTNAME",,"OS2ENVIRONMENT"))
2014            ok = VRFlush( , "EF_NETBIOS_NAME" )
2015        end
2016        if VRGet("EF_WorkGroup","Value") = "" then do
2017            ok = VRset("EF_WorkGroup","Value","WORKGROUP")
2018            ok = VRFlush( , "EF_WorkGroup" )
2019        end
2020    end
2021
2022    Ok = VRset("Main", "Painting", 1)
2023    ok = VRSet("Main", 'Pointer', '<default>' )
2024    IF options.!debug == 1 THEN SAY 'CN_smbconf_Click() done'
2025return
2026/*:VRX         CN_smbconf_ContextMenu
2027*/
2028CN_smbconf_ContextMenu:
2029    ok = VRMethod( "CN_smbconf", "GetRecordList", "Selected", "Prophandle." )
2030    if PropHandle.0 = 0 then return
2031    ParentHandle = VRMethod("CN_smbconf","GetRecordAttr", Prophandle.1,"Parent")
2032    ok = VRset("Menu_ShareContext_AddPrinter",    "Visible", 0)   
2033    ok = VRset("Menu_ShareContext_RenamePrinter", "Visible", 0)   
2034    ok = VRset("Menu_ShareContext_RemovePrinter", "Visible", 0)
2035    ok = VRset("Menu_ShareContext_Add",           "Visible", 0)   
2036    ok = VRset("Menu_ShareContext_Rename",        "Visible", 0)
2037    ok = VRset("Menu_ShareContext_Remove",        "Visible", 0)
2038
2039    if Prophandle.1 = smbconf.!root          then ok = VRset("GB_Help",      "Visible", 1)
2040    if Prophandle.1 = smbconf.!global   | Parenthandle = smbconf.!global   then return
2041    if Prophandle.1 = smbconf.!homes    | Parenthandle = smbconf.!homes    then return
2042    if Prophandle.1 = smbconf.!dirs then do
2043        ok = VRset("Menu_ShareContext_Add", "Visible", 1)   
2044    end
2045    if Parenthandle = smbconf.!dirs then do
2046        ok = VRset("Menu_ShareContext_Add", "Visible", 1)   
2047        ok = VRset("Menu_ShareContext_Rename", "Visible", 1)
2048        ok = VRset("Menu_ShareContext_Remove", "Visible", 1)
2049    end
2050    if Prophandle.1 = smbconf.!printers then do
2051        ok = VRset("Menu_ShareContext_AddPrinter", "Visible", 1)   
2052    end
2053    if Parenthandle = smbconf.!printers then do
2054        ok = VRset("Menu_ShareContext_AddPrinter", "Visible", 1)   
2055        ok = VRset("Menu_ShareContext_RenamePrinter", "Visible", 1)   
2056        ok = VRset("Menu_ShareContext_RemovePrinter", "Visible", 1)
2057    end
2058
2059    ok = VRMethod( "Menu_ShareContext", "Popup", , , "", "" )
2060
2061return
2062
2063/*:VRX         EF_display_charset_Change
2064*/
2065EF_display_charset_Change:
2066    call _ShareObject_Changed
2067return
2068
2069/*:VRX         EF_dos_charset_Change
2070*/
2071EF_dos_charset_Change:
2072    call _ShareObject_Changed
2073return
2074
2075/*:VRX         EF_Log_file_Change
2076*/
2077EF_Log_file_Change:
2078    call _ShareObject_Changed
2079return
2080
2081/*:VRX         EF_LOG_LEVEL_Change
2082*/
2083EF_LOG_LEVEL_Change:
2084    call _ShareObject_Changed
2085return
2086
2087/*:VRX         EF_NetBIOS_Name_Change
2088*/
2089EF_NetBIOS_Name_Change:
2090    call _ShareObject_Changed
2091return
2092
2093/*:VRX         EF_path_Change
2094*/
2095EF_path_Change:
2096    call _ShareObject_Changed
2097return
2098
2099/*:VRX         EF_SECURITY_Change
2100*/
2101EF_SECURITY_Change:
2102    call _ShareObject_Changed
2103return
2104
2105/*:VRX         EF_Server_String_Change
2106*/
2107EF_Server_String_Change:
2108    call _ShareObject_Changed
2109return
2110
2111/*:VRX         EF_Unix_charset_Change
2112*/
2113EF_Unix_charset_Change:
2114    call _ShareObject_Changed
2115return
2116
2117/*:VRX         EF_Workgroup_Change
2118*/
2119EF_Workgroup_Change:
2120    call _ShareObject_Changed
2121return
2122
2123/*:VRX         Fini
2124*/
2125Fini:
2126    window = VRWindow()
2127    call VRSet window, "Visible", 0
2128    drop window
2129return 0
2130
2131/*:VRX         GB_Global_1_Close
2132*/
2133GB_Global_1_Close:
2134    call GB_Global_1_Fini
2135return
2136
2137/*:VRX         GB_Global_1_Create
2138*/
2139GB_Global_1_Create:
2140    call GB_Global_1_Init   
2141return
2142
2143/*:VRX         GB_Global_1_Fini
2144*/
2145GB_Global_1_Fini:
2146    window = VRInfo( "Window" )
2147    call VRDestroy window
2148    drop window
2149return
2150/*:VRX         GB_Global_1_Init
2151*/
2152GB_Global_1_Init:
2153    window = VRInfo( "Object" )
2154    if( \VRIsChildOf( window, "Notebook" ) ) then do
2155        call VRMethod window, "CenterWindow"
2156        call VRSet window, "Visible", 1
2157        call VRMethod window, "Activate"
2158    end
2159    drop window
2160return
2161
2162/*:VRX         Halt
2163*/
2164Halt:
2165    signal _VREHalt
2166return
2167
2168/*:VRX         Init
2169*/
2170Init:
2171    window = VRWindow()
2172    call VRMethod window, "CenterWindow"
2173    call VRSet window, "Visible", 1
2174    call VRMethod window, "Activate"
2175    drop window
2176return
2177
2178/*:VRX         Installer_Close
2179*/
2180Installer_Close:
2181    Msg.Text = NLVGetMessage(114)
2182    Msg.Type = "I"
2183    call _ShowMsg
2184    call Installer_Fini
2185return
2186
2187/*:VRX         Installer_Create
2188*/
2189Installer_Create:
2190    call Installer_Init
2191    CALL NLVSetText 'Installer',                  'Caption', 90
2192    CALL NLVSetText 'DT_RootPasswordDescription', 'Caption', 91
2193    CALL NLVSetText 'DT_RootPassword',            'Caption', 92
2194    CALL NLVSetText 'DT_RootPassword_repeat',     'Caption', 93
2195    CALL NLVSetText 'CB_NoRoot',                  'Caption', 94
2196    CALL NLVSetText 'DT_Backend',                 'Caption', 95
2197    CALL NLVSetText 'DT_ServerType',              'Caption', 96
2198    CALL NLVSetText 'PB_Install_Default',         'Caption', 97
2199    CALL NLVSetText 'PB_Install_Migration',       'Caption', 98
2200
2201    ok = VRSet("PB_Install_Migration", "Enabled", lsshareiniexists * ibmlaniniexists )
2202    ok = VRSet("TM_Installer","Enabled", 0)
2203    if stream(samba.!group,'c','query exists') = "" | stream(samba.!group,'c','query size') < 120 then do
2204        call _GroupCreate
2205    end
2206    if stream(samba.!masterpasswd,'c','query exists') = "" | stream(samba.!group,'c','query size') < 230 then do
2207        call _MasterPasswdCreate
2208        call _PasswordDBRewrite
2209        ok = VRSet("CB_NoRoot","Enabled", 0)
2210    end
2211    if stream(samba.!pwddb,'c','query exists') = "" | stream(samba.!spwddb,'c','query exists') = "" then do
2212        call _PasswordDBRewrite
2213        ok = VRSet("CB_NoRoot","Enabled", 0)
2214    end
2215    if \VRFileExists(ETC'\samba\private\secrets.tdb') then do
2216        ok = VRSet("CB_NoRoot","Enabled", 0)
2217    end
2218    UseTDBsam = 1
2219    CreatePDC = 0
2220return
2221
2222/*:VRX         Installer_Fini
2223*/
2224Installer_Fini:
2225    window = VRInfo( "Window" )
2226    call VRDestroy window
2227    drop window
2228return
2229/*:VRX         Installer_Init
2230*/
2231Installer_Init:
2232    window = VRInfo( "Object" )
2233    if( \VRIsChildOf( window, "Notebook" ) ) then do
2234        call VRMethod window, "CenterWindow"
2235        call VRSet window, "Visible", 1
2236        call VRMethod window, "Activate"
2237    end
2238    drop window
2239return
2240
2241/*:VRX         IPB_ChooseDir_Click
2242*/
2243IPB_ChooseDir_Click:
2244    InitDir = VRGet("EF_Path","Value")
2245    VarPos = pos('%', InitDir)
2246    if VarPos > 0 then do
2247        VarChar = substr(InitDir,VarPos,2)
2248        InitDir = left(InitDir,VarPos-1)
2249        say VarChar
2250    end
2251    NewPath = _dirDialog('Choose path for 'VRGet("DT_Shares","Caption"),_fs2bs(InitDir))
2252    if NewPath = "" then return
2253    if VarPos > 0 then NewPath = NewPath'\'VarChar
2254    ok = VRset("EF_Path","value",NewPath)
2255return
2256
2257/*:VRX         IPB_NewItem_Click
2258*/
2259IPB_NewItem_Click:
2260    smbconfopt = samba.!tools'\smbconf.opt'
2261say smbconfopt
2262    do until lines(smbconfopt) = 0
2263        smbconfline = linein(smbconfopt)
2264say smbconfline
2265        I = I + 1
2266        opt.I = smbconfline
2267    end
2268    opt.0 = I
2269    ok = stream(smbconfopt,'c','close')
2270    ok = VRMethod("DDCB_Add_Voc","Reset")
2271    ok = VRMethod("DDCB_Add_Voc","AddStringList", opt.)
2272    ok = VRSet("DDCB_Add_Voc","Top",ObjYPos-380)
2273    ok = VRSet("EF_Add_Voc","Top",ObjYPos-380)
2274    ok = VRSet("PB_Add_Voc_OK","Top",ObjYPos)
2275    ok = VRSet("PB_Add_Voc_Cancel","Top",ObjYPos)
2276
2277    ok = VRSet("DDCB_ADD_Voc","Visible",1)
2278    ok = VRSet("EF_ADD_Voc","Visible",1)
2279    ok = VRSet("PB_Add_Voc_OK","Visible",1)
2280    ok = VRSet("PB_add_Voc_Cancel","Visible",1)
2281return
2282
2283/*:VRX         Main_Close
2284*/
2285Main_Close:
2286    call Quit
2287return
2288
2289/*:VRX         Main_Create
2290*/
2291Main_Create:
2292    ok = VRREdirectStdIO("ON")
2293    options.!debug = 1
2294
2295    call _LoadOtherFuncs
2296
2297    call _INIRead
2298
2299    call _ParseCommandLine
2300
2301    call _InitTempDir
2302    call _SambaInit
2303    call _SambaExtendSearchPath
2304    call _GUIInitNLV
2305
2306    call _FindHtpasswd
2307    call Main_Resize
2308    call _SambaCheckComponents
2309    call _SambaVersion
2310    call _FindIBMLANPath
2311    call _SmbConfTreeInit /* creates the records for default sections */
2312
2313    /* Installation mode is triggered by a timer activated in GUIInit, when no smb.conf exists */
2314    call _GUIInit
2315return
2316
2317/*:VRX         Main_Resize
2318*/
2319Main_Resize:
2320    IF options.!debug == 1 THEN SAY "Main_Resize() started"
2321    Ok = VRset("Main", "Painting", 0)
2322
2323   /*  /* Basic measurements */
2324    main_iwidth  = VRGet("Main","InteriorWidth")                /* Width of window client-area */
2325    main_iheight = VRGet("Main","InteriorHeight")               /* Height of window client-area */
2326
2327    if main_iheight < 5500 then ok = VRSet("Main","Height",6200)
2328    sbar_height  = VRGet("GB_STATUSBAR","Height")               /* Height of status-bar */
2329    split_left   = VRGet("SPLIT_Main","Left")                   /* Position of the left edge of the split-bar */
2330    marginx2     = margin * 2                                   /* Common margin around controls */
2331    pbtn_height  = 400                                          /* Height of the panels' internal button areas */
2332
2333    pane_height  = main_iheight - sbar_height - (margin * 4)    /* Height of a split-bar panel */
2334    lpane_width  = split_left - margin                          /* Width of the left split-bar panel */
2335    rpane_width  = main_iwidth - split_left - 60 - margin       /* Width of the right split-bar panel */ */
2336
2337    /* ab hier alt */
2338    ok = VRSet("GB_SmbConfTree","Top",    FWidth)
2339    ok = VRSet("GB_SmbConfTree","Left",   FWidth-24)
2340    ok = VRSet("GB_SmbConfTree","Height", VRGet("Main", "Height") -1350)
2341
2342    ok = VRset("GB_SmbConfTree3","Top",     FWidth)
2343    ok = VRset("GB_SmbConfTree3","Left",    FWidth)
2344    ok = VRset("GB_SmbConfTree3","Height",  245  )
2345    ok = VRset("GB_SmbConfTree3","Width",   VRGet("GB_SmbConfTree","Width") -(FWidth*2))
2346
2347    ok = VRset("DT_SmbConfTree","Top",     8)
2348    ok = VRset("DT_SmbConfTree","Left",    8)
2349    ok = VRset("DT_SmbConfTree","Height",  213)
2350    ok = VRset("DT_SmbConfTree","Width",   VRGet("GB_SmbConfTree3","Width") - 24)
2351
2352    ok = VRset("GB_SmbConfTree2","Left",   FWidth)
2353    ok = VRset("GB_SmbConfTree2","Top",    245 + FWidth*2)
2354    ok = VRset("GB_SmbConfTree2","Width",  VRGet("GB_SmbConfTree","Width")-FWidth*2)
2355    ok = VRset("GB_SmbConfTree2","Height", VRGet("GB_SmbConfTree","Height")-FWidth*3-245)
2356
2357    ok = VRset("CN_SmbConf", "Top",    FWidth)
2358    ok = VRset("CN_SmbConf", "Left",   FWidth)
2359    ok = VRset("CN_SmbConf", "Width",  VRGet("GB_SmbConfTree2","Width") -(FWidth*2))
2360    ok = VRset("CN_SmbConf", "Height", VRGet("GB_SmbConfTree2","Height")-(FWidth*2))
2361
2362    ok = VRset("GB_Help",   "Top",    FWidth)
2363    ok = VRset("GB_Help",   "Left",   VRGet("GB_SmbConfTree","Width") + 60)
2364    ok = VRSet("GB_Help",   "Height", VRGet("GB_SmbConfTree","Height"))
2365    ok = VRSet("GB_Help",   "Width",  VRGet("Main", "Width") - VRGet("GB_SmbConfTree","width") - 60- FWidth*2-24*2)
2366
2367    ok = VRset("GB_Help3","Top",     FWidth)
2368    ok = VRset("GB_Help3","Left",    FWidth)
2369    ok = VRset("GB_Help3","Height",  245  )
2370    ok = VRset("GB_Help3","Width",   VRGet("GB_Help","Width") -(FWidth*2))
2371
2372    ok = VRset("GB_Help2","Left",   FWidth)
2373    ok = VRset("GB_Help2","Top",    245 + FWidth*2)
2374    ok = VRset("GB_Help2","Width",  VRGet("GB_Help","Width")-FWidth*2)
2375    ok = VRset("GB_Help2","Height", VRGet("GB_Help","Height")-FWidth*3-245)
2376
2377    ok = VRset("DT_Help","Top",     8)
2378    ok = VRset("DT_Help","Left",    8)
2379    ok = VRset("DT_Help","Height",  213)
2380    ok = VRset("DT_Help","Width",   VRGet("GB_Help3","Width") - 24)
2381
2382    ok = VRset("GB_Shares",   "Top",    FWidth)
2383    ok = VRset("GB_Shares",   "Left",   VRGet("GB_SmbConfTree","Width") + 60)
2384    ok = VRSet("GB_Shares",   "Height", VRGet("GB_SmbConfTree","Height"))
2385    ok = VRSet("GB_Shares",   "Width",  VRGet("Main", "Width") - VRGet("GB_SmbConfTree","width") - 60- FWidth*2-24*2)
2386
2387    ok = VRset("GB_Shares3","Top",     FWidth)
2388    ok = VRset("GB_Shares3","Left",    FWidth)
2389    ok = VRset("GB_Shares3","Height",  245  )
2390    ok = VRset("GB_Shares3","Width",   VRGet("GB_Shares","Width") -(FWidth*2))
2391
2392    ok = VRset("GB_Shares2","Left",   FWidth)
2393    ok = VRset("GB_Shares2","Top",    245 + FWidth*2)
2394    ok = VRset("GB_Shares2","Width",  VRGet("GB_Shares","Width")-FWidth*2)
2395    ok = VRset("GB_Shares2","Height", VRGet("GB_Shares","Height")-FWidth*3-245)
2396
2397    ok = VRset("DT_Shares", "Top",    8)
2398    ok = VRset("DT_Shares", "Left",   8)
2399    ok = VRset("DT_Shares", "Height", 213)
2400    ok = VRset("DT_Shares", "Width",  VRGet("GB_Shares3","Width") - 24)
2401
2402    ok = VRSet("GB_Global", "Height", VRGet("GB_SmbConfTree","Height"))
2403    ok = VRSet("GB_Global", "Width",  VRGet("GB_Shares",     "Width"))
2404
2405    MButton.bTop   = VRGet("GB_SmbConfTree","height")+FWidth*2
2406    MButton.bLeft  = VRGet("GB_Shares","Left")
2407    MButton.bWidth = VRGet("PB_Save","Width")
2408
2409    if MButton.bTop < 1300 & MButton.bLeft < 1300 then do
2410        MButton.bTop = 4842
2411        MButton.bLeft = 3758
2412        MButton.bWidth = 1241
2413        FWidth = 32
2414    end
2415
2416    ok = VRSet("PB_Reload", "Top",    MButton.bTop)
2417    ok = VRSet("PB_Reload", "Left",   MButton.bLeft)
2418    ok = VRSet("PB_Reload", "Width",  MButton.bWidth)
2419
2420    ok = VRSet("PB_Save", "Top",    MButton.bTop)
2421    ok = VRSet("PB_Save", "Left",   MButton.bLeft+1*FWidth+MButton.bWidth)
2422    ok = VRSet("PB_Reload", "Width",  MButton.bWidth)
2423
2424    ok = VRSet("PB_Undo",   "Top",    MButton.bTop)
2425    ok = VRSet("PB_Undo",   "Left",   MButton.bLeft+2*FWidth+MButton.bWidth*2)
2426    ok = VRSet("PB_Undo",   "Width",  MButton.bWidth)
2427
2428    ok = VRSet("PB_Cancel", "Top",    MButton.bTop)
2429    ok = VRSet("PB_Cancel", "Left",   MButton.bLeft+3*FWidth+MButton.bWidth*3)
2430    ok = VRSet("PB_Cancel", "Width",  MButton.bWidth)
2431
2432 /* ok = VRSet("PB_Help",   "Top",    MButton.bTop)
2433    ok = VRSet("PB_Help",   "Left",   MButton.bLeft+6*FWidth+MButton.bWidth*3)
2434    ok = VRSet("PB_Help",   "Width",  MButton.bWidth) */
2435
2436    drop MButton.b
2437
2438    Top    = VRGet("Main","Top")
2439    Left   = VRGet("Main","Left")
2440    Width  = VRGet("Main","Width")
2441    Height = VRGet("Main","Height")
2442
2443    if ActiveGroup = "Global" then do
2444
2445    end
2446    IF options.!debug == 1 THEN SAY "  Window size = "VRGet("Main","Width")', 'VRGet("Main","Height")
2447
2448    /* check and empty event queue, trash spurious resize events */
2449    EventString = ''
2450    TrashedResize = 0
2451    do until EventString = 'nop'
2452        EventString = VREvent('N')
2453        say '  Event: "'EventString'" ('TrashedResize')'
2454        if EventString <> 'nop' then do
2455            if EventString = 'CALL Main_Resize' then TrashedResize = TrashedResize + 1
2456                                                else interpret eventString
2457        end
2458    end
2459    if TrashedResize >= 2 then CALL Main_Resize
2460
2461    IF options.!debug == 1 THEN SAY "  Window size = "VRGet("Main","Width")', 'VRGet("Main","Height")
2462    Ok = VRset("Main", "Painting", 1)
2463    IF options.!debug == 1 THEN SAY "Main_Resize() done"
2464return
2465
2466/*:VRX         Menu_Action_AddHomes_Click
2467*/
2468Menu_Action_AddHomes_Click:
2469    call _SmbConfDefault_Homes
2470    call _SmbConfTreeInit
2471    call _SmbConfLoad
2472return
2473
2474/*:VRX         Menu_Action_AddNetLogon_Click
2475*/
2476Menu_Action_AddNetLogon_Click:
2477    call _SmbConfDefault_Netlogon
2478    call _SmbConfTreeInit
2479    call _SmbConfLoad
2480return
2481
2482/*:VRX         Menu_Action_AddProfiles_Click
2483*/
2484Menu_Action_AddProfiles_Click:
2485    call _SmbConfDefault_Profiles
2486    call _SmbConfTreeInit
2487    call _SmbConfLoad
2488return
2489
2490/*:VRX         Menu_Action_EraseTransient_Click
2491*/
2492Menu_Action_EraseTransient_Click:
2493    if _SambaRunning() then do
2494        Msg.Text = NLVGetMessage(70)
2495        Msg.Type = "E"
2496        ok = _ShowMsg()
2497        return
2498    end
2499
2500    ok = VRMethod("CN_smbconf","SetRecordAttr", smbconf.!global, "Selected", 1)
2501    call CN_smbconf_Click   
2502
2503    if VRIsValidObject( "EF_LOCK_DIRECTORY" ) then do
2504        LockDir = VRGet("EF_Lock_Directory","Value")
2505        Msg.Text = NLVGetMessage(71)
2506        Msg.Type = "Q"
2507        ok = _MsgYesNo()
2508        if ok <> 1 then return
2509
2510        ok = SysFileDelete(LockDir"\gencache.tdb")
2511        ok = SysFileDelete(LockDir"\brlock.tdb")
2512        ok = SysFileDelete(LockDir"\unexpected.tdb")
2513        ok = SysFileDelete(LockDir"\connections.tdb")
2514        ok = SysFileDelete(LockDir"\locking.tdb")
2515        ok = SysFileDelete(LockDir"\messages.tdb")
2516    end
2517return
2518
2519/*:VRX         Menu_File_Debug_Click
2520*/
2521Menu_File_Debug_Click:
2522    options.!debug = VRGet("Menu_File_debug","Checked")
2523
2524    /* The following 2 lines are unnecessary for a checkbox ! */
2525    ok = VRSet("Menu_File_debug","Checked",\options.!debug)
2526    options.!debug = \options.!debug
2527
2528    if options.!debug
2529        then ok = VRRedirectStdIO("On")
2530        else ok = VRRedirectStdIO("OFF")
2531   
2532return
2533
2534/*:VRX         Menu_File_Exit_Click
2535*/
2536Menu_File_Exit_Click:
2537    call Quit
2538return
2539
2540/*:VRX         Menu_File_Import_IBMPeer_Click
2541*/
2542Menu_File_Import_IBMPeer_Click:
2543    call _SmbConfMigratePeer
2544    ok = SysFileTree(smbconf,exist.,'FO')
2545    SmbConfExists = exist.0
2546    call _SmbConfTreeReset
2547return
2548
2549/*:VRX         Menu_File_ImportHosts_Click
2550*/
2551Menu_File_ImportHosts_Click:
2552    if VRFileExists(ETC'\samba\lmhosts') then do
2553        Msg.Text = NLVGetMessage(56, ETC'\samba\lmhosts')
2554        Msg.Type = 'Q'
2555        if _MsgYesNo() = 1 then do
2556            call _LMHostsImport
2557        end
2558    end
2559    else call _LMHostsImport
2560return
2561
2562/*:VRX         Menu_File_PrintCap_Click
2563*/
2564Menu_File_PrintCap_Click:
2565    call _PrintcapCreate
2566    Msg.Text = NLVGetMessage(50, samba.!printcap)
2567    msg.Type = 'I'
2568    call _ShowMsg
2569return
2570
2571/*:VRX         Menu_File_reset_Click
2572*/
2573Menu_File_reset_Click:
2574    call _SmbConfCreateDefault
2575    ok = SysFileTree(smbconf,exist.,'FO')
2576    SmbConfExists = exist.0
2577    call _SmbConfTreeReset
2578return
2579
2580/*:VRX         Menu_File_SmbUpdate_Click
2581*/
2582Menu_File_SmbUpdate_Click:
2583    BuildFile = VRFileDialog( VRWindow(), NLVGetMessage(64), "Open", options.!builddir"\samba-*zip", , ,  )
2584    if BuildFile = '' then return
2585    options.!builddir = VRParseFilename(buildfile,'DP')
2586    address CMD samba.!smbcmd' stop'
2587    OldDir = Directory(Strip(samba.!bin,'T','\'))
2588    ok = VRRedirectStdIO('ON')
2589    address cmd 'unzip.exe -oCj 'BuildFile' *.exe *.dll'
2590    say 'unzip RC = 'RC
2591    if RC <> 0 then address cmd 'PAUSE'
2592    IF options.!debug <> 1 THEN ok = VRRedirectStdIO('OFF')
2593    ok = directory(OldDir)
2594    call _SambaVersion
2595    ok = VRSet("EF_Binaries_Version","value",samba.!version)
2596    address CMD samba.!smbcmd' start'
2597return
2598
2599/*:VRX         Menu_Help_About_Click
2600*/
2601Menu_Help_About_Click:
2602    say '  'samba.!smbd' -V --debuglevel=0 2>'samba.!error' 1>'smboutput
2603    address cmd samba.!smbd' -V --debuglevel=0 2>'samba.!error' 1>'smboutput
2604
2605    SambaVer = "Samba "||strip(linein(smboutput))
2606    ok = stream(smboutput,'c','close')
2607
2608    window = VRLoadSecondary( "About", "W" )
2609return
2610
2611/*:VRX         Menu_Options_ExportMode_Click
2612*/
2613Menu_Options_ExportMode_Click:
2614    say 'ExpertMode_Click started'
2615    say         samba.!testparmexe' -v -s 1>'TempDir'smb.conf 2>'TempDir'sscc.testparm'
2616    address cmd samba.!testparmexe' -v -s 1>'TempDir'smb.conf 2>'TempDir'sscc.testparm'
2617    say 'VRCopyFile('TempDir'smb.conf, 'smbconf' )'
2618    say "  smb.conf Gr”áe: "stream(smbconf,'c','QUERY SIZE')
2619    ok = VRCopyFile( TempDir'smb.conf', smbconf )
2620    say "  smb.conf Gr”áe: "stream(smbconf,'c','QUERY SIZE')
2621    say 'Copy ok ='ok' (1 = success, 0 = failure)'
2622    call _SmbConfTreeReset
2623    call Main_Resize
2624    say 'ExpertMode_Click done'
2625return
2626
2627/*:VRX         Menu_Options_MiniIcons_Click
2628*/
2629Menu_Options_MiniIcons_Click:
2630    advanced.!bigicons = \advanced.!bigicons
2631    ok = VRset("CN_SMBCONF", "MiniIcons", \advanced.!bigicons)
2632    ok = VRset("Menu_Options_MiniIcons",  "Checked", \advanced.!bigicons)
2633return
2634
2635/*:VRX         Menu_Options_SimpleMode_Click
2636*/
2637Menu_Options_SimpleMode_Click:
2638    say 'SimpleMode_Click started'
2639
2640    /* Workaround for testparm bugs */
2641    say 'VRCopyFile('smbconf', 'TempDir'smb.conf )'
2642    ok = VRCopyFile( smbconf, TempDir'smb.conf')
2643    call _SmbConfCommitChanges
2644
2645    say samba.!testparmexe' -s 1>'TempDir'smb.conf 2>'TempDir'sscc.testparm'
2646    address cmd samba.!testparmexe' -s 1>'TempDir'smb.conf 2>'TempDir'sscc.testparm'
2647    NewSize = stream(TempDir"smb.conf",'c','QUERY SIZE')
2648    say "  "TempDir"smb.conf Gr”áe: "NewSize
2649    if NewSize = 0 then 'pause'
2650    say "  smb.conf Gr”áe: "stream(smbconf,'c','QUERY SIZE')
2651    say 'VRCopyFile('TempDir'smb.conf, 'smbconf' )'
2652    ok = VRCopyFile( TempDir'smb.conf' , smbconf )
2653    say "  smb.conf Gr”áe: "stream(smbconf,'c','QUERY SIZE')
2654    say 'Copy ok ='ok' (1 = success, 0 = failure)'
2655    call _SmbConfTreeReset
2656    do I = Page to 3 by -1
2657        ok = VRMethod( "GB_Global", "DeletePage", I  )
2658        ok = VRDestroy("GL_GLOBAL_"I)
2659    end
2660    Page = 2
2661    call Main_resize
2662say 'SimpleMode_Click done'
2663return
2664
2665/*:VRX         Menu_ShareContext_Add_Click
2666*/
2667Menu_ShareContext_Add_Click:
2668        NewShareDir = _dirDialog()
2669        if NewShareDir = "" then return
2670        NewShareName = filespec("N",NewShareDir)
2671        Buttons.1 = "OK"
2672        Buttons.2 = "Abort"
2673        Buttons.0 = 2
2674        id = VRPrompt( VRWindow(), "Enter name for new share", "NewShareName", "Add new Samba share", "Buttons.", buttons.1, buttons.2 )
2675        if ID = 2 | NewShareName = "" then return
2676        NewShareHandle = VRMethod( "CN_smbconf", "AddRecord", smbconf.!dirs,, NewShareName,"#4")
2677        call lineout smbconf, '['NewShareName']'
2678        call lineout smbconf, Indent||'path = '_bs2fs(NewShareDir)
2679        call lineout smbconf, Indent||'comment = 'NewShareName' directory'
2680        call lineout smbconf, Indent||'browseable = Yes'
2681        call lineout smbconf, Indent||'read only = Yes'
2682        call lineout smbconf, Indent||'hide files = /*.?SF/'
2683        call lineout smbconf
2684        call _SmbConfTreeReset
2685        Msg.Text = NLVGetMessage(69)
2686        Msg.Type = 'I'
2687        call _ShowMsg
2688        ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!dirs, "Collapsed", 0 )
2689        ok = VRMethod("CN_smbconf","SetRecordAttr",NewShareHandle, "Selected", 1 )
2690return
2691
2692/*:VRX         Menu_ShareContext_AddPrinter_Click
2693*/
2694Menu_ShareContext_AddPrinter_Click:
2695        AbortPrinter = 1
2696        window = VRLoadSecondary( "PrinterSelection", "W" )
2697        if AbortPrinter then return
2698        parse var SharePrinter PrinterName';'PrinterQueue';'PrinterDriver
2699        NewShareHandle = VRMethod( "CN_smbconf", "AddRecord", smbconf.!printers,, PrinterQueue,"#4")
2700        call lineout smbconf, '['PrinterQueue']'
2701        call lineout smbconf, Indent||'path = '_bs2fs(ETC'\samba\spool\'printerqueue)
2702        ok = SysMkDir(ETC'\samba\spool\'printerqueue)
2703        call lineout smbconf, Indent||'comment = 'Printername
2704        call lineout smbconf, Indent||'create mask = 0700'
2705        call lineout smbconf, Indent||'printer name = 'printerqueue
2706        call lineout smbconf, Indent||'printing = os2'
2707        call lineout smbconf, Indent||'printable = Yes'
2708        call lineout smbconf, Indent||'print command = 'samba.!bin'\smbprint.exe "%s" "%p" "%J" "%c" "%z"'
2709        call lineout smbconf, Indent||'browseable = Yes'
2710        call lineout smbconf, Indent||'guest ok = Yes'
2711        call lineout smbconf, Indent||'read only = No'
2712        call lineout smbconf
2713        call _SmbConfTreeReset
2714        Msg.Text = NLVGetMessage(69)
2715        Msg.Type = 'I'
2716        call _ShowMsg
2717        ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!printers, "Collapsed", 0 )
2718        ok = VRMethod("CN_smbconf","SetRecordAttr",NewShareHandle, "Selected", 1 )
2719return
2720
2721/*:VRX         Menu_ShareContext_Remove_Click
2722*/
2723Menu_ShareContext_Remove_Click:
2724    call _SmbConfShareRemove
2725    if \Aborted then ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!dirs, "Collapsed", 0 )
2726return
2727
2728/*:VRX         Menu_ShareContext_RemovePrinter_Click
2729*/
2730Menu_ShareContext_RemovePrinter_Click:
2731    call _SmbConfShareRemove
2732    if \Aborted then ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!printers, "Collapsed", 0 )
2733return
2734
2735/*:VRX         Menu_ShareContext_Rename_Click
2736*/
2737Menu_ShareContext_Rename_Click:
2738    call _SmbConfShareRename
2739    if \Aborted then ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!dirs, "Collapsed", 0 )
2740return
2741
2742/*:VRX         Menu_ShareContext_RenamePrinter_Click
2743*/
2744Menu_ShareContext_RenamePrinter_Click:
2745    call _SmbConfShareRename
2746    if \Aborted then ok = VRMethod("CN_smbconf","SetRecordAttr",smbconf.!printers, "Collapsed", 0 )
2747return
2748
2749/*:VRX         PB_1_Click
2750*/
2751PB_1_Click:
2752    ok = VRREdirectStdIO("ON")
2753    Buttons.1 = NLVGetMessage(2)
2754    Buttons.2 = NLVGetMessage(3)
2755    Buttons.0 = 2
2756    command = 'd:\samba\smbpasswd.exe'
2757    id = VRPrompt( VRWindow(), "Console", "command", "Console", "Buttons.", buttons.1, buttons.2 )
2758    if id = 2 then return
2759    say command
2760    address cmd command
2761    /* samba.!netexe' rpc 'command' 'DebugLevel' 'UserCred' 2>'samba.!error' 1>'samba.!msg */
2762    /* if RC <> 0 then call _SambaShowError; else call _SambaShowMsg */
2763return
2764
2765/*:VRX         PB_AboutOK_Click
2766*/
2767PB_AboutOK_Click:
2768    call About_Close
2769return
2770
2771/*:VRX         PB_Add_Voc_Cancel_Click
2772*/
2773PB_Add_Voc_Cancel_Click:
2774    drop opt.
2775    ok = VRSet("DDCB_Add_Voc","Value","")
2776    ok = VRSet("EF_Add_Voc", "Value","")
2777
2778    ok = VRSet("DDCB_ADD_Voc","Visible",0)
2779    ok = VRSet("EF_ADD_Voc","Visible",0)
2780    ok = VRSet("PB_Add_Voc_OK","Visible",0)
2781    ok = VRSet("PB_add_Voc_Cancel","Visible",0)
2782return
2783
2784/*:VRX         PB_Add_Voc_OK_Click
2785*/
2786PB_Add_Voc_OK_Click:
2787    NewVoc = VRGet("DDCB_Add_Voc","Value")
2788    NewValue=VRGet("EF_Add_Voc", "Value")
2789    call IniSet NewVoc, NewValue, CurSection, samba.!smbconf
2790    drop opt.
2791    ok = VRSet("DDCB_Add_Voc","Value","")
2792    ok = VRSet("EF_Add_Voc", "Value","")
2793    ok = VRSet("DDCB_ADD_Voc","Visible",0)
2794    ok = VRSet("EF_ADD_Voc","Visible",0)
2795    ok = VRSet("PB_Add_Voc_OK","Visible",0)
2796    ok = VRSet("PB_add_Voc_Cancel","Visible",0)
2797
2798    call Menu_Options_SimpleMode_Click
2799return
2800
2801/*:VRX         PB_Cancel_Click
2802*/
2803PB_Cancel_Click:
2804    IF options.!debug == 1 THEN say 'PB_Cancel_Click() started'   
2805    if VRGet("PB_Save","Enabled") then call PB_Save_Click
2806'pause'
2807    call Quit
2808    IF options.!debug == 1 THEN say 'PB_Cancel_Click() done'   
2809return
2810
2811/*:VRX         PB_Help_Click
2812*/
2813PB_Help_Click:
2814
2815return
2816
2817/*:VRX         PB_Install_Default_Click
2818*/
2819PB_Install_Default_Click:
2820    if VRGet("EF_Workgroup_Initial","Value") = "" then return
2821
2822    if \VRGet("CB_NoRoot","Set") then do
2823        if \_SambaRootPWCheck() then return
2824    end
2825
2826    call _SmbConfCreateDefault
2827    /* call _Smb35Init */
2828    ok = SysFileTree(smbconf,exist.,'FO')
2829    SmbConfExists = exist.0
2830    call _SmbConfBackup
2831    call _SmbConfTreeReset
2832
2833    if \VRGet("CB_NoRoot","Set") then do
2834        call _SambaRootPWSet
2835    end
2836    call _SambaGuestCreate
2837
2838    call _SambaUserCreate
2839    ok = VRSet("Main", 'Pointer', 'WAIT' )
2840    call _SambaGroupMapInst
2841    ok = VRSet("Main", 'Pointer', '<default>' )
2842    /* call Menu_File_ImportHosts_Click */
2843
2844    call Installer_Close
2845return
2846
2847/*:VRX         PB_Install_Migration_Click
2848*/
2849PB_Install_Migration_Click:
2850    if VRGet("EF_Workgroup_Initial","Value") = "" then return
2851
2852    if \VRGet("CB_NoRoot","Set") then do
2853        if \_SambaRootPWCheck() then return
2854    end
2855
2856
2857    call _SmbConfMigratePeer
2858    ok = SysFileTree(smbconf,exist.,'FO')
2859    SmbConfExists = exist.0
2860    call _SmbConfBackup
2861    call _SmbConfTreeReset
2862    if \VRGet("CB_NoRoot","Set") then do
2863        call _SambaRootPWSet
2864    end
2865    call _SambaGuestCreate
2866
2867    call _SambaUserCreate
2868    ok = VRSet("Main", 'Pointer', 'WAIT' )
2869    call _SambaGroupMapInst
2870    ok = VRSet("Main", 'Pointer', '<default>' )
2871
2872/*  call Menu_File_ImportHosts_Click */
2873
2874    call Installer_Close
2875return
2876
2877/*:VRX         PB_Printer_Abort_Click
2878*/
2879PB_Printer_Abort_Click:
2880    call PrinterSelection_Close
2881return
2882
2883/*:VRX         PB_Printer_OK_Click
2884*/
2885PB_Printer_OK_Click:
2886    SharePrinter = RawPrinter(VRGet("LB_Printers","SelectedString"))
2887    AbortPrinter = 0
2888    say SharePrinter
2889    call PrinterSelection_Close
2890return
2891
2892RawPrinter:
2893    do I = 1 to printer.0 until PurePrinter(printer.I) = arg(1)
2894    end
2895return printer.I
2896/*:VRX         PB_Reload_Click
2897*/
2898PB_Reload_Click:
2899    call PB_Save_Click   
2900    call beep 960, 1
2901    address CMD samba.!smbcmd' reload'
2902return
2903
2904/*:VRX         PB_RemoveContinue_Click
2905*/
2906PB_RemoveContinue_Click:
2907
2908    if VRGet("CB_RemoveSmbConf","set") then do
2909        ok = SysFileDelete(samba.!smbconf)
2910        SmbConfExists = 0
2911        Installmode = 1
2912    end
2913    else Installmode = 0
2914
2915    if VRGet("CB_RemoveBackend","set") then do
2916        ok = SysFileTree(ETC"\samba\*.?db",xdb.,'FOS')
2917        do I = 1 to xdb.0
2918            ok = SysFileDelete(xdb.I)
2919            if ok <> 0 then do
2920                Msg.Text = "Error "ok" deleting "xdb.I"!"
2921                Msg.Type = "W"
2922                call _ShowMsg
2923            end
2924        end
2925    end
2926    if VRGet("CB_RemoveLMHosts","set") then do
2927        call _LMHostsImport
2928    end
2929
2930    call RemoveConfig_Close
2931return
2932
2933/*:VRX         PB_Save_Click
2934*/
2935PB_Save_Click:
2936    IF options.!debug == 1 THEN say 'PB_Save_Click() started'
2937    if ValueChanged then do
2938        if CurSection <> "" then do
2939            call _SaveChanges
2940            ok = VRSet("PB_Save", "Enabled", 0)
2941            call CN_smbconf_Click
2942        end
2943    end
2944    IF options.!debug == 1 THEN say 'PB_Save_Click() done'
2945return
2946
2947/*:VRX         PB_StartStop_Click
2948*/
2949PB_StartStop_Click:
2950    call PB_Save_Click   
2951    call beep 960, 1
2952    address CMD samba.!smbcmd' reload'
2953return
2954
2955/*:VRX         PB_Undo_Click
2956*/
2957PB_Undo_Click:
2958    call _SmbConfRestore
2959    SmbConfExists = 1
2960    call _SmbConfTreeReset   
2961return
2962
2963/*:VRX         PrinterSelection_Close
2964*/
2965PrinterSelection_Close:
2966    call PrinterSelection_Fini
2967return
2968
2969/*:VRX         PrinterSelection_Create
2970*/
2971PrinterSelection_Create:
2972    call PrinterSelection_Init
2973    ok = VRMethod( "Application", "ListPrinters", "printer." )
2974
2975    CALL NLVSetText 'Printerselection',     'Caption', 40
2976    CALL NLVSetText 'PB_Printer_OK',        'Caption',  2
2977    CALL NLVSetText 'PB_Printer_Abort',     'Caption',  3
2978
2979    do I = 1 to printer.0
2980        ok = VRMethod("LB_Printers","AddString",PurePrinter(printer.I))
2981        if PurePrinter(printer.!default) = PurePrinter(printer.I) then ok = VRSet("LB_Printers","Selected",I)
2982    end
2983return
2984/*:VRX         PrinterSelection_Fini
2985*/
2986PrinterSelection_Fini:
2987    window = VRInfo( "Window" )
2988    call VRDestroy window
2989    drop window
2990return
2991/*:VRX         PrinterSelection_Init
2992*/
2993PrinterSelection_Init:
2994    window = VRInfo( "Object" )
2995    if( \VRIsChildOf( window, "Notebook" ) ) then do
2996        call VRMethod window, "CenterWindow"
2997        call VRSet window, "Visible", 1
2998        call VRMethod window, "Activate"
2999    end
3000    drop window
3001return
3002
3003/*:VRX         PurePrinter
3004*/
3005PurePrinter:
3006return substr(arg(1),1,pos(';',arg(1))-1)
3007
3008/*:VRX         Quit
3009*/
3010Quit:
3011    IF options.!debug == 1 THEN say "Quit() start"
3012
3013    if VRGet("Main","WindowState") = "Maximized"|,
3014       VRGet("Main","WindowState") = "Minimized" then ok = VRMethod("Main", "Restore")
3015
3016    if samba.!testparmexe <> "" then do
3017        address cmd samba.!testparmexe' -s 1>'TempDir'smb.conf 2>'TempDir'sscc.testparm'
3018        call _SmbConfCommitChanges
3019    end
3020
3021    call _INIWrite
3022    call _SambaFinish
3023    ok = SysFileDelete(TempDir'sscc.testparm')
3024    ok = SysFileDelete(smboutput)
3025
3026    IF options.!debug == 1 THEN say "Quit() done"
3027    /* ok = VRRedirectStdio('OFF') */
3028    window = VRWindow()
3029    call VRSet window, "Shutdown", 1
3030    drop window
3031return
3032
3033/*:VRX         RB_PDC_Click
3034*/
3035RB_PDC_Click:
3036    CreatePDC = VRGet("RB_PDC","Set")
3037return
3038
3039/*:VRX         RB_smbpasswd_Click
3040*/
3041RB_smbpasswd_Click:
3042    UseTDBsam = 0
3043return
3044
3045/*:VRX         RB_Standalone_Click
3046*/
3047RB_Standalone_Click:
3048    CreatePDC = \VRGet("RB_Standalone","Set")
3049return
3050
3051/*:VRX         RB_tdbsam_Click
3052*/
3053RB_tdbsam_Click:
3054    UseTDBsam = 1
3055return
3056
3057/*:VRX         RemoveConfig_Close
3058*/
3059RemoveConfig_Close:
3060    call RemoveConfig_Fini
3061return
3062
3063/*:VRX         RemoveConfig_Create
3064*/
3065RemoveConfig_Create:
3066    call RemoveConfig_Init
3067    CALL NLVSetText 'RemoveConfig',                  'Caption', 90
3068    CALL NLVSetText 'PB_RemoveContinue',             'Caption', 14
3069
3070    ok = VRset("CB_RemoveSmbConf","Caption", NLVGetMessage(56, 'smb.conf'))
3071    ok = VRset("CB_RemoveBackend","Caption", NLVGetMessage(56, 'Backend'))
3072    ok = VRset("CB_RemoveLMHosts","Caption", NLVGetMessage(56, 'lmhosts'))
3073
3074    /* Check if ?db backend files exist */
3075    ok = SysFileTree(ETC"\samba\*.?db",xdb.,'FOS')
3076    if xdb.0 = 0 then ok = VRset("CB_RemoveBackend","Enabled", 0)
3077
3078    /* Check if LMHOsts exists */
3079    ok = VRset("CB_RemoveLMHosts","Enabled", VRFileExists(ETC'\samba\lmhosts'))
3080return
3081
3082/*:VRX         RemoveConfig_Fini
3083*/
3084RemoveConfig_Fini:
3085    window = VRInfo( "Window" )
3086    call VRDestroy window
3087    drop window
3088return
3089/*:VRX         RemoveConfig_Init
3090*/
3091RemoveConfig_Init:
3092    window = VRInfo( "Object" )
3093    if( \VRIsChildOf( window, "Notebook" ) ) then do
3094        call VRMethod window, "CenterWindow"
3095        call VRSet window, "Visible", 1
3096        call VRMethod window, "Activate"
3097    end
3098    drop window
3099return
3100
3101/*:VRX         TM_Installer_Trigger
3102*/
3103TM_Installer_Trigger:
3104    call _InstallerMode
3105return
3106
3107/*:VRX         TM_Value_Trigger
3108*/
3109TM_Value_Trigger:
3110    say "TM_Value_Trigger started"
3111    ValueChanged = 0
3112    ok = VRSet("PB_Save", "Enabled", 0)
3113    ChangeList = ""
3114    ok = VRSet("TM_Value", "Enabled", 0)
3115    say "TM_Value_Trigger done"
3116return
Note: See TracBrowser for help on using the repository browser.