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

Last change on this file since 924 was 924, checked in by Herwig Bauernfeind, 9 years ago

GUITools: EVFSGUI: Start implementinig client side Samba configuration settings

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