public object BuildItem(PluginItemMetadata itemData, PluginRuntime plugin) { BuilderHelper.CheckParameter("ServiceClassName", itemData); string serviceClassName = itemData.Attributes["ServiceClassName"]; object serviceInstance = plugin.InstantiatePluginObject(serviceClassName); if (serviceInstance == null) { ServiceRegistration.Get<ILogger>().Warn("ServiceBuilder: Could not instantiate service class '{0}' in plugin '{1}' (id: '{2}')", serviceClassName, itemData.PluginRuntime.Metadata.Name, itemData.PluginRuntime.Metadata.PluginId); return null; } string registrationClassAssembly; if (!itemData.Attributes.TryGetValue("RegistrationClassAssembly", out registrationClassAssembly)) registrationClassAssembly = null; string registrationClassName; if (!itemData.Attributes.TryGetValue("RegistrationClassName", out registrationClassName)) registrationClassName = null; Type registrationType; if (string.IsNullOrEmpty(registrationClassName)) registrationType = serviceInstance.GetType(); else registrationType = string.IsNullOrEmpty(registrationClassAssembly) ? plugin.GetPluginType(registrationClassName) : Type.GetType(registrationClassName + ", " + registrationClassAssembly); if (registrationType == null) { ServiceRegistration.Get<ILogger>().Warn("ServiceBuilder: Could not instantiate service registration type '{0}' (Assembly: '{1}') in plugin '{2}' (id: '{3}')", registrationClassName, registrationClassAssembly, itemData.PluginRuntime.Metadata.Name, itemData.PluginRuntime.Metadata.PluginId); return null; } return new ServiceItem(registrationType, serviceInstance); }
public void Activated(PluginRuntime pluginRuntime) { messageQueue = new AsynchronousMessageQueue(this, new string[] {SystemMessaging.CHANNEL, PlayerManagerMessaging.CHANNEL}); messageQueue.MessageReceived += OnMessageReceived; messageQueue.Start(); }
public void Activated(PluginRuntime pluginRuntime) { var meta = pluginRuntime.Metadata; Logger.Info(string.Format("{0} v{1} [{2}] by {3}", meta.Name, meta.PluginVersion, meta.Description, meta.Author)); DvDevice device = ServiceRegistration.Get<IBackendServer>().UPnPBackendServer.FindDevicesByDeviceTypeAndVersion(UPnPTypesAndIds.BACKEND_SERVER_DEVICE_TYPE, UPnPTypesAndIds.BACKEND_SERVER_DEVICE_TYPE_VERSION, true).FirstOrDefault(); if (device != null) { var serverSettings = new ServerSettingsImpl(); Logger.Debug("ServerSettings: Registering ServerSettings service."); device.AddService(serverSettings); Logger.Debug("ServerSettings: Adding ServerSettings service to MP2 backend root device"); // List all assemblies InitPluginAssemblyList(); // Set our own resolver to lookup types from any of assemblies from Plugins subfolder. SettingsSerializer.CustomAssemblyResolver = PluginsAssemblyResolver; // AppDomain.CurrentDomain.AssemblyResolve += PluginsAssemblyResolver; Logger.Debug("ServerSettings: Adding Plugins folder to private path"); } else { Logger.Error("ServerSettings: MP2 backend root device not found!"); } }
protected static ConfigSectionMetadata BuildSection(PluginItemMetadata itemData, PluginRuntime plugin) { string location = ConfigBaseMetadata.ConcatLocations(itemData.RegistrationLocation, itemData.Id); string text = null; string iconSmallPath = null; string iconLargePath = null; foreach (KeyValuePair<string, string> attr in itemData.Attributes) { switch (attr.Key) { case "Text": text = attr.Value; break; case "IconSmallPath": iconSmallPath = attr.Value; break; case "IconLargePath": iconLargePath = attr.Value; break; default: throw new ArgumentException("'ConfigSection' builder doesn't define an attribute '" + attr.Key + "'"); } } if (text == null) throw new ArgumentException("'ConfigSection' item needs an attribute 'Text'"); return new ConfigSectionMetadata(location, text, plugin.Metadata.GetAbsolutePath(iconSmallPath), plugin.Metadata.GetAbsolutePath(iconLargePath)); }
public object BuildItem(PluginItemMetadata itemData, PluginRuntime plugin) { BuilderHelper.CheckParameter("ClassName", itemData); BuilderHelper.CheckParameter("ProviderName", itemData); BuilderHelper.CheckParameter("Priority", itemData); return new ThumbnailProviderRegistration(plugin.GetPluginType(itemData.Attributes["ClassName"]), itemData.Id, itemData.Attributes["ProviderName"], itemData.Attributes["Priority"]); }
public object BuildItem(PluginItemMetadata itemData, PluginRuntime plugin) { BuilderHelper.CheckParameter("ClassName", itemData); BuilderHelper.CheckParameter("Caption", itemData); BuilderHelper.CheckParameter("Sort", itemData); return new MediaItemActionExtension(plugin.GetPluginType(itemData.Attributes["ClassName"]), itemData.Attributes["Caption"], itemData.Attributes["Sort"], itemData.Id); }
public void Activated(PluginRuntime pluginRuntime) { ServiceRegistration.Set<ITvHandler>(new SlimTvHandler()); // Register recording section in MediaLibrary RecordingsLibrary.RegisterOnMediaLibrary(); }
public void Activated(PluginRuntime pluginRuntime) { if (_isInitialized) return; _isInitialized = true; // All non-default media item aspects must be registered var miatr = ServiceRegistration.Get<IMediaItemAspectTypeRegistration>(); miatr.RegisterLocallyKnownMediaItemAspectType(OnlineVideosAspect.Metadata); InitializeOnlineVideoSettings(); // create a message queue for OnlineVideos to broadcast that the list of site utils was rebuild _messageQueue = new AsynchronousMessageQueue(this, new string[] { OnlineVideosMessaging.CHANNEL }); _messageQueue.Start(); // load and update sites in a background thread, it takes time and we are on the Main thread delaying MP2 startup ServiceRegistration.Get<IThreadPool>().Add( InitialSitesUpdateAndLoad, "OnlineVideos Initial Sites Load & Update", QueuePriority.Low, ThreadPriority.BelowNormal, AfterInitialLoad); }
public object BuildItem(PluginItemMetadata itemData, PluginRuntime plugin) { BuilderHelper.CheckParameter("Type", itemData); BuilderHelper.CheckParameter("Directory", itemData); return new PluginResource( (PluginResourceType) Enum.Parse(typeof (PluginResourceType), itemData.Attributes["Type"]), plugin.Metadata.GetAbsolutePath(itemData.Attributes["Directory"])); }
public void Activated(PluginRuntime pluginRuntime) { EmulatorsCore.Init(new EmulatorsSettings()); importer = new Importer(); EmulatorsCore.Database.OnItemDeleting += Database_OnItemDeleting; ServiceRegistration.Set<IEmulatorsService>(this); ImporterMessaging.SendImporterMessage(ImporterMessaging.MessageType.Init); }
public void Activated(PluginRuntime pluginRuntime) { var meta = pluginRuntime.Metadata; Logger.Info(string.Format("{0} v{1} [{2}] by {3}", meta.Name, meta.PluginVersion, meta.Description, meta.Author)); Logger.Debug("MediaServerPlugin: Adding UPNP device as a root device"); ServiceRegistration.Get<IBackendServer>().UPnPBackendServer.AddRootDevice(_device); ServiceRegistration.Get<IResourceServer>().AddHttpModule(new DlnaResourceAccessModule()); }
public void Activated(PluginRuntime pluginRuntime) { var meta = pluginRuntime.Metadata; Logger.Info(string.Format("{0} v{1} [{2}] by {3}", meta.Name, meta.PluginVersion, meta.Description, meta.Author)); ServiceRegistration.Get<IMessageBroker>().RegisterMessageReceiver(SystemMessaging.CHANNEL, this); SubscribeToMessages(); //Logger.Debug("UPnPRenderPlugin: Adding UPNP device as a root device"); //ServiceRegistration.Get<IFrontendServer>().UPnPFrontendServer.AddRootDevice(_device); }
public void RevokeItem(object item, PluginItemMetadata itemData, PluginRuntime plugin) { BackgroundType type; string typeName = GetBackgroundAndType(itemData.Attributes, out type); switch (type) { case BackgroundType.Manager: plugin.RevokePluginObject(typeName); break; } }
/// <summary> /// Registers a plugin to be dependent from this plugin. This is necessary to build up a /// plugin dependency tree. /// </summary> /// <param name="plugin">The plugin which is dependent on this plugin.</param> internal void AddDependentPlugin(PluginRuntime plugin) { lock (_syncObj) { if (_dependentPlugins == null) { _dependentPlugins = new List <PluginRuntime>(); } _dependentPlugins.Add(plugin); } }
public void Activated(PluginRuntime pluginRuntime) { var meta = pluginRuntime.Metadata; Logger.Info(string.Format("{0} v{1} [{2}] by {3}", meta.Name, meta.PluginVersion, meta.Description, meta.Author)); IResourceServer server = ServiceRegistration.Get<IResourceServer>(); if (server != null) { ServiceRegistration.Set<IFanArtService>(new FanArtService()); _fanartModule = new FanartAccessModule(); server.AddHttpModule(_fanartModule); } }
public void Activated(PluginRuntime pluginRuntime) { ISystemResolver systemResolver = ServiceRegistration.Get<ISystemResolver>(); var appKey = systemResolver.SystemType == SystemType.Server ? KEY_SERVER : KEY_CLIENT; // The appkey and shared key can be found in onetrueeror.com OneTrue.Configuration.Credentials(appKey.Item1, appKey.Item2); OneTrue.Configuration.CatchWinFormsExceptions(); OneTrue.Configuration.Advanced.UploadReportFailed += OnUploadReportFailed; // Exchange the logger by the error reporting wrapper var currentLogger = ServiceRegistration.Get<ILogger>(); var errorLogger = new ErrorLogWrapper(currentLogger); ServiceRegistration.Set<ILogger>(errorLogger); }
public object BuildItem(PluginItemMetadata itemData, PluginRuntime plugin) { BuilderHelper.CheckParameter("ClassName", itemData); BuilderHelper.CheckParameter("Filter", itemData); // Support for simplified escaping inside XML tag string filter = itemData.Attributes["Filter"].Replace("{", "<").Replace("}", ">"); FilterWrapper wrapper; if (_serializer == null) _serializer = new XmlSerializer(typeof(FilterWrapper)); using (var reader = new StringReader(filter)) wrapper = (FilterWrapper)_serializer.Deserialize(reader); return new MediaNavigationFilter(itemData.Attributes["ClassName"], wrapper.Filter); }
public object BuildItem(PluginItemMetadata itemData, PluginRuntime plugin) { BackgroundType type; string value = GetBackgroundAndType(itemData.Attributes, out type); switch (type) { case BackgroundType.Static: return new StaticBackgroundManager(value); case BackgroundType.Manager: // The cast is necessary here to ensure the returned instance is an IBackgroundManager return (IBackgroundManager) plugin.InstantiatePluginObject(value); default: throw new NotImplementedException(string.Format( "Background builder: Background type '{0}' is not implemented", type)); } }
public void Activated(PluginRuntime pluginRuntime) { ISystemStateService sss = ServiceRegistration.Get<ISystemStateService>(); if (sss.CurrentState == SystemState.Running) { _reloadSkinActions.RegisterKeyActions(); _loadSkinThemeActions.RegisterKeyActions(); } else { _messageQueue = new AsynchronousMessageQueue(typeof(ReloadSkinActions), new string[] { SystemMessaging.CHANNEL }); _messageQueue.MessageReceived += OnMessageReceived; _messageQueue.Start(); } }
public void Activated(PluginRuntime pluginRuntime) { var meta = pluginRuntime.Metadata; Logger.Info(string.Format("{0} v{1} [{2}] by {3}", meta.Name, meta.PluginVersion, meta.Description, meta.Author)); DvDevice device = ServiceRegistration.Get<IBackendServer>().UPnPBackendServer.FindDevicesByDeviceTypeAndVersion(UPnPTypesAndIds.BACKEND_SERVER_DEVICE_TYPE, UPnPTypesAndIds.BACKEND_SERVER_DEVICE_TYPE_VERSION, true).FirstOrDefault(); if (device != null) { ServiceRegistration.Set<IFanArtService>(new FanArtService()); Logger.Debug("FanArtService: Registered IFanArtService."); device.AddService(new FanArtServiceImpl()); Logger.Debug("FanArtService: Adding FanArt service to MP2 backend root device"); } else { Logger.Error("FanArtService: MP2 backend root device not found!"); } }
protected static ConfigGroupMetadata BuildGroup( PluginItemMetadata itemData, PluginRuntime plugin) { string location = ConfigBaseMetadata.ConcatLocations(itemData.RegistrationLocation, itemData.Id); string text = null; foreach (KeyValuePair<string, string> attr in itemData.Attributes) { switch (attr.Key) { case "Text": text = attr.Value; break; default: throw new ArgumentException("'ConfigGroup' builder doesn't define an attribute '" + attr.Key + "'"); } } if (text == null) throw new ArgumentException("'ConfigGroup' item needs an attribute 'Text'"); return new ConfigGroupMetadata(location, text); }
public bool NeedsPluginActive(PluginItemMetadata itemData, PluginRuntime plugin) { return true; }
public void RevokeItem(object item, PluginItemMetadata itemData, PluginRuntime plugin) { // Noting to do }
public void Activated(PluginRuntime pluginRuntime) { ConnectionMonitor.Instance.Install(); }
public object BuildItem(PluginItemMetadata itemData, PluginRuntime plugin) { BuilderHelper.CheckParameter("ClassName", itemData); return new FanartImageSourceProviderRegistration(plugin.GetPluginType(itemData.Attributes["ClassName"]), itemData.Id); }
public void RevokeItem(object item, PluginItemMetadata itemData, PluginRuntime plugin) { // Nothing to do here - the WorkflowManager will listen for workflow state withdrawals }
public object BuildItem(PluginItemMetadata itemData, PluginRuntime plugin) { if (itemData.BuilderName == "WorkflowState") return BuildWorkflowState(itemData); if (itemData.BuilderName == "DialogState") return BuildDialogState(itemData); return null; }
protected ConfigBase Instantiate(ConfigBaseMetadata metadata, PluginRuntime pluginRuntime) { ServiceRegistration.Get<ILogger>().Debug("ConfigurationNode: Loading configuration item '{0}'", metadata.Location); ConfigBase result; if (metadata.GetType() == typeof(ConfigGroupMetadata)) result = new ConfigGroup(); else if (metadata.GetType() == typeof(ConfigSectionMetadata)) result = new ConfigSection(); else if (metadata.GetType() == typeof(ConfigSettingMetadata)) { ConfigSettingMetadata csm = (ConfigSettingMetadata) metadata; try { ConfigSetting cs = (ConfigSetting) pluginRuntime.InstantiatePluginObject(csm.ClassName); if (cs == null) throw new ArgumentException(string.Format("Configuration class '{0}' not found", csm.ClassName)); cs.Load(); if (csm.ListenTo != null) foreach (string listenToLocation in csm.ListenTo) { IConfigurationNode node; if (FindNode(listenToLocation, out node)) if (node.ConfigObj is ConfigSetting) cs.ListenTo((ConfigSetting) node.ConfigObj); else ServiceRegistration.Get<ILogger>().Warn("ConfigurationNode '{0}': Trying to listen to setting, but location '{1}' references a {2}", Location, listenToLocation, node.ConfigObj.GetType().Name); } result = cs; } catch (Exception ex) { ServiceRegistration.Get<ILogger>().Error("Error loading configuration class '{0}'", ex, csm.ClassName); return null; } } else throw new NotImplementedException(string.Format("Unknown child class '{0}' of '{1}'", metadata.GetType().FullName, typeof(ConfigBaseMetadata).FullName)); result.SetMetadata(metadata); return result; }
public void Activated(PluginRuntime pluginRuntime) { Update(); }
/// <summary> /// Will be called when the plugin is started. This will happen as a result of a plugin auto-start /// or an item access which makes the plugin active. /// This method is called after the plugin's state was set to <see cref="PluginState.Active"/>. /// </summary> public void Activated(PluginRuntime pluginRuntime) { ISettingsManager settingsManager = ServiceRegistration.Get<ISettingsManager>(); MceRemoteSettings settings = settingsManager.Load<MceRemoteSettings>(); // We initialize the key code map here instead of in the constructor because here, we have access to the plugin's // directory (via the pluginRuntime parameter). _mappedKeyCodes = new Dictionary<int, Key>(); ICollection<MappedKeyCode> keyCodes = settings.RemoteMap ?? LoadRemoteMap(pluginRuntime.Metadata.GetAbsolutePath("DefaultRemoteMap.xml")); foreach (MappedKeyCode mkc in keyCodes) _mappedKeyCodes.Add(mkc.Code, mkc.Key); //_eHomeTransceivers.Add(new eHomeTransceiver() { DeviceID = "testKey", Name = "testValue" }); //SaveTransceivers(pluginRuntime.Metadata.GetAbsolutePath("eHomeTransceiverList.xml"), _eHomeTransceivers); ICollection<eHomeTransceiver> transceivers = settings.Transceivers ?? LoadTransceivers(pluginRuntime.Metadata.GetAbsolutePath("eHomeTransceiverList.xml")); if (transceivers.Count > 0) Remote.Transceivers.AddRange(transceivers); StartReceiver(); }
public void Activated(PluginRuntime pluginRuntime) { ServiceRegistration.Set<INewsCollector>(new NewsCollector()); }