<commit_before>/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*-  */
/*
 * libgfbgraph - GObject library for Facebook Graph API
 * Copyright (C) 2013 <NAME> <<EMAIL>>
 *
 * GFBGraph is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * GFBGraph is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with GFBGraph.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * SECTION:gfbgraph-simple-authorizer
 * @short_description: GFBGraph simple authorization interface
 * @stability: Unstable
 * @include: gfbgraph/gfbgraph-simple-authorizer.h
 *
 * #GFBGraphSimpleAuthorizer provides an implementation of the #GFBGraphAuthorizer interface
 * for authorization using a access token provided in creation time, no refresh, just a simple
 * authorizer for test purposes, don't use in final code.
 **/

#include "gfbgraph-authorizer.h"
#include "gfbgraph-simple-authorizer.h"

enum
{
        PROP_0,

        PROP_ACCESS_TOKEN
};

struct _GFBGraphSimpleAuthorizerPrivate {
        GMutex mutex;
        gchar *access_token;
};

static void gfbgraph_simple_authorizer_init         (GFBGraphSimpleAuthorizer *obj);
static void gfbgraph_simple_authorizer_class_init   (GFBGraphSimpleAuthorizerClass *klass);
static void gfbgraph_simple_authorizer_finalize     (GObject *obj);
static void gfbgraph_simple_authorizer_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void gfbgraph_simple_authorizer_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);

static void gfbgraph_simple_authorizer_iface_init (GFBGraphAuthorizerInterface *iface);

void     gfbgraph_simple_authorizer_process_call          (GFBGraphAuthorizer *iface, RestProxyCall *call);
void     gfbgraph_simple_authorizer_process_message       (GFBGraphAuthorizer *iface, SoupMessage *message);
gboolean gfbgraph_simple_authorizer_refresh_authorization (GFBGraphAuthorizer *iface, GCancellable *cancellable, GError **error);

#define GFBGRAPH_SIMPLE_AUTHORIZER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), GFBGRAPH_TYPE_SIMPLE_AUTHORIZER, GFBGraphSimpleAuthorizerPrivate))

static GObjectClass *parent_class = NULL;

G_DEFINE_TYPE_WITH_CODE (GFBGraphSimpleAuthorizer, gfbgraph_simple_authorizer, G_TYPE_OBJECT,
                         G_IMPLEMENT_INTERFACE (GFBGRAPH_TYPE_AUTHORIZER, gfbgraph_simple_authorizer_iface_init));


static void
gfbgraph_simple_authorizer_init (GFBGraphSimpleAuthorizer *obj)
{
        obj->priv = GFBGRAPH_SIMPLE_AUTHORIZER_GET_PRIVATE(obj);
        g_mutex_init (&obj->priv->mutex);
}

static void
gfbgraph_simple_authorizer_class_init (GFBGraphSimpleAuthorizerClass *klass)
{
        GObjectClass *gobject_class = G_OBJECT_CLASS (klass);

        parent_class            = g_type_class_peek_parent (klass);
        gobject_class->finalize = gfbgraph_simple_authorizer_finalize;
        gobject_class->set_property = gfbgraph_simple_authorizer_set_property;
        gobject_class->get_property = gfbgraph_simple_authorizer_get_property;

        g_type_class_add_private (gobject_class, sizeof(GFBGraphSimpleAuthorizerPrivate));

        /**
         * GFBGraphSimpleAuthorizer:access_token:
         *
         * The access token for the Facebook Graph API, normally, take it by hand in the 
         * Graph API explorer tool: https://developers.facebook.com/tools/explorer.
         **/
        g_object_class_install_property (gobject_class,
                                         PROP_ACCESS_TOKEN,
                                         g_param_spec_string ("access-token",
                                                              "The access token", "The access token for the Facebook Graph API.",
                                                              "",
                                                              G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
gfbgraph_simple_authorizer_finalize (GObject *obj)
{
        GFBGraphSimpleAuthorizerPrivate *priv;

        priv = GFBGRAPH_SIMPLE_AUTHORIZER_GET_PRIVATE (obj);

        g_free (priv->access_token);

        G_OBJECT_CLASS(parent_class)->finalize (obj);
}<commit_msg>simple-authorizer: Clear GMutex on the instance finalization<commit_after>/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*-  */
/*
 * libgfbgraph - GObject library for Facebook Graph API
 * Copyright (C) 2013 <NAME> <<EMAIL>>
 *
 * GFBGraph is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * GFBGraph is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with GFBGraph.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * SECTION:gfbgraph-simple-authorizer
 * @short_description: GFBGraph simple authorization interface
 * @stability: Unstable
 * @include: gfbgraph/gfbgraph-simple-authorizer.h
 *
 * #GFBGraphSimpleAuthorizer provides an implementation of the #GFBGraphAuthorizer interface
 * for authorization using a access token provided in creation time, no refresh, just a simple
 * authorizer for test purposes, don't use in final code.
 **/

#include "gfbgraph-authorizer.h"
#include "gfbgraph-simple-authorizer.h"

enum
{
        PROP_0,

        PROP_ACCESS_TOKEN
};

struct _GFBGraphSimpleAuthorizerPrivate {
        GMutex mutex;
        gchar *access_token;
};

static void gfbgraph_simple_authorizer_init         (GFBGraphSimpleAuthorizer *obj);
static void gfbgraph_simple_authorizer_class_init   (GFBGraphSimpleAuthorizerClass *klass);
static void gfbgraph_simple_authorizer_finalize     (GObject *obj);
static void gfbgraph_simple_authorizer_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void gfbgraph_simple_authorizer_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);

static void gfbgraph_simple_authorizer_iface_init (GFBGraphAuthorizerInterface *iface);

void     gfbgraph_simple_authorizer_process_call          (GFBGraphAuthorizer *iface, RestProxyCall *call);
void     gfbgraph_simple_authorizer_process_message       (GFBGraphAuthorizer *iface, SoupMessage *message);
gboolean gfbgraph_simple_authorizer_refresh_authorization (GFBGraphAuthorizer *iface, GCancellable *cancellable, GError **error);

#define GFBGRAPH_SIMPLE_AUTHORIZER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), GFBGRAPH_TYPE_SIMPLE_AUTHORIZER, GFBGraphSimpleAuthorizerPrivate))

static GObjectClass *parent_class = NULL;

G_DEFINE_TYPE_WITH_CODE (GFBGraphSimpleAuthorizer, gfbgraph_simple_authorizer, G_TYPE_OBJECT,
                         G_IMPLEMENT_INTERFACE (GFBGRAPH_TYPE_AUTHORIZER, gfbgraph_simple_authorizer_iface_init));


static void
gfbgraph_simple_authorizer_init (GFBGraphSimpleAuthorizer *obj)
{
        obj->priv = GFBGRAPH_SIMPLE_AUTHORIZER_GET_PRIVATE(obj);
        g_mutex_init (&obj->priv->mutex);
}

static void
gfbgraph_simple_authorizer_class_init (GFBGraphSimpleAuthorizerClass *klass)
{
        GObjectClass *gobject_class = G_OBJECT_CLASS (klass);

        parent_class            = g_type_class_peek_parent (klass);
        gobject_class->finalize = gfbgraph_simple_authorizer_finalize;
        gobject_class->set_property = gfbgraph_simple_authorizer_set_property;
        gobject_class->get_property = gfbgraph_simple_authorizer_get_property;

        g_type_class_add_private (gobject_class, sizeof(GFBGraphSimpleAuthorizerPrivate));

        /**
         * GFBGraphSimpleAuthorizer:access_token:
         *
         * The access token for the Facebook Graph API, normally, take it by hand in the 
         * Graph API explorer tool: https://developers.facebook.com/tools/explorer.
         **/
        g_object_class_install_property (gobject_class,
                                         PROP_ACCESS_TOKEN,
                                         g_param_spec_string ("access-token",
                                                              "The access token", "The access token for the Facebook Graph API.",
                                                              "",
                                                              G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
gfbgraph_simple_authorizer_finalize (GObject *obj)
{
        GFBGraphSimpleAuthorizerPrivate *priv;

        priv = GFBGRAPH_SIMPLE_AUTHORIZER_GET_PRIVATE (obj);

        g_free (priv->access_token);
        g_mutex_clear (&priv->mutex);

        G_OBJECT_CLASS(parent_class)->finalize (obj);
}
{'fraction_non_alphanumeric': 0.07145156099130995, 'fraction_numerical': 0.0019311232700354038, 'mean_word_length': 3.4709832134292564, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 28, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5200538', 'n_tokens_mistral': 2717, 'n_tokens_neox': 2674, 'n_words': 682}