source: branches/guitools-1.0/install/sscc.vrx@ 574

Last change on this file since 574 was 574, checked in by Herwig Bauernfeind, 14 years ago

GUI-Tools: SSCC: Workgroup/Domain can be set during installation

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