bug 289243, Camino should handle .ftploc files, r=cl, sr=mento. Patch by Wevah (mozilla@derailer.org)

This commit is contained in:
hwaara%gmail.com 2006-05-16 22:34:41 +00:00
Родитель 30bf4ab4cd
Коммит 993647fa92
6 изменённых файлов: 33 добавлений и 21 удалений

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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