1 | /* Routines to handle smbtree output */
|
---|
2 |
|
---|
3 | /*:VRX */
|
---|
4 | _RefreshTree:
|
---|
5 | say "_RefreshTree() started"
|
---|
6 | FirstRun = 0
|
---|
7 |
|
---|
8 | ok = SysFileDelete(samba.!msg)
|
---|
9 |
|
---|
10 | if UserCred = 'USERCRED' | UserCred = '' | UserCred = '--user=%' then do
|
---|
11 | UserCred = '-N'
|
---|
12 | end
|
---|
13 | say 'detach 'samba.!smbtreeexe' 'debuglevel' 'UserCred' >'samba.!msg
|
---|
14 | address cmd 'detach 'samba.!smbtreeexe' 'debuglevel' 'UserCred' >'samba.!msg
|
---|
15 |
|
---|
16 | if UserCred = '-N' then UserCred = ''
|
---|
17 |
|
---|
18 | ok = VRMethod("CN_smbtree", "RemoveRecord", "ALL")
|
---|
19 |
|
---|
20 | ok = VRSet("CN_smbtree","Enabled", 0)
|
---|
21 | ok = VRset("TM_RefreshTreeDisplay","Enabled",1)
|
---|
22 |
|
---|
23 | say "_RefreshTree() done"
|
---|
24 | return
|
---|
25 |
|
---|
26 | /*:VRX */
|
---|
27 | _RefreshTreeDisplay:
|
---|
28 | stat = stream(samba.!msg,'c','open read')
|
---|
29 | if stat <> "READY:" then return
|
---|
30 |
|
---|
31 | ok = VRset("TM_RefreshTreeDisplay","Enabled",0)
|
---|
32 | /* ok = VRSet("Main", "StatusText", NLVGetMessage(50)) */
|
---|
33 | ok = VRSet("CN_smbtree", 'Enabled', 0 )
|
---|
34 | /* ok = VRSet("Main", 'Pointer', 'Wait' ) */
|
---|
35 |
|
---|
36 | ok = VRSet( "CN_smbtree", "Painting", 0 )
|
---|
37 | ok = VRMethod("CN_smbtree", "RemoveRecord", "ALL")
|
---|
38 |
|
---|
39 | drop smbtree.
|
---|
40 | drop smbtreeline.
|
---|
41 |
|
---|
42 | sl = 0
|
---|
43 |
|
---|
44 | do until lines(samba.!msg) = 0
|
---|
45 | sl = sl + 1
|
---|
46 | smbtreeline.sl = linein(samba.!msg)
|
---|
47 | end
|
---|
48 | smbtreeline.0 = sl
|
---|
49 | ok = stream(samba.!msg,'c','close')
|
---|
50 |
|
---|
51 | do sl = 1 to smbtreeline.0
|
---|
52 | Header = c2x(left(smbtreeline.sl,3))
|
---|
53 | select
|
---|
54 | when Header = "09095C" then do /* share */
|
---|
55 | smbtreeline.sl = strip(smbtreeline.sl,,'09'x)
|
---|
56 | parse var smbtreeline.sl '\\'machine'\'share '09'x comment
|
---|
57 | machine = strip(machine)
|
---|
58 | share = left(strip(share),10)
|
---|
59 | comment = strip(comment)
|
---|
60 | text = translate(share' 'comment)
|
---|
61 | res = _GuessIcon(text)
|
---|
62 | if VRGet("CN_smbtree","View") = "IconTree" then do
|
---|
63 | parent = smbtree.!machine
|
---|
64 | smbtree.!share = VRMethod( "CN_smbtree", "AddRecord",parent,, share||'0D0A'x||comment, res)
|
---|
65 | end
|
---|
66 | end
|
---|
67 | when Header = "095C5C" then do /* Machine */
|
---|
68 | smbtreeline.sl = strip(smbtreeline.sl,,'09'x)
|
---|
69 | parse var smbtreeline.sl '\\'machine '0909'x comment
|
---|
70 | machine = left(strip(machine),13)
|
---|
71 | comment = strip(comment)
|
---|
72 | if VRGet("CN_smbtree","View") = "IconTree" then parent = smbtree.!workgroup; else parent = ""
|
---|
73 | smbtree.!machine = VRMethod( "CN_smbtree", "AddRecord",parent,, machine||'0D0A'x||comment,"#35:PMWP.DLL")
|
---|
74 | ok = VRMethod( "CN_smbtree", "SetFieldData", smbtree.!machine, NBFH, machine, CommentFH, Comment, WorkGroupFH, CurWG)
|
---|
75 | if VRGet("CN_smbtree","View") = "Detail" then do
|
---|
76 | address cmd samba.!nmblookupexe' 'machine' 'debuglevel' -N >'samba.!msg
|
---|
77 | ipstr = ""
|
---|
78 | ip = ""
|
---|
79 | do until lines(samba.!msg) = 0
|
---|
80 | nmblookupline = linein(samba.!msg)
|
---|
81 | if pos(strip(machine)'<',nmblookupline) > 0 then do
|
---|
82 | parse var nmblookupline ip .
|
---|
83 | if pos(strip(ip), ipstr) = 0 then do
|
---|
84 | ipstr = ipstr||ip','
|
---|
85 | end
|
---|
86 | end
|
---|
87 | end
|
---|
88 | ipstr = strip(ipstr,,',')
|
---|
89 | ok = VRMethod( "CN_smbtree", "SetFieldData", smbtree.!machine, IPFH, IPStr)
|
---|
90 | ok = stream(samba.!msg,'c','close')
|
---|
91 | if ip <> "" then do
|
---|
92 | address cmd samba.!smbclientexe' -L "'strip(machine)'" -I "'ip'" -N 'debuglevel' 2>'samba.!msg' 1>NUL'
|
---|
93 | smbline = linein(samba.!msg)
|
---|
94 | ok = stream(samba.!msg,'c','close')
|
---|
95 | parse var smbline "Domain=["WorkGroup"] OS=["OS"] Server=["Server"]"Rest
|
---|
96 | ok = VRMethod( "CN_smbtree", "SetFieldData", smbtree.!machine, OSFH, OS)
|
---|
97 | /* WorkGroupFH, Workgroup */
|
---|
98 | address cmd samba.!nmblookupexe' -A 'machine' 'debuglevel' -N >'samba.!msg
|
---|
99 | Master = ""
|
---|
100 | do until lines(samba.!msg) = 0
|
---|
101 | nmblookupline = linein(samba.!msg)
|
---|
102 | if pos('<1b>', nmblookupline) > 0 then Master = Master||"LMB," /* + */
|
---|
103 | if pos('<1d>', nmblookupline) > 0 then Master = Master||"DMB," /* * */
|
---|
104 | if pos('MAC',nmblookupline) > 0 then do
|
---|
105 | parse var nmblookupline . '=' MAC
|
---|
106 | MAC = strip(MAC)
|
---|
107 | end
|
---|
108 | end
|
---|
109 | Master= strip(Master,,',')
|
---|
110 | ok = stream(samba.!msg,'c','close')
|
---|
111 | ok = VRMethod( "CN_smbtree", "SetFieldData", smbtree.!machine, MBFH, Master,MacFH,MAC)
|
---|
112 | end
|
---|
113 | end
|
---|
114 | ok = VRSet( "CN_smbtree", "Painting", 1 )
|
---|
115 | ok = VRSet( "CN_smbtree", "Painting", 0 )
|
---|
116 |
|
---|
117 | end
|
---|
118 | otherwise do
|
---|
119 | say "Workgroup: "smbtreeline.sl
|
---|
120 | if pos("RECEIVING",translate(smbtreeline.sl)) > 0 then do
|
---|
121 | Msg.Type = "W"
|
---|
122 | Msg.Text = smbtreeline.sl
|
---|
123 | call _ShowMsg
|
---|
124 | end
|
---|
125 | else do
|
---|
126 | if VRGet("CN_smbtree","View") = "IconTree" then do
|
---|
127 | smbtree.!workgroup = VRMethod( "CN_smbtree", "AddRecord",,, smbtreeline.sl,"#62:PMWP.DLL")
|
---|
128 | ok = VRMethod( "CN_smbtree", "SetFieldData", smbtree.!workgroup, WorkGroupFH, smbtreeline.sl)
|
---|
129 | ok = VRMethod( "CN_smbtree", "SetRecordAttr", smbtree.!workgroup, "Collapsed", 0)
|
---|
130 | end
|
---|
131 | CurWG = smbtreeline.sl
|
---|
132 | end
|
---|
133 | end
|
---|
134 | end
|
---|
135 | end
|
---|
136 |
|
---|
137 | ok = VRSet( "CN_smbtree", "Painting", 1 )
|
---|
138 |
|
---|
139 | /* ok = VRSet("Main", 'Pointer', '<default>' ) */
|
---|
140 | ok = VRSet("CN_smbtree","Enabled", 1)
|
---|
141 | ok = VRSet("TM_Throbber","Enabled", 0)
|
---|
142 | ok = VRSet("Pict_Throbber","Visible", 0)
|
---|
143 | return
|
---|
144 |
|
---|
145 | /*:VRX _GuessIcon
|
---|
146 | */
|
---|
147 | _GuessIcon: procedure
|
---|
148 | text = arg(1)
|
---|
149 | select /* Printer guessing */
|
---|
150 | when pos('LJ',text) > 0 then res = '#65:PMWP.DLL'
|
---|
151 | when pos('LASER',text) > 0 then res = '#65:PMWP.DLL'
|
---|
152 | when pos('EPSON',text) > 0 then res = '#65:PMWP.DLL'
|
---|
153 | when pos('PRINT',text) > 0 then res = '#65:PMWP.DLL'
|
---|
154 | when pos('PRT',text) > 0 then res = '#65:PMWP.DLL'
|
---|
155 | when pos('CANON',text) > 0 then res = '#65:PMWP.DLL'
|
---|
156 | when pos('MINOLTA',text) > 0 then res = '#65:PMWP.DLL'
|
---|
157 | when pos('FAX',text) > 0 then res = '#65:PMWP.DLL'
|
---|
158 | when pos('LEXMARK',text) > 0 then res = '#65:PMWP.DLL'
|
---|
159 | when pos('IPC$',text) > 0 then res = '#59:PMWP.DLL'
|
---|
160 | otherwise res = "#34:PMWP.DLL"
|
---|
161 | end
|
---|
162 | return res
|
---|
163 |
|
---|