Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 412 lines (293 sloc) 11.996 kb
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
1 /*
2 iMedia Browser Framework <http://karelia.com/imedia/>
3
5721575 @danwood Noticed formatting on license prelude was wonky in some files. so I fixe...
danwood authored
4 Copyright (c) 2005-2012 by Karelia Software et al.
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
5
6 iMedia Browser is based on code originally developed by Jason Terhorst,
7 further developed for Sandvox by Greg Hulands, Dan Wood, and Terrence Talbot.
8 The new architecture for version 2.0 was developed by Peter Baumgartner.
9 Contributions have also been made by Matt Gough, Martin Wennerberg and others
10 as indicated in source files.
11
12 The iMedia Browser Framework is licensed under the following terms:
13
14 Permission is hereby granted, free of charge, to any person obtaining a copy
15 of this software and associated documentation files (the "Software"), to deal
16 in all or substantial portions of the Software without restriction, including
17 without limitation the rights to use, copy, modify, merge, publish,
18 distribute, sublicense, and/or sell copies of the Software, and to permit
19 persons to whom the Software is furnished to do so, subject to the following
20 conditions:
21
22 Redistributions of source code must retain the original terms stated here,
23 including this list of conditions, the disclaimer noted below, and the
5721575 @danwood Noticed formatting on license prelude was wonky in some files. so I fixe...
danwood authored
24 following copyright notice: Copyright (c) 2005-2012 by Karelia Software et al.
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
25
26 Redistributions in binary form must include, in an end-user-visible manner,
27 e.g., About window, Acknowledgments window, or similar, either a) the original
28 terms stated here, including this list of conditions, the disclaimer noted
29 below, and the aforementioned copyright notice, or b) the aforementioned
30 copyright notice and a link to karelia.com/imedia.
31
32 Neither the name of Karelia Software, nor Sandvox, nor the names of
33 contributors to iMedia Browser may be used to endorse or promote products
34 derived from the Software without prior and express written permission from
35 Karelia Software or individual contributors, as appropriate.
36
37 Disclaimer: THE SOFTWARE IS PROVIDED BY THE COPYRIGHT OWNER AND CONTRIBUTORS
38 "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
39 LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
40 AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
41 LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF
42 CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH, THE
43 SOFTWARE OR THE USE OF, OR OTHER DEALINGS IN, THE SOFTWARE.
44 */
45
46
b650ccd @peterb180369 Cleaned up obsolete stuff
peterb180369 authored
47 //----------------------------------------------------------------------------------------------------------------------
48
49
50 // Author: Peter Baumgartner, Dan Wood
135075f Added an author line in the header of each source file. This is done to ...
Peter Baumgartner authored
51
52
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
53 //----------------------------------------------------------------------------------------------------------------------
54
55
56 #pragma mark HEADERS
57
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
58 #import "IMBSafariParser.h"
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
59 #import "IMBNode.h"
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
60 #import "IMBLinkObject.h"
21c5a6e @peterb180369 New subclass that is optimized, as it doesn't transfer thumbnail across ...
peterb180369 authored
61 #import "IMBFolderObject.h"
b650ccd @peterb180369 Cleaned up obsolete stuff
peterb180369 authored
62 #import "NSImage+iMedia.h"
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
63 #import "NSFileManager+iMedia.h"
64 #import "NSWorkspace+iMedia.h"
65
66
67 //----------------------------------------------------------------------------------------------------------------------
68
69
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
70 @interface IMBSafariParser ()
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
71 - (NSDictionary*) plist;
72 - (NSString*) identifierForPlist:(NSDictionary*)inPlist;
73 - (BOOL) isLeafPlist:(NSDictionary*)inPlist;
74 - (void) populateNode:(IMBNode*)inNode plist:(NSDictionary*)inPlist;
75 - (IMBNode*) subnodeForPlist:(NSDictionary*)inPlist;
76 - (IMBObject*) objectForPlist:(NSDictionary*)inPlist;
77 @end
78
79
80 //----------------------------------------------------------------------------------------------------------------------
81
82
83 #pragma mark
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
84
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
85 @implementation IMBSafariParser
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
86
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
87 @synthesize appPath = _appPath;
88 @synthesize plist = _plist;
89 @synthesize modificationDate = _modificationDate;
90 @synthesize safariFaviconCache = _safariFaviconCache;
91
92
93 //----------------------------------------------------------------------------------------------------------------------
94
95
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
96 - (id) init
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
97 {
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
98 if ((self = [super init]))
97df657 Bugfix: iTunes parser caused crash due to out of bounds exception in bac...
Peter Baumgartner authored
99 {
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
100 self.appPath = nil;
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
101 self.plist = nil;
102 self.modificationDate = nil;
103 self.safariFaviconCache = [NSMutableDictionary dictionary];
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
104 }
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
105
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
106 return self;
107 }
108
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
109
110 - (void) dealloc
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
111 {
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
112 IMBRelease(_appPath);
113 IMBRelease(_plist);
114 IMBRelease(_modificationDate);
115 IMBRelease(_safariFaviconCache);
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
116 [super dealloc];
117 }
118
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
119
120 //----------------------------------------------------------------------------------------------------------------------
121
122
123 #pragma mark
124 #pragma mark Parser Methods
125
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
126
127 - (IMBNode*) unpopulatedTopLevelNode:(NSError**)outError
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
128 {
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
129 NSURL* url = (NSURL*)self.mediaSource;
130 NSString* path = [url path];
131
132 NSImage* icon = [[NSWorkspace imb_threadSafeWorkspace] iconForFile:self.appPath];
133 [icon setScalesWhenResized:YES];
134 [icon setSize:NSMakeSize(16.0,16.0)];
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
135
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
136 // Create an empty (unpopulated) root node...
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
137
138 IMBNode* node = [[[IMBNode alloc] init] autorelease];
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
139 node.icon = icon;
140 node.name = @"Safari";
141 node.identifier = [self identifierForPath:@"/"];
142 node.mediaType = self.mediaType;
143 node.mediaSource = self.mediaSource;
144 node.groupType = kIMBGroupTypeLibrary;
73c059c @peterb180369 Removed redundant lines (setting isGroupNode to NO). Parser code is easi...
peterb180369 authored
145 node.parserIdentifier = self.identifier;
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
146 node.isTopLevelNode = YES;
99bb62b @peterb180369 Renamed some properties (an ivars) to be more consistent. Should also be...
peterb180369 authored
147 node.isLeafNode = NO;
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
148
149 // Watch the XML file. Whenever something in iTunes changes, we have to replace the WHOLE tree from
150 // the root node down, as we have no way of finding WHAT has changed in iPhoto...
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
151
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
152 node.watcherType = kIMBWatcherTypeFSEvent;
153 node.watchedPath = [path stringByDeletingLastPathComponent];
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
154
155 return node;
156 }
157
158
159 //----------------------------------------------------------------------------------------------------------------------
160
161
99e82a6 @mikeabdullah -populateNode:error: return a BOOL to match Cocoa error handling convent...
mikeabdullah authored
162 - (BOOL) populateNode:(IMBNode*)inNode error:(NSError**)outError
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
163 {
2cb0e28 • Renamed rootNode methods to topLevelNodes to make the names less ambig...
Peter Baumgartner authored
164 if (inNode.isTopLevelNode)
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
165 {
166 NSDictionary* plist = [self plist];
167 [self populateNode:inNode plist:plist];
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
168 }
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
169
99e82a6 @mikeabdullah -populateNode:error: return a BOOL to match Cocoa error handling convent...
mikeabdullah authored
170 return YES;
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
171 }
172
173
174 //----------------------------------------------------------------------------------------------------------------------
175
176
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
177 // Since we know that we have local files we can use the helper method supplied by the base class...
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
178
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
179 - (NSData*) bookmarkForObject:(IMBObject*)inObject error:(NSError**)outError
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
180 {
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
181 return nil;
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
182 }
183
184
185 //----------------------------------------------------------------------------------------------------------------------
186
187
188 #pragma mark
189 #pragma mark Helper Methods
190
191
192 // Load the XML file into a plist lazily (on demand). If we notice that an existing cached plist is
193 // out-of-date we get rid of it and load it anew...
194
195 - (NSDictionary*) plist
196 {
d352065 Avoid threading issue by protecting access to plist property
Peter Baumgartner authored
197 NSDictionary* plist = nil;
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
198 NSURL* url = (NSURL*)self.mediaSource;
eb4b1b7 @mikeabdullah Use NSURL for checking mod date.
mikeabdullah authored
199
200 NSDate* modificationDate;
201 if (![url getResourceValue:&modificationDate forKey:NSURLContentModificationDateKey error:NULL]) modificationDate = nil;
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
202
d352065 Avoid threading issue by protecting access to plist property
Peter Baumgartner authored
203 @synchronized(self)
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
204 {
d352065 Avoid threading issue by protecting access to plist property
Peter Baumgartner authored
205 if ([self.modificationDate compare:modificationDate] == NSOrderedAscending)
206 {
207 self.plist = nil;
208 }
209
210 if (_plist == nil)
211 {
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
212 self.plist = [NSDictionary dictionaryWithContentsOfURL:url];
d352065 Avoid threading issue by protecting access to plist property
Peter Baumgartner authored
213 self.modificationDate = modificationDate;
214 }
215
216 plist = [[_plist retain] autorelease];
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
217 }
218
d352065 Avoid threading issue by protecting access to plist property
Peter Baumgartner authored
219 return plist;
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
220 }
221
222
223 //----------------------------------------------------------------------------------------------------------------------
224
225
226 // Create a unique identifier for a node specified by the plist dictionary...
227
228 - (NSString*) identifierForPlist:(NSDictionary*)inPlist
229 {
230 NSString* uuid = [inPlist objectForKey:@"WebBookmarkUUID"];
231 return [self identifierForPath:[NSString stringWithFormat:@"/%@",uuid]];
232 }
233
234
235 // A node is a leaf if it doesn't contain any subnodes...
236
237 - (BOOL) isLeafPlist:(NSDictionary*)inPlist
238 {
239 BOOL isLeaf = YES;
240 NSString* type = [inPlist objectForKey:@"WebBookmarkType"];
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
241
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
242 if ([type isEqualToString:@"WebBookmarkTypeList"])
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
243 {
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
244 NSArray* childrenPlist = [inPlist objectForKey:@"Children"];
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
245
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
246 for (NSDictionary* childPlist in childrenPlist)
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
247 {
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
248 type = [childPlist objectForKey:@"WebBookmarkType"];
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
249
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
250 if ([type isEqualToString:@"WebBookmarkTypeList"])
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
251 {
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
252 isLeaf = NO;
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
253 }
254 }
255 }
256
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
257 return isLeaf;
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
258 }
259
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
260
261 //----------------------------------------------------------------------------------------------------------------------
262
263
264 - (void) populateNode:(IMBNode*)inNode plist:(NSDictionary*)inPlist
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
265 {
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
266 NSMutableArray* subnodes = [inNode mutableArrayForPopulatingSubnodes];
3884bdc Changed subNodes property from retain to copy (to make code a bit safer)...
Peter Baumgartner authored
267 NSMutableArray* objects = [NSMutableArray array];
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
268
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
269 NSArray* childrenPlist = [inPlist objectForKey:@"Children"];
270 NSUInteger index = 0;
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
271
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
272 for (NSDictionary* childPlist in childrenPlist)
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
273 {
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
274 IMBNode* subnode = [self subnodeForPlist:childPlist];
275
276 if (subnode)
277 {
2cb0e28 • Renamed rootNode methods to topLevelNodes to make the names less ambig...
Peter Baumgartner authored
278 if ([inNode isTopLevelNode])
2ec8d25 @danwood Give safari bookmarks the custom icons for the top-level bookmarks bar a...
danwood authored
279 {
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
280 NSImage* newImage = nil;
281
2ec8d25 @danwood Give safari bookmarks the custom icons for the top-level bookmarks bar a...
danwood authored
282 if ([subnode.name isEqualToString:@"BookmarksMenu"])
283 {
284 subnode.name = NSLocalizedStringWithDefaultValue(
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
285 @"IMBSafariBookmarkParser.bookmarksMenu",
286 nil,IMBBundle(),
287 @"Bookmarks Menu",
288 @"top-level bookmark name");
289
290 newImage = [NSImage
291 imb_imageResourceNamed:@"tiny_menu.tiff"
292 fromApplication:@"com.apple.Safari"
293 fallbackTo:nil];
2ec8d25 @danwood Give safari bookmarks the custom icons for the top-level bookmarks bar a...
danwood authored
294
295 }
296 else if ([subnode.name isEqualToString:@"BookmarksBar"])
297 {
298 subnode.name = NSLocalizedStringWithDefaultValue(
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
299 @"IMBSafariBookmarkParser.bookmarksBar",
300 nil,IMBBundle(),
301 @"Bookmarks Bar",
302 @"top-level bookmark name");
2ec8d25 @danwood Give safari bookmarks the custom icons for the top-level bookmarks bar a...
danwood authored
303
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
304 newImage = [NSImage
305 imb_imageResourceNamed:@"FavoritesBar.tif"
306 fromApplication:@"com.apple.Safari"
307 fallbackTo:nil];
2ec8d25 @danwood Give safari bookmarks the custom icons for the top-level bookmarks bar a...
danwood authored
308 }
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
309
2ec8d25 @danwood Give safari bookmarks the custom icons for the top-level bookmarks bar a...
danwood authored
310 if (newImage)
311 {
312 subnode.icon = newImage;
313 }
314 }
315
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
316 [self populateNode:subnode plist:childPlist];
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
317 [subnodes addObject:subnode];
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
318 }
319
320 IMBObject* object = [self objectForPlist:childPlist];
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
321
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
322 if (object)
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
323 {
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
324 object.index = index++;
3884bdc Changed subNodes property from retain to copy (to make code a bit safer)...
Peter Baumgartner authored
325 [objects addObject:object];
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
326 }
327 }
3884bdc Changed subNodes property from retain to copy (to make code a bit safer)...
Peter Baumgartner authored
328
329 inNode.objects = objects;
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
330 }
331
332
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
333 //----------------------------------------------------------------------------------------------------------------------
334
335
336 - (IMBNode*) subnodeForPlist:(NSDictionary*)inPlist
337 {
338 IMBNode* subnode = nil;
339 NSString* type = [inPlist objectForKey:@"WebBookmarkType"];
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
340
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
341 if ([type isEqualToString:@"WebBookmarkTypeList"])
342 {
343 NSString* title = [inPlist objectForKey:@"Title"];
91ed080 @danwood Scary-looking checkin, but very basic -- in order to make sure that our ...
danwood authored
344 NSImage* icon = [NSImage imb_sharedGenericFolderIcon];
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
345
346 subnode = [[[IMBNode alloc] init] autorelease];
347 subnode.mediaSource = self.mediaSource;
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
348 subnode.mediaType = self.mediaType;
349 subnode.parserIdentifier = self.identifier;
99bb62b @peterb180369 Renamed some properties (an ivars) to be more consistent. Should also be...
peterb180369 authored
350 subnode.isLeafNode = [self isLeafPlist:inPlist];
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
351 subnode.identifier = [self identifierForPlist:inPlist];
352 subnode.icon = icon;
353 subnode.name = title;
354 }
355
356 return subnode;
357 }
358
359
360 //----------------------------------------------------------------------------------------------------------------------
361
362
363 - (IMBObject*) objectForPlist:(NSDictionary*)inPlist
364 {
365 IMBObject* object = nil;
366 NSString* type = [inPlist objectForKey:@"WebBookmarkType"];
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
367
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
368 if ([type isEqualToString:@"WebBookmarkTypeLeaf"])
369 {
370 NSDictionary* uri = [inPlist objectForKey:@"URIDictionary"];
371 NSString* title = [uri objectForKey:@"title"];
372 NSString* urlString = [inPlist objectForKey:@"URLString"];
373 NSURL* url = [NSURL URLWithString:urlString];
4729bba @danwood more progress on disappearing web loc icons. Gonna do lazy loading for ...
danwood authored
374
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
375 object = [[[IMBLinkObject alloc] init] autorelease];
376
4729bba @danwood more progress on disappearing web loc icons. Gonna do lazy loading for ...
danwood authored
377 if (url)
c1cab5f @danwood sync checkin -- trying to deal with web icon issues
danwood authored
378 {
4729bba @danwood more progress on disappearing web loc icons. Gonna do lazy loading for ...
danwood authored
379 object.location = (id)url;
380 object.imageRepresentationType = IKImageBrowserNSURLRepresentationType;
c1cab5f @danwood sync checkin -- trying to deal with web icon issues
danwood authored
381 }
382 else
383 {
4954ca3 @mikeabdullah Store URLs for object location.
mikeabdullah authored
384 object.location = [NSURL fileURLWithPath:urlString]; // url may not have been formed from string
4729bba @danwood more progress on disappearing web loc icons. Gonna do lazy loading for ...
danwood authored
385 object.imageRepresentationType = IKImageBrowserPathRepresentationType;
c1cab5f @danwood sync checkin -- trying to deal with web icon issues
danwood authored
386 }
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
387
4729bba @danwood more progress on disappearing web loc icons. Gonna do lazy loading for ...
danwood authored
388 object.name = title;
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
389 object.parserIdentifier = self.identifier;
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
390 }
e017e10 @danwood My lame attempt to get sub-folders in the safari parser. The double-cli...
danwood authored
391 else if ([type isEqualToString:@"WebBookmarkTypeList"])
392 {
393 IMBNode* subnode = [self subnodeForPlist:inPlist];
99bb62b @peterb180369 Renamed some properties (an ivars) to be more consistent. Should also be...
peterb180369 authored
394 subnode.isIncludedInPopup = NO;
e017e10 @danwood My lame attempt to get sub-folders in the safari parser. The double-cli...
danwood authored
395
396 NSString* title = [inPlist objectForKey:@"Title"]; // Capitalized for list, lowercase for leaves?
397
21c5a6e @peterb180369 New subclass that is optimized, as it doesn't transfer thumbnail across ...
peterb180369 authored
398 object = [[[IMBFolderObject alloc] init] autorelease];
e017e10 @danwood My lame attempt to get sub-folders in the safari parser. The double-cli...
danwood authored
399 object.name = title;
c99c5d8 @peterb180369 First draft of Safari parser
peterb180369 authored
400 object.parserIdentifier = self.identifier;
21c5a6e @peterb180369 New subclass that is optimized, as it doesn't transfer thumbnail across ...
peterb180369 authored
401 ((IMBFolderObject*)object).representedNodeIdentifier = subnode.identifier;
e017e10 @danwood My lame attempt to get sub-folders in the safari parser. The double-cli...
danwood authored
402 }
dbb7d1c First draft of Safari bookmarks parser. Work in progress (not fully func...
Peter Baumgartner authored
403
404 return object;
405 }
406
407
408 //----------------------------------------------------------------------------------------------------------------------
409
410
48a261d Made parsers (and other classes) in sync with the changes in IMBObject a...
Peter Baumgartner authored
411 @end
Something went wrong with that request. Please try again.