X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=WebThingPlugin.cs;h=6f23e9d54a6281da95b4142cb1da72276b8eca5d;hb=fc831a2ef0ae342cc73dee301e051bcfbbbeb82c;hp=91c68ca8c9e63a058778d55b2e44f7ce6ce7213f;hpb=0b2e5f8fffd9ed781a1ddab279dbd6fec5c7695a;p=WebThing.git diff --git a/WebThingPlugin.cs b/WebThingPlugin.cs index 91c68ca..6f23e9d 100644 --- a/WebThingPlugin.cs +++ b/WebThingPlugin.cs @@ -1,8 +1,36 @@ +using System; +using System.Collections.Generic; using WebKit; namespace bytex64.WebThing { public abstract class WebThingPlugin { - public abstract void Init(WebThing wt); + protected Dictionary Options; + + public WebThingPlugin() { + string classname = this.GetType().FullName; + + if (Config.PluginOptions.ContainsKey(classname)) { + Options = Config.PluginOptions[classname]; + } else { + Options = new Dictionary(); + Config.PluginOptions[classname] = Options; + } + } + + // Convenience function to easily save plugin configuration + protected void SaveConfig() { + if (Config.ConfigPathOut == null) return; + + string plugin_name = this.GetType().FullName; + Config.SaveFile(plugin_name, String.Format("{0}/{1}.conf", Config.ConfigPathOut, plugin_name)); + } + + // Plugin life cycle + public virtual void Init(WebThing wt) {} + public virtual void Deinit(WebThing wt) {} + + // WebView life cycle public virtual void InitWebView(WebView wv) {} + public virtual void DeinitWebView(WebView wv) {} } }