Statistics
| Revision:

root / src / plugin.c @ 2811

History | View | Annotate | Download (30.1 kB)

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