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

Last change on this file since 990 was 990, checked in by Herwig Bauernfeind, 4 years ago

GUITools: All changes that have built over time.

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