LCOV - code coverage report
Current view: top level - gio - gnotificationbackend.c (source / functions) Coverage Total Hit
Test: unnamed Lines: 100.0 % 30 30
Test Date: 2024-11-26 05:23:01 Functions: 100.0 % 9 9
Branches: - 0 0

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

Generated by: LCOV version 2.0-1