From 4f855450581ef6766fbb20442c796ed98a357e41 Mon Sep 17 00:00:00 2001 From: partyka1 Date: Thu, 13 Oct 2016 00:56:15 +0200 Subject: [PATCH] remove images paste logic --- Messenger/AppDelegate.mm | 42 ---------------------------------------- 1 file changed, 42 deletions(-) diff --git a/Messenger/AppDelegate.mm b/Messenger/AppDelegate.mm index 1dc76ab..42471f6 100644 --- a/Messenger/AppDelegate.mm +++ b/Messenger/AppDelegate.mm @@ -410,49 +410,7 @@ - (IBAction)findPeopleAndGroups:(id)sender { } - (IBAction)paste:(id)sender { - NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; - - // If we've got an image, let's paste it! - // Ain't nobody got time for dirty hax with React. - if ([pasteboard canReadObjectForClasses:@[[NSImage class]] options:nil]) { - NSImage *pastedImage = [[pasteboard readObjectsForClasses:@[[NSImage class]] options:nil] firstObject]; - - // Try to grab the URL to the image being pasted (if it's available) to just repurpose the already useable pasteboard. - NSURL *pastedFileURL = [[pasteboard readObjectsForClasses:@[[NSURL class]] options:nil] firstObject]; - - // If we haven't got a file URL (screenshot), we need to write it out first. - if (pastedFileURL == nil) { - // Convert the pasteboard image to a PNG. - NSRect proposedRect = NSMakeRect(0, 0, pastedImage.size.width, pastedImage.size.height); - CGImageRef pastedImageRef = [pastedImage CGImageForProposedRect:&proposedRect - context:NULL - hints:nil]; - NSBitmapImageRep *bitmapImageRep = [[NSBitmapImageRep alloc] initWithCGImage:pastedImageRef]; - NSData *PNGImageData = [bitmapImageRep representationUsingType:NSPNGFileType properties:@{}]; - - // Save it (temporarily with a new name). - NSString *uniqueFilename = [[NSUUID UUID].UUIDString stringByAppendingString:@".png"]; - NSString *tmpPath = [NSTemporaryDirectory() stringByAppendingPathComponent:uniqueFilename]; - [PNGImageData writeToFile:tmpPath atomically:YES]; - - pastedFileURL = [NSURL fileURLWithPath:tmpPath]; - - // Write our newly saved file to the pasteboard. - [pasteboard clearContents]; - [pasteboard declareTypes:@[NSFilenamesPboardType] owner:self]; - [pasteboard writeObjects:@[pastedFileURL]]; - } - - if (pastedFileURL != nil) { - // Fire off a completely falsified (and bs) drag+drop event. >:D - MMFakeDragInfo *info = [[MMFakeDragInfo alloc] initWithImage:pastedImage pasteboard:pasteboard]; - [_webView draggingEntered:info]; - [_webView draggingUpdated:info]; - [_webView performDragOperation:info]; - } - } else { [[NSApplication sharedApplication] sendAction:@selector(paste:) to:nil from:self]; - } } - (void)showActiveFriends {