[gnome-online-accounts] oauth2: Style fixes
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts] oauth2: Style fixes
- Date: Wed, 8 Feb 2017 14:54:07 +0000 (UTC)
commit 95191d09d0040a16271e474e990bda02f20e8db0
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Feb 8 15:12:39 2017 +0100
oauth2: Style fixes
Use the name 'self' to refer to the instance.
src/goabackend/goaoauth2provider.c | 311 ++++++++++++++++++------------------
1 files changed, 154 insertions(+), 157 deletions(-)
---
diff --git a/src/goabackend/goaoauth2provider.c b/src/goabackend/goaoauth2provider.c
index 997fc0f..d549019 100644
--- a/src/goabackend/goaoauth2provider.c
+++ b/src/goabackend/goaoauth2provider.c
@@ -105,14 +105,14 @@ is_authorization_error (GError *error)
/* ---------------------------------------------------------------------------------------------------- */
static gboolean
-goa_oauth2_provider_get_use_mobile_browser_default (GoaOAuth2Provider *provider)
+goa_oauth2_provider_get_use_mobile_browser_default (GoaOAuth2Provider *self)
{
return FALSE;
}
/**
* goa_oauth2_provider_get_use_mobile_browser:
- * @provider: A #GoaOAuth2Provider.
+ * @self: A #GoaOAuth2Provider.
*
* Returns whether there is a need for the embedded browser to identify
* itself as running on a mobile phone in order to get a more compact
@@ -125,23 +125,23 @@ goa_oauth2_provider_get_use_mobile_browser_default (GoaOAuth2Provider *provider
* running on a mobile platform, %FALSE otherwise.
*/
gboolean
-goa_oauth2_provider_get_use_mobile_browser (GoaOAuth2Provider *provider)
+goa_oauth2_provider_get_use_mobile_browser (GoaOAuth2Provider *self)
{
- g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (provider), FALSE);
- return GOA_OAUTH2_PROVIDER_GET_CLASS (provider)->get_use_mobile_browser (provider);
+ g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (self), FALSE);
+ return GOA_OAUTH2_PROVIDER_GET_CLASS (self)->get_use_mobile_browser (self);
}
/* ---------------------------------------------------------------------------------------------------- */
static gboolean
-goa_oauth2_provider_is_deny_node_default (GoaOAuth2Provider *provider, WebKitDOMNode *node)
+goa_oauth2_provider_is_deny_node_default (GoaOAuth2Provider *self, WebKitDOMNode *node)
{
return FALSE;
}
/**
* goa_oauth2_provider_is_deny_node:
- * @provider: A #GoaOAuth2Provider.
+ * @self: A #GoaOAuth2Provider.
* @node: A WebKitDOMNode.
*
* Checks whether @node is the HTML UI element that the user can use
@@ -157,23 +157,23 @@ goa_oauth2_provider_is_deny_node_default (GoaOAuth2Provider *provider, WebKitDOM
* Returns: %TRUE if the @node can be used to deny permission.
*/
gboolean
-goa_oauth2_provider_is_deny_node (GoaOAuth2Provider *provider, WebKitDOMNode *node)
+goa_oauth2_provider_is_deny_node (GoaOAuth2Provider *self, WebKitDOMNode *node)
{
- g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (provider), FALSE);
- return GOA_OAUTH2_PROVIDER_GET_CLASS (provider)->is_deny_node (provider, node);
+ g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (self), FALSE);
+ return GOA_OAUTH2_PROVIDER_GET_CLASS (self)->is_deny_node (self, node);
}
/* ---------------------------------------------------------------------------------------------------- */
static gboolean
-goa_oauth2_provider_is_password_node_default (GoaOAuth2Provider *provider, WebKitDOMHTMLInputElement
*element)
+goa_oauth2_provider_is_password_node_default (GoaOAuth2Provider *self, WebKitDOMHTMLInputElement *element)
{
return FALSE;
}
/**
* goa_oauth2_provider_is_password_node:
- * @provider: A #GoaOAuth2Provider.
+ * @self: A #GoaOAuth2Provider.
* @element: A WebKitDOMHTMLInputElement
*
* Checks whether @element is the HTML UI element that the user can
@@ -188,17 +188,17 @@ goa_oauth2_provider_is_password_node_default (GoaOAuth2Provider *provider, WebKi
* Returns: %TRUE if @element can be used to enter the password.
*/
gboolean
-goa_oauth2_provider_is_password_node (GoaOAuth2Provider *provider, WebKitDOMHTMLInputElement *element)
+goa_oauth2_provider_is_password_node (GoaOAuth2Provider *self, WebKitDOMHTMLInputElement *element)
{
- g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (provider), FALSE);
+ g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (self), FALSE);
g_return_val_if_fail (WEBKIT_DOM_IS_HTML_INPUT_ELEMENT (element), FALSE);
- return GOA_OAUTH2_PROVIDER_GET_CLASS (provider)->is_password_node (provider, element);
+ return GOA_OAUTH2_PROVIDER_GET_CLASS (self)->is_password_node (self, element);
}
/* ---------------------------------------------------------------------------------------------------- */
static void
-goa_oauth2_provider_add_account_key_values_default (GoaOAuth2Provider *provider,
+goa_oauth2_provider_add_account_key_values_default (GoaOAuth2Provider *self,
GVariantBuilder *builder)
{
/* do nothing */
@@ -206,7 +206,7 @@ goa_oauth2_provider_add_account_key_values_default (GoaOAuth2Provider *provider,
/**
* goa_oauth2_provider_add_account_key_values:
- * @provider: A #GoaProvider.
+ * @self: A #GoaProvider.
* @builder: A #GVariantBuilder for a <literal>a{ss}</literal> variant.
*
* Hook for implementations to add key/value pairs to the key-file
@@ -215,17 +215,17 @@ goa_oauth2_provider_add_account_key_values_default (GoaOAuth2Provider *provider,
* This is a virtual method where the default implementation does nothing.
*/
void
-goa_oauth2_provider_add_account_key_values (GoaOAuth2Provider *provider,
+goa_oauth2_provider_add_account_key_values (GoaOAuth2Provider *self,
GVariantBuilder *builder)
{
- g_return_if_fail (GOA_IS_OAUTH2_PROVIDER (provider));
- return GOA_OAUTH2_PROVIDER_GET_CLASS (provider)->add_account_key_values (provider, builder);
+ g_return_if_fail (GOA_IS_OAUTH2_PROVIDER (self));
+ return GOA_OAUTH2_PROVIDER_GET_CLASS (self)->add_account_key_values (self, builder);
}
/* ---------------------------------------------------------------------------------------------------- */
static gchar *
-goa_oauth2_provider_build_authorization_uri_default (GoaOAuth2Provider *provider,
+goa_oauth2_provider_build_authorization_uri_default (GoaOAuth2Provider *self,
const gchar *authorization_uri,
const gchar *escaped_redirect_uri,
const gchar *escaped_client_id,
@@ -244,7 +244,7 @@ goa_oauth2_provider_build_authorization_uri_default (GoaOAuth2Provider *provide
/**
* goa_oauth2_provider_build_authorization_uri:
- * @provider: A #GoaOAuth2Provider.
+ * @self: A #GoaOAuth2Provider.
* @authorization_uri: An authorization URI.
* @escaped_redirect_uri: An escaped redirect URI
* @escaped_client_id: An escaped client id
@@ -267,27 +267,27 @@ goa_oauth2_provider_build_authorization_uri_default (GoaOAuth2Provider *provide
* Returns: (transfer full): An authorization URI that must be freed with g_free().
*/
gchar *
-goa_oauth2_provider_build_authorization_uri (GoaOAuth2Provider *provider,
+goa_oauth2_provider_build_authorization_uri (GoaOAuth2Provider *self,
const gchar *authorization_uri,
const gchar *escaped_redirect_uri,
const gchar *escaped_client_id,
const gchar *escaped_scope)
{
- g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (provider), NULL);
+ g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (self), NULL);
g_return_val_if_fail (authorization_uri != NULL, NULL);
g_return_val_if_fail (escaped_redirect_uri != NULL, NULL);
g_return_val_if_fail (escaped_client_id != NULL, NULL);
- return GOA_OAUTH2_PROVIDER_GET_CLASS (provider)->build_authorization_uri (provider,
- authorization_uri,
- escaped_redirect_uri,
- escaped_client_id,
- escaped_scope);
+ return GOA_OAUTH2_PROVIDER_GET_CLASS (self)->build_authorization_uri (self,
+ authorization_uri,
+ escaped_redirect_uri,
+ escaped_client_id,
+ escaped_scope);
}
/* ---------------------------------------------------------------------------------------------------- */
static gboolean
-goa_oauth2_provider_decide_navigation_policy_default (GoaOAuth2Provider *provider,
+goa_oauth2_provider_decide_navigation_policy_default (GoaOAuth2Provider *self,
WebKitWebView *web_view,
WebKitNavigationPolicyDecision *decision)
{
@@ -296,7 +296,7 @@ goa_oauth2_provider_decide_navigation_policy_default (GoaOAuth2Provider
/*
* goa_oauth2_provider_decide_navigation_policy_default:
- * @provider: A #GoaOAuth2Provider.
+ * @self: A #GoaOAuth2Provider.
* @decision: A #WebKitNavigationPolicyDecision
*
* Certain OAuth2-like, but not exactly <ulink
@@ -312,22 +312,22 @@ goa_oauth2_provider_decide_navigation_policy_default (GoaOAuth2Provider
* %FALSE otherwise.
*/
gboolean
-goa_oauth2_provider_decide_navigation_policy (GoaOAuth2Provider *provider,
+goa_oauth2_provider_decide_navigation_policy (GoaOAuth2Provider *self,
WebKitWebView *web_view,
WebKitNavigationPolicyDecision *decision)
{
- g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (provider), FALSE);
+ g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (self), FALSE);
g_return_val_if_fail (WEBKIT_IS_WEB_VIEW (web_view), FALSE);
g_return_val_if_fail (WEBKIT_IS_NAVIGATION_POLICY_DECISION (decision), FALSE);
- return GOA_OAUTH2_PROVIDER_GET_CLASS (provider)->decide_navigation_policy (provider, web_view, decision);
+ return GOA_OAUTH2_PROVIDER_GET_CLASS (self)->decide_navigation_policy (self, web_view, decision);
}
/* ---------------------------------------------------------------------------------------------------- */
/**
* goa_oauth2_provider_process_redirect_url:
- * @provider: A #GoaOAuth2Provider.
+ * @self: A #GoaOAuth2Provider.
* @redirect_url: A redirect URI from the web browser
* @authorization_code: (out): Return location for access token
* @error: Return location for error or %NULL
@@ -346,25 +346,22 @@ goa_oauth2_provider_decide_navigation_policy (GoaOAuth2Provider *p
* otherwise.
*/
gboolean
-goa_oauth2_provider_process_redirect_url (GoaOAuth2Provider *provider,
+goa_oauth2_provider_process_redirect_url (GoaOAuth2Provider *self,
const gchar *redirect_url,
gchar **authorization_code,
GError **error)
{
- g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (provider), FALSE);
+ g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (self), FALSE);
g_return_val_if_fail (redirect_url != NULL, FALSE);
g_return_val_if_fail (authorization_code != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- return GOA_OAUTH2_PROVIDER_GET_CLASS (provider)->process_redirect_url (provider,
- redirect_url,
- authorization_code,
- error);
+ return GOA_OAUTH2_PROVIDER_GET_CLASS (self)->process_redirect_url (self, redirect_url, authorization_code,
error);
}
/**
* goa_oauth2_provider_get_authorization_uri:
- * @provider: A #GoaOAuth2Provider.
+ * @self: A #GoaOAuth2Provider.
*
* Gets the <ulink
* url="http://tools.ietf.org/html/draft-ietf-oauth-v2-15#section-2.1">authorization
@@ -380,26 +377,26 @@ goa_oauth2_provider_process_redirect_url (GoaOAuth2Provider *provider,
* This is a pure virtual method - a subclass must provide an
* implementation.
*
- * Returns: (transfer none): A string owned by @provider - do not free.
+ * Returns: (transfer none): A string owned by @self - do not free.
*/
const gchar *
-goa_oauth2_provider_get_authorization_uri (GoaOAuth2Provider *provider)
+goa_oauth2_provider_get_authorization_uri (GoaOAuth2Provider *self)
{
- g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (provider), NULL);
- return GOA_OAUTH2_PROVIDER_GET_CLASS (provider)->get_authorization_uri (provider);
+ g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (self), NULL);
+ return GOA_OAUTH2_PROVIDER_GET_CLASS (self)->get_authorization_uri (self);
}
/* ---------------------------------------------------------------------------------------------------- */
static const gchar *
-goa_oauth2_provider_get_token_uri_default (GoaOAuth2Provider *provider)
+goa_oauth2_provider_get_token_uri_default (GoaOAuth2Provider *self)
{
return NULL;
}
/**
* goa_oauth2_provider_get_token_uri:
- * @provider: A #GoaOAuth2Provider.
+ * @self: A #GoaOAuth2Provider.
*
* Gets the <ulink
* url="http://tools.ietf.org/html/draft-ietf-oauth-v2-15#section-2.2">token
@@ -413,20 +410,20 @@ goa_oauth2_provider_get_token_uri_default (GoaOAuth2Provider *provider)
* This is a virtual method where the default implementation returns
* %NULL.
*
- * Returns: (transfer none): A string owned by @provider - do not free.
+ * Returns: (transfer none): A string owned by @self - do not free.
*/
const gchar *
-goa_oauth2_provider_get_token_uri (GoaOAuth2Provider *provider)
+goa_oauth2_provider_get_token_uri (GoaOAuth2Provider *self)
{
- g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (provider), NULL);
- return GOA_OAUTH2_PROVIDER_GET_CLASS (provider)->get_token_uri (provider);
+ g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (self), NULL);
+ return GOA_OAUTH2_PROVIDER_GET_CLASS (self)->get_token_uri (self);
}
/* ---------------------------------------------------------------------------------------------------- */
/**
* goa_oauth2_provider_get_redirect_uri:
- * @provider: A #GoaOAuth2Provider.
+ * @self: A #GoaOAuth2Provider.
*
* Gets the <ulink
* url="http://tools.ietf.org/html/draft-ietf-oauth-v2-15#section-2.1.1">redirect_uri</ulink>
@@ -435,26 +432,26 @@ goa_oauth2_provider_get_token_uri (GoaOAuth2Provider *provider)
* This is a pure virtual method - a subclass must provide an
* implementation.
*
- * Returns: (transfer none): A string owned by @provider - do not free.
+ * Returns: (transfer none): A string owned by @self - do not free.
*/
const gchar *
-goa_oauth2_provider_get_redirect_uri (GoaOAuth2Provider *provider)
+goa_oauth2_provider_get_redirect_uri (GoaOAuth2Provider *self)
{
- g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (provider), NULL);
- return GOA_OAUTH2_PROVIDER_GET_CLASS (provider)->get_redirect_uri (provider);
+ g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (self), NULL);
+ return GOA_OAUTH2_PROVIDER_GET_CLASS (self)->get_redirect_uri (self);
}
/* ---------------------------------------------------------------------------------------------------- */
static const gchar *
-goa_oauth2_provider_get_scope_default (GoaOAuth2Provider *provider)
+goa_oauth2_provider_get_scope_default (GoaOAuth2Provider *self)
{
return NULL;
}
/**
* goa_oauth2_provider_get_scope:
- * @provider: A #GoaOAuth2Provider.
+ * @self: A #GoaOAuth2Provider.
*
* Gets the <ulink
* url="http://tools.ietf.org/html/draft-ietf-oauth-v2-15#section-2.1.1">scope</ulink>
@@ -463,20 +460,20 @@ goa_oauth2_provider_get_scope_default (GoaOAuth2Provider *provider)
* This is a virtual method where the default implementation returns
* %NULL.
*
- * Returns: (transfer none): A string owned by @provider - do not free.
+ * Returns: (transfer none): A string owned by @self - do not free.
*/
const gchar *
-goa_oauth2_provider_get_scope (GoaOAuth2Provider *provider)
+goa_oauth2_provider_get_scope (GoaOAuth2Provider *self)
{
- g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (provider), NULL);
- return GOA_OAUTH2_PROVIDER_GET_CLASS (provider)->get_scope (provider);
+ g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (self), NULL);
+ return GOA_OAUTH2_PROVIDER_GET_CLASS (self)->get_scope (self);
}
/* ---------------------------------------------------------------------------------------------------- */
/**
* goa_oauth2_provider_get_client_id:
- * @provider: A #GoaOAuth2Provider.
+ * @self: A #GoaOAuth2Provider.
*
* Gets the <ulink
* url="http://tools.ietf.org/html/draft-ietf-oauth-v2-15#section-3">client_id</ulink>
@@ -485,18 +482,18 @@ goa_oauth2_provider_get_scope (GoaOAuth2Provider *provider)
* This is a pure virtual method - a subclass must provide an
* implementation.
*
- * Returns: (transfer none): A string owned by @provider - do not free.
+ * Returns: (transfer none): A string owned by @self - do not free.
*/
const gchar *
-goa_oauth2_provider_get_client_id (GoaOAuth2Provider *provider)
+goa_oauth2_provider_get_client_id (GoaOAuth2Provider *self)
{
- g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (provider), NULL);
- return GOA_OAUTH2_PROVIDER_GET_CLASS (provider)->get_client_id (provider);
+ g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (self), NULL);
+ return GOA_OAUTH2_PROVIDER_GET_CLASS (self)->get_client_id (self);
}
/**
* goa_oauth2_provider_get_client_secret:
- * @provider: A #GoaOAuth2Provider.
+ * @self: A #GoaOAuth2Provider.
*
* Gets the <ulink
* url="http://tools.ietf.org/html/draft-ietf-oauth-v2-15#section-3">client_secret</ulink>
@@ -505,18 +502,18 @@ goa_oauth2_provider_get_client_id (GoaOAuth2Provider *provider)
* This is a pure virtual method - a subclass must provide an
* implementation.
*
- * Returns: (transfer none): A string owned by @provider - do not free.
+ * Returns: (transfer none): A string owned by @self - do not free.
*/
const gchar *
-goa_oauth2_provider_get_client_secret (GoaOAuth2Provider *provider)
+goa_oauth2_provider_get_client_secret (GoaOAuth2Provider *self)
{
- g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (provider), NULL);
- return GOA_OAUTH2_PROVIDER_GET_CLASS (provider)->get_client_secret (provider);
+ g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (self), NULL);
+ return GOA_OAUTH2_PROVIDER_GET_CLASS (self)->get_client_secret (self);
}
/**
* goa_oauth2_provider_get_authentication_cookie:
- * @provider: A #GoaOAuth2Provider.
+ * @self: A #GoaOAuth2Provider.
*
* Gets the name of a cookie whose presence indicates that the user has been able to
* log in during the authorization step. This is used to modify the embedded web
@@ -525,18 +522,18 @@ goa_oauth2_provider_get_client_secret (GoaOAuth2Provider *provider)
* This is a pure virtual method - a subclass must provide an
* implementation.
*
- * Returns: (transfer none): A string owned by @provider - do not free.
+ * Returns: (transfer none): A string owned by @self - do not free.
*/
const gchar *
-goa_oauth2_provider_get_authentication_cookie (GoaOAuth2Provider *provider)
+goa_oauth2_provider_get_authentication_cookie (GoaOAuth2Provider *self)
{
- g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (provider), NULL);
- return GOA_OAUTH2_PROVIDER_GET_CLASS (provider)->get_authentication_cookie (provider);
+ g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (self), NULL);
+ return GOA_OAUTH2_PROVIDER_GET_CLASS (self)->get_authentication_cookie (self);
}
/**
* goa_oauth2_provider_get_identity_sync:
- * @provider: A #GoaOAuth2Provider.
+ * @self: A #GoaOAuth2Provider.
* @access_token: A valid OAuth 2.0 access token.
* @out_presentation_identity: (out): Return location for presentation identity or %NULL.
* @cancellable: (allow-none): A #GCancellable or %NULL.
@@ -556,22 +553,26 @@ goa_oauth2_provider_get_authentication_cookie (GoaOAuth2Provider *provider)
* must be freed with g_free().
*/
gchar *
-goa_oauth2_provider_get_identity_sync (GoaOAuth2Provider *provider,
+goa_oauth2_provider_get_identity_sync (GoaOAuth2Provider *self,
const gchar *access_token,
gchar **out_presentation_identity,
GCancellable *cancellable,
GError **error)
{
- g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (provider), NULL);
+ g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (self), NULL);
g_return_val_if_fail (access_token != NULL, NULL);
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
- return GOA_OAUTH2_PROVIDER_GET_CLASS (provider)->get_identity_sync (provider, access_token,
out_presentation_identity, cancellable, error);
+ return GOA_OAUTH2_PROVIDER_GET_CLASS (self)->get_identity_sync (self,
+ access_token,
+ out_presentation_identity,
+ cancellable,
+ error);
}
/**
* goa_oauth2_provider_is_identity_node:
- * @provider: A #GoaOAuth2Provider.
+ * @self: A #GoaOAuth2Provider.
* @element: A WebKitDOMHTMLInputElement.
*
* Checks whether @element is the HTML UI element that the user can
@@ -583,10 +584,10 @@ goa_oauth2_provider_get_identity_sync (GoaOAuth2Provider *provider,
* Returns: %TRUE if the @element can be used to deny permission.
*/
gboolean
-goa_oauth2_provider_is_identity_node (GoaOAuth2Provider *provider, WebKitDOMHTMLInputElement *element)
+goa_oauth2_provider_is_identity_node (GoaOAuth2Provider *self, WebKitDOMHTMLInputElement *element)
{
- g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (provider), FALSE);
- return GOA_OAUTH2_PROVIDER_GET_CLASS (provider)->is_identity_node (provider, element);
+ g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (self), FALSE);
+ return GOA_OAUTH2_PROVIDER_GET_CLASS (self)->is_identity_node (self, element);
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -652,7 +653,7 @@ out:
/* ---------------------------------------------------------------------------------------------------- */
static gchar *
-get_tokens_sync (GoaOAuth2Provider *provider,
+get_tokens_sync (GoaOAuth2Provider *self,
const gchar *authorization_code,
const gchar *refresh_token,
gchar **out_refresh_token,
@@ -679,14 +680,14 @@ get_tokens_sync (GoaOAuth2Provider *provider,
tokens_error = NULL;
- proxy = rest_proxy_new (goa_oauth2_provider_get_token_uri (provider), FALSE);
+ proxy = rest_proxy_new (goa_oauth2_provider_get_token_uri (self), FALSE);
call = rest_proxy_new_call (proxy);
rest_proxy_call_set_method (call, "POST");
rest_proxy_call_add_header (call, "Content-Type", "application/x-www-form-urlencoded");
- rest_proxy_call_add_param (call, "client_id", goa_oauth2_provider_get_client_id (provider));
+ rest_proxy_call_add_param (call, "client_id", goa_oauth2_provider_get_client_id (self));
- client_secret = goa_oauth2_provider_get_client_secret (provider);
+ client_secret = goa_oauth2_provider_get_client_secret (self);
if (client_secret != NULL)
rest_proxy_call_add_param (call, "client_secret", client_secret);
@@ -700,7 +701,7 @@ get_tokens_sync (GoaOAuth2Provider *provider,
{
/* No refresh code.. request an access token using the authorization code instead */
rest_proxy_call_add_param (call, "grant_type", "authorization_code");
- rest_proxy_call_add_param (call, "redirect_uri", goa_oauth2_provider_get_redirect_uri (provider));
+ rest_proxy_call_add_param (call, "redirect_uri", goa_oauth2_provider_get_redirect_uri (self));
rest_proxy_call_add_param (call, "code", authorization_code);
}
@@ -816,20 +817,20 @@ get_tokens_sync (GoaOAuth2Provider *provider,
static void
on_web_view_deny_click (GoaWebView *web_view, gpointer user_data)
{
- GoaOAuth2Provider *provider = GOA_OAUTH2_PROVIDER (user_data);
+ GoaOAuth2Provider *self = GOA_OAUTH2_PROVIDER (user_data);
GoaOAuth2ProviderPrivate *priv;
- priv = goa_oauth2_provider_get_instance_private (provider);
+ priv = goa_oauth2_provider_get_instance_private (self);
gtk_dialog_response (priv->dialog, GTK_RESPONSE_CANCEL);
}
static void
on_web_view_password_submit (GoaWebView *web_view, const gchar *password, gpointer user_data)
{
- GoaOAuth2Provider *provider = GOA_OAUTH2_PROVIDER (user_data);
+ GoaOAuth2Provider *self = GOA_OAUTH2_PROVIDER (user_data);
GoaOAuth2ProviderPrivate *priv;
- priv = goa_oauth2_provider_get_instance_private (provider);
+ priv = goa_oauth2_provider_get_instance_private (self);
g_free (priv->password);
priv->password = g_strdup (password);
@@ -841,7 +842,7 @@ on_web_view_decide_policy (WebKitWebView *web_view,
WebKitPolicyDecisionType decision_type,
gpointer user_data)
{
- GoaOAuth2Provider *provider = GOA_OAUTH2_PROVIDER (user_data);
+ GoaOAuth2Provider *self = GOA_OAUTH2_PROVIDER (user_data);
GoaOAuth2ProviderPrivate *priv;
GHashTable *key_value_pairs;
WebKitNavigationAction *action;
@@ -854,12 +855,12 @@ on_web_view_decide_policy (WebKitWebView *web_view,
const gchar *requested_uri;
gint response_id = GTK_RESPONSE_NONE;
- priv = goa_oauth2_provider_get_instance_private (provider);
+ priv = goa_oauth2_provider_get_instance_private (self);
if (decision_type != WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION)
goto default_behaviour;
- if (goa_oauth2_provider_decide_navigation_policy (provider,
+ if (goa_oauth2_provider_decide_navigation_policy (self,
web_view,
WEBKIT_NAVIGATION_POLICY_DECISION (decision)))
{
@@ -872,7 +873,7 @@ on_web_view_decide_policy (WebKitWebView *web_view,
action = webkit_navigation_policy_decision_get_navigation_action (WEBKIT_NAVIGATION_POLICY_DECISION
(decision));
request = webkit_navigation_action_get_request (action);
requested_uri = webkit_uri_request_get_uri (request);
- redirect_uri = goa_oauth2_provider_get_redirect_uri (provider);
+ redirect_uri = goa_oauth2_provider_get_redirect_uri (self);
if (!g_str_has_prefix (requested_uri, redirect_uri))
goto default_behaviour;
@@ -887,12 +888,12 @@ on_web_view_decide_policy (WebKitWebView *web_view,
* 3) the auth code can be in the query part of the URI, with which
* we'll obtain the token later.
*/
- if (GOA_OAUTH2_PROVIDER_GET_CLASS (provider)->process_redirect_url)
+ if (GOA_OAUTH2_PROVIDER_GET_CLASS (self)->process_redirect_url)
{
gchar *url;
url = soup_uri_to_string (uri, FALSE);
- if (!goa_oauth2_provider_process_redirect_url (provider, url, &priv->access_token, &priv->error))
+ if (!goa_oauth2_provider_process_redirect_url (self, url, &priv->access_token, &priv->error))
{
g_prefix_error (&priv->error, _("Authorization response: "));
priv->error->domain = GOA_ERROR;
@@ -983,7 +984,7 @@ on_web_view_decide_policy (WebKitWebView *web_view,
}
static gboolean
-get_tokens_and_identity (GoaOAuth2Provider *provider,
+get_tokens_and_identity (GoaOAuth2Provider *self,
gboolean add_account,
const gchar *existing_identity,
GtkDialog *dialog,
@@ -1002,7 +1003,7 @@ get_tokens_and_identity (GoaOAuth2Provider *provider,
gchar *escaped_client_id;
gchar *escaped_scope;
- g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (provider), FALSE);
+ g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (self), FALSE);
g_return_val_if_fail ((!add_account && existing_identity != NULL && existing_identity[0] != '\0')
|| (add_account && existing_identity == NULL), FALSE);
g_return_val_if_fail (GTK_IS_DIALOG (dialog), FALSE);
@@ -1013,7 +1014,7 @@ get_tokens_and_identity (GoaOAuth2Provider *provider,
escaped_client_id = NULL;
escaped_scope = NULL;
- priv = goa_oauth2_provider_get_instance_private (provider);
+ priv = goa_oauth2_provider_get_instance_private (self);
g_return_val_if_fail (priv->error == NULL, FALSE);
/* TODO: check with NM whether we're online, if not - return error */
@@ -1029,46 +1030,46 @@ get_tokens_and_identity (GoaOAuth2Provider *provider,
g_clear_pointer (&priv->refresh_token, g_free);
/* TODO: use oauth2_proxy_build_login_url_full() */
- escaped_redirect_uri = g_uri_escape_string (goa_oauth2_provider_get_redirect_uri (provider), NULL, TRUE);
- escaped_client_id = g_uri_escape_string (goa_oauth2_provider_get_client_id (provider), NULL, TRUE);
- scope = goa_oauth2_provider_get_scope (provider);
+ escaped_redirect_uri = g_uri_escape_string (goa_oauth2_provider_get_redirect_uri (self), NULL, TRUE);
+ escaped_client_id = g_uri_escape_string (goa_oauth2_provider_get_client_id (self), NULL, TRUE);
+ scope = goa_oauth2_provider_get_scope (self);
if (scope != NULL)
- escaped_scope = g_uri_escape_string (goa_oauth2_provider_get_scope (provider), NULL, TRUE);
+ escaped_scope = g_uri_escape_string (goa_oauth2_provider_get_scope (self), NULL, TRUE);
else
escaped_scope = NULL;
- url = goa_oauth2_provider_build_authorization_uri (provider,
- goa_oauth2_provider_get_authorization_uri (provider),
+ url = goa_oauth2_provider_build_authorization_uri (self,
+ goa_oauth2_provider_get_authorization_uri (self),
escaped_redirect_uri,
escaped_client_id,
escaped_scope);
- goa_utils_set_dialog_title (GOA_PROVIDER (provider), dialog, add_account);
+ goa_utils_set_dialog_title (GOA_PROVIDER (self), dialog, add_account);
grid = gtk_grid_new ();
gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_VERTICAL);
gtk_grid_set_row_spacing (GTK_GRID (grid), 12);
gtk_container_add (GTK_CONTAINER (vbox), grid);
- web_view = goa_web_view_new (GOA_PROVIDER (provider), existing_identity);
+ web_view = goa_web_view_new (GOA_PROVIDER (self), existing_identity);
gtk_widget_set_hexpand (web_view, TRUE);
gtk_widget_set_vexpand (web_view, TRUE);
embed = goa_web_view_get_view (GOA_WEB_VIEW (web_view));
- preseed_data = goa_provider_get_preseed_data (GOA_PROVIDER (provider));
+ preseed_data = goa_provider_get_preseed_data (GOA_PROVIDER (self));
cookies = extract_cookies_from_preseed_data (preseed_data);
goa_web_view_add_cookies (GOA_WEB_VIEW (web_view), cookies);
soup_cookies_free (cookies);
- if (goa_oauth2_provider_get_use_mobile_browser (provider))
+ if (goa_oauth2_provider_get_use_mobile_browser (self))
goa_web_view_fake_mobile (GOA_WEB_VIEW (web_view));
webkit_web_view_load_uri (WEBKIT_WEB_VIEW (embed), url);
g_signal_connect (embed,
"decide-policy",
G_CALLBACK (on_web_view_decide_policy),
- provider);
- g_signal_connect (web_view, "deny-click", G_CALLBACK (on_web_view_deny_click), provider);
- g_signal_connect (web_view, "password-submit", G_CALLBACK (on_web_view_password_submit), provider);
+ self);
+ g_signal_connect (web_view, "deny-click", G_CALLBACK (on_web_view_deny_click), self);
+ g_signal_connect (web_view, "password-submit", G_CALLBACK (on_web_view_password_submit), self);
gtk_container_add (GTK_CONTAINER (grid), web_view);
gtk_window_set_default_size (GTK_WINDOW (dialog), -1, -1);
@@ -1104,7 +1105,7 @@ get_tokens_and_identity (GoaOAuth2Provider *provider,
*/
/* TODO: run in worker thread */
- priv->access_token = get_tokens_sync (provider,
+ priv->access_token = get_tokens_sync (self,
priv->authorization_code,
NULL, /* refresh_token */
&priv->refresh_token,
@@ -1121,7 +1122,7 @@ get_tokens_and_identity (GoaOAuth2Provider *provider,
g_assert (priv->access_token != NULL);
/* TODO: run in worker thread */
- priv->identity = goa_oauth2_provider_get_identity_sync (provider,
+ priv->identity = goa_oauth2_provider_get_identity_sync (self,
priv->access_token,
&priv->presentation_identity,
NULL, /* TODO: GCancellable */
@@ -1149,10 +1150,10 @@ add_account_cb (GoaManager *manager,
GAsyncResult *res,
gpointer user_data)
{
- GoaOAuth2Provider *provider = GOA_OAUTH2_PROVIDER (user_data);
+ GoaOAuth2Provider *self = GOA_OAUTH2_PROVIDER (user_data);
GoaOAuth2ProviderPrivate *priv;
- priv = goa_oauth2_provider_get_instance_private (provider);
+ priv = goa_oauth2_provider_get_instance_private (self);
goa_manager_call_add_account_finish (manager,
&priv->account_object_path,
@@ -1186,12 +1187,12 @@ abs_usec_to_duration (gint64 abs_usec)
}
static void
-add_credentials_key_values (GoaOAuth2Provider *provider,
+add_credentials_key_values (GoaOAuth2Provider *self,
GVariantBuilder *credentials)
{
GoaOAuth2ProviderPrivate *priv;
- priv = goa_oauth2_provider_get_instance_private (provider);
+ priv = goa_oauth2_provider_get_instance_private (self);
if (priv->authorization_code != NULL)
g_variant_builder_add (credentials, "{sv}", "authorization_code",
@@ -1207,19 +1208,19 @@ add_credentials_key_values (GoaOAuth2Provider *provider,
}
static GoaObject *
-goa_oauth2_provider_add_account (GoaProvider *_provider,
+goa_oauth2_provider_add_account (GoaProvider *provider,
GoaClient *client,
GtkDialog *dialog,
GtkBox *vbox,
GError **error)
{
- GoaOAuth2Provider *provider = GOA_OAUTH2_PROVIDER (_provider);
+ GoaOAuth2Provider *self = GOA_OAUTH2_PROVIDER (provider);
GoaOAuth2ProviderPrivate *priv;
GoaObject *ret;
GVariantBuilder credentials;
GVariantBuilder details;
- g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (provider), NULL);
+ g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (self), NULL);
g_return_val_if_fail (GOA_IS_CLIENT (client), NULL);
g_return_val_if_fail (GTK_IS_DIALOG (dialog), NULL);
g_return_val_if_fail (GTK_IS_BOX (vbox), NULL);
@@ -1227,13 +1228,9 @@ goa_oauth2_provider_add_account (GoaProvider *_provider,
ret = NULL;
- priv = goa_oauth2_provider_get_instance_private (provider);
+ priv = goa_oauth2_provider_get_instance_private (self);
- if (!get_tokens_and_identity (provider,
- TRUE,
- NULL,
- dialog,
- vbox))
+ if (!get_tokens_and_identity (self, TRUE, NULL, dialog, vbox))
goto out;
/* OK, got the identity... see if there's already an account
@@ -1242,30 +1239,30 @@ goa_oauth2_provider_add_account (GoaProvider *_provider,
if (!goa_utils_check_duplicate (client,
priv->identity,
priv->presentation_identity,
- goa_provider_get_provider_type (GOA_PROVIDER (provider)),
+ goa_provider_get_provider_type (GOA_PROVIDER (self)),
(GoaPeekInterfaceFunc) goa_object_peek_oauth2_based,
&priv->error))
goto out;
g_variant_builder_init (&credentials, G_VARIANT_TYPE_VARDICT);
- add_credentials_key_values (provider, &credentials);
+ add_credentials_key_values (self, &credentials);
g_variant_builder_init (&details, G_VARIANT_TYPE ("a{ss}"));
- goa_oauth2_provider_add_account_key_values (provider, &details);
+ goa_oauth2_provider_add_account_key_values (self, &details);
/* we want the GoaClient to update before this method returns (so it
* can create a proxy for the new object) so run the mainloop while
* waiting for this to complete
*/
goa_manager_call_add_account (goa_client_get_manager (client),
- goa_provider_get_provider_type (GOA_PROVIDER (provider)),
+ goa_provider_get_provider_type (GOA_PROVIDER (self)),
priv->identity,
priv->presentation_identity,
g_variant_builder_end (&credentials),
g_variant_builder_end (&details),
NULL, /* GCancellable* */
(GAsyncReadyCallback) add_account_cb,
- provider);
+ self);
priv->loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (priv->loop);
if (priv->error != NULL)
@@ -1294,13 +1291,13 @@ goa_oauth2_provider_add_account (GoaProvider *_provider,
/* ---------------------------------------------------------------------------------------------------- */
static gboolean
-goa_oauth2_provider_refresh_account (GoaProvider *_provider,
+goa_oauth2_provider_refresh_account (GoaProvider *provider,
GoaClient *client,
GoaObject *object,
GtkWindow *parent,
GError **error)
{
- GoaOAuth2Provider *provider = GOA_OAUTH2_PROVIDER (_provider);
+ GoaOAuth2Provider *self = GOA_OAUTH2_PROVIDER (provider);
GoaOAuth2ProviderPrivate *priv;
GoaAccount *account;
GtkWidget *dialog;
@@ -1309,7 +1306,7 @@ goa_oauth2_provider_refresh_account (GoaProvider *_provider,
GVariantBuilder builder;
gboolean ret;
- g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (provider), FALSE);
+ g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (self), FALSE);
g_return_val_if_fail (GOA_IS_CLIENT (client), FALSE);
g_return_val_if_fail (GOA_IS_OBJECT (object), FALSE);
g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), FALSE);
@@ -1317,7 +1314,7 @@ goa_oauth2_provider_refresh_account (GoaProvider *_provider,
ret = FALSE;
- priv = goa_oauth2_provider_get_instance_private (provider);
+ priv = goa_oauth2_provider_get_instance_private (self);
dialog = gtk_dialog_new_with_buttons (NULL,
parent,
@@ -1337,7 +1334,7 @@ goa_oauth2_provider_refresh_account (GoaProvider *_provider,
* log in via the provider's web interface.
*/
existing_presentation_identity = goa_account_get_presentation_identity (account);
- if (!get_tokens_and_identity (provider,
+ if (!get_tokens_and_identity (self,
FALSE,
existing_presentation_identity,
GTK_DIALOG (dialog),
@@ -1361,8 +1358,8 @@ goa_oauth2_provider_refresh_account (GoaProvider *_provider,
}
g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
- add_credentials_key_values (provider, &builder);
- if (!goa_utils_store_credentials_for_object_sync (GOA_PROVIDER (provider),
+ add_credentials_key_values (self, &builder);
+ if (!goa_utils_store_credentials_for_object_sync (GOA_PROVIDER (self),
object,
g_variant_builder_end (&builder),
NULL, /* GCancellable */
@@ -1397,7 +1394,7 @@ free_mutex (GMutex *mutex)
/**
* goa_oauth2_provider_get_access_token_sync:
- * @provider: A #GoaOAuth2Provider.
+ * @self: A #GoaOAuth2Provider.
* @object: A #GoaObject.
* @force_refresh: If set to %TRUE, forces a refresh of the access token, if possible.
* @out_access_token_expires_in: (out): Return location for how many seconds the returned token is valid for
(0 if unknown) or %NULL.
@@ -1427,7 +1424,7 @@ free_mutex (GMutex *mutex)
* string must be freed with g_free().
*/
gchar *
-goa_oauth2_provider_get_access_token_sync (GoaOAuth2Provider *provider,
+goa_oauth2_provider_get_access_token_sync (GoaOAuth2Provider *self,
GoaObject *object,
gboolean force_refresh,
gint *out_access_token_expires_in,
@@ -1449,7 +1446,7 @@ goa_oauth2_provider_get_access_token_sync (GoaOAuth2Provider *provider,
gchar *ret;
GMutex *lock;
- g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (provider), NULL);
+ g_return_val_if_fail (GOA_IS_OAUTH2_PROVIDER (self), NULL);
g_return_val_if_fail (GOA_IS_OBJECT (object), NULL);
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
@@ -1481,7 +1478,7 @@ goa_oauth2_provider_get_access_token_sync (GoaOAuth2Provider *provider,
g_mutex_lock (lock);
/* First, get the credentials from the keyring */
- credentials = goa_utils_lookup_credentials_sync (GOA_PROVIDER (provider),
+ credentials = goa_utils_lookup_credentials_sync (GOA_PROVIDER (self),
object,
cancellable,
error);
@@ -1544,7 +1541,7 @@ goa_oauth2_provider_get_access_token_sync (GoaOAuth2Provider *provider,
/* Otherwise, refresh it */
old_refresh_token = refresh_token; refresh_token = NULL;
g_free (access_token); access_token = NULL;
- access_token = get_tokens_sync (provider,
+ access_token = get_tokens_sync (self,
authorization_code,
old_refresh_token,
&refresh_token,
@@ -1584,7 +1581,7 @@ goa_oauth2_provider_get_access_token_sync (GoaOAuth2Provider *provider,
if (password != NULL)
g_variant_builder_add (&builder, "{sv}", "password", g_variant_new_string (password));
- if (!goa_utils_store_credentials_for_object_sync (GOA_PROVIDER (provider),
+ if (!goa_utils_store_credentials_for_object_sync (GOA_PROVIDER (self),
object,
g_variant_builder_end (&builder),
cancellable,
@@ -1663,13 +1660,13 @@ goa_oauth2_provider_build_object (GoaProvider *provider,
/* ---------------------------------------------------------------------------------------------------- */
static gboolean
-goa_oauth2_provider_ensure_credentials_sync (GoaProvider *_provider,
+goa_oauth2_provider_ensure_credentials_sync (GoaProvider *provider,
GoaObject *object,
gint *out_expires_in,
GCancellable *cancellable,
GError **error)
{
- GoaOAuth2Provider *provider = GOA_OAUTH2_PROVIDER (_provider);
+ GoaOAuth2Provider *self = GOA_OAUTH2_PROVIDER (provider);
gboolean ret;
gchar *access_token;
gint access_token_expires_in;
@@ -1682,7 +1679,7 @@ goa_oauth2_provider_ensure_credentials_sync (GoaProvider *_provider,
force_refresh = FALSE;
again:
- access_token = goa_oauth2_provider_get_access_token_sync (provider,
+ access_token = goa_oauth2_provider_get_access_token_sync (self,
object,
force_refresh,
&access_token_expires_in,
@@ -1691,7 +1688,7 @@ goa_oauth2_provider_ensure_credentials_sync (GoaProvider *_provider,
if (access_token == NULL)
goto out;
- identity = goa_oauth2_provider_get_identity_sync (provider,
+ identity = goa_oauth2_provider_get_identity_sync (self,
access_token,
NULL, /* out_presentation_identity */
cancellable,
@@ -1729,10 +1726,10 @@ goa_oauth2_provider_ensure_credentials_sync (GoaProvider *_provider,
static void
goa_oauth2_provider_finalize (GObject *object)
{
- GoaOAuth2Provider *provider = GOA_OAUTH2_PROVIDER (object);
+ GoaOAuth2Provider *self = GOA_OAUTH2_PROVIDER (object);
GoaOAuth2ProviderPrivate *priv;
- priv = goa_oauth2_provider_get_instance_private (provider);
+ priv = goa_oauth2_provider_get_instance_private (self);
g_clear_pointer (&priv->loop, g_main_loop_unref);
@@ -1748,7 +1745,7 @@ goa_oauth2_provider_finalize (GObject *object)
}
static void
-goa_oauth2_provider_init (GoaOAuth2Provider *provider)
+goa_oauth2_provider_init (GoaOAuth2Provider *self)
{
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]