Changeset 5937
- Timestamp:
- May 26, 2008, 11:23:07 PM (14 years ago)
- Location:
- trunk/macosx
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/Torrent.h
r5858 r5937 73 73 - (id) initWithPath: (NSString *) path location: (NSString *) location deleteTorrentFile: (torrentFileState) torrentDelete 74 74 lib: (tr_handle *) lib; 75 - (id) initWith Data: (NSData *) datalocation: (NSString *) location lib: (tr_handle *) lib;75 - (id) initWithTorrentStruct: (tr_torrent *) torrentStruct location: (NSString *) location lib: (tr_handle *) lib; 76 76 - (id) initWithHistory: (NSDictionary *) history lib: (tr_handle *) lib; 77 77 -
trunk/macosx/Torrent.m
r5922 r5937 31 31 @interface Torrent (Private) 32 32 33 - (id) initWithHash: (NSString *) hashString path: (NSString *) path data: (NSData *) datalib: (tr_handle *) lib33 - (id) initWithHash: (NSString *) hashString path: (NSString *) path torrentStruct: (tr_torrent *) torrentStruct lib: (tr_handle *) lib 34 34 publicTorrent: (NSNumber *) publicTorrent 35 35 downloadFolder: (NSString *) downloadFolder … … 71 71 lib: (tr_handle *) lib 72 72 { 73 self = [self initWithHash: nil path: path data: nillib: lib73 self = [self initWithHash: nil path: path torrentStruct: NULL lib: lib 74 74 publicTorrent: torrentDelete != TORRENT_FILE_DEFAULT 75 75 ? [NSNumber numberWithBool: torrentDelete == TORRENT_FILE_SAVE] : nil … … 89 89 } 90 90 91 - (id) initWith Data: (NSData *) datalocation: (NSString *) location lib: (tr_handle *) lib92 { 93 self = [self initWithHash: nil path: nil data: datalib: lib94 publicTorrent: nil91 - (id) initWithTorrentStruct: (tr_torrent *) torrentStruct location: (NSString *) location lib: (tr_handle *) lib 92 { 93 self = [self initWithHash: nil path: nil torrentStruct: torrentStruct lib: lib 94 publicTorrent: [NSNumber numberWithBool: NO] 95 95 downloadFolder: location 96 96 useIncompleteFolder: nil incompleteFolder: nil … … 106 106 { 107 107 self = [self initWithHash: [history objectForKey: @"TorrentHash"] 108 path: [history objectForKey: @"TorrentPath"] data: nillib: lib108 path: [history objectForKey: @"TorrentPath"] torrentStruct: NULL lib: lib 109 109 publicTorrent: [history objectForKey: @"PublicCopy"] 110 110 downloadFolder: [history objectForKey: @"DownloadFolder"] … … 1526 1526 1527 1527 //if a hash is given, attempt to load that; otherwise, attempt to open file at path 1528 - (id) initWithHash: (NSString *) hashString path: (NSString *) path data: (NSData *) datalib: (tr_handle *) lib1528 - (id) initWithHash: (NSString *) hashString path: (NSString *) path torrentStruct: (tr_torrent *) torrentStruct lib: (tr_handle *) lib 1529 1529 publicTorrent: (NSNumber *) publicTorrent 1530 1530 downloadFolder: (NSString *) downloadFolder … … 1556 1556 } 1557 1557 1558 //set libtransmission settings for initialization 1559 tr_ctor * ctor = tr_ctorNew(lib); 1560 tr_ctorSetPaused(ctor, TR_FORCE, YES); 1561 tr_ctorSetPeerLimit(ctor, TR_FALLBACK, [fDefaults integerForKey: @"PeersTorrent"]); 1562 1563 tr_info info; 1564 int error; 1565 if (hashString) 1566 { 1567 tr_ctorSetMetainfoFromHash(ctor, [hashString UTF8String]); 1568 if (tr_torrentParse(lib, ctor, &info) == TR_OK) 1569 { 1570 NSString * currentDownloadFolder = [self shouldUseIncompleteFolderForName: [NSString stringWithUTF8String: info.name]] 1558 if (torrentStruct) 1559 { 1560 fHandle = torrentStruct; 1561 1562 const tr_info * info = tr_torrentInfo(fHandle); 1563 NSString * currentDownloadFolder = [self shouldUseIncompleteFolderForName: [NSString stringWithUTF8String: info->name]] 1571 1564 ? fIncompleteFolder : fDownloadFolder; 1572 tr_ctorSetDownloadDir(ctor, TR_FORCE, [currentDownloadFolder UTF8String]); 1573 1574 fHandle = tr_torrentNew(lib, ctor, &error); 1575 } 1576 tr_metainfoFree(&info); 1577 } 1578 if (!fHandle && path) 1579 { 1580 tr_ctorSetMetainfoFromFile(ctor, [path UTF8String]); 1581 if (tr_torrentParse(lib, ctor, &info) == TR_OK) 1582 { 1583 NSString * currentDownloadFolder = [self shouldUseIncompleteFolderForName: [NSString stringWithUTF8String: info.name]] 1584 ? fIncompleteFolder : fDownloadFolder; 1585 tr_ctorSetDownloadDir(ctor, TR_FORCE, [currentDownloadFolder UTF8String]); 1586 1587 fHandle = tr_torrentNew(lib, ctor, &error); 1588 } 1589 tr_metainfoFree(&info); 1590 } 1591 if (!fHandle && data) 1592 { 1593 tr_ctorSetMetainfo(ctor, [data bytes], [data length]); 1594 if (tr_torrentParse(lib, ctor, &info) == TR_OK) 1595 { 1596 NSString * currentDownloadFolder = [self shouldUseIncompleteFolderForName: [NSString stringWithUTF8String: info.name]] 1597 ? fIncompleteFolder : fDownloadFolder; 1598 tr_ctorSetDownloadDir(ctor, TR_FORCE, [currentDownloadFolder UTF8String]); 1599 1600 fHandle = tr_torrentNew(lib, ctor, &error); 1601 } 1602 tr_metainfoFree(&info); 1603 } 1604 1605 tr_ctorFree(ctor); 1606 1607 if (!fHandle) 1608 { 1609 [self release]; 1610 return nil; 1565 tr_torrentSetDownloadDir(fHandle, [currentDownloadFolder UTF8String]); 1566 tr_metainfoFree(info); 1567 } 1568 else 1569 { 1570 //set libtransmission settings for initialization 1571 tr_ctor * ctor = tr_ctorNew(lib); 1572 tr_ctorSetPaused(ctor, TR_FORCE, YES); 1573 tr_ctorSetPeerLimit(ctor, TR_FALLBACK, [fDefaults integerForKey: @"PeersTorrent"]); 1574 1575 tr_info info; 1576 if (hashString) 1577 { 1578 tr_ctorSetMetainfoFromHash(ctor, [hashString UTF8String]); 1579 if (tr_torrentParse(lib, ctor, &info) == TR_OK) 1580 { 1581 NSString * currentDownloadFolder = [self shouldUseIncompleteFolderForName: [NSString stringWithUTF8String: info.name]] 1582 ? fIncompleteFolder : fDownloadFolder; 1583 tr_ctorSetDownloadDir(ctor, TR_FORCE, [currentDownloadFolder UTF8String]); 1584 1585 fHandle = tr_torrentNew(lib, ctor, NULL); 1586 } 1587 tr_metainfoFree(&info); 1588 } 1589 if (!fHandle && path) 1590 { 1591 tr_ctorSetMetainfoFromFile(ctor, [path UTF8String]); 1592 if (tr_torrentParse(lib, ctor, &info) == TR_OK) 1593 { 1594 NSString * currentDownloadFolder = [self shouldUseIncompleteFolderForName: [NSString stringWithUTF8String: info.name]] 1595 ? fIncompleteFolder : fDownloadFolder; 1596 tr_ctorSetDownloadDir(ctor, TR_FORCE, [currentDownloadFolder UTF8String]); 1597 1598 fHandle = tr_torrentNew(lib, ctor, NULL); 1599 } 1600 tr_metainfoFree(&info); 1601 } 1602 1603 tr_ctorFree(ctor); 1604 1605 if (!fHandle) 1606 { 1607 [self release]; 1608 return nil; 1609 } 1611 1610 } 1612 1611
Note: See TracChangeset
for help on using the changeset viewer.