blob: c8caa44b08fec1bdbaea0b2b4f7ca1176d9dac34 [file] [log] [blame]
Fred Drakec817e271998-08-10 18:40:22 +00001\section{\module{ic} ---
2 Access to Internet Config.}
Fred Drakefe7f3bc1998-07-23 17:55:31 +00003\declaremodule{builtin}{ic}
4
Fred Drake5ee808d1998-08-07 17:37:15 +00005\modulesynopsis{Access to Internet Config.}
Fred Drakefe7f3bc1998-07-23 17:55:31 +00006
Guido van Rossume229d861997-08-18 15:14:26 +00007
Guido van Rossume229d861997-08-18 15:14:26 +00008
Fred Drakeebce3701998-03-14 22:22:14 +00009This module provides access to Macintosh Internet Config package,
Guido van Rossume229d861997-08-18 15:14:26 +000010which stores preferences for Internet programs such as mail address,
11default homepage, etc. Also, Internet Config contains an elaborate set
12of mappings from Macintosh creator/type codes to foreign filename
13extensions plus information on how to transfer files (binary, ascii,
Fred Drakeebce3701998-03-14 22:22:14 +000014etc).
Guido van Rossume229d861997-08-18 15:14:26 +000015
Fred Drakeebce3701998-03-14 22:22:14 +000016There is a low-level companion module
17\module{icglue}\refbimodindex{icglue} which provides the basic
18Internet Config access functionality. This low-level module is not
Guido van Rossume229d861997-08-18 15:14:26 +000019documented, but the docstrings of the routines document the parameters
Fred Drakeebce3701998-03-14 22:22:14 +000020and the routine names are the same as for the Pascal or \C{} API to
21Internet Config, so the standard IC programmers' documentation can be
Guido van Rossume229d861997-08-18 15:14:26 +000022used if this module is needed.
23
Fred Drakeebce3701998-03-14 22:22:14 +000024The \module{ic} module defines the \exception{error} exception and
25symbolic names for all error codes Internet Config can produce; see
26the source for details.
Guido van Rossume229d861997-08-18 15:14:26 +000027
Fred Drakeebce3701998-03-14 22:22:14 +000028\begin{excdesc}{error}
29Exception raised on errors in the \module{ic} module.
30\end{excdesc}
Guido van Rossume229d861997-08-18 15:14:26 +000031
Fred Drakeebce3701998-03-14 22:22:14 +000032
Fred Drake5ab55031998-04-07 22:01:33 +000033The \module{ic} module defines the following class and function:
Fred Drakeebce3701998-03-14 22:22:14 +000034
Fred Drake5ab55031998-04-07 22:01:33 +000035\begin{classdesc}{IC}{\optional{signature\optional{, ic}}}
Fred Drake41788db1998-04-04 06:23:02 +000036Create an internet config object. The signature is a 4-character creator
Guido van Rossume229d861997-08-18 15:14:26 +000037code of the current application (default \code{'Pyth'}) which may
38influence some of ICs settings. The optional \var{ic} argument is a
Fred Drakeebce3701998-03-14 22:22:14 +000039low-level \code{icglue.icinstance} created beforehand, this may be
40useful if you want to get preferences from a different config file,
41etc.
Fred Drake5ab55031998-04-07 22:01:33 +000042\end{classdesc}
Guido van Rossume229d861997-08-18 15:14:26 +000043
Fred Drakeebce3701998-03-14 22:22:14 +000044\begin{funcdesc}{launchurl}{url\optional{, hint}}
45\funcline{parseurl}{data\optional{, start\optional{, end\optional{, hint}}}}
46\funcline{mapfile}{file}
47\funcline{maptypecreator}{type, creator\optional{, filename}}
48\funcline{settypecreator}{file}
Guido van Rossume229d861997-08-18 15:14:26 +000049These functions are ``shortcuts'' to the methods of the same name,
50described below.
51\end{funcdesc}
52
53
Fred Drake5ab55031998-04-07 22:01:33 +000054\subsection{IC Objects}
Guido van Rossume229d861997-08-18 15:14:26 +000055
Fred Drake5ab55031998-04-07 22:01:33 +000056\class{IC} objects have a mapping interface, hence to obtain the mail
57address you simply get \code{\var{ic}['MailAddress']}. Assignment also
58works, and changes the option in the configuration file.
Guido van Rossume229d861997-08-18 15:14:26 +000059
60The module knows about various datatypes, and converts the internal IC
Fred Drake5ab55031998-04-07 22:01:33 +000061representation to a ``logical'' Python data structure. Running the
Fred Drakeebce3701998-03-14 22:22:14 +000062\module{ic} module standalone will run a test program that lists all
Guido van Rossume229d861997-08-18 15:14:26 +000063keys and values in your IC database, this will have to server as
64documentation.
65
66If the module does not know how to represent the data it returns an
Fred Drakeebce3701998-03-14 22:22:14 +000067instance of the \code{ICOpaqueData} type, with the raw data in its
Fred Drake41788db1998-04-04 06:23:02 +000068\member{data} attribute. Objects of this type are also acceptable values
Guido van Rossume229d861997-08-18 15:14:26 +000069for assignment.
70
Fred Drake5ab55031998-04-07 22:01:33 +000071Besides the dictionary interface, \class{IC} objects have the
72following methods:
Guido van Rossume229d861997-08-18 15:14:26 +000073
Guido van Rossume229d861997-08-18 15:14:26 +000074
Fred Drake5ab55031998-04-07 22:01:33 +000075\begin{methoddesc}{launchurl}{url\optional{, hint}}
Guido van Rossume229d861997-08-18 15:14:26 +000076Parse the given URL, lauch the correct application and pass it the
77URL. The optional \var{hint} can be a scheme name such as
Fred Drakeebce3701998-03-14 22:22:14 +000078\code{'mailto:'}, in which case incomplete URLs are completed with this
79scheme. If \var{hint} is not provided, incomplete URLs are invalid.
Fred Drake5ab55031998-04-07 22:01:33 +000080\end{methoddesc}
Guido van Rossume229d861997-08-18 15:14:26 +000081
Fred Drake5ab55031998-04-07 22:01:33 +000082\begin{methoddesc}{parseurl}{data\optional{, start\optional{, end\optional{, hint}}}}
Guido van Rossume229d861997-08-18 15:14:26 +000083Find an URL somewhere in \var{data} and return start position, end
84position and the URL. The optional \var{start} and \var{end} can be
85used to limit the search, so for instance if a user clicks in a long
86textfield you can pass the whole textfield and the click-position in
87\var{start} and this routine will return the whole URL in which the
Fred Drake41788db1998-04-04 06:23:02 +000088user clicked. As above, \var{hint} is an optional scheme used to
89complete incomplete URLs.
Fred Drake5ab55031998-04-07 22:01:33 +000090\end{methoddesc}
Guido van Rossume229d861997-08-18 15:14:26 +000091
Fred Drake5ab55031998-04-07 22:01:33 +000092\begin{methoddesc}{mapfile}{file}
Guido van Rossume229d861997-08-18 15:14:26 +000093Return the mapping entry for the given \var{file}, which can be passed
Fred Drake41788db1998-04-04 06:23:02 +000094as either a filename or an \function{macfs.FSSpec()} result, and which
95need not exist.
Guido van Rossume229d861997-08-18 15:14:26 +000096
Fred Drake671fe9d1997-12-29 18:53:31 +000097The mapping entry is returned as a tuple \code{(}\var{version},
98\var{type}, \var{creator}, \var{postcreator}, \var{flags},
99\var{extension}, \var{appname}, \var{postappname}, \var{mimetype},
100\var{entryname}\code{)}, where \var{version} is the entry version
Fred Drake41788db1998-04-04 06:23:02 +0000101number, \var{type} is the 4-character filetype, \var{creator} is the
1024-character creator type, \var{postcreator} is the 4-character creator
103code of an
Guido van Rossume229d861997-08-18 15:14:26 +0000104optional application to post-process the file after downloading,
105\var{flags} are various bits specifying whether to transfer in binary
106or ascii and such, \var{extension} is the filename extension for this
107file type, \var{appname} is the printable name of the application to
108which this file belongs, \var{postappname} is the name of the
109postprocessing application, \var{mimetype} is the MIME type of this
110file and \var{entryname} is the name of this entry.
Fred Drake5ab55031998-04-07 22:01:33 +0000111\end{methoddesc}
Guido van Rossume229d861997-08-18 15:14:26 +0000112
Fred Drake5ab55031998-04-07 22:01:33 +0000113\begin{methoddesc}{maptypecreator}{type, creator\optional{, filename}}
Fred Drake41788db1998-04-04 06:23:02 +0000114Return the mapping entry for files with given 4-character \var{type} and
Guido van Rossume229d861997-08-18 15:14:26 +0000115\var{creator} codes. The optional \var{filename} may be specified to
116further help finding the correct entry (if the creator code is
117\code{'????'}, for instance).
118
119The mapping entry is returned in the same format as for \var{mapfile}.
Fred Drake5ab55031998-04-07 22:01:33 +0000120\end{methoddesc}
Guido van Rossume229d861997-08-18 15:14:26 +0000121
Fred Drake5ab55031998-04-07 22:01:33 +0000122\begin{methoddesc}{settypecreator}{file}
Guido van Rossume229d861997-08-18 15:14:26 +0000123Given an existing \var{file}, specified either as a filename or as an
Fred Drake41788db1998-04-04 06:23:02 +0000124\function{macfs.FSSpec()} result, set its creator and type correctly based
Fred Drakeebce3701998-03-14 22:22:14 +0000125on its extension. The finder is told about the change, so the finder
126icon will be updated quickly.
Fred Drake5ab55031998-04-07 22:01:33 +0000127\end{methoddesc}