source: branches/guitools-2.0/shared/smbtree.vrs@ 334

Last change on this file since 334 was 334, checked in by Herwig Bauernfeind, 16 years ago

GUI-Tools: SMBMON V.next (Adding sorting dialog)

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