[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

kocienda kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:02:43 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 357eb7e011bcf3f377883175bfa9f2466557c44b
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Nov 18 15:52:20 2002 +0000

    WebKit:
    
    	Added feature to import bookmarks/favorites from MSIE. This
    	fixes Radar 2961230 (import Mac IE bookmarks).
    
            * Bookmarks.subproj/WebBookmarkImporter.h: Added.
            * Bookmarks.subproj/WebBookmarkImporter.m: Added.
            (_breakStringIntoLines):
            (_HREFRangeFromSpec):
            (_HREFTextFromSpec):
            (_linkTextRangeFromSpec):
            (_linkTextFromSpec):
            (-[WebBookmarkImporter initWithPath:group:]):
            (-[WebBookmarkImporter topBookmark]):
            (-[WebBookmarkImporter error]):
            (-[WebBookmarkImporter dealloc]):
            * Bookmarks.subproj/WebBookmarkList.m:
            (-[WebBookmarkList init]): Create the bookmark list object. This
    	was not created with the -init initializer, causing bookmark lists
    	to fail.
            * English.lproj/Localizable.strings:
            * English.lproj/StringsNotToBeLocalized.txt:
            * WebKit.exp:
            * WebKit.pbproj/project.pbxproj:
    
    WebBrowser:
    
    	Added calls in Debug menu to import IE Favorites.
    	No doubt that this code will move somewhere else once
    	we figure out the interaction design for importing
    	bookmarks.
    
            * Debug/DebugUtilities.m:
            (-[DebugUtilities createDebugMenu]):
            (-[BrowserDocument importInteretExplorerBookmarks:]):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2730 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/Bookmarks.subproj/WebBookmarkImporter.h b/WebKit/Bookmarks.subproj/WebBookmarkImporter.h
new file mode 100644
index 0000000..078946e
--- /dev/null
+++ b/WebKit/Bookmarks.subproj/WebBookmarkImporter.h
@@ -0,0 +1,28 @@
+//
+//  WebBookmarkImporter.h
+//  WebKit
+//
+//  Created by Ken Kocienda on Sun Nov 17 2002.
+//  Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+ at class WebError;
+ at class WebBookmark;
+ at class WebBookmarkGroup;
+
+#define InteretExplorerBookmarksPath \
+    ([NSString stringWithFormat:@"%@/%@", NSHomeDirectory(), @"Library/Preferences/Explorer/Favorites.html"])
+
+ at interface WebBookmarkImporter : NSObject 
+{
+    WebBookmark *topBookmark;
+    WebError *error;
+}
+
+-(id)initWithPath:(NSString *)path group:(WebBookmarkGroup *)group;
+-(WebBookmark *)topBookmark;
+-(WebError *)error;
+
+ at end
diff --git a/WebKit/Bookmarks.subproj/WebBookmarkImporter.m b/WebKit/Bookmarks.subproj/WebBookmarkImporter.m
new file mode 100644
index 0000000..bee7c25
--- /dev/null
+++ b/WebKit/Bookmarks.subproj/WebBookmarkImporter.m
@@ -0,0 +1,301 @@
+//
+//  WebBookmarkImporter.m
+//  WebKit
+//
+//  Created by Ken Kocienda on Sun Nov 17 2002.
+//  Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+//
+
+#import "WebBookmarkImporter.h"
+
+#import <WebFoundation/WebError.h>
+#import <WebFoundation/WebLocalizableStrings.h>
+#import <WebKit/WebBookmark.h>
+#import <WebKit/WebBookmarkPrivate.h>
+#import <WebKit/WebBookmarkGroup.h>
+#import <WebKit/WebKitErrors.h>
+
+static NSMutableArray *_breakStringIntoLines(NSString *string)
+{
+    unsigned length;
+    unsigned index;
+    unsigned lineStart;
+    unsigned lineEnd;
+    unichar c;
+    BOOL crlf;
+    BOOL blankLine;
+    NSString *line;
+    NSCharacterSet *whitespaceCharacterSet;
+
+    NSMutableArray *lines = [NSMutableArray array];
+
+    length = [string length];
+    index = 0;
+    lineStart = 0;
+    lineEnd = 0;
+    crlf = NO;
+    blankLine = YES;
+    whitespaceCharacterSet = [NSCharacterSet whitespaceCharacterSet];
+    
+    while (index < length) {
+        crlf = NO;
+        c = [string characterAtIndex:index];
+        switch (c) {
+            case '\r':
+                if (index < length - 1) {
+                    if ([string characterAtIndex:index + 1] == '\n') {
+                        index++;
+                        crlf = YES;
+                    }
+                }
+                // fall through
+            case '\n':
+            case 0x2028: // unicode line break character
+            case 0x2029: // ditto
+                if (!blankLine) {
+                    line = [string substringWithRange:NSMakeRange(lineStart, lineEnd - lineStart + 1)];
+                    line = [line stringByTrimmingCharactersInSet:whitespaceCharacterSet];
+                    [lines addObject:line];
+                    blankLine = YES;
+                }
+                lineStart = index + 1;
+                if (crlf) {
+                    lineStart++;
+                }
+                break;
+            default:
+                blankLine = NO;
+                lineEnd = index;
+                break;
+        }
+        
+        index++;
+    }
+    
+    return lines;
+}
+
+static NSRange _HREFRangeFromSpec(NSString *spec)
+{
+    NSRange result;
+    unsigned startIndex;
+    unsigned endIndex;
+    int length;
+    int i;
+    unichar c;
+    NSRange range;
+
+    result.location = NSNotFound;
+    result.length = -1;
+    length = [spec length];
+    startIndex = 0;
+    endIndex = 0;
+
+    range = [spec rangeOfString:@"HREF="];
+    if (range.location == NSNotFound) {
+        return result;
+    }
+    startIndex = range.location + range.length;
+    // account for quote
+    startIndex++;
+
+    endIndex = length - startIndex;
+    for (i = startIndex; i < length; i++) {
+        c = [spec characterAtIndex:i];
+        if (c == '"') {
+            endIndex = i;
+            break;
+        }
+    }
+
+    result.location = startIndex;
+    result.length = endIndex - startIndex;
+
+    return result;
+}
+
+static NSString *_HREFTextFromSpec(NSString *spec)
+{
+    NSString *result = nil;
+
+    NSRange range = _HREFRangeFromSpec(spec);
+    
+    if (range.location != NSNotFound) {
+        result = [spec substringWithRange:range];
+    }
+    
+    return result;
+}
+
+static NSRange _linkTextRangeFromSpec(NSString *spec)
+{
+    NSRange result;
+    unsigned startIndex;
+    unsigned endIndex;
+    int closeBrackets;
+    int openBrackets;
+    int length;
+    int i;
+    unichar c;
+    
+    result.location = NSNotFound;
+    result.length = -1;
+    length = [spec length];
+    startIndex = 0;
+    endIndex = 0;
+
+    closeBrackets = 0;
+    for (i = 0; i < length; i++) {
+        c = [spec characterAtIndex:i];
+        if (c == '>') {
+            closeBrackets++;
+        }
+        else if (closeBrackets == 2 && startIndex == 0) {
+            startIndex = i;
+            break;
+        }
+    }
+
+    openBrackets = 0;
+    for (i = length - 1; i > 0; i--) {
+        c = [spec characterAtIndex:i];
+        if (c == '<') {
+            openBrackets = 1;
+        }
+        else if (openBrackets == 1) {
+            endIndex = i + 1;
+            break;
+        }
+    }
+
+    if (startIndex > 0 && endIndex > startIndex) {
+        result.location = startIndex;
+        result.length = endIndex - startIndex;
+    }
+    
+    return result;
+}
+
+static NSString *_linkTextFromSpec(NSString *spec)
+{
+    NSString *result = nil;
+
+    NSRange range = _linkTextRangeFromSpec(spec);
+    
+    if (range.location != NSNotFound) {
+        result = [spec substringWithRange:range];
+    }
+    
+    return result;
+}
+
+
+ at implementation WebBookmarkImporter
+
+-(id)initWithPath:(NSString *)path group:(WebBookmarkGroup *)group
+{
+    self = [super init];
+    if (!self) {
+        return nil;
+    }
+    
+    NSData *data = [[NSData alloc] initWithContentsOfFile:path];
+    if (!data) {
+        error = [WebError errorWithCode:WebErrorCannotOpenFile inDomain:WebErrorDomainWebKit failingURL:path];
+    }
+
+    NSString *string = [[NSString alloc] initWithData:data encoding:NSISOLatin1StringEncoding];
+    NSArray *lines = _breakStringIntoLines(string);
+    int lineCount = [lines count];
+    int i;
+    
+    WebBookmark *bookmark;
+    WebBookmark *currentBookmarkList;
+    NSMutableArray *bookmarkLists = [NSMutableArray array];
+    unsigned numberOfChildren;
+    
+    // create the top-level folder
+    topBookmark = [[WebBookmark bookmarkOfType:WebBookmarkTypeList] retain];
+    [topBookmark setTitle:UI_STRING("Imported IE Favorites", "Imported IE Favorites menu item")];
+    [topBookmark _setGroup:group];
+    [bookmarkLists addObject:topBookmark];
+    
+    for (i = 0; i < lineCount; i++) {
+        NSString *line = [lines objectAtIndex:i];
+        
+        if ([line hasPrefix:@"<DL>"]) {
+            // ignore this line
+            // we recognize new lists by parsing "<DT><H" lines
+        }
+        else if ([line hasPrefix:@"<DT><H"]) {
+            // a bookmark folder specifier
+            bookmark = [WebBookmark bookmarkOfType:WebBookmarkTypeList];
+            currentBookmarkList = [bookmarkLists lastObject];
+            // find the folder name
+            NSString *title = _linkTextFromSpec(line);
+            if (!title) {
+                continue;
+            }
+            [bookmark setTitle:title];
+            numberOfChildren = [currentBookmarkList numberOfChildren];
+            [currentBookmarkList insertChild:bookmark atIndex:numberOfChildren];
+            [bookmarkLists addObject:bookmark];
+        }
+        else if ([line hasPrefix:@"<DT><A"]) {
+            // a bookmark or folder specifier
+            bookmark = [WebBookmark bookmarkOfType:WebBookmarkTypeLeaf];
+            currentBookmarkList = [bookmarkLists lastObject];
+            // find the folder name
+            NSString *title = _linkTextFromSpec(line);
+            if (!title) {
+                continue;
+            }
+            if ([title isEqualToString:@"-"]) {
+                // skip dividers
+                continue;
+            }
+            [bookmark setTitle:title];
+            NSString *href = _HREFTextFromSpec(line);
+            if (!href) {
+                continue;
+            }
+            [bookmark setURLString:href];
+            numberOfChildren = [currentBookmarkList numberOfChildren];
+            [currentBookmarkList insertChild:bookmark atIndex:numberOfChildren];
+        }
+        else if ([line hasPrefix:@"</DL>"]) {
+            // ends a bookmark list
+            [bookmarkLists removeLastObject];
+        }
+        else {
+            // ignore this line
+        }
+    }
+
+    bookmark = [group topBookmark];
+    numberOfChildren = [bookmark numberOfChildren];
+    [bookmark insertChild:topBookmark atIndex:numberOfChildren];
+    
+    return self;
+}
+
+-(WebBookmark *)topBookmark
+{
+    return topBookmark;
+}
+
+-(WebError *)error
+{
+    return error;
+}
+
+-(void)dealloc
+{
+    [topBookmark release];
+    [error release];
+    
+    [super dealloc];
+}
+
+ at end
+
diff --git a/WebKit/Bookmarks.subproj/WebBookmarkList.m b/WebKit/Bookmarks.subproj/WebBookmarkList.m
index a01998e..f07cef1 100644
--- a/WebKit/Bookmarks.subproj/WebBookmarkList.m
+++ b/WebKit/Bookmarks.subproj/WebBookmarkList.m
@@ -17,6 +17,15 @@
 
 @implementation WebBookmarkList
 
+- (id)init
+{
+    [super init];
+
+    _list = [[NSMutableArray alloc] init];
+    
+    return self;
+}
+
 - (id)initWithTitle:(NSString *)title
               group:(WebBookmarkGroup *)group
 {
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index b2e7f88..25b8b4a 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,28 @@
+2002-11-18  Ken Kocienda  <kocienda at apple.com>
+
+	Added feature to import bookmarks/favorites from MSIE. This
+	fixes Radar 2961230 (import Mac IE bookmarks).
+
+        * Bookmarks.subproj/WebBookmarkImporter.h: Added.
+        * Bookmarks.subproj/WebBookmarkImporter.m: Added.
+        (_breakStringIntoLines):
+        (_HREFRangeFromSpec):
+        (_HREFTextFromSpec):
+        (_linkTextRangeFromSpec):
+        (_linkTextFromSpec):
+        (-[WebBookmarkImporter initWithPath:group:]):
+        (-[WebBookmarkImporter topBookmark]):
+        (-[WebBookmarkImporter error]):
+        (-[WebBookmarkImporter dealloc]):
+        * Bookmarks.subproj/WebBookmarkList.m:
+        (-[WebBookmarkList init]): Create the bookmark list object. This
+	was not created with the -init initializer, causing bookmark lists
+	to fail.
+        * English.lproj/Localizable.strings:
+        * English.lproj/StringsNotToBeLocalized.txt:
+        * WebKit.exp:
+        * WebKit.pbproj/project.pbxproj:
+
 2002-11-17  Trey Matteson  <trey at apple.com>
 
 	Code cleanup to make some internal methods return autoreleased objects.
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index b2e7f88..25b8b4a 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,28 @@
+2002-11-18  Ken Kocienda  <kocienda at apple.com>
+
+	Added feature to import bookmarks/favorites from MSIE. This
+	fixes Radar 2961230 (import Mac IE bookmarks).
+
+        * Bookmarks.subproj/WebBookmarkImporter.h: Added.
+        * Bookmarks.subproj/WebBookmarkImporter.m: Added.
+        (_breakStringIntoLines):
+        (_HREFRangeFromSpec):
+        (_HREFTextFromSpec):
+        (_linkTextRangeFromSpec):
+        (_linkTextFromSpec):
+        (-[WebBookmarkImporter initWithPath:group:]):
+        (-[WebBookmarkImporter topBookmark]):
+        (-[WebBookmarkImporter error]):
+        (-[WebBookmarkImporter dealloc]):
+        * Bookmarks.subproj/WebBookmarkList.m:
+        (-[WebBookmarkList init]): Create the bookmark list object. This
+	was not created with the -init initializer, causing bookmark lists
+	to fail.
+        * English.lproj/Localizable.strings:
+        * English.lproj/StringsNotToBeLocalized.txt:
+        * WebKit.exp:
+        * WebKit.pbproj/project.pbxproj:
+
 2002-11-17  Trey Matteson  <trey at apple.com>
 
 	Code cleanup to make some internal methods return autoreleased objects.
diff --git a/WebKit/English.lproj/Localizable.strings b/WebKit/English.lproj/Localizable.strings
index 4518f53..548eabd 100644
Binary files a/WebKit/English.lproj/Localizable.strings and b/WebKit/English.lproj/Localizable.strings differ
diff --git a/WebKit/English.lproj/StringsNotToBeLocalized.txt b/WebKit/English.lproj/StringsNotToBeLocalized.txt
index 2d8a7ea..98d14e1 100644
--- a/WebKit/English.lproj/StringsNotToBeLocalized.txt
+++ b/WebKit/English.lproj/StringsNotToBeLocalized.txt
@@ -11,6 +11,7 @@
 "%lf"
 "(This file must be converted with BinHex 4.0)"
 ","
+"-"
 "."
 "/"
 "/<!--frame%d-->-->"
@@ -26,6 +27,10 @@
 "7"
 ";"
 "<!--framePath "
+"</DL>"
+"<DL>"
+"<DT><A"
+"<DT><H"
 "="
 "ANIMEXTS1"
 "Apple Chancery"
@@ -52,6 +57,7 @@
 "DirectionS"
 "DirectionWS"
 "GET"
+"HREF="
 "Helvetica"
 "IE"
 "JoiningCausing"
diff --git a/WebKit/WebKit.exp b/WebKit/WebKit.exp
index 77a8249..c026e52 100644
--- a/WebKit/WebKit.exp
+++ b/WebKit/WebKit.exp
@@ -1,5 +1,6 @@
 .objc_class_name_WebBookmark
 .objc_class_name_WebBookmarkGroup
+.objc_class_name_WebBookmarkImporter
 .objc_class_name_WebController
 .objc_class_name_WebCoreStatistics
 .objc_class_name_WebDataSource
diff --git a/WebKit/WebKit.pbproj/project.pbxproj b/WebKit/WebKit.pbproj/project.pbxproj
index 1fd8ee0..6762cc5 100644
--- a/WebKit/WebKit.pbproj/project.pbxproj
+++ b/WebKit/WebKit.pbproj/project.pbxproj
@@ -196,6 +196,7 @@
 				F5065222027F557E01C1A526,
 				F5065224027F557E01C1A526,
 				F50AD3880282028B01C1A526,
+				BED907780389380000CA289C,
 				F5065226027F557E01C1A526,
 				F5065228027F557E01C1A526,
 				F5065221027F557E01C1A526,
@@ -413,6 +414,7 @@
 				83413E8A0375BCBE004719BE,
 				83413E900375BCD3004719BE,
 				9316400F0379832D008635CE,
+				BED907790389380000CA289C,
 			);
 			isa = PBXSourcesBuildPhase;
 			runOnlyForDeploymentPostprocessing = 0;
@@ -2244,6 +2246,43 @@
 //9C2
 //9C3
 //9C4
+//BE0
+//BE1
+//BE2
+//BE3
+//BE4
+		BED907760389380000CA289C = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			path = WebBookmarkImporter.h;
+			refType = 4;
+		};
+		BED907770389380000CA289C = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			path = WebBookmarkImporter.m;
+			refType = 4;
+		};
+		BED907780389380000CA289C = {
+			fileRef = BED907760389380000CA289C;
+			isa = PBXBuildFile;
+			settings = {
+				ATTRIBUTES = (
+					Private,
+				);
+			};
+		};
+		BED907790389380000CA289C = {
+			fileRef = BED907770389380000CA289C;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+//BE0
+//BE1
+//BE2
+//BE3
+//BE4
 //ED0
 //ED1
 //ED2
@@ -2339,6 +2378,8 @@
 				F50AD3870282028B01C1A526,
 				F506521B027F557E01C1A526,
 				F506521C027F557E01C1A526,
+				BED907760389380000CA289C,
+				BED907770389380000CA289C,
 				F506521D027F557E01C1A526,
 				F506521E027F557E01C1A526,
 				F506521F027F557E01C1A526,

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list