Create a plugin configuration (1 Viewer)

celesta

Portal Member
February 7, 2011
46
2
Hello,

I have some problem with plugin configuration.

My first goal is to display in configuration a string entry.

I add this to my plugin.xml:
Code:
<!-- Add dependancy to the configurations plugins -->  
  <DependsOn>
    <PluginReference PluginId="{1AFF4467-64B0-4ca1-AF28-9AEDF3525BCE}"/> <!-- ConfigurationManager -->
    <PluginReference PluginId="{B765A4B6-F455-4941-BDAE-2CE45208BFEB}"/> <!-- Configuration plugin -->
  </DependsOn>
  
  <!-- Plugin configuration menu -->
  <Register Location="/Configuration/Settings">
    <ConfigSection
        Id="Plugins"
        Redundant="true"
        Text="blabla"/>
  </Register>
  
  <!-- Contents of Plugin configuration menu -->
  <Register Location="/Configuration/Settings/Plugins">
    <ConfigSection
        Id="SMCV_Settings_Menu"
        Redundant="true"
        Text="blabla2"/>
  </Register>
  
  <!-- Contents of '/Plugins/Weather' section -->
  <Register Location="/Configuration/Settings/Plugins/SMCV_Settings_Menu">
    <CustomConfigSetting
        Id="SMCV_Settings_Content"
        Text="blabla3"
        HelpText="blabla4"
        ClassName="MediaPortal.plugin.smc_video.Configuration"
        />
  </Register>

And create a class:
Code:
Public Class Configuration

        Private _Parameters_Share As String

        Public Property Parameters_Share As String
            Get
                Return _Parameters_Share
            End Get
            Set(ByVal value As String)
                _Parameters_Share = value
            End Set
        End Property

    End Class

But now I don't know what to do and the log say:


Code:
System.ArgumentException: Configuration class 'MediaPortal.plugin.smc_video.Configuration' not found
   à MediaPortal.Configuration.ConfigurationManagement.ConfigurationNode.Instantiate(ConfigBaseMetadata metadata, PluginRuntime pluginRuntime)
 

morpheus_xx

Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    AW: Create a plugin configuration

    First, there is a difference between the "Setting" and the "Configuration":

    "Setting" stores your configured values (i.e. a string "Share").
    "Configuration" classes used to provide support for changing settings from GUI.

    For a very simple example look at the Setting for my slimtv4homeprovider:
    Code:
      class TV4HomeProviderSettings
      {
        /// <summary>
        /// Holds the host name or IP adress of the TV4home service (running on same machine as TvServer).
        /// </summary>
        [Setting(SettingScope.User, "localhost")]
        public string TvServerHost { get; set; }
      }

    and the related configuration class: TV4HomeServerAddress.cs (note the inheritance from "Entry", a simple string input)

    Code:
    using MediaPortal.Common.Configuration.ConfigurationClasses;
    using MediaPortal.Plugins.SlimTvClient.Providers.Settings;
    
    namespace MediaPortal.Plugins.SlimTv.Providers.Settings.Configuration
    {
      public class TV4HomeServerAddress[B] : Entry[/B]
      {
        public override void Load()
        {
          _value = SettingsManager.Load<TV4HomeProviderSettings>().TvServerHost;
        }
    
        public override void Save()
        {
          base.Save();
          TV4HomeProviderSettings settings = SettingsManager.Load<TV4HomeProviderSettings>();
          settings.TvServerHost = _value;
          SettingsManager.Save(settings);
        }
    
        public override int DisplayLength
        {
          get { return 50; }
        }
      }
    }

    You can use some different configuration "editor" classes from the MediaPortal.Common.Configuration.ConfigurationClasses namespace.

    The plugin.xml then have to contain the class name of a Configuration class.

    I hope this brings you a step further :)

    Morpheus
     

    celesta

    Portal Member
    February 7, 2011
    46
    2
    After long research, I think that my problem is that the class doesn't exist in mediaportal.

    In configurationnode.cs, after the line:
    ConfigSetting cs = (ConfigSetting) pluginRuntime.InstantiatePluginObject(csm.ClassName);

    cs is null.

    In my plugin project I have set:
    Assembly = <myplugin>
    root namespace = "" (empty)

    if I set root namespace = mediaportal.plugin.<myplugin>, the configuration is mediaportal.plugin.<myplugin>.mediaportal.plugin.<myplugin>

    Must I add reference to mediaportal.plugin.<myplugin> ? and mediaportal.plugin.<myplugin>.configuration ?

    I continue to search...
     

    Users who are viewing this thread

    Top Bottom