2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * 2007 Apple Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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.
30 import "IWebError.idl";
31 import "IWebMutableURLRequest.idl";
32 import "IWebURLAuthenticationChallenge.idl";
33 import "IWebURLResponse.idl";
34 import "IWebURLRequest.idl";
37 interface IWebDownloadDelegate;
39 interface IWebMutableURLRequest;
40 interface IWebURLAuthenticationChallenge;
41 interface IWebURLRequest;
42 interface IWebURLResponse;
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.
58 uuid(65EFE83B-A9E4-4516-8F3B-BAA25DA90FFD),
59 pointer_default(unique)
61 interface IWebDownload : IUnknown
64 + (BOOL)canResumeDownloadDecodedWithEncodingMIMEType:(NSString *)MIMEType
66 HRESULT canResumeDownloadDecodedWithEncodingMIMEType([in] BSTR mimeType, [out, retval] BOOL* result);
74 - (void)cancelForResume();
76 HRESULT cancelForResume();
84 - (BOOL)deletesFileUponFailure
86 HRESULT deletesFileUponFailure([out, retval] BOOL* result);
89 - (id)initWithRequest:(NSURLRequest *)request delegate:(id)delegate
91 HRESULT initWithRequest([in] IWebURLRequest* request, [in] IWebDownloadDelegate* delegate);
94 - (id)initWithResumeData:(NSData *)resumeData delegate:(id)delegate path:(NSString *)path
96 HRESULT initToResumeWithBundle([in] BSTR bundlePath, [in] IWebDownloadDelegate* delegate);
99 - (String)bundlePathForTargetPath:(String)targetPath
101 HRESULT bundlePathForTargetPath([in] BSTR target, [out, retval] BSTR* bundle);
104 - (NSURLRequest *)request
106 HRESULT request([out, retval] IWebURLRequest** request);
109 - (void)setDeletesFileUponFailure:(BOOL)deletesFileUponFailure
111 HRESULT setDeletesFileUponFailure([in] BOOL deletesFileUponFailure);
114 - (void)setDestination:(NSString *)path allowOverwrite:(BOOL)allowOverwrite
116 HRESULT setDestination([in] BSTR path, [in] BOOL allowOverwrite);
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)
130 uuid(16A32AE6-C862-40cd-9225-2CAF823F40F9),
131 pointer_default(unique)
133 interface IWebDownloadDelegate : IUnknown
135 HRESULT decideDestinationWithSuggestedFilename([in] IWebDownload* download, [in] BSTR filename);
137 HRESULT didCancelAuthenticationChallenge([in] IWebDownload* download, [in] IWebURLAuthenticationChallenge* challenge);
139 HRESULT didCreateDestination([in] IWebDownload* download, [in] BSTR destination);
141 HRESULT didFailWithError([in] IWebDownload* download, [in] IWebError* error);
143 HRESULT didReceiveAuthenticationChallenge([in] IWebDownload* download, [in] IWebURLAuthenticationChallenge* challenge);
145 HRESULT didReceiveDataOfLength([in] IWebDownload* download, [in] unsigned length);
147 HRESULT didReceiveResponse([in] IWebDownload* download, [in] IWebURLResponse* response);
149 HRESULT shouldDecodeSourceDataOfMIMEType([in] IWebDownload* download, [in] BSTR encodingType, [out, retval] BOOL* shouldDecode);
151 HRESULT willResumeWithResponse([in] IWebDownload* download, [in] IWebURLResponse* response, [in] long long fromByte);
153 HRESULT willSendRequest([in] IWebDownload* download, [in] IWebMutableURLRequest* request, [in] IWebURLResponse* redirectResponse, [out] IWebMutableURLRequest** finalRequest);
155 HRESULT didBegin([in] IWebDownload* download);
157 HRESULT didFinish([in] IWebDownload* download);