LCOV - code coverage report
Current view: top level - foo/src/client - jami_signal.h (source / functions) Hit Total Coverage
Test: jami-coverage-filtered.info Lines: 10 11 90.9 %
Date: 2026-02-28 10:41:24 Functions: 151 178 84.8 %

          Line data    Source code
       1             : /*
       2             :  *  Copyright (C) 2004-2026 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 "tracepoint.h"
      40             : 
      41             : #ifdef __APPLE__
      42             : #include <TargetConditionals.h>
      43             : #endif
      44             : 
      45             : #include <exception>
      46             : #include <memory>
      47             : #include <map>
      48             : #include <utility>
      49             : #include <string>
      50             : 
      51             : namespace jami {
      52             : 
      53             : using SignalHandlerMap = std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>>;
      54             : extern SignalHandlerMap& getSignalHandlers();
      55             : 
      56             : /*
      57             :  * Find related user given callback and call it with given
      58             :  * arguments.
      59             :  */
      60             : #pragma GCC diagnostic push
      61             : #pragma GCC diagnostic ignored "-Wunused-parameter"
      62             : template<typename Ts, typename... Args>
      63             : void
      64       25791 : emitSignal(Args... args)
      65             : {
      66             :     jami_tracepoint_if_enabled(emit_signal, demangle<Ts>().c_str());
      67             : 
      68       25791 :     const auto& handlers = getSignalHandlers();
      69       59917 :     if (auto wrap = libjami::CallbackWrapper<typename Ts::cb_type>(handlers.at(Ts::name))) {
      70             :         try {
      71        8335 :             auto cb = *wrap;
      72             :             jami_tracepoint(emit_signal_begin_callback, wrap.file_, wrap.linum_);
      73        8335 :             cb(args...);
      74             :             jami_tracepoint(emit_signal_end_callback);
      75        8335 :         } catch (std::exception& e) {
      76           0 :             JAMI_ERR("Exception during emit signal %s:\n%s", Ts::name, e.what());
      77             :         }
      78             :     }
      79             : 
      80             :     jami_tracepoint(emit_signal_end);
      81       25791 : }
      82             : #pragma GCC diagnostic pop
      83             : 
      84             : template<typename Ts>
      85             : std::pair<std::string, std::shared_ptr<libjami::CallbackWrapper<typename Ts::cb_type>>>
      86        3293 : exported_callback()
      87             : {
      88        3293 :     return std::make_pair((const std::string&) Ts::name,
      89        6586 :                           std::make_shared<libjami::CallbackWrapper<typename Ts::cb_type>>());
      90             : }
      91             : 
      92             : } // namespace jami

Generated by: LCOV version 1.14