LCOV - code coverage report
Current view: top level - sbus - sssd_dbus_common_signals.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 22 0.0 %
Date: 2016-06-29 Functions: 0 2 0.0 %

          Line data    Source code
       1             : /*
       2             :     Authors:
       3             :         Pavel Březina <pbrezina@redhat.com>
       4             : 
       5             :     Copyright (C) 2015 Red Hat
       6             : 
       7             :     This program is free software; you can redistribute it and/or modify
       8             :     it under the terms of the GNU General Public License as published by
       9             :     the Free Software Foundation; either version 3 of the License, or
      10             :     (at your option) any later version.
      11             : 
      12             :     This program is distributed in the hope that it will be useful,
      13             :     but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15             :     GNU General Public License for more details.
      16             : 
      17             :     You should have received a copy of the GNU General Public License
      18             :     along with this program.  If not, see <http://www.gnu.org/licenses/>.
      19             : */
      20             : 
      21             : #include <talloc.h>
      22             : #include <dbus/dbus.h>
      23             : #include <dhash.h>
      24             : 
      25             : #include "util/util.h"
      26             : #include "sbus/sssd_dbus.h"
      27             : #include "sbus/sssd_dbus_private.h"
      28             : 
      29             : static void
      30           0 : sbus_signal_name_owner_changed(struct sbus_incoming_signal *a_signal,
      31             :                                void *handler_data)
      32             : {
      33           0 :     hash_table_t *table = a_signal->conn->clients;
      34             :     hash_key_t *keys;
      35             :     unsigned long count;
      36             :     unsigned long i;
      37             :     int hret;
      38             : 
      39           0 :     DEBUG(SSSDBG_TRACE_FUNC, "Clearing UIDs cache\n");
      40             : 
      41           0 :     hret = hash_keys(table, &count, &keys);
      42           0 :     if (hret != HASH_SUCCESS) {
      43           0 :         DEBUG(SSSDBG_OP_FAILURE, "Unable to get hash keys\n");
      44           0 :         return;
      45             :     }
      46             : 
      47           0 :     for (i = 0; i < count; i++) {
      48           0 :         hret = hash_delete(table, &keys[i]);
      49           0 :         if (hret != HASH_SUCCESS) {
      50           0 :             DEBUG(SSSDBG_MINOR_FAILURE, "Could not delete key from hash\n");
      51           0 :             return;
      52             :         }
      53             :     }
      54             : 
      55           0 :     return;
      56             : }
      57             : 
      58             : struct signals_map {
      59             :     const char *iface;
      60             :     const char *signal;
      61             :     sbus_incoming_signal_fn handler_fn;
      62             :     int conn_type;
      63             : };
      64             : 
      65             : static struct signals_map signals_map[] = {
      66             :     { "org.freedesktop.DBus", "NameOwnerChanged",
      67             :       sbus_signal_name_owner_changed, SBUS_CONN_TYPE_SYSBUS },
      68             :     { NULL, NULL, NULL, 0 },
      69             : };
      70             : 
      71           0 : void sbus_register_common_signals(struct sbus_connection *conn, void *pvt)
      72             : {
      73             :     errno_t ret;
      74             :     int i;
      75             : 
      76           0 :     for (i = 0; signals_map[i].iface != NULL; i++) {
      77           0 :         if (signals_map[i].conn_type != conn->connection_type) {
      78             :             /* Skip this signal. */
      79           0 :             continue;
      80             :         }
      81             : 
      82           0 :         ret = sbus_signal_listen(conn, signals_map[i].iface,
      83             :                                  signals_map[i].signal,
      84             :                                  signals_map[i].handler_fn, conn);
      85           0 :         if (ret != EOK) {
      86           0 :             DEBUG(SSSDBG_MINOR_FAILURE, "Unable to register signal %s.%s\n",
      87             :                   signals_map[i].iface, signals_map[i].signal);
      88           0 :             continue;
      89             :         }
      90             :     }
      91           0 : }

Generated by: LCOV version 1.10