<commit_before>/*
 * Mex - a media explorer
 *
 * Copyright © 2010, 2011 Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU Lesser General Public License,
 * version 2.1, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses>
 */

#include <dbus/dbus-glib.h>
#include "mex-screensaver.h"

G_DEFINE_TYPE (MexScreensaver, mex_screensaver, G_TYPE_OBJECT)

#define SCREENSAVER_PRIVATE(o) \
    (G_TYPE_INSTANCE_GET_PRIVATE ((o), MEX_TYPE_SCREENSAVER, \
                                  MexScreensaverPrivate))

struct _MexScreensaverPrivate
{
  gint gnome_version;

  guint32 cookie;
};

static void
mex_screensaver_finalize (GObject *object)
{
  G_OBJECT_CLASS (mex_screensaver_parent_class)->finalize (object);
}

static void
mex_screensaver_class_init (MexScreensaverClass *klass)
{
  GObjectClass *object_class = G_OBJECT_CLASS (klass);

  g_type_class_add_private (klass, sizeof (MexScreensaverPrivate));

  object_class->finalize = mex_screensaver_finalize;
}

static void
mex_screensaver_init (MexScreensaver *self)
{
  self->priv = SCREENSAVER_PRIVATE (self);
}

MexScreensaver *
mex_screensaver_new (void)
{
  return g_object_new (MEX_TYPE_SCREENSAVER, NULL);
}

static DBusGProxy *
connect_gnome_screensaverd (MexScreensaver *self)
{
 MexScreensaverPrivate *priv = MEX_SCREENSAVER (self)->priv;

 DBusGConnection *dbus_connection;
 DBusGProxy *proxy;
 GError *error=NULL;

 dbus_connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);

 if (dbus_connection == NULL)
   {
     g_warning ("Failed to connect to dbus %s\n",
                (error) ? error->message : "");
     if (error)
       g_error_free (error);

     return NULL;
   }

 /* Try with gnome 2 api first. gnome_version 0 is the default
  * representing the undetermined state<commit_msg>screensaver: Fix use of uninitialized variable<commit_after>/*
 * Mex - a media explorer
 *
 * Copyright © 2010, 2011 Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU Lesser General Public License,
 * version 2.1, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses>
 */

#include <dbus/dbus-glib.h>
#include "mex-screensaver.h"

G_DEFINE_TYPE (MexScreensaver, mex_screensaver, G_TYPE_OBJECT)

#define SCREENSAVER_PRIVATE(o) \
    (G_TYPE_INSTANCE_GET_PRIVATE ((o), MEX_TYPE_SCREENSAVER, \
                                  MexScreensaverPrivate))

struct _MexScreensaverPrivate
{
  gint gnome_version;

  guint32 cookie;
};

static void
mex_screensaver_finalize (GObject *object)
{
  G_OBJECT_CLASS (mex_screensaver_parent_class)->finalize (object);
}

static void
mex_screensaver_class_init (MexScreensaverClass *klass)
{
  GObjectClass *object_class = G_OBJECT_CLASS (klass);

  g_type_class_add_private (klass, sizeof (MexScreensaverPrivate));

  object_class->finalize = mex_screensaver_finalize;
}

static void
mex_screensaver_init (MexScreensaver *self)
{
  self->priv = SCREENSAVER_PRIVATE (self);
}

MexScreensaver *
mex_screensaver_new (void)
{
  return g_object_new (MEX_TYPE_SCREENSAVER, NULL);
}

static DBusGProxy *
connect_gnome_screensaverd (MexScreensaver *self)
{
 MexScreensaverPrivate *priv = MEX_SCREENSAVER (self)->priv;

 DBusGConnection *dbus_connection;
 DBusGProxy *proxy = NULL;
 GError *error=NULL;

 dbus_connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);

 if (dbus_connection == NULL)
   {
     g_warning ("Failed to connect to dbus %s\n",
                (error) ? error->message : "");
     if (error)
       g_error_free (error);

     return NULL;
   }

 /* Try with gnome 2 api first. gnome_version 0 is the default
  * representing the undetermined state
{'fraction_non_alphanumeric': 0.08381374722838138, 'fraction_numerical': 0.006208425720620843, 'mean_word_length': 4.245348837209303, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6052961', 'n_tokens_mistral': 1540, 'n_tokens_neox': 1458, 'n_words': 429}