[gnome-online-accounts] Added Printers capability and use it in google backend
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts] Added Printers capability and use it in google backend
- Date: Mon, 3 Feb 2014 17:28:48 +0000 (UTC)
commit 6c388ff60ea7ef308f3c2c4459655163f5a213a5
Author: Tim Waugh <twaugh redhat com>
Date: Fri Jan 31 17:39:51 2014 +0000
Added Printers capability and use it in google backend
This is used in the cloudprint GTK+ print module:
https://bugzilla.gnome.org/show_bug.cgi?id=723368
https://bugzilla.gnome.org/show_bug.cgi?id=723370
README | 1 +
data/dbus-interfaces.xml | 22 +++++++++++++++++++
src/goabackend/goabackendenums.h | 4 ++-
src/goabackend/goagoogleprovider.c | 41 ++++++++++++++++++++++++++++++++++-
4 files changed, 65 insertions(+), 3 deletions(-)
---
diff --git a/README b/README
index f80a891..2cb2cb7 100644
--- a/README
+++ b/README
@@ -36,6 +36,7 @@ https://developers.google.com/google-apps/contacts/v3/
https://developers.google.com/google-apps/documents-list/
https://developers.google.com/google-apps/gmail/oauth_protocol
https://developers.google.com/talk/jep_extensions/oauth
+https://developers.google.com/cloud-print/docs/devguide
Notes:
We are allowed to embed the client_secret in the source code. See
diff --git a/data/dbus-interfaces.xml b/data/dbus-interfaces.xml
index 1545ef5..bde4075 100644
--- a/data/dbus-interfaces.xml
+++ b/data/dbus-interfaces.xml
@@ -165,6 +165,18 @@
-->
<property name="DocumentsDisabled" type="b" access="readwrite"/>
+ <!-- PrintersDisabled:
+ @since: 3.12.0
+
+ If %TRUE, the account will not expose any
+ #org.gnome.OnlineAccounts.Printers interface. If the account does not
+ provide printers-like capabilities, this property does nothing.
+
+ Note that the #org.gnomeOnlineAccounts.Printers interface is added or
+ removed from the account asynchronously.
+ -->
+ <property name="PrintersDisabled" type="b" access="readwrite"/>
+
<!-- PhotosDisabled:
@since: 3.8.0
@@ -693,4 +705,14 @@
<interface name="org.gnome.OnlineAccounts.ReadLater">
</interface>
+ <!--
+ org.gnome.OnlineAccounts.Printers:
+ @since: 3.12.0
+
+ An account object implements this interface if it provides
+ network printing capabilities.
+ -->
+ <interface name="org.gnome.OnlineAccounts.Printers">
+ </interface>
+
</node>
diff --git a/src/goabackend/goabackendenums.h b/src/goabackend/goabackendenums.h
index 5af588b..291619b 100644
--- a/src/goabackend/goabackendenums.h
+++ b/src/goabackend/goabackendenums.h
@@ -1,6 +1,6 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
- * Copyright (C) 2011, 2012 Red Hat, Inc.
+ * Copyright (C) 2011, 2012, 2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -68,6 +68,7 @@ typedef enum
* @GOA_PROVIDER_FEATURE_PHOTOS: Photos storage services (ie. Flickr).
* @GOA_PROVIDER_FEATURE_FILES: Files storage services (ie. WebDAV).
* @GOA_PROVIDER_FEATURE_TICKETING: Ticketing services (ie. Kerberos).
+ * @GOA_PROVIDER_FEATURE_PRINTERS: Network printing services (e.g. Google Cloud Print).
* @GOA_PROVIDER_FEATURE_INVALID: Used for error handling. No provider
* should provide this feature.
*
@@ -90,6 +91,7 @@ typedef enum /*< flags >*/
GOA_PROVIDER_FEATURE_FILES = 1 << 8,
GOA_PROVIDER_FEATURE_TICKETING = 1 << 9,
GOA_PROVIDER_FEATURE_READ_LATER= 1 << 10,
+ GOA_PROVIDER_FEATURE_PRINTERS = 1 << 11,
GOA_PROVIDER_FEATURE_INVALID = 0
} GoaProviderFeatures;
diff --git a/src/goabackend/goagoogleprovider.c b/src/goabackend/goagoogleprovider.c
index e547d97..12bacbb 100644
--- a/src/goabackend/goagoogleprovider.c
+++ b/src/goabackend/goagoogleprovider.c
@@ -94,7 +94,8 @@ get_provider_features (GoaProvider *_provider)
GOA_PROVIDER_FEATURE_CALENDAR |
GOA_PROVIDER_FEATURE_CONTACTS |
GOA_PROVIDER_FEATURE_CHAT |
- GOA_PROVIDER_FEATURE_DOCUMENTS;
+ GOA_PROVIDER_FEATURE_DOCUMENTS |
+ GOA_PROVIDER_FEATURE_PRINTERS;
}
static const gchar *
@@ -141,6 +142,9 @@ get_scope (GoaOAuth2Provider *provider)
/* GMail IMAP and SMTP access */
"https://mail.google.com/ "
+ /* Google Cloud Print */
+ "https://www.googleapis.com/auth/cloudprint "
+
/* Google Talk */
"https://www.googleapis.com/auth/googletalk";
}
@@ -148,7 +152,7 @@ get_scope (GoaOAuth2Provider *provider)
static guint
get_credentials_generation (GoaProvider *provider)
{
- return 6;
+ return 7;
}
static const gchar *
@@ -319,12 +323,14 @@ build_object (GoaProvider *provider,
GoaContacts *contacts;
GoaChat *chat;
GoaDocuments *documents;
+ GoaPrinters *printers;
gboolean ret;
gboolean mail_enabled;
gboolean calendar_enabled;
gboolean contacts_enabled;
gboolean chat_enabled;
gboolean documents_enabled;
+ gboolean printers_enabled;
const gchar *email_address;
account = NULL;
@@ -333,6 +339,7 @@ build_object (GoaProvider *provider,
contacts = NULL;
chat = NULL;
documents = NULL;
+ printers = NULL;
ret = FALSE;
/* Chain up */
@@ -461,6 +468,24 @@ build_object (GoaProvider *provider,
goa_object_skeleton_set_documents (object, NULL);
}
+ /* Printers */
+ printers = goa_object_get_printers (GOA_OBJECT (object));
+ printers_enabled = g_key_file_get_boolean (key_file, group, "PrintersEnabled", NULL);
+
+ if (printers_enabled)
+ {
+ if (printers == NULL)
+ {
+ printers = goa_printers_skeleton_new ();
+ goa_object_skeleton_set_printers (object, printers);
+ }
+ }
+ else
+ {
+ if (printers != NULL)
+ goa_object_skeleton_set_printers (object, NULL);
+ }
+
if (just_added)
{
goa_account_set_mail_disabled (account, !mail_enabled);
@@ -468,6 +493,7 @@ build_object (GoaProvider *provider,
goa_account_set_contacts_disabled (account, !contacts_enabled);
goa_account_set_chat_disabled (account, !chat_enabled);
goa_account_set_documents_disabled (account, !documents_enabled);
+ goa_account_set_printers_disabled (account, !printers_enabled);
g_signal_connect (account,
"notify::mail-disabled",
@@ -489,11 +515,16 @@ build_object (GoaProvider *provider,
"notify::documents-disabled",
G_CALLBACK (goa_util_account_notify_property_cb),
"DocumentsEnabled");
+ g_signal_connect (account,
+ "notify::printers-disabled",
+ G_CALLBACK (goa_util_account_notify_property_cb),
+ "PrintersEnabled");
}
ret = TRUE;
out:
+ g_clear_object (&printers);
g_clear_object (&documents);
g_clear_object (&chat);
g_clear_object (&contacts);
@@ -553,6 +584,11 @@ show_account (GoaProvider *provider,
NULL,
"documents-disabled",
_("_Documents"));
+
+ goa_util_add_row_switch_from_keyfile_with_blurb (grid, row++, object,
+ NULL,
+ "printers-disabled",
+ _("_Printers"));
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -566,6 +602,7 @@ add_account_key_values (GoaOAuth2Provider *provider,
g_variant_builder_add (builder, "{ss}", "ContactsEnabled", "true");
g_variant_builder_add (builder, "{ss}", "ChatEnabled", "true");
g_variant_builder_add (builder, "{ss}", "DocumentsEnabled", "true");
+ g_variant_builder_add (builder, "{ss}", "PrintersEnabled", "true");
}
/* ---------------------------------------------------------------------------------------------------- */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]