Statistics
| Revision:

root / src / plugin.c @ 3193

History | View | Annotate | Download (34 KB)

1
/*
2
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3
 * Copyright (C) 1999-2012 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

    
29
G_DEFINE_TYPE(SylPlugin, syl_plugin, G_TYPE_OBJECT);
30

    
31
enum {
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
        LAST_SIGNAL
50
};
51

    
52
#define GETFUNC(sym)        { func = syl_plugin_lookup_symbol(sym); }
53

    
54
#define SAFE_CALL(func_ptr)                { if (func_ptr) func_ptr(); }
55
#define SAFE_CALL_RET(func_ptr)                (func_ptr ? func_ptr() : NULL)
56
#define SAFE_CALL_RET_VAL(func_ptr, retval) \
57
                                        (func_ptr ? func_ptr() : retval)
58
#define SAFE_CALL_ARG1(func_ptr, arg1)        { if (func_ptr) func_ptr(arg1); }
59
#define SAFE_CALL_ARG1_RET(func_ptr, arg1) \
60
                                (func_ptr ? func_ptr(arg1) : NULL)
61
#define SAFE_CALL_ARG1_RET_VAL(func_ptr, arg1, retval) \
62
                                (func_ptr ? func_ptr(arg1) : retval)
63
#define SAFE_CALL_ARG2(func_ptr, arg1, arg2) \
64
                                { if (func_ptr) func_ptr(arg1, arg2); }
65
#define SAFE_CALL_ARG2_RET(func_ptr, arg1, arg2) \
66
                                (func_ptr ? func_ptr(arg1, arg2) : NULL)
67
#define SAFE_CALL_ARG2_RET_VAL(func_ptr, arg1, arg2, retval) \
68
                                (func_ptr ? func_ptr(arg1, arg2) : retval)
69
#define SAFE_CALL_ARG3(func_ptr, arg1, arg2, arg3) \
70
                                { if (func_ptr) func_ptr(arg1, arg2, arg3); }
71
#define SAFE_CALL_ARG3_RET(func_ptr, arg1, arg2, arg3) \
72
                                (func_ptr ? func_ptr(arg1, arg2, arg3) : NULL)
73
#define SAFE_CALL_ARG3_RET_VAL(func_ptr, arg1, arg2, arg3, retval) \
74
                                (func_ptr ? func_ptr(arg1, arg2, arg3) : retval)
75
#define SAFE_CALL_ARG4(func_ptr, arg1, arg2, arg3, arg4) \
76
                                { if (func_ptr) func_ptr(arg1, arg2, arg3); }
77
#define SAFE_CALL_ARG4_RET(func_ptr, arg1, arg2, arg3, arg4) \
78
                                (func_ptr ? func_ptr(arg1, arg2, arg3, arg4) : NULL)
79
#define SAFE_CALL_ARG4_RET_VAL(func_ptr, arg1, arg2, arg3, arg4, retval) \
80
                                (func_ptr ? func_ptr(arg1, arg2, arg3, arg4) : retval)
81

    
82
#define CALL_VOID_POINTER(getobj, sym)                \
83
{                                                \
84
        void (*func)(gpointer);                        \
85
        gpointer obj;                                \
86
        obj = getobj();                                \
87
        if (obj) {                                \
88
                GETFUNC(sym);                        \
89
                SAFE_CALL_ARG1(func, obj);        \
90
        }                                        \
91
}
92

    
93

    
94
static guint plugin_signals[LAST_SIGNAL] = { 0 };
95

    
96
static GHashTable *sym_table = NULL;
97
static GSList *module_list = NULL;
98
static GObject *plugin_obj = NULL;
99

    
100
static void syl_plugin_init(SylPlugin *self)
101
{
102
}
103

    
104
static void syl_plugin_class_init(SylPluginClass *klass)
105
{
106
        GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
107

    
108
        plugin_signals[PLUGIN_LOAD] =
109
                g_signal_new("plugin-load",
110
                             G_TYPE_FROM_CLASS(gobject_class),
111
                             G_SIGNAL_RUN_FIRST,
112
                             G_STRUCT_OFFSET(SylPluginClass, plugin_load),
113
                             NULL, NULL,
114
                             g_cclosure_marshal_VOID__POINTER,
115
                             G_TYPE_NONE,
116
                             1,
117
                             G_TYPE_POINTER);
118
        plugin_signals[PLUGIN_UNLOAD] =
119
                g_signal_new("plugin-unload",
120
                             G_TYPE_FROM_CLASS(gobject_class),
121
                             G_SIGNAL_RUN_FIRST,
122
                             G_STRUCT_OFFSET(SylPluginClass, plugin_unload),
123
                             NULL, NULL,
124
                             g_cclosure_marshal_VOID__POINTER,
125
                             G_TYPE_NONE,
126
                             1,
127
                             G_TYPE_POINTER);
128
        plugin_signals[FOLDERVIEW_MENU_POPUP] =
129
                g_signal_new("folderview-menu-popup",
130
                             G_TYPE_FROM_CLASS(gobject_class),
131
                             G_SIGNAL_RUN_FIRST,
132
                             G_STRUCT_OFFSET(SylPluginClass,
133
                                             folderview_menu_popup),
134
                             NULL, NULL,
135
                             g_cclosure_marshal_VOID__POINTER,
136
                             G_TYPE_NONE,
137
                             1,
138
                             G_TYPE_POINTER);
139
        plugin_signals[SUMMARYVIEW_MENU_POPUP] =
140
                g_signal_new("summaryview-menu-popup",
141
                             G_TYPE_FROM_CLASS(gobject_class),
142
                             G_SIGNAL_RUN_FIRST,
143
                             G_STRUCT_OFFSET(SylPluginClass,
144
                                             summaryview_menu_popup),
145
                             NULL, NULL,
146
                             g_cclosure_marshal_VOID__POINTER,
147
                             G_TYPE_NONE,
148
                             1,
149
                             G_TYPE_POINTER);
150
        plugin_signals[COMPOSE_CREATED] =
151
                g_signal_new("compose-created",
152
                             G_TYPE_FROM_CLASS(gobject_class),
153
                             G_SIGNAL_RUN_FIRST,
154
                             G_STRUCT_OFFSET(SylPluginClass, compose_created),
155
                             NULL, NULL,
156
                             g_cclosure_marshal_VOID__POINTER,
157
                             G_TYPE_NONE,
158
                             1,
159
                             G_TYPE_POINTER);
160
        plugin_signals[COMPOSE_DESTROY] =
161
                g_signal_new("compose-destroy",
162
                             G_TYPE_FROM_CLASS(gobject_class),
163
                             G_SIGNAL_RUN_FIRST,
164
                             G_STRUCT_OFFSET(SylPluginClass, compose_destroy),
165
                             NULL, NULL,
166
                             g_cclosure_marshal_VOID__POINTER,
167
                             G_TYPE_NONE,
168
                             1,
169
                             G_TYPE_POINTER);
170
        plugin_signals[TEXTVIEW_MENU_POPUP] =
171
                g_signal_new("textview-menu-popup",
172
                             G_TYPE_FROM_CLASS(gobject_class),
173
                             G_SIGNAL_RUN_FIRST,
174
                             G_STRUCT_OFFSET(SylPluginClass,
175
                                             textview_menu_popup),
176
                             NULL, NULL,
177
                             syl_plugin_marshal_VOID__POINTER_POINTER_STRING_STRING_POINTER,
178
                             G_TYPE_NONE,
179
                             5,
180
                             G_TYPE_POINTER,
181
                             G_TYPE_POINTER,
182
                             G_TYPE_STRING,
183
                             G_TYPE_STRING,
184
                             G_TYPE_POINTER);
185
        plugin_signals[COMPOSE_SEND] =
186
                g_signal_new("compose-send",
187
                             G_TYPE_FROM_CLASS(gobject_class),
188
                             G_SIGNAL_RUN_LAST,
189
                             G_STRUCT_OFFSET(SylPluginClass, compose_send),
190
                             NULL, NULL,
191
                             syl_plugin_marshal_BOOLEAN__POINTER_INT_INT_STRING_POINTER,
192
                             G_TYPE_BOOLEAN,
193
                             5,
194
                             G_TYPE_POINTER,
195
                             G_TYPE_INT,
196
                             G_TYPE_INT,
197
                             G_TYPE_STRING,
198
                             G_TYPE_POINTER);
199
        plugin_signals[MESSAGEVIEW_SHOW] =
200
                g_signal_new("messageview-show",
201
                             G_TYPE_FROM_CLASS(gobject_class),
202
                             G_SIGNAL_RUN_FIRST,
203
                             G_STRUCT_OFFSET(SylPluginClass, messageview_show),
204
                             NULL, NULL,
205
                             syl_plugin_marshal_VOID__POINTER_POINTER_BOOLEAN,
206
                             G_TYPE_NONE,
207
                             3,
208
                             G_TYPE_POINTER,
209
                             G_TYPE_POINTER,
210
                             G_TYPE_BOOLEAN);
211

    
212
        plugin_signals[INC_MAIL_START] =
213
                g_signal_new("inc-mail-start",
214
                             G_TYPE_FROM_CLASS(gobject_class),
215
                             G_SIGNAL_RUN_FIRST,
216
                             G_STRUCT_OFFSET(SylPluginClass, inc_mail_start),
217
                             NULL, NULL,
218
                             g_cclosure_marshal_VOID__POINTER,
219
                             G_TYPE_NONE,
220
                             1,
221
                             G_TYPE_POINTER);
222
        plugin_signals[INC_MAIL_FINISHED] =
223
                g_signal_new("inc-mail-finished",
224
                             G_TYPE_FROM_CLASS(gobject_class),
225
                             G_SIGNAL_RUN_FIRST,
226
                             G_STRUCT_OFFSET(SylPluginClass, inc_mail_finished),
227
                             NULL, NULL,
228
                             g_cclosure_marshal_VOID__INT,
229
                             G_TYPE_NONE,
230
                             1,
231
                             G_TYPE_INT);
232

    
233
        plugin_signals[PREFS_COMMON_OPEN] =
234
                g_signal_new("prefs-common-open",
235
                             G_TYPE_FROM_CLASS(gobject_class),
236
                             G_SIGNAL_RUN_FIRST,
237
                             G_STRUCT_OFFSET(SylPluginClass, prefs_common_open),
238
                             NULL, NULL,
239
                             g_cclosure_marshal_VOID__POINTER,
240
                             G_TYPE_NONE,
241
                             1,
242
                             G_TYPE_POINTER);
243
        plugin_signals[PREFS_ACCOUNT_OPEN] =
244
                g_signal_new("prefs-account-open",
245
                             G_TYPE_FROM_CLASS(gobject_class),
246
                             G_SIGNAL_RUN_FIRST,
247
                             G_STRUCT_OFFSET(SylPluginClass, prefs_account_open),
248
                             NULL, NULL,
249
                             syl_plugin_marshal_VOID__POINTER_POINTER,
250
                             G_TYPE_NONE,
251
                             2,
252
                             G_TYPE_POINTER,
253
                             G_TYPE_POINTER);
254
        plugin_signals[PREFS_FILTER_OPEN] =
255
                g_signal_new("prefs-filter-open",
256
                             G_TYPE_FROM_CLASS(gobject_class),
257
                             G_SIGNAL_RUN_FIRST,
258
                             G_STRUCT_OFFSET(SylPluginClass, prefs_filter_open),
259
                             NULL, NULL,
260
                             g_cclosure_marshal_VOID__POINTER,
261
                             G_TYPE_NONE,
262
                             1,
263
                             G_TYPE_POINTER);
264
        plugin_signals[PREFS_FILTER_EDIT_OPEN] =
265
                g_signal_new("prefs-filter-edit-open",
266
                             G_TYPE_FROM_CLASS(gobject_class),
267
                             G_SIGNAL_RUN_FIRST,
268
                             G_STRUCT_OFFSET(SylPluginClass, prefs_filter_edit_open),
269
                             NULL, NULL,
270
                             syl_plugin_marshal_VOID__POINTER_STRING_STRING_POINTER,
271
                             G_TYPE_NONE,
272
                             4,
273
                             G_TYPE_POINTER,
274
                             G_TYPE_STRING,
275
                             G_TYPE_STRING,
276
                             G_TYPE_POINTER);
277
        plugin_signals[PREFS_TEMPLATE_OPEN] =
278
                g_signal_new("prefs-template-open",
279
                             G_TYPE_FROM_CLASS(gobject_class),
280
                             G_SIGNAL_RUN_FIRST,
281
                             G_STRUCT_OFFSET(SylPluginClass, prefs_template_open),
282
                             NULL, NULL,
283
                             g_cclosure_marshal_VOID__POINTER,
284
                             G_TYPE_NONE,
285
                             1,
286
                             G_TYPE_POINTER);
287
        plugin_signals[PLUGIN_MANAGER_OPEN] =
288
                g_signal_new("plugin-manager-open",
289
                             G_TYPE_FROM_CLASS(gobject_class),
290
                             G_SIGNAL_RUN_FIRST,
291
                             G_STRUCT_OFFSET(SylPluginClass, plugin_manager_open),
292
                             NULL, NULL,
293
                             g_cclosure_marshal_VOID__POINTER,
294
                             G_TYPE_NONE,
295
                             1,
296
                             G_TYPE_POINTER);
297
}
298

    
299
void syl_plugin_signal_connect(const gchar *name, GCallback callback,
300
                               gpointer data)
301
{
302
        g_return_if_fail(plugin_obj != NULL);
303

    
304
        g_signal_connect(plugin_obj, name, callback, data);
305
}
306

    
307
void syl_plugin_signal_disconnect(gpointer func, gpointer data)
308
{
309
        g_return_if_fail(plugin_obj != NULL);
310

    
311
        g_signal_handlers_disconnect_by_func(plugin_obj, func, data);
312
}
313

    
314
void syl_plugin_signal_emit(const gchar *name, ...)
315
{
316
        guint signal_id;
317

    
318
        g_return_if_fail(plugin_obj != NULL);
319

    
320
        if (g_signal_parse_name(name, G_TYPE_FROM_INSTANCE(plugin_obj), &signal_id, NULL, FALSE)) {
321
                 \
322
                                va_list var_args;
323
                va_start(var_args, name);
324
                g_signal_emit_valist(plugin_obj, signal_id, 0, var_args);
325
                va_end(var_args);
326
        } else
327
                g_warning("%s: signal '%s' not found", G_STRLOC, name);
328
}
329

    
330
gint syl_plugin_init_lib(void)
331
{
332
        if (!g_module_supported()) {
333
                g_warning("Plug-in is not supported.");
334
                return -1;
335
        }
336

    
337
        if (!sym_table) {
338
                sym_table = g_hash_table_new(g_str_hash, g_str_equal);
339
        }
340

    
341
        if (!plugin_obj) {
342
                plugin_obj = g_object_new(SYL_TYPE_PLUGIN, NULL);
343
        }
344

    
345
        return 0;
346
}
347

    
348
gint syl_plugin_load(const gchar *name)
349
{
350
        GModule *module;
351
        SylPluginLoadFunc load_func = NULL;
352
        gchar *file;
353

    
354
        g_return_val_if_fail(plugin_obj != NULL, -1);
355
        g_return_val_if_fail(name != NULL, -1);
356

    
357
        debug_print("syl_plugin_load: loading %s\n", name);
358

    
359
        if (!g_path_is_absolute(name))
360
                file = g_strconcat(PLUGINDIR, G_DIR_SEPARATOR_S, name, NULL);
361
        else
362
                file = g_strdup(name);
363

    
364
        module = g_module_open(file, G_MODULE_BIND_LAZY);
365
        if (!module) {
366
                g_warning("Cannot open module: %s: %s", name, g_module_error());
367
                g_free(file);
368
                return -1;
369
        }
370
        if (g_slist_find(module_list, module)) {
371
                g_warning("Module %s is already loaded", name);
372
                g_free(file);
373
                return -1;
374
        }
375

    
376
        if (g_module_symbol(module, "plugin_load", (gpointer)&load_func)) {
377
                if (!syl_plugin_check_version(module)) {
378
                        g_warning("Version check failed. Skipping: %s", name);
379
                        g_module_close(module);
380
                        g_free(file);
381
                        return -1;
382
                }
383

    
384
                debug_print("calling plugin_load() in %s\n",
385
                            g_module_name(module));
386
                load_func();
387
                module_list = g_slist_prepend(module_list, module);
388
                g_signal_emit(plugin_obj, plugin_signals[PLUGIN_LOAD], 0, module);
389
        } else {
390
                g_warning("Cannot get symbol: %s: %s", name, g_module_error());
391
                g_module_close(module);
392
                g_free(file);
393
                return -1;
394
        }
395

    
396
        g_free(file);
397

    
398
        return 0;
399
}
400

    
401
gint syl_plugin_load_all(const gchar *dir)
402
{
403
        GDir *d;
404
        const gchar *dir_name;
405
        gchar *path;
406
        gint count = 0;
407

    
408
        g_return_val_if_fail(dir != NULL, -1);
409

    
410
        debug_print("loading plugins from directory: %s\n", dir);
411

    
412
        if ((d = g_dir_open(dir, 0, NULL)) == NULL) {
413
                debug_print("failed to open directory: %s\n", dir);
414
                return -1;
415
        }
416

    
417
        while ((dir_name = g_dir_read_name(d)) != NULL) {
418
                if (!g_str_has_suffix(dir_name, "." G_MODULE_SUFFIX))
419
                        continue;
420
                path = g_strconcat(dir, G_DIR_SEPARATOR_S, dir_name, NULL);
421
                if (syl_plugin_load(path) == 0)
422
                        count++;
423
                g_free(path);
424
        }
425

    
426
        g_dir_close(d);
427

    
428
        return count;
429
}
430

    
431
void syl_plugin_unload_all(void)
432
{
433
        GSList *cur;
434

    
435
        g_return_if_fail(plugin_obj != NULL);
436

    
437
        for (cur = module_list; cur != NULL; cur = cur->next) {
438
                GModule *module = (GModule *)cur->data;
439
                SylPluginUnloadFunc unload_func = NULL;
440

    
441
                if (g_module_symbol(module, "plugin_unload",
442
                                    (gpointer)&unload_func)) {
443
                        g_signal_emit(plugin_obj, plugin_signals[PLUGIN_UNLOAD],
444
                                      0, module);
445
                        debug_print("calling plugin_unload() in %s\n",
446
                                    g_module_name(module));
447
                        unload_func();
448
                } else {
449
                        g_warning("Cannot get symbol: %s", g_module_error());
450
                }
451
                if (!g_module_close(module)) {
452
                        g_warning("Module unload failed: %s", g_module_error());
453
                }
454
        }
455

    
456
        g_slist_free(module_list);
457
        module_list = NULL;
458
}
459

    
460
GSList *syl_plugin_get_module_list(void)
461
{
462
        return module_list;
463
}
464

    
465
SylPluginInfo *syl_plugin_get_info(GModule *module)
466
{
467
        SylPluginInfo * (*plugin_info_func)(void);
468

    
469
        g_return_val_if_fail(module != NULL, NULL);
470

    
471
        debug_print("getting plugin information of %s\n",
472
                    g_module_name(module));
473

    
474
        if (g_module_symbol(module, "plugin_info",
475
                            (gpointer)&plugin_info_func)) {
476
                debug_print("calling plugin_info() in %s\n",
477
                            g_module_name(module));
478
                return plugin_info_func();
479
        } else {
480
                g_warning("Cannot get symbol: %s: %s", g_module_name(module),
481
                          g_module_error());
482
                return NULL;
483
        }
484
}
485

    
486
gboolean syl_plugin_check_version(GModule *module)
487
{
488
        gint (*version_func)(void);
489
        gint ver;
490
        gint a_major;
491
        gint a_minor;
492
        gint p_major;
493
        gint p_minor;
494

    
495
        g_return_val_if_fail(module != NULL, FALSE);
496

    
497
        if (g_module_symbol(module, "plugin_interface_version",
498
                            (gpointer)&version_func)) {
499
                debug_print("calling plugin_interface_version() in %s\n",
500
                            g_module_name(module));
501
                ver = version_func();
502
        } else {
503
                g_warning("Cannot get symbol: %s: %s", g_module_name(module),
504
                          g_module_error());
505
                return FALSE;
506
        }
507

    
508
        a_major = SYL_PLUGIN_INTERFACE_VERSION & 0xff00;
509
        a_minor = SYL_PLUGIN_INTERFACE_VERSION & 0x00ff;
510
        p_major = ver & 0xff00;
511
        p_minor = ver & 0x00ff;
512
        if (a_major == p_major && a_minor >= p_minor) {
513
                debug_print("Version OK: plugin: %d, app: %d\n",
514
                            ver, SYL_PLUGIN_INTERFACE_VERSION);
515
                return TRUE;
516
        } else {
517
                g_warning("Plugin interface version mismatch: plugin: %d, app: %d", ver, SYL_PLUGIN_INTERFACE_VERSION);
518
                return FALSE;
519
        }
520
}
521

    
522
gint syl_plugin_add_symbol(const gchar *name, gpointer sym)
523
{
524
        g_hash_table_insert(sym_table, (gpointer)name, sym);
525
        return 0;
526
}
527

    
528
gpointer syl_plugin_lookup_symbol(const gchar *name)
529
{
530
        return g_hash_table_lookup(sym_table, name);
531
}
532

    
533
const gchar *syl_plugin_get_prog_version(void)
534
{
535
        gpointer sym;
536

    
537
        sym = syl_plugin_lookup_symbol("prog_version");
538
        return (gchar *)sym;
539
}
540

    
541
void syl_plugin_main_window_lock(void)
542
{
543
        CALL_VOID_POINTER(syl_plugin_main_window_get,
544
                          "main_window_lock");
545
}
546

    
547
void syl_plugin_main_window_unlock(void)
548
{
549
        CALL_VOID_POINTER(syl_plugin_main_window_get,
550
                          "main_window_unlock");
551
}
552

    
553
gpointer syl_plugin_main_window_get(void)
554
{
555
        gpointer (*func)(void);
556

    
557
        func = syl_plugin_lookup_symbol("main_window_get");
558
        return SAFE_CALL_RET(func);
559
}
560

    
561
void syl_plugin_main_window_popup(gpointer mainwin)
562
{
563
        void (*func)(gpointer);
564

    
565
        func = syl_plugin_lookup_symbol("main_window_popup");
566
        SAFE_CALL_ARG1(func, mainwin);
567
}
568

    
569
GtkWidget *syl_plugin_main_window_get_statusbar(void)
570
{
571
        gpointer widget;
572

    
573
        widget = syl_plugin_lookup_symbol("main_window_statusbar");
574
        return GTK_WIDGET(widget);
575
}
576

    
577
void syl_plugin_app_will_exit(gboolean force)
578
{
579
        void (*func)(gboolean);
580

    
581
        func = syl_plugin_lookup_symbol("app_will_exit");
582
        SAFE_CALL_ARG1(func, force);
583
}
584

    
585
static GtkItemFactory *get_item_factory(const gchar *path)
586
{
587
        GtkItemFactory *ifactory;
588

    
589
        if (!path)
590
                return NULL;
591

    
592
        if (strncmp(path, "<Main>", 6) == 0)
593
                ifactory = syl_plugin_lookup_symbol("main_window_menu_factory");
594
        else if (strncmp(path, "<MailFolder>", 12) == 0)
595
                ifactory = syl_plugin_lookup_symbol("folderview_mail_popup_factory");
596
        else if (strncmp(path, "<IMAPFolder>", 12) == 0)
597
                ifactory = syl_plugin_lookup_symbol("folderview_imap_popup_factory");
598
        else if (strncmp(path, "<NewsFolder>", 12) == 0)
599
                ifactory = syl_plugin_lookup_symbol("folderview_news_popup_factory");
600
        else if (strncmp(path, "<SummaryView>", 13) == 0)
601
                ifactory = syl_plugin_lookup_symbol("summaryview_popup_factory");
602
        else
603
                ifactory = syl_plugin_lookup_symbol("main_window_menu_factory");
604

    
605
        return ifactory;
606
}
607

    
608
gint syl_plugin_add_menuitem(const gchar *parent, const gchar *label,
609
                             SylPluginCallbackFunc func, gpointer data)
610
{
611
        GtkItemFactory *ifactory;
612
        GtkWidget *menu;
613
        GtkWidget *menuitem;
614

    
615
        if (!parent)
616
                return -1;
617

    
618
        ifactory = get_item_factory(parent);
619
        if (!ifactory)
620
                return -1;
621

    
622
        menu = gtk_item_factory_get_widget(ifactory, parent);
623
        if (!menu)
624
                return -1;
625

    
626
        if (label)
627
                menuitem = gtk_menu_item_new_with_label(label);
628
        else {
629
                menuitem = gtk_menu_item_new();
630
                gtk_widget_set_sensitive(menuitem, FALSE);
631
        }
632
        gtk_widget_show(menuitem);
633
        gtk_menu_append(GTK_MENU(menu), menuitem);
634
        if (func)
635
                g_signal_connect(G_OBJECT(menuitem), "activate",
636
                                 G_CALLBACK(func), data);
637

    
638
        return 0;
639
}
640

    
641
gint syl_plugin_add_factory_item(const gchar *parent, const gchar *label,
642
                                 SylPluginCallbackFunc func, gpointer data)
643
{
644
        GtkItemFactory *ifactory;
645
        GtkItemFactoryEntry entry = {NULL, NULL, NULL, 0, NULL};
646

    
647
        if (!parent)
648
                return -1;
649

    
650
        ifactory = get_item_factory(parent);
651
        if (!ifactory)
652
                return -1;
653

    
654
        if (label) {
655
                entry.path = (gchar *)label;
656
                if (g_str_has_suffix(label, "/---"))
657
                        entry.item_type = "<Separator>";
658
                else
659
                        entry.item_type = NULL;
660
        } else {
661
                entry.path = "/---";
662
                entry.item_type = "<Separator>";
663
        }
664
        entry.callback = func;
665
        g_print("entry.path = %s\n", entry.path);
666

    
667
        gtk_item_factory_create_item(ifactory, &entry, data, 2);
668

    
669
        return 0;
670
}
671

    
672
void syl_plugin_menu_set_sensitive(const gchar *path, gboolean sensitive)
673
{
674
        GtkItemFactory *ifactory;
675
        GtkWidget *widget;
676

    
677
        g_return_if_fail(path != NULL);
678

    
679
        ifactory = get_item_factory(path);
680
        if (!ifactory)
681
                return;
682

    
683
        widget = gtk_item_factory_get_item(ifactory, path);
684
        gtk_widget_set_sensitive(widget, sensitive);
685
}
686

    
687
void syl_plugin_menu_set_sensitive_all(GtkMenuShell *menu_shell,
688
                                       gboolean sensitive)
689
{
690
        GList *cur;
691

    
692
        for (cur = menu_shell->children; cur != NULL; cur = cur->next)
693
                gtk_widget_set_sensitive(GTK_WIDGET(cur->data), sensitive);
694
}
695

    
696
void syl_plugin_menu_set_active(const gchar *path, gboolean is_active)
697
{
698
        GtkItemFactory *ifactory;
699
        GtkWidget *widget;
700

    
701
        g_return_if_fail(path != NULL);
702

    
703
        ifactory = get_item_factory(path);
704
        if (!ifactory)
705
                return;
706

    
707
        widget = gtk_item_factory_get_item(ifactory, path);
708
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), is_active);
709
}
710

    
711
gpointer syl_plugin_folderview_get(void)
712
{
713
        gpointer (*func)(void);
714
        GETFUNC("folderview_get");
715
        return SAFE_CALL_RET(func);
716
}
717

    
718
void syl_plugin_folderview_add_sub_widget(GtkWidget *widget)
719
{
720
        void (*func)(gpointer, GtkWidget *);
721
        gpointer folderview;
722

    
723
        folderview = syl_plugin_folderview_get();
724
        if (folderview) {
725
                GETFUNC("folderview_add_sub_widget");
726
                SAFE_CALL_ARG2(func, folderview, widget);
727
        }
728
}
729

    
730
void syl_plugin_folderview_select(FolderItem *item)
731
{
732
        void (*func)(gpointer, FolderItem *);
733
        gpointer folderview;
734

    
735
        folderview = syl_plugin_folderview_get();
736
        if (folderview) {
737
                GETFUNC("folderview_select");
738
                SAFE_CALL_ARG2(func, folderview, item);
739
        }
740
}
741

    
742
void syl_plugin_folderview_unselect(void)
743
{
744
        CALL_VOID_POINTER(syl_plugin_folderview_get,
745
                          "folderview_unselect");
746
}
747

    
748
void syl_plugin_folderview_select_next_unread(void)
749
{
750
        CALL_VOID_POINTER(syl_plugin_folderview_get,
751
                          "folderview_select_next_unread");
752
}
753

    
754
FolderItem *syl_plugin_folderview_get_selected_item(void)
755
{
756
        FolderItem * (*func)(gpointer);
757
        gpointer folderview;
758

    
759
        folderview = syl_plugin_folderview_get();
760
        if (folderview) {
761
                GETFUNC("folderview_get_selected_item");
762
                return SAFE_CALL_ARG1_RET(func, folderview);
763
        }
764

    
765
        return NULL;
766
}
767

    
768
gint syl_plugin_folderview_check_new(Folder *folder)
769
{
770
        gint (*func)(Folder *);
771
        GETFUNC("folderview_check_new");
772
        return SAFE_CALL_ARG1_RET_VAL(func, folder, FALSE);
773
}
774

    
775
gint syl_plugin_folderview_check_new_item(FolderItem *item)
776
{
777
        gint (*func)(FolderItem *);
778
        GETFUNC("folderview_check_new_item");
779
        return SAFE_CALL_ARG1_RET_VAL(func, item, FALSE);
780
}
781

    
782
gint syl_plugin_folderview_check_new_all(void)
783
{
784
        gint (*func)(void);
785
        GETFUNC("folderview_check_new_all");
786
        return SAFE_CALL_RET_VAL(func, FALSE);
787
}
788

    
789
void syl_plugin_folderview_update_item(FolderItem *item,
790
                                       gboolean update_summary)
791
{
792
        void (*func)(FolderItem *, gboolean);
793
        GETFUNC("folderview_update_item");
794
        SAFE_CALL_ARG2(func, item, update_summary);
795
}
796

    
797
void syl_plugin_folderview_update_item_foreach(GHashTable *table,
798
                                               gboolean update_summary)
799
{
800
        void (*func)(GHashTable *, gboolean);
801
        GETFUNC("folderview_update_item_foreach");
802
        SAFE_CALL_ARG2(func, table, update_summary);
803
}
804

    
805
void syl_plugin_folderview_update_all_updated(gboolean update_summary)
806
{
807
        void (*func)(gboolean);
808
        GETFUNC("folderview_update_all_updated");
809
        SAFE_CALL_ARG1(func, update_summary);
810
}
811

    
812
void syl_plugin_folderview_check_new_selected(void)
813
{
814
        CALL_VOID_POINTER(syl_plugin_folderview_get,
815
                          "folderview_check_new_selected");
816
}
817

    
818
gpointer syl_plugin_summary_view_get(void)
819
{
820
        gpointer sym;
821

    
822
        sym = syl_plugin_lookup_symbol("summaryview");
823
        return sym;
824
}
825

    
826
void syl_plugin_summary_select_by_msgnum(guint msgnum)
827
{
828
        void (*func)(gpointer, guint);
829
        gpointer summary;
830

    
831
        summary = syl_plugin_summary_view_get();
832
        if (summary) {
833
                func = syl_plugin_lookup_symbol("summary_select_by_msgnum");
834
                SAFE_CALL_ARG2(func, summary, msgnum);
835
        }
836
}
837

    
838
gboolean syl_plugin_summary_select_by_msginfo(MsgInfo *msginfo)
839
{
840
        gboolean (*func)(gpointer, MsgInfo *);
841
        gpointer summary;
842

    
843
        summary = syl_plugin_summary_view_get();
844
        if (summary) {
845
                func = syl_plugin_lookup_symbol("summary_select_by_msginfo");
846
                return SAFE_CALL_ARG2_RET_VAL(func, summary, msginfo, FALSE);
847
        }
848

    
849
        return FALSE;
850
}
851

    
852
void syl_plugin_open_message(const gchar *folder_id, guint msgnum)
853
{
854
        FolderItem *item;
855
        MsgInfo *msginfo;
856

    
857
        item = folder_find_item_from_identifier(folder_id);
858
        msginfo = folder_item_get_msginfo(item, msgnum);
859

    
860
        if (msginfo) {
861
                if (!syl_plugin_summary_select_by_msginfo(msginfo)) {
862
                        syl_plugin_open_message_by_new_window(msginfo);
863
                }
864
                procmsg_msginfo_free(msginfo);
865
        }
866
}
867

    
868
void syl_plugin_summary_show_queued_msgs(void)
869
{
870
        CALL_VOID_POINTER(syl_plugin_summary_view_get,
871
                          "summary_show_queued_msgs");
872
}
873

    
874
void syl_plugin_summary_lock(void)
875
{
876
        CALL_VOID_POINTER(syl_plugin_summary_view_get,
877
                          "summary_lock");
878
}
879

    
880
void syl_plugin_summary_unlock(void)
881
{
882
        CALL_VOID_POINTER(syl_plugin_summary_view_get,
883
                          "summary_unlock");
884
}
885

    
886
gboolean syl_plugin_summary_is_locked(void)
887
{
888
        gboolean (*func)(gpointer);
889
        gpointer summary;
890

    
891
        summary = syl_plugin_summary_view_get();
892
        if (summary) {
893
                GETFUNC("summary_is_locked");
894
                return SAFE_CALL_ARG1_RET_VAL(func, summary, FALSE);
895
        }
896

    
897
        return FALSE;
898
}
899

    
900
gboolean syl_plugin_summary_is_read_locked(void)
901
{
902
        gboolean (*func)(gpointer);
903
        gpointer summary;
904

    
905
        summary = syl_plugin_summary_view_get();
906
        if (summary) {
907
                GETFUNC("summary_is_read_locked");
908
                return SAFE_CALL_ARG1_RET_VAL(func, summary, FALSE);
909
        }
910

    
911
        return FALSE;
912
}
913

    
914
void syl_plugin_summary_write_lock(void)
915
{
916
        CALL_VOID_POINTER(syl_plugin_summary_view_get,
917
                          "summary_write_lock");
918
}
919

    
920
void syl_plugin_summary_write_unlock(void)
921
{
922
        CALL_VOID_POINTER(syl_plugin_summary_view_get,
923
                          "summary_write_unlock");
924
}
925

    
926
gboolean syl_plugin_summary_is_write_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_write_locked");
934
                return SAFE_CALL_ARG1_RET_VAL(func, summary, FALSE);
935
        }
936

    
937
        return FALSE;
938
}
939

    
940
FolderItem *syl_plugin_summary_get_current_folder(void)
941
{
942
        FolderItem * (*func)(gpointer);
943
        gpointer summary;
944

    
945
        summary = syl_plugin_summary_view_get();
946
        if (summary) {
947
                GETFUNC("summary_get_current_folder");
948
                return SAFE_CALL_ARG1_RET(func, summary);
949
        }
950

    
951
        return NULL;
952
}
953

    
954
gint syl_plugin_summary_get_selection_type(void)
955
{
956
        gint (*func)(gpointer);
957
        gpointer summary;
958

    
959
        summary = syl_plugin_summary_view_get();
960
        if (summary) {
961
                GETFUNC("summary_get_selection_type");
962
                return SAFE_CALL_ARG1_RET_VAL(func, summary, 0);
963
        }
964

    
965
        return 0;
966
}
967

    
968
GSList *syl_plugin_summary_get_selected_msg_list(void)
969
{
970
        GSList * (*func)(gpointer);
971
        gpointer summary;
972

    
973
        summary = syl_plugin_summary_view_get();
974
        if (summary) {
975
                GETFUNC("summary_get_selected_msg_list");
976
                return SAFE_CALL_ARG1_RET(func, summary);
977
        }
978

    
979
        return NULL;
980
}
981

    
982
GSList *syl_plugin_summary_get_msg_list(void)
983
{
984
        GSList * (*func)(gpointer);
985
        gpointer summary;
986

    
987
        summary = syl_plugin_summary_view_get();
988
        if (summary) {
989
                GETFUNC("summary_get_msg_list");
990
                return SAFE_CALL_ARG1_RET(func, summary);
991
        }
992

    
993
        return NULL;
994
}
995

    
996
void syl_plugin_summary_redisplay_msg(void)
997
{
998
        CALL_VOID_POINTER(syl_plugin_summary_view_get,
999
                          "summary_redisplay_msg");
1000
}
1001

    
1002
void syl_plugin_summary_open_msg(void)
1003
{
1004
        CALL_VOID_POINTER(syl_plugin_summary_view_get,
1005
                          "summary_open_msg");
1006
}
1007

    
1008
void syl_plugin_summary_view_source(void)
1009
{
1010
        CALL_VOID_POINTER(syl_plugin_summary_view_get,
1011
                          "summary_view_source");
1012
}
1013

    
1014
void syl_plugin_summary_reedit(void)
1015
{
1016
        CALL_VOID_POINTER(syl_plugin_summary_view_get,
1017
                          "summary_reedit");
1018
}
1019

    
1020
void syl_plugin_summary_update_selected_rows(void)
1021
{
1022
        CALL_VOID_POINTER(syl_plugin_summary_view_get,
1023
                          "summary_update_selected_rows");
1024
}
1025

    
1026
void syl_plugin_summary_update_by_msgnum(guint msgnum)
1027
{
1028
        void (*func)(gpointer, guint);
1029
        gpointer summary;
1030

    
1031
        summary = syl_plugin_summary_view_get();
1032
        if (summary) {
1033
                func = syl_plugin_lookup_symbol("summary_update_by_msgnum");
1034
                SAFE_CALL_ARG2(func, summary, msgnum);
1035
        }
1036
}
1037

    
1038
gpointer syl_plugin_messageview_create_with_new_window(void)
1039
{
1040
        gpointer (*func)(void);
1041

    
1042
        func = syl_plugin_lookup_symbol("messageview_create_with_new_window");
1043
        return SAFE_CALL_RET(func);
1044
}
1045

    
1046
void syl_plugin_open_message_by_new_window(MsgInfo *msginfo)
1047
{
1048
        gpointer msgview;
1049
        gpointer (*func)(gpointer, MsgInfo *, gboolean);
1050

    
1051
        msgview = syl_plugin_messageview_create_with_new_window();
1052
        if (msgview) {
1053
                func = syl_plugin_lookup_symbol("messageview_show");
1054
                SAFE_CALL_ARG3(func, msgview, msginfo, FALSE);
1055
        }
1056
}
1057

    
1058

    
1059
gpointer syl_plugin_compose_new(PrefsAccount *account, FolderItem *item,
1060
                                const gchar *mailto, GPtrArray *attach_files)
1061
{
1062
        gpointer (*func)(PrefsAccount *, FolderItem *, const gchar *,
1063
                         GPtrArray *);
1064

    
1065
        func = syl_plugin_lookup_symbol("compose_new");
1066
        return SAFE_CALL_ARG4_RET(func, account, item, mailto, attach_files);
1067
}
1068

    
1069
void syl_plugin_compose_entry_set(gpointer compose, const gchar *text,
1070
                                  gint type)
1071
{
1072
        void (*func)(gpointer, const gchar *, gint);
1073

    
1074
        func = syl_plugin_lookup_symbol("compose_entry_set");
1075
        SAFE_CALL_ARG3(func, compose, text, type);
1076
}
1077

    
1078
void syl_plugin_compose_entry_append(gpointer compose, const gchar *text,
1079
                                     gint type)
1080
{
1081
        void (*func)(gpointer, const gchar *, gint);
1082

    
1083
        func = syl_plugin_lookup_symbol("compose_entry_append");
1084
        SAFE_CALL_ARG3(func, compose, text, type);
1085
}
1086

    
1087
gchar *syl_plugin_compose_entry_get_text(gpointer compose, gint type)
1088
{
1089
        gchar * (*func)(gpointer, gint);
1090

    
1091
        func = syl_plugin_lookup_symbol("compose_entry_get_text");
1092
        return SAFE_CALL_ARG2_RET(func, compose, type);
1093
}
1094

    
1095
void syl_plugin_compose_lock(gpointer compose)
1096
{
1097
        void (*func)(gpointer);
1098

    
1099
        func = syl_plugin_lookup_symbol("compose_lock");
1100
        SAFE_CALL_ARG1(func, compose);
1101
}
1102

    
1103
void syl_plugin_compose_unlock(gpointer compose)
1104
{
1105
        void (*func)(gpointer);
1106

    
1107
        func = syl_plugin_lookup_symbol("compose_unlock");
1108
        SAFE_CALL_ARG1(func, compose);
1109
}
1110

    
1111

    
1112
FolderItem *syl_plugin_folder_sel(Folder *cur_folder, gint sel_type,
1113
                                  const gchar *default_folder)
1114
{
1115
        FolderItem * (*func)(Folder *, gint, const gchar *);
1116

    
1117
        func = syl_plugin_lookup_symbol("foldersel_folder_sel");
1118
        return SAFE_CALL_ARG3_RET(func, cur_folder, sel_type, default_folder);
1119
}
1120

    
1121
FolderItem *syl_plugin_folder_sel_full(Folder *cur_folder, gint sel_type,
1122
                                       const gchar *default_folder,
1123
                                       const gchar *message)
1124
{
1125
        FolderItem * (*func)(Folder *, gint, const gchar *, const gchar *);
1126

    
1127
        func = syl_plugin_lookup_symbol("foldersel_folder_sel_full");
1128
        return SAFE_CALL_ARG4_RET(func, cur_folder, sel_type, default_folder,
1129
                                  message);
1130
}
1131

    
1132
gchar *syl_plugin_input_dialog(const gchar *title, const gchar *message,
1133
                               const gchar *default_string)
1134
{
1135
        gchar * (*func)(const gchar *, const gchar *, const gchar *);
1136

    
1137
        func = syl_plugin_lookup_symbol("input_dialog");
1138
        return SAFE_CALL_ARG3_RET(func, title, message, default_string);
1139
}
1140

    
1141
gchar *syl_plugin_input_dialog_with_invisible(const gchar *title,
1142
                                              const gchar *message,
1143
                                              const gchar *default_string)
1144
{
1145
        gchar * (*func)(const gchar *, const gchar *, const gchar *);
1146

    
1147
        func = syl_plugin_lookup_symbol("input_dialog_with_invisible");
1148
        return SAFE_CALL_ARG3_RET(func, title, message, default_string);
1149
}
1150

    
1151
void syl_plugin_manage_window_set_transient(GtkWindow *window)
1152
{
1153
        void (*func)(GtkWindow *);
1154

    
1155
        func = syl_plugin_lookup_symbol("manage_window_set_transient");
1156
        SAFE_CALL_ARG1(func, window);
1157
}
1158

    
1159
void syl_plugin_manage_window_signals_connect(GtkWindow *window)
1160
{
1161
        void (*func)(GtkWindow *);
1162

    
1163
        func = syl_plugin_lookup_symbol("manage_window_signals_connect");
1164
        SAFE_CALL_ARG1(func, window);
1165
}
1166

    
1167
GtkWidget *syl_plugin_manage_window_get_focus_window(void)
1168
{
1169
        GtkWidget * (*func)(void);
1170

    
1171
        func = syl_plugin_lookup_symbol("manage_window_get_focus_window");
1172
        return SAFE_CALL_RET(func);
1173
}
1174

    
1175
void syl_plugin_inc_mail(void)
1176
{
1177
        void (*func)(gpointer);
1178

    
1179
        func = syl_plugin_lookup_symbol("inc_mail");
1180
        SAFE_CALL_ARG1(func, syl_plugin_main_window_get());
1181
}
1182

    
1183
gboolean syl_plugin_inc_is_active(void)
1184
{
1185
        gboolean (*func)(void);
1186

    
1187
        func = syl_plugin_lookup_symbol("inc_is_active");
1188
        return SAFE_CALL_RET_VAL(func, FALSE);
1189
}
1190

    
1191
void syl_plugin_inc_lock(void)
1192
{
1193
        void (*func)(void);
1194

    
1195
        func = syl_plugin_lookup_symbol("inc_lock");
1196
        SAFE_CALL(func);
1197
}
1198

    
1199
void syl_plugin_inc_unlock(void)
1200
{
1201
        void (*func)(void);
1202

    
1203
        func = syl_plugin_lookup_symbol("inc_unlock");
1204
        SAFE_CALL(func);
1205
}
1206

    
1207
void syl_plugin_update_check(gboolean show_dialog_always)
1208
{
1209
        void (*func)(gboolean);
1210

    
1211
        func = syl_plugin_lookup_symbol("update_check");
1212
        SAFE_CALL_ARG1(func, show_dialog_always);
1213
}
1214

    
1215
void syl_plugin_update_check_set_check_url(const gchar *url)
1216
{
1217
        void (*func)(const gchar *);
1218

    
1219
        func = syl_plugin_lookup_symbol("update_check_set_check_url");
1220
        SAFE_CALL_ARG1(func, url);
1221
}
1222

    
1223
const gchar *syl_plugin_update_check_get_check_url(void)
1224
{
1225
        const gchar * (*func)(void);
1226

    
1227
        func = syl_plugin_lookup_symbol("update_check_get_check_url");
1228
        return SAFE_CALL_RET(func);
1229
}
1230

    
1231
void syl_plugin_update_check_set_download_url(const gchar *url)
1232
{
1233
        void (*func)(const gchar *);
1234

    
1235
        func = syl_plugin_lookup_symbol("update_check_set_download_url");
1236
        SAFE_CALL_ARG1(func, url);
1237
}
1238

    
1239
const gchar *syl_plugin_update_check_get_download_url(void)
1240
{
1241
        const gchar * (*func)(void);
1242

    
1243
        func = syl_plugin_lookup_symbol("update_check_get_download_url");
1244
        return SAFE_CALL_RET(func);
1245
}
1246

    
1247
void syl_plugin_update_check_set_jump_url(const gchar *url)
1248
{
1249
        void (*func)(const gchar *);
1250

    
1251
        func = syl_plugin_lookup_symbol("update_check_set_jump_url");
1252
        SAFE_CALL_ARG1(func, url);
1253
}
1254

    
1255
const gchar *syl_plugin_update_check_get_jump_url(void)
1256
{
1257
        const gchar * (*func)(void);
1258

    
1259
        func = syl_plugin_lookup_symbol("update_check_get_jump_url");
1260
        return SAFE_CALL_RET(func);
1261
}
1262

    
1263
void syl_plugin_update_check_set_check_plugin_url(const gchar *url)
1264
{
1265
        void (*func)(const gchar *);
1266

    
1267
        func = syl_plugin_lookup_symbol("update_check_set_check_plugin_url");
1268
        SAFE_CALL_ARG1(func, url);
1269
}
1270

    
1271
const gchar *syl_plugin_update_check_get_check_plugin_url(void)
1272
{
1273
        const gchar * (*func)(void);
1274

    
1275
        func = syl_plugin_lookup_symbol("update_check_get_check_plugin_url");
1276
        return SAFE_CALL_RET(func);
1277
}
1278

    
1279
void syl_plugin_update_check_set_jump_plugin_url(const gchar *url)
1280
{
1281
        void (*func)(const gchar *);
1282

    
1283
        func = syl_plugin_lookup_symbol("update_check_set_jump_plugin_url");
1284
        SAFE_CALL_ARG1(func, url);
1285
}
1286

    
1287
const gchar *syl_plugin_update_check_get_jump_plugin_url(void)
1288
{
1289
        const gchar * (*func)(void);
1290

    
1291
        func = syl_plugin_lookup_symbol("update_check_get_jump_plugin_url");
1292
        return SAFE_CALL_RET(func);
1293
}
1294

    
1295
gint syl_plugin_alertpanel_full(const gchar *title, const gchar *message,
1296
                                gint type, gint default_value,
1297
                                gboolean can_disable,
1298
                                const gchar *btn1_label,
1299
                                const gchar *btn2_label,
1300
                                const gchar *btn3_label)
1301
{
1302
        gint (*func)(const gchar *, const gchar *, gint, gint, gboolean,
1303
                        const gchar *, const gchar *, const gchar *);
1304

    
1305
        GETFUNC("alertpanel_full");
1306
        return func ? func(title, message, type, default_value, can_disable,
1307
                           btn1_label, btn2_label, btn3_label) : -1;
1308
}
1309

    
1310
gint syl_plugin_alertpanel(const gchar *title, const gchar *message,
1311
                           const gchar *btn1_label,
1312
                           const gchar *btn2_label,
1313
                           const gchar *btn3_label)
1314
{
1315
        gint (*func)(const gchar *, const gchar *,
1316
                        const gchar *, const gchar *, const gchar *);
1317

    
1318
        GETFUNC("alertpanel");
1319
        return func ? func(title, message, btn1_label, btn2_label, btn3_label)
1320
                : -1;
1321
}
1322

    
1323
void syl_plugin_alertpanel_message(const gchar *title, const gchar *message,
1324
                                   gint type)
1325
{
1326
        void (*func)(const gchar *, const gchar *, gint);
1327

    
1328
        GETFUNC("alertpanel_message");
1329
        SAFE_CALL_ARG3(func, title, message, type);
1330
}
1331

    
1332
gint syl_plugin_alertpanel_message_with_disable(const gchar *title,
1333
                                                const gchar *message,
1334
                                                gint type)
1335
{
1336
        gint (*func)(const gchar *, const gchar *, gint);
1337

    
1338
        GETFUNC("alertpanel_message_with_disable");
1339
        return SAFE_CALL_ARG3_RET_VAL(func, title, message, type, 0);
1340
}
1341

    
1342
gint syl_plugin_send_message(const gchar *file, PrefsAccount *ac,
1343
                             GSList *to_list)
1344
{
1345
        gint (*func)(const gchar *, PrefsAccount *, GSList *);
1346

    
1347
        GETFUNC("send_message");
1348
        return SAFE_CALL_ARG3_RET_VAL(func, file, ac, to_list, -1);
1349
}
1350

    
1351
gint syl_plugin_send_message_queue_all(FolderItem *queue, gboolean save_msgs,
1352
                                       gboolean filter_msgs)
1353
{
1354
        gint (*func)(FolderItem *, gboolean, gboolean);
1355

    
1356
        GETFUNC("send_message_queue_all");
1357
        return SAFE_CALL_ARG3_RET_VAL(func, queue, save_msgs, filter_msgs, -1);
1358
}
1359

    
1360
gint syl_plugin_send_message_set_reply_flag(const gchar *reply_target,
1361
                                            const gchar *msgid)
1362
{
1363
        gint (*func)(const gchar *, const gchar *);
1364

    
1365
        GETFUNC("send_message_set_reply_flag");
1366
        return SAFE_CALL_ARG2_RET_VAL(func, reply_target, msgid, -1);
1367
}
1368

    
1369
gint syl_plugin_send_message_set_forward_flags(const gchar *forward_targets)
1370
{
1371
        gint (*func)(const gchar *);
1372

    
1373
        GETFUNC("send_message_set_forward_flags");
1374
        return SAFE_CALL_ARG1_RET_VAL(func, forward_targets, -1);
1375
}