Changeset 345 for branches/guitools-2.0/shared/smbtree.vrs
- Timestamp:
- Oct 30, 2009, 4:17:35 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/guitools-2.0/shared/smbtree.vrs
r334 r345 14 14 if ShowHidden = 'SHOWHIDDEN' | ShowHidden = '' then ShowHidden = 0 15 15 16 say 'detach 'samba.!smbtreeexe' 'debuglevel' 'UserCred' >'samba.!msg17 address cmd 'detach 'samba.!smbtreeexe' 'debuglevel' 'UserCred' >'samba.!msg16 say 'detach 'samba.!smbtreeexe' -S 'debuglevel' 'UserCred' >'samba.!msg 17 address cmd 'detach 'samba.!smbtreeexe' -S 'debuglevel' 'UserCred' >'samba.!msg 18 18 19 19 if UserCred = '-N' then UserCred = '' … … 21 21 ok = VRMethod("CN_smbtree", "RemoveRecord", "ALL") 22 22 23 RefreshMode = "TREE" 23 24 ok = VRSet("CN_smbtree","Enabled", 0) 24 25 ok = VRset("TM_RefreshTreeDisplay","Enabled",1) … … 32 33 if stat <> "READY:" then return 33 34 35 if UserCred = 'USERCRED' | UserCred = '' | UserCred = '--user=%' then do 36 UserCred = '-N' 37 end 38 34 39 if ShowHidden = 'SHOWHIDDEN' | ShowHidden = '' then ShowHidden = 0 35 40 … … 58 63 Header = c2x(left(smbtreeline.sl,3)) 59 64 select 60 when Header = "09095C" then do /* share */65 when Header = "09095C" then do /* share - obsolete, we do that differently now see below! */ 61 66 smbtreeline.sl = strip(smbtreeline.sl,,'09'x) 62 67 parse var smbtreeline.sl '\\'machine'\'share '09'x comment … … 72 77 if pos("$", share) > 0 then ok = VRMethod( "CN_smbtree", "SetRecordAttr", smbtree.!share, "Visible", ShowHidden) 73 78 end 74 end 79 end /* end of obsolete share code */ 75 80 when Header = "095C5C" then do /* Machine */ 76 81 smbtreeline.sl = strip(smbtreeline.sl,,'09'x) … … 79 84 comment = strip(comment) 80 85 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") 86 ok = VRSet( "CN_smbtree", "Painting", 1 ) 87 smbtree.!machine = VRMethod( "CN_smbtree", "AddRecord",parent,, machine||'0D0A'x||comment) 88 /* We make any machine as sleeping initially */ 89 ok = VRMethod('CN_smbtree', 'SetRecordAttr', smbtree.!machine, 'Icon',"#61:PMWP.DLL") 82 90 ok = VRMethod( "CN_smbtree", "SetRecordAttr", smbtree.!machine, "ReadOnly", 1) 83 91 ok = VRMethod( "CN_smbtree", "SetFieldData", smbtree.!machine, NBFH, machine, CommentFH, Comment, WorkGroupFH, CurWG) 92 ok = VRSet( "CN_smbtree", "Painting", 0 ) 84 93 if VRGet("CN_smbtree","View") = "Detail" then do 85 94 address cmd samba.!nmblookupexe' 'machine' 'debuglevel' -N >'samba.!msg … … 123 132 end 124 133 end 125 ok = VRSet( "CN_smbtree", "Painting", 1 ) 126 ok = VRSet( "CN_smbtree", "Painting", 0 ) 134 else do 135 call _RefreshShares 136 end 127 137 end 128 138 otherwise do … … 139 149 ok = VRMethod( "CN_smbtree", "SetRecordAttr", smbtree.!workgroup, "Collapsed", 0) 140 150 ok = VRMethod( "CN_smbtree", "SetRecordAttr", smbtree.!workgroup, "ReadOnly", 1) 151 ok = VRMethod( "CN_smbtree", 'SetRecordAttr', smbtree.!workgroup, "UserData", "WORKGROUP|") 141 152 end 142 153 CurWG = smbtreeline.sl … … 154 165 return 155 166 156 /*:VRX _ GuessIcon167 /*:VRX _RefreshShares 157 168 */ 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 181 return res 169 _RefreshShares: 170 say "_RefreshShares() started" 171 RefreshID = RANDOM() 172 smbshares = TempDir||"smbshares."||machine 173 174 say 'detach 'samba.!smbclientexe' -L "'strip(machine)'" 'UserCred' 'debuglevel' 1>'smbshares' 2>NUL' 175 address cmd 'detach 'samba.!smbclientexe' -L "'strip(machine)'" 'UserCred' 'debuglevel' 1>'smbshares' 2>NUL' 176 177 RefreshMode = "SHARE" 178 179 ok = VRSet("CN_smbtree","Enabled", 0) 180 ok = VRset("TM_RefreshTreeDisplay","Enabled",1) 181 return 182 183 /*:VRX _AddSharesDisplay 184 */ 185 _AddSharesDisplay: /* New get shares code - uses smbclient output and is much faster */ 186 say "_AddSharesDisplay() started" 187 188 ok = SysFileTree(Tempdir||'smbshares.*',smbshare.,'FO') 189 190 if smbshare.0 = 0 then do /* we are done, no more files around, cleanup, disable Timer and exit */ 191 RefreshMode = "" 192 ok = VRSet("CN_smbtree","Enabled", 1) 193 ok = VRset("TM_RefreshTreeDisplay","Enabled",0) 194 say "_AddSharesDisplay() completed" 195 return /* exit here */ 196 end 197 198 if UserCred = 'USERCRED' | UserCred = '' | UserCred = '--user=%' then do 199 UserCred = '-N' 200 end 201 202 if ShowHidden = 'SHOWHIDDEN' | ShowHidden = '' then ShowHidden = 0 203 204 do I = 1 to smbshare.0 205 stat = stream(smbshare.I,'c','open read') 206 if stat = "READY:" then do /* we found a readable output file */ 207 Machine = VRParseFilename(smbshare.I,'E') 208 smbtree.!machine = _GetMachinehandle(Machine) 209 210 line = linein(smbshare.I) 211 say line 212 ok = VRMethod('CN_smbtree', 'SetRecordAttr', smbtree.!machine, 'UserData', "SERVER|"||strip(line)) 213 214 if left(line, 20) = "session setup failed" then do /* we see an error message */ 215 say left(line, 20) 216 signal sharecleanup 217 end 218 219 retries = 0 220 do while(left(line,1) <> '09'x) 221 line = linein(smbshare.I) 222 retries = retries + 1 223 say 'Retry 'retries 224 if retries >=10 then do /* No valid output - error */ 225 signal sharecleanup 226 end 227 end 228 229 /* Skip header */ 230 line = linein(smbshare.I) 231 line = linein(smbshare.I) 232 233 if left(line,5) = "Error" then ok = VRMethod('CN_smbtree', 'SetRecordAttr', smbtree.!machine, 'UserData', "SERVER|"||strip(line)) 234 235 do while(left(line,1) = '09'x) 236 parse var line '09'x share type comment 237 type = translate(strip(type)) 238 comment = strip(comment) 239 240 select 241 when type = "DISK" then res = '#34:PMWP.DLL' 242 when type = "PRINTER" then res = '#65:PMWP.DLL' 243 when type = "IPC" then res = '#59:PMWP.DLL' 244 when type = "DEVICE" then res = '#84:PMWP.DLL' /* There might be better ones around */ 245 otherwise res = '' 246 end 247 248 /* Now the machine receives the wakeup icon */ 249 ok = VRMethod('CN_smbtree', 'SetRecordAttr', smbtree.!machine, 'Icon', "#35:PMWP.DLL") 250 parent = smbtree.!machine 251 smbtree.!share = VRMethod( "CN_smbtree", "AddRecord",parent,, share||'0D0A'x||comment, res) 252 ok = VRMethod( "CN_smbtree", "SetRecordAttr", smbtree.!share, "ReadOnly", 1, 'UserData', type"|") 253 if pos("$", share) > 0 then ok = VRMethod( "CN_smbtree", "SetRecordAttr", smbtree.!share, "Visible", ShowHidden) 254 255 /* get next share */ 256 line = linein(smbshare.I) 257 end 258 sharecleanup: 259 say "_AddSharesDisplay() cleanup" 260 ok = stream(smbshare.I,'c','close') 261 ok = SysFileDelete(smbshare.I) 262 if ok <> 0 then say 'Failure 'ok' deleting "'smbshare.I'"!' 263 end 264 end 265 say "_AddSharesDisplay() loop finished" 266 return 267 268 /*:VRX _GetMachinehandle 269 */ 270 271 _GetMachinehandle: procedure 272 Machine = arg(1) 273 ok = VRMethod("CN_smbtree", "GetRecordList", "All", rh.) 274 275 do I = 1 to rh.0 276 277 ResName = VRMethod("CN_smbtree","GetRecordAttr",rh.I,"Caption") 278 279 parse var ResName ResName '0D0A'x . 280 ResName = strip(ResName) 281 282 if Machine = ResName then leave /* we got a matching name */ 283 end 284 return rh.I
Note:
See TracChangeset
for help on using the changeset viewer.