aboutsummaryrefslogtreecommitdiff
path: root/src/plugin.h
blob: 9b28dc5e90ae3bdffa06466c223224f509ef3d73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
/*
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
 * Copyright (C) 1999-2016 Hiroyuki Yamamoto
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef __PLUGIN_H__
#define __PLUGIN_H__

#include <glib.h>
#include <glib-object.h>
#include <gmodule.h>
#include <gtk/gtk.h>

#include "procmsg.h"
#include "folder.h"
#include "filter.h"
#include "plugin-types.h"

/* SylPlugin object */

#define SYL_TYPE_PLUGIN		(syl_plugin_get_type())
#define SYL_PLUGIN(obj)		(G_TYPE_CHECK_INSTANCE_CAST((obj), SYL_TYPE_PLUGIN, SylPlugin))
#define SYL_IS_PLUGIN(obj)	(G_TYPE_CHECK_INSTANCE_CAST((obj), SYL_TYPE_PLUGIN))
#define SYL_PLUGIN_CLASS(klass)	(G_TYPE_CHECK_CLASS_CAST((klass), SYL_TYPE_PLUGIN, SylPluginClass))
#define SYL_IS_PLUGIN_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE((klass), SYL_TYPE_PLUGIN))
#define SYL_PLUGIN_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS((obj), SYL_TYPE_PLUGIN, SylPluginClass))

typedef struct _SylPlugin	SylPlugin;
typedef struct _SylPluginClass	SylPluginClass;
typedef struct _SylPluginInfo	SylPluginInfo;

typedef void (*SylPluginLoadFunc)	(void);
typedef void (*SylPluginUnloadFunc)	(void);
typedef void (*SylPluginCallbackFunc)	(void);

#define SYL_PLUGIN_INTERFACE_VERSION	0x010a

struct _SylPlugin
{
	GObject parent_instance;
};

struct _SylPluginClass
{
	GObjectClass parent_class;

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

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

	void (* compose_created)	(GObject *obj, gpointer compose);
	void (* compose_destroy)	(GObject *obj, gpointer compose);

	void (* textview_menu_popup)	(GObject	*obj,
					 GtkMenu	*menu,
					 GtkTextView	*textview,
					 const gchar	*uri,
					 const gchar	*selected_text,
					 MsgInfo	*msginfo);

	gboolean (* compose_send)	(GObject	*obj,
					 gpointer	 compose,
					 gint		 compose_mode,
					 gint		 send_mode,
					 const gchar	*msg_file,
					 GSList		*to_list);

	void (* messageview_show)	(GObject	*obj,
					 gpointer	 msgview,
					 MsgInfo	*msginfo,
					 gboolean	 all_headers);

	void (* inc_mail_start)		(GObject	*obj,
					 PrefsAccount	*account);
	void (* inc_mail_finished)	(GObject	*obj,
					 gint		 new_messages);

	/* Prefs dialogs */
	void (* prefs_common_open)	(GObject	*obj,
					 GtkWidget	*window);
	void (* prefs_account_open)	(GObject	*obj,
					 PrefsAccount	*account,
					 GtkWidget	*window);
	void (* prefs_filter_open)	(GObject	*obj,
					 GtkWidget	*window);
	void (* prefs_filter_edit_open)	(GObject	*obj,
					 FilterRule	*rule,
					 const gchar	*header,
					 const gchar	*key,
					 GtkWidget	*window);
	void (* prefs_template_open)	(GObject	*obj,
					 GtkWidget	*window);
	void (* plugin_manager_open)	(GObject	*obj,
					 GtkWidget	*window);

	void (* main_window_toolbar_changed) (GObject *obj);
	void (* compose_toolbar_changed)     (GObject *obj, gpointer compose);
	void (* compose_attach_changed)     (GObject *obj, gpointer compose);
};

struct _SylPluginInfo
{
	gchar *name;
	gchar *version;
	gchar *author;
	gchar *description;

	gpointer pad1;
	gpointer pad2;
	gpointer pad3;
	gpointer pad4;
};

GType syl_plugin_get_type	(void);

void syl_plugin_signal_connect		(const gchar *name, GCallback callback,
					 gpointer data);
void syl_plugin_signal_disconnect	(gpointer func, gpointer data);
void syl_plugin_signal_emit		(const gchar *name, ...);

/* Used by Sylpheed */

gint syl_plugin_init_lib	(void);

gint syl_plugin_load		(const gchar *file);
gint syl_plugin_load_all	(const gchar *dir);
void syl_plugin_unload_all	(void);

GSList *syl_plugin_get_module_list	(void);
SylPluginInfo *syl_plugin_get_info	(GModule *module);
gboolean syl_plugin_check_version	(GModule *module);

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

/* Interfaces which should be implemented by plug-ins
     void plugin_load(void);
     void plugin_unload(void);
     SylPluginInfo *plugin_info(void);
     gint plugin_interface_version(void);
 */

/* Plug-in API (used by plug-ins) */

const gchar *syl_plugin_get_prog_version	(void);

void syl_plugin_main_window_lock		(void);
void syl_plugin_main_window_unlock		(void);
gpointer syl_plugin_main_window_get		(void);
void syl_plugin_main_window_popup		(gpointer mainwin);
GtkWidget *syl_plugin_main_window_get_toolbar	(void);
GtkWidget *syl_plugin_main_window_get_statusbar	(void);

void syl_plugin_app_will_exit			(gboolean force);

/* Menu */
gint syl_plugin_add_menuitem			(const gchar *parent,
						 const gchar *label,
						 SylPluginCallbackFunc func,
						 gpointer data);
gint syl_plugin_add_factory_item		(const gchar *menu,
						 const gchar *label,
						 SylPluginCallbackFunc func,
						 gpointer data);

void syl_plugin_menu_set_sensitive		(const gchar	*path,
						 gboolean	 sensitive);
void syl_plugin_menu_set_sensitive_all		(GtkMenuShell	*menu_shell,
						 gboolean	 sensitive);
void syl_plugin_menu_set_active			(const gchar	*path,
						 gboolean	 is_active);


/* FolderView */
gpointer syl_plugin_folderview_get		(void);

void syl_plugin_folderview_add_sub_widget	(GtkWidget	*widget);

void syl_plugin_folderview_select		(FolderItem	*item);
void syl_plugin_folderview_unselect		(void);
void syl_plugin_folderview_select_next_unread	(void);
FolderItem *syl_plugin_folderview_get_selected_item
						(void);

gint syl_plugin_folderview_check_new		(Folder         *folder);
gint syl_plugin_folderview_check_new_item	(FolderItem     *item);
gint syl_plugin_folderview_check_new_all	(void);

void syl_plugin_folderview_update_item		(FolderItem	*item,
						 gboolean	 update_summary);
void syl_plugin_folderview_update_item_foreach	(GHashTable	*table,
						 gboolean	 update_summary);
void syl_plugin_folderview_update_all_updated	(gboolean	 update_summary);
void syl_plugin_folderview_check_new_selected	(void);

/* SummaryView */
gpointer syl_plugin_summary_view_get		(void);
void syl_plugin_summary_select_by_msgnum	(guint msgnum);
gboolean syl_plugin_summary_select_by_msginfo	(MsgInfo *msginfo);

void syl_plugin_open_message			(const gchar *folder_id,
						 guint msgnum);

void syl_plugin_summary_show_queued_msgs	(void);

void syl_plugin_summary_lock			(void);
void syl_plugin_summary_unlock			(void);
gboolean syl_plugin_summary_is_locked		(void);
gboolean syl_plugin_summary_is_read_locked	(void);
void syl_plugin_summary_write_lock		(void);
void syl_plugin_summary_write_unlock		(void);
gboolean syl_plugin_summary_is_write_locked	(void);

FolderItem *syl_plugin_summary_get_current_folder
						(void);

gint syl_plugin_summary_get_selection_type	(void);
GSList *syl_plugin_summary_get_selected_msg_list(void);
GSList *syl_plugin_summary_get_msg_list		(void);

void syl_plugin_summary_redisplay_msg		(void);
void syl_plugin_summary_open_msg		(void);
void syl_plugin_summary_view_source		(void);
void syl_plugin_summary_reedit			(void);

void syl_plugin_summary_update_selected_rows	(void);
void syl_plugin_summary_update_by_msgnum	(guint msgnum);

/* MessageView */
gpointer syl_plugin_messageview_create_with_new_window
						(void);
void syl_plugin_open_message_by_new_window	(MsgInfo *msginfo);

/* Compose */
gpointer syl_plugin_compose_new			(PrefsAccount *account,
						 FolderItem *item,
						 const gchar *mailto,
						 GPtrArray *attach_files);
/* compose mode:
   1: reply 2: reply to sender 3: reply to all 4: reply to list
   | 1 << 16: with quote */
gpointer syl_plugin_compose_reply		(MsgInfo *msginfo,
						 FolderItem *item,
						 gint mode,
						 const gchar *body);
gpointer syl_plugin_compose_forward		(GSList *mlist,
						 FolderItem *item,
						 gboolean as_attach,
						 const gchar *body);
gpointer syl_plugin_compose_redirect		(MsgInfo *msginfo,
						 FolderItem *item);
gpointer syl_plugin_compose_reedit		(MsgInfo *msginfo);

/* entry type:
   0: To 1: Cc 2: Bcc 3: Reply-To 4: Subject 5: Newsgroups 6: Followup-To */
void syl_plugin_compose_entry_set		(gpointer compose,
						 const gchar *text,
						 gint type);
void syl_plugin_compose_entry_append		(gpointer compose,
						 const gchar *text,
						 gint type);
gchar *syl_plugin_compose_entry_get_text	(gpointer compose,
						 gint type);
void syl_plugin_compose_lock			(gpointer compose);
void syl_plugin_compose_unlock			(gpointer compose);

GtkWidget *syl_plugin_compose_get_toolbar	(gpointer compose);
GtkWidget *syl_plugin_compose_get_misc_hbox	(gpointer compose);
GtkWidget *syl_plugin_compose_get_textview	(gpointer compose);

gint syl_plugin_compose_send			(gpointer compose,
						 gboolean close_on_success);
void syl_plugin_compose_attach_append		(gpointer compose,
						 const gchar *file,
						 const gchar *filename,
						 const gchar *content_type);
void syl_plugin_compose_attach_remove_all	(gpointer compose);
/* returns list of SylPluginAttachInfo (GSList must be freed by caller) */
GSList *syl_plugin_get_attach_list		(gpointer compose);

/* Others */
FolderItem *syl_plugin_folder_sel		(Folder *cur_folder,
						 gint sel_type,
						 const gchar *default_folder);
FolderItem *syl_plugin_folder_sel_full		(Folder *cur_folder,
						 gint sel_type,
						 const gchar *default_folder,
						 const gchar *message);

gchar *syl_plugin_input_dialog			(const gchar *title,
						 const gchar *message,
						 const gchar *default_string);
gchar *syl_plugin_input_dialog_with_invisible	(const gchar *title,
						 const gchar *message,
						 const gchar *default_string);

void syl_plugin_manage_window_set_transient	(GtkWindow *window);
void syl_plugin_manage_window_signals_connect	(GtkWindow *window);
GtkWidget *syl_plugin_manage_window_get_focus_window
						(void);

void syl_plugin_inc_mail			(void);
gboolean syl_plugin_inc_is_active		(void);
void syl_plugin_inc_lock			(void);
void syl_plugin_inc_unlock			(void);

void syl_plugin_update_check			(gboolean show_dialog_always);
void syl_plugin_update_check_set_check_url		(const gchar *url);
const gchar *syl_plugin_update_check_get_check_url	(void);
void syl_plugin_update_check_set_download_url		(const gchar *url);
const gchar *syl_plugin_update_check_get_download_url	(void);
void syl_plugin_update_check_set_jump_url		(const gchar *url);
const gchar *syl_plugin_update_check_get_jump_url	(void);
void syl_plugin_update_check_set_check_plugin_url	(const gchar *url);
const gchar *syl_plugin_update_check_get_check_plugin_url(void);
void syl_plugin_update_check_set_jump_plugin_url	(const gchar *url);
const gchar *syl_plugin_update_check_get_jump_plugin_url(void);

/* type corresponds to AlertType
 * default_value and return value corresponds to AlertValue */
gint syl_plugin_alertpanel_full			(const gchar *title,
						 const gchar *message,
						 gint type,
						 gint default_value,
						 gboolean can_disable,
						 const gchar *btn1_label,
						 const gchar *btn2_label,
						 const gchar *btn3_label);
gint syl_plugin_alertpanel			(const gchar *title,
						 const gchar *message,
						 const gchar *btn1_label,
						 const gchar *btn2_label,
						 const gchar *btn3_label);
void syl_plugin_alertpanel_message		(const gchar *title,
						 const gchar *message,
						 gint type);
gint syl_plugin_alertpanel_message_with_disable	(const gchar *title,
						 const gchar *message,
						 gint type);

/* Send message */
gint syl_plugin_send_message			(const gchar	*file,
						 PrefsAccount	*ac,
						 GSList		*to_list);
gint syl_plugin_send_message_queue_all		(FolderItem	*queue,
						 gboolean	 save_msgs,
						 gboolean	 filter_msgs);
gint syl_plugin_send_message_set_reply_flag	(const gchar	*reply_target,
						 const gchar	*msgid);
gint syl_plugin_send_message_set_forward_flags	(const gchar	*forward_targets);

/* Notification window */
gint syl_plugin_notification_window_open	(const gchar	*message,
						 const gchar	*submessage,
						 guint		 timeout);
void syl_plugin_notification_window_set_message	(const gchar	*message,
						 const gchar	*submessage);
void syl_plugin_notification_window_close	(void);

#endif /* __PLUGIN_H__ */