LCOV - code coverage report
Current view: top level - src/jamidht - channel_handler.h (source / functions) Hit Total Coverage
Test: jami-coverage-filtered.info Lines: 1 1 100.0 %
Date: 2024-11-13 09:04:27 Functions: 1 2 50.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             : #pragma once
      18             : 
      19             : #include <dhtnet/multiplexed_socket.h>
      20             : 
      21             : namespace jami {
      22             : 
      23             : using DeviceId = dht::PkId;
      24             : using ConnectCb = std::function<void(std::shared_ptr<dhtnet::ChannelSocket>, const DeviceId&)>;
      25             : 
      26             : /**
      27             :  * A Channel handler is used to make the link between JamiAccount and ConnectionManager
      28             :  * Its role is to manage channels for a protocol (git/sip/etc)
      29             :  */
      30             : class ChannelHandlerInterface
      31             : {
      32             : public:
      33        3400 :     virtual ~ChannelHandlerInterface() {};
      34             : 
      35             :     /**
      36             :      * Ask for a new channel
      37             :      * @param deviceId      The device to connect
      38             :      * @param name          The name of the channel
      39             :      * @param cb            The callback to call when connected (can be immediate if already connected)
      40             :      */
      41             :     virtual void connect(const DeviceId& deviceId, const std::string& name, ConnectCb&& cb)
      42             :         = 0;
      43             : 
      44             :     /**
      45             :      * Determine if we accept or not the request. Called when ConnectionManager receives a request
      46             :      * @param peer          Peer who asked
      47             :      * @param name          The name of the channel
      48             :      * @return if we accept or not
      49             :      */
      50             :     virtual bool onRequest(const std::shared_ptr<dht::crypto::Certificate>& peer, const std::string& name) = 0;
      51             : 
      52             :     /**
      53             :      * Called when ConnectionManager has a new channel ready
      54             :      * @param peer          Connected peer
      55             :      * @param name          The name of the channel
      56             :      * @param channel       Channel to handle
      57             :      */
      58             :     virtual void onReady(const std::shared_ptr<dht::crypto::Certificate>& peer,
      59             :                          const std::string& name,
      60             :                          std::shared_ptr<dhtnet::ChannelSocket> channel)
      61             :         = 0;
      62             : };
      63             : 
      64             : } // namespace jami

Generated by: LCOV version 1.14