Fix scrolling functionality
[WebThing.git] / WebThingPlugin.cs
1 using System;
2 using System.Collections.Generic;
3 using WebKit;
4
5 namespace bytex64.WebThing {
6     public abstract class WebThingPlugin {
7         protected Dictionary<string,string> Options;
8
9         public WebThingPlugin() {
10             string classname = this.GetType().FullName;
11
12             if (Config.PluginOptions.ContainsKey(classname)) {
13                 Options = Config.PluginOptions[classname];
14             } else {
15                 Options = new Dictionary<string,string>();
16                 Config.PluginOptions[classname] = Options;
17             }
18         }
19
20         // Convenience function to easily save plugin configuration
21         protected void SaveConfig() {
22             if (Config.ConfigPathOut == null) return;
23
24             string plugin_name = this.GetType().FullName;
25             Config.SaveFile(plugin_name, String.Format("{0}/{1}.conf", Config.ConfigPathOut, plugin_name));
26         }
27
28         // Plugin life cycle
29         public virtual void Init(WebThing wt) {}
30         public virtual void Deinit(WebThing wt) {}
31
32         // WebView life cycle
33         public virtual void InitWebView(WebView wv) {}
34         public virtual void DeinitWebView(WebView wv) {}
35     }
36
37     // An interface implemented by plugins that handle search queries
38     // (a search query is anything that doesn't look like a URI)
39     public interface ISearchPlugin {
40         // Convert a search query into a URI.  If this plugin cannot
41         // handle the search, it should return null.
42         string SearchTransform(string search);
43     }
44 }