LCOV - code coverage report
Current view: top level - src/client - ring_signal.cpp (source / functions) Hit Total Coverage
Test: jami-coverage-filtered.info Lines: 107 109 98.2 %
Date: 2024-12-21 08:56:24 Functions: 3 3 100.0 %

          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             : 
      18             : #include "ring_signal.h"
      19             : 
      20             : namespace jami {
      21             : 
      22             : SignalHandlerMap&
      23       30376 : getSignalHandlers()
      24             : {
      25             :     static SignalHandlerMap handlers = {
      26             :         /* Call */
      27          38 :         exported_callback<libjami::CallSignal::StateChange>(),
      28          76 :         exported_callback<libjami::CallSignal::TransferFailed>(),
      29          76 :         exported_callback<libjami::CallSignal::TransferSucceeded>(),
      30          76 :         exported_callback<libjami::CallSignal::RecordPlaybackStopped>(),
      31          76 :         exported_callback<libjami::CallSignal::VoiceMailNotify>(),
      32          76 :         exported_callback<libjami::CallSignal::IncomingMessage>(),
      33          76 :         exported_callback<libjami::CallSignal::IncomingCall>(),
      34          76 :         exported_callback<libjami::CallSignal::IncomingCallWithMedia>(),
      35          76 :         exported_callback<libjami::CallSignal::MediaChangeRequested>(),
      36          76 :         exported_callback<libjami::CallSignal::RecordPlaybackFilepath>(),
      37          76 :         exported_callback<libjami::CallSignal::ConferenceCreated>(),
      38          76 :         exported_callback<libjami::CallSignal::ConferenceChanged>(),
      39          76 :         exported_callback<libjami::CallSignal::UpdatePlaybackScale>(),
      40          76 :         exported_callback<libjami::CallSignal::ConferenceRemoved>(),
      41          76 :         exported_callback<libjami::CallSignal::RecordingStateChanged>(),
      42          76 :         exported_callback<libjami::CallSignal::RtcpReportReceived>(),
      43          76 :         exported_callback<libjami::CallSignal::PeerHold>(),
      44          76 :         exported_callback<libjami::CallSignal::VideoMuted>(),
      45          76 :         exported_callback<libjami::CallSignal::AudioMuted>(),
      46          76 :         exported_callback<libjami::CallSignal::SmartInfo>(),
      47          76 :         exported_callback<libjami::CallSignal::ConnectionUpdate>(),
      48          76 :         exported_callback<libjami::CallSignal::OnConferenceInfosUpdated>(),
      49          76 :         exported_callback<libjami::CallSignal::RemoteRecordingChanged>(),
      50          76 :         exported_callback<libjami::CallSignal::MediaNegotiationStatus>(),
      51             : 
      52             :         /* Configuration */
      53          76 :         exported_callback<libjami::ConfigurationSignal::VolumeChanged>(),
      54          76 :         exported_callback<libjami::ConfigurationSignal::AccountsChanged>(),
      55          76 :         exported_callback<libjami::ConfigurationSignal::AccountDetailsChanged>(),
      56          76 :         exported_callback<libjami::ConfigurationSignal::StunStatusFailed>(),
      57          76 :         exported_callback<libjami::ConfigurationSignal::RegistrationStateChanged>(),
      58          76 :         exported_callback<libjami::ConfigurationSignal::VolatileDetailsChanged>(),
      59          76 :         exported_callback<libjami::ConfigurationSignal::CertificatePinned>(),
      60          76 :         exported_callback<libjami::ConfigurationSignal::CertificatePathPinned>(),
      61          76 :         exported_callback<libjami::ConfigurationSignal::CertificateExpired>(),
      62          76 :         exported_callback<libjami::ConfigurationSignal::CertificateStateChanged>(),
      63          76 :         exported_callback<libjami::ConfigurationSignal::IncomingAccountMessage>(),
      64          76 :         exported_callback<libjami::ConfigurationSignal::ComposingStatusChanged>(),
      65          76 :         exported_callback<libjami::ConfigurationSignal::AccountMessageStatusChanged>(),
      66          76 :         exported_callback<libjami::ConfigurationSignal::NeedsHost>(),
      67          76 :         exported_callback<libjami::ConfigurationSignal::ActiveCallsChanged>(),
      68          76 :         exported_callback<libjami::ConfigurationSignal::ProfileReceived>(),
      69          76 :         exported_callback<libjami::ConfigurationSignal::IncomingTrustRequest>(),
      70          76 :         exported_callback<libjami::ConfigurationSignal::ContactAdded>(),
      71          76 :         exported_callback<libjami::ConfigurationSignal::ContactRemoved>(),
      72          76 :         exported_callback<libjami::ConfigurationSignal::ExportOnRingEnded>(),
      73          76 :         exported_callback<libjami::ConfigurationSignal::KnownDevicesChanged>(),
      74          76 :         exported_callback<libjami::ConfigurationSignal::NameRegistrationEnded>(),
      75          76 :         exported_callback<libjami::ConfigurationSignal::RegisteredNameFound>(),
      76          76 :         exported_callback<libjami::ConfigurationSignal::UserSearchEnded>(),
      77          76 :         exported_callback<libjami::ConfigurationSignal::MediaParametersChanged>(),
      78          76 :         exported_callback<libjami::ConfigurationSignal::MigrationEnded>(),
      79          76 :         exported_callback<libjami::ConfigurationSignal::DeviceRevocationEnded>(),
      80          76 :         exported_callback<libjami::ConfigurationSignal::AccountProfileReceived>(),
      81          76 :         exported_callback<libjami::ConfigurationSignal::Error>(),
      82             : #if defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
      83             :         exported_callback<libjami::ConfigurationSignal::GetHardwareAudioFormat>(),
      84             : #endif
      85             : #if defined(__ANDROID__) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
      86             :         exported_callback<libjami::ConfigurationSignal::GetAppDataPath>(),
      87             :         exported_callback<libjami::ConfigurationSignal::GetDeviceName>(),
      88             : #endif
      89          76 :         exported_callback<libjami::ConfigurationSignal::HardwareDecodingChanged>(),
      90          76 :         exported_callback<libjami::ConfigurationSignal::HardwareEncodingChanged>(),
      91          76 :         exported_callback<libjami::ConfigurationSignal::MessageSend>(),
      92             : 
      93             :         /* Presence */
      94          76 :         exported_callback<libjami::PresenceSignal::NewServerSubscriptionRequest>(),
      95          76 :         exported_callback<libjami::PresenceSignal::NearbyPeerNotification>(),
      96          76 :         exported_callback<libjami::PresenceSignal::ServerError>(),
      97          76 :         exported_callback<libjami::PresenceSignal::NewBuddyNotification>(),
      98          76 :         exported_callback<libjami::PresenceSignal::SubscriptionStateChanged>(),
      99             : 
     100             :         /* Audio */
     101          76 :         exported_callback<libjami::AudioSignal::DeviceEvent>(),
     102          76 :         exported_callback<libjami::AudioSignal::AudioMeter>(),
     103             : 
     104             :         /* DataTransfer */
     105          76 :         exported_callback<libjami::DataTransferSignal::DataTransferEvent>(),
     106             : 
     107             : #ifdef ENABLE_VIDEO
     108             :         /* MediaPlayer */
     109          76 :         exported_callback<libjami::MediaPlayerSignal::FileOpened>(),
     110             : 
     111             :         /* Video */
     112          76 :         exported_callback<libjami::VideoSignal::DeviceEvent>(),
     113          76 :         exported_callback<libjami::VideoSignal::DecodingStarted>(),
     114          76 :         exported_callback<libjami::VideoSignal::DecodingStopped>(),
     115             : #ifdef __ANDROID__
     116             :         exported_callback<libjami::VideoSignal::GetCameraInfo>(),
     117             :         exported_callback<libjami::VideoSignal::SetParameters>(),
     118             :         exported_callback<libjami::VideoSignal::RequestKeyFrame>(),
     119             :         exported_callback<libjami::VideoSignal::SetBitrate>(),
     120             : #endif
     121          76 :         exported_callback<libjami::VideoSignal::StartCapture>(),
     122          76 :         exported_callback<libjami::VideoSignal::StopCapture>(),
     123          76 :         exported_callback<libjami::VideoSignal::DeviceAdded>(),
     124          76 :         exported_callback<libjami::VideoSignal::ParametersChanged>(),
     125             : #endif
     126             : 
     127             :         /* Conversation */
     128          76 :         exported_callback<libjami::ConversationSignal::ConversationLoaded>(),
     129          76 :         exported_callback<libjami::ConversationSignal::SwarmLoaded>(),
     130          76 :         exported_callback<libjami::ConversationSignal::MessagesFound>(),
     131          76 :         exported_callback<libjami::ConversationSignal::MessageReceived>(),
     132          76 :         exported_callback<libjami::ConversationSignal::SwarmMessageReceived>(),
     133          76 :         exported_callback<libjami::ConversationSignal::SwarmMessageUpdated>(),
     134          76 :         exported_callback<libjami::ConversationSignal::ReactionAdded>(),
     135          76 :         exported_callback<libjami::ConversationSignal::ReactionRemoved>(),
     136          76 :         exported_callback<libjami::ConversationSignal::ConversationProfileUpdated>(),
     137          76 :         exported_callback<libjami::ConversationSignal::ConversationRequestReceived>(),
     138          76 :         exported_callback<libjami::ConversationSignal::ConversationRequestDeclined>(),
     139          76 :         exported_callback<libjami::ConversationSignal::ConversationReady>(),
     140          76 :         exported_callback<libjami::ConversationSignal::ConversationRemoved>(),
     141          76 :         exported_callback<libjami::ConversationSignal::ConversationMemberEvent>(),
     142          76 :         exported_callback<libjami::ConversationSignal::ConversationSyncFinished>(),
     143          76 :         exported_callback<libjami::ConversationSignal::ConversationCloned>(),
     144          76 :         exported_callback<libjami::ConversationSignal::CallConnectionRequest>(),
     145          76 :         exported_callback<libjami::ConversationSignal::OnConversationError>(),
     146          76 :         exported_callback<libjami::ConversationSignal::ConversationPreferencesUpdated>(),
     147             : 
     148             : #ifdef ENABLE_PLUGIN
     149          76 :         exported_callback<libjami::PluginSignal::WebViewMessageReceived>(),
     150             : #endif
     151       37330 :     };
     152             : 
     153       30376 :     return handlers;
     154             : }
     155             : 
     156             : }; // namespace jami
     157             : 
     158             : namespace libjami {
     159             : 
     160             : void
     161         892 : registerSignalHandlers(const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>& handlers)
     162             : {
     163         892 :     auto& handlers_ = jami::getSignalHandlers();
     164        4457 :     for (auto& item : handlers) {
     165        3565 :         auto iter = handlers_.find(item.first);
     166        3565 :         if (iter == handlers_.end()) {
     167           0 :             JAMI_ERR("Signal %s not supported", item.first.c_str());
     168           0 :             continue;
     169             :         }
     170        3565 :         iter->second = item.second;
     171             :     }
     172         892 : }
     173             : 
     174             : void
     175         872 : unregisterSignalHandlers()
     176             : {
     177         872 :     auto& handlers_ = jami::getSignalHandlers();
     178       81096 :     for (auto& item : handlers_) {
     179       80224 :         item.second = {};
     180             :     }
     181         872 : }
     182             : 
     183             : } // namespace libjami

Generated by: LCOV version 1.14