Exemplo n.º 1
0
        public void Move(IResource res, IResource parent, IResource oldParent)
        {
            BookmarkChange change = new BookmarkChange();

            change.type         = 2;
            change.rdfid        = res.GetPropText(FavoritesPlugin._propBookmarkId);
            change.parent       = GetFolderBookmarkId(parent);
            change.oldparent    = GetFolderBookmarkId(oldParent);
            change.parent_id    = parent.Id;
            change.oldparent_id = oldParent.Id;
            LogBookmarkChange(change);
        }
Exemplo n.º 2
0
        public void Delete(IResource res)
        {
            BookmarkChange change = new BookmarkChange();

            change.type  = 1;
            change.id    = res.Id;
            change.rdfid = res.GetPropText(FavoritesPlugin._propBookmarkId);
            IResource parent = res.GetLinkProp(FavoritesPlugin._propParent);

            if (parent != null)
            {
                change.parent    = GetFolderBookmarkId(parent);
                change.parent_id = parent.Id;
            }
            LogBookmarkChange(change);
        }
Exemplo n.º 3
0
        public void Rename(IResource res, string newName)
        {
            BookmarkChange change = new BookmarkChange();

            change.type  = 0;
            change.id    = res.Id;
            change.rdfid = res.GetPropText(FavoritesPlugin._propBookmarkId);
            IResource parent = BookmarkService.GetParent(res);

            if (parent != null)
            {
                change.parent    = GetFolderBookmarkId(parent);
                change.parent_id = parent.Id;
            }
            change.name = newName;
            change.url  = res.GetPropText(FavoritesPlugin._propURL);
            LogBookmarkChange(change);
        }
Exemplo n.º 4
0
        private static BookmarkChange[] ParseChangesLog(string profileName)
        {
            IBookmarkService service =
                (IBookmarkService)Core.PluginLoader.GetPluginService(typeof(IBookmarkService));
            IResource profileRoot = service.GetProfileRoot(
                BookmarkService.NormalizeProfileName("Mozilla/" + profileName));

            if (profileRoot != null)
            {
                Trace.WriteLine("ParseChangesLog( " + profileName + " ) : profileRoot != null");
                MozillaBookmarkProfile profile =
                    service.GetOwnerProfile(profileRoot) as MozillaBookmarkProfile;
                if (profile != null)
                {
                    Trace.WriteLine("ParseChangesLog( " + profileName + " ) : profile != null");
                    profile.IsActive = true;
                    IStringList log = profileRoot.GetStringListProp(_propChangesLog);
                    if (log.Count > 0)
                    {
                        Trace.WriteLine("ParseChangesLog( " + profileName + " ) : log.Count > 0");
                        BookmarkChange[] result = new BookmarkChange[log.Count];
                        for (int i = 0; i < result.Length; ++i)
                        {
                            string[] changeFields = log[i].Split('\x01');
                            result[i].type         = Int32.Parse(changeFields[0]);
                            result[i].id           = Int32.Parse(changeFields[1]);
                            result[i].rdfid        = changeFields[2];
                            result[i].oldparent    = changeFields[3];
                            result[i].oldparent_id = Int32.Parse(changeFields[4]);
                            result[i].parent       = changeFields[5];
                            result[i].parent_id    = Int32.Parse(changeFields[6]);
                            result[i].name         = changeFields[7];
                            result[i].url          = changeFields[8];
                        }
                        profileRoot.DeleteProp(_propChangesLog);
                        return(result);
                    }
                }
            }
            return(null);
        }
Exemplo n.º 5
0
 private void LogBookmarkChange(BookmarkChange change)
 {
     if (!Core.ResourceStore.IsOwnerThread())
     {
         Core.ResourceAP.QueueJob(new LogBookmarkChangeDelegate(LogBookmarkChange), change);
     }
     else
     {
         StringBuilder historyStr = StringBuilderPool.Alloc();
         try
         {
             historyStr.AppendFormat("{0}\x01{1}\x01{2}\x01{3}\x01{4}\x01{5}\x01{6}\x01{7}\x01{8}",
                                     change.type, change.id, change.rdfid, change.oldparent, change.oldparent_id,
                                     change.parent, change.parent_id, change.name, change.url);
             _root.GetStringListProp(FavoritesPlugin._propChangesLog).Add(historyStr.ToString());
         }
         finally
         {
             StringBuilderPool.Dispose(historyStr);
         }
     }
 }