New method to send a mail without ui
[modest] / src / modest-ui-actions.h
1 /* Copyright (c) 2006, Nokia Corporation
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  *   notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  *   notice, this list of conditions and the following disclaimer in the
12  *   documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Nokia Corporation nor the names of its
14  *   contributors may be used to endorse or promote products derived from
15  *   this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 #ifndef __MODEST_UI_ACTIONS_H__
31 #define __MODEST_UI_ACTIONS_H__
32
33 #include <widgets/modest-msg-edit-window.h>
34 #include <widgets/modest-msg-view-window.h>
35 #include <widgets/modest-msg-view.h>
36 #include <widgets/modest-recpt-view.h>
37 #include <widgets/modest-folder-view.h>
38 #include <widgets/modest-header-view.h>
39 #include "modest-mail-operation.h"
40 #include "modest-tny-send-queue.h"
41 #include "modest-plugin-ui-actions.h"
42
43 G_BEGIN_DECLS
44
45 /* Menu & toolbar actions */
46 void     modest_ui_actions_on_about         (GtkAction *action, ModestWindow *win);
47
48 void     modest_ui_actions_refresh_message_window_after_delete (ModestMsgViewWindow* win);
49
50 void     modest_ui_actions_on_delete_message     (GtkAction *action, ModestWindow *win);
51
52 gboolean modest_ui_actions_on_edit_mode_delete_message (ModestWindow *win);
53
54 gboolean modest_ui_actions_on_edit_mode_delete_folder (ModestWindow *win);
55
56 void     modest_ui_actions_on_delete_message_or_folder (GtkAction *action, ModestWindow *win);
57
58 void     modest_ui_actions_on_quit          (GtkAction *action, ModestWindow *win);
59
60 void     modest_ui_actions_on_close_window  (GtkAction *action, ModestWindow *win);
61
62 void     modest_ui_actions_on_new_account      (GtkAction *action, ModestWindow *win);
63
64 void     modest_ui_actions_on_accounts      (GtkAction *action, ModestWindow *win);
65
66 void     modest_ui_actions_on_smtp_servers  (GtkAction *action, ModestWindow *win);
67
68 void     modest_ui_actions_add_to_contacts   (GtkAction *action, ModestWindow *win);
69 void     modest_ui_actions_on_add_to_contacts   (GtkAction *action, ModestWindow *win);
70
71 void     modest_ui_actions_on_select_contacts (GtkAction *action, ModestMsgEditWindow *win);
72
73 void     modest_ui_actions_on_open_addressbook (GtkAction *action, ModestWindow *win);
74
75 void     modest_ui_actions_on_check_names (GtkAction *action, ModestMsgEditWindow *win);
76
77 void     modest_ui_actions_on_new_msg       (GtkAction *action, ModestWindow *win);
78
79 void     modest_ui_actions_on_new_msg_or_folder (GtkAction *action, ModestWindow *win);
80
81 void     modest_ui_actions_on_open           (GtkAction *action, ModestWindow *win);
82
83 void     modest_ui_actions_on_reply         (GtkAction *action, ModestWindow *win);
84
85 void     modest_ui_actions_on_forward       (GtkAction *action, ModestWindow *win);
86
87 void     modest_ui_actions_on_sort          (GtkAction *action, ModestWindow *window);
88
89 void     modest_ui_actions_on_reply_all     (GtkAction *action, ModestWindow *win);
90
91 void     modest_ui_actions_on_next          (GtkAction *action, ModestWindow *window);
92
93 void     modest_ui_actions_on_prev          (GtkAction *action, ModestWindow *window);
94
95 void     modest_ui_actions_on_details       (GtkAction *action, ModestWindow *win);
96
97 void     modest_ui_actions_on_limit_error   (GtkAction *action, ModestWindow *win);
98
99 gboolean     modest_ui_actions_on_edit_mode_move_to       (ModestWindow *win);
100
101 void     modest_ui_actions_on_move_to       (GtkAction *action, ModestWindow *win);
102
103 void     modest_ui_actions_on_settings      (GtkAction *action, ModestWindow *win);
104
105 /**
106  * modest_ui_actions_on_help:
107  * @action: a #GtkAction
108  * @win: a #ModestWindow
109  * 
110  * Shows the help dialog
111  **/
112 void     modest_ui_actions_on_help          (GtkAction *action, GtkWindow *win);
113
114
115 /**
116  * modest_ui_actions_on_csm_elp:
117  * @action: a #GtkAction
118  * @win: a #ModestWindow
119  * 
120  * Shows the help dialog for folder view CSM. It shows the help ID
121  * which refers to the currently selected folder if any
122  **/
123 void     modest_ui_actions_on_csm_help      (GtkAction *action, GtkWindow *win);
124
125 #ifndef MODEST_TOOLKIT_HILDON2
126 /**
127  * modest_ui_actions_toggle_folders_view:
128  * @action: the #GtkAction
129  * @window: the #ModestWindow
130  * 
131  * this action switches between split view (with a folders pane at the
132  * left) and simple view without the left pane with the folders and
133  * accounts. Maybe it's only useful for Maemo code, but as it uses
134  * generic code could be used also by the GNOME UI
135  **/
136 void     modest_ui_actions_toggle_folders_view       (GtkAction *action, 
137                                                       ModestWindow *window);
138
139 /**
140  * modest_ui_actions_toggle_folders_view:
141  * @action: the #GtkAction
142  * @window: the #ModestWindow
143  * 
144  * this action shows or hides the column titles of the header list
145  * view. It also enables the two lines rendering for the treeview rows
146  **/
147 void     modest_ui_actions_toggle_header_list_view    (GtkAction *action, 
148                                                        ModestWindow *window);
149
150 /* Widget actions */
151 void     modest_ui_actions_on_header_selected          (ModestHeaderView *folder_view, 
152                                                         TnyHeader *header,
153                                                         ModestWindow *window);
154 #endif
155 void     modest_ui_actions_on_header_activated         (ModestHeaderView *folder_view, 
156                                                         TnyHeader *header,
157                                                         GtkTreePath *path,
158                                                         ModestWindow *window);
159
160 #ifndef MODEST_TOOLKIT_HILDON2
161 void     modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view,
162                                                          TnyFolderStore *folder_store, 
163                                                          gboolean selected,
164                                                          ModestWindow *window);
165 #endif
166
167 void     modest_ui_actions_on_item_not_found           (ModestHeaderView *header_view,
168                                                          ModestItemType type,
169                                                          ModestWindow *window);
170
171 void     modest_ui_actions_on_msg_link_hover           (ModestMsgView *msgview, const gchar* link,
172                                                         ModestWindow *win);
173
174 void     modest_ui_actions_on_msg_link_clicked         (ModestMsgView *msgview, const gchar* link,
175                                                         ModestWindow *win);
176
177 void     modest_ui_actions_on_msg_link_contextual      (ModestMsgView *msgview, const gchar* link,
178                                                         ModestWindow *win);
179
180 void     modest_ui_actions_on_msg_attachment_clicked   (ModestMsgView *msgview, TnyMimePart *mime_part,
181                                                         ModestWindow *win);
182
183 void     modest_ui_actions_on_msg_recpt_activated   (ModestMsgView *msgview, const gchar *address,
184                                                      ModestWindow *win);
185
186 gboolean modest_ui_actions_on_send_msg (ModestWindow *window,
187                                         TnyMsg *msg);
188
189 gboolean modest_ui_actions_on_send                     (GtkWidget *widget,
190                                                         ModestMsgEditWindow *edit_window);
191 gboolean modest_ui_actions_on_save_to_drafts           (GtkWidget *widget, 
192                                                         ModestMsgEditWindow *edit_window);
193
194
195 void     modest_ui_actions_on_toggle_bold              (GtkToggleAction *action,
196                                                         ModestMsgEditWindow *window);
197
198 void     modest_ui_actions_on_toggle_italics           (GtkToggleAction *action,
199                                                         ModestMsgEditWindow *window);
200
201 void     modest_ui_actions_on_toggle_bullets           (GtkToggleAction *action,
202                                                         ModestMsgEditWindow *window);
203
204 void     modest_ui_actions_on_change_justify      (GtkRadioAction *action,
205                                                    GtkRadioAction *selected,
206                                                    ModestMsgEditWindow *window);
207
208 void     modest_ui_actions_on_select_editor_color      (GtkAction *action,
209                                                         ModestMsgEditWindow *window);
210
211 void     modest_ui_actions_on_select_editor_background_color      (GtkAction *action,
212                                                                    ModestMsgEditWindow *window);
213
214 void     modest_ui_actions_on_insert_image             (GObject *object,
215                                                         ModestMsgEditWindow *window);
216
217 void     modest_ui_actions_on_attach_file             (GtkAction *action,
218                                                        ModestMsgEditWindow *window);
219
220 void     modest_ui_actions_on_remove_attachments      (GtkAction *action,
221                                                        ModestMsgEditWindow *window);
222 void     modest_ui_actions_on_mark_as_read            (GtkAction *action,
223                                                        ModestWindow *window);
224
225 void     modest_ui_actions_on_mark_as_unread            (GtkAction *action,
226                                                          ModestWindow *window);
227
228 void     modest_ui_actions_cancel_send (GtkAction *action,  ModestWindow *win);
229
230 /**
231  * modest_ui_actions_do_send_receive_all:
232  * @win: the window that will be used as source of the refresh mail operation
233  * @force_connection: whether or not the code should try to force a new connection if we're offline
234  * @poke_status: wheter ot not we want to poke the status of all mail folders
235  * @interactive: is coming from an interactive send receive.
236  * 
237  * Refreshes all the accounts
238  **/
239 void    modest_ui_actions_do_send_receive_all          (ModestWindow *win,
240                                                         gboolean force_connection,
241                                                         gboolean poke_status,
242                                                         gboolean interactive);
243
244 /**
245  * modest_ui_actions_do_send_receive:
246  * @account_name: the name of the Modest account or NULL
247  * @force_connection: whether or not the code should try to force a new connection if we're offline
248  * @poke_status: wheter ot not we want to poke the status of all mail folders
249  * @interactive: is coming from an interactive send receive
250  * @win: the window that will be used as source of the refresh mail operation
251  * 
252  * Refreshes the Modest account whose name is passed as argument. If
253  * NULL is passed as #account_name then this function refreses the
254  * active account, if no active account is defined then it picks the
255  * default account
256  **/
257 void    modest_ui_actions_do_send_receive              (const gchar *account_name,
258                                                         gboolean force_connection,
259                                                         gboolean poke_status,
260                                                         gboolean interactive,
261                                                         ModestWindow *win);
262
263 /**
264  * modest_ui_actions_on_send_receive:
265  * @action: a #GtkAction
266  * @win: the Window that contains the action
267  * 
268  * Handles the activation of the send receive action, for example
269  * clicks on Send&Receive button in the main toolbar
270  **/
271 void    modest_ui_actions_on_send_receive              (GtkAction *action, 
272                                                         ModestWindow *win);
273
274 void     modest_ui_actions_on_new_folder               (GtkAction *action,
275                                                         ModestWindow *window);
276
277 gboolean     modest_ui_actions_on_edit_mode_rename_folder            (ModestWindow *window);
278
279 void     modest_ui_actions_on_rename_folder            (GtkAction *action,
280                                                         ModestWindow *window);
281
282 void     modest_ui_actions_on_delete_folder            (GtkAction *action,
283                                                         ModestWindow *window);
284
285 #ifndef MODEST_TOOLKIT_HILDON2
286 void     modest_ui_actions_on_move_folder_to_trash_folder     (GtkAction *action,
287                                                                ModestWindow *window);
288 #endif
289
290 void     modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
291                                                   const gchar* server_account_name,
292                                                   gchar **username, gchar **password, gboolean *cancel, 
293                                                   gboolean *remember, ModestWindow *window);
294
295 void     modest_ui_actions_on_undo                     (GtkAction *action,
296                                                         ModestWindow *window);
297
298 void     modest_ui_actions_on_redo                     (GtkAction *action,
299                                                         ModestWindow *window);
300
301 void     modest_ui_actions_on_cut                      (GtkAction *action,
302                                                         ModestWindow *window);
303
304 void     modest_ui_actions_on_copy                     (GtkAction *action,
305                                                         ModestWindow *window);
306
307 void     modest_ui_actions_on_zoom_plus (GtkAction *action,
308                                          ModestWindow *window);
309
310 void     modest_ui_actions_on_zoom_minus (GtkAction *action,
311                                           ModestWindow *window);
312
313 void     modest_ui_actions_on_toggle_fullscreen    (GtkToggleAction *toggle,
314                                                     ModestWindow *window);
315
316 void     modest_ui_actions_on_change_fullscreen    (GtkAction *action,
317                                                     ModestWindow *window);
318
319 void     modest_ui_actions_on_paste                    (GtkAction *action,
320                                                         ModestWindow *window);
321
322 void     modest_ui_actions_on_select_all               (GtkAction *action,
323                                                         ModestWindow *window);
324
325 void     modest_ui_actions_on_toggle_show_cc (GtkToggleAction *toggle,
326                                               ModestMsgEditWindow *window);
327
328 void     modest_ui_actions_on_toggle_show_bcc (GtkToggleAction *toggle,
329                                               ModestMsgEditWindow *window);
330
331 void     modest_ui_actions_on_change_zoom              (GtkRadioAction *action,
332                                                         GtkRadioAction *selected,
333                                                         ModestWindow *window);
334
335 void     modest_ui_actions_msg_edit_on_change_priority (GtkRadioAction *action,
336                                                         GtkRadioAction *selected,
337                                                         ModestWindow *window);
338
339 void     modest_ui_actions_msg_edit_on_change_file_format (GtkRadioAction *action,
340                                                            GtkRadioAction *selected,
341                                                            ModestWindow *window);
342
343 void     modest_ui_actions_msg_edit_on_select_font (GtkAction *action,
344                                                     ModestMsgEditWindow *window);
345
346 /**
347  * modest_ui_actions_on_toggle_toolbar:
348  * @toggle: 
349  * @window: 
350  * 
351  * Hides/Shows the toolbars of the #ModestWindow instances
352  **/
353 void     modest_ui_actions_on_toggle_toolbar           (GtkToggleAction *toggle, 
354                                                         ModestWindow *window);
355
356 /**
357  * modest_ui_actions_on_folder_display_name_changed:
358  * @folder_view: a #ModestFolderView
359  * @display_name: the new window title
360  * @window: a #GtkWindow
361  * 
362  * Sets the title of the window to the value specified by
363  * display_name. This function is used typically as a callback to the
364  * "folder-display-name-changed" signal from the #ModestFolderView
365  **/
366 void     modest_ui_actions_on_folder_display_name_changed (ModestFolderView *folder_view,
367                                                            const gchar *display_name,
368                                                            GtkWindow *window);
369
370 void     modest_ui_actions_view_attachment                (GtkAction *action,
371                                                            ModestWindow *window);
372
373 void     modest_ui_actions_save_attachments               (GtkAction *action,
374                                                            ModestWindow *window);
375
376 void     modest_ui_actions_remove_attachments             (GtkAction *action,
377                                                            ModestWindow *window);
378
379 /**
380  * modest_ui_actions_on_retrieve_msg_contents:
381  * @action: the #GtkAction
382  * @window: the #ModestWindow that issues the action
383  * 
384  * Retrieve the contents of the selected messages in the header view
385  **/
386 void     modest_ui_actions_on_retrieve_msg_contents       (GtkAction *action,
387                                                            ModestWindow *window);
388
389 void
390 modest_ui_actions_on_email_menu_activated (GtkAction *action,
391                                           ModestWindow *window);
392
393 void
394 modest_ui_actions_on_edit_menu_activated (GtkAction *action,
395                                           ModestWindow *window);
396
397 void
398 modest_ui_actions_on_format_menu_activated (GtkAction *action,
399                                             ModestWindow *window);
400
401 void
402 modest_ui_actions_on_view_menu_activated (GtkAction *action,
403                                           ModestWindow *window);
404
405 void
406 modest_ui_actions_on_tools_menu_activated (GtkAction *action,
407                                           ModestWindow *window);
408
409 void
410 modest_ui_actions_on_attachment_menu_activated (GtkAction *action,
411                                                 ModestWindow *window);
412
413 void
414 modest_ui_actions_on_toolbar_csm_menu_activated (GtkAction *action,
415                                                  ModestWindow *window);
416
417 void
418 modest_ui_actions_on_folder_view_csm_menu_activated (GtkAction *action,
419                                                      ModestWindow *window);
420
421 void
422 modest_ui_actions_on_header_view_csm_menu_activated (GtkAction *action,
423                                                      ModestWindow *window);
424
425 void
426 modest_ui_actions_check_toolbar_dimming_rules (ModestWindow *window);
427
428 void
429 modest_ui_actions_check_menu_dimming_rules (ModestWindow *window);
430
431 /* Dimming rules groups */
432 #define MODEST_DIMMING_RULES_TOOLBAR "ModestToolbarDimmingRules"
433 #define MODEST_DIMMING_RULES_MENU "ModestMenuDimmingRules"
434 #define MODEST_DIMMING_RULES_CLIPBOARD "ModestClipboardDimmingRules"
435
436 /**
437  * modest_ui_actions_move_folder_error_handler:
438  * @mail_op: a #ModestMailOperation
439  * @user_data: user data
440  * 
441  * manages an error in a mail operation that tries to move a folder
442  **/
443 void     modest_ui_actions_move_folder_error_handler      (ModestMailOperation *mail_op, 
444                                                            gpointer user_data);
445 /**
446  * modest_ui_actions_send-receive_error_handler:
447  * @mail_op: a #ModestMailOperation
448  * @user_data: user data
449  * 
450  * manages an error in a mail operation that tries to execute
451  * a send&receive operation.
452  **/
453 void     modest_ui_actions_send_receive_error_handler      (ModestMailOperation *mail_op, 
454                                                             gpointer user_data);
455
456 /**
457  * modest_ui_actions_on_search_messages:
458  * @action: a #GtkAction
459  * @window: a #ModestWindow
460  *
461  * Shows the search messages dialog
462  **/
463 void     modest_ui_actions_on_search_messages             (GtkAction *action,
464                                                            ModestWindow *window);
465
466 /**
467  * modest_ui_actions_on_find_in_page:
468  * @action: a #GtkAction
469  * @window: a #ModestWindow
470  *
471  * Toggles the visibility of the find in page toolbar
472  **/
473 void     modest_ui_actions_on_toggle_find_in_page             (GtkAction *action,
474                                                                ModestWindow *window);
475
476 /**
477  * modest_ui_actions_msg_retrieval_check
478  * @mail_op: a #ModestMailOperation
479  * @header: a #TnyHeader
480  * @msg: a #TnyMsg
481  *
482  * This function checks that the message has been retrieved
483  * successfully. It it was not the case it unregisters the header from
484  * the window manager because it won't do it automatically unless the
485  * operation run fine
486  *
487  * Returns: TRUE if the operation was OK, otherwise FALSE
488  **/
489 gboolean modest_ui_actions_msg_retrieval_check                (ModestMailOperation *mail_op, 
490                                                                TnyHeader *header,
491                                                                TnyMsg *msg);
492
493
494 /**
495  * modest_ui_actions_disk_operations_error_handler
496  * @mail_op: a #ModestMailOperation
497  *
498  * Error handler for retrieval operations like
499  * modest_mail_operation_get_msg or
500  * modest_mail_operation_get_msgs_full
501  **/
502 void     modest_ui_actions_disk_operations_error_handler      (ModestMailOperation *mail_op,
503                                                                gpointer user_data);
504
505 /* Show the account creation wizard dialog.
506  * returns: TRUE if an account was created. FALSE if the user cancelled.
507  */
508 gboolean modest_ui_actions_run_account_setup_wizard (ModestWindow *win);
509
510 gint modest_ui_actions_msgs_move_to_confirmation (ModestWindow *win,
511                                                   TnyFolder *dest_folder,
512                                                   gboolean delete,
513                                                   TnyList *headers);
514
515 /*
516  * modest_ui_actions_on_send_queue_error_happened:
517  *
518  * Method for handling errors in send queues
519  */
520 void modest_ui_actions_on_send_queue_error_happened (TnySendQueue *self, 
521                                                      TnyHeader *header, 
522                                                      TnyMsg *msg, 
523                                                      GError *err, 
524                                                      gpointer user_data);
525
526 /*
527  * modest_ui_actions_on_send_queue_status_changed:
528  *
529  * Method for handling changes in the status of the messages in the send queues
530  */
531 void modest_ui_actions_on_send_queue_status_changed (ModestTnySendQueue *send_queue,
532                                                      gchar *msg_id, 
533                                                      guint status,
534                                                      gpointer user_data);
535
536 /**
537  * modest_ui_actions_compose_msg
538  * @win: Modest main window (can be NULL)
539  * @to_str: "To:" header, or NULL
540  * @cc_str: "Cc:" header, or NULL
541  * @bcc_str: "Bcc:" header, or NULL
542  * @subject_str: Subject of the message, or NULL
543  * @body_str: Body of the message (without signature), or NULL
544  * @attachments: attachments List of file URIs to attach
545  * @set_as_modified: wheter or not the message is set initially as modified or not
546  *
547  * Opens a new message editor for composing
548  */
549 void modest_ui_actions_compose_msg (ModestWindow *win,
550                                     const gchar *to_str,
551                                     const gchar *cc_str,
552                                     const gchar *bcc_str,
553                                     const gchar *subject_str,
554                                     const gchar *body_str,
555                                     GSList *attachments,
556                                     gboolean set_as_modified);
557
558 void modest_ui_actions_on_account_connection_error (ModestWindow *parent_window,
559                                                     TnyAccount *account);
560
561 gchar *modest_ui_actions_get_msg_already_deleted_error_msg (ModestWindow *win);
562
563 void modest_ui_actions_transfer_messages_helper (ModestWindow *win,
564                                                  TnyFolder *src_folder,
565                                                  TnyList *headers,
566                                                  TnyFolder *dst_folder);
567
568 void modest_ui_actions_on_fetch_images (GtkAction *action,
569                                         ModestWindow *window);
570
571 /**
572  * modest_ui_actions_check_for_active_account:
573  * @win: a #ModestWindow
574  * @account_name: the account name of the account to check
575  *
576  * Check whether any connections are active, and cancel them if
577  * the user wants.
578  *
579  * Returns: Returns TRUE if there was no problem, or if an operation
580  * was cancelled so we can continue. Returns FALSE if the user chose
581  * to cancel his request instead.
582  **/
583 gboolean modest_ui_actions_check_for_active_account (ModestWindow *win,
584                                                      const gchar* account_name);
585
586 G_END_DECLS
587 #endif /* __MODEST_UI_ACTIONS_H__ */