summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2011-05-25 17:30:17 -0400
committerDavid Zeuthen <davidz@redhat.com>2011-05-25 17:30:17 -0400
commitb1db07ef8be9405a572afebd87e06f6bdd0b1e06 (patch)
treec8cbc4f627526bd5712e44735b56fe952a3ec472
parent682f2baa58bdca6c500d38f75539c16ec7e57427 (diff)
Add Contacts, Calendar interfaces and make it work with the Google provider
Increase the credentials generation since we're now asking for an extra scope to access contacts. Signed-off-by: David Zeuthen <davidz@redhat.com>
-rw-r--r--data/dbus-interfaces.xml29
-rw-r--r--doc/goa-docs.xml4
-rw-r--r--doc/goa-sections.txt86
-rw-r--r--doc/goa.types6
-rw-r--r--src/goabackend/goagoogleprovider.c58
5 files changed, 179 insertions, 4 deletions
diff --git a/data/dbus-interfaces.xml b/data/dbus-interfaces.xml
index 02e7b99..a5f1463 100644
--- a/data/dbus-interfaces.xml
+++ b/data/dbus-interfaces.xml
@@ -111,12 +111,17 @@
#org.gnome.OnlineAccounts.Account and
#org.gnome.OnlineAccounts.OAuthBased interfaces.
- The object may implement #org.gnome.OnlineAccounts.Mail (if mail is enabled).
+ The object may implement #org.gnome.OnlineAccounts.Mail,
+ #org.gnome.OnlineAccounts.Calendar and
+ #org.gnome.OnlineAccounts.Contacts depending on the account and
+ the user's preferences.
When creating this kind of account via the
org.gnome.OnlineAccounts.Manager.AddAccount() method, you need
- to include an <literal>Identity</literal> and
- <literal>MailEnabled</literal> elements in the @details
+ to include an <literal>Identity</literal>,
+ <literal>MailEnabled</literal>,
+ <literal>CalendarEnabled</literal>
+ and <literal>ContactsEnabled</literal> elements in the @details
parameter.
-->
<interface name="org.gnome.OnlineAccounts.GoogleAccount">
@@ -515,4 +520,22 @@
</method>
</interface>
+ <!--
+ org.gnome.OnlineAccounts.Calendar:
+
+ An account object implements this interface if it provides
+ calendar-like capabilities.
+ -->
+ <interface name="org.gnome.OnlineAccounts.Calendar">
+ </interface>
+
+ <!--
+ org.gnome.OnlineAccounts.Contacts:
+
+ An account object implements this interface if it provides
+ contacts-like capabilities.
+ -->
+ <interface name="org.gnome.OnlineAccounts.Contacts">
+ </interface>
+
</node>
diff --git a/doc/goa-docs.xml b/doc/goa-docs.xml
index 87b9421..994c716 100644
--- a/doc/goa-docs.xml
+++ b/doc/goa-docs.xml
@@ -111,6 +111,8 @@
<title>Service-specific Interfaces</title>
<xi:include href="../src/goa/goa-generated-doc-org.gnome.OnlineAccounts.Mail.xml"/>
<xi:include href="../src/goa/goa-generated-doc-org.gnome.OnlineAccounts.Mail.Monitor.xml"/>
+ <xi:include href="../src/goa/goa-generated-doc-org.gnome.OnlineAccounts.Calendar.xml"/>
+ <xi:include href="../src/goa/goa-generated-doc-org.gnome.OnlineAccounts.Contacts.xml"/>
</chapter>
<chapter>
<title>Provider-specific Interfaces</title>
@@ -136,6 +138,8 @@
<xi:include href="xml/GoaOAuth2Based.xml"/>
<xi:include href="xml/GoaMail.xml"/>
<xi:include href="xml/GoaMailMonitor.xml"/>
+ <xi:include href="xml/GoaCalendar.xml"/>
+ <xi:include href="xml/GoaContacts.xml"/>
<xi:include href="xml/GoaGoogleAccount.xml"/>
<xi:include href="xml/GoaFacebookAccount.xml"/>
<xi:include href="xml/GoaYahooAccount.xml"/>
diff --git a/doc/goa-sections.txt b/doc/goa-sections.txt
index 12c28cb..26153b3 100644
--- a/doc/goa-sections.txt
+++ b/doc/goa-sections.txt
@@ -58,6 +58,8 @@ goa_object_get_oauth_based
goa_object_get_oauth2_based
goa_object_get_mail
goa_object_get_mail_monitor
+goa_object_get_calendar
+goa_object_get_contacts
goa_object_peek_manager
goa_object_peek_account
goa_object_peek_google_account
@@ -69,6 +71,8 @@ goa_object_peek_oauth_based
goa_object_peek_oauth2_based
goa_object_peek_mail
goa_object_peek_mail_monitor
+goa_object_peek_calendar
+goa_object_peek_contacts
GoaObjectProxy
GoaObjectProxyClass
goa_object_proxy_new
@@ -86,6 +90,8 @@ goa_object_skeleton_set_oauth_based
goa_object_skeleton_set_oauth2_based
goa_object_skeleton_set_mail
goa_object_skeleton_set_mail_monitor
+goa_object_skeleton_set_calendar
+goa_object_skeleton_set_contacts
<SUBSECTION Standard>
goa_object_get_type
goa_object_proxy_get_type
@@ -782,6 +788,86 @@ goa_mail_monitor_skeleton_get_type
</SECTION>
<SECTION>
+<FILE>GoaCalendar</FILE>
+GoaCalendar
+GoaCalendarIface
+goa_calendar_interface_info
+GoaCalendarProxy
+GoaCalendarProxyClass
+goa_calendar_proxy_new
+goa_calendar_proxy_new_finish
+goa_calendar_proxy_new_sync
+goa_calendar_proxy_new_for_bus
+goa_calendar_proxy_new_for_bus_finish
+goa_calendar_proxy_new_for_bus_sync
+GoaCalendarSkeleton
+GoaCalendarSkeletonClass
+goa_calendar_skeleton_new
+<SUBSECTION Standard>
+GOA_TYPE_CALENDAR
+GOA_IS_CALENDAR
+GOA_CALENDAR
+GOA_CALENDAR_GET_IFACE
+GOA_TYPE_CALENDAR_PROXY
+GOA_IS_CALENDAR_PROXY
+GOA_IS_CALENDAR_PROXY_CLASS
+GOA_CALENDAR_PROXY
+GOA_CALENDAR_PROXY_CLASS
+GOA_CALENDAR_PROXY_GET_CLASS
+GOA_TYPE_CALENDAR_SKELETON
+GOA_IS_CALENDAR_SKELETON
+GOA_IS_CALENDAR_SKELETON_CLASS
+GOA_CALENDAR_SKELETON
+GOA_CALENDAR_SKELETON_CLASS
+GOA_CALENDAR_SKELETON_GET_CLASS
+GoaCalendarProxyPrivate
+GoaCalendarSkeletonPrivate
+goa_calendar_get_type
+goa_calendar_proxy_get_type
+goa_calendar_skeleton_get_type
+</SECTION>
+
+<SECTION>
+<FILE>GoaContacts</FILE>
+GoaContacts
+GoaContactsIface
+goa_contacts_interface_info
+GoaContactsProxy
+GoaContactsProxyClass
+goa_contacts_proxy_new
+goa_contacts_proxy_new_finish
+goa_contacts_proxy_new_sync
+goa_contacts_proxy_new_for_bus
+goa_contacts_proxy_new_for_bus_finish
+goa_contacts_proxy_new_for_bus_sync
+GoaContactsSkeleton
+GoaContactsSkeletonClass
+goa_contacts_skeleton_new
+<SUBSECTION Standard>
+GOA_TYPE_CONTACTS
+GOA_IS_CONTACTS
+GOA_CONTACTS
+GOA_CONTACTS_GET_IFACE
+GOA_TYPE_CONTACTS_PROXY
+GOA_IS_CONTACTS_PROXY
+GOA_IS_CONTACTS_PROXY_CLASS
+GOA_CONTACTS_PROXY
+GOA_CONTACTS_PROXY_CLASS
+GOA_CONTACTS_PROXY_GET_CLASS
+GOA_TYPE_CONTACTS_SKELETON
+GOA_IS_CONTACTS_SKELETON
+GOA_IS_CONTACTS_SKELETON_CLASS
+GOA_CONTACTS_SKELETON
+GOA_CONTACTS_SKELETON_CLASS
+GOA_CONTACTS_SKELETON_GET_CLASS
+GoaContactsProxyPrivate
+GoaContactsSkeletonPrivate
+goa_contacts_get_type
+goa_contacts_proxy_get_type
+goa_contacts_skeleton_get_type
+</SECTION>
+
+<SECTION>
<FILE>goaimapclient</FILE>
GoaImapClient
goa_imap_client_new
diff --git a/doc/goa.types b/doc/goa.types
index 7174895..683660b 100644
--- a/doc/goa.types
+++ b/doc/goa.types
@@ -30,6 +30,12 @@ goa_mail_skeleton_get_type
goa_mail_monitor_get_type
goa_mail_monitor_proxy_get_type
goa_mail_monitor_skeleton_get_type
+goa_calendar_get_type
+goa_calendar_proxy_get_type
+goa_calendar_skeleton_get_type
+goa_contacts_get_type
+goa_contacts_proxy_get_type
+goa_contacts_skeleton_get_type
goa_provider_get_type
goa_generic_mail_provider_get_type
diff --git a/src/goabackend/goagoogleprovider.c b/src/goabackend/goagoogleprovider.c
index ed5c63d..5f35386 100644
--- a/src/goabackend/goagoogleprovider.c
+++ b/src/goabackend/goagoogleprovider.c
@@ -113,11 +113,22 @@ get_request_uri_params (GoaOAuthProvider *provider)
/* IMAP, SMTP access: http://code.google.com/apis/gmail/oauth/protocol.html */
"https://mail.google.com/ "
/* Calendar data API: http://code.google.com/apis/calendar/data/2.0/developers_guide.html */
- "https://www.google.com/calendar/feeds"));
+ "https://www.google.com/calendar/feeds "
+ /* Contacts API: http://code.google.com/apis/contacts/docs/3.0/developers_guide.html */
+ "https://www.google.com/m8/feeds/"));
g_ptr_array_add (p, NULL);
+
+ /* NOTE: Increase the number returned in get_crededentials_generation if adding scopes */
+
return (gchar **) g_ptr_array_free (p, FALSE);
}
+static guint
+get_credentials_generation (GoaProvider *provider)
+{
+ return 1;
+}
+
static const gchar *
get_authorization_uri (GoaOAuthProvider *provider)
{
@@ -243,14 +254,20 @@ build_object (GoaProvider *provider,
GoaAccount *account;
GoaGoogleAccount *google_account;
GoaMail *mail;
+ GoaCalendar *calendar;
+ GoaContacts *contacts;
gboolean ret;
gchar *email_address;
gboolean mail_enabled;
+ gboolean calendar_enabled;
+ gboolean contacts_enabled;
email_address = NULL;
account = NULL;
google_account = NULL;
mail = NULL;
+ calendar = NULL;
+ contacts = NULL;
ret = FALSE;
/* Chain up */
@@ -317,11 +334,47 @@ build_object (GoaProvider *provider,
goa_object_skeleton_set_mail (object, NULL);
}
+ calendar = goa_object_get_calendar (GOA_OBJECT (object));
+ calendar_enabled = g_key_file_get_boolean (key_file, group, "CalendarEnabled", NULL);
+ if (calendar_enabled)
+ {
+ if (calendar == NULL)
+ {
+ calendar = goa_calendar_skeleton_new ();
+ goa_object_skeleton_set_calendar (object, calendar);
+ }
+ }
+ else
+ {
+ if (calendar != NULL)
+ goa_object_skeleton_set_calendar (object, NULL);
+ }
+
+ contacts = goa_object_get_contacts (GOA_OBJECT (object));
+ contacts_enabled = g_key_file_get_boolean (key_file, group, "ContactsEnabled", NULL);
+ if (contacts_enabled)
+ {
+ if (contacts == NULL)
+ {
+ contacts = goa_contacts_skeleton_new ();
+ goa_object_skeleton_set_contacts (object, contacts);
+ }
+ }
+ else
+ {
+ if (contacts != NULL)
+ goa_object_skeleton_set_contacts (object, NULL);
+ }
+
ret = TRUE;
out:
g_free (email_address);
+ if (contacts != NULL)
+ g_object_unref (contacts);
+ if (calendar != NULL)
+ g_object_unref (calendar);
if (mail != NULL)
g_object_unref (mail);
if (google_account != NULL)
@@ -355,6 +408,7 @@ show_account (GoaProvider *provider,
goa_util_add_heading (table, _("Use this account for"));
goa_util_add_row_switch_from_keyfile (table, object, _("Mail"), "MailEnabled");
goa_util_add_row_switch_from_keyfile (table, object, _("Calendar"), "CalendarEnabled");
+ goa_util_add_row_switch_from_keyfile (table, object, _("Contacts"), "ContactsEnabled");
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -365,6 +419,7 @@ add_account_key_values (GoaOAuthProvider *provider,
{
g_variant_builder_add (builder, "{ss}", "MailEnabled", "true");
g_variant_builder_add (builder, "{ss}", "CalendarEnabled", "true");
+ g_variant_builder_add (builder, "{ss}", "ContactsEnabled", "true");
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -385,6 +440,7 @@ goa_google_provider_class_init (GoaGoogleProviderClass *klass)
provider_class->get_name = get_name;
provider_class->build_object = build_object;
provider_class->show_account = show_account;
+ provider_class->get_credentials_generation = get_credentials_generation;
oauth_class = GOA_OAUTH_PROVIDER_CLASS (klass);
oauth_class->get_identity_sync = get_identity_sync;