412695 Don't write empty/zero values in bookmarks.plist for last-visited date, visit count, and status. Handles folders too: don't write empty/zero values for the folder type and UUID. r=smorgan

This commit is contained in:
mark%moxienet.com 2008-01-17 18:29:09 +00:00
Родитель 30fcdab40d
Коммит 648087d977
2 изменённых файлов: 17 добавлений и 12 удалений

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

@ -64,7 +64,6 @@ NSString* const URLLoadSuccessKey = @"url_bool";
// methods used for saving to files; are guaranteed never to return nil
- (id)savedURL;
- (id)savedLastVisit;
- (id)savedStatus;
- (id)savedNumberOfVisits;
- (id)savedFaviconURL;
@ -294,12 +293,7 @@ NSString* const URLLoadSuccessKey = @"url_bool";
- (id)savedURL
{
return mURL;
}
- (id)savedLastVisit
{
return mLastVisit;
return mURL ? mURL : @"";
}
- (id)savedStatus
@ -366,11 +360,18 @@ NSString* const URLLoadSuccessKey = @"url_bool";
NSMutableDictionary* itemDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[self savedTitle], BMTitleKey,
[self savedURL], BMURLKey,
[self savedLastVisit], BMLastVisitKey,
[self savedNumberOfVisits], BMNumberVisitsKey,
[self savedStatus], BMStatusKey,
nil];
if (mLastVisit)
[itemDict setObject:mLastVisit forKey:BMLastVisitKey];
if (mNumberOfVisits)
[itemDict setObject:[self savedNumberOfVisits] forKey:BMNumberVisitsKey];
// The bookmark is guaranteed not to be a separator at this point, so
// [self savedStatus] will be 0, and there is no reason to write anything
// for BMStatusKey.
if ([[self itemDescription] length])
[itemDict setObject:[self itemDescription] forKey:BMDescKey];

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

@ -1197,10 +1197,14 @@ static int BookmarkItemSort(id firstItem, id secondItem, void* context)
NSMutableDictionary* folderDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
children, BMChildrenKey,
[self savedTitle], BMTitleKey,
[self savedUUID], BMUUIDKey,
[self savedSpecialFlag], BMFolderTypeKey,
nil];
if (mSpecialFlag)
[folderDict setObject:[self savedSpecialFlag] forKey:BMFolderTypeKey];
if ([mUUID length])
[folderDict setObject:mUUID forKey:BMUUIDKey];
if ([[self itemDescription] length])
[folderDict setObject:[self itemDescription] forKey:BMFolderDescKey];