Interaction logic for Window1.xaml
Beispiel #1
0
 /// <summary>
 /// Takes a given FeedConfiItem and iterates through all the available plugins to see if any of them can handle it.
 /// </summary>
 private void GetFeedType(FeedConfigItem feedConfigItem)
 {
     try
     {
         Log.Debug("Getting the Feed Type");
         var document = (XmlDocument)FeedwinManager.Fetch(feedConfigItem);
         foreach (var feedplugin in FeedwinManager.thisinst.Plugins)
         {
             Log.Debug("Testing {0} to see if it can handle feed", feedplugin.PluginName);
             if (!feedplugin.CanHandle(document))
             {
                 continue;
             }
             Log.Debug("It can! Yay!");
             var reqproxy = feedConfigItem.ProxyType != HttpProxyHelper.ProxyType.Global ? feedConfigItem.Proxy : HttpProxyHelper.GetGlobalProxy();
             if (reqproxy != null)
             {
                 Log.Debug("Set Proxy for feed to {0}", reqproxy.GetProxy(new Uri(feedConfigItem.Url)));
             }
             else
             {
                 Log.Debug("Set Proxy for feed to nothing, nothing at all");
             }
             rssfeed = feedplugin.AddFeed(new Uri(feedConfigItem.Url), feedConfigItem.AuthType, feedConfigItem.UserName, feedConfigItem.Password, reqproxy);
             rssfeed.UpdateInterval = feedConfigItem.UpdateInterval;
             break;
         }
     }
     catch (XmlException ex) { errormsg = "Invalid XML Document"; Log.Error("XMLException thrown in parsing the feed", ex); }
     catch (UriFormatException ex) { errormsg = "Invalid URI"; Log.Error("URIException thrown in fetching the feed", ex); }
     catch (WebException ex) { errormsg = ex.Message; Log.Error("WebException thrown in fetching the feed", ex); }
     if (rssfeed == null)
     {
         Log.Debug("Didn't find a plugin to handle this feed");
         if (errormsg == string.Empty)
         {
             errormsg = "No Plugin to handle feed";
         }
     }
     else
     {
         rssfeed.Updated += rssfeed_Updated;
         Log.Debug("Kicking off the watcher thread");
         var t = new Thread(rssfeed.Watch)
         {
             IsBackground = true
         };
         t.SetApartmentState(ApartmentState.STA);
         t.Start();
     }
     RedrawWin();
 }
        /// <summary>
        /// Constructor. Where the magic lovin' happens.
        /// </summary>
        public FeedwinManager()
        {
            Log.Info("Starting up");
            try
            {
                Log.Debug("Building Manager window");
                InitializeComponent();

                //We're going to use the notifyicon and context menu from Winforms, because the WPF versions are a bit shit at the moment.
                CreateIconContextMenu();

                LoadSettings();

                thisinst = this;

                Log.Debug("Removing SSL cert validation");
                ServicePointManager.Expect100Continue = false;
                //We currently don't care if your RSS feed is being MITM'd.
                ServicePointManager.ServerCertificateValidationCallback =
                    (sender, certificate, chain, sslPolicyErrors) => true;

                LoadPlugins();

                //We serialize the configuration to the app.config. To let us do this, we need a serlializer.
                Log.Debug("Creating XML serializer for the saved FeedConfigItems");
                serializer = new XmlSerializer(FeedConfigItems.GetType());
                ReloadFeedConfigItems();

                //If we don't have any feeds loaded, prompt the user to add some.
                if (FeedConfigItems.Items.Count == 0)
                {
                    notifyicon.ShowBalloonTip(1000);
                }

                LoadProxy();

                SetGuiConfigValues();

                Visibility = Visibility.Collapsed;
                Hide();

                Log.Debug("Checking for updates on startup");
                var updater = new AutoUpdate();
                updater.CheckForUpdates(true);
            }
            catch (Exception ex)
            {
                Log.Error("Exception caught during FeedwinManager constructor", ex);
                throw;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Constructor. Where the magic lovin' happens.
        /// </summary>
        public FeedwinManager()
        {
            Log.Info("Starting up");
            try
            {
                Log.Debug("Building Manager window");
                InitializeComponent();

                //We're going to use the notifyicon and context menu from Winforms, because the WPF versions are a bit shit at the moment.
                CreateIconContextMenu();

                LoadSettings();

                thisinst = this;

                Log.Debug("Removing SSL cert validation");
                ServicePointManager.Expect100Continue = false;
                //We currently don't care if your RSS feed is being MITM'd.
                ServicePointManager.ServerCertificateValidationCallback =
                    (sender, certificate, chain, sslPolicyErrors) => true;

                LoadPlugins();

                //We serialize the configuration to the app.config. To let us do this, we need a serlializer.
                Log.Debug("Creating XML serializer for the saved FeedConfigItems");
                serializer = new XmlSerializer(FeedConfigItems.GetType());
                ReloadFeedConfigItems();

                //If we don't have any feeds loaded, prompt the user to add some.
                if (FeedConfigItems.Items.Count == 0)
                {
                    notifyicon.ShowBalloonTip(1000);
                }

                LoadProxy();

                SetGuiConfigValues();

                Visibility = Visibility.Collapsed;
                Hide();

                Log.Debug("Checking for updates on startup");
                var updater = new AutoUpdate();
                updater.CheckForUpdates(true);
            }
            catch (Exception ex)
            {
                Log.Error("Exception caught during FeedwinManager constructor", ex);
                throw;
            }
        }