예제 #1
0
        private FirefoxBookmarkLink RowToLink(FirefoxBookmarkRow row)
        {
            var link = new FirefoxBookmarkLink()
            {
                Id              = row.Id,
                Title           = row.Title,
                LastModified    = DateTimeHelper.FromUnixTimeStamp(row.LastModified),
                Added           = DateTimeHelper.FromUnixTimeStamp(row.DateAdded),
                Url             = row.Url ?? string.Empty,
                LastVisit       = DateTimeHelper.FromUnixTimeStamp(row.LastVisit),
                VisitCount      = (int?)row.VisitCount,
                IconContentType = row.FaviconContentType,
                IconData        = row.FaviconData,
                IconUrl         = row.FaviconUrl,
            };

            if (link.Url.StartsWith("places:", StringComparison.CurrentCultureIgnoreCase))
            {
                link.Internal = true;
            }
            if (row.Attributes != null)
            {
                foreach (var attr in row.Attributes)
                {
                    var attrName = attr.AttributeName.ToLower();
                    switch (attrName)
                    {
                    case "livemark/feeduri":
                        link.FeedUrl = attr.AttributeValue;
                        break;

                    case "livemark/siteuri":
                        link.Url = attr.AttributeValue;
                        break;

                    case "bookmarkproperties/description":
                        link.Description = attr.AttributeValue;
                        break;

                    case "places/excludefrombackup":
                        link.ExcludeFromBackup = attr.AttributeValue == "1";
                        break;
                    }
                    if (attrName.StartsWith("places/", StringComparison.CurrentCultureIgnoreCase))
                    {
                        link.Internal = true;
                    }
                }
            }

            return(link);
        }
        private FirefoxBookmarkFolder RowToFolder(FirefoxBookmarkRow row, int?bookmarksToolbarId)
        {
            var folder = new FirefoxBookmarkFolder()
            {
                Title        = row.Title,
                LastModified = DateTimeHelper.FromUnixTimeStamp(row.LastModified),
                Added        = DateTimeHelper.FromUnixTimeStamp(row.DateAdded),
                Id           = row.Id,
            };

            if (row.Id == bookmarksToolbarId)
            {
                folder.IsBoomarksToolbar = true;
                folder.Attributes.Add("personal_toolbar_folder", "true");
            }
            if (row.Attributes != null)
            {
                foreach (var attr in row.Attributes)
                {
                    var attrName = attr.AttributeName.ToLower();
                    switch (attrName)
                    {
                    case "bookmarkproperties/description":
                        folder.Description = attr.AttributeValue;
                        break;

                    case "places/excludefrombackup":
                        folder.ExcludeFromBackup = attr.AttributeValue == "1";
                        break;
                    }
                    if (attrName.StartsWith("places", StringComparison.CurrentCultureIgnoreCase))
                    {
                        folder.Internal = true;
                    }
                }
            }
            return(folder);
        }
        private FirefoxBookmarkLink RowToLink(FirefoxBookmarkRow row)
        {
            var link = new FirefoxBookmarkLink()
            {
                Id = row.Id,
                Title = row.Title,
                LastModified = DateTimeHelper.FromUnixTimeStamp(row.LastModified),
                Added = DateTimeHelper.FromUnixTimeStamp(row.DateAdded),
                Url = row.Url??string.Empty,
                LastVisit = DateTimeHelper.FromUnixTimeStamp(row.LastVisit),
                VisitCount = (int?)row.VisitCount,
                IconContentType = row.FaviconContentType,
                IconData = row.FaviconData,
                IconUrl = row.FaviconUrl,
            };
            if (link.Url.StartsWith("places:", StringComparison.CurrentCultureIgnoreCase))
                link.Internal = true;
            if (row.Attributes != null)
            {
                foreach (var attr in row.Attributes)
                {
                    var attrName = attr.AttributeName.ToLower();
                    switch (attrName)
                    {
                        case "livemark/feeduri":
                            link.FeedUrl = attr.AttributeValue;
                            break;
                        case "livemark/siteuri":
                            link.Url = attr.AttributeValue;
                            break;
                        case "bookmarkproperties/description":
                            link.Description = attr.AttributeValue;
                            break;
                        case "places/excludefrombackup":
                            link.ExcludeFromBackup = attr.AttributeValue == "1";
                            break;
                    }
                    if (attrName.StartsWith("places/", StringComparison.CurrentCultureIgnoreCase))
                        link.Internal = true;
                }
            }

            return link;
        }
 private FirefoxBookmarkFolder RowToFolder(FirefoxBookmarkRow row, int? bookmarksToolbarId)
 {
     var folder = new FirefoxBookmarkFolder()
     {
         Title = row.Title,
         LastModified = DateTimeHelper.FromUnixTimeStamp(row.LastModified),
         Added = DateTimeHelper.FromUnixTimeStamp(row.DateAdded),
         Id = row.Id,
     };
     if (row.Id == bookmarksToolbarId)
     {
         folder.IsBoomarksToolbar = true;
         folder.Attributes.Add("personal_toolbar_folder", "true");
     }
     if (row.Attributes != null)
     {
         foreach (var attr in row.Attributes)
         {
             var attrName = attr.AttributeName.ToLower();
             switch (attrName)
             {
                 case "bookmarkproperties/description":
                     folder.Description = attr.AttributeValue;
                     break;
                 case "places/excludefrombackup":
                     folder.ExcludeFromBackup = attr.AttributeValue == "1";
                     break;
             }
             if (attrName.StartsWith("places", StringComparison.CurrentCultureIgnoreCase))
             {
                 folder.Internal = true;
             }
         }
     }
     return folder;
 }