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