[gnome-online-accounts] provider: Add GoaProvider:get_features() to list supported features



commit 6525720571ec019d2787b142d92b93d3e26f5f87
Author: Emanuele Aina <emanuele aina collabora com>
Date:   Tue Jan 29 20:12:54 2013 +0100

    provider: Add GoaProvider:get_features() to list supported features
    
    The GoaProvider:get_features() virtual method will be the basis for
    filtering providers by functionality to e.g. be able to show only
    accounts and providers that provide IM services when requesting the
    creation of a chat account from Empathy.
    
    This also deprecates goa_provider_get_provider_group() to be replaced by
    goa_provider_get_provider_features().
    
    https://bugzilla.gnome.org/show_bug.cgi?id=695886

 doc/goa-sections.txt                    |    2 +
 src/goabackend/goabackendenums.h        |   35 +++++++++++++++++++++++++++++++
 src/goabackend/goaexchangeprovider.c    |   10 ++++++++
 src/goabackend/goafacebookprovider.c    |    7 ++++++
 src/goabackend/goaflickrprovider.c      |    7 ++++++
 src/goabackend/goagoogleprovider.c      |   12 ++++++++++
 src/goabackend/goaimapsmtpprovider.c    |    7 ++++++
 src/goabackend/goakerberosprovider.c    |    7 ++++++
 src/goabackend/goaowncloudprovider.c    |   10 ++++++++
 src/goabackend/goaprovider.c            |   21 ++++++++++++++++++
 src/goabackend/goaprovider.h            |    8 +++++-
 src/goabackend/goawindowsliveprovider.c |    9 ++++++++
 src/goabackend/goayahooprovider.c       |    7 ++++++
 13 files changed, 140 insertions(+), 2 deletions(-)
---
diff --git a/doc/goa-sections.txt b/doc/goa-sections.txt
index 2ec5bfb..b88bb45 100644
--- a/doc/goa-sections.txt
+++ b/doc/goa-sections.txt
@@ -415,10 +415,12 @@ GOA_CHECK_VERSION
 GoaProvider
 GoaProviderClass
 GoaProviderGroup
+GoaProviderFeatures
 goa_provider_get_provider_type
 goa_provider_get_provider_name
 goa_provider_get_provider_icon
 goa_provider_get_provider_group
+goa_provider_get_provider_features
 goa_provider_build_object
 goa_provider_add_account
 goa_provider_set_preseed_data
diff --git a/src/goabackend/goabackendenums.h b/src/goabackend/goabackendenums.h
index b5e3b32..eae938b 100644
--- a/src/goabackend/goabackendenums.h
+++ b/src/goabackend/goabackendenums.h
@@ -58,6 +58,41 @@ typedef enum
   GOA_PROVIDER_GROUP_INVALID
 } GoaProviderGroup;
 
+/**
+ * GoaProviderFeatures:
+ * @GOA_PROVIDER_FEATURE_BRANDED: Common providers to be highlighted (ie. Google, OwnCloud).
+ * @GOA_PROVIDER_FEATURE_MAIL: Mail services (ie. SMTP, IMAP).
+ * @GOA_PROVIDER_FEATURE_CALENDAR: Calendaring services (ie. CalDAV).
+ * @GOA_PROVIDER_FEATURE_CONTACTS: Addressbook services (ie. CardDAV).
+ * @GOA_PROVIDER_FEATURE_CHAT: Instant messaging services (ie. XMPP, IRC).
+ * @GOA_PROVIDER_FEATURE_DOCUMENTS: Documents storage services (ie. Google Documents).
+ * @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_INVALID: Used for error handling. No provider
+ *   should provide this feature.
+ *
+ * These flags specify the features exported by each provider. They can be
+ * expecially useful to restrict the list of available providers when
+ * requesting the creation of an account for a specific purpose (eg. from a
+ * chat program).
+ *
+ * Since: 3.10
+ */
+typedef enum /*< flags >*/
+{
+  GOA_PROVIDER_FEATURE_BRANDED   = 1 << 1,
+  GOA_PROVIDER_FEATURE_MAIL      = 1 << 2,
+  GOA_PROVIDER_FEATURE_CALENDAR  = 1 << 3,
+  GOA_PROVIDER_FEATURE_CONTACTS  = 1 << 4,
+  GOA_PROVIDER_FEATURE_CHAT      = 1 << 5,
+  GOA_PROVIDER_FEATURE_DOCUMENTS = 1 << 6,
+  GOA_PROVIDER_FEATURE_PHOTOS    = 1 << 7,
+  GOA_PROVIDER_FEATURE_FILES     = 1 << 8,
+  GOA_PROVIDER_FEATURE_TICKETING = 1 << 9,
+  GOA_PROVIDER_FEATURE_INVALID   = 0
+} GoaProviderFeatures;
+
 G_END_DECLS
 
 #endif /* __GOA_BACKEND_ENUMS_H__ */
diff --git a/src/goabackend/goaexchangeprovider.c b/src/goabackend/goaexchangeprovider.c
index e2a9213..144d046 100644
--- a/src/goabackend/goaexchangeprovider.c
+++ b/src/goabackend/goaexchangeprovider.c
@@ -85,6 +85,15 @@ get_provider_group (GoaProvider *_provider)
   return GOA_PROVIDER_GROUP_BRANDED;
 }
 
+static GoaProviderFeatures
+get_provider_features (GoaProvider *_provider)
+{
+  return GOA_PROVIDER_FEATURE_BRANDED |
+         GOA_PROVIDER_FEATURE_MAIL |
+         GOA_PROVIDER_FEATURE_CALENDAR |
+         GOA_PROVIDER_FEATURE_CONTACTS;
+}
+
 /* ---------------------------------------------------------------------------------------------------- */
 
 static gboolean on_handle_get_password (GoaPasswordBased      *interface,
@@ -984,6 +993,7 @@ goa_exchange_provider_class_init (GoaExchangeProviderClass *klass)
   provider_class->get_provider_type          = get_provider_type;
   provider_class->get_provider_name          = get_provider_name;
   provider_class->get_provider_group         = get_provider_group;
+  provider_class->get_provider_features      = get_provider_features;
   provider_class->add_account                = add_account;
   provider_class->refresh_account            = refresh_account;
   provider_class->build_object               = build_object;
diff --git a/src/goabackend/goafacebookprovider.c b/src/goabackend/goafacebookprovider.c
index b65bf8c..442195d 100644
--- a/src/goabackend/goafacebookprovider.c
+++ b/src/goabackend/goafacebookprovider.c
@@ -88,6 +88,12 @@ get_provider_group (GoaProvider *_provider)
   return GOA_PROVIDER_GROUP_BRANDED;
 }
 
+static GoaProviderFeatures
+get_provider_features (GoaProvider *_provider)
+{
+  return GOA_PROVIDER_FEATURE_BRANDED | GOA_PROVIDER_FEATURE_CHAT;
+}
+
 /* facebook client flow sends a different auth query then the base
  * OAuth2Provider */
 static gchar *
@@ -439,6 +445,7 @@ goa_facebook_provider_class_init (GoaFacebookProviderClass *klass)
   provider_class->get_provider_type          = get_provider_type;
   provider_class->get_provider_name          = get_provider_name;
   provider_class->get_provider_group         = get_provider_group;
+  provider_class->get_provider_features      = get_provider_features;
   provider_class->build_object               = build_object;
   provider_class->show_account               = show_account;
 
diff --git a/src/goabackend/goaflickrprovider.c b/src/goabackend/goaflickrprovider.c
index a472669..bc9eee9 100644
--- a/src/goabackend/goaflickrprovider.c
+++ b/src/goabackend/goaflickrprovider.c
@@ -89,6 +89,12 @@ get_provider_group (GoaProvider *_provider)
   return GOA_PROVIDER_GROUP_BRANDED;
 }
 
+static GoaProviderFeatures
+get_provider_features (GoaProvider *_provider)
+{
+  return GOA_PROVIDER_FEATURE_BRANDED | GOA_PROVIDER_FEATURE_PHOTOS;
+}
+
 static const gchar *
 get_consumer_key (GoaOAuthProvider *provider)
 {
@@ -450,6 +456,7 @@ goa_flickr_provider_class_init (GoaFlickrProviderClass *klass)
   provider_class->get_provider_type     = get_provider_type;
   provider_class->get_provider_name     = get_provider_name;
   provider_class->get_provider_group         = get_provider_group;
+  provider_class->get_provider_features      = get_provider_features;
   provider_class->build_object          = build_object;
   provider_class->show_account          = show_account;
 
diff --git a/src/goabackend/goagoogleprovider.c b/src/goabackend/goagoogleprovider.c
index 3bc174b..8271711 100644
--- a/src/goabackend/goagoogleprovider.c
+++ b/src/goabackend/goagoogleprovider.c
@@ -92,6 +92,17 @@ get_provider_group (GoaProvider *_provider)
   return GOA_PROVIDER_GROUP_BRANDED;
 }
 
+static GoaProviderFeatures
+get_provider_features (GoaProvider *_provider)
+{
+  return GOA_PROVIDER_FEATURE_BRANDED |
+         GOA_PROVIDER_FEATURE_MAIL |
+         GOA_PROVIDER_FEATURE_CALENDAR |
+         GOA_PROVIDER_FEATURE_CONTACTS |
+         GOA_PROVIDER_FEATURE_CHAT |
+         GOA_PROVIDER_FEATURE_DOCUMENTS;
+}
+
 static const gchar *
 get_authorization_uri (GoaOAuth2Provider *provider)
 {
@@ -729,6 +740,7 @@ goa_google_provider_class_init (GoaGoogleProviderClass *klass)
   provider_class->get_provider_type          = get_provider_type;
   provider_class->get_provider_name          = get_provider_name;
   provider_class->get_provider_group         = get_provider_group;
+  provider_class->get_provider_features      = get_provider_features;
   provider_class->build_object               = build_object;
   provider_class->ensure_credentials_sync    = ensure_credentials_sync;
   provider_class->show_account               = show_account;
diff --git a/src/goabackend/goaimapsmtpprovider.c b/src/goabackend/goaimapsmtpprovider.c
index 5512b79..36f4955 100644
--- a/src/goabackend/goaimapsmtpprovider.c
+++ b/src/goabackend/goaimapsmtpprovider.c
@@ -88,6 +88,12 @@ get_provider_group (GoaProvider *provider)
   return GOA_PROVIDER_GROUP_MAIL;
 }
 
+static GoaProviderFeatures
+get_provider_features (GoaProvider *_provider)
+{
+  return GOA_PROVIDER_FEATURE_MAIL;
+}
+
 static GIcon *
 get_provider_icon (GoaProvider *provider, GoaObject *object)
 {
@@ -1567,6 +1573,7 @@ goa_imap_smtp_provider_class_init (GoaImapSmtpProviderClass *klass)
   provider_class->get_provider_type          = get_provider_type;
   provider_class->get_provider_name          = get_provider_name;
   provider_class->get_provider_group         = get_provider_group;
+  provider_class->get_provider_features      = get_provider_features;
   provider_class->get_provider_icon          = get_provider_icon;
   provider_class->add_account                = add_account;
   provider_class->refresh_account            = refresh_account;
diff --git a/src/goabackend/goakerberosprovider.c b/src/goabackend/goakerberosprovider.c
index a212d8f..abded27 100644
--- a/src/goabackend/goakerberosprovider.c
+++ b/src/goabackend/goakerberosprovider.c
@@ -93,6 +93,12 @@ get_provider_group (GoaProvider *_provider)
   return GOA_PROVIDER_GROUP_TICKETING;
 }
 
+static GoaProviderFeatures
+get_provider_features (GoaProvider *_provider)
+{
+  return GOA_PROVIDER_FEATURE_TICKETING;
+}
+
 typedef struct
 {
   GtkDialog *dialog;
@@ -1921,6 +1927,7 @@ goa_kerberos_provider_class_init (GoaKerberosProviderClass *kerberos_class)
   provider_class->get_provider_type          = get_provider_type;
   provider_class->get_provider_name          = get_provider_name;
   provider_class->get_provider_group         = get_provider_group;
+  provider_class->get_provider_features      = get_provider_features;
   provider_class->build_object               = build_object;
   provider_class->add_account                = add_account;
   provider_class->refresh_account            = refresh_account;
diff --git a/src/goabackend/goaowncloudprovider.c b/src/goabackend/goaowncloudprovider.c
index f23c14a..2c3069b 100644
--- a/src/goabackend/goaowncloudprovider.c
+++ b/src/goabackend/goaowncloudprovider.c
@@ -90,6 +90,15 @@ get_provider_group (GoaProvider *_provider)
   return GOA_PROVIDER_GROUP_BRANDED;
 }
 
+static GoaProviderFeatures
+get_provider_features (GoaProvider *_provider)
+{
+  return GOA_PROVIDER_FEATURE_BRANDED |
+         GOA_PROVIDER_FEATURE_CALENDAR |
+         GOA_PROVIDER_FEATURE_CONTACTS |
+         GOA_PROVIDER_FEATURE_FILES;
+}
+
 /* ---------------------------------------------------------------------------------------------------- */
 
 static gboolean on_handle_get_password (GoaPasswordBased      *interface,
@@ -1086,6 +1095,7 @@ goa_owncloud_provider_class_init (GoaOwncloudProviderClass *klass)
   provider_class->get_provider_type          = get_provider_type;
   provider_class->get_provider_name          = get_provider_name;
   provider_class->get_provider_group         = get_provider_group;
+  provider_class->get_provider_features      = get_provider_features;
   provider_class->add_account                = add_account;
   provider_class->refresh_account            = refresh_account;
   provider_class->build_object               = build_object;
diff --git a/src/goabackend/goaprovider.c b/src/goabackend/goaprovider.c
index 6093017..d7d78a0 100644
--- a/src/goabackend/goaprovider.c
+++ b/src/goabackend/goaprovider.c
@@ -299,6 +299,8 @@ goa_provider_get_provider_icon_default (GoaProvider *provider,
  * Returns: A #GoaProviderGroup.
  *
  * Since: 3.8
+ *
+ * Deprecated: 3.10: Use goa_provider_get_provider_features() instead.
  */
 GoaProviderGroup
 goa_provider_get_provider_group (GoaProvider *provider)
@@ -307,6 +309,25 @@ goa_provider_get_provider_group (GoaProvider *provider)
   return GOA_PROVIDER_GET_CLASS (provider)->get_provider_group (provider);
 }
 
+/**
+ * goa_provider_get_provider_features:
+ * @provider: A #GoaProvider.
+ *
+ * Get the features bitmask (eg. %GOA_PROVIDER_FEATURE_CHAT|%GOA_PROVIDER_FEATURE_CONTACTS)
+ * supported by the provider.
+ *
+ * Returns: The #GoaProviderFeatures bitmask with the provided features.
+ *
+ * Since: 3.10
+ */
+GoaProviderFeatures
+goa_provider_get_provider_features (GoaProvider *provider)
+{
+  g_return_val_if_fail (GOA_IS_PROVIDER (provider), GOA_PROVIDER_FEATURE_INVALID);
+  g_return_val_if_fail (GOA_PROVIDER_GET_CLASS (provider)->get_provider_features != NULL, 
GOA_PROVIDER_FEATURE_INVALID);
+  return GOA_PROVIDER_GET_CLASS (provider)->get_provider_features (provider);
+}
+
 /* ---------------------------------------------------------------------------------------------------- */
 
 /**
diff --git a/src/goabackend/goaprovider.h b/src/goabackend/goaprovider.h
index a960a78..89fb826 100644
--- a/src/goabackend/goaprovider.h
+++ b/src/goabackend/goaprovider.h
@@ -63,6 +63,7 @@ struct _GoaProvider
  * @get_provider_name: Virtual function for goa_provider_get_provider_name().
  * @get_provider_icon: Virtual function for goa_provider_get_provider_icon().
  * @get_provider_group: Virtual function for goa_provider_get_provider_group().
+ * @get_provider_features: Virtual function for goa_provider_get_provider_features().
  * @add_account: Virtual function for goa_provider_add_account().
  * @refresh_account: Virtual function for goa_provider_refresh_account().
  * @build_object: Virtual function for goa_provider_build_object().
@@ -115,10 +116,11 @@ struct _GoaProviderClass
 
   /* pure virtual */
   GoaProviderGroup (*get_provider_group) (GoaProvider   *provider);
+  GoaProviderFeatures  (*get_provider_features)     (GoaProvider   *provider);
 
   /*< private >*/
   /* Padding for future expansion */
-  gpointer goa_reserved[32];
+  gpointer goa_reserved[31];
 };
 
 GType        goa_provider_get_type                  (void) G_GNUC_CONST;
@@ -127,7 +129,9 @@ gchar       *goa_provider_get_provider_name         (GoaProvider         *provid
                                                      GoaObject           *object);
 GIcon       *goa_provider_get_provider_icon         (GoaProvider         *provider,
                                                      GoaObject           *object);
+G_DEPRECATED_FOR(goa_provider_get_provider_features)
 GoaProviderGroup goa_provider_get_provider_group    (GoaProvider         *provider);
+GoaProviderFeatures goa_provider_get_provider_features (GoaProvider      *provider);
 void         goa_provider_set_preseed_data          (GoaProvider *provider,
                                                      GVariant    *preseed_data);
 GVariant    *goa_provider_get_preseed_data          (GoaProvider *provider);
@@ -170,8 +174,8 @@ gboolean     goa_provider_ensure_credentials_sync   (GoaProvider         *provid
                                                      GError             **error);
 guint        goa_provider_get_credentials_generation (GoaProvider        *provider);
 
-
 GList        *goa_provider_get_all (void);
+
 GoaProvider  *goa_provider_get_for_provider_type (const gchar *provider_type);
 
 /* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/goabackend/goawindowsliveprovider.c b/src/goabackend/goawindowsliveprovider.c
index ed6e3d3..bcfb460 100644
--- a/src/goabackend/goawindowsliveprovider.c
+++ b/src/goabackend/goawindowsliveprovider.c
@@ -90,6 +90,14 @@ get_provider_group (GoaProvider *_provider)
   return GOA_PROVIDER_GROUP_BRANDED;
 }
 
+static GoaProviderFeatures
+get_provider_features (GoaProvider *_provider)
+{
+  return GOA_PROVIDER_FEATURE_BRANDED |
+         GOA_PROVIDER_FEATURE_CHAT |
+         GOA_PROVIDER_FEATURE_DOCUMENTS;
+}
+
 static const gchar *
 get_authorization_uri (GoaOAuth2Provider *provider)
 {
@@ -458,6 +466,7 @@ goa_windows_live_provider_class_init (GoaWindowsLiveProviderClass *klass)
   provider_class->get_provider_type          = get_provider_type;
   provider_class->get_provider_name          = get_provider_name;
   provider_class->get_provider_group         = get_provider_group;
+  provider_class->get_provider_features      = get_provider_features;
   provider_class->build_object               = build_object;
   provider_class->show_account               = show_account;
   provider_class->get_credentials_generation = get_credentials_generation;
diff --git a/src/goabackend/goayahooprovider.c b/src/goabackend/goayahooprovider.c
index ac4b353..f3b4373 100644
--- a/src/goabackend/goayahooprovider.c
+++ b/src/goabackend/goayahooprovider.c
@@ -87,6 +87,12 @@ get_provider_group (GoaProvider *_provider)
   return GOA_PROVIDER_GROUP_BRANDED;
 }
 
+static GoaProviderFeatures
+get_provider_features (GoaProvider *_provider)
+{
+  return GOA_PROVIDER_FEATURE_BRANDED;
+}
+
 static const gchar *
 get_consumer_key (GoaOAuthProvider *provider)
 {
@@ -421,6 +427,7 @@ goa_yahoo_provider_class_init (GoaYahooProviderClass *klass)
   provider_class->get_provider_type     = get_provider_type;
   provider_class->get_provider_name     = get_provider_name;
   provider_class->get_provider_group    = get_provider_group;
+  provider_class->get_provider_features = get_provider_features;
   provider_class->build_object          = build_object;
   provider_class->show_account          = show_account;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]