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-11-15 09:04:49 Functions: 154 182 84.6 %

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

Generated by: LCOV version 1.14