Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pluginname"></param>
        /// <returns></returns>
        private bool UpdateablePluginsContainsPlugin(DownloadDetailsPlugin plugin)
        {
            for (int i = 0; i < this.updatableplugins.Count; i++)
            {
                if (this.updatableplugins[i].DownloadUrl == plugin.DownloadUrl)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Parser results of versions requested plugins, and set tabpage with plugin update visible
        /// if there are plugin update(s) are available.
        /// </summary>
        /// <param name="sender">Sender object</param>
        /// <param name="e">Event arguments</param>
        private void httputil_pluginsversions_compleet(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
        {
            string result = (string)e.Result;

            if (result == null)
            {
                return;
            }

            if (result.Length < 1)
            {
                return;
            }

            this.updatableplugins = new List <DownloadDetailsPlugin>();
            XmlDocument xmldoc = new XmlDocument();

            xmldoc.LoadXml(result);
            XmlNodeList xmlnodelist = xmldoc.SelectNodes("/plugins/plugin");

            foreach (XmlNode xmlnode in xmlnodelist)
            {
                if (xmlnode.ChildNodes.Count == 1)
                {
                    const int MAXLENMESSAGE = 500;
                    string    errormessage  = xmlnode.ChildNodes[0].InnerText;
                    if (errormessage.Length > MAXLENMESSAGE)
                    {
                        errormessage = errormessage.Substring(0, MAXLENMESSAGE);
                    }

                    Log.Write(LogType.error, errormessage);
                }
                else if (xmlnode.ChildNodes.Count > 1)
                {
                    bool minversionipluginokay = true;
                    DownloadDetailsPlugin downloaddetailsplugin = new DownloadDetailsPlugin();
                    for (int i = 0; (i < xmlnode.ChildNodes.Count && minversionipluginokay); ++i)
                    {
                        switch (xmlnode.ChildNodes[i].Name)
                        {
                        case "name":
                            downloaddetailsplugin.Name = xmlnode.ChildNodes[i].InnerText;
                            break;

                        case "version":
                            downloaddetailsplugin.Version = xmlnode.ChildNodes[i].InnerText;
                            break;

                        case "downloadurl":
                            downloaddetailsplugin.DownloadUrl = xmlnode.ChildNodes[i].InnerText;
                            break;

                        case "signature":
                            downloaddetailsplugin.Signature = xmlnode.ChildNodes[i].InnerText;
                            break;

                        case "minversioniplugin":
                            short[] pluginipluginversionneeded = new short[] { 0, 0, 0 };
                            try
                            {
                                pluginipluginversionneeded = Program.ParserVersionString(xmlnode.ChildNodes[i].InnerText);
                            }
                            catch (Exception)
                            {
                                Log.Write(LogType.error, "Server returned unknown minversioniplugin.");
                            }

                            if (Program.CompareVersions(pluginipluginversionneeded, PluginsManager.GetIPluginVersion()) > 1)
                            {
                                minversionipluginokay = false;
                            }

                            break;
                        }
                    }

                    if (downloaddetailsplugin.IsInstalledPlugin() && minversionipluginokay)
                    {
                        if (downloaddetailsplugin.IsNewerVersion())
                        {
                            this.updatableplugins.Add(downloaddetailsplugin);
                        }
                    }
                }
            }

            if (this.updatableplugins.Count > 0)
            {
                this.SetTabPageUpdatesVisible(true);
                this.tabControlPlugins.SelectedTab = this.tabPagePluginsUpdates;
            }

            for (int i = 0; i < this.updatableplugins.Count; i++)
            {
                this.chxlbxPluginUpdates.Items.Add(this.updatableplugins[i].Name, PLUGINUPDATECHECKEDDEFAULT);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Downloading of plugin details data is compleet, parser data and display plugin details
        /// </summary>
        /// <param name="sender">Sender object</param>
        /// <param name="e">RunWorkerCompleted event arguments</param>
        private void httputil_plugindetail_DownloadCompleet(object sender, RunWorkerCompletedEventArgs e)
        {
            string response = (string)e.Result;

            if (String.IsNullOrEmpty(response))
            {
                return;
            }

            this.timerTextUpdaterLoading.Stop();
            this.ClearPluginDetails();
            this.selectedplugindetails = xmlUtil.ParserDetailsPlugin(response);
            if (this.selectedplugindetails != null)
            {
                if (this.selectedplugindetails.IsInstalledPlugin())
                {
                    this.btnPluginDownload.Enabled = false;
                    if (this.selectedplugindetails.IsNewerVersion())
                    {
                        this.btnPluginDownload.Text = Strings.T("needs update");
                        if (this.updatableplugins == null)
                        {
                            this.updatableplugins = new List <DownloadDetailsPlugin>();
                        }

                        if (!this.UpdateablePluginsContainsPlugin(this.selectedplugindetails))
                        {
                            this.updatableplugins.Add(this.selectedplugindetails);
                            this.chxlbxPluginUpdates.Items.Add(this.selectedplugindetails.Name, PLUGINUPDATECHECKEDDEFAULT);
                            this.SetTabPageUpdatesVisible(true);
                        }
                    }
                    else
                    {
                        this.btnPluginDownload.Text = Strings.T("already installed");
                    }
                }
                else
                {
                    this.btnPluginDownload.Enabled = true;
                    this.btnPluginDownload.Text    = Strings.T("download");
                }

                if (!string.IsNullOrEmpty(this.selectedplugindetails.DownloadUrl) && Uri.IsWellFormedUriString(this.selectedplugindetails.DownloadUrl, UriKind.Absolute))
                {
                    this.btnPluginDownload.Visible = true;
                }

                this.lblPluginName.Text            = this.selectedplugindetails.Name;
                this.lblPluginVersion.Text         = Strings.T("version: ") + this.selectedplugindetails.Version;
                this.lblLicense.Text               = Strings.T("license: ") + this.selectedplugindetails.LicenseType;
                this.lblPluginDescription.Text     = this.selectedplugindetails.Description;
                this.linklblPluginMoreInfo.Visible = true;
                if (Settings.NotesTooltipsEnabled)
                {
                    this.tooltip.SetToolTip(this.linklblPluginMoreInfo, Strings.T("visit: {0}", PLUGINMOREINFOURL + Uri.EscapeUriString(this.selectedplugindetails.Name)));
                }
            }
            else
            {
                this.lblPluginDescription.Text     = Strings.T("Could not load plugins details, please check if your network connection is still working.");
                this.linklblPluginMoreInfo.Visible = false;
            }
        }