1/*
2 * Copyright (C) 2006, 2007, 2008 Apple Inc.  All rights reserved.
3 *               2007 Apple Inc.  All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#ifndef DO_NO_IMPORTS
28import "oaidl.idl";
29import "ocidl.idl";
30import "IWebError.idl";
31import "IWebMutableURLRequest.idl";
32import "IWebURLAuthenticationChallenge.idl";
33import "IWebURLResponse.idl";
34import "IWebURLRequest.idl";
35#endif
36
37interface IWebDownloadDelegate;
38interface IWebError;
39interface IWebMutableURLRequest;
40interface IWebURLAuthenticationChallenge;
41interface IWebURLRequest;
42interface IWebURLResponse;
43
44/*!
45    @class WebDownload
46    @discussion A WebDownload works just like an NSURLDownload, with
47    one extra feature: if you do not implement the
48    authentication-related delegate methods, it will automatically
49    prompt for authentication using the standard WebKit authentication
50    panel, as either a sheet or window. It provides no extra methods,
51    but does have one additional delegate method.
52*/
53
54[
55    object,
56    oleautomation,
57    hidden,
58    uuid(65EFE83B-A9E4-4516-8F3B-BAA25DA90FFD),
59    pointer_default(unique)
60]
61interface IWebDownload : IUnknown
62{
63    /*
64        + (BOOL)canResumeDownloadDecodedWithEncodingMIMEType:(NSString *)MIMEType
65    */
66    HRESULT canResumeDownloadDecodedWithEncodingMIMEType([in] BSTR mimeType, [out, retval] BOOL* result);
67
68    /*
69        - (void)cancel
70    */
71    HRESULT cancel();
72
73    /*
74        - (void)cancelForResume();
75    */
76    HRESULT cancelForResume();
77
78    /*
79        - (void)start
80    */
81    HRESULT start();
82
83    /*
84        - (BOOL)deletesFileUponFailure
85    */
86    HRESULT deletesFileUponFailure([out, retval] BOOL* result);
87
88    /*
89        - (id)initWithRequest:(NSURLRequest *)request delegate:(id)delegate
90    */
91    HRESULT initWithRequest([in] IWebURLRequest* request, [in] IWebDownloadDelegate* delegate);
92
93    /*
94        - (id)initWithResumeData:(NSData *)resumeData delegate:(id)delegate path:(NSString *)path
95    */
96    HRESULT initToResumeWithBundle([in] BSTR bundlePath, [in] IWebDownloadDelegate* delegate);
97
98    /*
99        - (String)bundlePathForTargetPath:(String)targetPath
100    */
101    HRESULT bundlePathForTargetPath([in] BSTR target, [out, retval] BSTR* bundle);
102
103    /*
104        - (NSURLRequest *)request
105    */
106    HRESULT request([out, retval] IWebURLRequest** request);
107
108    /*
109        - (void)setDeletesFileUponFailure:(BOOL)deletesFileUponFailure
110    */
111    HRESULT setDeletesFileUponFailure([in] BOOL deletesFileUponFailure);
112
113    /*
114        - (void)setDestination:(NSString *)path allowOverwrite:(BOOL)allowOverwrite
115    */
116    HRESULT setDestination([in] BSTR path, [in] BOOL allowOverwrite);
117}
118
119
120/*!
121    @protocol WebDownloadDelegate
122    @discussion The WebDownloadDelegate delegate has one extra method used to choose
123    the right window when automatically prompting with a sheet.
124    @interface NSObject (WebDownloadDelegate)
125*/
126
127[
128    object,
129    oleautomation,
130    uuid(16A32AE6-C862-40cd-9225-2CAF823F40F9),
131    pointer_default(unique)
132]
133interface IWebDownloadDelegate : IUnknown
134{
135    HRESULT decideDestinationWithSuggestedFilename([in] IWebDownload* download, [in] BSTR filename);
136
137    HRESULT didCancelAuthenticationChallenge([in] IWebDownload* download, [in] IWebURLAuthenticationChallenge* challenge);
138
139    HRESULT didCreateDestination([in] IWebDownload* download, [in] BSTR destination);
140
141    HRESULT didFailWithError([in] IWebDownload* download, [in] IWebError* error);
142
143    HRESULT didReceiveAuthenticationChallenge([in] IWebDownload* download, [in] IWebURLAuthenticationChallenge* challenge);
144
145    HRESULT didReceiveDataOfLength([in] IWebDownload* download, [in] unsigned length);
146
147    HRESULT didReceiveResponse([in] IWebDownload* download, [in] IWebURLResponse* response);
148
149    HRESULT shouldDecodeSourceDataOfMIMEType([in] IWebDownload* download, [in] BSTR encodingType, [out, retval] BOOL* shouldDecode);
150
151    HRESULT willResumeWithResponse([in] IWebDownload* download, [in] IWebURLResponse* response, [in] long long fromByte);
152
153    HRESULT willSendRequest([in] IWebDownload* download, [in] IWebMutableURLRequest* request, [in] IWebURLResponse* redirectResponse, [out] IWebMutableURLRequest** finalRequest);
154
155    HRESULT didBegin([in] IWebDownload* download);
156
157    HRESULT didFinish([in] IWebDownload* download);
158}
159