Ejemplo n.º 1
0
        protected override void UpdateRow(TreeIter iter, AddinHeader info, object dataItem, bool enabled, Gdk.Pixbuf icon)
        {
            base.UpdateRow(iter, info, dataItem, enabled, icon);
            AddinRepositoryEntry arep = (AddinRepositoryEntry)dataItem;

            treeStore.SetValue(iter, ncol, arep.RepositoryName);
        }
Ejemplo n.º 2
0
        static void FilterOldVersions(List <AddinRepositoryEntry> addins)
        {
            Dictionary <string, string> versions = new Dictionary <string, string> ();

            foreach (AddinRepositoryEntry a in addins)
            {
                string last;
                string id, version;
                Addin.GetIdParts(a.Addin.Id, out id, out version);
                if (!versions.TryGetValue(id, out last) || Addin.CompareVersions(last, version) > 0)
                {
                    versions [id] = version;
                }
            }
            for (int n = 0; n < addins.Count; n++)
            {
                AddinRepositoryEntry a = addins [n];
                string id, version;
                Addin.GetIdParts(a.Addin.Id, out id, out version);
                if (versions [id] != version)
                {
                    addins.RemoveAt(n--);
                }
            }
        }
		public static AddinPackage PackageFromRepository (AddinRepositoryEntry repAddin)
		{
			AddinPackage pack = new AddinPackage ();
			pack.info = (AddinInfo) repAddin.Addin;
			pack.url = new Uri (new Uri (repAddin.RepositoryUrl), repAddin.Url).ToString ();
			return pack;
		}
Ejemplo n.º 4
0
        public virtual void InstallPlugin(string name)
        {
            Addin addin = AddinManager.Registry.GetAddins().SingleOrDefault(p => p.Description.LocalId.Equals(name, StringComparison.OrdinalIgnoreCase));

            if (addin != null)
            {
                Logger.Error("Plugin {0} is already installed!");

                return;
            }

            var addins = SetupService.Repositories.GetAvailableAddins(RepositorySearchFlags.LatestVersionsOnly).Where(p => p.Addin.Name.Equals(name, StringComparison.OrdinalIgnoreCase)).ToArray();

            if (addins.Any())
            {
                AddinRepositoryEntry avAddin = addins.First();

                var property = avAddin.Addin.Properties.SingleOrDefault(p => p.Name.Equals("star", StringComparison.OrdinalIgnoreCase));

                if (property != null)
                {
                    InstallPlugin(new[] { avAddin });
                }
                else
                {
                    Logger.Error("Plugin {0} does not define a minimum Star version requirement. Installation failed!", avAddin.Addin.Id);
                }
            }
            else
            {
                Logger.Error("Could not find plugin by the name \"{0}\"", name);
            }
        }
Ejemplo n.º 5
0
        public static AddinPackage PackageFromRepository(AddinRepositoryEntry repAddin)
        {
            AddinPackage pack = new AddinPackage();

            pack.info = (AddinInfo)repAddin.Addin;
            pack.url  = new Uri(new Uri(repAddin.RepositoryUrl), repAddin.Url).ToString();
            return(pack);
        }
Ejemplo n.º 6
0
        void CheckProperties(AddinRepositoryEntry[] areps, string id, params string[] props)
        {
            AddinRepositoryEntry arep = areps.FirstOrDefault(a => a.Addin.Id == id);

            for (int n = 0; n < props.Length; n += 2)
            {
                Assert.AreEqual(props[n + 1], arep.Addin.Properties.GetPropertyValue(props[n]));
            }
        }
Ejemplo n.º 7
0
 static IAsyncOperation InstallAddin(IProgressMonitor monitor, AddinRepositoryEntry addin)
 {
     // Add-in engine changes must be done in the gui thread since mono.addins is not thread safe
     DispatchService.GuiDispatch(delegate {
         using (monitor) {
             Runtime.AddinSetupService.Install(new ProgressStatusMonitor(monitor), addin);
         }
     });
     return(monitor.AsyncOperation);
 }
Ejemplo n.º 8
0
 bool AddinShouldShow(AddinRepositoryEntry entry)
 {
     if (entry == null)
     {
         throw new ArgumentNullException("entry");
     }
     return
         // Don't show addins that do not match the filter.
         (entry.Addin.Name.ToLower().Contains(filter.ToLower()) &&
          // Make sure addin is allowed by current classifier.
          PluginManager.PluginClassifiesAs(entry, category));
 }
Ejemplo n.º 9
0
        void CheckAddin(AddinRepositoryEntry[] areps, string id, string ns, string version, string compat, string name, string category, string author, string copyright, string desc)
        {
            AddinRepositoryEntry arep = areps.FirstOrDefault(a => a.Addin.Id == id);

            Assert.IsNotNull(arep, "Add-in " + id + " not found");
            Assert.AreEqual(id, arep.Addin.Id);
            Assert.AreEqual(ns, arep.Addin.Namespace);
            Assert.AreEqual(version, arep.Addin.Version);
            Assert.AreEqual(compat, arep.Addin.BaseVersion);
            Assert.AreEqual(name, arep.Addin.Name);
            Assert.AreEqual(category, arep.Addin.Category);
            Assert.AreEqual(author, arep.Addin.Author);
            Assert.AreEqual(copyright, arep.Addin.Copyright);
            Assert.AreEqual(desc, arep.Addin.Description);
        }
Ejemplo n.º 10
0
 void LoadRemoteIcon(TreeIter it, string iconId, AddinRepositoryEntry arep, IAsyncResult res, AddinHeader info, object dataItem, AddinStatus status)
 {
     if (!disposed && treeStore.IterIsValid(it))
     {
         Gdk.Pixbuf customPix = null;
         try {
             Gdk.PixbufLoader loader = new Gdk.PixbufLoader(arep.EndDownloadSupportFile(res));
             customPix = loader.Pixbuf;
         } catch (Exception ex) {
             Console.WriteLine(ex);
         }
         cachedIcons [iconId] = customPix;
         StoreIcon(it, iconId, customPix, status);
     }
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Installs the plugin.
        /// </summary>
        /// <returns>
        /// The plugin.
        /// </returns>
        /// <param name='args'>
        /// Arguments.
        /// </param>
        public bool InstallPlugin(int ndx, out Dictionary <string, object> result)
        {
            Dictionary <string, object> res = new Dictionary <string, object>();

            PackageCollection    pack = new PackageCollection();
            PackageCollection    toUninstall;
            DependencyCollection unresolved;

            IProgressStatus ps = new ConsoleProgressStatus(false);

            AddinRepositoryEntry[] available = GetSortedAvailbleAddins();

            if (ndx > (available.Length - 1))
            {
                MainConsole.Instance.Output("Selection out of range");
                result = res;
                return(false);
            }

            AddinRepositoryEntry aentry = available[ndx];

            Package p = Package.FromRepository(aentry);

            pack.Add(p);

            ResolveDependencies(ps, pack, out toUninstall, out unresolved);

            // Attempt to install the plugin disabled
            if (Install(ps, pack) == true)
            {
                MainConsole.Instance.Output("Ignore the following error...");
                PluginRegistry.Update(ps);
                Addin addin = PluginRegistry.GetAddin(aentry.Addin.Id);
                PluginRegistry.DisableAddin(addin.Id);
                addin.Enabled = false;

                MainConsole.Instance.Output("Installation Success");
                ListInstalledAddins(out res);
                result = res;
                return(true);
            }
            else
            {
                MainConsole.Instance.Output("Installation Failed");
                result = res;
                return(false);
            }
        }
Ejemplo n.º 12
0
        public AddinRepositoryEntry GetUpdate(Addin a)
        {
            AddinRepositoryEntry[] updates = service.Repositories.GetAvailableAddinUpdates(Addin.GetIdName(a.Id));
            AddinRepositoryEntry   best    = null;
            string bestVersion             = a.Version;

            foreach (AddinRepositoryEntry e in updates)
            {
                if (Addin.CompareVersions(bestVersion, e.Addin.Version) > 0)
                {
                    best        = e;
                    bestVersion = e.Addin.Version;
                }
            }
            return(best);
        }
Ejemplo n.º 13
0
        public void GetSupportFile()
        {
            InitRepository();
            setup.BuildRepository(monitor, repoDir);
            setup.Repositories.RegisterRepository(monitor, repoUrl, true);

            AddinRepositoryEntry arep = setup.Repositories.GetAvailableAddin("SimpleApp.Core", "0.1.0")[0];
            IAsyncResult         res  = arep.BeginDownloadSupportFile(arep.Addin.Properties.GetPropertyValue("Prop3"), null, null);
            Stream       s            = arep.EndDownloadSupportFile(res);
            StreamReader sr           = new StreamReader(s);

            Assert.AreEqual("Some support file", sr.ReadToEnd());
            sr.Close();

            setup.Repositories.RemoveRepository(repoUrl);
        }
Ejemplo n.º 14
0
        void SetRowIcon(TreeIter it, AddinHeader info, object dataItem, AddinStatus status)
        {
            string customIcom = info.Properties.GetPropertyValue("Icon32");
            string iconId     = info.Id + " " + info.Version + " " + customIcom;

            Gdk.Pixbuf customPix;

            if (customIcom.Length == 0)
            {
                customPix = null;
                iconId    = "__";
            }
            else if (!cachedIcons.TryGetValue(iconId, out customPix))
            {
                if (dataItem is Addin)
                {
                    string file = Path.Combine(((Addin)dataItem).Description.BasePath, customIcom);
                    if (File.Exists(file))
                    {
                        try
                        {
                            customPix = new Gdk.Pixbuf(file);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                        }
                    }
                    cachedIcons [iconId] = customPix;
                }
                else if (dataItem is AddinRepositoryEntry)
                {
                    AddinRepositoryEntry arep = (AddinRepositoryEntry)dataItem;
                    string tmpId = iconId;
                    arep.BeginDownloadSupportFile(customIcom, delegate(IAsyncResult res)
                    {
                        Gtk.Application.Invoke(delegate
                        {
                            LoadRemoteIcon(it, tmpId, arep, res, info, dataItem, status);
                        });
                    }, null);
                    iconId = "__";
                }
            }

            StoreIcon(it, iconId, customPix, status);
        }
Ejemplo n.º 15
0
        public void InstallPlugin(string name)
        {
            Addin addin = AddinManager.Registry.GetAddins().SingleOrDefault(p => p.Description.LocalId.Equals(name, StringComparison.OrdinalIgnoreCase));

            if (addin != null)
            {
                Logger.Error("Plugin {0} is already installed!");

                return;
            }

            var addins = setupService.Repositories.GetAvailableAddins(RepositorySearchFlags.LatestVersionsOnly).Where(p => p.Addin.Name.Equals(name, StringComparison.OrdinalIgnoreCase)).ToArray();

            if (addins.Any())
            {
                AddinRepositoryEntry avAddin = addins.First();

                var property = avAddin.Addin.Properties.SingleOrDefault(p => p.Name.Equals("sharpstar", StringComparison.OrdinalIgnoreCase));

                if (property != null)
                {
                    Version ver = Assembly.GetEntryAssembly().GetName().Version;

                    string verStr = String.Format("{0}.{1}.{2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision);

                    if (Addin.CompareVersions(verStr, property.Value) <= 0)
                    {
                        setupService.Install(new ProgressStatus(), addins);

                        AddinManager.Registry.EnableAddin(avAddin.Addin.Id);
                    }
                    else
                    {
                        Logger.Error("Plugin {0} now requires SharpStar version {1}+. Update failed!", avAddin.Addin.Id, property.Value);
                    }
                }
                else
                {
                    Logger.Error("Plugin {0} does not define a minimum SharpStar version requirement. Installation failed!", avAddin.Addin.Id);
                }
            }
            else
            {
                Logger.Error("Could not find plugin by the name \"{0}\"", name);
            }
        }
Ejemplo n.º 16
0
        protected virtual void OnUpdateAll(object sender, System.EventArgs e)
        {
            object[] data = updatesTree.AddinsData;
            AddinRepositoryEntry[] entries = new AddinRepositoryEntry [data.Length];
            Array.Copy(data, entries, data.Length);
            InstallDialog dlg = new InstallDialog(this, service);

            try {
                dlg.InitForInstall(entries);
                if (dlg.Run() == (int)Gtk.ResponseType.Ok)
                {
                    LoadAll();
                }
            } finally {
                dlg.Destroy();
            }
        }
Ejemplo n.º 17
0
        protected virtual void OnUpdateAll(object sender, System.EventArgs e)
        {
            object[] data = updatesTree.AddinsData;
            AddinRepositoryEntry[] entries = new AddinRepositoryEntry [data.Length];
            Array.Copy(data, entries, data.Length);
            Gtk.Builder   builder = new Gtk.Builder(null, "Mono.Addins.GuiGtk3.interfaces.InstallDialog.ui", null);
            InstallDialog dlg     = new InstallDialog(service, builder, builder.GetObject("InstallDialog").Handle);

            try {
                dlg.InitForInstall(entries);
                if (dlg.Run() == (int)Gtk.ResponseType.Ok)
                {
                    LoadAll();
                }
            } finally {
                dlg.Destroy();
            }
        }
Ejemplo n.º 18
0
 public ImageContainer(AddinRepositoryEntry aentry, string fileName) : this()
 {
     this.aentry = aentry;
     aresult     = aentry.BeginDownloadSupportFile(fileName, ImageDownloaded, null);
 }
Ejemplo n.º 19
0
		static IEnumerable<Release> ParseReleases (string addinId, AddinRepositoryEntry entry)
		{
			// Format of release notes is:
			// {{version1,date1}} release note text {{version2,date2}} release note text ...
			// Releases msyu
			// for example:
			// {{1.1,2011-01-10}} Release notes for 1.1 {{1.2,2011-03-22}} Release notes for 2.3
			
			string releaseNotes = entry.Addin.Properties.GetPropertyValue ("ReleaseNotes");
			if (releaseNotes.Length == 0) {
				string file = entry.Addin.Properties.GetPropertyValue ("ReleaseNotesFile");
				if (file.Length > 0) {
					IAsyncResult res = entry.BeginDownloadSupportFile (file, null, null);
					res.AsyncWaitHandle.WaitOne ();
					try {
						using (Stream s = entry.EndDownloadSupportFile (res)) {
							StreamReader sr = new StreamReader (s);
							releaseNotes = sr.ReadToEnd ();
						}
					} catch (Exception ex) {
						LoggingService.LogError ("Could not download release notes", ex);
					}
				}
			}
			
			if (releaseNotes.Length == 0)
				yield break;
			
			var addin = AddinManager.Registry.GetAddin (Addin.GetIdName (addinId));
			string currentVersion = addin != null ? addin.Version : null;
			
			int i = releaseNotes.IndexOf ("{{");
			while (i != -1) {
				int j = releaseNotes.IndexOf ("}}", i + 2);
				if (j == -1)
					break;
				string[] h = releaseNotes.Substring (i + 2, j - i - 2).Trim ().Split (',');
				if (h.Length != 2)
					break;
				DateTime date;
				if (!DateTime.TryParse (h[1].Trim (), CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out date))
					break;
				int k = releaseNotes.IndexOf ("{{", j + 2);
				string version = h[0].Trim ();
				if (currentVersion == null || Addin.CompareVersions (currentVersion, version) > 0) {
					string txt = k != -1 ? releaseNotes.Substring (j + 2, k - j - 2) : releaseNotes.Substring (j + 2);
					yield return new Release () {
						Version = version,
						Date = date,
						Notes = txt.Trim (' ','\t','\r','\n')
					};
				}
				i = k;
			}
		}
Ejemplo n.º 20
0
 protected string Description(AddinRepositoryEntry a)
 {
     return(Description(a.Addin));
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Creates a package object for an add-in available in an on-line repository
 /// </summary>
 /// <param name="repAddin">
 /// An add-in reference
 /// </param>
 /// <returns>
 /// The package
 /// </returns>
 public static Package FromRepository(AddinRepositoryEntry repAddin)
 {
     return(AddinPackage.PackageFromRepository(repAddin));
 }
Ejemplo n.º 22
0
 void CheckAddin(AddinRepositoryEntry[] areps, string id, string ns, string version, string compat, string name, string category, string author, string copyright, string desc)
 {
     AddinRepositoryEntry arep = areps.FirstOrDefault (a => a.Addin.Id == id);
     Assert.IsNotNull (arep, "Add-in " + id + " not found");
     Assert.AreEqual (id, arep.Addin.Id);
     Assert.AreEqual (ns, arep.Addin.Namespace);
     Assert.AreEqual (version, arep.Addin.Version);
     Assert.AreEqual (compat, arep.Addin.BaseVersion);
     Assert.AreEqual (name, arep.Addin.Name);
     Assert.AreEqual (category, arep.Addin.Category);
     Assert.AreEqual (author, arep.Addin.Author);
     Assert.AreEqual (copyright, arep.Addin.Copyright);
     Assert.AreEqual (desc, arep.Addin.Description);
 }
Ejemplo n.º 23
0
 public override bool IsMatch(AddinRepositoryEntry entry)
 {
     return(InCategory(entry, OfficialCategory));
 }
Ejemplo n.º 24
0
 public override bool IsMatch(AddinRepositoryEntry entry)
 {
     return(InCategory(entry, CommunityCategory));
 }
Ejemplo n.º 25
0
        static IEnumerable <Release> ParseReleases(string addinId, AddinRepositoryEntry entry)
        {
            // Format of release notes is:
            // {{version1,date1}} release note text {{version2,date2}} release note text ...
            // Releases msyu
            // for example:
            // {{1.1,2011-01-10}} Release notes for 1.1 {{1.2,2011-03-22}} Release notes for 2.3

            string releaseNotes = entry.Addin.Properties.GetPropertyValue("ReleaseNotes");

            if (releaseNotes.Length == 0)
            {
                string file = entry.Addin.Properties.GetPropertyValue("ReleaseNotesFile");
                if (file.Length > 0)
                {
                    IAsyncResult res = entry.BeginDownloadSupportFile(file, null, null);
                    res.AsyncWaitHandle.WaitOne();
                    try {
                        using (Stream s = entry.EndDownloadSupportFile(res)) {
                            StreamReader sr = new StreamReader(s);
                            releaseNotes = sr.ReadToEnd();
                        }
                    } catch (Exception ex) {
                        LoggingService.LogError("Could not download release notes", ex);
                    }
                }
            }

            if (releaseNotes.Length == 0)
            {
                yield break;
            }

            var    addin          = AddinManager.Registry.GetAddin(Addin.GetIdName(addinId));
            string currentVersion = addin != null ? addin.Version : null;

            int i = releaseNotes.IndexOf("{{");

            while (i != -1)
            {
                int j = releaseNotes.IndexOf("}}", i + 2);
                if (j == -1)
                {
                    break;
                }
                string[] h = releaseNotes.Substring(i + 2, j - i - 2).Trim().Split(',');
                if (h.Length != 2)
                {
                    break;
                }
                DateTime date;
                if (!DateTime.TryParse(h[1].Trim(), CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out date))
                {
                    break;
                }
                int    k       = releaseNotes.IndexOf("{{", j + 2);
                string version = h[0].Trim();
                if (currentVersion == null || Addin.CompareVersions(currentVersion, version) > 0)
                {
                    string txt = k != -1 ? releaseNotes.Substring(j + 2, k - j - 2) : releaseNotes.Substring(j + 2);
                    yield return(new Release()
                    {
                        Version = version,
                        Date = date,
                        Notes = txt.Trim(' ', '\t', '\r', '\n')
                    });
                }
                i = k;
            }
        }
Ejemplo n.º 26
0
 public virtual bool IsMatch(AddinRepositoryEntry entry)
 {
     return(false);
 }
Ejemplo n.º 27
0
        void FillSummaryPage()
        {
            btnPrev.Sensitive = true;

            AddinHeader[]     infos = tree.GetSelectedAddins();
            PackageCollection packs = new PackageCollection();

            foreach (AddinHeader info in infos)
            {
                AddinRepositoryEntry arep = (AddinRepositoryEntry)tree.GetAddinData(info);
                packs.Add(Package.FromRepository(arep));
            }

            packagesToInstall = new PackageCollection(packs);

            PackageCollection    toUninstall;
            DependencyCollection unresolved;
            bool res;

            InstallMonitor m = new InstallMonitor();

            res = service.ResolveDependencies(m, packs, out toUninstall, out unresolved);

            StringBuilder sb = new StringBuilder();

            if (!res)
            {
                sb.Append("<b><span foreground=\"red\">").Append(Catalog.GetString("The selected extensions can't be installed because there are dependency conflicts.")).Append("</span></b>\n");
                foreach (string s in m.Errors)
                {
                    sb.Append("<b><span foreground=\"red\">" + s + "</span></b>\n");
                }
                sb.Append("\n");
            }

            if (m.Warnings.Count != 0)
            {
                foreach (string w in m.Warnings)
                {
                    sb.Append("<b><span foreground=\"red\">" + w + "</span></b>\n");
                }
                sb.Append("\n");
            }

            sb.Append("<b>").Append(Catalog.GetString("The following packages will be installed:")).Append("</b>\n\n");
            foreach (Package p in packs)
            {
                sb.Append(p.Name);
                if (!p.SharedInstall)
                {
                    sb.Append(Catalog.GetString(" (in user directory)"));
                }
                sb.Append("\n");
            }
            sb.Append("\n");

            if (toUninstall.Count > 0)
            {
                sb.Append("<b>").Append(Catalog.GetString("The following packages need to be uninstalled:")).Append("</b>\n\n");
                foreach (Package p in toUninstall)
                {
                    sb.Append(p.Name + "\n");
                }
                sb.Append("\n");
            }

            if (unresolved.Count > 0)
            {
                sb.Append("<b>").Append(Catalog.GetString("The following dependencies could not be resolved:")).Append("</b>\n\n");
                foreach (Dependency p in unresolved)
                {
                    sb.Append(p.Name + "\n");
                }
                sb.Append("\n");
            }
            btnNext.Sensitive   = res;
            labelSummary.Markup = sb.ToString();
        }
Ejemplo n.º 28
0
		public void InitForInstall (AddinRepositoryEntry[] addinsToInstall)
		{
			this.addinsToInstall = addinsToInstall;
			FillSummaryPage ();
//			Services.PlaceDialog (this, TransientFor);
		}
Ejemplo n.º 29
0
 public bool ResolveDependencies(IProgressStatus statusMonitor, AddinRepositoryEntry[] addins, out PackageCollection resolved, out PackageCollection toUninstall, out DependencyCollection unresolved)
 {
     resolved = new PackageCollection ();
     for (int n=0; n<addins.Length; n++)
         resolved.Add (AddinPackage.FromRepository (addins [n]));
     return ResolveDependencies (statusMonitor, resolved, out toUninstall, out unresolved);
 }
Ejemplo n.º 30
0
        public void ShowAddins(object[] data)
        {
            selectedEntry.Clear();
            selectedAddin.Clear();
            eboxButs.Visible = true;
            topHeaderBox.Hide();
            urlButton.Hide();

            if (titleIcon != null)
            {
                boxTitle.Remove(titleIcon);
                titleIcon.Destroy();
                titleIcon = null;
            }

            foreach (var img in previewImages)
            {
                ((Gtk.Container)img.Parent).Remove(img);
                img.Destroy();
            }
            previewImages.Clear();

            if (data.Length == 1)
            {
                headerBox.Show();
                ShowAddin(data[0]);
            }
            else if (data.Length > 1)
            {
                headerBox.Hide();
                StringBuilder sb = new StringBuilder();
                sb.Append(Catalog.GetString("Multiple selection:\n\n"));
                bool allowUpdate    = AllowInstall;
                bool allowInstall   = true;
                bool allowUninstall = AllowInstall;
                bool allowEnable    = true;
                bool allowDisable   = true;

                foreach (object o in data)
                {
                    Addin installed;
                    if (o is Addin)
                    {
                        Addin a = (Addin)o;
                        installed = a;
                        selectedAddin.Add(a);
                        sb.Append(a.Name);
                    }
                    else
                    {
                        AddinRepositoryEntry entry = (AddinRepositoryEntry)o;
                        selectedEntry.Add(entry);
                        sb.Append(entry.Addin.Name);
                        installed = AddinManager.Registry.GetAddin(Addin.GetIdName(entry.Addin.Id));
                    }
                    if (installed != null)
                    {
                        if (GetUpdate(installed) == null)
                        {
                            allowUpdate = false;
                        }
                        allowInstall = false;
                        if (installed.Enabled)
                        {
                            allowEnable = false;
                        }
                        else
                        {
                            allowDisable = false;
                        }
                    }
                    else
                    {
                        allowEnable = allowDisable = allowUninstall = allowUpdate = false;
                    }

                    sb.Append('\n');
                    labelDesc.Text = sb.ToString();

                    if (allowEnable)
                    {
                        btnDisable.Visible = true;
                        btnDisable.Label   = Catalog.GetString("Enable");
                    }
                    else if (allowDisable)
                    {
                        btnDisable.Visible = true;
                        btnDisable.Label   = Catalog.GetString("Disable");
                    }
                    else
                    {
                        btnDisable.Visible = false;
                    }
                    btnInstall.Visible   = allowInstall;
                    btnUninstall.Visible = allowUninstall;
                    btnUpdate.Visible    = allowUpdate;
                }
            }
            else
            {
                headerBox.Hide();
                btnDisable.Visible   = false;
                btnInstall.Visible   = false;
                btnUninstall.Visible = false;
                btnUpdate.Visible    = false;
                eboxButs.Visible     = false;
                labelDesc.Text       = Catalog.GetString("No selection");
            }
        }
Ejemplo n.º 31
0
 protected virtual void OnUpdateAll(object sender, System.EventArgs e)
 {
     object[] data = updatesTree.AddinsData;
     AddinRepositoryEntry[] entries = new AddinRepositoryEntry [data.Length];
     Array.Copy (data, entries, data.Length);
     InstallDialog dlg = new InstallDialog (this, service);
     try {
         dlg.InitForInstall (entries);
         if (dlg.Run () == (int) Gtk.ResponseType.Ok)
             LoadAll ();
     } finally {
         dlg.Destroy ();
     }
 }
Ejemplo n.º 32
0
 protected virtual void OnUpdateAll(object sender, System.EventArgs e)
 {
     object[] data = updatesTree.AddinsData;
     AddinRepositoryEntry[] entries = new AddinRepositoryEntry [data.Length];
     Array.Copy (data, entries, data.Length);
     Gtk.Builder builder = new Gtk.Builder (null, "Mono.Addins.GuiGtk3.interfaces.InstallDialog.ui", null);
     InstallDialog dlg = new InstallDialog (service, builder, builder.GetObject ("InstallDialog").Handle);
     try {
         dlg.InitForInstall (entries);
         if (dlg.Run () == (int) Gtk.ResponseType.Ok)
             LoadAll ();
     } finally {
         dlg.Destroy ();
     }
 }
Ejemplo n.º 33
0
 public override bool IsMatch(AddinRepositoryEntry entry)
 {
     return(!InCategory(entry, "Hidden"));
 }
Ejemplo n.º 34
0
 protected bool InCategory(AddinRepositoryEntry entry, string category)
 {
     return(entry.Addin.Category.Contains(category));
 }
Ejemplo n.º 35
0
 void LoadRemoteIcon(TreeIter it, string iconId, AddinRepositoryEntry arep, IAsyncResult res, AddinHeader info, object dataItem, AddinStatus status)
 {
     if (!disposed && treeStore.IterIsValid (it)) {
         Gdk.Pixbuf customPix = null;
         try {
             Gdk.PixbufLoader loader = new Gdk.PixbufLoader (arep.EndDownloadSupportFile (res));
             customPix = loader.Pixbuf;
         } catch (Exception ex) {
             Console.WriteLine (ex);
         }
         cachedIcons [iconId] = customPix;
         StoreIcon (it, iconId, customPix, status);
     }
 }
Ejemplo n.º 36
0
 public ImageContainer(AddinRepositoryEntry aentry, string fileName)
     : this()
 {
     this.aentry = aentry;
     aresult = aentry.BeginDownloadSupportFile (fileName, ImageDownloaded, null);
 }
Ejemplo n.º 37
0
		static IAsyncOperation InstallAddin (IProgressMonitor monitor, AddinRepositoryEntry addin)
		{
			// Add-in engine changes must be done in the gui thread since mono.addins is not thread safe
			DispatchService.GuiDispatch (delegate {
				using (monitor) {
					Runtime.AddinSetupService.Install (new ProgressStatusMonitor (monitor), addin);
				}
			});
			return monitor.AsyncOperation;
		}
Ejemplo n.º 38
0
 void CheckProperties(AddinRepositoryEntry[] areps, string id, params string[] props)
 {
     AddinRepositoryEntry arep = areps.FirstOrDefault (a => a.Addin.Id == id);
     for (int n=0; n<props.Length; n+=2)
         Assert.AreEqual (props[n+1], arep.Addin.Properties.GetPropertyValue (props[n]));
 }
Ejemplo n.º 39
0
        void ShowAddin(object data)
        {
            AddinHeader sinfo        = null;
            Addin       installed    = null;
            AddinHeader updateInfo   = null;
            string      repo         = "";
            string      downloadSize = null;

            topHeaderBox.Hide();

            if (data is Addin)
            {
                installed = (Addin)data;
                sinfo     = SetupService.GetAddinHeader(installed);
                var entry = GetUpdate(installed);
                if (entry != null)
                {
                    updateInfo = entry.Addin;
                    selectedEntry.Add(entry);
                }
                foreach (var prop in sinfo.Properties)
                {
                    if (prop.Name.StartsWith("PreviewImage"))
                    {
                        previewImages.Add(new ImageContainer(installed, prop.Value));
                    }
                }
                string icon32 = sinfo.Properties.GetPropertyValue("Icon32");
                if (icon32.Length > 0)
                {
                    titleIcon = new ImageContainer(installed, icon32);
                }
            }
            else if (data is AddinRepositoryEntry)
            {
                AddinRepositoryEntry entry = (AddinRepositoryEntry)data;
                sinfo     = entry.Addin;
                installed = AddinManager.Registry.GetAddin(Addin.GetIdName(sinfo.Id));
                if (installed != null && Addin.CompareVersions(installed.Version, sinfo.Version) > 0)
                {
                    updateInfo = sinfo;
                }
                selectedEntry.Add(entry);
                string rname = !string.IsNullOrEmpty(entry.RepositoryName) ? entry.RepositoryName : entry.RepositoryUrl;
                repo = "<small><b>" + Catalog.GetString("Available in repository:") + "</b>\n" + GLib.Markup.EscapeText(rname) + "\n\n</small>";
                foreach (var prop in sinfo.Properties)
                {
                    if (prop.Name.StartsWith("PreviewImage"))
                    {
                        previewImages.Add(new ImageContainer(entry, prop.Value));
                    }
                }
                string icon32 = sinfo.Properties.GetPropertyValue("Icon32");
                if (icon32.Length > 0)
                {
                    titleIcon = new ImageContainer(entry, icon32);
                }
                int size;
                if (int.TryParse(sinfo.Properties.GetPropertyValue("DownloadSize"), out size))
                {
                    float fs = ((float)size) / 1048576f;
                    downloadSize = fs.ToString("0.00 MB");
                }
            }
            else
            {
                selectedEntry.Clear();
            }

            if (installed != null)
            {
                selectedAddin.Add(installed);
            }

            string missingDepsTxt = null;

            if (sinfo == null)
            {
                btnDisable.Visible   = false;
                btnUninstall.Visible = false;
                btnUpdate.Visible    = false;
            }
            else
            {
                string version;
                string newVersion = null;
                if (installed != null)
                {
                    btnInstall.Visible   = false;
                    btnUpdate.Visible    = updateInfo != null && AllowInstall;
                    btnDisable.Visible   = true;
                    btnDisable.Label     = installed.Enabled ? Catalog.GetString("Disable") : Catalog.GetString("Enable");
                    btnDisable.Visible   = installed.Description.CanDisable;
                    btnUninstall.Visible = installed.Description.CanUninstall;
                    version = installed.Version;
                    var missingDeps = Services.GetMissingDependencies(installed);
                    if (updateInfo != null)
                    {
                        newVersion         = updateInfo.Version;
                        labelHeader.Markup = "<b><span color='black'>" + Catalog.GetString("Update available") + "</span></b>";
//						topHeaderBox.BackgroundColor = new Gdk.Color (0, 132, 208);
                        imageHeader.Pixbuf           = Gdk.Pixbuf.LoadFromResource("update-16.png");
                        topHeaderBox.BackgroundColor = new Gdk.Color(255, 176, 0);
                        topHeaderBox.Show();
                    }
                    else if (missingDeps.Any())
                    {
                        labelHeader.Markup           = "<b><span color='black'>" + Catalog.GetString("This extension package can't be loaded due to missing dependencies") + "</span></b>";
                        topHeaderBox.BackgroundColor = new Gdk.Color(255, 176, 0);
                        imageHeader.SetFromStock(Gtk.Stock.DialogWarning, Gtk.IconSize.Menu);
                        topHeaderBox.Show();
                        missingDepsTxt = "";
                        foreach (var mdep in missingDeps)
                        {
                            if (mdep.Found != null)
                            {
                                missingDepsTxt += "\n" + string.Format(Catalog.GetString("Required: {0} v{1}, found v{2}"), mdep.Addin, mdep.Required, mdep.Found);
                            }
                            else
                            {
                                missingDepsTxt += "\n" + string.Format(Catalog.GetString("Missing: {0} v{1}"), mdep.Addin, mdep.Required);
                            }
                        }
                    }
                }
                else
                {
                    btnInstall.Visible   = AllowInstall;
                    btnUpdate.Visible    = false;
                    btnDisable.Visible   = false;
                    btnUninstall.Visible = false;
                    version = sinfo.Version;
                }
                labelName.Markup = "<b><big>" + GLib.Markup.EscapeText(sinfo.Name) + "</big></b>";

                string ver;
                if (newVersion != null)
                {
                    ver  = "<small><b>" + Catalog.GetString("Installed version") + ":</b> " + version + "</small>\n";
                    ver += "<small><b>" + Catalog.GetString("Repository version") + ":</b> " + newVersion + "</small>";
                }
                else
                {
                    ver = "<small><b>" + Catalog.GetString("Version") + " " + version + "</b></small>";
                }

                if (downloadSize != null)
                {
                    ver += "\n<small><b>" + Catalog.GetString("Download size") + ":</b> " + downloadSize + "</small>";
                }
                if (missingDepsTxt != null)
                {
                    ver += "\n\n" + GLib.Markup.EscapeText(Catalog.GetString("The following dependencies required by this extension package are not available:")) + missingDepsTxt;
                }
                labelVersion.Markup = ver;

                string desc = GLib.Markup.EscapeText(sinfo.Description);
                labelDesc.Markup = repo + GLib.Markup.EscapeText(desc);

                foreach (var img in previewImages)
                {
                    vboxDesc.PackStart(img, false, false, 0);
                }

                urlButton.Visible = !string.IsNullOrEmpty(sinfo.Url);
                infoUrl           = sinfo.Url;

                if (titleIcon != null)
                {
                    boxTitle.PackEnd(titleIcon, false, false, 0);
                    labelName.WidthRequest    = titleWidth - 32;
                    labelVersion.WidthRequest = titleWidth - 32;
                }
                else
                {
                    labelName.WidthRequest    = titleWidth;
                    labelVersion.WidthRequest = titleWidth;
                }

                if (IsRealized)
                {
                    SetComponentsBg();
                }
            }
        }
Ejemplo n.º 40
0
        public static bool PluginClassifiesAs(AddinRepositoryEntry entry, string className)
        {
            AddinClassifier classifier = Classifiers.FirstOrDefault(c => c.Name == className);

            return(classifier == null ? false : classifier.IsMatch(entry));
        }
Ejemplo n.º 41
0
 public static Addin GetAddin(this AddinRepositoryEntry self)
 {
     return(AddinManager.Registry.GetAddin(self.Addin.Id));
 }
Ejemplo n.º 42
0
 public bool ResolveDependencies(IProgressStatus statusMonitor, AddinRepositoryEntry[] addins, out PackageCollection resolved, out PackageCollection toUninstall, out DependencyCollection unresolved)
 {
     return store.ResolveDependencies (statusMonitor, addins, out resolved, out toUninstall, out unresolved);
 }
Ejemplo n.º 43
0
		/// <summary>
		/// Creates a package object for an add-in available in an on-line repository
		/// </summary>
		/// <param name="repAddin">
		/// An add-in reference
		/// </param>
		/// <returns>
		/// The package
		/// </returns>
		public static Package FromRepository (AddinRepositoryEntry repAddin)
		{
			return AddinPackage.PackageFromRepository (repAddin);
		}