source: trunk/guitools/smbmon/smbmon.vrx@ 805

Last change on this file since 805 was 805, checked in by Herwig Bauernfeind, 12 years ago

SMBMon 2.5: Add zombie detection

File size: 82.4 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\trunk\guitools\shared\inittempdir.vrs
94#append U:\Develop\Samba\trunk\guitools\shared\sambainit.vrs
95#append U:\Develop\Samba\trunk\guitools\shared\nlv.vrs
96#append U:\Develop\Samba\trunk\guitools\shared\smbtree.vrs
97*/
98return
99/*:VRX _ColumnShow
100*/
101_ColumnShow:
102 userdata = VRGet(VRInfo("Object"),"Userdata")
103 parse var userdata Container '|' fieldh '|' VisStatus
104say userdata
105 ok = VRMethod(Container,"SetFieldAttr", fieldh, "Visible", \VisStatus )
106return
107
108/*:VRX _ColumnsMenu
109*/
110_ColumnsMenu:
111 Container = arg(1)
112 ok = VRMethod(Container, "GetFieldList", "Fields." )
113
114 do I = 1 to 14
115 R2I = right("0"||I,2)
116 if I <= fields.0 then do
117/* say "Columns_"||R2I' 'VRMethod(Container, "GetFieldAttr", fields.I, "Title" ) */
118 ok = VRset("Columns_"||R2I, "Visible", 1)
119 ok = VRset("Columns_"||R2I, "Caption", VRMethod(Container, "GetFieldAttr", fields.I, "Title" ))
120 ok = VRset("Columns_"||R2I, "Checked", VRMethod(Container, "GetFieldAttr", fields.I, "Visible" ))
121 ok = VRset("Columns_"||R2I, "Userdata", Container'|'fields.I'|'VRMethod(Container, "GetFieldAttr", fields.I, "Visible" ))
122 end
123 else ok = VRset("Columns_"||R2I, "Visible", 0)
124 end
125 ok = VRMethod( "Columns", "Popup", , , "", "" )
126return
127
128/*:VRX _ContainerInit
129*/
130_ContainerInit:
131 say '_ContainerInit() started.'
132
133 /* User */
134 UIconH = VRMethod( "CN_Users", "AddField", "Icon", NLVGetMessage(148) )
135 UsernameFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(131) )
136 GroupFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(132) )
137 UMachineFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(133) )
138 UIPAdrFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(147) )
139 UPIDFH = VRMethod( "CN_Users", "AddField", "String", NLVGetMessage(130) )
140
141 /* Files */
142 FIconH = VRMethod( "CN_Files", "AddField", "Icon", NLVGetMessage(148) )
143 FileFH = VRMethod( "CN_Files", "AddField", "String", NLVGetMessage(134) )
144 FUserFH = VRMethod( "CN_Files", "AddField", "String", NLVGetMessage(131) )
145 FPIDFH = VRMethod( "CN_Files", "AddField", "String", NLVGetMessage(130) )
146 DenyModeFH = VRMethod( "CN_Files", "AddField", "String", NLVGetMessage(135) )
147 TimeFH = VRMethod( "CN_Files", "AddField", "String", NLVGetMessage(136) )
148 DateFH = VRMethod( "CN_Files", "AddField", "String", NLVGetMessage(149) )
149 AccessFH = VRMethod( "CN_Files", "AddField", "String", NLVGetMessage(137) )
150 RWFH = VRMethod( "CN_Files", "AddField", "String", NLVGetMessage(138) )
151 OplockFH = VRMethod( "CN_Files", "AddField", "String", NLVGetMessage(139) )
152 UIDFH = VRMethod( "CN_Files", "AddField", "String", NLVGetMessage(140) )
153 SharePathFH= VRMethod( "CN_Files", "AddField", "String", NLVGetMessage(141) )
154 NameFH = VRMethod( "CN_Files", "AddField", "String", NLVGetMessage(142) )
155
156 /* service */
157 SIconH = VRMethod( "CN_Service", "AddField", "Icon", NLVGetMessage(148) )
158 SPIDFH = VRMethod( "CN_Service", "AddField", "String", NLVGetMessage(130) )
159 ServiceFH = VRMethod( "CN_Service", "AddField", "String", NLVGetMessage(143) )
160 SMachineFH = VRMethod( "CN_Service", "AddField", "String", NLVGetMessage(133) )
161 ConnectedFH= VRMethod( "CN_Service", "AddField", "String", NLVGetMessage(144) )
162
163 /* daemons */
164 DaemonFH = VRMethod( "CN_Daemons", "AddField", "String", NLVGetMessage(145) )
165 DStatusFH = VRMethod( "CN_Daemons", "AddField", "String", NLVGetMessage(146) )
166 DPidsFH = VRMethod( "CN_Daemons", "AddField", "String", NLVGetMessage(130) )
167
168 /* Browse tree */
169 WorkgroupFH= VRMethod( "CN_smbtree", "AddField", "String", NLVGetMessage(150) )
170 NBFH = VRMethod( "CN_smbtree", "AddField", "String", "NetBIOS name" )
171 IpFH = VRMethod( "CN_smbtree", "AddField", "String", NLVGetMessage(147) )
172 MBFH = VRMethod( "CN_smbtree", "AddField", "String", "DMB/LMB" )
173
174 OSFH = VRMethod( "CN_smbtree", "AddField", "String", "OS" )
175 /* VersionFH = VRMethod( "CN_SmbTree", "AddField", "String", "Version" ) */
176 CommentFH = VRMethod( "CN_smbtree", "AddField", "String", NLVGetMessage(151) )
177 MacFH = VRMethod( "CN_smbtree", "AddField", "String", "MAC" )
178
179 ok = VRMethod("CN_smbtree","SetfieldAttr",IPFH, "ReadOnly", 1)
180 ok = VRMethod("CN_smbtree","SetfieldAttr",NBFH, "ReadOnly", 1)
181 ok = VRMethod("CN_smbtree","SetfieldAttr",MBFH, "ReadOnly", 1)
182 ok = VRMethod("CN_smbtree","SetfieldAttr",WorkGroupFH,"ReadOnly", 1)
183 ok = VRMethod("CN_smbtree","SetfieldAttr",OSFH, "ReadOnly", 1)
184 ok = VRMethod("CN_smbtree","SetfieldAttr",MacFH, "ReadOnly", 1)
185
186
187 /* add records for the 3 daemons */
188 smbdHandle = VRMethod("CN_Daemons", "Addrecord",, ,"smbd.exe","$41")
189 ok = VRMethod("CN_Daemons", "SetFieldData", smbdHandle, DaemonFH, "smbd.exe")
190 nmbdHandle = VRMethod("CN_Daemons", "Addrecord", ,,"nmbd.exe","$41")
191 ok = VRMethod("CN_Daemons", "SetFieldData", nmbdHandle, DaemonFH, "nmbd.exe")
192 winbHandle = VRMethod("CN_Daemons", "Addrecord",, ,"winbindd.exe","$41")
193 ok = VRMethod("CN_Daemons", "SetFieldData", winbHandle, DaemonFH, "winbindd.exe")
194 ok = (stream(samba.!bin'\winbindd.exe','c','query exists') <> "")
195 ok = VRMethod("CN_Daemons", "SetRecordAttr", winbHandle, "Visible", ok)
196
197 ok = VRMethod("CN_Daemons","SetRecordAttr","All", "Collapsed", 0 )
198
199 say '_ContainerInit() done.'
200return
201/*:VRX _ContainerSort
202*/
203_ContainerSort:
204 ok = VRMethod( "LB_SortFields", "GetSelectedList", "SortFields." )
205 if Fields.0 = 0 then return
206 idx = SortFields.1
207 ok = VRset( Container, "DetailSort", Fields.idx )
208 ok = VRSet( Container, "Sort", SortOrder )
209 ok = VRMethod( Container, "SortRecords" )
210return
211
212/*:VRX _CreateSmbStarter
213*/
214_CreateSmbStarter:
215ok = SysFileDelete(samba.!bin'\smbstarter.cmd')
216call lineout samba.!bin'\smbstarter.cmd', '/* REXX */'
217call lineout samba.!bin'\smbstarter.cmd', 'signal on failure name CLEANUP'
218call lineout samba.!bin'\smbstarter.cmd', 'signal on halt name CLEANUP'
219call lineout samba.!bin'\smbstarter.cmd', 'signal on syntax name CLEANUP'
220call lineout samba.!bin'\smbstarter.cmd', 'say "Samba Server Starter"'
221call lineout samba.!bin'\smbstarter.cmd', 'address cmd "@echo off"'
222call lineout samba.!bin'\smbstarter.cmd', 'home:'
223call lineout samba.!bin'\smbstarter.cmd', 'select'
224call lineout samba.!bin'\smbstarter.cmd', 'when VRFileExists("smbstart") then do'
225call lineout samba.!bin'\smbstarter.cmd', 'say "Start"'
226call lineout samba.!bin'\smbstarter.cmd', 'address cmd "call 'samba.!bin'\smb.cmd start"'
227call lineout samba.!bin'\smbstarter.cmd', 'ok = SysFileDelete("smbstart")'
228call lineout samba.!bin'\smbstarter.cmd', 'end'
229call lineout samba.!bin'\smbstarter.cmd', 'when VRFileExists("smbstop") then do'
230call lineout samba.!bin'\smbstarter.cmd', 'say "Stop"'
231call lineout samba.!bin'\smbstarter.cmd', 'address cmd "call 'samba.!bin'\smb.cmd stop"'
232call lineout samba.!bin'\smbstarter.cmd', 'ok = SysFileDelete("smbstop")'
233call lineout samba.!bin'\smbstarter.cmd', 'end'
234call lineout samba.!bin'\smbstarter.cmd', 'when VRFileExists("restart") then do'
235call lineout samba.!bin'\smbstarter.cmd', 'say "Restart"'
236call lineout samba.!bin'\smbstarter.cmd', 'address cmd "call 'samba.!bin'\smb.cmd restart"'
237call lineout samba.!bin'\smbstarter.cmd', 'ok = SysFileDelete("restart")'
238call lineout samba.!bin'\smbstarter.cmd', 'end'
239call lineout samba.!bin'\smbstarter.cmd', 'when VRFileExists("reload") then do'
240call lineout samba.!bin'\smbstarter.cmd', 'say "Reload"'
241call lineout samba.!bin'\smbstarter.cmd', 'address cmd "call 'samba.!bin'\smb.cmd reload"'
242call lineout samba.!bin'\smbstarter.cmd', 'ok = SysFileDelete("reload")'
243call lineout samba.!bin'\smbstarter.cmd', 'end'
244call lineout samba.!bin'\smbstarter.cmd', 'when VRFileExists("quit") then do'
245call lineout samba.!bin'\smbstarter.cmd', 'say "Quit"'
246call lineout samba.!bin'\smbstarter.cmd', 'ok = SysFileDelete("quit")'
247call lineout samba.!bin'\smbstarter.cmd', 'signal cleanup'
248call lineout samba.!bin'\smbstarter.cmd', 'end'
249call lineout samba.!bin'\smbstarter.cmd', 'otherwise nop'
250call lineout samba.!bin'\smbstarter.cmd', 'end'
251call lineout samba.!bin'\smbstarter.cmd', 'ok = SysSleep(1)'
252call lineout samba.!bin'\smbstarter.cmd', 'signal home'
253call lineout samba.!bin'\smbstarter.cmd', 'cleanup:'
254call lineout samba.!bin'\smbstarter.cmd', 'say "Aborting..."'
255call lineout samba.!bin'\smbstarter.cmd', 'exit'
256ok = stream(samba.!bin'\smbstarter.cmd','c','close')
257
258Setup = 'NOPRINT=YES;DEFAULTVIEW=RUNNING;'||,
259 'EXENAME='samba.!bin'\smbstarter.cmd;'||,
260 'STARTUPDIR='samba.!bin';'||,
261 'TITLE=;'||,
262 'PROGTYPE=WINDOWABLEVIO;'||,
263 'MINIMIZED=YES;'||,
264 'VISIBLE=NO;'||,
265 'NOAUTOCLOSE=NO;'||,
266 'OBJECTID=<smbstarter>'
267
268rc = SysCreateObject('WPProgram', 'SMBSTARTER', '<WP_NOWHERE>', Setup, 'UPDATE' )
269If rc <> 1 Then Say ' > failed to create SMBSTARTER Object'
270else ok = SysOpenObject('<smbstarter>', 'DEFAULT', 1)
271
272
273return
274
275/*:VRX _GuessIcon
276*/
277_GuessIcon: procedure
278 text = arg(1)
279 select /* Printer guessing */
280 when pos('LJ',text) > 0 then res = '#65:PMWP.DLL'
281 when pos('LASER',text) > 0 then res = '#65:PMWP.DLL'
282 when pos('EPSON',text) > 0 then res = '#65:PMWP.DLL'
283 when pos('PRINT',text) > 0 then res = '#65:PMWP.DLL'
284 when pos('PRT',text) > 0 then res = '#65:PMWP.DLL'
285 when pos('CANON',text) > 0 then res = '#65:PMWP.DLL'
286 when pos('MINOLTA',text) > 0 then res = '#65:PMWP.DLL'
287 when pos('FAX',text) > 0 then res = '#65:PMWP.DLL'
288 when pos('LEXMARK',text) > 0 then res = '#65:PMWP.DLL'
289 when pos('IPC$',text) > 0 then res = '#59:PMWP.DLL'
290 otherwise res = "#34:PMWP.DLL"
291 end
292return res
293
294/*:VRX _GUIInit
295*/
296_GUIInit:
297 IF options.!debug == 1 then say time()' _GUIInit() started'
298
299 if datatype(Top) = 'NUM' then do
300 ok = VRset("Main","Top",Top)
301 ok = VRset("Main","Left",Left)
302 ok = VRset("Main","Width",Width)
303 ok = VRset("Main","Height",Height)
304 end
305
306 ok = VRSet("Main", "Font", Font.!Main)
307 ok = VRSet("DT_StatusBar","Font", Font.!Status)
308 ok = VRSet("SW_Users", "Font", Font.!Users)
309 ok = VRSet("SW_Files", "Font", Font.!Files)
310 ok = VRSet("SW_Service", "Font", Font.!Service)
311 ok = VRSet("SW_Daemons", "Font", Font.!Daemons)
312 ok = VRSet("SW_SMBTree", "Font", Font.!SMBTree)
313 ok = VRSet("SW_Settings", "Font", Font.!Settings)
314
315 ok = VRSet("CN_Users", "Font", Font.!Users)
316 ok = VRSet("CN_Files", "Font", Font.!Files)
317 ok = VRSet("CN_Service", "Font", Font.!Service)
318 ok = VRSet("CN_Daemons", "Font", Font.!Daemons)
319 ok = VRSet("CN_SMBTree", "Font", Font.!SMBTree)
320
321
322 Buttonwidth = VRMethod( "Screen", "PixelsToTwips", 32 )
323
324 ok = VRSet("SPIN_Intervall", "Value", Intervall)
325 ok = VRSet("SPIN_IntervallMin","Value", IntervallMin)
326 ok = VRSet("TM_Refresh","Delay", Intervall * 1000)
327
328 ok = VRSet("PB_START", "Enabled", VRFileExists(samba.!smbcmd))
329 ok = VRSet("PB_Restart","Enabled", VRFileExists(samba.!smbcmd))
330 ok = VRSet("PB_Reload", "Enabled", VRFileExists(samba.!smbcmd))
331
332 ok = VRSet("CN_Daemons", "View", DaemonView)
333 ok = VRSet("CN_smbtree", "View", TreeView)
334 ok = VRSet("CB_NoMsgBox", "Set", NoMsgBox)
335 ok = VRSet("CB_WPSStartStop", "Set", WPSStartStop)
336 ok = VRSet("CB_DetectZombies","Set", DetectZombies)
337
338 call _INILayoutRead "CN_Users"
339 call _INILayoutRead "CN_Files"
340 call _INILayoutRead "CN_Service"
341 call _INILayoutRead "CN_Daemons"
342 call _INILayoutRead "CN_smbtree"
343
344 ok = VRset("CN_DAEMONS", "MiniIcons", \advanced.!bigicons)
345 ok = VRset("CN_SMBTREE", "MiniIcons", \advanced.!bigicons)
346 ok = VRset("ContextMenu_Tree_MiniIcons", "Checked", \advanced.!bigicons)
347 ok = VRset("ContextMenu_Daemons_MiniIcons", "Checked", \advanced.!bigicons)
348 ok = VRSet("CB_Debug","set",options.!Debug)
349
350 if _ChkTempFreeSpace() < 262144 then do
351 Msg.Type = "W"
352 Msg.Text = NLVGetMessage(116, TempDir)
353 call _ShowMsg
354 end
355
356 /* Common margin around controls */
357 margin = ((VRGet("Main", "InteriorLeft") / 3) * 2) + 2
358
359 /* Statusbar */
360 ok = VRSet("DT_STATUSBAR","Caption", VRGet("Main", "HintText"))
361
362 call Main_Resize
363
364
365 ok = VRSet("Main", "Visible", 1)
366 IF options.!debug == 1 then say time()' _GUIInit() done'
367return
368
369/*:VRX _INILayoutRead
370*/
371_INILayoutRead:
372 Container = arg(1)
373 ok = VRMethod(Container, "GetFieldList", "Fields." )
374 Layout = VRGetIni( "Layout", Container, OurINI )
375 if Layout = "" then return
376 do I = 1 to Fields.0
377 ok = VRMethod(Container, "SetFieldAttr", fields.I,"Visible", substr(Layout,I,1))
378 end
379return
380
381/*:VRX _INILayoutWrite
382*/
383_INILayoutWrite:
384 Container = arg(1)
385 ok = VRMethod(Container, "GetFieldList", "Fields." )
386 Layout = ""
387 do I = 1 to fields.0
388 Layout = Layout||VRMethod(Container, "GetFieldAttr", fields.I, "Visible" )
389 end
390 ok = VRSetIni( "Layout", Container , Layout, OurINI, 'NoClose' )
391return
392
393/*:VRX _INIRead
394*/
395_INIRead:
396 IF options.!debug == 1 then say time()' _INIRead() started'
397
398 OurINI = strip(VRParseFileName(VRget("Application","Program"),'DP')'\SMBSTATUS.INI',,'\')
399 ok = SysFileTree(OurINI, INIFound.,'FO')
400 if INIFound.0 = 1 then OurINI = VRParseFileName(INIFound.1,'DPNE')
401 IF options.!debug == 1 then say ' OurINI='OurINI
402
403 Top = VRGetIni( "Pos", "Top", OurINI , 'NoClose')
404 Left = VRGetIni( "Pos", "Left", OurINI , 'NoClose')
405 Width = VRGetIni( "Pos", "Width", OurINI , 'NoClose')
406 Height= VRGetIni( "Pos", "Height", OurINI , 'NoClose')
407
408 Font.!Users = VRGetIni( "Fonts", "SW_USERS", OurINI , 'NoClose' )
409 Font.!Files = VRGetIni( "Fonts", "SW_FILES", OurINI , 'NoClose' )
410 Font.!Service = VRGetIni( "Fonts", "SW_SERVICE", OurINI , 'NoClose' )
411 Font.!Daemons = VRGetIni( "Fonts", "SW_DAEMONS", OurINI , 'NoClose' )
412 Font.!SMBTree = VRGetIni( "Fonts", "SW_SMBTREE", OurINI , 'NoClose' )
413 Font.!Settings= VRGetIni( "Fonts", "SW_SETTINGS", OurINI , 'NoClose' )
414 Font.!Main = VRGetIni( "Fonts", "Main", OurINI , 'NoClose' )
415 Font.!Status = VRGetIni( "Fonts", "Statusfont", OurINI , 'NoClose' )
416
417 if Font.!Users = "" then Font.!Users = "9.WarpSans"
418 if Font.!Files = "" then Font.!Files = "9.WarpSans"
419 if Font.!Service = "" then Font.!Service = "9.WarpSans"
420 if Font.!Daemons = "" then Font.!Daemons = "9.WarpSans"
421 if Font.!SMBTree = "" then Font.!SMBTree = "9.WarpSans"
422 if Font.!Settings = "" then Font.!Settings = "9.WarpSans"
423 if Font.!Main = "" then Font.!Main = "9.WarpSans"
424 if Font.!Status = "" then Font.!Status = "9.WarpSans"
425
426 Intervall = VRGetIni( "Settings", "Intervall", OurINI,'NoClose')
427 if Intervall = "" then Intervall = 60
428
429 IntervallMin = VRGetIni( "Settings", "IntervallMin", OurINI,'NoClose')
430 if IntervallMin = "" then IntervallMin = 180
431
432 CurrentPageNr = VRGetIni( "Settings", "CurrentPageNr", OurINI,'NoClose')
433 if CurrentPageNr = "" then CurrentPageNr = 4
434
435 DaemonView = VRGetIni( "Settings", "DaemonView", OurINI,'NoClose')
436 if DaemonView = "" then DaemonView = "Detail"
437
438 TreeView = VRGetIni( "Settings", "TreeView", OurINI,'NoClose')
439 if TreeView = "" then TreeView = "IconTree"
440
441 NoMsgBox = VRGetIni( "Settings", "NoMsgBox", OurINI,'NoClose')
442 if NoMsgBox = "" then NoMsgBox = 1
443
444 WPSStartStop = VRGetIni( "Settings", "WPSStartStop", OurINI,'NoClose')
445 if WPSStartStop = "" then WPSStartStop = 1
446
447 DetectZombies = VRGetIni( "Settings", "DetectZombies", OurINI,'NoClose')
448 if DetectZombies = "" then DetectZombies = 0
449
450 options.!debug = VRGetIni( "Options", "Debug", OurINI)
451 if options.!debug = "" then options.!debug = 0
452
453 if options.!Debug then ok = VRRedirectStdIO("ON")
454 else ok = VRRedirectStdIO("OFF")
455
456 advanced.!bigicons = VRGetIni( "Settings", "BigIcons", OurINI)
457 if advanced.!bigicons = "" then advanced.!bigicons = 0
458
459 /* For Browse page */
460 FirstRun = 1
461 /* For Users page in case connections.tdb is not initialised */
462 IgnoreSmbNoInit = 1
463
464 /* For Refresh tree display code */
465 RefreshMode =""
466
467 smbdpidhandle.0 = 0
468 nmbdpidhandle.0 = 0
469 winbpidhandle.0 = 0
470
471 prevsmbdct = 0
472 prevnmbdct = 0
473 prevwinbct = 0
474
475 smbdoutput = TempDir'smbd.out'
476 IF options.!debug == 1 then say time()' _INIRead() done'
477return
478
479/*:VRX _INIWrite
480*/
481_INIWrite:
482 say 'start _INIWrite()'
483 ok = VRSetIni( "Pos", "Top", VRGet("Main","Top"), OurINI, 'NoClose' )
484 ok = VRSetIni( "Pos", "Left", VRGet("Main","Left"), OurINI, 'NoClose' )
485 ok = VRSetIni( "Pos", "Width", VRGet("Main","Width"), OurINI, 'NoClose' )
486 ok = VRSetIni( "Pos", "Height", VRGet("Main","Height"), OurINI, 'NoClose' )
487
488 ok = VRSetIni( "Settings", "Intervall", VRGet("SPIN_Intervall","Value"),OurINI,'NoClose')
489 ok = VRSetIni( "Settings", "IntervallMin", VRGet("SPIN_IntervallMin","Value"),OurINI,'NoClose')
490 ok = VRSetIni( "Settings", "CurrentPageNr",CurrentPageNr, OurINI,'NoClose')
491 ok = VRSetIni( "Settings", "DaemonView", VRGet("CN_Daemons","View"), OurINI,'NoClose')
492 ok = VRSetIni( "Settings", "TreeView", VRGet("CN_smbtree","View"), OurINI,'NoClose')
493 ok = VRSetIni( "Settings", "NoMsgBox", NoMsgBox, OurINI,'NoClose')
494 ok = VRSetIni( "Settings", "WPSStartStop", WPSStartStop, OurINI,'NoClose')
495 ok = VRSetIni( "Settings", "BigIcons", \VRGet("CN_SMBTREE", "MiniIcons"),OurINI,'NoClose')
496 ok = VRSetIni( "Settings", "DetectZombies",DetectZombies, OurINI,'NoClose')
497
498 ok = VRSetIni( "Options", "Debug", options.!debug, OurINI, 'NoClose' )
499
500 call _INILayoutWrite "CN_Users"
501 call _INILayoutWrite "CN_Files"
502 call _INILayoutWrite "CN_Service"
503 call _INILayoutWrite "CN_Daemons"
504 call _INILayoutWrite "CN_smbtree"
505
506 if VRGet("CN_USERS", "Font") <> "<default>" then ok = VRSet("SW_USERS", "Font", VRGet("CN_USERS", "Font"))
507 if VRGet("CN_FILES", "Font") <> "<default>" then ok = VRSet("SW_FILES", "Font", VRGet("CN_FILES", "Font"))
508 if VRGet("CN_SERVICE", "Font") <> "<default>" then ok = VRSet("SW_SERVICE","Font", VRGet("CN_SERVICE","Font"))
509 if VRGet("CN_DAEMONS", "Font") <> "<default>" then ok = VRSet("SW_DAEMONS","Font", VRGet("CN_DAEMONS","Font"))
510 if VRGet("CN_SMBTREE", "Font") <> "<default>" then ok = VRSet("SW_SMBTREE","Font", VRGet("CN_SMBTREE","Font"))
511
512 ok = VRSetIni( "Fonts", "SW_USERS", VRGet("SW_USERS", "Font"), OurINI, 'NoClose' )
513 ok = VRSetIni( "Fonts", "SW_FILES", VRGet("SW_FILES", "Font"), OurINI, 'NoClose' )
514 ok = VRSetIni( "Fonts", "SW_SERVICE", VRGet("SW_SERVICE", "Font"), OurINI, 'NoClose' )
515 ok = VRSetIni( "Fonts", "SW_DAEMONS", VRGet("SW_DAEMONS", "Font"), OurINI, 'NoClose' )
516 ok = VRSetIni( "Fonts", "SW_SMBTREE", VRGet("SW_SMBTREE", "Font"), OurINI, 'NoClose' )
517 ok = VRSetIni( "Fonts", "SW_SETTINGS",VRGet("SW_SETTINGS","Font"), OurINI, 'NoClose' )
518 ok = VRSetIni( "Fonts", "Statusfont", VRGet("DT_StatusBar","Font"),OurINI, 'NoClose' )
519 ok = VRSetIni( "Fonts", "Main", VRGet("Main","Font"), OurINI )
520 say 'done _INIWrite()'
521return
522
523/*:VRX _LoadotherFuncs
524*/
525_LoadotherFuncs:
526 IF options.!debug == 1 then say time()' _LoadotherFuncs() started'
527 SIGNAL ON SYNTAX NAME DLLMissing
528
529 call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
530 call SysLoadFuncs
531
532 call RxFuncAdd 'PRLoadFuncs', 'PR1UTIL', 'PRLoadFuncs'
533 call PRLoadFuncs
534
535 SIGNAL OFF SYNTAX
536 IF options.!debug == 1 then say time()' _LoadotherFuncs() done'
537return
538
539DLLMissing:
540 Fatal = 1
541 call VRMessage 'Main', 'REXX function library 'strip(translate(word(sourceline(SIGL-1),4),' ',"',"))'.DLL is missing!', "EVFSGUI fatal error", "E"
542signal Quit
543/*:VRX _MsgYesNo
544*/
545_MsgYesNo:
546 say "_MsgYesNo() started"
547 buttons.0 = 2
548 buttons.1 = NLVGetMessage(6)
549 buttons.2 = NLVGetMessage(7)
550 default = 2
551 buttons.default = NLVGetMessage(7)
552 esc = 2
553 buttons.esc = NLVGetMessage(7)
554 RC = VRMessage( VRWindow(), Msg.Text, Msg.Title,"Q","buttons.",default, esc )
555 say "_MsgYesNo() done, answer "RC
556return RC
557
558/*:VRX _NLVSetup
559*/
560_NLVSetup:
561
562 Msg.Title = NLVGetMessage(1)
563 ok = VRSet("Main","helpFile", settings.!helpfile)
564
565 CALL NLVSetText 'PB_Refresh', 'Caption', 11
566 CALL NLVSetText 'PB_Cancel', 'Caption', 12
567 CALL NLVSetText 'PB_Help', 'Caption', 13
568 CALL NLVSetText 'PB_About', 'Caption', 14
569
570 CALL NLVSetText 'PB_Refresh', 'Hinttext', 51
571 CALL NLVSetText 'PB_Cancel', 'Hinttext', 54
572 CALL NLVSetText 'PB_Help', 'Hinttext', 52
573 CALL NLVSetText 'PB_About', 'Hinttext', 53
574
575/* CALL NLVSetText 'TAB_1', 'Userdata', 15
576 CALL NLVSetText 'TAB_2', 'Userdata', 16
577 CALL NLVSetText 'TAB_3', 'Userdata', 17
578 CALL NLVSetText 'TAB_4', 'Userdata', 18
579 CALL NLVSetText 'TAB_5', 'Userdata', 19
580 CALL NLVSetText 'TAB_6', 'Userdata', 24
581
582 CALL NLVSetText 'TAB_1', 'Hinttext', 55
583 CALL NLVSetText 'TAB_2', 'Hinttext', 56
584 CALL NLVSetText 'TAB_3', 'Hinttext', 57
585 CALL NLVSetText 'TAB_4', 'Hinttext', 58
586 CALL NLVSetText 'TAB_5', 'Hinttext', 59
587 CALL NLVSetText 'TAB_6', 'Hinttext', 60 */
588
589/* CALL NLVSetText 'Page_1', 'Hinttext', 55
590 CALL NLVSetText 'Page_2', 'Hinttext', 56
591 CALL NLVSetText 'Page_3', 'Hinttext', 57
592 CALL NLVSetText 'Page_4', 'Hinttext', 58
593 CALL NLVSetText 'Page_5', 'Hinttext', 59
594 CALL NLVSetText 'Page_6', 'Hinttext', 60 */
595
596 CALL NLVSetText 'DT_Refresh', 'Caption', 25
597 CALL NLVSetText 'DT_RefreshMin', 'Caption', 25
598 CALL NLVSetText 'DT_Intervall', 'Caption', 26
599 ok = VRSet("DT_IntervallMin", "Caption", NLVGetMessage(26)' 'NLVGetMessage(28))
600 CALL NLVSetText 'CB_NoMsgBox', 'Caption', 27
601 CALL NLVSetText 'CB_WPSSTARTSTOP', 'Caption', 29
602 CALL NLVSetText 'CB_DetectZombies','Caption', 30
603
604 CALL NLVSetText 'ContextMenu_Daemons_Sort', 'Caption', 35
605 CALL NLVSetText 'ContextMenu_Daemons_Ping', 'Caption', 32
606 CALL NLVSetText 'ContextMenu_Daemons_Details','Caption', 118
607 CALL NLVSetText 'ContextMenu_Daemons_Tree', 'Caption', 120
608
609 CALL NLVSetText 'ContextMenu_Files_Sort', 'Caption', 35
610
611 CALL NLVSetText 'ContextMenu_Service_Sort', 'Caption', 35
612 CALL NLVSetText 'ContextMenu_Service_CloseSHare', 'Caption', 70
613
614 CALL NLVSetText 'ContextMenu_Users_SendMsg', 'Caption', 80
615 CALL NLVSetText 'ContextMenu_Users_Sort', 'Caption', 35
616
617 CALL NLVSetText 'ContextMenu_Tree_SendMsg', 'Caption', 80
618 CALL NLVSetText 'ContextMenu_Tree_Sort', 'Caption', 35
619 CALL NLVSetText 'ContextMenu_Tree_Tree', 'Caption', 120
620 CALL NLVSetText 'ContextMenu_Tree_Details', 'Caption', 118
621return
622
623/*:VRX _Refresh
624*/
625_Refresh:
626 IF options.!debug == 1 then say time()' _Refresh() started'
627 ok = VRSet("TM_refresh","Enabled", 0)
628 SmbNoInit = 0
629
630 refreshoutput = TempDir'refresh.out'
631 refresherr = TempDir'refresh.err'
632
633 say ' 'samba.!smbd' -V --debuglevel=0 2>'refresherr' 1>'refreshoutput
634 address cmd samba.!smbd' -V --debuglevel=0 2>'refresherr' 1>'refreshoutput
635
636 SambaVer = "Samba "||strip(linein(refreshoutput))
637 say ' smbd.exe: "'SambaVer'"'
638 ok = stream(refreshoutput,'c','close')
639
640 say ' 'samba.!smbstatusexe' smbd 'DebugLevel' 2>'refresherr' 1>'refreshoutput
641 address cmd samba.!smbstatusexe' smbd 'DebugLevel' 2>'refresherr' 1>'refreshoutput
642
643 /* First line is usually empty */
644 Hdr = linein(refreshoutput)
645 SambaStVer = strip(linein(refreshoutput)) /* we can detect version mismatches here */
646 say ' smbstatus: "'SambaStVer'"'
647
648 select
649 when pos('not initialised',SambaStVer) > 0 then do
650 SambaVer = SambaVer||" (Init)"
651 SmbNoInit = 1
652 end
653 when translate(SambaStVer) <> translate(SambaVer) then SambaVer = SambaVer||" (Hybrid)"
654 otherwise nop
655 end
656
657 Ok = VRSet("Main", "Caption", SambaVer' - 'NLVGetMessage(146))
658
659 /* Active User */
660 Hdr1 = linein(refreshoutput)
661/* say ' 1:'hdr1 */
662 Hdr2 = linein(refreshoutput)
663/* say ' 2:'hdr2 */
664 Zeile = linein(refreshoutput)
665 say ' 'Zeile
666 if SmbNoInit then do
667 call lineout samba.!msg, SambaStVer
668 call lineout samba.!msg, Hdr1
669 call lineout samba.!msg, Hdr2
670 call lineout samba.!msg, Zeile
671 ok = stream(samba.!msg,'c','close')
672 if IgnoreSmbNoInit then do
673 call _SambaShowMsg
674 IgnoreSmbNoInit = 0
675 end
676 end
677
678 say ' SmbNoInit = 'SmbNoInit
679
680 /* Active users */
681 ok = VRSet("CN_Users","Painting", 0)
682 ok = VRMethod("CN_Users", "RemoveRecord", "ALL")
683 Username.0 = 0
684 IP.0 = 0
685 Group.0 = 0
686 I = 0
687 if \SmbNoInit then do
688 do while Zeile <> ''
689 parse var Zeile UPID Username Group Machine IP
690 I = I + 1
691 UPID.I = UPID
692 Username.I = Username
693 Group.I = Group
694 IP = strip(IP)
695 parse var IP '('IP.I')'
696 RecHandle = VRMethod("CN_Users", "Addrecord")
697 ok = VRMethod("CN_Users", "SetFieldData", RecHandle, UIconH, "$44", UPIDFH, UPID, UsernameFH, Username, GroupFH, Group, UMachineFH, Machine, UIPAdrFH, IP.I)
698 Zeile = linein(refreshoutput)
699 end
700 end
701 Username.0 = I
702 Group.0 = I
703 UPID.0 = I
704 ok = VRSet("CN_Users","Painting", 1)
705
706 /* Active Services */
707 Hdr = linein(refreshoutput)
708 Hdr = linein(refreshoutput)
709 I = 0
710 Zeile = linein(refreshoutput)
711 ok = VRSet("CN_Service","Painting", 0)
712 ok = VRMethod("CN_Service", "RemoveRecord", "ALL")
713 do while Zeile <> ''
714 parse var Zeile Service SPId Machine Connected
715 I = I + 1
716 SPid.I = SPid
717 Machine.I = Machine
718 Service.I = Service
719 Icon = _GuessIcon(Service.I)
720
721 Connected = strip(Connected)
722 T. = ""
723 parse var Connected T.WDay T.Month T.DoM T.TimeoD T.Year
724 Connected = T.TimeoD', 'T.WDay' 'T.DoM' 'T.Month' 'T.Year
725
726 RecHandle = VRMethod("CN_Service", "Addrecord")
727 ok = VRMethod("CN_Service", "SetFieldData", RecHandle, SIconH, Icon, ServiceFH, Service, SPIDFH, SPID, SMachineFH, Machine, ConnectedFH, Connected)
728 Zeile = linein(refreshoutput)
729 end
730 SPid.0 = I
731 Machine.0 = I
732 Service.0 = I
733
734 ok = VRSet("CN_Service","Painting", 1)
735
736 /* Open files */
737 Hdr = linein(refreshoutput)
738 Hdr = linein(refreshoutput)
739 Hdr = linein(refreshoutput)
740
741 Zeile = linein(refreshoutput)
742 ok = VRSet("CN_Files","Painting", 0)
743 ok = VRMethod("CN_Files", "RemoveRecord", "ALL")
744 File.0 = 0
745 FPID.0 = 0
746 do while Zeile <> ''
747 parse var Zeile FPid Uid DenyMode Access RW Oplock Sharepath Rest
748 TimeDate = right(rest,25)
749 Name = strip(left(Rest,max(length(Rest)-25),1))
750 I = I + 1
751 sharepath = strip(translate(left(sharepath,1))||translate(substr(SharePath,2),'\','/'),'T','\')
752 Username = UID
753 do J = 1 to UPID.0
754 if FPID = UPID.J then do
755 Username = Username.J
756 leave
757 end
758 end
759 File = SharePath||'\'||translate(Name,'\','/')
760 File.I = File
761 FPID.I = FPID
762 TimeDate = strip(TimeDate)
763 say Timedate
764 T. = ""
765 parse var TimeDate T.WDay T.Month T.DoM T.TimeoD T.Year
766 FileTime = T.TimeoD
767 FileDate = T.WDay' 'T.DoM' 'T.Month' 'T.Year
768 RecHandle = VRMethod("CN_Files", "Addrecord")
769 ok = VRMethod("CN_Files", "SetFieldData", RecHandle, FPidFH, FPid, FileFH, File, FUserFH, Username, UidFH, Uid, DenyModeFH, DenyMode, AccessFH, Access, RWFH, RW)
770 ok = VRMethod("CN_Files", "SetFieldData", RecHandle, FIconH, "$45", TimeFH, FileTime, DateFH, FileDate, OplockFH, Oplock, SharePathFH, Sharepath, NameFH, Name)
771 Zeile = linein(refreshoutput)
772 end
773 File.0 = I
774 FPID.0 = I
775
776 ok = stream(refreshoutput, 'c','close')
777 ok = SysFileDelete(refreshoutput)
778 ok = stream(refresherr, 'c','close')
779 ok = SysFileDelete(refreshouterr)
780
781 call _RefreshDaemons
782 ok = VRSet("CN_Files","Painting", 1)
783 if VRGet("Main", "WindowState") = "Minimized" then do
784 ok = VRSet("TM_Refresh","Delay", IntervallMin * 1000)
785 end
786 else do
787 ok = VRSet("TM_Refresh","Delay", Intervall * 1000)
788 end
789 ok = VRSet("TM_refresh","Enabled", 1)
790
791 IF options.!debug == 1 then say time()' _Refresh() done'
792return
793/*:VRX _RefreshDaemons
794*/
795_RefreshDaemons:
796 IF options.!debug == 1 then say time()' _RefreshDaemons() started'
797 ok = VRSet("TM_RefreshDaemons","Delay",3000)
798
799 ok = VRSet("CN_Daemons","Painting", 0 )
800 call VRSet VRWindow(), 'Pointer', 'Wait'
801
802 do I = 1 to smbdpidhandle.0
803 ok = VRMethod("CN_Daemons", "RemoveRecord", smbdpidhandle.I )
804 end
805
806 do I = 1 to nmbdpidhandle.0
807 ok = VRMethod("CN_Daemons", "RemoveRecord", nmbdpidhandle.I )
808 end
809
810 do I = 1 to winbpidhandle.0
811 ok = VRMethod("CN_Daemons", "RemoveRecord", winbpidhandle.I )
812 end
813
814 Running = _SambaRunning()
815
816 call VRSet VRWindow(), 'Pointer', '<default>'
817
818 smbdpids = pids.!smbd
819 nmbdpids = pids.!nmbd
820 winbpids = pids.!nmbd
821
822 smbdRunning = running.!smbd
823 nmbdRunning = running.!nmbd
824 winbRunning = running.!winb
825
826 if smbdRunning then do
827 ok = VRMethod("CN_Daemons", "SetFieldData", smbdHandle, DStatusFH, NLVGetMessage(40), DPidsFH, smbdpids)
828 ok = VRMethod("CN_Daemons", "SetRecordAttr", smbdHandle, "Icon", "$46")
829 smbdpidhandle.0 = words(smbdpids)
830 if options.!debug = 1 then do
831 if smbdpidhandle.0 > prevsmbdct then do
832 prevsmbdct = smbdpidhandle.0
833 call beep 880*1, 10
834 call beep 880*2, 10
835 call beep 880*4, 10
836 end
837 if smbdpidhandle.0 < prevsmbdct then do
838 prevsmbdct = smbdpidhandle.0
839 call beep 880*4, 10
840 call beep 880*2, 10
841 call beep 880*1, 10
842 end
843 end
844
845 do I = 1 to words(smbdpids)
846 Username = ""
847 do J = 1 to UPID.0
848 if UPID.J = word(smbdpids,I) then do
849 Username = ' 'Username.J
850 leave
851 end
852 end
853 smbdpidhandle.I = VRMethod( "CN_Daemons", "AddRecord", smbdhandle, , 'PID 'word(smbdpids,I)' ('d2x(word(smbdpids,I))'x)', "$48")
854 /* we ping all smbd.exe except the first one */
855 if DetectZombies = 1 & I > 1 then do
856 ok = VRSet("Main", 'Pointer', 'Wait' )
857 address cmd samba.!smbcontrolexe' 'word(smbdpids,I)' ping --timeout=2 --debuglevel=0 2>'samba.!error' 1>'samba.!msg
858 ok = VRSet("Main", 'Pointer', '<default>' )
859 response = linein(samba.!msg)
860 ok = stream(samba.!msg,'c','close')
861 if pos('PONG', response) = 0 then do /* we have a zombie */
862 ok = VRMethod( "CN_Daemons", "SetRecordAttr", smbdpidhandle.I,"Icon", "$49")
863 say " Found Zombie "word(smbdpids,I)
864 end
865 end
866 if Username <> "" then do
867 smbdpidhandle.I.user = VRMethod( "CN_Daemons", "AddRecord", smbdpidhandle.I, , Username, "$44")
868 do J = 1 to FPID.0
869 if FPID.J = word(smbdpids,I) then do
870 dummyHandle = VRMethod( "CN_Daemons", "AddRecord", smbdpidhandle.I.user, , File.J, "$45")
871 end
872 end
873 end
874 end
875 end
876 else do
877 ok = VRMethod("CN_Daemons", "SetFieldData", smbdHandle, DStatusFH, NLVGetMessage(41), DPidsFH, "")
878 ok = VRMethod("CN_Daemons", "SetRecordAttr", smbdHandle, "Icon", "$47")
879 if options.!debug = 1 then do
880 if prevsmbdct > 0 then do
881 prevsmbdct = 0
882 call beep 880*4, 10
883 call beep 880*2, 10
884 call beep 880*1, 10
885 end
886 end
887 end
888
889 if nmbdRunning then do
890 ok = VRMethod("CN_Daemons", "SetFieldData", nmbdHandle, DStatusFH, NLVGetMessage(40), DPidsFH, nmbdpids)
891 ok = VRMethod("CN_Daemons", "SetRecordAttr", nmbdHandle, "Icon", "$46")
892 nmbdpidhandle.0 = words(nmbdpids)
893 do I = 1 to words(nmbdpids)
894 nmbdpidhandle.I = VRMethod( "CN_Daemons", "AddRecord", nmbdhandle, , 'PID 'word(nmbdpids,I)' ('d2x(word(nmbdpids,I))'x)', "$48")
895 end
896 end
897 else do
898 ok = VRMethod("CN_Daemons", "SetFieldData", nmbdHandle, DStatusFH, NLVGetMessage(41), DPidsFH, "")
899 ok = VRMethod("CN_Daemons", "SetRecordAttr", nmbdHandle, "Icon", "$47")
900 end
901
902 if winbRunning then do
903 ok = VRMethod("CN_Daemons", "SetFieldData", winbHandle, DStatusFH, NLVGetMessage(40), DPidsFH, winbpids)
904 ok = VRMethod("CN_Daemons", "SetRecordAttr", winbHandle, "Icon", "$46")
905 winbpidhandle.0 = words(winbpids)
906 do I = 1 to words(winbpids)
907 winbpidhandle.I = VRMethod( "CN_Daemons", "AddRecord", winbhandle, , 'PID 'word(winbpids,I)' ('d2x(word(winbpids,I))'x)', "$48")
908 end
909 end
910 else do
911 ok = VRMethod("CN_Daemons", "SetFieldData", winbHandle, DStatusFH, NLVGetMessage(41), DPidsFH, "")
912 ok = VRMethod("CN_Daemons", "SetRecordAttr", winbHandle, "Icon", "$47")
913 end
914
915 if \(smbdrunning|nmbdrunning|winbrunning) then do
916 ok = VRSet("PB_START", "Enabled", 1)
917 ok = VRSet("PB_STOP", "Enabled", 0)
918 ok = VRSet("PB_ReStart","Enabled", 0)
919 ok = VRSet("PB_ReLoad", "Enabled", 0)
920 end
921 else do
922 ok = VRSet("PB_START", "Enabled", 0)
923 ok = VRSet("PB_STOP", "Enabled", 1)
924 ok = VRSet("PB_ReStart","Enabled", 1)
925 ok = VRSet("PB_ReLoad", "Enabled", 1)
926 end
927
928 ok = (stream(samba.!bin'\winbindd.exe','c','query exists') <> "")
929 ok = VRMethod("CN_Daemons", "SetRecordAttr", winbHandle, "Visible", ok)
930 ok = VRSet("CN_Daemons","Painting", 1 )
931 if Running then call _SambaUptime
932
933 IF options.!debug == 1 then say time()' _RefreshDaemons() done'
934return
935
936/*
937_pids: procedure
938 pongfile = arg(1)
939 pids = ''
940 do until lines(pongfile) = 0
941 pongline = linein(pongfile)
942 if word(Pongline,1) = 'PONG' then do
943 parse var pongline pong from tpid pid
944 pids = pids||pid', '
945 end
946 else pids = pids||pongline
947 end
948 pids = strip(strip(pids),,',')
949 ok = stream(pongfile,'c','close')
950 ok = SysFileDelete(pongfile)
951return pids
952 */
953
954/* pingout = 'ping.out'
955 '@smbcontrol -t 2 smbd ping -d 0 1>'pingout
956 if rc = 0 then smbdRunning = 1
957 ok = VRMethod("CN_Daemons", "SetFieldData", smbdHandle, DPidsFH, _pids(pingout))
958
959 '@smbcontrol -t 2 nmbd ping -d 0 1>'pingout
960 if rc = 0 then nmbdRunning = 1
961 ok = VRMethod("CN_Daemons", "SetFieldData", nmbdHandle, DPidsFH, _pids(pingout))
962
963 '@smbcontrol -t 1 winbindd ping -d 0 1>'pingout
964 if rc = 0 then winbRunning = 1
965 ok = VRMethod("CN_Daemons", "SetFieldData", winbHandle, DPidsFH, _pids(pingout))
966
967 ok = SysFileDelete(PingOut)
968*/
969/*:VRX _RefreshDaemonsDelay
970*/
971_RefreshDaemonsDelay:
972 IF options.!debug == 1 then say time()' _RefreshDaemonsDelay() started'
973 IF options.!debug == 1 then say " Old intervall = "VRGet("TM_RefreshDaemons","Delay")
974 ok = VRSet("TM_RefreshDaemons","Delay", 60000)
975 IF options.!debug == 1 then say " New Intervall = "VRGet("TM_RefreshDaemons","Delay")
976 IF options.!debug == 1 then say time()' _RefreshDaemonsDelay() done'
977return
978
979/*:VRX _SambaFindPIDfile
980*/
981_SambaFindPIDfile:
982 IF options.!debug == 1 then say time()' _SambaFindPIDfile() started'
983
984 ok = SysFileTree(ETC'\samba\pid\nmbd*pid',nmbdpid.,'FO')
985 if nmbdpid.0 = 1
986 then nmbdpidfile = nmbdpid.1;
987 else nmbdpidfile = ""
988
989 IF options.!debug == 1 then say " nmbdpidfile = "nmbdpidfile
990
991 IF options.!debug == 1 then say time()' _SambaFindPIDfile() done'
992return
993
994/*:VRX _SambaShowError
995*/
996_SambaShowError: procedure expose samba. settings. options.
997 I = 0
998 do while lines(samba.!error) <> 0
999 I = I + 1
1000 smberr.I = linein(samba.!error)
1001 end
1002 ok = stream(Samba.!error,"c","close")
1003 smberr.0 = I
1004 Buttons.1 = "OK" /* NLVGetMessage(2) */
1005 Buttons.0 = 1
1006 id = VRMessageStem( VRWindow(), "smberr.", VRGet("Main", "Caption") , "Error", "Buttons.", buttons.1, buttons.1 )
1007 ok = SysFileDelete(Samba.!error)
1008return
1009
1010/*:VRX _SambaShowMsg
1011*/
1012_SambaShowMsg: procedure expose samba. settings. options.
1013 say "SambaShowMsg started"
1014 skipWords = arg(1)
1015 skip.0 = words(skipWords)
1016 do J = 1 to skip.0
1017 skip.J = translate(word(skipWords,J))
1018 end
1019 I = 0
1020 do while lines(samba.!msg) <> 0
1021 msgline = linein(samba.!msg)
1022 SkipIt = 0
1023 do J = 1 to skip.0
1024 if pos(skip.J,translate(msgline)) > 0 then do
1025 skipit = 1
1026 leave
1027 end
1028 end
1029 if \SkipIt then do
1030 I = I + 1
1031 smbmsg.I = strip(MsgLine)
1032 end
1033 end
1034 ok = stream(Samba.!msg,"c","close")
1035 say " stream close "Samba.!msg" = "ok
1036 smbmsg.0 = I
1037 if smbmsg.0 > 0 then do
1038 Buttons.1 = "OK" /* NLVGetMessage(2) */
1039 Buttons.0 = 1
1040 id = VRMessageStem( VRWindow(), "smbmsg.", VRGet("Main", "Caption") , "I", "Buttons.", buttons.1, buttons.1 )
1041 end
1042 ok = SysFileDelete(Samba.!msg)
1043 say " Delete "Samba.!msg" = "ok
1044 say "SambaShowMsg done"
1045return
1046/*:VRX _SambaUptime
1047*/
1048_SambaUptime:
1049 IF options.!debug == 1 then say time()' _SambaUptime() started'
1050 call _SambaFindPIDfile
1051 if nmbdpidfile = "" then do
1052 ok = VRset("CN_Daemons", "Caption", NLVGetMessage(42)||" "||NLVGetMessage(41))
1053 return
1054 end
1055
1056 StartTime = SysGetFileDateTime(nmbdpidfile)
1057 if StartTime = -1 then return
1058
1059 NowTime = substr(date('S'),1,4)'-'substr(date('S'),5,2)'-'substr(date('S'),7,2)' 'time()
1060
1061 /* StartTime = "2007-12-31 00:00:00"
1062 NowTime = "2008-03-05 08:59:50" */
1063
1064 IF options.!debug == 1 then do
1065 say " Start Time ='"StartTime"'"
1066 say " Now Time ='"NowTime"'"
1067 end
1068
1069 doM.0 = 12
1070 doM.1 = 31; doM.2 = 28; doM.3 = 31; doM.4 = 30; doM.5 = 31; doM.6 = 30;
1071 doM.7 = 31; doM.8 = 31; doM.9 = 30; doM.10= 31; doM.11= 30; doM.12= 31
1072
1073 parse var StartTime sY'-'sM'-'sD' 'sH':'sMi':'sS
1074 parse var NowTime nY'-'nM'-'nD' 'nH':'nMi':'nS
1075
1076 if nY//4 = 0 & nY//400 <> 0 then doM.2 = 29
1077
1078 /* say doM.2 */
1079
1080 uY =nY-sY
1081 uM =nM-sM
1082 uD =nD-sD
1083 uH =nH-sH
1084 uMi=nMi-sMi
1085 uS =nS-sS
1086
1087
1088
1089 if uS < 0 then do; uMi= uMi- 1; uS = uS + 60; end
1090 if uMi< 0 then do; uH = uH - 1; uMi= uMi+ 60; end
1091 if uH < 0 then do; uD = uD - 1; uH = uH + 24; end
1092 if uD < 0 then do;
1093 /* uM = uM - 1; */
1094 if uM < 0 then uMx = uM + 12; else uMx = uM
1095 uD = uD + doM.uMx - 1;
1096 end
1097 if uM < 0 then do; uY = uY - 1; uM = uM + 12; end
1098
1099 /* say uY uM uD uH uMi uS */
1100
1101 UpTimeStr = ' 'NlvGetMessage(43)':'
1102 if uY <> 0 then UpTimeStr = UpTimeStr' 'uY' 'NlvGetMessage(44)
1103 if uM <> 0 then UpTimeStr = UpTimeStr' 'uM' 'NlvGetMessage(45)
1104 if uD <> 0 then UpTimeStr = UpTimeStr' 'uD' 'NlvGetMessage(46)
1105 if uH <> 0 then UpTimeStr = UpTimeStr' 'uH' 'NlvGetMessage(47)
1106 if uMi<> 0 then UpTimeStr = UpTimeStr' 'uMi' 'NlvGetMessage(48)
1107 if uS <> 0 | UpTimeStr = ' 'NlvGetMessage(43)':' then UpTimeStr = UpTimeStr' 'uS' 'NlvGetMessage(49)
1108
1109 ok = VRset("CN_Daemons", "Caption", UpTimeStr)
1110
1111 IF options.!debug == 1 then say time()' _SambaUptime() done'
1112return
1113
1114/*:VRX _SendMsg
1115*/
1116_SendMsg:
1117 Buttons.1 = NLVGetMessage( 2 )
1118 Buttons.2 = NLVGetMessage( 3 )
1119 Buttons.0 = 2
1120 Message = "Blurp!"
1121 id = VRPrompt( VRWindow(), NLVGetMessage( 85 , CurMachine), "Message", NLVGetMessage( 80 ), "Buttons.", buttons.1, buttons.2 )
1122
1123 MsgFile = SysTempFileName(TempDir'\smbmsg.'??? )
1124 call lineout MsgFile, Message
1125 ok = stream(MsgFile,'c','close')
1126say Message
1127 address cmd samba.!smbclientexe' --message='CurMachine' 'DebugLevel' <'MsgFile' 2>&1>'samba.!msg
1128 /* if rc <> 0 then call _SambaShowError; else */
1129 call _SambaShowMsg
1130 ok = SysFileDelete(MsgFile)
1131return
1132
1133/*:VRX _ShowMsg
1134*/
1135_ShowMsg:
1136 Buttons.1 = NLVGetMessage(2)
1137 Buttons.0 = 1
1138 id = VRMessage( VRWindow(), Msg.Text, Msg.Title, Msg.Type, "Buttons.", buttons.1, buttons.1 )
1139return
1140
1141/*:VRX _TabbedDialogSetup
1142*/
1143_TabbedDialogSetup:
1144 IF options.!debug == 1 THEN SAY time()' _TabbedDialogSetup started'
1145 w = VRLoad( "TDL_1", VRWindowPath(), "SW_DAEMONS" )
1146 ok = VRMethod( "TDL_1", "InsertPage", w,"+ "NLVGetMessage(18)" ")
1147
1148 w = VRLoad( "TDL_1", VRWindowPath(), "SW_SMBTREE" )
1149 ok = VRMethod( "TDL_1", "InsertPage", w,"+ "NLVGetMessage(19)" ")
1150
1151 w = VRLoad( "TDL_1", VRWindowPath(), "SW_USERS" )
1152 ok = VRMethod( "TDL_1", "InsertPage", w,"+ "NLVGetMessage(15)" ")
1153
1154 w = VRLoad( "TDL_1", VRWindowPath(), "SW_FILES" )
1155 ok = VRMethod( "TDL_1", "InsertPage", w,"+ "NLVGetMessage(16)" ")
1156
1157 w = VRLoad( "TDL_1", VRWindowPath(), "SW_SERVICE" )
1158 ok = VRMethod( "TDL_1", "InsertPage", w,"+ "NLVGetMessage(17)" ")
1159
1160 w = VRLoad( "TDL_1", VRWindowPath(), "SW_SETTINGS" )
1161 ok = VRMethod( "TDL_1", "InsertPage", w,"+ "NLVGetMessage(24)" ")
1162 IF options.!debug == 1 THEN SAY time()' _TabbedDialogSetup done'
1163return
1164
1165/*:VRX About_Close
1166*/
1167About_Close:
1168 call About_Fini
1169return
1170
1171/*:VRX About_Create
1172*/
1173About_Create:
1174 call About_Init
1175 ok = VRSet("About","Caption", NLVGetMessage(20))
1176 ok = VRSet("PB_AboutOK","Caption", NLVGetMessage(2))
1177 SambaTeam.0 = 9
1178 SambaTeam.1 = 'Silvan Scherrer'
1179 SambaTeam.2 = 'Herwig Bauernfeind'
1180 SambaTeam.3 = 'Vitali Pelenyov'
1181 SambaTeam.4 = 'Paul Smedley'
1182 SambaTeam.5 = 'Yuri Dario'
1183 SambaTeam.6 = 'Alex Taylor'
1184 SambaTeam.7 = 'Nikolay Kolosov'
1185 SambaTeam.8 = 'All the Samba people'
1186 SambaTeam.9 = 'All the netlabs people'
1187 ok = VRSet("About","Font", VRGet("SW_SETTINGS","Font"))
1188 ok = VRMethod("LB_SambaTeam","AddStringList", "SambaTeam." )
1189 ok = VRSet("DT_SambaTeam","Caption", NLVGetMessage(21))
1190 ok = VRSet("MLE_Version","Value", NLVGetMessage(1)||'0D0A'x||VRGet("Main", "Hinttext")||'0D0A'x||'0D0A'x||SambaVer)
1191return
1192
1193/*:VRX About_Fini
1194*/
1195About_Fini:
1196 window = VRInfo( "Window" )
1197 call VRDestroy window
1198 drop window
1199return
1200/*:VRX About_Init
1201*/
1202About_Init:
1203 window = VRInfo( "Object" )
1204 if( \VRIsChildOf( window, "Notebook" ) ) then do
1205 call VRMethod window, "CenterWindow"
1206 call VRSet window, "Visible", 1
1207 call VRMethod window, "Activate"
1208 end
1209 drop window
1210return
1211
1212/*:VRX Activate
1213*/
1214Activate:
1215 parse arg Nr
1216 /* call PushbackAll */
1217 CurrentPageNr = Nr
1218 /* ok = VRSet("PB_"Nr,"Font","9.WarpSans Bold") */
1219/* ok = VRSet("TAB_"Nr,"Top", TabTop-8)
1220 ok = VRSet("TAB_"Nr,"Left",TabWidth*(Nr-1)+PageLeft)
1221 ok = VRSet("TAB_"Nr,"PicturePath", "#1"||Nr||";#1"||Nr)
1222 ok = VRset("DT_PageName", "Caption", VRGet("TAB_"Nr, "UserData"))
1223 ok = VRSet("Page_"Nr,"Visible", 1)
1224 select
1225 when Nr = 1 then ok = VRSet("IPB_paper","PicturePath","#4;#4")
1226 when Nr = Pages then ok = VRSet("IPB_paper","PicturePath","#6;#6")
1227 otherwise ok = VRSet("IPB_paper","PicturePath","#5;#5")
1228 end */
1229return
1230
1231/*:VRX CB_Debug_Click
1232*/
1233CB_Debug_Click:
1234 options.!Debug = VRGet("CB_Debug","set")
1235 if options.!Debug then ok = VRREdirectStdIO("ON")
1236 else ok = VRREdirectStdIO("OFF")
1237return
1238
1239/*:VRX CB_DetectZombies_Click
1240*/
1241CB_DetectZombies_Click:
1242 DetectZombies = VRGet("CB_DetectZombies","set")
1243 say 'DetectZombies = "'DetectZombies'"'
1244return
1245
1246/*:VRX CB_NoMsgBox_Click
1247*/
1248CB_NoMsgBox_Click:
1249 NoMsgBox = VRGet("CB_NoMsgBox","set")
1250 say 'NoMsgBox = "'NoMsgBox'"'
1251return
1252
1253/*:VRX CB_WPSSTARTSTOP_Click
1254*/
1255CB_WPSSTARTSTOP_Click:
1256 WPSStartStop = VRGet("CB_WPSStartStop","set")
1257 say 'WPSStartStop = "'WPSStartStop'"'
1258return
1259
1260/*:VRX CN_Daemons_Click
1261*/
1262CN_Daemons_Click:
1263 IF options.!debug == 1 then say time()' CN_Daemons_Click() started'
1264 NowClickedRecord = VRInfo("Record")
1265 say " NowRecord = '"NowClickedRecord"'"
1266 say " LastRecord = '"LastClickedRecord"'"
1267 if NowClickedRecord <> LastClickedRecord then call _RefreshDaemonsDelay
1268 LastClickedRecord = NowClickedRecord
1269 IF options.!debug == 1 then say time()' CN_Daemons_Click() done'
1270return
1271
1272/*:VRX CN_Daemons_ContextMenu
1273*/
1274CN_Daemons_ContextMenu:
1275 if VRInfo("Top") < 400 & VRGet("CN_Daemons", "View") = "Detail" then call _ColumnsMenu "CN_Daemons"
1276 else do
1277 say " Record = '"VRInfo("Record")"'"
1278
1279 call _RefreshDaemonsDelay
1280 DRH = VRInfo("Record")
1281 DaemonName = ""
1282
1283 OH = VRInfo("Object")
1284 ok = VRset("ContextMenu_Daemons_Details", "Visible", 1 )
1285 ok = VRset("ContextMenu_Daemons_Tree", "Visible", 1 )
1286 ok = VRset("MItem_9", "Visible", 1 )
1287 ok = VRset("ContextMenu_Daemons_Sort", "Visible", 1 )
1288 ok = VRset("ContextMenu_Daemons_MiniIcons", "Visible", 1 )
1289 ok = VRset("MItem_13", "Visible", 1 )
1290 ok = VRset("ContextMenu_Daemons_Ping", "Visible", 1 )
1291 ok = VRset("ContextMenu_Daemons_KillPID", "Visible", 1 )
1292 ok = VRset("ContextMenu_Daemons_Start", "Visible", 1 )
1293 ok = VRset("ContextMenu_Daemons_Shutdown", "Visible", 1 )
1294
1295 if DRH <> "" then do
1296 DaemonName = VRMethod("CN_Daemons", "GetRecordAttr", DRH, "Caption")
1297 ok = VRset("ContextMenu_Daemons_Ping","Visible", 1 )
1298 end
1299
1300 select
1301 when Words(DaemonName) = 3 & pos("PID ",DaemonName) > 0 then do /* a child process with PID in name */
1302 DaemonName = word(DaemonName,2)
1303 ok = VRSet("ContextMenu_Daemons_KillPID", "Caption", NLVGetMessage( 38, DaemonName))
1304 ok = VRset("ContextMenu_Daemons_Start", "Visible", 0 )
1305 end
1306 when Words(DaemonName) = 1 & (pos("mbd.exe",Daemonname) > 0 | pos("winbindd.exe",Daemonname) > 0) then do /* on root process */
1307 parse var DaemonName DaemonName'.exe'
1308 if strip(VRMethod("CN_Daemons", "GetFieldData", DRH, DPidsFH)) <> "" then do
1309 ok = VRSet("ContextMenu_Daemons_Shutdown", "Caption", NLVGetMessage( 33, DaemonName))
1310 ok = VRset("ContextMenu_Daemons_KillPID", "Visible", 0 )
1311 ok = VRset("ContextMenu_Daemons_Start", "Visible", 0 )
1312 end
1313 end
1314 when pos("\", DaemonName) > 0 then do /* we are on a file */
1315 ok = VRset("MItem_13", "Visible", 0 )
1316 ok = VRset("ContextMenu_Daemons_Ping", "Visible", 0 )
1317 ok = VRset("ContextMenu_Daemons_KillPID", "Visible", 0 )
1318 ok = VRset("ContextMenu_Daemons_Start", "Visible", 0 )
1319 ok = VRset("ContextMenu_Daemons_Shutdown", "Visible", 0 )
1320 end
1321 otherwise do /* we are on a user */
1322 ok = VRset("MItem_13", "Visible", 0 )
1323 ok = VRset("ContextMenu_Daemons_Ping", "Visible", 0 )
1324 ok = VRset("ContextMenu_Daemons_KillPID", "Visible", 0 )
1325 ok = VRset("ContextMenu_Daemons_Start", "Visible", 0 )
1326 ok = VRset("ContextMenu_Daemons_Shutdown", "Visible", 0 )
1327 end
1328 end
1329 say ' Daemon is "'DaemonName'"'
1330 ok = VRMethod( "ContextMenu_Daemons", "Popup", , , "", "" )
1331 end
1332return
1333
1334/*:VRX CN_Files_ContextMenu
1335*/
1336CN_Files_ContextMenu:
1337 if VRInfo("Top") < 400 & VRGet("CN_Files", "View") = "Detail" then call _ColumnsMenu "CN_Files"
1338 else do
1339 RH = VRInfo("Record")
1340 OH = VRInfo("Object")
1341 if RH <> "" then do
1342 ok = VRMethod( "Contextmenu_Files", "Popup", , , "", "PositionOnItem" )
1343 end
1344 end
1345return
1346
1347/*:VRX CN_Service_ContextMenu
1348*/
1349CN_Service_ContextMenu:
1350 if VRInfo("Top") < 400 & VRGet("CN_Service", "View") = "Detail" then call _ColumnsMenu "CN_Service"
1351 else do
1352 ok = VRSet("TM_refresh","Enabled", 0)
1353 SRH = VRInfo("Record")
1354 OH = VRInfo("Object")
1355 if SRH <> "" then do
1356 Service = VRMethod("CN_Service", "GetFieldData", SRH, ServiceFH)
1357 say ' Service is "'Service'"'
1358 ok = VRMethod( "ContextMenu_Service", "Popup", , , "", "" )
1359 end
1360 end
1361return
1362
1363/*:VRX CN_smbtree_Click
1364*/
1365CN_smbtree_Click:
1366 rh = VRInfo('Record')
1367 if VRMethod( 'CN_SMBTREE', "ValidateRecord", rh) <> 1 then return
1368 userdata = VRMethod('CN_smbtree', 'GetRecordAttr', rh, 'UserData')
1369 parse var userdata . '|' userdata
1370 ok = VRset("Main","StatusText", userdata)
1371
1372
1373return
1374
1375/*:VRX CN_smbtree_ContextMenu
1376*/
1377CN_smbtree_ContextMenu:
1378 if VRInfo("Top") < 400 & VRGet("CN_smbtree", "View") = "Detail" then call _ColumnsMenu "CN_smbtree"
1379 else do
1380 RH = VRInfo("Record")
1381 if RH <> "" then do
1382 CurMachine = word(VRMethod( "CN_smbtree", "GetRecordAttr", RH, "Caption" ),1)
1383 ok = VRMethod( "Contextmenu_Tree", "Popup", , , "", "PositionOnItem" )
1384 end
1385 end
1386return
1387
1388/*:VRX CN_Users_ContextMenu
1389*/
1390CN_Users_ContextMenu:
1391 if VRInfo("Top") < 400 & VRGet("CN_users", "View") = "Detail" then call _ColumnsMenu "CN_users"
1392 else do
1393 RH = VRInfo("Record")
1394 OH = VRInfo("Object")
1395 if RH <> "" then do
1396 CurMachine = VRMethod( "CN_users", "GetFieldData", RH, UMachineFH )
1397 ok = VRMethod( "Contextmenu_Users", "Popup", , , "", "PositionOnItem" )
1398 end
1399 end
1400return
1401
1402/*:VRX Columns_01_Click
1403*/
1404Columns_01_Click:
1405 call _ColumnShow
1406return
1407
1408/*:VRX Columns_02_Click
1409*/
1410Columns_02_Click:
1411 call _ColumnShow
1412return
1413
1414/*:VRX Columns_03_Click
1415*/
1416Columns_03_Click:
1417 call _ColumnShow
1418return
1419
1420/*:VRX Columns_04_Click
1421*/
1422Columns_04_Click:
1423 call _ColumnShow
1424return
1425
1426/*:VRX Columns_05_Click
1427*/
1428Columns_05_Click:
1429 call _ColumnShow
1430return
1431
1432/*:VRX Columns_06_Click
1433*/
1434Columns_06_Click:
1435 call _ColumnShow
1436return
1437
1438/*:VRX Columns_07_Click
1439*/
1440Columns_07_Click:
1441 call _ColumnShow
1442return
1443
1444/*:VRX Columns_08_Click
1445*/
1446Columns_08_Click:
1447 call _ColumnShow
1448return
1449
1450/*:VRX Columns_09_Click
1451*/
1452Columns_09_Click:
1453 call _ColumnShow
1454return
1455
1456/*:VRX Columns_10_Click
1457*/
1458Columns_10_Click:
1459 call _ColumnShow
1460return
1461
1462/*:VRX Columns_11_Click
1463*/
1464Columns_11_Click:
1465 call _ColumnShow
1466return
1467
1468/*:VRX Columns_12_Click
1469*/
1470Columns_12_Click:
1471 call _ColumnShow
1472return
1473
1474/*:VRX Columns_13_Click
1475*/
1476Columns_13_Click:
1477 call _ColumnShow
1478return
1479
1480/*:VRX Columns_14_Click
1481*/
1482Columns_14_Click:
1483 call _ColumnShow
1484return
1485
1486/*:VRX ContextMenu_Daemons_Details_Click
1487*/
1488ContextMenu_Daemons_Details_Click:
1489 ok = VRset("CN_Daemons","View","Detail")
1490 ok = VRset("ContextMenu_Daemons_Tree","Enabled",1)
1491 ok = VRset("ContextMenu_Daemons_Details","Enabled",0)
1492 ok = VRSet("TM_refresh","Enabled", 1)
1493return
1494
1495/*:VRX ContextMenu_Daemons_KillPID_Click
1496*/
1497ContextMenu_Daemons_KillPID_Click:
1498 Msg.Text = NLVGetMessage(39, DaemonName)
1499 Msg.Type = 'Q'
1500 if _MsgYesNo() = 1 then do
1501 ok = PRKillProcess("1",DaemonName )
1502 if ok = 0 then say ", success!"; else say ", error "ok
1503
1504/* say 'kill -9 'DaemonName
1505 address cmd 'kill -9 'DaemonName */
1506 end
1507 ok = VRSet("TM_Refresh","Enabled", 1)
1508return
1509
1510/*:VRX ContextMenu_Daemons_MiniIcons_Click
1511*/
1512ContextMenu_Daemons_MiniIcons_Click:
1513 advanced.!bigicons = \advanced.!bigicons
1514 ok = VRset("CN_DAEMONS", "MiniIcons", \advanced.!bigicons)
1515 ok = VRset("CN_SMBTREE", "MiniIcons", \advanced.!bigicons)
1516 ok = VRset("ContextMenu_Tree_MiniIcons", "Checked", \advanced.!bigicons)
1517 ok = VRset("ContextMenu_Daemons_MiniIcons", "Checked", \advanced.!bigicons)
1518return
1519
1520/*:VRX ContextMenu_Daemons_Ping_Click
1521*/
1522ContextMenu_Daemons_Ping_Click:
1523 ok = VRSet("Main", 'Pointer', 'Wait' )
1524 address cmd samba.!smbcontrolexe' 'DaemonName' ping --timeout=3 --debuglevel=0 2>'samba.!error' 1>'samba.!msg
1525 call _SambaShowMsg "section table registered"
1526
1527 ok = VRSet("Main", 'Pointer', '<default>' )
1528 ok = VRSet("TM_refresh","Enabled", 1)
1529return
1530
1531/*:VRX ContextMenu_Daemons_Shutdown_Click
1532*/
1533ContextMenu_Daemons_Shutdown_Click:
1534 Msg.Text = NLVGetMessage(34, DaemonName)
1535 Msg.Type = 'Q'
1536 if _MsgYesNo() = 1 then do
1537 address cmd samba.!smbcontrolexe' 'DaemonName' shutdown 2>'samba.!error' 1>'samba.!msg
1538 call _SambaShowMsg "section table registered tdb"
1539 end
1540 ok = VRSet("TM_Refresh","Enabled", 1)
1541return
1542
1543/*:VRX ContextMenu_Daemons_Sort_Click
1544*/
1545ContextMenu_Daemons_Sort_Click:
1546 window = VRLoadSecondary( "SW_SORT", "W" )
1547return
1548
1549/*:VRX ContextMenu_Daemons_Start_Click
1550*/
1551ContextMenu_Daemons_Start_Click:
1552 Msg.Text = NLVGetMessage(37, DaemonName)
1553 Msg.Type = 'Q'
1554 if _MsgYesNo() = 1 then do
1555 say samba.!smbcmd' start 'DaemonName
1556 address cmd samba.!smbcmd' start 'DaemonName
1557 end
1558 ok = VRSet("TM_Refresh","Enabled", 1)
1559return
1560
1561/*:VRX ContextMenu_Daemons_Tree_Click
1562*/
1563ContextMenu_Daemons_Tree_Click:
1564 ok = VRset("CN_Daemons","View","IconTree")
1565 ok = VRset("ContextMenu_Daemons_Tree","Enabled",0)
1566 ok = VRset("ContextMenu_Daemons_Details","Enabled",1)
1567 ok = VRSet("TM_refresh","Enabled", 1)
1568return
1569
1570/*:VRX ContextMenu_Files_Sort_Click
1571*/
1572ContextMenu_Files_Sort_Click:
1573 window = VRLoadSecondary( "SW_SORT", "W" )
1574return
1575
1576/*:VRX ContextMenu_Service_CloseShare_Click
1577*/
1578ContextMenu_Service_CloseShare_Click:
1579 Msg.Text = NLVGetMessage(75, Service)
1580 Msg.Type = 'Q'
1581 if _MsgYesNo() = 1 then do
1582 address cmd samba.!smbcontrolexe' smbd close-share 'Service' --debuglevel=0' /* ' 2>'samba.!error' 1>'samba.!msg */
1583 /* No usable output from Samba here ! */
1584 /* call _SambaShowMsg */
1585 Msg.Text = NLVGetMessage(76, Service)
1586 Msg.Type = 'I'
1587 call _ShowMsg
1588 end
1589 ok = VRSet("TM_refresh","Enabled", 1)
1590return
1591
1592/*:VRX ContextMenu_Service_Sort_Click
1593*/
1594ContextMenu_Service_Sort_Click:
1595 window = VRLoadSecondary( "SW_SORT", "W" )
1596return
1597
1598/*:VRX ContextMenu_Tree_Details_Click
1599*/
1600ContextMenu_Tree_Details_Click:
1601 ok = VRset("CN_smbtree","View","Detail")
1602 ok = VRset("ContextMenu_Tree_Tree","Enabled",1)
1603 ok = VRset("ContextMenu_Tree_Details","Enabled",0)
1604 ok = VRset("ContextMenu_Tree_Icons","Enabled",1)
1605 ok = VRset("TM_Throbber", "Enabled", 1)
1606 ok = VRset("Pict_Throbber", "Visible", 0)
1607 call _RefreshTree
1608return
1609
1610/*:VRX ContextMenu_Tree_Icons_Click
1611*/
1612ContextMenu_Tree_Icons_Click:
1613 ok = VRset("CN_smbtree","View","Icon")
1614 ok = VRset("ContextMenu_Tree_Icons","Enabled",0)
1615 ok = VRset("ContextMenu_Tree_Tree","Enabled",1)
1616 ok = VRset("ContextMenu_Tree_Details","Enabled",1)
1617 ok = VRset("TM_Throbber", "Enabled", 1)
1618 ok = VRset("Pict_Throbber", "Visible", 1)
1619 call _RefreshTree
1620return
1621
1622/*:VRX ContextMenu_Tree_MiniIcons_Click
1623*/
1624ContextMenu_Tree_MiniIcons_Click:
1625 advanced.!bigicons = \advanced.!bigicons
1626 ok = VRset("CN_DAEMONS", "MiniIcons", \advanced.!bigicons)
1627 ok = VRset("CN_SMBTREE", "MiniIcons", \advanced.!bigicons)
1628 ok = VRset("ContextMenu_Tree_MiniIcons", "Checked", \advanced.!bigicons)
1629 ok = VRset("ContextMenu_Daemons_MiniIcons", "Checked", \advanced.!bigicons)
1630return
1631
1632/*:VRX ContextMenu_Tree_SendMsg_Click
1633*/
1634ContextMenu_Tree_SendMsg_Click:
1635 call _SendMsg
1636return
1637
1638/*:VRX ContextMenu_Tree_Sort_Click
1639*/
1640ContextMenu_Tree_Sort_Click:
1641 window = VRLoadSecondary( "SW_SORT", "W" )
1642return
1643
1644/*:VRX ContextMenu_Tree_Tree_Click
1645*/
1646ContextMenu_Tree_Tree_Click:
1647 ok = VRset("CN_smbtree","View","IconTree")
1648 ok = VRset("ContextMenu_Tree_Tree","Enabled",0)
1649 ok = VRset("ContextMenu_Tree_Details","Enabled",1)
1650 ok = VRset("ContextMenu_Tree_Icons","Enabled",1)
1651 ok = VRset("TM_Throbber", "Enabled", 1)
1652 ok = VRset("Pict_Throbber", "Visible", 1)
1653 call _RefreshTree
1654return
1655
1656/*:VRX ContextMenu_Users_SendMsg_Click
1657*/
1658ContextMenu_Users_SendMsg_Click:
1659 call _SendMsg
1660return
1661
1662/*:VRX ContextMenu_Users_Sort_Click
1663*/
1664ContextMenu_Users_Sort_Click:
1665 window = VRLoadSecondary( "SW_SORT", "W" )
1666return
1667
1668/*:VRX DT_STATUSBAR_ContextMenu
1669*/
1670DT_STATUSBAR_ContextMenu:
1671 ok = VRSet("DT_STATUSBAR","Caption", VRGet("Main", "HintText"))
1672return
1673
1674/*:VRX Fini
1675*/
1676Fini:
1677 window = VRWindow()
1678 call VRSet window, "Visible", 0
1679 drop window
1680return 0
1681
1682/*:VRX GetBootDrive
1683*/
1684GetBootDrive:
1685/* Use SysBootDrive if possible */
1686If Rxfuncadd('SysBootDrive', 'RexxUtil', 'SysBootDrive') Then
1687 Return Left(Value('RUNWORKPLACE',,'OS2ENVIRONMENT'),2)
1688Else
1689 Return SysBootDrive()
1690
1691
1692/*:VRX Halt
1693*/
1694Halt:
1695 signal _VREHalt
1696return
1697
1698/*:VRX Init
1699*/
1700Init:
1701window = VRWindow()
1702call VRMethod window, "CenterWindow"
1703call VRSet window, "Visible", 0
1704call VRMethod window, "Activate"
1705drop window
1706return
1707
1708/*:VRX LB_SortFields_Click
1709*/
1710LB_SortFields_Click:
1711 call _ContainerSort
1712return
1713
1714/*:VRX Main_Activate
1715*/
1716Main_Activate:
1717 call TM_Refresh_Trigger
1718 ok = VRset("TM_Refresh", "Enabled", 1)
1719return
1720
1721/*:VRX Main_Close
1722*/
1723Main_Close:
1724 call Quit
1725return
1726
1727/*:VRX Main_Create
1728*/
1729Main_Create:
1730 options.!debug = 1
1731 if options.!debug == 1 then do
1732 ok = VRRedirectStdIO("ON")
1733 say time()' Main_Create started'
1734 end
1735 else ok = VRRedirectStdIO("OFF")
1736
1737 call _LoadOtherFuncs
1738 call _InitTempDir
1739
1740 call _IniRead
1741 call NLVSetup
1742
1743 call _TabbeddialogSetup
1744 call _NLVSetup
1745 call _SambaInit
1746 if \WPSStartStop then call _CreateSmbStarter
1747 if _SambaRunning() then call _SambaFindPIDfile
1748 call _ContainerInit
1749 call _GUIInit
1750
1751/* str = 'call TAB_'CurrentPageNr'_Click';
1752say str
1753interpret str
1754say 'Done 'str
1755 if CurrentPageNr <> 5 then do
1756 ok = VRSet("TM_Throbber", "Enabled", 1)
1757 call _RefreshTree
1758 end */
1759 ok = VRMethod("PB_Refresh","SetFocus")
1760
1761 if options.!debug == 1 then say time()' Main_Create done'
1762return
1763/*:VRX Main_Deactivate
1764*/
1765Main_Deactivate:
1766 ok = VRset("TM_Refresh", "Enabled", 0)
1767return
1768
1769/*:VRX Main_Resize
1770*/
1771Main_Resize:
1772 IF options.!debug == 1 THEN SAY time()' Main_Resize started'
1773 ok = VRSet("Main","Painting", 0)
1774
1775 /* Basic measurements */
1776 main_iwidth = VRGet("Main","InteriorWidth") /* Width of window client-area */
1777 main_iheight = VRGet("Main","InteriorHeight") /* Height of window client-area */
1778
1779 /* if main_iheight < 5500 then ok = VRSet("Main","Height",6200) */
1780 sbar_height = 209 /* Height of status-bar */
1781 marginx2 = margin * 2 /* Common margin around controls */
1782
1783 pbtn_dist = 980
1784 pbtn_nr = 4
1785 pbtn_pos = max((main_iwidth - pbtn_Dist * pbtn_Nr)%2, 0)+ margin
1786 pbtn_height = 400 /* Height of the panels' internal button areas */
1787 pbtn_width = 940
1788
1789 pane_height = main_iheight- sbar_height - pbtn_height - margin * 7 /* Height of notebook */
1790 pane_width = main_iwidth - marginx2 /* Width of the notebook panel */
1791
1792 /* Tabbed Dialog */
1793 ok = VRset("TDL_1", "Top", marginx2 )
1794 ok = VRset("TDL_1", "Left", margin )
1795 ok = VRset("TDL_1", "Width", pane_width )
1796 ok = VRset("TDL_1", "Height", pane_height )
1797
1798 /* Statusbar */
1799 ok = VRSet("GB_STATUSBAR", "Left", margin )
1800 ok = VRSet("GB_STATUSBAR", "Top", main_iheight - sbar_height - margin )
1801 ok = VRSet("GB_STATUSBAR", "Height",sbar_height )
1802 ok = VRSet("GB_STATUSBAR", "Width", pane_width )
1803
1804 ok = VRSet("DT_STATUSBAR", "Top", 12 )
1805 ok = VRSet("DT_STATUSBAR", "Left", 12 )
1806 ok = VRSet("DT_STATUSBAR", "Height",sbar_height- 24)
1807 ok = VRSet("DT_STATUSBAR", "Width", pane_width - 24)
1808
1809 ok = VRSet("PB_Refresh","top", pane_height + margin * 4 )
1810 ok = VRSet("PB_Help", "top", pane_height + margin * 4 )
1811 ok = VRSet("PB_Cancel", "top", pane_height + margin * 4 )
1812 ok = VRSet("PB_About", "top", pane_height + margin * 4 )
1813
1814 ok = VRSet("PB_Refresh","left",pbtn_pos + pbtn_dist * (pbtn_nr - 4))
1815 ok = VRSet("PB_Help", "left",pbtn_pos + pbtn_dist * (pbtn_nr - 3))
1816 ok = VRSet("PB_About", "left",pbtn_pos + pbtn_dist * (pbtn_nr - 2))
1817 ok = VRSet("PB_Cancel", "left",pbtn_pos + pbtn_dist * (pbtn_nr - 1))
1818
1819 ok = VRset("GB_USERS","Top", margin )
1820 ok = VRset("GB_USERS","Left", marginx2)
1821 ok = VRset("GB_USERS","Width", pane_width - 760)
1822 ok = VRset("GB_USERS","Height", pane_height- 1020)
1823 ok = VRset("CN_USERS","Top", margin)
1824 ok = VRset("CN_USERS","Left", margin)
1825 ok = VRset("CN_USERS","Width", pane_width - 760 - marginx2 )
1826 ok = VRset("CN_USERS","Height", pane_height- 1020- marginx2 )
1827
1828 ok = VRset("GB_FILES","Top", margin )
1829 ok = VRset("GB_FILES","Left", marginx2)
1830 ok = VRset("GB_FILES","Width", pane_width - 760)
1831 ok = VRset("GB_FILES","Height", pane_height- 1020)
1832 ok = VRset("CN_FILES","Top", margin)
1833 ok = VRset("CN_FILES","Left", margin)
1834 ok = VRset("CN_FILES","Width", pane_width - 760 - marginx2 )
1835 ok = VRset("CN_FILES","Height", pane_height- 1020- marginx2 )
1836
1837 ok = VRset("GB_SERVICE","Top", margin )
1838 ok = VRset("GB_SERVICE","Left", marginx2)
1839 ok = VRset("GB_SERVICE","Width", pane_width - 760)
1840 ok = VRset("GB_SERVICE","Height", pane_height- 1020)
1841 ok = VRset("CN_SERVICE","Top", margin)
1842 ok = VRset("CN_SERVICE","Left", margin)
1843 ok = VRset("CN_SERVICE","Width", pane_width - 760 - marginx2 )
1844 ok = VRset("CN_SERVICE","Height", pane_height- 1020- marginx2 )
1845
1846 ok = VRset("GB_DAEMONS","Top", margin )
1847 ok = VRset("GB_DAEMONS","Left", marginx2)
1848 ok = VRset("GB_DAEMONS","Width", pane_width - 760)
1849 ok = VRset("GB_DAEMONS","Height", pane_height- 1020)
1850 ok = VRset("CN_DAEMONS","Top", margin)
1851 ok = VRset("CN_DAEMONS","Left", margin)
1852 ok = VRset("CN_DAEMONS","Width", pane_width - 760 - margin*4 - pbtn_width)
1853 ok = VRset("CN_DAEMONS","Height", pane_height- 1020 - marginx2 )
1854
1855 ok = VRSet("PB_START", "Top", pbtn_height*2 - marginx2)
1856 ok = VRSet("PB_STOP", "Top", pbtn_height*3 - marginx2)
1857 ok = VRSet("PB_Restart","Top", pbtn_height*4 - marginx2)
1858 ok = VRSet("PB_Reload", "Top", pbtn_height*5 - marginx2)
1859 ok = VRSet("PB_DelLogs","Top", pbtn_height*6 - marginx2)
1860
1861 ok = VRSet("PB_START", "Left", pane_width - 760 - marginx2 - pbtn_width)
1862 ok = VRSet("PB_STOP", "Left", pane_width - 760 - marginx2 - pbtn_width)
1863 ok = VRSet("PB_Restart","Left", pane_width - 760 - marginx2 - pbtn_width)
1864 ok = VRSet("PB_Reload", "Left", pane_width - 760 - marginx2 - pbtn_width)
1865 ok = VRSet("PB_DelLogs","Left", pane_width - 760 - marginx2 - pbtn_width)
1866
1867 ok = VRset("GB_SMBTREE","Top", margin )
1868 ok = VRset("GB_SMBTREE","Left", marginx2)
1869 ok = VRset("GB_SMBTREE","Width", pane_width - 760)
1870 ok = VRset("GB_SMBTREE","Height", pane_height- 1020)
1871 ok = VRset("CN_SMBTREE","Top", margin)
1872 ok = VRset("CN_SMBTREE","Left", margin)
1873 ok = VRset("CN_SMBTREE","Width", pane_width - 760 - marginx2 )
1874 ok = VRset("CN_SMBTREE","Height", pane_height- 1020- marginx2 )
1875
1876 ok = VRset("PICT_THROBBER", "Top", VRGet("CN_SMBTREE","Height") % 2 - 100 )
1877 ok = VRset("PICT_THROBBER", "Left", VRGet("CN_SMBTREE","Width") % 2 - 200 )
1878
1879 ok = VRset("GB_SETTINGS","Top", margin )
1880 ok = VRset("GB_SETTINGS","Left", marginx2)
1881 ok = VRset("GB_SETTINGS","Width", pane_width - 760)
1882 ok = VRset("GB_SETTINGS","Height", pane_height- 1020)
1883
1884
1885 /* check and empty event queue, trash spurious resize events */
1886 EventString = ''
1887 TrashedResize = 0
1888 do until EventString = 'nop'
1889 EventString = VREvent('N')
1890 if EventString <> 'nop' then do
1891 if EventString = 'CALL Main_Resize' then TrashedResize = 1
1892 else interpret eventString
1893 end
1894 end
1895 if TrashedResize then CALL Main_Resize
1896 ok = VRSet("Main", "Painting", 1)
1897
1898 IF options.!debug == 1 THEN SAY time()' Main_Resize done'
1899return
1900
1901/*:VRX Page1_Create
1902*/
1903Page1_Create:
1904
1905Return
1906
1907/*:VRX Page1_Init
1908*/
1909Page1_Init:
1910 call _ContainerInit
1911return
1912
1913/*:VRX Page2_Create
1914*/
1915Page2_create:
1916
1917Return
1918/*:VRX Page2_init
1919*/
1920Page2_init:
1921
1922return
1923
1924/*:VRX Page3_Create
1925*/
1926Page3_create:
1927
1928Return
1929/*:VRX Page3_Init
1930*/
1931Page3_Init:
1932
1933return
1934
1935/*:VRX Page4_Create
1936*/
1937Page4_Create:
1938
1939Return
1940/*:VRX Page4_init
1941*/
1942Page4_init:
1943
1944return
1945
1946/*:VRX Page5_Create
1947*/
1948Page5_Create:
1949
1950return
1951
1952/*:VRX Page5_Init
1953*/
1954Page5_Init:
1955
1956return
1957
1958/*:VRX Paper_Init
1959*/
1960Paper_Init:
1961 ok = VRSet("IPB_Paper","Width" ,VRMethod( "Screen", "PixelsToTwips", 32 ))
1962 ok = VRSet("IPB_Paper","Height",VRMethod( "Screen", "PixelsToTwips", 32 ))
1963 ok = VRset("IPB_Paper","Left",VRget("GB_Main2","width")-420)
1964return
1965
1966/*:VRX PB_About_Click
1967*/
1968PB_About_Click:
1969 window = VRLoadSecondary( "About", "W" )
1970return
1971
1972/*:VRX PB_AboutOK_Click
1973*/
1974PB_AboutOK_Click:
1975 call About_Close
1976return
1977
1978/*:VRX PB_Cancel_Click
1979*/
1980PB_Cancel_Click:
1981 say 'start PB_Cancel_Click'
1982 Call Quit
1983 say 'done PB_Cancel_Click'
1984return
1985
1986/*:VRX PB_DELLOGS_Click
1987*/
1988PB_DELLOGS_Click:
1989 call VRSet VRWindow(), 'Pointer', 'Wait'
1990
1991 /* Fixme - this needs to be read from smb.conf */
1992 samba.!logdir = ETC'\samba\log'
1993
1994 ok = SysFileTree(samba.!logdir'\log.*', logs.,'FO')
1995 do I = 1 to logs.0
1996 ok = VRMethod( "CN_Daemons", "GetRecordList", "All", "handle." )
1997 KeepLog = 0
1998 do J = 1 to handle.0
1999 CurPID = VRMethod("CN_Daemons", "GetFieldData", handle.J, DPidsFH)
2000 if pos(CurPID,logs.I) > 0 then KeepLog = 1
2001 end
2002 if KeepLog = 0 then ok = SysFileDelete(logs.I)
2003 end
2004
2005 call VRSet VRWindow(), 'Pointer', '<default>'
2006return
2007
2008/*:VRX PB_Help_Click
2009*/
2010PB_Help_Click:
2011 ok = VRMethod("Main", "InvokeHelp" )
2012return
2013
2014/*:VRX PB_Refresh_Click
2015*/
2016PB_Refresh_Click:
2017 IF options.!debug == 1 then say time()' PB_Refresh_Click() started'
2018 ok = SysSleep(0.3)
2019
2020 say " CurrentPageNr = "CurrentPageNr
2021
2022 if CurrentPageNr = 2 then do
2023 ok = VRset("Pict_Throbber", "Visible", 1)
2024 ok = VRset("TM_Throbber", "Enabled", 1)
2025 call _RefreshTree
2026 end
2027 else call _Refresh
2028 IF options.!debug == 1 then say time()' PB_Refresh_Click() done'
2029return
2030
2031/*:VRX PB_RELOAD_Click
2032*/
2033PB_RELOAD_Click:
2034 call VRSet VRWindow(), 'Pointer', 'Wait'
2035 if WPSStartStop then do
2036 ok = SysOpenObject('<smb_reload>', 'DEFAULT', 1)
2037 end
2038 else do
2039 call lineout samba.!bin"\smbstart", "reload"
2040 ok = stream(samba.!bin"\reload","c","close")
2041 end
2042 ok = VRSet("TM_Refresh","Delay", 2000)
2043 call VRSet VRWindow(), 'Pointer', '<default>'
2044return
2045
2046/*:VRX PB_RESTART_Click
2047*/
2048PB_RESTART_Click:
2049 call VRSet VRWindow(), 'Pointer', 'Wait'
2050 if WPSStartStop then do
2051 ok = SysOpenObject('<smb_restart>', 'DEFAULT', 1)
2052 end
2053 else do
2054 call lineout samba.!bin"\restart", "restart"
2055 ok = stream(samba.!bin"\restart","c","close")
2056 end
2057 ok = VRSet("TM_Refresh","Delay", 1000)
2058 call VRSet VRWindow(), 'Pointer', '<default>'
2059return
2060
2061/*:VRX PB_Sort_Cancel_Click
2062*/
2063PB_Sort_Cancel_Click:
2064 ok = VRset( Container, "DetailSort", Old.SortField )
2065 ok = VRSet( Container, "Sort", Old.SortOrder )
2066 ok = VRMethod( Container, "SortRecords" )
2067 drop Old.
2068 call SW_SORT_Close
2069return
2070
2071/*:VRX PB_Sort_OK_Click
2072*/
2073PB_Sort_OK_Click:
2074 drop Old.
2075 call SW_SORT_Close
2076return
2077
2078/*:VRX PB_START_Click
2079*/
2080PB_START_Click:
2081 say "IPB_Start_Click started"
2082 call VRSet VRWindow(), 'Pointer', 'Wait'
2083 if WPSStartStop then do
2084 ok = SysOpenObject('<smb_start>', 'DEFAULT', 1)
2085 end
2086 else do
2087 call lineout samba.!bin"\smbstart", "smbstart"
2088 ok = stream(samba.!bin"\smbstart","c","close")
2089 end
2090 ok = VRSet("TM_Refresh","Delay", 1000)
2091 call VRSet VRWindow(), 'Pointer', '<default>'
2092 say "IPB_Start_Click done"
2093return
2094/*:VRX PB_STOP_Click
2095*/
2096PB_STOP_Click:
2097 say "IPB_Stop_Click started"
2098 call VRSet VRWindow(), 'Pointer', 'Wait'
2099 if WPSStartStop then do
2100 ok = SysOpenObject('<smb_stop>', 'DEFAULT', 1)
2101 end
2102 else do
2103 call lineout samba.!bin"\smbstop", "smbstop"
2104 ok = stream(samba.!bin"\smbstop","c","close")
2105 end
2106 ok = VRSet("TM_Refresh","Delay", 1000)
2107 call VRSet VRWindow(), 'Pointer', '<default>'
2108 say "IPB_Stop_Click done"
2109return
2110/*:VRX PushbackAll
2111*/
2112PushbackAll:
2113 Pages = 6
2114 /* Tab distance from top */
2115 TabTop = 20
2116 TabWidth = VRMethod( "Screen", "PixelsToTwips", 78 )
2117 TabHeight= VRMethod( "Screen", "PixelsToTwips", 24 )
2118
2119 /* Page Position */
2120 PageLeft = 120
2121 PageTop = PageLeft + TabTop + 330
2122
2123 /* Page size */
2124 PageHeight = 3000
2125 PageWidth = 3000
2126 call beep 880, 20
2127/* ok = VRset("DT_PageName", "Caption", "")
2128 ok = VRSet("GB_Main","Left", 0)
2129 ok = VRSet("GB_Main","Top", TabTop+230)
2130 do I = 1 to Pages
2131 ok = VRSet("TAB_"I,"Top", TabTop)
2132 ok = VRSet("TAB_"I,"PicturePath","#2"||I||";#2"||I)
2133 ok = VRSet("TAB_"I,"Left",TabWidth*(I-1)+PageLeft)
2134 ok = VRSet("TAB_"I,"Width",TabWidth)
2135 ok = VRSet("TAB_"I,"Height",TabHeight)
2136 ok = VRSet("Page_"I,"Height", max(PageHeight,VRget("GB_Main2","Height")-600))
2137 ok = VRSet("Page_"I,"Width", max(PageWidth,VRget("GB_Main2","Width")-450))
2138 ok = VRSet("Page_"I,"Left", PageLeft)
2139 ok = VRSet("Page_"I,"Top", PageTop)
2140 ok = VRSet("Page_"I,"Visible", 0)
2141 ok = VRSet("Page_"I,"BackColor", "<default>")
2142 end */
2143return
2144
2145/*:VRX Quit
2146*/
2147Quit:
2148 call VRSet VRWindow(), 'Pointer', 'Wait'
2149 call _IniWrite
2150 ok = VRRedirectStdIO("OFF")
2151 call _SambaFinish
2152
2153 ok = SysFileDelete(smbdoutput)
2154
2155 call lineout samba.!bin"\quit", "quit"
2156 ok = stream(samba.!bin"\quit","c","close")
2157 ok = SysSleep(1)
2158 ok = SysDestroyObject('<smbstarter>')
2159 ok = SysFileDelete(samba.!bin'\smbstarter.cmd')
2160 ok = SysFileDelete(samba.!bin'\quit')
2161 call VRSet VRWindow(), 'Pointer', '<default>'
2162
2163 window = VRWindow()
2164 call VRSet window, "Shutdown", 1
2165 drop window
2166return
2167
2168/*:VRX RB_Sort_Ascending_Click
2169*/
2170RB_Sort_Ascending_Click:
2171 SortOrder = "Ascending"
2172 call _ContainerSort
2173return
2174
2175/*:VRX RB_Sort_Descending_Click
2176*/
2177RB_Sort_Descending_Click:
2178 SortOrder = "Descending"
2179 call _ContainerSort
2180return
2181
2182/*:VRX RB_Sort_None_Click
2183*/
2184RB_Sort_None_Click:
2185 SortOrder = "None"
2186 call _ContainerSort
2187return
2188
2189/*:VRX SPIN_Intervall_Change
2190*/
2191SPIN_Intervall_Change:
2192 Intervall = VRGet("SPIN_Intervall","Value")
2193 ok = VRSet("TM_Refresh","Delay", Intervall * 1000)
2194return
2195
2196/*:VRX SPIN_IntervallMin_Change
2197*/
2198SPIN_IntervallMin_Change:
2199 IntervallMin = VRGet("SPIN_IntervallMin","Value")
2200return
2201
2202/*:VRX SW_DAEMONS_Close
2203*/
2204SW_DAEMONS_Close:
2205 call SW_DAEMONS_Fini
2206return
2207
2208/*:VRX SW_DAEMONS_Create
2209*/
2210SW_DAEMONS_Create:
2211 call SW_DAEMONS_Init
2212return
2213
2214/*:VRX SW_DAEMONS_Fini
2215*/
2216SW_DAEMONS_Fini:
2217 window = VRInfo( "Window" )
2218 call VRDestroy window
2219 drop window
2220return
2221/*:VRX SW_DAEMONS_Init
2222*/
2223SW_DAEMONS_Init:
2224 window = VRInfo( "Object" )
2225 if( \VRIsChildOf( window, "Notebook" ) ) then do
2226 call VRMethod window, "CenterWindow"
2227 call VRSet window, "Visible", 1
2228 call VRMethod window, "Activate"
2229 end
2230 drop window
2231return
2232
2233/*:VRX SW_FILES_Close
2234*/
2235SW_FILES_Close:
2236 call SW_FILES_Fini
2237return
2238
2239/*:VRX SW_FILES_Create
2240*/
2241SW_FILES_Create:
2242 call SW_FILES_Init
2243return
2244
2245/*:VRX SW_FILES_Fini
2246*/
2247SW_FILES_Fini:
2248 window = VRInfo( "Window" )
2249 call VRDestroy window
2250 drop window
2251return
2252/*:VRX SW_FILES_Init
2253*/
2254SW_FILES_Init:
2255 window = VRInfo( "Object" )
2256 if( \VRIsChildOf( window, "TDL" ) ) then do
2257 call VRMethod window, "CenterWindow"
2258 call VRSet window, "Visible", 1
2259 call VRMethod window, "Activate"
2260 end
2261 drop window
2262return
2263
2264/*:VRX SW_SERVICE_Close
2265*/
2266SW_SERVICE_Close:
2267 call SW_SERVICE_Fini
2268return
2269
2270/*:VRX SW_SERVICE_Create
2271*/
2272SW_SERVICE_Create:
2273 call SW_SERVICE_Init
2274return
2275
2276/*:VRX SW_SERVICE_Fini
2277*/
2278SW_SERVICE_Fini:
2279 window = VRInfo( "Window" )
2280 call VRDestroy window
2281 drop window
2282return
2283/*:VRX SW_SERVICE_Init
2284*/
2285SW_SERVICE_Init:
2286 window = VRInfo( "Object" )
2287 if( \VRIsChildOf( window, "TDL" ) ) then do
2288 call VRMethod window, "CenterWindow"
2289 call VRSet window, "Visible", 1
2290 call VRMethod window, "Activate"
2291 end
2292 drop window
2293return
2294
2295/*:VRX SW_SETTINGS_Close
2296*/
2297SW_SETTINGS_Close:
2298 call SW_SETTINGS_Fini
2299return
2300
2301/*:VRX SW_SETTINGS_Create
2302*/
2303SW_SETTINGS_Create:
2304 call SW_SETTINGS_Init
2305return
2306
2307/*:VRX SW_SETTINGS_Fini
2308*/
2309SW_SETTINGS_Fini:
2310 window = VRInfo( "Window" )
2311 call VRDestroy window
2312 drop window
2313return
2314/*:VRX SW_SETTINGS_Init
2315*/
2316SW_SETTINGS_Init:
2317 window = VRInfo( "Object" )
2318 if( \VRIsChildOf( window, "TDL" ) ) then do
2319 call VRMethod window, "CenterWindow"
2320 call VRSet window, "Visible", 1
2321 call VRMethod window, "Activate"
2322 end
2323 drop window
2324return
2325
2326/*:VRX SW_SMBTREE_Close
2327*/
2328SW_SMBTREE_Close:
2329 call SW_SMBTREE_Fini
2330return
2331
2332/*:VRX SW_SMBTREE_Create
2333*/
2334SW_SMBTREE_Create:
2335 call SW_SMBTREE_Init
2336return
2337
2338/*:VRX SW_SMBTREE_Fini
2339*/
2340SW_SMBTREE_Fini:
2341 window = VRInfo( "Window" )
2342 call VRDestroy window
2343 drop window
2344return
2345/*:VRX SW_SMBTREE_Init
2346*/
2347SW_SMBTREE_Init:
2348 window = VRInfo( "Object" )
2349 if( \VRIsChildOf( window, "TDL" ) ) then do
2350 call VRMethod window, "CenterWindow"
2351 call VRSet window, "Visible", 1
2352 call VRMethod window, "Activate"
2353 end
2354 drop window
2355return
2356
2357/*:VRX SW_SMBTREE_Init_Content
2358*/
2359SW_SMBTREE_Init_Content:
2360 ok = VRset("Pict_Throbber", "Visible", 1)
2361 ok = VRset("TM_Throbber", "Enabled", 1)
2362 call _RefreshTree
2363return
2364
2365/*:VRX SW_SORT_Close
2366*/
2367SW_SORT_Close:
2368 call SW_SORT_Fini
2369return
2370
2371/*:VRX SW_SORT_Create
2372*/
2373SW_SORT_Create:
2374 call SW_SORT_Init
2375
2376 CALL NLVSetText 'SW_SORT', 'Caption', 35
2377 CALL NLVSetText 'PB_Sort_OK', 'Caption', 2
2378 CALL NLVSetText 'PB_Sort_Cancel', 'Caption', 3
2379
2380 CALL NLVSetText 'RB_Sort_Ascending', 'Caption', 90
2381 CALL NLVSetText 'RB_Sort_Descending', 'Caption', 91
2382 CALL NLVSetText 'RB_Sort_None', 'Caption', 92
2383
2384 Container = OH
2385say OH
2386say Container
2387 ok = VRMethod(Container, "GetFieldList", "Fields." )
2388
2389 SortOrder = "None"
2390
2391 do I = 1 to Fields.0
2392 ok = VRMethod("LB_SortFields","AddString", VRMethod(Container, "GetFieldAttr", fields.I, "Title" ))
2393 end
2394 Old.SortField = VRGet( Container, "DetailSort" )
2395 Old.SortOrder = VRGet( Container, "Sort" )
2396say Old.SortField
2397say Old.SortOrder
2398return
2399
2400/*:VRX SW_SORT_Fini
2401*/
2402SW_SORT_Fini:
2403 window = VRInfo( "Window" )
2404 call VRDestroy window
2405 drop window
2406return
2407/*:VRX SW_SORT_Init
2408*/
2409SW_SORT_Init:
2410 window = VRInfo( "Object" )
2411 if( \VRIsChildOf( window, "Notebook" ) ) then do
2412 call VRMethod window, "CenterWindow"
2413 call VRSet window, "Visible", 1
2414 call VRMethod window, "Activate"
2415 end
2416 drop window
2417return
2418
2419/*:VRX SW_USERS_Close
2420*/
2421SW_USERS_Close:
2422 call SW_USERS_Fini
2423return
2424
2425/*:VRX SW_USERS_Create
2426*/
2427SW_USERS_Create:
2428 call SW_USERS_Init
2429return
2430
2431/*:VRX SW_USERS_Fini
2432*/
2433SW_USERS_Fini:
2434 window = VRInfo( "Window" )
2435 call VRDestroy window
2436 drop window
2437return
2438/*:VRX SW_USERS_Init
2439*/
2440SW_USERS_Init:
2441 window = VRInfo( "Object" )
2442 if( \VRIsChildOf( window, "Notebook" ) ) then do
2443 call VRMethod window, "CenterWindow"
2444 call VRSet window, "Visible", 1
2445 call VRMethod window, "Activate"
2446 end
2447 drop window
2448return
2449
2450/*:VRX TDL_1_PageSelected
2451*/
2452TDL_1_PageSelected:
2453 page = VRInfo("Page")
2454 CurrentPageNr = page
2455 ok = VRSet("TM_RefreshDaemons","Enabled", 0)
2456 ok = VRSet("DT_STATUSBAR","Caption", VRGet("Main", "HintText"))
2457 /* call _TabsStrip */
2458 select
2459 when page = 1 then do /* daemons */
2460 ok = VRSet("TM_RefreshDaemons","Enabled", 1)
2461 ok = VRSet("TM_RefreshDaemons","Delay", 3000)
2462 end
2463 when page = 2 then do /* smbtree */
2464 ok = VRMethod( "CN_SMBTree", "GetRecordList", "All", "handle." )
2465 /* if the page is empty, populate it */
2466 if handle.0 = 0 then call PB_Refresh_Click
2467 end
2468 when page = 3 then do /* Users */
2469 nop
2470 end
2471 when page = 4 then do /* files */
2472 nop
2473 end
2474 when page = 5 then do /* service */
2475 nop
2476 end
2477 when page = 6 then do /* Settings */
2478 nop
2479 end
2480 otherwise nop
2481 end
2482return
2483
2484/*:VRX TM_Refresh_Trigger
2485*/
2486TM_Refresh_Trigger:
2487/* call beep 1200, 20 */
2488 ok = VRSet("TM_Refresh","Delay", Intervall * 1000)
2489 call _Refresh
2490return
2491
2492/*:VRX TM_RefreshDaemons_Trigger
2493*/
2494TM_RefreshDaemons_Trigger:
2495 ok = VRSet("TM_RefreshDaemons","Delay", 3000)
2496 call _RefreshDaemons
2497return
2498
2499/*:VRX TM_RefreshTreeDisplay_Trigger
2500*/
2501TM_RefreshTreeDisplay_Trigger:
2502 select
2503 when RefreshMode = "TREE" then do
2504 call _RefreshTreeDisplay
2505 end
2506 when RefreshMode = "SHARE" then do
2507 call _AddSharesDisplay
2508 end
2509 otherwise say "RefreshMode = "RefreshMode
2510 end
2511return
2512
2513/*:VRX TM_Throbber_Trigger
2514*/
2515TM_Throbber_Trigger:
2516 pIdx = VRGet("Pict_Throbber","PicturePath")
2517 parse var pIdx '#' pidx
2518 pidx = pidx + 1
2519 if pidx = 136 then pidx = 111
2520 ok = VRSet("Pict_Throbber","PicturePath","#"pidx)
2521return
2522
Note: See TracBrowser for help on using the repository browser.