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

Last change on this file since 890 was 875, checked in by Herwig Bauernfeind, 10 years ago

GUITools: SSCC (Ticket #248), SMBMon (TDB Check page), EVFSGUI, shared library updates

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