diff --git a/camino/Info-Camino.plist b/camino/Info-Camino.plist index 415c09469e2..34e5f4034a7 100644 --- a/camino/Info-Camino.plist +++ b/camino/Info-Camino.plist @@ -75,6 +75,7 @@ CFBundleTypeExtensions webloc + ftploc url CFBundleTypeIconFile @@ -84,6 +85,8 @@ CFBundleTypeOSTypes ilht + ilft + LINK CFBundleTypeRole Viewer diff --git a/camino/Info-CaminoStatic.plist b/camino/Info-CaminoStatic.plist index 415c09469e2..34e5f4034a7 100644 --- a/camino/Info-CaminoStatic.plist +++ b/camino/Info-CaminoStatic.plist @@ -75,6 +75,7 @@ CFBundleTypeExtensions webloc + ftploc url CFBundleTypeIconFile @@ -84,6 +85,8 @@ CFBundleTypeOSTypes ilht + ilft + LINK CFBundleTypeRole Viewer diff --git a/camino/src/application/MainController.mm b/camino/src/application/MainController.mm index ade4867193f..0866e3fe16f 100644 --- a/camino/src/application/MainController.mm +++ b/camino/src/application/MainController.mm @@ -579,17 +579,19 @@ const int kReuseWindowOnAE = 2; /* This takes an NSURL to a local file, and if that file is a file that contains a URL we want and isn't the content itself, we return the URL it contains. -Otherwise, we return the URL we originally got. Right now this supports .url and -.webloc files. +Otherwise, we return the URL we originally got. Right now this supports .url, +.webloc and .ftploc files. */ +(NSURL*) decodeLocalFileURL:(NSURL*)url { NSString *urlPathString = [url path]; + NSString *ext = [urlPathString pathExtension]; + OSType fileType = NSHFSTypeCodeFromFileType(NSHFSTypeOfFile(urlPathString)); - if ([[urlPathString pathExtension] isEqualToString:@"url"]) - url = [NSURL urlFromIEURLFile:urlPathString]; - else if ([[urlPathString pathExtension] isEqualToString:@"webloc"]) - url = [NSURL urlFromWebloc:urlPathString]; + if ([ext isEqualToString:@"url"] || fileType == 'LINK') + url = [NSURL URLFromIEURLFile:urlPathString]; + else if ([ext isEqualToString:@"webloc"] || [ext isEqualToString:@"ftploc"] || fileType == 'ilht' || fileType == 'ilft') + url = [NSURL URLFromInetloc:urlPathString]; return url; } @@ -676,9 +678,12 @@ Otherwise, we return the URL we originally got. Right now this supports .url and [openPanel setCanChooseDirectories:NO]; [openPanel setAllowsMultipleSelection:YES]; NSArray* fileTypes = [NSArray arrayWithObjects: @"htm",@"html",@"shtml",@"xhtml",@"xml", - @"txt",@"text", + @"txt",@"text", @"gif",@"jpg",@"jpeg",@"png",@"bmp",@"svg",@"svgz", - @"webloc",@"url", + @"webloc",@"ftploc",@"url", + NSFileTypeForHFSTypeCode('ilht'), + NSFileTypeForHFSTypeCode('ilft'), + NSFileTypeForHFSTypeCode('LINK'), nil]; BrowserWindowController* browserController = [self getMainWindowBrowserController]; @@ -719,7 +724,7 @@ Otherwise, we return the URL we originally got. Right now this supports .url and { [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:curURL]; curURL = [MainController decodeLocalFileURL:curURL]; - [urlStringsArray addObject:[curURL path]]; + [urlStringsArray addObject:[curURL absoluteString]]; } if (!browserController) diff --git a/camino/src/extensions/NSPasteboard+Utils.mm b/camino/src/extensions/NSPasteboard+Utils.mm index 8f7659b6b52..d3797e7f031 100644 --- a/camino/src/extensions/NSPasteboard+Utils.mm +++ b/camino/src/extensions/NSPasteboard+Utils.mm @@ -156,16 +156,17 @@ NSString* const kWebURLsWithTitlesPboardType = @"WebURLsWithTitlesPboardType"; NSString *ext = [file pathExtension]; NSString *urlString = nil; NSString *title = @""; + OSType fileType = NSHFSTypeCodeFromFileType(NSHFSTypeOfFile(file)); - // Check whether the file is a .webloc, a .url, or some other kind of file. - if ([ext isEqualToString:@"webloc"]) { - NSURL* urlFromWebloc = [NSURL urlFromWebloc:file]; - if (urlFromWebloc) { - urlString = [urlFromWebloc absoluteString]; + // Check whether the file is a .webloc, a .ftploc, a .url, or some other kind of file. + if ([ext isEqualToString:@"webloc"] || [ext isEqualToString:@"ftploc"] || fileType == 'ilht' || fileType == 'ilft') { + NSURL* urlFromInetloc = [NSURL URLFromInetloc:file]; + if (urlFromInetloc) { + urlString = [urlFromInetloc absoluteString]; title = [[file lastPathComponent] stringByDeletingPathExtension]; } - } else if ([ext isEqualToString:@"url"]) { - NSURL* urlFromIEURLFile = [NSURL urlFromIEURLFile:file]; + } else if ([ext isEqualToString:@"url"] || fileType == 'LINK') { + NSURL* urlFromIEURLFile = [NSURL URLFromIEURLFile:file]; if (urlFromIEURLFile) { urlString = [urlFromIEURLFile absoluteString]; title = [[file lastPathComponent] stringByDeletingPathExtension]; diff --git a/camino/src/extensions/NSURL+Utils.h b/camino/src/extensions/NSURL+Utils.h index ddfd6fd9ea1..bf27121ded8 100644 --- a/camino/src/extensions/NSURL+Utils.h +++ b/camino/src/extensions/NSURL+Utils.h @@ -41,7 +41,7 @@ @interface NSURL (CaminoExtensions) -+(NSURL*)urlFromWebloc:(NSString*)inFile; -+(NSURL*)urlFromIEURLFile:(NSString*)inFile; ++(NSURL*)URLFromInetloc:(NSString*)inFile; ++(NSURL*)URLFromIEURLFile:(NSString*)inFile; @end diff --git a/camino/src/extensions/NSURL+Utils.m b/camino/src/extensions/NSURL+Utils.m index 2441c990012..fe07b05641d 100644 --- a/camino/src/extensions/NSURL+Utils.m +++ b/camino/src/extensions/NSURL+Utils.m @@ -42,9 +42,9 @@ @implementation NSURL (CaminoExtensions) // -// Reads the URL from a .webloc file. +// Reads the URL from a .webloc/.ftploc file. // Returns the URL, or nil on failure. -+(NSURL*)urlFromWebloc:(NSString*)inFile ++(NSURL*)URLFromInetloc:(NSString*)inFile { FSRef ref; NSURL *ret = nil; @@ -83,7 +83,7 @@ // Reads the URL from a .url file. // Returns the URL or nil on failure. // -+(NSURL*)urlFromIEURLFile:(NSString*)inFile ++(NSURL*)URLFromIEURLFile:(NSString*)inFile { NSURL *ret = nil;