| 1 |
/* |
| 2 |
* SPDX-FileCopyrightText: (C) 2016 Red Hat, Inc. (www.redhat.com) |
| 3 |
* SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
*/ |
| 5 |
|
| 6 |
#include "evolution-ews-config.h" |
| 7 |
|
| 8 |
#include <libebackend/libebackend.h> |
| 9 |
#include <libedataserver/libedataserver.h> |
| 10 |
|
| 11 |
#include <e-util/e-util.h> |
| 12 |
#include <mail/e-mail-config-provider-page.h> |
| 13 |
|
| 14 |
#include "e-mail-config-ews-offline-options.h" |
| 15 |
|
| 16 |
/* Standard GObject macros */ |
| 17 |
#define E_TYPE_MAIL_CONFIG_EWS_OFFLINE_OPTIONS \ |
| 18 |
(e_mail_config_ews_offline_options_get_type ()) |
| 19 |
#define E_MAIL_CONFIG_EWS_OFFLINE_OPTIONS(obj) \ |
| 20 |
(G_TYPE_CHECK_INSTANCE_CAST \ |
| 21 |
((obj), E_TYPE_MAIL_CONFIG_EWS_OFFLINE_OPTIONS, EMailConfigEwsOfflineOptions)) |
| 22 |
#define E_MAIL_CONFIG_EWS_OFFLINE_OPTIONS_CLASS(cls) \ |
| 23 |
(G_TYPE_CHECK_CLASS_CAST \ |
| 24 |
((cls), E_TYPE_MAIL_CONFIG_EWS_OFFLINE_OPTIONS, EMailConfigEwsOfflineOptionsClass)) |
| 25 |
#define E_IS_MAIL_CONFIG_EWS_OFFLINE_OPTIONS(obj) \ |
| 26 |
(G_TYPE_CHECK_INSTANCE_TYPE \ |
| 27 |
((obj), E_TYPE_MAIL_CONFIG_EWS_OFFLINE_OPTIONS)) |
| 28 |
#define E_IS_MAIL_CONFIG_EWS_OFFLINE_OPTIONS_CLASS(cls) \ |
| 29 |
(G_TYPE_CHECK_CLASS_TYPE \ |
| 30 |
((cls), E_TYPE_MAIL_CONFIG_EWS_OFFLINE_OPTIONS)) |
| 31 |
#define E_MAIL_CONFIG_EWS_OFFLINE_OPTIONS_GET_CLASS(obj) \ |
| 32 |
(G_TYPE_INSTANCE_GET_CLASS \ |
| 33 |
((obj), E_TYPE_MAIL_CONFIG_EWS_OFFLINE_OPTIONS, EMailConfigEwsOfflineOptionsClass)) |
| 34 |
|
| 35 |
typedef struct _EMailConfigEwsOfflineOptions EMailConfigEwsOfflineOptions; |
| 36 |
typedef struct _EMailConfigEwsOfflineOptionsClass EMailConfigEwsOfflineOptionsClass; |
| 37 |
|
| 38 |
struct _EMailConfigEwsOfflineOptions { |
| 39 |
EExtension parent; |
| 40 |
}; |
| 41 |
|
| 42 |
struct _EMailConfigEwsOfflineOptionsClass { |
| 43 |
EExtensionClass parent_class; |
| 44 |
}; |
| 45 |
|
| 46 |
GType e_mail_config_ews_offline_options_get_type |
| 47 |
(void) G_GNUC_CONST; |
| 48 |
|
| 49 |
G_DEFINE_DYNAMIC_TYPE (EMailConfigEwsOfflineOptions, e_mail_config_ews_offline_options, E_TYPE_EXTENSION) |
| 50 |
|
| 51 |
static void |
| 52 |
mail_config_ews_offline_options_constructed (GObject *object) |
| 53 |
{ |
| 54 |
EMailConfigProviderPage *provider_page; |
| 55 |
EMailConfigServiceBackend *backend; |
| 56 |
CamelProvider *provider; |
| 57 |
CamelSettings *settings; |
| 58 |
GtkBox *placeholder; |
| 59 |
GtkWidget *hbox; |
| 60 |
|
| 61 |
/* Chain up to parent's constructed() method. */ |
| 62 |
G_OBJECT_CLASS (e_mail_config_ews_offline_options_parent_class)->constructed (object); |
| 63 |
|
| 64 |
provider_page = E_MAIL_CONFIG_PROVIDER_PAGE (e_extension_get_extensible (E_EXTENSION (object))); |
| 65 |
backend = e_mail_config_provider_page_get_backend (provider_page); |
| 66 |
provider = e_mail_config_service_backend_get_provider (backend); |
| 67 |
settings = e_mail_config_service_backend_get_settings (backend); |
| 68 |
|
| 69 |
if (e_mail_config_provider_page_is_empty (provider_page) || |
| 70 |
!provider || g_strcmp0 (provider->protocol, "ews") != 0) |
| 71 |
return; |
| 72 |
|
| 73 |
g_return_if_fail (CAMEL_IS_OFFLINE_SETTINGS (settings)); |
| 74 |
|
| 75 |
placeholder = e_mail_config_provider_page_get_placeholder (provider_page, "ews-limit-by-age-placeholder"); |
| 76 |
g_return_if_fail (placeholder != NULL); |
| 77 |
|
| 78 |
hbox = e_dialog_offline_settings_new_limit_box (CAMEL_OFFLINE_SETTINGS (settings)); |
| 79 |
gtk_box_pack_start (placeholder, hbox, FALSE, FALSE, 0); |
| 80 |
gtk_widget_show (hbox); |
| 81 |
} |
| 82 |
|
| 83 |
static void |
| 84 |
e_mail_config_ews_offline_options_class_init (EMailConfigEwsOfflineOptionsClass *class) |
| 85 |
{ |
| 86 |
GObjectClass *object_class; |
| 87 |
EExtensionClass *extension_class; |
| 88 |
|
| 89 |
object_class = G_OBJECT_CLASS (class); |
| 90 |
object_class->constructed = mail_config_ews_offline_options_constructed; |
| 91 |
|
| 92 |
extension_class = E_EXTENSION_CLASS (class); |
| 93 |
extension_class->extensible_type = E_TYPE_MAIL_CONFIG_PROVIDER_PAGE; |
| 94 |
} |
| 95 |
|
| 96 |
static void |
| 97 |
e_mail_config_ews_offline_options_class_finalize (EMailConfigEwsOfflineOptionsClass *class) |
| 98 |
{ |
| 99 |
} |
| 100 |
|
| 101 |
static void |
| 102 |
e_mail_config_ews_offline_options_init (EMailConfigEwsOfflineOptions *extension) |
| 103 |
{ |
| 104 |
} |
| 105 |
|
| 106 |
void |
| 107 |
e_mail_config_ews_offline_options_type_register (GTypeModule *type_module) |
| 108 |
{ |
| 109 |
/* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration |
| 110 |
* function, so we have to wrap it with a public function in |
| 111 |
* order to register types from a separate compilation unit. */ |
| 112 |
e_mail_config_ews_offline_options_register_type (type_module); |
| 113 |
} |