private IResource ForwardWeblinkDisplay(IResource resource) { if (Core.State != CoreState.Running) { return(resource); } try { string url = resource.GetPropText(_propURL); if (BookmarkService.DownloadMethod == 2) { if (_lastDisplayedWeblink != resource) { BookmarkService.ImmediateQueueWeblink(resource, url); } return(resource); } Core.ResourceBrowser.ShowUrlBar(url); IResource source = resource.GetLinkProp("Source"); if (source != null) { return(source); } return(resource); } finally { _lastDisplayedWeblink = resource; } }
private void NewWeblink() { bool newWeblink = false; if (_favorite == null) { _favorite = Core.ResourceStore.BeginNewResource("Weblink"); newWeblink = true; } else { _favorite.BeginUpdate(); } try { string url = _URLBox.Text; _favorite.SetProp(Core.Props.Name, _nameBox.Text); _favorite.SetProp(FavoritesPlugin._propURL, url); int updateFreq = 0; if (_updateCheckBox.Checked) { updateFreq = (int)_hoursBox.Value * 60 * 60; int unitIndex = _unitBox.SelectedIndex; if (unitIndex > 0) // days or weeks { updateFreq *= 24; if (unitIndex > 1) // weeks { updateFreq *= 7; } } } _favorite.SetProp(FavoritesPlugin._propUpdateFreq, updateFreq); if (_parent != null) { _favorite.AddLink(FavoritesPlugin._propParent, _parent); } Core.WorkspaceManager.AddToActiveWorkspace(_favorite); } finally { _favorite.EndUpdate(); } if (newWeblink) { IBookmarkProfile profile = _bookmarkService.GetOwnerProfile(_favorite); string error = null; if (profile != null && profile.CanCreate(_favorite, out error)) { profile.Create(_favorite); } else { Core.UserInterfaceAP.QueueJob(new LineDelegate(DisplayError), error); } BookmarkService.ImmediateQueueWeblink(_favorite, _URLBox.Text); } }
public void Execute(IActionContext context) { for (int i = 0; i < context.SelectedResources.Count; ++i) { IResource res = context.SelectedResources[i]; if (res.Type != "Weblink") { res = res.GetLinkProp("Source"); } if (res != null && res.Type == "Weblink") { BookmarkService.ImmediateQueueWeblink(res, res.GetPropText("URL")); } } }
private void WeblinkOrFolderChanged(object sender, ResourcePropIndexEventArgs e) { IResource webLink = e.Resource; IPropertyChangeSet set = e.ChangeSet; int propLastModified = Core.ResourceStore.PropTypes["LastModified"].Id; if (BookmarkService.DownloadMethod != 2 && webLink == _lastDisplayedWeblink && ((set.IsPropertyChanged(propLastModified) && webLink.HasProp("Source")) || (set.IsPropertyChanged(Core.Props.LastError) && webLink.HasProp(Core.Props.LastError)))) { // if the displayed web link has changed, redisplay it IResourceBrowser browser = Core.ResourceBrowser; if ((webLink == _favoritesTreePane.SelectedNode && Core.TabManager.CurrentTabId == "Web") || (browser.SelectedResources.Count == 1 && webLink == browser.SelectedResources[0])) { Core.UserInterfaceAP.QueueJobAt(DateTime.Now.AddSeconds(1), "RedisplaySelectedResource", browser.RedisplaySelectedResource); } } string URL = webLink.GetPropText(_propURL); if (URL.Length > 0) { if (set.IsPropertyChanged(_propLastUpdated) || set.IsPropertyChanged(_propUpdateFreq)) { BookmarkService.QueueWeblink(webLink, URL, BookmarkService.BookmarkSynchronizationTime(webLink)); } if (set.IsPropertyChanged(_propURL)) { BookmarkService.ImmediateQueueWeblink(webLink, URL); } } if (set.IsPropertyChanged(Core.PropIds.Name) || set.IsPropertyChanged(_propURL)) { IBookmarkProfile profile = _bookmarkService.GetOwnerProfile(webLink); string error; if (profile != null && profile.CanCreate(webLink, out error)) { profile.Create(webLink); } } }
public void DisplayResource(IResource resource) { string url = resource.GetPropText(_propURL); if (BookmarkService.DownloadMethod == 2) { if (Core.WebBrowser.CurrentUrl != url) { Core.WebBrowser.NavigateInPlace(url); Core.ResourceBrowser.ShowUrlBar(url); } } else { IResource source = resource.GetLinkProp("Source"); if (source == null) { string lastError = resource.GetPropText(Core.Props.LastError); if (lastError.Length == 0) { if (url.Length > 0) { Core.WebBrowser.ShowHtml("<html><body>Downloading...</body></html>", WebSecurityContext.Trusted, null); BookmarkService.ImmediateQueueWeblink(resource, url); } } else { string err = lastError.Replace("&", "&").Replace("\"", """).Replace("<", "<").Replace(">", ">"); Core.WebBrowser.ShowHtml( "<html><body><b>Bookmark could not be downloaded</b><br><br>" + err + "</body></html>", WebSecurityContext.Trusted, null); } } } }