#include "clientglobals.h"
#include <QAudioOutput>
#include <QAudioFormat>

ClientGlobals::RfbEncoding ClientGlobals::mapRfbEncoding( const QString &name )
{
    if ( name.compare( "RAW", Qt::CaseInsensitive ) == 0 )
        return Raw;
    if ( name.compare( "ZLIB", Qt::CaseInsensitive ) == 0 )
        return Zlib;
    if ( name.compare( "HEXTILE",Qt::CaseInsensitive ) == 0 )
        return Hextile;
    return EncodingInvalid;
}

ClientGlobals::AuthType ClientGlobals::mapAuthType( const QString &name )
{
    if ( name.compare( "NONE",Qt::CaseInsensitive ) == 0 )
        return None;
    if ( name.compare( "VNC",Qt::CaseInsensitive ) == 0 )
        return VNC;
    if ( name.compare( "TLS",Qt::CaseInsensitive ) == 0 )
        return TLS;
    if ( name.compare( "VENCRYPT",Qt::CaseInsensitive ) == 0 )
        return VenCrypt;
    if ( name.compare( "SASL",Qt::CaseInsensitive ) == 0 )
        return SASL;
    return AuthInvalid;
}

ClientGlobals::SubAuthType ClientGlobals::mapAuthSubType( const QString &name )
{
    if ( name.compare( "Plain",Qt::CaseInsensitive ) == 0 )
        return Plain;
    if ( name.compare( "TLSNone",Qt::CaseInsensitive ) == 0 )
        return TLSNone;
    if ( name.compare( "TLSVNC",Qt::CaseInsensitive ) == 0 )
        return TLSVNC;
    if ( name.compare( "TLSPlain",Qt::CaseInsensitive ) == 0 )
        return TLSPlain;
    if ( name.compare( "X509None",Qt::CaseInsensitive ) == 0 )
        return X509None;
    if ( name.compare( "X509VNC",Qt::CaseInsensitive ) == 0 )
        return X509VNC;
    if ( name.compare( "X509Plain",Qt::CaseInsensitive ) == 0 )
        return X509Plain;
    return SubTypeInvalid;
}

quint8 ClientGlobals::mapQtAudioFormatToRFB( const QAudioFormat &format )
{
    if( format.sampleSize() == 8 && format.sampleType() == QAudioFormat::UnSignedInt )
        return 0x00;
    if( format.sampleSize() == 8 && format.sampleType() == QAudioFormat::SignedInt )
        return 0x01;
    if( format.sampleSize() == 16 && format.sampleType() == QAudioFormat::UnSignedInt )
        return 0x02;
    if( format.sampleSize() == 16 && format.sampleType() == QAudioFormat::SignedInt )
        return 0x03;
    if( format.sampleSize() == 32 && format.sampleType() == QAudioFormat::UnSignedInt )
        return 0x04;
    if( format.sampleSize() == 32 && format.sampleType() == QAudioFormat::SignedInt )
        return 0x05;
    return 0x06;
}

