blob: 0d54626a6f38b6e91fa2090f6c3b05e4fe940ac2 [file] [log] [blame]
Fred Drakec817e271998-08-10 18:40:22 +00001\section{\module{ic} ---
Fred Drakef6863c11999-03-02 16:37:17 +00002 Access to Internet Config}
3
Fred Drakefe7f3bc1998-07-23 17:55:31 +00004\declaremodule{builtin}{ic}
Fred Drakef6863c11999-03-02 16:37:17 +00005 \platform{Mac}
Fred Drake5ee808d1998-08-07 17:37:15 +00006\modulesynopsis{Access to Internet Config.}
Fred Drakefe7f3bc1998-07-23 17:55:31 +00007
Guido van Rossume229d861997-08-18 15:14:26 +00008
Fred Drake6de28bd1999-03-04 19:00:26 +00009This module provides access to Macintosh Internet
10Config\index{Internet Config} package,
Guido van Rossume229d861997-08-18 15:14:26 +000011which stores preferences for Internet programs such as mail address,
12default homepage, etc. Also, Internet Config contains an elaborate set
13of mappings from Macintosh creator/type codes to foreign filename
14extensions plus information on how to transfer files (binary, ascii,
Fred Drakeebce3701998-03-14 22:22:14 +000015etc).
Guido van Rossume229d861997-08-18 15:14:26 +000016
Fred Drakeebce3701998-03-14 22:22:14 +000017There is a low-level companion module
18\module{icglue}\refbimodindex{icglue} which provides the basic
19Internet Config access functionality. This low-level module is not
Guido van Rossume229d861997-08-18 15:14:26 +000020documented, but the docstrings of the routines document the parameters
Fred Drakeebce3701998-03-14 22:22:14 +000021and the routine names are the same as for the Pascal or \C{} API to
22Internet Config, so the standard IC programmers' documentation can be
Guido van Rossume229d861997-08-18 15:14:26 +000023used if this module is needed.
24
Fred Drakeebce3701998-03-14 22:22:14 +000025The \module{ic} module defines the \exception{error} exception and
26symbolic names for all error codes Internet Config can produce; see
27the source for details.
Guido van Rossume229d861997-08-18 15:14:26 +000028
Fred Drakeebce3701998-03-14 22:22:14 +000029\begin{excdesc}{error}
30Exception raised on errors in the \module{ic} module.
31\end{excdesc}
Guido van Rossume229d861997-08-18 15:14:26 +000032
Fred Drakeebce3701998-03-14 22:22:14 +000033
Fred Drake5ab55031998-04-07 22:01:33 +000034The \module{ic} module defines the following class and function:
Fred Drakeebce3701998-03-14 22:22:14 +000035
Fred Drake5ab55031998-04-07 22:01:33 +000036\begin{classdesc}{IC}{\optional{signature\optional{, ic}}}
Fred Drake41788db1998-04-04 06:23:02 +000037Create an internet config object. The signature is a 4-character creator
Guido van Rossume229d861997-08-18 15:14:26 +000038code of the current application (default \code{'Pyth'}) which may
39influence some of ICs settings. The optional \var{ic} argument is a
Fred Drakeebce3701998-03-14 22:22:14 +000040low-level \code{icglue.icinstance} created beforehand, this may be
41useful if you want to get preferences from a different config file,
42etc.
Fred Drake5ab55031998-04-07 22:01:33 +000043\end{classdesc}
Guido van Rossume229d861997-08-18 15:14:26 +000044
Fred Drakeebce3701998-03-14 22:22:14 +000045\begin{funcdesc}{launchurl}{url\optional{, hint}}
46\funcline{parseurl}{data\optional{, start\optional{, end\optional{, hint}}}}
47\funcline{mapfile}{file}
48\funcline{maptypecreator}{type, creator\optional{, filename}}
49\funcline{settypecreator}{file}
Guido van Rossume229d861997-08-18 15:14:26 +000050These functions are ``shortcuts'' to the methods of the same name,
51described below.
52\end{funcdesc}
53
54
Fred Drake5ab55031998-04-07 22:01:33 +000055\subsection{IC Objects}
Guido van Rossume229d861997-08-18 15:14:26 +000056
Fred Drake5ab55031998-04-07 22:01:33 +000057\class{IC} objects have a mapping interface, hence to obtain the mail
58address you simply get \code{\var{ic}['MailAddress']}. Assignment also
59works, and changes the option in the configuration file.
Guido van Rossume229d861997-08-18 15:14:26 +000060
61The module knows about various datatypes, and converts the internal IC
Fred Drake5ab55031998-04-07 22:01:33 +000062representation to a ``logical'' Python data structure. Running the
Fred Drakeebce3701998-03-14 22:22:14 +000063\module{ic} module standalone will run a test program that lists all
Guido van Rossume229d861997-08-18 15:14:26 +000064keys and values in your IC database, this will have to server as
65documentation.
66
67If the module does not know how to represent the data it returns an
Fred Drakeebce3701998-03-14 22:22:14 +000068instance of the \code{ICOpaqueData} type, with the raw data in its
Fred Drake41788db1998-04-04 06:23:02 +000069\member{data} attribute. Objects of this type are also acceptable values
Guido van Rossume229d861997-08-18 15:14:26 +000070for assignment.
71
Fred Drake5ab55031998-04-07 22:01:33 +000072Besides the dictionary interface, \class{IC} objects have the
73following methods:
Guido van Rossume229d861997-08-18 15:14:26 +000074
Guido van Rossume229d861997-08-18 15:14:26 +000075
Fred Drake5ab55031998-04-07 22:01:33 +000076\begin{methoddesc}{launchurl}{url\optional{, hint}}
Guido van Rossume229d861997-08-18 15:14:26 +000077Parse the given URL, lauch the correct application and pass it the
78URL. The optional \var{hint} can be a scheme name such as
Fred Drakeebce3701998-03-14 22:22:14 +000079\code{'mailto:'}, in which case incomplete URLs are completed with this
80scheme. If \var{hint} is not provided, incomplete URLs are invalid.
Fred Drake5ab55031998-04-07 22:01:33 +000081\end{methoddesc}
Guido van Rossume229d861997-08-18 15:14:26 +000082
Fred Drake5ab55031998-04-07 22:01:33 +000083\begin{methoddesc}{parseurl}{data\optional{, start\optional{, end\optional{, hint}}}}
Guido van Rossume229d861997-08-18 15:14:26 +000084Find an URL somewhere in \var{data} and return start position, end
85position and the URL. The optional \var{start} and \var{end} can be
86used to limit the search, so for instance if a user clicks in a long
87textfield you can pass the whole textfield and the click-position in
88\var{start} and this routine will return the whole URL in which the
Fred Drake41788db1998-04-04 06:23:02 +000089user clicked. As above, \var{hint} is an optional scheme used to
90complete incomplete URLs.
Fred Drake5ab55031998-04-07 22:01:33 +000091\end{methoddesc}
Guido van Rossume229d861997-08-18 15:14:26 +000092
Fred Drake5ab55031998-04-07 22:01:33 +000093\begin{methoddesc}{mapfile}{file}
Guido van Rossume229d861997-08-18 15:14:26 +000094Return the mapping entry for the given \var{file}, which can be passed
Fred Drake41788db1998-04-04 06:23:02 +000095as either a filename or an \function{macfs.FSSpec()} result, and which
96need not exist.
Guido van Rossume229d861997-08-18 15:14:26 +000097
Fred Drakef6863c11999-03-02 16:37:17 +000098The mapping entry is returned as a tuple \code{(\var{version},
Fred Drake671fe9d1997-12-29 18:53:31 +000099\var{type}, \var{creator}, \var{postcreator}, \var{flags},
100\var{extension}, \var{appname}, \var{postappname}, \var{mimetype},
Fred Drakef6863c11999-03-02 16:37:17 +0000101\var{entryname})}, where \var{version} is the entry version
Fred Drake41788db1998-04-04 06:23:02 +0000102number, \var{type} is the 4-character filetype, \var{creator} is the
1034-character creator type, \var{postcreator} is the 4-character creator
104code of an
Guido van Rossume229d861997-08-18 15:14:26 +0000105optional application to post-process the file after downloading,
106\var{flags} are various bits specifying whether to transfer in binary
107or ascii and such, \var{extension} is the filename extension for this
108file type, \var{appname} is the printable name of the application to
109which this file belongs, \var{postappname} is the name of the
110postprocessing application, \var{mimetype} is the MIME type of this
111file and \var{entryname} is the name of this entry.
Fred Drake5ab55031998-04-07 22:01:33 +0000112\end{methoddesc}
Guido van Rossume229d861997-08-18 15:14:26 +0000113
Fred Drake5ab55031998-04-07 22:01:33 +0000114\begin{methoddesc}{maptypecreator}{type, creator\optional{, filename}}
Fred Drake41788db1998-04-04 06:23:02 +0000115Return the mapping entry for files with given 4-character \var{type} and
Guido van Rossume229d861997-08-18 15:14:26 +0000116\var{creator} codes. The optional \var{filename} may be specified to
117further help finding the correct entry (if the creator code is
118\code{'????'}, for instance).
119
120The mapping entry is returned in the same format as for \var{mapfile}.
Fred Drake5ab55031998-04-07 22:01:33 +0000121\end{methoddesc}
Guido van Rossume229d861997-08-18 15:14:26 +0000122
Fred Drake5ab55031998-04-07 22:01:33 +0000123\begin{methoddesc}{settypecreator}{file}
Guido van Rossume229d861997-08-18 15:14:26 +0000124Given an existing \var{file}, specified either as a filename or as an
Fred Drake41788db1998-04-04 06:23:02 +0000125\function{macfs.FSSpec()} result, set its creator and type correctly based
Fred Drakeebce3701998-03-14 22:22:14 +0000126on its extension. The finder is told about the change, so the finder
127icon will be updated quickly.
Fred Drake5ab55031998-04-07 22:01:33 +0000128\end{methoddesc}