Create a plugin configuration

Discussion in 'Plugin Development' started by celesta, October 10, 2011.

  1. celesta

    celesta Portal Member

    Joined:
    February 7, 2011
    Messages:
    46
    Likes Received:
    2
    Ratings:
    +2 / 0
    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 (Text):
    1. <!-- Add dependancy to the configurations plugins -->  
    2.   <DependsOn>
    3.     <PluginReference PluginId="{1AFF4467-64B0-4ca1-AF28-9AEDF3525BCE}"/> <!-- ConfigurationManager -->
    4.     <PluginReference PluginId="{B765A4B6-F455-4941-BDAE-2CE45208BFEB}"/> <!-- Configuration plugin -->
    5.   </DependsOn>
    6.  
    7.   <!-- Plugin configuration menu -->
    8.   <Register Location="/Configuration/Settings">
    9.     <ConfigSection
    10.         Id="Plugins"
    11.         Redundant="true"
    12.         Text="blabla"/>
    13.   </Register>
    14.  
    15.   <!-- Contents of Plugin configuration menu -->
    16.   <Register Location="/Configuration/Settings/Plugins">
    17.     <ConfigSection
    18.         Id="SMCV_Settings_Menu"
    19.         Redundant="true"
    20.         Text="blabla2"/>
    21.   </Register>
    22.  
    23.   <!-- Contents of '/Plugins/Weather' section -->
    24.   <Register Location="/Configuration/Settings/Plugins/SMCV_Settings_Menu">
    25.     <CustomConfigSetting
    26.         Id="SMCV_Settings_Content"
    27.         Text="blabla3"
    28.         HelpText="blabla4"
    29.         ClassName="MediaPortal.plugin.smc_video.Configuration"
    30.         />
    31.   </Register>  
    And create a class:
    Code (Text):
    1. Public Class Configuration
    2.  
    3.         Private _Parameters_Share As String
    4.  
    5.         Public Property Parameters_Share As String
    6.             Get
    7.                 Return _Parameters_Share
    8.             End Get
    9.             Set(ByVal value As String)
    10.                 _Parameters_Share = value
    11.             End Set
    12.         End Property
    13.  
    14.     End Class
    But now I don't know what to do and the log say:


    Code (Text):
    1. System.ArgumentException: Configuration class 'MediaPortal.plugin.smc_video.Configuration' not found
    2.    à MediaPortal.Configuration.ConfigurationManagement.ConfigurationNode.Instantiate(ConfigBaseMetadata metadata, PluginRuntime pluginRuntime)
     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. morpheus_xx
    • Team MediaPortal

    morpheus_xx Lead Dev MP2

    Joined:
    March 24, 2007
    Messages:
    11,017
    Likes Received:
    4,750
    Ratings:
    +6,796 / 11
    Home Country:
    Germany Germany
    Show System Specs
    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 (Text):
    1.   class TV4HomeProviderSettings
    2.   {
    3.     /// <summary>
    4.     /// Holds the host name or IP adress of the TV4home service (running on same machine as TvServer).
    5.     /// </summary>
    6.     [Setting(SettingScope.User, "localhost")]
    7.     public string TvServerHost { get; set; }
    8.   }
    and the related configuration class: TV4HomeServerAddress.cs (note the inheritance from "Entry", a simple string input)

    Code (Text):
    1. using MediaPortal.Common.Configuration.ConfigurationClasses;
    2. using MediaPortal.Plugins.SlimTvClient.Providers.Settings;
    3.  
    4. namespace MediaPortal.Plugins.SlimTv.Providers.Settings.Configuration
    5. {
    6.   public class TV4HomeServerAddress[B] : Entry[/B]
    7.   {
    8.     public override void Load()
    9.     {
    10.       _value = SettingsManager.Load<TV4HomeProviderSettings>().TvServerHost;
    11.     }
    12.  
    13.     public override void Save()
    14.     {
    15.       base.Save();
    16.       TV4HomeProviderSettings settings = SettingsManager.Load<TV4HomeProviderSettings>();
    17.       settings.TvServerHost = _value;
    18.       SettingsManager.Save(settings);
    19.     }
    20.  
    21.     public override int DisplayLength
    22.     {
    23.       get { return 50; }
    24.     }
    25.   }
    26. }
    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
     
  4. celesta

    celesta Portal Member

    Joined:
    February 7, 2011
    Messages:
    46
    Likes Received:
    2
    Ratings:
    +2 / 0
    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...
     
Loading...

Users Viewing Thread (Users: 0, Guests: 0)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!