Coverage Report

Created: 2025-07-01 07:09

/src/glib/gio/gnotificationbackend.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright © 2013 Lars Uebernickel
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2.1 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General
15
 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
16
 *
17
 * Authors: Lars Uebernickel <lars@uebernic.de>
18
 */
19
20
#include "gnotificationbackend.h"
21
22
#include "gnotification.h"
23
#include "gapplication.h"
24
#include "gactiongroup.h"
25
#include "giomodule-priv.h"
26
27
G_DEFINE_TYPE (GNotificationBackend, g_notification_backend, G_TYPE_OBJECT)
28
29
static void
30
g_notification_backend_class_init (GNotificationBackendClass *class)
31
0
{
32
0
}
33
34
static void
35
g_notification_backend_init (GNotificationBackend *backend)
36
0
{
37
0
}
38
39
GNotificationBackend *
40
g_notification_backend_new_default (GApplication *application)
41
0
{
42
0
  GType backend_type;
43
0
  GNotificationBackend *backend;
44
45
0
  g_return_val_if_fail (G_IS_APPLICATION (application), NULL);
46
47
0
  backend_type = _g_io_module_get_default_type (G_NOTIFICATION_BACKEND_EXTENSION_POINT_NAME,
48
0
                                                "GNOTIFICATION_BACKEND",
49
0
                                                G_STRUCT_OFFSET (GNotificationBackendClass, is_supported));
50
51
0
  backend = g_object_new (backend_type, NULL);
52
53
  /* Avoid ref cycle by not taking a ref to the application at all. The
54
   * backend only lives as long as the application does.
55
   */
56
0
  backend->application = application;
57
58
0
  backend->dbus_connection = g_application_get_dbus_connection (application);
59
0
  if (backend->dbus_connection)
60
0
    g_object_ref (backend->dbus_connection);
61
62
0
  return backend;
63
0
}
64
65
void
66
g_notification_backend_send_notification (GNotificationBackend *backend,
67
                                          const gchar          *id,
68
                                          GNotification        *notification)
69
0
{
70
0
  g_return_if_fail (G_IS_NOTIFICATION_BACKEND (backend));
71
0
  g_return_if_fail (G_IS_NOTIFICATION (notification));
72
73
0
  G_NOTIFICATION_BACKEND_GET_CLASS (backend)->send_notification (backend, id, notification);
74
0
}
75
76
void
77
g_notification_backend_withdraw_notification (GNotificationBackend *backend,
78
                                              const gchar          *id)
79
0
{
80
0
  g_return_if_fail (G_IS_NOTIFICATION_BACKEND (backend));
81
0
  g_return_if_fail (id != NULL);
82
83
0
  G_NOTIFICATION_BACKEND_GET_CLASS (backend)->withdraw_notification (backend, id);
84
0
}