<commit_before>/*
 * Copyright (C) 2009 Collabora Ltd.
 *
 * This library 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.
 *
 * 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
 *
 * Authors: <NAME> <<EMAIL>>
 */

#include "config.h"
#include "entry.h"
#include "entry-internal.h"

#include <glib.h>

#define DEBUG_FLAG TPL_DEBUG_ENTRY
#include <telepathy-logger/debug-internal.h>
#include <telepathy-logger/util-internal.h>

/**
 * SECTION:entry
 * @title: TplEntry
 * @short_description: Abstract representation of a log entry
 * @see_also: #TplEntryText and other subclasses when they'll exist
 *
 * The TPLogger log entry represent a generic log entry, which will be
 * specialied by subclasses of #TplEntry.
 */

/**
 * TplEntry:
 *
 * An object representing a generic log entry.
 */

/**
 * TPL_ENTRY_MSG_ID_IS_VALID:
 * @msg: a message ID
 *
 * Return whether a message ID is valid.
 *
 * If %FALSE is returned, it means that either a invalid input has been
 * passed, or the TplEntry is currently set to %TPL_ENTRY_MSG_ID_UNKNOWN
 * or %TPL_ENTRY_MSG_ID_ACKNOWLEDGED.
 *
 * Returns: %TRUE if the argument is a valid message ID or %FALSE otherwise.
 */

/**
 * TPL_ENTRY_MSG_ID_UNKNOWN:
 *
 * Special value used instead of a message ID to indicate a message with an
 * unknown status (before _tpl_entry_set_pending_msg_id() was called, or
 * when it wasn't possible to obtain the message ID).
 */

/**
 * TPL_ENTRY_MSG_ID_ACKNOWLEDGED:
 *
 * Special value used instead of a message ID to indicate an acknowledged
 * message.
 */

G_DEFINE_ABSTRACT_TYPE (TplEntry, tpl_entry, G_TYPE_OBJECT)

static void tpl_entry_set_log_id (TplEntry *self, const gchar *data);

struct _TplEntryPriv
{
  gchar *log_id;
  gint64 timestamp;
  TplEntrySignalType signal_type;
  gchar *chat_id;
  TpAccount *account;
  gchar *channel_path;

  /* incoming/outgoing */
  TplEntryDirection direction;

  /* message and receiver may be NULL depending on the signal. ie. status
   * changed signals set only the sender */
  TplEntity *sender;
  TplEntity *receiver;
};

enum {
    PROP_TIMESTAMP = 1,
    PROP_LOG_ID,
    PROP_DIRECTION,
    PROP_CHAT_ID,
    PROP_ACCOUNT,
    PROP_ACCOUNT_PATH,
    PROP_CHANNEL_PATH,
    PROP_SENDER,
    PROP_RECEIVER
};


static void
tpl_entry_finalize (GObject *obj)
{
  TplEntry *self = TPL_ENTRY (obj);
  TplEntryPriv *priv = self->priv;

  g_free (priv->chat_id);
  priv->chat_id = NULL;

  tp_clear_object (&priv->account);

  G_OBJECT_CLASS (tpl_entry_parent_class)->finalize (obj);
}


static void
tpl_entry_dispose (GObject *obj)
{
  TplEntry *self = TPL_ENTRY (obj);
  TplEntryPriv *priv = self->priv;

  if (priv->sender != NULL)
    {
      g_object_unref (priv->sender);
      priv->sender = NULL;
    }
  if (priv->receiver != NULL)
    {
      g_object_unref (priv->receiver);
      priv->receiver = NULL;
    }<commit_msg>entry: use tp_clear_pointer() and tp_clear_object()<commit_after>/*
 * Copyright (C) 2009 Collabora Ltd.
 *
 * This library 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.
 *
 * 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
 *
 * Authors: <NAME> <<EMAIL>>
 */

#include "config.h"
#include "entry.h"
#include "entry-internal.h"

#include <glib.h>

#define DEBUG_FLAG TPL_DEBUG_ENTRY
#include <telepathy-logger/debug-internal.h>
#include <telepathy-logger/util-internal.h>

/**
 * SECTION:entry
 * @title: TplEntry
 * @short_description: Abstract representation of a log entry
 * @see_also: #TplEntryText and other subclasses when they'll exist
 *
 * The TPLogger log entry represent a generic log entry, which will be
 * specialied by subclasses of #TplEntry.
 */

/**
 * TplEntry:
 *
 * An object representing a generic log entry.
 */

/**
 * TPL_ENTRY_MSG_ID_IS_VALID:
 * @msg: a message ID
 *
 * Return whether a message ID is valid.
 *
 * If %FALSE is returned, it means that either a invalid input has been
 * passed, or the TplEntry is currently set to %TPL_ENTRY_MSG_ID_UNKNOWN
 * or %TPL_ENTRY_MSG_ID_ACKNOWLEDGED.
 *
 * Returns: %TRUE if the argument is a valid message ID or %FALSE otherwise.
 */

/**
 * TPL_ENTRY_MSG_ID_UNKNOWN:
 *
 * Special value used instead of a message ID to indicate a message with an
 * unknown status (before _tpl_entry_set_pending_msg_id() was called, or
 * when it wasn't possible to obtain the message ID).
 */

/**
 * TPL_ENTRY_MSG_ID_ACKNOWLEDGED:
 *
 * Special value used instead of a message ID to indicate an acknowledged
 * message.
 */

G_DEFINE_ABSTRACT_TYPE (TplEntry, tpl_entry, G_TYPE_OBJECT)

static void tpl_entry_set_log_id (TplEntry *self, const gchar *data);

struct _TplEntryPriv
{
  gchar *log_id;
  gint64 timestamp;
  TplEntrySignalType signal_type;
  gchar *chat_id;
  TpAccount *account;
  gchar *channel_path;

  /* incoming/outgoing */
  TplEntryDirection direction;

  /* message and receiver may be NULL depending on the signal. ie. status
   * changed signals set only the sender */
  TplEntity *sender;
  TplEntity *receiver;
};

enum {
    PROP_TIMESTAMP = 1,
    PROP_LOG_ID,
    PROP_DIRECTION,
    PROP_CHAT_ID,
    PROP_ACCOUNT,
    PROP_ACCOUNT_PATH,
    PROP_CHANNEL_PATH,
    PROP_SENDER,
    PROP_RECEIVER
};


static void
tpl_entry_finalize (GObject *obj)
{
  TplEntry *self = TPL_ENTRY (obj);
  TplEntryPriv *priv = self->priv;

  tp_clear_pointer (&priv->chat_id, g_free);

  G_OBJECT_CLASS (tpl_entry_parent_class)->finalize (obj);
}


static void
tpl_entry_dispose (GObject *obj)
{
  TplEntry *self = TPL_ENTRY (obj);
  TplEntryPriv *priv = self->priv;

  tp_clear_object (&priv->account);
  tp_clear_object (&priv->sender);
  tp_clear_object (&priv->receiver);
{'fraction_non_alphanumeric': 0.0896460953495174, 'fraction_numerical': 0.0058496636443404505, 'mean_word_length': 3.930785868781543, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3592900', 'n_tokens_mistral': 2269, 'n_tokens_neox': 2206, 'n_words': 765}