~ubuntu-branches/ubuntu/utopic/gnome-online-accounts/utopic

« back to all changes in this revision

Viewing changes to src/goabackend/goagoogleprovider.c

  • Committer: Package Import Robot
  • Author(s): Andreas Henriksson, Laurent Bigonville, Andreas Henriksson
  • Date: 2014-05-16 11:42:52 UTC
  • mfrom: (1.1.28) (0.1.12 sid)
  • Revision ID: package-import@ubuntu.com-20140516114252-u5ect6mk6ht8i38x
Tags: 3.12.2-1
[ Laurent Bigonville ]
* debian/control.in: Recommends realmd package (Closes: #725965)

[ Andreas Henriksson ]
* New upstream release.
  - Removes chat support from Windows Live provider (XMPP gateway gone).
* Bump Standards-Version to 3.9.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2
2
/*
3
 
 * Copyright (C) 2011, 2012, 2013 Red Hat, Inc.
 
3
 * Copyright (C) 2011, 2012, 2013, 2014 Red Hat, Inc.
4
4
 *
5
5
 * This library is free software; you can redistribute it and/or
6
6
 * modify it under the terms of the GNU Lesser General Public
13
13
 * Lesser General Public License for more details.
14
14
 *
15
15
 * You should have received a copy of the GNU Lesser General
16
 
 * Public License along with this library; if not, write to the
17
 
 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18
 
 * Boston, MA 02111-1307, USA.
 
16
 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
19
17
 *
20
18
 * Authors: David Zeuthen <davidz@redhat.com>
21
19
 *          Debarshi Ray <debarshir@gnome.org>
27
25
#include <rest/oauth-proxy.h>
28
26
#include <json-glib/json-glib.h>
29
27
 
30
 
#include "goalogging.h"
31
28
#include "goaprovider.h"
32
29
#include "goaprovider-priv.h"
33
30
#include "goaoauth2provider.h"
96
93
         GOA_PROVIDER_FEATURE_CALENDAR |
97
94
         GOA_PROVIDER_FEATURE_CONTACTS |
98
95
         GOA_PROVIDER_FEATURE_CHAT |
99
 
         GOA_PROVIDER_FEATURE_DOCUMENTS;
 
96
         GOA_PROVIDER_FEATURE_DOCUMENTS |
 
97
         GOA_PROVIDER_FEATURE_PRINTERS;
100
98
}
101
99
 
102
100
static const gchar *
123
121
  return /* Read-only access to the user's email address */
124
122
         "https://www.googleapis.com/auth/userinfo.email "
125
123
 
 
124
         /* Name and picture */
 
125
         "https://www.googleapis.com/auth/userinfo.profile "
 
126
 
126
127
         /* Google Calendar API (CalDAV and GData) */
127
128
         "https://www.googleapis.com/auth/calendar "
128
129
 
140
141
         /* GMail IMAP and SMTP access */
141
142
         "https://mail.google.com/ "
142
143
 
 
144
         /* Google Cloud Print */
 
145
         "https://www.googleapis.com/auth/cloudprint "
 
146
 
143
147
         /* Google Talk */
144
148
         "https://www.googleapis.com/auth/googletalk";
145
149
}
147
151
static guint
148
152
get_credentials_generation (GoaProvider *provider)
149
153
{
150
 
  return 5;
 
154
  return 7;
151
155
}
152
156
 
153
157
static const gchar *
207
211
      g_set_error (error,
208
212
                   GOA_ERROR,
209
213
                   GOA_ERROR_FAILED,
210
 
                   _("Expected status 200 when requesting guid, instead got status %d (%s)"),
 
214
                   _("Expected status 200 when requesting your identity, instead got status %d (%s)"),
211
215
                   rest_proxy_call_get_status_code (call),
212
216
                   rest_proxy_call_get_status_message (call));
213
217
      goto out;
219
223
                                   rest_proxy_call_get_payload_length (call),
220
224
                                   &identity_error))
221
225
    {
222
 
      goa_warning ("json_parser_load_from_data() failed: %s (%s, %d)",
223
 
                   identity_error->message,
224
 
                   g_quark_to_string (identity_error->domain),
225
 
                   identity_error->code);
 
226
      g_warning ("json_parser_load_from_data() failed: %s (%s, %d)",
 
227
                 identity_error->message,
 
228
                 g_quark_to_string (identity_error->domain),
 
229
                 identity_error->code);
226
230
      g_set_error (error,
227
231
                   GOA_ERROR,
228
232
                   GOA_ERROR_FAILED,
234
238
  email = g_strdup (json_object_get_string_member (json_object, "email"));
235
239
  if (email == NULL)
236
240
    {
237
 
      goa_warning ("Did not find email in JSON data");
 
241
      g_warning ("Did not find email in JSON data");
238
242
      g_set_error (error,
239
243
                   GOA_ERROR,
240
244
                   GOA_ERROR_FAILED,
318
322
  GoaContacts *contacts;
319
323
  GoaChat *chat;
320
324
  GoaDocuments *documents;
 
325
  GoaPrinters *printers;
321
326
  gboolean ret;
322
327
  gboolean mail_enabled;
323
328
  gboolean calendar_enabled;
324
329
  gboolean contacts_enabled;
325
330
  gboolean chat_enabled;
326
331
  gboolean documents_enabled;
 
332
  gboolean printers_enabled;
327
333
  const gchar *email_address;
328
334
 
329
335
  account = NULL;
332
338
  contacts = NULL;
333
339
  chat = NULL;
334
340
  documents = NULL;
 
341
  printers = NULL;
335
342
  ret = FALSE;
336
343
 
337
344
  /* Chain up */
365
372
                        "smtp-host",       "smtp.gmail.com",
366
373
                        "smtp-user-name",  email_address,
367
374
                        "smtp-use-auth",   TRUE,
 
375
                        "smtp-auth-xoauth2", TRUE,
368
376
                        "smtp-use-tls",    TRUE,
369
377
                        NULL);
370
378
          goa_object_skeleton_set_mail (object, mail);
459
467
        goa_object_skeleton_set_documents (object, NULL);
460
468
    }
461
469
 
 
470
  /* Printers */
 
471
  printers = goa_object_get_printers (GOA_OBJECT (object));
 
472
  printers_enabled = g_key_file_get_boolean (key_file, group, "PrintersEnabled", NULL);
 
473
 
 
474
  if (printers_enabled)
 
475
    {
 
476
      if (printers == NULL)
 
477
        {
 
478
          printers = goa_printers_skeleton_new ();
 
479
          goa_object_skeleton_set_printers (object, printers);
 
480
        }
 
481
    }
 
482
  else
 
483
    {
 
484
      if (printers != NULL)
 
485
        goa_object_skeleton_set_printers (object, NULL);
 
486
    }
 
487
 
462
488
  if (just_added)
463
489
    {
464
490
      goa_account_set_mail_disabled (account, !mail_enabled);
466
492
      goa_account_set_contacts_disabled (account, !contacts_enabled);
467
493
      goa_account_set_chat_disabled (account, !chat_enabled);
468
494
      goa_account_set_documents_disabled (account, !documents_enabled);
 
495
      goa_account_set_printers_disabled (account, !printers_enabled);
469
496
 
470
497
      g_signal_connect (account,
471
498
                        "notify::mail-disabled",
487
514
                        "notify::documents-disabled",
488
515
                        G_CALLBACK (goa_util_account_notify_property_cb),
489
516
                        "DocumentsEnabled");
 
517
      g_signal_connect (account,
 
518
                        "notify::printers-disabled",
 
519
                        G_CALLBACK (goa_util_account_notify_property_cb),
 
520
                        "PrintersEnabled");
490
521
    }
491
522
 
492
523
  ret = TRUE;
493
524
 
494
525
 out:
 
526
  g_clear_object (&printers);
495
527
  g_clear_object (&documents);
496
528
  g_clear_object (&chat);
497
529
  g_clear_object (&contacts);
526
558
  goa_util_add_account_info (grid, row++, object);
527
559
 
528
560
  goa_util_add_row_switch_from_keyfile_with_blurb (grid, row++, object,
 
561
                                                   /* Translators: This is a label for a series of
 
562
                                                    * options switches. For example: “Use for Mail”. */
529
563
                                                   _("Use for"),
530
564
                                                   "mail-disabled",
531
565
                                                   _("_Mail"));
549
583
                                                   NULL,
550
584
                                                   "documents-disabled",
551
585
                                                   _("_Documents"));
 
586
 
 
587
  goa_util_add_row_switch_from_keyfile_with_blurb (grid, row++, object,
 
588
                                                   NULL,
 
589
                                                   "printers-disabled",
 
590
                                                   _("_Printers"));
552
591
}
553
592
 
554
593
/* ---------------------------------------------------------------------------------------------------- */
562
601
  g_variant_builder_add (builder, "{ss}", "ContactsEnabled", "true");
563
602
  g_variant_builder_add (builder, "{ss}", "ChatEnabled", "true");
564
603
  g_variant_builder_add (builder, "{ss}", "DocumentsEnabled", "true");
 
604
  g_variant_builder_add (builder, "{ss}", "PrintersEnabled", "true");
565
605
}
566
606
 
567
607
/* ---------------------------------------------------------------------------------------------------- */