summaryrefslogtreecommitdiff
path: root/PLUGIN.txt
diff options
context:
space:
mode:
Diffstat (limited to 'PLUGIN.txt')
-rw-r--r--PLUGIN.txt406
1 files changed, 406 insertions, 0 deletions
diff --git a/PLUGIN.txt b/PLUGIN.txt
new file mode 100644
index 0000000..b0d9daf
--- /dev/null
+++ b/PLUGIN.txt
@@ -0,0 +1,406 @@
1Sylpheed Plugin Specification
2=============================
3
4The following is the architecture of plugin system of Sylpheed.
5
6 +----------+ +----------------------+ +-----------+
7 | Sylpheed |----| libsylpheed-plugin-0 |--+--| Plug-in A |
8 +----------+ +----------------------+ | +-----------+
9 Sylpheed Plug-in interface | Plug-in DLL
10 library +--+
11 | +------------+ | | +-----------+
12 +--------| libsylph-0 |---------+ +--| Plug-in B |
13 +------------+ +-----------+
14 LibSylph mail library
15
16Sylpheed loads the plug-in DLLs installed in the plug-in directory on
17startup.
18
19Plug-in can only access the functions of Sylpheed through the APIs provided
20with libsylpheed-plugin-0 and libsylph-0 library.
21
22There are two kinds of plug-in API. One is called directly from plug-ins,
23another one utilizes the signal mechanism of GObject and calls the callback
24functions on specific events.
25
26The plug-in system is implemented in libsylph/sylmain.[ch] and
27src/plugin.[ch].
28
29
30Plug-in API
31===========
32
33Functions used by Sylpheed
34--------------------------
35
36-------------------------------------------------------------------------
37void syl_plugin_signal_connect (const gchar *name, GCallback callback,
38 gpointer data);
39
40Connects to signals available with SylPlugin object (obtained inside library).
41The specification of callback functions that receive signals is similar to
42that of normal GObject.
43Refer to the signals list for available signals.
44-------------------------------------------------------------------------
45void syl_plugin_signal_disconnect(gpointer func, gpointer data);
46
47Disconnects signals connected by syl_plugin_signal_connect().
48-------------------------------------------------------------------------
49void syl_plugin_signal_emit(const gchar *name, ...);
50
51Emits SylPlugin object signals.
52-------------------------------------------------------------------------
53gint syl_plugin_init_lib (void);
54
55Initializes the libsylpheed-plugin-0 library.
56-------------------------------------------------------------------------
57gint syl_plugin_load (const gchar *file);
58
59Loads plug-in DLL files into memory.
60-------------------------------------------------------------------------
61gint syl_plugin_load_all (const gchar *dir);
62
63Loads plug-in DLL files in the specified directory into memory.
64-------------------------------------------------------------------------
65void syl_plugin_unload_all (void);
66
67Unloads all loaded plug-ins.
68-------------------------------------------------------------------------
69GSList *syl_plugin_get_module_list (void);
70
71Obtains the list of plug-ins loaded into memory.
72It returns the list of pointers to GModule struct.
73The list is obtained by the library internally, so it must not be freed.
74-------------------------------------------------------------------------
75SylPluginInfo *syl_plugin_get_info (GModule *module);
76
77Obtains plug-in information. The information is returned as SylPluginInfo
78struct.
79-------------------------------------------------------------------------
80gboolean syl_plugin_check_version (GModule *module);
81
82Compares plug-in interface versions and checks if the plug-in is compatible.
83Returns TRUE if the version matches, FALSE otherwise.
84-------------------------------------------------------------------------
85gint syl_plugin_add_symbol (const gchar *name, gpointer sym);
86
87Registers symbol name and pointer value related to it to the library.
88-------------------------------------------------------------------------
89gpointer syl_plugin_lookup_symbol (const gchar *name);
90
91Searches symbol registered by syl_plugin_add_symbol() and returns its
92pointer value.
93-------------------------------------------------------------------------
94
95
96Functions which must be implemented by plug-ins
97-----------------------------------------------
98
99-------------------------------------------------------------------------
100void plugin_load(void)
101
102Called from Sylpheed on plug-in load.
103Do initialization of plug-in etc. here.
104-------------------------------------------------------------------------
105void plugin_unload(void)
106
107Called from Sylpheed on plug-in unload.
108Do finalization of plug-in etc. here.
109-------------------------------------------------------------------------
110SylPluginInfo *plugin_info(void)
111
112Fuction to return struct which stores plug-in information to Sylpheed.
113It normally returns pointer to static struct.
114-------------------------------------------------------------------------
115gint plugin_interface_version(void)
116
117Function to return plug-in API interface version to Sylpheed.
118A plug-in normally returns constant value SYL_PLUGIN_INTERFACE_VERSION.
119Sylpheed compares this value with its own value and checks if it is
120compatible. Sylpheed's plug-in interface version must be equal to or greater
121than the plug-in's plug-in interface verson. If the major versions of the
122interface version differ, they are treated as incompatible.
123
124Ex.1: Sylpheed plug-in interface version: 0x0102
125 A plug-in plug-in interface version: 0x0100: OK
126Ex.2: Sylpheed plug-in interface version: 0x0102
127 A plug-in plug-in interface version: 0x0103: NG
128-------------------------------------------------------------------------
129
130
131Functions used by plug-ins
132--------------------------
133
134Refer to the header file plugin.h for the functions list.
135
136
137Signals list
138------------
139
140* libsylpheed-plugin-0
141
142Call syl_plugin_signal_connect() to use the following signals.
143
144Example:
145 syl_plugin_signal_connect("plugin-load", G_CALLBACK(plugin_load_cb), data);
146
147-------------------------------------------------------------------------
148void (* plugin_load) (GObject *obj, GModule *module);
149
150Emitted on plug-in loading by syl_plugin_load().
151-------------------------------------------------------------------------
152void (* plugin_unload) (GObject *obj, GModule *module);
153
154Emitted on plug-in unloading by syl_plugin_unload_all().
155-------------------------------------------------------------------------
156void (* folderview_menu_popup) (GObject *obj, gpointer ifactory);
157
158Emitted on popup of the context menu of FolderView.
159-------------------------------------------------------------------------
160void (* summaryview_menu_popup) (GObject *obj, gpointer ifactory);
161
162Emitted on popup of the context menu of SummaryView.
163-------------------------------------------------------------------------
164void (* compose_created) (GObject *obj, gpointer compose);
165
166Emitted on creating 'Compose' message composition window.
167-------------------------------------------------------------------------
168void (* compose_destroy) (GObject *obj, gpointer compose);
169
170Emitted just before 'Compose' message composition window is destroyed.
171-------------------------------------------------------------------------
172void (* textview_menu_popup) (GObject *obj,
173 GtkMenu *menu,
174 GtkTextView *textview,
175 const gchar *uri,
176 const gchar *selected_text,
177 MsgInfo *msginfo);
178
179Emitted on popup of the context menu of TextView.
180You can add any menu items to the passed GtkMenu.
181The menu object will be created on open and destroyed on close, so menu items
182must be added each time.
183
184menu: context menu object
185textview: GtkTextView object
186uri: URI string if the menu popups on an URI
187selected_text: string if a string is selected on the text view
188msginfo: the MsgInfo message object displayed in the text view
189-------------------------------------------------------------------------
190gboolean (* compose_send) (GObject *obj,
191 gpointer compose,
192 gint compose_mode,
193 gint send_mode,
194 const gchar *msg_file,
195 GSList *to_list);
196
197Emitted on a composed message is being sent.
198If FALSE is returned, the message is sent normally.
199If TRUE is returned, sending is cancelled.
200
201compose: the Compose object
202compose_mode: ComposeMode enum
203send_mode: 0: send immediately 1: queue and send later
204msg_file: path to the created message file
205to_list: list of recipients
206-------------------------------------------------------------------------
207void (* messageview_show) (GObject *obj,
208 gpointer msgview,
209 MsgInfo *msginfo,
210 gboolean all_headers);
211
212Emitted on displaying a message.
213
214msgview: the MessageView object
215msginfo: the MsgInfo message object displayed
216all_headers: TRUE if all headers are displayed. FALSE if not.
217-------------------------------------------------------------------------
218void (* inc_mail_start) (GObject *obj,
219 PrefsAccount *account);
220
221Emitted on the start of receiving.
222
223account: receive target account (PrefsAccount)
224-------------------------------------------------------------------------
225void (* inc_mail_finished) (GObject *obj,
226 gint new_messages);
227
228Emitted on the end of receiving.
229
230new_messages: number of received messages
231-------------------------------------------------------------------------
232void (* prefs_common_open) (GObject *obj,
233 GtkWidget *window);
234
235Emitted on opening common preferences dialog.
236
237window: dialog window (GtkWindow)
238-------------------------------------------------------------------------
239void (* prefs_account_open) (GObject *obj,
240 PrefsAccount *account,
241 GtkWidget *window);
242
243Emitted on opening account preferences dialog.
244
245window: dialog window (GtkWindow)
246-------------------------------------------------------------------------
247void (* prefs_filter_open) (GObject *obj,
248 GtkWidget *window);
249
250Emitted on opening filter rule preferences dialog.
251
252window: dialog window (GtkWindow)
253-------------------------------------------------------------------------
254void (* prefs_filter_edit_open) (GObject *obj,
255 FilterRule *rule,
256 const gchar *header,
257 const gchar *key,
258 GtkWidget *window);
259
260Emitted on opening filter rule edit dialog.
261
262window: dialog window (GtkWindow)
263-------------------------------------------------------------------------
264void (* prefs_template_open) (GObject *obj,
265 GtkWidget *window);
266
267Emitted on opening template dialog.
268
269window: dialog window (GtkWindow)
270-------------------------------------------------------------------------
271void (* plugin_manager_open) (GObject *obj,
272 GtkWidget *window);
273
274Emitted on opening plug-in manager dialog.
275
276window: dialog window (GtkWindow)
277-------------------------------------------------------------------------
278void (* main_window_toolbar_changed) (GObject *obj);
279
280Emitted on toolbar change of main window.
281Use syl_plugin_main_window_get_toolbar() to get main window toolbar object.
282-------------------------------------------------------------------------
283void (* compose_toolbar_changed) (GObject *obj, gpointer compose);
284
285Emitted on toolbar change of compose window.
286Use syl_plugin_compose_get_toolbar() to get compose toolbar object.
287
288compose: Compose object
289-------------------------------------------------------------------------
290void (* compose_attach_changed) (GObject *obj, gpointer compose);
291
292Emitted when attachments in compose window are changed.
293Use syl_plugin_get_attach_list() to get the list of current attachments.
294
295compose: Compose object
296-------------------------------------------------------------------------
297
298* libsylph-0
299
300The following signals can be used by passing GObject obtained by
301syl_app_get() to the first argument of g_signal_connect().
302
303Example:
304
305void init_done_cb(GObject *obj, gpointer data)
306{
307 ...
308}
309
310 g_signal_connect(syl_app_get(), "init-done", G_CALLBACK(init_done_cb),
311 data);
312
313-------------------------------------------------------------------------
314void (* init_done) (GObject *obj)
315
316Emitted when the initialization of application completes.
317-------------------------------------------------------------------------
318void (* app_exit) (GObject *obj)
319
320Emitted when application exits.
321-------------------------------------------------------------------------
322void (* app_force_exit) (GObject *obj)
323
324Emitted when application is forced to exit (no confirmation).
325(ex: sylpheed --exit)
326-------------------------------------------------------------------------
327void (* add_msg) (GObject *obj, FolderItem *item, const gchar *file, guint num)
328
329Emitted when a message (number num) is added into folder item.
330-------------------------------------------------------------------------
331void (* remove_msg) (GObject *obj, FolderItem *item, const gchar *file,
332 guint num)
333
334Emitted when a message (number num) is removed from folder item.
335-------------------------------------------------------------------------
336void (* remove_all_msg) (GObject *obj, FolderItem *item)
337
338Emitted when all messages are removed from folder item.
339-------------------------------------------------------------------------
340void (* remove_folder) (GObject *obj, FolderItem *item)
341
342Emitted when folder item is removed.
343-------------------------------------------------------------------------
344void (* move_folder) (GObject *obj, FolderItem *item, const gchar *old_id,
345 const gchar *new_id)
346
347Emitted when folder item is moved (renamed) from old_id to new_id.
348old_id and new_id are folder identifier strings.
349-------------------------------------------------------------------------
350void (* folderlist_updated) (GObject *obj)
351
352Emitted when folder information is modified and folderlist.xml, which
353contains folder list, is updated.
354-------------------------------------------------------------------------
355void (* account_updated) (GObject *obj)
356
357Emitted on the update of account information.
358It will not be emitted if it is locked by account_update_lock(), though.
359-------------------------------------------------------------------------
360
361
362Sample plug-ins
363===============
364
365There is sample plug-ins under the 'plugin' directory.
366These plug-ins will not be installed with 'make install'.
367It is required to enter the directory plugin/* and run
368'make install-plugin'.
369
370Test Plug-in
371------------
372
373The 'test' plug-in has the basic structure of Sylpheed plug-in and the
374following process:
375
376- Output string "test plug-in loaded!" to stdout on load
377- Get folder list and output to stdout
378- Get Sylpheed version string and output to stdout
379- Get the main window and put it in front
380- Add sub widget under the folder view
381- Add 'Plugin test' menu item on the 'Tools' menu
382- When 'Plugin test' menu is selected, a window with a button named
383 'Click this button' is displayed. When it is clicked, a message is displayed
384- Capture the following events and show messages: application initialization
385 and exiting, folder view context menu popup, creating and destroying compose
386 window, sending messages
387- Capture the text view context menu popup event and add a menu item
388
389Attachment Tool Plug-in
390-----------------------
391
392This is a plug-in for handling messages with attached files.
393
394See plugin/attachment_tool/README for the details.
395
396
397About license
398=============
399
400It is required that a plug-in DLL dynamically loaded by Sylpheed is GPL or
401GPL-compatible license (ex. modified BSD license) based on the GPL clause
402because the license of Sylpheed itself is GPL.
403
404If you want to apply non-GPL license like proprietary license to your plug-in,
405you must make the module an independent executable file, and make it work with
406inter-process communication with a DLL.