コード例 #1
0
        public void Update(IActionContext context, ref ActionPresentation presentation)
        {
            if (context.Kind == ActionContextKind.Keyboard && Core.TabManager.CurrentTabId != "Web")
            {
                presentation.Visible = false;
                return;
            }

            if (context.Kind == ActionContextKind.MainMenu || context.Kind == ActionContextKind.Keyboard ||
                (context.CurrentUrl != null && context.CurrentUrl.Length > 0))
            {
                return;
            }
            if (context.Kind == ActionContextKind.ContextMenu && context.Instance != FavoritesPlugin._favoritesTreePane)
            {
                presentation.Visible = false;
                return;
            }

            int count = context.SelectedResources.Count;

            if (presentation.Visible = count < 2)
            {
                if (count == 1)
                {
                    FavoritesTools.IActionUpdateWeblinksOrFolders(
                        context, ref presentation, FavoritesTools.ActionType.Create);
                }
            }
            presentation.Enabled = presentation.Visible;
            presentation.Visible = true;
        }
コード例 #2
0
 public override void Update(IActionContext context, ref ActionPresentation presentation)
 {
     base.Update(context, ref presentation);
     if (presentation.Visible)
     {
         FavoritesTools.IActionUpdateWeblinks(context, ref presentation);
         if (presentation.Visible)
         {
             string text = "Mark as Unread";
             foreach (IResource res in context.SelectedResources.ValidResources)
             {
                 IResource source = res;
                 if (source.Type == "Weblink")
                 {
                     source = source.GetLinkProp("Source");
                 }
                 if (source != null && source.HasProp(Core.Props.IsUnread))
                 {
                     text = "Mark as Read";
                     break;
                 }
             }
             presentation.Text = text;
         }
     }
 }
コード例 #3
0
 public override void Update(IActionContext context, ref ActionPresentation presentation)
 {
     base.Update(context, ref presentation);
     if (presentation.Visible)
     {
         FavoritesTools.IActionUpdateWeblinks(context, ref presentation);
     }
 }
コード例 #4
0
 internal static void QueueWeblink(IResource webLink, string URL, DateTime when)
 {
     if (when < DateTime.MaxValue)
     {
         FavoritesTools.TraceIfAllowed("Queueing " + URL + " to be processed at " + when);
         Core.NetworkAP.QueueJobAt(when, new FavoriteJob(webLink, URL));
     }
 }
コード例 #5
0
 public void Update(IActionContext context, ref ActionPresentation presentation)
 {
     FavoritesTools.IActionUpdateWeblinksOrFolders(
         context, ref presentation, FavoritesTools.ActionType.Edit);
     if (presentation.Visible &&
         context.SelectedResources.Count == 1 && context.SelectedResources[0].Type == "Folder")
     {
         IResourceList recursiveFavorites = Core.ResourceStore.EmptyResourceList;
         FavoritesPropertiesForm.RecursivelyUpdateResourceList(
             ref recursiveFavorites, context.SelectedResources[0], true);
         presentation.Visible = recursiveFavorites.Count > 0;
     }
 }
コード例 #6
0
ファイル: IEFavoritesProfile.cs プロジェクト: mo5h/omeo
        private void EnumerateFavorites(string folder, IResource parent)
        {
            FileInfo[] files = IOTools.GetFiles(folder);
            if (files != null)
            {
                IResourceList weblinks          = BookmarkService.SubNodes("Weblink", parent);
                IntArrayList  processedWeblinks = new IntArrayList(files.Length);
                foreach (FileInfo fileInfo in files)
                {
                    IResource weblink = null;
                    try
                    {
                        if (fileInfo.Extension.ToLower() == ".url")
                        {
                            weblink = ProcessFavoriteFile(fileInfo, parent);
                        }
                        else if (fileInfo.Extension.ToLower() == ".lnk")
                        {
                            weblink = ProcessShortcut(fileInfo, parent);
                        }
                    }
                    catch (Exception e)
                    {
                        FavoritesTools.TraceIfAllowed(e.Message);
                        continue;
                    }
                    if (weblink != null)
                    {
                        processedWeblinks.Add(weblink.Id);
                    }
                }
                _bookmarkservice.DeleteBookmarks(weblinks.Minus(
                                                     Core.ResourceStore.ListFromIds(processedWeblinks, false)));
            }

            DirectoryInfo[] dirs = IOTools.GetDirectories(folder);
            if (dirs != null)
            {
                IResourceList folders          = BookmarkService.SubNodes("Folder", parent);
                IntArrayList  processedFolders = new IntArrayList(dirs.Length);
                foreach (DirectoryInfo dirInfo in dirs)
                {
                    IResource subfolder = _bookmarkservice.FindOrCreateFolder(parent, dirInfo.Name);
                    EnumerateFavorites(IOTools.GetFullName(dirInfo), subfolder);
                    processedFolders.Add(subfolder.Id);
                }
                _bookmarkservice.DeleteFolders(folders.Minus(
                                                   Core.ResourceStore.ListFromIds(processedFolders, false)));
            }
        }
コード例 #7
0
 public void Update(IActionContext context, ref ActionPresentation presentation)
 {
     if (context.Instance != FavoritesPlugin._favoritesTreePane)
     {
         presentation.Visible = false;
     }
     else
     {
         int count = context.SelectedResources.Count;
         if (presentation.Visible = count < 2)
         {
             if (count == 1)
             {
                 FavoritesTools.IActionUpdateWeblinksOrFolders(
                     context, ref presentation, FavoritesTools.ActionType.Create);
             }
         }
         presentation.Enabled = presentation.Visible;
         presentation.Visible = true;
     }
 }
コード例 #8
0
ファイル: IEFavoritesProfile.cs プロジェクト: mo5h/omeo
        /**
         * parse favorite file (.url), return corresponding weblink resource
         */
        private IResource ProcessFavoriteFile(FileInfo fileInfo, IResource parent)
        {
            FileStream stream = IOTools.OpenRead(fileInfo);

            if (stream != null)
            {
                using (StreamReader reader = new StreamReader(stream, Encoding.Default))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        string trimmedLine = line.Trim();
                        if (trimmedLine.ToLower().StartsWith("url="))
                        {
                            string url = trimmedLine.Substring(4, line.Length - 4).Trim();
                            FavoritesTools.TraceIfAllowed(
                                "Creating or updating '" + fileInfo.FullName + "', " + url);
                            return(CreateFavoriteResource(url, fileInfo, parent));
                        }
                    }
                }
            }
            return(null);
        }
コード例 #9
0
ファイル: FavoriteUOW.cs プロジェクト: mo5h/omeo
        private void DecoratedHttpReaderPredicate()
        {
            MethodInvoker method = _reader.NextMethod;

            _reader.InvokeAfterWait(null, null);   // clear readers methods
            if (_reader.Type == HttpReader.URLType.Undefined || method == null)
            {
                SetLastError("Protocol is not supported.");
                InvokeAfterWait(null, null);
                return;
            }

            /**
             * perform HttpReader work
             */
            method();

            /**
             * if there occured an http error save it and stop download
             */
            if (_reader.CurrentState == HttpReader.State.Error)
            {
                SetLastError(_reader.LastException.Message);
                InvokeAfterWait(null, null);
                return;
            }

            /**
             * if reading is performed the first time for the job, check whether
             * the content was changed or not from the last download attempt
             * stop download and set error if necessary
             */
            if (_lastState == HttpReader.State.Connecting &&
                (_reader.CurrentState == HttpReader.State.Done || _reader.CurrentState == HttpReader.State.Reading))
            {
                HttpWebResponse response = _reader.WebResponse;
                if (_webLink.HasProp("LastModified") && GetLastModified(response) <= LastModified())
                {
                    FavoritesTools.TraceIfAllowed(_reader.URL + " not modified, download stopped");
                    InvokeAfterWait(null, null);
                    return;
                }
            }

            /**
             * if download has finished, process response
             */
            if (_reader.CurrentState == HttpReader.State.Done)
            {
                FavoritesTools.TraceIfAllowed("_reader.CurrentState == HttpReader.State.Done");
                if (_reader.Type == HttpReader.URLType.File)
                {
                    Core.ResourceAP.QueueJob(new MethodInvoker(ProcessFile));
                }
                else if (_reader.Type == HttpReader.URLType.Web)
                {
                    Core.ResourceAP.QueueJob(new MethodInvoker(ProcessWebLink));
                }
            }
            _lastState = _reader.CurrentState;
            InvokeAfterWait(NextMethod, _reader.NextWaitHandle);
        }
コード例 #10
0
ファイル: FavoritesUpdateQueue.cs プロジェクト: mo5h/omeo
 public override void GroupFinished()
 {
     FavoritesTools.TraceIfAllowed("Finished download a group of " + _weblinks.Count + " weblinks");
 }
コード例 #11
0
ファイル: FavoritesUpdateQueue.cs プロジェクト: mo5h/omeo
 public override void GroupStarting()
 {
     FavoritesTools.TraceIfAllowed("Starting download a group of " + _weblinks.Count + " weblinks");
 }
コード例 #12
0
        private void OKButton_Click(object sender, System.EventArgs e)
        {
            if (_okButton.Enabled)
            {
                _okButton.Enabled = false;
                string url = _URLBox.Text.Trim();
                if (url.IndexOf("://") < 0)
                {
                    if (url.IndexOf('\\') >= 0)
                    {
                        url = "file://" + url;
                    }
                    else
                    {
                        url = "http://" + url;
                    }
                    _URLBox.Text = url;
                }
                try
                {
                    new Uri(url);
                }
                catch (Exception exc)
                {
                    Utils.DisplayException(exc, "Bad URL");
                    _URLBox.Focus();
                    _okButton.Enabled = true;
                    return;
                }

                string bookmarkName = _nameBox.Text;
                if (bookmarkName.Length == 0)
                {
                    bookmarkName = url;
                }
                _nameBox.Text = bookmarkName;
                if (_parent != null)
                {
                    if (_createInCombo.SelectedItem != null)
                    {
                        _parent = (IResource)_createInCombo.SelectedItem;
                    }
                    IBookmarkProfile profile = _bookmarkService.GetOwnerProfile(_parent);
                    if (profile != null)
                    {
                        bookmarkName = FavoritesTools.GetSafeBookmarkName(profile, bookmarkName);
                        string    error       = null;
                        IResource tempWeblink = Core.ResourceStore.NewResourceTransient("Weblink");
                        tempWeblink.SetProp(FavoritesPlugin._propURL, url);
                        tempWeblink.SetProp(Core.Props.Name, bookmarkName);
                        tempWeblink.AddLink(FavoritesPlugin._propParent, _parent);
                        if (!profile.CanCreate(tempWeblink, out error))
                        {
                            DisplayError(error);
                            _nameBox.Focus();
                            _okButton.Enabled = true;
                            return;
                        }
                    }
                }

                bool newFavorite = _favorite == null;
                Core.ResourceAP.RunUniqueJob(new MethodInvoker(NewWeblink));
                if (newFavorite)
                {
                    FavoritesPlugin._favoritesTreePane.SelectResource(_favorite);
                }
                Close();
            }
        }
コード例 #13
0
 public void Update(IActionContext context, ref ActionPresentation presentation)
 {
     FavoritesTools.IActionUpdateWeblinks(context, ref presentation);
 }
コード例 #14
0
 public void Update(IActionContext context, ref ActionPresentation presentation)
 {
     FavoritesTools.IActionUpdateWeblinksOrFolders(
         context, ref presentation, FavoritesTools.ActionType.Delete);
 }
コード例 #15
0
 internal static void ImmediateQueueWeblink(IResource webLink, string URL)
 {
     FavoritesTools.TraceIfAllowed("Queueing " + URL);
     Core.NetworkAP.QueueJob(JobPriority.Immediate, new FavoriteJob(webLink, URL));
 }