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-12-21 08:56:24 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        3390 :     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             :      * @param connectionType  The connection type used by iOS notifications (not used)
      41             :      * @param forceNewConnection  If we want a new SIP connection (not used)
      42             :      */
      43             :     virtual void connect(const DeviceId& deviceId,
      44             :                          const std::string& name,
      45             :                          ConnectCb&& cb,
      46             :                          const std::string& connectionType = "",
      47             :                          bool forceNewConnection = false)
      48             :         = 0;
      49             : 
      50             :     /**
      51             :      * Determine if we accept or not the request. Called when ConnectionManager receives a request
      52             :      * @param peer          Peer who asked
      53             :      * @param name          The name of the channel
      54             :      * @return if we accept or not
      55             :      */
      56             :     virtual bool onRequest(const std::shared_ptr<dht::crypto::Certificate>& peer,
      57             :                            const std::string& name)
      58             :         = 0;
      59             : 
      60             :     /**
      61             :      * Called when ConnectionManager has a new channel ready
      62             :      * @param peer          Connected peer
      63             :      * @param name          The name of the channel
      64             :      * @param channel       Channel to handle
      65             :      */
      66             :     virtual void onReady(const std::shared_ptr<dht::crypto::Certificate>& peer,
      67             :                          const std::string& name,
      68             :                          std::shared_ptr<dhtnet::ChannelSocket> channel)
      69             :         = 0;
      70             : };
      71             : 
      72             : } // namespace jami

Generated by: LCOV version 1.14