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

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

GUI-Tools: More work on EVFSGUI V.next (Feature complete now, more bugs fixed, started code cleaning)

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