Statistics
| Revision:

root / PLUGIN.txt

History | View | Annotate | Download (15.1 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 3243 hiro
gboolean (* compose_send)       (GObject        *obj,
191 3243 hiro
                                 gpointer        compose,
192 3243 hiro
                                 gint            compose_mode,
193 3243 hiro
                                 gint            send_mode,
194 3243 hiro
                                 const gchar    *msg_file,
195 3243 hiro
                                 GSList         *to_list);
196 2811 hiro
197 3243 hiro
Emitted on a composed message is being sent.
198 3243 hiro
If FALSE is returned, the message is sent normally.
199 3243 hiro
If TRUE is returned, sending is cancelled.
200 3243 hiro
201 3243 hiro
compose: the Compose object
202 3243 hiro
compose_mode: ComposeMode enum
203 3243 hiro
send_mode: 0: send immediately 1: queue and send later
204 3243 hiro
msg_file: path to the created message file
205 3243 hiro
to_list: list of recipients
206 3243 hiro
-------------------------------------------------------------------------
207 3243 hiro
void (* messageview_show)       (GObject        *obj,
208 3243 hiro
                                 gpointer        msgview,
209 3243 hiro
                                 MsgInfo        *msginfo,
210 3243 hiro
                                 gboolean        all_headers);
211 3243 hiro
212 3243 hiro
Emitted on displaying a message.
213 3243 hiro
214 3243 hiro
msgview: the MessageView object
215 3243 hiro
msginfo: the MsgInfo message object displayed
216 3243 hiro
all_headers: TRUE if all headers are displayed. FALSE if not.
217 3243 hiro
-------------------------------------------------------------------------
218 3243 hiro
void (* inc_mail_start)         (GObject        *obj,
219 3243 hiro
                                 PrefsAccount   *account);
220 3243 hiro
221 3243 hiro
Emitted on the start of receiving.
222 3243 hiro
223 3243 hiro
account: receive target account (PrefsAccount)
224 3243 hiro
-------------------------------------------------------------------------
225 3243 hiro
void (* inc_mail_finished)      (GObject        *obj,
226 3243 hiro
                                 gint            new_messages);
227 3243 hiro
228 3243 hiro
Emitted on the end of receiving.
229 3243 hiro
230 3243 hiro
new_messages: number of received messages
231 3243 hiro
-------------------------------------------------------------------------
232 3243 hiro
void (* prefs_common_open)      (GObject        *obj,
233 3243 hiro
                                 GtkWidget      *window);
234 3243 hiro
235 3243 hiro
Emitted on opening common preferences dialog.
236 3243 hiro
237 3243 hiro
window: dialog window (GtkWindow)
238 3243 hiro
-------------------------------------------------------------------------
239 3243 hiro
void (* prefs_account_open)     (GObject        *obj,
240 3243 hiro
                                 PrefsAccount   *account,
241 3243 hiro
                                 GtkWidget      *window);
242 3243 hiro
243 3243 hiro
Emitted on opening account preferences dialog.
244 3243 hiro
245 3243 hiro
window: dialog window (GtkWindow)
246 3243 hiro
-------------------------------------------------------------------------
247 3243 hiro
void (* prefs_filter_open)      (GObject        *obj,
248 3243 hiro
                                 GtkWidget      *window);
249 3243 hiro
250 3243 hiro
Emitted on opening filter rule preferences dialog.
251 3243 hiro
252 3243 hiro
window: dialog window (GtkWindow)
253 3243 hiro
-------------------------------------------------------------------------
254 3243 hiro
void (* prefs_filter_edit_open) (GObject        *obj,
255 3243 hiro
                                 FilterRule     *rule,
256 3243 hiro
                                 const gchar    *header,
257 3243 hiro
                                 const gchar    *key,
258 3243 hiro
                                 GtkWidget      *window);
259 3243 hiro
260 3243 hiro
Emitted on opening filter rule edit dialog.
261 3243 hiro
262 3243 hiro
window: dialog window (GtkWindow)
263 3243 hiro
-------------------------------------------------------------------------
264 3243 hiro
void (* prefs_template_open)    (GObject        *obj,
265 3243 hiro
                                 GtkWidget      *window);
266 3243 hiro
267 3243 hiro
Emitted on opening template dialog.
268 3243 hiro
269 3243 hiro
window: dialog window (GtkWindow)
270 3243 hiro
-------------------------------------------------------------------------
271 3243 hiro
void (* plugin_manager_open)    (GObject        *obj,
272 3243 hiro
                                 GtkWidget      *window);
273 3243 hiro
274 3243 hiro
Emitted on opening plug-in manager dialog.
275 3243 hiro
276 3243 hiro
window: dialog window (GtkWindow)
277 3243 hiro
-------------------------------------------------------------------------
278 3243 hiro
279 2184 hiro
* libsylph-0
280 2184 hiro
281 2185 hiro
The following signals can be used by passing GObject obtained by
282 2185 hiro
syl_app_get() to the first argument of g_signal_connect().
283 2185 hiro
284 2185 hiro
Example:
285 2185 hiro
286 2185 hiro
void init_done_cb(GObject *obj, gpointer data)
287 2185 hiro
{
288 2185 hiro
    ...
289 2185 hiro
}
290 2185 hiro
291 2185 hiro
    g_signal_connect(syl_app_get(), "init-done", G_CALLBACK(init_done_cb),
292 2185 hiro
                     data);
293 2185 hiro
294 2184 hiro
-------------------------------------------------------------------------
295 2185 hiro
void (* init_done) (GObject *obj)
296 2185 hiro
297 2187 hiro
Emitted when the initialization of application completes.
298 2185 hiro
-------------------------------------------------------------------------
299 2185 hiro
void (* app_exit) (GObject *obj)
300 2185 hiro
301 2187 hiro
Emitted when application exits.
302 2185 hiro
-------------------------------------------------------------------------
303 2798 hiro
void (* app_force_exit) (GObject *obj)
304 2798 hiro
305 2798 hiro
Emitted when application is forced to exit (no confirmation).
306 2798 hiro
(ex: sylpheed --exit)
307 2798 hiro
-------------------------------------------------------------------------
308 2185 hiro
void (* add_msg) (GObject *obj, FolderItem *item, const gchar *file, guint num)
309 2185 hiro
310 2187 hiro
Emitted when a message (number num) is added into folder item.
311 2185 hiro
-------------------------------------------------------------------------
312 2185 hiro
void (* remove_msg) (GObject *obj, FolderItem *item, const gchar *file,
313 2185 hiro
                     guint num)
314 2185 hiro
315 2187 hiro
Emitted when a message (number num) is removed from folder item.
316 2185 hiro
-------------------------------------------------------------------------
317 2185 hiro
void (* remove_all_msg) (GObject *obj, FolderItem *item)
318 2185 hiro
319 2187 hiro
Emitted when all messages are removed from folder item.
320 2185 hiro
-------------------------------------------------------------------------
321 2185 hiro
void (* remove_folder) (GObject *obj, FolderItem *item)
322 2185 hiro
323 2187 hiro
Emitted when folder item is removed.
324 2185 hiro
-------------------------------------------------------------------------
325 2185 hiro
void (* move_folder) (GObject *obj, FolderItem *item, const gchar *old_id,
326 2185 hiro
                      const gchar *new_id)
327 2185 hiro
328 2187 hiro
Emitted when folder item is moved (renamed) from old_id to new_id.
329 2187 hiro
old_id and new_id are folder identifier strings.
330 2185 hiro
-------------------------------------------------------------------------
331 2185 hiro
void (* folderlist_updated) (GObject *obj)
332 2185 hiro
333 2187 hiro
Emitted when folder information is modified and folderlist.xml, which
334 2187 hiro
contains folder list, is updated.
335 2185 hiro
-------------------------------------------------------------------------
336 2527 hiro
void (* account_updated) (GObject *obj)
337 2185 hiro
338 2527 hiro
Emitted on the update of account information.
339 2527 hiro
It will not be emitted if it is locked by account_update_lock(), though.
340 2527 hiro
-------------------------------------------------------------------------
341 2185 hiro
342 2527 hiro
343 2666 hiro
Sample plug-ins
344 2666 hiro
===============
345 2185 hiro
346 2666 hiro
There is sample plug-ins under the 'plugin' directory.
347 2666 hiro
These plug-ins will not be installed with 'make install'.
348 2666 hiro
It is required to enter the directory plugin/* and run
349 2666 hiro
'make install-plugin'.
350 2185 hiro
351 2666 hiro
Test Plug-in
352 2666 hiro
------------
353 2666 hiro
354 2185 hiro
The 'test' plug-in has the basic structure of Sylpheed plug-in and the
355 2185 hiro
following process:
356 2185 hiro
357 2185 hiro
- Output string "test plug-in loaded!" to stdout on load
358 2185 hiro
- Get folder list and output to stdout
359 2185 hiro
- Get Sylpheed version string and output to stdout
360 2185 hiro
- Get the main window and put it in front
361 2570 hiro
- Add sub widget under the folder view
362 2185 hiro
- Add 'Plugin test' menu item on the 'Tools' menu
363 2185 hiro
- When 'Plugin test' menu is selected, a window with a button named
364 2438 hiro
  'Click this button' is displayed. When it is clicked, a message is displayed
365 2438 hiro
- Capture the following events and show messages: application initialization
366 2438 hiro
  and exiting, folder view context menu popup, creating and destroying compose
367 2886 hiro
  window, sending messages
368 2811 hiro
- Capture the text view context menu popup event and add a menu item
369 2185 hiro
370 2666 hiro
Attachment Tool Plug-in
371 2666 hiro
-----------------------
372 2185 hiro
373 2666 hiro
This is a plug-in for handling messages with attached files.
374 2666 hiro
375 2666 hiro
See plugin/attachment_tool/README for the details.
376 2666 hiro
377 2666 hiro
378 2185 hiro
About license
379 2185 hiro
=============
380 2185 hiro
381 2185 hiro
It is required that a plug-in DLL dynamically loaded by Sylpheed is GPL or
382 2185 hiro
GPL-compatible license (ex. modified BSD license) based on the GPL clause
383 2185 hiro
because the license of Sylpheed itself is GPL.
384 2185 hiro
385 2185 hiro
If you want to apply non-GPL license like proprietary license to your plug-in,
386 2185 hiro
you must make the module an independent executable file, and make it work with
387 2185 hiro
inter-process communication with a DLL.