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()
|
||||
|
||||
set(${PROJECT_NAME}_SOURCES
|
||||
AboutWindowController.m
|
||||
AddMagnetWindowController.m
|
||||
AddWindowController.m
|
||||
BadgeView.m
|
||||
Badger.m
|
||||
BlocklistDownloader.m
|
||||
BlocklistDownloaderViewController.m
|
||||
BlocklistScheduler.m
|
||||
BonjourController.m
|
||||
ButtonToolbarItem.m
|
||||
ColorTextField.m
|
||||
Controller.m
|
||||
CreatorWindowController.m
|
||||
DragOverlayView.m
|
||||
DragOverlayWindow.m
|
||||
ExpandedPathToIconTransformer.m
|
||||
ExpandedPathToPathTransformer.m
|
||||
FileListNode.m
|
||||
FileNameCell.m
|
||||
FileOutlineController.m
|
||||
FileOutlineView.m
|
||||
FilePriorityCell.m
|
||||
FileRenameSheetController.m
|
||||
FilterBarController.m
|
||||
FilterBarView.m
|
||||
FilterButton.m
|
||||
GlobalOptionsPopoverViewController.m
|
||||
GroupToolbarItem.m
|
||||
GroupsController.m
|
||||
GroupsPrefsController.m
|
||||
InfoActivityViewController.m
|
||||
InfoFileViewController.m
|
||||
InfoGeneralViewController.m
|
||||
InfoOptionsViewController.m
|
||||
InfoPeersViewController.m
|
||||
InfoTabButtonBack.m
|
||||
InfoTabButtonCell.m
|
||||
InfoTextField.m
|
||||
InfoTrackersViewController.m
|
||||
InfoWindowController.m
|
||||
main.m
|
||||
MessageWindowController.m
|
||||
NSApplicationAdditions.m
|
||||
NSImageAdditions.m
|
||||
NSMutableArrayAdditions.m
|
||||
NSStringAdditions.m
|
||||
PeerProgressIndicatorCell.m
|
||||
PeerTableView.m
|
||||
PiecesView.m
|
||||
PortChecker.m
|
||||
PredicateEditorRowTemplateAny.m
|
||||
PrefsController.m
|
||||
PrefsWindow.m
|
||||
ProgressGradients.m
|
||||
ShareToolbarItem.m
|
||||
ShareTorrentFileHelper.m
|
||||
StatsWindowController.m
|
||||
StatusBarController.m
|
||||
StatusBarView.m
|
||||
ToolbarSegmentedCell.m
|
||||
Torrent.m
|
||||
TorrentCell.m
|
||||
TorrentGroup.m
|
||||
TorrentTableView.m
|
||||
TrackerCell.m
|
||||
TrackerNode.m
|
||||
TrackerTableView.m
|
||||
URLSheetWindowController.m
|
||||
WebSeedTableView.m
|
||||
AboutWindowController.mm
|
||||
AddMagnetWindowController.mm
|
||||
AddWindowController.mm
|
||||
BadgeView.mm
|
||||
Badger.mm
|
||||
BlocklistDownloader.mm
|
||||
BlocklistDownloaderViewController.mm
|
||||
BlocklistScheduler.mm
|
||||
BonjourController.mm
|
||||
ButtonToolbarItem.mm
|
||||
ColorTextField.mm
|
||||
Controller.mm
|
||||
CreatorWindowController.mm
|
||||
DragOverlayView.mm
|
||||
DragOverlayWindow.mm
|
||||
ExpandedPathToIconTransformer.mm
|
||||
ExpandedPathToPathTransformer.mm
|
||||
FileListNode.mm
|
||||
FileNameCell.mm
|
||||
FileOutlineController.mm
|
||||
FileOutlineView.mm
|
||||
FilePriorityCell.mm
|
||||
FileRenameSheetController.mm
|
||||
FilterBarController.mm
|
||||
FilterBarView.mm
|
||||
FilterButton.mm
|
||||
GlobalOptionsPopoverViewController.mm
|
||||
GroupToolbarItem.mm
|
||||
GroupsController.mm
|
||||
GroupsPrefsController.mm
|
||||
InfoActivityViewController.mm
|
||||
InfoFileViewController.mm
|
||||
InfoGeneralViewController.mm
|
||||
InfoOptionsViewController.mm
|
||||
InfoPeersViewController.mm
|
||||
InfoTabButtonBack.mm
|
||||
InfoTabButtonCell.mm
|
||||
InfoTextField.mm
|
||||
InfoTrackersViewController.mm
|
||||
InfoWindowController.mm
|
||||
main.mm
|
||||
MessageWindowController.mm
|
||||
NSApplicationAdditions.mm
|
||||
NSImageAdditions.mm
|
||||
NSMutableArrayAdditions.mm
|
||||
NSStringAdditions.mm
|
||||
PeerProgressIndicatorCell.mm
|
||||
PeerTableView.mm
|
||||
PiecesView.mm
|
||||
PortChecker.mm
|
||||
PredicateEditorRowTemplateAny.mm
|
||||
PrefsController.mm
|
||||
PrefsWindow.mm
|
||||
ProgressGradients.mm
|
||||
ShareToolbarItem.mm
|
||||
ShareTorrentFileHelper.mm
|
||||
StatsWindowController.mm
|
||||
StatusBarController.mm
|
||||
StatusBarView.mm
|
||||
ToolbarSegmentedCell.mm
|
||||
Torrent.mm
|
||||
TorrentCell.mm
|
||||
TorrentGroup.mm
|
||||
TorrentTableView.mm
|
||||
TrackerCell.mm
|
||||
TrackerNode.mm
|
||||
TrackerTableView.mm
|
||||
URLSheetWindowController.mm
|
||||
WebSeedTableView.mm
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_HEADERS
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#import <Cocoa/Cocoa.h>
|
||||
#import <Quartz/Quartz.h>
|
||||
|
||||
#import <Sparkle/SUUpdaterDelegate.h>
|
||||
|
||||
#include <libtransmission/transmission.h>
|
||||
|
||||
#import "VDKQueue.h"
|
||||
|
@ -49,7 +51,7 @@ typedef NS_ENUM(unsigned int, addType) { //
|
|||
};
|
||||
|
||||
@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 TorrentTableView* fTableView;
|
||||
|
|
|
@ -1309,7 +1309,7 @@ static void removeKeRangerRansomware()
|
|||
|
||||
- (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
|
||||
|
@ -4204,9 +4204,9 @@ static void removeKeRangerRansomware()
|
|||
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];
|
||||
button.bezelStyle = NSTexturedRoundedBezelStyle;
|
|
@ -420,7 +420,7 @@
|
|||
|
||||
for (Torrent* torrent in fTorrents)
|
||||
{
|
||||
torrent.ratioSetting = setting;
|
||||
torrent.ratioSetting = static_cast<tr_ratiolimit>(setting);
|
||||
}
|
||||
|
||||
fRatioLimitField.hidden = !single;
|
||||
|
@ -470,7 +470,7 @@
|
|||
|
||||
for (Torrent* torrent in fTorrents)
|
||||
{
|
||||
torrent.idleSetting = setting;
|
||||
torrent.idleSetting = static_cast<tr_idlelimit>(setting);
|
||||
}
|
||||
|
||||
fIdleLimitField.hidden = !single;
|
|
@ -765,7 +765,7 @@
|
|||
|
||||
- (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
|
|
@ -1,11 +1,11 @@
|
|||
project(trmacql)
|
||||
|
||||
set(${PROJECT_NAME}_SOURCES
|
||||
../NSApplicationAdditions.m
|
||||
../NSStringAdditions.m
|
||||
GeneratePreviewForURL.m
|
||||
GenerateThumbnailForURL.m
|
||||
main.c
|
||||
../NSApplicationAdditions.mm
|
||||
../NSStringAdditions.mm
|
||||
GeneratePreviewForURL.mm
|
||||
GenerateThumbnailForURL.mm
|
||||
main.cc
|
||||
)
|
||||
|
||||
set(${PROJECT_NAME}_HEADERS
|
||||
|
|
|
@ -105,7 +105,7 @@ QuickLookGeneratorPluginType* AllocQuickLookGeneratorPluginType(CFUUIDRef inFact
|
|||
memcpy(theNewInstance->conduitInterface, &myInterfaceFtbl, sizeof(QLGeneratorInterfaceStruct));
|
||||
|
||||
/* Retain and keep an open instance refcount for each factory. */
|
||||
theNewInstance->factoryID = CFRetain(inFactoryID);
|
||||
theNewInstance->factoryID = static_cast<CFUUIDRef>(CFRetain(inFactoryID));
|
||||
CFPlugInAddInstanceForFactory(inFactoryID);
|
||||
|
||||
/* 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];
|
||||
}
|
||||
|
||||
NSInteger const webSeedCount = fStat->webseedsSendingToUs;
|
||||
if (webSeedCount > 0)
|
||||
if (NSInteger const webSeedCount = fStat->webseedsSendingToUs; webSeedCount > 0)
|
||||
{
|
||||
NSString* webSeedString;
|
||||
if (webSeedCount == 1)
|
||||
|
@ -1661,7 +1660,7 @@ bool trashDataFile(char const* filename, tr_error** error)
|
|||
- (void)setFileCheckState:(NSInteger)state forIndexes:(NSIndexSet*)indexSet
|
||||
{
|
||||
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++)
|
||||
{
|
||||
files[i] = index;
|
||||
|
@ -1677,7 +1676,7 @@ bool trashDataFile(char const* filename, tr_error** error)
|
|||
- (void)setFilePriority:(tr_priority_t)priority forIndexes:(NSIndexSet*)indexSet
|
||||
{
|
||||
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++)
|
||||
{
|
||||
files[i] = index;
|
||||
|
@ -1899,18 +1898,18 @@ bool trashDataFile(char const* filename, tr_error** error)
|
|||
tr_parse_result result = TR_PARSE_ERR;
|
||||
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)
|
||||
{
|
||||
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
|
||||
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)
|
||||
|
@ -2173,9 +2172,12 @@ bool trashDataFile(char const* filename, tr_error** error)
|
|||
|
||||
if (success)
|
||||
{
|
||||
using WeakUpdateNodeAndChildrenForRename = void (^__block __weak)(FileListNode*);
|
||||
using UpdateNodeAndChildrenForRename = void (^)(FileListNode*);
|
||||
|
||||
NSString* oldName = oldPath.lastPathComponent;
|
||||
void (^__block __weak weakUpdateNodeAndChildrenForRename)(FileListNode*);
|
||||
void (^updateNodeAndChildrenForRename)(FileListNode*);
|
||||
WeakUpdateNodeAndChildrenForRename weakUpdateNodeAndChildrenForRename;
|
||||
UpdateNodeAndChildrenForRename updateNodeAndChildrenForRename;
|
||||
weakUpdateNodeAndChildrenForRename = updateNodeAndChildrenForRename = ^(FileListNode* node) {
|
||||
[node updateFromOldName:oldName toNewName:newName inPath:path];
|
||||
|
|
@ -702,7 +702,7 @@
|
|||
}
|
||||
|
||||
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];
|
||||
|
||||
NSBitmapImageRep* bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:nil pixelsWide:pieceCount pixelsHigh:1
|
|
@ -63,7 +63,7 @@
|
|||
return NO;
|
||||
}
|
||||
|
||||
typeof(self) other = (typeof(self))object;
|
||||
auto other = static_cast<decltype(self)>(object);
|
||||
if (self.torrent != other.torrent)
|
||||
{
|
||||
return NO;
|
Loading…
Reference in New Issue