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

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

GUI-Tools: SSCC 1.0.0, SMBUsers 0.9.8 several fixes, rest

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