2
2
* module-gnome-online-accounts.c
4
* This library is free software you can redistribute it and/or modify it
4
* This library is free software: you can redistribute it and/or modify it
5
5
* under the terms of the GNU Lesser General Public License as published by
6
6
* the Free Software Foundation.
8
8
* This library is distributed in the hope that it will be useful, but
9
9
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
10
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11
11
* for more details.
13
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this library; if not, see <http://www.gnu.org/licenses/>.
14
* along with this library. If not, see <http://www.gnu.org/licenses/>.
24
24
#include "goaewsclient.h"
25
25
#include "e-goa-client.h"
26
#include "e-goa-password-based.h"
28
27
/* Standard GObject macros */
29
28
#define E_TYPE_GNOME_ONLINE_ACCOUNTS \
169
168
GValue *target_value,
171
GoaObject *goa_object = GOA_OBJECT (g_binding_get_source (binding));
172
ESourceExtension *source_extension = E_SOURCE_EXTENSION (g_binding_get_target (binding));
174
ESourceGoa *goa_extension;
172
175
gpointer v_object;
174
177
v_object = g_value_get_object (source_value);
175
178
g_value_set_boolean (target_value, v_object != NULL);
180
g_return_val_if_fail (goa_object != NULL, TRUE);
181
g_return_val_if_fail (source_extension != NULL, TRUE);
183
source = e_source_extension_get_source (source_extension);
184
goa_extension = e_source_get_extension (source, E_SOURCE_EXTENSION_GOA);
186
if (g_strcmp0 (g_binding_get_source_property (binding), "calendar") == 0) {
189
if (v_object && GOA_IS_CALENDAR (v_object))
190
uri = goa_calendar_dup_uri (v_object);
192
e_source_goa_set_calendar_url (goa_extension, uri);
195
} else if (g_strcmp0 (g_binding_get_source_property (binding), "contacts") == 0) {
198
if (v_object && GOA_IS_CONTACTS (v_object))
199
uri = goa_contacts_dup_uri (v_object);
201
e_source_goa_set_contacts_url (goa_extension, uri);
238
replace_host (gchar **url,
243
uri = soup_uri_new (*url);
247
soup_uri_set_host (uri, host);
250
*url = soup_uri_to_string (uri, FALSE);
256
267
gnome_online_accounts_config_exchange (EGnomeOnlineAccounts *extension,
258
269
GoaObject *goa_object)
317
328
if (source_extension != NULL) {
318
329
GoaAccount *goa_account;
319
330
CamelSettings *settings;
320
gchar *host, *user, *email;
322
334
goa_account = goa_object_peek_account (goa_object);
323
host = goa_exchange_dup_host (goa_exchange);
324
335
user = goa_account_dup_identity (goa_account);
325
336
email = goa_account_dup_presentation_identity (goa_account);
328
replace_host (&as_url, host);
329
replace_host (&oab_url, host);
338
suri = soup_uri_new (as_url);
333
341
source_extension,
578
586
goa_calendar = goa_object_get_calendar (goa_object);
579
587
goa_contacts = goa_object_get_contacts (goa_object);
581
g_object_bind_property (
589
e_binding_bind_property (
582
590
goa_account, "presentation-identity",
583
591
source, "display-name",
584
592
G_BINDING_SYNC_CREATE);
586
594
extension_name = E_SOURCE_EXTENSION_GOA;
587
595
source_extension = e_source_get_extension (source, extension_name);
589
g_object_bind_property (
597
e_binding_bind_property (
590
598
goa_account, "id",
591
599
source_extension, "account-id",
592
600
G_BINDING_SYNC_CREATE);
594
602
if (goa_calendar != NULL) {
595
g_object_bind_property (
603
e_binding_bind_property (
596
604
goa_calendar, "uri",
597
605
source_extension, "calendar-url",
598
606
G_BINDING_SYNC_CREATE);
601
609
if (goa_contacts != NULL) {
602
g_object_bind_property (
610
e_binding_bind_property (
603
611
goa_contacts, "uri",
604
612
source_extension, "contacts-url",
605
613
G_BINDING_SYNC_CREATE);
608
616
extension_name = E_SOURCE_EXTENSION_COLLECTION;
609
617
source_extension = e_source_get_extension (source, extension_name);
611
g_object_bind_property_full (
619
e_binding_bind_property_full (
612
620
goa_account, "provider-type",
613
621
source_extension, "backend-name",
614
622
G_BINDING_SYNC_CREATE,
617
625
NULL, (GDestroyNotify) NULL);
619
g_object_bind_property (
627
e_binding_bind_property (
620
628
goa_account, "identity",
621
629
source_extension, "identity",
622
630
G_BINDING_SYNC_CREATE);
624
g_object_bind_property_full (
632
e_binding_bind_property_full (
625
633
goa_object, "calendar",
626
634
source_extension, "calendar-enabled",
627
635
G_BINDING_SYNC_CREATE,
630
638
NULL, (GDestroyNotify) NULL);
632
g_object_bind_property_full (
640
e_binding_bind_property_full (
633
641
goa_object, "contacts",
634
642
source_extension, "contacts-enabled",
635
643
G_BINDING_SYNC_CREATE,
638
646
NULL, (GDestroyNotify) NULL);
640
g_object_bind_property_full (
648
e_binding_bind_property_full (
641
649
goa_object, "mail",
642
650
source_extension, "mail-enabled",
643
651
G_BINDING_SYNC_CREATE,
652
660
/* Handle optional GOA interfaces. */
653
661
gnome_online_accounts_config_exchange (extension, source, goa_object);
663
e_server_side_source_set_writable (E_SERVER_SIDE_SOURCE (source), TRUE);
655
665
/* The data source should not be removable by clients. */
656
e_server_side_source_set_removable (
657
E_SERVER_SIDE_SOURCE (source), FALSE);
659
if (goa_object_peek_password_based (goa_object) != NULL) {
660
/* Obtain passwords from the OnlineAccounts service. */
661
e_server_side_source_set_auth_session_type (
662
E_SERVER_SIDE_SOURCE (source),
663
E_TYPE_GOA_PASSWORD_BASED);
666
e_server_side_source_set_removable (E_SERVER_SIDE_SOURCE (source), FALSE);
666
668
if (goa_object_peek_oauth2_based (goa_object) != NULL) {
667
669
/* This module provides OAuth 2.0 support to the collection.
702
704
GoaMail *goa_mail;
703
705
ESourceExtension *source_extension;
704
706
EServerSideSource *server_side_source;
707
ESourceMailSubmission *mail_submission;
708
ESourceMailComposition *mail_composition;
705
709
const gchar *extension_name;
707
712
goa_mail = goa_object_get_mail (goa_object);
708
g_return_if_fail (goa_mail != NULL);
713
/* NULL, when the Mail part is disabled */
710
717
extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
711
718
source_extension = e_source_get_extension (source, extension_name);
713
g_object_bind_property (
720
e_binding_bind_property (
714
721
goa_mail, "email-address",
715
722
source_extension, "address",
716
723
G_BINDING_SYNC_CREATE);
718
725
g_object_unref (goa_mail);
727
/* Set default Sent folder to the On This Computer/Sent */
728
mail_submission = e_source_get_extension (source, E_SOURCE_EXTENSION_MAIL_SUBMISSION);
729
tmp = e_source_mail_submission_dup_sent_folder (mail_submission);
731
e_source_mail_submission_set_sent_folder (mail_submission, "folder://local/Sent");
734
/* Set default Drafts folder to the On This Computer/Drafts */
735
mail_composition = e_source_get_extension (source, E_SOURCE_EXTENSION_MAIL_COMPOSITION);
736
tmp = e_source_mail_composition_dup_drafts_folder (mail_composition);
738
e_source_mail_composition_set_drafts_folder (mail_composition, "folder://local/Drafts");
720
741
/* Clients may change the source by may not remove it. */
721
742
server_side_source = E_SERVER_SIDE_SOURCE (source);
722
743
e_server_side_source_set_writable (server_side_source, TRUE);
916
937
if (source_uid == NULL && backend_name != NULL)
917
938
backend_factory = e_data_factory_ref_backend_factory (
918
E_DATA_FACTORY (server), backend_name);
939
E_DATA_FACTORY (server), backend_name, E_SOURCE_EXTENSION_COLLECTION);
920
941
if (backend_factory != NULL) {
921
942
gnome_online_accounts_create_collection (