LCOV - code coverage report
Current view: top level - src/client - ring_signal.h (source / functions) Hit Total Coverage
Test: jami-coverage-filtered.info Lines: 9 10 90.0 %
Date: 2024-04-24 08:04:06 Functions: 155 181 85.6 %

          Line data    Source code
       1             : /*
       2             :  *  Copyright (C) 2004-2024 Savoir-faire Linux Inc.
       3             :  *
       4             :  *  Author: Guillaume Roguez <Guillaume.Roguez@savoirfairelinux.com>
       5             :  *
       6             :  *  This program is free software; you can redistribute it and/or modify
       7             :  *  it under the terms of the GNU General Public License as published by
       8             :  *  the Free Software Foundation; either version 3 of the License, or
       9             :  *  (at your option) any later version.
      10             :  *
      11             :  *  This program 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
      14             :  *  GNU General Public License for more details.
      15             :  *
      16             :  *  You should have received a copy of the GNU General Public License
      17             :  *  along with this program; if not, write to the Free Software
      18             :  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
      19             :  */
      20             : 
      21             : #pragma once
      22             : 
      23             : #ifdef HAVE_CONFIG_H
      24             : #include "config.h"
      25             : #endif
      26             : 
      27             : #include "callmanager_interface.h"
      28             : #include "configurationmanager_interface.h"
      29             : #include "conversation_interface.h"
      30             : #include "presencemanager_interface.h"
      31             : #include "datatransfer_interface.h"
      32             : 
      33             : #ifdef ENABLE_VIDEO
      34             : #include "videomanager_interface.h"
      35             : #endif
      36             : 
      37             : #ifdef ENABLE_PLUGIN
      38             : #include "plugin_manager_interface.h"
      39             : #endif
      40             : 
      41             : #include "jami.h"
      42             : #include "logger.h"
      43             : #include "trace-tools.h"
      44             : #include "tracepoint.h"
      45             : 
      46             : #ifdef __APPLE__
      47             : #include <TargetConditionals.h>
      48             : #endif
      49             : 
      50             : #include <exception>
      51             : #include <memory>
      52             : #include <map>
      53             : #include <utility>
      54             : #include <string>
      55             : 
      56             : namespace jami {
      57             : 
      58             : using SignalHandlerMap = std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>>;
      59             : extern SignalHandlerMap& getSignalHandlers();
      60             : 
      61             : /*
      62             :  * Find related user given callback and call it with given
      63             :  * arguments.
      64             :  */
      65             : #pragma GCC diagnostic push
      66             : #pragma GCC diagnostic ignored "-Wunused-parameter"
      67             : template<typename Ts, typename... Args>
      68       27998 : void emitSignal(Args... args)
      69             : {
      70             :     jami_tracepoint_if_enabled(emit_signal, demangle<Ts>().c_str());
      71             : 
      72       27998 :     const auto& handlers = getSignalHandlers();
      73       63972 :     if (auto wrap = libjami::CallbackWrapper<typename Ts::cb_type>(handlers.at(Ts::name))) {
      74             :         try {
      75        7976 :             auto cb = *wrap;
      76             :             jami_tracepoint(emit_signal_begin_callback,
      77             :                             wrap.file_, wrap.linum_);
      78        7976 :             cb(args...);
      79             :             jami_tracepoint(emit_signal_end_callback);
      80        7976 :         } catch (std::exception& e) {
      81           0 :             JAMI_ERR("Exception during emit signal %s:\n%s", Ts::name, e.what());
      82             :         }
      83             :     }
      84             : 
      85             :     jami_tracepoint(emit_signal_end);
      86       27998 : }
      87             : #pragma GCC diagnostic pop
      88             : 
      89             : template<typename Ts>
      90             : std::pair<std::string, std::shared_ptr<libjami::CallbackWrapper<typename Ts::cb_type>>>
      91        3496 : exported_callback()
      92             : {
      93             :     return std::make_pair((const std::string&) Ts::name,
      94        3496 :                           std::make_shared<libjami::CallbackWrapper<typename Ts::cb_type>>());
      95             : }
      96             : 
      97             : } // namespace jami

Generated by: LCOV version 1.14