summaryrefslogtreecommitdiff
path: root/src/plugin.c
diff options
context:
space:
mode:
authorSimeon Simeonov2018-02-26 11:23:00 +0100
committerSimeon Simeonov2018-02-26 11:23:00 +0100
commit0b3cbf57875fd692e4ba0b336fefa4bee1ed00dc (patch)
treeaf916a30553c78ce9d4f2d8658656a175c5b6921 /src/plugin.c
Initial commit for sylpheed 3.7.0
Diffstat (limited to 'src/plugin.c')
-rw-r--r--src/plugin.c1535
1 files changed, 1535 insertions, 0 deletions
diff --git a/src/plugin.c b/src/plugin.c
new file mode 100644
index 0000000..52fbc5d
--- /dev/null
+++ b/src/plugin.c
@@ -0,0 +1,1535 @@
1/*
2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2016 Hiroyuki Yamamoto
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20#include <glib.h>
21#include <gmodule.h>
22#include <gtk/gtk.h>
23
24#include "plugin.h"
25#include "utils.h"
26#include "folder.h"
27#include "plugin-marshal.h"
28
29G_DEFINE_TYPE(SylPlugin, syl_plugin, G_TYPE_OBJECT);
30
31enum {
32 PLUGIN_LOAD,
33 PLUGIN_UNLOAD,
34 FOLDERVIEW_MENU_POPUP,
35 SUMMARYVIEW_MENU_POPUP,
36 COMPOSE_CREATED,
37 COMPOSE_DESTROY,
38 TEXTVIEW_MENU_POPUP,
39 COMPOSE_SEND,
40 MESSAGEVIEW_SHOW,
41 INC_MAIL_START,
42 INC_MAIL_FINISHED,
43 PREFS_COMMON_OPEN,
44 PREFS_ACCOUNT_OPEN,
45 PREFS_FILTER_OPEN,
46 PREFS_FILTER_EDIT_OPEN,
47 PREFS_TEMPLATE_OPEN,
48 PLUGIN_MANAGER_OPEN,
49 MAIN_WINDOW_TOOLBAR_CHANGED,
50 COMPOSE_TOOLBAR_CHANGED,
51 COMPOSE_ATTACH_CHANGED,
52 LAST_SIGNAL
53};
54
55#define GETFUNC(sym) { func = syl_plugin_lookup_symbol(sym); }
56
57#define SAFE_CALL(func_ptr) { if (func_ptr) func_ptr(); }
58#define SAFE_CALL_RET(func_ptr) (func_ptr ? func_ptr() : NULL)
59#define SAFE_CALL_RET_VAL(func_ptr, retval) \
60 (func_ptr ? func_ptr() : retval)
61#define SAFE_CALL_ARG1(func_ptr, arg1) { if (func_ptr) func_ptr(arg1); }
62#define SAFE_CALL_ARG1_RET(func_ptr, arg1) \
63 (func_ptr ? func_ptr(arg1) : NULL)
64#define SAFE_CALL_ARG1_RET_VAL(func_ptr, arg1, retval) \
65 (func_ptr ? func_ptr(arg1) : retval)
66#define SAFE_CALL_ARG2(func_ptr, arg1, arg2) \
67 { if (func_ptr) func_ptr(arg1, arg2); }
68#define SAFE_CALL_ARG2_RET(func_ptr, arg1, arg2) \
69 (func_ptr ? func_ptr(arg1, arg2) : NULL)
70#define SAFE_CALL_ARG2_RET_VAL(func_ptr, arg1, arg2, retval) \
71 (func_ptr ? func_ptr(arg1, arg2) : retval)
72#define SAFE_CALL_ARG3(func_ptr, arg1, arg2, arg3) \
73 { if (func_ptr) func_ptr(arg1, arg2, arg3); }
74#define SAFE_CALL_ARG3_RET(func_ptr, arg1, arg2, arg3) \
75 (func_ptr ? func_ptr(arg1, arg2, arg3) : NULL)
76#define SAFE_CALL_ARG3_RET_VAL(func_ptr, arg1, arg2, arg3, retval) \
77 (func_ptr ? func_ptr(arg1, arg2, arg3) : retval)
78#define SAFE_CALL_ARG4(func_ptr, arg1, arg2, arg3, arg4) \
79 { if (func_ptr) func_ptr(arg1, arg2, arg3, arg4); }
80#define SAFE_CALL_ARG4_RET(func_ptr, arg1, arg2, arg3, arg4) \
81 (func_ptr ? func_ptr(arg1, arg2, arg3, arg4) : NULL)
82#define SAFE_CALL_ARG4_RET_VAL(func_ptr, arg1, arg2, arg3, arg4, retval) \
83 (func_ptr ? func_ptr(arg1, arg2, arg3, arg4) : retval)
84
85#define CALL_VOID_POINTER(getobj, sym) \
86{ \
87 void (*func)(gpointer); \
88 gpointer obj; \
89 obj = getobj(); \
90 if (obj) { \
91 GETFUNC(sym); \
92 SAFE_CALL_ARG1(func, obj); \
93 } \
94}
95
96
97static guint plugin_signals[LAST_SIGNAL] = { 0 };
98
99static GHashTable *sym_table = NULL;
100static GSList *module_list = NULL;
101static GObject *plugin_obj = NULL;
102
103static void syl_plugin_init(SylPlugin *self)
104{
105}
106
107static void syl_plugin_class_init(SylPluginClass *klass)
108{
109 GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
110
111 plugin_signals[PLUGIN_LOAD] =
112 g_signal_new("plugin-load",
113 G_TYPE_FROM_CLASS(gobject_class),
114 G_SIGNAL_RUN_FIRST,
115 G_STRUCT_OFFSET(SylPluginClass, plugin_load),
116 NULL, NULL,
117 g_cclosure_marshal_VOID__POINTER,
118 G_TYPE_NONE,
119 1,
120 G_TYPE_POINTER);
121 plugin_signals[PLUGIN_UNLOAD] =
122 g_signal_new("plugin-unload",
123 G_TYPE_FROM_CLASS(gobject_class),
124 G_SIGNAL_RUN_FIRST,
125 G_STRUCT_OFFSET(SylPluginClass, plugin_unload),
126 NULL, NULL,
127 g_cclosure_marshal_VOID__POINTER,
128 G_TYPE_NONE,
129 1,
130 G_TYPE_POINTER);
131 plugin_signals[FOLDERVIEW_MENU_POPUP] =
132 g_signal_new("folderview-menu-popup",
133 G_TYPE_FROM_CLASS(gobject_class),
134 G_SIGNAL_RUN_FIRST,
135 G_STRUCT_OFFSET(SylPluginClass,
136 folderview_menu_popup),
137 NULL, NULL,
138 g_cclosure_marshal_VOID__POINTER,
139 G_TYPE_NONE,
140 1,
141 G_TYPE_POINTER);
142 plugin_signals[SUMMARYVIEW_MENU_POPUP] =
143 g_signal_new("summaryview-menu-popup",
144 G_TYPE_FROM_CLASS(gobject_class),
145 G_SIGNAL_RUN_FIRST,
146 G_STRUCT_OFFSET(SylPluginClass,
147 summaryview_menu_popup),
148 NULL, NULL,
149 g_cclosure_marshal_VOID__POINTER,
150 G_TYPE_NONE,
151 1,
152 G_TYPE_POINTER);
153 plugin_signals[COMPOSE_CREATED] =
154 g_signal_new("compose-created",
155 G_TYPE_FROM_CLASS(gobject_class),
156 G_SIGNAL_RUN_FIRST,
157 G_STRUCT_OFFSET(SylPluginClass, compose_created),
158 NULL, NULL,
159 g_cclosure_marshal_VOID__POINTER,
160 G_TYPE_NONE,
161 1,
162 G_TYPE_POINTER);
163 plugin_signals[COMPOSE_DESTROY] =
164 g_signal_new("compose-destroy",
165 G_TYPE_FROM_CLASS(gobject_class),
166 G_SIGNAL_RUN_FIRST,
167 G_STRUCT_OFFSET(SylPluginClass, compose_destroy),
168 NULL, NULL,
169 g_cclosure_marshal_VOID__POINTER,
170 G_TYPE_NONE,
171 1,
172 G_TYPE_POINTER);
173 plugin_signals[TEXTVIEW_MENU_POPUP] =
174 g_signal_new("textview-menu-popup",
175 G_TYPE_FROM_CLASS(gobject_class),
176 G_SIGNAL_RUN_FIRST,
177 G_STRUCT_OFFSET(SylPluginClass,
178 textview_menu_popup),
179 NULL, NULL,
180 syl_plugin_marshal_VOID__POINTER_POINTER_STRING_STRING_POINTER,
181 G_TYPE_NONE,
182 5,
183 G_TYPE_POINTER,
184 G_TYPE_POINTER,
185 G_TYPE_STRING,
186 G_TYPE_STRING,
187 G_TYPE_POINTER);
188 plugin_signals[COMPOSE_SEND] =
189 g_signal_new("compose-send",
190 G_TYPE_FROM_CLASS(gobject_class),
191 G_SIGNAL_RUN_LAST,
192 G_STRUCT_OFFSET(SylPluginClass, compose_send),
193 NULL, NULL,
194 syl_plugin_marshal_BOOLEAN__POINTER_INT_INT_STRING_POINTER,
195 G_TYPE_BOOLEAN,
196 5,
197 G_TYPE_POINTER,
198 G_TYPE_INT,
199 G_TYPE_INT,
200 G_TYPE_STRING,
201 G_TYPE_POINTER);
202 plugin_signals[MESSAGEVIEW_SHOW] =
203 g_signal_new("messageview-show",
204 G_TYPE_FROM_CLASS(gobject_class),
205 G_SIGNAL_RUN_FIRST,
206 G_STRUCT_OFFSET(SylPluginClass, messageview_show),
207 NULL, NULL,
208 syl_plugin_marshal_VOID__POINTER_POINTER_BOOLEAN,
209 G_TYPE_NONE,
210 3,
211 G_TYPE_POINTER,
212 G_TYPE_POINTER,
213 G_TYPE_BOOLEAN);
214
215 plugin_signals[INC_MAIL_START] =
216 g_signal_new("inc-mail-start",
217 G_TYPE_FROM_CLASS(gobject_class),
218 G_SIGNAL_RUN_FIRST,
219 G_STRUCT_OFFSET(SylPluginClass, inc_mail_start),
220 NULL, NULL,
221 g_cclosure_marshal_VOID__POINTER,
222 G_TYPE_NONE,
223 1,
224 G_TYPE_POINTER);
225 plugin_signals[INC_MAIL_FINISHED] =
226 g_signal_new("inc-mail-finished",
227 G_TYPE_FROM_CLASS(gobject_class),
228 G_SIGNAL_RUN_FIRST,
229 G_STRUCT_OFFSET(SylPluginClass, inc_mail_finished),
230 NULL, NULL,
231 g_cclosure_marshal_VOID__INT,
232 G_TYPE_NONE,
233 1,
234 G_TYPE_INT);
235
236 plugin_signals[PREFS_COMMON_OPEN] =
237 g_signal_new("prefs-common-open",
238 G_TYPE_FROM_CLASS(gobject_class),
239 G_SIGNAL_RUN_FIRST,
240 G_STRUCT_OFFSET(SylPluginClass, prefs_common_open),
241 NULL, NULL,
242 g_cclosure_marshal_VOID__POINTER,
243 G_TYPE_NONE,
244 1,
245 G_TYPE_POINTER);
246 plugin_signals[PREFS_ACCOUNT_OPEN] =
247 g_signal_new("prefs-account-open",
248 G_TYPE_FROM_CLASS(gobject_class),
249 G_SIGNAL_RUN_FIRST,
250 G_STRUCT_OFFSET(SylPluginClass, prefs_account_open),
251 NULL, NULL,
252 syl_plugin_marshal_VOID__POINTER_POINTER,
253 G_TYPE_NONE,
254 2,
255 G_TYPE_POINTER,
256 G_TYPE_POINTER);
257 plugin_signals[PREFS_FILTER_OPEN] =
258 g_signal_new("prefs-filter-open",
259 G_TYPE_FROM_CLASS(gobject_class),
260 G_SIGNAL_RUN_FIRST,
261 G_STRUCT_OFFSET(SylPluginClass, prefs_filter_open),
262 NULL, NULL,
263 g_cclosure_marshal_VOID__POINTER,
264 G_TYPE_NONE,
265 1,
266 G_TYPE_POINTER);
267 plugin_signals[PREFS_FILTER_EDIT_OPEN] =
268 g_signal_new("prefs-filter-edit-open",
269 G_TYPE_FROM_CLASS(gobject_class),
270 G_SIGNAL_RUN_FIRST,
271 G_STRUCT_OFFSET(SylPluginClass, prefs_filter_edit_open),
272 NULL, NULL,
273 syl_plugin_marshal_VOID__POINTER_STRING_STRING_POINTER,
274 G_TYPE_NONE,
275 4,
276 G_TYPE_POINTER,
277 G_TYPE_STRING,
278 G_TYPE_STRING,
279 G_TYPE_POINTER);
280 plugin_signals[PREFS_TEMPLATE_OPEN] =
281 g_signal_new("prefs-template-open",
282 G_TYPE_FROM_CLASS(gobject_class),
283 G_SIGNAL_RUN_FIRST,
284 G_STRUCT_OFFSET(SylPluginClass, prefs_template_open),
285 NULL, NULL,
286 g_cclosure_marshal_VOID__POINTER,
287 G_TYPE_NONE,
288 1,
289 G_TYPE_POINTER);
290 plugin_signals[PLUGIN_MANAGER_OPEN] =
291 g_signal_new("plugin-manager-open",
292 G_TYPE_FROM_CLASS(gobject_class),
293 G_SIGNAL_RUN_FIRST,
294 G_STRUCT_OFFSET(SylPluginClass, plugin_manager_open),
295 NULL, NULL,
296 g_cclosure_marshal_VOID__POINTER,
297 G_TYPE_NONE,
298 1,
299 G_TYPE_POINTER);
300 plugin_signals[MAIN_WINDOW_TOOLBAR_CHANGED] =
301 g_signal_new("main-window-toolbar-changed",
302 G_TYPE_FROM_CLASS(gobject_class),
303 G_SIGNAL_RUN_FIRST,
304 G_STRUCT_OFFSET(SylPluginClass, main_window_toolbar_changed),
305 NULL, NULL,
306 g_cclosure_marshal_VOID__VOID,
307 G_TYPE_NONE,
308 0);
309 plugin_signals[COMPOSE_TOOLBAR_CHANGED] =
310 g_signal_new("compose-toolbar-changed",
311 G_TYPE_FROM_CLASS(gobject_class),
312 G_SIGNAL_RUN_FIRST,
313 G_STRUCT_OFFSET(SylPluginClass, compose_toolbar_changed),
314 NULL, NULL,
315 g_cclosure_marshal_VOID__POINTER,
316 G_TYPE_NONE,
317 1,
318 G_TYPE_POINTER);
319 plugin_signals[COMPOSE_TOOLBAR_CHANGED] =
320 g_signal_new("compose-attach-changed",
321 G_TYPE_FROM_CLASS(gobject_class),
322 G_SIGNAL_RUN_FIRST,
323 G_STRUCT_OFFSET(SylPluginClass, compose_attach_changed),
324 NULL, NULL,
325 g_cclosure_marshal_VOID__POINTER,
326 G_TYPE_NONE,
327 1,
328 G_TYPE_POINTER);
329}
330
331void syl_plugin_signal_connect(const gchar *name, GCallback callback,
332 gpointer data)
333{
334 g_return_if_fail(plugin_obj != NULL);
335
336 g_signal_connect(plugin_obj, name, callback, data);
337}
338
339void syl_plugin_signal_disconnect(gpointer func, gpointer data)
340{
341 g_return_if_fail(plugin_obj != NULL);
342
343 g_signal_handlers_disconnect_by_func(plugin_obj, func, data);
344}
345
346void syl_plugin_signal_emit(const gchar *name, ...)
347{
348 guint signal_id;
349
350 g_return_if_fail(plugin_obj != NULL);
351
352 if (g_signal_parse_name(name, G_TYPE_FROM_INSTANCE(plugin_obj), &signal_id, NULL, FALSE)) {
353 \
354 va_list var_args;
355 va_start(var_args, name);
356 g_signal_emit_valist(plugin_obj, signal_id, 0, var_args);
357 va_end(var_args);
358 } else
359 g_warning("%s: signal '%s' not found", G_STRLOC, name);
360}
361
362gint syl_plugin_init_lib(void)
363{
364 if (!g_module_supported()) {
365 g_warning("Plug-in is not supported.");
366 return -1;
367 }
368
369 if (!sym_table) {
370 sym_table = g_hash_table_new(g_str_hash, g_str_equal);
371 }
372
373 if (!plugin_obj) {
374 plugin_obj = g_object_new(SYL_TYPE_PLUGIN, NULL);
375 }
376
377 return 0;
378}
379
380gint syl_plugin_load(const gchar *name)
381{
382 GModule *module;
383 SylPluginLoadFunc load_func = NULL;
384 gchar *file;
385
386 g_return_val_if_fail(plugin_obj != NULL, -1);
387 g_return_val_if_fail(name != NULL, -1);
388
389 debug_print("syl_plugin_load: loading %s\n", name);
390
391 if (!g_path_is_absolute(name))
392 file = g_strconcat(PLUGINDIR, G_DIR_SEPARATOR_S, name, NULL);
393 else
394 file = g_strdup(name);
395
396 module = g_module_open(file, G_MODULE_BIND_LAZY);
397 if (!module) {
398 g_warning("Cannot open module: %s: %s", name, g_module_error());
399 g_free(file);
400 return -1;
401 }
402 if (g_slist_find(module_list, module)) {
403 g_warning("Module %s is already loaded", name);
404 g_free(file);
405 return -1;
406 }
407
408 if (g_module_symbol(module, "plugin_load", (gpointer)&load_func)) {
409 if (!syl_plugin_check_version(module)) {
410 g_warning("Version check failed. Skipping: %s", name);
411 g_module_close(module);
412 g_free(file);
413 return -1;
414 }
415
416 debug_print("calling plugin_load() in %s\n",
417 g_module_name(module));
418 load_func();
419 module_list = g_slist_prepend(module_list, module);
420 g_signal_emit(plugin_obj, plugin_signals[PLUGIN_LOAD], 0, module);
421 } else {
422 g_warning("Cannot get symbol: %s: %s", name, g_module_error());
423 g_module_close(module);
424 g_free(file);
425 return -1;
426 }
427
428 g_free(file);
429
430 return 0;
431}
432
433gint syl_plugin_load_all(const gchar *dir)
434{
435 GDir *d;
436 const gchar *dir_name;
437 gchar *path;
438 gint count = 0;
439
440 g_return_val_if_fail(dir != NULL, -1);
441
442 debug_print("loading plugins from directory: %s\n", dir);
443
444 if ((d = g_dir_open(dir, 0, NULL)) == NULL) {
445 debug_print("failed to open directory: %s\n", dir);
446 return -1;
447 }
448
449 while ((dir_name = g_dir_read_name(d)) != NULL) {
450 if (!g_str_has_suffix(dir_name, "." G_MODULE_SUFFIX))
451 continue;
452 path = g_strconcat(dir, G_DIR_SEPARATOR_S, dir_name, NULL);
453 if (syl_plugin_load(path) == 0)
454 count++;
455 g_free(path);
456 }
457
458 g_dir_close(d);
459
460 return count;
461}
462
463void syl_plugin_unload_all(void)
464{
465 GSList *cur;
466
467 g_return_if_fail(plugin_obj != NULL);
468
469 for (cur = module_list; cur != NULL; cur = cur->next) {
470 GModule *module = (GModule *)cur->data;
471 SylPluginUnloadFunc unload_func = NULL;
472
473 if (g_module_symbol(module, "plugin_unload",
474 (gpointer)&unload_func)) {
475 g_signal_emit(plugin_obj, plugin_signals[PLUGIN_UNLOAD],
476 0, module);
477 debug_print("calling plugin_unload() in %s\n",
478 g_module_name(module));
479 unload_func();
480 } else {
481 g_warning("Cannot get symbol: %s", g_module_error());
482 }
483 if (!g_module_close(module)) {
484 g_warning("Module unload failed: %s", g_module_error());
485 }
486 }
487
488 g_slist_free(module_list);
489 module_list = NULL;
490}
491
492GSList *syl_plugin_get_module_list(void)
493{
494 return module_list;
495}
496
497SylPluginInfo *syl_plugin_get_info(GModule *module)
498{
499 SylPluginInfo * (*plugin_info_func)(void);
500
501 g_return_val_if_fail(module != NULL, NULL);
502
503 debug_print("getting plugin information of %s\n",
504 g_module_name(module));
505
506 if (g_module_symbol(module, "plugin_info",
507 (gpointer)&plugin_info_func)) {
508 debug_print("calling plugin_info() in %s\n",
509 g_module_name(module));
510 return plugin_info_func();
511 } else {
512 g_warning("Cannot get symbol: %s: %s", g_module_name(module),
513 g_module_error());
514 return NULL;
515 }
516}
517
518gboolean syl_plugin_check_version(GModule *module)
519{
520 gint (*version_func)(void);
521 gint ver;
522 gint a_major;
523 gint a_minor;
524 gint p_major;
525 gint p_minor;
526
527 g_return_val_if_fail(module != NULL, FALSE);
528
529 if (g_module_symbol(module, "plugin_interface_version",
530 (gpointer)&version_func)) {
531 debug_print("calling plugin_interface_version() in %s\n",
532 g_module_name(module));
533 ver = version_func();
534 } else {
535 g_warning("Cannot get symbol: %s: %s", g_module_name(module),
536 g_module_error());
537 return FALSE;
538 }
539
540 a_major = SYL_PLUGIN_INTERFACE_VERSION & 0xff00;
541 a_minor = SYL_PLUGIN_INTERFACE_VERSION & 0x00ff;
542 p_major = ver & 0xff00;
543 p_minor = ver & 0x00ff;
544 if (a_major == p_major && a_minor >= p_minor) {
545 debug_print("Version OK: plugin: %d, app: %d\n",
546 ver, SYL_PLUGIN_INTERFACE_VERSION);
547 return TRUE;
548 } else {
549 g_warning("Plugin interface version mismatch: plugin: %d, app: %d", ver, SYL_PLUGIN_INTERFACE_VERSION);
550 return FALSE;
551 }
552}
553
554gint syl_plugin_add_symbol(const gchar *name, gpointer sym)
555{
556 g_hash_table_insert(sym_table, (gpointer)name, sym);
557 return 0;
558}
559
560gpointer syl_plugin_lookup_symbol(const gchar *name)
561{
562 return g_hash_table_lookup(sym_table, name);
563}
564
565const gchar *syl_plugin_get_prog_version(void)
566{
567 gpointer sym;
568
569 sym = syl_plugin_lookup_symbol("prog_version");
570 return (gchar *)sym;
571}
572
573void syl_plugin_main_window_lock(void)
574{
575 CALL_VOID_POINTER(syl_plugin_main_window_get,
576 "main_window_lock");
577}
578
579void syl_plugin_main_window_unlock(void)
580{
581 CALL_VOID_POINTER(syl_plugin_main_window_get,
582 "main_window_unlock");
583}
584
585gpointer syl_plugin_main_window_get(void)
586{
587 gpointer (*func)(void);
588
589 func = syl_plugin_lookup_symbol("main_window_get");
590 return SAFE_CALL_RET(func);
591}
592
593void syl_plugin_main_window_popup(gpointer mainwin)
594{
595 void (*func)(gpointer);
596
597 func = syl_plugin_lookup_symbol("main_window_popup");
598 SAFE_CALL_ARG1(func, mainwin);
599}
600
601GtkWidget *syl_plugin_main_window_get_toolbar(void)
602{
603 gpointer widget;
604
605 widget = syl_plugin_lookup_symbol("main_window_toolbar");
606 return GTK_WIDGET(widget);
607}
608
609GtkWidget *syl_plugin_main_window_get_statusbar(void)
610{
611 gpointer widget;
612
613 widget = syl_plugin_lookup_symbol("main_window_statusbar");
614 return GTK_WIDGET(widget);
615}
616
617void syl_plugin_app_will_exit(gboolean force)
618{
619 void (*func)(gboolean);
620
621 func = syl_plugin_lookup_symbol("app_will_exit");
622 SAFE_CALL_ARG1(func, force);
623}
624
625static GtkItemFactory *get_item_factory(const gchar *path)
626{
627 GtkItemFactory *ifactory;
628
629 if (!path)
630 return NULL;
631
632 if (strncmp(path, "<Main>", 6) == 0)
633 ifactory = syl_plugin_lookup_symbol("main_window_menu_factory");
634 else if (strncmp(path, "<MailFolder>", 12) == 0)
635 ifactory = syl_plugin_lookup_symbol("folderview_mail_popup_factory");
636 else if (strncmp(path, "<IMAPFolder>", 12) == 0)
637 ifactory = syl_plugin_lookup_symbol("folderview_imap_popup_factory");
638 else if (strncmp(path, "<NewsFolder>", 12) == 0)
639 ifactory = syl_plugin_lookup_symbol("folderview_news_popup_factory");
640 else if (strncmp(path, "<SummaryView>", 13) == 0)
641 ifactory = syl_plugin_lookup_symbol("summaryview_popup_factory");
642 else
643 ifactory = syl_plugin_lookup_symbol("main_window_menu_factory");
644
645 return ifactory;
646}
647
648gint syl_plugin_add_menuitem(const gchar *parent, const gchar *label,
649 SylPluginCallbackFunc func, gpointer data)
650{
651 GtkItemFactory *ifactory;
652 GtkWidget *menu;
653 GtkWidget *menuitem;
654
655 if (!parent)
656 return -1;
657
658 ifactory = get_item_factory(parent);
659 if (!ifactory)
660 return -1;
661
662 menu = gtk_item_factory_get_widget(ifactory, parent);
663 if (!menu)
664 return -1;
665
666 if (label)
667 menuitem = gtk_menu_item_new_with_label(label);
668 else {
669 menuitem = gtk_menu_item_new();
670 gtk_widget_set_sensitive(menuitem, FALSE);
671 }
672 gtk_widget_show(menuitem);
673 gtk_menu_append(GTK_MENU(menu), menuitem);
674 if (func)
675 g_signal_connect(G_OBJECT(menuitem), "activate",
676 G_CALLBACK(func), data);
677
678 return 0;
679}
680
681gint syl_plugin_add_factory_item(const gchar *parent, const gchar *label,
682 SylPluginCallbackFunc func, gpointer data)
683{
684 GtkItemFactory *ifactory;
685 GtkItemFactoryEntry entry = {NULL, NULL, NULL, 0, NULL};
686
687 if (!parent)
688 return -1;
689
690 ifactory = get_item_factory(parent);
691 if (!ifactory)
692 return -1;
693
694 if (label) {
695 entry.path = (gchar *)label;
696 if (g_str_has_suffix(label, "/---"))
697 entry.item_type = "<Separator>";
698 else
699 entry.item_type = NULL;
700 } else {
701 entry.path = "/---";
702 entry.item_type = "<Separator>";
703 }
704 entry.callback = func;
705 g_print("entry.path = %s\n", entry.path);
706
707 gtk_item_factory_create_item(ifactory, &entry, data, 2);
708
709 return 0;
710}
711
712void syl_plugin_menu_set_sensitive(const gchar *path, gboolean sensitive)
713{
714 GtkItemFactory *ifactory;
715 GtkWidget *widget;
716
717 g_return_if_fail(path != NULL);
718
719 ifactory = get_item_factory(path);
720 if (!ifactory)
721 return;
722
723 widget = gtk_item_factory_get_item(ifactory, path);
724 gtk_widget_set_sensitive(widget, sensitive);
725}
726
727void syl_plugin_menu_set_sensitive_all(GtkMenuShell *menu_shell,
728 gboolean sensitive)
729{
730 GList *cur;
731
732 for (cur = menu_shell->children; cur != NULL; cur = cur->next)
733 gtk_widget_set_sensitive(GTK_WIDGET(cur->data), sensitive);
734}
735
736void syl_plugin_menu_set_active(const gchar *path, gboolean is_active)
737{
738 GtkItemFactory *ifactory;
739 GtkWidget *widget;
740
741 g_return_if_fail(path != NULL);
742
743 ifactory = get_item_factory(path);
744 if (!ifactory)
745 return;
746
747 widget = gtk_item_factory_get_item(ifactory, path);
748 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), is_active);
749}
750
751gpointer syl_plugin_folderview_get(void)
752{
753 gpointer (*func)(void);
754 GETFUNC("folderview_get");
755 return SAFE_CALL_RET(func);
756}
757
758void syl_plugin_folderview_add_sub_widget(GtkWidget *widget)
759{
760 void (*func)(gpointer, GtkWidget *);
761 gpointer folderview;
762
763 folderview = syl_plugin_folderview_get();
764 if (folderview) {
765 GETFUNC("folderview_add_sub_widget");
766 SAFE_CALL_ARG2(func, folderview, widget);
767 }
768}
769
770void syl_plugin_folderview_select(FolderItem *item)
771{
772 void (*func)(gpointer, FolderItem *);
773 gpointer folderview;
774
775 folderview = syl_plugin_folderview_get();
776 if (folderview) {
777 GETFUNC("folderview_select");
778 SAFE_CALL_ARG2(func, folderview, item);
779 }
780}
781
782void syl_plugin_folderview_unselect(void)
783{
784 CALL_VOID_POINTER(syl_plugin_folderview_get,
785 "folderview_unselect");
786}
787
788void syl_plugin_folderview_select_next_unread(void)
789{
790 CALL_VOID_POINTER(syl_plugin_folderview_get,
791 "folderview_select_next_unread");
792}
793
794FolderItem *syl_plugin_folderview_get_selected_item(void)
795{
796 FolderItem * (*func)(gpointer);
797 gpointer folderview;
798
799 folderview = syl_plugin_folderview_get();
800 if (folderview) {
801 GETFUNC("folderview_get_selected_item");
802 return SAFE_CALL_ARG1_RET(func, folderview);
803 }
804
805 return NULL;
806}
807
808gint syl_plugin_folderview_check_new(Folder *folder)
809{
810 gint (*func)(Folder *);
811 GETFUNC("folderview_check_new");
812 return SAFE_CALL_ARG1_RET_VAL(func, folder, FALSE);
813}
814
815gint syl_plugin_folderview_check_new_item(FolderItem *item)
816{
817 gint (*func)(FolderItem *);
818 GETFUNC("folderview_check_new_item");
819 return SAFE_CALL_ARG1_RET_VAL(func, item, FALSE);
820}
821
822gint syl_plugin_folderview_check_new_all(void)
823{
824 gint (*func)(void);
825 GETFUNC("folderview_check_new_all");
826 return SAFE_CALL_RET_VAL(func, FALSE);
827}
828
829void syl_plugin_folderview_update_item(FolderItem *item,
830 gboolean update_summary)
831{
832 void (*func)(FolderItem *, gboolean);
833 GETFUNC("folderview_update_item");
834 SAFE_CALL_ARG2(func, item, update_summary);
835}
836
837void syl_plugin_folderview_update_item_foreach(GHashTable *table,
838 gboolean update_summary)
839{
840 void (*func)(GHashTable *, gboolean);
841 GETFUNC("folderview_update_item_foreach");
842 SAFE_CALL_ARG2(func, table, update_summary);
843}
844
845void syl_plugin_folderview_update_all_updated(gboolean update_summary)
846{
847 void (*func)(gboolean);
848 GETFUNC("folderview_update_all_updated");
849 SAFE_CALL_ARG1(func, update_summary);
850}
851
852void syl_plugin_folderview_check_new_selected(void)
853{
854 CALL_VOID_POINTER(syl_plugin_folderview_get,
855 "folderview_check_new_selected");
856}
857
858gpointer syl_plugin_summary_view_get(void)
859{
860 gpointer sym;
861
862 sym = syl_plugin_lookup_symbol("summaryview");
863 return sym;
864}
865
866void syl_plugin_summary_select_by_msgnum(guint msgnum)
867{
868 void (*func)(gpointer, guint);
869 gpointer summary;
870
871 summary = syl_plugin_summary_view_get();
872 if (summary) {
873 func = syl_plugin_lookup_symbol("summary_select_by_msgnum");
874 SAFE_CALL_ARG2(func, summary, msgnum);
875 }
876}
877
878gboolean syl_plugin_summary_select_by_msginfo(MsgInfo *msginfo)
879{
880 gboolean (*func)(gpointer, MsgInfo *);
881 gpointer summary;
882
883 summary = syl_plugin_summary_view_get();
884 if (summary) {
885 func = syl_plugin_lookup_symbol("summary_select_by_msginfo");
886 return SAFE_CALL_ARG2_RET_VAL(func, summary, msginfo, FALSE);
887 }
888
889 return FALSE;
890}
891
892void syl_plugin_open_message(const gchar *folder_id, guint msgnum)
893{
894 FolderItem *item;
895 MsgInfo *msginfo;
896
897 item = folder_find_item_from_identifier(folder_id);
898 msginfo = folder_item_get_msginfo(item, msgnum);
899
900 if (msginfo) {
901 if (!syl_plugin_summary_select_by_msginfo(msginfo)) {
902 syl_plugin_open_message_by_new_window(msginfo);
903 }
904 procmsg_msginfo_free(msginfo);
905 }
906}
907
908void syl_plugin_summary_show_queued_msgs(void)
909{
910 CALL_VOID_POINTER(syl_plugin_summary_view_get,
911 "summary_show_queued_msgs");
912}
913
914void syl_plugin_summary_lock(void)
915{
916 CALL_VOID_POINTER(syl_plugin_summary_view_get,
917 "summary_lock");
918}
919
920void syl_plugin_summary_unlock(void)
921{
922 CALL_VOID_POINTER(syl_plugin_summary_view_get,
923 "summary_unlock");
924}
925
926gboolean syl_plugin_summary_is_locked(void)
927{
928 gboolean (*func)(gpointer);
929 gpointer summary;
930
931 summary = syl_plugin_summary_view_get();
932 if (summary) {
933 GETFUNC("summary_is_locked");
934 return SAFE_CALL_ARG1_RET_VAL(func, summary, FALSE);
935 }
936
937 return FALSE;
938}
939
940gboolean syl_plugin_summary_is_read_locked(void)
941{
942 gboolean (*func)(gpointer);
943 gpointer summary;
944
945 summary = syl_plugin_summary_view_get();
946 if (summary) {
947 GETFUNC("summary_is_read_locked");
948 return SAFE_CALL_ARG1_RET_VAL(func, summary, FALSE);
949 }
950
951 return FALSE;
952}
953
954void syl_plugin_summary_write_lock(void)
955{
956 CALL_VOID_POINTER(syl_plugin_summary_view_get,
957 "summary_write_lock");
958}
959
960void syl_plugin_summary_write_unlock(void)
961{
962 CALL_VOID_POINTER(syl_plugin_summary_view_get,
963 "summary_write_unlock");
964}
965
966gboolean syl_plugin_summary_is_write_locked(void)
967{
968 gboolean (*func)(gpointer);
969 gpointer summary;
970
971 summary = syl_plugin_summary_view_get();
972 if (summary) {
973 GETFUNC("summary_is_write_locked");
974 return SAFE_CALL_ARG1_RET_VAL(func, summary, FALSE);
975 }
976
977 return FALSE;
978}
979
980FolderItem *syl_plugin_summary_get_current_folder(void)
981{
982 FolderItem * (*func)(gpointer);
983 gpointer summary;
984
985 summary = syl_plugin_summary_view_get();
986 if (summary) {
987 GETFUNC("summary_get_current_folder");
988 return SAFE_CALL_ARG1_RET(func, summary);
989 }
990
991 return NULL;
992}
993
994gint syl_plugin_summary_get_selection_type(void)
995{
996 gint (*func)(gpointer);
997 gpointer summary;
998
999 summary = syl_plugin_summary_view_get();
1000 if (summary) {
1001 GETFUNC("summary_get_selection_type");
1002 return SAFE_CALL_ARG1_RET_VAL(func, summary, 0);
1003 }
1004
1005 return 0;
1006}
1007
1008GSList *syl_plugin_summary_get_selected_msg_list(void)
1009{
1010 GSList * (*func)(gpointer);
1011 gpointer summary;
1012
1013 summary = syl_plugin_summary_view_get();
1014 if (summary) {
1015 GETFUNC("summary_get_selected_msg_list");
1016 return SAFE_CALL_ARG1_RET(func, summary);
1017 }
1018
1019 return NULL;
1020}
1021
1022GSList *syl_plugin_summary_get_msg_list(void)
1023{
1024 GSList * (*func)(gpointer);
1025 gpointer summary;
1026
1027 summary = syl_plugin_summary_view_get();
1028 if (summary) {
1029 GETFUNC("summary_get_msg_list");
1030 return SAFE_CALL_ARG1_RET(func, summary);
1031 }
1032
1033 return NULL;
1034}
1035
1036void syl_plugin_summary_redisplay_msg(void)
1037{
1038 CALL_VOID_POINTER(syl_plugin_summary_view_get,
1039 "summary_redisplay_msg");
1040}
1041
1042void syl_plugin_summary_open_msg(void)
1043{
1044 CALL_VOID_POINTER(syl_plugin_summary_view_get,
1045 "summary_open_msg");
1046}
1047
1048void syl_plugin_summary_view_source(void)
1049{
1050 CALL_VOID_POINTER(syl_plugin_summary_view_get,
1051 "summary_view_source");
1052}
1053
1054void syl_plugin_summary_reedit(void)
1055{
1056 CALL_VOID_POINTER(syl_plugin_summary_view_get,
1057 "summary_reedit");
1058}
1059
1060void syl_plugin_summary_update_selected_rows(void)
1061{
1062 CALL_VOID_POINTER(syl_plugin_summary_view_get,
1063 "summary_update_selected_rows");
1064}
1065
1066void syl_plugin_summary_update_by_msgnum(guint msgnum)
1067{
1068 void (*func)(gpointer, guint);
1069 gpointer summary;
1070
1071 summary = syl_plugin_summary_view_get();
1072 if (summary) {
1073 func = syl_plugin_lookup_symbol("summary_update_by_msgnum");
1074 SAFE_CALL_ARG2(func, summary, msgnum);
1075 }
1076}
1077
1078gpointer syl_plugin_messageview_create_with_new_window(void)
1079{
1080 gpointer (*func)(void);
1081
1082 func = syl_plugin_lookup_symbol("messageview_create_with_new_window");
1083 return SAFE_CALL_RET(func);
1084}
1085
1086void syl_plugin_open_message_by_new_window(MsgInfo *msginfo)
1087{
1088 gpointer msgview;
1089 gpointer (*func)(gpointer, MsgInfo *, gboolean);
1090
1091 msgview = syl_plugin_messageview_create_with_new_window();
1092 if (msgview) {
1093 func = syl_plugin_lookup_symbol("messageview_show");
1094 SAFE_CALL_ARG3(func, msgview, msginfo, FALSE);
1095 }
1096}
1097
1098
1099gpointer syl_plugin_compose_new(PrefsAccount *account, FolderItem *item,
1100 const gchar *mailto, GPtrArray *attach_files)
1101{
1102 gpointer (*func)(PrefsAccount *, FolderItem *, const gchar *,
1103 GPtrArray *);
1104
1105 func = syl_plugin_lookup_symbol("compose_new");
1106 return SAFE_CALL_ARG4_RET(func, account, item, mailto, attach_files);
1107}
1108
1109gpointer syl_plugin_compose_reply(MsgInfo *msginfo, FolderItem *item,
1110 gint mode, const gchar *body)
1111{
1112 gpointer (*func)(MsgInfo *, FolderItem *, gint, const gchar *);
1113
1114 GETFUNC("compose_reply");
1115 return SAFE_CALL_ARG4_RET(func, msginfo, item, mode, body);
1116}
1117
1118gpointer syl_plugin_compose_forward(GSList *mlist, FolderItem *item,
1119 gboolean as_attach, const gchar *body)
1120{
1121 gpointer (*func)(GSList *, FolderItem *, gboolean, const gchar *);
1122
1123 GETFUNC("compose_forward");
1124 return SAFE_CALL_ARG4_RET(func, mlist, item, as_attach, body);
1125}
1126
1127gpointer syl_plugin_compose_redirect(MsgInfo *msginfo, FolderItem *item)
1128{
1129 gpointer (*func)(MsgInfo *, FolderItem *);
1130
1131 GETFUNC("compose_redirect");
1132 return SAFE_CALL_ARG2_RET(func, msginfo, item);
1133}
1134
1135gpointer syl_plugin_compose_reedit(MsgInfo *msginfo)
1136{
1137 gpointer (*func)(MsgInfo *);
1138
1139 GETFUNC("compose_reedit");
1140 return SAFE_CALL_ARG1_RET(func, msginfo);
1141}
1142
1143void syl_plugin_compose_entry_set(gpointer compose, const gchar *text,
1144 gint type)
1145{
1146 void (*func)(gpointer, const gchar *, gint);
1147
1148 func = syl_plugin_lookup_symbol("compose_entry_set");
1149 SAFE_CALL_ARG3(func, compose, text, type);
1150}
1151
1152void syl_plugin_compose_entry_append(gpointer compose, const gchar *text,
1153 gint type)
1154{
1155 void (*func)(gpointer, const gchar *, gint);
1156
1157 func = syl_plugin_lookup_symbol("compose_entry_append");
1158 SAFE_CALL_ARG3(func, compose, text, type);
1159}
1160
1161gchar *syl_plugin_compose_entry_get_text(gpointer compose, gint type)
1162{
1163 gchar * (*func)(gpointer, gint);
1164
1165 func = syl_plugin_lookup_symbol("compose_entry_get_text");
1166 return SAFE_CALL_ARG2_RET(func, compose, type);
1167}
1168
1169void syl_plugin_compose_lock(gpointer compose)
1170{
1171 void (*func)(gpointer);
1172
1173 func = syl_plugin_lookup_symbol("compose_lock");
1174 SAFE_CALL_ARG1(func, compose);
1175}
1176
1177void syl_plugin_compose_unlock(gpointer compose)
1178{
1179 void (*func)(gpointer);
1180
1181 func = syl_plugin_lookup_symbol("compose_unlock");
1182 SAFE_CALL_ARG1(func, compose);
1183}
1184
1185GtkWidget *syl_plugin_compose_get_toolbar(gpointer compose)
1186{
1187 GtkWidget * (*func)(gpointer);
1188
1189 func = syl_plugin_lookup_symbol("compose_get_toolbar");
1190 return SAFE_CALL_ARG1_RET(func, compose);
1191}
1192
1193GtkWidget *syl_plugin_compose_get_misc_hbox(gpointer compose)
1194{
1195 GtkWidget * (*func)(gpointer);
1196
1197 func = syl_plugin_lookup_symbol("compose_get_misc_hbox");
1198 return SAFE_CALL_ARG1_RET(func, compose);
1199}
1200
1201GtkWidget *syl_plugin_compose_get_textview(gpointer compose)
1202{
1203 GtkWidget * (*func)(gpointer);
1204
1205 func = syl_plugin_lookup_symbol("compose_get_textview");
1206 return SAFE_CALL_ARG1_RET(func, compose);
1207}
1208
1209gint syl_plugin_compose_send(gpointer compose, gboolean close_on_success)
1210{
1211 gint (*func)(gpointer, gboolean);
1212
1213 GETFUNC("compose_send");
1214 return SAFE_CALL_ARG2_RET_VAL(func, compose, close_on_success, -1);
1215}
1216
1217void syl_plugin_compose_attach_append(gpointer compose,
1218 const gchar *file,
1219 const gchar *filename,
1220 const gchar *content_type)
1221{
1222 void (*func)(gpointer, const gchar *, const gchar *, const gchar *);
1223
1224 GETFUNC("compose_attach_append");
1225 SAFE_CALL_ARG4(func, compose, file, filename, content_type);
1226}
1227
1228void syl_plugin_compose_attach_remove_all(gpointer compose)
1229{
1230 void (*func)(gpointer);
1231
1232 GETFUNC("compose_attach_remove_all");
1233 SAFE_CALL_ARG1(func, compose);
1234}
1235
1236GSList *syl_plugin_get_attach_list(gpointer compose)
1237{
1238 GSList * (*func)(gpointer);
1239
1240 GETFUNC("compose_get_attach_list");
1241 return SAFE_CALL_ARG1_RET(func, compose);
1242}
1243
1244
1245FolderItem *syl_plugin_folder_sel(Folder *cur_folder, gint sel_type,
1246 const gchar *default_folder)
1247{
1248 FolderItem * (*func)(Folder *, gint, const gchar *);
1249
1250 func = syl_plugin_lookup_symbol("foldersel_folder_sel");
1251 return SAFE_CALL_ARG3_RET(func, cur_folder, sel_type, default_folder);
1252}
1253
1254FolderItem *syl_plugin_folder_sel_full(Folder *cur_folder, gint sel_type,
1255 const gchar *default_folder,
1256 const gchar *message)
1257{
1258 FolderItem * (*func)(Folder *, gint, const gchar *, const gchar *);
1259
1260 func = syl_plugin_lookup_symbol("foldersel_folder_sel_full");
1261 return SAFE_CALL_ARG4_RET(func, cur_folder, sel_type, default_folder,
1262 message);
1263}
1264
1265gchar *syl_plugin_input_dialog(const gchar *title, const gchar *message,
1266 const gchar *default_string)
1267{
1268 gchar * (*func)(const gchar *, const gchar *, const gchar *);
1269
1270 func = syl_plugin_lookup_symbol("input_dialog");
1271 return SAFE_CALL_ARG3_RET(func, title, message, default_string);
1272}
1273
1274gchar *syl_plugin_input_dialog_with_invisible(const gchar *title,
1275 const gchar *message,
1276 const gchar *default_string)
1277{
1278 gchar * (*func)(const gchar *, const gchar *, const gchar *);
1279
1280 func = syl_plugin_lookup_symbol("input_dialog_with_invisible");
1281 return SAFE_CALL_ARG3_RET(func, title, message, default_string);
1282}
1283
1284void syl_plugin_manage_window_set_transient(GtkWindow *window)
1285{
1286 void (*func)(GtkWindow *);
1287
1288 func = syl_plugin_lookup_symbol("manage_window_set_transient");
1289 SAFE_CALL_ARG1(func, window);
1290}
1291
1292void syl_plugin_manage_window_signals_connect(GtkWindow *window)
1293{
1294 void (*func)(GtkWindow *);
1295
1296 func = syl_plugin_lookup_symbol("manage_window_signals_connect");
1297 SAFE_CALL_ARG1(func, window);
1298}
1299
1300GtkWidget *syl_plugin_manage_window_get_focus_window(void)
1301{
1302 GtkWidget * (*func)(void);
1303
1304 func = syl_plugin_lookup_symbol("manage_window_get_focus_window");
1305 return SAFE_CALL_RET(func);
1306}
1307
1308void syl_plugin_inc_mail(void)
1309{
1310 void (*func)(gpointer);
1311
1312 func = syl_plugin_lookup_symbol("inc_mail");
1313 SAFE_CALL_ARG1(func, syl_plugin_main_window_get());
1314}
1315
1316gboolean syl_plugin_inc_is_active(void)
1317{
1318 gboolean (*func)(void);
1319
1320 func = syl_plugin_lookup_symbol("inc_is_active");
1321 return SAFE_CALL_RET_VAL(func, FALSE);
1322}
1323
1324void syl_plugin_inc_lock(void)
1325{
1326 void (*func)(void);
1327
1328 func = syl_plugin_lookup_symbol("inc_lock");
1329 SAFE_CALL(func);
1330}
1331
1332void syl_plugin_inc_unlock(void)
1333{
1334 void (*func)(void);
1335
1336 func = syl_plugin_lookup_symbol("inc_unlock");
1337 SAFE_CALL(func);
1338}
1339
1340void syl_plugin_update_check(gboolean show_dialog_always)
1341{
1342 void (*func)(gboolean);
1343
1344 func = syl_plugin_lookup_symbol("update_check");
1345 SAFE_CALL_ARG1(func, show_dialog_always);
1346}
1347
1348void syl_plugin_update_check_set_check_url(const gchar *url)
1349{
1350 void (*func)(const gchar *);
1351
1352 func = syl_plugin_lookup_symbol("update_check_set_check_url");
1353 SAFE_CALL_ARG1(func, url);
1354}
1355
1356const gchar *syl_plugin_update_check_get_check_url(void)
1357{
1358 const gchar * (*func)(void);
1359
1360 func = syl_plugin_lookup_symbol("update_check_get_check_url");
1361 return SAFE_CALL_RET(func);
1362}
1363
1364void syl_plugin_update_check_set_download_url(const gchar *url)
1365{
1366 void (*func)(const gchar *);
1367
1368 func = syl_plugin_lookup_symbol("update_check_set_download_url");
1369 SAFE_CALL_ARG1(func, url);
1370}
1371
1372const gchar *syl_plugin_update_check_get_download_url(void)
1373{
1374 const gchar * (*func)(void);
1375
1376 func = syl_plugin_lookup_symbol("update_check_get_download_url");
1377 return SAFE_CALL_RET(func);
1378}
1379
1380void syl_plugin_update_check_set_jump_url(const gchar *url)
1381{
1382 void (*func)(const gchar *);
1383
1384 func = syl_plugin_lookup_symbol("update_check_set_jump_url");
1385 SAFE_CALL_ARG1(func, url);
1386}
1387
1388const gchar *syl_plugin_update_check_get_jump_url(void)
1389{
1390 const gchar * (*func)(void);
1391
1392 func = syl_plugin_lookup_symbol("update_check_get_jump_url");
1393 return SAFE_CALL_RET(func);
1394}
1395
1396void syl_plugin_update_check_set_check_plugin_url(const gchar *url)
1397{
1398 void (*func)(const gchar *);
1399
1400 func = syl_plugin_lookup_symbol("update_check_set_check_plugin_url");
1401 SAFE_CALL_ARG1(func, url);
1402}
1403
1404const gchar *syl_plugin_update_check_get_check_plugin_url(void)
1405{
1406 const gchar * (*func)(void);
1407
1408 func = syl_plugin_lookup_symbol("update_check_get_check_plugin_url");
1409 return SAFE_CALL_RET(func);
1410}
1411
1412void syl_plugin_update_check_set_jump_plugin_url(const gchar *url)
1413{
1414 void (*func)(const gchar *);
1415
1416 func = syl_plugin_lookup_symbol("update_check_set_jump_plugin_url");
1417 SAFE_CALL_ARG1(func, url);
1418}
1419
1420const gchar *syl_plugin_update_check_get_jump_plugin_url(void)
1421{
1422 const gchar * (*func)(void);
1423
1424 func = syl_plugin_lookup_symbol("update_check_get_jump_plugin_url");
1425 return SAFE_CALL_RET(func);
1426}
1427
1428gint syl_plugin_alertpanel_full(const gchar *title, const gchar *message,
1429 gint type, gint default_value,
1430 gboolean can_disable,
1431 const gchar *btn1_label,
1432 const gchar *btn2_label,
1433 const gchar *btn3_label)
1434{
1435 gint (*func)(const gchar *, const gchar *, gint, gint, gboolean,
1436 const gchar *, const gchar *, const gchar *);
1437
1438 GETFUNC("alertpanel_full");
1439 return func ? func(title, message, type, default_value, can_disable,
1440 btn1_label, btn2_label, btn3_label) : -1;
1441}
1442
1443gint syl_plugin_alertpanel(const gchar *title, const gchar *message,
1444 const gchar *btn1_label,
1445 const gchar *btn2_label,
1446 const gchar *btn3_label)
1447{
1448 gint (*func)(const gchar *, const gchar *,
1449 const gchar *, const gchar *, const gchar *);
1450
1451 GETFUNC("alertpanel");
1452 return func ? func(title, message, btn1_label, btn2_label, btn3_label)
1453 : -1;
1454}
1455
1456void syl_plugin_alertpanel_message(const gchar *title, const gchar *message,
1457 gint type)
1458{
1459 void (*func)(const gchar *, const gchar *, gint);
1460
1461 GETFUNC("alertpanel_message");
1462 SAFE_CALL_ARG3(func, title, message, type);
1463}
1464
1465gint syl_plugin_alertpanel_message_with_disable(const gchar *title,
1466 const gchar *message,
1467 gint type)
1468{
1469 gint (*func)(const gchar *, const gchar *, gint);
1470
1471 GETFUNC("alertpanel_message_with_disable");
1472 return SAFE_CALL_ARG3_RET_VAL(func, title, message, type, 0);
1473}
1474
1475gint syl_plugin_send_message(const gchar *file, PrefsAccount *ac,
1476 GSList *to_list)
1477{
1478 gint (*func)(const gchar *, PrefsAccount *, GSList *);
1479
1480 GETFUNC("send_message");
1481 return SAFE_CALL_ARG3_RET_VAL(func, file, ac, to_list, -1);
1482}
1483
1484gint syl_plugin_send_message_queue_all(FolderItem *queue, gboolean save_msgs,
1485 gboolean filter_msgs)
1486{
1487 gint (*func)(FolderItem *, gboolean, gboolean);
1488
1489 GETFUNC("send_message_queue_all");
1490 return SAFE_CALL_ARG3_RET_VAL(func, queue, save_msgs, filter_msgs, -1);
1491}
1492
1493gint syl_plugin_send_message_set_reply_flag(const gchar *reply_target,
1494 const gchar *msgid)
1495{
1496 gint (*func)(const gchar *, const gchar *);
1497
1498 GETFUNC("send_message_set_reply_flag");
1499 return SAFE_CALL_ARG2_RET_VAL(func, reply_target, msgid, -1);
1500}
1501
1502gint syl_plugin_send_message_set_forward_flags(const gchar *forward_targets)
1503{
1504 gint (*func)(const gchar *);
1505
1506 GETFUNC("send_message_set_forward_flags");
1507 return SAFE_CALL_ARG1_RET_VAL(func, forward_targets, -1);
1508}
1509
1510gint syl_plugin_notification_window_open(const gchar *message,
1511 const gchar *submessage,
1512 guint timeout)
1513{
1514 gint (*func)(const gchar *, const gchar *, guint);
1515
1516 GETFUNC("notification_window_open");
1517 return SAFE_CALL_ARG3_RET_VAL(func, message, submessage, timeout, -1);
1518}
1519
1520void syl_plugin_notification_window_set_message(const gchar *message,
1521 const gchar *submessage)
1522{
1523 void (*func)(const gchar *, const gchar *);
1524
1525 GETFUNC("notification_window_set_message");
1526 SAFE_CALL_ARG2(func, message, submessage);
1527}
1528
1529void syl_plugin_notification_window_close(void)
1530{
1531 void (*func)(void);
1532
1533 GETFUNC("notification_window_close");
1534 SAFE_CALL(func);
1535}