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

Last change on this file since 521 was 490, checked in by Herwig Bauernfeind, 15 years ago

GUI-Tools: SSCC debuggingg code, SMBUsers 0.9.9 several fixes, rest

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