Esempio n. 1
0
        /* (Mostly) Autogenerated */

        protected bool Equals(LoaderConfig other)
        {
            return(string.Equals(LoaderPath32, other.LoaderPath32) &&
                   string.Equals(LoaderPath64, other.LoaderPath64) &&
                   string.Equals(ApplicationConfigDirectory, other.ApplicationConfigDirectory) &&
                   string.Equals(ModConfigDirectory, other.ModConfigDirectory) &&
                   string.Equals(PluginConfigDirectory, other.PluginConfigDirectory) &&
                   EnabledPlugins.SequenceEqualWithNullSupport(other.EnabledPlugins));
        }
Esempio n. 2
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (InstallDirectory != null ? InstallDirectory.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ApplicationConfigDirectory != null ? ApplicationConfigDirectory.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ModConfigDirectory != null ? ModConfigDirectory.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (PluginConfigDirectory != null ? PluginConfigDirectory.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (EnabledPlugins != null ? EnabledPlugins.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ModSupportMatrix != null ? ModSupportMatrix.GetHashCode() : 0);
         return(hashCode);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Setup the source contents of the LiveRadioSource, i.e. create a childsource for each enabled plugin found
        /// and initialize the overview widget.
        /// </summary>
        /// <returns>
        /// A <see cref="System.Boolean"/> -- always returns true
        /// </returns>
        private bool SetupSourceContents()
        {
            foreach (ILiveRadioPlugin plugin in plugins)
            {
                if (EnabledPlugins.Contains(plugin.Name))
                {
                    AddPlugin(plugin);
                }
            }

            source_contents = new LiveRadioSourceContents(plugins);
            Properties.Set <ISourceContents> ("Nereid.SourceContents", source_contents);

            ServiceManager.SourceManager.SourceAdded -= OnSourceAdded;
            return(true);
        }
Esempio n. 4
0
        internal static Task CommitTransaction(StateTransitionTransaction transaction)
        {
            if (!transaction.HasStateChanged)
            {
                return(Task.WhenAll());
            }

            if (!UnityGame.OnMainThread)
            {
                var transactionCopy = transaction.Clone();
                transaction.Dispose();
                return(UnityMainThreadTaskScheduler.Factory.StartNew(() => CommitTransaction(transactionCopy)).Unwrap());
            }

            lock (commitTransactionLockObject)
            {
                if (transaction.CurrentlyEnabled.Except(EnabledPlugins)
                    .Concat(EnabledPlugins.Except(transaction.CurrentlyEnabled)).Any() ||
                    transaction.CurrentlyDisabled.Except(DisabledPlugins)
                    .Concat(DisabledPlugins.Except(transaction.CurrentlyDisabled)).Any())
                { // ensure that the transaction's base state reflects the current state, otherwise throw
                    transaction.Dispose();
                    throw new InvalidOperationException("Transaction no longer resembles the current state of plugins");
                }

                var toEnable  = transaction.ToEnable;
                var toDisable = transaction.ToDisable;
                transaction.Dispose();

                using var disabledChangeTransaction = DisabledConfig.Instance.ChangeTransaction();
                {
                    // first enable the mods that need to be
                    void DeTree(List <PluginMetadata> into, IEnumerable <PluginMetadata> tree)
                    {
                        foreach (var st in tree)
                        {
                            if (toEnable.Contains(st) && !into.Contains(st))
                            {
                                DeTree(into, st.Dependencies);
                                into.Add(st);
                            }
                        }
                    }

                    var enableOrder = new List <PluginMetadata>();
                    DeTree(enableOrder, toEnable);

                    foreach (var meta in enableOrder)
                    {
                        var executor = runtimeDisabledPlugins.FirstOrDefault(e => e.Metadata == meta);
                        if (meta.RuntimeOptions == RuntimeOptions.DynamicInit)
                        {
                            if (executor != null)
                            {
                                runtimeDisabledPlugins.Remove(executor);
                            }
                            else
                            {
                                executor = PluginLoader.InitPlugin(meta, EnabledPlugins);
                            }

                            if (executor == null)
                            {
                                continue;                   // couldn't initialize, skip to next
                            }
                        }

                        PluginLoader.DisabledPlugins.Remove(meta);
                        DisabledConfig.Instance.DisabledModIds.Remove(meta.Id ?? meta.Name);

                        PluginEnabled?.Invoke(meta, meta.RuntimeOptions != RuntimeOptions.DynamicInit);

                        if (meta.RuntimeOptions == RuntimeOptions.DynamicInit)
                        {
                            _bsPlugins.Add(executor);

                            try
                            {
                                executor.Enable();
                            }
                            catch (Exception e)
                            {
                                Logger.loader.Error($"Error while enabling {meta.Id}:");
                                Logger.loader.Error(e);
                                // this should still be considered enabled, hence its position
                            }
                        }
                    }
                }

                var result = Task.WhenAll();
                {
Esempio n. 5
0
 public List <IPlugin> GetPlugins(int siteId)
 {
     return(EnabledPlugins.Where(plugin => IsEnabled(plugin, siteId)).ToList());
 }
Esempio n. 6
0
        /// <summary>
        /// Constructor -- creates a new LiveRadio parent source
        /// </summary>
        public LiveRadioSource() : base(AddinManager.CurrentLocalizer.GetString("LiveRadio"),
                                        AddinManager.CurrentLocalizer.GetString("LiveRadio"), "live-radio", sort_order)
        {
            Properties.SetString("Icon.Name", "radio");
            TypeUniqueId = "live-radio";
            IsLocal      = false;

            string enabled_plugin_names = EnabledPluginsEntry.Get();

            if (String.IsNullOrEmpty(enabled_plugin_names))
            {
                enabled_plugins = new List <string> ();
            }
            else
            {
                enabled_plugins = new List <string> (enabled_plugin_names.Split(','));
            }

            //Load internet directory parser plugins
            plugins = new LiveRadioPluginManager().LoadPlugins();
            foreach (ILiveRadioPlugin plugin in plugins)
            {
                Log.DebugFormat("[LiveRadioSource]<Constructor> found plugin: {0}, enabled: {1}",
                                plugin.Name,
                                (EnabledPlugins.Contains(plugin.Name)));
            }

            AfterInitialized();

            //setting up interface actions
            InterfaceActionService uia_service = ServiceManager.Get <InterfaceActionService> ();

            uia_service.GlobalActions.AddImportant(new ActionEntry[] { new ActionEntry("LiveRadioAction", null,
                                                                                       AddinManager.CurrentLocalizer.GetString("Live_Radio"), null, null, null),
                                                                       new ActionEntry("LiveRadioConfigureAction", Stock.Properties,
                                                                                       AddinManager.CurrentLocalizer.GetString("_Configure"), null,
                                                                                       AddinManager.CurrentLocalizer.GetString("Configure the LiveRadio plugin"), OnConfigure) });

            uia_service.GlobalActions.AddImportant(
                new ActionEntry("RefreshLiveRadioAction",
                                Stock.Refresh, AddinManager.CurrentLocalizer.GetString("Refresh View"), null,
                                AddinManager.CurrentLocalizer.GetString("Refresh View"),
                                OnRefreshPlugin));
            uia_service.GlobalActions.AddImportant(
                new ActionEntry("AddToInternetRadioAction",
                                Stock.Add, AddinManager.CurrentLocalizer.GetString("Add To Internet Radio"), null,
                                AddinManager.CurrentLocalizer.GetString("Add stream as Internet Radio Station"),
                                OnAddToInternetRadio));

            ui_global_id = uia_service.UIManager.AddUiFromResource("GlobalUI.xml");

            Properties.SetString("ActiveSourceUIResource", "ActiveSourceUI.xml");
            Properties.Set <bool> ("ActiveSourceUIResourcePropagate", true);
            Properties.Set <System.Reflection.Assembly> ("ActiveSourceUIResource.Assembly", typeof(LiveRadioPluginSource).Assembly);

            Properties.SetString("GtkActionPath", "/LiveRadioContextMenu");
            Properties.Set <bool> ("Nereid.SourceContentsPropagate", false);

            if (!SetupSourceContents())
            {
                ServiceManager.SourceManager.SourceAdded += OnSourceAdded;
            }
        }