Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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));

            LoadSettings();
            StartUp();
        }
Ejemplo n.º 3
0
 public void Activated(PluginRuntime pluginRuntime)
 {
     if (pluginRuntime != null)
     {
         var meta = pluginRuntime.Metadata;
         Logger.Info(string.Format("{0} v{1} [{2}] by {3}", meta.Name, meta.PluginVersion, meta.Description, meta.Author));
     }
     StartClient();
 }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        public void RevokeItem(object item, PluginItemMetadata itemData, PluginRuntime plugin)
        {
            if (item == null)
            {
                return;
            }
            ServiceItem si = (ServiceItem)item;

            plugin.RevokePluginObject(si.ServiceInstance.GetType().FullName);
        }
Ejemplo n.º 6
0
        public void Activated(PluginRuntime pluginRuntime)
        {
            ServiceRegistration.Set <ITvHandler>(new SlimTvHandler());
            ServiceRegistration.Set <ISlimTvNotificationService>(new SlimTvNotificationService());
            // Register recording section in MediaLibrary
            RecordingsLibrary.RegisterOnMediaLibrary();

            // Dummy call to static instance which creates required message handlers
            var channels = ChannelContext.Instance.Channels;
        }
Ejemplo n.º 7
0
        public void Activated(PluginRuntime pluginRuntime)
        {
            // List all assemblies
            InitPluginAssemblyList();
            // Set our own resolver to lookup types from any of assemblies from Plugins subfolder.
            ServerStateSerializer.CustomAssemblyResolver = PluginsAssemblyResolver;
            ServiceRegistration.Get <ILogger>().Debug("ServerStatePlugin: Adding Plugins folder to private path");

            Install();
        }
Ejemplo n.º 8
0
        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());
        }
Ejemplo n.º 9
0
        protected static ConfigSettingMetadata BuildCustomSetting(
            PluginItemMetadata itemData, PluginRuntime plugin)
        {
            string location  = ConfigBaseMetadata.ConcatLocations(itemData.RegistrationLocation, itemData.Id);
            string text      = null;
            string className = null;
            string helpText  = null;
            IDictionary <string, string> additionalData  = null;
            IDictionary <string, Type>   additionalTypes = null;
            ICollection <string>         listenTo        = null;

            foreach (KeyValuePair <string, string> attr in itemData.Attributes)
            {
                switch (attr.Key)
                {
                case "Text":
                    text = attr.Value;
                    break;

                case "ClassName":
                    className = attr.Value;
                    break;

                case "HelpText":
                    helpText = attr.Value;
                    break;

                case "ListenTo":
                    listenTo = ParseListenTo(attr.Value);
                    break;

                case "AdditionalData":
                    additionalData = ParseAdditionalData(attr.Value);
                    break;

                case "AdditionalTypes":
                    additionalTypes = ParseAdditionalTypes(attr.Value, plugin);
                    break;

                default:
                    throw new ArgumentException("'ConfigSetting' builder doesn't define an attribute '" + attr.Key + "'");
                }
            }
            if (text == null)
            {
                throw new ArgumentException("'ConfigSetting' item needs an attribute 'Text'");
            }
            ConfigSettingMetadata result = new ConfigSettingMetadata(location, text, className, helpText, listenTo)
            {
                AdditionalData  = additionalData,
                AdditionalTypes = additionalTypes
            };

            return(result);
        }
Ejemplo n.º 10
0
 public object BuildItem(PluginItemMetadata itemData, PluginRuntime plugin)
 {
     if (itemData.BuilderName == "WorkflowState")
     {
         return(BuildWorkflowState(itemData));
     }
     if (itemData.BuilderName == "DialogState")
     {
         return(BuildDialogState(itemData));
     }
     return(null);
 }
Ejemplo n.º 11
0
        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;
            }
        }
Ejemplo n.º 12
0
        // At the moment, we simply use an InstanceBuilder here. In the future, we could provide the option to
        // give a set of supported file extensions in the player builder item registration, which can be evaluated before
        // requesting the player builder -> lazy load the player builders on request
        public object BuildItem(PluginItemMetadata itemData, PluginRuntime plugin)
        {
            BuilderHelper.CheckParameter("ClassName", itemData);
            int    priority = 0;
            string prioString;

            if (itemData.Attributes.TryGetValue("Priority", out prioString))
            {
                int.TryParse(prioString, out priority);
            }

            return(new PlayerBuilderWrapper(itemData.Id, plugin.InstantiatePluginObject(itemData.Attributes["ClassName"]) as IPlayerBuilder, priority));
        }
Ejemplo n.º 13
0
        virtual public object BuildItem(PluginItemMetadata itemData, PluginRuntime plugin)
        {
            BuilderHelper.CheckParameter("ClassName", itemData);
            BuilderHelper.CheckParameter("Caption", itemData);
            BuilderHelper.CheckParameter("Sort", itemData);
            string restrictionGroup; // optional

            if (itemData.Attributes.TryGetValue("RestrictionGroup", out restrictionGroup))
            {
                ServiceRegistration.Get <IUserManagement>().RegisterRestrictionGroup(restrictionGroup);
            }
            return(_constructor(plugin.GetPluginType(itemData.Attributes["ClassName"]), itemData.Attributes["Caption"], itemData.Attributes["Sort"], restrictionGroup, itemData.Id));
        }
        public async 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));

            if (Directory.Exists(Settings.CachePath) == false)
            {
                Directory.CreateDirectory(Settings.CachePath);
            }

            await ServiceRegistration.Get <IMediaConverter>().CleanUpTranscodeCacheAsync();
        }
Ejemplo n.º 15
0
        protected static ConfigSettingMetadata BuildSetting(
            PluginItemMetadata itemData, PluginRuntime plugin)
        {
            string location  = ConfigBaseMetadata.ConcatLocations(itemData.RegistrationLocation, itemData.Id);
            string text      = null;
            string sort      = null;
            string className = null;
            string helpText  = null;
            ICollection <string> listenTo = null;
            string restrictionGroup       = null;

            foreach (KeyValuePair <string, string> attr in itemData.Attributes)
            {
                switch (attr.Key)
                {
                case "Text":
                    text = attr.Value;
                    break;

                case "Sort":
                    sort = attr.Value;
                    break;

                case "ClassName":
                    className = attr.Value;
                    break;

                case "HelpText":
                    helpText = attr.Value;
                    break;

                case "ListenTo":
                    listenTo = ParseListenTo(attr.Value);
                    break;

                case "RestrictionGroup":
                    SetValueAndRegister(ref restrictionGroup, attr.Value);
                    break;

                default:
                    throw new ArgumentException("'ConfigSetting' builder doesn't define an attribute '" + attr.Key + "'");
                }
            }
            if (text == null)
            {
                throw new ArgumentException("'ConfigSetting' item needs an attribute 'Text'");
            }
            return(new ConfigSettingMetadata(location, text, sort, className, helpText, listenTo, restrictionGroup));
        }
Ejemplo n.º 16
0
        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);
            }
        }
Ejemplo n.º 17
0
        public bool NeedsPluginActive(PluginItemMetadata itemData, PluginRuntime plugin)
        {
            BackgroundType type;
            string         value = GetBackgroundAndType(itemData.Attributes, out type);

            if (type == BackgroundType.Static)
            {
                return(false);
            }
            if (type == BackgroundType.Manager)
            {
                return(true);
            }
            throw new NotImplementedException(string.Format(
                                                  "Background builder: Background type '{0}' is not implemented", type));
        }
Ejemplo n.º 18
0
        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);
        }
Ejemplo n.º 19
0
        public void Activated(PluginRuntime pluginRuntime)
        {
            var settingsManager = ServiceRegistration.Get <ISettingsManager>();
            var settings        = settingsManager.Load <WhatsNewSettings>();

            if (settings.NewsConfirmed)
            {
                return;
            }

            _messageQueue = new AsynchronousMessageQueue(this.GetType(), new string[]
            {
                WorkflowManagerMessaging.CHANNEL
            });
            _messageQueue.MessageReceived += OnMessageReceived;
            _messageQueue.Start();
        }
Ejemplo n.º 20
0
        public void Activated(PluginRuntime pluginRuntime)
        {
            string absolutePlatformDir;

            if (!NativeMethods.SetPlatformSearchDirectories(out absolutePlatformDir))
            {
                throw new Exception("Error adding dll probe path");
            }

            GamesLibrary.RegisterOnMediaLibrary();

            // Init OpenGl here as it creates a hidden window which we later
            // use to create an opengl context for cores that support hardware
            // rendering. The window should be created on the main thread, which
            // we should be on here, otherwise the window's device context
            // becomes invalid when the thread that created it dies.
            OpenGL.Gl.Initialize();
        }
        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));
        }
Ejemplo n.º 22
0
        public void Activated(PluginRuntime pluginRuntime)
        {
            ISystemStateService sss = ServiceRegistration.Get <ISystemStateService>();

            if (sss.CurrentState == SystemState.Running)
            {
                RegisterKeyBindings();
            }
            else
            {
                _messageQueue = new AsynchronousMessageQueue(typeof(StatisticsRenderer), new string[]
                {
                    SystemMessaging.CHANNEL
                });
                _messageQueue.MessageReceived += OnMessageReceived;
                _messageQueue.Start();
            }
        }
Ejemplo n.º 23
0
        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));
            }
        }
Ejemplo n.º 24
0
        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));
        }
Ejemplo n.º 25
0
        public object BuildItem(PluginItemMetadata itemData, PluginRuntime plugin)
        {
            switch (itemData.BuilderName)
            {
            case "ConfigSection":
                return(BuildSection(itemData, plugin));

            case "ConfigGroup":
                return(BuildGroup(itemData, plugin));

            case "ConfigSetting":
                return(BuildSetting(itemData, plugin));

            case "CustomConfigSetting":
                return(BuildCustomSetting(itemData, plugin));
            }
            throw new ArgumentException(string.Format("{0} builder cannot build setting of type '{1}'",
                                                      typeof(ConfigBuilder).Name, itemData.BuilderName));
        }
Ejemplo n.º 26
0
        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();
            }
        }
Ejemplo n.º 27
0
        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!");
            }
        }
Ejemplo n.º 28
0
        public void Activated(PluginRuntime pluginRuntime)
        {
            var stateService = new ServerStateServiceImpl();

            ServiceRegistration.Set <IServerStateService>(stateService);

            DvDevice device = ServiceRegistration.Get <IBackendServer>().UPnPBackendServer
                              .FindDevicesByDeviceTypeAndVersion(UPnPTypesAndIds.BACKEND_SERVER_DEVICE_TYPE, UPnPTypesAndIds.BACKEND_SERVER_DEVICE_TYPE_VERSION, true).FirstOrDefault();

            if (device != null)
            {
                Logger.Debug("ServerStateService: Registering ServerStateService service.");
                device.AddService(stateService);
                Logger.Debug("ServerStateService: Adding ServerStateService service to MP2 backend root device");
            }
            else
            {
                Logger.Error("ServerStateService: MP2 backend root device not found!");
            }
        }
Ejemplo n.º 29
0
        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();
                    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);
        }
Ejemplo n.º 30
0
        public App()
        {
            var pluginRuntime = new PluginRuntime();

            pluginRuntime.Start(new[]
            {
                typeof(ModernUserInterfacePlugin),

                typeof(CodeFlowPlugin),
                typeof(ConnectPlugin),
                typeof(KudosPlugin),
                typeof(ManicTimePlugin),
                typeof(OutlookPlugin),
                typeof(TeamFoundationServerPlugin),
                typeof(YammerPlugin),

                typeof(ExcelRenderPlugin),
                typeof(HtmlRenderPlugin),
            });

            SimpleIoc.Default.Register <IPluginRuntime>(() => pluginRuntime);
            SimpleIoc.Default.Register <IThemeSwitchService, MahAppsModernThemeSwitchService>();
        }
Ejemplo n.º 31
0
 public void Activated(PluginRuntime pluginRuntime)
 {
   CreatePictureDatabase();
 }