Пример #1
0
        void Uninstall(string[] args)
        {
            if (args.Length < 1)
            {
                throw new InstallException("The add-in id is required.");
            }

            Addin ads = registry.GetAddin(args[0]);

            if (ads == null)
            {
                throw new InstallException("The add-in '" + args[0] + "' is not installed.");
            }

            Console.WriteLine("The following add-ins will be uninstalled:");
            Console.WriteLine(" - " + ads.Description.Name);
            foreach (Addin si in service.GetDependentAddins(args[0], true))
            {
                Console.WriteLine(" - " + si.Description.Name);
            }

            Console.WriteLine();
            Console.Write("Are you sure you want to continue? (y/N): ");
            string res = Console.ReadLine();

            if (res == "y" || res == "Y")
            {
                service.Uninstall(new ConsoleProgressStatus(verbose), ads.Id);
            }
        }
Пример #2
0
        public void ResolveInstalledDuplicateAddin(string version)
        {
            var dir      = Util.GetSampleDirectory("ScanTest");
            var registry = new AddinRegistry(Path.Combine(dir, "Config"), Path.Combine(dir, "App"), Path.Combine(dir, "Addins"));

            // Hide the user addin. We'll simulate that the add-in is added
            var addinPath = Path.Combine(dir, "Addins", "SimpleAddin.addin.xml");

            File.Move(addinPath, addinPath + ".x");

            registry.Rebuild(new ConsoleProgressStatus(true));

            // Query using a lower version number
            var addin = registry.GetAddin("SimpleApp.Ext" + version);

            Assert.IsNotNull(addin);
            Assert.AreEqual("AppDir", addin.Properties.GetPropertyValue("Origin"));

            // Now simulate that the add-in is added

            File.Move(addinPath + ".x", addinPath);
            registry.Update(new ConsoleProgressStatus(true));
            addin = registry.GetAddin("SimpleApp.Ext" + version);
            Assert.IsNotNull(addin);
            Assert.AreEqual("AddinsDir", addin.Properties.GetPropertyValue("Origin"));
        }
Пример #3
0
        void CheckInstall(string[] args)
        {
            if (args.Length < 1)
            {
                PrintHelp("check-install");
                return;
            }

            PackageCollection packs = new PackageCollection();

            for (int n = 0; n < args.Length; n++)
            {
                Addin addin = registry.GetAddin(GetFullId(args[n]));
                if (addin != null)
                {
                    continue;
                }
                string aname    = Addin.GetIdName(GetFullId(args[n]));
                string aversion = Addin.GetIdVersion(args[n]);
                if (aversion.Length == 0)
                {
                    aversion = null;
                }

                AddinRepositoryEntry[] ads = service.Repositories.GetAvailableAddin(aname, aversion);
                if (ads.Length == 0)
                {
                    throw new InstallException("The addin '" + args[n] + "' is not available for install.");
                }
                packs.Add(AddinPackage.FromRepository(ads[ads.Length - 1]));
            }
            Install(packs, false);
        }
Пример #4
0
        public SelectNodeSetDialog(DotNetProject project, AddinRegistry registry, AddinDescription desc)
        {
            this.Build();
            this.project  = project;
            this.registry = registry;
            this.desc     = desc;

            foreach (AddinDependency adep in desc.MainModule.Dependencies)
            {
                Addin addin = registry.GetAddin(adep.FullAddinId);
                if (addin != null && addin.Description != null)
                {
                    foreach (ExtensionNodeSet ns in addin.Description.ExtensionNodeSets)
                    {
                        combo.AppendText(ns.Id);
                        sets [ns.Id] = ns;
                    }
                }
            }

            foreach (ExtensionNodeSet ns in desc.ExtensionNodeSets)
            {
                combo.AppendText(ns.Id);
                sets [ns.Id] = ns;
            }

            nodeseteditor.AllowEditing = false;
            buttonOk.Sensitive         = false;
        }
        ExtensionNodeSet FindNodeSet(string name)
        {
            foreach (ExtensionNodeSet ns in adesc.ExtensionNodeSets)
            {
                if (ns.Id == name)
                {
                    return(ns);
                }
            }

            foreach (AddinDependency adep in adesc.MainModule.Dependencies)
            {
                Addin addin = registry.GetAddin(adep.FullAddinId);
                if (addin != null && addin.Description != null)
                {
                    foreach (ExtensionNodeSet ns in addin.Description.ExtensionNodeSets)
                    {
                        if (ns.Id == name)
                        {
                            return(ns);
                        }
                    }
                }
            }
            return(null);
        }
        void FillExtensionPoint(TreeIter iter, ExtensionPoint ep)
        {
            // Add extension node types

            FillExtensionNodeSet(iter, ep.NodeSet);

            // Add extension nodes from known add-ins

            ArrayList extensions = new ArrayList();

            CollectExtensions(ep.ParentAddinDescription, ep.Path, extensions);
            foreach (Dependency dep in ep.ParentAddinDescription.MainModule.Dependencies)
            {
                AddinDependency adep = dep as AddinDependency;
                if (adep == null)
                {
                    continue;
                }
                Addin addin = registry.GetAddin(adep.FullAddinId);
                if (addin != null)
                {
                    CollectExtensions(addin.Description, ep.Path, extensions);
                }
            }

            // Sort the extensions, to make sure they are added in the correct order
            // That is, deepest children last.
            extensions.Sort(new ExtensionComparer());

//			iter = store.AppendValues (iter, "Extensions", null, ep, false, false, null, false, true);

            // Add the nodes
            foreach (Extension ext in extensions)
            {
                string           subp  = ext.Path.Substring(ep.Path.Length);
                TreeIter         citer = iter;
                ExtensionNodeSet ns    = ep.NodeSet;
                bool             found = true;
                foreach (string p in subp.Split('/'))
                {
                    if (p.Length == 0)
                    {
                        continue;
                    }
                    if (!GetNodeBranch(citer, p, ns, out citer, out ns))
                    {
                        found = false;
                        break;
                    }
                }
                if (found)
                {
                    FillNodes(citer, ns, ext.ExtensionNodes);
                }
            }
        }
Пример #7
0
        public IEnumerable <Addin> GetReferencedAddins()
        {
            yield return(AddinRegistry.GetAddin("MonoDevelop.Core"));

            yield return(AddinRegistry.GetAddin("MonoDevelop.Ide"));

            foreach (var ar in Project.Items.OfType <AddinReference> ())
            {
                yield return(AddinRegistry.GetAddin(ar.Include));
            }
        }
Пример #8
0
        public IEnumerable <Addin> GetReferencedAddins()
        {
            yield return(AddinRegistry.GetAddin("MonoDevelop.Core"));

            yield return(AddinRegistry.GetAddin("MonoDevelop.Ide"));

            foreach (var ar in AddinReferences)
            {
                yield return(AddinRegistry.GetAddin(ar.Id));
            }
        }
Пример #9
0
        internal static ExtensionNodeDescriptionCollection GetExtensionNodes(AddinRegistry registry, AddinDescription desc, string path)
        {
            ArrayList extensions = new ArrayList();

            CollectExtensions(desc, path, extensions);
            foreach (Dependency dep in desc.MainModule.Dependencies)
            {
                AddinDependency adep = dep as AddinDependency;
                if (adep == null)
                {
                    continue;
                }
                Addin addin = registry.GetAddin(adep.FullAddinId);
                if (addin != null)
                {
                    CollectExtensions(addin.Description, path, extensions);
                }
            }

            // Sort the extensions, to make sure they are added in the correct order
            // That is, deepest children last.
            extensions.Sort(new ExtensionComparer());

            ExtensionNodeDescriptionCollection nodes = new ExtensionNodeDescriptionCollection();

            // Add the nodes
            foreach (Extension ext in extensions)
            {
                string subp = path.Substring(ext.Path.Length);
                ExtensionNodeDescriptionCollection col = ext.ExtensionNodes;
                foreach (string p in subp.Split('/'))
                {
                    if (p.Length == 0)
                    {
                        continue;
                    }
                    ExtensionNodeDescription node = col [p];
                    if (node == null)
                    {
                        col = null;
                        break;
                    }
                    else
                    {
                        col = node.ChildNodes;
                    }
                }
                if (col != null)
                {
                    nodes.AddRange(col);
                }
            }
            return(nodes);
        }
Пример #10
0
        public void Fill(AddinRegistry reg, ExtensionPoint ep)
        {
            List <AddinDescription> deps = new List <AddinDescription> ();

            foreach (var addinId in ep.ExtenderAddins)
            {
                Addin ad = reg.GetAddin(addinId);
                if (ad != null && ad.LocalId != ep.ParentAddinDescription.LocalId)
                {
                    deps.Add(ad.Description);
                }
            }
            Fill(ep.ParentAddinDescription, ep.ParentAddinDescription, ep.Path, deps);
        }
Пример #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);
            }
        }
Пример #12
0
        CompletionDataList GetPathCompletion(string subPath)
        {
            CompletionContext ctx = GetCompletionContext(1);

            if (!(ctx is ExtensionCompletionContext))
            {
                return(null);
            }
            ModuleCompletionContext mc = (ModuleCompletionContext)ctx.GetParentContext(typeof(ModuleCompletionContext));

            Set <string>       paths = new Set <string> ();
            CompletionDataList cp    = new CompletionDataList();

            foreach (AddinDependency adep in mc.Module.Dependencies)
            {
                Addin addin = registry.GetAddin(adep.FullAddinId);
                if (addin != null && addin.Description != null)
                {
                    foreach (ExtensionPoint ep in addin.Description.ExtensionPoints)
                    {
                        if (ep.Path.StartsWith(subPath))
                        {
                            string spath = ep.Path.Substring(subPath.Length);
                            int    i     = spath.IndexOf('/');
                            if (i != -1)
                            {
                                spath = spath.Substring(0, i);
                            }
                            if (paths.Add(spath))
                            {
                                if (i == -1)                                 // Full match. Add the documentation
                                {
                                    cp.Add(spath, "md-extension-point", ep.Name + "\n" + ep.Description);
                                }
                                else
                                {
                                    cp.Add(spath, "md-literal");
                                }
                            }
                        }
                    }
                }
            }
            return(cp);
        }
Пример #13
0
 public override void OnAddAttributeValues(string attName)
 {
     if (attName == "id")
     {
         ModuleCompletionContext mc = (ModuleCompletionContext)GetParentContext(typeof(ModuleCompletionContext));
         foreach (AddinDependency adep in mc.Module.Dependencies)
         {
             Addin addin = AddinRegistry.GetAddin(adep.FullAddinId);
             if (addin != null && addin.Description != null)
             {
                 foreach (ExtensionNodeSet ns in addin.Description.ExtensionNodeSets)
                 {
                     Add(ns.Id, "");
                 }
             }
         }
     }
 }
Пример #14
0
        public void Fill(AddinRegistry reg, AddinDescription localDesc, AddinDescription pdesc, string path)
        {
            List <AddinDescription> deps = new List <AddinDescription> ();

            foreach (Dependency dep in pdesc.MainModule.Dependencies)
            {
                AddinDependency adep = dep as AddinDependency;
                if (adep == null)
                {
                    continue;
                }
                Addin addin = reg.GetAddin(adep.FullAddinId);
                if (addin != null)
                {
                    deps.Add(addin.Description);
                }
            }
            Fill(localDesc, pdesc, path, deps);
        }
Пример #15
0
        ExtensionNodeSet FindNodeSet(AddinRegistry reg, AddinDescription adesc, string name)
        {
            ExtensionNodeSet nset = adesc.ExtensionNodeSets [name];

            if (nset != null)
            {
                return(nset);
            }
            foreach (AddinDependency adep in adesc.MainModule.Dependencies)
            {
                Addin addin = reg.GetAddin(adep.FullAddinId);
                if (addin != null)
                {
                    nset = adesc.ExtensionNodeSets [name];
                    if (nset != null)
                    {
                        return(nset);
                    }
                }
            }
            return(null);
        }