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

Last change on this file since 444 was 408, checked in by Herwig Bauernfeind, 16 years ago

GUI-Tools: SSCC 0.9.5, SMBUsers 0.9.6 several fixes

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