* Shop + Plugin is now functionnal, sample Plugin provided to connect to the default...
[circ.git] / Circ.Lib / Plugin / Plugin.cs
blobaf6a5cf6d2c3258a5bf904037209c208b8e0f5a0
1 #region License
2 /* Circ.Lib : main library behind Circ
3 * Copyright (C) 2007 LAVAL Jérémie
5 * This file is licensed under the terms of the LGPL.
7 * For the complete licence see the file COPYING.
8 */
9 #endregion
10 using System;
11 using Circ.Backend;
12 using Circ.Controller;
13 using Circ.Lib;
15 namespace Circ.Plugins
17 [Mono.Addins.TypeExtensionPoint("/Circ/Plugins")]
18 public abstract class Plugin
20 #region Things that people should implement
21 /// <summary>
22 /// Ask the names of the authors of the plugin
23 /// </summary>
24 /// <return>The names of the authors</return>
25 public abstract string[] Authors { get; }
27 /// <summary>
28 /// Ask the name of the plugin
29 /// </summary>
30 /// <return>The name of the plugin</return>
31 public abstract string Name { get; }
33 /// <summary>
34 /// Ask the description of the plugin
35 /// </summary>
36 /// <return>The description of the plugin</return>
37 public abstract string Description { get; }
39 /// <summary>
40 /// Ask the version in textual form of the plugin
41 /// </summary>
42 /// <return>the version of the plugin</return>
43 public abstract string Version { get; }
45 /// <summary>
46 /// This method is used by the plugin to allocate the ressource it might need
47 /// </summary>
48 /// <return>Return true if the operation was successful, false if a problem happened</return>
49 /// <remarks>If the method return false, the Dispose method is called and the plugin isn't added to the factory</remarks>
50 public abstract bool InitializePlugin();
52 /// <summary>
53 /// This method is used by the plugin to dispose its ressources
54 /// </summary>
55 public abstract void Dispose();
58 /// <summary>
59 /// If your plugin provides services via commands (like the classical ones i.e. /nick, /away etc...)
60 /// return them here
61 /// </summary>
62 /// <remarks>Return just the name of the command (ex : foo and not /foo)</remarks>
63 public abstract string[] CommandsProvided { get; }
65 /// <summary>
66 /// Give the command and its parameters to the plugin to allo it to do its job
67 /// </summary>
68 /// <param name="cmd">the command and its parameter</param>
69 /// <remarks>The trailing slash (/) is stripped from the command (ex: "foo bar" and not "/foo bar"</remarks>
70 public abstract void ParseCommand(string cmd);
71 #endregion
73 #region Common ways to interact with the connections
75 protected void ConnectNewServer(ConnectionInfo ci)
77 MainControlFactory.MainControl.ConnectNewServer(ci);
80 protected void JoinNewChan(string serverName, string chanName)
82 MainControlFactory.MainControl.GetConnectionControls(serverName).JoinChannel(chanName);
85 protected void SendMessageToChannel(string serverName, string channelName, string message)
87 MainControlFactory.MainControl.GetConnectionControls(serverName)
88 .GetChannelControl(channelName).SendMessage(message);
91 protected string[] ChannelOpened {
92 get {
93 return MainControlFactory.MainControl.
97 protected event EventHandler NewChannelJoined;
98 protected event EventHandler NewServerJoined;
100 // In fact plugins worker can use GuiFactory and MainControlFactory now
101 #endregion