From a36bfc0968843115b16e55c8d660b4d511199b0e Mon Sep 17 00:00:00 2001 From: "hwaara%gmail.com" Date: Tue, 16 May 2006 22:36:18 +0000 Subject: [PATCH] bug 289243, Camino should handle .ftploc files, r=cl, sr=mento. Patch by Wevah (mozilla@derailer.org) git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@196709 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/camino/Info-Camino.plist | 3 +++ mozilla/camino/Info-CaminoStatic.plist | 3 +++ .../camino/src/application/MainController.mm | 23 +++++++++++-------- .../src/extensions/NSPasteboard+Utils.mm | 15 ++++++------ mozilla/camino/src/extensions/NSURL+Utils.h | 4 ++-- mozilla/camino/src/extensions/NSURL+Utils.m | 6 ++--- 6 files changed, 33 insertions(+), 21 deletions(-) diff --git a/mozilla/camino/Info-Camino.plist b/mozilla/camino/Info-Camino.plist index 01bcdcbcc46..92acd0bdd7e 100644 --- a/mozilla/camino/Info-Camino.plist +++ b/mozilla/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/mozilla/camino/Info-CaminoStatic.plist b/mozilla/camino/Info-CaminoStatic.plist index 01bcdcbcc46..92acd0bdd7e 100644 --- a/mozilla/camino/Info-CaminoStatic.plist +++ b/mozilla/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/mozilla/camino/src/application/MainController.mm b/mozilla/camino/src/application/MainController.mm index 3ecf699b657..cc63032794e 100644 --- a/mozilla/camino/src/application/MainController.mm +++ b/mozilla/camino/src/application/MainController.mm @@ -580,17 +580,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; } @@ -677,9 +679,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]; @@ -720,7 +725,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/mozilla/camino/src/extensions/NSPasteboard+Utils.mm b/mozilla/camino/src/extensions/NSPasteboard+Utils.mm index 8f7659b6b52..d3797e7f031 100644 --- a/mozilla/camino/src/extensions/NSPasteboard+Utils.mm +++ b/mozilla/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/mozilla/camino/src/extensions/NSURL+Utils.h b/mozilla/camino/src/extensions/NSURL+Utils.h index ddfd6fd9ea1..bf27121ded8 100644 --- a/mozilla/camino/src/extensions/NSURL+Utils.h +++ b/mozilla/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/mozilla/camino/src/extensions/NSURL+Utils.m b/mozilla/camino/src/extensions/NSURL+Utils.m index 2441c990012..fe07b05641d 100644 --- a/mozilla/camino/src/extensions/NSURL+Utils.m +++ b/mozilla/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;