LCOV - code coverage report
Current view: top level - src/jamidht - channel_handler.h (source / functions) Coverage Total Hit
Test: jami-coverage-filtered.info Lines: 33.3 % 3 1
Test Date: 2026-06-13 09:18:46 Functions: 33.3 % 3 1

            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              : #include <dhtnet/multiplexed_socket.h>
      20              : // #include <opendht/crypto.h>
      21              : 
      22              : namespace jami {
      23              : 
      24              : using DeviceId = dht::PkId;
      25              : using ConnectCb = std::function<void(std::shared_ptr<dhtnet::ChannelSocket>, const DeviceId&)>;
      26              : using ConnectCallbackLegacy = std::function<void(std::shared_ptr<dhtnet::ChannelSocket>, const dht::InfoHash&)>;
      27              : 
      28              : // using ConnectCb = dhtnet::ConnectCallback;
      29              : // using ConnectCallbackLegacy = dhtnet::ConnectCallbackLegacy;
      30              : 
      31              : /**
      32              :  * A Channel handler is used to make the link between JamiAccount and ConnectionManager
      33              :  * Its role is to manage channels for a protocol (git/sip/etc)
      34              :  */
      35              : class ChannelHandlerInterface
      36              : {
      37              : public:
      38         5376 :     virtual ~ChannelHandlerInterface() {};
      39              : 
      40              :     /**
      41              :      * Ask for a new channel
      42              :      * @param deviceId      The device to connect
      43              :      * @param name          The name of the channel
      44              :      * @param cb            The callback to call when connected (can be immediate if already connected)
      45              :      * @param connectionType  The connection type used by iOS notifications (not used)
      46              :      * @param forceNewConnection  If we want a new SIP connection (not used)
      47              :      */
      48              :     virtual void connect(const DeviceId& deviceId,
      49              :                          const std::string& name,
      50              :                          ConnectCb&& cb,
      51              :                          const std::string& connectionType = "",
      52              :                          bool forceNewConnection = false)
      53              :         = 0;
      54              : 
      55            0 :     virtual void connect(const dht::InfoHash& /*infoHash*/, const std::string& /*name*/, ConnectCallbackLegacy&& /*cb*/)
      56            0 :     {}
      57              : 
      58              :     /**
      59              :      * Determine if we accept or not the request. Called when ConnectionManager receives a request
      60              :      * @param peer          Peer who asked
      61              :      * @param name          The name of the channel
      62              :      * @return if we accept or not
      63              :      */
      64              :     virtual bool onRequest(const std::shared_ptr<dht::crypto::Certificate>& peer, const std::string& name) = 0;
      65              : 
      66              :     /**
      67              :      * Called when ConnectionManager has a new channel ready
      68              :      * @param peer          Connected peer
      69              :      * @param name          The name of the channel
      70              :      * @param channel       Channel to handle
      71              :      */
      72              :     virtual void onReady(const std::shared_ptr<dht::crypto::Certificate>& peer,
      73              :                          const std::string& name,
      74              :                          std::shared_ptr<dhtnet::ChannelSocket> channel)
      75              :         = 0;
      76              : };
      77              : 
      78              : } // namespace jami
        

Generated by: LCOV version 2.0-1