コード例 #1
0
		public AddinDetailWidget (Addin addin)
		{
			this.Addin = addin;

			BorderWidth = 12;

			var desc = Addin.Description;
			PackStart (new Label { Markup = string.Format ("<big><tt>{0}</tt></big>\n{1}\n{2}", desc.AddinId, desc.Name, desc.Description)}, true, false, 0);

			ShowAll ();
		}
コード例 #2
0
ファイル: AddinsManager.cs プロジェクト: xenoinc/ToolsHub
 private void OnAddinLoaded(object sender, Mono.Addins.AddinEventArgs args)
 {
     Mono.Addins.Addin addin = Mono.Addins.AddinManager.Registry.GetAddin(args.AddinId);
     Log.Debug($"=============================");
     Log.Debug($"OnAddinLoaded: {args.AddinId}");
     Log.Debug($"         Name: '{addin.Name}'");
     Log.Debug($"  Description: '{addin.Description.Description}'");
     Log.Debug($"    Namespace: '{addin.Namespace}'");
     Log.Debug($"      Enabled: '{addin.Enabled}'");
     Log.Debug($"         File: '{addin.AddinFile}'");
     Log.Debug("= = = = = = = = = = = = =");
 }
コード例 #3
0
ファイル: RuntimeAddin.cs プロジェクト: slluis/mono-addins
 internal RuntimeAddin(AddinEngine addinEngine, RuntimeAddin parentAddin, ModuleDescription module)
 {
     this.addinEngine = addinEngine;
     this.parentAddin = parentAddin;
     this.module = module;
     id = parentAddin.id;
     baseDirectory = parentAddin.baseDirectory;
     privatePath = parentAddin.privatePath;
     ainfo = parentAddin.ainfo;
     localizer = parentAddin.localizer;
     module.RuntimeAddin = this;
 }
コード例 #4
0
		public AddAddinReferenceDialog (Addin[] allAddins)
		{
			if (allAddins == null || allAddins.Length == 0)
				throw new ArgumentException ();

			Title = GettextCatalog.GetString ("Add Addin Reference");
			DestroyWithParent = true;
			Modal = true;
			HasSeparator = false;
			WidthRequest = 400;
			HeightRequest = 400;
			AllowShrink = false;
			Resizable = true;

			AddActionWidget (new Button (Stock.Cancel), ResponseType.Cancel);
			AddActionWidget (addButton, ResponseType.Ok);

			treeView.HeadersVisible = false;
			treeView.Model = store;

			var column = new TreeViewColumn ();
			var toggleRenderer = new CellRendererToggle ();
			column.PackStart (toggleRenderer, false);
			column.SetCellDataFunc (toggleRenderer, ToggleCellDataFunc);

			toggleRenderer.Toggled += HandleToggled;

			var textRenderer = new CellRendererText ();
			column.PackStart (textRenderer, true);
			column.SetCellDataFunc (textRenderer, TextCellDataFunc);

			treeView.AppendColumn (column);
			var sw = new CompactScrolledWindow {
				Child = treeView
			};
			VBox.PackStart (sw);

			foreach (var addin in allAddins.OrderBy (a => a.Id)) {
				store.AppendValues (addin, false);
			}

			addButton.Sensitive = false;

			ShowAll ();
		}
コード例 #5
0
ファイル: RuntimeAddin.cs プロジェクト: slluis/mono-addins
        internal AddinDescription Load(Addin iad)
        {
            ainfo = iad;

            AddinDescription description = iad.Description;
            id = description.AddinId;
            baseDirectory = description.BasePath;
            module = description.MainModule;
            module.RuntimeAddin = this;

            if (description.Localizer != null) {
                string cls = description.Localizer.GetAttribute ("type");

                // First try getting one of the stock localizers. If none of found try getting the type.
                object fob = null;
                Type t = Type.GetType ("Mono.Addins.Localization." + cls + "Localizer, " + GetType().Assembly.FullName, false);
                if (t != null)
                    fob = Activator.CreateInstance (t);

                if (fob == null)
                    fob = CreateInstance (cls, true);

                IAddinLocalizerFactory factory = fob as IAddinLocalizerFactory;
                if (factory == null)
                    throw new InvalidOperationException ("Localizer factory type '" + cls + "' must implement IAddinLocalizerFactory");
                localizer = new AddinLocalizer (factory.CreateLocalizer (this, description.Localizer));
            }

            return description;
        }
コード例 #6
0
		public static AddinPackage FromInstalledAddin (Addin sinfo)
		{
			AddinPackage pack = new AddinPackage ();
			pack.info = AddinInfo.ReadFromDescription (sinfo.Description);
			return pack;
		}
コード例 #7
0
		internal override void PrepareUninstall (IProgressMonitor monitor, AddinStore service)
		{
			iaddin = service.Registry.GetAddin (info.Id, true);
			if (iaddin == null)
				throw new InstallException (string.Format ("The add-in '{0}' is not installed.", info.Name));

			AddinDescription conf = iaddin.Description;
			string basePath = Path.GetDirectoryName (conf.AddinFile);
			
			if (!File.Exists (iaddin.AddinFile)) {
				monitor.ReportWarning (string.Format ("The add-in '{0}' is scheduled for uninstalling, but the add-in file could not be found.", info.Name));
				return;
			}
			
			if (!service.HasWriteAccess (iaddin.AddinFile))
				throw new InstallException (AddinStore.GetUninstallErrorNoRoot (info));

			foreach (string relPath in conf.AllFiles) {
				string path = Path.Combine (basePath, relPath);
				if (!File.Exists (path))
					continue;
				if (!service.HasWriteAccess (path))
					throw new InstallException (AddinStore.GetUninstallErrorNoRoot (info));
			}
			
			tempFolder = CreateTempFolder ();
			CopyAddinFiles (monitor, conf, iaddin.AddinFile, tempFolder);
		}
コード例 #8
0
		internal override void RollbackInstall (IProgressMonitor monitor, AddinStore service)
		{
			if (installed) {
				iaddin = service.Registry.GetAddin (info.Id);
				if (iaddin != null)
					CommitUninstall (monitor, service);
			}
		}
コード例 #9
0
		static void AddReference (AddinDescription desc, Addin addin)
		{
			foreach (AddinDependency adep in desc.MainModule.Dependencies) {
				if (adep.FullAddinId == addin.Id)
					return;
			}
			if (addin.Namespace == desc.Namespace)
				desc.MainModule.Dependencies.Add (new AddinDependency (addin.LocalId, addin.Version));
			else
				desc.MainModule.Dependencies.Add (new AddinDependency (addin.Id));
		}
コード例 #10
0
 public bool IsAddinLoaded(string id)
 {
     return(loadedAddins.Contains(Addin.GetIdName(id)));
 }
コード例 #11
0
ファイル: SetupTool.cs プロジェクト: directhex/mono-addins
 bool IsHidden(Addin ainfo)
 {
     return service.ApplicationNamespace != null && !(ainfo.Namespace + ".").StartsWith (service.ApplicationNamespace + ".") || ainfo.Description.IsHidden;
 }
コード例 #12
0
ファイル: AddinPackage.cs プロジェクト: mono/mono-addins
        internal override void PrepareUninstall(IProgressMonitor monitor, AddinStore service)
        {
            iaddin = service.Registry.GetAddin (info.Id, true);
            if (iaddin == null)
                throw new InstallException (string.Format ("The add-in '{0}' is not installed.", info.Name));

            AddinDescription conf = iaddin.Description;

            if (!File.Exists (iaddin.AddinFile)) {
                monitor.ReportWarning (string.Format ("The add-in '{0}' is scheduled for uninstalling, but the add-in file could not be found.", info.Name));
                return;
            }

            // The add-in is a core application add-in. It can't be uninstalled, so it will be disabled.
            if (!service.IsUserAddin (iaddin.AddinFile)) {
                disablingOnUninstall = true;
                return;
            }

            // If the add-in assemblies are loaded, or if there is any file with a write lock, delay the uninstallation
            HashSet<string> files = new HashSet<string> (GetInstalledFiles (conf));
            if (AddinManager.CheckAssembliesLoaded (files) || files.Any (f => HasWriteLock (f))) {
                uninstallingLoaded = true;
                return;
            }

            if (!service.HasWriteAccess (iaddin.AddinFile))
                throw new InstallException (AddinStore.GetUninstallErrorNoRoot (info));

            foreach (string path in GetInstalledFiles (conf)) {
                if (!service.HasWriteAccess (path))
                    throw new InstallException (AddinStore.GetUninstallErrorNoRoot (info));
            }

            tempFolder = CreateTempFolder ();
            CopyAddinFiles (monitor, conf, iaddin.AddinFile, tempFolder);
        }
コード例 #13
0
 public int CompareVersionTo(AddinInfo other)
 {
     return(Addin.CompareVersions(this.version, other.Version));
 }
コード例 #14
0
ファイル: AddinEngine.cs プロジェクト: ianitor/mono-addins
        bool ResolveLoadDependencies(ArrayList addins, Stack depCheck, string id, bool optional)
        {
            if (IsAddinLoaded(id))
            {
                return(true);
            }

            if (depCheck.Contains(id))
            {
                throw new InvalidOperationException("A cyclic addin dependency has been detected.");
            }

            depCheck.Push(id);

            Addin iad = Registry.GetAddin(id);

            if (iad == null || !iad.Enabled)
            {
                if (optional)
                {
                    return(false);
                }
                else if (iad != null && !iad.Enabled)
                {
                    throw new MissingDependencyException(GettextCatalog.GetString("The required addin '{0}' is disabled.", id));
                }
                else
                {
                    throw new MissingDependencyException(GettextCatalog.GetString("The required addin '{0}' is not installed.", id));
                }
            }

            // If this addin has already been requested, bring it to the head
            // of the list, so it is loaded earlier than before.
            addins.Remove(iad);
            addins.Add(iad);

            foreach (Dependency dep in iad.AddinInfo.Dependencies)
            {
                AddinDependency adep = dep as AddinDependency;
                if (adep != null)
                {
                    try {
                        string adepid = Addin.GetFullId(iad.AddinInfo.Namespace, adep.AddinId, adep.Version);
                        ResolveLoadDependencies(addins, depCheck, adepid, false);
                    } catch (MissingDependencyException) {
                        if (optional)
                        {
                            return(false);
                        }
                        else
                        {
                            throw;
                        }
                    }
                }
            }

            if (iad.AddinInfo.OptionalDependencies != null)
            {
                foreach (Dependency dep in iad.AddinInfo.OptionalDependencies)
                {
                    AddinDependency adep = dep as AddinDependency;
                    if (adep != null)
                    {
                        string adepid = Addin.GetFullId(iad.Namespace, adep.AddinId, adep.Version);
                        if (!ResolveLoadDependencies(addins, depCheck, adepid, true))
                        {
                            return(false);
                        }
                    }
                }
            }

            depCheck.Pop();
            return(true);
        }
コード例 #15
0
ファイル: AddinEngine.cs プロジェクト: ianitor/mono-addins
        internal bool LoadAddin(IProgressStatus statusMonitor, string id, bool throwExceptions)
        {
            try {
                lock (LocalLock) {
                    if (IsAddinLoaded(id))
                    {
                        return(true);
                    }

                    if (!Registry.IsAddinEnabled(id))
                    {
                        string msg = GettextCatalog.GetString("Disabled add-ins can't be loaded.");
                        ReportError(msg, id, null, false);
                        if (throwExceptions)
                        {
                            throw new InvalidOperationException(msg);
                        }
                        return(false);
                    }

                    ArrayList addins   = new ArrayList();
                    Stack     depCheck = new Stack();
                    ResolveLoadDependencies(addins, depCheck, id, false);
                    addins.Reverse();

                    if (statusMonitor != null)
                    {
                        statusMonitor.SetMessage("Loading Addins");
                    }

                    for (int n = 0; n < addins.Count; n++)
                    {
                        if (statusMonitor != null)
                        {
                            statusMonitor.SetProgress((double)n / (double)addins.Count);
                        }

                        Addin iad = (Addin)addins [n];
                        if (IsAddinLoaded(iad.Id))
                        {
                            continue;
                        }

                        if (statusMonitor != null)
                        {
                            statusMonitor.SetMessage(string.Format(GettextCatalog.GetString("Loading {0} add-in"), iad.Id));
                        }

                        if (!InsertAddin(statusMonitor, iad))
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
            }
            catch (Exception ex) {
                ReportError("Add-in could not be loaded: " + ex.Message, id, ex, false);
                if (statusMonitor != null)
                {
                    statusMonitor.ReportError("Add-in '" + id + "' could not be loaded.", ex);
                }
                if (throwExceptions)
                {
                    throw;
                }
                return(false);
            }
        }
コード例 #16
0
ファイル: AddinEngine.cs プロジェクト: ianitor/mono-addins
 /// <summary>
 /// Checks if an add-in has been loaded.
 /// </summary>
 /// <param name="id">
 /// Full identifier of the add-in.
 /// </param>
 /// <returns>
 /// True if the add-in is loaded.
 /// </returns>
 public bool IsAddinLoaded(string id)
 {
     CheckInitialized();
     ValidateAddinRoots();
     return(loadedAddins.ContainsKey(Addin.GetIdName(id)));
 }
コード例 #17
0
        internal void ActivateAddinExtensions(string id)
        {
            // Looks for loaded extension points which are extended by the provided
            // add-in, and adds the new nodes

            try {
                fireEvents = true;

                Addin addin = AddinManager.Registry.GetAddin(id);
                if (addin == null)
                {
                    AddinManager.ReportError("Required add-in not found", id, null, false);
                    return;
                }
                // Take note that his add-in has been enabled at run-time
                // Needed because loaded add-in descriptions may not include this add-in.
                RegisterRuntimeEnabledAddin(id);

                // Look for loaded extension points
                Hashtable eps = new Hashtable();
                foreach (ModuleDescription mod in addin.Description.AllModules)
                {
                    foreach (Extension ext in mod.Extensions)
                    {
                        ExtensionPoint ep = tree.FindLoadedExtensionPoint(ext.Path);
                        if (ep != null && !eps.Contains(ep))
                        {
                            eps.Add(ep, ep);
                        }
                    }
                }

                // Add the new nodes
                ArrayList loadedNodes = new ArrayList();
                foreach (ExtensionPoint ep in eps.Keys)
                {
                    ExtensionLoadData data = GetAddinExtensions(id, ep);
                    if (data != null)
                    {
                        foreach (Extension ext in data.Extensions)
                        {
                            TreeNode node = GetNode(ext.Path);
                            if (node != null && node.ExtensionNodeSet != null)
                            {
                                if (node.ChildrenLoaded)
                                {
                                    LoadModuleExtensionNodes(ext, data.AddinId, node.ExtensionNodeSet, loadedNodes);
                                }
                            }
                            else
                            {
                                AddinManager.ReportError("Extension node not found or not extensible: " + ext.Path, id, null, false);
                            }
                        }

                        // Global extension change event. Other events are fired by LoadModuleExtensionNodes.
                        NotifyExtensionsChanged(new ExtensionEventArgs(ep.Path));
                    }
                }

                // Call the OnAddinLoaded method on nodes, if the add-in is already loaded
                foreach (TreeNode nod in loadedNodes)
                {
                    nod.ExtensionNode.OnAddinLoaded();
                }
            }
            finally {
                fireEvents = false;
            }
            // Do the same in child contexts

            lock (conditionTypes) {
                if (childContexts != null)
                {
                    foreach (WeakReference wref in childContexts)
                    {
                        ExtensionContext ctx = wref.Target as ExtensionContext;
                        if (ctx != null)
                        {
                            ctx.ActivateAddinExtensions(id);
                        }
                    }
                }
            }
        }
コード例 #18
0
 internal RuntimeAddin GetAddin(string id)
 {
     return((RuntimeAddin)loadedAddins [Addin.GetIdName(id)]);
 }
コード例 #19
0
ファイル: AddinEngine.cs プロジェクト: slluis/mono-addins
        bool InsertAddin(IProgressStatus statusMonitor, Addin iad)
        {
            try {
                RuntimeAddin p = new RuntimeAddin (this);

                // Read the config file and load the add-in assemblies
                AddinDescription description = p.Load (iad);

                // Register the add-in
                loadedAddins [Addin.GetIdName (p.Id)] = p;

                if (!AddinDatabase.RunningSetupProcess) {
                    // Load the extension points and other addin data

                    foreach (ExtensionNodeSet rel in description.ExtensionNodeSets) {
                        RegisterNodeSet (rel);
                    }

                    foreach (ConditionTypeDescription cond in description.ConditionTypes) {
                        Type ctype = p.GetType (cond.TypeName, true);
                        RegisterCondition (cond.Id, ctype);
                    }
                }

                foreach (ExtensionPoint ep in description.ExtensionPoints)
                    InsertExtensionPoint (p, ep);

                // Fire loaded event
                NotifyAddinLoaded (p);
                ReportAddinLoad (p.Id);
                return true;
            }
            catch (Exception ex) {
                ReportError ("Add-in could not be loaded", iad.Id, ex, false);
                if (statusMonitor != null)
                    statusMonitor.ReportError ("Add-in '" + iad.Id + "' could not be loaded.", ex);
                return false;
            }
        }
コード例 #20
0
		public static string GetUnversionedId (Addin addin)
		{
			if (string.IsNullOrEmpty (addin.Namespace))
				return addin.LocalId;
			return addin.Namespace + "." + addin.LocalId;
		}
コード例 #21
0
		internal AddinDescription Load (Addin iad)
		{
			ainfo = iad;
			
			ArrayList plugList = new ArrayList ();
			ArrayList asmList = new ArrayList ();
			
			AddinDescription description = iad.Description;
			id = description.AddinId;
			baseDirectory = description.BasePath;
			
			// Load the main modules
			LoadModule (description.MainModule, description.Namespace, plugList, asmList);
			
			// Load the optional modules, if the dependencies are present
			foreach (ModuleDescription module in description.OptionalModules) {
				if (CheckAddinDependencies (module))
					LoadModule (module, description.Namespace, plugList, asmList);
			}
			
			depAddins = (RuntimeAddin[]) plugList.ToArray (typeof(RuntimeAddin));
			assemblies = (Assembly[]) asmList.ToArray (typeof(Assembly));
			
			return description;
		}
コード例 #22
0
		void AddAddin (Addin a)
		{
			string id = a.Namespace == this.AddinDescription.Namespace ? a.LocalId : Addin.GetIdName (a.Id);
			Add (id, a.Name + ". " + a.Description, id + "\" version=\"" + a.Version + "\"");
		}
コード例 #23
0
		void AddAddin (Addin addin)
		{
			AddinDescription desc = addin.Description;
			if (desc == null || desc.ExtensionPoints.Count == 0)
				return;
			
			if (isRoot && !desc.IsRoot)
				return;
			
			if (showTypedOnly) {
				bool istyped = false;
				for (int n=0; n<desc.ExtensionPoints.Count && !istyped; n++) {
					ExtensionPoint ep = desc.ExtensionPoints [n];
					for (int m=0; m<ep.NodeSet.NodeTypes.Count && !istyped; m++) {
						if (((ExtensionNodeType)ep.NodeSet.NodeTypes [m]).ObjectTypeName.Length > 0)
							istyped = true;
					}
				}
				if (!istyped)
					return;
			}
				
			TreeIter iter = TreeIter.Zero;
			if (showNamespaces) {
				if (desc.Namespace.Length == 0)
					iter = GetBranch (iter, AddinManager.CurrentLocalizer.GetString ("Global namespace"), pixNamespace);
				else
					iter = GetBranch (iter, desc.Namespace, pixNamespace);
			}
			if (showCategories) {
				if (desc.Category.Length > 0) {
					foreach (string cat in desc.Category.Split ('/')) {
						string tcat = cat.Trim ();
						if (tcat.Length == 0)
							continue;
						iter = GetBranch (iter, tcat, pixCategory);
					}
				} else {
					iter = GetBranch (iter, AddinManager.CurrentLocalizer.GetString ("Miscellaneous"), pixCategory);
				}
			}
			
			iter = GetBranch (iter, desc.Name, pixAddin);
			store.SetValue (iter, ColObject, addin);
			
			if (addinSelector) {
				store.SetValue (iter, ColShowCheck, true);
				store.SetValue (iter, ColChecked, selection.Contains (addin));
				store.SetValue (iter, ColFilled, true);
				return;
			}
			
			if (showExtensionPoints) {
				store.SetValue (iter, ColFilled, false);
				// Add a dummy node to make sure the expand button is shown
				store.AppendValues (iter, "", null, null, false, false, null, true, true);
			}
		}
コード例 #24
0
		internal AddinDescription Load (Addin iad)
		{
			ainfo = iad;
			
			ArrayList plugList = new ArrayList ();
			ArrayList asmList = new ArrayList ();
			
			AddinDescription description = iad.Description;
			id = description.AddinId;
			baseDirectory = description.BasePath;
			
			// Load the main modules
			LoadModule (description.MainModule, description.Namespace, plugList, asmList);
			
			// Load the optional modules, if the dependencies are present
			foreach (ModuleDescription module in description.OptionalModules) {
				if (CheckAddinDependencies (module))
					LoadModule (module, description.Namespace, plugList, asmList);
			}
			
			depAddins = (RuntimeAddin[]) plugList.ToArray (typeof(RuntimeAddin));
			assemblies = (Assembly[]) asmList.ToArray (typeof(Assembly));
			
			if (description.Localizer != null) {
				string cls = description.Localizer.GetAttribute ("type");
				
				// First try getting one of the stock localizers. If none of found try getting the type.
				object fob = CreateInstance ("Mono.Addins.Localization." + cls + "Localizer", false);
				if (fob == null)
					fob = CreateInstance (cls, true);
				
				IAddinLocalizerFactory factory = fob as IAddinLocalizerFactory;
				if (factory == null)
					throw new InvalidOperationException ("Localizer factory type '" + cls + "' must implement IAddinLocalizerFactory");
				localizer = new AddinLocalizer (factory.CreateLocalizer (this, description.Localizer));
			}
			
			return description;
		}