Skip to content
Snippets Groups Projects
Select Git revision
  • eb0fb2bdc282883e07f712a27a533bbdfa8fa4c3
  • master default protected
  • release/202005
  • release/202001
  • release/201912
  • release/201911
  • release/releaseWindowsTestOne
  • release/windowsReleaseTest
  • release/releaseTest
  • release/releaseWindowsTest
  • release/201910
  • release/qt/201910
  • release/windows-test/201910
  • release/201908
  • release/201906
  • release/201905
  • release/201904
  • release/201903
  • release/201902
  • release/201901
  • release/201812
  • 4.0.0
  • 2.2.0
  • 2.1.0
  • 2.0.1
  • 2.0.0
  • 1.4.1
  • 1.4.0
  • 1.3.0
  • 1.2.0
  • 1.1.0
31 results

multiplexed_socket.cpp

Blame
    • Sébastien Blin's avatar
      eb0fb2bd
      ConnectionManager: first version · eb0fb2bd
      Sébastien Blin authored
      This patch introduces the first version for the first layer of group chat, the
      ConnectionManager.
      
      This class provides an API to get a channel socket between two devices. Behind
      that API, channel sockets are working on top of a MultiplexedSocket, working
      on top of a TLS Socket.
      
      So, if an user want a socket, they just have to call connectDevice. The manager
      will contact the other device through the DHT, negotiate (via the ICE protocol)
      a socket, start a TLS session and then open a new channel. Channel 0 is used as
      a control channel (to get channel requests and answer). Other channels are for
      the user.
      
      When a TLS packet is sent, the format is usually:
      | 16 bits = len of the content | 16 bits = channel | content... |
      
      Scenarios are described in the unitTest linked to that patch.
      
      Finally, each Jami accounts has its own ConnectionManager.
      
      Change-Id: I9cdd681e91ca71f24338e728fc382349393c6912
      eb0fb2bd
      History
      ConnectionManager: first version
      Sébastien Blin authored
      This patch introduces the first version for the first layer of group chat, the
      ConnectionManager.
      
      This class provides an API to get a channel socket between two devices. Behind
      that API, channel sockets are working on top of a MultiplexedSocket, working
      on top of a TLS Socket.
      
      So, if an user want a socket, they just have to call connectDevice. The manager
      will contact the other device through the DHT, negotiate (via the ICE protocol)
      a socket, start a TLS session and then open a new channel. Channel 0 is used as
      a control channel (to get channel requests and answer). Other channels are for
      the user.
      
      When a TLS packet is sent, the format is usually:
      | 16 bits = len of the content | 16 bits = channel | content... |
      
      Scenarios are described in the unitTest linked to that patch.
      
      Finally, each Jami accounts has its own ConnectionManager.
      
      Change-Id: I9cdd681e91ca71f24338e728fc382349393c6912
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    videocodeclistmodel.cpp 3.39 KiB
    /*
     * Copyright (C) 2019-2020 by Savoir-faire Linux
     * Author: Yang Wang   <yang.wang@savoirfairelinux.com>
     *
     * This program is free software; you can redistribute it and/or modify
     * it under the terms of the GNU General Public License as published by
     * the Free Software Foundation; either version 3 of the License, or
     * (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License
     * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     */
    
    #include "videocodeclistmodel.h"
    
    #include <QList>
    
    VideoCodecListModel::VideoCodecListModel(QObject *parent)
        : QAbstractListModel(parent)
    {}
    
    VideoCodecListModel::~VideoCodecListModel() {}
    
    int
    VideoCodecListModel::rowCount(const QModelIndex &parent) const
    {
        if (!parent.isValid()) {
            /*
             * Count.
             */
            QList<lrc::api::Codec> realCodecList;
            auto videoCodecListOld = LRCInstance::getCurrentAccountInfo().codecModel->getVideoCodecs();
    
            for (auto codec : videoCodecListOld) {
                if (codec.name.length()) {
                    realCodecList.append(codec);
                }
            }
    
            return realCodecList.size();
        }
        /*
         * A valid QModelIndex returns 0 as no entry has sub-elements.
         */
        return 0;
    }
    
    int
    VideoCodecListModel::columnCount(const QModelIndex &parent) const
    {
        Q_UNUSED(parent);
        /*
         * Only need one column.
         */
        return 1;
    }
    
    QVariant
    VideoCodecListModel::data(const QModelIndex &index, int role) const
    {
        auto videoCodecList = LRCInstance::getCurrentAccountInfo().codecModel->getVideoCodecs();
        if (!index.isValid() || videoCodecList.size() <= index.row()) {
            return QVariant();
        }
    
        QList<lrc::api::Codec> realCodecList;
    
        for (auto codec : videoCodecList) {
            if (codec.name.length()) {
                realCodecList.append(codec);
            }
        }
    
        switch (role) {
        case Role::VideoCodecName:
            return QVariant(realCodecList.at(index.row()).name);
        case Role::IsEnabled:
            return QVariant(realCodecList.at(index.row()).enabled);
        case Role::VideoCodecID:
            return QVariant(realCodecList.at(index.row()).id);
        }
        return QVariant();
    }
    
    QHash<int, QByteArray>
    VideoCodecListModel::roleNames() const
    {
        QHash<int, QByteArray> roles;
        roles[VideoCodecName] = "VideoCodecName";
        roles[IsEnabled] = "IsEnabled";
        roles[VideoCodecID] = "VideoCodecID";
        return roles;
    }
    
    QModelIndex
    VideoCodecListModel::index(int row, int column, const QModelIndex &parent) const
    {
        Q_UNUSED(parent);
        if (column != 0) {
            return QModelIndex();
        }
    
        if (row >= 0 && row < rowCount()) {
            return createIndex(row, column);
        }
        return QModelIndex();
    }
    
    QModelIndex
    VideoCodecListModel::parent(const QModelIndex &child) const
    {
        Q_UNUSED(child);
        return QModelIndex();
    }
    
    Qt::ItemFlags
    VideoCodecListModel::flags(const QModelIndex &index) const
    {
        auto flags = QAbstractItemModel::flags(index) | Qt::ItemNeverHasChildren | Qt::ItemIsSelectable
                     | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled;
        if (!index.isValid()) {
            return QAbstractItemModel::flags(index);
        }
        return flags;
    }