From aee103075852019566f3da7fede006540b3a38ab Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Thu, 3 Sep 2020 14:10:08 -0400 Subject: [PATCH] Copy device identifier from macOS menu item. --- .../Source/Mac/Base.lproj/MainMenu.xib | 22 +++++++++++++++++-- platform-darwin/Source/Mac/MPMacAppDelegate.h | 1 + platform-darwin/Source/Mac/MPMacAppDelegate.m | 6 +++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/platform-darwin/Source/Mac/Base.lproj/MainMenu.xib b/platform-darwin/Source/Mac/Base.lproj/MainMenu.xib index 02a42378..ed525d43 100644 --- a/platform-darwin/Source/Mac/Base.lproj/MainMenu.xib +++ b/platform-darwin/Source/Mac/Base.lproj/MainMenu.xib @@ -1,8 +1,8 @@ - + - + @@ -199,6 +199,7 @@ + @@ -216,6 +217,23 @@ + + + + + + + + + + + + + + + + + diff --git a/platform-darwin/Source/Mac/MPMacAppDelegate.h b/platform-darwin/Source/Mac/MPMacAppDelegate.h index 8de27882..5adc00e9 100644 --- a/platform-darwin/Source/Mac/MPMacAppDelegate.h +++ b/platform-darwin/Source/Mac/MPMacAppDelegate.h @@ -42,6 +42,7 @@ - (IBAction)showPasswordWindow:(id)sender; - (void)setLoginItemEnabled:(BOOL)enabled; - (IBAction)togglePreference:(id)sender; +- (IBAction)copyIdentifier:(id)sender; - (IBAction)newUser:(NSMenuItem *)sender; - (IBAction)lock:(id)sender; - (IBAction)terminate:(id)sender; diff --git a/platform-darwin/Source/Mac/MPMacAppDelegate.m b/platform-darwin/Source/Mac/MPMacAppDelegate.m index a74e0d23..737a2ad9 100644 --- a/platform-darwin/Source/Mac/MPMacAppDelegate.m +++ b/platform-darwin/Source/Mac/MPMacAppDelegate.m @@ -435,6 +435,12 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven [self updateMenuItems]; } +- (IBAction)copyIdentifier:(id)sender { + [[NSPasteboard generalPasteboard] declareTypes:@[ NSStringPboardType ] owner:nil]; + if (![[NSPasteboard generalPasteboard] setString:[PearlKeyChain deviceIdentifier] forType:NSPasteboardTypeString]) + wrn( @"Couldn't copy device identifier to pasteboard." ); +} + - (IBAction)newUser:(NSMenuItem *)sender { NSAlert *alert = [NSAlert new];