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

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

GUI-Tools: More work on EVFSGUI V.next (Fixed several bugs)

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