Changeset 9735
- Timestamp:
- Dec 13, 2009, 1:36:22 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/Torrent.m
r9726 r9735 32 32 @interface Torrent (Private) 33 33 34 - (id) initWithPath: (NSString *) path hash: (NSString *) hashString torrentStruct: (tr_torrent *) torrentStruct lib: (tr_session *) lib 34 - (id) initWithPath: (NSString *) path hash: (NSString *) hashString torrentStruct: (tr_torrent *) torrentStruct 35 magnetAddress: (NSString *) magnetAddress lib: (tr_session *) lib 35 36 waitToStart: (NSNumber *) waitToStart 36 37 groupValue: (NSNumber *) groupValue … … 79 80 lib: (tr_session *) lib 80 81 { 81 self = [self initWithPath: path hash: nil torrentStruct: NULL lib: lib82 self = [self initWithPath: path hash: nil torrentStruct: NULL magnetAddress: nil lib: lib 82 83 waitToStart: nil groupValue: nil 83 84 downloadFolder: location legacyIncompleteFolder: nil]; … … 93 94 - (id) initWithTorrentStruct: (tr_torrent *) torrentStruct location: (NSString *) location lib: (tr_session *) lib 94 95 { 95 self = [self initWithPath: nil hash: nil torrentStruct: torrentStruct lib: lib96 self = [self initWithPath: nil hash: nil torrentStruct: torrentStruct magnetAddress: nil lib: lib 96 97 waitToStart: nil groupValue: nil 97 98 downloadFolder: location legacyIncompleteFolder: nil]; … … 103 104 - (id) initWithMagnetAddress: (NSString *) address location: (NSString *) location lib: (tr_session *) lib 104 105 { 105 #warning move into real constructor? 106 //set libtransmission settings for initialization 107 tr_ctor * ctor = tr_ctorNew(lib); 108 tr_ctorSetPaused(ctor, TR_FORCE, YES); 109 110 const tr_parse_result result = tr_ctorSetMagnet(ctor, [address UTF8String]); 111 112 tr_torrent * handle = NULL; 113 if (result == TR_PARSE_OK) 114 handle = tr_torrentNew(ctor, NULL); 115 116 tr_ctorFree(ctor); 117 118 if (handle) 119 self = [self initWithPath: nil hash: nil torrentStruct: handle lib: lib 120 waitToStart: nil groupValue: nil 121 downloadFolder: location legacyIncompleteFolder: nil]; 122 else 123 self = nil; 106 self = [self initWithPath: nil hash: nil torrentStruct: nil magnetAddress: address 107 lib: lib waitToStart: nil groupValue: nil 108 downloadFolder: location legacyIncompleteFolder: nil]; 124 109 125 110 return self; … … 130 115 self = [self initWithPath: [history objectForKey: @"InternalTorrentPath"] 131 116 hash: [history objectForKey: @"TorrentHash"] 132 torrentStruct: NULL lib: lib 117 torrentStruct: NULL 118 magnetAddress: nil 119 lib: lib 133 120 waitToStart: [history objectForKey: @"WaitToStart"] 134 121 groupValue: [history objectForKey: @"GroupValue"] … … 1543 1530 @implementation Torrent (Private) 1544 1531 1545 - (id) initWithPath: (NSString *) path hash: (NSString *) hashString torrentStruct: (tr_torrent *) torrentStruct lib: (tr_session *) lib 1532 - (id) initWithPath: (NSString *) path hash: (NSString *) hashString torrentStruct: (tr_torrent *) torrentStruct 1533 magnetAddress: (NSString *) magnetAddress lib: (tr_session *) lib 1546 1534 waitToStart: (NSNumber *) waitToStart 1547 1535 groupValue: (NSNumber *) groupValue … … 1555 1543 if (torrentStruct) 1556 1544 fHandle = torrentStruct; 1545 else if (magnetAddress) 1546 { 1547 tr_ctor * ctor = tr_ctorNew(lib); 1548 1549 tr_ctorSetPaused(ctor, TR_FORCE, YES); 1550 if (downloadFolder) 1551 tr_ctorSetDownloadDir(ctor, TR_FORCE, [downloadFolder UTF8String]); 1552 1553 const tr_parse_result result = tr_ctorSetMagnet(ctor, [magnetAddress UTF8String]); 1554 1555 if (result == TR_PARSE_OK) 1556 fHandle = tr_torrentNew(ctor, NULL); 1557 1558 tr_ctorFree(ctor); 1559 1560 if (!fHandle) 1561 { 1562 [self release]; 1563 return nil; 1564 } 1565 } 1557 1566 else 1558 1567 { 1559 1568 //set libtransmission settings for initialization 1560 1569 tr_ctor * ctor = tr_ctorNew(lib); 1570 1561 1571 tr_ctorSetPaused(ctor, TR_FORCE, YES); 1572 if (downloadFolder) 1573 tr_ctorSetDownloadDir(ctor, TR_FORCE, [downloadFolder UTF8String]); 1574 if (incompleteFolder) 1575 tr_ctorSetIncompleteDir(ctor, [incompleteFolder UTF8String]); 1562 1576 1563 1577 tr_parse_result result = TR_PARSE_ERR; … … 1570 1584 1571 1585 if (result == TR_PARSE_OK) 1572 {1573 if (downloadFolder)1574 tr_ctorSetDownloadDir(ctor, TR_FORCE, [downloadFolder UTF8String]);1575 if (incompleteFolder)1576 tr_ctorSetIncompleteDir(ctor, [incompleteFolder UTF8String]);1577 1578 1586 fHandle = tr_torrentNew(ctor, NULL); 1579 }1580 1587 1581 1588 tr_ctorFree(ctor);
Note: See TracChangeset
for help on using the changeset viewer.