X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=WebThingPlugin.cs;h=a201b86744060eb9f33a5040ca576c819d189d50;hb=2744fefc32dbe9b59a570f6515d51121b8fcfbe3;hp=56caa4cc43727f4ebf81e211d5fb877e887bae74;hpb=fc785e55243b0a680c19ea6ccd77b759fe216766;p=WebThing.git diff --git a/WebThingPlugin.cs b/WebThingPlugin.cs index 56caa4c..a201b86 100644 --- a/WebThingPlugin.cs +++ b/WebThingPlugin.cs @@ -9,13 +9,36 @@ namespace bytex64.WebThing { public WebThingPlugin() { string classname = this.GetType().FullName; - if (Config.PluginOptions.ContainsKey(classname)) + if (Config.PluginOptions.ContainsKey(classname)) { Options = Config.PluginOptions[classname]; - else + } 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) {} + } + + // An interface implemented by plugins that handle search queries + // (a search query is anything that doesn't look like a URI) + public interface ISearchPlugin { + // Convert a search query into a URI. If this plugin cannot + // handle the search, it should return null. + string SearchTransform(string search); } }