// solves a compile problem on recent Ubuntu
#endif
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* Definitions ****************************************************************/
// define this macro to get debug output
//#define _DEBUG_
#undef _DEBUG_
// version and application name (use version from qt prject file)
#undef VERSION
#define VERSION APP_VERSION
#define APP_NAME "Jamulus"
// Windows registry key name of auto run entry for the server
#define AUTORUN_SERVER_REG_NAME "Jamulus server"
// default names of the ini-file for client and server
#define DEFAULT_INI_FILE_NAME "Jamulus.ini"
#define DEFAULT_INI_FILE_NAME_SERVER "Jamulusserver.ini"
// file name for logging file
#define DEFAULT_LOG_FILE_NAME "Jamulussrvlog.txt"
// System block size, this is the block size on which the audio coder works.
// All other block sizes must be a multiple of this size.
// Note that the UpdateAutoSetting() function assumes a value of 128.
#define SYSTEM_FRAME_SIZE_SAMPLES 64
#define DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES ( 2 * SYSTEM_FRAME_SIZE_SAMPLES )
// additional buffer for delay panning
#define MAX_DELAY_PANNING_SAMPLES 64
// default server address and port numbers
#define DEFAULT_QOS_NUMBER 128 // CS4 (Quality of Service)
#define DEFAULT_SERVER_ADDRESS "anygenre1.jamulus.io"
#define DEFAULT_PORT_NUMBER 22124
#define CENTSERV_ANY_GENRE2 "anygenre2.jamulus.io:22224"
#define CENTSERV_ANY_GENRE3 "anygenre3.jamulus.io:22624"
#define CENTSERV_GENRE_ROCK "rock.jamulus.io:22424"
#define CENTSERV_GENRE_JAZZ "jazz.jamulus.io:22324"
#define CENTSERV_GENRE_CLASSICAL_FOLK "classical.jamulus.io:22524"
#define CENTSERV_GENRE_CHORAL "choral.jamulus.io:22724"
// specify an invalid port to disable the server
#define INVALID_PORT -1
// servers to check for new versions
#define UPDATECHECK1_ADDRESS "updatecheck1.jamulus.io"
#define UPDATECHECK2_ADDRESS "updatecheck2.jamulus.io"
// getting started and software manual URL
#define CLIENT_GETTING_STARTED_URL "https://jamulus.io/wiki/Getting-Started"
#define SERVER_GETTING_STARTED_URL "https://jamulus.io/wiki/Running-a-Server"
#define SOFTWARE_MANUAL_URL "https://jamulus.io/wiki/Software-Manual"
// app update message
#define APP_UPGRADE_AVAILABLE_MSG_TEXT \
QCoreApplication::translate ( \
"global", \
"A %1 upgrade is available: go to details and downloads" )
// determining server internal address uses well-known host and port
// We just need a valid, public Internet IP here. We will not send any
// traffic there as we will only set up an UDP socket without sending any
// data.
#define WELL_KNOWN_HOST "1.1.1.1" // CloudFlare
#define WELL_KNOWN_HOST6 "2606:4700:4700::1111" // CloudFlare
#define WELL_KNOWN_PORT DEFAULT_PORT_NUMBER
#define IP_LOOKUP_TIMEOUT 500 // ms
// system sample rate (the sound card and audio coder works on this sample rate)
#define SYSTEM_SAMPLE_RATE_HZ 48000 // Hz
// define the allowed audio frame size factors (since the
// "SYSTEM_FRAME_SIZE_SAMPLES" is quite small, it may be that on some
// computers a larger value is required)
#define FRAME_SIZE_FACTOR_PREFERRED 1 // 64 samples accumulated frame size
#define FRAME_SIZE_FACTOR_DEFAULT 2 // 128 samples accumulated frame size
#define FRAME_SIZE_FACTOR_SAFE 4 // 256 samples accumulated frame size
// define the minimum allowed number of coded bytes for CELT (the encoder
// gets in trouble if the value is too low)
#define CELT_MINIMUM_NUM_BYTES 10
// Maximum block size for network input buffer. It is defined by the longest
// protocol message which is PROTMESSID_CLM_SERVER_LIST: Worst case:
// (2+2+1+2+2)+200*(4+2+2+1+1+2+20+2+32+2+20)=17609
// We add some headroom to that value.
#define MAX_SIZE_BYTES_NETW_BUF 20000
// minimum/maximum network buffer size (which can be chosen by slider)
#define MIN_NET_BUF_SIZE_NUM_BL 1 // number of blocks
#define MAX_NET_BUF_SIZE_NUM_BL 20 // number of blocks
#define AUTO_NET_BUF_SIZE_FOR_PROTOCOL ( MAX_NET_BUF_SIZE_NUM_BL + 1 ) // auto set parameter (only used for protocol)
// default network buffer size
#define DEF_NET_BUF_SIZE_NUM_BL 10 // number of blocks
// audio mixer fader and panning maximum value
#define AUD_MIX_FADER_MAX 100
#define AUD_MIX_PAN_MAX 100
// range of audio mixer fader
#define AUD_MIX_FADER_RANGE_DB 35.0f
// coefficient for averaging channel levels for automatic fader adjustment
#define AUTO_FADER_ADJUST_ALPHA 0.2f
// target level for auto fader adjustment in decibels
#define AUTO_FADER_TARGET_LEVEL_DB -30.0f
// threshold in decibels below which the channel is considered as noise
// and not adjusted
#define AUTO_FADER_NOISE_THRESHOLD_DB -40.0f
// maximum number of fader groups (must be consistent to audiomixerboard implementation)
#define MAX_NUM_FADER_GROUPS 8
// maximum number of recognized sound cards installed in the system
#define MAX_NUMBER_SOUND_CARDS 129 // e.g. 16 inputs, 8 outputs + default entry (MacOS)
// define the maximum number of audio channel for input/output we can store
// channel infos for (and therefore this is the maximum number of entries in
// the channel selection combo box regardless of the actual available number
// of channels by the audio device)
#define MAX_NUM_IN_OUT_CHANNELS 64
// maximum number of elemts in the server address combo box
#define MAX_NUM_SERVER_ADDR_ITEMS 12
// maximum number of fader settings to be stored (together with the fader tags)
#define MAX_NUM_STORED_FADER_SETTINGS 250
// range for signal level meter
#define LOW_BOUND_SIG_METER ( -50.0 ) // dB
#define UPPER_BOUND_SIG_METER ( 0.0 ) // dB
// defines for LED level meter CLevelMeter
#define NUM_STEPS_LED_BAR 8
#define RED_BOUND_LED_BAR 7
#define YELLOW_BOUND_LED_BAR 5
// maximum number of connected clients at the server (must not be larger than 256)
#define MAX_NUM_CHANNELS 150 // max number channels for server
// actual number of used channels in the server
// this parameter can safely be changed from 1 to MAX_NUM_CHANNELS
// without any other changes in the code
#define DEFAULT_USED_NUM_CHANNELS 10 // default used number channels for server
// Maximum number of servers registered in the server list. If you want to
// change this parameter, you most probably have to adjust MAX_SIZE_BYTES_NETW_BUF.
#define MAX_NUM_SERVERS_IN_SERVER_LIST 150 // reduced to 150 because we now have genre-based server lists
// defines the time interval at which the ping time is updated in the GUI
#define PING_UPDATE_TIME_MS 500 // ms
// defines the time interval at which the ping time is updated for the server list
#define PING_UPDATE_TIME_SERVER_LIST_MS 2500 // ms
// defines the interval between Channel Level updates from the server
#define CHANNEL_LEVEL_UPDATE_INTERVAL 200 // number of frames at 64 samples frame size
// time-out until a registered server is deleted from the server list if no
// new registering was made in minutes
#define SERVLIST_TIME_OUT_MINUTES 33 // minutes (should include 3 UDP registration messages)
// poll time for server list (to check if entries are time-out)
#define SERVLIST_POLL_TIME_MINUTES 1 // minute
// time interval for sending ping messages to servers in the server list
#define SERVLIST_UPDATE_PING_SERVERS_MS 59000 // ms
// time between server registration refreshes
#define SERVLIST_REGIST_INTERV_MINUTES 15 // minutes
// defines the minimum time a server must run to be a permanent server
#define SERVLIST_TIME_PERMSERV_MINUTES 2880 // minutes, 2880 = 60 min * 24 h * 2 d
// registration response timeout
#define REGISTER_SERVER_TIME_OUT_MS 500 // ms
// defines the maximum number of times to retry server registration
// when no response is received within the timeout (before reverting
// to SERVLIST_REGIST_INTERV_MINUTES)
#define REGISTER_SERVER_RETRY_LIMIT 5 // count
// Maximum length of fader tag and text message strings (Since for chat messages
// some HTML code is added, we also have to define a second length which includes
// this additionl HTML code. Right now the length of the HTML code is approx. 66
// characters. Here, we add some headroom to this number)
#define MAX_LEN_FADER_TAG 16
#define MAX_LEN_CHAT_TEXT 1600
#define MAX_LEN_CHAT_TEXT_PLUS_HTML 1800
#define MAX_LEN_SERVER_NAME 20
#define MAX_LEN_IP_ADDRESS 15
#define MAX_LEN_SERVER_CITY 20
#define MAX_LEN_VERSION_TEXT 30
// define Settings tab indexes
#define SETTING_TAB_USER 0
#define SETTING_TAB_AUDIONET 1
#define SETTING_TAB_ADVANCED 2
// common tool tip bottom line text
#define TOOLTIP_COM_END_TEXT \
"
" + \
QCoreApplication::translate ( "global", \
"For more information use the \"What's " \
"This\" help (help menu, right mouse button or Shift+F1)" ) + \
"
"
// server welcome message title (do not change for compatibility!)
#define WELCOME_MESSAGE_PREFIX "Server Welcome Message: "
// mixer settings file name suffix
#define MIX_SETTINGS_FILE_SUFFIX "jch"
// minimum length of JSON-RPC secret string (main.cpp)
#define JSON_RPC_MINIMUM_SECRET_LENGTH 16
// JSON-RPC listen address
#define JSON_RPC_LISTEN_ADDRESS "127.0.0.1"
#define _MAXSHORT 32767
#define _MINSHORT ( -32768 )
#define INVALID_INDEX -1 // define invalid index as a negative value (a valid index must always be >= 0)
#if HAVE_STDINT_H
# include
#elif HAVE_INTTYPES_H
# include
#elif defined( _WIN32 )
typedef __int64 int64_t;
typedef __int32 int32_t;
typedef __int16 int16_t;
typedef unsigned __int64 uint64_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int8 uint8_t;
#elif defined( ANDROID )
// don't redfine types for android as these ones below don't work
#else
typedef long long int64_t;
typedef int int32_t;
typedef short int16_t;
typedef unsigned long long uint64_t;
typedef unsigned int uint32_t;
typedef unsigned short uint16_t;
typedef unsigned char uint8_t;
#endif
/* Pseudo enum definitions -------------------------------------------------- */
// definition for custom event
#define MS_PACKET_RECEIVED 0
/* Classes ********************************************************************/
class CGenErr
{
public:
CGenErr ( QString strNewErrorMsg, QString strNewErrorType = "" ) : strErrorMsg ( strNewErrorMsg ), strErrorType ( strNewErrorType ) {}
QString GetErrorText() const
{
// return formatted error text
if ( strErrorType.isEmpty() )
{
return strErrorMsg;
}
else
{
return strErrorType + ": " + strErrorMsg;
}
}
protected:
QString strErrorMsg;
QString strErrorType;
};
class CCustomEvent : public QEvent
{
public:
CCustomEvent ( int iNewMeTy, int iNewSt, int iNewChN = 0 ) :
QEvent ( QEvent::Type ( QEvent::User + 11 ) ),
iMessType ( iNewMeTy ),
iStatus ( iNewSt ),
iChanNum ( iNewChN )
{}
int iMessType;
int iStatus;
int iChanNum;
};
/* Prototypes for global functions ********************************************/
// command line parsing, TODO do not declare functions globally but in a class
QString UsageArguments ( char** argv );
bool GetFlagArgument ( char** argv, int& i, QString strShortOpt, QString strLongOpt );
bool GetStringArgument ( int argc, char** argv, int& i, QString strShortOpt, QString strLongOpt, QString& strArg );
bool GetNumericArgument ( int argc,
char** argv,
int& i,
QString strShortOpt,
QString strLongOpt,
double rRangeStart,
double rRangeStop,
double& rValue );
jamulus-3.9.1+dfsg/src/clientrpc.cpp 0000644 0001750 0001750 00000027360 14340334543 016442 0 ustar vimer vimer /******************************************************************************\
* Copyright (c) 2021-2022
*
* Author(s):
* dtinth
* Christian Hoffmann
*
******************************************************************************
*
* 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 2 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, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
\******************************************************************************/
#include "clientrpc.h"
CClientRpc::CClientRpc ( CClient* pClient, CRpcServer* pRpcServer, QObject* parent ) : QObject ( parent )
{
/// @rpc_notification jamulusclient/chatTextReceived
/// @brief Emitted when a chat text is received.
/// @param {string} params.chatText - The chat text.
connect ( pClient, &CClient::ChatTextReceived, [=] ( QString strChatText ) {
pRpcServer->BroadcastNotification ( "jamulusclient/chatTextReceived",
QJsonObject{
{ "chatText", strChatText },
} );
} );
/// @rpc_notification jamulusclient/connected
/// @brief Emitted when the client is connected to the server.
/// @param {number} params.id - The channel ID assigned to the client.
connect ( pClient, &CClient::ClientIDReceived, [=] ( int iChanID ) {
pRpcServer->BroadcastNotification ( "jamulusclient/connected",
QJsonObject{
{ "id", iChanID },
} );
} );
/// @rpc_notification jamulusclient/clientListReceived
/// @brief Emitted when the client list is received.
/// @param {array} params.clients - The client list.
/// @param {number} params.clients[*].id - The channel ID.
/// @param {string} params.clients[*].name - The musician’s name.
/// @param {string} params.clients[*].skillLevel - The musician’s skill level (beginner, intermediate, expert, or null).
/// @param {number} params.clients[*].countryId - The musician’s country ID (see QLocale::Country).
/// @param {string} params.clients[*].city - The musician’s city.
/// @param {number} params.clients[*].instrumentId - The musician’s instrument ID (see CInstPictures::GetTable).
connect ( pClient, &CClient::ConClientListMesReceived, [=] ( CVector vecChanInfo ) {
QJsonArray arrChanInfo;
for ( const auto& chanInfo : vecChanInfo )
{
QJsonObject objChanInfo{
{ "id", chanInfo.iChanID },
{ "name", chanInfo.strName },
{ "skillLevel", SerializeSkillLevel ( chanInfo.eSkillLevel ) },
{ "countryId", chanInfo.eCountry },
{ "city", chanInfo.strCity },
{ "instrumentId", chanInfo.iInstrument },
};
arrChanInfo.append ( objChanInfo );
}
pRpcServer->BroadcastNotification ( "jamulusclient/clientListReceived",
QJsonObject{
{ "clients", arrChanInfo },
} );
arrStoredChanInfo = arrChanInfo;
} );
/// @rpc_notification jamulusclient/channelLevelListReceived
/// @brief Emitted when the channel level list is received.
/// @param {array} params.channelLevelList - The channel level list.
/// Each item corresponds to the respective client retrieved from the jamulusclient/clientListReceived notification.
/// @param {number} params.channelLevelList[*] - The channel level, an integer between 0 and 9.
connect ( pClient, &CClient::CLChannelLevelListReceived, [=] ( CHostAddress /* unused */, CVector vecLevelList ) {
QJsonArray arrLevelList;
for ( const auto& level : vecLevelList )
{
arrLevelList.append ( level );
}
pRpcServer->BroadcastNotification ( "jamulusclient/channelLevelListReceived",
QJsonObject{
{ "channelLevelList", arrLevelList },
} );
} );
/// @rpc_notification jamulusclient/disconnected
/// @brief Emitted when the client is disconnected from the server.
/// @param {object} params - No parameters (empty object).
connect ( pClient, &CClient::Disconnected, [=]() { pRpcServer->BroadcastNotification ( "jamulusclient/disconnected", QJsonObject{} ); } );
/// @rpc_method jamulus/getMode
/// @brief Returns the current mode, i.e. whether Jamulus is running as a server or client.
/// @param {object} params - No parameters (empty object).
/// @result {string} result.mode - The current mode (server or client).
pRpcServer->HandleMethod ( "jamulus/getMode", [=] ( const QJsonObject& params, QJsonObject& response ) {
QJsonObject result{ { "mode", "client" } };
response["result"] = result;
Q_UNUSED ( params );
} );
/// @rpc_method jamulusclient/getClientInfo
/// @brief Returns the client information.
/// @param {object} params - No parameters (empty object).
/// @result {boolean} result.connected - Whether the client is connected to the server.
pRpcServer->HandleMethod ( "jamulusclient/getClientInfo", [=] ( const QJsonObject& params, QJsonObject& response ) {
QJsonObject result{ { "connected", pClient->IsConnected() } };
response["result"] = result;
Q_UNUSED ( params );
} );
/// @rpc_method jamulusclient/getChannelInfo
/// @brief Returns the client's profile information.
/// @param {object} params - No parameters (empty object).
/// @result {number} result.id - The channel ID.
/// @result {string} result.name - The musician’s name.
/// @result {string} result.skillLevel - The musician’s skill level (beginner, intermediate, expert, or null).
/// @result {number} result.countryId - The musician’s country ID (see QLocale::Country).
/// @result {string} result.city - The musician’s city.
/// @result {number} result.instrumentId - The musician’s instrument ID (see CInstPictures::GetTable).
/// @result {string} result.skillLevel - Your skill level (beginner, intermediate, expert, or null).
pRpcServer->HandleMethod ( "jamulusclient/getChannelInfo", [=] ( const QJsonObject& params, QJsonObject& response ) {
QJsonObject result{
// TODO: We cannot include "id" here is pClient->ChannelInfo is a CChannelCoreInfo which lacks that field.
{ "name", pClient->ChannelInfo.strName },
{ "countryId", pClient->ChannelInfo.eCountry },
{ "city", pClient->ChannelInfo.strCity },
{ "instrumentId", pClient->ChannelInfo.iInstrument },
{ "skillLevel", SerializeSkillLevel ( pClient->ChannelInfo.eSkillLevel ) },
};
response["result"] = result;
Q_UNUSED ( params );
} );
/// @rpc_method jamulusclient/getClientList
/// @brief Returns the client list.
/// @param {object} params - No parameters (empty object).
/// @result {array} result.clients - The client list. See jamulusclient/clientListReceived for the format.
pRpcServer->HandleMethod ( "jamulusclient/getClientList", [=] ( const QJsonObject& params, QJsonObject& response ) {
if ( !pClient->IsConnected() )
{
response["error"] = CRpcServer::CreateJsonRpcError ( 1, "Client is not connected" );
return;
}
QJsonObject result{
{ "clients", arrStoredChanInfo },
};
response["result"] = result;
Q_UNUSED ( params );
} );
/// @rpc_method jamulusclient/setName
/// @brief Sets your name.
/// @param {string} params.name - The new name.
/// @result {string} result - Always "ok".
pRpcServer->HandleMethod ( "jamulusclient/setName", [=] ( const QJsonObject& params, QJsonObject& response ) {
auto jsonName = params["name"];
if ( !jsonName.isString() )
{
response["error"] = CRpcServer::CreateJsonRpcError ( CRpcServer::iErrInvalidParams, "Invalid params: name is not a string" );
return;
}
pClient->ChannelInfo.strName = TruncateString ( jsonName.toString(), MAX_LEN_FADER_TAG );
pClient->SetRemoteInfo();
response["result"] = "ok";
} );
/// @rpc_method jamulusclient/setSkillLevel
/// @brief Sets your skill level.
/// @param {string} params.skillLevel - The new skill level (beginner, intermediate, expert, or null).
/// @result {string} result - Always "ok".
pRpcServer->HandleMethod ( "jamulusclient/setSkillLevel", [=] ( const QJsonObject& params, QJsonObject& response ) {
auto jsonSkillLevel = params["skillLevel"];
if ( jsonSkillLevel.isNull() )
{
pClient->ChannelInfo.eSkillLevel = SL_NOT_SET;
pClient->SetRemoteInfo();
return;
}
if ( !jsonSkillLevel.isString() )
{
response["error"] = CRpcServer::CreateJsonRpcError ( CRpcServer::iErrInvalidParams, "Invalid params: skillLevel is not a string" );
return;
}
auto strSkillLevel = jsonSkillLevel.toString();
if ( strSkillLevel == "beginner" )
{
pClient->ChannelInfo.eSkillLevel = SL_BEGINNER;
}
else if ( strSkillLevel == "intermediate" )
{
pClient->ChannelInfo.eSkillLevel = SL_INTERMEDIATE;
}
else if ( strSkillLevel == "expert" )
{
pClient->ChannelInfo.eSkillLevel = SL_PROFESSIONAL;
}
else
{
response["error"] = CRpcServer::CreateJsonRpcError ( CRpcServer::iErrInvalidParams,
"Invalid params: skillLevel is not beginner, intermediate or expert" );
return;
}
pClient->SetRemoteInfo();
response["result"] = "ok";
} );
/// @rpc_method jamulusclient/sendChatText
/// @brief Sends a chat text message.
/// @param {string} params.chatText - The chat text message.
/// @result {string} result - Always "ok".
pRpcServer->HandleMethod ( "jamulusclient/sendChatText", [=] ( const QJsonObject& params, QJsonObject& response ) {
auto jsonMessage = params["chatText"];
if ( !jsonMessage.isString() )
{
response["error"] = CRpcServer::CreateJsonRpcError ( CRpcServer::iErrInvalidParams, "Invalid params: chatText is not a string" );
return;
}
if ( !pClient->IsConnected() )
{
response["error"] = CRpcServer::CreateJsonRpcError ( 1, "Client is not connected" );
return;
}
pClient->CreateChatTextMes ( jsonMessage.toString() );
response["result"] = "ok";
} );
}
QJsonValue CClientRpc::SerializeSkillLevel ( ESkillLevel eSkillLevel )
{
switch ( eSkillLevel )
{
case SL_BEGINNER:
return QJsonValue ( "beginner" );
case SL_INTERMEDIATE:
return QJsonValue ( "intermediate" );
case SL_PROFESSIONAL:
return QJsonValue ( "expert" );
default:
return QJsonValue ( QJsonValue::Null );
}
}
jamulus-3.9.1+dfsg/src/multicolorled.cpp 0000644 0001750 0001750 00000011065 14340334543 017330 0 ustar vimer vimer /******************************************************************************\
* Copyright (c) 2004-2022
*
* Author(s):
* Volker Fischer
*
* Description:
* Implements a multi color LED
*
******************************************************************************
*
* 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 2 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, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
\******************************************************************************/
#include "multicolorled.h"
/* Implementation *************************************************************/
CMultiColorLED::CMultiColorLED ( QWidget* parent ) :
QLabel ( parent ),
BitmCubeDisabled ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDDisabled.png" ) ),
BitmCubeGrey ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGrey.png" ) ),
BitmCubeGreen ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreenBig.png" ) ),
BitmCubeYellow ( QString::fromUtf8 ( ":/png/LEDs/res/IndicatorYellowFancy.png" ) ),
BitmCubeRed ( QString::fromUtf8 ( ":/png/LEDs/res/IndicatorRedFancy.png" ) ),
BitmIndicatorGreen ( QString::fromUtf8 ( ":/png/LEDs/res/IndicatorGreen.png" ) ),
BitmIndicatorYellow ( QString::fromUtf8 ( ":/png/LEDs/res/IndicatorYellow.png" ) ),
BitmIndicatorRed ( QString::fromUtf8 ( ":/png/LEDs/res/IndicatorRed.png" ) )
{
// set init bitmap
setPixmap ( BitmCubeGrey );
eColorFlag = RL_GREY;
// set default type and reset
eType = MT_LED;
Reset();
}
void CMultiColorLED::SetType ( const EType eNType )
{
eType = eNType;
Reset();
}
void CMultiColorLED::changeEvent ( QEvent* curEvent )
{
// act on enabled changed state
if ( curEvent->type() == QEvent::EnabledChange )
{
if ( isEnabled() )
{
setPixmap ( BitmCubeGrey );
eColorFlag = RL_GREY;
}
else
{
setPixmap ( BitmCubeDisabled );
eColorFlag = RL_DISABLED;
}
}
}
void CMultiColorLED::SetColor ( const ELightColor eNewColorFlag )
{
switch ( eNewColorFlag )
{
case RL_RED:
// red
if ( eColorFlag != RL_RED )
{
if ( eType == MT_LED )
{
setPixmap ( BitmCubeRed );
}
else
{
setPixmap ( BitmIndicatorRed );
}
setAccessibleDescription ( tr ( "Red" ) );
eColorFlag = RL_RED;
}
break;
case RL_YELLOW:
// yellow
if ( eColorFlag != RL_YELLOW )
{
if ( eType == MT_LED )
{
setPixmap ( BitmCubeYellow );
}
else
{
setPixmap ( BitmIndicatorYellow );
}
setAccessibleDescription ( tr ( "Yellow" ) );
eColorFlag = RL_YELLOW;
}
break;
case RL_GREEN:
// green
if ( eColorFlag != RL_GREEN )
{
if ( eType == MT_LED )
{
setPixmap ( BitmCubeGreen );
}
else
{
setPixmap ( BitmIndicatorGreen );
}
setAccessibleDescription ( tr ( "Green" ) );
eColorFlag = RL_GREEN;
}
break;
default:
// if no color is active, set control to grey light
if ( eColorFlag != RL_GREY )
{
if ( eType == MT_LED )
{
setPixmap ( BitmCubeGrey );
}
else
{
// make it invisible if in indicator mode
setPixmap ( QPixmap() );
}
eColorFlag = RL_GREY;
}
break;
}
}
void CMultiColorLED::Reset()
{
if ( isEnabled() )
{
// set color flag to disable to make sure the pixmap gets updated
eColorFlag = RL_DISABLED;
SetColor ( RL_GREY );
}
}
void CMultiColorLED::SetLight ( const ELightColor eNewStatus )
{
if ( isEnabled() )
{
SetColor ( eNewStatus );
}
}
jamulus-3.9.1+dfsg/src/clientdlgbase.ui 0000644 0001750 0001750 00000055042 14340334543 017110 0 ustar vimer vimer
CClientDlgBase
0
0
511
490
true
:/png/main/res/fronticon.png:/png/main/res/fronticon.png
true
0
0
3
3
-