aboutsummaryrefslogtreecommitdiff
path: root/PLUGIN.txt
blob: 31217492b461f4d1a9fdd6e12401049208c8e312 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
Sylpheed Plugin Specification
=============================

The following is the architecture of plugin system of Sylpheed.

 +----------+    +----------------------+     +-----------+
 | Sylpheed |----| libsylpheed-plugin-0 |--+--| Plug-in A |
 +----------+    +----------------------+  |  +-----------+
   Sylpheed         Plug-in interface      |   Plug-in DLL
                    library             +--+
        |        +------------+         |  |  +-----------+
        +--------| libsylph-0 |---------+  +--| Plug-in B |
                 +------------+               +-----------+
                 LibSylph mail library

Sylpheed loads the plug-in DLLs installed in the plug-in directory on
startup.

Plug-in can only access the functions of Sylpheed through the APIs provided
with libsylpheed-plugin-0 and libsylph-0 library.

There are two kinds of plug-in API. One is called directly from plug-ins,
another one utilizes the signal mechanism of GObject and calls the callback
functions on specific events.

The plug-in system is implemented in libsylph/sylmain.[ch] and
src/plugin.[ch].

Plug-in API
===========

Used by Sylpheed
----------------

-------------------------------------------------------------------------
void syl_plugin_signal_connect  (const gchar *name, GCallback callback,
                                 gpointer data);

-------------------------------------------------------------------------
void syl_plugin_signal_disconnect(gpointer func, gpointer data);

-------------------------------------------------------------------------
void syl_plugin_signal_emit(const gchar *name, ...);

-------------------------------------------------------------------------
gint syl_plugin_init_lib        (void);

-------------------------------------------------------------------------
gint syl_plugin_load            (const gchar *file);

-------------------------------------------------------------------------
gint syl_plugin_load_all        (const gchar *dir);

-------------------------------------------------------------------------
void syl_plugin_unload_all      (void);

-------------------------------------------------------------------------
GSList *syl_plugin_get_module_list      (void);

-------------------------------------------------------------------------
SylPluginInfo *syl_plugin_get_info      (GModule *module);

-------------------------------------------------------------------------
gboolean syl_plugin_check_version       (GModule *module);

-------------------------------------------------------------------------
gint syl_plugin_add_symbol              (const gchar *name, gpointer sym);

-------------------------------------------------------------------------
gpointer syl_plugin_lookup_symbol       (const gchar *name);

-------------------------------------------------------------------------


Functions which must be implemented by plug-ins
-----------------------------------------------

-------------------------------------------------------------------------
void plugin_load(void)

-------------------------------------------------------------------------
void plugin_unload(void)

-------------------------------------------------------------------------
SylPluginInfo *plugin_info(void)

-------------------------------------------------------------------------
gint plugin_interface_version(void)

-------------------------------------------------------------------------


Functions used by plug-ins
--------------------------

Refer to plugin.h for the functions list.


Signals list
------------

* libsylpheed-plugin-0

Call syl_plugin_signal_connect() to use the following signals.

Example:
  syl_plugin_signal_connect("plugin-load", G_CALLBACK(plugin_load_cb), data);

-------------------------------------------------------------------------
void (* plugin_load)    (GObject *obj, GModule *module);

-------------------------------------------------------------------------
void (* plugin_unload)  (GObject *obj, GModule *module);

-------------------------------------------------------------------------
void (* folderview_menu_popup)  (GObject *obj, gpointer ifactory);

-------------------------------------------------------------------------

* libsylph-0

The following signals can be used by passing GObject obtained by
syl_app_get() to the first argument of g_signal_connect().

Example:

void init_done_cb(GObject *obj, gpointer data)
{
    ...
}

    g_signal_connect(syl_app_get(), "init-done", G_CALLBACK(init_done_cb),
                     data);

-------------------------------------------------------------------------
void (* init_done) (GObject *obj)

-------------------------------------------------------------------------
void (* app_exit) (GObject *obj)

-------------------------------------------------------------------------
void (* add_msg) (GObject *obj, FolderItem *item, const gchar *file, guint num)

-------------------------------------------------------------------------
void (* remove_msg) (GObject *obj, FolderItem *item, const gchar *file,
                     guint num)

-------------------------------------------------------------------------
void (* remove_all_msg) (GObject *obj, FolderItem *item)

-------------------------------------------------------------------------
void (* remove_folder) (GObject *obj, FolderItem *item)

-------------------------------------------------------------------------
void (* move_folder) (GObject *obj, FolderItem *item, const gchar *old_id,
                      const gchar *new_id)

-------------------------------------------------------------------------
void (* folderlist_updated) (GObject *obj)

-------------------------------------------------------------------------


Sample plug-in
==============

There is a sample plug-in at plugin/test. This plug-in will not be installed
with 'make install'. It is required to enter the directory plugin/test and
run 'make install-plugin'.

The 'test' plug-in has the basic structure of Sylpheed plug-in and the
following process:

- Output string "test plug-in loaded!" to stdout on load
- Get folder list and output to stdout
- Get Sylpheed version string and output to stdout
- Get the main window and put it in front
- Add 'Plugin test' menu item on the 'Tools' menu
- When 'Plugin test' menu is selected, a window with a button named
  'Click this to quit' is displayed. If it is clicked, Sylpheed will quit


About license
=============

It is required that a plug-in DLL dynamically loaded by Sylpheed is GPL or
GPL-compatible license (ex. modified BSD license) based on the GPL clause
because the license of Sylpheed itself is GPL.

If you want to apply non-GPL license like proprietary license to your plug-in,
you must make the module an independent executable file, and make it work with
inter-process communication with a DLL.