| 1 | /* |
|---|
| 2 | * QEMU Cocoa Control Download Class |
|---|
| 3 | * |
|---|
| 4 | * Copyright (c) 2006 René Korthaus |
|---|
| 5 | * |
|---|
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
|---|
| 7 | * of this software and associated documentation files (the "Software"), to deal |
|---|
| 8 | * in the Software without restriction, including without limitation the rights |
|---|
| 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|---|
| 10 | * copies of the Software, and to permit persons to whom the Software is |
|---|
| 11 | * furnished to do so, subject to the following conditions: |
|---|
| 12 | * |
|---|
| 13 | * The above copyright notice and this permission notice shall be included in |
|---|
| 14 | * all copies or substantial portions of the Software. |
|---|
| 15 | * |
|---|
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|---|
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|---|
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|---|
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|---|
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|---|
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|---|
| 22 | * THE SOFTWARE. |
|---|
| 23 | */ |
|---|
| 24 | |
|---|
| 25 | #import <Cocoa/Cocoa.h> |
|---|
| 26 | #import "../../Transmission/libtransmission/transmission.h" |
|---|
| 27 | |
|---|
| 28 | @interface cocoaDownload : NSObject |
|---|
| 29 | { |
|---|
| 30 | NSString * name; |
|---|
| 31 | NSString * url; |
|---|
| 32 | NSString * savePath; |
|---|
| 33 | NSMutableArray * lastReceivedContentLength; |
|---|
| 34 | NSTimer * timer; |
|---|
| 35 | |
|---|
| 36 | BOOL isHTTP; |
|---|
| 37 | BOOL isBT; |
|---|
| 38 | BOOL isQVM; |
|---|
| 39 | |
|---|
| 40 | float receivedContentLength; |
|---|
| 41 | float expectedContentLength; |
|---|
| 42 | float downloadRate; |
|---|
| 43 | |
|---|
| 44 | // HTTP Download stuff |
|---|
| 45 | NSURLDownload * theDownload; |
|---|
| 46 | |
|---|
| 47 | // BT Download stuff |
|---|
| 48 | tr_handle_t * fHandle; // main handle for libtransmission instance |
|---|
| 49 | tr_torrent_t * tHandle; // handle for single torrent |
|---|
| 50 | int tError; // error code returned by tr_torrentInit |
|---|
| 51 | int fCount, fSeeding, fDownloading, fCompleted; |
|---|
| 52 | tr_stat_t * tStat; |
|---|
| 53 | tr_info_t * tInfo; |
|---|
| 54 | NSTimer * fTimer; |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | - (id) initWithHTTP; |
|---|
| 58 | - (id) initWithBT; |
|---|
| 59 | |
|---|
| 60 | // get and set methods |
|---|
| 61 | - (void) setURL:(NSString *)aURL; |
|---|
| 62 | - (void) setName:(NSString *)aName; |
|---|
| 63 | - (void) setQVM:(BOOL)val; |
|---|
| 64 | - (NSString *) getName; |
|---|
| 65 | - (NSString *) getSavePath; |
|---|
| 66 | |
|---|
| 67 | - (float) getExpectedData; |
|---|
| 68 | - (float) getReceivedData; |
|---|
| 69 | - (int) getLastReceivedData; |
|---|
| 70 | |
|---|
| 71 | // managing downloads |
|---|
| 72 | - (void) startDownload; |
|---|
| 73 | - (void) startHTTPDownload; |
|---|
| 74 | - (void) startBTDownload; |
|---|
| 75 | - (void) checkDownloadStarted; |
|---|
| 76 | - (void) stopDownload; |
|---|
| 77 | |
|---|
| 78 | // HTTP Download Methods and Delegates |
|---|
| 79 | // no declaration needed, cause they are NSNotification methods |
|---|
| 80 | |
|---|
| 81 | // BT Download Methods and Delegates |
|---|
| 82 | |
|---|
| 83 | // Additional Functions |
|---|
| 84 | - (NSString *) createQVM; |
|---|
| 85 | |
|---|
| 86 | @end |
|---|