Esempio n. 1
0
 internal RSSDiscoverResult(string url, string name, string hintText)
 {
     _url          = url;
     _name         = name;
     _hintText     = hintText;
     _existingFeed = RSSPlugin.GetExistingFeed(url);
 }
Esempio n. 2
0
 private void DiscoverDone()
 {
     if (_rssDiscover.Results.Count > 0)
     {
         if (_rssDiscover.Results.Count == 1)
         {
             IResource existingFeed = RSSPlugin.GetExistingFeed(_rssDiscover.Results[0].URL);
             if (existingFeed != null)
             {
                 _feedAddressPane.ErrorMessage = "You are already subscribed to that feed.";
                 _feedAddressPane.SetExistingFeedLink(existingFeed);
             }
             else
             {
                 _newFeedProxy.BeginUpdate();
                 _newFeedProxy.SetProp(Core.Props.Name, _rssDiscover.Results[0].Name);
                 _newFeedProxy.SetProp(Props.URL, _rssDiscover.Results[0].URL);
                 _newFeedProxy.EndUpdate();
                 _feedsToSubscribe = new ResourceProxy[] { _newFeedProxy };
                 ShowTitleGroupPage(OnBackToFirstPage);
             }
         }
         else
         {
             ShowMultipleResultsPage();
         }
     }
     else
     {
         ShowErrorInformation("Could't find a feed for the selected site", string.Empty);
     }
 }
Esempio n. 3
0
        private void OnDownloadClick()
        {
            _feedAddressPane.SetExistingFeedLink(null);
            if (File.Exists(_feedAddressPane.FeedUrl))
            {
                _feedAddressPane.FeedUrl = "file://" + _feedAddressPane.FeedUrl;
            }
            else
            if (_feedAddressPane.FeedUrl.IndexOf("://") < 0)
            {
                _feedAddressPane.FeedUrl = "http://" + _feedAddressPane.FeedUrl;
            }
            else
            {
                string url = _feedAddressPane.FeedUrl.ToLower();
                if (!HttpReader.IsSupportedProtocol(url))
                {
                    _feedAddressPane.ErrorMessage = "Unknown URL schema. Only http:, https: and file: are supported.";
                    return;
                }
            }

            try
            {
                new Uri(_feedAddressPane.FeedUrl);
            }
            catch (Exception ex)
            {
                _feedAddressPane.ErrorMessage = ex.Message;
                return;
            }

            IResource existingFeed = RSSPlugin.GetExistingFeed(_feedAddressPane.FeedUrl);

            if (existingFeed != null)
            {
                _feedAddressPane.ErrorMessage = "You are already subscribed to that feed.";
                _feedAddressPane.SetExistingFeedLink(existingFeed);
                return;
            }

            _progressLabel.Text = "Downloading...";
            _nextButton.Enabled = false;
            _feedAddressPane.ControlsEnabled = false;

            if (_newFeedProxy != null)
            {
                _newFeedProxy.DeleteAsync();
                _newFeedProxy = null;
            }

            _newFeedProxy = CreateFeedProxy(_feedAddressPane.FeedUrl, null);

            _rssUnitOfWork = new RSSUnitOfWork(_newFeedProxy.Resource, false, true);
            _rssUnitOfWork.DownloadProgress += OnDownloadProgress;
            _rssUnitOfWork.ParseDone        += OnParseDone;
            Core.NetworkAP.QueueJob(JobPriority.Immediate, _rssUnitOfWork);
        }
Esempio n. 4
0
        private void OnFinishClick()
        {
            Trace.WriteLine("SubscribeToSearchFeeds -- OnFinishClick.");
            _nextButton.Enabled = false;
            if (_feedsToSubscribe == null)
            {
                throw new InvalidOperationException("Trying to finish wizard with unknown feeds to subscribe");
            }
            if (_feedsToSubscribe.Length == 0)
            {
                DoCancel();
                Close();
                return;
            }
            if (_feedsToSubscribe.Length == 1 &&
                RSSPlugin.GetExistingFeed(_feedsToSubscribe [0].Resource.GetStringProp(Props.URL)) != null)
            {
                MessageBox.Show(this, "You have already subscribed to this feed.",
                                "Subscribe to Feed");
                DoCancel();
                return;
            }

            IResource parentGroup = _titleGroupPane.SelectedGroup;

            if (parentGroup == null)
            {
                parentGroup = RSSPlugin.RootFeedGroup;
            }

            Trace.WriteLine("SubscribeToSearchFeeds -- Starting to link feeds to parent.");
            foreach (ResourceProxy proxy in _feedsToSubscribe)
            {
                if (proxy == _newFeedProxy)
                {
                    _newFeedProxy = null;
                }
                proxy.BeginUpdate();
                try
                {
                    if (_feedsToSubscribe.Length == 1)
                    {
                        proxy.SetProp(Core.Props.Name, _titleGroupPane.FeedTitle);
                    }
                    proxy.DeleteProp(Props.Transient);
                    proxy.SetProp(Core.Props.Parent, parentGroup);
                    Trace.WriteLine("SubscribeToSearchFeeds -- Link feed to parent [" + parentGroup.DisplayName + "]");
                }
                finally
                {
                    proxy.EndUpdate();
                    Trace.WriteLine("SubscribeToSearchFeeds -- EndUpdate called for a feed");
                }
                Core.WorkspaceManager.AddToActiveWorkspace(proxy.Resource);
                Trace.WriteLine("SubscribeToSearchFeeds -- AddToActiveWorkspace called for a feed.");
                RSSPlugin.GetInstance().QueueFeedUpdate(proxy.Resource);
                Trace.WriteLine("SubscribeToSearchFeeds -- QueueFeedUpdate called for a feed.");
            }

            Core.UIManager.BeginUpdateSidebar();
            if (Core.TabManager.ActivateTab("Feeds"))
            {
                Core.LeftSidebar.ActivateViewPane("Feeds");
            }
            Core.UIManager.EndUpdateSidebar();
            RSSPlugin.RSSTreePane.SelectResource(_feedsToSubscribe [0].Resource);
            RSSPlugin.SaveSubscription();

            _newFeedProxy     = null;
            _feedsToSubscribe = null;
            Close();
        }