Added ref to Misc/NEWS file; added hint to run regen script on Linux.
[python/dscho.git] / Mac / Lib / toolbox / WWW_Suite.py
blob437243c1d2bc76d17e031346e49c5a3b13ce687a
1 """Suite WorldWideWeb suite, as defined in Spyglass spec.:
2 Level 1, version 1
4 Generated from flap:Programma's:Netscape 2.0b5 Folder:Netscape 2.0b5
5 AETE/AEUT resource version 1/0, language 0, script 0
6 """
8 import addpack
9 addpack.addpack('Tools')
10 addpack.addpack('bgen')
11 addpack.addpack('ae')
13 import aetools
14 import MacOS
16 _code = 'WWW!'
18 class WWW_Suite:
20 _argmap_OpenURL = {
21 'to' : 'INTO',
22 'toWindow' : 'WIND',
23 'flags' : 'FLGS',
24 'post_data' : 'POST',
25 'post_type' : 'MIME',
26 'progressApp' : 'PROG',
29 def OpenURL(self, _object, _attributes={}, **_arguments):
30 """OpenURL: Opens a URL. Allows for more options than GetURL event
31 Required argument: URL
32 Keyword argument to: file destination
33 Keyword argument toWindow: window iD
34 Keyword argument flags: Binary: any combination of 1, 2 and 4 is allowed: 1 and 2 mean force reload the document. 4 is ignored
35 Keyword argument post_data: Form posting data
36 Keyword argument post_type: MIME type of the posting data. Defaults to application/x-www-form-urlencoded
37 Keyword argument progressApp: Application that will display progress
38 Keyword argument _attributes: AppleEvent attribute dictionary
39 Returns: ID of the loading window
40 """
41 _code = 'WWW!'
42 _subcode = 'OURL'
44 aetools.keysubst(_arguments, self._argmap_OpenURL)
45 _arguments['----'] = _object
48 _reply, _arguments, _attributes = self.send(_code, _subcode,
49 _arguments, _attributes)
50 if _arguments.has_key('errn'):
51 raise MacOS.Error, aetools.decodeerror(_arguments)
52 # XXXX Optionally decode result
53 if _arguments.has_key('----'):
54 return _arguments['----']
56 _argmap_ShowFile = {
57 'MIME_type' : 'MIME',
58 'Window_ID' : 'WIND',
59 'URL' : 'URL ',
62 def ShowFile(self, _object, _attributes={}, **_arguments):
63 """ShowFile: Similar to OpenDocuments, except that it specifies the parent URL, and MIME type of the file
64 Required argument: File to open
65 Keyword argument MIME_type: MIME type
66 Keyword argument Window_ID: Window to open the file in
67 Keyword argument URL: Use this as a base URL
68 Keyword argument _attributes: AppleEvent attribute dictionary
69 Returns: Window ID of the loaded window. 0 means ShowFile failed, FFFFFFF means that data was not appropriate type to display in the browser.
70 """
71 _code = 'WWW!'
72 _subcode = 'SHWF'
74 aetools.keysubst(_arguments, self._argmap_ShowFile)
75 _arguments['----'] = _object
78 _reply, _arguments, _attributes = self.send(_code, _subcode,
79 _arguments, _attributes)
80 if _arguments.has_key('errn'):
81 raise MacOS.Error, aetools.decodeerror(_arguments)
82 # XXXX Optionally decode result
83 if _arguments.has_key('----'):
84 return _arguments['----']
86 _argmap_parse_anchor = {
87 'relative_to' : 'RELA',
90 def parse_anchor(self, _object, _attributes={}, **_arguments):
91 """parse anchor: Resolves the relative URL
92 Required argument: Main URL
93 Keyword argument relative_to: Relative URL
94 Keyword argument _attributes: AppleEvent attribute dictionary
95 Returns: Parsed URL
96 """
97 _code = 'WWW!'
98 _subcode = 'PRSA'
100 aetools.keysubst(_arguments, self._argmap_parse_anchor)
101 _arguments['----'] = _object
104 _reply, _arguments, _attributes = self.send(_code, _subcode,
105 _arguments, _attributes)
106 if _arguments.has_key('errn'):
107 raise MacOS.Error, aetools.decodeerror(_arguments)
108 # XXXX Optionally decode result
109 if _arguments.has_key('----'):
110 return _arguments['----']
112 _argmap_cancel_progress = {
113 'in_window' : 'WIND',
116 def cancel_progress(self, _object=None, _attributes={}, **_arguments):
117 """cancel progress: Interrupts the download of the document in the given window
118 Required argument: progress ID, obtained from the progress app
119 Keyword argument in_window: window ID of the progress to cancel
120 Keyword argument _attributes: AppleEvent attribute dictionary
122 _code = 'WWW!'
123 _subcode = 'CNCL'
125 aetools.keysubst(_arguments, self._argmap_cancel_progress)
126 _arguments['----'] = _object
129 _reply, _arguments, _attributes = self.send(_code, _subcode,
130 _arguments, _attributes)
131 if _arguments.has_key('errn'):
132 raise MacOS.Error, aetools.decodeerror(_arguments)
133 # XXXX Optionally decode result
134 if _arguments.has_key('----'):
135 return _arguments['----']
137 def find_URL(self, _object, _attributes={}, **_arguments):
138 """find URL: If the file was downloaded by Netscape, you can call FindURL to find out the URL used to download the file.
139 Required argument: File spec
140 Keyword argument _attributes: AppleEvent attribute dictionary
141 Returns: The URL
143 _code = 'WWW!'
144 _subcode = 'FURL'
146 if _arguments: raise TypeError, 'No optional args expected'
147 _arguments['----'] = _object
150 _reply, _arguments, _attributes = self.send(_code, _subcode,
151 _arguments, _attributes)
152 if _arguments.has_key('errn'):
153 raise MacOS.Error, aetools.decodeerror(_arguments)
154 # XXXX Optionally decode result
155 if _arguments.has_key('----'):
156 return _arguments['----']
158 def webActivate(self, _object=None, _attributes={}, **_arguments):
159 """webActivate: Makes Netscape the frontmost application, and selects a given window. This event is here for suite completeness/ cross-platform compatibility only, you should use standard AppleEvents instead.
160 Required argument: window to bring to front
161 Keyword argument _attributes: AppleEvent attribute dictionary
163 _code = 'WWW!'
164 _subcode = 'ACTV'
166 if _arguments: raise TypeError, 'No optional args expected'
167 _arguments['----'] = _object
170 _reply, _arguments, _attributes = self.send(_code, _subcode,
171 _arguments, _attributes)
172 if _arguments.has_key('errn'):
173 raise MacOS.Error, aetools.decodeerror(_arguments)
174 # XXXX Optionally decode result
175 if _arguments.has_key('----'):
176 return _arguments['----']
178 def list_windows(self, _no_object=None, _attributes={}, **_arguments):
179 """list windows: Lists the IDs of all the hypertext windows
180 Keyword argument _attributes: AppleEvent attribute dictionary
181 Returns: List of unique IDs of all the hypertext windows
183 _code = 'WWW!'
184 _subcode = 'LSTW'
186 if _arguments: raise TypeError, 'No optional args expected'
187 if _no_object != None: raise TypeError, 'No direct arg expected'
190 _reply, _arguments, _attributes = self.send(_code, _subcode,
191 _arguments, _attributes)
192 if _arguments.has_key('errn'):
193 raise MacOS.Error, aetools.decodeerror(_arguments)
194 # XXXX Optionally decode result
195 if _arguments.has_key('----'):
196 return _arguments['----']
198 def get_window_info(self, _object=None, _attributes={}, **_arguments):
199 """get window info: Returns the information about the window as a list. Currently the list contains the window title and the URL. You can get the same information using standard Apple Event GetProperty.
200 Required argument: window ID
201 Keyword argument _attributes: AppleEvent attribute dictionary
202 Returns: undocumented, typecode 'list'
204 _code = 'WWW!'
205 _subcode = 'WNFO'
207 if _arguments: raise TypeError, 'No optional args expected'
208 _arguments['----'] = _object
211 _reply, _arguments, _attributes = self.send(_code, _subcode,
212 _arguments, _attributes)
213 if _arguments.has_key('errn'):
214 raise MacOS.Error, aetools.decodeerror(_arguments)
215 # XXXX Optionally decode result
216 if _arguments.has_key('----'):
217 return _arguments['----']
219 def register_URL_echo(self, _object=None, _attributes={}, **_arguments):
220 """register URL echo: Registers the ³echo² application. Each download from now on will be echoed to this application.
221 Required argument: Application signature
222 Keyword argument _attributes: AppleEvent attribute dictionary
224 _code = 'WWW!'
225 _subcode = 'RGUE'
227 if _arguments: raise TypeError, 'No optional args expected'
228 _arguments['----'] = _object
231 _reply, _arguments, _attributes = self.send(_code, _subcode,
232 _arguments, _attributes)
233 if _arguments.has_key('errn'):
234 raise MacOS.Error, aetools.decodeerror(_arguments)
235 # XXXX Optionally decode result
236 if _arguments.has_key('----'):
237 return _arguments['----']
239 def unregister_URL_echo(self, _object, _attributes={}, **_arguments):
240 """unregister URL echo: cancels URL echo
241 Required argument: application signature
242 Keyword argument _attributes: AppleEvent attribute dictionary
244 _code = 'WWW!'
245 _subcode = 'UNRU'
247 if _arguments: raise TypeError, 'No optional args expected'
248 _arguments['----'] = _object
251 _reply, _arguments, _attributes = self.send(_code, _subcode,
252 _arguments, _attributes)
253 if _arguments.has_key('errn'):
254 raise MacOS.Error, aetools.decodeerror(_arguments)
255 # XXXX Optionally decode result
256 if _arguments.has_key('----'):
257 return _arguments['----']
259 _argmap_register_viewer = {
260 'MIME_type' : 'MIME',
261 'with_file_type' : 'FTYP',
264 def register_viewer(self, _object, _attributes={}, **_arguments):
265 """register viewer: Registers an application as a Œspecial¹ viewer for this MIME type. The application will be launched with ViewDoc events
266 Required argument: Application sig
267 Keyword argument MIME_type: MIME type viewer is registering for
268 Keyword argument with_file_type: Mac file type for the downloaded files
269 Keyword argument _attributes: AppleEvent attribute dictionary
270 Returns: TRUE if registration has been successful
272 _code = 'WWW!'
273 _subcode = 'RGVW'
275 aetools.keysubst(_arguments, self._argmap_register_viewer)
276 _arguments['----'] = _object
279 _reply, _arguments, _attributes = self.send(_code, _subcode,
280 _arguments, _attributes)
281 if _arguments.has_key('errn'):
282 raise MacOS.Error, aetools.decodeerror(_arguments)
283 # XXXX Optionally decode result
284 if _arguments.has_key('----'):
285 return _arguments['----']
287 _argmap_unregister_viewer = {
288 'MIME_type' : 'MIME',
291 def unregister_viewer(self, _object, _attributes={}, **_arguments):
292 """unregister viewer: Revert to the old way of handling this MIME type
293 Required argument: Application sig
294 Keyword argument MIME_type: MIME type to be unregistered
295 Keyword argument _attributes: AppleEvent attribute dictionary
296 Returns: TRUE if the event was successful
298 _code = 'WWW!'
299 _subcode = 'UNRV'
301 aetools.keysubst(_arguments, self._argmap_unregister_viewer)
302 _arguments['----'] = _object
305 _reply, _arguments, _attributes = self.send(_code, _subcode,
306 _arguments, _attributes)
307 if _arguments.has_key('errn'):
308 raise MacOS.Error, aetools.decodeerror(_arguments)
309 # XXXX Optionally decode result
310 if _arguments.has_key('----'):
311 return _arguments['----']
313 _argmap_register_protocol = {
314 'for_protocol' : 'PROT',
317 def register_protocol(self, _object=None, _attributes={}, **_arguments):
318 """register protocol: Registers application as a ³handler² for this protocol with a given prefix. The handler will receive ³OpenURL², or if that fails, ³GetURL² event.
319 Required argument: Application sig
320 Keyword argument for_protocol: protocol prefix: ³finger:², ³file²,
321 Keyword argument _attributes: AppleEvent attribute dictionary
322 Returns: TRUE if registration has been successful
324 _code = 'WWW!'
325 _subcode = 'RGPR'
327 aetools.keysubst(_arguments, self._argmap_register_protocol)
328 _arguments['----'] = _object
331 _reply, _arguments, _attributes = self.send(_code, _subcode,
332 _arguments, _attributes)
333 if _arguments.has_key('errn'):
334 raise MacOS.Error, aetools.decodeerror(_arguments)
335 # XXXX Optionally decode result
336 if _arguments.has_key('----'):
337 return _arguments['----']
339 _argmap_unregister_protocol = {
340 'for_protocol' : 'PROT',
343 def unregister_protocol(self, _object=None, _attributes={}, **_arguments):
344 """unregister protocol: reverses the effects of ³register protocol²
345 Required argument: Application sig.
346 Keyword argument for_protocol: protocol prefix. If none, unregister for all protocols
347 Keyword argument _attributes: AppleEvent attribute dictionary
348 Returns: TRUE if successful
350 _code = 'WWW!'
351 _subcode = 'UNRP'
353 aetools.keysubst(_arguments, self._argmap_unregister_protocol)
354 _arguments['----'] = _object
357 _reply, _arguments, _attributes = self.send(_code, _subcode,
358 _arguments, _attributes)
359 if _arguments.has_key('errn'):
360 raise MacOS.Error, aetools.decodeerror(_arguments)
361 # XXXX Optionally decode result
362 if _arguments.has_key('----'):
363 return _arguments['----']
365 _argmap_register_window_close = {
366 'for_window' : 'WIND',
369 def register_window_close(self, _object=None, _attributes={}, **_arguments):
370 """register window close: Netscape will notify registered application when this window closes
371 Required argument: Application signature
372 Keyword argument for_window: window ID
373 Keyword argument _attributes: AppleEvent attribute dictionary
374 Returns: true if successful
376 _code = 'WWW!'
377 _subcode = 'RGWC'
379 aetools.keysubst(_arguments, self._argmap_register_window_close)
380 _arguments['----'] = _object
383 _reply, _arguments, _attributes = self.send(_code, _subcode,
384 _arguments, _attributes)
385 if _arguments.has_key('errn'):
386 raise MacOS.Error, aetools.decodeerror(_arguments)
387 # XXXX Optionally decode result
388 if _arguments.has_key('----'):
389 return _arguments['----']
391 _argmap_unregister_window_close = {
392 'for_window' : 'WIND',
395 def unregister_window_close(self, _object=None, _attributes={}, **_arguments):
396 """unregister window close: Undo for register window close
397 Required argument: Application signature
398 Keyword argument for_window: window ID
399 Keyword argument _attributes: AppleEvent attribute dictionary
400 Returns: true if successful
402 _code = 'WWW!'
403 _subcode = 'UNRC'
405 aetools.keysubst(_arguments, self._argmap_unregister_window_close)
406 _arguments['----'] = _object
409 _reply, _arguments, _attributes = self.send(_code, _subcode,
410 _arguments, _attributes)
411 if _arguments.has_key('errn'):
412 raise MacOS.Error, aetools.decodeerror(_arguments)
413 # XXXX Optionally decode result
414 if _arguments.has_key('----'):
415 return _arguments['----']