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
This commit is contained in:
hwaara%gmail.com
2006-05-16 22:36:18 +00:00
parent e66da9285b
commit a36bfc0968
6 changed files with 33 additions and 21 deletions

View File

@@ -75,6 +75,7 @@
<key>CFBundleTypeExtensions</key>
<array>
<string>webloc</string>
<string>ftploc</string>
<string>url</string>
</array>
<key>CFBundleTypeIconFile</key>
@@ -84,6 +85,8 @@
<key>CFBundleTypeOSTypes</key>
<array>
<string>ilht</string>
<string>ilft</string>
<string>LINK</string>
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>

View File

@@ -75,6 +75,7 @@
<key>CFBundleTypeExtensions</key>
<array>
<string>webloc</string>
<string>ftploc</string>
<string>url</string>
</array>
<key>CFBundleTypeIconFile</key>
@@ -84,6 +85,8 @@
<key>CFBundleTypeOSTypes</key>
<array>
<string>ilht</string>
<string>ilft</string>
<string>LINK</string>
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>

View File

@@ -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)

View File

@@ -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];

View File

@@ -41,7 +41,7 @@
@interface NSURL (CaminoExtensions)
+(NSURL*)urlFromWebloc:(NSString*)inFile;
+(NSURL*)urlFromIEURLFile:(NSString*)inFile;
+(NSURL*)URLFromInetloc:(NSString*)inFile;
+(NSURL*)URLFromIEURLFile:(NSString*)inFile;
@end

View File

@@ -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;