Statistics
| Revision:

root / PLUGIN.txt @ 3019

History | View | Annotate | Download (11.6 kB)

1 2174 hiro
Sylpheed Plugin Specification
2 2174 hiro
=============================
3 2174 hiro
4 2181 hiro
The following is the architecture of plugin system of Sylpheed.
5 2181 hiro
6 2181 hiro
 +----------+    +----------------------+     +-----------+
7 2181 hiro
 | Sylpheed |----| libsylpheed-plugin-0 |--+--| Plug-in A |
8 2181 hiro
 +----------+    +----------------------+  |  +-----------+
9 2181 hiro
   Sylpheed         Plug-in interface      |   Plug-in DLL
10 2181 hiro
                    library             +--+
11 2181 hiro
        |        +------------+         |  |  +-----------+
12 2181 hiro
        +--------| libsylph-0 |---------+  +--| Plug-in B |
13 2181 hiro
                 +------------+               +-----------+
14 2181 hiro
                 LibSylph mail library
15 2181 hiro
16 2181 hiro
Sylpheed loads the plug-in DLLs installed in the plug-in directory on
17 2181 hiro
startup.
18 2181 hiro
19 2181 hiro
Plug-in can only access the functions of Sylpheed through the APIs provided
20 2181 hiro
with libsylpheed-plugin-0 and libsylph-0 library.
21 2184 hiro
22 2184 hiro
There are two kinds of plug-in API. One is called directly from plug-ins,
23 2184 hiro
another one utilizes the signal mechanism of GObject and calls the callback
24 2184 hiro
functions on specific events.
25 2184 hiro
26 2184 hiro
The plug-in system is implemented in libsylph/sylmain.[ch] and
27 2184 hiro
src/plugin.[ch].
28 2184 hiro
29 2187 hiro
30 2184 hiro
Plug-in API
31 2184 hiro
===========
32 2184 hiro
33 2187 hiro
Functions used by Sylpheed
34 2187 hiro
--------------------------
35 2184 hiro
36 2184 hiro
-------------------------------------------------------------------------
37 2184 hiro
void syl_plugin_signal_connect  (const gchar *name, GCallback callback,
38 2184 hiro
                                 gpointer data);
39 2184 hiro
40 2187 hiro
Connects to signals available with SylPlugin object (obtained inside library).
41 2187 hiro
The specification of callback functions that receive signals is similar to
42 2187 hiro
that of normal GObject.
43 2187 hiro
Refer to the signals list for available signals.
44 2184 hiro
-------------------------------------------------------------------------
45 2184 hiro
void syl_plugin_signal_disconnect(gpointer func, gpointer data);
46 2184 hiro
47 2187 hiro
Disconnects signals connected by syl_plugin_signal_connect().
48 2184 hiro
-------------------------------------------------------------------------
49 2184 hiro
void syl_plugin_signal_emit(const gchar *name, ...);
50 2184 hiro
51 2187 hiro
Emits SylPlugin object signals.
52 2184 hiro
-------------------------------------------------------------------------
53 2184 hiro
gint syl_plugin_init_lib        (void);
54 2184 hiro
55 2187 hiro
Initializes the libsylpheed-plugin-0 library.
56 2184 hiro
-------------------------------------------------------------------------
57 2184 hiro
gint syl_plugin_load            (const gchar *file);
58 2184 hiro
59 2187 hiro
Loads plug-in DLL files into memory.
60 2184 hiro
-------------------------------------------------------------------------
61 2184 hiro
gint syl_plugin_load_all        (const gchar *dir);
62 2184 hiro
63 2187 hiro
Loads plug-in DLL files in the specified directory into memory.
64 2184 hiro
-------------------------------------------------------------------------
65 2184 hiro
void syl_plugin_unload_all      (void);
66 2184 hiro
67 2187 hiro
Unloads all loaded plug-ins.
68 2184 hiro
-------------------------------------------------------------------------
69 2184 hiro
GSList *syl_plugin_get_module_list      (void);
70 2184 hiro
71 2187 hiro
Obtains the list of plug-ins loaded into memory.
72 2187 hiro
It returns the list of pointers to GModule struct.
73 2187 hiro
The list is obtained by the library internally, so it must not be freed.
74 2184 hiro
-------------------------------------------------------------------------
75 2184 hiro
SylPluginInfo *syl_plugin_get_info      (GModule *module);
76 2184 hiro
77 2187 hiro
Obtains plug-in information. The information is returned as SylPluginInfo
78 2187 hiro
struct.
79 2184 hiro
-------------------------------------------------------------------------
80 2184 hiro
gboolean syl_plugin_check_version       (GModule *module);
81 2184 hiro
82 2187 hiro
Compares plug-in interface versions and checks if the plug-in is compatible.
83 2187 hiro
Returns TRUE if the version matches, FALSE otherwise.
84 2184 hiro
-------------------------------------------------------------------------
85 2184 hiro
gint syl_plugin_add_symbol              (const gchar *name, gpointer sym);
86 2184 hiro
87 2187 hiro
Registers symbol name and pointer value related to it to the library.
88 2184 hiro
-------------------------------------------------------------------------
89 2184 hiro
gpointer syl_plugin_lookup_symbol       (const gchar *name);
90 2184 hiro
91 2187 hiro
Searches symbol registered by syl_plugin_add_symbol() and returns its
92 2187 hiro
pointer value.
93 2184 hiro
-------------------------------------------------------------------------
94 2184 hiro
95 2184 hiro
96 2184 hiro
Functions which must be implemented by plug-ins
97 2184 hiro
-----------------------------------------------
98 2184 hiro
99 2184 hiro
-------------------------------------------------------------------------
100 2184 hiro
void plugin_load(void)
101 2184 hiro
102 2187 hiro
Called from Sylpheed on plug-in load.
103 2187 hiro
Do initialization of plug-in etc. here.
104 2184 hiro
-------------------------------------------------------------------------
105 2184 hiro
void plugin_unload(void)
106 2184 hiro
107 2187 hiro
Called from Sylpheed on plug-in unload.
108 2187 hiro
Do finalization of plug-in etc. here.
109 2184 hiro
-------------------------------------------------------------------------
110 2184 hiro
SylPluginInfo *plugin_info(void)
111 2184 hiro
112 2187 hiro
Fuction to return struct which stores plug-in information to Sylpheed.
113 2187 hiro
It normally returns pointer to static struct.
114 2184 hiro
-------------------------------------------------------------------------
115 2184 hiro
gint plugin_interface_version(void)
116 2184 hiro
117 2187 hiro
Function to return plug-in API interface version to Sylpheed.
118 2187 hiro
A plug-in normally returns constant value SYL_PLUGIN_INTERFACE_VERSION.
119 2187 hiro
Sylpheed compares this value with its own value and checks if it is
120 2187 hiro
compatible. Sylpheed's plug-in interface version must be equal to or greater
121 2187 hiro
than the plug-in's plug-in interface verson. If the major versions of the
122 2187 hiro
interface version differ, they are treated as incompatible.
123 2187 hiro
124 2187 hiro
Ex.1: Sylpheed plug-in interface version: 0x0102
125 2187 hiro
      A plug-in plug-in interface version: 0x0100: OK
126 2187 hiro
Ex.2: Sylpheed plug-in interface version: 0x0102
127 2187 hiro
      A plug-in plug-in interface version: 0x0103: NG
128 2184 hiro
-------------------------------------------------------------------------
129 2184 hiro
130 2184 hiro
131 2184 hiro
Functions used by plug-ins
132 2184 hiro
--------------------------
133 2184 hiro
134 2552 hiro
Refer to the header file plugin.h for the functions list.
135 2184 hiro
136 2184 hiro
137 2184 hiro
Signals list
138 2184 hiro
------------
139 2184 hiro
140 2184 hiro
* libsylpheed-plugin-0
141 2184 hiro
142 2184 hiro
Call syl_plugin_signal_connect() to use the following signals.
143 2184 hiro
144 2184 hiro
Example:
145 2184 hiro
  syl_plugin_signal_connect("plugin-load", G_CALLBACK(plugin_load_cb), data);
146 2184 hiro
147 2184 hiro
-------------------------------------------------------------------------
148 2184 hiro
void (* plugin_load)    (GObject *obj, GModule *module);
149 2184 hiro
150 2187 hiro
Emitted on plug-in loading by syl_plugin_load().
151 2184 hiro
-------------------------------------------------------------------------
152 2184 hiro
void (* plugin_unload)  (GObject *obj, GModule *module);
153 2184 hiro
154 2187 hiro
Emitted on plug-in unloading by syl_plugin_unload_all().
155 2184 hiro
-------------------------------------------------------------------------
156 2184 hiro
void (* folderview_menu_popup)  (GObject *obj, gpointer ifactory);
157 2184 hiro
158 2187 hiro
Emitted on popup of the context menu of FolderView.
159 2184 hiro
-------------------------------------------------------------------------
160 2666 hiro
void (* summaryview_menu_popup)  (GObject *obj, gpointer ifactory);
161 2666 hiro
162 2666 hiro
Emitted on popup of the context menu of SummaryView.
163 2666 hiro
-------------------------------------------------------------------------
164 2527 hiro
void (* compose_created)        (GObject *obj, gpointer compose);
165 2184 hiro
166 2527 hiro
Emitted on creating 'Compose' message composition window.
167 2527 hiro
-------------------------------------------------------------------------
168 2527 hiro
void (* compose_destroy)        (GObject *obj, gpointer compose);
169 2527 hiro
170 2527 hiro
Emitted just before 'Compose' message composition window is destroyed.
171 2527 hiro
-------------------------------------------------------------------------
172 2811 hiro
void (* textview_menu_popup)    (GObject *obj,
173 2811 hiro
                                 GtkMenu *menu,
174 2811 hiro
                                 GtkTextView *textview,
175 2811 hiro
                                 const gchar *uri,
176 2821 hiro
                                 const gchar *selected_text,
177 2821 hiro
                                 MsgInfo *msginfo);
178 2527 hiro
179 2811 hiro
Emitted on popup of the context menu of TextView.
180 2811 hiro
You can add any menu items to the passed GtkMenu.
181 2821 hiro
The menu object will be created on open and destroyed on close, so menu items
182 2821 hiro
must be added each time.
183 2811 hiro
184 2811 hiro
menu: context menu object
185 2811 hiro
textview: GtkTextView object
186 2811 hiro
uri: URI string if the menu popups on an URI
187 2811 hiro
selected_text: string if a string is selected on the text view
188 2821 hiro
msginfo: the MsgInfo message object displayed in the text view
189 2811 hiro
-------------------------------------------------------------------------
190 2811 hiro
191 2184 hiro
* libsylph-0
192 2184 hiro
193 2185 hiro
The following signals can be used by passing GObject obtained by
194 2185 hiro
syl_app_get() to the first argument of g_signal_connect().
195 2185 hiro
196 2185 hiro
Example:
197 2185 hiro
198 2185 hiro
void init_done_cb(GObject *obj, gpointer data)
199 2185 hiro
{
200 2185 hiro
    ...
201 2185 hiro
}
202 2185 hiro
203 2185 hiro
    g_signal_connect(syl_app_get(), "init-done", G_CALLBACK(init_done_cb),
204 2185 hiro
                     data);
205 2185 hiro
206 2184 hiro
-------------------------------------------------------------------------
207 2185 hiro
void (* init_done) (GObject *obj)
208 2185 hiro
209 2187 hiro
Emitted when the initialization of application completes.
210 2185 hiro
-------------------------------------------------------------------------
211 2185 hiro
void (* app_exit) (GObject *obj)
212 2185 hiro
213 2187 hiro
Emitted when application exits.
214 2185 hiro
-------------------------------------------------------------------------
215 2798 hiro
void (* app_force_exit) (GObject *obj)
216 2798 hiro
217 2798 hiro
Emitted when application is forced to exit (no confirmation).
218 2798 hiro
(ex: sylpheed --exit)
219 2798 hiro
-------------------------------------------------------------------------
220 2185 hiro
void (* add_msg) (GObject *obj, FolderItem *item, const gchar *file, guint num)
221 2185 hiro
222 2187 hiro
Emitted when a message (number num) is added into folder item.
223 2185 hiro
-------------------------------------------------------------------------
224 2185 hiro
void (* remove_msg) (GObject *obj, FolderItem *item, const gchar *file,
225 2185 hiro
                     guint num)
226 2185 hiro
227 2187 hiro
Emitted when a message (number num) is removed from folder item.
228 2185 hiro
-------------------------------------------------------------------------
229 2185 hiro
void (* remove_all_msg) (GObject *obj, FolderItem *item)
230 2185 hiro
231 2187 hiro
Emitted when all messages are removed from folder item.
232 2185 hiro
-------------------------------------------------------------------------
233 2185 hiro
void (* remove_folder) (GObject *obj, FolderItem *item)
234 2185 hiro
235 2187 hiro
Emitted when folder item is removed.
236 2185 hiro
-------------------------------------------------------------------------
237 2185 hiro
void (* move_folder) (GObject *obj, FolderItem *item, const gchar *old_id,
238 2185 hiro
                      const gchar *new_id)
239 2185 hiro
240 2187 hiro
Emitted when folder item is moved (renamed) from old_id to new_id.
241 2187 hiro
old_id and new_id are folder identifier strings.
242 2185 hiro
-------------------------------------------------------------------------
243 2185 hiro
void (* folderlist_updated) (GObject *obj)
244 2185 hiro
245 2187 hiro
Emitted when folder information is modified and folderlist.xml, which
246 2187 hiro
contains folder list, is updated.
247 2185 hiro
-------------------------------------------------------------------------
248 2527 hiro
void (* account_updated) (GObject *obj)
249 2185 hiro
250 2527 hiro
Emitted on the update of account information.
251 2527 hiro
It will not be emitted if it is locked by account_update_lock(), though.
252 2527 hiro
-------------------------------------------------------------------------
253 2185 hiro
254 2527 hiro
255 2666 hiro
Sample plug-ins
256 2666 hiro
===============
257 2185 hiro
258 2666 hiro
There is sample plug-ins under the 'plugin' directory.
259 2666 hiro
These plug-ins will not be installed with 'make install'.
260 2666 hiro
It is required to enter the directory plugin/* and run
261 2666 hiro
'make install-plugin'.
262 2185 hiro
263 2666 hiro
Test Plug-in
264 2666 hiro
------------
265 2666 hiro
266 2185 hiro
The 'test' plug-in has the basic structure of Sylpheed plug-in and the
267 2185 hiro
following process:
268 2185 hiro
269 2185 hiro
- Output string "test plug-in loaded!" to stdout on load
270 2185 hiro
- Get folder list and output to stdout
271 2185 hiro
- Get Sylpheed version string and output to stdout
272 2185 hiro
- Get the main window and put it in front
273 2570 hiro
- Add sub widget under the folder view
274 2185 hiro
- Add 'Plugin test' menu item on the 'Tools' menu
275 2185 hiro
- When 'Plugin test' menu is selected, a window with a button named
276 2438 hiro
  'Click this button' is displayed. When it is clicked, a message is displayed
277 2438 hiro
- Capture the following events and show messages: application initialization
278 2438 hiro
  and exiting, folder view context menu popup, creating and destroying compose
279 2886 hiro
  window, sending messages
280 2811 hiro
- Capture the text view context menu popup event and add a menu item
281 2185 hiro
282 2666 hiro
Attachment Tool Plug-in
283 2666 hiro
-----------------------
284 2185 hiro
285 2666 hiro
This is a plug-in for handling messages with attached files.
286 2666 hiro
287 2666 hiro
See plugin/attachment_tool/README for the details.
288 2666 hiro
289 2666 hiro
290 2185 hiro
About license
291 2185 hiro
=============
292 2185 hiro
293 2185 hiro
It is required that a plug-in DLL dynamically loaded by Sylpheed is GPL or
294 2185 hiro
GPL-compatible license (ex. modified BSD license) based on the GPL clause
295 2185 hiro
because the license of Sylpheed itself is GPL.
296 2185 hiro
297 2185 hiro
If you want to apply non-GPL license like proprietary license to your plug-in,
298 2185 hiro
you must make the module an independent executable file, and make it work with
299 2185 hiro
inter-process communication with a DLL.