Port macOS client to C++ (#1830)
* Rename all .m (Obj-C) files to .mm (Obj-C++) * Fix build in Obj-C++ mode * Fix Xcode build
This commit is contained in:
parent
5c9b34c676
commit
b7ba261359
File diff suppressed because it is too large
Load Diff
|
@ -38,75 +38,75 @@ function(tr_tiff_from_pngs OFILE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
set(${PROJECT_NAME}_SOURCES
|
set(${PROJECT_NAME}_SOURCES
|
||||||
AboutWindowController.m
|
AboutWindowController.mm
|
||||||
AddMagnetWindowController.m
|
AddMagnetWindowController.mm
|
||||||
AddWindowController.m
|
AddWindowController.mm
|
||||||
BadgeView.m
|
BadgeView.mm
|
||||||
Badger.m
|
Badger.mm
|
||||||
BlocklistDownloader.m
|
BlocklistDownloader.mm
|
||||||
BlocklistDownloaderViewController.m
|
BlocklistDownloaderViewController.mm
|
||||||
BlocklistScheduler.m
|
BlocklistScheduler.mm
|
||||||
BonjourController.m
|
BonjourController.mm
|
||||||
ButtonToolbarItem.m
|
ButtonToolbarItem.mm
|
||||||
ColorTextField.m
|
ColorTextField.mm
|
||||||
Controller.m
|
Controller.mm
|
||||||
CreatorWindowController.m
|
CreatorWindowController.mm
|
||||||
DragOverlayView.m
|
DragOverlayView.mm
|
||||||
DragOverlayWindow.m
|
DragOverlayWindow.mm
|
||||||
ExpandedPathToIconTransformer.m
|
ExpandedPathToIconTransformer.mm
|
||||||
ExpandedPathToPathTransformer.m
|
ExpandedPathToPathTransformer.mm
|
||||||
FileListNode.m
|
FileListNode.mm
|
||||||
FileNameCell.m
|
FileNameCell.mm
|
||||||
FileOutlineController.m
|
FileOutlineController.mm
|
||||||
FileOutlineView.m
|
FileOutlineView.mm
|
||||||
FilePriorityCell.m
|
FilePriorityCell.mm
|
||||||
FileRenameSheetController.m
|
FileRenameSheetController.mm
|
||||||
FilterBarController.m
|
FilterBarController.mm
|
||||||
FilterBarView.m
|
FilterBarView.mm
|
||||||
FilterButton.m
|
FilterButton.mm
|
||||||
GlobalOptionsPopoverViewController.m
|
GlobalOptionsPopoverViewController.mm
|
||||||
GroupToolbarItem.m
|
GroupToolbarItem.mm
|
||||||
GroupsController.m
|
GroupsController.mm
|
||||||
GroupsPrefsController.m
|
GroupsPrefsController.mm
|
||||||
InfoActivityViewController.m
|
InfoActivityViewController.mm
|
||||||
InfoFileViewController.m
|
InfoFileViewController.mm
|
||||||
InfoGeneralViewController.m
|
InfoGeneralViewController.mm
|
||||||
InfoOptionsViewController.m
|
InfoOptionsViewController.mm
|
||||||
InfoPeersViewController.m
|
InfoPeersViewController.mm
|
||||||
InfoTabButtonBack.m
|
InfoTabButtonBack.mm
|
||||||
InfoTabButtonCell.m
|
InfoTabButtonCell.mm
|
||||||
InfoTextField.m
|
InfoTextField.mm
|
||||||
InfoTrackersViewController.m
|
InfoTrackersViewController.mm
|
||||||
InfoWindowController.m
|
InfoWindowController.mm
|
||||||
main.m
|
main.mm
|
||||||
MessageWindowController.m
|
MessageWindowController.mm
|
||||||
NSApplicationAdditions.m
|
NSApplicationAdditions.mm
|
||||||
NSImageAdditions.m
|
NSImageAdditions.mm
|
||||||
NSMutableArrayAdditions.m
|
NSMutableArrayAdditions.mm
|
||||||
NSStringAdditions.m
|
NSStringAdditions.mm
|
||||||
PeerProgressIndicatorCell.m
|
PeerProgressIndicatorCell.mm
|
||||||
PeerTableView.m
|
PeerTableView.mm
|
||||||
PiecesView.m
|
PiecesView.mm
|
||||||
PortChecker.m
|
PortChecker.mm
|
||||||
PredicateEditorRowTemplateAny.m
|
PredicateEditorRowTemplateAny.mm
|
||||||
PrefsController.m
|
PrefsController.mm
|
||||||
PrefsWindow.m
|
PrefsWindow.mm
|
||||||
ProgressGradients.m
|
ProgressGradients.mm
|
||||||
ShareToolbarItem.m
|
ShareToolbarItem.mm
|
||||||
ShareTorrentFileHelper.m
|
ShareTorrentFileHelper.mm
|
||||||
StatsWindowController.m
|
StatsWindowController.mm
|
||||||
StatusBarController.m
|
StatusBarController.mm
|
||||||
StatusBarView.m
|
StatusBarView.mm
|
||||||
ToolbarSegmentedCell.m
|
ToolbarSegmentedCell.mm
|
||||||
Torrent.m
|
Torrent.mm
|
||||||
TorrentCell.m
|
TorrentCell.mm
|
||||||
TorrentGroup.m
|
TorrentGroup.mm
|
||||||
TorrentTableView.m
|
TorrentTableView.mm
|
||||||
TrackerCell.m
|
TrackerCell.mm
|
||||||
TrackerNode.m
|
TrackerNode.mm
|
||||||
TrackerTableView.m
|
TrackerTableView.mm
|
||||||
URLSheetWindowController.m
|
URLSheetWindowController.mm
|
||||||
WebSeedTableView.m
|
WebSeedTableView.mm
|
||||||
)
|
)
|
||||||
|
|
||||||
set(${PROJECT_NAME}_HEADERS
|
set(${PROJECT_NAME}_HEADERS
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
#import <Quartz/Quartz.h>
|
#import <Quartz/Quartz.h>
|
||||||
|
|
||||||
|
#import <Sparkle/SUUpdaterDelegate.h>
|
||||||
|
|
||||||
#include <libtransmission/transmission.h>
|
#include <libtransmission/transmission.h>
|
||||||
|
|
||||||
#import "VDKQueue.h"
|
#import "VDKQueue.h"
|
||||||
|
@ -49,7 +51,7 @@ typedef NS_ENUM(unsigned int, addType) { //
|
||||||
};
|
};
|
||||||
|
|
||||||
@interface Controller
|
@interface Controller
|
||||||
: NSObject<NSApplicationDelegate, NSURLDownloadDelegate, NSUserNotificationCenterDelegate, NSPopoverDelegate, NSSharingServiceDelegate, NSSharingServicePickerDelegate, NSSoundDelegate, NSToolbarDelegate, NSWindowDelegate, QLPreviewPanelDataSource, QLPreviewPanelDelegate, VDKQueueDelegate>
|
: NSObject<NSApplicationDelegate, NSURLDownloadDelegate, NSUserNotificationCenterDelegate, NSPopoverDelegate, NSSharingServiceDelegate, NSSharingServicePickerDelegate, NSSoundDelegate, NSToolbarDelegate, NSWindowDelegate, QLPreviewPanelDataSource, QLPreviewPanelDelegate, VDKQueueDelegate, SUUpdaterDelegate>
|
||||||
{
|
{
|
||||||
IBOutlet NSWindow* fWindow;
|
IBOutlet NSWindow* fWindow;
|
||||||
IBOutlet TorrentTableView* fTableView;
|
IBOutlet TorrentTableView* fTableView;
|
||||||
|
|
|
@ -1309,7 +1309,7 @@ static void removeKeRangerRansomware()
|
||||||
|
|
||||||
- (void)openFilesWithDict:(NSDictionary*)dictionary
|
- (void)openFilesWithDict:(NSDictionary*)dictionary
|
||||||
{
|
{
|
||||||
[self openFiles:dictionary[@"Filenames"] addType:[dictionary[@"AddType"] intValue] forcePath:nil];
|
[self openFiles:dictionary[@"Filenames"] addType:static_cast<addType>([dictionary[@"AddType"] intValue]) forcePath:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
//called on by applescript
|
//called on by applescript
|
||||||
|
@ -4204,9 +4204,9 @@ static void removeKeRangerRansomware()
|
||||||
return [self toolbarButtonWithIdentifier:ident forToolbarButtonClass:[ButtonToolbarItem class]];
|
return [self toolbarButtonWithIdentifier:ident forToolbarButtonClass:[ButtonToolbarItem class]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)toolbarButtonWithIdentifier:(NSString*)ident forToolbarButtonClass:(Class)class
|
- (id)toolbarButtonWithIdentifier:(NSString*)ident forToolbarButtonClass:(Class)klass
|
||||||
{
|
{
|
||||||
ButtonToolbarItem* item = [[class alloc] initWithItemIdentifier:ident];
|
ButtonToolbarItem* item = [[klass alloc] initWithItemIdentifier:ident];
|
||||||
|
|
||||||
NSButton* button = [[NSButton alloc] init];
|
NSButton* button = [[NSButton alloc] init];
|
||||||
button.bezelStyle = NSTexturedRoundedBezelStyle;
|
button.bezelStyle = NSTexturedRoundedBezelStyle;
|
|
@ -420,7 +420,7 @@
|
||||||
|
|
||||||
for (Torrent* torrent in fTorrents)
|
for (Torrent* torrent in fTorrents)
|
||||||
{
|
{
|
||||||
torrent.ratioSetting = setting;
|
torrent.ratioSetting = static_cast<tr_ratiolimit>(setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
fRatioLimitField.hidden = !single;
|
fRatioLimitField.hidden = !single;
|
||||||
|
@ -470,7 +470,7 @@
|
||||||
|
|
||||||
for (Torrent* torrent in fTorrents)
|
for (Torrent* torrent in fTorrents)
|
||||||
{
|
{
|
||||||
torrent.idleSetting = setting;
|
torrent.idleSetting = static_cast<tr_idlelimit>(setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
fIdleLimitField.hidden = !single;
|
fIdleLimitField.hidden = !single;
|
|
@ -765,7 +765,7 @@
|
||||||
|
|
||||||
- (void)setAutoSpeedLimitDay:(id)sender
|
- (void)setAutoSpeedLimitDay:(id)sender
|
||||||
{
|
{
|
||||||
tr_sessionSetAltSpeedDay(fHandle, [sender selectedItem].tag);
|
tr_sessionSetAltSpeedDay(fHandle, static_cast<tr_sched_day>([sender selectedItem].tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSInteger)dateToTimeSum:(NSDate*)date
|
+ (NSInteger)dateToTimeSum:(NSDate*)date
|
|
@ -1,11 +1,11 @@
|
||||||
project(trmacql)
|
project(trmacql)
|
||||||
|
|
||||||
set(${PROJECT_NAME}_SOURCES
|
set(${PROJECT_NAME}_SOURCES
|
||||||
../NSApplicationAdditions.m
|
../NSApplicationAdditions.mm
|
||||||
../NSStringAdditions.m
|
../NSStringAdditions.mm
|
||||||
GeneratePreviewForURL.m
|
GeneratePreviewForURL.mm
|
||||||
GenerateThumbnailForURL.m
|
GenerateThumbnailForURL.mm
|
||||||
main.c
|
main.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
set(${PROJECT_NAME}_HEADERS
|
set(${PROJECT_NAME}_HEADERS
|
||||||
|
|
|
@ -105,7 +105,7 @@ QuickLookGeneratorPluginType* AllocQuickLookGeneratorPluginType(CFUUIDRef inFact
|
||||||
memcpy(theNewInstance->conduitInterface, &myInterfaceFtbl, sizeof(QLGeneratorInterfaceStruct));
|
memcpy(theNewInstance->conduitInterface, &myInterfaceFtbl, sizeof(QLGeneratorInterfaceStruct));
|
||||||
|
|
||||||
/* Retain and keep an open instance refcount for each factory. */
|
/* Retain and keep an open instance refcount for each factory. */
|
||||||
theNewInstance->factoryID = CFRetain(inFactoryID);
|
theNewInstance->factoryID = static_cast<CFUUIDRef>(CFRetain(inFactoryID));
|
||||||
CFPlugInAddInstanceForFactory(inFactoryID);
|
CFPlugInAddInstanceForFactory(inFactoryID);
|
||||||
|
|
||||||
/* This function returns the IUnknown interface so set the refCount to one. */
|
/* This function returns the IUnknown interface so set the refCount to one. */
|
|
@ -1257,8 +1257,7 @@ bool trashDataFile(char const* filename, tr_error** error)
|
||||||
self.peersSendingToUs];
|
self.peersSendingToUs];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSInteger const webSeedCount = fStat->webseedsSendingToUs;
|
if (NSInteger const webSeedCount = fStat->webseedsSendingToUs; webSeedCount > 0)
|
||||||
if (webSeedCount > 0)
|
|
||||||
{
|
{
|
||||||
NSString* webSeedString;
|
NSString* webSeedString;
|
||||||
if (webSeedCount == 1)
|
if (webSeedCount == 1)
|
||||||
|
@ -1661,7 +1660,7 @@ bool trashDataFile(char const* filename, tr_error** error)
|
||||||
- (void)setFileCheckState:(NSInteger)state forIndexes:(NSIndexSet*)indexSet
|
- (void)setFileCheckState:(NSInteger)state forIndexes:(NSIndexSet*)indexSet
|
||||||
{
|
{
|
||||||
NSUInteger count = indexSet.count;
|
NSUInteger count = indexSet.count;
|
||||||
tr_file_index_t* files = malloc(count * sizeof(tr_file_index_t));
|
tr_file_index_t* files = static_cast<tr_file_index_t*>(malloc(count * sizeof(tr_file_index_t)));
|
||||||
for (NSUInteger index = indexSet.firstIndex, i = 0; index != NSNotFound; index = [indexSet indexGreaterThanIndex:index], i++)
|
for (NSUInteger index = indexSet.firstIndex, i = 0; index != NSNotFound; index = [indexSet indexGreaterThanIndex:index], i++)
|
||||||
{
|
{
|
||||||
files[i] = index;
|
files[i] = index;
|
||||||
|
@ -1677,7 +1676,7 @@ bool trashDataFile(char const* filename, tr_error** error)
|
||||||
- (void)setFilePriority:(tr_priority_t)priority forIndexes:(NSIndexSet*)indexSet
|
- (void)setFilePriority:(tr_priority_t)priority forIndexes:(NSIndexSet*)indexSet
|
||||||
{
|
{
|
||||||
NSUInteger const count = indexSet.count;
|
NSUInteger const count = indexSet.count;
|
||||||
tr_file_index_t* files = tr_malloc(count * sizeof(tr_file_index_t));
|
tr_file_index_t* files = static_cast<tr_file_index_t*>(tr_malloc(count * sizeof(tr_file_index_t)));
|
||||||
for (NSUInteger index = indexSet.firstIndex, i = 0; index != NSNotFound; index = [indexSet indexGreaterThanIndex:index], i++)
|
for (NSUInteger index = indexSet.firstIndex, i = 0; index != NSNotFound; index = [indexSet indexGreaterThanIndex:index], i++)
|
||||||
{
|
{
|
||||||
files[i] = index;
|
files[i] = index;
|
||||||
|
@ -1899,18 +1898,18 @@ bool trashDataFile(char const* filename, tr_error** error)
|
||||||
tr_parse_result result = TR_PARSE_ERR;
|
tr_parse_result result = TR_PARSE_ERR;
|
||||||
if (path)
|
if (path)
|
||||||
{
|
{
|
||||||
result = tr_ctorSetMetainfoFromFile(ctor, path.UTF8String);
|
result = static_cast<tr_parse_result>(tr_ctorSetMetainfoFromFile(ctor, path.UTF8String));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != TR_PARSE_OK && magnetAddress)
|
if (result != TR_PARSE_OK && magnetAddress)
|
||||||
{
|
{
|
||||||
result = tr_ctorSetMetainfoFromMagnetLink(ctor, magnetAddress.UTF8String);
|
result = static_cast<tr_parse_result>(tr_ctorSetMetainfoFromMagnetLink(ctor, magnetAddress.UTF8String));
|
||||||
}
|
}
|
||||||
|
|
||||||
//backup - shouldn't be needed after upgrade to 1.70
|
//backup - shouldn't be needed after upgrade to 1.70
|
||||||
if (result != TR_PARSE_OK && hashString)
|
if (result != TR_PARSE_OK && hashString)
|
||||||
{
|
{
|
||||||
result = tr_ctorSetMetainfoFromHash(ctor, hashString.UTF8String);
|
result = static_cast<tr_parse_result>(tr_ctorSetMetainfoFromHash(ctor, hashString.UTF8String));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == TR_PARSE_OK)
|
if (result == TR_PARSE_OK)
|
||||||
|
@ -2173,9 +2172,12 @@ bool trashDataFile(char const* filename, tr_error** error)
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
|
using WeakUpdateNodeAndChildrenForRename = void (^__block __weak)(FileListNode*);
|
||||||
|
using UpdateNodeAndChildrenForRename = void (^)(FileListNode*);
|
||||||
|
|
||||||
NSString* oldName = oldPath.lastPathComponent;
|
NSString* oldName = oldPath.lastPathComponent;
|
||||||
void (^__block __weak weakUpdateNodeAndChildrenForRename)(FileListNode*);
|
WeakUpdateNodeAndChildrenForRename weakUpdateNodeAndChildrenForRename;
|
||||||
void (^updateNodeAndChildrenForRename)(FileListNode*);
|
UpdateNodeAndChildrenForRename updateNodeAndChildrenForRename;
|
||||||
weakUpdateNodeAndChildrenForRename = updateNodeAndChildrenForRename = ^(FileListNode* node) {
|
weakUpdateNodeAndChildrenForRename = updateNodeAndChildrenForRename = ^(FileListNode* node) {
|
||||||
[node updateFromOldName:oldName toNewName:newName inPath:path];
|
[node updateFromOldName:oldName toNewName:newName inPath:path];
|
||||||
|
|
|
@ -702,7 +702,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
NSInteger pieceCount = MIN(torrent.pieceCount, MAX_PIECES);
|
NSInteger pieceCount = MIN(torrent.pieceCount, MAX_PIECES);
|
||||||
float* piecesPercent = malloc(pieceCount * sizeof(float));
|
float* piecesPercent = static_cast<float*>(malloc(pieceCount * sizeof(float)));
|
||||||
[torrent getAmountFinished:piecesPercent size:pieceCount];
|
[torrent getAmountFinished:piecesPercent size:pieceCount];
|
||||||
|
|
||||||
NSBitmapImageRep* bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:nil pixelsWide:pieceCount pixelsHigh:1
|
NSBitmapImageRep* bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:nil pixelsWide:pieceCount pixelsHigh:1
|
|
@ -63,7 +63,7 @@
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
typeof(self) other = (typeof(self))object;
|
auto other = static_cast<decltype(self)>(object);
|
||||||
if (self.torrent != other.torrent)
|
if (self.torrent != other.torrent)
|
||||||
{
|
{
|
||||||
return NO;
|
return NO;
|
Loading…
Reference in New Issue