fix unix2dos issue with some files
This commit is contained in:
parent
1e3543f603
commit
c0685e9b78
9 changed files with 4274 additions and 4274 deletions
446
src/client.h
446
src/client.h
|
@ -1,223 +1,223 @@
|
||||||
/******************************************************************************\
|
/******************************************************************************\
|
||||||
* Copyright (c) 2004-2009
|
* Copyright (c) 2004-2009
|
||||||
*
|
*
|
||||||
* Author(s):
|
* Author(s):
|
||||||
* Volker Fischer
|
* Volker Fischer
|
||||||
*
|
*
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under
|
* 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
|
* 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
|
* Foundation; either version 2 of the License, or (at your option) any later
|
||||||
* version.
|
* version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* 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
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
* details.
|
* details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along with
|
* 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.,
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
|
|
||||||
#if !defined ( CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_ )
|
#if !defined ( CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_ )
|
||||||
#define CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_
|
#define CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_
|
||||||
|
|
||||||
#include <qglobal.h>
|
#include <qglobal.h>
|
||||||
#include <qhostaddress.h>
|
#include <qhostaddress.h>
|
||||||
#include <qhostinfo.h>
|
#include <qhostinfo.h>
|
||||||
#include <qstring.h>
|
#include <qstring.h>
|
||||||
#include <qdatetime.h>
|
#include <qdatetime.h>
|
||||||
#include <qmessagebox.h>
|
#include <qmessagebox.h>
|
||||||
#include "celt.h"
|
#include "celt.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
#include "channel.h"
|
#include "channel.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# include "../windows/sound.h"
|
# include "../windows/sound.h"
|
||||||
#else
|
#else
|
||||||
# include "../linux/sound.h"
|
# include "../linux/sound.h"
|
||||||
# include <sched.h>
|
# include <sched.h>
|
||||||
# include <socket.h>
|
# include <socket.h>
|
||||||
# include <netdb.h>
|
# include <netdb.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Definitions ****************************************************************/
|
/* Definitions ****************************************************************/
|
||||||
// audio in fader range
|
// audio in fader range
|
||||||
#define AUD_FADER_IN_MIN 0
|
#define AUD_FADER_IN_MIN 0
|
||||||
#define AUD_FADER_IN_MAX 100
|
#define AUD_FADER_IN_MAX 100
|
||||||
#define AUD_FADER_IN_MIDDLE ( AUD_FADER_IN_MAX / 2 )
|
#define AUD_FADER_IN_MIDDLE ( AUD_FADER_IN_MAX / 2 )
|
||||||
|
|
||||||
// audio reverberation range
|
// audio reverberation range
|
||||||
#define AUD_REVERB_MAX 100
|
#define AUD_REVERB_MAX 100
|
||||||
|
|
||||||
// CELT number of coded bytes per audio packet
|
// CELT number of coded bytes per audio packet
|
||||||
// 24: low/normal quality 156 kbsp (128) / 114 kbps (256)
|
// 24: low/normal quality 156 kbsp (128) / 114 kbps (256)
|
||||||
// 44: high quality 216 kbps (128) / 174 kbps (256)
|
// 44: high quality 216 kbps (128) / 174 kbps (256)
|
||||||
#define CELT_NUM_BYTES_NORMAL_QUALITY 24
|
#define CELT_NUM_BYTES_NORMAL_QUALITY 24
|
||||||
#define CELT_NUM_BYTES_HIGH_QUALITY 44
|
#define CELT_NUM_BYTES_HIGH_QUALITY 44
|
||||||
|
|
||||||
|
|
||||||
/* Classes ********************************************************************/
|
/* Classes ********************************************************************/
|
||||||
class CClient : public QObject
|
class CClient : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CClient ( const quint16 iPortNumber );
|
CClient ( const quint16 iPortNumber );
|
||||||
virtual ~CClient() {}
|
virtual ~CClient() {}
|
||||||
|
|
||||||
void Start();
|
void Start();
|
||||||
void Stop();
|
void Stop();
|
||||||
bool IsRunning() { return Sound.IsRunning(); }
|
bool IsRunning() { return Sound.IsRunning(); }
|
||||||
bool SetServerAddr ( QString strNAddr );
|
bool SetServerAddr ( QString strNAddr );
|
||||||
double MicLevelL() { return SignalLevelMeter.MicLevelLeft(); }
|
double MicLevelL() { return SignalLevelMeter.MicLevelLeft(); }
|
||||||
double MicLevelR() { return SignalLevelMeter.MicLevelRight(); }
|
double MicLevelR() { return SignalLevelMeter.MicLevelRight(); }
|
||||||
bool IsConnected() { return Channel.IsConnected(); }
|
bool IsConnected() { return Channel.IsConnected(); }
|
||||||
|
|
||||||
double GetTimingStdDev() { return CycleTimeVariance.GetStdDev(); }
|
double GetTimingStdDev() { return CycleTimeVariance.GetStdDev(); }
|
||||||
|
|
||||||
bool GetOpenChatOnNewMessage() const { return bOpenChatOnNewMessage; }
|
bool GetOpenChatOnNewMessage() const { return bOpenChatOnNewMessage; }
|
||||||
void SetOpenChatOnNewMessage ( const bool bNV ) { bOpenChatOnNewMessage = bNV; }
|
void SetOpenChatOnNewMessage ( const bool bNV ) { bOpenChatOnNewMessage = bNV; }
|
||||||
|
|
||||||
EGUIDesign GetGUIDesign() const { return eGUIDesign; }
|
EGUIDesign GetGUIDesign() const { return eGUIDesign; }
|
||||||
void SetGUIDesign ( const EGUIDesign bNGD ) { eGUIDesign = bNGD; }
|
void SetGUIDesign ( const EGUIDesign bNGD ) { eGUIDesign = bNGD; }
|
||||||
|
|
||||||
bool GetCELTHighQuality() const { return bCeltDoHighQuality; }
|
bool GetCELTHighQuality() const { return bCeltDoHighQuality; }
|
||||||
void SetCELTHighQuality ( const bool bNCeltHighQualityFlag );
|
void SetCELTHighQuality ( const bool bNCeltHighQualityFlag );
|
||||||
|
|
||||||
int GetAudioInFader() const { return iAudioInFader; }
|
int GetAudioInFader() const { return iAudioInFader; }
|
||||||
void SetAudioInFader ( const int iNV ) { iAudioInFader = iNV; }
|
void SetAudioInFader ( const int iNV ) { iAudioInFader = iNV; }
|
||||||
|
|
||||||
int GetReverbLevel() const { return iReverbLevel; }
|
int GetReverbLevel() const { return iReverbLevel; }
|
||||||
void SetReverbLevel ( const int iNL ) { iReverbLevel = iNL; }
|
void SetReverbLevel ( const int iNL ) { iReverbLevel = iNL; }
|
||||||
|
|
||||||
bool IsReverbOnLeftChan() const { return bReverbOnLeftChan; }
|
bool IsReverbOnLeftChan() const { return bReverbOnLeftChan; }
|
||||||
void SetReverbOnLeftChan ( const bool bIL )
|
void SetReverbOnLeftChan ( const bool bIL )
|
||||||
{
|
{
|
||||||
bReverbOnLeftChan = bIL;
|
bReverbOnLeftChan = bIL;
|
||||||
AudioReverb.Clear();
|
AudioReverb.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetDoAutoSockBufSize ( const bool bValue ) { bDoAutoSockBufSize = bValue; }
|
void SetDoAutoSockBufSize ( const bool bValue ) { bDoAutoSockBufSize = bValue; }
|
||||||
bool GetDoAutoSockBufSize() const { return bDoAutoSockBufSize; }
|
bool GetDoAutoSockBufSize() const { return bDoAutoSockBufSize; }
|
||||||
void SetSockBufNumFrames ( const int iNumBlocks )
|
void SetSockBufNumFrames ( const int iNumBlocks )
|
||||||
{
|
{
|
||||||
// only change parameter if new parameter is different from current one
|
// only change parameter if new parameter is different from current one
|
||||||
if ( Channel.GetSockBufNumFrames() != iNumBlocks )
|
if ( Channel.GetSockBufNumFrames() != iNumBlocks )
|
||||||
{
|
{
|
||||||
// set the new socket size (number of frames)
|
// set the new socket size (number of frames)
|
||||||
if ( !Channel.SetSockBufNumFrames ( iNumBlocks ) )
|
if ( !Channel.SetSockBufNumFrames ( iNumBlocks ) )
|
||||||
{
|
{
|
||||||
// if setting of socket buffer size was successful,
|
// if setting of socket buffer size was successful,
|
||||||
// tell the server that size has changed
|
// tell the server that size has changed
|
||||||
Channel.CreateJitBufMes ( iNumBlocks );
|
Channel.CreateJitBufMes ( iNumBlocks );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int GetSockBufNumFrames() { return Channel.GetSockBufNumFrames(); }
|
int GetSockBufNumFrames() { return Channel.GetSockBufNumFrames(); }
|
||||||
|
|
||||||
int GetUploadRateKbps() { return Channel.GetUploadRateKbps(); }
|
int GetUploadRateKbps() { return Channel.GetUploadRateKbps(); }
|
||||||
|
|
||||||
int GetSndCrdNumDev() { return Sound.GetNumDev(); }
|
int GetSndCrdNumDev() { return Sound.GetNumDev(); }
|
||||||
std::string GetSndCrdDeviceName ( const int iDiD )
|
std::string GetSndCrdDeviceName ( const int iDiD )
|
||||||
{ return Sound.GetDeviceName ( iDiD ); }
|
{ return Sound.GetDeviceName ( iDiD ); }
|
||||||
|
|
||||||
QString SetSndCrdDev ( const int iNewDev );
|
QString SetSndCrdDev ( const int iNewDev );
|
||||||
int GetSndCrdDev() { return Sound.GetDev(); }
|
int GetSndCrdDev() { return Sound.GetDev(); }
|
||||||
void OpenSndCrdDriverSetup() { Sound.OpenDriverSetup(); }
|
void OpenSndCrdDriverSetup() { Sound.OpenDriverSetup(); }
|
||||||
|
|
||||||
void SetSndCrdPrefFrameSizeFactor ( const int iNewFactor );
|
void SetSndCrdPrefFrameSizeFactor ( const int iNewFactor );
|
||||||
int GetSndCrdPrefFrameSizeFactor()
|
int GetSndCrdPrefFrameSizeFactor()
|
||||||
{ return iSndCrdPrefFrameSizeFactor; }
|
{ return iSndCrdPrefFrameSizeFactor; }
|
||||||
int GetSndCrdActualMonoBlSize() { return iMonoBlockSizeSam; }
|
int GetSndCrdActualMonoBlSize() { return iMonoBlockSizeSam; }
|
||||||
|
|
||||||
void SetRemoteChanGain ( const int iId, const double dGain )
|
void SetRemoteChanGain ( const int iId, const double dGain )
|
||||||
{ Channel.SetRemoteChanGain ( iId, dGain ); }
|
{ Channel.SetRemoteChanGain ( iId, dGain ); }
|
||||||
|
|
||||||
void SetRemoteName() { Channel.SetRemoteName ( strName ); }
|
void SetRemoteName() { Channel.SetRemoteName ( strName ); }
|
||||||
|
|
||||||
void SendTextMess ( const QString& strChatText )
|
void SendTextMess ( const QString& strChatText )
|
||||||
{ Channel.CreateChatTextMes ( strChatText ); }
|
{ Channel.CreateChatTextMes ( strChatText ); }
|
||||||
|
|
||||||
void SendPingMess()
|
void SendPingMess()
|
||||||
{ Channel.CreatePingMes ( PreciseTime.elapsed() ); };
|
{ Channel.CreatePingMes ( PreciseTime.elapsed() ); };
|
||||||
|
|
||||||
CChannel* GetChannel() { return &Channel; }
|
CChannel* GetChannel() { return &Channel; }
|
||||||
|
|
||||||
|
|
||||||
// settings
|
// settings
|
||||||
CVector<QString> vstrIPAddress;
|
CVector<QString> vstrIPAddress;
|
||||||
QString strName;
|
QString strName;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// callback function must be static, otherwise it does not work
|
// callback function must be static, otherwise it does not work
|
||||||
static void AudioCallback ( CVector<short>& psData, void* arg );
|
static void AudioCallback ( CVector<short>& psData, void* arg );
|
||||||
|
|
||||||
bool Init();
|
bool Init();
|
||||||
void ProcessAudioData ( CVector<short>& vecsStereoSndCrd );
|
void ProcessAudioData ( CVector<short>& vecsStereoSndCrd );
|
||||||
void UpdateSocketBufferSize();
|
void UpdateSocketBufferSize();
|
||||||
|
|
||||||
// only one channel is needed for client application
|
// only one channel is needed for client application
|
||||||
CChannel Channel;
|
CChannel Channel;
|
||||||
bool bDoAutoSockBufSize;
|
bool bDoAutoSockBufSize;
|
||||||
|
|
||||||
// audio encoder/decoder
|
// audio encoder/decoder
|
||||||
CELTMode* CeltMode;
|
CELTMode* CeltMode;
|
||||||
CELTEncoder* CeltEncoder;
|
CELTEncoder* CeltEncoder;
|
||||||
CELTDecoder* CeltDecoder;
|
CELTDecoder* CeltDecoder;
|
||||||
int iCeltNumCodedBytes;
|
int iCeltNumCodedBytes;
|
||||||
bool bCeltDoHighQuality;
|
bool bCeltDoHighQuality;
|
||||||
CVector<unsigned char> vecCeltData;
|
CVector<unsigned char> vecCeltData;
|
||||||
|
|
||||||
CSocket Socket;
|
CSocket Socket;
|
||||||
CSound Sound;
|
CSound Sound;
|
||||||
CStereoSignalLevelMeter SignalLevelMeter;
|
CStereoSignalLevelMeter SignalLevelMeter;
|
||||||
|
|
||||||
CVector<uint8_t> vecbyNetwData;
|
CVector<uint8_t> vecbyNetwData;
|
||||||
|
|
||||||
int iAudioInFader;
|
int iAudioInFader;
|
||||||
bool bReverbOnLeftChan;
|
bool bReverbOnLeftChan;
|
||||||
int iReverbLevel;
|
int iReverbLevel;
|
||||||
CAudioReverb AudioReverb;
|
CAudioReverb AudioReverb;
|
||||||
|
|
||||||
int iSndCrdPrefFrameSizeFactor;
|
int iSndCrdPrefFrameSizeFactor;
|
||||||
int iSndCrdFrameSizeFactor;
|
int iSndCrdFrameSizeFactor;
|
||||||
|
|
||||||
int iMonoBlockSizeSam;
|
int iMonoBlockSizeSam;
|
||||||
int iStereoBlockSizeSam;
|
int iStereoBlockSizeSam;
|
||||||
|
|
||||||
bool bOpenChatOnNewMessage;
|
bool bOpenChatOnNewMessage;
|
||||||
EGUIDesign eGUIDesign;
|
EGUIDesign eGUIDesign;
|
||||||
|
|
||||||
CVector<int16_t> vecsAudioSndCrdMono;
|
CVector<int16_t> vecsAudioSndCrdMono;
|
||||||
CVector<int16_t> vecsAudioSndCrdStereo;
|
CVector<int16_t> vecsAudioSndCrdStereo;
|
||||||
CVector<double> vecdAudioStereo;
|
CVector<double> vecdAudioStereo;
|
||||||
CVector<int16_t> vecsNetwork;
|
CVector<int16_t> vecsNetwork;
|
||||||
|
|
||||||
// for ping measurement
|
// for ping measurement
|
||||||
CPreciseTime PreciseTime;
|
CPreciseTime PreciseTime;
|
||||||
|
|
||||||
CCycleTimeVariance CycleTimeVariance;
|
CCycleTimeVariance CycleTimeVariance;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void OnSendProtMessage ( CVector<uint8_t> vecMessage );
|
void OnSendProtMessage ( CVector<uint8_t> vecMessage );
|
||||||
void OnReqJittBufSize() { Channel.CreateJitBufMes ( Channel.GetSockBufNumFrames() ); }
|
void OnReqJittBufSize() { Channel.CreateJitBufMes ( Channel.GetSockBufNumFrames() ); }
|
||||||
void OnReqChanName() { Channel.SetRemoteName ( strName ); }
|
void OnReqChanName() { Channel.SetRemoteName ( strName ); }
|
||||||
void OnNewConnection();
|
void OnNewConnection();
|
||||||
void OnReceivePingMessage ( int iMs );
|
void OnReceivePingMessage ( int iMs );
|
||||||
void OnSndCrdReinitRequest();
|
void OnSndCrdReinitRequest();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
|
void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
|
||||||
void ChatTextReceived ( QString strChatText );
|
void ChatTextReceived ( QString strChatText );
|
||||||
void PingTimeReceived ( int iPingTime );
|
void PingTimeReceived ( int iPingTime );
|
||||||
void Disconnected();
|
void Disconnected();
|
||||||
void Stopped();
|
void Stopped();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* !defined ( CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_ ) */
|
#endif /* !defined ( CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_ ) */
|
||||||
|
|
|
@ -1,473 +1,473 @@
|
||||||
/******************************************************************************\
|
/******************************************************************************\
|
||||||
* Copyright (c) 2004-2009
|
* Copyright (c) 2004-2009
|
||||||
*
|
*
|
||||||
* Author(s):
|
* Author(s):
|
||||||
* Volker Fischer
|
* Volker Fischer
|
||||||
*
|
*
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under
|
* 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
|
* 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
|
* Foundation; either version 2 of the License, or (at your option) any later
|
||||||
* version.
|
* version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* 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
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
* details.
|
* details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along with
|
* 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.,
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
|
|
||||||
#include "clientsettingsdlg.h"
|
#include "clientsettingsdlg.h"
|
||||||
|
|
||||||
|
|
||||||
/* Implementation *************************************************************/
|
/* Implementation *************************************************************/
|
||||||
CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
|
CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
|
||||||
Qt::WindowFlags f ) : pClient ( pNCliP ), QDialog ( parent, f )
|
Qt::WindowFlags f ) : pClient ( pNCliP ), QDialog ( parent, f )
|
||||||
{
|
{
|
||||||
setupUi ( this );
|
setupUi ( this );
|
||||||
|
|
||||||
// add help text to controls
|
// add help text to controls
|
||||||
QString strJitterBufferSize = tr ( "<b>Jitter Buffer Size:</b> The size of "
|
QString strJitterBufferSize = tr ( "<b>Jitter Buffer Size:</b> The size of "
|
||||||
"the network buffer (jitter buffer). The jitter buffer compensates for "
|
"the network buffer (jitter buffer). The jitter buffer compensates for "
|
||||||
"the network jitter. The larger this buffer is, the more robust the "
|
"the network jitter. The larger this buffer is, the more robust the "
|
||||||
"connection is against network jitter but the higher is the latency. "
|
"connection is against network jitter but the higher is the latency. "
|
||||||
"This setting is therefore a trade-off between audio drop outs and "
|
"This setting is therefore a trade-off between audio drop outs and "
|
||||||
"overall audio delay.<br>By changing this setting, both, the client "
|
"overall audio delay.<br>By changing this setting, both, the client "
|
||||||
"and the server jitter buffer is set to the same value." );
|
"and the server jitter buffer is set to the same value." );
|
||||||
SliderNetBuf->setWhatsThis ( strJitterBufferSize );
|
SliderNetBuf->setWhatsThis ( strJitterBufferSize );
|
||||||
TextNetBuf->setWhatsThis ( strJitterBufferSize );
|
TextNetBuf->setWhatsThis ( strJitterBufferSize );
|
||||||
GroupBoxJitterBuffer->setWhatsThis ( strJitterBufferSize );
|
GroupBoxJitterBuffer->setWhatsThis ( strJitterBufferSize );
|
||||||
|
|
||||||
// init driver button
|
// init driver button
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
ButtonDriverSetup->setText ( "ASIO Setup" );
|
ButtonDriverSetup->setText ( "ASIO Setup" );
|
||||||
#else
|
#else
|
||||||
// no use for this button for Linux right now, maybe later used
|
// no use for this button for Linux right now, maybe later used
|
||||||
// for Jack
|
// for Jack
|
||||||
ButtonDriverSetup->hide();
|
ButtonDriverSetup->hide();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// init delay and other information controls
|
// init delay and other information controls
|
||||||
CLEDOverallDelay->SetUpdateTime ( 2 * PING_UPDATE_TIME );
|
CLEDOverallDelay->SetUpdateTime ( 2 * PING_UPDATE_TIME );
|
||||||
CLEDOverallDelay->Reset();
|
CLEDOverallDelay->Reset();
|
||||||
TextLabelPingTime->setText ( "" );
|
TextLabelPingTime->setText ( "" );
|
||||||
TextLabelOverallDelay->setText ( "" );
|
TextLabelOverallDelay->setText ( "" );
|
||||||
TextUpstreamValue->setText ( "" );
|
TextUpstreamValue->setText ( "" );
|
||||||
|
|
||||||
|
|
||||||
// init slider controls ---
|
// init slider controls ---
|
||||||
// network buffer
|
// network buffer
|
||||||
SliderNetBuf->setRange ( MIN_NET_BUF_SIZE_NUM_BL, MAX_NET_BUF_SIZE_NUM_BL );
|
SliderNetBuf->setRange ( MIN_NET_BUF_SIZE_NUM_BL, MAX_NET_BUF_SIZE_NUM_BL );
|
||||||
UpdateJitterBufferFrame();
|
UpdateJitterBufferFrame();
|
||||||
|
|
||||||
// init combo box containing all available sound cards in the system
|
// init combo box containing all available sound cards in the system
|
||||||
cbSoundcard->clear();
|
cbSoundcard->clear();
|
||||||
for ( int iSndDevIdx = 0; iSndDevIdx < pClient->GetSndCrdNumDev(); iSndDevIdx++ )
|
for ( int iSndDevIdx = 0; iSndDevIdx < pClient->GetSndCrdNumDev(); iSndDevIdx++ )
|
||||||
{
|
{
|
||||||
cbSoundcard->addItem ( pClient->GetSndCrdDeviceName ( iSndDevIdx ).c_str() );
|
cbSoundcard->addItem ( pClient->GetSndCrdDeviceName ( iSndDevIdx ).c_str() );
|
||||||
}
|
}
|
||||||
cbSoundcard->setCurrentIndex ( pClient->GetSndCrdDev() );
|
cbSoundcard->setCurrentIndex ( pClient->GetSndCrdDev() );
|
||||||
|
|
||||||
// "OpenChatOnNewMessage" check box
|
// "OpenChatOnNewMessage" check box
|
||||||
if ( pClient->GetOpenChatOnNewMessage() )
|
if ( pClient->GetOpenChatOnNewMessage() )
|
||||||
{
|
{
|
||||||
cbOpenChatOnNewMessage->setCheckState ( Qt::Checked );
|
cbOpenChatOnNewMessage->setCheckState ( Qt::Checked );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cbOpenChatOnNewMessage->setCheckState ( Qt::Unchecked );
|
cbOpenChatOnNewMessage->setCheckState ( Qt::Unchecked );
|
||||||
}
|
}
|
||||||
|
|
||||||
// fancy GUI design check box
|
// fancy GUI design check box
|
||||||
if ( pClient->GetGUIDesign() == GD_STANDARD )
|
if ( pClient->GetGUIDesign() == GD_STANDARD )
|
||||||
{
|
{
|
||||||
cbGUIDesignFancy->setCheckState ( Qt::Unchecked );
|
cbGUIDesignFancy->setCheckState ( Qt::Unchecked );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cbGUIDesignFancy->setCheckState ( Qt::Checked );
|
cbGUIDesignFancy->setCheckState ( Qt::Checked );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO we disable the fancy GUI switch because the new design
|
// TODO we disable the fancy GUI switch because the new design
|
||||||
// is not yet finished
|
// is not yet finished
|
||||||
cbGUIDesignFancy->setVisible ( false );
|
cbGUIDesignFancy->setVisible ( false );
|
||||||
|
|
||||||
|
|
||||||
// "High Quality Audio" check box
|
// "High Quality Audio" check box
|
||||||
if ( pClient->GetCELTHighQuality() )
|
if ( pClient->GetCELTHighQuality() )
|
||||||
{
|
{
|
||||||
cbUseHighQualityAudio->setCheckState ( Qt::Checked );
|
cbUseHighQualityAudio->setCheckState ( Qt::Checked );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cbUseHighQualityAudio->setCheckState ( Qt::Unchecked );
|
cbUseHighQualityAudio->setCheckState ( Qt::Unchecked );
|
||||||
}
|
}
|
||||||
|
|
||||||
// set text for sound card buffer delay radio buttons
|
// set text for sound card buffer delay radio buttons
|
||||||
rButBufferDelayPreferred->setText ( GenSndCrdBufferDelayString (
|
rButBufferDelayPreferred->setText ( GenSndCrdBufferDelayString (
|
||||||
FRAME_SIZE_FACTOR_PREFERRED * SYSTEM_FRAME_SIZE_SAMPLES,
|
FRAME_SIZE_FACTOR_PREFERRED * SYSTEM_FRAME_SIZE_SAMPLES,
|
||||||
", preferred" ) );
|
", preferred" ) );
|
||||||
|
|
||||||
rButBufferDelayDefault->setText ( GenSndCrdBufferDelayString (
|
rButBufferDelayDefault->setText ( GenSndCrdBufferDelayString (
|
||||||
FRAME_SIZE_FACTOR_DEFAULT * SYSTEM_FRAME_SIZE_SAMPLES,
|
FRAME_SIZE_FACTOR_DEFAULT * SYSTEM_FRAME_SIZE_SAMPLES,
|
||||||
", default" ) );
|
", default" ) );
|
||||||
|
|
||||||
rButBufferDelaySafe->setText ( GenSndCrdBufferDelayString (
|
rButBufferDelaySafe->setText ( GenSndCrdBufferDelayString (
|
||||||
FRAME_SIZE_FACTOR_SAFE * SYSTEM_FRAME_SIZE_SAMPLES ) );
|
FRAME_SIZE_FACTOR_SAFE * SYSTEM_FRAME_SIZE_SAMPLES ) );
|
||||||
|
|
||||||
// sound card buffer delay inits
|
// sound card buffer delay inits
|
||||||
SndCrdBufferDelayButtonGroup.addButton ( rButBufferDelayPreferred );
|
SndCrdBufferDelayButtonGroup.addButton ( rButBufferDelayPreferred );
|
||||||
SndCrdBufferDelayButtonGroup.addButton ( rButBufferDelayDefault );
|
SndCrdBufferDelayButtonGroup.addButton ( rButBufferDelayDefault );
|
||||||
SndCrdBufferDelayButtonGroup.addButton ( rButBufferDelaySafe );
|
SndCrdBufferDelayButtonGroup.addButton ( rButBufferDelaySafe );
|
||||||
|
|
||||||
UpdateSoundCardFrame();
|
UpdateSoundCardFrame();
|
||||||
|
|
||||||
|
|
||||||
// Connections -------------------------------------------------------------
|
// Connections -------------------------------------------------------------
|
||||||
// timers
|
// timers
|
||||||
QObject::connect ( &TimerStatus, SIGNAL ( timeout() ),
|
QObject::connect ( &TimerStatus, SIGNAL ( timeout() ),
|
||||||
this, SLOT ( OnTimerStatus() ) );
|
this, SLOT ( OnTimerStatus() ) );
|
||||||
|
|
||||||
QObject::connect ( &TimerPing, SIGNAL ( timeout() ),
|
QObject::connect ( &TimerPing, SIGNAL ( timeout() ),
|
||||||
this, SLOT ( OnTimerPing() ) );
|
this, SLOT ( OnTimerPing() ) );
|
||||||
|
|
||||||
// slider controls
|
// slider controls
|
||||||
QObject::connect ( SliderNetBuf, SIGNAL ( valueChanged ( int ) ),
|
QObject::connect ( SliderNetBuf, SIGNAL ( valueChanged ( int ) ),
|
||||||
this, SLOT ( OnSliderNetBuf ( int ) ) );
|
this, SLOT ( OnSliderNetBuf ( int ) ) );
|
||||||
|
|
||||||
// check boxes
|
// check boxes
|
||||||
QObject::connect ( cbOpenChatOnNewMessage, SIGNAL ( stateChanged ( int ) ),
|
QObject::connect ( cbOpenChatOnNewMessage, SIGNAL ( stateChanged ( int ) ),
|
||||||
this, SLOT ( OnOpenChatOnNewMessageStateChanged ( int ) ) );
|
this, SLOT ( OnOpenChatOnNewMessageStateChanged ( int ) ) );
|
||||||
|
|
||||||
QObject::connect ( cbGUIDesignFancy, SIGNAL ( stateChanged ( int ) ),
|
QObject::connect ( cbGUIDesignFancy, SIGNAL ( stateChanged ( int ) ),
|
||||||
this, SLOT ( OnGUIDesignFancyStateChanged ( int ) ) );
|
this, SLOT ( OnGUIDesignFancyStateChanged ( int ) ) );
|
||||||
|
|
||||||
QObject::connect ( cbUseHighQualityAudio, SIGNAL ( stateChanged ( int ) ),
|
QObject::connect ( cbUseHighQualityAudio, SIGNAL ( stateChanged ( int ) ),
|
||||||
this, SLOT ( OnUseHighQualityAudioStateChanged ( int ) ) );
|
this, SLOT ( OnUseHighQualityAudioStateChanged ( int ) ) );
|
||||||
|
|
||||||
QObject::connect ( cbAutoJitBuf, SIGNAL ( stateChanged ( int ) ),
|
QObject::connect ( cbAutoJitBuf, SIGNAL ( stateChanged ( int ) ),
|
||||||
this, SLOT ( OnAutoJitBuf ( int ) ) );
|
this, SLOT ( OnAutoJitBuf ( int ) ) );
|
||||||
|
|
||||||
// combo boxes
|
// combo boxes
|
||||||
QObject::connect ( cbSoundcard, SIGNAL ( activated ( int ) ),
|
QObject::connect ( cbSoundcard, SIGNAL ( activated ( int ) ),
|
||||||
this, SLOT ( OnSoundCrdSelection ( int ) ) );
|
this, SLOT ( OnSoundCrdSelection ( int ) ) );
|
||||||
|
|
||||||
// buttons
|
// buttons
|
||||||
QObject::connect ( ButtonDriverSetup, SIGNAL ( clicked() ),
|
QObject::connect ( ButtonDriverSetup, SIGNAL ( clicked() ),
|
||||||
this, SLOT ( OnDriverSetupBut() ) );
|
this, SLOT ( OnDriverSetupBut() ) );
|
||||||
|
|
||||||
// misc
|
// misc
|
||||||
QObject::connect ( pClient, SIGNAL ( PingTimeReceived ( int ) ),
|
QObject::connect ( pClient, SIGNAL ( PingTimeReceived ( int ) ),
|
||||||
this, SLOT ( OnPingTimeResult ( int ) ) );
|
this, SLOT ( OnPingTimeResult ( int ) ) );
|
||||||
|
|
||||||
QObject::connect ( &SndCrdBufferDelayButtonGroup,
|
QObject::connect ( &SndCrdBufferDelayButtonGroup,
|
||||||
SIGNAL ( buttonClicked ( QAbstractButton* ) ), this,
|
SIGNAL ( buttonClicked ( QAbstractButton* ) ), this,
|
||||||
SLOT ( OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* ) ) );
|
SLOT ( OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* ) ) );
|
||||||
|
|
||||||
|
|
||||||
// Timers ------------------------------------------------------------------
|
// Timers ------------------------------------------------------------------
|
||||||
// start timer for status bar
|
// start timer for status bar
|
||||||
TimerStatus.start ( DISPLAY_UPDATE_TIME );
|
TimerStatus.start ( DISPLAY_UPDATE_TIME );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::UpdateJitterBufferFrame()
|
void CClientSettingsDlg::UpdateJitterBufferFrame()
|
||||||
{
|
{
|
||||||
// update slider value and text
|
// update slider value and text
|
||||||
const int iCurNumNetBuf = pClient->GetSockBufNumFrames();
|
const int iCurNumNetBuf = pClient->GetSockBufNumFrames();
|
||||||
SliderNetBuf->setValue ( iCurNumNetBuf );
|
SliderNetBuf->setValue ( iCurNumNetBuf );
|
||||||
TextNetBuf->setText ( "Size: " + QString().setNum ( iCurNumNetBuf ) );
|
TextNetBuf->setText ( "Size: " + QString().setNum ( iCurNumNetBuf ) );
|
||||||
|
|
||||||
// if auto setting is enabled, disable slider control
|
// if auto setting is enabled, disable slider control
|
||||||
cbAutoJitBuf->setChecked ( pClient->GetDoAutoSockBufSize() );
|
cbAutoJitBuf->setChecked ( pClient->GetDoAutoSockBufSize() );
|
||||||
SliderNetBuf->setEnabled ( !pClient->GetDoAutoSockBufSize() );
|
SliderNetBuf->setEnabled ( !pClient->GetDoAutoSockBufSize() );
|
||||||
TextNetBuf->setEnabled ( !pClient->GetDoAutoSockBufSize() );
|
TextNetBuf->setEnabled ( !pClient->GetDoAutoSockBufSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CClientSettingsDlg::GenSndCrdBufferDelayString ( const int iFrameSize,
|
QString CClientSettingsDlg::GenSndCrdBufferDelayString ( const int iFrameSize,
|
||||||
const QString strAddText )
|
const QString strAddText )
|
||||||
{
|
{
|
||||||
// use two times the buffer delay for the entire delay since
|
// use two times the buffer delay for the entire delay since
|
||||||
// we have input and output
|
// we have input and output
|
||||||
return QString().setNum ( (double) iFrameSize * 2 *
|
return QString().setNum ( (double) iFrameSize * 2 *
|
||||||
1000 / SYSTEM_SAMPLE_RATE, 'f', 2 ) + " ms (" +
|
1000 / SYSTEM_SAMPLE_RATE, 'f', 2 ) + " ms (" +
|
||||||
QString().setNum ( iFrameSize ) + strAddText + ")";
|
QString().setNum ( iFrameSize ) + strAddText + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::UpdateSoundCardFrame()
|
void CClientSettingsDlg::UpdateSoundCardFrame()
|
||||||
{
|
{
|
||||||
// update slider value and text
|
// update slider value and text
|
||||||
const int iCurPrefFrameSizeFactor =
|
const int iCurPrefFrameSizeFactor =
|
||||||
pClient->GetSndCrdPrefFrameSizeFactor();
|
pClient->GetSndCrdPrefFrameSizeFactor();
|
||||||
|
|
||||||
const int iCurActualBufSize =
|
const int iCurActualBufSize =
|
||||||
pClient->GetSndCrdActualMonoBlSize();
|
pClient->GetSndCrdActualMonoBlSize();
|
||||||
|
|
||||||
// update radio buttons
|
// update radio buttons
|
||||||
switch ( iCurPrefFrameSizeFactor )
|
switch ( iCurPrefFrameSizeFactor )
|
||||||
{
|
{
|
||||||
case FRAME_SIZE_FACTOR_PREFERRED:
|
case FRAME_SIZE_FACTOR_PREFERRED:
|
||||||
rButBufferDelayPreferred->setChecked ( true );
|
rButBufferDelayPreferred->setChecked ( true );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FRAME_SIZE_FACTOR_DEFAULT:
|
case FRAME_SIZE_FACTOR_DEFAULT:
|
||||||
rButBufferDelayDefault->setChecked ( true );
|
rButBufferDelayDefault->setChecked ( true );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FRAME_SIZE_FACTOR_SAFE:
|
case FRAME_SIZE_FACTOR_SAFE:
|
||||||
rButBufferDelaySafe->setChecked ( true );
|
rButBufferDelaySafe->setChecked ( true );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// preferred size
|
// preferred size
|
||||||
const int iPrefBufSize =
|
const int iPrefBufSize =
|
||||||
iCurPrefFrameSizeFactor * SYSTEM_FRAME_SIZE_SAMPLES;
|
iCurPrefFrameSizeFactor * SYSTEM_FRAME_SIZE_SAMPLES;
|
||||||
|
|
||||||
// actual size (use yellow color if different from preferred size)
|
// actual size (use yellow color if different from preferred size)
|
||||||
const QString strActSizeValues =
|
const QString strActSizeValues =
|
||||||
GenSndCrdBufferDelayString ( iCurActualBufSize );
|
GenSndCrdBufferDelayString ( iCurActualBufSize );
|
||||||
|
|
||||||
if ( iPrefBufSize != iCurActualBufSize )
|
if ( iPrefBufSize != iCurActualBufSize )
|
||||||
{
|
{
|
||||||
// yellow color if actual buffer size is not the selected one
|
// yellow color if actual buffer size is not the selected one
|
||||||
// but a valid one, red color if actual buffer size is not the
|
// but a valid one, red color if actual buffer size is not the
|
||||||
// selected one and is not a vaild one
|
// selected one and is not a vaild one
|
||||||
if ( ( iCurActualBufSize != ( SYSTEM_FRAME_SIZE_SAMPLES * FRAME_SIZE_FACTOR_PREFERRED ) ) &&
|
if ( ( iCurActualBufSize != ( SYSTEM_FRAME_SIZE_SAMPLES * FRAME_SIZE_FACTOR_PREFERRED ) ) &&
|
||||||
( iCurActualBufSize != ( SYSTEM_FRAME_SIZE_SAMPLES * FRAME_SIZE_FACTOR_DEFAULT ) ) &&
|
( iCurActualBufSize != ( SYSTEM_FRAME_SIZE_SAMPLES * FRAME_SIZE_FACTOR_DEFAULT ) ) &&
|
||||||
( iCurActualBufSize != ( SYSTEM_FRAME_SIZE_SAMPLES * FRAME_SIZE_FACTOR_SAFE ) ) )
|
( iCurActualBufSize != ( SYSTEM_FRAME_SIZE_SAMPLES * FRAME_SIZE_FACTOR_SAFE ) ) )
|
||||||
{
|
{
|
||||||
TextLabelActualSndCrdBufDelay->setText ( "<b><font color=""red"">" +
|
TextLabelActualSndCrdBufDelay->setText ( "<b><font color=""red"">" +
|
||||||
strActSizeValues + "</font></b>" );
|
strActSizeValues + "</font></b>" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TextLabelActualSndCrdBufDelay->setText ( "<b><font color=""yellow"">" +
|
TextLabelActualSndCrdBufDelay->setText ( "<b><font color=""yellow"">" +
|
||||||
strActSizeValues + "</font></b>" );
|
strActSizeValues + "</font></b>" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TextLabelActualSndCrdBufDelay->setText ( strActSizeValues );
|
TextLabelActualSndCrdBufDelay->setText ( strActSizeValues );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::showEvent ( QShowEvent* showEvent )
|
void CClientSettingsDlg::showEvent ( QShowEvent* showEvent )
|
||||||
{
|
{
|
||||||
// only activate ping timer if window is actually shown
|
// only activate ping timer if window is actually shown
|
||||||
TimerPing.start ( PING_UPDATE_TIME );
|
TimerPing.start ( PING_UPDATE_TIME );
|
||||||
|
|
||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::hideEvent ( QHideEvent* hideEvent )
|
void CClientSettingsDlg::hideEvent ( QHideEvent* hideEvent )
|
||||||
{
|
{
|
||||||
// if window is closed, stop timer for ping
|
// if window is closed, stop timer for ping
|
||||||
TimerPing.stop();
|
TimerPing.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::OnDriverSetupBut()
|
void CClientSettingsDlg::OnDriverSetupBut()
|
||||||
{
|
{
|
||||||
pClient->OpenSndCrdDriverSetup();
|
pClient->OpenSndCrdDriverSetup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::OnSliderNetBuf ( int value )
|
void CClientSettingsDlg::OnSliderNetBuf ( int value )
|
||||||
{
|
{
|
||||||
pClient->SetSockBufNumFrames ( value );
|
pClient->SetSockBufNumFrames ( value );
|
||||||
UpdateJitterBufferFrame();
|
UpdateJitterBufferFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::OnSliderSndCrdBufferDelay ( int value )
|
void CClientSettingsDlg::OnSliderSndCrdBufferDelay ( int value )
|
||||||
{
|
{
|
||||||
pClient->SetSndCrdPrefFrameSizeFactor ( value );
|
pClient->SetSndCrdPrefFrameSizeFactor ( value );
|
||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::OnSoundCrdSelection ( int iSndDevIdx )
|
void CClientSettingsDlg::OnSoundCrdSelection ( int iSndDevIdx )
|
||||||
{
|
{
|
||||||
const QString strError = pClient->SetSndCrdDev ( iSndDevIdx );
|
const QString strError = pClient->SetSndCrdDev ( iSndDevIdx );
|
||||||
|
|
||||||
if ( !strError.isEmpty() )
|
if ( !strError.isEmpty() )
|
||||||
{
|
{
|
||||||
QMessageBox::critical ( 0, APP_NAME,
|
QMessageBox::critical ( 0, APP_NAME,
|
||||||
QString ( "The selected audio device could not be used because "
|
QString ( "The selected audio device could not be used because "
|
||||||
"of the following error: " ) + strError +
|
"of the following error: " ) + strError +
|
||||||
QString ( " The previous driver will be selected." ), "Ok", 0 );
|
QString ( " The previous driver will be selected." ), "Ok", 0 );
|
||||||
|
|
||||||
// recover old selection
|
// recover old selection
|
||||||
cbSoundcard->setCurrentIndex ( pClient->GetSndCrdDev() );
|
cbSoundcard->setCurrentIndex ( pClient->GetSndCrdDev() );
|
||||||
}
|
}
|
||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::OnAutoJitBuf ( int value )
|
void CClientSettingsDlg::OnAutoJitBuf ( int value )
|
||||||
{
|
{
|
||||||
pClient->SetDoAutoSockBufSize ( value == Qt::Checked );
|
pClient->SetDoAutoSockBufSize ( value == Qt::Checked );
|
||||||
UpdateJitterBufferFrame();
|
UpdateJitterBufferFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::OnOpenChatOnNewMessageStateChanged ( int value )
|
void CClientSettingsDlg::OnOpenChatOnNewMessageStateChanged ( int value )
|
||||||
{
|
{
|
||||||
pClient->SetOpenChatOnNewMessage ( value == Qt::Checked );
|
pClient->SetOpenChatOnNewMessage ( value == Qt::Checked );
|
||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::OnGUIDesignFancyStateChanged ( int value )
|
void CClientSettingsDlg::OnGUIDesignFancyStateChanged ( int value )
|
||||||
{
|
{
|
||||||
if ( value == Qt::Unchecked )
|
if ( value == Qt::Unchecked )
|
||||||
{
|
{
|
||||||
pClient->SetGUIDesign ( GD_STANDARD );
|
pClient->SetGUIDesign ( GD_STANDARD );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pClient->SetGUIDesign ( GD_ORIGINAL );
|
pClient->SetGUIDesign ( GD_ORIGINAL );
|
||||||
}
|
}
|
||||||
emit GUIDesignChanged();
|
emit GUIDesignChanged();
|
||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::OnUseHighQualityAudioStateChanged ( int value )
|
void CClientSettingsDlg::OnUseHighQualityAudioStateChanged ( int value )
|
||||||
{
|
{
|
||||||
pClient->SetCELTHighQuality ( value == Qt::Checked );
|
pClient->SetCELTHighQuality ( value == Qt::Checked );
|
||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button )
|
void CClientSettingsDlg::OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button )
|
||||||
{
|
{
|
||||||
if ( button == rButBufferDelayPreferred )
|
if ( button == rButBufferDelayPreferred )
|
||||||
{
|
{
|
||||||
pClient->SetSndCrdPrefFrameSizeFactor ( FRAME_SIZE_FACTOR_PREFERRED );
|
pClient->SetSndCrdPrefFrameSizeFactor ( FRAME_SIZE_FACTOR_PREFERRED );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( button == rButBufferDelayDefault )
|
if ( button == rButBufferDelayDefault )
|
||||||
{
|
{
|
||||||
pClient->SetSndCrdPrefFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT );
|
pClient->SetSndCrdPrefFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( button == rButBufferDelaySafe )
|
if ( button == rButBufferDelaySafe )
|
||||||
{
|
{
|
||||||
pClient->SetSndCrdPrefFrameSizeFactor ( FRAME_SIZE_FACTOR_SAFE );
|
pClient->SetSndCrdPrefFrameSizeFactor ( FRAME_SIZE_FACTOR_SAFE );
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::OnTimerPing()
|
void CClientSettingsDlg::OnTimerPing()
|
||||||
{
|
{
|
||||||
// send ping message to server
|
// send ping message to server
|
||||||
pClient->SendPingMess();
|
pClient->SendPingMess();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::OnPingTimeResult ( int iPingTime )
|
void CClientSettingsDlg::OnPingTimeResult ( int iPingTime )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
For estimating the overall delay, use the following assumptions:
|
For estimating the overall delay, use the following assumptions:
|
||||||
- the mean delay of a cyclic buffer is half the buffer size (since
|
- the mean delay of a cyclic buffer is half the buffer size (since
|
||||||
for the average it is assumed that the buffer is half filled)
|
for the average it is assumed that the buffer is half filled)
|
||||||
- consider the jitter buffer on the server side, too
|
- consider the jitter buffer on the server side, too
|
||||||
*/
|
*/
|
||||||
// 2 times buffers at client and server divided by 2 (half the buffer
|
// 2 times buffers at client and server divided by 2 (half the buffer
|
||||||
// for the delay) is simply the total socket buffer size
|
// for the delay) is simply the total socket buffer size
|
||||||
const double dTotalJitterBufferDelayMS =
|
const double dTotalJitterBufferDelayMS =
|
||||||
SYSTEM_BLOCK_DURATION_MS_FLOAT * pClient->GetSockBufNumFrames();
|
SYSTEM_BLOCK_DURATION_MS_FLOAT * pClient->GetSockBufNumFrames();
|
||||||
|
|
||||||
// we assume that we have two period sizes for the input and one for the
|
// we assume that we have two period sizes for the input and one for the
|
||||||
// output, therefore we have "3 *" instead of "2 *" (for input and output)
|
// output, therefore we have "3 *" instead of "2 *" (for input and output)
|
||||||
// the actual sound card buffer size
|
// the actual sound card buffer size
|
||||||
const double dTotalSoundCardDelayMS =
|
const double dTotalSoundCardDelayMS =
|
||||||
3 * pClient->GetSndCrdActualMonoBlSize() *
|
3 * pClient->GetSndCrdActualMonoBlSize() *
|
||||||
1000 / SYSTEM_SAMPLE_RATE;
|
1000 / SYSTEM_SAMPLE_RATE;
|
||||||
|
|
||||||
// network packets are of the same size as the audio packets per definition
|
// network packets are of the same size as the audio packets per definition
|
||||||
const double dDelayToFillNetworkPackets =
|
const double dDelayToFillNetworkPackets =
|
||||||
pClient->GetSndCrdActualMonoBlSize() *
|
pClient->GetSndCrdActualMonoBlSize() *
|
||||||
1000 / SYSTEM_SAMPLE_RATE;
|
1000 / SYSTEM_SAMPLE_RATE;
|
||||||
|
|
||||||
// CELT additional delay at small frame sizes is half a frame size
|
// CELT additional delay at small frame sizes is half a frame size
|
||||||
const double dAdditionalAudioCodecDelay =
|
const double dAdditionalAudioCodecDelay =
|
||||||
SYSTEM_BLOCK_DURATION_MS_FLOAT / 2;
|
SYSTEM_BLOCK_DURATION_MS_FLOAT / 2;
|
||||||
|
|
||||||
const double dTotalBufferDelay =
|
const double dTotalBufferDelay =
|
||||||
dDelayToFillNetworkPackets +
|
dDelayToFillNetworkPackets +
|
||||||
dTotalJitterBufferDelayMS +
|
dTotalJitterBufferDelayMS +
|
||||||
dTotalSoundCardDelayMS +
|
dTotalSoundCardDelayMS +
|
||||||
dAdditionalAudioCodecDelay;
|
dAdditionalAudioCodecDelay;
|
||||||
|
|
||||||
const int iOverallDelay =
|
const int iOverallDelay =
|
||||||
LlconMath::round ( dTotalBufferDelay + iPingTime );
|
LlconMath::round ( dTotalBufferDelay + iPingTime );
|
||||||
|
|
||||||
// apply values to GUI labels, take special care if ping time exceeds
|
// apply values to GUI labels, take special care if ping time exceeds
|
||||||
// a certain value
|
// a certain value
|
||||||
if ( iPingTime > 500 )
|
if ( iPingTime > 500 )
|
||||||
{
|
{
|
||||||
const QString sErrorText =
|
const QString sErrorText =
|
||||||
"<font color=""red""><b>>500 ms</b></font>";
|
"<font color=""red""><b>>500 ms</b></font>";
|
||||||
|
|
||||||
TextLabelPingTime->setText ( sErrorText );
|
TextLabelPingTime->setText ( sErrorText );
|
||||||
TextLabelOverallDelay->setText ( sErrorText );
|
TextLabelOverallDelay->setText ( sErrorText );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TextLabelPingTime->setText ( QString().setNum ( iPingTime ) + " ms" );
|
TextLabelPingTime->setText ( QString().setNum ( iPingTime ) + " ms" );
|
||||||
TextLabelOverallDelay->setText (
|
TextLabelOverallDelay->setText (
|
||||||
QString().setNum ( iOverallDelay ) + " ms" );
|
QString().setNum ( iOverallDelay ) + " ms" );
|
||||||
}
|
}
|
||||||
|
|
||||||
// color definition: < 40 ms green, < 65 ms yellow, otherwise red
|
// color definition: < 40 ms green, < 65 ms yellow, otherwise red
|
||||||
if ( iOverallDelay <= 40 )
|
if ( iOverallDelay <= 40 )
|
||||||
{
|
{
|
||||||
CLEDOverallDelay->SetLight ( MUL_COL_LED_GREEN );
|
CLEDOverallDelay->SetLight ( MUL_COL_LED_GREEN );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( iOverallDelay <= 65 )
|
if ( iOverallDelay <= 65 )
|
||||||
{
|
{
|
||||||
CLEDOverallDelay->SetLight ( MUL_COL_LED_YELLOW );
|
CLEDOverallDelay->SetLight ( MUL_COL_LED_YELLOW );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CLEDOverallDelay->SetLight ( MUL_COL_LED_RED );
|
CLEDOverallDelay->SetLight ( MUL_COL_LED_RED );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::UpdateDisplay()
|
void CClientSettingsDlg::UpdateDisplay()
|
||||||
{
|
{
|
||||||
// update slider controls (settings might have been changed)
|
// update slider controls (settings might have been changed)
|
||||||
UpdateJitterBufferFrame();
|
UpdateJitterBufferFrame();
|
||||||
UpdateSoundCardFrame();
|
UpdateSoundCardFrame();
|
||||||
|
|
||||||
if ( !pClient->IsRunning() )
|
if ( !pClient->IsRunning() )
|
||||||
{
|
{
|
||||||
// clear text labels with client parameters
|
// clear text labels with client parameters
|
||||||
TextLabelPingTime->setText ( "" );
|
TextLabelPingTime->setText ( "" );
|
||||||
TextLabelOverallDelay->setText ( "" );
|
TextLabelOverallDelay->setText ( "" );
|
||||||
TextUpstreamValue->setText ( "" );
|
TextUpstreamValue->setText ( "" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// update upstream rate information label (only if client is running)
|
// update upstream rate information label (only if client is running)
|
||||||
TextUpstreamValue->setText (
|
TextUpstreamValue->setText (
|
||||||
QString().setNum ( pClient->GetUploadRateKbps() ) + " kbps" );
|
QString().setNum ( pClient->GetUploadRateKbps() ) + " kbps" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::SetStatus ( const int iMessType, const int iStatus )
|
void CClientSettingsDlg::SetStatus ( const int iMessType, const int iStatus )
|
||||||
{
|
{
|
||||||
switch ( iMessType )
|
switch ( iMessType )
|
||||||
{
|
{
|
||||||
case MS_JIT_BUF_PUT:
|
case MS_JIT_BUF_PUT:
|
||||||
case MS_JIT_BUF_GET:
|
case MS_JIT_BUF_GET:
|
||||||
// network LED shows combined status of put and get
|
// network LED shows combined status of put and get
|
||||||
CLEDNetw->SetLight ( iStatus );
|
CLEDNetw->SetLight ( iStatus );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MS_RESET_ALL:
|
case MS_RESET_ALL:
|
||||||
CLEDNetw->Reset();
|
CLEDNetw->Reset();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,95 +1,95 @@
|
||||||
/******************************************************************************\
|
/******************************************************************************\
|
||||||
* Copyright (c) 2004-2009
|
* Copyright (c) 2004-2009
|
||||||
*
|
*
|
||||||
* Author(s):
|
* Author(s):
|
||||||
* Volker Fischer
|
* Volker Fischer
|
||||||
*
|
*
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under
|
* 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
|
* 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
|
* Foundation; either version 2 of the License, or (at your option) any later
|
||||||
* version.
|
* version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* 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
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
* details.
|
* details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along with
|
* 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.,
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
|
|
||||||
#include <qlabel.h>
|
#include <qlabel.h>
|
||||||
#include <qstring.h>
|
#include <qstring.h>
|
||||||
#include <qlineedit.h>
|
#include <qlineedit.h>
|
||||||
#include <qpushbutton.h>
|
#include <qpushbutton.h>
|
||||||
#include <qprogressbar.h>
|
#include <qprogressbar.h>
|
||||||
#include <qwhatsthis.h>
|
#include <qwhatsthis.h>
|
||||||
#include <qtimer.h>
|
#include <qtimer.h>
|
||||||
#include <qslider.h>
|
#include <qslider.h>
|
||||||
#include <qradiobutton.h>
|
#include <qradiobutton.h>
|
||||||
#include <qmenubar.h>
|
#include <qmenubar.h>
|
||||||
#include <qlayout.h>
|
#include <qlayout.h>
|
||||||
#include <qbuttongroup.h>
|
#include <qbuttongroup.h>
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "multicolorled.h"
|
#include "multicolorled.h"
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# include "../windows/moc/clientsettingsdlgbase.h"
|
# include "../windows/moc/clientsettingsdlgbase.h"
|
||||||
#else
|
#else
|
||||||
# include "moc/clientsettingsdlgbase.h"
|
# include "moc/clientsettingsdlgbase.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Definitions ****************************************************************/
|
/* Definitions ****************************************************************/
|
||||||
// update time for GUI controls
|
// update time for GUI controls
|
||||||
#define DISPLAY_UPDATE_TIME 1000 // ms
|
#define DISPLAY_UPDATE_TIME 1000 // ms
|
||||||
#define PING_UPDATE_TIME 500 // ms
|
#define PING_UPDATE_TIME 500 // ms
|
||||||
|
|
||||||
|
|
||||||
/* Classes ********************************************************************/
|
/* Classes ********************************************************************/
|
||||||
class CClientSettingsDlg : public QDialog, private Ui_CClientSettingsDlgBase
|
class CClientSettingsDlg : public QDialog, private Ui_CClientSettingsDlgBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CClientSettingsDlg ( CClient* pNCliP, QWidget* parent = 0,
|
CClientSettingsDlg ( CClient* pNCliP, QWidget* parent = 0,
|
||||||
Qt::WindowFlags f = 0 );
|
Qt::WindowFlags f = 0 );
|
||||||
|
|
||||||
void SetStatus ( const int iMessType, const int iStatus );
|
void SetStatus ( const int iMessType, const int iStatus );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void UpdateJitterBufferFrame();
|
void UpdateJitterBufferFrame();
|
||||||
void UpdateSoundCardFrame();
|
void UpdateSoundCardFrame();
|
||||||
QString GenSndCrdBufferDelayString ( const int iFrameSize,
|
QString GenSndCrdBufferDelayString ( const int iFrameSize,
|
||||||
const QString strAddText = "" );
|
const QString strAddText = "" );
|
||||||
|
|
||||||
virtual void showEvent ( QShowEvent* showEvent );
|
virtual void showEvent ( QShowEvent* showEvent );
|
||||||
virtual void hideEvent ( QHideEvent* hideEvent );
|
virtual void hideEvent ( QHideEvent* hideEvent );
|
||||||
|
|
||||||
CClient* pClient;
|
CClient* pClient;
|
||||||
QTimer TimerStatus;
|
QTimer TimerStatus;
|
||||||
QTimer TimerPing;
|
QTimer TimerPing;
|
||||||
QButtonGroup SndCrdBufferDelayButtonGroup;
|
QButtonGroup SndCrdBufferDelayButtonGroup;
|
||||||
void UpdateDisplay();
|
void UpdateDisplay();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void OnTimerStatus() { UpdateDisplay(); }
|
void OnTimerStatus() { UpdateDisplay(); }
|
||||||
void OnTimerPing();
|
void OnTimerPing();
|
||||||
void OnSliderNetBuf ( int value );
|
void OnSliderNetBuf ( int value );
|
||||||
void OnSliderSndCrdBufferDelay ( int value );
|
void OnSliderSndCrdBufferDelay ( int value );
|
||||||
void OnAutoJitBuf ( int value );
|
void OnAutoJitBuf ( int value );
|
||||||
void OnOpenChatOnNewMessageStateChanged ( int value );
|
void OnOpenChatOnNewMessageStateChanged ( int value );
|
||||||
void OnGUIDesignFancyStateChanged ( int value );
|
void OnGUIDesignFancyStateChanged ( int value );
|
||||||
void OnUseHighQualityAudioStateChanged ( int value );
|
void OnUseHighQualityAudioStateChanged ( int value );
|
||||||
void OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button );
|
void OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button );
|
||||||
void OnPingTimeResult ( int iPingTime );
|
void OnPingTimeResult ( int iPingTime );
|
||||||
void OnSoundCrdSelection ( int iSndDevIdx );
|
void OnSoundCrdSelection ( int iSndDevIdx );
|
||||||
void OnDriverSetupBut();
|
void OnDriverSetupBut();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void GUIDesignChanged();
|
void GUIDesignChanged();
|
||||||
};
|
};
|
||||||
|
|
2314
src/protocol.cpp
2314
src/protocol.cpp
File diff suppressed because it is too large
Load diff
|
@ -88,9 +88,9 @@ public:
|
||||||
void CreateAndImmSendAcknMess ( const int& iID, const int& iCnt );
|
void CreateAndImmSendAcknMess ( const int& iID, const int& iCnt );
|
||||||
|
|
||||||
bool ParseMessage ( const CVector<uint8_t>& vecbyData,
|
bool ParseMessage ( const CVector<uint8_t>& vecbyData,
|
||||||
const int iNumBytes );
|
const int iNumBytes );
|
||||||
|
|
||||||
bool IsProtocolMessage ( const CVector<uint8_t>& vecbyData,
|
bool IsProtocolMessage ( const CVector<uint8_t>& vecbyData,
|
||||||
const int iNumBytes );
|
const int iNumBytes );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
1744
src/server.cpp
1744
src/server.cpp
File diff suppressed because it is too large
Load diff
|
@ -1,452 +1,452 @@
|
||||||
/******************************************************************************\
|
/******************************************************************************\
|
||||||
* Copyright (c) 2004-2009
|
* Copyright (c) 2004-2009
|
||||||
*
|
*
|
||||||
* Author(s):
|
* Author(s):
|
||||||
* Volker Fischer
|
* Volker Fischer
|
||||||
*
|
*
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under
|
* 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
|
* 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
|
* Foundation; either version 2 of the License, or (at your option) any later
|
||||||
* version.
|
* version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* 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
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
* details.
|
* details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along with
|
* 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.,
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
|
|
||||||
#include "serverlogging.h"
|
#include "serverlogging.h"
|
||||||
|
|
||||||
|
|
||||||
/* Implementation *************************************************************/
|
/* Implementation *************************************************************/
|
||||||
CHistoryGraph::CHistoryGraph() :
|
CHistoryGraph::CHistoryGraph() :
|
||||||
sFileName ( "" ),
|
sFileName ( "" ),
|
||||||
bDoHistory ( false ),
|
bDoHistory ( false ),
|
||||||
vHistoryDataFifo ( NUM_ITEMS_HISTORY ),
|
vHistoryDataFifo ( NUM_ITEMS_HISTORY ),
|
||||||
PlotCanvasRect ( 0, 0, 600, 450 ), // defines total size of graph
|
PlotCanvasRect ( 0, 0, 600, 450 ), // defines total size of graph
|
||||||
iNumTicksX ( 0 ), // just an initialization value, will be overwritten
|
iNumTicksX ( 0 ), // just an initialization value, will be overwritten
|
||||||
iYAxisStart ( 0 ),
|
iYAxisStart ( 0 ),
|
||||||
iYAxisEnd ( 24 ),
|
iYAxisEnd ( 24 ),
|
||||||
iNumTicksY ( 5 ),
|
iNumTicksY ( 5 ),
|
||||||
iGridFrameOffset ( 10 ),
|
iGridFrameOffset ( 10 ),
|
||||||
iGridWidthWeekend ( 3 ), // should be odd value
|
iGridWidthWeekend ( 3 ), // should be odd value
|
||||||
iTextOffsetToGrid ( 3 ),
|
iTextOffsetToGrid ( 3 ),
|
||||||
iXAxisTextHeight ( 22 ),
|
iXAxisTextHeight ( 22 ),
|
||||||
iMarkerSizeNewCon ( 11 ),
|
iMarkerSizeNewCon ( 11 ),
|
||||||
iMarkerSizeServSt ( 9 ),
|
iMarkerSizeServSt ( 9 ),
|
||||||
AxisFont ( "Arial", 12 ),
|
AxisFont ( "Arial", 12 ),
|
||||||
iTextOffsetX ( 18 ),
|
iTextOffsetX ( 18 ),
|
||||||
PlotBackgroundColor ( Qt::white ), // background
|
PlotBackgroundColor ( Qt::white ), // background
|
||||||
PlotFrameColor ( Qt::black ), // frame
|
PlotFrameColor ( Qt::black ), // frame
|
||||||
PlotGridColor ( Qt::gray ), // grid
|
PlotGridColor ( Qt::gray ), // grid
|
||||||
PlotTextColor ( Qt::black ), // text
|
PlotTextColor ( Qt::black ), // text
|
||||||
PlotMarkerNewColor ( Qt::darkCyan ), // marker for new connection
|
PlotMarkerNewColor ( Qt::darkCyan ), // marker for new connection
|
||||||
PlotMarkerNewLocalColor ( Qt::blue ), // marker for new local connection
|
PlotMarkerNewLocalColor ( Qt::blue ), // marker for new local connection
|
||||||
PlotMarkerStopColor ( Qt::red ), // marker for server stop
|
PlotMarkerStopColor ( Qt::red ), // marker for server stop
|
||||||
PlotPixmap ( 1, 1, QImage::Format_RGB32 )
|
PlotPixmap ( 1, 1, QImage::Format_RGB32 )
|
||||||
{
|
{
|
||||||
// generate plot grid frame rectangle
|
// generate plot grid frame rectangle
|
||||||
PlotGridFrame.setRect ( PlotCanvasRect.x() + iGridFrameOffset,
|
PlotGridFrame.setRect ( PlotCanvasRect.x() + iGridFrameOffset,
|
||||||
PlotCanvasRect.y() + iGridFrameOffset,
|
PlotCanvasRect.y() + iGridFrameOffset,
|
||||||
PlotCanvasRect.width() - 2 * iGridFrameOffset,
|
PlotCanvasRect.width() - 2 * iGridFrameOffset,
|
||||||
PlotCanvasRect.height() - 2 * iGridFrameOffset - iXAxisTextHeight );
|
PlotCanvasRect.height() - 2 * iGridFrameOffset - iXAxisTextHeight );
|
||||||
|
|
||||||
// scale pixmap to correct size
|
// scale pixmap to correct size
|
||||||
PlotPixmap = PlotPixmap.scaled (
|
PlotPixmap = PlotPixmap.scaled (
|
||||||
PlotCanvasRect.width(), PlotCanvasRect.height() );
|
PlotCanvasRect.width(), PlotCanvasRect.height() );
|
||||||
|
|
||||||
// connections
|
// connections
|
||||||
QObject::connect ( &TimerDailyUpdate, SIGNAL ( timeout() ),
|
QObject::connect ( &TimerDailyUpdate, SIGNAL ( timeout() ),
|
||||||
this, SLOT ( OnTimerDailyUpdate() ) );
|
this, SLOT ( OnTimerDailyUpdate() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHistoryGraph::Start ( const QString& sNewFileName )
|
void CHistoryGraph::Start ( const QString& sNewFileName )
|
||||||
{
|
{
|
||||||
if ( !sNewFileName.isEmpty() )
|
if ( !sNewFileName.isEmpty() )
|
||||||
{
|
{
|
||||||
// save file name
|
// save file name
|
||||||
sFileName = sNewFileName;
|
sFileName = sNewFileName;
|
||||||
|
|
||||||
// set enable flag
|
// set enable flag
|
||||||
bDoHistory = true;
|
bDoHistory = true;
|
||||||
|
|
||||||
// enable timer (update once a day)
|
// enable timer (update once a day)
|
||||||
TimerDailyUpdate.start ( 3600000 * 24 );
|
TimerDailyUpdate.start ( 3600000 * 24 );
|
||||||
|
|
||||||
// initial update (empty graph)
|
// initial update (empty graph)
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHistoryGraph::DrawFrame ( const int iNewNumTicksX )
|
void CHistoryGraph::DrawFrame ( const int iNewNumTicksX )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// store number of x-axis ticks (number of days we want to draw
|
// store number of x-axis ticks (number of days we want to draw
|
||||||
// the history for
|
// the history for
|
||||||
iNumTicksX = iNewNumTicksX;
|
iNumTicksX = iNewNumTicksX;
|
||||||
|
|
||||||
// clear base pixmap for new plotting
|
// clear base pixmap for new plotting
|
||||||
PlotPixmap.fill ( PlotBackgroundColor.rgb() ); // fill background
|
PlotPixmap.fill ( PlotBackgroundColor.rgb() ); // fill background
|
||||||
|
|
||||||
// create painter
|
// create painter
|
||||||
QPainter PlotPainter ( &PlotPixmap );
|
QPainter PlotPainter ( &PlotPixmap );
|
||||||
|
|
||||||
|
|
||||||
// create actual plot region (grid frame) ----------------------------------
|
// create actual plot region (grid frame) ----------------------------------
|
||||||
PlotPainter.setPen ( PlotFrameColor );
|
PlotPainter.setPen ( PlotFrameColor );
|
||||||
PlotPainter.drawRect ( PlotGridFrame );
|
PlotPainter.drawRect ( PlotGridFrame );
|
||||||
|
|
||||||
// calculate step for x-axis ticks so that we get the desired number of
|
// calculate step for x-axis ticks so that we get the desired number of
|
||||||
// ticks -> 5 ticks
|
// ticks -> 5 ticks
|
||||||
|
|
||||||
// TODO the following equation does not work as expected but results are acceptable
|
// TODO the following equation does not work as expected but results are acceptable
|
||||||
|
|
||||||
// we want to have "floor ( iNumTicksX / 5 )" which is the same as
|
// we want to have "floor ( iNumTicksX / 5 )" which is the same as
|
||||||
// "iNumTicksX / 5" since "iNumTicksX" is an integer variable
|
// "iNumTicksX / 5" since "iNumTicksX" is an integer variable
|
||||||
const int iXAxisTickStep = iNumTicksX / 5 + 1;
|
const int iXAxisTickStep = iNumTicksX / 5 + 1;
|
||||||
|
|
||||||
// grid (ticks) for x-axis
|
// grid (ticks) for x-axis
|
||||||
dXSpace = static_cast<double> ( PlotGridFrame.width() ) / ( iNumTicksX + 1 );
|
dXSpace = static_cast<double> ( PlotGridFrame.width() ) / ( iNumTicksX + 1 );
|
||||||
for ( i = 0; i < iNumTicksX; i++ )
|
for ( i = 0; i < iNumTicksX; i++ )
|
||||||
{
|
{
|
||||||
int iBottomExtraTickLen = 0;
|
int iBottomExtraTickLen = 0;
|
||||||
const int iCurX = PlotGridFrame.x() + static_cast<int> ( dXSpace * ( i + 1 ) );
|
const int iCurX = PlotGridFrame.x() + static_cast<int> ( dXSpace * ( i + 1 ) );
|
||||||
const QDate curXAxisDate = curDate.addDays ( i - iNumTicksX + 1 );
|
const QDate curXAxisDate = curDate.addDays ( i - iNumTicksX + 1 );
|
||||||
|
|
||||||
// text (print only every "iXAxisTickStep" tick)
|
// text (print only every "iXAxisTickStep" tick)
|
||||||
if ( !( i % iXAxisTickStep ) )
|
if ( !( i % iXAxisTickStep ) )
|
||||||
{
|
{
|
||||||
PlotPainter.setPen ( PlotTextColor );
|
PlotPainter.setPen ( PlotTextColor );
|
||||||
PlotPainter.setFont ( AxisFont );
|
PlotPainter.setFont ( AxisFont );
|
||||||
PlotPainter.drawText (
|
PlotPainter.drawText (
|
||||||
QPoint ( iCurX - iTextOffsetX,
|
QPoint ( iCurX - iTextOffsetX,
|
||||||
PlotGridFrame.bottom() + iXAxisTextHeight + iTextOffsetToGrid ),
|
PlotGridFrame.bottom() + iXAxisTextHeight + iTextOffsetToGrid ),
|
||||||
curXAxisDate.toString ( "dd.MM." ) );
|
curXAxisDate.toString ( "dd.MM." ) );
|
||||||
|
|
||||||
iBottomExtraTickLen = 5;
|
iBottomExtraTickLen = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// regular grid
|
// regular grid
|
||||||
PlotPainter.setPen ( PlotGridColor );
|
PlotPainter.setPen ( PlotGridColor );
|
||||||
PlotPainter.drawLine ( iCurX, 1 + PlotGridFrame.y(),
|
PlotPainter.drawLine ( iCurX, 1 + PlotGridFrame.y(),
|
||||||
iCurX, PlotGridFrame.bottom() + iBottomExtraTickLen );
|
iCurX, PlotGridFrame.bottom() + iBottomExtraTickLen );
|
||||||
|
|
||||||
// different grid width for weekends (overwrite regular grid)
|
// different grid width for weekends (overwrite regular grid)
|
||||||
if ( ( curXAxisDate.dayOfWeek() == 6 ) || // check for Saturday
|
if ( ( curXAxisDate.dayOfWeek() == 6 ) || // check for Saturday
|
||||||
( curXAxisDate.dayOfWeek() == 7 ) ) // check for Sunday
|
( curXAxisDate.dayOfWeek() == 7 ) ) // check for Sunday
|
||||||
{
|
{
|
||||||
const int iGridWidthWeekendHalf = iGridWidthWeekend / 2;
|
const int iGridWidthWeekendHalf = iGridWidthWeekend / 2;
|
||||||
|
|
||||||
PlotPainter.setPen ( QPen ( PlotGridColor, iGridWidthWeekend ) );
|
PlotPainter.setPen ( QPen ( PlotGridColor, iGridWidthWeekend ) );
|
||||||
PlotPainter.drawLine ( iCurX, 1 + PlotGridFrame.y() + iGridWidthWeekendHalf,
|
PlotPainter.drawLine ( iCurX, 1 + PlotGridFrame.y() + iGridWidthWeekendHalf,
|
||||||
iCurX, PlotGridFrame.bottom() - iGridWidthWeekendHalf );
|
iCurX, PlotGridFrame.bottom() - iGridWidthWeekendHalf );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// grid (ticks) for y-axis, draw iNumTicksY - 2 grid lines and
|
// grid (ticks) for y-axis, draw iNumTicksY - 2 grid lines and
|
||||||
// iNumTicksY - 1 text labels (the lowest grid line is the grid frame)
|
// iNumTicksY - 1 text labels (the lowest grid line is the grid frame)
|
||||||
iYSpace = PlotGridFrame.height() / ( iNumTicksY - 1 );
|
iYSpace = PlotGridFrame.height() / ( iNumTicksY - 1 );
|
||||||
for ( i = 0; i < ( iNumTicksY - 1 ); i++ )
|
for ( i = 0; i < ( iNumTicksY - 1 ); i++ )
|
||||||
{
|
{
|
||||||
const int iCurY = PlotGridFrame.y() + iYSpace * ( i + 1 );
|
const int iCurY = PlotGridFrame.y() + iYSpace * ( i + 1 );
|
||||||
|
|
||||||
// text
|
// text
|
||||||
PlotPainter.setPen ( PlotTextColor );
|
PlotPainter.setPen ( PlotTextColor );
|
||||||
PlotPainter.setFont ( AxisFont );
|
PlotPainter.setFont ( AxisFont );
|
||||||
PlotPainter.drawText ( QPoint (
|
PlotPainter.drawText ( QPoint (
|
||||||
PlotGridFrame.x() + iTextOffsetToGrid,
|
PlotGridFrame.x() + iTextOffsetToGrid,
|
||||||
iCurY - iTextOffsetToGrid ),
|
iCurY - iTextOffsetToGrid ),
|
||||||
QString ( "%1:00" ).arg (
|
QString ( "%1:00" ).arg (
|
||||||
( iYAxisEnd - iYAxisStart ) / ( iNumTicksY - 1 ) *
|
( iYAxisEnd - iYAxisStart ) / ( iNumTicksY - 1 ) *
|
||||||
( ( iNumTicksY - 2 ) - i ) ) );
|
( ( iNumTicksY - 2 ) - i ) ) );
|
||||||
|
|
||||||
// grid (do not overwrite frame)
|
// grid (do not overwrite frame)
|
||||||
if ( i < ( iNumTicksY - 2 ) )
|
if ( i < ( iNumTicksY - 2 ) )
|
||||||
{
|
{
|
||||||
PlotPainter.setPen ( PlotGridColor );
|
PlotPainter.setPen ( PlotGridColor );
|
||||||
PlotPainter.drawLine ( PlotGridFrame.x(), iCurY,
|
PlotPainter.drawLine ( PlotGridFrame.x(), iCurY,
|
||||||
PlotGridFrame.right(), iCurY );
|
PlotGridFrame.right(), iCurY );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHistoryGraph::AddMarker ( const SHistoryData& curHistoryData )
|
void CHistoryGraph::AddMarker ( const SHistoryData& curHistoryData )
|
||||||
{
|
{
|
||||||
// calculate x-axis offset (difference of days compared to
|
// calculate x-axis offset (difference of days compared to
|
||||||
// current date)
|
// current date)
|
||||||
const int iXAxisOffs =
|
const int iXAxisOffs =
|
||||||
curDate.daysTo ( curHistoryData.DateTime.date() );
|
curDate.daysTo ( curHistoryData.DateTime.date() );
|
||||||
|
|
||||||
// check range, if out of range, do not plot anything
|
// check range, if out of range, do not plot anything
|
||||||
if ( -iXAxisOffs > ( iNumTicksX - 1 ) )
|
if ( -iXAxisOffs > ( iNumTicksX - 1 ) )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate y-axis offset (consider hours and minutes)
|
// calculate y-axis offset (consider hours and minutes)
|
||||||
const double dYAxisOffs = 24 - curHistoryData.DateTime.time().hour() -
|
const double dYAxisOffs = 24 - curHistoryData.DateTime.time().hour() -
|
||||||
static_cast<double> ( curHistoryData.DateTime.time().minute() ) / 60;
|
static_cast<double> ( curHistoryData.DateTime.time().minute() ) / 60;
|
||||||
|
|
||||||
// calculate the actual point in the graph (in pixels)
|
// calculate the actual point in the graph (in pixels)
|
||||||
const QPoint curPoint (
|
const QPoint curPoint (
|
||||||
PlotGridFrame.x() + static_cast<int> ( dXSpace * ( iNumTicksX + iXAxisOffs ) ),
|
PlotGridFrame.x() + static_cast<int> ( dXSpace * ( iNumTicksX + iXAxisOffs ) ),
|
||||||
PlotGridFrame.y() + static_cast<int> ( static_cast<double> (
|
PlotGridFrame.y() + static_cast<int> ( static_cast<double> (
|
||||||
PlotGridFrame.height() ) / ( iYAxisEnd - iYAxisStart ) * dYAxisOffs ) );
|
PlotGridFrame.height() ) / ( iYAxisEnd - iYAxisStart ) * dYAxisOffs ) );
|
||||||
|
|
||||||
// create painter for plot
|
// create painter for plot
|
||||||
QPainter PlotPainter ( &PlotPixmap );
|
QPainter PlotPainter ( &PlotPixmap );
|
||||||
|
|
||||||
// we use different markers for new connection and server stop items
|
// we use different markers for new connection and server stop items
|
||||||
switch ( curHistoryData.Type )
|
switch ( curHistoryData.Type )
|
||||||
{
|
{
|
||||||
case HIT_SERVER_STOP:
|
case HIT_SERVER_STOP:
|
||||||
// filled circle marker
|
// filled circle marker
|
||||||
PlotPainter.setPen ( QPen ( QBrush ( PlotMarkerStopColor ),
|
PlotPainter.setPen ( QPen ( QBrush ( PlotMarkerStopColor ),
|
||||||
iMarkerSizeServSt, Qt::SolidLine, Qt::RoundCap ) );
|
iMarkerSizeServSt, Qt::SolidLine, Qt::RoundCap ) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HIT_LOCAL_CONNECTION:
|
case HIT_LOCAL_CONNECTION:
|
||||||
// filled square marker
|
// filled square marker
|
||||||
PlotPainter.setPen ( QPen ( QBrush ( PlotMarkerNewLocalColor ),
|
PlotPainter.setPen ( QPen ( QBrush ( PlotMarkerNewLocalColor ),
|
||||||
iMarkerSizeNewCon ) );
|
iMarkerSizeNewCon ) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HIT_REMOTE_CONNECTION:
|
case HIT_REMOTE_CONNECTION:
|
||||||
// filled square marker
|
// filled square marker
|
||||||
PlotPainter.setPen ( QPen ( QBrush ( PlotMarkerNewColor ),
|
PlotPainter.setPen ( QPen ( QBrush ( PlotMarkerNewColor ),
|
||||||
iMarkerSizeNewCon ) );
|
iMarkerSizeNewCon ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
PlotPainter.drawPoint ( curPoint );
|
PlotPainter.drawPoint ( curPoint );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHistoryGraph::Save ( const QString sFileName )
|
void CHistoryGraph::Save ( const QString sFileName )
|
||||||
{
|
{
|
||||||
// save plot as a file
|
// save plot as a file
|
||||||
PlotPixmap.save ( sFileName, "JPG", 90 );
|
PlotPixmap.save ( sFileName, "JPG", 90 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHistoryGraph::Add ( const QDateTime& newDateTime,
|
void CHistoryGraph::Add ( const QDateTime& newDateTime,
|
||||||
const QHostAddress ClientInetAddr )
|
const QHostAddress ClientInetAddr )
|
||||||
{
|
{
|
||||||
if ( bDoHistory )
|
if ( bDoHistory )
|
||||||
{
|
{
|
||||||
// add element to history, distinguish between a local connection
|
// add element to history, distinguish between a local connection
|
||||||
// and a remote connection
|
// and a remote connection
|
||||||
if ( ( ClientInetAddr == QHostAddress ( "127.0.0.1" ) ) ||
|
if ( ( ClientInetAddr == QHostAddress ( "127.0.0.1" ) ) ||
|
||||||
( ClientInetAddr.toString().left ( 7 ).compare ( "192.168" ) == 0 ) )
|
( ClientInetAddr.toString().left ( 7 ).compare ( "192.168" ) == 0 ) )
|
||||||
{
|
{
|
||||||
// local connection
|
// local connection
|
||||||
Add ( newDateTime, CHistoryGraph::HIT_LOCAL_CONNECTION );
|
Add ( newDateTime, CHistoryGraph::HIT_LOCAL_CONNECTION );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// remote connection
|
// remote connection
|
||||||
Add ( newDateTime, CHistoryGraph::HIT_REMOTE_CONNECTION );
|
Add ( newDateTime, CHistoryGraph::HIT_REMOTE_CONNECTION );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHistoryGraph::Add ( const QDateTime& newDateTime,
|
void CHistoryGraph::Add ( const QDateTime& newDateTime,
|
||||||
const EHistoryItemType curType )
|
const EHistoryItemType curType )
|
||||||
{
|
{
|
||||||
if ( bDoHistory )
|
if ( bDoHistory )
|
||||||
{
|
{
|
||||||
// create and add new element in FIFO
|
// create and add new element in FIFO
|
||||||
SHistoryData curHistoryData;
|
SHistoryData curHistoryData;
|
||||||
curHistoryData.DateTime = newDateTime;
|
curHistoryData.DateTime = newDateTime;
|
||||||
curHistoryData.Type = curType;
|
curHistoryData.Type = curType;
|
||||||
|
|
||||||
vHistoryDataFifo.Add ( curHistoryData );
|
vHistoryDataFifo.Add ( curHistoryData );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHistoryGraph::Update()
|
void CHistoryGraph::Update()
|
||||||
{
|
{
|
||||||
if ( bDoHistory )
|
if ( bDoHistory )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// store current date for reference
|
// store current date for reference
|
||||||
curDate = QDate::currentDate();
|
curDate = QDate::currentDate();
|
||||||
|
|
||||||
// get oldest date in history
|
// get oldest date in history
|
||||||
QDate oldestDate = curDate.addDays ( 1 ); // one day in the future
|
QDate oldestDate = curDate.addDays ( 1 ); // one day in the future
|
||||||
const int iNumItemsForHistory = vHistoryDataFifo.Size();
|
const int iNumItemsForHistory = vHistoryDataFifo.Size();
|
||||||
for ( i = 0; i < iNumItemsForHistory; i++ )
|
for ( i = 0; i < iNumItemsForHistory; i++ )
|
||||||
{
|
{
|
||||||
// only use valid dates
|
// only use valid dates
|
||||||
if ( vHistoryDataFifo[i].DateTime.date().isValid() )
|
if ( vHistoryDataFifo[i].DateTime.date().isValid() )
|
||||||
{
|
{
|
||||||
if ( vHistoryDataFifo[i].DateTime.date() < oldestDate )
|
if ( vHistoryDataFifo[i].DateTime.date() < oldestDate )
|
||||||
{
|
{
|
||||||
oldestDate = vHistoryDataFifo[i].DateTime.date();
|
oldestDate = vHistoryDataFifo[i].DateTime.date();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const int iNumDaysInHistory = -curDate.daysTo ( oldestDate ) + 1;
|
const int iNumDaysInHistory = -curDate.daysTo ( oldestDate ) + 1;
|
||||||
|
|
||||||
// draw frame of the graph
|
// draw frame of the graph
|
||||||
DrawFrame ( iNumDaysInHistory );
|
DrawFrame ( iNumDaysInHistory );
|
||||||
|
|
||||||
// add markers
|
// add markers
|
||||||
for ( i = 0; i < iNumItemsForHistory; i++ )
|
for ( i = 0; i < iNumItemsForHistory; i++ )
|
||||||
{
|
{
|
||||||
AddMarker ( vHistoryDataFifo[i] );
|
AddMarker ( vHistoryDataFifo[i] );
|
||||||
}
|
}
|
||||||
|
|
||||||
// save graph as picture in file
|
// save graph as picture in file
|
||||||
Save ( sFileName );
|
Save ( sFileName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Server logging --------------------------------------------------------------
|
// Server logging --------------------------------------------------------------
|
||||||
CServerLogging::~CServerLogging()
|
CServerLogging::~CServerLogging()
|
||||||
{
|
{
|
||||||
// close logging file of open
|
// close logging file of open
|
||||||
if ( File.isOpen() )
|
if ( File.isOpen() )
|
||||||
{
|
{
|
||||||
File.close();
|
File.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerLogging::Start ( const QString& strLoggingFileName )
|
void CServerLogging::Start ( const QString& strLoggingFileName )
|
||||||
{
|
{
|
||||||
// open file
|
// open file
|
||||||
File.setFileName ( strLoggingFileName );
|
File.setFileName ( strLoggingFileName );
|
||||||
if ( File.open ( QIODevice::Append | QIODevice::Text ) )
|
if ( File.open ( QIODevice::Append | QIODevice::Text ) )
|
||||||
{
|
{
|
||||||
bDoLogging = true;
|
bDoLogging = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerLogging::EnableHistory ( const QString& strHistoryFileName )
|
void CServerLogging::EnableHistory ( const QString& strHistoryFileName )
|
||||||
{
|
{
|
||||||
HistoryGraph.Start ( strHistoryFileName );
|
HistoryGraph.Start ( strHistoryFileName );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerLogging::AddNewConnection ( const QHostAddress& ClientInetAddr )
|
void CServerLogging::AddNewConnection ( const QHostAddress& ClientInetAddr )
|
||||||
{
|
{
|
||||||
// logging of new connected channel
|
// logging of new connected channel
|
||||||
const QString strLogStr = CurTimeDatetoLogString() + ", " +
|
const QString strLogStr = CurTimeDatetoLogString() + ", " +
|
||||||
ClientInetAddr.toString() + ", connected";
|
ClientInetAddr.toString() + ", connected";
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
QTextStream tsConsoloeStream ( stdout );
|
QTextStream tsConsoloeStream ( stdout );
|
||||||
tsConsoloeStream << strLogStr << endl; // on console
|
tsConsoloeStream << strLogStr << endl; // on console
|
||||||
#endif
|
#endif
|
||||||
*this << strLogStr; // in log file
|
*this << strLogStr; // in log file
|
||||||
|
|
||||||
// add element to history
|
// add element to history
|
||||||
HistoryGraph.Add ( QDateTime::currentDateTime(), ClientInetAddr );
|
HistoryGraph.Add ( QDateTime::currentDateTime(), ClientInetAddr );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerLogging::AddServerStopped()
|
void CServerLogging::AddServerStopped()
|
||||||
{
|
{
|
||||||
const QString strLogStr = CurTimeDatetoLogString() + ",, server stopped "
|
const QString strLogStr = CurTimeDatetoLogString() + ",, server stopped "
|
||||||
"-------------------------------------";
|
"-------------------------------------";
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
QTextStream tsConsoloeStream ( stdout );
|
QTextStream tsConsoloeStream ( stdout );
|
||||||
tsConsoloeStream << strLogStr << endl; // on console
|
tsConsoloeStream << strLogStr << endl; // on console
|
||||||
#endif
|
#endif
|
||||||
*this << strLogStr; // in log file
|
*this << strLogStr; // in log file
|
||||||
|
|
||||||
// add element to history and update on server stop
|
// add element to history and update on server stop
|
||||||
HistoryGraph.Add ( QDateTime::currentDateTime(),
|
HistoryGraph.Add ( QDateTime::currentDateTime(),
|
||||||
CHistoryGraph::HIT_SERVER_STOP );
|
CHistoryGraph::HIT_SERVER_STOP );
|
||||||
|
|
||||||
HistoryGraph.Update();
|
HistoryGraph.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerLogging::operator<< ( const QString& sNewStr )
|
void CServerLogging::operator<< ( const QString& sNewStr )
|
||||||
{
|
{
|
||||||
if ( bDoLogging )
|
if ( bDoLogging )
|
||||||
{
|
{
|
||||||
// append new line in logging file
|
// append new line in logging file
|
||||||
QTextStream out ( &File );
|
QTextStream out ( &File );
|
||||||
out << sNewStr << endl;
|
out << sNewStr << endl;
|
||||||
File.flush();
|
File.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerLogging::ParseLogFile ( const QString& strFileName )
|
void CServerLogging::ParseLogFile ( const QString& strFileName )
|
||||||
{
|
{
|
||||||
// open file for reading
|
// open file for reading
|
||||||
QFile LogFile ( strFileName );
|
QFile LogFile ( strFileName );
|
||||||
LogFile.open ( QIODevice::ReadOnly | QIODevice::Text );
|
LogFile.open ( QIODevice::ReadOnly | QIODevice::Text );
|
||||||
|
|
||||||
QTextStream inStream ( &LogFile );
|
QTextStream inStream ( &LogFile );
|
||||||
|
|
||||||
// read all content from file
|
// read all content from file
|
||||||
while ( !inStream.atEnd() )
|
while ( !inStream.atEnd() )
|
||||||
{
|
{
|
||||||
// get a new line from log file
|
// get a new line from log file
|
||||||
QString strCurLine = inStream.readLine();
|
QString strCurLine = inStream.readLine();
|
||||||
|
|
||||||
// parse log file line
|
// parse log file line
|
||||||
QStringList strlistCurLine = strCurLine.split( "," );
|
QStringList strlistCurLine = strCurLine.split( "," );
|
||||||
|
|
||||||
// check number of separated strings condition
|
// check number of separated strings condition
|
||||||
if ( strlistCurLine.size() == 4 )
|
if ( strlistCurLine.size() == 4 )
|
||||||
{
|
{
|
||||||
// first entry
|
// first entry
|
||||||
QDate curDate =
|
QDate curDate =
|
||||||
QDate::fromString ( strlistCurLine.at ( 0 ).trimmed(),
|
QDate::fromString ( strlistCurLine.at ( 0 ).trimmed(),
|
||||||
"d.M.yyyy" );
|
"d.M.yyyy" );
|
||||||
|
|
||||||
// second entry
|
// second entry
|
||||||
QTime curTime =
|
QTime curTime =
|
||||||
QTime::fromString ( strlistCurLine.at ( 1 ).trimmed(),
|
QTime::fromString ( strlistCurLine.at ( 1 ).trimmed(),
|
||||||
"hh:mm:ss" );
|
"hh:mm:ss" );
|
||||||
|
|
||||||
if ( curDate.isValid() && curTime.isValid() )
|
if ( curDate.isValid() && curTime.isValid() )
|
||||||
{
|
{
|
||||||
QDateTime curDateTime ( curDate, curTime );
|
QDateTime curDateTime ( curDate, curTime );
|
||||||
|
|
||||||
// check if server stop or new client connection
|
// check if server stop or new client connection
|
||||||
QString strAddress = strlistCurLine.at ( 2 ).trimmed();
|
QString strAddress = strlistCurLine.at ( 2 ).trimmed();
|
||||||
if ( strAddress.isEmpty() )
|
if ( strAddress.isEmpty() )
|
||||||
{
|
{
|
||||||
// server stop
|
// server stop
|
||||||
HistoryGraph.Add ( curDateTime,
|
HistoryGraph.Add ( curDateTime,
|
||||||
CHistoryGraph::HIT_SERVER_STOP );
|
CHistoryGraph::HIT_SERVER_STOP );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QHostAddress curAddress;
|
QHostAddress curAddress;
|
||||||
|
|
||||||
// third entry is IP address
|
// third entry is IP address
|
||||||
if ( curAddress.setAddress ( strlistCurLine.at ( 2 ).trimmed() ) )
|
if ( curAddress.setAddress ( strlistCurLine.at ( 2 ).trimmed() ) )
|
||||||
{
|
{
|
||||||
// new client connection
|
// new client connection
|
||||||
HistoryGraph.Add ( curDateTime, curAddress );
|
HistoryGraph.Add ( curDateTime, curAddress );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryGraph.Update();
|
HistoryGraph.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CServerLogging::CurTimeDatetoLogString()
|
QString CServerLogging::CurTimeDatetoLogString()
|
||||||
{
|
{
|
||||||
// time and date to string conversion
|
// time and date to string conversion
|
||||||
const QDateTime curDateTime = QDateTime::currentDateTime();
|
const QDateTime curDateTime = QDateTime::currentDateTime();
|
||||||
|
|
||||||
// format date and time output according to "3.9.2006, 11:38:08"
|
// format date and time output according to "3.9.2006, 11:38:08"
|
||||||
return QString().setNum ( curDateTime.date().day() ) + "." +
|
return QString().setNum ( curDateTime.date().day() ) + "." +
|
||||||
QString().setNum ( curDateTime.date().month() ) + "." +
|
QString().setNum ( curDateTime.date().month() ) + "." +
|
||||||
QString().setNum ( curDateTime.date().year() ) + ", " +
|
QString().setNum ( curDateTime.date().year() ) + ", " +
|
||||||
curDateTime.time().toString();
|
curDateTime.time().toString();
|
||||||
}
|
}
|
||||||
|
|
704
src/settings.cpp
704
src/settings.cpp
|
@ -1,352 +1,352 @@
|
||||||
/******************************************************************************\
|
/******************************************************************************\
|
||||||
* Copyright (c) 2004-2009
|
* Copyright (c) 2004-2009
|
||||||
*
|
*
|
||||||
* Author(s):
|
* Author(s):
|
||||||
* Volker Fischer
|
* Volker Fischer
|
||||||
*
|
*
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under
|
* 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
|
* 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
|
* Foundation; either version 2 of the License, or (at your option) any later
|
||||||
* version.
|
* version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* 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
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
* details.
|
* details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along with
|
* 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.,
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
|
|
||||||
/* Implementation *************************************************************/
|
/* Implementation *************************************************************/
|
||||||
void CSettings::ReadIniFile ( const QString& sFileName )
|
void CSettings::ReadIniFile ( const QString& sFileName )
|
||||||
{
|
{
|
||||||
int iValue;
|
int iValue;
|
||||||
bool bValue;
|
bool bValue;
|
||||||
QDomDocument IniXMLDocument;
|
QDomDocument IniXMLDocument;
|
||||||
|
|
||||||
// load data from init-file
|
// load data from init-file
|
||||||
// prepare file name for loading initialization data from XML file
|
// prepare file name for loading initialization data from XML file
|
||||||
QString sCurFileName = sFileName;
|
QString sCurFileName = sFileName;
|
||||||
if ( sCurFileName.isEmpty() )
|
if ( sCurFileName.isEmpty() )
|
||||||
{
|
{
|
||||||
// if no file name is available, use default file name
|
// if no file name is available, use default file name
|
||||||
sCurFileName = LLCON_INIT_FILE_NAME;
|
sCurFileName = LLCON_INIT_FILE_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read data from file if possible
|
// read data from file if possible
|
||||||
QFile file ( sCurFileName );
|
QFile file ( sCurFileName );
|
||||||
if ( file.open ( QIODevice::ReadOnly ) )
|
if ( file.open ( QIODevice::ReadOnly ) )
|
||||||
{
|
{
|
||||||
QTextStream in ( &file );
|
QTextStream in ( &file );
|
||||||
IniXMLDocument.setContent ( in.readAll(), false );
|
IniXMLDocument.setContent ( in.readAll(), false );
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// actual settings data ---------------------------------------------------
|
// actual settings data ---------------------------------------------------
|
||||||
// IP addresses
|
// IP addresses
|
||||||
for ( int iIPAddrIdx = 0; iIPAddrIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIPAddrIdx++ )
|
for ( int iIPAddrIdx = 0; iIPAddrIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIPAddrIdx++ )
|
||||||
{
|
{
|
||||||
QString sDefaultIP = "";
|
QString sDefaultIP = "";
|
||||||
|
|
||||||
// use default only for first entry
|
// use default only for first entry
|
||||||
if ( iIPAddrIdx == 0 )
|
if ( iIPAddrIdx == 0 )
|
||||||
{
|
{
|
||||||
sDefaultIP = DEFAULT_SERVER_ADDRESS;
|
sDefaultIP = DEFAULT_SERVER_ADDRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
pClient->vstrIPAddress[iIPAddrIdx] =
|
pClient->vstrIPAddress[iIPAddrIdx] =
|
||||||
GetIniSetting ( IniXMLDocument, "client",
|
GetIniSetting ( IniXMLDocument, "client",
|
||||||
QString ( "ipaddress%1" ).arg ( iIPAddrIdx ), sDefaultIP );
|
QString ( "ipaddress%1" ).arg ( iIPAddrIdx ), sDefaultIP );
|
||||||
}
|
}
|
||||||
|
|
||||||
// name
|
// name
|
||||||
pClient->strName = GetIniSetting ( IniXMLDocument, "client", "name" );
|
pClient->strName = GetIniSetting ( IniXMLDocument, "client", "name" );
|
||||||
|
|
||||||
// audio fader
|
// audio fader
|
||||||
if ( GetNumericIniSet ( IniXMLDocument, "client", "audfad",
|
if ( GetNumericIniSet ( IniXMLDocument, "client", "audfad",
|
||||||
AUD_FADER_IN_MIN, AUD_FADER_IN_MAX, iValue ) )
|
AUD_FADER_IN_MIN, AUD_FADER_IN_MAX, iValue ) )
|
||||||
{
|
{
|
||||||
pClient->SetAudioInFader ( iValue );
|
pClient->SetAudioInFader ( iValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
// reverberation level
|
// reverberation level
|
||||||
if ( GetNumericIniSet ( IniXMLDocument, "client", "revlev",
|
if ( GetNumericIniSet ( IniXMLDocument, "client", "revlev",
|
||||||
0, AUD_REVERB_MAX, iValue ) )
|
0, AUD_REVERB_MAX, iValue ) )
|
||||||
{
|
{
|
||||||
pClient->SetReverbLevel ( iValue );
|
pClient->SetReverbLevel ( iValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
// reverberation channel assignment
|
// reverberation channel assignment
|
||||||
if ( GetFlagIniSet ( IniXMLDocument, "client", "reverblchan", bValue ) )
|
if ( GetFlagIniSet ( IniXMLDocument, "client", "reverblchan", bValue ) )
|
||||||
{
|
{
|
||||||
pClient->SetReverbOnLeftChan ( bValue );
|
pClient->SetReverbOnLeftChan ( bValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
// sound card selection
|
// sound card selection
|
||||||
// special case with this setting: the sound card initialization depends on this setting
|
// special case with this setting: the sound card initialization depends on this setting
|
||||||
// call, therefore, if no setting file parameter could be retrieved, the sound card is
|
// call, therefore, if no setting file parameter could be retrieved, the sound card is
|
||||||
// initialized with a default setting defined here
|
// initialized with a default setting defined here
|
||||||
if ( GetNumericIniSet ( IniXMLDocument, "client", "auddevidx",
|
if ( GetNumericIniSet ( IniXMLDocument, "client", "auddevidx",
|
||||||
1, MAX_NUMBER_SOUND_CARDS, iValue ) )
|
1, MAX_NUMBER_SOUND_CARDS, iValue ) )
|
||||||
{
|
{
|
||||||
pClient->SetSndCrdDev ( iValue );
|
pClient->SetSndCrdDev ( iValue );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// use "INVALID_SNC_CARD_DEVICE" to tell the sound card driver that no
|
// use "INVALID_SNC_CARD_DEVICE" to tell the sound card driver that no
|
||||||
// device selection was done previously
|
// device selection was done previously
|
||||||
pClient->SetSndCrdDev ( INVALID_SNC_CARD_DEVICE );
|
pClient->SetSndCrdDev ( INVALID_SNC_CARD_DEVICE );
|
||||||
}
|
}
|
||||||
|
|
||||||
// sound card preferred buffer size index
|
// sound card preferred buffer size index
|
||||||
if ( GetNumericIniSet ( IniXMLDocument, "client", "prefsndcrdbufidx",
|
if ( GetNumericIniSet ( IniXMLDocument, "client", "prefsndcrdbufidx",
|
||||||
FRAME_SIZE_FACTOR_PREFERRED, FRAME_SIZE_FACTOR_SAFE, iValue ) )
|
FRAME_SIZE_FACTOR_PREFERRED, FRAME_SIZE_FACTOR_SAFE, iValue ) )
|
||||||
{
|
{
|
||||||
// additional check required since only a subset of factors are
|
// additional check required since only a subset of factors are
|
||||||
// defined
|
// defined
|
||||||
if ( ( iValue == FRAME_SIZE_FACTOR_PREFERRED ) ||
|
if ( ( iValue == FRAME_SIZE_FACTOR_PREFERRED ) ||
|
||||||
( iValue == FRAME_SIZE_FACTOR_DEFAULT ) ||
|
( iValue == FRAME_SIZE_FACTOR_DEFAULT ) ||
|
||||||
( iValue == FRAME_SIZE_FACTOR_SAFE ) )
|
( iValue == FRAME_SIZE_FACTOR_SAFE ) )
|
||||||
{
|
{
|
||||||
pClient->SetSndCrdPrefFrameSizeFactor ( iValue );
|
pClient->SetSndCrdPrefFrameSizeFactor ( iValue );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// automatic network jitter buffer size setting
|
// automatic network jitter buffer size setting
|
||||||
if ( GetFlagIniSet ( IniXMLDocument, "client", "autojitbuf", bValue ) )
|
if ( GetFlagIniSet ( IniXMLDocument, "client", "autojitbuf", bValue ) )
|
||||||
{
|
{
|
||||||
pClient->SetDoAutoSockBufSize ( bValue );
|
pClient->SetDoAutoSockBufSize ( bValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
// network jitter buffer size
|
// network jitter buffer size
|
||||||
if ( GetNumericIniSet ( IniXMLDocument, "client", "jitbuf",
|
if ( GetNumericIniSet ( IniXMLDocument, "client", "jitbuf",
|
||||||
MIN_NET_BUF_SIZE_NUM_BL, MAX_NET_BUF_SIZE_NUM_BL, iValue ) )
|
MIN_NET_BUF_SIZE_NUM_BL, MAX_NET_BUF_SIZE_NUM_BL, iValue ) )
|
||||||
{
|
{
|
||||||
pClient->SetSockBufNumFrames ( iValue );
|
pClient->SetSockBufNumFrames ( iValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
// flag whether the chat window shall be opened on a new chat message
|
// flag whether the chat window shall be opened on a new chat message
|
||||||
if ( GetFlagIniSet ( IniXMLDocument, "client", "openchatonnewmessage", bValue ) )
|
if ( GetFlagIniSet ( IniXMLDocument, "client", "openchatonnewmessage", bValue ) )
|
||||||
{
|
{
|
||||||
pClient->SetOpenChatOnNewMessage ( bValue );
|
pClient->SetOpenChatOnNewMessage ( bValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
// GUI design
|
// GUI design
|
||||||
if ( GetNumericIniSet ( IniXMLDocument, "client", "guidesign",
|
if ( GetNumericIniSet ( IniXMLDocument, "client", "guidesign",
|
||||||
0, 1 /* GD_ORIGINAL */, iValue ) )
|
0, 1 /* GD_ORIGINAL */, iValue ) )
|
||||||
{
|
{
|
||||||
pClient->SetGUIDesign ( static_cast<EGUIDesign> ( iValue ) );
|
pClient->SetGUIDesign ( static_cast<EGUIDesign> ( iValue ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// flag whether using high quality audio or not
|
// flag whether using high quality audio or not
|
||||||
if ( GetFlagIniSet ( IniXMLDocument, "client", "highqualityaudio", bValue ) )
|
if ( GetFlagIniSet ( IniXMLDocument, "client", "highqualityaudio", bValue ) )
|
||||||
{
|
{
|
||||||
pClient->SetCELTHighQuality ( bValue );
|
pClient->SetCELTHighQuality ( bValue );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettings::WriteIniFile ( const QString& sFileName )
|
void CSettings::WriteIniFile ( const QString& sFileName )
|
||||||
{
|
{
|
||||||
// create XML document for storing initialization parameters
|
// create XML document for storing initialization parameters
|
||||||
QDomDocument IniXMLDocument;
|
QDomDocument IniXMLDocument;
|
||||||
|
|
||||||
|
|
||||||
// actual settings data ---------------------------------------------------
|
// actual settings data ---------------------------------------------------
|
||||||
// IP addresses
|
// IP addresses
|
||||||
for ( int iIPAddrIdx = 0; iIPAddrIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIPAddrIdx++ )
|
for ( int iIPAddrIdx = 0; iIPAddrIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIPAddrIdx++ )
|
||||||
{
|
{
|
||||||
PutIniSetting ( IniXMLDocument, "client",
|
PutIniSetting ( IniXMLDocument, "client",
|
||||||
QString ( "ipaddress%1" ).arg ( iIPAddrIdx ),
|
QString ( "ipaddress%1" ).arg ( iIPAddrIdx ),
|
||||||
pClient->vstrIPAddress[iIPAddrIdx] );
|
pClient->vstrIPAddress[iIPAddrIdx] );
|
||||||
}
|
}
|
||||||
|
|
||||||
// name
|
// name
|
||||||
PutIniSetting ( IniXMLDocument, "client", "name",
|
PutIniSetting ( IniXMLDocument, "client", "name",
|
||||||
pClient->strName );
|
pClient->strName );
|
||||||
|
|
||||||
// audio fader
|
// audio fader
|
||||||
SetNumericIniSet ( IniXMLDocument, "client", "audfad",
|
SetNumericIniSet ( IniXMLDocument, "client", "audfad",
|
||||||
pClient->GetAudioInFader() );
|
pClient->GetAudioInFader() );
|
||||||
|
|
||||||
// reverberation level
|
// reverberation level
|
||||||
SetNumericIniSet ( IniXMLDocument, "client", "revlev",
|
SetNumericIniSet ( IniXMLDocument, "client", "revlev",
|
||||||
pClient->GetReverbLevel() );
|
pClient->GetReverbLevel() );
|
||||||
|
|
||||||
// reverberation channel assignment
|
// reverberation channel assignment
|
||||||
SetFlagIniSet ( IniXMLDocument, "client", "reverblchan",
|
SetFlagIniSet ( IniXMLDocument, "client", "reverblchan",
|
||||||
pClient->IsReverbOnLeftChan() );
|
pClient->IsReverbOnLeftChan() );
|
||||||
|
|
||||||
// sound card selection
|
// sound card selection
|
||||||
SetNumericIniSet ( IniXMLDocument, "client", "auddevidx",
|
SetNumericIniSet ( IniXMLDocument, "client", "auddevidx",
|
||||||
pClient->GetSndCrdDev() );
|
pClient->GetSndCrdDev() );
|
||||||
|
|
||||||
// sound card preferred buffer size index
|
// sound card preferred buffer size index
|
||||||
SetNumericIniSet ( IniXMLDocument, "client", "prefsndcrdbufidx",
|
SetNumericIniSet ( IniXMLDocument, "client", "prefsndcrdbufidx",
|
||||||
pClient->GetSndCrdPrefFrameSizeFactor() );
|
pClient->GetSndCrdPrefFrameSizeFactor() );
|
||||||
|
|
||||||
// automatic network jitter buffer size setting
|
// automatic network jitter buffer size setting
|
||||||
SetFlagIniSet ( IniXMLDocument, "client", "autojitbuf",
|
SetFlagIniSet ( IniXMLDocument, "client", "autojitbuf",
|
||||||
pClient->GetDoAutoSockBufSize() );
|
pClient->GetDoAutoSockBufSize() );
|
||||||
|
|
||||||
// network jitter buffer size
|
// network jitter buffer size
|
||||||
SetNumericIniSet ( IniXMLDocument, "client", "jitbuf",
|
SetNumericIniSet ( IniXMLDocument, "client", "jitbuf",
|
||||||
pClient->GetSockBufNumFrames() );
|
pClient->GetSockBufNumFrames() );
|
||||||
|
|
||||||
// flag whether the chat window shall be opened on a new chat message
|
// flag whether the chat window shall be opened on a new chat message
|
||||||
SetFlagIniSet ( IniXMLDocument, "client", "openchatonnewmessage",
|
SetFlagIniSet ( IniXMLDocument, "client", "openchatonnewmessage",
|
||||||
pClient->GetOpenChatOnNewMessage() );
|
pClient->GetOpenChatOnNewMessage() );
|
||||||
|
|
||||||
// GUI design
|
// GUI design
|
||||||
SetNumericIniSet ( IniXMLDocument, "client", "guidesign",
|
SetNumericIniSet ( IniXMLDocument, "client", "guidesign",
|
||||||
static_cast<int> ( pClient->GetGUIDesign() ) );
|
static_cast<int> ( pClient->GetGUIDesign() ) );
|
||||||
|
|
||||||
// flag whether using high quality audio or not
|
// flag whether using high quality audio or not
|
||||||
SetFlagIniSet ( IniXMLDocument, "client", "highqualityaudio",
|
SetFlagIniSet ( IniXMLDocument, "client", "highqualityaudio",
|
||||||
pClient->GetCELTHighQuality() );
|
pClient->GetCELTHighQuality() );
|
||||||
|
|
||||||
// prepare file name for storing initialization data in XML file
|
// prepare file name for storing initialization data in XML file
|
||||||
QString sCurFileName = sFileName;
|
QString sCurFileName = sFileName;
|
||||||
if ( sCurFileName.isEmpty() )
|
if ( sCurFileName.isEmpty() )
|
||||||
{
|
{
|
||||||
// if no file name is available, use default file name
|
// if no file name is available, use default file name
|
||||||
sCurFileName = LLCON_INIT_FILE_NAME;
|
sCurFileName = LLCON_INIT_FILE_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
// store XML data in file
|
// store XML data in file
|
||||||
QFile file ( sCurFileName );
|
QFile file ( sCurFileName );
|
||||||
if ( file.open ( QIODevice::WriteOnly ) )
|
if ( file.open ( QIODevice::WriteOnly ) )
|
||||||
{
|
{
|
||||||
QTextStream out ( &file );
|
QTextStream out ( &file );
|
||||||
out << IniXMLDocument.toString();
|
out << IniXMLDocument.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettings::SetNumericIniSet ( QDomDocument& xmlFile, const QString& strSection,
|
void CSettings::SetNumericIniSet ( QDomDocument& xmlFile, const QString& strSection,
|
||||||
const QString& strKey, const int iValue )
|
const QString& strKey, const int iValue )
|
||||||
{
|
{
|
||||||
// convert input parameter which is an integer to string and store
|
// convert input parameter which is an integer to string and store
|
||||||
PutIniSetting ( xmlFile, strSection, strKey, QString("%1").arg(iValue) );
|
PutIniSetting ( xmlFile, strSection, strKey, QString("%1").arg(iValue) );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSettings::GetNumericIniSet ( const QDomDocument& xmlFile, const QString& strSection,
|
bool CSettings::GetNumericIniSet ( const QDomDocument& xmlFile, const QString& strSection,
|
||||||
const QString& strKey, const int iRangeStart,
|
const QString& strKey, const int iRangeStart,
|
||||||
const int iRangeStop, int& iValue )
|
const int iRangeStop, int& iValue )
|
||||||
{
|
{
|
||||||
// init return value
|
// init return value
|
||||||
bool bReturn = false;
|
bool bReturn = false;
|
||||||
|
|
||||||
const QString strGetIni = GetIniSetting ( xmlFile, strSection, strKey );
|
const QString strGetIni = GetIniSetting ( xmlFile, strSection, strKey );
|
||||||
|
|
||||||
// check if it is a valid parameter
|
// check if it is a valid parameter
|
||||||
if ( !strGetIni.isEmpty() )
|
if ( !strGetIni.isEmpty() )
|
||||||
{
|
{
|
||||||
// convert string from init file to integer
|
// convert string from init file to integer
|
||||||
iValue = strGetIni.toInt();
|
iValue = strGetIni.toInt();
|
||||||
|
|
||||||
// check range
|
// check range
|
||||||
if ( ( iValue >= iRangeStart ) && ( iValue <= iRangeStop ) )
|
if ( ( iValue >= iRangeStart ) && ( iValue <= iRangeStop ) )
|
||||||
{
|
{
|
||||||
bReturn = true;
|
bReturn = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return bReturn;
|
return bReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettings::SetFlagIniSet ( QDomDocument& xmlFile, const QString& strSection,
|
void CSettings::SetFlagIniSet ( QDomDocument& xmlFile, const QString& strSection,
|
||||||
const QString& strKey, const bool bValue )
|
const QString& strKey, const bool bValue )
|
||||||
{
|
{
|
||||||
// we encode true -> "1" and false -> "0"
|
// we encode true -> "1" and false -> "0"
|
||||||
if ( bValue == true )
|
if ( bValue == true )
|
||||||
{
|
{
|
||||||
PutIniSetting ( xmlFile, strSection, strKey, "1" );
|
PutIniSetting ( xmlFile, strSection, strKey, "1" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PutIniSetting ( xmlFile, strSection, strKey, "0" );
|
PutIniSetting ( xmlFile, strSection, strKey, "0" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSettings::GetFlagIniSet ( const QDomDocument& xmlFile, const QString& strSection,
|
bool CSettings::GetFlagIniSet ( const QDomDocument& xmlFile, const QString& strSection,
|
||||||
const QString& strKey, bool& bValue )
|
const QString& strKey, bool& bValue )
|
||||||
{
|
{
|
||||||
// init return value
|
// init return value
|
||||||
bool bReturn = false;
|
bool bReturn = false;
|
||||||
|
|
||||||
const QString strGetIni = GetIniSetting ( xmlFile, strSection, strKey );
|
const QString strGetIni = GetIniSetting ( xmlFile, strSection, strKey );
|
||||||
|
|
||||||
if ( !strGetIni.isEmpty() )
|
if ( !strGetIni.isEmpty() )
|
||||||
{
|
{
|
||||||
if ( strGetIni.toInt() )
|
if ( strGetIni.toInt() )
|
||||||
{
|
{
|
||||||
bValue = true;
|
bValue = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bValue = false;
|
bValue = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bReturn = true;
|
bReturn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bReturn;
|
return bReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Init-file routines using XML ***********************************************
|
// Init-file routines using XML ***********************************************
|
||||||
QString CSettings::GetIniSetting ( const QDomDocument& xmlFile, const QString& sSection,
|
QString CSettings::GetIniSetting ( const QDomDocument& xmlFile, const QString& sSection,
|
||||||
const QString& sKey, const QString& sDefaultVal )
|
const QString& sKey, const QString& sDefaultVal )
|
||||||
{
|
{
|
||||||
// init return parameter with default value
|
// init return parameter with default value
|
||||||
QString sResult ( sDefaultVal );
|
QString sResult ( sDefaultVal );
|
||||||
|
|
||||||
// get section
|
// get section
|
||||||
QDomElement xmlSection = xmlFile.firstChildElement ( sSection );
|
QDomElement xmlSection = xmlFile.firstChildElement ( sSection );
|
||||||
if ( !xmlSection.isNull() )
|
if ( !xmlSection.isNull() )
|
||||||
{
|
{
|
||||||
// get key
|
// get key
|
||||||
QDomElement xmlKey = xmlSection.firstChildElement ( sKey );
|
QDomElement xmlKey = xmlSection.firstChildElement ( sKey );
|
||||||
if ( !xmlKey.isNull() )
|
if ( !xmlKey.isNull() )
|
||||||
{
|
{
|
||||||
// get value
|
// get value
|
||||||
sResult = xmlKey.text();
|
sResult = xmlKey.text();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sResult;
|
return sResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettings::PutIniSetting ( QDomDocument& xmlFile, const QString& sSection,
|
void CSettings::PutIniSetting ( QDomDocument& xmlFile, const QString& sSection,
|
||||||
const QString& sKey, const QString& sValue )
|
const QString& sKey, const QString& sValue )
|
||||||
{
|
{
|
||||||
// check if section is already there, if not then create it
|
// check if section is already there, if not then create it
|
||||||
QDomElement xmlSection = xmlFile.firstChildElement ( sSection );
|
QDomElement xmlSection = xmlFile.firstChildElement ( sSection );
|
||||||
if ( xmlSection.isNull() )
|
if ( xmlSection.isNull() )
|
||||||
{
|
{
|
||||||
// create new root element and add to document
|
// create new root element and add to document
|
||||||
xmlSection = xmlFile.createElement ( sSection );
|
xmlSection = xmlFile.createElement ( sSection );
|
||||||
xmlFile.appendChild ( xmlSection );
|
xmlFile.appendChild ( xmlSection );
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if key is already there, if not then create it
|
// check if key is already there, if not then create it
|
||||||
QDomElement xmlKey = xmlSection.firstChildElement ( sKey );
|
QDomElement xmlKey = xmlSection.firstChildElement ( sKey );
|
||||||
if ( xmlKey.isNull() )
|
if ( xmlKey.isNull() )
|
||||||
{
|
{
|
||||||
xmlKey = xmlFile.createElement ( sKey );
|
xmlKey = xmlFile.createElement ( sKey );
|
||||||
xmlSection.appendChild ( xmlKey );
|
xmlSection.appendChild ( xmlKey );
|
||||||
}
|
}
|
||||||
|
|
||||||
// add actual data to the key
|
// add actual data to the key
|
||||||
QDomText currentValue = xmlFile.createTextNode ( sValue );
|
QDomText currentValue = xmlFile.createTextNode ( sValue );
|
||||||
xmlKey.appendChild ( currentValue );
|
xmlKey.appendChild ( currentValue );
|
||||||
}
|
}
|
||||||
|
|
1294
src/util.h
1294
src/util.h
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue