summaryrefslogtreecommitdiff
path: root/telepathy-glib/logger.c
blob: c3d1593184c550c5247fed8f2f2767a9e43e0a6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
 * TpLogger - a TpProxy for the logger
 *
 * Copyright (C) 2014 Collabora Ltd. <http://www.collabora.co.uk/>
 *
 * 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, see <http://www.gnu.org/licenses/>.
 */


#include "config.h"

#include "logger.h"

#include <telepathy-glib/telepathy-glib-dbus.h>
#include <telepathy-glib/cli-misc.h>
#include <telepathy-glib/proxy-subclass.h>

#define DEBUG_FLAG TP_DEBUG_PROXY
#include "telepathy-glib/client-factory-internal.h"
#include "telepathy-glib/debug-internal.h"
#include "telepathy-glib/dbus-internal.h"

/**
 * SECTION: logger
 * @title: TpLogger
 * @short_description: proxy object on the logger
 *
 * #TpLogger is a #TpProxy subclass on the telepathy logger.
 */

/**
 * TpLogger:
 *
 * Data structure representing a #TpLogger.
 *
 * Since: 0.99.8
 */

/**
 * TpLoggerClass:
 *
 * The class of a #TpLogger.
 *
 * Since: 0.99.8
 */

G_DEFINE_TYPE (TpLogger, tp_logger, TP_TYPE_PROXY)

struct _TpLoggerPriv
{
  gpointer unused;
};

static void
tp_logger_class_init (
    TpLoggerClass *klass)
{
  TpProxyClass *proxy_class = (TpProxyClass *) klass;

  proxy_class->interface = TP_IFACE_QUARK_LOGGER;

  g_type_class_add_private (klass, sizeof (TpLoggerPriv));
}

static void
tp_logger_init (TpLogger *self)
{
  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
      TP_TYPE_LOGGER, TpLoggerPriv);
}

TpLogger *
_tp_logger_new (TpClientFactory *factory)
{
  return g_object_new (TP_TYPE_LOGGER,
      "bus-name", TP_LOGGER_BUS_NAME,
      "object-path", TP_LOGGER_OBJECT_PATH,
      "factory", factory,
      NULL);
}

/**
 * tp_logger_dup:
 *
 * Returns the default #TpClientFactory's #TpLogger. It will use
 * tp_client_factory_dup(), print a warning and return %NULL if it fails.
 *
 * Returns: (transfer full): a reference on a #TpLogger singleton.
 *
 * Since: 0.99.8
 */
TpLogger *
tp_logger_dup (void)
{
  TpLogger *self;
  TpClientFactory *factory;
  GError *error = NULL;

  factory = tp_client_factory_dup (&error);
  if (factory == NULL)
    {
      WARNING ("Error getting default TpClientFactory: %s", error->message);
      g_clear_error (&error);
      return NULL;
    }

  self = tp_client_factory_ensure_logger (factory);

  g_object_unref (factory);

  return self;
}