CatNiP docutest
Sähköinen nuottikirja, HY-TKTKL-OHTUPROJ KESÄ11
MediaWikiDownload Class Reference

MediaWikiDownload saves a remote file to local storage. More...

#import <MediaWikiDownload.h>

List of all members.

Public Member Functions

(void) - abortRead
 Aborts the data transfer in progress.
(void) - addProgressListener:
 Adds a progress listener object to this object's listeners.
(NSString *) - buildQueryURL
 Builds the query URL, intended to be easily re-implemented in sublcasses.
(void) - connection:didFailWithError:
 NSURLConnection delegate method.
(void) - connection:didReceiveData:
 NSURLConnection delegate method.
(void) - connection:didReceiveResponse:
 NSURLConnection delegate method.
(void) - connectionDidFinishLoading:
 NSURLConnection delegate method.
(id) - init [implementation]
 Initializes the object.
(id) - initWithDelegate:
 Initialize a new MediaWikiDownload object with the specified delegate.
(id) - initWithDelegate:mediaWikiURL:
 Initialize a new MediaWikiDownload object with the specified delegate and MediaWiki URL (as a string)
(void) - removeProgressListener:
 Removes a progress listener object from this object's listeners.
(BOOL) - startQuery
 Launches the query process.

Protected Attributes

NSURLConnection * mediaWikiConnection
NSMutableURLRequest * mediaWikiRequest
NSFileHandle * outHandle
NSString * outputPath
NSMutableSet * progressListeners
id< MediaWikiDownloadDelegatequeryDelegate
NSMutableData * receivedData
BOOL working

Properties

NSInteger currentBytes
 Manual accessor for currentBytes.
NSInteger expectedSize
 Manual accessor for expectedSize.
NSString * mediaWikiFilename
 The filename of the file to download.
NSString * mediaWikiURLString
 The base URL for this MediaWiki query.

Detailed Description

MediaWikiDownload saves a remote file to local storage.

MediaWikiDownload is designed to fetch an attachment file from a MediaWiki site, specifically IMSLP. It sets any cookies required and manually saves the data to the temp directory, moving it to the Documents storage once complete.

A succesful download is reported to the delegate.

Created by Antti V J Niemela, tkol on 6/7/11. Copyright 2011 University of Helsinki. All rights reserved.


Member Function Documentation

- (void) abortRead

Aborts the data transfer in progress.

The temporary file (if it exists) is not destroyed.

Here is the caller graph for this function:

- (void) addProgressListener: (id <MediaWikiProgressListener>)  listener

Adds a progress listener object to this object's listeners.

Progress Listeners receive periodic updates on the progress of the data transfer taking place. Multiple listeners are supported.

Parameters:
listenerA MediaWikiProgressListener that should receive updates.
- (NSString *) buildQueryURL

Builds the query URL, intended to be easily re-implemented in sublcasses.

Builds the query URL.

The URL is based on the mediaWikiURLString property. The filename property is appended to the base URL to receive the final, complete URL to download.

Returns:
The URL to be used when attempting the connection

Here is the caller graph for this function:

- (void) connection: (NSURLConnection *)  connection
didFailWithError: (NSError *)  error 

NSURLConnection delegate method.

NSURLConnectionDelegate implementation, reports the error with NSLog and cleans file handles.

The temporary file that might have been created is not destroyed.

Here is the call graph for this function:

- (void) connection: (NSURLConnection *)  connection
didReceiveData: (NSData *)  data 

NSURLConnection delegate method.

NSURLConnectionDelegate implementation, passes the data to a filehandle and updates any MediaWikiProgressListeners.

- (void) connection: (NSURLConnection *)  connection
didReceiveResponse: (NSURLResponse *)  response 

NSURLConnection delegate method.

NSURLConnectionDelegate implementation, resets the output file handle (only the data from the last response is stuff we're interested in).

- (void) connectionDidFinishLoading: (NSURLConnection *)  connection

NSURLConnection delegate method.

NSURLConnectionDelegate implementation, informs the MediaWikiDownloadDelegate about a succesful download.

Here is the call graph for this function:

- (id) init [implementation]

Initializes the object.

Here is the caller graph for this function:

- (id) initWithDelegate: (id <MediaWikiDownloadDelegate>)  mediaWikiDownloadDelegate

Initialize a new MediaWikiDownload object with the specified delegate.

Initializes the object with the specified delegate.

Parameters:
MediaWikiDownloadDelegateThe delegate object that will receive the data read from the URL
Returns:
id pointer to the initialized object.

Here is the call graph for this function:

Here is the caller graph for this function:

- (id) initWithDelegate: (id <MediaWikiDownloadDelegate>)  mediaWikiDownloadDelegate
mediaWikiURL: (NSString*)  mwURLString 

Initialize a new MediaWikiDownload object with the specified delegate and MediaWiki URL (as a string)

Initializes the object with the specified delegate and MediaWiki URL.

Parameters:
MediaWikiDownloadDelegateThe delegate object that will receive the data read from the URL
mwURLStringThe URL to read from.
Returns:
id pointer to the initialized object.

Here is the call graph for this function:

- (void) removeProgressListener: (id <MediaWikiProgressListener>)  listener

Removes a progress listener object from this object's listeners.

Parameters:
listenerThe listener to remove from this object's listener set.

Here is the caller graph for this function:

- (BOOL) startQuery

Launches the query process.

Starts the MediaWiki query.

Starts the HTTP query represented by the URL received using [self buildQueryURL] using an internal NSURLConnection object. This object functions as the delegate for the NSURLConnection, and passes the read data to it's delegate once the connection finishes loading.

Returns:
YES if the connection started succesfully, NO if the URL was malformed or this object was already in the middle of reading data

Here is the call graph for this function:


Member Data Documentation

- (NSURLConnection*) mediaWikiConnection [protected]
- (NSMutableURLRequest*) mediaWikiRequest [protected]
- (NSFileHandle*) outHandle [protected]
- (NSString*) outputPath [protected]
- (NSMutableSet*) progressListeners [protected]
- (NSMutableData*) receivedData [protected]
- (BOOL) working [protected]

Property Documentation

- (NSInteger) currentBytes [read, assign]

Manual accessor for currentBytes.

Returns:
The number of bytes of data received from the target host.
- (NSInteger) expectedSize [read, assign]

Manual accessor for expectedSize.

Only available once a NSURLResponse has been received from the target host. Returns NSIntegerMin if a response has not yet been received, and -1 when a response has been received but it did not contain information on the size of the response.

Returns:
The expected size (in 8-bit bytes) of the file, NSIntegerMin or -1.
- (NSString *) mediaWikiFilename [read, write, copy]

The filename of the file to download.

- (NSString *) mediaWikiURLString [read, write, copy]

The base URL for this MediaWiki query.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Enumerations Enumerator Properties Defines