APTR handle = OpenConnection(STRPTR address, int port, struct hwTagList *tags);
OpenConnection()
implementation has to check whether your plugin wants to handle this connection or not. If
your plugin wants to handle this connection, your OpenConnection()
implementation needs to
open it and return a handle, which will be used to refer to this connection by all other
functions of your network adapter plugin, back to Hollywood. If your plugin doesn't want
to handle the connection, your OpenConnection()
implementation has to return NULL
. The handle
returned by this function is an opaque data type only your plugin knows about. Hollywood will
just use this handle to refer to the connection.
The address
and port
parameters will contain the address and port number of the server to
connect to. Note that address
could be an IP address in IPv4 or IPv6 notation or a host name.
Starting with Hollywood 9.0, OpenConnection()
can also be used to implement complete protocol
handling. This makes it possible to add support for new protocols to Hollywood's DownloadFile()
and UploadFile()
functions. By default, those functions only support HTTP and FTP. If you want
OpenConnection()
to completely take over protocol handling, you have to ignore what is passed in
address
and port
because it contains no protocol information but just the address and port of
a remote machine. Instead, you have to examine the URL that is passed in the new HWOPENCONNTAG_URL
tag. Hollywood will pass a full URL, i.e. including the protocol identifier, in that tag. If the
URL contains a protocol you would like to handle, you'll have to set the HWOPENCONNTAG_CUSTOMPROTOCOL
tag to True
then. See below for details.
Additionally, Hollywood might pass a tag list containing further parameters to OpenConnection()
.
The following tags can currently be set:
HWOPENCONNTAG_SSL:
DownloadFile()
or OpenConnection()
support a tag named SSL
that
can be set to indicate that the connection should be established using SSL. If this tag
is set to True
, the iData
member of HWOPENCONNTAG_SSL
will also be set to True
. How your
plugin interprets this tag, is up to you.
HWOPENCONNTAG_TIMEOUT:
iData
member will tell your implementation of
OpenConnection()
to maximum amount of time that should be used to try to connect to the
server. This timeout value will be specified in milliseconds.
HWOPENCONNTAG_URL:
pData
member of this tag will be set to a string that contains the full URL the user has
passed to DownloadFile()
or UploadFile()
. This tag is important if your OpenConnection()
implementation wants to take over protocol handling completely. In that case, you can ignore
what is passed in the address
and port
arguments and just use the URL specified here. Note
that you have to set HWOPENCONNTAG_CUSTOMPROTOCOL
to True
to signal to Hollywood that you
want to take over all protocol handling (see below) (V9.0).
HWOPENCONNTAG_CUSTOMPROTOCOL:
pData
member of this tag will be set to a pointer to an int
. You have to write True
to this int
pointer to indicate that your plugin wants to do all protocol handling on its
own. In that case, Hollywood won't perform any protocol I/O with your connection but it will
just expect your ReceiveData() function to provide the data to be
downloaded, or, in case HWOPENCONNTAG_UPLOAD
has been set to True
, it will just send the
data that should be uploaded by calling SendData(). Note that if you
set this tag to True
, your GetConnectionInfo() function should
be prepared to return some statistical information about the connection, like the total
number of bytes to be transferred. See GetConnectionInfo for details. (V9.0)
HWOPENCONNTAG_UPLOAD:
True
, Hollywood might still call your
ReceiveData() function as well because protocols like HTTP often
return HTML pages after finishing the upload. (V9.0)
HWOPENCONNTAG_UPLOADSIZE:
pData
member of this tag will be set to a pointer to a DOSINT64
containing
the size in bytes of the data to be uploaded. (V9.0)
HWOPENCONNTAG_USERNAME:
pData
member of this tag will point to a string containing the user name to
be used for protocol authentification. (V9.0)
HWOPENCONNTAG_PASSWORD:
pData
member of this tag will point to a string containing the password to
be used for protocol authentification. (V9.0)
HWOPENCONNTAG_FOLLOWLOCATION:
True
if redirections to a new address should be allowed
or False
if they should be forbidden. Redirections to new addresses are often requested
by HTTP servers. (V9.0)
HWOPENCONNTAG_TEXTMODE:
True
if the transfers should be done in text (ASCII)
mode. FTP servers typically distinguish between text and binary transfer modes. (V9.0)
HWOPENCONNTAG_MULTIPART:
pData
member of this tag may be set to a struct hwMultiPartInfo
pointer containing a list of multiple parts to be uploaded to a HTTP server by using the
POST
method.
The struct hwMultiPartInfo
looks like this:
struct hwMultiPartInfo { struct hwMultiPartInfo *Succ; STRPTR Name; STRPTR MIMEType; STRPTR DestFile; STRPTR Data; APTR FileHandle; DOSINT64 Length; }; |
Here is a description of the individual structure members:
Succ:
Name:
MIMEType:
NULL
.
DestFile:
NULL
, then the part object shouldn't be uploaded as a file.
Data:
FileHandle
will always be set. If Data
is set, FileHandle
will be NULL
and
vice versa. The size of the data to be uploaded will be specified in the
Length
member. If DestFile
is non-NULL
, the data must be uploaded as a file, otherwise
it must be uploaded as form data.
FileHandle:
DestFile
will contain the name to use for that. The Length
member
will contain the file size. If FileHandle
is set, Data
will always be NULL
and
vice versa.
Length:
Data
or the
FileHandle
members (see above).
Note that HWOPENCONNTAG_UPLOADSIZE
won't contain a valid size when using multi-part
uploads.
There is also the HWOPENCONNTAG_POST
tag which Hollywood can also use to specify data
to be uploaded to a HTTP server (see below). HWOPENCONNTAG_POST
and HWOPENCONNTAG_MULTIPART
are mutually exclusive. (V9.0)
HWOPENCONNTAG_PROXY:
pData
tag member. (V9.0)
HWOPENCONNTAG_USERAGENT:
pData
tag member.
(V9.0)
HWOPENCONNTAG_CUSTOMHEADERS:
pData
tag member
and they will be separated by \r\n characters (carriage return and line feed). (V9.0)
HWOPENCONNTAG_VERBOSE:
True
if the user has requested verbose mode by setting
the Verbose
tag in DownloadFile()
or UploadFile()
to True
. In verbose mode, your plugin
may choose to log some information about the connection to Hollywood's output device. (V9.0)
HWOPENCONNTAG_POST:
pData
member of this tag will contain data to
be posted to a HTTP server. Note that this isn't limited to text but can also contain
binary data. The size of the data to be posted will be specified in the HWOPENCONNTAG_POSTSIZE
tag and the type will be specified in the HWOPENCONNTAG_POSTTYPE
tag. This tag is an
alternative to the HWOPENCONNTAG_MULTIPART
tag which is used for multi-part messages.
HWOPENCONNTAG_POST
and HWOPENCONNTAG_MULTIPART
are mutually exclusive. (V9.0)
HWOPENCONNTAG_POSTSIZE:
HWOPENCONNTAG_POST
has been set, this will contain the size in bytes of the data
to be uploaded. Hollywood will set the pData
member of this tag to a pointer to a
DOSINT64
that contains the size in bytes of the data to be uploaded. (V9.0)
HWOPENCONNTAG_POSTTYPE:
HWOPENCONNTAG_POST
has been set, the pData
member of this tag will contain a
string describing the MIME type of the data to be uploaded. (V9.0)
HWOPENCONNTAG_FAILONERROR:
True
if the connection should fail in case the remote
file doesn't exist. For example, when requesting a non-existing file from a HTTP server,
the server will still return data (a 404 error page) instead of failing. If Hollywood
wants your plugin to fail in such cases and not return a 404 error page, it will set
HWOPENCONNTAG_FAILONERROR
to True
. (V9.1)
HWOPENCONNTAG_ENCODED:
True
if the URL passed in HWOPENCONNTAG_URL
is already
escaped. If this tag is set to False
or if it isn't present at all, the URL passed in
HWOPENCONNTAG_URL
is unescaped and might need escaping before it can be parsed. (V9.1)
HWOPENCONNTAG_USERTAGS:
pData
will point to a struct hwUserTagList
containing
a list of user tags passed by the Hollywood script. User tags are a way of
passing additional information from Hollywood scripts to plugin functions.
See User tags for details. (V10.0)
NULL
NULL
if your plugin
doesn't want to handle this connection