Beispiel #1
0
void TestServerInfo::removeUserChannel()
{
    ServerInfo server("localhost", 2040, 2);
    QString userFullName("anon@localhost");
    server.addUser(User(userFullName));

    QFETCH(quint8, channelsToAdd);
    QFETCH(quint8, channelsToRemove);

    //adding some channels
    for (quint8 channelIndex = 0; channelIndex < channelsToAdd; ++channelIndex) {
        QString channelName = "channel " + QString::number(channelIndex);
        server.addUserChannel(userFullName, UserChannel(channelName, channelIndex));
    }

    //removing channels and check
    for (quint8 channelIndex = 0; channelIndex < channelsToRemove; ++channelIndex) {
        UserChannel channel = server.getUser(userFullName).getChannel(channelIndex);
        if(channelsToRemove >= channelsToAdd){
            server.removeUserChannel(userFullName, channel);
            QVERIFY(!server.getUser(userFullName).hasChannel(channel.getIndex()));
        }
        else{
            QCOMPARE(channel.getName(), QString("invalid"));
        }
    }
}
Beispiel #2
0
void Server::updateUserChannel(const UserChannel &serverChannel)
{
    QString userFullName = serverChannel.getUserFullName();
    if(users.contains(userFullName)){
        users[userFullName].updateChannelName(serverChannel.getIndex(), serverChannel.getName());
    }
}
Beispiel #3
0
UserChannel::UserChannel(const UserChannel &c) :
    userFullName(c.getUserFullName()),
    channelName(c.getName()),
    active(c.isActive()),
    index(c.getIndex()),
    volume(c.volume),
    pan(c.pan),
    flags(c.flags)
{
}