<commit_before>/* vi: set et sw=4 ts=4 cino=t0,(0: */
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of libsignon-glib
 *
 * Copyright (C) 2009-2010 Nokia Corporation.
 *
 * Contact: <NAME> <<EMAIL>>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1 as published by the Free Software Foundation.
 *
 * This library 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 this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 */

/**
 * SECTION:signon-identity
 * @title: SignonIdentity
 * @short_description: client side presentation of a credential.
 *
 * The #SignonIdentity represents an database entry for a single identity.
 */

#include "signon-identity.h"
#include "signon-internals.h"
#include "signon-proxy.h"
#include "signon-identity-glib-gen.h"
#include "signon-client-glib-gen.h"
#include <glib.h>

#define SIGNON_IDENTITY_IFACE  "com.nokia.singlesignon.SignonIdentity"

G_DEFINE_TYPE (SignonIdentity, signon_identity, G_TYPE_OBJECT);

enum
{
    PROP_0,

    PROP_ID
};

typedef struct _SignonIdentityInfo
{
    gchar *user_name;
    gchar *password;
    gchar *caption;
} SignonIdentityInfo;

struct _SignonIdentityPrivate
{
    SignonProxy *signon_proxy;
    SignonIdentityInfo *identityInfo;
    GError *last_error;
    guint id;
};

#define SIGNON_IDENTITY_PRIV(obj) (SIGNON_IDENTITY(obj)->priv)

static void
signon_identity_set_property (GObject *object,
                              guint property_id,
                              const GValue *value,
                              GParamSpec *pspec)
{
    SignonIdentity *self = SIGNON_IDENTITY (object);

    switch (property_id)
    {
    case PROP_ID:
        self->priv->id = g_value_get_uint (value);
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
        break;

    }
}

static void
signon_identity_get_property (GObject *object,
                              guint property_id,
                              GValue *value,
                              GParamSpec *pspec)
{
    SignonIdentity *self = SIGNON_IDENTITY (object);

    switch (property_id)
    {
    case PROP_ID:
        g_value_set_uint (value, self->priv->id);
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
        break;
    }
}

static void
signon_identity_init (SignonIdentity *identity)
{
    identity->priv = G_TYPE_INSTANCE_GET_PRIVATE (identity, SIGNON_TYPE_IDENTITY,
                                                  SignonIdentityPrivate);
    identity->priv->signon_proxy = signon_proxy_new();
}

static void
signon_identity_dispose (GObject *object)
{
    SignonIdentity *identity = SIGNON_IDENTITY (object);
    SignonIdentityPrivate *priv = identity->priv;

    if (priv->identityInfo)
    {
        g_slice_free (SignonIdentityInfo, priv->identityInfo);
        priv->identityInfo = NULL;
    }

    if (priv->last_error)<commit_msg>Fix for bug NB#163667, adding custom free function for identityInfo<commit_after>/* vi: set et sw=4 ts=4 cino=t0,(0: */
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of libsignon-glib
 *
 * Copyright (C) 2009-2010 Nokia Corporation.
 *
 * Contact: <NAME> <<EMAIL>>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1 as published by the Free Software Foundation.
 *
 * This library 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 this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 */

/**
 * SECTION:signon-identity
 * @title: SignonIdentity
 * @short_description: client side presentation of a credential.
 *
 * The #SignonIdentity represents an database entry for a single identity.
 */

#include "signon-identity.h"
#include "signon-internals.h"
#include "signon-proxy.h"
#include "signon-identity-glib-gen.h"
#include "signon-client-glib-gen.h"
#include <glib.h>

#define SIGNON_IDENTITY_IFACE  "com.nokia.singlesignon.SignonIdentity"

G_DEFINE_TYPE (SignonIdentity, signon_identity, G_TYPE_OBJECT);

enum
{
    PROP_0,

    PROP_ID
};

typedef struct _SignonIdentityInfo
{
    gchar *user_name;
    gchar *password;
    gchar *caption;
} SignonIdentityInfo;

struct _SignonIdentityPrivate
{
    SignonProxy *signon_proxy;
    SignonIdentityInfo *identityInfo;
    GError *last_error;
    guint id;
};

void _signon_identity_info_free (SignonIdentityInfo *identity_info)
{
    g_return_if_fail (identity_info != NULL);

    g_free (identity_info->user_name);
    g_free (identity_info->password);
    g_free (identity_info->caption);
    g_slice_free (SignonIdentityInfo, identity_info);
}

#define SIGNON_IDENTITY_PRIV(obj) (SIGNON_IDENTITY(obj)->priv)

static void
signon_identity_set_property (GObject *object,
                              guint property_id,
                              const GValue *value,
                              GParamSpec *pspec)
{
    SignonIdentity *self = SIGNON_IDENTITY (object);

    switch (property_id)
    {
    case PROP_ID:
        self->priv->id = g_value_get_uint (value);
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
        break;

    }
}

static void
signon_identity_get_property (GObject *object,
                              guint property_id,
                              GValue *value,
                              GParamSpec *pspec)
{
    SignonIdentity *self = SIGNON_IDENTITY (object);

    switch (property_id)
    {
    case PROP_ID:
        g_value_set_uint (value, self->priv->id);
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
        break;
    }
}

static void
signon_identity_init (SignonIdentity *identity)
{
    identity->priv = G_TYPE_INSTANCE_GET_PRIVATE (identity, SIGNON_TYPE_IDENTITY,
                                                  SignonIdentityPrivate);
    identity->priv->signon_proxy = signon_proxy_new();
}

static void
signon_identity_dispose (GObject *object)
{
    SignonIdentity *identity = SIGNON_IDENTITY (object);
    SignonIdentityPrivate *priv = identity->priv;

    if (priv->identityInfo)
    {
        _signon_identity_info_free (priv->identityInfo);
        priv->identityInfo = NULL;
    }

    if (priv->last_error)
{'fraction_non_alphanumeric': 0.09042403819151923, 'fraction_numerical': 0.008424599831508003, 'mean_word_length': 2.9331860850358917, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '797113', 'n_tokens_mistral': 2233, 'n_tokens_neox': 2166, 'n_words': 601}