~ubuntu-branches/ubuntu/wily/evolution-data-server/wily

« back to all changes in this revision

Viewing changes to modules/gnome-online-accounts/module-gnome-online-accounts.c

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2015-07-20 13:34:59 UTC
  • mfrom: (1.1.126) (1.2.48 sid)
  • Revision ID: package-import@ubuntu.com-20150720133459-g6y46hnu5ewtoz08
Tags: 3.16.4-0ubuntu2
debian/patches/0001-Bug-752373-Monthly-events-do-not-recur-correctly.patch:
Cherry-pick patch from upstream to fix events not recurring correctly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * module-gnome-online-accounts.c
3
3
 *
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.
7
7
 *
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.
12
12
 *
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/>.
15
15
 *
16
16
 */
17
17
 
23
23
 
24
24
#include "goaewsclient.h"
25
25
#include "e-goa-client.h"
26
 
#include "e-goa-password-based.h"
27
26
 
28
27
/* Standard GObject macros */
29
28
#define E_TYPE_GNOME_ONLINE_ACCOUNTS \
169
168
                                          GValue *target_value,
170
169
                                          gpointer unused)
171
170
{
 
171
        GoaObject *goa_object = GOA_OBJECT (g_binding_get_source (binding));
 
172
        ESourceExtension *source_extension = E_SOURCE_EXTENSION (g_binding_get_target (binding));
 
173
        ESource *source;
 
174
        ESourceGoa *goa_extension;
172
175
        gpointer v_object;
173
176
 
174
177
        v_object = g_value_get_object (source_value);
175
178
        g_value_set_boolean (target_value, v_object != NULL);
176
179
 
 
180
        g_return_val_if_fail (goa_object != NULL, TRUE);
 
181
        g_return_val_if_fail (source_extension != NULL, TRUE);
 
182
 
 
183
        source = e_source_extension_get_source (source_extension);
 
184
        goa_extension = e_source_get_extension (source, E_SOURCE_EXTENSION_GOA);
 
185
 
 
186
        if (g_strcmp0 (g_binding_get_source_property (binding), "calendar") == 0) {
 
187
                gchar *uri = NULL;
 
188
 
 
189
                if (v_object && GOA_IS_CALENDAR (v_object))
 
190
                        uri = goa_calendar_dup_uri (v_object);
 
191
 
 
192
                e_source_goa_set_calendar_url (goa_extension, uri);
 
193
 
 
194
                g_free (uri);
 
195
        } else if (g_strcmp0 (g_binding_get_source_property (binding), "contacts") == 0) {
 
196
                gchar *uri = NULL;
 
197
 
 
198
                if (v_object && GOA_IS_CONTACTS (v_object))
 
199
                        uri = goa_contacts_dup_uri (v_object);
 
200
 
 
201
                e_source_goa_set_contacts_url (goa_extension, uri);
 
202
 
 
203
                g_free (uri);
 
204
        }
 
205
 
177
206
        return TRUE;
178
207
}
179
208
 
235
264
}
236
265
 
237
266
static void
238
 
replace_host (gchar **url,
239
 
              const gchar *host)
240
 
{
241
 
        SoupURI *uri;
242
 
 
243
 
        uri = soup_uri_new (*url);
244
 
        if (!uri)
245
 
                return;
246
 
 
247
 
        soup_uri_set_host (uri, host);
248
 
 
249
 
        g_free (*url);
250
 
        *url = soup_uri_to_string (uri, FALSE);
251
 
 
252
 
        soup_uri_free (uri);
253
 
}
254
 
 
255
 
static void
256
267
gnome_online_accounts_config_exchange (EGnomeOnlineAccounts *extension,
257
268
                                       ESource *source,
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;
 
331
                SoupURI *suri;
 
332
                gchar *user, *email;
321
333
 
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);
326
337
 
327
 
                if (host && *host) {
328
 
                        replace_host (&as_url, host);
329
 
                        replace_host (&oab_url, host);
330
 
                }
 
338
                suri = soup_uri_new (as_url);
331
339
 
332
340
                g_object_set (
333
341
                        source_extension,
341
349
 
342
350
                g_object_set (
343
351
                        settings,
344
 
                        "host", host,
 
352
                        "host", soup_uri_get_host (suri),
345
353
                        "user", user,
346
354
                        "email", email,
347
355
                        NULL);
348
356
 
349
 
                g_free (host);
 
357
                soup_uri_free (suri);
350
358
                g_free (user);
351
359
                g_free (email);
352
360
        } else {
578
586
        goa_calendar = goa_object_get_calendar (goa_object);
579
587
        goa_contacts = goa_object_get_contacts (goa_object);
580
588
 
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);
588
596
 
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);
593
601
 
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);
599
607
        }
600
608
 
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);
610
618
 
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,
616
624
                NULL,
617
625
                NULL, (GDestroyNotify) NULL);
618
626
 
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);
623
631
 
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,
629
637
                NULL,
630
638
                NULL, (GDestroyNotify) NULL);
631
639
 
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,
637
645
                NULL,
638
646
                NULL, (GDestroyNotify) NULL);
639
647
 
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);
654
662
 
 
663
        e_server_side_source_set_writable (E_SERVER_SIDE_SOURCE (source), TRUE);
 
664
 
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);
658
 
 
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);
664
 
        }
 
666
        e_server_side_source_set_removable (E_SERVER_SIDE_SOURCE (source), FALSE);
665
667
 
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;
 
710
        gchar *tmp;
706
711
 
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 */
 
714
        if (!goa_mail)
 
715
                return;
709
716
 
710
717
        extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
711
718
        source_extension = e_source_get_extension (source, extension_name);
712
719
 
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);
717
724
 
718
725
        g_object_unref (goa_mail);
719
726
 
 
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);
 
730
        if (!tmp || !*tmp)
 
731
                e_source_mail_submission_set_sent_folder (mail_submission, "folder://local/Sent");
 
732
        g_free (tmp);
 
733
 
 
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);
 
737
        if (!tmp || !*tmp)
 
738
                e_source_mail_composition_set_drafts_folder (mail_composition, "folder://local/Drafts");
 
739
        g_free (tmp);
 
740
 
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);
915
936
 
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);
919
940
 
920
941
        if (backend_factory != NULL) {
921
942
                gnome_online_accounts_create_collection (
1337
1358
e_module_load (GTypeModule *type_module)
1338
1359
{
1339
1360
        e_goa_client_type_register (type_module);
1340
 
        e_goa_password_based_type_register (type_module);
1341
1361
        e_gnome_online_accounts_register_type (type_module);
1342
1362
}
1343
1363