libmacic.tex 5.2 KB
Newer Older
1
\section{Standard Module \sectcode{ic}}
2
\label{module-ic}
3 4 5
\bimodindex{ic}


Fred Drake's avatar
Fred Drake committed
6
This module provides access to Macintosh Internet Config package,
7 8 9 10
which stores preferences for Internet programs such as mail address,
default homepage, etc. Also, Internet Config contains an elaborate set
of mappings from Macintosh creator/type codes to foreign filename
extensions plus information on how to transfer files (binary, ascii,
Fred Drake's avatar
Fred Drake committed
11
etc).
12

Fred Drake's avatar
Fred Drake committed
13 14 15
There is a low-level companion module
\module{icglue}\refbimodindex{icglue} which provides the basic
Internet Config access functionality.  This low-level module is not
16
documented, but the docstrings of the routines document the parameters
Fred Drake's avatar
Fred Drake committed
17 18
and the routine names are the same as for the Pascal or \C{} API to
Internet Config, so the standard IC programmers' documentation can be
19 20
used if this module is needed.

Fred Drake's avatar
Fred Drake committed
21 22 23
The \module{ic} module defines the \exception{error} exception and
symbolic names for all error codes Internet Config can produce; see
the source for details.
24

Fred Drake's avatar
Fred Drake committed
25 26 27
\begin{excdesc}{error}
Exception raised on errors in the \module{ic} module.
\end{excdesc}
28

Fred Drake's avatar
Fred Drake committed
29 30 31 32

The \module{ic} module defines the following functions:

\begin{funcdesc}{IC}{\optional{signature\optional{, ic}}}
33 34 35
Create an internet config object. The signature is a 4-char creator
code of the current application (default \code{'Pyth'}) which may
influence some of ICs settings. The optional \var{ic} argument is a
Fred Drake's avatar
Fred Drake committed
36 37 38
low-level \code{icglue.icinstance} created beforehand, this may be
useful if you want to get preferences from a different config file,
etc.
39 40
\end{funcdesc}

Fred Drake's avatar
Fred Drake committed
41 42 43 44 45
\begin{funcdesc}{launchurl}{url\optional{, hint}}
\funcline{parseurl}{data\optional{, start\optional{, end\optional{, hint}}}}
\funcline{mapfile}{file}
\funcline{maptypecreator}{type, creator\optional{, filename}}
\funcline{settypecreator}{file}
46 47 48 49 50 51 52 53
These functions are ``shortcuts'' to the methods of the same name,
described below.
\end{funcdesc}


\subsection{IC objects}

IC objects have a mapping interface, hence to obtain the mail address
Fred Drake's avatar
Fred Drake committed
54 55
you simply get \code{\var{ic}['MailAddress']}. Assignment also works,
and changes the option in the configuration file.
56 57 58

The module knows about various datatypes, and converts the internal IC
representation to a ``logical'' python datastructure. Running the
Fred Drake's avatar
Fred Drake committed
59
\module{ic} module standalone will run a test program that lists all
60 61 62 63
keys and values in your IC database, this will have to server as
documentation.

If the module does not know how to represent the data it returns an
Fred Drake's avatar
Fred Drake committed
64
instance of the \code{ICOpaqueData} type, with the raw data in its
65 66 67 68 69
\var{data} attribute. Objects of this type are also acceptable values
for assignment.

Besides the dictionary interface IC objects have the following methods:

Fred Drake's avatar
Fred Drake committed
70
\setindexsubitem{(IC attribute)}
71

Fred Drake's avatar
Fred Drake committed
72
\begin{funcdesc}{launchurl}{url\optional{, hint}}
73 74
Parse the given URL, lauch the correct application and pass it the
URL. The optional \var{hint} can be a scheme name such as
Fred Drake's avatar
Fred Drake committed
75 76
\code{'mailto:'}, in which case incomplete URLs are completed with this
scheme.  If \var{hint} is not provided, incomplete URLs are invalid.
77 78
\end{funcdesc}

Fred Drake's avatar
Fred Drake committed
79
\begin{funcdesc}{parseurl}{data\optional{, start\optional{, end\optional{, hint}}}}
80 81 82 83 84
Find an URL somewhere in \var{data} and return start position, end
position and the URL. The optional \var{start} and \var{end} can be
used to limit the search, so for instance if a user clicks in a long
textfield you can pass the whole textfield and the click-position in
\var{start} and this routine will return the whole URL in which the
Fred Drake's avatar
Fred Drake committed
85
user clicked.  \var{Hint} is again an optional scheme used to complete
86 87 88 89 90
incomplete URLs.
\end{funcdesc}

\begin{funcdesc}{mapfile}{file}
Return the mapping entry for the given \var{file}, which can be passed
Fred Drake's avatar
Fred Drake committed
91 92
as either a filename or an \code{macfs.FSSpec} object, and which need
not exist.
93

94 95 96 97
The mapping entry is returned as a tuple \code{(}\var{version},
\var{type}, \var{creator}, \var{postcreator}, \var{flags},
\var{extension}, \var{appname}, \var{postappname}, \var{mimetype},
\var{entryname}\code{)}, where \var{version} is the entry version
98 99 100 101 102 103 104 105 106 107 108
number, \var{type} is the 4-char filetype, \var{creator} is the 4-char
creator type, \var{postcreator} is the 4-char creator code of an
optional application to post-process the file after downloading,
\var{flags} are various bits specifying whether to transfer in binary
or ascii and such, \var{extension} is the filename extension for this
file type, \var{appname} is the printable name of the application to
which this file belongs, \var{postappname} is the name of the
postprocessing application, \var{mimetype} is the MIME type of this
file and \var{entryname} is the name of this entry.
\end{funcdesc}

Fred Drake's avatar
Fred Drake committed
109
\begin{funcdesc}{maptypecreator}{type, creator\optional{, filename}}
110 111 112 113 114 115 116 117 118 119
Return the mapping entry for files with given 4-char \var{type} and
\var{creator} codes. The optional \var{filename} may be specified to
further help finding the correct entry (if the creator code is
\code{'????'}, for instance).

The mapping entry is returned in the same format as for \var{mapfile}.
\end{funcdesc}

\begin{funcdesc}{settypecreator}{file}
Given an existing \var{file}, specified either as a filename or as an
Fred Drake's avatar
Fred Drake committed
120 121 122
\code{macfs.FSSpec} record, set its creator and type correctly based
on its extension.  The finder is told about the change, so the finder
icon will be updated quickly.
123
\end{funcdesc}