1 /* Copyright (c) 2008, Nokia Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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.
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.
31 /* modest-account-settings.h */
33 #ifndef __MODEST_ACCOUNT_PROTOCOL_H__
34 #define __MODEST_ACCOUNT_PROTOCOL_H__
36 #include "widgets/modest-account-settings-dialog.h"
37 #include "modest-protocol.h"
38 #include "widgets/modest-window.h"
39 #include "widgets/modest-wizard-dialog.h"
40 #include "modest-pair.h"
41 #include <tny-account.h>
46 /* convenience macros */
47 #define MODEST_TYPE_ACCOUNT_PROTOCOL (modest_account_protocol_get_type())
48 #define MODEST_ACCOUNT_PROTOCOL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_ACCOUNT_PROTOCOL,ModestAccountProtocol))
49 #define MODEST_ACCOUNT_PROTOCOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_ACCOUNT_PROTOCOL,ModestAccountProtocolClass))
50 #define MODEST_IS_ACCOUNT_PROTOCOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_ACCOUNT_PROTOCOL))
51 #define MODEST_IS_ACCOUNT_PROTOCOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_ACCOUNT_PROTOCOL))
52 #define MODEST_ACCOUNT_PROTOCOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_ACCOUNT_PROTOCOL,ModestAccountProtocolClass))
54 typedef struct _ModestAccountProtocol ModestAccountProtocol;
55 typedef struct _ModestAccountProtocolClass ModestAccountProtocolClass;
58 MODEST_ACCOUNT_PROTOCOL_ICON_MAILBOX = 0,
59 MODEST_ACCOUNT_PROTOCOL_ICON_PROTOCOL,
60 MODEST_ACCOUNT_PROTOCOL_ICON_ACCOUNT,
61 MODEST_ACCOUNT_PROTOCOL_ICON_FOLDER,
62 } ModestAccountProtocolIconType;
64 typedef void (*ModestAccountProtocolCheckSupportFunc) (ModestAccountProtocol *self,
65 gboolean supported, gpointer userdata);
66 typedef void (*ModestAccountProtocolSaveRemoteDraftCallback) (ModestAccountProtocol *self,
68 const gchar *account_id,
69 TnyMsg *new_remote_msg,
75 struct _ModestAccountProtocol {
76 ModestProtocol parent;
79 struct _ModestAccountProtocolClass {
80 ModestProtocolClass parent_class;
83 TnyAccount * (*create_account) (ModestAccountProtocol *self);
84 ModestAccountSettingsDialog* (*create_account_settings_dialog) (ModestAccountProtocol* self);
85 ModestPairList* (*get_easysetupwizard_tabs) (ModestAccountProtocol* self);
86 ModestWizardDialogResponseOverrideFunc (*get_wizard_response_override) (ModestAccountProtocol *self);
87 void (*save_settings) (ModestAccountProtocol *self, ModestAccountSettingsDialog *dialog, ModestAccountSettings *settings);
88 void (*save_wizard_settings) (ModestAccountProtocol *self, GList *wizard_pages, ModestAccountSettings *settings);
89 gboolean (*is_supported) (ModestAccountProtocol *self);
90 void (*check_support) (ModestAccountProtocol *self, ModestAccountProtocolCheckSupportFunc func, gpointer userdata);
91 gchar * (*get_from) (ModestAccountProtocol *self, const gchar *account_id, const gchar *mailbox);
92 ModestPairList * (*get_from_list) (ModestAccountProtocol *self, const gchar *account_id);
93 gchar * (*get_signature) (ModestAccountProtocol *self, const gchar *account_id, const gchar *mailbox, gboolean *has_signature);
94 const GdkPixbuf * (*get_icon) (ModestAccountProtocol *self, ModestAccountProtocolIconType icon_type,
95 GObject *object, guint icon_size);
96 gchar * (*get_service_name) (ModestAccountProtocol *self, const gchar *account_id, const gchar *mailbox);
97 const GdkPixbuf * (*get_service_icon) (ModestAccountProtocol *self, const gchar *account_id, const gchar *mailbox, guint icon_size);
98 void (*save_remote_draft) (ModestAccountProtocol *self,
99 const gchar *account_id, TnyMsg *new_msg, TnyMsg *old_msg,
100 ModestAccountProtocolSaveRemoteDraftCallback callback,
102 void (*cancel_check_support) (ModestAccountProtocol *self);
103 void (*wizard_finished) (ModestAccountProtocol *self);
104 gboolean (*decode_part_to_stream) (ModestAccountProtocol *protocol,
106 const gchar *stream_uri,
110 gboolean (*decode_part_to_stream_async) (ModestAccountProtocol *protocol,
112 const gchar *stream_uri,
114 TnyMimePartCallback callback,
115 TnyStatusCallback status_callback,
118 gboolean (*handle_calendar) (ModestAccountProtocol *protocol,
119 ModestWindow *window,
120 TnyMimePart *calendar_part,
121 GtkContainer *container);
123 /* Padding for future expansions */
124 void (*_reserved9) (void);
125 void (*_reserved10) (void);
126 void (*_reserved11) (void);
127 void (*_reserved12) (void);
128 void (*_reserved13) (void);
129 void (*_reserved14) (void);
130 void (*_reserved15) (void);
131 void (*_reserved16) (void);
135 * modest_account_protocol_get_type:
137 * Returns: GType of the account protocol type
139 GType modest_account_protocol_get_type (void) G_GNUC_CONST;
142 * modest_account_protocol_new:
144 * creates a new instance of #ModestAccountProtocol
146 * Returns: a #ModestAccountProtocol
148 ModestProtocol* modest_account_protocol_new (const gchar *name, const gchar *display_name,
149 guint port, guint alternate_port,
150 GType account_g_type);
153 * modest_account_protocol_get_port:
154 * @self: a #ModestAccountProtocol
156 * get the protocol standard port
160 guint modest_account_protocol_get_port (ModestAccountProtocol *self);
163 * modest_account_protocol_set_port:
164 * @self: a #ModestAccountProtocol
167 * set @port as the protocol standard port
169 void modest_account_protocol_set_port (ModestAccountProtocol *self,
173 * modest_account_protocol_get_alternate_port:
174 * @self: a #ModestAccountProtocol
176 * get the protocol standard alternate_port
180 guint modest_account_protocol_get_alternate_port (ModestAccountProtocol *self);
183 * modest_account_protocol_set_alternate_port:
184 * @self: a #ModestAccountProtocol
185 * @alternate_port: a #guint
187 * set @alternate_port as the protocol alternate port
189 void modest_account_protocol_set_alternate_port (ModestAccountProtocol *self,
190 guint alternate_port);
193 * modest_account_protocol_set_account_options:
194 * @self: a #ModestAccountProtocol
195 * @account_options: a #TnyList of account options and their values
197 * set the account options that will be passed to TnyCamelAccount for this protocol.
198 * This replaces previous option lists for this protocol
200 void modest_account_protocol_set_account_options (ModestAccountProtocol *self,
201 TnyList *account_options);
204 * modest_account_protocol_get_account_options:
205 * @self: a #ModestAccountProtocol
207 * obtain the account options for this account protocol.
209 * Returns: a caller-owner copy of the account options list.
211 TnyList *modest_account_protocol_get_account_options (ModestAccountProtocol *self);
214 * modest_account_protocol_has_custom_secure_auth_mech:
215 * @self: a #ModestAccountProtocol
216 * @auth_protocol_type: a #ModestProtocolType for an auth protocol
218 * checks whether there's a custom secure auth mech camel string for @auth_protocol_type.
220 * Returns: %TRUE if registered, %FALSE otherwise
223 modest_account_protocol_has_custom_secure_auth_mech (ModestAccountProtocol *self, ModestProtocolType auth_protocol_type);
226 * modest_account_protocol_get_custom_secure_auth_mech:
227 * @self: a #ModestAccountProtocol
228 * @auth_protocol_type: a #ModestProtocolType for an auth protocol
230 * obtains the secure auth mech of @auth_protocol_type in protocol. Be careful as %NULL does not imply
231 * there's no custom auth mech registered (you can register %NULL). To check if it's registered, just
232 * use modest_account_protocol_has_custom_secure_auth_mech().
234 * Returns: the secure auth mech for this auth protocol type that will be passed to camel.
237 modest_account_protocol_get_custom_secure_auth_mech (ModestAccountProtocol *self, ModestProtocolType auth_protocol_type);
240 * modest_account_protocol_unset_custom_secure_auth_mech:
241 * @self: a #ModestAccountProtocol
242 * @auth_protocol_type: a #ModestProtocolType for an auth protocol
244 * Unsets the secure auth meth of @auth_protocol_type in protocol.
247 modest_account_protocol_unset_custom_secure_auth_mech (ModestAccountProtocol *self, ModestProtocolType auth_protocol_type);
250 * modest_account_protocol_set_custom_secure_auth_mech:
251 * @self: a #ModestAccountProtocol
252 * @auth_protocol_type: a #ModestProtocolType for an auth protocol
253 * @secure_auth_mech: a string or %NULL
255 * sets the secure auth mech of @auth_protocol_type in protocol. Be careful as %NULL does not imply
256 * there's no custom auth mech registered (you can register %NULL). If you set %NULL you're regitering %NULL as the custom secure auth
257 * mechanism instead of unsetting it.
260 modest_account_protocol_set_custom_secure_auth_mech (ModestAccountProtocol *self, ModestProtocolType auth_protocol_type, const gchar *secure_auth_mech);
263 * modest_account_protocol_get_account_g_type:
264 * @self: a #ModestAccountProtocol
266 * get the protocol type used for factoring new TnyAccount
270 GType modest_account_protocol_get_account_g_type (ModestAccountProtocol *self);
273 * modest_account_protocol_set_account_g_type:
274 * @self: a #ModestAccountProtocol
275 * @account_g_type: a #GType
277 * set @account_g_type as the type modest_account_protocol_create_account will
280 void modest_account_protocol_set_account_g_type (ModestAccountProtocol *self,
281 GType account_g_type);
284 * modest_account_protocol_create_account:
285 * @self: a #ModestAccountProtocol
287 * create a new account instance for this protocol
289 * Returns: a #TnyAccount
291 TnyAccount * modest_account_protocol_create_account (ModestAccountProtocol *self);
294 * modest_account_protocol_get_account_settings_dialog:
295 * @self: a #ModestAccountProtocol
296 * @account_name: the name of the account we're creating the dialog for
298 * retrieves the account settings dialog used to setup the account
299 * represented by this protocol
301 * Returns: a #ModestAccountSettingsDialog
303 ModestAccountSettingsDialog* modest_account_protocol_get_account_settings_dialog (ModestAccountProtocol *self,
304 const gchar *account_name);
306 ModestPairList* modest_account_protocol_get_easysetupwizard_tabs (ModestAccountProtocol *self);
309 * modest_account_protocol_save_settings:
310 * @self: this #ModestAccountProtocol
311 * @dialog: a #ModestAccountSettingsDialog
312 * @settings: the #ModestAccountSettings
314 * this function stores the values held by the account settings dialog
315 * in the account settings object that is passed as argument
317 * NOTE: this function provides a default implementation that calls
318 * the save_settings method of the acocunt settings dialog. So if your
319 * implementation do not do anything more just do not redefine it
321 void modest_account_protocol_save_settings (ModestAccountProtocol *self,
322 ModestAccountSettingsDialog *dialog,
323 ModestAccountSettings *settings);
326 * modest_account_protocol_save_wizard_settings:
327 * @self: this #ModestAccountProtocol
328 * @wizard_pages: a list of #ModestEasysetupWizardPage
329 * @settings: the #ModestAccountSettings
331 * this function stores the data input by the users in the wizard in
332 * the account settings object passed as argument
334 void modest_account_protocol_save_wizard_settings (ModestAccountProtocol *self,
336 ModestAccountSettings *settings);
339 * modest_account_protocol_get_wizard_response_override:
340 * @self: a #ModestAccountProtocol
342 * obtains the method that should be used to override wizard response behavior when the
343 * wizard is setting up this account type.
345 * Returns: a #ModestWizardDialogResponseOverrideFunc
347 ModestWizardDialogResponseOverrideFunc modest_account_protocol_get_wizard_response_override (ModestAccountProtocol *self);
351 * modest_account_protocol_check_support:
352 * @self: a #ModestAccountProtocol
353 * @func: a #ModestAccountProtocolCheckSupportFunc
354 * @userdata: a gpointer
356 * This method checks asynchronously if the account protocol @self is
357 * supported. Once checked, @func will be called with the result in the
360 * modest_account_protocol_is_supported() should return the cached response
363 void modest_account_protocol_check_support (ModestAccountProtocol *self,
364 ModestAccountProtocolCheckSupportFunc func,
368 * modest_account_protocol_cancel_check_support:
369 * @self: a #ModestAccountProtocol
371 * This method requests that the check support requests running should be
372 * immediately cancelled. Once this happens, is_supported should return %FALSE
373 * until a new succesful check_support request is finished.
375 void modest_account_protocol_cancel_check_support (ModestAccountProtocol *self);
378 * modest_account_protocol_wizard_finished:
379 * @self: a #ModestAccountProtocol
381 * Method that let protocol know if the wizard has finished, for the case it's
382 * needed to do some stuff after check_support.
384 void modest_account_protocol_wizard_finished (ModestAccountProtocol *self);
387 * modest_account_protocol_is_supported:
388 * @self: a #ModestAccountProtocol
390 * Determines if the account protocol is supported on this device.
392 * Returns: %TRUE if the protocol is supported, %FALSE otherwise
394 gboolean modest_account_protocol_is_supported (ModestAccountProtocol *self);
397 * modest_account_protocol_get_from:
398 * @self: a #ModestAccountProtocol
399 * @account_id: a transport account name
400 * @mailbox: a mailbox
402 * Obtain the From: string for the account and mailbox. Should be used only
403 * with transports with multi mailbox support.
405 * Returns: a newly allocated string
407 gchar *modest_account_protocol_get_from (ModestAccountProtocol *self,
408 const gchar *account_id,
409 const gchar *mailbox);
412 * modest_account_protocol_get_from_list:
413 * @self: a #ModestAccountProtocol
414 * @account_id: a transport account name
416 * Obtain a list of pairs (mailbox - From: string) for filling the From picker.
418 * Returns: a ModestPairList
420 ModestPairList *modest_account_protocol_get_from_list (ModestAccountProtocol *self,
421 const gchar *account_id);
424 * modest_account_protocol_get_signature:
425 * @self: a #ModestAccountProtocol
426 * @account_id: a transport account name
427 * @mailbox: a mailbox
429 * Obtain the signature string for the account and mailbox. Should be used only
430 * with transports with multi mailbox support.
432 * Returns: a newly allocated string
434 gchar *modest_account_protocol_get_signature (ModestAccountProtocol *self,
435 const gchar *account_id,
436 const gchar *mailbox,
437 gboolean *has_signature);
440 * modest_account_protocol_get_icon:
441 * @self: a #ModestAccountProtocl
442 * @icon_type: a #ModestAccountProtocolIconType
443 * @object: a #GObject
444 * @icon_size: the icon size to get
446 * Returns a @self owned #GdkPixbuf with the icon for @icon_type and @object. @object type
447 * should match @icon_type.
449 * Returns: a #GdkPixbuf (don't free or manipulate this, just copy)
451 const GdkPixbuf * modest_account_protocol_get_icon (ModestAccountProtocol *self, ModestAccountProtocolIconType icon_type,
452 GObject *object, guint icon_size);
455 * modest_account_protocol_get_service_name:
456 * @self: a #ModestAccountProtocol
457 * @account_id: a transport account name
458 * @mailbox: a mailbox
460 * Obtain the service name string for the account and mailbox.
462 * Returns: a newly allocated string
464 gchar *modest_account_protocol_get_service_name (ModestAccountProtocol *self,
465 const gchar *account_id,
466 const gchar *mailbox);
469 * modest_account_protocol_get_service_icon:
470 * @self: a #ModestAccountProtocol
471 * @account_id: a transport account name
472 * @mailbox: a mailbox
474 * Obtain the service icon for the account and mailbox.
476 * Returns: a protocol owned #GdkPixbuf
478 const GdkPixbuf *modest_account_protocol_get_service_icon (ModestAccountProtocol *self,
479 const gchar *account_id,
480 const gchar *mailbox,
484 * modest_account_protocol_save_remote_draft:
485 * @self: a #ModestAccountProtocol
486 * @account_id: a transport account_name
487 * @new_msg: the newly created message in local storage.
488 * @old_msg: the old message
489 * @callback: the code that should be executed on finishing the remote message saving
490 * @userdata: a #gpointer
492 * Saves the just-saved to local draft, into a remote storage.
494 void modest_account_protocol_save_remote_draft (ModestAccountProtocol *self,
495 const gchar *account_id,
498 ModestAccountProtocolSaveRemoteDraftCallback callback,
502 * modest_account_protocol_decode_part_to_stream:
503 * @self: a #ModestAccountProtocol
504 * @part: a #TnyMimePart
505 * @stream_uri: a string
506 * @stream: a #TnyStream
507 * @written: a #gssize pointer, with the number of bytes written
510 * This virtual method delegates on the account protocol to decode @part
511 * into @stream. It just allows the provider to decode it as it needs
512 * (i.e. when the original message has a fake attachment, and provider
513 * can return the real attachment).
515 * The @stream_uri parameter tells the uri of the resource @stream is
516 * wrapping (if known).
518 * Returns: %TRUE if @protocol does the decode operation, %FALSE if modest
522 modest_account_protocol_decode_part_to_stream (ModestAccountProtocol *protocol,
524 const gchar *stream_uri,
530 * modest_account_protocol_decode_part_to_stream_async:
531 * @self: a #ModestAccountProtocol
532 * @part: a #TnyMimePart
533 * @stream_uri: a string
534 * @stream: a #TnyStream
536 * This virtual method delegates on the account protocol to decode @part
537 * into @stream, but asynchronously.
539 * The @stream_uri parameter tells the uri of the resource @stream is
540 * wrapping (if known).
542 * Returns: %TRUE if @protocol does the decode operation (then we shouldn't expect
543 * callback to happen from this call, %FALSE if modest should do it.
545 gboolean modest_account_protocol_decode_part_to_stream_async (ModestAccountProtocol *self,
547 const gchar *stream_uri,
549 TnyMimePartCallback callback,
550 TnyStatusCallback status_callback,
554 * modest_account_protocol_handle_calendar:
555 * @self: a #ModestAccountProtocol
556 * @window: the #ModestWindow requesting to handle calendar
557 * @calendar_part: a #TnyMimePart
558 * @container: a #GtkContainer (a #GtkVBox now)
560 * Instruct the account protocol to handle a calendar mime part. The account protocol
561 * will fill @container with the controls to handle the @calendar invitation.
563 * Returns: %TRUE if account protocol handles the calendar request, %FALSE otherwise
565 gboolean modest_account_protocol_handle_calendar (ModestAccountProtocol *self,
566 ModestWindow *window,
567 TnyMimePart *calendar_part,
568 GtkContainer *container);
573 #endif /* __MODEST_ACCOUNT_PROTOCOL_H__ */